@nswds/app 1.73.0 → 1.75.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 +53 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -6
- package/dist/index.d.ts +5 -6
- package/dist/index.js +54 -37
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -49,7 +49,6 @@ var vaul = require('vaul');
|
|
|
49
49
|
var reactHookForm = require('react-hook-form');
|
|
50
50
|
var ToggleGroupPrimitive = require('@radix-ui/react-toggle-group');
|
|
51
51
|
var TogglePrimitive = require('@radix-ui/react-toggle');
|
|
52
|
-
var slugify = require('@sindresorhus/slugify');
|
|
53
52
|
var Image2 = require('next/image');
|
|
54
53
|
var HoverCardPrimitive = require('@radix-ui/react-hover-card');
|
|
55
54
|
var inputOtp = require('input-otp');
|
|
@@ -59,6 +58,7 @@ var ProgressPrimitive = require('@radix-ui/react-progress');
|
|
|
59
58
|
var tailwindVariants = require('tailwind-variants');
|
|
60
59
|
var ResizablePrimitive = require('react-resizable-panels');
|
|
61
60
|
var SliderPrimitive = require('@radix-ui/react-slider');
|
|
61
|
+
var slugify$1 = require('@sindresorhus/slugify');
|
|
62
62
|
var zustand = require('zustand');
|
|
63
63
|
var middleware = require('zustand/middleware');
|
|
64
64
|
|
|
@@ -17465,36 +17465,31 @@ function FormatToggle({ format, setFormat }) {
|
|
|
17465
17465
|
|
|
17466
17466
|
// package.json
|
|
17467
17467
|
var package_default = {
|
|
17468
|
-
version: "1.
|
|
17469
|
-
function
|
|
17470
|
-
|
|
17471
|
-
|
|
17472
|
-
|
|
17473
|
-
|
|
17474
|
-
|
|
17475
|
-
|
|
17476
|
-
|
|
17477
|
-
|
|
17478
|
-
|
|
17479
|
-
|
|
17480
|
-
|
|
17481
|
-
return out.trim();
|
|
17468
|
+
version: "1.74.0"};
|
|
17469
|
+
function flattenText(nodes) {
|
|
17470
|
+
if (nodes == null || typeof nodes === "boolean") return "";
|
|
17471
|
+
if (typeof nodes === "string" || typeof nodes === "number") return String(nodes);
|
|
17472
|
+
if (Array.isArray(nodes)) return nodes.map(flattenText).join("");
|
|
17473
|
+
if (React5.isValidElement(nodes)) {
|
|
17474
|
+
const { children } = nodes.props;
|
|
17475
|
+
return flattenText(children);
|
|
17476
|
+
}
|
|
17477
|
+
return "";
|
|
17478
|
+
}
|
|
17479
|
+
function slugify(input) {
|
|
17480
|
+
return input.toLowerCase().trim().replace(/[\s\W]+/g, "-").replace(/^-+|-+$/g, "");
|
|
17482
17481
|
}
|
|
17483
17482
|
function Heading({
|
|
17484
17483
|
className,
|
|
17485
17484
|
trim = "normal",
|
|
17486
|
-
id: id3,
|
|
17487
17485
|
size = 1,
|
|
17488
17486
|
level = 1,
|
|
17489
17487
|
display = false,
|
|
17488
|
+
id: idProp,
|
|
17490
17489
|
children,
|
|
17491
17490
|
...props
|
|
17492
17491
|
}) {
|
|
17493
|
-
const
|
|
17494
|
-
const slugify$1 = slugify.slugifyWithCounter();
|
|
17495
|
-
const computedId = id3 ?? slugify$1(textFromChildren(children));
|
|
17496
|
-
if (typeof window === "undefined") console.log("SSR id:", id3);
|
|
17497
|
-
else console.log("Client id:", id3);
|
|
17492
|
+
const Tag = `h${level}`;
|
|
17498
17493
|
const headingSizeClasses = {
|
|
17499
17494
|
1: "text-[calc(var(--heading-font-size-1)_*_var(--heading-font-size-adjust))] leading-[var(--line-height-52)] tracking-[calc(var(--heading-letter-spacing-2)_+_var(--heading-letter-spacing))]",
|
|
17500
17495
|
2: "text-[calc(var(--heading-font-size-2)_*_var(--heading-font-size-adjust))] leading-[var(--line-height-44)] tracking-[calc(var(--heading-letter-spacing-2)_+_var(--heading-letter-spacing))]",
|
|
@@ -17526,11 +17521,17 @@ function Heading({
|
|
|
17526
17521
|
"after:mt-[calc(var(--leading-trim-end,var(--default-leading-trim-end))-var(--line-height,calc(1em*var(--default-line-height)))/2)]"
|
|
17527
17522
|
]
|
|
17528
17523
|
};
|
|
17524
|
+
const computedId = React5.useMemo(() => {
|
|
17525
|
+
if (idProp) return idProp;
|
|
17526
|
+
const text = flattenText(children);
|
|
17527
|
+
return text ? slugify(text) : void 0;
|
|
17528
|
+
}, [idProp, children]);
|
|
17529
17529
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
17530
|
-
|
|
17530
|
+
Tag,
|
|
17531
17531
|
{
|
|
17532
17532
|
...props,
|
|
17533
17533
|
id: computedId,
|
|
17534
|
+
"data-anchor": true,
|
|
17534
17535
|
className: clsx12__default.default(
|
|
17535
17536
|
className,
|
|
17536
17537
|
trimClasses[trim],
|
|
@@ -29931,9 +29932,12 @@ function useActiveSectionObserver(tableOfContents) {
|
|
|
29931
29932
|
return currentSection;
|
|
29932
29933
|
}
|
|
29933
29934
|
function TableOfContents({ tableOfContents }) {
|
|
29934
|
-
const [
|
|
29935
|
-
React5.useEffect(() =>
|
|
29936
|
-
|
|
29935
|
+
const [ready, setReady] = React5.useState(false);
|
|
29936
|
+
React5.useEffect(() => {
|
|
29937
|
+
const raf = requestAnimationFrame(() => setReady(true));
|
|
29938
|
+
return () => cancelAnimationFrame(raf);
|
|
29939
|
+
}, []);
|
|
29940
|
+
const currentSection = useActiveSectionObserver(ready ? tableOfContents : []);
|
|
29937
29941
|
const isActive = React5.useMemo(() => {
|
|
29938
29942
|
const check = (section) => {
|
|
29939
29943
|
if (section.id === currentSection) return true;
|
|
@@ -29941,8 +29945,8 @@ function TableOfContents({ tableOfContents }) {
|
|
|
29941
29945
|
};
|
|
29942
29946
|
return check;
|
|
29943
29947
|
}, [currentSection]);
|
|
29944
|
-
return /* @__PURE__ */ jsxRuntime.jsx("nav", { "aria-labelledby": "on-this-page-title", className: "w-56", suppressHydrationWarning: true, children: !
|
|
29945
|
-
//
|
|
29948
|
+
return /* @__PURE__ */ jsxRuntime.jsx("nav", { "aria-labelledby": "on-this-page-title", className: "w-56", suppressHydrationWarning: true, children: !ready ? (
|
|
29949
|
+
// SSR + initial client paint: deterministic skeleton
|
|
29946
29950
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { "aria-hidden": true, className: "mt-3 space-y-2", children: [
|
|
29947
29951
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 w-40 animate-pulse rounded bg-black/10 dark:bg-white/10" }),
|
|
29948
29952
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-3 w-32 animate-pulse rounded bg-black/10 dark:bg-white/10" }),
|
|
@@ -30632,7 +30636,7 @@ function domToSimple(node) {
|
|
|
30632
30636
|
}
|
|
30633
30637
|
throw new Error("Unsupported node type");
|
|
30634
30638
|
}
|
|
30635
|
-
function getHeadings(
|
|
30639
|
+
function getHeadings(slugify2 = slugify$1.slugifyWithCounter()) {
|
|
30636
30640
|
const content = document.querySelector("article");
|
|
30637
30641
|
if (!content) {
|
|
30638
30642
|
return [];
|
|
@@ -30643,7 +30647,7 @@ function getHeadings(slugify$1 = slugify.slugifyWithCounter()) {
|
|
|
30643
30647
|
headings.forEach((el) => {
|
|
30644
30648
|
const simplifiedNode = domToSimple(el);
|
|
30645
30649
|
const title = getNodeText(simplifiedNode).trim();
|
|
30646
|
-
const slugifiedTitle =
|
|
30650
|
+
const slugifiedTitle = slugify2(title);
|
|
30647
30651
|
const id3 = el.id || slugifiedTitle;
|
|
30648
30652
|
const level = parseInt(el.tagName[1]);
|
|
30649
30653
|
const node = { level, id: id3, title, children: [] };
|
|
@@ -30666,14 +30670,27 @@ function getHeadings(slugify$1 = slugify.slugifyWithCounter()) {
|
|
|
30666
30670
|
}
|
|
30667
30671
|
function usePageHeadings() {
|
|
30668
30672
|
const [headings, setHeadings] = React5.useState([]);
|
|
30669
|
-
const pathname = navigation.usePathname();
|
|
30670
30673
|
React5.useEffect(() => {
|
|
30671
|
-
const
|
|
30672
|
-
|
|
30673
|
-
|
|
30674
|
-
|
|
30675
|
-
|
|
30676
|
-
|
|
30674
|
+
const raf = requestAnimationFrame(() => {
|
|
30675
|
+
setHeadings(getHeadings());
|
|
30676
|
+
});
|
|
30677
|
+
const observer = new MutationObserver(() => {
|
|
30678
|
+
setHeadings(getHeadings());
|
|
30679
|
+
});
|
|
30680
|
+
const article = document.querySelector("article");
|
|
30681
|
+
if (article) {
|
|
30682
|
+
observer.observe(article, {
|
|
30683
|
+
childList: true,
|
|
30684
|
+
subtree: true,
|
|
30685
|
+
attributes: true,
|
|
30686
|
+
attributeFilter: ["id"]
|
|
30687
|
+
});
|
|
30688
|
+
}
|
|
30689
|
+
return () => {
|
|
30690
|
+
cancelAnimationFrame(raf);
|
|
30691
|
+
observer.disconnect();
|
|
30692
|
+
};
|
|
30693
|
+
}, []);
|
|
30677
30694
|
return headings;
|
|
30678
30695
|
}
|
|
30679
30696
|
function createFormStore(opts) {
|