@flipdish/ui-library 0.44.0 → 0.45.1
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/SidePanelRegion.cjs +8 -0
- package/dist/components/organisms/SidePanel/components/SidePanelRegion.cjs.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelRegion.d.ts.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelRegion.js +8 -0
- package/dist/components/organisms/SidePanel/components/SidePanelRegion.js.map +1 -1
- package/dist/components/organisms/SlideoutMenu/components/SlideoutShell.cjs +27 -60
- package/dist/components/organisms/SlideoutMenu/components/SlideoutShell.cjs.map +1 -1
- package/dist/components/organisms/SlideoutMenu/components/SlideoutShell.d.ts +2 -3
- package/dist/components/organisms/SlideoutMenu/components/SlideoutShell.d.ts.map +1 -1
- package/dist/components/organisms/SlideoutMenu/components/SlideoutShell.js +27 -60
- package/dist/components/organisms/SlideoutMenu/components/SlideoutShell.js.map +1 -1
- package/dist/components/organisms/SlideoutMenu/hooks/useCloseWhenCovered.cjs +31 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useCloseWhenCovered.cjs.map +1 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useCloseWhenCovered.d.ts +15 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useCloseWhenCovered.d.ts.map +1 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useCloseWhenCovered.js +29 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useCloseWhenCovered.js.map +1 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useDialogFocusSettle.cjs +41 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useDialogFocusSettle.cjs.map +1 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useDialogFocusSettle.d.ts +19 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useDialogFocusSettle.d.ts.map +1 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useDialogFocusSettle.js +39 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useDialogFocusSettle.js.map +1 -0
- package/dist/components/organisms/SlideoutMenu/hooks/usePageEscapeDismiss.cjs +36 -0
- package/dist/components/organisms/SlideoutMenu/hooks/usePageEscapeDismiss.cjs.map +1 -0
- package/dist/components/organisms/SlideoutMenu/hooks/usePageEscapeDismiss.d.ts +21 -0
- package/dist/components/organisms/SlideoutMenu/hooks/usePageEscapeDismiss.d.ts.map +1 -0
- package/dist/components/organisms/SlideoutMenu/hooks/usePageEscapeDismiss.js +34 -0
- package/dist/components/organisms/SlideoutMenu/hooks/usePageEscapeDismiss.js.map +1 -0
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.cjs +3 -2
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.cjs.map +1 -1
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.d.ts.map +1 -1
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.js +4 -3
- package/dist/components/organisms/SlideoutMenu/hooks/useSlideoutState.js.map +1 -1
- package/dist/components/organisms/SlideoutMenu/index.cjs +5 -0
- package/dist/components/organisms/SlideoutMenu/index.cjs.map +1 -1
- package/dist/components/organisms/SlideoutMenu/index.d.ts +16 -9
- package/dist/components/organisms/SlideoutMenu/index.d.ts.map +1 -1
- package/dist/components/organisms/SlideoutMenu/index.js +5 -0
- package/dist/components/organisms/SlideoutMenu/index.js.map +1 -1
- package/dist/components/organisms/SlideoutMenu/providers/PageArea.context.cjs +4 -4
- package/dist/components/organisms/SlideoutMenu/providers/PageArea.context.d.ts +4 -4
- package/dist/components/organisms/SlideoutMenu/providers/PageArea.context.js +4 -4
- package/dist/hooks/__internal__/usePanelFocus/usePanelFocus.cjs +24 -8
- package/dist/hooks/__internal__/usePanelFocus/usePanelFocus.cjs.map +1 -1
- package/dist/hooks/__internal__/usePanelFocus/usePanelFocus.d.ts +3 -2
- package/dist/hooks/__internal__/usePanelFocus/usePanelFocus.d.ts.map +1 -1
- package/dist/hooks/__internal__/usePanelFocus/usePanelFocus.js +25 -9
- package/dist/hooks/__internal__/usePanelFocus/usePanelFocus.js.map +1 -1
- package/dist/providers/ThemeProvider/Theme.context.cjs +17 -0
- package/dist/providers/ThemeProvider/Theme.context.cjs.map +1 -0
- package/dist/providers/ThemeProvider/Theme.context.d.ts +16 -0
- package/dist/providers/ThemeProvider/Theme.context.d.ts.map +1 -0
- package/dist/providers/ThemeProvider/Theme.context.js +14 -0
- package/dist/providers/ThemeProvider/Theme.context.js.map +1 -0
- package/dist/providers/ThemeProvider/index.cjs +3 -11
- package/dist/providers/ThemeProvider/index.cjs.map +1 -1
- package/dist/providers/ThemeProvider/index.d.ts +1 -14
- package/dist/providers/ThemeProvider/index.d.ts.map +1 -1
- package/dist/providers/ThemeProvider/index.js +3 -10
- package/dist/providers/ThemeProvider/index.js.map +1 -1
- package/dist/utilities/__internal__/pageCoverUtils/pageCover.utils.cjs +30 -0
- package/dist/utilities/__internal__/pageCoverUtils/pageCover.utils.cjs.map +1 -0
- package/dist/utilities/__internal__/pageCoverUtils/pageCover.utils.d.ts +19 -0
- package/dist/utilities/__internal__/pageCoverUtils/pageCover.utils.d.ts.map +1 -0
- package/dist/utilities/__internal__/pageCoverUtils/pageCover.utils.js +26 -0
- package/dist/utilities/__internal__/pageCoverUtils/pageCover.utils.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useRef, useState, useEffect,
|
|
1
|
+
import { useRef, useState, useEffect, useCallback, useLayoutEffect } from 'react';
|
|
2
2
|
import { getFocusedElement } from '../../../utilities/__internal__/focusUtils/focus.utils.js';
|
|
3
3
|
import { coverElement, lastCoverOf } from '../../../utilities/__internal__/inertUtils/inert.utils.js';
|
|
4
4
|
|
|
@@ -7,18 +7,25 @@ const focusableSiblingBefore = (panel) => {
|
|
|
7
7
|
const sibling = panel.previousElementSibling;
|
|
8
8
|
return sibling instanceof HTMLElement && sibling.tabIndex >= 0 ? sibling : null;
|
|
9
9
|
};
|
|
10
|
-
/** Whether a hand-back can land: a control, or a region given a `tabindex`,
|
|
11
|
-
const canTakeFocus = (element) => element instanceof HTMLElement &&
|
|
10
|
+
/** Whether a hand-back can land: a control, or a region given a `tabindex`, neither disabled nor under a cover. */
|
|
11
|
+
const canTakeFocus = (element) => element instanceof HTMLElement &&
|
|
12
|
+
(element.tabIndex >= 0 || element.hasAttribute('tabindex')) &&
|
|
13
|
+
!element.matches(':disabled') &&
|
|
14
|
+
element.closest('[inert]') === null;
|
|
12
15
|
/**
|
|
13
16
|
* What covers an element under an inert ancestor: the last panel to cover that ancestor, else the sibling after it, as a
|
|
14
|
-
* side panel sits after the page it covers
|
|
17
|
+
* side panel sits after the page it covers, else the first region inside that sibling given a `tabindex` that can take
|
|
18
|
+
* focus, as a host wraps its side panel. Nothing when none of those can.
|
|
15
19
|
*/
|
|
16
20
|
const coverOver = (element) => {
|
|
17
21
|
const covered = element.closest('[inert]');
|
|
18
22
|
if (!(covered instanceof HTMLElement))
|
|
19
23
|
return null;
|
|
20
24
|
const candidate = lastCoverOf(covered) ?? covered.nextElementSibling;
|
|
21
|
-
|
|
25
|
+
if (canTakeFocus(candidate))
|
|
26
|
+
return candidate;
|
|
27
|
+
const regions = candidate ? [...candidate.querySelectorAll('[tabindex]')] : [];
|
|
28
|
+
return regions.find(canTakeFocus) ?? null;
|
|
22
29
|
};
|
|
23
30
|
/**
|
|
24
31
|
* What the panel covers: the given element, unless the panel sits inside it, as overlays do without a scoped anchor, when
|
|
@@ -37,8 +44,8 @@ const resolveCovered = (panel, coveredRef) => {
|
|
|
37
44
|
* a popover does.
|
|
38
45
|
*
|
|
39
46
|
* @param options See `UsePanelFocusOptions`.
|
|
40
|
-
* @returns a capture-phase focus handler to spread onto the panel element,
|
|
41
|
-
* close at another control after a content swap
|
|
47
|
+
* @returns a capture-phase focus handler to spread onto the panel element, `setOpener`, which points the hand-back on
|
|
48
|
+
* close at another control after a content swap, and `liftCover`, which lifts the cover ahead of the close that follows
|
|
42
49
|
*/
|
|
43
50
|
const usePanelFocus = ({ panelRef, isPresent, isDesktop, coveredRef, shouldFocusOnMount, contentKey }) => {
|
|
44
51
|
const openerRef = useRef(null);
|
|
@@ -97,6 +104,7 @@ const usePanelFocus = ({ panelRef, isPresent, isDesktop, coveredRef, shouldFocus
|
|
|
97
104
|
// React runs every cleanup before any effect in a commit, so the cover lifts before the hand-back above lands focus in the
|
|
98
105
|
// page. Covers are counted per element, so two panels over the same page restore its own `inert` only when the last lifts.
|
|
99
106
|
const isCovering = isPresent && !isDesktop;
|
|
107
|
+
const liftCoverRef = useRef(null);
|
|
100
108
|
useEffect(() => {
|
|
101
109
|
const panel = panelRef.current;
|
|
102
110
|
// Only a given element is covered; the panel's siblings are the layout's to cover, as `AppShell` does for a side panel.
|
|
@@ -108,8 +116,16 @@ const usePanelFocus = ({ panelRef, isPresent, isDesktop, coveredRef, shouldFocus
|
|
|
108
116
|
const focused = getFocusedElement();
|
|
109
117
|
if (focused && covered.contains(focused))
|
|
110
118
|
panel.focus({ preventScroll: true });
|
|
111
|
-
|
|
119
|
+
const lift = coverElement(covered, panel);
|
|
120
|
+
liftCoverRef.current = lift;
|
|
121
|
+
return () => {
|
|
122
|
+
lift();
|
|
123
|
+
liftCoverRef.current = null;
|
|
124
|
+
};
|
|
112
125
|
}, [panelRef, coveredRef, isCovering]);
|
|
126
|
+
// For a close that another panel caused: that panel is mounting under this cover in the same pass, and its focus call would
|
|
127
|
+
// be refused until the cover lifts at the next commit. Lifting is idempotent, so the effect's own cleanup stays harmless.
|
|
128
|
+
const liftCover = useCallback(() => liftCoverRef.current?.(), []);
|
|
113
129
|
// Swapping content unmounts whatever held focus, which drops it on the page. The region takes it, so Tab stays inside and
|
|
114
130
|
// closing can still hand it back. Content that focuses itself on mount (an `autoFocus` input) has done so by now and keeps it.
|
|
115
131
|
const previousContentKey = useRef(contentKey);
|
|
@@ -131,7 +147,7 @@ const usePanelFocus = ({ panelRef, isPresent, isDesktop, coveredRef, shouldFocus
|
|
|
131
147
|
const setOpener = useCallback((element) => {
|
|
132
148
|
openerRef.current = element;
|
|
133
149
|
}, []);
|
|
134
|
-
return { onFocusCapture, setOpener };
|
|
150
|
+
return { onFocusCapture, setOpener, liftCover };
|
|
135
151
|
};
|
|
136
152
|
|
|
137
153
|
export { usePanelFocus };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePanelFocus.js","sources":["../../../../src/hooks/__internal__/usePanelFocus/usePanelFocus.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAOA;AACA,MAAM,sBAAsB,GAAG,CAAC,KAAkB,KAAwB;AACxE,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,sBAAsB;AAE5C,IAAA,OAAO,OAAO,YAAY,WAAW,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,GAAG,OAAO,GAAG,IAAI;AACjF,CAAC;AAED;AACA,MAAM,YAAY,GAAG,CAAC,OAAmC,KACvD,OAAO,YAAY,WAAW,
|
|
1
|
+
{"version":3,"file":"usePanelFocus.js","sources":["../../../../src/hooks/__internal__/usePanelFocus/usePanelFocus.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAOA;AACA,MAAM,sBAAsB,GAAG,CAAC,KAAkB,KAAwB;AACxE,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,sBAAsB;AAE5C,IAAA,OAAO,OAAO,YAAY,WAAW,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,GAAG,OAAO,GAAG,IAAI;AACjF,CAAC;AAED;AACA,MAAM,YAAY,GAAG,CAAC,OAAmC,KACvD,OAAO,YAAY,WAAW;AAC9B,KAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,IAAI,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;AAC3D,IAAA,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC;AAC7B,IAAA,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,IAAI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 -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
// Its own file so library components can read it without a public export; one module, so one context for every reader.
|
|
6
|
+
const ThemeContext = React.createContext(undefined);
|
|
7
|
+
/**
|
|
8
|
+
* The element the app's theme cascades from: in a micro-frontend, its whole mount. Unlike `useTheme` it never throws, so a
|
|
9
|
+
* component such as `SlideoutMenu` can adapt to the app's root without requiring the provider.
|
|
10
|
+
*
|
|
11
|
+
* @returns The themed root, or `null` outside a `ThemeProvider` or before it has mounted.
|
|
12
|
+
*/
|
|
13
|
+
const useThemeRoot = () => React.useContext(ThemeContext)?.themeRoot ?? null;
|
|
14
|
+
|
|
15
|
+
exports.ThemeContext = ThemeContext;
|
|
16
|
+
exports.useThemeRoot = useThemeRoot;
|
|
17
|
+
//# sourceMappingURL=Theme.context.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Theme.context.cjs","sources":["../../../src/providers/ThemeProvider/Theme.context.ts"],"sourcesContent":[null],"names":["createContext","useContext"],"mappings":";;;;AAaA;MACa,YAAY,GAAGA,mBAAa,CAA+B,SAAS;AAEjF;;;;;AAKG;AACI,MAAM,YAAY,GAAG,MAA0BC,gBAAU,CAAC,YAAY,CAAC,EAAE,SAAS,IAAI;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type Theme = 'light' | 'dark' | 'system';
|
|
2
|
+
export interface ThemeContextType {
|
|
3
|
+
theme: Theme;
|
|
4
|
+
setTheme: (theme: Theme) => void;
|
|
5
|
+
themeRoot: HTMLElement | null;
|
|
6
|
+
resolvedMode: 'light' | 'dark';
|
|
7
|
+
}
|
|
8
|
+
export declare const ThemeContext: import("react").Context<ThemeContextType | undefined>;
|
|
9
|
+
/**
|
|
10
|
+
* The element the app's theme cascades from: in a micro-frontend, its whole mount. Unlike `useTheme` it never throws, so a
|
|
11
|
+
* component such as `SlideoutMenu` can adapt to the app's root without requiring the provider.
|
|
12
|
+
*
|
|
13
|
+
* @returns The themed root, or `null` outside a `ThemeProvider` or before it has mounted.
|
|
14
|
+
*/
|
|
15
|
+
export declare const useThemeRoot: () => HTMLElement | null;
|
|
16
|
+
//# sourceMappingURL=Theme.context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Theme.context.d.ts","sourceRoot":"","sources":["../../../src/providers/ThemeProvider/Theme.context.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEhD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,SAAS,EAAE,WAAW,GAAG,IAAI,CAAC;IAC9B,YAAY,EAAE,OAAO,GAAG,MAAM,CAAC;CAChC;AAGD,eAAO,MAAM,YAAY,uDAAyD,CAAC;AAEnF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,QAAO,WAAW,GAAG,IAAmD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
// Its own file so library components can read it without a public export; one module, so one context for every reader.
|
|
4
|
+
const ThemeContext = createContext(undefined);
|
|
5
|
+
/**
|
|
6
|
+
* The element the app's theme cascades from: in a micro-frontend, its whole mount. Unlike `useTheme` it never throws, so a
|
|
7
|
+
* component such as `SlideoutMenu` can adapt to the app's root without requiring the provider.
|
|
8
|
+
*
|
|
9
|
+
* @returns The themed root, or `null` outside a `ThemeProvider` or before it has mounted.
|
|
10
|
+
*/
|
|
11
|
+
const useThemeRoot = () => useContext(ThemeContext)?.themeRoot ?? null;
|
|
12
|
+
|
|
13
|
+
export { ThemeContext, useThemeRoot };
|
|
14
|
+
//# sourceMappingURL=Theme.context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Theme.context.js","sources":["../../../src/providers/ThemeProvider/Theme.context.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAaA;MACa,YAAY,GAAG,aAAa,CAA+B,SAAS;AAEjF;;;;;AAKG;AACI,MAAM,YAAY,GAAG,MAA0B,UAAU,CAAC,YAAY,CAAC,EAAE,SAAS,IAAI;;"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var React = require('react');
|
|
5
|
+
var Theme_context = require('./Theme.context.cjs');
|
|
5
6
|
|
|
6
|
-
const ThemeContext = React.createContext(undefined);
|
|
7
7
|
/**
|
|
8
8
|
* Reads the current theme and its setter from the nearest `ThemeProvider`.
|
|
9
9
|
*
|
|
@@ -11,19 +11,12 @@ const ThemeContext = React.createContext(undefined);
|
|
|
11
11
|
* element carrying `data-theme`.
|
|
12
12
|
*/
|
|
13
13
|
const useTheme = () => {
|
|
14
|
-
const context = React.useContext(ThemeContext);
|
|
14
|
+
const context = React.useContext(Theme_context.ThemeContext);
|
|
15
15
|
if (context === undefined) {
|
|
16
16
|
throw new Error('useTheme must be used within a ThemeProvider');
|
|
17
17
|
}
|
|
18
18
|
return context;
|
|
19
19
|
};
|
|
20
|
-
/**
|
|
21
|
-
* The element the app's theme cascades from: in a micro-frontend, its whole mount. Unlike `useTheme` it never throws,
|
|
22
|
-
* so a component can adapt to the app's root without requiring the provider.
|
|
23
|
-
*
|
|
24
|
-
* @returns The themed root, or `null` outside a `ThemeProvider` or before it has mounted.
|
|
25
|
-
*/
|
|
26
|
-
const useThemeRoot = () => React.useContext(ThemeContext)?.themeRoot ?? null;
|
|
27
20
|
// Providers currently mirroring onto <html>, so a page with several (a Storybook docs page mounts one per
|
|
28
21
|
// story) only loses the attribute when the last one unmounts.
|
|
29
22
|
let documentThemeWriters = 0;
|
|
@@ -87,10 +80,9 @@ const ThemeProvider = ({ children, defaultTheme = 'system', storageKey, themeMod
|
|
|
87
80
|
return () => mediaQuery.removeEventListener('change', handleChange);
|
|
88
81
|
}, []);
|
|
89
82
|
const contextValue = React.useMemo(() => ({ theme: activeTheme, setTheme, themeRoot, resolvedMode }), [activeTheme, themeRoot, resolvedMode]);
|
|
90
|
-
return (jsxRuntime.jsx(ThemeContext.Provider, { value: contextValue, children: jsxRuntime.jsx("div", { ref: setThemeRoot, "data-theme": resolvedMode, "data-mfe-scope": scopeId, style: { display: 'contents' }, children: children }) }));
|
|
83
|
+
return (jsxRuntime.jsx(Theme_context.ThemeContext.Provider, { value: contextValue, children: jsxRuntime.jsx("div", { ref: setThemeRoot, "data-theme": resolvedMode, "data-mfe-scope": scopeId, style: { display: 'contents' }, children: children }) }));
|
|
91
84
|
};
|
|
92
85
|
|
|
93
86
|
exports.ThemeProvider = ThemeProvider;
|
|
94
87
|
exports.useTheme = useTheme;
|
|
95
|
-
exports.useThemeRoot = useThemeRoot;
|
|
96
88
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/providers/ThemeProvider/index.tsx"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/providers/ThemeProvider/index.tsx"],"sourcesContent":[null],"names":["useContext","ThemeContext","useState","useEffect","useMemo","_jsx"],"mappings":";;;;;;AAMA;;;;;AAKG;AACI,MAAM,QAAQ,GAAG,MAAuB;AAC7C,IAAA,MAAM,OAAO,GAAGA,gBAAU,CAACC,0BAAY,CAAC;AAExC,IAAA,IAAI,OAAO,KAAK,SAAS,EAAE;AACzB,QAAA,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC;IACjE;AAEA,IAAA,OAAO,OAAO;AAChB;AAEA;AACA;AACA,IAAI,oBAAoB,GAAG,CAAC;AAE5B,MAAM,uBAAuB,GAAG,MAAuB;IACrD,IAAI,OAAO,MAAM,KAAK,WAAW;AAAE,QAAA,OAAO,OAAO;AACjD,IAAA,OAAO,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YAAY,EAAA,gBAAA,EAAkB,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAAA,QAAA,EACtG,QAAQ,EAAA,CACL,EAAA,CACgB;AAE5B;;;"}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
type Theme
|
|
3
|
-
interface ThemeContextType {
|
|
4
|
-
theme: Theme;
|
|
5
|
-
setTheme: (theme: Theme) => void;
|
|
6
|
-
themeRoot: HTMLElement | null;
|
|
7
|
-
resolvedMode: 'light' | 'dark';
|
|
8
|
-
}
|
|
2
|
+
import { type Theme, type ThemeContextType } from './Theme.context';
|
|
9
3
|
/**
|
|
10
4
|
* Reads the current theme and its setter from the nearest `ThemeProvider`.
|
|
11
5
|
*
|
|
@@ -13,13 +7,6 @@ interface ThemeContextType {
|
|
|
13
7
|
* element carrying `data-theme`.
|
|
14
8
|
*/
|
|
15
9
|
export declare const useTheme: () => ThemeContextType;
|
|
16
|
-
/**
|
|
17
|
-
* The element the app's theme cascades from: in a micro-frontend, its whole mount. Unlike `useTheme` it never throws,
|
|
18
|
-
* so a component can adapt to the app's root without requiring the provider.
|
|
19
|
-
*
|
|
20
|
-
* @returns The themed root, or `null` outside a `ThemeProvider` or before it has mounted.
|
|
21
|
-
*/
|
|
22
|
-
export declare const useThemeRoot: () => HTMLElement | null;
|
|
23
10
|
interface ThemeProviderProps {
|
|
24
11
|
children: ReactNode;
|
|
25
12
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/ThemeProvider/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/ThemeProvider/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,KAAK,KAAK,EAAgB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAElF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,QAAO,gBAQ3B,CAAC;AAWF,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACrC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GAAI,4HAO3B,kBAAkB,gCA0DpB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { useState, useEffect, useMemo, useContext } from 'react';
|
|
3
|
+
import { ThemeContext } from './Theme.context.js';
|
|
3
4
|
|
|
4
|
-
const ThemeContext = createContext(undefined);
|
|
5
5
|
/**
|
|
6
6
|
* Reads the current theme and its setter from the nearest `ThemeProvider`.
|
|
7
7
|
*
|
|
@@ -15,13 +15,6 @@ const useTheme = () => {
|
|
|
15
15
|
}
|
|
16
16
|
return context;
|
|
17
17
|
};
|
|
18
|
-
/**
|
|
19
|
-
* The element the app's theme cascades from: in a micro-frontend, its whole mount. Unlike `useTheme` it never throws,
|
|
20
|
-
* so a component can adapt to the app's root without requiring the provider.
|
|
21
|
-
*
|
|
22
|
-
* @returns The themed root, or `null` outside a `ThemeProvider` or before it has mounted.
|
|
23
|
-
*/
|
|
24
|
-
const useThemeRoot = () => useContext(ThemeContext)?.themeRoot ?? null;
|
|
25
18
|
// Providers currently mirroring onto <html>, so a page with several (a Storybook docs page mounts one per
|
|
26
19
|
// story) only loses the attribute when the last one unmounts.
|
|
27
20
|
let documentThemeWriters = 0;
|
|
@@ -88,5 +81,5 @@ const ThemeProvider = ({ children, defaultTheme = 'system', storageKey, themeMod
|
|
|
88
81
|
return (jsx(ThemeContext.Provider, { value: contextValue, children: jsx("div", { ref: setThemeRoot, "data-theme": resolvedMode, "data-mfe-scope": scopeId, style: { display: 'contents' }, children: children }) }));
|
|
89
82
|
};
|
|
90
83
|
|
|
91
|
-
export { ThemeProvider, useTheme
|
|
84
|
+
export { ThemeProvider, useTheme };
|
|
92
85
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/providers/ThemeProvider/index.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/providers/ThemeProvider/index.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;AAMA;;;;;AAKG;AACI,MAAM,QAAQ,GAAG,MAAuB;AAC7C,IAAA,MAAM,OAAO,GAAG,UAAU,CAAC,YAAY,CAAC;AAExC,IAAA,IAAI,OAAO,KAAK,SAAS,EAAE;AACzB,QAAA,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC;IACjE;AAEA,IAAA,OAAO,OAAO;AAChB;AAEA;AACA;AACA,IAAI,oBAAoB,GAAG,CAAC;AAE5B,MAAM,uBAAuB,GAAG,MAAuB;IACrD,IAAI,OAAO,MAAM,KAAK,WAAW;AAAE,QAAA,OAAO,OAAO;AACjD,IAAA,OAAO,MAAM,CAAC,UAAU,CAAC,8BAA8B,CAAC,CAAC,OAAO,GAAG,MAAM,GAAG,OAAO;AACrF,CAAC;AAkCD;;;;;;;AAOG;AACI,MAAM,aAAa,GAAG,CAAC,EAC5B,QAAQ,EACR,YAAY,GAAG,QAAQ,EACvB,UAAU,EACV,iBAAiB,EACjB,OAAO,EAAE,WAAW,EACpB,iBAAiB,EAAE,qBAAqB,GACrB,KAA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so it
|
|
5
|
+
* reaches an overlay in another React root, as a host's panel reaches a micro-frontend's slideout.
|
|
6
|
+
*/
|
|
7
|
+
const PAGE_COVER_EVENT = 'fd-page-cover';
|
|
8
|
+
/**
|
|
9
|
+
* Announces that a panel has started covering the page.
|
|
10
|
+
*
|
|
11
|
+
* @param panel The panel now covering the page.
|
|
12
|
+
*/
|
|
13
|
+
const dispatchPageCover = (panel) => {
|
|
14
|
+
panel.dispatchEvent(new CustomEvent(PAGE_COVER_EVENT, { bubbles: true }));
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Listens for any panel starting to cover the page.
|
|
18
|
+
*
|
|
19
|
+
* @param listener Runs on each cover.
|
|
20
|
+
* @returns Stops listening.
|
|
21
|
+
*/
|
|
22
|
+
const subscribePageCover = (listener) => {
|
|
23
|
+
document.addEventListener(PAGE_COVER_EVENT, listener);
|
|
24
|
+
return () => document.removeEventListener(PAGE_COVER_EVENT, listener);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.PAGE_COVER_EVENT = PAGE_COVER_EVENT;
|
|
28
|
+
exports.dispatchPageCover = dispatchPageCover;
|
|
29
|
+
exports.subscribePageCover = subscribePageCover;
|
|
30
|
+
//# sourceMappingURL=pageCover.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pageCover.utils.cjs","sources":["../../../../src/utilities/__internal__/pageCoverUtils/pageCover.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;AAGG;AACI,MAAM,gBAAgB,GAAG;AAEhC;;;;AAIG;AACI,MAAM,iBAAiB,GAAG,CAAC,KAAkB,KAAU;AAC5D,IAAA,KAAK,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,gBAAgB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AAC3E;AAEA;;;;;AAKG;AACI,MAAM,kBAAkB,GAAG,CAAC,QAAoB,KAAkB;AACvE,IAAA,QAAQ,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,QAAQ,CAAC;IACrD,OAAO,MAAM,QAAQ,CAAC,mBAAmB,CAAC,gBAAgB,EAAE,QAAQ,CAAC;AACvE;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fired on a side panel, bubbling, as it starts covering the page below `lg`. A DOM event rather than context, so it
|
|
3
|
+
* reaches an overlay in another React root, as a host's panel reaches a micro-frontend's slideout.
|
|
4
|
+
*/
|
|
5
|
+
export declare const PAGE_COVER_EVENT = "fd-page-cover";
|
|
6
|
+
/**
|
|
7
|
+
* Announces that a panel has started covering the page.
|
|
8
|
+
*
|
|
9
|
+
* @param panel The panel now covering the page.
|
|
10
|
+
*/
|
|
11
|
+
export declare const dispatchPageCover: (panel: HTMLElement) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Listens for any panel starting to cover the page.
|
|
14
|
+
*
|
|
15
|
+
* @param listener Runs on each cover.
|
|
16
|
+
* @returns Stops listening.
|
|
17
|
+
*/
|
|
18
|
+
export declare const subscribePageCover: (listener: () => void) => (() => void);
|
|
19
|
+
//# sourceMappingURL=pageCover.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pageCover.utils.d.ts","sourceRoot":"","sources":["../../../../src/utilities/__internal__/pageCoverUtils/pageCover.utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,WAAW,KAAG,IAEtD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,MAAM,IAAI,KAAG,CAAC,MAAM,IAAI,CAGpE,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fired on a side panel, bubbling, as it starts covering the page below `lg`. A DOM event rather than context, so it
|
|
3
|
+
* reaches an overlay in another React root, as a host's panel reaches a micro-frontend's slideout.
|
|
4
|
+
*/
|
|
5
|
+
const PAGE_COVER_EVENT = 'fd-page-cover';
|
|
6
|
+
/**
|
|
7
|
+
* Announces that a panel has started covering the page.
|
|
8
|
+
*
|
|
9
|
+
* @param panel The panel now covering the page.
|
|
10
|
+
*/
|
|
11
|
+
const dispatchPageCover = (panel) => {
|
|
12
|
+
panel.dispatchEvent(new CustomEvent(PAGE_COVER_EVENT, { bubbles: true }));
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Listens for any panel starting to cover the page.
|
|
16
|
+
*
|
|
17
|
+
* @param listener Runs on each cover.
|
|
18
|
+
* @returns Stops listening.
|
|
19
|
+
*/
|
|
20
|
+
const subscribePageCover = (listener) => {
|
|
21
|
+
document.addEventListener(PAGE_COVER_EVENT, listener);
|
|
22
|
+
return () => document.removeEventListener(PAGE_COVER_EVENT, listener);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { PAGE_COVER_EVENT, dispatchPageCover, subscribePageCover };
|
|
26
|
+
//# sourceMappingURL=pageCover.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pageCover.utils.js","sources":["../../../../src/utilities/__internal__/pageCoverUtils/pageCover.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;AAGG;AACI,MAAM,gBAAgB,GAAG;AAEhC;;;;AAIG;AACI,MAAM,iBAAiB,GAAG,CAAC,KAAkB,KAAU;AAC5D,IAAA,KAAK,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,gBAAgB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AAC3E;AAEA;;;;;AAKG;AACI,MAAM,kBAAkB,GAAG,CAAC,QAAoB,KAAkB;AACvE,IAAA,QAAQ,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,QAAQ,CAAC;IACrD,OAAO,MAAM,QAAQ,CAAC,mBAAmB,CAAC,gBAAgB,EAAE,QAAQ,CAAC;AACvE;;"}
|