@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.
Files changed (51) hide show
  1. package/CHANGELOG.md +20 -5
  2. package/build/guide/index.js +10 -11
  3. package/build/guide/index.js.map +1 -1
  4. package/build/mobile/bottom-sheet/cell.native.js +2 -1
  5. package/build/mobile/bottom-sheet/cell.native.js.map +1 -1
  6. package/build/number-control/index.js.map +1 -1
  7. package/build/range-control/index.js +7 -1
  8. package/build/range-control/index.js.map +1 -1
  9. package/build/range-control/input-range.js.map +1 -1
  10. package/build/range-control/styles/range-control-styles.js +35 -36
  11. package/build/range-control/styles/range-control-styles.js.map +1 -1
  12. package/build/unit-control/index.js +4 -2
  13. package/build/unit-control/index.js.map +1 -1
  14. package/build-module/guide/index.js +10 -10
  15. package/build-module/guide/index.js.map +1 -1
  16. package/build-module/mobile/bottom-sheet/cell.native.js +2 -1
  17. package/build-module/mobile/bottom-sheet/cell.native.js.map +1 -1
  18. package/build-module/number-control/index.js.map +1 -1
  19. package/build-module/range-control/index.js +6 -1
  20. package/build-module/range-control/index.js.map +1 -1
  21. package/build-module/range-control/input-range.js.map +1 -1
  22. package/build-module/range-control/styles/range-control-styles.js +35 -36
  23. package/build-module/range-control/styles/range-control-styles.js.map +1 -1
  24. package/build-module/unit-control/index.js +3 -2
  25. package/build-module/unit-control/index.js.map +1 -1
  26. package/build-style/style-rtl.css +3 -7
  27. package/build-style/style.css +3 -7
  28. package/build-types/color-picker/styles.d.ts +2 -1
  29. package/build-types/color-picker/styles.d.ts.map +1 -1
  30. package/build-types/guide/index.d.ts.map +1 -1
  31. package/build-types/number-control/index.d.ts.map +1 -1
  32. package/build-types/range-control/index.d.ts +15 -2
  33. package/build-types/range-control/index.d.ts.map +1 -1
  34. package/build-types/range-control/input-range.d.ts.map +1 -1
  35. package/build-types/range-control/styles/range-control-styles.d.ts +4 -2
  36. package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
  37. package/build-types/range-control/types.d.ts +6 -0
  38. package/build-types/range-control/types.d.ts.map +1 -1
  39. package/build-types/unit-control/index.d.ts.map +1 -1
  40. package/package.json +19 -19
  41. package/src/dropdown-menu/style.scss +9 -13
  42. package/src/guide/index.tsx +10 -13
  43. package/src/mobile/bottom-sheet/cell.native.js +1 -0
  44. package/src/number-control/index.tsx +0 -1
  45. package/src/range-control/index.tsx +14 -2
  46. package/src/range-control/input-range.tsx +0 -1
  47. package/src/range-control/styles/range-control-styles.ts +12 -3
  48. package/src/range-control/types.ts +6 -0
  49. package/src/unit-control/index.tsx +3 -2
  50. package/src/unit-control/test/index.tsx +5 -2
  51. 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( 2 );
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 () => {