@economic/taco 0.0.26-alpha.0 → 0.0.26-alpha.9

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 (45) hide show
  1. package/dist/components/Combobox/Combobox.d.ts +0 -3
  2. package/dist/components/Combobox/useCombobox.d.ts +1 -1
  3. package/dist/components/Datepicker/Datepicker.d.ts +1 -1
  4. package/dist/components/Field/Field.d.ts +13 -24
  5. package/dist/components/Input/Input.d.ts +2 -5
  6. package/dist/components/Input/util.d.ts +1 -3
  7. package/dist/components/Listbox/Listbox.d.ts +3 -7
  8. package/dist/components/Listbox/ScrollableList.d.ts +2 -5
  9. package/dist/components/Listbox/useListbox.d.ts +1 -1
  10. package/dist/components/SearchInput/SearchInput.d.ts +1 -1
  11. package/dist/components/Select/Select.d.ts +1 -1
  12. package/dist/components/Textarea/Textarea.d.ts +2 -5
  13. package/dist/esm/components/Checkbox/Checkbox.js +2 -2
  14. package/dist/esm/components/Checkbox/Checkbox.js.map +1 -1
  15. package/dist/esm/components/Combobox/Combobox.js.map +1 -1
  16. package/dist/esm/components/Combobox/useCombobox.js +1 -1
  17. package/dist/esm/components/Combobox/useCombobox.js.map +1 -1
  18. package/dist/esm/components/Field/Field.js +38 -18
  19. package/dist/esm/components/Field/Field.js.map +1 -1
  20. package/dist/esm/components/IconButton/IconButton.js +1 -1
  21. package/dist/esm/components/IconButton/IconButton.js.map +1 -1
  22. package/dist/esm/components/Input/Input.js +5 -4
  23. package/dist/esm/components/Input/Input.js.map +1 -1
  24. package/dist/esm/components/Input/util.js +12 -39
  25. package/dist/esm/components/Input/util.js.map +1 -1
  26. package/dist/esm/components/Listbox/Listbox.js.map +1 -1
  27. package/dist/esm/components/Listbox/ScrollableList.js +1 -1
  28. package/dist/esm/components/Listbox/ScrollableList.js.map +1 -1
  29. package/dist/esm/components/Listbox/useListbox.js +3 -1
  30. package/dist/esm/components/Listbox/useListbox.js.map +1 -1
  31. package/dist/esm/components/Select/Select.js +1 -0
  32. package/dist/esm/components/Select/Select.js.map +1 -1
  33. package/dist/esm/components/Select/useSelect.js +3 -4
  34. package/dist/esm/components/Select/useSelect.js.map +1 -1
  35. package/dist/esm/components/Switch/Switch.js +2 -2
  36. package/dist/esm/components/Switch/Switch.js.map +1 -1
  37. package/dist/esm/components/Textarea/Textarea.js +1 -1
  38. package/dist/esm/components/Textarea/Textarea.js.map +1 -1
  39. package/dist/taco.cjs.development.js +67 -72
  40. package/dist/taco.cjs.development.js.map +1 -1
  41. package/dist/taco.cjs.production.min.js +1 -1
  42. package/dist/taco.cjs.production.min.js.map +1 -1
  43. package/package.json +2 -2
  44. package/types.json +455 -432
  45. package/dist/utils/tailwind.d.ts +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useListbox.js","sources":["../../../../src/components/Listbox/useListbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { v4 as uuid } from 'uuid';\nimport { ListboxProps } from './Listbox';\nimport { useProxiedRef } from '../../utils/hooks/useProxiedRef';\nimport { setInputValueByRef, getIndexFromValue, findByValue, getActiveDescendant, useFlattenedData, sanitizeItem } from './util';\nimport { ScrollableListProps } from './ScrollableList';\nimport { useTypeahead } from './useTypeahead';\n\ntype useListbox = {\n list: ScrollableListProps;\n input: Omit<React.HTMLAttributes<HTMLInputElement>, 'defaultValue'>;\n};\n\nexport const useListbox = (\n {\n data: externalData = [],\n defaultValue,\n disabled,\n emptyValue,\n id: nativeId,\n name,\n onChange,\n onFocus,\n onKeyDown,\n value = emptyValue,\n ...otherProps\n }: ListboxProps,\n ref: React.Ref<HTMLInputElement>\n): useListbox => {\n const data = useFlattenedData(emptyValue !== undefined ? [{ text: '', value: emptyValue }, ...externalData] : externalData);\n const id = React.useMemo(() => nativeId || uuid(), [nativeId]);\n const inputRef = useProxiedRef<HTMLInputElement>(ref);\n const currentIndex = value !== undefined ? getIndexFromValue(data, value) : undefined;\n const { getNextIndex } = useTypeahead({ data, currentIndex });\n\n const setInputValueByIndex = (index: number | undefined): void => {\n if (index !== undefined) {\n const option = data[index];\n\n if (option && !option.disabled) {\n setInputValueByRef(inputRef.current, option.value);\n }\n }\n };\n\n const handleListboxChange = (index: number): void => {\n setInputValueByIndex(index);\n };\n\n React.useEffect(() => {\n if (data.length && currentIndex === undefined) {\n if (defaultValue !== undefined) {\n const defaultValueIndex = getIndexFromValue(data, defaultValue);\n\n if (defaultValueIndex !== undefined) {\n setInputValueByIndex(defaultValueIndex);\n }\n } else {\n setInputValueByIndex(0);\n }\n }\n }, [data]);\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>): void => {\n const charKey = String.fromCharCode(event.keyCode);\n\n if (charKey.match(/(\\w)/g)) {\n const nextIndex = getNextIndex(charKey);\n\n if (nextIndex > -1 && nextIndex !== currentIndex) {\n setInputValueByIndex(nextIndex);\n }\n return;\n }\n\n if (onKeyDown) {\n event.persist();\n onKeyDown(event);\n }\n };\n\n const handleListboxFocus = (event: React.FocusEvent<HTMLElement>): void => {\n if (currentIndex === undefined && data.length) {\n setInputValueByIndex(0);\n }\n\n if (onFocus) {\n event.persist();\n onFocus(event);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n event.persist();\n\n if (onChange) {\n const item = findByValue(data, event.target.value);\n (event as any).detail = sanitizeItem(item);\n\n const indexes = item?.path?.split('.') ?? [];\n\n if (indexes.length > 1) {\n // we don't want to map the current item\n indexes.pop();\n // we need to rebuild the path as we map\n let lastPath: string;\n\n (event as any).detail.parents = indexes.map(i => {\n lastPath = lastPath ? [lastPath, i].join('.') : i;\n return sanitizeItem(data.find(i => i.path === lastPath));\n });\n }\n\n onChange(event);\n }\n };\n\n const list: ScrollableListProps = {\n ...otherProps,\n 'aria-activedescendant': getActiveDescendant(data, currentIndex, id),\n data,\n disabled,\n id,\n onChange: handleListboxChange,\n onFocus: handleListboxFocus,\n onKeyDown: handleListboxKeyDown,\n scrollOnFocus: true,\n tabIndex: disabled ? -1 : otherProps.tabIndex ? otherProps.tabIndex : 0,\n value: currentIndex,\n };\n\n const input = {\n name,\n onChange: handleInputChange,\n ref: inputRef,\n tabIndex: -1,\n value: value === undefined || value === null ? '' : value,\n };\n\n return { list, input };\n};\n"],"names":["useListbox","ref","data","externalData","defaultValue","disabled","emptyValue","nativeId","id","name","onChange","onFocus","onKeyDown","value","otherProps","useFlattenedData","undefined","text","React","uuid","inputRef","useProxiedRef","currentIndex","getIndexFromValue","useTypeahead","getNextIndex","setInputValueByIndex","index","option","setInputValueByRef","current","handleListboxChange","length","defaultValueIndex","handleListboxKeyDown","event","charKey","String","fromCharCode","keyCode","match","nextIndex","persist","handleListboxFocus","handleInputChange","item","findByValue","target","detail","sanitizeItem","indexes","path","split","pop","lastPath","parents","map","i","join","find","list","getActiveDescendant","scrollOnFocus","tabIndex","input"],"mappings":";;;;;;;;IAaaA,UAAU,GAAG,SAAbA,UAAa,OActBC,GAdsB;uBAElBC;MAAMC,sCAAe;MACrBC,oBAAAA;MACAC,gBAAAA;MACAC,kBAAAA;MACIC,gBAAJC;MACAC,YAAAA;MACAC,gBAAAA;MACAC,eAAAA;MACAC,iBAAAA;wBACAC;MAAAA,gCAAQP;MACLQ;;AAIP,MAAMZ,IAAI,GAAGa,gBAAgB,CAACT,UAAU,KAAKU,SAAf,IAA4B;AAAEC,IAAAA,IAAI,EAAE,EAAR;AAAYJ,IAAAA,KAAK,EAAEP;AAAnB,GAA5B,SAAgEH,YAAhE,IAAgFA,YAAjF,CAA7B;AACA,MAAMK,EAAE,GAAGU,OAAA,CAAc;AAAA,WAAMX,QAAQ,IAAIY,EAAI,EAAtB;AAAA,GAAd,EAAwC,CAACZ,QAAD,CAAxC,CAAX;AACA,MAAMa,QAAQ,GAAGC,aAAa,CAAmBpB,GAAnB,CAA9B;AACA,MAAMqB,YAAY,GAAGT,KAAK,KAAKG,SAAV,GAAsBO,iBAAiB,CAACrB,IAAD,EAAOW,KAAP,CAAvC,GAAuDG,SAA5E;;AACA,sBAAyBQ,YAAY,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ent":["import * as React from 'react';\nimport { v4 as uuid } from 'uuid';\nimport { ListboxProps } from './Listbox';\nimport { useProxiedRef } from '../../utils/hooks/useProxiedRef';\nimport { setInputValueByRef, getIndexFromValue, findByValue, getActiveDescendant, useFlattenedData, sanitizeItem } from './util';\nimport { ScrollableListProps } from './ScrollableList';\nimport { useTypeahead } from './useTypeahead';\n\ntype useListbox = {\n list: ScrollableListProps;\n input: Omit<React.HTMLAttributes<HTMLInputElement>, 'defaultValue'>;\n};\n\nexport const useListbox = (\n {\n data: externalData = [],\n defaultValue,\n disabled,\n emptyValue,\n id: nativeId,\n invalid,\n name,\n onChange,\n onFocus,\n onKeyDown,\n value = emptyValue,\n ...otherProps\n }: ListboxProps,\n ref: React.Ref<HTMLInputElement>\n): useListbox => {\n const data = useFlattenedData(emptyValue !== undefined ? [{ text: '', value: emptyValue }, ...externalData] : externalData);\n const id = React.useMemo(() => nativeId || uuid(), [nativeId]);\n const inputRef = useProxiedRef<HTMLInputElement>(ref);\n const currentIndex = value !== undefined ? getIndexFromValue(data, value) : undefined;\n const { getNextIndex } = useTypeahead({ data, currentIndex });\n\n const setInputValueByIndex = (index: number | undefined): void => {\n if (index !== undefined) {\n const option = data[index];\n\n if (option && !option.disabled) {\n setInputValueByRef(inputRef.current, option.value);\n }\n }\n };\n\n const handleListboxChange = (index: number): void => {\n setInputValueByIndex(index);\n };\n\n React.useEffect(() => {\n if (data.length && currentIndex === undefined) {\n if (defaultValue !== undefined) {\n const defaultValueIndex = getIndexFromValue(data, defaultValue);\n\n if (defaultValueIndex !== undefined) {\n setInputValueByIndex(defaultValueIndex);\n }\n } else {\n setInputValueByIndex(0);\n }\n }\n }, [data]);\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>): void => {\n const charKey = String.fromCharCode(event.keyCode);\n\n if (charKey.match(/(\\w)/g)) {\n const nextIndex = getNextIndex(charKey);\n\n if (nextIndex > -1 && nextIndex !== currentIndex) {\n setInputValueByIndex(nextIndex);\n }\n return;\n }\n\n if (onKeyDown) {\n event.persist();\n onKeyDown(event);\n }\n };\n\n const handleListboxFocus = (event: React.FocusEvent<HTMLElement>): void => {\n if (currentIndex === undefined && data.length) {\n setInputValueByIndex(0);\n }\n\n if (onFocus) {\n event.persist();\n onFocus(event);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n event.persist();\n\n if (onChange) {\n const item = findByValue(data, event.target.value);\n (event as any).detail = sanitizeItem(item);\n\n const indexes = item?.path?.split('.') ?? [];\n\n if (indexes.length > 1) {\n // we don't want to map the current item\n indexes.pop();\n // we need to rebuild the path as we map\n let lastPath: string;\n\n (event as any).detail.parents = indexes.map(i => {\n lastPath = lastPath ? [lastPath, i].join('.') : i;\n return sanitizeItem(data.find(i => i.path === lastPath));\n });\n }\n\n onChange(event);\n }\n };\n\n const list: ScrollableListProps = {\n ...otherProps,\n 'aria-activedescendant': getActiveDescendant(data, currentIndex, id),\n data,\n disabled,\n id,\n invalid,\n onChange: handleListboxChange,\n onFocus: handleListboxFocus,\n onKeyDown: handleListboxKeyDown,\n scrollOnFocus: true,\n tabIndex: disabled ? -1 : otherProps.tabIndex ? otherProps.tabIndex : 0,\n value: currentIndex,\n };\n\n const input = {\n name,\n onChange: handleInputChange,\n ref: inputRef,\n tabIndex: -1,\n value: value === undefined || value === null ? '' : value,\n };\n\n return { list, input };\n};\n"],"names":["useListbox","ref","data","externalData","defaultValue","disabled","emptyValue","nativeId","id","invalid","name","onChange","onFocus","onKeyDown","value","otherProps","useFlattenedData","undefined","text","React","uuid","inputRef","useProxiedRef","currentIndex","getIndexFromValue","useTypeahead","getNextIndex","setInputValueByIndex","index","option","setInputValueByRef","current","handleListboxChange","length","defaultValueIndex","handleListboxKeyDown","event","charKey","String","fromCharCode","keyCode","match","nextIndex","persist","handleListboxFocus","handleInputChange","item","findByValue","target","detail","sanitizeItem","indexes","path","split","pop","lastPath","parents","map","i","join","find","list","getActiveDescendant","scrollOnFocus","tabIndex","input"],"mapp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AAPA,OANM;AAONE,IAAAA,QAAQ,EAAEqB,mBAPJ;AAQNpB,IAAAA,OAAO,EAAEgC,kBARH;AASN/B,IAAAA,SAAS,EAAEsB,oBATL;AAUN4B,IAAAA,aAAa,EAAE,IAVT;AAWNC,IAAAA,QAAQ,EAAE3D,QAAQ,GAAG,CAAC,CAAJ,GAAQU,UAAU,CAACiD,QAAX,GAAsBjD,UAAU,CAACiD,QAAjC,GAA4C,CAXhE;AAYNlD,IAAAA,KAAK,EAAES;AAZD,IAAV;;AAeA,MAAM0C,KAAK,GAAG;AACVvD,IAAAA,IAAI,EAAJA,IADU;AAEVC,IAAAA,QAAQ,EAAEkC,iBAFA;AAGV5C,IAAAA,GAAG,EAAEoB,QAHK;AAIV2C,IAAAA,QAAQ,EAAE,CAAC,CAJD;AAKVlD,IAAAA,KAAK,EAAEA,KAAK,KAAKG,SAAV,IAAuBH,KAAK,KAAK,IAAjC,GAAwC,EAAxC,GAA6CA;AAL1C,GAAd;AAQA,SAAO;AAAE+C,IAAAA,IAAI,EAAJA,IAAF;AAAQI,IAAAA,KAAK,EAALA;AAAR,GAAP;AACH;;;;"}
@@ -51,6 +51,7 @@ var BaseSelect = /*#__PURE__*/forwardRef(function BaseSelect(props, ref) {
51
51
 
52
52
  var commonListboxProps = _extends({}, listbox, {
53
53
  className: 'w-auto',
54
+ invalid: undefined,
54
55
  style: {
55
56
  minWidth: selectDimensions === null || selectDimensions === void 0 ? void 0 : selectDimensions.width
56
57
  },
@@ -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 * 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 = Omit<ListboxProps, 'dialog'> &\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} dialog={undefined} 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","dialog","undefined","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/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jC,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 = Omit<ListboxProps, 'dialog'> &\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 invalid: undefined,\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} dialog={undefined} 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","invalid","undefined","minWidth","width","tabIndex","PopoverPrimitive","multiselect","Icon","name","align","sideOffset","MultiListbox","Listbox","type","Select","editable","Combobox","dialog","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;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SAAS0C,MAAT,CAAgBzC,KAAhB,EAAoCC,GAApC;AACnC,MAAQyC,QAAR,GAAoC1C,KAApC,CAAQ0C,QAAR;AAAA,MAAqBpC,UAArB,iCAAoCN,KAApC;;AAEA,MAAI0C,QAAJ,EAAc;AACV,WAAO3C,aAAA,CAAC4C,QAAD,oBAAcrC;AAAYsC,MAAAA,MAAM,EAAEhB;AAAWiB,MAAAA,MAAM;AAAC5C,MAAAA,GAAG,EAAEA;MAAzD,CAAP;AACH;;AAED,SAAOF,aAAA,CAACD,UAAD,oBAAgBQ;AAAYL,IAAAA,GAAG,EAAEA;IAAjC,CAAP;AACH,CARqB;;;;"}
@@ -37,8 +37,7 @@ var useSelect = function useSelect(_ref, ref) {
37
37
  var id = useMemo(function () {
38
38
  return nativeId || "select_" + v4();
39
39
  }, [nativeId]);
40
- var internalInputRef = useRef(null);
41
- var buttonId = id + "-button"; // support 'escape' resetting to the value that was set when the listbox opened
40
+ var internalInputRef = useRef(null); // support 'escape' resetting to the value that was set when the listbox opened
42
41
 
43
42
  var _React$useState2 = useState(value),
44
43
  lastValue = _React$useState2[0],
@@ -165,9 +164,9 @@ var useSelect = function useSelect(_ref, ref) {
165
164
  var button = {
166
165
  'aria-haspopup': 'listbox',
167
166
  'aria-label': ariaLabel ? ariaLabel + " " + text : undefined,
168
- 'aria-labelledby': ariaLabelledBy ? ariaLabelledBy + " " + buttonId : undefined,
167
+ 'aria-labelledby': ariaLabelledBy ? ariaLabelledBy + " " + id : undefined,
169
168
  disabled: disabled,
170
- id: buttonId,
169
+ id: id,
171
170
  onKeyDown: !disabled && !readOnly ? handleButtonKeyDown : undefined,
172
171
  type: 'button'
173
172
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useSelect.js","sources":["../../../../src/components/Select/useSelect.tsx"],"sourcesContent":["import * as React from 'react';\nimport keycode from 'keycode';\nimport cn from 'classnames';\nimport { v4 as uuid } from 'uuid';\nimport { useLocalization } from '../Provider/Provider';\nimport { SelectProps } from './Select';\nimport { ListboxProps } from '../Listbox/Listbox';\nimport { useProxiedRef } from '../../utils/hooks/useProxiedRef';\nimport { setInputValueByRef, findByValue, useFlattenedData, sanitizeItem } from '../Listbox/util';\nimport { ScrollableListItemValue } from '../Listbox/ScrollableList';\n\ntype useSelect = React.HtmlHTMLAttributes<HTMLDivElement> & {\n button: React.ButtonHTMLAttributes<HTMLButtonElement>;\n listbox: ListboxProps;\n input: any;\n popover: { open: boolean; onOpenChange: (open: boolean) => void };\n text: string | JSX.Element;\n more?: number;\n};\n\nexport const useSelect = (\n {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data = [],\n defaultValue,\n disabled,\n emptyValue,\n id: nativeId,\n multiselect,\n onClick,\n onChange,\n readOnly,\n value = emptyValue,\n ...otherProps\n }: SelectProps,\n ref: React.Ref<HTMLInputElement>\n): useSelect => {\n const { texts } = useLocalization();\n const searchData = useFlattenedData(data);\n const inputRef = useProxiedRef<HTMLInputElement>(ref);\n const [open, setOpen] = React.useState(false);\n const id = React.useMemo(() => nativeId || `select_${uuid()}`, [nativeId]);\n const internalInputRef = React.useRef(null);\n const buttonId = `${id}-button`;\n // support 'escape' resetting to the value that was set when the listbox opened\n const [lastValue, setLastValue] = React.useState<ScrollableListItemValue | undefined>(value);\n\n React.useEffect(() => {\n setLastValue(value);\n }, [open]);\n\n React.useEffect(() => {\n if (defaultValue !== undefined && value === undefined) {\n setInputValueByRef(internalInputRef.current, defaultValue);\n }\n }, [defaultValue]);\n\n React.useEffect(() => {\n if (value !== undefined) {\n setInputValueByRef(internalInputRef.current, value);\n } else if (data.length && defaultValue === undefined) {\n setInputValueByRef(internalInputRef.current, data[0].value);\n }\n }, []);\n\n // event handlers\n const handleButtonKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>): void => {\n if (event.keyCode === keycode('up') || event.keyCode === keycode('down')) {\n event.preventDefault();\n setOpen(true);\n }\n };\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>): void => {\n switch (event.keyCode) {\n case keycode('escape'): {\n event.preventDefault();\n if (lastValue !== undefined) {\n setInputValueByRef(inputRef.current, lastValue);\n }\n\n setOpen(false);\n break;\n }\n\n case keycode('tab'):\n case keycode('enter'): {\n if (event.keyCode !== keycode('tab')) {\n event.preventDefault();\n }\n setOpen(false);\n break;\n }\n\n default:\n }\n\n if (otherProps.onKeyDown) {\n otherProps.onKeyDown(event);\n }\n };\n\n const handleListboxClick = (event: React.MouseEvent<HTMLLIElement>): void => {\n event.preventDefault();\n if (!multiselect) {\n setOpen(false);\n }\n };\n\n let text: string | JSX.Element = '';\n let more = 0;\n\n if (value !== undefined) {\n if (multiselect) {\n const selectedValues = value?.toString().split(',') || [];\n\n if (selectedValues.length === searchData.filter(item => !item.disabled).length) {\n text = texts.select.allOptionsSelected;\n } else {\n text = findByValue(searchData, selectedValues[0])?.text ?? '';\n more = selectedValues.length > 1 ? selectedValues.length - 1 : 0;\n }\n } else {\n const item = findByValue(searchData, value);\n\n if (item) {\n text = item.icon ? (\n <>\n {React.cloneElement(item.icon, {\n className: cn(item.icon.props.className, 'mr-1 -mt-px'),\n })}\n {item.text}\n </>\n ) : (\n item.text\n );\n }\n }\n }\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n event.persist();\n\n if (onChange) {\n const item = findByValue(searchData, event.target.value);\n (event as any).detail = sanitizeItem(item);\n\n const indexes = item?.path?.split('.') ?? [];\n\n if (indexes.length > 1) {\n // we don't want to map the current item\n indexes.pop();\n // we need to rebuild the path as we map\n let lastPath: string;\n\n (event as any).detail.parents = indexes.map(i => {\n lastPath = lastPath ? [lastPath, i].join('.') : i;\n return sanitizeItem(searchData.find(i => i.path === lastPath));\n });\n }\n\n onChange(event);\n }\n };\n\n const button: React.ButtonHTMLAttributes<HTMLButtonElement> = {\n 'aria-haspopup': 'listbox' as const,\n 'aria-label': ariaLabel ? `${ariaLabel} ${text}` : undefined,\n 'aria-labelledby': ariaLabelledBy ? `${ariaLabelledBy} ${buttonId}` : undefined,\n disabled,\n id: buttonId,\n onKeyDown: !disabled && !readOnly ? handleButtonKeyDown : undefined,\n type: 'button',\n };\n\n const listbox = {\n ...otherProps,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data,\n disabled,\n emptyValue,\n onClick: handleListboxClick,\n onChange: event => {\n setInputValueByRef(internalInputRef.current, event.target?.value);\n },\n onKeyDown: handleListboxKeyDown,\n ref: inputRef,\n value,\n multiselect,\n };\n\n const input = {\n onChange: handleInputChange,\n ref: internalInputRef,\n value: value ?? '',\n };\n\n return {\n button,\n listbox,\n input,\n popover: {\n open,\n onOpenChange: setOpen,\n },\n text,\n more,\n };\n};\n"],"names":["useSelect","ref","ariaLabel","ariaLabelledBy","data","defaultValue","disabled","emptyValue","nativeId","id","multiselect","onChange","readOnly","value","otherProps","useLocalization","texts","searchData","useFlattenedData","inputRef","useProxiedRef","React","open","setOpen","uuid","internalInputRef","buttonId","lastValue","setLastValue","undefined","setInputValueByRef","current","length","handleButtonKeyDown","event","keyCode","keycode","preventDefault","handleListboxKeyDown","onKeyDown","handleListboxClick","text","more","selectedValues","toString","split","filter","item","select","allOptionsSelected","findByValue","icon","className","cn","props","handleInputChange","persist","target","detail","sanitizeItem","indexes","path","pop","lastPath","parents","map","i","join","find","button","type","listbox","onClick","input","popover","onOpenChange"],"mappings":";;;;;;;;;;IAoBaA,SAAS,GAAG,SAAZA,SAAY,OAgBrBC,GAhBqB;MAEHC,iBAAd;MACmBC,sBAAnB;uBACAC;MAAAA,8BAAO;MACPC,oBAAAA;MACAC,gBAAAA;MACAC,kBAAAA;MACIC,gBAAJC;MACAC,mBAAAA;MAEAC,gBAAAA;MACAC,gBAAAA;wBACAC;MAAAA,gCAAQN;MACLO;;AAIP,yBAAkBC,eAAe,EAAjC;AAAA,MAAQC,KAAR,oBAAQA,KAAR;;AACA,MAAMC,UAAU,GAAGC,gBAAgB,CAACd,IAAD,CAAnC;AACA,MAAMe,QAAQ,GAAGC,aAAa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QAAQ,EAARA,QALS;AAMTC,IAAAA,UAAU,EAAVA,UANS;AAOTiE,IAAAA,OAAO,EAAEhC,kBAPA;AAQT7B,IAAAA,QAAQ,EAAE,kBAAAuB,KAAK;;;AACXJ,MAAAA,kBAAkB,CAACL,gBAAgB,CAACM,OAAlB,mBAA2BG,KAAK,CAACuB,MAAjC,kDAA2B,cAAc5C,KAAzC,CAAlB;AACH,KAVQ;AAWT0B,IAAAA,SAAS,EAAED,oBAXF;AAYTrC,IAAAA,GAAG,EAAEkB,QAZI;AAaTN,IAAAA,KAAK,EAALA,KAbS;AAcTH,IAAAA,WAAW,EAAXA;AAdS,IAAb;;AAiBA,MAAM+D,KAAK,GAAG;AACV9D,IAAAA,QAAQ,EAAE4C,iBADA;AAEVtD,IAAAA,GAAG,EAAEwB,gBAFK;AAGVZ,IAAAA,KAAK,EAAEA,KAAF,aAAEA,KAAF,cAAEA,KAAF,GAAW;AAHN,GAAd;AAMA,SAAO;AACHwD,IAAAA,MAAM,EAANA,MADG;AAEHE,IAAAA,OAAO,EAAPA,OAFG;AAGHE,IAAAA,KAAK,EAALA,KAHG;AAIHC,IAAAA,OAAO,EAAE;AACLpD,MAAAA,IAAI,EAAJA,IADK;AAELqD,MAAAA,YAAY,EAAEpD;AAFT,KAJN;AAQHkB,IAAAA,IAAI,EAAJA,IARG;AASHC,IAAAA,IAAI,EAAJA;AATG,GAAP;AAWH;;;;"}
1
+ {"version":3,"file":"useSelect.js","sources":["../../../../src/components/Select/useSelect.tsx"],"sourcesContent":["import * as React from 'react';\nimport keycode from 'keycode';\nimport cn from 'classnames';\nimport { v4 as uuid } from 'uuid';\nimport { useLocalization } from '../Provider/Provider';\nimport { SelectProps } from './Select';\nimport { ListboxProps } from '../Listbox/Listbox';\nimport { useProxiedRef } from '../../utils/hooks/useProxiedRef';\nimport { setInputValueByRef, findByValue, useFlattenedData, sanitizeItem } from '../Listbox/util';\nimport { ScrollableListItemValue } from '../Listbox/ScrollableList';\n\ntype useSelect = React.HtmlHTMLAttributes<HTMLDivElement> & {\n button: React.ButtonHTMLAttributes<HTMLButtonElement>;\n listbox: ListboxProps;\n input: any;\n popover: { open: boolean; onOpenChange: (open: boolean) => void };\n text: string | JSX.Element;\n more?: number;\n};\n\nexport const useSelect = (\n {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data = [],\n defaultValue,\n disabled,\n emptyValue,\n id: nativeId,\n multiselect,\n onClick,\n onChange,\n readOnly,\n value = emptyValue,\n ...otherProps\n }: SelectProps,\n ref: React.Ref<HTMLInputElement>\n): useSelect => {\n const { texts } = useLocalization();\n const searchData = useFlattenedData(data);\n const inputRef = useProxiedRef<HTMLInputElement>(ref);\n const [open, setOpen] = React.useState(false);\n const id = React.useMemo(() => nativeId || `select_${uuid()}`, [nativeId]);\n const internalInputRef = React.useRef(null);\n // support 'escape' resetting to the value that was set when the listbox opened\n const [lastValue, setLastValue] = React.useState<ScrollableListItemValue | undefined>(value);\n\n React.useEffect(() => {\n setLastValue(value);\n }, [open]);\n\n React.useEffect(() => {\n if (defaultValue !== undefined && value === undefined) {\n setInputValueByRef(internalInputRef.current, defaultValue);\n }\n }, [defaultValue]);\n\n React.useEffect(() => {\n if (value !== undefined) {\n setInputValueByRef(internalInputRef.current, value);\n } else if (data.length && defaultValue === undefined) {\n setInputValueByRef(internalInputRef.current, data[0].value);\n }\n }, []);\n\n // event handlers\n const handleButtonKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>): void => {\n if (event.keyCode === keycode('up') || event.keyCode === keycode('down')) {\n event.preventDefault();\n setOpen(true);\n }\n };\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>): void => {\n switch (event.keyCode) {\n case keycode('escape'): {\n event.preventDefault();\n if (lastValue !== undefined) {\n setInputValueByRef(inputRef.current, lastValue);\n }\n\n setOpen(false);\n break;\n }\n\n case keycode('tab'):\n case keycode('enter'): {\n if (event.keyCode !== keycode('tab')) {\n event.preventDefault();\n }\n setOpen(false);\n break;\n }\n\n default:\n }\n\n if (otherProps.onKeyDown) {\n otherProps.onKeyDown(event);\n }\n };\n\n const handleListboxClick = (event: React.MouseEvent<HTMLLIElement>): void => {\n event.preventDefault();\n if (!multiselect) {\n setOpen(false);\n }\n };\n\n let text: string | JSX.Element = '';\n let more = 0;\n\n if (value !== undefined) {\n if (multiselect) {\n const selectedValues = value?.toString().split(',') || [];\n\n if (selectedValues.length === searchData.filter(item => !item.disabled).length) {\n text = texts.select.allOptionsSelected;\n } else {\n text = findByValue(searchData, selectedValues[0])?.text ?? '';\n more = selectedValues.length > 1 ? selectedValues.length - 1 : 0;\n }\n } else {\n const item = findByValue(searchData, value);\n\n if (item) {\n text = item.icon ? (\n <>\n {React.cloneElement(item.icon, {\n className: cn(item.icon.props.className, 'mr-1 -mt-px'),\n })}\n {item.text}\n </>\n ) : (\n item.text\n );\n }\n }\n }\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n event.persist();\n\n if (onChange) {\n const item = findByValue(searchData, event.target.value);\n (event as any).detail = sanitizeItem(item);\n\n const indexes = item?.path?.split('.') ?? [];\n\n if (indexes.length > 1) {\n // we don't want to map the current item\n indexes.pop();\n // we need to rebuild the path as we map\n let lastPath: string;\n\n (event as any).detail.parents = indexes.map(i => {\n lastPath = lastPath ? [lastPath, i].join('.') : i;\n return sanitizeItem(searchData.find(i => i.path === lastPath));\n });\n }\n\n onChange(event);\n }\n };\n\n const button: React.ButtonHTMLAttributes<HTMLButtonElement> = {\n 'aria-haspopup': 'listbox' as const,\n 'aria-label': ariaLabel ? `${ariaLabel} ${text}` : undefined,\n 'aria-labelledby': ariaLabelledBy ? `${ariaLabelledBy} ${id}` : undefined,\n disabled,\n id,\n onKeyDown: !disabled && !readOnly ? handleButtonKeyDown : undefined,\n type: 'button',\n };\n\n const listbox = {\n ...otherProps,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n data,\n disabled,\n emptyValue,\n onClick: handleListboxClick,\n onChange: event => {\n setInputValueByRef(internalInputRef.current, event.target?.value);\n },\n onKeyDown: handleListboxKeyDown,\n ref: inputRef,\n value,\n multiselect,\n };\n\n const input = {\n onChange: handleInputChange,\n ref: internalInputRef,\n value: value ?? '',\n };\n\n return {\n button,\n listbox,\n input,\n popover: {\n open,\n onOpenChange: setOpen,\n },\n text,\n more,\n };\n};\n"],"names":["useSelect","ref","ariaLabel","ariaLabelledBy","data","defaultValue","disabled","emptyValue","nativeId","id","multiselect","onChange","readOnly","value","otherProps","useLocalization","texts","searchData","useFlattenedData","inputRef","useProxiedRef","React","open","setOpen","uuid","internalInputRef","lastValue","setLastValue","undefined","setInputValueByRef","current","length","handleButtonKeyDown","event","keyCode","keycode","preventDefault","handleListboxKeyDown","onKeyDown","handleListboxClick","text","more","selectedValues","toString","split","filter","item","select","allOptionsSelected","findByValue","icon","className","cn","props","handleInputChange","persist","target","detail","sanitizeItem","indexes","path","pop","lastPath","parents","map","i","join","find","button","type","listbox","onClick","input","popover","onOpenChange"],"mappings":";;;;;;;;;;IAoBaA,SAAS,GAAG,SAAZA,SAAY,OAgBrBC,GAhBqB;MAEHC,iBAAd;MACmBC,sBAAnB;uBACAC;MAAAA,8BAAO;MACPC,oBAAAA;MACAC,gBAAAA;MACAC,kBAAAA;MACIC,gBAAJC;MACAC,mBAAAA;MAEAC,gBAAAA;MACAC,gBAAAA;wBACAC;MAAAA,gCAAQN;MACLO;;AAIP,yBAAkBC,eAAe,EAAjC;AAAA,MAAQC,KAAR,oBAAQA,KAAR;;AACA,MAAMC,UAAU,GAAGC,gBAAgB,CAACd,IAAD,CAAnC;AACA,MAAMe,QAAQ,GAAGC,aAAa,CAAmBnB,GAAnB,CAA9B;;AACA,wBAAwBoB,QAAA,CAAe,KAAf,CAAxB;AAAA,MAAOC,IAAP;AAAA,MAAaC,OAAb;;AACA,MAAMd,EAAE,GAAGY,OAAA,CAAc;AAAA,WAAMb,QAAQ,gBAAcgB,EAAI,EAAhC;AAAA,GAAd,EAAoD,C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KAVQ;AAWTyB,IAAAA,SAAS,EAAED,oBAXF;AAYTpC,IAAAA,GAAG,EAAEkB,QAZI;AAaTN,IAAAA,KAAK,EAALA,KAbS;AAcTH,IAAAA,WAAW,EAAXA;AAdS,IAAb;;AAiBA,MAAM8D,KAAK,GAAG;AACV7D,IAAAA,QAAQ,EAAE2C,iBADA;AAEVrD,IAAAA,GAAG,EAAEwB,gBAFK;AAGVZ,IAAAA,KAAK,EAAEA,KAAF,aAAEA,KAAF,cAAEA,KAAF,GAAW;AAHN,GAAd;AAMA,SAAO;AACHuD,IAAAA,MAAM,EAANA,MADG;AAEHE,IAAAA,OAAO,EAAPA,OAFG;AAGHE,IAAAA,KAAK,EAALA,KAHG;AAIHC,IAAAA,OAAO,EAAE;AACLnD,MAAAA,IAAI,EAAJA,IADK;AAELoD,MAAAA,YAAY,EAAEnD;AAFT,KAJN;AAQHiB,IAAAA,IAAI,EAAJA,IARG;AASHC,IAAAA,IAAI,EAAJA;AATG,GAAP;AAWH;;;;"}
@@ -19,14 +19,14 @@ var Switch = /*#__PURE__*/forwardRef(function Switch(props, ref) {
19
19
  onCheckedChange: onChange,
20
20
  ref: ref
21
21
  }), createElement(Thumb, {
22
- className: "'will-change-transform transition-transform translate-x-1 group-aria-checked:translate-x-5 h-4 w-4 mt-1 bg-white rounded-full"
22
+ className: "'will-change-transform group-aria-checked:translate-x-5 mt-1 h-4 w-4 translate-x-1 rounded-full bg-white transition-transform"
23
23
  }));
24
24
 
25
25
  if (label) {
26
26
  var labelClassName = cn('flex items-center cursor-pointer', {
27
27
  'cursor-not-allowed text-grey-dark': props.disabled
28
28
  });
29
- return createElement("label", {
29
+ element = createElement("label", {
30
30
  className: labelClassName
31
31
  }, element, label);
32
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.js","sources":["../../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as PrimitiveSwitch from '@radix-ui/react-switch';\n\ntype SwitchBaseProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'onChange'> & {\n /** Label for the switch */\n label?: React.ReactNode;\n /* Whether user input is required */\n required?: boolean;\n};\n\ninterface UncontrolledSwitchProps extends SwitchBaseProps {\n checked?: never;\n onChange?: never;\n /* The default checked state (uncontrolled) */\n defaultChecked?: boolean;\n}\n\ninterface ControlledSwitchProps extends SwitchBaseProps {\n defaultChecked?: never;\n /* The current checked state (controlled) */\n checked: boolean;\n /* Handler called when the checked state changes */\n onChange: (checked: boolean) => void;\n}\n\nexport type SwitchProps = UncontrolledSwitchProps | ControlledSwitchProps;\n\nexport const Switch = React.forwardRef(function Switch(props: SwitchProps, ref: React.Ref<HTMLButtonElement>) {\n const { label, onChange, ...otherProps } = props;\n\n const className = cn(\n 'group h-6 w-10 flex rounded-full inline-flex',\n {\n 'mr-2': !!label,\n 'bg-grey-darker aria-checked:bg-blue focus:yt-focus': !props.disabled,\n 'bg-grey-light cursor-not-allowed aria-checked:bg-blue-light': props.disabled,\n },\n props.className\n );\n\n const element = (\n <PrimitiveSwitch.Root {...otherProps} className={className} onCheckedChange={onChange} ref={ref}>\n <PrimitiveSwitch.Thumb className=\"'will-change-transform transition-transform translate-x-1 group-aria-checked:translate-x-5 h-4 w-4 mt-1 bg-white rounded-full\" />\n </PrimitiveSwitch.Root>\n );\n\n if (label) {\n const labelClassName = cn('flex items-center cursor-pointer', {\n 'cursor-not-allowed text-grey-dark': props.disabled,\n });\n\n return (\n <label className={labelClassName}>\n {element}\n {label}\n </label>\n );\n }\n\n return element;\n});\n"],"names":["Switch","React","props","ref","label","onChange","otherProps","className","cn","disabled","element","PrimitiveSwitch","onCheckedChange","labelClassName"],"mappings":";;;;;;IA4BaA,MAAM,gBAAGC,UAAA,CAAiB,SAASD,MAAT,CAAgBE,KAAhB,EAAoCC,GAApC;AACnC,MAAQC,KAAR,GAA2CF,KAA3C,CAAQE,KAAR;AAAA,MAAeC,QAAf,GAA2CH,KAA3C,CAAeG,QAAf;AAAA,MAA4BC,UAA5B,iCAA2CJ,KAA3C;;AAEA,MAAMK,SAAS,GAAGC,EAAE,CAChB,8CADgB,EAEhB;AACI,YAAQ,CAAC,CAACJ,KADd;AAEI,0DAAsD,CAACF,KAAK,CAACO,QAFjE;AAGI,mEAA+DP,KAAK,CAACO;AAHzE,GAFgB,EAOhBP,KAAK,CAACK,SAPU,CAApB;AAUA,MAAMG,OAAO,GACTT,aAAA,CAACU,IAAD,oBAA0BL;AAAYC,IAAAA,SAAS,EAAEA;AAAWK,IAAAA,eAAe,EAAEP;AAAUF,IAAAA,GAAG,EAAEA;IAA5F,EACIF,aAAA,CAACU,KAAD;AAAuBJ,IAAAA,SAAS,EAAC;GAAjC,CADJ,CADJ;;AAMA,MAAIH,KAAJ,EAAW;AACP,QAAMS,cAAc,GAAGL,EAAE,CAAC,kCAAD,EAAqC;AAC1D,2CAAqCN,KAAK,CAACO;AADe,KAArC,CAAzB;AAIA,WACIR,aAAA,QAAA;AAAOM,MAAAA,SAAS,EAAEM;KAAlB,EACKH,OADL,EAEKN,KAFL,CADJ;AAMH;;AAED,SAAOM,OAAP;AACH,CAjCqB;;;;"}
1
+ {"version":3,"file":"Switch.js","sources":["../../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as PrimitiveSwitch from '@radix-ui/react-switch';\n\ntype SwitchBaseProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'onChange'> & {\n /** Label for the switch */\n label?: React.ReactNode;\n /* Whether user input is required */\n required?: boolean;\n};\n\ninterface UncontrolledSwitchProps extends SwitchBaseProps {\n checked?: never;\n onChange?: never;\n /* The default checked state (uncontrolled) */\n defaultChecked?: boolean;\n}\n\ninterface ControlledSwitchProps extends SwitchBaseProps {\n defaultChecked?: never;\n /* The current checked state (controlled) */\n checked: boolean;\n /* Handler called when the checked state changes */\n onChange: (checked: boolean) => void;\n}\n\nexport type SwitchProps = UncontrolledSwitchProps | ControlledSwitchProps;\n\nexport const Switch = React.forwardRef(function Switch(props: SwitchProps, ref: React.Ref<HTMLButtonElement>) {\n const { label, onChange, ...otherProps } = props;\n\n const className = cn(\n 'group h-6 w-10 flex rounded-full inline-flex',\n {\n 'mr-2': !!label,\n 'bg-grey-darker aria-checked:bg-blue focus:yt-focus': !props.disabled,\n 'bg-grey-light cursor-not-allowed aria-checked:bg-blue-light': props.disabled,\n },\n props.className\n );\n\n let element = (\n <PrimitiveSwitch.Root {...otherProps} className={className} onCheckedChange={onChange} ref={ref}>\n <PrimitiveSwitch.Thumb className=\"'will-change-transform group-aria-checked:translate-x-5 mt-1 h-4 w-4 translate-x-1 rounded-full bg-white transition-transform\" />\n </PrimitiveSwitch.Root>\n );\n\n if (label) {\n const labelClassName = cn('flex items-center cursor-pointer', {\n 'cursor-not-allowed text-grey-dark': props.disabled,\n });\n\n element = (\n <label className={labelClassName}>\n {element}\n {label}\n </label>\n );\n }\n\n return element;\n});\n"],"names":["Switch","React","props","ref","label","onChange","otherProps","className","cn","disabled","element","PrimitiveSwitch","onCheckedChange","labelClassName"],"mappings":";;;;;;IA4BaA,MAAM,gBAAGC,UAAA,CAAiB,SAASD,MAAT,CAAgBE,KAAhB,EAAoCC,GAApC;AACnC,MAAQC,KAAR,GAA2CF,KAA3C,CAAQE,KAAR;AAAA,MAAeC,QAAf,GAA2CH,KAA3C,CAAeG,QAAf;AAAA,MAA4BC,UAA5B,iCAA2CJ,KAA3C;;AAEA,MAAMK,SAAS,GAAGC,EAAE,CAChB,8CADgB,EAEhB;AACI,YAAQ,CAAC,CAACJ,KADd;AAEI,0DAAsD,CAACF,KAAK,CAACO,QAFjE;AAGI,mEAA+DP,KAAK,CAACO;AAHzE,GAFgB,EAOhBP,KAAK,CAACK,SAPU,CAApB;AAUA,MAAIG,OAAO,GACPT,aAAA,CAACU,IAAD,oBAA0BL;AAAYC,IAAAA,SAAS,EAAEA;AAAWK,IAAAA,eAAe,EAAEP;AAAUF,IAAAA,GAAG,EAAEA;IAA5F,EACIF,aAAA,CAACU,KAAD;AAAuBJ,IAAAA,SAAS,EAAC;GAAjC,CADJ,CADJ;;AAMA,MAAIH,KAAJ,EAAW;AACP,QAAMS,cAAc,GAAGL,EAAE,CAAC,kCAAD,EAAqC;AAC1D,2CAAqCN,KAAK,CAACO;AADe,KAArC,CAAzB;AAIAC,IAAAA,OAAO,GACHT,aAAA,QAAA;AAAOM,MAAAA,SAAS,EAAEM;KAAlB,EACKH,OADL,EAEKN,KAFL,CADJ;AAMH;;AAED,SAAOM,OAAP;AACH,CAjCqB;;;;"}
@@ -3,7 +3,7 @@ import { forwardRef, createElement } from 'react';
3
3
  import cn from 'classnames';
4
4
  import { getInputClasses } from '../Input/util.js';
5
5
 
6
- var _excluded = ["defaultValue", "highlighted", "onKeyDown", "state"];
6
+ var _excluded = ["defaultValue", "highlighted", "invalid", "onKeyDown"];
7
7
  var Textarea = /*#__PURE__*/forwardRef(function Textarea(props, ref) {
8
8
  var onKeyDown = props.onKeyDown,
9
9
  otherProps = _objectWithoutPropertiesLoose(props, _excluded);
@@ -1 +1 @@
1
- {"version":3,"file":"Textarea.js","sources":["../../../../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { State } from '../../types';\nimport { getInputClasses } from '../Input/util';\n\nexport type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement> & {\n /** Draws attention to the textarea by changing its style and making it visually prominent */\n highlighted?: boolean;\n /** State will change the style of the textarea **/\n state?: State;\n /** Value of the textarea */\n value?: string;\n};\n\nexport const Textarea = React.forwardRef(function Textarea(props: TextareaProps, ref: React.Ref<HTMLTextAreaElement>) {\n const { defaultValue: _, highlighted, onKeyDown, state, ...otherProps } = props;\n const classNames = cn(getInputClasses(props), 'py-1 min-h-[75px] disabled:resize-none', props.className);\n\n // home and end keys only navigate to the start/end of textarea value if the textarea container does not scroll\n // if it has scroll height then the browser reverts to native scrolling behaviour only\n // so we manually override it to ensure _our_ desired behaviour remains intact\n const handleKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (event.key === 'Home' || event.key === 'End') {\n event.preventDefault();\n const position = event.key === 'End' ? event.currentTarget.value.length : 0;\n event.currentTarget.setSelectionRange(position, position);\n event.currentTarget.scrollTop = event.key === 'End' ? event.currentTarget.scrollHeight : 0;\n }\n\n if (onKeyDown) {\n onKeyDown(event);\n }\n };\n\n return <textarea {...otherProps} className={classNames} data-taco=\"textarea\" onKeyDown={handleKeyDown} ref={ref} />;\n});\n"],"names":["Textarea","React","props","ref","onKeyDown","otherProps","classNames","cn","getInputClasses","className","handleKeyDown","event","key","preventDefault","position","currentTarget","value","length","setSelectionRange","scrollTop","scrollHeight"],"mappings":";;;;;;IAcaA,QAAQ,gBAAGC,UAAA,CAAiB,SAASD,QAAT,CAAkBE,KAAlB,EAAwCC,GAAxC;AACrC,MAAsCC,SAAtC,GAA0EF,KAA1E,CAAsCE,SAAtC;AAAA,MAA2DC,UAA3D,iCAA0EH,KAA1E;;AACA,MAAMI,UAAU,GAAGC,EAAE,CAACC,eAAe,CAACN,KAAD,CAAhB,EAAyB,wCAAzB,EAAmEA,KAAK,CAACO,SAAzE,CAArB;AAGA;AACA;;AACA,MAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD;AAClB,QAAIA,KAAK,CAACC,GAAN,KAAc,MAAd,IAAwBD,KAAK,CAACC,GAAN,KAAc,KAA1C,EAAiD;AAC7CD,MAAAA,KAAK,CAACE,cAAN;AACA,UAAMC,QAAQ,GAAGH,KAAK,CAACC,GAAN,KAAc,KAAd,GAAsBD,KAAK,CAACI,aAAN,CAAoBC,KAApB,CAA0BC,MAAhD,GAAyD,CAA1E;AACAN,MAAAA,KAAK,CAACI,aAAN,CAAoBG,iBAApB,CAAsCJ,QAAtC,EAAgDA,QAAhD;AACAH,MAAAA,KAAK,CAACI,aAAN,CAAoBI,SAApB,GAAgCR,KAAK,CAACC,GAAN,KAAc,KAAd,GAAsBD,KAAK,CAACI,aAAN,CAAoBK,YAA1C,GAAyD,CAAzF;AACH;;AAED,QAAIhB,SAAJ,EAAe;AACXA,MAAAA,SAAS,CAACO,KAAD,CAAT;AACH;AACJ,GAXD;;AAaA,SAAOV,aAAA,WAAA,oBAAcI;AAAYI,IAAAA,SAAS,EAAEH;iBAAsB;AAAWF,IAAAA,SAAS,EAAEM;AAAeP,IAAAA,GAAG,EAAEA;IAArG,CAAP;AACH,CArBuB;;;;"}
1
+ {"version":3,"file":"Textarea.js","sources":["../../../../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { getInputClasses } from '../Input/util';\n\nexport type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement> & {\n /** Draws attention to the textarea by changing its style and making it visually prominent */\n highlighted?: boolean;\n invalid?: boolean;\n /** Value of the textarea */\n value?: string;\n};\n\nexport const Textarea = React.forwardRef(function Textarea(props: TextareaProps, ref: React.Ref<HTMLTextAreaElement>) {\n const { defaultValue: _, highlighted, invalid, onKeyDown, ...otherProps } = props;\n const classNames = cn(getInputClasses(props), 'py-1 min-h-[75px] disabled:resize-none', props.className);\n\n // home and end keys only navigate to the start/end of textarea value if the textarea container does not scroll\n // if it has scroll height then the browser reverts to native scrolling behaviour only\n // so we manually override it to ensure _our_ desired behaviour remains intact\n const handleKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (event.key === 'Home' || event.key === 'End') {\n event.preventDefault();\n const position = event.key === 'End' ? event.currentTarget.value.length : 0;\n event.currentTarget.setSelectionRange(position, position);\n event.currentTarget.scrollTop = event.key === 'End' ? event.currentTarget.scrollHeight : 0;\n }\n\n if (onKeyDown) {\n onKeyDown(event);\n }\n };\n\n return <textarea {...otherProps} className={classNames} data-taco=\"textarea\" onKeyDown={handleKeyDown} ref={ref} />;\n});\n"],"names":["Textarea","React","props","ref","onKeyDown","otherProps","classNames","cn","getInputClasses","className","handleKeyDown","event","key","preventDefault","position","currentTarget","value","length","setSelectionRange","scrollTop","scrollHeight"],"mappings":";;;;;;IAYaA,QAAQ,gBAAGC,UAAA,CAAiB,SAASD,QAAT,CAAkBE,KAAlB,EAAwCC,GAAxC;AACrC,MAA+CC,SAA/C,GAA4EF,KAA5E,CAA+CE,SAA/C;AAAA,MAA6DC,UAA7D,iCAA4EH,KAA5E;;AACA,MAAMI,UAAU,GAAGC,EAAE,CAACC,eAAe,CAACN,KAAD,CAAhB,EAAyB,wCAAzB,EAAmEA,KAAK,CAACO,SAAzE,CAArB;AAGA;AACA;;AACA,MAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD;AAClB,QAAIA,KAAK,CAACC,GAAN,KAAc,MAAd,IAAwBD,KAAK,CAACC,GAAN,KAAc,KAA1C,EAAiD;AAC7CD,MAAAA,KAAK,CAACE,cAAN;AACA,UAAMC,QAAQ,GAAGH,KAAK,CAACC,GAAN,KAAc,KAAd,GAAsBD,KAAK,CAACI,aAAN,CAAoBC,KAApB,CAA0BC,MAAhD,GAAyD,CAA1E;AACAN,MAAAA,KAAK,CAACI,aAAN,CAAoBG,iBAApB,CAAsCJ,QAAtC,EAAgDA,QAAhD;AACAH,MAAAA,KAAK,CAACI,aAAN,CAAoBI,SAApB,GAAgCR,KAAK,CAACC,GAAN,KAAc,KAAd,GAAsBD,KAAK,CAACI,aAAN,CAAoBK,YAA1C,GAAyD,CAAzF;AACH;;AAED,QAAIhB,SAAJ,EAAe;AACXA,MAAAA,SAAS,CAACO,KAAD,CAAT;AACH;AACJ,GAXD;;AAaA,SAAOV,aAAA,WAAA,oBAAcI;AAAYI,IAAAA,SAAS,EAAEH;iBAAsB;AAAWF,IAAAA,SAAS,EAAEM;AAAeP,IAAAA,GAAG,EAAEA;IAArG,CAAP;AACH,CArBuB;;;;"}
@@ -3467,7 +3467,7 @@ var IconButton = /*#__PURE__*/React.forwardRef(function IconButton(props, ref) {
3467
3467
  rounded = _props$rounded === void 0 ? false : _props$rounded,
3468
3468
  otherProps = _objectWithoutPropertiesLoose(props, _excluded$6);
3469
3469
 
3470
- var className = cn(getButtonClasses(), getAppearanceClasses(appearance, true), {
3470
+ var className = cn('w-8', getButtonClasses(), getAppearanceClasses(appearance, true), {
3471
3471
  'rounded-full': rounded,
3472
3472
  rounded: !rounded,
3473
3473
  'cursor-not-allowed opacity-50': props.disabled,
@@ -4203,9 +4203,9 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(props, ref) {
4203
4203
  }
4204
4204
 
4205
4205
  var element = React.createElement(CheckboxPrimitive.Root, Object.assign({}, otherProps, {
4206
- "data-taco": "checkbox",
4207
4206
  checked: indeterminate ? 'indeterminate' : checked,
4208
4207
  className: className,
4208
+ "data-taco": "checkbox",
4209
4209
  onCheckedChange: handleChange,
4210
4210
  ref: ref
4211
4211
  }), React.createElement(CheckboxPrimitive.Indicator, {
@@ -4219,7 +4219,7 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(props, ref) {
4219
4219
  var labelClassName = cn('flex items-center cursor-pointer', {
4220
4220
  'cursor-not-allowed text-grey-dark': props.disabled
4221
4221
  });
4222
- return React.createElement("label", {
4222
+ element = React.createElement("label", {
4223
4223
  className: labelClassName
4224
4224
  }, element, label);
4225
4225
  }
@@ -4242,56 +4242,30 @@ var useProxiedRef = function useProxiedRef(ref) {
4242
4242
  };
4243
4243
 
4244
4244
  var getInputClasses = function getInputClasses(props) {
4245
- var _cn;
4246
-
4247
- return cn('peer bg-white text-black text-sm border font-normal not-italic no-underline rounded inline-flex leading-6 px-2 relative w-full text-ellipsis transition-all delay-100 ease-in flex items-center', (_cn = {
4245
+ return cn('peer bg-white text-black text-sm border font-normal not-italic no-underline rounded inline-flex leading-6 px-2 relative w-full text-ellipsis transition-all delay-100 ease-in flex items-center', {
4248
4246
  'cursor-not-allowed text-black bg-grey': props.readOnly,
4249
- 'border-grey text-opacity-25 cursor-not-allowed': props.disabled
4250
- }, _cn[getStateClasses$1(props.state)] = !props.disabled, _cn['bg-[rgba(255,255,0,0.075)]'] = props.highlighted && props.disabled, _cn['bg-[rgba(255,255,0,0.2)]'] = props.highlighted && !props.disabled, _cn));
4247
+ 'border-grey text-opacity-25 cursor-not-allowed': props.disabled,
4248
+ 'bg-[rgba(255,255,0,0.075)]': props.highlighted && props.disabled,
4249
+ 'bg-[rgba(255,255,0,0.2)]': props.highlighted && !props.disabled,
4250
+ 'border-grey-dark hover:shadow-[0_0_0.1rem_theme(colors.grey.darker)] focus:border-blue-light focus:yt-focus active:border-blue-dark': !props.invalid,
4251
+ 'border-red hover:shadow-[0_0_0.15rem_theme(colors.red.DEFAULT)] focus:border-red-light focus:yt-focus-red active:border-red-dark': props.invalid
4252
+ });
4251
4253
  };
4252
- var getStateClasses$1 = function getStateClasses(value) {
4253
- switch (value) {
4254
- case 'success':
4255
- return 'border-green hover:shadow-[0_0_0.15rem_theme(colors.green.DEFAULT)] focus:border-green-light focus:yt-focus-green active:border-green-dark';
4256
-
4257
- case 'error':
4258
- return 'border-red hover:shadow-[0_0_0.15rem_theme(colors.red.DEFAULT)] focus:border-red-light focus:yt-focus-red active:border-red-dark';
4259
-
4260
- case 'warning':
4261
- return 'border-yellow-dark hover:shadow-[0_0_0.15rem_theme(colors.yellow.dark)] focus:yt-focus-yellow active:border-yellow-dark';
4262
-
4263
- case 'information':
4264
- return 'border-blue hover:shadow-[0_0_0.15rem_theme(colors.blue.dark)] focus:border-blue-light focus:yt-focus active:border-blue-dark';
4265
-
4266
- default:
4267
- return 'border-grey-dark hover:shadow-[0_0_0.1rem_theme(colors.grey.darker)] focus:border-blue-light focus:yt-focus active:border-blue-dark';
4254
+ var getButtonStateClasses = function getButtonStateClasses(invalid) {
4255
+ if (invalid) {
4256
+ return '!border-red focus:!border-red-light focus:yt-focus-red peer-focus:!border-red-light peer-focus:peer-active:!border-red-dark';
4268
4257
  }
4269
- };
4270
- var getButtonStateClasses = function getButtonStateClasses(value) {
4271
- switch (value) {
4272
- case 'success':
4273
- return '!border-green focus:!border-green-light focus:yt-focus-green peer-focus:!border-green-light peer-focus:peer-active:!border-green-dark';
4274
4258
 
4275
- case 'error':
4276
- return '!border-red focus:!border-red-light focus:yt-focus-red peer-focus:!border-red-light peer-focus:peer-active:!border-red-dark';
4277
-
4278
- case 'warning':
4279
- return '!border-yellow-dark focus:!border-yellow-dark focus:yt-focus-yellow peer-focus:peer-active:!border-yellow-dark';
4280
-
4281
- case 'information':
4282
- return '!border-blue focus:!border-blue-light peer-focus:!border-blue-light peer-focus:peer-active:!border-blue-dark';
4283
-
4284
- default:
4285
- return '!border-grey-dark focus:!border-blue-light peer-focus:!border-blue-light peer-focus:peer-active:!border-blue-dark';
4286
- }
4259
+ return '!border-grey-dark focus:!border-blue-light peer-focus:!border-blue-light peer-focus:peer-active:!border-blue-dark';
4287
4260
  };
4288
4261
 
4289
- var _excluded$d = ["button", "icon", "highlighted", "onKeyDown", "state", "autoFocus"];
4262
+ var _excluded$d = ["button", "icon", "highlighted", "invalid", "onKeyDown", "autoFocus"];
4290
4263
  var Input = /*#__PURE__*/React.forwardRef(function Input(props, ref) {
4291
4264
  var button = props.button,
4292
4265
  icon = props.icon,
4266
+ _props$invalid = props.invalid,
4267
+ invalid = _props$invalid === void 0 ? false : _props$invalid,
4293
4268
  onKeyDown = props.onKeyDown,
4294
- state = props.state,
4295
4269
  autoFocus = props.autoFocus,
4296
4270
  otherProps = _objectWithoutPropertiesLoose(props, _excluded$d);
4297
4271
 
@@ -4334,7 +4308,7 @@ var Input = /*#__PURE__*/React.forwardRef(function Input(props, ref) {
4334
4308
  var _button$props$disable, _cn;
4335
4309
 
4336
4310
  var disabled = (_button$props$disable = button.props.disabled) !== null && _button$props$disable !== void 0 ? _button$props$disable : otherProps.disabled;
4337
- var buttonClassName = cn('items-center flex justify-center border absolute rounded-l-none rounded-r right-0 h-full focus:rounded focus:outline-none', (_cn = {}, _cn[getButtonStateClasses(state)] = !props.disabled, _cn), button.props.className);
4311
+ var buttonClassName = cn('items-center flex justify-center border absolute rounded-l-none rounded-r right-0 h-full focus:rounded focus:outline-none', (_cn = {}, _cn[getButtonStateClasses(invalid)] = !props.disabled, _cn), button.props.className);
4338
4312
  extra = React.cloneElement(button, {
4339
4313
  className: buttonClassName,
4340
4314
  disabled: disabled
@@ -4353,7 +4327,7 @@ var Input = /*#__PURE__*/React.forwardRef(function Input(props, ref) {
4353
4327
  }
4354
4328
 
4355
4329
  var containerClassName = cn('bg-white inline-flex relative rounded w-full', otherProps.className);
4356
- return React.createElement("div", {
4330
+ input = React.createElement("div", {
4357
4331
  className: containerClassName,
4358
4332
  "data-taco": "input-container"
4359
4333
  }, input, extra);
@@ -4451,7 +4425,7 @@ var useListScrollTo = function useListScrollTo(internalRef, itemRefs) {
4451
4425
  };
4452
4426
  };
4453
4427
 
4454
- var _excluded$e = ["data", "disabled", "highlighted", "id", "loading", "onChange", "onClick", "onFocus", "onKeyDown", "readOnly", "scrollOnFocus", "state", "value", "multiselect", "selectedIndexes", "allOptionsSelected"],
4428
+ var _excluded$e = ["data", "disabled", "highlighted", "id", "invalid", "loading", "onChange", "onClick", "onFocus", "onKeyDown", "readOnly", "scrollOnFocus", "value", "multiselect", "selectedIndexes", "allOptionsSelected"],
4455
4429
  _excluded2$1 = ["children", "icon"];
4456
4430
  var getId = function getId(id, value) {
4457
4431
  return id + "_" + value;
@@ -4853,7 +4827,7 @@ var filterData = function filterData(data, value) {
4853
4827
  });
4854
4828
  };
4855
4829
 
4856
- var _excluded$g = ["aria-label", "aria-labelledby", "data", "defaultValue", "disabled", "id", "inline", "loading", "onChange", "onClick", "onKeyDown", "onSearch", "readOnly", "value"];
4830
+ var _excluded$g = ["aria-label", "aria-labelledby", "data", "defaultValue", "disabled", "inline", "loading", "onChange", "onClick", "onKeyDown", "onSearch", "readOnly", "value"];
4857
4831
  var debouncer = /*#__PURE__*/debounce(function (f) {
4858
4832
  return f();
4859
4833
  }, 200);
@@ -5966,32 +5940,51 @@ Dialog.Extra = Extra;
5966
5940
  Dialog.Drawer = Drawer;
5967
5941
  Dialog.Close = Close$2;
5968
5942
 
5969
- var _excluded$n = ["disabled", "children", "message", "state"];
5943
+ var _excluded$n = ["children", "disabled", "invalid", "label", "message", "required"];
5970
5944
  var Field = /*#__PURE__*/React.forwardRef(function Field(props, ref) {
5971
- var disabled = props.disabled,
5972
- children = props.children,
5945
+ var _children$props$id, _children$props, _children$props$inval, _children$props2, _children$props$requi, _children$props3, _children$props4;
5946
+
5947
+ var children = props.children,
5948
+ disabled = props.disabled,
5949
+ invalid = props.invalid,
5950
+ label = props.label,
5973
5951
  message = props.message,
5974
- state = props.state,
5952
+ required = props.required,
5975
5953
  otherProps = _objectWithoutPropertiesLoose(props, _excluded$n);
5976
5954
 
5977
- var className = cn('flex flex-col font-bold text-xs leading-loose pb-4 min-h-[theme(spacing.18)]', {
5978
- 'text-grey-dark': disabled
5955
+ var idRef = React.useRef((_children$props$id = children === null || children === void 0 ? void 0 : (_children$props = children.props) === null || _children$props === void 0 ? void 0 : _children$props.id) !== null && _children$props$id !== void 0 ? _children$props$id : uuid.v4());
5956
+ var isInvalid = (_children$props$inval = children === null || children === void 0 ? void 0 : (_children$props2 = children.props) === null || _children$props2 === void 0 ? void 0 : _children$props2.invalid) !== null && _children$props$inval !== void 0 ? _children$props$inval : invalid;
5957
+ var isRequired = (_children$props$requi = children === null || children === void 0 ? void 0 : (_children$props3 = children.props) === null || _children$props3 === void 0 ? void 0 : _children$props3.required) !== null && _children$props$requi !== void 0 ? _children$props$requi : required;
5958
+ var className = cn('flex flex-col', {
5959
+ 'pt-5': !label,
5960
+ 'mb-4': !message
5979
5961
  }, props.className);
5980
- var messageClassName = cn('h-4 text-xs text-left leading-normal font-normal truncate -mb-4', {
5981
- 'text-grey-darkest': !state || state === 'default',
5982
- 'text-red': state === 'error',
5983
- 'text-green': state === 'success',
5984
- 'text-blue': state === 'information',
5985
- 'text-yellow-dark': state === 'warning',
5962
+ var labelClassName = cn('font-bold text-xs leading-4 h-4 truncate mb-1', {
5963
+ 'text-grey-dark': disabled
5964
+ });
5965
+ var messageClassName = cn('text-xs leading-normal truncate flex-none', {
5966
+ 'text-grey-darkest': !isInvalid,
5967
+ 'text-red': isInvalid,
5986
5968
  'opacity-50': disabled
5987
- }, props.className);
5988
- return React.createElement("label", Object.assign({}, otherProps, {
5969
+ });
5970
+
5971
+ if (!label && !(children !== null && children !== void 0 && children.props['aria-label'])) {
5972
+ console.warn('TACO - You are creating a Field without a `label`, you must pass an `aria-label` to the Field child to provide an accessible experience for our users.');
5973
+ }
5974
+
5975
+ return React.createElement("div", Object.assign({}, otherProps, {
5989
5976
  className: className,
5990
- "data-taco": "label",
5977
+ "data-taco": "field",
5991
5978
  ref: ref
5992
- }), children, message && React.createElement("span", {
5979
+ }), label && React.createElement("label", {
5980
+ htmlFor: idRef.current,
5981
+ className: labelClassName,
5982
+ "data-taco": "label"
5983
+ }, label, isRequired ? '*' : ''), idRef.current !== (children === null || children === void 0 ? void 0 : (_children$props4 = children.props) === null || _children$props4 === void 0 ? void 0 : _children$props4.id) ? React.cloneElement(children, {
5984
+ id: idRef.current
5985
+ }) : children, message && React.createElement("span", {
5993
5986
  className: messageClassName,
5994
- role: state === 'error' ? 'alert' : undefined
5987
+ role: isInvalid ? 'alert' : undefined
5995
5988
  }, message));
5996
5989
  });
5997
5990
 
@@ -6157,7 +6150,7 @@ var useTypeahead = function useTypeahead(_ref) {
6157
6150
  };
6158
6151
  };
6159
6152
 
6160
- var _excluded$s = ["data", "defaultValue", "disabled", "emptyValue", "id", "name", "onChange", "onFocus", "onKeyDown", "value"];
6153
+ var _excluded$s = ["data", "defaultValue", "disabled", "emptyValue", "id", "invalid", "name", "onChange", "onFocus", "onKeyDown", "value"];
6161
6154
  var useListbox = function useListbox(_ref, ref) {
6162
6155
  var _ref$data = _ref.data,
6163
6156
  externalData = _ref$data === void 0 ? [] : _ref$data,
@@ -6165,6 +6158,7 @@ var useListbox = function useListbox(_ref, ref) {
6165
6158
  disabled = _ref.disabled,
6166
6159
  emptyValue = _ref.emptyValue,
6167
6160
  nativeId = _ref.id,
6161
+ invalid = _ref.invalid,
6168
6162
  name = _ref.name,
6169
6163
  onChange = _ref.onChange,
6170
6164
  onFocus = _ref.onFocus,
@@ -6279,6 +6273,7 @@ var useListbox = function useListbox(_ref, ref) {
6279
6273
  data: data,
6280
6274
  disabled: disabled,
6281
6275
  id: id,
6276
+ invalid: invalid,
6282
6277
  onChange: handleListboxChange,
6283
6278
  onFocus: handleListboxFocus,
6284
6279
  onKeyDown: handleListboxKeyDown,
@@ -7405,8 +7400,7 @@ var useSelect = function useSelect(_ref, ref) {
7405
7400
  var id = React.useMemo(function () {
7406
7401
  return nativeId || "select_" + uuid.v4();
7407
7402
  }, [nativeId]);
7408
- var internalInputRef = React.useRef(null);
7409
- var buttonId = id + "-button"; // support 'escape' resetting to the value that was set when the listbox opened
7403
+ var internalInputRef = React.useRef(null); // support 'escape' resetting to the value that was set when the listbox opened
7410
7404
 
7411
7405
  var _React$useState2 = React.useState(value),
7412
7406
  lastValue = _React$useState2[0],
@@ -7533,9 +7527,9 @@ var useSelect = function useSelect(_ref, ref) {
7533
7527
  var button = {
7534
7528
  'aria-haspopup': 'listbox',
7535
7529
  'aria-label': ariaLabel ? ariaLabel + " " + text : undefined,
7536
- 'aria-labelledby': ariaLabelledBy ? ariaLabelledBy + " " + buttonId : undefined,
7530
+ 'aria-labelledby': ariaLabelledBy ? ariaLabelledBy + " " + id : undefined,
7537
7531
  disabled: disabled,
7538
- id: buttonId,
7532
+ id: id,
7539
7533
  onKeyDown: !disabled && !readOnly ? handleButtonKeyDown : undefined,
7540
7534
  type: 'button'
7541
7535
  };
@@ -7617,6 +7611,7 @@ var BaseSelect = /*#__PURE__*/React.forwardRef(function BaseSelect(props, ref) {
7617
7611
 
7618
7612
  var commonListboxProps = _extends({}, listbox, {
7619
7613
  className: 'w-auto',
7614
+ invalid: undefined,
7620
7615
  style: {
7621
7616
  minWidth: selectDimensions === null || selectDimensions === void 0 ? void 0 : selectDimensions.width
7622
7617
  },
@@ -9681,7 +9676,7 @@ Tabs.List = TabList;
9681
9676
  Tabs.Trigger = TabTrigger;
9682
9677
  Tabs.Content = TabContent;
9683
9678
 
9684
- var _excluded$Q = ["defaultValue", "highlighted", "onKeyDown", "state"];
9679
+ var _excluded$Q = ["defaultValue", "highlighted", "invalid", "onKeyDown"];
9685
9680
  var Textarea = /*#__PURE__*/React.forwardRef(function Textarea(props, ref) {
9686
9681
  var onKeyDown = props.onKeyDown,
9687
9682
  otherProps = _objectWithoutPropertiesLoose(props, _excluded$Q);
@@ -9727,14 +9722,14 @@ var Switch = /*#__PURE__*/React.forwardRef(function Switch(props, ref) {
9727
9722
  onCheckedChange: onChange,
9728
9723
  ref: ref
9729
9724
  }), React.createElement(PrimitiveSwitch.Thumb, {
9730
- className: "'will-change-transform transition-transform translate-x-1 group-aria-checked:translate-x-5 h-4 w-4 mt-1 bg-white rounded-full"
9725
+ className: "'will-change-transform group-aria-checked:translate-x-5 mt-1 h-4 w-4 translate-x-1 rounded-full bg-white transition-transform"
9731
9726
  }));
9732
9727
 
9733
9728
  if (label) {
9734
9729
  var labelClassName = cn('flex items-center cursor-pointer', {
9735
9730
  'cursor-not-allowed text-grey-dark': props.disabled
9736
9731
  });
9737
- return React.createElement("label", {
9732
+ element = React.createElement("label", {
9738
9733
  className: labelClassName
9739
9734
  }, element, label);
9740
9735
  }