@nswds/app 1.29.0 → 1.30.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/index.cjs +43 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +43 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -9393,14 +9393,54 @@ var TocContext = React6.createContext({
|
|
|
9393
9393
|
function TocProvider({ children }) {
|
|
9394
9394
|
const [toc, setToc] = React6.useState(true);
|
|
9395
9395
|
const pathname = navigation.usePathname();
|
|
9396
|
+
const isInitialMount = React6.useRef(true);
|
|
9397
|
+
const tocExplicitlySet = React6.useRef(false);
|
|
9396
9398
|
React6.useEffect(() => {
|
|
9399
|
+
if (isInitialMount.current) {
|
|
9400
|
+
isInitialMount.current = false;
|
|
9401
|
+
return;
|
|
9402
|
+
}
|
|
9403
|
+
tocExplicitlySet.current = false;
|
|
9397
9404
|
setToc(true);
|
|
9398
9405
|
}, [pathname]);
|
|
9399
|
-
|
|
9406
|
+
const handleSetToc = (value) => {
|
|
9407
|
+
tocExplicitlySet.current = true;
|
|
9408
|
+
setToc(value);
|
|
9409
|
+
};
|
|
9410
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TocContext.Provider, { value: { toc, setToc: handleSetToc }, children });
|
|
9400
9411
|
}
|
|
9401
9412
|
function useToc() {
|
|
9402
9413
|
return React6.useContext(TocContext);
|
|
9403
9414
|
}
|
|
9415
|
+
var MOBILE_BREAKPOINT = 768;
|
|
9416
|
+
function useIsMobile() {
|
|
9417
|
+
const [isMobile, setIsMobile] = React6__namespace.useState(void 0);
|
|
9418
|
+
React6__namespace.useEffect(() => {
|
|
9419
|
+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
9420
|
+
const onChange = () => {
|
|
9421
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
9422
|
+
};
|
|
9423
|
+
mql.addEventListener("change", onChange);
|
|
9424
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
9425
|
+
return () => mql.removeEventListener("change", onChange);
|
|
9426
|
+
}, []);
|
|
9427
|
+
return !!isMobile;
|
|
9428
|
+
}
|
|
9429
|
+
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React6.useLayoutEffect : React6.useEffect;
|
|
9430
|
+
function useDisableToc() {
|
|
9431
|
+
const { setToc } = useToc();
|
|
9432
|
+
useIsomorphicLayoutEffect(() => {
|
|
9433
|
+
setToc(false);
|
|
9434
|
+
}, [setToc]);
|
|
9435
|
+
React6.useEffect(() => {
|
|
9436
|
+
const raf = requestAnimationFrame(() => {
|
|
9437
|
+
setToc(false);
|
|
9438
|
+
});
|
|
9439
|
+
return () => {
|
|
9440
|
+
cancelAnimationFrame(raf);
|
|
9441
|
+
};
|
|
9442
|
+
}, [setToc]);
|
|
9443
|
+
}
|
|
9404
9444
|
function getNodeText(node) {
|
|
9405
9445
|
let text = "";
|
|
9406
9446
|
for (const child of node.children ?? []) {
|
|
@@ -9784,7 +9824,9 @@ exports.themeIndices = themeIndices;
|
|
|
9784
9824
|
exports.themeTokens = themeTokens;
|
|
9785
9825
|
exports.toggleVariants = toggleVariants;
|
|
9786
9826
|
exports.truncate = truncate;
|
|
9827
|
+
exports.useDisableToc = useDisableToc;
|
|
9787
9828
|
exports.useFormField = useFormField;
|
|
9829
|
+
exports.useIsMobile = useIsMobile;
|
|
9788
9830
|
exports.useToc = useToc;
|
|
9789
9831
|
//# sourceMappingURL=index.cjs.map
|
|
9790
9832
|
//# sourceMappingURL=index.cjs.map
|