@economic/taco 2.55.0-settings.1 → 2.55.0-settings.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSettingsListener.js +4 -2
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSettingsListener.js.map +1 -1
- package/dist/taco.cjs.development.js +4 -2
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/package.json +2 -2
@@ -7,13 +7,15 @@ function useTableSettingsListener(table, tableId, onChangeSettings, isEnabled =
|
|
7
7
|
const taco = useTaco();
|
8
8
|
const meta = table.options.meta;
|
9
9
|
const state = table.getState();
|
10
|
+
const lastUsedSettingsRef = React__default.useRef(removeDisabledSettings(getSettings(table), enabledSettings));
|
10
11
|
React__default.useEffect(() => {
|
11
12
|
const handler = setTimeout(() => {
|
12
13
|
if (!hasSomeEnabledSettings) {
|
13
14
|
return;
|
14
15
|
}
|
15
16
|
const settings = removeDisabledSettings(getSettings(table), enabledSettings);
|
16
|
-
if (Object.keys(settings).length) {
|
17
|
+
if (Object.keys(settings).length && JSON.stringify(settings) !== JSON.stringify(lastUsedSettingsRef.current)) {
|
18
|
+
lastUsedSettingsRef.current = settings;
|
17
19
|
// some settings shouldn't be persisted, but we comment them out here to highlight the intention
|
18
20
|
taco.settings.saveSetting(getSettingsId(tableId), settings);
|
19
21
|
if (onChangeSettings) {
|
@@ -28,7 +30,7 @@ function useTableSettingsListener(table, tableId, onChangeSettings, isEnabled =
|
|
28
30
|
//state.grouping,
|
29
31
|
meta.printing.settings, meta.rowHeight.height,
|
30
32
|
//state.globalFilter,
|
31
|
-
state.sorting]);
|
33
|
+
state.sorting, lastUsedSettingsRef.current]);
|
32
34
|
}
|
33
35
|
const DEFAULT_ENABLED_OPTIONS = {
|
34
36
|
columnOrder: true,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableSettingsListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableSettingsListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { getSettings, getSettingsId } from '../util/settings';\nimport { useTaco } from '../../../../hooks/useTaco';\nimport { TableEnableSettingsOptions, TableSettings, TableSettingsHandler } from '../../types';\n\nexport function useTableSettingsListener<TType = unknown>(\n table: ReactTable<TType>,\n tableId: string,\n onChangeSettings: TableSettingsHandler | undefined,\n isEnabled: boolean | Partial<TableEnableSettingsOptions> = false\n) {\n const [enabledSettings, hasSomeEnabledSettings] = useEnabledSettings(isEnabled);\n const taco = useTaco();\n const meta = table.options.meta as ReactTableMeta<TType>;\n const state = table.getState();\n\n React.useEffect(() => {\n const handler = setTimeout(() => {\n if (!hasSomeEnabledSettings) {\n return;\n }\n\n const settings = removeDisabledSettings(getSettings(table), enabledSettings);\n\n if (Object.keys(settings).length) {\n // some settings shouldn't be persisted, but we comment them out here to highlight the intention\n taco.settings.saveSetting(getSettingsId(tableId), settings);\n\n if (onChangeSettings) {\n onChangeSettings(getSettings(table));\n }\n }\n }, 250);\n\n return () => clearTimeout(handler);\n }, [\n //state.columnFilters,\n state.columnOrder,\n state.columnPinning,\n state.columnSizing,\n state.columnVisibility,\n table.options.enableGlobalFilter,\n meta.fontSize.size,\n //state.grouping,\n meta.printing.settings,\n meta.rowHeight.height,\n //state.globalFilter,\n state.sorting,\n ]);\n}\n\nconst DEFAULT_ENABLED_OPTIONS = {\n columnOrder: true,\n columnPinning: true,\n columnSizing: true,\n columnVisibility: true,\n excludeUnmatchedRecordsInSearch: true,\n fontSize: true,\n grouping: true,\n rowHeight: true,\n sorting: true,\n};\n\nfunction useEnabledSettings(isEnabled: boolean | Partial<TableEnableSettingsOptions>): [TableEnableSettingsOptions, boolean] {\n return React.useMemo(() => {\n if (isEnabled === false) {\n return [\n Object.keys(DEFAULT_ENABLED_OPTIONS).reduce(\n (o, key) => ({ ...o, [key]: false }),\n {}\n ) as TableEnableSettingsOptions,\n false,\n ];\n } else if (isEnabled === true) {\n return [DEFAULT_ENABLED_OPTIONS, true];\n }\n\n const options = { ...DEFAULT_ENABLED_OPTIONS, ...isEnabled };\n return [options, Object.values(options).some(o => o === true)];\n }, [isEnabled]);\n}\n\nfunction removeDisabledSettings(settings: TableSettings, enabledSettings: TableEnableSettingsOptions) {\n const sanitizedSettings: TableSettings = { ...settings };\n\n Object.keys(enabledSettings).forEach(setting => {\n if (!enabledSettings[setting]) {\n delete sanitizedSettings[setting];\n }\n });\n\n return sanitizedSettings;\n}\n"],"names":["useTableSettingsListener","table","tableId","onChangeSettings","isEnabled","enabledSettings","hasSomeEnabledSettings","useEnabledSettings","taco","useTaco","meta","options","state","getState","React","useEffect","handler","setTimeout","settings","
|
1
|
+
{"version":3,"file":"useTableSettingsListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableSettingsListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { getSettings, getSettingsId } from '../util/settings';\nimport { useTaco } from '../../../../hooks/useTaco';\nimport { TableEnableSettingsOptions, TableSettings, TableSettingsHandler } from '../../types';\n\nexport function useTableSettingsListener<TType = unknown>(\n table: ReactTable<TType>,\n tableId: string,\n onChangeSettings: TableSettingsHandler | undefined,\n isEnabled: boolean | Partial<TableEnableSettingsOptions> = false\n) {\n const [enabledSettings, hasSomeEnabledSettings] = useEnabledSettings(isEnabled);\n const taco = useTaco();\n const meta = table.options.meta as ReactTableMeta<TType>;\n const state = table.getState();\n\n const lastUsedSettingsRef = React.useRef(removeDisabledSettings(getSettings(table), enabledSettings));\n\n React.useEffect(() => {\n const handler = setTimeout(() => {\n if (!hasSomeEnabledSettings) {\n return;\n }\n\n const settings = removeDisabledSettings(getSettings(table), enabledSettings);\n\n if (Object.keys(settings).length && JSON.stringify(settings) !== JSON.stringify(lastUsedSettingsRef.current)) {\n lastUsedSettingsRef.current = settings;\n\n // some settings shouldn't be persisted, but we comment them out here to highlight the intention\n taco.settings.saveSetting(getSettingsId(tableId), settings);\n\n if (onChangeSettings) {\n onChangeSettings(getSettings(table));\n }\n }\n }, 250);\n\n return () => clearTimeout(handler);\n }, [\n //state.columnFilters,\n state.columnOrder,\n state.columnPinning,\n state.columnSizing,\n state.columnVisibility,\n table.options.enableGlobalFilter,\n meta.fontSize.size,\n //state.grouping,\n meta.printing.settings,\n meta.rowHeight.height,\n //state.globalFilter,\n state.sorting,\n lastUsedSettingsRef.current,\n ]);\n}\n\nconst DEFAULT_ENABLED_OPTIONS = {\n columnOrder: true,\n columnPinning: true,\n columnSizing: true,\n columnVisibility: true,\n excludeUnmatchedRecordsInSearch: true,\n fontSize: true,\n grouping: true,\n rowHeight: true,\n sorting: true,\n};\n\nfunction useEnabledSettings(isEnabled: boolean | Partial<TableEnableSettingsOptions>): [TableEnableSettingsOptions, boolean] {\n return React.useMemo(() => {\n if (isEnabled === false) {\n return [\n Object.keys(DEFAULT_ENABLED_OPTIONS).reduce(\n (o, key) => ({ ...o, [key]: false }),\n {}\n ) as TableEnableSettingsOptions,\n false,\n ];\n } else if (isEnabled === true) {\n return [DEFAULT_ENABLED_OPTIONS, true];\n }\n\n const options = { ...DEFAULT_ENABLED_OPTIONS, ...isEnabled };\n return [options, Object.values(options).some(o => o === true)];\n }, [isEnabled]);\n}\n\nfunction removeDisabledSettings(settings: TableSettings, enabledSettings: TableEnableSettingsOptions) {\n const sanitizedSettings: TableSettings = { ...settings };\n\n Object.keys(enabledSettings).forEach(setting => {\n if (!enabledSettings[setting]) {\n delete sanitizedSettings[setting];\n }\n });\n\n return sanitizedSettings;\n}\n"],"names":["useTableSettingsListener","table","tableId","onChangeSettings","isEnabled","enabledSettings","hasSomeEnabledSettings","useEnabledSettings","taco","useTaco","meta","options","state","getState","lastUsedSettingsRef","React","useRef","removeDisabledSettings","getSettings","useEffect","handler","setTimeout","settings","Object","keys","length","JSON","stringify","current","saveSetting","getSettingsId","clearTimeout","columnOrder","columnPinning","columnSizing","columnVisibility","enableGlobalFilter","fontSize","size","printing","rowHeight","height","sorting","DEFAULT_ENABLED_OPTIONS","excludeUnmatchedRecordsInSearch","grouping","useMemo","reduce","o","key","values","some","sanitizedSettings","forEach","setting"],"mappings":";;;;SAMgBA,wBAAwBA,CACpCC,KAAwB,EACxBC,OAAe,EACfC,gBAAkD,EAClDC,YAA2D,KAAK;EAEhE,MAAM,CAACC,eAAe,EAAEC,sBAAsB,CAAC,GAAGC,kBAAkB,CAACH,SAAS,CAAC;EAC/E,MAAMI,IAAI,GAAGC,OAAO,EAAE;EACtB,MAAMC,IAAI,GAAGT,KAAK,CAACU,OAAO,CAACD,IAA6B;EACxD,MAAME,KAAK,GAAGX,KAAK,CAACY,QAAQ,EAAE;EAE9B,MAAMC,mBAAmB,GAAGC,cAAK,CAACC,MAAM,CAACC,sBAAsB,CAACC,WAAW,CAACjB,KAAK,CAAC,EAAEI,eAAe,CAAC,CAAC;EAErGU,cAAK,CAACI,SAAS,CAAC;IACZ,MAAMC,OAAO,GAAGC,UAAU,CAAC;MACvB,IAAI,CAACf,sBAAsB,EAAE;QACzB;;MAGJ,MAAMgB,QAAQ,GAAGL,sBAAsB,CAACC,WAAW,CAACjB,KAAK,CAAC,EAAEI,eAAe,CAAC;MAE5E,IAAIkB,MAAM,CAACC,IAAI,CAACF,QAAQ,CAAC,CAACG,MAAM,IAAIC,IAAI,CAACC,SAAS,CAACL,QAAQ,CAAC,KAAKI,IAAI,CAACC,SAAS,CAACb,mBAAmB,CAACc,OAAO,CAAC,EAAE;QAC1Gd,mBAAmB,CAACc,OAAO,GAAGN,QAAQ;;QAGtCd,IAAI,CAACc,QAAQ,CAACO,WAAW,CAACC,aAAa,CAAC5B,OAAO,CAAC,EAAEoB,QAAQ,CAAC;QAE3D,IAAInB,gBAAgB,EAAE;UAClBA,gBAAgB,CAACe,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AAO,EAAEY,MAAM,CAAC2B,MAAM,CAACvC,OAAO,CAAC,CAACwC,IAAI,CAACH,CAAC,IAAIA,CAAC,KAAK,IAAI,CAAC,CAAC;GACjE,EAAE,CAAC5C,SAAS,CAAC,CAAC;AACnB;AAEA,SAASa,sBAAsBA,CAACK,QAAuB,EAAEjB,eAA2C;EAChG,MAAM+C,iBAAiB,GAAkB;IAAE,GAAG9B;GAAU;EAExDC,MAAM,CAACC,IAAI,CAACnB,eAAe,CAAC,CAACgD,OAAO,CAACC,OAAO;IACxC,IAAI,CAACjD,eAAe,CAACiD,OAAO,CAAC,EAAE;MAC3B,OAAOF,iBAAiB,CAACE,OAAO,CAAC;;GAExC,CAAC;EAEF,OAAOF,iBAAiB;AAC5B;;;;"}
|
@@ -11781,13 +11781,15 @@ function useTableSettingsListener(table, tableId, onChangeSettings, isEnabled =
|
|
11781
11781
|
const taco = useTaco();
|
11782
11782
|
const meta = table.options.meta;
|
11783
11783
|
const state = table.getState();
|
11784
|
+
const lastUsedSettingsRef = React__default.useRef(removeDisabledSettings(getSettings(table), enabledSettings));
|
11784
11785
|
React__default.useEffect(() => {
|
11785
11786
|
const handler = setTimeout(() => {
|
11786
11787
|
if (!hasSomeEnabledSettings) {
|
11787
11788
|
return;
|
11788
11789
|
}
|
11789
11790
|
const settings = removeDisabledSettings(getSettings(table), enabledSettings);
|
11790
|
-
if (Object.keys(settings).length) {
|
11791
|
+
if (Object.keys(settings).length && JSON.stringify(settings) !== JSON.stringify(lastUsedSettingsRef.current)) {
|
11792
|
+
lastUsedSettingsRef.current = settings;
|
11791
11793
|
// some settings shouldn't be persisted, but we comment them out here to highlight the intention
|
11792
11794
|
taco.settings.saveSetting(getSettingsId(tableId), settings);
|
11793
11795
|
if (onChangeSettings) {
|
@@ -11802,7 +11804,7 @@ function useTableSettingsListener(table, tableId, onChangeSettings, isEnabled =
|
|
11802
11804
|
//state.grouping,
|
11803
11805
|
meta.printing.settings, meta.rowHeight.height,
|
11804
11806
|
//state.globalFilter,
|
11805
|
-
state.sorting]);
|
11807
|
+
state.sorting, lastUsedSettingsRef.current]);
|
11806
11808
|
}
|
11807
11809
|
const DEFAULT_ENABLED_OPTIONS = {
|
11808
11810
|
columnOrder: true,
|