@chayns-components/core 5.0.21 → 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.
Files changed (42) hide show
  1. package/lib/cjs/components/color-scheme-provider/ColorSchemeProvider.js +5 -1
  2. package/lib/cjs/components/color-scheme-provider/ColorSchemeProvider.js.map +1 -1
  3. package/lib/cjs/components/color-scheme-provider/ColorSchemeProvider.styles.js +37 -0
  4. package/lib/cjs/components/color-scheme-provider/ColorSchemeProvider.styles.js.map +1 -1
  5. package/lib/cjs/components/grouped-image/GroupedImage.styles.js +18 -20
  6. package/lib/cjs/components/grouped-image/GroupedImage.styles.js.map +1 -1
  7. package/lib/cjs/components/list/List.js +97 -37
  8. package/lib/cjs/components/list/List.js.map +1 -1
  9. package/lib/cjs/components/list/list-item/ListItem.js +0 -9
  10. package/lib/cjs/components/list/list-item/ListItem.js.map +1 -1
  11. package/lib/cjs/components/number-input/NumberInput.js +213 -132
  12. package/lib/cjs/components/number-input/NumberInput.js.map +1 -1
  13. package/lib/cjs/components/progress-bar/ProgressBar.js +181 -66
  14. package/lib/cjs/components/progress-bar/ProgressBar.js.map +1 -1
  15. package/lib/cjs/components/progress-bar/ProgressBar.styles.js +36 -1
  16. package/lib/cjs/components/progress-bar/ProgressBar.styles.js.map +1 -1
  17. package/lib/cjs/utils/numberInput.js +1 -0
  18. package/lib/cjs/utils/numberInput.js.map +1 -1
  19. package/lib/esm/components/color-scheme-provider/ColorSchemeProvider.js +6 -2
  20. package/lib/esm/components/color-scheme-provider/ColorSchemeProvider.js.map +1 -1
  21. package/lib/esm/components/color-scheme-provider/ColorSchemeProvider.styles.js +38 -1
  22. package/lib/esm/components/color-scheme-provider/ColorSchemeProvider.styles.js.map +1 -1
  23. package/lib/esm/components/grouped-image/GroupedImage.styles.js +18 -20
  24. package/lib/esm/components/grouped-image/GroupedImage.styles.js.map +1 -1
  25. package/lib/esm/components/list/List.js +97 -37
  26. package/lib/esm/components/list/List.js.map +1 -1
  27. package/lib/esm/components/list/list-item/ListItem.js +0 -9
  28. package/lib/esm/components/list/list-item/ListItem.js.map +1 -1
  29. package/lib/esm/components/number-input/NumberInput.js +213 -132
  30. package/lib/esm/components/number-input/NumberInput.js.map +1 -1
  31. package/lib/esm/components/progress-bar/ProgressBar.js +173 -68
  32. package/lib/esm/components/progress-bar/ProgressBar.js.map +1 -1
  33. package/lib/esm/components/progress-bar/ProgressBar.styles.js +36 -1
  34. package/lib/esm/components/progress-bar/ProgressBar.styles.js.map +1 -1
  35. package/lib/esm/utils/numberInput.js +1 -0
  36. package/lib/esm/utils/numberInput.js.map +1 -1
  37. package/lib/types/components/color-scheme-provider/ColorSchemeProvider.styles.d.ts +7 -3
  38. package/lib/types/components/grouped-image/GroupedImage.styles.d.ts +3 -1
  39. package/lib/types/components/list/List.d.ts +0 -1
  40. package/lib/types/components/progress-bar/ProgressBar.d.ts +9 -1
  41. package/lib/types/components/progress-bar/ProgressBar.styles.d.ts +7 -0
  42. package/package.json +2 -2
@@ -1,150 +1,231 @@
1
+ import { c as _c } from "react-compiler-runtime";
1
2
  import React, { useEffect, useRef, useState } from 'react';
2
3
  import { NUMBER_CLEAR_REGEX } from '../../constants/numberInput';
3
4
  import { formateNumber, isValidString, parseFloatWithDecimals } from '../../utils/numberInput';
4
5
  import Input from '../input/Input';
5
- const NumberInput = ({
6
- isDecimalInput,
7
- isMoneyInput,
8
- isTimeInput,
9
- isInvalid,
10
- maxNumber = Infinity,
11
- value,
12
- shouldTriggerChangeOnFormat = true,
13
- placeholder,
14
- onBlur,
15
- isDisabled,
16
- onChange,
17
- shouldShowOnlyBottomBorder,
18
- minNumber = -Infinity
19
- }) => {
20
- // the plainText will be shown in the input, when it is in focus
21
- const [plainText, setPlainText] = useState('');
22
- // the formattedValue will be shown in the input, when it is not in focus
23
- const [formattedValue, setFormattedValue] = useState('');
6
+ const NumberInput = t0 => {
7
+ "use memo";
8
+
9
+ const $ = _c(41);
10
+ const {
11
+ isDecimalInput,
12
+ isMoneyInput,
13
+ isTimeInput,
14
+ isInvalid,
15
+ maxNumber: t1,
16
+ value,
17
+ shouldTriggerChangeOnFormat: t2,
18
+ placeholder,
19
+ onBlur,
20
+ isDisabled,
21
+ onChange,
22
+ shouldShowOnlyBottomBorder,
23
+ minNumber: t3
24
+ } = t0;
25
+ const maxNumber = t1 === undefined ? Infinity : t1;
26
+ const shouldTriggerChangeOnFormat = t2 === undefined ? true : t2;
27
+ const minNumber = t3 === undefined ? -Infinity : t3;
28
+ const [plainText, setPlainText] = useState("");
29
+ const [formattedValue, setFormattedValue] = useState("");
24
30
  const [hasFocus, setHasFocus] = useState(false);
25
31
  const [shouldRemainPlaceholder, setShouldRemainPlaceholder] = useState(false);
26
32
  const [isValueInvalid, setIsValueInvalid] = useState(false);
27
- const localPlaceholder = placeholder ?? (isMoneyInput ? '€' : undefined);
33
+ const localPlaceholder = placeholder ?? (isMoneyInput ? "\u20AC" : undefined);
28
34
  const initialInputRef = useRef(true);
29
- const onLocalChange = event => {
30
- const newValue = event.target.value;
31
- initialInputRef.current = false;
32
- const sanitizedValueString = newValue
33
- // Removes everything except numbers, commas and points
34
- .replace(NUMBER_CLEAR_REGEX, '');
35
- if (isTimeInput && (sanitizedValueString.includes(':') && sanitizedValueString.length > 5 || !sanitizedValueString.includes(':') && sanitizedValueString.length > 4)) {
36
- return;
37
- }
38
- const valueToCheck = sanitizedValueString.replaceAll(',', '.');
39
- if (!isValidString({
40
- string: valueToCheck,
41
- isMoneyInput,
42
- isDecimalInput,
43
- isTimeInput
44
- })) {
45
- return;
46
- }
47
- if (maxNumber && Number(valueToCheck) > maxNumber || minNumber && Number(valueToCheck) < minNumber) {
48
- return;
49
- }
50
- if (newValue.length === 1 && newValue.match(/^[0-9]+$/) === null) {
51
- setShouldRemainPlaceholder(true);
52
- } else {
53
- setShouldRemainPlaceholder(false);
54
- }
55
- setPlainText(sanitizedValueString.replaceAll('.', ','));
56
- if (typeof onChange === 'function') {
57
- onChange(sanitizedValueString.replaceAll('.', ','));
58
- }
59
- };
60
- const onLocalBlur = () => {
61
- const sanitizedValue = plainText;
62
- let newIsInvalid = false;
63
- let parsedNumber = null;
64
- if (!isTimeInput) {
65
- parsedNumber = parseFloatWithDecimals({
66
- stringValue: sanitizedValue.replace(',', '.').replaceAll(':', '').replace('€', ''),
67
- decimals: isMoneyInput ? 2 : undefined
68
- });
69
- if (parsedNumber && parsedNumber !== 0 && (parsedNumber > maxNumber || parsedNumber < minNumber)) {
70
- newIsInvalid = true;
35
+ let t4;
36
+ if ($[0] !== isDecimalInput || $[1] !== isMoneyInput || $[2] !== isTimeInput || $[3] !== maxNumber || $[4] !== minNumber || $[5] !== onChange) {
37
+ t4 = event => {
38
+ const newValue = event.target.value;
39
+ initialInputRef.current = false;
40
+ const sanitizedValueString = newValue.replace(NUMBER_CLEAR_REGEX, "");
41
+ if (isTimeInput && (sanitizedValueString.includes(":") && sanitizedValueString.length > 5 || !sanitizedValueString.includes(":") && sanitizedValueString.length > 4)) {
42
+ return;
71
43
  }
72
- setIsValueInvalid(newIsInvalid);
73
- }
74
- const newStringValue = plainText.length === 0 ? '' : formateNumber({
75
- number: isTimeInput ? sanitizedValue : parsedNumber,
76
- isMoneyInput,
77
- isTimeInput
78
- });
79
- setFormattedValue(`${newStringValue} ${isMoneyInput ? '€' : ''}`);
80
- setPlainText(newStringValue.replaceAll('.', ''));
81
- setHasFocus(false);
82
- if (typeof onChange === 'function' && shouldTriggerChangeOnFormat) {
83
- onChange(newStringValue.replaceAll('.', ''));
84
- }
85
- if (typeof onBlur === 'function') {
86
- if (isTimeInput) {
87
- onBlur(newStringValue, newIsInvalid);
44
+ const valueToCheck = sanitizedValueString.replaceAll(",", ".");
45
+ if (!isValidString({
46
+ string: valueToCheck,
47
+ isMoneyInput,
48
+ isDecimalInput,
49
+ isTimeInput
50
+ })) {
51
+ return;
52
+ }
53
+ if (maxNumber && Number(valueToCheck) > maxNumber || minNumber && Number(valueToCheck) < minNumber) {
54
+ return;
55
+ }
56
+ if (newValue.length === 1 && newValue.match(/^[0-9]+$/) === null) {
57
+ setShouldRemainPlaceholder(true);
88
58
  } else {
89
- onBlur(parsedNumber, newIsInvalid);
59
+ setShouldRemainPlaceholder(false);
90
60
  }
91
- }
92
- };
93
- const onLocalFocus = () => {
94
- // formattedValue will be a number string with german number format (e.g. 1.000,00)
95
- // It will remove all dots, so that the user can type in the number
96
- setPlainText(formattedValue.replaceAll('.', '').replace('€', '').replaceAll(' ', ''));
97
-
98
- // This will update the external state
99
- if (typeof onChange === 'function' && shouldTriggerChangeOnFormat) {
100
- onChange(formattedValue.replaceAll('.', '').replace('€', '').replaceAll(' ', ''));
101
- }
102
- setIsValueInvalid(false);
103
- setHasFocus(true);
104
- };
105
-
106
- // updates the formattedValue, when the value changes
107
- useEffect(() => {
108
- let parsedNumber = null;
109
- if (!isTimeInput) {
110
- parsedNumber = parseFloatWithDecimals({
111
- stringValue: plainText.replace(',', '.').replaceAll(':', '').replace('€', '').replaceAll(' ', ''),
112
- decimals: isMoneyInput ? 2 : undefined
61
+ setPlainText(sanitizedValueString.replaceAll(".", ","));
62
+ if (typeof onChange === "function") {
63
+ onChange(sanitizedValueString.replaceAll(".", ","));
64
+ }
65
+ };
66
+ $[0] = isDecimalInput;
67
+ $[1] = isMoneyInput;
68
+ $[2] = isTimeInput;
69
+ $[3] = maxNumber;
70
+ $[4] = minNumber;
71
+ $[5] = onChange;
72
+ $[6] = t4;
73
+ } else {
74
+ t4 = $[6];
75
+ }
76
+ const onLocalChange = t4;
77
+ let t5;
78
+ if ($[7] !== isMoneyInput || $[8] !== isTimeInput || $[9] !== maxNumber || $[10] !== minNumber || $[11] !== onBlur || $[12] !== onChange || $[13] !== plainText || $[14] !== shouldTriggerChangeOnFormat) {
79
+ t5 = () => {
80
+ const sanitizedValue = plainText;
81
+ let newIsInvalid = false;
82
+ let parsedNumber = null;
83
+ if (!isTimeInput) {
84
+ parsedNumber = parseFloatWithDecimals({
85
+ stringValue: sanitizedValue.replace(",", ".").replaceAll(":", "").replace("\u20AC", ""),
86
+ decimals: isMoneyInput ? 2 : undefined
87
+ });
88
+ if (parsedNumber && parsedNumber !== 0 && (parsedNumber > maxNumber || parsedNumber < minNumber)) {
89
+ newIsInvalid = true;
90
+ }
91
+ setIsValueInvalid(newIsInvalid);
92
+ }
93
+ const newStringValue = plainText.length === 0 ? "" : formateNumber({
94
+ number: isTimeInput ? sanitizedValue : parsedNumber,
95
+ isMoneyInput,
96
+ isTimeInput
113
97
  });
114
-
115
- // checks, if a given number is invalid, if the input is not in focus
116
- if (!hasFocus) {
117
- if (parsedNumber === null && initialInputRef.current) {
118
- setIsValueInvalid(false);
98
+ setFormattedValue(`${newStringValue} ${isMoneyInput ? "\u20AC" : ""}`);
99
+ setPlainText(newStringValue.replaceAll(".", ""));
100
+ setHasFocus(false);
101
+ if (typeof onChange === "function" && shouldTriggerChangeOnFormat) {
102
+ onChange(newStringValue.replaceAll(".", ""));
103
+ }
104
+ if (typeof onBlur === "function") {
105
+ if (isTimeInput) {
106
+ onBlur(newStringValue, newIsInvalid);
119
107
  } else {
120
- setIsValueInvalid(parsedNumber === null || parsedNumber > maxNumber || parsedNumber < minNumber);
108
+ onBlur(parsedNumber, newIsInvalid);
109
+ }
110
+ }
111
+ };
112
+ $[7] = isMoneyInput;
113
+ $[8] = isTimeInput;
114
+ $[9] = maxNumber;
115
+ $[10] = minNumber;
116
+ $[11] = onBlur;
117
+ $[12] = onChange;
118
+ $[13] = plainText;
119
+ $[14] = shouldTriggerChangeOnFormat;
120
+ $[15] = t5;
121
+ } else {
122
+ t5 = $[15];
123
+ }
124
+ const onLocalBlur = t5;
125
+ let t6;
126
+ if ($[16] !== formattedValue || $[17] !== onChange || $[18] !== shouldTriggerChangeOnFormat) {
127
+ t6 = () => {
128
+ setPlainText(formattedValue.replaceAll(".", "").replace("\u20AC", "").replaceAll(" ", ""));
129
+ if (typeof onChange === "function" && shouldTriggerChangeOnFormat) {
130
+ onChange(formattedValue.replaceAll(".", "").replace("\u20AC", "").replaceAll(" ", ""));
131
+ }
132
+ setIsValueInvalid(false);
133
+ setHasFocus(true);
134
+ };
135
+ $[16] = formattedValue;
136
+ $[17] = onChange;
137
+ $[18] = shouldTriggerChangeOnFormat;
138
+ $[19] = t6;
139
+ } else {
140
+ t6 = $[19];
141
+ }
142
+ const onLocalFocus = t6;
143
+ let t7;
144
+ let t8;
145
+ if ($[20] !== hasFocus || $[21] !== isMoneyInput || $[22] !== isTimeInput || $[23] !== maxNumber || $[24] !== minNumber || $[25] !== plainText) {
146
+ t7 = () => {
147
+ let parsedNumber_0 = null;
148
+ if (!isTimeInput) {
149
+ parsedNumber_0 = parseFloatWithDecimals({
150
+ stringValue: plainText.replace(",", ".").replaceAll(":", "").replace("\u20AC", "").replaceAll(" ", ""),
151
+ decimals: isMoneyInput ? 2 : undefined
152
+ });
153
+ if (!hasFocus) {
154
+ if (parsedNumber_0 === null && initialInputRef.current) {
155
+ setIsValueInvalid(false);
156
+ } else {
157
+ setIsValueInvalid(parsedNumber_0 === null || parsedNumber_0 > maxNumber || parsedNumber_0 < minNumber);
158
+ }
121
159
  }
122
160
  }
123
- }
124
- setFormattedValue(plainText.length === 0 ? '' : `${formateNumber({
125
- number: isTimeInput ? plainText : parsedNumber,
126
- isMoneyInput,
127
- isTimeInput
128
- })}${isMoneyInput ? ' €' : ''}`);
129
- }, [hasFocus, isMoneyInput, isTimeInput, maxNumber, minNumber, plainText]);
130
- useEffect(() => {
131
- if (typeof value === 'string') {
132
- setPlainText(value.replace('€', '').replaceAll(' ', ''));
133
- }
134
- }, [value]);
135
- return /*#__PURE__*/React.createElement(Input, {
136
- shouldRemainPlaceholder: shouldRemainPlaceholder,
137
- shouldShowOnlyBottomBorder: shouldShowOnlyBottomBorder,
138
- inputMode: "decimal",
139
- onChange: onLocalChange,
140
- value: hasFocus ? plainText : formattedValue,
141
- placeholder: localPlaceholder,
142
- onBlur: onLocalBlur,
143
- onFocus: onLocalFocus,
144
- isDisabled: isDisabled,
145
- isInvalid: typeof isInvalid === 'boolean' ? isInvalid : isValueInvalid,
146
- shouldShowCenteredContent: shouldShowOnlyBottomBorder
147
- });
161
+ setFormattedValue(plainText.length === 0 ? "" : `${formateNumber({
162
+ number: isTimeInput ? plainText : parsedNumber_0,
163
+ isMoneyInput,
164
+ isTimeInput
165
+ })}${isMoneyInput ? " \u20AC" : ""}`);
166
+ };
167
+ t8 = [hasFocus, isMoneyInput, isTimeInput, maxNumber, minNumber, plainText];
168
+ $[20] = hasFocus;
169
+ $[21] = isMoneyInput;
170
+ $[22] = isTimeInput;
171
+ $[23] = maxNumber;
172
+ $[24] = minNumber;
173
+ $[25] = plainText;
174
+ $[26] = t7;
175
+ $[27] = t8;
176
+ } else {
177
+ t7 = $[26];
178
+ t8 = $[27];
179
+ }
180
+ useEffect(t7, t8);
181
+ let t10;
182
+ let t9;
183
+ if ($[28] !== value) {
184
+ t9 = () => {
185
+ if (typeof value === "string") {
186
+ setPlainText(value.replace("\u20AC", "").replaceAll(" ", ""));
187
+ }
188
+ };
189
+ t10 = [value];
190
+ $[28] = value;
191
+ $[29] = t10;
192
+ $[30] = t9;
193
+ } else {
194
+ t10 = $[29];
195
+ t9 = $[30];
196
+ }
197
+ useEffect(t9, t10);
198
+ const t11 = hasFocus ? plainText : formattedValue;
199
+ const t12 = typeof isInvalid === "boolean" ? isInvalid : isValueInvalid;
200
+ let t13;
201
+ if ($[31] !== isDisabled || $[32] !== localPlaceholder || $[33] !== onLocalBlur || $[34] !== onLocalChange || $[35] !== onLocalFocus || $[36] !== shouldRemainPlaceholder || $[37] !== shouldShowOnlyBottomBorder || $[38] !== t11 || $[39] !== t12) {
202
+ t13 = /*#__PURE__*/React.createElement(Input, {
203
+ shouldRemainPlaceholder: shouldRemainPlaceholder,
204
+ shouldShowOnlyBottomBorder: shouldShowOnlyBottomBorder,
205
+ inputMode: "decimal",
206
+ onChange: onLocalChange,
207
+ value: t11,
208
+ placeholder: localPlaceholder,
209
+ onBlur: onLocalBlur,
210
+ onFocus: onLocalFocus,
211
+ isDisabled: isDisabled,
212
+ isInvalid: t12,
213
+ shouldShowCenteredContent: shouldShowOnlyBottomBorder
214
+ });
215
+ $[31] = isDisabled;
216
+ $[32] = localPlaceholder;
217
+ $[33] = onLocalBlur;
218
+ $[34] = onLocalChange;
219
+ $[35] = onLocalFocus;
220
+ $[36] = shouldRemainPlaceholder;
221
+ $[37] = shouldShowOnlyBottomBorder;
222
+ $[38] = t11;
223
+ $[39] = t12;
224
+ $[40] = t13;
225
+ } else {
226
+ t13 = $[40];
227
+ }
228
+ return t13;
148
229
  };
149
230
  NumberInput.displayName = 'NumberInput';
150
231
  export default NumberInput;
@@ -1 +1 @@
1
- {"version":3,"file":"NumberInput.js","names":["React","useEffect","useRef","useState","NUMBER_CLEAR_REGEX","formateNumber","isValidString","parseFloatWithDecimals","Input","NumberInput","isDecimalInput","isMoneyInput","isTimeInput","isInvalid","maxNumber","Infinity","value","shouldTriggerChangeOnFormat","placeholder","onBlur","isDisabled","onChange","shouldShowOnlyBottomBorder","minNumber","plainText","setPlainText","formattedValue","setFormattedValue","hasFocus","setHasFocus","shouldRemainPlaceholder","setShouldRemainPlaceholder","isValueInvalid","setIsValueInvalid","localPlaceholder","undefined","initialInputRef","onLocalChange","event","newValue","target","current","sanitizedValueString","replace","includes","length","valueToCheck","replaceAll","string","Number","match","onLocalBlur","sanitizedValue","newIsInvalid","parsedNumber","stringValue","decimals","newStringValue","number","onLocalFocus","createElement","inputMode","onFocus","shouldShowCenteredContent","displayName"],"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 );\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qD,MAAM,EAAE9C,WAAW,GAAGY,SAAS,GAAG8B,YAAY;MAC9C3C,YAAY;MACZC;IACJ,CAAC,CAAC,GAAGD,YAAY,GAAG,IAAI,GAAG,EAAE,EACvC,CAAC;EACL,CAAC,EAAE,CAACiB,QAAQ,EAAEjB,YAAY,EAAEC,WAAW,EAAEE,SAAS,EAAES,SAAS,EAAEC,SAAS,CAAC,CAAC;EAE1EvB,SAAS,CAAC,MAAM;IACZ,IAAI,OAAOe,KAAK,KAAK,QAAQ,EAAE;MAC3BS,YAAY,CAACT,KAAK,CAAC2B,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAACI,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC5D;EACJ,CAAC,EAAE,CAAC/B,KAAK,CAAC,CAAC;EAEX,oBACIhB,KAAA,CAAA4D,aAAA,CAACpD,KAAK;IACFsB,uBAAuB,EAAEA,uBAAwB;IACjDR,0BAA0B,EAAEA,0BAA2B;IACvDuC,SAAS,EAAC,SAAS;IACnBxC,QAAQ,EAAEgB,aAAc;IACxBrB,KAAK,EAAEY,QAAQ,GAAGJ,SAAS,GAAGE,cAAe;IAC7CR,WAAW,EAAEgB,gBAAiB;IAC9Bf,MAAM,EAAEgC,WAAY;IACpBW,OAAO,EAAEH,YAAa;IACtBvC,UAAU,EAAEA,UAAW;IACvBP,SAAS,EAAE,OAAOA,SAAS,KAAK,SAAS,GAAGA,SAAS,GAAGmB,cAAe;IACvE+B,yBAAyB,EAAEzC;EAA2B,CACzD,CAAC;AAEV,CAAC;AAEDb,WAAW,CAACuD,WAAW,GAAG,aAAa;AAEvC,eAAevD,WAAW","ignoreList":[]}
1
+ {"version":3,"file":"NumberInput.js","names":["React","useEffect","useRef","useState","NUMBER_CLEAR_REGEX","formateNumber","isValidString","parseFloatWithDecimals","Input","NumberInput","t0","$","_c","isDecimalInput","isMoneyInput","isTimeInput","isInvalid","maxNumber","t1","value","shouldTriggerChangeOnFormat","t2","placeholder","onBlur","isDisabled","onChange","shouldShowOnlyBottomBorder","minNumber","t3","undefined","Infinity","plainText","setPlainText","formattedValue","setFormattedValue","hasFocus","setHasFocus","shouldRemainPlaceholder","setShouldRemainPlaceholder","isValueInvalid","setIsValueInvalid","localPlaceholder","initialInputRef","t4","event","newValue","target","current","sanitizedValueString","replace","includes","length","valueToCheck","replaceAll","string","Number","match","onLocalChange","t5","sanitizedValue","newIsInvalid","parsedNumber","stringValue","decimals","newStringValue","number","onLocalBlur","t6","onLocalFocus","t7","t8","parsedNumber_0","t10","t9","t11","t12","t13","createElement","inputMode","displayName"],"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,OAAOA,KAAK,IAA4BC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAClF,SAASC,kBAAkB,QAAQ,6BAA6B;AAChE,SAASC,aAAa,EAAEC,aAAa,EAAEC,sBAAsB,QAAQ,yBAAyB;AAC9F,OAAOC,KAAK,MAAM,gBAAgB;AA8DlC,MAAMC,WAAiC,GAAGC,EAAA;EAAA;;EAAA,MAAAC,CAAA,GAAAC,EAAA;EAAC;IAAAC,cAAA;IAAAC,YAAA;IAAAC,WAAA;IAAAC,SAAA;IAAAC,SAAA,EAAAC,EAAA;IAAAC,KAAA;IAAAC,2BAAA,EAAAC,EAAA;IAAAC,WAAA;IAAAC,MAAA;IAAAC,UAAA;IAAAC,QAAA;IAAAC,0BAAA;IAAAC,SAAA,EAAAC;EAAA,IAAAlB,EAc1C;E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