neatkit 0.8.0 → 0.10.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/Boundary.cjs +1 -1
- package/dist/Boundary.js +29 -29
- package/dist/Button-CVe9T_Zw.cjs +1 -0
- package/dist/Button-D6rXvcqq.js +101 -0
- package/dist/Button.cjs +1 -1
- package/dist/Button.js +1 -1
- package/dist/Checkbox.cjs +1 -1
- package/dist/Checkbox.js +111 -110
- package/dist/{Code-JDb4VFl7.cjs → Code-B7s_rN0G.cjs} +1 -1
- package/dist/{Code-ClkozPlv.js → Code-Bp2X1k-g.js} +1 -4
- package/dist/Code.cjs +1 -1
- package/dist/Code.js +1 -1
- package/dist/Divider-C7XGlr26.cjs +1 -0
- package/dist/{Divider-BE15WVDI.js → Divider-DZgpYpr-.js} +1 -1
- package/dist/Divider.cjs +1 -1
- package/dist/Divider.js +1 -1
- package/dist/Icon-BIBzgznI.cjs +1 -0
- package/dist/{Icon-BoEUoOk7.js → Icon-CxK1wlGk.js} +98 -52
- package/dist/Icon.cjs +1 -1
- package/dist/Icon.js +1 -1
- package/dist/Input.cjs +1 -1
- package/dist/Input.js +52 -51
- package/dist/Markdown.cjs +1 -1
- package/dist/Markdown.js +108 -104
- package/dist/Modal.cjs +1 -1
- package/dist/Modal.js +57 -56
- package/dist/PinInput.cjs +1 -1
- package/dist/PinInput.js +88 -87
- package/dist/Popover.cjs +1 -1
- package/dist/Popover.js +147 -141
- package/dist/Progress.cjs +1 -0
- package/dist/Progress.js +40 -0
- package/dist/Radio.cjs +1 -1
- package/dist/Radio.js +48 -47
- package/dist/Select.cjs +1 -1
- package/dist/Select.js +363 -359
- package/dist/Sidebar.cjs +1 -1
- package/dist/Sidebar.js +326 -311
- package/dist/Spinner-BE0F4y2S.cjs +1 -0
- package/dist/Spinner-CmxlDlOk.js +23 -0
- package/dist/Spinner.cjs +1 -1
- package/dist/Spinner.js +1 -1
- package/dist/Table-BqWBgMTU.cjs +1 -0
- package/dist/Table-DutHfiXR.js +423 -0
- package/dist/Table.cjs +1 -1
- package/dist/Table.js +1 -1
- package/dist/{Tooltip-B4bajPtk.cjs → Tooltip-CCuE-hfp.cjs} +1 -1
- package/dist/{Tooltip-BVqdnKK_.js → Tooltip-CeyRKNv4.js} +1 -1
- package/dist/Tooltip.cjs +1 -1
- package/dist/Tooltip.js +1 -1
- package/dist/albert-sans-cb3e34c4.woff2 +0 -0
- package/dist/components/Icon/icons/GearIcon.d.ts +11 -0
- package/dist/components/Icon/icons/ImageIcon.d.ts +11 -0
- package/dist/components/Icon/utils/registry.d.ts +2 -0
- package/dist/components/Portal/hooks/useAnchoredPosition.d.ts +59 -0
- package/dist/components/Progress/Progress.d.ts +38 -0
- package/dist/components/Progress/index.d.ts +2 -0
- package/dist/components/Progress/utils/value.d.ts +25 -0
- package/dist/components/Select/Select.d.ts +6 -74
- package/dist/components/Select/components/CustomSelect.d.ts +59 -0
- package/dist/components/Select/components/NativeSelect.d.ts +26 -0
- package/dist/components/Select/components/SelectListbox.d.ts +50 -0
- package/dist/components/Select/hooks/useSelectFormReset.d.ts +27 -0
- package/dist/components/Select/hooks/useSelectPosition.d.ts +12 -0
- package/dist/components/Select/hooks/useTypeahead.d.ts +14 -0
- package/dist/components/Select/utils/options.d.ts +38 -0
- package/dist/components/Sidebar/Sidebar.d.ts +36 -25
- package/dist/components/Sidebar/components/SidebarFooter.d.ts +5 -0
- package/dist/components/Sidebar/components/SidebarGroup.d.ts +5 -16
- package/dist/components/Sidebar/components/SidebarHeader.d.ts +29 -0
- package/dist/components/Sidebar/components/SidebarItem.d.ts +3 -0
- package/dist/components/Sidebar/components/SidebarOverlay.d.ts +3 -4
- package/dist/components/Sidebar/components/SidebarPanel.d.ts +4 -4
- package/dist/components/Sidebar/hooks/usePresentation.d.ts +2 -2
- package/dist/components/Sidebar/index.d.ts +1 -1
- package/dist/components/Sidebar/utils/presentation.d.ts +12 -0
- package/dist/components/Sidebar/utils/state.d.ts +2 -2
- package/dist/components/Table/Table.d.ts +21 -209
- package/dist/components/Table/components/TableAction.d.ts +18 -0
- package/dist/components/Table/components/TableActionCell.d.ts +15 -0
- package/dist/components/Table/components/TableActionHeaderCell.d.ts +13 -0
- package/dist/components/Table/components/TableBody.d.ts +27 -0
- package/dist/components/Table/components/TableCell.d.ts +42 -0
- package/dist/components/Table/components/TableFoot.d.ts +19 -0
- package/dist/components/Table/components/TableHead.d.ts +19 -0
- package/dist/components/Table/components/TableHeaderCell.d.ts +23 -0
- package/dist/components/Table/components/TableRow.d.ts +67 -0
- package/dist/components/Table/hooks/useHorizontalOverflow.d.ts +25 -0
- package/dist/components/Table/utils/cell.d.ts +25 -0
- package/dist/components/Table/utils/children.d.ts +18 -0
- package/dist/components/Table/utils/trigger.d.ts +54 -0
- package/dist/style.css +1 -1
- package/dist/useAnchoredPosition-C0VS7hm6.js +105 -0
- package/dist/useAnchoredPosition-D7GRFzoX.cjs +1 -0
- package/dist/useFloatingPosition-Dq8xpr3E.js +27 -0
- package/dist/useFloatingPosition-g5kXywoB.cjs +1 -0
- package/dist/useFocusTrap-C0IcCdNf.js +136 -0
- package/dist/useFocusTrap-gAK_402D.cjs +1 -0
- package/package.json +7 -1
- package/dist/Button-Chv4O66e.js +0 -99
- package/dist/Button-DCKtFvSo.cjs +0 -1
- package/dist/Divider-CJYbFcSX.cjs +0 -1
- package/dist/Icon-DJ4BigRz.cjs +0 -1
- package/dist/Spinner-BXgw60UC.cjs +0 -1
- package/dist/Spinner-CVYvk6YK.js +0 -25
- package/dist/Table-B30TBckZ.js +0 -402
- package/dist/Table-DceR12X9.cjs +0 -1
- package/dist/floating-position-5wJ5G5IT.js +0 -48
- package/dist/floating-position-Cy9xxdH4.cjs +0 -1
- package/dist/useFloatingPosition-BBEUHPqy.cjs +0 -1
- package/dist/useFloatingPosition-CMirP2-2.js +0 -43
- package/dist/useFocusTrap-BrFZdMqQ.cjs +0 -1
- package/dist/useFocusTrap-DhVnlboe.js +0 -136
package/dist/Modal.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
2
|
+
import { jsx as s, jsxs as _ } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef as H, useRef as g, useContext as J, useId as K, useState as Q, useMemo as U, useCallback as h } from "react";
|
|
4
4
|
import { u as V } from "./effects-D5CWf-Pl.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { u as ae } from "./
|
|
9
|
-
import {
|
|
5
|
+
import { a as W } from "./reference-CXMr27nM.js";
|
|
6
|
+
import { B as X } from "./Button-D6rXvcqq.js";
|
|
7
|
+
import { b as E, c as Y, P as Z, F as w, d as ee, e as oe } from "./usePresence-CqegYqy4.js";
|
|
8
|
+
import { u as ae } from "./useFocusTrap-C0IcCdNf.js";
|
|
9
|
+
import { u as se } from "./useScrollLock-Drd7OZRC.js";
|
|
10
|
+
import { S as ne } from "./Surface-vEFsZC12.js";
|
|
10
11
|
import { T as te } from "./Text-rN6iDo0V.js";
|
|
11
|
-
function
|
|
12
|
-
a.current =
|
|
12
|
+
function re(t, a, r) {
|
|
13
|
+
a.current = t, W(r, t);
|
|
13
14
|
}
|
|
14
|
-
function
|
|
15
|
+
function ie(t) {
|
|
15
16
|
const {
|
|
16
17
|
"aria-label": a,
|
|
17
|
-
"aria-labelledby":
|
|
18
|
-
children:
|
|
18
|
+
"aria-labelledby": r,
|
|
19
|
+
children: n,
|
|
19
20
|
className: b,
|
|
20
21
|
closeButtonLabel: d = "Close modal",
|
|
21
22
|
exitable: i = !0,
|
|
@@ -24,17 +25,17 @@ function re(n) {
|
|
|
24
25
|
lockScroll: u = !0,
|
|
25
26
|
onClose: e,
|
|
26
27
|
open: o,
|
|
27
|
-
ownerDocument:
|
|
28
|
-
presenceState:
|
|
29
|
-
restoreFocus:
|
|
30
|
-
role:
|
|
31
|
-
style:
|
|
28
|
+
ownerDocument: R,
|
|
29
|
+
presenceState: k,
|
|
30
|
+
restoreFocus: F = !0,
|
|
31
|
+
role: P = "dialog",
|
|
32
|
+
style: M,
|
|
32
33
|
title: m,
|
|
33
|
-
trapFocus:
|
|
34
|
-
...
|
|
35
|
-
} =
|
|
36
|
-
(
|
|
37
|
-
|
|
34
|
+
trapFocus: x = !0,
|
|
35
|
+
...N
|
|
36
|
+
} = t, D = g(null), B = g(null), O = J(w), I = `${K()}-title`, [f, T] = Q(null), p = E("Modal").boundaryElement, y = ee(!0, p), j = U(() => [D], []), v = !!(m != null && m.trim()), z = c ?? (v ? B : void 0), A = r ?? (a === void 0 && v ? I : void 0), C = h(
|
|
37
|
+
(S) => {
|
|
38
|
+
re(S, D, l), T(S);
|
|
38
39
|
},
|
|
39
40
|
[l]
|
|
40
41
|
);
|
|
@@ -46,7 +47,7 @@ function re(n) {
|
|
|
46
47
|
}, [e]), q = h(() => {
|
|
47
48
|
e == null || e("outside");
|
|
48
49
|
}, [e]);
|
|
49
|
-
|
|
50
|
+
oe({
|
|
50
51
|
boundary: p,
|
|
51
52
|
active: o,
|
|
52
53
|
boundaries: j,
|
|
@@ -55,19 +56,19 @@ function re(n) {
|
|
|
55
56
|
layerId: y.id,
|
|
56
57
|
onEscapeDismiss: $,
|
|
57
58
|
onPointerDownOutsideDismiss: q,
|
|
58
|
-
ownerDocument:
|
|
59
|
+
ownerDocument: R
|
|
59
60
|
});
|
|
60
|
-
const G =
|
|
61
|
+
const G = ae({
|
|
61
62
|
boundary: p,
|
|
62
|
-
active: o &&
|
|
63
|
+
active: o && x,
|
|
63
64
|
container: f,
|
|
64
65
|
initialFocusReference: z,
|
|
65
66
|
layerId: y.id,
|
|
66
|
-
restoreFocus:
|
|
67
|
+
restoreFocus: F
|
|
67
68
|
});
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
69
|
+
se(u, R, p);
|
|
70
|
+
const L = i ? /* @__PURE__ */ s(
|
|
71
|
+
X,
|
|
71
72
|
{
|
|
72
73
|
"aria-label": d,
|
|
73
74
|
className: "nk-modal__close",
|
|
@@ -78,49 +79,49 @@ function re(n) {
|
|
|
78
79
|
variant: "ghost"
|
|
79
80
|
}
|
|
80
81
|
) : null;
|
|
81
|
-
return /* @__PURE__ */
|
|
82
|
-
|
|
82
|
+
return /* @__PURE__ */ s(
|
|
83
|
+
w.Provider,
|
|
83
84
|
{
|
|
84
|
-
value: o &&
|
|
85
|
-
children: /* @__PURE__ */
|
|
85
|
+
value: o && x ? G : O,
|
|
86
|
+
children: /* @__PURE__ */ s(
|
|
86
87
|
"div",
|
|
87
88
|
{
|
|
88
89
|
className: "nk-modal__overlay",
|
|
89
|
-
"data-state":
|
|
90
|
+
"data-state": k,
|
|
90
91
|
role: "presentation",
|
|
91
92
|
style: { zIndex: y.zIndex },
|
|
92
|
-
children: /* @__PURE__ */
|
|
93
|
-
|
|
93
|
+
children: /* @__PURE__ */ s("div", { className: "nk-modal__viewport", children: /* @__PURE__ */ _(
|
|
94
|
+
ne,
|
|
94
95
|
{
|
|
95
|
-
...
|
|
96
|
+
...N,
|
|
96
97
|
ref: C,
|
|
97
98
|
"aria-hidden": o ? void 0 : !0,
|
|
98
99
|
"aria-label": o ? a : void 0,
|
|
99
100
|
"aria-labelledby": o ? A : void 0,
|
|
100
101
|
"aria-modal": o ? "true" : void 0,
|
|
101
102
|
className: ["nk-modal", b].filter(Boolean).join(" "),
|
|
102
|
-
"data-state":
|
|
103
|
-
role: o ?
|
|
104
|
-
style:
|
|
103
|
+
"data-state": k,
|
|
104
|
+
role: o ? P : void 0,
|
|
105
|
+
style: M,
|
|
105
106
|
tabIndex: -1,
|
|
106
107
|
children: [
|
|
107
|
-
v ? /* @__PURE__ */
|
|
108
|
-
/* @__PURE__ */
|
|
108
|
+
v ? /* @__PURE__ */ _("div", { className: "nk-modal__header", children: [
|
|
109
|
+
/* @__PURE__ */ s(
|
|
109
110
|
te,
|
|
110
111
|
{
|
|
111
112
|
as: "h2",
|
|
112
113
|
className: "nk-modal__title",
|
|
113
|
-
id:
|
|
114
|
-
ref:
|
|
114
|
+
id: I,
|
|
115
|
+
ref: B,
|
|
115
116
|
size: "subtitle",
|
|
116
117
|
tabIndex: -1,
|
|
117
118
|
weight: "semibold",
|
|
118
119
|
children: m
|
|
119
120
|
}
|
|
120
121
|
),
|
|
121
|
-
|
|
122
|
-
] }) :
|
|
123
|
-
|
|
122
|
+
L
|
|
123
|
+
] }) : L,
|
|
124
|
+
n
|
|
124
125
|
]
|
|
125
126
|
}
|
|
126
127
|
) })
|
|
@@ -129,21 +130,21 @@ function re(n) {
|
|
|
129
130
|
}
|
|
130
131
|
);
|
|
131
132
|
}
|
|
132
|
-
const
|
|
133
|
-
const { open:
|
|
134
|
-
|
|
135
|
-
const i =
|
|
136
|
-
return !l.present || !u ? null : /* @__PURE__ */
|
|
137
|
-
|
|
133
|
+
const he = H(function(a, r) {
|
|
134
|
+
const { open: n } = a, b = E("Modal"), d = g(a);
|
|
135
|
+
n && (d.current = a);
|
|
136
|
+
const i = n ? a : d.current, l = Y(n), c = b.boundaryElement, u = (c == null ? void 0 : c.ownerDocument) ?? (typeof document > "u" ? null : document);
|
|
137
|
+
return !l.present || !u ? null : /* @__PURE__ */ s(Z, { children: /* @__PURE__ */ s(
|
|
138
|
+
ie,
|
|
138
139
|
{
|
|
139
140
|
...i,
|
|
140
|
-
forwardedReference:
|
|
141
|
-
open:
|
|
141
|
+
forwardedReference: r,
|
|
142
|
+
open: n,
|
|
142
143
|
ownerDocument: u,
|
|
143
144
|
presenceState: l.state === "closing" ? "closing" : "open"
|
|
144
145
|
}
|
|
145
146
|
) });
|
|
146
147
|
});
|
|
147
148
|
export {
|
|
148
|
-
|
|
149
|
+
he as default
|
|
149
150
|
};
|
package/dist/PinInput.cjs
CHANGED
|
@@ -1 +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-Bntn6ad_.cjs"),$=
|
|
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-Bntn6ad_.cjs"),$=require("./reference-C2guRuR0.cjs"),B=3,X=10,H=4;function Z(r){return Number.isFinite(r)?Math.min(X,Math.max(B,Math.trunc(r))):H}function M(r,s,o){return(s==="numeric"?r.replace(/[^0-9]/g,""):r.replace(/[^0-9a-z]/gi,"").toUpperCase()).slice(0,o)}function J(r,s,o){s.current=r,$.assignElementReference(o,r)}function Q(r,s){var c;const o=(c=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(r),"value"))==null?void 0:c.set;o?o.call(r,s):r.value=s}function U(r,s,o){const c=Math.min(o-1,Math.max(0,s)),P=Math.min(c+1,r.value.length);r.focus(),r.setSelectionRange(c,P)}function W(r){const{defaultValue:s,disabled:o,forwardedReference:c,length:P,mode:u,onChange:_,onComplete:N,onFocus:w,onKeyDown:p,onPaste:x,onSelect:y,readOnly:S,value:V}=r,n=Z(P),R=M(s,u,n),b=v.useRef(null),[k,D]=v.useState(R),[E,d]=v.useState(0),f=V!==void 0,i=M(f?V:k,u,n),C=v.useCallback(t=>J(t,b,c),[c]);v.useEffect(()=>{!f&&k!==i&&D(i)},[f,i,k]),v.useEffect(()=>{var l;if(f)return;const t=(l=b.current)==null?void 0:l.form;if(!t)return;const e=t.getRootNode();function a(h){h.target!==t||h.defaultPrevented||(D(R),d(0))}return e.addEventListener("reset",a),()=>e.removeEventListener("reset",a)},[f,R]);function L(t){const e=t.selectionStart??i.length;return Math.min(n-1,Math.max(0,e))}function T(t){const e=t.currentTarget,a=e.selectionStart??e.value.length,l=M(e.value,u,n),h=M(e.value.slice(0,a),u,n).length;e.value=l,f||D(l),_==null||_(t),l.length===n&&l!==i&&(N==null||N(l));const g=Math.min(n-1,h);d(g),e.setSelectionRange(g,Math.min(g+1,l.length))}function A(t){if(x==null||x(t),t.defaultPrevented||o||S)return;const e=M(t.clipboardData.getData("text"),u,n);if(t.preventDefault(),e.length===0)return;const a=t.currentTarget,l=a.selectionStart??i.length,h=a.selectionEnd??l,g=e.length===n?e:M(i.slice(0,l)+e+i.slice(h),u,n),j=e.length===n?n:Math.min(n,l+e.length);Q(a,g),a.setSelectionRange(j,j),a.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,a=Math.min(n-1,Math.max(0,L(t.currentTarget)+e));d(a),U(t.currentTarget,a,n)}function O(t){w==null||w(t);const e=Math.min(n-1,i.length);d(e),U(t.currentTarget,e,n)}function q(t){y==null||y(t),d(L(t.currentTarget))}function F(t,e){if(t.preventDefault(),o)return;const a=b.current;a&&(d(e),U(a,e,n))}return{activeIndex:E,handleChange:T,handleFocus:O,handleKeyDown:z,handlePaste:A,handleSelect:q,handleSlotPointerDown:F,inputCallbackReference:C,length:n,renderedValue:i}}const Y=v.forwardRef(function(s,o){const{"aria-invalid":c,autoCapitalize:P,autoComplete:u="one-time-code",className:_,censored:N=!1,defaultValue:w="",disabled:p=!1,invalid:x=!1,length:y=H,mode:S="numeric",onChange:V,onComplete:n,onFocus:R,onKeyDown:b,onPaste:k,onSelect:D,readOnly:E=!1,style:d,value:f,wrap:i=!1,...C}=s,{activeIndex:L,handleChange:T,handleFocus:A,handleKeyDown:z,handlePaste:O,handleSelect:q,handleSlotPointerDown:F,inputCallbackReference:t,length:e,renderedValue:a}=W({defaultValue:w,disabled:p,forwardedReference:o,length:y,mode:S,onChange:V,onComplete:n,onFocus:R,onKeyDown:b,onPaste:k,onSelect:D,readOnly:E,value:f}),l=x||G.hasInvalidState(c),h=!i&&e>=6&&e%2===0,g=e/2,j={...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":l||void 0,"data-read-only":E||void 0,"data-wrap":i||void 0,style:j,children:[m.jsx("input",{...C,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:q,pattern:S==="numeric"?`[0-9]{${e}}`:`[0-9A-Za-z]{${e}}`,readOnly:E,spellCheck:!1,type:"text",value:a}),m.jsx("span",{"aria-hidden":"true",className:"nk-pin-input__slots",children:Array.from({length:e},(ee,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":L===I||void 0,onPointerDown:K=>F(K,I),children:N&&a[I]?m.jsx("span",{className:"nk-pin-input__censor"}):a[I]??""})]},I))})]})});exports.default=Y;
|
package/dist/PinInput.js
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as G, jsx as
|
|
2
|
+
import { jsxs as G, jsx as V } from "react/jsx-runtime";
|
|
3
3
|
import { useRef as B, useState as H, useCallback as X, useEffect as K, forwardRef as Z } from "react";
|
|
4
4
|
import { r as J, h as Q } from "./aria-CeA9QfD1.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
import { a as W } from "./reference-CXMr27nM.js";
|
|
6
|
+
const Y = 3, ee = 10, q = 4;
|
|
7
|
+
function te(r) {
|
|
8
|
+
return Number.isFinite(r) ? Math.min(
|
|
9
|
+
ee,
|
|
10
|
+
Math.max(Y, Math.trunc(r))
|
|
10
11
|
) : q;
|
|
11
12
|
}
|
|
12
|
-
function S(
|
|
13
|
-
return (s === "numeric" ?
|
|
13
|
+
function S(r, s, l) {
|
|
14
|
+
return (s === "numeric" ? r.replace(/[^0-9]/g, "") : r.replace(/[^0-9a-z]/gi, "").toUpperCase()).slice(0, l);
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
-
s.current =
|
|
16
|
+
function ne(r, s, l) {
|
|
17
|
+
s.current = r, W(l, r);
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
+
function ae(r, s) {
|
|
19
20
|
var c;
|
|
20
|
-
const
|
|
21
|
-
Object.getPrototypeOf(
|
|
21
|
+
const l = (c = Object.getOwnPropertyDescriptor(
|
|
22
|
+
Object.getPrototypeOf(r),
|
|
22
23
|
"value"
|
|
23
24
|
)) == null ? void 0 : c.set;
|
|
24
|
-
|
|
25
|
+
l ? l.call(r, s) : r.value = s;
|
|
25
26
|
}
|
|
26
|
-
function U(
|
|
27
|
-
const c = Math.min(
|
|
28
|
-
|
|
27
|
+
function U(r, s, l) {
|
|
28
|
+
const c = Math.min(l - 1, Math.max(0, s)), x = Math.min(c + 1, r.value.length);
|
|
29
|
+
r.focus(), r.setSelectionRange(c, x);
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
+
function re(r) {
|
|
31
32
|
const {
|
|
32
33
|
defaultValue: s,
|
|
33
|
-
disabled:
|
|
34
|
+
disabled: l,
|
|
34
35
|
forwardedReference: c,
|
|
35
36
|
length: x,
|
|
36
37
|
mode: u,
|
|
@@ -41,78 +42,78 @@ function ae(a) {
|
|
|
41
42
|
onPaste: g,
|
|
42
43
|
onSelect: N,
|
|
43
44
|
readOnly: v,
|
|
44
|
-
value:
|
|
45
|
-
} =
|
|
45
|
+
value: b
|
|
46
|
+
} = r, n = te(x), w = S(
|
|
46
47
|
s,
|
|
47
48
|
u,
|
|
48
49
|
n
|
|
49
|
-
),
|
|
50
|
-
|
|
51
|
-
), [
|
|
52
|
-
f ?
|
|
50
|
+
), y = B(null), [k, R] = H(
|
|
51
|
+
w
|
|
52
|
+
), [D, d] = H(0), f = b !== void 0, i = S(
|
|
53
|
+
f ? b : k,
|
|
53
54
|
u,
|
|
54
55
|
n
|
|
55
|
-
),
|
|
56
|
-
(t) =>
|
|
56
|
+
), C = X(
|
|
57
|
+
(t) => ne(
|
|
57
58
|
t,
|
|
58
|
-
|
|
59
|
+
y,
|
|
59
60
|
c
|
|
60
61
|
),
|
|
61
62
|
[c]
|
|
62
63
|
);
|
|
63
64
|
K(() => {
|
|
64
|
-
!f &&
|
|
65
|
-
}, [f, i,
|
|
66
|
-
var
|
|
65
|
+
!f && k !== i && R(i);
|
|
66
|
+
}, [f, i, k]), K(() => {
|
|
67
|
+
var o;
|
|
67
68
|
if (f) return;
|
|
68
|
-
const t = (
|
|
69
|
+
const t = (o = y.current) == null ? void 0 : o.form;
|
|
69
70
|
if (!t) return;
|
|
70
71
|
const e = t.getRootNode();
|
|
71
|
-
function
|
|
72
|
-
h.target !== t || h.defaultPrevented || (
|
|
72
|
+
function a(h) {
|
|
73
|
+
h.target !== t || h.defaultPrevented || (R(w), d(0));
|
|
73
74
|
}
|
|
74
|
-
return e.addEventListener("reset",
|
|
75
|
-
}, [f,
|
|
76
|
-
function
|
|
75
|
+
return e.addEventListener("reset", a), () => e.removeEventListener("reset", a);
|
|
76
|
+
}, [f, w]);
|
|
77
|
+
function E(t) {
|
|
77
78
|
const e = t.selectionStart ?? i.length;
|
|
78
79
|
return Math.min(n - 1, Math.max(0, e));
|
|
79
80
|
}
|
|
80
81
|
function T(t) {
|
|
81
|
-
const e = t.currentTarget,
|
|
82
|
-
e.value.slice(0,
|
|
82
|
+
const e = t.currentTarget, a = e.selectionStart ?? e.value.length, o = S(e.value, u, n), h = S(
|
|
83
|
+
e.value.slice(0, a),
|
|
83
84
|
u,
|
|
84
85
|
n
|
|
85
86
|
).length;
|
|
86
|
-
e.value =
|
|
87
|
+
e.value = o, f || R(o), M == null || M(t), o.length === n && o !== i && (P == null || P(o));
|
|
87
88
|
const m = Math.min(n - 1, h);
|
|
88
89
|
d(m), e.setSelectionRange(
|
|
89
90
|
m,
|
|
90
|
-
Math.min(m + 1,
|
|
91
|
+
Math.min(m + 1, o.length)
|
|
91
92
|
);
|
|
92
93
|
}
|
|
93
94
|
function A(t) {
|
|
94
|
-
if (g == null || g(t), t.defaultPrevented ||
|
|
95
|
+
if (g == null || g(t), t.defaultPrevented || l || v) return;
|
|
95
96
|
const e = S(
|
|
96
97
|
t.clipboardData.getData("text"),
|
|
97
98
|
u,
|
|
98
99
|
n
|
|
99
100
|
);
|
|
100
101
|
if (t.preventDefault(), e.length === 0) return;
|
|
101
|
-
const
|
|
102
|
-
i.slice(0,
|
|
102
|
+
const a = t.currentTarget, o = a.selectionStart ?? i.length, h = a.selectionEnd ?? o, m = e.length === n ? e : S(
|
|
103
|
+
i.slice(0, o) + e + i.slice(h),
|
|
103
104
|
u,
|
|
104
105
|
n
|
|
105
|
-
),
|
|
106
|
-
|
|
106
|
+
), L = e.length === n ? n : Math.min(n, o + e.length);
|
|
107
|
+
ae(a, m), a.setSelectionRange(L, L), a.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
107
108
|
}
|
|
108
109
|
function z(t) {
|
|
109
110
|
if (p == null || p(t), t.defaultPrevented || t.key !== "ArrowLeft" && t.key !== "ArrowRight") return;
|
|
110
111
|
t.preventDefault();
|
|
111
|
-
const e = t.key === "ArrowLeft" ? -1 : 1,
|
|
112
|
+
const e = t.key === "ArrowLeft" ? -1 : 1, a = Math.min(
|
|
112
113
|
n - 1,
|
|
113
|
-
Math.max(0,
|
|
114
|
+
Math.max(0, E(t.currentTarget) + e)
|
|
114
115
|
);
|
|
115
|
-
d(
|
|
116
|
+
d(a), U(t.currentTarget, a, n);
|
|
116
117
|
}
|
|
117
118
|
function F(t) {
|
|
118
119
|
_ == null || _(t);
|
|
@@ -120,27 +121,27 @@ function ae(a) {
|
|
|
120
121
|
d(e), U(t.currentTarget, e, n);
|
|
121
122
|
}
|
|
122
123
|
function O(t) {
|
|
123
|
-
N == null || N(t), d(
|
|
124
|
+
N == null || N(t), d(E(t.currentTarget));
|
|
124
125
|
}
|
|
125
126
|
function j(t, e) {
|
|
126
|
-
if (t.preventDefault(),
|
|
127
|
-
const
|
|
128
|
-
|
|
127
|
+
if (t.preventDefault(), l) return;
|
|
128
|
+
const a = y.current;
|
|
129
|
+
a && (d(e), U(a, e, n));
|
|
129
130
|
}
|
|
130
131
|
return {
|
|
131
|
-
activeIndex:
|
|
132
|
+
activeIndex: D,
|
|
132
133
|
handleChange: T,
|
|
133
134
|
handleFocus: F,
|
|
134
135
|
handleKeyDown: z,
|
|
135
136
|
handlePaste: A,
|
|
136
137
|
handleSelect: O,
|
|
137
138
|
handleSlotPointerDown: j,
|
|
138
|
-
inputCallbackReference:
|
|
139
|
+
inputCallbackReference: C,
|
|
139
140
|
length: n,
|
|
140
141
|
renderedValue: i
|
|
141
142
|
};
|
|
142
143
|
}
|
|
143
|
-
const
|
|
144
|
+
const ue = Z(function(s, l) {
|
|
144
145
|
const {
|
|
145
146
|
"aria-invalid": c,
|
|
146
147
|
autoCapitalize: x,
|
|
@@ -152,19 +153,19 @@ const se = Z(function(s, r) {
|
|
|
152
153
|
invalid: g = !1,
|
|
153
154
|
length: N = q,
|
|
154
155
|
mode: v = "numeric",
|
|
155
|
-
onChange:
|
|
156
|
+
onChange: b,
|
|
156
157
|
onComplete: n,
|
|
157
|
-
onFocus:
|
|
158
|
-
onKeyDown:
|
|
159
|
-
onPaste:
|
|
160
|
-
onSelect:
|
|
161
|
-
readOnly:
|
|
158
|
+
onFocus: w,
|
|
159
|
+
onKeyDown: y,
|
|
160
|
+
onPaste: k,
|
|
161
|
+
onSelect: R,
|
|
162
|
+
readOnly: D = !1,
|
|
162
163
|
style: d,
|
|
163
164
|
value: f,
|
|
164
165
|
wrap: i = !1,
|
|
165
|
-
...
|
|
166
|
+
...C
|
|
166
167
|
} = s, {
|
|
167
|
-
activeIndex:
|
|
168
|
+
activeIndex: E,
|
|
168
169
|
handleChange: T,
|
|
169
170
|
handleFocus: A,
|
|
170
171
|
handleKeyDown: z,
|
|
@@ -173,22 +174,22 @@ const se = Z(function(s, r) {
|
|
|
173
174
|
handleSlotPointerDown: j,
|
|
174
175
|
inputCallbackReference: t,
|
|
175
176
|
length: e,
|
|
176
|
-
renderedValue:
|
|
177
|
-
} =
|
|
177
|
+
renderedValue: a
|
|
178
|
+
} = re({
|
|
178
179
|
defaultValue: _,
|
|
179
180
|
disabled: p,
|
|
180
|
-
forwardedReference:
|
|
181
|
+
forwardedReference: l,
|
|
181
182
|
length: N,
|
|
182
183
|
mode: v,
|
|
183
|
-
onChange:
|
|
184
|
+
onChange: b,
|
|
184
185
|
onComplete: n,
|
|
185
|
-
onFocus:
|
|
186
|
-
onKeyDown:
|
|
187
|
-
onPaste:
|
|
188
|
-
onSelect:
|
|
189
|
-
readOnly:
|
|
186
|
+
onFocus: w,
|
|
187
|
+
onKeyDown: y,
|
|
188
|
+
onPaste: k,
|
|
189
|
+
onSelect: R,
|
|
190
|
+
readOnly: D,
|
|
190
191
|
value: f
|
|
191
|
-
}),
|
|
192
|
+
}), o = g || Q(c), h = !i && e >= 6 && e % 2 === 0, m = e / 2, L = {
|
|
192
193
|
...d,
|
|
193
194
|
"--nk-pin-input-columns": Math.ceil(e / 2)
|
|
194
195
|
};
|
|
@@ -197,15 +198,15 @@ const se = Z(function(s, r) {
|
|
|
197
198
|
{
|
|
198
199
|
className: ["nk-pin-input", M].filter(Boolean).join(" "),
|
|
199
200
|
"data-disabled": p || void 0,
|
|
200
|
-
"data-invalid":
|
|
201
|
-
"data-read-only":
|
|
201
|
+
"data-invalid": o || void 0,
|
|
202
|
+
"data-read-only": D || void 0,
|
|
202
203
|
"data-wrap": i || void 0,
|
|
203
|
-
style:
|
|
204
|
+
style: L,
|
|
204
205
|
children: [
|
|
205
|
-
/* @__PURE__ */
|
|
206
|
+
/* @__PURE__ */ V(
|
|
206
207
|
"input",
|
|
207
208
|
{
|
|
208
|
-
...
|
|
209
|
+
...C,
|
|
209
210
|
ref: t,
|
|
210
211
|
"aria-invalid": J(g, c),
|
|
211
212
|
autoCapitalize: x ?? (v === "alphanumeric" ? "characters" : "off"),
|
|
@@ -221,21 +222,21 @@ const se = Z(function(s, r) {
|
|
|
221
222
|
onPaste: F,
|
|
222
223
|
onSelect: O,
|
|
223
224
|
pattern: v === "numeric" ? `[0-9]{${e}}` : `[0-9A-Za-z]{${e}}`,
|
|
224
|
-
readOnly:
|
|
225
|
+
readOnly: D,
|
|
225
226
|
spellCheck: !1,
|
|
226
227
|
type: "text",
|
|
227
|
-
value:
|
|
228
|
+
value: a
|
|
228
229
|
}
|
|
229
230
|
),
|
|
230
|
-
/* @__PURE__ */
|
|
231
|
-
h && I === m ? /* @__PURE__ */
|
|
232
|
-
/* @__PURE__ */
|
|
231
|
+
/* @__PURE__ */ V("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: [
|
|
232
|
+
h && I === m ? /* @__PURE__ */ V("span", { className: "nk-pin-input__separator", children: "-" }) : null,
|
|
233
|
+
/* @__PURE__ */ V(
|
|
233
234
|
"span",
|
|
234
235
|
{
|
|
235
236
|
className: "nk-pin-input__slot",
|
|
236
|
-
"data-active":
|
|
237
|
+
"data-active": E === I || void 0,
|
|
237
238
|
onPointerDown: ($) => j($, I),
|
|
238
|
-
children: P &&
|
|
239
|
+
children: P && a[I] ? /* @__PURE__ */ V("span", { className: "nk-pin-input__censor" }) : a[I] ?? ""
|
|
239
240
|
}
|
|
240
241
|
)
|
|
241
242
|
] }, I)) })
|
|
@@ -244,5 +245,5 @@ const se = Z(function(s, r) {
|
|
|
244
245
|
);
|
|
245
246
|
});
|
|
246
247
|
export {
|
|
247
|
-
|
|
248
|
+
ue as default
|
|
248
249
|
};
|
package/dist/Popover.cjs
CHANGED
|
@@ -1 +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"),
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react/jsx-runtime"),t=require("react"),Oe=require("./aria-Bntn6ad_.cjs"),qe=require("./effects-D85L_7zM.cjs"),M=require("./reference-C2guRuR0.cjs"),b=require("./usePresence-B5RYv4e1.cjs"),we=require("./useFloatingPosition-g5kXywoB.cjs"),De=require("./useFocusTrap-gAK_402D.cjs"),Fe=require("./Surface-BttJYSDt.cjs");function je(o){const{inert:i,panelElement:c}=o;return qe.useIsomorphicLayoutEffect(()=>{c&&(c.inert=i)},[i,c]),null}function Le(o,i,c){i.current=o,M.assignElementReference(c,o)}function Ne(o,i,c){i.current=o,M.assignElementReference(c,o)}function _e(o){const i=o.tagName.toLowerCase();return o.getAttribute("role")==="button"&&i!=="button"?!1:["button","input","select","summary","textarea"].includes(i)?!0:i==="a"&&o.hasAttribute("href")}function Be(o){return o==="grid"||o==="listbox"||o==="menu"||o==="tree"?o:"dialog"}const Me=t.forwardRef(function(i,c){const{"aria-label":K,"aria-labelledby":re,autoFocus:D=!0,children:ne,className:se,closeOnEscape:oe=!0,closeOnOutsideInteraction:ae=!0,defaultOpen:ie=!1,disabled:x=!1,initialFocusReference:E,onEscapeKeyDown:ce,onOpenChange:k,onPointerDownOutside:I,open:z,placement:A="bottom",restoreFocus:F=!0,role:H="dialog",style:V,tabIndex:ue,trapFocus:v=!1,trigger:d,...le}=i;if(d.type===t.Fragment)throw new Error("Popover requires a single non-Fragment trigger");const $=t.useId(),de=t.useContext(b.FocusScopeContext),U=`${$}-popover`,s=d.props,G=M.getElementReference(d),J=s.id??`${$}-trigger`,P=x||s.disabled===!0||s["aria-disabled"]===!0||s["aria-disabled"]==="true",R=z!==void 0,[fe,pe]=t.useState(ie),r=R?z:fe,C=b.usePresence(r),Q=t.useRef(null),W=t.useRef(null),j=t.useRef("programmatic"),L=t.useRef(null),X=t.useRef(r),T=t.useRef(null),[ge,me]=t.useReducer(e=>e+1,0),[u,be]=t.useState(null),[f,ve]=t.useState(null),a=(u==null?void 0:u.ownerDocument)??(typeof document>"u"?null:document),S=b.useBoundary("Popover").boundaryElement,O=b.useOverlayLayer(C.present,S),ye=t.useMemo(()=>[Q,W],[]),p=we.useFloatingPosition(C.present,A,u,f,S),he=t.useCallback(e=>{Ne(e,Q,G),be(e)},[G]),Ee=t.useCallback(e=>{Le(e,W,c),ve(e)},[c]),g=t.useCallback((e,n)=>{r!==e&&(R?(L.current={open:e,reason:n},me()):(j.current=n,pe(e)),k==null||k(e,n))},[R,k,r]),Pe=t.useCallback(()=>{g(!1,"escape")},[g]),Re=t.useCallback(()=>{g(!1,"outside")},[g]),Te=t.useCallback(e=>{var m;if(I==null||I(e),e.defaultPrevented)return;const n=(m=a==null?void 0:a.defaultView)==null?void 0:m.HTMLElement;n?T.current=e.composedPath().find(h=>h instanceof n&&h.tabIndex>=0)??e.target:T.current=e.target},[I,a]);b.useDismissableLayer({boundary:S,active:r,boundaries:ye,dismissOnEscape:oe,dismissOnPointerDownOutside:ae,layerId:O.id,onEscapeDismiss:Pe,onEscapeKeyDown:ce,onPointerDownOutside:Te,onPointerDownOutsideDismiss:Re,ownerDocument:a});const xe=De.useFocusTrap({boundary:S,active:r&&v,autoFocus:D,container:f,initialFocusReference:E,layerId:O.id,restoreFocus:F});t.useEffect(()=>{if(!r||v||!D||!f)return;let e=!0;return Promise.resolve().then(()=>{if(!e)return;const n=E==null?void 0:E.current;(n&&f.contains(n)?n:f).focus({preventScroll:!0})}),()=>{e=!1}},[D,E,r,f,v]),t.useEffect(()=>{var te;const e=X.current;X.current=r;const n=L.current;let m=j.current;if(R&&(m="programmatic",e!==r&&(n==null?void 0:n.open)===r&&(m=n.reason)),L.current=null,r){j.current="programmatic",T.current=null;return}const h=a==null?void 0:a.activeElement,_=T.current,B=(te=a==null?void 0:a.defaultView)==null?void 0:te.HTMLElement,Se=m==="outside"&&B&&_ instanceof B&&h instanceof B&&(_===h||_.contains(h));e&&!v&&F&&!Se&&(u==null||u.focus({preventScroll:!0})),T.current=null},[ge,R,r,a,F,v,u]),t.useEffect(()=>{x&&r&&g(!1,"programmatic")},[x,r,g]);function ke(e){var n;if(P){e.preventDefault(),e.stopPropagation();return}(n=s.onClick)==null||n.call(s,e),!e.defaultPrevented&&g(!r,"trigger")}function Ie(e){var n;(n=s.onKeyDown)==null||n.call(s,e),!(e.defaultPrevented||P||_e(e.currentTarget)||e.key!=="Enter"&&e.key!==" ")&&(e.preventDefault(),e.currentTarget.click())}if(x)return d;const N=typeof d.type=="string",y=N?d.type:null,Y=y==="a"&&typeof s.href=="string",Z=N&&!(y==="button"||y==="input"||y==="select"||y==="summary"||y==="textarea"||Y),ee=Y&&P;let q=s.role;q===void 0&&(ee?q="link":Z&&(q="button"));let w=s.tabIndex;w===void 0&&Z&&(w=0),P&&(w=-1);const Ce=t.cloneElement(d,{"aria-controls":r?Oe.mergeIdentifiers(s["aria-controls"],U):s["aria-controls"],"aria-expanded":r,"aria-haspopup":s["aria-haspopup"]??Be(H),"aria-disabled":P?!0:s["aria-disabled"],className:[s.className,"nk-popover__trigger"].filter(Boolean).join(" "),href:ee?void 0:s.href,id:J,onClick:ke,onKeyDown:N?Ie:s.onKeyDown,ref:he,role:q,tabIndex:w});return l.jsxs(l.Fragment,{children:[Ce,l.jsx(b.FocusScopeContext.Provider,{value:r&&v?xe:de,children:C.present&&a?l.jsx(b.Portal,{children:l.jsxs(Fe.Surface,{...le,ref:Ee,"aria-hidden":r?void 0:!0,"aria-label":r?K:void 0,"aria-labelledby":r?re??(K===void 0?J:void 0):void 0,className:["nk-popover",se].filter(Boolean).join(" "),"data-placement":(p==null?void 0:p.placement)??A,"data-state":C.state==="closing"?"closing":"open",id:U,role:r?H:void 0,style:p?{...V,"--nk-popover-arrow-offset":`${p.arrowOffset}px`,left:p.left,top:p.top,zIndex:O.zIndex}:{...V,visibility:"hidden",zIndex:O.zIndex},tabIndex:ue??-1,children:[l.jsx(je,{inert:!r,panelElement:f}),l.jsx("span",{"aria-hidden":"true",className:"nk-popover__arrow"}),l.jsx("div",{className:"nk-popover__content",children:ne})]})}):null})]})});exports.default=Me;
|