@phillips/seldon 1.154.0 → 1.156.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.
- package/dist/_virtual/index5.js +2 -2
- package/dist/_virtual/index6.js +2 -2
- package/dist/_virtual/index7.js +2 -2
- package/dist/_virtual/index8.js +2 -2
- package/dist/components/ComboBox/ComboBox.d.ts +30 -13
- package/dist/components/ComboBox/ComboBox.js +253 -148
- package/dist/components/ComboBox/ComboBox.stories.d.ts +46 -4
- package/dist/components/ComboBox/types.d.ts +18 -0
- package/dist/components/PhoneNumberPicker/PhoneNumberPicker.d.ts +8 -28
- package/dist/components/PhoneNumberPicker/PhoneNumberPicker.js +39 -0
- package/dist/components/PhoneNumberPicker/PhoneNumberPicker.stories.d.ts +1 -2
- package/dist/components/PhoneNumberPicker/index.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +59 -57
- package/dist/node_modules/exenv/index.js +1 -1
- package/dist/node_modules/ics/dist/index.js +2 -2
- package/dist/node_modules/ics/dist/pipeline/index.js +1 -1
- package/dist/node_modules/libphonenumber-js/es6/getCountries.js +7 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/isObject.js +7 -0
- package/dist/node_modules/libphonenumber-js/es6/metadata.js +456 -0
- package/dist/node_modules/libphonenumber-js/es6/tools/semver-compare.js +14 -0
- package/dist/node_modules/libphonenumber-js/metadata.min.json.js +4 -0
- package/dist/node_modules/libphonenumber-js/min/exports/getCountries.js +8 -0
- package/dist/node_modules/libphonenumber-js/min/exports/getCountryCallingCode.js +8 -0
- package/dist/node_modules/libphonenumber-js/min/exports/withMetadataArgument.js +8 -0
- package/dist/node_modules/prop-types/node_modules/react-is/index.js +1 -1
- package/dist/pages/page.test.d.ts +1 -0
- package/dist/scss/components/ComboBox/_combobox.scss +93 -57
- package/dist/scss/components/ContentPeek/_contentPeek.scss +1 -1
- package/dist/utils/usePrevious.d.ts +1 -0
- package/dist/utils/usePrevious.js +10 -0
- package/package.json +1 -1
package/dist/_virtual/index5.js
CHANGED
package/dist/_virtual/index6.js
CHANGED
package/dist/_virtual/index7.js
CHANGED
package/dist/_virtual/index8.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
import { ComboBoxOption } from './types';
|
|
2
3
|
export interface ComboBoxProps {
|
|
3
4
|
/**
|
|
4
5
|
* Boolean to specify whether you want the underlying label to be visually hidden
|
|
@@ -7,10 +8,7 @@ export interface ComboBoxProps {
|
|
|
7
8
|
/**
|
|
8
9
|
* List of options to be displayed in the ComboBox.
|
|
9
10
|
*/
|
|
10
|
-
options:
|
|
11
|
-
label?: string;
|
|
12
|
-
value: string;
|
|
13
|
-
}[];
|
|
11
|
+
options: ComboBoxOption[];
|
|
14
12
|
/**
|
|
15
13
|
* Unique id for the ComboBox.
|
|
16
14
|
*/
|
|
@@ -28,13 +26,31 @@ export interface ComboBoxProps {
|
|
|
28
26
|
*/
|
|
29
27
|
placeholder?: string;
|
|
30
28
|
/**
|
|
31
|
-
*
|
|
29
|
+
* Name attribute for form submission
|
|
32
30
|
*/
|
|
33
|
-
|
|
31
|
+
name?: string;
|
|
34
32
|
/**
|
|
35
|
-
*
|
|
33
|
+
* Value for the selected option for controlled usage.
|
|
36
34
|
*/
|
|
37
|
-
|
|
35
|
+
value?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Handler for value changes for controlled usage
|
|
38
|
+
*/
|
|
39
|
+
onChange?: (value: string, option: ComboBoxOption | null) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Function to render custom option content
|
|
42
|
+
* Similar to MUI's renderOption
|
|
43
|
+
*/
|
|
44
|
+
renderOption?: (option: ComboBoxOption) => React.ReactNode;
|
|
45
|
+
/**
|
|
46
|
+
* Sets the invalid state of the input
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
invalid?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Text to display when input is invalid
|
|
52
|
+
*/
|
|
53
|
+
invalidText?: string;
|
|
38
54
|
/**
|
|
39
55
|
* aria-label optional input label
|
|
40
56
|
*/
|
|
@@ -51,25 +67,26 @@ export interface ComboBoxProps {
|
|
|
51
67
|
* aria-label for content
|
|
52
68
|
*/
|
|
53
69
|
ariaLabelContent?: string;
|
|
54
|
-
/**
|
|
55
|
-
* If true, the input will be cleared when the user clicks away when the input value is not in the options list.
|
|
56
|
-
*/
|
|
57
|
-
autoClearInput?: boolean;
|
|
58
70
|
/**
|
|
59
71
|
* popoverContainer ref for the ComboBox
|
|
60
72
|
*/
|
|
61
73
|
popoverContainerRef?: React.RefObject<HTMLElement>;
|
|
62
74
|
/**
|
|
63
75
|
* No options message translation
|
|
76
|
+
* @default "No Options."
|
|
64
77
|
*/
|
|
65
78
|
noOptionsMessage?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Handler called when the combobox loses focus
|
|
81
|
+
*/
|
|
82
|
+
onBlur?: React.FocusEventHandler<HTMLDivElement>;
|
|
66
83
|
}
|
|
67
84
|
/**
|
|
68
85
|
* ## Overview
|
|
69
86
|
*
|
|
70
87
|
* This is a ComboBox component that allows users to select from a list of options or enter a custom value.
|
|
71
88
|
*
|
|
72
|
-
* [Figma Link]
|
|
89
|
+
* [Figma Link](https://www.figma.com/design/rIefa3bRPyZbZmtyV9PSQv/My-Account?node-id=1-3&p=f&m=dev)
|
|
73
90
|
*
|
|
74
91
|
* [Storybook Link](https://phillips-seldon.netlify.app/?path=/docs/components-comboBox--overview)
|
|
75
92
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Root as
|
|
3
|
-
import
|
|
4
|
-
import { Command as
|
|
5
|
-
import
|
|
6
|
-
import { useOnClickOutside as
|
|
1
|
+
import { jsxs as T, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { Root as dt, Trigger as ht, Portal as _t, Content as vt } from "../../node_modules/@radix-ui/react-popover/dist/index.js";
|
|
3
|
+
import d from "../../node_modules/classnames/index.js";
|
|
4
|
+
import { Command as $t, CommandInput as yt, CommandList as wt, CommandGroup as Ct, CommandItem as bt } from "../../node_modules/cmdk/dist/index.js";
|
|
5
|
+
import gt, { useState as S, useCallback as b, useRef as k, useMemo as x } from "react";
|
|
6
|
+
import { useOnClickOutside as Nt } from "../../node_modules/usehooks-ts/dist/index.js";
|
|
7
7
|
import "../../assets/formatted/AccountActive.js";
|
|
8
8
|
import "../../assets/formatted/Account.js";
|
|
9
9
|
import "../../assets/formatted/Add.js";
|
|
@@ -14,11 +14,11 @@ import "../../assets/formatted/ArrowRight.js";
|
|
|
14
14
|
import "../../assets/formatted/ArrowUp.js";
|
|
15
15
|
import "../../assets/formatted/Bag.js";
|
|
16
16
|
import "../../assets/formatted/Calendar.js";
|
|
17
|
-
import
|
|
17
|
+
import It from "../../assets/formatted/ChevronDown.js";
|
|
18
18
|
import "../../assets/formatted/ChevronLeft.js";
|
|
19
19
|
import "../../assets/formatted/ChevronRight.js";
|
|
20
20
|
import "../../assets/formatted/ChevronUp.js";
|
|
21
|
-
import
|
|
21
|
+
import Ot from "../../assets/formatted/CloseX.js";
|
|
22
22
|
import "../../assets/formatted/ConditionReport.js";
|
|
23
23
|
import "../../assets/formatted/Delete.js";
|
|
24
24
|
import "../../assets/formatted/Download.js";
|
|
@@ -68,156 +68,261 @@ import "../../assets/formatted/VolumeMaximum.js";
|
|
|
68
68
|
import "../../assets/formatted/VolumeMid.js";
|
|
69
69
|
import "../../assets/formatted/VolumeMinimum.js";
|
|
70
70
|
import "../../assets/formatted/WeChat.js";
|
|
71
|
-
import { getCommonProps as
|
|
72
|
-
import
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
71
|
+
import { getCommonProps as Tt, useNormalizedInputProps as kt } from "../../utils/index.js";
|
|
72
|
+
import X from "../IconButton/IconButton.js";
|
|
73
|
+
import { ButtonVariants as H } from "../Button/types.js";
|
|
74
|
+
import { usePrevious as xt } from "../../utils/usePrevious.js";
|
|
75
|
+
const Vt = gt.forwardRef(function({
|
|
76
|
+
options: a = [],
|
|
77
|
+
className: J,
|
|
78
|
+
id: s,
|
|
79
|
+
labelText: Q,
|
|
80
|
+
placeholder: Y,
|
|
81
|
+
name: V,
|
|
82
|
+
value: u,
|
|
83
|
+
onChange: p,
|
|
84
|
+
onBlur: Z,
|
|
85
|
+
renderOption: j,
|
|
86
|
+
ariaLabelDropdown: g,
|
|
87
|
+
ariaLabelInput: q,
|
|
88
|
+
ariaLabelClear: N,
|
|
89
|
+
ariaLabelContent: z,
|
|
90
|
+
hideLabel: tt = !1,
|
|
91
|
+
popoverContainerRef: et,
|
|
92
|
+
noOptionsMessage: rt = "No Options.",
|
|
93
|
+
invalid: I = !1,
|
|
94
|
+
invalidText: ot,
|
|
95
|
+
...st
|
|
96
|
+
}, D) {
|
|
97
|
+
const { className: e, ...lt } = Tt({ id: s }, "ComboBox"), it = It, nt = Ot, G = kt({
|
|
98
|
+
id: s,
|
|
99
|
+
invalid: I,
|
|
100
|
+
invalidText: ot,
|
|
101
|
+
type: "text"
|
|
102
|
+
}), [f, K] = S(!1), [at, ct] = S(""), U = xt(u), R = b((t) => t.label || t.value, []), [l, $] = S(() => {
|
|
103
|
+
if (u !== void 0) {
|
|
104
|
+
const t = a.find((r) => r.value === u);
|
|
105
|
+
return t ? t.displayValue || R(t) : "";
|
|
106
|
+
}
|
|
107
|
+
return "";
|
|
108
|
+
}), y = k(null), w = k(null), C = k(!1), E = k(null), c = b((t) => R(t), [R]), h = u !== void 0, F = h ? u : at, i = x(() => a.find((t) => t.value === F) || null, [a, F]), _ = x(() => i ? i.displayValue || c(i) : "", [i, c]), m = x(() => {
|
|
109
|
+
if (!l || i && l === _)
|
|
110
|
+
return a;
|
|
111
|
+
const t = l.toLowerCase().trim();
|
|
112
|
+
return a.filter((r) => {
|
|
113
|
+
const B = c(r).toLowerCase().includes(t), L = r.value.toLowerCase().includes(t), A = r.displayValue?.toLowerCase().includes(t) || !1;
|
|
114
|
+
let v = !1;
|
|
115
|
+
return r.filterTerms && r.filterTerms.length > 0 && (v = r.filterTerms.some((ft) => ft.toLowerCase().includes(t))), B || L || A || v;
|
|
116
|
+
});
|
|
117
|
+
}, [l, _, i, c, a]), n = b(
|
|
118
|
+
(t) => {
|
|
119
|
+
K(t), t && i && m.length > 5 && requestAnimationFrame(() => {
|
|
120
|
+
E.current && E.current.scrollIntoView({
|
|
121
|
+
block: "nearest",
|
|
122
|
+
behavior: "auto"
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
},
|
|
126
|
+
[i, m.length]
|
|
127
|
+
), O = b(
|
|
128
|
+
(t) => {
|
|
129
|
+
h || ct(t.value);
|
|
130
|
+
const r = t.displayValue || c(t);
|
|
131
|
+
$(r), p && p(t.value, t), n(!1), C.current = !0, requestAnimationFrame(() => {
|
|
132
|
+
C.current = !1;
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
[h, p, n, c]
|
|
136
|
+
), mt = (t) => {
|
|
137
|
+
n(!1), C.current = !0, t.preventDefault(), t.stopPropagation(), p && h && p("", null), $(""), w.current?.focus(), requestAnimationFrame(() => {
|
|
138
|
+
C.current = !1;
|
|
139
|
+
});
|
|
140
|
+
}, ut = () => {
|
|
141
|
+
K(!f), w.current?.focus();
|
|
142
|
+
}, pt = (t) => {
|
|
143
|
+
$(t), t !== "" && m.length > 0 && n(!0);
|
|
144
|
+
}, W = x(() => {
|
|
145
|
+
if (h) {
|
|
146
|
+
if (u !== U)
|
|
147
|
+
return i ? _ : l;
|
|
148
|
+
if (i) {
|
|
149
|
+
const t = _;
|
|
150
|
+
return t !== l ? l : t;
|
|
151
|
+
} else
|
|
152
|
+
return l;
|
|
153
|
+
}
|
|
154
|
+
return l;
|
|
155
|
+
}, [h, l, u, U, i, _]), M = (t) => {
|
|
156
|
+
if (i) {
|
|
157
|
+
const r = _;
|
|
158
|
+
r !== W && !t && $(r);
|
|
159
|
+
} else
|
|
160
|
+
$("");
|
|
161
|
+
}, P = b(() => {
|
|
162
|
+
const t = a.filter((r) => {
|
|
163
|
+
const B = c(r).toLowerCase(), L = r.value.toLowerCase(), A = r.displayValue?.toLowerCase(), v = l.toLowerCase();
|
|
164
|
+
return B === v || L === v || A === v;
|
|
165
|
+
});
|
|
166
|
+
t.length === 1 && O(t[0]);
|
|
167
|
+
}, [l, a, O, c]);
|
|
168
|
+
return Nt(y, (t) => {
|
|
169
|
+
t.target.closest(`.${e}__item`) || t.target.closest(`.${e}__content`) || y.current?.contains(t.target) || t.target === y.current || (P(), M(), n(!1));
|
|
170
|
+
}), /* @__PURE__ */ T("div", { ref: D, className: d(e, J), id: s, ...lt, ...st, children: [
|
|
171
|
+
V && /* @__PURE__ */ o(
|
|
172
|
+
"input",
|
|
103
173
|
{
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
174
|
+
type: "hidden",
|
|
175
|
+
name: V,
|
|
176
|
+
id: V,
|
|
177
|
+
value: F || "",
|
|
178
|
+
ref: (t) => {
|
|
179
|
+
typeof D == "function" && t && D(t);
|
|
180
|
+
}
|
|
110
181
|
}
|
|
111
182
|
),
|
|
112
|
-
/* @__PURE__ */
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
183
|
+
/* @__PURE__ */ T("div", { ref: y, className: `${e}__wrapper`, children: [
|
|
184
|
+
/* @__PURE__ */ o(
|
|
185
|
+
"label",
|
|
186
|
+
{
|
|
187
|
+
htmlFor: `${s}-input`,
|
|
188
|
+
className: d(`${e}__label`, {
|
|
189
|
+
[`${e}__label--hidden`]: tt,
|
|
190
|
+
[`${e}__label--invalid`]: I
|
|
191
|
+
}),
|
|
192
|
+
"data-testid": `${s}-label`,
|
|
193
|
+
children: Q
|
|
194
|
+
}
|
|
195
|
+
),
|
|
196
|
+
/* @__PURE__ */ o(
|
|
197
|
+
$t,
|
|
198
|
+
{
|
|
199
|
+
loop: !0,
|
|
200
|
+
onKeyDown: (t) => {
|
|
201
|
+
setTimeout(() => {
|
|
202
|
+
t.key === "Escape" && n(!1);
|
|
203
|
+
}, 0);
|
|
204
|
+
},
|
|
205
|
+
shouldFilter: !1,
|
|
206
|
+
className: `${e}__command-wrapper`,
|
|
207
|
+
children: /* @__PURE__ */ T(dt, { open: f, modal: !1, children: [
|
|
208
|
+
/* @__PURE__ */ o(ht, { asChild: !0, children: /* @__PURE__ */ T(
|
|
209
|
+
"div",
|
|
125
210
|
{
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
211
|
+
className: d(`${e}__input-wrapper`, {
|
|
212
|
+
[`${e}__input-wrapper--invalid`]: I
|
|
213
|
+
}),
|
|
214
|
+
children: [
|
|
215
|
+
/* @__PURE__ */ o(
|
|
216
|
+
yt,
|
|
217
|
+
{
|
|
218
|
+
id: `${s}-input`,
|
|
219
|
+
placeholder: Y,
|
|
220
|
+
value: W,
|
|
221
|
+
onValueChange: pt,
|
|
222
|
+
tabIndex: 0,
|
|
223
|
+
onFocus: () => {
|
|
224
|
+
m.length > 0 && !C.current && !f && n(!0);
|
|
225
|
+
},
|
|
226
|
+
onClick: (t) => {
|
|
227
|
+
n(!0), t.preventDefault(), t.currentTarget.focus();
|
|
228
|
+
},
|
|
229
|
+
onKeyDown: (t) => {
|
|
230
|
+
t.key === "Tab" ? (n(!1), P(), M()) : t.key === "Enter" && !f ? (p && p(l, null), m.length === 1 && O(m[0])) : t.key === "Escape" ? (n(!1), t.preventDefault(), P(), M()) : (t.key === "ArrowDown" || t.key === "ArrowUp") && !f && m.length > 0 && (n(!0), t.preventDefault());
|
|
231
|
+
},
|
|
232
|
+
onBlur: Z,
|
|
233
|
+
className: d(`${e}__input`, {
|
|
234
|
+
[`${e}__input--invalid`]: I
|
|
235
|
+
}),
|
|
236
|
+
"aria-label": q || `${s}-input`,
|
|
237
|
+
"data-testid": `${s}-input`,
|
|
238
|
+
ref: w
|
|
239
|
+
}
|
|
240
|
+
),
|
|
241
|
+
l && /* @__PURE__ */ o(
|
|
242
|
+
X,
|
|
243
|
+
{
|
|
244
|
+
className: `${e}__close-button`,
|
|
245
|
+
"data-testid": `${s}-clear-button`,
|
|
246
|
+
onClick: mt,
|
|
247
|
+
"aria-label": N || `${s}-clear`,
|
|
248
|
+
tabIndex: -1,
|
|
249
|
+
variant: H.tertiary,
|
|
250
|
+
children: /* @__PURE__ */ o(
|
|
251
|
+
nt,
|
|
252
|
+
{
|
|
253
|
+
color: "currentColor",
|
|
254
|
+
height: 18,
|
|
255
|
+
width: 18,
|
|
256
|
+
className: `${e}__icon-button`,
|
|
257
|
+
title: N || `${s}-clear`
|
|
258
|
+
}
|
|
259
|
+
)
|
|
260
|
+
}
|
|
261
|
+
),
|
|
262
|
+
/* @__PURE__ */ o(
|
|
263
|
+
X,
|
|
264
|
+
{
|
|
265
|
+
"aria-label": g || `${s}-dropdown`,
|
|
266
|
+
className: d(`${e}__dropdown-button`, {
|
|
267
|
+
[`${e}__dropdown-button--open`]: f
|
|
268
|
+
}),
|
|
269
|
+
onClick: ut,
|
|
270
|
+
"data-testid": `${s}-dropdown`,
|
|
271
|
+
tabIndex: -1,
|
|
272
|
+
variant: H.tertiary,
|
|
273
|
+
children: /* @__PURE__ */ o(
|
|
274
|
+
it,
|
|
275
|
+
{
|
|
276
|
+
color: "currentColor",
|
|
277
|
+
height: 18,
|
|
278
|
+
width: 18,
|
|
279
|
+
className: `${e}__icon-button`,
|
|
280
|
+
title: g || `${s}-dropdown`
|
|
281
|
+
}
|
|
282
|
+
)
|
|
283
|
+
}
|
|
284
|
+
)
|
|
285
|
+
]
|
|
142
286
|
}
|
|
143
287
|
) }),
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
{
|
|
147
|
-
className: `${e}__close-button`,
|
|
148
|
-
"data-testid": `${r}-item-close-button`,
|
|
149
|
-
onClick: () => i(""),
|
|
150
|
-
"aria-label": u || `${r}-clear`,
|
|
151
|
-
tabIndex: -1,
|
|
152
|
-
children: /* @__PURE__ */ t("div", { className: `${e}__icon`, children: /* @__PURE__ */ t(
|
|
153
|
-
D,
|
|
154
|
-
{
|
|
155
|
-
color: N("", "$primary-black"),
|
|
156
|
-
height: 18,
|
|
157
|
-
width: 18,
|
|
158
|
-
className: `${e}__icon-button`
|
|
159
|
-
}
|
|
160
|
-
) })
|
|
161
|
-
}
|
|
162
|
-
),
|
|
163
|
-
/* @__PURE__ */ t(
|
|
164
|
-
"button",
|
|
288
|
+
f && /* @__PURE__ */ o(_t, { container: et?.current || document.body, children: /* @__PURE__ */ o(
|
|
289
|
+
vt,
|
|
165
290
|
{
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
291
|
+
className: `${e}__content`,
|
|
292
|
+
"aria-label": z || `${s}-content`,
|
|
293
|
+
side: "bottom",
|
|
294
|
+
sideOffset: -5,
|
|
295
|
+
align: "start",
|
|
296
|
+
alignOffset: 0,
|
|
297
|
+
onFocus: () => {
|
|
298
|
+
document.activeElement !== w.current && w.current?.focus();
|
|
299
|
+
},
|
|
300
|
+
style: {
|
|
301
|
+
width: y.current?.offsetWidth || "100%"
|
|
302
|
+
},
|
|
303
|
+
children: /* @__PURE__ */ o(wt, { className: `${e}__list`, children: m.length > 0 ? /* @__PURE__ */ o(Ct, { className: `${e}__group`, children: m.map((t) => /* @__PURE__ */ o(
|
|
304
|
+
bt,
|
|
173
305
|
{
|
|
174
|
-
className:
|
|
175
|
-
[`${e}
|
|
306
|
+
className: d(`${e}__item`, {
|
|
307
|
+
[`${e}__item--selected`]: i?.value === t.value
|
|
176
308
|
}),
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
height: 18,
|
|
182
|
-
width: 18,
|
|
183
|
-
className: `${e}__icon-button`
|
|
184
|
-
}
|
|
185
|
-
)
|
|
186
|
-
}
|
|
187
|
-
)
|
|
188
|
-
}
|
|
189
|
-
)
|
|
190
|
-
] }),
|
|
191
|
-
/* @__PURE__ */ t(F, { container: k?.current, children: /* @__PURE__ */ t(
|
|
192
|
-
K,
|
|
193
|
-
{
|
|
194
|
-
className: `${e}__content`,
|
|
195
|
-
"aria-label": _ || `${r}-content`,
|
|
196
|
-
children: C && /* @__PURE__ */ t(X, { className: `${e}__list`, children: n.some(
|
|
197
|
-
(o) => o.value.toLowerCase().includes(m.toLowerCase()) || o.label && o.label.toLowerCase().includes(m.toLowerCase())
|
|
198
|
-
) ? /* @__PURE__ */ t(q, { children: n.map(
|
|
199
|
-
(o, h) => (o.value.toLowerCase().includes(m.toLowerCase()) || o.label && o.label.toLowerCase().includes(m.toLowerCase())) && /* @__PURE__ */ t(
|
|
200
|
-
z,
|
|
201
|
-
{
|
|
202
|
-
className: `${e}__item`,
|
|
203
|
-
value: o.label ? `${o.label} ${o.value}` : o.value,
|
|
204
|
-
ref: (a) => E.current[o.value] = a,
|
|
205
|
-
onSelect: (a) => {
|
|
206
|
-
i(a), s(!1);
|
|
207
|
-
},
|
|
208
|
-
children: o.label ? `${o.label} ${o.value}` : o.value
|
|
309
|
+
value: t.value,
|
|
310
|
+
onSelect: () => O(t),
|
|
311
|
+
...i?.value === t.value ? { ref: E } : {},
|
|
312
|
+
children: j ? j(t) : c(t)
|
|
209
313
|
},
|
|
210
|
-
|
|
211
|
-
)
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
314
|
+
t.value
|
|
315
|
+
)) }) : /* @__PURE__ */ o("div", { className: `${e}__no-options`, children: rt }) })
|
|
316
|
+
}
|
|
317
|
+
) })
|
|
318
|
+
] })
|
|
319
|
+
}
|
|
320
|
+
),
|
|
321
|
+
G.validation ? G.validation : /* @__PURE__ */ o("p", { className: d(`${e}__validation`), children: " " })
|
|
322
|
+
] })
|
|
323
|
+
] });
|
|
219
324
|
});
|
|
220
|
-
|
|
325
|
+
Vt.displayName = "ComboBox";
|
|
221
326
|
export {
|
|
222
|
-
|
|
327
|
+
Vt as default
|
|
223
328
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { ComboBoxProps } from './ComboBox';
|
|
3
|
+
import { ComboBoxOption } from './types';
|
|
3
4
|
declare const meta: {
|
|
4
5
|
title: string;
|
|
5
6
|
component: React.ForwardRefExoticComponent<ComboBoxProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -8,12 +9,53 @@ export default meta;
|
|
|
8
9
|
export declare const Playground: {
|
|
9
10
|
(props: ComboBoxProps): import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
args: {
|
|
11
|
-
options:
|
|
12
|
-
value: string;
|
|
13
|
-
}[];
|
|
12
|
+
options: ComboBoxOption[];
|
|
14
13
|
id: string;
|
|
15
14
|
labelText: string;
|
|
16
15
|
};
|
|
17
|
-
argTypes: {
|
|
16
|
+
argTypes: {
|
|
17
|
+
options: {
|
|
18
|
+
control: string;
|
|
19
|
+
};
|
|
20
|
+
id: {
|
|
21
|
+
control: string;
|
|
22
|
+
};
|
|
23
|
+
labelText: {
|
|
24
|
+
control: string;
|
|
25
|
+
};
|
|
26
|
+
invalid: {
|
|
27
|
+
control: string;
|
|
28
|
+
};
|
|
29
|
+
invalidText: {
|
|
30
|
+
control: string;
|
|
31
|
+
};
|
|
32
|
+
placeholder: {
|
|
33
|
+
control: string;
|
|
34
|
+
};
|
|
35
|
+
ariaLabelInput: {
|
|
36
|
+
control: string;
|
|
37
|
+
};
|
|
38
|
+
disabled: {
|
|
39
|
+
control: string;
|
|
40
|
+
};
|
|
41
|
+
readOnly: {
|
|
42
|
+
control: string;
|
|
43
|
+
};
|
|
44
|
+
popoverContainerRef: {
|
|
45
|
+
control: boolean;
|
|
46
|
+
};
|
|
47
|
+
renderOption: {
|
|
48
|
+
control: boolean;
|
|
49
|
+
};
|
|
50
|
+
onChange: {
|
|
51
|
+
control: boolean;
|
|
52
|
+
};
|
|
53
|
+
value: {
|
|
54
|
+
control: boolean;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
18
57
|
};
|
|
19
58
|
export declare const ComboBoxInDrawer: () => import("react/jsx-runtime").JSX.Element;
|
|
59
|
+
export declare const CustomRendering: () => import("react/jsx-runtime").JSX.Element;
|
|
60
|
+
export declare const FilterTermsExample: () => import("react/jsx-runtime").JSX.Element;
|
|
61
|
+
export declare const Phone: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface ComboBoxOption {
|
|
2
|
+
/**
|
|
3
|
+
* The label or display text
|
|
4
|
+
*/
|
|
5
|
+
label?: string;
|
|
6
|
+
/**
|
|
7
|
+
* The option value (used for selection)
|
|
8
|
+
*/
|
|
9
|
+
value: string;
|
|
10
|
+
/**
|
|
11
|
+
* Display value shown in input when selected (defaults to label)
|
|
12
|
+
*/
|
|
13
|
+
displayValue?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Additional terms for filtering
|
|
16
|
+
*/
|
|
17
|
+
filterTerms?: string[];
|
|
18
|
+
}
|