wimui 0.59.0 → 0.60.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/components/_internal/useInlineFloating.cjs +2 -0
  2. package/dist/components/_internal/useInlineFloating.d.ts +54 -0
  3. package/dist/components/_internal/useInlineFloating.js +61 -0
  4. package/dist/components/ai/ModelSelector/ModelSelector.cjs +1 -1
  5. package/dist/components/ai/ModelSelector/ModelSelector.js +88 -84
  6. package/dist/components/ai/ModelSelector/model-selector.module.cjs +1 -1
  7. package/dist/components/ai/ModelSelector/model-selector.module.js +1 -1
  8. package/dist/components/ai/SourceCitation/SourceCitation.cjs +1 -1
  9. package/dist/components/ai/SourceCitation/SourceCitation.d.ts +5 -1
  10. package/dist/components/ai/SourceCitation/SourceCitation.js +10 -8
  11. package/dist/components/data-display/DataGrid/DataGrid.cjs +1 -1
  12. package/dist/components/data-display/DataGrid/DataGrid.d.ts +5 -1
  13. package/dist/components/data-display/DataGrid/DataGrid.js +54 -53
  14. package/dist/components/data-display/FAQSection/FAQSection.cjs +1 -1
  15. package/dist/components/data-display/FAQSection/FAQSection.d.ts +5 -1
  16. package/dist/components/data-display/FAQSection/FAQSection.js +5 -3
  17. package/dist/components/data-display/TreeView/TreeView.cjs +1 -1
  18. package/dist/components/data-display/TreeView/TreeView.d.ts +5 -1
  19. package/dist/components/data-display/TreeView/TreeView.js +87 -87
  20. package/dist/components/feedback/Notification/Notification.cjs +1 -1
  21. package/dist/components/feedback/Notification/Notification.d.ts +5 -1
  22. package/dist/components/feedback/Notification/Notification.js +10 -8
  23. package/dist/components/feedback/Toast/Toast.cjs +1 -1
  24. package/dist/components/feedback/Toast/Toast.d.ts +5 -1
  25. package/dist/components/feedback/Toast/Toast.js +11 -9
  26. package/dist/components/form/Cascader/Cascader.cjs +1 -1
  27. package/dist/components/form/Cascader/Cascader.js +89 -85
  28. package/dist/components/form/Cascader/cascader.module.cjs +1 -1
  29. package/dist/components/form/Cascader/cascader.module.js +6 -6
  30. package/dist/components/form/Combobox/Combobox.cjs +1 -1
  31. package/dist/components/form/Combobox/Combobox.js +108 -102
  32. package/dist/components/form/Combobox/combobox.module.cjs +1 -1
  33. package/dist/components/form/Combobox/combobox.module.js +1 -1
  34. package/dist/components/form/DatePicker/DatePicker.cjs +1 -1
  35. package/dist/components/form/DatePicker/DatePicker.js +90 -85
  36. package/dist/components/form/DatePicker/date-picker.module.cjs +1 -1
  37. package/dist/components/form/DatePicker/date-picker.module.js +1 -1
  38. package/dist/components/form/Mentions/Mentions.cjs +1 -1
  39. package/dist/components/form/Mentions/Mentions.js +4 -4
  40. package/dist/components/form/MultiSelect/MultiSelect.cjs +1 -1
  41. package/dist/components/form/MultiSelect/MultiSelect.js +80 -77
  42. package/dist/components/form/MultiSelect/multiselect.module.cjs +1 -1
  43. package/dist/components/form/MultiSelect/multiselect.module.js +1 -1
  44. package/dist/components/form/PhoneInput/PhoneInput.cjs +1 -1
  45. package/dist/components/form/PhoneInput/PhoneInput.js +117 -111
  46. package/dist/components/form/PhoneInput/phone-input.module.cjs +1 -1
  47. package/dist/components/form/PhoneInput/phone-input.module.js +1 -1
  48. package/dist/components/form/Select/Select.cjs +1 -1
  49. package/dist/components/form/Select/Select.js +96 -89
  50. package/dist/components/form/Select/select.module.cjs +1 -1
  51. package/dist/components/form/Select/select.module.js +1 -1
  52. package/dist/components/form/SignaturePad/SignaturePad.cjs +1 -1
  53. package/dist/components/form/SignaturePad/SignaturePad.d.ts +5 -1
  54. package/dist/components/form/SignaturePad/SignaturePad.js +47 -47
  55. package/dist/components/form/TreeSelect/TreeSelect.cjs +1 -1
  56. package/dist/components/form/TreeSelect/TreeSelect.js +115 -112
  57. package/dist/components/form/TreeSelect/tree-select.module.cjs +1 -1
  58. package/dist/components/form/TreeSelect/tree-select.module.js +6 -6
  59. package/dist/components/navigation/CommandPalette/CommandPalette.cjs +1 -1
  60. package/dist/components/navigation/CommandPalette/CommandPalette.d.ts +5 -1
  61. package/dist/components/navigation/CommandPalette/CommandPalette.js +11 -6
  62. package/dist/components/navigation/Pagination/Pagination.cjs +1 -1
  63. package/dist/components/navigation/Pagination/Pagination.d.ts +5 -1
  64. package/dist/components/navigation/Pagination/Pagination.js +65 -63
  65. package/dist/components/overlay/Menu/Menu.cjs +1 -1
  66. package/dist/components/overlay/Menu/Menu.d.ts +4 -0
  67. package/dist/components/overlay/Menu/Menu.js +23 -21
  68. package/dist/llms-full.txt +19 -1
  69. package/dist/llms.txt +1 -1
  70. package/dist/styles.css +1 -1
  71. package/dist/wimui.umd.css +1 -1
  72. package/dist/wimui.umd.js +5 -5
  73. package/package.json +4 -4
@@ -1,26 +1,28 @@
1
1
  "use client";
2
- import { Transition as e } from "../../layout/Transition/Transition.js";
3
- import t from "../../../icon/chevron-right.js";
4
- import { Icon as n } from "../../media/Icon/Icon.js";
5
- import { BaseListItem as r } from "../../_internal/BaseListItem/BaseListItem.js";
6
- import { InputBase as i } from "../InputBase/InputBase.js";
7
- import a from "./cascader.module.js";
8
- import { FieldTemplate as o } from "../FieldTemplate/FieldTemplate.js";
9
- import s, { useEffect as c, useId as l, useRef as u, useState as d } from "react";
10
- import f from "classnames";
11
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
2
+ import { useMergedRef as e } from "../../../hooks/useMergedRef.js";
3
+ import { Transition as t } from "../../layout/Transition/Transition.js";
4
+ import n from "../../../icon/chevron-right.js";
5
+ import { Icon as r } from "../../media/Icon/Icon.js";
6
+ import { BaseListItem as i } from "../../_internal/BaseListItem/BaseListItem.js";
7
+ import { InputBase as a } from "../InputBase/InputBase.js";
8
+ import { useInlineFloating as o } from "../../_internal/useInlineFloating.js";
9
+ import s from "./cascader.module.js";
10
+ import { FieldTemplate as c } from "../FieldTemplate/FieldTemplate.js";
11
+ import l, { useEffect as u, useId as ee, useRef as d, useState as f } from "react";
12
+ import p from "classnames";
13
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
12
14
  //#region src/components/form/Cascader/Cascader.tsx
13
- function h(e) {
15
+ function g(e) {
14
16
  return typeof e == "string" ? e : typeof e == "number" ? String(e) : "";
15
17
  }
16
- var g = ({ options: g = [], value: _, onChange: v, placeholder: y, label: b, error: x, required: S, layout: ee, className: te, disabled: C = !1, defaultValue: w, id: ne, expandTrigger: T = "click", separator: E = " / ", allowClear: re = !1, "aria-label": D, "aria-labelledby": ie, "aria-describedby": ae, width: oe, fullWidth: se = !1, ...O }) => {
17
- let ce = l(), k = ne || `wim-cascader-${ce}`, A = b ? `${k}-label` : void 0, j = x ? `${k}-error` : void 0, M = A ?? ie, le = `${k}-trigger`, N = `${k}-popup`, [P, F] = d(!1), [ue, I] = d(w || []), [L, R] = d([]), [z, B] = d(-1), [V, H] = d([]), [de, U] = d(!1), W = u(null), G = u(null), K = _ !== void 0, q = K ? _ : ue;
18
- c(() => {
18
+ var _ = ({ options: _ = [], value: v, onChange: y, placeholder: b, label: x, error: S, required: C, layout: te, className: ne, disabled: w = !1, defaultValue: T, id: re, expandTrigger: ie = "click", separator: E = " / ", allowClear: ae = !1, "aria-label": D, "aria-labelledby": oe, "aria-describedby": O, width: se, fullWidth: ce = !1, ...le }) => {
19
+ let ue = ee(), k = re || `wim-cascader-${ue}`, A = x ? `${k}-label` : void 0, j = S ? `${k}-error` : void 0, M = A ?? oe, de = `${k}-trigger`, N = `${k}-popup`, [P, F] = f(!1), [fe, I] = f(T || []), [L, R] = f([]), [z, B] = f(-1), [V, H] = f([]), [pe, U] = f(!1), W = d(null), G = d(null), K = v !== void 0, q = K ? v : fe;
20
+ u(() => {
19
21
  let e = (e) => {
20
22
  W.current && !W.current.contains(e.target) && F(!1);
21
23
  };
22
24
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
23
- }, []), c(() => {
25
+ }, []), u(() => {
24
26
  if (P && z >= 0) {
25
27
  let e = V[z], t = `${k}-menu-${z}-option-${e}`, n = W.current?.querySelector(`#${t}`);
26
28
  n && n.scrollIntoView({
@@ -35,44 +37,44 @@ var g = ({ options: g = [], value: _, onChange: v, placeholder: y, label: b, err
35
37
  k
36
38
  ]);
37
39
  let J = () => {
38
- if (!C) {
40
+ if (!w) {
39
41
  let e = !P;
40
42
  F(e), e ? (R(q || []), B(0), H([0])) : B(-1);
41
43
  }
42
- }, fe = () => {
44
+ }, me = () => {
43
45
  if (!q || q.length === 0) return null;
44
- let e = [], t = g;
46
+ let e = [], t = _;
45
47
  for (let n of q) {
46
48
  let r = t.find((e) => e.value === n);
47
49
  if (r) e.push(r.label), t = r.children || [];
48
50
  else break;
49
51
  }
50
- return e.length === 0 ? null : e.map((t, n) => /* @__PURE__ */ m(s.Fragment, { children: [t, n < e.length - 1 && /* @__PURE__ */ p("span", { children: E })] }, n));
52
+ return e.length === 0 ? null : e.map((t, n) => /* @__PURE__ */ h(l.Fragment, { children: [t, n < e.length - 1 && /* @__PURE__ */ m("span", { children: E })] }, n));
51
53
  }, Y = (e, t) => {
52
54
  if (e.disabled) return;
53
55
  let n = [...L.slice(0, t), e.value];
54
56
  if (R(n), !e.children || e.children.length === 0) {
55
- if (K || I(n), v) {
56
- let e = [], t = g;
57
+ if (K || I(n), y) {
58
+ let e = [], t = _;
57
59
  for (let r of n) {
58
60
  let n = t.find((e) => e.value === r);
59
61
  n && (e.push(n), t = n.children || []);
60
62
  }
61
- v(n, e);
63
+ y(n, e);
62
64
  }
63
65
  F(!1), G.current?.focus();
64
66
  }
65
- }, pe = (e) => {
66
- e?.stopPropagation(), !C && (K || I([]), v && v([], []));
67
- }, me = (e, t) => {
68
- T === "hover" && !e.disabled && R([...L.slice(0, t), e.value]);
69
67
  }, he = (e) => {
70
- if (U(!0), C) return;
68
+ e?.stopPropagation(), !w && (K || I([]), y && y([], []));
69
+ }, ge = (e, t) => {
70
+ ie === "hover" && !e.disabled && R([...L.slice(0, t), e.value]);
71
+ }, _e = (e) => {
72
+ if (U(!0), w) return;
71
73
  if (!P) {
72
74
  (e.key === "Enter" || e.key === " " || e.key === "ArrowDown" || e.key === "ArrowDown" && e.altKey) && (e.preventDefault(), J());
73
75
  return;
74
76
  }
75
- let t = [g], n = g;
77
+ let t = [_], n = _;
76
78
  for (let e = 0; e < L.length; e++) {
77
79
  let r = L[e], i = n.find((e) => e.value === r);
78
80
  if (i && i.children && i.children.length > 0) t.push(i.children), n = i.children;
@@ -125,110 +127,112 @@ var g = ({ options: g = [], value: _, onChange: v, placeholder: y, label: b, err
125
127
  break;
126
128
  case "Tab": P && (F(!1), B(-1));
127
129
  }
128
- }, X = [g], Z = g;
130
+ }, X = [_], Z = _;
129
131
  for (let e = 0; e < L.length; e++) {
130
132
  let t = L[e], n = Z.find((e) => e.value === t);
131
133
  if (n && n.children && n.children.length > 0) X.push(n.children), Z = n.children;
132
134
  else break;
133
135
  }
134
- let Q = fe(), $ = () => {
136
+ let Q = me(), $ = () => {
135
137
  if (!q || q.length === 0) return "";
136
- let e = [], t = g;
138
+ let e = [], t = _;
137
139
  for (let n of q) {
138
140
  let r = t.find((e) => e.value === n);
139
- if (r) e.push(h(r.label)), t = r.children || [];
141
+ if (r) e.push(g(r.label)), t = r.children || [];
140
142
  else break;
141
143
  }
142
144
  return e.join(E);
143
- };
144
- return /* @__PURE__ */ p(o, {
145
- label: b,
146
- error: x,
147
- required: S,
148
- layout: ee,
145
+ }, { setReference: ve, setFloating: ye, floatingProps: be } = o({ open: P && !w }), xe = e(W, ve);
146
+ return /* @__PURE__ */ m(c, {
147
+ label: x,
148
+ error: S,
149
+ required: C,
150
+ layout: te,
149
151
  labelId: A,
150
152
  errorId: j,
151
- className: f("wim-cascader", te),
152
- children: /* @__PURE__ */ m("div", {
153
- className: a.root,
154
- ref: W,
153
+ className: p("wim-cascader", ne),
154
+ children: /* @__PURE__ */ h("div", {
155
+ className: s.root,
156
+ ref: xe,
155
157
  onMouseMove: () => U(!1),
156
- "data-keyboard-nav": de,
157
- ...O,
158
- children: [/* @__PURE__ */ p(i, {
159
- disabled: C,
160
- allowClear: re,
158
+ "data-keyboard-nav": pe,
159
+ ...le,
160
+ children: [/* @__PURE__ */ m(a, {
161
+ disabled: w,
162
+ allowClear: ae,
161
163
  hasValue: !!Q,
162
- onClear: pe,
163
- intent: x ? "danger" : "default",
164
- width: oe,
165
- fullWidth: se,
164
+ onClear: he,
165
+ intent: S ? "danger" : "default",
166
+ width: se,
167
+ fullWidth: ce,
166
168
  rightIcons: [{
167
169
  name: "ChevronDownIcon",
168
170
  rotated: P
169
171
  }],
170
- className: f(P && a.open),
171
- children: /* @__PURE__ */ p("div", {
172
- id: le,
172
+ className: p(P && s.open),
173
+ children: /* @__PURE__ */ m("div", {
174
+ id: de,
173
175
  ref: G,
174
- className: f(a.trigger, C && a.disabled),
176
+ className: p(s.trigger, w && s.disabled),
175
177
  onClick: J,
176
- onKeyDown: he,
177
- tabIndex: C ? -1 : 0,
178
+ onKeyDown: _e,
179
+ tabIndex: w ? -1 : 0,
178
180
  role: "combobox",
179
181
  "aria-expanded": P,
180
182
  "aria-controls": P ? N : void 0,
181
183
  "aria-haspopup": "listbox",
182
- "aria-disabled": C,
184
+ "aria-disabled": w,
183
185
  "aria-labelledby": M,
184
- "aria-label": M ? void 0 : D || $() || h(y),
185
- "aria-describedby": [ae, j].filter(Boolean).join(" ") || void 0,
186
- "aria-required": S,
187
- "aria-invalid": !!x,
186
+ "aria-label": M ? void 0 : D || $() || g(b),
187
+ "aria-describedby": [O, j].filter(Boolean).join(" ") || void 0,
188
+ "aria-required": C,
189
+ "aria-invalid": !!S,
188
190
  "aria-activedescendant": P && z >= 0 ? `${k}-menu-${z}-option-${V[z]}` : void 0,
189
- children: /* @__PURE__ */ p("div", {
190
- className: f(a.value, !Q && a.placeholder),
191
- children: Q || y
191
+ children: /* @__PURE__ */ m("div", {
192
+ className: p(s.value, !Q && s.placeholder),
193
+ children: Q || b
192
194
  })
193
195
  })
194
- }), /* @__PURE__ */ p(e, {
195
- show: P && !C,
196
+ }), /* @__PURE__ */ m(t, {
197
+ show: P && !w,
196
198
  preset: "fade",
197
199
  id: N,
198
- className: a.dropdown,
199
- children: X.map((e, i) => /* @__PURE__ */ p("div", {
200
- className: a.menu,
200
+ className: s.dropdown,
201
+ ref: ye,
202
+ ...be,
203
+ children: X.map((e, t) => /* @__PURE__ */ m("div", {
204
+ className: s.menu,
201
205
  role: "listbox",
202
206
  "aria-labelledby": M,
203
- "aria-label": M ? void 0 : D || $() || h(y),
204
- children: e.map((e, o) => {
205
- let s = L[i] === e.value, c = z === i && V[i] === o, l = q[i] === e.value, u = e.children && e.children.length > 0;
206
- return /* @__PURE__ */ p(r, {
207
- className: f(a.menuItem, l && a.selected),
208
- active: c || s,
207
+ "aria-label": M ? void 0 : D || $() || g(b),
208
+ children: e.map((e, a) => {
209
+ let o = L[t] === e.value, c = z === t && V[t] === a, l = q[t] === e.value, u = e.children && e.children.length > 0;
210
+ return /* @__PURE__ */ m(i, {
211
+ className: p(s.menuItem, l && s.selected),
212
+ active: c || o,
209
213
  disabled: e.disabled,
210
- onClick: (t) => {
211
- t.stopPropagation(), Y(e, i);
214
+ onClick: (n) => {
215
+ n.stopPropagation(), Y(e, t);
212
216
  },
213
217
  onMouseEnter: () => {
214
- me(e, i), B(i), H((e) => [...e.slice(0, i), o]);
218
+ ge(e, t), B(t), H((e) => [...e.slice(0, t), a]);
215
219
  },
216
- rightSection: u ? /* @__PURE__ */ p(n, {
217
- component: t,
220
+ rightSection: u ? /* @__PURE__ */ m(r, {
221
+ component: n,
218
222
  size: "sm"
219
223
  }) : void 0,
220
224
  role: "option",
221
- id: `${k}-menu-${i}-option-${o}`,
225
+ id: `${k}-menu-${t}-option-${a}`,
222
226
  "aria-selected": l,
223
227
  tabIndex: -1,
224
228
  children: e.label
225
229
  }, e.value);
226
230
  })
227
- }, i))
231
+ }, t))
228
232
  })]
229
233
  })
230
234
  });
231
235
  };
232
- g.displayName = "Cascader";
236
+ _.displayName = "Cascader";
233
237
  //#endregion
234
- export { g as Cascader };
238
+ export { _ as Cascader };
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- var e=`_root_58ik4_323`,t=`_label_58ik4_328`,n=`_trigger_58ik4_335`,r=`_disabled_58ik4_348`,i=`_open_58ik4_354`,a=`_value_58ik4_362`,o=`_placeholder_58ik4_363`,s=`_icon_58ik4_366`,c=`_clear_58ik4_386`,l=`_dropdown_58ik4_398`,u=`_menu_58ik4_417`,d=`_menuItem_58ik4_446`,f=`_active_58ik4_446`,p=`_selected_58ik4_454`,m={"wim-docs-container":`_wim-docs-container_58ik4_87`,"wim-t":`_wim-t_58ik4_290`,"react-flow":`_react-flow_58ik4_313`,"react-flow__edges":`_react-flow__edges_58ik4_314`,"react-flow__connectionline":`_react-flow__connectionline_58ik4_315`,root:e,label:t,trigger:n,disabled:r,open:i,value:a,placeholder:o,icon:s,clear:c,dropdown:l,menu:u,menuItem:d,active:f,selected:p};exports.active=f,exports.clear=c,exports.default=m,exports.disabled=r,exports.dropdown=l,exports.icon=s,exports.label=t,exports.menu=u,exports.menuItem=d,exports.open=i,exports.placeholder=o,exports.root=e,exports.selected=p,exports.trigger=n,exports.value=a;
2
+ var e=`_root_10y2r_323`,t=`_label_10y2r_328`,n=`_trigger_10y2r_335`,r=`_disabled_10y2r_348`,i=`_open_10y2r_354`,a=`_value_10y2r_362`,o=`_placeholder_10y2r_363`,s=`_icon_10y2r_366`,c=`_clear_10y2r_386`,l=`_dropdown_10y2r_398`,u=`_menu_10y2r_428`,d=`_menuItem_10y2r_457`,f=`_active_10y2r_457`,p=`_selected_10y2r_465`,m={"wim-docs-container":`_wim-docs-container_10y2r_87`,"wim-t":`_wim-t_10y2r_290`,"react-flow":`_react-flow_10y2r_313`,"react-flow__edges":`_react-flow__edges_10y2r_314`,"react-flow__connectionline":`_react-flow__connectionline_10y2r_315`,root:e,label:t,trigger:n,disabled:r,open:i,value:a,placeholder:o,icon:s,clear:c,dropdown:l,menu:u,menuItem:d,active:f,selected:p};exports.active=f,exports.clear=c,exports.default=m,exports.disabled=r,exports.dropdown=l,exports.icon=s,exports.label=t,exports.menu=u,exports.menuItem=d,exports.open=i,exports.placeholder=o,exports.root=e,exports.selected=p,exports.trigger=n,exports.value=a;
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  //#region src/components/form/Cascader/cascader.module.scss
3
- var e = "_root_58ik4_323", t = "_label_58ik4_328", n = "_trigger_58ik4_335", r = "_disabled_58ik4_348", i = "_open_58ik4_354", a = "_value_58ik4_362", o = "_placeholder_58ik4_363", s = "_icon_58ik4_366", c = "_clear_58ik4_386", l = "_dropdown_58ik4_398", u = "_menu_58ik4_417", d = "_menuItem_58ik4_446", f = "_active_58ik4_446", p = "_selected_58ik4_454", m = {
4
- "wim-docs-container": "_wim-docs-container_58ik4_87",
5
- "wim-t": "_wim-t_58ik4_290",
6
- "react-flow": "_react-flow_58ik4_313",
7
- "react-flow__edges": "_react-flow__edges_58ik4_314",
8
- "react-flow__connectionline": "_react-flow__connectionline_58ik4_315",
3
+ var e = "_root_10y2r_323", t = "_label_10y2r_328", n = "_trigger_10y2r_335", r = "_disabled_10y2r_348", i = "_open_10y2r_354", a = "_value_10y2r_362", o = "_placeholder_10y2r_363", s = "_icon_10y2r_366", c = "_clear_10y2r_386", l = "_dropdown_10y2r_398", u = "_menu_10y2r_428", d = "_menuItem_10y2r_457", f = "_active_10y2r_457", p = "_selected_10y2r_465", m = {
4
+ "wim-docs-container": "_wim-docs-container_10y2r_87",
5
+ "wim-t": "_wim-t_10y2r_290",
6
+ "react-flow": "_react-flow_10y2r_313",
7
+ "react-flow__edges": "_react-flow__edges_10y2r_314",
8
+ "react-flow__connectionline": "_react-flow__connectionline_10y2r_315",
9
9
  root: e,
10
10
  label: t,
11
11
  trigger: n,
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../_internal/BaseListItem/BaseListItem.cjs"),n=require("../InputBase/InputBase.cjs"),r=require("../FieldTemplate/FieldTemplate.cjs"),i=require("./combobox.module.cjs");let a=require("react");a=e.__toESM(a,1);let o=require("classnames");o=e.__toESM(o,1);let s=require("react/jsx-runtime");var c=({options:e=[],onChange:c,placeholder:l,showSearchIcon:u=!0,allowClear:d=!0,defaultValue:f=``,className:p,disabled:m=!1,label:h,error:g,required:_,layout:v,fullWidth:y=!1,id:b,labels:x={},...S})=>{let{noResults:C=`No results found`}=x,[w,T]=(0,a.useState)(!1),[E,D]=(0,a.useState)(f),[O,k]=(0,a.useState)(-1),[A,j]=(0,a.useState)(!1),M=(0,a.useRef)(null),N=(0,a.useId)(),P=b||`wim-combobox-${N}`,F=`${P}-list`,I=h?`${P}-label`:void 0,L=g?`${P}-error`:void 0,R=(0,a.useMemo)(()=>{let t=(E||``).toLowerCase();return e.filter(e=>e.label.toLowerCase().includes(t))},[e,E]);(0,a.useEffect)(()=>{let e=e=>{M.current&&!M.current.contains(e.target)&&T(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let z=e=>{let t=e.target.value;D(t),T(!0),k(-1)},B=e=>{D(e.label),T(!1),c&&c(e)};return(0,s.jsx)(r.FieldTemplate,{label:h,error:g,required:_,layout:v,labelId:I,htmlFor:P,errorId:L,className:p,children:(0,s.jsxs)(`div`,{className:(0,o.default)(`wim-combobox`,i.default.root,y&&i.default.fullWidth),ref:M,onMouseMove:()=>j(!1),"data-keyboard-nav":A,children:[(0,s.jsx)(n.InputBase,{disabled:m,allowClear:d,hasValue:!!E,onClear:()=>D(``),intent:g?`danger`:`default`,leftIcon:u?`SearchIcon`:void 0,fullWidth:y,rightIcons:[{name:`ChevronDownIcon`,rotated:w,onClick:()=>T(!w),decorative:!0}],children:(0,s.jsx)(`input`,{id:P,className:i.default.input,placeholder:l,value:E,onChange:z,onKeyDown:e=>{if(j(!0),!w&&e.key===`ArrowDown`){T(!0);return}switch(e.key){case`ArrowDown`:k(e=>e<R.length-1?e+1:0);break;case`ArrowUp`:k(e=>e<=0?R.length-1:e-1);break;case`Enter`:O>=0&&O<R.length&&B(R[O]);break;case`Escape`:T(!1);break;case`Tab`:T(!1)}},onFocus:()=>T(!0),disabled:m,autoComplete:`off`,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":w,"aria-controls":w?F:void 0,"aria-labelledby":I,"aria-describedby":L,required:_,"aria-invalid":!!g,"aria-activedescendant":w&&O>=0?`${F}-option-${O}`:void 0,...S})}),w&&R.length>0&&(0,s.jsx)(`div`,{className:i.default.dropdown,children:(0,s.jsx)(`ul`,{id:F,className:i.default.list,role:`listbox`,"aria-labelledby":I,children:R.map((e,n)=>(0,s.jsx)(t.BaseListItem,{asChild:!0,id:`${F}-option-${n}`,className:(0,o.default)(i.default.option,n===O&&i.default.selected),active:n===O,onClick:()=>B(e),onMouseEnter:()=>k(n),role:`option`,"aria-selected":n===O,children:(0,s.jsx)(`li`,{children:e.label})},e.value))})}),w&&R.length===0&&(0,s.jsx)(`div`,{className:i.default.dropdown,children:(0,s.jsx)(`div`,{className:i.default.empty,role:`region`,"aria-live":`polite`,children:C})})]})})};c.displayName=`Combobox`,exports.Combobox=c;
2
+ const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../hooks/useMergedRef.cjs"),n=require("../../_internal/BaseListItem/BaseListItem.cjs"),r=require("../InputBase/InputBase.cjs"),i=require("../../_internal/useInlineFloating.cjs"),a=require("../FieldTemplate/FieldTemplate.cjs"),o=require("./combobox.module.cjs");let s=require("react");s=e.__toESM(s,1);let c=require("classnames");c=e.__toESM(c,1);let l=require("react/jsx-runtime");var u=({options:e=[],onChange:u,placeholder:d,showSearchIcon:f=!0,allowClear:p=!0,defaultValue:m=``,className:h,disabled:g=!1,label:_,error:v,required:y,layout:b,fullWidth:x=!1,id:S,labels:C={},...w})=>{let{noResults:T=`No results found`}=C,[E,D]=(0,s.useState)(!1),[O,k]=(0,s.useState)(m),[A,j]=(0,s.useState)(-1),[M,N]=(0,s.useState)(!1),P=(0,s.useRef)(null),F=(0,s.useId)(),I=S||`wim-combobox-${F}`,L=`${I}-list`,R=_?`${I}-label`:void 0,z=v?`${I}-error`:void 0,B=(0,s.useMemo)(()=>{let t=(O||``).toLowerCase();return e.filter(e=>e.label.toLowerCase().includes(t))},[e,O]);(0,s.useEffect)(()=>{let e=e=>{P.current&&!P.current.contains(e.target)&&D(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let V=e=>{let t=e.target.value;k(t),D(!0),j(-1)},H=e=>{k(e.label),D(!1),u&&u(e)},U=e=>{if(N(!0),!E&&e.key===`ArrowDown`){D(!0);return}switch(e.key){case`ArrowDown`:j(e=>e<B.length-1?e+1:0);break;case`ArrowUp`:j(e=>e<=0?B.length-1:e-1);break;case`Enter`:A>=0&&A<B.length&&H(B[A]);break;case`Escape`:D(!1);break;case`Tab`:D(!1)}},{setReference:W,setFloating:G,floatingProps:K}=i.useInlineFloating({open:E}),q=t.useMergedRef(P,W);return(0,l.jsx)(a.FieldTemplate,{label:_,error:v,required:y,layout:b,labelId:R,htmlFor:I,errorId:z,className:h,children:(0,l.jsxs)(`div`,{className:(0,c.default)(`wim-combobox`,o.default.root,x&&o.default.fullWidth),ref:q,onMouseMove:()=>N(!1),"data-keyboard-nav":M,children:[(0,l.jsx)(r.InputBase,{disabled:g,allowClear:p,hasValue:!!O,onClear:()=>k(``),intent:v?`danger`:`default`,leftIcon:f?`SearchIcon`:void 0,fullWidth:x,rightIcons:[{name:`ChevronDownIcon`,rotated:E,onClick:()=>D(!E),decorative:!0}],children:(0,l.jsx)(`input`,{id:I,className:o.default.input,placeholder:d,value:O,onChange:V,onKeyDown:U,onFocus:()=>D(!0),disabled:g,autoComplete:`off`,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":E,"aria-controls":E?L:void 0,"aria-labelledby":R,"aria-describedby":z,required:y,"aria-invalid":!!v,"aria-activedescendant":E&&A>=0?`${L}-option-${A}`:void 0,...w})}),E&&B.length>0&&(0,l.jsx)(`div`,{className:o.default.dropdown,ref:G,...K,children:(0,l.jsx)(`ul`,{id:L,className:o.default.list,role:`listbox`,"aria-labelledby":R,children:B.map((e,t)=>(0,l.jsx)(n.BaseListItem,{asChild:!0,id:`${L}-option-${t}`,className:(0,c.default)(o.default.option,t===A&&o.default.selected),active:t===A,onClick:()=>H(e),onMouseEnter:()=>j(t),role:`option`,"aria-selected":t===A,children:(0,l.jsx)(`li`,{children:e.label})},e.value))})}),E&&B.length===0&&(0,l.jsx)(`div`,{className:o.default.dropdown,ref:G,...K,children:(0,l.jsx)(`div`,{className:o.default.empty,role:`region`,"aria-live":`polite`,children:T})})]})})};u.displayName=`Combobox`,exports.Combobox=u;
@@ -1,133 +1,139 @@
1
1
  "use client";
2
- import { BaseListItem as e } from "../../_internal/BaseListItem/BaseListItem.js";
3
- import { InputBase as t } from "../InputBase/InputBase.js";
4
- import { FieldTemplate as n } from "../FieldTemplate/FieldTemplate.js";
5
- import r from "./combobox.module.js";
6
- import { useEffect as i, useId as a, useMemo as o, useRef as s, useState as c } from "react";
7
- import l from "classnames";
8
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
2
+ import { useMergedRef as e } from "../../../hooks/useMergedRef.js";
3
+ import { BaseListItem as t } from "../../_internal/BaseListItem/BaseListItem.js";
4
+ import { InputBase as n } from "../InputBase/InputBase.js";
5
+ import { useInlineFloating as r } from "../../_internal/useInlineFloating.js";
6
+ import { FieldTemplate as i } from "../FieldTemplate/FieldTemplate.js";
7
+ import a from "./combobox.module.js";
8
+ import { useEffect as o, useId as s, useMemo as c, useRef as l, useState as u } from "react";
9
+ import d from "classnames";
10
+ import { jsx as f, jsxs as p } from "react/jsx-runtime";
9
11
  //#region src/components/form/Combobox/Combobox.tsx
10
- var f = ({ options: f = [], onChange: p, placeholder: m, showSearchIcon: h = !0, allowClear: g = !0, defaultValue: _ = "", className: v, disabled: y = !1, label: b, error: x, required: S, layout: C, fullWidth: w = !1, id: T, labels: E = {}, ...D }) => {
11
- let { noResults: O = "No results found" } = E, [k, A] = c(!1), [j, M] = c(_), [N, P] = c(-1), [F, I] = c(!1), L = s(null), R = a(), z = T || `wim-combobox-${R}`, B = `${z}-list`, V = b ? `${z}-label` : void 0, H = x ? `${z}-error` : void 0, U = o(() => {
12
- let e = (j || "").toLowerCase();
13
- return f.filter((t) => t.label.toLowerCase().includes(e));
14
- }, [f, j]);
15
- i(() => {
12
+ var m = ({ options: m = [], onChange: h, placeholder: g, showSearchIcon: _ = !0, allowClear: v = !0, defaultValue: y = "", className: b, disabled: x = !1, label: S, error: C, required: w, layout: T, fullWidth: E = !1, id: D, labels: O = {}, ...k }) => {
13
+ let { noResults: A = "No results found" } = O, [j, M] = u(!1), [N, P] = u(y), [F, I] = u(-1), [L, R] = u(!1), z = l(null), B = s(), V = D || `wim-combobox-${B}`, H = `${V}-list`, U = S ? `${V}-label` : void 0, W = C ? `${V}-error` : void 0, G = c(() => {
14
+ let e = (N || "").toLowerCase();
15
+ return m.filter((t) => t.label.toLowerCase().includes(e));
16
+ }, [m, N]);
17
+ o(() => {
16
18
  let e = (e) => {
17
- L.current && !L.current.contains(e.target) && A(!1);
19
+ z.current && !z.current.contains(e.target) && M(!1);
18
20
  };
19
21
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
20
22
  }, []);
21
- let W = (e) => {
23
+ let K = (e) => {
22
24
  let t = e.target.value;
23
- M(t), A(!0), P(-1);
24
- }, G = (e) => {
25
- M(e.label), A(!1), p && p(e);
26
- };
27
- return /* @__PURE__ */ u(n, {
28
- label: b,
29
- error: x,
30
- required: S,
31
- layout: C,
32
- labelId: V,
33
- htmlFor: z,
34
- errorId: H,
35
- className: v,
36
- children: /* @__PURE__ */ d("div", {
37
- className: l("wim-combobox", r.root, w && r.fullWidth),
38
- ref: L,
39
- onMouseMove: () => I(!1),
40
- "data-keyboard-nav": F,
25
+ P(t), M(!0), I(-1);
26
+ }, q = (e) => {
27
+ P(e.label), M(!1), h && h(e);
28
+ }, J = (e) => {
29
+ if (R(!0), !j && e.key === "ArrowDown") {
30
+ M(!0);
31
+ return;
32
+ }
33
+ switch (e.key) {
34
+ case "ArrowDown":
35
+ I((e) => e < G.length - 1 ? e + 1 : 0);
36
+ break;
37
+ case "ArrowUp":
38
+ I((e) => e <= 0 ? G.length - 1 : e - 1);
39
+ break;
40
+ case "Enter":
41
+ F >= 0 && F < G.length && q(G[F]);
42
+ break;
43
+ case "Escape":
44
+ M(!1);
45
+ break;
46
+ case "Tab": M(!1);
47
+ }
48
+ }, { setReference: Y, setFloating: X, floatingProps: Z } = r({ open: j }), Q = e(z, Y);
49
+ return /* @__PURE__ */ f(i, {
50
+ label: S,
51
+ error: C,
52
+ required: w,
53
+ layout: T,
54
+ labelId: U,
55
+ htmlFor: V,
56
+ errorId: W,
57
+ className: b,
58
+ children: /* @__PURE__ */ p("div", {
59
+ className: d("wim-combobox", a.root, E && a.fullWidth),
60
+ ref: Q,
61
+ onMouseMove: () => R(!1),
62
+ "data-keyboard-nav": L,
41
63
  children: [
42
- /* @__PURE__ */ u(t, {
43
- disabled: y,
44
- allowClear: g,
45
- hasValue: !!j,
46
- onClear: () => M(""),
47
- intent: x ? "danger" : "default",
48
- leftIcon: h ? "SearchIcon" : void 0,
49
- fullWidth: w,
64
+ /* @__PURE__ */ f(n, {
65
+ disabled: x,
66
+ allowClear: v,
67
+ hasValue: !!N,
68
+ onClear: () => P(""),
69
+ intent: C ? "danger" : "default",
70
+ leftIcon: _ ? "SearchIcon" : void 0,
71
+ fullWidth: E,
50
72
  rightIcons: [{
51
73
  name: "ChevronDownIcon",
52
- rotated: k,
53
- onClick: () => A(!k),
74
+ rotated: j,
75
+ onClick: () => M(!j),
54
76
  decorative: !0
55
77
  }],
56
- children: /* @__PURE__ */ u("input", {
57
- id: z,
58
- className: r.input,
59
- placeholder: m,
60
- value: j,
61
- onChange: W,
62
- onKeyDown: (e) => {
63
- if (I(!0), !k && e.key === "ArrowDown") {
64
- A(!0);
65
- return;
66
- }
67
- switch (e.key) {
68
- case "ArrowDown":
69
- P((e) => e < U.length - 1 ? e + 1 : 0);
70
- break;
71
- case "ArrowUp":
72
- P((e) => e <= 0 ? U.length - 1 : e - 1);
73
- break;
74
- case "Enter":
75
- N >= 0 && N < U.length && G(U[N]);
76
- break;
77
- case "Escape":
78
- A(!1);
79
- break;
80
- case "Tab": A(!1);
81
- }
82
- },
83
- onFocus: () => A(!0),
84
- disabled: y,
78
+ children: /* @__PURE__ */ f("input", {
79
+ id: V,
80
+ className: a.input,
81
+ placeholder: g,
82
+ value: N,
83
+ onChange: K,
84
+ onKeyDown: J,
85
+ onFocus: () => M(!0),
86
+ disabled: x,
85
87
  autoComplete: "off",
86
88
  role: "combobox",
87
89
  "aria-autocomplete": "list",
88
- "aria-expanded": k,
89
- "aria-controls": k ? B : void 0,
90
- "aria-labelledby": V,
91
- "aria-describedby": H,
92
- required: S,
93
- "aria-invalid": !!x,
94
- "aria-activedescendant": k && N >= 0 ? `${B}-option-${N}` : void 0,
95
- ...D
90
+ "aria-expanded": j,
91
+ "aria-controls": j ? H : void 0,
92
+ "aria-labelledby": U,
93
+ "aria-describedby": W,
94
+ required: w,
95
+ "aria-invalid": !!C,
96
+ "aria-activedescendant": j && F >= 0 ? `${H}-option-${F}` : void 0,
97
+ ...k
96
98
  })
97
99
  }),
98
- k && U.length > 0 && /* @__PURE__ */ u("div", {
99
- className: r.dropdown,
100
- children: /* @__PURE__ */ u("ul", {
101
- id: B,
102
- className: r.list,
100
+ j && G.length > 0 && /* @__PURE__ */ f("div", {
101
+ className: a.dropdown,
102
+ ref: X,
103
+ ...Z,
104
+ children: /* @__PURE__ */ f("ul", {
105
+ id: H,
106
+ className: a.list,
103
107
  role: "listbox",
104
- "aria-labelledby": V,
105
- children: U.map((t, n) => /* @__PURE__ */ u(e, {
108
+ "aria-labelledby": U,
109
+ children: G.map((e, n) => /* @__PURE__ */ f(t, {
106
110
  asChild: !0,
107
- id: `${B}-option-${n}`,
108
- className: l(r.option, n === N && r.selected),
109
- active: n === N,
110
- onClick: () => G(t),
111
- onMouseEnter: () => P(n),
111
+ id: `${H}-option-${n}`,
112
+ className: d(a.option, n === F && a.selected),
113
+ active: n === F,
114
+ onClick: () => q(e),
115
+ onMouseEnter: () => I(n),
112
116
  role: "option",
113
- "aria-selected": n === N,
114
- children: /* @__PURE__ */ u("li", { children: t.label })
115
- }, t.value))
117
+ "aria-selected": n === F,
118
+ children: /* @__PURE__ */ f("li", { children: e.label })
119
+ }, e.value))
116
120
  })
117
121
  }),
118
- k && U.length === 0 && /* @__PURE__ */ u("div", {
119
- className: r.dropdown,
120
- children: /* @__PURE__ */ u("div", {
121
- className: r.empty,
122
+ j && G.length === 0 && /* @__PURE__ */ f("div", {
123
+ className: a.dropdown,
124
+ ref: X,
125
+ ...Z,
126
+ children: /* @__PURE__ */ f("div", {
127
+ className: a.empty,
122
128
  role: "region",
123
129
  "aria-live": "polite",
124
- children: O
130
+ children: A
125
131
  })
126
132
  })
127
133
  ]
128
134
  })
129
135
  });
130
136
  };
131
- f.displayName = "Combobox";
137
+ m.displayName = "Combobox";
132
138
  //#endregion
133
- export { f as Combobox };
139
+ export { m as Combobox };
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- var e=`_root_rh3xq_3`,t=`_fullWidth_rh3xq_8`,n=`_input_rh3xq_11`,r=`_dropdown_rh3xq_32`,i=`_list_rh3xq_37`,a=`_option_rh3xq_60`,o=`_selected_rh3xq_64`,s=`_empty_rh3xq_69`,c={root:e,fullWidth:t,input:n,dropdown:r,list:i,option:a,selected:o,empty:s};exports.default=c,exports.dropdown=r,exports.empty=s,exports.fullWidth=t,exports.input=n,exports.list=i,exports.option=a,exports.root=e,exports.selected=o;
2
+ var e=`_root_o8hc3_3`,t=`_fullWidth_o8hc3_8`,n=`_input_o8hc3_11`,r=`_dropdown_o8hc3_32`,i=`_list_o8hc3_37`,a=`_option_o8hc3_69`,o=`_selected_o8hc3_73`,s=`_empty_o8hc3_78`,c={root:e,fullWidth:t,input:n,dropdown:r,list:i,option:a,selected:o,empty:s};exports.default=c,exports.dropdown=r,exports.empty=s,exports.fullWidth=t,exports.input=n,exports.list=i,exports.option=a,exports.root=e,exports.selected=o;
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  //#region src/components/form/Combobox/combobox.module.scss
3
- var e = "_root_rh3xq_3", t = "_fullWidth_rh3xq_8", n = "_input_rh3xq_11", r = "_dropdown_rh3xq_32", i = "_list_rh3xq_37", a = "_option_rh3xq_60", o = "_selected_rh3xq_64", s = "_empty_rh3xq_69", c = {
3
+ var e = "_root_o8hc3_3", t = "_fullWidth_o8hc3_8", n = "_input_o8hc3_11", r = "_dropdown_o8hc3_32", i = "_list_o8hc3_37", a = "_option_o8hc3_69", o = "_selected_o8hc3_73", s = "_empty_o8hc3_78", c = {
4
4
  root: e,
5
5
  fullWidth: t,
6
6
  input: n,
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../i18n/useWimTranslation.cjs"),r=require("../../layout/Transition/Transition.cjs"),i=require("../../overlay/FocusTrap/FocusTrap.cjs"),a=require("../../../i18n/generated/components.cjs"),o=require("../InputBase/InputBase.cjs"),s=require("../FieldTemplate/FieldTemplate.cjs"),c=require("../Input/input.module.cjs"),l=require("../../data-display/Calendar/Calendar.cjs"),u=require("../../_internal/mergeRefs.cjs"),d=require("./date-picker.module.cjs");let f=require("react");f=e.__toESM(f,1);let p=require("classnames");p=e.__toESM(p,1);let m=require("react/jsx-runtime");var h=(0,f.forwardRef)(({intent:e=`default`,variant:h=`outline`,fullWidth:g=!1,className:_,disabled:v,value:y,defaultValue:b,onChange:x,format:ee=`YYYY-MM-DD`,clearable:S=!0,placeholder:C,minDate:te,maxDate:ne,disabledDates:re,label:w,error:T,required:E,layout:D,id:O,labels:k,width:A,asChild:j=!1,children:M,...N},P)=>{let[F,I]=(0,f.useState)(!1),[L,R]=(0,f.useState)(b||null),z=(0,f.useRef)(null),B=(0,f.useRef)(null),V=u.mergeRefs(z,P),{t:H}=n.useWimTranslation(a.componentsNs),U=(0,f.useId)(),W=O||`wim-datepicker-${U}`,G=`${W}-dropdown`,K=w?`${W}-label`:void 0,q=T?`${W}-error`:void 0,J=y!==void 0,Y=J?y:L,X=C??k?.placeholder,Z=v,Q=T?`danger`:e;(0,f.useEffect)(()=>{let e=e=>{z.current&&!z.current.contains(e.target)&&I(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,f.useEffect)(()=>{let e=e=>{e.key===`Escape`&&F&&(I(!1),B.current?.focus())};return F&&document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[F]);let ie=e=>{if(!e)return``;let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,`0`),r=String(e.getDate()).padStart(2,`0`);return ee.replace(`YYYY`,String(t)).replace(`MM`,n).replace(`DD`,r)},ae=e=>{J||R(e),x?.(e),I(!1),B.current?.focus()},oe=e=>{e?.stopPropagation(),Z||(J||R(null),x?.(null))},$=()=>{Z||I(!F)};return(0,f.useEffect)(()=>{if(F){let e=setTimeout(()=>{let e=z.current?.querySelector(`[data-calendar-day][tabindex="0"]:not(:disabled), [data-calendar-day][data-selected]:not(:disabled), [data-calendar-day]:focus`);e?e.focus():z.current?.querySelector(`[data-calendar-day]:not([data-other-month]):not(:disabled)`)?.focus()},50);return()=>clearTimeout(e)}},[F]),(0,m.jsx)(s.FieldTemplate,{label:w,error:T,required:E,layout:D,labelId:K,htmlFor:W,errorId:q,className:_,children:(0,m.jsxs)(j?t.Root:`div`,{ref:V,className:(0,p.default)(`wim-date-picker`,d.default.root,g&&d.default.fullWidth),children:[(0,m.jsx)(o.InputBase,{intent:Q,variant:h,width:A,fullWidth:g,disabled:Z,allowClear:S,hasValue:!!Y,onClear:oe,rightIcons:[{name:`ChevronDownIcon`,rotated:F,onClick:$,decorative:!0}],children:(0,m.jsx)(`input`,{id:W,ref:B,type:`text`,readOnly:!0,role:`combobox`,className:(0,p.default)(c.default.root,d.default.input),value:ie(Y),placeholder:X,disabled:Z,onClick:$,onKeyDown:e=>{Z||(e.key===`Escape`?(I(!1),B.current?.focus()):(e.key===`Enter`||e.key===` `||e.key===`ArrowDown`&&(e.altKey||!F))&&(e.preventDefault(),I(!F)))},"aria-haspopup":`dialog`,"aria-expanded":F,"aria-controls":F?G:void 0,"aria-invalid":Q===`danger`,"aria-describedby":q,"aria-labelledby":K,"aria-required":E,...N})}),(0,m.jsx)(r.Transition,{show:F&&!v,preset:`fade`,id:G,className:d.default.dropdown,children:(0,m.jsx)(i.FocusTrap,{active:F,initialFocus:!1,children:(0,m.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":K,"aria-label":K?void 0:N[`aria-label`]??H(`datepicker.dialog`),children:(0,m.jsx)(l.Calendar,{value:Y??void 0,onChange:ae})})})}),(0,m.jsx)(t.Slottable,{children:M})]})})});h.displayName=`DatePicker`,exports.DatePicker=h,exports.default=h;
2
+ const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../i18n/useWimTranslation.cjs"),r=require("../../../hooks/useMergedRef.cjs"),i=require("../../layout/Transition/Transition.cjs"),a=require("../../overlay/FocusTrap/FocusTrap.cjs"),o=require("../../../i18n/generated/components.cjs"),ee=require("../InputBase/InputBase.cjs"),s=require("../../_internal/useInlineFloating.cjs"),c=require("../FieldTemplate/FieldTemplate.cjs"),l=require("../Input/input.module.cjs"),u=require("../../data-display/Calendar/Calendar.cjs"),d=require("./date-picker.module.cjs");let f=require("react");f=e.__toESM(f,1);let p=require("classnames");p=e.__toESM(p,1);let m=require("react/jsx-runtime");var h=(0,f.forwardRef)(({intent:e=`default`,variant:h=`outline`,fullWidth:g=!1,className:_,disabled:v,value:y,defaultValue:b,onChange:x,format:te=`YYYY-MM-DD`,clearable:S=!0,placeholder:C,minDate:ne,maxDate:re,disabledDates:ie,label:w,error:T,required:E,layout:D,id:O,labels:k,width:A,asChild:j=!1,children:M,...N},P)=>{let[F,I]=(0,f.useState)(!1),[L,R]=(0,f.useState)(b||null),z=(0,f.useRef)(null),B=(0,f.useRef)(null),{t:V}=n.useWimTranslation(o.componentsNs),H=(0,f.useId)(),U=O||`wim-datepicker-${H}`,W=`${U}-dropdown`,G=w?`${U}-label`:void 0,K=T?`${U}-error`:void 0,q=y!==void 0,J=q?y:L,Y=C??k?.placeholder,X=v,Z=T?`danger`:e;(0,f.useEffect)(()=>{let e=e=>{z.current&&!z.current.contains(e.target)&&I(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,f.useEffect)(()=>{let e=e=>{e.key===`Escape`&&F&&(I(!1),B.current?.focus())};return F&&document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[F]);let Q=e=>{if(!e)return``;let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,`0`),r=String(e.getDate()).padStart(2,`0`);return te.replace(`YYYY`,String(t)).replace(`MM`,n).replace(`DD`,r)},ae=e=>{q||R(e),x?.(e),I(!1),B.current?.focus()},oe=e=>{e?.stopPropagation(),X||(q||R(null),x?.(null))},$=()=>{X||I(!F)},se=e=>{X||(e.key===`Escape`?(I(!1),B.current?.focus()):(e.key===`Enter`||e.key===` `||e.key===`ArrowDown`&&(e.altKey||!F))&&(e.preventDefault(),I(!F)))};(0,f.useEffect)(()=>{if(F){let e=setTimeout(()=>{let e=z.current?.querySelector(`[data-calendar-day][tabindex="0"]:not(:disabled), [data-calendar-day][data-selected]:not(:disabled), [data-calendar-day]:focus`);e?e.focus():z.current?.querySelector(`[data-calendar-day]:not([data-other-month]):not(:disabled)`)?.focus()},50);return()=>clearTimeout(e)}},[F]);let ce=j?t.Root:`div`,{setReference:le,setFloating:ue,floatingProps:de}=s.useInlineFloating({open:F&&!v}),fe=r.useMergedRef(z,P,le);return(0,m.jsx)(c.FieldTemplate,{label:w,error:T,required:E,layout:D,labelId:G,htmlFor:U,errorId:K,className:_,children:(0,m.jsxs)(ce,{ref:fe,className:(0,p.default)(`wim-date-picker`,d.default.root,g&&d.default.fullWidth),children:[(0,m.jsx)(ee.InputBase,{intent:Z,variant:h,width:A,fullWidth:g,disabled:X,allowClear:S,hasValue:!!J,onClear:oe,rightIcons:[{name:`ChevronDownIcon`,rotated:F,onClick:$,decorative:!0}],children:(0,m.jsx)(`input`,{id:U,ref:B,type:`text`,readOnly:!0,role:`combobox`,className:(0,p.default)(l.default.root,d.default.input),value:Q(J),placeholder:Y,disabled:X,onClick:$,onKeyDown:se,"aria-haspopup":`dialog`,"aria-expanded":F,"aria-controls":F?W:void 0,"aria-invalid":Z===`danger`,"aria-describedby":K,"aria-labelledby":G,"aria-required":E,...N})}),(0,m.jsx)(i.Transition,{show:F&&!v,preset:`fade`,id:W,className:d.default.dropdown,ref:ue,...de,children:(0,m.jsx)(a.FocusTrap,{active:F,initialFocus:!1,children:(0,m.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":G,"aria-label":G?void 0:N[`aria-label`]??V(`datepicker.dialog`),children:(0,m.jsx)(u.Calendar,{value:J??void 0,onChange:ae})})})}),(0,m.jsx)(t.Slottable,{children:M})]})})});h.displayName=`DatePicker`,exports.DatePicker=h,exports.default=h;