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
@@ -1,99 +0,0 @@
1
- "use client";
2
- import { jsxs as v, Fragment as q, jsx as m } from "react/jsx-runtime";
3
- import { forwardRef as C, createElement as K, isValidElement as G, Fragment as O } from "react";
4
- import { q as x } from "./Icon-uQmpr5P2.js";
5
- import { S as V } from "./Spinner-CVYvk6YK.js";
6
- function g(t) {
7
- return t == null || typeof t == "boolean" || typeof t == "string" && !t.trim() ? !1 : Array.isArray(t) ? t.some(g) : G(t) && t.type === O ? g(t.props.children) : !0;
8
- }
9
- function W(t, s) {
10
- const a = t.getBoundingClientRect(), p = s.clientX - a.left, l = s.clientY - a.top;
11
- t.style.setProperty("--nk-button-glow-x", `${p}px`), t.style.setProperty("--nk-button-glow-y", `${l}px`);
12
- }
13
- const L = C(function(s, a) {
14
- const {
15
- as: p,
16
- children: l,
17
- className: P,
18
- disabled: B,
19
- fullWidth: w = !1,
20
- icon: i,
21
- iconAlignment: h = "left",
22
- loading: f = !1,
23
- onClick: A,
24
- onKeyDown: k,
25
- onMouseMove: D,
26
- role: y,
27
- shape: I = "capsule",
28
- tabIndex: b,
29
- textAlignment: j = "center",
30
- tone: z,
31
- variant: E = "primary",
32
- ...d
33
- } = s, r = p ?? "button", e = B || f, M = !!i && !g(l), u = r === "a" && "href" in d && typeof d.href == "string", c = typeof r == "string" && r !== "button" && !u, N = (o) => {
34
- if (e) {
35
- o.preventDefault(), o.stopPropagation();
36
- return;
37
- }
38
- const n = A;
39
- n == null || n(o);
40
- }, R = (o) => {
41
- W(o.currentTarget, o);
42
- const n = D;
43
- n == null || n(o);
44
- }, S = (o) => {
45
- const n = k;
46
- n == null || n(o), !(o.defaultPrevented || e || !c || o.key !== "Enter" && o.key !== " ") && (o.preventDefault(), o.currentTarget.click());
47
- }, _ = r === "button" ? {
48
- disabled: e,
49
- type: d.type ?? "button"
50
- } : { "aria-disabled": e || void 0 }, F = u && e ? { href: void 0 } : void 0, T = u && e ? y ?? "link" : c ? y ?? "button" : y, $ = r === "button" ? b : u && e ? void 0 : e ? -1 : c ? b ?? 0 : b;
51
- return K(
52
- r,
53
- {
54
- ...d,
55
- ..._,
56
- ...F,
57
- ref: a,
58
- "aria-busy": f || void 0,
59
- className: ["nk-button", P].filter(Boolean).join(" "),
60
- "data-full-width": w || void 0,
61
- "data-icon-only": M || void 0,
62
- "data-shape": I,
63
- "data-tone": z,
64
- "data-variant": E,
65
- onClick: N,
66
- onKeyDown: c ? S : k,
67
- onMouseMove: R,
68
- role: T,
69
- tabIndex: $
70
- },
71
- /* @__PURE__ */ v(q, { children: [
72
- /* @__PURE__ */ v(
73
- "span",
74
- {
75
- className: "nk-button__content",
76
- style: { justifyContent: j },
77
- children: [
78
- i && h === "left" ? /* @__PURE__ */ m(x, { size: 14, type: i }) : null,
79
- l,
80
- i && h === "right" ? /* @__PURE__ */ m(x, { size: 14, type: i }) : null
81
- ]
82
- }
83
- ),
84
- f ? /* @__PURE__ */ m(
85
- V,
86
- {
87
- "aria-hidden": "true",
88
- "aria-label": void 0,
89
- className: "nk-button__spinner",
90
- role: void 0,
91
- size: 16
92
- }
93
- ) : null
94
- ] })
95
- );
96
- });
97
- export {
98
- L as B
99
- };
@@ -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;
@@ -1 +0,0 @@
1
- "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const B=require("react/jsx-runtime"),a=require("react"),R=require("./aria-DKxpE8cA.cjs"),I=require("./Checkbox-VQifZrZZ.cjs"),Y=require("./field-control-NfLwcPj6.cjs"),D=Object.freeze([]);function P(r,o){a.Children.forEach(r,e=>{if(e==null||typeof e=="boolean")return;if(!a.isValidElement(e))throw new Error("CheckboxGroup children must be direct Checkbox elements or fragments");if(e.type===a.Fragment){P(e.props.children,o);return}if(e.type!==I.Checkbox)throw new Error("CheckboxGroup children must be direct Checkbox elements or fragments");const n=e;o.push({disabled:!!n.props.disabled,required:!!n.props.required,value:String(n.props.value??"on")})})}function J(r){const o=[];P(r,o);const e=new Set;return o.forEach(n=>{if(e.has(n.value))throw new Error("CheckboxGroup Checkbox values must be unique");e.add(n.value)}),o}function Q(r,o,e){o.current=r,typeof e=="function"?e(r):e&&(e.current=r)}const T=a.forwardRef(function(o,e){const{"aria-invalid":n,children:c,className:A,defaultValue:l=D,disabled:u=!1,invalid:C=!1,name:L,onChange:v,orientation:M="vertical",required:h=!1,value:m,..._}=o,k=a.useRef(null),[F,g]=a.useState(l),d=m!==void 0,H=d?m:F,N=C||R.hasInvalidState(n),E=J(c),q=u?[]:E.filter(t=>!t.disabled).map(t=>t.value),S=new Set(q),U=H.some(t=>S.has(t)),f=q[0],x=E.find(t=>!t.disabled&&t.value===f),V=l.some(t=>S.has(t)),y=!!(x!=null&&x.required),z=a.useCallback(t=>Q(t,k,e),[e]);a.useEffect(()=>{var p;if(d)return;const t=(p=k.current)==null?void 0:p.querySelector('input[type="checkbox"]'),i=t instanceof HTMLInputElement?t.form:null;if(!i)return;const b=i.getRootNode();function s(G){var j;if(G.target!==i||G.defaultPrevented)return;const O=Array.from(((j=k.current)==null?void 0:j.querySelectorAll('input[type="checkbox"]'))??[]).find(w=>!w.disabled&&w.value===f);O&&(O.required=!!(y||h&&!V)),g(l)}return b.addEventListener("reset",s),()=>b.removeEventListener("reset",s)},[c,l,V,d,h,y,f]);function K(t){if(!d){const i=t.currentTarget.value,b=t.currentTarget.checked;g(s=>b?[...new Set([...s,i])]:s.filter(p=>p!==i))}v==null||v(t)}const X={defaultValue:l,disabled:u,handleChange:K,hasSelection:U,name:L,required:h,value:m,validationValue:f};return B.jsx(I.CheckboxGroupContext.Provider,{value:X,children:B.jsx("div",{..._,ref:z,"aria-disabled":u||void 0,"aria-invalid":R.resolveAriaInvalid(C,n),className:["nk-checkbox-group",A].filter(Boolean).join(" "),"data-disabled":u||void 0,"data-invalid":N||void 0,"data-orientation":M,role:"group",children:c})})});Y.markFieldGroupControl(T,"label");exports.default=T;
@@ -1,144 +0,0 @@
1
- "use client";
2
- import { jsx as B } from "react/jsx-runtime";
3
- import { forwardRef as _, useRef as z, useState as K, useCallback as X, useEffect as Y, Children as D, isValidElement as J, Fragment as Q } from "react";
4
- import { r as W, h as Z } from "./aria-DHnOMyYp.js";
5
- import { a as $, C as ee } from "./Checkbox-BvXM9VyY.js";
6
- import { m as oe } from "./field-control-XAn_FKks.js";
7
- const te = Object.freeze([]);
8
- function I(r, t) {
9
- D.forEach(r, (e) => {
10
- if (e == null || typeof e == "boolean")
11
- return;
12
- if (!J(e))
13
- throw new Error(
14
- "CheckboxGroup children must be direct Checkbox elements or fragments"
15
- );
16
- if (e.type === Q) {
17
- I(e.props.children, t);
18
- return;
19
- }
20
- if (e.type !== ee)
21
- throw new Error(
22
- "CheckboxGroup children must be direct Checkbox elements or fragments"
23
- );
24
- const n = e;
25
- t.push({
26
- disabled: !!n.props.disabled,
27
- required: !!n.props.required,
28
- value: String(n.props.value ?? "on")
29
- });
30
- });
31
- }
32
- function ne(r) {
33
- const t = [];
34
- I(r, t);
35
- const e = /* @__PURE__ */ new Set();
36
- return t.forEach((n) => {
37
- if (e.has(n.value))
38
- throw new Error("CheckboxGroup Checkbox values must be unique");
39
- e.add(n.value);
40
- }), t;
41
- }
42
- function re(r, t, e) {
43
- t.current = r, typeof e == "function" ? e(r) : e && (e.current = r);
44
- }
45
- const ae = _(
46
- function(t, e) {
47
- const {
48
- "aria-invalid": n,
49
- children: s,
50
- className: R,
51
- defaultValue: i = te,
52
- disabled: c = !1,
53
- invalid: x = !1,
54
- name: A,
55
- onChange: b,
56
- orientation: L = "vertical",
57
- required: m = !1,
58
- value: h,
59
- ...P
60
- } = t, v = z(null), [T, C] = K(i), u = h !== void 0, j = u ? h : T, F = x || Z(n), g = ne(s), E = c ? [] : g.filter((o) => !o.disabled).map((o) => o.value), S = new Set(E), H = j.some(
61
- (o) => S.has(o)
62
- ), d = E[0], k = g.find(
63
- (o) => !o.disabled && o.value === d
64
- ), V = i.some(
65
- (o) => S.has(o)
66
- ), q = !!(k != null && k.required), N = X(
67
- (o) => re(
68
- o,
69
- v,
70
- e
71
- ),
72
- [e]
73
- );
74
- Y(() => {
75
- var p;
76
- if (u) return;
77
- const o = (p = v.current) == null ? void 0 : p.querySelector(
78
- 'input[type="checkbox"]'
79
- ), a = o instanceof HTMLInputElement ? o.form : null;
80
- if (!a) return;
81
- const f = a.getRootNode();
82
- function l(y) {
83
- var O;
84
- if (y.target !== a || y.defaultPrevented) return;
85
- const G = Array.from(
86
- ((O = v.current) == null ? void 0 : O.querySelectorAll(
87
- 'input[type="checkbox"]'
88
- )) ?? []
89
- ).find(
90
- (w) => !w.disabled && w.value === d
91
- );
92
- G && (G.required = !!(q || m && !V)), C(i);
93
- }
94
- return f.addEventListener("reset", l), () => f.removeEventListener("reset", l);
95
- }, [
96
- s,
97
- i,
98
- V,
99
- u,
100
- m,
101
- q,
102
- d
103
- ]);
104
- function M(o) {
105
- if (!u) {
106
- const a = o.currentTarget.value, f = o.currentTarget.checked;
107
- C((l) => f ? [.../* @__PURE__ */ new Set([...l, a])] : l.filter((p) => p !== a));
108
- }
109
- b == null || b(o);
110
- }
111
- const U = {
112
- defaultValue: i,
113
- disabled: c,
114
- handleChange: M,
115
- hasSelection: H,
116
- name: A,
117
- required: m,
118
- value: h,
119
- validationValue: d
120
- };
121
- return /* @__PURE__ */ B($.Provider, { value: U, children: /* @__PURE__ */ B(
122
- "div",
123
- {
124
- ...P,
125
- ref: N,
126
- "aria-disabled": c || void 0,
127
- "aria-invalid": W(x, n),
128
- className: [
129
- "nk-checkbox-group",
130
- R
131
- ].filter(Boolean).join(" "),
132
- "data-disabled": c || void 0,
133
- "data-invalid": F || void 0,
134
- "data-orientation": L,
135
- role: "group",
136
- children: s
137
- }
138
- ) });
139
- }
140
- );
141
- oe(ae, "label");
142
- export {
143
- ae as default
144
- };