neatkit 0.4.2 → 0.6.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/Alert-DQ5CCE0N.js +29 -0
- package/dist/Alert-LJDkNUqH.cjs +1 -0
- package/dist/Alert.cjs +1 -0
- package/dist/Alert.js +4 -0
- package/dist/Avatar.cjs +1 -0
- package/dist/Avatar.js +55 -0
- package/dist/Badge.cjs +1 -0
- package/dist/Badge.js +25 -0
- package/dist/Button-BAsLfA0D.js +99 -0
- package/dist/Button-D7JUO6Fs.cjs +1 -0
- package/dist/Button.cjs +1 -0
- package/dist/Button.js +5 -0
- package/dist/Card-CPq6dsut.js +34 -0
- package/dist/Card-CQ-8_1tO.cjs +1 -0
- package/dist/Card.cjs +1 -0
- package/dist/Card.js +4 -0
- package/dist/Checkbox-BvXM9VyY.js +68 -0
- package/dist/Checkbox-VQifZrZZ.cjs +1 -0
- package/dist/Checkbox.cjs +1 -0
- package/dist/Checkbox.js +5 -0
- package/dist/CheckboxGroup.cjs +1 -0
- package/dist/CheckboxGroup.js +144 -0
- package/dist/Code-BP2ZCmUf.js +7446 -0
- package/dist/Code-eispVOW3.cjs +6 -0
- package/dist/Code.cjs +1 -0
- package/dist/Code.js +5 -0
- package/dist/Content.cjs +1 -0
- package/dist/Content.js +144 -0
- package/dist/Divider-BE15WVDI.js +42 -0
- package/dist/Divider-CJYbFcSX.cjs +1 -0
- package/dist/Divider.cjs +1 -0
- package/dist/Divider.js +4 -0
- package/dist/Field.cjs +1 -0
- package/dist/Field.js +115 -0
- package/dist/Icon-D8IZceys.cjs +1 -0
- package/dist/Icon-uQmpr5P2.js +1139 -0
- package/dist/Icon.cjs +1 -0
- package/dist/Icon.js +37 -0
- package/dist/Input.cjs +1 -0
- package/dist/Input.js +146 -0
- package/dist/Markdown.cjs +31 -0
- package/dist/Markdown.js +18411 -0
- package/dist/Modal.cjs +1 -0
- package/dist/Modal.js +171 -0
- package/dist/PinInput.cjs +1 -0
- package/dist/PinInput.js +248 -0
- package/dist/Popover.cjs +1 -0
- package/dist/Popover.js +238 -0
- package/dist/Radio.cjs +1 -0
- package/dist/Radio.js +65 -0
- package/dist/RadioGroup.cjs +1 -0
- package/dist/RadioGroup.js +51 -0
- package/dist/RadioGroupContext-BX9KnDek.cjs +1 -0
- package/dist/RadioGroupContext-DbKM4zPZ.js +5 -0
- package/dist/Select.cjs +1 -0
- package/dist/Select.js +473 -0
- package/dist/Skeleton.cjs +1 -0
- package/dist/Skeleton.js +27 -0
- package/dist/Spinner-BXgw60UC.cjs +1 -0
- package/dist/Spinner-CVYvk6YK.js +25 -0
- package/dist/Spinner.cjs +1 -0
- package/dist/Spinner.js +4 -0
- package/dist/Surface-BttJYSDt.cjs +1 -0
- package/dist/Surface-vEFsZC12.js +17 -0
- package/dist/Switch.cjs +1 -0
- package/dist/Switch.js +39 -0
- package/dist/Table-83unQQOi.cjs +1 -0
- package/dist/Table-Cw8u-pEW.js +403 -0
- package/dist/Table.cjs +1 -0
- package/dist/Table.js +5 -0
- package/dist/Text-DWYlIcPj.cjs +1 -0
- package/dist/Text-rN6iDo0V.js +24 -0
- package/dist/Text.cjs +1 -0
- package/dist/Text.js +4 -0
- package/dist/TextArea.cjs +1 -0
- package/dist/TextArea.js +43 -0
- package/dist/Tooltip-BB82wNOE.cjs +1 -0
- package/dist/Tooltip-CqWK_GRD.js +236 -0
- package/dist/Tooltip.cjs +1 -0
- package/dist/Tooltip.js +6 -0
- package/dist/aria-DHnOMyYp.js +10 -0
- package/dist/aria-DKxpE8cA.cjs +1 -0
- package/dist/components/Alert/index.d.ts +1 -1
- package/dist/components/Avatar/index.d.ts +1 -1
- package/dist/components/Badge/index.d.ts +1 -1
- package/dist/components/Button/Button.d.ts +2 -2
- package/dist/components/Button/index.d.ts +1 -1
- package/dist/components/Card/index.d.ts +1 -1
- package/dist/components/Checkbox/index.d.ts +1 -1
- package/dist/components/CheckboxGroup/index.d.ts +1 -1
- package/dist/components/Code/Code.d.ts +47 -0
- package/dist/components/Code/index.d.ts +2 -0
- package/dist/components/Code/utils/highlight.d.ts +17 -0
- package/dist/components/Content/Content.d.ts +3 -3
- package/dist/components/Content/index.d.ts +2 -2
- package/dist/components/Divider/index.d.ts +1 -1
- package/dist/components/Field/index.d.ts +1 -1
- package/dist/components/Icon/index.d.ts +1 -1
- package/dist/components/Input/index.d.ts +1 -1
- package/dist/components/Markdown/Markdown.d.ts +66 -0
- package/dist/components/Markdown/index.d.ts +3 -0
- package/dist/components/Markdown/utils/language.d.ts +9 -0
- package/dist/components/Markdown/utils/renderers.d.ts +15 -0
- package/dist/components/Markdown/utils/security.d.ts +66 -0
- package/dist/components/Modal/index.d.ts +1 -1
- package/dist/components/PinInput/index.d.ts +1 -1
- package/dist/components/Popover/index.d.ts +1 -1
- package/dist/components/Radio/index.d.ts +1 -1
- package/dist/components/RadioGroup/index.d.ts +1 -1
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/Skeleton/index.d.ts +1 -1
- package/dist/components/Spinner/index.d.ts +1 -1
- package/dist/components/Switch/index.d.ts +1 -1
- package/dist/components/Table/Table.d.ts +7 -11
- package/dist/components/Table/index.d.ts +1 -1
- package/dist/components/Text/index.d.ts +1 -1
- package/dist/components/TextArea/index.d.ts +1 -1
- package/dist/components/Tooltip/index.d.ts +1 -1
- package/dist/field-control-NfLwcPj6.cjs +1 -0
- package/dist/field-control-XAn_FKks.js +16 -0
- package/dist/focus-restoration-70WcQRr5.cjs +1 -0
- package/dist/focus-restoration-BvNZzrQA.js +16 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -26
- package/dist/index.js +6 -4409
- package/dist/reference-C2guRuR0.cjs +1 -0
- package/dist/reference-CXMr27nM.js +12 -0
- package/dist/style.css +1 -1
- package/dist/tokens.d.ts +1 -1
- package/dist/units-BmjPCccF.js +90 -0
- package/dist/units-PzuiQNnw.cjs +1 -0
- package/dist/useFloatingPosition-CxzhAvy8.js +73 -0
- package/dist/useFloatingPosition-D1FqYy0l.cjs +1 -0
- package/dist/useFocusTrap--cgjy78G.cjs +1 -0
- package/dist/useFocusTrap-Da4nEash.js +134 -0
- package/dist/usePresence-DSPt6aKi.js +210 -0
- package/dist/usePresence-qe92UTvK.cjs +1 -0
- package/package.json +155 -2
package/dist/Modal.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("react/jsx-runtime"),s=require("react"),$=require("./Button-D7JUO6Fs.cjs"),f=require("./usePresence-qe92UTvK.cjs"),A=require("./useFocusTrap--cgjy78G.cjs"),D=require("./Surface-BttJYSDt.cjs"),V=require("./Text-DWYlIcPj.cjs"),y=new WeakMap;function G(l,e){s.useEffect(()=>{if(!l||!e)return;const o=y.get(e);if(o)o.count+=1;else{const t=e.body,r=e.defaultView,u=r&&Number.parseFloat(r.getComputedStyle(t).paddingRight)||0,n=e.documentElement.clientWidth,c=r&&n>0?Math.max(0,r.innerWidth-n):0,b={count:1,overflow:t.style.overflow,paddingRight:t.style.paddingRight};y.set(e,b),t.style.overflow="hidden",c>0&&(t.style.paddingRight=`${u+c}px`)}return()=>{const t=y.get(e);t&&(t.count-=1,!(t.count>0)&&(e.body.style.overflow=t.overflow,e.body.style.paddingRight=t.paddingRight,y.delete(e)))}},[l,e])}function H(l,e,o){e.current=l,typeof o=="function"?o(l):o&&(o.current=l)}function J(l){const{"aria-label":e,"aria-labelledby":o,children:t,className:r,closeButtonLabel:u="Close modal",exitable:n=!0,forwardedReference:c,initialFocusReference:b,lockScroll:P=!0,onClose:i,open:a,ownerDocument:h,presenceState:x,restoreFocus:_=!0,role:B="dialog",style:I,title:p,trapFocus:S=!0,...M}=l,R=s.useRef(null),k=s.useRef(null),E=s.useContext(f.FocusScopeContext),L=`${s.useId()}-title`,[g,q]=s.useState(null),m=f.useOverlayLayer(!0,h),N=s.useMemo(()=>[R],[]),v=!!(p!=null&&p.trim()),O=b??(v?k:void 0),T=o??(e===void 0&&v?L:void 0),W=s.useCallback(F=>{H(F,R,c),q(F)},[c]);s.useLayoutEffect(()=>{g&&(g.inert=!a)},[g,a]);const w=s.useCallback(()=>{i==null||i("escape")},[i]),C=s.useCallback(()=>{i==null||i("outside")},[i]);f.useDismissableLayer({active:a,boundaries:N,dismissOnEscape:n,dismissOnPointerDownOutside:n,layerId:m.id,onEscapeDismiss:w,onPointerDownOutsideDismiss:C,ownerDocument:h});const z=A.useFocusTrap({active:a&&S,container:g,initialFocusReference:O,layerId:m.id,restoreFocus:_});G(P,h);const j=n?d.jsx($.Button,{"aria-label":u,className:"nk-modal__close",icon:"cross",onClick:()=>i==null?void 0:i("close-button"),shape:"rectangle",type:"button",variant:"ghost"}):null;return d.jsx(f.FocusScopeContext.Provider,{value:a&&S?z:E,children:d.jsx("div",{className:"nk-modal__overlay","data-state":x,role:"presentation",style:{zIndex:m.zIndex},children:d.jsxs(D.Surface,{...M,ref:W,"aria-hidden":a?void 0:!0,"aria-label":a?e:void 0,"aria-labelledby":a?T:void 0,"aria-modal":a?"true":void 0,className:["nk-modal",r].filter(Boolean).join(" "),"data-state":x,role:a?B:void 0,style:I,tabIndex:-1,children:[v?d.jsxs("div",{className:"nk-modal__header",children:[d.jsx(V.Text,{as:"h2",className:"nk-modal__title",id:L,ref:k,size:"subtitle",tabIndex:-1,weight:"semibold",children:p}),j]}):j,t]})})})}const K=s.forwardRef(function(e,o){const{open:t}=e,r=s.useRef(e);t&&(r.current=e);const u=t?e:r.current,{portalContainer:n}=u,c=f.usePresence(t),b=(n==null?void 0:n.ownerDocument)??(typeof document>"u"?null:document);return c.present?d.jsx(f.Portal,{container:n,children:d.jsx(J,{...u,forwardedReference:o,open:t,ownerDocument:b,presenceState:c.state==="closing"?"closing":"open"})}):null});exports.default=K;
|
package/dist/Modal.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as d, jsxs as B } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect as V, forwardRef as q, useRef as v, useContext as G, useId as H, useState as J, useMemo as K, useCallback as h, useLayoutEffect as Q } from "react";
|
|
4
|
+
import { B as U } from "./Button-BAsLfA0D.js";
|
|
5
|
+
import { a as X, P as Y, F as I, b as Z, c as ee } from "./usePresence-DSPt6aKi.js";
|
|
6
|
+
import { u as te } from "./useFocusTrap-Da4nEash.js";
|
|
7
|
+
import { S as oe } from "./Surface-vEFsZC12.js";
|
|
8
|
+
import { T as se } from "./Text-rN6iDo0V.js";
|
|
9
|
+
const p = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
function ae(n, e) {
|
|
11
|
+
V(() => {
|
|
12
|
+
if (!n || !e) return;
|
|
13
|
+
const o = p.get(e);
|
|
14
|
+
if (o)
|
|
15
|
+
o.count += 1;
|
|
16
|
+
else {
|
|
17
|
+
const t = e.body, l = e.defaultView, c = l && Number.parseFloat(
|
|
18
|
+
l.getComputedStyle(t).paddingRight
|
|
19
|
+
) || 0, s = e.documentElement.clientWidth, r = l && s > 0 ? Math.max(
|
|
20
|
+
0,
|
|
21
|
+
l.innerWidth - s
|
|
22
|
+
) : 0, u = {
|
|
23
|
+
count: 1,
|
|
24
|
+
overflow: t.style.overflow,
|
|
25
|
+
paddingRight: t.style.paddingRight
|
|
26
|
+
};
|
|
27
|
+
p.set(e, u), t.style.overflow = "hidden", r > 0 && (t.style.paddingRight = `${c + r}px`);
|
|
28
|
+
}
|
|
29
|
+
return () => {
|
|
30
|
+
const t = p.get(e);
|
|
31
|
+
t && (t.count -= 1, !(t.count > 0) && (e.body.style.overflow = t.overflow, e.body.style.paddingRight = t.paddingRight, p.delete(e)));
|
|
32
|
+
};
|
|
33
|
+
}, [n, e]);
|
|
34
|
+
}
|
|
35
|
+
function ie(n, e, o) {
|
|
36
|
+
e.current = n, typeof o == "function" ? o(n) : o && (o.current = n);
|
|
37
|
+
}
|
|
38
|
+
function ne(n) {
|
|
39
|
+
const {
|
|
40
|
+
"aria-label": e,
|
|
41
|
+
"aria-labelledby": o,
|
|
42
|
+
children: t,
|
|
43
|
+
className: l,
|
|
44
|
+
closeButtonLabel: c = "Close modal",
|
|
45
|
+
exitable: s = !0,
|
|
46
|
+
forwardedReference: r,
|
|
47
|
+
initialFocusReference: u,
|
|
48
|
+
lockScroll: E = !0,
|
|
49
|
+
onClose: a,
|
|
50
|
+
open: i,
|
|
51
|
+
ownerDocument: b,
|
|
52
|
+
presenceState: S,
|
|
53
|
+
restoreFocus: _ = !0,
|
|
54
|
+
role: M = "dialog",
|
|
55
|
+
style: N,
|
|
56
|
+
title: f,
|
|
57
|
+
trapFocus: k = !0,
|
|
58
|
+
...O
|
|
59
|
+
} = n, x = v(null), R = v(null), W = G(I), L = `${H()}-title`, [m, T] = J(null), g = Z(!0, b), w = K(() => [x], []), y = !!(f != null && f.trim()), j = u ?? (y ? R : void 0), z = o ?? (e === void 0 && y ? L : void 0), $ = h(
|
|
60
|
+
(P) => {
|
|
61
|
+
ie(P, x, r), T(P);
|
|
62
|
+
},
|
|
63
|
+
[r]
|
|
64
|
+
);
|
|
65
|
+
Q(() => {
|
|
66
|
+
m && (m.inert = !i);
|
|
67
|
+
}, [m, i]);
|
|
68
|
+
const A = h(() => {
|
|
69
|
+
a == null || a("escape");
|
|
70
|
+
}, [a]), C = h(() => {
|
|
71
|
+
a == null || a("outside");
|
|
72
|
+
}, [a]);
|
|
73
|
+
ee({
|
|
74
|
+
active: i,
|
|
75
|
+
boundaries: w,
|
|
76
|
+
dismissOnEscape: s,
|
|
77
|
+
dismissOnPointerDownOutside: s,
|
|
78
|
+
layerId: g.id,
|
|
79
|
+
onEscapeDismiss: A,
|
|
80
|
+
onPointerDownOutsideDismiss: C,
|
|
81
|
+
ownerDocument: b
|
|
82
|
+
});
|
|
83
|
+
const D = te({
|
|
84
|
+
active: i && k,
|
|
85
|
+
container: m,
|
|
86
|
+
initialFocusReference: j,
|
|
87
|
+
layerId: g.id,
|
|
88
|
+
restoreFocus: _
|
|
89
|
+
});
|
|
90
|
+
ae(E, b);
|
|
91
|
+
const F = s ? /* @__PURE__ */ d(
|
|
92
|
+
U,
|
|
93
|
+
{
|
|
94
|
+
"aria-label": c,
|
|
95
|
+
className: "nk-modal__close",
|
|
96
|
+
icon: "cross",
|
|
97
|
+
onClick: () => a == null ? void 0 : a("close-button"),
|
|
98
|
+
shape: "rectangle",
|
|
99
|
+
type: "button",
|
|
100
|
+
variant: "ghost"
|
|
101
|
+
}
|
|
102
|
+
) : null;
|
|
103
|
+
return /* @__PURE__ */ d(
|
|
104
|
+
I.Provider,
|
|
105
|
+
{
|
|
106
|
+
value: i && k ? D : W,
|
|
107
|
+
children: /* @__PURE__ */ d(
|
|
108
|
+
"div",
|
|
109
|
+
{
|
|
110
|
+
className: "nk-modal__overlay",
|
|
111
|
+
"data-state": S,
|
|
112
|
+
role: "presentation",
|
|
113
|
+
style: { zIndex: g.zIndex },
|
|
114
|
+
children: /* @__PURE__ */ B(
|
|
115
|
+
oe,
|
|
116
|
+
{
|
|
117
|
+
...O,
|
|
118
|
+
ref: $,
|
|
119
|
+
"aria-hidden": i ? void 0 : !0,
|
|
120
|
+
"aria-label": i ? e : void 0,
|
|
121
|
+
"aria-labelledby": i ? z : void 0,
|
|
122
|
+
"aria-modal": i ? "true" : void 0,
|
|
123
|
+
className: ["nk-modal", l].filter(Boolean).join(" "),
|
|
124
|
+
"data-state": S,
|
|
125
|
+
role: i ? M : void 0,
|
|
126
|
+
style: N,
|
|
127
|
+
tabIndex: -1,
|
|
128
|
+
children: [
|
|
129
|
+
y ? /* @__PURE__ */ B("div", { className: "nk-modal__header", children: [
|
|
130
|
+
/* @__PURE__ */ d(
|
|
131
|
+
se,
|
|
132
|
+
{
|
|
133
|
+
as: "h2",
|
|
134
|
+
className: "nk-modal__title",
|
|
135
|
+
id: L,
|
|
136
|
+
ref: R,
|
|
137
|
+
size: "subtitle",
|
|
138
|
+
tabIndex: -1,
|
|
139
|
+
weight: "semibold",
|
|
140
|
+
children: f
|
|
141
|
+
}
|
|
142
|
+
),
|
|
143
|
+
F
|
|
144
|
+
] }) : F,
|
|
145
|
+
t
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
const pe = q(function(e, o) {
|
|
155
|
+
const { open: t } = e, l = v(e);
|
|
156
|
+
t && (l.current = e);
|
|
157
|
+
const c = t ? e : l.current, { portalContainer: s } = c, r = X(t), u = (s == null ? void 0 : s.ownerDocument) ?? (typeof document > "u" ? null : document);
|
|
158
|
+
return r.present ? /* @__PURE__ */ d(Y, { container: s, children: /* @__PURE__ */ d(
|
|
159
|
+
ne,
|
|
160
|
+
{
|
|
161
|
+
...c,
|
|
162
|
+
forwardedReference: o,
|
|
163
|
+
open: t,
|
|
164
|
+
ownerDocument: u,
|
|
165
|
+
presenceState: r.state === "closing" ? "closing" : "open"
|
|
166
|
+
}
|
|
167
|
+
) }) : null;
|
|
168
|
+
});
|
|
169
|
+
export {
|
|
170
|
+
pe as default
|
|
171
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("react/jsx-runtime"),v=require("react"),G=require("./aria-DKxpE8cA.cjs"),$=3,B=10,H=4;function X(a){return Number.isFinite(a)?Math.min(B,Math.max($,Math.trunc(a))):H}function M(a,s,l){return(s==="numeric"?a.replace(/[^0-9]/g,""):a.replace(/[^0-9a-z]/gi,"").toUpperCase()).slice(0,l)}function Z(a,s,l){s.current=a,typeof l=="function"?l(a):l&&(l.current=a)}function J(a,s){var c;const l=(c=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(a),"value"))==null?void 0:c.set;l?l.call(a,s):a.value=s}function U(a,s,l){const c=Math.min(l-1,Math.max(0,s)),P=Math.min(c+1,a.value.length);a.focus(),a.setSelectionRange(c,P)}function Q(a){const{defaultValue:s,disabled:l,forwardedReference:c,length:P,mode:u,onChange:_,onComplete:y,onFocus:N,onKeyDown:p,onPaste:x,onSelect:b,readOnly:S,value:L}=a,n=X(P),k=M(s,u,n),w=v.useRef(null),[D,V]=v.useState(k),[E,d]=v.useState(0),f=L!==void 0,i=M(f?L:D,u,n),R=v.useCallback(t=>Z(t,w,c),[c]);v.useEffect(()=>{!f&&D!==i&&V(i)},[f,i,D]),v.useEffect(()=>{var o;if(f)return;const t=(o=w.current)==null?void 0:o.form;if(!t)return;const e=t.getRootNode();function r(h){h.target!==t||h.defaultPrevented||(V(k),d(0))}return e.addEventListener("reset",r),()=>e.removeEventListener("reset",r)},[f,k]);function j(t){const e=t.selectionStart??i.length;return Math.min(n-1,Math.max(0,e))}function T(t){const e=t.currentTarget,r=e.selectionStart??e.value.length,o=M(e.value,u,n),h=M(e.value.slice(0,r),u,n).length;e.value=o,f||V(o),_==null||_(t),o.length===n&&o!==i&&(y==null||y(o));const g=Math.min(n-1,h);d(g),e.setSelectionRange(g,Math.min(g+1,o.length))}function A(t){if(x==null||x(t),t.defaultPrevented||l||S)return;const e=M(t.clipboardData.getData("text"),u,n);if(t.preventDefault(),e.length===0)return;const r=t.currentTarget,o=r.selectionStart??i.length,h=r.selectionEnd??o,g=e.length===n?e:M(i.slice(0,o)+e+i.slice(h),u,n),C=e.length===n?n:Math.min(n,o+e.length);J(r,g),r.setSelectionRange(C,C),r.dispatchEvent(new Event("input",{bubbles:!0}))}function z(t){if(p==null||p(t),t.defaultPrevented||t.key!=="ArrowLeft"&&t.key!=="ArrowRight")return;t.preventDefault();const e=t.key==="ArrowLeft"?-1:1,r=Math.min(n-1,Math.max(0,j(t.currentTarget)+e));d(r),U(t.currentTarget,r,n)}function O(t){N==null||N(t);const e=Math.min(n-1,i.length);d(e),U(t.currentTarget,e,n)}function F(t){b==null||b(t),d(j(t.currentTarget))}function q(t,e){if(t.preventDefault(),l)return;const r=w.current;r&&(d(e),U(r,e,n))}return{activeIndex:E,handleChange:T,handleFocus:O,handleKeyDown:z,handlePaste:A,handleSelect:F,handleSlotPointerDown:q,inputCallbackReference:R,length:n,renderedValue:i}}const W=v.forwardRef(function(s,l){const{"aria-invalid":c,autoCapitalize:P,autoComplete:u="one-time-code",className:_,censored:y=!1,defaultValue:N="",disabled:p=!1,invalid:x=!1,length:b=H,mode:S="numeric",onChange:L,onComplete:n,onFocus:k,onKeyDown:w,onPaste:D,onSelect:V,readOnly:E=!1,style:d,value:f,wrap:i=!1,...R}=s,{activeIndex:j,handleChange:T,handleFocus:A,handleKeyDown:z,handlePaste:O,handleSelect:F,handleSlotPointerDown:q,inputCallbackReference:t,length:e,renderedValue:r}=Q({defaultValue:N,disabled:p,forwardedReference:l,length:b,mode:S,onChange:L,onComplete:n,onFocus:k,onKeyDown:w,onPaste:D,onSelect:V,readOnly:E,value:f}),o=x||G.hasInvalidState(c),h=!i&&e>=6&&e%2===0,g=e/2,C={...d,"--nk-pin-input-columns":Math.ceil(e/2)};return m.jsxs("span",{className:["nk-pin-input",_].filter(Boolean).join(" "),"data-disabled":p||void 0,"data-invalid":o||void 0,"data-read-only":E||void 0,"data-wrap":i||void 0,style:C,children:[m.jsx("input",{...R,ref:t,"aria-invalid":G.resolveAriaInvalid(x,c),autoCapitalize:P??(S==="alphanumeric"?"characters":"off"),autoComplete:u,className:"nk-pin-input__control",disabled:p,inputMode:S==="numeric"?"numeric":"text",maxLength:e,minLength:e,onChange:T,onFocus:A,onKeyDown:z,onPaste:O,onSelect:F,pattern:S==="numeric"?`[0-9]{${e}}`:`[0-9A-Za-z]{${e}}`,readOnly:E,spellCheck:!1,type:"text",value:r}),m.jsx("span",{"aria-hidden":"true",className:"nk-pin-input__slots",children:Array.from({length:e},(Y,I)=>m.jsxs("span",{className:"nk-pin-input__slot-group",children:[h&&I===g?m.jsx("span",{className:"nk-pin-input__separator",children:"-"}):null,m.jsx("span",{className:"nk-pin-input__slot","data-active":j===I||void 0,onPointerDown:K=>q(K,I),children:y&&r[I]?m.jsx("span",{className:"nk-pin-input__censor"}):r[I]??""})]},I))})]})});exports.default=W;
|
package/dist/PinInput.js
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as G, jsx as b } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as B, useState as H, useCallback as X, useEffect as K, forwardRef as Z } from "react";
|
|
4
|
+
import { r as J, h as Q } from "./aria-DHnOMyYp.js";
|
|
5
|
+
const W = 3, Y = 10, q = 4;
|
|
6
|
+
function ee(a) {
|
|
7
|
+
return Number.isFinite(a) ? Math.min(
|
|
8
|
+
Y,
|
|
9
|
+
Math.max(W, Math.trunc(a))
|
|
10
|
+
) : q;
|
|
11
|
+
}
|
|
12
|
+
function S(a, s, r) {
|
|
13
|
+
return (s === "numeric" ? a.replace(/[^0-9]/g, "") : a.replace(/[^0-9a-z]/gi, "").toUpperCase()).slice(0, r);
|
|
14
|
+
}
|
|
15
|
+
function te(a, s, r) {
|
|
16
|
+
s.current = a, typeof r == "function" ? r(a) : r && (r.current = a);
|
|
17
|
+
}
|
|
18
|
+
function ne(a, s) {
|
|
19
|
+
var c;
|
|
20
|
+
const r = (c = Object.getOwnPropertyDescriptor(
|
|
21
|
+
Object.getPrototypeOf(a),
|
|
22
|
+
"value"
|
|
23
|
+
)) == null ? void 0 : c.set;
|
|
24
|
+
r ? r.call(a, s) : a.value = s;
|
|
25
|
+
}
|
|
26
|
+
function U(a, s, r) {
|
|
27
|
+
const c = Math.min(r - 1, Math.max(0, s)), x = Math.min(c + 1, a.value.length);
|
|
28
|
+
a.focus(), a.setSelectionRange(c, x);
|
|
29
|
+
}
|
|
30
|
+
function ae(a) {
|
|
31
|
+
const {
|
|
32
|
+
defaultValue: s,
|
|
33
|
+
disabled: r,
|
|
34
|
+
forwardedReference: c,
|
|
35
|
+
length: x,
|
|
36
|
+
mode: u,
|
|
37
|
+
onChange: M,
|
|
38
|
+
onComplete: P,
|
|
39
|
+
onFocus: _,
|
|
40
|
+
onKeyDown: p,
|
|
41
|
+
onPaste: g,
|
|
42
|
+
onSelect: N,
|
|
43
|
+
readOnly: v,
|
|
44
|
+
value: L
|
|
45
|
+
} = a, n = ee(x), y = S(
|
|
46
|
+
s,
|
|
47
|
+
u,
|
|
48
|
+
n
|
|
49
|
+
), k = B(null), [w, D] = H(
|
|
50
|
+
y
|
|
51
|
+
), [V, d] = H(0), f = L !== void 0, i = S(
|
|
52
|
+
f ? L : w,
|
|
53
|
+
u,
|
|
54
|
+
n
|
|
55
|
+
), R = X(
|
|
56
|
+
(t) => te(
|
|
57
|
+
t,
|
|
58
|
+
k,
|
|
59
|
+
c
|
|
60
|
+
),
|
|
61
|
+
[c]
|
|
62
|
+
);
|
|
63
|
+
K(() => {
|
|
64
|
+
!f && w !== i && D(i);
|
|
65
|
+
}, [f, i, w]), K(() => {
|
|
66
|
+
var l;
|
|
67
|
+
if (f) return;
|
|
68
|
+
const t = (l = k.current) == null ? void 0 : l.form;
|
|
69
|
+
if (!t) return;
|
|
70
|
+
const e = t.getRootNode();
|
|
71
|
+
function o(h) {
|
|
72
|
+
h.target !== t || h.defaultPrevented || (D(y), d(0));
|
|
73
|
+
}
|
|
74
|
+
return e.addEventListener("reset", o), () => e.removeEventListener("reset", o);
|
|
75
|
+
}, [f, y]);
|
|
76
|
+
function C(t) {
|
|
77
|
+
const e = t.selectionStart ?? i.length;
|
|
78
|
+
return Math.min(n - 1, Math.max(0, e));
|
|
79
|
+
}
|
|
80
|
+
function T(t) {
|
|
81
|
+
const e = t.currentTarget, o = e.selectionStart ?? e.value.length, l = S(e.value, u, n), h = S(
|
|
82
|
+
e.value.slice(0, o),
|
|
83
|
+
u,
|
|
84
|
+
n
|
|
85
|
+
).length;
|
|
86
|
+
e.value = l, f || D(l), M == null || M(t), l.length === n && l !== i && (P == null || P(l));
|
|
87
|
+
const m = Math.min(n - 1, h);
|
|
88
|
+
d(m), e.setSelectionRange(
|
|
89
|
+
m,
|
|
90
|
+
Math.min(m + 1, l.length)
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
function A(t) {
|
|
94
|
+
if (g == null || g(t), t.defaultPrevented || r || v) return;
|
|
95
|
+
const e = S(
|
|
96
|
+
t.clipboardData.getData("text"),
|
|
97
|
+
u,
|
|
98
|
+
n
|
|
99
|
+
);
|
|
100
|
+
if (t.preventDefault(), e.length === 0) return;
|
|
101
|
+
const o = t.currentTarget, l = o.selectionStart ?? i.length, h = o.selectionEnd ?? l, m = e.length === n ? e : S(
|
|
102
|
+
i.slice(0, l) + e + i.slice(h),
|
|
103
|
+
u,
|
|
104
|
+
n
|
|
105
|
+
), E = e.length === n ? n : Math.min(n, l + e.length);
|
|
106
|
+
ne(o, m), o.setSelectionRange(E, E), o.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
107
|
+
}
|
|
108
|
+
function z(t) {
|
|
109
|
+
if (p == null || p(t), t.defaultPrevented || t.key !== "ArrowLeft" && t.key !== "ArrowRight") return;
|
|
110
|
+
t.preventDefault();
|
|
111
|
+
const e = t.key === "ArrowLeft" ? -1 : 1, o = Math.min(
|
|
112
|
+
n - 1,
|
|
113
|
+
Math.max(0, C(t.currentTarget) + e)
|
|
114
|
+
);
|
|
115
|
+
d(o), U(t.currentTarget, o, n);
|
|
116
|
+
}
|
|
117
|
+
function F(t) {
|
|
118
|
+
_ == null || _(t);
|
|
119
|
+
const e = Math.min(n - 1, i.length);
|
|
120
|
+
d(e), U(t.currentTarget, e, n);
|
|
121
|
+
}
|
|
122
|
+
function O(t) {
|
|
123
|
+
N == null || N(t), d(C(t.currentTarget));
|
|
124
|
+
}
|
|
125
|
+
function j(t, e) {
|
|
126
|
+
if (t.preventDefault(), r) return;
|
|
127
|
+
const o = k.current;
|
|
128
|
+
o && (d(e), U(o, e, n));
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
activeIndex: V,
|
|
132
|
+
handleChange: T,
|
|
133
|
+
handleFocus: F,
|
|
134
|
+
handleKeyDown: z,
|
|
135
|
+
handlePaste: A,
|
|
136
|
+
handleSelect: O,
|
|
137
|
+
handleSlotPointerDown: j,
|
|
138
|
+
inputCallbackReference: R,
|
|
139
|
+
length: n,
|
|
140
|
+
renderedValue: i
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
const se = Z(function(s, r) {
|
|
144
|
+
const {
|
|
145
|
+
"aria-invalid": c,
|
|
146
|
+
autoCapitalize: x,
|
|
147
|
+
autoComplete: u = "one-time-code",
|
|
148
|
+
className: M,
|
|
149
|
+
censored: P = !1,
|
|
150
|
+
defaultValue: _ = "",
|
|
151
|
+
disabled: p = !1,
|
|
152
|
+
invalid: g = !1,
|
|
153
|
+
length: N = q,
|
|
154
|
+
mode: v = "numeric",
|
|
155
|
+
onChange: L,
|
|
156
|
+
onComplete: n,
|
|
157
|
+
onFocus: y,
|
|
158
|
+
onKeyDown: k,
|
|
159
|
+
onPaste: w,
|
|
160
|
+
onSelect: D,
|
|
161
|
+
readOnly: V = !1,
|
|
162
|
+
style: d,
|
|
163
|
+
value: f,
|
|
164
|
+
wrap: i = !1,
|
|
165
|
+
...R
|
|
166
|
+
} = s, {
|
|
167
|
+
activeIndex: C,
|
|
168
|
+
handleChange: T,
|
|
169
|
+
handleFocus: A,
|
|
170
|
+
handleKeyDown: z,
|
|
171
|
+
handlePaste: F,
|
|
172
|
+
handleSelect: O,
|
|
173
|
+
handleSlotPointerDown: j,
|
|
174
|
+
inputCallbackReference: t,
|
|
175
|
+
length: e,
|
|
176
|
+
renderedValue: o
|
|
177
|
+
} = ae({
|
|
178
|
+
defaultValue: _,
|
|
179
|
+
disabled: p,
|
|
180
|
+
forwardedReference: r,
|
|
181
|
+
length: N,
|
|
182
|
+
mode: v,
|
|
183
|
+
onChange: L,
|
|
184
|
+
onComplete: n,
|
|
185
|
+
onFocus: y,
|
|
186
|
+
onKeyDown: k,
|
|
187
|
+
onPaste: w,
|
|
188
|
+
onSelect: D,
|
|
189
|
+
readOnly: V,
|
|
190
|
+
value: f
|
|
191
|
+
}), l = g || Q(c), h = !i && e >= 6 && e % 2 === 0, m = e / 2, E = {
|
|
192
|
+
...d,
|
|
193
|
+
"--nk-pin-input-columns": Math.ceil(e / 2)
|
|
194
|
+
};
|
|
195
|
+
return /* @__PURE__ */ G(
|
|
196
|
+
"span",
|
|
197
|
+
{
|
|
198
|
+
className: ["nk-pin-input", M].filter(Boolean).join(" "),
|
|
199
|
+
"data-disabled": p || void 0,
|
|
200
|
+
"data-invalid": l || void 0,
|
|
201
|
+
"data-read-only": V || void 0,
|
|
202
|
+
"data-wrap": i || void 0,
|
|
203
|
+
style: E,
|
|
204
|
+
children: [
|
|
205
|
+
/* @__PURE__ */ b(
|
|
206
|
+
"input",
|
|
207
|
+
{
|
|
208
|
+
...R,
|
|
209
|
+
ref: t,
|
|
210
|
+
"aria-invalid": J(g, c),
|
|
211
|
+
autoCapitalize: x ?? (v === "alphanumeric" ? "characters" : "off"),
|
|
212
|
+
autoComplete: u,
|
|
213
|
+
className: "nk-pin-input__control",
|
|
214
|
+
disabled: p,
|
|
215
|
+
inputMode: v === "numeric" ? "numeric" : "text",
|
|
216
|
+
maxLength: e,
|
|
217
|
+
minLength: e,
|
|
218
|
+
onChange: T,
|
|
219
|
+
onFocus: A,
|
|
220
|
+
onKeyDown: z,
|
|
221
|
+
onPaste: F,
|
|
222
|
+
onSelect: O,
|
|
223
|
+
pattern: v === "numeric" ? `[0-9]{${e}}` : `[0-9A-Za-z]{${e}}`,
|
|
224
|
+
readOnly: V,
|
|
225
|
+
spellCheck: !1,
|
|
226
|
+
type: "text",
|
|
227
|
+
value: o
|
|
228
|
+
}
|
|
229
|
+
),
|
|
230
|
+
/* @__PURE__ */ b("span", { "aria-hidden": "true", className: "nk-pin-input__slots", children: Array.from({ length: e }, (oe, I) => /* @__PURE__ */ G("span", { className: "nk-pin-input__slot-group", children: [
|
|
231
|
+
h && I === m ? /* @__PURE__ */ b("span", { className: "nk-pin-input__separator", children: "-" }) : null,
|
|
232
|
+
/* @__PURE__ */ b(
|
|
233
|
+
"span",
|
|
234
|
+
{
|
|
235
|
+
className: "nk-pin-input__slot",
|
|
236
|
+
"data-active": C === I || void 0,
|
|
237
|
+
onPointerDown: ($) => j($, I),
|
|
238
|
+
children: P && o[I] ? /* @__PURE__ */ b("span", { className: "nk-pin-input__censor" }) : o[I] ?? ""
|
|
239
|
+
}
|
|
240
|
+
)
|
|
241
|
+
] }, I)) })
|
|
242
|
+
]
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
});
|
|
246
|
+
export {
|
|
247
|
+
se as default
|
|
248
|
+
};
|
package/dist/Popover.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react/jsx-runtime"),t=require("react"),_=require("./reference-C2guRuR0.cjs"),y=require("./usePresence-qe92UTvK.cjs"),Ce=require("./useFloatingPosition-D1FqYy0l.cjs"),Se=require("./useFocusTrap--cgjy78G.cjs"),Oe=require("./Surface-BttJYSDt.cjs");function we(n){const{inert:a,panelElement:c}=n;return t.useLayoutEffect(()=>{c&&(c.inert=a)},[a,c]),null}function De(n,a,c){a.current=n,_.assignElementReference(c,n)}function Fe(n,a,c){a.current=n,_.assignElementReference(c,n)}function je(n,a){const c=(n==null?void 0:n.split(/\s+/).filter(Boolean))??[];return c.includes(a)||c.push(a),c.join(" ")}function qe(n){const a=n.tagName.toLowerCase();return n.getAttribute("role")==="button"&&a!=="button"?!1:["button","input","select","summary","textarea"].includes(a)?!0:a==="a"&&n.hasAttribute("href")}function Le(n){return n==="grid"||n==="listbox"||n==="menu"||n==="tree"?n:"dialog"}const Ne=t.forwardRef(function(a,c){const{"aria-label":B,"aria-labelledby":ee,autoFocus:w=!0,children:te,className:re,closeOnEscape:ne=!0,closeOnOutsideInteraction:se=!0,defaultOpen:oe=!1,disabled:T=!1,initialFocusReference:h,onEscapeKeyDown:ae,onOpenChange:x,onPointerDownOutside:k,open:M,placement:K="bottom",portalContainer:I,restoreFocus:D=!0,role:z="dialog",style:A,tabIndex:ce,trapFocus:m=!1,trigger:d,...ie}=a;if(d.type===t.Fragment)throw new Error("Popover requires a single non-Fragment trigger");const H=t.useId(),ue=t.useContext(y.FocusScopeContext),V=`${H}-popover`,o=d.props,$=_.getElementReference(d),U=o.id??`${H}-trigger`,P=T||o.disabled===!0||o["aria-disabled"]===!0||o["aria-disabled"]==="true",R=M!==void 0,[le,de]=t.useState(oe),r=R?M:le,C=y.usePresence(r),G=t.useRef(null),J=t.useRef(null),F=t.useRef("programmatic"),j=t.useRef(null),Q=t.useRef(r),S=t.useRef(null),[fe,pe]=t.useReducer(e=>e+1,0),[u,ge]=t.useState(null),[f,me]=t.useState(null),i=(I==null?void 0:I.ownerDocument)??(u==null?void 0:u.ownerDocument)??(typeof document>"u"?null:document),O=y.useOverlayLayer(C.present,i),be=t.useMemo(()=>[G,J],[]),p=Ce.useFloatingPosition(C.present,K,u,f),ve=t.useCallback(e=>{Fe(e,G,$),ge(e)},[$]),ye=t.useCallback(e=>{De(e,J,c),me(e)},[c]),g=t.useCallback((e,s)=>{r!==e&&(R?(j.current={open:e,reason:s},pe()):(F.current=s,de(e)),x==null||x(e,s))},[R,x,r]),he=t.useCallback(()=>{g(!1,"escape")},[g]),Pe=t.useCallback(()=>{g(!1,"outside")},[g]),Re=t.useCallback(e=>{var E;if(k==null||k(e),e.defaultPrevented)return;const s=(E=i==null?void 0:i.defaultView)==null?void 0:E.HTMLElement;S.current=s?e.composedPath().find(v=>v instanceof s&&v.tabIndex>=0)??e.target:e.target},[k,i]);y.useDismissableLayer({active:r,boundaries:be,dismissOnEscape:ne,dismissOnPointerDownOutside:se,layerId:O.id,onEscapeDismiss:he,onEscapeKeyDown:ae,onPointerDownOutside:Re,onPointerDownOutsideDismiss:Pe,ownerDocument:i});const Ee=Se.useFocusTrap({active:r&&m,autoFocus:w,container:f,initialFocusReference:h,layerId:O.id,restoreFocus:D});t.useEffect(()=>{if(!r||m||!w||!f)return;let e=!0;return Promise.resolve().then(()=>{if(!e)return;const s=h==null?void 0:h.current;(s&&f.contains(s)?s:f).focus({preventScroll:!0})}),()=>{e=!1}},[w,h,r,f,m]),t.useEffect(()=>{var Z;const e=Q.current;Q.current=r;const s=j.current,E=R?e!==r&&(s==null?void 0:s.open)===r?s.reason:"programmatic":F.current;if(j.current=null,r){F.current="programmatic",S.current=null;return}const v=i==null?void 0:i.activeElement,L=S.current,N=(Z=i==null?void 0:i.defaultView)==null?void 0:Z.HTMLElement,Ie=E==="outside"&&N&&L instanceof N&&v instanceof N&&(L===v||L.contains(v));e&&!m&&D&&!Ie&&(u==null||u.focus({preventScroll:!0})),S.current=null},[fe,R,r,i,D,m,u]),t.useEffect(()=>{T&&r&&g(!1,"programmatic")},[T,r,g]);function Te(e){var s;if(P){e.preventDefault(),e.stopPropagation();return}(s=o.onClick)==null||s.call(o,e),!e.defaultPrevented&&g(!r,"trigger")}function xe(e){var s;(s=o.onKeyDown)==null||s.call(o,e),!(e.defaultPrevented||P||qe(e.currentTarget)||e.key!=="Enter"&&e.key!==" ")&&(e.preventDefault(),e.currentTarget.click())}if(T)return d;const q=typeof d.type=="string",b=q?d.type:null,W=b==="a"&&typeof o.href=="string",X=q&&!(b==="button"||b==="input"||b==="select"||b==="summary"||b==="textarea"||W),Y=W&&P,ke=t.cloneElement(d,{"aria-controls":r?je(o["aria-controls"],V):o["aria-controls"],"aria-expanded":r,"aria-haspopup":o["aria-haspopup"]??Le(z),"aria-disabled":P?!0:o["aria-disabled"],className:[o.className,"nk-popover__trigger"].filter(Boolean).join(" "),href:Y?void 0:o.href,id:U,onClick:Te,onKeyDown:q?xe:o.onKeyDown,ref:ve,role:o.role??(Y?"link":X?"button":void 0),tabIndex:P?-1:o.tabIndex??(X?0:void 0)});return l.jsxs(l.Fragment,{children:[ke,l.jsx(y.FocusScopeContext.Provider,{value:r&&m?Ee:ue,children:C.present&&i?l.jsx(y.Portal,{container:I,inheritFrom:u,children:l.jsxs(Oe.Surface,{...ie,ref:ye,"aria-hidden":r?void 0:!0,"aria-label":r?B:void 0,"aria-labelledby":r?ee??(B===void 0?U:void 0):void 0,className:["nk-popover",re].filter(Boolean).join(" "),"data-placement":(p==null?void 0:p.placement)??K,"data-state":C.state==="closing"?"closing":"open",id:V,role:r?z:void 0,style:p?{...A,"--nk-popover-arrow-offset":`${p.arrowOffset}px`,left:p.left,top:p.top,zIndex:O.zIndex}:{...A,visibility:"hidden",zIndex:O.zIndex},tabIndex:ce??-1,children:[l.jsx(we,{inert:!r,panelElement:f}),l.jsx("span",{"aria-hidden":"true",className:"nk-popover__arrow"}),l.jsx("div",{className:"nk-popover__content",children:te})]})}):null})]})});exports.default=Ne;
|
package/dist/Popover.js
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
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;
|
|
14
|
+
}
|
|
15
|
+
function Qe(r, s, a) {
|
|
16
|
+
s.current = r, ne(a, r);
|
|
17
|
+
}
|
|
18
|
+
function We(r, s, a) {
|
|
19
|
+
s.current = r, ne(a, r);
|
|
20
|
+
}
|
|
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(" ");
|
|
24
|
+
}
|
|
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");
|
|
28
|
+
}
|
|
29
|
+
function Ze(r) {
|
|
30
|
+
return r === "grid" || r === "listbox" || r === "menu" || r === "tree" ? r : "dialog";
|
|
31
|
+
}
|
|
32
|
+
const ct = Ce(function(s, a) {
|
|
33
|
+
const {
|
|
34
|
+
"aria-label": q,
|
|
35
|
+
"aria-labelledby": oe,
|
|
36
|
+
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,
|
|
43
|
+
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,
|
|
55
|
+
trigger: l,
|
|
56
|
+
...fe
|
|
57
|
+
} = s;
|
|
58
|
+
if (l.type === Le)
|
|
59
|
+
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(
|
|
61
|
+
(e) => e + 1,
|
|
62
|
+
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],
|
|
65
|
+
[]
|
|
66
|
+
), d = Ve(
|
|
67
|
+
O.present,
|
|
68
|
+
A,
|
|
69
|
+
c,
|
|
70
|
+
u
|
|
71
|
+
), Ee = v(
|
|
72
|
+
(e) => {
|
|
73
|
+
We(
|
|
74
|
+
e,
|
|
75
|
+
J,
|
|
76
|
+
U
|
|
77
|
+
), he(e);
|
|
78
|
+
},
|
|
79
|
+
[U]
|
|
80
|
+
), Te = v(
|
|
81
|
+
(e) => {
|
|
82
|
+
Qe(
|
|
83
|
+
e,
|
|
84
|
+
Q,
|
|
85
|
+
a
|
|
86
|
+
), ye(e);
|
|
87
|
+
},
|
|
88
|
+
[a]
|
|
89
|
+
), f = v((e, n) => {
|
|
90
|
+
t !== e && (P ? (L.current = {
|
|
91
|
+
open: e,
|
|
92
|
+
reason: n
|
|
93
|
+
}, ve()) : (C.current = n, me(e)), R == null || R(e, n));
|
|
94
|
+
}, [P, R, t]), Ie = v(() => {
|
|
95
|
+
f(!1, "escape");
|
|
96
|
+
}, [f]), Re = v(() => {
|
|
97
|
+
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
|
|
117
|
+
});
|
|
118
|
+
const ke = Ue({
|
|
119
|
+
active: t && p,
|
|
120
|
+
autoFocus: F,
|
|
121
|
+
container: u,
|
|
122
|
+
initialFocusReference: h,
|
|
123
|
+
layerId: D.id,
|
|
124
|
+
restoreFocus: S
|
|
125
|
+
});
|
|
126
|
+
K(() => {
|
|
127
|
+
if (!t || p || !F || !u) return;
|
|
128
|
+
let e = !0;
|
|
129
|
+
return Promise.resolve().then(() => {
|
|
130
|
+
if (!e) return;
|
|
131
|
+
const n = h == null ? void 0 : h.current;
|
|
132
|
+
(n && u.contains(n) ? n : u).focus({ preventScroll: !0 });
|
|
133
|
+
}), () => {
|
|
134
|
+
e = !1;
|
|
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;
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
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;
|
|
147
|
+
}, [
|
|
148
|
+
be,
|
|
149
|
+
P,
|
|
150
|
+
t,
|
|
151
|
+
i,
|
|
152
|
+
S,
|
|
153
|
+
p,
|
|
154
|
+
c
|
|
155
|
+
]), K(() => {
|
|
156
|
+
I && t && f(!1, "programmatic");
|
|
157
|
+
}, [I, t, f]);
|
|
158
|
+
function Oe(e) {
|
|
159
|
+
var n;
|
|
160
|
+
if (y) {
|
|
161
|
+
e.preventDefault(), e.stopPropagation();
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
(n = o.onClick) == null || n.call(o, e), !e.defaultPrevented && f(!t, "trigger");
|
|
165
|
+
}
|
|
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());
|
|
169
|
+
}
|
|
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(
|
|
172
|
+
l,
|
|
173
|
+
{
|
|
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)
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
return /* @__PURE__ */ te(Se, { children: [
|
|
189
|
+
De,
|
|
190
|
+
/* @__PURE__ */ T(
|
|
191
|
+
re.Provider,
|
|
192
|
+
{
|
|
193
|
+
value: t && p ? ke : pe,
|
|
194
|
+
children: O.present && i ? /* @__PURE__ */ T(He, { container: k, inheritFrom: c, children: /* @__PURE__ */ te(
|
|
195
|
+
Ge,
|
|
196
|
+
{
|
|
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,
|
|
204
|
+
"data-state": O.state === "closing" ? "closing" : "open",
|
|
205
|
+
id: V,
|
|
206
|
+
role: t ? M : void 0,
|
|
207
|
+
style: d ? {
|
|
208
|
+
...$,
|
|
209
|
+
"--nk-popover-arrow-offset": `${d.arrowOffset}px`,
|
|
210
|
+
left: d.left,
|
|
211
|
+
top: d.top,
|
|
212
|
+
zIndex: D.zIndex
|
|
213
|
+
} : {
|
|
214
|
+
...$,
|
|
215
|
+
visibility: "hidden",
|
|
216
|
+
zIndex: D.zIndex
|
|
217
|
+
},
|
|
218
|
+
tabIndex: de ?? -1,
|
|
219
|
+
children: [
|
|
220
|
+
/* @__PURE__ */ T(
|
|
221
|
+
Je,
|
|
222
|
+
{
|
|
223
|
+
inert: !t,
|
|
224
|
+
panelElement: u
|
|
225
|
+
}
|
|
226
|
+
),
|
|
227
|
+
/* @__PURE__ */ T("span", { "aria-hidden": "true", className: "nk-popover__arrow" }),
|
|
228
|
+
/* @__PURE__ */ T("div", { className: "nk-popover__content", children: se })
|
|
229
|
+
]
|
|
230
|
+
}
|
|
231
|
+
) }) : null
|
|
232
|
+
}
|
|
233
|
+
)
|
|
234
|
+
] });
|
|
235
|
+
});
|
|
236
|
+
export {
|
|
237
|
+
ct as default
|
|
238
|
+
};
|