@koide-labs/ui 0.0.0 → 0.0.1
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 +23 -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/README.md
CHANGED
|
@@ -1,11 +1,61 @@
|
|
|
1
1
|
# @koide-labs/ui
|
|
2
2
|
|
|
3
|
-
Accessible, fresh, and simple.
|
|
3
|
+
Accessible, fresh, and simple.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- Consistent design with CSS Modules
|
|
6
|
+
- Token-first development for site-wide theming
|
|
7
|
+
- Accessible components with [Base UI](https://base-ui.com/)
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
## Installation
|
|
8
10
|
|
|
9
11
|
```bash
|
|
10
12
|
pnpm add @koide-labs/ui
|
|
11
13
|
```
|
|
14
|
+
|
|
15
|
+
Because we import CSS modules for each component, you must add this to your Vite config.
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { defineConfig } from "vite";
|
|
19
|
+
|
|
20
|
+
export default defineConfig({
|
|
21
|
+
ssr: {
|
|
22
|
+
noExternal: ["@koide-labs/ui"],
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Styling
|
|
28
|
+
|
|
29
|
+
I highly recommend using TailwindCSS.
|
|
30
|
+
|
|
31
|
+
```css
|
|
32
|
+
@import "tailwindcss" important;
|
|
33
|
+
@import "@koide-labs/integrations/tailwind.css";
|
|
34
|
+
@import "@koide-labs/styles/core.css";
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Fonts
|
|
38
|
+
|
|
39
|
+
- IBM Plex Sans
|
|
40
|
+
- IBM Plex Mono
|
|
41
|
+
|
|
42
|
+
```html
|
|
43
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
44
|
+
<link
|
|
45
|
+
rel="preconnect"
|
|
46
|
+
href="https://fonts.gstatic.com"
|
|
47
|
+
crossorigin="anonymous"
|
|
48
|
+
/>
|
|
49
|
+
<link
|
|
50
|
+
rel="stylesheet"
|
|
51
|
+
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono&family=IBM+Plex+Sans:wght@400;500;600&display=swap"
|
|
52
|
+
/>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Development
|
|
56
|
+
|
|
57
|
+
Run the Storybook development server.
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
pnpm run storybook
|
|
61
|
+
```
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
export type ValueOf<T> = T[keyof T];
|
|
2
|
-
|
|
3
2
|
export type Override<T, U> = Omit<T, keyof U> & U;
|
|
4
|
-
|
|
5
|
-
export type InvertRecord<T extends Record<string, string>> = Record<
|
|
6
|
-
T[keyof T],
|
|
7
|
-
keyof T
|
|
8
|
-
>;
|
|
3
|
+
export type InvertRecord<T extends Record<string, string>> = Record<T[keyof T], keyof T>;
|
package/dist/-types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/dist/-utils.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TextProps } from './components/text';
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
export declare function omit<T extends object>(record: T, keys: (keyof T)[]): Omit<T, (typeof keys)[number]>;
|
|
4
|
+
export declare function pick<T extends Record<string, string>, K extends keyof T>(record: T, keys: Array<K>): Pick<T, K>;
|
|
5
|
+
/**
|
|
6
|
+
* Convert a ReactNode into a Text element if it's a string
|
|
7
|
+
* This allows us to accept ReactNode props but properly convert them into text
|
|
8
|
+
* @param node ReactNode to conver to text
|
|
9
|
+
* @param props optional text props
|
|
10
|
+
* @returns ReactNode or Text
|
|
11
|
+
*/
|
|
12
|
+
export declare function textify(node: React.ReactNode, props?: TextProps): number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Merge many refs to pass to one element.
|
|
15
|
+
*
|
|
16
|
+
* Adapted from
|
|
17
|
+
* https://github.com/gregberge/react-merge-refs/blob/main/src/index.tsx
|
|
18
|
+
*/
|
|
19
|
+
export declare function mergeRefs<T = unknown>(...refs: Array<React.RefObject<T> | React.RefAttributes<T>["ref"] | undefined>): React.RefCallback<T>;
|
package/dist/-utils.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { Text as e } from "./components/text/index.js";
|
|
3
|
+
function s(t, n) {
|
|
4
|
+
const o = { ...t };
|
|
5
|
+
for (const r of n)
|
|
6
|
+
delete o[r];
|
|
7
|
+
return o;
|
|
8
|
+
}
|
|
9
|
+
function u(t, n) {
|
|
10
|
+
const o = {};
|
|
11
|
+
for (const r of n)
|
|
12
|
+
r in t && (o[r] = t[r]);
|
|
13
|
+
return o;
|
|
14
|
+
}
|
|
15
|
+
function l(t, n = {
|
|
16
|
+
// TODO look for any regressions
|
|
17
|
+
color: "inherit"
|
|
18
|
+
}) {
|
|
19
|
+
return typeof t == "string" ? /* @__PURE__ */ i(e, { ...n, children: t }) : t;
|
|
20
|
+
}
|
|
21
|
+
function m(...t) {
|
|
22
|
+
return (n) => {
|
|
23
|
+
t.forEach((o) => {
|
|
24
|
+
typeof o == "function" ? o(n) : o && (o.current = n);
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
m as mergeRefs,
|
|
30
|
+
s as omit,
|
|
31
|
+
u as pick,
|
|
32
|
+
l as textify
|
|
33
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as o from "react";
|
|
2
|
+
import { u as l } from "./useButton-DfIwsdb8.js";
|
|
3
|
+
import { u as c } from "./useRenderElement-DwToLA61.js";
|
|
4
|
+
const m = /* @__PURE__ */ o.forwardRef(function(t, s) {
|
|
5
|
+
const {
|
|
6
|
+
render: B,
|
|
7
|
+
className: b,
|
|
8
|
+
disabled: n = !1,
|
|
9
|
+
focusableWhenDisabled: a = !1,
|
|
10
|
+
nativeButton: r = !0,
|
|
11
|
+
...u
|
|
12
|
+
} = t, e = !!n, {
|
|
13
|
+
getButtonProps: i,
|
|
14
|
+
buttonRef: d
|
|
15
|
+
} = l({
|
|
16
|
+
disabled: e,
|
|
17
|
+
focusableWhenDisabled: a,
|
|
18
|
+
native: r
|
|
19
|
+
}), f = o.useMemo(() => ({
|
|
20
|
+
disabled: e
|
|
21
|
+
}), [e]);
|
|
22
|
+
return c("button", t, {
|
|
23
|
+
state: f,
|
|
24
|
+
ref: [s, d],
|
|
25
|
+
props: [u, i]
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
process.env.NODE_ENV !== "production" && (m.displayName = "Button");
|
|
29
|
+
export {
|
|
30
|
+
m as B
|
|
31
|
+
};
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import * as f from "react";
|
|
2
|
+
import { c as ee, b as Z, E as se, u as ie } from "./useRenderElement-DwToLA61.js";
|
|
3
|
+
import { a as re, C as ae } from "./useButton-DfIwsdb8.js";
|
|
4
|
+
import { u as de, C as le } from "./useCompositeListItem-OkcAim_1.js";
|
|
5
|
+
import { i as ce } from "./isElementDisabled-Cbd8W9kH.js";
|
|
6
|
+
import { u as j } from "./useStableCallback-CkTrVkNX.js";
|
|
7
|
+
import { s as q, A as ue, a as fe, i as J, b as z, c as v, H as he, E as ge, d as $, e as B, V as me, f as Ie, g as pe, h as xe, M as Re } from "./composite-C9L5QmZL.js";
|
|
8
|
+
import { g as Ee, a as ye, c as Ce, b as U, d as be, e as Ae, f as Me, h as Ke, i as _e } from "./composite-Bx7Szd_T.js";
|
|
9
|
+
import { u as He } from "./DirectionContext-C2o_MF_i.js";
|
|
10
|
+
import { jsx as Q } from "react/jsx-runtime";
|
|
11
|
+
function Fe(h = {}) {
|
|
12
|
+
const {
|
|
13
|
+
highlightItemOnHover: g,
|
|
14
|
+
highlightedIndex: r,
|
|
15
|
+
onHighlightedIndexChange: c
|
|
16
|
+
} = re(), {
|
|
17
|
+
ref: C,
|
|
18
|
+
index: t
|
|
19
|
+
} = de(h), d = r === t, b = f.useRef(null), K = ee(C, b);
|
|
20
|
+
return {
|
|
21
|
+
compositeProps: f.useMemo(() => ({
|
|
22
|
+
tabIndex: d ? 0 : -1,
|
|
23
|
+
onFocus() {
|
|
24
|
+
c(t);
|
|
25
|
+
},
|
|
26
|
+
onMouseMove() {
|
|
27
|
+
const s = b.current;
|
|
28
|
+
if (!g || !s)
|
|
29
|
+
return;
|
|
30
|
+
const A = s.hasAttribute("disabled") || s.ariaDisabled === "true";
|
|
31
|
+
!d && !A && s.focus();
|
|
32
|
+
}
|
|
33
|
+
}), [d, c, t, g]),
|
|
34
|
+
compositeRef: K,
|
|
35
|
+
index: t
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const Se = "data-composite-item-active", Oe = [];
|
|
39
|
+
function ke(h) {
|
|
40
|
+
const {
|
|
41
|
+
itemSizes: g,
|
|
42
|
+
cols: r = 1,
|
|
43
|
+
loopFocus: c = !0,
|
|
44
|
+
dense: C = !1,
|
|
45
|
+
orientation: t = "both",
|
|
46
|
+
direction: d,
|
|
47
|
+
highlightedIndex: b,
|
|
48
|
+
onHighlightedIndexChange: K,
|
|
49
|
+
rootRef: k,
|
|
50
|
+
enableHomeAndEndKeys: s = !1,
|
|
51
|
+
stopEventPropagation: A = !1,
|
|
52
|
+
disabledIndices: a,
|
|
53
|
+
modifierKeys: T = Oe
|
|
54
|
+
} = h, [N, G] = f.useState(0), _ = r > 1, R = f.useRef(null), L = ee(R, k), n = f.useRef([]), H = f.useRef(!1), l = b ?? N, E = j((e, i = !1) => {
|
|
55
|
+
if ((K ?? G)(e), i) {
|
|
56
|
+
const m = n.current[e];
|
|
57
|
+
q(R.current, m, d, t);
|
|
58
|
+
}
|
|
59
|
+
}), P = j((e) => {
|
|
60
|
+
if (e.size === 0 || H.current)
|
|
61
|
+
return;
|
|
62
|
+
H.current = !0;
|
|
63
|
+
const i = Array.from(e.keys()), m = i.find((u) => u?.hasAttribute(Se)) ?? null, I = m ? i.indexOf(m) : -1;
|
|
64
|
+
I !== -1 && E(I), q(R.current, m, d, t);
|
|
65
|
+
}), S = f.useMemo(() => ({
|
|
66
|
+
"aria-orientation": t === "both" ? void 0 : t,
|
|
67
|
+
ref: L,
|
|
68
|
+
onFocus(e) {
|
|
69
|
+
!R.current || !J(e.target) || e.target.setSelectionRange(0, e.target.value.length ?? 0);
|
|
70
|
+
},
|
|
71
|
+
onKeyDown(e) {
|
|
72
|
+
const i = s ? ue : fe;
|
|
73
|
+
if (!i.has(e.key) || Te(e, T) || !R.current)
|
|
74
|
+
return;
|
|
75
|
+
const I = d === "rtl", u = I ? $ : v, W = {
|
|
76
|
+
horizontal: u,
|
|
77
|
+
vertical: z,
|
|
78
|
+
both: u
|
|
79
|
+
}[t], M = I ? v : $, Y = {
|
|
80
|
+
horizontal: M,
|
|
81
|
+
vertical: B,
|
|
82
|
+
both: M
|
|
83
|
+
}[t];
|
|
84
|
+
if (J(e.target) && !ce(e.target)) {
|
|
85
|
+
const y = e.target.selectionStart, p = e.target.selectionEnd, V = e.target.value ?? "";
|
|
86
|
+
if (y == null || e.shiftKey || y !== p || e.key !== Y && y < V.length || e.key !== W && y > 0)
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
let o = l;
|
|
90
|
+
const D = Ee(n, a), w = ye(n, a);
|
|
91
|
+
if (_) {
|
|
92
|
+
const y = g || Array.from({
|
|
93
|
+
length: n.current.length
|
|
94
|
+
}, () => ({
|
|
95
|
+
width: 1,
|
|
96
|
+
height: 1
|
|
97
|
+
})), p = Ce(y, r, C), V = p.findIndex((x) => x != null && !U(n, x, a)), ne = p.reduce((x, O, oe) => O != null && !U(n, O, a) ? oe : x, -1);
|
|
98
|
+
o = p[be({
|
|
99
|
+
current: p.map((x) => x ? n.current[x] : null)
|
|
100
|
+
}, {
|
|
101
|
+
event: e,
|
|
102
|
+
orientation: t,
|
|
103
|
+
loopFocus: c,
|
|
104
|
+
cols: r,
|
|
105
|
+
// treat undefined (empty grid spaces) as disabled indices so we
|
|
106
|
+
// don't end up in them
|
|
107
|
+
disabledIndices: Me([...a || n.current.map((x, O) => U(n, O) ? O : void 0), void 0], p),
|
|
108
|
+
minIndex: V,
|
|
109
|
+
maxIndex: ne,
|
|
110
|
+
prevIndex: Ae(
|
|
111
|
+
l > w ? D : l,
|
|
112
|
+
y,
|
|
113
|
+
p,
|
|
114
|
+
r,
|
|
115
|
+
// use a corner matching the edge closest to the direction we're
|
|
116
|
+
// moving in so we don't end up in the same item. Prefer
|
|
117
|
+
// top/left over bottom/right.
|
|
118
|
+
// eslint-disable-next-line no-nested-ternary
|
|
119
|
+
e.key === z ? "bl" : e.key === v ? "tr" : "tl"
|
|
120
|
+
),
|
|
121
|
+
rtl: I
|
|
122
|
+
})];
|
|
123
|
+
}
|
|
124
|
+
const X = {
|
|
125
|
+
horizontal: [u],
|
|
126
|
+
vertical: [z],
|
|
127
|
+
both: [u, z]
|
|
128
|
+
}[t], F = {
|
|
129
|
+
horizontal: [M],
|
|
130
|
+
vertical: [B],
|
|
131
|
+
both: [M, B]
|
|
132
|
+
}[t], te = _ ? i : {
|
|
133
|
+
horizontal: s ? pe : xe,
|
|
134
|
+
vertical: s ? me : Ie,
|
|
135
|
+
both: i
|
|
136
|
+
}[t];
|
|
137
|
+
s && (e.key === he ? o = D : e.key === ge && (o = w)), o === l && (X.includes(e.key) || F.includes(e.key)) && (c && o === w && X.includes(e.key) ? o = D : c && o === D && F.includes(e.key) ? o = w : o = Ke(n, {
|
|
138
|
+
startingIndex: o,
|
|
139
|
+
decrement: F.includes(e.key),
|
|
140
|
+
disabledIndices: a
|
|
141
|
+
})), o !== l && !_e(n, o) && (A && e.stopPropagation(), te.has(e.key) && e.preventDefault(), E(o, !0), queueMicrotask(() => {
|
|
142
|
+
n.current[o]?.focus();
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
}), [r, C, d, a, n, s, l, _, g, c, L, T, E, t, A]);
|
|
146
|
+
return f.useMemo(() => ({
|
|
147
|
+
props: S,
|
|
148
|
+
highlightedIndex: l,
|
|
149
|
+
onHighlightedIndexChange: E,
|
|
150
|
+
elementsRef: n,
|
|
151
|
+
disabledIndices: a,
|
|
152
|
+
onMapChange: P,
|
|
153
|
+
relayKeyboardEvent: S.onKeyDown
|
|
154
|
+
}), [S, l, E, n, a, P]);
|
|
155
|
+
}
|
|
156
|
+
function Te(h, g) {
|
|
157
|
+
for (const r of Re.values())
|
|
158
|
+
if (!g.includes(r) && h.getModifierState(r))
|
|
159
|
+
return !0;
|
|
160
|
+
return !1;
|
|
161
|
+
}
|
|
162
|
+
function Ve(h) {
|
|
163
|
+
const {
|
|
164
|
+
render: g,
|
|
165
|
+
className: r,
|
|
166
|
+
refs: c = Z,
|
|
167
|
+
props: C = Z,
|
|
168
|
+
state: t = se,
|
|
169
|
+
stateAttributesMapping: d,
|
|
170
|
+
highlightedIndex: b,
|
|
171
|
+
onHighlightedIndexChange: K,
|
|
172
|
+
orientation: k,
|
|
173
|
+
dense: s,
|
|
174
|
+
itemSizes: A,
|
|
175
|
+
loopFocus: a,
|
|
176
|
+
cols: T,
|
|
177
|
+
enableHomeAndEndKeys: N,
|
|
178
|
+
onMapChange: G,
|
|
179
|
+
stopEventPropagation: _ = !0,
|
|
180
|
+
rootRef: R,
|
|
181
|
+
disabledIndices: L,
|
|
182
|
+
modifierKeys: n,
|
|
183
|
+
highlightItemOnHover: H = !1,
|
|
184
|
+
tag: l = "div",
|
|
185
|
+
...E
|
|
186
|
+
} = h, P = He(), {
|
|
187
|
+
props: S,
|
|
188
|
+
highlightedIndex: e,
|
|
189
|
+
onHighlightedIndexChange: i,
|
|
190
|
+
elementsRef: m,
|
|
191
|
+
onMapChange: I,
|
|
192
|
+
relayKeyboardEvent: u
|
|
193
|
+
} = ke({
|
|
194
|
+
itemSizes: A,
|
|
195
|
+
cols: T,
|
|
196
|
+
loopFocus: a,
|
|
197
|
+
dense: s,
|
|
198
|
+
orientation: k,
|
|
199
|
+
highlightedIndex: b,
|
|
200
|
+
onHighlightedIndexChange: K,
|
|
201
|
+
rootRef: R,
|
|
202
|
+
stopEventPropagation: _,
|
|
203
|
+
enableHomeAndEndKeys: N,
|
|
204
|
+
direction: P,
|
|
205
|
+
disabledIndices: L,
|
|
206
|
+
modifierKeys: n
|
|
207
|
+
}), W = ie(l, h, {
|
|
208
|
+
state: t,
|
|
209
|
+
ref: c,
|
|
210
|
+
props: [S, ...C, E],
|
|
211
|
+
stateAttributesMapping: d
|
|
212
|
+
}), M = f.useMemo(() => ({
|
|
213
|
+
highlightedIndex: e,
|
|
214
|
+
onHighlightedIndexChange: i,
|
|
215
|
+
highlightItemOnHover: H,
|
|
216
|
+
relayKeyboardEvent: u
|
|
217
|
+
}), [e, i, H, u]);
|
|
218
|
+
return /* @__PURE__ */ Q(ae.Provider, {
|
|
219
|
+
value: M,
|
|
220
|
+
children: /* @__PURE__ */ Q(le, {
|
|
221
|
+
elementsRef: m,
|
|
222
|
+
onMapChange: (Y) => {
|
|
223
|
+
G?.(Y), I(Y);
|
|
224
|
+
},
|
|
225
|
+
children: W
|
|
226
|
+
})
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
export {
|
|
230
|
+
Se as A,
|
|
231
|
+
Ve as C,
|
|
232
|
+
Fe as u
|
|
233
|
+
};
|