@chayns-components/core 5.0.24 → 5.0.25
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/cjs/components/color-scheme-provider/ColorSchemeProvider.js +5 -1
- package/lib/cjs/components/color-scheme-provider/ColorSchemeProvider.js.map +1 -1
- package/lib/cjs/components/color-scheme-provider/ColorSchemeProvider.styles.js +37 -0
- package/lib/cjs/components/color-scheme-provider/ColorSchemeProvider.styles.js.map +1 -1
- package/lib/cjs/components/list/List.js +97 -37
- package/lib/cjs/components/list/List.js.map +1 -1
- package/lib/cjs/components/list/list-item/ListItem.js +0 -9
- package/lib/cjs/components/list/list-item/ListItem.js.map +1 -1
- package/lib/cjs/components/number-input/NumberInput.js +213 -132
- package/lib/cjs/components/number-input/NumberInput.js.map +1 -1
- package/lib/cjs/utils/numberInput.js +1 -0
- package/lib/cjs/utils/numberInput.js.map +1 -1
- package/lib/esm/components/color-scheme-provider/ColorSchemeProvider.js +6 -2
- package/lib/esm/components/color-scheme-provider/ColorSchemeProvider.js.map +1 -1
- package/lib/esm/components/color-scheme-provider/ColorSchemeProvider.styles.js +38 -1
- package/lib/esm/components/color-scheme-provider/ColorSchemeProvider.styles.js.map +1 -1
- package/lib/esm/components/list/List.js +97 -37
- package/lib/esm/components/list/List.js.map +1 -1
- package/lib/esm/components/list/list-item/ListItem.js +0 -9
- package/lib/esm/components/list/list-item/ListItem.js.map +1 -1
- package/lib/esm/components/number-input/NumberInput.js +213 -132
- package/lib/esm/components/number-input/NumberInput.js.map +1 -1
- package/lib/esm/utils/numberInput.js +1 -0
- package/lib/esm/utils/numberInput.js.map +1 -1
- package/lib/types/components/color-scheme-provider/ColorSchemeProvider.styles.d.ts +7 -3
- package/lib/types/components/list/List.d.ts +0 -1
- package/package.json +2 -2
|
@@ -4,155 +4,236 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _reactCompilerRuntime = require("react-compiler-runtime");
|
|
7
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
9
|
var _numberInput = require("../../constants/numberInput");
|
|
9
10
|
var _numberInput2 = require("../../utils/numberInput");
|
|
10
11
|
var _Input = _interopRequireDefault(require("../input/Input"));
|
|
11
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
13
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
-
const NumberInput =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
14
|
+
const NumberInput = t0 => {
|
|
15
|
+
"use memo";
|
|
16
|
+
|
|
17
|
+
const $ = (0, _reactCompilerRuntime.c)(41);
|
|
18
|
+
const {
|
|
19
|
+
isDecimalInput,
|
|
20
|
+
isMoneyInput,
|
|
21
|
+
isTimeInput,
|
|
22
|
+
isInvalid,
|
|
23
|
+
maxNumber: t1,
|
|
24
|
+
value,
|
|
25
|
+
shouldTriggerChangeOnFormat: t2,
|
|
26
|
+
placeholder,
|
|
27
|
+
onBlur,
|
|
28
|
+
isDisabled,
|
|
29
|
+
onChange,
|
|
30
|
+
shouldShowOnlyBottomBorder,
|
|
31
|
+
minNumber: t3
|
|
32
|
+
} = t0;
|
|
33
|
+
const maxNumber = t1 === undefined ? Infinity : t1;
|
|
34
|
+
const shouldTriggerChangeOnFormat = t2 === undefined ? true : t2;
|
|
35
|
+
const minNumber = t3 === undefined ? -Infinity : t3;
|
|
36
|
+
const [plainText, setPlainText] = (0, _react.useState)("");
|
|
37
|
+
const [formattedValue, setFormattedValue] = (0, _react.useState)("");
|
|
32
38
|
const [hasFocus, setHasFocus] = (0, _react.useState)(false);
|
|
33
39
|
const [shouldRemainPlaceholder, setShouldRemainPlaceholder] = (0, _react.useState)(false);
|
|
34
40
|
const [isValueInvalid, setIsValueInvalid] = (0, _react.useState)(false);
|
|
35
|
-
const localPlaceholder = placeholder ?? (isMoneyInput ?
|
|
41
|
+
const localPlaceholder = placeholder ?? (isMoneyInput ? "\u20AC" : undefined);
|
|
36
42
|
const initialInputRef = (0, _react.useRef)(true);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
const valueToCheck = sanitizedValueString.replaceAll(',', '.');
|
|
47
|
-
if (!(0, _numberInput2.isValidString)({
|
|
48
|
-
string: valueToCheck,
|
|
49
|
-
isMoneyInput,
|
|
50
|
-
isDecimalInput,
|
|
51
|
-
isTimeInput
|
|
52
|
-
})) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (maxNumber && Number(valueToCheck) > maxNumber || minNumber && Number(valueToCheck) < minNumber) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (newValue.length === 1 && newValue.match(/^[0-9]+$/) === null) {
|
|
59
|
-
setShouldRemainPlaceholder(true);
|
|
60
|
-
} else {
|
|
61
|
-
setShouldRemainPlaceholder(false);
|
|
62
|
-
}
|
|
63
|
-
setPlainText(sanitizedValueString.replaceAll('.', ','));
|
|
64
|
-
if (typeof onChange === 'function') {
|
|
65
|
-
onChange(sanitizedValueString.replaceAll('.', ','));
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
const onLocalBlur = () => {
|
|
69
|
-
const sanitizedValue = plainText;
|
|
70
|
-
let newIsInvalid = false;
|
|
71
|
-
let parsedNumber = null;
|
|
72
|
-
if (!isTimeInput) {
|
|
73
|
-
parsedNumber = (0, _numberInput2.parseFloatWithDecimals)({
|
|
74
|
-
stringValue: sanitizedValue.replace(',', '.').replaceAll(':', '').replace('€', ''),
|
|
75
|
-
decimals: isMoneyInput ? 2 : undefined
|
|
76
|
-
});
|
|
77
|
-
if (parsedNumber && parsedNumber !== 0 && (parsedNumber > maxNumber || parsedNumber < minNumber)) {
|
|
78
|
-
newIsInvalid = true;
|
|
43
|
+
let t4;
|
|
44
|
+
if ($[0] !== isDecimalInput || $[1] !== isMoneyInput || $[2] !== isTimeInput || $[3] !== maxNumber || $[4] !== minNumber || $[5] !== onChange) {
|
|
45
|
+
t4 = event => {
|
|
46
|
+
const newValue = event.target.value;
|
|
47
|
+
initialInputRef.current = false;
|
|
48
|
+
const sanitizedValueString = newValue.replace(_numberInput.NUMBER_CLEAR_REGEX, "");
|
|
49
|
+
if (isTimeInput && (sanitizedValueString.includes(":") && sanitizedValueString.length > 5 || !sanitizedValueString.includes(":") && sanitizedValueString.length > 4)) {
|
|
50
|
+
return;
|
|
79
51
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (isTimeInput) {
|
|
95
|
-
onBlur(newStringValue, newIsInvalid);
|
|
52
|
+
const valueToCheck = sanitizedValueString.replaceAll(",", ".");
|
|
53
|
+
if (!(0, _numberInput2.isValidString)({
|
|
54
|
+
string: valueToCheck,
|
|
55
|
+
isMoneyInput,
|
|
56
|
+
isDecimalInput,
|
|
57
|
+
isTimeInput
|
|
58
|
+
})) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (maxNumber && Number(valueToCheck) > maxNumber || minNumber && Number(valueToCheck) < minNumber) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (newValue.length === 1 && newValue.match(/^[0-9]+$/) === null) {
|
|
65
|
+
setShouldRemainPlaceholder(true);
|
|
96
66
|
} else {
|
|
97
|
-
|
|
67
|
+
setShouldRemainPlaceholder(false);
|
|
98
68
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
69
|
+
setPlainText(sanitizedValueString.replaceAll(".", ","));
|
|
70
|
+
if (typeof onChange === "function") {
|
|
71
|
+
onChange(sanitizedValueString.replaceAll(".", ","));
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
$[0] = isDecimalInput;
|
|
75
|
+
$[1] = isMoneyInput;
|
|
76
|
+
$[2] = isTimeInput;
|
|
77
|
+
$[3] = maxNumber;
|
|
78
|
+
$[4] = minNumber;
|
|
79
|
+
$[5] = onChange;
|
|
80
|
+
$[6] = t4;
|
|
81
|
+
} else {
|
|
82
|
+
t4 = $[6];
|
|
83
|
+
}
|
|
84
|
+
const onLocalChange = t4;
|
|
85
|
+
let t5;
|
|
86
|
+
if ($[7] !== isMoneyInput || $[8] !== isTimeInput || $[9] !== maxNumber || $[10] !== minNumber || $[11] !== onBlur || $[12] !== onChange || $[13] !== plainText || $[14] !== shouldTriggerChangeOnFormat) {
|
|
87
|
+
t5 = () => {
|
|
88
|
+
const sanitizedValue = plainText;
|
|
89
|
+
let newIsInvalid = false;
|
|
90
|
+
let parsedNumber = null;
|
|
91
|
+
if (!isTimeInput) {
|
|
92
|
+
parsedNumber = (0, _numberInput2.parseFloatWithDecimals)({
|
|
93
|
+
stringValue: sanitizedValue.replace(",", ".").replaceAll(":", "").replace("\u20AC", ""),
|
|
94
|
+
decimals: isMoneyInput ? 2 : undefined
|
|
95
|
+
});
|
|
96
|
+
if (parsedNumber && parsedNumber !== 0 && (parsedNumber > maxNumber || parsedNumber < minNumber)) {
|
|
97
|
+
newIsInvalid = true;
|
|
98
|
+
}
|
|
99
|
+
setIsValueInvalid(newIsInvalid);
|
|
100
|
+
}
|
|
101
|
+
const newStringValue = plainText.length === 0 ? "" : (0, _numberInput2.formateNumber)({
|
|
102
|
+
number: isTimeInput ? sanitizedValue : parsedNumber,
|
|
103
|
+
isMoneyInput,
|
|
104
|
+
isTimeInput
|
|
121
105
|
});
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
106
|
+
setFormattedValue(`${newStringValue} ${isMoneyInput ? "\u20AC" : ""}`);
|
|
107
|
+
setPlainText(newStringValue.replaceAll(".", ""));
|
|
108
|
+
setHasFocus(false);
|
|
109
|
+
if (typeof onChange === "function" && shouldTriggerChangeOnFormat) {
|
|
110
|
+
onChange(newStringValue.replaceAll(".", ""));
|
|
111
|
+
}
|
|
112
|
+
if (typeof onBlur === "function") {
|
|
113
|
+
if (isTimeInput) {
|
|
114
|
+
onBlur(newStringValue, newIsInvalid);
|
|
127
115
|
} else {
|
|
128
|
-
|
|
116
|
+
onBlur(parsedNumber, newIsInvalid);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
$[7] = isMoneyInput;
|
|
121
|
+
$[8] = isTimeInput;
|
|
122
|
+
$[9] = maxNumber;
|
|
123
|
+
$[10] = minNumber;
|
|
124
|
+
$[11] = onBlur;
|
|
125
|
+
$[12] = onChange;
|
|
126
|
+
$[13] = plainText;
|
|
127
|
+
$[14] = shouldTriggerChangeOnFormat;
|
|
128
|
+
$[15] = t5;
|
|
129
|
+
} else {
|
|
130
|
+
t5 = $[15];
|
|
131
|
+
}
|
|
132
|
+
const onLocalBlur = t5;
|
|
133
|
+
let t6;
|
|
134
|
+
if ($[16] !== formattedValue || $[17] !== onChange || $[18] !== shouldTriggerChangeOnFormat) {
|
|
135
|
+
t6 = () => {
|
|
136
|
+
setPlainText(formattedValue.replaceAll(".", "").replace("\u20AC", "").replaceAll(" ", ""));
|
|
137
|
+
if (typeof onChange === "function" && shouldTriggerChangeOnFormat) {
|
|
138
|
+
onChange(formattedValue.replaceAll(".", "").replace("\u20AC", "").replaceAll(" ", ""));
|
|
139
|
+
}
|
|
140
|
+
setIsValueInvalid(false);
|
|
141
|
+
setHasFocus(true);
|
|
142
|
+
};
|
|
143
|
+
$[16] = formattedValue;
|
|
144
|
+
$[17] = onChange;
|
|
145
|
+
$[18] = shouldTriggerChangeOnFormat;
|
|
146
|
+
$[19] = t6;
|
|
147
|
+
} else {
|
|
148
|
+
t6 = $[19];
|
|
149
|
+
}
|
|
150
|
+
const onLocalFocus = t6;
|
|
151
|
+
let t7;
|
|
152
|
+
let t8;
|
|
153
|
+
if ($[20] !== hasFocus || $[21] !== isMoneyInput || $[22] !== isTimeInput || $[23] !== maxNumber || $[24] !== minNumber || $[25] !== plainText) {
|
|
154
|
+
t7 = () => {
|
|
155
|
+
let parsedNumber_0 = null;
|
|
156
|
+
if (!isTimeInput) {
|
|
157
|
+
parsedNumber_0 = (0, _numberInput2.parseFloatWithDecimals)({
|
|
158
|
+
stringValue: plainText.replace(",", ".").replaceAll(":", "").replace("\u20AC", "").replaceAll(" ", ""),
|
|
159
|
+
decimals: isMoneyInput ? 2 : undefined
|
|
160
|
+
});
|
|
161
|
+
if (!hasFocus) {
|
|
162
|
+
if (parsedNumber_0 === null && initialInputRef.current) {
|
|
163
|
+
setIsValueInvalid(false);
|
|
164
|
+
} else {
|
|
165
|
+
setIsValueInvalid(parsedNumber_0 === null || parsedNumber_0 > maxNumber || parsedNumber_0 < minNumber);
|
|
166
|
+
}
|
|
129
167
|
}
|
|
130
168
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
169
|
+
setFormattedValue(plainText.length === 0 ? "" : `${(0, _numberInput2.formateNumber)({
|
|
170
|
+
number: isTimeInput ? plainText : parsedNumber_0,
|
|
171
|
+
isMoneyInput,
|
|
172
|
+
isTimeInput
|
|
173
|
+
})}${isMoneyInput ? " \u20AC" : ""}`);
|
|
174
|
+
};
|
|
175
|
+
t8 = [hasFocus, isMoneyInput, isTimeInput, maxNumber, minNumber, plainText];
|
|
176
|
+
$[20] = hasFocus;
|
|
177
|
+
$[21] = isMoneyInput;
|
|
178
|
+
$[22] = isTimeInput;
|
|
179
|
+
$[23] = maxNumber;
|
|
180
|
+
$[24] = minNumber;
|
|
181
|
+
$[25] = plainText;
|
|
182
|
+
$[26] = t7;
|
|
183
|
+
$[27] = t8;
|
|
184
|
+
} else {
|
|
185
|
+
t7 = $[26];
|
|
186
|
+
t8 = $[27];
|
|
187
|
+
}
|
|
188
|
+
(0, _react.useEffect)(t7, t8);
|
|
189
|
+
let t10;
|
|
190
|
+
let t9;
|
|
191
|
+
if ($[28] !== value) {
|
|
192
|
+
t9 = () => {
|
|
193
|
+
if (typeof value === "string") {
|
|
194
|
+
setPlainText(value.replace("\u20AC", "").replaceAll(" ", ""));
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
t10 = [value];
|
|
198
|
+
$[28] = value;
|
|
199
|
+
$[29] = t10;
|
|
200
|
+
$[30] = t9;
|
|
201
|
+
} else {
|
|
202
|
+
t10 = $[29];
|
|
203
|
+
t9 = $[30];
|
|
204
|
+
}
|
|
205
|
+
(0, _react.useEffect)(t9, t10);
|
|
206
|
+
const t11 = hasFocus ? plainText : formattedValue;
|
|
207
|
+
const t12 = typeof isInvalid === "boolean" ? isInvalid : isValueInvalid;
|
|
208
|
+
let t13;
|
|
209
|
+
if ($[31] !== isDisabled || $[32] !== localPlaceholder || $[33] !== onLocalBlur || $[34] !== onLocalChange || $[35] !== onLocalFocus || $[36] !== shouldRemainPlaceholder || $[37] !== shouldShowOnlyBottomBorder || $[38] !== t11 || $[39] !== t12) {
|
|
210
|
+
t13 = /*#__PURE__*/_react.default.createElement(_Input.default, {
|
|
211
|
+
shouldRemainPlaceholder: shouldRemainPlaceholder,
|
|
212
|
+
shouldShowOnlyBottomBorder: shouldShowOnlyBottomBorder,
|
|
213
|
+
inputMode: "decimal",
|
|
214
|
+
onChange: onLocalChange,
|
|
215
|
+
value: t11,
|
|
216
|
+
placeholder: localPlaceholder,
|
|
217
|
+
onBlur: onLocalBlur,
|
|
218
|
+
onFocus: onLocalFocus,
|
|
219
|
+
isDisabled: isDisabled,
|
|
220
|
+
isInvalid: t12,
|
|
221
|
+
shouldShowCenteredContent: shouldShowOnlyBottomBorder
|
|
222
|
+
});
|
|
223
|
+
$[31] = isDisabled;
|
|
224
|
+
$[32] = localPlaceholder;
|
|
225
|
+
$[33] = onLocalBlur;
|
|
226
|
+
$[34] = onLocalChange;
|
|
227
|
+
$[35] = onLocalFocus;
|
|
228
|
+
$[36] = shouldRemainPlaceholder;
|
|
229
|
+
$[37] = shouldShowOnlyBottomBorder;
|
|
230
|
+
$[38] = t11;
|
|
231
|
+
$[39] = t12;
|
|
232
|
+
$[40] = t13;
|
|
233
|
+
} else {
|
|
234
|
+
t13 = $[40];
|
|
235
|
+
}
|
|
236
|
+
return t13;
|
|
156
237
|
};
|
|
157
238
|
NumberInput.displayName = 'NumberInput';
|
|
158
239
|
var _default = exports.default = NumberInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberInput.js","names":["_react","_interopRequireWildcard","require","_numberInput","_numberInput2","_Input","_interopRequireDefault","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","NumberInput","isDecimalInput","isMoneyInput","isTimeInput","isInvalid","maxNumber","Infinity","value","shouldTriggerChangeOnFormat","placeholder","onBlur","isDisabled","onChange","shouldShowOnlyBottomBorder","minNumber","plainText","setPlainText","useState","formattedValue","setFormattedValue","hasFocus","setHasFocus","shouldRemainPlaceholder","setShouldRemainPlaceholder","isValueInvalid","setIsValueInvalid","localPlaceholder","undefined","initialInputRef","useRef","onLocalChange","event","newValue","target","current","sanitizedValueString","replace","NUMBER_CLEAR_REGEX","includes","length","valueToCheck","replaceAll","isValidString","string","Number","match","onLocalBlur","sanitizedValue","newIsInvalid","parsedNumber","parseFloatWithDecimals","stringValue","decimals","newStringValue","formateNumber","number","onLocalFocus","useEffect","createElement","inputMode","onFocus","shouldShowCenteredContent","displayName","_default","exports"],"sources":["../../../../src/components/number-input/NumberInput.tsx"],"sourcesContent":["import React, { ChangeEventHandler, FC, useEffect, useRef, useState } from 'react';\nimport { NUMBER_CLEAR_REGEX } from '../../constants/numberInput';\nimport { formateNumber, isValidString, parseFloatWithDecimals } from '../../utils/numberInput';\nimport Input from '../input/Input';\n\nexport type NumberInputProps = {\n /**\n * Applies rules for decimal input.\n * Enables the user to input one zero as number before the comma\n */\n isDecimalInput?: boolean;\n /**\n * Whether the input is disabled\n */\n isDisabled?: boolean;\n /**\n * Whether the value is invalid.\n */\n isInvalid?: boolean;\n /**\n * Applies rules for money input.\n * Rules: only two decimal places, one zero before the comma\n */\n isMoneyInput?: boolean;\n /**\n * Whether the value should be formatted as a time.\n */\n isTimeInput?: boolean;\n /**\n * Limits the number to this value\n */\n maxNumber?: number;\n /**\n * Limits the number to this value\n */\n minNumber?: number;\n /**\n * Callback function that is called when the input gets out of focus\n */\n onBlur?: (newNumber: number | string | null, isInvalid: boolean) => void;\n /**\n * Callback function that is called when the input changes\n * It will pass the text from the input\n */\n onChange?: (newValue: string) => void;\n /**\n * Placeholder for the input field\n */\n placeholder?: string;\n /**\n * Whether only the bottom border should be displayed\n */\n shouldShowOnlyBottomBorder?: boolean;\n /**\n * Whether the onChange function should be triggert when the value is formatted on the focus or blur\n */\n shouldTriggerChangeOnFormat?: boolean;\n /**\n * The value, that should be displayed in the input, when it is in focus.\n * You can also pass a stringified number as default value.\n * NOTE: If you pass a stringified number, it will be formatted to the selected format\n */\n value?: string;\n};\n\nconst NumberInput: FC<NumberInputProps> = ({\n isDecimalInput,\n isMoneyInput,\n isTimeInput,\n isInvalid,\n maxNumber = Infinity,\n value,\n shouldTriggerChangeOnFormat = true,\n placeholder,\n onBlur,\n isDisabled,\n onChange,\n shouldShowOnlyBottomBorder,\n minNumber = -Infinity,\n}) => {\n // the plainText will be shown in the input, when it is in focus\n const [plainText, setPlainText] = useState<string>('');\n // the formattedValue will be shown in the input, when it is not in focus\n const [formattedValue, setFormattedValue] = useState<string>('');\n const [hasFocus, setHasFocus] = useState<boolean>(false);\n const [shouldRemainPlaceholder, setShouldRemainPlaceholder] = useState<boolean>(false);\n\n const [isValueInvalid, setIsValueInvalid] = useState(false);\n const localPlaceholder = placeholder ?? (isMoneyInput ? '€' : undefined);\n\n const initialInputRef = useRef(true);\n\n const onLocalChange: ChangeEventHandler<HTMLInputElement> = (event) => {\n const newValue = event.target.value;\n\n initialInputRef.current = false;\n\n const sanitizedValueString = newValue\n // Removes everything except numbers, commas and points\n .replace(NUMBER_CLEAR_REGEX, '');\n\n if (\n isTimeInput &&\n ((sanitizedValueString.includes(':') && sanitizedValueString.length > 5) ||\n (!sanitizedValueString.includes(':') && sanitizedValueString.length > 4))\n ) {\n return;\n }\n\n const valueToCheck = sanitizedValueString.replaceAll(',', '.');\n\n if (!isValidString({ string: valueToCheck, isMoneyInput, isDecimalInput, isTimeInput })) {\n return;\n }\n\n if (\n (maxNumber && Number(valueToCheck) > maxNumber) ||\n (minNumber && Number(valueToCheck) < minNumber)\n ) {\n return;\n }\n\n if (newValue.length === 1 && newValue.match(/^[0-9]+$/) === null) {\n setShouldRemainPlaceholder(true);\n } else {\n setShouldRemainPlaceholder(false);\n }\n\n setPlainText(sanitizedValueString.replaceAll('.', ','));\n\n if (typeof onChange === 'function') {\n onChange(sanitizedValueString.replaceAll('.', ','));\n }\n };\n\n const onLocalBlur = () => {\n const sanitizedValue = plainText;\n let newIsInvalid = false;\n let parsedNumber = null;\n\n if (!isTimeInput) {\n parsedNumber = parseFloatWithDecimals({\n stringValue: sanitizedValue.replace(',', '.').replaceAll(':', '').replace('€', ''),\n decimals: isMoneyInput ? 2 : undefined,\n });\n\n if (\n parsedNumber &&\n parsedNumber !== 0 &&\n (parsedNumber > maxNumber || parsedNumber < minNumber)\n ) {\n newIsInvalid = true;\n }\n\n setIsValueInvalid(newIsInvalid);\n }\n\n const newStringValue =\n plainText.length === 0\n ? ''\n : formateNumber({\n number: isTimeInput ? sanitizedValue : parsedNumber,\n isMoneyInput,\n isTimeInput,\n });\n\n setFormattedValue(`${newStringValue} ${isMoneyInput ? '€' : ''}`);\n setPlainText(newStringValue.replaceAll('.', ''));\n setHasFocus(false);\n\n if (typeof onChange === 'function' && shouldTriggerChangeOnFormat) {\n onChange(newStringValue.replaceAll('.', ''));\n }\n\n if (typeof onBlur === 'function') {\n if (isTimeInput) {\n onBlur(newStringValue, newIsInvalid);\n } else {\n onBlur(parsedNumber, newIsInvalid);\n }\n }\n };\n\n const onLocalFocus = () => {\n // formattedValue will be a number string with german number format (e.g. 1.000,00)\n // It will remove all dots, so that the user can type in the number\n setPlainText(formattedValue.replaceAll('.', '').replace('€', '').replaceAll(' ', ''));\n\n // This will update the external state\n if (typeof onChange === 'function' && shouldTriggerChangeOnFormat) {\n onChange(formattedValue.replaceAll('.', '').replace('€', '').replaceAll(' ', ''));\n }\n\n setIsValueInvalid(false);\n setHasFocus(true);\n };\n\n // updates the formattedValue, when the value changes\n useEffect(() => {\n let parsedNumber = null;\n\n if (!isTimeInput) {\n parsedNumber = parseFloatWithDecimals({\n stringValue: plainText\n .replace(',', '.')\n .replaceAll(':', '')\n .replace('€', '')\n .replaceAll(' ', ''),\n decimals: isMoneyInput ? 2 : undefined,\n });\n\n // checks, if a given number is invalid, if the input is not in focus\n if (!hasFocus) {\n if (parsedNumber === null && initialInputRef.current) {\n setIsValueInvalid(false);\n } else {\n setIsValueInvalid(\n parsedNumber === null ||\n parsedNumber > maxNumber ||\n parsedNumber < minNumber,\n );\n }\n }\n }\n\n setFormattedValue(\n plainText.length === 0\n ? ''\n : `${formateNumber({\n number: isTimeInput ? plainText : parsedNumber,\n isMoneyInput,\n isTimeInput,\n })}${isMoneyInput ? ' €' : ''}`,\n );\n }, [hasFocus, isMoneyInput, isTimeInput, maxNumber, minNumber, plainText]);\n\n useEffect(() => {\n if (typeof value === 'string') {\n setPlainText(value.replace('€', '').replaceAll(' ', ''));\n }\n }, [value]);\n\n return (\n <Input\n shouldRemainPlaceholder={shouldRemainPlaceholder}\n shouldShowOnlyBottomBorder={shouldShowOnlyBottomBorder}\n inputMode=\"decimal\"\n onChange={onLocalChange}\n value={hasFocus ? plainText : formattedValue}\n placeholder={localPlaceholder}\n onBlur={onLocalBlur}\n onFocus={onLocalFocus}\n isDisabled={isDisabled}\n isInvalid={typeof isInvalid === 'boolean' ? isInvalid : isValueInvalid}\n shouldShowCenteredContent={shouldShowOnlyBottomBorder}\n />\n );\n};\n\nNumberInput.displayName = 'NumberInput';\n\nexport default NumberInput;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAmC,SAAA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,CAAC,CAACK,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC5D;EACJ,CAAC,EAAE,CAAClC,KAAK,CAAC,CAAC;EAEX,oBACIjC,MAAA,CAAAS,OAAA,CAAA2E,aAAA,CAAC/E,MAAA,CAAAI,OAAK;IACFuC,uBAAuB,EAAEA,uBAAwB;IACjDT,0BAA0B,EAAEA,0BAA2B;IACvD8C,SAAS,EAAC,SAAS;IACnB/C,QAAQ,EAAEkB,aAAc;IACxBvB,KAAK,EAAEa,QAAQ,GAAGL,SAAS,GAAGG,cAAe;IAC7CT,WAAW,EAAEiB,gBAAiB;IAC9BhB,MAAM,EAAEoC,WAAY;IACpBc,OAAO,EAAEJ,YAAa;IACtB7C,UAAU,EAAEA,UAAW;IACvBP,SAAS,EAAE,OAAOA,SAAS,KAAK,SAAS,GAAGA,SAAS,GAAGoB,cAAe;IACvEqC,yBAAyB,EAAEhD;EAA2B,CACzD,CAAC;AAEV,CAAC;AAEDb,WAAW,CAAC8D,WAAW,GAAG,aAAa;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAjF,OAAA,GAEzBiB,WAAW","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"NumberInput.js","names":["_react","_interopRequireWildcard","require","_numberInput","_numberInput2","_Input","_interopRequireDefault","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","NumberInput","t0","$","_reactCompilerRuntime","c","isDecimalInput","isMoneyInput","isTimeInput","isInvalid","maxNumber","t1","value","shouldTriggerChangeOnFormat","t2","placeholder","onBlur","isDisabled","onChange","shouldShowOnlyBottomBorder","minNumber","t3","undefined","Infinity","plainText","setPlainText","useState","formattedValue","setFormattedValue","hasFocus","setHasFocus","shouldRemainPlaceholder","setShouldRemainPlaceholder","isValueInvalid","setIsValueInvalid","localPlaceholder","initialInputRef","useRef","t4","event","newValue","target","current","sanitizedValueString","replace","NUMBER_CLEAR_REGEX","includes","length","valueToCheck","replaceAll","isValidString","string","Number","match","onLocalChange","t5","sanitizedValue","newIsInvalid","parsedNumber","parseFloatWithDecimals","stringValue","decimals","newStringValue","formateNumber","number","onLocalBlur","t6","onLocalFocus","t7","t8","parsedNumber_0","useEffect","t10","t9","t11","t12","t13","createElement","inputMode","displayName","_default","exports"],"sources":["../../../../src/components/number-input/NumberInput.tsx"],"sourcesContent":["import React, { ChangeEventHandler, FC, useEffect, useRef, useState } from 'react';\nimport { NUMBER_CLEAR_REGEX } from '../../constants/numberInput';\nimport { formateNumber, isValidString, parseFloatWithDecimals } from '../../utils/numberInput';\nimport Input from '../input/Input';\n\nexport type NumberInputProps = {\n /**\n * Applies rules for decimal input.\n * Enables the user to input one zero as number before the comma\n */\n isDecimalInput?: boolean;\n /**\n * Whether the input is disabled\n */\n isDisabled?: boolean;\n /**\n * Whether the value is invalid.\n */\n isInvalid?: boolean;\n /**\n * Applies rules for money input.\n * Rules: only two decimal places, one zero before the comma\n */\n isMoneyInput?: boolean;\n /**\n * Whether the value should be formatted as a time.\n */\n isTimeInput?: boolean;\n /**\n * Limits the number to this value\n */\n maxNumber?: number;\n /**\n * Limits the number to this value\n */\n minNumber?: number;\n /**\n * Callback function that is called when the input gets out of focus\n */\n onBlur?: (newNumber: number | string | null, isInvalid: boolean) => void;\n /**\n * Callback function that is called when the input changes\n * It will pass the text from the input\n */\n onChange?: (newValue: string) => void;\n /**\n * Placeholder for the input field\n */\n placeholder?: string;\n /**\n * Whether only the bottom border should be displayed\n */\n shouldShowOnlyBottomBorder?: boolean;\n /**\n * Whether the onChange function should be triggert when the value is formatted on the focus or blur\n */\n shouldTriggerChangeOnFormat?: boolean;\n /**\n * The value, that should be displayed in the input, when it is in focus.\n * You can also pass a stringified number as default value.\n * NOTE: If you pass a stringified number, it will be formatted to the selected format\n */\n value?: string;\n};\n\nconst NumberInput: FC<NumberInputProps> = ({\n isDecimalInput,\n isMoneyInput,\n isTimeInput,\n isInvalid,\n maxNumber = Infinity,\n value,\n shouldTriggerChangeOnFormat = true,\n placeholder,\n onBlur,\n isDisabled,\n onChange,\n shouldShowOnlyBottomBorder,\n minNumber = -Infinity,\n}) => {\n 'use memo';\n\n // the plainText will be shown in the input, when it is in focus\n const [plainText, setPlainText] = useState<string>('');\n // the formattedValue will be shown in the input, when it is not in focus\n const [formattedValue, setFormattedValue] = useState<string>('');\n const [hasFocus, setHasFocus] = useState<boolean>(false);\n const [shouldRemainPlaceholder, setShouldRemainPlaceholder] = useState<boolean>(false);\n\n const [isValueInvalid, setIsValueInvalid] = useState(false);\n const localPlaceholder = placeholder ?? (isMoneyInput ? '€' : undefined);\n\n const initialInputRef = useRef(true);\n\n const onLocalChange: ChangeEventHandler<HTMLInputElement> = (event) => {\n const newValue = event.target.value;\n\n initialInputRef.current = false;\n\n const sanitizedValueString = newValue\n // Removes everything except numbers, commas and points\n .replace(NUMBER_CLEAR_REGEX, '');\n\n if (\n isTimeInput &&\n ((sanitizedValueString.includes(':') && sanitizedValueString.length > 5) ||\n (!sanitizedValueString.includes(':') && sanitizedValueString.length > 4))\n ) {\n return;\n }\n\n const valueToCheck = sanitizedValueString.replaceAll(',', '.');\n\n if (!isValidString({ string: valueToCheck, isMoneyInput, isDecimalInput, isTimeInput })) {\n return;\n }\n\n if (\n (maxNumber && Number(valueToCheck) > maxNumber) ||\n (minNumber && Number(valueToCheck) < minNumber)\n ) {\n return;\n }\n\n if (newValue.length === 1 && newValue.match(/^[0-9]+$/) === null) {\n setShouldRemainPlaceholder(true);\n } else {\n setShouldRemainPlaceholder(false);\n }\n\n setPlainText(sanitizedValueString.replaceAll('.', ','));\n\n if (typeof onChange === 'function') {\n onChange(sanitizedValueString.replaceAll('.', ','));\n }\n };\n\n const onLocalBlur = () => {\n const sanitizedValue = plainText;\n let newIsInvalid = false;\n let parsedNumber = null;\n\n if (!isTimeInput) {\n parsedNumber = parseFloatWithDecimals({\n stringValue: sanitizedValue.replace(',', '.').replaceAll(':', '').replace('€', ''),\n decimals: isMoneyInput ? 2 : undefined,\n });\n\n if (\n parsedNumber &&\n parsedNumber !== 0 &&\n (parsedNumber > maxNumber || parsedNumber < minNumber)\n ) {\n newIsInvalid = true;\n }\n\n setIsValueInvalid(newIsInvalid);\n }\n\n const newStringValue =\n plainText.length === 0\n ? ''\n : formateNumber({\n number: isTimeInput ? sanitizedValue : parsedNumber,\n isMoneyInput,\n isTimeInput,\n });\n\n setFormattedValue(`${newStringValue} ${isMoneyInput ? '€' : ''}`);\n setPlainText(newStringValue.replaceAll('.', ''));\n setHasFocus(false);\n\n if (typeof onChange === 'function' && shouldTriggerChangeOnFormat) {\n onChange(newStringValue.replaceAll('.', ''));\n }\n\n if (typeof onBlur === 'function') {\n if (isTimeInput) {\n onBlur(newStringValue, newIsInvalid);\n } else {\n onBlur(parsedNumber, newIsInvalid);\n }\n }\n };\n\n const onLocalFocus = () => {\n // formattedValue will be a number string with german number format (e.g. 1.000,00)\n // It will remove all dots, so that the user can type in the number\n setPlainText(formattedValue.replaceAll('.', '').replace('€', '').replaceAll(' ', ''));\n\n // This will update the external state\n if (typeof onChange === 'function' && shouldTriggerChangeOnFormat) {\n onChange(formattedValue.replaceAll('.', '').replace('€', '').replaceAll(' ', ''));\n }\n\n setIsValueInvalid(false);\n setHasFocus(true);\n };\n\n // updates the formattedValue, when the value changes\n useEffect(() => {\n let parsedNumber = null;\n\n if (!isTimeInput) {\n parsedNumber = parseFloatWithDecimals({\n stringValue: plainText\n .replace(',', '.')\n .replaceAll(':', '')\n .replace('€', '')\n .replaceAll(' ', ''),\n decimals: isMoneyInput ? 2 : undefined,\n });\n\n // checks, if a given number is invalid, if the input is not in focus\n if (!hasFocus) {\n if (parsedNumber === null && initialInputRef.current) {\n setIsValueInvalid(false);\n } else {\n setIsValueInvalid(\n parsedNumber === null ||\n parsedNumber > maxNumber ||\n parsedNumber < minNumber,\n );\n }\n }\n }\n\n setFormattedValue(\n plainText.length === 0\n ? ''\n : `${formateNumber({\n number: isTimeInput ? plainText : parsedNumber,\n isMoneyInput,\n isTimeInput,\n })}${isMoneyInput ? ' €' : ''}`,\n );\n }, [hasFocus, isMoneyInput, isTimeInput, maxNumber, minNumber, plainText]);\n\n useEffect(() => {\n if (typeof value === 'string') {\n setPlainText(value.replace('€', '').replaceAll(' ', ''));\n }\n }, [value]);\n\n return (\n <Input\n shouldRemainPlaceholder={shouldRemainPlaceholder}\n shouldShowOnlyBottomBorder={shouldShowOnlyBottomBorder}\n inputMode=\"decimal\"\n onChange={onLocalChange}\n value={hasFocus ? plainText : formattedValue}\n placeholder={localPlaceholder}\n onBlur={onLocalBlur}\n onFocus={onLocalFocus}\n isDisabled={isDisabled}\n isInvalid={typeof isInvalid === 'boolean' ? isInvalid : isValueInvalid}\n shouldShowCenteredContent={shouldShowOnlyBottomBorder}\n />\n );\n};\n\nNumberInput.displayName = 'NumberInput';\n\nexport default NumberInput;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAmC,SAAAI,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAV,uBAAA,YAAAA,CAAAM,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD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F,aAAA,CAACjG,MAAA,CAAAI,OAAK;MACuB+C,uBAAuB,EAAvBA,uBAAuB;MACpBZ,0BAA0B,EAA1BA,0BAA0B;MAC5C2D,SAAS,EAAT,SAAS;MACTxB,QAAa,EAAbA,aAAa;MAChB1C,KAAqC,EAArC8D,GAAqC;MAC/BvC,WAAgB,EAAhBA,gBAAgB;MACrB8B,MAAW,EAAXA,WAAW;MACVE,OAAY,EAAZA,YAAY;MACTlD,UAAU,EAAVA,UAAU;MACXR,SAA2D,EAA3DkE,GAA2D;MAC3CxD,yBAA0B,EAA1BA;IAA0B,CACxD,CAAC;IAAAhB,CAAA,OAAAc,UAAA;IAAAd,CAAA,OAAAgC,gBAAA;IAAAhC,CAAA,OAAA8D,WAAA;IAAA9D,CAAA,OAAAmD,aAAA;IAAAnD,CAAA,OAAAgE,YAAA;IAAAhE,CAAA,OAAA4B,uBAAA;IAAA5B,CAAA,OAAAgB,0BAAA;IAAAhB,CAAA,OAAAuE,GAAA;IAAAvE,CAAA,OAAAwE,GAAA;IAAAxE,CAAA,OAAAyE,GAAA;EAAA;IAAAA,GAAA,GAAAzE,CAAA;EAAA;EAAA,OAZFyE,GAYE;AAAA,CAET;AAED3E,WAAW,CAAC8E,WAAW,GAAG,aAAa;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAjG,OAAA,GAEzBiB,WAAW","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numberInput.js","names":["_numberInput","require","parseFloatWithDecimals","stringValue","decimals","parsed","parseFloat","toFixed","exports","formateNumber","number","isMoneyInput","isTimeInput","hours","minutes","firstTwoDigits","substring","includes","replace","firstTwoNumbers","
|
|
1
|
+
{"version":3,"file":"numberInput.js","names":["_numberInput","require","parseFloatWithDecimals","stringValue","decimals","parsed","parseFloat","toFixed","exports","formateNumber","number","isMoneyInput","isTimeInput","Number","isNaN","hours","minutes","firstTwoDigits","substring","includes","replace","firstTwoNumbers","lastTwoNumbers","lastTwoNumbersLength","length","hoursStr","minutesStr","toLocaleString","useGrouping","minimumFractionDigits","undefined","maximumFractionDigits","maximumSignificantDigits","isValidString","isDecimalInput","string","isValid","DECIMAL_TEST","test","MONEY_TEST","TIME_TEST","INTEGER_TEST","startsWith"],"sources":["../../../src/utils/numberInput.ts"],"sourcesContent":["import { DECIMAL_TEST, INTEGER_TEST, MONEY_TEST, TIME_TEST } from '../constants/numberInput';\n\ninterface ParseFloatWithDecimals {\n ({ stringValue, decimals }: { stringValue: string; decimals?: number }): number | null;\n}\n\nexport const parseFloatWithDecimals: ParseFloatWithDecimals = ({ stringValue, decimals }) => {\n if (stringValue === '') {\n return null;\n }\n\n const parsed = parseFloat(stringValue);\n\n if (decimals) {\n return parseFloat(parsed.toFixed(decimals));\n }\n\n return parsed;\n};\n\ninterface FormateNumberOptions {\n number: number | string | null;\n isMoneyInput?: boolean;\n isTimeInput?: boolean;\n}\n\nexport const formateNumber = ({ number, isMoneyInput, isTimeInput }: FormateNumberOptions) => {\n if (Number.isNaN(number)) return '';\n if (isTimeInput && typeof number === 'string') {\n let hours = 0;\n let minutes = 0;\n\n let firstTwoDigits = number.substring(0, 2);\n\n if (firstTwoDigits.includes(':')) {\n firstTwoDigits = firstTwoDigits.replace(':', '');\n\n firstTwoDigits = `0${firstTwoDigits}`;\n }\n\n const firstTwoNumbers = Number(firstTwoDigits);\n let lastTwoNumbers = 0;\n let lastTwoNumbersLength = 0;\n\n if (number.includes(':')) {\n lastTwoNumbers = Number(number.substring(3, 5));\n lastTwoNumbersLength = number.substring(3, 5).length;\n } else {\n lastTwoNumbers = Number(number.substring(2, 4));\n lastTwoNumbersLength = number.substring(2, 4).length;\n }\n\n hours = firstTwoNumbers > 23 ? 23 : firstTwoNumbers;\n\n if (lastTwoNumbers < 7 && lastTwoNumbersLength === 1) {\n minutes = lastTwoNumbers * 10;\n } else {\n minutes = lastTwoNumbers > 59 ? 59 : lastTwoNumbers;\n }\n\n const hoursStr = hours < 10 ? `0${hours}` : `${hours}`;\n const minutesStr = minutes < 10 ? `0${minutes}` : `${minutes}`;\n\n return `${hoursStr}:${minutesStr}`;\n }\n\n if (typeof number !== 'number') {\n return '';\n }\n\n return number.toLocaleString('de-DE', {\n useGrouping: true,\n minimumFractionDigits: isMoneyInput ? 2 : undefined,\n maximumFractionDigits: isMoneyInput ? 2 : undefined,\n maximumSignificantDigits: !isMoneyInput ? 20 : undefined,\n });\n};\n\ninterface IsValidString {\n (config: {\n string: string;\n isDecimalInput?: boolean;\n isMoneyInput?: boolean;\n isTimeInput?: boolean;\n }): boolean;\n}\n\nexport const isValidString: IsValidString = ({\n isDecimalInput,\n isMoneyInput,\n isTimeInput,\n string,\n}) => {\n let isValid = false;\n\n // Allows numbers, one (comma/point) and any number of decimal places\n if (isDecimalInput && DECIMAL_TEST.test(string)) {\n isValid = true;\n }\n\n // Allows numbers but excludes numbers with leading 0\n if (isMoneyInput && MONEY_TEST.test(string)) {\n isValid = true;\n }\n\n if (isTimeInput && TIME_TEST) {\n isValid = true;\n }\n\n // Allows numbers but excludes numbers with leading 0\n if (!isDecimalInput && !isMoneyInput && !isTimeInput && INTEGER_TEST.test(string)) {\n isValid = true;\n }\n\n if (string.length === 0) {\n isValid = true;\n }\n\n if (string.startsWith('0')) {\n isValid = true;\n }\n\n return isValid;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMO,MAAMC,sBAA8C,GAAGA,CAAC;EAAEC,WAAW;EAAEC;AAAS,CAAC,KAAK;EACzF,IAAID,WAAW,KAAK,EAAE,EAAE;IACpB,OAAO,IAAI;EACf;EAEA,MAAME,MAAM,GAAGC,UAAU,CAACH,WAAW,CAAC;EAEtC,IAAIC,QAAQ,EAAE;IACV,OAAOE,UAAU,CAACD,MAAM,CAACE,OAAO,CAACH,QAAQ,CAAC,CAAC;EAC/C;EAEA,OAAOC,MAAM;AACjB,CAAC;AAACG,OAAA,CAAAN,sBAAA,GAAAA,sBAAA;AAQK,MAAMO,aAAa,GAAG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E;IAC/EC,OAAO,GAAG,IAAI;EAClB;EAEA,IAAID,MAAM,CAACX,MAAM,KAAK,CAAC,EAAE;IACrBY,OAAO,GAAG,IAAI;EAClB;EAEA,IAAID,MAAM,CAACO,UAAU,CAAC,GAAG,CAAC,EAAE;IACxBN,OAAO,GAAG,IAAI;EAClB;EAEA,OAAOA,OAAO;AAClB,CAAC;AAAC5B,OAAA,CAAAyB,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useSite } from 'chayns-api';
|
|
1
|
+
import { useDevice, useSite } from 'chayns-api';
|
|
2
2
|
import React, { createContext, useContext, useMemo } from 'react';
|
|
3
3
|
import { createGlobalStyle, ThemeProvider } from 'styled-components';
|
|
4
4
|
import { StyledColorSchemeProvider } from './ColorSchemeProvider.styles';
|
|
@@ -38,6 +38,9 @@ const ColorSchemeProvider = ({
|
|
|
38
38
|
color: internalColor,
|
|
39
39
|
colorMode: internalColorMode
|
|
40
40
|
} = useSite();
|
|
41
|
+
const {
|
|
42
|
+
browser
|
|
43
|
+
} = useDevice();
|
|
41
44
|
const color = colorProp ?? context?.designSettings?.color ?? internalColor;
|
|
42
45
|
const colorMode = colorModeProp ?? context?.designSettings?.colorMode ?? internalColorMode;
|
|
43
46
|
const overrideParagraphFormat = color && color !== internalColor || colorMode !== internalColorMode;
|
|
@@ -58,7 +61,8 @@ const ColorSchemeProvider = ({
|
|
|
58
61
|
value: contextValue
|
|
59
62
|
}, /*#__PURE__*/React.createElement(StyledColorSchemeProvider, {
|
|
60
63
|
className: "color-scheme-provider",
|
|
61
|
-
style: style
|
|
64
|
+
style: style,
|
|
65
|
+
$browser: browser?.name
|
|
62
66
|
}, children), /*#__PURE__*/React.createElement(GlobalStyle, null)));
|
|
63
67
|
};
|
|
64
68
|
ColorSchemeProvider.displayName = 'ColorSchemeProvider';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorSchemeProvider.js","names":["useSite","React","createContext","useContext","useMemo","createGlobalStyle","ThemeProvider","StyledColorSchemeProvider","useChaynsTheme","GlobalStyle","ColorSchemeContext","undefined","useColorScheme","ColorSchemeProvider","children","color","colorProp","colorMode","colorModeProp","secondaryColor","siteId","style","iconColor","customVariables","context","internalColor","internalColorMode","designSettings","overrideParagraphFormat","paragraphFormat","contextValue","createElement","theme","Provider","value","className","displayName"],"sources":["../../../../src/components/color-scheme-provider/ColorSchemeProvider.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"ColorSchemeProvider.js","names":["useDevice","useSite","React","createContext","useContext","useMemo","createGlobalStyle","ThemeProvider","StyledColorSchemeProvider","useChaynsTheme","GlobalStyle","ColorSchemeContext","undefined","useColorScheme","ColorSchemeProvider","children","color","colorProp","colorMode","colorModeProp","secondaryColor","siteId","style","iconColor","customVariables","context","internalColor","internalColorMode","browser","designSettings","overrideParagraphFormat","paragraphFormat","contextValue","createElement","theme","Provider","value","className","$browser","name","displayName"],"sources":["../../../../src/components/color-scheme-provider/ColorSchemeProvider.tsx"],"sourcesContent":["import {\n ChaynsDesignSettings,\n ChaynsParagraphFormat,\n ColorMode,\n useDevice,\n useSite,\n} from 'chayns-api';\nimport React, { createContext, FC, ReactNode, useContext, useMemo } from 'react';\nimport { createGlobalStyle, ThemeProvider } from 'styled-components';\nimport { StyledColorSchemeProvider } from './ColorSchemeProvider.styles';\nimport { useChaynsTheme } from './hooks/useChaynsTheme';\nimport { BrowserName } from '../../types/chayns';\n\nexport type ColorSchemeProviderProps = {\n /**\n * The content of the application or the components for which the styles should be set\n */\n children: ReactNode;\n /**\n * The hex color to be used for the children\n */\n color?: string;\n /**\n * The color mode to be used for the children\n */\n colorMode?: ColorMode;\n /**\n * The secondary hex color to be used for the children\n */\n secondaryColor?: string;\n /**\n * The site id of the page for which the design settings should be fetched\n */\n siteId?: string;\n /**\n * Additional styles set on the root element\n */\n style?: { [key: string]: string | number };\n /**\n * Additional variables to extend the theme\n */\n customVariables?: Record<string, string>;\n /**\n * An optional color for all icons\n */\n iconColor?: string;\n};\n\nexport interface Theme {\n [key: string]: string;\n}\n\nexport type WithTheme<T> = T & {\n theme: Theme;\n};\n\nconst GlobalStyle = createGlobalStyle`\n .ellipsis {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n footer {\n font-size: 0.85rem;\n color: #888;\n margin: 10px 0 0;\n\n & a {\n color: #888;\n letter-spacing: -0.3px;\n }\n }\n`;\n\nexport interface ColorSchemeContextProps {\n designSettings?: ChaynsDesignSettings;\n paragraphFormat: ChaynsParagraphFormat[];\n theme: Theme;\n}\n\nexport const ColorSchemeContext = createContext<ColorSchemeContextProps | undefined>(undefined);\n\nexport const useColorScheme = () => useContext(ColorSchemeContext);\n\nconst ColorSchemeProvider: FC<ColorSchemeProviderProps> = ({\n children,\n color: colorProp,\n colorMode: colorModeProp,\n secondaryColor,\n siteId,\n style = {},\n iconColor,\n customVariables,\n}) => {\n const context = useContext(ColorSchemeContext);\n\n const { color: internalColor, colorMode: internalColorMode } = useSite();\n\n const { browser } = useDevice();\n\n const color = colorProp ?? context?.designSettings?.color ?? internalColor;\n const colorMode = colorModeProp ?? context?.designSettings?.colorMode ?? internalColorMode;\n\n const overrideParagraphFormat =\n (color && color !== internalColor) || colorMode !== internalColorMode;\n\n const paragraphFormat = useMemo(\n () => (overrideParagraphFormat ? [] : undefined),\n [overrideParagraphFormat],\n );\n\n const contextValue = useChaynsTheme({\n color,\n iconColor,\n colorMode,\n secondaryColor,\n siteId,\n customVariables,\n // Overrides the paragraphFormat on changed color or colorMode\n paragraphFormat,\n });\n\n return (\n <ThemeProvider theme={contextValue.theme}>\n <ColorSchemeContext.Provider value={contextValue}>\n <StyledColorSchemeProvider\n className=\"color-scheme-provider\"\n style={style}\n $browser={browser?.name as BrowserName}\n >\n {children}\n </StyledColorSchemeProvider>\n <GlobalStyle />\n </ColorSchemeContext.Provider>\n </ThemeProvider>\n );\n};\n\nColorSchemeProvider.displayName = 'ColorSchem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GAAG1B,OAAO,CAC3B,MAAOyB,uBAAuB,GAAG,EAAE,GAAGlB,SAAU,EAChD,CAACkB,uBAAuB,CAC5B,CAAC;EAED,MAAME,YAAY,GAAGvB,cAAc,CAAC;IAChCO,KAAK;IACLO,SAAS;IACTL,SAAS;IACTE,cAAc;IACdC,MAAM;IACNG,eAAe;IACf;IACAO;EACJ,CAAC,CAAC;EAEF,oBACI7B,KAAA,CAAA+B,aAAA,CAAC1B,aAAa;IAAC2B,KAAK,EAAEF,YAAY,CAACE;EAAM,gBACrChC,KAAA,CAAA+B,aAAA,CAACtB,kBAAkB,CAACwB,QAAQ;IAACC,KAAK,EAAEJ;EAAa,gBAC7C9B,KAAA,CAAA+B,aAAA,CAACzB,yBAAyB;IACtB6B,SAAS,EAAC,uBAAuB;IACjCf,KAAK,EAAEA,KAAM;IACbgB,QAAQ,EAAEV,OAAO,EAAEW;EAAoB,GAEtCxB,QACsB,CAAC,eAC5Bb,KAAA,CAAA+B,aAAA,CAACvB,WAAW,MAAE,CACW,CAClB,CAAC;AAExB,CAAC;AAEDI,mBAAmB,CAAC0B,WAAW,GAAG,qBAAqB;AAEvD,eAAe1B,mBAAmB","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getAvailableColorList } from '@chayns/colors';
|
|
2
|
-
import { styled } from 'styled-components';
|
|
2
|
+
import { css, styled } from 'styled-components';
|
|
3
3
|
// noinspection CssUnresolvedCustomProperty
|
|
4
4
|
export const StyledColorSchemeProvider = styled.div`
|
|
5
5
|
color: var(--chayns-color--text);
|
|
@@ -21,5 +21,42 @@ export const StyledColorSchemeProvider = styled.div`
|
|
|
21
21
|
.color-scheme-provider :is(h1,.h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6):first-child {
|
|
22
22
|
margin-top: 0;
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
// Styles for custom scrollbar
|
|
26
|
+
.chayns-scrollbar {
|
|
27
|
+
${({
|
|
28
|
+
$browser,
|
|
29
|
+
theme
|
|
30
|
+
}) => $browser === 'firefox' ? css`
|
|
31
|
+
scrollbar-color: rgba(${theme['text-rgb']}, 0.15) transparent;
|
|
32
|
+
scrollbar-width: thin;
|
|
33
|
+
` : css`
|
|
34
|
+
&::-webkit-scrollbar {
|
|
35
|
+
width: 10px;
|
|
36
|
+
height: 10px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&::-webkit-scrollbar-track {
|
|
40
|
+
background-color: transparent;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&::-webkit-scrollbar-button {
|
|
44
|
+
background-color: transparent;
|
|
45
|
+
height: 5px;
|
|
46
|
+
width: 5px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&::-webkit-scrollbar-thumb {
|
|
50
|
+
background-color: rgba(${theme['text-rgb']}, 0.15);
|
|
51
|
+
border-radius: 20px;
|
|
52
|
+
background-clip: padding-box;
|
|
53
|
+
border: solid 3px transparent;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&::-webkit-scrollbar-corner {
|
|
57
|
+
background-color: transparent;
|
|
58
|
+
}
|
|
59
|
+
`}
|
|
60
|
+
}
|
|
24
61
|
`;
|
|
25
62
|
//# sourceMappingURL=ColorSchemeProvider.styles.js.map
|