@selfdecode/sd-component-library 4.0.134 → 4.0.136
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/lib/components/forms-v2/input-container/interfaces.d.ts +2 -1
- package/lib/components/modals/modal/interfaces.d.ts +2 -1
- package/lib/sd-component-library100.js +2 -2
- package/lib/sd-component-library101.js +2 -2
- package/lib/sd-component-library102.js +59 -56
- package/lib/sd-component-library102.js.map +1 -1
- package/lib/sd-component-library104.js +4 -4
- package/lib/sd-component-library106.js +4 -4
- package/lib/sd-component-library112.js +1 -1
- package/lib/sd-component-library117.js +1 -1
- package/lib/sd-component-library118.js +2 -2
- package/lib/sd-component-library120.js +1 -1
- package/lib/sd-component-library121.js +1 -1
- package/lib/sd-component-library126.js +2 -2
- package/lib/sd-component-library127.js +2 -2
- package/lib/sd-component-library129.js +1 -1
- package/lib/sd-component-library133.js +3 -3
- package/lib/sd-component-library134.js +1 -1
- package/lib/sd-component-library136.js +2 -2
- package/lib/sd-component-library168.js +1 -1
- package/lib/sd-component-library171.js +1 -1
- package/lib/sd-component-library172.js +4 -4
- package/lib/sd-component-library197.js +3 -3
- package/lib/sd-component-library201.js +2 -3
- package/lib/sd-component-library201.js.map +1 -1
- package/lib/sd-component-library202.js +30 -2
- package/lib/sd-component-library202.js.map +1 -1
- package/lib/sd-component-library203.js +590 -21
- package/lib/sd-component-library203.js.map +1 -1
- package/lib/sd-component-library204.js +25 -598
- package/lib/sd-component-library204.js.map +1 -1
- package/lib/sd-component-library206.js +17 -25
- package/lib/sd-component-library206.js.map +1 -1
- package/lib/sd-component-library207.js +21 -18
- package/lib/sd-component-library207.js.map +1 -1
- package/lib/sd-component-library208.js +3 -21
- package/lib/sd-component-library208.js.map +1 -1
- package/lib/sd-component-library209.js +1 -1
- package/lib/sd-component-library209.js.map +1 -1
- package/lib/sd-component-library210.js +64 -3
- package/lib/sd-component-library210.js.map +1 -1
- package/lib/sd-component-library211.js +19 -60
- package/lib/sd-component-library211.js.map +1 -1
- package/lib/sd-component-library212.js +37 -20
- package/lib/sd-component-library212.js.map +1 -1
- package/lib/sd-component-library213.js +127 -38
- package/lib/sd-component-library213.js.map +1 -1
- package/lib/sd-component-library214.js +13 -129
- package/lib/sd-component-library214.js.map +1 -1
- package/lib/sd-component-library215.js +65 -13
- package/lib/sd-component-library215.js.map +1 -1
- package/lib/sd-component-library216.js +3 -14
- package/lib/sd-component-library216.js.map +1 -1
- package/lib/sd-component-library217.js +2 -2
- package/lib/sd-component-library217.js.map +1 -1
- package/lib/sd-component-library218.js +46 -3
- package/lib/sd-component-library218.js.map +1 -1
- package/lib/sd-component-library219.js +14 -3
- package/lib/sd-component-library219.js.map +1 -1
- package/lib/sd-component-library220.js +3 -52
- package/lib/sd-component-library220.js.map +1 -1
- package/lib/sd-component-library221.js +3 -65
- package/lib/sd-component-library221.js.map +1 -1
- package/lib/sd-component-library222.js +17 -3
- package/lib/sd-component-library222.js.map +1 -1
- package/lib/sd-component-library223.js +51 -45
- package/lib/sd-component-library223.js.map +1 -1
- package/lib/sd-component-library224.js +3 -17
- package/lib/sd-component-library224.js.map +1 -1
- package/lib/sd-component-library232.js +1 -1
- package/lib/sd-component-library234.js +1 -1
- package/lib/sd-component-library236.js +1 -1
- package/lib/sd-component-library237.js +1 -1
- package/lib/sd-component-library24.js +1 -1
- package/lib/sd-component-library240.js +1 -1
- package/lib/sd-component-library241.js +1 -1
- package/lib/sd-component-library244.js +46 -19
- package/lib/sd-component-library244.js.map +1 -1
- package/lib/sd-component-library245.js +75 -20
- package/lib/sd-component-library245.js.map +1 -1
- package/lib/sd-component-library246.js +39 -46
- package/lib/sd-component-library246.js.map +1 -1
- package/lib/sd-component-library247.js +26 -74
- package/lib/sd-component-library247.js.map +1 -1
- package/lib/sd-component-library249.js +18 -38
- package/lib/sd-component-library249.js.map +1 -1
- package/lib/sd-component-library250.js +18 -25
- package/lib/sd-component-library250.js.map +1 -1
- package/lib/sd-component-library252.js +323 -27
- package/lib/sd-component-library252.js.map +1 -1
- package/lib/sd-component-library253.js +5 -3
- package/lib/sd-component-library253.js.map +1 -1
- package/lib/sd-component-library254.js +25 -20
- package/lib/sd-component-library254.js.map +1 -1
- package/lib/sd-component-library255.js +1 -1
- package/lib/sd-component-library255.js.map +1 -1
- package/lib/sd-component-library256.js +17 -18
- package/lib/sd-component-library256.js.map +1 -1
- package/lib/sd-component-library257.js +3 -22
- package/lib/sd-component-library257.js.map +1 -1
- package/lib/sd-component-library258.js +25 -30
- package/lib/sd-component-library258.js.map +1 -1
- package/lib/sd-component-library259.js +21 -50
- package/lib/sd-component-library259.js.map +1 -1
- package/lib/sd-component-library260.js +30 -134
- package/lib/sd-component-library260.js.map +1 -1
- package/lib/sd-component-library261.js +39 -62
- package/lib/sd-component-library261.js.map +1 -1
- package/lib/sd-component-library262.js +120 -62
- package/lib/sd-component-library262.js.map +1 -1
- package/lib/sd-component-library263.js +75 -29
- package/lib/sd-component-library263.js.map +1 -1
- package/lib/sd-component-library264.js +68 -15
- package/lib/sd-component-library264.js.map +1 -1
- package/lib/sd-component-library265.js +25 -120
- package/lib/sd-component-library265.js.map +1 -1
- package/lib/sd-component-library266.js +16 -117
- package/lib/sd-component-library266.js.map +1 -1
- package/lib/sd-component-library267.js +125 -10
- package/lib/sd-component-library267.js.map +1 -1
- package/lib/sd-component-library268.js +111 -39
- package/lib/sd-component-library268.js.map +1 -1
- package/lib/sd-component-library269.js +10 -9
- package/lib/sd-component-library269.js.map +1 -1
- package/lib/sd-component-library270.js +48 -323
- package/lib/sd-component-library270.js.map +1 -1
- package/lib/sd-component-library271.js +9 -51
- package/lib/sd-component-library271.js.map +1 -1
- package/lib/sd-component-library272.js +48 -87
- package/lib/sd-component-library272.js.map +1 -1
- package/lib/sd-component-library273.js +52 -54
- package/lib/sd-component-library273.js.map +1 -1
- package/lib/sd-component-library274.js +92 -5
- package/lib/sd-component-library274.js.map +1 -1
- package/lib/sd-component-library277.js +10 -2
- package/lib/sd-component-library277.js.map +1 -1
- package/lib/sd-component-library278.js +2 -2
- package/lib/sd-component-library279.js +2 -6
- package/lib/sd-component-library279.js.map +1 -1
- package/lib/sd-component-library283.js +6 -10
- package/lib/sd-component-library283.js.map +1 -1
- package/lib/sd-component-library286.js +1 -1
- package/lib/sd-component-library304.js +1 -1
- package/lib/sd-component-library308.js +5 -57
- package/lib/sd-component-library308.js.map +1 -1
- package/lib/sd-component-library309.js +57 -5
- package/lib/sd-component-library309.js.map +1 -1
- package/lib/sd-component-library313.js +23 -33
- package/lib/sd-component-library313.js.map +1 -1
- package/lib/sd-component-library314.js +33 -23
- package/lib/sd-component-library314.js.map +1 -1
- package/lib/sd-component-library48.js +1 -1
- package/lib/sd-component-library49.js +1 -1
- package/lib/sd-component-library51.js +3 -3
- package/lib/sd-component-library52.js +2 -2
- package/lib/sd-component-library53.js +2 -2
- package/lib/sd-component-library55.js +65 -63
- package/lib/sd-component-library55.js.map +1 -1
- package/lib/sd-component-library57.js +81 -71
- package/lib/sd-component-library57.js.map +1 -1
- package/lib/sd-component-library58.js +46 -41
- package/lib/sd-component-library58.js.map +1 -1
- package/lib/sd-component-library6.js +1 -1
- package/lib/sd-component-library60.js +1 -1
- package/lib/sd-component-library61.js +1 -1
- package/lib/sd-component-library62.js +1 -1
- package/lib/sd-component-library63.js +1 -1
- package/lib/sd-component-library64.js +2 -2
- package/lib/sd-component-library65.js +1 -1
- package/lib/sd-component-library7.js +1 -1
- package/lib/sd-component-library70.js +2 -2
- package/lib/sd-component-library72.js +3 -3
- package/lib/sd-component-library74.js +2 -2
- package/lib/sd-component-library75.js +3 -3
- package/lib/sd-component-library76.js +1 -1
- package/lib/sd-component-library77.js +1 -1
- package/lib/sd-component-library79.js +1 -1
- package/lib/sd-component-library80.js +1 -1
- package/lib/sd-component-library98.js +2 -2
- package/lib/sd-component-library99.js +3 -3
- package/package.json +1 -1
|
@@ -1,48 +1,48 @@
|
|
|
1
1
|
import { j as i } from "./sd-component-library197.js";
|
|
2
|
-
import { useState as
|
|
3
|
-
import { Input as
|
|
4
|
-
import { translatedTextSuffix as
|
|
5
|
-
import { generateTestLocator as
|
|
6
|
-
import { InputContainer as
|
|
7
|
-
import { InvalidInputError as
|
|
8
|
-
const
|
|
2
|
+
import { useState as B, useEffect as E, useCallback as W } from "react";
|
|
3
|
+
import { Input as S } from "@rebass/forms";
|
|
4
|
+
import { translatedTextSuffix as h } from "./sd-component-library5.js";
|
|
5
|
+
import { generateTestLocator as g } from "./sd-component-library4.js";
|
|
6
|
+
import { InputContainer as T } from "./sd-component-library58.js";
|
|
7
|
+
import { InvalidInputError as $ } from "./sd-component-library68.js";
|
|
8
|
+
const k = (s, l, a) => (r) => {
|
|
9
9
|
const e = r.target.value;
|
|
10
10
|
try {
|
|
11
11
|
const o = a(e);
|
|
12
|
-
|
|
12
|
+
s(e), o && l(e);
|
|
13
13
|
} catch (o) {
|
|
14
|
-
if (!(o instanceof
|
|
14
|
+
if (!(o instanceof $))
|
|
15
15
|
throw o;
|
|
16
16
|
}
|
|
17
|
-
},
|
|
18
|
-
value:
|
|
17
|
+
}, D = ({
|
|
18
|
+
value: s,
|
|
19
19
|
onChange: l,
|
|
20
20
|
validateValue: a = () => !0,
|
|
21
21
|
focusInput: r,
|
|
22
22
|
className: e = "",
|
|
23
23
|
testLocatorId: o,
|
|
24
|
-
...
|
|
24
|
+
...f
|
|
25
25
|
}) => {
|
|
26
|
-
let t =
|
|
27
|
-
const
|
|
28
|
-
t.endsWith(
|
|
29
|
-
const [
|
|
30
|
-
|
|
31
|
-
t !== void 0 &&
|
|
26
|
+
let t = s;
|
|
27
|
+
const m = e;
|
|
28
|
+
t.endsWith(h) && (t = t.slice(0, -h.length), m.concat("no-translate"));
|
|
29
|
+
const [u, c] = B(t);
|
|
30
|
+
E(() => {
|
|
31
|
+
t !== void 0 && c(t);
|
|
32
32
|
}, [t]);
|
|
33
|
-
const
|
|
34
|
-
(
|
|
35
|
-
r && (
|
|
33
|
+
const x = W(
|
|
34
|
+
(n) => {
|
|
35
|
+
r && (n == null || n.focus());
|
|
36
36
|
},
|
|
37
37
|
[r]
|
|
38
38
|
);
|
|
39
39
|
return /* @__PURE__ */ i.jsx(
|
|
40
|
-
|
|
40
|
+
S,
|
|
41
41
|
{
|
|
42
42
|
variant: "_inputs.v2",
|
|
43
|
-
onChange:
|
|
44
|
-
value:
|
|
45
|
-
...
|
|
43
|
+
onChange: k(c, l, a),
|
|
44
|
+
value: u,
|
|
45
|
+
...f,
|
|
46
46
|
sx: {
|
|
47
47
|
":focus": {
|
|
48
48
|
borderBottomStyle: "solid",
|
|
@@ -51,76 +51,78 @@ const D = (n, l, a) => (r) => {
|
|
|
51
51
|
outline: "none"
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
|
-
...
|
|
55
|
-
className:
|
|
56
|
-
ref:
|
|
54
|
+
...g(o),
|
|
55
|
+
className: m,
|
|
56
|
+
ref: x
|
|
57
57
|
}
|
|
58
58
|
);
|
|
59
|
-
},
|
|
60
|
-
value:
|
|
59
|
+
}, v = "16px", U = ({
|
|
60
|
+
value: s,
|
|
61
61
|
onChange: l,
|
|
62
62
|
id: a,
|
|
63
63
|
disabled: r,
|
|
64
64
|
validateValue: e,
|
|
65
65
|
onFocus: o,
|
|
66
|
-
onBlur:
|
|
66
|
+
onBlur: f,
|
|
67
67
|
placeholder: t,
|
|
68
|
-
autoFocus:
|
|
69
|
-
onKeyPress:
|
|
70
|
-
focusInput:
|
|
71
|
-
maxLength:
|
|
72
|
-
showCheckMark:
|
|
73
|
-
checkmarkRight:
|
|
74
|
-
children:
|
|
75
|
-
inputPr:
|
|
76
|
-
inputMode:
|
|
77
|
-
type:
|
|
78
|
-
className:
|
|
79
|
-
testLocatorId:
|
|
80
|
-
...
|
|
68
|
+
autoFocus: m,
|
|
69
|
+
onKeyPress: u,
|
|
70
|
+
focusInput: c,
|
|
71
|
+
maxLength: x,
|
|
72
|
+
showCheckMark: n,
|
|
73
|
+
checkmarkRight: d = "0px",
|
|
74
|
+
children: w,
|
|
75
|
+
inputPr: b,
|
|
76
|
+
inputMode: j,
|
|
77
|
+
type: C,
|
|
78
|
+
className: V,
|
|
79
|
+
testLocatorId: p,
|
|
80
|
+
...y
|
|
81
81
|
}) => /* @__PURE__ */ i.jsxs(
|
|
82
|
-
|
|
82
|
+
T,
|
|
83
83
|
{
|
|
84
84
|
id: a,
|
|
85
85
|
cursor: r ? "not-allowed" : "pointer",
|
|
86
|
-
|
|
86
|
+
testLocatorId: p,
|
|
87
|
+
...y,
|
|
87
88
|
children: [
|
|
88
89
|
/* @__PURE__ */ i.jsx(
|
|
89
|
-
|
|
90
|
+
D,
|
|
90
91
|
{
|
|
91
|
-
value:
|
|
92
|
+
value: s,
|
|
92
93
|
onChange: l,
|
|
93
94
|
validateValue: e,
|
|
94
95
|
id: a,
|
|
95
96
|
disabled: r,
|
|
96
97
|
placeholder: t,
|
|
97
98
|
onFocus: o,
|
|
98
|
-
onBlur:
|
|
99
|
-
autoFocus:
|
|
100
|
-
onKeyPress:
|
|
101
|
-
focusInput:
|
|
102
|
-
maxLength:
|
|
103
|
-
inputMode:
|
|
104
|
-
type:
|
|
105
|
-
className:
|
|
106
|
-
testLocatorId:
|
|
107
|
-
pr:
|
|
99
|
+
onBlur: f,
|
|
100
|
+
autoFocus: m,
|
|
101
|
+
onKeyPress: u,
|
|
102
|
+
focusInput: c,
|
|
103
|
+
maxLength: x,
|
|
104
|
+
inputMode: j,
|
|
105
|
+
type: C,
|
|
106
|
+
className: V,
|
|
107
|
+
testLocatorId: p,
|
|
108
|
+
pr: b ?? (n ? `calc(${v} + ${d} + 2px)` : void 0)
|
|
108
109
|
}
|
|
109
110
|
),
|
|
110
|
-
|
|
111
|
+
n && /* @__PURE__ */ i.jsx(
|
|
111
112
|
"svg",
|
|
112
113
|
{
|
|
113
114
|
xmlns: "http://www.w3.org/2000/svg",
|
|
114
|
-
width:
|
|
115
|
+
width: v,
|
|
115
116
|
height: "11.931",
|
|
116
117
|
viewBox: "0 0 16 11.931",
|
|
117
118
|
fill: "#3DEB24",
|
|
118
119
|
style: {
|
|
119
120
|
position: "absolute",
|
|
120
|
-
right:
|
|
121
|
+
right: d,
|
|
121
122
|
bottom: "16px",
|
|
122
123
|
transform: "translateY(-50%)"
|
|
123
124
|
},
|
|
125
|
+
...p ? g(`${p}-check-mark`) : void 0,
|
|
124
126
|
children: /* @__PURE__ */ i.jsx(
|
|
125
127
|
"path",
|
|
126
128
|
{
|
|
@@ -130,12 +132,12 @@ const D = (n, l, a) => (r) => {
|
|
|
130
132
|
)
|
|
131
133
|
}
|
|
132
134
|
),
|
|
133
|
-
|
|
135
|
+
w
|
|
134
136
|
]
|
|
135
137
|
}
|
|
136
138
|
);
|
|
137
139
|
export {
|
|
138
|
-
|
|
140
|
+
D as FormV2Input,
|
|
139
141
|
U as FormV2InputWithContainer
|
|
140
142
|
};
|
|
141
143
|
//# sourceMappingURL=sd-component-library55.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sd-component-library55.js","sources":["../src/components/forms-v2/form-v2-input/form-v2-input.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useState } from \"react\";\n\nimport { Input as RebassInput } from \"@rebass/forms\";\n\nimport { translatedTextSuffix } from \"../../../core/constants\";\nimport { generateTestLocator } from \"../../../core/functions\";\nimport { InvalidInputError } from \"../../inputs\";\nimport { InputContainer, InputContainerProps } from \"../input-container\";\nimport { FormV2InputProps as Props } from \"./interfaces\";\n\nconst getOnChangeCallback =\n (\n setDisplayedValue: (newValue: string) => void,\n onChange: Props[\"onChange\"],\n validateValue: Required<Props>[\"validateValue\"]\n ) =>\n (event: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = event.target.value;\n try {\n const isValid = validateValue(newValue);\n setDisplayedValue(newValue);\n isValid && onChange(newValue);\n } catch (error) {\n if (!(error instanceof InvalidInputError)) throw error;\n }\n };\n\nexport const FormV2Input: React.FC<Props> = ({\n value,\n onChange,\n validateValue = () => true,\n focusInput,\n className = \"\",\n testLocatorId,\n ...props\n}) => {\n let valueToUse = value;\n const finalClassName = className;\n\n if (valueToUse.endsWith(translatedTextSuffix)) {\n valueToUse = valueToUse.slice(0, -translatedTextSuffix.length);\n finalClassName.concat(\"no-translate\");\n }\n\n const [displayedValue, setDisplayedValue] = useState(valueToUse);\n\n useEffect(() => {\n valueToUse !== undefined && setDisplayedValue(valueToUse);\n }, [valueToUse]);\n\n const ref = useCallback(\n (input: HTMLInputElement | null) => {\n focusInput && input?.focus();\n },\n [focusInput]\n );\n\n return (\n <RebassInput\n variant=\"_inputs.v2\"\n onChange={getOnChangeCallback(setDisplayedValue, onChange, validateValue)}\n value={displayedValue}\n {...props}\n sx={{\n \":focus\": {\n borderBottomStyle: \"solid\",\n borderBottomWidth: \"2px\",\n borderBottomColor: \"cl_blue\",\n outline: \"none\",\n },\n }}\n {...generateTestLocator(testLocatorId)}\n className={finalClassName}\n ref={ref}\n />\n );\n};\n\nconst checkMarkWidth = \"16px\";\n\nexport const FormV2InputWithContainer: React.FC<\n Omit<Props, \"pr\"> &\n InputContainerProps & {\n showCheckMark?: boolean;\n checkmarkRight?: string;\n inputPr?: Props[\"pr\"];\n }\n> = ({\n value,\n onChange,\n id,\n disabled,\n validateValue,\n onFocus,\n onBlur,\n placeholder,\n autoFocus,\n onKeyPress,\n focusInput,\n maxLength,\n showCheckMark,\n checkmarkRight = \"0px\",\n children,\n inputPr,\n inputMode,\n type,\n className,\n testLocatorId,\n ...containerProps\n}) => (\n <InputContainer\n id={id}\n cursor={disabled ? \"not-allowed\" : \"pointer\"}\n {...containerProps}\n >\n <FormV2Input\n {...{\n value,\n onChange,\n validateValue,\n id,\n disabled,\n placeholder,\n onFocus,\n onBlur,\n autoFocus,\n onKeyPress,\n focusInput,\n maxLength,\n inputMode,\n type,\n className,\n testLocatorId,\n }}\n pr={\n inputPr ??\n (showCheckMark\n ? `calc(${checkMarkWidth} + ${checkmarkRight} + 2px)`\n : undefined)\n }\n />\n\n {showCheckMark && (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width={checkMarkWidth}\n height=\"11.931\"\n viewBox=\"0 0 16 11.931\"\n fill=\"#3DEB24\"\n style={{\n position: \"absolute\",\n right: checkmarkRight,\n bottom: \"16px\",\n transform: \"translateY(-50%)\",\n }}\n >\n <path\n d=\"M5.434,16.274l-5.2-5.2a.8.8,0,0,1,0-1.131L1.366,8.812a.8.8,0,0,1,1.131,0l3.5,3.5,7.5-7.5a.8.8,0,0,1,1.131,0l1.131,1.131a.8.8,0,0,1,0,1.131l-9.2,9.2A.8.8,0,0,1,5.434,16.274Z\"\n transform=\"translate(0 -4.577)\"\n />\n </svg>\n )}\n\n {children}\n </InputContainer>\n);\n"],"names":["getOnChangeCallback","setDisplayedValue","onChange","validateValue","event","newValue","isValid","error","InvalidInputError","FormV2Input","value","focusInput","className","testLocatorId","props","valueToUse","finalClassName","translatedTextSuffix","displayedValue","useState","useEffect","ref","useCallback","input","jsx","RebassInput","generateTestLocator","checkMarkWidth","FormV2InputWithContainer","id","disabled","onFocus","onBlur","placeholder","autoFocus","onKeyPress","maxLength","showCheckMark","checkmarkRight","children","inputPr","inputMode","type","containerProps","jsxs","InputContainer"],"mappings":";;;;;;;AAUA,MAAMA,IACJ,CACEC,GACAC,GACAC,MAEF,CAACC,MAA+C;AACxC,QAAAC,IAAWD,EAAM,OAAO;AAC1B,MAAA;AACI,UAAAE,IAAUH,EAAcE,CAAQ;AACtC,IAAAJ,EAAkBI,CAAQ,GAC1BC,KAAWJ,EAASG,CAAQ;AAAA,WACrBE,GAAO;AACd,QAAI,EAAEA,aAAiBC;AAA0B,YAAAD;AAAA,EACnD;AACF,GAEWE,IAA+B,CAAC;AAAA,EAC3C,OAAAC;AAAA,EACA,UAAAR;AAAA,EACA,eAAAC,IAAgB,MAAM;AAAA,EACtB,YAAAQ;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,eAAAC;AAAA,EACA,GAAGC;AACL,MAAM;AACJ,MAAIC,IAAaL;AACjB,QAAM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A,GAAG8B;AACL,MACEC,gBAAAA,EAAA;AAAA,EAACC;AAAA,EAAA;AAAA,IACC,IAAAhB;AAAA,IACA,QAAQC,IAAW,gBAAgB;AAAA,
|
|
1
|
+
{"version":3,"file":"sd-component-library55.js","sources":["../src/components/forms-v2/form-v2-input/form-v2-input.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useState } from \"react\";\n\nimport { Input as RebassInput } from \"@rebass/forms\";\n\nimport { translatedTextSuffix } from \"../../../core/constants\";\nimport { generateTestLocator } from \"../../../core/functions\";\nimport { InvalidInputError } from \"../../inputs\";\nimport { InputContainer, InputContainerProps } from \"../input-container\";\nimport { FormV2InputProps as Props } from \"./interfaces\";\n\nconst getOnChangeCallback =\n (\n setDisplayedValue: (newValue: string) => void,\n onChange: Props[\"onChange\"],\n validateValue: Required<Props>[\"validateValue\"]\n ) =>\n (event: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = event.target.value;\n try {\n const isValid = validateValue(newValue);\n setDisplayedValue(newValue);\n isValid && onChange(newValue);\n } catch (error) {\n if (!(error instanceof InvalidInputError)) throw error;\n }\n };\n\nexport const FormV2Input: React.FC<Props> = ({\n value,\n onChange,\n validateValue = () => true,\n focusInput,\n className = \"\",\n testLocatorId,\n ...props\n}) => {\n let valueToUse = value;\n const finalClassName = className;\n\n if (valueToUse.endsWith(translatedTextSuffix)) {\n valueToUse = valueToUse.slice(0, -translatedTextSuffix.length);\n finalClassName.concat(\"no-translate\");\n }\n\n const [displayedValue, setDisplayedValue] = useState(valueToUse);\n\n useEffect(() => {\n valueToUse !== undefined && setDisplayedValue(valueToUse);\n }, [valueToUse]);\n\n const ref = useCallback(\n (input: HTMLInputElement | null) => {\n focusInput && input?.focus();\n },\n [focusInput]\n );\n\n return (\n <RebassInput\n variant=\"_inputs.v2\"\n onChange={getOnChangeCallback(setDisplayedValue, onChange, validateValue)}\n value={displayedValue}\n {...props}\n sx={{\n \":focus\": {\n borderBottomStyle: \"solid\",\n borderBottomWidth: \"2px\",\n borderBottomColor: \"cl_blue\",\n outline: \"none\",\n },\n }}\n {...generateTestLocator(testLocatorId)}\n className={finalClassName}\n ref={ref}\n />\n );\n};\n\nconst checkMarkWidth = \"16px\";\n\nexport const FormV2InputWithContainer: React.FC<\n Omit<Props, \"pr\"> &\n InputContainerProps & {\n showCheckMark?: boolean;\n checkmarkRight?: string;\n inputPr?: Props[\"pr\"];\n }\n> = ({\n value,\n onChange,\n id,\n disabled,\n validateValue,\n onFocus,\n onBlur,\n placeholder,\n autoFocus,\n onKeyPress,\n focusInput,\n maxLength,\n showCheckMark,\n checkmarkRight = \"0px\",\n children,\n inputPr,\n inputMode,\n type,\n className,\n testLocatorId,\n ...containerProps\n}) => (\n <InputContainer\n id={id}\n cursor={disabled ? \"not-allowed\" : \"pointer\"}\n testLocatorId={testLocatorId}\n {...containerProps}\n >\n <FormV2Input\n {...{\n value,\n onChange,\n validateValue,\n id,\n disabled,\n placeholder,\n onFocus,\n onBlur,\n autoFocus,\n onKeyPress,\n focusInput,\n maxLength,\n inputMode,\n type,\n className,\n testLocatorId,\n }}\n pr={\n inputPr ??\n (showCheckMark\n ? `calc(${checkMarkWidth} + ${checkmarkRight} + 2px)`\n : undefined)\n }\n />\n\n {showCheckMark && (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width={checkMarkWidth}\n height=\"11.931\"\n viewBox=\"0 0 16 11.931\"\n fill=\"#3DEB24\"\n style={{\n position: \"absolute\",\n right: checkmarkRight,\n bottom: \"16px\",\n transform: \"translateY(-50%)\",\n }}\n {...(testLocatorId\n ? generateTestLocator(`${testLocatorId}-check-mark`)\n : undefined)}\n >\n <path\n d=\"M5.434,16.274l-5.2-5.2a.8.8,0,0,1,0-1.131L1.366,8.812a.8.8,0,0,1,1.131,0l3.5,3.5,7.5-7.5a.8.8,0,0,1,1.131,0l1.131,1.131a.8.8,0,0,1,0,1.131l-9.2,9.2A.8.8,0,0,1,5.434,16.274Z\"\n transform=\"translate(0 -4.577)\"\n />\n </svg>\n )}\n\n {children}\n </InputContainer>\n);\n"],"names":["getOnChangeCallback","setDisplayedValue","onChange","validateValue","event","newValue","isValid","error","InvalidInputError","FormV2Input","value","focusInput","className","testLocatorId","props","valueToUse","finalClassName","translatedTextSuffix","displayedValue","useState","useEffect","ref","useCallback","input","jsx","RebassInput","generateTestLocator","checkMarkWidth","FormV2InputWithContainer","id","disabled","onFocus","onBlur","placeholder","autoFocus","onKeyPress","maxLength","showCheckMark","checkmarkRight","children","inputPr","inputMode","type","containerProps","jsxs","InputContainer"],"mappings":";;;;;;;AAUA,MAAMA,IACJ,CACEC,GACAC,GACAC,MAEF,CAACC,MAA+C;AACxC,QAAAC,IAAWD,EAAM,OAAO;AAC1B,MAAA;AACI,UAAAE,IAAUH,EAAcE,CAAQ;AACtC,IAAAJ,EAAkBI,CAAQ,GAC1BC,KAAWJ,EAASG,CAAQ;AAAA,WACrBE,GAAO;AACd,QAAI,EAAEA,aAAiBC;AAA0B,YAAAD;AAAA,EACnD;AACF,GAEWE,IAA+B,CAAC;AAAA,EAC3C,OAAAC;AAAA,EACA,UAAAR;AAAA,EACA,eAAAC,IAAgB,MAAM;AAAA,EACtB,YAAAQ;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,eAAAC;AAAA,EACA,GAAGC;AACL,MAAM;AACJ,MAAIC,IAAaL;AACjB,QAAMM,IAAiBJ;AAEnB,EAAAG,EAAW,SAASE,CAAoB,MAC1CF,IAAaA,EAAW,MAAM,GAAG,CAACE,EAAqB,MAAM,GAC7DD,EAAe,OAAO,cAAc;AAGtC,QAAM,CAACE,GAAgBjB,CAAiB,IAAIkB,EAASJ,CAAU;AAE/D,EAAAK,EAAU,MAAM;AACC,IAAAL,MAAA,UAAad,EAAkBc,CAAU;AAAA,EAAA,GACvD,CAACA,CAAU,CAAC;AAEf,QAAMM,IAAMC;AAAA,IACV,CAACC,MAAmC;AAClC,MAAAZ,MAAcY,KAAA,QAAAA,EAAO;AAAA,IACvB;AAAA,IACA,CAACZ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A,YAAAC;AAAA,UACA,YAAAxB;AAAA,UACA,WAAAyB;AAAA,UACA,WAAAK;AAAA,UACA,MAAAC;AAAA,UACA,WAAA9B;AAAA,UACA,eAAAC;AAAA,UAEF,IACE2B,MACCH,IACG,QAAQV,CAAc,MAAMW,CAAc,YAC1C;AAAA,QAAA;AAAA,MAER;AAAA,MAECD,KACCb,gBAAAA,EAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,OAAM;AAAA,UACN,OAAOG;AAAA,UACP,QAAO;AAAA,UACP,SAAQ;AAAA,UACR,MAAK;AAAA,UACL,OAAO;AAAA,YACL,UAAU;AAAA,YACV,OAAOW;AAAA,YACP,QAAQ;AAAA,YACR,WAAW;AAAA,UACb;AAAA,UACC,GAAIzB,IACDa,EAAoB,GAAGb,CAAa,aAAa,IACjD;AAAA,UAEJ,UAAAW,gBAAAA,EAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,GAAE;AAAA,cACF,WAAU;AAAA,YAAA;AAAA,UACZ;AAAA,QAAA;AAAA,MACF;AAAA,MAGDe;AAAA,IAAA;AAAA,EAAA;AACH;"}
|
|
@@ -1,127 +1,137 @@
|
|
|
1
1
|
import { j as s } from "./sd-component-library197.js";
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { Select as
|
|
4
|
-
import { generateTestLocator as
|
|
5
|
-
import { getNoTranslateClass as
|
|
2
|
+
import { useMemo as V, useCallback as $ } from "react";
|
|
3
|
+
import { Select as k } from "@rebass/forms";
|
|
4
|
+
import { generateTestLocator as d } from "./sd-component-library4.js";
|
|
5
|
+
import { getNoTranslateClass as j } from "./sd-component-library112.js";
|
|
6
6
|
import { InputContainer as A } from "./sd-component-library58.js";
|
|
7
7
|
const G = ({
|
|
8
8
|
defaultOptionObject: r,
|
|
9
|
-
hideDefaultOnSelect:
|
|
10
|
-
options:
|
|
9
|
+
hideDefaultOnSelect: C,
|
|
10
|
+
options: l,
|
|
11
11
|
value: o,
|
|
12
12
|
onChange: a,
|
|
13
|
-
disabled:
|
|
14
|
-
disabledTextValue:
|
|
15
|
-
translateSelect:
|
|
16
|
-
translateDefaultOption:
|
|
17
|
-
onFocus:
|
|
18
|
-
id:
|
|
19
|
-
textTransform:
|
|
20
|
-
defaultOptionColor:
|
|
21
|
-
arrowColor:
|
|
22
|
-
sx:
|
|
23
|
-
testLocatorId:
|
|
13
|
+
disabled: t,
|
|
14
|
+
disabledTextValue: i,
|
|
15
|
+
translateSelect: c = !0,
|
|
16
|
+
translateDefaultOption: m,
|
|
17
|
+
onFocus: h,
|
|
18
|
+
id: u,
|
|
19
|
+
textTransform: f = "none",
|
|
20
|
+
defaultOptionColor: p = "cl_grey",
|
|
21
|
+
arrowColor: x = "cl_darkGrey",
|
|
22
|
+
sx: g,
|
|
23
|
+
testLocatorId: n
|
|
24
24
|
}) => {
|
|
25
|
-
const
|
|
26
|
-
() => (r ? [r] : []).concat(
|
|
27
|
-
[
|
|
28
|
-
),
|
|
25
|
+
const v = V(
|
|
26
|
+
() => (r ? [r] : []).concat(l),
|
|
27
|
+
[l, r]
|
|
28
|
+
), N = $(
|
|
29
29
|
(e) => {
|
|
30
|
-
const
|
|
31
|
-
({ title:
|
|
30
|
+
const M = v.find(
|
|
31
|
+
({ title: T }) => T.trim().replaceAll(/\s{2,}/g, " ") === e
|
|
32
32
|
);
|
|
33
|
-
a(
|
|
33
|
+
a(M);
|
|
34
34
|
},
|
|
35
|
-
[a,
|
|
36
|
-
),
|
|
37
|
-
|
|
38
|
-
),
|
|
35
|
+
[a, v]
|
|
36
|
+
), S = !l.length, _ = !!r, w = j(
|
|
37
|
+
m !== !0 && !c || m === !1
|
|
38
|
+
), y = j(!c), F = navigator.userAgent.toLowerCase().indexOf("firefox") > -1;
|
|
39
39
|
return /* @__PURE__ */ s.jsx(
|
|
40
|
-
|
|
40
|
+
k,
|
|
41
41
|
{
|
|
42
|
-
value:
|
|
43
|
-
onChange: (e) =>
|
|
42
|
+
value: S ? i : o.title.trim(),
|
|
43
|
+
onChange: (e) => N(e.target.value),
|
|
44
44
|
variant: "_inputs.v2",
|
|
45
45
|
sx: {
|
|
46
46
|
pr: "16px",
|
|
47
|
-
textTransform:
|
|
47
|
+
textTransform: f,
|
|
48
48
|
cursor: "inherit",
|
|
49
49
|
borderBottomColor: "inherit",
|
|
50
|
-
...
|
|
50
|
+
...p && o.value === null ? { color: p } : {},
|
|
51
51
|
// to override default styles for selector arrow
|
|
52
52
|
"& + svg": {
|
|
53
|
-
fill:
|
|
54
|
-
transform: `translate(10px, ${
|
|
53
|
+
fill: t ? "cl_lightGrey" : x,
|
|
54
|
+
transform: `translate(10px, ${F ? 0 : 5}px) scale(.78)`,
|
|
55
55
|
path: {
|
|
56
56
|
d: "path('M12,8.6L6.72,3.29C6.32,2.9,5.68,2.9,5.29,3.29C4.90,3.69,4.9,4.33,5.29,4.73L11.23,10.7C11.44,10.91,11.72,11.01,12,11C12.27,11.01,12.55,10.91,12.76,10.7L18.7,4.73C19.09,4.33,19.09,3.69,18.7,3.29C18.31,2.9,17.67,2.9,17.27,3.29Z M12,8.6')"
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
|
-
...
|
|
59
|
+
...g
|
|
60
60
|
},
|
|
61
|
-
id:
|
|
62
|
-
disabled:
|
|
63
|
-
onFocus:
|
|
64
|
-
...
|
|
65
|
-
children:
|
|
61
|
+
id: u,
|
|
62
|
+
disabled: t,
|
|
63
|
+
onFocus: h,
|
|
64
|
+
...d(n),
|
|
65
|
+
children: S ? /* @__PURE__ */ s.jsx(
|
|
66
|
+
"option",
|
|
67
|
+
{
|
|
68
|
+
...n ? d(`${n}-disabled-option`) : {},
|
|
69
|
+
"data-test": "disabled-option",
|
|
70
|
+
children: i
|
|
71
|
+
},
|
|
72
|
+
"disabledTextValue"
|
|
73
|
+
) : v.slice(
|
|
66
74
|
// should default option be hidden?
|
|
67
|
-
|
|
75
|
+
_ && C && o.value !== null ? 1 : 0
|
|
68
76
|
).map((e) => /* @__PURE__ */ s.jsx(
|
|
69
77
|
"option",
|
|
70
78
|
{
|
|
71
79
|
"data-testid": "selector-option",
|
|
80
|
+
...n ? d(`${n}-option`) : {},
|
|
72
81
|
value: e.title,
|
|
73
|
-
className: e.value === null ?
|
|
82
|
+
className: e.value === null ? w : y,
|
|
74
83
|
children: e.title
|
|
75
84
|
},
|
|
76
85
|
e.id
|
|
77
86
|
))
|
|
78
87
|
}
|
|
79
88
|
);
|
|
80
|
-
},
|
|
89
|
+
}, z = ({
|
|
81
90
|
defaultOptionObject: r,
|
|
82
|
-
hideDefaultOnSelect:
|
|
83
|
-
options:
|
|
91
|
+
hideDefaultOnSelect: C,
|
|
92
|
+
options: l,
|
|
84
93
|
value: o,
|
|
85
94
|
onChange: a,
|
|
86
|
-
disabled:
|
|
87
|
-
disabledTextValue:
|
|
88
|
-
translateSelect:
|
|
89
|
-
translateDefaultOption:
|
|
90
|
-
onFocus:
|
|
91
|
-
id:
|
|
92
|
-
textTransform:
|
|
93
|
-
defaultOptionColor:
|
|
94
|
-
testLocatorId:
|
|
95
|
-
...
|
|
95
|
+
disabled: t,
|
|
96
|
+
disabledTextValue: i,
|
|
97
|
+
translateSelect: c,
|
|
98
|
+
translateDefaultOption: m,
|
|
99
|
+
onFocus: h,
|
|
100
|
+
id: u,
|
|
101
|
+
textTransform: f,
|
|
102
|
+
defaultOptionColor: p,
|
|
103
|
+
testLocatorId: x,
|
|
104
|
+
...g
|
|
96
105
|
}) => /* @__PURE__ */ s.jsx(
|
|
97
106
|
A,
|
|
98
107
|
{
|
|
99
|
-
id:
|
|
100
|
-
cursor:
|
|
101
|
-
|
|
108
|
+
id: u,
|
|
109
|
+
cursor: t ? "not-allowed" : "pointer",
|
|
110
|
+
testLocatorId: x,
|
|
111
|
+
...g,
|
|
102
112
|
children: /* @__PURE__ */ s.jsx(
|
|
103
113
|
G,
|
|
104
114
|
{
|
|
105
115
|
defaultOptionObject: r,
|
|
106
|
-
hideDefaultOnSelect:
|
|
107
|
-
options:
|
|
116
|
+
hideDefaultOnSelect: C,
|
|
117
|
+
options: l,
|
|
108
118
|
value: o,
|
|
109
119
|
onChange: a,
|
|
110
|
-
disabled:
|
|
111
|
-
disabledTextValue:
|
|
112
|
-
translateSelect:
|
|
113
|
-
translateDefaultOption:
|
|
114
|
-
onFocus:
|
|
115
|
-
id:
|
|
116
|
-
textTransform:
|
|
117
|
-
defaultOptionColor:
|
|
118
|
-
testLocatorId:
|
|
120
|
+
disabled: t,
|
|
121
|
+
disabledTextValue: i,
|
|
122
|
+
translateSelect: c,
|
|
123
|
+
translateDefaultOption: m,
|
|
124
|
+
onFocus: h,
|
|
125
|
+
id: u,
|
|
126
|
+
textTransform: f,
|
|
127
|
+
defaultOptionColor: p,
|
|
128
|
+
testLocatorId: x
|
|
119
129
|
}
|
|
120
130
|
)
|
|
121
131
|
}
|
|
122
132
|
);
|
|
123
133
|
export {
|
|
124
134
|
G as FormV2Selector,
|
|
125
|
-
|
|
135
|
+
z as FormV2SelectorWithContainer
|
|
126
136
|
};
|
|
127
137
|
//# sourceMappingURL=sd-component-library57.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sd-component-library57.js","sources":["../src/components/forms-v2/form-v2-selector/form-v2-selector.tsx"],"sourcesContent":["import React, { useCallback, useMemo } from \"react\";\n\nimport { Select } from \"@rebass/forms\";\nimport { SxProps } from \"rebass\";\n\nimport { generateTestLocator } from \"../../../core/functions\";\nimport { SelectorOptionV2 } from \"../../selectors\";\nimport { getNoTranslateClass } from \"../../selectors/selector/selector\";\nimport { InputContainer, InputContainerProps } from \"../input-container\";\nimport { FormV2SelectorProps as Props } from \"./interfaces\";\n\nexport const FormV2Selector = <T extends string = string>({\n defaultOptionObject,\n hideDefaultOnSelect,\n options,\n value: selection,\n onChange,\n disabled,\n disabledTextValue,\n translateSelect = true,\n translateDefaultOption,\n onFocus,\n id,\n textTransform = \"none\",\n defaultOptionColor = \"cl_grey\",\n arrowColor = \"cl_darkGrey\",\n sx,\n testLocatorId,\n}: Props<T>) => {\n const allOptions = useMemo<SelectorOptionV2<T | null>[]>(\n () =>\n (\n (defaultOptionObject\n ? [defaultOptionObject]\n : []) as SelectorOptionV2<T | null>[]\n ).concat(options),\n [options, defaultOptionObject]\n );\n\n const onSelect = useCallback(\n (selectionString: string) => {\n const newSelection = allOptions.find(\n ({ title }) =>\n title.trim().replaceAll(/\\s{2,}/g, \" \") === selectionString\n )!;\n onChange(newSelection);\n },\n [onChange, allOptions]\n );\n\n const noOptionsToSelect = !options.length;\n const hasDefaultValue = !!defaultOptionObject;\n\n const defaultOptionClassName = getNoTranslateClass(\n (translateDefaultOption !== true && !translateSelect) ||\n translateDefaultOption === false\n );\n const regularOptionClassName = getNoTranslateClass(!translateSelect);\n\n const isFirefox = navigator.userAgent.toLowerCase().indexOf(\"firefox\") > -1;\n\n return (\n <Select\n value={noOptionsToSelect ? disabledTextValue : selection.title.trim()}\n onChange={(event) => onSelect(event.target.value)}\n variant=\"_inputs.v2\"\n sx={\n {\n pr: \"16px\",\n textTransform,\n cursor: \"inherit\",\n borderBottomColor: \"inherit\",\n ...(defaultOptionColor && selection.value === null\n ? { color: defaultOptionColor }\n : {}),\n // to override default styles for selector arrow\n \"& + svg\": {\n fill: disabled ? \"cl_lightGrey\" : arrowColor,\n transform: `translate(10px, ${isFirefox ? 0 : 5}px) scale(.78)`,\n path: {\n d: \"path('M12,8.6L6.72,3.29C6.32,2.9,5.68,2.9,5.29,3.29C4.90,3.69,4.9,4.33,5.29,4.73L11.23,10.7C11.44,10.91,11.72,11.01,12,11C12.27,11.01,12.55,10.91,12.76,10.7L18.7,4.73C19.09,4.33,19.09,3.69,18.7,3.29C18.31,2.9,17.67,2.9,17.27,3.29Z M12,8.6')\",\n },\n },\n ...sx,\n } as SxProps[\"sx\"]\n }\n {...{ id, disabled, onFocus }}\n {...generateTestLocator(testLocatorId)}\n >\n {noOptionsToSelect ? (\n <option
|
|
1
|
+
{"version":3,"file":"sd-component-library57.js","sources":["../src/components/forms-v2/form-v2-selector/form-v2-selector.tsx"],"sourcesContent":["import React, { useCallback, useMemo } from \"react\";\n\nimport { Select } from \"@rebass/forms\";\nimport { SxProps } from \"rebass\";\n\nimport { generateTestLocator } from \"../../../core/functions\";\nimport { SelectorOptionV2 } from \"../../selectors\";\nimport { getNoTranslateClass } from \"../../selectors/selector/selector\";\nimport { InputContainer, InputContainerProps } from \"../input-container\";\nimport { FormV2SelectorProps as Props } from \"./interfaces\";\n\nexport const FormV2Selector = <T extends string = string>({\n defaultOptionObject,\n hideDefaultOnSelect,\n options,\n value: selection,\n onChange,\n disabled,\n disabledTextValue,\n translateSelect = true,\n translateDefaultOption,\n onFocus,\n id,\n textTransform = \"none\",\n defaultOptionColor = \"cl_grey\",\n arrowColor = \"cl_darkGrey\",\n sx,\n testLocatorId,\n}: Props<T>) => {\n const allOptions = useMemo<SelectorOptionV2<T | null>[]>(\n () =>\n (\n (defaultOptionObject\n ? [defaultOptionObject]\n : []) as SelectorOptionV2<T | null>[]\n ).concat(options),\n [options, defaultOptionObject]\n );\n\n const onSelect = useCallback(\n (selectionString: string) => {\n const newSelection = allOptions.find(\n ({ title }) =>\n title.trim().replaceAll(/\\s{2,}/g, \" \") === selectionString\n )!;\n onChange(newSelection);\n },\n [onChange, allOptions]\n );\n\n const noOptionsToSelect = !options.length;\n const hasDefaultValue = !!defaultOptionObject;\n\n const defaultOptionClassName = getNoTranslateClass(\n (translateDefaultOption !== true && !translateSelect) ||\n translateDefaultOption === false\n );\n const regularOptionClassName = getNoTranslateClass(!translateSelect);\n\n const isFirefox = navigator.userAgent.toLowerCase().indexOf(\"firefox\") > -1;\n\n return (\n <Select\n value={noOptionsToSelect ? disabledTextValue : selection.title.trim()}\n onChange={(event) => onSelect(event.target.value)}\n variant=\"_inputs.v2\"\n sx={\n {\n pr: \"16px\",\n textTransform,\n cursor: \"inherit\",\n borderBottomColor: \"inherit\",\n ...(defaultOptionColor && selection.value === null\n ? { color: defaultOptionColor }\n : {}),\n // to override default styles for selector arrow\n \"& + svg\": {\n fill: disabled ? \"cl_lightGrey\" : arrowColor,\n transform: `translate(10px, ${isFirefox ? 0 : 5}px) scale(.78)`,\n path: {\n d: \"path('M12,8.6L6.72,3.29C6.32,2.9,5.68,2.9,5.29,3.29C4.90,3.69,4.9,4.33,5.29,4.73L11.23,10.7C11.44,10.91,11.72,11.01,12,11C12.27,11.01,12.55,10.91,12.76,10.7L18.7,4.73C19.09,4.33,19.09,3.69,18.7,3.29C18.31,2.9,17.67,2.9,17.27,3.29Z M12,8.6')\",\n },\n },\n ...sx,\n } as SxProps[\"sx\"]\n }\n {...{ id, disabled, onFocus }}\n {...generateTestLocator(testLocatorId)}\n >\n {noOptionsToSelect ? (\n <option\n key=\"disabledTextValue\"\n {...(testLocatorId\n ? generateTestLocator(`${testLocatorId}-disabled-option`)\n : {})}\n data-test=\"disabled-option\"\n >\n {disabledTextValue}\n </option>\n ) : (\n allOptions\n .slice(\n // should default option be hidden?\n hasDefaultValue && hideDefaultOnSelect && selection.value !== null\n ? 1\n : 0\n )\n .map((option) => (\n <option\n key={option.id}\n data-testid=\"selector-option\"\n {...(testLocatorId\n ? generateTestLocator(`${testLocatorId}-option`)\n : {})}\n value={option.title}\n className={\n option.value === null\n ? defaultOptionClassName\n : regularOptionClassName\n }\n >\n {option.title}\n </option>\n ))\n )}\n </Select>\n );\n};\n\nexport const FormV2SelectorWithContainer = <T extends string = string>({\n defaultOptionObject,\n hideDefaultOnSelect,\n options,\n value,\n onChange,\n disabled,\n disabledTextValue,\n translateSelect,\n translateDefaultOption,\n onFocus,\n id,\n textTransform,\n defaultOptionColor,\n testLocatorId,\n ...containerProps\n}: Props<T> & InputContainerProps) => (\n <InputContainer\n id={id}\n cursor={disabled ? \"not-allowed\" : \"pointer\"}\n testLocatorId={testLocatorId}\n {...containerProps}\n >\n <FormV2Selector\n {...{\n defaultOptionObject,\n hideDefaultOnSelect,\n options,\n value,\n onChange,\n disabled,\n disabledTextValue,\n translateSelect,\n translateDefaultOption,\n onFocus,\n id,\n textTransform,\n defaultOptionColor,\n testLocatorId,\n }}\n />\n </InputContainer>\n);\n"],"names":["FormV2Selector","defaultOptionObject","hideDefaultOnSelect","options","selection","onChange","disabled","disabledTextValue","translateSelect","translateDefaultOption","onFocus","id","textTransform","defaultOptionColor","arrowColor","sx","testLocatorId","allOptions","useMemo","onSelect","useCallback","selectionString","newSelection","title","noOptionsToSelect","hasDefaultValue","defaultOptionClassName","getNoTranslateClass","regularOptionClassName","isFirefox","jsx","Select","event","generateTestLocator","option","FormV2SelectorWithContainer","value","containerProps","InputContainer"],"mappings":";;;;;;AAWO,MAAMA,IAAiB,CAA4B;AAAA,EACxD,qBAAAC;AAAA,EACA,qBAAAC;AAAA,EACA,SAAAC;AAAA,EACA,OAAOC;AAAA,EACP,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,wBAAAC;AAAA,EACA,SAAAC;AAAA,EACA,IAAAC;AAAA,EACA,eAAAC,IAAgB;AAAA,EAChB,oBAAAC,IAAqB;AAAA,EACrB,YAAAC,IAAa;AAAA,EACb,IAAAC;AAAA,EACA,eAAAC;AACF,MAAgB;AACd,QAAMC,IAAaC;AAAA,IACjB,OAEKjB,IACG,CAACA,CAAmB,IACpB,CAAC,GACL,OAAOE,CAAO;AAAA,IAClB,CAACA,GAASF,CAAmB;AAAA,EAAA,GAGzBkB,IAAWC;AAAA,IACf,CAACC,MAA4B;AAC3B,YAAMC,IAAeL,EAAW;AAAA,QAC9B,CAAC,EAAE,OAAAM,EACD,MAAAA,EAAM,KAAO,EAAA,WAAW,WAAW,GAAG,MAAMF;AAAA,MAAA;AAEhD,MAAAhB,EAASiB,CAAY;AAAA,IACvB;AAAA,IACA,CAACjB,GAAUY,CAAU;AAAA,EAAA,GAGjBO,IAAoB,CAACrB,EAAQ,QAC7BsB,IAAkB,CAAC,CAACxB,GAEpByB,IAAyBC;AAAA,IAC5BlB,MAA2B,MAAQ,CAACD,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WACEA,EAAO,UAAU,OACbR,IACAE;AAAA,UAGL,UAAOM,EAAA;AAAA,QAAA;AAAA,QAZHA,EAAO;AAAA,MAAA,CAcf;AAAA,IAAA;AAAA,EAAA;AAIX,GAEaC,IAA8B,CAA4B;AAAA,EACrE,qBAAAlC;AAAA,EACA,qBAAAC;AAAA,EACA,SAAAC;AAAA,EACA,OAAAiC;AAAA,EACA,UAAA/B;AAAA,EACA,UAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,wBAAAC;AAAA,EACA,SAAAC;AAAA,EACA,IAAAC;AAAA,EACA,eAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,eAAAG;AAAA,EACA,GAAGqB;AACL,MACEP,gBAAAA,EAAA;AAAA,EAACQ;AAAA,EAAA;AAAA,IACC,IAAA3B;AAAA,IACA,QAAQL,IAAW,gBAAgB;AAAA,IACnC,eAAAU;AAAA,IACC,GAAGqB;AAAA,IAEJ,UAAAP,gBAAAA,EAAA;AAAA,MAAC9B;AAAA,MAAA;AAAA,QAEG,qBAAAC;AAAA,QACA,qBAAAC;AAAA,QACA,SAAAC;AAAA,QACA,OAAAiC;AAAA,QACA,UAAA/B;AAAA,QACA,UAAAC;AAAA,QACA,mBAAAC;AAAA,QACA,iBAAAC;AAAA,QACA,wBAAAC;AAAA,QACA,SAAAC;AAAA,QACA,IAAAC;AAAA,QACA,eAAAC;AAAA,QACA,oBAAAC;AAAA,QACA,eAAAG;AAAA,MACF;AAAA,IACF;AAAA,EAAA;AACF;"}
|
|
@@ -1,92 +1,97 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import
|
|
1
|
+
import { j as l } from "./sd-component-library197.js";
|
|
2
|
+
import { generateTestLocator as x } from "./sd-component-library4.js";
|
|
3
|
+
import T from "./sd-component-library196.js";
|
|
3
4
|
import { InputLabel as z } from "./sd-component-library59.js";
|
|
4
5
|
import { GridContainerV2 as B } from "./sd-component-library38.js";
|
|
5
|
-
import { BaseTextV2 as
|
|
6
|
-
const
|
|
7
|
-
gap:
|
|
6
|
+
import { BaseTextV2 as e } from "./sd-component-library138.js";
|
|
7
|
+
const V = ({
|
|
8
|
+
gap: r = "0px",
|
|
8
9
|
cursor: f = "pointer",
|
|
9
10
|
sx: d,
|
|
10
|
-
required:
|
|
11
|
-
textAlign:
|
|
12
|
-
width:
|
|
13
|
-
label:
|
|
14
|
-
labelProps:
|
|
15
|
-
secondaryLabel:
|
|
16
|
-
secondaryLabelProps:
|
|
17
|
-
showErrorMessageText:
|
|
11
|
+
required: m = !1,
|
|
12
|
+
textAlign: h = "left",
|
|
13
|
+
width: u = "240px",
|
|
14
|
+
label: p,
|
|
15
|
+
labelProps: o,
|
|
16
|
+
secondaryLabel: c = m ? "*" : void 0,
|
|
17
|
+
secondaryLabelProps: a = m ? { color: "cl_purple", fontSize: 16, lineHeight: "12px" } : void 0,
|
|
18
|
+
showErrorMessageText: _ = !0,
|
|
18
19
|
errorMessage: t,
|
|
19
|
-
errorMessageProps:
|
|
20
|
-
baseBgColor:
|
|
21
|
-
bg:
|
|
22
|
-
id:
|
|
23
|
-
children:
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
errorMessageProps: n,
|
|
21
|
+
baseBgColor: j = "white",
|
|
22
|
+
bg: S = t ? "rgba(255, 0, 0, 0.05)" : j,
|
|
23
|
+
id: v,
|
|
24
|
+
children: y,
|
|
25
|
+
testLocatorId: i,
|
|
26
|
+
...C
|
|
27
|
+
}) => /* @__PURE__ */ l.jsxs(
|
|
26
28
|
B,
|
|
27
29
|
{
|
|
28
|
-
width:
|
|
29
|
-
gap:
|
|
30
|
-
bg:
|
|
31
|
-
textAlign:
|
|
32
|
-
...
|
|
30
|
+
width: u,
|
|
31
|
+
gap: r,
|
|
32
|
+
bg: S,
|
|
33
|
+
textAlign: h,
|
|
34
|
+
...C,
|
|
33
35
|
sx: {
|
|
34
36
|
position: "relative",
|
|
35
37
|
cursor: f,
|
|
36
38
|
flexGrow: 1,
|
|
37
39
|
"> * ": {
|
|
38
|
-
borderBottomColor: t ? "cl_red" :
|
|
40
|
+
borderBottomColor: t ? "cl_red" : T.forms._inputs.v2.borderBottomColor
|
|
39
41
|
},
|
|
40
42
|
...d
|
|
41
43
|
},
|
|
42
44
|
children: [
|
|
43
|
-
|
|
45
|
+
p && /* @__PURE__ */ l.jsxs(
|
|
44
46
|
z,
|
|
45
47
|
{
|
|
46
|
-
htmlFor:
|
|
48
|
+
htmlFor: v,
|
|
47
49
|
maxWidth: "100%",
|
|
48
50
|
color: t ? "cl_red" : "cl_darkGrey",
|
|
49
51
|
fontSize: 10,
|
|
50
52
|
fontWeight: "600",
|
|
51
|
-
...i,
|
|
53
|
+
...i ? x(`${i}-primary-label`) : {},
|
|
54
|
+
...o,
|
|
52
55
|
sx: {
|
|
53
56
|
letterSpacing: "1px",
|
|
54
57
|
textTransform: "uppercase",
|
|
55
58
|
cursor: "default",
|
|
56
|
-
...
|
|
59
|
+
...o == null ? void 0 : o.sx
|
|
57
60
|
},
|
|
58
61
|
children: [
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
p,
|
|
63
|
+
c && /* @__PURE__ */ l.jsx(
|
|
64
|
+
e,
|
|
62
65
|
{
|
|
63
66
|
display: "inline-block",
|
|
64
67
|
textTransform: "uppercase",
|
|
65
68
|
letterSpacing: "1px",
|
|
66
69
|
color: "cl_grey",
|
|
67
70
|
ml: "3px",
|
|
68
|
-
...
|
|
69
|
-
|
|
71
|
+
...i ? x(`${i}-secondary-label`) : {},
|
|
72
|
+
...a,
|
|
73
|
+
children: c
|
|
70
74
|
}
|
|
71
75
|
)
|
|
72
76
|
]
|
|
73
77
|
}
|
|
74
78
|
),
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
y,
|
|
80
|
+
_ && !!t && /* @__PURE__ */ l.jsx(
|
|
81
|
+
e,
|
|
78
82
|
{
|
|
79
83
|
fontSize: "12px",
|
|
80
84
|
lineHeight: "12px",
|
|
81
85
|
color: "cl_red",
|
|
82
86
|
maxWidth: "100%",
|
|
83
|
-
...
|
|
87
|
+
...n,
|
|
88
|
+
...i ? x(`${i}-error-message`) : {},
|
|
84
89
|
sx: {
|
|
85
90
|
position: "absolute",
|
|
86
91
|
top: "calc(100% + 5px)",
|
|
87
92
|
left: 0,
|
|
88
93
|
cursor: "default",
|
|
89
|
-
...
|
|
94
|
+
...n == null ? void 0 : n.sx
|
|
90
95
|
},
|
|
91
96
|
children: t
|
|
92
97
|
}
|
|
@@ -95,6 +100,6 @@ const y = ({
|
|
|
95
100
|
}
|
|
96
101
|
);
|
|
97
102
|
export {
|
|
98
|
-
|
|
103
|
+
V as InputContainer
|
|
99
104
|
};
|
|
100
105
|
//# sourceMappingURL=sd-component-library58.js.map
|