@wordpress/components 30.2.1-next.0f6f9d12c.0 → 30.2.2-next.e256d081a.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 (158) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/build/context/context-connect.js.map +1 -1
  3. package/build/menu-item/index.js +1 -0
  4. package/build/menu-item/index.js.map +1 -1
  5. package/build/tabs/styles.js +5 -5
  6. package/build/tabs/styles.js.map +1 -1
  7. package/build/utils/font-size.js.map +1 -1
  8. package/build/utils/get-valid-children.js.map +1 -1
  9. package/build/validated-form-controls/components/checkbox-control.js +5 -3
  10. package/build/validated-form-controls/components/checkbox-control.js.map +1 -1
  11. package/build/validated-form-controls/components/combobox-control.js +5 -3
  12. package/build/validated-form-controls/components/combobox-control.js.map +1 -1
  13. package/build/validated-form-controls/components/custom-select-control.js +5 -3
  14. package/build/validated-form-controls/components/custom-select-control.js.map +1 -1
  15. package/build/validated-form-controls/components/input-control.js +5 -3
  16. package/build/validated-form-controls/components/input-control.js.map +1 -1
  17. package/build/validated-form-controls/components/number-control.js +5 -3
  18. package/build/validated-form-controls/components/number-control.js.map +1 -1
  19. package/build/validated-form-controls/components/radio-control.js +5 -3
  20. package/build/validated-form-controls/components/radio-control.js.map +1 -1
  21. package/build/validated-form-controls/components/range-control.js +5 -3
  22. package/build/validated-form-controls/components/range-control.js.map +1 -1
  23. package/build/validated-form-controls/components/select-control.js +5 -3
  24. package/build/validated-form-controls/components/select-control.js.map +1 -1
  25. package/build/validated-form-controls/components/text-control.js +5 -3
  26. package/build/validated-form-controls/components/text-control.js.map +1 -1
  27. package/build/validated-form-controls/components/textarea-control.js +5 -3
  28. package/build/validated-form-controls/components/textarea-control.js.map +1 -1
  29. package/build/validated-form-controls/components/toggle-control.js +5 -3
  30. package/build/validated-form-controls/components/toggle-control.js.map +1 -1
  31. package/build/validated-form-controls/components/toggle-group-control.js +5 -3
  32. package/build/validated-form-controls/components/toggle-group-control.js.map +1 -1
  33. package/build/validated-form-controls/components/types.js.map +1 -1
  34. package/build/validated-form-controls/control-with-error.js +70 -35
  35. package/build/validated-form-controls/control-with-error.js.map +1 -1
  36. package/build/validated-form-controls/validity-indicator.js +45 -0
  37. package/build/validated-form-controls/validity-indicator.js.map +1 -0
  38. package/build-module/context/context-connect.js.map +1 -1
  39. package/build-module/menu-item/index.js +1 -0
  40. package/build-module/menu-item/index.js.map +1 -1
  41. package/build-module/tabs/styles.js +6 -6
  42. package/build-module/tabs/styles.js.map +1 -1
  43. package/build-module/utils/font-size.js.map +1 -1
  44. package/build-module/utils/get-valid-children.js.map +1 -1
  45. package/build-module/validated-form-controls/components/checkbox-control.js +5 -3
  46. package/build-module/validated-form-controls/components/checkbox-control.js.map +1 -1
  47. package/build-module/validated-form-controls/components/combobox-control.js +5 -3
  48. package/build-module/validated-form-controls/components/combobox-control.js.map +1 -1
  49. package/build-module/validated-form-controls/components/custom-select-control.js +5 -3
  50. package/build-module/validated-form-controls/components/custom-select-control.js.map +1 -1
  51. package/build-module/validated-form-controls/components/input-control.js +5 -3
  52. package/build-module/validated-form-controls/components/input-control.js.map +1 -1
  53. package/build-module/validated-form-controls/components/number-control.js +5 -3
  54. package/build-module/validated-form-controls/components/number-control.js.map +1 -1
  55. package/build-module/validated-form-controls/components/radio-control.js +5 -3
  56. package/build-module/validated-form-controls/components/radio-control.js.map +1 -1
  57. package/build-module/validated-form-controls/components/range-control.js +5 -3
  58. package/build-module/validated-form-controls/components/range-control.js.map +1 -1
  59. package/build-module/validated-form-controls/components/select-control.js +5 -3
  60. package/build-module/validated-form-controls/components/select-control.js.map +1 -1
  61. package/build-module/validated-form-controls/components/text-control.js +5 -3
  62. package/build-module/validated-form-controls/components/text-control.js.map +1 -1
  63. package/build-module/validated-form-controls/components/textarea-control.js +5 -3
  64. package/build-module/validated-form-controls/components/textarea-control.js.map +1 -1
  65. package/build-module/validated-form-controls/components/toggle-control.js +5 -3
  66. package/build-module/validated-form-controls/components/toggle-control.js.map +1 -1
  67. package/build-module/validated-form-controls/components/toggle-group-control.js +5 -3
  68. package/build-module/validated-form-controls/components/toggle-group-control.js.map +1 -1
  69. package/build-module/validated-form-controls/components/types.js.map +1 -1
  70. package/build-module/validated-form-controls/control-with-error.js +70 -34
  71. package/build-module/validated-form-controls/control-with-error.js.map +1 -1
  72. package/build-module/validated-form-controls/validity-indicator.js +37 -0
  73. package/build-module/validated-form-controls/validity-indicator.js.map +1 -0
  74. package/build-style/style-rtl.css +34 -22
  75. package/build-style/style.css +34 -22
  76. package/build-types/context/context-connect.d.ts +2 -2
  77. package/build-types/context/context-connect.d.ts.map +1 -1
  78. package/build-types/menu-item/index.d.ts.map +1 -1
  79. package/build-types/tabs/styles.d.ts.map +1 -1
  80. package/build-types/utils/font-size.d.ts +2 -2
  81. package/build-types/utils/font-size.d.ts.map +1 -1
  82. package/build-types/utils/get-valid-children.d.ts +2 -2
  83. package/build-types/utils/get-valid-children.d.ts.map +1 -1
  84. package/build-types/validated-form-controls/components/checkbox-control.d.ts.map +1 -1
  85. package/build-types/validated-form-controls/components/combobox-control.d.ts.map +1 -1
  86. package/build-types/validated-form-controls/components/custom-select-control.d.ts.map +1 -1
  87. package/build-types/validated-form-controls/components/input-control.d.ts.map +1 -1
  88. package/build-types/validated-form-controls/components/number-control.d.ts.map +1 -1
  89. package/build-types/validated-form-controls/components/radio-control.d.ts.map +1 -1
  90. package/build-types/validated-form-controls/components/range-control.d.ts.map +1 -1
  91. package/build-types/validated-form-controls/components/select-control.d.ts.map +1 -1
  92. package/build-types/validated-form-controls/components/stories/checkbox-control.story.d.ts.map +1 -1
  93. package/build-types/validated-form-controls/components/stories/combobox-control.story.d.ts.map +1 -1
  94. package/build-types/validated-form-controls/components/stories/custom-select-control.story.d.ts.map +1 -1
  95. package/build-types/validated-form-controls/components/stories/input-control.story.d.ts.map +1 -1
  96. package/build-types/validated-form-controls/components/stories/number-control.story.d.ts.map +1 -1
  97. package/build-types/validated-form-controls/components/stories/overview.story.d.ts +13 -0
  98. package/build-types/validated-form-controls/components/stories/overview.story.d.ts.map +1 -1
  99. package/build-types/validated-form-controls/components/stories/radio-control.story.d.ts.map +1 -1
  100. package/build-types/validated-form-controls/components/stories/range-control.story.d.ts.map +1 -1
  101. package/build-types/validated-form-controls/components/stories/select-control.story.d.ts.map +1 -1
  102. package/build-types/validated-form-controls/components/stories/text-control.story.d.ts.map +1 -1
  103. package/build-types/validated-form-controls/components/stories/textarea-control.story.d.ts.map +1 -1
  104. package/build-types/validated-form-controls/components/stories/toggle-control.story.d.ts.map +1 -1
  105. package/build-types/validated-form-controls/components/stories/toggle-group-control.story.d.ts.map +1 -1
  106. package/build-types/validated-form-controls/components/text-control.d.ts.map +1 -1
  107. package/build-types/validated-form-controls/components/textarea-control.d.ts.map +1 -1
  108. package/build-types/validated-form-controls/components/toggle-control.d.ts.map +1 -1
  109. package/build-types/validated-form-controls/components/toggle-group-control.d.ts.map +1 -1
  110. package/build-types/validated-form-controls/components/types.d.ts +21 -10
  111. package/build-types/validated-form-controls/components/types.d.ts.map +1 -1
  112. package/build-types/validated-form-controls/control-with-error.d.ts +4 -5
  113. package/build-types/validated-form-controls/control-with-error.d.ts.map +1 -1
  114. package/build-types/validated-form-controls/test/control-with-error.d.ts +2 -0
  115. package/build-types/validated-form-controls/test/control-with-error.d.ts.map +1 -0
  116. package/build-types/validated-form-controls/validity-indicator.d.ts +5 -0
  117. package/build-types/validated-form-controls/validity-indicator.d.ts.map +1 -0
  118. package/package.json +19 -19
  119. package/src/calendar/style.scss +22 -22
  120. package/src/context/context-connect.ts +2 -2
  121. package/src/menu-item/index.tsx +1 -0
  122. package/src/tabs/styles.ts +2 -1
  123. package/src/tools-panel/stories/index.story.tsx +3 -3
  124. package/src/utils/font-size.ts +2 -2
  125. package/src/utils/get-valid-children.ts +4 -2
  126. package/src/utils/theme-variables.scss +1 -0
  127. package/src/validated-form-controls/components/checkbox-control.tsx +5 -3
  128. package/src/validated-form-controls/components/combobox-control.tsx +5 -3
  129. package/src/validated-form-controls/components/custom-select-control.tsx +5 -3
  130. package/src/validated-form-controls/components/input-control.tsx +5 -3
  131. package/src/validated-form-controls/components/number-control.tsx +5 -3
  132. package/src/validated-form-controls/components/radio-control.tsx +5 -3
  133. package/src/validated-form-controls/components/range-control.tsx +5 -3
  134. package/src/validated-form-controls/components/select-control.tsx +5 -3
  135. package/src/validated-form-controls/components/stories/checkbox-control.story.tsx +17 -6
  136. package/src/validated-form-controls/components/stories/combobox-control.story.tsx +17 -6
  137. package/src/validated-form-controls/components/stories/custom-select-control.story.tsx +17 -6
  138. package/src/validated-form-controls/components/stories/input-control.story.tsx +51 -18
  139. package/src/validated-form-controls/components/stories/number-control.story.tsx +17 -6
  140. package/src/validated-form-controls/components/stories/overview.mdx +1 -1
  141. package/src/validated-form-controls/components/stories/overview.story.tsx +207 -17
  142. package/src/validated-form-controls/components/stories/radio-control.story.tsx +17 -6
  143. package/src/validated-form-controls/components/stories/range-control.story.tsx +17 -6
  144. package/src/validated-form-controls/components/stories/select-control.story.tsx +17 -6
  145. package/src/validated-form-controls/components/stories/text-control.story.tsx +17 -6
  146. package/src/validated-form-controls/components/stories/textarea-control.story.tsx +17 -6
  147. package/src/validated-form-controls/components/stories/toggle-control.story.tsx +17 -6
  148. package/src/validated-form-controls/components/stories/toggle-group-control.story.tsx +17 -6
  149. package/src/validated-form-controls/components/text-control.tsx +5 -3
  150. package/src/validated-form-controls/components/textarea-control.tsx +5 -3
  151. package/src/validated-form-controls/components/toggle-control.tsx +5 -3
  152. package/src/validated-form-controls/components/toggle-group-control.tsx +5 -3
  153. package/src/validated-form-controls/components/types.ts +21 -12
  154. package/src/validated-form-controls/control-with-error.tsx +93 -41
  155. package/src/validated-form-controls/style.scss +19 -5
  156. package/src/validated-form-controls/test/control-with-error.tsx +224 -0
  157. package/src/validated-form-controls/validity-indicator.tsx +48 -0
  158. package/tsconfig.tsbuildinfo +1 -1
@@ -10,18 +10,29 @@ export type ValidatedControlProps<V> = {
10
10
  */
11
11
  markWhenOptional?: boolean;
12
12
  /**
13
- * A function that returns a custom validity message when applicable. This error message will be applied to the
14
- * underlying element using the native [`setCustomValidity()` method](https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/setCustomValidity).
15
- * This means the custom validator will be run _in addition_ to any other HTML attribute-based validation, and
16
- * will be prioritized over any existing validity messages dictated by the HTML attributes.
17
- * An empty string or `undefined` return value will clear any existing custom validity message.
13
+ * Optional callback to run when the input should be validated. Use this to set
14
+ * a `customValidity` as necessary.
18
15
  *
19
- * Make sure you don't programatically pass a value (such as an initial value) to the control component
20
- * that fails this validator, because the validator will only run for user-initiated changes.
16
+ * Always prefer using standard HTML attributes like `required` and `min`/`max` over
17
+ * custom validators when possible, as they are simpler and have localized error messages built in.
18
+ */
19
+ onValidate?: (currentValue: V) => void;
20
+ /**
21
+ * Show a custom message based on the validation status.
21
22
  *
22
- * Always prefer using standard HTML attributes like `required` and `min`/`max` over custom validators
23
- * when possible, as they are simpler and have localized error messages built in.
23
+ * - When `type` is `invalid`, the message will be applied to the underlying element using the
24
+ * native [`setCustomValidity()` method](https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/setCustomValidity).
25
+ * This means the custom message will be prioritized over any existing validity messages
26
+ * triggered by HTML attribute-based validation.
27
+ * - When `type` is `validating` or `valid`, the custom validity message of the underlying element
28
+ * will be cleared. If there are no remaining validity messages triggered by HTML attribute-based validation,
29
+ * the message will be presented as a status indicator rather than an error. These indicators are intended
30
+ * for asynchronous validation calls that may take more than 1 second to complete.
31
+ * Otherwise, custom errors can simply be cleared by setting the `customValidity` prop to `undefined`.
24
32
  */
25
- customValidator?: (currentValue: V) => string | void;
33
+ customValidity?: {
34
+ type: 'validating' | 'valid' | 'invalid';
35
+ message: string;
36
+ };
26
37
  };
27
38
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/validated-form-controls/components/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,CAAE,CAAC,IAAK;IACxC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;;;;;;;OAYG;IAGH,eAAe,CAAC,EAAE,CAAE,YAAY,EAAE,CAAC,KAAM,MAAM,GAAG,IAAI,CAAC;CACvD,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/validated-form-controls/components/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,CAAE,CAAC,IAAK;IACxC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,CAAE,YAAY,EAAE,CAAC,KAAM,IAAI,CAAC;IACzC;;;;;;;;;;;;OAYG;IACH,cAAc,CAAC,EAAE;QAChB,IAAI,EAAE,YAAY,GAAG,OAAO,GAAG,SAAS,CAAC;QACzC,OAAO,EAAE,MAAM,CAAC;KAChB,CAAC;CACF,CAAC"}
@@ -1,3 +1,4 @@
1
+ import type { ValidatedControlProps } from './components/types';
1
2
  /**
2
3
  * HTML elements that support the Constraint Validation API.
3
4
  *
@@ -17,12 +18,10 @@ export declare const ControlWithError: import("react").ForwardRefExoticComponent
17
18
  */
18
19
  markWhenOptional?: boolean;
19
20
  /**
20
- * A function that returns a custom validity message when applicable.
21
- *
22
- * This message will be applied to the element returned by `getValidityTarget`.
23
- * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/setCustomValidity
21
+ * The callback to run when the input should be validated.
24
22
  */
25
- customValidator?: () => string | void;
23
+ onValidate?: () => void;
24
+ customValidity?: ValidatedControlProps<unknown>["customValidity"];
26
25
  /**
27
26
  * A function that returns the actual element on which the validity data should be applied.
28
27
  */
@@ -1 +1 @@
1
- {"version":3,"file":"control-with-error.d.ts","sourceRoot":"","sources":["../../src/validated-form-controls/control-with-error.tsx"],"names":[],"mappings":"AA6CA;;;;;;;GAOG;AACH,KAAK,cAAc,GAChB,mBAAmB,GACnB,gBAAgB,GAChB,iBAAiB,GACjB,mBAAmB,CAAC;AA4IvB,eAAO,MAAM,gBAAgB;IAlI3B;;OAEG;eACQ,OAAO;IAClB;;OAEG;uBACgB,OAAO;IAC1B;;;;;OAKG;sBACe,MAAM,MAAM,GAAG,IAAI;IACrC;;OAEG;uBACgB,MAAM,cAAc,GAAG,IAAI,GAAG,SAAS;IAC1D;;OAEG;;kDA6GoE,CAAC"}
1
+ {"version":3,"file":"control-with-error.d.ts","sourceRoot":"","sources":["../../src/validated-form-controls/control-with-error.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAyBhE;;;;;;;GAOG;AACH,KAAK,cAAc,GAChB,mBAAmB,GACnB,gBAAgB,GAChB,iBAAiB,GACjB,mBAAmB,CAAC;AAoMvB,eAAO,MAAM,gBAAgB;IAzL3B;;OAEG;eACQ,OAAO;IAClB;;OAEG;uBACgB,OAAO;IAC1B;;OAEG;iBACU,MAAM,IAAI;qBACN,qBAAqB,CAAE,OAAO,CAAE,CAAE,gBAAgB,CAAE;IACrE;;OAEG;uBACgB,MAAM,cAAc,GAAG,IAAI,GAAG,SAAS;IAC1D;;OAEG;;kDAsKoE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=control-with-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control-with-error.d.ts","sourceRoot":"","sources":["../../../src/validated-form-controls/test/control-with-error.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export declare function ValidityIndicator({ type, message, }: {
2
+ type: 'validating' | 'valid' | 'invalid';
3
+ message?: string;
4
+ }): import("react").JSX.Element;
5
+ //# sourceMappingURL=validity-indicator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validity-indicator.d.ts","sourceRoot":"","sources":["../../src/validated-form-controls/validity-indicator.tsx"],"names":[],"mappings":"AAgBA,wBAAgB,iBAAiB,CAAE,EAClC,IAAI,EACJ,OAAO,GACP,EAAE;IACF,IAAI,EAAE,YAAY,GAAG,OAAO,GAAG,SAAS,CAAC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB,+BAyBA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/components",
3
- "version": "30.2.1-next.0f6f9d12c.0",
3
+ "version": "30.2.2-next.e256d081a.0",
4
4
  "description": "UI components for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -44,23 +44,23 @@
44
44
  "@types/gradient-parser": "1.1.0",
45
45
  "@types/highlight-words-core": "1.2.1",
46
46
  "@use-gesture/react": "^10.3.1",
47
- "@wordpress/a11y": "^4.28.1-next.0f6f9d12c.0",
48
- "@wordpress/compose": "^7.28.1-next.0f6f9d12c.0",
49
- "@wordpress/date": "^5.28.1-next.0f6f9d12c.0",
50
- "@wordpress/deprecated": "^4.28.1-next.0f6f9d12c.0",
51
- "@wordpress/dom": "^4.28.1-next.0f6f9d12c.0",
52
- "@wordpress/element": "^6.28.1-next.0f6f9d12c.0",
53
- "@wordpress/escape-html": "^3.28.1-next.0f6f9d12c.0",
54
- "@wordpress/hooks": "^4.28.1-next.0f6f9d12c.0",
55
- "@wordpress/html-entities": "^4.28.1-next.0f6f9d12c.0",
56
- "@wordpress/i18n": "^6.1.1-next.0f6f9d12c.0",
57
- "@wordpress/icons": "^10.28.2-next.0f6f9d12c.0",
58
- "@wordpress/is-shallow-equal": "^5.28.1-next.0f6f9d12c.0",
59
- "@wordpress/keycodes": "^4.28.1-next.0f6f9d12c.0",
60
- "@wordpress/primitives": "^4.28.1-next.0f6f9d12c.0",
61
- "@wordpress/private-apis": "^1.28.1-next.0f6f9d12c.0",
62
- "@wordpress/rich-text": "^7.28.1-next.0f6f9d12c.0",
63
- "@wordpress/warning": "^3.28.1-next.0f6f9d12c.0",
47
+ "@wordpress/a11y": "^4.29.1-next.e256d081a.0",
48
+ "@wordpress/compose": "^7.29.1-next.e256d081a.0",
49
+ "@wordpress/date": "^5.30.1-next.e256d081a.0",
50
+ "@wordpress/deprecated": "^4.29.1-next.e256d081a.0",
51
+ "@wordpress/dom": "^4.29.1-next.e256d081a.0",
52
+ "@wordpress/element": "^6.29.1-next.e256d081a.0",
53
+ "@wordpress/escape-html": "^3.29.1-next.e256d081a.0",
54
+ "@wordpress/hooks": "^4.29.1-next.e256d081a.0",
55
+ "@wordpress/html-entities": "^4.29.1-next.e256d081a.0",
56
+ "@wordpress/i18n": "^6.2.1-next.e256d081a.0",
57
+ "@wordpress/icons": "^10.29.1-next.e256d081a.0",
58
+ "@wordpress/is-shallow-equal": "^5.29.1-next.e256d081a.0",
59
+ "@wordpress/keycodes": "^4.29.1-next.e256d081a.0",
60
+ "@wordpress/primitives": "^4.29.1-next.e256d081a.0",
61
+ "@wordpress/private-apis": "^1.29.1-next.e256d081a.0",
62
+ "@wordpress/rich-text": "^7.29.1-next.e256d081a.0",
63
+ "@wordpress/warning": "^3.29.1-next.e256d081a.0",
64
64
  "change-case": "^4.1.2",
65
65
  "clsx": "^2.1.1",
66
66
  "colord": "^2.7.0",
@@ -86,5 +86,5 @@
86
86
  "publishConfig": {
87
87
  "access": "public"
88
88
  },
89
- "gitHead": "7d4f4367e2f76deddf4a09b540e6b2f9f4c3fe9f"
89
+ "gitHead": "7d529ba9a461795d5f1572d3856de33f744287c2"
90
90
  }
@@ -1,9 +1,9 @@
1
1
  /* Root of the component. */
2
2
  // Internal variables
3
3
  $wp-components-calendar-outline-focus: var(--wp-admin-border-width-focus) solid $components-color-accent;
4
- $wp-components-calendar-button-height: 2rem;
5
- $wp-components-calendar-button-width: 2rem;
6
- $wp-components-calendar-nav-height: 2rem;
4
+ $wp-components-calendar-button-height: $grid-unit-40;
5
+ $wp-components-calendar-button-width: $grid-unit-40;
6
+ $wp-components-calendar-nav-height: $grid-unit-40;
7
7
  $wp-components-calendar-range-middle-background-color: color-mix(in srgb, $components-color-accent 4%, transparent);
8
8
  $wp-components-calendar-preview-border-color: color-mix(in srgb, $components-color-accent 16%, transparent);
9
9
 
@@ -13,10 +13,10 @@ $wp-components-calendar-preview-border-color: color-mix(in srgb, $components-col
13
13
  position: relative; /* Required to position the navigation toolbar. */
14
14
  box-sizing: border-box;
15
15
  display: inline flow-root;
16
- color: $gray-900;
17
- background-color: $white;
18
- font-size: 13px;
19
- font-weight: 400;
16
+ color: $components-color-foreground;
17
+ background-color: $components-color-background;
18
+ font-size: $font-size-medium;
19
+ font-weight: $font-weight-regular;
20
20
  z-index: 0; // Create a stacking context and render on top of the background.
21
21
 
22
22
  *,
@@ -35,7 +35,7 @@ $wp-components-calendar-preview-border-color: color-mix(in srgb, $components-col
35
35
  // date follows the same color as the button's text, since the button
36
36
  // inherits its text color.
37
37
  &:has(.components-calendar__day-button:disabled) {
38
- color: $gray-600;
38
+ color: $components-color-disabled;
39
39
  }
40
40
  &:has(.components-calendar__day-button:hover:not(:disabled)),
41
41
  &:has(.components-calendar__day-button:focus-visible) {
@@ -57,7 +57,7 @@ $wp-components-calendar-preview-border-color: color-mix(in srgb, $components-col
57
57
  height: $wp-components-calendar-button-height;
58
58
 
59
59
  border: none;
60
- border-radius: 2px;
60
+ border-radius: $radius-small;
61
61
 
62
62
  font: inherit;
63
63
  font-variant-numeric: tabular-nums;
@@ -73,7 +73,7 @@ $wp-components-calendar-preview-border-color: color-mix(in srgb, $components-col
73
73
  z-index: -1;
74
74
  inset: 0;
75
75
  border: none; // No default border to avoid polluting high-contrast mode.
76
- border-radius: 2px;
76
+ border-radius: $radius-small;
77
77
  }
78
78
 
79
79
  // Use the button's ::after to show the selection preview.
@@ -117,7 +117,7 @@ $wp-components-calendar-preview-border-color: color-mix(in srgb, $components-col
117
117
  .components-calendar__button-next,
118
118
  .components-calendar__button-previous {
119
119
  border: none;
120
- border-radius: 2px;
120
+ border-radius: $radius-small;
121
121
  background: none;
122
122
  padding: 0;
123
123
  margin: 0;
@@ -139,7 +139,7 @@ $wp-components-calendar-preview-border-color: color-mix(in srgb, $components-col
139
139
  &[aria-disabled="true"] {
140
140
  cursor: revert;
141
141
 
142
- color: $gray-600;
142
+ color: $components-color-disabled;
143
143
  }
144
144
 
145
145
  &:focus-visible {
@@ -150,8 +150,8 @@ $wp-components-calendar-preview-border-color: color-mix(in srgb, $components-col
150
150
  .components-calendar__chevron {
151
151
  display: inline-block;
152
152
  fill: currentColor;
153
- width: 16px;
154
- height: 16px;
153
+ width: $grid-unit-20;
154
+ height: $grid-unit-20;
155
155
  }
156
156
 
157
157
  .components-calendar[dir="rtl"]
@@ -167,7 +167,7 @@ $wp-components-calendar-preview-border-color: color-mix(in srgb, $components-col
167
167
  align-content: center;
168
168
 
169
169
  height: $wp-components-calendar-nav-height;
170
- margin-bottom: 12px;
170
+ margin-bottom: $grid-unit-15;
171
171
  }
172
172
 
173
173
  .components-calendar__months {
@@ -175,13 +175,13 @@ $wp-components-calendar-preview-border-color: color-mix(in srgb, $components-col
175
175
  display: flex;
176
176
  justify-content: center;
177
177
  flex-wrap: wrap;
178
- gap: 1rem;
178
+ gap: $grid-unit-20;
179
179
  max-width: fit-content;
180
180
  }
181
181
 
182
182
  .components-calendar__month-grid {
183
183
  border-collapse: separate;
184
- border-spacing: 0 4px;
184
+ border-spacing: 0 $grid-unit-05;
185
185
  }
186
186
 
187
187
  .components-calendar__nav {
@@ -202,7 +202,7 @@ $wp-components-calendar-preview-border-color: color-mix(in srgb, $components-col
202
202
  height: $wp-components-calendar-button-height;
203
203
  padding: 0;
204
204
 
205
- color: $gray-700;
205
+ color: $components-color-gray-700;
206
206
  text-align: center;
207
207
  text-transform: uppercase;
208
208
  }
@@ -227,12 +227,12 @@ $wp-components-calendar-preview-border-color: color-mix(in srgb, $components-col
227
227
  .components-calendar__day-button,
228
228
  .components-calendar__day-button:hover:not(:disabled)
229
229
  ) {
230
- color: $white;
230
+ color: $components-color-foreground-inverted;
231
231
  }
232
232
 
233
233
  .components-calendar__day-button {
234
234
  &::before {
235
- background-color: $gray-900;
235
+ background-color: $components-color-foreground;
236
236
  // Render a transparent border to highlight the selected day in
237
237
  // forced-colors (high-contrast) mode, since the background is not
238
238
  // visible.
@@ -240,11 +240,11 @@ $wp-components-calendar-preview-border-color: color-mix(in srgb, $components-col
240
240
  }
241
241
 
242
242
  &:disabled::before {
243
- background-color: $gray-600;
243
+ background-color: $components-color-disabled;
244
244
  }
245
245
 
246
246
  &:hover:not(:disabled)::before {
247
- background-color: $gray-800;
247
+ background-color: $components-color-gray-800;
248
248
  }
249
249
  }
250
250
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import type { ForwardedRef, ReactChild, ReactNode } from 'react';
4
+ import type { ForwardedRef, ReactElement, ReactNode } from 'react';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
@@ -114,7 +114,7 @@ function _contextConnect<
114
114
  * @return The connected namespaces.
115
115
  */
116
116
  export function getConnectNamespace(
117
- Component: ReactChild | undefined | {}
117
+ Component: ReactElement | number | string | undefined | {}
118
118
  ): string[] {
119
119
  if ( ! Component ) {
120
120
  return [];
@@ -67,6 +67,7 @@ function UnforwardedMenuItem(
67
67
  role={ role }
68
68
  icon={ iconPosition === 'left' ? icon : undefined }
69
69
  className={ className }
70
+ accessibleWhenDisabled
70
71
  { ...buttonProps }
71
72
  >
72
73
  <span className="components-menu-item__item">{ children }</span>
@@ -7,7 +7,7 @@ import * as Ariakit from '@ariakit/react';
7
7
  /**
8
8
  * Internal dependencies
9
9
  */
10
- import { COLORS, CONFIG } from '../utils';
10
+ import { COLORS, CONFIG, font } from '../utils';
11
11
  import { space } from '../utils/space';
12
12
  import Icon from '../icon';
13
13
 
@@ -163,6 +163,7 @@ export const Tab = styled( Ariakit.Tab )`
163
163
  cursor: pointer;
164
164
  line-height: 1.2; // Characters in some languages (e.g. Japanese) may have a native higher line-height.
165
165
  font-weight: 400;
166
+ font-size: ${ font( 'default.fontSize' ) };
166
167
  color: ${ COLORS.theme.foreground };
167
168
 
168
169
  &[aria-disabled='true'] {
@@ -54,7 +54,7 @@ export const Default: StoryFn< typeof ToolsPanel > = ( {
54
54
  const [ height, setHeight ] = useState< string | undefined >();
55
55
  const [ minHeight, setMinHeight ] = useState< string | undefined >();
56
56
  const [ width, setWidth ] = useState< string | undefined >();
57
- const [ scale, setScale ] = useState< React.ReactText | undefined >();
57
+ const [ scale, setScale ] = useState< number | string | undefined >();
58
58
 
59
59
  const resetAll: typeof resetAllProp = ( filters ) => {
60
60
  setHeight( undefined );
@@ -414,7 +414,7 @@ export const WithConditionalDefaultControl: StoryFn< typeof ToolsPanel > = ( {
414
414
  } ) => {
415
415
  const [ attributes, setAttributes ] = useState< {
416
416
  height?: string;
417
- scale?: React.ReactText;
417
+ scale?: number | string;
418
418
  } >( {} );
419
419
  const { height, scale } = attributes;
420
420
 
@@ -512,7 +512,7 @@ export const WithConditionallyRenderedControl: StoryFn<
512
512
  > = ( { resetAll: resetAllProp, panelId, ...props } ) => {
513
513
  const [ attributes, setAttributes ] = useState< {
514
514
  height?: string;
515
- scale?: React.ReactText;
515
+ scale?: number | string;
516
516
  } >( {} );
517
517
  const { height, scale } = attributes;
518
518
 
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import type { CSSProperties, ReactText } from 'react';
4
+ import type { CSSProperties } from 'react';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -61,7 +61,7 @@ export function getFontSize(
61
61
  return `calc(${ ratio } * ${ CONFIG.fontSize })`;
62
62
  }
63
63
 
64
- export function getHeadingFontSize( size: ReactText = 3 ): string {
64
+ export function getHeadingFontSize( size: number | string = 3 ): string {
65
65
  if ( ! HEADING_FONT_SIZES.includes( size as HeadingSize ) ) {
66
66
  return getFontSize( size );
67
67
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import type { ReactNode, ReactChild, ReactFragment, ReactPortal } from 'react';
4
+ import type { ReactNode, ReactElement, ReactPortal } from 'react';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
@@ -17,7 +17,9 @@ import { Children, isValidElement } from '@wordpress/element';
17
17
  */
18
18
  export function getValidChildren(
19
19
  children: ReactNode
20
- ): Array< ReactChild | ReactFragment | ReactPortal > {
20
+ ): Array<
21
+ ReactElement | number | string | Iterable< ReactNode > | ReactPortal
22
+ > {
21
23
  if ( typeof children === 'string' ) {
22
24
  return [ children ];
23
25
  }
@@ -29,3 +29,4 @@ $components-color-light-gray-placeholder: color-mix(in srgb, $components-color-b
29
29
 
30
30
  // Semantic aliases (prefer these over raw gray values when applicable).
31
31
  $components-color-border: #{ $components-color-gray-600 };
32
+ $components-color-disabled: #{ $components-color-gray-600 };
@@ -17,7 +17,8 @@ type Value = CheckboxControlProps[ 'checked' ];
17
17
  const UnforwardedValidatedCheckboxControl = (
18
18
  {
19
19
  required,
20
- customValidator,
20
+ onValidate,
21
+ customValidity,
21
22
  onChange,
22
23
  markWhenOptional,
23
24
  ...restProps
@@ -37,9 +38,10 @@ const UnforwardedValidatedCheckboxControl = (
37
38
  required={ required }
38
39
  markWhenOptional={ markWhenOptional }
39
40
  ref={ mergedRefs }
40
- customValidator={ () => {
41
- return customValidator?.( valueRef.current );
41
+ onValidate={ () => {
42
+ return onValidate?.( valueRef.current );
42
43
  } }
44
+ customValidity={ customValidity }
43
45
  getValidityTarget={ () =>
44
46
  validityTargetRef.current?.querySelector< HTMLInputElement >(
45
47
  'input[type="checkbox"]'
@@ -17,7 +17,8 @@ type Value = ComboboxControlProps[ 'value' ];
17
17
  const UnforwardedValidatedComboboxControl = (
18
18
  {
19
19
  required,
20
- customValidator,
20
+ onValidate,
21
+ customValidity,
21
22
  onChange,
22
23
  markWhenOptional,
23
24
  ...restProps
@@ -50,9 +51,10 @@ const UnforwardedValidatedComboboxControl = (
50
51
  required={ required }
51
52
  markWhenOptional={ markWhenOptional }
52
53
  ref={ mergedRefs }
53
- customValidator={ () => {
54
- return customValidator?.( valueRef.current );
54
+ onValidate={ () => {
55
+ return onValidate?.( valueRef.current );
55
56
  } }
57
+ customValidity={ customValidity }
56
58
  getValidityTarget={ () =>
57
59
  validityTargetRef.current?.querySelector< HTMLInputElement >(
58
60
  'input[role="combobox"]'
@@ -21,7 +21,8 @@ type Value = CustomSelectControlProps[ 'value' ];
21
21
  const UnforwardedValidatedCustomSelectControl = (
22
22
  {
23
23
  required,
24
- customValidator,
24
+ onValidate,
25
+ customValidity,
25
26
  onChange,
26
27
  markWhenOptional,
27
28
  ...restProps
@@ -43,9 +44,10 @@ const UnforwardedValidatedCustomSelectControl = (
43
44
  <ControlWithError
44
45
  required={ required }
45
46
  markWhenOptional={ markWhenOptional }
46
- customValidator={ () => {
47
- return customValidator?.( valueRef.current );
47
+ onValidate={ () => {
48
+ return onValidate?.( valueRef.current );
48
49
  } }
50
+ customValidity={ customValidity }
49
51
  getValidityTarget={ () => validityTargetRef.current }
50
52
  >
51
53
  <CustomSelectControl
@@ -17,7 +17,8 @@ type Value = InputControlProps[ 'value' ];
17
17
  const UnforwardedValidatedInputControl = (
18
18
  {
19
19
  required,
20
- customValidator,
20
+ onValidate,
21
+ customValidity,
21
22
  onChange,
22
23
  markWhenOptional,
23
24
  ...restProps
@@ -36,9 +37,10 @@ const UnforwardedValidatedInputControl = (
36
37
  <ControlWithError
37
38
  required={ required }
38
39
  markWhenOptional={ markWhenOptional }
39
- customValidator={ () => {
40
- return customValidator?.( valueRef.current );
40
+ onValidate={ () => {
41
+ return onValidate?.( valueRef.current );
41
42
  } }
43
+ customValidity={ customValidity }
42
44
  getValidityTarget={ () => validityTargetRef.current }
43
45
  >
44
46
  <InputControl
@@ -17,7 +17,8 @@ type Value = NumberControlProps[ 'value' ];
17
17
  const UnforwardedValidatedNumberControl = (
18
18
  {
19
19
  required,
20
- customValidator,
20
+ onValidate,
21
+ customValidity,
21
22
  onChange,
22
23
  markWhenOptional,
23
24
  ...restProps
@@ -36,9 +37,10 @@ const UnforwardedValidatedNumberControl = (
36
37
  <ControlWithError
37
38
  required={ required }
38
39
  markWhenOptional={ markWhenOptional }
39
- customValidator={ () => {
40
- return customValidator?.( valueRef.current );
40
+ onValidate={ () => {
41
+ return onValidate?.( valueRef.current );
41
42
  } }
43
+ customValidity={ customValidity }
42
44
  getValidityTarget={ () => validityTargetRef.current }
43
45
  >
44
46
  <NumberControl
@@ -17,7 +17,8 @@ type Value = RadioControlProps[ 'selected' ];
17
17
  const UnforwardedValidatedRadioControl = (
18
18
  {
19
19
  required,
20
- customValidator,
20
+ onValidate,
21
+ customValidity,
21
22
  onChange,
22
23
  markWhenOptional,
23
24
  ...restProps
@@ -35,9 +36,10 @@ const UnforwardedValidatedRadioControl = (
35
36
  markWhenOptional={ markWhenOptional }
36
37
  // TODO: Upstream limitation - RadioControl does not accept a ref.
37
38
  ref={ mergedRefs }
38
- customValidator={ () => {
39
- return customValidator?.( valueRef.current );
39
+ onValidate={ () => {
40
+ return onValidate?.( valueRef.current );
40
41
  } }
42
+ customValidity={ customValidity }
41
43
  getValidityTarget={ () =>
42
44
  validityTargetRef.current?.querySelector< HTMLInputElement >(
43
45
  'input[type="radio"]'
@@ -17,7 +17,8 @@ type Value = RangeControlProps[ 'value' ];
17
17
  const UnforwardedValidatedRangeControl = (
18
18
  {
19
19
  required,
20
- customValidator,
20
+ onValidate,
21
+ customValidity,
21
22
  onChange,
22
23
  markWhenOptional,
23
24
  ...restProps
@@ -36,9 +37,10 @@ const UnforwardedValidatedRangeControl = (
36
37
  <ControlWithError
37
38
  required={ required }
38
39
  markWhenOptional={ markWhenOptional }
39
- customValidator={ () => {
40
- return customValidator?.( valueRef.current );
40
+ onValidate={ () => {
41
+ return onValidate?.( valueRef.current );
41
42
  } }
43
+ customValidity={ customValidity }
42
44
  getValidityTarget={ () => validityTargetRef.current }
43
45
  >
44
46
  <RangeControl
@@ -26,7 +26,8 @@ type Value = SelectControlProps[ 'value' ];
26
26
  const UnforwardedValidatedSelectControl = (
27
27
  {
28
28
  required,
29
- customValidator,
29
+ onValidate,
30
+ customValidity,
30
31
  onChange,
31
32
  markWhenOptional,
32
33
  ...restProps
@@ -51,9 +52,10 @@ const UnforwardedValidatedSelectControl = (
51
52
  <ControlWithError
52
53
  required={ required }
53
54
  markWhenOptional={ markWhenOptional }
54
- customValidator={ () => {
55
- return customValidator?.( valueRef.current );
55
+ onValidate={ () => {
56
+ return onValidate?.( valueRef.current );
56
57
  } }
58
+ customValidity={ customValidity }
57
59
  getValidityTarget={ () => validityTargetRef.current }
58
60
  >
59
61
  <SelectControl
@@ -32,6 +32,12 @@ export default meta;
32
32
  export const Default: StoryObj< typeof ValidatedCheckboxControl > = {
33
33
  render: function Template( { onChange, ...args } ) {
34
34
  const [ checked, setChecked ] = useState( false );
35
+ const [ customValidity, setCustomValidity ] =
36
+ useState<
37
+ React.ComponentProps<
38
+ typeof ValidatedCheckboxControl
39
+ >[ 'customValidity' ]
40
+ >( undefined );
35
41
 
36
42
  return (
37
43
  <ValidatedCheckboxControl
@@ -41,6 +47,17 @@ export const Default: StoryObj< typeof ValidatedCheckboxControl > = {
41
47
  setChecked( value );
42
48
  onChange?.( value );
43
49
  } }
50
+ onValidate={ ( value ) => {
51
+ if ( value ) {
52
+ setCustomValidity( {
53
+ type: 'invalid',
54
+ message: 'This checkbox may not be checked.',
55
+ } );
56
+ } else {
57
+ setCustomValidity( undefined );
58
+ }
59
+ } }
60
+ customValidity={ customValidity }
44
61
  />
45
62
  );
46
63
  },
@@ -49,10 +66,4 @@ Default.args = {
49
66
  required: true,
50
67
  label: 'Checkbox',
51
68
  help: 'This checkbox may neither be checked nor unchecked.',
52
- customValidator: ( value ) => {
53
- if ( value ) {
54
- return 'This checkbox may not be checked.';
55
- }
56
- return undefined;
57
- },
58
69
  };