neatkit 0.16.5 → 0.16.7
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/{Button-ZzJbnjNg.js → Button-Dsr1zrKT.js} +1 -1
- package/dist/{Button-CYFy6sTv.cjs → Button-DyO8fkk1.cjs} +1 -1
- package/dist/Button.cjs +1 -1
- package/dist/Button.js +1 -1
- package/dist/Checkbox.cjs +1 -1
- package/dist/Checkbox.js +1 -1
- package/dist/{Icon-BHNINDhB.js → Icon-B9-_-fzr.js} +25 -16
- package/dist/{Icon-De6sqmQ9.cjs → Icon-Yl22zVSN.cjs} +1 -1
- package/dist/Icon.cjs +1 -1
- package/dist/Icon.js +1 -1
- package/dist/Input.cjs +1 -1
- package/dist/Input.js +1 -1
- package/dist/Markdown.cjs +1 -1
- package/dist/Markdown.js +7 -2
- package/dist/Modal.cjs +1 -1
- package/dist/Modal.js +26 -26
- package/dist/Popover.cjs +1 -1
- package/dist/Popover.js +81 -82
- package/dist/Select.cjs +1 -1
- package/dist/Select.js +280 -283
- package/dist/Sidebar.cjs +1 -1
- package/dist/Sidebar.js +21 -21
- package/dist/{Table-WlCsBVHC.js → Table-CURYs469.js} +2 -2
- package/dist/{Table-DEjAMnG3.cjs → Table-DTxKbMgJ.cjs} +1 -1
- package/dist/Table.cjs +1 -1
- package/dist/Table.js +1 -1
- package/dist/{Tooltip-4RWCnb2Q.js → Tooltip-BuRMZ4p_.js} +35 -35
- package/dist/{Tooltip-B2rZmRCs.cjs → Tooltip-tzVg8Bky.cjs} +1 -1
- package/dist/Tooltip.cjs +1 -1
- package/dist/Tooltip.js +1 -1
- package/dist/components/Markdown/utils/security.d.ts +2 -2
- package/dist/components/Popover/Popover.d.ts +10 -8
- package/dist/components/Portal/hooks/useDismissableLayer.d.ts +7 -4
- package/dist/components/Select/components/CustomSelect.d.ts +5 -4
- package/dist/components/Select/components/SelectListbox.d.ts +2 -4
- package/dist/components/Sidebar/Sidebar.d.ts +1 -1
- package/dist/style.css +1 -1
- package/dist/{useFocusTrap-BxPazAL6.js → useFocusTrap-BL3fDmTs.js} +1 -1
- package/dist/{useFocusTrap-CrMcAu8s.cjs → useFocusTrap-C--8mnsI.cjs} +1 -1
- package/dist/usePresence-BYnWctTh.js +232 -0
- package/dist/usePresence-HVr855AK.cjs +1 -0
- package/package.json +1 -1
- package/dist/usePresence-BTRY1_l-.js +0 -212
- package/dist/usePresence-Dm0mls5p.cjs +0 -1
package/dist/Modal.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as s, jsxs as
|
|
2
|
+
import { jsx as s, jsxs as D } 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
|
-
import { u as
|
|
4
|
+
import { u as F, a as V } from "./effects-DGbA6Q2O.js";
|
|
5
5
|
import { a as W } from "./reference-CXMr27nM.js";
|
|
6
|
-
import { B as X } from "./Button-
|
|
7
|
-
import { b as Y, P as Z, F as
|
|
8
|
-
import { u as ae } from "./useFocusTrap-
|
|
6
|
+
import { B as X } from "./Button-Dsr1zrKT.js";
|
|
7
|
+
import { b as Y, P as Z, F as E, c as ee, d as oe } from "./usePresence-BYnWctTh.js";
|
|
8
|
+
import { u as ae } from "./useFocusTrap-BL3fDmTs.js";
|
|
9
9
|
import { u as se } from "./useScrollLock-Drd7OZRC.js";
|
|
10
10
|
import { S as ne } from "./Surface-vEFsZC12.js";
|
|
11
11
|
import { T as te } from "./Text-rN6iDo0V.js";
|
|
@@ -27,15 +27,15 @@ function ie(t) {
|
|
|
27
27
|
open: o,
|
|
28
28
|
ownerDocument: R,
|
|
29
29
|
presenceState: k,
|
|
30
|
-
restoreFocus:
|
|
31
|
-
role:
|
|
32
|
-
style:
|
|
30
|
+
restoreFocus: w = !0,
|
|
31
|
+
role: M = "dialog",
|
|
32
|
+
style: N,
|
|
33
33
|
title: m,
|
|
34
34
|
trapFocus: x = !0,
|
|
35
|
-
...
|
|
36
|
-
} = t,
|
|
37
|
-
(
|
|
38
|
-
re(
|
|
35
|
+
...P
|
|
36
|
+
} = t, I = g(null), B = g(null), O = J(E), L = `${K()}-title`, [f, T] = Q(null), p = F("Modal").boundaryElement, y = ee(!0, p), j = U(() => [I], []), v = !!(m != null && m.trim()), z = c ?? (v ? B : void 0), A = r ?? (a === void 0 && v ? L : void 0), C = h(
|
|
37
|
+
(_) => {
|
|
38
|
+
re(_, I, l), T(_);
|
|
39
39
|
},
|
|
40
40
|
[l]
|
|
41
41
|
);
|
|
@@ -52,10 +52,10 @@ function ie(t) {
|
|
|
52
52
|
active: o,
|
|
53
53
|
boundaries: j,
|
|
54
54
|
dismissOnEscape: i,
|
|
55
|
-
|
|
55
|
+
dismissOnOutsideInteraction: i ? "consume" : "none",
|
|
56
56
|
layerId: y.id,
|
|
57
57
|
onEscapeDismiss: $,
|
|
58
|
-
|
|
58
|
+
onOutsideDismiss: q,
|
|
59
59
|
ownerDocument: R
|
|
60
60
|
});
|
|
61
61
|
const G = ae({
|
|
@@ -64,10 +64,10 @@ function ie(t) {
|
|
|
64
64
|
container: f,
|
|
65
65
|
initialFocusReference: z,
|
|
66
66
|
layerId: y.id,
|
|
67
|
-
restoreFocus:
|
|
67
|
+
restoreFocus: w
|
|
68
68
|
});
|
|
69
69
|
se(u, R, p);
|
|
70
|
-
const
|
|
70
|
+
const S = i ? /* @__PURE__ */ s(
|
|
71
71
|
X,
|
|
72
72
|
{
|
|
73
73
|
"aria-label": d,
|
|
@@ -80,7 +80,7 @@ function ie(t) {
|
|
|
80
80
|
}
|
|
81
81
|
) : null;
|
|
82
82
|
return /* @__PURE__ */ s(
|
|
83
|
-
|
|
83
|
+
E.Provider,
|
|
84
84
|
{
|
|
85
85
|
value: o && x ? G : O,
|
|
86
86
|
children: /* @__PURE__ */ s(
|
|
@@ -90,10 +90,10 @@ function ie(t) {
|
|
|
90
90
|
"data-state": k,
|
|
91
91
|
role: "presentation",
|
|
92
92
|
style: { zIndex: y.zIndex },
|
|
93
|
-
children: /* @__PURE__ */ s("div", { className: "nk-modal__viewport", children: /* @__PURE__ */
|
|
93
|
+
children: /* @__PURE__ */ s("div", { className: "nk-modal__viewport", children: /* @__PURE__ */ D(
|
|
94
94
|
ne,
|
|
95
95
|
{
|
|
96
|
-
...
|
|
96
|
+
...P,
|
|
97
97
|
ref: C,
|
|
98
98
|
"aria-hidden": o ? void 0 : !0,
|
|
99
99
|
"aria-label": o ? a : void 0,
|
|
@@ -101,17 +101,17 @@ function ie(t) {
|
|
|
101
101
|
"aria-modal": o ? "true" : void 0,
|
|
102
102
|
className: ["nk-modal", b].filter(Boolean).join(" "),
|
|
103
103
|
"data-state": k,
|
|
104
|
-
role: o ?
|
|
105
|
-
style:
|
|
104
|
+
role: o ? M : void 0,
|
|
105
|
+
style: N,
|
|
106
106
|
tabIndex: -1,
|
|
107
107
|
children: [
|
|
108
|
-
v ? /* @__PURE__ */
|
|
108
|
+
v ? /* @__PURE__ */ D("div", { className: "nk-modal__header", children: [
|
|
109
109
|
/* @__PURE__ */ s(
|
|
110
110
|
te,
|
|
111
111
|
{
|
|
112
112
|
as: "h2",
|
|
113
113
|
className: "nk-modal__title",
|
|
114
|
-
id:
|
|
114
|
+
id: L,
|
|
115
115
|
ref: B,
|
|
116
116
|
size: "subtitle",
|
|
117
117
|
tabIndex: -1,
|
|
@@ -119,8 +119,8 @@ function ie(t) {
|
|
|
119
119
|
children: m
|
|
120
120
|
}
|
|
121
121
|
),
|
|
122
|
-
|
|
123
|
-
] }) :
|
|
122
|
+
S
|
|
123
|
+
] }) : S,
|
|
124
124
|
n
|
|
125
125
|
]
|
|
126
126
|
}
|
|
@@ -131,7 +131,7 @@ function ie(t) {
|
|
|
131
131
|
);
|
|
132
132
|
}
|
|
133
133
|
const he = H(function(a, r) {
|
|
134
|
-
const { open: n } = a, b =
|
|
134
|
+
const { open: n } = a, b = F("Modal"), d = g(a);
|
|
135
135
|
n && (d.current = a);
|
|
136
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
137
|
return !l.present || !u ? null : /* @__PURE__ */ s(Z, { children: /* @__PURE__ */ s(
|
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"),r=require("react"),je=require("./aria-DM-xYEHQ.cjs"),se=require("./effects-D98vUn6N.cjs"),B=require("./reference-C2guRuR0.cjs"),ne=require("./useFloatingPosition-DPVO2E8O.cjs"),
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react/jsx-runtime"),r=require("react"),je=require("./aria-DM-xYEHQ.cjs"),se=require("./effects-D98vUn6N.cjs"),B=require("./reference-C2guRuR0.cjs"),ne=require("./useFloatingPosition-DPVO2E8O.cjs"),P=require("./usePresence-HVr855AK.cjs"),we=require("./useFocusTrap-C--8mnsI.cjs"),Le=require("./Surface-BttJYSDt.cjs");function De(n){const{inert:i,panelElement:c}=n;return se.useIsomorphicLayoutEffect(()=>{c&&(c.inert=i)},[i,c]),null}function Ne(n,i,c){i.current=n,B.assignElementReference(c,n)}function _e(n,i,c){i.current=n,B.assignElementReference(c,n)}function Me(n){const i=n.tagName.toLowerCase();return n.getAttribute("role")==="button"&&i!=="button"?!1:["button","input","select","summary","textarea"].includes(i)?!0:i==="a"&&n.hasAttribute("href")}function Be(n){return n==="grid"||n==="listbox"||n==="menu"||n==="tree"?n:"dialog"}const ze=r.forwardRef(function(i,c){const{"aria-label":z,"aria-labelledby":oe,align:A="center",autoFocus:j=!0,children:ae,className:ie,defaultOpen:ce=!1,disabled:x=!1,initialFocusReference:R,onEscapeKeyDown:ue,onOpenChange:k,onPointerDownOutside:I,open:H,placement:K="bottom",persistent:le=!1,restoreFocus:w=!0,role:V="dialog",style:$,tabIndex:de,trapFocus:b=!1,trigger:d,...fe}=i;if(d.type===r.Fragment)throw new Error("Popover requires a single non-Fragment trigger");const U=r.useId(),pe=r.useContext(P.FocusScopeContext),G=`${U}-popover`,o=d.props,J=B.getElementReference(d),Q=o.id??`${U}-trigger`,v=x||o.disabled===!0||o["aria-disabled"]===!0||o["aria-disabled"]==="true",T=H!==void 0,[ge,me]=r.useState(ce),t=T?H:ge,C=P.usePresence(t),W=r.useRef(null),X=r.useRef(null),L=r.useRef("programmatic"),D=r.useRef(null),Y=r.useRef(t),E=r.useRef(null),[be,ve]=r.useReducer(e=>e+1,0),[u,ye]=r.useState(null),[f,he]=r.useState(null),a=(u==null?void 0:u.ownerDocument)??(typeof document>"u"?null:document),S=se.useBoundary("Popover").boundaryElement,O=P.useOverlayLayer(C.present,S),Pe=r.useMemo(()=>[W,X],[]),p=ne.useFloatingPosition(C.present,K,u,f,S,A),Re=r.useCallback(e=>{_e(e,W,J),ye(e)},[J]),Te=r.useCallback(e=>{Ne(e,X,c),he(e)},[c]),g=r.useCallback((e,s)=>{t!==e&&(T?(D.current={open:e,reason:s},ve()):(L.current=s,me(e)),k==null||k(e,s))},[T,k,t]),Ee=r.useCallback(()=>{g(!1,"escape")},[g]),xe=r.useCallback(()=>{g(!1,"outside")},[g]),ke=r.useCallback(e=>{var m;if(I==null||I(e),e.defaultPrevented)return;const s=(m=a==null?void 0:a.defaultView)==null?void 0:m.HTMLElement;s?E.current=e.composedPath().find(h=>h instanceof s&&h.tabIndex>=0)??e.target:E.current=e.target},[I,a]);P.useDismissableLayer({boundary:S,active:t,boundaries:Pe,dismissOnEscape:!0,dismissOnOutsideInteraction:le?"none":"pass-through",layerId:O.id,onEscapeDismiss:Ee,onEscapeKeyDown:ue,onOutsideDismiss:xe,onPointerDownOutside:ke,ownerDocument:a});const Ie=we.useFocusTrap({boundary:S,active:t&&b,autoFocus:j,container:f,initialFocusReference:R,layerId:O.id,restoreFocus:w});r.useEffect(()=>{if(!t||b||!j||!f)return;let e=!0;return Promise.resolve().then(()=>{if(!e)return;const s=R==null?void 0:R.current;(s&&f.contains(s)?s:f).focus({preventScroll:!0})}),()=>{e=!1}},[j,R,t,f,b]),r.useEffect(()=>{var te;const e=Y.current;Y.current=t;const s=D.current;let m=L.current;if(T&&(m="programmatic",e!==t&&(s==null?void 0:s.open)===t&&(m=s.reason)),D.current=null,t){L.current="programmatic",E.current=null;return}const h=a==null?void 0:a.activeElement,_=E.current,M=(te=a==null?void 0:a.defaultView)==null?void 0:te.HTMLElement,Fe=m==="outside"&&M&&_ instanceof M&&h instanceof M&&(_===h||_.contains(h));e&&!b&&w&&!Fe&&(u==null||u.focus({preventScroll:!0})),E.current=null},[be,T,t,a,w,b,u]),r.useEffect(()=>{x&&t&&g(!1,"programmatic")},[x,t,g]);function Ce(e){if(v){e.preventDefault(),e.stopPropagation();return}e.defaultPrevented||g(!t,"trigger")}function Se(e){e.defaultPrevented||v||Me(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,Z=y==="a"&&typeof o.href=="string",ee=N&&!(y==="button"||y==="input"||y==="select"||y==="summary"||y==="textarea"||Z),re=Z&&v;let q=o.role;q===void 0&&(re?q="link":ee&&(q="button"));let F=o.tabIndex;F===void 0&&ee&&(F=0),v&&(F=-1);const Oe=v?{...o,onClick:void 0}:o,qe=r.cloneElement(d,ne.resolveTriggerOverrides(Oe,{"aria-controls":t?je.mergeIdentifiers(o["aria-controls"],G):o["aria-controls"],"aria-expanded":t,"aria-haspopup":o["aria-haspopup"]??Be(V),"aria-disabled":v?!0:o["aria-disabled"],className:"nk-popover__trigger",href:re?void 0:o.href,id:Q,onClick:Ce,onKeyDown:N?Se:void 0,ref:Re,role:q,tabIndex:F}));return l.jsxs(l.Fragment,{children:[qe,l.jsx(P.FocusScopeContext.Provider,{value:t&&b?Ie:pe,children:C.present&&a?l.jsx(P.Portal,{children:l.jsxs(Le.Surface,{...fe,ref:Te,"aria-hidden":t?void 0:!0,"aria-label":t?z:void 0,"aria-labelledby":t?oe??(z===void 0?Q:void 0):void 0,className:["nk-popover",ie].filter(Boolean).join(" "),"data-placement":(p==null?void 0:p.placement)??K,"data-align":A,"data-state":C.state==="closing"?"closing":"open",id:G,role:t?V:void 0,style:p?{...$,"--nk-popover-arrow-offset":`${p.arrowOffset}px`,left:p.left,top:p.top,zIndex:O.zIndex}:{...$,visibility:"hidden",zIndex:O.zIndex},tabIndex:de??-1,children:[l.jsx(De,{inert:!t,panelElement:f}),l.jsx("span",{"aria-hidden":"true",className:"nk-popover__arrow"}),l.jsx("div",{className:"nk-popover__content",children:ae})]})}):null})]})});exports.default=ze;
|
package/dist/Popover.js
CHANGED
|
@@ -1,132 +1,131 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as oe, Fragment as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { m as
|
|
5
|
-
import { u as
|
|
6
|
-
import { g as
|
|
7
|
-
import { u as
|
|
8
|
-
import { F as se, b as
|
|
9
|
-
import { u as
|
|
10
|
-
import { S as
|
|
11
|
-
function
|
|
2
|
+
import { jsxs as oe, Fragment as Ne, jsx as I } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as _e, Fragment as Be, useId as qe, useContext as ze, useState as A, useRef as y, useReducer as Ae, useMemo as Me, useCallback as h, useEffect as M, cloneElement as $e } from "react";
|
|
4
|
+
import { m as je } from "./aria-Bv-xVREf.js";
|
|
5
|
+
import { u as He, a as Ke } from "./effects-DGbA6Q2O.js";
|
|
6
|
+
import { g as Ve, a as ae } from "./reference-CXMr27nM.js";
|
|
7
|
+
import { u as Ue, r as Ge } from "./useFloatingPosition-DktY7k-t.js";
|
|
8
|
+
import { F as se, b as Je, c as Qe, d as We, P as Xe } from "./usePresence-BYnWctTh.js";
|
|
9
|
+
import { u as Ye } from "./useFocusTrap-BL3fDmTs.js";
|
|
10
|
+
import { S as Ze } from "./Surface-vEFsZC12.js";
|
|
11
|
+
function er(t) {
|
|
12
12
|
const { inert: a, panelElement: i } = t;
|
|
13
|
-
return
|
|
13
|
+
return Ke(() => {
|
|
14
14
|
i && (i.inert = a);
|
|
15
15
|
}, [a, i]), null;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function rr(t, a, i) {
|
|
18
18
|
a.current = t, ae(i, t);
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function tr(t, a, i) {
|
|
21
21
|
a.current = t, ae(i, t);
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function nr(t) {
|
|
24
24
|
const a = t.tagName.toLowerCase();
|
|
25
25
|
return t.getAttribute("role") === "button" && a !== "button" ? !1 : ["button", "input", "select", "summary", "textarea"].includes(a) ? !0 : a === "a" && t.hasAttribute("href");
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function or(t) {
|
|
28
28
|
return t === "grid" || t === "listbox" || t === "menu" || t === "tree" ? t : "dialog";
|
|
29
29
|
}
|
|
30
|
-
const
|
|
30
|
+
const mr = _e(function(a, i) {
|
|
31
31
|
const {
|
|
32
32
|
"aria-label": $,
|
|
33
33
|
"aria-labelledby": ie,
|
|
34
34
|
align: j = "center",
|
|
35
|
-
autoFocus:
|
|
35
|
+
autoFocus: L = !0,
|
|
36
36
|
children: ce,
|
|
37
37
|
className: le,
|
|
38
|
-
|
|
39
|
-
closeOnOutsideInteraction: de = !0,
|
|
40
|
-
defaultOpen: fe = !1,
|
|
38
|
+
defaultOpen: ue = !1,
|
|
41
39
|
disabled: R = !1,
|
|
42
40
|
initialFocusReference: P,
|
|
43
|
-
onEscapeKeyDown:
|
|
41
|
+
onEscapeKeyDown: de,
|
|
44
42
|
onOpenChange: x,
|
|
45
|
-
onPointerDownOutside:
|
|
43
|
+
onPointerDownOutside: k,
|
|
46
44
|
open: H,
|
|
47
45
|
placement: K = "bottom",
|
|
48
|
-
|
|
46
|
+
persistent: fe = !1,
|
|
47
|
+
restoreFocus: D = !0,
|
|
49
48
|
role: V = "dialog",
|
|
50
49
|
style: U,
|
|
51
|
-
tabIndex:
|
|
50
|
+
tabIndex: pe,
|
|
52
51
|
trapFocus: g = !1,
|
|
53
52
|
trigger: l,
|
|
54
|
-
...
|
|
53
|
+
...ge
|
|
55
54
|
} = a;
|
|
56
|
-
if (l.type ===
|
|
55
|
+
if (l.type === Be)
|
|
57
56
|
throw new Error("Popover requires a single non-Fragment trigger");
|
|
58
|
-
const G =
|
|
57
|
+
const G = qe(), me = ze(se), J = `${G}-popover`, o = l.props, Q = Ve(l), W = o.id ?? `${G}-trigger`, m = R || o.disabled === !0 || o["aria-disabled"] === !0 || o["aria-disabled"] === "true", T = H !== void 0, [be, ve] = A(ue), r = T ? H : be, O = Je(r), X = y(null), Y = y(null), N = y("programmatic"), _ = y(null), Z = y(r), E = y(null), [ye, he] = Ae(
|
|
59
58
|
(e) => e + 1,
|
|
60
59
|
0
|
|
61
|
-
), [c,
|
|
60
|
+
), [c, Pe] = A(null), [u, Te] = A(null), s = (c == null ? void 0 : c.ownerDocument) ?? (typeof document > "u" ? null : document), C = He("Popover").boundaryElement, S = Qe(O.present, C), Ee = Me(
|
|
62
61
|
() => [X, Y],
|
|
63
62
|
[]
|
|
64
|
-
), d =
|
|
65
|
-
|
|
63
|
+
), d = Ue(
|
|
64
|
+
O.present,
|
|
66
65
|
K,
|
|
67
66
|
c,
|
|
68
67
|
u,
|
|
69
68
|
C,
|
|
70
69
|
j
|
|
71
|
-
),
|
|
70
|
+
), Ie = h(
|
|
72
71
|
(e) => {
|
|
73
|
-
|
|
72
|
+
tr(
|
|
74
73
|
e,
|
|
75
74
|
X,
|
|
76
75
|
Q
|
|
77
|
-
),
|
|
76
|
+
), Pe(e);
|
|
78
77
|
},
|
|
79
78
|
[Q]
|
|
80
|
-
),
|
|
79
|
+
), Re = h(
|
|
81
80
|
(e) => {
|
|
82
|
-
|
|
81
|
+
rr(
|
|
83
82
|
e,
|
|
84
83
|
Y,
|
|
85
84
|
i
|
|
86
|
-
),
|
|
85
|
+
), Te(e);
|
|
87
86
|
},
|
|
88
87
|
[i]
|
|
89
88
|
), f = h((e, n) => {
|
|
90
89
|
r !== e && (T ? (_.current = {
|
|
91
90
|
open: e,
|
|
92
91
|
reason: n
|
|
93
|
-
},
|
|
94
|
-
}, [T, x, r]),
|
|
92
|
+
}, he()) : (N.current = n, ve(e)), x == null || x(e, n));
|
|
93
|
+
}, [T, x, r]), xe = h(() => {
|
|
95
94
|
f(!1, "escape");
|
|
96
95
|
}, [f]), ke = h(() => {
|
|
97
96
|
f(!1, "outside");
|
|
98
|
-
}, [f]),
|
|
97
|
+
}, [f]), Oe = h((e) => {
|
|
99
98
|
var p;
|
|
100
|
-
if (
|
|
99
|
+
if (k == null || k(e), e.defaultPrevented) return;
|
|
101
100
|
const n = (p = s == null ? void 0 : s.defaultView) == null ? void 0 : p.HTMLElement;
|
|
102
101
|
n ? E.current = e.composedPath().find(
|
|
103
102
|
(v) => v instanceof n && v.tabIndex >= 0
|
|
104
103
|
) ?? e.target : E.current = e.target;
|
|
105
|
-
}, [
|
|
106
|
-
|
|
104
|
+
}, [k, s]);
|
|
105
|
+
We({
|
|
107
106
|
boundary: C,
|
|
108
107
|
active: r,
|
|
109
|
-
boundaries:
|
|
110
|
-
dismissOnEscape:
|
|
111
|
-
|
|
108
|
+
boundaries: Ee,
|
|
109
|
+
dismissOnEscape: !0,
|
|
110
|
+
dismissOnOutsideInteraction: fe ? "none" : "pass-through",
|
|
112
111
|
layerId: S.id,
|
|
113
|
-
onEscapeDismiss:
|
|
114
|
-
onEscapeKeyDown:
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
onEscapeDismiss: xe,
|
|
113
|
+
onEscapeKeyDown: de,
|
|
114
|
+
onOutsideDismiss: ke,
|
|
115
|
+
onPointerDownOutside: Oe,
|
|
117
116
|
ownerDocument: s
|
|
118
117
|
});
|
|
119
|
-
const
|
|
118
|
+
const Ce = Ye({
|
|
120
119
|
boundary: C,
|
|
121
120
|
active: r && g,
|
|
122
|
-
autoFocus:
|
|
121
|
+
autoFocus: L,
|
|
123
122
|
container: u,
|
|
124
123
|
initialFocusReference: P,
|
|
125
124
|
layerId: S.id,
|
|
126
|
-
restoreFocus:
|
|
125
|
+
restoreFocus: D
|
|
127
126
|
});
|
|
128
127
|
M(() => {
|
|
129
|
-
if (!r || g || !
|
|
128
|
+
if (!r || g || !L || !u) return;
|
|
130
129
|
let e = !0;
|
|
131
130
|
return Promise.resolve().then(() => {
|
|
132
131
|
if (!e) return;
|
|
@@ -135,7 +134,7 @@ const br = Be(function(a, i) {
|
|
|
135
134
|
}), () => {
|
|
136
135
|
e = !1;
|
|
137
136
|
};
|
|
138
|
-
}, [
|
|
137
|
+
}, [L, P, r, u, g]), M(() => {
|
|
139
138
|
var ne;
|
|
140
139
|
const e = Z.current;
|
|
141
140
|
Z.current = r;
|
|
@@ -145,20 +144,20 @@ const br = Be(function(a, i) {
|
|
|
145
144
|
N.current = "programmatic", E.current = null;
|
|
146
145
|
return;
|
|
147
146
|
}
|
|
148
|
-
const v = s == null ? void 0 : s.activeElement, q = E.current, z = (ne = s == null ? void 0 : s.defaultView) == null ? void 0 : ne.HTMLElement,
|
|
149
|
-
e && !g &&
|
|
147
|
+
const v = s == null ? void 0 : s.activeElement, q = E.current, z = (ne = s == null ? void 0 : s.defaultView) == null ? void 0 : ne.HTMLElement, De = p === "outside" && z && q instanceof z && v instanceof z && (q === v || q.contains(v));
|
|
148
|
+
e && !g && D && !De && (c == null || c.focus({ preventScroll: !0 })), E.current = null;
|
|
150
149
|
}, [
|
|
151
|
-
|
|
150
|
+
ye,
|
|
152
151
|
T,
|
|
153
152
|
r,
|
|
154
153
|
s,
|
|
155
|
-
|
|
154
|
+
D,
|
|
156
155
|
g,
|
|
157
156
|
c
|
|
158
157
|
]), M(() => {
|
|
159
158
|
R && r && f(!1, "programmatic");
|
|
160
159
|
}, [R, r, f]);
|
|
161
|
-
function
|
|
160
|
+
function Se(e) {
|
|
162
161
|
if (m) {
|
|
163
162
|
e.preventDefault(), e.stopPropagation();
|
|
164
163
|
return;
|
|
@@ -166,49 +165,49 @@ const br = Be(function(a, i) {
|
|
|
166
165
|
e.defaultPrevented || f(!r, "trigger");
|
|
167
166
|
}
|
|
168
167
|
function Fe(e) {
|
|
169
|
-
e.defaultPrevented || m ||
|
|
168
|
+
e.defaultPrevented || m || nr(e.currentTarget) || e.key !== "Enter" && e.key !== " " || (e.preventDefault(), e.currentTarget.click());
|
|
170
169
|
}
|
|
171
170
|
if (R) return l;
|
|
172
171
|
const B = typeof l.type == "string", b = B ? l.type : null, ee = b === "a" && typeof o.href == "string", re = B && !(b === "button" || b === "input" || b === "select" || b === "summary" || b === "textarea" || ee), te = ee && m;
|
|
173
|
-
let
|
|
174
|
-
|
|
175
|
-
let
|
|
176
|
-
|
|
177
|
-
const
|
|
172
|
+
let F = o.role;
|
|
173
|
+
F === void 0 && (te ? F = "link" : re && (F = "button"));
|
|
174
|
+
let w = o.tabIndex;
|
|
175
|
+
w === void 0 && re && (w = 0), m && (w = -1);
|
|
176
|
+
const we = m ? { ...o, onClick: void 0 } : o, Le = $e(
|
|
178
177
|
l,
|
|
179
|
-
|
|
180
|
-
"aria-controls": r ?
|
|
178
|
+
Ge(we, {
|
|
179
|
+
"aria-controls": r ? je(o["aria-controls"], J) : o["aria-controls"],
|
|
181
180
|
"aria-expanded": r,
|
|
182
|
-
"aria-haspopup": o["aria-haspopup"] ??
|
|
181
|
+
"aria-haspopup": o["aria-haspopup"] ?? or(V),
|
|
183
182
|
"aria-disabled": m ? !0 : o["aria-disabled"],
|
|
184
183
|
className: "nk-popover__trigger",
|
|
185
184
|
href: te ? void 0 : o.href,
|
|
186
185
|
id: W,
|
|
187
|
-
onClick:
|
|
186
|
+
onClick: Se,
|
|
188
187
|
onKeyDown: B ? Fe : void 0,
|
|
189
|
-
ref:
|
|
190
|
-
role:
|
|
191
|
-
tabIndex:
|
|
188
|
+
ref: Ie,
|
|
189
|
+
role: F,
|
|
190
|
+
tabIndex: w
|
|
192
191
|
})
|
|
193
192
|
);
|
|
194
|
-
return /* @__PURE__ */ oe(
|
|
193
|
+
return /* @__PURE__ */ oe(Ne, { children: [
|
|
195
194
|
Le,
|
|
196
195
|
/* @__PURE__ */ I(
|
|
197
196
|
se.Provider,
|
|
198
197
|
{
|
|
199
|
-
value: r && g ?
|
|
200
|
-
children:
|
|
201
|
-
|
|
198
|
+
value: r && g ? Ce : me,
|
|
199
|
+
children: O.present && s ? /* @__PURE__ */ I(Xe, { children: /* @__PURE__ */ oe(
|
|
200
|
+
Ze,
|
|
202
201
|
{
|
|
203
|
-
...
|
|
204
|
-
ref:
|
|
202
|
+
...ge,
|
|
203
|
+
ref: Re,
|
|
205
204
|
"aria-hidden": r ? void 0 : !0,
|
|
206
205
|
"aria-label": r ? $ : void 0,
|
|
207
206
|
"aria-labelledby": r ? ie ?? ($ === void 0 ? W : void 0) : void 0,
|
|
208
207
|
className: ["nk-popover", le].filter(Boolean).join(" "),
|
|
209
208
|
"data-placement": (d == null ? void 0 : d.placement) ?? K,
|
|
210
209
|
"data-align": j,
|
|
211
|
-
"data-state":
|
|
210
|
+
"data-state": O.state === "closing" ? "closing" : "open",
|
|
212
211
|
id: J,
|
|
213
212
|
role: r ? V : void 0,
|
|
214
213
|
style: d ? {
|
|
@@ -222,10 +221,10 @@ const br = Be(function(a, i) {
|
|
|
222
221
|
visibility: "hidden",
|
|
223
222
|
zIndex: S.zIndex
|
|
224
223
|
},
|
|
225
|
-
tabIndex:
|
|
224
|
+
tabIndex: pe ?? -1,
|
|
226
225
|
children: [
|
|
227
226
|
/* @__PURE__ */ I(
|
|
228
|
-
|
|
227
|
+
er,
|
|
229
228
|
{
|
|
230
229
|
inert: !r,
|
|
231
230
|
panelElement: u
|
|
@@ -241,5 +240,5 @@ const br = Be(function(a, i) {
|
|
|
241
240
|
] });
|
|
242
241
|
});
|
|
243
242
|
export {
|
|
244
|
-
|
|
243
|
+
mr as default
|
|
245
244
|
};
|
package/dist/Select.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("react/jsx-runtime"),
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("react/jsx-runtime"),r=require("react"),J=require("./effects-D98vUn6N.cjs"),K=require("./aria-DM-xYEHQ.cjs"),Ie=require("./reference-C2guRuR0.cjs"),M=require("./Icon-Yl22zVSN.cjs"),F=require("./usePresence-HVr855AK.cjs"),ne=require("./useAnchoredPosition-CrdY2Eat.cjs");function ge(t){const{form:n,onReset:s,resetValue:o,triggerReference:a}=t,l=r.useRef(null);return r.useEffect(()=>{var u;const f=(u=a.current)==null?void 0:u.form;if(!f)return;function d(){const v=l.current;if(v){const x=Array.from(v.options),I=x.find(p=>p.value===o)??x[0];x.forEach(p=>{p.defaultSelected=p===I})}s()}return f.addEventListener("reset",d),()=>f.removeEventListener("reset",d)},[n,s,o,a]),l}const T=8,G=4,ke=160,we=72;function Re(t,n,s,o="start"){const a=s.bottom-t.bottom-G-T,l=t.top-s.top-G-T,f=a<ke&&l>a,d=Math.max(we,f?l:a),u=Math.max(t.width,(n==null?void 0:n.width)??t.width),v=s.left+T,x=ne.calculateAlignedPosition(o,t.left,t.width,u),I=Math.min(Math.max(v,x),Math.max(v,s.right-T-u)),p=f?Math.max(s.top+T,t.top-G-Math.min((n==null?void 0:n.height)??d,d)):t.bottom+G;return{left:I,maxHeight:d,minWidth:t.width,top:p}}function _e(t,n,s,o,a="start"){const l=r.useCallback(f=>{const{panelSize:d,triggerBounds:u,visibleBounds:v}=f;return Re(u,d,v,a)},[a]);return ne.useAnchoredPosition({active:t,boundary:o,fit:l,panel:s,trigger:n})}const Ee=500;function je(t){const n=r.useRef(""),s=r.useRef(null),o=r.useRef(null);return r.useEffect(()=>()=>{const a=o.current;a&&s.current!==null&&a.clearTimeout(s.current)},[]),r.useCallback(a=>{var u;const l=(u=t.current)==null?void 0:u.ownerDocument.defaultView;if(!l)return null;o.current=l;const f=n.current+a,d=Array.from(f).every(v=>v===a);return n.current=d?a:f,s.current!==null&&l.clearTimeout(s.current),s.current=l.setTimeout(()=>{n.current="",s.current=null},Ee),n.current},[t])}function Q(t,n,s){if(t.length===0)return-1;for(let o=1;o<=t.length;o+=1){const a=(n+s*o+t.length)%t.length;if(!t[a].disabled)return a}return-1}function De(t,n,s){for(let o=1;o<=t.length;o+=1){const a=(s+o+t.length)%t.length,l=t[a];if(!l.disabled&&l.label.toLocaleLowerCase().startsWith(n))return a}return-1}function Oe(t){const n=new Set;t.forEach(s=>{if(n.has(s.value))throw new Error("Select option values must be unique");n.add(s.value)})}function Se(t){const{active:n,align:s,highlightedIndex:o,id:a,listboxReference:l,onEscapeDismiss:f,onEscapeKeyDown:d,onHighlight:u,onOutsideDismiss:v,onPointerDownOutside:x,onSelect:I,options:p,ownerDocument:E,persistent:B,position:g,selectedValue:w,state:U,triggerReference:m}=t,H=r.useRef(null),L=J.useBoundary("Select").boundaryElement,j=F.useOverlayLayer(!0,L),q=r.useMemo(()=>[m,H],[m]),V=r.useCallback(h=>{H.current=h,l(h)},[l]);return F.useDismissableLayer({active:n,boundaries:q,boundary:L,dismissOnEscape:!0,dismissOnOutsideInteraction:B?"none":"pass-through",layerId:j.id,onEscapeDismiss:f,onEscapeKeyDown:d,onOutsideDismiss:v,onPointerDownOutside:x,ownerDocument:E}),c.jsx("div",{"aria-hidden":n?void 0:!0,"aria-labelledby":a,className:"nk-select__listbox","data-align":s,"data-state":U,id:`${a}-listbox`,ref:V,role:"listbox",style:g?{left:g.left,maxHeight:g.maxHeight,minWidth:g.minWidth,top:g.top,zIndex:j.zIndex}:{visibility:"hidden",zIndex:j.zIndex},children:p.map((h,A)=>c.jsxs("div",{"aria-disabled":h.disabled||void 0,"aria-selected":h.value===w,className:"nk-select__option","data-highlighted":A===o||void 0,"data-selected":h.value===w||void 0,id:`${a}-option-${A}`,onPointerDown:X=>{X.preventDefault(),h.disabled||I(h)},onPointerMove:()=>{h.disabled||u(A)},role:"option",children:[h.icon?c.jsx(M.Icon,{type:h.icon}):null,c.jsx("span",{className:"nk-select__option-label",children:h.label}),h.value===w?c.jsx(M.Icon,{className:"nk-select__check",type:"checkmark"}):null]},h.value))})}function Le(t,n,s){n.current=t,Ie.assignElementReference(s,t)}function Ae(t){var ee;const{"aria-invalid":n,align:s="start",className:o,defaultValue:a="",disabled:l=!1,displayOverride:f,form:d,forwardedReference:u,id:v,invalid:x=!1,name:I,onChange:p,onClick:E,onEscapeKeyDown:B,onKeyDown:g,onOpenChange:w,onPointerDownOutside:U,options:m,placeholder:H,persistent:L=!1,required:j=!1,style:q,value:V,width:h,...A}=t;Oe(m);const X=r.useId(),D=v??X,k=r.useRef(null),[C,se]=r.useState(null),[b,ae]=r.useState(!1),[R,N]=r.useState(-1),[le,Z]=r.useState(a),O=V!==void 0,S=O?V:le,re=m.find(e=>e.value===S),ie=x||K.hasInvalidState(n),oe=K.resolveAriaInvalid(x,n),Y=F.usePresence(b),P=((ee=k.current)==null?void 0:ee.ownerDocument)??(typeof document>"u"?null:document),ce=J.useBoundary("Select").boundaryElement,de=_e(Y.present,k.current,C,ce,s),ue=je(k),fe=h===void 0?q:{...q,width:h},W=f??re,he=r.useCallback(e=>Le(e,k,u),[u]),y=r.useCallback(e=>{b!==e&&(ae(e),w==null||w(e))},[w,b]),me=r.useCallback(()=>{O||Z(a),y(!1)},[a,O,y]),ve=ge({form:d,onReset:me,resetValue:O?S:a,triggerReference:k}),$=r.useCallback((e=1)=>{const i=m.findIndex(te=>te.value===S&&!te.disabled),_=e===1?-1:m.length;N(i>=0?i:Q(m,_,e)),y(!0)},[m,S,y]),z=r.useCallback(e=>{var i;l||e.disabled||(O||Z(e.value),y(!1),(i=k.current)==null||i.focus(),p==null||p(e.value))},[l,O,p,y]),pe=r.useCallback(()=>{var e;y(!1),(e=k.current)==null||e.focus()},[y]),be=r.useCallback(()=>{y(!1)},[y]);function ye(e){E==null||E(e),!(e.defaultPrevented||l)&&(b?y(!1):$())}function xe(e){if(g==null||g(e),!(e.defaultPrevented||l)){if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault();const i=e.key==="ArrowDown"?1:-1;b?N(_=>Q(m,_,i)):$(i);return}if(e.key==="Home"||e.key==="End"){if(e.preventDefault(),!b)$(e.key==="Home"?1:-1);else{const i=e.key==="Home"?1:-1,_=i===1?-1:m.length;N(Q(m,_,i))}return}if(e.key==="Enter"||e.key===" "){e.preventDefault();const i=m[R];b&&i?z(i):b||$();return}if(e.key==="Tab"){L||y(!1);return}if(e.key.length===1&&!e.altKey&&!e.ctrlKey&&!e.metaKey){const i=ue(e.key.toLocaleLowerCase());if(i===null)return;const _=De(m,i,R);_>=0&&(e.preventDefault(),b||y(!0),N(_))}}}return r.useEffect(()=>{l&&y(!1)},[l,y]),r.useEffect(()=>{var e;if(b&&R>=0){const i=P==null?void 0:P.getElementById(`${D}-option-${R}`);i&&(C!=null&&C.contains(i))&&((e=i.scrollIntoView)==null||e.call(i,{block:"nearest"}))}},[R,D,C,b]),c.jsxs("span",{className:["nk-select",o].filter(Boolean).join(" "),"data-disabled":l||void 0,"data-invalid":ie||void 0,"data-mode":"custom","data-open":b||void 0,style:fe,children:[c.jsxs("button",{...A,ref:he,"aria-activedescendant":b&&R>=0?`${D}-option-${R}`:void 0,"aria-controls":`${D}-listbox`,"aria-expanded":b,"aria-haspopup":"listbox","aria-invalid":oe,"aria-required":j||void 0,"aria-autocomplete":"none",className:"nk-select__trigger",disabled:l,form:d,id:D,onClick:ye,onKeyDown:xe,role:"combobox",type:"button",children:[W?c.jsxs("span",{className:"nk-select__value",children:[W.icon?c.jsx(M.Icon,{type:W.icon}):null,c.jsx("span",{className:"nk-select__value-label",children:W.label})]}):c.jsx("span",{className:"nk-select__placeholder",children:H}),c.jsx(M.Icon,{className:"nk-select__icon",type:"chevron-down"})]}),I||j?c.jsxs("select",{ref:ve,"aria-hidden":"true",className:"nk-select__form-control",disabled:l,form:d,name:I,onChange:()=>{},onInvalid:e=>{var i;e.preventDefault(),(i=k.current)==null||i.focus()},required:j,tabIndex:-1,value:S,children:[c.jsx("option",{value:""}),m.map(e=>c.jsx("option",{disabled:e.disabled,value:e.value,children:e.label},e.value))]}):null,Y.present&&P?c.jsx(F.Portal,{children:c.jsx(Se,{active:b,align:s,highlightedIndex:R,id:D,listboxReference:se,onEscapeDismiss:pe,onEscapeKeyDown:B,onHighlight:N,onOutsideDismiss:be,onPointerDownOutside:U,onSelect:z,options:m,ownerDocument:P,persistent:L,position:de,selectedValue:S,state:Y.state==="closing"?"closing":"open",triggerReference:k})}):null]})}function Ce(t){const{"aria-invalid":n,children:s,className:o,defaultValue:a,disabled:l=!1,forwardedReference:f,invalid:d=!1,placeholder:u,style:v,value:x,...I}=t,p=K.resolveAriaInvalid(d,n),E=d||K.hasInvalidState(n);return c.jsxs("span",{className:["nk-select",o].filter(Boolean).join(" "),"data-disabled":l||void 0,"data-invalid":E||void 0,"data-mode":"native",style:v,children:[c.jsxs("select",{...I,ref:f,"aria-invalid":p,className:"nk-select__control",defaultValue:x===void 0?a??(u!==void 0?"":void 0):void 0,disabled:l,value:x,children:[u!==void 0?c.jsx("option",{disabled:!0,value:"",children:u}):null,s]}),c.jsx(M.Icon,{className:"nk-select__icon",type:"chevron-down"})]})}const Ne=r.forwardRef(function(n,s){const{options:o}=n;return J.useBoundary("Select"),o!==void 0?c.jsx(Ae,{...n,forwardedReference:s}):c.jsx(Ce,{...n,forwardedReference:s})});exports.default=Ne;
|