@wordpress/components 32.2.1-next.v.202602191100.0 → 32.3.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 +24 -0
- package/build/alignment-matrix-control/cell.cjs +2 -2
- package/build/alignment-matrix-control/cell.cjs.map +2 -2
- package/build/alignment-matrix-control/index.cjs +2 -2
- package/build/alignment-matrix-control/index.cjs.map +2 -2
- package/build/angle-picker-control/angle-circle.cjs +2 -2
- package/build/angle-picker-control/angle-circle.cjs.map +2 -2
- package/build/color-picker/color-input.cjs +11 -8
- package/build/color-picker/color-input.cjs.map +2 -2
- package/build/color-picker/component.cjs +47 -3
- package/build/color-picker/component.cjs.map +2 -2
- package/build/color-picker/hsl-input.cjs +7 -28
- package/build/color-picker/hsl-input.cjs.map +2 -2
- package/build/color-picker/picker.cjs +29 -20
- package/build/color-picker/picker.cjs.map +2 -2
- package/build/date-time/date/styles.cjs +9 -9
- package/build/date-time/date/styles.cjs.map +2 -2
- package/build/number-control/index.cjs +2 -5
- package/build/number-control/index.cjs.map +2 -2
- package/build/select-control/styles/select-control-styles.cjs +8 -8
- package/build/select-control/styles/select-control-styles.cjs.map +2 -2
- package/build/snackbar/list.cjs +4 -1
- package/build/snackbar/list.cjs.map +2 -2
- package/build/toggle-group-control/toggle-group-control-option-base/styles.cjs +8 -8
- package/build/toggle-group-control/toggle-group-control-option-base/styles.cjs.map +2 -2
- package/build-module/alignment-matrix-control/cell.mjs +2 -2
- package/build-module/alignment-matrix-control/cell.mjs.map +2 -2
- package/build-module/alignment-matrix-control/index.mjs +2 -2
- package/build-module/alignment-matrix-control/index.mjs.map +2 -2
- package/build-module/angle-picker-control/angle-circle.mjs +2 -2
- package/build-module/angle-picker-control/angle-circle.mjs.map +2 -2
- package/build-module/color-picker/color-input.mjs +11 -8
- package/build-module/color-picker/color-input.mjs.map +2 -2
- package/build-module/color-picker/component.mjs +48 -4
- package/build-module/color-picker/component.mjs.map +2 -2
- package/build-module/color-picker/hsl-input.mjs +7 -28
- package/build-module/color-picker/hsl-input.mjs.map +2 -2
- package/build-module/color-picker/picker.mjs +30 -21
- package/build-module/color-picker/picker.mjs.map +2 -2
- package/build-module/date-time/date/styles.mjs +9 -9
- package/build-module/date-time/date/styles.mjs.map +2 -2
- package/build-module/number-control/index.mjs +2 -5
- package/build-module/number-control/index.mjs.map +2 -2
- package/build-module/select-control/styles/select-control-styles.mjs +8 -8
- package/build-module/select-control/styles/select-control-styles.mjs.map +2 -2
- package/build-module/snackbar/list.mjs +4 -1
- package/build-module/snackbar/list.mjs.map +2 -2
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.mjs +8 -8
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.mjs.map +2 -2
- package/build-style/style-rtl.css +2 -0
- package/build-style/style.css +2 -0
- package/build-types/color-picker/color-input.d.ts +1 -1
- package/build-types/color-picker/color-input.d.ts.map +1 -1
- package/build-types/color-picker/component.d.ts.map +1 -1
- package/build-types/color-picker/hsl-input.d.ts +1 -1
- package/build-types/color-picker/hsl-input.d.ts.map +1 -1
- package/build-types/color-picker/picker.d.ts +1 -1
- package/build-types/color-picker/picker.d.ts.map +1 -1
- package/build-types/color-picker/types.d.ts +6 -4
- package/build-types/color-picker/types.d.ts.map +1 -1
- package/build-types/date-time/date/styles.d.ts.map +1 -1
- package/build-types/dropdown/types.d.ts +9 -13
- package/build-types/dropdown/types.d.ts.map +1 -1
- package/build-types/modal/types.d.ts +9 -3
- package/build-types/modal/types.d.ts.map +1 -1
- package/build-types/number-control/index.d.ts.map +1 -1
- package/build-types/popover/types.d.ts +10 -10
- package/build-types/popover/types.d.ts.map +1 -1
- package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
- package/build-types/snackbar/list.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts +1 -1
- package/build-types/tools-panel/types.d.ts +1 -1
- package/build-types/tools-panel/types.d.ts.map +1 -1
- package/package.json +21 -21
- package/src/button/style.scss +1 -0
- package/src/color-picker/color-input.tsx +23 -4
- package/src/color-picker/component.tsx +88 -4
- package/src/color-picker/hsl-input.tsx +9 -51
- package/src/color-picker/picker.tsx +28 -24
- package/src/color-picker/test/index.tsx +139 -6
- package/src/color-picker/types.ts +6 -4
- package/src/date-time/date/styles.ts +1 -0
- package/src/dropdown/types.ts +9 -14
- package/src/form-token-field/style.scss +1 -0
- package/src/modal/types.ts +9 -5
- package/src/number-control/index.tsx +73 -77
- package/src/popover/types.ts +10 -10
- package/src/select-control/styles/select-control-styles.ts +1 -0
- package/src/snackbar/list.tsx +6 -1
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +18 -16
- package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +4 -6
- package/src/tools-panel/types.ts +4 -1
|
@@ -248,18 +248,19 @@ describe( 'ColorPicker', () => {
|
|
|
248
248
|
expect( onChange ).toHaveBeenLastCalledWith( '#597326' );
|
|
249
249
|
|
|
250
250
|
// Interact with the Lightness slider, setting to 100 (ie. white).
|
|
251
|
-
// It should also cause the `onChange` callback to fire
|
|
252
|
-
//
|
|
251
|
+
// It should also cause the `onChange` callback to fire. The hue and
|
|
252
|
+
// saturation should be preserved (not reset to 0) since the user
|
|
253
|
+
// explicitly set them earlier.
|
|
253
254
|
fireEvent.change( lightnessSlider, { target: { value: 100 } } );
|
|
254
255
|
|
|
255
256
|
await waitFor( () =>
|
|
256
257
|
expect( lightnessSlider ).toHaveValue( '100' )
|
|
257
258
|
);
|
|
258
259
|
expect( lightnessNumberInput ).toHaveValue( 100 );
|
|
259
|
-
expect( hueSlider ).toHaveValue( '
|
|
260
|
-
expect( saturationSlider ).toHaveValue( '
|
|
261
|
-
expect( hueNumberInput ).toHaveValue(
|
|
262
|
-
expect( saturationNumberInput ).toHaveValue(
|
|
260
|
+
expect( hueSlider ).toHaveValue( '80' );
|
|
261
|
+
expect( saturationSlider ).toHaveValue( '50' );
|
|
262
|
+
expect( hueNumberInput ).toHaveValue( 80 );
|
|
263
|
+
expect( saturationNumberInput ).toHaveValue( 50 );
|
|
263
264
|
expect( onChange ).toHaveBeenCalledTimes( 2 );
|
|
264
265
|
expect( onChange ).toHaveBeenLastCalledWith( '#ffffff' );
|
|
265
266
|
|
|
@@ -309,6 +310,138 @@ describe( 'ColorPicker', () => {
|
|
|
309
310
|
expect( lightnessNumberInput ).toHaveValue( 52 );
|
|
310
311
|
} );
|
|
311
312
|
|
|
313
|
+
it( 'should preserve hue and saturation when lightness is set to 0 (black)', async () => {
|
|
314
|
+
const onChange = jest.fn();
|
|
315
|
+
|
|
316
|
+
render(
|
|
317
|
+
<ControlledColorPicker
|
|
318
|
+
onChange={ onChange }
|
|
319
|
+
enableAlpha={ false }
|
|
320
|
+
initialColor="#2ad5d5" // hsl(180, 67%, 50%)
|
|
321
|
+
/>
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
const formatSelector = screen.getByRole( 'combobox' );
|
|
325
|
+
await userEvent.setup().selectOptions( formatSelector, 'hsl' );
|
|
326
|
+
|
|
327
|
+
const hueSliders = screen.getAllByRole( 'slider', { name: 'Hue' } );
|
|
328
|
+
const hueSlider = hueSliders.at( -1 )!;
|
|
329
|
+
const saturationSlider = screen.getByRole( 'slider', {
|
|
330
|
+
name: 'Saturation',
|
|
331
|
+
} );
|
|
332
|
+
const lightnessSlider = screen.getByRole( 'slider', {
|
|
333
|
+
name: 'Lightness',
|
|
334
|
+
} );
|
|
335
|
+
const hueNumberInput = screen.getByRole( 'spinbutton', {
|
|
336
|
+
name: 'Hue',
|
|
337
|
+
} );
|
|
338
|
+
const saturationNumberInput = screen.getByRole( 'spinbutton', {
|
|
339
|
+
name: 'Saturation',
|
|
340
|
+
} );
|
|
341
|
+
|
|
342
|
+
// Verify initial values
|
|
343
|
+
expect( hueSlider ).toHaveValue( '180' );
|
|
344
|
+
expect( saturationSlider ).toHaveValue( '67' );
|
|
345
|
+
|
|
346
|
+
// Set lightness to 0 (black)
|
|
347
|
+
fireEvent.change( lightnessSlider, { target: { value: 0 } } );
|
|
348
|
+
|
|
349
|
+
await waitFor( () => expect( lightnessSlider ).toHaveValue( '0' ) );
|
|
350
|
+
|
|
351
|
+
// Hue and saturation should be preserved
|
|
352
|
+
expect( hueSlider ).toHaveValue( '180' );
|
|
353
|
+
expect( saturationSlider ).toHaveValue( '67' );
|
|
354
|
+
expect( hueNumberInput ).toHaveValue( 180 );
|
|
355
|
+
expect( saturationNumberInput ).toHaveValue( 67 );
|
|
356
|
+
expect( onChange ).toHaveBeenLastCalledWith( '#000000' );
|
|
357
|
+
} );
|
|
358
|
+
|
|
359
|
+
it( 'should reset saturation to 0 when a mid-gray is entered via hex input', async () => {
|
|
360
|
+
const user = userEvent.setup();
|
|
361
|
+
|
|
362
|
+
render(
|
|
363
|
+
<ControlledColorPicker
|
|
364
|
+
enableAlpha={ false }
|
|
365
|
+
initialColor="#2ad5d5" // hsl(180, 67%, 50%)
|
|
366
|
+
/>
|
|
367
|
+
);
|
|
368
|
+
|
|
369
|
+
const formatSelector = screen.getByRole( 'combobox' );
|
|
370
|
+
|
|
371
|
+
// Start in hex mode and enter a mid-gray.
|
|
372
|
+
await user.selectOptions( formatSelector, 'hex' );
|
|
373
|
+
const hexInput = screen.getByRole( 'textbox' );
|
|
374
|
+
await user.clear( hexInput );
|
|
375
|
+
await user.type( hexInput, '808080' );
|
|
376
|
+
|
|
377
|
+
// Switch to HSL to inspect the values.
|
|
378
|
+
await user.selectOptions( formatSelector, 'hsl' );
|
|
379
|
+
|
|
380
|
+
const saturationSlider = screen.getByRole( 'slider', {
|
|
381
|
+
name: 'Saturation',
|
|
382
|
+
} );
|
|
383
|
+
const saturationNumberInput = screen.getByRole( 'spinbutton', {
|
|
384
|
+
name: 'Saturation',
|
|
385
|
+
} );
|
|
386
|
+
|
|
387
|
+
// #808080 is hsl(0, 0%, 50%) — a pure mid-gray.
|
|
388
|
+
// Saturation must be 0, not the stale value from the
|
|
389
|
+
// previous chromatic color.
|
|
390
|
+
await waitFor( () =>
|
|
391
|
+
expect( saturationSlider ).toHaveValue( '0' )
|
|
392
|
+
);
|
|
393
|
+
expect( saturationNumberInput ).toHaveValue( 0 );
|
|
394
|
+
} );
|
|
395
|
+
|
|
396
|
+
it( 'should preserve hue when saturation is set to 0', async () => {
|
|
397
|
+
const onChange = jest.fn();
|
|
398
|
+
|
|
399
|
+
render(
|
|
400
|
+
<ControlledColorPicker
|
|
401
|
+
onChange={ onChange }
|
|
402
|
+
enableAlpha={ false }
|
|
403
|
+
initialColor="#ff0000" // hsl(0, 100%, 50%) - pure red
|
|
404
|
+
/>
|
|
405
|
+
);
|
|
406
|
+
|
|
407
|
+
const formatSelector = screen.getByRole( 'combobox' );
|
|
408
|
+
await userEvent.setup().selectOptions( formatSelector, 'hsl' );
|
|
409
|
+
|
|
410
|
+
const hueSliders = screen.getAllByRole( 'slider', { name: 'Hue' } );
|
|
411
|
+
const hueSlider = hueSliders.at( -1 )!;
|
|
412
|
+
const saturationSlider = screen.getByRole( 'slider', {
|
|
413
|
+
name: 'Saturation',
|
|
414
|
+
} );
|
|
415
|
+
const hueNumberInput = screen.getByRole( 'spinbutton', {
|
|
416
|
+
name: 'Hue',
|
|
417
|
+
} );
|
|
418
|
+
|
|
419
|
+
// Set a specific hue first
|
|
420
|
+
fireEvent.change( hueSlider, { target: { value: 200 } } );
|
|
421
|
+
|
|
422
|
+
await waitFor( () => expect( hueSlider ).toHaveValue( '200' ) );
|
|
423
|
+
|
|
424
|
+
// Set saturation to 0 (grayscale)
|
|
425
|
+
fireEvent.change( saturationSlider, { target: { value: 0 } } );
|
|
426
|
+
|
|
427
|
+
await waitFor( () =>
|
|
428
|
+
expect( saturationSlider ).toHaveValue( '0' )
|
|
429
|
+
);
|
|
430
|
+
|
|
431
|
+
// Hue should be preserved even though color is now gray
|
|
432
|
+
expect( hueSlider ).toHaveValue( '200' );
|
|
433
|
+
expect( hueNumberInput ).toHaveValue( 200 );
|
|
434
|
+
|
|
435
|
+
// Increase saturation again - hue should still be 200
|
|
436
|
+
fireEvent.change( saturationSlider, { target: { value: 50 } } );
|
|
437
|
+
|
|
438
|
+
await waitFor( () =>
|
|
439
|
+
expect( saturationSlider ).toHaveValue( '50' )
|
|
440
|
+
);
|
|
441
|
+
|
|
442
|
+
expect( hueSlider ).toHaveValue( '200' );
|
|
443
|
+
expect( hueNumberInput ).toHaveValue( 200 );
|
|
444
|
+
} );
|
|
312
445
|
describe.each( [
|
|
313
446
|
[ 'hue', 'Hue', '#aad52a' ],
|
|
314
447
|
[ 'saturation', 'Saturation', '#20dfdf' ],
|
|
@@ -56,15 +56,17 @@ export type ColorPickerProps = WordPressComponentProps<
|
|
|
56
56
|
>;
|
|
57
57
|
|
|
58
58
|
export interface PickerProps {
|
|
59
|
-
|
|
59
|
+
hsla: HslaColor;
|
|
60
60
|
enableAlpha: boolean;
|
|
61
|
-
onChange: (
|
|
61
|
+
onChange: ( nextHsla: HslaColor ) => void;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
export interface ColorInputProps {
|
|
65
65
|
colorType: 'hsl' | 'hex' | 'rgb';
|
|
66
66
|
color: Colord;
|
|
67
|
+
hsla: HslaColor;
|
|
67
68
|
onChange: ( nextColor: Colord ) => void;
|
|
69
|
+
onHSLChange: ( nextHsla: HslaColor ) => void;
|
|
68
70
|
enableAlpha: boolean;
|
|
69
71
|
}
|
|
70
72
|
|
|
@@ -84,8 +86,8 @@ export interface HexInputProps {
|
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
export interface HslInputProps {
|
|
87
|
-
|
|
88
|
-
onChange: (
|
|
89
|
+
hsla: HslaColor;
|
|
90
|
+
onChange: ( nextHsla: HslaColor ) => void;
|
|
89
91
|
enableAlpha: boolean;
|
|
90
92
|
}
|
|
91
93
|
|
package/src/dropdown/types.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
1
|
+
import type { useFocusOnMount } from '@wordpress/compose';
|
|
4
2
|
import type { ComponentPropsWithoutRef, CSSProperties, ReactNode } from 'react';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
3
|
import type Popover from '../popover';
|
|
10
4
|
import type { PopoverProps } from '../popover/types';
|
|
11
5
|
|
|
@@ -42,16 +36,17 @@ export type DropdownProps = {
|
|
|
42
36
|
*/
|
|
43
37
|
expandOnMobile?: boolean;
|
|
44
38
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
39
|
+
* Determines focus behavior when the dialog mounts.
|
|
40
|
+
*
|
|
41
|
+
* - `"firstElement"` focuses the first tabbable element within.
|
|
42
|
+
* - `"firstInputElement"` focuses the first value control within.
|
|
43
|
+
* - `true` focuses the element itself.
|
|
44
|
+
* - `false` does nothing and _should not be used unless an accessible
|
|
45
|
+
* substitute behavior is implemented_.
|
|
51
46
|
*
|
|
52
47
|
* @default 'firstElement'
|
|
53
48
|
*/
|
|
54
|
-
focusOnMount?:
|
|
49
|
+
focusOnMount?: useFocusOnMount.Mode;
|
|
55
50
|
/**
|
|
56
51
|
* Set this to customize the text that is shown in the dropdown's header
|
|
57
52
|
* when it is fullscreen on mobile.
|
package/src/modal/types.ts
CHANGED
|
@@ -51,14 +51,18 @@ export type ModalProps = {
|
|
|
51
51
|
*/
|
|
52
52
|
contentLabel?: string;
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
54
|
+
* Determines focus behavior when the modal opens.
|
|
55
|
+
*
|
|
56
|
+
* - `"firstElement"` focuses the first tabbable element within.
|
|
57
|
+
* - `"firstInputElement"` focuses the first value control within.
|
|
58
|
+
* - `"firstContentElement"` focuses the first tabbable element within the modal’s content element.
|
|
59
|
+
* - `true` focuses the element itself.
|
|
60
|
+
* - `false` does nothing and _should not be used unless an accessible
|
|
61
|
+
* substitute behavior is implemented_.
|
|
56
62
|
*
|
|
57
63
|
* @default true
|
|
58
64
|
*/
|
|
59
|
-
focusOnMount?:
|
|
60
|
-
| Parameters< typeof useFocusOnMount >[ 0 ]
|
|
61
|
-
| 'firstContentElement';
|
|
65
|
+
focusOnMount?: useFocusOnMount.Mode | 'firstContentElement';
|
|
62
66
|
/**
|
|
63
67
|
* Elements that are injected into the modal header to the left of the close button (if rendered).
|
|
64
68
|
* Hidden if `__experimentalHideHeader` is `true`.
|
|
@@ -18,6 +18,7 @@ import deprecated from '@wordpress/deprecated';
|
|
|
18
18
|
*/
|
|
19
19
|
import { Input, SpinButton, styles } from './styles/number-control-styles';
|
|
20
20
|
import * as inputControlActionTypes from '../input-control/reducer/actions';
|
|
21
|
+
import type { StateReducer } from '../input-control/reducer/state';
|
|
21
22
|
import { add, subtract, clamp, ensureValidStep } from '../utils/math';
|
|
22
23
|
import { ensureNumber, isValueEmpty } from '../utils/values';
|
|
23
24
|
import type { WordPressComponentProps } from '../context/wordpress-component';
|
|
@@ -120,93 +121,91 @@ function UnforwardedNumberControl(
|
|
|
120
121
|
*
|
|
121
122
|
* @return The updated state to apply to InputControl
|
|
122
123
|
*/
|
|
123
|
-
const numberControlStateReducer:
|
|
124
|
-
|
|
125
|
-
const nextState = { ...state };
|
|
124
|
+
const numberControlStateReducer: StateReducer = ( state, action ) => {
|
|
125
|
+
const nextState = { ...state };
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
const { type, payload } = action;
|
|
128
|
+
const event = payload.event;
|
|
129
|
+
const currentValue = nextState.value;
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
131
|
+
/**
|
|
132
|
+
* Handles custom UP and DOWN Keyboard events
|
|
133
|
+
*/
|
|
134
|
+
if (
|
|
135
|
+
type === inputControlActionTypes.PRESS_UP ||
|
|
136
|
+
type === inputControlActionTypes.PRESS_DOWN
|
|
137
|
+
) {
|
|
138
|
+
nextState.value = spinValue(
|
|
139
|
+
currentValue,
|
|
140
|
+
type === inputControlActionTypes.PRESS_UP ? 'up' : 'down',
|
|
141
|
+
event as KeyboardEvent | undefined
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
144
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
145
|
+
/**
|
|
146
|
+
* Handles drag to update events
|
|
147
|
+
*/
|
|
148
|
+
if ( type === inputControlActionTypes.DRAG && isDragEnabled ) {
|
|
149
|
+
const [ x, y ] = payload.delta;
|
|
150
|
+
const enableShift = payload.shiftKey && isShiftStepEnabled;
|
|
151
|
+
const modifier = enableShift
|
|
152
|
+
? ensureNumber( shiftStep ) * baseSpin
|
|
153
|
+
: baseSpin;
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
let directionModifier;
|
|
156
|
+
let delta;
|
|
157
157
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
158
|
+
switch ( dragDirection ) {
|
|
159
|
+
case 'n':
|
|
160
|
+
delta = y;
|
|
161
|
+
directionModifier = -1;
|
|
162
|
+
break;
|
|
163
163
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
164
|
+
case 'e':
|
|
165
|
+
delta = x;
|
|
166
|
+
directionModifier = isRTL() ? -1 : 1;
|
|
167
|
+
break;
|
|
168
168
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
169
|
+
case 's':
|
|
170
|
+
delta = y;
|
|
171
|
+
directionModifier = 1;
|
|
172
|
+
break;
|
|
173
173
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
174
|
+
case 'w':
|
|
175
|
+
delta = x;
|
|
176
|
+
directionModifier = isRTL() ? 1 : -1;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
179
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
if ( delta !== 0 ) {
|
|
181
|
+
delta = Math.ceil( Math.abs( delta ) ) * Math.sign( delta );
|
|
182
|
+
const distance = delta * modifier * directionModifier;
|
|
183
183
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
184
|
+
nextState.value = constrainValue(
|
|
185
|
+
// @ts-expect-error TODO: Investigate if it's ok for currentValue to be undefined
|
|
186
|
+
add( currentValue, distance ),
|
|
187
|
+
enableShift ? modifier : undefined
|
|
188
|
+
);
|
|
190
189
|
}
|
|
190
|
+
}
|
|
191
191
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
required === false && currentValue === '';
|
|
192
|
+
/**
|
|
193
|
+
* Handles commit (ENTER key press or blur)
|
|
194
|
+
*/
|
|
195
|
+
if (
|
|
196
|
+
type === inputControlActionTypes.PRESS_ENTER ||
|
|
197
|
+
type === inputControlActionTypes.COMMIT
|
|
198
|
+
) {
|
|
199
|
+
const applyEmptyValue = required === false && currentValue === '';
|
|
201
200
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
201
|
+
nextState.value = applyEmptyValue
|
|
202
|
+
? currentValue
|
|
203
|
+
: // @ts-expect-error TODO: Investigate if it's ok for currentValue to be undefined
|
|
204
|
+
constrainValue( currentValue );
|
|
205
|
+
}
|
|
207
206
|
|
|
208
|
-
|
|
209
|
-
|
|
207
|
+
return stateReducerProp?.( nextState, action ) ?? nextState;
|
|
208
|
+
};
|
|
210
209
|
|
|
211
210
|
const buildSpinButtonClickHandler =
|
|
212
211
|
( direction: 'up' | 'down' ) =>
|
|
@@ -238,10 +237,7 @@ function UnforwardedNumberControl(
|
|
|
238
237
|
type={ typeProp }
|
|
239
238
|
// @ts-expect-error TODO: Resolve discrepancy between `value` types in InputControl based components
|
|
240
239
|
value={ valueProp }
|
|
241
|
-
__unstableStateReducer={
|
|
242
|
-
const baseState = numberControlStateReducer( state, action );
|
|
243
|
-
return stateReducerProp?.( baseState, action ) ?? baseState;
|
|
244
|
-
} }
|
|
240
|
+
__unstableStateReducer={ numberControlStateReducer }
|
|
245
241
|
size={ size }
|
|
246
242
|
__shouldNotWarnDeprecated36pxSize
|
|
247
243
|
suffix={
|
package/src/popover/types.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import type { ReactNode, MutableRefObject, SyntheticEvent } from 'react';
|
|
5
1
|
import type { Placement } from '@floating-ui/react-dom';
|
|
2
|
+
import type { useFocusOnMount } from '@wordpress/compose';
|
|
3
|
+
import type { MutableRefObject, ReactNode, SyntheticEvent } from 'react';
|
|
6
4
|
|
|
7
5
|
type PositionYAxis = 'top' | 'middle' | 'bottom';
|
|
8
6
|
type PositionXAxis = 'left' | 'center' | 'right';
|
|
@@ -75,15 +73,17 @@ export type PopoverProps = {
|
|
|
75
73
|
*/
|
|
76
74
|
constrainTabbing?: boolean;
|
|
77
75
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
76
|
+
* Determines focus behavior when the popover mounts.
|
|
77
|
+
*
|
|
78
|
+
* - `"firstElement"` focuses the first tabbable element within.
|
|
79
|
+
* - `"firstInputElement"` focuses the first value control within.
|
|
80
|
+
* - `true` focuses the element itself.
|
|
81
|
+
* - `false` does nothing and _should not be used unless an accessible
|
|
82
|
+
* substitute behavior is implemented_.
|
|
83
83
|
*
|
|
84
84
|
* @default 'firstElement'
|
|
85
85
|
*/
|
|
86
|
-
focusOnMount?:
|
|
86
|
+
focusOnMount?: useFocusOnMount.Mode;
|
|
87
87
|
/**
|
|
88
88
|
* A callback invoked when the focus leaves the opened popover. This should
|
|
89
89
|
* only be provided in advanced use-cases when a popover should close under
|
|
@@ -162,6 +162,7 @@ export const Select = styled.select< SelectProps >`
|
|
|
162
162
|
cursor: inherit;
|
|
163
163
|
display: block;
|
|
164
164
|
font-family: inherit;
|
|
165
|
+
line-height: 1.3; // Override forms.css styles, large enough value to prevent descender clipping without affecting height
|
|
165
166
|
margin: 0;
|
|
166
167
|
width: 100%;
|
|
167
168
|
max-width: none;
|
package/src/snackbar/list.tsx
CHANGED
|
@@ -86,7 +86,12 @@ export function SnackbarList( {
|
|
|
86
86
|
|
|
87
87
|
return (
|
|
88
88
|
<motion.div
|
|
89
|
-
layout={
|
|
89
|
+
layout={ isReducedMotion ? false : 'position' } // See https://www.framer.com/docs/animation/#layout-animations
|
|
90
|
+
// Ensures a stable full-width bounding box so that
|
|
91
|
+
// `layout="position"` only ever detects vertical
|
|
92
|
+
// shifts, preventing horizontal animation when
|
|
93
|
+
// notice text changes in place.
|
|
94
|
+
style={ { width: '100%' } }
|
|
90
95
|
initial="init"
|
|
91
96
|
animate="open"
|
|
92
97
|
exit="exit"
|
|
@@ -137,7 +137,6 @@ exports[`ToggleGroupControl controlled should render correctly with icons 1`] =
|
|
|
137
137
|
user-select: none;
|
|
138
138
|
width: 100%;
|
|
139
139
|
z-index: 2;
|
|
140
|
-
color: var(--wp-components-color-foreground, #1e1e1e);
|
|
141
140
|
height: 38px;
|
|
142
141
|
aspect-ratio: 1;
|
|
143
142
|
padding-left: 0;
|
|
@@ -157,12 +156,13 @@ exports[`ToggleGroupControl controlled should render correctly with icons 1`] =
|
|
|
157
156
|
border: 0;
|
|
158
157
|
}
|
|
159
158
|
|
|
160
|
-
.emotion-12[disabled]
|
|
159
|
+
.emotion-12[disabled],
|
|
160
|
+
.emotion-12[aria-disabled='true'] {
|
|
161
161
|
opacity: 0.4;
|
|
162
162
|
cursor: default;
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
.emotion-12:hover {
|
|
165
|
+
.emotion-12:hover:not( [disabled] ):not( [aria-disabled='true'] ) {
|
|
166
166
|
color: var(--wp-components-color-foreground, #1e1e1e);
|
|
167
167
|
}
|
|
168
168
|
|
|
@@ -211,7 +211,6 @@ exports[`ToggleGroupControl controlled should render correctly with icons 1`] =
|
|
|
211
211
|
user-select: none;
|
|
212
212
|
width: 100%;
|
|
213
213
|
z-index: 2;
|
|
214
|
-
color: var(--wp-components-color-foreground, #1e1e1e);
|
|
215
214
|
height: 38px;
|
|
216
215
|
aspect-ratio: 1;
|
|
217
216
|
padding-left: 0;
|
|
@@ -229,12 +228,13 @@ exports[`ToggleGroupControl controlled should render correctly with icons 1`] =
|
|
|
229
228
|
border: 0;
|
|
230
229
|
}
|
|
231
230
|
|
|
232
|
-
.emotion-17[disabled]
|
|
231
|
+
.emotion-17[disabled],
|
|
232
|
+
.emotion-17[aria-disabled='true'] {
|
|
233
233
|
opacity: 0.4;
|
|
234
234
|
cursor: default;
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
.emotion-17:hover {
|
|
237
|
+
.emotion-17:hover:not( [disabled] ):not( [aria-disabled='true'] ) {
|
|
238
238
|
color: var(--wp-components-color-foreground, #1e1e1e);
|
|
239
239
|
}
|
|
240
240
|
|
|
@@ -491,12 +491,13 @@ exports[`ToggleGroupControl controlled should render correctly with text options
|
|
|
491
491
|
border: 0;
|
|
492
492
|
}
|
|
493
493
|
|
|
494
|
-
.emotion-12[disabled]
|
|
494
|
+
.emotion-12[disabled],
|
|
495
|
+
.emotion-12[aria-disabled='true'] {
|
|
495
496
|
opacity: 0.4;
|
|
496
497
|
cursor: default;
|
|
497
498
|
}
|
|
498
499
|
|
|
499
|
-
.emotion-12:hover {
|
|
500
|
+
.emotion-12:hover:not( [disabled] ):not( [aria-disabled='true'] ) {
|
|
500
501
|
color: var(--wp-components-color-foreground, #1e1e1e);
|
|
501
502
|
}
|
|
502
503
|
|
|
@@ -726,7 +727,6 @@ exports[`ToggleGroupControl uncontrolled should render correctly with icons 1`]
|
|
|
726
727
|
user-select: none;
|
|
727
728
|
width: 100%;
|
|
728
729
|
z-index: 2;
|
|
729
|
-
color: var(--wp-components-color-foreground, #1e1e1e);
|
|
730
730
|
height: 38px;
|
|
731
731
|
aspect-ratio: 1;
|
|
732
732
|
padding-left: 0;
|
|
@@ -746,12 +746,13 @@ exports[`ToggleGroupControl uncontrolled should render correctly with icons 1`]
|
|
|
746
746
|
border: 0;
|
|
747
747
|
}
|
|
748
748
|
|
|
749
|
-
.emotion-12[disabled]
|
|
749
|
+
.emotion-12[disabled],
|
|
750
|
+
.emotion-12[aria-disabled='true'] {
|
|
750
751
|
opacity: 0.4;
|
|
751
752
|
cursor: default;
|
|
752
753
|
}
|
|
753
754
|
|
|
754
|
-
.emotion-12:hover {
|
|
755
|
+
.emotion-12:hover:not( [disabled] ):not( [aria-disabled='true'] ) {
|
|
755
756
|
color: var(--wp-components-color-foreground, #1e1e1e);
|
|
756
757
|
}
|
|
757
758
|
|
|
@@ -800,7 +801,6 @@ exports[`ToggleGroupControl uncontrolled should render correctly with icons 1`]
|
|
|
800
801
|
user-select: none;
|
|
801
802
|
width: 100%;
|
|
802
803
|
z-index: 2;
|
|
803
|
-
color: var(--wp-components-color-foreground, #1e1e1e);
|
|
804
804
|
height: 38px;
|
|
805
805
|
aspect-ratio: 1;
|
|
806
806
|
padding-left: 0;
|
|
@@ -818,12 +818,13 @@ exports[`ToggleGroupControl uncontrolled should render correctly with icons 1`]
|
|
|
818
818
|
border: 0;
|
|
819
819
|
}
|
|
820
820
|
|
|
821
|
-
.emotion-17[disabled]
|
|
821
|
+
.emotion-17[disabled],
|
|
822
|
+
.emotion-17[aria-disabled='true'] {
|
|
822
823
|
opacity: 0.4;
|
|
823
824
|
cursor: default;
|
|
824
825
|
}
|
|
825
826
|
|
|
826
|
-
.emotion-17:hover {
|
|
827
|
+
.emotion-17:hover:not( [disabled] ):not( [aria-disabled='true'] ) {
|
|
827
828
|
color: var(--wp-components-color-foreground, #1e1e1e);
|
|
828
829
|
}
|
|
829
830
|
|
|
@@ -1074,12 +1075,13 @@ exports[`ToggleGroupControl uncontrolled should render correctly with text optio
|
|
|
1074
1075
|
border: 0;
|
|
1075
1076
|
}
|
|
1076
1077
|
|
|
1077
|
-
.emotion-12[disabled]
|
|
1078
|
+
.emotion-12[disabled],
|
|
1079
|
+
.emotion-12[aria-disabled='true'] {
|
|
1078
1080
|
opacity: 0.4;
|
|
1079
1081
|
cursor: default;
|
|
1080
1082
|
}
|
|
1081
1083
|
|
|
1082
|
-
.emotion-12:hover {
|
|
1084
|
+
.emotion-12:hover:not( [disabled] ):not( [aria-disabled='true'] ) {
|
|
1083
1085
|
color: var(--wp-components-color-foreground, #1e1e1e);
|
|
1084
1086
|
}
|
|
1085
1087
|
|