@economic/taco 2.23.0 → 2.24.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Card/Card.d.ts +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +2 -0
- package/dist/components/Provider/Localization.d.ts +4 -0
- package/dist/components/Report/components/Body/Body.d.ts +0 -1
- package/dist/components/Report/components/Footer/Summary.d.ts +0 -1
- package/dist/components/Report/components/Toolbar/components/Filters/components/Filter.d.ts +2 -2
- package/dist/components/Report/components/Toolbar/components/Filters/components/FilterColumn.d.ts +5 -2
- package/dist/components/Report/useReport.d.ts +0 -1
- package/dist/components/Select2/Select2.d.ts +4 -0
- package/dist/components/Select2/hooks/useChildren.d.ts +1 -0
- package/dist/components/Table3/components/toolbar/Filter/filters/components/Filter.d.ts +2 -2
- package/dist/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.d.ts +5 -2
- package/dist/esm/index.css +55 -46
- package/dist/esm/packages/taco/src/components/Button/util.js +8 -8
- package/dist/esm/packages/taco/src/components/Button/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Card/Card.js +2 -1
- package/dist/esm/packages/taco/src/components/Card/Card.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js +11 -2
- package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Listbox/ScrollableList.js +1 -1
- package/dist/esm/packages/taco/src/components/Provider/Localization.js +5 -1
- package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/Report.js +3 -8
- package/dist/esm/packages/taco/src/components/Report/Report.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/components/Body/Body.js +1 -2
- package/dist/esm/packages/taco/src/components/Report/components/Body/Body.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/components/Footer/Footer.js +14 -2
- package/dist/esm/packages/taco/src/components/Report/components/Footer/Footer.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/components/Footer/Summary.js +2 -2
- package/dist/esm/packages/taco/src/components/Report/components/Footer/Summary.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/components/Internal/Selection.js +47 -11
- package/dist/esm/packages/taco/src/components/Report/components/Internal/Selection.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/ManageFiltersPopover.js +28 -43
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/ManageFiltersPopover.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Filter.js +14 -7
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Filter.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterColumn.js +4 -3
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterColumn.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Print/Print.js +10 -8
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Print/Print.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/listeners/useTableRowActiveListener.js +2 -2
- package/dist/esm/packages/taco/src/components/Report/listeners/useTableRowActiveListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/styles/useCssGridStylesheet.js +7 -4
- package/dist/esm/packages/taco/src/components/Report/styles/useCssGridStylesheet.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/util/useTableGlobalShortcuts.js +3 -10
- package/dist/esm/packages/taco/src/components/Report/util/useTableGlobalShortcuts.js.map +1 -1
- package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js +2 -1
- package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/Select2.js +43 -4
- package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/hooks/useChildren.js +1 -1
- package/dist/esm/packages/taco/src/components/Select2/hooks/useChildren.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +4 -6
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Selection.js +66 -14
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Selection.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js +27 -44
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Filter.js +14 -7
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Filter.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.js +4 -3
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintButton.js +2 -0
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintButton.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSettings.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js +3 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js +10 -3
- package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js.map +1 -1
- package/dist/esm/packages/taco/src/hooks/useLocalStorage.js.map +1 -1
- package/dist/esm/packages/taco/src/index.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Button.js +1 -0
- package/dist/esm/packages/taco/src/primitives/Button.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTablePrinting.js +24 -4
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTablePrinting.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableSettings.js +1 -2
- package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableSettings.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableSettingsListener.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableSettingsListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/useTable.js +7 -5
- package/dist/esm/packages/taco/src/primitives/Table/useTable/useTable.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/columns.js +33 -7
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/columns.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/settings.js +0 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/util/settings.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/dom.js +12 -3
- package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/keyboard.js +2 -2
- package/dist/esm/packages/taco/src/utils/keyboard.js.map +1 -1
- package/dist/hooks/useLocalStorage.d.ts +2 -1
- package/dist/index.css +55 -46
- package/dist/primitives/Table/types.d.ts +0 -2
- package/dist/primitives/Table/useTable/features/useTablePrinting.d.ts +10 -3
- package/dist/primitives/Table/useTable/useTable.d.ts +1 -1
- package/dist/primitives/Table/useTable/util/settings.d.ts +0 -1
- package/dist/taco.cjs.development.js +511 -387
- 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/dom.d.ts +3 -1
- package/package.json +2 -2
- package/types.json +6781 -6993
- package/dist/components/Report/components/Toolbar/components/Filters/components/Placeholder.d.ts +0 -12
- package/dist/components/Table3/components/toolbar/Filter/filters/components/Placeholder.d.ts +0 -12
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Placeholder.js +0 -41
- package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Placeholder.js.map +0 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Placeholder.js +0 -41
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Placeholder.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"FilterComparator.js","sources":["../../../../../../../../../../../../src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.tsx"],"sourcesContent":["import React from 'react';\nimport { Column as RTColumn, ColumnMeta } from '@tanstack/react-table';\nimport { Select2, Select2Props } from '../../../../../../Select2/Select2';\nimport { Table3FilterComparator } from '../../../../../types';\nimport { LocalizationTexts, useLocalization } from '../../../../../../Provider/Localization';\n\nexport type FilterComparatorProps<TType = unknown> = Omit<Select2Props, 'children'> & {\n column?: RTColumn<TType, unknown>;\n};\n\nexport function FilterComparator<TType = unknown>(props: FilterComparatorProps<TType>) {\n const { column, onChange: handleChange, value, ...attributes } = props;\n const { texts } = useLocalization();\n\n const validComparators = guessComparatorsBasedOnControl(column);\n\n React.useEffect(() => {\n if (value === undefined || !validComparators.includes(value as Table3FilterComparator)) {\n handleChange?.(validComparators[0]);\n }\n }, [validComparators]);\n\n return (\n <Select2 {...attributes} className=\"!w-32 flex-shrink-0\" disabled={!column} onChange={handleChange} value={value}>\n {validComparators.map(comparator => (\n <Select2.Option key={comparator} value={comparator}>\n {getComparatorText(comparator, texts, column)}\n </Select2.Option>\n ))}\n </Select2>\n );\n}\n\nfunction guessComparatorsBasedOnControl<TType = unknown>(column?: RTColumn<TType, unknown>): Table3FilterComparator[] {\n const columnMeta = (column?.columnDef.meta ?? {}) as ColumnMeta<TType, unknown>;\n\n if (Array.isArray(columnMeta.filters)) {\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n return columnMeta.filters;\n }\n\n if (typeof columnMeta.control === 'function') {\n const renderedControl = columnMeta.control({\n onBlur: () => undefined,\n onFocus: () => undefined,\n setValue: () => undefined,\n value: undefined,\n disabled: false,\n readOnly: false,\n ref: undefined as any,\n });\n\n if (React.isValidElement(renderedControl)) {\n const { props, type } = renderedControl as any;\n\n if (type.displayName === 'Select2') {\n if (props.multiple) {\n return [\n Table3FilterComparator.HasAnyOf,\n Table3FilterComparator.HasAllOf,\n Table3FilterComparator.IsEqualTo,\n Table3FilterComparator.HasNoneOf,\n Table3FilterComparator.IsEmpty,\n Table3FilterComparator.IsNotEmpty,\n ];\n }\n\n return [\n Table3FilterComparator.IsEqualTo,\n Table3FilterComparator.IsNotEqualTo,\n Table3FilterComparator.IsEmpty,\n Table3FilterComparator.IsNotEmpty,\n ];\n }\n }\n }\n\n if (columnMeta.dataType === 'number') {\n return [\n Table3FilterComparator.IsEqualTo,\n Table3FilterComparator.IsNotEqualTo,\n Table3FilterComparator.IsGreaterThan,\n Table3FilterComparator.IsLessThan,\n Table3FilterComparator.IsBetween,\n Table3FilterComparator.IsEmpty,\n Table3FilterComparator.IsNotEmpty,\n ];\n }\n\n if (columnMeta.control === 'datepicker' || columnMeta.dataType === 'datetime') {\n return [\n Table3FilterComparator.IsEqualTo,\n Table3FilterComparator.IsNotEqualTo,\n Table3FilterComparator.IsBetween,\n Table3FilterComparator.IsLessThan,\n Table3FilterComparator.IsGreaterThan,\n Table3FilterComparator.IsEmpty,\n Table3FilterComparator.IsNotEmpty,\n Table3FilterComparator.IsLessThanOrEqualTo,\n Table3FilterComparator.IsGreaterThanOrEqualTo,\n ];\n }\n\n if (columnMeta.control === 'switch') {\n return [Table3FilterComparator.IsEqualTo];\n }\n\n return [\n Table3FilterComparator.Contains,\n Table3FilterComparator.DoesNotContain,\n Table3FilterComparator.IsEqualTo,\n Table3FilterComparator.IsNotEqualTo,\n Table3FilterComparator.IsEmpty,\n Table3FilterComparator.IsNotEmpty,\n ];\n}\n\nfunction getComparatorText<TType = unknown>(\n comparator: Table3FilterComparator,\n texts: LocalizationTexts,\n column?: RTColumn<TType, unknown>\n) {\n const isDate = column?.columnDef?.meta?.control === 'datepicker';\n\n switch (comparator) {\n case Table3FilterComparator.Contains:\n return texts.table3.filters.comparators.contains;\n\n case Table3FilterComparator.DoesNotContain:\n return texts.table3.filters.comparators.doesNotContain;\n\n case Table3FilterComparator.IsEqualTo:\n return texts.table3.filters.comparators.isEqualTo;\n\n case Table3FilterComparator.IsNotEqualTo:\n return texts.table3.filters.comparators.isNotEqualTo;\n\n case Table3FilterComparator.IsGreaterThan:\n return isDate ? texts.table3.filters.comparators.isAfter : texts.table3.filters.comparators.isGreaterThan;\n\n case Table3FilterComparator.IsLessThan:\n return isDate ? texts.table3.filters.comparators.isBefore : texts.table3.filters.comparators.isLessThan;\n\n case Table3FilterComparator.IsBetween:\n return texts.table3.filters.comparators.isBetween;\n\n case Table3FilterComparator.IsEmpty:\n return texts.table3.filters.comparators.isEmpty;\n\n case Table3FilterComparator.IsNotEmpty:\n return texts.table3.filters.comparators.isNotEmpty;\n\n case Table3FilterComparator.IsLessThanOrEqualTo:\n return isDate ? texts.table3.filters.comparators.isOnOrBefore : texts.table3.filters.comparators.isLessThanOrEqualTo;\n\n case Table3FilterComparator.IsGreaterThanOrEqualTo:\n return isDate\n ? texts.table3.filters.comparators.isOnOrAfter\n : texts.table3.filters.comparators.isGreaterThanOrEqualTo;\n\n case Table3FilterComparator.HasAnyOf:\n return texts.table3.filters.comparators.hasAnyOf;\n\n case Table3FilterComparator.HasAllOf:\n return texts.table3.filters.comparators.hasAllOf;\n\n case Table3FilterComparator.HasNoneOf:\n return texts.table3.filters.comparators.hasNoneOf;\n\n default:\n return '';\n }\n}\n"],"names":["FilterComparator","props","column","onChange","handleChange","value","attributes","texts","useLocalization","validComparators","guessComparatorsBasedOnControl","React","useEffect","undefined","includes","Select2","className","disabled","map","comparator","Option","key","getComparatorText","columnMeta","_column$columnDef$met","columnDef","meta","Array","isArray","filters","control","renderedControl","onBlur","onFocus","setValue","readOnly","ref","isValidElement","type","displayName","multiple","Table3FilterComparator","HasAnyOf","HasAllOf","IsEqualTo","HasNoneOf","IsEmpty","IsNotEmpty","IsNotEqualTo","dataType","IsGreaterThan","IsLessThan","IsBetween","IsLessThanOrEqualTo","IsGreaterThanOrEqualTo","Contains","DoesNotContain","isDate","_column$columnDef","_column$columnDef$met2","table3","comparators","contains","doesNotContain","isEqualTo","isNotEqualTo","isAfter","isGreaterThan","isBefore","isLessThan","isBetween","isEmpty","isNotEmpty","isOnOrBefore","isLessThanOrEqualTo","isOnOrAfter","isGreaterThanOrEqualTo","hasAnyOf","hasAllOf","hasNoneOf"],"mappings":";;;;;SAUgBA,gBAAgBA,CAAkBC,KAAmC;EACjF,MAAM;IAAEC,MAAM;IAAEC,QAAQ,EAAEC,YAAY;IAAEC,KAAK;IAAE,GAAGC;GAAY,GAAGL,KAAK;EACtE,MAAM;IAAEM;GAAO,GAAGC,eAAe,EAAE;EAEnC,MAAMC,gBAAgB,GAAGC,8BAA8B,CAACR,MAAM,CAAC;EAE/DS,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIP,KAAK,KAAKQ,SAAS,IAAI,CAACJ,gBAAgB,CAACK,QAAQ,CAACT,KAA+B,CAAC,EAAE;MACpFD,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAGK,gBAAgB,CAAC,CAAC,CAAC,CAAC;;GAE1C,EAAE,CAACA,gBAAgB,CAAC,CAAC;EAEtB,oBACIE,6BAACI,OAAO,oBAAKT,UAAU;IAAEU,SAAS,EAAC,qBAAqB;IAACC,QAAQ,EAAE,CAACf,MAAM;IAAEC,QAAQ,EAAEC,YAAY;IAAEC,KAAK,EAAEA;MACtGI,gBAAgB,CAACS,GAAG,CAACC,UA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U;IAEtD,KAAK/B,sBAAsB,CAACY,mBAAmB;MAC3C,OAAOI,MAAM,GAAGlD,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACY,YAAY,GAAGlE,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACa,mBAAmB;IAExH,KAAKjC,sBAAsB,CAACa,sBAAsB;MAC9C,OAAOG,MAAM,GACPlD,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACc,WAAW,GAC5CpE,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACe,sBAAsB;IAEjE,KAAKnC,sBAAsB,CAACC,QAAQ;MAChC,OAAOnC,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACgB,QAAQ;IAEpD,KAAKpC,sBAAsB,CAACE,QAAQ;MAChC,OAAOpC,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACiB,QAAQ;IAEpD,KAAKrC,sBAAsB,CAACI,SAAS;MACjC,OAAOtC,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACkB,SAAS;IAErD;MACI,OAAO,EAAE;;AAErB;;;;"}
|
1
|
+
{"version":3,"file":"FilterComparator.js","sources":["../../../../../../../../../../../../src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.tsx"],"sourcesContent":["import React from 'react';\nimport { Column as RTColumn, ColumnMeta } from '@tanstack/react-table';\nimport { Select2, Select2Props } from '../../../../../../Select2/Select2';\nimport { Table3FilterComparator } from '../../../../../types';\nimport { LocalizationTexts, useLocalization } from '../../../../../../Provider/Localization';\n\nexport type FilterComparatorProps<TType = unknown> = Omit<Select2Props, 'children'> & {\n column?: RTColumn<TType, unknown>;\n};\n\nexport function FilterComparator<TType = unknown>(props: FilterComparatorProps<TType>) {\n const { column, onChange: handleChange, value, ...attributes } = props;\n const { texts } = useLocalization();\n\n const validComparators = guessComparatorsBasedOnControl(column);\n\n React.useEffect(() => {\n if (value === undefined || !validComparators.includes(value as Table3FilterComparator)) {\n handleChange?.(validComparators[0]);\n }\n }, [validComparators]);\n\n return (\n <Select2\n {...attributes}\n className=\"focus:yt-focus !w-32 flex-shrink-0\"\n disabled={!column}\n onChange={handleChange}\n value={value}>\n {validComparators.map(comparator => (\n <Select2.Option key={comparator} value={comparator}>\n {getComparatorText(comparator, texts, column)}\n </Select2.Option>\n ))}\n </Select2>\n );\n}\n\nfunction guessComparatorsBasedOnControl<TType = unknown>(column?: RTColumn<TType, unknown>): Table3FilterComparator[] {\n const columnMeta = (column?.columnDef.meta ?? {}) as ColumnMeta<TType, unknown>;\n\n if (Array.isArray(columnMeta.filters)) {\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n return columnMeta.filters;\n }\n\n if (typeof columnMeta.control === 'function') {\n const renderedControl = columnMeta.control({\n onBlur: () => undefined,\n onFocus: () => undefined,\n setValue: () => undefined,\n value: undefined,\n disabled: false,\n readOnly: false,\n ref: undefined as any,\n });\n\n if (React.isValidElement(renderedControl)) {\n const { props, type } = renderedControl as any;\n\n if (type.displayName === 'Select2') {\n if (props.multiple) {\n return [\n Table3FilterComparator.HasAnyOf,\n Table3FilterComparator.HasAllOf,\n Table3FilterComparator.IsEqualTo,\n Table3FilterComparator.HasNoneOf,\n Table3FilterComparator.IsEmpty,\n Table3FilterComparator.IsNotEmpty,\n ];\n }\n\n return [\n Table3FilterComparator.IsEqualTo,\n Table3FilterComparator.IsNotEqualTo,\n Table3FilterComparator.IsEmpty,\n Table3FilterComparator.IsNotEmpty,\n ];\n }\n }\n }\n\n if (columnMeta.dataType === 'number') {\n return [\n Table3FilterComparator.IsEqualTo,\n Table3FilterComparator.IsNotEqualTo,\n Table3FilterComparator.IsGreaterThan,\n Table3FilterComparator.IsLessThan,\n Table3FilterComparator.IsBetween,\n Table3FilterComparator.IsEmpty,\n Table3FilterComparator.IsNotEmpty,\n ];\n }\n\n if (columnMeta.control === 'datepicker' || columnMeta.dataType === 'datetime') {\n return [\n Table3FilterComparator.IsEqualTo,\n Table3FilterComparator.IsNotEqualTo,\n Table3FilterComparator.IsBetween,\n Table3FilterComparator.IsLessThan,\n Table3FilterComparator.IsGreaterThan,\n Table3FilterComparator.IsEmpty,\n Table3FilterComparator.IsNotEmpty,\n Table3FilterComparator.IsLessThanOrEqualTo,\n Table3FilterComparator.IsGreaterThanOrEqualTo,\n ];\n }\n\n if (columnMeta.control === 'switch') {\n return [Table3FilterComparator.IsEqualTo];\n }\n\n return [\n Table3FilterComparator.Contains,\n Table3FilterComparator.DoesNotContain,\n Table3FilterComparator.IsEqualTo,\n Table3FilterComparator.IsNotEqualTo,\n Table3FilterComparator.IsEmpty,\n Table3FilterComparator.IsNotEmpty,\n ];\n}\n\nfunction getComparatorText<TType = unknown>(\n comparator: Table3FilterComparator,\n texts: LocalizationTexts,\n column?: RTColumn<TType, unknown>\n) {\n const isDate = column?.columnDef?.meta?.control === 'datepicker';\n\n switch (comparator) {\n case Table3FilterComparator.Contains:\n return texts.table3.filters.comparators.contains;\n\n case Table3FilterComparator.DoesNotContain:\n return texts.table3.filters.comparators.doesNotContain;\n\n case Table3FilterComparator.IsEqualTo:\n return texts.table3.filters.comparators.isEqualTo;\n\n case Table3FilterComparator.IsNotEqualTo:\n return texts.table3.filters.comparators.isNotEqualTo;\n\n case Table3FilterComparator.IsGreaterThan:\n return isDate ? texts.table3.filters.comparators.isAfter : texts.table3.filters.comparators.isGreaterThan;\n\n case Table3FilterComparator.IsLessThan:\n return isDate ? texts.table3.filters.comparators.isBefore : texts.table3.filters.comparators.isLessThan;\n\n case Table3FilterComparator.IsBetween:\n return texts.table3.filters.comparators.isBetween;\n\n case Table3FilterComparator.IsEmpty:\n return texts.table3.filters.comparators.isEmpty;\n\n case Table3FilterComparator.IsNotEmpty:\n return texts.table3.filters.comparators.isNotEmpty;\n\n case Table3FilterComparator.IsLessThanOrEqualTo:\n return isDate ? texts.table3.filters.comparators.isOnOrBefore : texts.table3.filters.comparators.isLessThanOrEqualTo;\n\n case Table3FilterComparator.IsGreaterThanOrEqualTo:\n return isDate\n ? texts.table3.filters.comparators.isOnOrAfter\n : texts.table3.filters.comparators.isGreaterThanOrEqualTo;\n\n case Table3FilterComparator.HasAnyOf:\n return texts.table3.filters.comparators.hasAnyOf;\n\n case Table3FilterComparator.HasAllOf:\n return texts.table3.filters.comparators.hasAllOf;\n\n case Table3FilterComparator.HasNoneOf:\n return texts.table3.filters.comparators.hasNoneOf;\n\n default:\n return '';\n }\n}\n"],"names":["FilterComparator","props","column","onChange","handleChange","value","attributes","texts","useLocalization","validComparators","guessComparatorsBasedOnControl","React","useEffect","undefined","includes","Select2","className","disabled","map","comparator","Option","key","getComparatorText","columnMeta","_column$columnDef$met","columnDef","meta","Array","isArray","filters","control","renderedControl","onBlur","onFocus","setValue","readOnly","ref","isValidElement","type","displayName","multiple","Table3FilterComparator","HasAnyOf","HasAllOf","IsEqualTo","HasNoneOf","IsEmpty","IsNotEmpty","IsNotEqualTo","dataType","IsGreaterThan","IsLessThan","IsBetween","IsLessThanOrEqualTo","IsGreaterThanOrEqualTo","Contains","DoesNotContain","isDate","_column$columnDef","_column$columnDef$met2","table3","comparators","contains","doesNotContain","isEqualTo","isNotEqualTo","isAfter","isGreaterThan","isBefore","isLessThan","isBetween","isEmpty","isNotEmpty","isOnOrBefore","isLessThanOrEqualTo","isOnOrAfter","isGreaterThanOrEqualTo","hasAnyOf","hasAllOf","hasNoneOf"],"mappings":";;;;;SAUgBA,gBAAgBA,CAAkBC,KAAmC;EACjF,MAAM;IAAEC,MAAM;IAAEC,QAAQ,EAAEC,YAAY;IAAEC,KAAK;IAAE,GAAGC;GAAY,GAAGL,KAAK;EACtE,MAAM;IAAEM;GAAO,GAAGC,eAAe,EAAE;EAEnC,MAAMC,gBAAgB,GAAGC,8BAA8B,CAACR,MAAM,CAAC;EAE/DS,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIP,KAAK,KAAKQ,S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AM,CAAC/B,OAAO,CAACgC,WAAW,CAACQ,UAAU;IAE3G,KAAK5B,sBAAsB,CAACW,SAAS;MACjC,OAAO7C,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACS,SAAS;IAErD,KAAK7B,sBAAsB,CAACK,OAAO;MAC/B,OAAOvC,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACU,OAAO;IAEnD,KAAK9B,sBAAsB,CAACM,UAAU;MAClC,OAAOxC,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACW,UAAU;IAEtD,KAAK/B,sBAAsB,CAACY,mBAAmB;MAC3C,OAAOI,MAAM,GAAGlD,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACY,YAAY,GAAGlE,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACa,mBAAmB;IAExH,KAAKjC,sBAAsB,CAACa,sBAAsB;MAC9C,OAAOG,MAAM,GACPlD,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACc,WAAW,GAC5CpE,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACe,sBAAsB;IAEjE,KAAKnC,sBAAsB,CAACC,QAAQ;MAChC,OAAOnC,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACgB,QAAQ;IAEpD,KAAKpC,sBAAsB,CAACE,QAAQ;MAChC,OAAOpC,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACiB,QAAQ;IAEpD,KAAKrC,sBAAsB,CAACI,SAAS;MACjC,OAAOtC,KAAK,CAACqD,MAAM,CAAC/B,OAAO,CAACgC,WAAW,CAACkB,SAAS;IAErD;MACI,OAAO,EAAE;;AAErB;;;;"}
|
package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintButton.js
CHANGED
@@ -23,6 +23,7 @@ function PrintButton(props) {
|
|
23
23
|
const buttonRef = React__default.useRef(null);
|
24
24
|
const tableMeta = table.options.meta;
|
25
25
|
const state = table.getState();
|
26
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
26
27
|
const {
|
27
28
|
isWarningVisibleForLargeDatasets
|
28
29
|
} = tableMeta.printing;
|
@@ -201,6 +202,7 @@ function PrintButton(props) {
|
|
201
202
|
onAccept: handleWarningDialogAccept,
|
202
203
|
onClose: handleWarningDialogClose,
|
203
204
|
onCancel: handleWarningDialogCancel,
|
205
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
204
206
|
onVisibilityChange: tableMeta.printing.setIsWarningVisibleForLargeDatasets
|
205
207
|
}));
|
206
208
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PrintButton.js","sources":["../../../../../../../../../../src/components/Table3/components/toolbar/PrintButton/PrintButton.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { ToastReference, useToast } from '../../../../Toast/Toaster';\nimport { PrintIFrame } from './PrintIFrame';\nimport { Table3ColumnProps, Table3Props } from '../../../types';\nimport { WarningDialog } from './WarningDialog';\nimport { Shortcut } from '../../../../Shortcut/Shortcut';\n\nconst SAFE_PRINT_CELL_COUNT = 10000;\n\nexport type PrintButtonProps<TType = unknown> = React.HTMLAttributes<HTMLButtonElement> & {\n table: RTable<TType>;\n tableProps: Table3Props<TType>;\n};\n\nexport function PrintButton<TType = unknown>(props: PrintButtonProps<TType>) {\n const { table, tableProps } = props;\n const { texts } = useLocalization();\n const toast = useToast();\n\n const [isCurrentlyPrinting, setIsCurrentlyPrinting] = React.useState(false);\n const [showWarningDialog, setShowWarningDialog] = React.useState(false);\n const loadingToastRef = React.useRef<ToastReference | null>(null);\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n\n const tableMeta = table.options.meta as TableMeta<TType>;\n const state = table.getState();\n const { isWarningVisibleForLargeDatasets } = tableMeta.printing;\n\n // When changing printTableId, update packages/taco/src/components/Table3/Table3.tsx file and other usages where\n // printTableId is used to figure out whether the table is a print table or not.\n const printTableId = `${tableProps.id}_print`;\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n const excludeUnmatchedResults = tableMeta.search.excludeUnmatchedResults;\n\n const defaultSettings = React.useMemo(\n () => ({\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n columnFreezingIndex: tableMeta.columnFreezing.frozenColumnIndex,\n columnOrder: state.columnOrder,\n columnSizing: state.columnSizing,\n columnVisibility: state.columnVisibility,\n excludeUnmatchedRecordsInSearch: excludeUnmatchedResults,\n fontSize: tableMeta.fontSize.size,\n rowHeight: tableMeta.rowHeight.height,\n sorting: state.sorting,\n // we don't save these, but we must pass them to print\n columnFilters: state.columnFilters,\n globalFilter: state.globalFilter,\n }),\n [\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n tableMeta.columnFreezing.frozenColumnIndex,\n state.columnOrder,\n state.columnSizing,\n state.columnVisibility,\n excludeUnmatchedResults,\n tableMeta.fontSize.size,\n tableMeta.rowHeight.height,\n state.sorting,\n state.columnFilters,\n state.globalFilter,\n ]\n );\n\n const iframeTableChildren = React.useMemo(\n () =>\n (React.Children.toArray(tableProps.children) as React.ReactElement<Table3ColumnProps<TType>>[]).filter(child => {\n const enableColumnInPrinting = child.props?.enablePrinting;\n\n // For table children, only include columns doesn't have 'false' value for enablePrinting prop.\n if (React.isValidElement<Table3ColumnProps<TType>>(child) && enableColumnInPrinting === false) {\n return false;\n }\n\n return true;\n }),\n [tableProps.children]\n );\n\n const iframeTableProps = {\n ...tableProps,\n children: iframeTableChildren,\n defaultSettings,\n id: printTableId,\n };\n\n const handleLoadingError = (error: any) => {\n const errorMessage = `${texts.table3.print.error}: ${error}`;\n\n console.error(errorMessage);\n loadingToastRef.current?.error(errorMessage);\n };\n\n const restoreTableDataWithoutSearch = async () => {\n try {\n await tableMeta.server.loadAll?.(table.getState().sorting, table.getState().columnFilters, undefined);\n } catch (error) {\n handleLoadingError(error);\n return;\n }\n };\n\n const handleAfterPrint = async () => {\n if (tableMeta.server.loadAll && excludeUnmatchedResults) {\n await restoreTableDataWithoutSearch();\n }\n setIsCurrentlyPrinting(false);\n loadingToastRef.current?.close();\n };\n\n const handleBeforePrint = () => {\n loadingToastRef.current?.close();\n };\n\n const handlePrint = async () => {\n loadingToastRef.current = toast.loading(texts.table3.print.loading as any);\n\n const getCellCount = (data: TType[]) => (data.length ? data.length * Object.keys(data[0]).length : 0);\n let hasNonSafeCellCount = false;\n\n // if loadAll is not defined, just print with what we've got\n // don't compare length to data.length because the api might be choosing not to return all for performance\n if (!tableMeta.server.loadAll) {\n const { data } = tableProps;\n const cellCount = getCellCount(data);\n\n hasNonSafeCellCount = cellCount > SAFE_PRINT_CELL_COUNT;\n } else {\n try {\n await tableMeta.server.loadAll(\n table.getState().sorting,\n table.getState().columnFilters,\n // We need to pass search query to the server when printing, to be able to render correct data set in iFrame,\n // But in \"display\" table, search is performed only on client side, so we'll need to request data again without search query,\n // when printing will be finished.\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n excludeUnmatchedResults ? tableMeta.search.query : undefined\n );\n\n // After the loadAll call above, the data changes. Hence, it becomes essential to acquire the data after\n // this call rather than before it.\n const { data } = tableProps;\n const cellCount = getCellCount(data);\n\n hasNonSafeCellCount = cellCount > SAFE_PRINT_CELL_COUNT;\n } catch (error) {\n handleLoadingError(error);\n\n // in case of error, we return early\n return;\n }\n }\n\n if (hasNonSafeCellCount && isWarningVisibleForLargeDatasets) {\n setShowWarningDialog(true);\n } else {\n // only set printing (mount the iframe) when the data has loaded, it prevents repaint performance slow downs\n setIsCurrentlyPrinting(true);\n }\n };\n\n const shortcut = { key: 'p', meta: true, shift: false };\n const tooltip = (\n <>\n {texts.table3.print.tooltip}\n <Shortcut className=\"ml-2\" keys={shortcut} />\n </>\n );\n\n const handleWarningDialogAccept = () => {\n setIsCurrentlyPrinting(true);\n };\n\n const handleWarningDialogCancel = async () => {\n if (tableMeta.server.loadAll && excludeUnmatchedResults) {\n await restoreTableDataWithoutSearch();\n }\n };\n\n const handleWarningDialogClose = () => {\n loadingToastRef.current?.close();\n setShowWarningDialog(false);\n };\n\n return (\n <>\n <IconButton\n disabled={isCurrentlyPrinting}\n icon=\"print\"\n onClick={handlePrint}\n aria-label={texts.table3.print.tooltip}\n tooltip={tooltip}\n ref={buttonRef}\n shortcut={shortcut}\n />\n {isCurrentlyPrinting && iframeTableProps.data !== null && (\n <PrintIFrame\n onAfterPrint={handleAfterPrint}\n onBeforePrint={handleBeforePrint}\n tableProps={iframeTableProps as Table3Props<TType>}\n />\n )}\n <WarningDialog\n open={showWarningDialog}\n onAccept={handleWarningDialogAccept}\n onClose={handleWarningDialogClose}\n onCancel={handleWarningDialogCancel}\n onVisibilityChange={tableMeta.printing.setIsWarningVisibleForLargeDatasets}\n />\n </>\n );\n}\n"],"names":["SAFE_PRINT_CELL_COUNT","PrintButton","props","table","tableProps","texts","useLocalization","toast","useToast","isCurrentlyPrinting","setIsCurrentlyPrinting","React","useState","showWarningDialog","setShowWarningDialog","loadingToastRef","useRef","buttonRef","tableMeta","options","meta","state","getState","isWarningVisibleForLargeDatasets","printing","printTableId","id","excludeUnmatchedResults","search","defaultSettings","useMemo","columnFreezingIndex","columnFreezing","frozenColumnIndex","columnOrder","columnSizing","columnVisibility","excludeUnmatchedRecordsInSearch","fontSize","size","rowHeight","height","sorting","columnFilters","globalFilter","iframeTableChildren","Children","toArray","children","filter","child","enableColumnInPrinting","_child$props","enablePrinting","isValidElement","iframeTableProps","handleLoadingError","error","errorMessage","table3","print","console","_loadingToastRef$curr","current","restoreTableDataWithoutSearch","_tableMeta$server$loa","_tableMeta$server","Promise","resolve","server","loadAll","call","undefined","then","_temp","e","reject","handleAfterPrint","_loadingToastRef$curr2","close","_temp2","_temp3","handleBeforePrint","_loadingToastRef$curr3","handlePrint","hasNonSafeCellCount","loading","getCellCount","data","length","Object","keys","_temp5","cellCount","_temp4","_catch","query","_exit","_temp6","shortcut","key","shift","tooltip","Shortcut","className","handleWarningDialogAccept","handleWarningDialogCancel","_temp7","handleWarningDialogClose","_loadingToastRef$curr4","IconButton","disabled","icon","onClick","ref","PrintIFrame","onAfterPrint","onBeforePrint","WarningDialog","open","onAccept","onClose","onCancel","onVisibilityChange","setIsWarningVisibleForLargeDatasets"],"mappings":";;;;;;;;;AAWA,MAAMA,qBAAqB,GAAG,KAAK;SAOnBC,WAAWA,CAAkBC,KAA8B;EACvE,MAAM;IAAEC,KAAK;IAAEC;GAAY,GAAGF,KAAK;EACnC,MAAM;IAAEG;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,KAAK,GAAGC,QAAQ,EAAE;EAExB,MAAM,CAACC,mBAAmB,EAAEC,sBAAsB,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;EAC3E,MAAM,CAACC,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGH,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;EACvE,MAAMG,eAAe,GAAGJ,cAAK,CAACK,MAAM,CAAwB,IAAI,CAAC;EACjE,MAAMC,SAAS,GAAGN,cAAK,CAACK,MAAM,CAAoB,IAAI,CAAC;EAEvD,MAAME,SAAS,GAAGf,KAAK,CAACgB,OAAO,CAACC,IAAwB;EACxD,MAAMC,KAAK,GAAGlB,KAAK,CAACmB,QAAQ,EAAE;EAC9B,MAAM;IAAEC;GAAkC,GAAGL,SAAS,CAACM,QAAQ;;;EAI/D,MAAMC,YAAY,MAAMrB,UAAU,CAACsB,UAAU;;EAE7C,MAAMC,uBAAuB,GAAGT,SAAS,CAACU,MAAM,CAACD,uBAAuB;EAExE,MAAME,eAAe,GAAGlB,cAAK,CAACmB,OAAO,CACjC,OAAO;;IAEHC,mBAAmB,EAAEb,SAAS,CAAC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A,CAAAlC,IAAA;KAE5C,QAAAE,CAAA;MAAA,OAAAR,OAAA,CAAAS,MAAA,CAAAD,CAAA;;;EAED,MAAMiC,wBAAwB,GAAGA;;IAC7B,CAAAC,sBAAA,GAAA9F,eAAe,CAACgD,OAAO,cAAA8C,sBAAA,uBAAvBA,sBAAA,CAAyB9B,KAAK,EAAE;IAChCjE,oBAAoB,CAAC,KAAK,CAAC;GAC9B;EAED,oBACIH,yEACIA,6BAACmG,UAAU;IACPC,QAAQ,EAAEtG,mBAAmB;IAC7BuG,IAAI,EAAC,OAAO;IACZC,OAAO,EAAE7B,WAAW;kBACR/E,KAAK,CAACsD,MAAM,CAACC,KAAK,CAAC0C,OAAO;IACtCA,OAAO,EAAEA,OAAO;IAChBY,GAAG,EAAEjG,SAAS;IACdkF,QAAQ,EAAEA;IACZ,EACD1F,mBAAmB,IAAI8C,gBAAgB,CAACiC,IAAI,KAAK,IAAI,mBAClD7E,6BAACwG,WAAW;IACRC,YAAY,EAAEvC,gBAAgB;IAC9BwC,aAAa,EAAEnC,iBAAiB;IAChC9E,UAAU,EAAEmD;IACd,CACL,eACD5C,6BAAC2G,aAAa;IACVC,IAAI,EAAE1G,iBAAiB;IACvB2G,QAAQ,EAAEf,yBAAyB;IACnCgB,OAAO,EAAEb,wBAAwB;IACjCc,QAAQ,EAAEhB,yBAAyB;IACnCiB,kBAAkB,EAAEzG,SAAS,CAACM,QAAQ,CAACoG;IACzC,CACH;AAEX;;;;"}
|
1
|
+
{"version":3,"file":"PrintButton.js","sources":["../../../../../../../../../../src/components/Table3/components/toolbar/PrintButton/PrintButton.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { ToastReference, useToast } from '../../../../Toast/Toaster';\nimport { PrintIFrame } from './PrintIFrame';\nimport { Table3ColumnProps, Table3Props } from '../../../types';\nimport { WarningDialog } from './WarningDialog';\nimport { Shortcut } from '../../../../Shortcut/Shortcut';\n\nconst SAFE_PRINT_CELL_COUNT = 10000;\n\nexport type PrintButtonProps<TType = unknown> = React.HTMLAttributes<HTMLButtonElement> & {\n table: RTable<TType>;\n tableProps: Table3Props<TType>;\n};\n\nexport function PrintButton<TType = unknown>(props: PrintButtonProps<TType>) {\n const { table, tableProps } = props;\n const { texts } = useLocalization();\n const toast = useToast();\n\n const [isCurrentlyPrinting, setIsCurrentlyPrinting] = React.useState(false);\n const [showWarningDialog, setShowWarningDialog] = React.useState(false);\n const loadingToastRef = React.useRef<ToastReference | null>(null);\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n\n const tableMeta = table.options.meta as TableMeta<TType>;\n const state = table.getState();\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n const { isWarningVisibleForLargeDatasets } = tableMeta.printing;\n\n // When changing printTableId, update packages/taco/src/components/Table3/Table3.tsx file and other usages where\n // printTableId is used to figure out whether the table is a print table or not.\n const printTableId = `${tableProps.id}_print`;\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n const excludeUnmatchedResults = tableMeta.search.excludeUnmatchedResults;\n\n const defaultSettings = React.useMemo(\n () => ({\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n columnFreezingIndex: tableMeta.columnFreezing.frozenColumnIndex,\n columnOrder: state.columnOrder,\n columnSizing: state.columnSizing,\n columnVisibility: state.columnVisibility,\n excludeUnmatchedRecordsInSearch: excludeUnmatchedResults,\n fontSize: tableMeta.fontSize.size,\n rowHeight: tableMeta.rowHeight.height,\n sorting: state.sorting,\n // we don't save these, but we must pass them to print\n columnFilters: state.columnFilters,\n globalFilter: state.globalFilter,\n }),\n [\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n tableMeta.columnFreezing.frozenColumnIndex,\n state.columnOrder,\n state.columnSizing,\n state.columnVisibility,\n excludeUnmatchedResults,\n tableMeta.fontSize.size,\n tableMeta.rowHeight.height,\n state.sorting,\n state.columnFilters,\n state.globalFilter,\n ]\n );\n\n const iframeTableChildren = React.useMemo(\n () =>\n (React.Children.toArray(tableProps.children) as React.ReactElement<Table3ColumnProps<TType>>[]).filter(child => {\n const enableColumnInPrinting = child.props?.enablePrinting;\n\n // For table children, only include columns doesn't have 'false' value for enablePrinting prop.\n if (React.isValidElement<Table3ColumnProps<TType>>(child) && enableColumnInPrinting === false) {\n return false;\n }\n\n return true;\n }),\n [tableProps.children]\n );\n\n const iframeTableProps = {\n ...tableProps,\n children: iframeTableChildren,\n defaultSettings,\n id: printTableId,\n };\n\n const handleLoadingError = (error: any) => {\n const errorMessage = `${texts.table3.print.error}: ${error}`;\n\n console.error(errorMessage);\n loadingToastRef.current?.error(errorMessage);\n };\n\n const restoreTableDataWithoutSearch = async () => {\n try {\n await tableMeta.server.loadAll?.(table.getState().sorting, table.getState().columnFilters, undefined);\n } catch (error) {\n handleLoadingError(error);\n return;\n }\n };\n\n const handleAfterPrint = async () => {\n if (tableMeta.server.loadAll && excludeUnmatchedResults) {\n await restoreTableDataWithoutSearch();\n }\n setIsCurrentlyPrinting(false);\n loadingToastRef.current?.close();\n };\n\n const handleBeforePrint = () => {\n loadingToastRef.current?.close();\n };\n\n const handlePrint = async () => {\n loadingToastRef.current = toast.loading(texts.table3.print.loading as any);\n\n const getCellCount = (data: TType[]) => (data.length ? data.length * Object.keys(data[0]).length : 0);\n let hasNonSafeCellCount = false;\n\n // if loadAll is not defined, just print with what we've got\n // don't compare length to data.length because the api might be choosing not to return all for performance\n if (!tableMeta.server.loadAll) {\n const { data } = tableProps;\n const cellCount = getCellCount(data);\n\n hasNonSafeCellCount = cellCount > SAFE_PRINT_CELL_COUNT;\n } else {\n try {\n await tableMeta.server.loadAll(\n table.getState().sorting,\n table.getState().columnFilters,\n // We need to pass search query to the server when printing, to be able to render correct data set in iFrame,\n // But in \"display\" table, search is performed only on client side, so we'll need to request data again without search query,\n // when printing will be finished.\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n excludeUnmatchedResults ? tableMeta.search.query : undefined\n );\n\n // After the loadAll call above, the data changes. Hence, it becomes essential to acquire the data after\n // this call rather than before it.\n const { data } = tableProps;\n const cellCount = getCellCount(data);\n\n hasNonSafeCellCount = cellCount > SAFE_PRINT_CELL_COUNT;\n } catch (error) {\n handleLoadingError(error);\n\n // in case of error, we return early\n return;\n }\n }\n\n if (hasNonSafeCellCount && isWarningVisibleForLargeDatasets) {\n setShowWarningDialog(true);\n } else {\n // only set printing (mount the iframe) when the data has loaded, it prevents repaint performance slow downs\n setIsCurrentlyPrinting(true);\n }\n };\n\n const shortcut = { key: 'p', meta: true, shift: false };\n const tooltip = (\n <>\n {texts.table3.print.tooltip}\n <Shortcut className=\"ml-2\" keys={shortcut} />\n </>\n );\n\n const handleWarningDialogAccept = () => {\n setIsCurrentlyPrinting(true);\n };\n\n const handleWarningDialogCancel = async () => {\n if (tableMeta.server.loadAll && excludeUnmatchedResults) {\n await restoreTableDataWithoutSearch();\n }\n };\n\n const handleWarningDialogClose = () => {\n loadingToastRef.current?.close();\n setShowWarningDialog(false);\n };\n\n return (\n <>\n <IconButton\n disabled={isCurrentlyPrinting}\n icon=\"print\"\n onClick={handlePrint}\n aria-label={texts.table3.print.tooltip}\n tooltip={tooltip}\n ref={buttonRef}\n shortcut={shortcut}\n />\n {isCurrentlyPrinting && iframeTableProps.data !== null && (\n <PrintIFrame\n onAfterPrint={handleAfterPrint}\n onBeforePrint={handleBeforePrint}\n tableProps={iframeTableProps as Table3Props<TType>}\n />\n )}\n <WarningDialog\n open={showWarningDialog}\n onAccept={handleWarningDialogAccept}\n onClose={handleWarningDialogClose}\n onCancel={handleWarningDialogCancel}\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n onVisibilityChange={tableMeta.printing.setIsWarningVisibleForLargeDatasets}\n />\n </>\n );\n}\n"],"names":["SAFE_PRINT_CELL_COUNT","PrintButton","props","table","tableProps","texts","useLocalization","toast","useToast","isCurrentlyPrinting","setIsCurrentlyPrinting","React","useState","showWarningDialog","setShowWarningDialog","loadingToastRef","useRef","buttonRef","tableMeta","options","meta","state","getState","isWarningVisibleForLargeDatasets","printing","printTableId","id","excludeUnmatchedResults","search","defaultSettings","useMemo","columnFreezingIndex","columnFreezing","frozenColumnIndex","columnOrder","columnSizing","columnVisibility","excludeUnmatchedRecordsInSearch","fontSize","size","rowHeight","height","sorting","columnFilters","globalFilter","iframeTableChildren","Children","toArray","children","filter","child","enableColumnInPrinting","_child$props","enablePrinting","isValidElement","iframeTableProps","handleLoadingError","error","errorMessage","table3","print","console","_loadingToastRef$curr","current","restoreTableDataWithoutSearch","_tableMeta$server$loa","_tableMeta$server","Promise","resolve","server","loadAll","call","undefined","then","_temp","e","reject","handleAfterPrint","_loadingToastRef$curr2","close","_temp2","_temp3","handleBeforePrint","_loadingToastRef$curr3","handlePrint","hasNonSafeCellCount","loading","getCellCount","data","length","Object","keys","_temp5","cellCount","_temp4","_catch","query","_exit","_temp6","shortcut","key","shift","tooltip","Shortcut","className","handleWarningDialogAccept","handleWarningDialogCancel","_temp7","handleWarningDialogClose","_loadingToastRef$curr4","IconButton","disabled","icon","onClick","ref","PrintIFrame","onAfterPrint","onBeforePrint","WarningDialog","open","onAccept","onClose","onCancel","onVisibilityChange","setIsWarningVisibleForLargeDatasets"],"mappings":";;;;;;;;;AAWA,MAAMA,qBAAqB,GAAG,KAAK;SAOnBC,WAAWA,CAAkBC,KAA8B;EACvE,MAAM;IAAEC,KAAK;IAAEC;GAAY,GAAGF,KAAK;EACnC,MAAM;IAAEG;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,KAAK,GAAGC,QAAQ,EAAE;EAExB,MAAM,CAACC,mBAAmB,EAAEC,sBAAsB,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;EAC3E,MAAM,CAACC,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGH,cAAK,CAACC,QAAQ,CA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IACVC,IAAI,EAAE1G,iBAAiB;IACvB2G,QAAQ,EAAEf,yBAAyB;IACnCgB,OAAO,EAAEb,wBAAwB;IACjCc,QAAQ,EAAEhB,yBAAyB;;IAEnCiB,kBAAkB,EAAEzG,SAAS,CAACM,QAAQ,CAACoG;IACzC,CACH;AAEX;;;;"}
|
package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js
CHANGED
@@ -18,12 +18,12 @@ import '../../../../Banner/Banner.js';
|
|
18
18
|
import '../../../../Button/Button.js';
|
19
19
|
import '../../../../Calendar/Calendar.js';
|
20
20
|
import '../../../../Card/Card.js';
|
21
|
+
import '../../../../Spinner/Spinner.js';
|
21
22
|
import '../../../../Checkbox/Checkbox.js';
|
22
23
|
import '../../../../../hooks/useBoundingClientRectListener.js';
|
23
24
|
import '../../../../Input/Input.js';
|
24
25
|
import '../../../../../utils/hooks/useListKeyboardNavigation.js';
|
25
26
|
import '../../../../../utils/hooks/useListScrollTo.js';
|
26
|
-
import '../../../../Spinner/Spinner.js';
|
27
27
|
import '../../../../Combobox/Combobox.js';
|
28
28
|
import '../../../../../utils/date.js';
|
29
29
|
import '../../../../Popover/Popover.js';
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { useLocalStorage } from '../../../../hooks/useLocalStorage.js';
|
2
1
|
import { useTacoSettings } from '../../../../hooks/useTacoSettings.js';
|
2
|
+
import { useLocalStorage } from '../../../../hooks/useLocalStorage.js';
|
3
3
|
import { useLazyEffect } from '../../../../hooks/useLazyEffect.js';
|
4
4
|
|
5
5
|
function useUniqueTableId(tableId) {
|
package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js
CHANGED
@@ -15,7 +15,9 @@ function useSettingsStateListener(table, onChangeSettings) {
|
|
15
15
|
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
16
16
|
meta.columnFreezing.frozenColumnIndex, state.columnOrder, state.columnSizing, state.columnVisibility,
|
17
17
|
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
18
|
-
meta.search.excludeUnmatchedResults, meta.fontSize.size, meta.rowHeight.height,
|
18
|
+
meta.search.excludeUnmatchedResults, meta.fontSize.size, meta.rowHeight.height,
|
19
|
+
// @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
|
20
|
+
meta.printing.isWarningVisibleForLargeDatasets, state.sorting]);
|
19
21
|
}
|
20
22
|
|
21
23
|
export { useSettingsStateListener };
|
package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useSettingsStateListener.js","sources":["../../../../../../../../../src/components/Table3/hooks/listeners/useSettingsStateListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\nimport { Table3SettingsHandler } from '../../types';\n\nexport function useSettingsStateListener<TType = unknown>(\n table: RTable<TType>,\n onChangeSettings: Table3SettingsHandler | undefined\n) {\n const meta = table.options.meta as TableMeta<TType>;\n const state = table.getState();\n\n React.useEffect(() => {\n let handler;\n\n if (typeof onChangeSettings === 'function') {\n handler = setTimeout(() => {\n onChangeSettings(meta.getSettings());\n }, 250);\n }\n\n return () => clearTimeout(handler);\n }, [\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n meta.columnFreezing.frozenColumnIndex,\n state.columnOrder,\n state.columnSizing,\n state.columnVisibility,\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n meta.search.excludeUnmatchedResults,\n meta.fontSize.size,\n meta.rowHeight.height,\n meta.printing.isWarningVisibleForLargeDatasets,\n state.sorting,\n ]);\n}\n"],"names":["useSettingsStateListener","table","onChangeSettings","meta","options","state","getState","React","useEffect","handler","setTimeout","getSettings","clearTimeout","columnFreezing","frozenColumnIndex","columnOrder","columnSizing","columnVisibility","search","excludeUnmatchedResults","fontSize","size","rowHeight","height","printing","isWarningVisibleForLargeDatasets","sorting"],"mappings":";;SAIgBA,wBAAwBA,CACpCC,KAAoB,EACpBC,gBAAmD;EAEnD,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAAwB;EACnD,MAAME,KAAK,GAAGJ,KAAK,CAACK,QAAQ,EAAE;EAE9BC,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIC,OAAO;IAEX,IAAI,OAAOP,gBAAgB,KAAK,UAAU,EAAE;MACxCO,OAAO,GAAGC,UAAU,CAAC;QACjBR,gBAAgB,CAACC,IAAI,CAACQ,WAAW,EAAE,CAAC;OACvC,EAAE,GAAG,CAAC;;IAGX,OAAO,MAAMC,YAAY,CAACH,OAAO,CAAC;GACrC,EAAE;;EAECN,IAAI,CAACU,cAAc,CAACC,iBAAiB,EACrCT,KAAK,CAACU,WAAW,EACjBV,KAAK,CAACW,YAAY,EAClBX,KAAK,CAACY,gBAAgB;;EAEtBd,IAAI,CAACe,MAAM,CAACC,uBAAuB,EACnChB,IAAI,CAACiB,QAAQ,CAACC,IAAI,EAClBlB,IAAI,CAACmB,SAAS,CAACC,MAAM,
|
1
|
+
{"version":3,"file":"useSettingsStateListener.js","sources":["../../../../../../../../../src/components/Table3/hooks/listeners/useSettingsStateListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\nimport { Table3SettingsHandler } from '../../types';\n\nexport function useSettingsStateListener<TType = unknown>(\n table: RTable<TType>,\n onChangeSettings: Table3SettingsHandler | undefined\n) {\n const meta = table.options.meta as TableMeta<TType>;\n const state = table.getState();\n\n React.useEffect(() => {\n let handler;\n\n if (typeof onChangeSettings === 'function') {\n handler = setTimeout(() => {\n onChangeSettings(meta.getSettings());\n }, 250);\n }\n\n return () => clearTimeout(handler);\n }, [\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n meta.columnFreezing.frozenColumnIndex,\n state.columnOrder,\n state.columnSizing,\n state.columnVisibility,\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n meta.search.excludeUnmatchedResults,\n meta.fontSize.size,\n meta.rowHeight.height,\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n meta.printing.isWarningVisibleForLargeDatasets,\n state.sorting,\n ]);\n}\n"],"names":["useSettingsStateListener","table","onChangeSettings","meta","options","state","getState","React","useEffect","handler","setTimeout","getSettings","clearTimeout","columnFreezing","frozenColumnIndex","columnOrder","columnSizing","columnVisibility","search","excludeUnmatchedResults","fontSize","size","rowHeight","height","printing","isWarningVisibleForLargeDatasets","sorting"],"mappings":";;SAIgBA,wBAAwBA,CACpCC,KAAoB,EACpBC,gBAAmD;EAEnD,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAAwB;EACnD,MAAME,KAAK,GAAGJ,KAAK,CAACK,QAAQ,EAAE;EAE9BC,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIC,OAAO;IAEX,IAAI,OAAOP,gBAAgB,KAAK,UAAU,EAAE;MACxCO,OAAO,GAAGC,UAAU,CAAC;QACjBR,gBAAgB,CAACC,IAAI,CAACQ,WAAW,EAAE,CAAC;OACvC,EAAE,GAAG,CAAC;;IAGX,OAAO,MAAMC,YAAY,CAACH,OAAO,CAAC;GACrC,EAAE;;EAECN,IAAI,CAACU,cAAc,CAACC,iBAAiB,EACrCT,KAAK,CAACU,WAAW,EACjBV,KAAK,CAACW,YAAY,EAClBX,KAAK,CAACY,gBAAgB;;EAEtBd,IAAI,CAACe,MAAM,CAACC,uBAAuB,EACnChB,IAAI,CAACiB,QAAQ,CAACC,IAAI,EAClBlB,IAAI,CAACmB,SAAS,CAACC,MAAM;;EAErBpB,IAAI,CAACqB,QAAQ,CAACC,gCAAgC,EAC9CpB,KAAK,CAACqB,OAAO,CAChB,CAAC;AACN;;;;"}
|
@@ -36,7 +36,7 @@ import { useValidation } from './features/useValidation.js';
|
|
36
36
|
import { usePauseShortcuts } from './features/usePauseShortcuts.js';
|
37
37
|
|
38
38
|
function useTable(props, ref) {
|
39
|
-
var _settings$columnFreez, _props$length;
|
39
|
+
var _settings$columnFreez, _props$data, _ref, _props$length, _props$data2;
|
40
40
|
// load any persisted table settings and merge them with any defaults
|
41
41
|
const [settings, setSettings] = useSettings(props.id, props.defaultSettings, props.onChangeSettings);
|
42
42
|
// configure table3 options
|
@@ -60,6 +60,12 @@ function useTable(props, ref) {
|
|
60
60
|
// haven't migrated load all/server loading yet
|
61
61
|
const search = useSearch(options.enableSearch, settings.excludeUnmatchedRecordsInSearch);
|
62
62
|
const shortcutsState = usePauseShortcuts();
|
63
|
+
React__default.useEffect(() => {
|
64
|
+
// Needed for DataDog
|
65
|
+
if (!Array.isArray(props.data)) {
|
66
|
+
console.error('Table3 data value is not an array');
|
67
|
+
}
|
68
|
+
}, []);
|
63
69
|
// custom features - shared/migrated
|
64
70
|
const columnOrdering = useTableColumnOrdering(options.enableColumnOrdering);
|
65
71
|
const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);
|
@@ -112,7 +118,8 @@ function useTable(props, ref) {
|
|
112
118
|
};
|
113
119
|
};
|
114
120
|
const table = useReactTable({
|
115
|
-
|
121
|
+
// We need to fallback to an empty array, to avoid table crash in the client
|
122
|
+
data: (_props$data = props.data) !== null && _props$data !== void 0 ? _props$data : [],
|
116
123
|
columns,
|
117
124
|
getCoreRowModel: getCoreRowModel(),
|
118
125
|
initialState,
|
@@ -156,7 +163,7 @@ function useTable(props, ref) {
|
|
156
163
|
useTableSortingListener(table, props.onSort);
|
157
164
|
return {
|
158
165
|
table,
|
159
|
-
length: (_props$length = props.length) !== null && _props$length !== void 0 ? _props$length : props.data.length
|
166
|
+
length: (_ref = (_props$length = props.length) !== null && _props$length !== void 0 ? _props$length : (_props$data2 = props.data) === null || _props$data2 === void 0 ? void 0 : _props$data2.length) !== null && _ref !== void 0 ? _ref : 0
|
160
167
|
};
|
161
168
|
}
|
162
169
|
function configureReactTableOptions(props, options) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTable.js","sources":["../../../../../../../../src/components/Table3/hooks/useTable.tsx"],"sourcesContent":["import React from 'react';\nimport {\n getCoreRowModel,\n useReactTable,\n Row as RTRow,\n RowData,\n Column as RTColumn,\n TableOptions as RTableOptions,\n TableState,\n getSortedRowModel,\n getFilteredRowModel,\n ColumnMeta,\n} from '@tanstack/react-table';\nimport {\n Table3ColumnAlignment,\n Table3ColumnRenderer,\n Table3Props,\n Table3ColumnHeaderMenu,\n Table3ColumnControlRenderer,\n Table3ColumnDataType,\n Table3ColumnClassNameHandler,\n Table3ColumnFooterRenderer,\n TableStrategy,\n Table3FilterComparator,\n Table3Settings,\n Table3Options,\n Table3Ref,\n} from '../types';\nimport { useTableRowActive } from '../../../primitives/Table/useTable/features/useTableRowActive';\nimport { useTablePreset } from './useTablePreset';\nimport { useTableRowHeight } from '../../../primitives/Table/useTable/features/useTableRowHeight';\nimport { useTableFontSize } from '../../../primitives/Table/useTable/features/useTableFontSize';\nimport { useTableRowSelectionListener } from '../../../primitives/Table/useTable/listeners/useTableRowSelectionListener';\nimport { useRowDrag } from './features/useRowDrag';\nimport { useSettingsStateListener } from './listeners/useSettingsStateListener';\nimport { columnFilterFn, globalFilterFn } from '../util/filtering';\nimport { useTableSortingListener } from '../../../primitives/Table/useTable/listeners/useTableSortingListener';\nimport { useTableFilterListener } from '../../../primitives/Table/useTable/listeners/useTableFilterListener';\nimport { useTableDataListener } from '../../../primitives/Table/useTable/listeners/useTableDataListener';\nimport { useColumnFreezing } from './features/useColumnFreezing';\nimport { useTableRowSelection } from '../../../primitives/Table/useTable/features/useTableRowSelection';\nimport { useTableServerLoading } from '../../../primitives/Table/useTable/features/useTableServerLoading';\nimport { useTableRowClick } from '../../../primitives/Table/useTable/features/useTableRowClick';\nimport { useTableColumnOrdering } from '../../../primitives/Table/useTable/features/useTableColumnOrdering';\nimport { useRowDrop } from './features/useRowDrop';\nimport { useConvertChildrenToColumns } from './useConvertChildrenToColumns';\nimport { useEditing } from './features/useEditing';\nimport { usePrinting } from './features/usePrinting';\nimport { useTableShortcutsListener } from '../../../primitives/Table/useTable/listeners/useTableShortcutsListener';\nimport { useTableRowGoto } from '../../../primitives/Table/useTable/features/useTableRowGoto';\nimport { useTableServerLoadingListener } from '../../../primitives/Table/useTable/listeners/useTableServerLoadingListener';\nimport { useEditingStateListener } from './listeners/useEditingStateListener';\nimport { useSearch } from './features/useSearch';\nimport { useRowActions } from './features/useRowActions';\nimport { useSettings } from './features/useSettings';\nimport { getCellValueAsString } from '../util/columns';\nimport { Table3Validation, useValidation } from './features/useValidation';\nimport { usePauseShortcuts } from './features/usePauseShortcuts';\nimport { useTableFontSizeListener } from '../../../primitives/Table/useTable/listeners/useTableFontSizeListener';\nimport { ensureOrdering } from '../../../primitives/Table/useTable/util/columns';\nimport { COLUMN_ID as ACTIONS_COLUMN_ID } from '../components/columns/internal/Actions';\nimport { COLUMN_ID as EDITING_ACTIONS_COLUMN_ID } from '../components/columns/internal/EditingActions';\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n columnFreezing: ReturnType<typeof useColumnFreezing>;\n columnOrdering: ReturnType<typeof useTableColumnOrdering>;\n editing: ReturnType<typeof useEditing>;\n enableFooter: boolean;\n fontSize: ReturnType<typeof useTableFontSize>;\n getSettings: () => Table3Settings;\n isPrinting: boolean;\n isUsingServer: boolean;\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n printing: ReturnType<typeof usePrinting>;\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n rowActions: ReturnType<typeof useRowActions>;\n rowActive: ReturnType<typeof useTableRowActive>;\n rowClick: ReturnType<typeof useTableRowClick>;\n rowDrag: ReturnType<typeof useRowDrag>;\n rowDrop: ReturnType<typeof useRowDrop>;\n rowGoto: ReturnType<typeof useTableRowGoto>;\n rowHeight: ReturnType<typeof useTableRowHeight>;\n rowSelection: ReturnType<typeof useTableRowSelection>;\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n search: ReturnType<typeof useSearch>;\n server: ReturnType<typeof useTableServerLoading>;\n shortcutsState: ReturnType<typeof usePauseShortcuts>;\n tableRef: React.RefObject<Table3Ref>;\n validation: Table3Validation<TData>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: Table3ColumnAlignment;\n className?: Table3ColumnClassNameHandler<TData>;\n control?: Table3ColumnControlRenderer<TData>;\n dataType?: Table3ColumnDataType;\n defaultWidth?: number;\n enableOrdering?: boolean;\n enableSearch: boolean;\n enableTruncate?: boolean;\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n filters?: Table3FilterComparator[];\n footer?: Table3ColumnFooterRenderer;\n header: string;\n headerClassName?: string;\n menu?: Table3ColumnHeaderMenu;\n renderer?: Table3ColumnRenderer<TValue, TData>;\n tooltip?: string;\n }\n\n interface CellContext<TData extends RowData, TValue> {\n index: number;\n tableRef: React.RefObject<HTMLDivElement>;\n }\n\n interface HeaderContext<TData extends RowData, TValue> {\n scrollToIndex: TableStrategy['scrollToIndex'];\n }\n}\n\nexport function useTable<TType = unknown>(props: Table3Props<TType>, ref: React.RefObject<Table3Ref>) {\n // load any persisted table settings and merge them with any defaults\n const [settings, setSettings] = useSettings(props.id, props.defaultSettings, props.onChangeSettings);\n\n // configure table3 options\n const options = useTablePreset(props);\n\n // configure react-table built-in features\n const tableOptions = configureReactTableOptions(props, options);\n\n // configure custom features\n const columnFreezing = useColumnFreezing(settings.columnFreezingIndex ?? props.defaultColumnFreezingIndex, options);\n // can't change due to rename to \"active row\"\n const validation = useValidation<TType>(props.onCellValidate, props.onRowValidate);\n // not relevant to common table\n const editing = useEditing<TType>(options.enableEditing, ref, validation, props.onSave);\n // we changed how printing works, so this shouldn't be migrated\n const printing = usePrinting(options.enablePrinting, settings.showWarningWhenPrintingLargeDataset, props.id);\n // needs to be moved\n const rowActions = useRowActions<TType>(props.actionsForRow, props.actionsForRowLength);\n // not relevant to common table\n const rowDrag = useRowDrag(options.enableRowDrag);\n // not relevant to common table\n const rowDrop = useRowDrop(options.enableRowDrop, props.onRowDrop);\n // haven't migrated load all/server loading yet\n const search = useSearch(options.enableSearch, settings.excludeUnmatchedRecordsInSearch);\n const shortcutsState = usePauseShortcuts();\n\n // custom features - shared/migrated\n const columnOrdering = useTableColumnOrdering(options.enableColumnOrdering);\n const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);\n const rowActive = useTableRowActive(true, props.defaultCurrentRowIndex);\n const rowClick = useTableRowClick<TType>(true, props.onRowClick);\n const rowGoto = useTableRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);\n const rowSelection = useTableRowSelection(options.enableRowSelection);\n const server = useTableServerLoading(props.loadPage, props.loadAll);\n\n // columns\n const { columns, defaultColumnSizing, defaultColumnVisibility, defaultSorting } = useConvertChildrenToColumns<TType>(\n props,\n options,\n editing\n );\n\n // built-in features\n const initialState: Partial<TableState> = React.useMemo(() => {\n const sanitizeSortedColumns = column => columns.find(definedColumn => definedColumn.id === column.id);\n\n const state: Partial<TableState> = {\n columnOrder: ensureOrdering<TType>(columns, settings.columnOrder, [ACTIONS_COLUMN_ID, EDITING_ACTIONS_COLUMN_ID]),\n columnSizing: settings.columnSizing ?? defaultColumnSizing,\n columnVisibility: settings.columnVisibility ?? defaultColumnVisibility,\n sorting: settings.sorting ? settings.sorting.filter(sanitizeSortedColumns) : defaultSorting,\n };\n\n // we don't save these outside the table, but they need to be here for print to inherit them - see PrintButton.tsx\n if ((props.defaultSettings as any)?.columnFilters) {\n state.columnFilters = (props.defaultSettings as any)?.columnFilters;\n }\n\n if ((props.defaultSettings as any)?.globalFilter) {\n state.globalFilter = (props.defaultSettings as any)?.globalFilter;\n }\n\n return state;\n }, []);\n\n const getSettings = () => {\n const state = table.getState();\n return {\n columnFreezingIndex: columnFreezing.frozenColumnIndex,\n columnOrder: columnOrdering.isEnabled ? state.columnOrder : undefined,\n columnSizing: table.options.enableColumnResizing ? state.columnSizing : undefined,\n columnVisibility: table.options.enableHiding ? state.columnVisibility : undefined,\n excludeUnmatchedRecordsInSearch: search.excludeUnmatchedResults,\n fontSize: fontSize.isEnabled ? fontSize.size : undefined,\n rowHeight: rowHeight.isEnabled ? rowHeight.height : undefined,\n showWarningWhenPrintingLargeDataset: printing.isWarningVisibleForLargeDatasets,\n sorting: state.sorting,\n };\n };\n\n const table = useReactTable<TType>({\n data: props.data,\n columns,\n getCoreRowModel: getCoreRowModel(),\n initialState,\n ...tableOptions,\n //debugAll: true,\n meta: {\n columnFreezing,\n columnOrdering,\n editing,\n enableFooter: options.enableFooter,\n fontSize,\n getSettings,\n isPrinting: props.id.endsWith('_print'),\n isUsingServer: !!props.loadPage,\n printing,\n rowActions: rowActions as any,\n rowActive,\n rowClick: rowClick as any,\n rowDrag,\n rowDrop,\n rowGoto,\n rowHeight,\n rowSelection,\n search,\n server,\n shortcutsState,\n tableRef: ref,\n validation,\n },\n });\n\n // listeners\n useEditingStateListener(table);\n useSettingsStateListener(table, setSettings);\n // listeners - shared/migrated\n useTableDataListener(table);\n useTableFilterListener(table, props.onFilter);\n useTableFontSizeListener(table);\n useTableRowSelectionListener(table, props.onRowSelect);\n useTableServerLoadingListener(table, props.loadPage);\n useTableShortcutsListener(table, props.shortcuts);\n useTableSortingListener(table, props.onSort);\n\n return { table, length: props.length ?? props.data.length };\n}\n\nfunction configureReactTableOptions<TType = unknown>(props: Table3Props<TType>, options: Table3Options) {\n const tableOptions: Partial<RTableOptions<TType>> = {\n enableColumnFilters: options.enableFiltering,\n enableColumnResizing: options.enableColumnResizing,\n enableExpanding: options.enableRowExpansion,\n enableGlobalFilter: options.enableSearch,\n enableHiding: options.enableColumnHiding,\n enableRowSelection: options.enableRowSelection,\n enableMultiRowSelection: !options.enableRowSelectionSingle,\n enableSorting: options.enableSorting,\n };\n\n // resizing\n if (tableOptions.enableColumnResizing) {\n tableOptions.columnResizeMode = 'onChange';\n }\n\n // filtering\n if (tableOptions.enableColumnFilters) {\n if (!props.onFilter) {\n tableOptions.filterFns = {\n tacoFilter: (row: RTRow<TType>, columnId: string, filter: any) => columnFilterFn(row.getValue(columnId), filter),\n };\n tableOptions.getFilteredRowModel = getFilteredRowModel();\n }\n\n // we don't tableOptions.manualFiltering = true; because it breaks global filtering, server filtering still works :shrug:\n }\n\n // search\n if (tableOptions.enableGlobalFilter) {\n // search is always client side, since we call loadAll when searching\n tableOptions.globalFilterFn = (row: RTRow<TType>, columnId: string, searchQuery: string) => {\n try {\n if (row.original) {\n const cell = row.getAllCells().find(cell => cell.column.id === columnId);\n const columnMeta = cell?.column.columnDef.meta;\n\n if (cell && cell.column.getIsVisible() && columnMeta?.enableSearch) {\n const cellValue = getCellValueAsString(row.original[columnId], columnMeta?.dataType);\n\n if (cellValue !== undefined) {\n return globalFilterFn(cellValue, searchQuery);\n }\n }\n return false;\n }\n } catch {\n //\n }\n\n return false;\n };\n tableOptions.getFilteredRowModel = getFilteredRowModel();\n tableOptions.getColumnCanGlobalFilter = (column: RTColumn<TType>) =>\n (column.columnDef.meta as ColumnMeta<TType, unknown>).enableSearch ?? true;\n }\n\n // sorting\n if (options.enableSorting) {\n if (props.onSort) {\n tableOptions.manualSorting = true;\n // onSort is called as a listener to let the consumer update their data, so we don't use onSortingChange\n } else {\n tableOptions.getSortedRowModel = getSortedRowModel();\n }\n }\n\n return tableOptions;\n}\n"],"names":["useTable","props","ref","settings","setSettings","useSettings","id","defaultSettings","onChangeSettings","options","useTablePreset","tableOptions","configureReactTableOptions","columnFreezing","useColumnFreezing","_settings$columnFreez","columnFreezingIndex","defaultColumnFreezingIndex","validation","useValidation","onCellValidate","onRowValidate","editing","useEditing","enableEditing","onSave","printing","usePrinting","enablePrinting","showWarningWhenPrintingLargeDataset","rowActions","useRowActions","actionsForRow","actionsForRowLength","rowDrag","useRowDrag","enableRowDrag","rowDrop","useRowDrop","enableRowDrop","onRowDrop","search","useSearch","enableSearch","excludeUnmatchedRecordsInSearch","shortcutsState","usePauseShortcuts","columnOrdering","useTableColumnOrdering","enableColumnOrdering","fontSize","useTableFontSize","enableFontSize","rowActive","useTableRowActive","defaultCurrentRowIndex","rowClick","useTableRowClick","onRowClick","rowGoto","useTableRowGoto","enableRowGoto","onRowGoto","rowHeight","useTableRowHeight","enableRowHeight","rowSelection","useTableRowSelection","enableRowSelection","server","useTableServerLoading","loadPage","loadAll","columns","defaultColumnSizing","defaultColumnVisibility","defaultSorting","useConvertChildrenToColumns","initialState","React","useMemo","sanitizeSortedColumns","column","find","definedColumn","state","columnOrder","ensureOrdering","ACTIONS_COLUMN_ID","EDITING_ACTIONS_COLUMN_ID","columnSizing","_settings$columnSizin","columnVisibility","_settings$columnVisib","sorting","filter","_props$defaultSetting","columnFilters","_props$defaultSetting2","_props$defaultSetting3","globalFilter","_props$defaultSetting4","getSettings","table","getState","frozenColumnIndex","isEnabled","undefined","enableColumnResizing","enableHiding","excludeUnmatchedResults","size","height","isWarningVisibleForLargeDatasets","useReactTable","data","getCoreRowModel","meta","enableFooter","isPrinting","endsWith","isUsingServer","tableRef","useEditingStateListener","useSettingsStateListener","useTableDataListener","useTableFilterListener","onFilter","useTableFontSizeListener","useTableRowSelectionListener","onRowSelect","useTableServerLoadingListener","useTableShortcutsListener","shortcuts","useTableSortingListener","onSort","length","_props$length","enableColumnFilters","enableFiltering","enableExpanding","enableRowExpansion","enableGlobalFilter","enableColumnHiding","enableMultiRowSelection","enableRowSelectionSingle","enableSorting","columnResizeMode","filterFns","tacoFilter","row","columnId","columnFilterFn","getValue","getFilteredRowModel","globalFilterFn","searchQuery","original","cell","getAllCells","columnMeta","columnDef","getIsVisible","cellValue","getCellValueAsString","dataType","getColumnCanGlobalFilter","_column$columnDef$met","manualSorting","getSortedRowModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SA0HgBA,QAAQA,CAAkBC,KAAyB,EAAEC,GAA+B;;;EAEhG,MAAM,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;;;;"}
|
1
|
+
{"version":3,"file":"useTable.js","sources":["../../../../../../../../src/components/Table3/hooks/useTable.tsx"],"sourcesContent":["import React from 'react';\nimport {\n getCoreRowModel,\n useReactTable,\n Row as RTRow,\n RowData,\n Column as RTColumn,\n TableOptions as RTableOptions,\n TableState,\n getSortedRowModel,\n getFilteredRowModel,\n ColumnMeta,\n} from '@tanstack/react-table';\nimport {\n Table3ColumnAlignment,\n Table3ColumnRenderer,\n Table3Props,\n Table3ColumnHeaderMenu,\n Table3ColumnControlRenderer,\n Table3ColumnDataType,\n Table3ColumnClassNameHandler,\n Table3ColumnFooterRenderer,\n TableStrategy,\n Table3FilterComparator,\n Table3Settings,\n Table3Options,\n Table3Ref,\n} from '../types';\nimport { useTableRowActive } from '../../../primitives/Table/useTable/features/useTableRowActive';\nimport { useTablePreset } from './useTablePreset';\nimport { useTableRowHeight } from '../../../primitives/Table/useTable/features/useTableRowHeight';\nimport { useTableFontSize } from '../../../primitives/Table/useTable/features/useTableFontSize';\nimport { useTableRowSelectionListener } from '../../../primitives/Table/useTable/listeners/useTableRowSelectionListener';\nimport { useRowDrag } from './features/useRowDrag';\nimport { useSettingsStateListener } from './listeners/useSettingsStateListener';\nimport { columnFilterFn, globalFilterFn } from '../util/filtering';\nimport { useTableSortingListener } from '../../../primitives/Table/useTable/listeners/useTableSortingListener';\nimport { useTableFilterListener } from '../../../primitives/Table/useTable/listeners/useTableFilterListener';\nimport { useTableDataListener } from '../../../primitives/Table/useTable/listeners/useTableDataListener';\nimport { useColumnFreezing } from './features/useColumnFreezing';\nimport { useTableRowSelection } from '../../../primitives/Table/useTable/features/useTableRowSelection';\nimport { useTableServerLoading } from '../../../primitives/Table/useTable/features/useTableServerLoading';\nimport { useTableRowClick } from '../../../primitives/Table/useTable/features/useTableRowClick';\nimport { useTableColumnOrdering } from '../../../primitives/Table/useTable/features/useTableColumnOrdering';\nimport { useRowDrop } from './features/useRowDrop';\nimport { useConvertChildrenToColumns } from './useConvertChildrenToColumns';\nimport { useEditing } from './features/useEditing';\nimport { usePrinting } from './features/usePrinting';\nimport { useTableShortcutsListener } from '../../../primitives/Table/useTable/listeners/useTableShortcutsListener';\nimport { useTableRowGoto } from '../../../primitives/Table/useTable/features/useTableRowGoto';\nimport { useTableServerLoadingListener } from '../../../primitives/Table/useTable/listeners/useTableServerLoadingListener';\nimport { useEditingStateListener } from './listeners/useEditingStateListener';\nimport { useSearch } from './features/useSearch';\nimport { useRowActions } from './features/useRowActions';\nimport { useSettings } from './features/useSettings';\nimport { getCellValueAsString } from '../util/columns';\nimport { Table3Validation, useValidation } from './features/useValidation';\nimport { usePauseShortcuts } from './features/usePauseShortcuts';\nimport { useTableFontSizeListener } from '../../../primitives/Table/useTable/listeners/useTableFontSizeListener';\nimport { ensureOrdering } from '../../../primitives/Table/useTable/util/columns';\nimport { COLUMN_ID as ACTIONS_COLUMN_ID } from '../components/columns/internal/Actions';\nimport { COLUMN_ID as EDITING_ACTIONS_COLUMN_ID } from '../components/columns/internal/EditingActions';\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n columnFreezing: ReturnType<typeof useColumnFreezing>;\n columnOrdering: ReturnType<typeof useTableColumnOrdering>;\n editing: ReturnType<typeof useEditing>;\n enableFooter: boolean;\n fontSize: ReturnType<typeof useTableFontSize>;\n getSettings: () => Table3Settings;\n isPrinting: boolean;\n isUsingServer: boolean;\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n printing: ReturnType<typeof usePrinting>;\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n rowActions: ReturnType<typeof useRowActions>;\n rowActive: ReturnType<typeof useTableRowActive>;\n rowClick: ReturnType<typeof useTableRowClick>;\n rowDrag: ReturnType<typeof useRowDrag>;\n rowDrop: ReturnType<typeof useRowDrop>;\n rowGoto: ReturnType<typeof useTableRowGoto>;\n rowHeight: ReturnType<typeof useTableRowHeight>;\n rowSelection: ReturnType<typeof useTableRowSelection>;\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n search: ReturnType<typeof useSearch>;\n server: ReturnType<typeof useTableServerLoading>;\n shortcutsState: ReturnType<typeof usePauseShortcuts>;\n tableRef: React.RefObject<Table3Ref>;\n validation: Table3Validation<TData>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: Table3ColumnAlignment;\n className?: Table3ColumnClassNameHandler<TData>;\n control?: Table3ColumnControlRenderer<TData>;\n dataType?: Table3ColumnDataType;\n defaultWidth?: number;\n enableOrdering?: boolean;\n enableSearch: boolean;\n enableTruncate?: boolean;\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n filters?: Table3FilterComparator[];\n footer?: Table3ColumnFooterRenderer;\n header: string;\n headerClassName?: string;\n menu?: Table3ColumnHeaderMenu;\n renderer?: Table3ColumnRenderer<TValue, TData>;\n tooltip?: string;\n }\n\n interface CellContext<TData extends RowData, TValue> {\n index: number;\n tableRef: React.RefObject<HTMLDivElement>;\n }\n\n interface HeaderContext<TData extends RowData, TValue> {\n scrollToIndex: TableStrategy['scrollToIndex'];\n }\n}\n\nexport function useTable<TType = unknown>(props: Table3Props<TType>, ref: React.RefObject<Table3Ref>) {\n // load any persisted table settings and merge them with any defaults\n const [settings, setSettings] = useSettings(props.id, props.defaultSettings, props.onChangeSettings);\n\n // configure table3 options\n const options = useTablePreset(props);\n\n // configure react-table built-in features\n const tableOptions = configureReactTableOptions(props, options);\n\n // configure custom features\n const columnFreezing = useColumnFreezing(settings.columnFreezingIndex ?? props.defaultColumnFreezingIndex, options);\n // can't change due to rename to \"active row\"\n const validation = useValidation<TType>(props.onCellValidate, props.onRowValidate);\n // not relevant to common table\n const editing = useEditing<TType>(options.enableEditing, ref, validation, props.onSave);\n // we changed how printing works, so this shouldn't be migrated\n const printing = usePrinting(options.enablePrinting, settings.showWarningWhenPrintingLargeDataset, props.id);\n // needs to be moved\n const rowActions = useRowActions<TType>(props.actionsForRow, props.actionsForRowLength);\n // not relevant to common table\n const rowDrag = useRowDrag(options.enableRowDrag);\n // not relevant to common table\n const rowDrop = useRowDrop(options.enableRowDrop, props.onRowDrop);\n // haven't migrated load all/server loading yet\n const search = useSearch(options.enableSearch, settings.excludeUnmatchedRecordsInSearch);\n const shortcutsState = usePauseShortcuts();\n\n React.useEffect(() => {\n // Needed for DataDog\n if (!Array.isArray(props.data)) {\n console.error('Table3 data value is not an array');\n }\n }, []);\n\n // custom features - shared/migrated\n const columnOrdering = useTableColumnOrdering(options.enableColumnOrdering);\n const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);\n const rowActive = useTableRowActive(true, props.defaultCurrentRowIndex);\n const rowClick = useTableRowClick<TType>(true, props.onRowClick);\n const rowGoto = useTableRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);\n const rowSelection = useTableRowSelection(options.enableRowSelection);\n const server = useTableServerLoading(props.loadPage, props.loadAll);\n\n // columns\n const { columns, defaultColumnSizing, defaultColumnVisibility, defaultSorting } = useConvertChildrenToColumns<TType>(\n props,\n options,\n editing\n );\n\n // built-in features\n const initialState: Partial<TableState> = React.useMemo(() => {\n const sanitizeSortedColumns = column => columns.find(definedColumn => definedColumn.id === column.id);\n\n const state: Partial<TableState> = {\n columnOrder: ensureOrdering<TType>(columns, settings.columnOrder, [ACTIONS_COLUMN_ID, EDITING_ACTIONS_COLUMN_ID]),\n columnSizing: settings.columnSizing ?? defaultColumnSizing,\n columnVisibility: settings.columnVisibility ?? defaultColumnVisibility,\n sorting: settings.sorting ? settings.sorting.filter(sanitizeSortedColumns) : defaultSorting,\n };\n\n // we don't save these outside the table, but they need to be here for print to inherit them - see PrintButton.tsx\n if ((props.defaultSettings as any)?.columnFilters) {\n state.columnFilters = (props.defaultSettings as any)?.columnFilters;\n }\n\n if ((props.defaultSettings as any)?.globalFilter) {\n state.globalFilter = (props.defaultSettings as any)?.globalFilter;\n }\n\n return state;\n }, []);\n\n const getSettings = () => {\n const state = table.getState();\n return {\n columnFreezingIndex: columnFreezing.frozenColumnIndex,\n columnOrder: columnOrdering.isEnabled ? state.columnOrder : undefined,\n columnSizing: table.options.enableColumnResizing ? state.columnSizing : undefined,\n columnVisibility: table.options.enableHiding ? state.columnVisibility : undefined,\n excludeUnmatchedRecordsInSearch: search.excludeUnmatchedResults,\n fontSize: fontSize.isEnabled ? fontSize.size : undefined,\n rowHeight: rowHeight.isEnabled ? rowHeight.height : undefined,\n showWarningWhenPrintingLargeDataset: printing.isWarningVisibleForLargeDatasets,\n sorting: state.sorting,\n };\n };\n\n const table = useReactTable<TType>({\n // We need to fallback to an empty array, to avoid table crash in the client\n data: props.data ?? [],\n columns,\n getCoreRowModel: getCoreRowModel(),\n initialState,\n ...tableOptions,\n //debugAll: true,\n meta: {\n columnFreezing,\n columnOrdering,\n editing,\n enableFooter: options.enableFooter,\n fontSize,\n getSettings,\n isPrinting: props.id.endsWith('_print'),\n isUsingServer: !!props.loadPage,\n printing,\n rowActions: rowActions as any,\n rowActive,\n rowClick: rowClick as any,\n rowDrag,\n rowDrop,\n rowGoto,\n rowHeight,\n rowSelection,\n search,\n server,\n shortcutsState,\n tableRef: ref,\n validation,\n },\n });\n\n // listeners\n useEditingStateListener(table);\n useSettingsStateListener(table, setSettings);\n // listeners - shared/migrated\n useTableDataListener(table);\n useTableFilterListener(table, props.onFilter);\n useTableFontSizeListener(table);\n useTableRowSelectionListener(table, props.onRowSelect);\n useTableServerLoadingListener(table, props.loadPage);\n useTableShortcutsListener(table, props.shortcuts);\n useTableSortingListener(table, props.onSort);\n\n return { table, length: props.length ?? props.data?.length ?? 0 };\n}\n\nfunction configureReactTableOptions<TType = unknown>(props: Table3Props<TType>, options: Table3Options) {\n const tableOptions: Partial<RTableOptions<TType>> = {\n enableColumnFilters: options.enableFiltering,\n enableColumnResizing: options.enableColumnResizing,\n enableExpanding: options.enableRowExpansion,\n enableGlobalFilter: options.enableSearch,\n enableHiding: options.enableColumnHiding,\n enableRowSelection: options.enableRowSelection,\n enableMultiRowSelection: !options.enableRowSelectionSingle,\n enableSorting: options.enableSorting,\n };\n\n // resizing\n if (tableOptions.enableColumnResizing) {\n tableOptions.columnResizeMode = 'onChange';\n }\n\n // filtering\n if (tableOptions.enableColumnFilters) {\n if (!props.onFilter) {\n tableOptions.filterFns = {\n tacoFilter: (row: RTRow<TType>, columnId: string, filter: any) => columnFilterFn(row.getValue(columnId), filter),\n };\n tableOptions.getFilteredRowModel = getFilteredRowModel();\n }\n\n // we don't tableOptions.manualFiltering = true; because it breaks global filtering, server filtering still works :shrug:\n }\n\n // search\n if (tableOptions.enableGlobalFilter) {\n // search is always client side, since we call loadAll when searching\n tableOptions.globalFilterFn = (row: RTRow<TType>, columnId: string, searchQuery: string) => {\n try {\n if (row.original) {\n const cell = row.getAllCells().find(cell => cell.column.id === columnId);\n const columnMeta = cell?.column.columnDef.meta;\n\n if (cell && cell.column.getIsVisible() && columnMeta?.enableSearch) {\n const cellValue = getCellValueAsString(row.original[columnId], columnMeta?.dataType);\n\n if (cellValue !== undefined) {\n return globalFilterFn(cellValue, searchQuery);\n }\n }\n return false;\n }\n } catch {\n //\n }\n\n return false;\n };\n tableOptions.getFilteredRowModel = getFilteredRowModel();\n tableOptions.getColumnCanGlobalFilter = (column: RTColumn<TType>) =>\n (column.columnDef.meta as ColumnMeta<TType, unknown>).enableSearch ?? true;\n }\n\n // sorting\n if (options.enableSorting) {\n if (props.onSort) {\n tableOptions.manualSorting = true;\n // onSort is called as a listener to let the consumer update their data, so we don't use onSortingChange\n } else {\n tableOptions.getSortedRowModel = getSortedRowModel();\n }\n }\n\n return tableOptions;\n}\n"],"names":["useTable","props","ref","settings","setSettings","useSettings","id","defaultSettings","onChangeSettings","options","useTablePreset","tableOptions","configureReactTableOptions","columnFreezing","useColumnFreezing","_settings$columnFreez","columnFreezingIndex","defaultColumnFreezingIndex","validation","useValidation","onCellValidate","onRowValidate","editing","useEditing","enableEditing","onSave","printing","usePrinting","enablePrinting","showWarningWhenPrintingLargeDataset","rowActions","useRowActions","actionsForRow","actionsForRowLength","rowDrag","useRowDrag","enableRowDrag","rowDrop","useRowDrop","enableRowDrop","onRowDrop","search","useSearch","enableSearch","excludeUnmatchedRecordsInSearch","shortcutsState","usePauseShortcuts","React","useEffect","Array","isArray","data","console","error","columnOrdering","useTableColumnOrdering","enableColumnOrdering","fontSize","useTableFontSize","enableFontSize","rowActive","useTableRowActive","defaultCurrentRowIndex","rowClick","useTableRowClick","onRowClick","rowGoto","useTableRowGoto","enableRowGoto","onRowGoto","rowHeight","useTableRowHeight","enableRowHeight","rowSelection","useTableRowSelection","enableRowSelection","server","useTableServerLoading","loadPage","loadAll","columns","defaultColumnSizing","defaultColumnVisibility","defaultSorting","useConvertChildrenToColumns","initialState","useMemo","sanitizeSortedColumns","column","find","definedColumn","state","columnOrder","ensureOrdering","ACTIONS_COLUMN_ID","EDITING_ACTIONS_COLUMN_ID","columnSizing","_settings$columnSizin","columnVisibility","_settings$columnVisib","sorting","filter","_props$defaultSetting","columnFilters","_props$defaultSetting2","_props$defaultSetting3","globalFilter","_props$defaultSetting4","getSettings","table","getState","frozenColumnIndex","isEnabled","undefined","enableColumnResizing","enableHiding","excludeUnmatchedResults","size","height","isWarningVisibleForLargeDatasets","useReactTable","_props$data","getCoreRowModel","meta","enableFooter","isPrinting","endsWith","isUsingServer","tableRef","useEditingStateListener","useSettingsStateListener","useTableDataListener","useTableFilterListener","onFilter","useTableFontSizeListener","useTableRowSelectionListener","onRowSelect","useTableServerLoadingListener","useTableShortcutsListener","shortcuts","useTableSortingListener","onSort","length","_ref","_props$length","_props$data2","enableColumnFilters","enableFiltering","enableExpanding","enableRowExpansion","enableGlobalFilter","enableColumnHiding","enableMultiRowSelection","enableRowSelectionSingle","enableSorting","columnResizeMode","filterFns","tacoFilter","row","columnId","columnFilterFn","getValue","getFilteredRowModel","globalFilterFn","searchQuery","original","cell","getAllCells","columnMeta","columnDef","getIsVisible","cellValue","getCellValueAsString","dataType","getColumnCanGlobalFilter","_column$columnDef$met","manualSorting","getSortedRowModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SA0HgBA,QAAQA,CAAkBC,KAAyB,EAAEC,GAA+B;;;EAEhG,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGC,WAAW,CAACJ,KAAK,CAACK,EAAE,EAAEL,KAAK,CAACM,eAAe,EAAEN,KAAK,CAACO,gBAAgB,CAAC;;EAGpG,MAAMC,OAAO,GAAGC,cAAc,CAACT,KAAK,CAAC;;EAGrC,MAAMU,YAAY,GAAGC,0BAA0B,CAACX,KAAK,EAAEQ,OAAO,CAAC;;EAG/D,MAAMI,cAAc,GAAGC,iBAAiB,EAAAC,qBAAA,GAACZ,QAAQ,CAACa,mBAAmB,cAAAD,qBAAA,cAAAA,qBAAA,GAAId,KAAK,CAACgB,0BAA0B,EAAER,OAAO,CAAC;;EAEnH,MAAMS,UAAU,GAAGC,aAAa,CAAQlB,KAAK,CAACmB,cAAc,EAAEnB,KAAK,CAACoB,aAAa,CAAC;;EAElF,MAAMC,OAAO,GAAGC,UAAU,CAAQd,OAAO,CAACe,aAAa,EAAEtB,GAAG,EAAEgB,UAAU,EAAEjB,KAAK,CAACwB,MAAM,CAAC;;EAEvF,MAAMC,QAAQ,GAAGC,WAAW,CAAClB,OAAO,CAACmB,cAAc,EAAEzB,QAAQ,CAAC0B,mCAAmC,EAAE5B,KAAK,CAACK,EAAE,CAAC;;EAE5G,MAAMwB,UAAU,GAAGC,aAAa,CAAQ9B,KAAK,CAAC+B,aAAa,EAAE/B,KAAK,CAACgC,mBAAmB,CAAC;;EAEvF,MAAMC,OAAO,GAAGC,UAAU,CAAC1B,OAAO,CAAC2B,aAAa,CAAC;;EAEjD,MAAMC,OAAO,GAAGC,UAAU,CAAC7B,OAAO,CAAC8B,aAAa,EAAEtC,KAAK,CAACuC,SAAS,CAAC;;EAElE,MAA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AS,EAAEP,WAAW,CAAC;;;UAGrD,OAAO,KAAK;;OAEnB,CAAC,MAAM;;;MAIR,OAAO,KAAK;KACf;IACDzJ,YAAY,CAACuJ,mBAAmB,GAAGA,mBAAmB,EAAE;IACxDvJ,YAAY,CAACmK,wBAAwB,GAAItF,MAAuB;MAAA,IAAAuF,qBAAA;MAAA,QAAAA,qBAAA,GAC3DvF,MAAM,CAACiF,SAAS,CAAC9C,IAAmC,CAAChF,YAAY,cAAAoI,qBAAA,cAAAA,qBAAA,GAAI,IAAI;;;;EAIlF,IAAItK,OAAO,CAACiJ,aAAa,EAAE;IACvB,IAAIzJ,KAAK,CAAC4I,MAAM,EAAE;MACdlI,YAAY,CAACqK,aAAa,GAAG,IAAI;;KAEpC,MAAM;MACHrK,YAAY,CAACsK,iBAAiB,GAAGA,iBAAiB,EAAE;;;EAI5D,OAAOtK,YAAY;AACvB;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useLocalStorage.js","sources":["../../../../../../src/hooks/useLocalStorage.ts"],"sourcesContent":["import React from 'react';\n\nexport const useLocalStorage = <TType>(key?: string
|
1
|
+
{"version":3,"file":"useLocalStorage.js","sources":["../../../../../../src/hooks/useLocalStorage.ts"],"sourcesContent":["import React from 'react';\n\nexport const useLocalStorage = <TType>(\n key?: string,\n initialValue?: TType\n): [TType, React.Dispatch<React.SetStateAction<TType>>, () => void] => {\n const [state, setState] = React.useState<TType>(() => {\n if (!key) {\n return initialValue;\n }\n\n try {\n const localStorageValue = localStorage.getItem(key);\n\n if (typeof localStorageValue !== 'string') {\n localStorage.setItem(key, JSON.stringify(initialValue));\n return initialValue;\n } else {\n return JSON.parse(localStorageValue || 'null');\n }\n } catch {\n // If user is in private mode or has storage restriction\n // localStorage can throw. JSON.parse and JSON.stringify\n // can throw, too.\n return initialValue;\n }\n });\n\n React.useEffect(() => {\n if (!key) {\n return;\n }\n\n try {\n const serializedState = JSON.stringify(state);\n localStorage.setItem(key, serializedState);\n } catch {\n // If user is in private mode or has storage restriction\n // localStorage can throw. Also JSON.stringify can throw.\n }\n }, [key, state]);\n\n const clear = () => {\n if (key) {\n localStorage.removeItem(key);\n }\n };\n\n return [state, setState, clear];\n};\n"],"names":["useLocalStorage","key","initialValue","state","setState","React","useState","localStorageValue","localStorage","getItem","setItem","JSON","stringify","parse","useEffect","serializedState","clear","removeItem"],"mappings":";;MAEaA,eAAe,GAAGA,CAC3BC,GAAY,EACZC,YAAoB;EAEpB,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAQ;IAC5C,IAAI,CAACL,GAAG,EAAE;MACN,OAAOC,YAAY;;IAGvB,IAAI;MACA,MAAMK,iBAAiB,GAAGC,YAAY,CAACC,OAAO,CAACR,GAAG,CAAC;MAEnD,IAAI,OAAOM,iBAAiB,KAAK,QAAQ,EAAE;QACvCC,YAAY,CAACE,OAAO,CAACT,GAAG,EAAEU,IAAI,CAACC,SAAS,CAACV,YAAY,CAAC,CAAC;QACvD,OAAOA,YAAY;OACtB,MAAM;QACH,OAAOS,IAAI,CAACE,KAAK,CAACN,iBAAiB,IAAI,MAAM,CAAC;;KAErD,CAAC,MAAM;;;;MAIJ,OAAOL,YAAY;;GAE1B,CAAC;EAEFG,cAAK,CAACS,SAAS,CAAC;IACZ,IAAI,CAACb,GAAG,EAAE;MACN;;IAGJ,IAAI;MACA,MAAMc,eAAe,GAAGJ,IAAI,CAACC,SAAS,CAACT,KAAK,CAAC;MAC7CK,YAAY,CAACE,OAAO,CAACT,GAAG,EAAEc,eAAe,CAAC;KAC7C,CAAC,MAAM;;;;GAIX,EAAE,CAACd,GAAG,EAAEE,KAAK,CAAC,CAAC;EAEhB,MAAMa,KAAK,GAAGA;IACV,IAAIf,GAAG,EAAE;MACLO,YAAY,CAACS,UAAU,CAAChB,GAAG,CAAC;;GAEnC;EAED,OAAO,CAACE,KAAK,EAAEC,QAAQ,EAAEY,KAAK,CAAC;AACnC;;;;"}
|
@@ -17,12 +17,12 @@ export { Banner } from './components/Banner/Banner.js';
|
|
17
17
|
export { Button } from './components/Button/Button.js';
|
18
18
|
export { Calendar } from './components/Calendar/Calendar.js';
|
19
19
|
export { Card } from './components/Card/Card.js';
|
20
|
+
export { Spinner } from './components/Spinner/Spinner.js';
|
20
21
|
export { Checkbox } from './components/Checkbox/Checkbox.js';
|
21
22
|
export { useBoundingClientRectListener } from './hooks/useBoundingClientRectListener.js';
|
22
23
|
export { Input } from './components/Input/Input.js';
|
23
24
|
export { getNextIndexFromKey, useListKeyboardNavigation } from './utils/hooks/useListKeyboardNavigation.js';
|
24
25
|
export { useListScrollTo } from './utils/hooks/useListScrollTo.js';
|
25
|
-
export { Spinner } from './components/Spinner/Spinner.js';
|
26
26
|
export { Combobox } from './components/Combobox/Combobox.js';
|
27
27
|
export { format, isWeakEqual, parseFromCustomString, parseFromISOString } from './utils/date.js';
|
28
28
|
export { Popover } from './components/Popover/Popover.js';
|
@@ -23,6 +23,7 @@ const Button = /*#__PURE__*/forwardRef(function Button(props, ref) {
|
|
23
23
|
});
|
24
24
|
const Tag = props.href ? 'a' : 'button';
|
25
25
|
return /*#__PURE__*/createElement(Tag, Object.assign({}, otherProps, {
|
26
|
+
href: disabled ? undefined : props.href,
|
26
27
|
"aria-disabled": disabled ? 'true' : undefined,
|
27
28
|
disabled: disabled,
|
28
29
|
target: Tag === 'a' ? target : undefined,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../../../../src/primitives/Button.tsx"],"sourcesContent":["import * as React from 'react';\nimport { KeyDownHandlerOptions } from '../utils/keyboard';\nimport { useMergedRef } from '../hooks/useMergedRef';\nimport { useGlobalKeyDown } from '../hooks/useGlobalKeyDown';\n\ntype ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement | HTMLAnchorElement> & {\n /** Content should be a text */\n children: React.ReactNode;\n /** Provides url for buttons being used as a link */\n href?: string;\n shortcut?: string | KeyDownHandlerOptions;\n /** Provides target for buttons being used as a link */\n target?: '_self' | '_blank' | '_parent' | '_top';\n};\n\nconst Button = React.forwardRef(function Button(props: ButtonProps, ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>) {\n const { disabled, shortcut, target, type = 'button', ...otherProps } = props;\n const internalRef = useMergedRef<HTMLButtonElement | HTMLAnchorElement>(ref);\n\n useGlobalKeyDown(shortcut, event => {\n event?.preventDefault();\n const dialog = document.querySelector('[role=\"dialog\"]');\n\n // Don't trigger the click on the button if it is outside of the dialog\n if (dialog && !dialog?.contains(internalRef.current)) {\n return;\n }\n\n internalRef.current?.click();\n });\n\n const Tag = props.href ? 'a' : 'button';\n\n return (\n <Tag\n {...otherProps}\n aria-disabled={disabled ? 'true' : undefined}\n disabled={disabled}\n target={Tag === 'a' ? target : undefined}\n type={Tag !== 'a' ? type : undefined}\n ref={internalRef as any}>\n {React.Children.count(props.children) > 1\n ? React.Children.map(props.children, child => (typeof child === 'string' ? <span>{child}</span> : child))\n : props.children}\n </Tag>\n );\n});\n\nexport { Button };\nexport type { ButtonProps };\n"],"names":["Button","React","props","ref","disabled","shortcut","target","type","otherProps","internalRef","useMergedRef","useGlobalKeyDown","event","preventDefault","dialog","document","querySelector","contains","current","_internalRef$current","click","Tag","href","undefined","count","children","map","child"],"mappings":";;;;MAeMA,MAAM,gBAAGC,UAAgB,CAAC,SAASD,MAAMA,CAACE,KAAkB,EAAEC,GAAqD;EACrH,MAAM;IAAEC,QAAQ;IAAEC,QAAQ;IAAEC,MAAM;IAAEC,IAAI,GAAG,QAAQ;IAAE,GAAGC;GAAY,GAAGN,KAAK;EAC5E,MAAMO,WAAW,GAAGC,YAAY,CAAwCP,GAAG,CAAC;EAE5EQ,gBAAgB,CAACN,QAAQ,EAAEO,KAAK;;IAC5BA,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEC,cAAc,EAAE;IACvB,MAAMC,MAAM,GAAGC,QAAQ,CAACC,aAAa,CAAC,iBAAiB,CAAC;;IAGxD,IAAIF,MAAM,IAAI,EAACA,MAAM,aAANA,MAAM,eAANA,MAAM,CAAEG,QAAQ,CAACR,WAAW,CAACS,OAAO,CAAC,GAAE;MAClD;;IAGJ,CAAAC,oBAAA,GAAAV,WAAW,CAACS,OAAO,cAAAC,oBAAA,uBAAnBA,oBAAA,CAAqBC,KAAK,EAAE;GAC/B,CAAC;EAEF,MAAMC,GAAG,GAAGnB,KAAK,CAACoB,IAAI,GAAG,GAAG,GAAG,QAAQ;EAEvC,oBACIrB,cAACoB,GAAG,oBACIb,UAAU;
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../../../../../src/primitives/Button.tsx"],"sourcesContent":["import * as React from 'react';\nimport { KeyDownHandlerOptions } from '../utils/keyboard';\nimport { useMergedRef } from '../hooks/useMergedRef';\nimport { useGlobalKeyDown } from '../hooks/useGlobalKeyDown';\n\ntype ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement | HTMLAnchorElement> & {\n /** Content should be a text */\n children: React.ReactNode;\n /** Provides url for buttons being used as a link */\n href?: string;\n shortcut?: string | KeyDownHandlerOptions;\n /** Provides target for buttons being used as a link */\n target?: '_self' | '_blank' | '_parent' | '_top';\n};\n\nconst Button = React.forwardRef(function Button(props: ButtonProps, ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>) {\n const { disabled, shortcut, target, type = 'button', ...otherProps } = props;\n const internalRef = useMergedRef<HTMLButtonElement | HTMLAnchorElement>(ref);\n\n useGlobalKeyDown(shortcut, event => {\n event?.preventDefault();\n const dialog = document.querySelector('[role=\"dialog\"]');\n\n // Don't trigger the click on the button if it is outside of the dialog\n if (dialog && !dialog?.contains(internalRef.current)) {\n return;\n }\n\n internalRef.current?.click();\n });\n\n const Tag = props.href ? 'a' : 'button';\n\n return (\n <Tag\n {...otherProps}\n href={disabled ? undefined : props.href}\n aria-disabled={disabled ? 'true' : undefined}\n disabled={disabled}\n target={Tag === 'a' ? target : undefined}\n type={Tag !== 'a' ? type : undefined}\n ref={internalRef as any}>\n {React.Children.count(props.children) > 1\n ? React.Children.map(props.children, child => (typeof child === 'string' ? <span>{child}</span> : child))\n : props.children}\n </Tag>\n );\n});\n\nexport { Button };\nexport type { ButtonProps };\n"],"names":["Button","React","props","ref","disabled","shortcut","target","type","otherProps","internalRef","useMergedRef","useGlobalKeyDown","event","preventDefault","dialog","document","querySelector","contains","current","_internalRef$current","click","Tag","href","undefined","count","children","map","child"],"mappings":";;;;MAeMA,MAAM,gBAAGC,UAAgB,CAAC,SAASD,MAAMA,CAACE,KAAkB,EAAEC,GAAqD;EACrH,MAAM;IAAEC,QAAQ;IAAEC,QAAQ;IAAEC,MAAM;IAAEC,IAAI,GAAG,QAAQ;IAAE,GAAGC;GAAY,GAAGN,KAAK;EAC5E,MAAMO,WAAW,GAAGC,YAAY,CAAwCP,GAAG,CAAC;EAE5EQ,gBAAgB,CAACN,QAAQ,EAAEO,KAAK;;IAC5BA,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEC,cAAc,EAAE;IACvB,MAAMC,MAAM,GAAGC,QAAQ,CAACC,aAAa,CAAC,iBAAiB,CAAC;;IAGxD,IAAIF,MAAM,IAAI,EAACA,MAAM,aAANA,MAAM,eAANA,MAAM,CAAEG,QAAQ,CAACR,WAAW,CAACS,OAAO,CAAC,GAAE;MAClD;;IAGJ,CAAAC,oBAAA,GAAAV,WAAW,CAACS,OAAO,cAAAC,oBAAA,uBAAnBA,oBAAA,CAAqBC,KAAK,EAAE;GAC/B,CAAC;EAEF,MAAMC,GAAG,GAAGnB,KAAK,CAACoB,IAAI,GAAG,GAAG,GAAG,QAAQ;EAEvC,oBACIrB,cAACoB,GAAG,oBACIb,UAAU;IACdc,IAAI,EAAElB,QAAQ,GAAGmB,SAAS,GAAGrB,KAAK,CAACoB,IAAI;qBACxBlB,QAAQ,GAAG,MAAM,GAAGmB,SAAS;IAC5CnB,QAAQ,EAAEA,QAAQ;IAClBE,MAAM,EAAEe,GAAG,KAAK,GAAG,GAAGf,MAAM,GAAGiB,SAAS;IACxChB,IAAI,EAAEc,GAAG,KAAK,GAAG,GAAGd,IAAI,GAAGgB,SAAS;IACpCpB,GAAG,EAAEM;MACJR,QAAc,CAACuB,KAAK,CAACtB,KAAK,CAACuB,QAAQ,CAAC,GAAG,CAAC,GACnCxB,QAAc,CAACyB,GAAG,CAACxB,KAAK,CAACuB,QAAQ,EAAEE,KAAK,IAAK,OAAOA,KAAK,KAAK,QAAQ,gBAAG1B,4BAAO0B,KAAK,CAAQ,GAAGA,KAAM,CAAC,GACvGzB,KAAK,CAACuB,QAAQ,CAClB;AAEd,CAAC;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../../../../../src/primitives/Table/types.ts"],"sourcesContent":["import {\n ColumnFilter as ReactTableColumnFilter,\n ColumnFiltersState as ReactTableColumnFilterState,\n ColumnOrderState as ReactTableColumnOrderState,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSort as ReactTableColumnSort,\n ColumnSizingState as ReactTableColumnSizingState,\n GroupingState as ReactTableGroupingState,\n VisibilityState as ReactTableColumnVisibilityState,\n SortingState as ReactTableSortingState,\n BuiltInAggregationFn as ReactTableBuiltInAggregationFn,\n BuiltInSortingFn as ReactTableBuiltInSortingFn,\n HeaderContext as ReactTableHeaderContext,\n CellContext as ReactTableCellContext,\n ColumnMeta as ReactTableColumnMeta,\n} from '@tanstack/react-table';\nimport { FontSize, FontSizes, ValueOf } from '../../types';\nimport { MenuProps } from '../../components/Menu/Menu';\n\ntype TODO = any;\n\nexport type TableRef = HTMLTableElement & {\n instance: {\n resetFiltering: () => void;\n resetRowExpansion: () => void;\n resetRowSelection: () => void;\n resetSorting: () => void;\n };\n};\n\n// filtering\nexport enum TableFilterComparator {\n Contains,\n DoesNotContain,\n IsEqualTo,\n IsNotEqualTo,\n IsGreaterThan,\n IsLessThan,\n IsBetween,\n IsEmpty,\n IsNotEmpty,\n IsLessThanOrEqualTo,\n IsGreaterThanOrEqualTo,\n HasAnyOf,\n HasAllOf,\n HasNoneOf,\n}\nexport type TableFilterValue = {\n comparator: TableFilterComparator;\n value: any;\n};\nexport type TableFilter = {\n id: string;\n value: TableFilterValue;\n};\n\n// columns\nexport type TableColumnAlignment = 'left' | 'center' | 'right';\nexport type TableColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);\nexport type TableColumnDataType = 'auto' | 'number' | 'alphanumeric' | 'alphanumericCaseSensitive' | 'datetime' | 'boolean';\nexport type TableColumnFilter = ReactTableColumnFilter;\nexport type TableColumnMenu = (props: Partial<MenuProps>) => JSX.Element;\nexport type TableColumnRenderer<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererAggregate<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererControl<TType = unknown> =\n | ((props: TableColumnRendererControlProps, row?: TType) => JSX.Element)\n | 'datepicker'\n | 'input'\n | 'switch'\n | 'textarea';\nexport type TableColumnRendererControlProps = {\n className?: string;\n disabled?: boolean;\n fontSize?: FontSize;\n invalid?: boolean;\n onBlur?: (value: any) => void;\n onFocus?: React.FocusEventHandler;\n readOnly?: boolean;\n ref: React.RefObject<HTMLElement> | ((instance: HTMLElement | null | undefined) => void);\n setValue: (value: any) => void;\n value: any;\n};\nexport type TableColumnRendererHeader = string;\nexport type TableColumnRendererFooter<TValue> = (values: TValue[]) => JSX.Element | string | number | null;\nexport type TableColumnSort = ReactTableColumnSort;\nexport type TableColumnSortDirection = 'asc' | 'desc';\nexport type TableColumnSortFn<TType = unknown> =\n | ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1)\n | ReactTableBuiltInSortingFn\n | 'auto';\nexport type TableColumnWidth = number | 'grow';\n\n// rows\nexport type TableRowActionRenderer<TType = unknown> = (row: TType) => JSX.Element | null;\nexport type TableRowActionGroupRenderer<TType = unknown> = (rows: TType[]) => JSX.Element | null;\nexport type TableRowClickHandler<TType = unknown> = (row: TType) => void;\nexport type TableRowGotoHandler = (\n column: string,\n query: string,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<number>;\nexport type TableRowHeight = 'short' | 'medium' | 'tall' | 'extra-tall';\nexport type TableRowSelectHandler<TType = unknown> = (rows: TType[]) => void;\n\n// shortcuts\nexport type TableShortcutHandlerFn<TType = unknown> = (row: TType) => void;\nexport type TableShortcutHandlerObject<TType = unknown> = {\n handler: TableShortcutHandlerFn<TType>;\n meta?: boolean;\n shift?: boolean;\n};\n\n// table\nexport type TableFilterHandler = (filters: TableColumnFilter[]) => void;\nexport type TableFontSize = keyof typeof FontSizes;\nexport type TablePreset = 'lite' | 'complex';\nexport type TableRowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;\nexport type TableScrollToIndexHandler = (index: number, options?: { align: 'start' | 'center' | 'end' | 'auto' }) => void;\nexport type TableServerLoadPageHandler = (\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<void>;\nexport type TableServerLoadAllHandler = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<void>;\nexport enum TableServerLoadAllState {\n Incomplete,\n Loading,\n Completed,\n}\nexport type TableSettingsHandler = (settings: TableSettings) => void | Promise<void>;\nexport type TableShortcuts<TType = unknown> = Record<string, TableShortcutHandlerFn<TType> | TableShortcutHandlerObject<TType>>;\nexport type TableSortHandler = (sorting: TableColumnSort[]) => void;\n\n// settings\nexport type TableSettings = {\n columnFilters?: ReactTableColumnFilterState;\n columnOrder?: ReactTableColumnOrderState;\n columnPinning?: ReactTableColumnPinningState;\n columnSizing?: ReactTableColumnSizingState;\n columnVisibility?: ReactTableColumnVisibilityState;\n excludeUnmatchedRecordsInSearch?: boolean;\n fontSize?: TableFontSize;\n grouping?: ReactTableGroupingState;\n rowHeight?: TableRowHeight;\n showWarningWhenPrintingLargeDataset?: boolean;\n searchQuery?: string;\n sorting?: ReactTableSortingState;\n};\nexport type EnableSettingsOptions = {\n columnOrder: boolean;\n columnPinning: boolean;\n columnSizing: boolean;\n columnVisibility: boolean;\n excludeUnmatchedRecordsInSearch: boolean;\n fontSize: boolean;\n grouping: boolean;\n rowHeight: boolean;\n showWarningWhenPrintingLargeDataset: boolean;\n sorting: boolean;\n};\n\n// props\nexport type TableFeatureProps = {\n // react-table built-in\n enableFiltering?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableColumnFreezing?: boolean;\n enableColumnHiding?: boolean;\n enableColumnResizing?: boolean;\n enableRowExpansion?: boolean;\n enableRowSelection?: boolean;\n enableRowSelectionSingle?: boolean;\n\n // custom -- common between all table types\n enableColumnOrdering?: boolean;\n enableFontSize?: boolean;\n enableFooter?: boolean;\n enablePrinting?: boolean;\n enableRowActions?: boolean;\n enableRowActive?: boolean;\n enableRowClick?: boolean;\n enableRowGoto?: boolean;\n enableRowHeight?: boolean;\n enableSaveSettings?: boolean | Partial<EnableSettingsOptions>;\n};\n\nexport type useTableInternalColumn<TType = unknown> = {\n header?: (info: ReactTableHeaderContext<TType, unknown>) => JSX.Element | string | null;\n renderer: (info: ReactTableCellContext<TType, unknown>) => JSX.Element | string | null;\n meta?: ReactTableColumnMeta<TType, unknown>;\n size?: number;\n};\n\nexport type useTableInternalColumns<TType = unknown> = {\n rowActions?: useTableInternalColumn<TType>;\n rowExpansion?: useTableInternalColumn<TType>;\n rowSelection?: useTableInternalColumn<TType>;\n};\n\ntype useTableCommonProps<TType = unknown> = TableFeatureProps & {\n children: (JSX.Element | boolean | null | undefined)[];\n data: TType[];\n id: string;\n\n // misc\n defaultColumnFreezingIndex?: number;\n defaultRowActiveIndex?: number;\n defaultRowGroupColumnId?: keyof TType;\n defaultSettings?: TableSettings;\n preset?: TablePreset;\n rowActions?: TableRowActionRenderer<TType>[];\n rowActionsForGroup?: TableRowActionGroupRenderer<TType>[];\n rowActionsLength?: number;\n rowExpansionRenderer?: TableRowExpansionRenderer<TType>;\n shortcuts?: TableShortcuts<TType>;\n\n // handlers\n onRowClick?: TableRowClickHandler<TType>;\n onRowGoto?: TableRowGotoHandler;\n onRowSelect?: TableRowSelectHandler<TType>;\n\n // state change handlers\n onChangeFilter?: TableFilterHandler;\n onChangeSearch?: TODO; // not currently supported\n onChangeSettings?: TableSettingsHandler;\n onChangeSort?: TableSortHandler;\n};\n\nexport interface useTableClientProps<TType = unknown> extends useTableCommonProps<TType> {\n length?: never;\n loadAll?: never;\n loadPage?: never;\n pageSize?: never;\n}\n\nexport interface useTableServerProps<TType = unknown> extends useTableCommonProps<TType> {\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n pageSize?: number;\n}\n\nexport type useTableProps<TType = unknown> = useTableClientProps<TType> | useTableServerProps<TType>;\n\nexport type TableColumnProps<TType = unknown> = ValueOf<{\n [Key in keyof TType]: {\n accessor?: Key;\n id: string;\n } & {\n // renderers\n renderer?: TableColumnRenderer<TType, TType[Key]>;\n /** Renderer to use if the cell is an aggregate cell and part of a grouped row */\n aggregate?: TableColumnRendererAggregate<TType, TType[Key]>;\n control?: TableColumnRendererControl<TType>;\n footer?: TableColumnRendererFooter<TType[Key]>;\n header: TableColumnRendererHeader;\n // options\n /** Aggregation function to be used when the column is part of a grouped row */\n aggregationFn?: 'auto' | ReactTableBuiltInAggregationFn;\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TType>;\n dataType?: TableColumnDataType;\n defaultHidden?: boolean;\n defaultWidth?: TableColumnWidth;\n enableFiltering?: boolean;\n enableGrouping?: boolean;\n enableHiding?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableResizing?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n headerClassName?: string;\n menu?: TableColumnMenu;\n minWidth?: number;\n sort?: TableColumnSortDirection;\n sortFn?: TableColumnSortFn<TType>;\n tooltip?: string;\n };\n}>;\n\nexport type TableGroupProps = {\n children: (JSX.Element | boolean | null | undefined)[];\n header: string;\n id: string;\n};\n"],"names":["TableFilterComparator","TableServerLoadAllState"],"mappings":"AA8BA;IACYA;AAAZ,WAAYA,qBAAqB;EAC7BA,yEAAQ;EACRA,qFAAc;EACdA,2EAAS;EACTA,iFAAY;EACZA,mFAAa;EACbA,6EAAU;EACVA,2EAAS;EACTA,uEAAO;EACPA,6EAAU;EACVA,+FAAmB;EACnBA,sGAAsB;EACtBA,0EAAQ;EACRA,0EAAQ;EACRA,4EAAS;AACb,CAAC,EAfWA,qBAAqB,KAArBA,qBAAqB;IAoGrBC;AAAZ,WAAYA,uBAAuB;EAC/BA,iFAAU;EACVA,2EAAO;EACPA,+EAAS;AACb,CAAC,EAJWA,uBAAuB,KAAvBA,uBAAuB;;;;"}
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../../../../../src/primitives/Table/types.ts"],"sourcesContent":["import {\n ColumnFilter as ReactTableColumnFilter,\n ColumnFiltersState as ReactTableColumnFilterState,\n ColumnOrderState as ReactTableColumnOrderState,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSort as ReactTableColumnSort,\n ColumnSizingState as ReactTableColumnSizingState,\n GroupingState as ReactTableGroupingState,\n VisibilityState as ReactTableColumnVisibilityState,\n SortingState as ReactTableSortingState,\n BuiltInAggregationFn as ReactTableBuiltInAggregationFn,\n BuiltInSortingFn as ReactTableBuiltInSortingFn,\n HeaderContext as ReactTableHeaderContext,\n CellContext as ReactTableCellContext,\n ColumnMeta as ReactTableColumnMeta,\n} from '@tanstack/react-table';\nimport { FontSize, FontSizes, ValueOf } from '../../types';\nimport { MenuProps } from '../../components/Menu/Menu';\n\ntype TODO = any;\n\nexport type TableRef = HTMLTableElement & {\n instance: {\n resetFiltering: () => void;\n resetRowExpansion: () => void;\n resetRowSelection: () => void;\n resetSorting: () => void;\n };\n};\n\n// filtering\nexport enum TableFilterComparator {\n Contains,\n DoesNotContain,\n IsEqualTo,\n IsNotEqualTo,\n IsGreaterThan,\n IsLessThan,\n IsBetween,\n IsEmpty,\n IsNotEmpty,\n IsLessThanOrEqualTo,\n IsGreaterThanOrEqualTo,\n HasAnyOf,\n HasAllOf,\n HasNoneOf,\n}\nexport type TableFilterValue = {\n comparator: TableFilterComparator;\n value: any;\n};\nexport type TableFilter = {\n id: string;\n value: TableFilterValue;\n};\n\n// columns\nexport type TableColumnAlignment = 'left' | 'center' | 'right';\nexport type TableColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);\nexport type TableColumnDataType = 'auto' | 'number' | 'alphanumeric' | 'alphanumericCaseSensitive' | 'datetime' | 'boolean';\nexport type TableColumnFilter = ReactTableColumnFilter;\nexport type TableColumnMenu = (props: Partial<MenuProps>) => JSX.Element;\nexport type TableColumnRenderer<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererAggregate<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererControl<TType = unknown> =\n | ((props: TableColumnRendererControlProps, row?: TType) => JSX.Element)\n | 'datepicker'\n | 'input'\n | 'switch'\n | 'textarea';\nexport type TableColumnRendererControlProps = {\n className?: string;\n disabled?: boolean;\n fontSize?: FontSize;\n invalid?: boolean;\n onBlur?: (value: any) => void;\n onFocus?: React.FocusEventHandler;\n readOnly?: boolean;\n ref: React.RefObject<HTMLElement> | ((instance: HTMLElement | null | undefined) => void);\n setValue: (value: any) => void;\n value: any;\n};\nexport type TableColumnRendererHeader = string;\nexport type TableColumnRendererFooter<TValue> = (values: TValue[]) => JSX.Element | string | number | null;\nexport type TableColumnSort = ReactTableColumnSort;\nexport type TableColumnSortDirection = 'asc' | 'desc';\nexport type TableColumnSortFn<TType = unknown> =\n | ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1)\n | ReactTableBuiltInSortingFn\n | 'auto';\nexport type TableColumnWidth = number | 'grow';\n\n// rows\nexport type TableRowActionRenderer<TType = unknown> = (row: TType) => JSX.Element | null;\nexport type TableRowActionGroupRenderer<TType = unknown> = (rows: TType[]) => JSX.Element | null;\nexport type TableRowClickHandler<TType = unknown> = (row: TType) => void;\nexport type TableRowGotoHandler = (\n column: string,\n query: string,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<number>;\nexport type TableRowHeight = 'short' | 'medium' | 'tall' | 'extra-tall';\nexport type TableRowSelectHandler<TType = unknown> = (rows: TType[]) => void;\n\n// shortcuts\nexport type TableShortcutHandlerFn<TType = unknown> = (row: TType) => void;\nexport type TableShortcutHandlerObject<TType = unknown> = {\n handler: TableShortcutHandlerFn<TType>;\n meta?: boolean;\n shift?: boolean;\n};\n\n// table\nexport type TableFilterHandler = (filters: TableColumnFilter[]) => void;\nexport type TableFontSize = keyof typeof FontSizes;\nexport type TablePreset = 'lite' | 'complex';\nexport type TableRowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;\nexport type TableScrollToIndexHandler = (index: number, options?: { align: 'start' | 'center' | 'end' | 'auto' }) => void;\nexport type TableServerLoadPageHandler = (\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<void>;\nexport type TableServerLoadAllHandler = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<void>;\nexport enum TableServerLoadAllState {\n Incomplete,\n Loading,\n Completed,\n}\nexport type TableSettingsHandler = (settings: TableSettings) => void | Promise<void>;\nexport type TableShortcuts<TType = unknown> = Record<string, TableShortcutHandlerFn<TType> | TableShortcutHandlerObject<TType>>;\nexport type TableSortHandler = (sorting: TableColumnSort[]) => void;\n\n// settings\nexport type TableSettings = {\n columnFilters?: ReactTableColumnFilterState;\n columnOrder?: ReactTableColumnOrderState;\n columnPinning?: ReactTableColumnPinningState;\n columnSizing?: ReactTableColumnSizingState;\n columnVisibility?: ReactTableColumnVisibilityState;\n excludeUnmatchedRecordsInSearch?: boolean;\n fontSize?: TableFontSize;\n grouping?: ReactTableGroupingState;\n rowHeight?: TableRowHeight;\n searchQuery?: string;\n sorting?: ReactTableSortingState;\n};\nexport type EnableSettingsOptions = {\n columnOrder: boolean;\n columnPinning: boolean;\n columnSizing: boolean;\n columnVisibility: boolean;\n excludeUnmatchedRecordsInSearch: boolean;\n fontSize: boolean;\n grouping: boolean;\n rowHeight: boolean;\n sorting: boolean;\n};\n\n// props\nexport type TableFeatureProps = {\n // react-table built-in\n enableFiltering?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableColumnFreezing?: boolean;\n enableColumnHiding?: boolean;\n enableColumnResizing?: boolean;\n enableRowExpansion?: boolean;\n enableRowSelection?: boolean;\n enableRowSelectionSingle?: boolean;\n\n // custom -- common between all table types\n enableColumnOrdering?: boolean;\n enableFontSize?: boolean;\n enableFooter?: boolean;\n enablePrinting?: boolean;\n enableRowActions?: boolean;\n enableRowActive?: boolean;\n enableRowClick?: boolean;\n enableRowGoto?: boolean;\n enableRowHeight?: boolean;\n enableSaveSettings?: boolean | Partial<EnableSettingsOptions>;\n};\n\nexport type useTableInternalColumn<TType = unknown> = {\n header?: (info: ReactTableHeaderContext<TType, unknown>) => JSX.Element | string | null;\n renderer: (info: ReactTableCellContext<TType, unknown>) => JSX.Element | string | null;\n meta?: ReactTableColumnMeta<TType, unknown>;\n size?: number;\n};\n\nexport type useTableInternalColumns<TType = unknown> = {\n rowActions?: useTableInternalColumn<TType>;\n rowExpansion?: useTableInternalColumn<TType>;\n rowSelection?: useTableInternalColumn<TType>;\n};\n\ntype useTableCommonProps<TType = unknown> = TableFeatureProps & {\n children: (JSX.Element | boolean | null | undefined)[];\n data: TType[];\n id: string;\n\n // misc\n defaultColumnFreezingIndex?: number;\n defaultRowActiveIndex?: number;\n defaultRowGroupColumnId?: keyof TType;\n defaultSettings?: TableSettings;\n preset?: TablePreset;\n rowActions?: TableRowActionRenderer<TType>[];\n rowActionsForGroup?: TableRowActionGroupRenderer<TType>[];\n rowActionsLength?: number;\n rowExpansionRenderer?: TableRowExpansionRenderer<TType>;\n shortcuts?: TableShortcuts<TType>;\n\n // handlers\n onRowClick?: TableRowClickHandler<TType>;\n onRowGoto?: TableRowGotoHandler;\n onRowSelect?: TableRowSelectHandler<TType>;\n\n // state change handlers\n onChangeFilter?: TableFilterHandler;\n onChangeSearch?: TODO; // not currently supported\n onChangeSettings?: TableSettingsHandler;\n onChangeSort?: TableSortHandler;\n};\n\nexport interface useTableClientProps<TType = unknown> extends useTableCommonProps<TType> {\n length?: never;\n loadAll?: never;\n loadPage?: never;\n pageSize?: never;\n}\n\nexport interface useTableServerProps<TType = unknown> extends useTableCommonProps<TType> {\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n pageSize?: number;\n}\n\nexport type useTableProps<TType = unknown> = useTableClientProps<TType> | useTableServerProps<TType>;\n\nexport type TableColumnProps<TType = unknown> = ValueOf<{\n [Key in keyof TType]: {\n accessor?: Key;\n id: string;\n } & {\n // renderers\n renderer?: TableColumnRenderer<TType, TType[Key]>;\n /** Renderer to use if the cell is an aggregate cell and part of a grouped row */\n aggregate?: TableColumnRendererAggregate<TType, TType[Key]>;\n control?: TableColumnRendererControl<TType>;\n footer?: TableColumnRendererFooter<TType[Key]>;\n header: TableColumnRendererHeader;\n // options\n /** Aggregation function to be used when the column is part of a grouped row */\n aggregationFn?: 'auto' | ReactTableBuiltInAggregationFn;\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TType>;\n dataType?: TableColumnDataType;\n defaultHidden?: boolean;\n defaultWidth?: TableColumnWidth;\n enableFiltering?: boolean;\n enableGrouping?: boolean;\n enableHiding?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableResizing?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n headerClassName?: string;\n menu?: TableColumnMenu;\n minWidth?: number;\n sort?: TableColumnSortDirection;\n sortFn?: TableColumnSortFn<TType>;\n tooltip?: string;\n };\n}>;\n\nexport type TableGroupProps = {\n children: (JSX.Element | boolean | null | undefined)[];\n header: string;\n id: string;\n};\n"],"names":["TableFilterComparator","TableServerLoadAllState"],"mappings":"AA8BA;IACYA;AAAZ,WAAYA,qBAAqB;EAC7BA,yEAAQ;EACRA,qFAAc;EACdA,2EAAS;EACTA,iFAAY;EACZA,mFAAa;EACbA,6EAAU;EACVA,2EAAS;EACTA,uEAAO;EACPA,6EAAU;EACVA,+FAAmB;EACnBA,sGAAsB;EACtBA,0EAAQ;EACRA,0EAAQ;EACRA,4EAAS;AACb,CAAC,EAfWA,qBAAqB,KAArBA,qBAAqB;IAoGrBC;AAAZ,WAAYA,uBAAuB;EAC/BA,iFAAU;EACVA,2EAAO;EACPA,+EAAS;AACb,CAAC,EAJWA,uBAAuB,KAAvBA,uBAAuB;;;;"}
|
@@ -1,16 +1,36 @@
|
|
1
1
|
import React__default from 'react';
|
2
|
+
import { useTacoSettings } from '../../../../hooks/useTacoSettings.js';
|
3
|
+
import { useLocalStorage } from '../../../../hooks/useLocalStorage.js';
|
2
4
|
|
3
|
-
function useTablePrinting(isEnabled = false,
|
5
|
+
function useTablePrinting(isEnabled = false, tableId) {
|
4
6
|
const [isPrinting, setIsPrinting] = React__default.useState(false);
|
5
|
-
const [
|
7
|
+
const [settings, setSetting] = useTablePrintingSettings(tableId);
|
6
8
|
return {
|
7
9
|
isEnabled,
|
8
10
|
isPrinting,
|
9
11
|
setIsPrinting,
|
10
|
-
|
11
|
-
|
12
|
+
settings,
|
13
|
+
setSetting
|
12
14
|
};
|
13
15
|
}
|
16
|
+
const DEFAULT_PRINT_SETTINGS = {
|
17
|
+
size: 'A4',
|
18
|
+
orientation: 'portrait',
|
19
|
+
allRows: true,
|
20
|
+
splitGroups: true
|
21
|
+
};
|
22
|
+
function useTablePrintingSettings(tableId) {
|
23
|
+
const tacoSettings = useTacoSettings();
|
24
|
+
const uniqueId = `taco.${tacoSettings.uniqueUserIdentifier}.table.${tableId}.print.settings`;
|
25
|
+
const [persistedSettings, setPersistedSettings] = useLocalStorage(uniqueId, DEFAULT_PRINT_SETTINGS);
|
26
|
+
function setSetting(key, value) {
|
27
|
+
setPersistedSettings(currentSettings => ({
|
28
|
+
...currentSettings,
|
29
|
+
[key]: value
|
30
|
+
}));
|
31
|
+
}
|
32
|
+
return [persistedSettings, setSetting];
|
33
|
+
}
|
14
34
|
|
15
35
|
export { useTablePrinting };
|
16
36
|
//# sourceMappingURL=useTablePrinting.js.map
|
package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTablePrinting.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTablePrinting.js","sources":["../../../../../../../../../src/primitives/Table/useTable/features/useTablePrinting.ts"],"sourcesContent":["import React from 'react';\n\nexport function useTablePrinting(isEnabled = false,
|
1
|
+
{"version":3,"file":"useTablePrinting.js","sources":["../../../../../../../../../src/primitives/Table/useTable/features/useTablePrinting.ts"],"sourcesContent":["import React from 'react';\nimport { useTacoSettings } from '../../../../hooks/useTacoSettings';\nimport { useLocalStorage } from '../../../../hooks/useLocalStorage';\n\ntype TablePrintSettings = {\n allRows: boolean;\n orientation: 'portrait' | 'landscape';\n size: 'A3' | 'A4' | 'A5' | 'letter' | 'legal';\n splitGroups: boolean;\n};\n\nexport function useTablePrinting(isEnabled = false, tableId: string) {\n const [isPrinting, setIsPrinting] = React.useState(false);\n const [settings, setSetting] = useTablePrintingSettings(tableId);\n\n return {\n isEnabled,\n isPrinting,\n setIsPrinting,\n settings,\n setSetting,\n };\n}\n\nconst DEFAULT_PRINT_SETTINGS: TablePrintSettings = {\n size: 'A4',\n orientation: 'portrait',\n allRows: true,\n splitGroups: true,\n};\n\nfunction useTablePrintingSettings(tableId: string): [TablePrintSettings, (key: keyof TablePrintSettings, value: any) => void] {\n const tacoSettings = useTacoSettings();\n const uniqueId = `taco.${tacoSettings.uniqueUserIdentifier}.table.${tableId}.print.settings`;\n\n const [persistedSettings, setPersistedSettings] = useLocalStorage<TablePrintSettings>(uniqueId, DEFAULT_PRINT_SETTINGS);\n\n function setSetting(key: keyof TablePrintSettings, value: any) {\n setPersistedSettings(currentSettings => ({\n ...currentSettings,\n [key]: value,\n }));\n }\n\n return [persistedSettings, setSetting];\n}\n"],"names":["useTablePrinting","isEnabled","tableId","isPrinting","setIsPrinting","React","useState","settings","setSetting","useTablePrintingSettings","DEFAULT_PRINT_SETTINGS","size","orientation","allRows","splitGroups","tacoSettings","useTacoSettings","uniqueId","uniqueUserIdentifier","persistedSettings","setPersistedSettings","useLocalStorage","key","value","currentSettings"],"mappings":";;;;SAWgBA,gBAAgBA,CAACC,SAAS,GAAG,KAAK,EAAEC,OAAe;EAC/D,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;EACzD,MAAM,CAACC,QAAQ,EAAEC,UAAU,CAAC,GAAGC,wBAAwB,CAACP,OAAO,CAAC;EAEhE,OAAO;IACHD,SAAS;IACTE,UAAU;IACVC,aAAa;IACbG,QAAQ;IACRC;GACH;AACL;AAEA,MAAME,sBAAsB,GAAuB;EAC/CC,IAAI,EAAE,IAAI;EACVC,WAAW,EAAE,UAAU;EACvBC,OAAO,EAAE,IAAI;EACbC,WAAW,EAAE;CAChB;AAED,SAASL,wBAAwBA,CAACP,OAAe;EAC7C,MAAMa,YAAY,GAAGC,eAAe,EAAE;EACtC,MAAMC,QAAQ,WAAWF,YAAY,CAACG,8BAA8BhB,wBAAwB;EAE5F,MAAM,CAACiB,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGC,eAAe,CAAqBJ,QAAQ,EAAEP,sBAAsB,CAAC;EAEvH,SAASF,UAAUA,CAACc,GAA6B,EAAEC,KAAU;IACzDH,oBAAoB,CAACI,eAAe,KAAK;MACrC,GAAGA,eAAe;MAClB,CAACF,GAAG,GAAGC;KACV,CAAC,CAAC;;EAGP,OAAO,CAACJ,iBAAiB,EAAEX,UAAU,CAAC;AAC1C;;;;"}
|