@flipdish/ui-library 0.29.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/atoms/Input/index.cjs +3 -1
- package/dist/components/atoms/Input/index.cjs.map +1 -1
- package/dist/components/atoms/Input/index.d.ts +5 -1
- package/dist/components/atoms/Input/index.d.ts.map +1 -1
- package/dist/components/atoms/Input/index.js +3 -1
- package/dist/components/atoms/Input/index.js.map +1 -1
- package/dist/components/molecules/Select/components/combobox.cjs +3 -1
- package/dist/components/molecules/Select/components/combobox.cjs.map +1 -1
- package/dist/components/molecules/Select/components/combobox.d.ts.map +1 -1
- package/dist/components/molecules/Select/components/combobox.js +3 -1
- package/dist/components/molecules/Select/components/combobox.js.map +1 -1
- package/dist/components/organisms/ApplicationHeader/applicationHeader.types.d.ts +12 -5
- package/dist/components/organisms/ApplicationHeader/applicationHeader.types.d.ts.map +1 -1
- package/dist/components/organisms/ApplicationHeader/index.cjs +12 -17
- package/dist/components/organisms/ApplicationHeader/index.cjs.map +1 -1
- package/dist/components/organisms/ApplicationHeader/index.d.ts +9 -5
- package/dist/components/organisms/ApplicationHeader/index.d.ts.map +1 -1
- package/dist/components/organisms/ApplicationHeader/index.js +12 -18
- package/dist/components/organisms/ApplicationHeader/index.js.map +1 -1
- package/dist/components/organisms/Calendar/index.cjs +3 -3
- package/dist/components/organisms/Calendar/index.cjs.map +1 -1
- package/dist/components/organisms/Calendar/index.js +3 -3
- package/dist/components/organisms/Calendar/index.js.map +1 -1
- package/dist/components/organisms/CommandMenu/commandMenu.utils.cjs +0 -21
- package/dist/components/organisms/CommandMenu/commandMenu.utils.cjs.map +1 -1
- package/dist/components/organisms/CommandMenu/commandMenu.utils.d.ts +0 -9
- package/dist/components/organisms/CommandMenu/commandMenu.utils.d.ts.map +1 -1
- package/dist/components/organisms/CommandMenu/commandMenu.utils.js +1 -21
- package/dist/components/organisms/CommandMenu/commandMenu.utils.js.map +1 -1
- package/dist/components/organisms/CommandMenu/components/command-input.cjs +2 -2
- package/dist/components/organisms/CommandMenu/components/command-input.cjs.map +1 -1
- package/dist/components/organisms/CommandMenu/components/command-input.d.ts +3 -2
- package/dist/components/organisms/CommandMenu/components/command-input.d.ts.map +1 -1
- package/dist/components/organisms/CommandMenu/components/command-input.js +2 -2
- package/dist/components/organisms/CommandMenu/components/command-input.js.map +1 -1
- package/dist/components/organisms/CommandMenu/components/command-menu-item.cjs +15 -2
- package/dist/components/organisms/CommandMenu/components/command-menu-item.cjs.map +1 -1
- package/dist/components/organisms/CommandMenu/components/command-menu-item.d.ts +9 -1
- package/dist/components/organisms/CommandMenu/components/command-menu-item.d.ts.map +1 -1
- package/dist/components/organisms/CommandMenu/components/command-menu-item.js +15 -2
- package/dist/components/organisms/CommandMenu/components/command-menu-item.js.map +1 -1
- package/dist/components/organisms/CommandMenu/components/command-shortcut.cjs +2 -2
- package/dist/components/organisms/CommandMenu/components/command-shortcut.cjs.map +1 -1
- package/dist/components/organisms/CommandMenu/components/command-shortcut.d.ts +1 -0
- package/dist/components/organisms/CommandMenu/components/command-shortcut.d.ts.map +1 -1
- package/dist/components/organisms/CommandMenu/components/command-shortcut.js +2 -2
- package/dist/components/organisms/CommandMenu/components/command-shortcut.js.map +1 -1
- package/dist/components/organisms/CommandMenu/index.cjs +65 -29
- package/dist/components/organisms/CommandMenu/index.cjs.map +1 -1
- package/dist/components/organisms/CommandMenu/index.d.ts +29 -2
- package/dist/components/organisms/CommandMenu/index.d.ts.map +1 -1
- package/dist/components/organisms/CommandMenu/index.js +69 -33
- package/dist/components/organisms/CommandMenu/index.js.map +1 -1
- package/dist/components/organisms/CommandMenu/providers/command-menu-link-context.cjs +9 -0
- package/dist/components/organisms/CommandMenu/providers/command-menu-link-context.cjs.map +1 -0
- package/dist/components/organisms/CommandMenu/providers/command-menu-link-context.d.ts +3 -0
- package/dist/components/organisms/CommandMenu/providers/command-menu-link-context.d.ts.map +1 -0
- package/dist/components/organisms/CommandMenu/providers/command-menu-link-context.js +7 -0
- package/dist/components/organisms/CommandMenu/providers/command-menu-link-context.js.map +1 -0
- package/dist/components/organisms/DatePicker/components/input-date.cjs +3 -1
- package/dist/components/organisms/DatePicker/components/input-date.cjs.map +1 -1
- package/dist/components/organisms/DatePicker/components/input-date.d.ts +5 -1
- package/dist/components/organisms/DatePicker/components/input-date.d.ts.map +1 -1
- package/dist/components/organisms/DatePicker/components/input-date.js +3 -1
- package/dist/components/organisms/DatePicker/components/input-date.js.map +1 -1
- package/dist/components/organisms/HeaderNavigation/components/nav-account-card.cjs +3 -1
- package/dist/components/organisms/HeaderNavigation/components/nav-account-card.cjs.map +1 -1
- package/dist/components/organisms/HeaderNavigation/components/nav-account-card.d.ts +1 -1
- package/dist/components/organisms/HeaderNavigation/components/nav-account-card.d.ts.map +1 -1
- package/dist/components/organisms/HeaderNavigation/components/nav-account-card.js +3 -1
- package/dist/components/organisms/HeaderNavigation/components/nav-account-card.js.map +1 -1
- 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/SidebarNavigation/components/nav-account-card.cjs +3 -1
- package/dist/components/organisms/SidebarNavigation/components/nav-account-card.cjs.map +1 -1
- package/dist/components/organisms/SidebarNavigation/components/nav-account-card.d.ts +1 -1
- package/dist/components/organisms/SidebarNavigation/components/nav-account-card.d.ts.map +1 -1
- package/dist/components/organisms/SidebarNavigation/components/nav-account-card.js +3 -1
- package/dist/components/organisms/SidebarNavigation/components/nav-account-card.js.map +1 -1
- package/dist/components/organisms/SidebarNavigation/index.cjs +15 -5
- package/dist/components/organisms/SidebarNavigation/index.cjs.map +1 -1
- package/dist/components/organisms/SidebarNavigation/index.d.ts +3 -2
- package/dist/components/organisms/SidebarNavigation/index.d.ts.map +1 -1
- package/dist/components/organisms/SidebarNavigation/index.js +15 -5
- package/dist/components/organisms/SidebarNavigation/index.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/organisms/TextEditor/components/text-editor-extensions.cjs +9 -4
- package/dist/components/organisms/TextEditor/components/text-editor-extensions.cjs.map +1 -1
- package/dist/components/organisms/TextEditor/components/text-editor-extensions.d.ts.map +1 -1
- package/dist/components/organisms/TextEditor/components/text-editor-extensions.js +10 -5
- package/dist/components/organisms/TextEditor/components/text-editor-extensions.js.map +1 -1
- package/dist/components/organisms/TextEditor/components/text-editor-toolbar.cjs +8 -2
- package/dist/components/organisms/TextEditor/components/text-editor-toolbar.cjs.map +1 -1
- package/dist/components/organisms/TextEditor/components/text-editor-toolbar.d.ts.map +1 -1
- package/dist/components/organisms/TextEditor/components/text-editor-toolbar.js +8 -2
- package/dist/components/organisms/TextEditor/components/text-editor-toolbar.js.map +1 -1
- package/dist/components/organisms/TextEditor/textEditor.utils.cjs +3 -0
- package/dist/components/organisms/TextEditor/textEditor.utils.cjs.map +1 -1
- package/dist/components/organisms/TextEditor/textEditor.utils.d.ts +4 -0
- package/dist/components/organisms/TextEditor/textEditor.utils.d.ts.map +1 -1
- package/dist/components/organisms/TextEditor/textEditor.utils.js +3 -1
- package/dist/components/organisms/TextEditor/textEditor.utils.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/__internal__/useHotkeyHint/useHotkeyHint.cjs +24 -0
- package/dist/hooks/__internal__/useHotkeyHint/useHotkeyHint.cjs.map +1 -0
- package/dist/hooks/__internal__/useHotkeyHint/useHotkeyHint.d.ts +22 -0
- package/dist/hooks/__internal__/useHotkeyHint/useHotkeyHint.d.ts.map +1 -0
- package/dist/hooks/__internal__/useHotkeyHint/useHotkeyHint.js +22 -0
- package/dist/hooks/__internal__/useHotkeyHint/useHotkeyHint.js.map +1 -0
- package/dist/hooks/__internal__/useKeySequences/useKeySequences.cjs +54 -0
- package/dist/hooks/__internal__/useKeySequences/useKeySequences.cjs.map +1 -0
- package/dist/hooks/__internal__/useKeySequences/useKeySequences.d.ts +11 -0
- package/dist/hooks/__internal__/useKeySequences/useKeySequences.d.ts.map +1 -0
- package/dist/hooks/__internal__/useKeySequences/useKeySequences.js +52 -0
- package/dist/hooks/__internal__/useKeySequences/useKeySequences.js.map +1 -0
- package/dist/hooks/usePlatform/index.cjs +22 -0
- package/dist/hooks/usePlatform/index.cjs.map +1 -0
- package/dist/hooks/usePlatform/index.d.ts +22 -0
- package/dist/hooks/usePlatform/index.d.ts.map +1 -0
- package/dist/hooks/usePlatform/index.js +20 -0
- package/dist/hooks/usePlatform/index.js.map +1 -0
- 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/usePlatform/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__/hotkeysUtils/hotkeys.utils.cjs +222 -15
- package/dist/utilities/__internal__/hotkeysUtils/hotkeys.utils.cjs.map +1 -1
- package/dist/utilities/__internal__/hotkeysUtils/hotkeys.utils.d.ts +60 -5
- package/dist/utilities/__internal__/hotkeysUtils/hotkeys.utils.d.ts.map +1 -1
- package/dist/utilities/__internal__/hotkeysUtils/hotkeys.utils.js +215 -15
- package/dist/utilities/__internal__/hotkeysUtils/hotkeys.utils.js.map +1 -1
- package/dist/utilities/__internal__/platformUtils/platform.utils.cjs +26 -0
- package/dist/utilities/__internal__/platformUtils/platform.utils.cjs.map +1 -0
- package/dist/utilities/__internal__/platformUtils/platform.utils.d.ts +10 -0
- package/dist/utilities/__internal__/platformUtils/platform.utils.d.ts.map +1 -0
- package/dist/utilities/__internal__/platformUtils/platform.utils.js +23 -0
- package/dist/utilities/__internal__/platformUtils/platform.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,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var usePlatform = require('@flipdish/ui-library/hooks/usePlatform');
|
|
4
|
+
var hotkeys_utils = require('../../../utilities/__internal__/hotkeysUtils/hotkeys.utils.cjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Turns a shortcut into the label for the user's device: `mod+k` and `⌘K` both read `⌘K` on macOS and
|
|
8
|
+
* `Ctrl K` elsewhere. Serves every shortcut label in the library, whether the value is a real hotkey or
|
|
9
|
+
* display text: text that is not a hotkey (`Hold to talk`) is returned exactly as written. Reads as
|
|
10
|
+
* the non-Mac form on the server and during hydration.
|
|
11
|
+
*
|
|
12
|
+
* @param hotkey `react-hotkeys-hook` syntax (`mod+k`, `mod+slash`, a sequence such as `g>p`), the symbol
|
|
13
|
+
* shorthand (`⌘K`), a shortcut written out (`Ctrl+K`), or any other text.
|
|
14
|
+
* @returns The label, or `undefined` when nothing is given.
|
|
15
|
+
*
|
|
16
|
+
* @summary format a hotkey as a platform-aware label such as ⌘K or Ctrl K
|
|
17
|
+
*/
|
|
18
|
+
const useHotkeyHint = (hotkey, { commandOn = 'mac' } = {}) => {
|
|
19
|
+
const { isMac, isApple } = usePlatform.usePlatform();
|
|
20
|
+
return hotkey ? hotkeys_utils.formatHotkeyLabel(hotkey, commandOn === 'apple' ? isApple : isMac) : undefined;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.useHotkeyHint = useHotkeyHint;
|
|
24
|
+
//# sourceMappingURL=useHotkeyHint.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHotkeyHint.cjs","sources":["../../../../src/hooks/__internal__/useHotkeyHint/useHotkeyHint.ts"],"sourcesContent":[null],"names":["usePlatform","formatHotkeyLabel"],"mappings":";;;;;AAcA;;;;;;;;;;;AAWG;AACI,MAAM,aAAa,GAAG,CAAC,MAAiC,EAAE,EAAE,SAAS,GAAG,KAAK,EAAA,GAAwB,EAAE,KAAwB;IACpI,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAGA,uBAAW,EAAE;IAExC,OAAO,MAAM,GAAGC,+BAAiB,CAAC,MAAM,EAAE,SAAS,KAAK,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC,GAAG,SAAS;AAChG;;;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface HotkeyHintOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Which devices press ⌘ for `mod`. `mac` matches `react-hotkeys-hook`, which uses ⌘ on macOS only.
|
|
4
|
+
* `apple` matches editors built on ProseMirror, which also use ⌘ on iPhone and iPad.
|
|
5
|
+
* @default "mac"
|
|
6
|
+
*/
|
|
7
|
+
commandOn?: 'mac' | 'apple';
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Turns a shortcut into the label for the user's device: `mod+k` and `⌘K` both read `⌘K` on macOS and
|
|
11
|
+
* `Ctrl K` elsewhere. Serves every shortcut label in the library, whether the value is a real hotkey or
|
|
12
|
+
* display text: text that is not a hotkey (`Hold to talk`) is returned exactly as written. Reads as
|
|
13
|
+
* the non-Mac form on the server and during hydration.
|
|
14
|
+
*
|
|
15
|
+
* @param hotkey `react-hotkeys-hook` syntax (`mod+k`, `mod+slash`, a sequence such as `g>p`), the symbol
|
|
16
|
+
* shorthand (`⌘K`), a shortcut written out (`Ctrl+K`), or any other text.
|
|
17
|
+
* @returns The label, or `undefined` when nothing is given.
|
|
18
|
+
*
|
|
19
|
+
* @summary format a hotkey as a platform-aware label such as ⌘K or Ctrl K
|
|
20
|
+
*/
|
|
21
|
+
export declare const useHotkeyHint: (hotkey: string | null | undefined, { commandOn }?: HotkeyHintOptions) => string | undefined;
|
|
22
|
+
//# sourceMappingURL=useHotkeyHint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHotkeyHint.d.ts","sourceRoot":"","sources":["../../../../src/hooks/__internal__/useHotkeyHint/useHotkeyHint.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,SAAS,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,gBAAuB,iBAAsB,KAAG,MAAM,GAAG,SAIzH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { usePlatform } from '@flipdish/ui-library/hooks/usePlatform';
|
|
2
|
+
import { formatHotkeyLabel } from '../../../utilities/__internal__/hotkeysUtils/hotkeys.utils.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Turns a shortcut into the label for the user's device: `mod+k` and `⌘K` both read `⌘K` on macOS and
|
|
6
|
+
* `Ctrl K` elsewhere. Serves every shortcut label in the library, whether the value is a real hotkey or
|
|
7
|
+
* display text: text that is not a hotkey (`Hold to talk`) is returned exactly as written. Reads as
|
|
8
|
+
* the non-Mac form on the server and during hydration.
|
|
9
|
+
*
|
|
10
|
+
* @param hotkey `react-hotkeys-hook` syntax (`mod+k`, `mod+slash`, a sequence such as `g>p`), the symbol
|
|
11
|
+
* shorthand (`⌘K`), a shortcut written out (`Ctrl+K`), or any other text.
|
|
12
|
+
* @returns The label, or `undefined` when nothing is given.
|
|
13
|
+
*
|
|
14
|
+
* @summary format a hotkey as a platform-aware label such as ⌘K or Ctrl K
|
|
15
|
+
*/
|
|
16
|
+
const useHotkeyHint = (hotkey, { commandOn = 'mac' } = {}) => {
|
|
17
|
+
const { isMac, isApple } = usePlatform();
|
|
18
|
+
return hotkey ? formatHotkeyLabel(hotkey, commandOn === 'apple' ? isApple : isMac) : undefined;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { useHotkeyHint };
|
|
22
|
+
//# sourceMappingURL=useHotkeyHint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHotkeyHint.js","sources":["../../../../src/hooks/__internal__/useHotkeyHint/useHotkeyHint.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAcA;;;;;;;;;;;AAWG;AACI,MAAM,aAAa,GAAG,CAAC,MAAiC,EAAE,EAAE,SAAS,GAAG,KAAK,EAAA,GAAwB,EAAE,KAAwB;IACpI,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,WAAW,EAAE;IAExC,OAAO,MAAM,GAAG,iBAAiB,CAAC,MAAM,EAAE,SAAS,KAAK,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC,GAAG,SAAS;AAChG;;;;"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var hotkeys_utils = require('../../../utilities/__internal__/hotkeysUtils/hotkeys.utils.cjs');
|
|
5
|
+
var platform_utils = require('../../../utilities/__internal__/platformUtils/platform.utils.cjs');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Listens for plain-key shortcuts typed anywhere on the page: single keys (`?`) and sequences
|
|
9
|
+
* (`g` then `p`), including sequences that share a first key, which `react-hotkeys-hook` cannot
|
|
10
|
+
* tell apart. Keys pressed with ⌘/Ctrl/Alt or Shift plus a letter, or while focus is in a field, are ignored so ordinary
|
|
11
|
+
* typing and other shortcuts are never hijacked. A sequence must be completed within `timeoutMs`
|
|
12
|
+
* of its previous key.
|
|
13
|
+
*
|
|
14
|
+
* @summary match single-key and multi-key plain shortcuts outside form fields
|
|
15
|
+
*/
|
|
16
|
+
const useKeySequences = (sequences, onMatch, timeoutMs = 1000) => {
|
|
17
|
+
const latest = React.useRef({ sequences, onMatch });
|
|
18
|
+
React.useEffect(() => {
|
|
19
|
+
latest.current = { sequences, onMatch };
|
|
20
|
+
});
|
|
21
|
+
const hasSequences = sequences.length > 0;
|
|
22
|
+
React.useEffect(() => {
|
|
23
|
+
if (!hasSequences)
|
|
24
|
+
return;
|
|
25
|
+
let buffer = [];
|
|
26
|
+
let lastKeyAt = 0;
|
|
27
|
+
const onKeyDown = (event) => {
|
|
28
|
+
// A key name longer than one character (Shift, Enter, ArrowDown) is not a typed character.
|
|
29
|
+
if (event.defaultPrevented || event.repeat || event.key.length !== 1 || hotkeys_utils.isTypingInField(event))
|
|
30
|
+
return;
|
|
31
|
+
// AltGr (reported as Ctrl+Alt on Windows) and Option on Apple keyboards type characters such as `@` or `[` on many layouts.
|
|
32
|
+
const os = platform_utils.getPlatformOs();
|
|
33
|
+
const typesCharacter = event.getModifierState('AltGraph') || ((os === 'macos' || os === 'ios') && event.altKey && !event.ctrlKey);
|
|
34
|
+
if (event.metaKey || ((event.ctrlKey || event.altKey) && !typesCharacter))
|
|
35
|
+
return;
|
|
36
|
+
// Shift plus a letter is its own shortcut (`⇧d`), not the letter.
|
|
37
|
+
if (event.shiftKey && event.key.toLowerCase() !== event.key.toUpperCase())
|
|
38
|
+
return;
|
|
39
|
+
const now = Date.now();
|
|
40
|
+
const result = hotkeys_utils.advanceKeySequence(now - lastKeyAt > timeoutMs ? [] : buffer, event.key.toLowerCase(), latest.current.sequences);
|
|
41
|
+
buffer = result.buffer;
|
|
42
|
+
lastKeyAt = now;
|
|
43
|
+
if (result.matched !== undefined) {
|
|
44
|
+
event.preventDefault();
|
|
45
|
+
latest.current.onMatch(result.matched);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
document.addEventListener('keydown', onKeyDown);
|
|
49
|
+
return () => document.removeEventListener('keydown', onKeyDown);
|
|
50
|
+
}, [hasSequences, timeoutMs]);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
exports.useKeySequences = useKeySequences;
|
|
54
|
+
//# sourceMappingURL=useKeySequences.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useKeySequences.cjs","sources":["../../../../src/hooks/__internal__/useKeySequences/useKeySequences.ts"],"sourcesContent":[null],"names":["useRef","useEffect","isTypingInField","getPlatformOs","advanceKeySequence"],"mappings":";;;;;;AAMA;;;;;;;;AAQG;AACI,MAAM,eAAe,GAAG,CAAC,SAAqB,EAAE,OAAgC,EAAE,SAAS,GAAG,IAAI,KAAU;IACjH,MAAM,MAAM,GAAGA,YAAM,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;IAC7CC,eAAS,CAAC,MAAK;QACb,MAAM,CAAC,OAAO,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE;AACzC,IAAA,CAAC,CAAC;AAEF,IAAA,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC;IAEzCA,eAAS,CAAC,MAAK;AACb,QAAA,IAAI,CAAC,YAAY;YAAE;QAEnB,IAAI,MAAM,GAAa,EAAE;QACzB,IAAI,SAAS,GAAG,CAAC;AAEjB,QAAA,MAAM,SAAS,GAAG,CAAC,KAAoB,KAAI;;AAEzC,YAAA,IAAI,KAAK,CAAC,gBAAgB,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,IAAIC,6BAAe,CAAC,KAAK,CAAC;gBAAE;;AAEhG,YAAA,MAAM,EAAE,GAAGC,4BAAa,EAAE;AAC1B,YAAA,MAAM,cAAc,GAAG,KAAK,CAAC,gBAAgB,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,OAAO,IAAI,EAAE,KAAK,KAAK,KAAK,KAAK,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;AACjI,YAAA,IAAI,KAAK,CAAC,OAAO,KAAK,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,cAAc,CAAC;gBAAE;;AAE3E,YAAA,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE;gBAAE;AAE3E,YAAA,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;AACtB,YAAA,MAAM,MAAM,GAAGC,gCAAkB,CAAC,GAAG,GAAG,SAAS,GAAG,SAAS,GAAG,EAAE,GAAG,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;AAC/H,YAAA,MAAM,GAAG,MAAM,CAAC,MAAM;YACtB,SAAS,GAAG,GAAG;AAEf,YAAA,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE;gBAChC,KAAK,CAAC,cAAc,EAAE;gBACtB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;YACxC;AACF,QAAA,CAAC;AAED,QAAA,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC;QAC/C,OAAO,MAAM,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC;AACjE,IAAA,CAAC,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;AAC/B;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Listens for plain-key shortcuts typed anywhere on the page: single keys (`?`) and sequences
|
|
3
|
+
* (`g` then `p`), including sequences that share a first key, which `react-hotkeys-hook` cannot
|
|
4
|
+
* tell apart. Keys pressed with ⌘/Ctrl/Alt or Shift plus a letter, or while focus is in a field, are ignored so ordinary
|
|
5
|
+
* typing and other shortcuts are never hijacked. A sequence must be completed within `timeoutMs`
|
|
6
|
+
* of its previous key.
|
|
7
|
+
*
|
|
8
|
+
* @summary match single-key and multi-key plain shortcuts outside form fields
|
|
9
|
+
*/
|
|
10
|
+
export declare const useKeySequences: (sequences: string[][], onMatch: (index: number) => void, timeoutMs?: number) => void;
|
|
11
|
+
//# sourceMappingURL=useKeySequences.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useKeySequences.d.ts","sourceRoot":"","sources":["../../../../src/hooks/__internal__/useKeySequences/useKeySequences.ts"],"names":[],"mappings":"AAMA;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,WAAW,MAAM,EAAE,EAAE,EAAE,SAAS,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,EAAE,kBAAgB,KAAG,IAsC3G,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useRef, useEffect } from 'react';
|
|
2
|
+
import { isTypingInField, advanceKeySequence } from '../../../utilities/__internal__/hotkeysUtils/hotkeys.utils.js';
|
|
3
|
+
import { getPlatformOs } from '../../../utilities/__internal__/platformUtils/platform.utils.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Listens for plain-key shortcuts typed anywhere on the page: single keys (`?`) and sequences
|
|
7
|
+
* (`g` then `p`), including sequences that share a first key, which `react-hotkeys-hook` cannot
|
|
8
|
+
* tell apart. Keys pressed with ⌘/Ctrl/Alt or Shift plus a letter, or while focus is in a field, are ignored so ordinary
|
|
9
|
+
* typing and other shortcuts are never hijacked. A sequence must be completed within `timeoutMs`
|
|
10
|
+
* of its previous key.
|
|
11
|
+
*
|
|
12
|
+
* @summary match single-key and multi-key plain shortcuts outside form fields
|
|
13
|
+
*/
|
|
14
|
+
const useKeySequences = (sequences, onMatch, timeoutMs = 1000) => {
|
|
15
|
+
const latest = useRef({ sequences, onMatch });
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
latest.current = { sequences, onMatch };
|
|
18
|
+
});
|
|
19
|
+
const hasSequences = sequences.length > 0;
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!hasSequences)
|
|
22
|
+
return;
|
|
23
|
+
let buffer = [];
|
|
24
|
+
let lastKeyAt = 0;
|
|
25
|
+
const onKeyDown = (event) => {
|
|
26
|
+
// A key name longer than one character (Shift, Enter, ArrowDown) is not a typed character.
|
|
27
|
+
if (event.defaultPrevented || event.repeat || event.key.length !== 1 || isTypingInField(event))
|
|
28
|
+
return;
|
|
29
|
+
// AltGr (reported as Ctrl+Alt on Windows) and Option on Apple keyboards type characters such as `@` or `[` on many layouts.
|
|
30
|
+
const os = getPlatformOs();
|
|
31
|
+
const typesCharacter = event.getModifierState('AltGraph') || ((os === 'macos' || os === 'ios') && event.altKey && !event.ctrlKey);
|
|
32
|
+
if (event.metaKey || ((event.ctrlKey || event.altKey) && !typesCharacter))
|
|
33
|
+
return;
|
|
34
|
+
// Shift plus a letter is its own shortcut (`⇧d`), not the letter.
|
|
35
|
+
if (event.shiftKey && event.key.toLowerCase() !== event.key.toUpperCase())
|
|
36
|
+
return;
|
|
37
|
+
const now = Date.now();
|
|
38
|
+
const result = advanceKeySequence(now - lastKeyAt > timeoutMs ? [] : buffer, event.key.toLowerCase(), latest.current.sequences);
|
|
39
|
+
buffer = result.buffer;
|
|
40
|
+
lastKeyAt = now;
|
|
41
|
+
if (result.matched !== undefined) {
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
latest.current.onMatch(result.matched);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
document.addEventListener('keydown', onKeyDown);
|
|
47
|
+
return () => document.removeEventListener('keydown', onKeyDown);
|
|
48
|
+
}, [hasSequences, timeoutMs]);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export { useKeySequences };
|
|
52
|
+
//# sourceMappingURL=useKeySequences.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useKeySequences.js","sources":["../../../../src/hooks/__internal__/useKeySequences/useKeySequences.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAMA;;;;;;;;AAQG;AACI,MAAM,eAAe,GAAG,CAAC,SAAqB,EAAE,OAAgC,EAAE,SAAS,GAAG,IAAI,KAAU;IACjH,MAAM,MAAM,GAAG,MAAM,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;IAC7C,SAAS,CAAC,MAAK;QACb,MAAM,CAAC,OAAO,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE;AACzC,IAAA,CAAC,CAAC;AAEF,IAAA,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC;IAEzC,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,CAAC,YAAY;YAAE;QAEnB,IAAI,MAAM,GAAa,EAAE;QACzB,IAAI,SAAS,GAAG,CAAC;AAEjB,QAAA,MAAM,SAAS,GAAG,CAAC,KAAoB,KAAI;;AAEzC,YAAA,IAAI,KAAK,CAAC,gBAAgB,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,eAAe,CAAC,KAAK,CAAC;gBAAE;;AAEhG,YAAA,MAAM,EAAE,GAAG,aAAa,EAAE;AAC1B,YAAA,MAAM,cAAc,GAAG,KAAK,CAAC,gBAAgB,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,OAAO,IAAI,EAAE,KAAK,KAAK,KAAK,KAAK,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;AACjI,YAAA,IAAI,KAAK,CAAC,OAAO,KAAK,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,cAAc,CAAC;gBAAE;;AAE3E,YAAA,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE;gBAAE;AAE3E,YAAA,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;AACtB,YAAA,MAAM,MAAM,GAAG,kBAAkB,CAAC,GAAG,GAAG,SAAS,GAAG,SAAS,GAAG,EAAE,GAAG,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;AAC/H,YAAA,MAAM,GAAG,MAAM,CAAC,MAAM;YACtB,SAAS,GAAG,GAAG;AAEf,YAAA,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE;gBAChC,KAAK,CAAC,cAAc,EAAE;gBACtB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;YACxC;AACF,QAAA,CAAC;AAED,QAAA,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC;QAC/C,OAAO,MAAM,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC;AACjE,IAAA,CAAC,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;AAC/B;;;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var platform_utils = require('../../utilities/__internal__/platformUtils/platform.utils.cjs');
|
|
5
|
+
|
|
6
|
+
const subscribeToNothing = () => () => { };
|
|
7
|
+
const getServerOs = () => 'unknown';
|
|
8
|
+
/**
|
|
9
|
+
* Reports the operating system of the user's device, for wording that depends on it: a shortcut
|
|
10
|
+
* label, a download link, a help article. Detection reads the user agent, so treat it as a best
|
|
11
|
+
* guess and never as a reason to change behaviour; use `useBreakpoints` or feature detection for
|
|
12
|
+
* that. Every flag is `false` on the server and during hydration, then settles on the real device.
|
|
13
|
+
*
|
|
14
|
+
* @summary detect the user's operating system, safely across hydration
|
|
15
|
+
*/
|
|
16
|
+
const usePlatform = () => {
|
|
17
|
+
const os = React.useSyncExternalStore(subscribeToNothing, platform_utils.getPlatformOs, getServerOs);
|
|
18
|
+
return React.useMemo(() => ({ os, isMac: os === 'macos', isApple: os === 'macos' || os === 'ios', isWindows: os === 'windows' }), [os]);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.usePlatform = usePlatform;
|
|
22
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/hooks/usePlatform/index.ts"],"sourcesContent":[null],"names":["useSyncExternalStore","getPlatformOs","useMemo"],"mappings":";;;;;AAmBA,MAAM,kBAAkB,GAAG,MAAM,MAAK,EAAE,CAAC;AACzC,MAAM,WAAW,GAAG,MAAkB,SAAS;AAE/C;;;;;;;AAOG;AACI,MAAM,WAAW,GAAG,MAAmB;IAC5C,MAAM,EAAE,GAAGA,0BAAoB,CAAC,kBAAkB,EAAEC,4BAAa,EAAE,WAAW,CAAC;AAE/E,IAAA,OAAOC,aAAO,CAAC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,OAAO,EAAE,OAAO,EAAE,EAAE,KAAK,OAAO,IAAI,EAAE,KAAK,KAAK,EAAE,SAAS,EAAE,EAAE,KAAK,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACnI;;;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PlatformOs } from '../../utilities/__internal__/platformUtils/platform.utils';
|
|
2
|
+
export type { PlatformOs };
|
|
3
|
+
export interface PlatformInfo {
|
|
4
|
+
/** The operating system, or `unknown` on the server, during hydration and when it cannot be told. */
|
|
5
|
+
os: PlatformOs;
|
|
6
|
+
/** macOS only, where ⌘ is the primary shortcut modifier. Also true for an iPad in desktop mode, which reports itself as a Mac. */
|
|
7
|
+
isMac: boolean;
|
|
8
|
+
/** Any Apple device: macOS, iPhone or iPad. */
|
|
9
|
+
isApple: boolean;
|
|
10
|
+
/** Windows only, where the primary shortcut modifier is `ctrl`. */
|
|
11
|
+
isWindows: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Reports the operating system of the user's device, for wording that depends on it: a shortcut
|
|
15
|
+
* label, a download link, a help article. Detection reads the user agent, so treat it as a best
|
|
16
|
+
* guess and never as a reason to change behaviour; use `useBreakpoints` or feature detection for
|
|
17
|
+
* that. Every flag is `false` on the server and during hydration, then settles on the real device.
|
|
18
|
+
*
|
|
19
|
+
* @summary detect the user's operating system, safely across hydration
|
|
20
|
+
*/
|
|
21
|
+
export declare const usePlatform: () => PlatformInfo;
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/usePlatform/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2DAA2D,CAAC;AAE5F,YAAY,EAAE,UAAU,EAAE,CAAC;AAE3B,MAAM,WAAW,YAAY;IAC3B,qGAAqG;IACrG,EAAE,EAAE,UAAU,CAAC;IACf,kIAAkI;IAClI,KAAK,EAAE,OAAO,CAAC;IACf,+CAA+C;IAC/C,OAAO,EAAE,OAAO,CAAC;IACjB,mEAAmE;IACnE,SAAS,EAAE,OAAO,CAAC;CACpB;AAKD;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,QAAO,YAI9B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useSyncExternalStore, useMemo } from 'react';
|
|
2
|
+
import { getPlatformOs } from '../../utilities/__internal__/platformUtils/platform.utils.js';
|
|
3
|
+
|
|
4
|
+
const subscribeToNothing = () => () => { };
|
|
5
|
+
const getServerOs = () => 'unknown';
|
|
6
|
+
/**
|
|
7
|
+
* Reports the operating system of the user's device, for wording that depends on it: a shortcut
|
|
8
|
+
* label, a download link, a help article. Detection reads the user agent, so treat it as a best
|
|
9
|
+
* guess and never as a reason to change behaviour; use `useBreakpoints` or feature detection for
|
|
10
|
+
* that. Every flag is `false` on the server and during hydration, then settles on the real device.
|
|
11
|
+
*
|
|
12
|
+
* @summary detect the user's operating system, safely across hydration
|
|
13
|
+
*/
|
|
14
|
+
const usePlatform = () => {
|
|
15
|
+
const os = useSyncExternalStore(subscribeToNothing, getPlatformOs, getServerOs);
|
|
16
|
+
return useMemo(() => ({ os, isMac: os === 'macos', isApple: os === 'macos' || os === 'ios', isWindows: os === 'windows' }), [os]);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { usePlatform };
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/hooks/usePlatform/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAmBA,MAAM,kBAAkB,GAAG,MAAM,MAAK,EAAE,CAAC;AACzC,MAAM,WAAW,GAAG,MAAkB,SAAS;AAE/C;;;;;;;AAOG;AACI,MAAM,WAAW,GAAG,MAAmB;IAC5C,MAAM,EAAE,GAAG,oBAAoB,CAAC,kBAAkB,EAAE,aAAa,EAAE,WAAW,CAAC;AAE/E,IAAA,OAAO,OAAO,CAAC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,OAAO,EAAE,OAAO,EAAE,EAAE,KAAK,OAAO,IAAI,EAAE,KAAK,KAAK,EAAE,SAAS,EAAE,EAAE,KAAK,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACnI;;;;"}
|
|
@@ -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,MAAM,MAAM,GAAGD,YAAM,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAC1CE,eAAS,CAAC,MAAK;QACb,MAAM,CAAC,OAAO,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE;AACtC,IAAA,CAAC,CAAC;AAEF,IAAA,MAAM,OAAO,GAAGC,aAAO,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,gBAAAF,kCAAgB,CAAC,GAAG,CAAC,KAAK,CAAC;;gBAC3EA,kCAAgB,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,31 @@
|
|
|
1
|
+
export interface UseSidePanelOptions<T extends string> {
|
|
2
|
+
/**
|
|
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
|
+
* `usePlatform` 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/usePlatform` 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 `usePlatform` 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;;;;"}
|