@wordpress/components 25.1.3 → 25.1.5
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 +8 -1
- package/build/guide/icons.js +2 -5
- package/build/guide/icons.js.map +1 -1
- package/build/guide/index.js +14 -11
- package/build/guide/index.js.map +1 -1
- package/build/guide/page-control.js +1 -3
- package/build/guide/page-control.js.map +1 -1
- package/build/unit-control/index.js +4 -2
- package/build/unit-control/index.js.map +1 -1
- package/build-module/guide/icons.js +2 -5
- package/build-module/guide/icons.js.map +1 -1
- package/build-module/guide/index.js +14 -10
- package/build-module/guide/index.js.map +1 -1
- package/build-module/guide/page-control.js +1 -3
- package/build-module/guide/page-control.js.map +1 -1
- package/build-module/unit-control/index.js +3 -2
- package/build-module/unit-control/index.js.map +1 -1
- package/build-style/style-rtl.css +6 -19
- package/build-style/style.css +6 -19
- package/build-types/guide/icons.d.ts +1 -3
- package/build-types/guide/icons.d.ts.map +1 -1
- package/build-types/guide/index.d.ts.map +1 -1
- package/build-types/guide/page-control.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/guide/icons.tsx +2 -7
- package/src/guide/index.tsx +14 -13
- package/src/guide/page-control.tsx +1 -5
- package/src/guide/style.scss +8 -24
- package/src/unit-control/index.tsx +3 -2
- package/src/unit-control/test/index.tsx +5 -2
- package/tsconfig.tsbuildinfo +1 -1
package/build-style/style.css
CHANGED
|
@@ -1636,7 +1636,7 @@ body.is-dragging-components-draggable {
|
|
|
1636
1636
|
.components-guide__footer {
|
|
1637
1637
|
align-content: center;
|
|
1638
1638
|
display: flex;
|
|
1639
|
-
height:
|
|
1639
|
+
height: 36px;
|
|
1640
1640
|
justify-content: center;
|
|
1641
1641
|
margin: 0 0 24px 0;
|
|
1642
1642
|
padding: 0 32px;
|
|
@@ -1655,12 +1655,15 @@ body.is-dragging-components-draggable {
|
|
|
1655
1655
|
height: 30px;
|
|
1656
1656
|
min-width: 20px;
|
|
1657
1657
|
margin: -6px 0;
|
|
1658
|
+
color: #e0e0e0;
|
|
1659
|
+
}
|
|
1660
|
+
.components-guide__page-control li[aria-current=step] .components-button {
|
|
1661
|
+
color: var(--wp-components-color-accent, var(--wp-admin-theme-color));
|
|
1658
1662
|
}
|
|
1659
1663
|
|
|
1660
1664
|
.components-modal__frame.components-guide {
|
|
1661
1665
|
border: none;
|
|
1662
1666
|
min-width: 312px;
|
|
1663
|
-
height: 80vh;
|
|
1664
1667
|
max-height: 575px;
|
|
1665
1668
|
}
|
|
1666
1669
|
@media (max-width: 600px) {
|
|
@@ -1671,28 +1674,12 @@ body.is-dragging-components-draggable {
|
|
|
1671
1674
|
}
|
|
1672
1675
|
|
|
1673
1676
|
.components-button.components-guide__back-button, .components-button.components-guide__forward-button, .components-button.components-guide__finish-button {
|
|
1674
|
-
height: 30px;
|
|
1675
1677
|
position: absolute;
|
|
1676
1678
|
}
|
|
1677
|
-
.components-button.components-guide__back-button, .components-button.components-guide__forward-button {
|
|
1678
|
-
font-size: 13px;
|
|
1679
|
-
padding: 4px 2px;
|
|
1680
|
-
}
|
|
1681
|
-
.components-button.components-guide__back-button.has-text svg, .components-button.components-guide__forward-button.has-text svg {
|
|
1682
|
-
margin: 0;
|
|
1683
|
-
}
|
|
1684
|
-
.components-button.components-guide__back-button:hover, .components-button.components-guide__forward-button:hover {
|
|
1685
|
-
text-decoration: underline;
|
|
1686
|
-
}
|
|
1687
1679
|
.components-button.components-guide__back-button {
|
|
1688
1680
|
left: 32px;
|
|
1689
1681
|
}
|
|
1690
|
-
.components-button.components-guide__forward-button {
|
|
1691
|
-
right: 32px;
|
|
1692
|
-
color: #1386bf;
|
|
1693
|
-
font-weight: bold;
|
|
1694
|
-
}
|
|
1695
|
-
.components-button.components-guide__finish-button {
|
|
1682
|
+
.components-button.components-guide__forward-button, .components-button.components-guide__finish-button {
|
|
1696
1683
|
right: 32px;
|
|
1697
1684
|
}
|
|
1698
1685
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/guide/icons.tsx"],"names":[],"mappings":";AAKA,eAAO,MAAM,eAAe
|
|
1
|
+
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/guide/icons.tsx"],"names":[],"mappings":";AAKA,eAAO,MAAM,eAAe,mBAI3B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/guide/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/guide/index.tsx"],"names":[],"mappings":";AAkBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,iBAAS,KAAK,CAAE,EACf,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,gBAAiC,EACjC,QAAQ,EACR,KAAU,GACV,EAAE,UAAU,sBAiHZ;AAED,eAAe,KAAK,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-control.d.ts","sourceRoot":"","sources":["../../src/guide/page-control.tsx"],"names":[],"mappings":";AAUA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAE,EACpC,WAAW,EACX,aAAa,EACb,cAAc,GACd,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"page-control.d.ts","sourceRoot":"","sources":["../../src/guide/page-control.tsx"],"names":[],"mappings":";AAUA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAE,EACpC,WAAW,EACX,aAAa,EACb,cAAc,GACd,EAAE,gBAAgB,eA2BlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/unit-control/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/unit-control/index.tsx"],"names":[],"mappings":";AA2BA,OAAO,KAAK,EAAoB,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAkM7E;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW;;;;;;;;y+KAAuC,CAAC;AAEhE,OAAO,EAAE,gCAAgC,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC3E,eAAe,WAAW,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/components",
|
|
3
|
-
"version": "25.1.
|
|
3
|
+
"version": "25.1.5",
|
|
4
4
|
"description": "UI components for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@emotion/styled": "^11.6.0",
|
|
40
40
|
"@emotion/utils": "^1.0.0",
|
|
41
41
|
"@floating-ui/react-dom": "1.0.0",
|
|
42
|
-
"@radix-ui/react-dropdown-menu": "
|
|
42
|
+
"@radix-ui/react-dropdown-menu": "2.0.4",
|
|
43
43
|
"@use-gesture/react": "^10.2.24",
|
|
44
44
|
"@wordpress/a11y": "^3.35.1",
|
|
45
45
|
"@wordpress/compose": "^6.12.1",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@wordpress/keycodes": "^3.35.1",
|
|
57
57
|
"@wordpress/primitives": "^3.33.1",
|
|
58
58
|
"@wordpress/private-apis": "^0.17.1",
|
|
59
|
-
"@wordpress/rich-text": "^6.12.
|
|
59
|
+
"@wordpress/rich-text": "^6.12.3",
|
|
60
60
|
"@wordpress/warning": "^2.35.1",
|
|
61
61
|
"change-case": "^4.1.2",
|
|
62
62
|
"classnames": "^2.3.1",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"publishConfig": {
|
|
88
88
|
"access": "public"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "3eeb607ebb76c3bf06cb8acb462f0dc068f340f9"
|
|
91
91
|
}
|
package/src/guide/icons.tsx
CHANGED
|
@@ -3,13 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { SVG, Circle } from '@wordpress/primitives';
|
|
5
5
|
|
|
6
|
-
export const PageControlIcon = (
|
|
6
|
+
export const PageControlIcon = () => (
|
|
7
7
|
<SVG width="8" height="8" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
8
|
-
<Circle
|
|
9
|
-
cx="4"
|
|
10
|
-
cy="4"
|
|
11
|
-
r="4"
|
|
12
|
-
fill={ isSelected ? '#419ECD' : '#E1E3E6' }
|
|
13
|
-
/>
|
|
8
|
+
<Circle cx="4" cy="4" r="4" />
|
|
14
9
|
</SVG>
|
|
15
10
|
);
|
package/src/guide/index.tsx
CHANGED
|
@@ -9,7 +9,6 @@ import classnames from 'classnames';
|
|
|
9
9
|
import { useState, useEffect, Children, useRef } from '@wordpress/element';
|
|
10
10
|
import deprecated from '@wordpress/deprecated';
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
|
-
import { focus } from '@wordpress/dom';
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* Internal dependencies
|
|
@@ -59,9 +58,17 @@ function Guide( {
|
|
|
59
58
|
onFinish,
|
|
60
59
|
pages = [],
|
|
61
60
|
}: GuideProps ) {
|
|
62
|
-
const
|
|
61
|
+
const ref = useRef< HTMLDivElement >( null );
|
|
63
62
|
const [ currentPage, setCurrentPage ] = useState( 0 );
|
|
64
63
|
|
|
64
|
+
useEffect( () => {
|
|
65
|
+
// Place focus at the top of the guide on mount and when the page changes.
|
|
66
|
+
const frame = ref.current?.querySelector( '.components-guide' );
|
|
67
|
+
if ( frame instanceof HTMLElement ) {
|
|
68
|
+
frame.focus();
|
|
69
|
+
}
|
|
70
|
+
}, [ currentPage ] );
|
|
71
|
+
|
|
65
72
|
useEffect( () => {
|
|
66
73
|
if ( Children.count( children ) ) {
|
|
67
74
|
deprecated( 'Passing children to <Guide>', {
|
|
@@ -71,16 +78,6 @@ function Guide( {
|
|
|
71
78
|
}
|
|
72
79
|
}, [ children ] );
|
|
73
80
|
|
|
74
|
-
useEffect( () => {
|
|
75
|
-
// Each time we change the current page, start from the first element of the page.
|
|
76
|
-
// This also solves any focus loss that can happen.
|
|
77
|
-
if ( guideContainer.current ) {
|
|
78
|
-
(
|
|
79
|
-
focus.tabbable.find( guideContainer.current ) as HTMLElement[]
|
|
80
|
-
)[ 0 ]?.focus();
|
|
81
|
-
}
|
|
82
|
-
}, [ currentPage ] );
|
|
83
|
-
|
|
84
81
|
if ( Children.count( children ) ) {
|
|
85
82
|
pages =
|
|
86
83
|
Children.map( children, ( child ) => ( {
|
|
@@ -111,6 +108,7 @@ function Guide( {
|
|
|
111
108
|
<Modal
|
|
112
109
|
className={ classnames( 'components-guide', className ) }
|
|
113
110
|
contentLabel={ contentLabel }
|
|
111
|
+
isDismissible={ pages.length > 1 }
|
|
114
112
|
onRequestClose={ onFinish }
|
|
115
113
|
onKeyDown={ ( event ) => {
|
|
116
114
|
if ( event.code === 'ArrowLeft' ) {
|
|
@@ -123,7 +121,7 @@ function Guide( {
|
|
|
123
121
|
event.preventDefault();
|
|
124
122
|
}
|
|
125
123
|
} }
|
|
126
|
-
ref={
|
|
124
|
+
ref={ ref }
|
|
127
125
|
>
|
|
128
126
|
<div className="components-guide__container">
|
|
129
127
|
<div className="components-guide__page">
|
|
@@ -144,6 +142,7 @@ function Guide( {
|
|
|
144
142
|
{ canGoBack && (
|
|
145
143
|
<Button
|
|
146
144
|
className="components-guide__back-button"
|
|
145
|
+
variant="tertiary"
|
|
147
146
|
onClick={ goBack }
|
|
148
147
|
>
|
|
149
148
|
{ __( 'Previous' ) }
|
|
@@ -152,6 +151,7 @@ function Guide( {
|
|
|
152
151
|
{ canGoForward && (
|
|
153
152
|
<Button
|
|
154
153
|
className="components-guide__forward-button"
|
|
154
|
+
variant="primary"
|
|
155
155
|
onClick={ goForward }
|
|
156
156
|
>
|
|
157
157
|
{ __( 'Next' ) }
|
|
@@ -160,6 +160,7 @@ function Guide( {
|
|
|
160
160
|
{ ! canGoForward && (
|
|
161
161
|
<Button
|
|
162
162
|
className="components-guide__finish-button"
|
|
163
|
+
variant="primary"
|
|
163
164
|
onClick={ onFinish }
|
|
164
165
|
>
|
|
165
166
|
{ finishButtonText }
|
|
@@ -28,11 +28,7 @@ export default function PageControl( {
|
|
|
28
28
|
>
|
|
29
29
|
<Button
|
|
30
30
|
key={ page }
|
|
31
|
-
icon={
|
|
32
|
-
<PageControlIcon
|
|
33
|
-
isSelected={ page === currentPage }
|
|
34
|
-
/>
|
|
35
|
-
}
|
|
31
|
+
icon={ <PageControlIcon /> }
|
|
36
32
|
aria-label={ sprintf(
|
|
37
33
|
/* translators: 1: current page number 2: total number of pages */
|
|
38
34
|
__( 'Page %1$d of %2$d' ),
|
package/src/guide/style.scss
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
|
|
30
30
|
&:hover {
|
|
31
31
|
svg {
|
|
32
|
-
fill:
|
|
32
|
+
fill: $white;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
&__footer {
|
|
58
58
|
align-content: center;
|
|
59
59
|
display: flex;
|
|
60
|
-
height:
|
|
60
|
+
height: $button-size;
|
|
61
61
|
justify-content: center;
|
|
62
62
|
margin: 0 0 $grid-unit-30 0;
|
|
63
63
|
padding: 0 $grid-unit-40;
|
|
@@ -78,6 +78,11 @@
|
|
|
78
78
|
height: 30px;
|
|
79
79
|
min-width: 20px;
|
|
80
80
|
margin: -6px 0;
|
|
81
|
+
color: $gray-200;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
li[aria-current="step"] .components-button {
|
|
85
|
+
color: var(--wp-components-color-accent, var(--wp-admin-theme-color));
|
|
81
86
|
}
|
|
82
87
|
}
|
|
83
88
|
}
|
|
@@ -85,7 +90,6 @@
|
|
|
85
90
|
.components-modal__frame.components-guide {
|
|
86
91
|
border: none;
|
|
87
92
|
min-width: 312px;
|
|
88
|
-
height: 80vh;
|
|
89
93
|
max-height: 575px;
|
|
90
94
|
|
|
91
95
|
@media ( max-width: $break-small ) {
|
|
@@ -98,34 +102,14 @@
|
|
|
98
102
|
&.components-guide__back-button,
|
|
99
103
|
&.components-guide__forward-button,
|
|
100
104
|
&.components-guide__finish-button {
|
|
101
|
-
height: 30px;
|
|
102
105
|
position: absolute;
|
|
103
106
|
}
|
|
104
107
|
|
|
105
|
-
&.components-guide__back-button,
|
|
106
|
-
&.components-guide__forward-button {
|
|
107
|
-
font-size: $default-font-size;
|
|
108
|
-
padding: 4px 2px;
|
|
109
|
-
|
|
110
|
-
&.has-text svg {
|
|
111
|
-
margin: 0;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
&:hover {
|
|
115
|
-
text-decoration: underline;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
108
|
&.components-guide__back-button {
|
|
120
109
|
left: $grid-unit-40;
|
|
121
110
|
}
|
|
122
111
|
|
|
123
|
-
&.components-guide__forward-button
|
|
124
|
-
right: $grid-unit-40;
|
|
125
|
-
color: #1386bf;
|
|
126
|
-
font-weight: bold;
|
|
127
|
-
}
|
|
128
|
-
|
|
112
|
+
&.components-guide__forward-button,
|
|
129
113
|
&.components-guide__finish-button {
|
|
130
114
|
right: $grid-unit-40;
|
|
131
115
|
}
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
getValidParsedQuantityAndUnit,
|
|
25
25
|
} from './utils';
|
|
26
26
|
import { useControlledState } from '../utils/hooks';
|
|
27
|
+
import { escapeRegExp } from '../utils/strings';
|
|
27
28
|
import type { UnitControlProps, UnitControlOnChangeCallback } from './types';
|
|
28
29
|
|
|
29
30
|
function UnforwardedUnitControl(
|
|
@@ -76,9 +77,9 @@ function UnforwardedUnitControl(
|
|
|
76
77
|
);
|
|
77
78
|
const [ { value: firstUnitValue = '' } = {}, ...rest ] = list;
|
|
78
79
|
const firstCharacters = rest.reduce( ( carry, { value } ) => {
|
|
79
|
-
const first = value?.substring( 0, 1 ) || '';
|
|
80
|
+
const first = escapeRegExp( value?.substring( 0, 1 ) || '' );
|
|
80
81
|
return carry.includes( first ) ? carry : `${ carry }|${ first }`;
|
|
81
|
-
}, firstUnitValue.substring( 0, 1 ) );
|
|
82
|
+
}, escapeRegExp( firstUnitValue.substring( 0, 1 ) ) );
|
|
82
83
|
return [ list, new RegExp( `^(?:${ firstCharacters })$`, 'i' ) ];
|
|
83
84
|
}, [ nonNullValueProp, unitProp, unitsProp ] );
|
|
84
85
|
const [ parsedQuantity, parsedUnit ] = getParsedQuantityAndUnit(
|
|
@@ -373,18 +373,21 @@ describe( 'UnitControl', () => {
|
|
|
373
373
|
const units = [
|
|
374
374
|
{ value: 'pt', label: 'pt', default: 0 },
|
|
375
375
|
{ value: 'vmax', label: 'vmax', default: 10 },
|
|
376
|
+
// Proves that units with regex control characters don't error.
|
|
377
|
+
{ value: '+', label: '+', default: 10 },
|
|
376
378
|
];
|
|
377
379
|
|
|
378
380
|
render( <UnitControl units={ units } /> );
|
|
379
381
|
|
|
380
382
|
const options = getSelectOptions();
|
|
381
383
|
|
|
382
|
-
expect( options.length ).toBe(
|
|
384
|
+
expect( options.length ).toBe( 3 );
|
|
383
385
|
|
|
384
|
-
const [ pt, vmax ] = options;
|
|
386
|
+
const [ pt, vmax, plus ] = options;
|
|
385
387
|
|
|
386
388
|
expect( pt.value ).toBe( 'pt' );
|
|
387
389
|
expect( vmax.value ).toBe( 'vmax' );
|
|
390
|
+
expect( plus.value ).toBe( '+' );
|
|
388
391
|
} );
|
|
389
392
|
|
|
390
393
|
it( 'should reset value on unit change, if unit has default value', async () => {
|