@mattermost/compass-ui 0.1.0-alpha.20 → 0.1.0-alpha.22

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