neatkit 0.6.0 → 0.8.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.
Files changed (154) hide show
  1. package/dist/Avatar-Belo7qAY.cjs +1 -0
  2. package/dist/Avatar-DjDCFqNG.js +55 -0
  3. package/dist/Avatar.cjs +1 -1
  4. package/dist/Avatar.js +2 -52
  5. package/dist/Boundary.cjs +1 -0
  6. package/dist/Boundary.js +176 -0
  7. package/dist/{Button-BAsLfA0D.js → Button-Chv4O66e.js} +35 -35
  8. package/dist/Button-DCKtFvSo.cjs +1 -0
  9. package/dist/Button.cjs +1 -1
  10. package/dist/Button.js +1 -1
  11. package/dist/Checkbox.cjs +1 -1
  12. package/dist/Checkbox.js +213 -2
  13. package/dist/Code-ClkozPlv.js +227 -0
  14. package/dist/Code-JDb4VFl7.cjs +4 -0
  15. package/dist/Code.cjs +1 -1
  16. package/dist/Code.js +1 -1
  17. package/dist/{Icon-uQmpr5P2.js → Icon-BoEUoOk7.js} +144 -177
  18. package/dist/Icon-DJ4BigRz.cjs +1 -0
  19. package/dist/Icon.cjs +1 -1
  20. package/dist/Icon.js +2 -35
  21. package/dist/Input.cjs +1 -1
  22. package/dist/Input.js +70 -79
  23. package/dist/Markdown.cjs +1 -31
  24. package/dist/Markdown.js +461 -18062
  25. package/dist/Modal.cjs +1 -1
  26. package/dist/Modal.js +100 -122
  27. package/dist/PinInput.cjs +1 -1
  28. package/dist/PinInput.js +1 -1
  29. package/dist/Popover.cjs +1 -1
  30. package/dist/Popover.js +106 -106
  31. package/dist/Radio.cjs +1 -1
  32. package/dist/Radio.js +86 -41
  33. package/dist/Select.cjs +1 -1
  34. package/dist/Select.js +326 -315
  35. package/dist/Sidebar.cjs +1 -0
  36. package/dist/Sidebar.js +475 -0
  37. package/dist/Skeleton.cjs +1 -1
  38. package/dist/Skeleton.js +20 -16
  39. package/dist/Switch.cjs +1 -1
  40. package/dist/Switch.js +1 -1
  41. package/dist/Table-B30TBckZ.js +402 -0
  42. package/dist/Table-DceR12X9.cjs +1 -0
  43. package/dist/Table.cjs +1 -1
  44. package/dist/Table.js +1 -1
  45. package/dist/TextArea.cjs +1 -1
  46. package/dist/TextArea.js +1 -1
  47. package/dist/Tooltip-B4bajPtk.cjs +1 -0
  48. package/dist/Tooltip-BVqdnKK_.js +231 -0
  49. package/dist/Tooltip.cjs +1 -1
  50. package/dist/Tooltip.js +2 -3
  51. package/dist/aria-Bntn6ad_.cjs +1 -0
  52. package/dist/aria-CeA9QfD1.js +15 -0
  53. package/dist/components/Boundary/Boundary.d.ts +65 -0
  54. package/dist/components/Boundary/contexts/BoundaryContext.d.ts +28 -0
  55. package/dist/components/Boundary/hooks/useBoundary.d.ts +19 -0
  56. package/dist/components/Boundary/hooks/useBoundaryWidth.d.ts +23 -0
  57. package/dist/components/Boundary/index.d.ts +2 -0
  58. package/dist/components/Boundary/utils/width.d.ts +11 -0
  59. package/dist/components/Checkbox/Checkbox.d.ts +9 -1
  60. package/dist/components/{CheckboxGroup → Checkbox/components}/CheckboxGroup.d.ts +2 -2
  61. package/dist/components/Checkbox/index.d.ts +1 -0
  62. package/dist/components/Checkbox/utils/checkbox-option.d.ts +17 -0
  63. package/dist/components/Icon/Icon.d.ts +1 -0
  64. package/dist/components/Icon/index.d.ts +0 -33
  65. package/dist/components/Input/Input.d.ts +1 -9
  66. package/dist/components/Modal/Modal.d.ts +0 -4
  67. package/dist/components/PinInput/PinInput.d.ts +1 -1
  68. package/dist/components/Popover/Popover.d.ts +2 -6
  69. package/dist/components/Portal/Portal.d.ts +11 -8
  70. package/dist/components/Portal/hooks/useDismissableLayer.d.ts +2 -0
  71. package/dist/components/Portal/hooks/useFloatingPosition.d.ts +4 -3
  72. package/dist/components/Portal/hooks/useFocusTrap.d.ts +2 -0
  73. package/dist/components/Portal/hooks/useScrollLock.d.ts +9 -3
  74. package/dist/components/Portal/utils/boundary-focus.d.ts +23 -0
  75. package/dist/components/Portal/utils/floating-position.d.ts +43 -9
  76. package/dist/components/Portal/utils/overlay-stack.d.ts +22 -10
  77. package/dist/components/Portal/utils/scroll-container.d.ts +13 -0
  78. package/dist/components/Radio/Radio.d.ts +9 -1
  79. package/dist/components/{RadioGroup → Radio/components}/RadioGroup.d.ts +9 -2
  80. package/dist/components/Radio/index.d.ts +1 -0
  81. package/dist/components/Select/Select.d.ts +0 -2
  82. package/dist/components/Select/utils/listbox-position.d.ts +28 -0
  83. package/dist/components/Sidebar/Sidebar.d.ts +108 -0
  84. package/dist/components/Sidebar/components/SidebarFooter.d.ts +19 -0
  85. package/dist/components/Sidebar/components/SidebarGroup.d.ts +42 -0
  86. package/dist/components/Sidebar/components/SidebarItem.d.ts +43 -0
  87. package/dist/components/Sidebar/components/SidebarOverlay.d.ts +38 -0
  88. package/dist/components/Sidebar/components/SidebarPanel.d.ts +47 -0
  89. package/dist/components/Sidebar/components/SidebarTrigger.d.ts +47 -0
  90. package/dist/components/Sidebar/components/SidebarUser.d.ts +59 -0
  91. package/dist/components/Sidebar/hooks/usePresentation.d.ts +14 -0
  92. package/dist/components/Sidebar/hooks/useSidebar.d.ts +9 -0
  93. package/dist/components/Sidebar/index.d.ts +2 -0
  94. package/dist/components/Sidebar/utils/state.d.ts +62 -0
  95. package/dist/components/Skeleton/Skeleton.d.ts +21 -5
  96. package/dist/components/Table/Table.d.ts +9 -49
  97. package/dist/components/Table/contexts/TableContext.d.ts +4 -0
  98. package/dist/components/Table/index.d.ts +1 -1
  99. package/dist/components/Tooltip/Tooltip.d.ts +10 -4
  100. package/dist/components/Tooltip/TooltipProvider.d.ts +1 -1
  101. package/dist/components/Tooltip/index.d.ts +0 -1
  102. package/dist/effects-D5CWf-Pl.js +8 -0
  103. package/dist/effects-D85L_7zM.cjs +1 -0
  104. package/dist/floating-position-5wJ5G5IT.js +48 -0
  105. package/dist/floating-position-Cy9xxdH4.cjs +1 -0
  106. package/dist/style.css +1 -1
  107. package/dist/tokens.d.ts +1 -0
  108. package/dist/useFloatingPosition-BBEUHPqy.cjs +1 -0
  109. package/dist/useFloatingPosition-CMirP2-2.js +43 -0
  110. package/dist/useFocusTrap-BrFZdMqQ.cjs +1 -0
  111. package/dist/useFocusTrap-DhVnlboe.js +136 -0
  112. package/dist/usePresence-B5RYv4e1.cjs +1 -0
  113. package/dist/usePresence-CqegYqy4.js +221 -0
  114. package/dist/useScrollLock-Drd7OZRC.js +62 -0
  115. package/dist/useScrollLock-Dy8MZaSn.cjs +1 -0
  116. package/dist/utils/aria.d.ts +9 -0
  117. package/dist/utils/effects.d.ts +12 -0
  118. package/package.json +11 -16
  119. package/dist/Button-D7JUO6Fs.cjs +0 -1
  120. package/dist/Checkbox-BvXM9VyY.js +0 -68
  121. package/dist/Checkbox-VQifZrZZ.cjs +0 -1
  122. package/dist/CheckboxGroup.cjs +0 -1
  123. package/dist/CheckboxGroup.js +0 -144
  124. package/dist/Code-BP2ZCmUf.js +0 -7446
  125. package/dist/Code-eispVOW3.cjs +0 -6
  126. package/dist/Content.cjs +0 -1
  127. package/dist/Content.js +0 -144
  128. package/dist/Icon-D8IZceys.cjs +0 -1
  129. package/dist/RadioGroup.cjs +0 -1
  130. package/dist/RadioGroup.js +0 -51
  131. package/dist/RadioGroupContext-BX9KnDek.cjs +0 -1
  132. package/dist/RadioGroupContext-DbKM4zPZ.js +0 -5
  133. package/dist/Table-83unQQOi.cjs +0 -1
  134. package/dist/Table-Cw8u-pEW.js +0 -403
  135. package/dist/Tooltip-BB82wNOE.cjs +0 -1
  136. package/dist/Tooltip-CqWK_GRD.js +0 -236
  137. package/dist/aria-DHnOMyYp.js +0 -10
  138. package/dist/aria-DKxpE8cA.cjs +0 -1
  139. package/dist/components/CheckboxGroup/index.d.ts +0 -2
  140. package/dist/components/Content/Content.d.ts +0 -58
  141. package/dist/components/Content/hooks/useContentLayout.d.ts +0 -18
  142. package/dist/components/Content/index.d.ts +0 -2
  143. package/dist/components/Content/utils/layout.d.ts +0 -11
  144. package/dist/components/RadioGroup/index.d.ts +0 -2
  145. package/dist/useFloatingPosition-CxzhAvy8.js +0 -73
  146. package/dist/useFloatingPosition-D1FqYy0l.cjs +0 -1
  147. package/dist/useFocusTrap--cgjy78G.cjs +0 -1
  148. package/dist/useFocusTrap-Da4nEash.js +0 -134
  149. package/dist/usePresence-DSPt6aKi.js +0 -210
  150. package/dist/usePresence-qe92UTvK.cjs +0 -1
  151. /package/dist/components/{CheckboxGroup → Checkbox}/contexts/CheckboxGroupContext.d.ts +0 -0
  152. /package/dist/components/{CheckboxGroup → Checkbox}/hooks/useCheckboxGroup.d.ts +0 -0
  153. /package/dist/components/{RadioGroup → Radio}/contexts/RadioGroupContext.d.ts +0 -0
  154. /package/dist/components/{RadioGroup → Radio}/hooks/useRadioGroup.d.ts +0 -0
@@ -1,58 +0,0 @@
1
- import { type ComponentPropsWithRef, type ComponentPropsWithoutRef, type CSSProperties, type ElementType, type ReactElement } from "react";
2
- import "./styles/content.css";
3
- /** A type representing the explicit themes supported by Content. */
4
- export type ContentTheme = "light" | "dark";
5
- /** A type representing Content's visual background modes. */
6
- export type ContentMode = "grid" | "none";
7
- /** A type representing Content's minimum-height behavior. */
8
- export type ContentMinHeight = "auto" | "available" | "viewport";
9
- /** A type representing Content's vertical spacing behavior. */
10
- export type ContentSpacing = "standard" | "none";
11
- /** A type representing CSS custom properties accepted by Content styles. */
12
- type ContentCustomProperties = {
13
- [CustomProperty in `--${string}`]?: string | number;
14
- };
15
- /** A type representing native Content styles and CSS custom properties. */
16
- type ContentStyle = CSSProperties & ContentCustomProperties;
17
- /** A type representing the reference accepted by a polymorphic element. */
18
- type ContentReference<Component extends ElementType> = ComponentPropsWithRef<Component>["ref"];
19
- /** A type representing properties owned by the Content component. */
20
- type ContentOwnProps = {
21
- /** The explicit color theme applied within Content. */
22
- theme?: ContentTheme;
23
- /** The accent color exposed to Content descendants. */
24
- accent?: string;
25
- /** The visual background treatment applied to Content. */
26
- mode?: ContentMode;
27
- /** The minimum height applied to Content. */
28
- minHeight?: ContentMinHeight;
29
- /** The vertical spacing applied within Content. */
30
- spacing?: ContentSpacing;
31
- /** Whether Content applies its responsive cell-aligned inner width. */
32
- constrain?: boolean;
33
- };
34
- /** A type representing properties for a polymorphic Content element. */
35
- export type ContentProps<Component extends ElementType = "div"> = ContentOwnProps & {
36
- as?: Component;
37
- style?: ContentStyle;
38
- } & Omit<ComponentPropsWithoutRef<Component>, keyof ContentOwnProps | "as" | "style">;
39
- /**
40
- * A type representing the public polymorphic Content component.
41
- *
42
- * @param props - The properties accepted by the selected element.
43
- *
44
- * @returns The rendered Content element.
45
- */
46
- type ContentComponent = <Component extends ElementType = "div">(props: ContentProps<Component> & {
47
- ref?: ContentReference<Component>;
48
- }) => ReactElement | null;
49
- /**
50
- * Renders a scoped Neatkit design-system boundary.
51
- *
52
- * @param props - The properties that configure Content and its root element.
53
- * @param forwardedReference - The reference assigned to the root element.
54
- *
55
- * @returns The rendered Content element.
56
- */
57
- declare const Content: ContentComponent;
58
- export default Content;
@@ -1,18 +0,0 @@
1
- import { type ForwardedRef, type RefCallback } from "react";
2
- /** A type representing Content's measured layout state. */
3
- type ContentLayout = {
4
- /** The callback ref assigned to the Content root. */
5
- rootReference: RefCallback<HTMLElement>;
6
- /** The enhanced inner width, or undefined while CSS controls sizing. */
7
- innerWidth: number | undefined;
8
- };
9
- /**
10
- * Measures a Content root and progressively enhances its inner width.
11
- *
12
- * @param forwardedReference - The public reference assigned to the root.
13
- * @param constrain - Whether responsive inner-width sizing is enabled.
14
- *
15
- * @returns The merged root reference and calculated inner width.
16
- */
17
- export declare function useContentLayout(forwardedReference: ForwardedRef<HTMLElement>, constrain: boolean): ContentLayout;
18
- export {};
@@ -1,2 +0,0 @@
1
- export { default } from "./Content";
2
- export type { ContentMinHeight, ContentMode, ContentProps, ContentSpacing, ContentTheme, } from "./Content";
@@ -1,11 +0,0 @@
1
- /**
2
- * Calculates the enhanced inner width for a Content root.
3
- *
4
- * Provides a centered cell-aligned width for eligible container sizes.
5
- *
6
- * @param availableWidth - The Content root's available content-box width.
7
- * @param cellSize - The resolved grid cell size in CSS pixels.
8
- *
9
- * @returns The cell-aligned width, or undefined when CSS controls sizing.
10
- */
11
- export declare function calculateContentInnerWidth(availableWidth: number, cellSize: number): number | undefined;
@@ -1,2 +0,0 @@
1
- export { default } from "./RadioGroup";
2
- export type { RadioGroupOrientation, RadioGroupProps, } from "./RadioGroup";
@@ -1,73 +0,0 @@
1
- import { useState as E, useEffect as F } from "react";
2
- const L = 12, S = {
3
- bottom: "top",
4
- left: "right",
5
- right: "left",
6
- top: "bottom"
7
- };
8
- function b(i, o) {
9
- const t = Math.min(L, o / 2);
10
- return Math.min(Math.max(t, i), o - t);
11
- }
12
- function r(i) {
13
- return S[i];
14
- }
15
- function A(i, o) {
16
- return o === "left" || o === "right" ? i.width : i.height;
17
- }
18
- function v(i, o, t, e, u, s) {
19
- const m = {
20
- bottom: s - t.bottom - o * 2,
21
- left: t.left - o * 2,
22
- right: u - t.right - o * 2,
23
- top: t.top - o * 2
24
- }, n = r(i), w = A(e, i), f = m[i] < w && m[n] > m[i] ? n : i;
25
- let l = t.left + (t.width - e.width) / 2, h = t.top + (t.height - e.height) / 2;
26
- return f === "top" ? h = t.top - e.height - o : f === "bottom" ? h = t.bottom + o : f === "left" ? l = t.left - e.width - o : l = t.right + o, l = Math.min(
27
- Math.max(o, l),
28
- Math.max(o, u - o - e.width)
29
- ), h = Math.min(
30
- Math.max(o, h),
31
- Math.max(o, s - o - e.height)
32
- ), { arrowOffset: f === "top" || f === "bottom" ? b(
33
- t.left + t.width / 2 - l,
34
- e.width
35
- ) : b(
36
- t.top + t.height / 2 - h,
37
- e.height
38
- ), left: l, placement: f, top: h };
39
- }
40
- const x = 8;
41
- function N(i, o, t, e) {
42
- const [u, s] = E(null);
43
- return F(() => {
44
- if (!i || !t || !e) {
45
- s(null);
46
- return;
47
- }
48
- const m = t.ownerDocument.defaultView;
49
- if (!m) return;
50
- const n = m, w = n.getComputedStyle(t), f = Number.parseFloat(
51
- w.getPropertyValue("--nk-space-8")
52
- ), l = Number.isFinite(f) ? f : x;
53
- function h() {
54
- const P = t == null ? void 0 : t.getBoundingClientRect(), M = e == null ? void 0 : e.getBoundingClientRect();
55
- !P || !M || s(v(
56
- o,
57
- l,
58
- P,
59
- M,
60
- n.innerWidth,
61
- n.innerHeight
62
- ));
63
- }
64
- h(), n.addEventListener("resize", h), n.addEventListener("scroll", h, !0);
65
- const a = n.ResizeObserver, c = a ? new a(h) : null;
66
- return c == null || c.observe(t), c == null || c.observe(e), () => {
67
- n.removeEventListener("resize", h), n.removeEventListener("scroll", h, !0), c == null || c.disconnect();
68
- };
69
- }, [i, e, o, t]), u;
70
- }
71
- export {
72
- N as u
73
- };
@@ -1 +0,0 @@
1
- "use strict";const b=require("react"),r=12,E={bottom:"top",left:"right",right:"left",top:"bottom"};function F(i,o){const t=Math.min(r,o/2);return Math.min(Math.max(t,i),o-t)}function L(i){return E[i]}function S(i,o){return o==="left"||o==="right"?i.width:i.height}function A(i,o,t,e,u,s){const m={bottom:s-t.bottom-o*2,left:t.left-o*2,right:u-t.right-o*2,top:t.top-o*2},h=L(i),w=S(e,i),f=m[i]<w&&m[h]>m[i]?h:i;let l=t.left+(t.width-e.width)/2,n=t.top+(t.height-e.height)/2;return f==="top"?n=t.top-e.height-o:f==="bottom"?n=t.bottom+o:f==="left"?l=t.left-e.width-o:l=t.right+o,l=Math.min(Math.max(o,l),Math.max(o,u-o-e.width)),n=Math.min(Math.max(o,n),Math.max(o,s-o-e.height)),{arrowOffset:f==="top"||f==="bottom"?F(t.left+t.width/2-l,e.width):F(t.top+t.height/2-n,e.height),left:l,placement:f,top:n}}const v=8;function C(i,o,t,e){const[u,s]=b.useState(null);return b.useEffect(()=>{if(!i||!t||!e){s(null);return}const m=t.ownerDocument.defaultView;if(!m)return;const h=m,w=h.getComputedStyle(t),f=Number.parseFloat(w.getPropertyValue("--nk-space-8")),l=Number.isFinite(f)?f:v;function n(){const P=t==null?void 0:t.getBoundingClientRect(),M=e==null?void 0:e.getBoundingClientRect();!P||!M||s(A(o,l,P,M,h.innerWidth,h.innerHeight))}n(),h.addEventListener("resize",n),h.addEventListener("scroll",n,!0);const a=h.ResizeObserver,c=a?new a(n):null;return c==null||c.observe(t),c==null||c.observe(e),()=>{h.removeEventListener("resize",n),h.removeEventListener("scroll",n,!0),c==null||c.disconnect()}},[i,e,o,t]),u}exports.useFloatingPosition=C;
@@ -1 +0,0 @@
1
- "use strict";const m=require("react"),N=require("./focus-restoration-70WcQRr5.cjs"),y=require("./usePresence-qe92UTvK.cjs"),V=["a[href]","area[href]","button","input:not([type=hidden])","select","textarea","iframe","[contenteditable]:not([contenteditable='false'])","[tabindex]"].join(",");function A(r,s){let e=r;for(;e;){if(e.hidden||e.inert||e.getAttribute("aria-hidden")==="true")return!0;const t=e.ownerDocument.defaultView,n=t==null?void 0:t.getComputedStyle(e);if((n==null?void 0:n.display)==="none"||(n==null?void 0:n.visibility)==="hidden")return!0;if(e===s)break;e=e.parentElement}return!1}function K(r,s){var i;const e=(i=r.ownerDocument.defaultView)==null?void 0:i.HTMLInputElement;if(!e||!(r instanceof e)||r.type!=="radio"||!r.name)return!0;const t=s.filter(c=>c instanceof e&&c.type==="radio"&&c.name===r.name&&c.form===r.form),n=t.find(c=>c.checked);return n?n===r:t[0]===r}function P(r){const s=Array.from(r.querySelectorAll(V)).filter(e=>!e.matches(":disabled")&&e.tabIndex>=0&&!A(e,r));return s.filter(e=>K(e,s))}function F(r,s){const e=[r,...s];return[...new Set(e.flatMap(n=>P(n)))].sort((n,i)=>{var f;if(n===i)return 0;const c=n.compareDocumentPosition(i),E=((f=n.ownerDocument.defaultView)==null?void 0:f.Node.DOCUMENT_POSITION_FOLLOWING)??4;return c&E?-1:1})}function w(r,s,e){return e?r.contains(e)||[...s].some(t=>t.contains(e)):!1}function _(r){const{active:s,autoFocus:e=!0,container:t,initialFocusReference:n,layerId:i,restoreFocus:c=!0}=r,E=(t==null?void 0:t.ownerDocument)??null,f=m.useRef(new Set),b=m.useCallback(u=>(f.current.add(u),()=>f.current.delete(u)),[]),I=m.useMemo(()=>({registerBranch:b}),[b]);return y.useOverlayFocusLayer(s&&!!t,E,i),m.useEffect(()=>{var O,C;if(!s||!t)return;const u=t.ownerDocument,S=(O=u.defaultView)==null?void 0:O.HTMLElement,D=(C=u.defaultView)==null?void 0:C.Node,d=S&&u.activeElement instanceof S?u.activeElement:null;let L=!0;function T(){const o=n==null?void 0:n.current;(o&&w(t,f.current,o)?o:F(t,f.current)[0]??t).focus({preventScroll:!0})}function g(o){if(o.key!=="Tab"||!y.isTopmostFocusLayer(u,i))return;const a=F(t,f.current);if(a.length===0){o.preventDefault(),t==null||t.focus({preventScroll:!0});return}const p=a[0],h=a[a.length-1],l=u.activeElement,k=w(t,f.current,l),q=!a.some(M=>M===l)&&(l===t||l===(n==null?void 0:n.current));if(!k||q){o.preventDefault(),(o.shiftKey?h:p).focus();return}o.shiftKey&&l===p?(o.preventDefault(),h.focus()):!o.shiftKey&&l===h&&(o.preventDefault(),p.focus())}function v(o){y.isTopmostFocusLayer(u,i)&&D&&o.target instanceof D&&!w(t,f.current,o.target)&&T()}return u.addEventListener("keydown",g,!0),u.addEventListener("focusin",v,!0),e&&Promise.resolve().then(()=>{L&&T()}),()=>{L=!1,u.removeEventListener("keydown",g,!0),u.removeEventListener("focusin",v,!0),c&&(d!=null&&d.isConnected)&&N.restoreElementFocus(d)}},[s,e,t,n,i,c]),I}exports.useFocusTrap=_;
@@ -1,134 +0,0 @@
1
- import { useRef as N, useCallback as V, useMemo as q, useEffect as x } from "react";
2
- import { r as A } from "./focus-restoration-BvNZzrQA.js";
3
- import { u as K, i as O } from "./usePresence-DSPt6aKi.js";
4
- const _ = [
5
- "a[href]",
6
- "area[href]",
7
- "button",
8
- "input:not([type=hidden])",
9
- "select",
10
- "textarea",
11
- "iframe",
12
- "[contenteditable]:not([contenteditable='false'])",
13
- "[tabindex]"
14
- ].join(",");
15
- function B(r, u) {
16
- let e = r;
17
- for (; e; ) {
18
- if (e.hidden || e.inert || e.getAttribute("aria-hidden") === "true")
19
- return !0;
20
- const t = e.ownerDocument.defaultView, n = t == null ? void 0 : t.getComputedStyle(e);
21
- if ((n == null ? void 0 : n.display) === "none" || (n == null ? void 0 : n.visibility) === "hidden")
22
- return !0;
23
- if (e === u) break;
24
- e = e.parentElement;
25
- }
26
- return !1;
27
- }
28
- function H(r, u) {
29
- var i;
30
- const e = (i = r.ownerDocument.defaultView) == null ? void 0 : i.HTMLInputElement;
31
- if (!e || !(r instanceof e) || r.type !== "radio" || !r.name)
32
- return !0;
33
- const t = u.filter(
34
- (c) => c instanceof e && c.type === "radio" && c.name === r.name && c.form === r.form
35
- ), n = t.find((c) => c.checked);
36
- return n ? n === r : t[0] === r;
37
- }
38
- function P(r) {
39
- const u = Array.from(
40
- r.querySelectorAll(_)
41
- ).filter((e) => !e.matches(":disabled") && e.tabIndex >= 0 && !B(e, r));
42
- return u.filter(
43
- (e) => H(e, u)
44
- );
45
- }
46
- function C(r, u) {
47
- const e = [r, ...u];
48
- return [...new Set(
49
- e.flatMap(
50
- (n) => P(n)
51
- )
52
- )].sort((n, i) => {
53
- var f;
54
- if (n === i) return 0;
55
- const c = n.compareDocumentPosition(i), m = ((f = n.ownerDocument.defaultView) == null ? void 0 : f.Node.DOCUMENT_POSITION_FOLLOWING) ?? 4;
56
- return c & m ? -1 : 1;
57
- });
58
- }
59
- function h(r, u, e) {
60
- return e ? r.contains(e) || [...u].some((t) => t.contains(e)) : !1;
61
- }
62
- function z(r) {
63
- const {
64
- active: u,
65
- autoFocus: e = !0,
66
- container: t,
67
- initialFocusReference: n,
68
- layerId: i,
69
- restoreFocus: c = !0
70
- } = r, m = (t == null ? void 0 : t.ownerDocument) ?? null, f = N(/* @__PURE__ */ new Set()), w = V((s) => (f.current.add(s), () => f.current.delete(s)), []), I = q(() => ({ registerBranch: w }), [w]);
71
- return K(u && !!t, m, i), x(() => {
72
- var g, v;
73
- if (!u || !t) return;
74
- const s = t.ownerDocument, y = (g = s.defaultView) == null ? void 0 : g.HTMLElement, b = (v = s.defaultView) == null ? void 0 : v.Node, d = y && s.activeElement instanceof y ? s.activeElement : null;
75
- let S = !0;
76
- function D() {
77
- const o = n == null ? void 0 : n.current;
78
- (o && h(
79
- t,
80
- f.current,
81
- o
82
- ) ? o : C(
83
- t,
84
- f.current
85
- )[0] ?? t).focus({ preventScroll: !0 });
86
- }
87
- function L(o) {
88
- if (o.key !== "Tab" || !O(s, i))
89
- return;
90
- const a = C(
91
- t,
92
- f.current
93
- );
94
- if (a.length === 0) {
95
- o.preventDefault(), t == null || t.focus({ preventScroll: !0 });
96
- return;
97
- }
98
- const E = a[0], p = a[a.length - 1], l = s.activeElement, F = h(
99
- t,
100
- f.current,
101
- l
102
- ), k = !a.some(
103
- (M) => M === l
104
- ) && (l === t || l === (n == null ? void 0 : n.current));
105
- if (!F || k) {
106
- o.preventDefault(), (o.shiftKey ? p : E).focus();
107
- return;
108
- }
109
- o.shiftKey && l === E ? (o.preventDefault(), p.focus()) : !o.shiftKey && l === p && (o.preventDefault(), E.focus());
110
- }
111
- function T(o) {
112
- O(s, i) && b && o.target instanceof b && !h(
113
- t,
114
- f.current,
115
- o.target
116
- ) && D();
117
- }
118
- return s.addEventListener("keydown", L, !0), s.addEventListener("focusin", T, !0), e && Promise.resolve().then(() => {
119
- S && D();
120
- }), () => {
121
- S = !1, s.removeEventListener("keydown", L, !0), s.removeEventListener("focusin", T, !0), c && (d != null && d.isConnected) && A(d);
122
- };
123
- }, [
124
- u,
125
- e,
126
- t,
127
- n,
128
- i,
129
- c
130
- ]), I;
131
- }
132
- export {
133
- z as u
134
- };
@@ -1,210 +0,0 @@
1
- "use client";
2
- import { jsxs as b, Fragment as x, jsx as g } from "react/jsx-runtime";
3
- import { createContext as O, useRef as v, useState as m, useEffect as f, useContext as M, useLayoutEffect as R, useReducer as k } from "react";
4
- import { createPortal as I } from "react-dom";
5
- const C = O(void 0), L = typeof window > "u" ? f : R;
6
- function P(r, t) {
7
- const e = r.ownerDocument.defaultView;
8
- if (!e) return;
9
- const n = e.getComputedStyle(r);
10
- Array.from(t.style).filter((u) => u.startsWith("--nk-")).forEach((u) => {
11
- t.style.removeProperty(u);
12
- });
13
- for (let u = 0; u < n.length; u += 1) {
14
- const c = n.item(u);
15
- c.startsWith("--nk-") && t.style.setProperty(
16
- c,
17
- n.getPropertyValue(c)
18
- );
19
- }
20
- }
21
- function F(r) {
22
- const { children: t, source: e } = r, n = v(null), s = M(C), [u, c] = m(null);
23
- return L(() => {
24
- const o = n.current;
25
- if (!(!o || !s))
26
- return s.registerBranch(o);
27
- }, [s]), L(() => {
28
- var h;
29
- const o = n.current;
30
- if (!o) return;
31
- P(e, o), c(e);
32
- const a = e.closest(".nk-content") ?? e, l = (h = e.ownerDocument.defaultView) == null ? void 0 : h.MutationObserver;
33
- if (!l) return;
34
- const y = new l(() => {
35
- P(e, o);
36
- });
37
- return y.observe(a, {
38
- attributeFilter: ["class", "data-theme", "style"],
39
- attributes: !0
40
- }), () => y.disconnect();
41
- }, [e]), /* @__PURE__ */ g(
42
- "div",
43
- {
44
- className: "nk-portal",
45
- ref: n,
46
- style: { display: "contents" },
47
- children: u === e ? t : null
48
- }
49
- );
50
- }
51
- function W(r) {
52
- const { children: t, container: e, inheritFrom: n } = r, s = v(null), [u, c] = m(!1);
53
- f(() => {
54
- c(!0);
55
- }, []);
56
- const o = n ?? s.current, i = (o == null ? void 0 : o.ownerDocument) ?? (typeof document > "u" ? null : document), a = e ?? (i == null ? void 0 : i.body) ?? null;
57
- return /* @__PURE__ */ b(x, { children: [
58
- n ? null : /* @__PURE__ */ g("span", { "aria-hidden": "true", hidden: !0, ref: s }),
59
- u && o && a ? I(
60
- /* @__PURE__ */ g(F, { source: o, children: t }),
61
- a
62
- ) : null
63
- ] });
64
- }
65
- const T = 1e3, B = 10, S = /* @__PURE__ */ new WeakMap();
66
- function p(r) {
67
- const t = S.get(r);
68
- if (t) return t;
69
- const e = {
70
- focusLayers: /* @__PURE__ */ new Set(),
71
- layers: [],
72
- listeners: /* @__PURE__ */ new Set()
73
- };
74
- return S.set(r, e), e;
75
- }
76
- function E(r) {
77
- r.listeners.forEach((t) => t());
78
- }
79
- function j(r, t) {
80
- const e = v(Symbol("nk-overlay-layer")), [, n] = k((o) => o + 1, 0);
81
- f(() => {
82
- if (!r || !t) return;
83
- const o = p(t), i = () => n();
84
- return o.listeners.add(i), o.layers.push(e.current), E(o), () => {
85
- o.listeners.delete(i);
86
- const a = o.layers.indexOf(e.current);
87
- a >= 0 && o.layers.splice(a, 1), E(o);
88
- };
89
- }, [r, t]);
90
- const s = t ? p(t) : null, u = (s == null ? void 0 : s.layers.indexOf(
91
- e.current
92
- )) ?? -1, c = u >= 0 ? u : (s == null ? void 0 : s.layers.length) ?? 0;
93
- return {
94
- id: e.current,
95
- zIndex: T + c * B
96
- };
97
- }
98
- function w(r, t) {
99
- const e = p(r).layers;
100
- return e.length > 0 && e[e.length - 1] === t;
101
- }
102
- function X(r, t, e) {
103
- f(() => {
104
- if (!r || !t) return;
105
- const n = p(t);
106
- return n.focusLayers.add(e), () => {
107
- n.focusLayers.delete(e);
108
- };
109
- }, [r, e, t]);
110
- }
111
- function Y(r, t) {
112
- const e = p(r);
113
- for (let n = e.layers.length - 1; n >= 0; n -= 1) {
114
- const s = e.layers[n];
115
- if (e.focusLayers.has(s))
116
- return s === t;
117
- }
118
- return !1;
119
- }
120
- function V(r, t) {
121
- const e = r.composedPath();
122
- return t.some((n) => {
123
- var c;
124
- const s = n.current;
125
- if (!s) return !1;
126
- if (e.includes(s)) return !0;
127
- const u = (c = s.ownerDocument.defaultView) == null ? void 0 : c.Node;
128
- return u && r.target instanceof u ? s.contains(r.target) : !1;
129
- });
130
- }
131
- function Z(r) {
132
- const {
133
- active: t,
134
- boundaries: e,
135
- dismissOnEscape: n = !0,
136
- dismissOnPointerDownOutside: s = !0,
137
- layerId: u,
138
- onEscapeDismiss: c,
139
- onEscapeKeyDown: o,
140
- onPointerDownOutside: i,
141
- onPointerDownOutsideDismiss: a,
142
- ownerDocument: l
143
- } = r;
144
- f(() => {
145
- if (!t || !l) return;
146
- function y(d) {
147
- d.key !== "Escape" || !n || !w(l, u) || (o == null || o(d), !d.defaultPrevented && (d.preventDefault(), c == null || c()));
148
- }
149
- function h(d) {
150
- !s || !w(l, u) || V(d, e) || (i == null || i(d), !d.defaultPrevented && (a == null || a()));
151
- }
152
- return l.addEventListener("keydown", y, !0), l.addEventListener("pointerdown", h, !0), () => {
153
- l.removeEventListener("keydown", y, !0), l.removeEventListener("pointerdown", h, !0);
154
- };
155
- }, [
156
- t,
157
- e,
158
- n,
159
- s,
160
- u,
161
- c,
162
- o,
163
- i,
164
- a,
165
- l
166
- ]);
167
- }
168
- function _() {
169
- const [r, t] = m(!1);
170
- return f(() => {
171
- const e = typeof window > "u" ? null : window;
172
- if (!(e != null && e.matchMedia)) return;
173
- const n = e.matchMedia(
174
- "(prefers-reduced-motion: reduce)"
175
- ), s = () => {
176
- t(n.matches);
177
- };
178
- return s(), n.addEventListener("change", s), () => n.removeEventListener("change", s);
179
- }, []), r;
180
- }
181
- function Q(r, t = 200) {
182
- const e = _(), [n, s] = m(r);
183
- return f(() => {
184
- if (r) {
185
- s(!0);
186
- return;
187
- }
188
- if (!n) return;
189
- if (e || t <= 0) {
190
- s(!1);
191
- return;
192
- }
193
- const u = window.setTimeout(() => {
194
- s(!1);
195
- }, t);
196
- return () => window.clearTimeout(u);
197
- }, [t, r, e, n]), {
198
- present: n,
199
- state: r ? "open" : n ? "closing" : "closed"
200
- };
201
- }
202
- export {
203
- C as F,
204
- W as P,
205
- Q as a,
206
- j as b,
207
- Z as c,
208
- Y as i,
209
- X as u
210
- };
@@ -1 +0,0 @@
1
- "use client";"use strict";const p=require("react/jsx-runtime"),c=require("react"),x=require("react-dom"),P=c.createContext(void 0),v=typeof window>"u"?c.useEffect:c.useLayoutEffect;function E(r,t){const e=r.ownerDocument.defaultView;if(!e)return;const n=e.getComputedStyle(r);Array.from(t.style).filter(u=>u.startsWith("--nk-")).forEach(u=>{t.style.removeProperty(u)});for(let u=0;u<n.length;u+=1){const i=n.item(u);i.startsWith("--nk-")&&t.style.setProperty(i,n.getPropertyValue(i))}}function w(r){const{children:t,source:e}=r,n=c.useRef(null),s=c.useContext(P),[u,i]=c.useState(null);return v(()=>{const o=n.current;if(!(!o||!s))return s.registerBranch(o)},[s]),v(()=>{var h;const o=n.current;if(!o)return;E(e,o),i(e);const l=e.closest(".nk-content")??e,f=(h=e.ownerDocument.defaultView)==null?void 0:h.MutationObserver;if(!f)return;const y=new f(()=>{E(e,o)});return y.observe(l,{attributeFilter:["class","data-theme","style"],attributes:!0}),()=>y.disconnect()},[e]),p.jsx("div",{className:"nk-portal",ref:n,style:{display:"contents"},children:u===e?t:null})}function b(r){const{children:t,container:e,inheritFrom:n}=r,s=c.useRef(null),[u,i]=c.useState(!1);c.useEffect(()=>{i(!0)},[]);const o=n??s.current,a=(o==null?void 0:o.ownerDocument)??(typeof document>"u"?null:document),l=e??(a==null?void 0:a.body)??null;return p.jsxs(p.Fragment,{children:[n?null:p.jsx("span",{"aria-hidden":"true",hidden:!0,ref:s}),u&&o&&l?x.createPortal(p.jsx(w,{source:o,children:t}),l):null]})}const O=1e3,R=10,L=new WeakMap;function m(r){const t=L.get(r);if(t)return t;const e={focusLayers:new Set,layers:[],listeners:new Set};return L.set(r,e),e}function g(r){r.listeners.forEach(t=>t())}function M(r,t){const e=c.useRef(Symbol("nk-overlay-layer")),[,n]=c.useReducer(o=>o+1,0);c.useEffect(()=>{if(!r||!t)return;const o=m(t),a=()=>n();return o.listeners.add(a),o.layers.push(e.current),g(o),()=>{o.listeners.delete(a);const l=o.layers.indexOf(e.current);l>=0&&o.layers.splice(l,1),g(o)}},[r,t]);const s=t?m(t):null,u=(s==null?void 0:s.layers.indexOf(e.current))??-1,i=u>=0?u:(s==null?void 0:s.layers.length)??0;return{id:e.current,zIndex:O+i*R}}function S(r,t){const e=m(r).layers;return e.length>0&&e[e.length-1]===t}function k(r,t,e){c.useEffect(()=>{if(!r||!t)return;const n=m(t);return n.focusLayers.add(e),()=>{n.focusLayers.delete(e)}},[r,e,t])}function F(r,t){const e=m(r);for(let n=e.layers.length-1;n>=0;n-=1){const s=e.layers[n];if(e.focusLayers.has(s))return s===t}return!1}function I(r,t){const e=r.composedPath();return t.some(n=>{var i;const s=n.current;if(!s)return!1;if(e.includes(s))return!0;const u=(i=s.ownerDocument.defaultView)==null?void 0:i.Node;return u&&r.target instanceof u?s.contains(r.target):!1})}function C(r){const{active:t,boundaries:e,dismissOnEscape:n=!0,dismissOnPointerDownOutside:s=!0,layerId:u,onEscapeDismiss:i,onEscapeKeyDown:o,onPointerDownOutside:a,onPointerDownOutsideDismiss:l,ownerDocument:f}=r;c.useEffect(()=>{if(!t||!f)return;function y(d){d.key!=="Escape"||!n||!S(f,u)||(o==null||o(d),!d.defaultPrevented&&(d.preventDefault(),i==null||i()))}function h(d){!s||!S(f,u)||I(d,e)||(a==null||a(d),!d.defaultPrevented&&(l==null||l()))}return f.addEventListener("keydown",y,!0),f.addEventListener("pointerdown",h,!0),()=>{f.removeEventListener("keydown",y,!0),f.removeEventListener("pointerdown",h,!0)}},[t,e,n,s,u,i,o,a,l,f])}function T(){const[r,t]=c.useState(!1);return c.useEffect(()=>{const e=typeof window>"u"?null:window;if(!(e!=null&&e.matchMedia))return;const n=e.matchMedia("(prefers-reduced-motion: reduce)"),s=()=>{t(n.matches)};return s(),n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[]),r}function B(r,t=200){const e=T(),[n,s]=c.useState(r);return c.useEffect(()=>{if(r){s(!0);return}if(!n)return;if(e||t<=0){s(!1);return}const u=window.setTimeout(()=>{s(!1)},t);return()=>window.clearTimeout(u)},[t,r,e,n]),{present:n,state:r?"open":n?"closing":"closed"}}exports.FocusScopeContext=P;exports.Portal=b;exports.isTopmostFocusLayer=F;exports.useDismissableLayer=C;exports.useOverlayFocusLayer=k;exports.useOverlayLayer=M;exports.usePresence=B;