@koide-labs/ui 0.0.0 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -3
- package/{src/-types.ts → dist/-types.d.ts} +1 -6
- package/dist/-types.js +1 -0
- package/dist/-utils.d.ts +19 -0
- package/dist/-utils.js +33 -0
- package/dist/Button-DrPFFzo7.js +31 -0
- package/dist/CompositeRoot-CVk5a-pR.js +233 -0
- package/dist/DirectionContext-C2o_MF_i.js +9 -0
- package/dist/FieldItemContext-DAvk99to.js +11 -0
- package/dist/FloatingPortal-tWyuKRSN.js +435 -0
- package/dist/FloatingPortalLite-DVyq6YhV.js +28 -0
- package/dist/InternalBackdrop-jYAiOJ8v.js +574 -0
- package/dist/LabelableContext-BMvjVwor.js +169 -0
- package/dist/ToolbarRootContext-CvvL0Tk1.js +9 -0
- package/dist/clamp-D0KDAQIz.js +6 -0
- package/dist/clsx-OuTLNxxd.js +16 -0
- package/dist/components/accordion/index.d.ts +12 -0
- package/dist/components/accordion/index.js +699 -0
- package/dist/components/alert-dialog/index.d.ts +26 -0
- package/dist/components/alert-dialog/index.js +136 -0
- package/dist/components/anchor/index.d.ts +8 -0
- package/dist/components/anchor/index.js +38 -0
- package/dist/components/avatar/index.d.ts +21 -0
- package/dist/components/avatar/index.js +161 -0
- package/dist/components/badge/index.d.ts +16 -0
- package/dist/components/badge/index.js +40 -0
- package/dist/components/button/index.d.ts +24 -0
- package/dist/components/button/index.js +47 -0
- package/dist/components/checkbox/index.d.ts +9 -0
- package/dist/components/checkbox/index.js +269 -0
- package/dist/components/code/index.d.ts +9 -0
- package/dist/components/code/index.js +10 -0
- package/dist/components/collapse/index.d.ts +11 -0
- package/dist/components/collapse/index.js +41 -0
- package/dist/components/command/index.d.ts +14 -0
- package/dist/components/command/index.js +1695 -0
- package/dist/components/context-menu/index.d.ts +42 -0
- package/dist/components/context-menu/index.js +1444 -0
- package/dist/components/dialog/index.d.ts +48 -0
- package/dist/components/dialog/index.js +138 -0
- package/dist/components/heading/index.d.ts +44 -0
- package/dist/components/heading/index.js +56 -0
- package/dist/components/icon/icon-names.d.ts +1 -0
- package/dist/components/icon/icon-names.js +1 -0
- package/dist/components/icon/index.d.ts +24 -0
- package/dist/components/icon/index.js +43 -0
- package/dist/components/icon-button/index.d.ts +12 -0
- package/dist/components/icon-button/index.js +45 -0
- package/dist/components/inline-code/index.d.ts +6 -0
- package/dist/components/inline-code/index.js +22 -0
- package/dist/components/input/index.d.ts +3 -0
- package/dist/components/input/index.js +119 -0
- package/dist/components/meter/index.d.ts +18 -0
- package/dist/components/meter/index.js +165 -0
- package/dist/components/multiline-input/index.d.ts +6 -0
- package/dist/components/multiline-input/index.js +100 -0
- package/dist/components/number-input/index.d.ts +10 -0
- package/dist/components/number-input/index.js +1169 -0
- package/dist/components/password-input/index.d.ts +2 -0
- package/dist/components/password-input/index.js +29 -0
- package/dist/components/pill/index.d.ts +13 -0
- package/dist/components/pill/index.js +38 -0
- package/dist/components/popover/index.d.ts +21 -0
- package/dist/components/popover/index.js +636 -0
- package/dist/components/preview-card/index.d.ts +17 -0
- package/dist/components/preview-card/index.js +402 -0
- package/dist/components/radio/index.d.ts +13 -0
- package/dist/components/radio/index.js +404 -0
- package/dist/components/search-bar/index.d.ts +12 -0
- package/dist/components/search-bar/index.js +48 -0
- package/dist/components/select/index.d.ts +16 -0
- package/dist/components/select/index.js +1263 -0
- package/dist/components/separator/index.d.ts +7 -0
- package/dist/components/separator/index.js +6 -0
- package/dist/components/slider/index.d.ts +5 -0
- package/dist/components/slider/index.js +902 -0
- package/dist/components/spinner/index.d.ts +2 -0
- package/dist/components/spinner/index.js +13 -0
- package/dist/components/stacked-avatars/index.d.ts +14 -0
- package/dist/components/stacked-avatars/index.js +92 -0
- package/dist/components/status-banner/index.d.ts +17 -0
- package/dist/components/status-banner/index.js +69 -0
- package/dist/components/surface/index.d.ts +27 -0
- package/dist/components/surface/index.js +41 -0
- package/dist/components/switch/index.d.ts +5 -0
- package/dist/components/switch/index.js +196 -0
- package/dist/components/tabs/index.d.ts +18 -0
- package/dist/components/tabs/index.js +509 -0
- package/dist/components/text/index.d.ts +26 -0
- package/dist/components/text/index.js +51 -0
- package/dist/components/theme-provider/index.d.ts +2 -0
- package/dist/components/theme-provider/index.js +6 -0
- package/dist/components/theme-provider/theme-context.d.ts +9 -0
- package/dist/components/theme-provider/theme-context.js +13 -0
- package/dist/components/theme-provider/theme-provider.d.ts +17 -0
- package/dist/components/theme-provider/theme-provider.js +30 -0
- package/dist/components/timestamp/index.d.ts +23 -0
- package/dist/components/timestamp/index.js +1392 -0
- package/dist/components/toast/index.d.ts +2 -0
- package/dist/components/toast/index.js +7 -0
- package/dist/components/toast/toast.d.ts +2 -0
- package/dist/components/toast/toast.js +878 -0
- package/dist/components/toast/use-toast-manager.d.ts +27 -0
- package/dist/components/toast/use-toast-manager.js +4 -0
- package/dist/components/tooltip/index.d.ts +14 -0
- package/dist/components/tooltip/index.js +712 -0
- package/dist/components/tooltip/tooltip-arrow.d.ts +3 -0
- package/dist/components/tooltip/tooltip-arrow.js +6 -0
- package/dist/components/view/index.d.ts +30 -0
- package/dist/components/view/index.js +84 -0
- package/dist/components/visually-hidden/index.d.ts +1 -0
- package/dist/components/visually-hidden/index.js +4 -0
- package/dist/composite-Bx7Szd_T.js +208 -0
- package/dist/composite-C9L5QmZL.js +66 -0
- package/dist/createBaseUIEventDetails-D8M2Yl-a.js +59 -0
- package/dist/detectBrowser-I-s3yzIE.js +43 -0
- package/dist/dialog.css +1 -0
- package/dist/dialog.module-BeF-6XAo.js +415 -0
- package/dist/element-CZEOj04G.js +80 -0
- package/dist/event-CKoGyQEJ.js +30 -0
- package/dist/floating-ui.utils-C7pRWMZ_.js +128 -0
- package/dist/floating-ui.utils.dom-C7FS5id0.js +135 -0
- package/dist/formatErrorMessage-BqPuTBN-.js +7 -0
- package/dist/formatNumber-1UNwjeqf.js +25 -0
- package/dist/getDisabledMountTransitionStyles-YfHPge6T.js +1510 -0
- package/dist/index-BX1XbbRk.js +1206 -0
- package/dist/index-CeuccO-T.js +109 -0
- package/dist/index-DN9Bn1qm.js +29 -0
- package/dist/index-FMoPxlJ2.js +52 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +108 -0
- package/dist/index10.css +1 -0
- package/dist/index11.css +1 -0
- package/dist/index12.css +1 -0
- package/dist/index13.css +1 -0
- package/dist/index14.css +1 -0
- package/dist/index15.css +1 -0
- package/dist/index16.css +1 -0
- package/dist/index17.css +1 -0
- package/dist/index18.css +1 -0
- package/dist/index19.css +1 -0
- package/dist/index2.css +1 -0
- package/dist/index20.css +1 -0
- package/dist/index21.css +1 -0
- package/dist/index22.css +1 -0
- package/dist/index23.css +1 -0
- package/dist/index24.css +1 -0
- package/dist/index25.css +1 -0
- package/dist/index26.css +1 -0
- package/dist/index27.css +1 -0
- package/dist/index28.css +1 -0
- package/dist/index29.css +1 -0
- package/dist/index3.css +1 -0
- package/dist/index30.css +1 -0
- package/dist/index31.css +1 -0
- package/dist/index32.css +1 -0
- package/dist/index33.css +1 -0
- package/dist/index34.css +1 -0
- package/dist/index35.css +1 -0
- package/dist/index36.css +1 -0
- package/dist/index37.css +1 -0
- package/dist/index4.css +1 -0
- package/dist/index5.css +1 -0
- package/dist/index6.css +1 -0
- package/dist/index7.css +1 -0
- package/dist/index8.css +1 -0
- package/dist/index9.css +1 -0
- package/dist/inertValue-BCYGsdmf.js +7 -0
- package/dist/input.css +1 -0
- package/dist/input.module-DDQY_Ij6.js +7 -0
- package/dist/integrations/react-markdown/index.d.ts +5 -0
- package/dist/integrations/react-markdown/index.js +6895 -0
- package/dist/integrations/remix/index.d.ts +9 -0
- package/{src/integrations/remix.ts → dist/integrations/remix/index.js} +7 -4
- package/dist/integrations/tailwind.css +1 -0
- package/dist/integrations/twemoij/index.d.ts +3 -0
- package/dist/integrations/twemoij/index.js +18 -0
- package/dist/isElementDisabled-Cbd8W9kH.js +6 -0
- package/dist/owner-rKN292Q9.js +6 -0
- package/dist/safePolygon-DWy1dGKJ.js +308 -0
- package/dist/styles/core.css +1 -0
- package/dist/styles/tokens.d.ts +400 -0
- package/{src/styles/tokens.ts → dist/styles/tokens.js} +54 -96
- package/dist/toast.css +1 -0
- package/dist/tooltip-arrow-C1qXdi5T.js +24 -0
- package/dist/tooltip-arrow.css +1 -0
- package/dist/transitions.css +1 -0
- package/dist/transitions.module-CWX8e5cx.js +1343 -0
- package/dist/use-toast-manager-Dq-44AuW.js +37 -0
- package/dist/useAnimationFrame-451ugS_6.js +68 -0
- package/dist/useBaseUiId-B7WyxtIE.js +7 -0
- package/dist/useButton-DfIwsdb8.js +127 -0
- package/dist/useCompositeListItem-OkcAim_1.js +148 -0
- package/dist/useControlled-Du4sJyMj.js +31 -0
- package/dist/useHoverReferenceInteraction-SfOBPoXM.js +264 -0
- package/dist/useId-C5kyn6tA.js +22 -0
- package/dist/useIsoLayoutEffect-CIDbvm3Q.js +6 -0
- package/dist/useLabelableId-Ci_jDvmv.js +29 -0
- package/dist/useOnMount-VRW6CK2u.js +8 -0
- package/dist/useOpenChangeComplete-Dse9kY9E.js +61 -0
- package/dist/usePopupAutoResize-CNR6Ekmx.js +85 -0
- package/dist/useRender-CLx7dR_1.js +7 -0
- package/dist/useRenderElement-DwToLA61.js +244 -0
- package/dist/useRole-oDBdbuwQ.js +77 -0
- package/dist/useStableCallback-CkTrVkNX.js +29 -0
- package/dist/useSyncedFloatingRootContext-Dorsv-jf.js +167 -0
- package/dist/useTimeout-CflX-kz3.js +32 -0
- package/dist/useTransitionStatus-CUfcuGAV.js +42 -0
- package/dist/useTypeahead-D85V2IUx.js +333 -0
- package/dist/useValueAsRef-HURLzret.js +19 -0
- package/dist/useValueChanged-DL757-yD.js +14 -0
- package/dist/valueToPercent-DaP9qN4u.js +6 -0
- package/dist/view.css +1 -0
- package/dist/view.module-DfDLgJE0.js +6 -0
- package/dist/visuallyHidden-CpJ-mhai.js +16 -0
- package/dist/warn-CKtX8MLJ.js +11 -0
- package/package.json +18 -2
- package/.husky/pre-commit +0 -1
- package/.storybook/main.ts +0 -25
- package/.storybook/preview-head.html +0 -6
- package/.storybook/preview.tsx +0 -48
- package/.storybook/vitest.setup.ts +0 -8
- package/eslint.config.mjs +0 -29
- package/lint-staged.config.js +0 -15
- package/pnpm-workspace.yaml +0 -2
- package/postcss.config.mjs +0 -7
- package/prettier.config.mjs +0 -24
- package/scripts/build-icon-types.ts +0 -38
- package/src/-utils.tsx +0 -64
- package/src/components/accordion/accordion.module.css +0 -44
- package/src/components/accordion/accordion.stories.tsx +0 -36
- package/src/components/accordion/index.tsx +0 -67
- package/src/components/alert-dialog/alert-dialog.module.css +0 -5
- package/src/components/alert-dialog/alert-dialog.stories.tsx +0 -53
- package/src/components/alert-dialog/index.tsx +0 -138
- package/src/components/anchor/anchor.module.css +0 -18
- package/src/components/anchor/anchor.stories.tsx +0 -28
- package/src/components/anchor/index.tsx +0 -45
- package/src/components/avatar/avatar.module.css +0 -56
- package/src/components/avatar/avatar.stories.tsx +0 -61
- package/src/components/avatar/index.tsx +0 -82
- package/src/components/badge/badge.module.css +0 -35
- package/src/components/badge/badge.stories.tsx +0 -60
- package/src/components/badge/index.tsx +0 -71
- package/src/components/button/button.module.css +0 -42
- package/src/components/button/button.stories.tsx +0 -108
- package/src/components/button/index.tsx +0 -63
- package/src/components/checkbox/checkbox.module.css +0 -36
- package/src/components/checkbox/checkbox.stories.tsx +0 -21
- package/src/components/checkbox/index.tsx +0 -41
- package/src/components/code/code.module.css +0 -20
- package/src/components/code/code.stories.tsx +0 -42
- package/src/components/code/index.tsx +0 -73
- package/src/components/collapse/collapse.module.css +0 -27
- package/src/components/collapse/collapse.stories.tsx +0 -27
- package/src/components/collapse/index.tsx +0 -59
- package/src/components/command/command.module.css +0 -95
- package/src/components/command/command.stories.tsx +0 -38
- package/src/components/command/index.tsx +0 -108
- package/src/components/context-menu/context-menu.module.css +0 -36
- package/src/components/context-menu/context-menu.stories.tsx +0 -99
- package/src/components/context-menu/index.tsx +0 -242
- package/src/components/dialog/dialog.module.css +0 -71
- package/src/components/dialog/dialog.stories.tsx +0 -29
- package/src/components/dialog/index.tsx +0 -148
- package/src/components/heading/heading.module.css +0 -3
- package/src/components/heading/heading.stories.tsx +0 -52
- package/src/components/heading/index.tsx +0 -112
- package/src/components/icon/icon-names.ts +0 -3189
- package/src/components/icon/icon.module.css +0 -36
- package/src/components/icon/icon.stories.tsx +0 -40
- package/src/components/icon/index.tsx +0 -60
- package/src/components/icon-button/icon-button.module.css +0 -33
- package/src/components/icon-button/icon-button.stories.tsx +0 -59
- package/src/components/icon-button/index.tsx +0 -48
- package/src/components/inline-code/index.tsx +0 -29
- package/src/components/inline-code/inline-code.module.css +0 -13
- package/src/components/inline-code/inline-code.stories.tsx +0 -31
- package/src/components/input/index.tsx +0 -22
- package/src/components/input/input.module.css +0 -23
- package/src/components/input/input.stories.tsx +0 -52
- package/src/components/meter/index.tsx +0 -55
- package/src/components/meter/meter.module.css +0 -23
- package/src/components/meter/meter.stories.tsx +0 -31
- package/src/components/multiline-input/index.tsx +0 -58
- package/src/components/multiline-input/multiline-input.stories.tsx +0 -26
- package/src/components/number-input/index.tsx +0 -74
- package/src/components/number-input/number-input.module.css +0 -41
- package/src/components/number-input/number-input.stories.tsx +0 -24
- package/src/components/password-input/index.tsx +0 -24
- package/src/components/password-input/password-input.module.css +0 -10
- package/src/components/password-input/password-input.stories.tsx +0 -24
- package/src/components/pill/index.tsx +0 -45
- package/src/components/pill/pill.module.css +0 -22
- package/src/components/pill/pill.stories.tsx +0 -83
- package/src/components/popover/index.tsx +0 -94
- package/src/components/popover/popover.module.css +0 -8
- package/src/components/popover/popover.stories.tsx +0 -53
- package/src/components/preview-card/index.tsx +0 -68
- package/src/components/preview-card/preview-card.module.css +0 -5
- package/src/components/preview-card/preview-card.stories.tsx +0 -58
- package/src/components/radio/index.tsx +0 -67
- package/src/components/radio/radio-group.module.css +0 -5
- package/src/components/radio/radio.module.css +0 -36
- package/src/components/radio/radio.stories.tsx +0 -27
- package/src/components/search-bar/index.tsx +0 -60
- package/src/components/search-bar/search-bar.module.css +0 -29
- package/src/components/search-bar/search-bar.stories.tsx +0 -37
- package/src/components/select/index.tsx +0 -132
- package/src/components/select/select.module.css +0 -63
- package/src/components/select/select.stories.tsx +0 -49
- package/src/components/separator/index.tsx +0 -28
- package/src/components/separator/separator.module.css +0 -24
- package/src/components/separator/separator.stories.tsx +0 -40
- package/src/components/slider/index.tsx +0 -28
- package/src/components/slider/slider.module.css +0 -52
- package/src/components/slider/slider.stories.tsx +0 -53
- package/src/components/spinner/index.tsx +0 -14
- package/src/components/spinner/spinner.module.css +0 -13
- package/src/components/spinner/spinner.stories.tsx +0 -17
- package/src/components/stacked-avatars/index.tsx +0 -88
- package/src/components/stacked-avatars/stacked-avatars.module.css +0 -79
- package/src/components/stacked-avatars/stacked-avatars.stories.tsx +0 -48
- package/src/components/status-banner/index.tsx +0 -96
- package/src/components/status-banner/status-banner.module.css +0 -52
- package/src/components/status-banner/status-banner.stories.tsx +0 -44
- package/src/components/surface/index.tsx +0 -83
- package/src/components/surface/surface.module.css +0 -35
- package/src/components/surface/surface.stories.tsx +0 -84
- package/src/components/switch/index.tsx +0 -23
- package/src/components/switch/switch.module.css +0 -45
- package/src/components/switch/switch.stories.tsx +0 -48
- package/src/components/tabs/index.tsx +0 -126
- package/src/components/tabs/tabs.module.css +0 -134
- package/src/components/tabs/tabs.stories.tsx +0 -88
- package/src/components/text/index.tsx +0 -69
- package/src/components/text/text.module.css +0 -76
- package/src/components/text/text.stories.tsx +0 -107
- package/src/components/theme-provider/index.ts +0 -2
- package/src/components/theme-provider/theme-context.tsx +0 -18
- package/src/components/theme-provider/theme-provider.stories.tsx +0 -47
- package/src/components/theme-provider/theme-provider.tsx +0 -77
- package/src/components/timestamp/index.tsx +0 -131
- package/src/components/timestamp/timestamp.module.css +0 -8
- package/src/components/timestamp/timestamp.stories.tsx +0 -37
- package/src/components/toast/index.ts +0 -2
- package/src/components/toast/toast.module.css +0 -163
- package/src/components/toast/toast.stories.tsx +0 -53
- package/src/components/toast/toast.tsx +0 -104
- package/src/components/toast/use-toast-manager.ts +0 -63
- package/src/components/tooltip/index.tsx +0 -61
- package/src/components/tooltip/tooltip-arrow.tsx +0 -17
- package/src/components/tooltip/tooltip.module.css +0 -44
- package/src/components/tooltip/tooltip.stories.tsx +0 -76
- package/src/components/view/index.tsx +0 -137
- package/src/components/view/view.module.css +0 -11
- package/src/components/view/view.stories.tsx +0 -131
- package/src/components/view/view_colorway.module.css +0 -280
- package/src/components/view/view_interactive.module.css +0 -127
- package/src/components/view/view_loading.module.css +0 -58
- package/src/components/visually-hidden/index.ts +0 -1
- package/src/index.ts +0 -49
- package/src/integrations/react-markdown/index.tsx +0 -134
- package/src/integrations/react-markdown/react-markdown.module.css +0 -62
- package/src/integrations/react-markdown/react-markdown.stories.tsx +0 -31
- package/src/integrations/tailwind.css +0 -173
- package/src/integrations/twemoij/index.tsx +0 -13
- package/src/integrations/twemoij/twemoji.module.css +0 -7
- package/src/integrations/twemoij/twemoji.stories.tsx +0 -40
- package/src/stories/components/all-variants.tsx +0 -40
- package/src/stories/data.ts +0 -72
- package/src/stories/utils.ts +0 -20
- package/src/styles/core.css +0 -153
- package/src/styles/themes/dark.css +0 -86
- package/src/styles/themes/light.css +0 -86
- package/src/styles/transitions.module.css +0 -31
- package/stylelint.config.mjs +0 -29
- package/tsconfig.app.json +0 -35
- package/tsconfig.json +0 -7
- package/tsconfig.node.json +0 -26
- package/vite.config.ts +0 -103
- package/vitest.shims.d.ts +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koide-labs/ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -12,8 +12,20 @@
|
|
|
12
12
|
"types": "./dist/components/*/index.d.ts",
|
|
13
13
|
"default": "./dist/components/*/index.js"
|
|
14
14
|
},
|
|
15
|
-
"./
|
|
15
|
+
"./integrations/tailwind.css": "./dist/integrations/tailwind.css",
|
|
16
|
+
"./integrations/*": {
|
|
17
|
+
"types": "./dist/integrations/*/index.d.ts",
|
|
18
|
+
"default": "./dist/integrations/*/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./styles/core.css": "./dist/styles/core.css",
|
|
21
|
+
"./styles/tokens": {
|
|
22
|
+
"types": "./dist/styles/tokens.d.ts",
|
|
23
|
+
"default": "./dist/styles/tokens.js"
|
|
24
|
+
}
|
|
16
25
|
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
17
29
|
"packageManager": "pnpm@10.19.0",
|
|
18
30
|
"scripts": {
|
|
19
31
|
"dev": "vite",
|
|
@@ -44,6 +56,10 @@
|
|
|
44
56
|
"react-dom": "^19.2.0",
|
|
45
57
|
"react-markdown": "^10.1.0"
|
|
46
58
|
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"react": "^19.2.0",
|
|
61
|
+
"react-dom": "^19.2.0"
|
|
62
|
+
},
|
|
47
63
|
"devDependencies": {
|
|
48
64
|
"@chromatic-com/storybook": "^4.1.3",
|
|
49
65
|
"@eslint/js": "^9.39.1",
|
package/.husky/pre-commit
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
pnpm exec lint-staged
|
package/.storybook/main.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { withoutVitePlugins } from "@storybook/builder-vite";
|
|
2
|
-
import type { StorybookConfig } from "@storybook/react-vite";
|
|
3
|
-
|
|
4
|
-
const config: StorybookConfig = {
|
|
5
|
-
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
|
|
6
|
-
addons: [
|
|
7
|
-
"@chromatic-com/storybook",
|
|
8
|
-
"@storybook/addon-vitest",
|
|
9
|
-
"@storybook/addon-a11y",
|
|
10
|
-
"@storybook/addon-docs",
|
|
11
|
-
],
|
|
12
|
-
framework: "@storybook/react-vite",
|
|
13
|
-
viteFinal: async (config) => {
|
|
14
|
-
return {
|
|
15
|
-
...config,
|
|
16
|
-
plugins: await withoutVitePlugins(config.plugins, [
|
|
17
|
-
"vite:lib-inject-css",
|
|
18
|
-
]),
|
|
19
|
-
};
|
|
20
|
-
},
|
|
21
|
-
core: {
|
|
22
|
-
disableTelemetry: true,
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
export default config;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
2
|
-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
3
|
-
<link
|
|
4
|
-
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,400;0,500;0,600;1,400;1,500;1,600&family=IBM+Plex+Sans:ital,wght@0,100..700;1,100..700&display=swap"
|
|
5
|
-
rel="stylesheet"
|
|
6
|
-
/>
|
package/.storybook/preview.tsx
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { Preview } from "@storybook/react-vite";
|
|
2
|
-
|
|
3
|
-
import "../src/styles/core.css";
|
|
4
|
-
|
|
5
|
-
const preview: Preview = {
|
|
6
|
-
parameters: {
|
|
7
|
-
controls: {
|
|
8
|
-
matchers: {
|
|
9
|
-
color: /(background|color)$/i,
|
|
10
|
-
date: /Date$/i,
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
a11y: {
|
|
14
|
-
// 'todo' - show a11y violations in the test UI only
|
|
15
|
-
// 'error' - fail CI on a11y violations
|
|
16
|
-
// 'off' - skip a11y checks entirely
|
|
17
|
-
test: "todo",
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
globalTypes: {
|
|
21
|
-
theme: {
|
|
22
|
-
name: "Theme",
|
|
23
|
-
description: "Global theme for components.",
|
|
24
|
-
defaultValue: "light",
|
|
25
|
-
toolbar: {
|
|
26
|
-
icon: "paintbrush",
|
|
27
|
-
items: [
|
|
28
|
-
{ value: "light", title: "Light" },
|
|
29
|
-
{ value: "dark", title: "Dark" },
|
|
30
|
-
],
|
|
31
|
-
showName: true,
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
decorators: [
|
|
36
|
-
(Story, context) => {
|
|
37
|
-
document.body.dataset.theme = context.globals.theme || "light";
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<div className="root">
|
|
41
|
-
<Story />
|
|
42
|
-
</div>
|
|
43
|
-
);
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export default preview;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as a11yAddonAnnotations from "@storybook/addon-a11y/preview";
|
|
2
|
-
import { setProjectAnnotations } from "@storybook/react-vite";
|
|
3
|
-
|
|
4
|
-
import * as projectAnnotations from "./preview";
|
|
5
|
-
|
|
6
|
-
// This is an important step to apply the right configuration when testing your stories.
|
|
7
|
-
// More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
|
|
8
|
-
setProjectAnnotations([a11yAddonAnnotations, projectAnnotations]);
|
package/eslint.config.mjs
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format
|
|
2
|
-
|
|
3
|
-
import js from "@eslint/js";
|
|
4
|
-
import reactHooks from "eslint-plugin-react-hooks";
|
|
5
|
-
import reactRefresh from "eslint-plugin-react-refresh";
|
|
6
|
-
import storybook from "eslint-plugin-storybook";
|
|
7
|
-
import { defineConfig, globalIgnores } from "eslint/config";
|
|
8
|
-
import globals from "globals";
|
|
9
|
-
import tseslint from "typescript-eslint";
|
|
10
|
-
|
|
11
|
-
export default defineConfig([
|
|
12
|
-
globalIgnores(["dist", ".archived", ".husky", "storybook-static"]),
|
|
13
|
-
{
|
|
14
|
-
plugins: {
|
|
15
|
-
storybook: storybook,
|
|
16
|
-
},
|
|
17
|
-
files: ["**/*.{ts,tsx}"],
|
|
18
|
-
extends: [
|
|
19
|
-
js.configs.recommended,
|
|
20
|
-
tseslint.configs.recommended,
|
|
21
|
-
reactHooks.configs.flat.recommended,
|
|
22
|
-
reactRefresh.configs.vite,
|
|
23
|
-
],
|
|
24
|
-
languageOptions: {
|
|
25
|
-
ecmaVersion: 2020,
|
|
26
|
-
globals: globals.browser,
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
]);
|
package/lint-staged.config.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @filename lint-staged.config.cjs
|
|
3
|
-
* @type {import("lint-staged").Configuration}
|
|
4
|
-
*/
|
|
5
|
-
export default {
|
|
6
|
-
"*": ["pnpm run format"],
|
|
7
|
-
/**
|
|
8
|
-
* Feels like it goes against what lint-staged is meant for
|
|
9
|
-
* But its supported and we really should typecheck before committing
|
|
10
|
-
* https://github.com/lint-staged/lint-staged?tab=readme-ov-file#example-run-tsc-on-changes-to-typescript-files-but-do-not-pass-any-filename-arguments
|
|
11
|
-
*/
|
|
12
|
-
"**/*.{ts,tsx}?(x)": () => ["pnpm run typecheck"],
|
|
13
|
-
"**/*.{ts,tsx}": ["pnpm run lint:ts"],
|
|
14
|
-
"**/*.css": ["pnpm run lint:style"],
|
|
15
|
-
};
|
package/pnpm-workspace.yaml
DELETED
package/postcss.config.mjs
DELETED
package/prettier.config.mjs
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import "@ianvs/prettier-plugin-sort-imports";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @filename prettier.config.mjs
|
|
5
|
-
* @type {import("prettier").Config & import("@ianvs/prettier-plugin-sort-imports").PluginConfig}
|
|
6
|
-
*/
|
|
7
|
-
export default {
|
|
8
|
-
singleQuote: false,
|
|
9
|
-
semi: true,
|
|
10
|
-
plugins: ["@ianvs/prettier-plugin-sort-imports", "prettier-plugin-css-order"],
|
|
11
|
-
importOrder: [
|
|
12
|
-
"<BUILTIN_MODULES>", // Node.js built-in modules
|
|
13
|
-
"<THIRD_PARTY_MODULES>", // Imports not matched by other special words or groups.
|
|
14
|
-
"",
|
|
15
|
-
"^~/(.*)$",
|
|
16
|
-
"",
|
|
17
|
-
"^[./](?!.*\\.module\\.css$)",
|
|
18
|
-
"",
|
|
19
|
-
"\\.module\\.css$",
|
|
20
|
-
],
|
|
21
|
-
importOrderParserPlugins: ["typescript", "jsx", "decorators-legacy"],
|
|
22
|
-
importOrderTypeScriptVersion: "5.0.0",
|
|
23
|
-
cssDeclarationSorterOrder: "concentric-css",
|
|
24
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import fs from "fs/promises";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import process from "process";
|
|
4
|
-
import url from "url";
|
|
5
|
-
import * as prettier from "prettier";
|
|
6
|
-
import remixicon from "remixicon/fonts/remixicon.glyph.json";
|
|
7
|
-
|
|
8
|
-
// https://stackoverflow.com/questions/46745014/alternative-for-dirname-in-node-js-when-using-es6-modules
|
|
9
|
-
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
10
|
-
|
|
11
|
-
const PRETTIER_CONFIG = path.resolve(__dirname, "../prettier.config.mjs");
|
|
12
|
-
const EXPORT_FILE = path.resolve(
|
|
13
|
-
__dirname,
|
|
14
|
-
"../src/components/icon/icon-names.ts",
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
async function buildIconTypes() {
|
|
18
|
-
const text = `export type IconName = ${Object.keys(remixicon)
|
|
19
|
-
.map((icon) => `"${icon}"`)
|
|
20
|
-
.join("|")};`;
|
|
21
|
-
const options = await prettier.resolveConfig(PRETTIER_CONFIG);
|
|
22
|
-
const formatted = await prettier.format(text, {
|
|
23
|
-
...options,
|
|
24
|
-
parser: "typescript",
|
|
25
|
-
});
|
|
26
|
-
await fs.writeFile(EXPORT_FILE, formatted);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
buildIconTypes()
|
|
30
|
-
.then(() => {
|
|
31
|
-
console.info("Built icon types.");
|
|
32
|
-
process.exit(0);
|
|
33
|
-
})
|
|
34
|
-
.catch((error) => {
|
|
35
|
-
console.error(error);
|
|
36
|
-
console.error("Failed to build icon types.");
|
|
37
|
-
process.exit(1);
|
|
38
|
-
});
|
package/src/-utils.tsx
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type * as React from "react";
|
|
2
|
-
|
|
3
|
-
import { Text, type TextProps } from "~/components/text";
|
|
4
|
-
|
|
5
|
-
export function omit<T extends object>(
|
|
6
|
-
record: T,
|
|
7
|
-
keys: (keyof T)[],
|
|
8
|
-
): Omit<T, (typeof keys)[number]> {
|
|
9
|
-
const shallowClone = { ...record };
|
|
10
|
-
for (const key of keys) {
|
|
11
|
-
delete shallowClone[key];
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return shallowClone;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function pick<T extends Record<string, string>, K extends keyof T>(
|
|
18
|
-
record: T,
|
|
19
|
-
keys: Array<K>,
|
|
20
|
-
) {
|
|
21
|
-
const result = {} as Pick<T, K>;
|
|
22
|
-
for (const key of keys) {
|
|
23
|
-
if (key in record) {
|
|
24
|
-
result[key] = record[key];
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return result;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Convert a ReactNode into a Text element if it's a string
|
|
32
|
-
* This allows us to accept ReactNode props but properly convert them into text
|
|
33
|
-
* @param node ReactNode to conver to text
|
|
34
|
-
* @param props optional text props
|
|
35
|
-
* @returns ReactNode or Text
|
|
36
|
-
*/
|
|
37
|
-
export function textify(
|
|
38
|
-
node: React.ReactNode,
|
|
39
|
-
props: TextProps = {
|
|
40
|
-
color: "inherit",
|
|
41
|
-
},
|
|
42
|
-
) {
|
|
43
|
-
return typeof node === "string" ? <Text {...props}>{node}</Text> : node;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Merge many refs to pass to one element.
|
|
48
|
-
*
|
|
49
|
-
* Adapted from
|
|
50
|
-
* https://github.com/gregberge/react-merge-refs/blob/main/src/index.tsx
|
|
51
|
-
*/
|
|
52
|
-
export function mergeRefs<T = unknown>(
|
|
53
|
-
...refs: Array<React.RefObject<T> | React.RefAttributes<T>["ref"] | undefined>
|
|
54
|
-
): React.RefCallback<T> {
|
|
55
|
-
return (value) => {
|
|
56
|
-
refs.forEach((ref) => {
|
|
57
|
-
if (typeof ref === "function") {
|
|
58
|
-
ref(value);
|
|
59
|
-
} else if (ref) {
|
|
60
|
-
(ref as React.RefObject<T | null>).current = value;
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
.accordion {
|
|
2
|
-
border-bottom: 1px solid var(--surface-interactive-border);
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.accordion__header {
|
|
6
|
-
display: flex;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.accordion__trigger-icon {
|
|
10
|
-
transform: rotate(-45deg);
|
|
11
|
-
transition: transform var(--transition-duration-snappy)
|
|
12
|
-
var(--transition-timing-function-snappy);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.accordion__trigger {
|
|
16
|
-
flex-grow: 1;
|
|
17
|
-
flex-shrink: 1;
|
|
18
|
-
flex-direction: row;
|
|
19
|
-
justify-content: space-between;
|
|
20
|
-
align-items: center;
|
|
21
|
-
border-radius: 0 !important;
|
|
22
|
-
padding: var(--space-8) var(--space-12);
|
|
23
|
-
line-height: 1;
|
|
24
|
-
|
|
25
|
-
&[data-panel-open] .accordion__trigger-icon {
|
|
26
|
-
transform: rotate(0);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.accordion__panel {
|
|
31
|
-
transition: height var(--transition-duration-chill)
|
|
32
|
-
var(--transition-timing-function-chill);
|
|
33
|
-
height: var(--accordion-panel-height);
|
|
34
|
-
overflow: hidden;
|
|
35
|
-
|
|
36
|
-
&[data-starting-style],
|
|
37
|
-
&[data-ending-style] {
|
|
38
|
-
height: 0;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.accordion__panel-content {
|
|
43
|
-
padding: var(--space-12);
|
|
44
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
-
|
|
3
|
-
import { tokens } from "~/styles/tokens";
|
|
4
|
-
|
|
5
|
-
import { Accordion, AccordionItem } from ".";
|
|
6
|
-
|
|
7
|
-
const meta = {
|
|
8
|
-
title: "Accordion",
|
|
9
|
-
component: Accordion,
|
|
10
|
-
parameters: { layout: "centered" },
|
|
11
|
-
} satisfies Meta<typeof Accordion>;
|
|
12
|
-
|
|
13
|
-
export default meta;
|
|
14
|
-
|
|
15
|
-
type Story = StoryObj<typeof meta>;
|
|
16
|
-
|
|
17
|
-
export const Default: Story = {
|
|
18
|
-
render: () => (
|
|
19
|
-
<Accordion
|
|
20
|
-
multiple
|
|
21
|
-
defaultValue={["item-1"]}
|
|
22
|
-
style={{ width: tokens.space256 }}
|
|
23
|
-
>
|
|
24
|
-
<AccordionItem
|
|
25
|
-
value="item-1"
|
|
26
|
-
header={"I am the header"}
|
|
27
|
-
content={"Hello, I am inside the accordion"}
|
|
28
|
-
/>
|
|
29
|
-
<AccordionItem
|
|
30
|
-
value="item-2"
|
|
31
|
-
header={"I am the header"}
|
|
32
|
-
content={"Hello, I am inside the accordion"}
|
|
33
|
-
/>
|
|
34
|
-
</Accordion>
|
|
35
|
-
),
|
|
36
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { Accordion as AccordionPrimitive } from "@base-ui/react/accordion";
|
|
2
|
-
import clsx from "clsx";
|
|
3
|
-
import type { ComponentProps, ReactNode } from "react";
|
|
4
|
-
|
|
5
|
-
import { textify } from "~/-utils";
|
|
6
|
-
|
|
7
|
-
import { Icon } from "../icon";
|
|
8
|
-
import { Surface } from "../surface";
|
|
9
|
-
import { View } from "../view";
|
|
10
|
-
|
|
11
|
-
import styles from "./accordion.module.css";
|
|
12
|
-
|
|
13
|
-
export const Accordion = AccordionPrimitive.Root;
|
|
14
|
-
|
|
15
|
-
export type AccordionItemProps = Omit<
|
|
16
|
-
ComponentProps<typeof AccordionPrimitive.Item>,
|
|
17
|
-
"render"
|
|
18
|
-
> & {
|
|
19
|
-
/** The content to display in the accordion header trigger. */
|
|
20
|
-
header: ReactNode;
|
|
21
|
-
|
|
22
|
-
/** The content to display within the expandable accordion panel. */
|
|
23
|
-
content: ReactNode;
|
|
24
|
-
|
|
25
|
-
/** Apply className to the accordion trigger */
|
|
26
|
-
className?: string;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export function AccordionItem({
|
|
30
|
-
header,
|
|
31
|
-
content,
|
|
32
|
-
className,
|
|
33
|
-
...props
|
|
34
|
-
}: AccordionItemProps) {
|
|
35
|
-
return (
|
|
36
|
-
<AccordionPrimitive.Item className={styles["accordion"]} {...props}>
|
|
37
|
-
<AccordionPrimitive.Header className={styles["accordion__header"]}>
|
|
38
|
-
<Surface
|
|
39
|
-
elevated
|
|
40
|
-
render={
|
|
41
|
-
<View
|
|
42
|
-
interactive="list-item"
|
|
43
|
-
render={
|
|
44
|
-
<AccordionPrimitive.Trigger
|
|
45
|
-
className={clsx(styles["accordion__trigger"], className)}
|
|
46
|
-
/>
|
|
47
|
-
}
|
|
48
|
-
>
|
|
49
|
-
{textify(header)}
|
|
50
|
-
<Icon
|
|
51
|
-
name="close-line"
|
|
52
|
-
className={styles["accordion__trigger-icon"]}
|
|
53
|
-
/>
|
|
54
|
-
</View>
|
|
55
|
-
}
|
|
56
|
-
/>
|
|
57
|
-
</AccordionPrimitive.Header>
|
|
58
|
-
<AccordionPrimitive.Panel className={styles["accordion__panel"]}>
|
|
59
|
-
<View className={styles["accordion__panel-content"]}>
|
|
60
|
-
{textify(content, {
|
|
61
|
-
multiline: true,
|
|
62
|
-
})}
|
|
63
|
-
</View>
|
|
64
|
-
</AccordionPrimitive.Panel>
|
|
65
|
-
</AccordionPrimitive.Item>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
-
|
|
3
|
-
import { AlertDialog } from ".";
|
|
4
|
-
import { Button } from "../button";
|
|
5
|
-
|
|
6
|
-
const meta = {
|
|
7
|
-
title: "Dialog/Alert Dialog",
|
|
8
|
-
component: AlertDialog,
|
|
9
|
-
parameters: { layout: "centered" },
|
|
10
|
-
argTypes: {
|
|
11
|
-
width: {
|
|
12
|
-
control: "select",
|
|
13
|
-
options: ["sm", "md", "lg"],
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
} satisfies Meta<typeof AlertDialog>;
|
|
17
|
-
|
|
18
|
-
export default meta;
|
|
19
|
-
|
|
20
|
-
type Story = StoryObj<typeof meta>;
|
|
21
|
-
|
|
22
|
-
export const Default: Story = {
|
|
23
|
-
argTypes: {
|
|
24
|
-
children: {
|
|
25
|
-
table: {
|
|
26
|
-
disable: true,
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
trigger: {
|
|
30
|
-
table: {
|
|
31
|
-
disable: true,
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
args: {
|
|
36
|
-
title: "Are you absolutely sure?",
|
|
37
|
-
description:
|
|
38
|
-
"This action cannot be undone. This will permanently delete your account and remove your data from our servers.",
|
|
39
|
-
actions: [{ children: "Cancel" }, { children: "Yes, delete account." }],
|
|
40
|
-
width: "md",
|
|
41
|
-
centered: false,
|
|
42
|
-
},
|
|
43
|
-
render: (props) => (
|
|
44
|
-
<AlertDialog
|
|
45
|
-
{...props}
|
|
46
|
-
trigger={
|
|
47
|
-
<Button leftIcon="delete-bin-line" interactive="red_outline">
|
|
48
|
-
Delete acount
|
|
49
|
-
</Button>
|
|
50
|
-
}
|
|
51
|
-
/>
|
|
52
|
-
),
|
|
53
|
-
};
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { AlertDialog as AlertDialogPrimitive } from "@base-ui/react/alert-dialog";
|
|
2
|
-
import clsx from "clsx";
|
|
3
|
-
import type { ComponentProps } from "react";
|
|
4
|
-
|
|
5
|
-
import { Button, type ButtonProps } from "../button";
|
|
6
|
-
import type { BaseDialogProps } from "../dialog";
|
|
7
|
-
import { Surface } from "../surface";
|
|
8
|
-
import { Text } from "../text";
|
|
9
|
-
import { View } from "../view";
|
|
10
|
-
|
|
11
|
-
import transitionStyles from "../../styles/transitions.module.css";
|
|
12
|
-
import dialogStyles from "../dialog/dialog.module.css";
|
|
13
|
-
import styles from "./alert-dialog.module.css";
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* General guidance:
|
|
17
|
-
*
|
|
18
|
-
* Should you have nested modals? Absolutely not. It's confusing to navigate and
|
|
19
|
-
* obliterates the stacking context by putting multiple root surfaces on top of
|
|
20
|
-
* each other.
|
|
21
|
-
*
|
|
22
|
-
* Should you have payloads? Probably not... Currently unsupported but that
|
|
23
|
-
* style of generalization feels kind of anti-composition
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
export type AlertDialogProps = ComponentProps<
|
|
27
|
-
typeof AlertDialogPrimitive.Root
|
|
28
|
-
> &
|
|
29
|
-
BaseDialogProps & {
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
* The actions to display in the alert dialog. You must have at least two
|
|
33
|
-
* actions. By default, actions will be `interactive` and the last action will
|
|
34
|
-
* have `colorway` "negative_fill".
|
|
35
|
-
*
|
|
36
|
-
*/
|
|
37
|
-
actions: Array<ButtonProps>;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export function AlertDialog({
|
|
41
|
-
title,
|
|
42
|
-
description,
|
|
43
|
-
children,
|
|
44
|
-
actions,
|
|
45
|
-
trigger,
|
|
46
|
-
width = "md",
|
|
47
|
-
background = "root",
|
|
48
|
-
centered = false,
|
|
49
|
-
className,
|
|
50
|
-
...props
|
|
51
|
-
}: AlertDialogProps) {
|
|
52
|
-
if (actions.length < 2) {
|
|
53
|
-
console.error("You must have at least two actions.");
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<AlertDialogPrimitive.Root {...props}>
|
|
58
|
-
{trigger ? <AlertDialogPrimitive.Trigger render={trigger} /> : null}
|
|
59
|
-
<AlertDialogPrimitive.Portal>
|
|
60
|
-
<AlertDialogPrimitive.Backdrop
|
|
61
|
-
className={clsx(
|
|
62
|
-
dialogStyles["dialog__backdrop"],
|
|
63
|
-
transitionStyles["transition_opacity"],
|
|
64
|
-
)}
|
|
65
|
-
/>
|
|
66
|
-
<AlertDialogPrimitive.Popup
|
|
67
|
-
className={clsx(
|
|
68
|
-
dialogStyles["dialog__popup"],
|
|
69
|
-
centered && dialogStyles["dialog__popup_centered"],
|
|
70
|
-
transitionStyles["transition_scale"],
|
|
71
|
-
)}
|
|
72
|
-
>
|
|
73
|
-
<Surface
|
|
74
|
-
background={background}
|
|
75
|
-
className={clsx(
|
|
76
|
-
dialogStyles["dialog__content"],
|
|
77
|
-
dialogStyles[`dialog__content_width_${width}`],
|
|
78
|
-
className,
|
|
79
|
-
)}
|
|
80
|
-
>
|
|
81
|
-
{title || description ? (
|
|
82
|
-
<View className={dialogStyles["dialog__header"]}>
|
|
83
|
-
{title ? (
|
|
84
|
-
<Text render={<AlertDialogPrimitive.Title />} size="2xl">
|
|
85
|
-
{title}
|
|
86
|
-
</Text>
|
|
87
|
-
) : null}
|
|
88
|
-
{description ? (
|
|
89
|
-
<Text
|
|
90
|
-
multiline
|
|
91
|
-
color="dimmer"
|
|
92
|
-
render={<AlertDialogPrimitive.Description />}
|
|
93
|
-
>
|
|
94
|
-
{description}
|
|
95
|
-
</Text>
|
|
96
|
-
) : null}
|
|
97
|
-
</View>
|
|
98
|
-
) : null}
|
|
99
|
-
{children}
|
|
100
|
-
<View className={styles["alert-dialog__actions"]}>
|
|
101
|
-
{actions.map(({ children, ...action }, i) => (
|
|
102
|
-
<AlertDialogClose
|
|
103
|
-
key={i}
|
|
104
|
-
{...getButtonProps(action, i + 1 === actions.length)}
|
|
105
|
-
>
|
|
106
|
-
{children}
|
|
107
|
-
</AlertDialogClose>
|
|
108
|
-
))}
|
|
109
|
-
</View>
|
|
110
|
-
</Surface>
|
|
111
|
-
</AlertDialogPrimitive.Popup>
|
|
112
|
-
</AlertDialogPrimitive.Portal>
|
|
113
|
-
</AlertDialogPrimitive.Root>
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export function AlertDialogClose(props: ButtonProps) {
|
|
118
|
-
return <AlertDialogPrimitive.Close render={<Button {...props} />} />;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Sensible defaults for actions (buttons)
|
|
123
|
-
* @param props Action provided by AlertDialog
|
|
124
|
-
* @param isLast Is this the last action provided in the array?
|
|
125
|
-
* @returns Props with defaults
|
|
126
|
-
*/
|
|
127
|
-
function getButtonProps(props: ButtonProps, isLast?: boolean): ButtonProps {
|
|
128
|
-
if (isLast) {
|
|
129
|
-
return {
|
|
130
|
-
interactive: "negative_fill",
|
|
131
|
-
...props,
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
return {
|
|
135
|
-
interactive: true,
|
|
136
|
-
...props,
|
|
137
|
-
};
|
|
138
|
-
}
|