neatkit 0.7.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 -60
  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
package/dist/tokens.d.ts CHANGED
@@ -127,6 +127,7 @@ export declare const BASE_THEME_TOKENS: {
127
127
  };
128
128
  /** Dark-theme overrides applied on top of the base theme. */
129
129
  export declare const DARK_THEME_TOKENS: {
130
+ readonly "--nk-accent": "#3b82f6";
130
131
  readonly "--nk-color-background": "#000";
131
132
  readonly "--nk-color-surface": "#111";
132
133
  readonly "--nk-color-text": "#fff";
@@ -0,0 +1 @@
1
+ "use strict";const B=require("react"),L=require("./floating-position-Cy9xxdH4.cjs"),S=8;function A(d,r,o,s,c){const[P,p]=B.useState(null);return B.useEffect(()=>{if(!d||!o||!s||!c){p(null);return}const C=o,F=s,i=c,a=o.ownerDocument.defaultView;if(!a)return;const n=a,m=n.getComputedStyle(o),f=Number.parseFloat(m.getPropertyValue("--nk-space-8")),w=Number.isFinite(f)?f:S;function e(){const v=C.getBoundingClientRect(),E=F.getBoundingClientRect(),u=i.getBoundingClientRect(),l=L.calculateFloatingPosition(r,w,v,E,L.getVisibleBounds(u,n.innerWidth,n.innerHeight));p({...l,left:l.left-u.left-i.clientLeft+i.scrollLeft,top:l.top-u.top-i.clientTop+i.scrollTop})}e(),n.addEventListener("scroll",e,!0),n.addEventListener("resize",e);const g=n.ResizeObserver,t=g?new g(e):null;return t==null||t.observe(o),t==null||t.observe(s),t==null||t.observe(c),()=>{n.removeEventListener("scroll",e,!0),n.removeEventListener("resize",e),t==null||t.disconnect()}},[d,c,s,r,o]),P}exports.useFloatingPosition=A;
@@ -0,0 +1,43 @@
1
+ import { useState as v, useEffect as E } from "react";
2
+ import { c as S, g as A } from "./floating-position-5wJ5G5IT.js";
3
+ const N = 8;
4
+ function V(d, r, n, s, c) {
5
+ const [m, p] = v(null);
6
+ return E(() => {
7
+ if (!d || !n || !s || !c) {
8
+ p(null);
9
+ return;
10
+ }
11
+ const B = n, L = s, i = c, f = n.ownerDocument.defaultView;
12
+ if (!f) return;
13
+ const o = f, C = o.getComputedStyle(n), a = Number.parseFloat(
14
+ C.getPropertyValue("--nk-space-8")
15
+ ), P = Number.isFinite(a) ? a : N;
16
+ function e() {
17
+ const w = B.getBoundingClientRect(), F = L.getBoundingClientRect(), l = i.getBoundingClientRect(), u = S(
18
+ r,
19
+ P,
20
+ w,
21
+ F,
22
+ A(
23
+ l,
24
+ o.innerWidth,
25
+ o.innerHeight
26
+ )
27
+ );
28
+ p({
29
+ ...u,
30
+ left: u.left - l.left - i.clientLeft + i.scrollLeft,
31
+ top: u.top - l.top - i.clientTop + i.scrollTop
32
+ });
33
+ }
34
+ e(), o.addEventListener("scroll", e, !0), o.addEventListener("resize", e);
35
+ const g = o.ResizeObserver, t = g ? new g(e) : null;
36
+ return t == null || t.observe(n), t == null || t.observe(s), t == null || t.observe(c), () => {
37
+ o.removeEventListener("scroll", e, !0), o.removeEventListener("resize", e), t == null || t.disconnect();
38
+ };
39
+ }, [d, c, s, r, n]), m;
40
+ }
41
+ export {
42
+ V as u
43
+ };
@@ -0,0 +1 @@
1
+ "use strict";const h=require("react"),E=require("./usePresence-B5RYv4e1.cjs"),N=require("./focus-restoration-70WcQRr5.cjs"),V=["a[href]","area[href]","button","input:not([type=hidden])","select","textarea","iframe","[contenteditable]:not([contenteditable='false'])","[tabindex]"].join(",");function B(n,o){let t=n;for(;t;){if(t.hidden||t.inert||t.getAttribute("aria-hidden")==="true")return!0;const s=t.ownerDocument.defaultView,e=s==null?void 0:s.getComputedStyle(t);if((e==null?void 0:e.display)==="none"||(e==null?void 0:e.visibility)==="hidden")return!0;if(t===o)break;t=t.parentElement}return!1}function K(n,o){var u;const t=(u=n.ownerDocument.defaultView)==null?void 0:u.HTMLInputElement;if(!t||!(n instanceof t)||n.type!=="radio"||!n.name)return!0;const s=o.filter(c=>c instanceof t&&c.type==="radio"&&c.name===n.name&&c.form===n.form),e=s.find(c=>c.checked);return e?e===n:s[0]===n}function P(n){const o=Array.from(n.querySelectorAll(V)).filter(t=>!t.matches(":disabled")&&t.tabIndex>=0&&!B(t,n));return o.filter(t=>K(t,o))}function C(n,o){const t=[n,...o];return[...new Set(t.flatMap(e=>P(e)))].sort((e,u)=>{var a;if(e===u)return 0;const c=e.compareDocumentPosition(u),m=((a=e.ownerDocument.defaultView)==null?void 0:a.Node.DOCUMENT_POSITION_FOLLOWING)??4;return c&m?-1:1})}function w(n,o,t){return t?n.contains(t)||[...o].some(s=>s.contains(t)):!1}function _(n){const{active:o,autoFocus:t=!0,boundary:s,container:e,initialFocusReference:u,layerId:c,restoreFocus:m=!0}=n,a=h.useRef(new Set),S=h.useCallback(f=>(a.current.add(f),()=>a.current.delete(f)),[]),k=h.useMemo(()=>({registerBranch:S}),[S]);return E.useOverlayFocusLayer(o&&!!e,s,c),h.useEffect(()=>{var g,I;if(!o||!e||!s)return;const f=s,i=e.ownerDocument,L=(g=i.defaultView)==null?void 0:g.HTMLElement,T=(I=i.defaultView)==null?void 0:I.Node,p=L&&i.activeElement instanceof L?i.activeElement:null;let v=!0;function O(){const r=u==null?void 0:u.current;(r&&w(e,a.current,r)?r:C(e,a.current)[0]??e).focus({preventScroll:!0})}function D(r){if(r.key!=="Tab"||!E.isTopmostFocusLayer(f,c)||E.isFocusInsideAnotherOverlay(i,f))return;const l=C(e,a.current);if(l.length===0){r.preventDefault(),e==null||e.focus({preventScroll:!0});return}const y=l[0],b=l[l.length-1],d=i.activeElement,q=w(e,a.current,d),A=!l.some(M=>M===d)&&(d===e||d===(u==null?void 0:u.current));if(!q||A){r.preventDefault(),(r.shiftKey?b:y).focus();return}r.shiftKey&&d===y?(r.preventDefault(),b.focus()):!r.shiftKey&&d===b&&(r.preventDefault(),y.focus())}function F(r){E.isTopmostFocusLayer(f,c)&&!E.isFocusInsideAnotherOverlay(i,f)&&T&&r.target instanceof T&&!w(e,a.current,r.target)&&O()}return i.addEventListener("keydown",D,!0),i.addEventListener("focusin",F,!0),t&&Promise.resolve().then(()=>{v&&O()}),()=>{v=!1,i.removeEventListener("keydown",D,!0),i.removeEventListener("focusin",F,!0),m&&(p!=null&&p.isConnected)&&N.restoreElementFocus(p)}},[o,t,s,e,u,c,m]),k}exports.useFocusTrap=_;
@@ -0,0 +1,136 @@
1
+ import { useRef as V, useCallback as q, useMemo as x, useEffect as B } from "react";
2
+ import { u as K, i as C, a as I } from "./usePresence-CqegYqy4.js";
3
+ import { r as _ } from "./focus-restoration-BvNZzrQA.js";
4
+ const H = [
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 P(n, o) {
16
+ let t = n;
17
+ for (; t; ) {
18
+ if (t.hidden || t.inert || t.getAttribute("aria-hidden") === "true")
19
+ return !0;
20
+ const s = t.ownerDocument.defaultView, e = s == null ? void 0 : s.getComputedStyle(t);
21
+ if ((e == null ? void 0 : e.display) === "none" || (e == null ? void 0 : e.visibility) === "hidden")
22
+ return !0;
23
+ if (t === o) break;
24
+ t = t.parentElement;
25
+ }
26
+ return !1;
27
+ }
28
+ function G(n, o) {
29
+ var u;
30
+ const t = (u = n.ownerDocument.defaultView) == null ? void 0 : u.HTMLInputElement;
31
+ if (!t || !(n instanceof t) || n.type !== "radio" || !n.name)
32
+ return !0;
33
+ const s = o.filter(
34
+ (c) => c instanceof t && c.type === "radio" && c.name === n.name && c.form === n.form
35
+ ), e = s.find((c) => c.checked);
36
+ return e ? e === n : s[0] === n;
37
+ }
38
+ function R(n) {
39
+ const o = Array.from(
40
+ n.querySelectorAll(H)
41
+ ).filter((t) => !t.matches(":disabled") && t.tabIndex >= 0 && !P(t, n));
42
+ return o.filter(
43
+ (t) => G(t, o)
44
+ );
45
+ }
46
+ function F(n, o) {
47
+ const t = [n, ...o];
48
+ return [...new Set(
49
+ t.flatMap(
50
+ (e) => R(e)
51
+ )
52
+ )].sort((e, u) => {
53
+ var a;
54
+ if (e === u) return 0;
55
+ const c = e.compareDocumentPosition(u), m = ((a = e.ownerDocument.defaultView) == null ? void 0 : a.Node.DOCUMENT_POSITION_FOLLOWING) ?? 4;
56
+ return c & m ? -1 : 1;
57
+ });
58
+ }
59
+ function y(n, o, t) {
60
+ return t ? n.contains(t) || [...o].some((s) => s.contains(t)) : !1;
61
+ }
62
+ function Q(n) {
63
+ const {
64
+ active: o,
65
+ autoFocus: t = !0,
66
+ boundary: s,
67
+ container: e,
68
+ initialFocusReference: u,
69
+ layerId: c,
70
+ restoreFocus: m = !0
71
+ } = n, a = V(/* @__PURE__ */ new Set()), b = q((f) => (a.current.add(f), () => a.current.delete(f)), []), k = x(() => ({ registerBranch: b }), [b]);
72
+ return K(o && !!e, s, c), B(() => {
73
+ var T, g;
74
+ if (!o || !e || !s) return;
75
+ const f = s, i = e.ownerDocument, w = (T = i.defaultView) == null ? void 0 : T.HTMLElement, S = (g = i.defaultView) == null ? void 0 : g.Node, E = w && i.activeElement instanceof w ? i.activeElement : null;
76
+ let L = !0;
77
+ function v() {
78
+ const r = u == null ? void 0 : u.current;
79
+ (r && y(
80
+ e,
81
+ a.current,
82
+ r
83
+ ) ? r : F(
84
+ e,
85
+ a.current
86
+ )[0] ?? e).focus({ preventScroll: !0 });
87
+ }
88
+ function D(r) {
89
+ if (r.key !== "Tab" || !C(f, c) || I(i, f))
90
+ return;
91
+ const l = F(
92
+ e,
93
+ a.current
94
+ );
95
+ if (l.length === 0) {
96
+ r.preventDefault(), e == null || e.focus({ preventScroll: !0 });
97
+ return;
98
+ }
99
+ const p = l[0], h = l[l.length - 1], d = i.activeElement, M = y(
100
+ e,
101
+ a.current,
102
+ d
103
+ ), N = !l.some(
104
+ (A) => A === d
105
+ ) && (d === e || d === (u == null ? void 0 : u.current));
106
+ if (!M || N) {
107
+ r.preventDefault(), (r.shiftKey ? h : p).focus();
108
+ return;
109
+ }
110
+ r.shiftKey && d === p ? (r.preventDefault(), h.focus()) : !r.shiftKey && d === h && (r.preventDefault(), p.focus());
111
+ }
112
+ function O(r) {
113
+ C(f, c) && !I(i, f) && S && r.target instanceof S && !y(
114
+ e,
115
+ a.current,
116
+ r.target
117
+ ) && v();
118
+ }
119
+ return i.addEventListener("keydown", D, !0), i.addEventListener("focusin", O, !0), t && Promise.resolve().then(() => {
120
+ L && v();
121
+ }), () => {
122
+ L = !1, i.removeEventListener("keydown", D, !0), i.removeEventListener("focusin", O, !0), m && (E != null && E.isConnected) && _(E);
123
+ };
124
+ }, [
125
+ o,
126
+ t,
127
+ s,
128
+ e,
129
+ u,
130
+ c,
131
+ m
132
+ ]), k;
133
+ }
134
+ export {
135
+ Q as u
136
+ };
@@ -0,0 +1 @@
1
+ "use client";"use strict";const w=require("react/jsx-runtime"),o=require("react"),k=require("react-dom"),O=require("./effects-D85L_7zM.cjs");function P(r){const e=o.useContext(O.BoundaryContext);if(r!==void 0&&!e)throw new Error(`${r} must be rendered inside Boundary. Neatkit resolves portals, overlay stacking, and responsive behavior against the nearest Boundary, so wrap your interface in <Boundary>.`);return e}const x=o.createContext(void 0);function M(r){const{children:e}=r,t=o.useRef(null),n=o.useContext(x);return O.useIsomorphicLayoutEffect(()=>{const s=t.current;if(!(!s||!n))return n.registerBranch(s)},[n]),w.jsx("div",{className:"nk-portal",ref:t,style:{display:"contents"},children:e})}function T(r){const{children:e}=r,t=P("Portal"),[n,s]=o.useState(!1);o.useEffect(()=>{s(!0)},[]);const c=t.portalElement;return n&&c?k.createPortal(w.jsx(M,{children:e}),c):null}const b=1e3,A=10,v=new WeakMap;function y(r){const e=v.get(r);if(e)return e;const t={focusLayers:new Set,layers:[],listeners:new Set};return v.set(r,t),t}function g(r){r.listeners.forEach(e=>e())}function C(r,e){const t=o.useRef(Symbol("nk-overlay-layer")),[,n]=o.useReducer(u=>u+1,0);o.useEffect(()=>{if(!r||!e)return;const u=y(e),l=()=>n();return u.listeners.add(l),u.layers.push(t.current),g(u),()=>{u.listeners.delete(l);const f=u.layers.indexOf(t.current);f>=0&&u.layers.splice(f,1),g(u)}},[r,e]);const s=e?y(e):null,c=(s==null?void 0:s.layers.indexOf(t.current))??-1,i=c>=0?c:(s==null?void 0:s.layers.length)??0;return{id:t.current,zIndex:b+i*A}}function m(r,e){const t=y(r).layers;return t.length>0&&t[t.length-1]===e}function F(r){var e;return(((e=v.get(r))==null?void 0:e.layers.length)??0)>0}function _(r,e,t){o.useEffect(()=>{if(!r||!e)return;const n=y(e);return n.focusLayers.add(t),()=>{n.focusLayers.delete(t)}},[r,t,e])}function N(r,e){const t=y(r);for(let n=t.layers.length-1;n>=0;n-=1){const s=t.layers[n];if(t.focusLayers.has(s))return s===e}return!1}const D=1;function q(r){if(!r)return null;const e=r.nodeType===D?r:r.parentElement;return(e==null?void 0:e.closest(".nk-boundary"))??null}function I(r,e){var n;let t=q(r);for(;t!==null;){if(t===e)return!1;if(F(t))return!0;t=((n=t.parentElement)==null?void 0:n.closest(".nk-boundary"))??null}return!1}function B(r,e){return I(r.activeElement,e)}function j(r,e){return I(r,e)}function V(r,e){const t=r.composedPath();return e.some(n=>{var i;const s=n.current;if(!s)return!1;if(t.includes(s))return!0;const c=(i=s.ownerDocument.defaultView)==null?void 0:i.Node;return c&&r.target instanceof c?s.contains(r.target):!1})}function Y(r){const{active:e,boundaries:t,boundary:n,dismissOnEscape:s=!0,dismissOnPointerDownOutside:c=!0,layerId:i,onEscapeDismiss:u,onEscapeKeyDown:l,onPointerDownOutside:f,onPointerDownOutsideDismiss:h,ownerDocument:d}=r;o.useEffect(()=>{if(!e||!d||!n)return;const p=n,R=d;function E(a){a.key!=="Escape"||!s||!m(p,i)||B(R,p)||(l==null||l(a),!a.defaultPrevented&&(a.preventDefault(),u==null||u()))}function L(a){if(!c||!m(p,i)||V(a,t))return;const S=a.target;j(S,p)||(f==null||f(a),!a.defaultPrevented&&(h==null||h()))}return d.addEventListener("keydown",E,!0),d.addEventListener("pointerdown",L,!0),()=>{d.removeEventListener("keydown",E,!0),d.removeEventListener("pointerdown",L,!0)}},[e,t,n,s,c,i,u,l,f,h,d])}function X(){const[r,e]=o.useState(!1);return o.useEffect(()=>{const t=typeof window>"u"?null:window;if(!(t!=null&&t.matchMedia))return;const n=t.matchMedia("(prefers-reduced-motion: reduce)"),s=()=>{e(n.matches)};return s(),n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[]),r}function Z(r,e=200){const t=X(),[n,s]=o.useState(r);return o.useEffect(()=>{if(r){s(!0);return}if(!n)return;if(t||e<=0){s(!1);return}const c=window.setTimeout(()=>{s(!1)},e);return()=>window.clearTimeout(c)},[e,r,t,n]),{present:n,state:r?"open":n?"closing":"closed"}}exports.FocusScopeContext=x;exports.Portal=T;exports.isFocusInsideAnotherOverlay=B;exports.isTopmostFocusLayer=N;exports.useBoundary=P;exports.useDismissableLayer=Y;exports.useOverlayFocusLayer=_;exports.useOverlayLayer=C;exports.usePresence=Z;
@@ -0,0 +1,221 @@
1
+ "use client";
2
+ import { jsx as P } from "react/jsx-runtime";
3
+ import { useContext as O, createContext as M, useState as m, useEffect as d, useRef as B, useReducer as R } from "react";
4
+ import { createPortal as b } from "react-dom";
5
+ import { B as S, u as T } from "./effects-D5CWf-Pl.js";
6
+ function _(r) {
7
+ const e = O(S);
8
+ if (r !== void 0 && !e)
9
+ throw new Error(
10
+ `${r} must be rendered inside Boundary. Neatkit resolves portals, overlay stacking, and responsive behavior against the nearest Boundary, so wrap your interface in <Boundary>.`
11
+ );
12
+ return e;
13
+ }
14
+ const A = M(void 0);
15
+ function N(r) {
16
+ const { children: e } = r, n = B(null), t = O(A);
17
+ return T(() => {
18
+ const s = n.current;
19
+ if (!(!s || !t))
20
+ return t.registerBranch(s);
21
+ }, [t]), /* @__PURE__ */ P(
22
+ "div",
23
+ {
24
+ className: "nk-portal",
25
+ ref: n,
26
+ style: { display: "contents" },
27
+ children: e
28
+ }
29
+ );
30
+ }
31
+ function H(r) {
32
+ const { children: e } = r, n = _("Portal"), [t, s] = m(!1);
33
+ d(() => {
34
+ s(!0);
35
+ }, []);
36
+ const u = n.portalElement;
37
+ return t && u ? b(/* @__PURE__ */ P(N, { children: e }), u) : null;
38
+ }
39
+ const C = 1e3, F = 10, v = /* @__PURE__ */ new WeakMap();
40
+ function y(r) {
41
+ const e = v.get(r);
42
+ if (e) return e;
43
+ const n = {
44
+ focusLayers: /* @__PURE__ */ new Set(),
45
+ layers: [],
46
+ listeners: /* @__PURE__ */ new Set()
47
+ };
48
+ return v.set(r, n), n;
49
+ }
50
+ function L(r) {
51
+ r.listeners.forEach((e) => e());
52
+ }
53
+ function J(r, e) {
54
+ const n = B(Symbol("nk-overlay-layer")), [, t] = R((o) => o + 1, 0);
55
+ d(() => {
56
+ if (!r || !e) return;
57
+ const o = y(e), i = () => t();
58
+ return o.listeners.add(i), o.layers.push(n.current), L(o), () => {
59
+ o.listeners.delete(i);
60
+ const l = o.layers.indexOf(n.current);
61
+ l >= 0 && o.layers.splice(l, 1), L(o);
62
+ };
63
+ }, [r, e]);
64
+ const s = e ? y(e) : null, u = (s == null ? void 0 : s.layers.indexOf(
65
+ n.current
66
+ )) ?? -1, c = u >= 0 ? u : (s == null ? void 0 : s.layers.length) ?? 0;
67
+ return {
68
+ id: n.current,
69
+ zIndex: C + c * F
70
+ };
71
+ }
72
+ function w(r, e) {
73
+ const n = y(r).layers;
74
+ return n.length > 0 && n[n.length - 1] === e;
75
+ }
76
+ function D(r) {
77
+ var e;
78
+ return (((e = v.get(r)) == null ? void 0 : e.layers.length) ?? 0) > 0;
79
+ }
80
+ function K(r, e, n) {
81
+ d(() => {
82
+ if (!r || !e) return;
83
+ const t = y(e);
84
+ return t.focusLayers.add(n), () => {
85
+ t.focusLayers.delete(n);
86
+ };
87
+ }, [r, n, e]);
88
+ }
89
+ function U(r, e) {
90
+ const n = y(r);
91
+ for (let t = n.layers.length - 1; t >= 0; t -= 1) {
92
+ const s = n.layers[t];
93
+ if (n.focusLayers.has(s))
94
+ return s === e;
95
+ }
96
+ return !1;
97
+ }
98
+ const V = 1;
99
+ function Y(r) {
100
+ if (!r) return null;
101
+ const e = r.nodeType === V ? r : r.parentElement;
102
+ return (e == null ? void 0 : e.closest(".nk-boundary")) ?? null;
103
+ }
104
+ function I(r, e) {
105
+ var t;
106
+ let n = Y(r);
107
+ for (; n !== null; ) {
108
+ if (n === e) return !1;
109
+ if (D(n)) return !0;
110
+ n = ((t = n.parentElement) == null ? void 0 : t.closest(".nk-boundary")) ?? null;
111
+ }
112
+ return !1;
113
+ }
114
+ function X(r, e) {
115
+ return I(
116
+ r.activeElement,
117
+ e
118
+ );
119
+ }
120
+ function Z(r, e) {
121
+ return I(r, e);
122
+ }
123
+ function j(r, e) {
124
+ const n = r.composedPath();
125
+ return e.some((t) => {
126
+ var c;
127
+ const s = t.current;
128
+ if (!s) return !1;
129
+ if (n.includes(s)) return !0;
130
+ const u = (c = s.ownerDocument.defaultView) == null ? void 0 : c.Node;
131
+ return u && r.target instanceof u ? s.contains(r.target) : !1;
132
+ });
133
+ }
134
+ function W(r) {
135
+ const {
136
+ active: e,
137
+ boundaries: n,
138
+ boundary: t,
139
+ dismissOnEscape: s = !0,
140
+ dismissOnPointerDownOutside: u = !0,
141
+ layerId: c,
142
+ onEscapeDismiss: o,
143
+ onEscapeKeyDown: i,
144
+ onPointerDownOutside: l,
145
+ onPointerDownOutsideDismiss: h,
146
+ ownerDocument: f
147
+ } = r;
148
+ d(() => {
149
+ if (!e || !f || !t) return;
150
+ const p = t, x = f;
151
+ function E(a) {
152
+ a.key !== "Escape" || !s || !w(p, c) || X(x, p) || (i == null || i(a), !a.defaultPrevented && (a.preventDefault(), o == null || o()));
153
+ }
154
+ function g(a) {
155
+ if (!u || !w(p, c) || j(a, n))
156
+ return;
157
+ const k = a.target;
158
+ Z(k, p) || (l == null || l(a), !a.defaultPrevented && (h == null || h()));
159
+ }
160
+ return f.addEventListener("keydown", E, !0), f.addEventListener("pointerdown", g, !0), () => {
161
+ f.removeEventListener("keydown", E, !0), f.removeEventListener("pointerdown", g, !0);
162
+ };
163
+ }, [
164
+ e,
165
+ n,
166
+ t,
167
+ s,
168
+ u,
169
+ c,
170
+ o,
171
+ i,
172
+ l,
173
+ h,
174
+ f
175
+ ]);
176
+ }
177
+ function z() {
178
+ const [r, e] = m(!1);
179
+ return d(() => {
180
+ const n = typeof window > "u" ? null : window;
181
+ if (!(n != null && n.matchMedia)) return;
182
+ const t = n.matchMedia(
183
+ "(prefers-reduced-motion: reduce)"
184
+ ), s = () => {
185
+ e(t.matches);
186
+ };
187
+ return s(), t.addEventListener("change", s), () => t.removeEventListener("change", s);
188
+ }, []), r;
189
+ }
190
+ function ee(r, e = 200) {
191
+ const n = z(), [t, s] = m(r);
192
+ return d(() => {
193
+ if (r) {
194
+ s(!0);
195
+ return;
196
+ }
197
+ if (!t) return;
198
+ if (n || e <= 0) {
199
+ s(!1);
200
+ return;
201
+ }
202
+ const u = window.setTimeout(() => {
203
+ s(!1);
204
+ }, e);
205
+ return () => window.clearTimeout(u);
206
+ }, [e, r, n, t]), {
207
+ present: t,
208
+ state: r ? "open" : t ? "closing" : "closed"
209
+ };
210
+ }
211
+ export {
212
+ A as F,
213
+ H as P,
214
+ X as a,
215
+ _ as b,
216
+ ee as c,
217
+ J as d,
218
+ W as e,
219
+ U as i,
220
+ K as u
221
+ };
@@ -0,0 +1,62 @@
1
+ import { useEffect as g } from "react";
2
+ const m = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]);
3
+ function h(e, l) {
4
+ const o = l.defaultView;
5
+ if (!e || !o) return null;
6
+ let t = e;
7
+ for (; t !== null && t !== l.body && t !== l.documentElement; ) {
8
+ if (t !== e && t.classList.contains("nk-boundary"))
9
+ return null;
10
+ const s = o.getComputedStyle(t);
11
+ if ([
12
+ s.overflowY,
13
+ s.overflowX,
14
+ ...s.overflow.split(/\s+/)
15
+ ].some((n) => m.has(n)))
16
+ return t;
17
+ t = t.parentElement;
18
+ }
19
+ return l;
20
+ }
21
+ const i = /* @__PURE__ */ new WeakMap();
22
+ function f(e) {
23
+ const o = (e.ownerDocument ?? e).defaultView, t = o == null ? void 0 : o.Document, s = o == null ? void 0 : o.HTMLElement;
24
+ if (t && e instanceof t) {
25
+ const r = e.defaultView, n = e.documentElement.clientWidth;
26
+ return {
27
+ element: e.body,
28
+ scrollbarWidth: r && n > 0 ? Math.max(0, r.innerWidth - n) : 0
29
+ };
30
+ }
31
+ return !s || !(e instanceof s) ? null : {
32
+ element: e,
33
+ scrollbarWidth: Math.max(0, e.offsetWidth - e.clientWidth)
34
+ };
35
+ }
36
+ function w(e, l, o) {
37
+ g(() => {
38
+ if (!e || !l) return;
39
+ const t = h(o, l);
40
+ if (!t) return;
41
+ const s = i.get(t);
42
+ if (s)
43
+ return s.count += 1, () => d(t);
44
+ const r = f(t);
45
+ if (!r) return;
46
+ const { element: n, scrollbarWidth: c } = r, u = l.defaultView, a = u && Number.parseFloat(u.getComputedStyle(n).paddingRight) || 0;
47
+ return i.set(t, {
48
+ count: 1,
49
+ overflow: n.style.overflow,
50
+ paddingRight: n.style.paddingRight
51
+ }), n.style.overflow = "hidden", c > 0 && (n.style.paddingRight = `${a + c}px`), () => d(t);
52
+ }, [e, o, l]);
53
+ }
54
+ function d(e) {
55
+ const l = i.get(e);
56
+ if (!l || (l.count -= 1, l.count > 0)) return;
57
+ const o = f(e);
58
+ o && (o.element.style.overflow = l.overflow, o.element.style.paddingRight = l.paddingRight), i.delete(e);
59
+ }
60
+ export {
61
+ w as u
62
+ };
@@ -0,0 +1 @@
1
+ "use strict";const g=require("react"),m=new Set(["auto","scroll","overlay"]);function h(e,l){const o=l.defaultView;if(!e||!o)return null;let t=e;for(;t!==null&&t!==l.body&&t!==l.documentElement;){if(t!==e&&t.classList.contains("nk-boundary"))return null;const s=o.getComputedStyle(t);if([s.overflowY,s.overflowX,...s.overflow.split(/\s+/)].some(n=>m.has(n)))return t;t=t.parentElement}return l}const c=new WeakMap;function f(e){const o=(e.ownerDocument??e).defaultView,t=o==null?void 0:o.Document,s=o==null?void 0:o.HTMLElement;if(t&&e instanceof t){const r=e.defaultView,n=e.documentElement.clientWidth;return{element:e.body,scrollbarWidth:r&&n>0?Math.max(0,r.innerWidth-n):0}}return!s||!(e instanceof s)?null:{element:e,scrollbarWidth:Math.max(0,e.offsetWidth-e.clientWidth)}}function p(e,l,o){g.useEffect(()=>{if(!e||!l)return;const t=h(o,l);if(!t)return;const s=c.get(t);if(s)return s.count+=1,()=>d(t);const r=f(t);if(!r)return;const{element:n,scrollbarWidth:i}=r,u=l.defaultView,a=u&&Number.parseFloat(u.getComputedStyle(n).paddingRight)||0;return c.set(t,{count:1,overflow:n.style.overflow,paddingRight:n.style.paddingRight}),n.style.overflow="hidden",i>0&&(n.style.paddingRight=`${a+i}px`),()=>d(t)},[e,o,l])}function d(e){const l=c.get(e);if(!l||(l.count-=1,l.count>0))return;const o=f(e);o&&(o.element.style.overflow=l.overflow,o.element.style.paddingRight=l.paddingRight),c.delete(e)}exports.useScrollLock=p;
@@ -16,3 +16,12 @@ export declare function hasInvalidState(ariaInvalid: AriaAttributes["aria-invali
16
16
  * @returns The value exposed through the rendered ARIA attribute.
17
17
  */
18
18
  export declare function resolveAriaInvalid(invalid: boolean, ariaInvalid: AriaAttributes["aria-invalid"]): AriaAttributes["aria-invalid"];
19
+ /**
20
+ * Appends one identifier to an existing space-separated association.
21
+ *
22
+ * @param identifiers - The existing association identifiers.
23
+ * @param identifier - The identifier appended when it is not already present.
24
+ *
25
+ * @returns The combined identifier list without duplicates.
26
+ */
27
+ export declare function mergeIdentifiers(identifiers: string | undefined, identifier: string): string;
@@ -0,0 +1,12 @@
1
+ import { useEffect } from "react";
2
+ /**
3
+ * The layout effect variant that is also safe to evaluate while rendering
4
+ * on a server.
5
+ *
6
+ * A layout effect cannot run before markup is serialized, so React warns
7
+ * whenever a component using one is server-rendered. Selecting the passive
8
+ * variant when no window exists keeps that warning out of a consumer's
9
+ * server output while preserving before-paint timing in a browser, where
10
+ * measurement and publication have to settle before the frame is shown.
11
+ */
12
+ export declare const useIsomorphicLayoutEffect: typeof useEffect;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neatkit",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "A modern, composable UI library for the web.",
5
5
  "keywords": [
6
6
  "library",
@@ -44,6 +44,11 @@
44
44
  "import": "./dist/Badge.js",
45
45
  "require": "./dist/Badge.cjs"
46
46
  },
47
+ "./Boundary": {
48
+ "types": "./dist/components/Boundary/index.d.ts",
49
+ "import": "./dist/Boundary.js",
50
+ "require": "./dist/Boundary.cjs"
51
+ },
47
52
  "./Button": {
48
53
  "types": "./dist/components/Button/index.d.ts",
49
54
  "import": "./dist/Button.js",
@@ -59,21 +64,11 @@
59
64
  "import": "./dist/Checkbox.js",
60
65
  "require": "./dist/Checkbox.cjs"
61
66
  },
62
- "./CheckboxGroup": {
63
- "types": "./dist/components/CheckboxGroup/index.d.ts",
64
- "import": "./dist/CheckboxGroup.js",
65
- "require": "./dist/CheckboxGroup.cjs"
66
- },
67
67
  "./Code": {
68
68
  "types": "./dist/components/Code/index.d.ts",
69
69
  "import": "./dist/Code.js",
70
70
  "require": "./dist/Code.cjs"
71
71
  },
72
- "./Content": {
73
- "types": "./dist/components/Content/index.d.ts",
74
- "import": "./dist/Content.js",
75
- "require": "./dist/Content.cjs"
76
- },
77
72
  "./Divider": {
78
73
  "types": "./dist/components/Divider/index.d.ts",
79
74
  "import": "./dist/Divider.js",
@@ -119,16 +114,16 @@
119
114
  "import": "./dist/Radio.js",
120
115
  "require": "./dist/Radio.cjs"
121
116
  },
122
- "./RadioGroup": {
123
- "types": "./dist/components/RadioGroup/index.d.ts",
124
- "import": "./dist/RadioGroup.js",
125
- "require": "./dist/RadioGroup.cjs"
126
- },
127
117
  "./Select": {
128
118
  "types": "./dist/components/Select/index.d.ts",
129
119
  "import": "./dist/Select.js",
130
120
  "require": "./dist/Select.cjs"
131
121
  },
122
+ "./Sidebar": {
123
+ "types": "./dist/components/Sidebar/index.d.ts",
124
+ "import": "./dist/Sidebar.js",
125
+ "require": "./dist/Sidebar.cjs"
126
+ },
132
127
  "./Skeleton": {
133
128
  "types": "./dist/components/Skeleton/index.d.ts",
134
129
  "import": "./dist/Skeleton.js",
@@ -1 +0,0 @@
1
- "use client";"use strict";const r=require("react/jsx-runtime"),f=require("react"),v=require("./Icon-D8IZceys.cjs"),F=require("./Spinner-BXgw60UC.cjs");function m(t){return t==null||typeof t=="boolean"||typeof t=="string"&&!t.trim()?!1:Array.isArray(t)?t.some(m):f.isValidElement(t)&&t.type===f.Fragment?m(t.props.children):!0}function K(t,a){const l=t.getBoundingClientRect(),y=a.clientX-l.left,c=a.clientY-l.top;t.style.setProperty("--nk-button-glow-x",`${y}px`),t.style.setProperty("--nk-button-glow-y",`${c}px`)}const $=f.forwardRef(function(a,l){const{as:y,children:c,className:P,disabled:j,fullWidth:B=!1,icon:s,iconAlignment:x="left",loading:b=!1,onClick:w,onKeyDown:k,onMouseMove:I,role:h,shape:A="capsule",tabIndex:g,textAlignment:q="center",tone:D,variant:R="primary",...u}=a,i=y??"button",o=j||b,z=!!s&&!m(c),d=i==="a"&&"href"in u&&typeof u.href=="string",p=typeof i=="string"&&i!=="button"&&!d,E=n=>{if(o){n.preventDefault(),n.stopPropagation();return}const e=w;e==null||e(n)},M=n=>{K(n.currentTarget,n);const e=I;e==null||e(n)},N=n=>{const e=k;e==null||e(n),!(n.defaultPrevented||o||!p||n.key!=="Enter"&&n.key!==" ")&&(n.preventDefault(),n.currentTarget.click())},S=i==="button"?{disabled:o,type:u.type??"button"}:{"aria-disabled":o||void 0},_=d&&o?{href:void 0}:void 0,T=d&&o?h??"link":p?h??"button":h,C=i==="button"?g:d&&o?void 0:o?-1:p?g??0:g;return f.createElement(i,{...u,...S,..._,ref:l,"aria-busy":b||void 0,className:["nk-button",P].filter(Boolean).join(" "),"data-full-width":B||void 0,"data-icon-only":z||void 0,"data-shape":A,"data-tone":D,"data-variant":R,onClick:E,onKeyDown:p?N:k,onMouseMove:M,role:T,tabIndex:C},r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"nk-button__content",style:{justifyContent:q},children:[s&&x==="left"?r.jsx(v.Icon,{size:14,type:s}):null,c,s&&x==="right"?r.jsx(v.Icon,{size:14,type:s}):null]}),b?r.jsx(F.Spinner,{"aria-hidden":"true","aria-label":void 0,className:"nk-button__spinner",role:void 0,size:16}):null]}))});exports.Button=$;
@@ -1,68 +0,0 @@
1
- "use client";
2
- import { jsxs as k, jsx as a } from "react/jsx-runtime";
3
- import { createContext as j, useContext as y, forwardRef as B } from "react";
4
- import { r as S, h as V } from "./aria-DHnOMyYp.js";
5
- import { q as P } from "./Icon-uQmpr5P2.js";
6
- import { T as R } from "./Text-rN6iDo0V.js";
7
- const T = j(void 0);
8
- function w() {
9
- return y(T);
10
- }
11
- const J = B(function(m, f) {
12
- var u;
13
- const {
14
- "aria-invalid": s,
15
- checked: v,
16
- children: o,
17
- className: b,
18
- defaultChecked: x,
19
- disabled: C = !1,
20
- invalid: c = !1,
21
- name: p,
22
- onChange: n,
23
- required: d = !1,
24
- style: _,
25
- value: t = "on",
26
- ...N
27
- } = m, e = w(), i = String(t), r = (e == null ? void 0 : e.value) !== void 0, h = C || !!(e != null && e.disabled), q = !!(e != null && e.required && !e.hasSelection && e.validationValue === i), I = c || V(s);
28
- function G(l) {
29
- n == null || n(l), l.defaultPrevented || e == null || e.handleChange(l);
30
- }
31
- return /* @__PURE__ */ k(
32
- "label",
33
- {
34
- className: ["nk-checkbox", b].filter(Boolean).join(" "),
35
- "data-disabled": h || void 0,
36
- "data-invalid": I || void 0,
37
- style: _,
38
- children: [
39
- /* @__PURE__ */ a(
40
- "input",
41
- {
42
- ...N,
43
- ref: f,
44
- "aria-invalid": S(c, s),
45
- checked: e ? r ? (u = e.value) == null ? void 0 : u.includes(i) : void 0 : v,
46
- className: "nk-checkbox__control",
47
- defaultChecked: e && !r ? e.defaultValue.includes(i) : x,
48
- disabled: h,
49
- name: (e == null ? void 0 : e.name) ?? p,
50
- onChange: G,
51
- required: d || q,
52
- type: "checkbox",
53
- value: t
54
- }
55
- ),
56
- /* @__PURE__ */ a("span", { "aria-hidden": "true", className: "nk-checkbox__visual", children: /* @__PURE__ */ a(P, { className: "nk-checkbox__icon", size: 12, type: "checkmark" }) }),
57
- o !== void 0 ? /* @__PURE__ */ k(R, { as: "span", className: "nk-checkbox__label", children: [
58
- o,
59
- d ? /* @__PURE__ */ a("span", { "aria-hidden": "true", className: "nk-checkbox__required", children: "*" }) : null
60
- ] }) : null
61
- ]
62
- }
63
- );
64
- });
65
- export {
66
- J as C,
67
- T as a
68
- };
@@ -1 +0,0 @@
1
- "use client";"use strict";const a=require("react/jsx-runtime"),s=require("react"),k=require("./aria-DKxpE8cA.cjs"),B=require("./Icon-D8IZceys.cjs"),R=require("./Text-DWYlIcPj.cjs"),b=s.createContext(void 0);function S(){return s.useContext(b)}const V=s.forwardRef(function(v,f){var x;const{"aria-invalid":l,checked:C,children:o,className:m,defaultChecked:q,disabled:_=!1,invalid:t=!1,name:j,onChange:n,required:d=!1,style:N,value:r="on",...I}=v,e=S(),i=String(r),u=(e==null?void 0:e.value)!==void 0,h=_||!!(e!=null&&e.disabled),p=!!(e!=null&&e.required&&!e.hasSelection&&e.validationValue===i),G=t||k.hasInvalidState(l);function y(c){n==null||n(c),c.defaultPrevented||e==null||e.handleChange(c)}return a.jsxs("label",{className:["nk-checkbox",m].filter(Boolean).join(" "),"data-disabled":h||void 0,"data-invalid":G||void 0,style:N,children:[a.jsx("input",{...I,ref:f,"aria-invalid":k.resolveAriaInvalid(t,l),checked:e?u?(x=e.value)==null?void 0:x.includes(i):void 0:C,className:"nk-checkbox__control",defaultChecked:e&&!u?e.defaultValue.includes(i):q,disabled:h,name:(e==null?void 0:e.name)??j,onChange:y,required:d||p,type:"checkbox",value:r}),a.jsx("span",{"aria-hidden":"true",className:"nk-checkbox__visual",children:a.jsx(B.Icon,{className:"nk-checkbox__icon",size:12,type:"checkmark"})}),o!==void 0?a.jsxs(R.Text,{as:"span",className:"nk-checkbox__label",children:[o,d?a.jsx("span",{"aria-hidden":"true",className:"nk-checkbox__required",children:"*"}):null]}):null]})});exports.Checkbox=V;exports.CheckboxGroupContext=b;