@alixpartners/ui-components 2.1.0 → 2.2.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/ToastProvider-D5LImZ-Q.js +1136 -0
- 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 -1
- package/dist/assets/NavBar.css +1 -1
- package/dist/assets/SplitButton.css +1 -1
- package/dist/assets/TagsFields.css +1 -1
- package/dist/assets/Tooltip.css +1 -1
- package/dist/components/Banner/Banner.test.js +1 -1
- package/dist/components/Button/Button.test.js +124 -3217
- package/dist/components/Checkbox/Checkbox.js +7 -6
- package/dist/components/Checkbox/Checkbox.test.js +47 -47
- package/dist/components/Creatable/Creatable.js +107 -108
- package/dist/components/Dialog/Dialog.d.ts +21 -7
- package/dist/components/Dialog/Dialog.js +296 -61
- package/dist/components/Dialog/Dialog.test.d.ts +1 -0
- package/dist/components/Dialog/Dialog.test.js +368 -0
- package/dist/components/Dropdown/Dropdown.js +78 -79
- package/dist/components/FilePicker/FilePicker.js +6 -6
- package/dist/components/FilePicker/FilePicker.test.js +1 -1
- package/dist/components/Ghost/Ghost.test.js +6 -6
- package/dist/components/Input/Input.test.js +2 -2
- package/dist/components/NavBar/NavBar.js +16 -16
- package/dist/components/Radio/Radio.js +1 -1
- package/dist/components/RadioGroup/RadioGroup.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 +8 -9
- 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 -4
- package/dist/components/Textarea/Textarea.test.js +2 -2
- package/dist/components/Toast/Toast.d.ts +5 -19
- package/dist/components/Toast/Toast.js +65 -62
- package/dist/components/Toast/Toast.test.js +47 -30
- package/dist/components/ToastProvider/ToastContext.d.ts +11 -0
- package/dist/components/ToastProvider/ToastProvider.d.ts +19 -0
- package/dist/components/ToastProvider/ToastProvider.js +7 -0
- package/dist/components/ToastProvider/ToastProvider.test.d.ts +1 -0
- package/dist/components/ToastProvider/ToastProvider.test.js +264 -0
- package/dist/components/ToastProvider/types.d.ts +54 -0
- package/dist/components/ToastProvider/useToast.d.ts +28 -0
- package/dist/components/Toggle/Toggle.js +31 -30
- package/dist/components/Toggle/Toggle.test.js +9 -9
- package/dist/components/Tooltip/Tooltip.js +20 -19
- package/dist/{index-2H7slGYV.js → index-7CBv-Jx6.js} +1 -1
- package/dist/{index-DpfPnSMn.js → index-BymOxiM6.js} +2 -2
- package/dist/index-C-3_YVJ1.js +1539 -0
- package/dist/{index-BKtdMA_j.js → index-C4ffg1vf.js} +24 -23
- package/dist/{index-BGZDIjm9.js → index-Chv2KjIL.js} +171 -168
- package/dist/{index-BJXIvJs4.js → index-CpsmI33B.js} +24 -23
- package/dist/index-CxAtPSMM.js +27 -0
- package/dist/{index-CjQV7MmW.js → index-DEphED6n.js} +11 -11
- package/dist/index-DM51yNMI.js +237 -0
- package/dist/{index-CVWHq7Pr.js → index-D_3jWVyV.js} +37 -36
- package/dist/index-DkTDHhag.js +3098 -0
- package/dist/index-DrR82jOT.js +142 -0
- package/dist/magic-string.es-uPKorP4O.js +663 -0
- package/dist/main.d.ts +5 -0
- package/dist/main.js +48 -42
- package/dist/useToast-Cz5MGKnw.js +11 -0
- package/dist/{vi.ClIskdbk-CFW_9sOK.js → vi.bdSIJ99Y-017e_Pkz.js} +9494 -10227
- package/package.json +6 -3
- package/dist/index-DWydnyjJ.js +0 -245
- package/dist/index-DieLVN0p.js +0 -1664
- package/dist/magic-string.es-D4UQQyt0.js +0 -859
|
@@ -3,9 +3,10 @@ import * as b from "react";
|
|
|
3
3
|
import { useId as z, useState as G, useEffect as J } from "react";
|
|
4
4
|
import U from "../Icon/Icon.js";
|
|
5
5
|
import { c as P } from "../../clsx-OuTLNxxd.js";
|
|
6
|
-
import {
|
|
7
|
-
import { u as
|
|
8
|
-
import {
|
|
6
|
+
import { P as w, u as V, d as D, c as g, b as W } from "../../index-DM51yNMI.js";
|
|
7
|
+
import { u as $ } from "../../index-BZPx6jYI.js";
|
|
8
|
+
import { u as Q } from "../../index-CxAtPSMM.js";
|
|
9
|
+
import { P as Y } from "../../index-BymOxiM6.js";
|
|
9
10
|
import '../../assets/Checkbox.css';const Z = "Checkbox-module__wrapper___rznMS", ee = "Checkbox-module__root___BS5dT", te = "Checkbox-module__indicator___HXLHH", oe = "Checkbox-module__checked___XfvkJ", re = "Checkbox-module__icon___VMxEf", ce = "Checkbox-module__label___JBaRm", ne = "Checkbox-module__disabled___WagIC", C = {
|
|
10
11
|
wrapper: Z,
|
|
11
12
|
root: ee,
|
|
@@ -15,7 +16,7 @@ import '../../assets/Checkbox.css';const Z = "Checkbox-module__wrapper___rznMS",
|
|
|
15
16
|
label: ce,
|
|
16
17
|
disabled: ne
|
|
17
18
|
};
|
|
18
|
-
var I = "Checkbox", [se
|
|
19
|
+
var I = "Checkbox", [se] = W(I), [ae, N] = se(I);
|
|
19
20
|
function de(t) {
|
|
20
21
|
const {
|
|
21
22
|
__scopeCheckbox: n,
|
|
@@ -30,7 +31,7 @@ function de(t) {
|
|
|
30
31
|
value: m = "on",
|
|
31
32
|
// @ts-expect-error
|
|
32
33
|
internal_do_not_use_render: o
|
|
33
|
-
} = t, [u, v] =
|
|
34
|
+
} = t, [u, v] = V({
|
|
34
35
|
prop: c,
|
|
35
36
|
defaultProp: r ?? !1,
|
|
36
37
|
onChange: a,
|
|
@@ -190,7 +191,7 @@ var F = "CheckboxBubbleInput", K = b.forwardRef(
|
|
|
190
191
|
form: o,
|
|
191
192
|
bubbleInput: u,
|
|
192
193
|
setBubbleInput: v
|
|
193
|
-
} = N(F, t), _ = D(c, v), x =
|
|
194
|
+
} = N(F, t), _ = D(c, v), x = $(e), y = Q(s);
|
|
194
195
|
b.useEffect(() => {
|
|
195
196
|
const f = u;
|
|
196
197
|
if (!f) return;
|
|
@@ -1,145 +1,145 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { d, i as
|
|
2
|
+
import { d as a, i as d, r as n, g as c, s as o, v as b, f as h } from "../../vi.bdSIJ99Y-017e_Pkz.js";
|
|
3
3
|
import l from "./Checkbox.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
a("Checkbox", () => {
|
|
5
|
+
a("Rendering", () => {
|
|
6
|
+
a("Label", () => {
|
|
7
|
+
d("should render checkbox with label", () => {
|
|
8
8
|
var e;
|
|
9
9
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox" })), c(o.queryByTestId("checkbox")).toBeInTheDocument(), c(o.queryByTestId("checkbox-label")).toBeInTheDocument(), c((e = o.queryByTestId("checkbox-label")) == null ? void 0 : e.textContent).toBe("Test checkbox");
|
|
10
|
-
}),
|
|
10
|
+
}), d("should render checkbox with empty string label", () => {
|
|
11
11
|
n(/* @__PURE__ */ t(l, { label: "" })), c(o.queryByTestId("checkbox")).toBeInTheDocument(), c(o.queryByTestId("checkbox-label")).not.toBeInTheDocument();
|
|
12
|
-
}),
|
|
12
|
+
}), d("should render without label when label is null", () => {
|
|
13
13
|
n(/* @__PURE__ */ t(l, { label: null })), c(o.queryByTestId("checkbox")).toBeInTheDocument(), c(o.queryByTestId("checkbox-label")).not.toBeInTheDocument();
|
|
14
|
-
}),
|
|
14
|
+
}), d("should render without label when label is undefined", () => {
|
|
15
15
|
n(/* @__PURE__ */ t(l, { label: void 0 })), c(o.queryByTestId("checkbox")).toBeInTheDocument(), c(o.queryByTestId("checkbox-label")).not.toBeInTheDocument();
|
|
16
16
|
});
|
|
17
|
-
}),
|
|
18
|
-
|
|
17
|
+
}), a("Indicator and Icon", () => {
|
|
18
|
+
d("should render indicator and check icon when checked", () => {
|
|
19
19
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox", checked: !0 }));
|
|
20
20
|
const e = o.queryByTestId("checkbox-indicator"), s = o.queryByTestId("checkbox-icon");
|
|
21
21
|
c(e).toBeInTheDocument(), c(s).toBeInTheDocument();
|
|
22
|
-
}),
|
|
22
|
+
}), d("should not render check icon when unchecked", () => {
|
|
23
23
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox", checked: !1 }));
|
|
24
24
|
const e = o.queryByTestId("checkbox-indicator"), s = o.queryByTestId("checkbox-icon");
|
|
25
25
|
c(e).not.toBeInTheDocument(), c(s).not.toBeInTheDocument();
|
|
26
26
|
});
|
|
27
|
-
}),
|
|
28
|
-
|
|
27
|
+
}), a("Disabled state", () => {
|
|
28
|
+
d("should render enabled when disabled prop is not provided", () => {
|
|
29
29
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox" }));
|
|
30
30
|
const e = o.queryByTestId("checkbox");
|
|
31
31
|
c(e).toBeEnabled();
|
|
32
|
-
}),
|
|
32
|
+
}), d("should render enabled when disabled prop is undefined", () => {
|
|
33
33
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox", disabled: void 0 }));
|
|
34
34
|
const e = o.queryByTestId("checkbox");
|
|
35
35
|
c(e).toBeEnabled();
|
|
36
|
-
}),
|
|
36
|
+
}), d("should render enabled when disabled prop is null", () => {
|
|
37
37
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox", disabled: null }));
|
|
38
38
|
const e = o.queryByTestId("checkbox");
|
|
39
39
|
c(e).toBeEnabled();
|
|
40
|
-
}),
|
|
40
|
+
}), d("should render disabled when disabled prop is true", () => {
|
|
41
41
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox", disabled: !0 }));
|
|
42
42
|
const e = o.queryByTestId("checkbox");
|
|
43
43
|
c(e).toBeDisabled();
|
|
44
|
-
}),
|
|
44
|
+
}), d("should render enabled when disabled prop is false", () => {
|
|
45
45
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox", disabled: !1 }));
|
|
46
46
|
const e = o.queryByTestId("checkbox");
|
|
47
47
|
c(e).toBeEnabled();
|
|
48
48
|
});
|
|
49
|
-
}),
|
|
50
|
-
|
|
49
|
+
}), a("CSS Classes", () => {
|
|
50
|
+
d("should apply wrapper class", () => {
|
|
51
51
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox" }));
|
|
52
52
|
const e = o.getByTestId("checkbox-wrapper");
|
|
53
53
|
c(e.className).toContain("wrapper");
|
|
54
|
-
}),
|
|
54
|
+
}), d("should apply disabled class when disabled", () => {
|
|
55
55
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox", disabled: !0 }));
|
|
56
56
|
const e = o.getByTestId("checkbox-wrapper");
|
|
57
57
|
c(e.className).toContain("disabled");
|
|
58
|
-
}),
|
|
58
|
+
}), d("should not apply disabled class when enabled", () => {
|
|
59
59
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox", disabled: !1 }));
|
|
60
60
|
const e = o.getByTestId("checkbox-wrapper");
|
|
61
61
|
c(e.className).not.toContain("disabled");
|
|
62
|
-
}),
|
|
62
|
+
}), d("should apply checked class when checked", () => {
|
|
63
63
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox", checked: !0 }));
|
|
64
64
|
const e = o.getByTestId("checkbox");
|
|
65
65
|
c(e.className).toContain("checked");
|
|
66
|
-
}),
|
|
66
|
+
}), d("should not apply checked class when unchecked", () => {
|
|
67
67
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox", checked: !1 }));
|
|
68
68
|
const e = o.getByTestId("checkbox");
|
|
69
69
|
c(e.className).not.toContain("checked");
|
|
70
|
-
}),
|
|
70
|
+
}), d("should apply label class", () => {
|
|
71
71
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox" }));
|
|
72
72
|
const e = o.getByTestId("checkbox-label");
|
|
73
73
|
c(e.className).toContain("label");
|
|
74
74
|
});
|
|
75
75
|
});
|
|
76
|
-
}),
|
|
77
|
-
|
|
76
|
+
}), a("User Interactions", () => {
|
|
77
|
+
d("should call onChange when clicked", () => {
|
|
78
78
|
const e = b.fn();
|
|
79
79
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox", onChange: e }));
|
|
80
80
|
const s = o.getByTestId("checkbox");
|
|
81
|
-
|
|
82
|
-
}),
|
|
81
|
+
h.click(s), c(e).toHaveBeenCalledTimes(1), c(e).toHaveBeenCalledWith(!0);
|
|
82
|
+
}), d("should toggle checked state when clicked", () => {
|
|
83
83
|
const e = b.fn();
|
|
84
84
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox", onChange: e }));
|
|
85
85
|
const s = o.getByTestId("checkbox");
|
|
86
|
-
c(s).not.toBeChecked(),
|
|
87
|
-
}),
|
|
86
|
+
c(s).not.toBeChecked(), h.click(s), c(s).toBeChecked(), c(e).toHaveBeenCalledWith(!0), h.click(s), c(s).not.toBeChecked(), c(e).toHaveBeenCalledWith(!1);
|
|
87
|
+
}), d("should re-render when checked prop changes", () => {
|
|
88
88
|
const {
|
|
89
89
|
rerender: e
|
|
90
90
|
} = n(/* @__PURE__ */ t(l, { label: "Test checkbox", checked: !1 })), s = o.getByTestId("checkbox");
|
|
91
91
|
c(s).not.toBeChecked(), e(/* @__PURE__ */ t(l, { label: "Test checkbox", checked: !0 })), c(s).toBeChecked(), e(/* @__PURE__ */ t(l, { label: "Test checkbox", checked: !1 })), c(s).not.toBeChecked();
|
|
92
|
-
}),
|
|
92
|
+
}), d("should not call onChange when disabled", () => {
|
|
93
93
|
const e = b.fn();
|
|
94
94
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox", disabled: !0, onChange: e }));
|
|
95
95
|
const s = o.getByTestId("checkbox");
|
|
96
|
-
|
|
97
|
-
}),
|
|
96
|
+
h.click(s), c(e).not.toHaveBeenCalled();
|
|
97
|
+
}), d("should not toggle when disabled", () => {
|
|
98
98
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox", disabled: !0, checked: !1 }));
|
|
99
99
|
const e = o.getByTestId("checkbox");
|
|
100
|
-
c(e).not.toBeChecked(),
|
|
101
|
-
}),
|
|
100
|
+
c(e).not.toBeChecked(), h.click(e), c(e).not.toBeChecked();
|
|
101
|
+
}), d("should handle keyboard interactions", () => {
|
|
102
102
|
const e = b.fn();
|
|
103
103
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox", onChange: e }));
|
|
104
104
|
const s = o.getByTestId("checkbox");
|
|
105
|
-
c(s).not.toBeChecked(),
|
|
105
|
+
c(s).not.toBeChecked(), h.keyDown(s, {
|
|
106
106
|
key: " "
|
|
107
|
-
}), c(e).toHaveBeenCalledTimes(1), c(e).toHaveBeenCalledWith(!0), c(s).toBeChecked(),
|
|
107
|
+
}), c(e).toHaveBeenCalledTimes(1), c(e).toHaveBeenCalledWith(!0), c(s).toBeChecked(), h.keyDown(s, {
|
|
108
108
|
key: " "
|
|
109
109
|
}), c(e).toHaveBeenCalledTimes(2), c(e).toHaveBeenCalledWith(!1), c(s).not.toBeChecked();
|
|
110
|
-
}),
|
|
110
|
+
}), d("should not handle keyboard interactions when disabled", () => {
|
|
111
111
|
const e = b.fn();
|
|
112
112
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox", disabled: !0, onChange: e }));
|
|
113
113
|
const s = o.getByTestId("checkbox");
|
|
114
|
-
|
|
114
|
+
h.keyDown(s, {
|
|
115
115
|
key: "Enter"
|
|
116
|
-
}), c(e).not.toHaveBeenCalled(),
|
|
116
|
+
}), c(e).not.toHaveBeenCalled(), h.keyDown(s, {
|
|
117
117
|
key: " "
|
|
118
118
|
}), c(e).not.toHaveBeenCalled();
|
|
119
119
|
});
|
|
120
|
-
}),
|
|
121
|
-
|
|
120
|
+
}), a("Accessibility", () => {
|
|
121
|
+
d("should have unique id attributes", () => {
|
|
122
122
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox" })), n(/* @__PURE__ */ t(l, { label: "Test checkbox" }));
|
|
123
123
|
const e = o.queryAllByTestId("checkbox");
|
|
124
124
|
c(e).toHaveLength(2);
|
|
125
125
|
const s = e.map((r) => r.getAttribute("id")), k = Array.from(new Set(s)).length;
|
|
126
126
|
c(k).toBe(2);
|
|
127
|
-
}),
|
|
127
|
+
}), d("should have proper ARIA attributes", () => {
|
|
128
128
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox" }));
|
|
129
129
|
const e = o.getByTestId("checkbox");
|
|
130
130
|
c(e).toHaveAttribute("role", "checkbox");
|
|
131
|
-
}),
|
|
131
|
+
}), d("should have label associated with checkbox", () => {
|
|
132
132
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox" }));
|
|
133
133
|
const e = o.getByTestId("checkbox"), s = o.getByTestId("checkbox-label");
|
|
134
134
|
c(s).toHaveAttribute("for", e.getAttribute("id"));
|
|
135
|
-
}),
|
|
135
|
+
}), d("should be focusable when enabled", () => {
|
|
136
136
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox" }));
|
|
137
137
|
const e = o.getByTestId("checkbox");
|
|
138
138
|
e.focus(), c(e).toHaveFocus();
|
|
139
|
-
}),
|
|
139
|
+
}), d("should not be focusable when disabled", () => {
|
|
140
140
|
n(/* @__PURE__ */ t(l, { label: "Test checkbox", disabled: !0 }));
|
|
141
141
|
const e = o.getByTestId("checkbox");
|
|
142
|
-
|
|
142
|
+
c(e).toBeDisabled();
|
|
143
143
|
});
|
|
144
144
|
});
|
|
145
145
|
});
|
|
@@ -1,59 +1,58 @@
|
|
|
1
|
-
import { jsxs as w, jsx as
|
|
1
|
+
import { jsxs as w, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import { c as C } from "../../clsx-OuTLNxxd.js";
|
|
3
|
-
import {
|
|
3
|
+
import { useState as A, useRef as R, useEffect as V, useCallback as ae } from "react";
|
|
4
4
|
import B from "../Icon/Icon.js";
|
|
5
|
-
import
|
|
5
|
+
import he from "../Button/Button.js";
|
|
6
6
|
import "../Input/Input.js";
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
dropdownLabel: Oe,
|
|
7
|
+
import Ie from "../Tooltip/Tooltip.js";
|
|
8
|
+
import { R as ve, A as Le, P as Ne, C as ge } from "../../index-C4ffg1vf.js";
|
|
9
|
+
import '../../assets/Creatable.css';const ye = "Creatable-module__dropdownContainer___y0ptC", De = "Creatable-module__dropdownLabel___RyuSY", ke = "Creatable-module__dropdownLabelDisabled___nhYc0", xe = "Creatable-module__required___g26DB", Oe = "Creatable-module__dropdownWrapper___wu-B3", Ae = "Creatable-module__selectedItemsCreatable___P0mME", Re = "Creatable-module__selectedItem___0LADh", Ve = "Creatable-module__selectedItemLabel___m0LSV", Ee = "Creatable-module__removeButton___tjxwh", Fe = "Creatable-module__removeIcon___KQKbD", Se = "Creatable-module__singleSelectedCreatableItem___tanxX", Me = "Creatable-module__singleSelectedCreatableItemRemoveButton___Qi9Si", Be = "Creatable-module__dropdownActions___FmHZe", Ge = "Creatable-module__dropdownArrow___SJmKg", Ke = "Creatable-module__dropdownArrowOpen___T3E0S", je = "Creatable-module__dropdownMenu___HEhC3", Ue = "Creatable-module__dropdownCreatableSearchContainer___AgXA3", We = "Creatable-module__disabled___ZIdus", $e = "Creatable-module__dropdownCreatableError___FYVla", Je = "Creatable-module__creatableInput___KaKxv", Pe = "Creatable-module__optionsList___VZgJf", Ye = "Creatable-module__categoryGroup___g8f-g", qe = "Creatable-module__categoryDivider___QUgR9", ze = "Creatable-module__categoryLabel___YhGp9", Qe = "Creatable-module__optionItem___Ys808", Ze = "Creatable-module__optionItemDisabled___jvfGz", He = "Creatable-module__optionItemFocused___OfIQd", Te = "Creatable-module__optionContent___9RCsJ", Xe = "Creatable-module__optionLabel___FJfM1", et = "Creatable-module__tickIcon___VjpDN", tt = "Creatable-module__helpers___GmPY4", lt = "Creatable-module__helpText___89mXU", ot = "Creatable-module__helpTextDisabled___shU6E", at = "Creatable-module__helpLink___IdU0g", rt = "Creatable-module__helpLinkDisabled___B8rpy", nt = "Creatable-module__errorMessage___HRKr5", t = {
|
|
10
|
+
dropdownContainer: ye,
|
|
11
|
+
dropdownLabel: De,
|
|
13
12
|
"label-text": "Creatable-module__label-text___jlV2x",
|
|
14
|
-
dropdownLabelDisabled:
|
|
13
|
+
dropdownLabelDisabled: ke,
|
|
15
14
|
"label-tooltip-icon": "Creatable-module__label-tooltip-icon___G7Bou",
|
|
16
|
-
required:
|
|
17
|
-
dropdownWrapper:
|
|
18
|
-
selectedItemsCreatable:
|
|
19
|
-
selectedItem:
|
|
20
|
-
selectedItemLabel:
|
|
21
|
-
removeButton:
|
|
22
|
-
removeIcon:
|
|
23
|
-
singleSelectedCreatableItem:
|
|
24
|
-
singleSelectedCreatableItemRemoveButton:
|
|
25
|
-
dropdownActions:
|
|
26
|
-
dropdownArrow:
|
|
27
|
-
dropdownArrowOpen:
|
|
28
|
-
dropdownMenu:
|
|
15
|
+
required: xe,
|
|
16
|
+
dropdownWrapper: Oe,
|
|
17
|
+
selectedItemsCreatable: Ae,
|
|
18
|
+
selectedItem: Re,
|
|
19
|
+
selectedItemLabel: Ve,
|
|
20
|
+
removeButton: Ee,
|
|
21
|
+
removeIcon: Fe,
|
|
22
|
+
singleSelectedCreatableItem: Se,
|
|
23
|
+
singleSelectedCreatableItemRemoveButton: Me,
|
|
24
|
+
dropdownActions: Be,
|
|
25
|
+
dropdownArrow: Ge,
|
|
26
|
+
dropdownArrowOpen: Ke,
|
|
27
|
+
dropdownMenu: je,
|
|
29
28
|
"dropdown-container-grouped": "Creatable-module__dropdown-container-grouped___gZle-",
|
|
30
29
|
"dropdown-container-multi-select": "Creatable-module__dropdown-container-multi-select___1U1U4",
|
|
31
|
-
dropdownCreatableSearchContainer:
|
|
32
|
-
disabled:
|
|
33
|
-
dropdownCreatableError:
|
|
34
|
-
creatableInput:
|
|
35
|
-
optionsList:
|
|
36
|
-
categoryGroup:
|
|
37
|
-
categoryDivider:
|
|
38
|
-
categoryLabel:
|
|
39
|
-
optionItem:
|
|
40
|
-
optionItemDisabled:
|
|
41
|
-
optionItemFocused:
|
|
42
|
-
optionContent:
|
|
43
|
-
optionLabel:
|
|
44
|
-
tickIcon:
|
|
45
|
-
helpers:
|
|
46
|
-
helpText:
|
|
47
|
-
helpTextDisabled:
|
|
48
|
-
helpLink:
|
|
49
|
-
helpLinkDisabled:
|
|
50
|
-
errorMessage:
|
|
30
|
+
dropdownCreatableSearchContainer: Ue,
|
|
31
|
+
disabled: We,
|
|
32
|
+
dropdownCreatableError: $e,
|
|
33
|
+
creatableInput: Je,
|
|
34
|
+
optionsList: Pe,
|
|
35
|
+
categoryGroup: Ye,
|
|
36
|
+
categoryDivider: qe,
|
|
37
|
+
categoryLabel: ze,
|
|
38
|
+
optionItem: Qe,
|
|
39
|
+
optionItemDisabled: Ze,
|
|
40
|
+
optionItemFocused: He,
|
|
41
|
+
optionContent: Te,
|
|
42
|
+
optionLabel: Xe,
|
|
43
|
+
tickIcon: et,
|
|
44
|
+
helpers: tt,
|
|
45
|
+
helpText: lt,
|
|
46
|
+
helpTextDisabled: ot,
|
|
47
|
+
helpLink: at,
|
|
48
|
+
helpLinkDisabled: rt,
|
|
49
|
+
errorMessage: nt
|
|
51
50
|
};
|
|
52
|
-
function
|
|
51
|
+
function bt({
|
|
53
52
|
className: re,
|
|
54
53
|
label: G,
|
|
55
|
-
options:
|
|
56
|
-
value:
|
|
54
|
+
options: D,
|
|
55
|
+
value: k = [],
|
|
57
56
|
disabled: v = !1,
|
|
58
57
|
required: ne = !1,
|
|
59
58
|
maxLength: se,
|
|
@@ -63,7 +62,7 @@ function ht({
|
|
|
63
62
|
helpLink: J,
|
|
64
63
|
helpLinkText: P,
|
|
65
64
|
onChange: r,
|
|
66
|
-
onSearch:
|
|
65
|
+
onSearch: x,
|
|
67
66
|
multiSelect: m = !1,
|
|
68
67
|
grouped: ce = !1,
|
|
69
68
|
align: Y = "left",
|
|
@@ -75,71 +74,71 @@ function ht({
|
|
|
75
74
|
caseSensitive: j = !1,
|
|
76
75
|
..._e
|
|
77
76
|
}) {
|
|
78
|
-
const
|
|
77
|
+
const [u, N] = A(k), [c, h] = A(!1), [Q, b] = A(""), [f, i] = A(-1), Z = R(null), O = R(null), g = R(null), H = R(null), [T, ue] = A(0), X = R(k);
|
|
79
78
|
V(() => {
|
|
80
|
-
JSON.stringify(X.current) !== JSON.stringify(
|
|
81
|
-
}, [
|
|
79
|
+
JSON.stringify(X.current) !== JSON.stringify(k) && (N(k), X.current = k);
|
|
80
|
+
}, [k]), V(() => {
|
|
82
81
|
var a;
|
|
83
82
|
const e = (a = O.current) == null ? void 0 : a.getBoundingClientRect().width;
|
|
84
|
-
e &&
|
|
83
|
+
e && ue(e);
|
|
85
84
|
}, []);
|
|
86
|
-
const _ = Q.trim(), p =
|
|
87
|
-
const a = j ? e.label : e.label.toLowerCase(),
|
|
88
|
-
return a.includes(
|
|
89
|
-
}), S = _ !== "" && !
|
|
85
|
+
const _ = Q.trim(), p = D.filter((e) => {
|
|
86
|
+
const a = j ? e.label : e.label.toLowerCase(), l = j ? _ : _.toLowerCase();
|
|
87
|
+
return a.includes(l);
|
|
88
|
+
}), S = _ !== "" && !D.find((e) => j ? e.label === _ : e.label.toLowerCase() === _.toLowerCase());
|
|
90
89
|
V(() => {
|
|
91
90
|
c && g.current && g.current.focus();
|
|
92
91
|
}, [c]);
|
|
93
|
-
const
|
|
92
|
+
const pe = (e) => {
|
|
94
93
|
h(e), b(""), i(-1);
|
|
95
94
|
}, U = ae((e) => {
|
|
96
|
-
var
|
|
95
|
+
var l, n;
|
|
97
96
|
const a = {
|
|
98
97
|
value: e,
|
|
99
98
|
label: e,
|
|
100
99
|
disabled: !1
|
|
101
100
|
};
|
|
102
|
-
if (
|
|
103
|
-
const
|
|
104
|
-
N(
|
|
101
|
+
if (D.push(a), m) {
|
|
102
|
+
const y = u.includes(e) ? u : [...u, e];
|
|
103
|
+
N(y), r == null || r(y), (l = g.current) == null || l.focus(), b(""), h(!0), i(-1);
|
|
105
104
|
} else {
|
|
106
105
|
const d = [e];
|
|
107
106
|
N(d), r == null || r(d), b(""), (n = O.current) == null || n.focus(), h(!1), i(-1);
|
|
108
107
|
}
|
|
109
|
-
}, [m, r,
|
|
110
|
-
var a,
|
|
108
|
+
}, [m, r, D, u]), W = ae((e) => {
|
|
109
|
+
var a, l, n;
|
|
111
110
|
if (!e.disabled)
|
|
112
111
|
if (m) {
|
|
113
|
-
const
|
|
114
|
-
N(
|
|
112
|
+
const y = u.includes(e.value) ? u.filter((Ce) => Ce !== e.value) : [...u, e.value];
|
|
113
|
+
N(y), r == null || r(y), h(!0), (a = g.current) == null || a.focus(), b(""), i(-1);
|
|
115
114
|
} else if (u.includes(e.value)) {
|
|
116
115
|
if (q) {
|
|
117
116
|
const d = [];
|
|
118
|
-
N(d), r == null || r(d), (
|
|
117
|
+
N(d), r == null || r(d), (l = O.current) == null || l.focus(), h(!1), b(""), i(-1);
|
|
119
118
|
}
|
|
120
119
|
} else {
|
|
121
120
|
const d = [e.value];
|
|
122
121
|
N(d), r == null || r(d), (n = O.current) == null || n.focus(), h(!1), b(""), i(-1);
|
|
123
122
|
}
|
|
124
|
-
}, [m, r, u, q]),
|
|
125
|
-
h(!0), b(e), i(-1),
|
|
123
|
+
}, [m, r, u, q]), me = (e) => {
|
|
124
|
+
h(!0), b(e), i(-1), x == null || x(e);
|
|
126
125
|
}, $ = (e) => {
|
|
127
|
-
h(!0), b(e), i(-1),
|
|
126
|
+
h(!0), b(e), i(-1), x == null || x(e);
|
|
128
127
|
}, ee = (e) => {
|
|
129
|
-
const a = u.filter((
|
|
128
|
+
const a = u.filter((l) => l !== e);
|
|
130
129
|
N(a), r == null || r(a);
|
|
131
130
|
};
|
|
132
131
|
V(() => {
|
|
133
132
|
const e = (a) => {
|
|
134
133
|
if (!c) return;
|
|
135
|
-
const
|
|
136
|
-
if (
|
|
134
|
+
const l = p.length + (S ? 1 : 0);
|
|
135
|
+
if (l !== 0)
|
|
137
136
|
switch (a.key) {
|
|
138
137
|
case "ArrowDown":
|
|
139
|
-
a.preventDefault(), i((n) => n < 0 ? 0 : n <
|
|
138
|
+
a.preventDefault(), i((n) => n < 0 ? 0 : n < l - 1 ? n + 1 : 0);
|
|
140
139
|
break;
|
|
141
140
|
case "ArrowUp":
|
|
142
|
-
a.preventDefault(), i((n) => n < 0 ?
|
|
141
|
+
a.preventDefault(), i((n) => n < 0 ? l - 1 : n > 0 ? n - 1 : l - 1);
|
|
143
142
|
break;
|
|
144
143
|
case "Enter":
|
|
145
144
|
if (a.preventDefault(), f >= 0 && f < p.length) {
|
|
@@ -160,21 +159,21 @@ function ht({
|
|
|
160
159
|
block: "nearest"
|
|
161
160
|
});
|
|
162
161
|
}, [c, f]);
|
|
163
|
-
const M = u, s =
|
|
164
|
-
const
|
|
165
|
-
return e[
|
|
166
|
-
}, {}),
|
|
162
|
+
const M = u, s = D.filter((e) => M.includes(e.value)), be = !!E, te = D.filter((e) => !e.disabled), le = te.length > 0 && te.every((e) => M.includes(e.value)), fe = p.reduce((e, a) => {
|
|
163
|
+
const l = a.category || "default";
|
|
164
|
+
return e[l] || (e[l] = []), e[l].push(a), e;
|
|
165
|
+
}, {}), we = p, {
|
|
167
166
|
onBlur: I,
|
|
168
|
-
...
|
|
167
|
+
...oe
|
|
169
168
|
} = _e;
|
|
170
|
-
return /* @__PURE__ */ w("div", { ref: Z, className: C(t.dropdownContainer, ce && t["dropdown-container-grouped"], m && t["dropdown-container-multi-select"], re), ...
|
|
169
|
+
return /* @__PURE__ */ w("div", { ref: Z, className: C(t.dropdownContainer, ce && t["dropdown-container-grouped"], m && t["dropdown-container-multi-select"], re), ...oe, children: [
|
|
171
170
|
G && /* @__PURE__ */ w("label", { className: C(t.dropdownLabel, v && t.dropdownLabelDisabled), children: [
|
|
172
|
-
/* @__PURE__ */
|
|
173
|
-
ne && /* @__PURE__ */
|
|
174
|
-
L && /* @__PURE__ */
|
|
171
|
+
/* @__PURE__ */ o("span", { title: G, className: t["label-text"], children: G }),
|
|
172
|
+
ne && /* @__PURE__ */ o("span", { className: t.required, children: "*" }),
|
|
173
|
+
L && /* @__PURE__ */ o(Ie, { content: L.content, size: L.size, theme: L.theme, tipSide: L.tipSide, tipAlignment: L.tipAlignment, startVisible: L.startVisible, children: /* @__PURE__ */ o(B, { icon: "ap-icon-info", className: t["label-tooltip-icon"] }) })
|
|
175
174
|
] }),
|
|
176
|
-
/* @__PURE__ */
|
|
177
|
-
/* @__PURE__ */
|
|
175
|
+
/* @__PURE__ */ o(ve, { open: c, onOpenChange: pe, children: /* @__PURE__ */ w("div", { className: t.dropdownWrapper, children: [
|
|
176
|
+
/* @__PURE__ */ o(Le, { children: /* @__PURE__ */ w("div", { tabIndex: !m && s.length > 0 ? 0 : -1, ref: O, className: C(t.dropdownCreatableSearchContainer, v && t.disabled, be && t.dropdownCreatableError), onBlur: (e) => {
|
|
178
177
|
c || I == null || I(e);
|
|
179
178
|
}, onClick: () => {
|
|
180
179
|
var e;
|
|
@@ -184,49 +183,49 @@ function ht({
|
|
|
184
183
|
}, onKeyDown: (e) => {
|
|
185
184
|
if (e.key === "Enter" && !m && s.length > 0 && !c)
|
|
186
185
|
return $("");
|
|
187
|
-
}, ...
|
|
188
|
-
s.length > 0 && /* @__PURE__ */
|
|
189
|
-
/* @__PURE__ */
|
|
190
|
-
/* @__PURE__ */
|
|
186
|
+
}, ...oe, children: [
|
|
187
|
+
s.length > 0 && /* @__PURE__ */ o("div", { className: C(t.selectedItemsCreatable), children: m ? s.length > 3 ? /* @__PURE__ */ o("div", { className: t.selectedItem, children: /* @__PURE__ */ o("span", { className: t.selectedItemLabel, title: le && F ? F : `${s.length} ${z}`, children: le && F ? F : `${s.length} ${z}` }) }) : s.map((e) => /* @__PURE__ */ w("div", { className: t.selectedItem, children: [
|
|
188
|
+
/* @__PURE__ */ o("span", { className: t.selectedItemLabel, title: e.label, children: e.label }),
|
|
189
|
+
/* @__PURE__ */ o("button", { type: "button", className: t.removeButton, onClick: () => ee(e.value), disabled: v, children: /* @__PURE__ */ o(B, { icon: "ap-icon-close", className: t.removeIcon }) })
|
|
191
190
|
] }, e.value)) : s.length > 0 && /* @__PURE__ */ w("div", { className: t.singleSelectedCreatableItem, children: [
|
|
192
|
-
/* @__PURE__ */
|
|
193
|
-
/* @__PURE__ */
|
|
191
|
+
/* @__PURE__ */ o("span", { className: t.selectedItemLabel, title: s[0].label, children: s[0].label }),
|
|
192
|
+
/* @__PURE__ */ o(he, { type: "tertiary", variant: "default", size: "sm", onClick: () => ee(s[0].value), disabled: v, icon: "ap-icon-add-filled", className: t.singleSelectedCreatableItemRemoveButton })
|
|
194
193
|
] }) }),
|
|
195
|
-
(m || !s.length) && /* @__PURE__ */
|
|
194
|
+
(m || !s.length) && /* @__PURE__ */ o("input", { maxLength: se, ref: g, placeholder: s.length > 0 ? "" : de, value: Q, onChange: (e) => me(e.target.value), onFocus: (e) => $(e.target.value), onBlur: (e) => {
|
|
196
195
|
c || I == null || I(e);
|
|
197
196
|
}, disabled: v, className: t.creatableInput }),
|
|
198
|
-
/* @__PURE__ */
|
|
197
|
+
/* @__PURE__ */ o("div", { className: t.dropdownActions, children: /* @__PURE__ */ o(B, { icon: "ap-icon-expand-more", className: C(t.dropdownArrow, c && t.dropdownArrowOpen) }) })
|
|
199
198
|
] }) }),
|
|
200
|
-
/* @__PURE__ */
|
|
199
|
+
/* @__PURE__ */ o(Ne, { children: /* @__PURE__ */ o(ge, { onOpenAutoFocus: (e) => {
|
|
201
200
|
e.preventDefault();
|
|
202
201
|
}, align: Y === "right" ? "end" : "start", side: "bottom", avoidCollisions: !0, sideOffset: 6, collisionPadding: 8, style: {
|
|
203
202
|
width: T,
|
|
204
203
|
zIndex: 9999
|
|
205
204
|
}, onInteractOutside: (e) => {
|
|
206
|
-
var
|
|
207
|
-
e.target === g.current && e.preventDefault(), ((
|
|
208
|
-
}, children: c && /* @__PURE__ */
|
|
205
|
+
var l;
|
|
206
|
+
e.target === g.current && e.preventDefault(), ((l = Z.current) == null ? void 0 : l.contains(e.target)) || I == null || I(e);
|
|
207
|
+
}, children: c && /* @__PURE__ */ o("div", { style: {
|
|
209
208
|
width: T
|
|
210
209
|
}, 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(
|
|
212
|
-
e !== "default" && /* @__PURE__ */
|
|
213
|
-
a.map((
|
|
214
|
-
const n =
|
|
215
|
-
return /* @__PURE__ */
|
|
216
|
-
/* @__PURE__ */
|
|
217
|
-
M.includes(
|
|
218
|
-
] }) },
|
|
210
|
+
p.length > 0 ? Object.entries(fe).map(([e, a]) => /* @__PURE__ */ w("div", { className: t.categoryGroup, children: [
|
|
211
|
+
e !== "default" && /* @__PURE__ */ o("div", { className: t.categoryDivider, children: /* @__PURE__ */ o("span", { className: t.categoryLabel, children: e }) }),
|
|
212
|
+
a.map((l) => {
|
|
213
|
+
const n = we.indexOf(l), d = p.find((y) => y.value === l.value);
|
|
214
|
+
return /* @__PURE__ */ o("button", { title: (d == null ? void 0 : d.label) || l.label, type: "button", className: C(t.optionItem, M.includes(l.value) && t.optionItemSelected, l.disabled && t.optionItemDisabled, n === f && t.optionItemFocused), onClick: () => W(l), disabled: l.disabled, "data-dropdown-option-item": !0, "data-option-index": n, children: /* @__PURE__ */ w("div", { className: t.optionContent, children: [
|
|
215
|
+
/* @__PURE__ */ o("span", { className: t.optionLabel, children: l.label }),
|
|
216
|
+
M.includes(l.value) && /* @__PURE__ */ o(B, { icon: "ap-icon-check", className: t.tickIcon })
|
|
217
|
+
] }) }, l.value);
|
|
219
218
|
})
|
|
220
219
|
] }, e)) : null,
|
|
221
|
-
S && /* @__PURE__ */
|
|
220
|
+
S && /* @__PURE__ */ o("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__ */ o("div", { className: t.optionContent, children: /* @__PURE__ */ o("span", { className: t.optionLabel, children: _ ? `Create "${_}"` : "Create new option" }) }) })
|
|
222
221
|
] }) }) }) })
|
|
223
222
|
] }) }),
|
|
224
223
|
/* @__PURE__ */ w("div", { className: t.helpers, children: [
|
|
225
|
-
E ? /* @__PURE__ */
|
|
226
|
-
J && P && /* @__PURE__ */
|
|
224
|
+
E ? /* @__PURE__ */ o("span", { title: E, className: t.errorMessage, children: E }) : K && /* @__PURE__ */ o("span", { title: K, className: C(t.helpText, v && t.helpTextDisabled), children: K }),
|
|
225
|
+
J && P && /* @__PURE__ */ o("a", { href: J, className: C(t.helpLink, v && t.helpLinkDisabled), target: "_blank", rel: "noopener noreferrer", children: P })
|
|
227
226
|
] })
|
|
228
227
|
] });
|
|
229
228
|
}
|
|
230
229
|
export {
|
|
231
|
-
|
|
230
|
+
bt as default
|
|
232
231
|
};
|