@mattermost/compass-ui 0.1.0-alpha.21 → 0.1.0-alpha.23

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 (79) hide show
  1. package/dist/components/combobox/Combobox.cjs +1 -1
  2. package/dist/components/combobox/Combobox.cjs.map +1 -1
  3. package/dist/components/combobox/Combobox.css +1 -1
  4. package/dist/components/combobox/Combobox.d.ts +43 -3
  5. package/dist/components/combobox/Combobox.d.ts.map +1 -1
  6. package/dist/components/combobox/Combobox.js +298 -283
  7. package/dist/components/combobox/Combobox.js.map +1 -1
  8. package/dist/components/combobox/Combobox.module.scss.cjs +1 -1
  9. package/dist/components/combobox/Combobox.module.scss.js +25 -25
  10. package/dist/components/combobox/index.d.ts +1 -1
  11. package/dist/components/combobox/index.d.ts.map +1 -1
  12. package/dist/components/dropdown/Dropdown.css +1 -1
  13. package/dist/components/dropdown/Dropdown.module.scss.cjs +1 -1
  14. package/dist/components/dropdown/Dropdown.module.scss.js +14 -14
  15. package/dist/components/global-banner/GlobalBanner.css +1 -1
  16. package/dist/components/global-banner/GlobalBanner.module.scss.cjs +1 -1
  17. package/dist/components/global-banner/GlobalBanner.module.scss.js +10 -10
  18. package/dist/components/modal/Modal.cjs +1 -1
  19. package/dist/components/modal/Modal.cjs.map +1 -1
  20. package/dist/components/modal/Modal.d.ts.map +1 -1
  21. package/dist/components/modal/Modal.js +91 -93
  22. package/dist/components/modal/Modal.js.map +1 -1
  23. package/dist/components/modal/ModalOverlay.cjs +2 -0
  24. package/dist/components/modal/ModalOverlay.cjs.map +1 -0
  25. package/dist/components/modal/ModalOverlay.css +1 -1
  26. package/dist/components/modal/ModalOverlay.d.ts +43 -0
  27. package/dist/components/modal/ModalOverlay.d.ts.map +1 -0
  28. package/dist/components/modal/ModalOverlay.js +59 -0
  29. package/dist/components/modal/ModalOverlay.js.map +1 -0
  30. package/dist/components/modal/ModalOverlay.module.scss.cjs +1 -1
  31. package/dist/components/modal/ModalOverlay.module.scss.js +3 -3
  32. package/dist/components/modal/index.cjs +1 -1
  33. package/dist/components/modal/index.d.ts +2 -0
  34. package/dist/components/modal/index.d.ts.map +1 -1
  35. package/dist/components/modal/index.js +4 -2
  36. package/dist/components/modal/index.js.map +1 -1
  37. package/dist/components/password-input/PasswordInput.css +1 -1
  38. package/dist/components/password-input/PasswordInput.module.scss.cjs +1 -1
  39. package/dist/components/password-input/PasswordInput.module.scss.js +12 -12
  40. package/dist/components/progress-bar/ProgressBar.cjs +1 -1
  41. package/dist/components/progress-bar/ProgressBar.cjs.map +1 -1
  42. package/dist/components/progress-bar/ProgressBar.d.ts +10 -2
  43. package/dist/components/progress-bar/ProgressBar.d.ts.map +1 -1
  44. package/dist/components/progress-bar/ProgressBar.js +31 -21
  45. package/dist/components/progress-bar/ProgressBar.js.map +1 -1
  46. package/dist/components/search-input/SearchInput.css +1 -1
  47. package/dist/components/search-input/SearchInput.module.scss.cjs +1 -1
  48. package/dist/components/search-input/SearchInput.module.scss.js +15 -15
  49. package/dist/components/text-area/TextArea.css +1 -1
  50. package/dist/components/text-area/TextArea.module.scss.cjs +1 -1
  51. package/dist/components/text-area/TextArea.module.scss.js +12 -12
  52. package/dist/components/text-input/TextInput.css +1 -1
  53. package/dist/components/text-input/TextInput.module.scss.cjs +1 -1
  54. package/dist/components/text-input/TextInput.module.scss.js +19 -19
  55. package/dist/components/thread-footer/ThreadFooter.css +1 -1
  56. package/dist/components/thread-footer/ThreadFooter.module.scss.cjs +1 -1
  57. package/dist/components/thread-footer/ThreadFooter.module.scss.js +18 -18
  58. package/dist/components/toast/Toast.css +1 -1
  59. package/dist/components/toast/Toast.module.scss.cjs +1 -1
  60. package/dist/components/toast/Toast.module.scss.js +10 -10
  61. package/dist/components/tour-point/TourPoint.css +1 -1
  62. package/dist/components/tour-point/TourPoint.module.scss.cjs +1 -1
  63. package/dist/components/tour-point/TourPoint.module.scss.js +28 -28
  64. package/dist/index.cjs +1 -1
  65. package/dist/index.js +97 -95
  66. package/dist/index.js.map +1 -1
  67. package/dist/utils/scrollLock.cjs +2 -0
  68. package/dist/utils/scrollLock.cjs.map +1 -0
  69. package/dist/utils/scrollLock.d.ts +9 -0
  70. package/dist/utils/scrollLock.d.ts.map +1 -0
  71. package/dist/utils/scrollLock.js +38 -0
  72. package/dist/utils/scrollLock.js.map +1 -0
  73. package/dist/utils/useOnExited.cjs +2 -0
  74. package/dist/utils/useOnExited.cjs.map +1 -0
  75. package/dist/utils/useOnExited.d.ts +7 -0
  76. package/dist/utils/useOnExited.d.ts.map +1 -0
  77. package/dist/utils/useOnExited.js +14 -0
  78. package/dist/utils/useOnExited.js.map +1 -0
  79. package/package.json +2 -1
@@ -1,294 +1,300 @@
1
- import { jsxs as M, jsx as l } from "react/jsx-runtime";
2
- import { forwardRef as vr, useId as hr, useRef as X, useCallback as d, useState as V, useMemo as R, useEffect as Me } from "react";
3
- import __xr from "@mattermost/compass-icons/components/chevron-down.js";const xr=__xr&&__xr.default?__xr.default:__xr;
4
- import ___r from "@mattermost/compass-icons/components/close-circle.js";const _r=___r&&___r.default?___r.default:___r;
5
- import __gr from "@mattermost/compass-icons/components/plus.js";const gr=__gr&&__gr.default?__gr.default:__gr;
6
- import yr from "../chip/Chip.js";
7
- import pr from "../chip/ChipGroup.js";
8
- import ae, { IconSlotContext as kr } from "../icon/Icon.js";
9
- import Ve from "../menu-item/MenuItem.js";
10
- import Ar, { PopoverMenuScroll as wr } from "../popover-menu/PopoverMenu.js";
11
- import Dr from "../spinner/Spinner.js";
12
- import Nr from "../team-avatar/TeamAvatar.js";
13
- import Mr from "../user-avatar/UserAvatar.js";
14
- import { useAnchoredPopupPortal as Vr } from "../../hooks/use-anchored-popup-portal.js";
15
- import { useOutsideClose as Rr } from "../../hooks/use-outside-close.js";
16
- import { usePopoverTransition as Er } from "../../hooks/use-popover-transition.js";
17
- import { mergeMenuItemProps as Sr } from "../../utils/menuItemProps.js";
18
- import { mergeClassNames as Ir } from "../../utils/props.js";
19
- import { toKebab as Tr } from "../../utils/string.js";
20
- import a from "./Combobox.module.scss.js";
21
- const Re = 280, Lr = {
1
+ import { jsxs as M, jsx as a } from "react/jsx-runtime";
2
+ import { forwardRef as Nr, useId as wr, useRef as X, useCallback as d, useState as I, useMemo as V, useEffect as Re } from "react";
3
+ import __Dr from "@mattermost/compass-icons/components/chevron-down.js";const Dr=__Dr&&__Dr.default?__Dr.default:__Dr;
4
+ import __Mr from "@mattermost/compass-icons/components/close-circle.js";const Mr=__Mr&&__Mr.default?__Mr.default:__Mr;
5
+ import __Ir from "@mattermost/compass-icons/components/plus.js";const Ir=__Ir&&__Ir.default?__Ir.default:__Ir;
6
+ import Vr from "../chip/Chip.js";
7
+ import Rr from "../chip/ChipGroup.js";
8
+ import ce, { IconSlotContext as Er } from "../icon/Icon.js";
9
+ import Ee from "../menu-item/MenuItem.js";
10
+ import Sr, { PopoverMenuScroll as Tr } from "../popover-menu/PopoverMenu.js";
11
+ import Lr from "../spinner/Spinner.js";
12
+ import zr from "../team-avatar/TeamAvatar.js";
13
+ import Cr from "../user-avatar/UserAvatar.js";
14
+ import { useAnchoredPopupPortal as Hr } from "../../hooks/use-anchored-popup-portal.js";
15
+ import { useOutsideClose as $r } from "../../hooks/use-outside-close.js";
16
+ import { usePopoverTransition as Fr } from "../../hooks/use-popover-transition.js";
17
+ import { mergeMenuItemProps as Or } from "../../utils/menuItemProps.js";
18
+ import { mergeClassNames as jr } from "../../utils/props.js";
19
+ import { toKebab as Ur } from "../../utils/string.js";
20
+ import l from "./Combobox.module.scss.js";
21
+ const Se = 280, qr = {
22
22
  small: "small",
23
23
  medium: "medium",
24
24
  large: "large"
25
- }, Fr = {
25
+ }, Gr = {
26
26
  small: "12",
27
27
  medium: "16",
28
28
  large: "16"
29
29
  };
30
- function zr(n) {
31
- return typeof n == "string" ? `${n} selections` : "Selected";
30
+ function Qr(t) {
31
+ return typeof t == "string" ? `${t} selections` : "Selected";
32
32
  }
33
- function Cr(n) {
34
- return `Create "${n}"`;
33
+ function Xr(t) {
34
+ return `Create "${t}"`;
35
35
  }
36
- function se(n) {
37
- return n.kind === "option" && n.option.disabled === !0;
36
+ function ue(t) {
37
+ return t.kind === "option" && t.option.disabled === !0;
38
38
  }
39
- function Hr(n, b) {
40
- return b ? n.label.toLowerCase().includes(b.toLowerCase()) : !0;
39
+ function Zr(t, b) {
40
+ return b ? t.label.toLowerCase().includes(b.toLowerCase()) : !0;
41
41
  }
42
- function $r(n) {
43
- return n == null ? null : Array.isArray(n) ? n[0] ?? null : n === "" ? null : n;
42
+ function Pr(t) {
43
+ return t == null ? null : Array.isArray(t) ? t[0] ?? null : t === "" ? null : t;
44
44
  }
45
- function Or(n) {
46
- return n == null ? [] : Array.isArray(n) ? n : n === "" ? [] : [n];
45
+ function Wr(t) {
46
+ return t == null ? [] : Array.isArray(t) ? t : t === "" ? [] : [t];
47
47
  }
48
- function jr(n) {
49
- if (n.leadingVisual != null) return n.leadingVisual;
50
- if (n.leadingAvatar != null)
51
- return /* @__PURE__ */ l(
52
- Mr,
48
+ function Yr(t) {
49
+ if (t.leadingVisual != null) return t.leadingVisual;
50
+ if (t.leadingAvatar != null)
51
+ return /* @__PURE__ */ a(
52
+ Cr,
53
53
  {
54
- src: n.leadingAvatar.src,
55
- alt: n.leadingAvatar.alt,
54
+ src: t.leadingAvatar.src,
55
+ alt: t.leadingAvatar.alt,
56
56
  size: "24"
57
57
  }
58
58
  );
59
- if (n.leadingTeamAvatar != null)
60
- return /* @__PURE__ */ l(
61
- Nr,
59
+ if (t.leadingTeamAvatar != null)
60
+ return /* @__PURE__ */ a(
61
+ zr,
62
62
  {
63
- src: n.leadingTeamAvatar.src,
64
- initials: n.leadingTeamAvatar.initials ?? (n.leadingTeamAvatar.src ? void 0 : Array.from(n.label).slice(0, 2).join("")),
65
- alt: n.leadingTeamAvatar.alt,
63
+ src: t.leadingTeamAvatar.src,
64
+ initials: t.leadingTeamAvatar.initials ?? (t.leadingTeamAvatar.src ? void 0 : Array.from(t.label).slice(0, 2).join("")),
65
+ alt: t.leadingTeamAvatar.alt,
66
66
  size: "24",
67
67
  variant: "menu"
68
68
  }
69
69
  );
70
70
  }
71
- const cn = vr(function({
71
+ const xt = Nr(function({
72
72
  options: b,
73
- menuItemProps: Ee,
74
- multiple: o = !1,
75
- value: ie,
76
- defaultValue: ce,
77
- onChange: H,
73
+ menuItemProps: Te,
74
+ multiple: n = !1,
75
+ value: fe,
76
+ defaultValue: de,
77
+ onChange: $,
78
78
  inputValue: Z,
79
- defaultInputValue: Se = "",
79
+ defaultInputValue: Le = "",
80
80
  onInputChange: u,
81
- label: D,
82
- placeholder: Ie,
83
- leadingIcon: q,
84
- size: P = "medium",
85
- invalid: ue = !1,
81
+ label: w,
82
+ placeholder: ze,
83
+ leadingIcon: P,
84
+ size: W = "medium",
85
+ invalid: me = !1,
86
86
  disabled: g = !1,
87
- filter: $ = !0,
88
- emptyMessage: Te = "No results",
89
- loading: fe = !1,
90
- loadingMessage: Le = "Loading…",
87
+ filter: F = !0,
88
+ emptyMessage: Ce = "No results",
89
+ loading: be = !1,
90
+ loadingMessage: He = "Loading…",
91
91
  selectedOptions: k,
92
- creatable: E = !1,
93
- onCreateOption: W,
94
- formatCreateLabel: Fe = Cr,
95
- clearable: ze = !1,
96
- clearLabel: Ce = "Clear",
97
- clearButtonProps: y,
98
- selectionsLabel: He,
99
- listboxLabel: $e = "Options",
100
- className: Oe = "",
101
- id: je,
102
- "aria-label": de,
103
- portalContainer: Ue = null,
104
- zIndex: Ke
105
- }, S) {
106
- const Ge = hr(), Y = je ?? Ge, I = `${Y}-listbox`, B = X(null), me = X(null), w = X(null), Qe = d(
92
+ creatable: R = !1,
93
+ onCreateOption: Y,
94
+ formatCreateLabel: $e = Xr,
95
+ clearable: Fe = !1,
96
+ clearLabel: Oe = "Clear",
97
+ clearButtonProps: p,
98
+ selectionsLabel: je,
99
+ listboxLabel: Ue = "Options",
100
+ className: qe = "",
101
+ id: Ge,
102
+ "aria-label": ve,
103
+ "aria-describedby": Qe,
104
+ required: Xe = !1,
105
+ onFocus: J,
106
+ onBlur: K,
107
+ onKeyDown: B,
108
+ portalContainer: Ze = null,
109
+ zIndex: Pe,
110
+ ...We
111
+ }, E) {
112
+ const Ye = wr(), ee = Ge ?? Ye, S = `${ee}-listbox`, re = X(null), he = X(null), N = X(null), Je = d(
107
113
  (e) => {
108
- w.current = e, typeof S == "function" ? S(e) : S && (S.current = e);
114
+ N.current = e, typeof E == "function" ? E(e) : E && (E.current = e);
109
115
  },
110
- [S]
111
- ), J = ie !== void 0, [Xe, Ze] = V(() => ce !== void 0 ? ce : o ? [] : null), ee = J ? ie : Xe, v = o ? null : $r(ee), s = R(
112
- () => o ? Or(ee) : [],
113
- [o, ee]
114
- ), m = Z !== void 0, [re, T] = V(Se), [c, be] = V(!1), [qe, ve] = V(!1), [h, A] = V(-1), O = X(!1), he = d(
116
+ [E]
117
+ ), te = fe !== void 0, [Ke, Be] = I(() => de !== void 0 ? de : n ? [] : null), ne = te ? fe : Ke, v = n ? null : Pr(ne), s = V(
118
+ () => n ? Wr(ne) : [],
119
+ [n, ne]
120
+ ), m = Z !== void 0, [oe, T] = I(Le), [c, xe] = I(!1), [er, _e] = I(!1), [h, A] = I(-1), O = X(!1), ge = d(
115
121
  (e) => {
116
122
  e !== h && (O.current = !0, A(e));
117
123
  },
118
124
  [h]
119
- ), [j, L] = V(null), U = d(
120
- (e) => b.find((r) => r.value === e) ?? (k == null ? void 0 : k.find((r) => r.value === e)) ?? (E ? { value: e, label: e } : void 0),
121
- [b, k, E]
122
- ), K = R(
125
+ ), [j, L] = I(null), U = d(
126
+ (e) => b.find((r) => r.value === e) ?? (k == null ? void 0 : k.find((r) => r.value === e)) ?? (R ? { value: e, label: e } : void 0),
127
+ [b, k, R]
128
+ ), q = V(
123
129
  () => v == null ? void 0 : U(v),
124
130
  [U, v]
125
- ), ne = m ? Z : o ? re : j !== null ? j : (K == null ? void 0 : K.label) ?? re, oe = m ? Z : o ? re : j !== null ? j : "", F = d(
131
+ ), ae = m ? Z : n ? oe : j !== null ? j : (q == null ? void 0 : q.label) ?? oe, le = m ? Z : n ? oe : j !== null ? j : "", z = d(
126
132
  (e) => {
127
- m || (T(e), o || L(e)), u == null || u(e);
133
+ m || (T(e), n || L(e)), u == null || u(e);
128
134
  },
129
- [m, o, u]
135
+ [m, n, u]
130
136
  ), x = d(
131
137
  (e) => {
132
- J || Ze(e), H == null || H(e);
138
+ te || Be(e), $ == null || $(e);
133
139
  },
134
- [J, H]
135
- ), xe = R(() => {
136
- if ($ === !1) return b;
137
- const e = typeof $ == "function" ? $ : Hr;
138
- return b.filter((r) => e(r, oe));
139
- }, [b, $, oe]), z = E ? oe.trim() : "", _e = R(() => {
140
- if (z === "") return !1;
141
- const e = z.toLowerCase(), r = (f) => f.toLowerCase() === e;
142
- return [...b, ...k ?? []].some((f) => r(f.label) || r(f.value)) ? !1 : !(o ? s : v != null ? [v] : []).some(r);
140
+ [te, $]
141
+ ), pe = V(() => {
142
+ if (F === !1) return b;
143
+ const e = typeof F == "function" ? F : Zr;
144
+ return b.filter((r) => e(r, le));
145
+ }, [b, F, le]), C = R ? le.trim() : "", ye = V(() => {
146
+ if (C === "") return !1;
147
+ const e = C.toLowerCase(), r = (f) => f.toLowerCase() === e;
148
+ return [...b, ...k ?? []].some((f) => r(f.label) || r(f.value)) ? !1 : !(n ? s : v != null ? [v] : []).some(r);
143
149
  }, [
144
- z,
150
+ C,
145
151
  b,
146
152
  k,
147
- o,
153
+ n,
148
154
  s,
149
155
  v
150
- ]), i = R(
156
+ ]), i = V(
151
157
  () => [
152
- ...xe.map((e) => ({ kind: "option", option: e })),
153
- ..._e ? [{ kind: "create", inputValue: z }] : []
158
+ ...pe.map((e) => ({ kind: "option", option: e })),
159
+ ...ye ? [{ kind: "create", inputValue: C }] : []
154
160
  ],
155
- [xe, _e, z]
156
- ), N = d(
157
- (e) => e.kind === "option" ? `${I}-option-${e.option.value}` : `${I}-create`,
158
- [I]
159
- ), { mounted: ge, visible: Pe } = Er(c), {
160
- placement: We,
161
- maxHeight: Ye,
162
- style: Be,
163
- portalRef: ye,
164
- renderPortal: Je
165
- } = Vr(me, ge, {
166
- preferredHeight: Re,
167
- maxHeightCap: Re,
168
- portalContainer: Ue,
169
- zIndex: Ke
170
- }), p = d(() => {
171
- be(!1), A(-1), !o && !m && (L(null), T(""));
172
- }, [o, m]), C = d(() => {
173
- g || be(!0);
161
+ [pe, ye, C]
162
+ ), D = d(
163
+ (e) => e.kind === "option" ? `${S}-option-${e.option.value}` : `${S}-create`,
164
+ [S]
165
+ ), { mounted: ke, visible: rr } = Fr(c), {
166
+ placement: tr,
167
+ maxHeight: nr,
168
+ style: or,
169
+ portalRef: Ae,
170
+ renderPortal: ar
171
+ } = Hr(he, ke, {
172
+ preferredHeight: Se,
173
+ maxHeightCap: Se,
174
+ portalContainer: Ze,
175
+ zIndex: Pe
176
+ }), y = d(() => {
177
+ xe(!1), A(-1), !n && !m && (L(null), T(""));
178
+ }, [n, m]), H = d(() => {
179
+ g || xe(!0);
174
180
  }, [g]);
175
- Rr(B, c, p, ye), Me(() => {
181
+ $r(re, c, y, Ae), Re(() => {
176
182
  c && A((e) => {
177
183
  if (i.length === 0) return -1;
178
184
  if (e >= 0 && e < i.length) return e;
179
185
  const r = i.findIndex(
180
- (t) => t.kind === "option" && (o ? s.includes(t.option.value) : t.option.value === v)
186
+ (o) => o.kind === "option" && (n ? s.includes(o.option.value) : o.option.value === v)
181
187
  );
182
188
  return r >= 0 ? r : 0;
183
189
  });
184
- }, [c, i, o, s, v]);
185
- const er = d(
186
- (e) => o ? s.includes(e) : v === e,
187
- [o, s, v]
188
- ), te = d(
190
+ }, [c, i, n, s, v]);
191
+ const lr = d(
192
+ (e) => n ? s.includes(e) : v === e,
193
+ [n, s, v]
194
+ ), se = d(
189
195
  (e) => {
190
196
  var r;
191
197
  if (!e.disabled) {
192
- if (o) {
193
- const t = s.includes(e.value) ? s.filter((_) => _ !== e.value) : [...s, e.value];
194
- x(t), F(""), p(), (r = w.current) == null || r.focus();
198
+ if (n) {
199
+ const o = s.includes(e.value) ? s.filter((_) => _ !== e.value) : [...s, e.value];
200
+ x(o), z(""), y(), (r = N.current) == null || r.focus();
195
201
  return;
196
202
  }
197
- x(e.value), m ? u == null || u(e.label) : (T(""), L(null)), p();
203
+ x(e.value), m ? u == null || u(e.label) : (T(""), L(null)), y();
198
204
  }
199
205
  },
200
206
  [
201
- o,
207
+ n,
202
208
  s,
203
209
  x,
204
- F,
210
+ z,
205
211
  m,
206
212
  u,
207
- p
213
+ y
208
214
  ]
209
- ), le = d(
215
+ ), ie = d(
210
216
  (e) => {
211
217
  var r;
212
- if (W ? W(e) : x(o ? [...s, e] : e), o) {
213
- F(""), p(), (r = w.current) == null || r.focus();
218
+ if (Y ? Y(e) : x(n ? [...s, e] : e), n) {
219
+ z(""), y(), (r = N.current) == null || r.focus();
214
220
  return;
215
221
  }
216
- m ? u == null || u(e) : (T(""), L(null)), p();
222
+ m ? u == null || u(e) : (T(""), L(null)), y();
217
223
  },
218
224
  [
219
- W,
220
- o,
225
+ Y,
226
+ n,
221
227
  s,
222
228
  x,
223
- F,
229
+ z,
224
230
  m,
225
231
  u,
226
- p
232
+ y
227
233
  ]
228
- ), rr = d(
234
+ ), sr = d(
229
235
  (e) => {
230
- e.kind === "create" ? le(e.inputValue) : te(e.option);
236
+ e.kind === "create" ? ie(e.inputValue) : se(e.option);
231
237
  },
232
- [le, te]
233
- ), nr = d(() => {
238
+ [ie, se]
239
+ ), ir = d(() => {
234
240
  var e;
235
- x(null), m ? u == null || u("") : (T(""), L(null)), (e = w.current) == null || e.focus();
236
- }, [x, m, u]), pe = d(
241
+ x(null), m ? u == null || u("") : (T(""), L(null)), (e = N.current) == null || e.focus();
242
+ }, [x, m, u]), Ne = d(
237
243
  (e) => {
238
- o && x(s.filter((r) => r !== e));
244
+ n && x(s.filter((r) => r !== e));
239
245
  },
240
- [o, s, x]
241
- ), ke = d(
246
+ [n, s, x]
247
+ ), we = d(
242
248
  (e) => {
243
249
  O.current = !1;
244
- const r = i.map((t, _) => ({ row: t, i: _ })).filter(({ row: t }) => !se(t));
250
+ const r = i.map((o, _) => ({ row: o, i: _ })).filter(({ row: o }) => !ue(o));
245
251
  if (r.length === 0) {
246
252
  A(-1);
247
253
  return;
248
254
  }
249
- A((t) => {
250
- const _ = r.findIndex(({ i: Q }) => Q === t), f = _ < 0 ? e > 0 ? 0 : r.length - 1 : (_ + e + r.length) % r.length;
255
+ A((o) => {
256
+ const _ = r.findIndex(({ i: Q }) => Q === o), f = _ < 0 ? e > 0 ? 0 : r.length - 1 : (_ + e + r.length) % r.length;
251
257
  return r[f].i;
252
258
  });
253
259
  },
254
260
  [i]
255
261
  );
256
- Me(() => {
257
- var r, t;
262
+ Re(() => {
263
+ var r, o;
258
264
  if (!c || h < 0) return;
259
265
  if (O.current) {
260
266
  O.current = !1;
261
267
  return;
262
268
  }
263
269
  const e = i[h];
264
- e && ((t = (r = document.getElementById(N(e))) == null ? void 0 : r.scrollIntoView) == null || t.call(r, { block: "nearest" }));
265
- }, [c, h, i, N]);
266
- const or = (e) => {
270
+ e && ((o = (r = document.getElementById(D(e))) == null ? void 0 : r.scrollIntoView) == null || o.call(r, { block: "nearest" }));
271
+ }, [c, h, i, D]);
272
+ const cr = (e) => {
267
273
  const r = e.target.value;
268
- F(r), c || C(), A(0);
269
- }, tr = () => {
270
- ve(!0), C(), !o && !m && K && requestAnimationFrame(() => {
274
+ z(r), c || H(), A(0);
275
+ }, ur = () => {
276
+ _e(!0), H(), !n && !m && q && requestAnimationFrame(() => {
271
277
  var e;
272
- (e = w.current) == null || e.select();
278
+ (e = N.current) == null || e.select();
273
279
  });
274
- }, Ae = (e) => {
275
- var t;
280
+ }, De = (e) => {
281
+ var o;
276
282
  const r = e.relatedTarget;
277
- r && ((t = B.current) != null && t.contains(r)) || ve(!1);
278
- }, lr = (e) => {
283
+ r && ((o = re.current) != null && o.contains(r)) || _e(!1);
284
+ }, fr = (e) => {
279
285
  if (!g)
280
286
  switch (e.key) {
281
287
  case "ArrowDown":
282
- e.preventDefault(), c ? ke(1) : C();
288
+ e.preventDefault(), c ? we(1) : H();
283
289
  break;
284
290
  case "ArrowUp":
285
- e.preventDefault(), c ? ke(-1) : C();
291
+ e.preventDefault(), c ? we(-1) : H();
286
292
  break;
287
293
  case "Home":
288
294
  c && i.length > 0 && (e.preventDefault(), A(
289
295
  Math.max(
290
296
  0,
291
- i.findIndex((r) => !se(r))
297
+ i.findIndex((r) => !ue(r))
292
298
  )
293
299
  ));
294
300
  break;
@@ -296,82 +302,88 @@ const cn = vr(function({
296
302
  if (c && i.length > 0) {
297
303
  e.preventDefault();
298
304
  for (let r = i.length - 1; r >= 0; r--)
299
- if (!se(i[r])) {
305
+ if (!ue(i[r])) {
300
306
  A(r);
301
307
  break;
302
308
  }
303
309
  }
304
310
  break;
305
311
  case "Enter":
306
- c && h >= 0 && i[h] && (e.preventDefault(), rr(i[h]));
312
+ c && h >= 0 && i[h] && (e.preventDefault(), sr(i[h]));
307
313
  break;
308
314
  case "Escape":
309
- c && (e.preventDefault(), p());
315
+ c && (e.preventDefault(), y());
310
316
  break;
311
317
  case "Backspace":
312
- o && ne === "" && s.length > 0 && (e.preventDefault(), pe(s[s.length - 1]));
318
+ n && ae === "" && s.length > 0 && (e.preventDefault(), Ne(s[s.length - 1]));
313
319
  break;
314
320
  case "Tab":
315
- p();
321
+ y();
316
322
  break;
317
323
  }
318
- }, ar = (e) => {
324
+ }, dr = (e) => {
325
+ ur(), J == null || J(e);
326
+ }, mr = (e) => {
327
+ De(e), K == null || K(e);
328
+ }, br = (e) => {
329
+ fr(e), B == null || B(e);
330
+ }, vr = (e) => {
319
331
  var r;
320
- g || e.target.closest("[data-chip], [data-combobox-clear]") || (e.target !== w.current && (e.preventDefault(), (r = w.current) == null || r.focus()), c || C());
321
- }, we = o ? s.length > 0 : v != null && v !== "", sr = ne.length > 0, ir = ze && !o && we && !g, cr = qe || c || we || sr, De = h >= 0 ? i[h] : void 0, ur = De != null ? N(De) : void 0, G = R(() => {
322
- if (!o) return [];
332
+ g || e.target.closest("[data-chip], [data-combobox-clear]") || (e.target !== N.current && (e.preventDefault(), (r = N.current) == null || r.focus()), c || H());
333
+ }, Me = n ? s.length > 0 : v != null && v !== "", hr = ae.length > 0, xr = Fe && !n && Me && !g, _r = er || c || Me || hr, Ie = h >= 0 ? i[h] : void 0, gr = Ie != null ? D(Ie) : void 0, G = V(() => {
334
+ if (!n) return [];
323
335
  if (k == null) {
324
- const e = b.filter((t) => s.includes(t.value));
325
- if (!E) return e;
326
- const r = new Set(e.map((t) => t.value));
336
+ const e = b.filter((o) => s.includes(o.value));
337
+ if (!R) return e;
338
+ const r = new Set(e.map((o) => o.value));
327
339
  return [
328
340
  ...e,
329
- ...s.filter((t) => !r.has(t)).map((t) => ({ value: t, label: t }))
341
+ ...s.filter((o) => !r.has(o)).map((o) => ({ value: o, label: o }))
330
342
  ];
331
343
  }
332
344
  return s.map(U).filter((e) => e != null);
333
345
  }, [
334
- o,
346
+ n,
335
347
  k,
336
348
  b,
337
349
  s,
338
- E,
350
+ R,
339
351
  U
340
- ]), fr = a[`combobox--size-${Tr(P)}`], dr = o && G.length > 0, mr = [
341
- a.combobox,
342
- fr,
343
- ue ? a["combobox--invalid"] : "",
344
- D != null && cr ? a["combobox--label-floated"] : "",
345
- q != null ? a["combobox--has-leading-icon"] : "",
346
- dr ? a["combobox--has-chips"] : "",
347
- c ? a["combobox--open"] : "",
348
- g ? a["combobox--disabled"] : "",
349
- Oe
352
+ ]), pr = l[`combobox--size-${Ur(W)}`], yr = n && G.length > 0, kr = [
353
+ l.combobox,
354
+ pr,
355
+ me ? l["combobox--invalid"] : "",
356
+ w != null && _r ? l["combobox--label-floated"] : "",
357
+ P != null ? l["combobox--has-leading-icon"] : "",
358
+ yr ? l["combobox--has-chips"] : "",
359
+ c ? l["combobox--open"] : "",
360
+ g ? l["combobox--disabled"] : "",
361
+ qe
350
362
  ].filter(Boolean).join(" ");
351
- return /* @__PURE__ */ M("div", { className: mr, ref: B, children: [
352
- /* @__PURE__ */ M("div", { className: a.combobox__wrapper, ref: me, children: [
353
- D != null && /* @__PURE__ */ l("label", { className: a.combobox__label, htmlFor: Y, children: D }),
363
+ return /* @__PURE__ */ M("div", { className: kr, ref: re, children: [
364
+ /* @__PURE__ */ M("div", { className: l.combobox__wrapper, ref: he, children: [
365
+ w != null && /* @__PURE__ */ a("label", { className: l.combobox__label, htmlFor: ee, children: w }),
354
366
  /* @__PURE__ */ M(
355
367
  "div",
356
368
  {
357
- className: a.combobox__inner,
358
- onMouseDown: ar,
369
+ className: l.combobox__inner,
370
+ onMouseDown: vr,
359
371
  children: [
360
- q != null && /* @__PURE__ */ l("span", { className: a["combobox__leading-icon"], "aria-hidden": !0, children: /* @__PURE__ */ l(kr.Provider, { value: { size: "16" }, children: q }) }),
361
- /* @__PURE__ */ M("div", { className: a.combobox__value, children: [
362
- o && G.length > 0 && /* @__PURE__ */ l(
363
- pr,
372
+ P != null && /* @__PURE__ */ a("span", { className: l["combobox__leading-icon"], "aria-hidden": !0, children: /* @__PURE__ */ a(Er.Provider, { value: { size: "16" }, children: P }) }),
373
+ /* @__PURE__ */ M("div", { className: l.combobox__value, children: [
374
+ n && G.length > 0 && /* @__PURE__ */ a(
375
+ Rr,
364
376
  {
365
- "aria-label": He ?? zr(D),
377
+ "aria-label": je ?? Qr(w),
366
378
  disabled: g,
367
- children: G.map((e) => /* @__PURE__ */ l(
368
- yr,
379
+ children: G.map((e) => /* @__PURE__ */ a(
380
+ Vr,
369
381
  {
370
- size: Lr[P],
382
+ size: qr[W],
371
383
  leadingAvatar: e.leadingAvatar,
372
384
  leadingIcon: e.leadingAvatar == null ? e.leadingVisual : void 0,
373
385
  onRemove: g ? void 0 : (r) => {
374
- r.stopPropagation(), pe(e.value);
386
+ r.stopPropagation(), Ne(e.value);
375
387
  },
376
388
  children: e.label
377
389
  },
@@ -379,130 +391,133 @@ const cn = vr(function({
379
391
  ))
380
392
  }
381
393
  ),
382
- /* @__PURE__ */ l(
394
+ /* @__PURE__ */ a(
383
395
  "input",
384
396
  {
385
- ref: Qe,
386
- id: Y,
387
- className: a.combobox__control,
397
+ ...We,
398
+ ref: Je,
399
+ id: ee,
400
+ className: l.combobox__control,
388
401
  type: "text",
389
402
  role: "combobox",
390
403
  autoComplete: "off",
391
404
  spellCheck: !1,
392
405
  disabled: g,
393
- placeholder: o && G.length > 0 ? void 0 : Ie,
394
- value: ne,
395
- "aria-label": de,
396
- "aria-invalid": ue ? !0 : void 0,
406
+ placeholder: n && G.length > 0 ? void 0 : ze,
407
+ value: ae,
408
+ "aria-label": ve,
409
+ "aria-describedby": Qe || void 0,
410
+ "aria-required": Xe ? !0 : void 0,
411
+ "aria-invalid": me ? !0 : void 0,
397
412
  "aria-expanded": c,
398
- "aria-controls": I,
413
+ "aria-controls": S,
399
414
  "aria-autocomplete": "list",
400
- "aria-activedescendant": ur,
401
- "aria-busy": fe || void 0,
402
- onChange: or,
403
- onFocus: tr,
404
- onBlur: Ae,
405
- onKeyDown: lr
415
+ "aria-activedescendant": gr,
416
+ "aria-busy": be || void 0,
417
+ onChange: cr,
418
+ onFocus: dr,
419
+ onBlur: mr,
420
+ onKeyDown: br
406
421
  }
407
422
  )
408
423
  ] }),
409
- ir && /* @__PURE__ */ l(
424
+ xr && /* @__PURE__ */ a(
410
425
  "button",
411
426
  {
412
- ...y,
427
+ ...p,
413
428
  type: "button",
414
- className: Ir(
415
- a.combobox__clear,
416
- y == null ? void 0 : y.className
429
+ className: jr(
430
+ l.combobox__clear,
431
+ p == null ? void 0 : p.className
417
432
  ),
418
- "aria-label": Ce,
433
+ "aria-label": Oe,
419
434
  "data-combobox-clear": "",
420
- onClick: nr,
435
+ onClick: ir,
421
436
  onBlur: (e) => {
422
437
  var r;
423
- (r = y == null ? void 0 : y.onBlur) == null || r.call(y, e), Ae(e);
438
+ (r = p == null ? void 0 : p.onBlur) == null || r.call(p, e), De(e);
424
439
  },
425
- children: /* @__PURE__ */ l(ae, { size: Fr[P], glyph: /* @__PURE__ */ l(_r, {}) })
440
+ children: /* @__PURE__ */ a(ce, { size: Gr[W], glyph: /* @__PURE__ */ a(Mr, {}) })
426
441
  }
427
442
  ),
428
- /* @__PURE__ */ l("span", { className: a["combobox__trailing-icon"], "aria-hidden": !0, children: /* @__PURE__ */ l(ae, { size: "12", glyph: /* @__PURE__ */ l(xr, {}) }) })
443
+ /* @__PURE__ */ a("span", { className: l["combobox__trailing-icon"], "aria-hidden": !0, children: /* @__PURE__ */ a(ce, { size: "12", glyph: /* @__PURE__ */ a(Dr, {}) }) })
429
444
  ]
430
445
  }
431
446
  )
432
447
  ] }),
433
- ge && Je(
434
- /* @__PURE__ */ l(
448
+ ke && ar(
449
+ /* @__PURE__ */ a(
435
450
  "div",
436
451
  {
437
- ref: ye,
452
+ ref: Ae,
438
453
  className: [
439
- a.combobox__popup,
440
- We === "above" ? a["combobox__popup--above"] : "",
441
- Pe ? a["combobox__popup--visible"] : ""
454
+ l.combobox__popup,
455
+ tr === "above" ? l["combobox__popup--above"] : "",
456
+ rr ? l["combobox__popup--visible"] : ""
442
457
  ].filter(Boolean).join(" "),
443
- style: Be,
444
- children: /* @__PURE__ */ l(Ar, { className: a.combobox__menu, children: /* @__PURE__ */ M(wr, { maxHeight: Ye, children: [
445
- i.length > 0 && /* @__PURE__ */ l(
458
+ style: or,
459
+ children: /* @__PURE__ */ a(Sr, { className: l.combobox__menu, children: /* @__PURE__ */ M(Tr, { maxHeight: nr, children: [
460
+ i.length > 0 && /* @__PURE__ */ a(
446
461
  "ul",
447
462
  {
448
- id: I,
449
- className: a.combobox__list,
463
+ id: S,
464
+ className: l.combobox__list,
450
465
  role: "listbox",
451
- "aria-multiselectable": o || void 0,
452
- "aria-label": typeof D == "string" ? D : de ?? $e,
466
+ "aria-multiselectable": n || void 0,
467
+ "aria-label": typeof w == "string" ? w : ve ?? Ue,
453
468
  children: i.map((e, r) => {
454
- const t = r === h, _ = (br) => {
455
- br.preventDefault();
469
+ const o = r === h, _ = (Ar) => {
470
+ Ar.preventDefault();
456
471
  };
457
472
  if (e.kind === "create")
458
- return /* @__PURE__ */ l(
473
+ return /* @__PURE__ */ a(
459
474
  "li",
460
475
  {
461
- className: a.combobox__option,
476
+ className: l.combobox__option,
462
477
  role: "presentation",
463
- children: /* @__PURE__ */ l(
464
- Ve,
478
+ children: /* @__PURE__ */ a(
479
+ Ee,
465
480
  {
466
- id: N(e),
481
+ id: D(e),
467
482
  role: "option",
468
- label: Fe(e.inputValue),
469
- leadingVisual: /* @__PURE__ */ l(ae, { glyph: /* @__PURE__ */ l(gr, {}) }),
470
- active: t,
483
+ label: $e(e.inputValue),
484
+ leadingVisual: /* @__PURE__ */ a(ce, { glyph: /* @__PURE__ */ a(Ir, {}) }),
485
+ active: o,
471
486
  "aria-selected": !1,
472
487
  onMouseDown: _,
473
- onMouseEnter: () => he(r),
474
- onClick: () => le(e.inputValue)
488
+ onMouseEnter: () => ge(r),
489
+ onClick: () => ie(e.inputValue)
475
490
  }
476
491
  )
477
492
  },
478
- N(e)
493
+ D(e)
479
494
  );
480
- const { option: f } = e, Q = er(f.value), Ne = jr(f);
481
- return /* @__PURE__ */ l(
495
+ const { option: f } = e, Q = lr(f.value), Ve = Yr(f);
496
+ return /* @__PURE__ */ a(
482
497
  "li",
483
498
  {
484
- className: a.combobox__option,
499
+ className: l.combobox__option,
485
500
  role: "presentation",
486
- children: /* @__PURE__ */ l(
487
- Ve,
501
+ children: /* @__PURE__ */ a(
502
+ Ee,
488
503
  {
489
- ...Sr(
490
- Ee,
504
+ ...Or(
505
+ Te,
491
506
  f.menuItemProps
492
507
  ),
493
- id: N(e),
508
+ id: D(e),
494
509
  role: "option",
495
510
  label: f.label,
496
511
  secondaryLabel: f.secondaryLabel,
497
- leadingElement: Ne != null,
498
- leadingVisual: Ne,
512
+ leadingElement: Ve != null,
513
+ leadingVisual: Ve,
499
514
  trailingElement: Q,
500
- active: t,
515
+ active: o,
501
516
  disabled: f.disabled,
502
517
  "aria-selected": Q,
503
518
  onMouseDown: _,
504
- onMouseEnter: () => he(r),
505
- onClick: () => te(f)
519
+ onMouseEnter: () => ge(r),
520
+ onClick: () => se(f)
506
521
  }
507
522
  )
508
523
  },
@@ -511,10 +526,10 @@ const cn = vr(function({
511
526
  })
512
527
  }
513
528
  ),
514
- fe ? /* @__PURE__ */ M("div", { className: a.combobox__loading, role: "status", children: [
515
- /* @__PURE__ */ l(Dr, { size: "16", "aria-hidden": !0 }),
516
- /* @__PURE__ */ l("span", { children: Le })
517
- ] }) : i.length === 0 && /* @__PURE__ */ l("p", { className: a.combobox__empty, children: Te })
529
+ be ? /* @__PURE__ */ M("div", { className: l.combobox__loading, role: "status", children: [
530
+ /* @__PURE__ */ a(Lr, { size: "16", "aria-hidden": !0 }),
531
+ /* @__PURE__ */ a("span", { children: He })
532
+ ] }) : i.length === 0 && /* @__PURE__ */ a("p", { className: l.combobox__empty, children: Ce })
518
533
  ] }) })
519
534
  }
520
535
  )
@@ -522,6 +537,6 @@ const cn = vr(function({
522
537
  ] });
523
538
  });
524
539
  export {
525
- cn as default
540
+ xt as default
526
541
  };
527
542
  //# sourceMappingURL=Combobox.js.map