@alixpartners/ui-components 2.0.2 → 2.1.2
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 -1
- 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 -1
- 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 +2 -1
- package/dist/components/Creatable/Creatable.js +136 -138
- package/dist/components/Dialog/Dialog.d.ts +1 -0
- package/dist/components/Dialog/Dialog.js +20 -19
- package/dist/components/Dropdown/Dropdown.js +101 -100
- 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.js +3 -2
- package/dist/components/Textarea/Textarea.js +70 -68
- 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/main.d.ts +2 -0
- package/dist/main.js +36 -34
- 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", () => {
|
|
@@ -8,6 +8,7 @@ type CreatableProps = {
|
|
|
8
8
|
value?: string[];
|
|
9
9
|
disabled?: boolean;
|
|
10
10
|
required?: boolean;
|
|
11
|
+
maxLength?: number;
|
|
11
12
|
searchPlaceholder?: string;
|
|
12
13
|
errorMessage?: string;
|
|
13
14
|
helpText?: string;
|
|
@@ -49,5 +50,5 @@ type CreatableProps = {
|
|
|
49
50
|
* @param {DataAttributes} [props.data-*] - Additional `data-` attributes forwarded to the root element
|
|
50
51
|
* @returns {JSX.Element} The rendered Creatable component
|
|
51
52
|
*/
|
|
52
|
-
export default function Creatable({ className, label, options, value, disabled, required, searchPlaceholder, errorMessage, helpText, helpLink, helpLinkText, onChange, onSearch, multiSelect, grouped, align, dropdownMenuClassName, labelTooltip, unselect, selectedOptionsLabel, allOptionsSelectedLabel, caseSensitive, ...props }: CreatableProps): import("react/jsx-runtime").JSX.Element;
|
|
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;
|
|
53
54
|
export {};
|
|
@@ -1,234 +1,232 @@
|
|
|
1
1
|
import { jsxs as w, jsx as l } from "react/jsx-runtime";
|
|
2
2
|
import { c as C } from "../../clsx-OuTLNxxd.js";
|
|
3
|
-
import { useState as
|
|
4
|
-
import
|
|
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
5
|
import ve from "../Button/Button.js";
|
|
6
6
|
import "../Input/Input.js";
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
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 = {
|
|
10
11
|
dropdownContainer: ke,
|
|
11
|
-
dropdownLabel:
|
|
12
|
+
dropdownLabel: Oe,
|
|
12
13
|
"label-text": "Creatable-module__label-text___jlV2x",
|
|
13
|
-
dropdownLabelDisabled:
|
|
14
|
+
dropdownLabelDisabled: Ae,
|
|
14
15
|
"label-tooltip-icon": "Creatable-module__label-tooltip-icon___G7Bou",
|
|
15
|
-
required:
|
|
16
|
-
dropdownWrapper:
|
|
17
|
-
selectedItemsCreatable:
|
|
18
|
-
selectedItem:
|
|
19
|
-
selectedItemLabel:
|
|
16
|
+
required: Re,
|
|
17
|
+
dropdownWrapper: Ve,
|
|
18
|
+
selectedItemsCreatable: Ee,
|
|
19
|
+
selectedItem: Fe,
|
|
20
|
+
selectedItemLabel: Se,
|
|
20
21
|
removeButton: Me,
|
|
21
|
-
removeIcon:
|
|
22
|
-
singleSelectedCreatableItem:
|
|
23
|
-
singleSelectedCreatableItemRemoveButton:
|
|
24
|
-
dropdownActions:
|
|
25
|
-
dropdownArrow:
|
|
26
|
-
dropdownArrowOpen:
|
|
27
|
-
dropdownMenu:
|
|
22
|
+
removeIcon: Be,
|
|
23
|
+
singleSelectedCreatableItem: Ge,
|
|
24
|
+
singleSelectedCreatableItemRemoveButton: Ke,
|
|
25
|
+
dropdownActions: je,
|
|
26
|
+
dropdownArrow: Ue,
|
|
27
|
+
dropdownArrowOpen: We,
|
|
28
|
+
dropdownMenu: $e,
|
|
28
29
|
"dropdown-container-grouped": "Creatable-module__dropdown-container-grouped___gZle-",
|
|
29
30
|
"dropdown-container-multi-select": "Creatable-module__dropdown-container-multi-select___1U1U4",
|
|
30
|
-
dropdownCreatableSearchContainer:
|
|
31
|
-
disabled:
|
|
32
|
-
dropdownCreatableError:
|
|
33
|
-
creatableInput:
|
|
34
|
-
optionsList:
|
|
35
|
-
categoryGroup:
|
|
36
|
-
categoryDivider:
|
|
37
|
-
categoryLabel:
|
|
38
|
-
optionItem:
|
|
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,
|
|
39
40
|
optionItemDisabled: Xe,
|
|
40
|
-
optionItemFocused:
|
|
41
|
-
optionContent:
|
|
42
|
-
optionLabel:
|
|
43
|
-
tickIcon:
|
|
44
|
-
helpers:
|
|
41
|
+
optionItemFocused: et,
|
|
42
|
+
optionContent: tt,
|
|
43
|
+
optionLabel: ot,
|
|
44
|
+
tickIcon: lt,
|
|
45
|
+
helpers: at,
|
|
45
46
|
helpText: rt,
|
|
46
|
-
helpTextDisabled:
|
|
47
|
-
helpLink:
|
|
48
|
-
helpLinkDisabled:
|
|
49
|
-
errorMessage:
|
|
47
|
+
helpTextDisabled: nt,
|
|
48
|
+
helpLink: st,
|
|
49
|
+
helpLinkDisabled: dt,
|
|
50
|
+
errorMessage: ct
|
|
50
51
|
};
|
|
51
|
-
function
|
|
52
|
+
function ht({
|
|
52
53
|
className: re,
|
|
53
54
|
label: G,
|
|
54
|
-
options:
|
|
55
|
-
value:
|
|
55
|
+
options: y,
|
|
56
|
+
value: x = [],
|
|
56
57
|
disabled: v = !1,
|
|
57
|
-
required:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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,
|
|
65
67
|
multiSelect: m = !1,
|
|
66
|
-
grouped:
|
|
68
|
+
grouped: ce = !1,
|
|
67
69
|
align: Y = "left",
|
|
68
|
-
dropdownMenuClassName:
|
|
69
|
-
labelTooltip:
|
|
70
|
+
dropdownMenuClassName: ie,
|
|
71
|
+
labelTooltip: L,
|
|
70
72
|
unselect: q = !1,
|
|
71
73
|
selectedOptionsLabel: z = "options selected",
|
|
72
|
-
allOptionsSelectedLabel:
|
|
73
|
-
caseSensitive:
|
|
74
|
-
...
|
|
74
|
+
allOptionsSelectedLabel: F,
|
|
75
|
+
caseSensitive: j = !1,
|
|
76
|
+
..._e
|
|
75
77
|
}) {
|
|
76
|
-
const [u, N] =
|
|
77
|
-
|
|
78
|
-
JSON.stringify(X.current) !== JSON.stringify(
|
|
79
|
-
}, [
|
|
80
|
-
var
|
|
81
|
-
const e = (
|
|
82
|
-
e &&
|
|
83
|
-
}, []), R(() => {
|
|
84
|
-
var r;
|
|
85
|
-
const e = (r = E.current) == null ? void 0 : r.getBoundingClientRect().width;
|
|
86
|
-
e && me(e);
|
|
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);
|
|
87
85
|
}, []);
|
|
88
|
-
const _ = Q.trim(), p =
|
|
89
|
-
const
|
|
90
|
-
return
|
|
91
|
-
}), S = _ !== "" && !
|
|
92
|
-
|
|
93
|
-
c &&
|
|
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();
|
|
94
92
|
}, [c]);
|
|
95
|
-
const
|
|
93
|
+
const me = (e) => {
|
|
96
94
|
h(e), b(""), i(-1);
|
|
97
|
-
},
|
|
95
|
+
}, U = ae((e) => {
|
|
98
96
|
var o, n;
|
|
99
|
-
const
|
|
97
|
+
const a = {
|
|
100
98
|
value: e,
|
|
101
99
|
label: e,
|
|
102
100
|
disabled: !1
|
|
103
101
|
};
|
|
104
|
-
if (
|
|
105
|
-
const
|
|
106
|
-
N(
|
|
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);
|
|
107
105
|
} else {
|
|
108
106
|
const d = [e];
|
|
109
|
-
N(d),
|
|
107
|
+
N(d), r == null || r(d), b(""), (n = O.current) == null || n.focus(), h(!1), i(-1);
|
|
110
108
|
}
|
|
111
|
-
}, [m,
|
|
112
|
-
var
|
|
109
|
+
}, [m, r, y, u]), W = ae((e) => {
|
|
110
|
+
var a, o, n;
|
|
113
111
|
if (!e.disabled)
|
|
114
112
|
if (m) {
|
|
115
|
-
const
|
|
116
|
-
N(
|
|
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);
|
|
117
115
|
} else if (u.includes(e.value)) {
|
|
118
116
|
if (q) {
|
|
119
117
|
const d = [];
|
|
120
|
-
N(d),
|
|
118
|
+
N(d), r == null || r(d), (o = O.current) == null || o.focus(), h(!1), b(""), i(-1);
|
|
121
119
|
}
|
|
122
120
|
} else {
|
|
123
121
|
const d = [e.value];
|
|
124
|
-
N(d),
|
|
122
|
+
N(d), r == null || r(d), (n = O.current) == null || n.focus(), h(!1), b(""), i(-1);
|
|
125
123
|
}
|
|
126
|
-
}, [m,
|
|
127
|
-
h(!0), b(e), i(-1),
|
|
128
|
-
},
|
|
129
|
-
h(!0), b(e), i(-1),
|
|
130
|
-
},
|
|
131
|
-
const
|
|
132
|
-
N(
|
|
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);
|
|
133
131
|
};
|
|
134
|
-
|
|
135
|
-
const e = (
|
|
132
|
+
V(() => {
|
|
133
|
+
const e = (a) => {
|
|
136
134
|
if (!c) return;
|
|
137
135
|
const o = p.length + (S ? 1 : 0);
|
|
138
136
|
if (o !== 0)
|
|
139
|
-
switch (
|
|
137
|
+
switch (a.key) {
|
|
140
138
|
case "ArrowDown":
|
|
141
|
-
|
|
139
|
+
a.preventDefault(), i((n) => n < 0 ? 0 : n < o - 1 ? n + 1 : 0);
|
|
142
140
|
break;
|
|
143
141
|
case "ArrowUp":
|
|
144
|
-
|
|
142
|
+
a.preventDefault(), i((n) => n < 0 ? o - 1 : n > 0 ? n - 1 : o - 1);
|
|
145
143
|
break;
|
|
146
144
|
case "Enter":
|
|
147
|
-
if (
|
|
145
|
+
if (a.preventDefault(), f >= 0 && f < p.length) {
|
|
148
146
|
const n = p[f];
|
|
149
|
-
|
|
150
|
-
} else S && f === p.length &&
|
|
147
|
+
W(n);
|
|
148
|
+
} else S && f === p.length && U(_);
|
|
151
149
|
break;
|
|
152
150
|
case "Escape":
|
|
153
|
-
|
|
151
|
+
a.preventDefault(), h(!1), b(""), i(-1);
|
|
154
152
|
break;
|
|
155
153
|
}
|
|
156
154
|
};
|
|
157
155
|
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
158
|
-
}, [f, p,
|
|
156
|
+
}, [f, p, U, W, S, c, _]), V(() => {
|
|
159
157
|
if (!c || f < 0) return;
|
|
160
|
-
const e = H.current,
|
|
161
|
-
e &&
|
|
158
|
+
const e = H.current, a = e == null ? void 0 : e.querySelector(`[data-option-index="${f}"]`);
|
|
159
|
+
e && a && a.scrollIntoView({
|
|
162
160
|
block: "nearest"
|
|
163
161
|
});
|
|
164
162
|
}, [c, f]);
|
|
165
|
-
const
|
|
166
|
-
const o =
|
|
167
|
-
return e[o] || (e[o] = []), e[o].push(
|
|
168
|
-
}, {}),
|
|
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, {
|
|
169
167
|
onBlur: I,
|
|
170
|
-
...
|
|
171
|
-
} =
|
|
172
|
-
return /* @__PURE__ */ w("div", { ref: Z, className: C(t.dropdownContainer,
|
|
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: [
|
|
173
171
|
G && /* @__PURE__ */ w("label", { className: C(t.dropdownLabel, v && t.dropdownLabelDisabled), children: [
|
|
174
172
|
/* @__PURE__ */ l("span", { title: G, className: t["label-text"], children: G }),
|
|
175
|
-
|
|
176
|
-
|
|
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"] }) })
|
|
177
175
|
] }),
|
|
178
|
-
/* @__PURE__ */ l(
|
|
179
|
-
/* @__PURE__ */ l(
|
|
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) => {
|
|
180
178
|
c || I == null || I(e);
|
|
181
179
|
}, onClick: () => {
|
|
182
180
|
var e;
|
|
183
181
|
if (!m && s.length > 0)
|
|
184
|
-
return
|
|
185
|
-
(e =
|
|
182
|
+
return $("");
|
|
183
|
+
(e = g.current) == null || e.focus();
|
|
186
184
|
}, onKeyDown: (e) => {
|
|
187
185
|
if (e.key === "Enter" && !m && s.length > 0 && !c)
|
|
188
|
-
return
|
|
189
|
-
}, ...
|
|
190
|
-
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:
|
|
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: [
|
|
191
189
|
/* @__PURE__ */ l("span", { className: t.selectedItemLabel, title: e.label, children: e.label }),
|
|
192
|
-
/* @__PURE__ */ l("button", { type: "button", className: t.removeButton, onClick: () =>
|
|
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 }) })
|
|
193
191
|
] }, e.value)) : s.length > 0 && /* @__PURE__ */ w("div", { className: t.singleSelectedCreatableItem, children: [
|
|
194
192
|
/* @__PURE__ */ l("span", { className: t.selectedItemLabel, title: s[0].label, children: s[0].label }),
|
|
195
|
-
/* @__PURE__ */ l(ve, { type: "tertiary", variant: "default", size: "sm", onClick: () =>
|
|
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 })
|
|
196
194
|
] }) }),
|
|
197
|
-
(m || !s.length) && /* @__PURE__ */ l("input", { ref:
|
|
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) => {
|
|
198
196
|
c || I == null || I(e);
|
|
199
197
|
}, disabled: v, className: t.creatableInput }),
|
|
200
|
-
/* @__PURE__ */ l("div", { className: t.dropdownActions, children: /* @__PURE__ */ l(
|
|
198
|
+
/* @__PURE__ */ l("div", { className: t.dropdownActions, children: /* @__PURE__ */ l(B, { icon: "ap-icon-expand-more", className: C(t.dropdownArrow, c && t.dropdownArrowOpen) }) })
|
|
201
199
|
] }) }),
|
|
202
|
-
/* @__PURE__ */ l(ye, { children: /* @__PURE__ */ l(
|
|
200
|
+
/* @__PURE__ */ l(ye, { container: ue, children: /* @__PURE__ */ l(xe, { onOpenAutoFocus: (e) => {
|
|
203
201
|
e.preventDefault();
|
|
204
202
|
}, align: Y === "right" ? "end" : "start", side: "bottom", avoidCollisions: !0, sideOffset: 6, collisionPadding: 8, style: {
|
|
205
|
-
|
|
203
|
+
width: T,
|
|
206
204
|
zIndex: 9999
|
|
207
205
|
}, onInteractOutside: (e) => {
|
|
208
206
|
var o;
|
|
209
|
-
e.target ===
|
|
207
|
+
e.target === g.current && e.preventDefault(), ((o = Z.current) == null ? void 0 : o.contains(e.target)) || I == null || I(e);
|
|
210
208
|
}, children: c && /* @__PURE__ */ l("div", { style: {
|
|
211
|
-
|
|
212
|
-
}, className: C(t.dropdownMenu,
|
|
213
|
-
p.length > 0 ? Object.entries(
|
|
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: [
|
|
214
212
|
e !== "default" && /* @__PURE__ */ l("div", { className: t.categoryDivider, children: /* @__PURE__ */ l("span", { className: t.categoryLabel, children: e }) }),
|
|
215
|
-
|
|
216
|
-
const n =
|
|
217
|
-
return /* @__PURE__ */ l("button", { title: (d == null ? void 0 : d.label) || o.label, type: "button", className: C(t.optionItem,
|
|
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: [
|
|
218
216
|
/* @__PURE__ */ l("span", { className: t.optionLabel, children: o.label }),
|
|
219
|
-
|
|
217
|
+
M.includes(o.value) && /* @__PURE__ */ l(B, { icon: "ap-icon-check", className: t.tickIcon })
|
|
220
218
|
] }) }, o.value);
|
|
221
219
|
})
|
|
222
220
|
] }, e)) : null,
|
|
223
|
-
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: () =>
|
|
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" }) }) })
|
|
224
222
|
] }) }) }) })
|
|
225
223
|
] }) }),
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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 })
|
|
229
227
|
] })
|
|
230
228
|
] });
|
|
231
229
|
}
|
|
232
230
|
export {
|
|
233
|
-
|
|
231
|
+
ht as default
|
|
234
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
|
};
|