@flipdish/ui-library 0.30.0 → 0.31.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.
- package/dist/components/organisms/SidePanel/components/side-panel-content.cjs +15 -0
- package/dist/components/organisms/SidePanel/components/side-panel-content.cjs.map +1 -0
- package/dist/components/organisms/SidePanel/components/side-panel-content.d.ts +11 -0
- package/dist/components/organisms/SidePanel/components/side-panel-content.d.ts.map +1 -0
- package/dist/components/organisms/SidePanel/components/side-panel-content.js +13 -0
- package/dist/components/organisms/SidePanel/components/side-panel-content.js.map +1 -0
- package/dist/components/organisms/SidePanel/components/side-panel-footer.cjs +15 -0
- package/dist/components/organisms/SidePanel/components/side-panel-footer.cjs.map +1 -0
- package/dist/components/organisms/SidePanel/components/side-panel-footer.d.ts +11 -0
- package/dist/components/organisms/SidePanel/components/side-panel-footer.d.ts.map +1 -0
- package/dist/components/organisms/SidePanel/components/side-panel-footer.js +13 -0
- package/dist/components/organisms/SidePanel/components/side-panel-footer.js.map +1 -0
- package/dist/components/organisms/SidePanel/components/side-panel-header.cjs +19 -0
- package/dist/components/organisms/SidePanel/components/side-panel-header.cjs.map +1 -0
- package/dist/components/organisms/SidePanel/components/side-panel-header.d.ts +15 -0
- package/dist/components/organisms/SidePanel/components/side-panel-header.d.ts.map +1 -0
- package/dist/components/organisms/SidePanel/components/side-panel-header.js +17 -0
- package/dist/components/organisms/SidePanel/components/side-panel-header.js.map +1 -0
- package/dist/components/organisms/SidePanel/components/side-panel-region.cjs +42 -0
- package/dist/components/organisms/SidePanel/components/side-panel-region.cjs.map +1 -0
- package/dist/components/organisms/SidePanel/components/side-panel-region.d.ts +15 -0
- package/dist/components/organisms/SidePanel/components/side-panel-region.d.ts.map +1 -0
- package/dist/components/organisms/SidePanel/components/side-panel-region.js +39 -0
- package/dist/components/organisms/SidePanel/components/side-panel-region.js.map +1 -0
- package/dist/components/organisms/SidePanel/hooks/useOpenOnMount.cjs +29 -0
- package/dist/components/organisms/SidePanel/hooks/useOpenOnMount.cjs.map +1 -0
- package/dist/components/organisms/SidePanel/hooks/useOpenOnMount.d.ts +13 -0
- package/dist/components/organisms/SidePanel/hooks/useOpenOnMount.d.ts.map +1 -0
- package/dist/components/organisms/SidePanel/hooks/useOpenOnMount.js +27 -0
- package/dist/components/organisms/SidePanel/hooks/useOpenOnMount.js.map +1 -0
- package/dist/components/organisms/SidePanel/hooks/usePanelFocus.cjs +76 -0
- package/dist/components/organisms/SidePanel/hooks/usePanelFocus.cjs.map +1 -0
- package/dist/components/organisms/SidePanel/hooks/usePanelFocus.d.ts +22 -0
- package/dist/components/organisms/SidePanel/hooks/usePanelFocus.d.ts.map +1 -0
- package/dist/components/organisms/SidePanel/hooks/usePanelFocus.js +74 -0
- package/dist/components/organisms/SidePanel/hooks/usePanelFocus.js.map +1 -0
- package/dist/components/organisms/SidePanel/index.cjs +51 -0
- package/dist/components/organisms/SidePanel/index.cjs.map +1 -0
- package/dist/components/organisms/SidePanel/index.d.ts +48 -0
- package/dist/components/organisms/SidePanel/index.d.ts.map +1 -0
- package/dist/components/organisms/SidePanel/index.js +49 -0
- package/dist/components/organisms/SidePanel/index.js.map +1 -0
- package/dist/components/organisms/SidePanel/providers/page-cover-context.cjs +12 -0
- package/dist/components/organisms/SidePanel/providers/page-cover-context.cjs.map +1 -0
- package/dist/components/organisms/SidePanel/providers/page-cover-context.d.ts +6 -0
- package/dist/components/organisms/SidePanel/providers/page-cover-context.d.ts.map +1 -0
- package/dist/components/organisms/SidePanel/providers/page-cover-context.js +10 -0
- package/dist/components/organisms/SidePanel/providers/page-cover-context.js.map +1 -0
- package/dist/components/organisms/SidePanel/providers/side-panel-context.cjs +9 -0
- package/dist/components/organisms/SidePanel/providers/side-panel-context.cjs.map +1 -0
- package/dist/components/organisms/SidePanel/providers/side-panel-context.d.ts +8 -0
- package/dist/components/organisms/SidePanel/providers/side-panel-context.d.ts.map +1 -0
- package/dist/components/organisms/SidePanel/providers/side-panel-context.js +7 -0
- package/dist/components/organisms/SidePanel/providers/side-panel-context.js.map +1 -0
- package/dist/components/organisms/SidebarNavigation/components/mobile-header.cjs +1 -1
- package/dist/components/organisms/SidebarNavigation/components/mobile-header.cjs.map +1 -1
- package/dist/components/organisms/SidebarNavigation/components/mobile-header.js +1 -1
- package/dist/components/organisms/SidebarNavigation/components/mobile-header.js.map +1 -1
- package/dist/components/organisms/SlideoutMenu/index.cjs +9 -3
- package/dist/components/organisms/SlideoutMenu/index.cjs.map +1 -1
- package/dist/components/organisms/SlideoutMenu/index.d.ts +1 -1
- package/dist/components/organisms/SlideoutMenu/index.d.ts.map +1 -1
- package/dist/components/organisms/SlideoutMenu/index.js +10 -4
- package/dist/components/organisms/SlideoutMenu/index.js.map +1 -1
- package/dist/components/templates/AppShell/hooks/usePageCover.cjs +24 -0
- package/dist/components/templates/AppShell/hooks/usePageCover.cjs.map +1 -0
- package/dist/components/templates/AppShell/hooks/usePageCover.d.ts +14 -0
- package/dist/components/templates/AppShell/hooks/usePageCover.d.ts.map +1 -0
- package/dist/components/templates/AppShell/hooks/usePageCover.js +22 -0
- package/dist/components/templates/AppShell/hooks/usePageCover.js.map +1 -0
- package/dist/components/templates/AppShell/index.cjs +13 -7
- package/dist/components/templates/AppShell/index.cjs.map +1 -1
- package/dist/components/templates/AppShell/index.d.ts +8 -7
- package/dist/components/templates/AppShell/index.d.ts.map +1 -1
- package/dist/components/templates/AppShell/index.js +13 -7
- package/dist/components/templates/AppShell/index.js.map +1 -1
- package/dist/hooks/useSidePanel/index.cjs +61 -0
- package/dist/hooks/useSidePanel/index.cjs.map +1 -0
- package/dist/hooks/useSidePanel/index.d.ts +31 -0
- package/dist/hooks/useSidePanel/index.d.ts.map +1 -0
- package/dist/hooks/useSidePanel/index.js +59 -0
- package/dist/hooks/useSidePanel/index.js.map +1 -0
- package/dist/native/components/organisms/SidePanel/index.d.ts +12 -0
- package/dist/native/hooks/useSidePanel/index.d.ts +12 -0
- package/dist/utilities/__internal__/focusUtils/focus.utils.cjs +12 -0
- package/dist/utilities/__internal__/focusUtils/focus.utils.cjs.map +1 -0
- package/dist/utilities/__internal__/focusUtils/focus.utils.d.ts +3 -0
- package/dist/utilities/__internal__/focusUtils/focus.utils.d.ts.map +1 -0
- package/dist/utilities/__internal__/focusUtils/focus.utils.js +10 -0
- package/dist/utilities/__internal__/focusUtils/focus.utils.js.map +1 -0
- package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.cjs +3 -0
- package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.cjs.map +1 -1
- package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.d.ts +2 -0
- package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.d.ts.map +1 -1
- package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.js +3 -1
- package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.js.map +1 -1
- package/dist/utilities/localStorageUtils/index.cjs +7 -0
- package/dist/utilities/localStorageUtils/index.cjs.map +1 -1
- package/dist/utilities/localStorageUtils/index.d.ts +2 -0
- package/dist/utilities/localStorageUtils/index.d.ts.map +1 -1
- package/dist/utilities/localStorageUtils/index.js +8 -2
- package/dist/utilities/localStorageUtils/index.js.map +1 -1
- package/dist/utilities/localStorageUtils/localStorageUtils.constants.cjs +2 -0
- package/dist/utilities/localStorageUtils/localStorageUtils.constants.cjs.map +1 -1
- package/dist/utilities/localStorageUtils/localStorageUtils.constants.d.ts +2 -0
- package/dist/utilities/localStorageUtils/localStorageUtils.constants.d.ts.map +1 -1
- package/dist/utilities/localStorageUtils/localStorageUtils.constants.js +2 -0
- package/dist/utilities/localStorageUtils/localStorageUtils.constants.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
3
3
|
import { useResolvedTestId, joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
4
|
+
import { PageCoverContext } from '../../organisms/SidePanel/providers/page-cover-context.js';
|
|
5
|
+
import { usePageCover } from './hooks/usePageCover.js';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Layout-only template for an app shell: navigation beside a content column that stacks the
|
|
7
|
-
* header above the page, with an optional side panel
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* header above the page, with an optional side panel under the header. The shell is exactly the
|
|
10
|
+
* height of the window and the document never scrolls: the page content scrolls in its own area
|
|
11
|
+
* under the header, so the header, navigation and side panel stay in place with no sticky
|
|
12
|
+
* positioning. It holds no state and renders whatever is passed to its slots, so the app keeps
|
|
13
|
+
* ownership of navigation, search and panel state.
|
|
12
14
|
*
|
|
13
15
|
* @summary window-height layout template placing navigation, header, a scrolling page area and a side panel
|
|
14
16
|
*/
|
|
15
17
|
const AppShell = ({ sidebar, header, panel, children, scrollAreaProps, className, 'data-testid': dataTestId }) => {
|
|
16
18
|
const appShellTestId = useResolvedTestId({ testId: dataTestId, segment: 'app-shell', rootName: 'app-shell' });
|
|
19
|
+
// A `SidePanel` in the `panel` slot calls the setter while it covers the page area below `lg`.
|
|
20
|
+
const { scrollAreaRef, setPageCovered } = usePageCover(scrollAreaProps?.ref);
|
|
17
21
|
return (
|
|
18
22
|
// A column below `lg`, so a navigation that renders its own mobile top bar stacks above the content.
|
|
19
|
-
jsxs("div", { "data-testid": appShellTestId, className: cx('flex h-dvh w-full flex-col overflow-hidden bg-primary lg:flex-row', className), children: [sidebar, jsxs("div", { className: "flex min-h-0 min-w-0 flex-1 flex-col", children: [header, jsxs("div", { className: "flex min-h-0 flex-1", children: [jsx("div", { id: scrollAreaProps?.id, ref:
|
|
23
|
+
jsxs("div", { "data-testid": appShellTestId, className: cx('flex h-dvh w-full flex-col overflow-hidden bg-primary lg:flex-row', className), children: [sidebar, jsxs("div", { className: "flex min-h-0 min-w-0 flex-1 flex-col", children: [header, jsxs("div", { className: "relative flex min-h-0 flex-1 overflow-clip", children: [jsx("div", { id: scrollAreaProps?.id, ref: scrollAreaRef, "data-testid": scrollAreaProps?.['data-testid'] ?? joinTestId(appShellTestId, 'scroll-area'),
|
|
20
24
|
// Focusable so keyboard users can scroll a page that has no focusable content of its own (axe: scrollable-region-focusable).
|
|
21
25
|
// biome-ignore lint/a11y/noNoninteractiveTabindex: a scrollable region must be reachable by keyboard
|
|
22
|
-
tabIndex: 0,
|
|
26
|
+
tabIndex: 0,
|
|
27
|
+
// isolate keeps the page's own stacked content (sticky headers) under a panel that covers it.
|
|
28
|
+
className: "isolate flex min-w-0 flex-1 flex-col overflow-y-auto outline-focus-ring focus-visible:outline-2 focus-visible:-outline-offset-2", children: children }), jsx(PageCoverContext.Provider, { value: setPageCovered, children: panel })] })] })] }));
|
|
23
29
|
};
|
|
24
30
|
|
|
25
31
|
export { AppShell };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/templates/AppShell/index.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/templates/AppShell/index.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;;AAsCA;;;;;;;;;AASG;MACU,QAAQ,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAiB,KAAe;AAChJ,IAAA,MAAM,cAAc,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;;AAE7G,IAAA,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,GAAG,YAAY,CAAC,eAAe,EAAE,GAAG,CAAC;IAE5E;;IAEEA,IAAA,CAAA,KAAA,EAAA,EAAA,aAAA,EAAkB,cAAc,EAAE,SAAS,EAAE,EAAE,CAAC,mEAAmE,EAAE,SAAS,CAAC,aAC5H,OAAO,EAGRA,cAAK,SAAS,EAAC,sCAAsC,EAAA,QAAA,EAAA,CAClD,MAAM,EAGPA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,4CAA4C,EAAA,QAAA,EAAA,CACzDC,GAAA,CAAA,KAAA,EAAA,EACE,EAAE,EAAE,eAAe,EAAE,EAAE,EACvB,GAAG,EAAE,aAAa,EAAA,aAAA,EACL,eAAe,GAAG,aAAa,CAAC,IAAI,UAAU,CAAC,cAAc,EAAE,aAAa,CAAC;;;AAG1F,gCAAA,QAAQ,EAAE,CAAC;;gCAEX,SAAS,EAAC,iIAAiI,EAAA,QAAA,EAE1I,QAAQ,GACL,EAENA,GAAA,CAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,cAAc,EAAA,QAAA,EAAG,KAAK,GAA6B,CAAA,EAAA,CACjF,CAAA,EAAA,CACF,CAAA,EAAA,CACF;AAEV;;;;"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var useBreakpoints = require('@flipdish/ui-library/hooks/useBreakpoints');
|
|
4
|
+
var localStorageUtils = require('@flipdish/ui-library/utilities/localStorageUtils');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
const subscribeToNothing = () => () => { };
|
|
8
|
+
const isPersisted = (persist, panel) => persist?.some((id) => id === panel) ?? false;
|
|
9
|
+
/**
|
|
10
|
+
* State for one `SidePanel` slot shared by several panels, such as notifications and an assistant.
|
|
11
|
+
* It holds a single value, so only one panel is ever open, and it can remember chosen panels so they
|
|
12
|
+
* reopen on the next visit. Pass each header button `active === id` and `toggle(id)`, and pass
|
|
13
|
+
* `SidePanel` `isOpen` and `onOpenChange`.
|
|
14
|
+
*
|
|
15
|
+
* @summary one-at-a-time side panel state that can reopen a panel on the next visit
|
|
16
|
+
*/
|
|
17
|
+
const useSidePanel = ({ persist } = {}) => {
|
|
18
|
+
// undefined until the user opens or closes a panel; until then the remembered panel shows.
|
|
19
|
+
const [chosen, setChosen] = React.useState(undefined);
|
|
20
|
+
const isDesktop = useBreakpoints.useBreakpoints('lg');
|
|
21
|
+
// False on the server and while hydrating, so storage is first read once the markup already matches.
|
|
22
|
+
const canReadStorage = React.useSyncExternalStore(subscribeToNothing, () => true, () => false);
|
|
23
|
+
// Read once, on the first render that may: a later resize or a new `persist` array must not reopen a panel.
|
|
24
|
+
const remembered = React.useRef(undefined);
|
|
25
|
+
if (canReadStorage && remembered.current === undefined) {
|
|
26
|
+
const stored = isDesktop ? localStorageUtils.sidePanelStorage.get() : null;
|
|
27
|
+
remembered.current = stored !== null && isPersisted(persist, stored) ? stored : null;
|
|
28
|
+
}
|
|
29
|
+
const active = chosen === undefined ? (remembered.current ?? null) : chosen;
|
|
30
|
+
// The actions read these instead of closing over a render, so a memoised handler and two calls in one tick both see the latest state.
|
|
31
|
+
const latest = React.useRef({ active, persist });
|
|
32
|
+
React.useEffect(() => {
|
|
33
|
+
latest.current = { active, persist };
|
|
34
|
+
});
|
|
35
|
+
const actions = React.useMemo(() => {
|
|
36
|
+
const show = (panel) => {
|
|
37
|
+
latest.current.active = panel;
|
|
38
|
+
setChosen(panel);
|
|
39
|
+
const { persist: persisted } = latest.current;
|
|
40
|
+
if (!persisted?.length)
|
|
41
|
+
return;
|
|
42
|
+
if (panel !== null && isPersisted(persisted, panel))
|
|
43
|
+
localStorageUtils.sidePanelStorage.set(panel);
|
|
44
|
+
else
|
|
45
|
+
localStorageUtils.sidePanelStorage.clear();
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
open: (panel) => show(panel),
|
|
49
|
+
toggle: (panel) => show(latest.current.active === panel ? null : panel),
|
|
50
|
+
close: () => show(null),
|
|
51
|
+
onOpenChange: (isOpen) => {
|
|
52
|
+
if (!isOpen)
|
|
53
|
+
show(null);
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}, []);
|
|
57
|
+
return { active, isOpen: active !== null, ...actions };
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
exports.useSidePanel = useSidePanel;
|
|
61
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/hooks/useSidePanel/index.ts"],"sourcesContent":[null],"names":["useState","useBreakpoints","useSyncExternalStore","useRef","sidePanelStorage","useEffect","useMemo"],"mappings":";;;;;;AA6BA,MAAM,kBAAkB,GAAG,MAAM,MAAK,EAAE,CAAC;AAEzC,MAAM,WAAW,GAAG,CAAmB,OAAiC,EAAE,KAAa,KAAiB,OAAO,EAAE,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC,IAAI,KAAK;AAEpJ;;;;;;;AAOG;AACI,MAAM,YAAY,GAAG,CAAmB,EAAE,OAAO,EAAA,GAA6B,EAAE,KAAuB;;IAE5G,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAGA,cAAQ,CAAuB,SAAS,CAAC;AACrE,IAAA,MAAM,SAAS,GAAGC,6BAAc,CAAC,IAAI,CAAC;;AAEtC,IAAA,MAAM,cAAc,GAAGC,0BAAoB,CACzC,kBAAkB,EAClB,MAAM,IAAI,EACV,MAAM,KAAK,CACZ;;AAGD,IAAA,MAAM,UAAU,GAAGC,YAAM,CAAuB,SAAS,CAAC;IAC1D,IAAI,cAAc,IAAI,UAAU,CAAC,OAAO,KAAK,SAAS,EAAE;AACtD,QAAA,MAAM,MAAM,GAAG,SAAS,GAAGC,kCAAgB,CAAC,GAAG,EAAE,GAAG,IAAI;QACxD,UAAU,CAAC,OAAO,GAAG,MAAM,KAAK,IAAI,IAAI,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI;IACtF;AAEA,IAAA,MAAM,MAAM,GAAG,MAAM,KAAK,SAAS,IAAI,UAAU,CAAC,OAAO,IAAI,IAAI,IAAI,MAAM;;IAG3E,M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|
|
3
|
+
* Panels to reopen on the next visit, remembered in `localStorage`. A remembered panel reopens from
|
|
4
|
+
* `lg` only, since below it the panel would cover the page on load. Leave out to remember nothing.
|
|
5
|
+
*/
|
|
6
|
+
persist?: readonly T[];
|
|
7
|
+
}
|
|
8
|
+
export interface SidePanelState<T extends string> {
|
|
9
|
+
/** The open panel, or `null` when none is open. */
|
|
10
|
+
active: T | null;
|
|
11
|
+
/** Whether any panel is open. Pass it to `SidePanel`'s `isOpen`. */
|
|
12
|
+
isOpen: boolean;
|
|
13
|
+
/** Opens a panel, replacing the one that is open. */
|
|
14
|
+
open: (panel: T) => void;
|
|
15
|
+
/** Opens a panel, or closes it when it is the one already open. Use it for a header button. */
|
|
16
|
+
toggle: (panel: T) => void;
|
|
17
|
+
/** Closes whichever panel is open. */
|
|
18
|
+
close: () => void;
|
|
19
|
+
/** Closes the panel when called with `false`. Pass it to `SidePanel`'s `onOpenChange`. */
|
|
20
|
+
onOpenChange: (isOpen: boolean) => void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* State for one `SidePanel` slot shared by several panels, such as notifications and an assistant.
|
|
24
|
+
* It holds a single value, so only one panel is ever open, and it can remember chosen panels so they
|
|
25
|
+
* reopen on the next visit. Pass each header button `active === id` and `toggle(id)`, and pass
|
|
26
|
+
* `SidePanel` `isOpen` and `onOpenChange`.
|
|
27
|
+
*
|
|
28
|
+
* @summary one-at-a-time side panel state that can reopen a panel on the next visit
|
|
29
|
+
*/
|
|
30
|
+
export declare const useSidePanel: <T extends string>({ persist }?: UseSidePanelOptions<T>) => SidePanelState<T>;
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSidePanel/index.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,MAAM;IACnD;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,MAAM;IAC9C,mDAAmD;IACnD,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC;IACjB,oEAAoE;IACpE,MAAM,EAAE,OAAO,CAAC;IAChB,qDAAqD;IACrD,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IACzB,+FAA+F;IAC/F,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC3B,sCAAsC;IACtC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,0FAA0F;IAC1F,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC;AAMD;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,MAAM,EAAE,cAAa,mBAAmB,CAAC,CAAC,CAAM,KAAG,cAAc,CAAC,CAAC,CA+CzG,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useBreakpoints } from '@flipdish/ui-library/hooks/useBreakpoints';
|
|
2
|
+
import { sidePanelStorage } from '@flipdish/ui-library/utilities/localStorageUtils';
|
|
3
|
+
import { useState, useSyncExternalStore, useRef, useEffect, useMemo } from 'react';
|
|
4
|
+
|
|
5
|
+
const subscribeToNothing = () => () => { };
|
|
6
|
+
const isPersisted = (persist, panel) => persist?.some((id) => id === panel) ?? false;
|
|
7
|
+
/**
|
|
8
|
+
* State for one `SidePanel` slot shared by several panels, such as notifications and an assistant.
|
|
9
|
+
* It holds a single value, so only one panel is ever open, and it can remember chosen panels so they
|
|
10
|
+
* reopen on the next visit. Pass each header button `active === id` and `toggle(id)`, and pass
|
|
11
|
+
* `SidePanel` `isOpen` and `onOpenChange`.
|
|
12
|
+
*
|
|
13
|
+
* @summary one-at-a-time side panel state that can reopen a panel on the next visit
|
|
14
|
+
*/
|
|
15
|
+
const useSidePanel = ({ persist } = {}) => {
|
|
16
|
+
// undefined until the user opens or closes a panel; until then the remembered panel shows.
|
|
17
|
+
const [chosen, setChosen] = useState(undefined);
|
|
18
|
+
const isDesktop = useBreakpoints('lg');
|
|
19
|
+
// False on the server and while hydrating, so storage is first read once the markup already matches.
|
|
20
|
+
const canReadStorage = useSyncExternalStore(subscribeToNothing, () => true, () => false);
|
|
21
|
+
// Read once, on the first render that may: a later resize or a new `persist` array must not reopen a panel.
|
|
22
|
+
const remembered = useRef(undefined);
|
|
23
|
+
if (canReadStorage && remembered.current === undefined) {
|
|
24
|
+
const stored = isDesktop ? sidePanelStorage.get() : null;
|
|
25
|
+
remembered.current = stored !== null && isPersisted(persist, stored) ? stored : null;
|
|
26
|
+
}
|
|
27
|
+
const active = chosen === undefined ? (remembered.current ?? null) : chosen;
|
|
28
|
+
// The actions read these instead of closing over a render, so a memoised handler and two calls in one tick both see the latest state.
|
|
29
|
+
const latest = useRef({ active, persist });
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
latest.current = { active, persist };
|
|
32
|
+
});
|
|
33
|
+
const actions = useMemo(() => {
|
|
34
|
+
const show = (panel) => {
|
|
35
|
+
latest.current.active = panel;
|
|
36
|
+
setChosen(panel);
|
|
37
|
+
const { persist: persisted } = latest.current;
|
|
38
|
+
if (!persisted?.length)
|
|
39
|
+
return;
|
|
40
|
+
if (panel !== null && isPersisted(persisted, panel))
|
|
41
|
+
sidePanelStorage.set(panel);
|
|
42
|
+
else
|
|
43
|
+
sidePanelStorage.clear();
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
open: (panel) => show(panel),
|
|
47
|
+
toggle: (panel) => show(latest.current.active === panel ? null : panel),
|
|
48
|
+
close: () => show(null),
|
|
49
|
+
onOpenChange: (isOpen) => {
|
|
50
|
+
if (!isOpen)
|
|
51
|
+
show(null);
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}, []);
|
|
55
|
+
return { active, isOpen: active !== null, ...actions };
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export { useSidePanel };
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/hooks/useSidePanel/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AA6BA,MAAM,kBAAkB,GAAG,MAAM,MAAK,EAAE,CAAC;AAEzC,MAAM,WAAW,GAAG,CAAmB,OAAiC,EAAE,KAAa,KAAiB,OAAO,EAAE,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC,IAAI,KAAK;AAEpJ;;;;;;;AAOG;AACI,MAAM,YAAY,GAAG,CAAmB,EAAE,OAAO,EAAA,GAA6B,EAAE,KAAuB;;IAE5G,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAuB,SAAS,CAAC;AACrE,IAAA,MAAM,SAAS,GAAG,cAAc,CAAC,IAAI,CAAC;;AAEtC,IAAA,MAAM,cAAc,GAAG,oBAAoB,CACzC,kBAAkB,EAClB,MAAM,IAAI,EACV,MAAM,KAAK,CACZ;;AAGD,IAAA,MAAM,UAAU,GAAG,MAAM,CAAuB,SAAS,CAAC;IAC1D,IAAI,cAAc,IAAI,UAAU,CAAC,OAAO,KAAK,SAAS,EAAE;AACtD,QAAA,MAAM,MAAM,GAAG,SAAS,GAAG,gBAAgB,CAAC,GAAG,EAAE,GAAG,IAAI;QACxD,UAAU,CAAC,OAAO,GAAG,MAAM,KAAK,IAAI,IAAI,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI;IACtF;AAEA,IAAA,MAAM,MAAM,GAAG,MAAM,KAAK,SAAS,IAAI,UAAU,CAAC,OAAO,IAAI,IAAI,IAAI,MAAM;;IAG3E,MAAM,MAAM,GAAG,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAC1C,SAAS,CAAC,MAAK;QACb,MAAM,CAAC,OAAO,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE;AACtC,IAAA,CAAC,CAAC;AAEF,IAAA,MAAM,OAAO,GAAG,OAAO,CAAwE,MAAK;AAClG,QAAA,MAAM,IAAI,GAAG,CAAC,KAAe,KAAI;AAC/B,YAAA,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK;YAC7B,SAAS,CAAC,KAAK,CAAC;YAChB,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,OAAO;YAC7C,IAAI,CAAC,SAAS,EAAE,MAAM;gBAAE;YACxB,IAAI,KAAK,KAAK,IAAI,IAAI,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC;AAAE,gBAAA,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC;;gBAC3E,gBAAgB,CAAC,KAAK,EAAE;AAC/B,QAAA,CAAC;QAED,OAAO;YACL,IAAI,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC;YAC5B,MAAM,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC;AACvE,YAAA,KAAK,EAAE,MAAM,IAAI,CAAC,IAAI,CAAC;AACvB,YAAA,YAAY,EAAE,CAAC,MAAM,KAAI;AACvB,gBAAA,IAAI,CAAC,MAAM;oBAAE,IAAI,CAAC,IAAI,CAAC;YACzB,CAAC;SACF;IACH,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,EAAE,GAAG,OAAO,EAAE;AACxD;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `SidePanel` has no React Native implementation.
|
|
3
|
+
*
|
|
4
|
+
* This is a generated types-only stub (scripts/emit-native-stubs.mjs). It exists so
|
|
5
|
+
* that importing `@flipdish/ui-library/components/organisms/SidePanel` from React Native fails at
|
|
6
|
+
* compile time rather than resolving to the web build's types. There is no
|
|
7
|
+
* matching `index.js`, so Metro cannot bundle this module either.
|
|
8
|
+
*
|
|
9
|
+
* To make `SidePanel` available on React Native, add an `index.native.tsx` beside
|
|
10
|
+
* its `index.tsx` — the build picks it up automatically and this stub disappears.
|
|
11
|
+
*/
|
|
12
|
+
export declare const __NO_REACT_NATIVE_IMPLEMENTATION__: never;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `useSidePanel` has no React Native implementation.
|
|
3
|
+
*
|
|
4
|
+
* This is a generated types-only stub (scripts/emit-native-stubs.mjs). It exists so
|
|
5
|
+
* that importing `@flipdish/ui-library/hooks/useSidePanel` from React Native fails at
|
|
6
|
+
* compile time rather than resolving to the web build's types. There is no
|
|
7
|
+
* matching `index.js`, so Metro cannot bundle this module either.
|
|
8
|
+
*
|
|
9
|
+
* To make `useSidePanel` available on React Native, add an `index.native.tsx` beside
|
|
10
|
+
* its `index.tsx` — the build picks it up automatically and this stub disappears.
|
|
11
|
+
*/
|
|
12
|
+
export declare const __NO_REACT_NATIVE_IMPLEMENTATION__: never;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/** The element that has keyboard focus, or `null` on the server and when focus rests on the page itself. */
|
|
4
|
+
const getFocusedElement = () => {
|
|
5
|
+
if (typeof document === 'undefined')
|
|
6
|
+
return null;
|
|
7
|
+
const { activeElement } = document;
|
|
8
|
+
return activeElement instanceof HTMLElement && activeElement !== document.body ? activeElement : null;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
exports.getFocusedElement = getFocusedElement;
|
|
12
|
+
//# sourceMappingURL=focus.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus.utils.cjs","sources":["../../../../src/utilities/__internal__/focusUtils/focus.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACO,MAAM,iBAAiB,GAAG,MAAyB;IACxD,IAAI,OAAO,QAAQ,KAAK,WAAW;AAAE,QAAA,OAAO,IAAI;AAChD,IAAA,MAAM,EAAE,aAAa,EAAE,GAAG,QAAQ;AAElC,IAAA,OAAO,aAAa,YAAY,WAAW,IAAI,aAAa,KAAK,QAAQ,CAAC,IAAI,GAAG,aAAa,GAAG,IAAI;AACvG;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus.utils.d.ts","sourceRoot":"","sources":["../../../../src/utilities/__internal__/focusUtils/focus.utils.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,eAAO,MAAM,iBAAiB,QAAO,WAAW,GAAG,IAKlD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The element that has keyboard focus, or `null` on the server and when focus rests on the page itself. */
|
|
2
|
+
const getFocusedElement = () => {
|
|
3
|
+
if (typeof document === 'undefined')
|
|
4
|
+
return null;
|
|
5
|
+
const { activeElement } = document;
|
|
6
|
+
return activeElement instanceof HTMLElement && activeElement !== document.body ? activeElement : null;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { getFocusedElement };
|
|
10
|
+
//# sourceMappingURL=focus.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus.utils.js","sources":["../../../../src/utilities/__internal__/focusUtils/focus.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACO,MAAM,iBAAiB,GAAG,MAAyB;IACxD,IAAI,OAAO,QAAQ,KAAK,WAAW;AAAE,QAAA,OAAO,IAAI;AAChD,IAAA,MAAM,EAAE,aAAa,EAAE,GAAG,QAAQ;AAElC,IAAA,OAAO,aAAa,YAAY,WAAW,IAAI,aAAa,KAAK,QAAQ,CAAC,IAAI,GAAG,aAAa,GAAG,IAAI;AACvG;;;;"}
|
|
@@ -45,6 +45,8 @@ const safeRemove = (getStorage, key) => {
|
|
|
45
45
|
};
|
|
46
46
|
/** Reusable `validate` guard for a boolean item. */
|
|
47
47
|
const isBoolean = (value) => typeof value === 'boolean';
|
|
48
|
+
/** Reusable `validate` guard for a string item. */
|
|
49
|
+
const isString = (value) => typeof value === 'string';
|
|
48
50
|
/**
|
|
49
51
|
* Parse a plain `'true'`/`'false'` string (not JSON) into a boolean; throws
|
|
50
52
|
* `errorMessage` for anything else so `WebStorageItem.get()` treats it as
|
|
@@ -98,5 +100,6 @@ const createWebStorageItem = (getStorage, key, options = {}) => {
|
|
|
98
100
|
|
|
99
101
|
exports.createWebStorageItem = createWebStorageItem;
|
|
100
102
|
exports.isBoolean = isBoolean;
|
|
103
|
+
exports.isString = isString;
|
|
101
104
|
exports.parseBooleanString = parseBooleanString;
|
|
102
105
|
//# sourceMappingURL=webStorage.utils.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webStorage.utils.cjs","sources":["../../../../src/utilities/__internal__/webStorageUtils/webStorage.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;;;;AAUG;AAKH,MAAM,OAAO,GAAG,CAAC,UAA2B,EAAE,GAAW,KAAmB;IAC1E,IAAI,OAAO,MAAM,KAAK,WAAW;AAAE,QAAA,OAAO,IAAI;AAC9C,IAAA,IAAI;AACF,QAAA,OAAO,UAAU,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;IAClC;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,IAAI;IACb;AACF,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,UAA2B,EAAE,GAAW,EAAE,KAAa,KAAa;IACnF,IAAI,OAAO,MAAM,KAAK,WAAW;AAAE,QAAA,OAAO,KAAK;AAC/C,IAAA,IAAI;QACF,UAAU,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC;AAChC,QAAA,OAAO,IAAI;IACb;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;IACd;AACF,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,UAA2B,EAAE,GAAW,KAAa;IACvE,IAAI,OAAO,MAAM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O,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
|
|
1
|
+
{"version":3,"file":"webStorage.utils.cjs","sources":["../../../../src/utilities/__internal__/webStorageUtils/webStorage.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;;;;AAUG;AAKH,MAAM,OAAO,GAAG,CAAC,UAA2B,EAAE,GAAW,KAAmB;IAC1E,IAAI,OAAO,MAAM,KAAK,WAAW;AAAE,QAAA,OAAO,IAAI;AAC9C,IAAA,IAAI;AACF,QAAA,OAAO,UAAU,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;IAClC;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,IAAI;IACb;AACF,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,UAA2B,EAAE,GAAW,EAAE,KAAa,KAAa;IACnF,IAAI,OAAO,MAAM,KAAK,WAAW;AAAE,QAAA,OAAO,KAAK;AAC/C,IAAA,IAAI;QACF,UAAU,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC;AAChC,QAAA,OAAO,IAAI;IACb;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;IACd;AACF,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,UAA2B,EAAE,GAAW,KAAa;IACvE,IAAI,OAAO,MAAM,KAAK,WAAW;AAAE,QAAA,OAAO,KAAK;AAC/C,IAAA,IAAI;AACF,QAAA,UAAU,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC;AAC5B,QAAA,OAAO,IAAI;IACb;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;IACd;AACF,CAAC;AAoBD;AACO,MAAM,SAAS,GAAG,CAAC,KAAc,KAAuB,OAAO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AE,GAAG,CAAC;QAC7B,CAAC;KACF;AACH;;;;;;;"}
|
|
@@ -29,6 +29,8 @@ export interface WebStorageItemOptions<T> {
|
|
|
29
29
|
}
|
|
30
30
|
/** Reusable `validate` guard for a boolean item. */
|
|
31
31
|
export declare const isBoolean: (value: unknown) => value is boolean;
|
|
32
|
+
/** Reusable `validate` guard for a string item. */
|
|
33
|
+
export declare const isString: (value: unknown) => value is string;
|
|
32
34
|
/**
|
|
33
35
|
* Parse a plain `'true'`/`'false'` string (not JSON) into a boolean; throws
|
|
34
36
|
* `errorMessage` for anything else so `WebStorageItem.get()` treats it as
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webStorage.utils.d.ts","sourceRoot":"","sources":["../../../../src/utilities/__internal__/webStorageUtils/webStorage.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,qFAAqF;AACrF,KAAK,eAAe,GAAG,MAAM,OAAO,CAAC;AA+BrC,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,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,qBAAqB,CAAC,CAAC;IACtC,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,oDAAoD;AACpD,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,OAAqC,CAAC;AAE1F;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,MAAM,EAAE,cAAc,MAAM,KAAG,OAItE,CAAC;AAEF,kFAAkF;AAClF,eAAO,MAAM,oBAAoB,GAAI,CAAC,EAAE,YAAY,eAAe,EAAE,KAAK,MAAM,EAAE,UAAS,qBAAqB,CAAC,CAAC,CAAM,KAAG,cAAc,CAAC,CAAC,CAgC1I,CAAC"}
|
|
1
|
+
{"version":3,"file":"webStorage.utils.d.ts","sourceRoot":"","sources":["../../../../src/utilities/__internal__/webStorageUtils/webStorage.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,qFAAqF;AACrF,KAAK,eAAe,GAAG,MAAM,OAAO,CAAC;AA+BrC,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,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,qBAAqB,CAAC,CAAC;IACtC,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,oDAAoD;AACpD,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,OAAqC,CAAC;AAE1F,mDAAmD;AACnD,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAAmC,CAAC;AAEvF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,MAAM,EAAE,cAAc,MAAM,KAAG,OAItE,CAAC;AAEF,kFAAkF;AAClF,eAAO,MAAM,oBAAoB,GAAI,CAAC,EAAE,YAAY,eAAe,EAAE,KAAK,MAAM,EAAE,UAAS,qBAAqB,CAAC,CAAC,CAAM,KAAG,cAAc,CAAC,CAAC,CAgC1I,CAAC"}
|
|
@@ -43,6 +43,8 @@ const safeRemove = (getStorage, key) => {
|
|
|
43
43
|
};
|
|
44
44
|
/** Reusable `validate` guard for a boolean item. */
|
|
45
45
|
const isBoolean = (value) => typeof value === 'boolean';
|
|
46
|
+
/** Reusable `validate` guard for a string item. */
|
|
47
|
+
const isString = (value) => typeof value === 'string';
|
|
46
48
|
/**
|
|
47
49
|
* Parse a plain `'true'`/`'false'` string (not JSON) into a boolean; throws
|
|
48
50
|
* `errorMessage` for anything else so `WebStorageItem.get()` treats it as
|
|
@@ -94,5 +96,5 @@ const createWebStorageItem = (getStorage, key, options = {}) => {
|
|
|
94
96
|
};
|
|
95
97
|
};
|
|
96
98
|
|
|
97
|
-
export { createWebStorageItem, isBoolean, parseBooleanString };
|
|
99
|
+
export { createWebStorageItem, isBoolean, isString, parseBooleanString };
|
|
98
100
|
//# sourceMappingURL=webStorage.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webStorage.utils.js","sources":["../../../../src/utilities/__internal__/webStorageUtils/webStorage.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;AAUG;AAKH,MAAM,OAAO,GAAG,CAAC,UAA2B,EAAE,GAAW,KAAmB;IAC1E,IAAI,OAAO,MAAM,KAAK,WAAW;AAAE,QAAA,OAAO,IAAI;AAC9C,IAAA,IAAI;AACF,QAAA,OAAO,UAAU,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;IAClC;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,IAAI;IACb;AACF,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,UAA2B,EAAE,GAAW,EAAE,KAAa,KAAa;IACnF,IAAI,OAAO,MAAM,KAAK,WAAW;AAAE,QAAA,OAAO,KAA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C;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;;;;"}
|
|
1
|
+
{"version":3,"file":"webStorage.utils.js","sources":["../../../../src/utilities/__internal__/webStorageUtils/webStorage.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;AAUG;AAKH,MAAM,OAAO,GAAG,CAAC,UAA2B,EAAE,GAAW,KAAmB;IAC1E,IAAI,OAAO,MAAM,KAAK,WAAW;AAAE,QAAA,OAAO,IAAI;AAC9C,IAAA,IAAI;AACF,QAAA,OAAO,UAAU,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;IAClC;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,IAAI;IACb;AACF,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,UAA2B,EAAE,GAAW,EAAE,KAAa,KAAa;IACnF,IAAI,OAAO,MAAM,KAAK,WAAW;AAAE,QAAA,OAAO,KAAK;AAC/C,IAAA,IAAI;QACF,UAAU,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC;AAChC,QAAA,OAAO,IAAI;IACb;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;IACd;AACF,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,UAA2B,EAAE,GAAW,KAAa;IACvE,IAAI,OAAO,MAAM,KA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A,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,15 @@ const sidebarCollapsedStorage = createLocalStorageItem(localStorageUtils_constan
|
|
|
31
31
|
deserialize: (raw) => webStorage_utils.parseBooleanString(raw, 'Invalid sidebar collapsed value'),
|
|
32
32
|
validate: webStorage_utils.isBoolean,
|
|
33
33
|
});
|
|
34
|
+
/** Persistence for the panel `useSidePanel` reopens on the next visit. Stored as the bare panel id. */
|
|
35
|
+
const sidePanelStorage = createLocalStorageItem(localStorageUtils_constants.LOCAL_STORAGE_KEYS.sidePanel, {
|
|
36
|
+
serialize: String,
|
|
37
|
+
deserialize: (raw) => raw,
|
|
38
|
+
validate: webStorage_utils.isString,
|
|
39
|
+
});
|
|
34
40
|
|
|
35
41
|
exports.LOCAL_STORAGE_KEYS = localStorageUtils_constants.LOCAL_STORAGE_KEYS;
|
|
36
42
|
exports.createLocalStorageItem = createLocalStorageItem;
|
|
43
|
+
exports.sidePanelStorage = sidePanelStorage;
|
|
37
44
|
exports.sidebarCollapsedStorage = sidebarCollapsedStorage;
|
|
38
45
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
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
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/utilities/localStorageUtils/index.ts"],"sourcesContent":[null],"names":["createWebStorageItem","LOCAL_STORAGE_KEYS","parseBooleanString","isBoolean","isString"],"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;AAED;MACa,gBAAgB,GAAG,sBAAsB,CAASF,8CAAkB,CAAC,SAAS,EAAE;AAC3F,IAAA,SAAS,EAAE,MAAM;AACjB,IAAA,WAAW,EAAE,CAAC,GAAG,KAAK,GAAG;AACzB,IAAA,QAAQ,EAAEG,yBAAQ;AACnB,CAAA;;;;;;;"}
|
|
@@ -40,4 +40,6 @@ export declare const createLocalStorageItem: <T>(key: string, options?: LocalSto
|
|
|
40
40
|
* plain strings `'true'` / `'false'` to preserve the original on-disk format.
|
|
41
41
|
*/
|
|
42
42
|
export declare const sidebarCollapsedStorage: LocalStorageItem<boolean>;
|
|
43
|
+
/** Persistence for the panel `useSidePanel` reopens on the next visit. Stored as the bare panel id. */
|
|
44
|
+
export declare const sidePanelStorage: LocalStorageItem<string>;
|
|
43
45
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/localStorageUtils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAI9B,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,oEAAoE;IACpE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC;CAC3C;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GAAI,CAAC,EAAE,KAAK,MAAM,EAAE,UAAS,uBAAuB,CAAC,CAAC,CAAM,KAAG,gBAAgB,CAAC,CAAC,CACrD,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,2BAIlC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/localStorageUtils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAI9B,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,oEAAoE;IACpE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC;CAC3C;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GAAI,CAAC,EAAE,KAAK,MAAM,EAAE,UAAS,uBAAuB,CAAC,CAAC,CAAM,KAAG,gBAAgB,CAAC,CAAC,CACrD,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,2BAIlC,CAAC;AAEH,uGAAuG;AACvG,eAAO,MAAM,gBAAgB,0BAI3B,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createWebStorageItem, isBoolean, parseBooleanString } from '../__internal__/webStorageUtils/webStorage.utils.js';
|
|
1
|
+
import { createWebStorageItem, isBoolean, parseBooleanString, isString } from '../__internal__/webStorageUtils/webStorage.utils.js';
|
|
2
2
|
import { LOCAL_STORAGE_KEYS } from './localStorageUtils.constants.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -29,6 +29,12 @@ const sidebarCollapsedStorage = createLocalStorageItem(LOCAL_STORAGE_KEYS.sideba
|
|
|
29
29
|
deserialize: (raw) => parseBooleanString(raw, 'Invalid sidebar collapsed value'),
|
|
30
30
|
validate: isBoolean,
|
|
31
31
|
});
|
|
32
|
+
/** Persistence for the panel `useSidePanel` reopens on the next visit. Stored as the bare panel id. */
|
|
33
|
+
const sidePanelStorage = createLocalStorageItem(LOCAL_STORAGE_KEYS.sidePanel, {
|
|
34
|
+
serialize: String,
|
|
35
|
+
deserialize: (raw) => raw,
|
|
36
|
+
validate: isString,
|
|
37
|
+
});
|
|
32
38
|
|
|
33
|
-
export { LOCAL_STORAGE_KEYS, createLocalStorageItem, sidebarCollapsedStorage };
|
|
39
|
+
export { LOCAL_STORAGE_KEYS, createLocalStorageItem, sidePanelStorage, sidebarCollapsedStorage };
|
|
34
40
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/utilities/localStorageUtils/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;;;;;;;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
|
+
{"version":3,"file":"index.js","sources":["../../../src/utilities/localStorageUtils/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;;;;;;;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;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;;;;"}
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
const LOCAL_STORAGE_KEYS = {
|
|
10
10
|
/** `SidebarNavigation` collapsed/expanded preference. */
|
|
11
11
|
sidebarCollapsed: 'fd-sidebar-collapsed',
|
|
12
|
+
/** The side panel `useSidePanel` reopens on the next visit. */
|
|
13
|
+
sidePanel: 'fd-side-panel',
|
|
12
14
|
};
|
|
13
15
|
|
|
14
16
|
exports.LOCAL_STORAGE_KEYS = LOCAL_STORAGE_KEYS;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localStorageUtils.constants.cjs","sources":["../../../src/utilities/localStorageUtils/localStorageUtils.constants.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;AAKG;AACI,MAAM,kBAAkB,GAAG;;AAEhC,IAAA,gBAAgB,EAAE,sBAAsB;;;;;"}
|
|
1
|
+
{"version":3,"file":"localStorageUtils.constants.cjs","sources":["../../../src/utilities/localStorageUtils/localStorageUtils.constants.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;AAKG;AACI,MAAM,kBAAkB,GAAG;;AAEhC,IAAA,gBAAgB,EAAE,sBAAsB;;AAExC,IAAA,SAAS,EAAE,eAAe;;;;;"}
|
|
@@ -7,5 +7,7 @@
|
|
|
7
7
|
export declare const LOCAL_STORAGE_KEYS: {
|
|
8
8
|
/** `SidebarNavigation` collapsed/expanded preference. */
|
|
9
9
|
readonly sidebarCollapsed: "fd-sidebar-collapsed";
|
|
10
|
+
/** The side panel `useSidePanel` reopens on the next visit. */
|
|
11
|
+
readonly sidePanel: "fd-side-panel";
|
|
10
12
|
};
|
|
11
13
|
//# sourceMappingURL=localStorageUtils.constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localStorageUtils.constants.d.ts","sourceRoot":"","sources":["../../../src/utilities/localStorageUtils/localStorageUtils.constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;IAC7B,yDAAyD;;
|
|
1
|
+
{"version":3,"file":"localStorageUtils.constants.d.ts","sourceRoot":"","sources":["../../../src/utilities/localStorageUtils/localStorageUtils.constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;IAC7B,yDAAyD;;IAEzD,+DAA+D;;CAEvD,CAAC"}
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
const LOCAL_STORAGE_KEYS = {
|
|
8
8
|
/** `SidebarNavigation` collapsed/expanded preference. */
|
|
9
9
|
sidebarCollapsed: 'fd-sidebar-collapsed',
|
|
10
|
+
/** The side panel `useSidePanel` reopens on the next visit. */
|
|
11
|
+
sidePanel: 'fd-side-panel',
|
|
10
12
|
};
|
|
11
13
|
|
|
12
14
|
export { LOCAL_STORAGE_KEYS };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localStorageUtils.constants.js","sources":["../../../src/utilities/localStorageUtils/localStorageUtils.constants.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;AAKG;AACI,MAAM,kBAAkB,GAAG;;AAEhC,IAAA,gBAAgB,EAAE,sBAAsB;;;;;"}
|
|
1
|
+
{"version":3,"file":"localStorageUtils.constants.js","sources":["../../../src/utilities/localStorageUtils/localStorageUtils.constants.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;AAKG;AACI,MAAM,kBAAkB,GAAG;;AAEhC,IAAA,gBAAgB,EAAE,sBAAsB;;AAExC,IAAA,SAAS,EAAE,eAAe;;;;;"}
|