@phillips/seldon 1.176.0 → 1.177.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/components/ComboBox/ComboBox.d.ts +5 -0
- package/dist/components/ComboBox/ComboBox.js +132 -130
- package/dist/components/ComboBox/ComboBox.stories.d.ts +7 -0
- package/dist/components/Drawer/Drawer.js +36 -36
- package/dist/components/Modal/Modal.js +30 -30
- package/dist/components/Toast/useToast.js +11 -7
- package/dist/scss/components/ComboBox/_combobox.scss +4 -0
- package/package.json +1 -1
|
@@ -80,6 +80,11 @@ export interface ComboBoxProps {
|
|
|
80
80
|
* Handler called when the combobox loses focus
|
|
81
81
|
*/
|
|
82
82
|
onBlur?: React.FocusEventHandler<HTMLDivElement>;
|
|
83
|
+
/**
|
|
84
|
+
* Number of characters required in the input before the dropdown options are shown.
|
|
85
|
+
* @default 0
|
|
86
|
+
*/
|
|
87
|
+
countOfCharsBeforeDropdown?: number;
|
|
83
88
|
}
|
|
84
89
|
/**
|
|
85
90
|
* ## Overview
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { Root as
|
|
1
|
+
import { jsxs as x, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { Root as ht, Trigger as _t, Portal as vt, Content as $t } from "../../node_modules/@radix-ui/react-popover/dist/index.js";
|
|
3
3
|
import d from "../../node_modules/classnames/index.js";
|
|
4
|
-
import { Command as
|
|
5
|
-
import
|
|
6
|
-
import { useOnClickOutside as
|
|
4
|
+
import { Command as yt, CommandInput as Ct, CommandList as bt, CommandGroup as wt, CommandItem as gt } from "../../node_modules/cmdk/dist/index.js";
|
|
5
|
+
import Nt, { useState as S, useCallback as g, useRef as O, useMemo as V } from "react";
|
|
6
|
+
import { useOnClickOutside as It } 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";
|
|
@@ -29,11 +29,11 @@ import "../../assets/formatted/ArrowRight.js";
|
|
|
29
29
|
import "../../assets/formatted/ArrowUp.js";
|
|
30
30
|
import "../../assets/formatted/Bag.js";
|
|
31
31
|
import "../../assets/formatted/Calendar.js";
|
|
32
|
-
import
|
|
32
|
+
import Tt from "../../assets/formatted/ChevronDown.js";
|
|
33
33
|
import "../../assets/formatted/ChevronLeft.js";
|
|
34
34
|
import "../../assets/formatted/ChevronRight.js";
|
|
35
35
|
import "../../assets/formatted/ChevronUp.js";
|
|
36
|
-
import
|
|
36
|
+
import kt from "../../assets/formatted/CloseX.js";
|
|
37
37
|
import "../../assets/formatted/ConditionReport.js";
|
|
38
38
|
import "../../assets/formatted/Delete.js";
|
|
39
39
|
import "../../assets/formatted/Download.js";
|
|
@@ -83,133 +83,135 @@ import "../../assets/formatted/VolumeMaximum.js";
|
|
|
83
83
|
import "../../assets/formatted/VolumeMid.js";
|
|
84
84
|
import "../../assets/formatted/VolumeMinimum.js";
|
|
85
85
|
import "../../assets/formatted/WeChat.js";
|
|
86
|
-
import { getCommonProps as
|
|
87
|
-
import
|
|
88
|
-
import { ButtonVariants as
|
|
89
|
-
import { usePrevious as
|
|
90
|
-
const
|
|
86
|
+
import { getCommonProps as xt, useNormalizedInputProps as Ot } from "../../utils/index.js";
|
|
87
|
+
import H from "../IconButton/IconButton.js";
|
|
88
|
+
import { ButtonVariants as J } from "../Button/types.js";
|
|
89
|
+
import { usePrevious as Vt } from "../../utils/usePrevious.js";
|
|
90
|
+
const Dt = Nt.forwardRef(function({
|
|
91
91
|
options: a = [],
|
|
92
|
-
className:
|
|
93
|
-
id:
|
|
94
|
-
labelText:
|
|
95
|
-
placeholder:
|
|
96
|
-
name:
|
|
92
|
+
className: Q,
|
|
93
|
+
id: l,
|
|
94
|
+
labelText: Y,
|
|
95
|
+
placeholder: Z,
|
|
96
|
+
name: D,
|
|
97
97
|
value: p,
|
|
98
98
|
onChange: u,
|
|
99
|
-
onBlur:
|
|
99
|
+
onBlur: tt,
|
|
100
100
|
renderOption: j,
|
|
101
|
-
ariaLabelDropdown:
|
|
101
|
+
ariaLabelDropdown: N,
|
|
102
102
|
ariaLabelInput: q,
|
|
103
|
-
ariaLabelClear:
|
|
103
|
+
ariaLabelClear: I,
|
|
104
104
|
ariaLabelContent: z,
|
|
105
|
-
hideLabel:
|
|
106
|
-
popoverContainerRef:
|
|
107
|
-
noOptionsMessage:
|
|
108
|
-
invalid:
|
|
109
|
-
invalidText:
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
105
|
+
hideLabel: et = !1,
|
|
106
|
+
popoverContainerRef: rt,
|
|
107
|
+
noOptionsMessage: ot = "No Options.",
|
|
108
|
+
invalid: T = !1,
|
|
109
|
+
invalidText: it,
|
|
110
|
+
countOfCharsBeforeDropdown: G = 0,
|
|
111
|
+
...lt
|
|
112
|
+
}, M) {
|
|
113
|
+
const { className: e, ...st } = xt({ id: l }, "ComboBox"), nt = Tt, at = kt, K = Ot({
|
|
114
|
+
id: l,
|
|
115
|
+
invalid: T,
|
|
116
|
+
invalidText: it,
|
|
116
117
|
type: "text"
|
|
117
|
-
}), [f,
|
|
118
|
+
}), [f, U] = S(!1), [mt, ct] = S(""), W = Vt(p), R = g((t) => t.label || t.value, []), [o, $] = S(() => {
|
|
118
119
|
if (p !== void 0) {
|
|
119
120
|
const t = a.find((r) => r.value === p);
|
|
120
121
|
return t ? t.displayValue || R(t) : "";
|
|
121
122
|
}
|
|
122
123
|
return "";
|
|
123
|
-
}), y =
|
|
124
|
-
if (!
|
|
124
|
+
}), y = O(null), C = O(null), b = O(!1), E = O(null), m = g((t) => R(t), [R]), h = p !== void 0, F = h ? p : mt, s = V(() => a.find((t) => t.value === F) || null, [a, F]), _ = V(() => s ? s.displayValue || m(s) : "", [s, m]), c = V(() => {
|
|
125
|
+
if (!o || s && o === _)
|
|
125
126
|
return a;
|
|
126
|
-
const t =
|
|
127
|
+
const t = o.toLowerCase().trim();
|
|
127
128
|
return a.filter((r) => {
|
|
128
|
-
const
|
|
129
|
+
const w = m(r).toLowerCase().includes(t), A = r.value.toLowerCase().includes(t), B = r.displayValue?.toLowerCase().includes(t) || !1;
|
|
129
130
|
let v = !1;
|
|
130
|
-
return r.filterTerms && r.filterTerms.length > 0 && (v = r.filterTerms.some((
|
|
131
|
+
return r.filterTerms && r.filterTerms.length > 0 && (v = r.filterTerms.some((dt) => dt.toLowerCase().includes(t))), w || A || B || v;
|
|
131
132
|
});
|
|
132
|
-
}, [
|
|
133
|
-
(t) => {
|
|
134
|
-
|
|
133
|
+
}, [o, _, s, m, a]), n = g(
|
|
134
|
+
(t, r) => {
|
|
135
|
+
const w = (r?.length || o.length) >= G;
|
|
136
|
+
(!t || t && w) && U(t), t && s && c.length > 5 && requestAnimationFrame(() => {
|
|
135
137
|
E.current && E.current.scrollIntoView({
|
|
136
138
|
block: "nearest",
|
|
137
139
|
behavior: "auto"
|
|
138
140
|
});
|
|
139
141
|
});
|
|
140
142
|
},
|
|
141
|
-
[
|
|
142
|
-
),
|
|
143
|
+
[G, o.length, s, c.length]
|
|
144
|
+
), k = g(
|
|
143
145
|
(t) => {
|
|
144
|
-
h ||
|
|
146
|
+
h || ct(t.value);
|
|
145
147
|
const r = t.displayValue || m(t);
|
|
146
|
-
$(r), u && u(t.value, t), n(!1),
|
|
147
|
-
|
|
148
|
+
$(r), u && u(t.value, t), n(!1), b.current = !0, requestAnimationFrame(() => {
|
|
149
|
+
b.current = !1;
|
|
148
150
|
});
|
|
149
151
|
},
|
|
150
152
|
[h, u, n, m]
|
|
151
|
-
),
|
|
152
|
-
n(!1),
|
|
153
|
-
|
|
153
|
+
), pt = (t) => {
|
|
154
|
+
n(!1), b.current = !0, t.preventDefault(), t.stopPropagation(), u && h && u("", null), $(""), C.current?.focus(), requestAnimationFrame(() => {
|
|
155
|
+
b.current = !1;
|
|
154
156
|
});
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
},
|
|
158
|
-
$(t), t !== "" && c.length > 0 && n(!0);
|
|
159
|
-
},
|
|
157
|
+
}, ut = () => {
|
|
158
|
+
U(!f), C.current?.focus();
|
|
159
|
+
}, ft = (t) => {
|
|
160
|
+
$(t), t !== "" && c.length > 0 && n(!0, t);
|
|
161
|
+
}, X = V(() => {
|
|
160
162
|
if (h) {
|
|
161
|
-
if (p !==
|
|
162
|
-
return
|
|
163
|
-
if (
|
|
163
|
+
if (p !== W)
|
|
164
|
+
return s ? _ : o;
|
|
165
|
+
if (s) {
|
|
164
166
|
const t = _;
|
|
165
|
-
return t !==
|
|
167
|
+
return t !== o ? o : t;
|
|
166
168
|
} else
|
|
167
|
-
return
|
|
169
|
+
return o;
|
|
168
170
|
}
|
|
169
|
-
return
|
|
170
|
-
}, [h,
|
|
171
|
-
if (
|
|
171
|
+
return o;
|
|
172
|
+
}, [h, o, p, W, s, _]), P = (t) => {
|
|
173
|
+
if (s) {
|
|
172
174
|
const r = _;
|
|
173
|
-
r !==
|
|
175
|
+
r !== X && !t && $(r);
|
|
174
176
|
} else
|
|
175
177
|
$("");
|
|
176
|
-
},
|
|
178
|
+
}, L = g(() => {
|
|
177
179
|
const t = a.filter((r) => {
|
|
178
|
-
const
|
|
179
|
-
return
|
|
180
|
+
const w = m(r).toLowerCase(), A = r.value.toLowerCase(), B = r.displayValue?.toLowerCase(), v = o.toLowerCase();
|
|
181
|
+
return w === v || A === v || B === v;
|
|
180
182
|
});
|
|
181
|
-
t.length === 1 &&
|
|
182
|
-
}, [
|
|
183
|
-
return
|
|
184
|
-
t.target.closest(`.${e}__item`) || t.target.closest(`.${e}__content`) || y.current?.contains(t.target) || t.target === y.current || (
|
|
185
|
-
}), /* @__PURE__ */
|
|
186
|
-
|
|
183
|
+
t.length === 1 && k(t[0]);
|
|
184
|
+
}, [o, a, k, m]);
|
|
185
|
+
return It(y, (t) => {
|
|
186
|
+
t.target.closest(`.${e}__item`) || t.target.closest(`.${e}__content`) || y.current?.contains(t.target) || t.target === y.current || (L(), P(), n(!1));
|
|
187
|
+
}), /* @__PURE__ */ x("div", { ref: M, className: d(e, Q), id: l, ...st, ...lt, children: [
|
|
188
|
+
D && /* @__PURE__ */ i(
|
|
187
189
|
"input",
|
|
188
190
|
{
|
|
189
191
|
type: "hidden",
|
|
190
|
-
name:
|
|
191
|
-
id:
|
|
192
|
+
name: D,
|
|
193
|
+
id: D,
|
|
192
194
|
value: F || "",
|
|
193
195
|
ref: (t) => {
|
|
194
|
-
typeof
|
|
196
|
+
typeof M == "function" && t && M(t);
|
|
195
197
|
}
|
|
196
198
|
}
|
|
197
199
|
),
|
|
198
|
-
/* @__PURE__ */
|
|
199
|
-
/* @__PURE__ */
|
|
200
|
+
/* @__PURE__ */ x("div", { ref: y, className: `${e}__wrapper`, children: [
|
|
201
|
+
/* @__PURE__ */ i(
|
|
200
202
|
"label",
|
|
201
203
|
{
|
|
202
|
-
htmlFor: `${
|
|
204
|
+
htmlFor: `${l}-input`,
|
|
203
205
|
className: d(`${e}__label`, {
|
|
204
|
-
[`${e}__label--hidden`]:
|
|
205
|
-
[`${e}__label--invalid`]:
|
|
206
|
+
[`${e}__label--hidden`]: et,
|
|
207
|
+
[`${e}__label--invalid`]: T
|
|
206
208
|
}),
|
|
207
|
-
"data-testid": `${
|
|
208
|
-
children:
|
|
209
|
+
"data-testid": `${l}-label`,
|
|
210
|
+
children: Y
|
|
209
211
|
}
|
|
210
212
|
),
|
|
211
|
-
/* @__PURE__ */
|
|
212
|
-
|
|
213
|
+
/* @__PURE__ */ i(
|
|
214
|
+
yt,
|
|
213
215
|
{
|
|
214
216
|
loop: !0,
|
|
215
217
|
onKeyDown: (t) => {
|
|
@@ -219,80 +221,80 @@ const Vt = gt.forwardRef(function({
|
|
|
219
221
|
},
|
|
220
222
|
shouldFilter: !1,
|
|
221
223
|
className: `${e}__command-wrapper`,
|
|
222
|
-
children: /* @__PURE__ */
|
|
223
|
-
/* @__PURE__ */
|
|
224
|
+
children: /* @__PURE__ */ x(ht, { open: f, modal: !1, children: [
|
|
225
|
+
/* @__PURE__ */ i(_t, { asChild: !0, children: /* @__PURE__ */ x(
|
|
224
226
|
"div",
|
|
225
227
|
{
|
|
226
228
|
className: d(`${e}__input-wrapper`, {
|
|
227
|
-
[`${e}__input-wrapper--invalid`]:
|
|
229
|
+
[`${e}__input-wrapper--invalid`]: T
|
|
228
230
|
}),
|
|
229
231
|
children: [
|
|
230
|
-
/* @__PURE__ */
|
|
231
|
-
|
|
232
|
+
/* @__PURE__ */ i(
|
|
233
|
+
Ct,
|
|
232
234
|
{
|
|
233
|
-
id: `${
|
|
234
|
-
placeholder:
|
|
235
|
-
value:
|
|
236
|
-
onValueChange:
|
|
235
|
+
id: `${l}-input`,
|
|
236
|
+
placeholder: Z,
|
|
237
|
+
value: X,
|
|
238
|
+
onValueChange: ft,
|
|
237
239
|
tabIndex: 0,
|
|
238
240
|
onFocus: () => {
|
|
239
|
-
c.length > 0 && !
|
|
241
|
+
c.length > 0 && !b.current && !f && n(!0);
|
|
240
242
|
},
|
|
241
243
|
onClick: (t) => {
|
|
242
244
|
n(!0), t.preventDefault(), t.currentTarget.focus();
|
|
243
245
|
},
|
|
244
246
|
onKeyDown: (t) => {
|
|
245
|
-
t.key === "Tab" ? (n(!1),
|
|
247
|
+
t.key === "Tab" ? (n(!1), L(), P()) : t.key === "Enter" && !f ? (u && u(o, null), c.length === 1 && k(c[0])) : t.key === "Escape" ? (n(!1), t.preventDefault(), L(), P()) : (t.key === "ArrowDown" || t.key === "ArrowUp") && !f && c.length > 0 && (n(!0), t.preventDefault());
|
|
246
248
|
},
|
|
247
|
-
onBlur:
|
|
249
|
+
onBlur: tt,
|
|
248
250
|
className: d(`${e}__input`, {
|
|
249
|
-
[`${e}__input--invalid`]:
|
|
251
|
+
[`${e}__input--invalid`]: T
|
|
250
252
|
}),
|
|
251
|
-
"aria-label": q || `${
|
|
252
|
-
"data-testid": `${
|
|
253
|
-
ref:
|
|
253
|
+
"aria-label": q || `${l}-input`,
|
|
254
|
+
"data-testid": `${l}-input`,
|
|
255
|
+
ref: C
|
|
254
256
|
}
|
|
255
257
|
),
|
|
256
|
-
|
|
257
|
-
|
|
258
|
+
o && /* @__PURE__ */ i(
|
|
259
|
+
H,
|
|
258
260
|
{
|
|
259
261
|
className: `${e}__close-button`,
|
|
260
|
-
"data-testid": `${
|
|
261
|
-
onClick:
|
|
262
|
-
"aria-label":
|
|
262
|
+
"data-testid": `${l}-clear-button`,
|
|
263
|
+
onClick: pt,
|
|
264
|
+
"aria-label": I || `${l}-clear`,
|
|
263
265
|
tabIndex: -1,
|
|
264
|
-
variant:
|
|
265
|
-
children: /* @__PURE__ */
|
|
266
|
-
|
|
266
|
+
variant: J.tertiary,
|
|
267
|
+
children: /* @__PURE__ */ i(
|
|
268
|
+
at,
|
|
267
269
|
{
|
|
268
270
|
color: "currentColor",
|
|
269
271
|
height: 18,
|
|
270
272
|
width: 18,
|
|
271
273
|
className: `${e}__icon-button`,
|
|
272
|
-
title:
|
|
274
|
+
title: I || `${l}-clear`
|
|
273
275
|
}
|
|
274
276
|
)
|
|
275
277
|
}
|
|
276
278
|
),
|
|
277
|
-
/* @__PURE__ */
|
|
278
|
-
|
|
279
|
+
/* @__PURE__ */ i(
|
|
280
|
+
H,
|
|
279
281
|
{
|
|
280
|
-
"aria-label":
|
|
282
|
+
"aria-label": N || `${l}-dropdown`,
|
|
281
283
|
className: d(`${e}__dropdown-button`, {
|
|
282
284
|
[`${e}__dropdown-button--open`]: f
|
|
283
285
|
}),
|
|
284
|
-
onClick:
|
|
285
|
-
"data-testid": `${
|
|
286
|
+
onClick: ut,
|
|
287
|
+
"data-testid": `${l}-dropdown`,
|
|
286
288
|
tabIndex: -1,
|
|
287
|
-
variant:
|
|
288
|
-
children: /* @__PURE__ */
|
|
289
|
-
|
|
289
|
+
variant: J.tertiary,
|
|
290
|
+
children: /* @__PURE__ */ i(
|
|
291
|
+
nt,
|
|
290
292
|
{
|
|
291
293
|
color: "currentColor",
|
|
292
294
|
height: 18,
|
|
293
295
|
width: 18,
|
|
294
296
|
className: `${e}__icon-button`,
|
|
295
|
-
title:
|
|
297
|
+
title: N || `${l}-dropdown`
|
|
296
298
|
}
|
|
297
299
|
)
|
|
298
300
|
}
|
|
@@ -300,44 +302,44 @@ const Vt = gt.forwardRef(function({
|
|
|
300
302
|
]
|
|
301
303
|
}
|
|
302
304
|
) }),
|
|
303
|
-
f && /* @__PURE__ */
|
|
304
|
-
|
|
305
|
+
f && /* @__PURE__ */ i(vt, { container: rt?.current || document.body, children: /* @__PURE__ */ i(
|
|
306
|
+
$t,
|
|
305
307
|
{
|
|
306
308
|
className: `${e}__content`,
|
|
307
|
-
"aria-label": z || `${
|
|
309
|
+
"aria-label": z || `${l}-content`,
|
|
308
310
|
side: "bottom",
|
|
309
311
|
sideOffset: -5,
|
|
310
312
|
align: "start",
|
|
311
313
|
alignOffset: 0,
|
|
312
314
|
onFocus: () => {
|
|
313
|
-
document.activeElement !==
|
|
315
|
+
document.activeElement !== C.current && C.current?.focus();
|
|
314
316
|
},
|
|
315
317
|
style: {
|
|
316
318
|
width: y.current?.offsetWidth || "100%"
|
|
317
319
|
},
|
|
318
|
-
children: /* @__PURE__ */
|
|
319
|
-
|
|
320
|
+
children: /* @__PURE__ */ i(bt, { className: `${e}__list`, children: c.length > 0 ? /* @__PURE__ */ i(wt, { className: `${e}__group`, children: c.map((t) => /* @__PURE__ */ i(
|
|
321
|
+
gt,
|
|
320
322
|
{
|
|
321
323
|
className: d(`${e}__item`, {
|
|
322
|
-
[`${e}__item--selected`]:
|
|
324
|
+
[`${e}__item--selected`]: s?.value === t.value
|
|
323
325
|
}),
|
|
324
326
|
value: t.value,
|
|
325
|
-
onSelect: () =>
|
|
326
|
-
...
|
|
327
|
+
onSelect: () => k(t),
|
|
328
|
+
...s?.value === t.value ? { ref: E } : {},
|
|
327
329
|
children: j ? j(t) : m(t)
|
|
328
330
|
},
|
|
329
331
|
t.value
|
|
330
|
-
)) }) : /* @__PURE__ */
|
|
332
|
+
)) }) : /* @__PURE__ */ i("div", { className: `${e}__no-options`, children: ot }) })
|
|
331
333
|
}
|
|
332
334
|
) })
|
|
333
335
|
] })
|
|
334
336
|
}
|
|
335
337
|
),
|
|
336
|
-
|
|
338
|
+
K.validation ? K.validation : /* @__PURE__ */ i("p", { className: d(`${e}__validation`), children: " " })
|
|
337
339
|
] })
|
|
338
340
|
] });
|
|
339
341
|
});
|
|
340
|
-
|
|
342
|
+
Dt.displayName = "ComboBox";
|
|
341
343
|
export {
|
|
342
|
-
|
|
344
|
+
Dt as default
|
|
343
345
|
};
|
|
@@ -12,6 +12,7 @@ export declare const Playground: {
|
|
|
12
12
|
options: ComboBoxOption[];
|
|
13
13
|
id: string;
|
|
14
14
|
labelText: string;
|
|
15
|
+
noOptionsMessage: string;
|
|
15
16
|
};
|
|
16
17
|
argTypes: {
|
|
17
18
|
options: {
|
|
@@ -53,6 +54,12 @@ export declare const Playground: {
|
|
|
53
54
|
value: {
|
|
54
55
|
control: boolean;
|
|
55
56
|
};
|
|
57
|
+
countOfCharsBeforeDropdown: {
|
|
58
|
+
control: string;
|
|
59
|
+
};
|
|
60
|
+
noOptionsMessage: {
|
|
61
|
+
control: string;
|
|
62
|
+
};
|
|
56
63
|
};
|
|
57
64
|
};
|
|
58
65
|
export declare const ComboBoxInDrawer: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import { Root as $, Portal as
|
|
5
|
-
import { VisuallyHidden as
|
|
1
|
+
import { jsx as r, jsxs as n } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as _ } from "react";
|
|
3
|
+
import i from "../../node_modules/classnames/index.js";
|
|
4
|
+
import { Root as $, Portal as b, Overlay as v, Content as w, Title as D, Description as P, Close as B } from "../../node_modules/@radix-ui/react-dialog/dist/index.js";
|
|
5
|
+
import { VisuallyHidden as c } from "../../node_modules/@radix-ui/react-visually-hidden/dist/index.js";
|
|
6
6
|
import { getCommonProps as j, noOp as k } from "../../utils/index.js";
|
|
7
7
|
import H from "./DrawerHeader.js";
|
|
8
8
|
import I from "../IconButton/IconButton.js";
|
|
9
9
|
import { ButtonVariants as R } from "../Button/types.js";
|
|
10
10
|
import V from "../Icon/Icon.js";
|
|
11
|
-
const g =
|
|
11
|
+
const g = _(
|
|
12
12
|
({
|
|
13
13
|
isOpen: d,
|
|
14
14
|
onClose: t = k,
|
|
15
|
-
headerText:
|
|
15
|
+
headerText: e,
|
|
16
16
|
title: m,
|
|
17
|
-
description:
|
|
18
|
-
drawerOpenSide:
|
|
19
|
-
paddingLevel:
|
|
20
|
-
className:
|
|
21
|
-
children:
|
|
17
|
+
description: p = m,
|
|
18
|
+
drawerOpenSide: a = "right",
|
|
19
|
+
paddingLevel: s,
|
|
20
|
+
className: f,
|
|
21
|
+
children: h,
|
|
22
22
|
...l
|
|
23
|
-
},
|
|
24
|
-
const { className: o, ...
|
|
25
|
-
return
|
|
23
|
+
}, u) => {
|
|
24
|
+
const { className: o, ...C } = j(l, "Drawer"), y = a === "bottom";
|
|
25
|
+
return s ?? (s = e ? 1 : 2), /* @__PURE__ */ r(
|
|
26
26
|
$,
|
|
27
27
|
{
|
|
28
28
|
open: d,
|
|
29
|
-
onOpenChange: (
|
|
30
|
-
|
|
29
|
+
onOpenChange: (N) => {
|
|
30
|
+
N || (document.body.style.removeProperty("pointer-events"), t());
|
|
31
31
|
},
|
|
32
|
-
children: /* @__PURE__ */
|
|
33
|
-
/* @__PURE__ */ r(
|
|
34
|
-
/* @__PURE__ */
|
|
35
|
-
|
|
32
|
+
children: /* @__PURE__ */ n(b, { children: [
|
|
33
|
+
/* @__PURE__ */ r(v, { onClick: t, className: `${o}__overlay`, "data-testid": "drawer-overlay" }),
|
|
34
|
+
/* @__PURE__ */ n(
|
|
35
|
+
w,
|
|
36
36
|
{
|
|
37
|
-
className:
|
|
38
|
-
[`${o}--bottom`]:
|
|
37
|
+
className: i(o, f, {
|
|
38
|
+
[`${o}--bottom`]: y
|
|
39
39
|
}),
|
|
40
|
-
"data-side":
|
|
40
|
+
"data-side": a,
|
|
41
41
|
id: l.id,
|
|
42
|
-
ref:
|
|
43
|
-
...
|
|
42
|
+
ref: u,
|
|
43
|
+
...C,
|
|
44
44
|
children: [
|
|
45
|
-
/* @__PURE__ */ r(
|
|
46
|
-
/* @__PURE__ */ r(
|
|
47
|
-
|
|
45
|
+
/* @__PURE__ */ r(c, { asChild: !0, children: /* @__PURE__ */ r(D, { children: m }) }),
|
|
46
|
+
/* @__PURE__ */ r(c, { asChild: !0, children: /* @__PURE__ */ r(P, { children: p }) }),
|
|
47
|
+
e ? /* @__PURE__ */ r(
|
|
48
48
|
H,
|
|
49
49
|
{
|
|
50
50
|
baseClassName: o,
|
|
51
|
-
headerText:
|
|
51
|
+
headerText: e,
|
|
52
52
|
onClose: t,
|
|
53
|
-
drawerOpenSide:
|
|
53
|
+
drawerOpenSide: a
|
|
54
54
|
}
|
|
55
|
-
) : /* @__PURE__ */ r(
|
|
55
|
+
) : /* @__PURE__ */ r(B, { asChild: !0, children: /* @__PURE__ */ r(
|
|
56
56
|
I,
|
|
57
57
|
{
|
|
58
58
|
onClick: t,
|
|
59
|
-
className:
|
|
59
|
+
className: i(`${o}__close`),
|
|
60
60
|
"aria-label": "Close",
|
|
61
61
|
"data-testid": "drawer-close",
|
|
62
62
|
variant: R.tertiary,
|
|
@@ -66,11 +66,11 @@ const g = y(
|
|
|
66
66
|
/* @__PURE__ */ r(
|
|
67
67
|
"div",
|
|
68
68
|
{
|
|
69
|
-
className:
|
|
69
|
+
className: i(
|
|
70
70
|
`${o}__content`,
|
|
71
|
-
|
|
71
|
+
s < 3 && `${o}__content--ep${s}`
|
|
72
72
|
),
|
|
73
|
-
children:
|
|
73
|
+
children: h
|
|
74
74
|
}
|
|
75
75
|
)
|
|
76
76
|
]
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
import { jsx as o, jsxs as
|
|
1
|
+
import { jsx as o, jsxs as a } from "react/jsx-runtime";
|
|
2
2
|
import t from "../../node_modules/classnames/index.js";
|
|
3
|
-
import { getCommonProps as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { ButtonVariants as
|
|
7
|
-
import { Root as
|
|
3
|
+
import { getCommonProps as v, noOp as N } from "../../utils/index.js";
|
|
4
|
+
import _ from "../Icon/Icon.js";
|
|
5
|
+
import M from "../IconButton/IconButton.js";
|
|
6
|
+
import { ButtonVariants as b } from "../Button/types.js";
|
|
7
|
+
import { Root as g, Portal as P, Overlay as x, Content as I, Title as O, Description as $, Close as j } from "../../node_modules/@radix-ui/react-dialog/dist/index.js";
|
|
8
8
|
import { VisuallyHidden as w } from "../../node_modules/@radix-ui/react-visually-hidden/dist/index.js";
|
|
9
9
|
import { forwardRef as B } from "react";
|
|
10
10
|
const R = B(
|
|
11
11
|
({
|
|
12
12
|
children: l,
|
|
13
|
-
className:
|
|
14
|
-
overlayClassName:
|
|
13
|
+
className: s,
|
|
14
|
+
overlayClassName: i,
|
|
15
15
|
isOpen: m = !1,
|
|
16
|
-
onClose:
|
|
17
|
-
style:
|
|
16
|
+
onClose: n = N,
|
|
17
|
+
style: d,
|
|
18
18
|
contentLabel: c,
|
|
19
|
-
closeIcon:
|
|
20
|
-
closeIconPosition:
|
|
21
|
-
...
|
|
19
|
+
closeIcon: p = /* @__PURE__ */ o(_, { icon: "CloseX", height: 32, width: 32, color: "currentColor" }),
|
|
20
|
+
closeIconPosition: f = "right",
|
|
21
|
+
...r
|
|
22
22
|
}, h) => {
|
|
23
|
-
const { className:
|
|
23
|
+
const { className: e, "data-testid": u, ...C } = v(r, "Modal");
|
|
24
24
|
return /* @__PURE__ */ o(
|
|
25
|
-
|
|
25
|
+
g,
|
|
26
26
|
{
|
|
27
27
|
open: m,
|
|
28
28
|
onOpenChange: (y) => {
|
|
29
|
-
y ||
|
|
29
|
+
y || (document.body.style.removeProperty("pointer-events"), n());
|
|
30
30
|
},
|
|
31
|
-
children: /* @__PURE__ */
|
|
31
|
+
children: /* @__PURE__ */ a(P, { children: [
|
|
32
32
|
/* @__PURE__ */ o(
|
|
33
|
-
|
|
33
|
+
x,
|
|
34
34
|
{
|
|
35
|
-
className: t(`${
|
|
35
|
+
className: t(`${e}__overlay`, i),
|
|
36
36
|
"data-testid": "modal-overlay"
|
|
37
37
|
}
|
|
38
38
|
),
|
|
39
|
-
/* @__PURE__ */
|
|
40
|
-
|
|
39
|
+
/* @__PURE__ */ a(
|
|
40
|
+
I,
|
|
41
41
|
{
|
|
42
42
|
ref: h,
|
|
43
|
-
className: t(
|
|
43
|
+
className: t(e, s),
|
|
44
44
|
"data-testid": u,
|
|
45
45
|
"aria-modal": "true",
|
|
46
|
-
style:
|
|
46
|
+
style: d,
|
|
47
47
|
...C,
|
|
48
|
-
...
|
|
48
|
+
...r,
|
|
49
49
|
children: [
|
|
50
|
-
/* @__PURE__ */ o(w, { asChild: !0, children: /* @__PURE__ */ o(
|
|
50
|
+
/* @__PURE__ */ o(w, { asChild: !0, children: /* @__PURE__ */ o(O, { children: c ?? "Modal" }) }),
|
|
51
51
|
/* @__PURE__ */ o($, {}),
|
|
52
52
|
/* @__PURE__ */ o(j, { asChild: !0, children: /* @__PURE__ */ o(
|
|
53
|
-
|
|
53
|
+
M,
|
|
54
54
|
{
|
|
55
55
|
id: "modal-close-button",
|
|
56
56
|
"aria-label": "Close Modal",
|
|
57
|
-
className: t(`${
|
|
58
|
-
[`${
|
|
57
|
+
className: t(`${e}__close`, {
|
|
58
|
+
[`${e}__close--left`]: f === "left"
|
|
59
59
|
}),
|
|
60
|
-
variant:
|
|
61
|
-
children:
|
|
60
|
+
variant: b.tertiary,
|
|
61
|
+
children: p
|
|
62
62
|
}
|
|
63
63
|
) }),
|
|
64
64
|
l
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { useToastContext as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { useToastContext as a } from "./useToastContext.js";
|
|
2
|
+
import { useCallback as o } from "react";
|
|
3
|
+
const c = () => {
|
|
4
|
+
const { addToast: e } = a();
|
|
5
|
+
return o(
|
|
6
|
+
(t) => {
|
|
7
|
+
typeof t == "object" && t !== null && "title" in t ? e(t) : e({ title: t });
|
|
8
|
+
},
|
|
9
|
+
[e]
|
|
10
|
+
);
|
|
7
11
|
};
|
|
8
12
|
export {
|
|
9
|
-
|
|
13
|
+
c as useToast
|
|
10
14
|
};
|