Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- `TabPanel`: Add ability to set icon only tab buttons ([#45005](https://github.com/WordPress/gutenberg/pull/45005)).

### Internal

- NumberControl: refactor styles/tests/stories to TypeScript, replace fireEvent with user-event ([#45990](https://github.com/WordPress/gutenberg/pull/45990)).

## 22.1.0 (2022-11-16)

### Enhancements
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import type { ComponentMeta, ComponentStory } from '@storybook/react';

/**
* WordPress dependencies
*/
Expand All @@ -6,9 +11,9 @@ import { useState } from '@wordpress/element';
/**
* Internal dependencies
*/
import NumberControl from '../';
import NumberControl from '..';

export default {
const meta: ComponentMeta< typeof NumberControl > = {
title: 'Components (Experimental)/NumberControl',
component: NumberControl,
argTypes: {
Expand All @@ -19,10 +24,19 @@ export default {
type: { control: { type: 'text' } },
value: { control: null },
},
parameters: {
controls: { expanded: true },
docs: { source: { state: 'open' } },
},
};
Comment thread
ciampo marked this conversation as resolved.
Resolved

function Template( { onChange, ...props } ) {
const [ value, setValue ] = useState( '0' );
export default meta;

const Template: ComponentStory< typeof NumberControl > = ( {
onChange,
...props
} ) => {
const [ value, setValue ] = useState< string | undefined >( '0' );
const [ isValidValue, setIsValidValue ] = useState( true );

return (
Expand All @@ -32,14 +46,17 @@ function Template( { onChange, ...props } ) {
value={ value }
onChange={ ( v, extra ) => {
setValue( v );
setIsValidValue( extra.event.target.validity.valid );
onChange( v, extra );
setIsValidValue(
( extra.event.target as HTMLInputElement ).validity
.valid
);
onChange?.( v, extra );
} }
/>
<p>Is valid? { isValidValue ? 'Yes' : 'No' }</p>
</>
);
}
};

export const Default = Template.bind( {} );
Default.args = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-nocheck
/**
* External dependencies
*/
Expand All @@ -12,8 +11,9 @@ import InputControl from '../../input-control';
import { COLORS } from '../../utils';
import Button from '../../button';
import { space } from '../../ui/utils/space';
import type { NumberControlProps } from '../types';

const htmlArrowStyles = ( { hideHTMLArrows } ) => {
const htmlArrowStyles = ( { hideHTMLArrows }: { hideHTMLArrows: boolean } ) => {
if ( ! hideHTMLArrows ) {
return ``;
}
Expand All @@ -35,7 +35,9 @@ export const Input = styled( InputControl )`
${ htmlArrowStyles };
`;

const spinButtonSizeStyles = ( { size } ) => {
const spinButtonSizeStyles = ( {
size,
}: Pick< NumberControlProps, 'size' > ) => {
if ( size !== 'small' ) {
return ``;
}
Expand Down
Loading