@flipdish/ui-library 0.19.0 → 0.20.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 (57) hide show
  1. package/README.md +6 -7
  2. package/dist/components/atoms/Badge/index.cjs +0 -1
  3. package/dist/components/atoms/Badge/index.cjs.map +1 -1
  4. package/dist/components/atoms/Badge/index.d.ts +0 -5
  5. package/dist/components/atoms/Badge/index.d.ts.map +1 -1
  6. package/dist/components/atoms/Badge/index.js +1 -1
  7. package/dist/components/atoms/Badge/index.js.map +1 -1
  8. package/dist/components/molecules/Carousel/index.cjs +0 -1
  9. package/dist/components/molecules/Carousel/index.cjs.map +1 -1
  10. package/dist/components/molecules/Carousel/index.d.ts +0 -1
  11. package/dist/components/molecules/Carousel/index.d.ts.map +1 -1
  12. package/dist/components/molecules/Carousel/index.js +1 -1
  13. package/dist/components/molecules/Carousel/index.js.map +1 -1
  14. package/dist/components/organisms/Charts/index.d.ts +22 -6
  15. package/dist/components/organisms/Charts/index.d.ts.map +1 -1
  16. package/dist/components/organisms/FileUpload/index.cjs +1 -4
  17. package/dist/components/organisms/FileUpload/index.cjs.map +1 -1
  18. package/dist/components/organisms/FileUpload/index.d.ts +1 -9
  19. package/dist/components/organisms/FileUpload/index.d.ts.map +1 -1
  20. package/dist/components/organisms/FileUpload/index.js +3 -3
  21. package/dist/components/organisms/FileUpload/index.js.map +1 -1
  22. package/dist/components/organisms/GradientPicker/index.cjs +0 -6
  23. package/dist/components/organisms/GradientPicker/index.cjs.map +1 -1
  24. package/dist/components/organisms/GradientPicker/index.d.ts +0 -28
  25. package/dist/components/organisms/GradientPicker/index.d.ts.map +1 -1
  26. package/dist/components/organisms/GradientPicker/index.js +1 -1
  27. package/dist/components/organisms/GradientPicker/index.js.map +1 -1
  28. package/dist/components/organisms/ImagePicker/index.cjs +0 -3
  29. package/dist/components/organisms/ImagePicker/index.cjs.map +1 -1
  30. package/dist/components/organisms/ImagePicker/index.d.ts +0 -6
  31. package/dist/components/organisms/ImagePicker/index.d.ts.map +1 -1
  32. package/dist/components/organisms/ImagePicker/index.js +1 -1
  33. package/dist/components/organisms/ImagePicker/index.js.map +1 -1
  34. package/dist/native/utilities/cx/index.d.ts +2 -2
  35. package/dist/native/utilities/cx/index.js +2 -2
  36. package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.cjs +102 -0
  37. package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.cjs.map +1 -0
  38. package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.d.ts +41 -0
  39. package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.d.ts.map +1 -0
  40. package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.js +98 -0
  41. package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.js.map +1 -0
  42. package/dist/utilities/cx/index.cjs +2 -2
  43. package/dist/utilities/cx/index.d.ts +2 -2
  44. package/dist/utilities/cx/index.js +2 -2
  45. package/dist/utilities/localStorageUtils/index.cjs +9 -102
  46. package/dist/utilities/localStorageUtils/index.cjs.map +1 -1
  47. package/dist/utilities/localStorageUtils/index.d.ts +5 -5
  48. package/dist/utilities/localStorageUtils/index.d.ts.map +1 -1
  49. package/dist/utilities/localStorageUtils/index.js +7 -100
  50. package/dist/utilities/localStorageUtils/index.js.map +1 -1
  51. package/dist/utilities/sessionStorageUtils/index.cjs +9 -103
  52. package/dist/utilities/sessionStorageUtils/index.cjs.map +1 -1
  53. package/dist/utilities/sessionStorageUtils/index.d.ts +5 -6
  54. package/dist/utilities/sessionStorageUtils/index.d.ts.map +1 -1
  55. package/dist/utilities/sessionStorageUtils/index.js +7 -101
  56. package/dist/utilities/sessionStorageUtils/index.js.map +1 -1
  57. package/package.json +3 -7
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webStorage.utils.js","sources":["../../../../src/utilities/__internal__/webStorageUtils/webStorage.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;AAUG;AAKH,MAAM,O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AG,IAAI,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,CAAC,KAA2B,EAAE,QAAQ,EAAE,GAAG,OAAO;IAExG,OAAO;QACL,GAAG,GAAA;YACD,MAAM,GAAG,GAAG,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;YACpC,IAAI,GAAG,IAAI,IAAI;AAAE,gBAAA,OAAO,IAAI;AAC5B,YAAA,IAAI;AACF,gBAAA,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC;AAC9B,gBAAA,IAAI,QAAQ,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;AAAE,oBAAA,OAAO,IAAI;AAC7C,gBAAA,OAAO,KAAK;YACd;AAAE,YAAA,MAAM;AACN,gBAAA,OAAO,IAAI;YACb;QACF,CAAC;AACD,QAAA,GAAG,CAAC,KAAK,EAAA;AACP,YAAA,IAAI;AACF,gBAAA,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC;;;;gBAInC,IAAI,OAAO,UAAU,KAAK,QAAQ;oBAAE;AACpC,gBAAA,OAAO,CAAC,UAAU,EAAE,GAAG,EAAE,UAAU,CAAC;YACtC;AAAE,YAAA,MAAM;;;YAGR;QACF,CAAC;QACD,KAAK,GAAA;AACH,YAAA,UAAU,CAAC,UAAU,EAAE,GAAG,CAAC;QAC7B,CAAC;KACF;AACH;;;;"}
@@ -31,8 +31,8 @@ const twMerge = tailwindMerge.extendTailwindMerge({
31
31
  const cx = twMerge;
32
32
  /**
33
33
  * Identity helper that exists only so Tailwind IntelliSense recognises and sorts
34
- * the class strings held inside style-config objects (e.g. `tailwind-variants`
35
- * slot maps). Returns its argument unchanged.
34
+ * the class strings held inside style-config objects (the `*.styles.ts` sortCx
35
+ * maps components use). Returns its argument unchanged.
36
36
  */
37
37
  const sortCx = (classes) => classes;
38
38
 
@@ -14,8 +14,8 @@ type ClassValue = string | number;
14
14
  type ClassDefinition = Record<string, ClassValue | Record<string, ClassValue | Record<string, ClassValue>>>;
15
15
  /**
16
16
  * Identity helper that exists only so Tailwind IntelliSense recognises and sorts
17
- * the class strings held inside style-config objects (e.g. `tailwind-variants`
18
- * slot maps). Returns its argument unchanged.
17
+ * the class strings held inside style-config objects (the `*.styles.ts` sortCx
18
+ * maps components use). Returns its argument unchanged.
19
19
  */
20
20
  export declare const sortCx: <T extends ClassDefinition>(classes: T) => T;
21
21
  export {};
@@ -29,8 +29,8 @@ const twMerge = extendTailwindMerge({
29
29
  const cx = twMerge;
30
30
  /**
31
31
  * Identity helper that exists only so Tailwind IntelliSense recognises and sorts
32
- * the class strings held inside style-config objects (e.g. `tailwind-variants`
33
- * slot maps). Returns its argument unchanged.
32
+ * the class strings held inside style-config objects (the `*.styles.ts` sortCx
33
+ * maps components use). Returns its argument unchanged.
34
34
  */
35
35
  const sortCx = (classes) => classes;
36
36
 
@@ -1,75 +1,18 @@
1
1
  'use strict';
2
2
 
3
+ var webStorage_utils = require('../__internal__/webStorageUtils/webStorage.utils.cjs');
3
4
  var localStorageUtils_constants = require('./localStorageUtils.constants.cjs');
4
5
 
5
6
  /**
6
- * Web-only, typed `localStorage` persistence. DOM access (`window.localStorage`)
7
- * lives here rather than in components, so component code stays free of `window.*`
8
- * and keeps React Native parity see `useBreakpoint` for the same isolation
9
- * pattern. Every helper no-ops / returns `null` when `localStorage` is
10
- * unavailable (SSR, React Native, private mode, quota errors).
7
+ * Web-only, typed `localStorage` persistence. Thin wrapper over the shared
8
+ * `#internal/utilities/webStorageUtils` factory (which `sessionStorageUtils`
9
+ * also uses the two modules were byte-identical twins before the factory).
10
+ * Every helper no-ops / returns `null` when `localStorage` is unavailable
11
+ * (SSR, React Native, private mode, quota errors).
11
12
  *
12
13
  * Every key this package persists is registered in `localStorageUtils.constants.ts`
13
14
  * — check there for the full list before adding a new one.
14
15
  */
15
- const isBrowser = typeof window !== 'undefined';
16
- /**
17
- * Internal `localStorage` primitives backing `createLocalStorageItem`. Not
18
- * exported — everything a consumer needs goes through `createLocalStorageItem`,
19
- * which adds typed serialization/validation on top. Add a raw string export
20
- * here only once a real caller needs plain-string storage without JSON typing.
21
- */
22
- /** Read a raw string value, or `null` when unset/unavailable. */
23
- const safeLocalGet = (key) => {
24
- if (!isBrowser)
25
- return null;
26
- try {
27
- return window.localStorage.getItem(key);
28
- }
29
- catch {
30
- return null;
31
- }
32
- };
33
- /** Persist a raw string value; returns whether the write succeeded. */
34
- const safeLocalSet = (key, value) => {
35
- if (!isBrowser)
36
- return false;
37
- try {
38
- window.localStorage.setItem(key, value);
39
- return true;
40
- }
41
- catch {
42
- return false;
43
- }
44
- };
45
- /** Remove a value; returns whether the removal succeeded. */
46
- const safeLocalRemove = (key) => {
47
- if (!isBrowser)
48
- return false;
49
- try {
50
- window.localStorage.removeItem(key);
51
- return true;
52
- }
53
- catch {
54
- return false;
55
- }
56
- };
57
- /**
58
- * Reusable `validate` guard for a `createLocalStorageItem<boolean>` item.
59
- */
60
- const isBoolean = (value) => typeof value === 'boolean';
61
- /**
62
- * Parse a plain `'true'`/`'false'` string (not JSON) into a boolean; throws
63
- * `errorMessage` for anything else so `createLocalStorageItem.get()` treats it
64
- * as invalid data and returns `null`.
65
- */
66
- const parseBooleanString = (raw, errorMessage) => {
67
- if (raw === 'true')
68
- return true;
69
- if (raw === 'false')
70
- return false;
71
- throw new Error(errorMessage);
72
- };
73
16
  /**
74
17
  * Build a typed, failure-safe accessor for a single `localStorage` key.
75
18
  *
@@ -78,51 +21,15 @@ const parseBooleanString = (raw, errorMessage) => {
78
21
  * draft.set({ title: 'Hi' });
79
22
  * const value = draft.get(); // Draft | null
80
23
  */
81
- const createLocalStorageItem = (key, options = {}) => {
82
- const { serialize = JSON.stringify, deserialize = JSON.parse, validate } = options;
83
- return {
84
- get() {
85
- const raw = safeLocalGet(key);
86
- if (raw == null)
87
- return null;
88
- try {
89
- const value = deserialize(raw);
90
- if (validate && !validate(value))
91
- return null;
92
- return value;
93
- }
94
- catch {
95
- return null;
96
- }
97
- },
98
- set(value) {
99
- try {
100
- const serialized = serialize(value);
101
- // JSON.stringify (and a custom serializer) can return `undefined` for a
102
- // top-level `undefined`, function, or symbol — treat that as a failed
103
- // serialization rather than writing the literal string "undefined".
104
- if (typeof serialized !== 'string')
105
- return;
106
- safeLocalSet(key, serialized);
107
- }
108
- catch {
109
- // serialize() can throw (e.g. circular refs); matches the documented
110
- // failure-safe contract — silently ignore, same as a write failure.
111
- }
112
- },
113
- clear() {
114
- safeLocalRemove(key);
115
- },
116
- };
117
- };
24
+ const createLocalStorageItem = (key, options = {}) => webStorage_utils.createWebStorageItem(() => window.localStorage, key, options);
118
25
  /**
119
26
  * Persistence for the `SidebarNavigation` collapsed preference. Stored as the
120
27
  * plain strings `'true'` / `'false'` to preserve the original on-disk format.
121
28
  */
122
29
  const sidebarCollapsedStorage = createLocalStorageItem(localStorageUtils_constants.LOCAL_STORAGE_KEYS.sidebarCollapsed, {
123
30
  serialize: String,
124
- deserialize: (raw) => parseBooleanString(raw, 'Invalid sidebar collapsed value'),
125
- validate: isBoolean,
31
+ deserialize: (raw) => webStorage_utils.parseBooleanString(raw, 'Invalid sidebar collapsed value'),
32
+ validate: webStorage_utils.isBoolean,
126
33
  });
127
34
 
128
35
  exports.LOCAL_STORAGE_KEYS = localStorageUtils_constants.LOCAL_STORAGE_KEYS;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/utilities/localStorageUtils/index.ts"],"sourcesContent":[null],"names":["LOCAL_STORAGE_KEYS"],"mappings":";;;;AAAA;;;;;;;;;AASG;AAMH,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW;AAE/C;;;;;AAKG;AAEH;AACA,MAAM,YAAY,GAAG,CAAC,GAAW,KAAmB;AAClD,IAAA,IAAI,CAAC,SAAS;AAAE,QAAA,OAAO,IAAI;AAC3B,IAAA,IAAI;QACF,OAAO,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC;IACzC;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,IAAI;IACb;A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C5B,YAAA,IAAI;AACF,gBAAA,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC;AAC9B,gBAAA,IAAI,QAAQ,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;AAAE,oBAAA,OAAO,IAAI;AAC7C,gBAAA,OAAO,KAAK;YACd;AAAE,YAAA,MAAM;AACN,gBAAA,OAAO,IAAI;YACb;QACF,CAAC;AACD,QAAA,GAAG,CAAC,KAAK,EAAA;AACP,YAAA,IAAI;AACF,gBAAA,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC;;;;gBAInC,IAAI,OAAO,UAAU,KAAK,QAAQ;oBAAE;AACpC,gBAAA,YAAY,CAAC,GAAG,EAAE,UAAU,CAAC;YAC/B;AAAE,YAAA,MAAM;;;YAGR;QACF,CAAC;QACD,KAAK,GAAA;YACH,eAAe,CAAC,GAAG,CAAC;QACtB,CAAC;KACF;AACH;AAEA;;;AAGG;MACU,uBAAuB,GAAG,sBAAsB,CAAUA,8CAAkB,CAAC,gBAAgB,EAAE;AAC1G,IAAA,SAAS,EAAE,MAAM;IACjB,WAAW,EAAE,CAAC,GAAG,KAAK,kBAAkB,CAAC,GAAG,EAAE,iCAAiC,CAAC;AAChF,IAAA,QAAQ,EAAE,SAAS;AACpB,CAAA;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../src/utilities/localStorageUtils/index.ts"],"sourcesContent":[null],"names":["createWebStorageItem","LOCAL_STORAGE_KEYS","parseBooleanString","isBoolean"],"mappings":";;;;;AAAA;;;;;;;;;AASG;AA2BH;;;;;;;AAOG;AACI,MAAM,sBAAsB,GAAG,CAAI,GAAW,EAAE,OAAA,GAAsC,EAAE,KAC7FA,qCAAoB,CAAC,MAAM,MAAM,CAAC,YAAY,EAAE,GAAG,EAAE,OAAO;AAE9D;;;AAGG;MACU,uBAAuB,GAAG,sBAAsB,CAAUC,8CAAkB,CAAC,gBAAgB,EAAE;AAC1G,IAAA,SAAS,EAAE,MAAM;IACjB,WAAW,EAAE,CAAC,GAAG,KAAKC,mCAAkB,CAAC,GAAG,EAAE,iCAAiC,CAAC;AAChF,IAAA,QAAQ,EAAEC,0BAAS;AACpB,CAAA;;;;;;"}
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Web-only, typed `localStorage` persistence. DOM access (`window.localStorage`)
3
- * lives here rather than in components, so component code stays free of `window.*`
4
- * and keeps React Native parity see `useBreakpoint` for the same isolation
5
- * pattern. Every helper no-ops / returns `null` when `localStorage` is
6
- * unavailable (SSR, React Native, private mode, quota errors).
2
+ * Web-only, typed `localStorage` persistence. Thin wrapper over the shared
3
+ * `#internal/utilities/webStorageUtils` factory (which `sessionStorageUtils`
4
+ * also uses the two modules were byte-identical twins before the factory).
5
+ * Every helper no-ops / returns `null` when `localStorage` is unavailable
6
+ * (SSR, React Native, private mode, quota errors).
7
7
  *
8
8
  * Every key this package persists is registered in `localStorageUtils.constants.ts`
9
9
  * — check there for the full list before adding a new one.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/localStorageUtils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,CAAC;AA2C9B,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,gFAAgF;IAChF,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAChB,wEAAwE;IACxE,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACpB,mDAAmD;IACnD,KAAK,IAAI,IAAI,CAAC;CACf;AAED,MAAM,WAAW,uBAAuB,CAAC,CAAC;IACxC,8DAA8D;IAC9D,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;IACjC,2DAA2D;IAC3D,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,CAAC,CAAC;IACjC,oEAA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1,16 @@
1
+ import { createWebStorageItem, isBoolean, parseBooleanString } from '../__internal__/webStorageUtils/webStorage.utils.js';
1
2
  import { LOCAL_STORAGE_KEYS } from './localStorageUtils.constants.js';
2
3
 
3
4
  /**
4
- * Web-only, typed `localStorage` persistence. DOM access (`window.localStorage`)
5
- * lives here rather than in components, so component code stays free of `window.*`
6
- * and keeps React Native parity see `useBreakpoint` for the same isolation
7
- * pattern. Every helper no-ops / returns `null` when `localStorage` is
8
- * unavailable (SSR, React Native, private mode, quota errors).
5
+ * Web-only, typed `localStorage` persistence. Thin wrapper over the shared
6
+ * `#internal/utilities/webStorageUtils` factory (which `sessionStorageUtils`
7
+ * also uses the two modules were byte-identical twins before the factory).
8
+ * Every helper no-ops / returns `null` when `localStorage` is unavailable
9
+ * (SSR, React Native, private mode, quota errors).
9
10
  *
10
11
  * Every key this package persists is registered in `localStorageUtils.constants.ts`
11
12
  * — check there for the full list before adding a new one.
12
13
  */
13
- const isBrowser = typeof window !== 'undefined';
14
- /**
15
- * Internal `localStorage` primitives backing `createLocalStorageItem`. Not
16
- * exported — everything a consumer needs goes through `createLocalStorageItem`,
17
- * which adds typed serialization/validation on top. Add a raw string export
18
- * here only once a real caller needs plain-string storage without JSON typing.
19
- */
20
- /** Read a raw string value, or `null` when unset/unavailable. */
21
- const safeLocalGet = (key) => {
22
- if (!isBrowser)
23
- return null;
24
- try {
25
- return window.localStorage.getItem(key);
26
- }
27
- catch {
28
- return null;
29
- }
30
- };
31
- /** Persist a raw string value; returns whether the write succeeded. */
32
- const safeLocalSet = (key, value) => {
33
- if (!isBrowser)
34
- return false;
35
- try {
36
- window.localStorage.setItem(key, value);
37
- return true;
38
- }
39
- catch {
40
- return false;
41
- }
42
- };
43
- /** Remove a value; returns whether the removal succeeded. */
44
- const safeLocalRemove = (key) => {
45
- if (!isBrowser)
46
- return false;
47
- try {
48
- window.localStorage.removeItem(key);
49
- return true;
50
- }
51
- catch {
52
- return false;
53
- }
54
- };
55
- /**
56
- * Reusable `validate` guard for a `createLocalStorageItem<boolean>` item.
57
- */
58
- const isBoolean = (value) => typeof value === 'boolean';
59
- /**
60
- * Parse a plain `'true'`/`'false'` string (not JSON) into a boolean; throws
61
- * `errorMessage` for anything else so `createLocalStorageItem.get()` treats it
62
- * as invalid data and returns `null`.
63
- */
64
- const parseBooleanString = (raw, errorMessage) => {
65
- if (raw === 'true')
66
- return true;
67
- if (raw === 'false')
68
- return false;
69
- throw new Error(errorMessage);
70
- };
71
14
  /**
72
15
  * Build a typed, failure-safe accessor for a single `localStorage` key.
73
16
  *
@@ -76,43 +19,7 @@ const parseBooleanString = (raw, errorMessage) => {
76
19
  * draft.set({ title: 'Hi' });
77
20
  * const value = draft.get(); // Draft | null
78
21
  */
79
- const createLocalStorageItem = (key, options = {}) => {
80
- const { serialize = JSON.stringify, deserialize = JSON.parse, validate } = options;
81
- return {
82
- get() {
83
- const raw = safeLocalGet(key);
84
- if (raw == null)
85
- return null;
86
- try {
87
- const value = deserialize(raw);
88
- if (validate && !validate(value))
89
- return null;
90
- return value;
91
- }
92
- catch {
93
- return null;
94
- }
95
- },
96
- set(value) {
97
- try {
98
- const serialized = serialize(value);
99
- // JSON.stringify (and a custom serializer) can return `undefined` for a
100
- // top-level `undefined`, function, or symbol — treat that as a failed
101
- // serialization rather than writing the literal string "undefined".
102
- if (typeof serialized !== 'string')
103
- return;
104
- safeLocalSet(key, serialized);
105
- }
106
- catch {
107
- // serialize() can throw (e.g. circular refs); matches the documented
108
- // failure-safe contract — silently ignore, same as a write failure.
109
- }
110
- },
111
- clear() {
112
- safeLocalRemove(key);
113
- },
114
- };
115
- };
22
+ const createLocalStorageItem = (key, options = {}) => createWebStorageItem(() => window.localStorage, key, options);
116
23
  /**
117
24
  * Persistence for the `SidebarNavigation` collapsed preference. Stored as the
118
25
  * plain strings `'true'` / `'false'` to preserve the original on-disk format.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/utilities/localStorageUtils/index.ts"],"sourcesContent":[null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;;;;AASG;AA2BH;;;;;;;AAOG;AACI,MAAM,sBAAsB,GAAG,CAAI,GAAW,EAAE,OAAA,GAAsC,EAAE,KAC7F,oBAAoB,CAAC,MAAM,MAAM,CAAC,YAAY,EAAE,GAAG,EAAE,OAAO;AAE9D;;;AAGG;MACU,uBAAuB,GAAG,sBAAsB,CAAU,kBAAkB,CAAC,gBAAgB,EAAE;AAC1G,IAAA,SAAS,EAAE,MAAM;IACjB,WAAW,EAAE,CAAC,GAAG,KAAK,kBAAkB,CAAC,GAAG,EAAE,iCAAiC,CAAC;AAChF,IAAA,QAAQ,EAAE,SAAS;AACpB,CAAA;;;;"}
@@ -1,76 +1,18 @@
1
1
  'use strict';
2
2
 
3
+ var webStorage_utils = require('../__internal__/webStorageUtils/webStorage.utils.cjs');
3
4
  var sessionStorageUtils_constants = require('./sessionStorageUtils.constants.cjs');
4
5
 
5
6
  /**
6
- * Web-only, typed `sessionStorage` persistence. DOM access (`window.sessionStorage`)
7
- * lives here rather than in components, so component code stays free of `window.*`
8
- * and keeps React Native parity this is the `sessionStorage` counterpart of
9
- * `localStorageUtils` (same isolation pattern). Every helper no-ops / returns
10
- * `null` when `sessionStorage` is unavailable (SSR, React Native, private mode,
11
- * quota errors).
7
+ * Web-only, typed `sessionStorage` persistence. Thin wrapper over the shared
8
+ * `#internal/utilities/webStorageUtils` factory (which `localStorageUtils`
9
+ * also uses the two modules were byte-identical twins before the factory).
10
+ * Every helper no-ops / returns `null` when `sessionStorage` is unavailable
11
+ * (SSR, React Native, private mode, quota errors).
12
12
  *
13
13
  * Every key this package persists is registered in `sessionStorageUtils.constants.ts`
14
14
  * — check there for the full list before adding a new one.
15
15
  */
16
- const isBrowser = typeof window !== 'undefined';
17
- /**
18
- * Internal `sessionStorage` primitives backing `createSessionStorageItem`. Not
19
- * exported — everything a consumer needs goes through `createSessionStorageItem`,
20
- * which adds typed serialization/validation on top. Add a raw string export
21
- * here only once a real caller needs plain-string storage without JSON typing.
22
- */
23
- /** Read a raw string value, or `null` when unset/unavailable. */
24
- const safeSessionGet = (key) => {
25
- if (!isBrowser)
26
- return null;
27
- try {
28
- return window.sessionStorage.getItem(key);
29
- }
30
- catch {
31
- return null;
32
- }
33
- };
34
- /** Persist a raw string value; returns whether the write succeeded. */
35
- const safeSessionSet = (key, value) => {
36
- if (!isBrowser)
37
- return false;
38
- try {
39
- window.sessionStorage.setItem(key, value);
40
- return true;
41
- }
42
- catch {
43
- return false;
44
- }
45
- };
46
- /** Remove a value; returns whether the removal succeeded. */
47
- const safeSessionRemove = (key) => {
48
- if (!isBrowser)
49
- return false;
50
- try {
51
- window.sessionStorage.removeItem(key);
52
- return true;
53
- }
54
- catch {
55
- return false;
56
- }
57
- };
58
- /**
59
- * Reusable `validate` guard for a `createSessionStorageItem<boolean>` item.
60
- */
61
- const isBoolean = (value) => typeof value === 'boolean';
62
- /**
63
- * Parse a plain `'true'`/`'false'` string (not JSON) into a boolean; throws
64
- * `errorMessage` for anything else so `createSessionStorageItem.get()` treats it
65
- * as invalid data and returns `null`.
66
- */
67
- const parseBooleanString = (raw, errorMessage) => {
68
- if (raw === 'true')
69
- return true;
70
- if (raw === 'false')
71
- return false;
72
- throw new Error(errorMessage);
73
- };
74
16
  /**
75
17
  * Build a typed, failure-safe accessor for a single `sessionStorage` key.
76
18
  *
@@ -79,51 +21,15 @@ const parseBooleanString = (raw, errorMessage) => {
79
21
  * draft.set({ title: 'Hi' });
80
22
  * const value = draft.get(); // Draft | null
81
23
  */
82
- const createSessionStorageItem = (key, options = {}) => {
83
- const { serialize = JSON.stringify, deserialize = JSON.parse, validate } = options;
84
- return {
85
- get() {
86
- const raw = safeSessionGet(key);
87
- if (raw == null)
88
- return null;
89
- try {
90
- const value = deserialize(raw);
91
- if (validate && !validate(value))
92
- return null;
93
- return value;
94
- }
95
- catch {
96
- return null;
97
- }
98
- },
99
- set(value) {
100
- try {
101
- const serialized = serialize(value);
102
- // JSON.stringify (and a custom serializer) can return `undefined` for a
103
- // top-level `undefined`, function, or symbol — treat that as a failed
104
- // serialization rather than writing the literal string "undefined".
105
- if (typeof serialized !== 'string')
106
- return;
107
- safeSessionSet(key, serialized);
108
- }
109
- catch {
110
- // serialize() can throw (e.g. circular refs); matches the documented
111
- // failure-safe contract — silently ignore, same as a write failure.
112
- }
113
- },
114
- clear() {
115
- safeSessionRemove(key);
116
- },
117
- };
118
- };
24
+ const createSessionStorageItem = (key, options = {}) => webStorage_utils.createWebStorageItem(() => window.sessionStorage, key, options);
119
25
  /**
120
26
  * Persistence for `lazyWithRetry`'s force-refresh-once marker. Stored as the
121
27
  * plain strings `'true'` / `'false'` to preserve the original portal-library format.
122
28
  */
123
29
  const pageForceRefreshedStorage = createSessionStorageItem(sessionStorageUtils_constants.SESSION_STORAGE_KEYS.pageHasBeenForceRefreshed, {
124
30
  serialize: String,
125
- deserialize: (raw) => parseBooleanString(raw, 'Invalid page-force-refreshed value'),
126
- validate: isBoolean,
31
+ deserialize: (raw) => webStorage_utils.parseBooleanString(raw, 'Invalid page-force-refreshed value'),
32
+ validate: webStorage_utils.isBoolean,
127
33
  });
128
34
 
129
35
  exports.SESSION_STORAGE_KEYS = sessionStorageUtils_constants.SESSION_STORAGE_KEYS;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/utilities/sessionStorageUtils/index.ts"],"sourcesContent":[null],"names":["SESSION_STORAGE_KEYS"],"mappings":";;;;AAAA;;;;;;;;;;AAUG;AAMH,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW;AAE/C;;;;;AAKG;AAEH;AACA,MAAM,cAAc,GAAG,CAAC,GAAW,KAAmB;AACpD,IAAA,IAAI,CAAC,SAAS;AAAE,QAAA,OAAO,IAAI;AAC3B,IAAA,IAAI;QACF,OAAO,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC;IAC3C;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,IAAI;IACb;AACF,CAAC;AAED;AACA,MAAM,cAAc,GAAG,CAA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K,GAAG,WAAW,CAAC,GAAG,CAAC;AAC9B,gBAAA,IAAI,QAAQ,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;AAAE,oBAAA,OAAO,IAAI;AAC7C,gBAAA,OAAO,KAAK;YACd;AAAE,YAAA,MAAM;AACN,gBAAA,OAAO,IAAI;YACb;QACF,CAAC;AACD,QAAA,GAAG,CAAC,KAAK,EAAA;AACP,YAAA,IAAI;AACF,gBAAA,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC;;;;gBAInC,IAAI,OAAO,UAAU,KAAK,QAAQ;oBAAE;AACpC,gBAAA,cAAc,CAAC,GAAG,EAAE,UAAU,CAAC;YACjC;AAAE,YAAA,MAAM;;;YAGR;QACF,CAAC;QACD,KAAK,GAAA;YACH,iBAAiB,CAAC,GAAG,CAAC;QACxB,CAAC;KACF;AACH;AAEA;;;AAGG;MACU,yBAAyB,GAAG,wBAAwB,CAAUA,kDAAoB,CAAC,yBAAyB,EAAE;AACzH,IAAA,SAAS,EAAE,MAAM;IACjB,WAAW,EAAE,CAAC,GAAG,KAAK,kBAAkB,CAAC,GAAG,EAAE,oCAAoC,CAAC;AACnF,IAAA,QAAQ,EAAE,SAAS;AACpB,CAAA;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../src/utilities/sessionStorageUtils/index.ts"],"sourcesContent":[null],"names":["createWebStorageItem","SESSION_STORAGE_KEYS","parseBooleanString","isBoolean"],"mappings":";;;;;AAAA;;;;;;;;;AASG;AA2BH;;;;;;;AAOG;AACI,MAAM,wBAAwB,GAAG,CAAI,GAAW,EAAE,OAAA,GAAwC,EAAE,KACjGA,qCAAoB,CAAC,MAAM,MAAM,CAAC,cAAc,EAAE,GAAG,EAAE,OAAO;AAEhE;;;AAGG;MACU,yBAAyB,GAAG,wBAAwB,CAAUC,kDAAoB,CAAC,yBAAyB,EAAE;AACzH,IAAA,SAAS,EAAE,MAAM;IACjB,WAAW,EAAE,CAAC,GAAG,KAAKC,mCAAkB,CAAC,GAAG,EAAE,oCAAoC,CAAC;AACnF,IAAA,QAAQ,EAAEC,0BAAS;AACpB,CAAA;;;;;;"}
@@ -1,10 +1,9 @@
1
1
  /**
2
- * Web-only, typed `sessionStorage` persistence. DOM access (`window.sessionStorage`)
3
- * lives here rather than in components, so component code stays free of `window.*`
4
- * and keeps React Native parity this is the `sessionStorage` counterpart of
5
- * `localStorageUtils` (same isolation pattern). Every helper no-ops / returns
6
- * `null` when `sessionStorage` is unavailable (SSR, React Native, private mode,
7
- * quota errors).
2
+ * Web-only, typed `sessionStorage` persistence. Thin wrapper over the shared
3
+ * `#internal/utilities/webStorageUtils` factory (which `localStorageUtils`
4
+ * also uses the two modules were byte-identical twins before the factory).
5
+ * Every helper no-ops / returns `null` when `sessionStorage` is unavailable
6
+ * (SSR, React Native, private mode, quota errors).
8
7
  *
9
8
  * Every key this package persists is registered in `sessionStorageUtils.constants.ts`
10
9
  * — check there for the full list before adding a new one.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/sessionStorageUtils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,EAAE,oBAAoB,EAAE,CAAC;AA2ChC,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,gFAAgF;IAChF,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAChB,wEAAwE;IACxE,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACpB,mDAAmD;IACnD,KAAK,IAAI,IAAI,CAAC;CACf;AAED,MAAM,WAAW,yBAAyB,CAAC,CAAC;IAC1C,8DAA8D;IAC9D,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;IACjC,2DAA2D;IAC3D,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,CAAC,CAAC;IACjC,oEA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74 +1,16 @@
1
+ import { createWebStorageItem, isBoolean, parseBooleanString } from '../__internal__/webStorageUtils/webStorage.utils.js';
1
2
  import { SESSION_STORAGE_KEYS } from './sessionStorageUtils.constants.js';
2
3
 
3
4
  /**
4
- * Web-only, typed `sessionStorage` persistence. DOM access (`window.sessionStorage`)
5
- * lives here rather than in components, so component code stays free of `window.*`
6
- * and keeps React Native parity this is the `sessionStorage` counterpart of
7
- * `localStorageUtils` (same isolation pattern). Every helper no-ops / returns
8
- * `null` when `sessionStorage` is unavailable (SSR, React Native, private mode,
9
- * quota errors).
5
+ * Web-only, typed `sessionStorage` persistence. Thin wrapper over the shared
6
+ * `#internal/utilities/webStorageUtils` factory (which `localStorageUtils`
7
+ * also uses the two modules were byte-identical twins before the factory).
8
+ * Every helper no-ops / returns `null` when `sessionStorage` is unavailable
9
+ * (SSR, React Native, private mode, quota errors).
10
10
  *
11
11
  * Every key this package persists is registered in `sessionStorageUtils.constants.ts`
12
12
  * — check there for the full list before adding a new one.
13
13
  */
14
- const isBrowser = typeof window !== 'undefined';
15
- /**
16
- * Internal `sessionStorage` primitives backing `createSessionStorageItem`. Not
17
- * exported — everything a consumer needs goes through `createSessionStorageItem`,
18
- * which adds typed serialization/validation on top. Add a raw string export
19
- * here only once a real caller needs plain-string storage without JSON typing.
20
- */
21
- /** Read a raw string value, or `null` when unset/unavailable. */
22
- const safeSessionGet = (key) => {
23
- if (!isBrowser)
24
- return null;
25
- try {
26
- return window.sessionStorage.getItem(key);
27
- }
28
- catch {
29
- return null;
30
- }
31
- };
32
- /** Persist a raw string value; returns whether the write succeeded. */
33
- const safeSessionSet = (key, value) => {
34
- if (!isBrowser)
35
- return false;
36
- try {
37
- window.sessionStorage.setItem(key, value);
38
- return true;
39
- }
40
- catch {
41
- return false;
42
- }
43
- };
44
- /** Remove a value; returns whether the removal succeeded. */
45
- const safeSessionRemove = (key) => {
46
- if (!isBrowser)
47
- return false;
48
- try {
49
- window.sessionStorage.removeItem(key);
50
- return true;
51
- }
52
- catch {
53
- return false;
54
- }
55
- };
56
- /**
57
- * Reusable `validate` guard for a `createSessionStorageItem<boolean>` item.
58
- */
59
- const isBoolean = (value) => typeof value === 'boolean';
60
- /**
61
- * Parse a plain `'true'`/`'false'` string (not JSON) into a boolean; throws
62
- * `errorMessage` for anything else so `createSessionStorageItem.get()` treats it
63
- * as invalid data and returns `null`.
64
- */
65
- const parseBooleanString = (raw, errorMessage) => {
66
- if (raw === 'true')
67
- return true;
68
- if (raw === 'false')
69
- return false;
70
- throw new Error(errorMessage);
71
- };
72
14
  /**
73
15
  * Build a typed, failure-safe accessor for a single `sessionStorage` key.
74
16
  *
@@ -77,43 +19,7 @@ const parseBooleanString = (raw, errorMessage) => {
77
19
  * draft.set({ title: 'Hi' });
78
20
  * const value = draft.get(); // Draft | null
79
21
  */
80
- const createSessionStorageItem = (key, options = {}) => {
81
- const { serialize = JSON.stringify, deserialize = JSON.parse, validate } = options;
82
- return {
83
- get() {
84
- const raw = safeSessionGet(key);
85
- if (raw == null)
86
- return null;
87
- try {
88
- const value = deserialize(raw);
89
- if (validate && !validate(value))
90
- return null;
91
- return value;
92
- }
93
- catch {
94
- return null;
95
- }
96
- },
97
- set(value) {
98
- try {
99
- const serialized = serialize(value);
100
- // JSON.stringify (and a custom serializer) can return `undefined` for a
101
- // top-level `undefined`, function, or symbol — treat that as a failed
102
- // serialization rather than writing the literal string "undefined".
103
- if (typeof serialized !== 'string')
104
- return;
105
- safeSessionSet(key, serialized);
106
- }
107
- catch {
108
- // serialize() can throw (e.g. circular refs); matches the documented
109
- // failure-safe contract — silently ignore, same as a write failure.
110
- }
111
- },
112
- clear() {
113
- safeSessionRemove(key);
114
- },
115
- };
116
- };
22
+ const createSessionStorageItem = (key, options = {}) => createWebStorageItem(() => window.sessionStorage, key, options);
117
23
  /**
118
24
  * Persistence for `lazyWithRetry`'s force-refresh-once marker. Stored as the
119
25
  * plain strings `'true'` / `'false'` to preserve the original portal-library format.