@sereno-ds/ui 0.41.2 → 0.41.4

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.
Files changed (39) hide show
  1. package/dist/_internal/useIsoLayoutEffect.d.ts +1 -1
  2. package/dist/_internal/useOutsidePress.d.ts +15 -0
  3. package/dist/_internal/useOutsidePress.js +20 -0
  4. package/dist/_internal/useOutsidePress.js.map +1 -0
  5. package/dist/core/Menu.js +2 -10
  6. package/dist/core/Menu.js.map +1 -1
  7. package/dist/forms/Autocomplete.js +2 -11
  8. package/dist/forms/Autocomplete.js.map +1 -1
  9. package/dist/forms/AvatarUpload.js +3 -258
  10. package/dist/forms/AvatarUpload.js.map +1 -1
  11. package/dist/forms/DatePicker.js +3 -11
  12. package/dist/forms/DatePicker.js.map +1 -1
  13. package/dist/forms/Select.js +2 -10
  14. package/dist/forms/Select.js.map +1 -1
  15. package/dist/forms/_internal/AvatarCaptureDialog.d.ts +28 -0
  16. package/dist/forms/_internal/AvatarCaptureDialog.js +127 -0
  17. package/dist/forms/_internal/AvatarCaptureDialog.js.map +1 -0
  18. package/dist/forms/_internal/CalendarGrid.js +6 -11
  19. package/dist/forms/_internal/CalendarGrid.js.map +1 -1
  20. package/dist/forms/_internal/useCamera.d.ts +12 -0
  21. package/dist/forms/_internal/useCamera.js +58 -0
  22. package/dist/forms/_internal/useCamera.js.map +1 -0
  23. package/dist/forms/_internal/useCropper.d.ts +27 -0
  24. package/dist/forms/_internal/useCropper.js +92 -0
  25. package/dist/forms/_internal/useCropper.js.map +1 -0
  26. package/dist/index.d.ts +2 -1
  27. package/dist/navigation/SidebarNav.d.ts +3 -43
  28. package/dist/navigation/SidebarNav.js +4 -415
  29. package/dist/navigation/SidebarNav.js.map +1 -1
  30. package/dist/navigation/_internal/SidebarNavItems.d.ts +46 -0
  31. package/dist/navigation/_internal/SidebarNavItems.js +299 -0
  32. package/dist/navigation/_internal/SidebarNavItems.js.map +1 -0
  33. package/dist/navigation/_internal/SidebarSubmenuPopover.d.ts +13 -0
  34. package/dist/navigation/_internal/SidebarSubmenuPopover.js +129 -0
  35. package/dist/navigation/_internal/SidebarSubmenuPopover.js.map +1 -0
  36. package/dist/navigation/_internal/sidebarNavContext.d.ts +24 -0
  37. package/dist/navigation/_internal/sidebarNavContext.js +14 -0
  38. package/dist/navigation/_internal/sidebarNavContext.js.map +1 -0
  39. package/package.json +1 -1
@@ -0,0 +1,58 @@
1
+ import * as React from "react";
2
+ function useCamera(active, onError) {
3
+ const videoRef = React.useRef(null);
4
+ const streamRef = React.useRef(null);
5
+ const [ready, setReady] = React.useState(false);
6
+ const onErrorRef = React.useRef(onError);
7
+ React.useEffect(() => {
8
+ onErrorRef.current = onError;
9
+ });
10
+ React.useEffect(() => {
11
+ if (!active) return;
12
+ let cancelled = false;
13
+ let started = null;
14
+ const md = typeof navigator !== "undefined" ? navigator.mediaDevices : void 0;
15
+ if (!md?.getUserMedia) {
16
+ onErrorRef.current();
17
+ return;
18
+ }
19
+ md.getUserMedia({ video: { facingMode: "user", width: { ideal: 1280 }, height: { ideal: 1280 } }, audio: false }).then((s) => {
20
+ if (cancelled) {
21
+ s.getTracks().forEach((tr) => tr.stop());
22
+ return;
23
+ }
24
+ started = s;
25
+ streamRef.current = s;
26
+ if (videoRef.current) videoRef.current.srcObject = s;
27
+ setReady(true);
28
+ }).catch(() => onErrorRef.current());
29
+ return () => {
30
+ cancelled = true;
31
+ started?.getTracks().forEach((tr) => tr.stop());
32
+ streamRef.current = null;
33
+ setReady(false);
34
+ };
35
+ }, [active]);
36
+ const attachVideo = React.useCallback((el) => {
37
+ videoRef.current = el;
38
+ if (el && streamRef.current) el.srcObject = streamRef.current;
39
+ }, []);
40
+ const shoot = (onShot) => {
41
+ const v = videoRef.current;
42
+ if (!v || !v.videoWidth) return;
43
+ const s = Math.min(v.videoWidth, v.videoHeight);
44
+ const canvas = document.createElement("canvas");
45
+ canvas.width = canvas.height = s;
46
+ const ctx = canvas.getContext("2d");
47
+ if (!ctx) return;
48
+ ctx.translate(s, 0);
49
+ ctx.scale(-1, 1);
50
+ ctx.drawImage(v, (v.videoWidth - s) / 2, (v.videoHeight - s) / 2, s, s, 0, 0, s, s);
51
+ canvas.toBlob((b) => b && onShot(b), "image/jpeg", 0.9);
52
+ };
53
+ return { attachVideo, ready, shoot };
54
+ }
55
+ export {
56
+ useCamera
57
+ };
58
+ //# sourceMappingURL=useCamera.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/forms/_internal/useCamera.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * Live camera via `getUserMedia`, while `active`. A failure (no API, permission denied)\n * goes through `onError`. `ready` turns true once the stream is flowing; going inactive\n * stops the tracks, so the camera light goes off as soon as the dialog leaves this step.\n */\nexport function useCamera(active: boolean, onError: () => void) {\n const videoRef = React.useRef<HTMLVideoElement | null>(null);\n const streamRef = React.useRef<MediaStream | null>(null);\n const [ready, setReady] = React.useState(false);\n // Read through a ref so a new `onError` closure each render does not restart the camera.\n const onErrorRef = React.useRef(onError);\n React.useEffect(() => {\n onErrorRef.current = onError;\n });\n\n React.useEffect(() => {\n if (!active) return;\n let cancelled = false;\n let started: MediaStream | null = null;\n const md = typeof navigator !== 'undefined' ? navigator.mediaDevices : undefined;\n if (!md?.getUserMedia) {\n onErrorRef.current();\n return;\n }\n md.getUserMedia({ video: { facingMode: 'user', width: { ideal: 1280 }, height: { ideal: 1280 } }, audio: false })\n .then((s) => {\n if (cancelled) {\n s.getTracks().forEach((tr) => tr.stop());\n return;\n }\n started = s;\n streamRef.current = s;\n if (videoRef.current) videoRef.current.srcObject = s;\n setReady(true);\n })\n .catch(() => onErrorRef.current());\n return () => {\n cancelled = true;\n started?.getTracks().forEach((tr) => tr.stop());\n streamRef.current = null;\n setReady(false);\n };\n }, [active]);\n\n // The `<video>` may mount after the stream arrives (`Dialog` renders its children a render\n // late) or the other way round, so wire them up whichever comes last: here for the element,\n // above for the stream.\n const attachVideo = React.useCallback((el: HTMLVideoElement | null) => {\n videoRef.current = el;\n if (el && streamRef.current) el.srcObject = streamRef.current;\n }, []);\n\n /** Grabs the centred square of the current frame, mirrored like the preview, as a JPEG. */\n const shoot = (onShot: (b: Blob) => void) => {\n const v = videoRef.current;\n if (!v || !v.videoWidth) return;\n const s = Math.min(v.videoWidth, v.videoHeight);\n const canvas = document.createElement('canvas');\n canvas.width = canvas.height = s;\n const ctx = canvas.getContext('2d');\n if (!ctx) return;\n ctx.translate(s, 0);\n ctx.scale(-1, 1);\n ctx.drawImage(v, (v.videoWidth - s) / 2, (v.videoHeight - s) / 2, s, s, 0, 0, s, s);\n canvas.toBlob((b) => b && onShot(b), 'image/jpeg', 0.9);\n };\n\n return { attachVideo, ready, shoot };\n}\n"],"mappings":"AAAA,YAAY,WAAW;AAOhB,SAAS,UAAU,QAAiB,SAAqB;AAC9D,QAAM,WAAW,MAAM,OAAgC,IAAI;AAC3D,QAAM,YAAY,MAAM,OAA2B,IAAI;AACvD,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,KAAK;AAE9C,QAAM,aAAa,MAAM,OAAO,OAAO;AACvC,QAAM,UAAU,MAAM;AACpB,eAAW,UAAU;AAAA,EACvB,CAAC;AAED,QAAM,UAAU,MAAM;AACpB,QAAI,CAAC,OAAQ;AACb,QAAI,YAAY;AAChB,QAAI,UAA8B;AAClC,UAAM,KAAK,OAAO,cAAc,cAAc,UAAU,eAAe;AACvE,QAAI,CAAC,IAAI,cAAc;AACrB,iBAAW,QAAQ;AACnB;AAAA,IACF;AACA,OAAG,aAAa,EAAE,OAAO,EAAE,YAAY,QAAQ,OAAO,EAAE,OAAO,KAAK,GAAG,QAAQ,EAAE,OAAO,KAAK,EAAE,GAAG,OAAO,MAAM,CAAC,EAC7G,KAAK,CAAC,MAAM;AACX,UAAI,WAAW;AACb,UAAE,UAAU,EAAE,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;AACvC;AAAA,MACF;AACA,gBAAU;AACV,gBAAU,UAAU;AACpB,UAAI,SAAS,QAAS,UAAS,QAAQ,YAAY;AACnD,eAAS,IAAI;AAAA,IACf,CAAC,EACA,MAAM,MAAM,WAAW,QAAQ,CAAC;AACnC,WAAO,MAAM;AACX,kBAAY;AACZ,eAAS,UAAU,EAAE,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;AAC9C,gBAAU,UAAU;AACpB,eAAS,KAAK;AAAA,IAChB;AAAA,EACF,GAAG,CAAC,MAAM,CAAC;AAKX,QAAM,cAAc,MAAM,YAAY,CAAC,OAAgC;AACrE,aAAS,UAAU;AACnB,QAAI,MAAM,UAAU,QAAS,IAAG,YAAY,UAAU;AAAA,EACxD,GAAG,CAAC,CAAC;AAGL,QAAM,QAAQ,CAAC,WAA8B;AAC3C,UAAM,IAAI,SAAS;AACnB,QAAI,CAAC,KAAK,CAAC,EAAE,WAAY;AACzB,UAAM,IAAI,KAAK,IAAI,EAAE,YAAY,EAAE,WAAW;AAC9C,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,WAAO,QAAQ,OAAO,SAAS;AAC/B,UAAM,MAAM,OAAO,WAAW,IAAI;AAClC,QAAI,CAAC,IAAK;AACV,QAAI,UAAU,GAAG,CAAC;AAClB,QAAI,MAAM,IAAI,CAAC;AACf,QAAI,UAAU,IAAI,EAAE,aAAa,KAAK,IAAI,EAAE,cAAc,KAAK,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAClF,WAAO,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC,GAAG,cAAc,GAAG;AAAA,EACxD;AAEA,SAAO,EAAE,aAAa,OAAO,MAAM;AACrC;","names":[]}
@@ -0,0 +1,27 @@
1
+ import * as React from 'react';
2
+
3
+ /**
4
+ * The crop state and math for one picked photo (`src`): pan, zoom, the stage's live size,
5
+ * and the export. It lives above the dialog, not inside the crop step, so the header, body
6
+ * and footer of a single `Dialog` can all read it while the camera step swaps in and out.
7
+ * Everything resets when `src` changes, so a retaken photo starts centred at 1x.
8
+ */
9
+ declare function useCropper(src: string | null, outputSize: number): {
10
+ setImgEl: React.Dispatch<React.SetStateAction<HTMLImageElement | null>>;
11
+ setStageEl: React.Dispatch<React.SetStateAction<HTMLDivElement | null>>;
12
+ zoom: number;
13
+ setZoomAt: (nextZoom: number) => void;
14
+ offset: {
15
+ x: number;
16
+ y: number;
17
+ };
18
+ dispW: number;
19
+ dispH: number;
20
+ onImgLoad: (el: HTMLImageElement) => void;
21
+ onPointerDown: (e: React.PointerEvent) => void;
22
+ onPointerMove: (e: React.PointerEvent) => void;
23
+ onPointerUp: () => void;
24
+ save: (onSave: (b: Blob) => void) => void;
25
+ };
26
+
27
+ export { useCropper };
@@ -0,0 +1,92 @@
1
+ import * as React from "react";
2
+ const DEFAULT_STAGE = 280;
3
+ function useCropper(src, outputSize) {
4
+ const [imgEl, setImgEl] = React.useState(null);
5
+ const [stageEl, setStageEl] = React.useState(null);
6
+ const [V, setV] = React.useState(DEFAULT_STAGE);
7
+ const prevV = React.useRef(V);
8
+ const [nat, setNat] = React.useState(null);
9
+ const [zoom, setZoom] = React.useState(1);
10
+ const [offset, setOffset] = React.useState({ x: 0, y: 0 });
11
+ const drag = React.useRef(null);
12
+ const [seenSrc, setSeenSrc] = React.useState(src);
13
+ if (src !== seenSrc) {
14
+ setSeenSrc(src);
15
+ setNat(null);
16
+ setZoom(1);
17
+ setOffset({ x: 0, y: 0 });
18
+ }
19
+ React.useEffect(() => {
20
+ if (!stageEl) return;
21
+ const ro = new ResizeObserver((entries) => {
22
+ const w = Math.round(entries[0]?.contentRect.width ?? 0);
23
+ if (!w || w === prevV.current) return;
24
+ const factor = w / prevV.current;
25
+ prevV.current = w;
26
+ setV(w);
27
+ setOffset((o) => ({ x: o.x * factor, y: o.y * factor }));
28
+ });
29
+ ro.observe(stageEl);
30
+ return () => ro.disconnect();
31
+ }, [stageEl]);
32
+ const scaleMin = nat ? V / Math.min(nat.w, nat.h) : 1;
33
+ const scale = scaleMin * zoom;
34
+ const dispW = nat ? nat.w * scale : V;
35
+ const dispH = nat ? nat.h * scale : V;
36
+ const clamp = React.useCallback(
37
+ (o) => ({
38
+ x: Math.min(0, Math.max(V - dispW, o.x)),
39
+ y: Math.min(0, Math.max(V - dispH, o.y))
40
+ }),
41
+ [V, dispW, dispH]
42
+ );
43
+ const onImgLoad = (el) => {
44
+ const w = el.naturalWidth;
45
+ const h = el.naturalHeight;
46
+ setNat({ w, h });
47
+ const s = V / Math.min(w, h);
48
+ setOffset({ x: (V - w * s) / 2, y: (V - h * s) / 2 });
49
+ };
50
+ const setZoomAt = (nextZoom) => {
51
+ const z = Math.min(3, Math.max(1, nextZoom));
52
+ setZoom((prevZ) => {
53
+ const oldScale = scaleMin * prevZ;
54
+ const newScale = scaleMin * z;
55
+ setOffset((o) => {
56
+ const imgX = (V / 2 - o.x) / oldScale;
57
+ const imgY = (V / 2 - o.y) / oldScale;
58
+ return clamp({ x: V / 2 - imgX * newScale, y: V / 2 - imgY * newScale });
59
+ });
60
+ return z;
61
+ });
62
+ };
63
+ const onPointerDown = (e) => {
64
+ e.target.setPointerCapture(e.pointerId);
65
+ drag.current = { x: e.clientX, y: e.clientY };
66
+ };
67
+ const onPointerMove = (e) => {
68
+ if (!drag.current) return;
69
+ const dx = e.clientX - drag.current.x;
70
+ const dy = e.clientY - drag.current.y;
71
+ drag.current = { x: e.clientX, y: e.clientY };
72
+ setOffset((o) => clamp({ x: o.x + dx, y: o.y + dy }));
73
+ };
74
+ const onPointerUp = () => {
75
+ drag.current = null;
76
+ };
77
+ const save = (onSave) => {
78
+ if (!imgEl || !nat) return;
79
+ const canvas = document.createElement("canvas");
80
+ canvas.width = canvas.height = outputSize;
81
+ const ctx = canvas.getContext("2d");
82
+ if (!ctx) return;
83
+ const sSize = V / scale;
84
+ ctx.drawImage(imgEl, -offset.x / scale, -offset.y / scale, sSize, sSize, 0, 0, outputSize, outputSize);
85
+ canvas.toBlob((b) => b && onSave(b), "image/jpeg", 0.85);
86
+ };
87
+ return { setImgEl, setStageEl, zoom, setZoomAt, offset, dispW, dispH, onImgLoad, onPointerDown, onPointerMove, onPointerUp, save };
88
+ }
89
+ export {
90
+ useCropper
91
+ };
92
+ //# sourceMappingURL=useCropper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/forms/_internal/useCropper.ts"],"sourcesContent":["import * as React from 'react';\n\nconst DEFAULT_STAGE = 280; // crop stage's assumed size (px) before its own ResizeObserver measures it\n\n/**\n * The crop state and math for one picked photo (`src`): pan, zoom, the stage's live size,\n * and the export. It lives above the dialog, not inside the crop step, so the header, body\n * and footer of a single `Dialog` can all read it while the camera step swaps in and out.\n * Everything resets when `src` changes, so a retaken photo starts centred at 1x.\n */\nexport function useCropper(src: string | null, outputSize: number) {\n const [imgEl, setImgEl] = React.useState<HTMLImageElement | null>(null);\n // A *callback* ref (kept as state), not a plain `useRef` + a `[]`-effect: `Dialog` renders\n // its children only from the render *after* its own `mounted` flips true (SSR-safe portal),\n // so on the stage's very first mount a `useEffect(..., [])` reading `stageRef.current` at\n // that point would still see `null` and, with no deps to fire again on, never retry, so `V`\n // would then stay stuck at the `DEFAULT_STAGE` guess forever (this exact bug, caught live:\n // the displayed image stayed 280px inside a stage CSS had already sized at ~344px, a gray\n // gap on two edges). The callback fires the moment React actually attaches the node.\n const [stageEl, setStageEl] = React.useState<HTMLDivElement | null>(null);\n // The stage's own live rendered size (it's `width: 100%` of the dialog body now, not a\n // fixed px box), read via ResizeObserver. `DEFAULT_STAGE` is only the guess for the very\n // first paint, before the observer's first callback lands.\n const [V, setV] = React.useState(DEFAULT_STAGE);\n const prevV = React.useRef(V);\n const [nat, setNat] = React.useState<{ w: number; h: number } | null>(null);\n const [zoom, setZoom] = React.useState(1);\n const [offset, setOffset] = React.useState({ x: 0, y: 0 });\n const drag = React.useRef<{ x: number; y: number } | null>(null);\n\n // A new photo starts from scratch. Adjusting state while rendering (rather than in an\n // effect) means the stale pan / zoom is never painted against the new image.\n const [seenSrc, setSeenSrc] = React.useState(src);\n if (src !== seenSrc) {\n setSeenSrc(src);\n setNat(null);\n setZoom(1);\n setOffset({ x: 0, y: 0 });\n }\n\n React.useEffect(() => {\n if (!stageEl) return;\n const ro = new ResizeObserver((entries) => {\n const w = Math.round(entries[0]?.contentRect.width ?? 0);\n if (!w || w === prevV.current) return;\n // A live resize while the dialog is open (a phone rotated, a window resized) or the\n // very first real measurement replacing `DEFAULT_STAGE`: rescale the pan offset by\n // the same factor as the viewport itself, so the framed crop doesn't jump. `scale`\n // (see below) is linear in `V`, so multiplying the offset by `newV / oldV` keeps\n // the same fraction of the image framed.\n const factor = w / prevV.current;\n prevV.current = w;\n setV(w);\n setOffset((o) => ({ x: o.x * factor, y: o.y * factor }));\n });\n ro.observe(stageEl);\n return () => ro.disconnect();\n }, [stageEl]);\n\n const scaleMin = nat ? V / Math.min(nat.w, nat.h) : 1;\n const scale = scaleMin * zoom;\n const dispW = nat ? nat.w * scale : V;\n const dispH = nat ? nat.h * scale : V;\n\n const clamp = React.useCallback(\n (o: { x: number; y: number }) => ({\n x: Math.min(0, Math.max(V - dispW, o.x)),\n y: Math.min(0, Math.max(V - dispH, o.y)),\n }),\n [V, dispW, dispH],\n );\n\n const onImgLoad = (el: HTMLImageElement) => {\n const w = el.naturalWidth;\n const h = el.naturalHeight;\n setNat({ w, h });\n const s = V / Math.min(w, h);\n setOffset({ x: (V - w * s) / 2, y: (V - h * s) / 2 });\n };\n\n const setZoomAt = (nextZoom: number) => {\n const z = Math.min(3, Math.max(1, nextZoom));\n setZoom((prevZ) => {\n const oldScale = scaleMin * prevZ;\n const newScale = scaleMin * z;\n setOffset((o) => {\n const imgX = (V / 2 - o.x) / oldScale;\n const imgY = (V / 2 - o.y) / oldScale;\n return clamp({ x: V / 2 - imgX * newScale, y: V / 2 - imgY * newScale });\n });\n return z;\n });\n };\n\n const onPointerDown = (e: React.PointerEvent) => {\n (e.target as HTMLElement).setPointerCapture(e.pointerId);\n drag.current = { x: e.clientX, y: e.clientY };\n };\n const onPointerMove = (e: React.PointerEvent) => {\n if (!drag.current) return;\n const dx = e.clientX - drag.current.x;\n const dy = e.clientY - drag.current.y;\n drag.current = { x: e.clientX, y: e.clientY };\n setOffset((o) => clamp({ x: o.x + dx, y: o.y + dy }));\n };\n const onPointerUp = () => {\n drag.current = null;\n };\n\n const save = (onSave: (b: Blob) => void) => {\n if (!imgEl || !nat) return;\n const canvas = document.createElement('canvas');\n canvas.width = canvas.height = outputSize;\n const ctx = canvas.getContext('2d');\n if (!ctx) return;\n const sSize = V / scale;\n ctx.drawImage(imgEl, -offset.x / scale, -offset.y / scale, sSize, sSize, 0, 0, outputSize, outputSize);\n canvas.toBlob((b) => b && onSave(b), 'image/jpeg', 0.85);\n };\n\n return { setImgEl, setStageEl, zoom, setZoomAt, offset, dispW, dispH, onImgLoad, onPointerDown, onPointerMove, onPointerUp, save };\n}\n"],"mappings":"AAAA,YAAY,WAAW;AAEvB,MAAM,gBAAgB;AAQf,SAAS,WAAW,KAAoB,YAAoB;AACjE,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAkC,IAAI;AAQtE,QAAM,CAAC,SAAS,UAAU,IAAI,MAAM,SAAgC,IAAI;AAIxE,QAAM,CAAC,GAAG,IAAI,IAAI,MAAM,SAAS,aAAa;AAC9C,QAAM,QAAQ,MAAM,OAAO,CAAC;AAC5B,QAAM,CAAC,KAAK,MAAM,IAAI,MAAM,SAA0C,IAAI;AAC1E,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,CAAC;AACxC,QAAM,CAAC,QAAQ,SAAS,IAAI,MAAM,SAAS,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;AACzD,QAAM,OAAO,MAAM,OAAwC,IAAI;AAI/D,QAAM,CAAC,SAAS,UAAU,IAAI,MAAM,SAAS,GAAG;AAChD,MAAI,QAAQ,SAAS;AACnB,eAAW,GAAG;AACd,WAAO,IAAI;AACX,YAAQ,CAAC;AACT,cAAU,EAAE,GAAG,GAAG,GAAG,EA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OAAO,GAAG,GAAG,YAAY,UAAU;AACrG,WAAO,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC,GAAG,cAAc,IAAI;AAAA,EACzD;AAEA,SAAO,EAAE,UAAU,YAAY,MAAM,WAAW,QAAQ,OAAO,OAAO,WAAW,eAAe,eAAe,aAAa,KAAK;AACnI;","names":[]}
package/dist/index.d.ts CHANGED
@@ -27,7 +27,7 @@ export { SearchInput, SearchInputProps } from './forms/SearchInput.js';
27
27
  export { TopBar, TopBarActionsProps, TopBarLeadingProps, TopBarProps, TopBarTitleProps } from './navigation/TopBar.js';
28
28
  export { Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps } from './navigation/Tabs.js';
29
29
  export { BottomNav, BottomNavItemProps, BottomNavProps } from './navigation/BottomNav.js';
30
- export { SidebarNav, SidebarNavItemProps, SidebarNavProps, SidebarNavSectionProps, SidebarNavSubItemProps } from './navigation/SidebarNav.js';
30
+ export { SidebarNav, SidebarNavProps } from './navigation/SidebarNav.js';
31
31
  export { Stepper, StepperProps, StepperStepProps } from './navigation/Stepper.js';
32
32
  export { Pagination, PaginationLabels, PaginationProps } from './navigation/Pagination.js';
33
33
  export { Alert, AlertProps } from './feedback/Alert.js';
@@ -39,5 +39,6 @@ export { EmptyState, EmptyStateProps } from './feedback/EmptyState.js';
39
39
  export { ThemeProvider } from './theme/ThemeProvider.js';
40
40
  export { ThemeToggle } from './theme/ThemeToggle.js';
41
41
  export { CalendarDayContext, CalendarDayDot, CalendarDayDots, CalendarDotTone } from './forms/_internal/calendarDots.js';
42
+ export { SidebarNavItemProps, SidebarNavSectionProps, SidebarNavSubItemProps } from './navigation/_internal/SidebarNavItems.js';
42
43
  import 'react';
43
44
  import './_internal/mask.js';
@@ -1,4 +1,6 @@
1
1
  import * as React from 'react';
2
+ import { Section, Item, SubItem } from './_internal/SidebarNavItems.js';
3
+ export { SidebarNavItemProps, SidebarNavSectionProps, SidebarNavSubItemProps } from './_internal/SidebarNavItems.js';
2
4
 
3
5
  /**
4
6
  * Desktop primary navigation - a **compound component**, the counterpart to
@@ -50,53 +52,11 @@ interface SidebarNavProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onCha
50
52
  disabled?: boolean;
51
53
  children: React.ReactNode;
52
54
  }
53
- interface SidebarNavSectionProps {
54
- /** Small uppercase heading above the block. Omit for an unlabelled group - the divider still shows. */
55
- label?: string;
56
- children: React.ReactNode;
57
- }
58
- interface SidebarNavItemProps {
59
- value: string;
60
- label: string;
61
- /** A Lucide icon passed as a node - sized by the caller. */
62
- icon?: React.ReactNode;
63
- count?: number;
64
- /** Render this leaf as a real link (routing, new-tab, SSR-active) via `linkComponent`. Ignored while `disabled`. */
65
- href?: string;
66
- /**
67
- * Not selectable - e.g. a feature locked behind a higher plan. Inherits the
68
- * root's `disabled` when unset; an explicit `false` opts back in under a
69
- * disabled root.
70
- *
71
- * `aria-disabled` (not the native attribute), so the row is still in the
72
- * accessibility tree and a screen reader finds it - but it leaves the Tab
73
- * order (a locked area shouldn't cost a dead tab stop per item), a click
74
- * never fires `onChange`, `href` never navigates (it renders as a `<button>`,
75
- * never a link), and a parent `Item` doesn't toggle its accordion or open its
76
- * rail flyout. It can still be the current page: `value` pointing at it keeps
77
- * `aria-current` and the active look, just muted.
78
- */
79
- disabled?: boolean;
80
- /** `SidebarNav.SubItem`s - a second level. Present ⇒ this item is not a destination itself, it toggles them. */
81
- children?: React.ReactNode;
82
- }
83
- interface SidebarNavSubItemProps {
84
- value: string;
85
- label: string;
86
- count?: number;
87
- /** Not selectable. Inherits from its parent `Item` (which inherits the root); an explicit value wins. Same contract as `SidebarNav.Item`'s `disabled`. */
88
- disabled?: boolean;
89
- /** Set by the parent `Item` when rendering this into the collapsed rail's flyout popover - not for consumers to pass. */
90
- compact?: boolean;
91
- }
92
55
  declare function SidebarNavRoot({ value, onChange, collapsed: collapsedProp, defaultCollapsed, onCollapsedChange, collapsible, header, footer, labels, linkComponent, disabled, children, style, ...rest }: SidebarNavProps): React.JSX.Element;
93
- declare function Section({ label, children }: SidebarNavSectionProps): React.JSX.Element;
94
- declare function Item({ value, label, icon, count, href, disabled: disabledProp, children }: SidebarNavItemProps): React.JSX.Element;
95
- declare function SubItem({ value, label, count, disabled: disabledProp, compact }: SidebarNavSubItemProps): React.JSX.Element;
96
56
  declare const SidebarNav: typeof SidebarNavRoot & {
97
57
  Section: typeof Section;
98
58
  Item: typeof Item;
99
59
  SubItem: typeof SubItem;
100
60
  };
101
61
 
102
- export { SidebarNav, type SidebarNavItemProps, type SidebarNavProps, type SidebarNavSectionProps, type SidebarNavSubItemProps };
62
+ export { SidebarNav, type SidebarNavProps };