@wordpress/components 30.9.0 → 31.0.0
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/CHANGELOG.md +26 -4
- package/build/alignment-matrix-control/cell.js +131 -3
- package/build/alignment-matrix-control/cell.js.map +4 -4
- package/build/alignment-matrix-control/index.js +134 -6
- package/build/alignment-matrix-control/index.js.map +3 -3
- package/build/angle-picker-control/angle-circle.js +119 -15
- package/build/angle-picker-control/angle-circle.js.map +4 -4
- package/build/angle-picker-control/index.js +12 -7
- package/build/angle-picker-control/index.js.map +3 -3
- package/build/dropdown-menu/index.js +1 -1
- package/build/dropdown-menu/index.js.map +2 -2
- package/build/form-token-field/index.js +1 -13
- package/build/form-token-field/index.js.map +3 -3
- package/build/menu/styles.js +17 -17
- package/build/menu/styles.js.map +2 -2
- package/build/menu-item/index.js +1 -1
- package/build/menu-item/index.js.map +2 -2
- package/build/notice/index.js +1 -1
- package/build/notice/index.js.map +2 -2
- package/build/query-controls/index.js +0 -1
- package/build/query-controls/index.js.map +2 -2
- package/build/snackbar/index.js +1 -1
- package/build/snackbar/index.js.map +1 -1
- package/build/validated-form-controls/components/checkbox-control.js +0 -10
- package/build/validated-form-controls/components/checkbox-control.js.map +2 -2
- package/build/validated-form-controls/components/combobox-control.js +1 -11
- package/build/validated-form-controls/components/combobox-control.js.map +2 -2
- package/build/validated-form-controls/components/custom-select-control.js +0 -10
- package/build/validated-form-controls/components/custom-select-control.js.map +2 -2
- package/build/validated-form-controls/components/form-token-field.js +2 -13
- package/build/validated-form-controls/components/form-token-field.js.map +2 -2
- package/build/validated-form-controls/components/input-control.js +0 -10
- package/build/validated-form-controls/components/input-control.js.map +2 -2
- package/build/validated-form-controls/components/number-control.js +0 -10
- package/build/validated-form-controls/components/number-control.js.map +2 -2
- package/build/validated-form-controls/components/radio-control.js +0 -10
- package/build/validated-form-controls/components/radio-control.js.map +2 -2
- package/build/validated-form-controls/components/range-control.js +0 -10
- package/build/validated-form-controls/components/range-control.js.map +2 -2
- package/build/validated-form-controls/components/select-control.js +0 -10
- package/build/validated-form-controls/components/select-control.js.map +2 -2
- package/build/validated-form-controls/components/text-control.js +0 -10
- package/build/validated-form-controls/components/text-control.js.map +2 -2
- package/build/validated-form-controls/components/textarea-control.js +0 -10
- package/build/validated-form-controls/components/textarea-control.js.map +2 -2
- package/build/validated-form-controls/components/toggle-control.js +0 -10
- package/build/validated-form-controls/components/toggle-control.js.map +2 -2
- package/build/validated-form-controls/components/toggle-group-control.js +0 -10
- package/build/validated-form-controls/components/toggle-group-control.js.map +2 -2
- package/build/validated-form-controls/control-with-error.js +53 -58
- package/build/validated-form-controls/control-with-error.js.map +2 -2
- package/build-module/alignment-matrix-control/cell.js +131 -3
- package/build-module/alignment-matrix-control/cell.js.map +3 -3
- package/build-module/alignment-matrix-control/index.js +134 -6
- package/build-module/alignment-matrix-control/index.js.map +3 -3
- package/build-module/angle-picker-control/angle-circle.js +109 -15
- package/build-module/angle-picker-control/angle-circle.js.map +3 -3
- package/build-module/angle-picker-control/index.js +12 -7
- package/build-module/angle-picker-control/index.js.map +2 -2
- package/build-module/dropdown-menu/index.js +1 -1
- package/build-module/dropdown-menu/index.js.map +2 -2
- package/build-module/form-token-field/index.js +1 -13
- package/build-module/form-token-field/index.js.map +2 -2
- package/build-module/menu/styles.js +17 -17
- package/build-module/menu/styles.js.map +2 -2
- package/build-module/menu-item/index.js +1 -1
- package/build-module/menu-item/index.js.map +2 -2
- package/build-module/notice/index.js +1 -1
- package/build-module/notice/index.js.map +2 -2
- package/build-module/query-controls/index.js +0 -1
- package/build-module/query-controls/index.js.map +2 -2
- package/build-module/snackbar/index.js +1 -1
- package/build-module/snackbar/index.js.map +1 -1
- package/build-module/validated-form-controls/components/checkbox-control.js +0 -10
- package/build-module/validated-form-controls/components/checkbox-control.js.map +2 -2
- package/build-module/validated-form-controls/components/combobox-control.js +1 -11
- package/build-module/validated-form-controls/components/combobox-control.js.map +2 -2
- package/build-module/validated-form-controls/components/custom-select-control.js +0 -10
- package/build-module/validated-form-controls/components/custom-select-control.js.map +2 -2
- package/build-module/validated-form-controls/components/form-token-field.js +2 -13
- package/build-module/validated-form-controls/components/form-token-field.js.map +2 -2
- package/build-module/validated-form-controls/components/input-control.js +0 -10
- package/build-module/validated-form-controls/components/input-control.js.map +2 -2
- package/build-module/validated-form-controls/components/number-control.js +0 -10
- package/build-module/validated-form-controls/components/number-control.js.map +2 -2
- package/build-module/validated-form-controls/components/radio-control.js +0 -10
- package/build-module/validated-form-controls/components/radio-control.js.map +2 -2
- package/build-module/validated-form-controls/components/range-control.js +0 -10
- package/build-module/validated-form-controls/components/range-control.js.map +2 -2
- package/build-module/validated-form-controls/components/select-control.js +0 -10
- package/build-module/validated-form-controls/components/select-control.js.map +2 -2
- package/build-module/validated-form-controls/components/text-control.js +0 -10
- package/build-module/validated-form-controls/components/text-control.js.map +2 -2
- package/build-module/validated-form-controls/components/textarea-control.js +0 -10
- package/build-module/validated-form-controls/components/textarea-control.js.map +2 -2
- package/build-module/validated-form-controls/components/toggle-control.js +0 -10
- package/build-module/validated-form-controls/components/toggle-control.js.map +2 -2
- package/build-module/validated-form-controls/components/toggle-group-control.js +0 -10
- package/build-module/validated-form-controls/components/toggle-group-control.js.map +2 -2
- package/build-module/validated-form-controls/control-with-error.js +53 -58
- package/build-module/validated-form-controls/control-with-error.js.map +2 -2
- package/build-style/style-rtl.css +21 -33
- package/build-style/style.css +21 -33
- package/build-types/alignment-matrix-control/cell.d.ts.map +1 -1
- package/build-types/alignment-matrix-control/index.d.ts.map +1 -1
- package/build-types/angle-picker-control/angle-circle.d.ts +1 -1
- package/build-types/angle-picker-control/angle-circle.d.ts.map +1 -1
- package/build-types/angle-picker-control/index.d.ts.map +1 -1
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/stories/index.story.d.ts.map +1 -1
- package/build-types/form-token-field/types.d.ts +0 -6
- package/build-types/form-token-field/types.d.ts.map +1 -1
- package/build-types/notice/index.d.ts.map +1 -1
- package/build-types/notice/stories/index.story.d.ts.map +1 -1
- package/build-types/query-controls/index.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/checkbox-control.d.ts +1 -1
- package/build-types/validated-form-controls/components/checkbox-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/combobox-control.d.ts +2 -3
- package/build-types/validated-form-controls/components/combobox-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/custom-select-control.d.ts +1 -2
- package/build-types/validated-form-controls/components/custom-select-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/form-token-field.d.ts +1 -2
- package/build-types/validated-form-controls/components/form-token-field.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/input-control.d.ts +1 -2
- package/build-types/validated-form-controls/components/input-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/number-control.d.ts +1 -1
- package/build-types/validated-form-controls/components/number-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/radio-control.d.ts +1 -1
- package/build-types/validated-form-controls/components/radio-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/range-control.d.ts +1 -1
- package/build-types/validated-form-controls/components/range-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/select-control.d.ts +2 -3
- package/build-types/validated-form-controls/components/select-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/checkbox-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/combobox-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/custom-select-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/form-token-field.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/input-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/number-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/overview.story.d.ts +7 -0
- package/build-types/validated-form-controls/components/stories/overview.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/radio-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/range-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/select-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/text-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/textarea-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/toggle-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/toggle-group-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/text-control.d.ts +1 -1
- package/build-types/validated-form-controls/components/text-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/textarea-control.d.ts +1 -1
- package/build-types/validated-form-controls/components/textarea-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/toggle-control.d.ts +1 -1
- package/build-types/validated-form-controls/components/toggle-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/toggle-group-control.d.ts +1 -1
- package/build-types/validated-form-controls/components/toggle-group-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/types.d.ts +1 -9
- package/build-types/validated-form-controls/components/types.d.ts.map +1 -1
- package/build-types/validated-form-controls/control-with-error.d.ts +4 -5
- package/build-types/validated-form-controls/control-with-error.d.ts.map +1 -1
- package/package.json +20 -20
- package/src/alignment-matrix-control/cell.tsx +14 -3
- package/src/alignment-matrix-control/index.tsx +15 -6
- package/src/alignment-matrix-control/style.module.scss +84 -0
- package/src/angle-picker-control/angle-circle.tsx +27 -12
- package/src/angle-picker-control/index.tsx +8 -7
- package/src/angle-picker-control/style.module.scss +40 -0
- package/src/button/style.scss +1 -1
- package/src/dropdown-menu/index.tsx +1 -1
- package/src/dropdown-menu/style.scss +1 -1
- package/src/form-token-field/README.md +0 -2
- package/src/form-token-field/index.tsx +1 -13
- package/src/form-token-field/stories/index.story.tsx +0 -2
- package/src/form-token-field/test/index.tsx +0 -1
- package/src/form-token-field/types.ts +0 -6
- package/src/guide/style.scss +3 -3
- package/src/menu/styles.ts +2 -2
- package/src/menu-item/index.tsx +1 -1
- package/src/menu-item/test/__snapshots__/index.js.snap +4 -4
- package/src/modal/style.scss +5 -5
- package/src/notice/index.tsx +53 -46
- package/src/notice/stories/index.story.tsx +17 -1
- package/src/notice/style.scss +3 -20
- package/src/query-controls/index.tsx +0 -1
- package/src/snackbar/index.tsx +1 -1
- package/src/validated-form-controls/components/checkbox-control.tsx +1 -14
- package/src/validated-form-controls/components/combobox-control.tsx +1 -14
- package/src/validated-form-controls/components/custom-select-control.tsx +1 -19
- package/src/validated-form-controls/components/form-token-field.tsx +4 -21
- package/src/validated-form-controls/components/input-control.tsx +1 -14
- package/src/validated-form-controls/components/number-control.tsx +1 -16
- package/src/validated-form-controls/components/radio-control.tsx +2 -18
- package/src/validated-form-controls/components/range-control.tsx +1 -14
- package/src/validated-form-controls/components/select-control.tsx +1 -23
- package/src/validated-form-controls/components/stories/checkbox-control.story.tsx +11 -20
- package/src/validated-form-controls/components/stories/combobox-control.story.tsx +8 -17
- package/src/validated-form-controls/components/stories/custom-select-control.story.tsx +8 -17
- package/src/validated-form-controls/components/stories/form-token-field.story.tsx +14 -26
- package/src/validated-form-controls/components/stories/input-control.story.tsx +25 -50
- package/src/validated-form-controls/components/stories/number-control.story.tsx +10 -19
- package/src/validated-form-controls/components/stories/overview.mdx +3 -3
- package/src/validated-form-controls/components/stories/overview.story.tsx +94 -79
- package/src/validated-form-controls/components/stories/radio-control.story.tsx +11 -20
- package/src/validated-form-controls/components/stories/range-control.story.tsx +8 -17
- package/src/validated-form-controls/components/stories/select-control.story.tsx +9 -18
- package/src/validated-form-controls/components/stories/text-control.story.tsx +11 -17
- package/src/validated-form-controls/components/stories/textarea-control.story.tsx +12 -16
- package/src/validated-form-controls/components/stories/toggle-control.story.tsx +11 -20
- package/src/validated-form-controls/components/stories/toggle-group-control.story.tsx +8 -17
- package/src/validated-form-controls/components/text-control.tsx +1 -14
- package/src/validated-form-controls/components/textarea-control.tsx +1 -14
- package/src/validated-form-controls/components/toggle-control.tsx +1 -14
- package/src/validated-form-controls/components/toggle-group-control.tsx +1 -14
- package/src/validated-form-controls/components/types.ts +1 -9
- package/src/validated-form-controls/control-with-error.tsx +57 -84
- package/src/validated-form-controls/style.scss +7 -7
- package/src/validated-form-controls/test/control-with-error.tsx +66 -5
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/alignment-matrix-control/styles.js +0 -105
- package/build/alignment-matrix-control/styles.js.map +0 -7
- package/build/angle-picker-control/styles/angle-picker-control-styles.js +0 -88
- package/build/angle-picker-control/styles/angle-picker-control-styles.js.map +0 -7
- package/build-module/alignment-matrix-control/styles.js +0 -67
- package/build-module/alignment-matrix-control/styles.js.map +0 -7
- package/build-module/angle-picker-control/styles/angle-picker-control-styles.js +0 -50
- package/build-module/angle-picker-control/styles/angle-picker-control-styles.js.map +0 -7
- package/build-types/alignment-matrix-control/styles.d.ts +0 -21
- package/build-types/alignment-matrix-control/styles.d.ts.map +0 -1
- package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts +0 -18
- package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts.map +0 -1
- package/src/alignment-matrix-control/styles.ts +0 -113
- package/src/angle-picker-control/styles/angle-picker-control-styles.tsx +0 -58
|
@@ -12,7 +12,6 @@ import { __, _n, sprintf } from '@wordpress/i18n';
|
|
|
12
12
|
import { useDebounce, useInstanceId, usePrevious } from '@wordpress/compose';
|
|
13
13
|
import { speak } from '@wordpress/a11y';
|
|
14
14
|
import isShallowEqual from '@wordpress/is-shallow-equal';
|
|
15
|
-
import deprecated from '@wordpress/deprecated';
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
17
|
* Internal dependencies
|
|
@@ -27,7 +26,6 @@ import {
|
|
|
27
26
|
StyledHelp,
|
|
28
27
|
StyledLabel,
|
|
29
28
|
} from '../base-control/styles/base-control-styles';
|
|
30
|
-
import { Spacer } from '../spacer';
|
|
31
29
|
import { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';
|
|
32
30
|
import { withIgnoreIMEEvents } from '../utils/with-ignore-ime-events';
|
|
33
31
|
import { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';
|
|
@@ -75,18 +73,9 @@ export function FormTokenField( props: FormTokenFieldProps ) {
|
|
|
75
73
|
__experimentalShowHowTo = true,
|
|
76
74
|
__next40pxDefaultSize = false,
|
|
77
75
|
__experimentalAutoSelectFirstMatch = false,
|
|
78
|
-
__nextHasNoMarginBottom = false,
|
|
79
76
|
tokenizeOnBlur = false,
|
|
80
77
|
} = useDeprecated36pxDefaultSizeProp< FormTokenFieldProps >( props );
|
|
81
78
|
|
|
82
|
-
if ( ! __nextHasNoMarginBottom ) {
|
|
83
|
-
deprecated( 'Bottom margin styles for wp.components.FormTokenField', {
|
|
84
|
-
since: '6.7',
|
|
85
|
-
version: '7.0',
|
|
86
|
-
hint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version.',
|
|
87
|
-
} );
|
|
88
|
-
}
|
|
89
|
-
|
|
90
79
|
maybeWarnDeprecated36pxSize( {
|
|
91
80
|
componentName: 'FormTokenField',
|
|
92
81
|
size: undefined,
|
|
@@ -760,12 +749,11 @@ export function FormTokenField( props: FormTokenFieldProps ) {
|
|
|
760
749
|
/>
|
|
761
750
|
) }
|
|
762
751
|
</div>
|
|
763
|
-
{ ! __nextHasNoMarginBottom && <Spacer marginBottom={ 2 } /> }
|
|
764
752
|
{ __experimentalShowHowTo && (
|
|
765
753
|
<StyledHelp
|
|
766
754
|
id={ `components-form-token-suggestions-howto-${ instanceId }` }
|
|
767
755
|
className="components-form-token-field__help"
|
|
768
|
-
__nextHasNoMarginBottom
|
|
756
|
+
__nextHasNoMarginBottom
|
|
769
757
|
>
|
|
770
758
|
{ tokenizeOnSpace
|
|
771
759
|
? __(
|
|
@@ -63,7 +63,6 @@ export const Default: StoryFn< typeof FormTokenField > = DefaultTemplate.bind(
|
|
|
63
63
|
Default.args = {
|
|
64
64
|
label: 'Type a continent',
|
|
65
65
|
suggestions: continents,
|
|
66
|
-
__nextHasNoMarginBottom: true,
|
|
67
66
|
__next40pxDefaultSize: true,
|
|
68
67
|
};
|
|
69
68
|
|
|
@@ -102,7 +101,6 @@ export const Async: StoryFn< typeof FormTokenField > = ( {
|
|
|
102
101
|
Async.args = {
|
|
103
102
|
label: 'Type a continent',
|
|
104
103
|
suggestions: continents,
|
|
105
|
-
__nextHasNoMarginBottom: true,
|
|
106
104
|
__next40pxDefaultSize: true,
|
|
107
105
|
};
|
|
108
106
|
|
|
@@ -178,12 +178,6 @@ export interface FormTokenFieldProps
|
|
|
178
178
|
* Custom renderer for suggestions.
|
|
179
179
|
*/
|
|
180
180
|
__experimentalRenderItem?: ( args: { item: string } ) => ReactNode;
|
|
181
|
-
/**
|
|
182
|
-
* Start opting into the new margin-free styles that will become the default in a future version.
|
|
183
|
-
*
|
|
184
|
-
* @default false
|
|
185
|
-
*/
|
|
186
|
-
__nextHasNoMarginBottom?: boolean;
|
|
187
181
|
/**
|
|
188
182
|
* If true, add any incompleteTokenValue as a new token when the field loses focus.
|
|
189
183
|
*
|
package/src/guide/style.scss
CHANGED
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
height: $button-size;
|
|
60
60
|
justify-content: center;
|
|
61
61
|
margin: 0 0 $grid-unit-30 0;
|
|
62
|
-
padding: 0 $grid-unit-
|
|
62
|
+
padding: 0 $grid-unit-30;
|
|
63
63
|
position: relative;
|
|
64
64
|
width: 100%;
|
|
65
65
|
}
|
|
@@ -103,11 +103,11 @@
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
&.components-guide__back-button {
|
|
106
|
-
left: $grid-unit-
|
|
106
|
+
left: $grid-unit-30;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
&.components-guide__forward-button,
|
|
110
110
|
&.components-guide__finish-button {
|
|
111
|
-
right: $grid-unit-
|
|
111
|
+
right: $grid-unit-30;
|
|
112
112
|
}
|
|
113
113
|
}
|
package/src/menu/styles.ts
CHANGED
|
@@ -25,7 +25,7 @@ const ANIMATION_PARAMS = {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
const CONTENT_WRAPPER_PADDING = space( 1 );
|
|
28
|
-
const ITEM_PADDING_BLOCK = space(
|
|
28
|
+
const ITEM_PADDING_BLOCK = space( 1 );
|
|
29
29
|
const ITEM_PADDING_INLINE = space( 3 );
|
|
30
30
|
|
|
31
31
|
// TODO:
|
|
@@ -152,7 +152,7 @@ const baseItem = css`
|
|
|
152
152
|
all: unset;
|
|
153
153
|
|
|
154
154
|
position: relative;
|
|
155
|
-
min-height: ${ space(
|
|
155
|
+
min-height: ${ space( 8 ) };
|
|
156
156
|
box-sizing: border-box;
|
|
157
157
|
|
|
158
158
|
/* Occupy the width of all grid columns (ie. full width) */
|
package/src/menu-item/index.tsx
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
exports[`MenuItem should match snapshot when all props provided 1`] = `
|
|
4
4
|
<button
|
|
5
5
|
aria-checked="true"
|
|
6
|
-
class="components-button components-menu-item__button my-class is-
|
|
6
|
+
class="components-button components-menu-item__button my-class is-compact"
|
|
7
7
|
role="menuitemcheckbox"
|
|
8
8
|
type="button"
|
|
9
9
|
>
|
|
@@ -35,7 +35,7 @@ exports[`MenuItem should match snapshot when all props provided 1`] = `
|
|
|
35
35
|
|
|
36
36
|
exports[`MenuItem should match snapshot when info is provided 1`] = `
|
|
37
37
|
<button
|
|
38
|
-
class="components-button components-menu-item__button is-
|
|
38
|
+
class="components-button components-menu-item__button is-compact"
|
|
39
39
|
role="menuitem"
|
|
40
40
|
type="button"
|
|
41
41
|
>
|
|
@@ -62,7 +62,7 @@ exports[`MenuItem should match snapshot when info is provided 1`] = `
|
|
|
62
62
|
|
|
63
63
|
exports[`MenuItem should match snapshot when isSelected and role are optionally provided 1`] = `
|
|
64
64
|
<button
|
|
65
|
-
class="components-button components-menu-item__button my-class is-
|
|
65
|
+
class="components-button components-menu-item__button my-class is-compact"
|
|
66
66
|
role="menuitem"
|
|
67
67
|
type="button"
|
|
68
68
|
>
|
|
@@ -94,7 +94,7 @@ exports[`MenuItem should match snapshot when isSelected and role are optionally
|
|
|
94
94
|
|
|
95
95
|
exports[`MenuItem should match snapshot when only label provided 1`] = `
|
|
96
96
|
<button
|
|
97
|
-
class="components-button components-menu-item__button is-
|
|
97
|
+
class="components-button components-menu-item__button is-compact"
|
|
98
98
|
role="menuitem"
|
|
99
99
|
type="button"
|
|
100
100
|
>
|
package/src/modal/style.scss
CHANGED
|
@@ -109,10 +109,10 @@
|
|
|
109
109
|
|
|
110
110
|
&.is-full-screen {
|
|
111
111
|
// When full screen, make sure the children container is full height.
|
|
112
|
-
.components-modal__content {
|
|
112
|
+
:where(.components-modal__content) {
|
|
113
113
|
display: flex;
|
|
114
114
|
// If this container is scrollable, bottom padding won't apply so we use margin instead.
|
|
115
|
-
margin-bottom: $grid-unit-
|
|
115
|
+
margin-bottom: $grid-unit-30;
|
|
116
116
|
padding-bottom: 0;
|
|
117
117
|
|
|
118
118
|
> :last-child {
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
.components-modal__header {
|
|
153
153
|
box-sizing: border-box;
|
|
154
154
|
border-bottom: $border-width solid transparent;
|
|
155
|
-
padding: $grid-unit-30
|
|
155
|
+
padding: $grid-unit-30;
|
|
156
156
|
display: flex;
|
|
157
157
|
flex-direction: row;
|
|
158
158
|
justify-content: space-between;
|
|
@@ -206,12 +206,12 @@
|
|
|
206
206
|
flex: 1;
|
|
207
207
|
margin-top: $header-height + $grid-unit-10;
|
|
208
208
|
// Small top padding required to avoid cutting off the visible outline when the first child element is focusable.
|
|
209
|
-
padding: $grid-unit-05 $grid-unit-
|
|
209
|
+
padding: $grid-unit-05 $grid-unit-30 $grid-unit-30;
|
|
210
210
|
overflow: auto;
|
|
211
211
|
|
|
212
212
|
&.hide-header {
|
|
213
213
|
margin-top: 0;
|
|
214
|
-
padding-top: $grid-unit-
|
|
214
|
+
padding-top: $grid-unit-30;
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
&.is-scrollable:focus-visible {
|
package/src/notice/index.tsx
CHANGED
|
@@ -111,53 +111,60 @@ function Notice( {
|
|
|
111
111
|
<VisuallyHidden>{ getStatusLabel( status ) }</VisuallyHidden>
|
|
112
112
|
<div className="components-notice__content">
|
|
113
113
|
{ children }
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
114
|
+
{ actions.length > 0 && (
|
|
115
|
+
<div className="components-notice__actions">
|
|
116
|
+
{ actions.map(
|
|
117
|
+
(
|
|
118
|
+
{
|
|
119
|
+
className: buttonCustomClasses,
|
|
120
|
+
label,
|
|
121
|
+
isPrimary,
|
|
122
|
+
variant,
|
|
123
|
+
noDefaultClasses = false,
|
|
124
|
+
onClick,
|
|
125
|
+
url,
|
|
126
|
+
}: NoticeAction &
|
|
127
|
+
// `isPrimary` is a legacy prop included for
|
|
128
|
+
// backcompat, but `variant` should be used
|
|
129
|
+
// instead.
|
|
130
|
+
Pick< DeprecatedButtonProps, 'isPrimary' >,
|
|
131
|
+
index
|
|
132
|
+
) => {
|
|
133
|
+
let computedVariant = variant;
|
|
134
|
+
if (
|
|
135
|
+
variant !== 'primary' &&
|
|
136
|
+
! noDefaultClasses
|
|
137
|
+
) {
|
|
138
|
+
computedVariant = ! url
|
|
139
|
+
? 'secondary'
|
|
140
|
+
: 'link';
|
|
141
|
+
}
|
|
142
|
+
if (
|
|
143
|
+
typeof computedVariant === 'undefined' &&
|
|
144
|
+
isPrimary
|
|
145
|
+
) {
|
|
146
|
+
computedVariant = 'primary';
|
|
147
|
+
}
|
|
142
148
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
149
|
+
return (
|
|
150
|
+
<Button
|
|
151
|
+
__next40pxDefaultSize
|
|
152
|
+
key={ index }
|
|
153
|
+
href={ url }
|
|
154
|
+
variant={ computedVariant }
|
|
155
|
+
onClick={ url ? undefined : onClick }
|
|
156
|
+
className={ clsx(
|
|
157
|
+
'components-notice__action',
|
|
158
|
+
buttonCustomClasses
|
|
159
|
+
) }
|
|
160
|
+
>
|
|
161
|
+
{ label }
|
|
162
|
+
</Button>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
) }
|
|
166
|
+
</div>
|
|
167
|
+
) }
|
|
161
168
|
</div>
|
|
162
169
|
{ isDismissible && (
|
|
163
170
|
<Button
|
|
@@ -89,7 +89,7 @@ WithActions.args = {
|
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
export const NoticeListSubcomponent: StoryFn< typeof NoticeList > = () => {
|
|
92
|
-
const exampleNotices = [
|
|
92
|
+
const exampleNotices: NoticeListProps[ 'notices' ] = [
|
|
93
93
|
{
|
|
94
94
|
id: 'second-notice',
|
|
95
95
|
content: 'second notice content',
|
|
@@ -97,6 +97,22 @@ export const NoticeListSubcomponent: StoryFn< typeof NoticeList > = () => {
|
|
|
97
97
|
{
|
|
98
98
|
id: 'first-notice',
|
|
99
99
|
content: 'first notice content',
|
|
100
|
+
actions: [
|
|
101
|
+
{
|
|
102
|
+
label: 'Click me!',
|
|
103
|
+
onClick: () => {},
|
|
104
|
+
variant: 'primary',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
label: 'Or click me instead!',
|
|
108
|
+
onClick: () => {},
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
label: 'Or visit a link for more info',
|
|
112
|
+
url: 'https://wordpress.org',
|
|
113
|
+
variant: 'link',
|
|
114
|
+
},
|
|
115
|
+
],
|
|
100
116
|
},
|
|
101
117
|
];
|
|
102
118
|
const [ notices, setNotices ] = useState( exampleNotices );
|
package/src/notice/style.scss
CHANGED
|
@@ -41,20 +41,9 @@
|
|
|
41
41
|
.components-notice__actions {
|
|
42
42
|
display: flex;
|
|
43
43
|
flex-wrap: wrap;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
&,
|
|
48
|
-
&.is-link {
|
|
49
|
-
margin-left: $grid-unit-15;
|
|
50
|
-
}
|
|
51
|
-
&.is-secondary {
|
|
52
|
-
vertical-align: initial;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// When it has better support, this can be replaced
|
|
56
|
-
// with column-gap since these are flex items.
|
|
57
|
-
margin-right: $grid-unit-10;
|
|
44
|
+
align-items: center;
|
|
45
|
+
gap: $grid-unit-15;
|
|
46
|
+
margin-top: $grid-unit-15;
|
|
58
47
|
}
|
|
59
48
|
|
|
60
49
|
.components-notice__dismiss {
|
|
@@ -86,10 +75,4 @@
|
|
|
86
75
|
margin-bottom: $grid-unit-15;
|
|
87
76
|
line-height: 2;
|
|
88
77
|
}
|
|
89
|
-
|
|
90
|
-
.components-notice__action.components-button {
|
|
91
|
-
display: block;
|
|
92
|
-
margin-left: 0;
|
|
93
|
-
margin-top: $grid-unit-10;
|
|
94
|
-
}
|
|
95
78
|
}
|
package/src/snackbar/index.tsx
CHANGED
|
@@ -27,7 +27,7 @@ import type { SnackbarProps } from './types';
|
|
|
27
27
|
import type { NoticeAction } from '../notice/types';
|
|
28
28
|
import type { WordPressComponentProps } from '../context';
|
|
29
29
|
|
|
30
|
-
const NOTICE_TIMEOUT =
|
|
30
|
+
const NOTICE_TIMEOUT = 6000;
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Custom hook which announces the message with the given politeness, if a
|
|
@@ -10,37 +10,28 @@ import { forwardRef, useRef } from '@wordpress/element';
|
|
|
10
10
|
import { ControlWithError } from '../control-with-error';
|
|
11
11
|
import type { ValidatedControlProps } from './types';
|
|
12
12
|
import CheckboxControl from '../../checkbox-control';
|
|
13
|
-
import type { CheckboxControlProps } from '../../checkbox-control/types';
|
|
14
|
-
|
|
15
|
-
type Value = CheckboxControlProps[ 'checked' ];
|
|
16
13
|
|
|
17
14
|
const UnforwardedValidatedCheckboxControl = (
|
|
18
15
|
{
|
|
19
16
|
required,
|
|
20
|
-
onValidate,
|
|
21
17
|
customValidity,
|
|
22
|
-
onChange,
|
|
23
18
|
markWhenOptional,
|
|
24
19
|
...restProps
|
|
25
20
|
}: Omit<
|
|
26
21
|
React.ComponentProps< typeof CheckboxControl >,
|
|
27
22
|
'__nextHasNoMarginBottom'
|
|
28
23
|
> &
|
|
29
|
-
ValidatedControlProps
|
|
24
|
+
ValidatedControlProps,
|
|
30
25
|
forwardedRef: React.ForwardedRef< HTMLInputElement >
|
|
31
26
|
) => {
|
|
32
27
|
const validityTargetRef = useRef< HTMLDivElement >( null );
|
|
33
28
|
const mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );
|
|
34
|
-
const valueRef = useRef< Value >( restProps.checked );
|
|
35
29
|
|
|
36
30
|
return (
|
|
37
31
|
<ControlWithError
|
|
38
32
|
required={ required }
|
|
39
33
|
markWhenOptional={ markWhenOptional }
|
|
40
34
|
ref={ mergedRefs }
|
|
41
|
-
onValidate={ () => {
|
|
42
|
-
return onValidate?.( valueRef.current );
|
|
43
|
-
} }
|
|
44
35
|
customValidity={ customValidity }
|
|
45
36
|
getValidityTarget={ () =>
|
|
46
37
|
validityTargetRef.current?.querySelector< HTMLInputElement >(
|
|
@@ -50,10 +41,6 @@ const UnforwardedValidatedCheckboxControl = (
|
|
|
50
41
|
>
|
|
51
42
|
<CheckboxControl
|
|
52
43
|
__nextHasNoMarginBottom
|
|
53
|
-
onChange={ ( value ) => {
|
|
54
|
-
valueRef.current = value;
|
|
55
|
-
onChange?.( value );
|
|
56
|
-
} }
|
|
57
44
|
// TODO: Upstream limitation - CheckboxControl doesn't support uncontrolled mode, visually.
|
|
58
45
|
{ ...restProps }
|
|
59
46
|
/>
|
|
@@ -10,28 +10,22 @@ import { forwardRef, useEffect, useRef } from '@wordpress/element';
|
|
|
10
10
|
import { ControlWithError } from '../control-with-error';
|
|
11
11
|
import type { ValidatedControlProps } from './types';
|
|
12
12
|
import ComboboxControl from '../../combobox-control';
|
|
13
|
-
import type { ComboboxControlProps } from '../../combobox-control/types';
|
|
14
|
-
|
|
15
|
-
type Value = ComboboxControlProps[ 'value' ];
|
|
16
13
|
|
|
17
14
|
const UnforwardedValidatedComboboxControl = (
|
|
18
15
|
{
|
|
19
16
|
required,
|
|
20
|
-
onValidate,
|
|
21
17
|
customValidity,
|
|
22
|
-
onChange,
|
|
23
18
|
markWhenOptional,
|
|
24
19
|
...restProps
|
|
25
20
|
}: Omit<
|
|
26
21
|
React.ComponentProps< typeof ComboboxControl >,
|
|
27
22
|
'__next40pxDefaultSize' | '__nextHasNoMarginBottom'
|
|
28
23
|
> &
|
|
29
|
-
ValidatedControlProps
|
|
24
|
+
ValidatedControlProps,
|
|
30
25
|
forwardedRef: React.ForwardedRef< HTMLInputElement >
|
|
31
26
|
) => {
|
|
32
27
|
const validityTargetRef = useRef< HTMLInputElement >( null );
|
|
33
28
|
const mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );
|
|
34
|
-
const valueRef = useRef< Value >( restProps.value );
|
|
35
29
|
|
|
36
30
|
// TODO: Upstream limitation - The `required` attribute is not passed down to the input,
|
|
37
31
|
// so we need to set it manually.
|
|
@@ -51,9 +45,6 @@ const UnforwardedValidatedComboboxControl = (
|
|
|
51
45
|
required={ required }
|
|
52
46
|
markWhenOptional={ markWhenOptional }
|
|
53
47
|
ref={ mergedRefs }
|
|
54
|
-
onValidate={ () => {
|
|
55
|
-
return onValidate?.( valueRef.current );
|
|
56
|
-
} }
|
|
57
48
|
customValidity={ customValidity }
|
|
58
49
|
getValidityTarget={ () =>
|
|
59
50
|
validityTargetRef.current?.querySelector< HTMLInputElement >(
|
|
@@ -65,10 +56,6 @@ const UnforwardedValidatedComboboxControl = (
|
|
|
65
56
|
__nextHasNoMarginBottom
|
|
66
57
|
__next40pxDefaultSize
|
|
67
58
|
{ ...restProps }
|
|
68
|
-
onChange={ ( value ) => {
|
|
69
|
-
valueRef.current = value;
|
|
70
|
-
onChange?.( value );
|
|
71
|
-
} }
|
|
72
59
|
/>
|
|
73
60
|
</ControlWithError>
|
|
74
61
|
);
|
|
@@ -9,32 +9,21 @@ import { forwardRef, useRef } from '@wordpress/element';
|
|
|
9
9
|
import { ControlWithError } from '../control-with-error';
|
|
10
10
|
import type { ValidatedControlProps } from './types';
|
|
11
11
|
import CustomSelectControl from '../../custom-select-control';
|
|
12
|
-
import type {
|
|
13
|
-
CustomSelectOption,
|
|
14
|
-
CustomSelectProps,
|
|
15
|
-
} from '../../custom-select-control/types';
|
|
16
|
-
|
|
17
|
-
type CustomSelectControlProps = CustomSelectProps< CustomSelectOption >;
|
|
18
|
-
|
|
19
|
-
type Value = CustomSelectControlProps[ 'value' ];
|
|
20
12
|
|
|
21
13
|
const UnforwardedValidatedCustomSelectControl = (
|
|
22
14
|
{
|
|
23
15
|
required,
|
|
24
|
-
onValidate,
|
|
25
16
|
customValidity,
|
|
26
|
-
onChange,
|
|
27
17
|
markWhenOptional,
|
|
28
18
|
...restProps
|
|
29
19
|
}: Omit<
|
|
30
20
|
React.ComponentProps< typeof CustomSelectControl >,
|
|
31
21
|
'__next40pxDefaultSize'
|
|
32
22
|
> &
|
|
33
|
-
ValidatedControlProps
|
|
23
|
+
ValidatedControlProps,
|
|
34
24
|
forwardedRef: React.ForwardedRef< HTMLDivElement >
|
|
35
25
|
) => {
|
|
36
26
|
const validityTargetRef = useRef< HTMLSelectElement >( null );
|
|
37
|
-
const valueRef = useRef< Value >( restProps.value );
|
|
38
27
|
|
|
39
28
|
return (
|
|
40
29
|
<div
|
|
@@ -44,9 +33,6 @@ const UnforwardedValidatedCustomSelectControl = (
|
|
|
44
33
|
<ControlWithError
|
|
45
34
|
required={ required }
|
|
46
35
|
markWhenOptional={ markWhenOptional }
|
|
47
|
-
onValidate={ () => {
|
|
48
|
-
return onValidate?.( valueRef.current );
|
|
49
|
-
} }
|
|
50
36
|
customValidity={ customValidity }
|
|
51
37
|
getValidityTarget={ () => validityTargetRef.current }
|
|
52
38
|
>
|
|
@@ -54,10 +40,6 @@ const UnforwardedValidatedCustomSelectControl = (
|
|
|
54
40
|
// TODO: Upstream limitation - Required isn't passed down correctly,
|
|
55
41
|
// so it needs to be set on a delegate element.
|
|
56
42
|
__next40pxDefaultSize
|
|
57
|
-
onChange={ ( value ) => {
|
|
58
|
-
valueRef.current = value.selectedItem;
|
|
59
|
-
onChange?.( value );
|
|
60
|
-
} }
|
|
61
43
|
{ ...restProps }
|
|
62
44
|
/>
|
|
63
45
|
</ControlWithError>
|
|
@@ -9,27 +9,21 @@ import { forwardRef, useRef } from '@wordpress/element';
|
|
|
9
9
|
import { ControlWithError } from '../control-with-error';
|
|
10
10
|
import type { ValidatedControlProps } from './types';
|
|
11
11
|
import { FormTokenField } from '../../form-token-field';
|
|
12
|
-
import type { FormTokenFieldProps } from '../../form-token-field/types';
|
|
13
|
-
|
|
14
|
-
type Value = FormTokenFieldProps[ 'value' ];
|
|
15
12
|
|
|
16
13
|
const UnforwardedValidatedFormTokenField = (
|
|
17
14
|
{
|
|
18
15
|
required,
|
|
19
|
-
onValidate,
|
|
20
16
|
customValidity,
|
|
21
|
-
onChange,
|
|
22
17
|
markWhenOptional,
|
|
23
18
|
...restProps
|
|
24
19
|
}: Omit<
|
|
25
20
|
React.ComponentProps< typeof FormTokenField >,
|
|
26
|
-
'__next40pxDefaultSize'
|
|
21
|
+
'__next40pxDefaultSize'
|
|
27
22
|
> &
|
|
28
|
-
ValidatedControlProps
|
|
23
|
+
ValidatedControlProps,
|
|
29
24
|
forwardedRef: React.ForwardedRef< HTMLDivElement >
|
|
30
25
|
) => {
|
|
31
26
|
const validityTargetRef = useRef< HTMLInputElement >( null );
|
|
32
|
-
const valueRef = useRef< Value >( restProps.value );
|
|
33
27
|
|
|
34
28
|
return (
|
|
35
29
|
<div
|
|
@@ -39,21 +33,10 @@ const UnforwardedValidatedFormTokenField = (
|
|
|
39
33
|
<ControlWithError
|
|
40
34
|
required={ required }
|
|
41
35
|
markWhenOptional={ markWhenOptional }
|
|
42
|
-
onValidate={ () => {
|
|
43
|
-
return onValidate?.( valueRef.current );
|
|
44
|
-
} }
|
|
45
36
|
customValidity={ customValidity }
|
|
46
37
|
getValidityTarget={ () => validityTargetRef.current }
|
|
47
38
|
>
|
|
48
|
-
<FormTokenField
|
|
49
|
-
__next40pxDefaultSize
|
|
50
|
-
__nextHasNoMarginBottom
|
|
51
|
-
{ ...restProps }
|
|
52
|
-
onChange={ ( value, ...args ) => {
|
|
53
|
-
valueRef.current = value;
|
|
54
|
-
onChange?.( value, ...args );
|
|
55
|
-
} }
|
|
56
|
-
/>
|
|
39
|
+
<FormTokenField __next40pxDefaultSize { ...restProps } />
|
|
57
40
|
</ControlWithError>
|
|
58
41
|
<input
|
|
59
42
|
className="components-validated-control__error-delegate"
|
|
@@ -61,7 +44,7 @@ const UnforwardedValidatedFormTokenField = (
|
|
|
61
44
|
ref={ validityTargetRef }
|
|
62
45
|
required={ required }
|
|
63
46
|
value={
|
|
64
|
-
|
|
47
|
+
restProps.value && restProps.value.length > 0
|
|
65
48
|
? 'hasvalue'
|
|
66
49
|
: ''
|
|
67
50
|
}
|
|
@@ -10,46 +10,33 @@ import { useMergeRefs } from '@wordpress/compose';
|
|
|
10
10
|
import { ControlWithError } from '../control-with-error';
|
|
11
11
|
import type { ValidatedControlProps } from './types';
|
|
12
12
|
import InputControl from '../../input-control';
|
|
13
|
-
import type { InputControlProps } from '../../input-control/types';
|
|
14
|
-
|
|
15
|
-
type Value = InputControlProps[ 'value' ];
|
|
16
13
|
|
|
17
14
|
const UnforwardedValidatedInputControl = (
|
|
18
15
|
{
|
|
19
16
|
required,
|
|
20
|
-
onValidate,
|
|
21
17
|
customValidity,
|
|
22
|
-
onChange,
|
|
23
18
|
markWhenOptional,
|
|
24
19
|
...restProps
|
|
25
20
|
}: Omit<
|
|
26
21
|
React.ComponentProps< typeof InputControl >,
|
|
27
22
|
'__next40pxDefaultSize'
|
|
28
23
|
> &
|
|
29
|
-
ValidatedControlProps
|
|
24
|
+
ValidatedControlProps,
|
|
30
25
|
forwardedRef: React.ForwardedRef< HTMLInputElement >
|
|
31
26
|
) => {
|
|
32
27
|
const validityTargetRef = useRef< HTMLInputElement >( null );
|
|
33
28
|
const mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );
|
|
34
|
-
const valueRef = useRef< Value >( restProps.value );
|
|
35
29
|
|
|
36
30
|
return (
|
|
37
31
|
<ControlWithError
|
|
38
32
|
required={ required }
|
|
39
33
|
markWhenOptional={ markWhenOptional }
|
|
40
|
-
onValidate={ () => {
|
|
41
|
-
return onValidate?.( valueRef.current );
|
|
42
|
-
} }
|
|
43
34
|
customValidity={ customValidity }
|
|
44
35
|
getValidityTarget={ () => validityTargetRef.current }
|
|
45
36
|
>
|
|
46
37
|
<InputControl
|
|
47
38
|
__next40pxDefaultSize
|
|
48
39
|
ref={ mergedRefs }
|
|
49
|
-
onChange={ ( value, ...args ) => {
|
|
50
|
-
valueRef.current = value;
|
|
51
|
-
onChange?.( value, ...args );
|
|
52
|
-
} }
|
|
53
40
|
{ ...restProps }
|
|
54
41
|
/>
|
|
55
42
|
</ControlWithError>
|