@wordpress/components 19.3.0 → 19.4.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 +27 -0
- package/CONTRIBUTING.md +1 -1
- package/README.md +8 -4
- package/build/base-field/hook.js +1 -1
- package/build/base-field/hook.js.map +1 -1
- package/build/button/deprecated.js +2 -1
- package/build/button/deprecated.js.map +1 -1
- package/build/button/index.js +2 -1
- package/build/button/index.js.map +1 -1
- package/build/card/card/component.js +1 -1
- package/build/card/card/component.js.map +1 -1
- package/build/card/card/hook.js +1 -1
- package/build/card/card/hook.js.map +1 -1
- package/build/card/card-body/hook.js +1 -1
- package/build/card/card-body/hook.js.map +1 -1
- package/build/card/card-divider/hook.js +1 -1
- package/build/card/card-divider/hook.js.map +1 -1
- package/build/card/card-footer/hook.js +1 -1
- package/build/card/card-footer/hook.js.map +1 -1
- package/build/card/card-header/hook.js +1 -1
- package/build/card/card-header/hook.js.map +1 -1
- package/build/card/card-media/hook.js +1 -1
- package/build/card/card-media/hook.js.map +1 -1
- package/build/circular-option-picker/index.js +2 -0
- package/build/circular-option-picker/index.js.map +1 -1
- package/build/color-indicator/index.js +2 -0
- package/build/color-indicator/index.js.map +1 -1
- package/build/color-palette/index.js +2 -0
- package/build/color-palette/index.js.map +1 -1
- package/build/color-picker/color-display.js.map +1 -1
- package/build/color-picker/color-input.js.map +1 -1
- package/build/color-picker/component.js +1 -1
- package/build/color-picker/component.js.map +1 -1
- package/build/color-picker/use-deprecated-props.js +2 -0
- package/build/color-picker/use-deprecated-props.js.map +1 -1
- package/build/date-time/time.js +1 -1
- package/build/date-time/time.js.map +1 -1
- package/build/dropdown/index.js +3 -3
- package/build/dropdown/index.js.map +1 -1
- package/build/elevation/hook.js +5 -5
- package/build/elevation/hook.js.map +1 -1
- package/build/flex/flex/hook.js +4 -4
- package/build/flex/flex/hook.js.map +1 -1
- package/build/grid/hook.js +2 -2
- package/build/grid/hook.js.map +1 -1
- package/build/item-group/item/hook.js +1 -1
- package/build/item-group/item/hook.js.map +1 -1
- package/build/modal/index.js +1 -12
- package/build/modal/index.js.map +1 -1
- package/build/navigator/context.js +2 -2
- package/build/navigator/context.js.map +1 -1
- package/build/navigator/navigator-provider/component.js +18 -25
- package/build/navigator/navigator-provider/component.js.map +1 -1
- package/build/navigator/navigator-screen/component.js +39 -13
- package/build/navigator/navigator-screen/component.js.map +1 -1
- package/build/navigator/use-navigator.js +4 -4
- package/build/navigator/use-navigator.js.map +1 -1
- package/build/placeholder/index.js +4 -4
- package/build/placeholder/index.js.map +1 -1
- package/build/scrollable/hook.js +1 -1
- package/build/scrollable/hook.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/fill.js +11 -2
- package/build/slot-fill/bubbles-virtually/fill.js.map +1 -1
- package/build/spinner/index.js +44 -5
- package/build/spinner/index.js.map +1 -1
- package/build/spinner/styles.js +56 -0
- package/build/spinner/styles.js.map +1 -0
- package/build/surface/hook.js +1 -1
- package/build/surface/hook.js.map +1 -1
- package/build/text/hook.js +5 -5
- package/build/text/hook.js.map +1 -1
- package/build/tip/index.js +4 -8
- package/build/tip/index.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build/tools-panel/tools-panel/hook.js +7 -7
- package/build/tools-panel/tools-panel/hook.js.map +1 -1
- package/build/tools-panel/tools-panel-header/hook.js +3 -3
- package/build/tools-panel/tools-panel-header/hook.js.map +1 -1
- package/build/tools-panel/tools-panel-item/hook.js +1 -1
- package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build/tree-grid/index.js +13 -6
- package/build/tree-grid/index.js.map +1 -1
- package/build/truncate/hook.js +2 -2
- package/build/truncate/hook.js.map +1 -1
- package/build/utils/config-values.js +1 -1
- package/build/utils/config-values.js.map +1 -1
- package/build-module/base-field/hook.js +1 -1
- package/build-module/base-field/hook.js.map +1 -1
- package/build-module/button/deprecated.js +2 -1
- package/build-module/button/deprecated.js.map +1 -1
- package/build-module/button/index.js +2 -1
- package/build-module/button/index.js.map +1 -1
- package/build-module/card/card/component.js +1 -1
- package/build-module/card/card/component.js.map +1 -1
- package/build-module/card/card/hook.js +1 -1
- package/build-module/card/card/hook.js.map +1 -1
- package/build-module/card/card-body/hook.js +1 -1
- package/build-module/card/card-body/hook.js.map +1 -1
- package/build-module/card/card-divider/hook.js +1 -1
- package/build-module/card/card-divider/hook.js.map +1 -1
- package/build-module/card/card-footer/hook.js +1 -1
- package/build-module/card/card-footer/hook.js.map +1 -1
- package/build-module/card/card-header/hook.js +1 -1
- package/build-module/card/card-header/hook.js.map +1 -1
- package/build-module/card/card-media/hook.js +1 -1
- package/build-module/card/card-media/hook.js.map +1 -1
- package/build-module/circular-option-picker/index.js +1 -0
- package/build-module/circular-option-picker/index.js.map +1 -1
- package/build-module/color-indicator/index.js +1 -0
- package/build-module/color-indicator/index.js.map +1 -1
- package/build-module/color-palette/index.js +1 -0
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/color-picker/color-display.js.map +1 -1
- package/build-module/color-picker/color-input.js.map +1 -1
- package/build-module/color-picker/component.js +1 -1
- package/build-module/color-picker/component.js.map +1 -1
- package/build-module/color-picker/use-deprecated-props.js +2 -0
- package/build-module/color-picker/use-deprecated-props.js.map +1 -1
- package/build-module/date-time/time.js +1 -1
- package/build-module/date-time/time.js.map +1 -1
- package/build-module/dropdown/index.js +3 -3
- package/build-module/dropdown/index.js.map +1 -1
- package/build-module/elevation/hook.js +5 -5
- package/build-module/elevation/hook.js.map +1 -1
- package/build-module/flex/flex/hook.js +4 -4
- package/build-module/flex/flex/hook.js.map +1 -1
- package/build-module/grid/hook.js +2 -2
- package/build-module/grid/hook.js.map +1 -1
- package/build-module/item-group/item/hook.js +1 -1
- package/build-module/item-group/item/hook.js.map +1 -1
- package/build-module/modal/index.js +1 -11
- package/build-module/modal/index.js.map +1 -1
- package/build-module/navigator/context.js +2 -2
- package/build-module/navigator/context.js.map +1 -1
- package/build-module/navigator/navigator-provider/component.js +18 -25
- package/build-module/navigator/navigator-provider/component.js.map +1 -1
- package/build-module/navigator/navigator-screen/component.js +39 -15
- package/build-module/navigator/navigator-screen/component.js.map +1 -1
- package/build-module/navigator/use-navigator.js +4 -4
- package/build-module/navigator/use-navigator.js.map +1 -1
- package/build-module/placeholder/index.js +4 -4
- package/build-module/placeholder/index.js.map +1 -1
- package/build-module/scrollable/hook.js +1 -1
- package/build-module/scrollable/hook.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/fill.js +11 -2
- package/build-module/slot-fill/bubbles-virtually/fill.js.map +1 -1
- package/build-module/spinner/index.js +40 -5
- package/build-module/spinner/index.js.map +1 -1
- package/build-module/spinner/styles.js +49 -0
- package/build-module/spinner/styles.js.map +1 -0
- package/build-module/surface/hook.js +1 -1
- package/build-module/surface/hook.js.map +1 -1
- package/build-module/text/hook.js +5 -5
- package/build-module/text/hook.js.map +1 -1
- package/build-module/tip/index.js +4 -8
- package/build-module/tip/index.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js +1 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel/hook.js +7 -7
- package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
- package/build-module/tools-panel/tools-panel-header/hook.js +3 -3
- package/build-module/tools-panel/tools-panel-header/hook.js.map +1 -1
- package/build-module/tools-panel/tools-panel-item/hook.js +1 -1
- package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build-module/tree-grid/index.js +12 -6
- package/build-module/tree-grid/index.js.map +1 -1
- package/build-module/truncate/hook.js +2 -2
- package/build-module/truncate/hook.js.map +1 -1
- package/build-module/utils/config-values.js +1 -1
- package/build-module/utils/config-values.js.map +1 -1
- package/build-style/style-rtl.css +12 -2
- package/build-style/style.css +12 -2
- package/build-types/button/index.d.ts.map +1 -1
- package/build-types/circular-option-picker/index.d.ts +31 -0
- package/build-types/circular-option-picker/index.d.ts.map +1 -0
- package/build-types/color-palette/index.d.ts +16 -0
- package/build-types/color-palette/index.d.ts.map +1 -0
- package/build-types/color-palette/styles.d.ts +8 -0
- package/build-types/color-palette/styles.d.ts.map +1 -0
- package/build-types/color-picker/color-display.d.ts +14 -0
- package/build-types/color-picker/color-display.d.ts.map +1 -0
- package/build-types/color-picker/color-input.d.ts +14 -0
- package/build-types/color-picker/color-input.d.ts.map +1 -0
- package/build-types/color-picker/component.d.ts +11 -0
- package/build-types/color-picker/component.d.ts.map +1 -0
- package/build-types/color-picker/hex-input.d.ts +13 -0
- package/build-types/color-picker/hex-input.d.ts.map +1 -0
- package/build-types/color-picker/hsl-input.d.ts +13 -0
- package/build-types/color-picker/hsl-input.d.ts.map +1 -0
- package/build-types/color-picker/index.d.ts +5 -0
- package/build-types/color-picker/index.d.ts.map +1 -0
- package/build-types/color-picker/input-with-slider.d.ts +12 -0
- package/build-types/color-picker/input-with-slider.d.ts.map +1 -0
- package/build-types/color-picker/legacy-adapter.d.ts +6 -0
- package/build-types/color-picker/legacy-adapter.d.ts.map +1 -0
- package/build-types/color-picker/picker.d.ts +10 -0
- package/build-types/color-picker/picker.d.ts.map +1 -0
- package/build-types/color-picker/rgb-input.d.ts +13 -0
- package/build-types/color-picker/rgb-input.d.ts.map +1 -0
- package/build-types/color-picker/styles.d.ts +76 -0
- package/build-types/color-picker/styles.d.ts.map +1 -0
- package/build-types/color-picker/types.d.ts +2 -0
- package/build-types/color-picker/types.d.ts.map +1 -0
- package/build-types/color-picker/use-deprecated-props.d.ts +49 -0
- package/build-types/color-picker/use-deprecated-props.d.ts.map +1 -0
- package/build-types/dropdown/index.d.ts +1 -13
- package/build-types/dropdown/index.d.ts.map +1 -1
- package/build-types/elevation/hook.d.ts.map +1 -1
- package/build-types/flex/flex/hook.d.ts.map +1 -1
- package/build-types/grid/hook.d.ts.map +1 -1
- package/build-types/navigator/navigator-provider/component.d.ts +4 -4
- package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-screen/component.d.ts +4 -4
- package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
- package/build-types/navigator/types.d.ts +5 -3
- package/build-types/navigator/types.d.ts.map +1 -1
- package/build-types/resizable-box/index.d.ts +1 -1
- package/build-types/resizable-box/resize-tooltip/index.d.ts +1 -1
- package/build-types/slot-fill/bubbles-virtually/fill.d.ts.map +1 -1
- package/build-types/spinner/index.d.ts +18 -1
- package/build-types/spinner/index.d.ts.map +1 -1
- package/build-types/spinner/styles.d.ts +13 -0
- package/build-types/spinner/styles.d.ts.map +1 -0
- package/build-types/surface/hook.d.ts.map +1 -1
- package/build-types/text/hook.d.ts.map +1 -1
- package/build-types/tip/index.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts +3 -2
- package/build-types/unit-control/index.d.ts.map +1 -1
- package/build-types/unit-control/types.d.ts +2 -1
- package/build-types/unit-control/types.d.ts.map +1 -1
- package/build-types/utils/config-values.d.ts +1 -1
- package/package.json +16 -17
- package/src/base-field/hook.js +1 -1
- package/src/button/deprecated.js +1 -0
- package/src/button/index.js +1 -0
- package/src/card/card/component.js +1 -1
- package/src/card/card/hook.js +1 -1
- package/src/card/card-body/hook.js +1 -1
- package/src/card/card-divider/hook.js +1 -1
- package/src/card/card-footer/hook.js +1 -1
- package/src/card/card-header/hook.js +1 -1
- package/src/card/card-media/hook.js +1 -1
- package/src/circular-option-picker/index.js +1 -0
- package/src/color-indicator/index.js +2 -0
- package/src/color-palette/index.js +1 -0
- package/src/color-palette/test/__snapshots__/index.js.snap +0 -1
- package/src/color-picker/color-display.tsx +1 -1
- package/src/color-picker/color-input.tsx +1 -1
- package/src/color-picker/component.tsx +1 -1
- package/src/color-picker/use-deprecated-props.ts +2 -0
- package/src/combobox-control/stories/index.js +6 -2
- package/src/combobox-control/style.scss +2 -2
- package/src/date-time/README.md +4 -4
- package/src/date-time/test/time.js +2 -2
- package/src/date-time/time.js +2 -2
- package/src/dropdown/index.js +14 -13
- package/src/elevation/hook.js +1 -0
- package/src/flex/flex/hook.js +1 -0
- package/src/grid/hook.js +1 -0
- package/src/item-group/item/hook.ts +1 -1
- package/src/item-group/stories/index.js +2 -2
- package/src/mobile/link-settings/test/edit.native.js +5 -5
- package/src/modal/index.js +1 -10
- package/src/navigator/context.ts +2 -2
- package/src/navigator/navigator-provider/README.md +11 -9
- package/src/navigator/navigator-provider/component.tsx +16 -25
- package/src/navigator/navigator-screen/component.tsx +55 -15
- package/src/navigator/stories/index.js +19 -5
- package/src/navigator/test/index.js +77 -25
- package/src/navigator/types.ts +5 -3
- package/src/navigator/use-navigator.ts +3 -3
- package/src/placeholder/index.js +8 -6
- package/src/placeholder/style.scss +12 -0
- package/src/placeholder/test/index.js +18 -1
- package/src/scrollable/hook.js +1 -1
- package/src/slot-fill/bubbles-virtually/fill.js +12 -1
- package/src/spinner/README.md +10 -10
- package/src/spinner/index.js +42 -3
- package/src/spinner/stories/index.js +36 -3
- package/src/spinner/styles.js +47 -0
- package/src/surface/hook.js +1 -0
- package/src/text/hook.js +1 -0
- package/src/tip/index.js +2 -4
- package/src/toggle-group-control/toggle-group-control/component.tsx +1 -1
- package/src/tools-panel/stories/index.js +20 -1
- package/src/tools-panel/test/__snapshots__/index.js.snap +0 -1
- package/src/tools-panel/test/index.js +31 -1
- package/src/tools-panel/tools-panel/hook.ts +14 -9
- package/src/tools-panel/tools-panel-header/hook.ts +3 -3
- package/src/tools-panel/tools-panel-item/hook.ts +1 -0
- package/src/tree-grid/index.js +19 -5
- package/src/truncate/hook.js +1 -1
- package/src/unit-control/types.ts +2 -1
- package/src/utils/config-values.js +1 -1
- package/src/utils/hooks/stories/use-cx.js +121 -44
- package/tsconfig.json +3 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/spinner/styles/spinner-styles.js +0 -40
- package/build/spinner/styles/spinner-styles.js.map +0 -1
- package/build-module/spinner/styles/spinner-styles.js +0 -28
- package/build-module/spinner/styles/spinner-styles.js.map +0 -1
- package/build-types/spinner/styles/spinner-styles.d.ts +0 -5
- package/build-types/spinner/styles/spinner-styles.d.ts.map +0 -1
- package/src/spinner/styles/spinner-styles.js +0 -47
- package/src/ui/visually-hidden/README.md +0 -21
package/src/card/card/hook.js
CHANGED
|
@@ -61,7 +61,7 @@ export function useCard( props ) {
|
|
|
61
61
|
isRounded && styles.rounded,
|
|
62
62
|
className
|
|
63
63
|
);
|
|
64
|
-
}, [ className, isBorderless, isRounded ] );
|
|
64
|
+
}, [ className, cx, isBorderless, isRounded ] );
|
|
65
65
|
|
|
66
66
|
const surfaceProps = useSurface( { ...otherProps, className: classes } );
|
|
67
67
|
|
|
@@ -266,7 +266,7 @@ const mapCountryOption = ( country ) => ( {
|
|
|
266
266
|
|
|
267
267
|
const countryOptions = countries.map( mapCountryOption );
|
|
268
268
|
|
|
269
|
-
function CountryCodeComboboxControl() {
|
|
269
|
+
function CountryCodeComboboxControl( { allowReset } ) {
|
|
270
270
|
const [ value, setValue ] = useState( null );
|
|
271
271
|
|
|
272
272
|
return (
|
|
@@ -276,9 +276,13 @@ function CountryCodeComboboxControl() {
|
|
|
276
276
|
onChange={ setValue }
|
|
277
277
|
label="Select a country"
|
|
278
278
|
options={ countryOptions }
|
|
279
|
+
allowReset={ allowReset }
|
|
279
280
|
/>
|
|
280
281
|
<p>Value: { value }</p>
|
|
281
282
|
</>
|
|
282
283
|
);
|
|
283
284
|
}
|
|
284
|
-
export const _default = (
|
|
285
|
+
export const _default = CountryCodeComboboxControl.bind( {} );
|
|
286
|
+
_default.args = {
|
|
287
|
+
allowReset: false,
|
|
288
|
+
};
|
|
@@ -40,7 +40,7 @@ input.components-combobox-control__input[type="text"] {
|
|
|
40
40
|
|
|
41
41
|
.components-combobox-control__reset.components-button {
|
|
42
42
|
display: flex;
|
|
43
|
-
height: $grid-unit-
|
|
44
|
-
min-width: $grid-unit-
|
|
43
|
+
height: $grid-unit-20;
|
|
44
|
+
min-width: $grid-unit-20;
|
|
45
45
|
padding: 0;
|
|
46
46
|
}
|
package/src/date-time/README.md
CHANGED
|
@@ -28,7 +28,7 @@ const MyDateTimePicker = () => {
|
|
|
28
28
|
is12Hour={ true }
|
|
29
29
|
/>
|
|
30
30
|
);
|
|
31
|
-
}
|
|
31
|
+
};
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
## Props
|
|
@@ -52,7 +52,7 @@ The function called when a new date or time has been selected. It is passed the
|
|
|
52
52
|
|
|
53
53
|
### is12Hour
|
|
54
54
|
|
|
55
|
-
Whether we use a 12-hour clock. With a 12-hour clock, an AM/PM widget is displayed and the time format is assumed to be MM-DD-YYYY.
|
|
55
|
+
Whether we use a 12-hour clock. With a 12-hour clock, an AM/PM widget is displayed and the time format is assumed to be `MM-DD-YYYY` (as opposed to the default format `DD-MM-YYYY`).
|
|
56
56
|
|
|
57
57
|
- Type: `bool`
|
|
58
58
|
- Required: No
|
|
@@ -69,5 +69,5 @@ A callback function which receives a Date object representing a day as an argume
|
|
|
69
69
|
|
|
70
70
|
A callback invoked when selecting the previous/next month in the date picker. The callback receives the new month date in the ISO format as an argument.
|
|
71
71
|
|
|
72
|
-
-
|
|
73
|
-
-
|
|
72
|
+
- Type: `Function`
|
|
73
|
+
- Required: No
|
|
@@ -278,7 +278,7 @@ describe( 'TimePicker', () => {
|
|
|
278
278
|
screen.getByLabelText( 'Day' )
|
|
279
279
|
);
|
|
280
280
|
|
|
281
|
-
expect( monthInputIndex
|
|
281
|
+
expect( monthInputIndex > dayInputIndex ).toBe( true );
|
|
282
282
|
|
|
283
283
|
rerender(
|
|
284
284
|
<form aria-label="form">
|
|
@@ -299,7 +299,7 @@ describe( 'TimePicker', () => {
|
|
|
299
299
|
screen.getByLabelText( 'Day' )
|
|
300
300
|
);
|
|
301
301
|
|
|
302
|
-
expect( monthInputIndex
|
|
302
|
+
expect( monthInputIndex < dayInputIndex ).toBe( true );
|
|
303
303
|
} );
|
|
304
304
|
|
|
305
305
|
it( 'Should set a time when passed a null currentTime', () => {
|
package/src/date-time/time.js
CHANGED
|
@@ -196,13 +196,13 @@ export function TimePicker( { is12Hour, currentTime, onChange } ) {
|
|
|
196
196
|
|
|
197
197
|
const dayMonthFormat = is12Hour ? (
|
|
198
198
|
<>
|
|
199
|
-
{ dayFormat }
|
|
200
199
|
{ monthFormat }
|
|
200
|
+
{ dayFormat }
|
|
201
201
|
</>
|
|
202
202
|
) : (
|
|
203
203
|
<>
|
|
204
|
-
{ monthFormat }
|
|
205
204
|
{ dayFormat }
|
|
205
|
+
{ monthFormat }
|
|
206
206
|
</>
|
|
207
207
|
);
|
|
208
208
|
|
package/src/dropdown/index.js
CHANGED
|
@@ -27,19 +27,20 @@ function useObservableState( initialState, onStateChange ) {
|
|
|
27
27
|
];
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export default function Dropdown( {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
export default function Dropdown( props ) {
|
|
31
|
+
const {
|
|
32
|
+
renderContent,
|
|
33
|
+
renderToggle,
|
|
34
|
+
position = 'bottom right',
|
|
35
|
+
className,
|
|
36
|
+
contentClassName,
|
|
37
|
+
expandOnMobile,
|
|
38
|
+
headerTitle,
|
|
39
|
+
focusOnMount,
|
|
40
|
+
popoverProps,
|
|
41
|
+
onClose,
|
|
42
|
+
onToggle,
|
|
43
|
+
} = props;
|
|
43
44
|
const containerRef = useRef();
|
|
44
45
|
const [ isOpen, setIsOpen ] = useObservableState( false, onToggle );
|
|
45
46
|
|
package/src/elevation/hook.js
CHANGED
package/src/flex/flex/hook.js
CHANGED
package/src/grid/hook.js
CHANGED
|
@@ -48,7 +48,7 @@ export function useItem( props: WordPressComponentProps< ItemProps, 'div' > ) {
|
|
|
48
48
|
spacedAround && styles.spacedAround,
|
|
49
49
|
className
|
|
50
50
|
),
|
|
51
|
-
[ as, className, size, spacedAround ]
|
|
51
|
+
[ as, className, cx, size, spacedAround ]
|
|
52
52
|
);
|
|
53
53
|
|
|
54
54
|
const wrapperClassName = cx( styles.itemWrapper );
|
|
@@ -145,7 +145,7 @@ const ItemWithChevron = ( {
|
|
|
145
145
|
|
|
146
146
|
const itemClassName = useMemo(
|
|
147
147
|
() => cx( ! alwaysVisible && appearingChevron, className ),
|
|
148
|
-
[ alwaysVisible, className ]
|
|
148
|
+
[ alwaysVisible, className, cx ]
|
|
149
149
|
);
|
|
150
150
|
|
|
151
151
|
const chevronIconClassName = useMemo(
|
|
@@ -155,7 +155,7 @@ const ItemWithChevron = ( {
|
|
|
155
155
|
fill: currentColor;
|
|
156
156
|
transform: ${ isRtlLayout ? 'scaleX( -100% )' : 'none' };
|
|
157
157
|
` ),
|
|
158
|
-
[ isRtlLayout ]
|
|
158
|
+
[ cx, isRtlLayout ]
|
|
159
159
|
);
|
|
160
160
|
|
|
161
161
|
return (
|
|
@@ -72,7 +72,7 @@ describe.each( [
|
|
|
72
72
|
it( 'should display the LINK SETTINGS with an EMPTY LINK TO field.', async () => {
|
|
73
73
|
// Arrange
|
|
74
74
|
const url = 'https://tonytahmouchtest.files.wordpress.com';
|
|
75
|
-
const subject = initializeEditor( { initialHtml } );
|
|
75
|
+
const subject = await initializeEditor( { initialHtml } );
|
|
76
76
|
Clipboard.getString.mockReturnValue( url );
|
|
77
77
|
|
|
78
78
|
// Act
|
|
@@ -109,7 +109,7 @@ describe.each( [
|
|
|
109
109
|
it( 'should display the LINK PICKER with NO FROM CLIPBOARD CELL.', async () => {
|
|
110
110
|
// Arrange
|
|
111
111
|
const url = 'tonytahmouchtest.files.wordpress.com';
|
|
112
|
-
const subject = initializeEditor( { initialHtml } );
|
|
112
|
+
const subject = await initializeEditor( { initialHtml } );
|
|
113
113
|
Clipboard.getString.mockReturnValue( url );
|
|
114
114
|
|
|
115
115
|
// Act
|
|
@@ -162,7 +162,7 @@ describe.each( [
|
|
|
162
162
|
it( 'should display the LINK PICKER with NO FROM CLIPBOARD CELL.', async () => {
|
|
163
163
|
// Arrange
|
|
164
164
|
const url = 'https://tonytahmouchtest.files.wordpress.com';
|
|
165
|
-
const subject = initializeEditor( { initialHtml } );
|
|
165
|
+
const subject = await initializeEditor( { initialHtml } );
|
|
166
166
|
Clipboard.getString.mockReturnValue( url );
|
|
167
167
|
|
|
168
168
|
// Act
|
|
@@ -241,7 +241,7 @@ describe.each( [
|
|
|
241
241
|
async () => {
|
|
242
242
|
// Arrange
|
|
243
243
|
const url = 'https://tonytahmouchtest.files.wordpress.com';
|
|
244
|
-
const subject = initializeEditor( { initialHtml } );
|
|
244
|
+
const subject = await initializeEditor( { initialHtml } );
|
|
245
245
|
Clipboard.getString.mockReturnValue( url );
|
|
246
246
|
|
|
247
247
|
// Act
|
|
@@ -308,7 +308,7 @@ describe.each( [
|
|
|
308
308
|
async () => {
|
|
309
309
|
// Arrange
|
|
310
310
|
const url = 'https://tonytahmouchtest.files.wordpress.com';
|
|
311
|
-
const subject = initializeEditor( { initialHtml } );
|
|
311
|
+
const subject = await initializeEditor( { initialHtml } );
|
|
312
312
|
Clipboard.getString.mockReturnValue( url );
|
|
313
313
|
|
|
314
314
|
// Act
|
package/src/modal/index.js
CHANGED
|
@@ -22,7 +22,6 @@ import {
|
|
|
22
22
|
useConstrainedTabbing,
|
|
23
23
|
useMergeRefs,
|
|
24
24
|
} from '@wordpress/compose';
|
|
25
|
-
import deprecated from '@wordpress/deprecated';
|
|
26
25
|
import { ESCAPE } from '@wordpress/keycodes';
|
|
27
26
|
import { __ } from '@wordpress/i18n';
|
|
28
27
|
import { closeSmall } from '@wordpress/icons';
|
|
@@ -45,8 +44,7 @@ function Modal( props, forwardedRef ) {
|
|
|
45
44
|
focusOnMount = true,
|
|
46
45
|
shouldCloseOnEsc = true,
|
|
47
46
|
shouldCloseOnClickOutside = true,
|
|
48
|
-
|
|
49
|
-
isDismissible = isDismissable || true,
|
|
47
|
+
isDismissible = true,
|
|
50
48
|
/* accessibility */
|
|
51
49
|
aria = {
|
|
52
50
|
labelledby: null,
|
|
@@ -93,13 +91,6 @@ function Modal( props, forwardedRef ) {
|
|
|
93
91
|
};
|
|
94
92
|
}, [] );
|
|
95
93
|
|
|
96
|
-
if ( isDismissable ) {
|
|
97
|
-
deprecated( 'isDismissable prop of the Modal component', {
|
|
98
|
-
since: '5.4',
|
|
99
|
-
alternative: 'isDismissible prop (renamed) of the Modal component',
|
|
100
|
-
} );
|
|
101
|
-
}
|
|
102
|
-
|
|
103
94
|
function handleEscapeKeyDown( event ) {
|
|
104
95
|
if (
|
|
105
96
|
shouldCloseOnEsc &&
|
package/src/navigator/context.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type { NavigatorContext as NavigatorContextType } from './types';
|
|
|
10
10
|
|
|
11
11
|
const initialContextValue: NavigatorContextType = {
|
|
12
12
|
location: {},
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
goTo: () => {},
|
|
14
|
+
goBack: () => {},
|
|
15
15
|
};
|
|
16
16
|
export const NavigatorContext = createContext( initialContextValue );
|
|
@@ -16,19 +16,19 @@ import {
|
|
|
16
16
|
} from '@wordpress/components';
|
|
17
17
|
|
|
18
18
|
function NavigatorButton( { path, ...props } ) {
|
|
19
|
-
const {
|
|
19
|
+
const { goTo } = useNavigator();
|
|
20
20
|
return (
|
|
21
21
|
<Button
|
|
22
22
|
variant="primary"
|
|
23
|
-
onClick={ () =>
|
|
23
|
+
onClick={ () => goTo( path ) }
|
|
24
24
|
{ ...props }
|
|
25
25
|
/>
|
|
26
26
|
);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
function NavigatorBackButton( props ) {
|
|
30
|
-
const {
|
|
31
|
-
return <Button variant="secondary" onClick={ () =>
|
|
30
|
+
const { goBack } = useNavigator();
|
|
31
|
+
return <Button variant="secondary" onClick={ () => goBack() } { ...props } />;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const MyNavigation = () => (
|
|
@@ -64,15 +64,17 @@ You can retrieve a `navigator` instance by using the `useNavigator` hook.
|
|
|
64
64
|
|
|
65
65
|
The `navigator` instance has a few properties:
|
|
66
66
|
|
|
67
|
-
### `
|
|
67
|
+
### `goTo`: `( path: string, options: NavigateOptions ) => void`
|
|
68
68
|
|
|
69
|
-
The `
|
|
69
|
+
The `goTo` function allows navigating to a given path. The second argument can augment the navigation operations with different options.
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
The available options are:
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
- `focusTargetSelector`: `string`. An optional property used to specify the CSS selector used to restore focus on the matching element when navigating back.
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
### `goBack`: `() => void`
|
|
76
|
+
|
|
77
|
+
The `goBack` function allows navigating to the previous path.
|
|
76
78
|
|
|
77
79
|
### `location`: `NavigatorLocation`
|
|
78
80
|
|
|
@@ -42,37 +42,25 @@ function NavigatorProvider(
|
|
|
42
42
|
>( [
|
|
43
43
|
{
|
|
44
44
|
path: initialPath,
|
|
45
|
-
isBack: false,
|
|
46
|
-
isInitial: true,
|
|
47
45
|
},
|
|
48
46
|
] );
|
|
49
47
|
|
|
50
|
-
const
|
|
51
|
-
( path, options ) => {
|
|
52
|
-
// Force the `isBack` flag to `false` when navigating forward on both the
|
|
53
|
-
// previous and the new location.
|
|
54
|
-
// Also force the `isInitial` flag to `false` for the new location, to make
|
|
55
|
-
// sure it doesn't get overridden by mistake.
|
|
48
|
+
const goTo: NavigatorContextType[ 'goTo' ] = useCallback(
|
|
49
|
+
( path, options = {} ) => {
|
|
56
50
|
setLocationHistory( [
|
|
57
|
-
...locationHistory
|
|
58
|
-
{
|
|
59
|
-
...locationHistory[ locationHistory.length - 1 ],
|
|
60
|
-
isBack: false,
|
|
61
|
-
},
|
|
51
|
+
...locationHistory,
|
|
62
52
|
{
|
|
63
53
|
...options,
|
|
64
54
|
path,
|
|
65
55
|
isBack: false,
|
|
66
|
-
isInitial: false,
|
|
67
56
|
},
|
|
68
57
|
] );
|
|
69
58
|
},
|
|
70
59
|
[ locationHistory ]
|
|
71
60
|
);
|
|
72
61
|
|
|
73
|
-
const
|
|
62
|
+
const goBack: NavigatorContextType[ 'goBack' ] = useCallback( () => {
|
|
74
63
|
if ( locationHistory.length > 1 ) {
|
|
75
|
-
// Force the `isBack` flag to `true` when navigating back.
|
|
76
64
|
setLocationHistory( [
|
|
77
65
|
...locationHistory.slice( 0, -2 ),
|
|
78
66
|
{
|
|
@@ -85,18 +73,21 @@ function NavigatorProvider(
|
|
|
85
73
|
|
|
86
74
|
const navigatorContextValue: NavigatorContextType = useMemo(
|
|
87
75
|
() => ( {
|
|
88
|
-
location:
|
|
89
|
-
|
|
90
|
-
|
|
76
|
+
location: {
|
|
77
|
+
...locationHistory[ locationHistory.length - 1 ],
|
|
78
|
+
isInitial: locationHistory.length === 1,
|
|
79
|
+
},
|
|
80
|
+
goTo,
|
|
81
|
+
goBack,
|
|
91
82
|
} ),
|
|
92
|
-
[ locationHistory,
|
|
83
|
+
[ locationHistory, goTo, goBack ]
|
|
93
84
|
);
|
|
94
85
|
|
|
95
86
|
const cx = useCx();
|
|
96
87
|
const classes = useMemo(
|
|
97
88
|
// Prevents horizontal overflow while animating screen transitions
|
|
98
89
|
() => cx( css( { overflowX: 'hidden' } ), className ),
|
|
99
|
-
[ className ]
|
|
90
|
+
[ className, cx ]
|
|
100
91
|
);
|
|
101
92
|
|
|
102
93
|
return (
|
|
@@ -120,19 +111,19 @@ function NavigatorProvider(
|
|
|
120
111
|
* } from '@wordpress/components';
|
|
121
112
|
*
|
|
122
113
|
* function NavigatorButton( { path, ...props } ) {
|
|
123
|
-
* const {
|
|
114
|
+
* const { goTo } = useNavigator();
|
|
124
115
|
* return (
|
|
125
116
|
* <Button
|
|
126
117
|
* variant="primary"
|
|
127
|
-
* onClick={ () =>
|
|
118
|
+
* onClick={ () => goTo( path ) }
|
|
128
119
|
* { ...props }
|
|
129
120
|
* />
|
|
130
121
|
* );
|
|
131
122
|
* }
|
|
132
123
|
*
|
|
133
124
|
* function NavigatorBackButton( props ) {
|
|
134
|
-
* const {
|
|
135
|
-
* return <Button variant="secondary" onClick={ () =>
|
|
125
|
+
* const { goBack } = useNavigator();
|
|
126
|
+
* return <Button variant="secondary" onClick={ () => goBack() } { ...props } />;
|
|
136
127
|
* }
|
|
137
128
|
*
|
|
138
129
|
* const MyNavigation = () => (
|
|
@@ -9,8 +9,13 @@ import { css } from '@emotion/react';
|
|
|
9
9
|
/**
|
|
10
10
|
* WordPress dependencies
|
|
11
11
|
*/
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { focus } from '@wordpress/dom';
|
|
13
|
+
import { useContext, useEffect, useMemo, useRef } from '@wordpress/element';
|
|
14
|
+
import {
|
|
15
|
+
useReducedMotion,
|
|
16
|
+
useMergeRefs,
|
|
17
|
+
usePrevious,
|
|
18
|
+
} from '@wordpress/compose';
|
|
14
19
|
import { isRTL } from '@wordpress/i18n';
|
|
15
20
|
|
|
16
21
|
/**
|
|
@@ -47,7 +52,9 @@ function NavigatorScreen( props: Props, forwardedRef: Ref< any > ) {
|
|
|
47
52
|
const prefersReducedMotion = useReducedMotion();
|
|
48
53
|
const { location } = useContext( NavigatorContext );
|
|
49
54
|
const isMatch = location.path === path;
|
|
50
|
-
const
|
|
55
|
+
const wrapperRef = useRef< HTMLDivElement >( null );
|
|
56
|
+
|
|
57
|
+
const previousLocation = usePrevious( location );
|
|
51
58
|
|
|
52
59
|
const cx = useCx();
|
|
53
60
|
const classes = useMemo(
|
|
@@ -61,15 +68,44 @@ function NavigatorScreen( props: Props, forwardedRef: Ref< any > ) {
|
|
|
61
68
|
} ),
|
|
62
69
|
className
|
|
63
70
|
),
|
|
64
|
-
[ className ]
|
|
71
|
+
[ className, cx ]
|
|
65
72
|
);
|
|
66
73
|
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
const [ hasPathChanged, setHasPathChanged ] = useState( false );
|
|
74
|
+
// Focus restoration
|
|
75
|
+
const isInitialLocation = location.isInitial && ! location.isBack;
|
|
70
76
|
useEffect( () => {
|
|
71
|
-
|
|
72
|
-
|
|
77
|
+
// Only attempt to restore focus:
|
|
78
|
+
// - if the current location is not the initial one (to avoid moving focus on page load)
|
|
79
|
+
// - when the screen becomes visible
|
|
80
|
+
// - if the wrapper ref has been assigned
|
|
81
|
+
if ( isInitialLocation || ! isMatch || ! wrapperRef.current ) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let elementToFocus: HTMLElement | null = null;
|
|
86
|
+
|
|
87
|
+
// When navigating back, if a selector is provided, use it to look for the
|
|
88
|
+
// target element (assumed to be a node inside the current NavigatorScreen)
|
|
89
|
+
if ( location.isBack && previousLocation?.focusTargetSelector ) {
|
|
90
|
+
elementToFocus = wrapperRef.current.querySelector(
|
|
91
|
+
previousLocation.focusTargetSelector
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// If the previous query didn't run or find any element to focus, fallback
|
|
96
|
+
// to the first tabbable element in the screen (or the screen itself).
|
|
97
|
+
if ( ! elementToFocus ) {
|
|
98
|
+
const firstTabbable = ( focus.tabbable.find(
|
|
99
|
+
wrapperRef.current
|
|
100
|
+
) as HTMLElement[] )[ 0 ];
|
|
101
|
+
|
|
102
|
+
elementToFocus = firstTabbable ?? wrapperRef.current;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
elementToFocus.focus();
|
|
106
|
+
}, [ isInitialLocation, isMatch ] );
|
|
107
|
+
|
|
108
|
+
const mergedWrapperRef = useMergeRefs( [ forwardedRef, wrapperRef ] );
|
|
73
109
|
|
|
74
110
|
if ( ! isMatch ) {
|
|
75
111
|
return null;
|
|
@@ -77,7 +113,11 @@ function NavigatorScreen( props: Props, forwardedRef: Ref< any > ) {
|
|
|
77
113
|
|
|
78
114
|
if ( prefersReducedMotion ) {
|
|
79
115
|
return (
|
|
80
|
-
<View
|
|
116
|
+
<View
|
|
117
|
+
ref={ mergedWrapperRef }
|
|
118
|
+
className={ classes }
|
|
119
|
+
{ ...otherProps }
|
|
120
|
+
>
|
|
81
121
|
{ children }
|
|
82
122
|
</View>
|
|
83
123
|
);
|
|
@@ -120,7 +160,7 @@ function NavigatorScreen( props: Props, forwardedRef: Ref< any > ) {
|
|
|
120
160
|
|
|
121
161
|
return (
|
|
122
162
|
<motion.div
|
|
123
|
-
ref={
|
|
163
|
+
ref={ mergedWrapperRef }
|
|
124
164
|
className={ classes }
|
|
125
165
|
{ ...otherProps }
|
|
126
166
|
{ ...animatedProps }
|
|
@@ -142,19 +182,19 @@ function NavigatorScreen( props: Props, forwardedRef: Ref< any > ) {
|
|
|
142
182
|
* } from '@wordpress/components';
|
|
143
183
|
*
|
|
144
184
|
* function NavigatorButton( { path, ...props } ) {
|
|
145
|
-
* const {
|
|
185
|
+
* const { goTo } = useNavigator();
|
|
146
186
|
* return (
|
|
147
187
|
* <Button
|
|
148
188
|
* variant="primary"
|
|
149
|
-
* onClick={ () =>
|
|
189
|
+
* onClick={ () => goTo( path ) }
|
|
150
190
|
* { ...props }
|
|
151
191
|
* />
|
|
152
192
|
* );
|
|
153
193
|
* }
|
|
154
194
|
*
|
|
155
195
|
* function NavigatorBackButton( props ) {
|
|
156
|
-
* const {
|
|
157
|
-
* return <Button variant="secondary" onClick={ () =>
|
|
196
|
+
* const { goBack } = useNavigator();
|
|
197
|
+
* return <Button variant="secondary" onClick={ () => goBack() } { ...props } />;
|
|
158
198
|
* }
|
|
159
199
|
*
|
|
160
200
|
* const MyNavigation = () => (
|