@acusti/css-value-input 1.0.0-rc.16 → 1.0.0-rc.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CSSValueInput.d.ts +1 -3
- package/dist/CSSValueInput.js +151 -224
- package/dist/CSSValueInput.js.map +1 -1
- package/dist/CSSValueInput.test.js +11 -58
- package/package.json +1 -1
- package/src/CSSValueInput.tsx +5 -1
package/dist/CSSValueInput.d.ts
CHANGED
|
@@ -39,7 +39,5 @@ export type Props = {
|
|
|
39
39
|
validator?: RegExp | ((value: string) => boolean);
|
|
40
40
|
value?: string;
|
|
41
41
|
};
|
|
42
|
-
declare const _default: React.ForwardRefExoticComponent<
|
|
43
|
-
Props & React.RefAttributes<HTMLInputElement>
|
|
44
|
-
>;
|
|
42
|
+
declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLInputElement>>;
|
|
45
43
|
export default _default;
|
package/dist/CSSValueInput.js
CHANGED
|
@@ -1,44 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DEFAULT_CSS_VALUE_TYPE,
|
|
3
|
-
DEFAULT_UNIT_BY_CSS_VALUE_TYPE,
|
|
4
|
-
getCSSValueAsNumber,
|
|
5
|
-
getCSSValueWithUnit,
|
|
6
|
-
getUnitFromCSSValue,
|
|
7
|
-
roundToPrecision,
|
|
8
|
-
} from '@acusti/css-values';
|
|
1
|
+
import { DEFAULT_CSS_VALUE_TYPE, DEFAULT_UNIT_BY_CSS_VALUE_TYPE, getCSSValueAsNumber, getCSSValueWithUnit, getUnitFromCSSValue, roundToPrecision, } from '@acusti/css-values';
|
|
9
2
|
import InputText from '@acusti/input-text';
|
|
10
3
|
import clsx from 'clsx';
|
|
11
4
|
import * as React from 'react';
|
|
12
5
|
const { useCallback, useEffect, useImperativeHandle, useRef } = React;
|
|
13
6
|
const ROOT_CLASS_NAME = 'cssvalueinput';
|
|
14
|
-
export default React.forwardRef(function CSSValueInput(
|
|
15
|
-
{
|
|
16
|
-
allowEmpty = true,
|
|
17
|
-
className,
|
|
18
|
-
cssValueType = DEFAULT_CSS_VALUE_TYPE,
|
|
19
|
-
disabled,
|
|
20
|
-
getValueAsNumber = getCSSValueAsNumber,
|
|
21
|
-
icon,
|
|
22
|
-
label,
|
|
23
|
-
max,
|
|
24
|
-
min,
|
|
25
|
-
name,
|
|
26
|
-
onBlur,
|
|
27
|
-
onChange,
|
|
28
|
-
onFocus,
|
|
29
|
-
onKeyDown,
|
|
30
|
-
onKeyUp,
|
|
31
|
-
onSubmitValue,
|
|
32
|
-
placeholder,
|
|
33
|
-
step = 1,
|
|
34
|
-
tabIndex,
|
|
35
|
-
title,
|
|
36
|
-
unit = DEFAULT_UNIT_BY_CSS_VALUE_TYPE[cssValueType],
|
|
37
|
-
validator,
|
|
38
|
-
value,
|
|
39
|
-
},
|
|
40
|
-
ref,
|
|
41
|
-
) {
|
|
7
|
+
export default React.forwardRef(function CSSValueInput({ allowEmpty = true, className, cssValueType = DEFAULT_CSS_VALUE_TYPE, disabled, getValueAsNumber = getCSSValueAsNumber, icon, label, max, min, name, onBlur, onChange, onFocus, onKeyDown, onKeyUp, onSubmitValue, placeholder, step = 1, tabIndex, title, unit = DEFAULT_UNIT_BY_CSS_VALUE_TYPE[cssValueType], validator, value, }, ref) {
|
|
42
8
|
const inputRef = useRef(null);
|
|
43
9
|
useImperativeHandle(ref, () => inputRef.current);
|
|
44
10
|
// props.value should be a string; if it’s a number, convert it here
|
|
@@ -49,203 +15,164 @@ export default React.forwardRef(function CSSValueInput(
|
|
|
49
15
|
useEffect(() => {
|
|
50
16
|
submittedValueRef.current = value !== null && value !== void 0 ? value : '';
|
|
51
17
|
}, [value]);
|
|
52
|
-
const handleSubmitValue = useCallback(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
let isValid = false;
|
|
85
|
-
if (validator instanceof RegExp) {
|
|
86
|
-
isValid = validator.test(currentValue);
|
|
87
|
-
} else if (validator) {
|
|
88
|
-
isValid = validator(currentValue);
|
|
89
|
-
}
|
|
90
|
-
if (isValid) {
|
|
91
|
-
handleSubmitValue(event);
|
|
92
|
-
} else {
|
|
93
|
-
// If current value isn’t valid, revert to last submitted value
|
|
94
|
-
input.value = submittedValueRef.current;
|
|
95
|
-
}
|
|
96
|
-
return;
|
|
18
|
+
const handleSubmitValue = useCallback((event) => {
|
|
19
|
+
const currentValue = event.currentTarget.value;
|
|
20
|
+
// Store last submittedValue (used to reset value on invalid input)
|
|
21
|
+
submittedValueRef.current = currentValue;
|
|
22
|
+
onSubmitValue(currentValue);
|
|
23
|
+
}, [onSubmitValue]);
|
|
24
|
+
const handleBlur = useCallback((event) => {
|
|
25
|
+
const input = event.currentTarget;
|
|
26
|
+
inputRef.current = input;
|
|
27
|
+
if (onBlur)
|
|
28
|
+
onBlur(event);
|
|
29
|
+
const currentValue = input.value.trim();
|
|
30
|
+
// If allowEmpty and value is empty, skip all validation + normalization
|
|
31
|
+
if (allowEmpty && !currentValue) {
|
|
32
|
+
handleSubmitValue(event);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const currentValueAsNumber = getValueAsNumber(currentValue);
|
|
36
|
+
const isCurrentValueFinite = Number.isFinite(currentValueAsNumber);
|
|
37
|
+
// Inherit unit from last submitted value unless default is unitless;
|
|
38
|
+
// ensures that submitting a new value with no unit doesn’t add a unit
|
|
39
|
+
const defaultUnit = unit
|
|
40
|
+
? getUnitFromCSSValue({
|
|
41
|
+
cssValueType,
|
|
42
|
+
defaultUnit: unit,
|
|
43
|
+
value: submittedValueRef.current,
|
|
44
|
+
})
|
|
45
|
+
: '';
|
|
46
|
+
if (!isCurrentValueFinite) {
|
|
47
|
+
let isValid = false;
|
|
48
|
+
if (validator instanceof RegExp) {
|
|
49
|
+
isValid = validator.test(currentValue);
|
|
97
50
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (isCurrentValueFinite) {
|
|
101
|
-
if (min != null && currentValueAsNumber < min) {
|
|
102
|
-
normalizedValueAsNumber = min;
|
|
103
|
-
} else if (max != null && currentValueAsNumber > max) {
|
|
104
|
-
normalizedValueAsNumber = max;
|
|
105
|
-
} else if (cssValueType === 'integer') {
|
|
106
|
-
normalizedValueAsNumber = Math.floor(currentValueAsNumber);
|
|
107
|
-
}
|
|
51
|
+
else if (validator) {
|
|
52
|
+
isValid = validator(currentValue);
|
|
108
53
|
}
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
cssValueType,
|
|
112
|
-
defaultUnit,
|
|
113
|
-
value: currentValue,
|
|
114
|
-
});
|
|
115
|
-
input.value = normalizedValueAsNumber + currentUnit;
|
|
116
|
-
} else {
|
|
117
|
-
input.value = getCSSValueWithUnit({
|
|
118
|
-
cssValueType,
|
|
119
|
-
defaultUnit,
|
|
120
|
-
value: currentValue,
|
|
121
|
-
});
|
|
54
|
+
if (isValid) {
|
|
55
|
+
handleSubmitValue(event);
|
|
122
56
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
allowEmpty,
|
|
127
|
-
cssValueType,
|
|
128
|
-
getValueAsNumber,
|
|
129
|
-
handleSubmitValue,
|
|
130
|
-
max,
|
|
131
|
-
min,
|
|
132
|
-
onBlur,
|
|
133
|
-
unit,
|
|
134
|
-
validator,
|
|
135
|
-
],
|
|
136
|
-
);
|
|
137
|
-
const getNextValue = useCallback(
|
|
138
|
-
({ currentValue, multiplier = 1, signum = 1 }) => {
|
|
139
|
-
const modifier = multiplier * step * signum;
|
|
140
|
-
const currentValueAsNumber = getValueAsNumber(currentValue);
|
|
141
|
-
// If currentValue isn’t numeric, don’t try to increment/decrement it
|
|
142
|
-
if (typeof currentValue === 'string' && Number.isNaN(currentValueAsNumber)) {
|
|
143
|
-
return currentValue;
|
|
57
|
+
else {
|
|
58
|
+
// If current value isn’t valid, revert to last submitted value
|
|
59
|
+
input.value = submittedValueRef.current;
|
|
144
60
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
// Normalize value by applying min/max and integer constraints
|
|
64
|
+
let normalizedValueAsNumber = currentValueAsNumber;
|
|
65
|
+
if (isCurrentValueFinite) {
|
|
66
|
+
if (min != null && currentValueAsNumber < min) {
|
|
67
|
+
normalizedValueAsNumber = min;
|
|
150
68
|
}
|
|
151
|
-
if (
|
|
152
|
-
|
|
69
|
+
else if (max != null && currentValueAsNumber > max) {
|
|
70
|
+
normalizedValueAsNumber = max;
|
|
153
71
|
}
|
|
154
|
-
if (
|
|
155
|
-
|
|
72
|
+
else if (cssValueType === 'integer') {
|
|
73
|
+
normalizedValueAsNumber = Math.floor(currentValueAsNumber);
|
|
156
74
|
}
|
|
157
|
-
|
|
75
|
+
}
|
|
76
|
+
if (normalizedValueAsNumber !== currentValueAsNumber) {
|
|
77
|
+
const currentUnit = getUnitFromCSSValue({
|
|
158
78
|
cssValueType,
|
|
159
|
-
defaultUnit
|
|
79
|
+
defaultUnit,
|
|
160
80
|
value: currentValue,
|
|
161
81
|
});
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
82
|
+
input.value = normalizedValueAsNumber + currentUnit;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
input.value = getCSSValueWithUnit({
|
|
86
|
+
cssValueType,
|
|
87
|
+
defaultUnit,
|
|
88
|
+
value: currentValue,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
handleSubmitValue(event);
|
|
92
|
+
}, [
|
|
93
|
+
allowEmpty,
|
|
94
|
+
cssValueType,
|
|
95
|
+
getValueAsNumber,
|
|
96
|
+
handleSubmitValue,
|
|
97
|
+
max,
|
|
98
|
+
min,
|
|
99
|
+
onBlur,
|
|
100
|
+
unit,
|
|
101
|
+
validator,
|
|
102
|
+
]);
|
|
103
|
+
const getNextValue = useCallback(({ currentValue, multiplier = 1, signum = 1, }) => {
|
|
104
|
+
const modifier = multiplier * step * signum;
|
|
105
|
+
const currentValueAsNumber = getValueAsNumber(currentValue);
|
|
106
|
+
// If currentValue isn’t numeric, don’t try to increment/decrement it
|
|
107
|
+
if (typeof currentValue === 'string' && Number.isNaN(currentValueAsNumber)) {
|
|
108
|
+
return currentValue;
|
|
109
|
+
}
|
|
110
|
+
let nextValue = currentValueAsNumber + modifier;
|
|
111
|
+
if (cssValueType === 'integer') {
|
|
112
|
+
nextValue = Math.floor(nextValue);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
nextValue = roundToPrecision(nextValue, 5);
|
|
116
|
+
}
|
|
117
|
+
if (typeof max === 'number' && Number.isFinite(max)) {
|
|
118
|
+
nextValue = Math.min(max, nextValue);
|
|
119
|
+
}
|
|
120
|
+
if (typeof min === 'number' && Number.isFinite(min)) {
|
|
121
|
+
nextValue = Math.max(min, nextValue);
|
|
122
|
+
}
|
|
123
|
+
const nextUnit = getUnitFromCSSValue({
|
|
124
|
+
cssValueType,
|
|
125
|
+
defaultUnit: unit,
|
|
126
|
+
value: currentValue,
|
|
127
|
+
});
|
|
128
|
+
return `${nextValue}${nextUnit}`;
|
|
129
|
+
}, [cssValueType, getValueAsNumber, max, min, step, unit]);
|
|
130
|
+
const handleKeyDown = useCallback((event) => {
|
|
131
|
+
var _a, _b;
|
|
132
|
+
const input = event.currentTarget;
|
|
133
|
+
inputRef.current = input;
|
|
134
|
+
if (onKeyDown)
|
|
135
|
+
onKeyDown(event);
|
|
136
|
+
const currentValue = (_b = (_a = input.value) !== null && _a !== void 0 ? _a : placeholder) !== null && _b !== void 0 ? _b : `0${unit}`;
|
|
137
|
+
let nextValue = '';
|
|
138
|
+
switch (event.key) {
|
|
139
|
+
case 'Escape':
|
|
140
|
+
case 'Enter':
|
|
141
|
+
if (event.key === 'Escape') {
|
|
142
|
+
input.value = submittedValueRef.current;
|
|
143
|
+
}
|
|
144
|
+
input.blur();
|
|
145
|
+
return;
|
|
146
|
+
case 'ArrowUp':
|
|
147
|
+
case 'ArrowDown':
|
|
148
|
+
nextValue = getNextValue({
|
|
149
|
+
currentValue,
|
|
150
|
+
multiplier: event.shiftKey ? 10 : 1,
|
|
151
|
+
signum: event.key === 'ArrowUp' ? 1 : -1,
|
|
152
|
+
});
|
|
153
|
+
if (nextValue === currentValue)
|
|
197
154
|
return;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
);
|
|
214
|
-
return React.createElement(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
:
|
|
220
|
-
label
|
|
221
|
-
? React.createElement(
|
|
222
|
-
'div',
|
|
223
|
-
{ className: `${ROOT_CLASS_NAME}-label` },
|
|
224
|
-
React.createElement(
|
|
225
|
-
'p',
|
|
226
|
-
{ className: `${ROOT_CLASS_NAME}-label-text` },
|
|
227
|
-
label,
|
|
228
|
-
),
|
|
229
|
-
)
|
|
230
|
-
: null,
|
|
231
|
-
React.createElement(
|
|
232
|
-
'div',
|
|
233
|
-
{ className: `${ROOT_CLASS_NAME}-value` },
|
|
234
|
-
React.createElement(InputText, {
|
|
235
|
-
disabled: disabled,
|
|
236
|
-
initialValue: value,
|
|
237
|
-
name: name,
|
|
238
|
-
onBlur: handleBlur,
|
|
239
|
-
onChange: onChange,
|
|
240
|
-
onFocus: onFocus,
|
|
241
|
-
onKeyDown: handleKeyDown,
|
|
242
|
-
onKeyUp: handleKeyUp,
|
|
243
|
-
placeholder: placeholder,
|
|
244
|
-
ref: inputRef,
|
|
245
|
-
selectTextOnFocus: true,
|
|
246
|
-
tabIndex: tabIndex,
|
|
247
|
-
}),
|
|
248
|
-
),
|
|
249
|
-
);
|
|
155
|
+
event.stopPropagation();
|
|
156
|
+
event.preventDefault();
|
|
157
|
+
input.value = nextValue;
|
|
158
|
+
return;
|
|
159
|
+
default:
|
|
160
|
+
// No default key handling
|
|
161
|
+
}
|
|
162
|
+
}, [getNextValue, onKeyDown, placeholder, unit]);
|
|
163
|
+
const handleKeyUp = useCallback((event) => {
|
|
164
|
+
if (onKeyUp)
|
|
165
|
+
onKeyUp(event);
|
|
166
|
+
// If this is the key up from ↑ or ↓ keys, time to handleSubmitValue
|
|
167
|
+
if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
|
|
168
|
+
handleSubmitValue(event);
|
|
169
|
+
}
|
|
170
|
+
}, [handleSubmitValue, onKeyUp]);
|
|
171
|
+
return (React.createElement("label", { "aria-label": label ? undefined : title, className: clsx(ROOT_CLASS_NAME, className, { disabled }), title: title },
|
|
172
|
+
icon ? React.createElement("div", { className: `${ROOT_CLASS_NAME}-icon` }, icon) : null,
|
|
173
|
+
label ? (React.createElement("div", { className: `${ROOT_CLASS_NAME}-label` },
|
|
174
|
+
React.createElement("p", { className: `${ROOT_CLASS_NAME}-label-text` }, label))) : null,
|
|
175
|
+
React.createElement("div", { className: `${ROOT_CLASS_NAME}-value` },
|
|
176
|
+
React.createElement(InputText, { disabled: disabled, initialValue: value, name: name, onBlur: handleBlur, onChange: onChange, onFocus: onFocus, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, placeholder: placeholder, ref: inputRef, selectTextOnFocus: true, tabIndex: tabIndex }))));
|
|
250
177
|
});
|
|
251
|
-
//# sourceMappingURL=CSSValueInput.js.map
|
|
178
|
+
//# sourceMappingURL=CSSValueInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CSSValueInput.js","sourceRoot":"","sources":["../src/CSSValueInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,sBAAsB,EACtB,8BAA8B,EAC9B,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,GACnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA4C/B,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;AAEtE,MAAM,eAAe,GAAG,eAAe,CAAC;AAExC,eAAe,KAAK,CAAC,UAAU,CAA0B,SAAS,aAAa,CAC3E,EACI,UAAU,GAAG,IAAI,EACjB,SAAS,EACT,YAAY,GAAG,sBAAsB,EACrC,QAAQ,EACR,gBAAgB,GAAG,mBAAmB,EACtC,IAAI,EACJ,KAAK,EACL,GAAG,EACH,GAAG,EACH,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,OAAO,EACP,SAAS,EACT,OAAO,EACP,aAAa,EACb,WAAW,EACX,IAAI,GAAG,CAAC,EACR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ACF,CACX,CAAC;AACN,CAAC,CAAC,CAAC"}
|
|
@@ -4,20 +4,18 @@ import userEvent from '@testing-library/user-event';
|
|
|
4
4
|
import React from 'react'; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
5
|
import { afterEach, describe, expect, it } from 'vitest';
|
|
6
6
|
import CSSValueInput from './CSSValueInput.js';
|
|
7
|
-
const noop = () => {}; // eslint-disable-line @typescript-eslint/no-empty-function
|
|
7
|
+
const noop = () => { }; // eslint-disable-line @typescript-eslint/no-empty-function
|
|
8
8
|
afterEach(cleanup);
|
|
9
9
|
describe('CSSValueInput.tsx', () => {
|
|
10
10
|
it('renders a text input with the given props.value', () => {
|
|
11
|
-
render(
|
|
12
|
-
React.createElement(CSSValueInput, { onSubmitValue: noop, value: '24px' }),
|
|
13
|
-
);
|
|
11
|
+
render(React.createElement(CSSValueInput, { onSubmitValue: noop, value: "24px" }));
|
|
14
12
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
15
13
|
const input = screen.getByRole('textbox');
|
|
16
14
|
expect(input.value).toBe('24px');
|
|
17
15
|
});
|
|
18
16
|
it('handles ↑/↓ keys to increment/decrement by 1 and ⇧↑/⇧↓ to increment/decrement by 10 (preserving the CSS unit)', async () => {
|
|
19
17
|
const user = userEvent.setup();
|
|
20
|
-
render(React.createElement(CSSValueInput, { onSubmitValue: noop, value:
|
|
18
|
+
render(React.createElement(CSSValueInput, { onSubmitValue: noop, value: "75%" }));
|
|
21
19
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
22
20
|
const input = screen.getByRole('textbox');
|
|
23
21
|
expect(input.value).toBe('75%');
|
|
@@ -36,13 +34,7 @@ describe('CSSValueInput.tsx', () => {
|
|
|
36
34
|
});
|
|
37
35
|
it('supports custom props.step for ↑/↓ key handling', async () => {
|
|
38
36
|
const user = userEvent.setup();
|
|
39
|
-
render(
|
|
40
|
-
React.createElement(CSSValueInput, {
|
|
41
|
-
onSubmitValue: noop,
|
|
42
|
-
step: 0.1,
|
|
43
|
-
value: '2rem',
|
|
44
|
-
}),
|
|
45
|
-
);
|
|
37
|
+
render(React.createElement(CSSValueInput, { onSubmitValue: noop, step: 0.1, value: "2rem" }));
|
|
46
38
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
47
39
|
const input = screen.getByRole('textbox');
|
|
48
40
|
expect(input.value).toBe('2rem');
|
|
@@ -61,14 +53,7 @@ describe('CSSValueInput.tsx', () => {
|
|
|
61
53
|
});
|
|
62
54
|
it('uses props.unit as default unit when unit is missing', async () => {
|
|
63
55
|
const user = userEvent.setup();
|
|
64
|
-
render(
|
|
65
|
-
React.createElement(CSSValueInput, {
|
|
66
|
-
allowEmpty: true,
|
|
67
|
-
onSubmitValue: noop,
|
|
68
|
-
unit: 'px',
|
|
69
|
-
value: '',
|
|
70
|
-
}),
|
|
71
|
-
);
|
|
56
|
+
render(React.createElement(CSSValueInput, { allowEmpty: true, onSubmitValue: noop, unit: "px", value: "" }));
|
|
72
57
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
73
58
|
const input = screen.getByRole('textbox');
|
|
74
59
|
expect(input.value).toBe('');
|
|
@@ -77,14 +62,7 @@ describe('CSSValueInput.tsx', () => {
|
|
|
77
62
|
});
|
|
78
63
|
it('preserves last entered unit if different from props.unit when unit is missing', async () => {
|
|
79
64
|
const user = userEvent.setup();
|
|
80
|
-
render(
|
|
81
|
-
React.createElement(CSSValueInput, {
|
|
82
|
-
allowEmpty: true,
|
|
83
|
-
onSubmitValue: noop,
|
|
84
|
-
unit: 'px',
|
|
85
|
-
value: '',
|
|
86
|
-
}),
|
|
87
|
-
);
|
|
65
|
+
render(React.createElement(CSSValueInput, { allowEmpty: true, onSubmitValue: noop, unit: "px", value: "" }));
|
|
88
66
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
89
67
|
const input = screen.getByRole('textbox');
|
|
90
68
|
expect(input.value).toBe('');
|
|
@@ -95,14 +73,7 @@ describe('CSSValueInput.tsx', () => {
|
|
|
95
73
|
});
|
|
96
74
|
it('treats value as numeric if props.unit is an empty string', async () => {
|
|
97
75
|
const user = userEvent.setup();
|
|
98
|
-
render(
|
|
99
|
-
React.createElement(CSSValueInput, {
|
|
100
|
-
allowEmpty: true,
|
|
101
|
-
onSubmitValue: noop,
|
|
102
|
-
unit: '',
|
|
103
|
-
value: '100',
|
|
104
|
-
}),
|
|
105
|
-
);
|
|
76
|
+
render(React.createElement(CSSValueInput, { allowEmpty: true, onSubmitValue: noop, unit: "", value: "100" }));
|
|
106
77
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
107
78
|
const input = screen.getByRole('textbox');
|
|
108
79
|
expect(input.value).toBe('100');
|
|
@@ -117,35 +88,17 @@ describe('CSSValueInput.tsx', () => {
|
|
|
117
88
|
});
|
|
118
89
|
it('updates default unit as props.unit and props.value changes', async () => {
|
|
119
90
|
const user = userEvent.setup();
|
|
120
|
-
const { rerender } = render(
|
|
121
|
-
React.createElement(CSSValueInput, {
|
|
122
|
-
onSubmitValue: noop,
|
|
123
|
-
unit: 'px',
|
|
124
|
-
value: '12px',
|
|
125
|
-
}),
|
|
126
|
-
);
|
|
91
|
+
const { rerender } = render(React.createElement(CSSValueInput, { onSubmitValue: noop, unit: "px", value: "12px" }));
|
|
127
92
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
128
93
|
const input = screen.getByRole('textbox');
|
|
129
|
-
rerender(
|
|
130
|
-
React.createElement(CSSValueInput, {
|
|
131
|
-
onSubmitValue: noop,
|
|
132
|
-
unit: '',
|
|
133
|
-
value: '4',
|
|
134
|
-
}),
|
|
135
|
-
);
|
|
94
|
+
rerender(React.createElement(CSSValueInput, { onSubmitValue: noop, unit: "", value: "4" }));
|
|
136
95
|
expect(input.value).toBe('4');
|
|
137
96
|
await user.type(input, '25{Enter}');
|
|
138
97
|
expect(input.value).toBe('25');
|
|
139
|
-
rerender(
|
|
140
|
-
React.createElement(CSSValueInput, {
|
|
141
|
-
onSubmitValue: noop,
|
|
142
|
-
unit: 'rad',
|
|
143
|
-
value: '3rad',
|
|
144
|
-
}),
|
|
145
|
-
);
|
|
98
|
+
rerender(React.createElement(CSSValueInput, { onSubmitValue: noop, unit: "rad", value: "3rad" }));
|
|
146
99
|
expect(input.value).toBe('3rad');
|
|
147
100
|
await user.type(input, '-4.1{Enter}');
|
|
148
101
|
expect(input.value).toBe('-4.1rad');
|
|
149
102
|
});
|
|
150
103
|
});
|
|
151
|
-
//# sourceMappingURL=CSSValueInput.test.js.map
|
|
104
|
+
//# sourceMappingURL=CSSValueInput.test.js.map
|
package/package.json
CHANGED
package/src/CSSValueInput.tsx
CHANGED
|
@@ -287,7 +287,11 @@ export default React.forwardRef<HTMLInputElement, Props>(function CSSValueInput(
|
|
|
287
287
|
);
|
|
288
288
|
|
|
289
289
|
return (
|
|
290
|
-
<label
|
|
290
|
+
<label
|
|
291
|
+
aria-label={label ? undefined : title}
|
|
292
|
+
className={clsx(ROOT_CLASS_NAME, className, { disabled })}
|
|
293
|
+
title={title}
|
|
294
|
+
>
|
|
291
295
|
{icon ? <div className={`${ROOT_CLASS_NAME}-icon`}>{icon}</div> : null}
|
|
292
296
|
{label ? (
|
|
293
297
|
<div className={`${ROOT_CLASS_NAME}-label`}>
|