Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 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
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

- Updated the visual styles of the RangeControl component ([#33824](https://github.com/WordPress/gutenberg/pull/33824))

### New Feature

- Add `hideLabelFromVision` prop to `RangeControl` ([#33714](https://github.com/WordPress/gutenberg/pull/33714))

## 15.0.0 (2021-07-29)

### Breaking Change
Expand Down
1 change: 1 addition & 0 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"memize": "^1.1.0",
"moment": "^2.22.1",
"re-resizable": "^6.4.0",
"react-colorful": "^5.3.0",
"react-dates": "^17.1.1",
"react-resize-aware": "^3.1.0",
"react-use-gesture": "^9.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/button/deprecated.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* WordPress dependencies
*/
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/button/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* External dependencies
*/
Expand Down
6 changes: 3 additions & 3 deletions packages/components/src/input-control/input-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function InputField(

const handleOnBlur = ( event: FocusEvent< HTMLInputElement > ) => {
onBlur( event );
setIsFocused( false );
setIsFocused?.( false );

/**
* If isPressEnterToChange is set, this commits the value to
Expand All @@ -123,7 +123,7 @@ function InputField(

const handleOnFocus = ( event: FocusEvent< HTMLInputElement > ) => {
onFocus( event );
setIsFocused( true );
setIsFocused?.( true );
};

const handleOnChange = ( event: ChangeEvent< HTMLInputElement > ) => {
Expand All @@ -135,7 +135,7 @@ function InputField(
const nextValue = event.currentTarget.value;

try {
onValidate( nextValue, event );
onValidate( nextValue );
commit( nextValue, event );
} catch ( err ) {
invalidate( err, event );
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/input-control/reducer/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function mergeInitialState(
...initialInputControlState,
...initialState,
initialValue: value,
};
} as InputState;
}

/**
Expand Down
7 changes: 5 additions & 2 deletions packages/components/src/input-control/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,20 @@ export interface InputBaseProps extends BaseProps, FlexProps {
}

export interface InputControlProps
extends Omit< InputBaseProps, 'children' >,
extends Omit< InputBaseProps, 'children' | 'isFocused' >,
/**
* The `prefix` prop in `PolymorphicComponentProps< InputFieldProps, 'input', false >` comes from the
* `HTMLInputAttributes` and clashes with the one from `InputBaseProps`. So we have to omit it from
* `PolymorphicComponentProps< InputFieldProps, 'input', false >` in order that `InputBaseProps[ 'prefix' ]`
* be the only prefix prop. Otherwise it tries to do a union of the two prefix properties and you end up
* with an unresolvable type.
*
* `isFocused` and `setIsFocused` are managed internally by the InputControl, but the rest of the props
* for InputField are passed through.
*/
Omit<
PolymorphicComponentProps< InputFieldProps, 'input', false >,
'stateReducer' | 'prefix'
'stateReducer' | 'prefix' | 'isFocused' | 'setIsFocused'
> {
__unstableStateReducer?: InputFieldProps[ 'stateReducer' ];
}
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/number-control/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* External dependencies
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* External dependencies
*/
Expand All @@ -12,11 +13,15 @@ const htmlArrowStyles = ( { hideHTMLArrows } ) => {
if ( ! hideHTMLArrows ) return ``;

return css`
&::-webkit-outer-spin-button,
&::-webkit-inner-spin-button {
input[type='number']::-webkit-outer-spin-button,
input[type='number']::-webkit-inner-spin-button {
-webkit-appearance: none !important;
margin: 0 !important;
}

input[type='number'] {
-moz-appearance: textfield;
}
`;
};

Expand Down
1 change: 1 addition & 0 deletions packages/components/src/popover/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* External dependencies
*/
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/popover/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* WordPress dependencies
*/
Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/range-control/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* External dependencies
*/
Expand Down Expand Up @@ -47,6 +48,7 @@ function RangeControl(
initialPosition,
isShiftStepEnabled = true,
label,
hideLabelFromVision = false,
marks = false,
max = 100,
min = 0,
Expand Down Expand Up @@ -194,6 +196,7 @@ function RangeControl(
<BaseControl
className={ classes }
label={ label }
hideLabelFromVision={ hideLabelFromVision }
id={ id }
help={ help }
>
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/range-control/input-range.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* External dependencies
*/
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/range-control/mark.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* External dependencies
*/
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/range-control/rail.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* WordPress dependencies
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* External dependencies
*/
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/range-control/tooltip.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* External dependencies
*/
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/range-control/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* External dependencies
*/
Expand Down
5 changes: 3 additions & 2 deletions packages/components/src/select-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ function useUniqueId( idProp?: string ) {
return idProp || id;
}

export interface SelectControlProps extends Omit< InputBaseProps, 'children' > {
export interface SelectControlProps
extends Omit< InputBaseProps, 'children' | 'isFocused' > {
help?: string;
hideLabelFromVision?: boolean;
multiple?: boolean;
Expand Down Expand Up @@ -92,7 +93,7 @@ function SelectControl(

const handleOnChange = ( event: ChangeEvent< HTMLSelectElement > ) => {
if ( multiple ) {
const selectedOptions = [ ...event.target.options ].filter(
const selectedOptions = Array.from( event.target.options ).filter(
( { selected } ) => selected
);
const newValues = selectedOptions.map( ( { value } ) => value );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const fontSizeStyles = ( { selectSize }: SelectProps ) => {
small: '11px',
};

const fontSize = sizes[ selectSize ];
const fontSize = sizes[ selectSize as Size ];
const fontSizeMobile = '16px';

if ( ! fontSize ) return '';
Expand Down Expand Up @@ -57,7 +57,7 @@ const sizeStyles = ( { selectSize }: SelectProps ) => {
},
};

const style = sizes[ selectSize ] || sizes.default;
const style = sizes[ selectSize as Size ] || sizes.default;

return css( style );
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* WordPress dependencies
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* WordPress dependencies
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* WordPress dependencies
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* WordPress dependencies
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* WordPress dependencies
*/
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/slot-fill/context.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* WordPress dependencies
*/
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/slot-fill/fill.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* External dependencies
*/
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/slot-fill/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* WordPress dependencies
*/
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/slot-fill/provider.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* External dependencies
*/
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/slot-fill/slot.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* External dependencies
*/
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/slot-fill/use-slot.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* WordPress dependencies
*/
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/tooltip/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/**
* External dependencies
*/
Expand Down
57 changes: 57 additions & 0 deletions packages/components/src/ui/color-picker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# ColorPicker

<div class="callout callout-alert">
This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
</div>

`ColorPicker` is a color picking component based on `react-colorful`. It lets you pick a color visually or by manipulating the individual RGB(A), HSL(A) and Hex(8) color values.

## Usage

```jsx
import { ColorPicker } from '@wordpress/components/ui';

function Example() {
const [color, setColor] = useState();
return (
<ColorPicker
color={color}
onChange={setColor}
enableAlpha
defaultValue="#000"
/>
);
}
```

## Props

### `color`

**Type**: `string`

The current color value to display in the picker. Must be a hex or hex8 string.

### `onChange`

**Type**: `(hex8Color: string) => void`

Fired when the color changes. Always passes a hex8 color string.

### `enableAlpha`

**Type**: `boolean`

Defaults to `false`. When `true` the color picker will display the alpha channel both in the bottom inputs as well as in the color picker itself.
Comment on lines +41 to +45
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: should we use the same format we've been using for newer components?

Suggested change
### `enableAlpha`
**Type**: `boolean`
Defaults to `false`. When `true` the color picker will display the alpha channel both in the bottom inputs as well as in the color picker itself.
### `enableAlpha`: `boolean`
When `true` the color picker will display the alpha channel both in the bottom inputs as well as in the color picker itself.
- Required: No
- Default: `false`


### `defaultValue`

**Type**: `string | undefined`

An optional default value to use for the color picker.

### `copyFormat`

**Type**: `'hex' | 'hsl' | 'rgb' | undefined`

The format to copy when clicking the displayed color format.
Loading