@cronocode/react-box 3.1.2 → 3.1.6

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 (34) hide show
  1. package/components/dataGrid/components/dataGridCell.d.ts +1 -1
  2. package/components/dataGrid/components/dataGridColumnFilter.d.ts +11 -0
  3. package/components/dataGrid/components/dataGridFilterCell.d.ts +8 -0
  4. package/components/dataGrid/components/dataGridFilterRow.d.ts +6 -0
  5. package/components/dataGrid/components/dataGridGlobalFilter.d.ts +6 -0
  6. package/components/dataGrid/contracts/dataGridContract.d.ts +57 -0
  7. package/components/dataGrid/models/columnModel.d.ts +1 -0
  8. package/components/dataGrid/models/gridModel.d.ts +53 -1
  9. package/components/dataGrid/models/groupRowModel.d.ts +2 -0
  10. package/components/dataGrid.cjs +1 -1
  11. package/components/dataGrid.mjs +694 -284
  12. package/components/dropdown.cjs +1 -1
  13. package/components/dropdown.d.ts +4 -1
  14. package/components/dropdown.mjs +158 -149
  15. package/components/form.mjs +1 -1
  16. package/components/semantics.d.ts +25 -25
  17. package/components/semantics.mjs +5 -5
  18. package/components/textbox.cjs +1 -1
  19. package/components/textbox.d.ts +2 -2
  20. package/components/textbox.mjs +5 -4
  21. package/components/tooltip.cjs +1 -1
  22. package/components/tooltip.d.ts +4 -0
  23. package/components/tooltip.mjs +45 -41
  24. package/core/boxStyles.d.ts +66 -31
  25. package/core/extends/boxComponents.d.ts +812 -153
  26. package/core/variables.d.ts +25 -1
  27. package/core.cjs +3 -7
  28. package/core.mjs +1542 -681
  29. package/hooks/useVirtualization.d.ts +43 -0
  30. package/package.json +7 -5
  31. package/ssg.cjs +1 -1
  32. package/ssg.mjs +28 -20
  33. package/types.d.ts +6 -5
  34. package/utils/string/fuzzySearch.d.ts +27 -0
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),t=require("react"),f=require("../box.cjs"),G=require("../core.cjs"),Q=require("./baseSvg.cjs"),X=require("./button.cjs"),Z=require("./flex.cjs"),L=require("./textbox.cjs"),ee=require("./tooltip.cjs");function te(p,s){const{name:M,defaultValue:h,value:x,multiple:c,isSearchable:y,searchPlaceholder:B,children:j,hideIcon:H,onChange:S,props:K,...Y}=p,[J,w]=t.useState(Array.isArray(h)?h:h?[h]:[]),i="value"in p?Array.isArray(x)?x:x?[x]:[]:J,[b,_]=t.useState(""),[a,T,I]=G.useVisibility(),k=t.useRef(null),U=t.useRef(null),[O,F]=t.useState(0),D=t.useMemo(()=>O>window.innerHeight/2,[O]),W=t.useMemo(()=>D?I.current?.getBoundingClientRect().height??0:0,[D,I]),l=t.useMemo(()=>(Array.isArray(j)?j:[j]).flatMap(e=>e),[j]),V=t.useMemo(()=>l.filter(e=>e.type?.displayName==="DropdownItem"),[l]),d=t.useMemo(()=>V.filter(e=>y&&b?R(e).toLowerCase().includes(b.toLowerCase()):!0),[y,b,l]),g=t.useMemo(()=>l.find(e=>e.type?.displayName==="DropdownUnselect"),[l]),q=t.useMemo(()=>l.find(e=>e.type?.displayName==="DropdownSelectAll"),[l]),N=t.useMemo(()=>l.find(e=>e.type?.displayName==="DropdownEmptyItem"),[l]),A=t.useMemo(()=>l.find(e=>e.type?.displayName==="DropdownDisplay"),[l]),$=t.useMemo(()=>{if(A)return typeof A.props.children=="function"?A.props.children(i,a):A.props.children;const e=d.filter(n=>i.includes(n.props.value));if(c&&e.length>1)return e.map(n=>R(n)).join(", ");const r=e.at(0);return r?.props.children??r?.props.value??(c?null:g?.props.children)},[c,d,i,g,a]),P=t.useCallback((e,...r)=>{if(r.length===0)w([]),S?.(void 0,[]);else if(c&&r.length>1){const n=r.map(u=>u.props.value);w(n),S?.(void 0,n)}else if(r.length===1){const n=r[0];if(c){const u=i.filter(C=>C!==n.props.value);u.length===i.length&&u.push(n.props.value),w(u),S?.(n.props.value,u)}else w([n.props.value]),S?.(n.props.value,[n.props.value])}c?(e.stopPropagation(),setTimeout(()=>k.current?.focus(),0)):(T(!1),setTimeout(()=>I.current?.focus(),0))},[c,i,w]);t.useEffect(()=>{a?setTimeout(()=>{k.current?.focus(),U.current?.querySelector('[aria-selected="true"]')?.scrollIntoView({block:"nearest"})},0):_("")},[a]);const E=q&&c&&d.length>i.length,z=g&&d.length>0&&!E;return o.jsxs(f.default,{width:"fit-content",children:[i.map(e=>o.jsx(L.default,{ref:s,name:M,type:"hidden",value:JSON.stringify(e)??""},JSON.stringify(e))),o.jsxs(X.default,{ref:I,type:"button",component:"dropdown",onClick:()=>T(e=>!e),props:{tabIndex:0,...K},...Y,children:[y&&o.jsx(L.default,{display:a&&y?"block":"none",clean:!0,flex1:!0,width:1,minHeight:5,placeholder:B,value:b,onChange:e=>_(e.target.value),ref:k,props:{onClick:e=>{a&&y&&e.stopPropagation()}}}),o.jsx(Z.default,{component:"dropdown.display",display:a&&y?"none":"flex",children:$??o.jsx(o.Fragment,{children:" "})}),!H&&o.jsx(f.default,{children:o.jsx(Q.default,{viewBox:"0 0 10 6",width:"0.6rem",rotate:a?180:0,children:o.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m1 1 4 4 4-4"})})})]}),a&&o.jsx(ee.default,{ref:U,position:"absolute",width:"fit",top:D?void 0:0,bottom:D?2:void 0,style:{transform:`translateY(-${W}px)`},onPositionChange:e=>F(e.top-window.scrollY),children:(d.length>0||N)&&o.jsxs(f.default,{component:"dropdown.items",children:[z&&o.jsx(f.default,{component:"dropdown.unselect",selected:i.length===0,...g.props,props:{...g.props.props,onClick:e=>P(e)}}),E&&o.jsx(f.default,{component:"dropdown.selectAll",...q.props,props:{...q.props.props,onClick:e=>P(e,...V)}}),d.map(e=>{const{value:r,onClick:n,...u}=e.props;return o.jsx(f.default,{component:"dropdown.item",variant:c?"multiple":void 0,selected:i.includes(r),...u,props:{...u.props,onClick:C=>{n?.(C),P(C,e)}}},r)}),d.length===0&&N&&o.jsx(f.default,{component:"dropdown.emptyItem",...N.props})]})})]})}function v(p){const s=M=>null;return s.displayName=p,s}const m=t.forwardRef(te);m.Item=v("DropdownItem");m.Unselect=v("DropdownUnselect");m.SelectAll=v("DropdownSelectAll");m.EmptyItem=v("DropdownEmptyItem");m.Display=v("DropdownDisplay");m.displayName="Dropdown";function R(p){if(p==null)return"";if(typeof p=="object"){const s=p.props?.children;return s==null?"":typeof s=="object"?(Array.isArray(s)?s:[s]).map(h=>R(h)).join(""):s.toString()}return p.toString()}exports.default=m;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),t=require("react"),h=require("../box.cjs"),oe=require("../core.cjs"),ne=require("./baseSvg.cjs"),re=require("./button.cjs"),se=require("./checkbox.cjs"),W=require("./flex.cjs"),z=require("./textbox.cjs"),le=require("./tooltip.cjs");function ie(i,r){const{name:k,defaultValue:m,value:x,multiple:c=!1,isSearchable:y,searchPlaceholder:F,children:j,hideIcon:T,showCheckbox:$,onChange:S,props:G,...U}=i,b=U.variant==="compact",[Q,w]=t.useState(Array.isArray(m)?m:m?[m]:[]),p="value"in i?Array.isArray(x)?x:x?[x]:[]:Q,[C,V]=t.useState(""),[a,E,I]=oe.useVisibility(),q=t.useRef(null),L=t.useRef(null),[D,X]=t.useState({top:0,scrollY:0}),N=t.useMemo(()=>D.top-D.scrollY>window.innerHeight/2,[D.top,D.scrollY]),B=t.useMemo(()=>I.current?.getBoundingClientRect(),[I.current]),Z=t.useMemo(()=>N?0:B?.height??0,[N,B]),l=t.useMemo(()=>(Array.isArray(j)?j:[j]).flatMap(e=>e),[j]),K=t.useMemo(()=>l.filter(e=>e.type?.displayName==="DropdownItem"),[l]),d=t.useMemo(()=>K.filter(e=>y&&C?O(e).toLowerCase().includes(C.toLowerCase()):!0),[y,C,l]),v=t.useMemo(()=>l.find(e=>e.type?.displayName==="DropdownUnselect"),[l]),P=t.useMemo(()=>l.find(e=>e.type?.displayName==="DropdownSelectAll"),[l]),_=t.useMemo(()=>l.find(e=>e.type?.displayName==="DropdownEmptyItem"),[l]),A=t.useMemo(()=>l.find(e=>e.type?.displayName==="DropdownDisplay"),[l]),ee=t.useMemo(()=>{if(a&&y)return null;if(A)return typeof A.props.children=="function"?A.props.children(p,a):A.props.children;const e=d.filter(n=>p.includes(n.props.value));if(c&&e.length>1)return e.map(n=>O(n)).join(", ");const s=e.at(0);return s?.props.children??s?.props.value??(c?null:v?.props.children)},[c,d,p,v,a]),R=t.useCallback((e,...s)=>{if(s.length===0)w([]),S?.(void 0,[]);else if(c&&s.length>1){const n=s.map(u=>u.props.value);w(n),S?.(void 0,n)}else if(s.length===1){const n=s[0];if(c){const u=p.filter(M=>M!==n.props.value);u.length===p.length&&u.push(n.props.value),w(u),S?.(n.props.value,u)}else w([n.props.value]),S?.(n.props.value,[n.props.value])}c?(e.stopPropagation(),setTimeout(()=>q.current?.focus(),0)):(E(!1),setTimeout(()=>I.current?.focus(),0))},[c,p,w]);t.useEffect(()=>{a?setTimeout(()=>{q.current?.focus(),L.current?.querySelector('[aria-selected="true"]')?.scrollIntoView({block:"nearest"})},0):V("")},[a]);const H=P&&c&&d.length>p.length,te=v&&d.length>0&&!H;return o.jsxs(re.default,{ref:I,onClick:()=>E(e=>!e),component:"dropdown",props:{tabIndex:0,...G},position:"relative",pr:T?void 0:4,...U,children:[p.map(e=>o.jsx(z.default,{ref:r,name:k,type:"hidden",value:JSON.stringify(e)??""},JSON.stringify(e))),y&&a&&o.jsx(W.default,{ai:"center",position:"absolute",inset:0,p:3,children:o.jsx(z.default,{clean:!0,placeholder:F,value:C,onChange:e=>V(e.target.value),ref:q,color:"currentColor",width:"fit",props:{onClick:e=>{a&&y&&e.stopPropagation()}}})})," ",ee," ",!T&&o.jsx(W.default,{component:"dropdown.icon",children:o.jsx(ne.default,{viewBox:"0 0 10 6",width:"0.6rem",rotate:a?180:0,children:o.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m1 1 4 4 4-4"})})}),o.jsx(h.default,{position:"absolute",inset:0,children:a&&o.jsx(le.default,{ref:L,minWidth:"fit-content",style:{transform:N?"translateY(calc(-100% - 2px))":`translateY(${Z}px)`},onPositionChange:e=>X({top:e.top,scrollY:e.windowScrollY}),children:(d.length>0||_)&&o.jsxs(h.default,{component:"dropdown.items",children:[te&&o.jsx(h.default,{component:"dropdown.unselect",variant:{compact:b},selected:p.length===0,...v.props,props:{...v.props.props,onClick:e=>R(e)}}),H&&o.jsx(h.default,{component:"dropdown.selectAll",variant:{compact:b},...P.props,props:{...P.props.props,onClick:e=>R(e,...K)}}),d.map(e=>{const{value:s,onClick:n,children:u,...M}=e.props,Y=p.includes(s);return o.jsx(h.default,{component:"dropdown.item",variant:{multiple:c,compact:b},selected:Y,...M,children:$&&c?o.jsxs(o.Fragment,{children:[o.jsx(se.default,{readOnly:!0,checked:Y}),u]}):u,props:{...M.props,"aria-selected":Y,onClick:J=>{n?.(J),R(J,e)}}},s)}),d.length===0&&_&&o.jsx(h.default,{component:"dropdown.emptyItem",variant:{compact:b},..._.props})]})})})]})}function g(i){const r=k=>null;return r.displayName=i,r}const f=t.forwardRef(ie);f.Item=g("DropdownItem");f.Unselect=g("DropdownUnselect");f.SelectAll=g("DropdownSelectAll");f.EmptyItem=g("DropdownEmptyItem");f.Display=g("DropdownDisplay");f.displayName="Dropdown";function O(i){if(i==null)return"";if(typeof i=="object"){const r=i.props?.children;return r==null?"":typeof r=="object"?(Array.isArray(r)?r:[r]).map(m=>O(m)).join(""):r.toString()}return i.toString()}exports.default=f;
@@ -1,6 +1,7 @@
1
1
  import { RefAttributes } from 'react';
2
2
  import { BoxProps } from '../box';
3
- interface Props<TVal> extends Omit<BoxProps<'button'>, 'ref'> {
3
+ import { ComponentsAndVariants } from '../types';
4
+ interface Props<TVal, TKey extends keyof ComponentsAndVariants = 'dropdown'> extends Omit<BoxProps<'button', TKey>, 'ref' | 'tag'> {
4
5
  name?: string;
5
6
  defaultValue?: TVal | TVal[];
6
7
  value?: TVal | TVal[];
@@ -8,6 +9,8 @@ interface Props<TVal> extends Omit<BoxProps<'button'>, 'ref'> {
8
9
  isSearchable?: boolean;
9
10
  searchPlaceholder?: string;
10
11
  hideIcon?: boolean;
12
+ /** Show checkbox for each item in multiple selection mode */
13
+ showCheckbox?: boolean;
11
14
  onChange?: (value: TVal | undefined, values: TVal[]) => void;
12
15
  }
13
16
  interface DropdownItemProps<TVal> extends BoxProps {
@@ -1,169 +1,178 @@
1
- import { jsxs as B, jsx as r, Fragment as Z } from "react/jsx-runtime";
2
- import { forwardRef as ee, useState as V, useRef as F, useMemo as i, useCallback as oe, useEffect as te } from "react";
3
- import m from "../box.mjs";
4
- import { b as ne } from "../core.mjs";
5
- import re from "./baseSvg.mjs";
6
- import se from "./button.mjs";
7
- import le from "./flex.mjs";
8
- import J from "./textbox.mjs";
9
- import pe from "./tooltip.mjs";
10
- function ie(l, t) {
1
+ import { jsxs as V, jsx as o, Fragment as se } from "react/jsx-runtime";
2
+ import { forwardRef as le, useState as R, useRef as _, useMemo as l, useCallback as pe, useEffect as ie } from "react";
3
+ import f from "../box.mjs";
4
+ import { b as ce } from "../core.mjs";
5
+ import ae from "./baseSvg.mjs";
6
+ import de from "./button.mjs";
7
+ import ue from "./checkbox.mjs";
8
+ import $ from "./flex.mjs";
9
+ import G from "./textbox.mjs";
10
+ import me from "./tooltip.mjs";
11
+ function fe(p, r) {
11
12
  const {
12
- name: N,
13
- defaultValue: f,
14
- value: I,
15
- multiple: c,
16
- isSearchable: h,
17
- searchPlaceholder: M,
18
- children: D,
19
- hideIcon: q,
20
- onChange: x,
21
- props: W,
22
- ..._
23
- } = l, [$, w] = V(Array.isArray(f) ? f : f ? [f] : []), p = "value" in l ? Array.isArray(I) ? I : I ? [I] : [] : $, [S, R] = V(""), [a, E, A] = ne(), P = F(null), L = F(null), [H, z] = V(0), C = i(() => H > window.innerHeight / 2, [H]), G = i(() => C ? A.current?.getBoundingClientRect().height ?? 0 : 0, [C, A]), s = i(
24
- () => (Array.isArray(D) ? D : [D]).flatMap((e) => e),
25
- [D]
26
- ), K = i(() => s.filter((e) => e.type?.displayName === "DropdownItem"), [s]), u = i(() => K.filter((e) => h && S ? O(e).toLowerCase().includes(S.toLowerCase()) : !0), [h, S, s]), g = i(() => s.find((e) => e.type?.displayName === "DropdownUnselect"), [s]), T = i(() => s.find((e) => e.type?.displayName === "DropdownSelectAll"), [s]), j = i(() => s.find((e) => e.type?.displayName === "DropdownEmptyItem"), [s]), b = i(() => s.find((e) => e.type?.displayName === "DropdownDisplay"), [s]), Q = i(() => {
27
- if (b)
28
- return typeof b.props.children == "function" ? b.props.children(p, a) : b.props.children;
29
- const e = u.filter((o) => p.includes(o.props.value));
30
- if (c && e.length > 1)
31
- return e.map((o) => O(o)).join(", ");
13
+ name: P,
14
+ defaultValue: m,
15
+ value: C,
16
+ multiple: i = !1,
17
+ isSearchable: y,
18
+ searchPlaceholder: Q,
19
+ children: S,
20
+ hideIcon: L,
21
+ showCheckbox: X,
22
+ onChange: I,
23
+ props: Z,
24
+ ...K
25
+ } = p, x = K.variant === "compact", [ee, w] = R(Array.isArray(m) ? m : m ? [m] : []), c = "value" in p ? Array.isArray(C) ? C : C ? [C] : [] : ee, [D, F] = R(""), [a, H, b] = ce(), T = _(null), J = _(null), [A, te] = R({ top: 0, scrollY: 0 }), Y = l(
26
+ () => A.top - A.scrollY > window.innerHeight / 2,
27
+ [A.top, A.scrollY]
28
+ ), M = l(() => b.current?.getBoundingClientRect(), [b.current]), oe = l(() => Y ? 0 : M?.height ?? 0, [Y, M]), s = l(
29
+ () => (Array.isArray(S) ? S : [S]).flatMap((e) => e),
30
+ [S]
31
+ ), W = l(() => s.filter((e) => e.type?.displayName === "DropdownItem"), [s]), u = l(() => W.filter((e) => y && D ? E(e).toLowerCase().includes(D.toLowerCase()) : !0), [y, D, s]), v = l(() => s.find((e) => e.type?.displayName === "DropdownUnselect"), [s]), j = l(() => s.find((e) => e.type?.displayName === "DropdownSelectAll"), [s]), U = l(() => s.find((e) => e.type?.displayName === "DropdownEmptyItem"), [s]), k = l(() => s.find((e) => e.type?.displayName === "DropdownDisplay"), [s]), re = l(() => {
32
+ if (a && y) return null;
33
+ if (k)
34
+ return typeof k.props.children == "function" ? k.props.children(c, a) : k.props.children;
35
+ const e = u.filter((t) => c.includes(t.props.value));
36
+ if (i && e.length > 1)
37
+ return e.map((t) => E(t)).join(", ");
32
38
  const n = e.at(0);
33
- return n?.props.children ?? n?.props.value ?? (c ? null : g?.props.children);
34
- }, [c, u, p, g, a]), U = oe(
39
+ return n?.props.children ?? n?.props.value ?? (i ? null : v?.props.children);
40
+ }, [i, u, c, v, a]), B = pe(
35
41
  (e, ...n) => {
36
42
  if (n.length === 0)
37
- w([]), x?.(void 0, []);
38
- else if (c && n.length > 1) {
39
- const o = n.map((d) => d.props.value);
40
- w(o), x?.(void 0, o);
43
+ w([]), I?.(void 0, []);
44
+ else if (i && n.length > 1) {
45
+ const t = n.map((d) => d.props.value);
46
+ w(t), I?.(void 0, t);
41
47
  } else if (n.length === 1) {
42
- const o = n[0];
43
- if (c) {
44
- const d = p.filter((k) => k !== o.props.value);
45
- d.length === p.length && d.push(o.props.value), w(d), x?.(o.props.value, d);
48
+ const t = n[0];
49
+ if (i) {
50
+ const d = c.filter((N) => N !== t.props.value);
51
+ d.length === c.length && d.push(t.props.value), w(d), I?.(t.props.value, d);
46
52
  } else
47
- w([o.props.value]), x?.(o.props.value, [o.props.value]);
53
+ w([t.props.value]), I?.(t.props.value, [t.props.value]);
48
54
  }
49
- c ? (e.stopPropagation(), setTimeout(() => P.current?.focus(), 0)) : (E(!1), setTimeout(() => A.current?.focus(), 0));
55
+ i ? (e.stopPropagation(), setTimeout(() => T.current?.focus(), 0)) : (H(!1), setTimeout(() => b.current?.focus(), 0));
50
56
  },
51
- [c, p, w]
57
+ [i, c, w]
52
58
  );
53
- te(() => {
59
+ ie(() => {
54
60
  a ? setTimeout(() => {
55
- P.current?.focus(), L.current?.querySelector('[aria-selected="true"]')?.scrollIntoView({ block: "nearest" });
56
- }, 0) : R("");
61
+ T.current?.focus(), J.current?.querySelector('[aria-selected="true"]')?.scrollIntoView({ block: "nearest" });
62
+ }, 0) : F("");
57
63
  }, [a]);
58
- const Y = T && c && u.length > p.length, X = g && u.length > 0 && !Y;
59
- return /* @__PURE__ */ B(m, { width: "fit-content", children: [
60
- p.map((e) => /* @__PURE__ */ r(J, { ref: t, name: N, type: "hidden", value: JSON.stringify(e) ?? "" }, JSON.stringify(e))),
61
- /* @__PURE__ */ B(
62
- se,
63
- {
64
- ref: A,
65
- type: "button",
66
- component: "dropdown",
67
- onClick: () => E((e) => !e),
68
- props: { tabIndex: 0, ...W },
69
- ..._,
70
- children: [
71
- h && /* @__PURE__ */ r(
72
- J,
73
- {
74
- display: a && h ? "block" : "none",
75
- clean: !0,
76
- flex1: !0,
77
- width: 1,
78
- minHeight: 5,
79
- placeholder: M,
80
- value: S,
81
- onChange: (e) => R(e.target.value),
82
- ref: P,
83
- props: {
84
- onClick: (e) => {
85
- a && h && e.stopPropagation();
86
- }
64
+ const q = j && i && u.length > c.length, ne = v && u.length > 0 && !q;
65
+ return /* @__PURE__ */ V(
66
+ de,
67
+ {
68
+ ref: b,
69
+ onClick: () => H((e) => !e),
70
+ component: "dropdown",
71
+ props: { tabIndex: 0, ...Z },
72
+ position: "relative",
73
+ pr: L ? void 0 : 4,
74
+ ...K,
75
+ children: [
76
+ c.map((e) => /* @__PURE__ */ o(G, { ref: r, name: P, type: "hidden", value: JSON.stringify(e) ?? "" }, JSON.stringify(e))),
77
+ y && a && /* @__PURE__ */ o($, { ai: "center", position: "absolute", inset: 0, p: 3, children: /* @__PURE__ */ o(
78
+ G,
79
+ {
80
+ clean: !0,
81
+ placeholder: Q,
82
+ value: D,
83
+ onChange: (e) => F(e.target.value),
84
+ ref: T,
85
+ color: "currentColor",
86
+ width: "fit",
87
+ props: {
88
+ onClick: (e) => {
89
+ a && y && e.stopPropagation();
87
90
  }
88
91
  }
89
- ),
90
- /* @__PURE__ */ r(le, { component: "dropdown.display", display: a && h ? "none" : "flex", children: Q ?? /* @__PURE__ */ r(Z, { children: " " }) }),
91
- !q && /* @__PURE__ */ r(m, { children: /* @__PURE__ */ r(re, { viewBox: "0 0 10 6", width: "0.6rem", rotate: a ? 180 : 0, children: /* @__PURE__ */ r("path", { stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "m1 1 4 4 4-4" }) }) })
92
- ]
93
- }
94
- ),
95
- a && /* @__PURE__ */ r(
96
- pe,
97
- {
98
- ref: L,
99
- position: "absolute",
100
- width: "fit",
101
- top: C ? void 0 : 0,
102
- bottom: C ? 2 : void 0,
103
- style: { transform: `translateY(-${G}px)` },
104
- onPositionChange: (e) => z(e.top - window.scrollY),
105
- children: (u.length > 0 || j) && /* @__PURE__ */ B(m, { component: "dropdown.items", children: [
106
- X && /* @__PURE__ */ r(
107
- m,
108
- {
109
- component: "dropdown.unselect",
110
- selected: p.length === 0,
111
- ...g.props,
112
- props: { ...g.props.props, onClick: (e) => U(e) }
113
- }
114
- ),
115
- Y && /* @__PURE__ */ r(
116
- m,
117
- {
118
- component: "dropdown.selectAll",
119
- ...T.props,
120
- props: { ...T.props.props, onClick: (e) => U(e, ...K) }
121
- }
122
- ),
123
- u.map((e) => {
124
- const { value: n, onClick: o, ...d } = e.props;
125
- return /* @__PURE__ */ r(
126
- m,
127
- {
128
- component: "dropdown.item",
129
- variant: c ? "multiple" : void 0,
130
- selected: p.includes(n),
131
- ...d,
132
- props: {
133
- ...d.props,
134
- onClick: (k) => {
135
- o?.(k), U(k, e);
136
- }
92
+ }
93
+ ) }),
94
+ " ",
95
+ re,
96
+ " ",
97
+ !L && /* @__PURE__ */ o($, { component: "dropdown.icon", children: /* @__PURE__ */ o(ae, { viewBox: "0 0 10 6", width: "0.6rem", rotate: a ? 180 : 0, children: /* @__PURE__ */ o("path", { stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "m1 1 4 4 4-4" }) }) }),
98
+ /* @__PURE__ */ o(f, { position: "absolute", inset: 0, children: a && /* @__PURE__ */ o(
99
+ me,
100
+ {
101
+ ref: J,
102
+ minWidth: "fit-content",
103
+ style: { transform: Y ? "translateY(calc(-100% - 2px))" : `translateY(${oe}px)` },
104
+ onPositionChange: (e) => te({ top: e.top, scrollY: e.windowScrollY }),
105
+ children: (u.length > 0 || U) && /* @__PURE__ */ V(f, { component: "dropdown.items", children: [
106
+ ne && /* @__PURE__ */ o(
107
+ f,
108
+ {
109
+ component: "dropdown.unselect",
110
+ variant: { compact: x },
111
+ selected: c.length === 0,
112
+ ...v.props,
113
+ props: { ...v.props.props, onClick: (e) => B(e) }
137
114
  }
138
- },
139
- n
140
- );
141
- }),
142
- u.length === 0 && j && /* @__PURE__ */ r(m, { component: "dropdown.emptyItem", ...j.props })
143
- ] })
144
- }
145
- )
146
- ] });
115
+ ),
116
+ q && /* @__PURE__ */ o(
117
+ f,
118
+ {
119
+ component: "dropdown.selectAll",
120
+ variant: { compact: x },
121
+ ...j.props,
122
+ props: { ...j.props.props, onClick: (e) => B(e, ...W) }
123
+ }
124
+ ),
125
+ u.map((e) => {
126
+ const { value: n, onClick: t, children: d, ...N } = e.props, O = c.includes(n);
127
+ return /* @__PURE__ */ o(
128
+ f,
129
+ {
130
+ component: "dropdown.item",
131
+ variant: { multiple: i, compact: x },
132
+ selected: O,
133
+ ...N,
134
+ children: X && i ? /* @__PURE__ */ V(se, { children: [
135
+ /* @__PURE__ */ o(ue, { readOnly: !0, checked: O }),
136
+ d
137
+ ] }) : d,
138
+ props: {
139
+ ...N.props,
140
+ "aria-selected": O,
141
+ onClick: (z) => {
142
+ t?.(z), B(z, e);
143
+ }
144
+ }
145
+ },
146
+ n
147
+ );
148
+ }),
149
+ u.length === 0 && U && /* @__PURE__ */ o(f, { component: "dropdown.emptyItem", variant: { compact: x }, ...U.props })
150
+ ] })
151
+ }
152
+ ) })
153
+ ]
154
+ }
155
+ );
147
156
  }
148
- function v(l) {
149
- const t = (N) => null;
150
- return t.displayName = l, t;
157
+ function g(p) {
158
+ const r = (P) => null;
159
+ return r.displayName = p, r;
151
160
  }
152
- const y = ee(ie);
153
- y.Item = v("DropdownItem");
154
- y.Unselect = v("DropdownUnselect");
155
- y.SelectAll = v("DropdownSelectAll");
156
- y.EmptyItem = v("DropdownEmptyItem");
157
- y.Display = v("DropdownDisplay");
158
- y.displayName = "Dropdown";
159
- function O(l) {
160
- if (l == null) return "";
161
- if (typeof l == "object") {
162
- const t = l.props?.children;
163
- return t == null ? "" : typeof t == "object" ? (Array.isArray(t) ? t : [t]).map((f) => O(f)).join("") : t.toString();
161
+ const h = le(fe);
162
+ h.Item = g("DropdownItem");
163
+ h.Unselect = g("DropdownUnselect");
164
+ h.SelectAll = g("DropdownSelectAll");
165
+ h.EmptyItem = g("DropdownEmptyItem");
166
+ h.Display = g("DropdownDisplay");
167
+ h.displayName = "Dropdown";
168
+ function E(p) {
169
+ if (p == null) return "";
170
+ if (typeof p == "object") {
171
+ const r = p.props?.children;
172
+ return r == null ? "" : typeof r == "object" ? (Array.isArray(r) ? r : [r]).map((m) => E(m)).join("") : r.toString();
164
173
  }
165
- return l.toString();
174
+ return p.toString();
166
175
  }
167
176
  export {
168
- y as default
177
+ h as default
169
178
  };
@@ -1,7 +1,7 @@
1
1
  import { jsx as a } from "react/jsx-runtime";
2
2
  import { useRef as i, useCallback as p } from "react";
3
3
  import u from "../box.mjs";
4
- import { d as l } from "../core.mjs";
4
+ import { e as l } from "../core.mjs";
5
5
  function c(o) {
6
6
  const { onSubmit: r, props: e } = o, t = i(null), n = p(
7
7
  (m) => {