@economic/taco 0.0.1-alpha.8 → 0.0.2-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 (28) hide show
  1. package/dist/components/Combobox/useCombobox.d.ts +3 -3
  2. package/dist/components/Listbox/Listbox.d.ts +0 -1
  3. package/dist/components/RadioGroup/RadioGroup.d.ts +3 -3
  4. package/dist/components/Select/Select.d.ts +0 -5
  5. package/dist/components/Select/useSelect.d.ts +5 -4
  6. package/dist/esm/index.css +6 -78
  7. package/dist/esm/src/components/Combobox/Combobox.js +28 -24
  8. package/dist/esm/src/components/Combobox/Combobox.js.map +1 -1
  9. package/dist/esm/src/components/Combobox/useCombobox.js +32 -38
  10. package/dist/esm/src/components/Combobox/useCombobox.js.map +1 -1
  11. package/dist/esm/src/components/Listbox/Listbox.js +21 -5
  12. package/dist/esm/src/components/Listbox/Listbox.js.map +1 -1
  13. package/dist/esm/src/components/Listbox/ScrollableList.js +6 -4
  14. package/dist/esm/src/components/Listbox/ScrollableList.js.map +1 -1
  15. package/dist/esm/src/components/RadioGroup/RadioGroup.js +17 -16
  16. package/dist/esm/src/components/RadioGroup/RadioGroup.js.map +1 -1
  17. package/dist/esm/src/components/Select/Select.js +27 -26
  18. package/dist/esm/src/components/Select/Select.js.map +1 -1
  19. package/dist/esm/src/components/Select/useSelect.js +72 -39
  20. package/dist/esm/src/components/Select/useSelect.js.map +1 -1
  21. package/dist/index.css +6 -78
  22. package/dist/taco.cjs.development.js +211 -159
  23. package/dist/taco.cjs.development.js.map +1 -1
  24. package/dist/taco.cjs.production.min.js +1 -1
  25. package/dist/taco.cjs.production.min.js.map +1 -1
  26. package/dist/utils/tailwind.d.ts +1 -1
  27. package/package.json +2 -3
  28. package/types.json +237 -250
@@ -1,4 +1,4 @@
1
- import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../../../_virtual/_rollupPluginBabelHelpers.js';
1
+ import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
2
2
  import { forwardRef, createElement } from 'react';
3
3
  import cn from 'classnames';
4
4
  import { ScrollableList } from './ScrollableList.js';
@@ -15,10 +15,18 @@ var Listbox = /*#__PURE__*/forwardRef(function Listbox(props, ref) {
15
15
  list = _useListbox.list,
16
16
  input = _useListbox.input;
17
17
 
18
- var className = cn('yt-listbox', externalClassName);
18
+ var className = cn('bg-white inline-flex relative w-full', externalClassName);
19
19
  return createElement("span", {
20
+ "data-taco": "listbox",
20
21
  className: className
21
- }, createElement(ScrollableList, Object.assign({}, list)), createElement("input", Object.assign({}, input, {
22
+ }, createElement(ScrollableList, Object.assign({}, list, {
23
+ style: _extends({}, list.style, {
24
+ maxHeight: 'calc(12rem + 2px)'
25
+ /* (6 * option height) + listbox border */
26
+
27
+ })
28
+ })), createElement("input", Object.assign({}, input, {
29
+ className: "hidden",
22
30
  type: "text"
23
31
  })));
24
32
  });
@@ -30,10 +38,18 @@ var MultiListbox = /*#__PURE__*/forwardRef(function Listbox(props, ref) {
30
38
  list = _useMultiListbox.list,
31
39
  input = _useMultiListbox.input;
32
40
 
33
- var className = cn('yt-listbox', externalClassName);
41
+ var className = cn('bg-white inline-flex relative w-full', externalClassName);
34
42
  return createElement("span", {
43
+ "data-taco": "listbox",
35
44
  className: className
36
- }, createElement(ScrollableList, Object.assign({}, list)), createElement("input", Object.assign({}, input, {
45
+ }, createElement(ScrollableList, Object.assign({}, list, {
46
+ style: _extends({}, list.style, {
47
+ maxHeight: 'calc(12rem + 2px + 2px)'
48
+ /* (6 * option height) + listbox border + ALL_OPTIONS bottom border */
49
+
50
+ })
51
+ })), createElement("input", Object.assign({}, input, {
52
+ className: "hidden",
37
53
  type: "text"
38
54
  })));
39
55
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Listbox.js","sources":["../../../../../src/components/Listbox/Listbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { useListbox } from './useListbox';\nimport { useMultiListbox } from './useMultiListbox';\nimport { ScrollableList, ScrollableListItemValue, ScrollableListItem } from './ScrollableList';\nimport './Listbox.css';\nimport { State } from '../../types';\n\nexport type ListboxItem = ScrollableListItem;\nexport type ListboxValue = ScrollableListItemValue;\n\nexport type ListboxTexts = {\n /**\n * Text displayed in the listbox if no data provided.\n * To read more about how to provide the text, see [Provider](component:provider) component\n */\n empty: string;\n /**\n * Text displayed in the listbox to indicate the data is loading.\n * Read more about how to provide the text in [Provider](component:provider) component\n */\n loading: string;\n /**\n * The first option displayed in a multiselect listbox that selects all available options.\n * Read more about how to provide the text in [Provider](component:provider) component\n */\n allOption: string;\n};\n\nexport type ListboxProps = Pick<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'onFocus'> &\n Omit<React.InputHTMLAttributes<HTMLElement>, 'defaultValue' | 'onChange' | 'value'> & {\n /** Data indicating the options in listbox */\n data?: ListboxItem[];\n /**\n * Initial value of the listbox.\n * This is used when listbox is mounted, if no value is provided.\n * *Note* that listbox is a controlled component, setting this will also trigger the `onChange` event\n */\n defaultValue?: ListboxValue;\n /** Set what value should have an empty option in listbox */\n emptyValue?: ListboxValue;\n /** Draws attention to the listbox by changing its style and making it visually prominent */\n highlighted?: boolean;\n /**\n * Shows a loading indicator with a text next to it.\n * Read more about how to provide the text in [Provider](component:provider) component\n */\n loading?: boolean;\n /** State will change the style of the listbox */\n state?: State;\n /**\n * Value of the listbox representing the selected item.\n * It needs to be an existing value from the provided data\n */\n value?: ListboxValue;\n };\n\nexport const Listbox = React.forwardRef(function Listbox(props: ListboxProps, ref: React.Ref<HTMLInputElement>) {\n const { className: externalClassName, ...otherProps } = props;\n const { list, input } = useListbox(otherProps, ref);\n const className = cn('yt-listbox', externalClassName);\n\n return (\n <span className={className}>\n <ScrollableList {...list} />\n <input {...input} type=\"text\" />\n </span>\n );\n});\n\nexport const MultiListbox = React.forwardRef(function Listbox(props: ListboxProps, ref: React.Ref<HTMLInputElement>) {\n const { className: externalClassName, ...otherProps } = props;\n const { list, input } = useMultiListbox(otherProps, ref);\n const className = cn('yt-listbox', externalClassName);\n\n return (\n <span className={className}>\n <ScrollableList {...list} />\n <input {...input} type=\"text\" />\n </span>\n );\n});\n"],"names":["Listbox","React","props","ref","externalClassName","className","otherProps","useListbox","list","input","cn","ScrollableList","type","MultiListbox","useMultiListbox"],"mappings":";;;;;;;;;IAyDaA,OAAO,gBAAGC,UAAA,CAAiB,SAASD,OAAT,CAAiBE,KAAjB,EAAsCC,GAAtC;AACpC,MAAmBC,iBAAnB,GAAwDF,KAAxD,CAAQG,SAAR;AAAA,MAAyCC,UAAzC,iCAAwDJ,KAAxD;;AACA,oBAAwBK,UAAU,CAACD,UAAD,EAAaH,GAAb,CAAlC;AAAA,MAAQK,IAAR,eAAQA,IAAR;AAAA,MAAcC,KAAd,eAAcA,KAAd;;AACA,MAAMJ,SAAS,GAAGK,EAAE,CAAC,YAAD,EAAeN,iBAAf,CAApB;AAEA,SACIH,aAAA,OAAA;AAAMI,IAAAA,SAAS,EAAEA;GAAjB,EACIJ,aAAA,CAACU,cAAD,oBAAoBH,KAApB,CADJ,EAEIP,aAAA,QAAA,oBAAWQ;AAAOG,IAAAA,IAAI,EAAC;IAAvB,CAFJ,CADJ;AAMH,CAXsB;IAaVC,YAAY,gBAAGZ,UAAA,CAAiB,SAASD,OAAT,CAAiBE,KAAjB,EAAsCC,GAAtC;AACzC,MAAmBC,iBAAnB,GAAwDF,KAAxD,CAAQG,SAAR;AAAA,MAAyCC,UAAzC,iCAAwDJ,KAAxD;;AACA,yBAAwBY,eAAe,CAACR,UAAD,EAAaH,GAAb,CAAvC;AAAA,MAAQK,IAAR,oBAAQA,IAAR;AAAA,MAAcC,KAAd,oBAAcA,KAAd;;AACA,MAAMJ,SAAS,GAAGK,EAAE,CAAC,YAAD,EAAeN,iBAAf,CAApB;AAEA,SACIH,aAAA,OAAA;AAAMI,IAAAA,SAAS,EAAEA;GAAjB,EACIJ,aAAA,CAACU,cAAD,oBAAoBH,KAApB,CADJ,EAEIP,aAAA,QAAA,oBAAWQ;AAAOG,IAAAA,IAAI,EAAC;IAAvB,CAFJ,CADJ;AAMH,CAX2B;;;;"}
1
+ {"version":3,"file":"Listbox.js","sources":["../../../../../src/components/Listbox/Listbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { useListbox } from './useListbox';\nimport { useMultiListbox } from './useMultiListbox';\nimport { ScrollableList, ScrollableListItemValue, ScrollableListItem } from './ScrollableList';\nimport { State } from '../../types';\n\nexport type ListboxItem = ScrollableListItem;\nexport type ListboxValue = ScrollableListItemValue;\n\nexport type ListboxTexts = {\n /**\n * Text displayed in the listbox if no data provided.\n * To read more about how to provide the text, see [Provider](component:provider) component\n */\n empty: string;\n /**\n * Text displayed in the listbox to indicate the data is loading.\n * Read more about how to provide the text in [Provider](component:provider) component\n */\n loading: string;\n /**\n * The first option displayed in a multiselect listbox that selects all available options.\n * Read more about how to provide the text in [Provider](component:provider) component\n */\n allOption: string;\n};\n\nexport type ListboxProps = Pick<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'onFocus'> &\n Omit<React.InputHTMLAttributes<HTMLElement>, 'defaultValue' | 'onChange' | 'value'> & {\n /** Data indicating the options in listbox */\n data?: ListboxItem[];\n /**\n * Initial value of the listbox.\n * This is used when listbox is mounted, if no value is provided.\n * *Note* that listbox is a controlled component, setting this will also trigger the `onChange` event\n */\n defaultValue?: ListboxValue;\n /** Set what value should have an empty option in listbox */\n emptyValue?: ListboxValue;\n /** Draws attention to the listbox by changing its style and making it visually prominent */\n highlighted?: boolean;\n /**\n * Shows a loading indicator with a text next to it.\n * Read more about how to provide the text in [Provider](component:provider) component\n */\n loading?: boolean;\n /** State will change the style of the listbox */\n state?: State;\n /**\n * Value of the listbox representing the selected item.\n * It needs to be an existing value from the provided data\n */\n value?: ListboxValue;\n };\n\nexport const Listbox = React.forwardRef(function Listbox(props: ListboxProps, ref: React.Ref<HTMLInputElement>) {\n const { className: externalClassName, ...otherProps } = props;\n const { list, input } = useListbox(otherProps, ref);\n const className = cn('bg-white inline-flex relative w-full', externalClassName);\n\n return (\n <span data-taco=\"listbox\" className={className}>\n <ScrollableList\n {...list}\n style={{ ...list.style, maxHeight: 'calc(12rem + 2px)' /* (6 * option height) + listbox border */ }}\n />\n <input {...input} className=\"hidden\" type=\"text\" />\n </span>\n );\n});\n\nexport const MultiListbox = React.forwardRef(function Listbox(props: ListboxProps, ref: React.Ref<HTMLInputElement>) {\n const { className: externalClassName, ...otherProps } = props;\n const { list, input } = useMultiListbox(otherProps, ref);\n const className = cn('bg-white inline-flex relative w-full', externalClassName);\n\n return (\n <span data-taco=\"listbox\" className={className}>\n <ScrollableList\n {...list}\n style={{\n ...list.style,\n maxHeight: 'calc(12rem + 2px + 2px)' /* (6 * option height) + listbox border + ALL_OPTIONS bottom border */,\n }}\n />\n <input {...input} className=\"hidden\" type=\"text\" />\n </span>\n );\n});\n"],"names":["Listbox","React","props","ref","externalClassName","className","otherProps","useListbox","list","input","cn","ScrollableList","style","maxHeight","type","MultiListbox","useMultiListbox"],"mappings":";;;;;;;;;IAwDaA,OAAO,gBAAGC,UAAA,CAAiB,SAASD,OAAT,CAAiBE,KAAjB,EAAsCC,GAAtC;AACpC,MAAmBC,iBAAnB,GAAwDF,KAAxD,CAAQG,SAAR;AAAA,MAAyCC,UAAzC,iCAAwDJ,KAAxD;;AACA,oBAAwBK,UAAU,CAACD,UAAD,EAAaH,GAAb,CAAlC;AAAA,MAAQK,IAAR,eAAQA,IAAR;AAAA,MAAcC,KAAd,eAAcA,KAAd;;AACA,MAAMJ,SAAS,GAAGK,EAAE,CAAC,sCAAD,EAAyCN,iBAAzC,CAApB;AAEA,SACIH,aAAA,OAAA;iBAAgB;AAAUI,IAAAA,SAAS,EAAEA;GAArC,EACIJ,aAAA,CAACU,cAAD,oBACQH;AACJI,IAAAA,KAAK,eAAOJ,IAAI,CAACI,KAAZ;AAAmBC,MAAAA,SAAS,EAAE;AAAoB;;AAAlD;IAFT,CADJ,EAKIZ,aAAA,QAAA,oBAAWQ;AAAOJ,IAAAA,SAAS,EAAC;AAASS,IAAAA,IAAI,EAAC;IAA1C,CALJ,CADJ;AASH,CAdsB;IAgBVC,YAAY,gBAAGd,UAAA,CAAiB,SAASD,OAAT,CAAiBE,KAAjB,EAAsCC,GAAtC;AACzC,MAAmBC,iBAAnB,GAAwDF,KAAxD,CAAQG,SAAR;AAAA,MAAyCC,UAAzC,iCAAwDJ,KAAxD;;AACA,yBAAwBc,eAAe,CAACV,UAAD,EAAaH,GAAb,CAAvC;AAAA,MAAQK,IAAR,oBAAQA,IAAR;AAAA,MAAcC,KAAd,oBAAcA,KAAd;;AACA,MAAMJ,SAAS,GAAGK,EAAE,CAAC,sCAAD,EAAyCN,iBAAzC,CAApB;AAEA,SACIH,aAAA,OAAA;iBAAgB;AAAUI,IAAAA,SAAS,EAAEA;GAArC,EACIJ,aAAA,CAACU,cAAD,oBACQH;AACJI,IAAAA,KAAK,eACEJ,IAAI,CAACI,KADP;AAEDC,MAAAA,SAAS,EAAE;AAA0B;;AAFpC;IAFT,CADJ,EAQIZ,aAAA,QAAA,oBAAWQ;AAAOJ,IAAAA,SAAS,EAAC;AAASS,IAAAA,IAAI,EAAC;IAA1C,CARJ,CADJ;AAYH,CAjB2B;;;;"}
@@ -118,7 +118,9 @@ var ScrollableList = /*#__PURE__*/forwardRef(function ScrollableList(props, ref)
118
118
 
119
119
  var list = _extends({}, otherProps, {
120
120
  className: cn('inline-flex flex-col list-none !p-0 m-0 overflow-y-auto h-auto', getInputClasses(props), {
121
- 'yt-list--multiselect': multiselect
121
+ 'yt-list--multiselect': multiselect,
122
+ 'pointer-events-none': disabled,
123
+ 'cursor-not-allowed': disabled || readOnly
122
124
  }, otherProps.className),
123
125
  disabled: disabled,
124
126
  id: id,
@@ -136,7 +138,7 @@ var ScrollableList = /*#__PURE__*/forwardRef(function ScrollableList(props, ref)
136
138
  'aria-selected': multiselect ? getOptionCheckedState(String(option.value), index) : currentIndex === index,
137
139
  'data-focused': currentIndex === index,
138
140
  children: option.text,
139
- className: cn('flex items-center px-3 w-full cursor-pointer bg-white flex-[0_0_2rem] focus:wcag-blue', {
141
+ className: cn('flex items-center px-3 w-full cursor-pointer bg-white flex-[0_0_2rem] focus:wcag-blue focus:border-blue', {
140
142
  'sticky top-0 font-bold': depth === 0 && !!option.hasChildren
141
143
  }),
142
144
  disabled: option.disabled,
@@ -163,13 +165,13 @@ var ScrollableList = /*#__PURE__*/forwardRef(function ScrollableList(props, ref)
163
165
  optionProps = _objectWithoutPropertiesLoose(_ref, _excluded2);
164
166
 
165
167
  return createElement("li", Object.assign({}, optionProps), icon, createElement("span", {
166
- className: "flex-grow text-left truncate"
168
+ className: "flex-grow truncate text-left"
167
169
  }, children), multiselect && createElement(Checkbox, {
168
170
  checked: optionProps['aria-selected'],
169
171
  onChange: function onChange() {
170
172
  return null;
171
173
  },
172
- className: "ml-2 flex items-center justify-end pointer-events-none overflow-visible p-px"
174
+ className: "pointer-events-none ml-2 flex items-center justify-end overflow-visible p-px"
173
175
  }));
174
176
  }) : createElement("li", {
175
177
  className: "yt-list__empty"
@@ -1 +1 @@
1
- {"version":3,"file":"ScrollableList.js","sources":["../../../../../src/components/Listbox/ScrollableList.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { useProxiedRef } from '../../utils/hooks/useProxiedRef';\nimport { getNextIndexFromKeycode } from '../../utils/hooks/useListKeyboardNavigation';\nimport { useListScrollTo } from '../../utils/hooks/useListScrollTo';\nimport './ScrollableList.css';\nimport { Spinner } from '../Spinner/Spinner';\nimport { useLocalization } from '../Provider/Provider';\nimport { State } from '../../types';\nimport { Checkbox } from '../Checkbox/Checkbox';\nimport { getInputClasses } from '../Input/util';\n\nexport type ScrollableListItemValue = string | number | boolean | null;\n\nexport type ScrollableListItem = {\n /**\n * Set whether the item is disabled.\n * This will both change the style and make the item unselectable\n */\n disabled?: boolean;\n /* Specifies whether the item has child items -- intended for internal use only */\n hasChildren?: boolean;\n /** Place an icon before the item's text */\n icon?: React.ReactElement;\n /* The index path to the item -- intended for internal use only */\n path?: string;\n /** Text describing the item */\n text: string | JSX.Element;\n /** Value of the item */\n value: ScrollableListItemValue;\n /** Child items to show hierarchical data */\n children?: ScrollableListItem[];\n};\n\n/** @internal */\nexport type ScrollableListProps = Omit<\n React.HTMLAttributes<HTMLUListElement>,\n 'defaultValue' | 'id' | 'onChange' | 'onClick' | 'onKeyDown'\n> & {\n /** Data indicating the options in scrollable list */\n data: ScrollableListItem[];\n /** Sets the list to be disabled */\n disabled?: boolean;\n /** Draws attention to the scrollable list by changing its style and making it visually prominent */\n highlighted?: boolean;\n /** Set an id for the scrollable list */\n id: string;\n /**\n * Shows a loading indicator with a text next to it.\n * Read more about how to provide the text in `Provider` component.\n */\n loading?: boolean;\n /**\n * Handler called when current active/selected option changes in a scrollable list.\n * @param index indicates the index of the current active option\n */\n onChange: (index: number) => void;\n /** Handler called when option is clicked */\n onClick?: (event: React.MouseEvent<HTMLLIElement>, index: number) => void;\n /**\n * Set whether the selected item should be scrolled into view when listbox is focused.\n * Default value is `false`\n */\n scrollOnFocus?: boolean;\n /** Handler called when a key is pressed */\n onKeyDown?: (event: React.KeyboardEvent<HTMLUListElement>, index: number | undefined) => void;\n /* Sets the list to read only mode */\n readOnly?: boolean;\n /** State will change the style of the scrollable list */\n state?: State;\n /**\n * Value of the scrollable list representing the selected item.\n * It needs to be an existing value from the provided data.\n */\n value: number | undefined;\n /**\n * Allows to select multiple items from the list\n */\n multiselect?: boolean;\n /**\n * Contains the currently selected values when multiselect mode is ON.\n */\n selectedIndexes?: number[];\n /**\n * True when all available (not disabled) options are selected\n */\n allOptionsSelected?: boolean;\n};\n\n/** @internal */\nexport type ScrollableListPropsWithRef = ScrollableListProps & React.RefAttributes<HTMLUListElement>;\n\nexport const getId = (id: string, value: ScrollableListItemValue): string => `${id}_${value}`;\n\nconst getNextEnabledItem = (\n event: React.KeyboardEvent<HTMLElement>,\n data: ScrollableListItem[],\n index: number | undefined\n): number | undefined => {\n const nextIndex = getNextIndexFromKeycode(event.keyCode, data.length, index);\n\n if (nextIndex) {\n if (nextIndex === index) {\n return index;\n } else if (data[nextIndex] && data[nextIndex].disabled) {\n return getNextEnabledItem(event, data, nextIndex);\n }\n }\n\n return nextIndex;\n};\n\nexport const ScrollableList = React.forwardRef(function ScrollableList(\n props: ScrollableListProps,\n ref: React.Ref<HTMLUListElement>\n) {\n const {\n data,\n disabled,\n highlighted,\n id,\n loading,\n onChange: setCurrentIndex,\n onClick,\n onFocus,\n onKeyDown,\n readOnly,\n scrollOnFocus = false,\n state,\n value: currentIndex,\n multiselect,\n selectedIndexes = [],\n allOptionsSelected = false,\n ...otherProps\n } = props;\n const listRef = useProxiedRef<HTMLUListElement>(ref);\n const itemRefs = React.useMemo(() => data.map(() => React.createRef<HTMLLIElement>()), [data]);\n const { texts } = useLocalization();\n const { scrollTo } = useListScrollTo(listRef, itemRefs);\n\n React.useEffect(() => {\n scrollTo(currentIndex);\n }, [currentIndex]);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLUListElement>): void => {\n const nextIndex = getNextEnabledItem(event, data, currentIndex);\n\n if (nextIndex !== undefined && nextIndex !== currentIndex) {\n event.preventDefault();\n scrollTo(nextIndex);\n setCurrentIndex(nextIndex);\n }\n\n if (onKeyDown) {\n event.persist();\n const index = nextIndex !== undefined ? nextIndex : currentIndex;\n onKeyDown(event, index);\n }\n };\n\n const handleClick = (index: number) => (event: React.MouseEvent<HTMLLIElement>) => {\n setCurrentIndex(index);\n\n if (onClick) {\n event.persist();\n onClick(event, index);\n }\n };\n\n const handleFocus = (event: React.FocusEvent<HTMLUListElement>): void => {\n if (scrollOnFocus) {\n scrollTo(currentIndex);\n }\n\n if (onFocus) {\n event.persist();\n onFocus(event);\n }\n };\n\n const getOptionCheckedState = (optionValue: string, index: number): boolean => {\n if (optionValue === '#ALL-OPTIONS#') {\n return allOptionsSelected;\n } else if (!optionValue || !selectedIndexes) {\n return false;\n } else {\n return selectedIndexes.findIndex(i => i === index) !== -1;\n }\n };\n\n const list: React.HTMLAttributes<HTMLUListElement> &\n React.RefAttributes<HTMLUListElement> & { disabled?: boolean; readOnly?: boolean } = {\n ...otherProps,\n className: cn(\n 'inline-flex flex-col list-none !p-0 m-0 overflow-y-auto h-auto',\n getInputClasses(props),\n {\n 'yt-list--multiselect': multiselect,\n },\n otherProps.className\n ),\n disabled,\n id,\n onFocus: !disabled && !readOnly ? handleFocus : undefined,\n onKeyDown: !disabled && !readOnly ? handleKeyDown : undefined,\n readOnly,\n ref: listRef,\n role: 'listbox',\n tabIndex: otherProps.tabIndex || 0,\n };\n\n const options = data.map((option, index) => {\n const depth = option.path ? option.path.split('.').length - 1 : 0;\n\n return {\n 'aria-selected': multiselect ? getOptionCheckedState(String(option.value), index) : currentIndex === index,\n 'data-focused': currentIndex === index,\n children: option.text,\n className: cn('flex items-center px-3 w-full cursor-pointer bg-white flex-[0_0_2rem] focus:wcag-blue', {\n 'sticky top-0 font-bold': depth === 0 && !!option.hasChildren,\n }),\n disabled: option.disabled,\n icon: option.icon,\n id: getId(id, option.value),\n key: getId(id, option.value),\n onClick: !disabled && !readOnly ? handleClick(index) : undefined,\n ref: itemRefs[index],\n role: 'option',\n style:\n depth > 0\n ? {\n paddingLeft: `${depth + 1}rem`,\n }\n : undefined,\n };\n });\n\n return (\n <ul {...list} data-taco=\"scrollable-list\">\n {loading ? (\n <li className=\"yt-list__empty\">\n <span>\n <Spinner delay={0} />\n </span>\n <span>{texts.listbox.loading}</span>\n </li>\n ) : options.length ? (\n options.map(({ children, icon, ...optionProps }) => (\n <li {...optionProps}>\n {icon}\n <span className=\"flex-grow text-left truncate\">{children}</span>\n {multiselect && (\n <Checkbox\n checked={optionProps['aria-selected']}\n onChange={() => null}\n className=\"ml-2 flex items-center justify-end pointer-events-none overflow-visible p-px\"\n />\n )}\n </li>\n ))\n ) : (\n <li className=\"yt-list__empty\">\n <span>{texts.listbox.empty}</span>\n </li>\n )}\n </ul>\n );\n});\n"],"names":["getId","id","value","getNextEnabledItem","event","data","index","nextIndex","getNextIndexFromKeycode","keyCode","length","disabled","ScrollableList","React","props","ref","loading","setCurrentIndex","onChange","onClick","onFocus","onKeyDown","readOnly","scrollOnFocus","currentIndex","multiselect","selectedIndexes","allOptionsSelected","otherProps","listRef","useProxiedRef","itemRefs","map","useLocalization","texts","useListScrollTo","scrollTo","handleKeyDown","undefined","preventDefault","persist","handleClick","handleFocus","getOptionCheckedState","optionValue","findIndex","i","list","className","cn","getInputClasses","role","tabIndex","options","option","depth","path","split","String","children","text","hasChildren","icon","key","style","paddingLeft","Spinner","delay","listbox","optionProps","Checkbox","checked","empty"],"mappings":";;;;;;;;;;;;;IA4FaA,KAAK,GAAG,SAARA,KAAQ,CAACC,EAAD,EAAaC,KAAb;AAAA,SAA2DD,EAA3D,SAAiEC,KAAjE;AAAA;;AAErB,IAAMC,kBAAkB,GAAG,SAArBA,kBAAqB,CACvBC,KADuB,EAEvBC,IAFuB,EAGvBC,KAHuB;AAKvB,MAAMC,SAAS,GAAGC,uBAAuB,CAACJ,KAAK,CAACK,OAAP,EAAgBJ,IAAI,CAACK,MAArB,EAA6BJ,KAA7B,CAAzC;;AAEA,MAAIC,SAAJ,EAAe;AACX,QAAIA,SAAS,KAAKD,KAAlB,EAAyB;AACrB,aAAOA,KAAP;AACH,KAFD,MAEO,IAAID,IAAI,CAACE,SAAD,CAAJ,IAAmBF,IAAI,CAACE,SAAD,CAAJ,CAAgBI,QAAvC,EAAiD;AACpD,aAAOR,kBAAkB,CAACC,KAAD,EAAQC,IAAR,EAAcE,SAAd,CAAzB;AACH;AACJ;;AAED,SAAOA,SAAP;AACH,CAhBD;;IAkBaK,cAAc,gBAAGC,UAAA,CAAiB,SAASD,cAAT,CAC3CE,KAD2C,EAE3CC,GAF2C;AAI3C,MACIV,IADJ,GAkBIS,KAlBJ,CACIT,IADJ;AAAA,MAEIM,QA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A,oBAAQwD,YAAR,EACKP,IADL,EAEIjD,aAAA,OAAA;AAAMmC,MAAAA,SAAS,EAAC;KAAhB,EAAgDW,QAAhD,CAFJ,EAGKlC,WAAW,IACRZ,aAAA,CAACyD,QAAD;AACIC,MAAAA,OAAO,EAAEF,WAAW,CAAC,eAAD;AACpBnD,MAAAA,QAAQ,EAAE;AAAA,eAAM,IAAN;AAAA;AACV8B,MAAAA,SAAS,EAAC;KAHd,CAJR,CADQ;AAAA,GAAZ,CADA,GAeAnC,aAAA,KAAA;AAAImC,IAAAA,SAAS,EAAC;GAAd,EACInC,aAAA,OAAA,MAAA,EAAOqB,KAAK,CAACkC,OAAN,CAAcI,KAArB,CADJ,CAvBR,CADJ;AA8BH,CA3J6B;;;;"}
1
+ {"version":3,"file":"ScrollableList.js","sources":["../../../../../src/components/Listbox/ScrollableList.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { useProxiedRef } from '../../utils/hooks/useProxiedRef';\nimport { getNextIndexFromKeycode } from '../../utils/hooks/useListKeyboardNavigation';\nimport { useListScrollTo } from '../../utils/hooks/useListScrollTo';\nimport './ScrollableList.css';\nimport { Spinner } from '../Spinner/Spinner';\nimport { useLocalization } from '../Provider/Provider';\nimport { State } from '../../types';\nimport { Checkbox } from '../Checkbox/Checkbox';\nimport { getInputClasses } from '../Input/util';\n\nexport type ScrollableListItemValue = string | number | boolean | null;\n\nexport type ScrollableListItem = {\n /**\n * Set whether the item is disabled.\n * This will both change the style and make the item unselectable\n */\n disabled?: boolean;\n /* Specifies whether the item has child items -- intended for internal use only */\n hasChildren?: boolean;\n /** Place an icon before the item's text */\n icon?: React.ReactElement;\n /* The index path to the item -- intended for internal use only */\n path?: string;\n /** Text describing the item */\n text: string | JSX.Element;\n /** Value of the item */\n value: ScrollableListItemValue;\n /** Child items to show hierarchical data */\n children?: ScrollableListItem[];\n};\n\n/** @internal */\nexport type ScrollableListProps = Omit<\n React.HTMLAttributes<HTMLUListElement>,\n 'defaultValue' | 'id' | 'onChange' | 'onClick' | 'onKeyDown'\n> & {\n /** Data indicating the options in scrollable list */\n data: ScrollableListItem[];\n /** Sets the list to be disabled */\n disabled?: boolean;\n /** Draws attention to the scrollable list by changing its style and making it visually prominent */\n highlighted?: boolean;\n /** Set an id for the scrollable list */\n id: string;\n /**\n * Shows a loading indicator with a text next to it.\n * Read more about how to provide the text in `Provider` component.\n */\n loading?: boolean;\n /**\n * Handler called when current active/selected option changes in a scrollable list.\n * @param index indicates the index of the current active option\n */\n onChange: (index: number) => void;\n /** Handler called when option is clicked */\n onClick?: (event: React.MouseEvent<HTMLLIElement>, index: number) => void;\n /**\n * Set whether the selected item should be scrolled into view when listbox is focused.\n * Default value is `false`\n */\n scrollOnFocus?: boolean;\n /** Handler called when a key is pressed */\n onKeyDown?: (event: React.KeyboardEvent<HTMLUListElement>, index: number | undefined) => void;\n /* Sets the list to read only mode */\n readOnly?: boolean;\n /** State will change the style of the scrollable list */\n state?: State;\n /**\n * Value of the scrollable list representing the selected item.\n * It needs to be an existing value from the provided data.\n */\n value: number | undefined;\n /**\n * Allows to select multiple items from the list\n */\n multiselect?: boolean;\n /**\n * Contains the currently selected values when multiselect mode is ON.\n */\n selectedIndexes?: number[];\n /**\n * True when all available (not disabled) options are selected\n */\n allOptionsSelected?: boolean;\n};\n\n/** @internal */\nexport type ScrollableListPropsWithRef = ScrollableListProps & React.RefAttributes<HTMLUListElement>;\n\nexport const getId = (id: string, value: ScrollableListItemValue): string => `${id}_${value}`;\n\nconst getNextEnabledItem = (\n event: React.KeyboardEvent<HTMLElement>,\n data: ScrollableListItem[],\n index: number | undefined\n): number | undefined => {\n const nextIndex = getNextIndexFromKeycode(event.keyCode, data.length, index);\n\n if (nextIndex) {\n if (nextIndex === index) {\n return index;\n } else if (data[nextIndex] && data[nextIndex].disabled) {\n return getNextEnabledItem(event, data, nextIndex);\n }\n }\n\n return nextIndex;\n};\n\nexport const ScrollableList = React.forwardRef(function ScrollableList(\n props: ScrollableListProps,\n ref: React.Ref<HTMLUListElement>\n) {\n const {\n data,\n disabled,\n highlighted,\n id,\n loading,\n onChange: setCurrentIndex,\n onClick,\n onFocus,\n onKeyDown,\n readOnly,\n scrollOnFocus = false,\n state,\n value: currentIndex,\n multiselect,\n selectedIndexes = [],\n allOptionsSelected = false,\n ...otherProps\n } = props;\n const listRef = useProxiedRef<HTMLUListElement>(ref);\n const itemRefs = React.useMemo(() => data.map(() => React.createRef<HTMLLIElement>()), [data]);\n const { texts } = useLocalization();\n const { scrollTo } = useListScrollTo(listRef, itemRefs);\n\n React.useEffect(() => {\n scrollTo(currentIndex);\n }, [currentIndex]);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLUListElement>): void => {\n const nextIndex = getNextEnabledItem(event, data, currentIndex);\n\n if (nextIndex !== undefined && nextIndex !== currentIndex) {\n event.preventDefault();\n scrollTo(nextIndex);\n setCurrentIndex(nextIndex);\n }\n\n if (onKeyDown) {\n event.persist();\n const index = nextIndex !== undefined ? nextIndex : currentIndex;\n onKeyDown(event, index);\n }\n };\n\n const handleClick = (index: number) => (event: React.MouseEvent<HTMLLIElement>) => {\n setCurrentIndex(index);\n\n if (onClick) {\n event.persist();\n onClick(event, index);\n }\n };\n\n const handleFocus = (event: React.FocusEvent<HTMLUListElement>): void => {\n if (scrollOnFocus) {\n scrollTo(currentIndex);\n }\n\n if (onFocus) {\n event.persist();\n onFocus(event);\n }\n };\n\n const getOptionCheckedState = (optionValue: string, index: number): boolean => {\n if (optionValue === '#ALL-OPTIONS#') {\n return allOptionsSelected;\n } else if (!optionValue || !selectedIndexes) {\n return false;\n } else {\n return selectedIndexes.findIndex(i => i === index) !== -1;\n }\n };\n\n const list: React.HTMLAttributes<HTMLUListElement> &\n React.RefAttributes<HTMLUListElement> & { disabled?: boolean; readOnly?: boolean } = {\n ...otherProps,\n className: cn(\n 'inline-flex flex-col list-none !p-0 m-0 overflow-y-auto h-auto',\n getInputClasses(props),\n {\n 'yt-list--multiselect': multiselect,\n 'pointer-events-none': disabled,\n 'cursor-not-allowed': disabled || readOnly,\n },\n otherProps.className\n ),\n disabled,\n id,\n onFocus: !disabled && !readOnly ? handleFocus : undefined,\n onKeyDown: !disabled && !readOnly ? handleKeyDown : undefined,\n readOnly,\n ref: listRef,\n role: 'listbox',\n tabIndex: otherProps.tabIndex || 0,\n };\n\n const options = data.map((option, index) => {\n const depth = option.path ? option.path.split('.').length - 1 : 0;\n\n return {\n 'aria-selected': multiselect ? getOptionCheckedState(String(option.value), index) : currentIndex === index,\n 'data-focused': currentIndex === index,\n children: option.text,\n className: cn(\n 'flex items-center px-3 w-full cursor-pointer bg-white flex-[0_0_2rem] focus:wcag-blue focus:border-blue',\n {\n 'sticky top-0 font-bold': depth === 0 && !!option.hasChildren,\n }\n ),\n disabled: option.disabled,\n icon: option.icon,\n id: getId(id, option.value),\n key: getId(id, option.value),\n onClick: !disabled && !readOnly ? handleClick(index) : undefined,\n ref: itemRefs[index],\n role: 'option',\n style:\n depth > 0\n ? {\n paddingLeft: `${depth + 1}rem`,\n }\n : undefined,\n };\n });\n\n return (\n <ul {...list} data-taco=\"scrollable-list\">\n {loading ? (\n <li className=\"yt-list__empty\">\n <span>\n <Spinner delay={0} />\n </span>\n <span>{texts.listbox.loading}</span>\n </li>\n ) : options.length ? (\n options.map(({ children, icon, ...optionProps }) => (\n <li {...optionProps}>\n {icon}\n <span className=\"flex-grow truncate text-left\">{children}</span>\n {multiselect && (\n <Checkbox\n checked={optionProps['aria-selected']}\n onChange={() => null}\n className=\"pointer-events-none ml-2 flex items-center justify-end overflow-visible p-px\"\n />\n )}\n </li>\n ))\n ) : (\n <li className=\"yt-list__empty\">\n <span>{texts.listbox.empty}</span>\n </li>\n )}\n </ul>\n );\n});\n"],"names":["getId","id","value","getNextEnabledItem","event","data","index","nextIndex","getNextIndexFromKeycode","keyCode","length","disabled","ScrollableList","React","props","ref","loading","setCurrentIndex","onChange","onClick","onFocus","onKeyDown","readOnly","scrollOnFocus","currentIndex","multiselect","selectedIndexes","allOptionsSelected","otherProps","listRef","useProxiedRef","itemRefs","map","useLocalization","texts","useListScrollTo","scrollTo","handleKeyDown","undefined","preventDefault","persist","handleClick","handleFocus","getOptionCheckedState","optionValue","findIndex","i","list","className","cn","getInputClasses","role","tabIndex","options","option","depth","path","split","String","children","text","hasChildren","icon","key","style","paddingLeft","Spinner","delay","listbox","optionProps","Checkbox","checked","empty"],"mappings":";;;;;;;;;;;;;IA4FaA,KAAK,GAAG,SAARA,KAAQ,CAACC,EAAD,EAAaC,KAAb;AAAA,SAA2DD,EAA3D,SAAiEC,KAAjE;AAAA;;AAErB,IAAMC,kBAAkB,GAAG,SAArBA,kBAAqB,CACvBC,KADuB,EAEvBC,IAFuB,EAGvBC,KAHuB;AAKvB,MAAMC,SAAS,GAAGC,uBAAuB,CAACJ,KAAK,CAACK,OAAP,EAAgBJ,IAAI,CAACK,MAArB,EAA6BJ,KAA7B,CAAzC;;AAEA,MAAIC,SAAJ,EAAe;AACX,QAAIA,SAAS,KAAKD,KAAlB,EAAyB;AACrB,aAAOA,KAAP;AACH,KAFD,MAEO,IAAID,IAAI,CAACE,SAAD,CAAJ,IAAmBF,IAAI,CAACE,SAAD,CAAJ,CAAgBI,QAAvC,EAAiD;AACpD,aAAOR,kBAAkB,CAACC,KAAD,EAAQC,IAAR,EAAcE,SAAd,CAAzB;AACH;AACJ;;AAED,SAAOA,SAAP;AACH,CAhBD;;IAkBaK,cAAc,gBAAGC,UAAA,CAAiB,SAASD,cAAT,CAC3CE,KAD2C,EAE3CC,GAF2C;AAI3C,MACIV,IADJ,GAkBIS,KAlBJ,CACIT,IADJ;AAAA,MAEIM,QAFJ,GAkBIG,KAlBJ,CAEIH,QAFJ;AAAA,MAIIV,EAJJ,GAkBIa,KAlBJ,CAIIb,EAJJ;AAAA,MAKIe,OALJ,GAkBIF,KAlBJ,CAKIE,OALJ;AAAA,MAMcC,eANd,GAkBIH,KAlBJ,CAMII,QANJ;AAAA,MAOIC,OAPJ,GAkB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D;AACIC,MAAAA,OAAO,EAAEF,WAAW,CAAC,eAAD;AACpBnD,MAAAA,QAAQ,EAAE;AAAA,eAAM,IAAN;AAAA;AACV8B,MAAAA,SAAS,EAAC;KAHd,CAJR,CADQ;AAAA,GAAZ,CADA,GAeAnC,aAAA,KAAA;AAAImC,IAAAA,SAAS,EAAC;GAAd,EACInC,aAAA,OAAA,MAAA,EAAOqB,KAAK,CAACkC,OAAN,CAAcI,KAArB,CADJ,CAvBR,CADJ;AA8BH,CAhK6B;;;;"}
@@ -6,7 +6,7 @@ import { Root, Item, Indicator } from '@radix-ui/react-radio-group';
6
6
  var _excluded = ["children", "value"],
7
7
  _excluded2 = ["children", "defaultValue", "disabled", "invalid", "onChange", "orientation", "value"];
8
8
  var getRadioGroupItemValueAsString = function getRadioGroupItemValueAsString(value) {
9
- return value === undefined || value === null ? '' : String(value);
9
+ return value === null ? '' : String(value);
10
10
  };
11
11
  var findByValue = function findByValue(values, valueAsString) {
12
12
  return values.find(function (value) {
@@ -56,11 +56,11 @@ var useRadioGroup = function useRadioGroup(props) {
56
56
  otherProps = _objectWithoutPropertiesLoose(props, _excluded2);
57
57
 
58
58
  var values = useMemo(function () {
59
- var _React$Children$map;
60
-
61
- return (_React$Children$map = Children.map(children, function (child) {
62
- return child.props.value;
63
- })) !== null && _React$Children$map !== void 0 ? _React$Children$map : [];
59
+ var radioGroupItemValues = [];
60
+ Children.forEach(children, function (child) {
61
+ return radioGroupItemValues.push(child.props.value);
62
+ });
63
+ return radioGroupItemValues;
64
64
  }, [children]);
65
65
  var context = useMemo(function () {
66
66
  return {
@@ -70,17 +70,18 @@ var useRadioGroup = function useRadioGroup(props) {
70
70
  }, [disabled, invalid]);
71
71
  var valueProps;
72
72
 
73
- if (defaultValue) {
73
+ if (onChange !== undefined) {
74
+ var handleChange = function handleChange(value) {
75
+ return onChange(findByValue(values, value));
76
+ };
77
+
74
78
  valueProps = {
75
- defaultValue: getRadioGroupItemValueAsString(defaultValue) || undefined
79
+ onValueChange: handleChange,
80
+ value: value !== undefined ? getRadioGroupItemValueAsString(value) : undefined
76
81
  };
77
82
  } else {
78
- var handleChange = onChange ? function (value) {
79
- return onChange(findByValue(values, value));
80
- } : undefined;
81
83
  valueProps = {
82
- onValueChange: handleChange,
83
- value: getRadioGroupItemValueAsString(value) || undefined
84
+ defaultValue: defaultValue !== undefined ? getRadioGroupItemValueAsString(defaultValue) : undefined
84
85
  };
85
86
  }
86
87
 
@@ -98,9 +99,9 @@ var RadioGroup = /*#__PURE__*/forwardRef(function RadioGroup(props, ref) {
98
99
  otherProps = _useRadioGroup.props;
99
100
 
100
101
  var className = cn('flex items-start', {
101
- 'flex-wrap space-x-4': props.orientation === 'horizontal',
102
- 'flex-col space-y-2': props.orientation === 'vertical'
103
- }, props.className);
102
+ 'flex-wrap space-x-4': otherProps.orientation === 'horizontal',
103
+ 'flex-col space-y-2': otherProps.orientation === 'vertical'
104
+ }, otherProps.className);
104
105
  return createElement(RadioGroupContext.Provider, {
105
106
  value: context
106
107
  }, createElement(Root, Object.assign({}, otherProps, {
@@ -1 +1 @@
1
- {"version":3,"file":"RadioGroup.js","sources":["../../../../../src/components/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as RadioGroupPrimitive from '@radix-ui/react-radio-group';\nimport { Orientation } from '../../types';\n\nexport type RadioGroupItemValue = string | number | boolean | undefined;\n\nexport const getRadioGroupItemValueAsString = (value: RadioGroupItemValue): string =>\n value === undefined || value === null ? '' : String(value);\n\nexport const findByValue = (values: RadioGroupItemValue[], valueAsString: string): RadioGroupItemValue | undefined =>\n values.find(value => getRadioGroupItemValueAsString(value) === valueAsString);\n\nconst RadioGroupContext = React.createContext({ disabled: false, invalid: false });\n\nexport type RadioGroupItemProps<T = HTMLButtonElement> = Omit<\n React.ButtonHTMLAttributes<T>,\n 'children' | 'onSelect' | 'value'\n> & {\n /** Label for the radio group item */\n children: React.ReactNode;\n /* Whether the radio group item is disabled */\n disabled?: boolean;\n /** Value of the radio button */\n value: RadioGroupItemValue;\n};\n\nconst RadioGroupItem = React.forwardRef(function RadioGroupItem(props: RadioGroupItemProps, ref: React.Ref<HTMLButtonElement>) {\n const context = React.useContext(RadioGroupContext);\n const { children, value, ...otherProps } = props;\n\n const disabled = context.disabled || props.disabled;\n\n const className = cn('flex items-center justify-center h-4 w-4 mr-2 rounded-full bg-white border-2 ', {\n 'border-grey-dark focus:border-blue focus:yt-focus aria-checked:bg-blue aria-checked:border-blue':\n !disabled && !context.invalid,\n 'border-grey cursor-not-allowed aria-checked:bg-grey-dark aria-checked:border-grey-dark': disabled,\n 'border-red text-red focus:border-red focus:yt-focus-red aria-checked:bg-red aria-checked:border-red':\n context.invalid && !disabled,\n });\n const labelClassName = cn('flex items-center cursor-pointer', {\n 'cursor-not-allowed text-grey-dark': disabled,\n });\n\n return (\n <label className={labelClassName}>\n <RadioGroupPrimitive.Item\n {...otherProps}\n className={className}\n disabled={disabled}\n ref={ref}\n value={getRadioGroupItemValueAsString(value)}\n >\n <RadioGroupPrimitive.Indicator className=\"h-2 w-2 rounded-full bg-white\" />\n </RadioGroupPrimitive.Item>\n {children}\n </label>\n );\n});\n\ntype RadioGroupBaseProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n children: React.ReactElement<RadioGroupItemProps>[];\n /* Whether the radio group is disabled */\n disabled?: boolean;\n /* Whether the radio group is in an invalid state */\n invalid?: boolean;\n /** The name of the radio group, used when submitting an HTML form */\n name?: string;\n /**\n * Orientation of the radio group\n * @defaultValue vertical\n */\n orientation?: Orientation;\n /* Whether the radio group requires user input */\n required?: boolean;\n};\n\ninterface UncontrolledRadioGroupProps extends RadioGroupBaseProps {\n /* The default value (uncontrolled) */\n defaultValue?: RadioGroupItemValue;\n onChange?: never;\n value?: never;\n}\n\ninterface ControlledRadioGroupProps extends RadioGroupBaseProps {\n defaultValue?: never;\n /** Handler called when the value changes */\n onChange: (value: RadioGroupItemValue) => void;\n /** The current value (controlled) */\n value: RadioGroupItemValue;\n}\n\nexport type RadioGroupProps = UncontrolledRadioGroupProps | ControlledRadioGroupProps;\n\nexport type ForwardedRadioGroupWithStatics = React.ForwardRefExoticComponent<\n RadioGroupProps & React.RefAttributes<HTMLDivElement>\n> & {\n /** Item component rendered in a `RadioGroup` component */\n Item: React.ForwardRefExoticComponent<RadioGroupItemProps>;\n};\n\nexport const useRadioGroup = (props: RadioGroupProps) => {\n const { children, defaultValue, disabled, invalid, onChange, orientation = 'vertical', value, ...otherProps } = props;\n\n const values = React.useMemo<RadioGroupItemValue[]>(\n () => React.Children.map(children, (child: React.ReactElement<RadioGroupItemProps>) => child.props.value) ?? [],\n [children]\n );\n\n const context = React.useMemo(() => ({ disabled: disabled ?? false, invalid: invalid ?? false }), [disabled, invalid]);\n\n let valueProps;\n\n if (defaultValue) {\n valueProps = {\n defaultValue: getRadioGroupItemValueAsString(defaultValue) || undefined,\n };\n } else {\n const handleChange = onChange ? (value: string): void => onChange(findByValue(values, value)) : undefined;\n\n valueProps = {\n onValueChange: handleChange,\n value: getRadioGroupItemValueAsString(value) || undefined,\n };\n }\n\n return {\n context,\n props: {\n ...otherProps,\n ...valueProps,\n children,\n orientation,\n },\n };\n};\n\nexport const RadioGroup = React.forwardRef(function RadioGroup(props: RadioGroupProps, ref: React.Ref<HTMLDivElement>) {\n const { context, props: otherProps } = useRadioGroup(props);\n const className = cn(\n 'flex items-start',\n {\n 'flex-wrap space-x-4': props.orientation === 'horizontal',\n 'flex-col space-y-2': props.orientation === 'vertical',\n },\n props.className\n );\n\n return (\n <RadioGroupContext.Provider value={context}>\n <RadioGroupPrimitive.Root {...otherProps} className={className} data-taco=\"radio-group\" ref={ref} />\n </RadioGroupContext.Provider>\n );\n}) as ForwardedRadioGroupWithStatics;\nRadioGroup.Item = RadioGroupItem;\n"],"names":["getRadioGroupItemValueAsString","value","undefined","String","findByValue","values","valueAsString","find","RadioGroupContext","React","disabled","invalid","RadioGroupItem","props","ref","context","children","otherProps","className","cn","labelClassName","RadioGroupPrimitive","useRadioGroup","defaultValue","onChange","orientation","map","child","valueProps","handleChange","onValueChange","RadioGroup","Provider","Item"],"mappings":";;;;;;;IAOaA,8BAA8B,GAAG,SAAjCA,8BAAiC,CAACC,KAAD;AAAA,SAC1CA,KAAK,KAAKC,SAAV,IAAuBD,KAAK,KAAK,IAAjC,GAAwC,EAAxC,GAA6CE,MAAM,CAACF,KAAD,CADT;AAAA;IAGjCG,WAAW,GAAG,SAAdA,WAAc,CAACC,MAAD,EAAgCC,aAAhC;AAAA,SACvBD,MAAM,CAACE,IAAP,CAAY,UAAAN,KAAK;AAAA,WAAID,8BAA8B,CAACC,KAAD,CAA9B,KAA0CK,aAA9C;AAAA,GAAjB,CADuB;AAAA;AAG3B,IAAME,iBAAiB,gBAAGC,aAAA,CAAoB;AAAEC,EAAAA,QAAQ,EAAE,KAAZ;AAAmBC,EAAAA,OAAO,EAAE;AAA5B,CAApB,CAA1B;AAcA,IAAMC,cAAc,gBAAGH,UAAA,CAAiB,SAASG,cAAT,CAAwBC,KAAxB,EAAoDC,GAApD;AACpC,MAAMC,OAAO,GAAGN,UAAA,CAAiBD,iBAAjB,CAAhB;;AACA,MAAQQ,QAAR,GAA2CH,KAA3C,CAAQG,QAAR;AAAA,MAAkBf,KAAlB,GAA2CY,KAA3C,CAAkBZ,KAAlB;AAAA,MAA4BgB,UAA5B,iCAA2CJ,KAA3C;;AAEA,MAAMH,QAAQ,GAAGK,OAAO,CAACL,QAAR,IAAoBG,KAAK,CAACH,QAA3C;AAEA,MAAMQ,SAAS,GAAGC,EAAE,CAAC,+EAAD,EAAkF;AAClG,uGACI,CAACT,QAAD,IAAa,CAACK,OAAO,CAACJ,OAFwE;AAGlG,8FAA0FD,QAHQ;AAIlG,2GACIK,OAAO,CAACJ,OAAR,IAAmB,CAACD;AAL0E,GAAlF,CAApB;AAOA,MAAMU,cAAc,GAAGD,EAAE,CAAC,kCAAD,EAAqC;A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EACIN,aAAA,CAACY,IAAD,oBAA8BJ;AAAYC,IAAAA,SAAS,EAAEA;iBAAqB;AAAcJ,IAAAA,GAAG,EAAEA;IAA7F,CADJ,CADJ;AAKH,CAhByB;AAiB1BiB,UAAU,CAACE,IAAX,GAAkBrB,cAAlB;;;;"}
1
+ {"version":3,"file":"RadioGroup.js","sources":["../../../../../src/components/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as RadioGroupPrimitive from '@radix-ui/react-radio-group';\nimport { Orientation } from '../../types';\n\nexport type RadioGroupItemValue = string | number | boolean | null;\n\nexport const getRadioGroupItemValueAsString = (value: RadioGroupItemValue): string => (value === null ? '' : String(value));\n\nexport const findByValue = (values: RadioGroupItemValue[], valueAsString: string): RadioGroupItemValue =>\n values.find(value => getRadioGroupItemValueAsString(value) === valueAsString) as RadioGroupItemValue;\n\nconst RadioGroupContext = React.createContext({ disabled: false, invalid: false });\n\nexport type RadioGroupItemProps<T = HTMLButtonElement> = Omit<\n React.ButtonHTMLAttributes<T>,\n 'children' | 'onSelect' | 'value'\n> & {\n /** Label for the radio group item */\n children: React.ReactNode;\n /* Whether the radio group item is disabled */\n disabled?: boolean;\n /** Value of the radio button */\n value: RadioGroupItemValue;\n};\n\nconst RadioGroupItem = React.forwardRef(function RadioGroupItem(props: RadioGroupItemProps, ref: React.Ref<HTMLButtonElement>) {\n const context = React.useContext(RadioGroupContext);\n const { children, value, ...otherProps } = props;\n\n const disabled = context.disabled || props.disabled;\n\n const className = cn('flex items-center justify-center h-4 w-4 mr-2 rounded-full bg-white border-2 ', {\n 'border-grey-dark focus:border-blue focus:yt-focus aria-checked:bg-blue aria-checked:border-blue':\n !disabled && !context.invalid,\n 'border-grey cursor-not-allowed aria-checked:bg-grey-dark aria-checked:border-grey-dark': disabled,\n 'border-red text-red focus:border-red focus:yt-focus-red aria-checked:bg-red aria-checked:border-red':\n context.invalid && !disabled,\n });\n const labelClassName = cn('flex items-center cursor-pointer', {\n 'cursor-not-allowed text-grey-dark': disabled,\n });\n\n return (\n <label className={labelClassName}>\n <RadioGroupPrimitive.Item\n {...otherProps}\n className={className}\n disabled={disabled}\n ref={ref}\n value={getRadioGroupItemValueAsString(value)}\n >\n <RadioGroupPrimitive.Indicator className=\"h-2 w-2 rounded-full bg-white\" />\n </RadioGroupPrimitive.Item>\n {children}\n </label>\n );\n});\n\ntype RadioGroupBaseProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n children: React.ReactElement<RadioGroupItemProps>[];\n /* Whether the radio group is disabled */\n disabled?: boolean;\n /* Whether the radio group is in an invalid state */\n invalid?: boolean;\n /** The name of the radio group, used when submitting an HTML form */\n name?: string;\n /**\n * Orientation of the radio group\n * @defaultValue vertical\n */\n orientation?: Orientation;\n /* Whether the radio group requires user input */\n required?: boolean;\n};\n\ninterface UncontrolledRadioGroupProps extends RadioGroupBaseProps {\n /* The default value (uncontrolled) */\n defaultValue?: RadioGroupItemValue;\n onChange?: never;\n value?: never;\n}\n\ninterface ControlledRadioGroupProps extends RadioGroupBaseProps {\n defaultValue?: never;\n /** Handler called when the value changes */\n onChange: (value: RadioGroupItemValue) => void;\n /** The current value (controlled) */\n value?: RadioGroupItemValue;\n}\n\nexport type RadioGroupProps = UncontrolledRadioGroupProps | ControlledRadioGroupProps;\n\nexport type ForwardedRadioGroupWithStatics = React.ForwardRefExoticComponent<\n RadioGroupProps & React.RefAttributes<HTMLDivElement>\n> & {\n /** Item component rendered in a `RadioGroup` component */\n Item: React.ForwardRefExoticComponent<RadioGroupItemProps>;\n};\n\nexport const useRadioGroup = (props: RadioGroupProps) => {\n const { children, defaultValue, disabled, invalid, onChange, orientation = 'vertical', value, ...otherProps } = props;\n\n const values = React.useMemo<RadioGroupItemValue[]>(() => {\n const radioGroupItemValues: RadioGroupItemValue[] = [];\n\n React.Children.forEach(children, (child: React.ReactElement<RadioGroupItemProps>) =>\n radioGroupItemValues.push(child.props.value)\n );\n\n return radioGroupItemValues;\n }, [children]);\n\n const context = React.useMemo(() => ({ disabled: disabled ?? false, invalid: invalid ?? false }), [disabled, invalid]);\n\n let valueProps;\n\n if (onChange !== undefined) {\n const handleChange = (value: string): void => onChange(findByValue(values, value));\n\n valueProps = {\n onValueChange: handleChange,\n value: value !== undefined ? getRadioGroupItemValueAsString(value) : undefined,\n };\n } else {\n valueProps = {\n defaultValue: defaultValue !== undefined ? getRadioGroupItemValueAsString(defaultValue) : undefined,\n };\n }\n\n return {\n context,\n props: {\n ...otherProps,\n ...valueProps,\n children,\n orientation,\n },\n };\n};\n\nexport const RadioGroup = React.forwardRef(function RadioGroup(props: RadioGroupProps, ref: React.Ref<HTMLDivElement>) {\n const { context, props: otherProps } = useRadioGroup(props);\n const className = cn(\n 'flex items-start',\n {\n 'flex-wrap space-x-4': otherProps.orientation === 'horizontal',\n 'flex-col space-y-2': otherProps.orientation === 'vertical',\n },\n otherProps.className\n );\n\n return (\n <RadioGroupContext.Provider value={context}>\n <RadioGroupPrimitive.Root {...otherProps} className={className} data-taco=\"radio-group\" ref={ref} />\n </RadioGroupContext.Provider>\n );\n}) as ForwardedRadioGroupWithStatics;\nRadioGroup.Item = RadioGroupItem;\n"],"names":["getRadioGroupItemValueAsString","value","String","findByValue","values","valueAsString","find","RadioGroupContext","React","disabled","invalid","RadioGroupItem","props","ref","context","children","otherProps","className","cn","labelClassName","RadioGroupPrimitive","useRadioGroup","defaultValue","onChange","orientation","radioGroupItemValues","forEach","child","push","valueProps","undefined","handleChange","onValueChange","RadioGroup","Provider","Item"],"mappings":";;;;;;;IAOaA,8BAA8B,GAAG,SAAjCA,8BAAiC,CAACC,KAAD;AAAA,SAAyCA,KAAK,KAAK,IAAV,GAAiB,EAAjB,GAAsBC,MAAM,CAACD,KAAD,CAArE;AAAA;IAEjCE,WAAW,GAAG,SAAdA,WAAc,CAACC,MAAD,EAAgCC,aAAhC;AAAA,SACvBD,MAAM,CAACE,IAAP,CAAY,UAA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AAA,UAAU,GAAG;AACTG,MAAAA,aAAa,EAAED,YADN;AAET9B,MAAAA,KAAK,EAAEA,KAAK,KAAK6B,SAAV,GAAsB9B,8BAA8B,CAACC,KAAD,CAApD,GAA8D6B;AAF5D,KAAb;AAIH,GAPD,MAOO;AACHD,IAAAA,UAAU,GAAG;AACTP,MAAAA,YAAY,EAAEA,YAAY,KAAKQ,SAAjB,GAA6B9B,8BAA8B,CAACsB,YAAD,CAA3D,GAA4EQ;AADjF,KAAb;AAGH;;AAED,SAAO;AACHhB,IAAAA,OAAO,EAAPA,OADG;AAEHF,IAAAA,KAAK,eACEI,UADF,EAEEa,UAFF;AAGDd,MAAAA,QAAQ,EAARA,QAHC;AAIDS,MAAAA,WAAW,EAAXA;AAJC;AAFF,GAAP;AASH;IAEYS,UAAU,gBAAGzB,UAAA,CAAiB,SAASyB,UAAT,CAAoBrB,KAApB,EAA4CC,GAA5C;AACvC,uBAAuCQ,aAAa,CAACT,KAAD,CAApD;AAAA,MAAQE,OAAR,kBAAQA,OAAR;AAAA,MAAwBE,UAAxB,kBAAiBJ,KAAjB;;AACA,MAAMK,SAAS,GAAGC,EAAE,CAChB,kBADgB,EAEhB;AACI,2BAAuBF,UAAU,CAACQ,WAAX,KAA2B,YADtD;AAEI,0BAAsBR,UAAU,CAACQ,WAAX,KAA2B;AAFrD,GAFgB,EAMhBR,UAAU,CAACC,SANK,CAApB;AASA,SACIT,aAAA,CAACD,iBAAiB,CAAC2B,QAAnB;AAA4BjC,IAAAA,KAAK,EAAEa;GAAnC,EACIN,aAAA,CAACY,IAAD,oBAA8BJ;AAAYC,IAAAA,SAAS,EAAEA;iBAAqB;AAAcJ,IAAAA,GAAG,EAAEA;IAA7F,CADJ,CADJ;AAKH,CAhByB;AAiB1BoB,UAAU,CAACE,IAAX,GAAkBxB,cAAlB;;;;"}
@@ -3,7 +3,7 @@ import { forwardRef, createElement, useRef, useEffect, Fragment } from 'react';
3
3
  import cn from 'classnames';
4
4
  import { Icon } from '../Icon/Icon.js';
5
5
  import { Badge } from '../Badge/Badge.js';
6
- import { PopoverDisclosure, Popover } from 'reakit/Popover';
6
+ import { Root, Trigger, Content } from '@radix-ui/react-popover';
7
7
  import { getInputClasses } from '../Input/util.js';
8
8
  import { useBoundingClientRectListener } from '../../utils/hooks/useBoundingClientRectListener.js';
9
9
  import { Combobox } from '../Combobox/Combobox.js';
@@ -11,8 +11,7 @@ import { MultiListbox, Listbox } from '../Listbox/Listbox.js';
11
11
  import { useSelect } from './useSelect.js';
12
12
 
13
13
  var _excluded = ["autoFocus", "className", "highlighted", "style"],
14
- _excluded2 = ["container"],
15
- _excluded3 = ["editable"];
14
+ _excluded2 = ["editable"];
16
15
  var BaseSelect = /*#__PURE__*/forwardRef(function BaseSelect(props, ref) {
17
16
  var autoFocus = props.autoFocus,
18
17
  externalClassName = props.className,
@@ -23,19 +22,19 @@ var BaseSelect = /*#__PURE__*/forwardRef(function BaseSelect(props, ref) {
23
22
  button = _useSelect.button,
24
23
  listbox = _useSelect.listbox,
25
24
  popover = _useSelect.popover,
25
+ input = _useSelect.input,
26
26
  text = _useSelect.text,
27
27
  _useSelect$more = _useSelect.more,
28
28
  more = _useSelect$more === void 0 ? 0 : _useSelect$more;
29
29
 
30
- var container = popover.container,
31
- base = _objectWithoutPropertiesLoose(popover, _excluded2);
32
-
33
30
  var internalRef = useRef(null);
34
31
  var selectDimensions = useBoundingClientRectListener(internalRef);
35
32
  var className = cn('inline-flex relative w-full', {
36
33
  'yt-select--readonly': props.readOnly
37
34
  }, externalClassName);
38
- var inputClassname = cn(getInputClasses(props), 'text-left pr-0');
35
+ var inputClassname = cn(getInputClasses(props), 'text-left pr-0', {
36
+ 'border-blue': popover.open
37
+ });
39
38
  useEffect(function () {
40
39
  if (autoFocus && internalRef.current) {
41
40
  internalRef.current.focus();
@@ -43,7 +42,9 @@ var BaseSelect = /*#__PURE__*/forwardRef(function BaseSelect(props, ref) {
43
42
  }, []);
44
43
 
45
44
  var renderMultiSelection = function renderMultiSelection() {
46
- return createElement(Fragment, null, createElement("span", null, text), more > 0 && createElement(Badge, {
45
+ return createElement(Fragment, null, createElement("span", {
46
+ className: "flex-grow truncate text-left"
47
+ }, text), more > 0 && createElement(Badge, {
47
48
  className: "ml-2"
48
49
  }, "+" + more));
49
50
  };
@@ -53,34 +54,34 @@ var BaseSelect = /*#__PURE__*/forwardRef(function BaseSelect(props, ref) {
53
54
  style: {
54
55
  minWidth: selectDimensions === null || selectDimensions === void 0 ? void 0 : selectDimensions.width
55
56
  },
56
- tabIndex: popover.visible ? 0 : -1
57
+ tabIndex: popover.open ? 0 : -1
57
58
  });
58
59
 
59
60
  return createElement("span", {
60
61
  className: className,
61
62
  "data-taco": "select",
62
63
  style: style
63
- }, createElement(PopoverDisclosure, Object.assign({}, base, {
64
+ }, createElement(Root, Object.assign({}, popover), createElement(Trigger, Object.assign({}, button, {
65
+ className: inputClassname,
64
66
  ref: internalRef
65
- }), function (_ref) {
66
- var disclosureRef = _ref.ref;
67
- return createElement("button", Object.assign({
68
- ref: disclosureRef
69
- }, button, {
70
- className: inputClassname
71
- }), props.multiselect ? renderMultiSelection() : createElement("span", {
72
- className: "flex-grow"
73
- }, text), createElement("span", {
74
- className: "flex h-8 w-8 items-center justify-center"
75
- }, createElement(Icon, {
76
- className: "group-hover:text-grey-darkest text-black",
77
- name: popover.visible ? 'chevron-up' : 'chevron-down'
78
- })));
79
- }), !otherProps.disabled && createElement(Popover, Object.assign({}, base, container), props.multiselect ? createElement(MultiListbox, Object.assign({}, commonListboxProps)) : createElement(Listbox, Object.assign({}, commonListboxProps))));
67
+ }), props.multiselect ? renderMultiSelection() : createElement("span", {
68
+ className: "flex-grow truncate text-left"
69
+ }, text), createElement("span", {
70
+ className: "flex h-8 w-8 items-center justify-center"
71
+ }, createElement(Icon, {
72
+ className: "pointer-events-none",
73
+ name: popover.open ? 'chevron-up' : 'chevron-down'
74
+ }))), createElement(Content, {
75
+ align: "start",
76
+ sideOffset: 4
77
+ }, props.multiselect ? createElement(MultiListbox, Object.assign({}, commonListboxProps)) : createElement(Listbox, Object.assign({}, commonListboxProps))), createElement("input", Object.assign({}, input, {
78
+ className: "hidden",
79
+ type: "text"
80
+ }))));
80
81
  });
81
82
  var Select = /*#__PURE__*/forwardRef(function Select(props, ref) {
82
83
  var editable = props.editable,
83
- otherProps = _objectWithoutPropertiesLoose(props, _excluded3);
84
+ otherProps = _objectWithoutPropertiesLoose(props, _excluded2);
84
85
 
85
86
  if (editable) {
86
87
  return createElement(Combobox, Object.assign({}, otherProps, {
@@ -1 +1 @@
1
- {"version":3,"file":"Select.js","sources":["../../../../../src/components/Select/Select.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { Popover as BasePopover, PopoverDisclosure } from 'reakit/Popover';\n\nimport { Icon } from '../Icon/Icon';\nimport { Listbox, MultiListbox, ListboxProps } from '../Listbox/Listbox';\nimport { useBoundingClientRectListener } from '../../utils/hooks/useBoundingClientRectListener';\nimport { useSelect } from './useSelect';\nimport { Combobox, ComboboxProps } from '../Combobox/Combobox';\nimport './Select.css';\nimport { Badge } from '../Badge/Badge';\nimport { getInputClasses } from '../Input/util';\n\nexport type SelectTexts = {\n /**\n * The text displayed when all options are selected when multiselect mode in on.\n */\n allOptionsSelected: string;\n};\n\nexport type BaseSelectProps = ListboxProps &\n Omit<ComboboxProps, 'inline'> & {\n /**\n * Allows to select multiple values.\n * All the selected values will be combined in a comma-seperated string as the value of the input.\n */\n multiselect?: boolean;\n /** Optionally shows the icon for the selected option */\n showSelectedIcon?: boolean;\n };\n\nexport type SelectProps = BaseSelectProps & {\n /**\n * Creates an editable select.\n * Setting this will render a inline Combobox which will display the provided data on click/focus,\n * even if there is no value in the input.\n * After user starts typing, matching data will be displayed.\n */\n editable?: boolean;\n};\n\nconst BaseSelect = React.forwardRef(function BaseSelect(props: BaseSelectProps, ref: React.Ref<HTMLInputElement>) {\n const { autoFocus, className: externalClassName, highlighted, style, ...otherProps } = props;\n const { button, listbox, popover, text, more = 0 } = useSelect(otherProps, ref);\n const { container, ...base } = popover;\n const internalRef = React.useRef<HTMLButtonElement>(null);\n const selectDimensions = useBoundingClientRectListener(internalRef);\n const className = cn('inline-flex relative w-full', { 'yt-select--readonly': props.readOnly }, externalClassName);\n const inputClassname = cn(getInputClasses(props), 'text-left pr-0');\n\n React.useEffect(() => {\n if (autoFocus && internalRef.current) {\n internalRef.current.focus();\n }\n }, []);\n\n const renderMultiSelection = (): React.ReactNode => {\n return (\n <>\n <span>{text}</span>\n {more > 0 && <Badge className=\"ml-2\">{`+${more}`}</Badge>}\n </>\n );\n };\n\n const commonListboxProps = {\n ...listbox,\n className: 'w-auto',\n style: { minWidth: selectDimensions?.width },\n tabIndex: popover.visible ? 0 : -1,\n };\n\n return (\n <span className={className} data-taco=\"select\" style={style}>\n <PopoverDisclosure {...base} ref={internalRef}>\n {({ ref: disclosureRef }) => (\n <button ref={disclosureRef} {...button} className={inputClassname}>\n {props.multiselect ? renderMultiSelection() : <span className=\"flex-grow\">{text}</span>}\n <span className=\"flex h-8 w-8 items-center justify-center\">\n <Icon\n className=\"group-hover:text-grey-darkest text-black\"\n name={popover.visible ? 'chevron-up' : 'chevron-down'}\n />\n </span>\n </button>\n )}\n </PopoverDisclosure>\n {!otherProps.disabled && (\n <BasePopover {...base} {...container}>\n {props.multiselect ? <MultiListbox {...commonListboxProps} /> : <Listbox {...commonListboxProps} />}\n </BasePopover>\n )}\n </span>\n );\n});\n\nexport const Select = React.forwardRef(function Select(props: SelectProps, ref: React.Ref<HTMLInputElement>) {\n const { editable, ...otherProps } = props;\n\n if (editable) {\n return <Combobox {...otherProps} inline ref={ref} />;\n }\n\n return <BaseSelect {...otherProps} ref={ref} />;\n});\n"],"names":["BaseSelect","React","props","ref","autoFocus","externalClassName","className","style","otherProps","useSelect","button","listbox","popover","text","more","container","base","internalRef","selectDimensions","useBoundingClientRectListener","cn","readOnly","inputClassname","getInputClasses","current","focus","renderMultiSelection","Badge","commonListboxProps","minWidth","width","tabIndex","visible","PopoverDisclosure","disclosureRef","multiselect","Icon","name","disabled","BasePopover","MultiListbox","Listbox","Select","editable","Combobox","inline"],"mappings":";;;;;;;;;;;;;;;AAyCA,IAAMA,UAAU,gBAAGC,UAAA,CAAiB,SAASD,UAAT,CAAoBE,KAApB,EAA4CC,GAA5C;AAChC,MAAQC,SAAR,GAAuFF,KAAvF,CAAQE,SAAR;AAAA,MAA8BC,iBAA9B,GAAuFH,KAAvF,CAAmBI,SAAnB;AAAA,MAA8DC,KAA9D,GAAuFL,KAAvF,CAA8DK,KAA9D;AAAA,MAAwEC,UAAxE,iCAAuFN,KAAvF;;AACA,mBAAqDO,SAAS,CAACD,UAAD,EAAaL,GAAb,CAA9D;AAAA,MAAQO,MAAR,cAAQA,MAAR;AAAA,MAAgBC,OAAhB,cAAgBA,OAAhB;AAAA,MAAyBC,OAAzB,cAAyBA,OAAzB;AAAA,MAAkCC,IAAlC,cAAkCA,IAAlC;AAAA,mCAAwCC,IAAxC;AAAA,MAAwCA,IAAxC,gCAA+C,CAA/C;;AACA,MAAQC,SAAR,GAA+BH,OAA/B,CAAQG,SAAR;AAAA,MAAsBC,IAAtB,iCAA+BJ,OAA/B;;AACA,MAAMK,WAAW,GAAGhB,MAAA,CAAgC,IAAhC,CAApB;AACA,MAAMiB,gBAAgB,GAAGC,6BAA6B,CAACF,WAAD,CAAtD;AACA,MAAMX,SAAS,GAAGc,EAAE,CAAC,6BAAD,EAAgC;AAAE,2BAAuBlB,KAAK,CAACmB;AAA/B,GAAhC,EAA2EhB,iBAA3E,CAApB;AACA,MAAMiB,cAAc,GAAGF,EAAE,CAACG,eAAe,CAACrB,KAAD,CAAhB,EAAyB,gBAAzB,CAAzB;AAEAD,EAAAA,SAAA,CAAgB;AACZ,QAAIG,SAAS,IAAIa,WAAW,CAACO,OAA7B,EAAsC;AAClCP,MAAAA,WAAW,CAACO,OAAZ,CAAoBC,KAApB;AACH;AACJ,GAJD,EAIG,EAJH;;AAMA,MAAMC,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AAiBvB,MAAUD,UAA3B,EACKb,KAAK,CAACiC,WAAN,GAAoBlC,aAAA,CAACuC,YAAD,oBAAkBZ,mBAAlB,CAApB,GAA+D3B,aAAA,CAACwC,OAAD,oBAAab,mBAAb,CADpE,CAfR,CADJ;AAsBH,CArDkB,CAAnB;IAuDac,MAAM,gBAAGzC,UAAA,CAAiB,SAASyC,MAAT,CAAgBxC,KAAhB,EAAoCC,GAApC;AACnC,MAAQwC,QAAR,GAAoCzC,KAApC,CAAQyC,QAAR;AAAA,MAAqBnC,UAArB,iCAAoCN,KAApC;;AAEA,MAAIyC,QAAJ,EAAc;AACV,WAAO1C,aAAA,CAAC2C,QAAD,oBAAcpC;AAAYqC,MAAAA,MAAM;AAAC1C,MAAAA,GAAG,EAAEA;MAAtC,CAAP;AACH;;AAED,SAAOF,aAAA,CAACD,UAAD,oBAAgBQ;AAAYL,IAAAA,GAAG,EAAEA;IAAjC,CAAP;AACH,CARqB;;;;"}
1
+ {"version":3,"file":"Select.js","sources":["../../../../../src/components/Select/Select.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { Icon } from '../Icon/Icon';\nimport { Listbox, MultiListbox, ListboxProps } from '../Listbox/Listbox';\nimport { useBoundingClientRectListener } from '../../utils/hooks/useBoundingClientRectListener';\nimport { useSelect } from './useSelect';\nimport { Combobox, ComboboxProps } from '../Combobox/Combobox';\nimport { Badge } from '../Badge/Badge';\nimport { getInputClasses } from '../Input/util';\n\nexport type SelectTexts = {\n /**\n * The text displayed when all options are selected when multiselect mode in on.\n */\n allOptionsSelected: string;\n};\n\nexport type BaseSelectProps = ListboxProps &\n Omit<ComboboxProps, 'inline'> & {\n /**\n * Allows to select multiple values.\n * All the selected values will be combined in a comma-seperated string as the value of the input.\n */\n multiselect?: boolean;\n };\n\nexport type SelectProps = BaseSelectProps & {\n /**\n * Creates an editable select.\n * Setting this will render a inline Combobox which will display the provided data on click/focus,\n * even if there is no value in the input.\n * After user starts typing, matching data will be displayed.\n */\n editable?: boolean;\n};\n\nconst BaseSelect = React.forwardRef(function BaseSelect(props: BaseSelectProps, ref: React.Ref<HTMLInputElement>) {\n const { autoFocus, className: externalClassName, highlighted, style, ...otherProps } = props;\n const { button, listbox, popover, input, text, more = 0 } = useSelect(otherProps, ref);\n const internalRef = React.useRef<HTMLButtonElement>(null);\n const selectDimensions = useBoundingClientRectListener(internalRef);\n const className = cn('inline-flex relative w-full', { 'yt-select--readonly': props.readOnly }, externalClassName);\n const inputClassname = cn(getInputClasses(props), 'text-left pr-0', {\n 'border-blue': popover.open,\n });\n\n React.useEffect(() => {\n if (autoFocus && internalRef.current) {\n internalRef.current.focus();\n }\n }, []);\n\n const renderMultiSelection = (): React.ReactNode => {\n return (\n <>\n <span className=\"flex-grow truncate text-left\">{text}</span>\n {more > 0 && <Badge className=\"ml-2\">{`+${more}`}</Badge>}\n </>\n );\n };\n\n const commonListboxProps = {\n ...listbox,\n className: 'w-auto',\n style: { minWidth: selectDimensions?.width },\n tabIndex: popover.open ? 0 : -1,\n };\n\n return (\n <span className={className} data-taco=\"select\" style={style}>\n <PopoverPrimitive.Root {...popover}>\n <PopoverPrimitive.Trigger {...button} className={inputClassname} ref={internalRef}>\n {props.multiselect ? renderMultiSelection() : <span className=\"flex-grow truncate text-left\">{text}</span>}\n <span className=\"flex h-8 w-8 items-center justify-center\">\n <Icon className=\"pointer-events-none\" name={popover.open ? 'chevron-up' : 'chevron-down'} />\n </span>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Content align=\"start\" sideOffset={4}>\n {props.multiselect ? <MultiListbox {...commonListboxProps} /> : <Listbox {...commonListboxProps} />}\n </PopoverPrimitive.Content>\n <input {...input} className=\"hidden\" type=\"text\" />\n </PopoverPrimitive.Root>\n </span>\n );\n});\n\nexport const Select = React.forwardRef(function Select(props: SelectProps, ref: React.Ref<HTMLInputElement>) {\n const { editable, ...otherProps } = props;\n\n if (editable) {\n return <Combobox {...otherProps} inline ref={ref} />;\n }\n\n return <BaseSelect {...otherProps} ref={ref} />;\n});\n"],"names":["BaseSelect","React","props","ref","autoFocus","externalClassName","className","style","otherProps","useSelect","button","listbox","popover","input","text","more","internalRef","selectDimensions","useBoundingClientRectListener","cn","readOnly","inputClassname","getInputClasses","open","current","focus","renderMultiSelection","Badge","commonListboxProps","minWidth","width","tabIndex","PopoverPrimitive","multiselect","Icon","name","align","sideOffset","MultiListbox","Listbox","type","Select","editable","Combobox","inline"],"mappings":";;;;;;;;;;;;;;AAqCA,IAAMA,UAAU,gBAAGC,UAAA,CAAiB,SAASD,UAAT,CAAoBE,KAApB,EAA4CC,GAA5C;AAChC,MAAQC,SAAR,GAAuFF,KAAvF,CAAQE,SAAR;AAAA,MAA8BC,iBAA9B,GAAuFH,KAAvF,CAAmBI,SAAnB;AAAA,MAA8DC,KAA9D,GAAuFL,KAAvF,CAA8DK,KAA9D;AAAA,MAAwEC,UAAxE,iCAAuFN,KAAvF;;AACA,mBAA4DO,SAAS,CAACD,UAAD,EAAaL,GAAb,CAArE;AAAA,MAAQO,MAAR,cAAQA,MAAR;AAAA,MAAgBC,OAAhB,cAAgBA,OAAhB;AAAA,MAAyBC,OAAzB,cAAyBA,OAAzB;AAAA,MAAkCC,KAAlC,cAAkCA,KAAlC;AAAA,MAAyCC,IAAzC,cAAyCA,IAAzC;AAAA,mCAA+CC,IAA/C;AAAA,MAA+CA,IAA/C,gCAAsD,CAAtD;;AACA,MAAMC,WAAW,GAAGf,MAAA,CAAgC,IAAhC,CAApB;AACA,MAAMgB,gBAAgB,GAAGC,6BAA6B,CAACF,WAAD,CAAtD;AACA,MAAMV,SAAS,GAAGa,EAAE,CAAC,6BAAD,EAAgC;AAAE,2BAAuBjB,KAAK,CAACkB;AAA/B,GAAhC,EAA2Ef,iBAA3E,CAApB;AACA,MAAMgB,cAAc,GAAGF,EAAE,CAACG,eAAe,CAACpB,KAAD,CAAhB,EAAyB,gBAAzB,EAA2C;AAChE,mBA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