neatkit 0.4.2 → 0.6.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 (138) hide show
  1. package/dist/Alert-DQ5CCE0N.js +29 -0
  2. package/dist/Alert-LJDkNUqH.cjs +1 -0
  3. package/dist/Alert.cjs +1 -0
  4. package/dist/Alert.js +4 -0
  5. package/dist/Avatar.cjs +1 -0
  6. package/dist/Avatar.js +55 -0
  7. package/dist/Badge.cjs +1 -0
  8. package/dist/Badge.js +25 -0
  9. package/dist/Button-BAsLfA0D.js +99 -0
  10. package/dist/Button-D7JUO6Fs.cjs +1 -0
  11. package/dist/Button.cjs +1 -0
  12. package/dist/Button.js +5 -0
  13. package/dist/Card-CPq6dsut.js +34 -0
  14. package/dist/Card-CQ-8_1tO.cjs +1 -0
  15. package/dist/Card.cjs +1 -0
  16. package/dist/Card.js +4 -0
  17. package/dist/Checkbox-BvXM9VyY.js +68 -0
  18. package/dist/Checkbox-VQifZrZZ.cjs +1 -0
  19. package/dist/Checkbox.cjs +1 -0
  20. package/dist/Checkbox.js +5 -0
  21. package/dist/CheckboxGroup.cjs +1 -0
  22. package/dist/CheckboxGroup.js +144 -0
  23. package/dist/Code-BP2ZCmUf.js +7446 -0
  24. package/dist/Code-eispVOW3.cjs +6 -0
  25. package/dist/Code.cjs +1 -0
  26. package/dist/Code.js +5 -0
  27. package/dist/Content.cjs +1 -0
  28. package/dist/Content.js +144 -0
  29. package/dist/Divider-BE15WVDI.js +42 -0
  30. package/dist/Divider-CJYbFcSX.cjs +1 -0
  31. package/dist/Divider.cjs +1 -0
  32. package/dist/Divider.js +4 -0
  33. package/dist/Field.cjs +1 -0
  34. package/dist/Field.js +115 -0
  35. package/dist/Icon-D8IZceys.cjs +1 -0
  36. package/dist/Icon-uQmpr5P2.js +1139 -0
  37. package/dist/Icon.cjs +1 -0
  38. package/dist/Icon.js +37 -0
  39. package/dist/Input.cjs +1 -0
  40. package/dist/Input.js +146 -0
  41. package/dist/Markdown.cjs +31 -0
  42. package/dist/Markdown.js +18411 -0
  43. package/dist/Modal.cjs +1 -0
  44. package/dist/Modal.js +171 -0
  45. package/dist/PinInput.cjs +1 -0
  46. package/dist/PinInput.js +248 -0
  47. package/dist/Popover.cjs +1 -0
  48. package/dist/Popover.js +238 -0
  49. package/dist/Radio.cjs +1 -0
  50. package/dist/Radio.js +65 -0
  51. package/dist/RadioGroup.cjs +1 -0
  52. package/dist/RadioGroup.js +51 -0
  53. package/dist/RadioGroupContext-BX9KnDek.cjs +1 -0
  54. package/dist/RadioGroupContext-DbKM4zPZ.js +5 -0
  55. package/dist/Select.cjs +1 -0
  56. package/dist/Select.js +473 -0
  57. package/dist/Skeleton.cjs +1 -0
  58. package/dist/Skeleton.js +27 -0
  59. package/dist/Spinner-BXgw60UC.cjs +1 -0
  60. package/dist/Spinner-CVYvk6YK.js +25 -0
  61. package/dist/Spinner.cjs +1 -0
  62. package/dist/Spinner.js +4 -0
  63. package/dist/Surface-BttJYSDt.cjs +1 -0
  64. package/dist/Surface-vEFsZC12.js +17 -0
  65. package/dist/Switch.cjs +1 -0
  66. package/dist/Switch.js +39 -0
  67. package/dist/Table-83unQQOi.cjs +1 -0
  68. package/dist/Table-Cw8u-pEW.js +403 -0
  69. package/dist/Table.cjs +1 -0
  70. package/dist/Table.js +5 -0
  71. package/dist/Text-DWYlIcPj.cjs +1 -0
  72. package/dist/Text-rN6iDo0V.js +24 -0
  73. package/dist/Text.cjs +1 -0
  74. package/dist/Text.js +4 -0
  75. package/dist/TextArea.cjs +1 -0
  76. package/dist/TextArea.js +43 -0
  77. package/dist/Tooltip-BB82wNOE.cjs +1 -0
  78. package/dist/Tooltip-CqWK_GRD.js +236 -0
  79. package/dist/Tooltip.cjs +1 -0
  80. package/dist/Tooltip.js +6 -0
  81. package/dist/aria-DHnOMyYp.js +10 -0
  82. package/dist/aria-DKxpE8cA.cjs +1 -0
  83. package/dist/components/Alert/index.d.ts +1 -1
  84. package/dist/components/Avatar/index.d.ts +1 -1
  85. package/dist/components/Badge/index.d.ts +1 -1
  86. package/dist/components/Button/Button.d.ts +2 -2
  87. package/dist/components/Button/index.d.ts +1 -1
  88. package/dist/components/Card/index.d.ts +1 -1
  89. package/dist/components/Checkbox/index.d.ts +1 -1
  90. package/dist/components/CheckboxGroup/index.d.ts +1 -1
  91. package/dist/components/Code/Code.d.ts +47 -0
  92. package/dist/components/Code/index.d.ts +2 -0
  93. package/dist/components/Code/utils/highlight.d.ts +17 -0
  94. package/dist/components/Content/Content.d.ts +3 -3
  95. package/dist/components/Content/index.d.ts +2 -2
  96. package/dist/components/Divider/index.d.ts +1 -1
  97. package/dist/components/Field/index.d.ts +1 -1
  98. package/dist/components/Icon/index.d.ts +1 -1
  99. package/dist/components/Input/index.d.ts +1 -1
  100. package/dist/components/Markdown/Markdown.d.ts +66 -0
  101. package/dist/components/Markdown/index.d.ts +3 -0
  102. package/dist/components/Markdown/utils/language.d.ts +9 -0
  103. package/dist/components/Markdown/utils/renderers.d.ts +15 -0
  104. package/dist/components/Markdown/utils/security.d.ts +66 -0
  105. package/dist/components/Modal/index.d.ts +1 -1
  106. package/dist/components/PinInput/index.d.ts +1 -1
  107. package/dist/components/Popover/index.d.ts +1 -1
  108. package/dist/components/Radio/index.d.ts +1 -1
  109. package/dist/components/RadioGroup/index.d.ts +1 -1
  110. package/dist/components/Select/index.d.ts +1 -1
  111. package/dist/components/Skeleton/index.d.ts +1 -1
  112. package/dist/components/Spinner/index.d.ts +1 -1
  113. package/dist/components/Switch/index.d.ts +1 -1
  114. package/dist/components/Table/Table.d.ts +7 -11
  115. package/dist/components/Table/index.d.ts +1 -1
  116. package/dist/components/Text/index.d.ts +1 -1
  117. package/dist/components/TextArea/index.d.ts +1 -1
  118. package/dist/components/Tooltip/index.d.ts +1 -1
  119. package/dist/field-control-NfLwcPj6.cjs +1 -0
  120. package/dist/field-control-XAn_FKks.js +16 -0
  121. package/dist/focus-restoration-70WcQRr5.cjs +1 -0
  122. package/dist/focus-restoration-BvNZzrQA.js +16 -0
  123. package/dist/index.cjs +1 -1
  124. package/dist/index.d.ts +1 -26
  125. package/dist/index.js +6 -4409
  126. package/dist/reference-C2guRuR0.cjs +1 -0
  127. package/dist/reference-CXMr27nM.js +12 -0
  128. package/dist/style.css +1 -1
  129. package/dist/tokens.d.ts +1 -1
  130. package/dist/units-BmjPCccF.js +90 -0
  131. package/dist/units-PzuiQNnw.cjs +1 -0
  132. package/dist/useFloatingPosition-CxzhAvy8.js +73 -0
  133. package/dist/useFloatingPosition-D1FqYy0l.cjs +1 -0
  134. package/dist/useFocusTrap--cgjy78G.cjs +1 -0
  135. package/dist/useFocusTrap-Da4nEash.js +134 -0
  136. package/dist/usePresence-DSPt6aKi.js +210 -0
  137. package/dist/usePresence-qe92UTvK.cjs +1 -0
  138. package/package.json +155 -2
package/dist/tokens.d.ts CHANGED
@@ -6,7 +6,7 @@ export declare const SPACE_SIZES: readonly [2, 4, 8, 12, 16, 24, 32, 48];
6
6
  export type SpaceSize = (typeof SPACE_SIZES)[number];
7
7
  /** The canonical Neatkit responsive breakpoints in CSS pixels. */
8
8
  export declare const BREAKPOINTS: {
9
- readonly sm: 768;
9
+ readonly sm: 720;
10
10
  readonly md: 960;
11
11
  readonly lg: 1440;
12
12
  readonly xl: 1920;
@@ -0,0 +1,90 @@
1
+ const e = [2, 4, 8, 12, 16, 24, 32, 48], n = {
2
+ sm: 720,
3
+ md: 960,
4
+ lg: 1440,
5
+ xl: 1920
6
+ }, l = {
7
+ color: {
8
+ accent: {
9
+ default: "var(--nk-accent)",
10
+ soft: "var(--nk-accent-soft)",
11
+ subtle: "var(--nk-accent-subtle)"
12
+ },
13
+ background: "var(--nk-color-background)",
14
+ surface: "var(--nk-color-surface)",
15
+ text: {
16
+ default: "var(--nk-color-text)",
17
+ muted: "var(--nk-color-text-muted)"
18
+ },
19
+ border: "var(--nk-color-border)",
20
+ emphasis: {
21
+ fill: "var(--nk-color-emphasis-fill)",
22
+ fillForeground: "var(--nk-color-emphasis-fill-foreground)"
23
+ },
24
+ info: {
25
+ foreground: "var(--nk-color-info-foreground)",
26
+ fill: "var(--nk-color-info-fill)",
27
+ fillForeground: "var(--nk-color-info-fill-foreground)"
28
+ },
29
+ success: {
30
+ foreground: "var(--nk-color-success-foreground)",
31
+ fill: "var(--nk-color-success-fill)",
32
+ fillForeground: "var(--nk-color-success-fill-foreground)"
33
+ },
34
+ warning: {
35
+ foreground: "var(--nk-color-warning-foreground)",
36
+ fill: "var(--nk-color-warning-fill)",
37
+ fillForeground: "var(--nk-color-warning-fill-foreground)"
38
+ },
39
+ danger: {
40
+ foreground: "var(--nk-color-danger-foreground)",
41
+ fill: "var(--nk-color-danger-fill)",
42
+ fillForeground: "var(--nk-color-danger-fill-foreground)"
43
+ }
44
+ },
45
+ radius: {
46
+ small: "var(--nk-radius-small)",
47
+ medium: "var(--nk-radius-medium)",
48
+ large: "var(--nk-radius-large)"
49
+ },
50
+ shadow: {
51
+ subtle: "var(--nk-shadow-subtle)",
52
+ medium: "var(--nk-shadow-medium)",
53
+ strong: "var(--nk-shadow-strong)"
54
+ }
55
+ };
56
+ ({
57
+ ...Object.fromEntries(
58
+ e.map((r) => [`--nk-space-${r}`, `${r}px`])
59
+ )
60
+ });
61
+ function a(r) {
62
+ if (typeof r != "number" || !Number.isFinite(r))
63
+ throw new RangeError("Cell amount must be a finite number.");
64
+ const o = r * 36;
65
+ if (!Number.isFinite(o))
66
+ throw new RangeError("Calculated cell value must be finite.");
67
+ return o;
68
+ }
69
+ function i(r) {
70
+ if (!e.some((o) => o === r))
71
+ throw new RangeError(`Unsupported spacing size: ${String(r)}.`);
72
+ return r;
73
+ }
74
+ function t(r) {
75
+ if (!Object.prototype.hasOwnProperty.call(n, r))
76
+ throw new RangeError(`Unsupported breakpoint: ${String(r)}.`);
77
+ return n[r];
78
+ }
79
+ function s(r) {
80
+ if (typeof r != "number" || !Number.isFinite(r))
81
+ throw new RangeError("Pixel value must be a finite number.");
82
+ return `${r}px`;
83
+ }
84
+ export {
85
+ t as b,
86
+ a as c,
87
+ s as p,
88
+ i as s,
89
+ l as t
90
+ };
@@ -0,0 +1 @@
1
+ "use strict";const e=[2,4,8,12,16,24,32,48],n={sm:720,md:960,lg:1440,xl:1920},l={color:{accent:{default:"var(--nk-accent)",soft:"var(--nk-accent-soft)",subtle:"var(--nk-accent-subtle)"},background:"var(--nk-color-background)",surface:"var(--nk-color-surface)",text:{default:"var(--nk-color-text)",muted:"var(--nk-color-text-muted)"},border:"var(--nk-color-border)",emphasis:{fill:"var(--nk-color-emphasis-fill)",fillForeground:"var(--nk-color-emphasis-fill-foreground)"},info:{foreground:"var(--nk-color-info-foreground)",fill:"var(--nk-color-info-fill)",fillForeground:"var(--nk-color-info-fill-foreground)"},success:{foreground:"var(--nk-color-success-foreground)",fill:"var(--nk-color-success-fill)",fillForeground:"var(--nk-color-success-fill-foreground)"},warning:{foreground:"var(--nk-color-warning-foreground)",fill:"var(--nk-color-warning-fill)",fillForeground:"var(--nk-color-warning-fill-foreground)"},danger:{foreground:"var(--nk-color-danger-foreground)",fill:"var(--nk-color-danger-fill)",fillForeground:"var(--nk-color-danger-fill-foreground)"}},radius:{small:"var(--nk-radius-small)",medium:"var(--nk-radius-medium)",large:"var(--nk-radius-large)"},shadow:{subtle:"var(--nk-shadow-subtle)",medium:"var(--nk-shadow-medium)",strong:"var(--nk-shadow-strong)"}};({...Object.fromEntries(e.map(r=>[`--nk-space-${r}`,`${r}px`]))});function a(r){if(typeof r!="number"||!Number.isFinite(r))throw new RangeError("Cell amount must be a finite number.");const o=r*36;if(!Number.isFinite(o))throw new RangeError("Calculated cell value must be finite.");return o}function i(r){if(!e.some(o=>o===r))throw new RangeError(`Unsupported spacing size: ${String(r)}.`);return r}function t(r){if(!Object.prototype.hasOwnProperty.call(n,r))throw new RangeError(`Unsupported breakpoint: ${String(r)}.`);return n[r]}function u(r){if(typeof r!="number"||!Number.isFinite(r))throw new RangeError("Pixel value must be a finite number.");return`${r}px`}exports.breakpoint=t;exports.cell=a;exports.px=u;exports.space=i;exports.tokens=l;
@@ -0,0 +1,73 @@
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
+ };
@@ -0,0 +1 @@
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;
@@ -0,0 +1 @@
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=_;
@@ -0,0 +1,134 @@
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
+ };
@@ -0,0 +1,210 @@
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
+ };
@@ -0,0 +1 @@
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;