@wordpress/components 25.13.0 → 25.14.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 +38 -1
- package/build/border-control/border-control-dropdown/component.js +4 -2
- package/build/border-control/border-control-dropdown/component.js.map +1 -1
- package/build/border-control/border-control-dropdown/hook.js +3 -2
- package/build/border-control/border-control-dropdown/hook.js.map +1 -1
- package/build/border-control/styles.js +17 -17
- package/build/border-control/styles.js.map +1 -1
- package/build/checkbox-control/index.js +1 -1
- package/build/checkbox-control/index.js.map +1 -1
- package/build/checkbox-control/types.js.map +1 -1
- package/build/date-time/time/timezone.js +11 -2
- package/build/date-time/time/timezone.js.map +1 -1
- package/build/dimension-control/index.js +2 -0
- package/build/dimension-control/index.js.map +1 -1
- package/build/dimension-control/types.js.map +1 -1
- package/build/dropdown-menu-v2-ariakit/styles.js +14 -14
- package/build/dropdown-menu-v2-ariakit/styles.js.map +1 -1
- package/build/focal-point-picker/controls.js +5 -1
- package/build/focal-point-picker/controls.js.map +1 -1
- package/build/focal-point-picker/index.js +2 -0
- package/build/focal-point-picker/index.js.map +1 -1
- package/build/focal-point-picker/styles/focal-point-picker-style.js +15 -15
- package/build/focal-point-picker/styles/focal-point-picker-style.js.map +1 -1
- package/build/focal-point-picker/types.js.map +1 -1
- package/build/font-size-picker/font-size-picker-select.js +2 -0
- package/build/font-size-picker/font-size-picker-select.js.map +1 -1
- package/build/font-size-picker/font-size-picker-toggle-group.js +2 -0
- package/build/font-size-picker/font-size-picker-toggle-group.js.map +1 -1
- package/build/font-size-picker/index.js +6 -1
- package/build/font-size-picker/index.js.map +1 -1
- package/build/font-size-picker/types.js.map +1 -1
- package/build/index.native.js +0 -16
- package/build/index.native.js.map +1 -1
- package/build/mobile/global-styles-context/utils.native.js +13 -0
- package/build/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build/palette-edit/index.js +21 -1
- package/build/palette-edit/index.js.map +1 -1
- package/build/query-controls/author-select.js +3 -1
- package/build/query-controls/author-select.js.map +1 -1
- package/build/query-controls/category-select.js +3 -1
- package/build/query-controls/category-select.js.map +1 -1
- package/build/query-controls/index.js +6 -1
- package/build/query-controls/index.js.map +1 -1
- package/build/query-controls/types.js.map +1 -1
- package/build/tabs/index.js +18 -1
- package/build/tabs/index.js.map +1 -1
- package/build/tabs/tab.js +2 -2
- package/build/tabs/tab.js.map +1 -1
- package/build/tabs/tabpanel.js +3 -2
- package/build/tabs/tabpanel.js.map +1 -1
- package/build/tabs/types.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/utils.js +17 -17
- package/build/toggle-group-control/toggle-group-control/utils.js.map +1 -1
- package/build/tools-panel/tools-panel-item/hook.js +11 -11
- package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/component.js +4 -2
- package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/hook.js +3 -2
- package/build-module/border-control/border-control-dropdown/hook.js.map +1 -1
- package/build-module/border-control/styles.js +17 -17
- package/build-module/border-control/styles.js.map +1 -1
- package/build-module/checkbox-control/index.js +1 -1
- package/build-module/checkbox-control/index.js.map +1 -1
- package/build-module/checkbox-control/types.js.map +1 -1
- package/build-module/date-time/time/timezone.js +11 -2
- package/build-module/date-time/time/timezone.js.map +1 -1
- package/build-module/dimension-control/index.js +2 -0
- package/build-module/dimension-control/index.js.map +1 -1
- package/build-module/dimension-control/types.js.map +1 -1
- package/build-module/dropdown-menu-v2-ariakit/styles.js +14 -14
- package/build-module/dropdown-menu-v2-ariakit/styles.js.map +1 -1
- package/build-module/focal-point-picker/controls.js +5 -1
- package/build-module/focal-point-picker/controls.js.map +1 -1
- package/build-module/focal-point-picker/index.js +2 -0
- package/build-module/focal-point-picker/index.js.map +1 -1
- package/build-module/focal-point-picker/styles/focal-point-picker-style.js +15 -15
- package/build-module/focal-point-picker/styles/focal-point-picker-style.js.map +1 -1
- package/build-module/focal-point-picker/types.js.map +1 -1
- package/build-module/font-size-picker/font-size-picker-select.js +2 -0
- package/build-module/font-size-picker/font-size-picker-select.js.map +1 -1
- package/build-module/font-size-picker/font-size-picker-toggle-group.js +2 -0
- package/build-module/font-size-picker/font-size-picker-toggle-group.js.map +1 -1
- package/build-module/font-size-picker/index.js +6 -1
- package/build-module/font-size-picker/index.js.map +1 -1
- package/build-module/font-size-picker/types.js.map +1 -1
- package/build-module/index.native.js +0 -2
- package/build-module/index.native.js.map +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js +13 -0
- package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build-module/palette-edit/index.js +20 -3
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/query-controls/author-select.js +3 -1
- package/build-module/query-controls/author-select.js.map +1 -1
- package/build-module/query-controls/category-select.js +3 -1
- package/build-module/query-controls/category-select.js.map +1 -1
- package/build-module/query-controls/index.js +6 -1
- package/build-module/query-controls/index.js.map +1 -1
- package/build-module/query-controls/types.js.map +1 -1
- package/build-module/tabs/index.js +18 -1
- package/build-module/tabs/index.js.map +1 -1
- package/build-module/tabs/tab.js +2 -2
- package/build-module/tabs/tab.js.map +1 -1
- package/build-module/tabs/tabpanel.js +3 -2
- package/build-module/tabs/tabpanel.js.map +1 -1
- package/build-module/tabs/types.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/utils.js +17 -17
- package/build-module/toggle-group-control/toggle-group-control/utils.js.map +1 -1
- package/build-module/tools-panel/tools-panel-item/hook.js +11 -11
- package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build-style/style-rtl.css +1 -1
- package/build-style/style.css +1 -1
- package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/hook.d.ts +1 -0
- package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
- package/build-types/border-control/styles.d.ts +1 -1
- package/build-types/border-control/styles.d.ts.map +1 -1
- package/build-types/checkbox-control/index.d.ts.map +1 -1
- package/build-types/checkbox-control/types.d.ts +3 -2
- package/build-types/checkbox-control/types.d.ts.map +1 -1
- package/build-types/date-time/time/timezone.d.ts.map +1 -1
- package/build-types/dimension-control/index.d.ts.map +1 -1
- package/build-types/dimension-control/types.d.ts +6 -0
- package/build-types/dimension-control/types.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2-ariakit/styles.d.ts.map +1 -1
- package/build-types/focal-point-picker/controls.d.ts +1 -1
- package/build-types/focal-point-picker/controls.d.ts.map +1 -1
- package/build-types/focal-point-picker/index.d.ts +1 -1
- package/build-types/focal-point-picker/index.d.ts.map +1 -1
- package/build-types/focal-point-picker/stories/index.story.d.ts +8 -4
- package/build-types/focal-point-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/focal-point-picker/types.d.ts +7 -0
- package/build-types/focal-point-picker/types.d.ts.map +1 -1
- package/build-types/font-size-picker/font-size-picker-select.d.ts.map +1 -1
- package/build-types/font-size-picker/font-size-picker-toggle-group.d.ts.map +1 -1
- package/build-types/font-size-picker/index.d.ts.map +1 -1
- package/build-types/font-size-picker/types.d.ts +8 -1
- package/build-types/font-size-picker/types.d.ts.map +1 -1
- package/build-types/palette-edit/index.d.ts +6 -1
- package/build-types/palette-edit/index.d.ts.map +1 -1
- package/build-types/query-controls/author-select.d.ts +1 -1
- package/build-types/query-controls/author-select.d.ts.map +1 -1
- package/build-types/query-controls/category-select.d.ts +1 -1
- package/build-types/query-controls/category-select.d.ts.map +1 -1
- package/build-types/query-controls/index.d.ts +1 -1
- package/build-types/query-controls/index.d.ts.map +1 -1
- package/build-types/query-controls/types.d.ts +9 -0
- package/build-types/query-controls/types.d.ts.map +1 -1
- package/build-types/tabs/index.d.ts +2 -2
- package/build-types/tabs/index.d.ts.map +1 -1
- package/build-types/tabs/tab.d.ts +2 -1
- package/build-types/tabs/tab.d.ts.map +1 -1
- package/build-types/tabs/tabpanel.d.ts +2 -1
- package/build-types/tabs/tabpanel.d.ts.map +1 -1
- package/build-types/tabs/types.d.ts +8 -3
- package/build-types/tabs/types.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/utils.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
- package/package.json +19 -19
- package/src/border-control/border-control-dropdown/component.tsx +3 -1
- package/src/border-control/border-control-dropdown/hook.ts +3 -2
- package/src/border-control/styles.ts +2 -9
- package/src/checkbox-control/README.md +2 -1
- package/src/checkbox-control/index.tsx +8 -6
- package/src/checkbox-control/test/__snapshots__/index.tsx.snap +3 -8
- package/src/checkbox-control/test/index.tsx +7 -0
- package/src/checkbox-control/types.ts +3 -2
- package/src/custom-select-control/test/index.js +367 -35
- package/src/date-time/time/timezone.tsx +15 -3
- package/src/dimension-control/index.tsx +2 -0
- package/src/dimension-control/test/__snapshots__/index.test.js.snap +2 -2
- package/src/dimension-control/types.ts +6 -0
- package/src/dropdown-menu-v2-ariakit/styles.ts +12 -0
- package/src/focal-point-picker/controls.tsx +4 -0
- package/src/focal-point-picker/index.tsx +2 -0
- package/src/focal-point-picker/styles/focal-point-picker-style.ts +1 -1
- package/src/focal-point-picker/types.ts +7 -0
- package/src/font-size-picker/font-size-picker-select.tsx +2 -0
- package/src/font-size-picker/font-size-picker-toggle-group.tsx +9 -1
- package/src/font-size-picker/index.tsx +11 -3
- package/src/font-size-picker/types.ts +8 -1
- package/src/form-toggle/style.scss +4 -2
- package/src/index.native.js +0 -2
- package/src/mobile/global-styles-context/test/utils.native.js +22 -0
- package/src/mobile/global-styles-context/utils.native.js +14 -0
- package/src/mobile/link-settings/style.native.scss +0 -17
- package/src/palette-edit/index.tsx +22 -8
- package/src/palette-edit/style.scss +2 -2
- package/src/palette-edit/test/index.tsx +75 -1
- package/src/query-controls/author-select.tsx +2 -0
- package/src/query-controls/category-select.tsx +2 -0
- package/src/query-controls/index.tsx +6 -1
- package/src/query-controls/types.ts +9 -0
- package/src/search-control/README.md +2 -0
- package/src/spinner/README.md +2 -0
- package/src/tabs/README.md +4 -4
- package/src/tabs/index.tsx +22 -1
- package/src/tabs/stories/index.story.tsx +48 -48
- package/src/tabs/tab.tsx +3 -3
- package/src/tabs/tabpanel.tsx +7 -3
- package/src/tabs/test/index.tsx +180 -106
- package/src/tabs/types.ts +8 -3
- package/src/toggle-group-control/test/index.tsx +54 -1
- package/src/toggle-group-control/toggle-group-control/utils.ts +15 -20
- package/src/tools-panel/tools-panel-item/hook.ts +10 -21
- package/tsconfig.tsbuildinfo +1 -1
- package/build/mobile/inserter-button/index.native.js +0 -98
- package/build/mobile/inserter-button/index.native.js.map +0 -1
- package/build/mobile/inserter-button/sparkles.js +0 -23
- package/build/mobile/inserter-button/sparkles.js.map +0 -1
- package/build/mobile/link-settings/image-link-destinations-screen.native.js +0 -119
- package/build/mobile/link-settings/image-link-destinations-screen.native.js.map +0 -1
- package/build-module/mobile/inserter-button/index.native.js +0 -89
- package/build-module/mobile/inserter-button/index.native.js.map +0 -1
- package/build-module/mobile/inserter-button/sparkles.js +0 -15
- package/build-module/mobile/inserter-button/sparkles.js.map +0 -1
- package/build-module/mobile/link-settings/image-link-destinations-screen.native.js +0 -110
- package/build-module/mobile/link-settings/image-link-destinations-screen.native.js.map +0 -1
- package/build-types/mobile/inserter-button/sparkles.d.ts +0 -3
- package/build-types/mobile/inserter-button/sparkles.d.ts.map +0 -1
- package/src/mobile/inserter-button/README.md +0 -62
- package/src/mobile/inserter-button/index.native.js +0 -116
- package/src/mobile/inserter-button/sparkles.js +0 -15
- package/src/mobile/inserter-button/style.native.scss +0 -72
- package/src/mobile/link-settings/image-link-destinations-screen.native.js +0 -152
|
@@ -45,6 +45,7 @@ const UnforwardedFontSizePicker = (
|
|
|
45
45
|
const {
|
|
46
46
|
/** Start opting into the new margin-free styles that will become the default in a future version. */
|
|
47
47
|
__nextHasNoMarginBottom = false,
|
|
48
|
+
__next40pxDefaultSize = false,
|
|
48
49
|
fallbackFontSize,
|
|
49
50
|
fontSizes = [],
|
|
50
51
|
disableCustomFontSizes = false,
|
|
@@ -165,6 +166,7 @@ const UnforwardedFontSizePicker = (
|
|
|
165
166
|
shouldUseSelectControl &&
|
|
166
167
|
! showCustomValueControl && (
|
|
167
168
|
<FontSizePickerSelect
|
|
169
|
+
__next40pxDefaultSize={ __next40pxDefaultSize }
|
|
168
170
|
fontSizes={ fontSizes }
|
|
169
171
|
value={ value }
|
|
170
172
|
disableCustomFontSizes={ disableCustomFontSizes }
|
|
@@ -194,6 +196,7 @@ const UnforwardedFontSizePicker = (
|
|
|
194
196
|
fontSizes={ fontSizes }
|
|
195
197
|
value={ value }
|
|
196
198
|
__nextHasNoMarginBottom={ __nextHasNoMarginBottom }
|
|
199
|
+
__next40pxDefaultSize={ __next40pxDefaultSize }
|
|
197
200
|
size={ size }
|
|
198
201
|
onChange={ ( newValue ) => {
|
|
199
202
|
if ( newValue === undefined ) {
|
|
@@ -214,6 +217,7 @@ const UnforwardedFontSizePicker = (
|
|
|
214
217
|
<Flex className="components-font-size-picker__custom-size-control">
|
|
215
218
|
<FlexItem isBlock>
|
|
216
219
|
<UnitControl
|
|
220
|
+
__next40pxDefaultSize={ __next40pxDefaultSize }
|
|
217
221
|
label={ __( 'Custom' ) }
|
|
218
222
|
labelPosition="top"
|
|
219
223
|
hideLabelFromVision
|
|
@@ -241,6 +245,9 @@ const UnforwardedFontSizePicker = (
|
|
|
241
245
|
__nextHasNoMarginBottom={
|
|
242
246
|
__nextHasNoMarginBottom
|
|
243
247
|
}
|
|
248
|
+
__next40pxDefaultSize={
|
|
249
|
+
__next40pxDefaultSize
|
|
250
|
+
}
|
|
244
251
|
className="components-font-size-picker__custom-input"
|
|
245
252
|
label={ __( 'Custom Size' ) }
|
|
246
253
|
hideLabelFromVision
|
|
@@ -276,9 +283,10 @@ const UnforwardedFontSizePicker = (
|
|
|
276
283
|
variant="secondary"
|
|
277
284
|
__next40pxDefaultSize
|
|
278
285
|
size={
|
|
279
|
-
size
|
|
280
|
-
|
|
281
|
-
|
|
286
|
+
size === '__unstable-large' ||
|
|
287
|
+
props.__next40pxDefaultSize
|
|
288
|
+
? 'default'
|
|
289
|
+
: 'small'
|
|
282
290
|
}
|
|
283
291
|
>
|
|
284
292
|
{ __( 'Reset' ) }
|
|
@@ -57,6 +57,12 @@ export type FontSizePickerProps = {
|
|
|
57
57
|
* @default false
|
|
58
58
|
*/
|
|
59
59
|
__nextHasNoMarginBottom?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Start opting into the larger default height that will become the default size in a future version.
|
|
62
|
+
*
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
__next40pxDefaultSize?: boolean;
|
|
60
66
|
/**
|
|
61
67
|
* Size of the control.
|
|
62
68
|
*
|
|
@@ -93,6 +99,7 @@ export type FontSizePickerSelectProps = Pick<
|
|
|
93
99
|
>;
|
|
94
100
|
onChange: NonNullable< FontSizePickerProps[ 'onChange' ] >;
|
|
95
101
|
onSelectCustom: () => void;
|
|
102
|
+
__next40pxDefaultSize: boolean;
|
|
96
103
|
};
|
|
97
104
|
|
|
98
105
|
export type FontSizePickerSelectOption = {
|
|
@@ -104,7 +111,7 @@ export type FontSizePickerSelectOption = {
|
|
|
104
111
|
|
|
105
112
|
export type FontSizePickerToggleGroupProps = Pick<
|
|
106
113
|
FontSizePickerProps,
|
|
107
|
-
'value' | 'size' | '__nextHasNoMarginBottom'
|
|
114
|
+
'value' | 'size' | '__nextHasNoMarginBottom' | '__next40pxDefaultSize'
|
|
108
115
|
> & {
|
|
109
116
|
fontSizes: NonNullable< FontSizePickerProps[ 'fontSizes' ] >;
|
|
110
117
|
onChange: NonNullable< FontSizePickerProps[ 'onChange' ] >;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@use "sass:math";
|
|
2
|
+
|
|
1
3
|
$toggle-width: 36px;
|
|
2
4
|
$toggle-height: 18px;
|
|
3
5
|
$toggle-border-width: 1px;
|
|
@@ -20,7 +22,7 @@ $transition-duration: 0.2s;
|
|
|
20
22
|
border: $toggle-border-width solid $gray-900;
|
|
21
23
|
width: $toggle-width;
|
|
22
24
|
height: $toggle-height;
|
|
23
|
-
border-radius: $toggle-height
|
|
25
|
+
border-radius: math.div($toggle-height, 2);
|
|
24
26
|
transition:
|
|
25
27
|
$transition-duration background-color ease,
|
|
26
28
|
$transition-duration border-color ease;
|
|
@@ -59,7 +61,7 @@ $transition-duration: 0.2s;
|
|
|
59
61
|
background-color: $gray-900;
|
|
60
62
|
|
|
61
63
|
// Transparent border acts as a fill in Windows High Contrast Mode.
|
|
62
|
-
border: $thumb-size
|
|
64
|
+
border: math.div($thumb-size, 2) solid transparent;
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
// Checked state.
|
package/src/index.native.js
CHANGED
|
@@ -106,11 +106,9 @@ export { default as LinkPickerScreen } from './mobile/link-picker/link-picker-sc
|
|
|
106
106
|
export { default as LinkSettings } from './mobile/link-settings';
|
|
107
107
|
export { default as LinkSettingsScreen } from './mobile/link-settings/link-settings-screen';
|
|
108
108
|
export { default as LinkSettingsNavigation } from './mobile/link-settings/link-settings-navigation';
|
|
109
|
-
export { default as ImageLinkDestinationsScreen } from './mobile/link-settings/image-link-destinations-screen';
|
|
110
109
|
export { default as SegmentedControl } from './mobile/segmented-control';
|
|
111
110
|
export { default as Image, IMAGE_DEFAULT_FOCAL_POINT } from './mobile/image';
|
|
112
111
|
export { default as ImageEditingButton } from './mobile/image/image-editing-button';
|
|
113
|
-
export { default as InserterButton } from './mobile/inserter-button';
|
|
114
112
|
export { setClipboard, getClipboard } from './mobile/clipboard';
|
|
115
113
|
export { default as AudioPlayer } from './mobile/audio-player';
|
|
116
114
|
export { default as Badge } from './mobile/badge';
|
|
@@ -108,6 +108,28 @@ describe( 'parseStylesVariables', () => {
|
|
|
108
108
|
expect.objectContaining( PARSED_GLOBAL_STYLES )
|
|
109
109
|
);
|
|
110
110
|
} );
|
|
111
|
+
|
|
112
|
+
it( 'returns the parsed custom color values correctly', () => {
|
|
113
|
+
const defaultStyles = {
|
|
114
|
+
...DEFAULT_GLOBAL_STYLES,
|
|
115
|
+
color: {
|
|
116
|
+
text: 'var(--wp--custom--color--blue)',
|
|
117
|
+
background: 'var(--wp--custom--color--green)',
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
const customValues = parseStylesVariables(
|
|
121
|
+
JSON.stringify( RAW_FEATURES.custom ),
|
|
122
|
+
MAPPED_VALUES
|
|
123
|
+
);
|
|
124
|
+
const styles = parseStylesVariables(
|
|
125
|
+
JSON.stringify( defaultStyles ),
|
|
126
|
+
MAPPED_VALUES,
|
|
127
|
+
customValues
|
|
128
|
+
);
|
|
129
|
+
expect( styles ).toEqual(
|
|
130
|
+
expect.objectContaining( PARSED_GLOBAL_STYLES )
|
|
131
|
+
);
|
|
132
|
+
} );
|
|
111
133
|
} );
|
|
112
134
|
|
|
113
135
|
describe( 'getGlobalStyles', () => {
|
|
@@ -248,6 +248,20 @@ export function parseStylesVariables( styles, mappedValues, customValues ) {
|
|
|
248
248
|
const customValuesData = customValues ?? JSON.parse( stylesBase );
|
|
249
249
|
stylesBase = stylesBase.replace( regex, ( _$1, $2 ) => {
|
|
250
250
|
const path = $2.split( '--' );
|
|
251
|
+
|
|
252
|
+
// Supports cases for variables like var(--wp--custom--color--background)
|
|
253
|
+
if ( path[ 0 ] === 'color' ) {
|
|
254
|
+
const colorKey = path[ path.length - 1 ];
|
|
255
|
+
if ( mappedValues?.color ) {
|
|
256
|
+
const matchedValue = mappedValues.color?.values?.find(
|
|
257
|
+
( { slug } ) => slug === colorKey
|
|
258
|
+
);
|
|
259
|
+
if ( matchedValue ) {
|
|
260
|
+
return `${ matchedValue?.color }`;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
251
265
|
if (
|
|
252
266
|
path.reduce(
|
|
253
267
|
( prev, curr ) => prev && prev[ curr ],
|
|
@@ -2,20 +2,3 @@
|
|
|
2
2
|
padding-left: 0;
|
|
3
3
|
padding-right: 0;
|
|
4
4
|
}
|
|
5
|
-
|
|
6
|
-
// used in both light and dark modes
|
|
7
|
-
.placeholderTextColor {
|
|
8
|
-
color: #87a6bc;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.optionIcon {
|
|
12
|
-
color: $blue-50;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.optionIconDark {
|
|
16
|
-
color: $blue-30;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.unselectedOptionIcon {
|
|
20
|
-
opacity: 0;
|
|
21
|
-
}
|
|
@@ -60,7 +60,7 @@ import type {
|
|
|
60
60
|
PaletteElement,
|
|
61
61
|
} from './types';
|
|
62
62
|
|
|
63
|
-
const DEFAULT_COLOR = '#000';
|
|
63
|
+
export const DEFAULT_COLOR = '#000';
|
|
64
64
|
|
|
65
65
|
function NameInput( { value, onChange, label }: NameInputProps ) {
|
|
66
66
|
return (
|
|
@@ -261,16 +261,30 @@ function Option< T extends Color | Gradient >( {
|
|
|
261
261
|
);
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
-
|
|
264
|
+
/**
|
|
265
|
+
* Checks if a color or gradient is a temporary element by testing against default values.
|
|
266
|
+
*/
|
|
267
|
+
export function isTemporaryElement(
|
|
265
268
|
slugPrefix: string,
|
|
266
269
|
{ slug, color, gradient }: Color | Gradient
|
|
267
|
-
) {
|
|
270
|
+
): Boolean {
|
|
268
271
|
const regex = new RegExp( `^${ slugPrefix }color-([\\d]+)$` );
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
272
|
+
|
|
273
|
+
// If the slug matches the temporary name regex,
|
|
274
|
+
// check if the color or gradient matches the default value.
|
|
275
|
+
if ( regex.test( slug ) ) {
|
|
276
|
+
// The order is important as gradient elements
|
|
277
|
+
// contain a color property.
|
|
278
|
+
if ( !! gradient ) {
|
|
279
|
+
return gradient === DEFAULT_GRADIENT;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if ( !! color ) {
|
|
283
|
+
return color === DEFAULT_COLOR;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return false;
|
|
274
288
|
}
|
|
275
289
|
|
|
276
290
|
function PaletteEditListView< T extends Color | Gradient >( {
|
|
@@ -6,8 +6,13 @@ import { render, fireEvent, screen } from '@testing-library/react';
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
-
import PaletteEdit, {
|
|
9
|
+
import PaletteEdit, {
|
|
10
|
+
getNameForPosition,
|
|
11
|
+
isTemporaryElement,
|
|
12
|
+
DEFAULT_COLOR,
|
|
13
|
+
} from '..';
|
|
10
14
|
import type { PaletteElement } from '../types';
|
|
15
|
+
import { DEFAULT_GRADIENT } from '../../custom-gradient-picker/constants';
|
|
11
16
|
|
|
12
17
|
describe( 'getNameForPosition', () => {
|
|
13
18
|
test( 'should return 1 by default', () => {
|
|
@@ -80,6 +85,75 @@ describe( 'getNameForPosition', () => {
|
|
|
80
85
|
} );
|
|
81
86
|
} );
|
|
82
87
|
|
|
88
|
+
describe( 'isTemporaryElement', () => {
|
|
89
|
+
[
|
|
90
|
+
{
|
|
91
|
+
message: 'identifies temporary color',
|
|
92
|
+
slug: 'test-',
|
|
93
|
+
obj: {
|
|
94
|
+
name: '',
|
|
95
|
+
slug: 'test-color-1',
|
|
96
|
+
color: DEFAULT_COLOR,
|
|
97
|
+
},
|
|
98
|
+
expected: true,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
message: 'identifies temporary gradient',
|
|
102
|
+
slug: 'test-',
|
|
103
|
+
obj: {
|
|
104
|
+
name: '',
|
|
105
|
+
slug: 'test-color-1',
|
|
106
|
+
gradient: DEFAULT_GRADIENT,
|
|
107
|
+
},
|
|
108
|
+
expected: true,
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
message: 'identifies custom color slug',
|
|
112
|
+
slug: 'test-',
|
|
113
|
+
obj: {
|
|
114
|
+
name: '',
|
|
115
|
+
slug: 'test-color-happy',
|
|
116
|
+
color: DEFAULT_COLOR,
|
|
117
|
+
},
|
|
118
|
+
expected: false,
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
message: 'identifies custom color value',
|
|
122
|
+
slug: 'test-',
|
|
123
|
+
obj: {
|
|
124
|
+
name: '',
|
|
125
|
+
slug: 'test-color-1',
|
|
126
|
+
color: '#ccc',
|
|
127
|
+
},
|
|
128
|
+
expected: false,
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
message: 'identifies custom gradient slug',
|
|
132
|
+
slug: 'test-',
|
|
133
|
+
obj: {
|
|
134
|
+
name: '',
|
|
135
|
+
slug: 'test-gradient-joy',
|
|
136
|
+
color: DEFAULT_GRADIENT,
|
|
137
|
+
},
|
|
138
|
+
expected: false,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
message: 'identifies custom gradient value',
|
|
142
|
+
slug: 'test-',
|
|
143
|
+
obj: {
|
|
144
|
+
name: '',
|
|
145
|
+
slug: 'test-color-3',
|
|
146
|
+
color: 'linear-gradient(90deg, rgba(22, 22, 22, 1) 0%, rgb(155, 81, 224) 100%)',
|
|
147
|
+
},
|
|
148
|
+
expected: false,
|
|
149
|
+
},
|
|
150
|
+
].forEach( ( { message, slug, obj, expected } ) => {
|
|
151
|
+
it( `should ${ message }`, () => {
|
|
152
|
+
expect( isTemporaryElement( slug, obj ) ).toBe( expected );
|
|
153
|
+
} );
|
|
154
|
+
} );
|
|
155
|
+
} );
|
|
156
|
+
|
|
83
157
|
describe( 'PaletteEdit', () => {
|
|
84
158
|
const defaultProps = {
|
|
85
159
|
colors: [ { color: '#ffffff', name: 'Base', slug: 'base' } ],
|
|
@@ -6,6 +6,7 @@ import TreeSelect from '../tree-select';
|
|
|
6
6
|
import type { AuthorSelectProps } from './types';
|
|
7
7
|
|
|
8
8
|
export default function AuthorSelect( {
|
|
9
|
+
__next40pxDefaultSize,
|
|
9
10
|
label,
|
|
10
11
|
noOptionLabel,
|
|
11
12
|
authorList,
|
|
@@ -28,6 +29,7 @@ export default function AuthorSelect( {
|
|
|
28
29
|
: undefined
|
|
29
30
|
}
|
|
30
31
|
__nextHasNoMarginBottom
|
|
32
|
+
__next40pxDefaultSize={ __next40pxDefaultSize }
|
|
31
33
|
/>
|
|
32
34
|
);
|
|
33
35
|
}
|
|
@@ -11,6 +11,7 @@ import { useMemo } from '@wordpress/element';
|
|
|
11
11
|
import type { CategorySelectProps } from './types';
|
|
12
12
|
|
|
13
13
|
export default function CategorySelect( {
|
|
14
|
+
__next40pxDefaultSize,
|
|
14
15
|
label,
|
|
15
16
|
noOptionLabel,
|
|
16
17
|
categoriesList,
|
|
@@ -37,6 +38,7 @@ export default function CategorySelect( {
|
|
|
37
38
|
}
|
|
38
39
|
{ ...props }
|
|
39
40
|
__nextHasNoMarginBottom
|
|
41
|
+
__next40pxDefaultSize={ __next40pxDefaultSize }
|
|
40
42
|
/>
|
|
41
43
|
);
|
|
42
44
|
}
|
|
@@ -60,6 +60,7 @@ function isMultipleCategorySelection(
|
|
|
60
60
|
* ```
|
|
61
61
|
*/
|
|
62
62
|
export function QueryControls( {
|
|
63
|
+
__next40pxDefaultSize = false,
|
|
63
64
|
authorList,
|
|
64
65
|
selectedAuthorId,
|
|
65
66
|
numberOfItems,
|
|
@@ -81,6 +82,7 @@ export function QueryControls( {
|
|
|
81
82
|
onOrderChange && onOrderByChange && (
|
|
82
83
|
<SelectControl
|
|
83
84
|
__nextHasNoMarginBottom
|
|
85
|
+
__next40pxDefaultSize={ __next40pxDefaultSize }
|
|
84
86
|
key="query-controls-order-select"
|
|
85
87
|
label={ __( 'Order by' ) }
|
|
86
88
|
value={ `${ orderBy }/${ order }` }
|
|
@@ -131,6 +133,7 @@ export function QueryControls( {
|
|
|
131
133
|
props.categoriesList &&
|
|
132
134
|
props.onCategoryChange && (
|
|
133
135
|
<CategorySelect
|
|
136
|
+
__next40pxDefaultSize={ __next40pxDefaultSize }
|
|
134
137
|
key="query-controls-category-select"
|
|
135
138
|
categoriesList={ props.categoriesList }
|
|
136
139
|
label={ __( 'Category' ) }
|
|
@@ -143,6 +146,7 @@ export function QueryControls( {
|
|
|
143
146
|
props.categorySuggestions &&
|
|
144
147
|
props.onCategoryChange && (
|
|
145
148
|
<FormTokenField
|
|
149
|
+
__next40pxDefaultSize={ __next40pxDefaultSize }
|
|
146
150
|
__nextHasNoMarginBottom
|
|
147
151
|
key="query-controls-categories-select"
|
|
148
152
|
label={ __( 'Categories' ) }
|
|
@@ -166,6 +170,7 @@ export function QueryControls( {
|
|
|
166
170
|
),
|
|
167
171
|
onAuthorChange && (
|
|
168
172
|
<AuthorSelect
|
|
173
|
+
__next40pxDefaultSize={ __next40pxDefaultSize }
|
|
169
174
|
key="query-controls-author-select"
|
|
170
175
|
authorList={ authorList }
|
|
171
176
|
label={ __( 'Author' ) }
|
|
@@ -177,7 +182,7 @@ export function QueryControls( {
|
|
|
177
182
|
onNumberOfItemsChange && (
|
|
178
183
|
<RangeControl
|
|
179
184
|
__nextHasNoMarginBottom
|
|
180
|
-
__next40pxDefaultSize
|
|
185
|
+
__next40pxDefaultSize={ __next40pxDefaultSize }
|
|
181
186
|
key="query-controls-range-control"
|
|
182
187
|
label={ __( 'Number of items' ) }
|
|
183
188
|
value={ numberOfItems }
|
|
@@ -31,6 +31,7 @@ export type CategorySelectProps = Pick<
|
|
|
31
31
|
categoriesList: Category[];
|
|
32
32
|
onChange: ( newCategory: string ) => void;
|
|
33
33
|
selectedCategoryId?: Category[ 'id' ];
|
|
34
|
+
__next40pxDefaultSize: boolean;
|
|
34
35
|
};
|
|
35
36
|
|
|
36
37
|
export type AuthorSelectProps = Pick<
|
|
@@ -40,6 +41,7 @@ export type AuthorSelectProps = Pick<
|
|
|
40
41
|
authorList?: Author[];
|
|
41
42
|
onChange: ( newAuthor: string ) => void;
|
|
42
43
|
selectedAuthorId?: Author[ 'id' ];
|
|
44
|
+
__next40pxDefaultSize: boolean;
|
|
43
45
|
};
|
|
44
46
|
|
|
45
47
|
type Order = 'asc' | 'desc';
|
|
@@ -101,6 +103,13 @@ type BaseQueryControlsProps = {
|
|
|
101
103
|
* The selected author ID.
|
|
102
104
|
*/
|
|
103
105
|
selectedAuthorId?: AuthorSelectProps[ 'selectedAuthorId' ];
|
|
106
|
+
/**
|
|
107
|
+
* Start opting into the larger default height that will become the
|
|
108
|
+
* default size in a future version.
|
|
109
|
+
*
|
|
110
|
+
* @default false
|
|
111
|
+
*/
|
|
112
|
+
__next40pxDefaultSize?: boolean;
|
|
104
113
|
};
|
|
105
114
|
|
|
106
115
|
export type QueryControlsWithSingleCategorySelectionProps =
|
|
@@ -8,6 +8,8 @@ SearchControl components let users display a search control.
|
|
|
8
8
|
1. [Development guidelines](#development-guidelines)
|
|
9
9
|
2. [Related components](#related-components)
|
|
10
10
|
|
|
11
|
+
Check out the [Storybook page](https://wordpress.github.io/gutenberg/?path=/docs/components-searchcontrol--docs) for a visual exploration of this component.
|
|
12
|
+
|
|
11
13
|
## Development guidelines
|
|
12
14
|
|
|
13
15
|
### Usage
|
package/src/spinner/README.md
CHANGED
|
@@ -17,3 +17,5 @@ function Example() {
|
|
|
17
17
|
The spinner component should:
|
|
18
18
|
|
|
19
19
|
- Signal to users that the processing of their request is underway and will soon complete.
|
|
20
|
+
|
|
21
|
+
Check out the [Storybook page](https://wordpress.github.io/gutenberg/?path=/docs/components-spinner--docs) for a visual exploration of this component.
|
package/src/tabs/README.md
CHANGED
|
@@ -163,9 +163,9 @@ The children elements, which should be a series of `Tabs.TabPanel` components.
|
|
|
163
163
|
|
|
164
164
|
##### Props
|
|
165
165
|
|
|
166
|
-
###### `
|
|
166
|
+
###### `tabId`: `string`
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
A unique identifier for the tab, which is used to generate a unique id for the underlying element. The value of this prop should match with the value of the `tabId` prop on the corresponding `Tabs.TabPanel` component.
|
|
169
169
|
|
|
170
170
|
- Required: Yes
|
|
171
171
|
|
|
@@ -198,9 +198,9 @@ The children elements, generally the content to display on the tabpanel.
|
|
|
198
198
|
|
|
199
199
|
- Required: No
|
|
200
200
|
|
|
201
|
-
###### `
|
|
201
|
+
###### `tabId`: `string`
|
|
202
202
|
|
|
203
|
-
|
|
203
|
+
A unique identifier for the tabpanel, which is used to generate an instanced id for the underlying element. The value of this prop should match with the value of the `tabId` prop on the corresponding `Tabs.Tab` component.
|
|
204
204
|
|
|
205
205
|
- Required: Yes
|
|
206
206
|
|
package/src/tabs/index.tsx
CHANGED
|
@@ -45,7 +45,7 @@ function Tabs( {
|
|
|
45
45
|
const isControlled = selectedTabId !== undefined;
|
|
46
46
|
|
|
47
47
|
const { items, selectedId } = store.useState();
|
|
48
|
-
const { setSelectedId } = store;
|
|
48
|
+
const { setSelectedId, move } = store;
|
|
49
49
|
|
|
50
50
|
// Keep track of whether tabs have been populated. This is used to prevent
|
|
51
51
|
// certain effects from firing too early while tab data and relevant
|
|
@@ -154,6 +154,27 @@ function Tabs( {
|
|
|
154
154
|
setSelectedId,
|
|
155
155
|
] );
|
|
156
156
|
|
|
157
|
+
// In controlled mode, make sure browser focus follows the selected tab if
|
|
158
|
+
// the selection is changed while a tab is already being focused.
|
|
159
|
+
useLayoutEffect( () => {
|
|
160
|
+
if ( ! isControlled || ! selectOnMove ) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const currentItem = items.find( ( item ) => item.id === selectedId );
|
|
164
|
+
const activeElement = currentItem?.element?.ownerDocument.activeElement;
|
|
165
|
+
const tabsHasFocus = items.some( ( item ) => {
|
|
166
|
+
return activeElement && activeElement === item.element;
|
|
167
|
+
} );
|
|
168
|
+
|
|
169
|
+
if (
|
|
170
|
+
activeElement &&
|
|
171
|
+
tabsHasFocus &&
|
|
172
|
+
selectedId !== activeElement.id
|
|
173
|
+
) {
|
|
174
|
+
move( selectedId );
|
|
175
|
+
}
|
|
176
|
+
}, [ isControlled, items, move, selectOnMove, selectedId ] );
|
|
177
|
+
|
|
157
178
|
const contextValue = useMemo(
|
|
158
179
|
() => ( {
|
|
159
180
|
store,
|