neatkit 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Avatar-Belo7qAY.cjs +1 -0
- package/dist/Avatar-DjDCFqNG.js +55 -0
- package/dist/Avatar.cjs +1 -1
- package/dist/Avatar.js +2 -52
- package/dist/Boundary.cjs +1 -0
- package/dist/Boundary.js +176 -0
- package/dist/{Button-BAsLfA0D.js → Button-Chv4O66e.js} +35 -35
- package/dist/Button-DCKtFvSo.cjs +1 -0
- package/dist/Button.cjs +1 -1
- package/dist/Button.js +1 -1
- package/dist/Checkbox.cjs +1 -1
- package/dist/Checkbox.js +213 -2
- package/dist/Code-ClkozPlv.js +227 -0
- package/dist/Code-JDb4VFl7.cjs +4 -0
- package/dist/Code.cjs +1 -1
- package/dist/Code.js +1 -1
- package/dist/{Icon-uQmpr5P2.js → Icon-BoEUoOk7.js} +144 -177
- package/dist/Icon-DJ4BigRz.cjs +1 -0
- package/dist/Icon.cjs +1 -1
- package/dist/Icon.js +2 -35
- package/dist/Input.cjs +1 -1
- package/dist/Input.js +70 -79
- package/dist/Markdown.cjs +1 -31
- package/dist/Markdown.js +461 -18062
- package/dist/Modal.cjs +1 -1
- package/dist/Modal.js +100 -122
- package/dist/PinInput.cjs +1 -1
- package/dist/PinInput.js +1 -1
- package/dist/Popover.cjs +1 -1
- package/dist/Popover.js +106 -106
- package/dist/Radio.cjs +1 -1
- package/dist/Radio.js +86 -41
- package/dist/Select.cjs +1 -1
- package/dist/Select.js +326 -315
- package/dist/Sidebar.cjs +1 -0
- package/dist/Sidebar.js +475 -0
- package/dist/Skeleton.cjs +1 -1
- package/dist/Skeleton.js +20 -16
- package/dist/Switch.cjs +1 -1
- package/dist/Switch.js +1 -1
- package/dist/Table-B30TBckZ.js +402 -0
- package/dist/Table-DceR12X9.cjs +1 -0
- package/dist/Table.cjs +1 -1
- package/dist/Table.js +1 -1
- package/dist/TextArea.cjs +1 -1
- package/dist/TextArea.js +1 -1
- package/dist/Tooltip-B4bajPtk.cjs +1 -0
- package/dist/Tooltip-BVqdnKK_.js +231 -0
- package/dist/Tooltip.cjs +1 -1
- package/dist/Tooltip.js +2 -3
- package/dist/aria-Bntn6ad_.cjs +1 -0
- package/dist/aria-CeA9QfD1.js +15 -0
- package/dist/components/Boundary/Boundary.d.ts +65 -0
- package/dist/components/Boundary/contexts/BoundaryContext.d.ts +28 -0
- package/dist/components/Boundary/hooks/useBoundary.d.ts +19 -0
- package/dist/components/Boundary/hooks/useBoundaryWidth.d.ts +23 -0
- package/dist/components/Boundary/index.d.ts +2 -0
- package/dist/components/Boundary/utils/width.d.ts +11 -0
- package/dist/components/Checkbox/Checkbox.d.ts +9 -1
- package/dist/components/{CheckboxGroup → Checkbox/components}/CheckboxGroup.d.ts +2 -2
- package/dist/components/Checkbox/index.d.ts +1 -0
- package/dist/components/Checkbox/utils/checkbox-option.d.ts +17 -0
- package/dist/components/Icon/Icon.d.ts +1 -0
- package/dist/components/Icon/index.d.ts +0 -33
- package/dist/components/Input/Input.d.ts +1 -9
- package/dist/components/Modal/Modal.d.ts +0 -4
- package/dist/components/PinInput/PinInput.d.ts +1 -1
- package/dist/components/Popover/Popover.d.ts +2 -6
- package/dist/components/Portal/Portal.d.ts +11 -8
- package/dist/components/Portal/hooks/useDismissableLayer.d.ts +2 -0
- package/dist/components/Portal/hooks/useFloatingPosition.d.ts +4 -3
- package/dist/components/Portal/hooks/useFocusTrap.d.ts +2 -0
- package/dist/components/Portal/hooks/useScrollLock.d.ts +9 -3
- package/dist/components/Portal/utils/boundary-focus.d.ts +23 -0
- package/dist/components/Portal/utils/floating-position.d.ts +43 -9
- package/dist/components/Portal/utils/overlay-stack.d.ts +22 -10
- package/dist/components/Portal/utils/scroll-container.d.ts +13 -0
- package/dist/components/Radio/Radio.d.ts +9 -1
- package/dist/components/{RadioGroup → Radio/components}/RadioGroup.d.ts +9 -2
- package/dist/components/Radio/index.d.ts +1 -0
- package/dist/components/Select/Select.d.ts +0 -2
- package/dist/components/Select/utils/listbox-position.d.ts +28 -0
- package/dist/components/Sidebar/Sidebar.d.ts +108 -0
- package/dist/components/Sidebar/components/SidebarFooter.d.ts +19 -0
- package/dist/components/Sidebar/components/SidebarGroup.d.ts +42 -0
- package/dist/components/Sidebar/components/SidebarItem.d.ts +43 -0
- package/dist/components/Sidebar/components/SidebarOverlay.d.ts +38 -0
- package/dist/components/Sidebar/components/SidebarPanel.d.ts +47 -0
- package/dist/components/Sidebar/components/SidebarTrigger.d.ts +47 -0
- package/dist/components/Sidebar/components/SidebarUser.d.ts +59 -0
- package/dist/components/Sidebar/hooks/usePresentation.d.ts +14 -0
- package/dist/components/Sidebar/hooks/useSidebar.d.ts +9 -0
- package/dist/components/Sidebar/index.d.ts +2 -0
- package/dist/components/Sidebar/utils/state.d.ts +62 -0
- package/dist/components/Skeleton/Skeleton.d.ts +21 -5
- package/dist/components/Table/Table.d.ts +9 -49
- package/dist/components/Table/contexts/TableContext.d.ts +4 -0
- package/dist/components/Table/index.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +10 -4
- package/dist/components/Tooltip/TooltipProvider.d.ts +1 -1
- package/dist/components/Tooltip/index.d.ts +0 -1
- package/dist/effects-D5CWf-Pl.js +8 -0
- package/dist/effects-D85L_7zM.cjs +1 -0
- package/dist/floating-position-5wJ5G5IT.js +48 -0
- package/dist/floating-position-Cy9xxdH4.cjs +1 -0
- package/dist/style.css +1 -1
- package/dist/tokens.d.ts +1 -0
- package/dist/useFloatingPosition-BBEUHPqy.cjs +1 -0
- package/dist/useFloatingPosition-CMirP2-2.js +43 -0
- package/dist/useFocusTrap-BrFZdMqQ.cjs +1 -0
- package/dist/useFocusTrap-DhVnlboe.js +136 -0
- package/dist/usePresence-B5RYv4e1.cjs +1 -0
- package/dist/usePresence-CqegYqy4.js +221 -0
- package/dist/useScrollLock-Drd7OZRC.js +62 -0
- package/dist/useScrollLock-Dy8MZaSn.cjs +1 -0
- package/dist/utils/aria.d.ts +9 -0
- package/dist/utils/effects.d.ts +12 -0
- package/package.json +11 -16
- package/dist/Button-D7JUO6Fs.cjs +0 -1
- package/dist/Checkbox-BvXM9VyY.js +0 -68
- package/dist/Checkbox-VQifZrZZ.cjs +0 -1
- package/dist/CheckboxGroup.cjs +0 -1
- package/dist/CheckboxGroup.js +0 -144
- package/dist/Code-BP2ZCmUf.js +0 -7446
- package/dist/Code-eispVOW3.cjs +0 -6
- package/dist/Content.cjs +0 -1
- package/dist/Content.js +0 -144
- package/dist/Icon-D8IZceys.cjs +0 -1
- package/dist/RadioGroup.cjs +0 -1
- package/dist/RadioGroup.js +0 -51
- package/dist/RadioGroupContext-BX9KnDek.cjs +0 -1
- package/dist/RadioGroupContext-DbKM4zPZ.js +0 -5
- package/dist/Table-83unQQOi.cjs +0 -1
- package/dist/Table-Cw8u-pEW.js +0 -403
- package/dist/Tooltip-BB82wNOE.cjs +0 -1
- package/dist/Tooltip-CqWK_GRD.js +0 -236
- package/dist/aria-DHnOMyYp.js +0 -10
- package/dist/aria-DKxpE8cA.cjs +0 -1
- package/dist/components/CheckboxGroup/index.d.ts +0 -2
- package/dist/components/Content/Content.d.ts +0 -58
- package/dist/components/Content/hooks/useContentLayout.d.ts +0 -18
- package/dist/components/Content/index.d.ts +0 -2
- package/dist/components/Content/utils/layout.d.ts +0 -11
- package/dist/components/RadioGroup/index.d.ts +0 -2
- package/dist/useFloatingPosition-CxzhAvy8.js +0 -73
- package/dist/useFloatingPosition-D1FqYy0l.cjs +0 -1
- package/dist/useFocusTrap--cgjy78G.cjs +0 -1
- package/dist/useFocusTrap-Da4nEash.js +0 -134
- package/dist/usePresence-DSPt6aKi.js +0 -210
- package/dist/usePresence-qe92UTvK.cjs +0 -1
- /package/dist/components/{CheckboxGroup → Checkbox}/contexts/CheckboxGroupContext.d.ts +0 -0
- /package/dist/components/{CheckboxGroup → Checkbox}/hooks/useCheckboxGroup.d.ts +0 -0
- /package/dist/components/{RadioGroup → Radio}/contexts/RadioGroupContext.d.ts +0 -0
- /package/dist/components/{RadioGroup → Radio}/hooks/useRadioGroup.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";const o=require("react/jsx-runtime"),u=require("react");function I(a){return(Array.from((a==null?void 0:a.trim())??"")[0]??"?").trim().toUpperCase()||"?"}function b(a){if(a==="?")return"neutral";const e=Array.from(a)[0]??"";if("AJO".includes(e))return"1";if("BNSV".includes(e))return"2";if("CFLQW".includes(e))return"3";if("EHKMPTX".includes(e))return"4";if("DGRUY".includes(e))return"5";if("IZ".includes(e))return"6";const n=e.codePointAt(0)??0;return String(n%6+1)}const y=u.forwardRef(function(e,n){const{alt:i,className:d,image:r,size:s=32,style:f,...m}=e,[v,g]=u.useState(),l=!!r&&r!==v,t=(i==null?void 0:i.trim())??"",c=I(t),A=typeof s=="number"?`${s}px`:s,k=t?{"aria-label":t,role:"img"}:{"aria-hidden":!0,role:void 0};function p(){g(r)}return o.jsx("div",{...m,...l?void 0:k,ref:n,className:["nk-avatar",d].filter(Boolean).join(" "),"data-palette":b(c),"data-state":l?"image":"fallback",style:{...f,"--nk-avatar-size":A},children:l?o.jsx("img",{alt:t,className:"nk-avatar__image",onError:p,src:r}):o.jsx("span",{"aria-hidden":"true",className:"nk-avatar__initial",children:c})})});exports.Avatar=y;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as k, useState as I } from "react";
|
|
4
|
+
function b(a) {
|
|
5
|
+
return (Array.from((a == null ? void 0 : a.trim()) ?? "")[0] ?? "?").trim().toUpperCase() || "?";
|
|
6
|
+
}
|
|
7
|
+
function y(a) {
|
|
8
|
+
if (a === "?") return "neutral";
|
|
9
|
+
const e = Array.from(a)[0] ?? "";
|
|
10
|
+
if ("AJO".includes(e)) return "1";
|
|
11
|
+
if ("BNSV".includes(e)) return "2";
|
|
12
|
+
if ("CFLQW".includes(e)) return "3";
|
|
13
|
+
if ("EHKMPTX".includes(e)) return "4";
|
|
14
|
+
if ("DGRUY".includes(e)) return "5";
|
|
15
|
+
if ("IZ".includes(e)) return "6";
|
|
16
|
+
const n = e.codePointAt(0) ?? 0;
|
|
17
|
+
return String(n % 6 + 1);
|
|
18
|
+
}
|
|
19
|
+
const P = k(function(e, n) {
|
|
20
|
+
const {
|
|
21
|
+
alt: i,
|
|
22
|
+
className: u,
|
|
23
|
+
image: r,
|
|
24
|
+
size: s = 32,
|
|
25
|
+
style: f,
|
|
26
|
+
...d
|
|
27
|
+
} = e, [m, v] = I(), l = !!r && r !== m, t = (i == null ? void 0 : i.trim()) ?? "", c = b(t), p = typeof s == "number" ? `${s}px` : s, g = t ? { "aria-label": t, role: "img" } : { "aria-hidden": !0, role: void 0 };
|
|
28
|
+
function A() {
|
|
29
|
+
v(r);
|
|
30
|
+
}
|
|
31
|
+
return /* @__PURE__ */ o(
|
|
32
|
+
"div",
|
|
33
|
+
{
|
|
34
|
+
...d,
|
|
35
|
+
...l ? void 0 : g,
|
|
36
|
+
ref: n,
|
|
37
|
+
className: ["nk-avatar", u].filter(Boolean).join(" "),
|
|
38
|
+
"data-palette": y(c),
|
|
39
|
+
"data-state": l ? "image" : "fallback",
|
|
40
|
+
style: { ...f, "--nk-avatar-size": p },
|
|
41
|
+
children: l ? /* @__PURE__ */ o(
|
|
42
|
+
"img",
|
|
43
|
+
{
|
|
44
|
+
alt: t,
|
|
45
|
+
className: "nk-avatar__image",
|
|
46
|
+
onError: A,
|
|
47
|
+
src: r
|
|
48
|
+
}
|
|
49
|
+
) : /* @__PURE__ */ o("span", { "aria-hidden": "true", className: "nk-avatar__initial", children: c })
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
export {
|
|
54
|
+
P as A
|
|
55
|
+
};
|
package/dist/Avatar.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./Avatar-Belo7qAY.cjs");exports.default=e.Avatar;
|
package/dist/Avatar.js
CHANGED
|
@@ -1,55 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { forwardRef as A, useState as I } from "react";
|
|
4
|
-
function b(a) {
|
|
5
|
-
return (Array.from((a == null ? void 0 : a.trim()) ?? "")[0] ?? "?").trim().toUpperCase() || "?";
|
|
6
|
-
}
|
|
7
|
-
function y(a) {
|
|
8
|
-
if (a === "?") return "neutral";
|
|
9
|
-
const e = Array.from(a)[0] ?? "";
|
|
10
|
-
if ("AJO".includes(e)) return "1";
|
|
11
|
-
if ("BNSV".includes(e)) return "2";
|
|
12
|
-
if ("CFLQW".includes(e)) return "3";
|
|
13
|
-
if ("EHKMPTX".includes(e)) return "4";
|
|
14
|
-
if ("DGRUY".includes(e)) return "5";
|
|
15
|
-
if ("IZ".includes(e)) return "6";
|
|
16
|
-
const n = e.codePointAt(0) ?? 0;
|
|
17
|
-
return String(n % 6 + 1);
|
|
18
|
-
}
|
|
19
|
-
const P = A(function(e, n) {
|
|
20
|
-
const {
|
|
21
|
-
alt: i,
|
|
22
|
-
className: u,
|
|
23
|
-
image: r,
|
|
24
|
-
size: l = 32,
|
|
25
|
-
style: f,
|
|
26
|
-
...d
|
|
27
|
-
} = e, [m, v] = I(), s = !!r && r !== m, t = (i == null ? void 0 : i.trim()) ?? "", c = b(t), p = typeof l == "number" ? `${l}px` : l, g = t ? { "aria-label": t, role: "img" } : { "aria-hidden": !0, role: void 0 };
|
|
28
|
-
function k() {
|
|
29
|
-
v(r);
|
|
30
|
-
}
|
|
31
|
-
return /* @__PURE__ */ o(
|
|
32
|
-
"div",
|
|
33
|
-
{
|
|
34
|
-
...d,
|
|
35
|
-
...s ? void 0 : g,
|
|
36
|
-
ref: n,
|
|
37
|
-
className: ["nk-avatar", u].filter(Boolean).join(" "),
|
|
38
|
-
"data-palette": y(c),
|
|
39
|
-
"data-state": s ? "image" : "fallback",
|
|
40
|
-
style: { ...f, "--nk-avatar-size": p },
|
|
41
|
-
children: s ? /* @__PURE__ */ o(
|
|
42
|
-
"img",
|
|
43
|
-
{
|
|
44
|
-
alt: t,
|
|
45
|
-
className: "nk-avatar__image",
|
|
46
|
-
onError: k,
|
|
47
|
-
src: r
|
|
48
|
-
}
|
|
49
|
-
) : /* @__PURE__ */ o("span", { "aria-hidden": "true", className: "nk-avatar__initial", children: c })
|
|
50
|
-
}
|
|
51
|
-
);
|
|
52
|
-
});
|
|
2
|
+
import { A as a } from "./Avatar-DjDCFqNG.js";
|
|
53
3
|
export {
|
|
54
|
-
|
|
4
|
+
a as default
|
|
55
5
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react"),W=require("./effects-D85L_7zM.cjs"),g=require("./units-PzuiQNnw.cjs"),C=[{minWidth:g.breakpoint("xl"),marginPercent:32,preferredWidth:1200},{minWidth:g.breakpoint("lg"),marginPercent:20,preferredWidth:1100},{minWidth:g.breakpoint("md"),marginPercent:14,preferredWidth:g.breakpoint("md")},{minWidth:g.breakpoint("sm"),marginPercent:8,preferredWidth:650}],N=16;function P(e){for(const t of C)if(e>=t.minWidth)return t}function R(e,t){if(!Number.isFinite(e)||!Number.isFinite(t)||e<g.breakpoint("sm")||t<=0)return;const n=P(e);if(!n)return;const i=e*n.marginPercent/100,d=e-i*2,s=Math.min(n.preferredWidth,e-N),l=Math.max(d,s);let u=Math.floor(l/t);if(u%2===0&&(u-=1),!(u<3))return Math.min((u-1)*t,e)}function B(e,t){if(typeof e=="function"){e(t);return}e&&(e.current=t)}function F(){const e=new Set;let t;return{publish(n){t!==n&&(t=n,e.forEach(i=>i()))},read(){return t},subscribe(n){return e.add(n),()=>{e.delete(n)}}}}function z(e){if(e.clientWidth===0)return;const t=window.getComputedStyle(e),n=(Number.parseFloat(t.paddingLeft)||0)+(Number.parseFloat(t.paddingRight)||0);return Math.max(e.clientWidth-n,0)}function _(e){const n=window.getComputedStyle(e).getPropertyValue("--nk-cell").trim().match(/^([+]?(?:\d+\.?\d*|\.\d+))px$/i);if(!n)return;const i=Number.parseFloat(n[1]);return Number.isFinite(i)&&i>0?i:void 0}function O(e,t){const n=o.useRef(null),i=o.useRef(null),d=o.useRef(void 0),s=o.useRef(null),[l,u]=o.useState(void 0),[b,y]=o.useState(null);s.current||(s.current=F());const h=s.current,a=o.useCallback(r=>{const c=z(r);if(h.publish(c),!t||c===void 0){if(d.current===void 0)return;d.current=void 0,u(void 0);return}const f=_(r),p=f===void 0?void 0:R(c,f);d.current!==p&&(d.current=p,u(p))},[h,t]),m=o.useCallback(r=>{var f;if((f=i.current)==null||f.disconnect(),i.current=null,typeof ResizeObserver>"u")return;const c=new ResizeObserver(()=>a(r));c.observe(r),i.current=c},[a]),v=o.useCallback(r=>{var c;(c=i.current)==null||c.disconnect(),i.current=null,n.current=r,y(r),B(e,r),!(!r||typeof window>"u")&&(a(r),m(r))},[m,e,a]);return W.useIsomorphicLayoutEffect(()=>{n.current&&a(n.current)}),o.useEffect(()=>(n.current&&m(n.current),()=>{var r;(r=i.current)==null||r.disconnect(),i.current=null}),[m]),{contentWidth:l,rootElement:b,rootReference:v,width:h}}const I=o.forwardRef(function(t,n){const{as:i,children:d,className:s,style:l,theme:u="auto",accent:b,decoration:y="grid",width:h="narrow",height:a="content",spacing:m="standard",...v}=t,{contentWidth:r,rootElement:c,rootReference:f,width:p}=O(n,h==="narrow"),w=o.useMemo(()=>({boundaryElement:c,portalElement:c,width:p}),[c,p]),S=i??"div",M=b!==void 0?{...l,"--nk-accent":b}:l,k=o.createElement(S,{...v,ref:f,className:["nk-boundary",s].filter(Boolean).join(" "),"data-theme":u,"data-decoration":y,"data-width":h,"data-height":a,"data-spacing":m,style:M},o.createElement("div",{className:"nk-boundary__content",style:r===void 0?void 0:{width:`${r}px`}},d));return o.createElement(W.BoundaryContext.Provider,{value:w},k)});exports.default=I;
|
package/dist/Boundary.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRef as y, useState as M, useCallback as w, useEffect as P, forwardRef as F, useMemo as R, createElement as b } from "react";
|
|
3
|
+
import { u as k, B as z } from "./effects-D5CWf-Pl.js";
|
|
4
|
+
import { b as p } from "./units-BmjPCccF.js";
|
|
5
|
+
const I = [
|
|
6
|
+
{
|
|
7
|
+
minWidth: p("xl"),
|
|
8
|
+
marginPercent: 32,
|
|
9
|
+
preferredWidth: 1200
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
minWidth: p("lg"),
|
|
13
|
+
marginPercent: 20,
|
|
14
|
+
preferredWidth: 1100
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
minWidth: p("md"),
|
|
18
|
+
marginPercent: 14,
|
|
19
|
+
preferredWidth: p("md")
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
minWidth: p("sm"),
|
|
23
|
+
marginPercent: 8,
|
|
24
|
+
preferredWidth: 650
|
|
25
|
+
}
|
|
26
|
+
], O = 16;
|
|
27
|
+
function V(t) {
|
|
28
|
+
for (const e of I)
|
|
29
|
+
if (t >= e.minWidth) return e;
|
|
30
|
+
}
|
|
31
|
+
function _(t, e) {
|
|
32
|
+
if (!Number.isFinite(t) || !Number.isFinite(e) || t < p("sm") || e <= 0)
|
|
33
|
+
return;
|
|
34
|
+
const n = V(t);
|
|
35
|
+
if (!n) return;
|
|
36
|
+
const o = t * n.marginPercent / 100, u = t - o * 2, d = Math.min(
|
|
37
|
+
n.preferredWidth,
|
|
38
|
+
t - O
|
|
39
|
+
), f = Math.max(u, d);
|
|
40
|
+
let c = Math.floor(f / e);
|
|
41
|
+
if (c % 2 === 0 && (c -= 1), !(c < 3))
|
|
42
|
+
return Math.min((c - 1) * e, t);
|
|
43
|
+
}
|
|
44
|
+
function x(t, e) {
|
|
45
|
+
if (typeof t == "function") {
|
|
46
|
+
t(e);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
t && (t.current = e);
|
|
50
|
+
}
|
|
51
|
+
function L() {
|
|
52
|
+
const t = /* @__PURE__ */ new Set();
|
|
53
|
+
let e;
|
|
54
|
+
return {
|
|
55
|
+
publish(n) {
|
|
56
|
+
e !== n && (e = n, t.forEach((o) => o()));
|
|
57
|
+
},
|
|
58
|
+
read() {
|
|
59
|
+
return e;
|
|
60
|
+
},
|
|
61
|
+
subscribe(n) {
|
|
62
|
+
return t.add(n), () => {
|
|
63
|
+
t.delete(n);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function T(t) {
|
|
69
|
+
if (t.clientWidth === 0) return;
|
|
70
|
+
const e = window.getComputedStyle(t), n = (Number.parseFloat(e.paddingLeft) || 0) + (Number.parseFloat(e.paddingRight) || 0);
|
|
71
|
+
return Math.max(t.clientWidth - n, 0);
|
|
72
|
+
}
|
|
73
|
+
function A(t) {
|
|
74
|
+
const n = window.getComputedStyle(t).getPropertyValue("--nk-cell").trim().match(
|
|
75
|
+
/^([+]?(?:\d+\.?\d*|\.\d+))px$/i
|
|
76
|
+
);
|
|
77
|
+
if (!n) return;
|
|
78
|
+
const o = Number.parseFloat(n[1]);
|
|
79
|
+
return Number.isFinite(o) && o > 0 ? o : void 0;
|
|
80
|
+
}
|
|
81
|
+
function $(t, e) {
|
|
82
|
+
const n = y(null), o = y(null), u = y(void 0), d = y(null), [f, c] = M(void 0), [g, v] = M(null);
|
|
83
|
+
d.current || (d.current = L());
|
|
84
|
+
const l = d.current, s = w((r) => {
|
|
85
|
+
const i = T(r);
|
|
86
|
+
if (l.publish(i), !e || i === void 0) {
|
|
87
|
+
if (u.current === void 0) return;
|
|
88
|
+
u.current = void 0, c(void 0);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const a = A(r), m = a === void 0 ? void 0 : _(i, a);
|
|
92
|
+
u.current !== m && (u.current = m, c(m));
|
|
93
|
+
}, [l, e]), h = w(
|
|
94
|
+
(r) => {
|
|
95
|
+
var a;
|
|
96
|
+
if ((a = o.current) == null || a.disconnect(), o.current = null, typeof ResizeObserver > "u") return;
|
|
97
|
+
const i = new ResizeObserver(
|
|
98
|
+
() => s(r)
|
|
99
|
+
);
|
|
100
|
+
i.observe(r), o.current = i;
|
|
101
|
+
},
|
|
102
|
+
[s]
|
|
103
|
+
), W = w(
|
|
104
|
+
(r) => {
|
|
105
|
+
var i;
|
|
106
|
+
(i = o.current) == null || i.disconnect(), o.current = null, n.current = r, v(r), x(t, r), !(!r || typeof window > "u") && (s(r), h(r));
|
|
107
|
+
},
|
|
108
|
+
[h, t, s]
|
|
109
|
+
);
|
|
110
|
+
return k(() => {
|
|
111
|
+
n.current && s(n.current);
|
|
112
|
+
}), P(() => (n.current && h(n.current), () => {
|
|
113
|
+
var r;
|
|
114
|
+
(r = o.current) == null || r.disconnect(), o.current = null;
|
|
115
|
+
}), [h]), {
|
|
116
|
+
contentWidth: f,
|
|
117
|
+
rootElement: g,
|
|
118
|
+
rootReference: W,
|
|
119
|
+
width: l
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
const U = F(
|
|
123
|
+
function(e, n) {
|
|
124
|
+
const {
|
|
125
|
+
as: o,
|
|
126
|
+
children: u,
|
|
127
|
+
className: d,
|
|
128
|
+
style: f,
|
|
129
|
+
theme: c = "auto",
|
|
130
|
+
accent: g,
|
|
131
|
+
decoration: v = "grid",
|
|
132
|
+
width: l = "narrow",
|
|
133
|
+
height: s = "content",
|
|
134
|
+
spacing: h = "standard",
|
|
135
|
+
...W
|
|
136
|
+
} = e, {
|
|
137
|
+
contentWidth: r,
|
|
138
|
+
rootElement: i,
|
|
139
|
+
rootReference: a,
|
|
140
|
+
width: m
|
|
141
|
+
} = $(n, l === "narrow"), S = R(() => ({
|
|
142
|
+
boundaryElement: i,
|
|
143
|
+
portalElement: i,
|
|
144
|
+
width: m
|
|
145
|
+
}), [i, m]), B = o ?? "div", C = g !== void 0 ? { ...f, "--nk-accent": g } : f, N = b(
|
|
146
|
+
B,
|
|
147
|
+
{
|
|
148
|
+
...W,
|
|
149
|
+
ref: a,
|
|
150
|
+
className: ["nk-boundary", d].filter(Boolean).join(" "),
|
|
151
|
+
"data-theme": c,
|
|
152
|
+
"data-decoration": v,
|
|
153
|
+
"data-width": l,
|
|
154
|
+
"data-height": s,
|
|
155
|
+
"data-spacing": h,
|
|
156
|
+
style: C
|
|
157
|
+
},
|
|
158
|
+
b(
|
|
159
|
+
"div",
|
|
160
|
+
{
|
|
161
|
+
className: "nk-boundary__content",
|
|
162
|
+
style: r === void 0 ? void 0 : { width: `${r}px` }
|
|
163
|
+
},
|
|
164
|
+
u
|
|
165
|
+
)
|
|
166
|
+
);
|
|
167
|
+
return b(
|
|
168
|
+
z.Provider,
|
|
169
|
+
{ value: S },
|
|
170
|
+
N
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
export {
|
|
175
|
+
U as default
|
|
176
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import {
|
|
2
|
+
import { jsxs as k, Fragment as C, jsx as m } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as K, createElement as q, isValidElement as G, Fragment as O } from "react";
|
|
4
|
+
import { I as x } from "./Icon-BoEUoOk7.js";
|
|
5
5
|
import { S as V } from "./Spinner-CVYvk6YK.js";
|
|
6
6
|
function g(t) {
|
|
7
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
8
|
}
|
|
9
|
-
function W(t,
|
|
10
|
-
const
|
|
9
|
+
function W(t, a) {
|
|
10
|
+
const s = t.getBoundingClientRect(), p = a.clientX - s.left, l = a.clientY - s.top;
|
|
11
11
|
t.style.setProperty("--nk-button-glow-x", `${p}px`), t.style.setProperty("--nk-button-glow-y", `${l}px`);
|
|
12
12
|
}
|
|
13
|
-
const L =
|
|
13
|
+
const L = K(function(a, s) {
|
|
14
14
|
const {
|
|
15
15
|
as: p,
|
|
16
16
|
children: l,
|
|
@@ -21,63 +21,63 @@ const L = C(function(s, a) {
|
|
|
21
21
|
iconAlignment: h = "left",
|
|
22
22
|
loading: f = !1,
|
|
23
23
|
onClick: A,
|
|
24
|
-
onKeyDown:
|
|
25
|
-
onMouseMove:
|
|
24
|
+
onKeyDown: v,
|
|
25
|
+
onMouseMove: I,
|
|
26
26
|
role: y,
|
|
27
|
-
shape:
|
|
27
|
+
shape: D = "capsule",
|
|
28
28
|
tabIndex: b,
|
|
29
29
|
textAlignment: j = "center",
|
|
30
|
-
tone:
|
|
31
|
-
variant:
|
|
30
|
+
tone: E,
|
|
31
|
+
variant: M = "primary",
|
|
32
32
|
...d
|
|
33
|
-
} =
|
|
33
|
+
} = a, r = p ?? "button", e = B || f, N = !!i && !g(l), u = r === "a" && "href" in d && typeof d.href == "string", c = typeof r == "string" && r !== "button" && !u, R = (o) => {
|
|
34
34
|
if (e) {
|
|
35
35
|
o.preventDefault(), o.stopPropagation();
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
38
|
const n = A;
|
|
39
39
|
n == null || n(o);
|
|
40
|
-
},
|
|
40
|
+
}, S = (o) => {
|
|
41
41
|
W(o.currentTarget, o);
|
|
42
|
-
const n =
|
|
42
|
+
const n = I;
|
|
43
43
|
n == null || n(o);
|
|
44
|
-
},
|
|
45
|
-
const n =
|
|
44
|
+
}, _ = (o) => {
|
|
45
|
+
const n = v;
|
|
46
46
|
n == null || n(o), !(o.defaultPrevented || e || !c || o.key !== "Enter" && o.key !== " ") && (o.preventDefault(), o.currentTarget.click());
|
|
47
|
-
},
|
|
48
|
-
disabled: e,
|
|
47
|
+
}, F = r === "button" ? {
|
|
48
|
+
"aria-disabled": e || void 0,
|
|
49
49
|
type: d.type ?? "button"
|
|
50
|
-
} : { "aria-disabled": e || void 0 },
|
|
51
|
-
return
|
|
50
|
+
} : { "aria-disabled": e || void 0 }, T = u && e ? { href: void 0 } : void 0, $ = u && e ? y ?? "link" : c ? y ?? "button" : y, z = r === "button" ? b : u && e ? void 0 : e ? -1 : c ? b ?? 0 : b;
|
|
51
|
+
return q(
|
|
52
52
|
r,
|
|
53
53
|
{
|
|
54
54
|
...d,
|
|
55
|
-
..._,
|
|
56
55
|
...F,
|
|
57
|
-
|
|
56
|
+
...T,
|
|
57
|
+
ref: s,
|
|
58
58
|
"aria-busy": f || void 0,
|
|
59
59
|
className: ["nk-button", P].filter(Boolean).join(" "),
|
|
60
60
|
"data-full-width": w || void 0,
|
|
61
|
-
"data-icon-only":
|
|
62
|
-
"data-shape":
|
|
63
|
-
"data-tone":
|
|
64
|
-
"data-variant":
|
|
65
|
-
onClick:
|
|
66
|
-
onKeyDown: c ?
|
|
67
|
-
onMouseMove:
|
|
68
|
-
role:
|
|
69
|
-
tabIndex:
|
|
61
|
+
"data-icon-only": N || void 0,
|
|
62
|
+
"data-shape": D,
|
|
63
|
+
"data-tone": E,
|
|
64
|
+
"data-variant": M,
|
|
65
|
+
onClick: R,
|
|
66
|
+
onKeyDown: c ? _ : v,
|
|
67
|
+
onMouseMove: S,
|
|
68
|
+
role: $,
|
|
69
|
+
tabIndex: z
|
|
70
70
|
},
|
|
71
|
-
/* @__PURE__ */
|
|
72
|
-
/* @__PURE__ */
|
|
71
|
+
/* @__PURE__ */ k(C, { children: [
|
|
72
|
+
/* @__PURE__ */ k(
|
|
73
73
|
"span",
|
|
74
74
|
{
|
|
75
75
|
className: "nk-button__content",
|
|
76
76
|
style: { justifyContent: j },
|
|
77
77
|
children: [
|
|
78
|
-
i && h === "left" ? /* @__PURE__ */ m(x, {
|
|
78
|
+
i && h === "left" ? /* @__PURE__ */ m(x, { type: i }) : null,
|
|
79
79
|
l,
|
|
80
|
-
i && h === "right" ? /* @__PURE__ */ m(x, {
|
|
80
|
+
i && h === "right" ? /* @__PURE__ */ m(x, { type: i }) : null
|
|
81
81
|
]
|
|
82
82
|
}
|
|
83
83
|
),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";const r=require("react/jsx-runtime"),f=require("react"),k=require("./Icon-DJ4BigRz.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:v,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,E=!!s&&!m(c),d=i==="a"&&"href"in u&&typeof u.href=="string",p=typeof i=="string"&&i!=="button"&&!d,M=n=>{if(o){n.preventDefault(),n.stopPropagation();return}const e=w;e==null||e(n)},N=n=>{K(n.currentTarget,n);const e=I;e==null||e(n)},S=n=>{const e=v;e==null||e(n),!(n.defaultPrevented||o||!p||n.key!=="Enter"&&n.key!==" ")&&(n.preventDefault(),n.currentTarget.click())},_=i==="button"?{"aria-disabled":o||void 0,type:u.type??"button"}:{"aria-disabled":o||void 0},T=d&&o?{href:void 0}:void 0,z=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,..._,...T,ref:l,"aria-busy":b||void 0,className:["nk-button",P].filter(Boolean).join(" "),"data-full-width":B||void 0,"data-icon-only":E||void 0,"data-shape":A,"data-tone":D,"data-variant":R,onClick:M,onKeyDown:p?S:v,onMouseMove:N,role:z,tabIndex:C},r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"nk-button__content",style:{justifyContent:q},children:[s&&x==="left"?r.jsx(k.Icon,{type:s}):null,c,s&&x==="right"?r.jsx(k.Icon,{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=$;
|
package/dist/Button.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./Button-
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./Button-DCKtFvSo.cjs");exports.default=e.Button;
|
package/dist/Button.js
CHANGED
package/dist/Checkbox.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react/jsx-runtime"),r=require("react"),N=require("./aria-Bntn6ad_.cjs"),Q=require("./field-control-NfLwcPj6.cjs"),W=require("./Icon-DJ4BigRz.cjs"),Z=require("./Text-DWYlIcPj.cjs"),T=Symbol("nk-checkbox-option");function $(o){Object.assign(o,{[T]:!0})}function F(o){if(typeof o!="function"&&typeof o!="object"||o===null)return!1;const a=o;return a[T]?!0:a.type!==void 0&&a.type!==o?F(a.type):!1}const z=r.createContext(void 0),ee=Object.freeze([]);function K(o,a){r.Children.forEach(o,n=>{if(n==null||typeof n=="boolean")return;if(!r.isValidElement(n))throw new Error("Checkbox.Group children must be direct Checkbox elements or fragments");if(n.type===r.Fragment){K(n.props.children,a);return}if(!F(n.type))throw new Error("Checkbox.Group children must be direct Checkbox elements or fragments");const i=n;a.push({disabled:!!i.props.disabled,required:!!i.props.required,value:String(i.props.value??"on")})})}function ne(o){const a=[];K(o,a);const n=new Set;return a.forEach(i=>{if(n.has(i.value))throw new Error("Checkbox.Group Checkbox values must be unique");n.add(i.value)}),a}function te(o,a,n){a.current=o,typeof n=="function"?n(o):n&&(n.current=o)}const U=r.forwardRef(function(a,n){const{"aria-invalid":i,children:u,className:S,defaultValue:s=ee,disabled:d=!1,invalid:E=!1,name:j,onChange:v,orientation:k="vertical",required:f=!1,value:x,...y}=a,p=r.useRef(null),[e,h]=r.useState(s),c=x!==void 0,O=c?x:e,B=E||N.hasInvalidState(i),_=ne(u),g=d?[]:_.filter(t=>!t.disabled).map(t=>t.value),m=new Set(g),C=O.some(t=>m.has(t)),V=g[0],R=_.find(t=>!t.disabled&&t.value===V),P=s.some(t=>m.has(t)),w=!!(R!=null&&R.required),D=r.useCallback(t=>te(t,p,n),[n]);r.useEffect(()=>{var I;if(c)return;const t=(I=p.current)==null?void 0:I.querySelector('input[type="checkbox"]'),b=t instanceof HTMLInputElement?t.form:null;if(!b)return;const G=b.getRootNode();function q(A){var L;if(A.target!==b||A.defaultPrevented)return;const H=Array.from(((L=p.current)==null?void 0:L.querySelectorAll('input[type="checkbox"]'))??[]).find(M=>!M.disabled&&M.value===V);H&&(H.required=!!(w||f&&!P)),h(s)}return G.addEventListener("reset",q),()=>G.removeEventListener("reset",q)},[u,s,P,c,f,w,V]);function Y(t){if(!c){const b=t.currentTarget.value,G=t.currentTarget.checked;h(q=>G?[...new Set([...q,b])]:q.filter(I=>I!==b))}v==null||v(t)}const J={defaultValue:s,disabled:d,handleChange:Y,hasSelection:C,name:j,required:f,value:x,validationValue:V};return l.jsx(z.Provider,{value:J,children:l.jsx("div",{...y,ref:D,"aria-disabled":d||void 0,"aria-invalid":N.resolveAriaInvalid(E,i),className:["nk-checkbox-group",S].filter(Boolean).join(" "),"data-disabled":d||void 0,"data-invalid":B||void 0,"data-orientation":k,role:"group",children:u})})});Q.markFieldGroupControl(U,"label");function oe(){return r.useContext(z)}const X=r.forwardRef(function(a,n){var m;const{"aria-invalid":i,checked:u,children:S,className:s,defaultChecked:d,disabled:E=!1,invalid:j=!1,name:v,onChange:k,required:f=!1,style:x,value:y="on",...p}=a,e=oe(),h=String(y),c=(e==null?void 0:e.value)!==void 0,O=E||!!(e!=null&&e.disabled),B=!!(e!=null&&e.required&&!e.hasSelection&&e.validationValue===h),_=j||N.hasInvalidState(i);function g(C){k==null||k(C),C.defaultPrevented||e==null||e.handleChange(C)}return l.jsxs("label",{className:["nk-checkbox",s].filter(Boolean).join(" "),"data-disabled":O||void 0,"data-invalid":_||void 0,style:x,children:[l.jsx("input",{...p,ref:n,"aria-invalid":N.resolveAriaInvalid(j,i),checked:e?c?(m=e.value)==null?void 0:m.includes(h):void 0:u,className:"nk-checkbox__control",defaultChecked:e&&!c?e.defaultValue.includes(h):d,disabled:O,name:(e==null?void 0:e.name)??v,onChange:g,required:f||B,type:"checkbox",value:y}),l.jsx("span",{"aria-hidden":"true",className:"nk-checkbox__visual",children:l.jsx(W.Icon,{className:"nk-checkbox__icon",size:12,type:"checkmark"})}),S!==void 0?l.jsxs(Z.Text,{as:"span",className:"nk-checkbox__label",children:[S,f?l.jsx("span",{"aria-hidden":"true",className:"nk-checkbox__required",children:"*"}):null]}):null]})});$(X);const ae=Object.assign(X,{Group:U});exports.default=ae;
|
package/dist/Checkbox.js
CHANGED
|
@@ -1,5 +1,216 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { jsx as h, jsxs as L } from "react/jsx-runtime";
|
|
3
|
+
import { createContext as Z, forwardRef as F, useRef as $, useState as ee, useCallback as ne, useEffect as oe, Children as te, isValidElement as ae, Fragment as ie, useContext as re } from "react";
|
|
4
|
+
import { r as T, h as z } from "./aria-CeA9QfD1.js";
|
|
5
|
+
import { m as le } from "./field-control-XAn_FKks.js";
|
|
6
|
+
import { I as se } from "./Icon-BoEUoOk7.js";
|
|
7
|
+
import { T as ce } from "./Text-rN6iDo0V.js";
|
|
8
|
+
const K = Symbol("nk-checkbox-option");
|
|
9
|
+
function ue(t) {
|
|
10
|
+
Object.assign(t, { [K]: !0 });
|
|
11
|
+
}
|
|
12
|
+
function M(t) {
|
|
13
|
+
if (typeof t != "function" && typeof t != "object" || t === null)
|
|
14
|
+
return !1;
|
|
15
|
+
const a = t;
|
|
16
|
+
return a[K] ? !0 : a.type !== void 0 && a.type !== t ? M(a.type) : !1;
|
|
17
|
+
}
|
|
18
|
+
const U = Z(void 0), de = Object.freeze([]);
|
|
19
|
+
function X(t, a) {
|
|
20
|
+
te.forEach(t, (n) => {
|
|
21
|
+
if (n == null || typeof n == "boolean")
|
|
22
|
+
return;
|
|
23
|
+
if (!ae(n))
|
|
24
|
+
throw new Error(
|
|
25
|
+
"Checkbox.Group children must be direct Checkbox elements or fragments"
|
|
26
|
+
);
|
|
27
|
+
if (n.type === ie) {
|
|
28
|
+
X(n.props.children, a);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (!M(n.type))
|
|
32
|
+
throw new Error(
|
|
33
|
+
"Checkbox.Group children must be direct Checkbox elements or fragments"
|
|
34
|
+
);
|
|
35
|
+
const i = n;
|
|
36
|
+
a.push({
|
|
37
|
+
disabled: !!i.props.disabled,
|
|
38
|
+
required: !!i.props.required,
|
|
39
|
+
value: String(i.props.value ?? "on")
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function fe(t) {
|
|
44
|
+
const a = [];
|
|
45
|
+
X(t, a);
|
|
46
|
+
const n = /* @__PURE__ */ new Set();
|
|
47
|
+
return a.forEach((i) => {
|
|
48
|
+
if (n.has(i.value))
|
|
49
|
+
throw new Error("Checkbox.Group Checkbox values must be unique");
|
|
50
|
+
n.add(i.value);
|
|
51
|
+
}), a;
|
|
52
|
+
}
|
|
53
|
+
function he(t, a, n) {
|
|
54
|
+
a.current = t, typeof n == "function" ? n(t) : n && (n.current = t);
|
|
55
|
+
}
|
|
56
|
+
const D = F(
|
|
57
|
+
function(a, n) {
|
|
58
|
+
const {
|
|
59
|
+
"aria-invalid": i,
|
|
60
|
+
children: s,
|
|
61
|
+
className: E,
|
|
62
|
+
defaultValue: r = de,
|
|
63
|
+
disabled: c = !1,
|
|
64
|
+
invalid: S = !1,
|
|
65
|
+
name: q,
|
|
66
|
+
onChange: b,
|
|
67
|
+
orientation: k = "vertical",
|
|
68
|
+
required: u = !1,
|
|
69
|
+
value: p,
|
|
70
|
+
...y
|
|
71
|
+
} = a, v = $(null), [e, d] = ee(r), l = p !== void 0, O = l ? p : e, B = S || z(i), V = fe(s), _ = c ? [] : V.filter((o) => !o.disabled).map((o) => o.value), m = new Set(_), x = O.some(
|
|
72
|
+
(o) => m.has(o)
|
|
73
|
+
), g = _[0], I = V.find(
|
|
74
|
+
(o) => !o.disabled && o.value === g
|
|
75
|
+
), j = r.some(
|
|
76
|
+
(o) => m.has(o)
|
|
77
|
+
), P = !!(I != null && I.required), J = ne(
|
|
78
|
+
(o) => he(
|
|
79
|
+
o,
|
|
80
|
+
v,
|
|
81
|
+
n
|
|
82
|
+
),
|
|
83
|
+
[n]
|
|
84
|
+
);
|
|
85
|
+
oe(() => {
|
|
86
|
+
var N;
|
|
87
|
+
if (l) return;
|
|
88
|
+
const o = (N = v.current) == null ? void 0 : N.querySelector(
|
|
89
|
+
'input[type="checkbox"]'
|
|
90
|
+
), f = o instanceof HTMLInputElement ? o.form : null;
|
|
91
|
+
if (!f) return;
|
|
92
|
+
const G = f.getRootNode();
|
|
93
|
+
function C(R) {
|
|
94
|
+
var A;
|
|
95
|
+
if (R.target !== f || R.defaultPrevented) return;
|
|
96
|
+
const w = Array.from(
|
|
97
|
+
((A = v.current) == null ? void 0 : A.querySelectorAll(
|
|
98
|
+
'input[type="checkbox"]'
|
|
99
|
+
)) ?? []
|
|
100
|
+
).find(
|
|
101
|
+
(H) => !H.disabled && H.value === g
|
|
102
|
+
);
|
|
103
|
+
w && (w.required = !!(P || u && !j)), d(r);
|
|
104
|
+
}
|
|
105
|
+
return G.addEventListener("reset", C), () => G.removeEventListener("reset", C);
|
|
106
|
+
}, [
|
|
107
|
+
s,
|
|
108
|
+
r,
|
|
109
|
+
j,
|
|
110
|
+
l,
|
|
111
|
+
u,
|
|
112
|
+
P,
|
|
113
|
+
g
|
|
114
|
+
]);
|
|
115
|
+
function Q(o) {
|
|
116
|
+
if (!l) {
|
|
117
|
+
const f = o.currentTarget.value, G = o.currentTarget.checked;
|
|
118
|
+
d((C) => G ? [.../* @__PURE__ */ new Set([...C, f])] : C.filter((N) => N !== f));
|
|
119
|
+
}
|
|
120
|
+
b == null || b(o);
|
|
121
|
+
}
|
|
122
|
+
const W = {
|
|
123
|
+
defaultValue: r,
|
|
124
|
+
disabled: c,
|
|
125
|
+
handleChange: Q,
|
|
126
|
+
hasSelection: x,
|
|
127
|
+
name: q,
|
|
128
|
+
required: u,
|
|
129
|
+
value: p,
|
|
130
|
+
validationValue: g
|
|
131
|
+
};
|
|
132
|
+
return /* @__PURE__ */ h(U.Provider, { value: W, children: /* @__PURE__ */ h(
|
|
133
|
+
"div",
|
|
134
|
+
{
|
|
135
|
+
...y,
|
|
136
|
+
ref: J,
|
|
137
|
+
"aria-disabled": c || void 0,
|
|
138
|
+
"aria-invalid": T(S, i),
|
|
139
|
+
className: [
|
|
140
|
+
"nk-checkbox-group",
|
|
141
|
+
E
|
|
142
|
+
].filter(Boolean).join(" "),
|
|
143
|
+
"data-disabled": c || void 0,
|
|
144
|
+
"data-invalid": B || void 0,
|
|
145
|
+
"data-orientation": k,
|
|
146
|
+
role: "group",
|
|
147
|
+
children: s
|
|
148
|
+
}
|
|
149
|
+
) });
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
le(D, "label");
|
|
153
|
+
function be() {
|
|
154
|
+
return re(U);
|
|
155
|
+
}
|
|
156
|
+
const Y = F(function(a, n) {
|
|
157
|
+
var m;
|
|
158
|
+
const {
|
|
159
|
+
"aria-invalid": i,
|
|
160
|
+
checked: s,
|
|
161
|
+
children: E,
|
|
162
|
+
className: r,
|
|
163
|
+
defaultChecked: c,
|
|
164
|
+
disabled: S = !1,
|
|
165
|
+
invalid: q = !1,
|
|
166
|
+
name: b,
|
|
167
|
+
onChange: k,
|
|
168
|
+
required: u = !1,
|
|
169
|
+
style: p,
|
|
170
|
+
value: y = "on",
|
|
171
|
+
...v
|
|
172
|
+
} = a, e = be(), d = String(y), l = (e == null ? void 0 : e.value) !== void 0, O = S || !!(e != null && e.disabled), B = !!(e != null && e.required && !e.hasSelection && e.validationValue === d), V = q || z(i);
|
|
173
|
+
function _(x) {
|
|
174
|
+
k == null || k(x), x.defaultPrevented || e == null || e.handleChange(x);
|
|
175
|
+
}
|
|
176
|
+
return /* @__PURE__ */ L(
|
|
177
|
+
"label",
|
|
178
|
+
{
|
|
179
|
+
className: ["nk-checkbox", r].filter(Boolean).join(" "),
|
|
180
|
+
"data-disabled": O || void 0,
|
|
181
|
+
"data-invalid": V || void 0,
|
|
182
|
+
style: p,
|
|
183
|
+
children: [
|
|
184
|
+
/* @__PURE__ */ h(
|
|
185
|
+
"input",
|
|
186
|
+
{
|
|
187
|
+
...v,
|
|
188
|
+
ref: n,
|
|
189
|
+
"aria-invalid": T(q, i),
|
|
190
|
+
checked: e ? l ? (m = e.value) == null ? void 0 : m.includes(d) : void 0 : s,
|
|
191
|
+
className: "nk-checkbox__control",
|
|
192
|
+
defaultChecked: e && !l ? e.defaultValue.includes(d) : c,
|
|
193
|
+
disabled: O,
|
|
194
|
+
name: (e == null ? void 0 : e.name) ?? b,
|
|
195
|
+
onChange: _,
|
|
196
|
+
required: u || B,
|
|
197
|
+
type: "checkbox",
|
|
198
|
+
value: y
|
|
199
|
+
}
|
|
200
|
+
),
|
|
201
|
+
/* @__PURE__ */ h("span", { "aria-hidden": "true", className: "nk-checkbox__visual", children: /* @__PURE__ */ h(se, { className: "nk-checkbox__icon", size: 12, type: "checkmark" }) }),
|
|
202
|
+
E !== void 0 ? /* @__PURE__ */ L(ce, { as: "span", className: "nk-checkbox__label", children: [
|
|
203
|
+
E,
|
|
204
|
+
u ? /* @__PURE__ */ h("span", { "aria-hidden": "true", className: "nk-checkbox__required", children: "*" }) : null
|
|
205
|
+
] }) : null
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
);
|
|
209
|
+
});
|
|
210
|
+
ue(Y);
|
|
211
|
+
const Ee = Object.assign(Y, {
|
|
212
|
+
Group: D
|
|
213
|
+
});
|
|
3
214
|
export {
|
|
4
|
-
|
|
215
|
+
Ee as default
|
|
5
216
|
};
|