react-animated-select 0.7.7 → 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.
Files changed (47) hide show
  1. package/dist/base.css +1 -0
  2. package/dist/chip.cjs +1 -0
  3. package/dist/chip.css +1 -0
  4. package/dist/chip.js +113 -0
  5. package/dist/chipGeometry.cjs +1 -0
  6. package/dist/chipGeometry.js +37 -0
  7. package/dist/chipMotion.cjs +1 -0
  8. package/dist/chipMotion.js +85 -0
  9. package/dist/dropdown.cjs +1 -0
  10. package/dist/dropdown.js +70 -0
  11. package/dist/dropdownPosition.cjs +1 -0
  12. package/dist/dropdownPosition.js +97 -0
  13. package/dist/index.cjs +1 -1
  14. package/dist/index.d.cts +41 -1
  15. package/dist/index.js +13 -0
  16. package/dist/liveRegion.cjs +1 -0
  17. package/dist/liveRegion.js +42 -0
  18. package/dist/model.cjs +1 -0
  19. package/dist/model.js +138 -0
  20. package/dist/motion.cjs +1 -0
  21. package/dist/motion.js +122 -0
  22. package/dist/optionList.cjs +1 -0
  23. package/dist/optionList.js +105 -0
  24. package/dist/paging.cjs +1 -0
  25. package/dist/paging.js +47 -0
  26. package/dist/select.cjs +1 -0
  27. package/dist/select.js +165 -0
  28. package/dist/state.cjs +1 -0
  29. package/dist/state.js +50 -0
  30. package/dist/style.css +4 -0
  31. package/dist/theme.css +1 -0
  32. package/dist/trigger.cjs +1 -0
  33. package/dist/trigger.js +99 -0
  34. package/dist/useChipLayout.cjs +1 -0
  35. package/dist/useChipLayout.js +77 -0
  36. package/dist/useSelect.cjs +1 -0
  37. package/dist/useSelect.js +100 -0
  38. package/dist/useSelectBehavior.cjs +1 -0
  39. package/dist/useSelectBehavior.js +107 -0
  40. package/dist/useSelectModel.cjs +1 -0
  41. package/dist/useSelectModel.js +59 -0
  42. package/dist/utils.cjs +1 -0
  43. package/dist/utils.js +99 -0
  44. package/index.d.ts +41 -1
  45. package/package.json +4 -4
  46. package/dist/index.css +0 -1
  47. package/dist/index.es.js +0 -1299
@@ -0,0 +1,105 @@
1
+ "use client";
2
+ import { jsx as m, jsxs as v } from "react/jsx-runtime";
3
+ import { SelectConfigContext as x, SelectStateContext as $, SelectActionsContext as E } from "./state.js";
4
+ import { memo as H, useContext as f, useMemo as j, useRef as M, useSyncExternalStore as A, useLayoutEffect as R } from "react";
5
+ import { effectiveHighlight as T } from "./useSelectBehavior.js";
6
+ import { optionDomId as y, flag as g, withClass as w, renderIcon as k, optionContent as _, dots as z } from "./utils.js";
7
+ import { Collapse as G } from "./motion.js";
8
+ const C = 0, V = 1, S = 2, L = (b) => {
9
+ const { highlightStore: e } = f(x), l = M(null), a = A(e.subscribe, () => {
10
+ const r = e.get();
11
+ return T(r) !== b ? C : r.ready ? S : V;
12
+ }, () => C);
13
+ return R(() => {
14
+ a === S && l.current?.scrollIntoView?.({ block: "nearest" });
15
+ }, [a]), [l, a !== C];
16
+ }, D = (b, e) => `${y(b, e.id)}_l`, Y = /* @__PURE__ */ H(function({ option: e, index: l, open: a, hasChildren: r }) {
17
+ const { selectId: o, icons: c, texts: u } = f(x), { selectOption: I, highlight: p } = f(E), [i, n] = L(l), t = r && !e.disabled;
18
+ return /* @__PURE__ */ v(
19
+ "div",
20
+ {
21
+ className: w("rac-group", e.className),
22
+ onMouseEnter: () => t && p(l),
23
+ onClick: (h) => I(e, h),
24
+ "aria-label": t ? `${e.name}, ${a ? u.groupOpen : u.groupClosed}` : void 0,
25
+ "aria-disabled": !t || void 0,
26
+ "data-highlighted": g(n),
27
+ "data-disabled": g(e.disabled),
28
+ id: y(o, e.id),
29
+ "data-open": g(a),
30
+ "aria-selected": "false",
31
+ style: e.style,
32
+ role: "option",
33
+ ref: i,
34
+ children: [
35
+ /* @__PURE__ */ m("span", { className: "rac-group-text", id: D(o, e), children: e.name }),
36
+ /* @__PURE__ */ m(G, { axis: "x", in: r && !e.disabled, className: "rac-group-arrow", "aria-hidden": "true", children: k(c.arrow) })
37
+ ]
38
+ }
39
+ );
40
+ }), q = /* @__PURE__ */ H(function({ option: e, index: l, isSelected: a, showCheckbox: r }) {
41
+ const { selectId: o, icons: c, renderOption: u } = f(x), { selectOption: I, highlight: p } = f(E), [i, n] = L(l), t = !e.disabled && !e.loading, h = _(e, u, a);
42
+ return /* @__PURE__ */ v(
43
+ "div",
44
+ {
45
+ className: w("rac-option", e.className),
46
+ onMouseEnter: () => t && p(l),
47
+ onClick: (N) => !e.loading && I(e, N),
48
+ "aria-disabled": e.disabled || e.loading,
49
+ "data-invalid": g(e.invalid),
50
+ "data-bool": typeof e.raw == "boolean" ? String(e.raw) : void 0,
51
+ "data-highlighted": g(n),
52
+ "data-loading": g(e.loading),
53
+ id: y(o, e.id),
54
+ "aria-selected": a,
55
+ style: e.style,
56
+ role: "option",
57
+ ref: i,
58
+ children: [
59
+ h ? /* @__PURE__ */ m("div", { className: "rac-option-jsx", children: h }) : /* @__PURE__ */ m("span", { className: "rac-option-text", children: e.name }),
60
+ e.loading && z,
61
+ r && /* @__PURE__ */ v("div", { className: "rac-check", "data-default": g(!c.checkbox), children: [
62
+ k(c.check, { className: "rac-checkmark" }),
63
+ k(c.checkbox, { className: "rac-check-icon" })
64
+ ] })
65
+ ]
66
+ }
67
+ );
68
+ }), U = /* @__PURE__ */ H(function() {
69
+ const { selectId: e, multiple: l } = f(x), { normalizedOptions: a, selected: r, selectedIDs: o, expandedGroups: c } = f($), u = r?.id;
70
+ return j(() => {
71
+ const I = new Set(o.map((s) => s.id)), p = a.reduce((s, d) => (d.group && (s[d.group] = (s[d.group] || 0) + 1), s), {}), i = [];
72
+ let n = [], t = null, h = null;
73
+ const N = () => {
74
+ t !== null && n.length && i.push(
75
+ /* @__PURE__ */ m(G, { axis: "y", in: c.has(t), className: "rac-group-items", role: "group", "aria-labelledby": h, children: n }, `slide-${t}`)
76
+ ), n = [];
77
+ }, O = (s, d) => /* @__PURE__ */ m(
78
+ q,
79
+ {
80
+ isSelected: I.has(s.id) || u === s.id,
81
+ showCheckbox: l && !s.disabled && "original" in s,
82
+ option: s,
83
+ index: d
84
+ },
85
+ s.id
86
+ );
87
+ return a.forEach((s, d) => {
88
+ s.groupHeader ? (N(), t = s.name, h = D(e, s), i.push(
89
+ /* @__PURE__ */ m(
90
+ Y,
91
+ {
92
+ hasChildren: p[s.name] > 0,
93
+ open: c.has(s.name),
94
+ option: s,
95
+ index: d
96
+ },
97
+ s.id
98
+ )
99
+ )) : s.group ? n.push(O(s, d)) : (N(), t = null, i.push(O(s, d)));
100
+ }), N(), i;
101
+ }, [a, u, o, c, l, e]);
102
+ });
103
+ export {
104
+ U as default
105
+ };
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("react/jsx-runtime"),e=require("react"),p=require("./state.cjs"),A=require("./useSelectBehavior.cjs"),H=require("./dropdown.cjs"),I=require("./utils.cjs"),L=({props:{hasMore:d,loadMore:n},lock:t,setPending:s})=>{if(!d||t.current)return;if(!n)return I.warnOnce("no loadMore","`hasMore` is set, but there is no `loadMore` to call.");t.current=!0,s(!0);const o=()=>s(!1);try{n()?.then?.(o,o)}catch(g){t.current=!1,o(),(globalThis.reportError??console.error)(g)}},P=({hasMore:d,loadButton:n,loadPending:t,moreText:s,pendingText:o})=>d&&n?{id:"special-load-more-id",name:t?o:s,loadMore:!0,loading:t,type:"special"}:null,q=e.memo(function(){const{highlightStore:n,hasMore:t,loadButton:s,loadOffset:o,loadAhead:g}=e.useContext(p.SelectConfigContext),{visibility:i,normalizedOptions:E,loadPending:M}=e.useContext(p.SelectStateContext),{loadMoreOnce:c}=e.useContext(p.SelectActionsContext),m=e.useRef(null),l=!s&&t,u=E.length,[h,O]=e.useState(u);!M&&h!==u&&O(u);const b=e.useSyncExternalStore(n.subscribe,()=>{const a=A.effectiveHighlight(n.get());return a>=u-g?a:null},()=>null);return e.useLayoutEffect(()=>{l&&b!==null&&i&&c()},[l,b,i,u,c]),e.useEffect(()=>{const a=m.current,r=l&&i&&a?.parentElement;if(!r||typeof IntersectionObserver>"u")return;let f=!1;const x=Number(o),v=Number.isFinite(x)?x:0,w=v-(parseFloat(getComputedStyle(r).paddingBottom)||0),S=new IntersectionObserver(F=>{const{isIntersecting:B,boundingClientRect:R,rootBounds:C}=F.at(-1);f=B&&!!C&&R.bottom<=C.bottom+.5,f&&c()},{root:r,rootMargin:`0px 0px ${w}px 0px`,threshold:[0,1]});S.observe(a);const y=()=>{f&&r.scrollHeight-r.scrollTop<=r.clientHeight+v&&c()};return r.addEventListener("scroll",y,{passive:!0}),()=>{S.disconnect(),r.removeEventListener("scroll",y)}},[l,i,o,h,c]),j.jsx(H.StatusRow,{ref:m,more:l})}),T={Footer:q,request:L,row:P};exports.PagingFooter=q;exports.paging=T;
package/dist/paging.js ADDED
@@ -0,0 +1,47 @@
1
+ "use client";
2
+ import { jsx as B } from "react/jsx-runtime";
3
+ import { memo as H, useContext as p, useRef as I, useState as L, useSyncExternalStore as R, useLayoutEffect as N, useEffect as T } from "react";
4
+ import { SelectConfigContext as j, SelectStateContext as q, SelectActionsContext as z } from "./state.js";
5
+ import { effectiveHighlight as P } from "./useSelectBehavior.js";
6
+ import { StatusRow as $ } from "./dropdown.js";
7
+ import { warnOnce as D } from "./utils.js";
8
+ const G = ({ props: { hasMore: u, loadMore: r }, lock: e, setPending: n }) => {
9
+ if (!u || e.current) return;
10
+ if (!r) return D("no loadMore", "`hasMore` is set, but there is no `loadMore` to call.");
11
+ e.current = !0, n(!0);
12
+ const t = () => n(!1);
13
+ try {
14
+ r()?.then?.(t, t);
15
+ } catch (f) {
16
+ e.current = !1, t(), (globalThis.reportError ?? console.error)(f);
17
+ }
18
+ }, J = ({ hasMore: u, loadButton: r, loadPending: e, moreText: n, pendingText: t }) => u && r ? { id: "special-load-more-id", name: e ? t : n, loadMore: !0, loading: e, type: "special" } : null, K = /* @__PURE__ */ H(function() {
19
+ const { highlightStore: r, hasMore: e, loadButton: n, loadOffset: t, loadAhead: f } = p(j), { visibility: s, normalizedOptions: C, loadPending: E } = p(q), { loadMoreOnce: i } = p(z), d = I(null), c = !n && e, l = C.length, [g, M] = L(l);
20
+ !E && g !== l && M(l);
21
+ const h = R(r.subscribe, () => {
22
+ const a = P(r.get());
23
+ return a >= l - f ? a : null;
24
+ }, () => null);
25
+ return N(() => {
26
+ c && h !== null && s && i();
27
+ }, [c, h, s, l, i]), T(() => {
28
+ const a = d.current, o = c && s && a?.parentElement;
29
+ if (!o || typeof IntersectionObserver > "u") return;
30
+ let m = !1;
31
+ const b = Number(t), x = Number.isFinite(b) ? b : 0, O = x - (parseFloat(getComputedStyle(o).paddingBottom) || 0), v = new IntersectionObserver((w) => {
32
+ const { isIntersecting: F, boundingClientRect: A, rootBounds: y } = w.at(-1);
33
+ m = F && !!y && A.bottom <= y.bottom + 0.5, m && i();
34
+ }, { root: o, rootMargin: `0px 0px ${O}px 0px`, threshold: [0, 1] });
35
+ v.observe(a);
36
+ const S = () => {
37
+ m && o.scrollHeight - o.scrollTop <= o.clientHeight + x && i();
38
+ };
39
+ return o.addEventListener("scroll", S, { passive: !0 }), () => {
40
+ v.disconnect(), o.removeEventListener("scroll", S);
41
+ };
42
+ }, [c, s, t, g, i]), /* @__PURE__ */ B($, { ref: d, more: c });
43
+ }), Z = { Footer: K, request: G, row: J };
44
+ export {
45
+ K as PagingFooter,
46
+ Z as paging
47
+ };
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),g=require("./state.cjs"),v=require("react"),M=require("./trigger.cjs"),T=require("./dropdown.cjs"),A=require("./liveRegion.cjs"),d=require("./utils.cjs"),q=require("./useSelect.cjs");;/* empty css */;/* empty css */const E={},l=e=>e!=null&&e!=="",w=e=>e?typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(w).join(" ").replace(/\s+/g," ").trim():v.isValidElement(e)?w(e.props.children):"":"",j=({name:e,label:o,id:t,value:s,className:a,style:n,children:i,disabled:c,group:r},h,x)=>{const u=w(i),O=s!==void 0?s:u;return i!=null&&!u&&!l(o)&&!l(e)&&!l(t)&&!l(s)&&d.warnOnce("no text","<Option> has content but no text to show in the title or chips. Add a `label` (or `value`), or enable `valueAsOption`."),{id:l(t)?String(t):h,userId:l(t)?t:O,value:O,label:l(o)?String(o):l(e)?String(e):u||(l(t)?String(t):""),jsx:i,hasJsx:i!=null,className:a,style:n,disabled:!!c,group:r||x||null}},D=({name:e,label:o,value:t,id:s,disabled:a,className:n="",style:i=E},c)=>{const r=e??o??s??t;return{disabled:!!a,isGroupMarker:!0,group:l(r)?String(r):c,className:n,style:i}},R=e=>`<${typeof e=="string"?e:e?.displayName||e?.name||"Component"}>`,m=(e,o,t=null,s="o",a=[])=>(v.Children.toArray(e).forEach(n=>{if(!v.isValidElement(n)){d.warnOnce("text",`Text inside <Select> or <OptGroup> is ignored ("${String(n).slice(0,30)}"). Wrap it in <Option>.`);return}const i=`${s}-${String(n.key).slice(1).replace(/[:$]/g,r=>r===":"?"-":"k").replace(/[^\p{L}\p{N}-]/gu,"")}`,c=n.type?.racKind;if(n.type===v.Fragment)m(n.props.children,o,t,i,a);else if(c==="option")a.push(j(n.props,i,t));else if(c==="define")m(n.type.racRender(n.props),o,t,i,a);else if(c==="group"){const r=D(n.props,o);a.push(r),m(n.props.children,o,r.group,i,a)}else{const r=R(n.type);d.warnOnce(`child ${r}`,`${r} inside <Select> is ignored: only <Option/>, <OptGroup/> and defineOption() components are read. Put custom content inside <Option>, or wrap the component with defineOption().`)}}),a),$=new Set(["ref","options","value","defaultValue","onChange","children","loadMore","open","onOpenChange","onFocus","onBlur","onKeyDown","childrenFirst","groupsClosed","disabled","loading","error","plugins"]),F=/^(aria|data)-/,y={options:[],value:void 0,defaultValue:void 0,onChange:void 0,multiple:!1,childrenFirst:!1,groupsClosed:!1,plugins:[],disabled:!1,loading:!1,error:!1,open:void 0,onOpenChange:void 0,popup:!0,onFocus:void 0,onBlur:void 0,onKeyDown:void 0,id:void 0,name:void 0,form:void 0,required:!1,hasMore:!1,loadMore:void 0,loadButton:!1,loadOffset:100,loadAhead:3,placeholder:"Choose option",selectedText:void 0,texts:{empty:"No options",disabled:"Disabled",loading:"Loading",error:"Failed to load",clear:"Clear selection",remove:"Remove",loadMore:"Load more",loadingMore:"Loading",emptyOption:"Empty option",invalidOption:"Invalid option",disabledOption:"Disabled option",emptyGroup:"Empty group",groupOpen:"expanded",groupClosed:"collapsed",list:"Options",required:void 0,removed:"Removed {label}",cleared:"Selection cleared",selected:"{n} selected",loaded:"{n} more options loaded"},renderOption:void 0,valueAsOption:!1,icons:{arrow:d.icons.ArrowUp,clear:d.icons.XMark,remove:d.icons.XMark,check:d.icons.Checkmark,checkbox:void 0},deleteInline:!1,deleteAlways:!1,className:"",optionsClassName:"",style:{},container:void 0,duration:300,easing:"ease",offset:1,animateOpacity:!0,keepMounted:!1},C={visibility:"open",setVisibility:"onOpenChange",ownBehavior:"open without onOpenChange",onOpen:"onOpenChange",onClose:"onOpenChange",unmount:"keepMounted (inverted)",showDelete:"deleteAlways",OpenIcon:"icons.arrow",ClearIcon:"icons.clear",DelIcon:"icons.remove",Checkmark:"icons.check",Checkbox:"icons.checkbox",emptyText:"texts.empty",disabledText:"texts.disabled",loadingText:"texts.loading",errorText:"texts.error",clearText:"texts.clear",removeText:"texts.remove",loadButtonText:"texts.loadMore",loadMoreText:"texts.loadingMore",emptyOption:"texts.emptyOption",invalidOption:"texts.invalidOption",disabledOption:"texts.disabledOption"},S=(e,o)=>{const t={...e};for(const s in o)o[s]!==void 0&&(t[s]=o[s]);return t};function I(e){for(const p in e)p in C&&d.warnOnce(`renamed ${p}`,`The \`${p}\` prop was removed. Use \`${C[p]}\`.`);e.value!==void 0&&!e.onChange&&d.warnOnce("read-only value","`value` is set without `onChange`, so the Select is read-only. Pass `onChange`, or `defaultValue` instead of `value`.");const o=S(y,e);o.texts=S(y.texts,e.texts),o.icons=S(y.icons,e.icons);const t=o.texts.emptyGroup,s=g.useDeepStable(v.useMemo(()=>m(o.children,t),[o.children,t])),{selectId:a,selectRef:n,highlightStore:i,ext:c,state:r,actions:h}=q.default(o,s),x={},u={};for(const p in o)$.has(p)||((F.test(p)?u:x)[p]=o[p]);const O=g.useShallowStable({...x,attrs:u,selectId:a,selectRef:n,highlightStore:i,ext:c});return f.jsx(g.SelectConfigContext.Provider,{value:O,children:f.jsx(g.SelectActionsContext.Provider,{value:h,children:f.jsxs(g.SelectStateContext.Provider,{value:r,children:[f.jsx(M.default,{}),f.jsx(T.default,{}),f.jsx(A.default,{})]})})})}function b(){return d.warnOnce("option outside","<Option/> was rendered outside <Select>, or inside a component that <Select> cannot read. Use it as a direct child, or wrap the component with defineOption()."),null}b.racKind="option";function k(){return null}k.racKind="group";exports.OptGroup=k;exports.Option=b;exports.Select=I;
package/dist/select.js ADDED
@@ -0,0 +1,165 @@
1
+ "use client";
2
+ import { jsx as f, jsxs as w } from "react/jsx-runtime";
3
+ import { useDeepStable as k, useShallowStable as T, SelectConfigContext as M, SelectActionsContext as A, SelectStateContext as D } from "./state.js";
4
+ import { useMemo as E, Children as R, isValidElement as b, Fragment as $ } from "react";
5
+ import L from "./trigger.js";
6
+ import F from "./dropdown.js";
7
+ import I from "./liveRegion.js";
8
+ import { warnOnce as u, icons as v } from "./utils.js";
9
+ import N from "./useSelect.js";
10
+ import './theme.css';import './base.css';/* empty css */
11
+ /* empty css */
12
+ const K = {}, l = (e) => e != null && e !== "", C = (e) => e ? typeof e == "string" || typeof e == "number" ? String(e) : Array.isArray(e) ? e.map(C).join(" ").replace(/\s+/g, " ").trim() : b(e) ? C(e.props.children) : "" : "", V = ({ name: e, label: o, id: t, value: s, className: a, style: n, children: i, disabled: p, group: r }, O, m) => {
13
+ const c = C(i), g = s !== void 0 ? s : c;
14
+ return i != null && !c && !l(o) && !l(e) && !l(t) && !l(s) && u("no text", "<Option> has content but no text to show in the title or chips. Add a `label` (or `value`), or enable `valueAsOption`."), {
15
+ id: l(t) ? String(t) : O,
16
+ userId: l(t) ? t : g,
17
+ value: g,
18
+ label: l(o) ? String(o) : l(e) ? String(e) : c || (l(t) ? String(t) : ""),
19
+ jsx: i,
20
+ hasJsx: i != null,
21
+ className: a,
22
+ style: n,
23
+ disabled: !!p,
24
+ group: r || m || null
25
+ };
26
+ }, j = ({ name: e, label: o, value: t, id: s, disabled: a, className: n = "", style: i = K }, p) => {
27
+ const r = e ?? o ?? s ?? t;
28
+ return { disabled: !!a, isGroupMarker: !0, group: l(r) ? String(r) : p, className: n, style: i };
29
+ }, B = (e) => `<${typeof e == "string" ? e : e?.displayName || e?.name || "Component"}>`, x = (e, o, t = null, s = "o", a = []) => (R.toArray(e).forEach((n) => {
30
+ if (!b(n)) {
31
+ u("text", `Text inside <Select> or <OptGroup> is ignored ("${String(n).slice(0, 30)}"). Wrap it in <Option>.`);
32
+ return;
33
+ }
34
+ const i = `${s}-${String(n.key).slice(1).replace(/[:$]/g, (r) => r === ":" ? "-" : "k").replace(/[^\p{L}\p{N}-]/gu, "")}`, p = n.type?.racKind;
35
+ if (n.type === $) x(n.props.children, o, t, i, a);
36
+ else if (p === "option") a.push(V(n.props, i, t));
37
+ else if (p === "define") x(n.type.racRender(n.props), o, t, i, a);
38
+ else if (p === "group") {
39
+ const r = j(n.props, o);
40
+ a.push(r), x(n.props.children, o, r.group, i, a);
41
+ } else {
42
+ const r = B(n.type);
43
+ u(`child ${r}`, `${r} inside <Select> is ignored: only <Option/>, <OptGroup/> and defineOption() components are read. Put custom content inside <Option>, or wrap the component with defineOption().`);
44
+ }
45
+ }), a), P = /* @__PURE__ */ new Set(["ref", "options", "value", "defaultValue", "onChange", "children", "loadMore", "open", "onOpenChange", "onFocus", "onBlur", "onKeyDown", "childrenFirst", "groupsClosed", "disabled", "loading", "error", "plugins"]), U = /^(aria|data)-/, h = {
46
+ options: [],
47
+ value: void 0,
48
+ defaultValue: void 0,
49
+ onChange: void 0,
50
+ multiple: !1,
51
+ childrenFirst: !1,
52
+ groupsClosed: !1,
53
+ plugins: [],
54
+ disabled: !1,
55
+ loading: !1,
56
+ error: !1,
57
+ open: void 0,
58
+ onOpenChange: void 0,
59
+ popup: !0,
60
+ onFocus: void 0,
61
+ onBlur: void 0,
62
+ onKeyDown: void 0,
63
+ id: void 0,
64
+ name: void 0,
65
+ form: void 0,
66
+ required: !1,
67
+ hasMore: !1,
68
+ loadMore: void 0,
69
+ loadButton: !1,
70
+ loadOffset: 100,
71
+ loadAhead: 3,
72
+ placeholder: "Choose option",
73
+ selectedText: void 0,
74
+ texts: {
75
+ empty: "No options",
76
+ disabled: "Disabled",
77
+ loading: "Loading",
78
+ error: "Failed to load",
79
+ clear: "Clear selection",
80
+ remove: "Remove",
81
+ loadMore: "Load more",
82
+ loadingMore: "Loading",
83
+ emptyOption: "Empty option",
84
+ invalidOption: "Invalid option",
85
+ disabledOption: "Disabled option",
86
+ emptyGroup: "Empty group",
87
+ groupOpen: "expanded",
88
+ groupClosed: "collapsed",
89
+ list: "Options",
90
+ required: void 0,
91
+ removed: "Removed {label}",
92
+ cleared: "Selection cleared",
93
+ selected: "{n} selected",
94
+ loaded: "{n} more options loaded"
95
+ },
96
+ renderOption: void 0,
97
+ valueAsOption: !1,
98
+ icons: { arrow: v.ArrowUp, clear: v.XMark, remove: v.XMark, check: v.Checkmark, checkbox: void 0 },
99
+ deleteInline: !1,
100
+ deleteAlways: !1,
101
+ className: "",
102
+ optionsClassName: "",
103
+ style: {},
104
+ container: void 0,
105
+ duration: 300,
106
+ easing: "ease",
107
+ offset: 1,
108
+ animateOpacity: !0,
109
+ keepMounted: !1
110
+ }, S = {
111
+ visibility: "open",
112
+ setVisibility: "onOpenChange",
113
+ ownBehavior: "open without onOpenChange",
114
+ onOpen: "onOpenChange",
115
+ onClose: "onOpenChange",
116
+ unmount: "keepMounted (inverted)",
117
+ showDelete: "deleteAlways",
118
+ OpenIcon: "icons.arrow",
119
+ ClearIcon: "icons.clear",
120
+ DelIcon: "icons.remove",
121
+ Checkmark: "icons.check",
122
+ Checkbox: "icons.checkbox",
123
+ emptyText: "texts.empty",
124
+ disabledText: "texts.disabled",
125
+ loadingText: "texts.loading",
126
+ errorText: "texts.error",
127
+ clearText: "texts.clear",
128
+ removeText: "texts.remove",
129
+ loadButtonText: "texts.loadMore",
130
+ loadMoreText: "texts.loadingMore",
131
+ emptyOption: "texts.emptyOption",
132
+ invalidOption: "texts.invalidOption",
133
+ disabledOption: "texts.disabledOption"
134
+ }, y = (e, o) => {
135
+ const t = { ...e };
136
+ for (const s in o) o[s] !== void 0 && (t[s] = o[s]);
137
+ return t;
138
+ };
139
+ function oe(e) {
140
+ for (const d in e) d in S && u(`renamed ${d}`, `The \`${d}\` prop was removed. Use \`${S[d]}\`.`);
141
+ e.value !== void 0 && !e.onChange && u("read-only value", "`value` is set without `onChange`, so the Select is read-only. Pass `onChange`, or `defaultValue` instead of `value`.");
142
+ const o = y(h, e);
143
+ o.texts = y(h.texts, e.texts), o.icons = y(h.icons, e.icons);
144
+ const t = o.texts.emptyGroup, s = k(E(() => x(o.children, t), [o.children, t])), { selectId: a, selectRef: n, highlightStore: i, ext: p, state: r, actions: O } = N(o, s), m = {}, c = {};
145
+ for (const d in o) P.has(d) || ((U.test(d) ? c : m)[d] = o[d]);
146
+ const g = T({ ...m, attrs: c, selectId: a, selectRef: n, highlightStore: i, ext: p });
147
+ return /* @__PURE__ */ f(M.Provider, { value: g, children: /* @__PURE__ */ f(A.Provider, { value: O, children: /* @__PURE__ */ w(D.Provider, { value: r, children: [
148
+ /* @__PURE__ */ f(L, {}),
149
+ /* @__PURE__ */ f(F, {}),
150
+ /* @__PURE__ */ f(I, {})
151
+ ] }) }) });
152
+ }
153
+ function Y() {
154
+ return u("option outside", "<Option/> was rendered outside <Select>, or inside a component that <Select> cannot read. Use it as a direct child, or wrap the component with defineOption()."), null;
155
+ }
156
+ Y.racKind = "option";
157
+ function _() {
158
+ return null;
159
+ }
160
+ _.racKind = "group";
161
+ export {
162
+ _ as OptGroup,
163
+ Y as Option,
164
+ oe as Select
165
+ };
package/dist/state.cjs ADDED
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),u=o.createContext(null),i=o.createContext(null),S=o.createContext(null),a=(e,t)=>{const c=typeof t=="function"?t(e):t;return c===e?e:Object.keys(c).some(n=>!Object.is(c[n],e[n]))?{...e,...c}:e},f=e=>{let t=e;const c=new Set;return{get:()=>t,set:s=>{Object.keys(s).every(n=>Object.is(s[n],t[n]))||(t={...t,...s},c.forEach(n=>n()))},subscribe:s=>(c.add(s),()=>c.delete(s))}},y=e=>{const t=o.useRef(e);o.useInsertionEffect(()=>{t.current=e});const[c]=o.useState(()=>Object.fromEntries(Object.keys(e).map(s=>[s,(...n)=>t.current[s](...n)])));return c},l=(e,t)=>{const[c,s]=o.useState(e);return c===e||t(c,e)?c:(s(e),e)},j=(e,t)=>e===t||!!e&&!!t&&Object.keys(e).length===Object.keys(t).length&&Object.keys(e).every(c=>Object.is(e[c],t[c])),r=(e,t,c=0)=>{if(Object.is(e,t))return!0;if(c>12||typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;if(e.$$typeof||t.$$typeof)return e.$$typeof===t.$$typeof&&e.type===t.type&&e.key===t.key&&r(e.props,t.props,c+1);const s=Object.keys(e);return s.length===Object.keys(t).length&&s.every(n=>Object.hasOwn(t,n)&&r(e[n],t[n],c+1))},O=new Set(["style","texts","icons","attrs"]),b=(e,t)=>{const c=Object.keys(t);return c.length===Object.keys(e).length&&c.every(s=>O.has(s)?j(e[s],t[s]):Object.is(e[s],t[s]))},p=e=>l(e,b),g=e=>l(e,r);exports.SelectActionsContext=i;exports.SelectConfigContext=u;exports.SelectStateContext=S;exports.compactReducer=a;exports.createStore=f;exports.deepEqual=r;exports.useDeepStable=g;exports.useShallowStable=p;exports.useStableActions=y;
package/dist/state.js ADDED
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ import { createContext as o, useState as l, useRef as i, useInsertionEffect as f } from "react";
3
+ const p = /* @__PURE__ */ o(null), b = /* @__PURE__ */ o(null), a = /* @__PURE__ */ o(null), g = (e, t) => {
4
+ const s = typeof t == "function" ? t(e) : t;
5
+ return s === e ? e : Object.keys(s).some((n) => !Object.is(s[n], e[n])) ? { ...e, ...s } : e;
6
+ }, h = (e) => {
7
+ let t = e;
8
+ const s = /* @__PURE__ */ new Set();
9
+ return {
10
+ get: () => t,
11
+ set: (c) => {
12
+ Object.keys(c).every((n) => Object.is(c[n], t[n])) || (t = { ...t, ...c }, s.forEach((n) => n()));
13
+ },
14
+ subscribe: (c) => (s.add(c), () => s.delete(c))
15
+ };
16
+ }, E = (e) => {
17
+ const t = i(e);
18
+ f(() => {
19
+ t.current = e;
20
+ });
21
+ const [s] = l(() => Object.fromEntries(
22
+ Object.keys(e).map((c) => [c, (...n) => t.current[c](...n)])
23
+ ));
24
+ return s;
25
+ }, u = (e, t) => {
26
+ const [s, c] = l(e);
27
+ return s === e || t(s, e) ? s : (c(e), e);
28
+ }, y = (e, t) => e === t || !!e && !!t && Object.keys(e).length === Object.keys(t).length && Object.keys(e).every((s) => Object.is(e[s], t[s])), r = (e, t, s = 0) => {
29
+ if (Object.is(e, t)) return !0;
30
+ if (s > 12 || typeof e != "object" || typeof t != "object" || e === null || t === null || Array.isArray(e) !== Array.isArray(t)) return !1;
31
+ if (e.$$typeof || t.$$typeof) return e.$$typeof === t.$$typeof && e.type === t.type && e.key === t.key && r(e.props, t.props, s + 1);
32
+ const c = Object.keys(e);
33
+ return c.length === Object.keys(t).length && c.every((n) => Object.hasOwn(t, n) && r(e[n], t[n], s + 1));
34
+ }, j = /* @__PURE__ */ new Set(["style", "texts", "icons", "attrs"]), O = (e, t) => {
35
+ const s = Object.keys(t);
36
+ return s.length === Object.keys(e).length && s.every(
37
+ (c) => j.has(c) ? y(e[c], t[c]) : Object.is(e[c], t[c])
38
+ );
39
+ }, $ = (e) => u(e, O), m = (e) => u(e, r);
40
+ export {
41
+ b as SelectActionsContext,
42
+ p as SelectConfigContext,
43
+ a as SelectStateContext,
44
+ g as compactReducer,
45
+ h as createStore,
46
+ r as deepEqual,
47
+ m as useDeepStable,
48
+ $ as useShallowStable,
49
+ E as useStableActions
50
+ };
package/dist/style.css ADDED
@@ -0,0 +1,4 @@
1
+ @layer rac.base, rac.theme;
2
+ @layer rac.base,rac.theme;@property --rac-list-max-height{syntax: "<length>"; inherits: true; initial-value: 250px;}@layer rac.base{:root{--rac-row: 2em}.rac-select,.rac-options{--rac-duration-fast: calc(var(--rac-duration) * .5)}@media(prefers-reduced-motion:reduce){.rac-select,.rac-options{--rac-duration: 1ms !important}.rac-dots i{animation:none}}.rac-select{position:relative;display:flex;align-items:center;box-sizing:border-box;min-width:0;max-width:100%;cursor:pointer}.rac-select:not([aria-haspopup]){cursor:default}.rac-select[aria-busy=true]{cursor:progress}.rac-select[aria-disabled=true]{cursor:not-allowed}.rac-select[aria-disabled=true][aria-busy=true]{cursor:wait}.rac-value{flex:1;min-width:0;min-height:var(--rac-row);box-sizing:border-box;display:flex;flex-wrap:wrap;align-items:center}.rac-title,.rac-pick{min-width:0;overflow-x:clip;white-space:nowrap;text-overflow:ellipsis}.rac-title{max-width:calc(100% - .25px)}.rac-value:has(.rac-pick){padding-block:calc((var(--rac-row) - 1lh) / 2)}.rac-dots{display:inline-flex;gap:.17em;margin-inline-start:.25em}.rac-dots i{width:.25em;height:.25em;border-radius:50%;background:currentColor;animation:rac-blink 1.4s infinite both}.rac-dots i:nth-child(2){animation-delay:.2s}.rac-dots i:nth-child(3){animation-delay:.4s}.rac-clear,.rac-arrow{display:grid;place-items:center;align-self:center}.rac-clear{padding:0;border:0;background:none;color:inherit;font:inherit;cursor:pointer}.rac-arrow,.rac-group-arrow{transition:rotate var(--rac-duration) var(--rac-ease)}.rac-select:not([data-placement=top],[aria-expanded=true]) .rac-arrow,.rac-select[data-placement=top][aria-expanded=true] .rac-arrow{rotate:180deg}.rac-icon{height:1em}.rac-input{position:absolute;inset:0;box-sizing:border-box;width:100%;height:100%;margin:0;padding:0;border:0;opacity:0;pointer-events:none}.rac-live{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}@media(any-pointer:coarse){.rac-clear{position:relative}.rac-arrow{pointer-events:none}.rac-clear:before{content:"";position:absolute;inset:min(0px,50% - 12px)}}.rac-options{box-sizing:border-box;z-index:2147483647;overflow:clip}.rac-options{opacity:var(--rac-visible, 1);transition:visibility 0s}.rac-options[data-offscreen]{visibility:hidden;transition:opacity var(--rac-duration) var(--rac-ease),visibility 0s var(--rac-duration)}.rac-list{max-height:var(--rac-list-max-height);overflow-x:hidden;overflow-y:auto;scrollbar-gutter:stable;scroll-behavior:smooth}.rac-option{display:flex;justify-content:space-between;align-items:center;overflow-wrap:anywhere;cursor:pointer}.rac-option[aria-disabled=true]{cursor:not-allowed}.rac-option[data-error]{cursor:default}.rac-option[data-loading]{justify-content:start;align-items:baseline;cursor:wait}.rac-check{position:relative;display:flex;justify-content:center;align-items:center}.rac-check[data-default]{width:1em;height:1em;border:1px solid}.rac-checkmark{position:absolute;width:auto;height:1em;opacity:0;scale:0;transition:opacity var(--rac-duration) var(--rac-ease),scale var(--rac-duration) var(--rac-ease)}.rac-option[aria-selected=true] .rac-checkmark{opacity:1;scale:1}.rac-group{display:flex;justify-content:space-between;align-items:center;cursor:pointer}.rac-group[data-disabled]{cursor:not-allowed}.rac-group-arrow{display:grid}.rac-group[data-open]>.rac-group-arrow{rotate:180deg}@keyframes rac-blink{0%{opacity:.2}20%{opacity:1}to{opacity:.2}}}
3
+ @layer rac.base,rac.theme;@layer rac.theme{:root{--rac-bg: color-mix(in srgb, Canvas 98%, CanvasText 2%);--rac-fg: CanvasText;--rac-danger: #e7000b;--rac-success: #4caf50;--rac-radius: 0px}.rac-select,.rac-options{--rac-tint-1: color-mix(in srgb, var(--rac-fg) 5%, var(--rac-bg));--rac-tint-2: color-mix(in srgb, var(--rac-fg) 10%, var(--rac-bg));--rac-tint-3: color-mix(in srgb, var(--rac-fg) 20%, var(--rac-bg));--rac-muted: color-mix(in srgb, var(--rac-fg) 55%, var(--rac-bg))}.rac-select,.rac-options{border-radius:var(--rac-radius)}.rac-select{padding:0 .5em;border:2px solid var(--rac-bg);background-color:var(--rac-bg);color:var(--rac-fg);transition:background-color var(--rac-duration) var(--rac-ease),border-color var(--rac-duration) var(--rac-ease),opacity var(--rac-duration) var(--rac-ease)}.rac-select[aria-haspopup]:not([aria-disabled=true]):hover{background-color:var(--rac-tint-1)}.rac-select[aria-haspopup]:not([aria-disabled=true],[data-error],[data-invalid]):hover{border-color:var(--rac-tint-1)}.rac-select[aria-disabled=true]{opacity:.75}.rac-select:is([data-error],[data-invalid]){border-color:var(--rac-danger)}.rac-select[aria-busy=true]:after{content:"";position:absolute;inset:0;border-radius:inherit;background:linear-gradient(90deg,transparent,var(--rac-muted),transparent) 0 100% / 40% 2px no-repeat;animation:rac-busy 1.5s ease-in-out infinite;pointer-events:none}@media(prefers-reduced-motion:reduce){.rac-select[aria-busy=true]:after{animation:none;background-size:100% 2px}}.rac-pick{margin-inline-end:.3em}.rac-pick:after{content:",";transition:opacity var(--rac-duration) var(--rac-ease)}.rac-pick[data-last]:after{opacity:0}:is(.rac-title,.rac-option)[data-bool=true]{color:var(--rac-success)}:is(.rac-title,.rac-option)[data-bool=false]{color:var(--rac-danger)}.rac-list{background-color:var(--rac-bg);color:var(--rac-fg);scrollbar-color:var(--rac-tint-2) var(--rac-tint-1);scrollbar-width:thin;scroll-padding-block:.5em}.rac-option{gap:.5em;padding:.5em;transition:background-color var(--rac-duration-fast) var(--rac-ease)}.rac-option[data-highlighted]{background-color:var(--rac-tint-2)}.rac-option[aria-selected=true]{background-color:var(--rac-tint-3)}.rac-option[aria-selected=true][data-highlighted]{background-color:color-mix(in srgb,var(--rac-fg) 30%,var(--rac-bg))}.rac-option[aria-disabled=true]{color:var(--rac-muted)}.rac-option[data-invalid]{color:var(--rac-danger)}.rac-option[data-loading]{gap:0;color:var(--rac-muted)}.rac-option[data-error]{color:var(--rac-danger)}.rac-check{margin-inline-end:.2em}.rac-check[data-default]{border-color:var(--rac-muted)}.rac-group{padding:.5em;font-size:1.25em;font-weight:700;transition:background-color var(--rac-duration-fast) var(--rac-ease)}.rac-group[data-highlighted]{background-color:var(--rac-tint-2)}.rac-group[data-disabled]{color:var(--rac-muted)}.rac-group-items{padding-inline-start:1em}@keyframes rac-busy{0%{background-position-x:-100%}to{background-position-x:200%}}}
4
+ @layer rac.base,rac.theme;@layer rac.base{.rac-chip-slot{display:flex;align-items:center;max-width:100%}.rac-chip-text,.rac-chip>.rac-option-jsx{min-width:0;overflow-x:clip}.rac-chip-text{text-overflow:ellipsis}.rac-chip{position:relative;display:inline-flex;flex-shrink:0;align-items:center;box-sizing:border-box;max-width:inherit;white-space:nowrap;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;touch-action:pan-y}.rac-chip-del{position:absolute;flex-shrink:0;inset-inline-end:0;height:100%;display:grid;align-items:center;padding:0;border:0;background:none;color:inherit;font:inherit;cursor:pointer}.rac-chip-del:disabled{cursor:inherit}.rac-select:is([data-deleting],[data-inline-delete]) .rac-chip-del{position:relative}@media(any-pointer:coarse){.rac-chip-del:before{content:"";position:absolute;inset:min(0px,50% - 12px)}}.rac-chip-slot>[data-plain]{display:flex;flex-shrink:0;align-items:center;max-width:inherit}.rac-chip-slot [data-sep]:after{content:var(--rac-sep)}.rac-spacer{flex-basis:100%;height:0;margin-inline-end:1px}}@layer rac.theme{.rac-chip{min-height:calc(var(--rac-row) - .5em);margin-block:.25em;margin-inline-end:.5em;padding-inline:.25em;border-radius:calc(var(--rac-radius) / 2);line-height:normal;background-color:var(--rac-tint-2);transition:background-color var(--rac-duration-fast) var(--rac-ease)}@media(hover:hover){.rac-chip:hover{background-color:var(--rac-tint-3)}}.rac-select[data-deleting] .rac-chip{background-color:color-mix(in srgb,var(--rac-danger) 15%,var(--rac-bg));animation:rac-shake .3s infinite}@media(prefers-reduced-motion:reduce){.rac-select[data-deleting] .rac-chip{animation:none}}.rac-chip-del{border-start-end-radius:inherit;border-end-end-radius:inherit;background-color:color-mix(in srgb,var(--rac-danger) 30%,var(--rac-bg));transition:color var(--rac-duration) var(--rac-ease),background-color var(--rac-duration) var(--rac-ease)}.rac-chip-del:hover{color:var(--rac-danger)}.rac-select:is([data-deleting],[data-inline-delete]) .rac-chip-del{background-color:transparent}@keyframes rac-shake{0%{transform:rotate(0)}25%{transform:rotate(-1deg)}75%{transform:rotate(1deg)}to{transform:rotate(0)}}}
package/dist/theme.css ADDED
@@ -0,0 +1 @@
1
+ @layer rac.base,rac.theme;@layer rac.theme{:root{--rac-bg: color-mix(in srgb, Canvas 98%, CanvasText 2%);--rac-fg: CanvasText;--rac-danger: #e7000b;--rac-success: #4caf50;--rac-radius: 0px}.rac-select,.rac-options{--rac-tint-1: color-mix(in srgb, var(--rac-fg) 5%, var(--rac-bg));--rac-tint-2: color-mix(in srgb, var(--rac-fg) 10%, var(--rac-bg));--rac-tint-3: color-mix(in srgb, var(--rac-fg) 20%, var(--rac-bg));--rac-muted: color-mix(in srgb, var(--rac-fg) 55%, var(--rac-bg))}.rac-select,.rac-options{border-radius:var(--rac-radius)}.rac-select{padding:0 .5em;border:2px solid var(--rac-bg);background-color:var(--rac-bg);color:var(--rac-fg);transition:background-color var(--rac-duration) var(--rac-ease),border-color var(--rac-duration) var(--rac-ease),opacity var(--rac-duration) var(--rac-ease)}.rac-select[aria-haspopup]:not([aria-disabled=true]):hover{background-color:var(--rac-tint-1)}.rac-select[aria-haspopup]:not([aria-disabled=true],[data-error],[data-invalid]):hover{border-color:var(--rac-tint-1)}.rac-select[aria-disabled=true]{opacity:.75}.rac-select:is([data-error],[data-invalid]){border-color:var(--rac-danger)}.rac-select[aria-busy=true]:after{content:"";position:absolute;inset:0;border-radius:inherit;background:linear-gradient(90deg,transparent,var(--rac-muted),transparent) 0 100% / 40% 2px no-repeat;animation:rac-busy 1.5s ease-in-out infinite;pointer-events:none}@media(prefers-reduced-motion:reduce){.rac-select[aria-busy=true]:after{animation:none;background-size:100% 2px}}.rac-pick{margin-inline-end:.3em}.rac-pick:after{content:",";transition:opacity var(--rac-duration) var(--rac-ease)}.rac-pick[data-last]:after{opacity:0}:is(.rac-title,.rac-option)[data-bool=true]{color:var(--rac-success)}:is(.rac-title,.rac-option)[data-bool=false]{color:var(--rac-danger)}.rac-list{background-color:var(--rac-bg);color:var(--rac-fg);scrollbar-color:var(--rac-tint-2) var(--rac-tint-1);scrollbar-width:thin;scroll-padding-block:.5em}.rac-option{gap:.5em;padding:.5em;transition:background-color var(--rac-duration-fast) var(--rac-ease)}.rac-option[data-highlighted]{background-color:var(--rac-tint-2)}.rac-option[aria-selected=true]{background-color:var(--rac-tint-3)}.rac-option[aria-selected=true][data-highlighted]{background-color:color-mix(in srgb,var(--rac-fg) 30%,var(--rac-bg))}.rac-option[aria-disabled=true]{color:var(--rac-muted)}.rac-option[data-invalid]{color:var(--rac-danger)}.rac-option[data-loading]{gap:0;color:var(--rac-muted)}.rac-option[data-error]{color:var(--rac-danger)}.rac-check{margin-inline-end:.2em}.rac-check[data-default]{border-color:var(--rac-muted)}.rac-group{padding:.5em;font-size:1.25em;font-weight:700;transition:background-color var(--rac-duration-fast) var(--rac-ease)}.rac-group[data-highlighted]{background-color:var(--rac-tint-2)}.rac-group[data-disabled]{color:var(--rac-muted)}.rac-group-items{padding-inline-start:1em}@keyframes rac-busy{0%{background-position-x:-100%}to{background-position-x:200%}}}
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react/jsx-runtime"),h=require("./state.cjs"),o=require("./utils.cjs"),e=require("react"),B=require("./useSelectBehavior.cjs"),H=require("./model.cjs"),w=require("./motion.cjs"),z=[],K=()=>{},_=b=>b==null?"":typeof b=="object"?H.toJSON(b)??"":String(b),G=e.memo(function(){const{selectRef:g,multiple:n,name:c,form:u,required:C}=e.useContext(h.SelectConfigContext),{selected:s,selectedIDs:x,disabled:t,fieldsetDisabled:p}=e.useContext(h.SelectStateContext),{reset:m,markInvalid:S}=e.useContext(h.SelectActionsContext),y=e.useRef(null);e.useEffect(()=>{const r=y.current?.getRootNode();let v;const j=N=>{N.target===y.current?.form&&(clearTimeout(v),v=setTimeout(()=>N.defaultPrevented||m()))};return r?.addEventListener("reset",j,!0),()=>{clearTimeout(v),r?.removeEventListener("reset",j,!0)}},[m]);const d=n?x:s?[s]:z,l=!C&&(!c||n&&!d.length),f=l||!d.length?[""]:d.map(r=>_(r.original)),i=()=>g.current?.focus();return f.map((r,v)=>a.jsx("input",{className:"rac-input",ref:v?void 0:y,name:l?void 0:c,form:u,value:r,hidden:l,required:C&&!v,disabled:t&&!p,tabIndex:-1,"aria-hidden":"true",autoComplete:"off",onChange:K,onInvalid:S,onFocus:i},v))}),R=e.memo(function({hidden:g,settle:n,wait:c,children:u}){const{valueAsOption:C,renderOption:s}=e.useContext(h.SelectConfigContext),{title:x,valueOption:t,hasActualValue:p,loading:m,error:S}=e.useContext(h.SelectStateContext),[y]=e.useState(()=>new Set),d=C&&t?o.optionContent(t,s,!0):null,l=m&&!S&&!p,f=`${d?t.id:x}${l?"-loading":""}`,i=t?.type==="boolean"?String(t.raw):void 0;return a.jsxs(w.Presence,{wait:c,children:[!g&&a.jsxs(w.Collapse,{axis:"x",fade:!0,group:y,className:o.withClass("rac-title",d&&t.className),style:d?t.style:void 0,"data-bool":i,onEntered:n,onExited:n,children:[d?a.jsx("div",{className:"rac-option-jsx",children:d}):x,l&&o.dots]},f),u]})}),J=e.memo(function(){const{selectedText:g,duration:n,texts:c}=e.useContext(h.SelectConfigContext),{selectedIDs:u}=e.useContext(h.SelectStateContext),C=e.useSyncExternalStore(o.watchMotion,o.reducedMotion,()=>!1),s=u.length>0&&!g;return a.jsx(R,{hidden:s,wait:n>0&&!C,children:s&&u.map((x,t)=>a.jsx(w.Collapse,{as:"span",axis:"none",exitAxis:"x",fade:!0,className:"rac-pick","data-last":o.flag(t===u.length-1),children:x.name||c.emptyOption},x.id))})}),Q=e.memo(function(){const{selectRef:g,multiple:n,duration:c,easing:u,ext:C}=e.useContext(h.SelectConfigContext),s=n?C.Value:void 0,x=e.useRef(null),[t,p]=e.useState({Slot:s,multiple:n,enter:!1,left:!1});let m=t;(s?t.Slot!==s||t.left:t.Slot&&(!n||t.left))?m={Slot:s,multiple:n,enter:!!s&&!t.Slot&&t.multiple,left:!1}:t.multiple!==n&&(m={...t,multiple:n}),m!==t&&p(m);const{Slot:S,enter:y}=m,d=e.useCallback(()=>p(i=>i.left?i:{...i,left:!0}),[]),[l]=e.useState(()=>({value:0,root:"",anim:null})),f=e.useRef({duration:c,easing:u});return e.useLayoutEffect(()=>{f.current={duration:c,easing:u}},[c,u]),e.useLayoutEffect(()=>{const i=x.current;if(!i||typeof ResizeObserver>"u")return;const r=new ResizeObserver(()=>o.followHeight(g.current,l,i.offsetHeight,f.current.duration,f.current.easing));return r.observe(i),()=>r.disconnect()},[S,g,l]),e.useEffect(()=>()=>l.anim?.cancel(),[l]),S?a.jsx(S,{height:l,enter:y,leaving:!s,onLeft:d}):a.jsx("div",{className:"rac-value",ref:x,children:n?a.jsx(J,{}):a.jsx(R,{})})}),U=e.memo(function(){const{selectRef:g,selectId:n,highlightStore:c,className:u,style:C,duration:s,easing:x,deleteInline:t,icons:p,texts:m,placeholder:S,id:y,required:d,popup:l,attrs:f}=e.useContext(h.SelectConfigContext),{visibility:i,active:r,hasActualValue:v,deleting:j,loading:N,loadPending:O,error:q,invalid:E,normalizedOptions:T}=e.useContext(h.SelectStateContext),{handleBlur:P,handleFocus:k,handleKeyDown:A,toggleVisibility:D,clear:F}=e.useContext(h.SelectActionsContext),V=e.useSyncExternalStore(c.subscribe,()=>{const I=i?T[B.effectiveHighlight(c.get())]:null;return I?o.optionDomId(n,I.id):void 0},()=>{}),L=!!p.clear&&v&&r&&!j,M=!!p.arrow&&r&&!j&&l,$=l?{role:"combobox","aria-haspopup":"listbox","aria-controls":`${n}-listbox`,"aria-expanded":i,"aria-activedescendant":V,"aria-required":d||void 0}:{role:"group"};return a.jsxs("div",{...f,id:y,ref:g,style:{"--rac-duration":`${s}ms`,"--rac-ease":x,...C},className:o.withClass("rac-select",u),...r&&{onKeyDown:A,onFocus:k,onClick:D,onBlur:P},...$,"aria-disabled":!r,tabIndex:r?0:-1,"aria-busy":N||O||void 0,"aria-label":f["aria-label"]??(f["aria-labelledby"]?void 0:S),"aria-invalid":E||f["aria-invalid"],"aria-describedby":[f["aria-describedby"],q&&`${n}-error`].filter(Boolean).join(" ")||void 0,"data-inline-delete":o.flag(t),"data-empty":o.flag(!v),"data-deleting":o.flag(j),"data-error":o.flag(q),"data-invalid":o.flag(E),children:[a.jsx(Q,{}),a.jsxs(w.Presence,{children:[L&&a.jsx(w.Collapse,{as:"button",type:"button",axis:"x",className:"rac-clear",tabIndex:-1,"aria-label":m.clear,onMouseDown:o.stopEvent,onClick:I=>{o.refocus(I,g),F(I)},children:o.renderIcon(p.clear)},"clear"),M&&a.jsx(w.Collapse,{axis:"x",className:"rac-arrow","aria-hidden":"true",children:o.renderIcon(p.arrow)},"arrow")]}),a.jsx(G,{})]})});exports.Title=R;exports.default=U;
@@ -0,0 +1,99 @@
1
+ "use client";
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
+ };
18
+ return r?.addEventListener("reset", S, !0), () => {
19
+ clearTimeout(b), r?.removeEventListener("reset", S, !0);
20
+ };
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
+ );
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;
55
+ }, () => {
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(
58
+ "div",
59
+ {
60
+ ...c,
61
+ id: y,
62
+ ref: m,
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
70
+ },
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),
83
+ children: [
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")
90
+ ] }),
91
+ /* @__PURE__ */ f(me, {})
92
+ ]
93
+ }
94
+ );
95
+ });
96
+ export {
97
+ z as Title,
98
+ Ce as default
99
+ };
@@ -0,0 +1 @@
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;
@@ -0,0 +1,77 @@
1
+ "use client";
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;
12
+ if (!r) return;
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(() => {
32
+ const e = () => B(!0, !0), t = typeof ResizeObserver > "u" ? null : new ResizeObserver(e);
33
+ return t ? t.observe(i.current) : e(), document.fonts?.addEventListener("loadingdone", e), () => {
34
+ t?.disconnect(), document.fonts?.removeEventListener("loadingdone", e);
35
+ };
36
+ }, []);
37
+ const fe = Y((e) => {
38
+ const t = i.current;
39
+ t && (v.current = Se(t, e), e && (x.current = Ce(t)));
40
+ }, []);
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);
48
+ }));
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
+ const t = getComputedStyle(e);
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
+ }
75
+ export {
76
+ De as default
77
+ };