@economic/taco 2.53.0-settings.6 → 2.53.0-virtualiser.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/components/Provider/Provider.d.ts +6 -7
  2. package/dist/components/Report/Report.d.ts +1 -1
  3. package/dist/esm/packages/taco/src/components/Provider/Provider.js +7 -14
  4. package/dist/esm/packages/taco/src/components/Provider/Provider.js.map +1 -1
  5. package/dist/esm/packages/taco/src/components/Report/Report.js +0 -8
  6. package/dist/esm/packages/taco/src/components/Report/Report.js.map +1 -1
  7. package/dist/esm/packages/taco/src/components/Table3/Table3.js +0 -8
  8. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  9. package/dist/esm/packages/taco/src/hooks/useLocalStorage.js +44 -0
  10. package/dist/esm/packages/taco/src/hooks/useLocalStorage.js.map +1 -0
  11. package/dist/esm/packages/taco/src/hooks/useTacoSettings.js +9 -0
  12. package/dist/esm/packages/taco/src/hooks/useTacoSettings.js.map +1 -0
  13. package/dist/esm/packages/taco/src/index.js +1 -1
  14. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/Toolbar.js +4 -6
  15. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/Toolbar.js.map +1 -1
  16. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +9 -9
  17. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
  18. package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js.map +1 -1
  19. package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
  20. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTablePrinting.js +21 -18
  21. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTablePrinting.js.map +1 -1
  22. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowActive.js +2 -2
  23. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowActive.js.map +1 -1
  24. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSettings.js +69 -0
  25. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSettings.js.map +1 -0
  26. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSettingsListener.js +9 -57
  27. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSettingsListener.js.map +1 -1
  28. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +5 -7
  29. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
  30. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/settings.js +1 -3
  31. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/settings.js.map +1 -1
  32. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +2 -5
  33. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
  34. package/dist/hooks/useLocalStorage.d.ts +2 -0
  35. package/dist/hooks/useTacoSettings.d.ts +1 -0
  36. package/dist/primitives/Table/Core/features/useTableRenderer.d.ts +2 -2
  37. package/dist/primitives/Table/Core/useTable.d.ts +4 -4
  38. package/dist/primitives/Table/types.d.ts +6 -16
  39. package/dist/primitives/Table/useTableManager/features/useTablePrinting.d.ts +8 -2
  40. package/dist/primitives/Table/useTableManager/features/useTableRowActive.d.ts +2 -2
  41. package/dist/primitives/Table/useTableManager/features/useTableSettings.d.ts +3 -0
  42. package/dist/primitives/Table/useTableManager/listeners/useTableSettingsListener.d.ts +2 -2
  43. package/dist/primitives/Table/useTableManager/util/settings.d.ts +0 -2
  44. package/dist/taco.cjs.development.js +156 -195
  45. package/dist/taco.cjs.development.js.map +1 -1
  46. package/dist/taco.cjs.production.min.js +1 -1
  47. package/dist/taco.cjs.production.min.js.map +1 -1
  48. package/package.json +2 -2
  49. package/dist/components/Provider/TacoContext.d.ts +0 -7
  50. package/dist/components/Provider/useTacoSettings.d.ts +0 -8
  51. package/dist/esm/packages/taco/src/components/Provider/TacoContext.js +0 -6
  52. package/dist/esm/packages/taco/src/components/Provider/TacoContext.js.map +0 -1
  53. package/dist/esm/packages/taco/src/components/Provider/useTacoSettings.js +0 -39
  54. package/dist/esm/packages/taco/src/components/Provider/useTacoSettings.js.map +0 -1
  55. package/dist/esm/packages/taco/src/hooks/useTaco.js +0 -9
  56. package/dist/esm/packages/taco/src/hooks/useTaco.js.map +0 -1
  57. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableSettingsPreloader.js +0 -44
  58. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableSettingsPreloader.js.map +0 -1
  59. package/dist/hooks/useTaco.d.ts +0 -1
  60. package/dist/primitives/Table/useTableManager/useTableSettingsPreloader.d.ts +0 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@economic/taco",
3
- "version": "2.53.0-settings.6",
3
+ "version": "2.53.0-virtualiser.0",
4
4
  "description": "E-conomic's Design System",
5
5
  "author": "Matt Daly <matthew.daly@visma.com>",
6
6
  "homepage": "https://github.com/e-conomic/taco#readme",
@@ -130,5 +130,5 @@
130
130
  "not ie < 11"
131
131
  ]
132
132
  },
133
- "gitHead": "1a465faeb8f9405fcab78bde0df3023d8cd3f7f5"
133
+ "gitHead": "231d13ea305edf461b4aa909a188729f57d58bc0"
134
134
  }
@@ -1,7 +0,0 @@
1
- import * as React from 'react';
2
- import { useTacoSettings } from './useTacoSettings';
3
- export declare type Taco = {
4
- settings: ReturnType<typeof useTacoSettings>;
5
- userId: string;
6
- };
7
- export declare const TacoContext: React.Context<Taco>;
@@ -1,8 +0,0 @@
1
- declare type TacoSettingsLoadHandler = <TType = unknown>(key: string) => Promise<TType>;
2
- declare type TacoSettingsSaveHandler = <TType = unknown>(key: string, setting: TType) => Promise<void>;
3
- export declare function useTacoSettings(load: TacoSettingsLoadHandler, save: TacoSettingsSaveHandler): {
4
- getSetting: <TType = unknown>(path: string) => TType;
5
- loadSetting: <TType_1 = unknown>(path: string) => Promise<TType_1>;
6
- saveSetting: <TType_2 = unknown>(path: string, value: TType_2) => Promise<void>;
7
- };
8
- export {};
@@ -1,6 +0,0 @@
1
- import { createContext } from 'react';
2
-
3
- const TacoContext = /*#__PURE__*/createContext({});
4
-
5
- export { TacoContext };
6
- //# sourceMappingURL=TacoContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TacoContext.js","sources":["../../../../../../../src/components/Provider/TacoContext.ts"],"sourcesContent":["import * as React from 'react';\nimport { useTacoSettings } from './useTacoSettings';\n\nexport type Taco = {\n settings: ReturnType<typeof useTacoSettings>;\n userId: string;\n};\n\nexport const TacoContext = React.createContext<Taco>({} as Taco);\n"],"names":["TacoContext","React"],"mappings":";;MAQaA,WAAW,gBAAGC,aAAmB,CAAO,EAAU;;;;"}
@@ -1,39 +0,0 @@
1
- import { useState } from 'react';
2
- import { setWith, get } from 'lodash-es';
3
-
4
- function useTacoSettings(load, save) {
5
- const saveSetting = function (path, value) {
6
- try {
7
- setState(currentState => setWith(currentState, path, value, Object));
8
- return Promise.resolve(save(path, value)); // don't block, since we have local state
9
- } catch (e) {
10
- return Promise.reject(e);
11
- }
12
- };
13
- const loadSetting = function (path) {
14
- try {
15
- const currentValue = get(state, path);
16
- if (currentValue) {
17
- return Promise.resolve(currentValue);
18
- }
19
- return Promise.resolve(load(path)).then(function (value) {
20
- setState(currentState => setWith(currentState, path, value, Object));
21
- return value;
22
- });
23
- } catch (e) {
24
- return Promise.reject(e);
25
- }
26
- };
27
- const [state, setState] = useState({});
28
- function getSetting(path) {
29
- return get(state, path);
30
- }
31
- return {
32
- getSetting,
33
- loadSetting,
34
- saveSetting
35
- };
36
- }
37
-
38
- export { useTacoSettings };
39
- //# sourceMappingURL=useTacoSettings.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useTacoSettings.js","sources":["../../../../../../../src/components/Provider/useTacoSettings.ts"],"sourcesContent":["import * as React from 'react';\nimport { get, setWith } from 'lodash';\n\ntype TacoSettingsLoadHandler = <TType = unknown>(key: string) => Promise<TType>;\ntype TacoSettingsSaveHandler = <TType = unknown>(key: string, setting: TType) => Promise<void>;\n\nexport function useTacoSettings(load: TacoSettingsLoadHandler, save: TacoSettingsSaveHandler) {\n const [state, setState] = React.useState({});\n\n function getSetting<TType = unknown>(path: string): TType {\n return get(state, path) as TType;\n }\n\n async function loadSetting<TType = unknown>(path: string) {\n const currentValue = get(state, path) as TType;\n\n if (currentValue) {\n return currentValue;\n }\n\n const value = await load<TType>(path);\n setState(currentState => setWith(currentState, path, value, Object));\n return value;\n }\n\n async function saveSetting<TType = unknown>(path: string, value: TType) {\n setState(currentState => setWith(currentState, path, value, Object));\n return save(path, value); // don't block, since we have local state\n }\n\n return { getSetting, loadSetting, saveSetting };\n}\n"],"names":["useTacoSettings","load","save","saveSetting","path","value","setState","currentState","setWith","Object","Promise","resolve","e","reject","loadSetting","currentValue","get","state","then","React","getSetting"],"mappings":";;;SAMgBA,eAAeA,CAACC,IAA6B,EAAEC,IAA6B;QAmBzEC,WAAW,aAAkBC,IAAY,EAAEC,KAAY;IAAA;MAClEC,QAAQ,CAACC,YAAY,IAAIC,OAAO,CAACD,YAAY,EAAEH,IAAI,EAAEC,KAAK,EAAEI,MAAM,CAAC,CAAC;MACpE,OAAAC,OAAA,CAAAC,OAAA,CAAOT,IAAI,CAACE,IAAI,EAAEC,KAAK,CAAC,EAAC;KAC5B,QAAAO,CAAA;MAAA,OAAAF,OAAA,CAAAG,MAAA,CAAAD,CAAA;;;EAAA,MAfcE,WAAW,aAAkBV,IAAY;IAAA;MACpD,MAAMW,YAAY,GAAGC,GAAG,CAACC,KAAK,EAAEb,IAAI,CAAU;MAE9C,IAAIW,YAAY,EAAE;QACd,OAAAL,OAAA,CAAAC,OAAA,CAAOI,YAAY;;MACtB,OAAAL,OAAA,CAAAC,OAAA,CAEmBV,IAAI,CAAQG,IAAI,CAAC,EAAAc,IAAA,WAA/Bb,KAAK;QACXC,QAAQ,CAACC,YAAY,IAAIC,OAAO,CAACD,YAAY,EAAEH,IAAI,EAAEC,KAAK,EAAEI,MAAM,CAAC,CAAC;QACpE,OAAOJ,KAAK;;KACf,QAAAO,CAAA;MAAA,OAAAF,OAAA,CAAAG,MAAA,CAAAD,CAAA;;;EAhBD,MAAM,CAACK,KAAK,EAAEX,QAAQ,CAAC,GAAGa,QAAc,CAAC,EAAE,CAAC;EAE5C,SAASC,UAAUA,CAAkBhB,IAAY;IAC7C,OAAOY,GAAG,CAACC,KAAK,EAAEb,IAAI,CAAU;;EAoBpC,OAAO;IAAEgB,UAAU;IAAEN,WAAW;IAAEX;GAAa;AACnD;;;;"}
@@ -1,9 +0,0 @@
1
- import React__default from 'react';
2
- import { TacoContext } from '../components/Provider/TacoContext.js';
3
-
4
- function useTaco() {
5
- return React__default.useContext(TacoContext);
6
- }
7
-
8
- export { useTaco };
9
- //# sourceMappingURL=useTaco.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useTaco.js","sources":["../../../../../../src/hooks/useTaco.ts"],"sourcesContent":["import React from 'react';\nimport { TacoContext } from '../components/Provider/TacoContext';\n\nexport function useTaco() {\n return React.useContext(TacoContext);\n}\n"],"names":["useTaco","React","useContext","TacoContext"],"mappings":";;;SAGgBA,OAAOA;EACnB,OAAOC,cAAK,CAACC,UAAU,CAACC,WAAW,CAAC;AACxC;;;;"}
@@ -1,44 +0,0 @@
1
- import React__default from 'react';
2
- import { getSettingsId } from './util/settings.js';
3
- import { useTaco } from '../../../hooks/useTaco.js';
4
-
5
- function getLegacySetting(currentKey) {
6
- try {
7
- const localStorageValue = localStorage.getItem(currentKey);
8
- if (localStorageValue) {
9
- const value = JSON.parse(localStorageValue || 'null');
10
- if (value !== null) {
11
- localStorage.removeItem(currentKey);
12
- return value;
13
- }
14
- }
15
- } catch {
16
- // If user is in private mode or has storage restriction
17
- // localStorage can throw. JSON.parse can throw, too.
18
- }
19
- return undefined;
20
- }
21
- function useTableSettingsPreloader(tableId) {
22
- const taco = useTaco();
23
- const [loading, setLoading] = React__default.useState(true);
24
- React__default.useLayoutEffect(() => {
25
- const key = getSettingsId(tableId);
26
- // migrate legacy settings if they exist, can be removed in the future
27
- const legacySettings = getLegacySetting(`taco.${taco.userId}.table.${tableId}.settings`);
28
- if (legacySettings) {
29
- const legacyPrintSettings = getLegacySetting(`taco.${taco.userId}.table.${tableId}.print.settings`);
30
- taco.settings.saveSetting(key, {
31
- ...legacySettings,
32
- print: legacyPrintSettings !== null && legacyPrintSettings !== void 0 ? legacyPrintSettings : {}
33
- }).finally(() => setLoading(false));
34
- } else {
35
- taco.settings.loadSetting(key).finally(() => setLoading(false));
36
- }
37
- }, []);
38
- return {
39
- loading
40
- };
41
- }
42
-
43
- export { useTableSettingsPreloader };
44
- //# sourceMappingURL=useTableSettingsPreloader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useTableSettingsPreloader.js","sources":["../../../../../../../../src/primitives/Table/useTableManager/useTableSettingsPreloader.ts"],"sourcesContent":["import React from 'react';\nimport { useTaco } from '../../../hooks/useTaco';\nimport { TablePrintSettings, TableSettings } from '../types';\nimport { getSettingsId } from './util/settings';\n\nfunction getLegacySetting<TType = unknown>(currentKey: string): TType | undefined {\n try {\n const localStorageValue = localStorage.getItem(currentKey);\n\n if (localStorageValue) {\n const value = JSON.parse(localStorageValue || 'null');\n\n if (value !== null) {\n localStorage.removeItem(currentKey);\n return value;\n }\n }\n } catch {\n // If user is in private mode or has storage restriction\n // localStorage can throw. JSON.parse can throw, too.\n }\n\n return undefined;\n}\n\nexport function useTableSettingsPreloader(tableId: string) {\n const taco = useTaco();\n const [loading, setLoading] = React.useState(true);\n\n React.useLayoutEffect(() => {\n const key = getSettingsId(tableId);\n\n // migrate legacy settings if they exist, can be removed in the future\n const legacySettings = getLegacySetting<TableSettings>(`taco.${taco.userId}.table.${tableId}.settings`);\n\n if (legacySettings) {\n const legacyPrintSettings = getLegacySetting<TablePrintSettings>(\n `taco.${taco.userId}.table.${tableId}.print.settings`\n );\n\n taco.settings\n .saveSetting(key, {\n ...legacySettings,\n print: legacyPrintSettings ?? {},\n })\n .finally(() => setLoading(false));\n } else {\n taco.settings.loadSetting<TableSettings>(key).finally(() => setLoading(false));\n }\n }, []);\n\n return { loading };\n}\n"],"names":["getLegacySetting","currentKey","localStorageValue","localStorage","getItem","value","JSON","parse","removeItem","undefined","useTableSettingsPreloader","tableId","taco","useTaco","loading","setLoading","React","useState","useLayoutEffect","key","getSettingsId","legacySettings","userId","legacyPrintSettings","settings","saveSetting","print","finally","loadSetting"],"mappings":";;;;AAKA,SAASA,gBAAgBA,CAAkBC,UAAkB;EACzD,IAAI;IACA,MAAMC,iBAAiB,GAAGC,YAAY,CAACC,OAAO,CAACH,UAAU,CAAC;IAE1D,IAAIC,iBAAiB,EAAE;MACnB,MAAMG,KAAK,GAAGC,IAAI,CAACC,KAAK,CAACL,iBAAiB,IAAI,MAAM,CAAC;MAErD,IAAIG,KAAK,KAAK,IAAI,EAAE;QAChBF,YAAY,CAACK,UAAU,CAACP,UAAU,CAAC;QACnC,OAAOI,KAAK;;;GAGvB,CAAC,MAAM;;;;EAKR,OAAOI,SAAS;AACpB;SAEgBC,yBAAyBA,CAACC,OAAe;EACrD,MAAMC,IAAI,GAAGC,OAAO,EAAE;EACtB,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,IAAI,CAAC;EAElDD,cAAK,CAACE,eAAe,CAAC;IAClB,MAAMC,GAAG,GAAGC,aAAa,CAACT,OAAO,CAAC;;IAGlC,MAAMU,cAAc,GAAGrB,gBAAgB,CAAgB,QAAQY,IAAI,CAACU,MAAM,UAAUX,OAAO,WAAW,CAAC;IAEvG,IAAIU,cAAc,EAAE;MAChB,MAAME,mBAAmB,GAAGvB,gBAAgB,CACxC,QAAQY,IAAI,CAACU,MAAM,UAAUX,OAAO,iBAAiB,CACxD;MAEDC,IAAI,CAACY,QAAQ,CACRC,WAAW,CAACN,GAAG,EAAE;QACd,GAAGE,cAAc;QACjBK,KAAK,EAAEH,mBAAmB,aAAnBA,mBAAmB,cAAnBA,mBAAmB,GAAI;OACjC,CAAC,CACDI,OAAO,CAAC,MAAMZ,UAAU,CAAC,KAAK,CAAC,CAAC;KACxC,MAAM;MACHH,IAAI,CAACY,QAAQ,CAACI,WAAW,CAAgBT,GAAG,CAAC,CAACQ,OAAO,CAAC,MAAMZ,UAAU,CAAC,KAAK,CAAC,CAAC;;GAErF,EAAE,EAAE,CAAC;EAEN,OAAO;IAAED;GAAS;AACtB;;;;"}
@@ -1 +0,0 @@
1
- export declare function useTaco(): import("../components/Provider/TacoContext").Taco;
@@ -1,3 +0,0 @@
1
- export declare function useTableSettingsPreloader(tableId: string): {
2
- loading: boolean;
3
- };