@economic/taco 1.11.0 → 1.11.2
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/Table/util/sortTypes.d.ts +1 -1
- package/dist/esm/components/Combobox/Combobox.js +1 -0
- package/dist/esm/components/Combobox/Combobox.js.map +1 -1
- package/dist/esm/components/Select/Select.js +1 -0
- package/dist/esm/components/Select/Select.js.map +1 -1
- package/dist/esm/components/Table/hooks/useTable.js +3 -2
- package/dist/esm/components/Table/hooks/useTable.js.map +1 -1
- package/dist/esm/components/Table/util/sortTypes.js +46 -25
- package/dist/esm/components/Table/util/sortTypes.js.map +1 -1
- package/dist/esm/components/Tooltip/Tooltip.js +6 -3
- package/dist/esm/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/taco.cjs.development.js +55 -29
- 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/package.json +3 -3
@@ -1,4 +1,4 @@
|
|
1
1
|
import { SortTypes, TableRow } from '../types';
|
2
2
|
declare type SortHandler<T> = (rowA: TableRow<T>, rowB: TableRow<T>, columnId: string) => 0 | 1 | -1;
|
3
|
-
export declare const sortTypes: Record<SortTypes, SortHandler<any>>;
|
3
|
+
export declare const sortTypes: (locale: string) => Record<SortTypes, SortHandler<any>>;
|
4
4
|
export {};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Combobox.js","sources":["../../../../src/components/Combobox/Combobox.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { Input, InputProps } from '../Input/Input';\nimport { useCombobox } from './useCombobox';\nimport { ScrollableList, ScrollableListItem, ScrollableListItemValue } from '../Listbox/ScrollableList';\nimport { useBoundingClientRectListener } from '../../utils/hooks/useBoundingClientRectListener';\nimport { IconButton } from '../IconButton/IconButton';\nimport './Combobox.css';\nimport { DialogProps } from '../Dialog/Dialog';\nimport { useLocalization } from '../Provider/Provider';\n\nexport type ComboboxTexts = {\n /* Tooltip shown for the dialog button */\n tooltip: string;\n};\n\nexport type ComboboxItem = ScrollableListItem;\nexport type ComboboxValue = ScrollableListItemValue;\n\ntype ComboboxBaseProps = Omit<InputProps, 'defaultValue' | 'button' | 'onChange' | 'value'> & {\n /** Array of options in combobox */\n data?: ComboboxItem[];\n /**\n * Initial value of the input in combobox.\n * This is used when combobox is mounted, if no value is provided.\n * *Note* that combobox is a controlled component, setting this will also trigger the `onChange` event\n */\n defaultValue?: ComboboxValue;\n /** Set what value should have an empty option in combobox */\n emptyValue?: ComboboxValue;\n /** Draws attention to the combobox by changing its style and making it visually prominent */\n highlighted?: boolean;\n /** Displays loading state in listbox */\n loading?: boolean;\n /**\n * Handler called when user chooses an option from the provided suggestions.\n * Suggestions will be calculated based on the input value.\n * There are two ways to choose an option: either click on it, or navigate using keyboard and press `enter`\n */\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\n /** Handler called when the user enters a query **/\n onSearch?: (query: string) => void | Promise<void>;\n /** Value of the input in combobox */\n value?: ComboboxValue;\n};\n\ninterface InlineComboboxProps extends ComboboxBaseProps {\n dialog?: never;\n /**\n * Combobox will display its data when input is clicked/focused, even if the input is empty.\n * *Note* that default combobox will display matching data only when user starts typing in input.\n */\n inline: boolean; // Example 3 on https://www.w3.org/TR/wai-aria-practices/examples/combobox/aria1.1pattern/listbox-combo.html\n}\n\ninterface DialogComboboxProps extends ComboboxBaseProps {\n dialog: (props: Partial<DialogProps>) => JSX.Element;\n inline?: never;\n}\n\nexport type ComboboxProps = InlineComboboxProps | DialogComboboxProps;\n\nexport const Combobox = React.forwardRef(function Combobox(props: ComboboxProps, ref: React.Ref<HTMLInputElement>) {\n const { className: externalClassName, dialog, style, ...otherProps } = props;\n const { combobox, button, input, popover, list } = useCombobox(otherProps, ref);\n const internalRef = React.useRef<HTMLDivElement>(null);\n const { texts } = useLocalization();\n const selectDimensions = useBoundingClientRectListener(internalRef);\n const className = cn(\n 'inline-flex relative',\n {\n 'yt-combobox--inline': props.inline,\n },\n externalClassName\n );\n\n return (\n <span className={className} data-taco=\"combobox\" style={style}>\n <PopoverPrimitive.Root {...popover}>\n <PopoverPrimitive.Anchor asChild ref={internalRef}>\n <div {...combobox} className=\"inline w-full\" ref={ref}>\n <Input\n {...input}\n autoComplete=\"off\"\n button={\n props.inline ? (\n <IconButton\n appearance=\"discrete\"\n className=\"!border-l-0 focus:!border-none focus:!shadow-none active:!border-none\"\n icon={popover.open ? 'chevron-up' : 'chevron-down'}\n onClick={() => {\n popover.onOpenChange(true);\n input.ref.current?.focus();\n }}\n tabIndex={-1}\n />\n ) : dialog ? (\n <IconButton\n aria-label={texts.combobox.tooltip}\n icon=\"list-search\"\n disabled={props.readOnly || props.disabled}\n dialog={dialog}\n onFocus={(event: React.FocusEvent<HTMLButtonElement>) => {\n // Prevents the default focus behaviour of showing the tooltip, on parent tooltip element\n event.preventDefault();\n input.ref.current?.focus();\n }}\n ref={button.ref}\n tabIndex={-1}\n tooltip={texts.combobox.tooltip}\n />\n ) : undefined\n }\n />\n </div>\n </PopoverPrimitive.Anchor>\n <PopoverPrimitive.Content\n align=\"start\"\n onOpenAutoFocus={event => {\n event.preventDefault();\n }}\n sideOffset={4}>\n <ScrollableList\n {...list}\n className={cn('!border-blue max-h-[calc(12rem+2px)] w-auto max-w-[theme(spacing.96)]')}\n style={{ minWidth: selectDimensions?.width }}\n tabIndex={popover.open ? 0 : -1}\n />\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Root>\n </span>\n );\n});\n"],"names":["Combobox","React","props","ref","className","externalClassName","dialog","style","otherProps","combobox","button","input","popover","list","useCombobox","internalRef","texts","useLocalization","selectDimensions","useBoundingClientRectListener","cn","inline","PopoverPrimitive","asChild","Input","autoComplete","IconButton","appearance","icon","open","onClick","onOpenChange","current","focus","tabIndex","tooltip","disabled","readOnly","onFocus","event","preventDefault","undefined","align","onOpenAutoFocus","side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KARf,CADJ,GAWI5B,MAAM,gBACNL,aAAA,CAACyB,UAAD;oBACgBV,KAAK,CAACP,QAAN,CAAe0B;MAC3BP,IAAI,EAAC;MACLQ,QAAQ,EAAElC,KAAK,CAACmC,QAAN,IAAkBnC,KAAK,CAACkC;MAClC9B,MAAM,EAAEA;MACRgC,OAAO,EAAGC,KAAD;;;;QAELA,KAAK,CAACC,cAAN;QACA,uBAAA7B,KAAK,CAACR,GAAN,CAAU6B,OAAV,4EAAmBC,KAAnB;;MAEJ9B,GAAG,EAAEO,MAAM,CAACP;MACZ+B,QAAQ,EAAE,CAAC;MACXC,OAAO,EAAEnB,KAAK,CAACP,QAAN,CAAe0B;KAZ5B,CADM,GAeNM;IA9BZ,CADJ,CADJ,CADJ,eAsCIxC,aAAA,CAACqB,OAAD;IACIoB,KAAK,EAAC;
|
1
|
+
{"version":3,"file":"Combobox.js","sources":["../../../../src/components/Combobox/Combobox.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { Input, InputProps } from '../Input/Input';\nimport { useCombobox } from './useCombobox';\nimport { ScrollableList, ScrollableListItem, ScrollableListItemValue } from '../Listbox/ScrollableList';\nimport { useBoundingClientRectListener } from '../../utils/hooks/useBoundingClientRectListener';\nimport { IconButton } from '../IconButton/IconButton';\nimport './Combobox.css';\nimport { DialogProps } from '../Dialog/Dialog';\nimport { useLocalization } from '../Provider/Provider';\n\nexport type ComboboxTexts = {\n /* Tooltip shown for the dialog button */\n tooltip: string;\n};\n\nexport type ComboboxItem = ScrollableListItem;\nexport type ComboboxValue = ScrollableListItemValue;\n\ntype ComboboxBaseProps = Omit<InputProps, 'defaultValue' | 'button' | 'onChange' | 'value'> & {\n /** Array of options in combobox */\n data?: ComboboxItem[];\n /**\n * Initial value of the input in combobox.\n * This is used when combobox is mounted, if no value is provided.\n * *Note* that combobox is a controlled component, setting this will also trigger the `onChange` event\n */\n defaultValue?: ComboboxValue;\n /** Set what value should have an empty option in combobox */\n emptyValue?: ComboboxValue;\n /** Draws attention to the combobox by changing its style and making it visually prominent */\n highlighted?: boolean;\n /** Displays loading state in listbox */\n loading?: boolean;\n /**\n * Handler called when user chooses an option from the provided suggestions.\n * Suggestions will be calculated based on the input value.\n * There are two ways to choose an option: either click on it, or navigate using keyboard and press `enter`\n */\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\n /** Handler called when the user enters a query **/\n onSearch?: (query: string) => void | Promise<void>;\n /** Value of the input in combobox */\n value?: ComboboxValue;\n};\n\ninterface InlineComboboxProps extends ComboboxBaseProps {\n dialog?: never;\n /**\n * Combobox will display its data when input is clicked/focused, even if the input is empty.\n * *Note* that default combobox will display matching data only when user starts typing in input.\n */\n inline: boolean; // Example 3 on https://www.w3.org/TR/wai-aria-practices/examples/combobox/aria1.1pattern/listbox-combo.html\n}\n\ninterface DialogComboboxProps extends ComboboxBaseProps {\n dialog: (props: Partial<DialogProps>) => JSX.Element;\n inline?: never;\n}\n\nexport type ComboboxProps = InlineComboboxProps | DialogComboboxProps;\n\nexport const Combobox = React.forwardRef(function Combobox(props: ComboboxProps, ref: React.Ref<HTMLInputElement>) {\n const { className: externalClassName, dialog, style, ...otherProps } = props;\n const { combobox, button, input, popover, list } = useCombobox(otherProps, ref);\n const internalRef = React.useRef<HTMLDivElement>(null);\n const { texts } = useLocalization();\n const selectDimensions = useBoundingClientRectListener(internalRef);\n const className = cn(\n 'inline-flex relative',\n {\n 'yt-combobox--inline': props.inline,\n },\n externalClassName\n );\n\n return (\n <span className={className} data-taco=\"combobox\" style={style}>\n <PopoverPrimitive.Root {...popover}>\n <PopoverPrimitive.Anchor asChild ref={internalRef}>\n <div {...combobox} className=\"inline w-full\" ref={ref}>\n <Input\n {...input}\n autoComplete=\"off\"\n button={\n props.inline ? (\n <IconButton\n appearance=\"discrete\"\n className=\"!border-l-0 focus:!border-none focus:!shadow-none active:!border-none\"\n icon={popover.open ? 'chevron-up' : 'chevron-down'}\n onClick={() => {\n popover.onOpenChange(true);\n input.ref.current?.focus();\n }}\n tabIndex={-1}\n />\n ) : dialog ? (\n <IconButton\n aria-label={texts.combobox.tooltip}\n icon=\"list-search\"\n disabled={props.readOnly || props.disabled}\n dialog={dialog}\n onFocus={(event: React.FocusEvent<HTMLButtonElement>) => {\n // Prevents the default focus behaviour of showing the tooltip, on parent tooltip element\n event.preventDefault();\n input.ref.current?.focus();\n }}\n ref={button.ref}\n tabIndex={-1}\n tooltip={texts.combobox.tooltip}\n />\n ) : undefined\n }\n />\n </div>\n </PopoverPrimitive.Anchor>\n <PopoverPrimitive.Content\n align=\"start\"\n className=\"z-10\"\n onOpenAutoFocus={event => {\n event.preventDefault();\n }}\n sideOffset={4}>\n <ScrollableList\n {...list}\n className={cn('!border-blue max-h-[calc(12rem+2px)] w-auto max-w-[theme(spacing.96)]')}\n style={{ minWidth: selectDimensions?.width }}\n tabIndex={popover.open ? 0 : -1}\n />\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Root>\n </span>\n );\n});\n"],"names":["Combobox","React","props","ref","className","externalClassName","dialog","style","otherProps","combobox","button","input","popover","list","useCombobox","internalRef","texts","useLocalization","selectDimensions","useBoundingClientRectListener","cn","inline","PopoverPrimitive","asChild","Input","autoComplete","IconButton","appearance","icon","open","onClick","onOpenChange","current","focus","tabIndex","tooltip","disabled","readOnly","onFocus","event","preventDefault","undefined","align","onOpenAutoFocus","sideOffset","ScrollableList","minWidth","width"],"mappings":";;;;;;;;;;MA+DaA,QAAQ,gBAAGC,UAAA,CAAiB,SAASD,QAAT,CAAkBE,KAAlB,EAAwCC,GAAxC;EACrC,MAAM;IAAEC,SAAS,EAAEC,iBAAb;IAAgCC,MAAhC;IAAwCC,KAAxC;IAA+C,GAAGC;MAAeN,KAAvE;EACA,MAAM;IAAEO,QAAF;IAAYC,MAAZ;IAAoBC,KAApB;IAA2BC,OAA3B;IAAoCC;MAASC,WAAW,CAACN,UAAD,EAAaL,GAAb,CAA9D;EACA,MAAMY,W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AAQ,EAAE,CAAC;MACXC,OAAO,EAAEnB,KAAK,CAACP,QAAN,CAAe0B;KAZ5B,CADM,GAeNM;IA9BZ,CADJ,CADJ,CADJ,eAsCIxC,aAAA,CAACqB,OAAD;IACIoB,KAAK,EAAC;IACNtC,SAAS,EAAC;IACVuC,eAAe,EAAEJ,KAAK;MAClBA,KAAK,CAACC,cAAN;;IAEJI,UAAU,EAAE;GANhB,eAOI3C,aAAA,CAAC4C,cAAD,oBACQhC;IACJT,SAAS,EAAEgB,EAAE,CAAC,uEAAD;IACbb,KAAK,EAAE;MAAEuC,QAAQ,EAAE5B,gBAAF,aAAEA,gBAAF,uBAAEA,gBAAgB,CAAE6B;;IACrCb,QAAQ,EAAEtB,OAAO,CAACiB,IAAR,GAAe,CAAf,GAAmB,CAAC;IAJlC,CAPJ,CAtCJ,CADJ,CADJ;AAyDH,CAvEuB;;;;"}
|
@@ -71,6 +71,7 @@ const BaseSelect = /*#__PURE__*/forwardRef(function BaseSelect(props, ref) {
|
|
71
71
|
name: popover.open ? 'chevron-up' : 'chevron-down'
|
72
72
|
}))), /*#__PURE__*/createElement(Content, {
|
73
73
|
align: "start",
|
74
|
+
className: "z-10",
|
74
75
|
sideOffset: 4
|
75
76
|
}, props.multiselect ? /*#__PURE__*/createElement(MultiListbox, Object.assign({}, commonListboxProps)) : /*#__PURE__*/createElement(Listbox, Object.assign({}, commonListboxProps))), /*#__PURE__*/createElement("input", Object.assign({}, input, {
|
76
77
|
className: "hidden",
|
@@ -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), 'h-8 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: ListboxProps = {\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","className","externalClassName","highlighted","style","otherProps","button","listbox","popover","input","text","more","useSelect","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,MAAMA,UAAU,gBAAGC,UAAA,CAAiB,SAASD,UAAT,CAAoBE,KAApB,EAA4CC,GAA5C;EAChC,MAAM;IAAEC,SAAF;IAAaC,SAAS,EAAEC,iBAAxB;IAA2CC,WAA3C;IAAwDC,KAAxD;IAA+D,GAAGC;MAAeP,KAAvF;EACA,MAAM;IAAEQ,MAAF;IAAUC,OAAV;IAAmBC,OAAnB;IAA4BC,KAA5B;IAAmCC,IAAnC;IAAyCC,IAAI,GAAG;MAAMC,SAAS,CAACP,UAAD,EAAaN,GAAb,CAArE;EACA,MAAMc,WAAW,GAAGhB,MAAA,CAAgC,IAAhC,CAApB;EACA,MAAMiB,gBAAgB,GAAGC,6BAA6B,CAACF,WAAD,CAAtD;EACA,MAAMZ,SAAS,GAAGe,E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S,EAAC;GAAhB,eACIJ,aAAA,CAACoC,IAAD;IAAMhC,SAAS,EAAC;IAAsBiC,IAAI,EAAE1B,OAAO,CAACY,IAAR,GAAe,YAAf,GAA8B;GAA1E,CADJ,CAFJ,CADJ,eAOIvB,aAAA,CAACkC,OAAD;IAA0BI,KAAK,EAAC;
|
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), 'h-8 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: ListboxProps = {\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\" className=\"z-10\" 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","className","externalClassName","highlighted","style","otherProps","button","listbox","popover","input","text","more","useSelect","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"],"m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AEhB;MAAWiB,MAAM;MAAC7C,GAAG,EAAEA;MAAzD,CAAP;;;EAGJ,oBAAOF,aAAA,CAACD,UAAD,oBAAgBS;IAAYN,GAAG,EAAEA;IAAjC,CAAP;AACH,CARqB;;;;"}
|
@@ -120,7 +120,8 @@ const useTable = (props, ref) => {
|
|
120
120
|
}
|
121
121
|
|
122
122
|
const {
|
123
|
-
texts
|
123
|
+
texts,
|
124
|
+
locale
|
124
125
|
} = useLocalization();
|
125
126
|
const {
|
126
127
|
columns,
|
@@ -157,7 +158,7 @@ const useTable = (props, ref) => {
|
|
157
158
|
autoResetSelectedRows: false,
|
158
159
|
autoResetSortBy: false,
|
159
160
|
autoResetPage: false,
|
160
|
-
sortTypes: React__default.useMemo(() => sortTypes, []),
|
161
|
+
sortTypes: React__default.useMemo(() => sortTypes(locale), []),
|
161
162
|
useControlledState: currentState => {
|
162
163
|
return React__default.useMemo(() => ({ ...currentState,
|
163
164
|
selectedRowIds: selectedRows || []
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTable.js","sources":["../../../../../src/components/Table/hooks/useTable.tsx"],"sourcesContent":["import React from 'react';\nimport { useTable as useReactTable, useExpanded, useSortBy, usePagination, useRowState } from 'react-table';\nimport { getColumnsFromChildren, getInternalSortRules } from '../util';\nimport { sortTypes } from '../util/sortTypes';\nimport { useRowEditing } from './plugins/useRowEditing';\nimport { useRowActions } from './plugins/useRowActions';\nimport { useRowSelect } from './plugins/useRowSelect';\nimport {\n InternalTable,\n InternalTableRow,\n PaginationHandler,\n RowActiveHandler,\n SortHandler,\n TableProps,\n TableRef,\n} from '../types';\nimport { useTableKeyboardNavigation } from './useTableKeyboardNavigation';\nimport { useLocalization } from '../../Provider/Provider';\nimport { useRowDraggable } from './plugins/useRowDraggable';\nimport { sanitizeRowProps } from '../util';\n\nconst useTableRowActive = (\n activeIndex: number | undefined,\n rows: InternalTableRow[],\n rowExpansionRenderer: TableProps<any>['rowExpansionRenderer'],\n handleonRowActive: RowActiveHandler<any> | undefined\n) => {\n React.useEffect(() => {\n if (activeIndex !== undefined && rows.length && handleonRowActive) {\n const focusedRow = rows[activeIndex];\n if (focusedRow) {\n const sanitizedFocusedRow = sanitizeRowProps(focusedRow, rowExpansionRenderer);\n handleonRowActive(sanitizedFocusedRow);\n }\n }\n }, [activeIndex, rows]);\n};\n\nconst useTableInstance = (instance: any, ref: React.RefObject<TableRef>): object => {\n const sanitizedInstance = React.useMemo(\n () => ({\n toggleAllRowsExpanded: instance.toggleAllRowsExpanded,\n toggleHideAllColumns: instance.toggleHideAllColumns,\n toggleHideColumn: instance.toggleHideColumn,\n toggleEditing: instance.toggleEditing,\n toggleRowEditing: instance.toggleRowEditing,\n resetRowEditing: instance.resetRowEditing,\n toggleRowExpanded: instance.toggleRowExpanded,\n toggleSortBy: instance.toggleSortBy,\n }),\n []\n );\n\n React.useEffect(() => {\n if (ref?.current) {\n ref.current.instance = sanitizedInstance;\n }\n }, [ref]);\n\n return sanitizedInstance;\n};\n\nconst useTablePaginationListener = (disablePagination: boolean, onPaginate: PaginationHandler | undefined, state: any): void => {\n React.useEffect(() => {\n if (!disablePagination && onPaginate) {\n onPaginate(state.pageIndex, state.pageSize);\n }\n }, [state.pageIndex, state.pageSize]);\n};\n\nconst useTableSortingListener = (\n data: any[],\n sortedRows: any[],\n onSort: SortHandler<any> | undefined,\n manualSorting: boolean,\n state: any\n): void => {\n React.useEffect(() => {\n if (onSort) {\n const sortRules = state.sortBy.map((rule: any) => ({ accessor: rule.id, desc: rule.desc }));\n\n if (manualSorting) {\n onSort(sortRules);\n } else {\n let sortedData;\n\n if (sortRules.length && sortedRows?.length) {\n sortedData = sortedRows.map((row: any) => row.original);\n }\n\n onSort(sortRules, sortedData || data);\n }\n }\n }, [onSort && JSON.stringify(state.sortBy), manualSorting]);\n};\n\nconst DEFAULT_PAGE_SIZE = 10;\n\nexport const useTable = <T extends {}>(\n props: TableProps<T> & { windowed?: boolean },\n ref: React.RefObject<TableRef>\n): InternalTable => {\n const {\n children,\n data,\n dangerouslyHijackGlobalKeyboardNavigation: _,\n onRowClick,\n onRowDrag,\n onSelectedRows,\n rowClassName,\n rowExpansionRenderer,\n rowHeight,\n selectedRows,\n\n // sorting\n disableSorting,\n manualSorting,\n onSort,\n sortRules,\n\n //index\n activeIndex: _1,\n defaultActiveIndex: _2,\n onChangeActiveIndex: _3,\n\n // pagination\n disablePagination = true,\n length,\n onPaginate,\n pageSize = DEFAULT_PAGE_SIZE,\n pageIndex = 0,\n\n // row editing\n inlineEditingUniqueId = undefined,\n onRowCreate,\n\n // actions\n actions,\n onRowEdit,\n onRowCopy,\n onRowDelete,\n onRowActive,\n\n windowed = false,\n\n ...otherProps\n } = props;\n\n if ((onSelectedRows && !selectedRows) || (!onSelectedRows && selectedRows)) {\n throw new Error(\n 'Selected rows in a Table component are fully controlled - you must pass both the `onSelectedRows` and `selectedRows` props when using row selection'\n );\n }\n\n const { texts } = useLocalization();\n const { columns, sortRules: defaultSortRules } = React.useMemo(\n () => getColumnsFromChildren(children, rowExpansionRenderer),\n [children, rowExpansionRenderer]\n );\n\n const manualPagination = !disablePagination && !!onPaginate && !!length;\n\n const {\n headerGroups,\n rows,\n sortedRows,\n prepareRow: prepareBaseRow,\n state,\n // pagination\n page,\n gotoPage,\n setPageSize,\n ...instance\n }: any = useReactTable(\n {\n columns,\n data,\n initialState: {\n // eslint-disable-next-line\n // @ts-ignore: not sure how to type this correctly right now\n sortBy: getInternalSortRules(sortRules) || defaultSortRules,\n pageSize: !disablePagination ? pageSize : undefined,\n pageIndex: !disablePagination ? pageIndex : undefined,\n },\n manualPagination,\n pageCount: manualPagination && length ? Math.ceil(length / pageSize) : -1,\n manualSortBy: manualSorting,\n disableSortBy: disableSorting,\n // most of these resets preventions are needed for editing mode\n autoResetExpanded: false,\n autoResetSelectedRows: false,\n autoResetSortBy: false,\n autoResetPage: false,\n sortTypes: React.useMemo(() => sortTypes, []),\n useControlledState: currentState => {\n return React.useMemo(\n () => ({\n ...currentState,\n selectedRowIds: selectedRows || [],\n }),\n [currentState, selectedRows]\n );\n },\n },\n useRowState,\n useSortBy,\n useExpanded,\n usePagination,\n useRowSelect(onSelectedRows),\n useRowDraggable(onRowDrag),\n useRowEditing(inlineEditingUniqueId),\n useRowActions(\n inlineEditingUniqueId,\n { onRowCreate, onRowEdit, onRowCopy, onRowDelete },\n actions,\n rowExpansionRenderer,\n texts,\n windowed\n )\n );\n\n useTablePaginationListener(disablePagination, onPaginate, state);\n useTableSortingListener(data, sortedRows, onSort, !!manualSorting, state);\n\n const sanitizedInstance = useTableInstance(instance, ref);\n\n const visibleRows = !disablePagination && !manualPagination ? page : rows;\n\n const [activeIndex, setActiveIndex, handleKeyDown, handleFocus] = useTableKeyboardNavigation<T>(\n props,\n visibleRows,\n { onRowClick, onRowCreate, onRowEdit, onRowCopy, onRowDelete, rowExpansionRenderer },\n ref\n );\n\n useTableRowActive(activeIndex, rows, rowExpansionRenderer, onRowActive);\n\n const prepareRow = React.useCallback(\n (row: any, index: number) => {\n prepareBaseRow(row);\n row.setActive = () => setActiveIndex(index);\n },\n [prepareBaseRow, setActiveIndex]\n );\n\n return {\n rowProps: {\n activeIndex,\n setActiveIndex,\n onRowClick,\n rowClassName,\n rowExpansionRenderer,\n rowHeight,\n inlineEditingUniqueId,\n },\n tableProps: {\n ...otherProps,\n headerGroups,\n onFocus: handleFocus,\n onKeyDown: handleKeyDown,\n tabIndex: otherProps.tabIndex ?? 0,\n },\n state,\n pagination: !disablePagination\n ? {\n length: manualPagination && length ? length : data.length,\n pageIndex: state.pageIndex,\n pageSize: state.pageSize,\n setPageIndex: gotoPage,\n setPageSize: setPageSize,\n }\n : null,\n rows: visibleRows,\n prepareRow,\n instance: sanitizedInstance,\n };\n};\n"],"names":["useTableRowActive","activeIndex","rows","rowExpansionRenderer","handleonRowActive","React","useEffect","undefined","length","focusedRow","sanitizedFocusedRow","sanitizeRowProps","useTableInstance","instance","ref","sanitizedInstance","useMemo","toggleAllRowsExpanded","toggleHideAllColumns","toggleHideColumn","toggleEditing","toggleRowEditing","resetRowEditing","toggleRowExpanded","toggleSortBy","current","useTablePaginationListener","disablePagination","onPaginate","state","pageIndex","pageSize","useTableSortingListener","data","sortedRows","onSort","manualSorting","sortRules","sortBy","map","rule","accessor","id","desc","sortedData","row","original","JSON","stringify","DEFAULT_PAGE_SIZE","useTable","props","children","dangerouslyHijackGlobalKeyboardNavigation","_","onRowClick","onRowDrag","onSelectedRows","rowClassName","rowHeight","selectedRows","disableSorting","_1","defaultActiveIndex","_2","onChangeActiveIndex","_3","inlineEditingUniqueId","onRowCreate","actions","onRowEdit","onRowCopy","onRowDelete","onRowActive","windowed","otherProps","Error","texts","useLocalization","columns","defaultSortRules","getColumnsFromChildren","manualPagination","headerGroups","prepareRow","prepareBaseRow","page","gotoPage","setPageSize","useReactTable","initialState","getInternalSortRules","pageCount","Math","ceil","manualSortBy","disableSortBy","autoResetExpanded","autoResetSelectedRows","autoResetSortBy","autoResetPage","sortTypes","useControlledState","currentState","selectedRowIds","useRowState","useSortBy","useExpanded","usePagination","useRowSelect","useRowDraggable","useRowEditing","useRowActions","visibleRows","setActiveIndex","handleKeyDown","handleFocus","useTableKeyboardNavigation","useCallback","index","setActive","rowProps","tableProps","onFocus","onKeyDown","tabIndex","pagination","setPageIndex"],"mappings":";;;;;;;;;;;AAqBA,MAAMA,iBAAiB,GAAG,CACtBC,WADsB,EAEtBC,IAFsB,EAGtBC,oBAHsB,EAItBC,iBAJsB;EAMtBC,cAAK,CAACC,SAAN,CAAgB;IACZ,IAAIL,WAAW,KAAKM,SAAhB,IAA6BL,IAAI,CAACM,MAAlC,IAA4CJ,iBAAhD,EAAmE;MAC/D,MAAMK,UAAU,GAAGP,IAAI,CAACD,WAAD,CAAvB;;MACA,IAAIQ,UAAJ,EAAgB;QACZ,MAAMC,mBAAmB,GAAGC,gBAAgB,CAACF,UAAD,EAAaN,oBAAb,CAA5C;QACAC,iBAAiB,CAACM,mBAAD,CAAjB;;;GALZ,EA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AAjD;IAA8DrE;GAH0B,EAIxFW,GAJwF,CAA5F;EAOAd,iBAAiB,CAACC,WAAD,EAAcC,IAAd,EAAoBC,oBAApB,EAA0CsE,WAA1C,CAAjB;EAEA,MAAMW,UAAU,GAAG/E,cAAK,CAACiH,WAAN,CACf,CAACzE,GAAD,EAAW0E,KAAX;IACIlC,cAAc,CAACxC,GAAD,CAAd;;IACAA,GAAG,CAAC2E,SAAJ,GAAgB,MAAMN,cAAc,CAACK,KAAD,CAApC;GAHW,EAKf,CAAClC,cAAD,EAAiB6B,cAAjB,CALe,CAAnB;EAQA,OAAO;IACHO,QAAQ,EAAE;MACNxH,WADM;MAENiH,cAFM;MAGN3D,UAHM;MAING,YAJM;MAKNvD,oBALM;MAMNwD,SANM;MAONQ;KARD;IAUHuD,UAAU,EAAE,EACR,GAAG/C,UADK;MAERQ,YAFQ;MAGRwC,OAAO,EAAEP,WAHD;MAIRQ,SAAS,EAAET,aAJH;MAKRU,QAAQ,0BAAElD,UAAU,CAACkD,QAAb,uEAAyB;KAflC;IAiBHhG,KAjBG;IAkBHiG,UAAU,EAAE,CAACnG,iBAAD,GACN;MACInB,MAAM,EAAE0E,gBAAgB,IAAI1E,MAApB,GAA6BA,MAA7B,GAAsCyB,IAAI,CAACzB,MADvD;MAEIsB,SAAS,EAAED,KAAK,CAACC,SAFrB;MAGIC,QAAQ,EAAEF,KAAK,CAACE,QAHpB;MAIIgG,YAAY,EAAExC,QAJlB;MAKIC,WAAW,EAAEA;KANX,GAQN,IA1BH;IA2BHtF,IAAI,EAAE+G,WA3BH;IA4BH7B,UA5BG;IA6BHvE,QAAQ,EAAEE;GA7Bd;AA+BH;;;;"}
|
1
|
+
{"version":3,"file":"useTable.js","sources":["../../../../../src/components/Table/hooks/useTable.tsx"],"sourcesContent":["import React from 'react';\nimport { useTable as useReactTable, useExpanded, useSortBy, usePagination, useRowState } from 'react-table';\nimport { getColumnsFromChildren, getInternalSortRules } from '../util';\nimport { sortTypes } from '../util/sortTypes';\nimport { useRowEditing } from './plugins/useRowEditing';\nimport { useRowActions } from './plugins/useRowActions';\nimport { useRowSelect } from './plugins/useRowSelect';\nimport {\n InternalTable,\n InternalTableRow,\n PaginationHandler,\n RowActiveHandler,\n SortHandler,\n TableProps,\n TableRef,\n} from '../types';\nimport { useTableKeyboardNavigation } from './useTableKeyboardNavigation';\nimport { useLocalization } from '../../Provider/Provider';\nimport { useRowDraggable } from './plugins/useRowDraggable';\nimport { sanitizeRowProps } from '../util';\n\nconst useTableRowActive = (\n activeIndex: number | undefined,\n rows: InternalTableRow[],\n rowExpansionRenderer: TableProps<any>['rowExpansionRenderer'],\n handleonRowActive: RowActiveHandler<any> | undefined\n) => {\n React.useEffect(() => {\n if (activeIndex !== undefined && rows.length && handleonRowActive) {\n const focusedRow = rows[activeIndex];\n if (focusedRow) {\n const sanitizedFocusedRow = sanitizeRowProps(focusedRow, rowExpansionRenderer);\n handleonRowActive(sanitizedFocusedRow);\n }\n }\n }, [activeIndex, rows]);\n};\n\nconst useTableInstance = (instance: any, ref: React.RefObject<TableRef>): object => {\n const sanitizedInstance = React.useMemo(\n () => ({\n toggleAllRowsExpanded: instance.toggleAllRowsExpanded,\n toggleHideAllColumns: instance.toggleHideAllColumns,\n toggleHideColumn: instance.toggleHideColumn,\n toggleEditing: instance.toggleEditing,\n toggleRowEditing: instance.toggleRowEditing,\n resetRowEditing: instance.resetRowEditing,\n toggleRowExpanded: instance.toggleRowExpanded,\n toggleSortBy: instance.toggleSortBy,\n }),\n []\n );\n\n React.useEffect(() => {\n if (ref?.current) {\n ref.current.instance = sanitizedInstance;\n }\n }, [ref]);\n\n return sanitizedInstance;\n};\n\nconst useTablePaginationListener = (disablePagination: boolean, onPaginate: PaginationHandler | undefined, state: any): void => {\n React.useEffect(() => {\n if (!disablePagination && onPaginate) {\n onPaginate(state.pageIndex, state.pageSize);\n }\n }, [state.pageIndex, state.pageSize]);\n};\n\nconst useTableSortingListener = (\n data: any[],\n sortedRows: any[],\n onSort: SortHandler<any> | undefined,\n manualSorting: boolean,\n state: any\n): void => {\n React.useEffect(() => {\n if (onSort) {\n const sortRules = state.sortBy.map((rule: any) => ({ accessor: rule.id, desc: rule.desc }));\n\n if (manualSorting) {\n onSort(sortRules);\n } else {\n let sortedData;\n\n if (sortRules.length && sortedRows?.length) {\n sortedData = sortedRows.map((row: any) => row.original);\n }\n\n onSort(sortRules, sortedData || data);\n }\n }\n }, [onSort && JSON.stringify(state.sortBy), manualSorting]);\n};\n\nconst DEFAULT_PAGE_SIZE = 10;\n\nexport const useTable = <T extends {}>(\n props: TableProps<T> & { windowed?: boolean },\n ref: React.RefObject<TableRef>\n): InternalTable => {\n const {\n children,\n data,\n dangerouslyHijackGlobalKeyboardNavigation: _,\n onRowClick,\n onRowDrag,\n onSelectedRows,\n rowClassName,\n rowExpansionRenderer,\n rowHeight,\n selectedRows,\n\n // sorting\n disableSorting,\n manualSorting,\n onSort,\n sortRules,\n\n //index\n activeIndex: _1,\n defaultActiveIndex: _2,\n onChangeActiveIndex: _3,\n\n // pagination\n disablePagination = true,\n length,\n onPaginate,\n pageSize = DEFAULT_PAGE_SIZE,\n pageIndex = 0,\n\n // row editing\n inlineEditingUniqueId = undefined,\n onRowCreate,\n\n // actions\n actions,\n onRowEdit,\n onRowCopy,\n onRowDelete,\n onRowActive,\n\n windowed = false,\n\n ...otherProps\n } = props;\n\n if ((onSelectedRows && !selectedRows) || (!onSelectedRows && selectedRows)) {\n throw new Error(\n 'Selected rows in a Table component are fully controlled - you must pass both the `onSelectedRows` and `selectedRows` props when using row selection'\n );\n }\n\n const { texts, locale } = useLocalization();\n const { columns, sortRules: defaultSortRules } = React.useMemo(\n () => getColumnsFromChildren(children, rowExpansionRenderer),\n [children, rowExpansionRenderer]\n );\n\n const manualPagination = !disablePagination && !!onPaginate && !!length;\n\n const {\n headerGroups,\n rows,\n sortedRows,\n prepareRow: prepareBaseRow,\n state,\n // pagination\n page,\n gotoPage,\n setPageSize,\n ...instance\n }: any = useReactTable(\n {\n columns,\n data,\n initialState: {\n // eslint-disable-next-line\n // @ts-ignore: not sure how to type this correctly right now\n sortBy: getInternalSortRules(sortRules) || defaultSortRules,\n pageSize: !disablePagination ? pageSize : undefined,\n pageIndex: !disablePagination ? pageIndex : undefined,\n },\n manualPagination,\n pageCount: manualPagination && length ? Math.ceil(length / pageSize) : -1,\n manualSortBy: manualSorting,\n disableSortBy: disableSorting,\n // most of these resets preventions are needed for editing mode\n autoResetExpanded: false,\n autoResetSelectedRows: false,\n autoResetSortBy: false,\n autoResetPage: false,\n sortTypes: React.useMemo(() => sortTypes(locale), []),\n useControlledState: currentState => {\n return React.useMemo(\n () => ({\n ...currentState,\n selectedRowIds: selectedRows || [],\n }),\n [currentState, selectedRows]\n );\n },\n },\n useRowState,\n useSortBy,\n useExpanded,\n usePagination,\n useRowSelect(onSelectedRows),\n useRowDraggable(onRowDrag),\n useRowEditing(inlineEditingUniqueId),\n useRowActions(\n inlineEditingUniqueId,\n { onRowCreate, onRowEdit, onRowCopy, onRowDelete },\n actions,\n rowExpansionRenderer,\n texts,\n windowed\n )\n );\n\n useTablePaginationListener(disablePagination, onPaginate, state);\n useTableSortingListener(data, sortedRows, onSort, !!manualSorting, state);\n\n const sanitizedInstance = useTableInstance(instance, ref);\n\n const visibleRows = !disablePagination && !manualPagination ? page : rows;\n\n const [activeIndex, setActiveIndex, handleKeyDown, handleFocus] = useTableKeyboardNavigation<T>(\n props,\n visibleRows,\n { onRowClick, onRowCreate, onRowEdit, onRowCopy, onRowDelete, rowExpansionRenderer },\n ref\n );\n\n useTableRowActive(activeIndex, rows, rowExpansionRenderer, onRowActive);\n\n const prepareRow = React.useCallback(\n (row: any, index: number) => {\n prepareBaseRow(row);\n row.setActive = () => setActiveIndex(index);\n },\n [prepareBaseRow, setActiveIndex]\n );\n\n return {\n rowProps: {\n activeIndex,\n setActiveIndex,\n onRowClick,\n rowClassName,\n rowExpansionRenderer,\n rowHeight,\n inlineEditingUniqueId,\n },\n tableProps: {\n ...otherProps,\n headerGroups,\n onFocus: handleFocus,\n onKeyDown: handleKeyDown,\n tabIndex: otherProps.tabIndex ?? 0,\n },\n state,\n pagination: !disablePagination\n ? {\n length: manualPagination && length ? length : data.length,\n pageIndex: state.pageIndex,\n pageSize: state.pageSize,\n setPageIndex: gotoPage,\n setPageSize: setPageSize,\n }\n : null,\n rows: visibleRows,\n prepareRow,\n instance: sanitizedInstance,\n };\n};\n"],"names":["useTableRowActive","activeIndex","rows","rowExpansionRenderer","handleonRowActive","React","useEffect","undefined","length","focusedRow","sanitizedFocusedRow","sanitizeRowProps","useTableInstance","instance","ref","sanitizedInstance","useMemo","toggleAllRowsExpanded","toggleHideAllColumns","toggleHideColumn","toggleEditing","toggleRowEditing","resetRowEditing","toggleRowExpanded","toggleSortBy","current","useTablePaginationListener","disablePagination","onPaginate","state","pageIndex","pageSize","useTableSortingListener","data","sortedRows","onSort","manualSorting","sortRules","sortBy","map","rule","accessor","id","desc","sortedData","row","original","JSON","stringify","DEFAULT_PAGE_SIZE","useTable","props","children","dangerouslyHijackGlobalKeyboardNavigation","_","onRowClick","onRowDrag","onSelectedRows","rowClassName","rowHeight","selectedRows","disableSorting","_1","defaultActiveIndex","_2","onChangeActiveIndex","_3","inlineEditingUniqueId","onRowCreate","actions","onRowEdit","onRowCopy","onRowDelete","onRowActive","windowed","otherProps","Error","texts","locale","useLocalization","columns","defaultSortRules","getColumnsFromChildren","manualPagination","headerGroups","prepareRow","prepareBaseRow","page","gotoPage","setPageSize","useReactTable","initialState","getInternalSortRules","pageCount","Math","ceil","manualSortBy","disableSortBy","autoResetExpanded","autoResetSelectedRows","autoResetSortBy","autoResetPage","sortTypes","useControlledState","currentState","selectedRowIds","useRowState","useSortBy","useExpanded","usePagination","useRowSelect","useRowDraggable","useRowEditing","useRowActions","visibleRows","setActiveIndex","handleKeyDown","handleFocus","useTableKeyboardNavigation","useCallback","index","setActive","rowProps","tableProps","onFocus","onKeyDown","tabIndex","pagination","setPageIndex"],"mappings":";;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CAACzB,MADvD;MAEIsB,SAAS,EAAED,KAAK,CAACC,SAFrB;MAGIC,QAAQ,EAAEF,KAAK,CAACE,QAHpB;MAIIiG,YAAY,EAAExC,QAJlB;MAKIC,WAAW,EAAEA;KANX,GAQN,IA1BH;IA2BHvF,IAAI,EAAEgH,WA3BH;IA4BH7B,UA5BG;IA6BHxE,QAAQ,EAAEE;GA7Bd;AA+BH;;;;"}
|
@@ -50,32 +50,53 @@ const compareBasic = (a, b) => {
|
|
50
50
|
return a === b ? 0 : a > b ? 1 : -1;
|
51
51
|
};
|
52
52
|
|
53
|
-
const
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
return compareBasic(a, b);
|
63
|
-
},
|
64
|
-
number: (rowA, rowB, columnId) => {
|
65
|
-
const a = getNumber(rowA.values[columnId]);
|
66
|
-
const b = getNumber(rowB.values[columnId]);
|
67
|
-
return compareBasic(a, b);
|
68
|
-
},
|
69
|
-
boolean: (rowA, rowB, columnId) => {
|
70
|
-
const a = !!rowA.values[columnId];
|
71
|
-
const b = !!rowB.values[columnId];
|
72
|
-
return compareBasic(a, b);
|
73
|
-
},
|
74
|
-
auto: (rowA, rowB, columnId) => {
|
75
|
-
const a = guess(rowA.values[columnId]);
|
76
|
-
const b = guess(rowB.values[columnId]);
|
77
|
-
return compareBasic(a, b);
|
53
|
+
const stringsLocaleCompare = (a, b, locale) => {
|
54
|
+
// In some browsers 'localCompare' may return -2 or 2 instead of -1 or 1
|
55
|
+
const compareResult = a.localeCompare(b, locale);
|
56
|
+
return compareResult === 0 ? 0 : compareResult > 0 ? 1 : -1;
|
57
|
+
};
|
58
|
+
|
59
|
+
const compareBasicStrings = (a, b, locale) => {
|
60
|
+
if (a && b) {
|
61
|
+
return stringsLocaleCompare(a, b, locale);
|
78
62
|
}
|
63
|
+
|
64
|
+
return compareBasic(a, b);
|
65
|
+
};
|
66
|
+
|
67
|
+
const sortTypes = locale => {
|
68
|
+
return {
|
69
|
+
datetime: (rowA, rowB, columnId) => {
|
70
|
+
const a = getTime(rowA.values[columnId]);
|
71
|
+
const b = getTime(rowB.values[columnId]);
|
72
|
+
return compareBasic(a, b);
|
73
|
+
},
|
74
|
+
string: (rowA, rowB, columnId) => {
|
75
|
+
const a = getString(rowA.values[columnId]);
|
76
|
+
const b = getString(rowB.values[columnId]);
|
77
|
+
return compareBasicStrings(a, b, locale);
|
78
|
+
},
|
79
|
+
number: (rowA, rowB, columnId) => {
|
80
|
+
const a = getNumber(rowA.values[columnId]);
|
81
|
+
const b = getNumber(rowB.values[columnId]);
|
82
|
+
return compareBasic(a, b);
|
83
|
+
},
|
84
|
+
boolean: (rowA, rowB, columnId) => {
|
85
|
+
const a = !!rowA.values[columnId];
|
86
|
+
const b = !!rowB.values[columnId];
|
87
|
+
return compareBasic(a, b);
|
88
|
+
},
|
89
|
+
auto: (rowA, rowB, columnId) => {
|
90
|
+
const a = guess(rowA.values[columnId]);
|
91
|
+
const b = guess(rowB.values[columnId]);
|
92
|
+
|
93
|
+
if (typeof a === 'string' && typeof b === 'string') {
|
94
|
+
return compareBasicStrings(a, b, locale);
|
95
|
+
} else {
|
96
|
+
return compareBasic(a, b);
|
97
|
+
}
|
98
|
+
}
|
99
|
+
};
|
79
100
|
};
|
80
101
|
|
81
102
|
export { sortTypes };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sortTypes.js","sources":["../../../../../src/components/Table/util/sortTypes.ts"],"sourcesContent":["import { SortTypes, TableRow } from '../types';\n\nconst getTime = (value: any): number | undefined => {\n const parsedValue: Date = typeof value === 'string' ? new Date(value) : value;\n return parsedValue?.getTime ? parsedValue.getTime() : undefined;\n};\n\nconst getNumber = (amount = '', decimalSeparator = ','): number | undefined => {\n if (typeof amount === 'number') {\n return amount;\n }\n\n if (amount === null || !amount.length) {\n return undefined;\n }\n\n let value;\n\n if (decimalSeparator === ',') {\n // replace digit seperator then replace decimal separator\n value = Number(amount.replace(/\\./g, '').replace(',', '.'));\n } else {\n // replace digit seperator\n value = Number(amount.replace(/,/g, ''));\n }\n\n return Number.isNaN(value) ? undefined : value;\n};\n\nconst getString = (value: any): string | undefined => {\n if (value) {\n return String(value).toLowerCase();\n }\n\n return undefined;\n};\n\nconst guess = (value: any): any => {\n if (typeof value === 'boolean') {\n return !!value;\n }\n\n return isNaN(value) ? getString(value) : Number(value);\n};\n\nconst compareBasic = (a: any, b: any) => {\n // places undefined values first in ascending order instead of descending\n if (a !== undefined && b === undefined) {\n return 1;\n }\n\n return a === b ? 0 : a > b ? 1 : -1;\n};\n\ntype SortHandler<T> = (rowA: TableRow<T>, rowB: TableRow<T>, columnId: string) => 0 | 1 | -1;\n\nexport const sortTypes: Record<SortTypes, SortHandler<any>>
|
1
|
+
{"version":3,"file":"sortTypes.js","sources":["../../../../../src/components/Table/util/sortTypes.ts"],"sourcesContent":["import { SortTypes, TableRow } from '../types';\n\nconst getTime = (value: any): number | undefined => {\n const parsedValue: Date = typeof value === 'string' ? new Date(value) : value;\n return parsedValue?.getTime ? parsedValue.getTime() : undefined;\n};\n\nconst getNumber = (amount = '', decimalSeparator = ','): number | undefined => {\n if (typeof amount === 'number') {\n return amount;\n }\n\n if (amount === null || !amount.length) {\n return undefined;\n }\n\n let value;\n\n if (decimalSeparator === ',') {\n // replace digit seperator then replace decimal separator\n value = Number(amount.replace(/\\./g, '').replace(',', '.'));\n } else {\n // replace digit seperator\n value = Number(amount.replace(/,/g, ''));\n }\n\n return Number.isNaN(value) ? undefined : value;\n};\n\nconst getString = (value: any): string | undefined => {\n if (value) {\n return String(value).toLowerCase();\n }\n\n return undefined;\n};\n\nconst guess = (value: any): any => {\n if (typeof value === 'boolean') {\n return !!value;\n }\n\n return isNaN(value) ? getString(value) : Number(value);\n};\n\nconst compareBasic = (a: any, b: any) => {\n // places undefined values first in ascending order instead of descending\n if (a !== undefined && b === undefined) {\n return 1;\n }\n\n return a === b ? 0 : a > b ? 1 : -1;\n};\n\nconst stringsLocaleCompare = (a: string, b: string, locale: string): 0 | 1 | -1 => {\n // In some browsers 'localCompare' may return -2 or 2 instead of -1 or 1\n const compareResult = a.localeCompare(b, locale);\n return compareResult === 0 ? 0 : compareResult > 0 ? 1 : -1;\n};\n\nconst compareBasicStrings = (a: string | undefined, b: string | undefined, locale: string): 0 | 1 | -1 => {\n if (a && b) {\n return stringsLocaleCompare(a, b, locale);\n }\n\n return compareBasic(a, b);\n};\n\ntype SortHandler<T> = (rowA: TableRow<T>, rowB: TableRow<T>, columnId: string) => 0 | 1 | -1;\n\nexport const sortTypes = (locale: string): Record<SortTypes, SortHandler<any>> => {\n return {\n datetime: (rowA, rowB, columnId) => {\n const a = getTime(rowA.values[columnId]);\n const b = getTime(rowB.values[columnId]);\n return compareBasic(a, b);\n },\n string: (rowA, rowB, columnId) => {\n const a = getString(rowA.values[columnId]);\n const b = getString(rowB.values[columnId]);\n return compareBasicStrings(a, b, locale);\n },\n number: (rowA, rowB, columnId) => {\n const a = getNumber(rowA.values[columnId]);\n const b = getNumber(rowB.values[columnId]);\n return compareBasic(a, b);\n },\n boolean: (rowA, rowB, columnId) => {\n const a = !!rowA.values[columnId];\n const b = !!rowB.values[columnId];\n return compareBasic(a, b);\n },\n auto: (rowA, rowB, columnId) => {\n const a = guess(rowA.values[columnId]);\n const b = guess(rowB.values[columnId]);\n if (typeof a === 'string' && typeof b === 'string') {\n return compareBasicStrings(a, b, locale);\n } else {\n return compareBasic(a, b);\n }\n },\n };\n};\n"],"names":["getTime","value","parsedValue","Date","undefined","getNumber","amount","decimalSeparator","length","Number","replace","isNaN","getString","String","toLowerCase","guess","compareBasic","a","b","stringsLocaleCompare","locale","compareResult","localeCompare","compareBasicStrings","sortTypes","datetime","rowA","rowB","columnId","values","string","number","boolean","auto"],"mappings":"AAEA,MAAMA,OAAO,GAAIC,KAAD;EACZ,MAAMC,WAAW,GAAS,OAAOD,KAAP,KAAiB,QAAjB,GAA4B,IAAIE,IAAJ,CAASF,KAAT,CAA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igger, Portal, Content, Arrow } from '@radix-ui/react-tooltip';
|
3
4
|
|
4
5
|
const Tooltip = /*#__PURE__*/forwardRef(function Tooltip(props, ref) {
|
5
6
|
const {
|
@@ -8,13 +9,15 @@ const Tooltip = /*#__PURE__*/forwardRef(function Tooltip(props, ref) {
|
|
8
9
|
placement,
|
9
10
|
...otherProps
|
10
11
|
} = props;
|
12
|
+
const className = cn('z-[999]', otherProps.className);
|
11
13
|
return /*#__PURE__*/createElement(Root, {
|
12
14
|
delayDuration: 50
|
13
15
|
}, /*#__PURE__*/createElement(Trigger, {
|
14
16
|
asChild: true,
|
15
17
|
ref: ref
|
16
|
-
}, children), /*#__PURE__*/createElement(Content, Object.assign({}, otherProps, {
|
18
|
+
}, children), /*#__PURE__*/createElement(Portal, null, /*#__PURE__*/createElement(Content, Object.assign({}, otherProps, {
|
17
19
|
asChild: true,
|
20
|
+
className: className,
|
18
21
|
side: placement,
|
19
22
|
sideOffset: 3
|
20
23
|
}), /*#__PURE__*/createElement("div", {
|
@@ -25,7 +28,7 @@ const Tooltip = /*#__PURE__*/forwardRef(function Tooltip(props, ref) {
|
|
25
28
|
}
|
26
29
|
}, /*#__PURE__*/createElement(Arrow, {
|
27
30
|
className: "fill-purple stroke-purple -mt-px"
|
28
|
-
}), title)));
|
31
|
+
}), title))));
|
29
32
|
});
|
30
33
|
|
31
34
|
export { Tooltip };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Tooltip.js","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as TooltipPrimitive from '@radix-ui/react-tooltip';\n\nexport type TooltipProps = React.HTMLAttributes<HTMLDivElement> & {\n /** The element which activates the tooltip when hovered. Should be a single React/HTML element */\n children: React.ReactElement | any;\n /** Text displayed in the tooltip */\n title: string;\n /**\n * Placement of the tooltip relative to the reference element. Placement will be reversed if a collision occurs\n * @defaultValue bottom\n */\n placement?: 'top' | 'right' | 'bottom' | 'left';\n};\n\nexport const Tooltip = React.forwardRef(function Tooltip(props: TooltipProps, ref: React.Ref<HTMLElement>) {\n const { title, children, placement, ...otherProps } = props;\n\n return (\n <TooltipPrimitive.Root delayDuration={50}>\n <TooltipPrimitive.Trigger asChild ref={ref as any}>\n {children}\n </TooltipPrimitive.Trigger>\n <TooltipPrimitive.Content {...otherProps} asChild side={placement} sideOffset={3}>\n
|
1
|
+
{"version":3,"file":"Tooltip.js","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as TooltipPrimitive from '@radix-ui/react-tooltip';\nimport cn from 'classnames';\n\nexport type TooltipProps = React.HTMLAttributes<HTMLDivElement> & {\n /** The element which activates the tooltip when hovered. Should be a single React/HTML element */\n children: React.ReactElement | any;\n /** Text displayed in the tooltip */\n title: string;\n /**\n * Placement of the tooltip relative to the reference element. Placement will be reversed if a collision occurs\n * @defaultValue bottom\n */\n placement?: 'top' | 'right' | 'bottom' | 'left';\n};\n\nexport const Tooltip = React.forwardRef(function Tooltip(props: TooltipProps, ref: React.Ref<HTMLElement>) {\n const { title, children, placement, ...otherProps } = props;\n const className = cn('z-[999]', otherProps.className);\n\n return (\n <TooltipPrimitive.Root delayDuration={50}>\n <TooltipPrimitive.Trigger asChild ref={ref as any}>\n {children}\n </TooltipPrimitive.Trigger>\n <TooltipPrimitive.Portal>\n <TooltipPrimitive.Content {...otherProps} asChild className={className} side={placement} sideOffset={3}>\n <div\n className=\"wcag-purple xs:max-w-[theme(spacing.56)] max-w-[theme(spacing.32)] animate-[fade-in_150ms] rounded-sm px-2 py-1 text-xs font-bold opacity-90\"\n data-taco=\"tooltip\"\n style={{\n transformOrigin: 'var(--radix-tooltip-content-transform-origin)',\n }}>\n <TooltipPrimitive.Arrow className=\"fill-purple stroke-purple -mt-px\" />\n {title}\n </div>\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n </TooltipPrimitive.Root>\n );\n});\n"],"names":["Tooltip","React","props","ref","title","children","placement","otherProps","className","cn","TooltipPrimitive","delayDuration","asChild","side","sideOffset","style","transformOrigin"],"mappings":";;;;MAgBaA,OAAO,gBAAGC,UAAA,CAAiB,SAASD,OAAT,CAAiBE,KAAjB,EAAsCC,GAAtC;EACpC,MAAM;IAAEC,KAAF;IAASC,QAAT;IAAmBC,SAAnB;IAA8B,GAAGC;MAAeL,KAAtD;EACA,MAAMM,SAAS,GAAGC,EAAE,CAAC,SAAD,EAAYF,UAAU,CAACC,SAAvB,CAApB;EAEA,oBACIP,aAAA,CAACS,IAAD;IAAuBC,aAAa,EAAE;GAAtC,eACIV,aAAA,CAACS,OAAD;IAA0BE,OAAO;IAACT,GAAG,EAAEA;GAAvC,EACKE,QADL,CADJ,eAIIJ,aAAA,CAACS,MAAD,MAAA,eACIT,aAAA,CAACS,OAAD,oBAA8BH;IAAYK,OAAO;IAACJ,SAAS,EAAEA;IAAWK,IAAI,EAAEP;IAAWQ,UAAU,EAAE;IAArG,eACIb,aAAA,MAAA;IACIO,SAAS,EAAC;iBACA;IACVO,KAAK,EAAE;MACHC,eAAe,EAAE;;GAJzB,eAMIf,aAAA,CAACS,KAAD;IAAwBF,SAAS,EAAC;GAAlC,CANJ,EAOKJ,KAPL,CADJ,CADJ,CAJJ,CADJ;AAoBH,CAxBsB;;;;"}
|
@@ -3443,13 +3443,15 @@ const Tooltip = /*#__PURE__*/React.forwardRef(function Tooltip(props, ref) {
|
|
3443
3443
|
placement,
|
3444
3444
|
...otherProps
|
3445
3445
|
} = props;
|
3446
|
+
const className = cn('z-[999]', otherProps.className);
|
3446
3447
|
return /*#__PURE__*/React.createElement(TooltipPrimitive.Root, {
|
3447
3448
|
delayDuration: 50
|
3448
3449
|
}, /*#__PURE__*/React.createElement(TooltipPrimitive.Trigger, {
|
3449
3450
|
asChild: true,
|
3450
3451
|
ref: ref
|
3451
|
-
}, children), /*#__PURE__*/React.createElement(TooltipPrimitive.Content, Object.assign({}, otherProps, {
|
3452
|
+
}, children), /*#__PURE__*/React.createElement(TooltipPrimitive.Portal, null, /*#__PURE__*/React.createElement(TooltipPrimitive.Content, Object.assign({}, otherProps, {
|
3452
3453
|
asChild: true,
|
3454
|
+
className: className,
|
3453
3455
|
side: placement,
|
3454
3456
|
sideOffset: 3
|
3455
3457
|
}), /*#__PURE__*/React.createElement("div", {
|
@@ -3460,7 +3462,7 @@ const Tooltip = /*#__PURE__*/React.forwardRef(function Tooltip(props, ref) {
|
|
3460
3462
|
}
|
3461
3463
|
}, /*#__PURE__*/React.createElement(TooltipPrimitive.Arrow, {
|
3462
3464
|
className: "fill-purple stroke-purple -mt-px"
|
3463
|
-
}), title)));
|
3465
|
+
}), title))));
|
3464
3466
|
});
|
3465
3467
|
|
3466
3468
|
const getButtonClasses = () => {
|
@@ -5186,6 +5188,7 @@ const Combobox = /*#__PURE__*/React.forwardRef(function Combobox(props, ref) {
|
|
5186
5188
|
}) : undefined
|
5187
5189
|
})))), /*#__PURE__*/React.createElement(PopoverPrimitive.Content, {
|
5188
5190
|
align: "start",
|
5191
|
+
className: "z-10",
|
5189
5192
|
onOpenAutoFocus: event => {
|
5190
5193
|
event.preventDefault();
|
5191
5194
|
},
|
@@ -7385,6 +7388,7 @@ const BaseSelect = /*#__PURE__*/React.forwardRef(function BaseSelect(props, ref)
|
|
7385
7388
|
name: popover.open ? 'chevron-up' : 'chevron-down'
|
7386
7389
|
}))), /*#__PURE__*/React.createElement(PopoverPrimitive.Content, {
|
7387
7390
|
align: "start",
|
7391
|
+
className: "z-10",
|
7388
7392
|
sideOffset: 4
|
7389
7393
|
}, props.multiselect ? /*#__PURE__*/React.createElement(MultiListbox, Object.assign({}, commonListboxProps)) : /*#__PURE__*/React.createElement(Listbox, Object.assign({}, commonListboxProps))), /*#__PURE__*/React.createElement("input", Object.assign({}, input, {
|
7390
7394
|
className: "hidden",
|
@@ -7731,32 +7735,53 @@ const compareBasic = (a, b) => {
|
|
7731
7735
|
return a === b ? 0 : a > b ? 1 : -1;
|
7732
7736
|
};
|
7733
7737
|
|
7734
|
-
const
|
7735
|
-
|
7736
|
-
|
7737
|
-
|
7738
|
-
|
7739
|
-
|
7740
|
-
|
7741
|
-
|
7742
|
-
|
7743
|
-
return compareBasic(a, b);
|
7744
|
-
},
|
7745
|
-
number: (rowA, rowB, columnId) => {
|
7746
|
-
const a = getNumber(rowA.values[columnId]);
|
7747
|
-
const b = getNumber(rowB.values[columnId]);
|
7748
|
-
return compareBasic(a, b);
|
7749
|
-
},
|
7750
|
-
boolean: (rowA, rowB, columnId) => {
|
7751
|
-
const a = !!rowA.values[columnId];
|
7752
|
-
const b = !!rowB.values[columnId];
|
7753
|
-
return compareBasic(a, b);
|
7754
|
-
},
|
7755
|
-
auto: (rowA, rowB, columnId) => {
|
7756
|
-
const a = guess(rowA.values[columnId]);
|
7757
|
-
const b = guess(rowB.values[columnId]);
|
7758
|
-
return compareBasic(a, b);
|
7738
|
+
const stringsLocaleCompare = (a, b, locale) => {
|
7739
|
+
// In some browsers 'localCompare' may return -2 or 2 instead of -1 or 1
|
7740
|
+
const compareResult = a.localeCompare(b, locale);
|
7741
|
+
return compareResult === 0 ? 0 : compareResult > 0 ? 1 : -1;
|
7742
|
+
};
|
7743
|
+
|
7744
|
+
const compareBasicStrings = (a, b, locale) => {
|
7745
|
+
if (a && b) {
|
7746
|
+
return stringsLocaleCompare(a, b, locale);
|
7759
7747
|
}
|
7748
|
+
|
7749
|
+
return compareBasic(a, b);
|
7750
|
+
};
|
7751
|
+
|
7752
|
+
const sortTypes = locale => {
|
7753
|
+
return {
|
7754
|
+
datetime: (rowA, rowB, columnId) => {
|
7755
|
+
const a = getTime(rowA.values[columnId]);
|
7756
|
+
const b = getTime(rowB.values[columnId]);
|
7757
|
+
return compareBasic(a, b);
|
7758
|
+
},
|
7759
|
+
string: (rowA, rowB, columnId) => {
|
7760
|
+
const a = getString(rowA.values[columnId]);
|
7761
|
+
const b = getString(rowB.values[columnId]);
|
7762
|
+
return compareBasicStrings(a, b, locale);
|
7763
|
+
},
|
7764
|
+
number: (rowA, rowB, columnId) => {
|
7765
|
+
const a = getNumber(rowA.values[columnId]);
|
7766
|
+
const b = getNumber(rowB.values[columnId]);
|
7767
|
+
return compareBasic(a, b);
|
7768
|
+
},
|
7769
|
+
boolean: (rowA, rowB, columnId) => {
|
7770
|
+
const a = !!rowA.values[columnId];
|
7771
|
+
const b = !!rowB.values[columnId];
|
7772
|
+
return compareBasic(a, b);
|
7773
|
+
},
|
7774
|
+
auto: (rowA, rowB, columnId) => {
|
7775
|
+
const a = guess(rowA.values[columnId]);
|
7776
|
+
const b = guess(rowB.values[columnId]);
|
7777
|
+
|
7778
|
+
if (typeof a === 'string' && typeof b === 'string') {
|
7779
|
+
return compareBasicStrings(a, b, locale);
|
7780
|
+
} else {
|
7781
|
+
return compareBasic(a, b);
|
7782
|
+
}
|
7783
|
+
}
|
7784
|
+
};
|
7760
7785
|
};
|
7761
7786
|
|
7762
7787
|
const pluginName = 'useRowEditing';
|
@@ -8551,7 +8576,8 @@ const useTable = (props, ref) => {
|
|
8551
8576
|
}
|
8552
8577
|
|
8553
8578
|
const {
|
8554
|
-
texts
|
8579
|
+
texts,
|
8580
|
+
locale
|
8555
8581
|
} = useLocalization();
|
8556
8582
|
const {
|
8557
8583
|
columns,
|
@@ -8588,7 +8614,7 @@ const useTable = (props, ref) => {
|
|
8588
8614
|
autoResetSelectedRows: false,
|
8589
8615
|
autoResetSortBy: false,
|
8590
8616
|
autoResetPage: false,
|
8591
|
-
sortTypes: React__default.useMemo(() => sortTypes, []),
|
8617
|
+
sortTypes: React__default.useMemo(() => sortTypes(locale), []),
|
8592
8618
|
useControlledState: currentState => {
|
8593
8619
|
return React__default.useMemo(() => ({ ...currentState,
|
8594
8620
|
selectedRowIds: selectedRows || []
|