diff --git a/TODO.md b/TODO.md index ab23284..857c456 100644 --- a/TODO.md +++ b/TODO.md @@ -41,13 +41,16 @@ - [X] Slider - [X] Spinner - [ ] Matrix2D +- Presentation + - [ ] Tabs + - [ ] Accordion - Rating - [ ] Rating -- RichText +- RichText (extract to own package) - [ ] RichTextInput - Temporal - [ ] Calendar - - [ ] DateDropdown + - [X] DateDropdown - [ ] DateTimeRangeInput - [ ] MonthInput - [ ] MonthDayInput diff --git a/categories/color/react/src/components/Swatch/index.tsx b/categories/color/react/src/components/Swatch/index.tsx index 138f851..abecc72 100644 --- a/categories/color/react/src/components/Swatch/index.tsx +++ b/categories/color/react/src/components/Swatch/index.tsx @@ -24,6 +24,7 @@ export const useSwatchControls = () => { }; export const Swatch = React.forwardRef(({ + // todo unify color and mode into one "value" attribute color, mode = 'rgb', className, diff --git a/categories/temporal/react/.eslintrc b/categories/temporal/react/.eslintrc new file mode 100644 index 0000000..f16a3e8 --- /dev/null +++ b/categories/temporal/react/.eslintrc @@ -0,0 +1,13 @@ +{ + "root": true, + "rules": { + "quote-props": "off", + "react/jsx-props-no-spreading": "off" + }, + "extends": [ + "lxsmnsyc/typescript/react" + ], + "parserOptions": { + "project": "./tsconfig.eslint.json" + } +} diff --git a/categories/temporal/react/.gitignore b/categories/temporal/react/.gitignore new file mode 100644 index 0000000..53992de --- /dev/null +++ b/categories/temporal/react/.gitignore @@ -0,0 +1,107 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.production +.env.development + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# Next.js build output +.next + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and *not* Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +.npmrc diff --git a/categories/temporal/react/LICENSE b/categories/temporal/react/LICENSE new file mode 100644 index 0000000..f24dd21 --- /dev/null +++ b/categories/temporal/react/LICENSE @@ -0,0 +1,7 @@ +MIT License Copyright (c) 2023 TheoryOfNekomata + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/categories/temporal/react/package.json b/categories/temporal/react/package.json new file mode 100644 index 0000000..163a615 --- /dev/null +++ b/categories/temporal/react/package.json @@ -0,0 +1,81 @@ +{ + "name": "@tesseract-design/web-temporal-react", + "version": "0.0.0", + "files": [ + "dist", + "src" + ], + "engines": { + "node": ">=12" + }, + "license": "MIT", + "keywords": [ + "pridepack" + ], + "devDependencies": { + "@testing-library/jest-dom": "^5.16.5", + "@testing-library/react": "^13.4.0", + "@types/node": "^18.14.1", + "@types/react": "^18.0.27", + "eslint": "^8.35.0", + "eslint-config-lxsmnsyc": "^0.5.0", + "jsdom": "^21.1.0", + "pridepack": "2.4.4", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "react-test-renderer": "^18.2.0", + "tslib": "^2.5.0", + "typescript": "^4.9.5", + "vitest": "^0.28.1" + }, + "peerDependencies": { + "react": "^16.8 || ^17.0 || ^18.0", + "react-dom": "^16.8 || ^17.0 || ^18.0" + }, + "scripts": { + "prepublishOnly": "pridepack clean && pridepack build", + "build": "pridepack build", + "type-check": "pridepack check", + "lint": "pridepack lint", + "clean": "pridepack clean", + "watch": "pridepack watch", + "start": "pridepack start", + "dev": "pridepack dev", + "test": "vitest" + }, + "private": false, + "description": "Tesseract components for inputting temporal data.", + "repository": { + "url": "", + "type": "git" + }, + "homepage": "", + "bugs": { + "url": "" + }, + "author": "TheoryOfNekomata ", + "publishConfig": { + "access": "public" + }, + "dependencies": { + "clsx": "^1.2.1", + "@tesseract-design/web-base": "workspace:*" + }, + "types": "./dist/types/index.d.ts", + "main": "./dist/cjs/production/index.js", + "module": "./dist/esm/production/index.js", + "exports": { + ".": { + "development": { + "require": "./dist/cjs/development/index.js", + "import": "./dist/esm/development/index.js" + }, + "require": "./dist/cjs/production/index.js", + "import": "./dist/esm/production/index.js", + "types": "./dist/types/index.d.ts" + } + }, + "typesVersions": { + "*": {} + } +} diff --git a/categories/temporal/react/pridepack.json b/categories/temporal/react/pridepack.json new file mode 100644 index 0000000..841fb58 --- /dev/null +++ b/categories/temporal/react/pridepack.json @@ -0,0 +1,3 @@ +{ + "target": "es2018" +} \ No newline at end of file diff --git a/categories/temporal/react/src/components/DateDropdown/index.tsx b/categories/temporal/react/src/components/DateDropdown/index.tsx new file mode 100644 index 0000000..0dc448b --- /dev/null +++ b/categories/temporal/react/src/components/DateDropdown/index.tsx @@ -0,0 +1,229 @@ +import * as React from 'react'; +import { TextControl } from '@tesseract-design/web-base'; +import clsx from 'clsx'; + +export type DateDropdownDerivedElement = HTMLInputElement; + +export interface DateDropdownProps extends Omit, 'size' | 'type' | 'label'> { + /** + * Short textual description indicating the nature of the component's value. + */ + label?: React.ReactNode, + /** + * Short textual description as guidelines for valid input values. + */ + hint?: React.ReactNode, + /** + * Size of the component. + */ + size?: TextControl.Size, + /** + * Additional description, usually graphical, indicating the nature of the component's value. + */ + indicator?: React.ReactNode, + /** + * Should the component display a border? + */ + border?: boolean, + /** + * Should the component occupy the whole width of its parent? + */ + block?: boolean, + /** + * Style of the component. + */ + variant?: TextControl.Variant, + /** + * Is the label hidden? + */ + hiddenLabel?: boolean, +} + +/** + * Component for inputting textual values. + */ +export const DateDropdown = React.forwardRef< + DateDropdownDerivedElement, + DateDropdownProps +>(( + { + label, + hint, + indicator, + size = 'medium' as const, + border = false, + block = false, + variant = 'default' as const, + hiddenLabel = false, + className, + id: idProp, + style, + onFocus, + onClick, + ...etcProps + }: DateDropdownProps, + forwardedRef, +) => { + const labelId = React.useId(); + const defaultId = React.useId(); + const id = idProp ?? defaultId; + + const handleFocus: React.FocusEventHandler = (e) => { + e.currentTarget.showPicker(); + onFocus?.(e); + }; + + const handleClick: React.MouseEventHandler = (e) => { + e.currentTarget.showPicker(); + onClick?.(e); + }; + + return ( +
+ + { + label && ( + + ) + } + {hint && ( +
+
+ {hint} +
+
+ )} + {indicator && ( +
+ {indicator} +
+ )} + { + border && ( + + ) + } +
+ ); +}); + +DateDropdown.displayName = 'DateDropdown'; + +DateDropdown.defaultProps = { + label: undefined, + hint: undefined, + size: 'medium', + indicator: undefined, + border: false, + block: false, + variant: 'default', + hiddenLabel: false, +}; diff --git a/categories/temporal/react/src/index.ts b/categories/temporal/react/src/index.ts new file mode 100644 index 0000000..61f534c --- /dev/null +++ b/categories/temporal/react/src/index.ts @@ -0,0 +1 @@ +export * from './components/DateDropdown'; diff --git a/categories/temporal/react/tsconfig.eslint.json b/categories/temporal/react/tsconfig.eslint.json new file mode 100644 index 0000000..16f2e87 --- /dev/null +++ b/categories/temporal/react/tsconfig.eslint.json @@ -0,0 +1,21 @@ +{ + "exclude": ["node_modules"], + "include": ["src", "types", "test"], + "compilerOptions": { + "module": "ESNext", + "lib": ["DOM", "ESNext"], + "importHelpers": true, + "declaration": true, + "sourceMap": true, + "rootDir": "./", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "moduleResolution": "node", + "jsx": "react", + "esModuleInterop": true, + "target": "es2018" + } +} diff --git a/categories/temporal/react/tsconfig.json b/categories/temporal/react/tsconfig.json new file mode 100644 index 0000000..0ed68f4 --- /dev/null +++ b/categories/temporal/react/tsconfig.json @@ -0,0 +1,21 @@ +{ + "exclude": ["node_modules"], + "include": ["src", "types"], + "compilerOptions": { + "module": "ESNext", + "lib": ["DOM", "ESNext"], + "importHelpers": true, + "declaration": true, + "sourceMap": true, + "rootDir": "./src", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "moduleResolution": "node", + "jsx": "react", + "esModuleInterop": true, + "target": "es2018" + } +} diff --git a/categories/temporal/react/vitest.config.ts b/categories/temporal/react/vitest.config.ts new file mode 100644 index 0000000..a104d21 --- /dev/null +++ b/categories/temporal/react/vitest.config.ts @@ -0,0 +1,8 @@ +/// + +export default ({ + test: { + global: true, + environment: 'jsdom', + }, +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6046bcc..edde644 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -559,6 +559,58 @@ importers: specifier: ^0.28.1 version: 0.28.1(jsdom@21.1.0) + categories/temporal/react: + dependencies: + '@tesseract-design/web-base': + specifier: workspace:* + version: link:../../../base + clsx: + specifier: ^1.2.1 + version: 1.2.1 + devDependencies: + '@testing-library/jest-dom': + specifier: ^5.16.5 + version: 5.16.5 + '@testing-library/react': + specifier: ^13.4.0 + version: 13.4.0(react-dom@18.2.0)(react@18.2.0) + '@types/node': + specifier: ^18.14.1 + version: 18.14.1 + '@types/react': + specifier: ^18.0.27 + version: 18.2.14 + eslint: + specifier: ^8.35.0 + version: 8.43.0 + eslint-config-lxsmnsyc: + specifier: ^0.5.0 + version: 0.5.0(eslint@8.43.0)(typescript@4.9.5) + jsdom: + specifier: ^21.1.0 + version: 21.1.0 + pridepack: + specifier: 2.4.4 + version: 2.4.4(eslint@8.43.0)(tslib@2.6.0)(typescript@4.9.5) + react: + specifier: ^18.2.0 + version: 18.2.0 + react-dom: + specifier: ^18.2.0 + version: 18.2.0(react@18.2.0) + react-test-renderer: + specifier: ^18.2.0 + version: 18.2.0(react@18.2.0) + tslib: + specifier: ^2.5.0 + version: 2.6.0 + typescript: + specifier: ^4.9.5 + version: 4.9.5 + vitest: + specifier: ^0.28.1 + version: 0.28.1(jsdom@21.1.0) + packages/audio-utils: dependencies: wavesurfer.js: @@ -1029,6 +1081,9 @@ importers: '@tesseract-design/web-number-react': specifier: workspace:* version: link:../../categories/number/react + '@tesseract-design/web-temporal-react': + specifier: workspace:* + version: link:../../categories/temporal/react '@theoryofnekomata/formxtra': specifier: ^1.0.3 version: 1.0.3 @@ -2060,7 +2115,6 @@ packages: typescript: 4.9.5 transitivePeerDependencies: - supports-color - dev: true /@typescript-eslint/parser@5.60.1(eslint@8.43.0)(typescript@5.1.3): resolution: {integrity: sha512-pHWlc3alg2oSMGwsU/Is8hbm3XFbcrb6P5wIxcQW9NsYBfnrubl/GhVVD/Jm/t8HXhA2WncoIRfBtnCgRGV96Q==} @@ -2080,6 +2134,7 @@ packages: typescript: 5.1.3 transitivePeerDependencies: - supports-color + dev: false /@typescript-eslint/scope-manager@5.60.1: resolution: {integrity: sha512-Dn/LnN7fEoRD+KspEOV0xDMynEmR3iSHdgNsarlXNLGGtcUok8L4N71dxUgt3YvlO8si7E+BJ5Fe3wb5yUw7DQ==} @@ -2131,7 +2186,6 @@ packages: typescript: 4.9.5 transitivePeerDependencies: - supports-color - dev: true /@typescript-eslint/typescript-estree@5.60.1(typescript@5.1.3): resolution: {integrity: sha512-hkX70J9+2M2ZT6fhti5Q2FoU9zb+GeZK2SLP1WZlvUDqdMbEKhexZODD1WodNRyO8eS+4nScvT0dts8IdaBzfw==} @@ -2152,6 +2206,7 @@ packages: typescript: 5.1.3 transitivePeerDependencies: - supports-color + dev: false /@typescript-eslint/utils@5.60.1(eslint@8.43.0)(typescript@4.9.5): resolution: {integrity: sha512-tiJ7FFdFQOWssFa3gqb94Ilexyw0JVxj6vBzaSpfN/8IhoKkDuSAenUKvsSHw2A/TMpJb26izIszTXaqygkvpQ==} @@ -3327,7 +3382,7 @@ packages: eslint: 8.43.0 eslint-import-resolver-node: 0.3.7 eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@5.60.1)(eslint-import-resolver-node@0.3.7)(eslint-plugin-import@2.27.5)(eslint@8.43.0) - eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.60.1)(eslint-import-resolver-typescript@3.5.5)(eslint@8.43.0) + eslint-plugin-import: 2.27.5(eslint@8.43.0) eslint-plugin-jsx-a11y: 6.7.1(eslint@8.43.0) eslint-plugin-react: 7.32.2(eslint@8.43.0) eslint-plugin-react-hooks: 4.6.0(eslint@8.43.0) @@ -3412,7 +3467,7 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 5.60.1(eslint@8.43.0)(typescript@5.1.3) + '@typescript-eslint/parser': 5.60.1(eslint@8.43.0)(typescript@4.9.5) debug: 3.2.7 eslint: 8.43.0 eslint-import-resolver-node: 0.3.7 @@ -3447,7 +3502,38 @@ packages: '@typescript-eslint/parser': optional: true dependencies: - '@typescript-eslint/parser': 5.60.1(eslint@8.43.0)(typescript@5.1.3) + '@typescript-eslint/parser': 5.60.1(eslint@8.43.0)(typescript@4.9.5) + array-includes: 3.1.6 + array.prototype.flat: 1.3.1 + array.prototype.flatmap: 1.3.1 + debug: 3.2.7 + doctrine: 2.1.0 + eslint: 8.43.0 + eslint-import-resolver-node: 0.3.7 + eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.60.1)(eslint-import-resolver-node@0.3.7)(eslint-import-resolver-typescript@3.5.5)(eslint@8.43.0) + has: 1.0.3 + is-core-module: 2.12.1 + is-glob: 4.0.3 + minimatch: 3.1.2 + object.values: 1.1.6 + resolve: 1.22.2 + semver: 6.3.0 + tsconfig-paths: 3.14.2 + transitivePeerDependencies: + - eslint-import-resolver-typescript + - eslint-import-resolver-webpack + - supports-color + + /eslint-plugin-import@2.27.5(eslint@8.43.0): + resolution: {integrity: sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow==} + engines: {node: '>=4'} + peerDependencies: + '@typescript-eslint/parser': '*' + eslint: ^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 + peerDependenciesMeta: + '@typescript-eslint/parser': + optional: true + dependencies: array-includes: 3.1.6 array.prototype.flat: 1.3.1 array.prototype.flatmap: 1.3.1 @@ -3468,6 +3554,7 @@ packages: - eslint-import-resolver-typescript - eslint-import-resolver-webpack - supports-color + dev: false /eslint-plugin-jest@25.7.0(@typescript-eslint/eslint-plugin@5.60.1)(eslint@8.43.0)(typescript@4.9.5): resolution: {integrity: sha512-PWLUEXeeF7C9QGKqvdSbzLOiLTx+bno7/HC9eefePfEb257QFHg7ye3dh80AZVkaa/RQsBB1Q/ORQvg2X7F0NQ==} @@ -6195,7 +6282,6 @@ packages: dependencies: tslib: 1.14.1 typescript: 4.9.5 - dev: true /tsutils@3.21.0(typescript@5.1.3): resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} @@ -6205,6 +6291,7 @@ packages: dependencies: tslib: 1.14.1 typescript: 5.1.3 + dev: false /tsx@3.12.7: resolution: {integrity: sha512-C2Ip+jPmqKd1GWVQDvz/Eyc6QJbGfE7NrR3fx5BpEHMZsEHoIxHL1j+lKdGobr8ovEyqeNkPLSKp6SCSOt7gmw==} @@ -6259,12 +6346,12 @@ packages: resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} engines: {node: '>=4.2.0'} hasBin: true - dev: true /typescript@5.1.3: resolution: {integrity: sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw==} engines: {node: '>=14.17'} hasBin: true + dev: false /ufo@1.1.2: resolution: {integrity: sha512-TrY6DsjTQQgyS3E3dBaOXf0TpPD8u9FVrVYmKVegJuFw51n/YB9XPt+U6ydzFG5ZIN7+DIjPbNmXoBj9esYhgQ==} diff --git a/showcases/web-kitchensink-reactnext/package.json b/showcases/web-kitchensink-reactnext/package.json index 053a64f..44327e8 100644 --- a/showcases/web-kitchensink-reactnext/package.json +++ b/showcases/web-kitchensink-reactnext/package.json @@ -27,6 +27,7 @@ "@tesseract-design/web-multichoice-react": "workspace:*", "@tesseract-design/web-navigation-react": "workspace:*", "@tesseract-design/web-number-react": "workspace:*", + "@tesseract-design/web-temporal-react": "workspace:*", "@theoryofnekomata/formxtra": "^1.0.3", "@types/node": "20.3.1", "@types/react": "18.2.14", diff --git a/showcases/web-kitchensink-reactnext/src/pages/categories/temporal/index.tsx b/showcases/web-kitchensink-reactnext/src/pages/categories/temporal/index.tsx new file mode 100644 index 0000000..c1d8701 --- /dev/null +++ b/showcases/web-kitchensink-reactnext/src/pages/categories/temporal/index.tsx @@ -0,0 +1,20 @@ +import {NextPage} from 'next'; +import {DefaultLayout} from '@/components/DefaultLayout'; +import {Section, Subsection} from '@/components/Section'; +import * as Temporal from '@tesseract-design/web-temporal-react'; + +const TemporalPage: NextPage = () => { + return ( + +
+ + + +
+
+ ) +} + +export default TemporalPage;