Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NumberControl: refactor to TypeScript #38753

Closed
wants to merge 26 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
bab61da
Rename index and styles
ciampo Feb 11, 2022
7f50084
Add prop types
ciampo Feb 11, 2022
bb7befb
Fix styles
ciampo Feb 11, 2022
1072a51
Type component signature
ciampo Feb 11, 2022
ee9e385
Ensure `min`, `max` amd `step` are converted to numbers for internal …
ciampo Feb 11, 2022
91cb750
Remove unnecessary `parseFloat`, since `shiftStep` is a `number`
ciampo Feb 11, 2022
126bdc7
Type `numberControlStateReducer` using the `Props` type
ciampo Feb 11, 2022
44b503f
Type `contrainValue`
ciampo Feb 11, 2022
b56da69
Default to `0` if `currentValue` is `undefined`, convert to number
ciampo Feb 11, 2022
f6a2df0
Commit and forward `value` as a `string`
ciampo Feb 11, 2022
800b8be
Cast even to `KeyboardEvent` when reacting to key up/down events
ciampo Feb 11, 2022
0167076
WIP README
ciampo Feb 11, 2022
b47c769
Ignore remaining TS errors
ciampo Feb 11, 2022
1c04a00
ShiftStep also as a string
ciampo Feb 16, 2022
8f20af5
Add `ensureString` utility function
ciampo Feb 16, 2022
62a3e27
Add `onDrag`, `onDragStart` and `onDragEnd` props from `InputControl`…
ciampo Feb 16, 2022
ace5d44
Force `nextValue` to be alway a string in the `UnitControl` onChange …
ciampo Feb 16, 2022
bd7491f
Tweak `value` and `onChange` so that they can accept also `number` in…
ciampo Feb 16, 2022
7d282d7
Update `InputControl` README to reflect that `value` can only be a `s…
ciampo Feb 16, 2022
486b099
Fix `ColorPicker` s TS errors
ciampo Feb 16, 2022
cb0b607
Tweak Storybook values
ciampo Feb 16, 2022
367c59d
`NumberControl` s value as a `string`
ciampo Feb 18, 2022
a9fa8a1
Fix story
ciampo Feb 18, 2022
8ecd990
Type reducer s DRAG action
ciampo Feb 18, 2022
0f9fc2d
Refactor common number/string utils
ciampo Feb 18, 2022
d507a8f
Update styles to assume `value` is a `string`
ciampo Feb 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Force nextValue to be alway a string in the UnitControl onChange …
…callback
ciampo committed Feb 16, 2022
commit ace5d44ddc91758c0b538c5e1c7615aab9e95f8f
9 changes: 8 additions & 1 deletion packages/components/src/unit-control/index.tsx
Original file line number Diff line number Diff line change
@@ -209,7 +209,14 @@ function UnitControl(
label={ label }
onBlur={ handleOnBlur }
onKeyDown={ handleOnKeyDown }
onChange={ handleOnChange }
onChange={ ( nextValue, extra ) => {
let v;

if ( typeof v !== 'undefined' ) {
v = `${ nextValue }`;
}
handleOnChange?.( v, extra );
} }
ref={ forwardedRef }
size={ size }
suffix={ inputSuffix }