@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.
- package/CHANGELOG.md +17 -0
- package/build/card/styles.js +21 -17
- package/build/card/styles.js.map +1 -1
- package/build/circular-option-picker/index.js +2 -2
- package/build/circular-option-picker/index.js.map +1 -1
- package/build/color-palette/index.js +7 -1
- package/build/color-palette/index.js.map +1 -1
- package/build/color-picker/component.js +15 -5
- package/build/color-picker/component.js.map +1 -1
- package/build/date-time/time.js +17 -3
- package/build/date-time/time.js.map +1 -1
- package/build/duotone-picker/duotone-picker.js +2 -1
- package/build/duotone-picker/duotone-picker.js.map +1 -1
- package/build/font-size-picker/index.js +2 -1
- package/build/font-size-picker/index.js.map +1 -1
- package/build/gradient-picker/index.js +2 -2
- package/build/gradient-picker/index.js.map +1 -1
- package/build/index.js +7 -7
- package/build/index.js.map +1 -1
- package/build/mobile/global-styles-context/utils.native.js +2 -2
- package/build/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build/navigation/item/index.js +9 -4
- package/build/navigation/item/index.js.map +1 -1
- package/build/navigation/styles/navigation-styles.js +37 -30
- package/build/navigation/styles/navigation-styles.js.map +1 -1
- package/build/palette-edit/index.js +307 -0
- package/build/palette-edit/index.js.map +1 -0
- package/build/palette-edit/styles.js +112 -0
- package/build/palette-edit/styles.js.map +1 -0
- package/build/popover/index.js +1 -1
- package/build/popover/index.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control-option/component.js +30 -4
- package/build/toggle-group-control/toggle-group-control-option/component.js.map +1 -1
- package/build/tooltip/index.js +4 -4
- package/build/tooltip/index.js.map +1 -1
- package/build-module/card/styles.js +21 -17
- package/build-module/card/styles.js.map +1 -1
- package/build-module/circular-option-picker/index.js +2 -2
- package/build-module/circular-option-picker/index.js.map +1 -1
- package/build-module/color-palette/index.js +6 -1
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/color-picker/component.js +13 -5
- package/build-module/color-picker/component.js.map +1 -1
- package/build-module/date-time/time.js +17 -3
- package/build-module/date-time/time.js.map +1 -1
- package/build-module/duotone-picker/duotone-picker.js +2 -1
- package/build-module/duotone-picker/duotone-picker.js.map +1 -1
- package/build-module/font-size-picker/index.js +2 -1
- package/build-module/font-size-picker/index.js.map +1 -1
- package/build-module/gradient-picker/index.js +2 -2
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js +2 -2
- package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build-module/navigation/item/index.js +10 -5
- package/build-module/navigation/item/index.js.map +1 -1
- package/build-module/navigation/styles/navigation-styles.js +34 -28
- package/build-module/navigation/styles/navigation-styles.js.map +1 -1
- package/build-module/palette-edit/index.js +280 -0
- package/build-module/palette-edit/index.js.map +1 -0
- package/build-module/palette-edit/styles.js +90 -0
- package/build-module/palette-edit/styles.js.map +1 -0
- package/build-module/popover/index.js +1 -1
- package/build-module/popover/index.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option/component.js +26 -5
- package/build-module/toggle-group-control/toggle-group-control-option/component.js.map +1 -1
- package/build-module/tooltip/index.js +4 -4
- package/build-module/tooltip/index.js.map +1 -1
- package/build-style/style-rtl.css +33 -1
- package/build-style/style.css +33 -1
- package/build-types/card/card/hook.d.ts +1 -1
- package/build-types/card/card-header/component.d.ts +1 -1
- package/build-types/card/styles.d.ts +7 -4
- package/build-types/card/styles.d.ts.map +1 -1
- package/build-types/card/types.d.ts +2 -1
- package/build-types/card/types.d.ts.map +1 -1
- package/build-types/confirm-dialog/component.d.ts +34 -0
- package/build-types/confirm-dialog/component.d.ts.map +1 -0
- package/build-types/confirm-dialog/index.d.ts +6 -0
- package/build-types/confirm-dialog/index.d.ts.map +1 -0
- package/build-types/confirm-dialog/types.d.ts +20 -0
- package/build-types/confirm-dialog/types.d.ts.map +1 -0
- package/build-types/flyout/styles.d.ts +1 -1
- package/build-types/higher-order/with-focus-outside/index.d.ts +3 -0
- package/build-types/higher-order/with-focus-outside/index.d.ts.map +1 -0
- package/build-types/modal/aria-helper.d.ts +27 -0
- package/build-types/modal/aria-helper.d.ts.map +1 -0
- package/build-types/modal/index.d.ts +3 -0
- package/build-types/modal/index.d.ts.map +1 -0
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/style-provider/index.d.ts +5 -0
- package/build-types/style-provider/index.d.ts.map +1 -0
- package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts.map +1 -1
- package/build-types/toggle-group-control/types.d.ts +23 -0
- package/build-types/toggle-group-control/types.d.ts.map +1 -1
- package/build-types/tooltip/index.d.ts +1 -7
- package/build-types/tooltip/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/card/styles.js +8 -3
- package/src/card/test/__snapshots__/index.js.snap +6 -1
- package/src/card/test/index.js +20 -0
- package/src/card/types.ts +2 -1
- package/src/circular-option-picker/index.js +7 -5
- package/src/circular-option-picker/style.scss +1 -0
- package/src/color-palette/index.js +8 -0
- package/src/color-palette/style.scss +21 -0
- package/src/color-palette/test/__snapshots__/index.js.snap +2 -0
- package/src/color-picker/README.md +13 -11
- package/src/color-picker/component.tsx +15 -5
- package/src/color-picker/test/index.js +15 -0
- package/src/date-time/test/time.js +32 -2
- package/src/date-time/time.js +14 -6
- package/src/duotone-picker/duotone-picker.js +8 -5
- package/src/font-size-picker/index.js +1 -0
- package/src/gradient-picker/index.js +7 -4
- package/src/gradient-picker/stories/index.js +23 -0
- package/src/index.js +1 -1
- package/src/mobile/global-styles-context/utils.native.js +2 -2
- package/src/navigation/item/index.js +20 -5
- package/src/navigation/stories/more-examples.js +2 -1
- package/src/navigation/styles/navigation-styles.js +5 -0
- package/src/palette-edit/index.js +398 -0
- package/src/palette-edit/style.scss +19 -0
- package/src/{color-edit → palette-edit}/styles.js +15 -18
- package/src/popover/index.js +5 -1
- package/src/style.scss +1 -1
- package/src/toggle-group-control/stories/index.js +15 -0
- package/src/toggle-group-control/test/index.js +57 -0
- package/src/toggle-group-control/toggle-group-control-option/README.md +8 -1
- package/src/toggle-group-control/toggle-group-control-option/component.tsx +40 -17
- package/src/toggle-group-control/types.ts +24 -0
- package/src/tooltip/index.js +2 -7
- package/tsconfig.tsbuildinfo +1 -1
- package/build/color-edit/index.js +0 -251
- package/build/color-edit/index.js.map +0 -1
- package/build/color-edit/styles.js +0 -112
- package/build/color-edit/styles.js.map +0 -1
- package/build-module/color-edit/index.js +0 -227
- package/build-module/color-edit/index.js.map +0 -1
- package/build-module/color-edit/styles.js +0 -90
- package/build-module/color-edit/styles.js.map +0 -1
- package/src/color-edit/index.js +0 -300
- 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 @@
|
|
|
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 @@
|
|
|
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":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/popover/index.js"],"names":[],"mappings":";AA2jBA;;;;;;;;;;;;;;;;;;;;;;;;;0DAA+C"}
|
|
@@ -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":"
|
|
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;
|
|
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(
|
|
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
|
|
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.
|
|
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": "
|
|
77
|
+
"gitHead": "34b76b2f9397215e5afb8443f5b3073c83913102"
|
|
78
78
|
}
|
package/src/card/styles.js
CHANGED
|
@@ -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:
|
|
102
|
-
|
|
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-
|
|
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;
|
package/src/card/test/index.js
CHANGED
|
@@ -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=
|
|
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
|
|
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
|
) : (
|
|
@@ -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
|
-
|
|
29
|
+
- Required: No
|
|
32
30
|
|
|
33
|
-
|
|
31
|
+
### `onChange`: `(hex8Color: string) => void`
|
|
34
32
|
|
|
35
33
|
Fired when the color changes. Always passes a hex8 color string.
|
|
36
34
|
|
|
37
|
-
|
|
35
|
+
- Required: No
|
|
38
36
|
|
|
39
|
-
|
|
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
|
-
|
|
41
|
+
- Required: No
|
|
42
|
+
- Default: `false`
|
|
44
43
|
|
|
45
|
-
|
|
44
|
+
### `defaultValue`: `string | undefined`
|
|
46
45
|
|
|
47
46
|
An optional default value to use for the color picker.
|
|
48
47
|
|
|
49
|
-
|
|
48
|
+
- Required: No
|
|
49
|
+
- Default: `'#fff'`
|
|
50
50
|
|
|
51
|
-
|
|
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
|
|
70
|
-
}, [ color
|
|
77
|
+
return colord( color );
|
|
78
|
+
}, [ color ] );
|
|
79
|
+
|
|
80
|
+
const debouncedSetColor = useDebounce( setColor );
|
|
71
81
|
|
|
72
82
|
const handleChange = useCallback(
|
|
73
83
|
( nextValue: Colord ) => {
|
|
74
|
-
|
|
84
|
+
debouncedSetColor( nextValue.toHex() );
|
|
75
85
|
},
|
|
76
|
-
[
|
|
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-
|
|
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-
|
|
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
|
|
package/src/date-time/time.js
CHANGED
|
@@ -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 ](
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
!! clearable && (
|
|
74
|
+
<CircularOptionPicker.ButtonAction
|
|
75
|
+
onClick={ () => onChange( undefined ) }
|
|
76
|
+
>
|
|
77
|
+
{ __( 'Clear' ) }
|
|
78
|
+
</CircularOptionPicker.ButtonAction>
|
|
79
|
+
)
|
|
77
80
|
}
|
|
78
81
|
>
|
|
79
82
|
{ ! disableCustomColors && ! disableCustomDuotone && (
|
|
@@ -110,9 +110,11 @@ export default function GradientPicker( {
|
|
|
110
110
|
const clearGradient = useCallback( () => onChange( undefined ), [
|
|
111
111
|
onChange,
|
|
112
112
|
] );
|
|
113
|
-
const Component =
|
|
114
|
-
|
|
115
|
-
|
|
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
|
>
|