@wordpress/components 30.6.1-next.ff1cebbba.0 → 30.6.2

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 (56) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/build/custom-select-control-v2/custom-select.js +2 -2
  3. package/build/custom-select-control-v2/custom-select.js.map +2 -2
  4. package/build/font-size-picker/font-size-picker-select.js +20 -19
  5. package/build/font-size-picker/font-size-picker-select.js.map +3 -3
  6. package/build/font-size-picker/font-size-picker-toggle-group.js +27 -3
  7. package/build/font-size-picker/font-size-picker-toggle-group.js.map +2 -2
  8. package/build/font-size-picker/index.js +23 -11
  9. package/build/font-size-picker/index.js.map +2 -2
  10. package/build/font-size-picker/styles.js +30 -13
  11. package/build/font-size-picker/styles.js.map +3 -3
  12. package/build/font-size-picker/utils.js +11 -0
  13. package/build/font-size-picker/utils.js.map +2 -2
  14. package/build-module/custom-select-control-v2/custom-select.js +1 -1
  15. package/build-module/custom-select-control-v2/custom-select.js.map +1 -1
  16. package/build-module/font-size-picker/font-size-picker-select.js +21 -10
  17. package/build-module/font-size-picker/font-size-picker-select.js.map +2 -2
  18. package/build-module/font-size-picker/font-size-picker-toggle-group.js +27 -3
  19. package/build-module/font-size-picker/font-size-picker-toggle-group.js.map +2 -2
  20. package/build-module/font-size-picker/index.js +23 -11
  21. package/build-module/font-size-picker/index.js.map +2 -2
  22. package/build-module/font-size-picker/styles.js +28 -12
  23. package/build-module/font-size-picker/styles.js.map +2 -2
  24. package/build-module/font-size-picker/utils.js +10 -0
  25. package/build-module/font-size-picker/utils.js.map +2 -2
  26. package/build-style/style-rtl.css +4 -3
  27. package/build-style/style.css +4 -3
  28. package/build-types/font-size-picker/font-size-picker-select.d.ts +3 -0
  29. package/build-types/font-size-picker/font-size-picker-select.d.ts.map +1 -1
  30. package/build-types/font-size-picker/font-size-picker-toggle-group.d.ts.map +1 -1
  31. package/build-types/font-size-picker/index.d.ts.map +1 -1
  32. package/build-types/font-size-picker/styles.d.ts +3 -0
  33. package/build-types/font-size-picker/styles.d.ts.map +1 -1
  34. package/build-types/font-size-picker/test/font-size-picker-select.d.ts +2 -0
  35. package/build-types/font-size-picker/test/font-size-picker-select.d.ts.map +1 -0
  36. package/build-types/font-size-picker/test/font-size-picker-toggle-group.d.ts +2 -0
  37. package/build-types/font-size-picker/test/font-size-picker-toggle-group.d.ts.map +1 -0
  38. package/build-types/font-size-picker/types.d.ts +18 -4
  39. package/build-types/font-size-picker/types.d.ts.map +1 -1
  40. package/build-types/font-size-picker/utils.d.ts +10 -1
  41. package/build-types/font-size-picker/utils.d.ts.map +1 -1
  42. package/package.json +20 -20
  43. package/src/badge/styles.scss +1 -0
  44. package/src/button/style.scss +3 -3
  45. package/src/custom-select-control-v2/custom-select.tsx +1 -1
  46. package/src/font-size-picker/README.md +10 -0
  47. package/src/font-size-picker/font-size-picker-select.tsx +44 -11
  48. package/src/font-size-picker/font-size-picker-toggle-group.tsx +58 -4
  49. package/src/font-size-picker/index.tsx +44 -19
  50. package/src/font-size-picker/styles.ts +9 -0
  51. package/src/font-size-picker/test/font-size-picker-select.tsx +221 -0
  52. package/src/font-size-picker/test/font-size-picker-toggle-group.tsx +275 -0
  53. package/src/font-size-picker/test/index.tsx +460 -2
  54. package/src/font-size-picker/types.ts +24 -4
  55. package/src/font-size-picker/utils.ts +23 -1
  56. package/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"font-size-picker-select.d.ts","sourceRoot":"","sources":["../../src/font-size-picker/font-size-picker-select.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EACX,yBAAyB,EAEzB,MAAM,SAAS,CAAC;AASjB,QAAA,MAAM,oBAAoB,UAAY,yBAAyB,gCA+C9D,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"font-size-picker-select.d.ts","sourceRoot":"","sources":["../../src/font-size-picker/font-size-picker-select.tsx"],"names":[],"mappings":"AAMA;;GAEG;AACH,OAAO,KAAK,EACX,yBAAyB,EAEzB,MAAM,SAAS,CAAC;AAUjB,QAAA,MAAM,oBAAoB,UAAY,yBAAyB,gCA+E9D,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"font-size-picker-toggle-group.d.ts","sourceRoot":"","sources":["../../src/font-size-picker/font-size-picker-toggle-group.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC;AAE9D,QAAA,MAAM,yBAAyB,UAAY,8BAA8B,gCAyBxE,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
1
+ {"version":3,"file":"font-size-picker-toggle-group.d.ts","sourceRoot":"","sources":["../../src/font-size-picker/font-size-picker-toggle-group.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC;AAE9D,QAAA,MAAM,yBAAyB,UAAY,8BAA8B,gCA+ExE,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/font-size-picker/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAwPnD,eAAO,MAAM,cAAc,qGAA0C,CAAC;AAEtE,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/font-size-picker/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAiRnD,eAAO,MAAM,cAAc,qGAA0C,CAAC;AAEtE,eAAe,cAAc,CAAC"}
@@ -18,4 +18,7 @@ export declare const HeaderLabel: import("@emotion/styled").StyledComponent<impo
18
18
  } & import("react").RefAttributes<any> & {
19
19
  theme?: import("@emotion/react").Theme;
20
20
  }, {}, {}>;
21
+ export declare const StyledCustomSelectControl: import("@emotion/styled").StyledComponent<import("../custom-select-control/types").CustomSelectProps<import("../custom-select-control/types").CustomSelectOption> & {
22
+ theme?: import("@emotion/react").Theme;
23
+ }, {}, {}>;
21
24
  //# sourceMappingURL=styles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/font-size-picker/styles.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,SAAS;;SAeR,MAAO,WAAW;2HAV/B,CAAC;AAEF,eAAO,MAAM,MAAM;;;;;;;UAElB,CAAC;AAEF,eAAO,MAAM,YAAY;;UAExB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;UAKvB,CAAC"}
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/font-size-picker/styles.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,SAAS;;SAWc,MAAO,WACpC;2HAPN,CAAC;AAEF,eAAO,MAAM,MAAM;;;;;;;UAElB,CAAC;AAEF,eAAO,MAAM,YAAY;;UAExB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;UAKvB,CAAC;AAGF,eAAO,MAAM,yBAAyB;;UAKrC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=font-size-picker-select.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"font-size-picker-select.d.ts","sourceRoot":"","sources":["../../../src/font-size-picker/test/font-size-picker-select.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=font-size-picker-toggle-group.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"font-size-picker-toggle-group.d.ts","sourceRoot":"","sources":["../../../src/font-size-picker/test/font-size-picker-toggle-group.tsx"],"names":[],"mappings":""}
@@ -37,6 +37,14 @@ export type FontSizePickerProps = {
37
37
  * as a number, the component operates in "unitless mode" where the `units` property has no effect.
38
38
  */
39
39
  value?: number | string;
40
+ /**
41
+ * Determines how the `value` prop should be interpreted.
42
+ * - `'literal'`: The `value` prop contains the actual font size value (number or string)
43
+ * - `'slug'`: The `value` prop contains the slug of the selected font size
44
+ *
45
+ * @default 'literal'
46
+ */
47
+ valueMode?: 'literal' | 'slug';
40
48
  /**
41
49
  * If `true`, a slider will be displayed alongside the input field when a
42
50
  * custom font size is active. Has no effect when `disableCustomFontSizes`
@@ -92,11 +100,17 @@ export type FontSize = {
92
100
  * size. Used for the class generation process.
93
101
  */
94
102
  slug: string;
103
+ /**
104
+ * The `hint` property is an optional string that provides additional information
105
+ * about the font size, such as fluid typography ranges or custom descriptions.
106
+ * Consumers can use this to provide their own preferred hints.
107
+ */
108
+ hint?: string;
95
109
  };
96
- export type FontSizePickerSelectProps = Pick<FontSizePickerProps, 'value' | 'size'> & {
110
+ export type FontSizePickerSelectProps = Pick<FontSizePickerProps, 'value' | 'size' | 'valueMode'> & {
97
111
  fontSizes: NonNullable<FontSizePickerProps['fontSizes']>;
98
112
  disableCustomFontSizes: NonNullable<FontSizePickerProps['disableCustomFontSizes']>;
99
- onChange: NonNullable<FontSizePickerProps['onChange']>;
113
+ onChange: (value: number | string | undefined, selectedItem?: FontSize) => void;
100
114
  onSelectCustom: () => void;
101
115
  __next40pxDefaultSize: boolean;
102
116
  };
@@ -106,8 +120,8 @@ export type FontSizePickerSelectOption = {
106
120
  value?: FontSize['size'];
107
121
  hint?: string;
108
122
  };
109
- export type FontSizePickerToggleGroupProps = Pick<FontSizePickerProps, 'value' | 'size' | '__next40pxDefaultSize'> & {
123
+ export type FontSizePickerToggleGroupProps = Pick<FontSizePickerProps, 'value' | 'size' | '__next40pxDefaultSize' | 'valueMode'> & {
110
124
  fontSizes: NonNullable<FontSizePickerProps['fontSizes']>;
111
- onChange: NonNullable<FontSizePickerProps['onChange']>;
125
+ onChange: (value: number | string | undefined, selectedItem?: FontSize) => void;
112
126
  };
113
127
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/font-size-picker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AW,CAAE,mBAAmB,CAAE,WAAW,CAAE,CAAE,CAAC;IAC7D,QAAQ,EAAE,CACT,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EAClC,YAAY,CAAC,EAAE,QAAQ,KACnB,IAAI,CAAC;CACV,CAAC"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Internal dependencies
3
3
  */
4
- import type { FontSizePickerProps } from './types';
4
+ import type { FontSizePickerProps, FontSize } from './types';
5
5
  /**
6
6
  * Some themes use css vars for their font sizes, so until we
7
7
  * have the way of calculating them don't display them.
@@ -10,4 +10,13 @@ import type { FontSizePickerProps } from './types';
10
10
  * @return Whether the value is a simple css value.
11
11
  */
12
12
  export declare function isSimpleCssValue(value: NonNullable<FontSizePickerProps['value']>): boolean;
13
+ /**
14
+ * Generates hint text for a font size.
15
+ * This function returns the hint provided by the consumer, if any.
16
+ * If no hint is provided, it falls back to showing the size value for simple CSS values.
17
+ *
18
+ * @param fontSize The font size object to generate hint text for.
19
+ * @return The hint text provided by the consumer, or the size value for simple CSS values, or undefined.
20
+ */
21
+ export declare function generateFontSizeHint(fontSize: FontSize): string | undefined;
13
22
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/font-size-picker/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,WAAW,CAAE,mBAAmB,CAAE,OAAO,CAAE,CAAE,WAKpD"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/font-size-picker/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE7D;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,WAAW,CAAE,mBAAmB,CAAE,OAAO,CAAE,CAAE,WAKpD;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAE,QAAQ,EAAE,QAAQ,GAAI,MAAM,GAAG,SAAS,CAY7E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/components",
3
- "version": "30.6.1-next.ff1cebbba.0",
3
+ "version": "30.6.2",
4
4
  "description": "UI components for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -54,24 +54,24 @@
54
54
  "@types/gradient-parser": "1.1.0",
55
55
  "@types/highlight-words-core": "1.2.1",
56
56
  "@use-gesture/react": "^10.3.1",
57
- "@wordpress/a11y": "^4.32.1-next.ff1cebbba.0",
58
- "@wordpress/base-styles": "^6.8.1-next.ff1cebbba.0",
59
- "@wordpress/compose": "^7.32.1-next.ff1cebbba.0",
60
- "@wordpress/date": "^5.32.1-next.ff1cebbba.0",
61
- "@wordpress/deprecated": "^4.32.1-next.ff1cebbba.0",
62
- "@wordpress/dom": "^4.32.1-next.ff1cebbba.0",
63
- "@wordpress/element": "^6.32.1-next.ff1cebbba.0",
64
- "@wordpress/escape-html": "^3.32.1-next.ff1cebbba.0",
65
- "@wordpress/hooks": "^4.32.1-next.ff1cebbba.0",
66
- "@wordpress/html-entities": "^4.32.1-next.ff1cebbba.0",
67
- "@wordpress/i18n": "^6.5.1-next.ff1cebbba.0",
68
- "@wordpress/icons": "^11.0.1-next.ff1cebbba.0",
69
- "@wordpress/is-shallow-equal": "^5.32.1-next.ff1cebbba.0",
70
- "@wordpress/keycodes": "^4.32.1-next.ff1cebbba.0",
71
- "@wordpress/primitives": "^4.32.1-next.ff1cebbba.0",
72
- "@wordpress/private-apis": "^1.32.1-next.ff1cebbba.0",
73
- "@wordpress/rich-text": "^7.32.1-next.ff1cebbba.0",
74
- "@wordpress/warning": "^3.32.1-next.ff1cebbba.0",
57
+ "@wordpress/a11y": "^4.33.1",
58
+ "@wordpress/base-styles": "^6.9.1",
59
+ "@wordpress/compose": "^7.33.1",
60
+ "@wordpress/date": "^5.33.1",
61
+ "@wordpress/deprecated": "^4.33.1",
62
+ "@wordpress/dom": "^4.33.1",
63
+ "@wordpress/element": "^6.33.1",
64
+ "@wordpress/escape-html": "^3.33.1",
65
+ "@wordpress/hooks": "^4.33.1",
66
+ "@wordpress/html-entities": "^4.33.1",
67
+ "@wordpress/i18n": "^6.6.1",
68
+ "@wordpress/icons": "^11.0.1",
69
+ "@wordpress/is-shallow-equal": "^5.33.1",
70
+ "@wordpress/keycodes": "^4.33.1",
71
+ "@wordpress/primitives": "^4.33.1",
72
+ "@wordpress/private-apis": "^1.33.1",
73
+ "@wordpress/rich-text": "^7.33.1",
74
+ "@wordpress/warning": "^3.33.1",
75
75
  "change-case": "^4.1.2",
76
76
  "clsx": "^2.1.1",
77
77
  "colord": "^2.7.0",
@@ -97,5 +97,5 @@
97
97
  "publishConfig": {
98
98
  "access": "public"
99
99
  },
100
- "gitHead": "c5b659710aff01d40d2eb97b211eb2cec9c07d3b"
100
+ "gitHead": "2e2a11a11f0c5c9cb2bba2dd40b8046d2a10dc9d"
101
101
  }
@@ -18,6 +18,7 @@ $badge-colors: (
18
18
  min-height: $grid-unit-30;
19
19
  border-radius: $radius-small;
20
20
  line-height: 0;
21
+ max-width: 100%;
21
22
 
22
23
  // Prevents anchor text-decoration styles from being applied through a parent.
23
24
  display: inline-block;
@@ -85,9 +85,9 @@
85
85
  &[aria-disabled="true"]:enabled, // This catches a situation where a Button is aria-disabled, but not disabled.
86
86
  &[aria-disabled="true"]:active:enabled {
87
87
  // TODO: Prepare for theming (https://github.com/WordPress/gutenberg/pull/45466/files#r1030872724)
88
- color: $components-color-foreground-inverted;
89
- background: $components-color-gray-300;
90
- border-color: $components-color-gray-300;
88
+ color: rgba($white, 0.4);
89
+ background: $components-color-accent;
90
+ border-color: $components-color-accent;
91
91
  outline: none;
92
92
 
93
93
  &:focus:enabled {
@@ -12,7 +12,7 @@ import { __, _n, sprintf } from '@wordpress/i18n';
12
12
  /**
13
13
  * Internal dependencies
14
14
  */
15
- import { VisuallyHidden } from '..';
15
+ import { VisuallyHidden } from '../visually-hidden';
16
16
  import * as Styled from './styles';
17
17
  import type {
18
18
  CustomSelectContext as CustomSelectContextType,
@@ -103,6 +103,16 @@ The current font size value.
103
103
 
104
104
  - Required: No
105
105
 
106
+ ### `valueMode`: `'literal' | 'slug'`
107
+
108
+ Determines how the `value` prop should be interpreted.
109
+
110
+ - `'literal'`: The `value` prop contains the actual font size value (number or string).
111
+ - `'slug'`: The `value` prop contains the slug of the selected font size.
112
+
113
+ - Required: No
114
+ - Default: `'literal'`
115
+
106
116
  ### `withReset`: `boolean`
107
117
 
108
118
  If `true`, a reset button will be displayed alongside the input field when a custom font size is active. Has no effect when `disableCustomFontSizes` is `true`.
@@ -2,16 +2,17 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __, sprintf } from '@wordpress/i18n';
5
+ import { useMemo } from '@wordpress/element';
5
6
 
6
7
  /**
7
8
  * Internal dependencies
8
9
  */
9
- import CustomSelectControl from '../custom-select-control';
10
10
  import type {
11
11
  FontSizePickerSelectProps,
12
12
  FontSizePickerSelectOption,
13
13
  } from './types';
14
- import { isSimpleCssValue } from './utils';
14
+ import { generateFontSizeHint } from './utils';
15
+ import { StyledCustomSelectControl } from './styles';
15
16
 
16
17
  const DEFAULT_OPTION: FontSizePickerSelectOption = {
17
18
  key: 'default',
@@ -20,15 +21,19 @@ const DEFAULT_OPTION: FontSizePickerSelectOption = {
20
21
  };
21
22
 
22
23
  const FontSizePickerSelect = ( props: FontSizePickerSelectProps ) => {
23
- const { __next40pxDefaultSize, fontSizes, value, size, onChange } = props;
24
+ const {
25
+ __next40pxDefaultSize,
26
+ fontSizes,
27
+ value,
28
+ size,
29
+ valueMode = 'literal',
30
+ onChange,
31
+ } = props;
24
32
 
25
33
  const options: FontSizePickerSelectOption[] = [
26
34
  DEFAULT_OPTION,
27
35
  ...fontSizes.map( ( fontSize ) => {
28
- let hint;
29
- if ( isSimpleCssValue( fontSize.size ) ) {
30
- hint = String( fontSize.size );
31
- }
36
+ const hint = generateFontSizeHint( fontSize );
32
37
  return {
33
38
  key: fontSize.slug,
34
39
  name: fontSize.name || fontSize.slug,
@@ -38,11 +43,30 @@ const FontSizePickerSelect = ( props: FontSizePickerSelectProps ) => {
38
43
  } ),
39
44
  ];
40
45
 
41
- const selectedOption =
42
- options.find( ( option ) => option.value === value ) ?? DEFAULT_OPTION;
46
+ const selectedOption = useMemo( () => {
47
+ if ( value === undefined ) {
48
+ return DEFAULT_OPTION;
49
+ }
50
+
51
+ // If valueMode is 'slug', find by slug
52
+ if ( valueMode === 'slug' ) {
53
+ const optionBySlug = options.find(
54
+ ( option ) => option.key === value
55
+ );
56
+ if ( optionBySlug ) {
57
+ return optionBySlug;
58
+ }
59
+ }
60
+
61
+ // If valueMode is 'literal', find by value (size)
62
+ return (
63
+ options.find( ( option ) => option.value === value ) ??
64
+ DEFAULT_OPTION
65
+ );
66
+ }, [ value, valueMode, options ] );
43
67
 
44
68
  return (
45
- <CustomSelectControl
69
+ <StyledCustomSelectControl
46
70
  __next40pxDefaultSize={ __next40pxDefaultSize }
47
71
  __shouldNotWarnDeprecated36pxSize
48
72
  className="components-font-size-picker__select"
@@ -61,7 +85,16 @@ const FontSizePickerSelect = ( props: FontSizePickerSelectProps ) => {
61
85
  }: {
62
86
  selectedItem: FontSizePickerSelectOption;
63
87
  } ) => {
64
- onChange( selectedItem.value );
88
+ // Find the corresponding FontSize object
89
+ const matchingFontSize =
90
+ selectedItem.key === 'default'
91
+ ? undefined
92
+ : fontSizes.find(
93
+ ( fontSize ) =>
94
+ fontSize.slug === selectedItem.key
95
+ );
96
+
97
+ onChange( selectedItem.value, matchingFontSize );
65
98
  } }
66
99
  size={ size }
67
100
  />
@@ -14,7 +14,46 @@ import { T_SHIRT_ABBREVIATIONS, T_SHIRT_NAMES } from './constants';
14
14
  import type { FontSizePickerToggleGroupProps } from './types';
15
15
 
16
16
  const FontSizePickerToggleGroup = ( props: FontSizePickerToggleGroupProps ) => {
17
- const { fontSizes, value, __next40pxDefaultSize, size, onChange } = props;
17
+ const {
18
+ fontSizes,
19
+ value,
20
+ valueMode = 'literal',
21
+ __next40pxDefaultSize,
22
+ size,
23
+ onChange,
24
+ } = props;
25
+
26
+ // Find the current value based on valueMode
27
+ const currentValue = ( () => {
28
+ if ( ! value ) {
29
+ return undefined;
30
+ }
31
+
32
+ // If valueMode is 'slug', the value is already the slug
33
+ if ( valueMode === 'slug' ) {
34
+ return String( value );
35
+ }
36
+
37
+ // If valueMode is 'literal', find the font size by size value
38
+ // If multiple font sizes have the same size value, we can't distinguish them
39
+ // without additional information, so we return undefined to avoid incorrect selection
40
+ const matchingFontSizes = fontSizes.filter(
41
+ ( fontSize ) => fontSize.size === value
42
+ );
43
+
44
+ // If there are multiple matches, return undefined to avoid selecting the wrong font size
45
+ if ( matchingFontSizes.length > 1 ) {
46
+ return undefined;
47
+ }
48
+
49
+ // Find the font size by size value
50
+ const fontSizeBySize = fontSizes.find(
51
+ ( fontSize ) => fontSize.size === value
52
+ );
53
+
54
+ return fontSizeBySize?.slug;
55
+ } )();
56
+
18
57
  return (
19
58
  <ToggleGroupControl
20
59
  __nextHasNoMarginBottom
@@ -22,15 +61,30 @@ const FontSizePickerToggleGroup = ( props: FontSizePickerToggleGroupProps ) => {
22
61
  __shouldNotWarnDeprecated36pxSize
23
62
  label={ __( 'Font size' ) }
24
63
  hideLabelFromVision
25
- value={ value }
26
- onChange={ onChange }
64
+ value={ currentValue }
65
+ onChange={ ( newSlug: string | number | undefined ) => {
66
+ if ( newSlug === undefined ) {
67
+ onChange( undefined );
68
+ } else {
69
+ // Find the font size by slug
70
+ const selectedFontSize = fontSizes.find(
71
+ ( fontSize ) => fontSize.slug === String( newSlug )
72
+ );
73
+ if ( selectedFontSize ) {
74
+ onChange(
75
+ selectedFontSize.size as number | string,
76
+ selectedFontSize
77
+ );
78
+ }
79
+ }
80
+ } }
27
81
  isBlock
28
82
  size={ size }
29
83
  >
30
84
  { fontSizes.map( ( fontSize, index ) => (
31
85
  <ToggleGroupControlOption
32
86
  key={ fontSize.slug }
33
- value={ fontSize.size }
87
+ value={ fontSize.slug }
34
88
  label={ T_SHIRT_ABBREVIATIONS[ index ] }
35
89
  aria-label={ fontSize.name || T_SHIRT_NAMES[ index ] }
36
90
  showTooltip
@@ -46,6 +46,7 @@ const UnforwardedFontSizePicker = (
46
46
  size = 'default',
47
47
  units: unitsProp = DEFAULT_UNITS,
48
48
  value,
49
+ valueMode = 'literal',
49
50
  withSlider = false,
50
51
  withReset = true,
51
52
  } = props;
@@ -59,15 +60,32 @@ const UnforwardedFontSizePicker = (
59
60
  availableUnits: unitsProp,
60
61
  } );
61
62
 
62
- const selectedFontSize = fontSizes.find(
63
- ( fontSize ) => fontSize.size === value
64
- );
63
+ const selectedFontSize = ( () => {
64
+ if ( ! value ) {
65
+ return undefined;
66
+ }
67
+
68
+ // If valueMode is 'slug', find by slug
69
+ if ( valueMode === 'slug' ) {
70
+ return fontSizes.find( ( fontSize ) => fontSize.slug === value );
71
+ }
72
+
73
+ // If valueMode is 'literal', find by size value
74
+ return fontSizes.find( ( fontSize ) => fontSize.size === value );
75
+ } )();
65
76
  const isCustomValue = !! value && ! selectedFontSize;
66
77
 
67
78
  // Initially request a custom picker if the value is not from the predef list.
68
79
  const [ userRequestedCustom, setUserRequestedCustom ] =
69
80
  useState( isCustomValue );
70
81
 
82
+ // Resolve the literal value to use in custom controls when operating in slug mode.
83
+ // When `valueMode` is 'slug', the `value` prop contains the slug of the
84
+ // selected preset. In that case, the custom input should reflect the preset's
85
+ // actual size value so it pre-populates correctly after clicking "Set custom size".
86
+ const resolvedValueForControls =
87
+ valueMode === 'slug' ? selectedFontSize?.size : value;
88
+
71
89
  let currentPickerType;
72
90
  if ( ! disableCustomFontSizes && userRequestedCustom ) {
73
91
  // While showing the custom value picker, switch back to predef only if
@@ -88,10 +106,11 @@ const UnforwardedFontSizePicker = (
88
106
  // operates in a legacy "unitless" mode where UnitControl can only be used
89
107
  // to select px values and onChange() is always called with number values.
90
108
  const hasUnits =
91
- typeof value === 'string' || typeof fontSizes[ 0 ]?.size === 'string';
109
+ typeof resolvedValueForControls === 'string' ||
110
+ typeof fontSizes[ 0 ]?.size === 'string';
92
111
 
93
112
  const [ valueQuantity, valueUnit ] = parseQuantityAndUnitFromRawValue(
94
- value,
113
+ resolvedValueForControls,
95
114
  units
96
115
  );
97
116
  const isValueUnitRelative =
@@ -139,18 +158,16 @@ const UnforwardedFontSizePicker = (
139
158
  __next40pxDefaultSize={ __next40pxDefaultSize }
140
159
  fontSizes={ fontSizes }
141
160
  value={ value }
161
+ valueMode={ valueMode }
142
162
  disableCustomFontSizes={ disableCustomFontSizes }
143
163
  size={ size }
144
- onChange={ ( newValue ) => {
164
+ onChange={ ( newValue, selectedItem ) => {
145
165
  if ( newValue === undefined ) {
146
- onChange?.( undefined );
166
+ onChange?.( undefined, selectedItem );
147
167
  } else {
148
168
  onChange?.(
149
169
  hasUnits ? newValue : Number( newValue ),
150
- fontSizes.find(
151
- ( fontSize ) =>
152
- fontSize.size === newValue
153
- )
170
+ selectedItem
154
171
  );
155
172
  }
156
173
  } }
@@ -161,18 +178,16 @@ const UnforwardedFontSizePicker = (
161
178
  <FontSizePickerToggleGroup
162
179
  fontSizes={ fontSizes }
163
180
  value={ value }
181
+ valueMode={ valueMode }
164
182
  __next40pxDefaultSize={ __next40pxDefaultSize }
165
183
  size={ size }
166
- onChange={ ( newValue ) => {
184
+ onChange={ ( newValue, selectedItem ) => {
167
185
  if ( newValue === undefined ) {
168
- onChange?.( undefined );
186
+ onChange?.( undefined, selectedItem );
169
187
  } else {
170
188
  onChange?.(
171
189
  hasUnits ? newValue : Number( newValue ),
172
- fontSizes.find(
173
- ( fontSize ) =>
174
- fontSize.size === newValue
175
- )
190
+ selectedItem
176
191
  );
177
192
  }
178
193
  } }
@@ -187,11 +202,21 @@ const UnforwardedFontSizePicker = (
187
202
  label={ __( 'Font size' ) }
188
203
  labelPosition="top"
189
204
  hideLabelFromVision
190
- value={ value }
205
+ value={
206
+ hasUnits
207
+ ? `${ valueQuantity ?? '' }${
208
+ valueUnit ?? ''
209
+ }`
210
+ : resolvedValueForControls
211
+ }
191
212
  onChange={ ( newValue ) => {
192
213
  setUserRequestedCustom( true );
193
214
 
194
- if ( newValue === undefined ) {
215
+ // Treat clearing the input (empty string) as a reset
216
+ if (
217
+ newValue === undefined ||
218
+ newValue === ''
219
+ ) {
195
220
  onChange?.( undefined );
196
221
  } else {
197
222
  onChange?.(
@@ -8,6 +8,7 @@ import styled from '@emotion/styled';
8
8
  */
9
9
  import BaseControl from '../base-control';
10
10
  import Button from '../button';
11
+ import CustomSelectControl from '../custom-select-control';
11
12
  import { HStack } from '../h-stack';
12
13
  import { space } from '../utils/space';
13
14
 
@@ -32,3 +33,11 @@ export const HeaderLabel = styled( BaseControl.VisualLabel )`
32
33
  justify-content: flex-start;
33
34
  margin-bottom: 0;
34
35
  `;
36
+
37
+ // Custom styled component to force line break between name and hint while keeping checkmark on the right
38
+ export const StyledCustomSelectControl = styled( CustomSelectControl )`
39
+ .components-custom-select-control__item
40
+ .components-custom-select-control__item-hint {
41
+ width: 100%;
42
+ }
43
+ `;