@wordpress/components 19.0.4 → 19.1.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 (144) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/build/card/styles.js +21 -17
  3. package/build/card/styles.js.map +1 -1
  4. package/build/circular-option-picker/index.js +2 -2
  5. package/build/circular-option-picker/index.js.map +1 -1
  6. package/build/color-palette/index.js +7 -1
  7. package/build/color-palette/index.js.map +1 -1
  8. package/build/color-picker/component.js +15 -5
  9. package/build/color-picker/component.js.map +1 -1
  10. package/build/date-time/time.js +17 -3
  11. package/build/date-time/time.js.map +1 -1
  12. package/build/duotone-picker/duotone-picker.js +2 -1
  13. package/build/duotone-picker/duotone-picker.js.map +1 -1
  14. package/build/font-size-picker/index.js +2 -1
  15. package/build/font-size-picker/index.js.map +1 -1
  16. package/build/gradient-picker/index.js +2 -2
  17. package/build/gradient-picker/index.js.map +1 -1
  18. package/build/index.js +7 -7
  19. package/build/index.js.map +1 -1
  20. package/build/mobile/global-styles-context/utils.native.js +2 -2
  21. package/build/mobile/global-styles-context/utils.native.js.map +1 -1
  22. package/build/navigation/item/index.js +9 -4
  23. package/build/navigation/item/index.js.map +1 -1
  24. package/build/navigation/styles/navigation-styles.js +37 -30
  25. package/build/navigation/styles/navigation-styles.js.map +1 -1
  26. package/build/palette-edit/index.js +307 -0
  27. package/build/palette-edit/index.js.map +1 -0
  28. package/build/palette-edit/styles.js +112 -0
  29. package/build/palette-edit/styles.js.map +1 -0
  30. package/build/popover/index.js +1 -1
  31. package/build/popover/index.js.map +1 -1
  32. package/build/toggle-group-control/toggle-group-control-option/component.js +30 -4
  33. package/build/toggle-group-control/toggle-group-control-option/component.js.map +1 -1
  34. package/build/tooltip/index.js +4 -4
  35. package/build/tooltip/index.js.map +1 -1
  36. package/build-module/card/styles.js +21 -17
  37. package/build-module/card/styles.js.map +1 -1
  38. package/build-module/circular-option-picker/index.js +2 -2
  39. package/build-module/circular-option-picker/index.js.map +1 -1
  40. package/build-module/color-palette/index.js +6 -1
  41. package/build-module/color-palette/index.js.map +1 -1
  42. package/build-module/color-picker/component.js +13 -5
  43. package/build-module/color-picker/component.js.map +1 -1
  44. package/build-module/date-time/time.js +17 -3
  45. package/build-module/date-time/time.js.map +1 -1
  46. package/build-module/duotone-picker/duotone-picker.js +2 -1
  47. package/build-module/duotone-picker/duotone-picker.js.map +1 -1
  48. package/build-module/font-size-picker/index.js +2 -1
  49. package/build-module/font-size-picker/index.js.map +1 -1
  50. package/build-module/gradient-picker/index.js +2 -2
  51. package/build-module/gradient-picker/index.js.map +1 -1
  52. package/build-module/index.js +1 -1
  53. package/build-module/index.js.map +1 -1
  54. package/build-module/mobile/global-styles-context/utils.native.js +2 -2
  55. package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
  56. package/build-module/navigation/item/index.js +10 -5
  57. package/build-module/navigation/item/index.js.map +1 -1
  58. package/build-module/navigation/styles/navigation-styles.js +34 -28
  59. package/build-module/navigation/styles/navigation-styles.js.map +1 -1
  60. package/build-module/palette-edit/index.js +280 -0
  61. package/build-module/palette-edit/index.js.map +1 -0
  62. package/build-module/palette-edit/styles.js +90 -0
  63. package/build-module/palette-edit/styles.js.map +1 -0
  64. package/build-module/popover/index.js +1 -1
  65. package/build-module/popover/index.js.map +1 -1
  66. package/build-module/toggle-group-control/toggle-group-control-option/component.js +26 -5
  67. package/build-module/toggle-group-control/toggle-group-control-option/component.js.map +1 -1
  68. package/build-module/tooltip/index.js +4 -4
  69. package/build-module/tooltip/index.js.map +1 -1
  70. package/build-style/style-rtl.css +33 -1
  71. package/build-style/style.css +33 -1
  72. package/build-types/card/card/hook.d.ts +1 -1
  73. package/build-types/card/card-header/component.d.ts +1 -1
  74. package/build-types/card/styles.d.ts +7 -4
  75. package/build-types/card/styles.d.ts.map +1 -1
  76. package/build-types/card/types.d.ts +2 -1
  77. package/build-types/card/types.d.ts.map +1 -1
  78. package/build-types/confirm-dialog/component.d.ts +34 -0
  79. package/build-types/confirm-dialog/component.d.ts.map +1 -0
  80. package/build-types/confirm-dialog/index.d.ts +6 -0
  81. package/build-types/confirm-dialog/index.d.ts.map +1 -0
  82. package/build-types/confirm-dialog/types.d.ts +20 -0
  83. package/build-types/confirm-dialog/types.d.ts.map +1 -0
  84. package/build-types/flyout/styles.d.ts +1 -1
  85. package/build-types/higher-order/with-focus-outside/index.d.ts +3 -0
  86. package/build-types/higher-order/with-focus-outside/index.d.ts.map +1 -0
  87. package/build-types/modal/aria-helper.d.ts +27 -0
  88. package/build-types/modal/aria-helper.d.ts.map +1 -0
  89. package/build-types/modal/index.d.ts +3 -0
  90. package/build-types/modal/index.d.ts.map +1 -0
  91. package/build-types/popover/index.d.ts.map +1 -1
  92. package/build-types/style-provider/index.d.ts +5 -0
  93. package/build-types/style-provider/index.d.ts.map +1 -0
  94. package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts.map +1 -1
  95. package/build-types/toggle-group-control/types.d.ts +23 -0
  96. package/build-types/toggle-group-control/types.d.ts.map +1 -1
  97. package/build-types/tooltip/index.d.ts +1 -7
  98. package/build-types/tooltip/index.d.ts.map +1 -1
  99. package/package.json +2 -2
  100. package/src/card/styles.js +8 -3
  101. package/src/card/test/__snapshots__/index.js.snap +6 -1
  102. package/src/card/test/index.js +20 -0
  103. package/src/card/types.ts +2 -1
  104. package/src/circular-option-picker/index.js +7 -5
  105. package/src/circular-option-picker/style.scss +1 -0
  106. package/src/color-palette/index.js +8 -0
  107. package/src/color-palette/style.scss +21 -0
  108. package/src/color-palette/test/__snapshots__/index.js.snap +2 -0
  109. package/src/color-picker/README.md +13 -11
  110. package/src/color-picker/component.tsx +15 -5
  111. package/src/color-picker/test/index.js +15 -0
  112. package/src/date-time/test/time.js +32 -2
  113. package/src/date-time/time.js +14 -6
  114. package/src/duotone-picker/duotone-picker.js +8 -5
  115. package/src/font-size-picker/index.js +1 -0
  116. package/src/gradient-picker/index.js +7 -4
  117. package/src/gradient-picker/stories/index.js +23 -0
  118. package/src/index.js +1 -1
  119. package/src/mobile/global-styles-context/utils.native.js +2 -2
  120. package/src/navigation/item/index.js +20 -5
  121. package/src/navigation/stories/more-examples.js +2 -1
  122. package/src/navigation/styles/navigation-styles.js +5 -0
  123. package/src/palette-edit/index.js +398 -0
  124. package/src/palette-edit/style.scss +19 -0
  125. package/src/{color-edit → palette-edit}/styles.js +15 -18
  126. package/src/popover/index.js +5 -1
  127. package/src/style.scss +1 -1
  128. package/src/toggle-group-control/stories/index.js +15 -0
  129. package/src/toggle-group-control/test/index.js +57 -0
  130. package/src/toggle-group-control/toggle-group-control-option/README.md +8 -1
  131. package/src/toggle-group-control/toggle-group-control-option/component.tsx +40 -17
  132. package/src/toggle-group-control/types.ts +24 -0
  133. package/src/tooltip/index.js +2 -7
  134. package/tsconfig.tsbuildinfo +1 -1
  135. package/build/color-edit/index.js +0 -251
  136. package/build/color-edit/index.js.map +0 -1
  137. package/build/color-edit/styles.js +0 -112
  138. package/build/color-edit/styles.js.map +0 -1
  139. package/build-module/color-edit/index.js +0 -227
  140. package/build-module/color-edit/index.js.map +0 -1
  141. package/build-module/color-edit/styles.js +0 -90
  142. package/build-module/color-edit/styles.js.map +0 -1
  143. package/src/color-edit/index.js +0 -300
  144. package/src/color-edit/style.scss +0 -6
@@ -8,7 +8,7 @@ export declare const FlyoutContentView: import("@emotion/styled").StyledComponen
8
8
  theme?: import("@emotion/react").Theme | undefined;
9
9
  }, {}, {}>;
10
10
  export declare const CardView: import("@emotion/styled").StyledComponent<import("../surface/types").Props & {
11
- size?: import("../card/types").SizeOptions | undefined;
11
+ size?: import("../card/types").SizeOptions | "extraSmall" | undefined;
12
12
  } & {
13
13
  elevation?: number | undefined;
14
14
  isBorderless?: boolean | undefined;
@@ -0,0 +1,3 @@
1
+ declare var _default: import("@wordpress/compose/build-types/utils/create-higher-order-component").HigherOrderComponent<any, any>;
2
+ export default _default;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/higher-order/with-focus-outside/index.js"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Hides all elements in the body element from screen-readers except
3
+ * the provided element and elements that should not be hidden from
4
+ * screen-readers.
5
+ *
6
+ * The reason we do this is because `aria-modal="true"` currently is bugged
7
+ * in Safari, and support is spotty in other browsers overall. In the future
8
+ * we should consider removing these helper functions in favor of
9
+ * `aria-modal="true"`.
10
+ *
11
+ * @param {Element} unhiddenElement The element that should not be hidden.
12
+ */
13
+ export function hideApp(unhiddenElement: Element): void;
14
+ /**
15
+ * Determines if the passed element should not be hidden from screen readers.
16
+ *
17
+ * @param {HTMLElement} element The element that should be checked.
18
+ *
19
+ * @return {boolean} Whether the element should not be hidden from screen-readers.
20
+ */
21
+ export function elementShouldBeHidden(element: HTMLElement): boolean;
22
+ /**
23
+ * Makes all elements in the body that have been hidden by `hideApp`
24
+ * visible again to screen-readers.
25
+ */
26
+ export function showApp(): void;
27
+ //# sourceMappingURL=aria-helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aria-helper.d.ts","sourceRoot":"","sources":["../../src/modal/aria-helper.js"],"names":[],"mappings":"AAkBA;;;;;;;;;;;GAWG;AACH,yCAFW,OAAO,QAiBjB;AAED;;;;;;GAMG;AACH,+CAJW,WAAW,GAEV,OAAO,CAUlB;AAED;;;GAGG;AACH,gCASC"}
@@ -0,0 +1,3 @@
1
+ declare var _default: import("react").ForwardRefExoticComponent<Pick<any, string | number | symbol> & import("react").RefAttributes<any>>;
2
+ export default _default;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/modal/index.js"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/popover/index.js"],"names":[],"mappings":";AAujBA;;;;;;;;;;;;;;;;;;;;;;;;;0DAA+C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/popover/index.js"],"names":[],"mappings":";AA2jBA;;;;;;;;;;;;;;;;;;;;;;;;;0DAA+C"}
@@ -0,0 +1,5 @@
1
+ export default function StyleProvider({ children, document }: {
2
+ children: any;
3
+ document: any;
4
+ }): JSX.Element | null;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/style-provider/index.js"],"names":[],"mappings":"AAsBA;;;uBAQC"}
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/toggle-group-control/toggle-group-control-option/component.tsx"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAuD9D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAA,MAAM,iCAAiC,8FAGtC,CAAC;AAEF,eAAe,iCAAiC,CAAC"}
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/toggle-group-control/toggle-group-control-option/component.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,6BAA6B,EAAoB,MAAM,UAAU,CAAC;AA+EhF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAA,MAAM,iCAAiC,8FAGtC,CAAC;AAEF,eAAe,iCAAiC,CAAC"}
@@ -14,6 +14,29 @@ export declare type ToggleGroupControlOptionProps = {
14
14
  * to specify a different label for assistive technologies.
15
15
  */
16
16
  label: string;
17
+ /**
18
+ * Whether to display a Tooltip for the control option. If set to `true`, the tooltip will
19
+ * show the aria-label or the label prop text.
20
+ *
21
+ * @default false
22
+ */
23
+ showTooltip?: boolean;
24
+ };
25
+ export declare type WithToolTipProps = {
26
+ /**
27
+ * React children
28
+ */
29
+ children: ReactNode;
30
+ /**
31
+ * Label for the Tooltip component.
32
+ */
33
+ text: string;
34
+ /**
35
+ * Whether to wrap the control option in a Tooltip component.
36
+ *
37
+ * @default false
38
+ */
39
+ showTooltip?: boolean;
17
40
  };
18
41
  export declare type ToggleGroupControlProps = Omit<FormElementProps<any>, 'defaultValue'> & {
19
42
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/toggle-group-control/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAE/C;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,oBAAY,6BAA6B,GAAG;IAC3C,KAAK,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,oBAAY,uBAAuB,GAAG,IAAI,CACzC,gBAAgB,CAAE,GAAG,CAAE,EACvB,cAAc,CACd,GAAG;IACH;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAE,KAAK,EAAE,SAAS,GAAG,SAAS,KAAM,IAAI,CAAC;IACpD;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,oBAAY,8BAA8B,GAAG,gBAAgB,GAAG;IAC/D;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,oBAAY,+BAA+B,GAAG;IAC7C,YAAY,EAAE,gBAAgB,CAAE,WAAW,GAAG,SAAS,CAAE,CAAC;IAC1D,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,KAAK,CAAC,EAAE,GAAG,CAAC;CACZ,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/toggle-group-control/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAE/C;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,oBAAY,6BAA6B,GAAG;IAC3C,KAAK,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,oBAAY,gBAAgB,GAAG;IAC9B;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,oBAAY,uBAAuB,GAAG,IAAI,CACzC,gBAAgB,CAAE,GAAG,CAAE,EACvB,cAAc,CACd,GAAG;IACH;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAE,KAAK,EAAE,SAAS,GAAG,SAAS,KAAM,IAAI,CAAC;IACpD;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,oBAAY,8BAA8B,GAAG,gBAAgB,GAAG;IAC/D;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,oBAAY,+BAA+B,GAAG;IAC7C,YAAY,EAAE,gBAAgB,CAAE,WAAW,GAAG,SAAS,CAAE,CAAC;IAC1D,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,KAAK,CAAC,EAAE,GAAG,CAAC;CACZ,CAAC"}
@@ -5,11 +5,5 @@
5
5
  */
6
6
  export const TOOLTIP_DELAY: number;
7
7
  export default Tooltip;
8
- declare function Tooltip({ children, position, text, shortcut, delay, }: {
9
- children: any;
10
- position: any;
11
- text: any;
12
- shortcut: any;
13
- delay?: number | undefined;
14
- }): any;
8
+ declare function Tooltip(props: any): any;
15
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tooltip/index.js"],"names":[],"mappings":"AAwBA;;;;GAIG;AACH,4BAFU,MAAM,CAEiB;;AAiEjC;;;;;;QAuIC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tooltip/index.js"],"names":[],"mappings":"AAwBA;;;;GAIG;AACH,4BAFU,MAAM,CAEiB;;AAiEjC,0CAkIC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/components",
3
- "version": "19.0.4",
3
+ "version": "19.1.2",
4
4
  "description": "UI components for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -74,5 +74,5 @@
74
74
  "publishConfig": {
75
75
  "access": "public"
76
76
  },
77
- "gitHead": "ca22e8852fcc91889510e417bdaa180ad60f8dac"
77
+ "gitHead": "34b76b2f9397215e5afb8443f5b3073c83913102"
78
78
  }
@@ -88,6 +88,10 @@ export const rounded = css`
88
88
  border-radius: ${ CONFIG.cardBorderRadius };
89
89
  `;
90
90
 
91
+ const xSmallCardPadding = css`
92
+ padding: ${ CONFIG.cardPaddingXSmall };
93
+ `;
94
+
91
95
  export const cardPaddings = {
92
96
  large: css`
93
97
  padding: ${ CONFIG.cardPaddingLarge };
@@ -98,9 +102,10 @@ export const cardPaddings = {
98
102
  small: css`
99
103
  padding: ${ CONFIG.cardPaddingSmall };
100
104
  `,
101
- xSmall: css`
102
- padding: ${ CONFIG.cardPaddingXSmall };
103
- `,
105
+ xSmall: xSmallCardPadding,
106
+ // The `extraSmall` size is not officially documented, but the following styles
107
+ // are kept for legacy reasons to support older values of the `size` prop.
108
+ extraSmall: xSmallCardPadding,
104
109
  };
105
110
 
106
111
  export const shady = css`
@@ -141,7 +141,7 @@ Snapshot Diff:
141
141
  </div>
142
142
  <div
143
143
  - class="components-flex components-card__footer components-card-footer css-c7cteg-View-Flex-sx-Base-sx-Items-ItemsRow-Footer-borderRadius-borderColor-large-borderless em57xhy0"
144
- + class="components-flex components-card__footer components-card-footer css-1mzdgj0-View-Flex-sx-Base-sx-Items-ItemsRow-Footer-borderRadius-borderColor-xSmall em57xhy0"
144
+ + class="components-flex components-card__footer components-card-footer css-1t7s584-View-Flex-sx-Base-sx-Items-ItemsRow-Footer-borderRadius-borderColor-xSmallCardPadding em57xhy0"
145
145
  data-wp-c16t="true"
146
146
  data-wp-component="CardFooter"
147
147
  >
@@ -784,6 +784,11 @@ Snapshot Diff:
784
784
  </div>
785
785
  `;
786
786
 
787
+ exports[`Card Card component should support the legacy extraSmall value for the size prop as an alias for the xSmall value 1`] = `
788
+ Snapshot Diff:
789
+ Compared values have no visual difference.
790
+ `;
791
+
787
792
  exports[`Card Card component should warn when the isElevated prop is passed 1`] = `
788
793
  .emotion-0 {
789
794
  background-color: #fff;
@@ -143,6 +143,26 @@ describe( 'Card', () => {
143
143
  expect( withoutBorder ).toMatchDiffSnapshot( withBorder );
144
144
  } );
145
145
 
146
+ it( 'should support the legacy extraSmall value for the size prop as an alias for the xSmall value', () => {
147
+ const { container: containerXSmall } = render(
148
+ <Card size="xSmall">
149
+ <CardHeader>Header</CardHeader>
150
+ <CardBody>Body</CardBody>
151
+ <CardFooter>Footer</CardFooter>
152
+ </Card>
153
+ );
154
+ const { container: containerExtraSmall } = render(
155
+ <Card size="extraSmall">
156
+ <CardHeader>Header</CardHeader>
157
+ <CardBody>Body</CardBody>
158
+ <CardFooter>Footer</CardFooter>
159
+ </Card>
160
+ );
161
+ expect( containerXSmall ).toMatchDiffSnapshot(
162
+ containerExtraSmall
163
+ );
164
+ } );
165
+
146
166
  describe( 'CardHeader', () => {
147
167
  it( 'should render with a darker background color when isShady is true', () => {
148
168
  const { container } = render( <CardHeader>Header</CardHeader> );
package/src/card/types.ts CHANGED
@@ -9,6 +9,7 @@ import type { CSSProperties } from 'react';
9
9
  */
10
10
  import type { Props as SurfaceProps } from '../surface/types';
11
11
 
12
+ type DeprecatedSizeOptions = 'extraSmall';
12
13
  export type SizeOptions = 'xSmall' | 'small' | 'medium' | 'large';
13
14
 
14
15
  type SizeableProps = {
@@ -17,7 +18,7 @@ type SizeableProps = {
17
18
  *
18
19
  * @default 'medium'
19
20
  */
20
- size?: SizeOptions;
21
+ size?: SizeOptions | DeprecatedSizeOptions;
21
22
  };
22
23
 
23
24
  export type Props = SurfaceProps &
@@ -25,15 +25,17 @@ function Option( {
25
25
  const optionButton = (
26
26
  <Button
27
27
  isPressed={ isSelected }
28
- className={ classnames(
29
- className,
30
- 'components-circular-option-picker__option'
31
- ) }
28
+ className="components-circular-option-picker__option"
32
29
  { ...additionalProps }
33
30
  />
34
31
  );
35
32
  return (
36
- <div className="components-circular-option-picker__option-wrapper">
33
+ <div
34
+ className={ classnames(
35
+ className,
36
+ 'components-circular-option-picker__option-wrapper'
37
+ ) }
38
+ >
37
39
  { tooltipText ? (
38
40
  <Tooltip text={ tooltipText }>{ optionButton }</Tooltip>
39
41
  ) : (
@@ -9,6 +9,7 @@ $color-palette-circle-spacing: 12px;
9
9
  .components-circular-option-picker__custom-clear-wrapper {
10
10
  display: flex;
11
11
  justify-content: flex-end;
12
+ margin-top: $grid-unit-15;
12
13
  }
13
14
 
14
15
  .components-circular-option-picker__swatches {
@@ -5,6 +5,7 @@ import { map } from 'lodash';
5
5
  import { colord, extend } from 'colord';
6
6
  import namesPlugin from 'colord/plugins/names';
7
7
  import a11yPlugin from 'colord/plugins/a11y';
8
+ import classnames from 'classnames';
8
9
 
9
10
  /**
10
11
  * WordPress dependencies
@@ -117,6 +118,7 @@ export default function ColorPalette( {
117
118
  onChange,
118
119
  value,
119
120
  __experimentalHasMultipleOrigins = false,
121
+ __experimentalIsRenderedInSidebar = false,
120
122
  } ) {
121
123
  const clearColor = useCallback( () => onChange( undefined ), [ onChange ] );
122
124
  const Component = __experimentalHasMultipleOrigins
@@ -135,6 +137,12 @@ export default function ColorPalette( {
135
137
  <VStack spacing={ 3 } className={ className }>
136
138
  { ! disableCustomColors && (
137
139
  <Dropdown
140
+ contentClassName={ classnames(
141
+ 'components-color-palette__custom-color-dropdown-content',
142
+ {
143
+ 'is-rendered-in-sidebar': __experimentalIsRenderedInSidebar,
144
+ }
145
+ ) }
138
146
  renderContent={ renderCustomColorPicker }
139
147
  renderToggle={ ( { isOpen, onToggle } ) => (
140
148
  <button
@@ -16,3 +16,24 @@
16
16
  color: $white;
17
17
  cursor: pointer;
18
18
  }
19
+
20
+ .components-dropdown__content.components-color-palette__custom-color-dropdown-content .components-popover__content {
21
+ overflow: visible;
22
+ box-shadow: 0 4px 4px rgba(0, 0, 0, 0.05);
23
+ border: none;
24
+ border-radius: $radius-block-ui;
25
+ & > div {
26
+ padding: 0;
27
+ }
28
+ .react-colorful__saturation {
29
+ border-top-right-radius: $radius-block-ui;
30
+ border-top-left-radius: $radius-block-ui;
31
+ }
32
+ }
33
+
34
+ @include break-medium() {
35
+ .components-dropdown__content.components-color-palette__custom-color-dropdown-content.is-rendered-in-sidebar.is-from-top .components-popover__content {
36
+ margin-right: #{ math.div($sidebar-width, 2) + $grid-unit-20 };
37
+ margin-top: #{ -($grid-unit-60 + $grid-unit-15) };
38
+ }
39
+ }
@@ -26,6 +26,7 @@ exports[`ColorPalette Dropdown .renderToggle should render dropdown content 1`]
26
26
 
27
27
  exports[`ColorPalette Dropdown should render it correctly 1`] = `
28
28
  <Dropdown
29
+ contentClassName="components-color-palette__custom-color-dropdown-content"
29
30
  key=".0"
30
31
  renderContent={[Function]}
31
32
  renderToggle={[Function]}
@@ -177,6 +178,7 @@ exports[`ColorPalette should render a dynamic toolbar of colors 1`] = `
177
178
  data-wp-component="VStack"
178
179
  >
179
180
  <Dropdown
181
+ contentClassName="components-color-palette__custom-color-dropdown-content"
180
182
  key=".0"
181
183
  renderContent={[Function]}
182
184
  renderToggle={[Function]}
@@ -22,32 +22,34 @@ function Example() {
22
22
 
23
23
  ## Props
24
24
 
25
- ### `color`
26
-
27
- **Type**: `string`
25
+ ### `color`: `string`
28
26
 
29
27
  The current color value to display in the picker. Must be a hex or hex8 string.
30
28
 
31
- ### `onChange`
29
+ - Required: No
32
30
 
33
- **Type**: `(hex8Color: string) => void`
31
+ ### `onChange`: `(hex8Color: string) => void`
34
32
 
35
33
  Fired when the color changes. Always passes a hex8 color string.
36
34
 
37
- ### `enableAlpha`
35
+ - Required: No
38
36
 
39
- **Type**: `boolean`
37
+ ### `enableAlpha`: `boolean`
40
38
 
41
39
  Defaults to `false`. When `true` the color picker will display the alpha channel both in the bottom inputs as well as in the color picker itself.
42
40
 
43
- ### `defaultValue`
41
+ - Required: No
42
+ - Default: `false`
44
43
 
45
- **Type**: `string | undefined`
44
+ ### `defaultValue`: `string | undefined`
46
45
 
47
46
  An optional default value to use for the color picker.
48
47
 
49
- ### `copyFormat`
48
+ - Required: No
49
+ - Default: `'#fff'`
50
50
 
51
- **Type**: `'hex' | 'hsl' | 'rgb' | undefined`
51
+ ### `copyFormat`: `'hex' | 'hsl' | 'rgb' | undefined`
52
52
 
53
53
  The format to copy when clicking the displayed color format.
54
+
55
+ - Required: No
@@ -11,6 +11,7 @@ import namesPlugin from 'colord/plugins/names';
11
11
  */
12
12
  import { useState, useMemo } from '@wordpress/element';
13
13
  import { settings } from '@wordpress/icons';
14
+ import { useDebounce } from '@wordpress/compose';
14
15
  import { __ } from '@wordpress/i18n';
15
16
 
16
17
  /**
@@ -32,6 +33,7 @@ import {
32
33
  import { ColorDisplay } from './color-display';
33
34
  import { ColorInput } from './color-input';
34
35
  import { Picker } from './picker';
36
+ import { useControlledValue } from '../utils/hooks';
35
37
 
36
38
  import type { ColorType } from './types';
37
39
 
@@ -57,7 +59,7 @@ const ColorPicker = (
57
59
  ) => {
58
60
  const {
59
61
  enableAlpha = false,
60
- color,
62
+ color: colorProp,
61
63
  onChange,
62
64
  defaultValue = '#fff',
63
65
  copyFormat,
@@ -65,15 +67,23 @@ const ColorPicker = (
65
67
  } = useContextSystem( props, 'ColorPicker' );
66
68
 
67
69
  // Use a safe default value for the color and remove the possibility of `undefined`.
70
+ const [ color, setColor ] = useControlledValue( {
71
+ onChange,
72
+ value: colorProp,
73
+ defaultValue,
74
+ } );
75
+
68
76
  const safeColordColor = useMemo( () => {
69
- return color ? colord( color ) : colord( defaultValue );
70
- }, [ color, defaultValue ] );
77
+ return colord( color );
78
+ }, [ color ] );
79
+
80
+ const debouncedSetColor = useDebounce( setColor );
71
81
 
72
82
  const handleChange = useCallback(
73
83
  ( nextValue: Colord ) => {
74
- onChange( nextValue.toHex() );
84
+ debouncedSetColor( nextValue.toHex() );
75
85
  },
76
- [ onChange ]
86
+ [ debouncedSetColor ]
77
87
  );
78
88
 
79
89
  const [ showInputs, setShowInputs ] = useState< boolean >( false );
@@ -41,6 +41,12 @@ function moveReactColorfulSlider( sliderElement, from, to ) {
41
41
  fireEvent( sliderElement, new FakeMouseEvent( 'mousemove', to ) );
42
42
  }
43
43
 
44
+ const sleep = ( ms ) => {
45
+ const promise = new Promise( ( resolve ) => setTimeout( resolve, ms ) );
46
+ jest.advanceTimersByTime( ms + 1 );
47
+ return promise;
48
+ };
49
+
44
50
  const hslaMatcher = expect.objectContaining( {
45
51
  h: expect.any( Number ),
46
52
  s: expect.any( Number ),
@@ -87,6 +93,9 @@ describe( 'ColorPicker', () => {
87
93
  { pageX: 10, pageY: 10 }
88
94
  );
89
95
 
96
+ // `onChange` is debounced so we need to sleep for at least 1ms before checking that onChange was called
97
+ await sleep( 1 );
98
+
90
99
  expect( onChangeComplete ).toHaveBeenCalledWith(
91
100
  legacyColorMatcher
92
101
  );
@@ -108,6 +117,9 @@ describe( 'ColorPicker', () => {
108
117
  { pageX: 10, pageY: 10 }
109
118
  );
110
119
 
120
+ // `onChange` is debounced so we need to sleep for at least 1ms before checking that onChange was called
121
+ await sleep( 1 );
122
+
111
123
  expect( onChange ).toHaveBeenCalledWith(
112
124
  expect.stringMatching( /^#([a-fA-F0-9]{8})$/ )
113
125
  );
@@ -138,6 +150,9 @@ describe( 'ColorPicker', () => {
138
150
  { pageX: 10, pageY: 10 }
139
151
  );
140
152
 
153
+ // `onChange` is debounced so we need to sleep for at least 1ms before checking that onChange was called
154
+ await sleep( 1 );
155
+
141
156
  expect( onChange ).toHaveBeenCalledWith(
142
157
  expect.stringMatching( /^#([a-fA-F0-9]{6})$/ )
143
158
  );
@@ -47,13 +47,13 @@ describe( 'TimePicker', () => {
47
47
  fireEvent.change( hoursInput, { target: { value: '12' } } );
48
48
  fireEvent.blur( hoursInput );
49
49
 
50
- expect( onChangeSpy ).toHaveBeenCalledWith( '2018-12-22T12:00:00' );
50
+ expect( onChangeSpy ).toHaveBeenCalledWith( '2018-12-22T00:00:00' );
51
51
  onChangeSpy.mockClear();
52
52
 
53
53
  fireEvent.change( minutesInput, { target: { value: '35' } } );
54
54
  fireEvent.blur( minutesInput );
55
55
 
56
- expect( onChangeSpy ).toHaveBeenCalledWith( '2018-12-22T12:35:00' );
56
+ expect( onChangeSpy ).toHaveBeenCalledWith( '2018-12-22T00:35:00' );
57
57
  onChangeSpy.mockClear();
58
58
  } );
59
59
 
@@ -169,6 +169,36 @@ describe( 'TimePicker', () => {
169
169
  expect( onChangeSpy ).toHaveBeenCalledWith( '1986-10-18T11:00:00' );
170
170
  } );
171
171
 
172
+ it( 'should allow to set the time correctly when the PM period is selected', () => {
173
+ const onChangeSpy = jest.fn();
174
+
175
+ render(
176
+ <TimePicker
177
+ currentTime="1986-10-18T11:00:00"
178
+ onChange={ onChangeSpy }
179
+ is12Hour
180
+ />
181
+ );
182
+
183
+ const pmButton = screen.getByText( 'PM' );
184
+ fireEvent.click( pmButton );
185
+
186
+ const hoursInput = screen.getByLabelText( 'Hours' );
187
+ fireEvent.change( hoursInput, { target: { value: '6' } } );
188
+ fireEvent.blur( hoursInput );
189
+
190
+ // When clicking on 'PM', we expect the time to be 11pm
191
+ expect( onChangeSpy ).toHaveBeenNthCalledWith(
192
+ 1,
193
+ '1986-10-18T23:00:00'
194
+ );
195
+ // When changing the hours to '6', we expect the time to be 6pm
196
+ expect( onChangeSpy ).toHaveBeenNthCalledWith(
197
+ 2,
198
+ '1986-10-18T18:00:00'
199
+ );
200
+ } );
201
+
172
202
  it( 'should truncate at the minutes on change', () => {
173
203
  const onChangeSpy = jest.fn();
174
204
 
@@ -28,6 +28,10 @@ import TimeZone from './timezone';
28
28
  */
29
29
  const TIMEZONELESS_FORMAT = 'YYYY-MM-DDTHH:mm:ss';
30
30
 
31
+ function from12hTo24h( hours, isPm ) {
32
+ return isPm ? ( ( hours % 12 ) + 12 ) % 24 : hours % 12;
33
+ }
34
+
31
35
  /**
32
36
  * <UpdateOnBlurAsIntegerField>
33
37
  * A shared component to parse, validate, and handle remounting of the underlying form field element like <input> and <select>.
@@ -117,8 +121,16 @@ export function TimePicker( { is12Hour, currentTime, onChange } ) {
117
121
  }
118
122
 
119
123
  function update( name, value ) {
124
+ // If the 12-hour format is being used and the 'PM' period is selected, then
125
+ // the incoming value (which ranges 1-12) should be increased by 12 to match
126
+ // the expected 24-hour format.
127
+ let adjustedValue = value;
128
+ if ( name === 'hours' && is12Hour ) {
129
+ adjustedValue = from12hTo24h( value, am === 'PM' );
130
+ }
131
+
120
132
  // Clone the date and call the specific setter function according to `name`.
121
- const newDate = date.clone()[ name ]( value );
133
+ const newDate = date.clone()[ name ]( adjustedValue );
122
134
  changeDate( newDate );
123
135
  }
124
136
 
@@ -132,11 +144,7 @@ export function TimePicker( { is12Hour, currentTime, onChange } ) {
132
144
 
133
145
  const newDate = date
134
146
  .clone()
135
- .hours(
136
- value === 'PM'
137
- ? ( ( parsedHours % 12 ) + 12 ) % 24
138
- : parsedHours % 12
139
- );
147
+ .hours( from12hTo24h( parsedHours, value === 'PM' ) );
140
148
 
141
149
  changeDate( newDate );
142
150
  };
@@ -19,6 +19,7 @@ import CustomDuotoneBar from './custom-duotone-bar';
19
19
  import { getDefaultColors, getGradientFromCSSColors } from './utils';
20
20
 
21
21
  function DuotonePicker( {
22
+ clearable = true,
22
23
  colorPalette,
23
24
  duotonePalette,
24
25
  disableCustomColors,
@@ -69,11 +70,13 @@ function DuotonePicker( {
69
70
  );
70
71
  } ) }
71
72
  actions={
72
- <CircularOptionPicker.ButtonAction
73
- onClick={ () => onChange( undefined ) }
74
- >
75
- { __( 'Clear' ) }
76
- </CircularOptionPicker.ButtonAction>
73
+ !! clearable && (
74
+ <CircularOptionPicker.ButtonAction
75
+ onClick={ () => onChange( undefined ) }
76
+ >
77
+ { __( 'Clear' ) }
78
+ </CircularOptionPicker.ButtonAction>
79
+ )
77
80
  }
78
81
  >
79
82
  { ! disableCustomColors && ! disableCustomDuotone && (
@@ -186,6 +186,7 @@ function FontSizePicker(
186
186
  value={ option.value }
187
187
  label={ option.label }
188
188
  aria-label={ option.name }
189
+ showTooltip={ true }
189
190
  />
190
191
  ) ) }
191
192
  </ToggleGroupControl>
@@ -110,9 +110,11 @@ export default function GradientPicker( {
110
110
  const clearGradient = useCallback( () => onChange( undefined ), [
111
111
  onChange,
112
112
  ] );
113
- const Component = __experimentalHasMultipleOrigins
114
- ? MultipleOrigin
115
- : SingleOrigin;
113
+ const Component =
114
+ __experimentalHasMultipleOrigins && gradients?.length
115
+ ? MultipleOrigin
116
+ : SingleOrigin;
117
+
116
118
  return (
117
119
  <Component
118
120
  className={ className }
@@ -122,7 +124,8 @@ export default function GradientPicker( {
122
124
  onChange={ onChange }
123
125
  value={ value }
124
126
  actions={
125
- clearable && (
127
+ clearable &&
128
+ ( gradients?.length || ! disableCustomGradients ) && (
126
129
  <CircularOptionPicker.ButtonAction
127
130
  onClick={ clearGradient }
128
131
  >