@alixpartners/ui-components 2.0.1 → 2.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.
- package/README.md +99 -99
- package/dist/assets/Creatable.css +1 -0
- package/dist/assets/Dialog.css +1 -1
- package/dist/assets/Dropdown.css +1 -1
- package/dist/assets/FilePicker.css +1 -0
- package/dist/assets/Input.css +1 -1
- package/dist/assets/NavBar.css +1 -1
- package/dist/assets/TagsFields.css +1 -0
- package/dist/assets/Textarea.css +1 -1
- package/dist/components/Banner/Banner.test.js +1 -1
- package/dist/components/Button/Button.d.ts +2 -1
- package/dist/components/Button/Button.js +16 -15
- package/dist/components/Button/Button.test.js +3218 -120
- package/dist/components/Checkbox/Checkbox.test.js +1 -1
- package/dist/components/Creatable/Creatable.d.ts +20 -8
- package/dist/components/Creatable/Creatable.js +228 -31
- package/dist/components/Dialog/Dialog.d.ts +1 -0
- package/dist/components/Dialog/Dialog.js +20 -19
- package/dist/components/Dropdown/Dropdown.d.ts +1 -5
- package/dist/components/Dropdown/Dropdown.js +197 -473
- package/dist/components/FilePicker/FilePicker.d.ts +46 -0
- package/dist/components/FilePicker/FilePicker.js +153 -0
- package/dist/components/FilePicker/FilePicker.test.d.ts +1 -0
- package/dist/components/FilePicker/FilePicker.test.js +8 -0
- package/dist/components/Ghost/Ghost.test.js +1 -1
- package/dist/components/Input/Input.test.js +1 -1
- package/dist/components/RadioGroup/RadioGroup.test.js +1 -1
- package/dist/components/Search/Search.test.js +1 -1
- package/dist/components/SplitButton/SplitButton.js +4 -3
- package/dist/components/SplitButton/SplitButton.test.js +1 -1
- package/dist/components/Tag/Tag.test.js +1 -1
- package/dist/components/TagsFields/TagsFields.d.ts +22 -7
- package/dist/components/TagsFields/TagsFields.js +227 -16
- package/dist/components/Textarea/Textarea.test.js +1 -1
- package/dist/components/Toast/Toast.test.js +1 -1
- package/dist/components/Toggle/Toggle.test.js +1 -1
- package/dist/index-BKtdMA_j.js +226 -0
- package/dist/{vi.ClIskdbk-DlR4jLzR.js → vi.ClIskdbk-CFW_9sOK.js} +1 -0
- package/dist/web.config +8 -8
- package/package.json +84 -84
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { d, i as h, r as n, g as c, s as o, v as b, f as a } from "../../vi.ClIskdbk-
|
|
2
|
+
import { d, i as h, r as n, g as c, s as o, v as b, f as a } from "../../vi.ClIskdbk-CFW_9sOK.js";
|
|
3
3
|
import l from "./Checkbox.js";
|
|
4
4
|
d("Checkbox", () => {
|
|
5
5
|
d("Rendering", () => {
|
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
import { DataAttributes } from '../../types/data-attributes';
|
|
2
|
-
import { DropdownOption } from '../Dropdown/Dropdown';
|
|
2
|
+
import { DropdownOption, LabelTooltipProps } from '../Dropdown/Dropdown';
|
|
3
3
|
import { InteractiveEventHandlers } from '../../types/native-events';
|
|
4
4
|
type CreatableProps = {
|
|
5
5
|
className?: string;
|
|
6
|
-
label
|
|
7
|
-
required?: boolean;
|
|
6
|
+
label?: string;
|
|
8
7
|
options: DropdownOption[];
|
|
9
|
-
multiSelect?: boolean;
|
|
10
8
|
value?: string[];
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
maxLength?: number;
|
|
12
|
+
searchPlaceholder?: string;
|
|
13
|
+
errorMessage?: string;
|
|
11
14
|
helpText?: string;
|
|
12
15
|
helpLink?: string;
|
|
13
16
|
helpLinkText?: string;
|
|
14
|
-
disabled?: boolean;
|
|
15
|
-
caseSensitive?: boolean;
|
|
16
|
-
errorMessage?: string;
|
|
17
17
|
onChange?: (selectedValues: string[]) => void;
|
|
18
|
+
onSearch?: (searchTerm: string) => void;
|
|
19
|
+
grouped?: boolean;
|
|
20
|
+
multiSelect?: boolean;
|
|
21
|
+
align?: 'left' | 'right';
|
|
22
|
+
dropdownMenuClassName?: string;
|
|
23
|
+
hideSelectedItems?: boolean;
|
|
24
|
+
labelTooltip?: LabelTooltipProps;
|
|
25
|
+
unselect?: boolean;
|
|
26
|
+
selectedOptionLabel?: string;
|
|
27
|
+
selectedOptionsLabel?: string;
|
|
28
|
+
allOptionsSelectedLabel?: string;
|
|
29
|
+
caseSensitive?: boolean;
|
|
18
30
|
} & DataAttributes & InteractiveEventHandlers;
|
|
19
31
|
/**
|
|
20
32
|
* A dropdown input that lets users create new items on the fly.
|
|
@@ -38,5 +50,5 @@ type CreatableProps = {
|
|
|
38
50
|
* @param {DataAttributes} [props.data-*] - Additional `data-` attributes forwarded to the root element
|
|
39
51
|
* @returns {JSX.Element} The rendered Creatable component
|
|
40
52
|
*/
|
|
41
|
-
export default function Creatable({ className, label,
|
|
53
|
+
export default function Creatable({ className, label, options, value, disabled, required, maxLength, searchPlaceholder, errorMessage, helpText, helpLink, helpLinkText, onChange, onSearch, multiSelect, grouped, align, dropdownMenuClassName, labelTooltip, unselect, selectedOptionsLabel, allOptionsSelectedLabel, caseSensitive, ...props }: CreatableProps): import("react/jsx-runtime").JSX.Element;
|
|
42
54
|
export {};
|
|
@@ -1,35 +1,232 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
import { jsxs as w, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { c as C } from "../../clsx-OuTLNxxd.js";
|
|
3
|
+
import { useContext as Ie, useState as A, useRef as R, useEffect as V, useCallback as ae } from "react";
|
|
4
|
+
import B from "../Icon/Icon.js";
|
|
5
|
+
import ve from "../Button/Button.js";
|
|
6
|
+
import "../Input/Input.js";
|
|
7
|
+
import Le from "../Tooltip/Tooltip.js";
|
|
8
|
+
import { DialogContext as Ne } from "../Dialog/Dialog.js";
|
|
9
|
+
import { R as ge, A as De, P as ye, C as xe } from "../../index-BKtdMA_j.js";
|
|
10
|
+
import '../../assets/Creatable.css';const ke = "Creatable-module__dropdownContainer___y0ptC", Oe = "Creatable-module__dropdownLabel___RyuSY", Ae = "Creatable-module__dropdownLabelDisabled___nhYc0", Re = "Creatable-module__required___g26DB", Ve = "Creatable-module__dropdownWrapper___wu-B3", Ee = "Creatable-module__selectedItemsCreatable___P0mME", Fe = "Creatable-module__selectedItem___0LADh", Se = "Creatable-module__selectedItemLabel___m0LSV", Me = "Creatable-module__removeButton___tjxwh", Be = "Creatable-module__removeIcon___KQKbD", Ge = "Creatable-module__singleSelectedCreatableItem___tanxX", Ke = "Creatable-module__singleSelectedCreatableItemRemoveButton___Qi9Si", je = "Creatable-module__dropdownActions___FmHZe", Ue = "Creatable-module__dropdownArrow___SJmKg", We = "Creatable-module__dropdownArrowOpen___T3E0S", $e = "Creatable-module__dropdownMenu___HEhC3", Je = "Creatable-module__dropdownCreatableSearchContainer___AgXA3", Pe = "Creatable-module__disabled___ZIdus", Ye = "Creatable-module__dropdownCreatableError___FYVla", qe = "Creatable-module__creatableInput___KaKxv", ze = "Creatable-module__optionsList___VZgJf", Qe = "Creatable-module__categoryGroup___g8f-g", Ze = "Creatable-module__categoryDivider___QUgR9", He = "Creatable-module__categoryLabel___YhGp9", Te = "Creatable-module__optionItem___Ys808", Xe = "Creatable-module__optionItemDisabled___jvfGz", et = "Creatable-module__optionItemFocused___OfIQd", tt = "Creatable-module__optionContent___9RCsJ", ot = "Creatable-module__optionLabel___FJfM1", lt = "Creatable-module__tickIcon___VjpDN", at = "Creatable-module__helpers___GmPY4", rt = "Creatable-module__helpText___89mXU", nt = "Creatable-module__helpTextDisabled___shU6E", st = "Creatable-module__helpLink___IdU0g", dt = "Creatable-module__helpLinkDisabled___B8rpy", ct = "Creatable-module__errorMessage___HRKr5", t = {
|
|
11
|
+
dropdownContainer: ke,
|
|
12
|
+
dropdownLabel: Oe,
|
|
13
|
+
"label-text": "Creatable-module__label-text___jlV2x",
|
|
14
|
+
dropdownLabelDisabled: Ae,
|
|
15
|
+
"label-tooltip-icon": "Creatable-module__label-tooltip-icon___G7Bou",
|
|
16
|
+
required: Re,
|
|
17
|
+
dropdownWrapper: Ve,
|
|
18
|
+
selectedItemsCreatable: Ee,
|
|
19
|
+
selectedItem: Fe,
|
|
20
|
+
selectedItemLabel: Se,
|
|
21
|
+
removeButton: Me,
|
|
22
|
+
removeIcon: Be,
|
|
23
|
+
singleSelectedCreatableItem: Ge,
|
|
24
|
+
singleSelectedCreatableItemRemoveButton: Ke,
|
|
25
|
+
dropdownActions: je,
|
|
26
|
+
dropdownArrow: Ue,
|
|
27
|
+
dropdownArrowOpen: We,
|
|
28
|
+
dropdownMenu: $e,
|
|
29
|
+
"dropdown-container-grouped": "Creatable-module__dropdown-container-grouped___gZle-",
|
|
30
|
+
"dropdown-container-multi-select": "Creatable-module__dropdown-container-multi-select___1U1U4",
|
|
31
|
+
dropdownCreatableSearchContainer: Je,
|
|
32
|
+
disabled: Pe,
|
|
33
|
+
dropdownCreatableError: Ye,
|
|
34
|
+
creatableInput: qe,
|
|
35
|
+
optionsList: ze,
|
|
36
|
+
categoryGroup: Qe,
|
|
37
|
+
categoryDivider: Ze,
|
|
38
|
+
categoryLabel: He,
|
|
39
|
+
optionItem: Te,
|
|
40
|
+
optionItemDisabled: Xe,
|
|
41
|
+
optionItemFocused: et,
|
|
42
|
+
optionContent: tt,
|
|
43
|
+
optionLabel: ot,
|
|
44
|
+
tickIcon: lt,
|
|
45
|
+
helpers: at,
|
|
46
|
+
helpText: rt,
|
|
47
|
+
helpTextDisabled: nt,
|
|
48
|
+
helpLink: st,
|
|
49
|
+
helpLinkDisabled: dt,
|
|
50
|
+
errorMessage: ct
|
|
51
|
+
};
|
|
52
|
+
function ht({
|
|
53
|
+
className: re,
|
|
54
|
+
label: G,
|
|
55
|
+
options: y,
|
|
56
|
+
value: x = [],
|
|
57
|
+
disabled: v = !1,
|
|
58
|
+
required: ne = !1,
|
|
59
|
+
maxLength: se,
|
|
60
|
+
searchPlaceholder: de = "Search options...",
|
|
61
|
+
errorMessage: E,
|
|
62
|
+
helpText: K,
|
|
63
|
+
helpLink: J,
|
|
64
|
+
helpLinkText: P,
|
|
65
|
+
onChange: r,
|
|
66
|
+
onSearch: k,
|
|
67
|
+
multiSelect: m = !1,
|
|
68
|
+
grouped: ce = !1,
|
|
69
|
+
align: Y = "left",
|
|
70
|
+
dropdownMenuClassName: ie,
|
|
71
|
+
labelTooltip: L,
|
|
72
|
+
unselect: q = !1,
|
|
73
|
+
selectedOptionsLabel: z = "options selected",
|
|
74
|
+
allOptionsSelectedLabel: F,
|
|
75
|
+
caseSensitive: j = !1,
|
|
76
|
+
..._e
|
|
30
77
|
}) {
|
|
31
|
-
|
|
78
|
+
const ue = Ie(Ne), [u, N] = A(x), [c, h] = A(!1), [Q, b] = A(""), [f, i] = A(-1), Z = R(null), O = R(null), g = R(null), H = R(null), [T, pe] = A(0), X = R(x);
|
|
79
|
+
V(() => {
|
|
80
|
+
JSON.stringify(X.current) !== JSON.stringify(x) && (N(x), X.current = x);
|
|
81
|
+
}, [x]), V(() => {
|
|
82
|
+
var a;
|
|
83
|
+
const e = (a = O.current) == null ? void 0 : a.getBoundingClientRect().width;
|
|
84
|
+
e && pe(e);
|
|
85
|
+
}, []);
|
|
86
|
+
const _ = Q.trim(), p = y.filter((e) => {
|
|
87
|
+
const a = j ? e.label : e.label.toLowerCase(), o = j ? _ : _.toLowerCase();
|
|
88
|
+
return a.includes(o);
|
|
89
|
+
}), S = _ !== "" && !y.find((e) => j ? e.label === _ : e.label.toLowerCase() === _.toLowerCase());
|
|
90
|
+
V(() => {
|
|
91
|
+
c && g.current && g.current.focus();
|
|
92
|
+
}, [c]);
|
|
93
|
+
const me = (e) => {
|
|
94
|
+
h(e), b(""), i(-1);
|
|
95
|
+
}, U = ae((e) => {
|
|
96
|
+
var o, n;
|
|
97
|
+
const a = {
|
|
98
|
+
value: e,
|
|
99
|
+
label: e,
|
|
100
|
+
disabled: !1
|
|
101
|
+
};
|
|
102
|
+
if (y.push(a), m) {
|
|
103
|
+
const D = u.includes(e) ? u : [...u, e];
|
|
104
|
+
N(D), r == null || r(D), (o = g.current) == null || o.focus(), b(""), h(!0), i(-1);
|
|
105
|
+
} else {
|
|
106
|
+
const d = [e];
|
|
107
|
+
N(d), r == null || r(d), b(""), (n = O.current) == null || n.focus(), h(!1), i(-1);
|
|
108
|
+
}
|
|
109
|
+
}, [m, r, y, u]), W = ae((e) => {
|
|
110
|
+
var a, o, n;
|
|
111
|
+
if (!e.disabled)
|
|
112
|
+
if (m) {
|
|
113
|
+
const D = u.includes(e.value) ? u.filter((he) => he !== e.value) : [...u, e.value];
|
|
114
|
+
N(D), r == null || r(D), h(!0), (a = g.current) == null || a.focus(), b(""), i(-1);
|
|
115
|
+
} else if (u.includes(e.value)) {
|
|
116
|
+
if (q) {
|
|
117
|
+
const d = [];
|
|
118
|
+
N(d), r == null || r(d), (o = O.current) == null || o.focus(), h(!1), b(""), i(-1);
|
|
119
|
+
}
|
|
120
|
+
} else {
|
|
121
|
+
const d = [e.value];
|
|
122
|
+
N(d), r == null || r(d), (n = O.current) == null || n.focus(), h(!1), b(""), i(-1);
|
|
123
|
+
}
|
|
124
|
+
}, [m, r, u, q]), be = (e) => {
|
|
125
|
+
h(!0), b(e), i(-1), k == null || k(e);
|
|
126
|
+
}, $ = (e) => {
|
|
127
|
+
h(!0), b(e), i(-1), k == null || k(e);
|
|
128
|
+
}, ee = (e) => {
|
|
129
|
+
const a = u.filter((o) => o !== e);
|
|
130
|
+
N(a), r == null || r(a);
|
|
131
|
+
};
|
|
132
|
+
V(() => {
|
|
133
|
+
const e = (a) => {
|
|
134
|
+
if (!c) return;
|
|
135
|
+
const o = p.length + (S ? 1 : 0);
|
|
136
|
+
if (o !== 0)
|
|
137
|
+
switch (a.key) {
|
|
138
|
+
case "ArrowDown":
|
|
139
|
+
a.preventDefault(), i((n) => n < 0 ? 0 : n < o - 1 ? n + 1 : 0);
|
|
140
|
+
break;
|
|
141
|
+
case "ArrowUp":
|
|
142
|
+
a.preventDefault(), i((n) => n < 0 ? o - 1 : n > 0 ? n - 1 : o - 1);
|
|
143
|
+
break;
|
|
144
|
+
case "Enter":
|
|
145
|
+
if (a.preventDefault(), f >= 0 && f < p.length) {
|
|
146
|
+
const n = p[f];
|
|
147
|
+
W(n);
|
|
148
|
+
} else S && f === p.length && U(_);
|
|
149
|
+
break;
|
|
150
|
+
case "Escape":
|
|
151
|
+
a.preventDefault(), h(!1), b(""), i(-1);
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
156
|
+
}, [f, p, U, W, S, c, _]), V(() => {
|
|
157
|
+
if (!c || f < 0) return;
|
|
158
|
+
const e = H.current, a = e == null ? void 0 : e.querySelector(`[data-option-index="${f}"]`);
|
|
159
|
+
e && a && a.scrollIntoView({
|
|
160
|
+
block: "nearest"
|
|
161
|
+
});
|
|
162
|
+
}, [c, f]);
|
|
163
|
+
const M = u, s = y.filter((e) => M.includes(e.value)), fe = !!E, te = y.filter((e) => !e.disabled), oe = te.length > 0 && te.every((e) => M.includes(e.value)), we = p.reduce((e, a) => {
|
|
164
|
+
const o = a.category || "default";
|
|
165
|
+
return e[o] || (e[o] = []), e[o].push(a), e;
|
|
166
|
+
}, {}), Ce = p, {
|
|
167
|
+
onBlur: I,
|
|
168
|
+
...le
|
|
169
|
+
} = _e;
|
|
170
|
+
return /* @__PURE__ */ w("div", { ref: Z, className: C(t.dropdownContainer, ce && t["dropdown-container-grouped"], m && t["dropdown-container-multi-select"], re), ...le, children: [
|
|
171
|
+
G && /* @__PURE__ */ w("label", { className: C(t.dropdownLabel, v && t.dropdownLabelDisabled), children: [
|
|
172
|
+
/* @__PURE__ */ l("span", { title: G, className: t["label-text"], children: G }),
|
|
173
|
+
ne && /* @__PURE__ */ l("span", { className: t.required, children: "*" }),
|
|
174
|
+
L && /* @__PURE__ */ l(Le, { content: L.content, size: L.size, theme: L.theme, tipSide: L.tipSide, tipAlignment: L.tipAlignment, startVisible: L.startVisible, children: /* @__PURE__ */ l(B, { icon: "ap-icon-info", className: t["label-tooltip-icon"] }) })
|
|
175
|
+
] }),
|
|
176
|
+
/* @__PURE__ */ l(ge, { open: c, onOpenChange: me, children: /* @__PURE__ */ w("div", { className: t.dropdownWrapper, children: [
|
|
177
|
+
/* @__PURE__ */ l(De, { children: /* @__PURE__ */ w("div", { tabIndex: !m && s.length > 0 ? 0 : -1, ref: O, className: C(t.dropdownCreatableSearchContainer, v && t.disabled, fe && t.dropdownCreatableError), onBlur: (e) => {
|
|
178
|
+
c || I == null || I(e);
|
|
179
|
+
}, onClick: () => {
|
|
180
|
+
var e;
|
|
181
|
+
if (!m && s.length > 0)
|
|
182
|
+
return $("");
|
|
183
|
+
(e = g.current) == null || e.focus();
|
|
184
|
+
}, onKeyDown: (e) => {
|
|
185
|
+
if (e.key === "Enter" && !m && s.length > 0 && !c)
|
|
186
|
+
return $("");
|
|
187
|
+
}, ...le, children: [
|
|
188
|
+
s.length > 0 && /* @__PURE__ */ l("div", { className: C(t.selectedItemsCreatable), children: m ? s.length > 3 ? /* @__PURE__ */ l("div", { className: t.selectedItem, children: /* @__PURE__ */ l("span", { className: t.selectedItemLabel, title: oe && F ? F : `${s.length} ${z}`, children: oe && F ? F : `${s.length} ${z}` }) }) : s.map((e) => /* @__PURE__ */ w("div", { className: t.selectedItem, children: [
|
|
189
|
+
/* @__PURE__ */ l("span", { className: t.selectedItemLabel, title: e.label, children: e.label }),
|
|
190
|
+
/* @__PURE__ */ l("button", { type: "button", className: t.removeButton, onClick: () => ee(e.value), disabled: v, children: /* @__PURE__ */ l(B, { icon: "ap-icon-close", className: t.removeIcon }) })
|
|
191
|
+
] }, e.value)) : s.length > 0 && /* @__PURE__ */ w("div", { className: t.singleSelectedCreatableItem, children: [
|
|
192
|
+
/* @__PURE__ */ l("span", { className: t.selectedItemLabel, title: s[0].label, children: s[0].label }),
|
|
193
|
+
/* @__PURE__ */ l(ve, { type: "tertiary", variant: "default", size: "sm", onClick: () => ee(s[0].value), disabled: v, icon: "ap-icon-add-filled", className: t.singleSelectedCreatableItemRemoveButton })
|
|
194
|
+
] }) }),
|
|
195
|
+
(m || !s.length) && /* @__PURE__ */ l("input", { maxLength: se, ref: g, placeholder: s.length > 0 ? "" : de, value: Q, onChange: (e) => be(e.target.value), onFocus: (e) => $(e.target.value), onBlur: (e) => {
|
|
196
|
+
c || I == null || I(e);
|
|
197
|
+
}, disabled: v, className: t.creatableInput }),
|
|
198
|
+
/* @__PURE__ */ l("div", { className: t.dropdownActions, children: /* @__PURE__ */ l(B, { icon: "ap-icon-expand-more", className: C(t.dropdownArrow, c && t.dropdownArrowOpen) }) })
|
|
199
|
+
] }) }),
|
|
200
|
+
/* @__PURE__ */ l(ye, { container: ue, children: /* @__PURE__ */ l(xe, { onOpenAutoFocus: (e) => {
|
|
201
|
+
e.preventDefault();
|
|
202
|
+
}, align: Y === "right" ? "end" : "start", side: "bottom", avoidCollisions: !0, sideOffset: 6, collisionPadding: 8, style: {
|
|
203
|
+
width: T,
|
|
204
|
+
zIndex: 9999
|
|
205
|
+
}, onInteractOutside: (e) => {
|
|
206
|
+
var o;
|
|
207
|
+
e.target === g.current && e.preventDefault(), ((o = Z.current) == null ? void 0 : o.contains(e.target)) || I == null || I(e);
|
|
208
|
+
}, children: c && /* @__PURE__ */ l("div", { style: {
|
|
209
|
+
width: T
|
|
210
|
+
}, className: C(t.dropdownMenu, ie, Y === "right" && t.dropdownMenuRight), children: /* @__PURE__ */ w("div", { ref: H, className: t.optionsList, "data-dropdown-options-list": !0, children: [
|
|
211
|
+
p.length > 0 ? Object.entries(we).map(([e, a]) => /* @__PURE__ */ w("div", { className: t.categoryGroup, children: [
|
|
212
|
+
e !== "default" && /* @__PURE__ */ l("div", { className: t.categoryDivider, children: /* @__PURE__ */ l("span", { className: t.categoryLabel, children: e }) }),
|
|
213
|
+
a.map((o) => {
|
|
214
|
+
const n = Ce.indexOf(o), d = p.find((D) => D.value === o.value);
|
|
215
|
+
return /* @__PURE__ */ l("button", { title: (d == null ? void 0 : d.label) || o.label, type: "button", className: C(t.optionItem, M.includes(o.value) && t.optionItemSelected, o.disabled && t.optionItemDisabled, n === f && t.optionItemFocused), onClick: () => W(o), disabled: o.disabled, "data-dropdown-option-item": !0, "data-option-index": n, children: /* @__PURE__ */ w("div", { className: t.optionContent, children: [
|
|
216
|
+
/* @__PURE__ */ l("span", { className: t.optionLabel, children: o.label }),
|
|
217
|
+
M.includes(o.value) && /* @__PURE__ */ l(B, { icon: "ap-icon-check", className: t.tickIcon })
|
|
218
|
+
] }) }, o.value);
|
|
219
|
+
})
|
|
220
|
+
] }, e)) : null,
|
|
221
|
+
S && /* @__PURE__ */ l("button", { type: "button", className: C(t.optionItem, t.optionItemCreatable, f === p.length && t.optionItemFocused), title: _ ? `Create "${_}"` : "Create new option", "data-option-index": p.length, onClick: () => U(_), children: /* @__PURE__ */ l("div", { className: t.optionContent, children: /* @__PURE__ */ l("span", { className: t.optionLabel, children: _ ? `Create "${_}"` : "Create new option" }) }) })
|
|
222
|
+
] }) }) }) })
|
|
223
|
+
] }) }),
|
|
224
|
+
/* @__PURE__ */ w("div", { className: t.helpers, children: [
|
|
225
|
+
E ? /* @__PURE__ */ l("span", { title: E, className: t.errorMessage, children: E }) : K && /* @__PURE__ */ l("span", { title: K, className: C(t.helpText, v && t.helpTextDisabled), children: K }),
|
|
226
|
+
J && P && /* @__PURE__ */ l("a", { href: J, className: C(t.helpLink, v && t.helpLinkDisabled), target: "_blank", rel: "noopener noreferrer", children: P })
|
|
227
|
+
] })
|
|
228
|
+
] });
|
|
32
229
|
}
|
|
33
230
|
export {
|
|
34
|
-
|
|
231
|
+
ht as default
|
|
35
232
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DataAttributes } from '../../types/data-attributes';
|
|
2
2
|
import { ApIcon } from '../../assets/ap-icons-types';
|
|
3
|
+
export declare const DialogContext: import('react').Context<HTMLElement | null>;
|
|
3
4
|
/**
|
|
4
5
|
* Dialog component that displays modal content with customizable actions and optional illustration.
|
|
5
6
|
* Provides a native HTML dialog element with backdrop support, confirmation/cancellation actions, and accessibility features.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as c, jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as h, useEffect as
|
|
2
|
+
import { createContext as I, useRef as h, useEffect as P } from "react";
|
|
3
3
|
import f from "../Button/Button.js";
|
|
4
4
|
import H from "../Icon/Icon.js";
|
|
5
5
|
import '../../assets/Dialog.css';const J = "Dialog-module__dialog___r4ljx", a = {
|
|
@@ -11,38 +11,38 @@ import '../../assets/Dialog.css';const J = "Dialog-module__dialog___r4ljx", a =
|
|
|
11
11
|
"dialog-buttons": "Dialog-module__dialog-buttons___x-v2M",
|
|
12
12
|
"dialog-close-button": "Dialog-module__dialog-close-button___-PzEz",
|
|
13
13
|
"dialog-close-button-icon": "Dialog-module__dialog-close-button-icon___BeGg2"
|
|
14
|
-
};
|
|
15
|
-
function
|
|
14
|
+
}, K = I(null);
|
|
15
|
+
function F({
|
|
16
16
|
children: g,
|
|
17
17
|
isOpen: d,
|
|
18
18
|
onClose: l,
|
|
19
19
|
title: v,
|
|
20
|
-
description:
|
|
20
|
+
description: D,
|
|
21
21
|
illustrationSrc: s,
|
|
22
22
|
confirmButtonText: _,
|
|
23
|
-
cancelButtonText:
|
|
24
|
-
confirmButtonType:
|
|
23
|
+
cancelButtonText: n,
|
|
24
|
+
confirmButtonType: b = "primary",
|
|
25
25
|
cancelButtonType: p = "primary",
|
|
26
26
|
confirmButtonVariant: N = "default",
|
|
27
27
|
cancelButtonVariant: k = "cancel",
|
|
28
|
-
confirmButtonSize:
|
|
29
|
-
cancelButtonSize:
|
|
30
|
-
confirmButtonIcon:
|
|
31
|
-
cancelButtonIcon:
|
|
28
|
+
confirmButtonSize: x = "md",
|
|
29
|
+
cancelButtonSize: y = "md",
|
|
30
|
+
confirmButtonIcon: z,
|
|
31
|
+
cancelButtonIcon: j,
|
|
32
32
|
onConfirm: e,
|
|
33
33
|
onCancel: r,
|
|
34
34
|
className: M,
|
|
35
35
|
...R
|
|
36
36
|
}) {
|
|
37
37
|
const w = h(null), t = h(null);
|
|
38
|
-
|
|
38
|
+
P(() => {
|
|
39
39
|
var i, m;
|
|
40
40
|
d !== void 0 && (d ? (i = t.current) == null || i.showModal() : (m = t.current) == null || m.close());
|
|
41
41
|
}, [d]);
|
|
42
42
|
const A = () => {
|
|
43
43
|
var i;
|
|
44
44
|
(i = t.current) == null || i.showModal();
|
|
45
|
-
},
|
|
45
|
+
}, u = () => {
|
|
46
46
|
var i;
|
|
47
47
|
l == null || l(), d === void 0 && ((i = t.current) == null || i.close());
|
|
48
48
|
}, E = () => {
|
|
@@ -54,20 +54,21 @@ function q({
|
|
|
54
54
|
};
|
|
55
55
|
return /* @__PURE__ */ c("div", { className: M, ...R, children: [
|
|
56
56
|
g && /* @__PURE__ */ o("div", { ref: w, onClick: A, children: g }),
|
|
57
|
-
/* @__PURE__ */
|
|
58
|
-
l && /* @__PURE__ */ o("button", { className: a["dialog-close-button"], onClick:
|
|
57
|
+
/* @__PURE__ */ o("dialog", { className: a.dialog, ref: t, onClose: u, children: /* @__PURE__ */ c(K.Provider, { value: t.current, children: [
|
|
58
|
+
l && /* @__PURE__ */ o("button", { className: a["dialog-close-button"], onClick: u, children: /* @__PURE__ */ o(H, { className: a["dialog-close-button-icon"], icon: "ap-icon-close" }) }),
|
|
59
59
|
s && /* @__PURE__ */ o("div", { className: a["dialog-illustration"], children: /* @__PURE__ */ o("img", { src: s, alt: "Dialog illustration" }) }),
|
|
60
60
|
/* @__PURE__ */ c("div", { className: a["dialog-content"], children: [
|
|
61
61
|
/* @__PURE__ */ o("h2", { className: a["dialog-title"], children: v }),
|
|
62
|
-
/* @__PURE__ */ o("div", { className: a["dialog-description"], children:
|
|
62
|
+
/* @__PURE__ */ o("div", { className: a["dialog-description"], children: D })
|
|
63
63
|
] }),
|
|
64
64
|
/* @__PURE__ */ c("div", { className: a["dialog-buttons"], children: [
|
|
65
|
-
|
|
66
|
-
_ && /* @__PURE__ */ o(f, { type:
|
|
65
|
+
n && /* @__PURE__ */ o(f, { type: p, variant: k, size: y, onClick: G, icon: j, children: n }),
|
|
66
|
+
_ && /* @__PURE__ */ o(f, { type: b, variant: N, size: x, onClick: E, icon: z, children: _ })
|
|
67
67
|
] })
|
|
68
|
-
] })
|
|
68
|
+
] }) })
|
|
69
69
|
] });
|
|
70
70
|
}
|
|
71
71
|
export {
|
|
72
|
-
|
|
72
|
+
K as DialogContext,
|
|
73
|
+
F as default
|
|
73
74
|
};
|
|
@@ -29,12 +29,10 @@ type DropdownProps = {
|
|
|
29
29
|
align?: 'left' | 'right';
|
|
30
30
|
onToggleChange?: (checked: boolean) => void;
|
|
31
31
|
toggleLabel?: string;
|
|
32
|
-
isCreatable?: boolean;
|
|
33
32
|
dropdownTriggerClassName?: string;
|
|
34
33
|
dropdownMenuClassName?: string;
|
|
35
34
|
hideSelectedItems?: boolean;
|
|
36
35
|
labelTooltip?: LabelTooltipProps;
|
|
37
|
-
isTagsFields?: boolean;
|
|
38
36
|
unselect?: boolean;
|
|
39
37
|
selectedOptionLabel?: string;
|
|
40
38
|
selectedOptionsLabel?: string;
|
|
@@ -63,15 +61,13 @@ type DropdownProps = {
|
|
|
63
61
|
* @param {'left' | 'right'} [props.align] - Alignment of the dropdown menu (defaults to 'left')
|
|
64
62
|
* @param {(checked: boolean) => void} [props.onToggleChange] - Callback fired when toggle state changes (shows toggle if provided)
|
|
65
63
|
* @param {string} [props.toggleLabel] - Label text for the toggle control
|
|
66
|
-
* @param {boolean} [props.isCreatable] - Whether to show a "Create new option" button in the dropdown (defaults to false)
|
|
67
64
|
* @param {string} [props.dropdownTriggerClassName] - Class name for the dropdown trigger
|
|
68
65
|
* @param {string} [props.dropdownMenuClassName] - Class name for the dropdown menu
|
|
69
66
|
* @param {boolean} [props.hideSelectedItems] - Whether to hide the selected items in the dropdown trigger (defaults to false)
|
|
70
67
|
* @param {LabelTooltipProps} [props.labelTooltip] - Tooltip to display next to the label
|
|
71
|
-
* @param {boolean} [props.isTagsFields] - Whether to use creatable-style UI without creation functionality (defaults to false)
|
|
72
68
|
* @param {boolean} [props.unselect] - Whether single select dropdown allows deselection of selected items (defaults to false)
|
|
73
69
|
* @param {boolean} [props.caseSensitive] - Whether to perform case-sensitive matching when checking for existing options in creatable mode (defaults to false)
|
|
74
70
|
* @returns {JSX.Element} The rendered Dropdown component
|
|
75
71
|
*/
|
|
76
|
-
export default function Dropdown({ className, label, options, value, placeholder, disabled, required, searchable, searchPlaceholder, errorMessage, helpText, helpLink, helpLinkText, onChange, onSearch, multiSelect, grouped, align, onToggleChange, toggleLabel,
|
|
72
|
+
export default function Dropdown({ className, label, options, value, placeholder, disabled, required, searchable, searchPlaceholder, errorMessage, helpText, helpLink, helpLinkText, onChange, onSearch, multiSelect, grouped, align, onToggleChange, toggleLabel, dropdownTriggerClassName, dropdownMenuClassName, hideSelectedItems, labelTooltip, unselect, selectedOptionLabel, selectedOptionsLabel, allOptionsSelectedLabel, caseSensitive, ...props }: DropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
77
73
|
export {};
|