react-animated-select 0.8.0 → 0.8.1
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/base.css +1 -1
- package/dist/chip.cjs +1 -1
- package/dist/chip.css +1 -1
- package/dist/chip.js +81 -62
- package/dist/chipGeometry.cjs +1 -1
- package/dist/chipGeometry.js +31 -58
- package/dist/chipMotion.cjs +1 -0
- package/dist/chipMotion.js +85 -0
- package/dist/dropdownPosition.cjs +1 -1
- package/dist/dropdownPosition.js +86 -76
- package/dist/index.d.cts +13 -0
- package/dist/motion.cjs +1 -1
- package/dist/motion.js +88 -86
- package/dist/style.css +3 -3
- package/dist/theme.css +1 -1
- package/dist/trigger.cjs +1 -1
- package/dist/trigger.js +82 -77
- package/dist/useChipLayout.cjs +1 -1
- package/dist/useChipLayout.js +65 -66
- package/dist/useSelectBehavior.cjs +1 -1
- package/dist/useSelectBehavior.js +44 -46
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +11 -11
- package/index.d.ts +13 -0
- package/package.json +1 -1
package/dist/trigger.js
CHANGED
|
@@ -1,94 +1,99 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { SelectConfigContext as N, SelectStateContext as
|
|
4
|
-
import { optionDomId as
|
|
5
|
-
import { memo as
|
|
6
|
-
import { effectiveHighlight as
|
|
7
|
-
import { toJSON as
|
|
8
|
-
import { Presence as
|
|
9
|
-
const
|
|
10
|
-
},
|
|
11
|
-
const { selectRef: m, multiple:
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
let
|
|
15
|
-
const
|
|
16
|
-
|
|
2
|
+
import { jsxs as O, jsx as f } from "react/jsx-runtime";
|
|
3
|
+
import { SelectConfigContext as N, SelectStateContext as D, SelectActionsContext as j } from "./state.js";
|
|
4
|
+
import { optionDomId as Z, flag as w, withClass as $, renderIcon as P, stopEvent as ee, refocus as te, optionContent as oe, dots as ne, followHeight as re, watchMotion as ae, reducedMotion as ie } from "./utils.js";
|
|
5
|
+
import { memo as I, useContext as h, useSyncExternalStore as q, useState as E, useRef as T, useCallback as le, useLayoutEffect as V, useEffect as H } from "react";
|
|
6
|
+
import { effectiveHighlight as se } from "./useSelectBehavior.js";
|
|
7
|
+
import { toJSON as ce } from "./model.js";
|
|
8
|
+
import { Presence as L, Collapse as k } from "./motion.js";
|
|
9
|
+
const de = [], ue = () => {
|
|
10
|
+
}, fe = (v) => v == null ? "" : typeof v == "object" ? ce(v) ?? "" : String(v), me = /* @__PURE__ */ I(function() {
|
|
11
|
+
const { selectRef: m, multiple: t, name: i, form: l, required: g } = h(N), { selected: o, selectedIDs: d, disabled: e, fieldsetDisabled: p } = h(D), { reset: u, markInvalid: x } = h(j), y = T(null);
|
|
12
|
+
H(() => {
|
|
13
|
+
const r = y.current?.getRootNode();
|
|
14
|
+
let b;
|
|
15
|
+
const S = (R) => {
|
|
16
|
+
R.target === y.current?.form && (clearTimeout(b), b = setTimeout(() => R.defaultPrevented || u()));
|
|
17
17
|
};
|
|
18
|
-
return
|
|
19
|
-
clearTimeout(
|
|
18
|
+
return r?.addEventListener("reset", S, !0), () => {
|
|
19
|
+
clearTimeout(b), r?.removeEventListener("reset", S, !0);
|
|
20
20
|
};
|
|
21
|
-
}, [
|
|
22
|
-
const
|
|
23
|
-
return
|
|
24
|
-
(
|
|
21
|
+
}, [u]);
|
|
22
|
+
const s = t ? d : o ? [o] : de, n = !g && (!i || t && !s.length), c = n || !s.length ? [""] : s.map((r) => fe(r.original)), a = () => m.current?.focus();
|
|
23
|
+
return c.map(
|
|
24
|
+
(r, b) => /* @__PURE__ */ f("input", { className: "rac-input", ref: b ? void 0 : y, name: n ? void 0 : i, form: l, value: r, hidden: n, required: g && !b, disabled: e && !p, tabIndex: -1, "aria-hidden": "true", autoComplete: "off", onChange: ue, onInvalid: x, onFocus: a }, b)
|
|
25
25
|
);
|
|
26
|
-
}),
|
|
27
|
-
const {
|
|
28
|
-
return /* @__PURE__ */
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
-
}, [
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
return
|
|
26
|
+
}), z = /* @__PURE__ */ I(function({ hidden: m, settle: t, wait: i, children: l }) {
|
|
27
|
+
const { valueAsOption: g, renderOption: o } = h(N), { title: d, valueOption: e, hasActualValue: p, loading: u, error: x } = h(D), [y] = E(() => /* @__PURE__ */ new Set()), s = g && e ? oe(e, o, !0) : null, n = u && !x && !p, c = `${s ? e.id : d}${n ? "-loading" : ""}`, a = e?.type === "boolean" ? String(e.raw) : void 0;
|
|
28
|
+
return /* @__PURE__ */ O(L, { wait: i, children: [
|
|
29
|
+
!m && /* @__PURE__ */ O(k, { axis: "x", fade: !0, group: y, className: $("rac-title", s && e.className), style: s ? e.style : void 0, "data-bool": a, onEntered: t, onExited: t, children: [
|
|
30
|
+
s ? /* @__PURE__ */ f("div", { className: "rac-option-jsx", children: s }) : d,
|
|
31
|
+
n && ne
|
|
32
|
+
] }, c),
|
|
33
|
+
l
|
|
34
|
+
] });
|
|
35
|
+
}), pe = /* @__PURE__ */ I(function() {
|
|
36
|
+
const { selectedText: m, duration: t, texts: i } = h(N), { selectedIDs: l } = h(D), g = q(ae, ie, () => !1), o = l.length > 0 && !m;
|
|
37
|
+
return /* @__PURE__ */ f(z, { hidden: o, wait: t > 0 && !g, children: o && l.map((d, e) => /* @__PURE__ */ f(k, { as: "span", axis: "none", exitAxis: "x", fade: !0, className: "rac-pick", "data-last": w(e === l.length - 1), children: d.name || i.emptyOption }, d.id)) });
|
|
38
|
+
}), he = /* @__PURE__ */ I(function() {
|
|
39
|
+
const { selectRef: m, multiple: t, duration: i, easing: l, ext: g } = h(N), o = t ? g.Value : void 0, d = T(null), [e, p] = E({ Slot: o, multiple: t, enter: !1, left: !1 });
|
|
40
|
+
let u = e;
|
|
41
|
+
(o ? e.Slot !== o || e.left : e.Slot && (!t || e.left)) ? u = { Slot: o, multiple: t, enter: !!o && !e.Slot && e.multiple, left: !1 } : e.multiple !== t && (u = { ...e, multiple: t }), u !== e && p(u);
|
|
42
|
+
const { Slot: x, enter: y } = u, s = le(() => p((a) => a.left ? a : { ...a, left: !0 }), []), [n] = E(() => ({ value: 0, root: "", anim: null })), c = T({ duration: i, easing: l });
|
|
43
|
+
return V(() => {
|
|
44
|
+
c.current = { duration: i, easing: l };
|
|
45
|
+
}, [i, l]), V(() => {
|
|
46
|
+
const a = d.current;
|
|
47
|
+
if (!a || typeof ResizeObserver > "u") return;
|
|
48
|
+
const r = new ResizeObserver(() => re(m.current, n, a.offsetHeight, c.current.duration, c.current.easing));
|
|
49
|
+
return r.observe(a), () => r.disconnect();
|
|
50
|
+
}, [x, m, n]), H(() => () => n.anim?.cancel(), [n]), x ? /* @__PURE__ */ f(x, { height: n, enter: y, leaving: !o, onLeft: s }) : /* @__PURE__ */ f("div", { className: "rac-value", ref: d, children: t ? /* @__PURE__ */ f(pe, {}) : /* @__PURE__ */ f(z, {}) });
|
|
51
|
+
}), Ce = /* @__PURE__ */ I(function() {
|
|
52
|
+
const { selectRef: m, selectId: t, highlightStore: i, className: l, style: g, duration: o, easing: d, deleteInline: e, icons: p, texts: u, placeholder: x, id: y, required: s, popup: n, attrs: c } = h(N), { visibility: a, active: r, hasActualValue: b, deleting: S, loading: R, loadPending: B, error: A, invalid: F, normalizedOptions: K } = h(D), { handleBlur: M, handleFocus: G, handleKeyDown: J, toggleVisibility: _, clear: Q } = h(j), U = q(i.subscribe, () => {
|
|
53
|
+
const C = a ? K[se(i.get())] : null;
|
|
54
|
+
return C ? Z(t, C.id) : void 0;
|
|
50
55
|
}, () => {
|
|
51
|
-
}),
|
|
52
|
-
return /* @__PURE__ */
|
|
56
|
+
}), W = !!p.clear && b && r && !S, X = !!p.arrow && r && !S && n, Y = n ? { role: "combobox", "aria-haspopup": "listbox", "aria-controls": `${t}-listbox`, "aria-expanded": a, "aria-activedescendant": U, "aria-required": s || void 0 } : { role: "group" };
|
|
57
|
+
return /* @__PURE__ */ O(
|
|
53
58
|
"div",
|
|
54
59
|
{
|
|
55
|
-
...
|
|
56
|
-
id:
|
|
60
|
+
...c,
|
|
61
|
+
id: y,
|
|
57
62
|
ref: m,
|
|
58
|
-
style: { "--rac-duration": `${
|
|
59
|
-
className:
|
|
60
|
-
...
|
|
61
|
-
onKeyDown:
|
|
62
|
-
onFocus:
|
|
63
|
-
onClick:
|
|
64
|
-
onBlur:
|
|
63
|
+
style: { "--rac-duration": `${o}ms`, "--rac-ease": d, ...g },
|
|
64
|
+
className: $("rac-select", l),
|
|
65
|
+
...r && {
|
|
66
|
+
onKeyDown: J,
|
|
67
|
+
onFocus: G,
|
|
68
|
+
onClick: _,
|
|
69
|
+
onBlur: M
|
|
65
70
|
},
|
|
66
|
-
...
|
|
67
|
-
"aria-disabled": !
|
|
68
|
-
tabIndex:
|
|
69
|
-
"aria-busy":
|
|
70
|
-
"aria-label":
|
|
71
|
-
"aria-invalid":
|
|
72
|
-
"aria-describedby": [
|
|
73
|
-
"data-inline-delete":
|
|
74
|
-
"data-empty":
|
|
75
|
-
"data-deleting":
|
|
76
|
-
"data-error":
|
|
77
|
-
"data-invalid":
|
|
71
|
+
...Y,
|
|
72
|
+
"aria-disabled": !r,
|
|
73
|
+
tabIndex: r ? 0 : -1,
|
|
74
|
+
"aria-busy": R || B || void 0,
|
|
75
|
+
"aria-label": c["aria-label"] ?? (c["aria-labelledby"] ? void 0 : x),
|
|
76
|
+
"aria-invalid": F || c["aria-invalid"],
|
|
77
|
+
"aria-describedby": [c["aria-describedby"], A && `${t}-error`].filter(Boolean).join(" ") || void 0,
|
|
78
|
+
"data-inline-delete": w(e),
|
|
79
|
+
"data-empty": w(!b),
|
|
80
|
+
"data-deleting": w(S),
|
|
81
|
+
"data-error": w(A),
|
|
82
|
+
"data-invalid": w(F),
|
|
78
83
|
children: [
|
|
79
|
-
/* @__PURE__ */
|
|
80
|
-
/* @__PURE__ */
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}, children:
|
|
84
|
-
|
|
84
|
+
/* @__PURE__ */ f(he, {}),
|
|
85
|
+
/* @__PURE__ */ O(L, { children: [
|
|
86
|
+
W && /* @__PURE__ */ f(k, { as: "button", type: "button", axis: "x", className: "rac-clear", tabIndex: -1, "aria-label": u.clear, onMouseDown: ee, onClick: (C) => {
|
|
87
|
+
te(C, m), Q(C);
|
|
88
|
+
}, children: P(p.clear) }, "clear"),
|
|
89
|
+
X && /* @__PURE__ */ f(k, { axis: "x", className: "rac-arrow", "aria-hidden": "true", children: P(p.arrow) }, "arrow")
|
|
85
90
|
] }),
|
|
86
|
-
/* @__PURE__ */
|
|
91
|
+
/* @__PURE__ */ f(me, {})
|
|
87
92
|
]
|
|
88
93
|
}
|
|
89
94
|
);
|
|
90
95
|
});
|
|
91
96
|
export {
|
|
92
|
-
|
|
93
|
-
|
|
97
|
+
z as Title,
|
|
98
|
+
Ce as default
|
|
94
99
|
};
|
package/dist/useChipLayout.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react"),
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react"),V=require("react-dom"),R=require("./state.cjs"),f=require("./utils.cjs"),a=require("./chipGeometry.cjs"),i=require("./chipMotion.cjs"),se=.25,re={hoverId:null,swipedId:null,held:!1,breaks:a.NONE};function oe(y,{height:p,enter:J,leaving:C,onLeft:q}){const{selectRef:m,duration:u,easing:l,deleteInline:B,deleteAlways:j,icons:Q,valueAsOption:U,renderOption:X}=n.useContext(R.SelectConfigContext),{selectedIDs:F,deleting:v,visibility:H,active:O}=n.useContext(R.SelectStateContext),{setDeleting:D,setVisibility:N}=n.useContext(R.SelectActionsContext),[T,Y]=n.useState(0),[s]=n.useState(()=>R.createStore(re)),[Z]=n.useState(()=>new Set),G=n.useSyncExternalStore(s.subscribe,()=>s.get().held,()=>!1),L=n.useSyncExternalStore(s.subscribe,()=>s.get().breaks,()=>a.NONE),$=n.useSyncExternalStore(f.watchMotion,f.reducedMotion,()=>!1),h=n.useRef({rows:null,reserve:0,chips:y,swap:!1,dress:!1,wide:!1,duration:u,easing:l}),w=n.useRef(null),k=n.useRef(null),d=n.useRef(null),W=n.useRef(null),[z,ee]=n.useState(()=>!!J&&u>0&&!f.reducedMotion()),M=C||z,_=!!Q.remove,K=B&&!j&&!v&&_,E=K&&!M?T+se:0,x=K&&!T&&y.length>0,A=M?3:U?X?2:1:0,g=_?(B||v?1:0)|(j||v?2:0):0,P=n.useRef(g),I=n.useEffectEvent((e,t)=>{const r=d.current,o=h.current;if(!r)return;const c=i.isResizing(r);c&&t||(e&&s.get().held&&a.freeze(s,r,o),c?o.fit!=null&&f.followHeight(m.current,p,o.fit,o.duration,o.easing,r):(t||p.value)&&f.followHeight(m.current,p,r.offsetHeight,o.duration,o.easing),s.get().held||s.set({breaks:a.restBreaks(s,r,o.chips,o.reserve)}))}),S=n.useCallback(()=>{const e=d.current,t=h.current;if(!e||!s.get().held||i.isBusy(e,t.dress))return;const r=a.slotsOf(e),o=r.map(b=>b.getBoundingClientRect()),c=a.restBreaks(s,e,t.chips,t.reserve);Object.assign(t,{rows:null,floor:null,fit:null,dress:!1,wide:!1}),V.flushSync(()=>s.set({held:!1,breaks:c})),t.swap=i.isBusy(e),t.swap&&V.flushSync(()=>a.freeze(s,e,t)),f.reducedMotion()||r.forEach((b,ne)=>b.isConnected&&i.flip(b,o[ne],t.swap?u/2:u,l))},[s,u,l]);n.useLayoutEffect(()=>{Object.assign(h.current,{duration:u,easing:l})},[u,l]),n.useLayoutEffect(()=>{const e=P.current,t=d.current,r=h.current;if(P.current=g,e===g||!t||!u||f.reducedMotion()||((e^g)&1&&i.shift(t,!!(g&1),u,l,S),!((e|g)&1)||!i.isBusy(t,!0)))return;const o=r.rows,c=o??a.snapRows(w.current);Object.assign(r,{dress:!0,wide:!1,rows:c,reserve:E}),c&&a.freeze(s,t,r),!(c&&r.rows.length<=c.length)&&(Object.assign(r,{wide:!0,rows:o}),a.freeze(s,t,r))},[g,E,s,u,l,S]),n.useLayoutEffect(()=>{const e=h.current,t=d.current,r=e.chips!==y;Object.assign(e,{chips:y,reserve:E}),r&&t&&i.isBusy(t,e.dress)&&a.freeze(s,t,e),I(!r)},[y,E,s]),n.useLayoutEffect(()=>{const e=()=>I(!0,!0),t=typeof ResizeObserver>"u"?null:new ResizeObserver(e);return t?t.observe(d.current):e(),document.fonts?.addEventListener("loadingdone",e),()=>{t?.disconnect(),document.fonts?.removeEventListener("loadingdone",e)}},[]);const te=n.useCallback(e=>{const t=d.current;t&&(w.current=i.snapOf(t,e),e&&(k.current=i.padOf(t)))},[]);return n.useLayoutEffect(()=>{const e=d.current,t=h.current,r=k.current;if(k.current=null,!e||!w.current||!u||f.reducedMotion())return;i.repad(e,r,u,l);const o=i.resizesOf(w.current);o.length&&(t.floor=new Map(o.map(({id:c,width:b})=>[c,b])),a.freeze(s,e,t),f.followHeight(m.current,p,t.fit,u,l,e),i.resize(o,u,l,()=>{S(),I(!1,!0)}))},[A,s,u,l,m,S,p]),n.useEffect(()=>{const e=z&&requestAnimationFrame(()=>ee(!1));return()=>cancelAnimationFrame(e)},[z]),n.useLayoutEffect(()=>{const e=d.current;if(!C)return;let t;const r=()=>s.get().held||!!e?.getAnimations({subtree:!0}).some(c=>c.playState==="running"&&c.effect?.getComputedTiming().endTime<1/0),o=()=>{r()?t=requestAnimationFrame(o):q()};return o(),()=>cancelAnimationFrame(t)},[C,q,s]),n.useLayoutEffect(()=>{const e=w.current;!e||L!==s.get().breaks||(w.current=null,f.reducedMotion()||e.forEach((t,r)=>r.isConnected&&i.flip(r,t,u,l)))},[L,y,A,g,s,u,l]),n.useLayoutEffect(()=>{const e=d.current,t=h.current;!e||!p.value||i.isResizing(e)||f.followHeight(m.current,p,e.offsetHeight,t.duration,t.easing)},[L,G,m,p]),n.useEffect(()=>{v&&H&&N(!1),v&&(!F.length||!O)&&D(!1),s.set({hoverId:null,...!O&&{swipedId:null}})},[F.length,v,H,O,D,N,s]),n.useLayoutEffect(()=>{const e=W.current;if(!x||!e)return;const t=getComputedStyle(e);Y(e.getBoundingClientRect().width+parseFloat(t.marginLeft)+parseFloat(t.marginRight))},[x]),{chipStore:s,delGroup:Z,valueRef:d,delIconRef:W,probe:x,settle:S,held:G,snapshot:te,look:A,dress:g,plain:M,wait:u>0&&!$}}exports.default=oe;
|
package/dist/useChipLayout.js
CHANGED
|
@@ -1,78 +1,77 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useContext as
|
|
3
|
-
import { flushSync as
|
|
4
|
-
import { SelectConfigContext as
|
|
5
|
-
import { watchMotion as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const h = y.findIndex(([, S]) => ae(S.original, o.original));
|
|
13
|
-
if (h >= 0) return [y.splice(h, 1)[0][0], o];
|
|
14
|
-
let m = o.id;
|
|
15
|
-
for (; k.has(m); ) m += "~";
|
|
16
|
-
return k.add(m), [m, o];
|
|
17
|
-
});
|
|
18
|
-
}, Ce = (i) => {
|
|
19
|
-
const [c, s] = I(() => ({ chips: i, keyed: Z(i, []) }));
|
|
20
|
-
if (c.chips === i) return c.keyed;
|
|
21
|
-
const l = Z(i, c.keyed);
|
|
22
|
-
return s({ chips: i, keyed: l }), l;
|
|
23
|
-
};
|
|
24
|
-
function Re(i) {
|
|
25
|
-
const { selectRef: c, duration: s, easing: l, deleteInline: y, deleteAlways: k, icons: o, valueAsOption: h, renderOption: m } = j(oe), { selectedIDs: S, deleting: C, visibility: F, active: x } = j(le), { setDeleting: K, setVisibility: N } = j(ie), [V, $] = I(0), [n] = I(() => ce(pe)), [ee] = I(() => /* @__PURE__ */ new Set()), W = D(n.subscribe, () => n.get().held, () => !1), z = D(n.subscribe, () => n.get().breaks, () => _), te = D(ue, R, () => !1), p = b({ rows: null, reserve: 0, chips: i, swap: !1, duration: s, easing: l }), w = b(null), f = b({ value: 0, root: "", anim: null }), a = b(null), G = b(null), q = y && !k && !C && !!o.remove, J = q ? V + me : 0, L = q && !V && i.length > 0, A = h ? m ? 2 : 1 : 0, B = se((e, t) => {
|
|
26
|
-
const r = a.current, u = p.current;
|
|
2
|
+
import { useContext as D, useState as C, useSyncExternalStore as H, useRef as w, useEffectEvent as me, useCallback as Y, useLayoutEffect as a, useEffect as Z } from "react";
|
|
3
|
+
import { flushSync as _ } from "react-dom";
|
|
4
|
+
import { SelectConfigContext as ge, SelectStateContext as pe, SelectActionsContext as ve, createStore as he } from "./state.js";
|
|
5
|
+
import { watchMotion as we, reducedMotion as b, followHeight as O } from "./utils.js";
|
|
6
|
+
import { NONE as ne, freeze as y, restBreaks as $, slotsOf as be, snapRows as ye } from "./chipGeometry.js";
|
|
7
|
+
import { isResizing as ee, isBusy as E, flip as te, shift as Re, snapOf as Se, padOf as Ce, repad as Oe, resizesOf as Ee, resize as ke } from "./chipMotion.js";
|
|
8
|
+
const Ae = 0.25, Ie = { hoverId: null, swipedId: null, held: !1, breaks: ne };
|
|
9
|
+
function De(m, { height: f, enter: re, leaving: k, onLeft: M }) {
|
|
10
|
+
const { selectRef: g, duration: o, easing: l, deleteInline: q, deleteAlways: N, icons: se, valueAsOption: oe, renderOption: ce } = D(ge), { selectedIDs: T, deleting: p, visibility: W, active: A } = D(pe), { setDeleting: G, setVisibility: K } = D(ve), [V, le] = C(0), [n] = C(() => he(Ie)), [ie] = C(() => /* @__PURE__ */ new Set()), J = H(n.subscribe, () => n.get().held, () => !1), I = H(n.subscribe, () => n.get().breaks, () => ne), ue = H(we, b, () => !1), d = w({ rows: null, reserve: 0, chips: m, swap: !1, dress: !1, wide: !1, duration: o, easing: l }), v = w(null), x = w(null), i = w(null), P = w(null), [z, ae] = C(() => !!re && o > 0 && !b()), F = k || z, Q = !!se.remove, U = q && !N && !p && Q, S = U && !F ? V + Ae : 0, j = U && !V && m.length > 0, L = F ? 3 : oe ? ce ? 2 : 1 : 0, u = Q ? (q || p ? 1 : 0) | (N || p ? 2 : 0) : 0, X = w(u), B = me((e, t) => {
|
|
11
|
+
const r = i.current, s = d.current;
|
|
27
12
|
if (!r) return;
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
13
|
+
const c = ee(r);
|
|
14
|
+
c && t || (e && n.get().held && y(n, r, s), c ? s.fit != null && O(g.current, f, s.fit, s.duration, s.easing, r) : (t || f.value) && O(g.current, f, r.offsetHeight, s.duration, s.easing), n.get().held || n.set({ breaks: $(n, r, s.chips, s.reserve) }));
|
|
15
|
+
}), R = Y(() => {
|
|
16
|
+
const e = i.current, t = d.current;
|
|
17
|
+
if (!e || !n.get().held || E(e, t.dress)) return;
|
|
18
|
+
const r = be(e), s = r.map((h) => h.getBoundingClientRect()), c = $(n, e, t.chips, t.reserve);
|
|
19
|
+
Object.assign(t, { rows: null, floor: null, fit: null, dress: !1, wide: !1 }), _(() => n.set({ held: !1, breaks: c })), t.swap = E(e), t.swap && _(() => y(n, e, t)), b() || r.forEach((h, de) => h.isConnected && te(h, s[de], t.swap ? o / 2 : o, l));
|
|
20
|
+
}, [n, o, l]);
|
|
21
|
+
a(() => {
|
|
22
|
+
Object.assign(d.current, { duration: o, easing: l });
|
|
23
|
+
}, [o, l]), a(() => {
|
|
24
|
+
const e = X.current, t = i.current, r = d.current;
|
|
25
|
+
if (X.current = u, e === u || !t || !o || b() || ((e ^ u) & 1 && Re(t, !!(u & 1), o, l, R), !((e | u) & 1) || !E(t, !0))) return;
|
|
26
|
+
const s = r.rows, c = s ?? ye(v.current);
|
|
27
|
+
Object.assign(r, { dress: !0, wide: !1, rows: c, reserve: S }), c && y(n, t, r), !(c && r.rows.length <= c.length) && (Object.assign(r, { wide: !0, rows: s }), y(n, t, r));
|
|
28
|
+
}, [u, S, n, o, l, R]), a(() => {
|
|
29
|
+
const e = d.current, t = i.current, r = e.chips !== m;
|
|
30
|
+
Object.assign(e, { chips: m, reserve: S }), r && t && E(t, e.dress) && y(n, t, e), B(!r);
|
|
31
|
+
}, [m, S, n]), a(() => {
|
|
40
32
|
const e = () => B(!0, !0), t = typeof ResizeObserver > "u" ? null : new ResizeObserver(e);
|
|
41
|
-
return t ? t.observe(
|
|
33
|
+
return t ? t.observe(i.current) : e(), document.fonts?.addEventListener("loadingdone", e), () => {
|
|
42
34
|
t?.disconnect(), document.fonts?.removeEventListener("loadingdone", e);
|
|
43
35
|
};
|
|
44
36
|
}, []);
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
const t = p.current, r = fe(e), u = r.map((d) => d.getBoundingClientRect()), v = X(n, e, t.chips, t.reserve);
|
|
49
|
-
Object.assign(t, { rows: null, floor: null, fit: null }), T(() => n.set({ held: !1, breaks: v })), t.swap = H(e), t.swap && T(() => E(n, e, t)), R() || r.forEach((d, re) => d.isConnected && Y(d, u[re], t.swap ? s / 2 : s, l));
|
|
50
|
-
}, [n, s, l]), ne = P((e) => {
|
|
51
|
-
a.current && (w.current = de(a.current, e));
|
|
37
|
+
const fe = Y((e) => {
|
|
38
|
+
const t = i.current;
|
|
39
|
+
t && (v.current = Se(t, e), e && (x.current = Ce(t)));
|
|
52
40
|
}, []);
|
|
53
|
-
return
|
|
54
|
-
const e =
|
|
55
|
-
if (!e || !
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
41
|
+
return a(() => {
|
|
42
|
+
const e = i.current, t = d.current, r = x.current;
|
|
43
|
+
if (x.current = null, !e || !v.current || !o || b()) return;
|
|
44
|
+
Oe(e, r, o, l);
|
|
45
|
+
const s = Ee(v.current);
|
|
46
|
+
s.length && (t.floor = new Map(s.map(({ id: c, width: h }) => [c, h])), y(n, e, t), O(g.current, f, t.fit, o, l, e), ke(s, o, l, () => {
|
|
47
|
+
R(), B(!1, !0);
|
|
59
48
|
}));
|
|
60
|
-
}, [
|
|
61
|
-
const e =
|
|
62
|
-
|
|
63
|
-
}, [z
|
|
64
|
-
const e =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
49
|
+
}, [L, n, o, l, g, R, f]), Z(() => {
|
|
50
|
+
const e = z && requestAnimationFrame(() => ae(!1));
|
|
51
|
+
return () => cancelAnimationFrame(e);
|
|
52
|
+
}, [z]), a(() => {
|
|
53
|
+
const e = i.current;
|
|
54
|
+
if (!k) return;
|
|
55
|
+
let t;
|
|
56
|
+
const r = () => n.get().held || !!e?.getAnimations({ subtree: !0 }).some((c) => c.playState === "running" && c.effect?.getComputedTiming().endTime < 1 / 0), s = () => {
|
|
57
|
+
r() ? t = requestAnimationFrame(s) : M();
|
|
58
|
+
};
|
|
59
|
+
return s(), () => cancelAnimationFrame(t);
|
|
60
|
+
}, [k, M, n]), a(() => {
|
|
61
|
+
const e = v.current;
|
|
62
|
+
!e || I !== n.get().breaks || (v.current = null, b() || e.forEach((t, r) => r.isConnected && te(r, t, o, l)));
|
|
63
|
+
}, [I, m, L, u, n, o, l]), a(() => {
|
|
64
|
+
const e = i.current, t = d.current;
|
|
65
|
+
!e || !f.value || ee(e) || O(g.current, f, e.offsetHeight, t.duration, t.easing);
|
|
66
|
+
}, [I, J, g, f]), Z(() => {
|
|
67
|
+
p && W && K(!1), p && (!T.length || !A) && G(!1), n.set({ hoverId: null, ...!A && { swipedId: null } });
|
|
68
|
+
}, [T.length, p, W, A, G, K, n]), a(() => {
|
|
69
|
+
const e = P.current;
|
|
70
|
+
if (!j || !e) return;
|
|
71
71
|
const t = getComputedStyle(e);
|
|
72
|
-
|
|
73
|
-
}, [
|
|
72
|
+
le(e.getBoundingClientRect().width + parseFloat(t.marginLeft) + parseFloat(t.marginRight));
|
|
73
|
+
}, [j]), { chipStore: n, delGroup: ie, valueRef: i, delIconRef: P, probe: j, settle: R, held: J, snapshot: fe, look: L, dress: u, plain: F, wait: o > 0 && !ue };
|
|
74
74
|
}
|
|
75
75
|
export {
|
|
76
|
-
|
|
77
|
-
Ce as useChipKeys
|
|
76
|
+
De as default
|
|
78
77
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const T=require("react"),L=require("./state.cjs"),M=require("./utils.cjs"),S={index:-1,fallback:-1,ready:!1},D=({index:r,fallback:l})=>r===-1?l:r,U=10,C=500,V=new Set(["ArrowDown","ArrowUp","PageDown","PageUp","Home","End"]),_=(r,l)=>T.useMemo(()=>{const c=new Set(r.map(s=>s.group).filter(Boolean)),i=s=>!!s&&!s.disabled&&!s.loading&&(s.groupHeader?c.has(s.name):!s.group||l.has(s.group));return{reach:i,list:r.flatMap((s,f)=>i(s)?[f]:[])}},[r,l]),z=(r,l,c,i)=>{const s=r.length-1;if(s<0)return-1;if(c==="Home")return r[0];if(c==="End")return r[s];const f=c==="ArrowUp"||c==="PageUp"?-1:1,u=r.findIndex(h=>h>=l),a=(r[u]===l?u:(u===-1?r.length:u)-(f>0?1:0))+f*(c.startsWith("Page")?U:1);return a>=0&&a<=s?r[a]:c.startsWith("Page")||i?r[a<0?0:s]:r[(a+r.length)%r.length]},I=(r,l,c,i)=>{const s=[...i].every(a=>a===i[0]),f=s?i[0]:i,u=l.filter(a=>"original"in r[a]),o=Math.max(u.indexOf(c)+(s?1:0),0);for(let a=0;a<u.length;a++){const h=u[(o+a)%u.length];if(String(r[h].name).toLowerCase().startsWith(f))return h}return-1};function R({props:r,state:l,setState:c,normalizedOptions:i,expandedGroups:s,selected:f,selectedIDs:u,visibility:o,setVisibility:a,modelActions:h,highlightStore:w}){const{disabled:E,multiple:y,hasMore:F,loadButton:P,icons:H,onFocus:k,onBlur:q,onKeyDown:A}=r,{selectOption:B,clear:W,removeOption:j}=h,{deleting:v}=l,{reach:x,list:m}=_(i,s),d=T.useRef({lastWindowFocusTime:0,justFocused:!1,focusTimeout:null,query:"",queryTimeout:null,row:-1}),p=T.useMemo(()=>{const e=new Set(y?u.map(n=>n.id):f?[f.id]:[]),t=e.size?i.findIndex(n=>e.has(n.id)&&x(n)):-1;return t!==-1?t:m.find(n=>!i[n].groupHeader)??m[0]??-1},[i,f,u,y,x,m]);T.useLayoutEffect(()=>{const{index:e}=w.get(),{row:t}=d.current,n=e===-1||x(i[e])||i[e]?.loadMore?e:e===t?m.find(g=>g>t)??m.at(-1)??-1:-1;d.current.row=i[n]?.loadMore?n:-1,w.set({fallback:p,index:n})}),T.useEffect(()=>{const e=d.current,t=()=>e.lastWindowFocusTime=Date.now();return window.addEventListener("focus",t),()=>{window.removeEventListener("focus",t),clearTimeout(e.focusTimeout),clearTimeout(e.queryTimeout)}},[]);const b=e=>w.set({index:e}),K=(e,t)=>{const n=d.current;clearTimeout(n.queryTimeout),n.queryTimeout=setTimeout(()=>n.query="",C),n.query+=e.toLowerCase();const g=I(i,m,t,n.query);g!==-1&&b(g),o||a(!0)};return L.useStableActions({highlight:b,handleBlur:e=>{const t=e.relatedTarget?.closest(".rac-options");e.currentTarget.contains(e.relatedTarget)||t||(q?.(e),v&&c({deleting:!1}),o&&a(!1))},handleFocus:e=>{const t=e.currentTarget.contains(e.relatedTarget);t||k?.(e),!(t||e.target!==e.currentTarget||o||E||v||document.hidden||Date.now()-d.current.lastWindowFocusTime<100)&&(clearTimeout(d.current.focusTimeout),d.current.focusTimeout=setTimeout(()=>d.current.justFocused=!1,200),d.current.justFocused=!0,a(!0))},toggleVisibility:e=>{if(v){M.stopEvent(e),c({deleting:!1});return}E||d.current.justFocused||a(!o)},handleKeyDown:e=>{if(A?.(e),e.defaultPrevented||E||e.nativeEvent?.isComposing)return;const{key:t}=e;if(e.target!==e.currentTarget&&(t==="Enter"||t.length===1))return;const n=D(w.get());if(t.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&(t!==" "||d.current.query)){e.preventDefault(),K(t,n);return}if(V.has(t)){e.preventDefault(),(o||t==="Home"||t==="End")&&b(z(m,n,t,!P&&F)),o||a(!0);return}switch(t){case"Enter":case" ":e.preventDefault(),o?n!==-1&&i[n]&&(b(n),B(i[n],e)):a(!0);break;case"Escape":if(v)c({deleting:!1});else if(o)a(!1);else break;M.stopEvent(e);break;case"Tab":o&&a(!1);break;case"Backspace":case"Delete":{const g=u.at(-1);if(y&&t==="Backspace"&&H.remove&&g)j(g.id);else if(H.clear&&(f||g))W();else break;e.preventDefault();break}}}})}exports.default=R;exports.effectiveHighlight=D;exports.initialHighlight=S;
|
|
@@ -2,98 +2,96 @@
|
|
|
2
2
|
import { useMemo as F, useRef as L, useLayoutEffect as j, useEffect as U } from "react";
|
|
3
3
|
import { useStableActions as C } from "./state.js";
|
|
4
4
|
import { stopEvent as D } from "./utils.js";
|
|
5
|
-
const Q = { index: -1, fallback: -1, ready: !1 }, S = ({ index: r, fallback:
|
|
6
|
-
const
|
|
7
|
-
return { reach:
|
|
8
|
-
}, [r,
|
|
9
|
-
const
|
|
10
|
-
if (
|
|
11
|
-
if (
|
|
12
|
-
if (
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const h = l[(s + c) % l.length];
|
|
21
|
-
if (String(r[h].name).toLowerCase().startsWith(o)) return h;
|
|
5
|
+
const Q = { index: -1, fallback: -1, ready: !1 }, S = ({ index: r, fallback: l }) => r === -1 ? l : r, V = 10, z = 500, I = /* @__PURE__ */ new Set(["ArrowDown", "ArrowUp", "PageDown", "PageUp", "Home", "End"]), R = (r, l) => F(() => {
|
|
6
|
+
const s = new Set(r.map((o) => o.group).filter(Boolean)), c = (o) => !!o && !o.disabled && !o.loading && (o.groupHeader ? s.has(o.name) : !o.group || l.has(o.group));
|
|
7
|
+
return { reach: c, list: r.flatMap((o, f) => c(o) ? [f] : []) };
|
|
8
|
+
}, [r, l]), Y = (r, l, s, c) => {
|
|
9
|
+
const o = r.length - 1;
|
|
10
|
+
if (o < 0) return -1;
|
|
11
|
+
if (s === "Home") return r[0];
|
|
12
|
+
if (s === "End") return r[o];
|
|
13
|
+
const f = s === "ArrowUp" || s === "PageUp" ? -1 : 1, i = r.findIndex((h) => h >= l), a = (r[i] === l ? i : (i === -1 ? r.length : i) - (f > 0 ? 1 : 0)) + f * (s.startsWith("Page") ? V : 1);
|
|
14
|
+
return a >= 0 && a <= o ? r[a] : s.startsWith("Page") || c ? r[a < 0 ? 0 : o] : r[(a + r.length) % r.length];
|
|
15
|
+
}, _ = (r, l, s, c) => {
|
|
16
|
+
const o = [...c].every((a) => a === c[0]), f = o ? c[0] : c, i = l.filter((a) => "original" in r[a]), u = Math.max(i.indexOf(s) + (o ? 1 : 0), 0);
|
|
17
|
+
for (let a = 0; a < i.length; a++) {
|
|
18
|
+
const h = i[(u + a) % i.length];
|
|
19
|
+
if (String(r[h].name).toLowerCase().startsWith(f)) return h;
|
|
22
20
|
}
|
|
23
21
|
return -1;
|
|
24
22
|
};
|
|
25
|
-
function X({ props: r, state:
|
|
26
|
-
const { disabled: v, multiple: E, hasMore: k, loadButton: H, icons: x, onFocus: P, onBlur:
|
|
27
|
-
const e = new Set(E ?
|
|
28
|
-
return t !== -1 ? t : g.find((
|
|
29
|
-
}, [
|
|
23
|
+
function X({ props: r, state: l, setState: s, normalizedOptions: c, expandedGroups: o, selected: f, selectedIDs: i, visibility: u, setVisibility: a, modelActions: h, highlightStore: w }) {
|
|
24
|
+
const { disabled: v, multiple: E, hasMore: k, loadButton: H, icons: x, onFocus: P, onBlur: M, onKeyDown: p } = r, { selectOption: A, clear: B, removeOption: W } = h, { deleting: T } = l, { reach: y, list: g } = R(c, o), d = L({ lastWindowFocusTime: 0, justFocused: !1, focusTimeout: null, query: "", queryTimeout: null, row: -1 }), q = F(() => {
|
|
25
|
+
const e = new Set(E ? i.map((n) => n.id) : f ? [f.id] : []), t = e.size ? c.findIndex((n) => e.has(n.id) && y(n)) : -1;
|
|
26
|
+
return t !== -1 ? t : g.find((n) => !c[n].groupHeader) ?? g[0] ?? -1;
|
|
27
|
+
}, [c, f, i, E, y, g]);
|
|
30
28
|
j(() => {
|
|
31
|
-
const { index: e } =
|
|
32
|
-
|
|
29
|
+
const { index: e } = w.get(), { row: t } = d.current, n = e === -1 || y(c[e]) || c[e]?.loadMore ? e : e === t ? g.find((m) => m > t) ?? g.at(-1) ?? -1 : -1;
|
|
30
|
+
d.current.row = c[n]?.loadMore ? n : -1, w.set({ fallback: q, index: n });
|
|
33
31
|
}), U(() => {
|
|
34
32
|
const e = d.current, t = () => e.lastWindowFocusTime = Date.now();
|
|
35
33
|
return window.addEventListener("focus", t), () => {
|
|
36
34
|
window.removeEventListener("focus", t), clearTimeout(e.focusTimeout), clearTimeout(e.queryTimeout);
|
|
37
35
|
};
|
|
38
36
|
}, []);
|
|
39
|
-
const b = (e) =>
|
|
40
|
-
const
|
|
41
|
-
clearTimeout(
|
|
42
|
-
const m = _(
|
|
43
|
-
m !== -1 && b(m),
|
|
37
|
+
const b = (e) => w.set({ index: e }), K = (e, t) => {
|
|
38
|
+
const n = d.current;
|
|
39
|
+
clearTimeout(n.queryTimeout), n.queryTimeout = setTimeout(() => n.query = "", z), n.query += e.toLowerCase();
|
|
40
|
+
const m = _(c, g, t, n.query);
|
|
41
|
+
m !== -1 && b(m), u || a(!0);
|
|
44
42
|
};
|
|
45
43
|
return C({
|
|
46
44
|
highlight: b,
|
|
47
45
|
handleBlur: (e) => {
|
|
48
46
|
const t = e.relatedTarget?.closest(".rac-options");
|
|
49
|
-
e.currentTarget.contains(e.relatedTarget) || t || (
|
|
47
|
+
e.currentTarget.contains(e.relatedTarget) || t || (M?.(e), T && s({ deleting: !1 }), u && a(!1));
|
|
50
48
|
},
|
|
51
49
|
// [DOC: select-behavior]
|
|
52
50
|
handleFocus: (e) => {
|
|
53
51
|
const t = e.currentTarget.contains(e.relatedTarget);
|
|
54
|
-
t || P?.(e), !(t || e.target !== e.currentTarget ||
|
|
52
|
+
t || P?.(e), !(t || e.target !== e.currentTarget || u || v || T || document.hidden || Date.now() - d.current.lastWindowFocusTime < 100) && (clearTimeout(d.current.focusTimeout), d.current.focusTimeout = setTimeout(() => d.current.justFocused = !1, 200), d.current.justFocused = !0, a(!0));
|
|
55
53
|
},
|
|
56
54
|
toggleVisibility: (e) => {
|
|
57
|
-
if (
|
|
58
|
-
D(e),
|
|
55
|
+
if (T) {
|
|
56
|
+
D(e), s({ deleting: !1 });
|
|
59
57
|
return;
|
|
60
58
|
}
|
|
61
|
-
v || d.current.justFocused ||
|
|
59
|
+
v || d.current.justFocused || a(!u);
|
|
62
60
|
},
|
|
63
61
|
handleKeyDown: (e) => {
|
|
64
|
-
if (
|
|
62
|
+
if (p?.(e), e.defaultPrevented || v || e.nativeEvent?.isComposing) return;
|
|
65
63
|
const { key: t } = e;
|
|
66
64
|
if (e.target !== e.currentTarget && (t === "Enter" || t.length === 1)) return;
|
|
67
|
-
const
|
|
65
|
+
const n = S(w.get());
|
|
68
66
|
if (t.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (t !== " " || d.current.query)) {
|
|
69
|
-
e.preventDefault(), K(t,
|
|
67
|
+
e.preventDefault(), K(t, n);
|
|
70
68
|
return;
|
|
71
69
|
}
|
|
72
|
-
if (
|
|
73
|
-
e.preventDefault(), (
|
|
70
|
+
if (I.has(t)) {
|
|
71
|
+
e.preventDefault(), (u || t === "Home" || t === "End") && b(Y(g, n, t, !H && k)), u || a(!0);
|
|
74
72
|
return;
|
|
75
73
|
}
|
|
76
74
|
switch (t) {
|
|
77
75
|
case "Enter":
|
|
78
76
|
case " ":
|
|
79
|
-
e.preventDefault(),
|
|
77
|
+
e.preventDefault(), u ? n !== -1 && c[n] && (b(n), A(c[n], e)) : a(!0);
|
|
80
78
|
break;
|
|
81
79
|
// [DOC: select-behavior]
|
|
82
80
|
case "Escape":
|
|
83
|
-
if (
|
|
84
|
-
else if (
|
|
81
|
+
if (T) s({ deleting: !1 });
|
|
82
|
+
else if (u) a(!1);
|
|
85
83
|
else break;
|
|
86
84
|
D(e);
|
|
87
85
|
break;
|
|
88
86
|
case "Tab":
|
|
89
|
-
|
|
87
|
+
u && a(!1);
|
|
90
88
|
break;
|
|
91
89
|
// [DOC: select-behavior]
|
|
92
90
|
case "Backspace":
|
|
93
91
|
case "Delete": {
|
|
94
|
-
const m =
|
|
95
|
-
if (E && t === "Backspace" && x.remove && m)
|
|
96
|
-
else if (x.clear && (
|
|
92
|
+
const m = i.at(-1);
|
|
93
|
+
if (E && t === "Backspace" && x.remove && m) W(m.id);
|
|
94
|
+
else if (x.clear && (f || m)) B();
|
|
97
95
|
else break;
|
|
98
96
|
e.preventDefault();
|
|
99
97
|
break;
|
package/dist/utils.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),d=require("react"),p={XMark:({className:t="",...e})=>n.jsx("svg",{className:t,viewBox:"0 0 320 512",fill:"currentColor","aria-hidden":"true",height:"1em",width:"1em",...e,children:n.jsx("path",{d:"M310.6 361.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L160 301.3 54.6 406.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L114.7 256 9.4 150.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 210.7 265.4 105.4c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3L205.3 256l105.3 105.4z"})}),ArrowUp:({className:t="",...e})=>n.jsx("svg",{className:t,viewBox:"0 0 448 512",fill:"currentColor","aria-hidden":"true",height:"1em",width:"1em",...e,children:n.jsx("path",{d:"M34.9 289.5l175.9-175.8c9.4-9.4 24.6-9.4 33.9 0L420.1 289.5c15.1 15.1 4.4 41-17 41H51.9c-21.4 0-32.1-25.9-17-41z"})}),Checkmark:({className:t="",...e})=>n.jsx("svg",{className:t,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",height:"1em",width:"1em",...e,children:n.jsx("path",{d:"M20.285 6.708a1 1 0 0 0-1.414-1.416l-9.192 9.192-4.243-4.244a1 1 0 1 0-1.414 1.416l5 5a1 1 0 0 0 1.414 0l9.849-9.948z"})})},j=(t,e)=>{if(!t)return null;const i=(
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),d=require("react"),p={XMark:({className:t="",...e})=>n.jsx("svg",{className:t,viewBox:"0 0 320 512",fill:"currentColor","aria-hidden":"true",height:"1em",width:"1em",...e,children:n.jsx("path",{d:"M310.6 361.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L160 301.3 54.6 406.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L114.7 256 9.4 150.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 210.7 265.4 105.4c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3L205.3 256l105.3 105.4z"})}),ArrowUp:({className:t="",...e})=>n.jsx("svg",{className:t,viewBox:"0 0 448 512",fill:"currentColor","aria-hidden":"true",height:"1em",width:"1em",...e,children:n.jsx("path",{d:"M34.9 289.5l175.9-175.8c9.4-9.4 24.6-9.4 33.9 0L420.1 289.5c15.1 15.1 4.4 41-17 41H51.9c-21.4 0-32.1-25.9-17-41z"})}),Checkmark:({className:t="",...e})=>n.jsx("svg",{className:t,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",height:"1em",width:"1em",...e,children:n.jsx("path",{d:"M20.285 6.708a1 1 0 0 0-1.414-1.416l-9.192 9.192-4.243-4.244a1 1 0 1 0-1.414 1.416l5 5a1 1 0 0 0 1.414 0l9.849-9.948z"})})},j=(t,e)=>{if(!t)return null;const i=(r={})=>({...e,...r,style:{...e?.style,...r?.style}});if(typeof t=="string")return n.jsx("img",{src:t,...i(),className:u("rac-icon",e?.className),alt:""});if(d.isValidElement(t))return d.cloneElement(t,i(t.props));if(typeof t=="function"||typeof t=="object"&&t.$$typeof){const r=t;return n.jsx(r,{...i()})}return null},v=(t,e)=>`${t}-${String(e).replace(/[^A-Za-z0-9-]/gu,i=>`_${i.codePointAt(0).toString(36)}_`)}`,m=t=>t?"":void 0,u=(t,e)=>e?`${t} ${e}`:t,y=(t,e,i)=>t.jsx||(e&&"original"in t?e(t.original,{selected:i,disabled:!!t.disabled}):null),E=n.jsxs("span",{className:"rac-dots","aria-hidden":"true",children:[n.jsx("i",{}),n.jsx("i",{}),n.jsx("i",{})]}),C=(()=>{try{return process.env.NODE_ENV!=="production"}catch{return!1}})(),h=new Set,M=(t,e)=>{!C||h.has(t)||(h.add(t),console.warn(`[react-animated-select] ${e}`))},b=t=>{t?.stopPropagation(),t?.preventDefault()},S=(t,e)=>{t?.currentTarget.contains(document.activeElement)&&e.current?.focus()},g="(prefers-reduced-motion: reduce)",f=()=>!!window.matchMedia?.(g).matches,$=t=>{const e=window.matchMedia?.(g);return e?.addEventListener("change",t),()=>e?.removeEventListener("change",t)},D=(t,e,i,r,w,s)=>{if(!t||i===e.value)return;const o=getComputedStyle(t),c=e.anim?.playState==="running"?o.height:e.root;e.anim?.cancel(),s&&Object.assign(s.style,{height:`${i}px`,boxSizing:"border-box"}),e.root=o.height,s&&Object.assign(s.style,{height:"",boxSizing:""});const x=!e.value||c===e.root||!t.animate||f();if(e.value=i,e.anim=null,x)return;const a={overflow:"hidden",alignItems:"flex-start"},l=e.anim=t.animate([{...a,height:c},{...a,height:e.root}],{duration:r,easing:w});l.onfinish=()=>{e.anim===l&&(e.anim=null)}};exports.dots=E;exports.flag=m;exports.followHeight=D;exports.icons=p;exports.optionContent=y;exports.optionDomId=v;exports.reducedMotion=f;exports.refocus=S;exports.renderIcon=j;exports.stopEvent=b;exports.warnOnce=M;exports.watchMotion=$;exports.withClass=u;
|