@clasing/ui 2.0.7 → 2.0.8

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../index-DSjHHn1r.cjs"),C=require("../badge-CS2XfLYQ.cjs"),x=require("../command-CHisYTN-.cjs"),b=require("../popover-BnLx2OY6.cjs"),s=require("react"),w=require("../icon-component-DTlgy__B.cjs"),M=s.createContext(null);function N({children:t,values:n,defaultValues:r,onValuesChange:o}){const[m,p]=s.useState(!1),[h,f]=s.useState(new Set(n??r)),[y,j]=s.useState(new Map);function E(c){const i=u=>{const a=new Set(u);return a.has(c)?a.delete(c):a.add(c),a};f(i),o?.([...i(h)])}const g=s.useCallback((c,i)=>{j(u=>u.get(c)===i?u:new Map(u).set(c,i))},[]);return e.jsxRuntimeExports.jsx(M,{value:{open:m,setOpen:p,selectedValues:n?new Set(n):h,toggleValue:E,items:y,onItemAdded:g},children:e.jsxRuntimeExports.jsx(b.Popover,{open:m,onOpenChange:p,children:t})})}function k({className:t,children:n,size:r="md",...o}){const{open:m}=R();return e.jsxRuntimeExports.jsx(b.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsxs("button",{...o,role:o.role??"combobox","aria-expanded":o["aria-expanded"]??m,"data-size":r,className:e.cn("border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg:not([class*='text-'])]:text-muted-foreground flex w-fit items-center justify-between gap-2 overflow-hidden rounded-md border bg-transparent whitespace-nowrap transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",r==="xs"&&'label-sm h-7 px-2 py-1 [&_svg:not([class*="size-"])]:size-3.5',r==="sm"&&"label-md h-8 px-2 py-1",r==="md"&&"label-lg h-12 px-3 py-1",r==="lg"&&"label-xl h-16 px-4 py-2",t),children:[n,e.jsxRuntimeExports.jsx(w.IconComponent,{iconName:"IconSelector",className:"size-4 shrink-0 opacity-50"})]})})}function V({placeholder:t,clickToRemove:n=!0,className:r,overflowBehavior:o="wrap-when-open",...m}){const{selectedValues:p,toggleValue:h,items:f,open:y}=R(),[j,E]=s.useState(0),g=s.useRef(null),c=s.useRef(null),i=s.useRef(new Set),u=o==="wrap"||o==="wrap-when-open"&&y;s.useEffect(()=>{u&&i.current.forEach(l=>l.style.removeProperty("display"))},[u]);const a=s.useCallback(()=>{if(g.current==null)return;const l=g.current,d=c.current;d!=null&&(d.style.display="none"),i.current.forEach(S=>S.style.removeProperty("display"));let v=0;for(let S=i.current.size-1;S>=0;S--){const I=[...i.current][S];if(l.scrollWidth<=l.clientWidth)break;v=i.current.size-S,I.style.display="none",d?.style.removeProperty("display")}E(v)},[]);return s.useEffect(()=>{if(g.current==null)return;const l=new ResizeObserver(a);return l.observe(g.current),()=>l.disconnect()},[a]),s.useLayoutEffect(()=>{a()},[p,a]),p.size===0&&t?e.jsxRuntimeExports.jsx("span",{className:"text-muted-foreground font-normal",children:t}):e.jsxRuntimeExports.jsxs("div",{...m,ref:g,className:e.cn("flex min-h-[1.75rem] w-full gap-1.5 overflow-hidden",u&&"flex-wrap",r),children:[[...p].filter(l=>f.has(l)).map(l=>e.jsxRuntimeExports.jsxs(C.Badge,{ref:d=>{if(d!=null)return i.current.add(d),()=>{i.current.delete(d)}},variant:"outline",className:"group flex items-center gap-1",onClick:n?d=>{d.stopPropagation(),h(l)}:void 0,children:[f.get(l),n&&e.jsxRuntimeExports.jsx(w.IconComponent,{iconName:"IconX",className:"text-muted-foreground group-hover:text-destructive size-2"})]},l)),e.jsxRuntimeExports.jsxs(C.Badge,{style:{display:j>0&&!u?"block":"none"},variant:"outline",ref:c,children:["+",j]})]})}function z({search:t=!0,children:n,...r}){const o=typeof t=="object"?!0:t;return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{style:{display:"none"},children:e.jsxRuntimeExports.jsx(x.Command,{children:e.jsxRuntimeExports.jsx(x.CommandList,{children:n})})}),e.jsxRuntimeExports.jsx(b.PopoverContent,{className:"min-w-[var(--radix-popover-trigger-width)] p-0",children:e.jsxRuntimeExports.jsxs(x.Command,{...r,children:[o?e.jsxRuntimeExports.jsx(x.CommandInput,{placeholder:typeof t=="object"?t.placeholder:void 0}):e.jsxRuntimeExports.jsx("button",{autoFocus:!0,"aria-hidden":"true",className:"sr-only"}),e.jsxRuntimeExports.jsxs(x.CommandList,{children:[o&&e.jsxRuntimeExports.jsx(x.CommandEmpty,{children:typeof t=="object"?t.emptyMessage:void 0}),n]})]})})]})}function P({value:t,children:n,badgeLabel:r,onSelect:o,...m}){const{toggleValue:p,selectedValues:h,onItemAdded:f}=R(),y=h.has(t);return s.useEffect(()=>{f(t,r??n)},[t,n,f,r]),e.jsxRuntimeExports.jsxs(x.CommandItem,{...m,value:t,onSelect:j=>{p(j),o?.(j)},children:[e.jsxRuntimeExports.jsx(w.IconComponent,{iconName:"IconCheck",className:e.cn("mr-2 size-4",y?"opacity-100":"opacity-0")}),n]})}function q(t){return e.jsxRuntimeExports.jsx(x.CommandGroup,{...t})}function O(t){return e.jsxRuntimeExports.jsx(x.CommandSeparator,{...t})}function R(){const t=s.useContext(M);if(t==null)throw new Error("useMultiSelectContext must be used within a MultiSelectContext");return t}exports.MultiSelect=N;exports.MultiSelectContent=z;exports.MultiSelectGroup=q;exports.MultiSelectItem=P;exports.MultiSelectSeparator=O;exports.MultiSelectTrigger=k;exports.MultiSelectValue=V;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../index-DSjHHn1r.cjs"),I=require("../badge-CS2XfLYQ.cjs"),m=require("../command-CHisYTN-.cjs"),N=require("../popover-BnLx2OY6.cjs"),n=require("react"),v=require("../icon-component-DTlgy__B.cjs"),V=n.createContext(null);function k({children:t,values:r,defaultValues:i,onValuesChange:u,isLoading:d,onSearchChange:c,loadingText:f="Loading...",noResultsText:a="No results found"}){const[h,p]=n.useState(!1),[y,j]=n.useState(new Set(r??i)),[b,x]=n.useState(new Map),[S,E]=n.useState("");function o(s){const g=R=>{const C=new Set(R);return C.has(s)?C.delete(s):C.add(s),C};j(g),u?.([...g(y)])}const l=n.useCallback((s,g)=>{x(R=>R.get(s)===g?R:new Map(R).set(s,g))},[]),w=n.useCallback(s=>{E(s),c?.(s)},[c]);return e.jsxRuntimeExports.jsx(V,{value:{open:h,setOpen:p,selectedValues:r?new Set(r):y,toggleValue:o,items:b,onItemAdded:l,isLoading:d,searchValue:S,onSearchChange:w,loadingText:f,noResultsText:a},children:e.jsxRuntimeExports.jsx(N.Popover,{open:h,onOpenChange:p,children:t})})}function z({className:t,children:r,size:i="md",...u}){const{open:d}=M();return e.jsxRuntimeExports.jsx(N.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsxs("button",{...u,role:u.role??"combobox","aria-expanded":u["aria-expanded"]??d,"data-size":i,className:e.cn("border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg:not([class*='text-'])]:text-muted-foreground flex w-fit items-center justify-between gap-2 overflow-hidden rounded-md border bg-transparent whitespace-nowrap transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",i==="xs"&&'label-sm h-7 px-2 py-1 [&_svg:not([class*="size-"])]:size-3.5',i==="sm"&&"label-md h-8 px-2 py-1",i==="md"&&"label-lg h-12 px-3 py-1",i==="lg"&&"label-xl h-16 px-4 py-2",t),children:[r,e.jsxRuntimeExports.jsx(v.IconComponent,{iconName:"IconSelector",className:"size-4 shrink-0 opacity-50"})]})})}function P({placeholder:t,clickToRemove:r=!0,className:i,overflowBehavior:u="wrap-when-open",...d}){const{selectedValues:c,toggleValue:f,items:a,open:h}=M(),[p,y]=n.useState(0),j=n.useRef(null),b=n.useRef(null),x=n.useRef(new Set),S=u==="wrap"||u==="wrap-when-open"&&h;n.useEffect(()=>{S&&x.current.forEach(o=>o.style.removeProperty("display"))},[S]);const E=n.useCallback(()=>{if(j.current==null)return;const o=j.current,l=b.current;l!=null&&(l.style.display="none"),x.current.forEach(s=>s.style.removeProperty("display"));let w=0;for(let s=x.current.size-1;s>=0;s--){const g=[...x.current][s];if(o.scrollWidth<=o.clientWidth)break;w=x.current.size-s,g.style.display="none",l?.style.removeProperty("display")}y(w)},[]);return n.useEffect(()=>{if(j.current==null)return;const o=new ResizeObserver(E);return o.observe(j.current),()=>o.disconnect()},[E]),n.useLayoutEffect(()=>{E()},[c,E]),c.size===0&&t?e.jsxRuntimeExports.jsx("span",{className:"text-muted-foreground font-normal",children:t}):e.jsxRuntimeExports.jsxs("div",{...d,ref:j,className:e.cn("flex min-h-[1.75rem] w-full gap-1.5 overflow-hidden",S&&"flex-wrap",i),children:[[...c].filter(o=>a.has(o)).map(o=>e.jsxRuntimeExports.jsxs(I.Badge,{ref:l=>{if(l!=null)return x.current.add(l),()=>{x.current.delete(l)}},variant:"outline",className:"group flex items-center gap-1",onClick:r?l=>{l.stopPropagation(),f(o)}:void 0,children:[a.get(o),r&&e.jsxRuntimeExports.jsx(v.IconComponent,{iconName:"IconX",className:"text-muted-foreground group-hover:text-destructive size-2"})]},o)),e.jsxRuntimeExports.jsxs(I.Badge,{style:{display:p>0&&!S?"block":"none"},variant:"outline",ref:b,children:["+",p]})]})}function q({search:t=!0,children:r,...i}){const{isLoading:u,onSearchChange:d,searchValue:c,noResultsText:f}=M(),a=typeof t=="object"?!0:t;return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{style:{display:"none"},children:e.jsxRuntimeExports.jsx(m.Command,{children:e.jsxRuntimeExports.jsx(m.CommandList,{children:r})})}),e.jsxRuntimeExports.jsx(N.PopoverContent,{className:"min-w-[var(--radix-popover-trigger-width)] p-0",children:e.jsxRuntimeExports.jsxs(m.Command,{...i,children:[a?e.jsxRuntimeExports.jsx(m.CommandInput,{placeholder:typeof t=="object"?t.placeholder:void 0,value:c,onValueChange:d}):e.jsxRuntimeExports.jsx("button",{autoFocus:!0,"aria-hidden":"true",className:"sr-only"}),e.jsxRuntimeExports.jsx(m.CommandList,{children:u?e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-center py-6",children:[e.jsxRuntimeExports.jsx(v.IconComponent,{iconName:"IconLoader2",className:"text-muted-foreground size-4 animate-spin"}),e.jsxRuntimeExports.jsx("span",{className:"text-muted-foreground ml-2 text-sm",children:u})]}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[a&&e.jsxRuntimeExports.jsx(m.CommandEmpty,{children:f}),r]})})]})})]})}function O({value:t,children:r,badgeLabel:i,onSelect:u,...d}){const{toggleValue:c,selectedValues:f,onItemAdded:a}=M(),h=f.has(t);return n.useEffect(()=>{a(t,i??r)},[t,r,a,i]),e.jsxRuntimeExports.jsxs(m.CommandItem,{...d,value:t,onSelect:p=>{c(p),u?.(p)},children:[e.jsxRuntimeExports.jsx(v.IconComponent,{iconName:"IconCheck",className:e.cn("mr-2 size-4",h?"opacity-100":"opacity-0")}),r]})}function L(t){return e.jsxRuntimeExports.jsx(m.CommandGroup,{...t})}function _(t){return e.jsxRuntimeExports.jsx(m.CommandSeparator,{...t})}function M(){const t=n.useContext(V);if(t==null)throw new Error("useMultiSelectContext must be used within a MultiSelectContext");return t}exports.MultiSelect=k;exports.MultiSelectContent=q;exports.MultiSelectGroup=L;exports.MultiSelectItem=O;exports.MultiSelectSeparator=_;exports.MultiSelectTrigger=z;exports.MultiSelectValue=P;
@@ -1,11 +1,15 @@
1
1
  import { Button } from '@/components/button';
2
2
  import { Command, CommandGroup, CommandItem, CommandSeparator } from '@/components/command';
3
3
  import { type ComponentPropsWithoutRef, type ReactNode } from 'react';
4
- declare function MultiSelect({ children, values, defaultValues, onValuesChange, }: {
4
+ declare function MultiSelect({ children, values, defaultValues, onValuesChange, isLoading, onSearchChange, loadingText, noResultsText, }: {
5
5
  children: ReactNode;
6
6
  values?: string[];
7
7
  defaultValues?: string[];
8
8
  onValuesChange?: (values: string[]) => void;
9
+ isLoading?: boolean;
10
+ onSearchChange?: (value: string) => void;
11
+ loadingText?: string;
12
+ noResultsText?: string;
9
13
  }): import("react/jsx-runtime").JSX.Element;
10
14
  declare function MultiSelectTrigger({ className, children, size, ...props }: {
11
15
  className?: string;
@@ -1,70 +1,84 @@
1
- import { j as t, c as S } from "../index-DBpnlzOP.js";
2
- import { B as I } from "../badge-B4oRxQ-G.js";
3
- import { C as k, f as E, d as O, b as R, c as _, e as A, g as W } from "../command-CGUB58ej.js";
4
- import { P as F, b as G, c as B } from "../popover-C6pozFVL.js";
5
- import { createContext as L, useState as y, useCallback as V, useEffect as v, useRef as j, useLayoutEffect as T, useContext as X } from "react";
6
- import { I as C } from "../icon-component-DGImZz3K.js";
7
- const z = L(null);
8
- function U({
9
- children: e,
10
- values: n,
11
- defaultValues: r,
12
- onValuesChange: o
1
+ import { j as e, c as z } from "../index-DBpnlzOP.js";
2
+ import { B as E } from "../badge-B4oRxQ-G.js";
3
+ import { C as P, f as R, d as _, b as A, c as L, e as F, g as W } from "../command-CGUB58ej.js";
4
+ import { P as G, b as T, c as B } from "../popover-C6pozFVL.js";
5
+ import { createContext as X, useState as y, useCallback as I, useEffect as k, useRef as V, useLayoutEffect as q, useContext as D } from "react";
6
+ import { I as N } from "../icon-component-DGImZz3K.js";
7
+ const O = X(null);
8
+ function Z({
9
+ children: t,
10
+ values: r,
11
+ defaultValues: o,
12
+ onValuesChange: a,
13
+ isLoading: u,
14
+ onSearchChange: l,
15
+ loadingText: p = "Loading...",
16
+ noResultsText: c = "No results found"
13
17
  }) {
14
- const [d, m] = y(!1), [g, p] = y(
15
- new Set(n ?? r)
16
- ), [w, f] = y(/* @__PURE__ */ new Map());
17
- function b(a) {
18
- const s = (l) => {
19
- const c = new Set(l);
20
- return c.has(a) ? c.delete(a) : c.add(a), c;
18
+ const [h, m] = y(!1), [b, f] = y(
19
+ new Set(r ?? o)
20
+ ), [v, d] = y(/* @__PURE__ */ new Map()), [g, j] = y("");
21
+ function s(n) {
22
+ const x = (w) => {
23
+ const C = new Set(w);
24
+ return C.has(n) ? C.delete(n) : C.add(n), C;
21
25
  };
22
- p(s), o?.([...s(g)]);
26
+ f(x), a?.([...x(b)]);
23
27
  }
24
- const x = V((a, s) => {
25
- f((l) => l.get(a) === s ? l : new Map(l).set(a, s));
26
- }, []);
27
- return /* @__PURE__ */ t.jsx(
28
- z,
28
+ const i = I((n, x) => {
29
+ d((w) => w.get(n) === x ? w : new Map(w).set(n, x));
30
+ }, []), S = I(
31
+ (n) => {
32
+ j(n), l?.(n);
33
+ },
34
+ [l]
35
+ );
36
+ return /* @__PURE__ */ e.jsx(
37
+ O,
29
38
  {
30
39
  value: {
31
- open: d,
40
+ open: h,
32
41
  setOpen: m,
33
- selectedValues: n ? new Set(n) : g,
34
- toggleValue: b,
35
- items: w,
36
- onItemAdded: x
42
+ selectedValues: r ? new Set(r) : b,
43
+ toggleValue: s,
44
+ items: v,
45
+ onItemAdded: i,
46
+ isLoading: u,
47
+ searchValue: g,
48
+ onSearchChange: S,
49
+ loadingText: p,
50
+ noResultsText: c
37
51
  },
38
- children: /* @__PURE__ */ t.jsx(F, { open: d, onOpenChange: m, children: e })
52
+ children: /* @__PURE__ */ e.jsx(G, { open: h, onOpenChange: m, children: t })
39
53
  }
40
54
  );
41
55
  }
42
- function Y({
43
- className: e,
44
- children: n,
45
- size: r = "md",
46
- ...o
56
+ function $({
57
+ className: t,
58
+ children: r,
59
+ size: o = "md",
60
+ ...a
47
61
  }) {
48
- const { open: d } = M();
49
- return /* @__PURE__ */ t.jsx(B, { asChild: !0, children: /* @__PURE__ */ t.jsxs(
62
+ const { open: u } = M();
63
+ return /* @__PURE__ */ e.jsx(B, { asChild: !0, children: /* @__PURE__ */ e.jsxs(
50
64
  "button",
51
65
  {
52
- ...o,
53
- role: o.role ?? "combobox",
54
- "aria-expanded": o["aria-expanded"] ?? d,
55
- "data-size": r,
56
- className: S(
66
+ ...a,
67
+ role: a.role ?? "combobox",
68
+ "aria-expanded": a["aria-expanded"] ?? u,
69
+ "data-size": o,
70
+ className: z(
57
71
  "border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg:not([class*='text-'])]:text-muted-foreground flex w-fit items-center justify-between gap-2 overflow-hidden rounded-md border bg-transparent whitespace-nowrap transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
58
- r === "xs" && 'label-sm h-7 px-2 py-1 [&_svg:not([class*="size-"])]:size-3.5',
59
- r === "sm" && "label-md h-8 px-2 py-1",
60
- r === "md" && "label-lg h-12 px-3 py-1",
61
- r === "lg" && "label-xl h-16 px-4 py-2",
62
- e
72
+ o === "xs" && 'label-sm h-7 px-2 py-1 [&_svg:not([class*="size-"])]:size-3.5',
73
+ o === "sm" && "label-md h-8 px-2 py-1",
74
+ o === "md" && "label-lg h-12 px-3 py-1",
75
+ o === "lg" && "label-xl h-16 px-4 py-2",
76
+ t
63
77
  ),
64
78
  children: [
65
- n,
66
- /* @__PURE__ */ t.jsx(
67
- C,
79
+ r,
80
+ /* @__PURE__ */ e.jsx(
81
+ N,
68
82
  {
69
83
  iconName: "IconSelector",
70
84
  className: "size-4 shrink-0 opacity-50"
@@ -74,65 +88,65 @@ function Y({
74
88
  }
75
89
  ) });
76
90
  }
77
- function Z({
78
- placeholder: e,
79
- clickToRemove: n = !0,
80
- className: r,
81
- overflowBehavior: o = "wrap-when-open",
82
- ...d
91
+ function ee({
92
+ placeholder: t,
93
+ clickToRemove: r = !0,
94
+ className: o,
95
+ overflowBehavior: a = "wrap-when-open",
96
+ ...u
83
97
  }) {
84
- const { selectedValues: m, toggleValue: g, items: p, open: w } = M(), [f, b] = y(0), x = j(null), a = j(null), s = j(/* @__PURE__ */ new Set()), l = o === "wrap" || o === "wrap-when-open" && w;
85
- v(() => {
86
- l && s.current.forEach((i) => i.style.removeProperty("display"));
87
- }, [l]);
88
- const c = V(() => {
89
- if (x.current == null) return;
90
- const i = x.current, u = a.current;
91
- u != null && (u.style.display = "none"), s.current.forEach((h) => h.style.removeProperty("display"));
92
- let N = 0;
93
- for (let h = s.current.size - 1; h >= 0; h--) {
94
- const P = [...s.current][h];
95
- if (i.scrollWidth <= i.clientWidth)
98
+ const { selectedValues: l, toggleValue: p, items: c, open: h } = M(), [m, b] = y(0), f = V(null), v = V(null), d = V(/* @__PURE__ */ new Set()), g = a === "wrap" || a === "wrap-when-open" && h;
99
+ k(() => {
100
+ g && d.current.forEach((s) => s.style.removeProperty("display"));
101
+ }, [g]);
102
+ const j = I(() => {
103
+ if (f.current == null) return;
104
+ const s = f.current, i = v.current;
105
+ i != null && (i.style.display = "none"), d.current.forEach((n) => n.style.removeProperty("display"));
106
+ let S = 0;
107
+ for (let n = d.current.size - 1; n >= 0; n--) {
108
+ const x = [...d.current][n];
109
+ if (s.scrollWidth <= s.clientWidth)
96
110
  break;
97
- N = s.current.size - h, P.style.display = "none", u?.style.removeProperty("display");
111
+ S = d.current.size - n, x.style.display = "none", i?.style.removeProperty("display");
98
112
  }
99
- b(N);
113
+ b(S);
100
114
  }, []);
101
- return v(() => {
102
- if (x.current == null) return;
103
- const i = new ResizeObserver(c);
104
- return i.observe(x.current), () => i.disconnect();
105
- }, [c]), T(() => {
106
- c();
107
- }, [m, c]), m.size === 0 && e ? /* @__PURE__ */ t.jsx("span", { className: "text-muted-foreground font-normal", children: e }) : /* @__PURE__ */ t.jsxs(
115
+ return k(() => {
116
+ if (f.current == null) return;
117
+ const s = new ResizeObserver(j);
118
+ return s.observe(f.current), () => s.disconnect();
119
+ }, [j]), q(() => {
120
+ j();
121
+ }, [l, j]), l.size === 0 && t ? /* @__PURE__ */ e.jsx("span", { className: "text-muted-foreground font-normal", children: t }) : /* @__PURE__ */ e.jsxs(
108
122
  "div",
109
123
  {
110
- ...d,
111
- ref: x,
112
- className: S(
124
+ ...u,
125
+ ref: f,
126
+ className: z(
113
127
  "flex min-h-[1.75rem] w-full gap-1.5 overflow-hidden",
114
- l && "flex-wrap",
115
- r
128
+ g && "flex-wrap",
129
+ o
116
130
  ),
117
131
  children: [
118
- [...m].filter((i) => p.has(i)).map((i) => /* @__PURE__ */ t.jsxs(
119
- I,
132
+ [...l].filter((s) => c.has(s)).map((s) => /* @__PURE__ */ e.jsxs(
133
+ E,
120
134
  {
121
- ref: (u) => {
122
- if (u != null)
123
- return s.current.add(u), () => {
124
- s.current.delete(u);
135
+ ref: (i) => {
136
+ if (i != null)
137
+ return d.current.add(i), () => {
138
+ d.current.delete(i);
125
139
  };
126
140
  },
127
141
  variant: "outline",
128
142
  className: "group flex items-center gap-1",
129
- onClick: n ? (u) => {
130
- u.stopPropagation(), g(i);
143
+ onClick: r ? (i) => {
144
+ i.stopPropagation(), p(s);
131
145
  } : void 0,
132
146
  children: [
133
- p.get(i),
134
- n && /* @__PURE__ */ t.jsx(
135
- C,
147
+ c.get(s),
148
+ r && /* @__PURE__ */ e.jsx(
149
+ N,
136
150
  {
137
151
  iconName: "IconX",
138
152
  className: "text-muted-foreground group-hover:text-destructive size-2"
@@ -140,19 +154,19 @@ function Z({
140
154
  )
141
155
  ]
142
156
  },
143
- i
157
+ s
144
158
  )),
145
- /* @__PURE__ */ t.jsxs(
146
- I,
159
+ /* @__PURE__ */ e.jsxs(
160
+ E,
147
161
  {
148
162
  style: {
149
- display: f > 0 && !l ? "block" : "none"
163
+ display: m > 0 && !g ? "block" : "none"
150
164
  },
151
165
  variant: "outline",
152
- ref: a,
166
+ ref: v,
153
167
  children: [
154
168
  "+",
155
- f
169
+ m
156
170
  ]
157
171
  }
158
172
  )
@@ -160,79 +174,90 @@ function Z({
160
174
  }
161
175
  );
162
176
  }
163
- function $({
164
- search: e = !0,
165
- children: n,
166
- ...r
177
+ function te({
178
+ search: t = !0,
179
+ children: r,
180
+ ...o
167
181
  }) {
168
- const o = typeof e == "object" ? !0 : e;
169
- return /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
170
- /* @__PURE__ */ t.jsx("div", { style: { display: "none" }, children: /* @__PURE__ */ t.jsx(k, { children: /* @__PURE__ */ t.jsx(E, { children: n }) }) }),
171
- /* @__PURE__ */ t.jsx(G, { className: "min-w-[var(--radix-popover-trigger-width)] p-0", children: /* @__PURE__ */ t.jsxs(k, { ...r, children: [
172
- o ? /* @__PURE__ */ t.jsx(
173
- O,
182
+ const { isLoading: a, onSearchChange: u, searchValue: l, noResultsText: p } = M(), c = typeof t == "object" ? !0 : t;
183
+ return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
184
+ /* @__PURE__ */ e.jsx("div", { style: { display: "none" }, children: /* @__PURE__ */ e.jsx(P, { children: /* @__PURE__ */ e.jsx(R, { children: r }) }) }),
185
+ /* @__PURE__ */ e.jsx(T, { className: "min-w-[var(--radix-popover-trigger-width)] p-0", children: /* @__PURE__ */ e.jsxs(P, { ...o, children: [
186
+ c ? /* @__PURE__ */ e.jsx(
187
+ _,
174
188
  {
175
- placeholder: typeof e == "object" ? e.placeholder : void 0
189
+ placeholder: typeof t == "object" ? t.placeholder : void 0,
190
+ value: l,
191
+ onValueChange: u
176
192
  }
177
- ) : /* @__PURE__ */ t.jsx("button", { autoFocus: !0, "aria-hidden": "true", className: "sr-only" }),
178
- /* @__PURE__ */ t.jsxs(E, { children: [
179
- o && /* @__PURE__ */ t.jsx(R, { children: typeof e == "object" ? e.emptyMessage : void 0 }),
180
- n
181
- ] })
193
+ ) : /* @__PURE__ */ e.jsx("button", { autoFocus: !0, "aria-hidden": "true", className: "sr-only" }),
194
+ /* @__PURE__ */ e.jsx(R, { children: a ? /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-center py-6", children: [
195
+ /* @__PURE__ */ e.jsx(
196
+ N,
197
+ {
198
+ iconName: "IconLoader2",
199
+ className: "text-muted-foreground size-4 animate-spin"
200
+ }
201
+ ),
202
+ /* @__PURE__ */ e.jsx("span", { className: "text-muted-foreground ml-2 text-sm", children: a })
203
+ ] }) : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
204
+ c && /* @__PURE__ */ e.jsx(A, { children: p }),
205
+ r
206
+ ] }) })
182
207
  ] }) })
183
208
  ] });
184
209
  }
185
- function ee({
186
- value: e,
187
- children: n,
188
- badgeLabel: r,
189
- onSelect: o,
190
- ...d
210
+ function ne({
211
+ value: t,
212
+ children: r,
213
+ badgeLabel: o,
214
+ onSelect: a,
215
+ ...u
191
216
  }) {
192
- const { toggleValue: m, selectedValues: g, onItemAdded: p } = M(), w = g.has(e);
193
- return v(() => {
194
- p(e, r ?? n);
195
- }, [e, n, p, r]), /* @__PURE__ */ t.jsxs(
196
- A,
217
+ const { toggleValue: l, selectedValues: p, onItemAdded: c } = M(), h = p.has(t);
218
+ return k(() => {
219
+ c(t, o ?? r);
220
+ }, [t, r, c, o]), /* @__PURE__ */ e.jsxs(
221
+ F,
197
222
  {
198
- ...d,
199
- value: e,
200
- onSelect: (f) => {
201
- m(f), o?.(f);
223
+ ...u,
224
+ value: t,
225
+ onSelect: (m) => {
226
+ l(m), a?.(m);
202
227
  },
203
228
  children: [
204
- /* @__PURE__ */ t.jsx(
205
- C,
229
+ /* @__PURE__ */ e.jsx(
230
+ N,
206
231
  {
207
232
  iconName: "IconCheck",
208
- className: S("mr-2 size-4", w ? "opacity-100" : "opacity-0")
233
+ className: z("mr-2 size-4", h ? "opacity-100" : "opacity-0")
209
234
  }
210
235
  ),
211
- n
236
+ r
212
237
  ]
213
238
  }
214
239
  );
215
240
  }
216
- function te(e) {
217
- return /* @__PURE__ */ t.jsx(_, { ...e });
241
+ function re(t) {
242
+ return /* @__PURE__ */ e.jsx(L, { ...t });
218
243
  }
219
- function ne(e) {
220
- return /* @__PURE__ */ t.jsx(W, { ...e });
244
+ function se(t) {
245
+ return /* @__PURE__ */ e.jsx(W, { ...t });
221
246
  }
222
247
  function M() {
223
- const e = X(z);
224
- if (e == null)
248
+ const t = D(O);
249
+ if (t == null)
225
250
  throw new Error(
226
251
  "useMultiSelectContext must be used within a MultiSelectContext"
227
252
  );
228
- return e;
253
+ return t;
229
254
  }
230
255
  export {
231
- U as MultiSelect,
232
- $ as MultiSelectContent,
233
- te as MultiSelectGroup,
234
- ee as MultiSelectItem,
235
- ne as MultiSelectSeparator,
236
- Y as MultiSelectTrigger,
237
- Z as MultiSelectValue
256
+ Z as MultiSelect,
257
+ te as MultiSelectContent,
258
+ re as MultiSelectGroup,
259
+ ne as MultiSelectItem,
260
+ se as MultiSelectSeparator,
261
+ $ as MultiSelectTrigger,
262
+ ee as MultiSelectValue
238
263
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clasing/ui",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
4
4
  "type": "module",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",