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/Popover.js CHANGED
@@ -1,231 +1,237 @@
1
1
  "use client";
2
- import { jsxs as te, Fragment as Se, jsx as T } from "react/jsx-runtime";
3
- import { forwardRef as Ce, Fragment as Le, useId as Ne, useContext as Be, useState as j, useRef as b, useReducer as _e, useMemo as je, useCallback as v, useEffect as K, cloneElement as Ke, useLayoutEffect as qe } from "react";
4
- import { g as ze, a as ne } from "./reference-CXMr27nM.js";
5
- import { F as re, a as Ae, b as Me, c as $e, P as He } from "./usePresence-DSPt6aKi.js";
6
- import { u as Ve } from "./useFloatingPosition-CxzhAvy8.js";
7
- import { u as Ue } from "./useFocusTrap-Da4nEash.js";
8
- import { S as Ge } from "./Surface-vEFsZC12.js";
9
- function Je(r) {
10
- const { inert: s, panelElement: a } = r;
11
- return qe(() => {
12
- a && (a.inert = s);
13
- }, [s, a]), null;
2
+ import { jsxs as ne, Fragment as Le, jsx as I } from "react/jsx-runtime";
3
+ import { forwardRef as Ne, Fragment as Be, useId as _e, useContext as Ke, useState as q, useRef as v, useReducer as je, useMemo as qe, useCallback as y, useEffect as z, cloneElement as ze } from "react";
4
+ import { m as Ae } from "./aria-CeA9QfD1.js";
5
+ import { u as Me } from "./effects-D5CWf-Pl.js";
6
+ import { g as $e, a as se } from "./reference-CXMr27nM.js";
7
+ import { F as oe, c as He, b as Ve, d as Ue, e as Ge, P as Je } from "./usePresence-CqegYqy4.js";
8
+ import { u as Qe } from "./useFloatingPosition-B3ZC-v3v.js";
9
+ import { u as We } from "./useFocusTrap-DhVnlboe.js";
10
+ import { S as Xe } from "./Surface-vEFsZC12.js";
11
+ function Ye(o) {
12
+ const { inert: a, panelElement: i } = o;
13
+ return Me(() => {
14
+ i && (i.inert = a);
15
+ }, [a, i]), null;
14
16
  }
15
- function Qe(r, s, a) {
16
- s.current = r, ne(a, r);
17
+ function Ze(o, a, i) {
18
+ a.current = o, se(i, o);
17
19
  }
18
- function We(r, s, a) {
19
- s.current = r, ne(a, r);
20
+ function er(o, a, i) {
21
+ a.current = o, se(i, o);
20
22
  }
21
- function Xe(r, s) {
22
- const a = (r == null ? void 0 : r.split(/\s+/).filter(Boolean)) ?? [];
23
- return a.includes(s) || a.push(s), a.join(" ");
23
+ function rr(o) {
24
+ const a = o.tagName.toLowerCase();
25
+ return o.getAttribute("role") === "button" && a !== "button" ? !1 : ["button", "input", "select", "summary", "textarea"].includes(a) ? !0 : a === "a" && o.hasAttribute("href");
24
26
  }
25
- function Ye(r) {
26
- const s = r.tagName.toLowerCase();
27
- return r.getAttribute("role") === "button" && s !== "button" ? !1 : ["button", "input", "select", "summary", "textarea"].includes(s) ? !0 : s === "a" && r.hasAttribute("href");
27
+ function tr(o) {
28
+ return o === "grid" || o === "listbox" || o === "menu" || o === "tree" ? o : "dialog";
28
29
  }
29
- function Ze(r) {
30
- return r === "grid" || r === "listbox" || r === "menu" || r === "tree" ? r : "dialog";
31
- }
32
- const ct = Ce(function(s, a) {
30
+ const pr = Ne(function(a, i) {
33
31
  const {
34
- "aria-label": q,
35
- "aria-labelledby": oe,
32
+ "aria-label": A,
33
+ "aria-labelledby": ae,
36
34
  autoFocus: F = !0,
37
- children: se,
38
- className: ae,
39
- closeOnEscape: ie = !0,
40
- closeOnOutsideInteraction: ce = !0,
41
- defaultOpen: le = !1,
42
- disabled: I = !1,
35
+ children: ie,
36
+ className: ce,
37
+ closeOnEscape: le = !0,
38
+ closeOnOutsideInteraction: ue = !0,
39
+ defaultOpen: de = !1,
40
+ disabled: R = !1,
43
41
  initialFocusReference: h,
44
- onEscapeKeyDown: ue,
45
- onOpenChange: R,
46
- onPointerDownOutside: x,
47
- open: z,
48
- placement: A = "bottom",
49
- portalContainer: k,
50
- restoreFocus: S = !0,
51
- role: M = "dialog",
52
- style: $,
53
- tabIndex: de,
54
- trapFocus: p = !1,
42
+ onEscapeKeyDown: fe,
43
+ onOpenChange: x,
44
+ onPointerDownOutside: k,
45
+ open: M,
46
+ placement: $ = "bottom",
47
+ restoreFocus: L = !0,
48
+ role: H = "dialog",
49
+ style: V,
50
+ tabIndex: pe,
51
+ trapFocus: m = !1,
55
52
  trigger: l,
56
- ...fe
57
- } = s;
58
- if (l.type === Le)
53
+ ...me
54
+ } = a;
55
+ if (l.type === Be)
59
56
  throw new Error("Popover requires a single non-Fragment trigger");
60
- const H = Ne(), pe = Be(re), V = `${H}-popover`, o = l.props, U = ze(l), G = o.id ?? `${H}-trigger`, y = I || o.disabled === !0 || o["aria-disabled"] === !0 || o["aria-disabled"] === "true", P = z !== void 0, [ge, me] = j(le), t = P ? z : ge, O = Ae(t), J = b(null), Q = b(null), C = b("programmatic"), L = b(null), W = b(t), w = b(null), [be, ve] = _e(
57
+ const U = _e(), ge = Ke(oe), G = `${U}-popover`, n = l.props, J = $e(l), Q = n.id ?? `${U}-trigger`, P = R || n.disabled === !0 || n["aria-disabled"] === !0 || n["aria-disabled"] === "true", E = M !== void 0, [be, ve] = q(de), r = E ? M : be, O = He(r), W = v(null), X = v(null), N = v("programmatic"), B = v(null), Y = v(r), T = v(null), [ye, he] = je(
61
58
  (e) => e + 1,
62
59
  0
63
- ), [c, he] = j(null), [u, ye] = j(null), i = (k == null ? void 0 : k.ownerDocument) ?? (c == null ? void 0 : c.ownerDocument) ?? (typeof document > "u" ? null : document), D = Me(O.present, i), Pe = je(
64
- () => [J, Q],
60
+ ), [c, Pe] = q(null), [u, Ee] = q(null), s = (c == null ? void 0 : c.ownerDocument) ?? (typeof document > "u" ? null : document), w = Ve("Popover").boundaryElement, C = Ue(O.present, w), Te = qe(
61
+ () => [W, X],
65
62
  []
66
- ), d = Ve(
63
+ ), d = Qe(
67
64
  O.present,
68
- A,
65
+ $,
69
66
  c,
70
- u
71
- ), Ee = v(
67
+ u,
68
+ w
69
+ ), Ie = y(
72
70
  (e) => {
73
- We(
71
+ er(
74
72
  e,
75
- J,
76
- U
77
- ), he(e);
73
+ W,
74
+ J
75
+ ), Pe(e);
78
76
  },
79
- [U]
80
- ), Te = v(
77
+ [J]
78
+ ), Re = y(
81
79
  (e) => {
82
- Qe(
80
+ Ze(
83
81
  e,
84
- Q,
85
- a
86
- ), ye(e);
82
+ X,
83
+ i
84
+ ), Ee(e);
87
85
  },
88
- [a]
89
- ), f = v((e, n) => {
90
- t !== e && (P ? (L.current = {
86
+ [i]
87
+ ), f = y((e, t) => {
88
+ r !== e && (E ? (B.current = {
91
89
  open: e,
92
- reason: n
93
- }, ve()) : (C.current = n, me(e)), R == null || R(e, n));
94
- }, [P, R, t]), Ie = v(() => {
90
+ reason: t
91
+ }, he()) : (N.current = t, ve(e)), x == null || x(e, t));
92
+ }, [E, x, r]), xe = y(() => {
95
93
  f(!1, "escape");
96
- }, [f]), Re = v(() => {
94
+ }, [f]), ke = y(() => {
97
95
  f(!1, "outside");
98
- }, [f]), xe = v((e) => {
99
- var E;
100
- if (x == null || x(e), e.defaultPrevented) return;
101
- const n = (E = i == null ? void 0 : i.defaultView) == null ? void 0 : E.HTMLElement;
102
- w.current = n ? e.composedPath().find(
103
- (m) => m instanceof n && m.tabIndex >= 0
104
- ) ?? e.target : e.target;
105
- }, [x, i]);
106
- $e({
107
- active: t,
108
- boundaries: Pe,
109
- dismissOnEscape: ie,
110
- dismissOnPointerDownOutside: ce,
111
- layerId: D.id,
112
- onEscapeDismiss: Ie,
113
- onEscapeKeyDown: ue,
114
- onPointerDownOutside: xe,
115
- onPointerDownOutsideDismiss: Re,
116
- ownerDocument: i
96
+ }, [f]), Oe = y((e) => {
97
+ var p;
98
+ if (k == null || k(e), e.defaultPrevented) return;
99
+ const t = (p = s == null ? void 0 : s.defaultView) == null ? void 0 : p.HTMLElement;
100
+ t ? T.current = e.composedPath().find(
101
+ (b) => b instanceof t && b.tabIndex >= 0
102
+ ) ?? e.target : T.current = e.target;
103
+ }, [k, s]);
104
+ Ge({
105
+ boundary: w,
106
+ active: r,
107
+ boundaries: Te,
108
+ dismissOnEscape: le,
109
+ dismissOnPointerDownOutside: ue,
110
+ layerId: C.id,
111
+ onEscapeDismiss: xe,
112
+ onEscapeKeyDown: fe,
113
+ onPointerDownOutside: Oe,
114
+ onPointerDownOutsideDismiss: ke,
115
+ ownerDocument: s
117
116
  });
118
- const ke = Ue({
119
- active: t && p,
117
+ const we = We({
118
+ boundary: w,
119
+ active: r && m,
120
120
  autoFocus: F,
121
121
  container: u,
122
122
  initialFocusReference: h,
123
- layerId: D.id,
124
- restoreFocus: S
123
+ layerId: C.id,
124
+ restoreFocus: L
125
125
  });
126
- K(() => {
127
- if (!t || p || !F || !u) return;
126
+ z(() => {
127
+ if (!r || m || !F || !u) return;
128
128
  let e = !0;
129
129
  return Promise.resolve().then(() => {
130
130
  if (!e) return;
131
- const n = h == null ? void 0 : h.current;
132
- (n && u.contains(n) ? n : u).focus({ preventScroll: !0 });
131
+ const t = h == null ? void 0 : h.current;
132
+ (t && u.contains(t) ? t : u).focus({ preventScroll: !0 });
133
133
  }), () => {
134
134
  e = !1;
135
135
  };
136
- }, [F, h, t, u, p]), K(() => {
137
- var ee;
138
- const e = W.current;
139
- W.current = t;
140
- const n = L.current, E = P ? e !== t && (n == null ? void 0 : n.open) === t ? n.reason : "programmatic" : C.current;
141
- if (L.current = null, t) {
142
- C.current = "programmatic", w.current = null;
136
+ }, [F, h, r, u, m]), z(() => {
137
+ var te;
138
+ const e = Y.current;
139
+ Y.current = r;
140
+ const t = B.current;
141
+ let p = N.current;
142
+ if (E && (p = "programmatic", e !== r && (t == null ? void 0 : t.open) === r && (p = t.reason)), B.current = null, r) {
143
+ N.current = "programmatic", T.current = null;
143
144
  return;
144
145
  }
145
- const m = i == null ? void 0 : i.activeElement, B = w.current, _ = (ee = i == null ? void 0 : i.defaultView) == null ? void 0 : ee.HTMLElement, Fe = E === "outside" && _ && B instanceof _ && m instanceof _ && (B === m || B.contains(m));
146
- e && !p && S && !Fe && (c == null || c.focus({ preventScroll: !0 })), w.current = null;
146
+ const b = s == null ? void 0 : s.activeElement, K = T.current, j = (te = s == null ? void 0 : s.defaultView) == null ? void 0 : te.HTMLElement, Fe = p === "outside" && j && K instanceof j && b instanceof j && (K === b || K.contains(b));
147
+ e && !m && L && !Fe && (c == null || c.focus({ preventScroll: !0 })), T.current = null;
147
148
  }, [
148
- be,
149
- P,
150
- t,
151
- i,
152
- S,
153
- p,
149
+ ye,
150
+ E,
151
+ r,
152
+ s,
153
+ L,
154
+ m,
154
155
  c
155
- ]), K(() => {
156
- I && t && f(!1, "programmatic");
157
- }, [I, t, f]);
158
- function Oe(e) {
159
- var n;
160
- if (y) {
156
+ ]), z(() => {
157
+ R && r && f(!1, "programmatic");
158
+ }, [R, r, f]);
159
+ function Ce(e) {
160
+ var t;
161
+ if (P) {
161
162
  e.preventDefault(), e.stopPropagation();
162
163
  return;
163
164
  }
164
- (n = o.onClick) == null || n.call(o, e), !e.defaultPrevented && f(!t, "trigger");
165
+ (t = n.onClick) == null || t.call(n, e), !e.defaultPrevented && f(!r, "trigger");
165
166
  }
166
- function we(e) {
167
- var n;
168
- (n = o.onKeyDown) == null || n.call(o, e), !(e.defaultPrevented || y || Ye(e.currentTarget) || e.key !== "Enter" && e.key !== " ") && (e.preventDefault(), e.currentTarget.click());
167
+ function De(e) {
168
+ var t;
169
+ (t = n.onKeyDown) == null || t.call(n, e), !(e.defaultPrevented || P || rr(e.currentTarget) || e.key !== "Enter" && e.key !== " ") && (e.preventDefault(), e.currentTarget.click());
169
170
  }
170
- if (I) return l;
171
- const N = typeof l.type == "string", g = N ? l.type : null, X = g === "a" && typeof o.href == "string", Y = N && !(g === "button" || g === "input" || g === "select" || g === "summary" || g === "textarea" || X), Z = X && y, De = Ke(
171
+ if (R) return l;
172
+ const _ = typeof l.type == "string", g = _ ? l.type : null, Z = g === "a" && typeof n.href == "string", ee = _ && !(g === "button" || g === "input" || g === "select" || g === "summary" || g === "textarea" || Z), re = Z && P;
173
+ let D = n.role;
174
+ D === void 0 && (re ? D = "link" : ee && (D = "button"));
175
+ let S = n.tabIndex;
176
+ S === void 0 && ee && (S = 0), P && (S = -1);
177
+ const Se = ze(
172
178
  l,
173
179
  {
174
- "aria-controls": t ? Xe(o["aria-controls"], V) : o["aria-controls"],
175
- "aria-expanded": t,
176
- "aria-haspopup": o["aria-haspopup"] ?? Ze(M),
177
- "aria-disabled": y ? !0 : o["aria-disabled"],
178
- className: [o.className, "nk-popover__trigger"].filter(Boolean).join(" "),
179
- href: Z ? void 0 : o.href,
180
- id: G,
181
- onClick: Oe,
182
- onKeyDown: N ? we : o.onKeyDown,
183
- ref: Ee,
184
- role: o.role ?? (Z ? "link" : Y ? "button" : void 0),
185
- tabIndex: y ? -1 : o.tabIndex ?? (Y ? 0 : void 0)
180
+ "aria-controls": r ? Ae(n["aria-controls"], G) : n["aria-controls"],
181
+ "aria-expanded": r,
182
+ "aria-haspopup": n["aria-haspopup"] ?? tr(H),
183
+ "aria-disabled": P ? !0 : n["aria-disabled"],
184
+ className: [n.className, "nk-popover__trigger"].filter(Boolean).join(" "),
185
+ href: re ? void 0 : n.href,
186
+ id: Q,
187
+ onClick: Ce,
188
+ onKeyDown: _ ? De : n.onKeyDown,
189
+ ref: Ie,
190
+ role: D,
191
+ tabIndex: S
186
192
  }
187
193
  );
188
- return /* @__PURE__ */ te(Se, { children: [
189
- De,
190
- /* @__PURE__ */ T(
191
- re.Provider,
194
+ return /* @__PURE__ */ ne(Le, { children: [
195
+ Se,
196
+ /* @__PURE__ */ I(
197
+ oe.Provider,
192
198
  {
193
- value: t && p ? ke : pe,
194
- children: O.present && i ? /* @__PURE__ */ T(He, { container: k, inheritFrom: c, children: /* @__PURE__ */ te(
195
- Ge,
199
+ value: r && m ? we : ge,
200
+ children: O.present && s ? /* @__PURE__ */ I(Je, { children: /* @__PURE__ */ ne(
201
+ Xe,
196
202
  {
197
- ...fe,
198
- ref: Te,
199
- "aria-hidden": t ? void 0 : !0,
200
- "aria-label": t ? q : void 0,
201
- "aria-labelledby": t ? oe ?? (q === void 0 ? G : void 0) : void 0,
202
- className: ["nk-popover", ae].filter(Boolean).join(" "),
203
- "data-placement": (d == null ? void 0 : d.placement) ?? A,
203
+ ...me,
204
+ ref: Re,
205
+ "aria-hidden": r ? void 0 : !0,
206
+ "aria-label": r ? A : void 0,
207
+ "aria-labelledby": r ? ae ?? (A === void 0 ? Q : void 0) : void 0,
208
+ className: ["nk-popover", ce].filter(Boolean).join(" "),
209
+ "data-placement": (d == null ? void 0 : d.placement) ?? $,
204
210
  "data-state": O.state === "closing" ? "closing" : "open",
205
- id: V,
206
- role: t ? M : void 0,
211
+ id: G,
212
+ role: r ? H : void 0,
207
213
  style: d ? {
208
- ...$,
214
+ ...V,
209
215
  "--nk-popover-arrow-offset": `${d.arrowOffset}px`,
210
216
  left: d.left,
211
217
  top: d.top,
212
- zIndex: D.zIndex
218
+ zIndex: C.zIndex
213
219
  } : {
214
- ...$,
220
+ ...V,
215
221
  visibility: "hidden",
216
- zIndex: D.zIndex
222
+ zIndex: C.zIndex
217
223
  },
218
- tabIndex: de ?? -1,
224
+ tabIndex: pe ?? -1,
219
225
  children: [
220
- /* @__PURE__ */ T(
221
- Je,
226
+ /* @__PURE__ */ I(
227
+ Ye,
222
228
  {
223
- inert: !t,
229
+ inert: !r,
224
230
  panelElement: u
225
231
  }
226
232
  ),
227
- /* @__PURE__ */ T("span", { "aria-hidden": "true", className: "nk-popover__arrow" }),
228
- /* @__PURE__ */ T("div", { className: "nk-popover__content", children: se })
233
+ /* @__PURE__ */ I("span", { "aria-hidden": "true", className: "nk-popover__arrow" }),
234
+ /* @__PURE__ */ I("div", { className: "nk-popover__content", children: ie })
229
235
  ]
230
236
  }
231
237
  ) }) : null
@@ -234,5 +240,5 @@ const ct = Ce(function(s, a) {
234
240
  ] });
235
241
  });
236
242
  export {
237
- ct as default
243
+ pr as default
238
244
  };
package/dist/Radio.cjs CHANGED
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("react/jsx-runtime"),i=require("react"),v=require("./RadioGroupContext-BX9KnDek.cjs"),R=require("./Text-DWYlIcPj.cjs");function C(){const e=i.useContext(v.RadioGroupContext);if(!e)throw new Error("Radio must be rendered within RadioGroup");return e}function m(e,r,t){r.current=e,typeof t=="function"?t(e):t&&(t.current=e)}const _=i.forwardRef(function(r,t){const{children:d,className:f,disabled:p=!1,style:b,value:l,...h}=r,n=C(),c=i.useRef(null),a=n.disabled||p,s=n.value!==void 0,x=n.value===l,k=i.useCallback(o=>m(o,c,t),[t]);return i.useEffect(()=>{var o;!s&&a&&((o=c.current)!=null&&o.checked)&&(c.current.checked=!1)},[s,a]),u.jsxs("label",{className:["nk-radio",f].filter(Boolean).join(" "),"data-disabled":a||void 0,style:b,children:[u.jsx("input",{...h,ref:k,checked:s?!a&&x:void 0,className:"nk-radio__control",defaultChecked:s?void 0:!a&&n.defaultValue===l,disabled:a,name:n.name,onChange:n.onChange,required:n.required,type:"radio",value:l}),u.jsx("span",{"aria-hidden":"true",className:"nk-radio__visual"}),u.jsx(R.Text,{as:"span",className:"nk-radio__label",children:d})]})});exports.default=_;
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react/jsx-runtime"),r=require("react"),R=require("./aria-Bntn6ad_.cjs"),g=require("./field-control-NfLwcPj6.cjs"),j=require("./Text-DWYlIcPj.cjs"),m=r.createContext(void 0),k=r.forwardRef(function(d,e){const{"aria-invalid":c,children:f,className:p,defaultValue:b,disabled:n=!1,invalid:v=!1,name:a,onChange:u,orientation:o="vertical",required:t=!1,value:h,...x}=d,s=v||R.hasInvalidState(c),C={defaultValue:b,disabled:n,name:a,onChange:u,required:t,value:h};return l.jsx(m.Provider,{value:C,children:l.jsx("div",{...x,ref:e,"aria-disabled":n||void 0,"aria-invalid":R.resolveAriaInvalid(v,c),"aria-required":t||void 0,className:["nk-radio-group",p].filter(Boolean).join(" "),"data-disabled":n||void 0,"data-invalid":s||void 0,"data-orientation":o,role:"radiogroup",children:f})})});g.markFieldGroupControl(k,"group");function q(){const i=r.useContext(m);if(!i)throw new Error("Radio must be rendered within RadioGroup");return i}function _(i,d,e){d.current=i,typeof e=="function"?e(i):e&&(e.current=i)}const G=r.forwardRef(function(d,e){const{children:c,className:f,disabled:p=!1,style:b,value:n,...v}=d,a=q(),u=r.useRef(null),o=a.disabled||p,t=a.value!==void 0,h=a.value===n,x=r.useCallback(s=>_(s,u,e),[e]);return r.useEffect(()=>{var s;!t&&o&&((s=u.current)!=null&&s.checked)&&(u.current.checked=!1)},[t,o]),l.jsxs("label",{className:["nk-radio",f].filter(Boolean).join(" "),"data-disabled":o||void 0,style:b,children:[l.jsx("input",{...v,ref:x,checked:t?!o&&h:void 0,className:"nk-radio__control",defaultChecked:t?void 0:!o&&a.defaultValue===n,disabled:o,name:a.name,onChange:a.onChange,required:a.required,type:"radio",value:n}),l.jsx("span",{"aria-hidden":"true",className:"nk-radio__visual"}),l.jsx(j.Text,{as:"span",className:"nk-radio__label",children:c})]})}),N=Object.assign(G,{Group:k});exports.default=N;
package/dist/Radio.js CHANGED
@@ -1,65 +1,110 @@
1
1
  "use client";
2
- import { jsxs as k, jsx as u } from "react/jsx-runtime";
3
- import { useContext as R, forwardRef as v, useRef as C, useCallback as x, useEffect as _ } from "react";
4
- import { R as N } from "./RadioGroupContext-DbKM4zPZ.js";
5
- import { T as g } from "./Text-rN6iDo0V.js";
6
- function j() {
7
- const e = R(N);
8
- if (!e)
2
+ import { jsx as l, jsxs as g } from "react/jsx-runtime";
3
+ import { createContext as x, forwardRef as b, useContext as G, useRef as N, useCallback as _, useEffect as j } from "react";
4
+ import { r as q, h as I } from "./aria-CeA9QfD1.js";
5
+ import { m as V } from "./field-control-XAn_FKks.js";
6
+ import { T as y } from "./Text-rN6iDo0V.js";
7
+ const k = x(void 0), R = b(
8
+ function(s, a) {
9
+ const {
10
+ "aria-invalid": u,
11
+ children: f,
12
+ className: p,
13
+ defaultValue: v,
14
+ disabled: n = !1,
15
+ invalid: c = !1,
16
+ name: e,
17
+ onChange: d,
18
+ orientation: o = "vertical",
19
+ required: r = !1,
20
+ value: m,
21
+ ...h
22
+ } = s, t = c || I(u), C = {
23
+ defaultValue: v,
24
+ disabled: n,
25
+ name: e,
26
+ onChange: d,
27
+ required: r,
28
+ value: m
29
+ };
30
+ return /* @__PURE__ */ l(k.Provider, { value: C, children: /* @__PURE__ */ l(
31
+ "div",
32
+ {
33
+ ...h,
34
+ ref: a,
35
+ "aria-disabled": n || void 0,
36
+ "aria-invalid": q(c, u),
37
+ "aria-required": r || void 0,
38
+ className: ["nk-radio-group", p].filter(Boolean).join(" "),
39
+ "data-disabled": n || void 0,
40
+ "data-invalid": t || void 0,
41
+ "data-orientation": o,
42
+ role: "radiogroup",
43
+ children: f
44
+ }
45
+ ) });
46
+ }
47
+ );
48
+ V(R, "group");
49
+ function P() {
50
+ const i = G(k);
51
+ if (!i)
9
52
  throw new Error("Radio must be rendered within RadioGroup");
10
- return e;
53
+ return i;
11
54
  }
12
- function y(e, t, a) {
13
- t.current = e, typeof a == "function" ? a(e) : a && (a.current = e);
55
+ function B(i, s, a) {
56
+ s.current = i, typeof a == "function" ? a(i) : a && (a.current = i);
14
57
  }
15
- const V = v(function(t, a) {
58
+ const E = b(function(s, a) {
16
59
  const {
17
- children: c,
18
- className: d,
19
- disabled: f = !1,
20
- style: p,
21
- value: r,
22
- ...m
23
- } = t, o = j(), l = C(null), i = o.disabled || f, n = o.value !== void 0, h = o.value === r, b = x(
24
- (s) => y(
25
- s,
26
- l,
60
+ children: u,
61
+ className: f,
62
+ disabled: p = !1,
63
+ style: v,
64
+ value: n,
65
+ ...c
66
+ } = s, e = P(), d = N(null), o = e.disabled || p, r = e.value !== void 0, m = e.value === n, h = _(
67
+ (t) => B(
68
+ t,
69
+ d,
27
70
  a
28
71
  ),
29
72
  [a]
30
73
  );
31
- return _(() => {
32
- var s;
33
- !n && i && ((s = l.current) != null && s.checked) && (l.current.checked = !1);
34
- }, [n, i]), /* @__PURE__ */ k(
74
+ return j(() => {
75
+ var t;
76
+ !r && o && ((t = d.current) != null && t.checked) && (d.current.checked = !1);
77
+ }, [r, o]), /* @__PURE__ */ g(
35
78
  "label",
36
79
  {
37
- className: ["nk-radio", d].filter(Boolean).join(" "),
38
- "data-disabled": i || void 0,
39
- style: p,
80
+ className: ["nk-radio", f].filter(Boolean).join(" "),
81
+ "data-disabled": o || void 0,
82
+ style: v,
40
83
  children: [
41
- /* @__PURE__ */ u(
84
+ /* @__PURE__ */ l(
42
85
  "input",
43
86
  {
44
- ...m,
45
- ref: b,
46
- checked: n ? !i && h : void 0,
87
+ ...c,
88
+ ref: h,
89
+ checked: r ? !o && m : void 0,
47
90
  className: "nk-radio__control",
48
- defaultChecked: n ? void 0 : !i && o.defaultValue === r,
49
- disabled: i,
50
- name: o.name,
51
- onChange: o.onChange,
52
- required: o.required,
91
+ defaultChecked: r ? void 0 : !o && e.defaultValue === n,
92
+ disabled: o,
93
+ name: e.name,
94
+ onChange: e.onChange,
95
+ required: e.required,
53
96
  type: "radio",
54
- value: r
97
+ value: n
55
98
  }
56
99
  ),
57
- /* @__PURE__ */ u("span", { "aria-hidden": "true", className: "nk-radio__visual" }),
58
- /* @__PURE__ */ u(g, { as: "span", className: "nk-radio__label", children: c })
100
+ /* @__PURE__ */ l("span", { "aria-hidden": "true", className: "nk-radio__visual" }),
101
+ /* @__PURE__ */ l(y, { as: "span", className: "nk-radio__label", children: u })
59
102
  ]
60
103
  }
61
104
  );
105
+ }), O = Object.assign(E, {
106
+ Group: R
62
107
  });
63
108
  export {
64
- V as default
109
+ O as default
65
110
  };