@redsift/pickers 11.5.0 → 11.6.0-muiv5-alpha.0

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.
Files changed (93) hide show
  1. package/_virtual/_rollupPluginBabelHelpers.js +93 -0
  2. package/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
  3. package/components/combobox/Combobox.d.ts +29 -0
  4. package/components/combobox/Combobox.js +151 -0
  5. package/components/combobox/Combobox.js.map +1 -0
  6. package/components/combobox/context.js +6 -0
  7. package/components/combobox/context.js.map +1 -0
  8. package/components/combobox/intl/en-US.json.js +13 -0
  9. package/components/combobox/intl/en-US.json.js.map +1 -0
  10. package/components/combobox/intl/fr-FR.json.js +13 -0
  11. package/components/combobox/intl/fr-FR.json.js.map +1 -0
  12. package/components/combobox/intl/index.js +10 -0
  13. package/components/combobox/intl/index.js.map +1 -0
  14. package/components/combobox/types.d.ts +107 -0
  15. package/components/combobox/types.js +22 -0
  16. package/components/combobox/types.js.map +1 -0
  17. package/components/combobox-content/ComboboxContent.d.ts +17 -0
  18. package/components/combobox-content/ComboboxContent.js +70 -0
  19. package/components/combobox-content/ComboboxContent.js.map +1 -0
  20. package/components/combobox-content/types.d.ts +11 -0
  21. package/components/combobox-content-footer/ComboboxContentFooter.d.ts +9 -0
  22. package/components/combobox-content-footer/ComboboxContentFooter.js +28 -0
  23. package/components/combobox-content-footer/ComboboxContentFooter.js.map +1 -0
  24. package/components/combobox-content-footer/styles.js +12 -0
  25. package/components/combobox-content-footer/styles.js.map +1 -0
  26. package/components/combobox-content-footer/types.d.ts +11 -0
  27. package/components/combobox-content-header/ComboboxContentHeader.d.ts +9 -0
  28. package/components/combobox-content-header/ComboboxContentHeader.js +28 -0
  29. package/components/combobox-content-header/ComboboxContentHeader.js.map +1 -0
  30. package/components/combobox-content-header/styles.js +12 -0
  31. package/components/combobox-content-header/styles.js.map +1 -0
  32. package/components/combobox-content-header/types.d.ts +11 -0
  33. package/components/combobox-content-listbox/ComboboxContentListbox.d.ts +9 -0
  34. package/components/combobox-content-listbox/ComboboxContentListbox.js +124 -0
  35. package/components/combobox-content-listbox/ComboboxContentListbox.js.map +1 -0
  36. package/components/combobox-content-listbox/types.d.ts +12 -0
  37. package/components/combobox-trigger/ComboboxTrigger.d.ts +9 -0
  38. package/components/combobox-trigger/ComboboxTrigger.js +352 -0
  39. package/components/combobox-trigger/ComboboxTrigger.js.map +1 -0
  40. package/components/combobox-trigger/types.d.ts +27 -0
  41. package/components/item/Item.d.ts +8 -0
  42. package/components/item/Item.js +137 -0
  43. package/components/item/Item.js.map +1 -0
  44. package/components/item/useMenuItem.js +69 -0
  45. package/components/item/useMenuItem.js.map +1 -0
  46. package/components/menu-button/MenuButton.d.ts +29 -0
  47. package/components/menu-button/MenuButton.js +76 -0
  48. package/components/menu-button/MenuButton.js.map +1 -0
  49. package/components/menu-button/context.js +6 -0
  50. package/components/menu-button/context.js.map +1 -0
  51. package/components/menu-button/types.d.ts +45 -0
  52. package/components/menu-button-content/MenuButtonContent.d.ts +17 -0
  53. package/components/menu-button-content/MenuButtonContent.js +68 -0
  54. package/components/menu-button-content/MenuButtonContent.js.map +1 -0
  55. package/components/menu-button-content/types.d.ts +9 -0
  56. package/components/menu-button-content-footer/MenuButtonContentFooter.d.ts +9 -0
  57. package/components/menu-button-content-footer/MenuButtonContentFooter.js +28 -0
  58. package/components/menu-button-content-footer/MenuButtonContentFooter.js.map +1 -0
  59. package/components/menu-button-content-footer/styles.js +12 -0
  60. package/components/menu-button-content-footer/styles.js.map +1 -0
  61. package/components/menu-button-content-footer/types.d.ts +11 -0
  62. package/components/menu-button-content-header/MenuButtonContentHeader.d.ts +9 -0
  63. package/components/menu-button-content-header/MenuButtonContentHeader.js +28 -0
  64. package/components/menu-button-content-header/MenuButtonContentHeader.js.map +1 -0
  65. package/components/menu-button-content-header/styles.js +12 -0
  66. package/components/menu-button-content-header/styles.js.map +1 -0
  67. package/components/menu-button-content-header/types.d.ts +11 -0
  68. package/components/menu-button-content-menu/MenuButtonContentMenu.d.ts +9 -0
  69. package/components/menu-button-content-menu/MenuButtonContentMenu.js +41 -0
  70. package/components/menu-button-content-menu/MenuButtonContentMenu.js.map +1 -0
  71. package/components/menu-button-content-menu/types.d.ts +9 -0
  72. package/components/menu-button-trigger/MenuButtonTrigger.d.ts +9 -0
  73. package/components/menu-button-trigger/MenuButtonTrigger.js +167 -0
  74. package/components/menu-button-trigger/MenuButtonTrigger.js.map +1 -0
  75. package/components/menu-button-trigger/types.d.ts +15 -0
  76. package/components/select/Select.d.ts +22 -0
  77. package/components/select/Select.js +116 -0
  78. package/components/select/Select.js.map +1 -0
  79. package/components/select/context.js +6 -0
  80. package/components/select/context.js.map +1 -0
  81. package/components/select/types.d.ts +61 -0
  82. package/components/select-content/SelectContent.d.ts +9 -0
  83. package/components/select-content/SelectContent.js +62 -0
  84. package/components/select-content/SelectContent.js.map +1 -0
  85. package/components/select-content/types.d.ts +9 -0
  86. package/components/select-trigger/SelectTrigger.d.ts +9 -0
  87. package/components/select-trigger/SelectTrigger.js +249 -0
  88. package/components/select-trigger/SelectTrigger.js.map +1 -0
  89. package/components/select-trigger/types.d.ts +17 -0
  90. package/index.d.ts +31 -438
  91. package/index.js +17 -1822
  92. package/index.js.map +1 -1
  93. package/package.json +8 -8
@@ -0,0 +1,167 @@
1
+ import { objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React, { forwardRef, useContext } from 'react';
3
+ import classNames from 'classnames';
4
+ import { FocusWithinGroupContext, useTheme, isComponent, FocusWithinGroupActionType, EventKey } from '@redsift/design-system';
5
+ import { usePopoverContext, useMergeRefs } from '@redsift/popovers';
6
+ import { MenuButtonContext } from '../menu-button/context.js';
7
+
8
+ const COMPONENT_NAME = 'MenuButtonTrigger';
9
+ const CLASSNAME = 'redsift-menu-button-trigger';
10
+
11
+ /**
12
+ * The MenuButtonTrigger component.
13
+ */
14
+ const MenuButtonTrigger = /*#__PURE__*/forwardRef((props, ref) => {
15
+ const {
16
+ children
17
+ } = props;
18
+ const {
19
+ getReferenceProps,
20
+ isOpen,
21
+ handleOpen,
22
+ refs
23
+ } = usePopoverContext();
24
+ const childrenRef = children.ref;
25
+ const triggerRef = useMergeRefs([refs.setReference, ref, childrenRef]);
26
+ const focusContext = useContext(FocusWithinGroupContext);
27
+ const menuButtonContext = useContext(MenuButtonContext);
28
+ const theme = useTheme();
29
+ const renderedChildren = typeof children === 'function' ? children({
30
+ isOpen
31
+ }) : children;
32
+ const handleKeyDown = event => {
33
+ const code = event.code;
34
+ if (code === 'Escape' || code === 'Tab') {
35
+ if (isOpen) {
36
+ handleOpen(false);
37
+ }
38
+ } else if (code === 'ArrowDown') {
39
+ if (!isOpen) {
40
+ handleOpen(true);
41
+ }
42
+ if (focusContext.state.selectedId !== null) {
43
+ focusContext.dispatch({
44
+ type: FocusWithinGroupActionType.DELAY_ACTION,
45
+ payload: {
46
+ type: FocusWithinGroupActionType.KEY_DOWN_ON_LIST,
47
+ payload: {
48
+ key: EventKey.ArrowDown,
49
+ ctrlKey: event.ctrlKey
50
+ }
51
+ }
52
+ });
53
+ } else {
54
+ focusContext.dispatch({
55
+ type: FocusWithinGroupActionType.DELAY_ACTION,
56
+ payload: {
57
+ type: FocusWithinGroupActionType.KEY_DOWN_ON_LIST,
58
+ payload: {
59
+ key: EventKey.Home,
60
+ ctrlKey: event.ctrlKey
61
+ }
62
+ }
63
+ });
64
+ }
65
+ event.preventDefault();
66
+ event.stopPropagation();
67
+ } else if (code === 'ArrowUp') {
68
+ if (!isOpen) {
69
+ handleOpen(true);
70
+ }
71
+ focusContext.dispatch({
72
+ type: FocusWithinGroupActionType.DELAY_ACTION,
73
+ payload: {
74
+ type: FocusWithinGroupActionType.KEY_DOWN_ON_LIST,
75
+ payload: {
76
+ key: focusContext.state.selectedId !== null ? EventKey.ArrowUp : EventKey.Home,
77
+ ctrlKey: event.ctrlKey
78
+ }
79
+ }
80
+ });
81
+ event.preventDefault();
82
+ event.stopPropagation();
83
+ } else if (code === 'Home') {
84
+ if (!isOpen) {
85
+ handleOpen(true);
86
+ }
87
+ focusContext.dispatch({
88
+ type: FocusWithinGroupActionType.DELAY_ACTION,
89
+ payload: {
90
+ type: FocusWithinGroupActionType.KEY_DOWN_ON_LIST,
91
+ payload: {
92
+ key: EventKey.Home,
93
+ ctrlKey: event.ctrlKey
94
+ }
95
+ }
96
+ });
97
+ event.preventDefault();
98
+ event.stopPropagation();
99
+ } else if (code === 'End') {
100
+ if (!isOpen) {
101
+ handleOpen(true);
102
+ }
103
+ focusContext.dispatch({
104
+ type: FocusWithinGroupActionType.DELAY_ACTION,
105
+ payload: {
106
+ type: FocusWithinGroupActionType.KEY_DOWN_ON_LIST,
107
+ payload: {
108
+ key: EventKey.End,
109
+ ctrlKey: event.ctrlKey
110
+ }
111
+ }
112
+ });
113
+ event.preventDefault();
114
+ event.stopPropagation();
115
+ } else if (code === 'Enter') {
116
+ if (isOpen && focusContext.state.selectedId) {
117
+ var _document$getElementB, _document$getElementB2, _document$getElementB3, _document$getElementB4;
118
+ (_document$getElementB = document.getElementById(focusContext.state.selectedId)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.click();
119
+ (_document$getElementB2 = document.getElementById(focusContext.state.selectedId)) === null || _document$getElementB2 === void 0 ? void 0 : (_document$getElementB3 = _document$getElementB2.getElementsByTagName('a')) === null || _document$getElementB3 === void 0 ? void 0 : (_document$getElementB4 = _document$getElementB3[0]) === null || _document$getElementB4 === void 0 ? void 0 : _document$getElementB4.click();
120
+ }
121
+ }
122
+ };
123
+ const handleClick = event => {
124
+ event.preventDefault();
125
+ event.stopPropagation();
126
+ if (isOpen) {
127
+ handleOpen(false);
128
+ } else {
129
+ var _focusContext$state$a, _focusContext$state$a2;
130
+ handleOpen(true);
131
+ focusContext.dispatch({
132
+ type: FocusWithinGroupActionType.DELAY_ACTION,
133
+ payload: {
134
+ type: FocusWithinGroupActionType.FOCUS_ON_LIST,
135
+ payload: {
136
+ id: (_focusContext$state$a = (_focusContext$state$a2 = focusContext.state.activedescendant) === null || _focusContext$state$a2 === void 0 ? void 0 : _focusContext$state$a2[0]) !== null && _focusContext$state$a !== void 0 ? _focusContext$state$a : ''
137
+ }
138
+ }
139
+ });
140
+ }
141
+ };
142
+ if (isComponent('Button')(renderedChildren) || isComponent('IconButton')(renderedChildren)) {
143
+ var _props$children, _focusContext$state$a3, _menuButtonContext$co, _menuButtonContext$va;
144
+ return /*#__PURE__*/React.cloneElement(renderedChildren, _objectSpread2(_objectSpread2({}, getReferenceProps(_objectSpread2(_objectSpread2(_objectSpread2({
145
+ ref: triggerRef
146
+ }, props), renderedChildren.props), {}, {
147
+ children: (_props$children = renderedChildren.props.children) !== null && _props$children !== void 0 ? _props$children : ''
148
+ }))), {}, {
149
+ theme,
150
+ 'aria-activedescendant': isOpen ? (_focusContext$state$a3 = focusContext.state.activedescendant) === null || _focusContext$state$a3 === void 0 ? void 0 : _focusContext$state$a3[0] : undefined,
151
+ className: classNames(renderedChildren.props.className, menuButtonContext === null || menuButtonContext === void 0 ? void 0 : menuButtonContext.triggerClassName),
152
+ color: (_menuButtonContext$co = menuButtonContext === null || menuButtonContext === void 0 ? void 0 : menuButtonContext.color) !== null && _menuButtonContext$co !== void 0 ? _menuButtonContext$co : renderedChildren.props.color,
153
+ isActive: isOpen,
154
+ isDisabled: menuButtonContext === null || menuButtonContext === void 0 ? void 0 : menuButtonContext.isDisabled,
155
+ onClick: handleClick,
156
+ onKeyDown: handleKeyDown,
157
+ role: 'button',
158
+ variant: (_menuButtonContext$va = menuButtonContext === null || menuButtonContext === void 0 ? void 0 : menuButtonContext.variant) !== null && _menuButtonContext$va !== void 0 ? _menuButtonContext$va : renderedChildren.props.variant
159
+ }));
160
+ }
161
+ return /*#__PURE__*/React.createElement(React.Fragment, null, renderedChildren);
162
+ });
163
+ MenuButtonTrigger.className = CLASSNAME;
164
+ MenuButtonTrigger.displayName = COMPONENT_NAME;
165
+
166
+ export { MenuButtonTrigger };
167
+ //# sourceMappingURL=MenuButtonTrigger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuButtonTrigger.js","sources":["../../../src/components/menu-button-trigger/MenuButtonTrigger.tsx"],"sourcesContent":["import React, { MouseEvent, ReactElement, forwardRef, useContext } from 'react';\nimport classNames from 'classnames';\n\nimport {\n Comp,\n EventKey,\n FocusWithinGroupActionType,\n FocusWithinGroupContext,\n isComponent,\n useTheme,\n} from '@redsift/design-system';\nimport { MenuButtonTriggerProps } from './types';\nimport { useMergeRefs, usePopoverContext } from '@redsift/popovers';\nimport { MenuButtonContext } from '../menu-button/context';\n\nconst COMPONENT_NAME = 'MenuButtonTrigger';\nconst CLASSNAME = 'redsift-menu-button-trigger';\n\n/**\n * The MenuButtonTrigger component.\n */\nexport const MenuButtonTrigger: Comp<MenuButtonTriggerProps, HTMLButtonElement> = forwardRef((props, ref) => {\n const { children } = props;\n\n const { getReferenceProps, isOpen, handleOpen, refs } = usePopoverContext();\n const childrenRef = (children as any).ref;\n const triggerRef = useMergeRefs([refs.setReference, ref, childrenRef]);\n\n const focusContext = useContext(FocusWithinGroupContext);\n const menuButtonContext = useContext(MenuButtonContext);\n const theme = useTheme();\n\n const renderedChildren = typeof children === 'function' ? children({ isOpen }) : children;\n\n const handleKeyDown = (event: KeyboardEvent) => {\n const code = event.code;\n\n if (code === 'Escape' || code === 'Tab') {\n if (isOpen) {\n handleOpen(false);\n }\n } else if (code === 'ArrowDown') {\n if (!isOpen) {\n handleOpen(true);\n }\n if (focusContext.state.selectedId !== null) {\n focusContext.dispatch({\n type: FocusWithinGroupActionType.DELAY_ACTION,\n payload: {\n type: FocusWithinGroupActionType.KEY_DOWN_ON_LIST,\n payload: {\n key: EventKey.ArrowDown,\n ctrlKey: event.ctrlKey,\n },\n },\n });\n } else {\n focusContext.dispatch({\n type: FocusWithinGroupActionType.DELAY_ACTION,\n payload: {\n type: FocusWithinGroupActionType.KEY_DOWN_ON_LIST,\n payload: {\n key: EventKey.Home,\n ctrlKey: event.ctrlKey,\n },\n },\n });\n }\n event.preventDefault();\n event.stopPropagation();\n } else if (code === 'ArrowUp') {\n if (!isOpen) {\n handleOpen(true);\n }\n focusContext.dispatch({\n type: FocusWithinGroupActionType.DELAY_ACTION,\n payload: {\n type: FocusWithinGroupActionType.KEY_DOWN_ON_LIST,\n payload: {\n key: focusContext.state.selectedId !== null ? EventKey.ArrowUp : EventKey.Home,\n ctrlKey: event.ctrlKey,\n },\n },\n });\n event.preventDefault();\n event.stopPropagation();\n } else if (code === 'Home') {\n if (!isOpen) {\n handleOpen(true);\n }\n focusContext.dispatch({\n type: FocusWithinGroupActionType.DELAY_ACTION,\n payload: {\n type: FocusWithinGroupActionType.KEY_DOWN_ON_LIST,\n payload: {\n key: EventKey.Home,\n ctrlKey: event.ctrlKey,\n },\n },\n });\n event.preventDefault();\n event.stopPropagation();\n } else if (code === 'End') {\n if (!isOpen) {\n handleOpen(true);\n }\n focusContext.dispatch({\n type: FocusWithinGroupActionType.DELAY_ACTION,\n payload: {\n type: FocusWithinGroupActionType.KEY_DOWN_ON_LIST,\n payload: {\n key: EventKey.End,\n ctrlKey: event.ctrlKey,\n },\n },\n });\n event.preventDefault();\n event.stopPropagation();\n } else if (code === 'Enter') {\n if (isOpen && focusContext.state.selectedId) {\n document.getElementById(focusContext.state.selectedId)?.click();\n document.getElementById(focusContext.state.selectedId)?.getElementsByTagName('a')?.[0]?.click();\n }\n }\n };\n\n const handleClick = (event: MouseEvent) => {\n event.preventDefault();\n event.stopPropagation();\n if (isOpen) {\n handleOpen(false);\n } else {\n handleOpen(true);\n focusContext.dispatch({\n type: FocusWithinGroupActionType.DELAY_ACTION,\n payload: {\n type: FocusWithinGroupActionType.FOCUS_ON_LIST,\n payload: {\n id: focusContext.state.activedescendant?.[0] ?? '',\n },\n },\n });\n }\n };\n\n if (isComponent('Button')(renderedChildren) || isComponent('IconButton')(renderedChildren)) {\n return React.cloneElement(renderedChildren, {\n ...getReferenceProps({\n ref: triggerRef,\n ...props,\n ...(renderedChildren as ReactElement).props,\n children: (renderedChildren as ReactElement).props.children ?? '',\n }),\n theme,\n 'aria-activedescendant': isOpen ? focusContext.state.activedescendant?.[0] : undefined,\n className: classNames((renderedChildren as ReactElement).props.className, menuButtonContext?.triggerClassName),\n color: menuButtonContext?.color ?? (renderedChildren as ReactElement).props.color,\n isActive: isOpen,\n isDisabled: menuButtonContext?.isDisabled,\n onClick: handleClick,\n onKeyDown: handleKeyDown,\n role: 'button',\n variant: menuButtonContext?.variant ?? (renderedChildren as ReactElement).props.variant,\n });\n }\n\n return <>{renderedChildren}</>;\n});\nMenuButtonTrigger.className = CLASSNAME;\nMenuButtonTrigger.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","MenuButtonTrigger","forwardRef","props","ref","children","getReferenceProps","isOpen","handleOpen","refs","usePopoverContext","childrenRef","triggerRef","useMergeRefs","setReference","focusContext","useContext","FocusWithinGroupContext","menuButtonContext","MenuButtonContext","theme","useTheme","renderedChildren","handleKeyDown","event","code","state","selectedId","dispatch","type","FocusWithinGroupActionType","DELAY_ACTION","payload","KEY_DOWN_ON_LIST","key","EventKey","ArrowDown","ctrlKey","Home","preventDefault","stopPropagation","ArrowUp","End","_document$getElementB","_document$getElementB2","_document$getElementB3","_document$getElementB4","document","getElementById","click","getElementsByTagName","handleClick","_focusContext$state$a","_focusContext$state$a2","FOCUS_ON_LIST","id","activedescendant","isComponent","_props$children","_focusContext$state$a3","_menuButtonContext$co","_menuButtonContext$va","React","cloneElement","_objectSpread","undefined","className","classNames","triggerClassName","color","isActive","isDisabled","onClick","onKeyDown","role","variant","createElement","Fragment","displayName"],"mappings":";;;;;;;AAeA,MAAMA,cAAc,GAAG,mBAAmB,CAAA;AAC1C,MAAMC,SAAS,GAAG,6BAA6B,CAAA;;AAE/C;AACA;AACA;AACO,MAAMC,iBAAkE,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EAC3G,MAAM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MAAAA,KAAK,GAAAT,qBAAA,GAAE1C,iBAAiB,KAAjBA,IAAAA,IAAAA,iBAAiB,uBAAjBA,iBAAiB,CAAEmD,KAAK,MAAAT,IAAAA,IAAAA,qBAAA,cAAAA,qBAAA,GAAKtC,gBAAgB,CAAkBnB,KAAK,CAACkE,KAAK;AACjFC,MAAAA,QAAQ,EAAE/D,MAAM;AAChBgE,MAAAA,UAAU,EAAErD,iBAAiB,KAAA,IAAA,IAAjBA,iBAAiB,KAAjBA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,iBAAiB,CAAEqD,UAAU;AACzCC,MAAAA,OAAO,EAAErB,WAAW;AACpBsB,MAAAA,SAAS,EAAElD,aAAa;AACxBmD,MAAAA,IAAI,EAAE,QAAQ;AACdC,MAAAA,OAAO,GAAAd,qBAAA,GAAE3C,iBAAiB,KAAjBA,IAAAA,IAAAA,iBAAiB,uBAAjBA,iBAAiB,CAAEyD,OAAO,MAAA,IAAA,IAAAd,qBAAA,KAAAA,KAAAA,CAAAA,GAAAA,qBAAA,GAAKvC,gBAAgB,CAAkBnB,KAAK,CAACwE,OAAAA;AAAO,KAAA,CACxF,CAAC,CAAA;AACJ,GAAA;EAEA,oBAAOb,KAAA,CAAAc,aAAA,CAAAd,KAAA,CAAAe,QAAA,EAAGvD,IAAAA,EAAAA,gBAAmB,CAAC,CAAA;AAChC,CAAC,EAAC;AACFrB,iBAAiB,CAACiE,SAAS,GAAGlE,SAAS,CAAA;AACvCC,iBAAiB,CAAC6E,WAAW,GAAG/E,cAAc;;;;"}
@@ -0,0 +1,15 @@
1
+ import { PopoverTriggerProps } from '@redsift/popovers';
2
+ import { ReactElement } from 'react';
3
+
4
+ /**
5
+ * Component props.
6
+ */
7
+ interface MenuButtonTriggerProps extends Omit<PopoverTriggerProps, 'children'> {
8
+ /** Children */
9
+ children: ReactElement | ((state: {
10
+ value?: string;
11
+ isOpen?: boolean;
12
+ }) => ReactElement);
13
+ }
14
+
15
+ export { MenuButtonTriggerProps };
@@ -0,0 +1,22 @@
1
+ import * as _redsift_design_system from '@redsift/design-system';
2
+ import React from 'react';
3
+ import { SelectProps } from './types.js';
4
+ import { SelectTriggerProps } from '../select-trigger/types.js';
5
+ import { SelectContentProps } from '../select-content/types.js';
6
+
7
+ /**
8
+ * The Select component.
9
+ */
10
+ declare const BaseSelect: React.FC<SelectProps> & {
11
+ displayName?: string;
12
+ className?: string;
13
+ };
14
+ declare const Select: React.FC<SelectProps> & {
15
+ displayName?: string | undefined;
16
+ className?: string | undefined;
17
+ } & {
18
+ Trigger: _redsift_design_system.Comp<SelectTriggerProps, HTMLButtonElement>;
19
+ Content: _redsift_design_system.Comp<SelectContentProps, HTMLDivElement>;
20
+ };
21
+
22
+ export { BaseSelect, Select };
@@ -0,0 +1,116 @@
1
+ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React, { useState, useEffect, useReducer, useMemo } from 'react';
3
+ import { Popover } from '@redsift/popovers';
4
+ import { SelectContext } from './context.js';
5
+ import { useTheme, ListboxReducer, ListboxActionType, ThemeProvider, FocusWithinGroup, ListboxContext, Flexbox, Text, Theme } from '@redsift/design-system';
6
+ import { SelectTrigger } from '../select-trigger/SelectTrigger.js';
7
+ import { SelectContent } from '../select-content/SelectContent.js';
8
+
9
+ const COMPONENT_NAME = 'Select';
10
+ const CLASSNAME = 'redsift-select';
11
+
12
+ /**
13
+ * The Select component.
14
+ */
15
+ const BaseSelect = props => {
16
+ const {
17
+ color,
18
+ defaultValue,
19
+ description,
20
+ descriptionProps,
21
+ isDisabled,
22
+ isInvalid,
23
+ minWidth = 'trigger-width',
24
+ onChange,
25
+ theme: propsTheme,
26
+ triggerClassName,
27
+ value,
28
+ variant,
29
+ wrapperProps
30
+ } = props;
31
+ const theme = useTheme(propsTheme);
32
+ const [selectedValue, setValue] = useState(value || defaultValue || '');
33
+ useEffect(() => {
34
+ if (value) {
35
+ state.setValue(value);
36
+ }
37
+ }, [value]);
38
+
39
+ /** Listbox context */
40
+ const [listboxState, listboxDispatch] = useReducer(ListboxReducer, {
41
+ isDisabled,
42
+ selectedValues: [selectedValue]
43
+ });
44
+ const listboxContext = useMemo(() => ({
45
+ state: listboxState,
46
+ dispatch: listboxDispatch
47
+ }), [listboxState]);
48
+ useEffect(() => {
49
+ listboxDispatch({
50
+ type: ListboxActionType.UPDATE_OPTIONS,
51
+ payload: {
52
+ isDisabled: isDisabled || false
53
+ }
54
+ });
55
+ }, [isDisabled, theme]);
56
+
57
+ /** Select context. */
58
+ const state = {
59
+ color,
60
+ isDisabled: isDisabled || false,
61
+ isInvalid: isInvalid || false,
62
+ setValue(value) {
63
+ if (isDisabled) {
64
+ return;
65
+ }
66
+ const previousValue = selectedValue;
67
+ setValue(value);
68
+ if (value !== previousValue && onChange) {
69
+ onChange(value);
70
+ }
71
+ },
72
+ theme,
73
+ triggerClassName,
74
+ value: selectedValue,
75
+ variant
76
+ };
77
+ return /*#__PURE__*/React.createElement(ThemeProvider, {
78
+ value: {
79
+ theme
80
+ }
81
+ }, /*#__PURE__*/React.createElement(FocusWithinGroup, {
82
+ focusType: "virtual-focus",
83
+ focusOnInit: false
84
+ }, /*#__PURE__*/React.createElement(SelectContext.Provider, {
85
+ value: state
86
+ }, /*#__PURE__*/React.createElement(ListboxContext.Provider, {
87
+ value: listboxContext
88
+ }, /*#__PURE__*/React.createElement(Flexbox, _extends({
89
+ flexDirection: "column",
90
+ alignItems: "flex-start",
91
+ gap: "0px"
92
+ }, wrapperProps), /*#__PURE__*/React.createElement(Popover, _extends({
93
+ theme: theme,
94
+ overrideDisplayName: {
95
+ content: 'SelectContent',
96
+ trigger: 'SelectTrigger'
97
+ },
98
+ placement: "bottom-start",
99
+ role: "listbox",
100
+ minWidth: minWidth
101
+ }, props)), description && typeof description === 'string' ? /*#__PURE__*/React.createElement(Text, _extends({
102
+ theme: theme,
103
+ marginTop: "8px",
104
+ variant: "caption",
105
+ color: isInvalid ? 'error' : theme === Theme.light ? 'dark-grey' : 'white'
106
+ }, descriptionProps), description) : description ? description : null)))));
107
+ };
108
+ BaseSelect.className = CLASSNAME;
109
+ BaseSelect.displayName = COMPONENT_NAME;
110
+ const Select = Object.assign(BaseSelect, {
111
+ Trigger: SelectTrigger,
112
+ Content: SelectContent
113
+ });
114
+
115
+ export { BaseSelect, Select };
116
+ //# sourceMappingURL=Select.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Select.js","sources":["../../../src/components/select/Select.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useReducer, useState } from 'react';\nimport { SelectContent } from '../select-content';\nimport { SelectTrigger } from '../select-trigger';\n\nimport { SelectProps } from './types';\nimport { Popover } from '@redsift/popovers';\nimport { SelectContext } from './context';\nimport {\n ListboxReducer,\n ListboxState,\n ListboxContextProps,\n FocusWithinGroup,\n ListboxContext,\n Flexbox,\n Text,\n ListboxActionType,\n Theme,\n useTheme,\n ThemeProvider,\n} from '@redsift/design-system';\n\nconst COMPONENT_NAME = 'Select';\nconst CLASSNAME = 'redsift-select';\n\n/**\n * The Select component.\n */\nexport const BaseSelect: React.FC<SelectProps> & {\n displayName?: string;\n className?: string;\n} = (props) => {\n const {\n color,\n defaultValue,\n description,\n descriptionProps,\n isDisabled,\n isInvalid,\n minWidth = 'trigger-width',\n onChange,\n theme: propsTheme,\n triggerClassName,\n value,\n variant,\n wrapperProps,\n } = props;\n\n const theme = useTheme(propsTheme);\n\n const [selectedValue, setValue] = useState<string>(value || defaultValue || '');\n useEffect(() => {\n if (value) {\n state.setValue(value);\n }\n }, [value]);\n\n /** Listbox context */\n const [listboxState, listboxDispatch] = useReducer(ListboxReducer, {\n isDisabled,\n selectedValues: [selectedValue],\n } as ListboxState);\n const listboxContext = useMemo<ListboxContextProps>(\n () => ({\n state: listboxState,\n dispatch: listboxDispatch,\n }),\n [listboxState]\n );\n useEffect(() => {\n listboxDispatch({\n type: ListboxActionType.UPDATE_OPTIONS,\n payload: {\n isDisabled: isDisabled || false,\n },\n });\n }, [isDisabled, theme]);\n\n /** Select context. */\n const state = {\n color,\n isDisabled: isDisabled || false,\n isInvalid: isInvalid || false,\n setValue(value: string) {\n if (isDisabled) {\n return;\n }\n\n const previousValue = selectedValue;\n setValue(value);\n if (value !== previousValue && onChange) {\n onChange(value);\n }\n },\n theme,\n triggerClassName,\n value: selectedValue,\n variant,\n };\n\n return (\n <ThemeProvider value={{ theme }}>\n <FocusWithinGroup focusType=\"virtual-focus\" focusOnInit={false}>\n <SelectContext.Provider value={state}>\n <ListboxContext.Provider value={listboxContext}>\n <Flexbox flexDirection=\"column\" alignItems=\"flex-start\" gap=\"0px\" {...wrapperProps}>\n <Popover\n theme={theme}\n overrideDisplayName={{ content: 'SelectContent', trigger: 'SelectTrigger' }}\n placement=\"bottom-start\"\n role=\"listbox\"\n minWidth={minWidth}\n {...props}\n />\n {description && typeof description === 'string' ? (\n <Text\n theme={theme}\n marginTop=\"8px\"\n variant=\"caption\"\n color={isInvalid ? 'error' : theme === Theme.light ? 'dark-grey' : 'white'}\n {...descriptionProps}\n >\n {description}\n </Text>\n ) : description ? (\n description\n ) : null}\n </Flexbox>\n </ListboxContext.Provider>\n </SelectContext.Provider>\n </FocusWithinGroup>\n </ThemeProvider>\n );\n};\nBaseSelect.className = CLASSNAME;\nBaseSelect.displayName = COMPONENT_NAME;\n\nexport const Select = Object.assign(BaseSelect, {\n Trigger: SelectTrigger,\n Content: SelectContent,\n});\n"],"names":["COMPONENT_NAME","CLASSNAME","BaseSelect","props","color","defaultValue","description","descriptionProps","isDisabled","isInvalid","minWidth","onChange","theme","propsTheme","triggerClassName","value","variant","wrapperProps","useTheme","selectedValue","setValue","useState","useEffect","state","listboxState","listboxDispatch","useReducer","ListboxReducer","selectedValues","listboxContext","useMemo","dispatch","type","ListboxActionType","UPDATE_OPTIONS","payload","previousValue","React","createElement","ThemeProvider","FocusWithinGroup","focusType","focusOnInit","SelectContext","Provider","ListboxContext","Flexbox","_extends","flexDirection","alignItems","gap","Popover","overrideDisplayName","content","trigger","placement","role","Text","marginTop","Theme","light","className","displayName","Select","Object","assign","Trigger","SelectTrigger","Content","SelectContent"],"mappings":";;;;;;;;AAqBA,MAAMA,cAAc,GAAG,QAAQ,CAAA;AAC/B,MAAMC,SAAS,GAAG,gBAAgB,CAAA;;AAElC;AACA;AACA;AACaC,MAAAA,UAGZ,GAAIC,KAAK,IAAK;EACb,MAAM;IACJC,KAAK;IACLC,YAAY;IACZC,WAAW;IACXC,gBAAgB;IAChBC,UAAU;IACVC,SAAS;AACTC,IAAAA,QAAQ,GAAG,eAAe;IAC1BC,QAAQ;AACRC,IAAAA,KAAK,EAAEC,UAAU;IACjBC,gBAAgB;IAChBC,KAAK;IACLC,OAAO;AACPC,IAAAA,YAAAA;AACF,GAAC,GAAGd,KAAK,CAAA;AAET,EAAA,MAAMS,KAAK,GAAGM,QAAQ,CAACL,UAAU,CAAC,CAAA;AAElC,EAAA,MAAM,CAACM,aAAa,EAAEC,QAAQ,CAAC,GAAGC,QAAQ,CAASN,KAAK,IAAIV,YAAY,IAAI,EAAE,CAAC,CAAA;AAC/EiB,EAAAA,SAAS,CAAC,MAAM;AACd,IAAA,IAAIP,KAAK,EAAE;AACTQ,MAAAA,KAAK,CAACH,QAAQ,CAACL,KAAK,CAAC,CAAA;AACvB,KAAA;AACF,GAAC,EAAE,CAACA,KAAK,CAAC,CAAC,CAAA;;AAEX;EACA,MAAM,CAACS,YAAY,EAAEC,eAAe,CAAC,GAAGC,UAAU,CAACC,cAAc,EAAE;IACjEnB,UAAU;IACVoB,cAAc,EAAE,CAACT,aAAa,CAAA;AAChC,GAAiB,CAAC,CAAA;AAClB,EAAA,MAAMU,cAAc,GAAGC,OAAO,CAC5B,OAAO;AACLP,IAAAA,KAAK,EAAEC,YAAY;AACnBO,IAAAA,QAAQ,EAAEN,eAAAA;AACZ,GAAC,CAAC,EACF,CAACD,YAAY,CACf,CAAC,CAAA;AACDF,EAAAA,SAAS,CAAC,MAAM;AACdG,IAAAA,eAAe,CAAC;MACdO,IAA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 export { SelectContext };
6
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sources":["../../../src/components/select/context.ts"],"sourcesContent":["import React from 'react';\nimport { SelectState } from './types';\n\nexport const SelectContext = React.createContext<SelectState | null>(null);\n"],"names":["SelectContext","React","createContext"],"mappings":";;AAGO,MAAMA,aAAa,gBAAGC,KAAK,CAACC,aAAa,CAAqB,IAAI;;;;"}
@@ -0,0 +1,61 @@
1
+ import { ButtonColor, ButtonVariant, TextFieldVariant, TextProps, Theme, FlexboxProps } from '@redsift/design-system';
2
+ import { PopoverProps } from '@redsift/popovers';
3
+ import { ReactElement } from 'react';
4
+
5
+ /**
6
+ * Context props.
7
+ */
8
+ type SelectState = {
9
+ /** Button color that will be forward to the trigger. */
10
+ readonly color?: ButtonColor;
11
+ /** Whether the select is disabled or not. */
12
+ readonly isDisabled: boolean;
13
+ /** Whether the select is invalid or not. */
14
+ readonly isInvalid: boolean;
15
+ /** Sets the selected value. */
16
+ setValue(value: string): void;
17
+ /** Current selected value. */
18
+ readonly value: string;
19
+ /** Class name to append to the trigger. */
20
+ readonly triggerClassName?: string;
21
+ /** Button variant that will be forward to the trigger. */
22
+ readonly variant?: ButtonVariant | TextFieldVariant;
23
+ };
24
+ /**
25
+ * Component props.
26
+ */
27
+ interface SelectProps extends PopoverProps {
28
+ /** Button color that will be forward to the trigger. */
29
+ color?: ButtonColor;
30
+ /**
31
+ * Default selected value.
32
+ * Used for uncontrolled version.
33
+ */
34
+ defaultValue?: string;
35
+ /** Description of the select. */
36
+ description?: string | ReactElement;
37
+ /** Additional description properties. */
38
+ descriptionProps?: Omit<TextProps, 'ref'>;
39
+ /** Whether the component is disabled or not. */
40
+ isDisabled?: boolean;
41
+ /** Whether the component is invalid or not. */
42
+ isInvalid?: boolean;
43
+ /** Method to handle component change. */
44
+ onChange?(value: string): void;
45
+ /**
46
+ * Currently selected value.
47
+ * Used for controlled version.
48
+ */
49
+ value?: string;
50
+ /** Button variant that will be forward to the trigger. */
51
+ variant?: ButtonVariant | TextFieldVariant;
52
+ /** Theme. */
53
+ theme?: Theme;
54
+ /** Class name to append to the trigger. */
55
+ triggerClassName?: string;
56
+ /** Props to forward to the wrapper. */
57
+ wrapperProps?: Omit<FlexboxProps, 'ref'>;
58
+ }
59
+ type StyledSelectProps = SelectProps;
60
+
61
+ export { SelectProps, SelectState, StyledSelectProps };
@@ -0,0 +1,9 @@
1
+ import { Comp } from '@redsift/design-system';
2
+ import { SelectContentProps } from './types.js';
3
+
4
+ /**
5
+ * The SelectContent component.
6
+ */
7
+ declare const SelectContent: Comp<SelectContentProps, HTMLDivElement>;
8
+
9
+ export { SelectContent };
@@ -0,0 +1,62 @@
1
+ import { extends as _extends, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React, { forwardRef, useContext, useEffect } from 'react';
3
+ import { getContainerProps, AppContainerContext, FocusWithinGroupContext, ListboxContext, useTheme, Flexbox } from '@redsift/design-system';
4
+ import { usePopoverContext, useMergeRefs, FloatingPortal, StyledPopoverContent, PopoverContent } from '@redsift/popovers';
5
+ import classNames from 'classnames';
6
+
7
+ const COMPONENT_NAME = 'SelectContent';
8
+ const CLASSNAME = 'redsift-select-content';
9
+
10
+ /**
11
+ * The SelectContent component.
12
+ */
13
+ const SelectContent = /*#__PURE__*/forwardRef((props, ref) => {
14
+ const {
15
+ children,
16
+ className,
17
+ style
18
+ } = props;
19
+ const containerProps = getContainerProps(props);
20
+ const {
21
+ getFloatingProps,
22
+ isOpen,
23
+ refs,
24
+ strategy,
25
+ x,
26
+ y
27
+ } = usePopoverContext();
28
+ const popoverRef = useMergeRefs([refs.setFloating, ref]);
29
+ const appContainerState = useContext(AppContainerContext);
30
+ const focusContext = useContext(FocusWithinGroupContext);
31
+ const listboxState = useContext(ListboxContext);
32
+ const theme = useTheme();
33
+ useEffect(() => {
34
+ if (focusContext && focusContext.state.delayedAction && focusContext.state.tabStops.length) {
35
+ focusContext.dispatch(focusContext.state.delayedAction);
36
+ }
37
+ }, [focusContext.state.delayedAction, focusContext.state.tabStops.length]);
38
+ return /*#__PURE__*/React.createElement(FloatingPortal, {
39
+ root: appContainerState === null || appContainerState === void 0 ? void 0 : appContainerState.appContainerRef.current
40
+ }, isOpen && /*#__PURE__*/React.createElement(StyledPopoverContent, _extends({
41
+ $theme: theme,
42
+ ref: popoverRef
43
+ }, getFloatingProps(props), {
44
+ style: _objectSpread2({
45
+ position: strategy,
46
+ top: y !== null && y !== void 0 ? y : 0,
47
+ left: x !== null && x !== void 0 ? x : 0
48
+ }, style),
49
+ className: classNames(PopoverContent.className, SelectContent.className, className),
50
+ "aria-disabled": listboxState.state.isDisabled
51
+ }), /*#__PURE__*/React.createElement(Flexbox, _extends({
52
+ flexDirection: "column",
53
+ gap: "0px",
54
+ margin: "8px 0px",
55
+ width: "100%"
56
+ }, containerProps), children)));
57
+ });
58
+ SelectContent.className = CLASSNAME;
59
+ SelectContent.displayName = COMPONENT_NAME;
60
+
61
+ export { SelectContent };
62
+ //# sourceMappingURL=SelectContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectContent.js","sources":["../../../src/components/select-content/SelectContent.tsx"],"sourcesContent":["import React, { forwardRef, useContext, useEffect } from 'react';\n\nimport {\n AppContainerContext,\n Comp,\n Flexbox,\n FocusWithinGroupContext,\n ListboxContext,\n getContainerProps,\n useTheme,\n} from '@redsift/design-system';\nimport { SelectContentProps } from './types';\nimport {\n FloatingPortal,\n PopoverContent,\n StyledPopoverContent,\n useMergeRefs,\n usePopoverContext,\n} from '@redsift/popovers';\nimport classNames from 'classnames';\n\nconst COMPONENT_NAME = 'SelectContent';\nconst CLASSNAME = 'redsift-select-content';\n\n/**\n * The SelectContent component.\n */\nexport const SelectContent: Comp<SelectContentProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { children, className, style } = props;\n const containerProps = getContainerProps(props);\n\n const { getFloatingProps, isOpen, refs, strategy, x, y } = usePopoverContext();\n const popoverRef = useMergeRefs([refs.setFloating, ref]);\n\n const appContainerState = useContext(AppContainerContext);\n const focusContext = useContext(FocusWithinGroupContext);\n const listboxState = useContext(ListboxContext);\n const theme = useTheme();\n\n useEffect(() => {\n if (focusContext && focusContext.state.delayedAction && focusContext.state.tabStops.length) {\n focusContext.dispatch(focusContext.state.delayedAction);\n }\n }, [focusContext.state.delayedAction, focusContext.state.tabStops.length]);\n\n return (\n <FloatingPortal root={appContainerState?.appContainerRef.current}>\n {isOpen && (\n <StyledPopoverContent\n $theme={theme!}\n ref={popoverRef}\n {...getFloatingProps(props)}\n style={{\n position: strategy,\n top: y ?? 0,\n left: x ?? 0,\n ...style,\n }}\n className={classNames(PopoverContent.className, SelectContent.className, className)}\n aria-disabled={listboxState.state.isDisabled}\n >\n <Flexbox flexDirection=\"column\" gap=\"0px\" margin=\"8px 0px\" width=\"100%\" {...containerProps}>\n {children}\n </Flexbox>\n </StyledPopoverContent>\n )}\n </FloatingPortal>\n );\n});\nSelectContent.className = CLASSNAME;\nSelectContent.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","SelectContent","forwardRef","props","ref","children","className","style","containerProps","getContainerProps","getFloatingProps","isOpen","refs","strategy","x","y","usePopoverContext","popoverRef","useMergeRefs","setFloating","appContainerState","useContext","AppContainerContext","focusContext","FocusWithinGroupContext","listboxState","ListboxContext","theme","useTheme","useEffect","state","delayedAction","tabStops","length","dispatch","React","createElement","FloatingPortal","root","appContainerRef","current","StyledPopoverContent","_extends","$theme","_objectSpread","position","top","left","classNames","PopoverContent","isDisabled","Flexbox","flexDirection","gap","margin","width","displayName"],"mappings":";;;;;;AAqBA,MAAMA,cAAc,GAAG,eAAe,CAAA;AACtC,MAAMC,SAAS,GAAG,wBAAwB,CAAA;;AAE1C;AACA;AACA;AACO,MAAMC,aAAuD,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EAChG,MAAM;IAAEC,QAAQ;IAAEC,SAAS;AAAE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KAAO;AACfvB,IAAAA,GAAG,EAAEa,UAAAA;GACDP,EAAAA,gBAAgB,CAACP,KAAK,CAAC,EAAA;AAC3BI,IAAAA,KAAK,EAAAqC,cAAA,CAAA;AACHC,MAAAA,QAAQ,EAAEhC,QAAQ;AAClBiC,MAAAA,GAAG,EAAE/B,CAAC,KAAA,IAAA,IAADA,CAAC,KAADA,KAAAA,CAAAA,GAAAA,CAAC,GAAI,CAAC;AACXgC,MAAAA,IAAI,EAAEjC,CAAC,KAAA,IAAA,IAADA,CAAC,KAAA,KAAA,CAAA,GAADA,CAAC,GAAI,CAAA;AAAC,KAAA,EACTP,KAAK,CACR;AACFD,IAAAA,SAAS,EAAE0C,UAAU,CAACC,cAAc,CAAC3C,SAAS,EAAEL,aAAa,CAACK,SAAS,EAAEA,SAAS,CAAE;IACpF,eAAemB,EAAAA,YAAY,CAACK,KAAK,CAACoB,UAAAA;AAAW,GAAA,CAAA,eAE7Cf,KAAA,CAAAC,aAAA,CAACe,OAAO,EAAAT,QAAA,CAAA;AAACU,IAAAA,aAAa,EAAC,QAAQ;AAACC,IAAAA,GAAG,EAAC,KAAK;AAACC,IAAAA,MAAM,EAAC,SAAS;AAACC,IAAAA,KAAK,EAAC,MAAA;AAAM,GAAA,EAAK/C,cAAc,CAAA,EACvFH,QACM,CACW,CAEV,CAAC,CAAA;AAErB,CAAC,EAAC;AACFJ,aAAa,CAACK,SAAS,GAAGN,SAAS,CAAA;AACnCC,aAAa,CAACuD,WAAW,GAAGzD,cAAc;;;;"}
@@ -0,0 +1,9 @@
1
+ import { PopoverContentProps } from '@redsift/popovers';
2
+
3
+ /**
4
+ * Component props.
5
+ */
6
+ interface SelectContentProps extends PopoverContentProps {
7
+ }
8
+
9
+ export { SelectContentProps };
@@ -0,0 +1,9 @@
1
+ import { Comp } from '@redsift/design-system';
2
+ import { SelectTriggerProps } from './types.js';
3
+
4
+ /**
5
+ * The SelectTrigger component.
6
+ */
7
+ declare const SelectTrigger: Comp<SelectTriggerProps, HTMLButtonElement>;
8
+
9
+ export { SelectTrigger };