@wordpress/components 25.1.4 → 25.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 +20 -5
- package/build/guide/index.js +10 -11
- package/build/guide/index.js.map +1 -1
- package/build/mobile/bottom-sheet/cell.native.js +2 -1
- package/build/mobile/bottom-sheet/cell.native.js.map +1 -1
- package/build/number-control/index.js.map +1 -1
- package/build/range-control/index.js +7 -1
- package/build/range-control/index.js.map +1 -1
- package/build/range-control/input-range.js.map +1 -1
- package/build/range-control/styles/range-control-styles.js +35 -36
- package/build/range-control/styles/range-control-styles.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/index.js +10 -10
- package/build-module/guide/index.js.map +1 -1
- package/build-module/mobile/bottom-sheet/cell.native.js +2 -1
- package/build-module/mobile/bottom-sheet/cell.native.js.map +1 -1
- package/build-module/number-control/index.js.map +1 -1
- package/build-module/range-control/index.js +6 -1
- package/build-module/range-control/index.js.map +1 -1
- package/build-module/range-control/input-range.js.map +1 -1
- package/build-module/range-control/styles/range-control-styles.js +35 -36
- package/build-module/range-control/styles/range-control-styles.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 +3 -7
- package/build-style/style.css +3 -7
- package/build-types/color-picker/styles.d.ts +2 -1
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/guide/index.d.ts.map +1 -1
- package/build-types/number-control/index.d.ts.map +1 -1
- package/build-types/range-control/index.d.ts +15 -2
- package/build-types/range-control/index.d.ts.map +1 -1
- package/build-types/range-control/input-range.d.ts.map +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts +4 -2
- package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
- package/build-types/range-control/types.d.ts +6 -0
- package/build-types/range-control/types.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts.map +1 -1
- package/package.json +19 -19
- package/src/dropdown-menu/style.scss +9 -13
- package/src/guide/index.tsx +10 -13
- package/src/mobile/bottom-sheet/cell.native.js +1 -0
- package/src/number-control/index.tsx +0 -1
- package/src/range-control/index.tsx +14 -2
- package/src/range-control/input-range.tsx +0 -1
- package/src/range-control/styles/range-control-styles.ts +12 -3
- package/src/range-control/types.ts +6 -0
- package/src/unit-control/index.tsx +3 -2
- package/src/unit-control/test/index.tsx +5 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -203,6 +203,12 @@ export type RangeControlProps = Pick<
|
|
|
203
203
|
* @default 10
|
|
204
204
|
*/
|
|
205
205
|
shiftStep?: number;
|
|
206
|
+
/**
|
|
207
|
+
* Start opting into the larger default height that will become the default size in a future version.
|
|
208
|
+
*
|
|
209
|
+
* @default false
|
|
210
|
+
*/
|
|
211
|
+
__next40pxDefaultSize?: boolean;
|
|
206
212
|
/**
|
|
207
213
|
* Forcing the Tooltip UI to show or hide. This is overridden to `false`
|
|
208
214
|
* when `step` is set to the special string value `any`.
|
|
@@ -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 () => {
|