@linyao.tw/ui 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/README.md +9 -1
  2. package/dist/components/date-time/calendar.js +7 -6
  3. package/dist/components/date-time/calendar.js.map +1 -1
  4. package/dist/components/date-time/date-field.js +9 -8
  5. package/dist/components/date-time/date-field.js.map +1 -1
  6. package/dist/components/date-time/date-picker.js +7 -6
  7. package/dist/components/date-time/date-picker.js.map +1 -1
  8. package/dist/components/date-time/date-range-picker.js +7 -6
  9. package/dist/components/date-time/date-range-picker.js.map +1 -1
  10. package/dist/components/date-time/index.js +0 -1
  11. package/dist/components/date-time/shared.d.ts +0 -1
  12. package/dist/components/date-time/shared.js +6 -9
  13. package/dist/components/date-time/shared.js.map +1 -1
  14. package/dist/components/date-time/time-field.js +7 -6
  15. package/dist/components/date-time/time-field.js.map +1 -1
  16. package/dist/components/feedback/alert.js +34 -34
  17. package/dist/components/feedback/alert.js.map +1 -1
  18. package/dist/components/feedback/banner.js +14 -14
  19. package/dist/components/feedback/banner.js.map +1 -1
  20. package/dist/components/feedback/empty-state.d.ts +2 -1
  21. package/dist/components/feedback/empty-state.js +30 -31
  22. package/dist/components/feedback/empty-state.js.map +1 -1
  23. package/dist/components/feedback/feedback.types.d.ts +0 -1
  24. package/dist/components/feedback/feedback.types.js +2 -5
  25. package/dist/components/feedback/feedback.types.js.map +1 -1
  26. package/dist/components/feedback/index.d.ts +8 -8
  27. package/dist/components/feedback/meter.js +20 -21
  28. package/dist/components/feedback/meter.js.map +1 -1
  29. package/dist/components/feedback/progress.js +20 -21
  30. package/dist/components/feedback/progress.js.map +1 -1
  31. package/dist/components/feedback/skeleton.js +10 -11
  32. package/dist/components/feedback/skeleton.js.map +1 -1
  33. package/dist/components/feedback/spinner.js +24 -25
  34. package/dist/components/feedback/spinner.js.map +1 -1
  35. package/dist/components/feedback/toast.js +22 -21
  36. package/dist/components/feedback/toast.js.map +1 -1
  37. package/dist/components/forms/{CodeField.d.ts → code-field.d.ts} +1 -1
  38. package/dist/components/forms/code-field.js +65 -0
  39. package/dist/components/forms/code-field.js.map +1 -0
  40. package/dist/components/forms/{FileUpload.d.ts → file-upload.d.ts} +1 -1
  41. package/dist/components/forms/{FileUpload.js → file-upload.js} +127 -111
  42. package/dist/components/forms/file-upload.js.map +1 -0
  43. package/dist/components/forms/index.d.ts +6 -6
  44. package/dist/components/forms/{Input.js → input.js} +3 -3
  45. package/dist/components/forms/input.js.map +1 -0
  46. package/dist/components/forms/internal.d.ts +0 -2
  47. package/dist/components/forms/internal.js +12 -17
  48. package/dist/components/forms/internal.js.map +1 -1
  49. package/dist/components/forms/number-field.js +73 -0
  50. package/dist/components/forms/number-field.js.map +1 -0
  51. package/dist/components/forms/otp-field.js +57 -0
  52. package/dist/components/forms/otp-field.js.map +1 -0
  53. package/dist/components/forms/{TextField.d.ts → text-field.d.ts} +5 -0
  54. package/dist/components/forms/text-field.js +200 -0
  55. package/dist/components/forms/text-field.js.map +1 -0
  56. package/dist/components/foundations/{Avatar.js → avatar.js} +3 -3
  57. package/dist/components/foundations/avatar.js.map +1 -0
  58. package/dist/components/foundations/{Badge.d.ts → badge.d.ts} +1 -1
  59. package/dist/components/foundations/{Badge.js → badge.js} +3 -3
  60. package/dist/components/foundations/badge.js.map +1 -0
  61. package/dist/components/foundations/{Button.js → button.js} +3 -3
  62. package/dist/components/foundations/button.js.map +1 -0
  63. package/dist/components/foundations/{Card.d.ts → card.d.ts} +9 -2
  64. package/dist/components/foundations/{Card.js → card.js} +5 -5
  65. package/dist/components/foundations/card.js.map +1 -0
  66. package/dist/components/foundations/{IconButton.d.ts → icon-button.d.ts} +2 -8
  67. package/dist/components/foundations/{IconButton.js → icon-button.js} +4 -4
  68. package/dist/components/foundations/icon-button.js.map +1 -0
  69. package/dist/components/foundations/index.d.ts +9 -9
  70. package/dist/components/foundations/{Link.d.ts → link.d.ts} +1 -1
  71. package/dist/components/foundations/link.js +46 -0
  72. package/dist/components/foundations/link.js.map +1 -0
  73. package/dist/components/foundations/{ListCell.d.ts → list-cell.d.ts} +1 -8
  74. package/dist/components/foundations/{ListCell.js → list-cell.js} +3 -3
  75. package/dist/components/foundations/list-cell.js.map +1 -0
  76. package/dist/components/foundations/{SectionHeading.d.ts → section-heading.d.ts} +5 -2
  77. package/dist/components/foundations/{SectionHeading.js → section-heading.js} +3 -3
  78. package/dist/components/foundations/section-heading.js.map +1 -0
  79. package/dist/components/foundations/{Separator.js → separator.js} +3 -3
  80. package/dist/components/foundations/separator.js.map +1 -0
  81. package/dist/components/navigation-data/breadcrumb-pagination.js +88 -81
  82. package/dist/components/navigation-data/breadcrumb-pagination.js.map +1 -1
  83. package/dist/components/navigation-data/command-palette.d.ts +26 -0
  84. package/dist/components/navigation-data/command-palette.js +100 -72
  85. package/dist/components/navigation-data/command-palette.js.map +1 -1
  86. package/dist/components/navigation-data/header-tab-bar.js +49 -46
  87. package/dist/components/navigation-data/header-tab-bar.js.map +1 -1
  88. package/dist/components/navigation-data/index.d.ts +7 -7
  89. package/dist/components/navigation-data/menubar-toolbar.js +1 -1
  90. package/dist/components/navigation-data/menubar-toolbar.js.map +1 -1
  91. package/dist/components/navigation-data/navigation-menu.js +1 -1
  92. package/dist/components/navigation-data/navigation-menu.js.map +1 -1
  93. package/dist/components/navigation-data/scroll-area.js +1 -1
  94. package/dist/components/navigation-data/scroll-area.js.map +1 -1
  95. package/dist/components/navigation-data/table-collection.d.ts +12 -3
  96. package/dist/components/navigation-data/table-collection.js +11 -9
  97. package/dist/components/navigation-data/table-collection.js.map +1 -1
  98. package/dist/components/overlays/dialog.d.ts +13 -2
  99. package/dist/components/overlays/dialog.js +136 -131
  100. package/dist/components/overlays/dialog.js.map +1 -1
  101. package/dist/components/overlays/disclosure.js +1 -1
  102. package/dist/components/overlays/disclosure.js.map +1 -1
  103. package/dist/components/overlays/drawer.d.ts +5 -1
  104. package/dist/components/overlays/drawer.js +156 -152
  105. package/dist/components/overlays/drawer.js.map +1 -1
  106. package/dist/components/overlays/floating.js +115 -113
  107. package/dist/components/overlays/floating.js.map +1 -1
  108. package/dist/components/overlays/index.d.ts +4 -4
  109. package/dist/components/selection/combobox.js +93 -93
  110. package/dist/components/selection/combobox.js.map +1 -1
  111. package/dist/components/selection/controls.d.ts +4 -1
  112. package/dist/components/selection/controls.js +140 -118
  113. package/dist/components/selection/controls.js.map +1 -1
  114. package/dist/components/selection/menu.js +120 -121
  115. package/dist/components/selection/menu.js.map +1 -1
  116. package/dist/components/selection/select.js +107 -107
  117. package/dist/components/selection/select.js.map +1 -1
  118. package/dist/fonts.css +13 -0
  119. package/dist/index.d.ts +1 -0
  120. package/dist/index.js +37 -33
  121. package/dist/internal/accessible-name.d.ts +12 -0
  122. package/dist/internal/class-names.d.ts +12 -0
  123. package/dist/{components/selection/classnames.js → internal/class-names.js} +3 -3
  124. package/dist/internal/class-names.js.map +1 -0
  125. package/dist/internal/index.d.ts +3 -0
  126. package/dist/{components/foundations/shared.d.ts → internal/render.d.ts} +2 -1
  127. package/dist/intl/index.d.ts +2 -0
  128. package/dist/intl/messages.d.ts +48 -0
  129. package/dist/intl/messages.js +80 -0
  130. package/dist/intl/messages.js.map +1 -0
  131. package/dist/intl/provider.d.ts +18 -0
  132. package/dist/intl/provider.js +22 -0
  133. package/dist/intl/provider.js.map +1 -0
  134. package/dist/styles.css +1 -1
  135. package/package.json +6 -4
  136. package/dist/components/feedback/feedback.module.js +0 -42
  137. package/dist/components/feedback/feedback.module.js.map +0 -1
  138. package/dist/components/forms/CodeField.js +0 -63
  139. package/dist/components/forms/CodeField.js.map +0 -1
  140. package/dist/components/forms/FileUpload.js.map +0 -1
  141. package/dist/components/forms/Input.js.map +0 -1
  142. package/dist/components/forms/NumberField.js +0 -71
  143. package/dist/components/forms/NumberField.js.map +0 -1
  144. package/dist/components/forms/OTPField.js +0 -54
  145. package/dist/components/forms/OTPField.js.map +0 -1
  146. package/dist/components/forms/TextField.js +0 -199
  147. package/dist/components/forms/TextField.js.map +0 -1
  148. package/dist/components/foundations/Avatar.js.map +0 -1
  149. package/dist/components/foundations/Badge.js.map +0 -1
  150. package/dist/components/foundations/Button.js.map +0 -1
  151. package/dist/components/foundations/Card.js.map +0 -1
  152. package/dist/components/foundations/IconButton.js.map +0 -1
  153. package/dist/components/foundations/Link.js +0 -40
  154. package/dist/components/foundations/Link.js.map +0 -1
  155. package/dist/components/foundations/ListCell.js.map +0 -1
  156. package/dist/components/foundations/SectionHeading.js.map +0 -1
  157. package/dist/components/foundations/Separator.js.map +0 -1
  158. package/dist/components/foundations/shared.js +0 -8
  159. package/dist/components/foundations/shared.js.map +0 -1
  160. package/dist/components/navigation-data/utils.d.ts +0 -2
  161. package/dist/components/navigation-data/utils.js +0 -11
  162. package/dist/components/navigation-data/utils.js.map +0 -1
  163. package/dist/components/overlays/class-names.d.ts +0 -6
  164. package/dist/components/overlays/class-names.js +0 -11
  165. package/dist/components/overlays/class-names.js.map +0 -1
  166. package/dist/components/selection/classnames.d.ts +0 -4
  167. package/dist/components/selection/classnames.js.map +0 -1
  168. package/dist/components/selection/selection.module.js +0 -51
  169. package/dist/components/selection/selection.module.js.map +0 -1
  170. /package/dist/components/forms/{Input.d.ts → input.d.ts} +0 -0
  171. /package/dist/components/forms/{NumberField.d.ts → number-field.d.ts} +0 -0
  172. /package/dist/components/forms/{OTPField.d.ts → otp-field.d.ts} +0 -0
  173. /package/dist/components/foundations/{Avatar.d.ts → avatar.d.ts} +0 -0
  174. /package/dist/components/foundations/{Button.d.ts → button.d.ts} +0 -0
  175. /package/dist/components/foundations/{Separator.d.ts → separator.d.ts} +0 -0
@@ -1,5 +1,5 @@
1
- import e from "./selection.module.js";
2
- import { mergeStateClassName as t } from "./classnames.js";
1
+ import { withStateClassName as e } from "../../internal/class-names.js";
2
+ import { useMessages as t } from "../../intl/provider.js";
3
3
  import { forwardRef as n, useMemo as r } from "react";
4
4
  import { jsx as i, jsxs as a } from "react/jsx-runtime";
5
5
  import { XIcon as o } from "@phosphor-icons/react/dist/csr/X";
@@ -8,65 +8,65 @@ import { CheckIcon as c } from "@phosphor-icons/react/dist/csr/Check";
8
8
  import { CaretDownIcon as l } from "@phosphor-icons/react/dist/csr/CaretDown";
9
9
  import { Autocomplete as u } from "@base-ui/react/autocomplete";
10
10
  //#region src/components/selection/combobox.tsx
11
- var d = n(function({ className: n, ...r }, a) {
11
+ var d = n(function({ className: t, ...n }, r) {
12
12
  return /* @__PURE__ */ i(s.InputGroup, {
13
- ...r,
14
- className: t(e.comboboxInputGroup, n),
15
- ref: a
13
+ ...n,
14
+ className: e("lyds-combobox__input-group", t),
15
+ ref: r
16
16
  });
17
- }), f = n(function({ className: n, ...r }, a) {
17
+ }), f = n(function({ className: t, ...n }, r) {
18
18
  return /* @__PURE__ */ i(s.Input, {
19
- ...r,
20
- className: t(e.comboboxInput, n),
21
- ref: a
19
+ ...n,
20
+ className: e("lyds-combobox__input", t),
21
+ ref: r
22
22
  });
23
- }), p = n(function({ className: n, ...r }, a) {
23
+ }), p = n(function({ className: t, ...n }, r) {
24
24
  return /* @__PURE__ */ i(s.Trigger, {
25
- ...r,
26
- className: t(e.comboboxTrigger, n),
27
- ref: a
25
+ ...n,
26
+ className: e("lyds-combobox__trigger", t),
27
+ ref: r
28
28
  });
29
- }), m = n(function({ className: n, ...r }, a) {
29
+ }), m = n(function({ className: t, ...n }, r) {
30
30
  return /* @__PURE__ */ i(s.Clear, {
31
- ...r,
32
- className: t(e.comboboxClear, n),
33
- ref: a
31
+ ...n,
32
+ className: e("lyds-combobox__clear", t),
33
+ ref: r
34
34
  });
35
- }), h = n(function({ className: n, ...r }, a) {
35
+ }), h = n(function({ className: t, ...n }, r) {
36
36
  return /* @__PURE__ */ i(s.Positioner, {
37
- ...r,
38
- className: t(e.positioner, n),
39
- ref: a
37
+ ...n,
38
+ className: e("lyds-listbox__positioner", t),
39
+ ref: r
40
40
  });
41
- }), g = n(function({ className: n, ...r }, a) {
41
+ }), g = n(function({ className: t, ...n }, r) {
42
42
  return /* @__PURE__ */ i(s.Popup, {
43
- ...r,
44
- className: t(e.popup, n),
45
- ref: a
43
+ ...n,
44
+ className: e("lyds-listbox__popup", t),
45
+ ref: r
46
46
  });
47
- }), _ = n(function({ className: n, ...r }, a) {
47
+ }), _ = n(function({ className: t, ...n }, r) {
48
48
  return /* @__PURE__ */ i(s.List, {
49
- ...r,
50
- className: t(e.optionList, n),
51
- ref: a
49
+ ...n,
50
+ className: e("lyds-listbox__list", t),
51
+ ref: r
52
52
  });
53
- }), v = n(function({ className: n, ...r }, a) {
53
+ }), v = n(function({ className: t, ...n }, r) {
54
54
  return /* @__PURE__ */ i(s.Item, {
55
- ...r,
56
- className: t(e.option, n),
57
- ref: a
55
+ ...n,
56
+ className: e("lyds-listbox__option", t),
57
+ ref: r
58
58
  });
59
- }), y = n(function({ className: n, ...r }, a) {
59
+ }), y = n(function({ className: t, ...n }, r) {
60
60
  return /* @__PURE__ */ i(s.ItemIndicator, {
61
- ...r,
62
- className: t(e.optionIndicator, n),
63
- ref: a
61
+ ...n,
62
+ className: e("lyds-listbox__option-indicator", t),
63
+ ref: r
64
64
  });
65
- }), b = n(function({ className: n, ...r }, a) {
65
+ }), b = n(function({ className: t, ...n }, r) {
66
66
  return /* @__PURE__ */ i(s.Empty, {
67
- ...r,
68
- className: t(e.emptyOption, n),
69
- ref: a
67
+ ...n,
68
+ className: e("lyds-listbox__empty", t),
69
+ ref: r
70
70
  });
71
71
  });
72
72
  function x(e) {
@@ -88,21 +88,21 @@ function x(e) {
88
88
  }
89
89
  };
90
90
  }
91
- function S({ "aria-describedby": t, "aria-label": n, "aria-labelledby": u, className: S, clearLabel: C = "清除選取", emptyMessage: w = "找不到符合的選項", inputProps: T, invalid: E = !1, itemToStringLabel: D, options: O, placeholder: k, popupProps: A, positionerProps: j, triggerLabel: M = "顯示選項", ...N }) {
92
- let P = r(() => x(O), [O]), F = r(() => D ?? ((e) => {
93
- let t = P.get(e)?.option;
91
+ function S({ "aria-describedby": e, "aria-label": n, "aria-labelledby": u, className: S, clearLabel: C, emptyMessage: w, inputProps: T, invalid: E = !1, itemToStringLabel: D, options: O, placeholder: k, popupProps: A, positionerProps: j, triggerLabel: M, ...N }) {
92
+ let P = t(), F = r(() => x(O), [O]), I = r(() => D ?? ((e) => {
93
+ let t = F.get(e)?.option;
94
94
  return t?.textValue ?? (typeof t?.label == "string" ? t.label : String(e));
95
- }), [D, P]);
95
+ }), [D, F]);
96
96
  return /* @__PURE__ */ a(s.Root, {
97
97
  ...N,
98
- itemToStringLabel: F,
99
- items: P.values,
98
+ itemToStringLabel: I,
99
+ items: F.values,
100
100
  children: [/* @__PURE__ */ a(d, {
101
101
  className: S,
102
102
  children: [
103
103
  /* @__PURE__ */ i(f, {
104
104
  ...T,
105
- "aria-describedby": t ?? T?.["aria-describedby"],
105
+ "aria-describedby": e ?? T?.["aria-describedby"],
106
106
  "aria-invalid": E || T?.["aria-invalid"] || void 0,
107
107
  "aria-label": n ?? T?.["aria-label"],
108
108
  "aria-labelledby": u ?? T?.["aria-labelledby"],
@@ -110,14 +110,14 @@ function S({ "aria-describedby": t, "aria-label": n, "aria-labelledby": u, class
110
110
  placeholder: k
111
111
  }),
112
112
  /* @__PURE__ */ i(m, {
113
- "aria-label": C,
113
+ "aria-label": C ?? P.comboboxClear,
114
114
  children: /* @__PURE__ */ i(o, {
115
115
  "aria-hidden": "true",
116
116
  weight: "bold"
117
117
  })
118
118
  }),
119
119
  /* @__PURE__ */ i(p, {
120
- "aria-label": M,
120
+ "aria-label": M ?? P.comboboxTrigger,
121
121
  children: /* @__PURE__ */ i(l, {
122
122
  "aria-hidden": "true",
123
123
  weight: "bold"
@@ -128,26 +128,26 @@ function S({ "aria-describedby": t, "aria-label": n, "aria-labelledby": u, class
128
128
  ...j,
129
129
  children: /* @__PURE__ */ a(g, {
130
130
  ...A,
131
- children: [/* @__PURE__ */ i(_, { children: (t, n) => {
132
- let r = P.get(t);
133
- if (!r) return null;
134
- let { option: o, sourceIndex: s } = r;
131
+ children: [/* @__PURE__ */ i(_, { children: (e, t) => {
132
+ let n = F.get(e);
133
+ if (!n) return null;
134
+ let { option: r, sourceIndex: o } = n;
135
135
  return /* @__PURE__ */ a(v, {
136
- disabled: o.disabled,
137
- index: n,
138
- value: t,
136
+ disabled: r.disabled,
137
+ index: t,
138
+ value: e,
139
139
  children: [/* @__PURE__ */ i(y, { children: /* @__PURE__ */ i(c, {
140
140
  "aria-hidden": "true",
141
141
  weight: "bold"
142
142
  }) }), /* @__PURE__ */ a("span", {
143
- className: e.optionText,
144
- children: [/* @__PURE__ */ i("span", { children: o.label }), o.description ? /* @__PURE__ */ i("span", {
145
- className: e.optionDescription,
146
- children: o.description
143
+ className: "lyds-listbox__option-text",
144
+ children: [/* @__PURE__ */ i("span", { children: r.label }), r.description ? /* @__PURE__ */ i("span", {
145
+ className: "lyds-listbox__option-description",
146
+ children: r.description
147
147
  }) : null]
148
148
  })]
149
- }, o.key ?? o.textValue ?? s);
150
- } }), /* @__PURE__ */ i(b, { children: w })]
149
+ }, r.key ?? r.textValue ?? o);
150
+ } }), /* @__PURE__ */ i(b, { children: w ?? P.comboboxEmpty })]
151
151
  })
152
152
  }) })]
153
153
  });
@@ -181,34 +181,34 @@ var C = Object.assign(S, {
181
181
  Value: s.Value,
182
182
  useFilter: s.useFilter,
183
183
  useFilteredItems: s.useFilteredItems
184
- }), w = n(function({ className: n, ...r }, a) {
184
+ }), w = n(function({ className: t, ...n }, r) {
185
185
  return /* @__PURE__ */ i(u.InputGroup, {
186
- ...r,
187
- className: t(e.comboboxInputGroup, n),
188
- ref: a
186
+ ...n,
187
+ className: e("lyds-combobox__input-group", t),
188
+ ref: r
189
189
  });
190
- }), T = n(function({ className: n, ...r }, a) {
190
+ }), T = n(function({ className: t, ...n }, r) {
191
191
  return /* @__PURE__ */ i(u.Item, {
192
- ...r,
193
- className: t(e.option, n),
194
- ref: a
192
+ ...n,
193
+ className: e("lyds-listbox__option", t),
194
+ ref: r
195
195
  });
196
196
  });
197
- function E({ "aria-describedby": t, "aria-label": n, "aria-labelledby": s, className: c, clearLabel: d = "清除搜尋內容", emptyMessage: p = "找不到建議項目", inputProps: v, invalid: y = !1, itemToStringValue: S, options: C, placeholder: E, popupProps: D, positionerProps: O, triggerLabel: k = "顯示建議項目", ...A }) {
198
- let j = r(() => x(C), [C]), M = r(() => S ?? ((e) => {
199
- let t = j.get(e)?.option;
197
+ function E({ "aria-describedby": e, "aria-label": n, "aria-labelledby": s, className: c, clearLabel: d, emptyMessage: p, inputProps: v, invalid: y = !1, itemToStringValue: S, options: C, placeholder: E, popupProps: D, positionerProps: O, triggerLabel: k, ...A }) {
198
+ let j = t(), M = r(() => x(C), [C]), N = r(() => S ?? ((e) => {
199
+ let t = M.get(e)?.option;
200
200
  return t?.textValue ?? (typeof t?.label == "string" ? t.label : String(e));
201
- }), [S, j]);
201
+ }), [S, M]);
202
202
  return /* @__PURE__ */ a(u.Root, {
203
203
  ...A,
204
- itemToStringValue: M,
205
- items: j.values,
204
+ itemToStringValue: N,
205
+ items: M.values,
206
206
  children: [/* @__PURE__ */ a(w, {
207
207
  className: c,
208
208
  children: [
209
209
  /* @__PURE__ */ i(f, {
210
210
  ...v,
211
- "aria-describedby": t ?? v?.["aria-describedby"],
211
+ "aria-describedby": e ?? v?.["aria-describedby"],
212
212
  "aria-invalid": y || v?.["aria-invalid"] || void 0,
213
213
  "aria-label": n ?? v?.["aria-label"],
214
214
  "aria-labelledby": s ?? v?.["aria-labelledby"],
@@ -216,15 +216,15 @@ function E({ "aria-describedby": t, "aria-label": n, "aria-labelledby": s, class
216
216
  placeholder: E
217
217
  }),
218
218
  /* @__PURE__ */ i(m, {
219
- "aria-label": d,
219
+ "aria-label": d ?? j.autocompleteClear,
220
220
  children: /* @__PURE__ */ i(o, {
221
221
  "aria-hidden": "true",
222
222
  weight: "bold"
223
223
  })
224
224
  }),
225
225
  /* @__PURE__ */ i(u.Trigger, {
226
- "aria-label": k,
227
- className: e.comboboxTrigger,
226
+ "aria-label": k ?? j.autocompleteTrigger,
227
+ className: "lyds-combobox__trigger",
228
228
  children: /* @__PURE__ */ i(l, {
229
229
  "aria-hidden": "true",
230
230
  weight: "bold"
@@ -235,20 +235,20 @@ function E({ "aria-describedby": t, "aria-label": n, "aria-labelledby": s, class
235
235
  ...O,
236
236
  children: /* @__PURE__ */ a(g, {
237
237
  ...D,
238
- children: [/* @__PURE__ */ i(_, { children: (t, n) => {
239
- let r = j.get(t);
240
- if (!r) return null;
241
- let { option: a, sourceIndex: o } = r;
238
+ children: [/* @__PURE__ */ i(_, { children: (e, t) => {
239
+ let n = M.get(e);
240
+ if (!n) return null;
241
+ let { option: r, sourceIndex: a } = n;
242
242
  return /* @__PURE__ */ i(T, {
243
- disabled: a.disabled,
244
- index: n,
245
- value: t,
243
+ disabled: r.disabled,
244
+ index: t,
245
+ value: e,
246
246
  children: /* @__PURE__ */ i("span", {
247
- className: e.optionText,
248
- children: a.label
247
+ className: "lyds-listbox__option-text",
248
+ children: r.label
249
249
  })
250
- }, a.key ?? a.textValue ?? o);
251
- } }), /* @__PURE__ */ i(b, { children: p })]
250
+ }, r.key ?? r.textValue ?? a);
251
+ } }), /* @__PURE__ */ i(b, { children: p ?? j.autocompleteEmpty })]
252
252
  })
253
253
  }) })]
254
254
  });
@@ -1 +1 @@
1
- {"version":3,"file":"combobox.js","names":[],"sources":["../../../src/components/selection/combobox.tsx"],"sourcesContent":["import { Autocomplete as BaseAutocomplete, type AutocompleteInputGroupProps, type AutocompleteItemProps, type AutocompleteRootProps } from \"@base-ui/react/autocomplete\";\nimport {\n\tCombobox as BaseCombobox,\n\ttype ComboboxClearProps,\n\ttype ComboboxEmptyProps,\n\ttype ComboboxInputGroupProps,\n\ttype ComboboxInputProps,\n\ttype ComboboxItemIndicatorProps,\n\ttype ComboboxItemProps,\n\ttype ComboboxListProps,\n\ttype ComboboxPopupProps,\n\ttype ComboboxPositionerProps,\n\ttype ComboboxRootProps,\n\ttype ComboboxTriggerProps\n} from \"@base-ui/react/combobox\";\nimport { CaretDownIcon } from \"@phosphor-icons/react/dist/csr/CaretDown\";\nimport { CheckIcon } from \"@phosphor-icons/react/dist/csr/Check\";\nimport { XIcon } from \"@phosphor-icons/react/dist/csr/X\";\nimport { forwardRef, useMemo, type Key, type ReactNode } from \"react\";\n\nimport { mergeStateClassName } from \"./classnames\";\nimport styles from \"./selection.module.css\";\n\nexport const ComboboxInputGroup = forwardRef<HTMLDivElement, ComboboxInputGroupProps>(function ComboboxInputGroup({ className, ...props }, ref) {\n\treturn <BaseCombobox.InputGroup {...props} className={mergeStateClassName(styles.comboboxInputGroup, className)} ref={ref} />;\n});\n\nexport const ComboboxInput = forwardRef<HTMLInputElement, ComboboxInputProps>(function ComboboxInput({ className, ...props }, ref) {\n\treturn <BaseCombobox.Input {...props} className={mergeStateClassName(styles.comboboxInput, className)} ref={ref} />;\n});\n\nexport const ComboboxTrigger = forwardRef<HTMLButtonElement, ComboboxTriggerProps>(function ComboboxTrigger({ className, ...props }, ref) {\n\treturn <BaseCombobox.Trigger {...props} className={mergeStateClassName(styles.comboboxTrigger, className)} ref={ref} />;\n});\n\nexport const ComboboxClear = forwardRef<HTMLButtonElement, ComboboxClearProps>(function ComboboxClear({ className, ...props }, ref) {\n\treturn <BaseCombobox.Clear {...props} className={mergeStateClassName(styles.comboboxClear, className)} ref={ref} />;\n});\n\nexport const ComboboxPositioner = forwardRef<HTMLDivElement, ComboboxPositionerProps>(function ComboboxPositioner({ className, ...props }, ref) {\n\treturn <BaseCombobox.Positioner {...props} className={mergeStateClassName(styles.positioner, className)} ref={ref} />;\n});\n\nexport const ComboboxPopup = forwardRef<HTMLDivElement, ComboboxPopupProps>(function ComboboxPopup({ className, ...props }, ref) {\n\treturn <BaseCombobox.Popup {...props} className={mergeStateClassName(styles.popup, className)} ref={ref} />;\n});\n\nexport const ComboboxList = forwardRef<HTMLDivElement, ComboboxListProps>(function ComboboxList({ className, ...props }, ref) {\n\treturn <BaseCombobox.List {...props} className={mergeStateClassName(styles.optionList, className)} ref={ref} />;\n});\n\nexport const ComboboxItem = forwardRef<HTMLDivElement, ComboboxItemProps>(function ComboboxItem({ className, ...props }, ref) {\n\treturn <BaseCombobox.Item {...props} className={mergeStateClassName(styles.option, className)} ref={ref} />;\n});\n\nexport const ComboboxItemIndicator = forwardRef<HTMLSpanElement, ComboboxItemIndicatorProps>(function ComboboxItemIndicator({ className, ...props }, ref) {\n\treturn <BaseCombobox.ItemIndicator {...props} className={mergeStateClassName(styles.optionIndicator, className)} ref={ref} />;\n});\n\nexport const ComboboxEmpty = forwardRef<HTMLDivElement, ComboboxEmptyProps>(function ComboboxEmpty({ className, ...props }, ref) {\n\treturn <BaseCombobox.Empty {...props} className={mergeStateClassName(styles.emptyOption, className)} ref={ref} />;\n});\n\nexport interface ComboboxOption<Value> {\n\tdescription?: ReactNode;\n\tdisabled?: boolean;\n\tkey?: Key;\n\tlabel: ReactNode;\n\ttextValue?: string;\n\tvalue: Value;\n}\n\ninterface IndexedOption<Option> {\n\toption: Option;\n\tsourceIndex: number;\n}\n\nfunction createOptionIndex<Value, Option extends { value: Value }>(options: readonly Option[]) {\n\tconst values: Value[] = [];\n\tconst lookup = new Map<Value, IndexedOption<Option>>();\n\tlet negativeZero: IndexedOption<Option> | undefined;\n\tlet positiveZero: IndexedOption<Option> | undefined;\n\n\toptions.forEach((option, sourceIndex) => {\n\t\tconst value = option.value;\n\t\tconst indexed = { option, sourceIndex };\n\t\tvalues.push(value);\n\n\t\tif (typeof value === \"number\" && value === 0) {\n\t\t\tif (Object.is(value, -0)) negativeZero ??= indexed;\n\t\t\telse positiveZero ??= indexed;\n\t\t\treturn;\n\t\t}\n\n\t\tif (!lookup.has(value)) lookup.set(value, indexed);\n\t});\n\n\treturn {\n\t\tvalues,\n\t\tget(value: Value) {\n\t\t\tif (typeof value === \"number\" && value === 0) {\n\t\t\t\treturn Object.is(value, -0) ? negativeZero : positiveZero;\n\t\t\t}\n\t\t\treturn lookup.get(value);\n\t\t}\n\t};\n}\n\nexport interface ComboboxProps<Value> extends Omit<ComboboxRootProps<Value, false>, \"children\" | \"items\" | \"multiple\"> {\n\t\"aria-describedby\"?: string;\n\t\"aria-label\"?: string;\n\t\"aria-labelledby\"?: string;\n\tclassName?: string;\n\tclearLabel?: string;\n\temptyMessage?: ReactNode;\n\tinputProps?: Omit<ComboboxInputProps, \"className\" | \"placeholder\">;\n\tinvalid?: boolean;\n\toptions: readonly ComboboxOption<Value>[];\n\tplaceholder?: string;\n\tpopupProps?: ComboboxPopupProps;\n\tpositionerProps?: ComboboxPositionerProps;\n\ttriggerLabel?: string;\n}\n\nfunction ComboboxComponent<Value>({\n\t\"aria-describedby\": ariaDescribedby,\n\t\"aria-label\": ariaLabel,\n\t\"aria-labelledby\": ariaLabelledby,\n\tclassName,\n\tclearLabel = \"清除選取\",\n\temptyMessage = \"找不到符合的選項\",\n\tinputProps,\n\tinvalid = false,\n\titemToStringLabel,\n\toptions,\n\tplaceholder,\n\tpopupProps,\n\tpositionerProps,\n\ttriggerLabel = \"顯示選項\",\n\t...rootProps\n}: ComboboxProps<Value>) {\n\tconst optionIndex = useMemo(() => createOptionIndex<Value, ComboboxOption<Value>>(options), [options]);\n\tconst stringify = useMemo(\n\t\t() =>\n\t\t\titemToStringLabel ??\n\t\t\t((itemValue: Value) => {\n\t\t\t\tconst option = optionIndex.get(itemValue)?.option;\n\t\t\t\treturn option?.textValue ?? (typeof option?.label === \"string\" ? option.label : String(itemValue));\n\t\t\t}),\n\t\t[itemToStringLabel, optionIndex]\n\t);\n\n\treturn (\n\t\t<BaseCombobox.Root {...rootProps} itemToStringLabel={stringify} items={optionIndex.values}>\n\t\t\t<ComboboxInputGroup className={className}>\n\t\t\t\t<ComboboxInput\n\t\t\t\t\t{...inputProps}\n\t\t\t\t\taria-describedby={ariaDescribedby ?? inputProps?.[\"aria-describedby\"]}\n\t\t\t\t\taria-invalid={invalid || inputProps?.[\"aria-invalid\"] || undefined}\n\t\t\t\t\taria-label={ariaLabel ?? inputProps?.[\"aria-label\"]}\n\t\t\t\t\taria-labelledby={ariaLabelledby ?? inputProps?.[\"aria-labelledby\"]}\n\t\t\t\t\tautoComplete={inputProps?.autoComplete ?? \"off\"}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t/>\n\t\t\t\t<ComboboxClear aria-label={clearLabel}>\n\t\t\t\t\t<XIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t\t</ComboboxClear>\n\t\t\t\t<ComboboxTrigger aria-label={triggerLabel}>\n\t\t\t\t\t<CaretDownIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t\t</ComboboxTrigger>\n\t\t\t</ComboboxInputGroup>\n\t\t\t<BaseCombobox.Portal>\n\t\t\t\t<ComboboxPositioner {...positionerProps}>\n\t\t\t\t\t<ComboboxPopup {...popupProps}>\n\t\t\t\t\t\t<ComboboxList>\n\t\t\t\t\t\t\t{(value: Value, index: number) => {\n\t\t\t\t\t\t\t\tconst indexed = optionIndex.get(value);\n\t\t\t\t\t\t\t\tif (!indexed) return null;\n\t\t\t\t\t\t\t\tconst { option, sourceIndex } = indexed;\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<ComboboxItem disabled={option.disabled} index={index} key={option.key ?? option.textValue ?? sourceIndex} value={value}>\n\t\t\t\t\t\t\t\t\t\t<ComboboxItemIndicator>\n\t\t\t\t\t\t\t\t\t\t\t<CheckIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t\t\t\t\t\t\t\t</ComboboxItemIndicator>\n\t\t\t\t\t\t\t\t\t\t<span className={styles.optionText}>\n\t\t\t\t\t\t\t\t\t\t\t<span>{option.label}</span>\n\t\t\t\t\t\t\t\t\t\t\t{option.description ? <span className={styles.optionDescription}>{option.description}</span> : null}\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</ComboboxItem>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t</ComboboxList>\n\t\t\t\t\t\t<ComboboxEmpty>{emptyMessage}</ComboboxEmpty>\n\t\t\t\t\t</ComboboxPopup>\n\t\t\t\t</ComboboxPositioner>\n\t\t\t</BaseCombobox.Portal>\n\t\t</BaseCombobox.Root>\n\t);\n}\n\nexport const Combobox = Object.assign(ComboboxComponent, {\n\tArrow: BaseCombobox.Arrow,\n\tBackdrop: BaseCombobox.Backdrop,\n\tChip: BaseCombobox.Chip,\n\tChipRemove: BaseCombobox.ChipRemove,\n\tChips: BaseCombobox.Chips,\n\tClear: ComboboxClear,\n\tCollection: BaseCombobox.Collection,\n\tEmpty: ComboboxEmpty,\n\tGroup: BaseCombobox.Group,\n\tGroupLabel: BaseCombobox.GroupLabel,\n\tIcon: BaseCombobox.Icon,\n\tInput: ComboboxInput,\n\tInputGroup: ComboboxInputGroup,\n\tItem: ComboboxItem,\n\tItemIndicator: ComboboxItemIndicator,\n\tLabel: BaseCombobox.Label,\n\tList: ComboboxList,\n\tPopup: ComboboxPopup,\n\tPortal: BaseCombobox.Portal,\n\tPositioner: ComboboxPositioner,\n\tRoot: BaseCombobox.Root,\n\tRow: BaseCombobox.Row,\n\tSeparator: BaseCombobox.Separator,\n\tStatus: BaseCombobox.Status,\n\tTrigger: ComboboxTrigger,\n\tValue: BaseCombobox.Value,\n\tuseFilter: BaseCombobox.useFilter,\n\tuseFilteredItems: BaseCombobox.useFilteredItems\n});\n\nexport const AutocompleteInputGroup = forwardRef<HTMLDivElement, AutocompleteInputGroupProps>(function AutocompleteInputGroup({ className, ...props }, ref) {\n\treturn <BaseAutocomplete.InputGroup {...props} className={mergeStateClassName(styles.comboboxInputGroup, className)} ref={ref} />;\n});\n\nexport const AutocompleteItem = forwardRef<HTMLDivElement, AutocompleteItemProps>(function AutocompleteItem({ className, ...props }, ref) {\n\treturn <BaseAutocomplete.Item {...props} className={mergeStateClassName(styles.option, className)} ref={ref} />;\n});\n\nexport interface AutocompleteOption<Value> {\n\tdisabled?: boolean;\n\tkey?: Key;\n\tlabel: ReactNode;\n\ttextValue?: string;\n\tvalue: Value;\n}\n\nexport interface AutocompleteProps<ItemValue> extends Omit<AutocompleteRootProps<ItemValue>, \"children\" | \"items\"> {\n\t\"aria-describedby\"?: string;\n\t\"aria-label\"?: string;\n\t\"aria-labelledby\"?: string;\n\tclassName?: string;\n\tclearLabel?: string;\n\temptyMessage?: ReactNode;\n\tinputProps?: Omit<ComboboxInputProps, \"className\" | \"placeholder\">;\n\tinvalid?: boolean;\n\toptions: readonly AutocompleteOption<ItemValue>[];\n\tplaceholder?: string;\n\tpopupProps?: ComboboxPopupProps;\n\tpositionerProps?: ComboboxPositionerProps;\n\ttriggerLabel?: string;\n}\n\nfunction AutocompleteComponent<ItemValue>({\n\t\"aria-describedby\": ariaDescribedby,\n\t\"aria-label\": ariaLabel,\n\t\"aria-labelledby\": ariaLabelledby,\n\tclassName,\n\tclearLabel = \"清除搜尋內容\",\n\temptyMessage = \"找不到建議項目\",\n\tinputProps,\n\tinvalid = false,\n\titemToStringValue,\n\toptions,\n\tplaceholder,\n\tpopupProps,\n\tpositionerProps,\n\ttriggerLabel = \"顯示建議項目\",\n\t...rootProps\n}: AutocompleteProps<ItemValue>) {\n\tconst optionIndex = useMemo(() => createOptionIndex<ItemValue, AutocompleteOption<ItemValue>>(options), [options]);\n\tconst stringify = useMemo(\n\t\t() =>\n\t\t\titemToStringValue ??\n\t\t\t((itemValue: ItemValue) => {\n\t\t\t\tconst option = optionIndex.get(itemValue)?.option;\n\t\t\t\treturn option?.textValue ?? (typeof option?.label === \"string\" ? option.label : String(itemValue));\n\t\t\t}),\n\t\t[itemToStringValue, optionIndex]\n\t);\n\n\treturn (\n\t\t<BaseAutocomplete.Root {...rootProps} itemToStringValue={stringify} items={optionIndex.values}>\n\t\t\t<AutocompleteInputGroup className={className}>\n\t\t\t\t<ComboboxInput\n\t\t\t\t\t{...inputProps}\n\t\t\t\t\taria-describedby={ariaDescribedby ?? inputProps?.[\"aria-describedby\"]}\n\t\t\t\t\taria-invalid={invalid || inputProps?.[\"aria-invalid\"] || undefined}\n\t\t\t\t\taria-label={ariaLabel ?? inputProps?.[\"aria-label\"]}\n\t\t\t\t\taria-labelledby={ariaLabelledby ?? inputProps?.[\"aria-labelledby\"]}\n\t\t\t\t\tautoComplete={inputProps?.autoComplete ?? \"off\"}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t/>\n\t\t\t\t<ComboboxClear aria-label={clearLabel}>\n\t\t\t\t\t<XIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t\t</ComboboxClear>\n\t\t\t\t<BaseAutocomplete.Trigger aria-label={triggerLabel} className={styles.comboboxTrigger}>\n\t\t\t\t\t<CaretDownIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t\t</BaseAutocomplete.Trigger>\n\t\t\t</AutocompleteInputGroup>\n\t\t\t<BaseAutocomplete.Portal>\n\t\t\t\t<ComboboxPositioner {...positionerProps}>\n\t\t\t\t\t<ComboboxPopup {...popupProps}>\n\t\t\t\t\t\t<ComboboxList>\n\t\t\t\t\t\t\t{(value: ItemValue, index: number) => {\n\t\t\t\t\t\t\t\tconst indexed = optionIndex.get(value);\n\t\t\t\t\t\t\t\tif (!indexed) return null;\n\t\t\t\t\t\t\t\tconst { option, sourceIndex } = indexed;\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<AutocompleteItem disabled={option.disabled} index={index} key={option.key ?? option.textValue ?? sourceIndex} value={value}>\n\t\t\t\t\t\t\t\t\t\t<span className={styles.optionText}>{option.label}</span>\n\t\t\t\t\t\t\t\t\t</AutocompleteItem>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t</ComboboxList>\n\t\t\t\t\t\t<ComboboxEmpty>{emptyMessage}</ComboboxEmpty>\n\t\t\t\t\t</ComboboxPopup>\n\t\t\t\t</ComboboxPositioner>\n\t\t\t</BaseAutocomplete.Portal>\n\t\t</BaseAutocomplete.Root>\n\t);\n}\n\nexport const Autocomplete = Object.assign(AutocompleteComponent, {\n\tArrow: BaseAutocomplete.Arrow,\n\tBackdrop: BaseAutocomplete.Backdrop,\n\tClear: ComboboxClear,\n\tCollection: BaseAutocomplete.Collection,\n\tEmpty: ComboboxEmpty,\n\tGroup: BaseAutocomplete.Group,\n\tGroupLabel: BaseAutocomplete.GroupLabel,\n\tIcon: BaseAutocomplete.Icon,\n\tInput: ComboboxInput,\n\tInputGroup: AutocompleteInputGroup,\n\tItem: AutocompleteItem,\n\tList: ComboboxList,\n\tPopup: ComboboxPopup,\n\tPortal: BaseAutocomplete.Portal,\n\tPositioner: ComboboxPositioner,\n\tRoot: BaseAutocomplete.Root,\n\tRow: BaseAutocomplete.Row,\n\tSeparator: BaseAutocomplete.Separator,\n\tStatus: BaseAutocomplete.Status,\n\tTrigger: BaseAutocomplete.Trigger,\n\tValue: BaseAutocomplete.Value,\n\tuseFilter: BaseAutocomplete.useFilter,\n\tuseFilteredItems: BaseAutocomplete.useFilteredItems\n});\n"],"mappings":";;;;;;;;;;AAuBA,IAAa,IAAqB,EAAoD,SAA4B,EAAE,cAAW,GAAG,KAAS,GAAK;CAC/I,OAAO,kBAAC,EAAa,YAAd;EAAyB,GAAI;EAAO,WAAW,EAAoB,EAAO,oBAAoB,CAAS;EAAQ;CAAM,CAAA;AAC7H,CAAC,GAEY,IAAgB,EAAiD,SAAuB,EAAE,cAAW,GAAG,KAAS,GAAK;CAClI,OAAO,kBAAC,EAAa,OAAd;EAAoB,GAAI;EAAO,WAAW,EAAoB,EAAO,eAAe,CAAS;EAAQ;CAAM,CAAA;AACnH,CAAC,GAEY,IAAkB,EAAoD,SAAyB,EAAE,cAAW,GAAG,KAAS,GAAK;CACzI,OAAO,kBAAC,EAAa,SAAd;EAAsB,GAAI;EAAO,WAAW,EAAoB,EAAO,iBAAiB,CAAS;EAAQ;CAAM,CAAA;AACvH,CAAC,GAEY,IAAgB,EAAkD,SAAuB,EAA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B,WAAW,EAAiB;CAC5B,QAAQ,EAAiB;CACzB,SAAS,EAAiB;CAC1B,OAAO,EAAiB;CACxB,WAAW,EAAiB;CAC5B,kBAAkB,EAAiB;AACpC,CAAC"}
1
+ {"version":3,"file":"combobox.js","names":[],"sources":["../../../src/components/selection/combobox.tsx"],"sourcesContent":["import { Autocomplete as BaseAutocomplete, type AutocompleteInputGroupProps, type AutocompleteItemProps, type AutocompleteRootProps } from \"@base-ui/react/autocomplete\";\nimport {\n\tCombobox as BaseCombobox,\n\ttype ComboboxClearProps,\n\ttype ComboboxEmptyProps,\n\ttype ComboboxInputGroupProps,\n\ttype ComboboxInputProps,\n\ttype ComboboxItemIndicatorProps,\n\ttype ComboboxItemProps,\n\ttype ComboboxListProps,\n\ttype ComboboxPopupProps,\n\ttype ComboboxPositionerProps,\n\ttype ComboboxRootProps,\n\ttype ComboboxTriggerProps\n} from \"@base-ui/react/combobox\";\nimport { CaretDownIcon } from \"@phosphor-icons/react/dist/csr/CaretDown\";\nimport { CheckIcon } from \"@phosphor-icons/react/dist/csr/Check\";\nimport { XIcon } from \"@phosphor-icons/react/dist/csr/X\";\nimport { forwardRef, useMemo, type Key, type ReactNode } from \"react\";\n\nimport { withStateClassName } from \"@/internal\";\nimport { useMessages } from \"@/intl\";\n\nexport const ComboboxInputGroup = forwardRef<HTMLDivElement, ComboboxInputGroupProps>(function ComboboxInputGroup({ className, ...props }, ref) {\n\treturn <BaseCombobox.InputGroup {...props} className={withStateClassName(\"lyds-combobox__input-group\", className)} ref={ref} />;\n});\n\nexport const ComboboxInput = forwardRef<HTMLInputElement, ComboboxInputProps>(function ComboboxInput({ className, ...props }, ref) {\n\treturn <BaseCombobox.Input {...props} className={withStateClassName(\"lyds-combobox__input\", className)} ref={ref} />;\n});\n\nexport const ComboboxTrigger = forwardRef<HTMLButtonElement, ComboboxTriggerProps>(function ComboboxTrigger({ className, ...props }, ref) {\n\treturn <BaseCombobox.Trigger {...props} className={withStateClassName(\"lyds-combobox__trigger\", className)} ref={ref} />;\n});\n\nexport const ComboboxClear = forwardRef<HTMLButtonElement, ComboboxClearProps>(function ComboboxClear({ className, ...props }, ref) {\n\treturn <BaseCombobox.Clear {...props} className={withStateClassName(\"lyds-combobox__clear\", className)} ref={ref} />;\n});\n\nexport const ComboboxPositioner = forwardRef<HTMLDivElement, ComboboxPositionerProps>(function ComboboxPositioner({ className, ...props }, ref) {\n\treturn <BaseCombobox.Positioner {...props} className={withStateClassName(\"lyds-listbox__positioner\", className)} ref={ref} />;\n});\n\nexport const ComboboxPopup = forwardRef<HTMLDivElement, ComboboxPopupProps>(function ComboboxPopup({ className, ...props }, ref) {\n\treturn <BaseCombobox.Popup {...props} className={withStateClassName(\"lyds-listbox__popup\", className)} ref={ref} />;\n});\n\nexport const ComboboxList = forwardRef<HTMLDivElement, ComboboxListProps>(function ComboboxList({ className, ...props }, ref) {\n\treturn <BaseCombobox.List {...props} className={withStateClassName(\"lyds-listbox__list\", className)} ref={ref} />;\n});\n\nexport const ComboboxItem = forwardRef<HTMLDivElement, ComboboxItemProps>(function ComboboxItem({ className, ...props }, ref) {\n\treturn <BaseCombobox.Item {...props} className={withStateClassName(\"lyds-listbox__option\", className)} ref={ref} />;\n});\n\nexport const ComboboxItemIndicator = forwardRef<HTMLSpanElement, ComboboxItemIndicatorProps>(function ComboboxItemIndicator({ className, ...props }, ref) {\n\treturn <BaseCombobox.ItemIndicator {...props} className={withStateClassName(\"lyds-listbox__option-indicator\", className)} ref={ref} />;\n});\n\nexport const ComboboxEmpty = forwardRef<HTMLDivElement, ComboboxEmptyProps>(function ComboboxEmpty({ className, ...props }, ref) {\n\treturn <BaseCombobox.Empty {...props} className={withStateClassName(\"lyds-listbox__empty\", className)} ref={ref} />;\n});\n\nexport interface ComboboxOption<Value> {\n\tdescription?: ReactNode;\n\tdisabled?: boolean;\n\tkey?: Key;\n\tlabel: ReactNode;\n\ttextValue?: string;\n\tvalue: Value;\n}\n\ninterface IndexedOption<Option> {\n\toption: Option;\n\tsourceIndex: number;\n}\n\nfunction createOptionIndex<Value, Option extends { value: Value }>(options: readonly Option[]) {\n\tconst values: Value[] = [];\n\tconst lookup = new Map<Value, IndexedOption<Option>>();\n\tlet negativeZero: IndexedOption<Option> | undefined;\n\tlet positiveZero: IndexedOption<Option> | undefined;\n\n\toptions.forEach((option, sourceIndex) => {\n\t\tconst value = option.value;\n\t\tconst indexed = { option, sourceIndex };\n\t\tvalues.push(value);\n\n\t\tif (typeof value === \"number\" && value === 0) {\n\t\t\tif (Object.is(value, -0)) negativeZero ??= indexed;\n\t\t\telse positiveZero ??= indexed;\n\t\t\treturn;\n\t\t}\n\n\t\tif (!lookup.has(value)) lookup.set(value, indexed);\n\t});\n\n\treturn {\n\t\tvalues,\n\t\tget(value: Value) {\n\t\t\tif (typeof value === \"number\" && value === 0) {\n\t\t\t\treturn Object.is(value, -0) ? negativeZero : positiveZero;\n\t\t\t}\n\t\t\treturn lookup.get(value);\n\t\t}\n\t};\n}\n\nexport interface ComboboxProps<Value> extends Omit<ComboboxRootProps<Value, false>, \"children\" | \"items\" | \"multiple\"> {\n\t\"aria-describedby\"?: string;\n\t\"aria-label\"?: string;\n\t\"aria-labelledby\"?: string;\n\tclassName?: string;\n\tclearLabel?: string;\n\temptyMessage?: ReactNode;\n\tinputProps?: Omit<ComboboxInputProps, \"className\" | \"placeholder\">;\n\tinvalid?: boolean;\n\toptions: readonly ComboboxOption<Value>[];\n\tplaceholder?: string;\n\tpopupProps?: ComboboxPopupProps;\n\tpositionerProps?: ComboboxPositionerProps;\n\ttriggerLabel?: string;\n}\n\nfunction ComboboxComponent<Value>({\n\t\"aria-describedby\": ariaDescribedby,\n\t\"aria-label\": ariaLabel,\n\t\"aria-labelledby\": ariaLabelledby,\n\tclassName,\n\tclearLabel,\n\temptyMessage,\n\tinputProps,\n\tinvalid = false,\n\titemToStringLabel,\n\toptions,\n\tplaceholder,\n\tpopupProps,\n\tpositionerProps,\n\ttriggerLabel,\n\t...rootProps\n}: ComboboxProps<Value>) {\n\tconst messages = useMessages();\n\tconst optionIndex = useMemo(() => createOptionIndex<Value, ComboboxOption<Value>>(options), [options]);\n\tconst stringify = useMemo(\n\t\t() =>\n\t\t\titemToStringLabel ??\n\t\t\t((itemValue: Value) => {\n\t\t\t\tconst option = optionIndex.get(itemValue)?.option;\n\t\t\t\treturn option?.textValue ?? (typeof option?.label === \"string\" ? option.label : String(itemValue));\n\t\t\t}),\n\t\t[itemToStringLabel, optionIndex]\n\t);\n\n\treturn (\n\t\t<BaseCombobox.Root {...rootProps} itemToStringLabel={stringify} items={optionIndex.values}>\n\t\t\t<ComboboxInputGroup className={className}>\n\t\t\t\t<ComboboxInput\n\t\t\t\t\t{...inputProps}\n\t\t\t\t\taria-describedby={ariaDescribedby ?? inputProps?.[\"aria-describedby\"]}\n\t\t\t\t\taria-invalid={invalid || inputProps?.[\"aria-invalid\"] || undefined}\n\t\t\t\t\taria-label={ariaLabel ?? inputProps?.[\"aria-label\"]}\n\t\t\t\t\taria-labelledby={ariaLabelledby ?? inputProps?.[\"aria-labelledby\"]}\n\t\t\t\t\tautoComplete={inputProps?.autoComplete ?? \"off\"}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t/>\n\t\t\t\t<ComboboxClear aria-label={clearLabel ?? messages.comboboxClear}>\n\t\t\t\t\t<XIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t\t</ComboboxClear>\n\t\t\t\t<ComboboxTrigger aria-label={triggerLabel ?? messages.comboboxTrigger}>\n\t\t\t\t\t<CaretDownIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t\t</ComboboxTrigger>\n\t\t\t</ComboboxInputGroup>\n\t\t\t<BaseCombobox.Portal>\n\t\t\t\t<ComboboxPositioner {...positionerProps}>\n\t\t\t\t\t<ComboboxPopup {...popupProps}>\n\t\t\t\t\t\t<ComboboxList>\n\t\t\t\t\t\t\t{(value: Value, index: number) => {\n\t\t\t\t\t\t\t\tconst indexed = optionIndex.get(value);\n\t\t\t\t\t\t\t\tif (!indexed) return null;\n\t\t\t\t\t\t\t\tconst { option, sourceIndex } = indexed;\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<ComboboxItem disabled={option.disabled} index={index} key={option.key ?? option.textValue ?? sourceIndex} value={value}>\n\t\t\t\t\t\t\t\t\t\t<ComboboxItemIndicator>\n\t\t\t\t\t\t\t\t\t\t\t<CheckIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t\t\t\t\t\t\t\t</ComboboxItemIndicator>\n\t\t\t\t\t\t\t\t\t\t<span className={\"lyds-listbox__option-text\"}>\n\t\t\t\t\t\t\t\t\t\t\t<span>{option.label}</span>\n\t\t\t\t\t\t\t\t\t\t\t{option.description ? <span className={\"lyds-listbox__option-description\"}>{option.description}</span> : null}\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</ComboboxItem>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t</ComboboxList>\n\t\t\t\t\t\t<ComboboxEmpty>{emptyMessage ?? messages.comboboxEmpty}</ComboboxEmpty>\n\t\t\t\t\t</ComboboxPopup>\n\t\t\t\t</ComboboxPositioner>\n\t\t\t</BaseCombobox.Portal>\n\t\t</BaseCombobox.Root>\n\t);\n}\n\nexport const Combobox = Object.assign(ComboboxComponent, {\n\tArrow: BaseCombobox.Arrow,\n\tBackdrop: BaseCombobox.Backdrop,\n\tChip: BaseCombobox.Chip,\n\tChipRemove: BaseCombobox.ChipRemove,\n\tChips: BaseCombobox.Chips,\n\tClear: ComboboxClear,\n\tCollection: BaseCombobox.Collection,\n\tEmpty: ComboboxEmpty,\n\tGroup: BaseCombobox.Group,\n\tGroupLabel: BaseCombobox.GroupLabel,\n\tIcon: BaseCombobox.Icon,\n\tInput: ComboboxInput,\n\tInputGroup: ComboboxInputGroup,\n\tItem: ComboboxItem,\n\tItemIndicator: ComboboxItemIndicator,\n\tLabel: BaseCombobox.Label,\n\tList: ComboboxList,\n\tPopup: ComboboxPopup,\n\tPortal: BaseCombobox.Portal,\n\tPositioner: ComboboxPositioner,\n\tRoot: BaseCombobox.Root,\n\tRow: BaseCombobox.Row,\n\tSeparator: BaseCombobox.Separator,\n\tStatus: BaseCombobox.Status,\n\tTrigger: ComboboxTrigger,\n\tValue: BaseCombobox.Value,\n\tuseFilter: BaseCombobox.useFilter,\n\tuseFilteredItems: BaseCombobox.useFilteredItems\n});\n\nexport const AutocompleteInputGroup = forwardRef<HTMLDivElement, AutocompleteInputGroupProps>(function AutocompleteInputGroup({ className, ...props }, ref) {\n\treturn <BaseAutocomplete.InputGroup {...props} className={withStateClassName(\"lyds-combobox__input-group\", className)} ref={ref} />;\n});\n\nexport const AutocompleteItem = forwardRef<HTMLDivElement, AutocompleteItemProps>(function AutocompleteItem({ className, ...props }, ref) {\n\treturn <BaseAutocomplete.Item {...props} className={withStateClassName(\"lyds-listbox__option\", className)} ref={ref} />;\n});\n\nexport interface AutocompleteOption<Value> {\n\tdisabled?: boolean;\n\tkey?: Key;\n\tlabel: ReactNode;\n\ttextValue?: string;\n\tvalue: Value;\n}\n\nexport interface AutocompleteProps<ItemValue> extends Omit<AutocompleteRootProps<ItemValue>, \"children\" | \"items\"> {\n\t\"aria-describedby\"?: string;\n\t\"aria-label\"?: string;\n\t\"aria-labelledby\"?: string;\n\tclassName?: string;\n\tclearLabel?: string;\n\temptyMessage?: ReactNode;\n\tinputProps?: Omit<ComboboxInputProps, \"className\" | \"placeholder\">;\n\tinvalid?: boolean;\n\toptions: readonly AutocompleteOption<ItemValue>[];\n\tplaceholder?: string;\n\tpopupProps?: ComboboxPopupProps;\n\tpositionerProps?: ComboboxPositionerProps;\n\ttriggerLabel?: string;\n}\n\nfunction AutocompleteComponent<ItemValue>({\n\t\"aria-describedby\": ariaDescribedby,\n\t\"aria-label\": ariaLabel,\n\t\"aria-labelledby\": ariaLabelledby,\n\tclassName,\n\tclearLabel,\n\temptyMessage,\n\tinputProps,\n\tinvalid = false,\n\titemToStringValue,\n\toptions,\n\tplaceholder,\n\tpopupProps,\n\tpositionerProps,\n\ttriggerLabel,\n\t...rootProps\n}: AutocompleteProps<ItemValue>) {\n\tconst messages = useMessages();\n\tconst optionIndex = useMemo(() => createOptionIndex<ItemValue, AutocompleteOption<ItemValue>>(options), [options]);\n\tconst stringify = useMemo(\n\t\t() =>\n\t\t\titemToStringValue ??\n\t\t\t((itemValue: ItemValue) => {\n\t\t\t\tconst option = optionIndex.get(itemValue)?.option;\n\t\t\t\treturn option?.textValue ?? (typeof option?.label === \"string\" ? option.label : String(itemValue));\n\t\t\t}),\n\t\t[itemToStringValue, optionIndex]\n\t);\n\n\treturn (\n\t\t<BaseAutocomplete.Root {...rootProps} itemToStringValue={stringify} items={optionIndex.values}>\n\t\t\t<AutocompleteInputGroup className={className}>\n\t\t\t\t<ComboboxInput\n\t\t\t\t\t{...inputProps}\n\t\t\t\t\taria-describedby={ariaDescribedby ?? inputProps?.[\"aria-describedby\"]}\n\t\t\t\t\taria-invalid={invalid || inputProps?.[\"aria-invalid\"] || undefined}\n\t\t\t\t\taria-label={ariaLabel ?? inputProps?.[\"aria-label\"]}\n\t\t\t\t\taria-labelledby={ariaLabelledby ?? inputProps?.[\"aria-labelledby\"]}\n\t\t\t\t\tautoComplete={inputProps?.autoComplete ?? \"off\"}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t/>\n\t\t\t\t<ComboboxClear aria-label={clearLabel ?? messages.autocompleteClear}>\n\t\t\t\t\t<XIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t\t</ComboboxClear>\n\t\t\t\t<BaseAutocomplete.Trigger aria-label={triggerLabel ?? messages.autocompleteTrigger} className={\"lyds-combobox__trigger\"}>\n\t\t\t\t\t<CaretDownIcon aria-hidden=\"true\" weight=\"bold\" />\n\t\t\t\t</BaseAutocomplete.Trigger>\n\t\t\t</AutocompleteInputGroup>\n\t\t\t<BaseAutocomplete.Portal>\n\t\t\t\t<ComboboxPositioner {...positionerProps}>\n\t\t\t\t\t<ComboboxPopup {...popupProps}>\n\t\t\t\t\t\t<ComboboxList>\n\t\t\t\t\t\t\t{(value: ItemValue, index: number) => {\n\t\t\t\t\t\t\t\tconst indexed = optionIndex.get(value);\n\t\t\t\t\t\t\t\tif (!indexed) return null;\n\t\t\t\t\t\t\t\tconst { option, sourceIndex } = indexed;\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<AutocompleteItem disabled={option.disabled} index={index} key={option.key ?? option.textValue ?? sourceIndex} value={value}>\n\t\t\t\t\t\t\t\t\t\t<span className={\"lyds-listbox__option-text\"}>{option.label}</span>\n\t\t\t\t\t\t\t\t\t</AutocompleteItem>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t</ComboboxList>\n\t\t\t\t\t\t<ComboboxEmpty>{emptyMessage ?? messages.autocompleteEmpty}</ComboboxEmpty>\n\t\t\t\t\t</ComboboxPopup>\n\t\t\t\t</ComboboxPositioner>\n\t\t\t</BaseAutocomplete.Portal>\n\t\t</BaseAutocomplete.Root>\n\t);\n}\n\nexport const Autocomplete = Object.assign(AutocompleteComponent, {\n\tArrow: BaseAutocomplete.Arrow,\n\tBackdrop: BaseAutocomplete.Backdrop,\n\tClear: ComboboxClear,\n\tCollection: BaseAutocomplete.Collection,\n\tEmpty: ComboboxEmpty,\n\tGroup: BaseAutocomplete.Group,\n\tGroupLabel: BaseAutocomplete.GroupLabel,\n\tIcon: BaseAutocomplete.Icon,\n\tInput: ComboboxInput,\n\tInputGroup: AutocompleteInputGroup,\n\tItem: AutocompleteItem,\n\tList: ComboboxList,\n\tPopup: ComboboxPopup,\n\tPortal: BaseAutocomplete.Portal,\n\tPositioner: ComboboxPositioner,\n\tRoot: BaseAutocomplete.Root,\n\tRow: BaseAutocomplete.Row,\n\tSeparator: BaseAutocomplete.Separator,\n\tStatus: BaseAutocomplete.Status,\n\tTrigger: BaseAutocomplete.Trigger,\n\tValue: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AAI,CAAC,GAAS,OAAO;KACrB,IAAM,EAAE,WAAQ,mBAAgB;KAChC,OACC,kBAAC,GAAD;MAAkB,UAAU,EAAO;MAAiB;MAAkE;MACrH,UAAA,kBAAC,QAAD;OAAM,WAAW;OAA8B,UAAA,EAAO;MAAY,CAAA;KACjD,GAF8C,EAAO,OAAO,EAAO,aAAa,CAEhF;IAEpB,EACa,CAAA,GACd,kBAAC,GAAD,EAAA,UAAgB,KAAgB,EAAS,kBAAiC,CAAA,CAC5D;;EACI,CAAA,EACI,CAAA,CACH;;AAEzB;AAEA,IAAa,IAAe,OAAO,OAAO,GAAuB;CAChE,OAAO,EAAiB;CACxB,UAAU,EAAiB;CAC3B,OAAO;CACP,YAAY,EAAiB;CAC7B,OAAO;CACP,OAAO,EAAiB;CACxB,YAAY,EAAiB;CAC7B,MAAM,EAAiB;CACvB,OAAO;CACP,YAAY;CACZ,MAAM;CACN,MAAM;CACN,OAAO;CACP,QAAQ,EAAiB;CACzB,YAAY;CACZ,MAAM,EAAiB;CACvB,KAAK,EAAiB;CACtB,WAAW,EAAiB;CAC5B,QAAQ,EAAiB;CACzB,SAAS,EAAiB;CAC1B,OAAO,EAAiB;CACxB,WAAW,EAAiB;CAC5B,kBAAkB,EAAiB;AACpC,CAAC"}
@@ -7,6 +7,7 @@ import { SwitchRootProps } from '@base-ui/react/switch';
7
7
  import { ToggleProps as BaseToggleProps } from '@base-ui/react/toggle';
8
8
  import { ToggleGroup as BaseToggleGroup, ToggleGroupProps as BaseToggleGroupProps } from '@base-ui/react/toggle-group';
9
9
  import { JSX, ReactNode, RefAttributes } from 'react';
10
+ import { AccessibleName } from '../../internal/index.js';
10
11
  export interface CheckboxProps extends CheckboxRootProps {
11
12
  indicator?: ReactNode;
12
13
  }
@@ -51,7 +52,7 @@ export declare const Toggle: ToggleComponent;
51
52
  export type ToggleGroupProps<Value extends string = string> = BaseToggleGroupProps<Value>;
52
53
  type ToggleGroupComponent = <Value extends string = string>(props: ToggleGroupProps<Value> & RefAttributes<HTMLDivElement>) => JSX.Element;
53
54
  export declare const ToggleGroup: ToggleGroupComponent;
54
- export interface SegmentedControlProps<Value extends string = string> extends Omit<BaseToggleGroupProps<Value>, "aria-readonly" | "defaultValue" | "multiple" | "onValueChange" | "value"> {
55
+ interface SegmentedControlOwnProps<Value extends string = string> extends Omit<BaseToggleGroupProps<Value>, "aria-label" | "aria-labelledby" | "aria-readonly" | "defaultValue" | "multiple" | "onValueChange" | "value"> {
55
56
  allowEmpty?: boolean;
56
57
  defaultValue?: Value | null;
57
58
  name?: string;
@@ -59,6 +60,8 @@ export interface SegmentedControlProps<Value extends string = string> extends Om
59
60
  size?: "sm" | "md";
60
61
  value?: Value | null;
61
62
  }
63
+ /** The segments name themselves; the group they belong to does not, so it has to be told. */
64
+ export type SegmentedControlProps<Value extends string = string> = SegmentedControlOwnProps<Value> & AccessibleName;
62
65
  type SegmentedControlComponent = <Value extends string = string>(props: SegmentedControlProps<Value> & RefAttributes<HTMLDivElement>) => JSX.Element;
63
66
  export declare const SegmentedControl: SegmentedControlComponent;
64
67
  export declare const SegmentedControlItem: ToggleComponent;