@accelint/design-system 0.1.0 → 0.1.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/dist/assets/components/button/button.css +55 -0
- package/dist/assets/components/checkbox/checkbox.css +73 -0
- package/dist/assets/components/chip/chip.css +62 -0
- package/dist/assets/components/combo-box/combo-box.css +66 -0
- package/dist/assets/components/dialog/dialog.css +51 -0
- package/dist/assets/components/drawer/drawer.css +135 -0
- package/dist/assets/components/group/group.css +33 -0
- package/dist/assets/components/icon/icon.css +19 -0
- package/dist/assets/components/input/input.css +29 -0
- package/dist/assets/components/menu/menu.css +83 -0
- package/dist/assets/components/options/options.css +80 -0
- package/dist/assets/components/picker/picker.css +47 -0
- package/dist/assets/components/popover/popover.css +26 -0
- package/dist/assets/components/query-builder/query-builder.css +129 -0
- package/dist/assets/components/radio/radio.css +67 -0
- package/dist/assets/components/search-field/search-field.css +62 -0
- package/dist/assets/components/select/select.css +33 -0
- package/dist/assets/components/switch/switch.css +62 -0
- package/dist/assets/components/tabs/tabs.css +144 -0
- package/dist/assets/components/textarea/textarea.css +32 -0
- package/dist/assets/components/tooltip/tooltip.css +54 -0
- package/dist/assets/components/tree/tree.css +157 -0
- package/dist/assets/hooks/use-theme/use-theme.css +6 -0
- package/dist/assets/src/components/button/button.css.ts.vanilla-9uttMYGm.css +55 -0
- package/dist/assets/src/components/checkbox/checkbox.css.ts.vanilla-Bewmypyn.css +73 -0
- package/dist/assets/src/components/chip/chip.css.ts.vanilla-CsGhxrlu.css +62 -0
- package/dist/assets/src/components/combo-box/combo-box.css.ts.vanilla-BNEPKjPm.css +66 -0
- package/dist/assets/src/components/dialog/dialog.css.ts.vanilla-CG0m-NJD.css +51 -0
- package/dist/assets/src/components/drawer/drawer.css.ts.vanilla-DEfHnoNS.css +135 -0
- package/dist/assets/src/components/group/group.css.ts.vanilla-DR69xgQy.css +33 -0
- package/dist/assets/src/components/icon/icon.css.ts.vanilla-CoUAfp2F.css +19 -0
- package/dist/assets/src/components/input/input.css.ts.vanilla-DoK5h9SX.css +29 -0
- package/dist/assets/src/components/menu/menu.css.ts.vanilla-CSnDqc5E.css +83 -0
- package/dist/assets/src/components/options/options.css.ts.vanilla-ngVt12W4.css +80 -0
- package/dist/assets/src/components/picker/picker.css.ts.vanilla-Fe0YXv-c.css +47 -0
- package/dist/assets/src/components/popover/popover.css.ts.vanilla-C5YGwwVD.css +26 -0
- package/dist/assets/src/components/query-builder/query-builder.css.ts.vanilla-B3P9cbCv.css +129 -0
- package/dist/assets/src/components/radio/radio.css.ts.vanilla-gi-KedQc.css +67 -0
- package/dist/assets/src/components/search-field/search-field.css.ts.vanilla-B_JL53f8.css +62 -0
- package/dist/assets/src/components/select/select.css.ts.vanilla-C94A60jf.css +33 -0
- package/dist/assets/src/components/switch/switch.css.ts.vanilla-DkQwtRa6.css +62 -0
- package/dist/assets/src/components/tabs/tabs.css.ts.vanilla-BygIflpl.css +144 -0
- package/dist/assets/src/components/textarea/textarea.css.ts.vanilla-Ba6E5HFc.css +32 -0
- package/dist/assets/src/components/tooltip/tooltip.css.ts.vanilla-BntxAlwN.css +54 -0
- package/dist/assets/src/components/tree/tree.css.ts.vanilla-SLmhk0zZ.css +157 -0
- package/dist/assets/src/hooks/use-theme/use-theme.css.ts.vanilla-zkVHnGkP.css +6 -0
- package/dist/assets/src/styles/layers.css.ts.vanilla-B2GUgnOF.css +21 -0
- package/dist/assets/src/styles/reset.css.ts.vanilla-C8PShXm0.css +31 -0
- package/dist/assets/src/styles/space.css.ts.vanilla-Md6Whc4G.css +18 -0
- package/dist/assets/src/styles/surfaces.css.ts.vanilla-Ckztx7VT.css +24 -0
- package/dist/assets/src/styles/theme.css.ts.vanilla-aDPSIzBK.css +208 -0
- package/dist/assets/src/styles/typography.css.ts.vanilla-DRT9H7rd.css +150 -0
- package/dist/assets/styles/layers.css +21 -0
- package/dist/assets/styles/reset.css +31 -0
- package/dist/assets/styles/space.css +18 -0
- package/dist/assets/styles/surfaces.css +24 -0
- package/dist/assets/styles/theme.css +208 -0
- package/dist/assets/styles/typography.css +150 -0
- package/dist/components/aria/aria.d.ts +19 -0
- package/dist/components/aria/aria.js +36 -0
- package/dist/components/aria/aria.js.map +1 -0
- package/dist/components/aria/index.d.ts +1 -0
- package/dist/components/button/button.css.d.ts +33 -0
- package/dist/components/button/button.d.ts +39 -0
- package/dist/components/button/button.js +71 -0
- package/dist/components/button/button.js.map +1 -0
- package/dist/components/button/button.vanilla.js +8 -0
- package/dist/components/button/button.vanilla.js.map +1 -0
- package/dist/components/button/index.d.ts +3 -0
- package/dist/components/button/types.d.ts +28 -0
- package/dist/components/checkbox/checkbox.css.d.ts +35 -0
- package/dist/components/checkbox/checkbox.d.ts +21 -0
- package/dist/components/checkbox/checkbox.js +68 -0
- package/dist/components/checkbox/checkbox.js.map +1 -0
- package/dist/components/checkbox/checkbox.vanilla.js +9 -0
- package/dist/components/checkbox/checkbox.vanilla.js.map +1 -0
- package/dist/components/checkbox/index.d.ts +3 -0
- package/dist/components/checkbox/types.d.ts +38 -0
- package/dist/components/chip/chip.css.d.ts +31 -0
- package/dist/components/chip/chip.d.ts +30 -0
- package/dist/components/chip/chip.js +106 -0
- package/dist/components/chip/chip.js.map +1 -0
- package/dist/components/chip/chip.vanilla.js +8 -0
- package/dist/components/chip/chip.vanilla.js.map +1 -0
- package/dist/components/chip/index.d.ts +3 -0
- package/dist/components/chip/types.d.ts +31 -0
- package/dist/components/collection/collection.d.ts +13 -0
- package/dist/components/collection/collection.js +15 -0
- package/dist/components/collection/collection.js.map +1 -0
- package/dist/components/collection/index.d.ts +1 -0
- package/dist/components/combo-box/combo-box.css.d.ts +22 -0
- package/dist/components/combo-box/combo-box.d.ts +8 -0
- package/dist/components/combo-box/combo-box.js +87 -0
- package/dist/components/combo-box/combo-box.js.map +1 -0
- package/dist/components/combo-box/combo-box.vanilla.js +8 -0
- package/dist/components/combo-box/combo-box.vanilla.js.map +1 -0
- package/dist/components/combo-box/index.d.ts +3 -0
- package/dist/components/combo-box/types.d.ts +32 -0
- package/dist/components/dialog/dialog.css.d.ts +34 -0
- package/dist/components/dialog/dialog.d.ts +18 -0
- package/dist/components/dialog/dialog.js +146 -0
- package/dist/components/dialog/dialog.js.map +1 -0
- package/dist/components/dialog/dialog.vanilla.js +8 -0
- package/dist/components/dialog/dialog.vanilla.js.map +1 -0
- package/dist/components/dialog/index.d.ts +3 -0
- package/dist/components/dialog/types.d.ts +48 -0
- package/dist/components/drawer/drawer.css.d.ts +33 -0
- package/dist/components/drawer/drawer.d.ts +13 -0
- package/dist/components/drawer/drawer.js +199 -0
- package/dist/components/drawer/drawer.js.map +1 -0
- package/dist/components/drawer/drawer.vanilla.js +10 -0
- package/dist/components/drawer/drawer.vanilla.js.map +1 -0
- package/dist/components/drawer/index.d.ts +3 -0
- package/dist/components/drawer/types.d.ts +71 -0
- package/dist/components/element/element.d.ts +11 -0
- package/dist/components/element/element.js +21 -0
- package/dist/components/element/element.js.map +1 -0
- package/dist/components/element/index.d.ts +2 -0
- package/dist/components/element/types.d.ts +21 -0
- package/dist/components/group/group.css.d.ts +14 -0
- package/dist/components/group/group.d.ts +10 -0
- package/dist/components/group/group.js +44 -0
- package/dist/components/group/group.js.map +1 -0
- package/dist/components/group/group.vanilla.js +7 -0
- package/dist/components/group/group.vanilla.js.map +1 -0
- package/dist/components/group/index.d.ts +3 -0
- package/dist/components/group/types.d.ts +35 -0
- package/dist/components/icon/icon.css.d.ts +18 -0
- package/dist/components/icon/icon.d.ts +12 -0
- package/dist/components/icon/icon.js +26 -0
- package/dist/components/icon/icon.js.map +1 -0
- package/dist/components/icon/icon.vanilla.js +8 -0
- package/dist/components/icon/icon.vanilla.js.map +1 -0
- package/dist/components/icon/index.d.ts +3 -0
- package/dist/components/icon/types.d.ts +13 -0
- package/dist/components/index.d.ts +26 -0
- package/dist/components/input/index.d.ts +3 -0
- package/dist/components/input/input.css.d.ts +29 -0
- package/dist/components/input/input.d.ts +8 -0
- package/dist/components/input/input.js +93 -0
- package/dist/components/input/input.js.map +1 -0
- package/dist/components/input/input.vanilla.js +8 -0
- package/dist/components/input/input.vanilla.js.map +1 -0
- package/dist/components/input/types.d.ts +44 -0
- package/dist/components/menu/index.d.ts +3 -0
- package/dist/components/menu/menu.css.d.ts +71 -0
- package/dist/components/menu/menu.d.ts +24 -0
- package/dist/components/menu/menu.js +155 -0
- package/dist/components/menu/menu.js.map +1 -0
- package/dist/components/menu/menu.vanilla.js +8 -0
- package/dist/components/menu/menu.vanilla.js.map +1 -0
- package/dist/components/menu/types.d.ts +48 -0
- package/dist/components/merge-provider/index.d.ts +2 -0
- package/dist/components/merge-provider/merge-provider.d.ts +14 -0
- package/dist/components/merge-provider/merge-provider.js +40 -0
- package/dist/components/merge-provider/merge-provider.js.map +1 -0
- package/dist/components/merge-provider/types.d.ts +5 -0
- package/dist/components/options/index.d.ts +3 -0
- package/dist/components/options/options.css.d.ts +75 -0
- package/dist/components/options/options.d.ts +20 -0
- package/dist/components/options/options.js +152 -0
- package/dist/components/options/options.js.map +1 -0
- package/dist/components/options/options.vanilla.js +10 -0
- package/dist/components/options/options.vanilla.js.map +1 -0
- package/dist/components/options/types.d.ts +49 -0
- package/dist/components/picker/index.d.ts +3 -0
- package/dist/components/picker/picker.css.d.ts +32 -0
- package/dist/components/picker/picker.d.ts +18 -0
- package/dist/components/picker/picker.js +46 -0
- package/dist/components/picker/picker.js.map +1 -0
- package/dist/components/picker/picker.stories.css.d.ts +3 -0
- package/dist/components/picker/picker.vanilla.js +9 -0
- package/dist/components/picker/picker.vanilla.js.map +1 -0
- package/dist/components/picker/types.d.ts +28 -0
- package/dist/components/popover/index.d.ts +3 -0
- package/dist/components/popover/popover.css.d.ts +31 -0
- package/dist/components/popover/popover.d.ts +8 -0
- package/dist/components/popover/popover.js +110 -0
- package/dist/components/popover/popover.js.map +1 -0
- package/dist/components/popover/popover.vanilla.js +7 -0
- package/dist/components/popover/popover.vanilla.js.map +1 -0
- package/dist/components/popover/types.d.ts +32 -0
- package/dist/components/query-builder/action-element.d.ts +2 -0
- package/dist/components/query-builder/action-element.js +12 -0
- package/dist/components/query-builder/action-element.js.map +1 -0
- package/dist/components/query-builder/constants.d.ts +4 -0
- package/dist/components/query-builder/constants.js +20 -0
- package/dist/components/query-builder/constants.js.map +1 -0
- package/dist/components/query-builder/dataset-sample.d.ts +91 -0
- package/dist/components/query-builder/group.d.ts +5 -0
- package/dist/components/query-builder/group.js +87 -0
- package/dist/components/query-builder/group.js.map +1 -0
- package/dist/components/query-builder/index.d.ts +5 -0
- package/dist/components/query-builder/query-builder.css.d.ts +91 -0
- package/dist/components/query-builder/query-builder.d.ts +2 -0
- package/dist/components/query-builder/query-builder.js +129 -0
- package/dist/components/query-builder/query-builder.js.map +1 -0
- package/dist/components/query-builder/query-builder.vanilla.js +10 -0
- package/dist/components/query-builder/query-builder.vanilla.js.map +1 -0
- package/dist/components/query-builder/rule.d.ts +3 -0
- package/dist/components/query-builder/rule.js +112 -0
- package/dist/components/query-builder/rule.js.map +1 -0
- package/dist/components/query-builder/types.d.ts +128 -0
- package/dist/components/query-builder/utils.d.ts +29 -0
- package/dist/components/query-builder/utils.js +22 -0
- package/dist/components/query-builder/utils.js.map +1 -0
- package/dist/components/query-builder/value-editor.d.ts +4 -0
- package/dist/components/query-builder/value-editor.js +74 -0
- package/dist/components/query-builder/value-editor.js.map +1 -0
- package/dist/components/query-builder/value-selector.d.ts +2 -0
- package/dist/components/query-builder/value-selector.js +28 -0
- package/dist/components/query-builder/value-selector.js.map +1 -0
- package/dist/components/radio/index.d.ts +3 -0
- package/dist/components/radio/radio.css.d.ts +34 -0
- package/dist/components/radio/radio.d.ts +16 -0
- package/dist/components/radio/radio.js +63 -0
- package/dist/components/radio/radio.js.map +1 -0
- package/dist/components/radio/radio.vanilla.js +8 -0
- package/dist/components/radio/radio.vanilla.js.map +1 -0
- package/dist/components/radio/types.d.ts +29 -0
- package/dist/components/search-field/index.d.ts +3 -0
- package/dist/components/search-field/search-field.css.d.ts +16 -0
- package/dist/components/search-field/search-field.d.ts +9 -0
- package/dist/components/search-field/search-field.js +60 -0
- package/dist/components/search-field/search-field.js.map +1 -0
- package/dist/components/search-field/search-field.vanilla.js +7 -0
- package/dist/components/search-field/search-field.vanilla.js.map +1 -0
- package/dist/components/search-field/types.d.ts +29 -0
- package/dist/components/select/index.d.ts +3 -0
- package/dist/components/select/select.css.d.ts +25 -0
- package/dist/components/select/select.d.ts +8 -0
- package/dist/components/select/select.js +80 -0
- package/dist/components/select/select.js.map +1 -0
- package/dist/components/select/select.vanilla.js +8 -0
- package/dist/components/select/select.vanilla.js.map +1 -0
- package/dist/components/select/types.d.ts +30 -0
- package/dist/components/switch/index.d.ts +3 -0
- package/dist/components/switch/switch.css.d.ts +25 -0
- package/dist/components/switch/switch.d.ts +4 -0
- package/dist/components/switch/switch.js +34 -0
- package/dist/components/switch/switch.js.map +1 -0
- package/dist/components/switch/switch.vanilla.js +8 -0
- package/dist/components/switch/switch.vanilla.js.map +1 -0
- package/dist/components/switch/types.d.ts +17 -0
- package/dist/components/tabs/index.d.ts +3 -0
- package/dist/components/tabs/tabs.css.d.ts +49 -0
- package/dist/components/tabs/tabs.d.ts +68 -0
- package/dist/components/tabs/tabs.js +108 -0
- package/dist/components/tabs/tabs.js.map +1 -0
- package/dist/components/tabs/tabs.vanilla.js +11 -0
- package/dist/components/tabs/tabs.vanilla.js.map +1 -0
- package/dist/components/tabs/types.d.ts +82 -0
- package/dist/components/textarea/index.d.ts +3 -0
- package/dist/components/textarea/textarea.css.d.ts +31 -0
- package/dist/components/textarea/textarea.d.ts +14 -0
- package/dist/components/textarea/textarea.js +86 -0
- package/dist/components/textarea/textarea.js.map +1 -0
- package/dist/components/textarea/textarea.vanilla.js +8 -0
- package/dist/components/textarea/textarea.vanilla.js.map +1 -0
- package/dist/components/textarea/types.d.ts +39 -0
- package/dist/components/tooltip/index.d.ts +3 -0
- package/dist/components/tooltip/tooltip.css.d.ts +23 -0
- package/dist/components/tooltip/tooltip.d.ts +23 -0
- package/dist/components/tooltip/tooltip.js +69 -0
- package/dist/components/tooltip/tooltip.js.map +1 -0
- package/dist/components/tooltip/tooltip.vanilla.js +8 -0
- package/dist/components/tooltip/tooltip.vanilla.js.map +1 -0
- package/dist/components/tooltip/types.d.ts +39 -0
- package/dist/components/tree/index.d.ts +3 -0
- package/dist/components/tree/tree.css.d.ts +73 -0
- package/dist/components/tree/tree.d.ts +5 -0
- package/dist/components/tree/tree.js +337 -0
- package/dist/components/tree/tree.js.map +1 -0
- package/dist/components/tree/tree.vanilla.js +11 -0
- package/dist/components/tree/tree.vanilla.js.map +1 -0
- package/dist/components/tree/types.d.ts +114 -0
- package/dist/components/tree/utils.d.ts +8 -0
- package/dist/components/tree/utils.js +75 -0
- package/dist/components/tree/utils.js.map +1 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/hooks/use-collection-render/index.d.ts +1 -0
- package/dist/hooks/use-collection-render/use-collection-render.d.ts +9 -0
- package/dist/hooks/use-collection-render/use-collection-render.js +20 -0
- package/dist/hooks/use-collection-render/use-collection-render.js.map +1 -0
- package/dist/hooks/use-context-props/index.d.ts +1 -0
- package/dist/hooks/use-context-props/use-context-props.d.ts +7 -0
- package/dist/hooks/use-context-props/use-context-props.js +15 -0
- package/dist/hooks/use-context-props/use-context-props.js.map +1 -0
- package/dist/hooks/use-defaults/index.d.ts +2 -0
- package/dist/hooks/use-defaults/types.d.ts +67 -0
- package/dist/hooks/use-defaults/use-defaults.d.ts +56 -0
- package/dist/hooks/use-defaults/use-defaults.js +21 -0
- package/dist/hooks/use-defaults/use-defaults.js.map +1 -0
- package/dist/hooks/use-propagating-press/index.d.ts +1 -0
- package/dist/hooks/use-propagating-press/use-propagating-press.d.ts +9 -0
- package/dist/hooks/use-propagating-press/use-propagating-press.js +14 -0
- package/dist/hooks/use-propagating-press/use-propagating-press.js.map +1 -0
- package/dist/hooks/use-slot/index.d.ts +1 -0
- package/dist/hooks/use-slot/use-slot.d.ts +13 -0
- package/dist/hooks/use-slot/use-slot.js +18 -0
- package/dist/hooks/use-slot/use-slot.js.map +1 -0
- package/dist/hooks/use-theme/index.d.ts +2 -0
- package/dist/hooks/use-theme/types.d.ts +86 -0
- package/dist/hooks/use-theme/use-theme.css.d.ts +1 -0
- package/dist/hooks/use-theme/use-theme.d.ts +13 -0
- package/dist/hooks/use-theme/use-theme.js +64 -0
- package/dist/hooks/use-theme/use-theme.js.map +1 -0
- package/dist/hooks/use-theme/use-theme.vanilla.js +4 -0
- package/dist/hooks/use-theme/use-theme.vanilla.js.map +1 -0
- package/dist/hooks/use-tree/index.d.ts +1 -0
- package/dist/hooks/use-tree/use-tree.d.ts +2 -0
- package/dist/hooks/use-tree/use-tree.js +217 -0
- package/dist/hooks/use-tree/use-tree.js.map +1 -0
- package/dist/hooks/use-tree/utils.d.ts +6 -0
- package/dist/hooks/use-tree/utils.js +77 -0
- package/dist/hooks/use-tree/utils.js.map +1 -0
- package/dist/hooks/use-update-effect/index.d.ts +1 -0
- package/dist/hooks/use-update-effect/use-update-effect.d.ts +1 -0
- package/dist/hooks/use-update-effect/use-update-effect.js +20 -0
- package/dist/hooks/use-update-effect/use-update-effect.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -0
- package/dist/ladle/actions.d.ts +1 -0
- package/dist/ladle/index.d.ts +1 -0
- package/dist/styles/index.d.ts +6 -0
- package/dist/styles/layers.css.d.ts +16 -0
- package/dist/styles/layers.vanilla.js +4 -0
- package/dist/styles/layers.vanilla.js.map +1 -0
- package/dist/styles/reset.css.d.ts +1 -0
- package/dist/styles/space.css.d.ts +1 -0
- package/dist/styles/surfaces.css.d.ts +4 -0
- package/dist/styles/surfaces.vanilla.js +4 -0
- package/dist/styles/surfaces.vanilla.js.map +1 -0
- package/dist/styles/theme.css.d.ts +334 -0
- package/dist/styles/theme.vanilla.js +31 -0
- package/dist/styles/theme.vanilla.js.map +1 -0
- package/dist/styles/typography.css.d.ts +17 -0
- package/dist/styles/typography.vanilla.js +8 -0
- package/dist/styles/typography.vanilla.js.map +1 -0
- package/dist/styles.css +2014 -0
- package/dist/test/setup.d.ts +1 -0
- package/dist/types/deckgl.d.ts +1 -0
- package/dist/types/generic.d.ts +3 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/props.d.ts +4 -0
- package/dist/types/react-aria.d.ts +91 -0
- package/dist/types/use-tree.d.ts +52 -0
- package/dist/types/vanilla-extract.d.ts +15 -0
- package/dist/utils/css.d.ts +139 -0
- package/dist/utils/css.js +145 -0
- package/dist/utils/css.js.map +1 -0
- package/dist/utils/events.d.ts +10 -0
- package/dist/utils/events.js +5 -0
- package/dist/utils/events.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/props.d.ts +29 -0
- package/dist/utils/props.js +108 -0
- package/dist/utils/props.js.map +1 -0
- package/dist/utils/validators.d.ts +49 -0
- package/dist/utils/validators.js +37 -0
- package/dist/utils/validators.js.map +1 -0
- package/dist/vanilla.d.ts +27 -0
- package/dist/vanilla.js +27 -0
- package/package.json +5 -5
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { createContext, forwardRef, useMemo, useCallback } from 'react';
|
|
3
|
+
import { Provider, Popover, Collection, UNSTABLE_CollectionRendererContext, ListBox, ListBoxItem, ListStateContext } from 'react-aria-components';
|
|
4
|
+
import { useContextProps } from '../../hooks/use-context-props/use-context-props.js';
|
|
5
|
+
import { useDefaultProps } from '../../hooks/use-defaults/use-defaults.js';
|
|
6
|
+
import { inlineVars } from '../../utils/css.js';
|
|
7
|
+
import { mergeClassNames, callRenderProps } from '../../utils/props.js';
|
|
8
|
+
import { useSlot } from '../../hooks/use-slot/use-slot.js';
|
|
9
|
+
import { useTheme } from '../../hooks/use-theme/use-theme.js';
|
|
10
|
+
import { bodies, headings } from '../../styles/typography.vanilla.js';
|
|
11
|
+
import { AriaSectionContext, AriaHeaderContext, AriaSeparatorContext, AriaSection, AriaTextContext, AriaKeyboardContext, AriaText } from '../aria/aria.js';
|
|
12
|
+
import { createCollectionRenderer } from '../collection/collection.js';
|
|
13
|
+
import { IconContext } from '../icon/icon.js';
|
|
14
|
+
import { optionsClassNames, optionsStateVars, optionsItemStateVars } from './options.vanilla.js';
|
|
15
|
+
|
|
16
|
+
const defaultMapping = {
|
|
17
|
+
description: {
|
|
18
|
+
sm: bodies.xs,
|
|
19
|
+
lg: bodies.xs
|
|
20
|
+
},
|
|
21
|
+
header: {
|
|
22
|
+
sm: headings.v4,
|
|
23
|
+
lg: headings.v5
|
|
24
|
+
},
|
|
25
|
+
label: {
|
|
26
|
+
sm: bodies.sm,
|
|
27
|
+
lg: bodies.sm
|
|
28
|
+
},
|
|
29
|
+
shortcut: {
|
|
30
|
+
sm: bodies.xs,
|
|
31
|
+
lg: bodies.xs
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const defaultSize = "lg";
|
|
35
|
+
const OptionsContext = createContext(null);
|
|
36
|
+
const Options = forwardRef(function Options2(props, ref) {
|
|
37
|
+
[props, ref] = useContextProps(props, ref, OptionsContext);
|
|
38
|
+
props = useDefaultProps(props, "Options");
|
|
39
|
+
const { children: childrenProp, classNames: classNamesProp, mapping: mappingProp, size = defaultSize, ...rest } = props;
|
|
40
|
+
const theme = useTheme();
|
|
41
|
+
const classNames = useMemo(() => mergeClassNames(optionsClassNames, theme.Options, classNamesProp, {
|
|
42
|
+
options: {
|
|
43
|
+
container: theme.className
|
|
44
|
+
// required to consume global theme within Popover
|
|
45
|
+
}
|
|
46
|
+
}), [theme.className, theme.Options, classNamesProp]);
|
|
47
|
+
const mapping = useMemo(() => ({
|
|
48
|
+
...defaultMapping,
|
|
49
|
+
...mappingProp
|
|
50
|
+
}), [mappingProp]);
|
|
51
|
+
const style = useCallback(({ ...renderProps }) => ({
|
|
52
|
+
...theme.style,
|
|
53
|
+
// required to consume global styles within Popover
|
|
54
|
+
...inlineVars(optionsStateVars, {
|
|
55
|
+
...renderProps,
|
|
56
|
+
size
|
|
57
|
+
})
|
|
58
|
+
}), [theme.style, size]);
|
|
59
|
+
const values = useMemo(() => [[OptionsListContext, { classNames, mapping, size }]], [classNames, mapping, size]);
|
|
60
|
+
const children = useCallback((renderProps) => jsx(Provider, { values, children: jsx("div", { className: classNames?.options?.options, children: callRenderProps(childrenProp, {
|
|
61
|
+
...renderProps,
|
|
62
|
+
size,
|
|
63
|
+
defaultChildren: null
|
|
64
|
+
}) }) }), [childrenProp, classNames?.options?.options, size, values]);
|
|
65
|
+
return jsx(Popover, { ...rest, ref, className: classNames?.options?.container, style, children });
|
|
66
|
+
});
|
|
67
|
+
const OptionsListContext = createContext(null);
|
|
68
|
+
const OptionsList = forwardRef(function OptionList(props, ref) {
|
|
69
|
+
[props, ref] = useContextProps(props, ref, OptionsListContext);
|
|
70
|
+
props = useDefaultProps(props, "OptionsList");
|
|
71
|
+
const { children: childrenProp, classNames: classNamesProp, items, mapping: mappingProp, selectionMode = "single", size = defaultSize, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...rest } = props;
|
|
72
|
+
const theme = useTheme();
|
|
73
|
+
const mapping = useMemo(() => ({
|
|
74
|
+
...defaultMapping,
|
|
75
|
+
...mappingProp
|
|
76
|
+
}), [mappingProp]);
|
|
77
|
+
const classNames = useMemo(() => mergeClassNames(optionsClassNames, theme.Options, classNamesProp, {
|
|
78
|
+
list: { header: mapping.header[size] }
|
|
79
|
+
}), [theme.Options, classNamesProp, mapping, size]);
|
|
80
|
+
const values = useMemo(() => [
|
|
81
|
+
[OptionsItemContext, { classNames, size, mapping }],
|
|
82
|
+
[AriaSectionContext, { className: classNames?.list?.section }],
|
|
83
|
+
[AriaHeaderContext, { className: classNames?.list?.header }],
|
|
84
|
+
[AriaSeparatorContext, { className: classNames?.list?.separator }]
|
|
85
|
+
], [classNames, size, mapping]);
|
|
86
|
+
const style = useCallback((renderProps) => inlineVars(optionsItemStateVars, { ...renderProps, size }), [size]);
|
|
87
|
+
const children = useMemo(() => {
|
|
88
|
+
if (!(childrenProp || items)) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
return jsx(AriaSection, { className: classNames?.list?.list, children: typeof childrenProp === "function" ? jsx(Collection, { items, children: childrenProp }) : childrenProp });
|
|
92
|
+
}, [classNames?.list?.list, childrenProp, items]);
|
|
93
|
+
const renderer = useMemo(() => createCollectionRenderer(ListStateContext, values), [values]);
|
|
94
|
+
return jsx(UNSTABLE_CollectionRendererContext.Provider, { value: renderer, children: jsx(Provider, { values, children: jsx(ListBox, { ...rest, ref, className: classNames?.list?.container, items, selectionMode, style, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, children }) }) });
|
|
95
|
+
});
|
|
96
|
+
const OptionsItemContext = createContext(null);
|
|
97
|
+
const OptionsItem = forwardRef(function OptionItem(props, ref) {
|
|
98
|
+
[props, ref] = useContextProps(props, ref, OptionsItemContext);
|
|
99
|
+
props = useDefaultProps(props, "OptionsItem");
|
|
100
|
+
const { id, children: childrenProp, classNames: classNamesProp, mapping: mappingProp, size = defaultSize, textValue = typeof childrenProp === "string" ? childrenProp : void 0, ...rest } = props;
|
|
101
|
+
const theme = useTheme();
|
|
102
|
+
const mapping = useMemo(() => ({
|
|
103
|
+
...defaultMapping,
|
|
104
|
+
...mappingProp
|
|
105
|
+
}), [mappingProp]);
|
|
106
|
+
const classNames = useMemo(() => mergeClassNames(optionsClassNames, classNamesProp, theme.Options, {
|
|
107
|
+
item: {
|
|
108
|
+
description: mapping.description[size],
|
|
109
|
+
label: mapping.label[size],
|
|
110
|
+
shortcut: mapping.shortcut[size]
|
|
111
|
+
}
|
|
112
|
+
}), [theme.Options, classNamesProp, mapping, size]);
|
|
113
|
+
const [descriptionRef, hasDescription] = useSlot();
|
|
114
|
+
const style = useCallback((renderProps) => inlineVars(optionsItemStateVars, {
|
|
115
|
+
...renderProps,
|
|
116
|
+
size,
|
|
117
|
+
hasDescription
|
|
118
|
+
}), [hasDescription, size]);
|
|
119
|
+
const values = useMemo(() => [
|
|
120
|
+
[
|
|
121
|
+
AriaTextContext,
|
|
122
|
+
{
|
|
123
|
+
slots: {
|
|
124
|
+
label: { className: classNames?.item?.label },
|
|
125
|
+
description: {
|
|
126
|
+
ref: descriptionRef,
|
|
127
|
+
className: classNames?.item?.description
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
],
|
|
132
|
+
[IconContext, { classNames: classNames?.item?.icon }],
|
|
133
|
+
[AriaKeyboardContext, { className: classNames?.item?.shortcut }]
|
|
134
|
+
], [
|
|
135
|
+
classNames?.item?.label,
|
|
136
|
+
descriptionRef,
|
|
137
|
+
classNames?.item?.description,
|
|
138
|
+
classNames?.item?.icon,
|
|
139
|
+
classNames?.item?.shortcut
|
|
140
|
+
]);
|
|
141
|
+
const children = useCallback((renderProps) => {
|
|
142
|
+
const content = callRenderProps(childrenProp, {
|
|
143
|
+
...renderProps,
|
|
144
|
+
size,
|
|
145
|
+
defaultChildren: null
|
|
146
|
+
});
|
|
147
|
+
return jsx(Provider, { values, children: jsx("div", { className: classNames?.item?.item, children: typeof content === "string" ? jsx(AriaText, { slot: "label", children: content }) : content }) });
|
|
148
|
+
}, [childrenProp, classNames?.item?.item, size, values]);
|
|
149
|
+
return jsx(ListBoxItem, { ...rest, id: id ?? textValue, ref, className: classNames?.item?.container, style, textValue, children });
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
export { Options, OptionsContext, OptionsItem, OptionsItemContext, OptionsList, OptionsListContext };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sources":["../../../src/components/options/options.tsx"],"sourcesContent":["import {\n createContext,\n forwardRef,\n useCallback,\n useMemo,\n type ForwardedRef,\n type HTMLAttributes,\n} from 'react';\nimport {\n Collection,\n ListBox,\n ListBoxItem,\n ListStateContext,\n Popover,\n Provider,\n UNSTABLE_CollectionRendererContext,\n type CollectionRenderer,\n type ContextValue,\n type ListBoxItemRenderProps,\n type ListBoxRenderProps,\n type PopoverRenderProps,\n type SectionProps,\n type SeparatorProps,\n type TextProps,\n} from 'react-aria-components';\nimport {\n useContextProps,\n useDefaultProps,\n useSlot,\n useTheme,\n} from '../../hooks';\nimport { bodies, headings } from '../../styles';\nimport { callRenderProps, inlineVars, mergeClassNames } from '../../utils';\nimport {\n AriaHeaderContext,\n AriaKeyboardContext,\n AriaSection,\n AriaSectionContext,\n AriaSeparatorContext,\n AriaText,\n AriaTextContext,\n} from '../aria';\nimport { createCollectionRenderer } from '../collection';\nimport { IconContext, type IconProps } from '../icon';\nimport {\n optionsClassNames,\n optionsItemStateVars,\n optionsStateVars,\n} from './options.css';\nimport type {\n OptionsItemProps,\n OptionsListProps,\n OptionsMapping,\n OptionsProps,\n} from './types';\n\nconst defaultMapping: OptionsMapping = {\n description: {\n sm: bodies.xs,\n lg: bodies.xs,\n },\n header: {\n sm: headings.v4,\n lg: headings.v5,\n },\n label: {\n sm: bodies.sm,\n lg: bodies.sm,\n },\n shortcut: {\n sm: bodies.xs,\n lg: bodies.xs,\n },\n};\n\nconst defaultSize = 'lg';\n\nexport const OptionsContext =\n createContext<ContextValue<OptionsProps, HTMLElement>>(null);\n\nexport const Options = forwardRef(function Options(\n props: OptionsProps,\n ref: ForwardedRef<HTMLElement>,\n) {\n [props, ref] = useContextProps(props, ref, OptionsContext);\n props = useDefaultProps(props, 'Options');\n\n const {\n children: childrenProp,\n classNames: classNamesProp,\n mapping: mappingProp,\n size = defaultSize,\n ...rest\n } = props;\n\n const theme = useTheme();\n\n const classNames = useMemo(\n () =>\n mergeClassNames(optionsClassNames, theme.Options, classNamesProp, {\n options: {\n container: theme.className, // required to consume global theme within Popover\n },\n }),\n [theme.className, theme.Options, classNamesProp],\n );\n\n const mapping = useMemo(\n () => ({\n ...defaultMapping,\n ...mappingProp,\n }),\n [mappingProp],\n );\n\n const style = useCallback(\n ({ ...renderProps }: PopoverRenderProps) => ({\n ...theme.style, // required to consume global styles within Popover\n ...inlineVars(optionsStateVars, {\n ...renderProps,\n size,\n }),\n }),\n [theme.style, size],\n );\n\n const values = useMemo<\n [\n [\n typeof OptionsListContext,\n ContextValue<OptionsListProps<object>, HTMLDivElement>,\n ],\n ]\n >(\n () => [[OptionsListContext, { classNames, mapping, size }]],\n [classNames, mapping, size],\n );\n\n const children = useCallback(\n (renderProps: PopoverRenderProps) => (\n <Provider values={values}>\n <div className={classNames?.options?.options}>\n {callRenderProps(childrenProp, {\n ...renderProps,\n size,\n defaultChildren: null,\n })}\n </div>\n </Provider>\n ),\n [childrenProp, classNames?.options?.options, size, values],\n );\n\n return (\n <Popover\n {...rest}\n ref={ref}\n className={classNames?.options?.container}\n style={style}\n >\n {children}\n </Popover>\n );\n});\n\nexport const OptionsListContext =\n createContext<ContextValue<OptionsListProps<object>, HTMLDivElement>>(null);\n\ntype OptionsListContexts = [\n [\n typeof OptionsItemContext,\n ContextValue<OptionsItemProps<object>, HTMLDivElement>,\n ],\n [typeof AriaSectionContext, ContextValue<SectionProps<object>, HTMLElement>],\n [\n typeof AriaHeaderContext,\n ContextValue<HTMLAttributes<HTMLElement>, HTMLElement>,\n ],\n [typeof AriaSeparatorContext, ContextValue<SeparatorProps, HTMLElement>],\n];\n\nexport const OptionsList = forwardRef(function OptionList<T extends object>(\n props: OptionsListProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n [props, ref] = useContextProps(props, ref, OptionsListContext);\n props = useDefaultProps(props, 'OptionsList');\n\n const {\n children: childrenProp,\n classNames: classNamesProp,\n items,\n mapping: mappingProp,\n selectionMode = 'single',\n size = defaultSize,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n ...rest\n } = props;\n\n const theme = useTheme();\n\n const mapping = useMemo(\n () => ({\n ...defaultMapping,\n ...mappingProp,\n }),\n [mappingProp],\n );\n\n const classNames = useMemo(\n () =>\n mergeClassNames(optionsClassNames, theme.Options, classNamesProp, {\n list: { header: mapping.header[size] },\n }),\n [theme.Options, classNamesProp, mapping, size],\n );\n\n const values = useMemo<OptionsListContexts>(\n () => [\n [OptionsItemContext, { classNames, size, mapping }],\n [AriaSectionContext, { className: classNames?.list?.section }],\n [AriaHeaderContext, { className: classNames?.list?.header }],\n [AriaSeparatorContext, { className: classNames?.list?.separator }],\n ],\n [classNames, size, mapping],\n );\n\n const style = useCallback(\n (renderProps: ListBoxRenderProps) =>\n inlineVars(optionsItemStateVars, { ...renderProps, size }),\n [size],\n );\n\n const children = useMemo(() => {\n if (!(childrenProp || items)) {\n return null;\n }\n\n return (\n <AriaSection className={classNames?.list?.list}>\n {typeof childrenProp === 'function' ? (\n <Collection items={items}>{childrenProp}</Collection>\n ) : (\n childrenProp\n )}\n </AriaSection>\n );\n }, [classNames?.list?.list, childrenProp, items]);\n\n const renderer = useMemo<CollectionRenderer>(\n () => createCollectionRenderer(ListStateContext, values),\n [values],\n );\n\n return (\n <UNSTABLE_CollectionRendererContext.Provider value={renderer}>\n <Provider values={values}>\n <ListBox<T>\n {...rest}\n ref={ref}\n className={classNames?.list?.container}\n items={items}\n selectionMode={selectionMode}\n style={style}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n >\n {children}\n </ListBox>\n </Provider>\n </UNSTABLE_CollectionRendererContext.Provider>\n );\n});\n\nexport const OptionsItemContext =\n createContext<ContextValue<OptionsItemProps<object>, HTMLDivElement>>(null);\n\nexport const OptionsItem = forwardRef(function OptionItem<T extends object>(\n props: OptionsItemProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n [props, ref] = useContextProps(props, ref, OptionsItemContext);\n props = useDefaultProps(props, 'OptionsItem');\n\n const {\n id,\n children: childrenProp,\n classNames: classNamesProp,\n mapping: mappingProp,\n size = defaultSize,\n textValue = typeof childrenProp === 'string' ? childrenProp : undefined,\n ...rest\n } = props;\n\n const theme = useTheme();\n\n const mapping = useMemo(\n () => ({\n ...defaultMapping,\n ...mappingProp,\n }),\n [mappingProp],\n );\n\n const classNames = useMemo(\n () =>\n mergeClassNames(optionsClassNames, classNamesProp, theme.Options, {\n item: {\n description: mapping.description[size],\n label: mapping.label[size],\n shortcut: mapping.shortcut[size],\n },\n }),\n [theme.Options, classNamesProp, mapping, size],\n );\n\n const [descriptionRef, hasDescription] = useSlot();\n\n const style = useCallback(\n (renderProps: ListBoxItemRenderProps) =>\n inlineVars(optionsItemStateVars, {\n ...renderProps,\n size,\n hasDescription,\n }),\n [hasDescription, size],\n );\n\n const values = useMemo<\n [\n [typeof AriaTextContext, ContextValue<TextProps, HTMLElement>],\n [typeof IconContext, ContextValue<IconProps, HTMLDivElement>],\n [\n typeof AriaKeyboardContext,\n ContextValue<HTMLAttributes<HTMLElement>, HTMLElement>,\n ],\n ]\n >(\n () => [\n [\n AriaTextContext,\n {\n slots: {\n label: { className: classNames?.item?.label },\n description: {\n ref: descriptionRef,\n className: classNames?.item?.description,\n },\n },\n },\n ],\n [IconContext, { classNames: classNames?.item?.icon }],\n [AriaKeyboardContext, { className: classNames?.item?.shortcut }],\n ],\n [\n classNames?.item?.label,\n descriptionRef,\n classNames?.item?.description,\n classNames?.item?.icon,\n classNames?.item?.shortcut,\n ],\n );\n\n const children = useCallback(\n (renderProps: ListBoxItemRenderProps) => {\n const content = callRenderProps(childrenProp, {\n ...renderProps,\n size,\n defaultChildren: null,\n });\n\n return (\n <Provider values={values}>\n <div className={classNames?.item?.item}>\n {typeof content === 'string' ? (\n <AriaText slot='label'>{content}</AriaText>\n ) : (\n content\n )}\n </div>\n </Provider>\n );\n },\n [childrenProp, classNames?.item?.item, size, values],\n );\n\n return (\n <ListBoxItem<T>\n {...rest}\n id={id ?? textValue}\n ref={ref as ForwardedRef<T>}\n className={classNames?.item?.container}\n style={style}\n textValue={textValue}\n >\n {children}\n </ListBoxItem>\n );\n});\n"],"names":["Options"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,MAAM,cAAiC,GAAA;AAAA,EACrC,WAAa,EAAA;AAAA,IACX,IAAI,MAAO,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AClB,cAAA;AAAA,MACA,YAAY,IAAM,EAAA,WAAA;AAAA,MAClB,YAAY,IAAM,EAAA,IAAA;AAAA,MAClB,YAAY,IAAM,EAAA,QAAA;AAAA,KACpB;AAAA,GACF,CAAA;AAEA,EAAA,MAAM,QAAW,GAAA,WAAA;AAAA,IACf,CAAC,WAAwC,KAAA;AACvC,MAAM,MAAA,OAAA,GAAU,gBAAgB,YAAc,EAAA;AAAA,QAC5C,GAAG,WAAA;AAAA,QACH,IAAA;AAAA,QACA,eAAiB,EAAA,IAAA;AAAA,OAClB,CAAA,CAAA;AAED,MAAA,2BACG,QAAS,EAAA,EAAA,MAAA,EACR,8BAAC,KAAI,EAAA,EAAA,SAAA,EAAW,YAAY,IAAM,EAAA,IAAA,EAC/B,iBAAO,OAAY,KAAA,QAAA,uBACjB,QAAS,EAAA,EAAA,IAAA,EAAK,SAAS,QAAQ,EAAA,OAAA,EAAA,CAAA,GAEhC,SAEJ,CACF,EAAA,CAAA,CAAA;AAAA,KAEJ;AAAA,IACA,CAAC,YAAc,EAAA,UAAA,EAAY,IAAM,EAAA,IAAA,EAAM,MAAM,MAAM,CAAA;AAAA,GACrD,CAAA;AAEA,EACE,uBAAA,GAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACE,GAAG,IAAA;AAAA,MACJ,IAAI,EAAM,IAAA,SAAA;AAAA,MACV,GAAA;AAAA,MACA,SAAA,EAAW,YAAY,IAAM,EAAA,SAAA;AAAA,MAC7B,KAAA;AAAA,MACA,SAAA;AAAA,MAEC,QAAA;AAAA,KAAA;AAAA,GACH,CAAA;AAEJ,CAAC;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
var optionsClassNames = { options: { container: "options_optionsClassNames_options_container__140gzb519", options: "options_optionsClassNames_options_options__140gzb51a surfaces_proud__15mw6jf5 surfaces_flush__15mw6jf4" }, list: { container: "options_optionsClassNames_list_container__140gzb51b", list: "options_optionsClassNames_list_list__140gzb51c", section: "options_optionsClassNames_list_section__140gzb51d", header: "options_optionsClassNames_list_header__140gzb51e", separator: "options_optionsClassNames_list_separator__140gzb51f" }, item: { container: "options_optionsClassNames_item_container__140gzb51g", item: "options_optionsClassNames_item_item__140gzb51h", icon: { icon: "options_optionsClassNames_item_icon_icon__140gzb51i" }, label: "options_optionsClassNames_item_label__140gzb51j", description: "options_optionsClassNames_item_description__140gzb51k", shortcut: "options_optionsClassNames_item_shortcut__140gzb51l" } };
|
|
3
|
+
var optionsColorVars = { list: { background: "var(--list-background__140gzb5l)", border: "var(--list-border__140gzb5m)", color: "var(--list-color__140gzb5n)" }, header: { background: "var(--header-background__140gzb5o)", border: "var(--header-border__140gzb5p)", color: "var(--header-color__140gzb5q)" }, separator: "var(--separator__140gzb5r)", item: { background: "var(--item-background__140gzb5s)", border: "var(--item-border__140gzb5t)", color: "var(--item-color__140gzb5u)" }, label: "var(--label__140gzb5v)", description: "var(--description__140gzb5w)" };
|
|
4
|
+
var optionsContainers = { options: "options_optionsContainers_options__140gzb50", list: "options_optionsContainers_list__140gzb51", item: "options_optionsContainers_item__140gzb52" };
|
|
5
|
+
var optionsItemStateVars = { selectionBehavior: "var(--selectionBehavior__140gzb5b)", selectionMode: "var(--selectionMode__140gzb5c)", size: "var(--size__140gzb5d)", hasDescription: "var(--hasDescription__140gzb5e)", isDisabled: "var(--isDisabled__140gzb5f)", isHovered: "var(--isHovered__140gzb5g)", isPressed: "var(--isPressed__140gzb5h)", isSelected: "var(--isSelected__140gzb5i)", isFocused: "var(--isFocused__140gzb5j)", isFocusVisible: "var(--isFocusVisible__140gzb5k)" };
|
|
6
|
+
var optionsListStateVars = { size: "var(--size__140gzb57)", isEmpty: "var(--isEmpty__140gzb58)", isFocused: "var(--isFocused__140gzb59)", isFocusVisible: "var(--isFocusVisible__140gzb5a)" };
|
|
7
|
+
var optionsSpaceVars = { options: { minWidth: "var(--options-minWidth__140gzb5x)", x: "var(--options-x__140gzb5y)", y: "var(--options-y__140gzb5z)" }, section: { x: "var(--section-x__140gzb510)", y: "var(--section-y__140gzb511)" }, header: { x: "var(--header-x__140gzb512)", y: "var(--header-y__140gzb513)" }, separator: { x: "var(--separator-x__140gzb514)", y: "var(--separator-y__140gzb515)" }, item: { x: "var(--item-x__140gzb516)", y: "var(--item-y__140gzb517)", gap: "var(--item-gap__140gzb518)" } };
|
|
8
|
+
var optionsStateVars = { size: "var(--size__140gzb53)", isEntering: "var(--isEntering__140gzb54)", isExiting: "var(--isExiting__140gzb55)", placement: "var(--placement__140gzb56)" };
|
|
9
|
+
|
|
10
|
+
export { optionsClassNames, optionsColorVars, optionsContainers, optionsItemStateVars, optionsListStateVars, optionsSpaceVars, optionsStateVars };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.vanilla.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { AsType } from '../../types';
|
|
2
|
+
import type { ListBoxItemProps, ListBoxItemRenderProps, ListBoxProps, ListBoxRenderProps, PopoverProps, PopoverRenderProps } from 'react-aria-components';
|
|
3
|
+
import type { PartialDeep } from 'type-fest';
|
|
4
|
+
import type { IconClassNames } from '../icon/types';
|
|
5
|
+
export type OptionsClassNames = PartialDeep<{
|
|
6
|
+
options: {
|
|
7
|
+
container: string;
|
|
8
|
+
options: string;
|
|
9
|
+
};
|
|
10
|
+
list: {
|
|
11
|
+
container: string;
|
|
12
|
+
list: string;
|
|
13
|
+
section: string;
|
|
14
|
+
header: string;
|
|
15
|
+
separator: string;
|
|
16
|
+
};
|
|
17
|
+
item: {
|
|
18
|
+
container: string;
|
|
19
|
+
item: string;
|
|
20
|
+
icon: IconClassNames;
|
|
21
|
+
label: string;
|
|
22
|
+
description: string;
|
|
23
|
+
shortcut: string;
|
|
24
|
+
};
|
|
25
|
+
}>;
|
|
26
|
+
export type OptionsSizes = 'sm' | 'lg';
|
|
27
|
+
export type OptionsMapping = {
|
|
28
|
+
description: Partial<Record<OptionsSizes, string>>;
|
|
29
|
+
header: Partial<Record<OptionsSizes, string>>;
|
|
30
|
+
label: Partial<Record<OptionsSizes, string>>;
|
|
31
|
+
shortcut: Partial<Record<OptionsSizes, string>>;
|
|
32
|
+
};
|
|
33
|
+
type BaseOptionsProps = {
|
|
34
|
+
classNames?: OptionsClassNames;
|
|
35
|
+
mapping?: Partial<OptionsMapping>;
|
|
36
|
+
size?: OptionsSizes;
|
|
37
|
+
};
|
|
38
|
+
export type OptionsProps = Omit<PopoverProps, 'className' | 'style'> & BaseOptionsProps;
|
|
39
|
+
export type OptionsListProps<T extends object> = Omit<ListBoxProps<T>, 'className' | 'dragAndDropHooks' | 'orientation' | 'style'> & BaseOptionsProps;
|
|
40
|
+
export type OptionsItemProps<T extends object> = Omit<ListBoxItemProps<T>, 'className' | 'style'> & BaseOptionsProps;
|
|
41
|
+
export type OptionsRenderProps = AsType<PopoverRenderProps> & Required<Pick<BaseOptionsProps, 'size'>>;
|
|
42
|
+
export type OptionsListRenderProps = AsType<ListBoxRenderProps> & Required<Pick<BaseOptionsProps, 'size'>>;
|
|
43
|
+
export type OptionsItemRenderProps = AsType<ListBoxItemRenderProps> & Required<Pick<BaseOptionsProps, 'size'>>;
|
|
44
|
+
export type OptionsState = Omit<OptionsRenderProps, 'trigger'>;
|
|
45
|
+
export type OptionsListState = Omit<OptionsListRenderProps, 'layout' | 'state' | 'isDropTarget'>;
|
|
46
|
+
export type OptionsItemState = Omit<OptionsItemRenderProps, 'allowsDragging' | 'isDragging' | 'isDropTarget'> & {
|
|
47
|
+
hasDescription: boolean;
|
|
48
|
+
};
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { Picker, PickerContext, PickerItem, PickerItemContext } from './picker';
|
|
2
|
+
export { pickerClassNames, pickerContainers, pickerItemColorVars, pickerItemStateVars, pickerSpaceVars, pickerStateVars, } from './picker.css';
|
|
3
|
+
export { type PickerClassNames, type PickerItemProps, type PickerItemRenderProps, type PickerItemState, type PickerProps, type PickerState, } from './types';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PickerClassNames } from './types';
|
|
2
|
+
export declare const pickerContainers: {
|
|
3
|
+
list: string;
|
|
4
|
+
item: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const pickerSpaceVars: {
|
|
7
|
+
gap: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
8
|
+
};
|
|
9
|
+
export declare const pickerStateVars: {
|
|
10
|
+
columns: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
11
|
+
layout: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
12
|
+
orientation: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
13
|
+
isEmpty: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
14
|
+
isFocused: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
15
|
+
isFocusVisible: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
16
|
+
};
|
|
17
|
+
export declare const pickerItemColorVars: {
|
|
18
|
+
background: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
19
|
+
border: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
20
|
+
color: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
21
|
+
};
|
|
22
|
+
export declare const pickerItemStateVars: {
|
|
23
|
+
selectionMode: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
24
|
+
selectionBehavior: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
25
|
+
isDisabled: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
26
|
+
isFocused: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
27
|
+
isFocusVisible: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
28
|
+
isHovered: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
29
|
+
isPressed: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
30
|
+
isSelected: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
31
|
+
};
|
|
32
|
+
export declare const pickerClassNames: PickerClassNames;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ContextValue } from 'react-aria-components';
|
|
2
|
+
import type { PickerItemProps, PickerProps } from './types';
|
|
3
|
+
export declare const PickerContext: import("react").Context<ContextValue<PickerProps<unknown>, HTMLDivElement>>;
|
|
4
|
+
export declare const PickerItemContext: import("react").Context<ContextValue<PickerItemProps<unknown>, HTMLDivElement>>;
|
|
5
|
+
/**
|
|
6
|
+
* Generic stylable picker that supports the functionality (sans drag and drop) of
|
|
7
|
+
* React Aria's ListBox: https://react-spectrum.adobe.com/react-aria/ListBox.html
|
|
8
|
+
*
|
|
9
|
+
* NOTE: The picker items does not support sections or separators
|
|
10
|
+
*/
|
|
11
|
+
export declare const Picker: <T extends object>(props: Omit<import("react-aria-components").ListBoxProps<T>, "className" | "style" | "dragAndDropHooks"> & {
|
|
12
|
+
classNames?: import("./types").PickerClassNames;
|
|
13
|
+
} & {
|
|
14
|
+
columns?: number;
|
|
15
|
+
} & import("react").RefAttributes<HTMLDivElement>) => import("react").ReactElement | null;
|
|
16
|
+
export declare const PickerItem: <T extends object>(props: Omit<import("react-aria-components").ListBoxItemProps<T>, "className" | "style"> & {
|
|
17
|
+
classNames?: import("./types").PickerClassNames;
|
|
18
|
+
} & import("react").RefAttributes<HTMLDivElement>) => import("react").ReactElement | null;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { createContext, forwardRef, useMemo, useCallback } from 'react';
|
|
3
|
+
import { useContextProps, Section, Collection, Provider, ListBox, ListBoxItem } from 'react-aria-components';
|
|
4
|
+
import { inlineVars } from '../../utils/css.js';
|
|
5
|
+
import { mergeClassNames, callRenderProps } from '../../utils/props.js';
|
|
6
|
+
import { useDefaultProps } from '../../hooks/use-defaults/use-defaults.js';
|
|
7
|
+
import { useTheme } from '../../hooks/use-theme/use-theme.js';
|
|
8
|
+
import { pickerClassNames, pickerStateVars, pickerItemStateVars } from './picker.vanilla.js';
|
|
9
|
+
|
|
10
|
+
const PickerContext = createContext(null);
|
|
11
|
+
const PickerItemContext = createContext(null);
|
|
12
|
+
const Picker = forwardRef(function Picker2(props, ref) {
|
|
13
|
+
[props, ref] = useContextProps(props, ref, PickerContext);
|
|
14
|
+
props = useDefaultProps(props, "Picker");
|
|
15
|
+
const { children: childrenProp, classNames: classNamesProp, columns, items, layout = "stack", orientation = "horizontal", selectionMode = "single", "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...rest } = props;
|
|
16
|
+
const theme = useTheme();
|
|
17
|
+
const classNames = useMemo(() => mergeClassNames(pickerClassNames, theme.Picker, classNamesProp), [theme.Picker, classNamesProp]);
|
|
18
|
+
const values = useMemo(() => [[PickerItemContext, { classNames }]], [classNames]);
|
|
19
|
+
const style = useCallback(({ state, ...renderProps }) => inlineVars(pickerStateVars, {
|
|
20
|
+
...renderProps,
|
|
21
|
+
columns,
|
|
22
|
+
layout,
|
|
23
|
+
orientation
|
|
24
|
+
}), [columns, layout, orientation]);
|
|
25
|
+
const children = useMemo(() => {
|
|
26
|
+
if (!(childrenProp || items)) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return jsx(Section, { className: classNames?.list?.list, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, children: typeof childrenProp === "function" ? jsx(Collection, { items, children: childrenProp }) : childrenProp });
|
|
30
|
+
}, [childrenProp, items, classNames?.list?.list, ariaLabel, ariaLabelledBy]);
|
|
31
|
+
return jsx(Provider, { values, children: jsx(ListBox, { ...rest, ref, className: classNames?.list?.container, items, layout, orientation, selectionMode, style, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, children }) });
|
|
32
|
+
});
|
|
33
|
+
const PickerItem = forwardRef(function PickerItem2(props, ref) {
|
|
34
|
+
[props, ref] = useContextProps(props, ref, PickerItemContext);
|
|
35
|
+
const { children: childrenProp, id, classNames: classNamesProp, textValue = typeof childrenProp === "string" ? childrenProp : void 0, ...rest } = props;
|
|
36
|
+
const theme = useTheme();
|
|
37
|
+
const classNames = useMemo(() => mergeClassNames(pickerClassNames, theme.Picker, classNamesProp), [theme.Picker, classNamesProp]);
|
|
38
|
+
const style = useCallback((renderProps) => inlineVars(pickerItemStateVars, renderProps), []);
|
|
39
|
+
const children = useCallback((renderProps) => jsx("div", { className: classNames?.item?.item, children: callRenderProps(childrenProp, {
|
|
40
|
+
...renderProps,
|
|
41
|
+
defaultChildren: null
|
|
42
|
+
}) }), [childrenProp, classNames?.item?.item]);
|
|
43
|
+
return jsx(ListBoxItem, { ...rest, ref, id: id ?? textValue, className: classNames?.item?.container, style, textValue, children });
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export { Picker, PickerContext, PickerItem, PickerItemContext };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"picker.js","sources":["../../../src/components/picker/picker.tsx"],"sourcesContent":["import {\n createContext,\n forwardRef,\n useCallback,\n useMemo,\n type ForwardedRef,\n} from 'react';\nimport {\n Collection,\n ListBox,\n ListBoxItem,\n Provider,\n Section,\n useContextProps,\n type ContextValue,\n type ListBoxItemRenderProps,\n type ListBoxRenderProps,\n} from 'react-aria-components';\nimport { useDefaultProps, useTheme } from '../../hooks';\nimport { callRenderProps, inlineVars, mergeClassNames } from '../../utils';\nimport {\n pickerClassNames,\n pickerItemStateVars,\n pickerStateVars,\n} from './picker.css';\nimport type { PickerItemProps, PickerProps } from './types';\n\nexport const PickerContext =\n createContext<ContextValue<PickerProps<unknown>, HTMLDivElement>>(null);\n\nexport const PickerItemContext =\n createContext<ContextValue<PickerItemProps<unknown>, HTMLDivElement>>(null);\n\n/**\n * Generic stylable picker that supports the functionality (sans drag and drop) of\n * React Aria's ListBox: https://react-spectrum.adobe.com/react-aria/ListBox.html\n *\n * NOTE: The picker items does not support sections or separators\n */\nexport const Picker = forwardRef(function Picker<T extends object>(\n props: PickerProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n [props, ref] = useContextProps(props, ref, PickerContext);\n\n props = useDefaultProps(props, 'Picker');\n\n const {\n children: childrenProp,\n classNames: classNamesProp,\n columns,\n items,\n layout = 'stack',\n orientation = 'horizontal',\n selectionMode = 'single',\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n ...rest\n } = props;\n\n const theme = useTheme();\n\n const classNames = useMemo(\n () => mergeClassNames(pickerClassNames, theme.Picker, classNamesProp),\n [theme.Picker, classNamesProp],\n );\n\n const values = useMemo<\n [\n [\n typeof PickerItemContext,\n ContextValue<PickerItemProps<unknown>, HTMLDivElement>,\n ],\n ]\n >(() => [[PickerItemContext, { classNames }]], [classNames]);\n\n const style = useCallback(\n ({ state, ...renderProps }: ListBoxRenderProps) =>\n inlineVars(pickerStateVars, {\n ...renderProps,\n columns,\n layout,\n orientation,\n }),\n [columns, layout, orientation],\n );\n\n const children = useMemo(() => {\n if (!(childrenProp || items)) {\n return null;\n }\n\n return (\n <Section\n className={classNames?.list?.list}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n >\n {typeof childrenProp === 'function' ? (\n <Collection items={items}>{childrenProp}</Collection>\n ) : (\n childrenProp\n )}\n </Section>\n );\n }, [childrenProp, items, classNames?.list?.list, ariaLabel, ariaLabelledBy]);\n\n return (\n <Provider values={values}>\n <ListBox<T>\n {...rest}\n ref={ref}\n className={classNames?.list?.container}\n items={items}\n layout={layout}\n orientation={orientation}\n selectionMode={selectionMode}\n style={style}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n >\n {children}\n </ListBox>\n </Provider>\n );\n});\n\nexport const PickerItem = forwardRef(function PickerItem<T extends object>(\n props: PickerItemProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n [props, ref] = useContextProps(props, ref, PickerItemContext);\n\n const {\n children: childrenProp,\n id,\n classNames: classNamesProp,\n textValue = typeof childrenProp === 'string' ? childrenProp : undefined,\n ...rest\n } = props;\n\n const theme = useTheme();\n\n const classNames = useMemo(\n () => mergeClassNames(pickerClassNames, theme.Picker, classNamesProp),\n [theme.Picker, classNamesProp],\n );\n\n const style = useCallback(\n (renderProps: ListBoxItemRenderProps) =>\n inlineVars(pickerItemStateVars, renderProps),\n [],\n );\n\n const children = useCallback(\n (renderProps: ListBoxItemRenderProps) => (\n <div className={classNames?.item?.item}>\n {callRenderProps(childrenProp, {\n ...renderProps,\n defaultChildren: null,\n })}\n </div>\n ),\n [childrenProp, classNames?.item?.item],\n );\n\n return (\n <ListBoxItem<T>\n {...rest}\n ref={ref as ForwardedRef<T>}\n id={id ?? textValue}\n className={classNames?.item?.container}\n style={style}\n textValue={textValue}\n >\n {children}\n </ListBoxItem>\n );\n});\n"],"names":["Picker","PickerItem"],"mappings":";;;;;;;;;;;;;;;;AA2Ba,MAAA,aAAA,GACX,cAAkE,IAAI,EAAA;AAE3D,MAAA,iBAAA,GACX,cAAsE,IAAI,EAAA;AAQrE,MAAM,MAAS,GAAA,UAAA,CAAW,SAASA,OAAAA,CACxC,OACA,GACA,EAAA;AACA,EAAA,CAAC,OAAO,GAAG,CAAA,GAAI,eAAgB,CAAA,KAAA,EAAO,KAAK,aAAa,CAAA,CAAA;AAExD,EAAQ,KAAA,GAAA,eAAA,CAAgB,OAAO,QAAQ,CAAA,CAAA;AAEvC,EAAM,MAAA;AAAA,IACJ,QAAU,EAAA,YAAA;AAAA,IACV,UAAY,EAAA,cAAA;AAAA,IACZ,OAAA;AAAA,IACA,KAAA;AAAA,IACA,MAAS,GAAA,OAAA;AAAA,IACT,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AAC,WAAA,KACC,UAAW,CAAA,mBAAA,EAAqB,WAAW,CAAA;AAAA,IAC7C,EAAC;AAAA,GACH,CAAA;AAEA,EAAA,MAAM,QAAW,GAAA,WAAA;AAAA,IACf,CAAC,gCACE,GAAA,CAAA,KAAA,EAAA,EAAI,WAAW,UAAY,EAAA,IAAA,EAAM,IAC/B,EAAA,QAAA,EAAA,eAAA,CAAgB,YAAc,EAAA;AAAA,MAC7B,GAAG,WAAA;AAAA,MACH,eAAiB,EAAA,IAAA;AAAA,KAClB,CACH,EAAA,CAAA;AAAA,IAEF,CAAC,YAAA,EAAc,UAAY,EAAA,IAAA,EAAM,IAAI,CAAA;AAAA,GACvC,CAAA;AAEA,EACE,uBAAA,GAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACE,GAAG,IAAA;AAAA,MACJ,GAAA;AAAA,MACA,IAAI,EAAM,IAAA,SAAA;AAAA,MACV,SAAA,EAAW,YAAY,IAAM,EAAA,SAAA;AAAA,MAC7B,KAAA;AAAA,MACA,SAAA;AAAA,MAEC,QAAA;AAAA,KAAA;AAAA,GACH,CAAA;AAEJ,CAAC;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
|
|
2
|
+
var pickerClassNames = { list: { container: "picker_pickerClassNames_list_container__k0t389k", list: "picker_pickerClassNames_list_list__k0t389l" }, item: { container: "picker_pickerClassNames_item_container__k0t389m", item: "picker_pickerClassNames_item_item__k0t389n" } };
|
|
3
|
+
var pickerContainers = { list: "picker_pickerContainers_list__k0t3890", item: "picker_pickerContainers_item__k0t3891" };
|
|
4
|
+
var pickerItemColorVars = { background: "var(--background__k0t3899)", border: "var(--border__k0t389a)", color: "var(--color__k0t389b)" };
|
|
5
|
+
var pickerItemStateVars = { selectionMode: "var(--selectionMode__k0t389c)", selectionBehavior: "var(--selectionBehavior__k0t389d)", isDisabled: "var(--isDisabled__k0t389e)", isFocused: "var(--isFocused__k0t389f)", isFocusVisible: "var(--isFocusVisible__k0t389g)", isHovered: "var(--isHovered__k0t389h)", isPressed: "var(--isPressed__k0t389i)", isSelected: "var(--isSelected__k0t389j)" };
|
|
6
|
+
var pickerSpaceVars = { gap: "var(--gap__k0t3892)" };
|
|
7
|
+
var pickerStateVars = { columns: "var(--columns__k0t3893)", layout: "var(--layout__k0t3894)", orientation: "var(--orientation__k0t3895)", isEmpty: "var(--isEmpty__k0t3896)", isFocused: "var(--isFocused__k0t3897)", isFocusVisible: "var(--isFocusVisible__k0t3898)" };
|
|
8
|
+
|
|
9
|
+
export { pickerClassNames, pickerContainers, pickerItemColorVars, pickerItemStateVars, pickerSpaceVars, pickerStateVars };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"picker.vanilla.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ListBoxProps, ListBoxItemProps, ListBoxItemRenderProps, ListBoxRenderProps } from 'react-aria-components';
|
|
2
|
+
import type { PartialDeep } from 'type-fest';
|
|
3
|
+
export type PickerClassNames = PartialDeep<{
|
|
4
|
+
list: {
|
|
5
|
+
container: string;
|
|
6
|
+
list: string;
|
|
7
|
+
};
|
|
8
|
+
item: {
|
|
9
|
+
container: string;
|
|
10
|
+
item: string;
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
type BaseProps = {
|
|
14
|
+
classNames?: PickerClassNames;
|
|
15
|
+
};
|
|
16
|
+
type BasePickerProps = BaseProps & {
|
|
17
|
+
/**
|
|
18
|
+
* Only applicable if layout='grid'
|
|
19
|
+
*/
|
|
20
|
+
columns?: number;
|
|
21
|
+
};
|
|
22
|
+
export type PickerState = Omit<ListBoxRenderProps, 'state' | 'isDropTarget'> & Required<Pick<PickerProps<unknown>, 'columns' | 'layout' | 'orientation'>>;
|
|
23
|
+
export type PickerProps<T> = Omit<ListBoxProps<T>, 'className' | 'dragAndDropHooks' | 'style'> & BasePickerProps;
|
|
24
|
+
export type BasePickerItemProps = BaseProps;
|
|
25
|
+
export type PickerItemRenderProps = Omit<ListBoxItemRenderProps, 'allowsDragging' | 'isDragging' | 'isDropTarget'>;
|
|
26
|
+
export type PickerItemState = PickerItemRenderProps;
|
|
27
|
+
export type PickerItemProps<T> = Omit<ListBoxItemProps<T>, 'className' | 'style'> & BasePickerItemProps;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { PopoverClassNames } from './types';
|
|
2
|
+
export declare const popoverContainer: string;
|
|
3
|
+
export declare const popoverColorVars: {
|
|
4
|
+
content: {
|
|
5
|
+
color: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare const popoverSpaceVars: {
|
|
9
|
+
width: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
10
|
+
x: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
11
|
+
y: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
12
|
+
gap: {
|
|
13
|
+
default: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
14
|
+
header: {
|
|
15
|
+
after: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
16
|
+
};
|
|
17
|
+
content: {
|
|
18
|
+
before: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
19
|
+
};
|
|
20
|
+
footer: {
|
|
21
|
+
before: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare const popoverStateVars: {
|
|
26
|
+
hasHeader: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
27
|
+
placement: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
28
|
+
isEntering: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
29
|
+
isExiting: `var(--${string})` | `var(--${string}, ${string})` | `var(--${string}, ${number})`;
|
|
30
|
+
};
|
|
31
|
+
export declare const popoverClassNames: PopoverClassNames;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ContextValue } from 'react-aria-components';
|
|
2
|
+
import type { PopoverMapping, PopoverProps } from './types';
|
|
3
|
+
export declare const PopoverContext: import("react").Context<ContextValue<PopoverProps, HTMLElement>>;
|
|
4
|
+
export declare const Popover: (props: Omit<import("react-aria-components").PopoverProps, "children" | "className" | "style"> & {
|
|
5
|
+
children?: import("../..").RenderPropsChildren<import("./types").PopoverRenderProps>;
|
|
6
|
+
classNames?: import("./types").PopoverClassNames;
|
|
7
|
+
mapping?: Partial<PopoverMapping>;
|
|
8
|
+
} & import("react").RefAttributes<HTMLElement>) => import("react").ReactElement | null;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { createContext, forwardRef, useMemo, useCallback } from 'react';
|
|
3
|
+
import { useContextProps, DEFAULT_SLOT, Provider, Dialog, Popover as Popover$1 } from 'react-aria-components';
|
|
4
|
+
import { inlineVars } from '../../utils/css.js';
|
|
5
|
+
import { mergeClassNames, callRenderProps } from '../../utils/props.js';
|
|
6
|
+
import { useDefaultProps } from '../../hooks/use-defaults/use-defaults.js';
|
|
7
|
+
import { useSlot } from '../../hooks/use-slot/use-slot.js';
|
|
8
|
+
import { useTheme } from '../../hooks/use-theme/use-theme.js';
|
|
9
|
+
import { headings } from '../../styles/typography.vanilla.js';
|
|
10
|
+
import { AriaHeadingContext } from '../aria/aria.js';
|
|
11
|
+
import { ButtonContext } from '../button/button.js';
|
|
12
|
+
import { ElementContext } from '../element/element.js';
|
|
13
|
+
import { GroupContext } from '../group/group.js';
|
|
14
|
+
import { popoverClassNames, popoverStateVars } from './popover.vanilla.js';
|
|
15
|
+
|
|
16
|
+
const defaultMapping = {
|
|
17
|
+
heading: headings.v4,
|
|
18
|
+
actions: {
|
|
19
|
+
context: ButtonContext,
|
|
20
|
+
orientation: "horizontal",
|
|
21
|
+
reverse: true
|
|
22
|
+
},
|
|
23
|
+
primary: {
|
|
24
|
+
size: "sm"
|
|
25
|
+
},
|
|
26
|
+
secondary: { size: "sm", variant: "bare" }
|
|
27
|
+
};
|
|
28
|
+
const PopoverContext = createContext(null);
|
|
29
|
+
const Popover = forwardRef(function Popover2(props, ref) {
|
|
30
|
+
[props, ref] = useContextProps(props, ref, PopoverContext);
|
|
31
|
+
props = useDefaultProps(props, "Popover");
|
|
32
|
+
const { children: childrenProp, classNames: classNamesProp, mapping: mappingProp, ...rest } = props;
|
|
33
|
+
const theme = useTheme();
|
|
34
|
+
const mapping = useMemo(() => ({ ...defaultMapping, ...mappingProp }), [mappingProp]);
|
|
35
|
+
const classNames = useMemo(() => mergeClassNames(popoverClassNames, theme.Popover, classNamesProp, {
|
|
36
|
+
popover: {
|
|
37
|
+
container: theme.className
|
|
38
|
+
// required to consume global theme within Popover
|
|
39
|
+
}
|
|
40
|
+
}), [theme.className, theme.Popover, classNamesProp]);
|
|
41
|
+
const [headerRef, hasHeader] = useSlot();
|
|
42
|
+
const style = useCallback((renderProps) => inlineVars(popoverStateVars, {
|
|
43
|
+
...theme.style,
|
|
44
|
+
// required to consume global styles within Popover
|
|
45
|
+
...renderProps,
|
|
46
|
+
hasHeader
|
|
47
|
+
}), [theme.style, hasHeader]);
|
|
48
|
+
const values = useMemo(() => [
|
|
49
|
+
[
|
|
50
|
+
ElementContext,
|
|
51
|
+
{
|
|
52
|
+
slots: {
|
|
53
|
+
[DEFAULT_SLOT]: {},
|
|
54
|
+
header: {
|
|
55
|
+
as: "header",
|
|
56
|
+
className: classNames?.header,
|
|
57
|
+
ref: headerRef,
|
|
58
|
+
values: [
|
|
59
|
+
[
|
|
60
|
+
AriaHeadingContext,
|
|
61
|
+
{
|
|
62
|
+
className: mapping.heading,
|
|
63
|
+
slot: "title"
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
[GroupContext, null]
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
content: { className: classNames?.content },
|
|
70
|
+
footer: {
|
|
71
|
+
as: "footer",
|
|
72
|
+
className: classNames?.footer,
|
|
73
|
+
values: [
|
|
74
|
+
[AriaHeadingContext, null],
|
|
75
|
+
[
|
|
76
|
+
GroupContext,
|
|
77
|
+
{
|
|
78
|
+
values: {
|
|
79
|
+
slots: {
|
|
80
|
+
[DEFAULT_SLOT]: mapping.primary ?? {},
|
|
81
|
+
secondary: mapping.secondary ?? {}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
...mapping.actions
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
], [
|
|
93
|
+
classNames?.header,
|
|
94
|
+
classNames?.content,
|
|
95
|
+
classNames?.footer,
|
|
96
|
+
headerRef,
|
|
97
|
+
mapping.actions,
|
|
98
|
+
mapping.heading,
|
|
99
|
+
mapping.primary,
|
|
100
|
+
mapping.secondary
|
|
101
|
+
]);
|
|
102
|
+
const children = useCallback((renderProps) => jsx(Provider, { values, children: jsx(Dialog, { className: classNames?.popover?.popover, children: ({ close }) => callRenderProps(childrenProp, {
|
|
103
|
+
...renderProps,
|
|
104
|
+
close,
|
|
105
|
+
defaultChildren: null
|
|
106
|
+
}) }) }), [childrenProp, classNames?.popover?.popover, values]);
|
|
107
|
+
return jsx(Popover$1, { ...rest, ref, className: classNames?.popover?.container, style, children });
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
export { Popover, PopoverContext };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popover.js","sources":["../../../src/components/popover/popover.tsx"],"sourcesContent":["import {\n createContext,\n forwardRef,\n useCallback,\n useMemo,\n type ForwardedRef,\n type HTMLAttributes,\n} from 'react';\nimport {\n DEFAULT_SLOT,\n Dialog as RACDialog,\n Provider,\n Popover as RACPopover,\n useContextProps,\n type ContextValue,\n type PopoverRenderProps as RACPopoverRenderProps,\n} from 'react-aria-components';\nimport { useDefaultProps, useSlot, useTheme } from '../../hooks';\nimport { headings } from '../../styles';\nimport { callRenderProps, inlineVars, mergeClassNames } from '../../utils';\nimport { AriaHeadingContext } from '../aria';\nimport { ButtonContext, type ButtonProps } from '../button';\nimport { ElementContext, type ElementProps } from '../element';\nimport { GroupContext, type GroupProps } from '../group';\nimport { popoverClassNames, popoverStateVars } from './popover.css';\nimport type { PopoverMapping, PopoverProps } from './types';\n\nconst defaultMapping: PopoverMapping = {\n heading: headings.v4,\n actions: {\n context: ButtonContext,\n orientation: 'horizontal',\n reverse: true,\n },\n primary: {\n size: 'sm',\n },\n secondary: { size: 'sm', variant: 'bare' },\n};\n\nexport const PopoverContext =\n createContext<ContextValue<PopoverProps, HTMLElement>>(null);\n\nexport const Popover = forwardRef(function Popover(\n props: PopoverProps,\n ref: ForwardedRef<HTMLElement>,\n) {\n [props, ref] = useContextProps(props, ref, PopoverContext);\n props = useDefaultProps(props, 'Popover');\n\n const {\n children: childrenProp,\n classNames: classNamesProp,\n mapping: mappingProp,\n ...rest\n } = props;\n\n const theme = useTheme();\n\n const mapping = useMemo(\n () => ({ ...defaultMapping, ...mappingProp }),\n [mappingProp],\n );\n\n const classNames = useMemo(\n () =>\n mergeClassNames(popoverClassNames, theme.Popover, classNamesProp, {\n popover: {\n container: theme.className, // required to consume global theme within Popover\n },\n }),\n [theme.className, theme.Popover, classNamesProp],\n );\n\n const [headerRef, hasHeader] = useSlot();\n\n const style = useCallback(\n (renderProps: RACPopoverRenderProps) =>\n inlineVars(popoverStateVars, {\n ...theme.style, // required to consume global styles within Popover\n ...renderProps,\n hasHeader,\n }),\n [theme.style, hasHeader],\n );\n\n const values = useMemo<\n [\n [\n typeof ElementContext,\n ContextValue<\n ElementProps<\n ContextValue<HTMLAttributes<HTMLElement>, HTMLHeadingElement>,\n ContextValue<\n GroupProps<ButtonProps, HTMLButtonElement>,\n HTMLDivElement\n >\n >,\n HTMLElement\n >,\n ],\n ]\n >(\n () => [\n [\n ElementContext,\n {\n slots: {\n [DEFAULT_SLOT]: {},\n header: {\n as: 'header',\n className: classNames?.header,\n ref: headerRef,\n values: [\n [\n AriaHeadingContext,\n {\n className: mapping.heading,\n slot: 'title',\n },\n ],\n [GroupContext, null],\n ],\n },\n content: { className: classNames?.content },\n footer: {\n as: 'footer',\n className: classNames?.footer,\n values: [\n [AriaHeadingContext, null],\n [\n GroupContext,\n {\n values: {\n slots: {\n [DEFAULT_SLOT]: mapping.primary ?? {},\n secondary: mapping.secondary ?? {},\n },\n },\n ...mapping.actions,\n },\n ],\n ],\n },\n },\n },\n ],\n ],\n [\n classNames?.header,\n classNames?.content,\n classNames?.footer,\n headerRef,\n mapping.actions,\n mapping.heading,\n mapping.primary,\n mapping.secondary,\n ],\n );\n\n const children = useCallback(\n (renderProps: RACPopoverRenderProps) => (\n <Provider values={values}>\n <RACDialog className={classNames?.popover?.popover}>\n {({ close }) =>\n callRenderProps(childrenProp, {\n ...renderProps,\n close,\n defaultChildren: null,\n })\n }\n </RACDialog>\n </Provider>\n ),\n [childrenProp, classNames?.popover?.popover, values],\n );\n\n return (\n <RACPopover\n {...rest}\n ref={ref}\n className={classNames?.popover?.container}\n style={style}\n >\n {children}\n </RACPopover>\n );\n});\n"],"names":["Popover","RACDialog","RACPopover"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,cAAiC,GAAA;AAAA,EACrC,SAAS,QAAS,CAAA,EAAA;AAAA,EAClB,OAAS,EAAA;AAAA,IACP,OAAS,EAAA,aAAA;AAAA,IACT,WAAa,EAAA,YAAA;AAAA,IACb,OAAS,EAAA,IAAA;AAAA,GACX;AAAA,EACA,OAAS,EAAA;AAAA,IACP,IAAM,EAAA,IAAA;AAAA,GACR;AAAA,EACA,SAAW,EAAA,EAAE,IA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,UAAY,EAAA,MAAA;AAAA,MACZ,SAAA;AAAA,MACA,OAAQ,CAAA,OAAA;AAAA,MACR,OAAQ,CAAA,OAAA;AAAA,MACR,OAAQ,CAAA,OAAA;AAAA,MACR,OAAQ,CAAA,SAAA;AAAA,KACV;AAAA,GACF,CAAA;AAEA,EAAA,MAAM,QAAW,GAAA,WAAA;AAAA,IACf,CAAC,WACC,qBAAA,GAAA,CAAC,QAAS,EAAA,EAAA,MAAA,EACR,8BAACC,MAAU,EAAA,EAAA,SAAA,EAAW,UAAY,EAAA,OAAA,EAAS,SACxC,QAAC,EAAA,CAAA,EAAE,KAAM,EAAA,KACR,gBAAgB,YAAc,EAAA;AAAA,MAC5B,GAAG,WAAA;AAAA,MACH,KAAA;AAAA,MACA,eAAiB,EAAA,IAAA;AAAA,KAClB,GAEL,CACF,EAAA,CAAA;AAAA,IAEF,CAAC,YAAA,EAAc,UAAY,EAAA,OAAA,EAAS,SAAS,MAAM,CAAA;AAAA,GACrD,CAAA;AAEA,EACE,uBAAA,GAAA;AAAA,IAACC,SAAA;AAAA,IAAA;AAAA,MACE,GAAG,IAAA;AAAA,MACJ,GAAA;AAAA,MACA,SAAA,EAAW,YAAY,OAAS,EAAA,SAAA;AAAA,MAChC,KAAA;AAAA,MAEC,QAAA;AAAA,KAAA;AAAA,GACH,CAAA;AAEJ,CAAC;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
var popoverClassNames = { popover: { container: "popover_popoverClassNames_popover_container__1tn75dxf", popover: "popover_popoverClassNames_popover_popover__1tn75dxg surfaces_proud__15mw6jf3 surfaces_flush__15mw6jf2" }, header: "popover_header__1tn75dxd", content: "popover_content__1tn75dxe", footer: "popover_popoverClassNames_footer__1tn75dxh" };
|
|
3
|
+
var popoverColorVars = { content: { color: "var(--content-color__1tn75dx1)" } };
|
|
4
|
+
var popoverSpaceVars = { width: "var(--width__1tn75dx2)", x: "var(--x__1tn75dx3)", y: "var(--y__1tn75dx4)", gap: { "default": "var(--gap-default__1tn75dx5)", header: { after: "var(--gap-header-after__1tn75dx6)" }, content: { before: "var(--gap-content-before__1tn75dx7)" }, footer: { before: "var(--gap-footer-before__1tn75dx8)" } } };
|
|
5
|
+
var popoverStateVars = { hasHeader: "var(--hasHeader__1tn75dx9)", placement: "var(--placement__1tn75dxa)", isEntering: "var(--isEntering__1tn75dxb)", isExiting: "var(--isExiting__1tn75dxc)" };
|
|
6
|
+
|
|
7
|
+
export { popoverClassNames, popoverColorVars, popoverSpaceVars, popoverStateVars };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popover.vanilla.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|