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
Ignore remaining TS errors
  • Loading branch information
ciampo committed Feb 16, 2022

Verified

This commit was signed with the committer’s verified signature. The key has expired.
tonistiigi Tõnis Tiigi
commit b47c76967bce9465be97737b47e0018a78fa35b7
2 changes: 2 additions & 0 deletions packages/components/src/color-picker/input-with-slider.tsx
Original file line number Diff line number Diff line change
@@ -32,7 +32,9 @@ export const InputWithSlider = ( {
max={ max }
label={ label }
hideLabelFromVision
// @ts-ignore
value={ value }
// @ts-ignore
onChange={ onChange }
prefix={
<Spacer
2 changes: 2 additions & 0 deletions packages/components/src/number-control/index.tsx
Original file line number Diff line number Diff line change
@@ -111,7 +111,9 @@ export function NumberControl(
* Handles drag to update events
*/
if ( type === inputControlActionTypes.DRAG && isDragEnabled ) {
// @ts-ignore
const [ x, y ] = payload.delta;
// @ts-ignore
const enableShift = payload.shiftKey && isShiftStepEnabled;
const modifier = enableShift ? shiftStep * baseStep : baseStep;

1 change: 1 addition & 0 deletions packages/components/src/unit-control/index.tsx
Original file line number Diff line number Diff line change
@@ -213,6 +213,7 @@ function UnitControl(
ref={ forwardedRef }
size={ size }
suffix={ inputSuffix }
// @ts-ignore
value={ value }
step={ step }
__unstableStateReducer={ composeStateReducers(