asma-ui-core 3.80.2 → 3.81.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 +32 -0
- package/dist/asma-ui-core.css +1 -1
- package/dist/components/inputs/dynamic-select/components/DynamicSelectAutocomplete.js +2 -2
- package/dist/components/inputs/phone-field/CountryCodeOptions.js +39 -0
- package/dist/components/inputs/phone-field/CountryCodeSelect.js +145 -0
- package/dist/components/inputs/phone-field/StyledCountryFlag.js +25 -0
- package/dist/components/inputs/phone-field/StyledPhoneField.js +74 -0
- package/dist/components/inputs/phone-field/useCountryPicker.js +55 -0
- package/dist/components/inputs/search-field/StyledSearchField.js +28 -24
- package/dist/components/inputs/select/StyledSelect.js +24 -24
- package/dist/components/inputs/select-autocomplete/StyledSelectAutocomplete.js +35 -35
- package/dist/index.js +117 -113
- package/dist/src/components/inputs/phone-field/CountryCodeOptions.d.ts +20 -0
- package/dist/src/components/inputs/phone-field/CountryCodeSelect.d.ts +30 -0
- package/dist/src/components/inputs/phone-field/StyledCountryFlag.d.ts +34 -0
- package/dist/src/components/inputs/phone-field/StyledPhoneField.d.ts +81 -0
- package/dist/src/components/inputs/phone-field/index.d.ts +3 -0
- package/dist/src/components/inputs/phone-field/types.d.ts +24 -0
- package/dist/src/components/inputs/phone-field/useCountryPicker.d.ts +30 -0
- package/dist/src/components/inputs/phone-field/useCountryPicker.test.d.ts +1 -0
- package/dist/src/components/inputs/select/StyledSelectItem.d.ts +2 -1
- package/dist/src/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -95,7 +95,7 @@ var ye = oe((k, F) => {
|
|
|
95
95
|
"aria-disabled": a
|
|
96
96
|
}, e["data-active"] !== void 0 && /* @__PURE__ */ l("span", {
|
|
97
97
|
"aria-hidden": "true",
|
|
98
|
-
className: "pointer-events-none absolute inset-y-0 left-0 border-l border-solid border-focus-ring"
|
|
98
|
+
className: "pointer-events-none absolute inset-y-0 left-0 border-l-[4px] border-solid border-focus-ring"
|
|
99
99
|
}), /* @__PURE__ */ l(L, {
|
|
100
100
|
arrow: !0,
|
|
101
101
|
title: c,
|
|
@@ -123,7 +123,7 @@ var ye = oe((k, F) => {
|
|
|
123
123
|
"aria-disabled": a
|
|
124
124
|
}, e["data-active"] !== void 0 && /* @__PURE__ */ l("span", {
|
|
125
125
|
"aria-hidden": "true",
|
|
126
|
-
className: "pointer-events-none absolute inset-y-0 left-0 border-l border-solid border-focus-ring"
|
|
126
|
+
className: "pointer-events-none absolute inset-y-0 left-0 border-l-[4px] border-solid border-focus-ring"
|
|
127
127
|
}), /* @__PURE__ */ l(L, {
|
|
128
128
|
arrow: !0,
|
|
129
129
|
title: c,
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { cn as i } from "../../../helpers/cn.js";
|
|
2
|
+
import { StyledSelectItem as u } from "../select/StyledSelectItem.js";
|
|
3
|
+
import { useEffect as x, useRef as N } from "react";
|
|
4
|
+
import { jsx as l, jsxs as o } from "react/jsx-runtime";
|
|
5
|
+
var j = ({ dataTest: m, visible: n, selectedIso2: d, activeIndex: s, optionId: r, onSelect: c, listId: f, label: p, renderFlag: b, className: h }) => {
|
|
6
|
+
const a = N(null);
|
|
7
|
+
return x(() => {
|
|
8
|
+
a.current?.querySelector(`#${CSS.escape(r(s))}`)?.scrollIntoView({ block: "nearest" });
|
|
9
|
+
}), /* @__PURE__ */ l("ul", {
|
|
10
|
+
ref: a,
|
|
11
|
+
id: f,
|
|
12
|
+
role: "listbox",
|
|
13
|
+
"aria-label": p,
|
|
14
|
+
"data-testid": `${m}-listbox`,
|
|
15
|
+
className: i("m-0 min-h-0 flex-1 list-none overflow-y-auto p-0", h),
|
|
16
|
+
children: n.map((e, t) => /* @__PURE__ */ l(u, {
|
|
17
|
+
id: r(t),
|
|
18
|
+
selected: e.iso2 === d,
|
|
19
|
+
onClick: () => c(e.iso2),
|
|
20
|
+
className: i("border-0 border-b border-solid border-delta-100", t === s && "bg-delta-50"),
|
|
21
|
+
children: /* @__PURE__ */ o("span", {
|
|
22
|
+
className: "flex w-full items-center justify-between gap-2",
|
|
23
|
+
children: [/* @__PURE__ */ o("span", {
|
|
24
|
+
className: "flex min-w-0 items-center gap-2",
|
|
25
|
+
children: [b?.(e.iso2, "eager"), /* @__PURE__ */ l("span", {
|
|
26
|
+
className: "truncate",
|
|
27
|
+
children: e.name
|
|
28
|
+
})]
|
|
29
|
+
}), /* @__PURE__ */ l("span", {
|
|
30
|
+
className: "shrink-0 font-medium text-delta-800",
|
|
31
|
+
children: `+${e.dialCode}`
|
|
32
|
+
})]
|
|
33
|
+
})
|
|
34
|
+
}, e.iso2))
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
j as CountryCodeOptions
|
|
39
|
+
};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { cn as m } from "../../../helpers/cn.js";
|
|
2
|
+
import { ChevronDownIcon as E } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
|
|
3
|
+
import { useMobileMediaQuery as Q } from "../../../hooks/useMediaQuery.hook.js";
|
|
4
|
+
import { StyledDialog as q } from "../../feedback/dialog/StyledDialog.js";
|
|
5
|
+
import { StyledPopover as A } from "../../utils/popover/StyledPopover.js";
|
|
6
|
+
import { notchedOutlineClass as F } from "../field-styles.js";
|
|
7
|
+
import { StyledSearchField as W } from "../search-field/StyledSearchField.js";
|
|
8
|
+
import { CountryCodeOptions as B } from "./CountryCodeOptions.js";
|
|
9
|
+
import { useCountryPicker as G } from "./useCountryPicker.js";
|
|
10
|
+
import { useEffect as K, useId as H, useRef as f, useState as x } from "react";
|
|
11
|
+
import { Fragment as J, jsx as e, jsxs as s } from "react/jsx-runtime";
|
|
12
|
+
var re = ({ dataTest: r, countries: b, value: n, onChange: O, disabled: i, selectCountryLabel: g, searchPlaceholder: P, renderFlag: u, labelledBy: v, className: M }) => {
|
|
13
|
+
const [t, w] = x(!1), [h, c] = x(""), [R, j] = x(null), y = f(null), C = f(null), I = f(!1), d = Q(), p = `${H()}-country-listbox`, N = b.find((a) => a.iso2 === n), k = N === void 0 ? "" : `+${N.dialCode}`, l = () => {
|
|
14
|
+
w(!1), c("");
|
|
15
|
+
}, D = (a) => {
|
|
16
|
+
O(a), l();
|
|
17
|
+
}, o = G({
|
|
18
|
+
countries: b,
|
|
19
|
+
selectedIso2: n,
|
|
20
|
+
query: h,
|
|
21
|
+
listId: p,
|
|
22
|
+
onSelect: D,
|
|
23
|
+
onDismiss: l
|
|
24
|
+
});
|
|
25
|
+
K(() => {
|
|
26
|
+
t && !d && y.current?.focus();
|
|
27
|
+
}, [t, d]), K(() => {
|
|
28
|
+
I.current && !t && C.current?.focus(), I.current = t;
|
|
29
|
+
}, [t]);
|
|
30
|
+
const S = /* @__PURE__ */ e(B, {
|
|
31
|
+
dataTest: r,
|
|
32
|
+
visible: o.visible,
|
|
33
|
+
selectedIso2: n,
|
|
34
|
+
activeIndex: o.activeIndex,
|
|
35
|
+
optionId: o.optionId,
|
|
36
|
+
onSelect: D,
|
|
37
|
+
listId: p,
|
|
38
|
+
label: g,
|
|
39
|
+
renderFlag: u
|
|
40
|
+
}), $ = {
|
|
41
|
+
role: "combobox",
|
|
42
|
+
"aria-activedescendant": o.visible.length > 0 ? o.optionId(o.activeIndex) : void 0,
|
|
43
|
+
"aria-autocomplete": "list",
|
|
44
|
+
"aria-controls": p,
|
|
45
|
+
"aria-expanded": !0
|
|
46
|
+
}, z = t && !d;
|
|
47
|
+
return /* @__PURE__ */ s(J, { children: [/* @__PURE__ */ s("div", {
|
|
48
|
+
ref: j,
|
|
49
|
+
"data-testid": `${r}-shell`,
|
|
50
|
+
style: { height: 40 },
|
|
51
|
+
className: m("group relative flex w-32 shrink-0 items-center gap-1.5 rounded px-3 text-base", i ? "cursor-not-allowed text-delta-300" : "text-delta-800"),
|
|
52
|
+
children: [/* @__PURE__ */ e("span", {
|
|
53
|
+
"aria-hidden": "true",
|
|
54
|
+
className: m(F({
|
|
55
|
+
disabled: i,
|
|
56
|
+
notched: !1
|
|
57
|
+
}), M)
|
|
58
|
+
}), z ? /* @__PURE__ */ s("span", {
|
|
59
|
+
className: "relative z-[1] flex w-full items-center gap-1.5",
|
|
60
|
+
children: [
|
|
61
|
+
u?.(n, "eager"),
|
|
62
|
+
/* @__PURE__ */ e("input", {
|
|
63
|
+
ref: y,
|
|
64
|
+
role: "combobox",
|
|
65
|
+
"data-testid": `${r}-search`,
|
|
66
|
+
className: "w-12 min-w-0 border-0 bg-transparent p-0 text-base outline-none",
|
|
67
|
+
value: h,
|
|
68
|
+
placeholder: k,
|
|
69
|
+
onChange: (a) => c(a.target.value),
|
|
70
|
+
onKeyDown: o.handleKeyDown,
|
|
71
|
+
"aria-controls": p,
|
|
72
|
+
"aria-expanded": !0,
|
|
73
|
+
"aria-activedescendant": $["aria-activedescendant"],
|
|
74
|
+
"aria-autocomplete": "list"
|
|
75
|
+
}),
|
|
76
|
+
/* @__PURE__ */ e("button", {
|
|
77
|
+
type: "button",
|
|
78
|
+
"data-testid": `${r}-collapse`,
|
|
79
|
+
"aria-labelledby": v,
|
|
80
|
+
"aria-expanded": !0,
|
|
81
|
+
onClick: l,
|
|
82
|
+
className: "ml-auto flex shrink-0 cursor-pointer border-0 bg-transparent p-0",
|
|
83
|
+
children: /* @__PURE__ */ e(E, {
|
|
84
|
+
width: 20,
|
|
85
|
+
height: 20,
|
|
86
|
+
className: "rotate-180"
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
]
|
|
90
|
+
}) : /* @__PURE__ */ s("button", {
|
|
91
|
+
ref: C,
|
|
92
|
+
type: "button",
|
|
93
|
+
"data-testid": r,
|
|
94
|
+
disabled: i,
|
|
95
|
+
"aria-haspopup": "listbox",
|
|
96
|
+
"aria-expanded": t,
|
|
97
|
+
"aria-labelledby": v,
|
|
98
|
+
onClick: () => w(!0),
|
|
99
|
+
className: m("relative z-[1] flex w-full items-center gap-1.5 border-0 bg-transparent p-0 text-base", i ? "cursor-not-allowed text-delta-300" : "cursor-pointer text-delta-800"),
|
|
100
|
+
children: [
|
|
101
|
+
u?.(n, "eager"),
|
|
102
|
+
/* @__PURE__ */ e("span", {
|
|
103
|
+
className: "w-12 text-left",
|
|
104
|
+
children: k
|
|
105
|
+
}),
|
|
106
|
+
/* @__PURE__ */ e(E, {
|
|
107
|
+
width: 20,
|
|
108
|
+
height: 20,
|
|
109
|
+
className: m("ml-auto shrink-0 transition-transform", t && "rotate-180")
|
|
110
|
+
})
|
|
111
|
+
]
|
|
112
|
+
})]
|
|
113
|
+
}), d ? /* @__PURE__ */ e(q, {
|
|
114
|
+
open: t,
|
|
115
|
+
onClose: l,
|
|
116
|
+
dataTest: `${r}-dialog`,
|
|
117
|
+
dialogTitle: g,
|
|
118
|
+
showCloseIcon: !0,
|
|
119
|
+
fullWidth: !0,
|
|
120
|
+
children: /* @__PURE__ */ s("div", {
|
|
121
|
+
className: "flex min-h-0 flex-1 flex-col",
|
|
122
|
+
children: [/* @__PURE__ */ e("div", {
|
|
123
|
+
className: "shrink-0 p-4",
|
|
124
|
+
children: /* @__PURE__ */ e(W, {
|
|
125
|
+
dataTest: `${r}-search`,
|
|
126
|
+
label: P,
|
|
127
|
+
value: h,
|
|
128
|
+
onChange: (a) => c(a.target.value),
|
|
129
|
+
onClear: () => c(""),
|
|
130
|
+
onKeyDown: o.handleKeyDown,
|
|
131
|
+
slotProps: { htmlInput: $ }
|
|
132
|
+
})
|
|
133
|
+
}), S]
|
|
134
|
+
})
|
|
135
|
+
}) : /* @__PURE__ */ e(A, {
|
|
136
|
+
open: t,
|
|
137
|
+
anchorEl: R,
|
|
138
|
+
onClose: l,
|
|
139
|
+
slotProps: { paper: { className: "flex max-h-80 w-80 flex-col overflow-hidden" } },
|
|
140
|
+
children: S
|
|
141
|
+
})] });
|
|
142
|
+
};
|
|
143
|
+
export {
|
|
144
|
+
re as CountryCodeSelect
|
|
145
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { cn as t } from "../../../helpers/cn.js";
|
|
2
|
+
import { useState as c } from "react";
|
|
3
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
4
|
+
var h = ({ iso2: r, src: o, loading: n = "lazy", className: d }) => {
|
|
5
|
+
const [s, i] = c(!1), e = t("h-4 w-6 shrink-0 rounded-sm bg-delta-100", d);
|
|
6
|
+
return s ? /* @__PURE__ */ a("span", {
|
|
7
|
+
"aria-hidden": "true",
|
|
8
|
+
"data-country": r.toLowerCase(),
|
|
9
|
+
className: e
|
|
10
|
+
}) : /* @__PURE__ */ a("img", {
|
|
11
|
+
src: o,
|
|
12
|
+
"data-country": r.toLowerCase(),
|
|
13
|
+
alt: "",
|
|
14
|
+
"aria-hidden": "true",
|
|
15
|
+
loading: n,
|
|
16
|
+
decoding: "async",
|
|
17
|
+
width: 24,
|
|
18
|
+
height: 16,
|
|
19
|
+
onError: () => i(!0),
|
|
20
|
+
className: t(e, "object-cover")
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
h as StyledCountryFlag
|
|
25
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { cn as L } from "../../../helpers/cn.js";
|
|
2
|
+
import { StyledInputField as M } from "../input-field/StyledInputField.js";
|
|
3
|
+
import { StyledLink as V } from "../../navigation/link/StyledLink.js";
|
|
4
|
+
import { CountryCodeSelect as W } from "./CountryCodeSelect.js";
|
|
5
|
+
import { useId as z } from "react";
|
|
6
|
+
import { jsx as t, jsxs as r } from "react/jsx-runtime";
|
|
7
|
+
var E = (e) => e.replace(/\D/g, ""), U = ({ dataTest: e, label: l, countries: h, country: n, onCountryChange: x, value: s, onChange: f, onBlur: N, error: v, helperText: y, reserveHelperText: g = !0, disabled: d, readOnly: $, readOnlyText: i, readOnlyHref: m, required: c, placeholder: b, formatNationalNumber: I, renderFlag: C, selectCountryLabel: S, searchPlaceholder: F, id: j, name: P, size: k = "medium", fieldClassName: p, helperTextClassName: w, className: A }) => {
|
|
8
|
+
const B = z(), a = j ?? `${B}-phone`, u = `${a}-label`, o = I?.(s, n) ?? s;
|
|
9
|
+
return /* @__PURE__ */ r("div", {
|
|
10
|
+
className: L("flex flex-col", A),
|
|
11
|
+
"data-testid": `${e}-root`,
|
|
12
|
+
children: [l != null && /* @__PURE__ */ r("label", {
|
|
13
|
+
id: u,
|
|
14
|
+
htmlFor: a,
|
|
15
|
+
className: "pb-1 text-base font-semibold text-delta-800",
|
|
16
|
+
children: [l, c === !0 && /* @__PURE__ */ t("span", {
|
|
17
|
+
"aria-hidden": "true",
|
|
18
|
+
children: " *"
|
|
19
|
+
})]
|
|
20
|
+
}), $ === !0 ? /* @__PURE__ */ t("span", {
|
|
21
|
+
className: "py-2 text-base text-delta-800",
|
|
22
|
+
children: m === void 0 ? /* @__PURE__ */ t("span", {
|
|
23
|
+
"data-testid": `${e}-readonly`,
|
|
24
|
+
children: i ?? o
|
|
25
|
+
}) : /* @__PURE__ */ t(V, {
|
|
26
|
+
dataTest: `${e}-readonly`,
|
|
27
|
+
href: m,
|
|
28
|
+
className: "-ml-1",
|
|
29
|
+
contentNode: i ?? o
|
|
30
|
+
})
|
|
31
|
+
}) : /* @__PURE__ */ r("div", {
|
|
32
|
+
className: "flex items-start gap-2.5",
|
|
33
|
+
children: [/* @__PURE__ */ t(W, {
|
|
34
|
+
dataTest: `${e}-country`,
|
|
35
|
+
countries: h,
|
|
36
|
+
value: n,
|
|
37
|
+
onChange: x,
|
|
38
|
+
disabled: d,
|
|
39
|
+
selectCountryLabel: S,
|
|
40
|
+
searchPlaceholder: F,
|
|
41
|
+
renderFlag: C,
|
|
42
|
+
labelledBy: l == null ? void 0 : u,
|
|
43
|
+
className: p
|
|
44
|
+
}), /* @__PURE__ */ t(M, {
|
|
45
|
+
dataTest: `${e}-number`,
|
|
46
|
+
className: "max-w-[200px]",
|
|
47
|
+
id: a,
|
|
48
|
+
name: P,
|
|
49
|
+
value: o,
|
|
50
|
+
onChange: (D) => f(E(D.target.value)),
|
|
51
|
+
onBlur: N,
|
|
52
|
+
placeholder: b,
|
|
53
|
+
error: v,
|
|
54
|
+
disabled: d,
|
|
55
|
+
required: c,
|
|
56
|
+
fullWidth: !0,
|
|
57
|
+
helperText: y,
|
|
58
|
+
reserveHelperText: g,
|
|
59
|
+
size: k,
|
|
60
|
+
slotProps: {
|
|
61
|
+
htmlInput: {
|
|
62
|
+
inputMode: "tel",
|
|
63
|
+
autoComplete: "tel"
|
|
64
|
+
},
|
|
65
|
+
input: { className: p },
|
|
66
|
+
formHelperText: { className: w }
|
|
67
|
+
}
|
|
68
|
+
})]
|
|
69
|
+
})]
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
export {
|
|
73
|
+
U as StyledPhoneField
|
|
74
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useMemo as m, useState as v } from "react";
|
|
2
|
+
function D(r, i) {
|
|
3
|
+
const n = i.trim();
|
|
4
|
+
if (n.length === 0) return !0;
|
|
5
|
+
const s = n.replace(/^\+/, "").replace(/\D/g, "");
|
|
6
|
+
return s.length === 0 && !new RegExp("\\p{L}", "u").test(n) || r.name.toLocaleLowerCase().includes(n.toLocaleLowerCase()) ? !0 : s.length > 0 && r.dialCode.startsWith(s);
|
|
7
|
+
}
|
|
8
|
+
function b({ countries: r, selectedIso2: i, query: n, listId: s, onSelect: f, onDismiss: d }) {
|
|
9
|
+
const [p, a] = v(i), o = m(() => r.filter((e) => D(e, n)), [r, n]), l = o.findIndex((e) => e.iso2 === p), c = l >= 0 ? l : 0, h = (e) => `${s}-option-${e}`, u = (e) => {
|
|
10
|
+
if (o.length === 0) return;
|
|
11
|
+
const t = o[(c + e + o.length) % o.length];
|
|
12
|
+
t !== void 0 && a(t.iso2);
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
visible: o,
|
|
16
|
+
activeIndex: c,
|
|
17
|
+
optionId: h,
|
|
18
|
+
handleKeyDown: (e) => {
|
|
19
|
+
switch (e.key) {
|
|
20
|
+
case "ArrowDown":
|
|
21
|
+
e.preventDefault(), u(1);
|
|
22
|
+
break;
|
|
23
|
+
case "ArrowUp":
|
|
24
|
+
e.preventDefault(), u(-1);
|
|
25
|
+
break;
|
|
26
|
+
case "Home": {
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
const t = o[0];
|
|
29
|
+
t !== void 0 && a(t.iso2);
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
case "End": {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
const t = o[o.length - 1];
|
|
35
|
+
t !== void 0 && a(t.iso2);
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
case "Enter": {
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
const t = o[c];
|
|
41
|
+
t !== void 0 && f(t.iso2);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
case "Escape":
|
|
45
|
+
e.preventDefault(), d();
|
|
46
|
+
break;
|
|
47
|
+
default:
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
b as useCountryPicker
|
|
55
|
+
};
|
|
@@ -1,49 +1,52 @@
|
|
|
1
1
|
import { cn as p } from "../../../helpers/cn.js";
|
|
2
|
-
import { SearchIcon as
|
|
2
|
+
import { SearchIcon as u } from "../../icons/search-icon/SearchIcon.js";
|
|
3
3
|
import { CloseIcon as f } from "../../icons/close-icon/CloseIcon.js";
|
|
4
|
-
import { StyledInputField as
|
|
5
|
-
import { useState as
|
|
4
|
+
import { StyledInputField as v } from "../input-field/StyledInputField.js";
|
|
5
|
+
import { useState as y } from "react";
|
|
6
6
|
import { jsx as t } from "react/jsx-runtime";
|
|
7
|
-
var
|
|
8
|
-
const [
|
|
7
|
+
var F = ({ value: r, onClear: d, label: a, onFocus: c, onBlur: h, slotProps: o, ...n }) => {
|
|
8
|
+
const [m, l] = y(!1), i = m || r, s = typeof a == "string" ? a : void 0;
|
|
9
9
|
return /* @__PURE__ */ t("div", {
|
|
10
10
|
className: "relative w-full",
|
|
11
|
-
children: /* @__PURE__ */ t(
|
|
11
|
+
children: /* @__PURE__ */ t(v, {
|
|
12
12
|
size: "small",
|
|
13
13
|
variant: "outlined",
|
|
14
|
-
value:
|
|
14
|
+
value: r,
|
|
15
15
|
reserveHelperText: !1,
|
|
16
|
-
label:
|
|
17
|
-
placeholder:
|
|
16
|
+
label: i ? a : void 0,
|
|
17
|
+
placeholder: i ? void 0 : s,
|
|
18
18
|
onFocus: (e) => {
|
|
19
|
-
l(!0),
|
|
19
|
+
l(!0), c?.(e);
|
|
20
20
|
},
|
|
21
21
|
onBlur: (e) => {
|
|
22
|
-
l(!1),
|
|
22
|
+
l(!1), h?.(e);
|
|
23
23
|
},
|
|
24
24
|
slotProps: {
|
|
25
|
+
...o,
|
|
25
26
|
htmlInput: {
|
|
27
|
+
"aria-label": i ? void 0 : s,
|
|
28
|
+
...o?.htmlInput,
|
|
26
29
|
style: {
|
|
27
30
|
overflow: "hidden",
|
|
28
31
|
textOverflow: "ellipsis",
|
|
29
32
|
whiteSpace: "nowrap",
|
|
30
|
-
...
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
...r ? { paddingRight: 40 } : {},
|
|
34
|
+
...o?.htmlInput?.style
|
|
35
|
+
}
|
|
33
36
|
},
|
|
34
37
|
input: {
|
|
35
|
-
endAdornment:
|
|
38
|
+
endAdornment: r ? /* @__PURE__ */ t("button", {
|
|
36
39
|
type: "button",
|
|
37
40
|
"aria-label": "Clear",
|
|
38
41
|
"data-testid": "styled-search-clear-icon",
|
|
39
|
-
className: p("cursor-pointer rounded-full border-0 bg-delta-50", "flex items-center justify-center", "transform-gpu transition-all duration-300 ease-in-out",
|
|
42
|
+
className: p("cursor-pointer rounded-full border-0 bg-delta-50", "flex items-center justify-center", "transform-gpu transition-all duration-300 ease-in-out", r ? "scale-100 opacity-100" : "pointer-events-none scale-75 opacity-0", n.readOnly && "-translate-x-[6.5px]"),
|
|
40
43
|
style: {
|
|
41
44
|
width: 24,
|
|
42
45
|
height: 24,
|
|
43
46
|
flexShrink: 0
|
|
44
47
|
},
|
|
45
48
|
onClick: (e) => {
|
|
46
|
-
e.preventDefault(), e.stopPropagation(),
|
|
49
|
+
e.preventDefault(), e.stopPropagation(), d?.();
|
|
47
50
|
},
|
|
48
51
|
children: /* @__PURE__ */ t(f, {
|
|
49
52
|
width: 20,
|
|
@@ -52,26 +55,27 @@ var I = ({ value: o, onClear: s, label: i, onFocus: d, onBlur: c, ...r }) => {
|
|
|
52
55
|
className: "pointer-events-none"
|
|
53
56
|
})
|
|
54
57
|
}) : null,
|
|
55
|
-
startAdornment:
|
|
58
|
+
startAdornment: i ? void 0 : /* @__PURE__ */ t("span", {
|
|
56
59
|
"data-testid": "styled-search-icon",
|
|
57
60
|
className: "flex items-center",
|
|
58
|
-
children: /* @__PURE__ */ t(
|
|
61
|
+
children: /* @__PURE__ */ t(u, {
|
|
59
62
|
width: 24,
|
|
60
63
|
height: 24,
|
|
61
64
|
color: "var(--colors-delta-700)",
|
|
62
65
|
className: "pointer-events-none"
|
|
63
66
|
})
|
|
64
|
-
})
|
|
67
|
+
}),
|
|
68
|
+
...o?.input
|
|
65
69
|
}
|
|
66
70
|
},
|
|
67
|
-
...
|
|
71
|
+
...n,
|
|
68
72
|
sx: {
|
|
69
|
-
width:
|
|
70
|
-
...
|
|
73
|
+
width: n.fullWidth ? "100%" : "var(--dynamic-toolbar-search-width, 160px)",
|
|
74
|
+
...n.sx
|
|
71
75
|
}
|
|
72
76
|
})
|
|
73
77
|
});
|
|
74
78
|
};
|
|
75
79
|
export {
|
|
76
|
-
|
|
80
|
+
F as StyledSearchField
|
|
77
81
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cn as
|
|
1
|
+
import { cn as y } from "../../../helpers/cn.js";
|
|
2
2
|
import { resolveSx as je } from "../../../helpers/sx.js";
|
|
3
3
|
import { ChevronDownIcon as Ue } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
|
|
4
4
|
import { CloseIcon as Ve } from "../../icons/close-icon/CloseIcon.js";
|
|
@@ -11,12 +11,12 @@ import { useFormControlContext as Xe } from "../../miscellaneous/FormControlCont
|
|
|
11
11
|
import { Children as se, cloneElement as Ze, isValidElement as u, useEffect as B, useId as et, useRef as tt, useState as x } from "react";
|
|
12
12
|
import { jsx as l, jsxs as L } from "react/jsx-runtime";
|
|
13
13
|
import { FloatingPortal as ot, autoUpdate as rt, flip as st, offset as nt, shift as lt, size as it, useClick as at, useDismiss as ct, useFloating as dt, useInteractions as ut, useMergeRefs as ft, useRole as pt } from "@floating-ui/react";
|
|
14
|
-
var Ct = ({ dataTest: T, value: M, defaultValue: ne, onChange: $, error: le, errorText: ie, helperText: j, reserveHelperText: ae, expandHelperText: ce = !0, allowClear: U, disabled: de, readOnly: c, name: w, placeholder: S, displayEmpty: C, multiple: f, renderValue: V, fullWidth: ue, className: fe, style: pe, sx: me, variant: be, children: q, MenuProps: ge, onFocus:
|
|
15
|
-
const d = Xe(),
|
|
14
|
+
var Ct = ({ dataTest: T, value: M, defaultValue: ne, onChange: $, error: le, errorText: ie, helperText: j, reserveHelperText: ae, expandHelperText: ce = !0, allowClear: U, disabled: de, readOnly: c, name: w, placeholder: S, displayEmpty: C, multiple: f, renderValue: V, fullWidth: ue, className: fe, style: pe, sx: me, variant: be, children: q, MenuProps: ge, onFocus: he, onBlur: ye, labelId: v }) => {
|
|
15
|
+
const d = Xe(), A = `${T}-listbox`, R = be === "standard", p = le ?? d?.error ?? !1, n = de ?? d?.disabled ?? !1, Y = p ? ie ?? j : j, { show: F, role: xe } = Je("StyledSelect", p, Y, ae, c), z = et(), { fieldRef: we, rowRef: ve, rowStyle: Ae } = Ge(ce && F), [r, K] = x(!1), [k, I] = x(!1), [m, b] = x(null), [Re, W] = x(ne), O = M !== void 0, o = O ? M : Re, i = Array.isArray(o) ? o.length > 0 : o !== void 0 && o !== "" && o !== null, g = se.toArray(q), G = (e) => f ? Array.isArray(o) && o.includes(e) : e === o, s = g.flatMap((e, t) => u(e) && !e.props.disabled ? [t] : []), E = g.findIndex((e) => u(e) && G(e.props.value)), ke = (e = 1) => s.includes(E) ? E : s[e === 1 ? 0 : s.length - 1] ?? null, D = m === null ? void 0 : `${A}-option-${m}`, P = tt(null), h = (e) => {
|
|
16
16
|
K(e), e || b(null);
|
|
17
17
|
}, { refs: { domReference: De, reference: J, setFloating: Se, setReference: Ce }, floatingStyles: Fe, context: N } = dt({
|
|
18
18
|
open: r,
|
|
19
|
-
onOpenChange:
|
|
19
|
+
onOpenChange: h,
|
|
20
20
|
placement: "bottom-start",
|
|
21
21
|
strategy: "fixed",
|
|
22
22
|
whileElementsMounted: rt,
|
|
@@ -55,18 +55,18 @@ var Ct = ({ dataTest: T, value: M, defaultValue: ne, onChange: $, error: le, err
|
|
|
55
55
|
O || W(oe), $?.({ target: {
|
|
56
56
|
value: oe,
|
|
57
57
|
name: w
|
|
58
|
-
} }, t), a && (
|
|
58
|
+
} }, t), a && (h(!1), requestAnimationFrame(() => De.current?.focus()));
|
|
59
59
|
}, ee = () => {
|
|
60
60
|
const e = f ? [] : "";
|
|
61
61
|
O || W(e), $?.({ target: {
|
|
62
62
|
value: e,
|
|
63
63
|
name: w
|
|
64
|
-
} }, null),
|
|
64
|
+
} }, null), h(!1), I(!1);
|
|
65
65
|
}, Pe = se.map(q, (e, t) => {
|
|
66
66
|
if (!u(e)) return e;
|
|
67
67
|
const a = e.props.value;
|
|
68
68
|
return Ze(e, {
|
|
69
|
-
id: `${
|
|
69
|
+
id: `${A}-option-${t}`,
|
|
70
70
|
active: t === m,
|
|
71
71
|
selected: G(a),
|
|
72
72
|
onClick: () => {
|
|
@@ -96,12 +96,12 @@ var Ct = ({ dataTest: T, value: M, defaultValue: ne, onChange: $, error: le, err
|
|
|
96
96
|
e.preventDefault(), Be(e.key === "ArrowDown" ? 1 : -1);
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
|
-
r && (e.key === "ArrowDown" || e.key === "ArrowUp" ? (e.preventDefault(), He(e.key === "ArrowDown" ? 1 : -1)) : e.key === "Home" || e.key === "End" ? (e.preventDefault(), b(s[e.key === "Home" ? 0 : s.length - 1] ?? null)) : e.key === " " ? (e.preventDefault(), te(!1)) : e.key === "Enter" ? (e.preventDefault(), te(!0)) : e.key === "Escape" ? (e.preventDefault(),
|
|
99
|
+
r && (e.key === "ArrowDown" || e.key === "ArrowUp" ? (e.preventDefault(), He(e.key === "ArrowDown" ? 1 : -1)) : e.key === "Home" || e.key === "End" ? (e.preventDefault(), b(s[e.key === "Home" ? 0 : s.length - 1] ?? null)) : e.key === " " ? (e.preventDefault(), te(!1)) : e.key === "Enter" ? (e.preventDefault(), te(!0)) : e.key === "Escape" ? (e.preventDefault(), h(!1)) : e.key === "Tab" && h(!1));
|
|
100
100
|
}
|
|
101
101
|
}, H = R && (r || k), Te = n ? "text-delta-300" : H ? "text-gama-500" : "text-delta-800", Me = n ? "text-delta-300" : "text-delta-700";
|
|
102
102
|
return /* @__PURE__ */ L("div", {
|
|
103
103
|
ref: we,
|
|
104
|
-
className:
|
|
104
|
+
className: y("group relative inline-flex flex-col", ue && "w-full", fe),
|
|
105
105
|
style: {
|
|
106
106
|
fontFamily: "Roboto, Helvetica, Arial, sans-serif",
|
|
107
107
|
...je(me),
|
|
@@ -119,25 +119,25 @@ var Ct = ({ dataTest: T, value: M, defaultValue: ne, onChange: $, error: le, err
|
|
|
119
119
|
role: "combobox",
|
|
120
120
|
"aria-haspopup": "listbox",
|
|
121
121
|
"aria-expanded": r,
|
|
122
|
-
"aria-controls":
|
|
122
|
+
"aria-controls": A,
|
|
123
123
|
"aria-activedescendant": r ? D : void 0,
|
|
124
|
-
"aria-labelledby":
|
|
125
|
-
"aria-label":
|
|
124
|
+
"aria-labelledby": v,
|
|
125
|
+
"aria-label": v ? void 0 : w,
|
|
126
126
|
"aria-invalid": p ? !0 : void 0,
|
|
127
127
|
"aria-describedby": F ? z : void 0,
|
|
128
128
|
"aria-disabled": n ? !0 : void 0,
|
|
129
129
|
disabled: n,
|
|
130
130
|
onFocus: (e) => {
|
|
131
|
-
I(!0),
|
|
131
|
+
I(!0), he?.(e);
|
|
132
132
|
},
|
|
133
133
|
onBlur: (e) => {
|
|
134
|
-
I(!1),
|
|
134
|
+
I(!1), ye?.(e);
|
|
135
135
|
},
|
|
136
136
|
style: { minWidth: i && !R ? 105 : void 0 },
|
|
137
|
-
className:
|
|
137
|
+
className: y("relative flex w-full items-center justify-between text-left outline-none", "h-10 rounded-lg border-0 px-3 text-base transition-colors", H ? "bg-gama-50" : "bg-transparent", Te, R && "min-w-0", n && "cursor-not-allowed", c && "pointer-events-none"),
|
|
138
138
|
children: [
|
|
139
139
|
/* @__PURE__ */ l("span", {
|
|
140
|
-
className:
|
|
140
|
+
className: y("min-w-0 flex-1 truncate", !i && "text-delta-500"),
|
|
141
141
|
children: i || C ? _e : S
|
|
142
142
|
}),
|
|
143
143
|
/* @__PURE__ */ L("span", {
|
|
@@ -145,7 +145,7 @@ var Ct = ({ dataTest: T, value: M, defaultValue: ne, onChange: $, error: le, err
|
|
|
145
145
|
children: [U && i && !n && /* @__PURE__ */ l("span", {
|
|
146
146
|
"aria-hidden": "true",
|
|
147
147
|
"data-testid": "select-clear-button",
|
|
148
|
-
className: "flex items-center justify-center rounded-full p-[2px] hover:bg-gama-100",
|
|
148
|
+
className: "invisible flex items-center justify-center rounded-full p-[2px] group-focus-within:visible hover:bg-gama-100",
|
|
149
149
|
onClick: (e) => {
|
|
150
150
|
e.stopPropagation(), ee();
|
|
151
151
|
},
|
|
@@ -156,7 +156,7 @@ var Ct = ({ dataTest: T, value: M, defaultValue: ne, onChange: $, error: le, err
|
|
|
156
156
|
}), /* @__PURE__ */ l(Ue, {
|
|
157
157
|
width: 24,
|
|
158
158
|
height: 24,
|
|
159
|
-
className:
|
|
159
|
+
className: y("shrink-0 transition-transform", H ? "text-gama-500" : Me, r && "rotate-180")
|
|
160
160
|
})]
|
|
161
161
|
}),
|
|
162
162
|
/* @__PURE__ */ l("div", { className: Qe({
|
|
@@ -173,28 +173,28 @@ var Ct = ({ dataTest: T, value: M, defaultValue: ne, onChange: $, error: le, err
|
|
|
173
173
|
children: /* @__PURE__ */ l("ul", {
|
|
174
174
|
ref: Ee,
|
|
175
175
|
...Oe(),
|
|
176
|
-
id:
|
|
176
|
+
id: A,
|
|
177
177
|
role: "listbox",
|
|
178
|
-
"aria-labelledby":
|
|
179
|
-
"aria-label":
|
|
178
|
+
"aria-labelledby": v,
|
|
179
|
+
"aria-label": v ? void 0 : w,
|
|
180
180
|
..._ ? qe : {},
|
|
181
181
|
style: {
|
|
182
182
|
..._ ? Ye : {},
|
|
183
183
|
...Fe,
|
|
184
184
|
fontFamily: "Roboto, Helvetica, Arial, sans-serif"
|
|
185
185
|
},
|
|
186
|
-
className:
|
|
186
|
+
className: y("z-[1300] m-0 max-h-72 list-none overflow-auto rounded border border-solid border-delta-300 bg-white px-0 py-2 shadow-[0px_2px_4px_0px_rgba(34,33,51,0.15)]", "[&>li:not(:last-child)]:border-0 [&>li:not(:last-child)]:border-b", "[&>li:not(:last-child)]:border-solid [&>li:not(:last-child)]:border-delta-200", ge?.className),
|
|
187
187
|
children: Pe
|
|
188
188
|
})
|
|
189
189
|
}),
|
|
190
190
|
F && /* @__PURE__ */ l(We, {
|
|
191
|
-
ref:
|
|
191
|
+
ref: ve,
|
|
192
192
|
id: z,
|
|
193
193
|
role: xe,
|
|
194
194
|
error: p,
|
|
195
195
|
message: Y,
|
|
196
196
|
className: "m-0 mr-[14px] box-border items-center",
|
|
197
|
-
style:
|
|
197
|
+
style: Ae
|
|
198
198
|
})
|
|
199
199
|
]
|
|
200
200
|
});
|