@vlrc-fe/components 1.0.0

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 (219) hide show
  1. package/README.md +193 -0
  2. package/dist/index.cjs +1 -0
  3. package/dist/index.js +42 -0
  4. package/dist/index10.cjs +1 -0
  5. package/dist/index10.js +85 -0
  6. package/dist/index100.cjs +1 -0
  7. package/dist/index100.js +65 -0
  8. package/dist/index101.cjs +1 -0
  9. package/dist/index101.js +48 -0
  10. package/dist/index102.cjs +1 -0
  11. package/dist/index102.js +67 -0
  12. package/dist/index103.cjs +1 -0
  13. package/dist/index103.js +151 -0
  14. package/dist/index104.cjs +1 -0
  15. package/dist/index104.js +23 -0
  16. package/dist/index105.cjs +1 -0
  17. package/dist/index105.js +27 -0
  18. package/dist/index106.cjs +1 -0
  19. package/dist/index106.js +53 -0
  20. package/dist/index107.cjs +1 -0
  21. package/dist/index107.js +161 -0
  22. package/dist/index108.cjs +1 -0
  23. package/dist/index108.js +16 -0
  24. package/dist/index109.cjs +1 -0
  25. package/dist/index11.cjs +1 -0
  26. package/dist/index11.js +86 -0
  27. package/dist/index12.cjs +1 -0
  28. package/dist/index12.js +122 -0
  29. package/dist/index13.cjs +1 -0
  30. package/dist/index13.js +14 -0
  31. package/dist/index14.cjs +1 -0
  32. package/dist/index14.js +16 -0
  33. package/dist/index15.cjs +1 -0
  34. package/dist/index15.js +115 -0
  35. package/dist/index16.cjs +1 -0
  36. package/dist/index16.js +727 -0
  37. package/dist/index17.cjs +1 -0
  38. package/dist/index17.js +348 -0
  39. package/dist/index18.cjs +1 -0
  40. package/dist/index18.js +76 -0
  41. package/dist/index19.cjs +1 -0
  42. package/dist/index19.js +14 -0
  43. package/dist/index2.cjs +1 -0
  44. package/dist/index2.js +122 -0
  45. package/dist/index20.cjs +1 -0
  46. package/dist/index20.js +116 -0
  47. package/dist/index21.cjs +1 -0
  48. package/dist/index21.js +35 -0
  49. package/dist/index22.cjs +1 -0
  50. package/dist/index22.js +18 -0
  51. package/dist/index23.cjs +1 -0
  52. package/dist/index23.js +27 -0
  53. package/dist/index24.cjs +1 -0
  54. package/dist/index24.js +35 -0
  55. package/dist/index25.cjs +1 -0
  56. package/dist/index25.js +97 -0
  57. package/dist/index26.cjs +1 -0
  58. package/dist/index26.js +28 -0
  59. package/dist/index27.cjs +1 -0
  60. package/dist/index27.js +14 -0
  61. package/dist/index28.cjs +1 -0
  62. package/dist/index28.js +67 -0
  63. package/dist/index29.cjs +1 -0
  64. package/dist/index29.js +13 -0
  65. package/dist/index3.cjs +1 -0
  66. package/dist/index3.js +8 -0
  67. package/dist/index30.cjs +1 -0
  68. package/dist/index30.js +35 -0
  69. package/dist/index31.cjs +1 -0
  70. package/dist/index31.js +43 -0
  71. package/dist/index32.cjs +1 -0
  72. package/dist/index32.js +14 -0
  73. package/dist/index33.cjs +1 -0
  74. package/dist/index33.js +64 -0
  75. package/dist/index34.cjs +1 -0
  76. package/dist/index34.js +23 -0
  77. package/dist/index35.cjs +1 -0
  78. package/dist/index35.js +34 -0
  79. package/dist/index36.cjs +1 -0
  80. package/dist/index36.js +27 -0
  81. package/dist/index37.cjs +1 -0
  82. package/dist/index37.js +26 -0
  83. package/dist/index38.cjs +1 -0
  84. package/dist/index38.js +157 -0
  85. package/dist/index39.cjs +1 -0
  86. package/dist/index39.js +34 -0
  87. package/dist/index4.cjs +1 -0
  88. package/dist/index4.js +43 -0
  89. package/dist/index40.cjs +1 -0
  90. package/dist/index40.js +46 -0
  91. package/dist/index41.cjs +1 -0
  92. package/dist/index41.js +118 -0
  93. package/dist/index42.cjs +1 -0
  94. package/dist/index42.js +125 -0
  95. package/dist/index43.cjs +1 -0
  96. package/dist/index43.js +26 -0
  97. package/dist/index44.cjs +1 -0
  98. package/dist/index44.js +88 -0
  99. package/dist/index45.cjs +1 -0
  100. package/dist/index45.js +221 -0
  101. package/dist/index46.cjs +1 -0
  102. package/dist/index46.js +166 -0
  103. package/dist/index47.cjs +1 -0
  104. package/dist/index47.js +126 -0
  105. package/dist/index48.cjs +1 -0
  106. package/dist/index48.js +15 -0
  107. package/dist/index49.cjs +1 -0
  108. package/dist/index49.js +9 -0
  109. package/dist/index5.cjs +1 -0
  110. package/dist/index5.js +24 -0
  111. package/dist/index50.cjs +1 -0
  112. package/dist/index50.js +17 -0
  113. package/dist/index51.cjs +1 -0
  114. package/dist/index51.js +22 -0
  115. package/dist/index52.cjs +1 -0
  116. package/dist/index52.js +18 -0
  117. package/dist/index53.cjs +1 -0
  118. package/dist/index53.js +6 -0
  119. package/dist/index54.cjs +1 -0
  120. package/dist/index54.js +7 -0
  121. package/dist/index55.cjs +1 -0
  122. package/dist/index55.js +8 -0
  123. package/dist/index56.cjs +1 -0
  124. package/dist/index56.js +7 -0
  125. package/dist/index57.cjs +1 -0
  126. package/dist/index57.js +7 -0
  127. package/dist/index58.cjs +1 -0
  128. package/dist/index58.js +9 -0
  129. package/dist/index59.cjs +1 -0
  130. package/dist/index59.js +69 -0
  131. package/dist/index6.cjs +1 -0
  132. package/dist/index6.js +51 -0
  133. package/dist/index60.cjs +1 -0
  134. package/dist/index60.js +11 -0
  135. package/dist/index61.cjs +1 -0
  136. package/dist/index61.js +202 -0
  137. package/dist/index62.cjs +1 -0
  138. package/dist/index62.js +124 -0
  139. package/dist/index63.cjs +1 -0
  140. package/dist/index63.js +32 -0
  141. package/dist/index64.cjs +1 -0
  142. package/dist/index64.js +20 -0
  143. package/dist/index65.cjs +1 -0
  144. package/dist/index65.js +69 -0
  145. package/dist/index66.cjs +1 -0
  146. package/dist/index66.js +32 -0
  147. package/dist/index67.cjs +1 -0
  148. package/dist/index67.js +11 -0
  149. package/dist/index68.cjs +1 -0
  150. package/dist/index68.js +280 -0
  151. package/dist/index69.cjs +1 -0
  152. package/dist/index69.js +157 -0
  153. package/dist/index7.cjs +1 -0
  154. package/dist/index7.js +88 -0
  155. package/dist/index70.cjs +1 -0
  156. package/dist/index70.js +20 -0
  157. package/dist/index71.cjs +1 -0
  158. package/dist/index71.js +10 -0
  159. package/dist/index72.cjs +1 -0
  160. package/dist/index72.js +14 -0
  161. package/dist/index73.cjs +1 -0
  162. package/dist/index73.js +8 -0
  163. package/dist/index74.cjs +1 -0
  164. package/dist/index74.js +8 -0
  165. package/dist/index75.cjs +1 -0
  166. package/dist/index75.js +11 -0
  167. package/dist/index76.cjs +1 -0
  168. package/dist/index76.js +10 -0
  169. package/dist/index77.cjs +1 -0
  170. package/dist/index77.js +6 -0
  171. package/dist/index78.cjs +1 -0
  172. package/dist/index78.js +8 -0
  173. package/dist/index79.cjs +1 -0
  174. package/dist/index79.js +8 -0
  175. package/dist/index8.cjs +1 -0
  176. package/dist/index8.js +68 -0
  177. package/dist/index80.cjs +1 -0
  178. package/dist/index80.js +10 -0
  179. package/dist/index81.cjs +1 -0
  180. package/dist/index81.js +11 -0
  181. package/dist/index82.cjs +1 -0
  182. package/dist/index82.js +15 -0
  183. package/dist/index83.cjs +1 -0
  184. package/dist/index83.js +11 -0
  185. package/dist/index84.cjs +1 -0
  186. package/dist/index84.js +11 -0
  187. package/dist/index85.cjs +1 -0
  188. package/dist/index85.js +6 -0
  189. package/dist/index86.cjs +1 -0
  190. package/dist/index86.js +43 -0
  191. package/dist/index87.cjs +1 -0
  192. package/dist/index87.js +382 -0
  193. package/dist/index88.cjs +1 -0
  194. package/dist/index88.js +40 -0
  195. package/dist/index89.cjs +1 -0
  196. package/dist/index89.js +23 -0
  197. package/dist/index9.cjs +1 -0
  198. package/dist/index9.js +20 -0
  199. package/dist/index90.cjs +1 -0
  200. package/dist/index90.js +59 -0
  201. package/dist/index91.cjs +1 -0
  202. package/dist/index91.js +55 -0
  203. package/dist/index92.cjs +1 -0
  204. package/dist/index92.js +54 -0
  205. package/dist/index93.cjs +1 -0
  206. package/dist/index93.js +57 -0
  207. package/dist/index94.cjs +1 -0
  208. package/dist/index94.js +57 -0
  209. package/dist/index95.cjs +1 -0
  210. package/dist/index95.js +88 -0
  211. package/dist/index96.cjs +1 -0
  212. package/dist/index96.js +66 -0
  213. package/dist/index97.cjs +1 -0
  214. package/dist/index97.js +594 -0
  215. package/dist/index98.cjs +9 -0
  216. package/dist/index98.js +30 -0
  217. package/dist/index99.cjs +1 -0
  218. package/dist/index99.js +50 -0
  219. package/package.json +82 -0
@@ -0,0 +1,125 @@
1
+ import { cn as e } from "./index3.js";
2
+ import { Button as t } from "./index6.js";
3
+ import { Checkbox as n } from "./index9.js";
4
+ import { Field as r, FieldContent as i, FieldDescription as a, FieldError as o, FieldLabel as s } from "./index15.js";
5
+ import { Controller as c } from "./index17.js";
6
+ import { Input as l } from "./index19.js";
7
+ import { Select as u, SelectContent as d, SelectTrigger as f, SelectValue as p } from "./index25.js";
8
+ import { Textarea as m } from "./index29.js";
9
+ import { Icons as h } from "./index41.js";
10
+ import { useState as g } from "react";
11
+ import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
12
+ //#region src/Form/Form.tsx
13
+ var b = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, x = /^(0|\+84)(3|5|7|8|9)[0-9]{8}$/, S = (e, t) => {
14
+ let n = e.toLowerCase();
15
+ if (t === "password") return n.includes("confirm") || n.includes("new") ? "new-password" : "current-password";
16
+ if (t === "email" || n.includes("email")) return "email";
17
+ if (t === "tel" || n.includes("phone")) return "tel";
18
+ if (n.includes("name")) return "name";
19
+ if (n.includes("username")) return "username";
20
+ };
21
+ function C({ children: e, label: t, control: n, name: l, htmlType: u, description: d, controlFirst: f, horizontal: p, rules: m, className: h }) {
22
+ return /* @__PURE__ */ v(c, {
23
+ control: n,
24
+ name: l,
25
+ rules: (() => {
26
+ let e = { ...m };
27
+ return u === "email" && !m?.pattern && (e.pattern = {
28
+ value: b,
29
+ message: "Email không hợp lệ"
30
+ }), u === "tel" && !m?.pattern && (e.pattern = {
31
+ value: x,
32
+ message: "Số điện thoại không hợp lệ"
33
+ }), m?.required !== void 0 && m.required !== !1 && (typeof m.required == "string" ? e.required = m.required : typeof m.required == "object" ? m.required.message || (e.required = {
34
+ ...m.required,
35
+ message: "Trường này là bắt buộc"
36
+ }) : e.required = "Trường này là bắt buộc"), e;
37
+ })(),
38
+ render: ({ field: n, fieldState: c }) => {
39
+ let l = /* @__PURE__ */ y(_, { children: [t && /* @__PURE__ */ y(s, {
40
+ htmlFor: n.name,
41
+ children: [t, m?.required && /* @__PURE__ */ v("span", {
42
+ className: "text-red-500 ml-1",
43
+ children: "*"
44
+ })]
45
+ }), d && /* @__PURE__ */ v(a, { children: d })] }), u = e({
46
+ ...n,
47
+ id: n.name,
48
+ "aria-invalid": c.invalid
49
+ }), g = c.invalid && /* @__PURE__ */ v(o, { errors: [c.error] });
50
+ return /* @__PURE__ */ v(r, {
51
+ className: h,
52
+ "data-invalid": c.invalid,
53
+ orientation: p ? "horizontal" : void 0,
54
+ children: f ? /* @__PURE__ */ y(_, { children: [u, /* @__PURE__ */ y(i, { children: [l, g] })] }) : /* @__PURE__ */ y(_, { children: [
55
+ /* @__PURE__ */ v(i, { children: l }),
56
+ u,
57
+ g
58
+ ] })
59
+ });
60
+ }
61
+ });
62
+ }
63
+ var w = ({ placeholder: n, inputClassName: r, leftIcon: i, rightIcon: a, disabled: o, autoComplete: s, ...c }) => {
64
+ let [u, d] = g(!1), f = c.htmlType === "password", p = s ?? S(String(c.name), c.htmlType);
65
+ return /* @__PURE__ */ v(C, {
66
+ ...c,
67
+ children: (s) => /* @__PURE__ */ y("div", {
68
+ className: "relative",
69
+ children: [
70
+ i && /* @__PURE__ */ v("div", {
71
+ className: "absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none",
72
+ children: i
73
+ }),
74
+ /* @__PURE__ */ v(l, {
75
+ ...s,
76
+ type: f && u ? "text" : c.htmlType,
77
+ autoComplete: p,
78
+ placeholder: n,
79
+ disabled: o,
80
+ className: e(i && "pl-10", (f || a) && "pr-10", r)
81
+ }),
82
+ f && /* @__PURE__ */ v(t, {
83
+ type: "button",
84
+ variant: "ghost",
85
+ size: "icon-sm",
86
+ onClick: () => d(!u),
87
+ className: "absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",
88
+ tabIndex: -1,
89
+ children: v(u ? h.EyeOff : h.Eye, { className: "h-4 w-4" })
90
+ }),
91
+ !f && a && /* @__PURE__ */ v("div", {
92
+ className: "absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none",
93
+ children: a
94
+ })
95
+ ]
96
+ })
97
+ });
98
+ }, T = (e) => /* @__PURE__ */ v(C, {
99
+ ...e,
100
+ children: (e) => /* @__PURE__ */ v(m, { ...e })
101
+ }), E = ({ children: e, ...t }) => /* @__PURE__ */ v(C, {
102
+ ...t,
103
+ children: ({ onChange: t, onBlur: n, ...r }) => /* @__PURE__ */ y(u, {
104
+ ...r,
105
+ onValueChange: t,
106
+ children: [/* @__PURE__ */ v(f, {
107
+ "aria-invalid": r["aria-invalid"],
108
+ id: r.id,
109
+ onBlur: n,
110
+ children: /* @__PURE__ */ v(p, {})
111
+ }), /* @__PURE__ */ v(d, { children: e })]
112
+ })
113
+ }), D = ({ disabled: e, ...t }) => /* @__PURE__ */ v(C, {
114
+ ...t,
115
+ horizontal: !0,
116
+ controlFirst: !0,
117
+ children: ({ onChange: t, value: r, ...i }) => /* @__PURE__ */ v(n, {
118
+ ...i,
119
+ checked: r,
120
+ onCheckedChange: t,
121
+ disabled: e
122
+ })
123
+ });
124
+ //#endregion
125
+ export { C as FormBase, D as FormCheckbox, w as FormInput, E as FormSimpleSelect, T as FormTextarea };
@@ -0,0 +1 @@
1
+ const e=require("./index4.cjs"),t=require("./index7.cjs"),n=require("./index10.cjs"),r=require("./index16.cjs"),i=require("./index18.cjs"),a=require("./index20.cjs"),o=require("./index26.cjs"),s=require("./index30.cjs"),c=require("./index42.cjs");let l=require("react"),u=require("react/jsx-runtime");var d=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,f=/^(0|\+84)(3|5|7|8|9)[0-9]{8}$/,p=(e,t)=>{let n=e.toLowerCase();if(t===`password`)return n.includes(`confirm`)||n.includes(`new`)?`new-password`:`current-password`;if(t===`email`||n.includes(`email`))return`email`;if(t===`tel`||n.includes(`phone`))return`tel`;if(n.includes(`name`))return`name`;if(n.includes(`username`))return`username`};function m({children:e,label:t,control:n,name:a,htmlType:o,description:s,controlFirst:c,horizontal:l,rules:p,className:m}){return(0,u.jsx)(i.Controller,{control:n,name:a,rules:(()=>{let e={...p};return o===`email`&&!p?.pattern&&(e.pattern={value:d,message:`Email không hợp lệ`}),o===`tel`&&!p?.pattern&&(e.pattern={value:f,message:`Số điện thoại không hợp lệ`}),p?.required!==void 0&&p.required!==!1&&(typeof p.required==`string`?e.required=p.required:typeof p.required==`object`?p.required.message||(e.required={...p.required,message:`Trường này là bắt buộc`}):e.required=`Trường này là bắt buộc`),e})(),render:({field:n,fieldState:i})=>{let a=(0,u.jsxs)(u.Fragment,{children:[t&&(0,u.jsxs)(r.FieldLabel,{htmlFor:n.name,children:[t,p?.required&&(0,u.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),s&&(0,u.jsx)(r.FieldDescription,{children:s})]}),o=e({...n,id:n.name,"aria-invalid":i.invalid}),d=i.invalid&&(0,u.jsx)(r.FieldError,{errors:[i.error]});return(0,u.jsx)(r.Field,{className:m,"data-invalid":i.invalid,orientation:l?`horizontal`:void 0,children:c?(0,u.jsxs)(u.Fragment,{children:[o,(0,u.jsxs)(r.FieldContent,{children:[a,d]})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(r.FieldContent,{children:a}),o,d]})})}})}var h=({placeholder:n,inputClassName:r,leftIcon:i,rightIcon:o,disabled:s,autoComplete:d,...f})=>{let[h,g]=(0,l.useState)(!1),_=f.htmlType===`password`,v=d??p(String(f.name),f.htmlType);return(0,u.jsx)(m,{...f,children:l=>(0,u.jsxs)(`div`,{className:`relative`,children:[i&&(0,u.jsx)(`div`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none`,children:i}),(0,u.jsx)(a.Input,{...l,type:_&&h?`text`:f.htmlType,autoComplete:v,placeholder:n,disabled:s,className:e.cn(i&&`pl-10`,(_||o)&&`pr-10`,r)}),_&&(0,u.jsx)(t.Button,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:()=>g(!h),className:`absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,tabIndex:-1,children:h?(0,u.jsx)(c.Icons.EyeOff,{className:`h-4 w-4`}):(0,u.jsx)(c.Icons.Eye,{className:`h-4 w-4`})}),!_&&o&&(0,u.jsx)(`div`,{className:`absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none`,children:o})]})})},g=e=>(0,u.jsx)(m,{...e,children:e=>(0,u.jsx)(s.Textarea,{...e})}),_=({children:e,...t})=>(0,u.jsx)(m,{...t,children:({onChange:t,onBlur:n,...r})=>(0,u.jsxs)(o.Select,{...r,onValueChange:t,children:[(0,u.jsx)(o.SelectTrigger,{"aria-invalid":r[`aria-invalid`],id:r.id,onBlur:n,children:(0,u.jsx)(o.SelectValue,{})}),(0,u.jsx)(o.SelectContent,{children:e})]})}),v=({disabled:e,...t})=>(0,u.jsx)(m,{...t,horizontal:!0,controlFirst:!0,children:({onChange:t,value:r,...i})=>(0,u.jsx)(n.Checkbox,{...i,checked:r,onCheckedChange:t,disabled:e})});exports.FormBase=m,exports.FormCheckbox=v,exports.FormInput=h,exports.FormSimpleSelect=_,exports.FormTextarea=g;
@@ -0,0 +1,26 @@
1
+ import { cva as e } from "class-variance-authority";
2
+ //#region src/MultiSelect/type.ts
3
+ var t = e("m-1 transition-all duration-300 ease-in-out", {
4
+ variants: {
5
+ variant: {
6
+ default: "border-foreground/10 text-foreground bg-card hover:bg-card/80",
7
+ secondary: "border-foreground/10 bg-secondary text-secondary-foreground hover:bg-secondary/80",
8
+ destructive: "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
9
+ inverted: "inverted"
10
+ },
11
+ badgeAnimation: {
12
+ bounce: "hover:-translate-y-1 hover:scale-110",
13
+ pulse: "hover:animate-pulse",
14
+ wiggle: "hover:animate-wiggle",
15
+ fade: "hover:opacity-80",
16
+ slide: "hover:translate-x-1",
17
+ none: ""
18
+ }
19
+ },
20
+ defaultVariants: {
21
+ variant: "default",
22
+ badgeAnimation: "bounce"
23
+ }
24
+ });
25
+ //#endregion
26
+ export { t as multiSelectVariants };
@@ -0,0 +1 @@
1
+ var e=(0,require("class-variance-authority").cva)(`m-1 transition-all duration-300 ease-in-out`,{variants:{variant:{default:`border-foreground/10 text-foreground bg-card hover:bg-card/80`,secondary:`border-foreground/10 bg-secondary text-secondary-foreground hover:bg-secondary/80`,destructive:`border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80`,inverted:`inverted`},badgeAnimation:{bounce:`hover:-translate-y-1 hover:scale-110`,pulse:`hover:animate-pulse`,wiggle:`hover:animate-wiggle`,fade:`hover:opacity-80`,slide:`hover:translate-x-1`,none:``}},defaultVariants:{variant:`default`,badgeAnimation:`bounce`}});exports.multiSelectVariants=e;
@@ -0,0 +1,88 @@
1
+ //#region src/MultiSelect/utils.ts
2
+ var e = (e) => Array.isArray(e) && e.length > 0 && "heading" in e[0], t = (e, t) => {
3
+ if (e.length !== t.length) return !1;
4
+ let n = [...e].sort(), r = [...t].sort();
5
+ return n.every((e, t) => e === r[t]);
6
+ }, n = (t, n) => {
7
+ if (t.length === 0) return {
8
+ options: [],
9
+ duplicates: []
10
+ };
11
+ let r = e(t) ? t.flatMap((e) => e.options) : t, i = /* @__PURE__ */ new Set(), a = [], o = [];
12
+ return r.forEach((e) => {
13
+ i.has(e.value) ? (a.push(e.value), n || o.push(e)) : (i.add(e.value), o.push(e));
14
+ }), {
15
+ options: n ? o : r,
16
+ duplicates: a
17
+ };
18
+ }, r = (e, t, n) => {
19
+ if (!e) return {
20
+ maxCount: t,
21
+ hideIcons: !1,
22
+ compactMode: !1
23
+ };
24
+ if (e === !0) {
25
+ let e = {
26
+ mobile: {
27
+ maxCount: 2,
28
+ hideIcons: !1,
29
+ compactMode: !0
30
+ },
31
+ tablet: {
32
+ maxCount: 4,
33
+ hideIcons: !1,
34
+ compactMode: !1
35
+ },
36
+ desktop: {
37
+ maxCount: 6,
38
+ hideIcons: !1,
39
+ compactMode: !1
40
+ }
41
+ }[n];
42
+ return {
43
+ maxCount: e?.maxCount ?? t,
44
+ hideIcons: e?.hideIcons ?? !1,
45
+ compactMode: e?.compactMode ?? !1
46
+ };
47
+ }
48
+ let r = e[n];
49
+ return {
50
+ maxCount: r?.maxCount ?? t,
51
+ hideIcons: r?.hideIcons ?? !1,
52
+ compactMode: r?.compactMode ?? !1
53
+ };
54
+ }, i = (e, t) => {
55
+ if (t?.badgeAnimation) switch (t.badgeAnimation) {
56
+ case "bounce": return e ? "animate-bounce" : "hover:-translate-y-1 hover:scale-110";
57
+ case "pulse": return "hover:animate-pulse";
58
+ case "wiggle": return "hover:animate-wiggle";
59
+ case "fade": return "hover:opacity-80";
60
+ case "slide": return "hover:translate-x-1";
61
+ case "none": return "";
62
+ default: return "";
63
+ }
64
+ return e ? "animate-bounce" : "";
65
+ }, a = (e) => {
66
+ if (e?.popoverAnimation) switch (e.popoverAnimation) {
67
+ case "scale": return "animate-scaleIn";
68
+ case "slide": return "animate-slideInDown";
69
+ case "fade": return "animate-fadeIn";
70
+ case "flip": return "animate-flipIn";
71
+ case "none": return "";
72
+ default: return "";
73
+ }
74
+ return "";
75
+ }, o = (t, n, r) => !r || !n ? t : t.length === 0 ? [] : e(t) ? t.map((e) => ({
76
+ ...e,
77
+ options: e.options.filter((e) => e.label.toLowerCase().includes(n.toLowerCase()) || e.value.toLowerCase().includes(n.toLowerCase()))
78
+ })).filter((e) => e.options.length > 0) : t.filter((e) => e.label.toLowerCase().includes(n.toLowerCase()) || e.value.toLowerCase().includes(n.toLowerCase())), s = (e, t, n, r) => ({
79
+ minWidth: n || (e === "mobile" ? "0px" : "200px"),
80
+ maxWidth: r || "100%",
81
+ width: t ? "auto" : "100%"
82
+ }), c = (e, t) => {
83
+ if (!t) return e.length;
84
+ let n = t.toLowerCase();
85
+ return e.filter((e) => e.label.toLowerCase().includes(n) || e.value.toLowerCase().includes(n)).length;
86
+ };
87
+ //#endregion
88
+ export { t as arraysEqual, n as buildAllOptions, i as buildBadgeAnimationClass, a as buildPopoverAnimationClass, s as buildWidthConstraints, r as computeResponsiveSettings, c as countMatchingOptions, o as filterOptions, e as isGroupedOptions };
@@ -0,0 +1 @@
1
+ var e=e=>Array.isArray(e)&&e.length>0&&`heading`in e[0],t=(e,t)=>{if(e.length!==t.length)return!1;let n=[...e].sort(),r=[...t].sort();return n.every((e,t)=>e===r[t])},n=(t,n)=>{if(t.length===0)return{options:[],duplicates:[]};let r=e(t)?t.flatMap(e=>e.options):t,i=new Set,a=[],o=[];return r.forEach(e=>{i.has(e.value)?(a.push(e.value),n||o.push(e)):(i.add(e.value),o.push(e))}),{options:n?o:r,duplicates:a}},r=(e,t,n)=>{if(!e)return{maxCount:t,hideIcons:!1,compactMode:!1};if(e===!0){let e={mobile:{maxCount:2,hideIcons:!1,compactMode:!0},tablet:{maxCount:4,hideIcons:!1,compactMode:!1},desktop:{maxCount:6,hideIcons:!1,compactMode:!1}}[n];return{maxCount:e?.maxCount??t,hideIcons:e?.hideIcons??!1,compactMode:e?.compactMode??!1}}let r=e[n];return{maxCount:r?.maxCount??t,hideIcons:r?.hideIcons??!1,compactMode:r?.compactMode??!1}},i=(e,t)=>{if(t?.badgeAnimation)switch(t.badgeAnimation){case`bounce`:return e?`animate-bounce`:`hover:-translate-y-1 hover:scale-110`;case`pulse`:return`hover:animate-pulse`;case`wiggle`:return`hover:animate-wiggle`;case`fade`:return`hover:opacity-80`;case`slide`:return`hover:translate-x-1`;case`none`:return``;default:return``}return e?`animate-bounce`:``},a=e=>{if(e?.popoverAnimation)switch(e.popoverAnimation){case`scale`:return`animate-scaleIn`;case`slide`:return`animate-slideInDown`;case`fade`:return`animate-fadeIn`;case`flip`:return`animate-flipIn`;case`none`:return``;default:return``}return``},o=(t,n,r)=>!r||!n?t:t.length===0?[]:e(t)?t.map(e=>({...e,options:e.options.filter(e=>e.label.toLowerCase().includes(n.toLowerCase())||e.value.toLowerCase().includes(n.toLowerCase()))})).filter(e=>e.options.length>0):t.filter(e=>e.label.toLowerCase().includes(n.toLowerCase())||e.value.toLowerCase().includes(n.toLowerCase())),s=(e,t,n,r)=>({minWidth:n||(e===`mobile`?`0px`:`200px`),maxWidth:r||`100%`,width:t?`auto`:`100%`}),c=(e,t)=>{if(!t)return e.length;let n=t.toLowerCase();return e.filter(e=>e.label.toLowerCase().includes(n)||e.value.toLowerCase().includes(n)).length};exports.arraysEqual=t,exports.buildAllOptions=n,exports.buildBadgeAnimationClass=i,exports.buildPopoverAnimationClass=a,exports.buildWidthConstraints=s,exports.computeResponsiveSettings=r,exports.countMatchingOptions=c,exports.filterOptions=o,exports.isGroupedOptions=e;
@@ -0,0 +1,221 @@
1
+ import { cn as e } from "./index3.js";
2
+ import { Badge as t } from "./index5.js";
3
+ import { Command as n, CommandEmpty as r, CommandGroup as i, CommandInput as a, CommandItem as o, CommandList as s, CommandSeparator as c } from "./index11.js";
4
+ import { Separator as l } from "./index14.js";
5
+ import { multiSelectVariants as u } from "./index43.js";
6
+ import { isGroupedOptions as d } from "./index44.js";
7
+ import { CheckIcon as f, ChevronDown as p, XCircle as m, XIcon as h } from "lucide-react";
8
+ import "react";
9
+ import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
10
+ //#region src/MultiSelect/renderers.tsx
11
+ var y = ({ politeMessage: e, assertiveMessage: t }) => /* @__PURE__ */ v("div", {
12
+ className: "sr-only",
13
+ children: [/* @__PURE__ */ _("div", {
14
+ "aria-live": "polite",
15
+ "aria-atomic": "true",
16
+ role: "status",
17
+ children: e
18
+ }), /* @__PURE__ */ _("div", {
19
+ "aria-live": "assertive",
20
+ "aria-atomic": "true",
21
+ role: "alert",
22
+ children: t
23
+ })]
24
+ }), b = ({ selectedValues: n, responsiveSettings: r, screenSize: i, singleLine: a, animation: o, animationConfig: s, badgeAnimationClass: c, variant: d, getOptionByValue: f, toggleOption: g, clearExtraOptions: y, handleClear: b }) => /* @__PURE__ */ v("div", {
25
+ className: "flex justify-between items-center w-full",
26
+ children: [/* @__PURE__ */ v("div", {
27
+ className: e("flex items-center gap-1", a ? "overflow-x-auto multiselect-singleline-scroll" : "flex-wrap", r.compactMode && "gap-0.5"),
28
+ style: a ? { paddingBottom: "4px" } : {},
29
+ children: [n.slice(0, r.maxCount).map((n) => {
30
+ let l = f(n), p = l?.icon, h = l?.style;
31
+ if (!l) return null;
32
+ let y = {
33
+ animationDuration: `${o}s`,
34
+ ...h?.badgeColor && { backgroundColor: h.badgeColor },
35
+ ...h?.gradient && {
36
+ background: h.gradient,
37
+ color: "white"
38
+ }
39
+ };
40
+ return /* @__PURE__ */ v(t, {
41
+ className: e(c, u({ variant: d }), h?.gradient && "text-white border-transparent", r.compactMode && "text-xs px-1.5 py-0.5", i === "mobile" && "max-w-30 truncate", a && "shrink-0 whitespace-nowrap", "[&>svg]:pointer-events-auto"),
42
+ style: {
43
+ ...y,
44
+ animationDuration: `${s?.duration || o}s`,
45
+ animationDelay: `${s?.delay || 0}s`
46
+ },
47
+ children: [
48
+ p && !r.hideIcons && /* @__PURE__ */ _(p, {
49
+ className: e("h-4 w-4 mr-2", r.compactMode && "h-3 w-3 mr-1", h?.iconColor && "text-current"),
50
+ ...h?.iconColor && { style: { color: h.iconColor } }
51
+ }),
52
+ /* @__PURE__ */ _("span", {
53
+ className: e(i === "mobile" && "truncate"),
54
+ children: l.label
55
+ }),
56
+ /* @__PURE__ */ _("div", {
57
+ role: "button",
58
+ tabIndex: 0,
59
+ onClick: (e) => {
60
+ e.stopPropagation(), g(n);
61
+ },
62
+ onKeyDown: (e) => {
63
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), e.stopPropagation(), g(n));
64
+ },
65
+ "aria-label": `Remove ${l.label} from selection`,
66
+ className: "ml-2 h-4 w-4 cursor-pointer hover:bg-white/20 rounded-sm p-0.5 -m-0.5 focus:outline-none focus:ring-1 focus:ring-white/50",
67
+ children: /* @__PURE__ */ _(m, { className: e("h-3 w-3", r.compactMode && "h-2.5 w-2.5") })
68
+ })
69
+ ]
70
+ }, n);
71
+ }).filter(Boolean), n.length > r.maxCount && /* @__PURE__ */ v(t, {
72
+ className: e("bg-transparent text-foreground border-foreground/1 hover:bg-transparent", c, u({ variant: d }), r.compactMode && "text-xs px-1.5 py-0.5", a && "shrink-0 whitespace-nowrap", "[&>svg]:pointer-events-auto"),
73
+ style: {
74
+ animationDuration: `${s?.duration || o}s`,
75
+ animationDelay: `${s?.delay || 0}s`
76
+ },
77
+ children: [`+ ${n.length - r.maxCount} more`, /* @__PURE__ */ _(m, {
78
+ className: e("ml-2 h-4 w-4 cursor-pointer", r.compactMode && "ml-1 h-3 w-3"),
79
+ onClick: (e) => {
80
+ e.stopPropagation(), y();
81
+ }
82
+ })]
83
+ })]
84
+ }), /* @__PURE__ */ v("div", {
85
+ className: "flex items-center justify-between",
86
+ children: [
87
+ /* @__PURE__ */ _("div", {
88
+ role: "button",
89
+ tabIndex: 0,
90
+ onClick: (e) => {
91
+ e.stopPropagation(), b();
92
+ },
93
+ onKeyDown: (e) => {
94
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), e.stopPropagation(), b());
95
+ },
96
+ "aria-label": `Clear all ${n.length} selected options`,
97
+ className: "flex items-center justify-center h-4 w-4 mx-2 cursor-pointer text-muted-foreground hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1 rounded-sm",
98
+ children: /* @__PURE__ */ _(h, { className: "h-4 w-4" })
99
+ }),
100
+ /* @__PURE__ */ _(l, {
101
+ orientation: "vertical",
102
+ className: "flex min-h-6 h-full"
103
+ }),
104
+ /* @__PURE__ */ _(p, {
105
+ className: "h-4 mx-2 cursor-pointer text-muted-foreground",
106
+ "aria-hidden": "true"
107
+ })
108
+ ]
109
+ })]
110
+ }), x = ({ placeholder: e }) => /* @__PURE__ */ v("div", {
111
+ className: "flex items-center justify-between w-full mx-auto",
112
+ children: [/* @__PURE__ */ _("span", {
113
+ className: "text-sm text-muted-foreground mx-3",
114
+ children: e
115
+ }), /* @__PURE__ */ _(p, { className: "h-4 cursor-pointer text-muted-foreground mx-2" })]
116
+ }), S = ({ filteredOptions: t, hideSelectAll: u, searchValue: p, searchable: m, selectedValues: h, getAllOptions: y, toggleAll: b, toggleOption: x, handleClear: S, setIsPopoverOpen: C, handleInputKeyDown: w, setSearchValue: T, multiSelectId: E, emptyIndicator: D, screenSize: O }) => /* @__PURE__ */ v(n, { children: [
117
+ m && /* @__PURE__ */ _(a, {
118
+ placeholder: "Search options...",
119
+ onKeyDown: w,
120
+ value: p,
121
+ onValueChange: T,
122
+ "aria-label": "Search through available options",
123
+ "aria-describedby": `${E}-search-help`
124
+ }),
125
+ m && /* @__PURE__ */ _("div", {
126
+ id: `${E}-search-help`,
127
+ className: "sr-only",
128
+ children: "Type to filter options. Use arrow keys to navigate results."
129
+ }),
130
+ /* @__PURE__ */ v(s, {
131
+ className: e("max-h-[40vh] overflow-y-auto multiselect-scrollbar", O === "mobile" && "max-h-[50vh]", "overscroll-behavior-y-contain"),
132
+ children: [
133
+ /* @__PURE__ */ _(r, { children: D || "No results found." }),
134
+ " ",
135
+ !u && !p && /* @__PURE__ */ _(i, { children: /* @__PURE__ */ v(o, {
136
+ onSelect: b,
137
+ role: "option",
138
+ "aria-selected": h.length === y().filter((e) => !e.disabled).length,
139
+ "aria-label": `Select all ${y().length} options`,
140
+ className: "cursor-pointer",
141
+ children: [/* @__PURE__ */ _("div", {
142
+ className: e("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary", h.length === y().filter((e) => !e.disabled).length ? "bg-primary text-primary-foreground" : "opacity-50 [&_svg]:invisible"),
143
+ "aria-hidden": "true",
144
+ children: /* @__PURE__ */ _(f, { className: "h-4 w-4" })
145
+ }), /* @__PURE__ */ v("span", { children: [
146
+ "(Select All",
147
+ y().length > 20 ? ` - ${y().length} options` : "",
148
+ ")"
149
+ ] })]
150
+ }, "all") }),
151
+ d(t) ? t.map((t) => /* @__PURE__ */ _(i, {
152
+ heading: t.heading,
153
+ children: t.options.map((t) => {
154
+ let n = h.includes(t.value);
155
+ return /* @__PURE__ */ v(o, {
156
+ onSelect: () => x(t.value),
157
+ role: "option",
158
+ "aria-selected": n,
159
+ "aria-disabled": t.disabled,
160
+ "aria-label": `${t.label}${n ? ", selected" : ", not selected"}${t.disabled ? ", disabled" : ""}`,
161
+ className: e("cursor-pointer", t.disabled && "opacity-50 cursor-not-allowed"),
162
+ disabled: t.disabled,
163
+ children: [
164
+ /* @__PURE__ */ _("div", {
165
+ className: e("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary", n ? "bg-primary text-primary-foreground" : "opacity-50 [&_svg]:invisible"),
166
+ "aria-hidden": "true",
167
+ children: /* @__PURE__ */ _(f, { className: "h-4 w-4" })
168
+ }),
169
+ t.icon && /* @__PURE__ */ _(t.icon, {
170
+ className: "mr-2 h-4 w-4 text-muted-foreground",
171
+ "aria-hidden": "true"
172
+ }),
173
+ /* @__PURE__ */ _("span", { children: t.label })
174
+ ]
175
+ }, t.value);
176
+ })
177
+ }, t.heading)) : /* @__PURE__ */ _(i, { children: t.map((t) => {
178
+ let n = h.includes(t.value);
179
+ return /* @__PURE__ */ v(o, {
180
+ onSelect: () => x(t.value),
181
+ role: "option",
182
+ "aria-selected": n,
183
+ "aria-disabled": t.disabled,
184
+ "aria-label": `${t.label}${n ? ", selected" : ", not selected"}${t.disabled ? ", disabled" : ""}`,
185
+ className: e("cursor-pointer", t.disabled && "opacity-50 cursor-not-allowed"),
186
+ disabled: t.disabled,
187
+ children: [
188
+ /* @__PURE__ */ _("div", {
189
+ className: e("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary", n ? "bg-primary text-primary-foreground" : "opacity-50 [&_svg]:invisible"),
190
+ "aria-hidden": "true",
191
+ children: /* @__PURE__ */ _(f, { className: "h-4 w-4" })
192
+ }),
193
+ t.icon && /* @__PURE__ */ _(t.icon, {
194
+ className: "mr-2 h-4 w-4 text-muted-foreground",
195
+ "aria-hidden": "true"
196
+ }),
197
+ /* @__PURE__ */ _("span", { children: t.label })
198
+ ]
199
+ }, t.value);
200
+ }) }),
201
+ /* @__PURE__ */ _(c, {}),
202
+ /* @__PURE__ */ _(i, { children: /* @__PURE__ */ v("div", {
203
+ className: "flex items-center justify-between",
204
+ children: [h.length > 0 && /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ _(o, {
205
+ onSelect: S,
206
+ className: "flex-1 justify-center cursor-pointer",
207
+ children: "Clear"
208
+ }), /* @__PURE__ */ _(l, {
209
+ orientation: "vertical",
210
+ className: "flex min-h-6 h-full"
211
+ })] }), /* @__PURE__ */ _(o, {
212
+ onSelect: () => C(!1),
213
+ className: "flex-1 justify-center cursor-pointer max-w-full",
214
+ children: "Close"
215
+ })]
216
+ }) })
217
+ ]
218
+ })
219
+ ] });
220
+ //#endregion
221
+ export { y as LiveRegion, S as OptionsContent, x as PlaceholderContent, b as SelectedValuesContent };
@@ -0,0 +1 @@
1
+ const e=require("./index4.cjs"),t=require("./index6.cjs"),n=require("./index12.cjs"),r=require("./index15.cjs"),i=require("./index44.cjs"),a=require("./index45.cjs");let o=require("lucide-react");require("react");let s=require("react/jsx-runtime");var c=({politeMessage:e,assertiveMessage:t})=>(0,s.jsxs)(`div`,{className:`sr-only`,children:[(0,s.jsx)(`div`,{"aria-live":`polite`,"aria-atomic":`true`,role:`status`,children:e}),(0,s.jsx)(`div`,{"aria-live":`assertive`,"aria-atomic":`true`,role:`alert`,children:t})]}),l=({selectedValues:n,responsiveSettings:a,screenSize:c,singleLine:l,animation:u,animationConfig:d,badgeAnimationClass:f,variant:p,getOptionByValue:m,toggleOption:h,clearExtraOptions:g,handleClear:_})=>(0,s.jsxs)(`div`,{className:`flex justify-between items-center w-full`,children:[(0,s.jsxs)(`div`,{className:e.cn(`flex items-center gap-1`,l?`overflow-x-auto multiselect-singleline-scroll`:`flex-wrap`,a.compactMode&&`gap-0.5`),style:l?{paddingBottom:`4px`}:{},children:[n.slice(0,a.maxCount).map(n=>{let r=m(n),g=r?.icon,_=r?.style;if(!r)return null;let v={animationDuration:`${u}s`,..._?.badgeColor&&{backgroundColor:_.badgeColor},..._?.gradient&&{background:_.gradient,color:`white`}};return(0,s.jsxs)(t.Badge,{className:e.cn(f,i.multiSelectVariants({variant:p}),_?.gradient&&`text-white border-transparent`,a.compactMode&&`text-xs px-1.5 py-0.5`,c===`mobile`&&`max-w-30 truncate`,l&&`shrink-0 whitespace-nowrap`,`[&>svg]:pointer-events-auto`),style:{...v,animationDuration:`${d?.duration||u}s`,animationDelay:`${d?.delay||0}s`},children:[g&&!a.hideIcons&&(0,s.jsx)(g,{className:e.cn(`h-4 w-4 mr-2`,a.compactMode&&`h-3 w-3 mr-1`,_?.iconColor&&`text-current`),..._?.iconColor&&{style:{color:_.iconColor}}}),(0,s.jsx)(`span`,{className:e.cn(c===`mobile`&&`truncate`),children:r.label}),(0,s.jsx)(`div`,{role:`button`,tabIndex:0,onClick:e=>{e.stopPropagation(),h(n)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),h(n))},"aria-label":`Remove ${r.label} from selection`,className:`ml-2 h-4 w-4 cursor-pointer hover:bg-white/20 rounded-sm p-0.5 -m-0.5 focus:outline-none focus:ring-1 focus:ring-white/50`,children:(0,s.jsx)(o.XCircle,{className:e.cn(`h-3 w-3`,a.compactMode&&`h-2.5 w-2.5`)})})]},n)}).filter(Boolean),n.length>a.maxCount&&(0,s.jsxs)(t.Badge,{className:e.cn(`bg-transparent text-foreground border-foreground/1 hover:bg-transparent`,f,i.multiSelectVariants({variant:p}),a.compactMode&&`text-xs px-1.5 py-0.5`,l&&`shrink-0 whitespace-nowrap`,`[&>svg]:pointer-events-auto`),style:{animationDuration:`${d?.duration||u}s`,animationDelay:`${d?.delay||0}s`},children:[`+ ${n.length-a.maxCount} more`,(0,s.jsx)(o.XCircle,{className:e.cn(`ml-2 h-4 w-4 cursor-pointer`,a.compactMode&&`ml-1 h-3 w-3`),onClick:e=>{e.stopPropagation(),g()}})]})]}),(0,s.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,s.jsx)(`div`,{role:`button`,tabIndex:0,onClick:e=>{e.stopPropagation(),_()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),_())},"aria-label":`Clear all ${n.length} selected options`,className:`flex items-center justify-center h-4 w-4 mx-2 cursor-pointer text-muted-foreground hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1 rounded-sm`,children:(0,s.jsx)(o.XIcon,{className:`h-4 w-4`})}),(0,s.jsx)(r.Separator,{orientation:`vertical`,className:`flex min-h-6 h-full`}),(0,s.jsx)(o.ChevronDown,{className:`h-4 mx-2 cursor-pointer text-muted-foreground`,"aria-hidden":`true`})]})]}),u=({placeholder:e})=>(0,s.jsxs)(`div`,{className:`flex items-center justify-between w-full mx-auto`,children:[(0,s.jsx)(`span`,{className:`text-sm text-muted-foreground mx-3`,children:e}),(0,s.jsx)(o.ChevronDown,{className:`h-4 cursor-pointer text-muted-foreground mx-2`})]}),d=({filteredOptions:t,hideSelectAll:i,searchValue:c,searchable:l,selectedValues:u,getAllOptions:d,toggleAll:f,toggleOption:p,handleClear:m,setIsPopoverOpen:h,handleInputKeyDown:g,setSearchValue:_,multiSelectId:v,emptyIndicator:y,screenSize:b})=>(0,s.jsxs)(n.Command,{children:[l&&(0,s.jsx)(n.CommandInput,{placeholder:`Search options...`,onKeyDown:g,value:c,onValueChange:_,"aria-label":`Search through available options`,"aria-describedby":`${v}-search-help`}),l&&(0,s.jsx)(`div`,{id:`${v}-search-help`,className:`sr-only`,children:`Type to filter options. Use arrow keys to navigate results.`}),(0,s.jsxs)(n.CommandList,{className:e.cn(`max-h-[40vh] overflow-y-auto multiselect-scrollbar`,b===`mobile`&&`max-h-[50vh]`,`overscroll-behavior-y-contain`),children:[(0,s.jsx)(n.CommandEmpty,{children:y||`No results found.`}),` `,!i&&!c&&(0,s.jsx)(n.CommandGroup,{children:(0,s.jsxs)(n.CommandItem,{onSelect:f,role:`option`,"aria-selected":u.length===d().filter(e=>!e.disabled).length,"aria-label":`Select all ${d().length} options`,className:`cursor-pointer`,children:[(0,s.jsx)(`div`,{className:e.cn(`mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary`,u.length===d().filter(e=>!e.disabled).length?`bg-primary text-primary-foreground`:`opacity-50 [&_svg]:invisible`),"aria-hidden":`true`,children:(0,s.jsx)(o.CheckIcon,{className:`h-4 w-4`})}),(0,s.jsxs)(`span`,{children:[`(Select All`,d().length>20?` - ${d().length} options`:``,`)`]})]},`all`)}),a.isGroupedOptions(t)?t.map(t=>(0,s.jsx)(n.CommandGroup,{heading:t.heading,children:t.options.map(t=>{let r=u.includes(t.value);return(0,s.jsxs)(n.CommandItem,{onSelect:()=>p(t.value),role:`option`,"aria-selected":r,"aria-disabled":t.disabled,"aria-label":`${t.label}${r?`, selected`:`, not selected`}${t.disabled?`, disabled`:``}`,className:e.cn(`cursor-pointer`,t.disabled&&`opacity-50 cursor-not-allowed`),disabled:t.disabled,children:[(0,s.jsx)(`div`,{className:e.cn(`mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary`,r?`bg-primary text-primary-foreground`:`opacity-50 [&_svg]:invisible`),"aria-hidden":`true`,children:(0,s.jsx)(o.CheckIcon,{className:`h-4 w-4`})}),t.icon&&(0,s.jsx)(t.icon,{className:`mr-2 h-4 w-4 text-muted-foreground`,"aria-hidden":`true`}),(0,s.jsx)(`span`,{children:t.label})]},t.value)})},t.heading)):(0,s.jsx)(n.CommandGroup,{children:t.map(t=>{let r=u.includes(t.value);return(0,s.jsxs)(n.CommandItem,{onSelect:()=>p(t.value),role:`option`,"aria-selected":r,"aria-disabled":t.disabled,"aria-label":`${t.label}${r?`, selected`:`, not selected`}${t.disabled?`, disabled`:``}`,className:e.cn(`cursor-pointer`,t.disabled&&`opacity-50 cursor-not-allowed`),disabled:t.disabled,children:[(0,s.jsx)(`div`,{className:e.cn(`mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary`,r?`bg-primary text-primary-foreground`:`opacity-50 [&_svg]:invisible`),"aria-hidden":`true`,children:(0,s.jsx)(o.CheckIcon,{className:`h-4 w-4`})}),t.icon&&(0,s.jsx)(t.icon,{className:`mr-2 h-4 w-4 text-muted-foreground`,"aria-hidden":`true`}),(0,s.jsx)(`span`,{children:t.label})]},t.value)})}),(0,s.jsx)(n.CommandSeparator,{}),(0,s.jsx)(n.CommandGroup,{children:(0,s.jsxs)(`div`,{className:`flex items-center justify-between`,children:[u.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.CommandItem,{onSelect:m,className:`flex-1 justify-center cursor-pointer`,children:`Clear`}),(0,s.jsx)(r.Separator,{orientation:`vertical`,className:`flex min-h-6 h-full`})]}),(0,s.jsx)(n.CommandItem,{onSelect:()=>h(!1),className:`flex-1 justify-center cursor-pointer max-w-full`,children:`Close`})]})})]})]});exports.LiveRegion=c,exports.OptionsContent=d,exports.PlaceholderContent=u,exports.SelectedValuesContent=l;
@@ -0,0 +1,166 @@
1
+ import { arraysEqual as e, buildAllOptions as t, buildBadgeAnimationClass as n, buildPopoverAnimationClass as r, buildWidthConstraints as i, computeResponsiveSettings as ee, countMatchingOptions as a, filterOptions as te } from "./index44.js";
2
+ import { useCallback as o, useEffect as s, useId as ne, useImperativeHandle as re, useMemo as c, useRef as l, useState as u } from "react";
3
+ //#region src/MultiSelect/useMultiSelect.ts
4
+ var d = ({ forwardedRef: d, ...f }) => {
5
+ let { options: p, onValueChange: m, defaultValue: h = [], animationConfig: g, maxCount: _ = 3, responsive: v, minWidth: y, maxWidth: b, deduplicateOptions: x = !1, resetOnDefaultValueChange: S = !0, closeOnSelect: C = !1, searchable: w = !0, autoSize: T = !1, disabled: E = !1 } = f, [D, O] = u(h), [k, A] = u(!1), [j, M] = u(!1), [N, P] = u(""), [F, ie] = u("desktop"), [I, L] = u(""), [ae, R] = u(""), z = l(D.length), B = l(k), V = l(N), H = ne(), U = `${H}-listbox`, W = `${H}-description`, G = `${H}-count`, K = l(h), q = l(null), J = o((e, t = "polite") => {
6
+ t === "assertive" ? (R(e), setTimeout(() => R(""), 100)) : (L(e), setTimeout(() => L(""), 100));
7
+ }, []), Y = o(() => {
8
+ let { options: e, duplicates: n } = t(p, x);
9
+ return e;
10
+ }, [x, p]), X = o((e) => Y().find((t) => t.value === e), [Y]), oe = c(() => te(p, N, w), [
11
+ p,
12
+ N,
13
+ w
14
+ ]), se = (e) => {
15
+ if (!E) {
16
+ if (e.key === "Enter") A(!0);
17
+ else if (e.key === "Backspace" && !e.currentTarget.value) {
18
+ let e = [...D];
19
+ e.pop(), O(e), m(e);
20
+ }
21
+ }
22
+ }, ce = (e) => {
23
+ if (E || X(e)?.disabled) return;
24
+ let t = D.includes(e) ? D.filter((t) => t !== e) : [...D, e];
25
+ O(t), m(t), C && A(!1);
26
+ }, Z = () => {
27
+ E || (O([]), m([]));
28
+ }, Q = () => {
29
+ E || A((e) => !e);
30
+ }, $ = c(() => ee(v, _, F), [
31
+ v,
32
+ _,
33
+ F
34
+ ]), le = () => {
35
+ if (E) return;
36
+ let e = D.slice(0, $.maxCount);
37
+ O(e), m(e);
38
+ }, ue = () => {
39
+ if (E) return;
40
+ let e = Y().filter((e) => !e.disabled);
41
+ if (D.length === e.length) Z();
42
+ else {
43
+ let t = e.map((e) => e.value);
44
+ O(t), m(t);
45
+ }
46
+ C && A(!1);
47
+ }, de = c(() => i(F, T, y, b), [
48
+ T,
49
+ b,
50
+ y,
51
+ F
52
+ ]);
53
+ s(() => {
54
+ if (!S) return;
55
+ let t = K.current;
56
+ e(t, h) || (e(D, h) || O(h), K.current = [...h]);
57
+ }, [
58
+ e,
59
+ h,
60
+ S,
61
+ D
62
+ ]), s(() => {
63
+ k || P("");
64
+ }, [k]), s(() => {
65
+ let e = D.length, t = Y(), n = t.filter((e) => !e.disabled).length;
66
+ if (e !== z.current) {
67
+ let r = e - z.current;
68
+ if (r > 0) {
69
+ let i = D.slice(-r).map((e) => t.find((t) => t.value === e)?.label).filter(Boolean);
70
+ i.length === 1 ? J(`${i[0]} selected. ${e} of ${n} options selected.`) : J(`${i.length} options selected. ${e} of ${n} total selected.`);
71
+ } else r < 0 && J(`Option removed. ${e} of ${n} options selected.`);
72
+ z.current = e;
73
+ }
74
+ if (k !== B.current && (J(k ? `Dropdown opened. ${n} options available. Use arrow keys to navigate.` : "Dropdown closed."), B.current = k), N !== V.current && N !== void 0) {
75
+ if (N && k) {
76
+ let e = a(t, N);
77
+ J(`${e} option${e === 1 ? "" : "s"} found for "${N}"`);
78
+ }
79
+ V.current = N;
80
+ }
81
+ }, [
82
+ J,
83
+ a,
84
+ Y,
85
+ k,
86
+ N,
87
+ D
88
+ ]), s(() => {
89
+ if (typeof window > "u") return;
90
+ let e = () => {
91
+ let e = window.innerWidth;
92
+ ie(e < 640 ? "mobile" : e < 1024 ? "tablet" : "desktop");
93
+ };
94
+ return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
95
+ }, []);
96
+ let fe = c(() => n(j, g), [g, j]), pe = c(() => r(g), [g]);
97
+ return re(d, () => ({
98
+ reset: () => {
99
+ O(h), A(!1), P(""), m(h);
100
+ },
101
+ getSelectedValues: () => D,
102
+ setSelectedValues: (e) => {
103
+ O(e), m(e);
104
+ },
105
+ clear: () => {
106
+ O([]), m([]);
107
+ },
108
+ focus: () => {
109
+ if (q.current) {
110
+ q.current.focus();
111
+ let e = q.current.style.outline, t = q.current.style.outlineOffset;
112
+ q.current.style.outline = "2px solid hsl(var(--ring))", q.current.style.outlineOffset = "2px", setTimeout(() => {
113
+ q.current && (q.current.style.outline = e, q.current.style.outlineOffset = t);
114
+ }, 1e3);
115
+ }
116
+ }
117
+ }), [
118
+ h,
119
+ d,
120
+ m,
121
+ D
122
+ ]), {
123
+ ids: {
124
+ multiSelectId: H,
125
+ listboxId: U,
126
+ triggerDescriptionId: W,
127
+ selectedCountId: G
128
+ },
129
+ state: {
130
+ selectedValues: D,
131
+ isPopoverOpen: k,
132
+ isAnimating: j,
133
+ searchValue: N,
134
+ screenSize: F
135
+ },
136
+ derived: {
137
+ filteredOptions: oe,
138
+ responsiveSettings: $,
139
+ widthConstraints: de,
140
+ badgeAnimationClass: fe,
141
+ popoverAnimationClass: pe
142
+ },
143
+ refs: { buttonRef: q },
144
+ helpers: {
145
+ getAllOptions: Y,
146
+ getOptionByValue: X
147
+ },
148
+ a11yMessages: {
149
+ politeMessage: I,
150
+ assertiveMessage: ae
151
+ },
152
+ handlers: {
153
+ setIsPopoverOpen: A,
154
+ handleTogglePopover: Q,
155
+ handleInputKeyDown: se,
156
+ toggleOption: ce,
157
+ handleClear: Z,
158
+ clearExtraOptions: le,
159
+ toggleAll: ue,
160
+ setSearchValue: P,
161
+ setIsAnimating: M
162
+ }
163
+ };
164
+ };
165
+ //#endregion
166
+ export { d as useMultiSelect };