@flipdish/ui-library 0.31.3 → 0.31.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/molecules/CodeSnippet/index.cjs.map +1 -1
- package/dist/components/molecules/CodeSnippet/index.d.ts.map +1 -1
- package/dist/components/molecules/CodeSnippet/index.js.map +1 -1
- package/dist/components/molecules/Pagination/index.cjs.map +1 -1
- package/dist/components/molecules/Pagination/index.d.ts.map +1 -1
- package/dist/components/molecules/Pagination/index.js.map +1 -1
- package/dist/components/organisms/ApplicationHeader/index.cjs +4 -5
- package/dist/components/organisms/ApplicationHeader/index.cjs.map +1 -1
- package/dist/components/organisms/ApplicationHeader/index.d.ts +4 -5
- package/dist/components/organisms/ApplicationHeader/index.d.ts.map +1 -1
- package/dist/components/organisms/ApplicationHeader/index.js +4 -5
- package/dist/components/organisms/ApplicationHeader/index.js.map +1 -1
- package/dist/components/organisms/Charts/components/PieChart.cjs +2 -4
- package/dist/components/organisms/Charts/components/PieChart.cjs.map +1 -1
- package/dist/components/organisms/Charts/components/PieChart.d.ts +2 -4
- package/dist/components/organisms/Charts/components/PieChart.d.ts.map +1 -1
- package/dist/components/organisms/Charts/components/PieChart.js +2 -4
- package/dist/components/organisms/Charts/components/PieChart.js.map +1 -1
- package/dist/components/organisms/Charts/index.d.ts +0 -2
- package/dist/components/organisms/Charts/index.d.ts.map +1 -1
- package/dist/components/organisms/ColorPicker/index.cjs +3 -2
- package/dist/components/organisms/ColorPicker/index.cjs.map +1 -1
- package/dist/components/organisms/ColorPicker/index.d.ts +3 -2
- package/dist/components/organisms/ColorPicker/index.d.ts.map +1 -1
- package/dist/components/organisms/ColorPicker/index.js +3 -2
- package/dist/components/organisms/ColorPicker/index.js.map +1 -1
- package/dist/components/organisms/ImagePicker/index.cjs +3 -2
- package/dist/components/organisms/ImagePicker/index.cjs.map +1 -1
- package/dist/components/organisms/ImagePicker/index.d.ts +3 -2
- package/dist/components/organisms/ImagePicker/index.d.ts.map +1 -1
- package/dist/components/organisms/ImagePicker/index.js +3 -2
- package/dist/components/organisms/ImagePicker/index.js.map +1 -1
- package/dist/components/organisms/PageHeader/index.cjs +4 -6
- package/dist/components/organisms/PageHeader/index.cjs.map +1 -1
- package/dist/components/organisms/PageHeader/index.d.ts +4 -6
- package/dist/components/organisms/PageHeader/index.d.ts.map +1 -1
- package/dist/components/organisms/PageHeader/index.js +4 -6
- package/dist/components/organisms/PageHeader/index.js.map +1 -1
- package/dist/components/organisms/SidePanel/index.cjs +5 -7
- package/dist/components/organisms/SidePanel/index.cjs.map +1 -1
- package/dist/components/organisms/SidePanel/index.d.ts +5 -7
- package/dist/components/organisms/SidePanel/index.d.ts.map +1 -1
- package/dist/components/organisms/SidePanel/index.js +5 -7
- package/dist/components/organisms/SidePanel/index.js.map +1 -1
- package/dist/components/organisms/SidebarNavigation/components/SidebarMenuButton.cjs +7 -4
- package/dist/components/organisms/SidebarNavigation/components/SidebarMenuButton.cjs.map +1 -1
- package/dist/components/organisms/SidebarNavigation/components/SidebarMenuButton.d.ts +7 -4
- package/dist/components/organisms/SidebarNavigation/components/SidebarMenuButton.d.ts.map +1 -1
- package/dist/components/organisms/SidebarNavigation/components/SidebarMenuButton.js +7 -4
- package/dist/components/organisms/SidebarNavigation/components/SidebarMenuButton.js.map +1 -1
- package/dist/components/organisms/SidebarNavigation/index.cjs +4 -8
- package/dist/components/organisms/SidebarNavigation/index.cjs.map +1 -1
- package/dist/components/organisms/SidebarNavigation/index.d.ts +4 -8
- package/dist/components/organisms/SidebarNavigation/index.d.ts.map +1 -1
- package/dist/components/organisms/SidebarNavigation/index.js +4 -8
- package/dist/components/organisms/SidebarNavigation/index.js.map +1 -1
- package/dist/components/templates/AppShell/index.cjs +5 -7
- package/dist/components/templates/AppShell/index.cjs.map +1 -1
- package/dist/components/templates/AppShell/index.d.ts +5 -7
- package/dist/components/templates/AppShell/index.d.ts.map +1 -1
- package/dist/components/templates/AppShell/index.js +5 -7
- package/dist/components/templates/AppShell/index.js.map +1 -1
- package/dist/components/templates/NotFoundPage/index.cjs +3 -9
- package/dist/components/templates/NotFoundPage/index.cjs.map +1 -1
- package/dist/components/templates/NotFoundPage/index.d.ts +3 -9
- package/dist/components/templates/NotFoundPage/index.d.ts.map +1 -1
- package/dist/components/templates/NotFoundPage/index.js +3 -9
- package/dist/components/templates/NotFoundPage/index.js.map +1 -1
- package/dist/components/templates/PageLayout/index.cjs +5 -12
- package/dist/components/templates/PageLayout/index.cjs.map +1 -1
- package/dist/components/templates/PageLayout/index.d.ts +5 -12
- package/dist/components/templates/PageLayout/index.d.ts.map +1 -1
- package/dist/components/templates/PageLayout/index.js +5 -12
- package/dist/components/templates/PageLayout/index.js.map +1 -1
- package/dist/hooks/useBreakpoints/index.cjs +5 -5
- package/dist/hooks/useBreakpoints/index.d.ts +5 -5
- package/dist/hooks/useBreakpoints/index.js +5 -5
- package/dist/hooks/useClipboard/index.cjs +5 -2
- package/dist/hooks/useClipboard/index.cjs.map +1 -1
- package/dist/hooks/useClipboard/index.d.ts +5 -2
- package/dist/hooks/useClipboard/index.d.ts.map +1 -1
- package/dist/hooks/useClipboard/index.js +5 -2
- package/dist/hooks/useClipboard/index.js.map +1 -1
- package/dist/hooks/usePlatform/index.cjs +4 -5
- package/dist/hooks/usePlatform/index.cjs.map +1 -1
- package/dist/hooks/usePlatform/index.d.ts +4 -5
- package/dist/hooks/usePlatform/index.d.ts.map +1 -1
- package/dist/hooks/usePlatform/index.js +4 -5
- package/dist/hooks/usePlatform/index.js.map +1 -1
- package/dist/hooks/useResizeObserver/index.cjs +7 -2
- package/dist/hooks/useResizeObserver/index.cjs.map +1 -1
- package/dist/hooks/useResizeObserver/index.d.ts +7 -2
- package/dist/hooks/useResizeObserver/index.d.ts.map +1 -1
- package/dist/hooks/useResizeObserver/index.js +7 -2
- package/dist/hooks/useResizeObserver/index.js.map +1 -1
- package/dist/hooks/useSidePanel/index.cjs +7 -5
- package/dist/hooks/useSidePanel/index.cjs.map +1 -1
- package/dist/hooks/useSidePanel/index.d.ts +7 -5
- package/dist/hooks/useSidePanel/index.d.ts.map +1 -1
- package/dist/hooks/useSidePanel/index.js +7 -5
- package/dist/hooks/useSidePanel/index.js.map +1 -1
- package/dist/native/utilities/cx/index.d.ts +9 -9
- package/dist/native/utilities/cx/index.d.ts.map +1 -1
- package/dist/native/utilities/cx/index.js +9 -9
- package/dist/native/utilities/cx/index.js.map +1 -1
- package/dist/native/utilities/testIdUtils/index.d.ts +44 -10
- package/dist/native/utilities/testIdUtils/index.d.ts.map +1 -1
- package/dist/native/utilities/testIdUtils/index.js +44 -10
- package/dist/native/utilities/testIdUtils/index.js.map +1 -1
- package/dist/providers/ErrorBoundary/index.cjs +5 -7
- package/dist/providers/ErrorBoundary/index.cjs.map +1 -1
- package/dist/providers/ErrorBoundary/index.d.ts +4 -7
- package/dist/providers/ErrorBoundary/index.d.ts.map +1 -1
- package/dist/providers/ErrorBoundary/index.js +5 -7
- package/dist/providers/ErrorBoundary/index.js.map +1 -1
- package/dist/providers/RouteProvider/index.cjs +5 -1
- package/dist/providers/RouteProvider/index.cjs.map +1 -1
- package/dist/providers/RouteProvider/index.d.ts +5 -1
- package/dist/providers/RouteProvider/index.d.ts.map +1 -1
- package/dist/providers/RouteProvider/index.js +5 -1
- package/dist/providers/RouteProvider/index.js.map +1 -1
- package/dist/providers/ThemeProvider/index.cjs +11 -1
- package/dist/providers/ThemeProvider/index.cjs.map +1 -1
- package/dist/providers/ThemeProvider/index.d.ts +11 -1
- package/dist/providers/ThemeProvider/index.d.ts.map +1 -1
- package/dist/providers/ThemeProvider/index.js +11 -1
- package/dist/providers/ThemeProvider/index.js.map +1 -1
- package/dist/providers/UIProvider/index.cjs +5 -1
- package/dist/providers/UIProvider/index.cjs.map +1 -1
- package/dist/providers/UIProvider/index.d.ts +5 -1
- package/dist/providers/UIProvider/index.d.ts.map +1 -1
- package/dist/providers/UIProvider/index.js +5 -1
- package/dist/providers/UIProvider/index.js.map +1 -1
- package/dist/utilities/cssScopeUtils/index.cjs +6 -5
- package/dist/utilities/cssScopeUtils/index.cjs.map +1 -1
- package/dist/utilities/cssScopeUtils/index.d.ts +6 -5
- package/dist/utilities/cssScopeUtils/index.d.ts.map +1 -1
- package/dist/utilities/cssScopeUtils/index.js +6 -5
- package/dist/utilities/cssScopeUtils/index.js.map +1 -1
- package/dist/utilities/cx/index.cjs +9 -9
- package/dist/utilities/cx/index.cjs.map +1 -1
- package/dist/utilities/cx/index.d.ts +9 -9
- package/dist/utilities/cx/index.d.ts.map +1 -1
- package/dist/utilities/cx/index.js +9 -9
- package/dist/utilities/cx/index.js.map +1 -1
- package/dist/utilities/hrefUtils/index.cjs +10 -11
- package/dist/utilities/hrefUtils/index.cjs.map +1 -1
- package/dist/utilities/hrefUtils/index.d.ts +10 -11
- package/dist/utilities/hrefUtils/index.d.ts.map +1 -1
- package/dist/utilities/hrefUtils/index.js +10 -11
- package/dist/utilities/hrefUtils/index.js.map +1 -1
- package/dist/utilities/localStorageUtils/index.cjs +8 -5
- package/dist/utilities/localStorageUtils/index.cjs.map +1 -1
- package/dist/utilities/localStorageUtils/index.d.ts +8 -5
- package/dist/utilities/localStorageUtils/index.d.ts.map +1 -1
- package/dist/utilities/localStorageUtils/index.js +8 -5
- package/dist/utilities/localStorageUtils/index.js.map +1 -1
- package/dist/utilities/renderUtils/index.cjs +31 -30
- package/dist/utilities/renderUtils/index.cjs.map +1 -1
- package/dist/utilities/renderUtils/index.d.ts +31 -30
- package/dist/utilities/renderUtils/index.d.ts.map +1 -1
- package/dist/utilities/renderUtils/index.js +31 -30
- package/dist/utilities/renderUtils/index.js.map +1 -1
- package/dist/utilities/sessionStorageUtils/index.cjs +8 -5
- package/dist/utilities/sessionStorageUtils/index.cjs.map +1 -1
- package/dist/utilities/sessionStorageUtils/index.d.ts +8 -5
- package/dist/utilities/sessionStorageUtils/index.d.ts.map +1 -1
- package/dist/utilities/sessionStorageUtils/index.js +8 -5
- package/dist/utilities/sessionStorageUtils/index.js.map +1 -1
- package/dist/utilities/testIdUtils/index.cjs +44 -10
- package/dist/utilities/testIdUtils/index.cjs.map +1 -1
- package/dist/utilities/testIdUtils/index.d.ts +44 -10
- package/dist/utilities/testIdUtils/index.d.ts.map +1 -1
- package/dist/utilities/testIdUtils/index.js +44 -10
- package/dist/utilities/testIdUtils/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -12,12 +12,15 @@ import { LOCAL_STORAGE_KEYS } from './localStorageUtils.constants.js';
|
|
|
12
12
|
* — check there for the full list before adding a new one.
|
|
13
13
|
*/
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Builds a typed, failure-safe accessor for a single `localStorage` key.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* const draft = createLocalStorageItem<Draft>('fd-draft'); draft.set({ title: 'Hi' }); draft.get(); // Draft | null
|
|
18
|
+
*
|
|
19
|
+
* @param key The storage key; register it in `LOCAL_STORAGE_KEYS` first.
|
|
20
|
+
* @param options Custom `serialize`/`deserialize` and a `validate` guard; see
|
|
21
|
+
* `LocalStorageItemOptions`.
|
|
22
|
+
* @returns `get`, `set` and `clear` that never throw; `get()` returns `null` when storage is
|
|
23
|
+
* unavailable, while `set()` and `clear()` return `void` and ignore failures.
|
|
21
24
|
*/
|
|
22
25
|
const createLocalStorageItem = (key, options = {}) => createWebStorageItem(() => window.localStorage, key, options);
|
|
23
26
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/utilities/localStorageUtils/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;;;;;;;AASG;AA2BH
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utilities/localStorageUtils/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;;;;;;;AASG;AA2BH;;;;;;;;;;AAUG;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;AAED;MACa,gBAAgB,GAAG,sBAAsB,CAAS,kBAAkB,CAAC,SAAS,EAAE;AAC3F,IAAA,SAAS,EAAE,MAAM;AACjB,IAAA,WAAW,EAAE,CAAC,GAAG,KAAK,GAAG;AACzB,IAAA,QAAQ,EAAE,QAAQ;AACnB,CAAA;;"}
|
|
@@ -4,10 +4,11 @@ var React = require('react');
|
|
|
4
4
|
var importWithRetry_utils = require('./importWithRetry.utils.cjs');
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Reads an environment variable from `process.env` first (tests, SSR), then Vite's
|
|
8
|
+
* `import.meta.env`.
|
|
8
9
|
*
|
|
9
|
-
* @param key The
|
|
10
|
-
* @returns
|
|
10
|
+
* @param key The variable name, such as `VITE_APPID_OVERRIDE`.
|
|
11
|
+
* @returns Its value, or an empty string when neither source defines it.
|
|
11
12
|
*/
|
|
12
13
|
const getEnvironmentVariable = (key) => {
|
|
13
14
|
// Prefer Node env in tests/SSR
|
|
@@ -23,10 +24,10 @@ const getEnvironmentVariable = (key) => {
|
|
|
23
24
|
return viteEnv?.[key] ?? '';
|
|
24
25
|
};
|
|
25
26
|
/**
|
|
26
|
-
*
|
|
27
|
+
* Reads an attribute from the `#flipdish-micro-frontend` container Portal mounts the app into.
|
|
27
28
|
*
|
|
28
|
-
* @param key The
|
|
29
|
-
* @returns
|
|
29
|
+
* @param key The attribute name, such as `data-app-id`.
|
|
30
|
+
* @returns Its value, or an empty string when there is no document or no such attribute.
|
|
30
31
|
*/
|
|
31
32
|
const getMicroFrontendAttribute = (key) => {
|
|
32
33
|
if (typeof document === 'undefined') {
|
|
@@ -36,49 +37,42 @@ const getMicroFrontendAttribute = (key) => {
|
|
|
36
37
|
return microFrontendDiv?.getAttribute(key) || '';
|
|
37
38
|
};
|
|
38
39
|
/**
|
|
39
|
-
*
|
|
40
|
+
* Reads the app id: the `VITE_APPID_OVERRIDE` environment variable first, then the container's
|
|
41
|
+
* `data-app-id` attribute (`data-appid` for portal-library 5.1.0 and below). Read once at call
|
|
42
|
+
* time; a component will not re-render when the value changes.
|
|
40
43
|
*
|
|
41
|
-
*
|
|
42
|
-
* If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-app-id`.
|
|
43
|
-
* Fallbacks to `data-appid` for backwards compatibility @flipdish/portal-library@5.1.0 and below
|
|
44
|
-
*
|
|
45
|
-
* @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.
|
|
44
|
+
* @returns The app id, or an empty string when neither source provides one.
|
|
46
45
|
*/
|
|
47
46
|
const getAppId = () => {
|
|
48
47
|
return getEnvironmentVariable('VITE_APPID_OVERRIDE') || getMicroFrontendAttribute('data-app-id') || getMicroFrontendAttribute('data-appid');
|
|
49
48
|
};
|
|
50
49
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-org-id`.
|
|
55
|
-
* Fallbacks to `data-orgid` for backwards compatibility @flipdish/portal-library@5.1.0 and below
|
|
50
|
+
* Reads the org id: the `VITE_ORGID_OVERRIDE` environment variable first, then the container's
|
|
51
|
+
* `data-org-id` attribute (`data-orgid` for portal-library 5.1.0 and below). Read once at call
|
|
52
|
+
* time; a component will not re-render when the value changes.
|
|
56
53
|
*
|
|
57
|
-
* @
|
|
54
|
+
* @returns The org id, or an empty string when neither source provides one.
|
|
58
55
|
*/
|
|
59
56
|
const getOrgId = () => {
|
|
60
57
|
return getEnvironmentVariable('VITE_ORGID_OVERRIDE') || getMicroFrontendAttribute('data-org-id') || getMicroFrontendAttribute('data-orgid');
|
|
61
58
|
};
|
|
62
59
|
/**
|
|
63
|
-
*
|
|
60
|
+
* Reads the brand id: the `VITE_BRANDID_OVERRIDE` environment variable first, then the
|
|
61
|
+
* container's `data-brand-id` attribute (`data-brandid` for portal-library 5.1.0 and below).
|
|
62
|
+
* Read once at call time; a component will not re-render when the value changes.
|
|
64
63
|
*
|
|
65
|
-
*
|
|
66
|
-
* If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-brand-id`.
|
|
67
|
-
* Fallbacks to `data-brandid` for backwards compatibility @flipdish/portal-library@5.1.0 and below
|
|
68
|
-
*
|
|
69
|
-
* @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.
|
|
64
|
+
* @returns The brand id, or an empty string when neither source provides one.
|
|
70
65
|
*/
|
|
71
66
|
const getBrandId = () => {
|
|
72
67
|
return getEnvironmentVariable('VITE_BRANDID_OVERRIDE') || getMicroFrontendAttribute('data-brand-id') || getMicroFrontendAttribute('data-brandid');
|
|
73
68
|
};
|
|
74
69
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* Fallbacks to `data-isflipdishstaff` for backwards compatibility @flipdish/portal-library@5.1.0 and below
|
|
70
|
+
* Reads the Flipdish-staff flag: the `VITE_ISFLIPDISHSTAFFOVERRIDE` environment variable
|
|
71
|
+
* first, then the container's `data-is-flipdish-staff` attribute (`data-isflipdishstaff` for
|
|
72
|
+
* portal-library 5.1.0 and below). Read once at call time; a component will not re-render when
|
|
73
|
+
* the value changes.
|
|
80
74
|
*
|
|
81
|
-
* @
|
|
75
|
+
* @returns `true` when the value reads as true, otherwise `false`.
|
|
82
76
|
*/
|
|
83
77
|
const getIsFlipdishStaff = () => {
|
|
84
78
|
const stringValue = getEnvironmentVariable('VITE_ISFLIPDISHSTAFFOVERRIDE') ||
|
|
@@ -86,6 +80,13 @@ const getIsFlipdishStaff = () => {
|
|
|
86
80
|
getMicroFrontendAttribute('data-isflipdishstaff');
|
|
87
81
|
return stringValue?.toString() === 'true';
|
|
88
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* `React.lazy` that reloads the page once when a dynamic import fails, on the assumption that
|
|
85
|
+
* a deploy replaced the chunk; a second failure after the reload is thrown as a real error.
|
|
86
|
+
*
|
|
87
|
+
* @param componentImport The `() => import('./Page')` factory you would pass to `React.lazy`.
|
|
88
|
+
* @returns A lazy component to render inside `Suspense`.
|
|
89
|
+
*/
|
|
89
90
|
// biome-ignore lint/suspicious/noExplicitAny: dynamic import factory shape isn't expressible without `any`; preserved from portal-library implementation
|
|
90
91
|
const lazyWithRetry = (componentImport) => React.lazy(() => importWithRetry_utils.importWithRetry(componentImport));
|
|
91
92
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/utilities/renderUtils/index.ts"],"sourcesContent":[null],"names":["lazy","importWithRetry"],"mappings":";;;;;AAIA
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/utilities/renderUtils/index.ts"],"sourcesContent":[null],"names":["lazy","importWithRetry"],"mappings":";;;;;AAIA;;;;;;AAMG;AACI,MAAM,sBAAsB,GAAG,CAAC,GAAW,KAAY;;AAE5D,IAAA,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE;AACzF,QAAA,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAW;IACnC;;;;;;AAMA,IAAA,MAAM,OAAO,GAAI,SAA6E;AAC9F,IAAA,OAAO,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE;AAC7B;AAEA;;;;;AAKG;AACI,MAAM,yBAAyB,GAAG,CAAC,GAAW,KAAY;AAC/D,IAAA,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;AACnC,QAAA,OAAO,EAAE;IACX;IACA,MAAM,gBAAgB,GAAG,QAAQ,CAAC,cAAc,CAAC,yBAAyB,CAAC;IAC3E,OAAO,gBAAgB,EAAE,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE;AAClD;AAEA;;;;;;AAMG;AACI,MAAM,QAAQ,GAAG,MAAa;AACnC,IAAA,OAAO,sBAAsB,CAAC,qBAAqB,CAAC,IAAI,yBAAyB,CAAC,aAAa,CAAC,IAAI,yBAAyB,CAAC,YAAY,CAAC;AAC7I;AAEA;;;;;;AAMG;AACI,MAAM,QAAQ,GAAG,MAAa;AACnC,IAAA,OAAO,sBAAsB,CAAC,qBAAqB,CAAC,IAAI,yBAAyB,CAAC,aAAa,CAAC,IAAI,yBAAyB,CAAC,YAAY,CAAC;AAC7I;AAEA;;;;;;AAMG;AACI,MAAM,UAAU,GAAG,MAAa;AACrC,IAAA,OAAO,sBAAsB,CAAC,uBAAuB,CAAC,IAAI,yBAAyB,CAAC,eAAe,CAAC,IAAI,yBAAyB,CAAC,cAAc,CAAC;AACnJ;AAEA;;;;;;;AAOG;AACI,MAAM,kBAAkB,GAAG,MAAc;AAC9C,IAAA,MAAM,WAAW,GACf,sBAAsB,CAAC,8BAA8B,CAAC;QACtD,yBAAyB,CAAC,wBAAwB,CAAC;QACnD,yBAAyB,CAAC,sBAAsB,CAAC;AACnD,IAAA,OAAO,WAAW,EAAE,QAAQ,EAAE,KAAK,MAAM;AAC3C;AAEA;;;;;;AAMG;AACH;AACO,MAAM,aAAa,GAAG,CAAC,eAA0B,KAAKA,UAAI,CAAC,MAAMC,qCAAe,CAAC,eAAe,CAAC;;;;;;;;"}
|
|
@@ -1,56 +1,57 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Reads an environment variable from `process.env` first (tests, SSR), then Vite's
|
|
3
|
+
* `import.meta.env`.
|
|
3
4
|
*
|
|
4
|
-
* @param key The
|
|
5
|
-
* @returns
|
|
5
|
+
* @param key The variable name, such as `VITE_APPID_OVERRIDE`.
|
|
6
|
+
* @returns Its value, or an empty string when neither source defines it.
|
|
6
7
|
*/
|
|
7
8
|
export declare const getEnvironmentVariable: (key: string) => string;
|
|
8
9
|
/**
|
|
9
|
-
*
|
|
10
|
+
* Reads an attribute from the `#flipdish-micro-frontend` container Portal mounts the app into.
|
|
10
11
|
*
|
|
11
|
-
* @param key The
|
|
12
|
-
* @returns
|
|
12
|
+
* @param key The attribute name, such as `data-app-id`.
|
|
13
|
+
* @returns Its value, or an empty string when there is no document or no such attribute.
|
|
13
14
|
*/
|
|
14
15
|
export declare const getMicroFrontendAttribute: (key: string) => string;
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
+
* Reads the app id: the `VITE_APPID_OVERRIDE` environment variable first, then the container's
|
|
18
|
+
* `data-app-id` attribute (`data-appid` for portal-library 5.1.0 and below). Read once at call
|
|
19
|
+
* time; a component will not re-render when the value changes.
|
|
17
20
|
*
|
|
18
|
-
*
|
|
19
|
-
* If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-app-id`.
|
|
20
|
-
* Fallbacks to `data-appid` for backwards compatibility @flipdish/portal-library@5.1.0 and below
|
|
21
|
-
*
|
|
22
|
-
* @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.
|
|
21
|
+
* @returns The app id, or an empty string when neither source provides one.
|
|
23
22
|
*/
|
|
24
23
|
export declare const getAppId: () => string;
|
|
25
24
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-org-id`.
|
|
30
|
-
* Fallbacks to `data-orgid` for backwards compatibility @flipdish/portal-library@5.1.0 and below
|
|
25
|
+
* Reads the org id: the `VITE_ORGID_OVERRIDE` environment variable first, then the container's
|
|
26
|
+
* `data-org-id` attribute (`data-orgid` for portal-library 5.1.0 and below). Read once at call
|
|
27
|
+
* time; a component will not re-render when the value changes.
|
|
31
28
|
*
|
|
32
|
-
* @
|
|
29
|
+
* @returns The org id, or an empty string when neither source provides one.
|
|
33
30
|
*/
|
|
34
31
|
export declare const getOrgId: () => string;
|
|
35
32
|
/**
|
|
36
|
-
*
|
|
33
|
+
* Reads the brand id: the `VITE_BRANDID_OVERRIDE` environment variable first, then the
|
|
34
|
+
* container's `data-brand-id` attribute (`data-brandid` for portal-library 5.1.0 and below).
|
|
35
|
+
* Read once at call time; a component will not re-render when the value changes.
|
|
37
36
|
*
|
|
38
|
-
*
|
|
39
|
-
* If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-brand-id`.
|
|
40
|
-
* Fallbacks to `data-brandid` for backwards compatibility @flipdish/portal-library@5.1.0 and below
|
|
41
|
-
*
|
|
42
|
-
* @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.
|
|
37
|
+
* @returns The brand id, or an empty string when neither source provides one.
|
|
43
38
|
*/
|
|
44
39
|
export declare const getBrandId: () => string;
|
|
45
40
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* Fallbacks to `data-isflipdishstaff` for backwards compatibility @flipdish/portal-library@5.1.0 and below
|
|
41
|
+
* Reads the Flipdish-staff flag: the `VITE_ISFLIPDISHSTAFFOVERRIDE` environment variable
|
|
42
|
+
* first, then the container's `data-is-flipdish-staff` attribute (`data-isflipdishstaff` for
|
|
43
|
+
* portal-library 5.1.0 and below). Read once at call time; a component will not re-render when
|
|
44
|
+
* the value changes.
|
|
51
45
|
*
|
|
52
|
-
* @
|
|
46
|
+
* @returns `true` when the value reads as true, otherwise `false`.
|
|
53
47
|
*/
|
|
54
48
|
export declare const getIsFlipdishStaff: () => boolean;
|
|
49
|
+
/**
|
|
50
|
+
* `React.lazy` that reloads the page once when a dynamic import fails, on the assumption that
|
|
51
|
+
* a deploy replaced the chunk; a second failure after the reload is thrown as a real error.
|
|
52
|
+
*
|
|
53
|
+
* @param componentImport The `() => import('./Page')` factory you would pass to `React.lazy`.
|
|
54
|
+
* @returns A lazy component to render inside `Suspense`.
|
|
55
|
+
*/
|
|
55
56
|
export declare const lazyWithRetry: (componentImport: () => any) => import("react").LazyExoticComponent<import("react").ComponentType<any>>;
|
|
56
57
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/renderUtils/index.ts"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/renderUtils/index.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GAAI,KAAK,MAAM,KAAG,MAYpD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GAAI,KAAK,MAAM,KAAG,MAMvD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,QAAO,MAE3B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,QAAO,MAE3B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,QAAO,MAE7B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,QAAO,OAMrC,CAAC;AAEF;;;;;;GAMG;AAEH,eAAO,MAAM,aAAa,GAAI,iBAAiB,MAAM,GAAG,4EAAiD,CAAC"}
|
|
@@ -2,10 +2,11 @@ import { lazy } from 'react';
|
|
|
2
2
|
import { importWithRetry } from './importWithRetry.utils.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Reads an environment variable from `process.env` first (tests, SSR), then Vite's
|
|
6
|
+
* `import.meta.env`.
|
|
6
7
|
*
|
|
7
|
-
* @param key The
|
|
8
|
-
* @returns
|
|
8
|
+
* @param key The variable name, such as `VITE_APPID_OVERRIDE`.
|
|
9
|
+
* @returns Its value, or an empty string when neither source defines it.
|
|
9
10
|
*/
|
|
10
11
|
const getEnvironmentVariable = (key) => {
|
|
11
12
|
// Prefer Node env in tests/SSR
|
|
@@ -21,10 +22,10 @@ const getEnvironmentVariable = (key) => {
|
|
|
21
22
|
return viteEnv?.[key] ?? '';
|
|
22
23
|
};
|
|
23
24
|
/**
|
|
24
|
-
*
|
|
25
|
+
* Reads an attribute from the `#flipdish-micro-frontend` container Portal mounts the app into.
|
|
25
26
|
*
|
|
26
|
-
* @param key The
|
|
27
|
-
* @returns
|
|
27
|
+
* @param key The attribute name, such as `data-app-id`.
|
|
28
|
+
* @returns Its value, or an empty string when there is no document or no such attribute.
|
|
28
29
|
*/
|
|
29
30
|
const getMicroFrontendAttribute = (key) => {
|
|
30
31
|
if (typeof document === 'undefined') {
|
|
@@ -34,49 +35,42 @@ const getMicroFrontendAttribute = (key) => {
|
|
|
34
35
|
return microFrontendDiv?.getAttribute(key) || '';
|
|
35
36
|
};
|
|
36
37
|
/**
|
|
37
|
-
*
|
|
38
|
+
* Reads the app id: the `VITE_APPID_OVERRIDE` environment variable first, then the container's
|
|
39
|
+
* `data-app-id` attribute (`data-appid` for portal-library 5.1.0 and below). Read once at call
|
|
40
|
+
* time; a component will not re-render when the value changes.
|
|
38
41
|
*
|
|
39
|
-
*
|
|
40
|
-
* If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-app-id`.
|
|
41
|
-
* Fallbacks to `data-appid` for backwards compatibility @flipdish/portal-library@5.1.0 and below
|
|
42
|
-
*
|
|
43
|
-
* @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.
|
|
42
|
+
* @returns The app id, or an empty string when neither source provides one.
|
|
44
43
|
*/
|
|
45
44
|
const getAppId = () => {
|
|
46
45
|
return getEnvironmentVariable('VITE_APPID_OVERRIDE') || getMicroFrontendAttribute('data-app-id') || getMicroFrontendAttribute('data-appid');
|
|
47
46
|
};
|
|
48
47
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-org-id`.
|
|
53
|
-
* Fallbacks to `data-orgid` for backwards compatibility @flipdish/portal-library@5.1.0 and below
|
|
48
|
+
* Reads the org id: the `VITE_ORGID_OVERRIDE` environment variable first, then the container's
|
|
49
|
+
* `data-org-id` attribute (`data-orgid` for portal-library 5.1.0 and below). Read once at call
|
|
50
|
+
* time; a component will not re-render when the value changes.
|
|
54
51
|
*
|
|
55
|
-
* @
|
|
52
|
+
* @returns The org id, or an empty string when neither source provides one.
|
|
56
53
|
*/
|
|
57
54
|
const getOrgId = () => {
|
|
58
55
|
return getEnvironmentVariable('VITE_ORGID_OVERRIDE') || getMicroFrontendAttribute('data-org-id') || getMicroFrontendAttribute('data-orgid');
|
|
59
56
|
};
|
|
60
57
|
/**
|
|
61
|
-
*
|
|
58
|
+
* Reads the brand id: the `VITE_BRANDID_OVERRIDE` environment variable first, then the
|
|
59
|
+
* container's `data-brand-id` attribute (`data-brandid` for portal-library 5.1.0 and below).
|
|
60
|
+
* Read once at call time; a component will not re-render when the value changes.
|
|
62
61
|
*
|
|
63
|
-
*
|
|
64
|
-
* If the environment variable is not set, it falls back to retrieving from a micro frontend attribute `data-brand-id`.
|
|
65
|
-
* Fallbacks to `data-brandid` for backwards compatibility @flipdish/portal-library@5.1.0 and below
|
|
66
|
-
*
|
|
67
|
-
* @warning Your component will not re-render if the value changes. Use 'useMicroFrontendAttributes' custom hook instead if you care about reactivity.
|
|
62
|
+
* @returns The brand id, or an empty string when neither source provides one.
|
|
68
63
|
*/
|
|
69
64
|
const getBrandId = () => {
|
|
70
65
|
return getEnvironmentVariable('VITE_BRANDID_OVERRIDE') || getMicroFrontendAttribute('data-brand-id') || getMicroFrontendAttribute('data-brandid');
|
|
71
66
|
};
|
|
72
67
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* Fallbacks to `data-isflipdishstaff` for backwards compatibility @flipdish/portal-library@5.1.0 and below
|
|
68
|
+
* Reads the Flipdish-staff flag: the `VITE_ISFLIPDISHSTAFFOVERRIDE` environment variable
|
|
69
|
+
* first, then the container's `data-is-flipdish-staff` attribute (`data-isflipdishstaff` for
|
|
70
|
+
* portal-library 5.1.0 and below). Read once at call time; a component will not re-render when
|
|
71
|
+
* the value changes.
|
|
78
72
|
*
|
|
79
|
-
* @
|
|
73
|
+
* @returns `true` when the value reads as true, otherwise `false`.
|
|
80
74
|
*/
|
|
81
75
|
const getIsFlipdishStaff = () => {
|
|
82
76
|
const stringValue = getEnvironmentVariable('VITE_ISFLIPDISHSTAFFOVERRIDE') ||
|
|
@@ -84,6 +78,13 @@ const getIsFlipdishStaff = () => {
|
|
|
84
78
|
getMicroFrontendAttribute('data-isflipdishstaff');
|
|
85
79
|
return stringValue?.toString() === 'true';
|
|
86
80
|
};
|
|
81
|
+
/**
|
|
82
|
+
* `React.lazy` that reloads the page once when a dynamic import fails, on the assumption that
|
|
83
|
+
* a deploy replaced the chunk; a second failure after the reload is thrown as a real error.
|
|
84
|
+
*
|
|
85
|
+
* @param componentImport The `() => import('./Page')` factory you would pass to `React.lazy`.
|
|
86
|
+
* @returns A lazy component to render inside `Suspense`.
|
|
87
|
+
*/
|
|
87
88
|
// biome-ignore lint/suspicious/noExplicitAny: dynamic import factory shape isn't expressible without `any`; preserved from portal-library implementation
|
|
88
89
|
const lazyWithRetry = (componentImport) => lazy(() => importWithRetry(componentImport));
|
|
89
90
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/utilities/renderUtils/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAIA
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utilities/renderUtils/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAIA;;;;;;AAMG;AACI,MAAM,sBAAsB,GAAG,CAAC,GAAW,KAAY;;AAE5D,IAAA,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE;AACzF,QAAA,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAW;IACnC;;;;;;AAMA,IAAA,MAAM,OAAO,GAAI,MAAM,CAAC,IAAkE,CAAC,GAAG;AAC9F,IAAA,OAAO,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE;AAC7B;AAEA;;;;;AAKG;AACI,MAAM,yBAAyB,GAAG,CAAC,GAAW,KAAY;AAC/D,IAAA,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;AACnC,QAAA,OAAO,EAAE;IACX;IACA,MAAM,gBAAgB,GAAG,QAAQ,CAAC,cAAc,CAAC,yBAAyB,CAAC;IAC3E,OAAO,gBAAgB,EAAE,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE;AAClD;AAEA;;;;;;AAMG;AACI,MAAM,QAAQ,GAAG,MAAa;AACnC,IAAA,OAAO,sBAAsB,CAAC,qBAAqB,CAAC,IAAI,yBAAyB,CAAC,aAAa,CAAC,IAAI,yBAAyB,CAAC,YAAY,CAAC;AAC7I;AAEA;;;;;;AAMG;AACI,MAAM,QAAQ,GAAG,MAAa;AACnC,IAAA,OAAO,sBAAsB,CAAC,qBAAqB,CAAC,IAAI,yBAAyB,CAAC,aAAa,CAAC,IAAI,yBAAyB,CAAC,YAAY,CAAC;AAC7I;AAEA;;;;;;AAMG;AACI,MAAM,UAAU,GAAG,MAAa;AACrC,IAAA,OAAO,sBAAsB,CAAC,uBAAuB,CAAC,IAAI,yBAAyB,CAAC,eAAe,CAAC,IAAI,yBAAyB,CAAC,cAAc,CAAC;AACnJ;AAEA;;;;;;;AAOG;AACI,MAAM,kBAAkB,GAAG,MAAc;AAC9C,IAAA,MAAM,WAAW,GACf,sBAAsB,CAAC,8BAA8B,CAAC;QACtD,yBAAyB,CAAC,wBAAwB,CAAC;QACnD,yBAAyB,CAAC,sBAAsB,CAAC;AACnD,IAAA,OAAO,WAAW,EAAE,QAAQ,EAAE,KAAK,MAAM;AAC3C;AAEA;;;;;;AAMG;AACH;AACO,MAAM,aAAa,GAAG,CAAC,eAA0B,KAAK,IAAI,CAAC,MAAM,eAAe,CAAC,eAAe,CAAC;;"}
|
|
@@ -14,12 +14,15 @@ var sessionStorageUtils_constants = require('./sessionStorageUtils.constants.cjs
|
|
|
14
14
|
* — check there for the full list before adding a new one.
|
|
15
15
|
*/
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Builds a typed, failure-safe accessor for a single `sessionStorage` key.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* const draft = createSessionStorageItem<Draft>('fd-draft'); draft.set({ title: 'Hi' }); draft.get(); // Draft | null
|
|
20
|
+
*
|
|
21
|
+
* @param key The storage key; register it in `SESSION_STORAGE_KEYS` first.
|
|
22
|
+
* @param options Custom `serialize`/`deserialize` and a `validate` guard; see
|
|
23
|
+
* `SessionStorageItemOptions`.
|
|
24
|
+
* @returns `get`, `set` and `clear` that never throw; `get()` returns `null` when storage is
|
|
25
|
+
* unavailable, while `set()` and `clear()` return `void` and ignore failures.
|
|
23
26
|
*/
|
|
24
27
|
const createSessionStorageItem = (key, options = {}) => webStorage_utils.createWebStorageItem(() => window.sessionStorage, key, options);
|
|
25
28
|
/**
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;;;;;;;;;;AAUG;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;;;;"}
|
|
@@ -27,12 +27,15 @@ export interface SessionStorageItemOptions<T> {
|
|
|
27
27
|
validate?: (value: unknown) => value is T;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Builds a typed, failure-safe accessor for a single `sessionStorage` key.
|
|
31
31
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
32
|
+
* const draft = createSessionStorageItem<Draft>('fd-draft'); draft.set({ title: 'Hi' }); draft.get(); // Draft | null
|
|
33
|
+
*
|
|
34
|
+
* @param key The storage key; register it in `SESSION_STORAGE_KEYS` first.
|
|
35
|
+
* @param options Custom `serialize`/`deserialize` and a `validate` guard; see
|
|
36
|
+
* `SessionStorageItemOptions`.
|
|
37
|
+
* @returns `get`, `set` and `clear` that never throw; `get()` returns `null` when storage is
|
|
38
|
+
* unavailable, while `set()` and `clear()` return `void` and ignore failures.
|
|
36
39
|
*/
|
|
37
40
|
export declare const createSessionStorageItem: <T>(key: string, options?: SessionStorageItemOptions<T>) => SessionStorageItem<T>;
|
|
38
41
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/sessionStorageUtils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAIhC,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,oEAAoE;IACpE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC;CAC3C;AAED
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/sessionStorageUtils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAIhC,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,oEAAoE;IACpE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC;CAC3C;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,GAAI,CAAC,EAAE,KAAK,MAAM,EAAE,UAAS,yBAAyB,CAAC,CAAC,CAAM,KAAG,kBAAkB,CAAC,CAAC,CACzD,CAAC;AAElE;;;GAGG;AACH,eAAO,MAAM,yBAAyB,6BAIpC,CAAC"}
|
|
@@ -12,12 +12,15 @@ import { SESSION_STORAGE_KEYS } from './sessionStorageUtils.constants.js';
|
|
|
12
12
|
* — check there for the full list before adding a new one.
|
|
13
13
|
*/
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Builds a typed, failure-safe accessor for a single `sessionStorage` key.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* const draft = createSessionStorageItem<Draft>('fd-draft'); draft.set({ title: 'Hi' }); draft.get(); // Draft | null
|
|
18
|
+
*
|
|
19
|
+
* @param key The storage key; register it in `SESSION_STORAGE_KEYS` first.
|
|
20
|
+
* @param options Custom `serialize`/`deserialize` and a `validate` guard; see
|
|
21
|
+
* `SessionStorageItemOptions`.
|
|
22
|
+
* @returns `get`, `set` and `clear` that never throw; `get()` returns `null` when storage is
|
|
23
|
+
* unavailable, while `set()` and `clear()` return `void` and ignore failures.
|
|
21
24
|
*/
|
|
22
25
|
const createSessionStorageItem = (key, options = {}) => createWebStorageItem(() => window.sessionStorage, key, options);
|
|
23
26
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/utilities/sessionStorageUtils/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;;;;;;;AASG;AA2BH
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utilities/sessionStorageUtils/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;;;;;;;AASG;AA2BH;;;;;;;;;;AAUG;AACI,MAAM,wBAAwB,GAAG,CAAI,GAAW,EAAE,OAAA,GAAwC,EAAE,KACjG,oBAAoB,CAAC,MAAM,MAAM,CAAC,cAAc,EAAE,GAAG,EAAE,OAAO;AAEhE;;;AAGG;MACU,yBAAyB,GAAG,wBAAwB,CAAU,oBAAoB,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;;"}
|
|
@@ -22,34 +22,68 @@ var React = require('react');
|
|
|
22
22
|
const TEST_ID_PREFIX = 'fd';
|
|
23
23
|
/** Separator placed between hierarchy levels (within a segment, use single `-`). */
|
|
24
24
|
const TEST_ID_SEPARATOR = '--';
|
|
25
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Converts an arbitrary string into a kebab-case, testid-safe segment.
|
|
27
|
+
*
|
|
28
|
+
* @param value A label or id, in any case or punctuation.
|
|
29
|
+
* @returns Lower-case text with runs of non-alphanumerics collapsed to single hyphens.
|
|
30
|
+
*/
|
|
26
31
|
const slugifyTestId = (value) => value
|
|
27
32
|
.toLowerCase()
|
|
28
33
|
.trim()
|
|
29
34
|
.replace(/[^a-z0-9]+/g, '-')
|
|
30
35
|
.replace(/^-+|-+$/g, '');
|
|
31
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Builds a root-level testid, e.g. `rootTestId('sidebar-navigation')` ->
|
|
38
|
+
* `fd-sidebar-navigation`.
|
|
39
|
+
*
|
|
40
|
+
* @param kebabName The component's kebab-case name.
|
|
41
|
+
* @returns The name prefixed with `fd-`.
|
|
42
|
+
*/
|
|
32
43
|
const rootTestId = (kebabName) => `${TEST_ID_PREFIX}-${kebabName}`;
|
|
33
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Appends a child segment to a parent testid, e.g. `joinTestId('fd-x', 'nav-item-orders')` ->
|
|
46
|
+
* `fd-x--nav-item-orders`.
|
|
47
|
+
*
|
|
48
|
+
* @param prefix The ancestor's resolved testid.
|
|
49
|
+
* @param segment The child's own segment, already slugified.
|
|
50
|
+
* @returns The two joined with `--`.
|
|
51
|
+
*/
|
|
34
52
|
const joinTestId = (prefix, segment) => `${prefix}${TEST_ID_SEPARATOR}${segment}`;
|
|
35
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Returns the override when provided, otherwise the fallback (explicit-child case).
|
|
55
|
+
*
|
|
56
|
+
* @param override A consumer-provided `data-testid`, if any.
|
|
57
|
+
* @param fallback The derived default to use without one.
|
|
58
|
+
* @returns Whichever applies.
|
|
59
|
+
*/
|
|
36
60
|
const resolveTestId = (override, fallback) => override ?? fallback;
|
|
37
61
|
/**
|
|
38
|
-
* Spread helper for
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
62
|
+
* Spread helper for a resolved test id: `{ 'data-testid': value }` when present, else an empty
|
|
63
|
+
* object. Centralising it keeps the attribute name in one place so a React Native sibling can
|
|
64
|
+
* map it to `testID`.
|
|
65
|
+
*
|
|
66
|
+
* @param testId The resolved id, or `undefined` to emit nothing.
|
|
67
|
+
* @returns Props to spread onto the rendered element.
|
|
42
68
|
*/
|
|
43
69
|
const testIdProps = (testId) => (testId ? { 'data-testid': testId } : {});
|
|
44
70
|
/** Context carrying the current resolved testid, used as the prefix for descendant components. */
|
|
45
71
|
const TestIdContext = React.createContext(undefined);
|
|
46
72
|
/** Provides a resolved testid as the prefix for descendant library components. */
|
|
47
73
|
const TestIdProvider = TestIdContext.Provider;
|
|
48
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* Reads the testid prefix contributed by an ancestor component.
|
|
76
|
+
*
|
|
77
|
+
* @returns The ancestor's resolved testid, or `undefined` at the root.
|
|
78
|
+
*/
|
|
49
79
|
const useTestIdPrefix = () => React.useContext(TestIdContext);
|
|
50
80
|
/**
|
|
51
|
-
*
|
|
81
|
+
* Resolves a component's testid: an explicit override wins; otherwise derive
|
|
52
82
|
* `<ancestorPrefix>--<segment>` when nested, or `fd-<rootName>` at the root.
|
|
83
|
+
*
|
|
84
|
+
* @param options The consumer `testId` override, the component's `segment`, and its
|
|
85
|
+
* `rootName`.
|
|
86
|
+
* @returns The id to render as `data-testid`.
|
|
53
87
|
*/
|
|
54
88
|
const useResolvedTestId = ({ testId, segment, rootName }) => {
|
|
55
89
|
const prefix = useTestIdPrefix();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/utilities/testIdUtils/index.ts"],"sourcesContent":[null],"names":["createContext","useContext"],"mappings":";;;;AAIA;;;;;;;;;;;;;;;AAeG;AAEH;AACO,MAAM,cAAc,GAAG;AAE9B;AACO,MAAM,iBAAiB,GAAG;AAEjC;
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/utilities/testIdUtils/index.ts"],"sourcesContent":[null],"names":["createContext","useContext"],"mappings":";;;;AAIA;;;;;;;;;;;;;;;AAeG;AAEH;AACO,MAAM,cAAc,GAAG;AAE9B;AACO,MAAM,iBAAiB,GAAG;AAEjC;;;;;AAKG;MACU,aAAa,GAAG,CAAC,KAAa,KACzC;AACG,KAAA,WAAW;AACX,KAAA,IAAI;AACJ,KAAA,OAAO,CAAC,aAAa,EAAE,GAAG;AAC1B,KAAA,OAAO,CAAC,UAAU,EAAE,EAAE;AAE3B;;;;;;AAMG;AACI,MAAM,UAAU,GAAG,CAAC,SAAiB,KAAa,CAAA,EAAG,cAAc,CAAA,CAAA,EAAI,SAAS;AAEvF;;;;;;;AAOG;AACI,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,OAAe,KAAa,GAAG,MAAM,CAAA,EAAG,iBAAiB,CAAA,EAAG,OAAO;AAE9G;;;;;;AAMG;AACI,MAAM,aAAa,GAAG,CAAC,QAA4B,EAAE,QAAgB,KAAa,QAAQ,IAAI;AAErG;;;;;;;AAOG;AACI,MAAM,WAAW,GAAG,CAAC,MAA0B,MAAkC,MAAM,GAAG,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE;AAE/H;MACa,aAAa,GAAGA,mBAAa,CAAqB,SAAS;AAExE;AACO,MAAM,cAAc,GAAG,aAAa,CAAC;AAE5C;;;;AAIG;AACI,MAAM,eAAe,GAAG,MAA0BC,gBAAU,CAAC,aAAa;AAWjF;;;;;;;AAOG;AACI,MAAM,iBAAiB,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAA4B,KAAY;AACnG,IAAA,MAAM,MAAM,GAAG,eAAe,EAAE;IAChC,OAAO,MAAM,KAAK,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;AAChF;;;;;;;;;;;;"}
|