neatkit 0.7.0 → 0.9.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 (179) 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-BV5OUXpc.js +101 -0
  8. package/dist/Button-DU4j_IED.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-B7s_rN0G.cjs +4 -0
  14. package/dist/Code-Bp2X1k-g.js +224 -0
  15. package/dist/Code.cjs +1 -1
  16. package/dist/Code.js +1 -1
  17. package/dist/Divider-C7XGlr26.cjs +1 -0
  18. package/dist/{Divider-BE15WVDI.js → Divider-DZgpYpr-.js} +1 -1
  19. package/dist/Divider.cjs +1 -1
  20. package/dist/Divider.js +1 -1
  21. package/dist/Icon-BIBzgznI.cjs +1 -0
  22. package/dist/{Icon-uQmpr5P2.js → Icon-CxK1wlGk.js} +194 -181
  23. package/dist/Icon.cjs +1 -1
  24. package/dist/Icon.js +2 -35
  25. package/dist/Input.cjs +1 -1
  26. package/dist/Input.js +70 -79
  27. package/dist/Markdown.cjs +1 -31
  28. package/dist/Markdown.js +469 -18066
  29. package/dist/Modal.cjs +1 -1
  30. package/dist/Modal.js +100 -122
  31. package/dist/PinInput.cjs +1 -1
  32. package/dist/PinInput.js +1 -1
  33. package/dist/Popover.cjs +1 -1
  34. package/dist/Popover.js +171 -165
  35. package/dist/Radio.cjs +1 -1
  36. package/dist/Radio.js +86 -41
  37. package/dist/Select.cjs +1 -1
  38. package/dist/Select.js +326 -315
  39. package/dist/Sidebar.cjs +1 -0
  40. package/dist/Sidebar.js +490 -0
  41. package/dist/Skeleton.cjs +1 -1
  42. package/dist/Skeleton.js +20 -16
  43. package/dist/Switch.cjs +1 -1
  44. package/dist/Switch.js +1 -1
  45. package/dist/Table-CADupJEU.js +423 -0
  46. package/dist/Table-qetwZpTC.cjs +1 -0
  47. package/dist/Table.cjs +1 -1
  48. package/dist/Table.js +1 -1
  49. package/dist/TextArea.cjs +1 -1
  50. package/dist/TextArea.js +1 -1
  51. package/dist/Tooltip-B2d5ss7S.cjs +1 -0
  52. package/dist/Tooltip-BK64rkxV.js +231 -0
  53. package/dist/Tooltip.cjs +1 -1
  54. package/dist/Tooltip.js +2 -3
  55. package/dist/albert-sans-cb3e34c4.woff2 +0 -0
  56. package/dist/aria-Bntn6ad_.cjs +1 -0
  57. package/dist/aria-CeA9QfD1.js +15 -0
  58. package/dist/components/Boundary/Boundary.d.ts +65 -0
  59. package/dist/components/Boundary/contexts/BoundaryContext.d.ts +28 -0
  60. package/dist/components/Boundary/hooks/useBoundary.d.ts +19 -0
  61. package/dist/components/Boundary/hooks/useBoundaryWidth.d.ts +23 -0
  62. package/dist/components/Boundary/index.d.ts +2 -0
  63. package/dist/components/Boundary/utils/width.d.ts +11 -0
  64. package/dist/components/Checkbox/Checkbox.d.ts +9 -1
  65. package/dist/components/{CheckboxGroup → Checkbox/components}/CheckboxGroup.d.ts +2 -2
  66. package/dist/components/Checkbox/index.d.ts +1 -0
  67. package/dist/components/Checkbox/utils/checkbox-option.d.ts +17 -0
  68. package/dist/components/Icon/Icon.d.ts +1 -0
  69. package/dist/components/Icon/icons/GearIcon.d.ts +11 -0
  70. package/dist/components/Icon/icons/ImageIcon.d.ts +11 -0
  71. package/dist/components/Icon/index.d.ts +0 -33
  72. package/dist/components/Icon/utils/registry.d.ts +2 -0
  73. package/dist/components/Input/Input.d.ts +1 -9
  74. package/dist/components/Modal/Modal.d.ts +0 -4
  75. package/dist/components/PinInput/PinInput.d.ts +1 -1
  76. package/dist/components/Popover/Popover.d.ts +2 -6
  77. package/dist/components/Portal/Portal.d.ts +11 -8
  78. package/dist/components/Portal/hooks/useDismissableLayer.d.ts +2 -0
  79. package/dist/components/Portal/hooks/useFloatingPosition.d.ts +4 -3
  80. package/dist/components/Portal/hooks/useFocusTrap.d.ts +2 -0
  81. package/dist/components/Portal/hooks/useScrollLock.d.ts +9 -3
  82. package/dist/components/Portal/utils/boundary-focus.d.ts +23 -0
  83. package/dist/components/Portal/utils/floating-position.d.ts +43 -9
  84. package/dist/components/Portal/utils/overlay-stack.d.ts +22 -10
  85. package/dist/components/Portal/utils/scroll-container.d.ts +13 -0
  86. package/dist/components/Radio/Radio.d.ts +9 -1
  87. package/dist/components/{RadioGroup → Radio/components}/RadioGroup.d.ts +9 -2
  88. package/dist/components/Radio/index.d.ts +1 -0
  89. package/dist/components/Select/Select.d.ts +0 -2
  90. package/dist/components/Select/utils/listbox-position.d.ts +28 -0
  91. package/dist/components/Sidebar/Sidebar.d.ts +113 -0
  92. package/dist/components/Sidebar/components/SidebarFooter.d.ts +24 -0
  93. package/dist/components/Sidebar/components/SidebarGroup.d.ts +31 -0
  94. package/dist/components/Sidebar/components/SidebarHeader.d.ts +29 -0
  95. package/dist/components/Sidebar/components/SidebarItem.d.ts +46 -0
  96. package/dist/components/Sidebar/components/SidebarOverlay.d.ts +38 -0
  97. package/dist/components/Sidebar/components/SidebarPanel.d.ts +47 -0
  98. package/dist/components/Sidebar/components/SidebarTrigger.d.ts +47 -0
  99. package/dist/components/Sidebar/components/SidebarUser.d.ts +59 -0
  100. package/dist/components/Sidebar/hooks/usePresentation.d.ts +14 -0
  101. package/dist/components/Sidebar/hooks/useSidebar.d.ts +9 -0
  102. package/dist/components/Sidebar/index.d.ts +2 -0
  103. package/dist/components/Sidebar/utils/presentation.d.ts +12 -0
  104. package/dist/components/Sidebar/utils/state.d.ts +62 -0
  105. package/dist/components/Skeleton/Skeleton.d.ts +21 -5
  106. package/dist/components/Table/Table.d.ts +21 -249
  107. package/dist/components/Table/components/TableAction.d.ts +18 -0
  108. package/dist/components/Table/components/TableActionCell.d.ts +15 -0
  109. package/dist/components/Table/components/TableActionHeaderCell.d.ts +13 -0
  110. package/dist/components/Table/components/TableBody.d.ts +27 -0
  111. package/dist/components/Table/components/TableCell.d.ts +42 -0
  112. package/dist/components/Table/components/TableFoot.d.ts +19 -0
  113. package/dist/components/Table/components/TableHead.d.ts +19 -0
  114. package/dist/components/Table/components/TableHeaderCell.d.ts +23 -0
  115. package/dist/components/Table/components/TableRow.d.ts +67 -0
  116. package/dist/components/Table/contexts/TableContext.d.ts +4 -0
  117. package/dist/components/Table/hooks/useHorizontalOverflow.d.ts +25 -0
  118. package/dist/components/Table/index.d.ts +1 -1
  119. package/dist/components/Table/utils/cell.d.ts +25 -0
  120. package/dist/components/Table/utils/children.d.ts +18 -0
  121. package/dist/components/Table/utils/trigger.d.ts +54 -0
  122. package/dist/components/Tooltip/Tooltip.d.ts +10 -4
  123. package/dist/components/Tooltip/TooltipProvider.d.ts +1 -1
  124. package/dist/components/Tooltip/index.d.ts +0 -1
  125. package/dist/effects-D5CWf-Pl.js +8 -0
  126. package/dist/effects-D85L_7zM.cjs +1 -0
  127. package/dist/floating-position-DIjh2wnP.cjs +1 -0
  128. package/dist/floating-position-DvR6e334.js +50 -0
  129. package/dist/style.css +1 -1
  130. package/dist/tokens.d.ts +1 -0
  131. package/dist/useFloatingPosition-B3ZC-v3v.js +43 -0
  132. package/dist/useFloatingPosition-GzkP9dCc.cjs +1 -0
  133. package/dist/useFocusTrap-BrFZdMqQ.cjs +1 -0
  134. package/dist/useFocusTrap-DhVnlboe.js +136 -0
  135. package/dist/usePresence-B5RYv4e1.cjs +1 -0
  136. package/dist/usePresence-CqegYqy4.js +221 -0
  137. package/dist/useScrollLock-Drd7OZRC.js +62 -0
  138. package/dist/useScrollLock-Dy8MZaSn.cjs +1 -0
  139. package/dist/utils/aria.d.ts +9 -0
  140. package/dist/utils/effects.d.ts +12 -0
  141. package/package.json +12 -16
  142. package/dist/Button-BAsLfA0D.js +0 -99
  143. package/dist/Button-D7JUO6Fs.cjs +0 -1
  144. package/dist/Checkbox-BvXM9VyY.js +0 -68
  145. package/dist/Checkbox-VQifZrZZ.cjs +0 -1
  146. package/dist/CheckboxGroup.cjs +0 -1
  147. package/dist/CheckboxGroup.js +0 -144
  148. package/dist/Code-BP2ZCmUf.js +0 -7446
  149. package/dist/Code-eispVOW3.cjs +0 -6
  150. package/dist/Content.cjs +0 -1
  151. package/dist/Content.js +0 -144
  152. package/dist/Divider-CJYbFcSX.cjs +0 -1
  153. package/dist/Icon-D8IZceys.cjs +0 -1
  154. package/dist/RadioGroup.cjs +0 -1
  155. package/dist/RadioGroup.js +0 -51
  156. package/dist/RadioGroupContext-BX9KnDek.cjs +0 -1
  157. package/dist/RadioGroupContext-DbKM4zPZ.js +0 -5
  158. package/dist/Table-83unQQOi.cjs +0 -1
  159. package/dist/Table-Cw8u-pEW.js +0 -403
  160. package/dist/Tooltip-BB82wNOE.cjs +0 -1
  161. package/dist/Tooltip-CqWK_GRD.js +0 -236
  162. package/dist/aria-DHnOMyYp.js +0 -10
  163. package/dist/aria-DKxpE8cA.cjs +0 -1
  164. package/dist/components/CheckboxGroup/index.d.ts +0 -2
  165. package/dist/components/Content/Content.d.ts +0 -60
  166. package/dist/components/Content/hooks/useContentLayout.d.ts +0 -18
  167. package/dist/components/Content/index.d.ts +0 -2
  168. package/dist/components/Content/utils/layout.d.ts +0 -11
  169. package/dist/components/RadioGroup/index.d.ts +0 -2
  170. package/dist/useFloatingPosition-CxzhAvy8.js +0 -73
  171. package/dist/useFloatingPosition-D1FqYy0l.cjs +0 -1
  172. package/dist/useFocusTrap--cgjy78G.cjs +0 -1
  173. package/dist/useFocusTrap-Da4nEash.js +0 -134
  174. package/dist/usePresence-DSPt6aKi.js +0 -210
  175. package/dist/usePresence-qe92UTvK.cjs +0 -1
  176. /package/dist/components/{CheckboxGroup → Checkbox}/contexts/CheckboxGroupContext.d.ts +0 -0
  177. /package/dist/components/{CheckboxGroup → Checkbox}/hooks/useCheckboxGroup.d.ts +0 -0
  178. /package/dist/components/{RadioGroup → Radio}/contexts/RadioGroupContext.d.ts +0 -0
  179. /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,43 @@
1
+ import { useState as v, useEffect as E } from "react";
2
+ import { c as S, g as A } from "./floating-position-DvR6e334.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 B=require("react"),L=require("./floating-position-DIjh2wnP.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 @@
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.9.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",
@@ -172,6 +167,7 @@
172
167
  "test:coverage": "vitest run --coverage",
173
168
  "test:watch": "vitest",
174
169
  "test:imports": "tsx test/imports.ts",
170
+ "test:styles": "tsx test/styles.ts",
175
171
  "typecheck": "tsc --noEmit"
176
172
  },
177
173
  "peerDependencies": {