From a33a0f5a0774ea3c298a220adb92a9974141ba68 Mon Sep 17 00:00:00 2001 From: Severin Landolt <41927988+severinlandolt@users.noreply.github.com> Date: Tue, 16 Apr 2024 08:49:44 +0200 Subject: [PATCH] feat!: Date picker with time (#11) * Update calendar * Update date picker --- package.json | 3 + pnpm-lock.yaml | 327 ++++++++++++++- src/components/Calendar/Calendar.tsx | 18 +- src/components/Calendar/changelog.md | 5 +- src/components/DatePicker/DatePicker.tsx | 392 +++++++++++++++++- src/components/DatePicker/changelog.md | 6 + src/components/DatePicker/datepicker.spec.ts | 48 +++ .../DatePicker/datepicker.stories.tsx | 44 +- .../DatePicker/daterangepicker.stories.tsx | 93 ++++- 9 files changed, 895 insertions(+), 41 deletions(-) diff --git a/package.json b/package.json index 7501243..6cdfb95 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ }, "dependencies": { "@ianvs/prettier-plugin-sort-imports": "^4.2.1", + "@internationalized/date": "^3.5.2", "@radix-ui/react-accordion": "^1.1.2", "@radix-ui/react-checkbox": "^1.0.4", "@radix-ui/react-dialog": "^1.0.5", @@ -27,6 +28,8 @@ "@radix-ui/react-tabs": "^1.0.4", "@radix-ui/react-toast": "^1.1.5", "@radix-ui/react-tooltip": "^1.0.7", + "@react-aria/datepicker": "^3.9.3", + "@react-stately/datepicker": "^3.9.2", "@remixicon/react": "^4.2.0", "@storybook/addon-a11y": "^8.0.6", "@storybook/theming": "^8.0.6", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 77df11e..aa72477 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ dependencies: '@ianvs/prettier-plugin-sort-imports': specifier: ^4.2.1 version: 4.2.1(prettier@3.2.5) + '@internationalized/date': + specifier: ^3.5.2 + version: 3.5.2 '@radix-ui/react-accordion': specifier: ^1.1.2 version: 1.1.2(@types/react-dom@18.2.24)(@types/react@18.2.74)(react-dom@18.2.0)(react@18.2.0) @@ -47,6 +50,12 @@ dependencies: '@radix-ui/react-tooltip': specifier: ^1.0.7 version: 1.0.7(@types/react-dom@18.2.24)(@types/react@18.2.74)(react-dom@18.2.0)(react@18.2.0) + '@react-aria/datepicker': + specifier: ^3.9.3 + version: 3.9.3(react-dom@18.2.0)(react@18.2.0) + '@react-stately/datepicker': + specifier: ^3.9.2 + version: 3.9.2(react@18.2.0) '@remixicon/react': specifier: ^4.2.0 version: 4.2.0(react@18.2.0) @@ -1773,6 +1782,40 @@ packages: resolution: {integrity: sha512-9TANp6GPoMtYzQdt54kfAyMmz1+osLlXdg2ENroU7zzrtflTLrrC/lgrIfaSe+Wu0b89GKccT7vxXA0MoAIO+Q==} dev: false + /@formatjs/ecma402-abstract@1.18.2: + resolution: {integrity: sha512-+QoPW4csYALsQIl8GbN14igZzDbuwzcpWrku9nyMXlaqAlwRBgl5V+p0vWMGFqHOw37czNXaP/lEk4wbLgcmtA==} + dependencies: + '@formatjs/intl-localematcher': 0.5.4 + tslib: 2.6.2 + dev: false + + /@formatjs/fast-memoize@2.2.0: + resolution: {integrity: sha512-hnk/nY8FyrL5YxwP9e4r9dqeM6cAbo8PeU9UjyXojZMNvVad2Z06FAVHyR3Ecw6fza+0GH7vdJgiKIVXTMbSBA==} + dependencies: + tslib: 2.6.2 + dev: false + + /@formatjs/icu-messageformat-parser@2.7.6: + resolution: {integrity: sha512-etVau26po9+eewJKYoiBKP6743I1br0/Ie00Pb/S/PtmYfmjTcOn2YCh2yNkSZI12h6Rg+BOgQYborXk46BvkA==} + dependencies: + '@formatjs/ecma402-abstract': 1.18.2 + '@formatjs/icu-skeleton-parser': 1.8.0 + tslib: 2.6.2 + dev: false + + /@formatjs/icu-skeleton-parser@1.8.0: + resolution: {integrity: sha512-QWLAYvM0n8hv7Nq5BEs4LKIjevpVpbGLAJgOaYzg9wABEoX1j0JO1q2/jVkO6CVlq0dbsxZCngS5aXbysYueqA==} + dependencies: + '@formatjs/ecma402-abstract': 1.18.2 + tslib: 2.6.2 + dev: false + + /@formatjs/intl-localematcher@0.5.4: + resolution: {integrity: sha512-zTwEpWOzZ2CiKcB93BLngUX59hQkuZjT2+SAQEscSm52peDW/getsawMcWF1rGRpMCX6D7nSJA3CzJ8gn13N/g==} + dependencies: + tslib: 2.6.2 + dev: false + /@humanwhocodes/config-array@0.11.14: resolution: {integrity: sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==} engines: {node: '>=10.10.0'} @@ -1813,6 +1856,31 @@ packages: - supports-color dev: false + /@internationalized/date@3.5.2: + resolution: {integrity: sha512-vo1yOMUt2hzp63IutEaTUxROdvQg1qlMRsbCvbay2AK2Gai7wIgCyK5weEX3nHkiLgo4qCXHijFNC/ILhlRpOQ==} + dependencies: + '@swc/helpers': 0.5.9 + dev: false + + /@internationalized/message@3.1.2: + resolution: {integrity: sha512-MHAWsZWz8jf6jFPZqpTudcCM361YMtPIRu9CXkYmKjJ/0R3pQRScV5C0zS+Qi50O5UAm8ecKhkXx6mWDDcF6/g==} + dependencies: + '@swc/helpers': 0.5.9 + intl-messageformat: 10.5.11 + dev: false + + /@internationalized/number@3.5.1: + resolution: {integrity: sha512-N0fPU/nz15SwR9IbfJ5xaS9Ss/O5h1sVXMZf43vc9mxEG48ovglvvzBjF53aHlq20uoR6c+88CrIXipU/LSzwg==} + dependencies: + '@swc/helpers': 0.5.9 + dev: false + + /@internationalized/string@3.2.1: + resolution: {integrity: sha512-vWQOvRIauvFMzOO+h7QrdsJmtN1AXAFVcaLWP9AseRN2o7iHceZ6bIXhBD4teZl8i91A3gxKnWBlGgjCwU6MFQ==} + dependencies: + '@swc/helpers': 0.5.9 + dev: false + /@isaacs/cliui@8.0.2: resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} engines: {node: '>=12'} @@ -2759,6 +2827,248 @@ packages: '@babel/runtime': 7.24.4 dev: false + /@react-aria/datepicker@3.9.3(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-1AjCAizd88ACKjVNhFazX4HZZFwWi2rsSlGCTm66Nx6wm5N/Cpbm466dpYEFyQUsKSOG4CC65G1zfYoMPe48MQ==} + peerDependencies: + react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 + react-dom: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 + dependencies: + '@internationalized/date': 3.5.2 + '@internationalized/number': 3.5.1 + '@internationalized/string': 3.2.1 + '@react-aria/focus': 3.16.2(react@18.2.0) + '@react-aria/form': 3.0.3(react@18.2.0) + '@react-aria/i18n': 3.10.2(react@18.2.0) + '@react-aria/interactions': 3.21.1(react@18.2.0) + '@react-aria/label': 3.7.6(react@18.2.0) + '@react-aria/spinbutton': 3.6.3(react-dom@18.2.0)(react@18.2.0) + '@react-aria/utils': 3.23.2(react@18.2.0) + '@react-stately/datepicker': 3.9.2(react@18.2.0) + '@react-stately/form': 3.0.1(react@18.2.0) + '@react-types/button': 3.9.2(react@18.2.0) + '@react-types/calendar': 3.4.4(react@18.2.0) + '@react-types/datepicker': 3.7.2(react@18.2.0) + '@react-types/dialog': 3.5.8(react@18.2.0) + '@react-types/shared': 3.22.1(react@18.2.0) + '@swc/helpers': 0.5.9 + react: 18.2.0 + react-dom: 18.2.0(react@18.2.0) + dev: false + + /@react-aria/focus@3.16.2(react@18.2.0): + resolution: {integrity: sha512-Rqo9ummmgotESfypzFjI3uh58yMpL+E+lJBbQuXkBM0u0cU2YYzu0uOrFrq3zcHk997udZvq1pGK/R+2xk9B7g==} + peerDependencies: + react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 + dependencies: + '@react-aria/interactions': 3.21.1(react@18.2.0) + '@react-aria/utils': 3.23.2(react@18.2.0) + '@react-types/shared': 3.22.1(react@18.2.0) + '@swc/helpers': 0.5.9 + clsx: 2.1.0 + react: 18.2.0 + dev: false + + /@react-aria/form@3.0.3(react@18.2.0): + resolution: {integrity: sha512-5Q2BHE4TTPDzGY2npCzpRRYshwWUb3SMUA/Cbz7QfEtBk+NYuVaq3KjvqLqgUUdyKtqLZ9Far0kIAexloOC4jw==} + peerDependencies: + react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 + dependencies: + '@react-aria/interactions': 3.21.1(react@18.2.0) + '@react-aria/utils': 3.23.2(react@18.2.0) + '@react-stately/form': 3.0.1(react@18.2.0) + '@react-types/shared': 3.22.1(react@18.2.0) + '@swc/helpers': 0.5.9 + react: 18.2.0 + dev: false + + /@react-aria/i18n@3.10.2(react@18.2.0): + resolution: {integrity: sha512-Z1ormoIvMOI4mEdcFLYsoJy9w/EzBdBmgfLP+S/Ah+1xwQOXpgwZxiKOhYHpWa0lf6hkKJL34N9MHJvCJ5Crvw==} + peerDependencies: + react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 + dependencies: + '@internationalized/date': 3.5.2 + '@internationalized/message': 3.1.2 + '@internationalized/number': 3.5.1 + '@internationalized/string': 3.2.1 + '@react-aria/ssr': 3.9.2(react@18.2.0) + '@react-aria/utils': 3.23.2(react@18.2.0) + '@react-types/shared': 3.22.1(react@18.2.0) + '@swc/helpers': 0.5.9 + react: 18.2.0 + dev: false + + /@react-aria/interactions@3.21.1(react@18.2.0): + resolution: {integrity: sha512-AlHf5SOzsShkHfV8GLLk3v9lEmYqYHURKcXWue0JdYbmquMRkUsf/+Tjl1+zHVAQ8lKqRnPYbTmc4AcZbqxltw==} + peerDependencies: + react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 + dependencies: + '@react-aria/ssr': 3.9.2(react@18.2.0) + '@react-aria/utils': 3.23.2(react@18.2.0) + '@react-types/shared': 3.22.1(react@18.2.0) + '@swc/helpers': 0.5.9 + react: 18.2.0 + dev: false + + /@react-aria/label@3.7.6(react@18.2.0): + resolution: {integrity: sha512-ap9iFS+6RUOqeW/F2JoNpERqMn1PvVIo3tTMrJ1TY1tIwyJOxdCBRgx9yjnPBnr+Ywguep+fkPNNi/m74+tXVQ==} + peerDependencies: + react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 + dependencies: + '@react-aria/utils': 3.23.2(react@18.2.0) + '@react-types/shared': 3.22.1(react@18.2.0) + '@swc/helpers': 0.5.9 + react: 18.2.0 + dev: false + + /@react-aria/live-announcer@3.3.2: + resolution: {integrity: sha512-aOyPcsfyY9tLCBhuUaYCruwcd1IrYLc47Ou+J7wMzjeN9v4lsaEfiN12WFl8pDqOwfy6/7It2wmlm5hOuZY8wQ==} + dependencies: + '@swc/helpers': 0.5.9 + dev: false + + /@react-aria/spinbutton@3.6.3(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-IlfhRu/pc9zOt2C5zSEB7NmmzddvWisGx2iGzw8BwIKMD+cN3uy+Qwp+sG6Z/JzFEBN0F6Mxm3l5lhbiqjpICQ==} + peerDependencies: + react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 + react-dom: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 + dependencies: + '@react-aria/i18n': 3.10.2(react@18.2.0) + '@react-aria/live-announcer': 3.3.2 + '@react-aria/utils': 3.23.2(react@18.2.0) + '@react-types/button': 3.9.2(react@18.2.0) + '@react-types/shared': 3.22.1(react@18.2.0) + '@swc/helpers': 0.5.9 + react: 18.2.0 + react-dom: 18.2.0(react@18.2.0) + dev: false + + /@react-aria/ssr@3.9.2(react@18.2.0): + resolution: {integrity: sha512-0gKkgDYdnq1w+ey8KzG9l+H5Z821qh9vVjztk55rUg71vTk/Eaebeir+WtzcLLwTjw3m/asIjx8Y59y1lJZhBw==} + engines: {node: '>= 12'} + peerDependencies: + react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 + dependencies: + '@swc/helpers': 0.5.9 + react: 18.2.0 + dev: false + + /@react-aria/utils@3.23.2(react@18.2.0): + resolution: {integrity: sha512-yznR9jJ0GG+YJvTMZxijQwVp+ahP66DY0apZf7X+dllyN+ByEDW+yaL1ewYPIpugxVzH5P8jhnBXsIyHKN411g==} + peerDependencies: + react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 + dependencies: + '@react-aria/ssr': 3.9.2(react@18.2.0) + '@react-stately/utils': 3.9.1(react@18.2.0) + '@react-types/shared': 3.22.1(react@18.2.0) + '@swc/helpers': 0.5.9 + clsx: 2.1.0 + react: 18.2.0 + dev: false + + /@react-stately/datepicker@3.9.2(react@18.2.0): + resolution: {integrity: sha512-Z6FrK6Af7R5BizqHhJFCj3Hn32mg5iLSDdEgFQAuO043guOXUKFUAnbxfbQUjL6PGE6QwWMfQD7PPGebHn9Ifw==} + peerDependencies: + react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 + dependencies: + '@internationalized/date': 3.5.2 + '@internationalized/string': 3.2.1 + '@react-stately/form': 3.0.1(react@18.2.0) + '@react-stately/overlays': 3.6.5(react@18.2.0) + '@react-stately/utils': 3.9.1(react@18.2.0) + '@react-types/datepicker': 3.7.2(react@18.2.0) + '@react-types/shared': 3.22.1(react@18.2.0) + '@swc/helpers': 0.5.9 + react: 18.2.0 + dev: false + + /@react-stately/form@3.0.1(react@18.2.0): + resolution: {integrity: sha512-T1Ul2Ou0uE/S4ECLcGKa0OfXjffdjEHfUFZAk7OZl0Mqq/F7dl5WpoLWJ4d4IyvZzGO6anFNenP+vODWbrF3NA==} + peerDependencies: + react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 + dependencies: + '@react-types/shared': 3.22.1(react@18.2.0) + '@swc/helpers': 0.5.9 + react: 18.2.0 + dev: false + + /@react-stately/overlays@3.6.5(react@18.2.0): + resolution: {integrity: sha512-U4rCFj6TPJPXLUvYXAcvh+yP/CO2W+7f0IuqP7ZZGE+Osk9qFkT+zRK5/6ayhBDFpmueNfjIEAzT9gYPQwNHFw==} + peerDependencies: + react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 + dependencies: + '@react-stately/utils': 3.9.1(react@18.2.0) + '@react-types/overlays': 3.8.5(react@18.2.0) + '@swc/helpers': 0.5.9 + react: 18.2.0 + dev: false + + /@react-stately/utils@3.9.1(react@18.2.0): + resolution: {integrity: sha512-yzw75GE0iUWiyps02BOAPTrybcsMIxEJlzXqtvllAb01O9uX5n0i3X+u2eCpj2UoDF4zS08Ps0jPgWxg8xEYtA==} + peerDependencies: + react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 + dependencies: + '@swc/helpers': 0.5.9 + react: 18.2.0 + dev: false + + /@react-types/button@3.9.2(react@18.2.0): + resolution: {integrity: sha512-EnPTkGHZRtiwAoJy5q9lDjoG30bEzA/qnvKG29VVXKYAGeqY2IlFs1ypmU+z1X/CpJgPcG3I5cakM7yTVm3pSg==} + peerDependencies: + react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 + dependencies: + '@react-types/shared': 3.22.1(react@18.2.0) + react: 18.2.0 + dev: false + + /@react-types/calendar@3.4.4(react@18.2.0): + resolution: {integrity: sha512-hV1Thmb/AES5OmfPvvmyjSkmsEULjiDfA7Yyy70L/YKuSNKb7Su+Bf2VnZuDW3ec+GxO4JJNlpJ0AkbphWBvcg==} + peerDependencies: + react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 + dependencies: + '@internationalized/date': 3.5.2 + '@react-types/shared': 3.22.1(react@18.2.0) + react: 18.2.0 + dev: false + + /@react-types/datepicker@3.7.2(react@18.2.0): + resolution: {integrity: sha512-zThqFAdhQL1dqyVDsDSSTdfCjoD6634eyg/B0ZJfQxcLUR/5pch3v/gxBhbyCVDGMNHRWUWIJvY9DVOepuoSug==} + peerDependencies: + react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 + dependencies: + '@internationalized/date': 3.5.2 + '@react-types/calendar': 3.4.4(react@18.2.0) + '@react-types/overlays': 3.8.5(react@18.2.0) + '@react-types/shared': 3.22.1(react@18.2.0) + react: 18.2.0 + dev: false + + /@react-types/dialog@3.5.8(react@18.2.0): + resolution: {integrity: sha512-RX8JsMvty8ADHRqVEkppoynXLtN4IzUh8d5z88UEBbcvWKlHfd6bOBQjQcBH3AUue5wjfpPIt6brw2VzgBY/3Q==} + peerDependencies: + react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 + dependencies: + '@react-types/overlays': 3.8.5(react@18.2.0) + '@react-types/shared': 3.22.1(react@18.2.0) + react: 18.2.0 + dev: false + + /@react-types/overlays@3.8.5(react@18.2.0): + resolution: {integrity: sha512-4D7EEBQigD/m8hE68Ys8eloyyZFHHduqykSIgINJ0edmo0jygRbWlTwuhWFR9USgSP4dK54duN0Mvq0m4HEVEw==} + peerDependencies: + react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 + dependencies: + '@react-types/shared': 3.22.1(react@18.2.0) + react: 18.2.0 + dev: false + + /@react-types/shared@3.22.1(react@18.2.0): + resolution: {integrity: sha512-PCpa+Vo6BKnRMuOEzy5zAZ3/H5tnQg1e80khMhK2xys0j6ZqzkgQC+fHMNZ7VDFNLqqNMj/o0eVeSBDh2POjkw==} + peerDependencies: + react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 + dependencies: + react: 18.2.0 + dev: false + /@remixicon/react@4.2.0(react@18.2.0): resolution: {integrity: sha512-eGhKpZ88OU0qkcY9pJu6khBmItDV82nU130E6C68yc+FbljueHlUYy/4CrJsmf860RIDMay2Rpzl27OSJ81miw==} peerDependencies: @@ -3655,6 +3965,12 @@ packages: file-system-cache: 2.3.0 dev: true + /@swc/helpers@0.5.9: + resolution: {integrity: sha512-XI76sLwMJoLjJTOK5RblBZkouOJG3X3hjxLCzLnyN1ifAiKQc6Hck3uvnU4Z/dV/Dyk36Ffj8FLvDLV2oWvKTw==} + dependencies: + tslib: 2.6.2 + dev: false + /@testing-library/dom@9.3.4: resolution: {integrity: sha512-FlS4ZWlp97iiNWig0Muq8p+3rVDjRiYE+YKGbAqXOu9nwJFFOdL00kFpz42M+4huzYi86vAK1sOOfyOG45muIQ==} engines: {node: '>=14'} @@ -5958,6 +6274,15 @@ packages: side-channel: 1.0.6 dev: true + /intl-messageformat@10.5.11: + resolution: {integrity: sha512-eYq5fkFBVxc7GIFDzpFQkDOZgNayNTQn4Oufe8jw6YY6OHVw70/4pA3FyCsQ0Gb2DnvEJEMmN2tOaXUGByM+kg==} + dependencies: + '@formatjs/ecma402-abstract': 1.18.2 + '@formatjs/fast-memoize': 2.2.0 + '@formatjs/icu-messageformat-parser': 2.7.6 + tslib: 2.6.2 + dev: false + /invariant@2.2.4: resolution: {integrity: sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==} dependencies: @@ -7306,7 +7631,7 @@ packages: date-fns: 3.6.0 react: 18.2.0 dev: false - + /react-docgen-typescript@2.2.2(typescript@5.4.4): resolution: {integrity: sha512-tvg2ZtOpOi6QDwsb3GZhOjDkkX0h8Z2gipvTg6OVMUyoYoURhEiRNePT8NZItTVCDh39JJHnLdfCOkzoLbFnTg==} peerDependencies: diff --git a/src/components/Calendar/Calendar.tsx b/src/components/Calendar/Calendar.tsx index 9a9283e..df54875 100644 --- a/src/components/Calendar/Calendar.tsx +++ b/src/components/Calendar/Calendar.tsx @@ -1,4 +1,4 @@ -// Tremor Raw Calendar [v0.0.0] +// Tremor Raw Calendar [v0.0.1] "use client" @@ -148,8 +148,8 @@ const Calendar = ({ ...classNames, }} components={{ - IconLeft: () => , - IconRight: () => , + IconLeft: () =>