@economic/taco 0.0.26-alpha.9 → 0.0.28-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Combobox/useCombobox.d.ts +1 -1
- package/dist/components/Datepicker/Datepicker.d.ts +1 -1
- package/dist/components/Field/Field.d.ts +19 -11
- package/dist/components/Menu/Menu.d.ts +3 -0
- package/dist/components/SearchInput/SearchInput.d.ts +1 -1
- package/dist/esm/components/Button/Button.js +3 -4
- package/dist/esm/components/Button/Button.js.map +1 -1
- package/dist/esm/components/Button/util.js +3 -2
- package/dist/esm/components/Button/util.js.map +1 -1
- package/dist/esm/components/Checkbox/Checkbox.js +5 -5
- package/dist/esm/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/esm/components/Combobox/Combobox.js +10 -5
- package/dist/esm/components/Combobox/Combobox.js.map +1 -1
- package/dist/esm/components/Combobox/useCombobox.js +1 -1
- package/dist/esm/components/Combobox/useCombobox.js.map +1 -1
- package/dist/esm/components/Field/Field.js +16 -38
- package/dist/esm/components/Field/Field.js.map +1 -1
- package/dist/esm/components/Hanger/Hanger.js +14 -3
- package/dist/esm/components/Hanger/Hanger.js.map +1 -1
- package/dist/esm/components/IconButton/IconButton.js +3 -4
- package/dist/esm/components/IconButton/IconButton.js.map +1 -1
- package/dist/esm/components/Input/Input.js +2 -3
- package/dist/esm/components/Input/Input.js.map +1 -1
- package/dist/esm/components/Input/util.js +1 -1
- package/dist/esm/components/Input/util.js.map +1 -1
- package/dist/esm/components/Listbox/Listbox.js.map +1 -1
- package/dist/esm/components/Listbox/ScrollableList.js +11 -0
- package/dist/esm/components/Listbox/ScrollableList.js.map +1 -1
- package/dist/esm/components/Menu/Menu.js +4 -3
- package/dist/esm/components/Menu/Menu.js.map +1 -1
- package/dist/esm/components/RadioGroup/RadioGroup.js +2 -2
- package/dist/esm/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/esm/components/SearchInput/SearchInput.js +1 -1
- package/dist/esm/components/SearchInput/SearchInput.js.map +1 -1
- package/dist/esm/components/Select/Select.js +1 -1
- package/dist/esm/components/Select/Select.js.map +1 -1
- package/dist/esm/components/Select/useSelect.js +10 -4
- package/dist/esm/components/Select/useSelect.js.map +1 -1
- package/dist/esm/components/Switch/Switch.js +2 -2
- package/dist/esm/components/Switch/Switch.js.map +1 -1
- package/dist/esm/components/Table/util/renderColumn.js +1 -1
- package/dist/esm/components/Table/util/renderColumn.js.map +1 -1
- package/dist/esm/components/Textarea/Textarea.js.map +1 -1
- package/dist/esm/index.css +2 -1
- package/dist/index.css +2 -1
- package/dist/taco.cjs.development.js +88 -77
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/dist/utils/tailwind.d.ts +1 -0
- package/package.json +17 -17
- package/types.json +418 -440
@@ -37,7 +37,8 @@ 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);
|
40
|
+
var internalInputRef = useRef(null);
|
41
|
+
var buttonId = id + "-button"; // support 'escape' resetting to the value that was set when the listbox opened
|
41
42
|
|
42
43
|
var _React$useState2 = useState(value),
|
43
44
|
lastValue = _React$useState2[0],
|
@@ -52,7 +53,12 @@ var useSelect = function useSelect(_ref, ref) {
|
|
52
53
|
}
|
53
54
|
}, [defaultValue]);
|
54
55
|
useEffect(function () {
|
55
|
-
|
56
|
+
// If emptyValue is defined, then set emptyValue
|
57
|
+
if (emptyValue !== undefined && value === emptyValue) {
|
58
|
+
setInputValueByRef(internalInputRef.current, value);
|
59
|
+
} else if (value !== undefined && data.some(function (option) {
|
60
|
+
return option.value === value;
|
61
|
+
})) {
|
56
62
|
setInputValueByRef(internalInputRef.current, value);
|
57
63
|
} else if (data.length && defaultValue === undefined) {
|
58
64
|
setInputValueByRef(internalInputRef.current, data[0].value);
|
@@ -164,9 +170,9 @@ var useSelect = function useSelect(_ref, ref) {
|
|
164
170
|
var button = {
|
165
171
|
'aria-haspopup': 'listbox',
|
166
172
|
'aria-label': ariaLabel ? ariaLabel + " " + text : undefined,
|
167
|
-
'aria-labelledby': ariaLabelledBy ? ariaLabelledBy + " " +
|
173
|
+
'aria-labelledby': ariaLabelledBy ? ariaLabelledBy + " " + buttonId : undefined,
|
168
174
|
disabled: disabled,
|
169
|
-
id:
|
175
|
+
id: buttonId,
|
170
176
|
onKeyDown: !disabled && !readOnly ? handleButtonKeyDown : undefined,
|
171
177
|
type: 'button'
|
172
178
|
};
|
@@ -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 // 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,CAAChB,QAAD,CAApD,CAAX;AACA,MAAMiB,gBAAgB,GAAGJ,MAAA,CAAa,IAAb,CAAzB;;AAEA,yBAAkCA,QAAA,CAAoDR,KAApD,CAAlC;AAAA,MAAOa,SAAP;AAAA,MAAkBC,YAAlB;;AAEAN,EAAAA,SAAA,CAAgB;AACZM,IAAAA,YAAY,CAACd,KAAD,CAAZ;AACH,GAFD,EAEG,CAACS,IAAD,CAFH;AAIAD,EAAAA,SAAA,CAAgB;AACZ,QAAIhB,YAAY,KAAKuB,SAAjB,IAA8Bf,KAAK,KAAKe,SAA5C,EAAuD;AACnDC,MAAAA,kBAAkB,CAACJ,gBAAgB,CAACK,OAAlB,EAA2BzB,YAA3B,CAAlB;AACH;AACJ,G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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;;;;"}
|
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 emptyValue is defined, then set emptyValue\n if (emptyValue !== undefined && value === emptyValue) {\n setInputValueByRef(internalInputRef.current, value);\n } else if (value !== undefined && data.some(option => option.value === value)) {\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","some","option","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,CAAChB,QAAD,CAApD,CAAX;AACA,MAAMiB,gBAAgB,GAAGJ,MAAA,CAAa,IAAb,CAAzB;AACA,MAAMK,QAAQ,GAAMjB,EAAN,YAAd;;AAEA,yBAAkCY,QAAA,CAAoDR,KAApD,CAAlC;AAAA,MAAOc,SAAP;AAAA,MAAkBC,YAAlB;;AAEAP,EAAAA,SAAA,CAAgB;AACZO,IAAAA,YAAY,CAACf,KAAD,CAAZ;AACH,GAFD,EAEG,CAACS,IAAD,CAFH;AAIAD,EAAAA,SAAA,CAAgB;AACZ,QAAIhB,YAAY,KAAKwB,SAAjB,IAA8BhB,KAAK,KAAKgB,SAA5C,EAAuD;AACnDC,MAAAA,kBAAkB,CAACL,gBAAgB,CAACM,OAAlB,EAA2B1B,YAA3B,CAAlB;AACH;AACJ,GAJD,EAIG,CAACA,YAAD,CAJH;AAMAgB,EAAAA,SAAA,CAAgB;AACZ;AACA,Q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AEwB,gBAFK;AAGVZ,IAAAA,KAAK,EAAEA,KAAF,aAAEA,KAAF,cAAEA,KAAF,GAAW;AAHN,GAAd;AAMA,SAAO;AACH0D,IAAAA,MAAM,EAANA,MADG;AAEHE,IAAAA,OAAO,EAAPA,OAFG;AAGHE,IAAAA,KAAK,EAALA,KAHG;AAIHC,IAAAA,OAAO,EAAE;AACLtD,MAAAA,IAAI,EAAJA,IADK;AAELuD,MAAAA,YAAY,EAAEtD;AAFT,KAJN;AAQHoB,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 group-aria-checked:translate-x-5
|
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"
|
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
|
-
|
29
|
+
return 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
|
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;;;;"}
|
@@ -14,7 +14,7 @@ var Column = function Column(_ref) {
|
|
14
14
|
'cursor-pointer': !cell.disableSorting,
|
15
15
|
'justify-start text-left': cell.align === 'left',
|
16
16
|
'justify-end text-right': cell.align === 'right',
|
17
|
-
'justify-center text-center': !cell.align
|
17
|
+
'justify-center text-center': cell.align === 'center' || !cell.align
|
18
18
|
}),
|
19
19
|
style: _extends({}, cell.style, {
|
20
20
|
flex: cell.flex
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"renderColumn.js","sources":["../../../../../src/components/Table/util/renderColumn.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { Icon } from '../../Icon/Icon';\n\nexport const Column = ({ cell }: any): any => {\n const props = {\n ...cell.getHeaderProps(),\n ...(cell.getSortByToggleProps && cell.getSortByToggleProps({ title: undefined })),\n className: cn('yt-table__cell flex flex-1 truncate p-2 align-middle text-grey-darkest hover:text-black', cell.className, {\n 'yt-table__cell__group': !!cell.columns,\n 'cursor-pointer': !cell.disableSorting,\n 'justify-start text-left': cell.align === 'left',\n 'justify-end text-right': cell.align === 'right',\n 'justify-center text-center': !cell.align,\n }),\n style: { ...cell.style, flex: cell.flex },\n };\n\n if (cell.isSorted) {\n props['aria-sort'] = cell.isSortedDesc ? 'descending' : 'ascending';\n }\n\n return (\n <div {...props} key={cell.id} data-taco=\"table-column\">\n <span className=\"truncate\">{cell.render('Header')}</span>\n {cell.isSorted ? <Icon name={cell.isSortedDesc ? 'chevron-down-solid' : 'chevron-up-solid'} /> : null}\n </div>\n );\n};\n"],"names":["Column","cell","props","getHeaderProps","getSortByToggleProps","title","undefined","className","cn","columns","disableSorting","align","style","flex","isSorted","isSortedDesc","React","key","id","render","Icon","name"],"mappings":";;;;;IAIaA,MAAM,GAAG,SAATA,MAAS;MAAGC,YAAAA;;AACrB,MAAMC,KAAK,gBACJD,IAAI,CAACE,cAAL,EADI,EAEHF,IAAI,CAACG,oBAAL,IAA6BH,IAAI,CAACG,oBAAL,CAA0B;AAAEC,IAAAA,KAAK,EAAEC;AAAT,GAA1B,CAF1B;AAGPC,IAAAA,SAAS,EAAEC,EAAE,CAAC,yFAAD,EAA4FP,IAAI,CAACM,SAAjG,EAA4G;AACrH,+BAAyB,CAAC,CAACN,IAAI,CAACQ,OADqF;AAErH,wBAAkB,CAACR,IAAI,CAACS,cAF6F;AAGrH,iCAA2BT,IAAI,CAACU,KAAL,KAAe,MAH2E;AAIrH,gCAA0BV,IAAI,CAACU,KAAL,KAAe,OAJ4E;AAKrH,
|
1
|
+
{"version":3,"file":"renderColumn.js","sources":["../../../../../src/components/Table/util/renderColumn.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { Icon } from '../../Icon/Icon';\n\nexport const Column = ({ cell }: any): any => {\n const props = {\n ...cell.getHeaderProps(),\n ...(cell.getSortByToggleProps && cell.getSortByToggleProps({ title: undefined })),\n className: cn('yt-table__cell flex flex-1 truncate p-2 align-middle text-grey-darkest hover:text-black', cell.className, {\n 'yt-table__cell__group': !!cell.columns,\n 'cursor-pointer': !cell.disableSorting,\n 'justify-start text-left': cell.align === 'left',\n 'justify-end text-right': cell.align === 'right',\n 'justify-center text-center': cell.align === 'center' || !cell.align,\n }),\n style: { ...cell.style, flex: cell.flex },\n };\n\n if (cell.isSorted) {\n props['aria-sort'] = cell.isSortedDesc ? 'descending' : 'ascending';\n }\n\n return (\n <div {...props} key={cell.id} data-taco=\"table-column\">\n <span className=\"truncate\">{cell.render('Header')}</span>\n {cell.isSorted ? <Icon name={cell.isSortedDesc ? 'chevron-down-solid' : 'chevron-up-solid'} /> : null}\n </div>\n );\n};\n"],"names":["Column","cell","props","getHeaderProps","getSortByToggleProps","title","undefined","className","cn","columns","disableSorting","align","style","flex","isSorted","isSortedDesc","React","key","id","render","Icon","name"],"mappings":";;;;;IAIaA,MAAM,GAAG,SAATA,MAAS;MAAGC,YAAAA;;AACrB,MAAMC,KAAK,gBACJD,IAAI,CAACE,cAAL,EADI,EAEHF,IAAI,CAACG,oBAAL,IAA6BH,IAAI,CAACG,oBAAL,CAA0B;AAAEC,IAAAA,KAAK,EAAEC;AAAT,GAA1B,CAF1B;AAGPC,IAAAA,SAAS,EAAEC,EAAE,CAAC,yFAAD,EAA4FP,IAAI,CAACM,SAAjG,EAA4G;AACrH,+BAAyB,CAAC,CAACN,IAAI,CAACQ,OADqF;AAErH,wBAAkB,CAACR,IAAI,CAACS,cAF6F;AAGrH,iCAA2BT,IAAI,CAACU,KAAL,KAAe,MAH2E;AAIrH,gCAA0BV,IAAI,CAACU,KAAL,KAAe,OAJ4E;AAKrH,oCAA8BV,IAAI,CAACU,KAAL,KAAe,QAAf,IAA2B,CAACV,IAAI,CAACU;AALsD,KAA5G,CAHN;AAUPC,IAAAA,KAAK,eAAOX,IAAI,CAACW,KAAZ;AAAmBC,MAAAA,IAAI,EAAEZ,IAAI,CAACY;AAA9B;AAVE,IAAX;;AAaA,MAAIZ,IAAI,CAACa,QAAT,EAAmB;AACfZ,IAAAA,KAAK,CAAC,WAAD,CAAL,GAAqBD,IAAI,CAACc,YAAL,GAAoB,YAApB,GAAmC,WAAxD;AACH;;AAED,SACIC,4BAAA,MAAA,oBAASd;AAAOe,IAAAA,GAAG,EAAEhB,IAAI,CAACiB;iBAAc;IAAxC,EACIF,4BAAA,OAAA;AAAMT,IAAAA,SAAS,EAAC;GAAhB,EAA4BN,IAAI,CAACkB,MAAL,CAAY,QAAZ,CAA5B,CADJ,EAEKlB,IAAI,CAACa,QAAL,GAAgBE,4BAAA,CAACI,IAAD;AAAMC,IAAAA,IAAI,EAAEpB,IAAI,CAACc,YAAL,GAAoB,oBAApB,GAA2C;GAAvD,CAAhB,GAAgG,IAFrG,CADJ;AAMH;;;;"}
|
@@ -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 { 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":";;;;;;
|
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 /* Whether the input is in an invalid state */\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":";;;;;;IAaaA,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;;;;"}
|
package/dist/esm/index.css
CHANGED
@@ -136,7 +136,8 @@
|
|
136
136
|
-webkit-appearance: none;
|
137
137
|
}
|
138
138
|
|
139
|
-
[data-radix-portal][aria-hidden] [data-taco='menu']
|
139
|
+
[data-radix-portal][aria-hidden] [data-taco='menu'],
|
140
|
+
[data-radix-portal][aria-hidden] [data-taco='hanger'] {
|
140
141
|
display: none;
|
141
142
|
opacity: 0;
|
142
143
|
}
|
package/dist/index.css
CHANGED
@@ -136,7 +136,8 @@
|
|
136
136
|
-webkit-appearance: none;
|
137
137
|
}
|
138
138
|
|
139
|
-
[data-radix-portal][aria-hidden] [data-taco='menu']
|
139
|
+
[data-radix-portal][aria-hidden] [data-taco='menu'],
|
140
|
+
[data-radix-portal][aria-hidden] [data-taco='hanger'] {
|
140
141
|
display: none;
|
141
142
|
opacity: 0;
|
142
143
|
}
|
@@ -3387,7 +3387,7 @@ var Tooltip = /*#__PURE__*/React.forwardRef(function Tooltip(props, ref) {
|
|
3387
3387
|
|
3388
3388
|
var _excluded$5 = ["dialog", "hanger", "menu", "popover", "tooltip"];
|
3389
3389
|
var getButtonClasses = function getButtonClasses() {
|
3390
|
-
return 'min-h-[theme(spacing.8)] min-w-[theme(spacing.8)] h-max leading-6 inline-flex items-center justify-center
|
3390
|
+
return 'min-h-[theme(spacing.8)] min-w-[theme(spacing.8)] h-max leading-6 inline-flex items-center justify-center border';
|
3391
3391
|
};
|
3392
3392
|
var getAppearanceClasses = function getAppearanceClasses(value, icon) {
|
3393
3393
|
if (icon === void 0) {
|
@@ -3436,7 +3436,8 @@ var createButton = function createButton(props, className, ref) {
|
|
3436
3436
|
});
|
3437
3437
|
} else if (typeof menu === 'function') {
|
3438
3438
|
button = menu({
|
3439
|
-
trigger: button
|
3439
|
+
trigger: button,
|
3440
|
+
appearance: otherProps.appearance
|
3440
3441
|
});
|
3441
3442
|
} else if (typeof popover === 'function') {
|
3442
3443
|
button = popover({
|
@@ -3459,15 +3460,14 @@ var createButton = function createButton(props, className, ref) {
|
|
3459
3460
|
return button;
|
3460
3461
|
};
|
3461
3462
|
|
3462
|
-
var _excluded$6 = ["
|
3463
|
+
var _excluded$6 = ["icon", "rounded"];
|
3463
3464
|
var IconButton = /*#__PURE__*/React.forwardRef(function IconButton(props, ref) {
|
3464
|
-
var
|
3465
|
-
icon = props.icon,
|
3465
|
+
var icon = props.icon,
|
3466
3466
|
_props$rounded = props.rounded,
|
3467
3467
|
rounded = _props$rounded === void 0 ? false : _props$rounded,
|
3468
3468
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded$6);
|
3469
3469
|
|
3470
|
-
var className = cn('w-8', getButtonClasses(), getAppearanceClasses(appearance, true), {
|
3470
|
+
var className = cn('w-8', getButtonClasses(), getAppearanceClasses(otherProps.appearance, true), {
|
3471
3471
|
'rounded-full': rounded,
|
3472
3472
|
rounded: !rounded,
|
3473
3473
|
'cursor-not-allowed opacity-50': props.disabled,
|
@@ -3504,13 +3504,12 @@ var Banner = /*#__PURE__*/React.forwardRef(function Banner(props, ref) {
|
|
3504
3504
|
}) : null);
|
3505
3505
|
});
|
3506
3506
|
|
3507
|
-
var _excluded$7 = ["
|
3507
|
+
var _excluded$7 = ["fluid"];
|
3508
3508
|
var Button$1 = /*#__PURE__*/React.forwardRef(function Button(props, ref) {
|
3509
|
-
var
|
3510
|
-
fluid = props.fluid,
|
3509
|
+
var fluid = props.fluid,
|
3511
3510
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded$7);
|
3512
3511
|
|
3513
|
-
var className = cn(getButtonClasses(), getAppearanceClasses(appearance), 'rounded px-3', {
|
3512
|
+
var className = cn(getButtonClasses(), getAppearanceClasses(otherProps.appearance), 'rounded px-3', {
|
3514
3513
|
'cursor-not-allowed opacity-50': props.disabled,
|
3515
3514
|
'focus:yt-focus active:focus:yt-focus': !props.disabled,
|
3516
3515
|
'w-full': fluid
|
@@ -4187,13 +4186,13 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(props, ref) {
|
|
4187
4186
|
onChange = props.onChange,
|
4188
4187
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded$c);
|
4189
4188
|
|
4190
|
-
var className = cn('h-5 w-5 border rounded text-sm', {
|
4189
|
+
var className = cn('bg-white h-5 w-5 border rounded text-sm flex-shrink-0 self-start mt-[0.1rem]', {
|
4191
4190
|
'mr-2': !!label,
|
4192
4191
|
'border-grey-dark text-blue focus:border-blue focus:yt-focus': !props.disabled && !invalid,
|
4193
4192
|
'border-grey text-blue-light cursor-not-allowed': props.disabled,
|
4194
4193
|
'bg-[rgba(255,255,0,0.2)] disabled:bg-[rgba(255,255,0,0.075)]': highlighted,
|
4195
4194
|
'border-red text-red focus:border-red focus:yt-focus-red': invalid && !props.disabled
|
4196
|
-
}
|
4195
|
+
});
|
4197
4196
|
var handleChange;
|
4198
4197
|
|
4199
4198
|
if (onChange) {
|
@@ -4203,9 +4202,9 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(props, ref) {
|
|
4203
4202
|
}
|
4204
4203
|
|
4205
4204
|
var element = React.createElement(CheckboxPrimitive.Root, Object.assign({}, otherProps, {
|
4205
|
+
"data-taco": "checkbox",
|
4206
4206
|
checked: indeterminate ? 'indeterminate' : checked,
|
4207
4207
|
className: className,
|
4208
|
-
"data-taco": "checkbox",
|
4209
4208
|
onCheckedChange: handleChange,
|
4210
4209
|
ref: ref
|
4211
4210
|
}), React.createElement(CheckboxPrimitive.Indicator, {
|
@@ -4218,8 +4217,8 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function Checkbox(props, ref) {
|
|
4218
4217
|
if (label) {
|
4219
4218
|
var labelClassName = cn('flex items-center cursor-pointer', {
|
4220
4219
|
'cursor-not-allowed text-grey-dark': props.disabled
|
4221
|
-
});
|
4222
|
-
|
4220
|
+
}, props.className);
|
4221
|
+
return React.createElement("label", {
|
4223
4222
|
className: labelClassName
|
4224
4223
|
}, element, label);
|
4225
4224
|
}
|
@@ -4242,7 +4241,7 @@ var useProxiedRef = function useProxiedRef(ref) {
|
|
4242
4241
|
};
|
4243
4242
|
|
4244
4243
|
var getInputClasses = function getInputClasses(props) {
|
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
|
4244
|
+
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 flex items-center', {
|
4246
4245
|
'cursor-not-allowed text-black bg-grey': props.readOnly,
|
4247
4246
|
'border-grey text-opacity-25 cursor-not-allowed': props.disabled,
|
4248
4247
|
'bg-[rgba(255,255,0,0.075)]': props.highlighted && props.disabled,
|
@@ -4263,8 +4262,7 @@ var _excluded$d = ["button", "icon", "highlighted", "invalid", "onKeyDown", "aut
|
|
4263
4262
|
var Input = /*#__PURE__*/React.forwardRef(function Input(props, ref) {
|
4264
4263
|
var button = props.button,
|
4265
4264
|
icon = props.icon,
|
4266
|
-
|
4267
|
-
invalid = _props$invalid === void 0 ? false : _props$invalid,
|
4265
|
+
invalid = props.invalid,
|
4268
4266
|
onKeyDown = props.onKeyDown,
|
4269
4267
|
autoFocus = props.autoFocus,
|
4270
4268
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded$d);
|
@@ -4327,7 +4325,7 @@ var Input = /*#__PURE__*/React.forwardRef(function Input(props, ref) {
|
|
4327
4325
|
}
|
4328
4326
|
|
4329
4327
|
var containerClassName = cn('bg-white inline-flex relative rounded w-full', otherProps.className);
|
4330
|
-
|
4328
|
+
return React.createElement("div", {
|
4331
4329
|
className: containerClassName,
|
4332
4330
|
"data-taco": "input-container"
|
4333
4331
|
}, input, extra);
|
@@ -4478,6 +4476,17 @@ var ScrollableList = /*#__PURE__*/React.forwardRef(function ScrollableList(props
|
|
4478
4476
|
var _useListScrollTo = useListScrollTo(listRef, itemRefs),
|
4479
4477
|
scrollTo = _useListScrollTo.scrollTo;
|
4480
4478
|
|
4479
|
+
React.useEffect(function () {
|
4480
|
+
var _itemRefs$currentInde;
|
4481
|
+
|
4482
|
+
if (currentIndex && (_itemRefs$currentInde = itemRefs[currentIndex]) !== null && _itemRefs$currentInde !== void 0 && _itemRefs$currentInde.current) {
|
4483
|
+
var _itemRefs$currentInde2;
|
4484
|
+
|
4485
|
+
(_itemRefs$currentInde2 = itemRefs[currentIndex].current) === null || _itemRefs$currentInde2 === void 0 ? void 0 : _itemRefs$currentInde2.scrollIntoView({
|
4486
|
+
block: 'center'
|
4487
|
+
});
|
4488
|
+
}
|
4489
|
+
}, []);
|
4481
4490
|
React.useEffect(function () {
|
4482
4491
|
scrollTo(currentIndex);
|
4483
4492
|
}, [currentIndex]);
|
@@ -4827,7 +4836,7 @@ var filterData = function filterData(data, value) {
|
|
4827
4836
|
});
|
4828
4837
|
};
|
4829
4838
|
|
4830
|
-
var _excluded$g = ["aria-label", "aria-labelledby", "data", "defaultValue", "disabled", "inline", "loading", "onChange", "onClick", "onKeyDown", "onSearch", "readOnly", "value"];
|
4839
|
+
var _excluded$g = ["aria-label", "aria-labelledby", "data", "defaultValue", "disabled", "id", "inline", "loading", "onChange", "onClick", "onKeyDown", "onSearch", "readOnly", "value"];
|
4831
4840
|
var debouncer = /*#__PURE__*/debounce(function (f) {
|
4832
4841
|
return f();
|
4833
4842
|
}, 200);
|
@@ -5205,17 +5214,22 @@ var Combobox = /*#__PURE__*/React.forwardRef(function Combobox(props, ref) {
|
|
5205
5214
|
className: "!border-l-0 focus:!border-none focus:!shadow-none active:!border-none",
|
5206
5215
|
icon: popover.open ? 'chevron-up' : 'chevron-down',
|
5207
5216
|
onClick: function onClick() {
|
5208
|
-
|
5217
|
+
var _input$ref$current;
|
5218
|
+
|
5219
|
+
popover.onOpenChange(true);
|
5220
|
+
(_input$ref$current = input.ref.current) === null || _input$ref$current === void 0 ? void 0 : _input$ref$current.focus();
|
5209
5221
|
},
|
5210
5222
|
tabIndex: -1
|
5211
5223
|
}) : dialog ? React.createElement(IconButton, {
|
5212
5224
|
icon: "list-search",
|
5213
5225
|
disabled: props.readOnly || props.disabled,
|
5214
5226
|
dialog: dialog,
|
5215
|
-
onFocus: function onFocus() {
|
5216
|
-
var _input$ref$
|
5227
|
+
onFocus: function onFocus(event) {
|
5228
|
+
var _input$ref$current2;
|
5217
5229
|
|
5218
|
-
|
5230
|
+
// Prevents the default focus behaviour of showing the tooltip, on parent tooltip element
|
5231
|
+
event.preventDefault();
|
5232
|
+
(_input$ref$current2 = input.ref.current) === null || _input$ref$current2 === void 0 ? void 0 : _input$ref$current2.focus();
|
5219
5233
|
},
|
5220
5234
|
ref: button.ref,
|
5221
5235
|
tabIndex: -1,
|
@@ -5228,7 +5242,7 @@ var Combobox = /*#__PURE__*/React.forwardRef(function Combobox(props, ref) {
|
|
5228
5242
|
},
|
5229
5243
|
sideOffset: 4
|
5230
5244
|
}, React.createElement(ScrollableList, Object.assign({}, list, {
|
5231
|
-
className: cn('border-blue max-h-[calc(12rem+2px)] w-auto max-w-[theme(spacing.96)]'),
|
5245
|
+
className: cn('!border-blue max-h-[calc(12rem+2px)] w-auto max-w-[theme(spacing.96)]'),
|
5232
5246
|
style: {
|
5233
5247
|
minWidth: selectDimensions === null || selectDimensions === void 0 ? void 0 : selectDimensions.width
|
5234
5248
|
},
|
@@ -5940,51 +5954,30 @@ Dialog.Extra = Extra;
|
|
5940
5954
|
Dialog.Drawer = Drawer;
|
5941
5955
|
Dialog.Close = Close$2;
|
5942
5956
|
|
5943
|
-
var _excluded$n = ["
|
5957
|
+
var _excluded$n = ["disabled", "children", "invalid", "message"];
|
5944
5958
|
var Field = /*#__PURE__*/React.forwardRef(function Field(props, ref) {
|
5945
|
-
var
|
5946
|
-
|
5947
|
-
|
5948
|
-
|
5949
|
-
invalid = props.invalid,
|
5950
|
-
label = props.label,
|
5959
|
+
var disabled = props.disabled,
|
5960
|
+
children = props.children,
|
5961
|
+
_props$invalid = props.invalid,
|
5962
|
+
invalid = _props$invalid === void 0 ? false : _props$invalid,
|
5951
5963
|
message = props.message,
|
5952
|
-
required = props.required,
|
5953
5964
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded$n);
|
5954
5965
|
|
5955
|
-
var
|
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
|
5961
|
-
}, props.className);
|
5962
|
-
var labelClassName = cn('font-bold text-xs leading-4 h-4 truncate mb-1', {
|
5966
|
+
var className = cn('flex flex-col font-bold text-xs leading-loose pb-4 min-h-[theme(spacing.18)]', {
|
5963
5967
|
'text-grey-dark': disabled
|
5964
|
-
});
|
5965
|
-
var messageClassName = cn('text-xs leading-normal truncate
|
5966
|
-
'text-grey-darkest': !
|
5967
|
-
'text-red':
|
5968
|
+
}, props.className);
|
5969
|
+
var messageClassName = cn('h-4 text-xs text-left leading-normal font-normal truncate -mb-4', {
|
5970
|
+
'text-grey-darkest': !invalid,
|
5971
|
+
'text-red': invalid,
|
5968
5972
|
'opacity-50': disabled
|
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, {
|
5973
|
+
}, props.className);
|
5974
|
+
return React.createElement("label", Object.assign({}, otherProps, {
|
5976
5975
|
className: className,
|
5977
|
-
"data-taco": "
|
5976
|
+
"data-taco": "label",
|
5978
5977
|
ref: ref
|
5979
|
-
}),
|
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", {
|
5978
|
+
}), children, message && React.createElement("span", {
|
5986
5979
|
className: messageClassName,
|
5987
|
-
role:
|
5980
|
+
role: invalid ? 'alert' : undefined
|
5988
5981
|
}, message));
|
5989
5982
|
});
|
5990
5983
|
|
@@ -6082,11 +6075,22 @@ var Hanger = /*#__PURE__*/React.forwardRef(function Hanger(props, ref) {
|
|
6082
6075
|
props: otherProps,
|
6083
6076
|
ref: ref
|
6084
6077
|
};
|
6085
|
-
}, [otherProps]);
|
6078
|
+
}, [otherProps]); // we do this to ensure hangers are mounted after their containers, e.g. if the container is another portal
|
6079
|
+
|
6080
|
+
var _React$useState = React.useState(false),
|
6081
|
+
open = _React$useState[0],
|
6082
|
+
setOpen = _React$useState[1];
|
6083
|
+
|
6084
|
+
React.useEffect(function () {
|
6085
|
+
if (defaultOpen) {
|
6086
|
+
setOpen(defaultOpen);
|
6087
|
+
}
|
6088
|
+
}, []);
|
6086
6089
|
return React.createElement(HangerContext.Provider, {
|
6087
6090
|
value: context
|
6088
6091
|
}, React.createElement(PopoverPrimitive.Root, {
|
6089
|
-
|
6092
|
+
key: String(open),
|
6093
|
+
defaultOpen: open
|
6090
6094
|
}, anchor && React.createElement(Anchor, null, anchor), children));
|
6091
6095
|
});
|
6092
6096
|
Hanger.Anchor = Anchor;
|
@@ -6119,7 +6123,7 @@ var SearchInput = /*#__PURE__*/React.forwardRef(function SearchInput(_ref, ref)
|
|
6119
6123
|
}, props, {
|
6120
6124
|
button: React.createElement(IconButton, {
|
6121
6125
|
icon: "search",
|
6122
|
-
className: "!border-transparent !bg-transparent",
|
6126
|
+
className: "!border-transparent !bg-transparent focus:!border-transparent peer-focus:!border-transparent peer-focus:peer-active:!border-transparent",
|
6123
6127
|
disabled: props.disabled,
|
6124
6128
|
onClick: handleClick
|
6125
6129
|
}),
|
@@ -6836,14 +6840,14 @@ var RadioGroupItem = /*#__PURE__*/React.forwardRef(function RadioGroupItem(props
|
|
6836
6840
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded$z);
|
6837
6841
|
|
6838
6842
|
var disabled = context.disabled || props.disabled;
|
6839
|
-
var className = cn('flex items-center justify-center h-4 w-4 mr-2 rounded-full bg-white border-2 ', {
|
6843
|
+
var className = cn('flex flex-shrink-0 self-start items-center justify-center h-4 w-4 mr-2 mt-[0.2rem] rounded-full bg-white border-2 ', {
|
6840
6844
|
'border-grey-dark focus:border-blue focus:yt-focus aria-checked:bg-blue aria-checked:border-blue': !disabled && !context.invalid,
|
6841
6845
|
'border-grey cursor-not-allowed aria-checked:bg-grey-dark aria-checked:border-grey-dark': disabled,
|
6842
6846
|
'border-red text-red focus:border-red focus:yt-focus-red aria-checked:bg-red aria-checked:border-red': context.invalid && !disabled
|
6843
6847
|
});
|
6844
6848
|
var labelClassName = cn('flex items-center cursor-pointer', {
|
6845
6849
|
'cursor-not-allowed text-grey-dark': disabled
|
6846
|
-
});
|
6850
|
+
}, props.className);
|
6847
6851
|
return React.createElement("label", {
|
6848
6852
|
className: labelClassName
|
6849
6853
|
}, React.createElement(RadioGroupPrimitive.Item, Object.assign({}, otherProps, {
|
@@ -7025,9 +7029,10 @@ var Header = function Header(props) {
|
|
7025
7029
|
}));
|
7026
7030
|
};
|
7027
7031
|
|
7028
|
-
var _excluded$B = ["children", "trigger"];
|
7032
|
+
var _excluded$B = ["appearance", "children", "trigger"];
|
7029
7033
|
var Menu = function Menu(externalProps) {
|
7030
|
-
var
|
7034
|
+
var externalAppearance = externalProps.appearance,
|
7035
|
+
children = externalProps.children,
|
7031
7036
|
trigger = externalProps.trigger,
|
7032
7037
|
props = _objectWithoutPropertiesLoose(externalProps, _excluded$B);
|
7033
7038
|
|
@@ -7035,7 +7040,7 @@ var Menu = function Menu(externalProps) {
|
|
7035
7040
|
open = _React$useState[0],
|
7036
7041
|
setOpen = _React$useState[1];
|
7037
7042
|
|
7038
|
-
var _React$useState2 = React.useState('default'),
|
7043
|
+
var _React$useState2 = React.useState(externalAppearance !== null && externalAppearance !== void 0 ? externalAppearance : 'default'),
|
7039
7044
|
appearance = _React$useState2[0],
|
7040
7045
|
_setAppearance = _React$useState2[1];
|
7041
7046
|
|
@@ -7400,7 +7405,8 @@ var useSelect = function useSelect(_ref, ref) {
|
|
7400
7405
|
var id = React.useMemo(function () {
|
7401
7406
|
return nativeId || "select_" + uuid.v4();
|
7402
7407
|
}, [nativeId]);
|
7403
|
-
var internalInputRef = React.useRef(null);
|
7408
|
+
var internalInputRef = React.useRef(null);
|
7409
|
+
var buttonId = id + "-button"; // support 'escape' resetting to the value that was set when the listbox opened
|
7404
7410
|
|
7405
7411
|
var _React$useState2 = React.useState(value),
|
7406
7412
|
lastValue = _React$useState2[0],
|
@@ -7415,7 +7421,12 @@ var useSelect = function useSelect(_ref, ref) {
|
|
7415
7421
|
}
|
7416
7422
|
}, [defaultValue]);
|
7417
7423
|
React.useEffect(function () {
|
7418
|
-
|
7424
|
+
// If emptyValue is defined, then set emptyValue
|
7425
|
+
if (emptyValue !== undefined && value === emptyValue) {
|
7426
|
+
setInputValueByRef$1(internalInputRef.current, value);
|
7427
|
+
} else if (value !== undefined && data.some(function (option) {
|
7428
|
+
return option.value === value;
|
7429
|
+
})) {
|
7419
7430
|
setInputValueByRef$1(internalInputRef.current, value);
|
7420
7431
|
} else if (data.length && defaultValue === undefined) {
|
7421
7432
|
setInputValueByRef$1(internalInputRef.current, data[0].value);
|
@@ -7527,9 +7538,9 @@ var useSelect = function useSelect(_ref, ref) {
|
|
7527
7538
|
var button = {
|
7528
7539
|
'aria-haspopup': 'listbox',
|
7529
7540
|
'aria-label': ariaLabel ? ariaLabel + " " + text : undefined,
|
7530
|
-
'aria-labelledby': ariaLabelledBy ? ariaLabelledBy + " " +
|
7541
|
+
'aria-labelledby': ariaLabelledBy ? ariaLabelledBy + " " + buttonId : undefined,
|
7531
7542
|
disabled: disabled,
|
7532
|
-
id:
|
7543
|
+
id: buttonId,
|
7533
7544
|
onKeyDown: !disabled && !readOnly ? handleButtonKeyDown : undefined,
|
7534
7545
|
type: 'button'
|
7535
7546
|
};
|
@@ -7592,7 +7603,7 @@ var BaseSelect = /*#__PURE__*/React.forwardRef(function BaseSelect(props, ref) {
|
|
7592
7603
|
var className = cn('inline-flex relative w-full', {
|
7593
7604
|
'yt-select--readonly': props.readOnly
|
7594
7605
|
}, externalClassName);
|
7595
|
-
var inputClassname = cn(getInputClasses(props), 'text-left pr-0', {
|
7606
|
+
var inputClassname = cn(getInputClasses(props), 'h-8 text-left pr-0', {
|
7596
7607
|
'border-blue': popover.open
|
7597
7608
|
});
|
7598
7609
|
React.useEffect(function () {
|
@@ -9104,7 +9115,7 @@ var Column = function Column(_ref) {
|
|
9104
9115
|
'cursor-pointer': !cell.disableSorting,
|
9105
9116
|
'justify-start text-left': cell.align === 'left',
|
9106
9117
|
'justify-end text-right': cell.align === 'right',
|
9107
|
-
'justify-center text-center': !cell.align
|
9118
|
+
'justify-center text-center': cell.align === 'center' || !cell.align
|
9108
9119
|
}),
|
9109
9120
|
style: _extends({}, cell.style, {
|
9110
9121
|
flex: cell.flex
|
@@ -9722,14 +9733,14 @@ var Switch = /*#__PURE__*/React.forwardRef(function Switch(props, ref) {
|
|
9722
9733
|
onCheckedChange: onChange,
|
9723
9734
|
ref: ref
|
9724
9735
|
}), React.createElement(PrimitiveSwitch.Thumb, {
|
9725
|
-
className: "'will-change-transform group-aria-checked:translate-x-5
|
9736
|
+
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"
|
9726
9737
|
}));
|
9727
9738
|
|
9728
9739
|
if (label) {
|
9729
9740
|
var labelClassName = cn('flex items-center cursor-pointer', {
|
9730
9741
|
'cursor-not-allowed text-grey-dark': props.disabled
|
9731
9742
|
});
|
9732
|
-
|
9743
|
+
return React.createElement("label", {
|
9733
9744
|
className: labelClassName
|
9734
9745
|
}, element, label);
|
9735
9746
|
}
|