@wordpress/components 21.1.2-next.4d3b314fd5.0 → 21.2.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.
- package/CHANGELOG.md +14 -1
- package/build/border-box-control/utils.js +42 -2
- package/build/border-box-control/utils.js.map +1 -1
- package/build/combobox-control/index.js +0 -1
- package/build/combobox-control/index.js.map +1 -1
- package/build/custom-select-control/index.js +4 -2
- package/build/custom-select-control/index.js.map +1 -1
- package/build/font-size-picker/index.js +46 -55
- package/build/font-size-picker/index.js.map +1 -1
- package/build/font-size-picker/styles.js +73 -0
- package/build/font-size-picker/styles.js.map +1 -0
- package/build/font-size-picker/types.js +6 -0
- package/build/font-size-picker/types.js.map +1 -0
- package/build/font-size-picker/utils.js +17 -15
- package/build/font-size-picker/utils.js.map +1 -1
- package/build/form-token-field/token-input.js +20 -1
- package/build/form-token-field/token-input.js.map +1 -1
- package/build/index.js +6 -0
- package/build/index.js.map +1 -1
- package/build/navigator/navigator-screen/component.js +8 -1
- package/build/navigator/navigator-screen/component.js.map +1 -1
- package/build/resizable-box/resize-tooltip/utils.js +12 -14
- package/build/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build/sandbox/index.js +13 -8
- package/build/sandbox/index.js.map +1 -1
- package/build/sandbox/index.native.js +3 -1
- package/build/sandbox/index.native.js.map +1 -1
- package/build/search-control/index.native.js +6 -2
- package/build/search-control/index.native.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/slot-fill-context.js +8 -2
- package/build/slot-fill/bubbles-virtually/slot-fill-context.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +31 -41
- package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/use-slot-fills.js +39 -0
- package/build/slot-fill/bubbles-virtually/use-slot-fills.js.map +1 -0
- package/build/slot-fill/bubbles-virtually/use-slot.js +13 -4
- package/build/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
- package/build/slot-fill/index.js +8 -0
- package/build/slot-fill/index.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control-option-base/styles.js +8 -8
- package/build/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
- package/build-module/border-box-control/utils.js +36 -1
- package/build-module/border-box-control/utils.js.map +1 -1
- package/build-module/combobox-control/index.js +0 -1
- package/build-module/combobox-control/index.js.map +1 -1
- package/build-module/custom-select-control/index.js +2 -1
- package/build-module/custom-select-control/index.js.map +1 -1
- package/build-module/font-size-picker/index.js +45 -53
- package/build-module/font-size-picker/index.js.map +1 -1
- package/build-module/font-size-picker/styles.js +62 -0
- package/build-module/font-size-picker/styles.js.map +1 -0
- package/build-module/font-size-picker/types.js +2 -0
- package/build-module/font-size-picker/types.js.map +1 -0
- package/build-module/font-size-picker/utils.js +21 -15
- package/build-module/font-size-picker/utils.js.map +1 -1
- package/build-module/form-token-field/token-input.js +21 -2
- package/build-module/form-token-field/token-input.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/navigator/navigator-screen/component.js +8 -1
- package/build-module/navigator/navigator-screen/component.js.map +1 -1
- package/build-module/resizable-box/resize-tooltip/utils.js +13 -15
- package/build-module/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build-module/sandbox/index.js +13 -8
- package/build-module/sandbox/index.js.map +1 -1
- package/build-module/sandbox/index.native.js +3 -1
- package/build-module/sandbox/index.native.js.map +1 -1
- package/build-module/search-control/index.native.js +6 -2
- package/build-module/search-control/index.native.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/slot-fill-context.js +7 -2
- package/build-module/slot-fill/bubbles-virtually/slot-fill-context.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +30 -42
- package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/use-slot-fills.js +27 -0
- package/build-module/slot-fill/bubbles-virtually/use-slot-fills.js.map +1 -0
- package/build-module/slot-fill/bubbles-virtually/use-slot.js +13 -5
- package/build-module/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
- package/build-module/slot-fill/index.js +1 -0
- package/build-module/slot-fill/index.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js +7 -7
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
- package/build-style/style-rtl.css +1 -98
- package/build-style/style.css +1 -98
- package/build-types/border-box-control/utils.d.ts +1 -3
- package/build-types/border-box-control/utils.d.ts.map +1 -1
- package/build-types/custom-select-control/index.d.ts +13 -0
- package/build-types/custom-select-control/index.d.ts.map +1 -0
- package/build-types/custom-select-control/styles.d.ts +9 -0
- package/build-types/custom-select-control/styles.d.ts.map +1 -0
- package/build-types/font-size-picker/index.d.ts +5 -0
- package/build-types/font-size-picker/index.d.ts.map +1 -0
- package/build-types/font-size-picker/stories/e2e/index.d.ts +16 -0
- package/build-types/font-size-picker/stories/e2e/index.d.ts.map +1 -0
- package/build-types/font-size-picker/stories/index.d.ts +31 -0
- package/build-types/font-size-picker/stories/index.d.ts.map +1 -0
- package/build-types/font-size-picker/styles.d.ts +27 -0
- package/build-types/font-size-picker/styles.d.ts.map +1 -0
- package/build-types/font-size-picker/test/index.d.ts +2 -0
- package/build-types/font-size-picker/test/index.d.ts.map +1 -0
- package/build-types/font-size-picker/test/utils.d.ts +2 -0
- package/build-types/font-size-picker/test/utils.d.ts.map +1 -0
- package/build-types/font-size-picker/types.d.ts +93 -0
- package/build-types/font-size-picker/types.d.ts.map +1 -0
- package/build-types/font-size-picker/utils.d.ts +41 -0
- package/build-types/font-size-picker/utils.d.ts.map +1 -0
- package/build-types/form-token-field/token-input.d.ts.map +1 -1
- package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/slot-fill-context.d.ts +2 -2
- package/build-types/slot-fill/bubbles-virtually/slot-fill-context.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/slot-fill-provider.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/use-slot-fills.d.ts +2 -0
- package/build-types/slot-fill/bubbles-virtually/use-slot-fills.d.ts.map +1 -0
- package/build-types/slot-fill/bubbles-virtually/use-slot.d.ts.map +1 -1
- package/build-types/slot-fill/index.d.ts +1 -0
- package/build-types/slot-fill/index.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts.map +1 -1
- package/package.json +19 -18
- package/src/alignment-matrix-control/test/index.js +17 -62
- package/src/border-box-control/test/utils.js +48 -0
- package/src/border-box-control/utils.ts +44 -1
- package/src/combobox-control/index.js +0 -5
- package/src/custom-select-control/index.js +2 -1
- package/src/font-size-picker/{index.js → index.tsx} +113 -79
- package/src/font-size-picker/stories/e2e/{index.js → index.tsx} +13 -4
- package/src/font-size-picker/stories/{index.js → index.tsx} +42 -36
- package/src/font-size-picker/styles.ts +44 -0
- package/src/font-size-picker/test/{index.js → index.tsx} +1 -1
- package/src/font-size-picker/test/{utils.js → utils.ts} +6 -2
- package/src/font-size-picker/types.ts +98 -0
- package/src/font-size-picker/{utils.js → utils.ts} +51 -27
- package/src/form-token-field/test/index.tsx +22 -1
- package/src/form-token-field/token-input.tsx +25 -3
- package/src/index.js +1 -0
- package/src/navigator/navigator-screen/component.tsx +8 -1
- package/src/navigator/test/index.js +119 -54
- package/src/placeholder/style.scss +2 -2
- package/src/resizable-box/resize-tooltip/utils.ts +13 -13
- package/src/sandbox/index.js +13 -7
- package/src/sandbox/index.native.js +3 -0
- package/src/search-control/index.native.js +6 -0
- package/src/slot-fill/bubbles-virtually/slot-fill-context.js +6 -2
- package/src/slot-fill/bubbles-virtually/slot-fill-provider.js +51 -58
- package/src/slot-fill/bubbles-virtually/use-slot-fills.js +24 -0
- package/src/slot-fill/bubbles-virtually/use-slot.js +11 -6
- package/src/slot-fill/index.js +1 -0
- package/src/style.scss +0 -1
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +1 -0
- package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +9 -7
- package/tsconfig.json +0 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/src/font-size-picker/style.scss +0 -78
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
5
|
+
export declare type FontSizePickerProps = {
|
|
6
|
+
/**
|
|
7
|
+
* If `true`, it will not be possible to choose a custom fontSize. The user
|
|
8
|
+
* will be forced to pick one of the pre-defined sizes passed in fontSizes.
|
|
9
|
+
*
|
|
10
|
+
* @default false
|
|
11
|
+
*/
|
|
12
|
+
disableCustomFontSizes?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* If no value exists, this prop defines the starting position for the font
|
|
15
|
+
* size picker slider. Only relevant if `withSlider` is `true`.
|
|
16
|
+
*/
|
|
17
|
+
fallbackFontSize?: number;
|
|
18
|
+
/**
|
|
19
|
+
* An array of font size objects. The object should contain properties size,
|
|
20
|
+
* name, and slug.
|
|
21
|
+
*/
|
|
22
|
+
fontSizes?: FontSize[];
|
|
23
|
+
/**
|
|
24
|
+
* A function that receives the new font size value.
|
|
25
|
+
* If onChange is called without any parameter, it should reset the value,
|
|
26
|
+
* attending to what reset means in that context, e.g., set the font size to
|
|
27
|
+
* undefined or set the font size a starting value.
|
|
28
|
+
*/
|
|
29
|
+
onChange?: (value: number | string | undefined) => void;
|
|
30
|
+
/**
|
|
31
|
+
* The current font size value.
|
|
32
|
+
*/
|
|
33
|
+
value?: number | string;
|
|
34
|
+
/**
|
|
35
|
+
* If `true`, the UI will contain a slider, instead of a numeric text input
|
|
36
|
+
* field. If `false`, no slider will be present.
|
|
37
|
+
*
|
|
38
|
+
* @default false
|
|
39
|
+
*/
|
|
40
|
+
withSlider?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* If `true`, a reset button will be displayed alongside the input field
|
|
43
|
+
* when a custom font size is active. Has no effect when
|
|
44
|
+
* `disableCustomFontSizes` or `withSlider` is `true`.
|
|
45
|
+
*
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
withReset?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Start opting into the new margin-free styles that will become the default
|
|
51
|
+
* in a future version, currently scheduled to be WordPress 6.4. (The prop
|
|
52
|
+
* can be safely removed once this happens.)
|
|
53
|
+
*
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
__nextHasNoMarginBottom?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Size of the control.
|
|
59
|
+
*
|
|
60
|
+
* @default default
|
|
61
|
+
*/
|
|
62
|
+
size?: 'default' | '__unstable-large';
|
|
63
|
+
};
|
|
64
|
+
export declare type FontSize = {
|
|
65
|
+
/**
|
|
66
|
+
* The property `size` contains a number with the font size value, in `px` or
|
|
67
|
+
* a string specifying the font size CSS property that should be used eg:
|
|
68
|
+
* "13px", "1em", or "clamp(12px, 5vw, 100px)".
|
|
69
|
+
*/
|
|
70
|
+
size: number | string;
|
|
71
|
+
/**
|
|
72
|
+
* The `name` property includes a label for that font size e.g.: `Small`.
|
|
73
|
+
*/
|
|
74
|
+
name?: string;
|
|
75
|
+
/**
|
|
76
|
+
* The `slug` property is a string with a unique identifier for the font
|
|
77
|
+
* size. Used for the class generation process.
|
|
78
|
+
*/
|
|
79
|
+
slug: string;
|
|
80
|
+
};
|
|
81
|
+
export declare type FontSizeOption = Omit<FontSize, 'size'> & Partial<Pick<FontSize, 'size'>>;
|
|
82
|
+
export declare type FontSizeSelectOption = Pick<FontSizeOption, 'size'> & {
|
|
83
|
+
key: string;
|
|
84
|
+
name?: string;
|
|
85
|
+
__experimentalHint: ReactNode;
|
|
86
|
+
};
|
|
87
|
+
export declare type FontSizeToggleGroupOption = {
|
|
88
|
+
key: string;
|
|
89
|
+
value: number | string;
|
|
90
|
+
label: string;
|
|
91
|
+
name: string;
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/font-size-picker/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,oBAAY,mBAAmB,GAAG;IACjC;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,KAAM,IAAI,CAAC;IAC1D;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;;OAMG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC;;;;OAIG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,kBAAkB,CAAC;CACtC,CAAC;AAEF,oBAAY,QAAQ,GAAG;IACtB;;;;OAIG;IACH,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,oBAAY,cAAc,GAAG,IAAI,CAAE,QAAQ,EAAE,MAAM,CAAE,GACpD,OAAO,CAAE,IAAI,CAAE,QAAQ,EAAE,MAAM,CAAE,CAAE,CAAC;AAErC,oBAAY,oBAAoB,GAAG,IAAI,CAAE,cAAc,EAAE,MAAM,CAAE,GAAG;IACnE,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB,EAAE,SAAS,CAAC;CAC9B,CAAC;AAEF,oBAAY,yBAAyB,GAAG;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACb,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { FontSize, FontSizeOption, FontSizeSelectOption, FontSizeToggleGroupOption, FontSizePickerProps } from './types';
|
|
5
|
+
export declare const CUSTOM_FONT_SIZE = "custom";
|
|
6
|
+
/**
|
|
7
|
+
* Helper util to split a font size to its numeric value
|
|
8
|
+
* and its `unit`, if exists.
|
|
9
|
+
*
|
|
10
|
+
* @param size Font size.
|
|
11
|
+
* @return An array with the numeric value and the unit if exists.
|
|
12
|
+
*/
|
|
13
|
+
export declare function splitValueAndUnitFromSize(size: NonNullable<FontSizePickerProps['value']>): string[];
|
|
14
|
+
/**
|
|
15
|
+
* Some themes use css vars for their font sizes, so until we
|
|
16
|
+
* have the way of calculating them don't display them.
|
|
17
|
+
*
|
|
18
|
+
* @param value The value that is checked.
|
|
19
|
+
* @return Whether the value is a simple css value.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isSimpleCssValue(value: NonNullable<FontSizePickerProps['value']>): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Return font size options in the proper format depending
|
|
24
|
+
* on the currently used control (select, toggle group).
|
|
25
|
+
*
|
|
26
|
+
* @param useSelectControl Whether to use a select control.
|
|
27
|
+
* @param optionsArray Array of available font sizes objects.
|
|
28
|
+
* @param disableCustomFontSizes Flag that indicates if custom font sizes are disabled.
|
|
29
|
+
* @return Array of font sizes in proper format for the used control.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getFontSizeOptions(useSelectControl: boolean, optionsArray: FontSize[], disableCustomFontSizes: boolean): FontSizeSelectOption[] | FontSizeToggleGroupOption[] | null;
|
|
32
|
+
/**
|
|
33
|
+
* Build options for the toggle group options.
|
|
34
|
+
*
|
|
35
|
+
* @param optionsArray An array of font size options.
|
|
36
|
+
* @param labelAliases An array of alternative labels.
|
|
37
|
+
* @return Remapped optionsArray.
|
|
38
|
+
*/
|
|
39
|
+
export declare function getToggleGroupOptions(optionsArray: FontSize[], labelAliases?: string[]): FontSizeToggleGroupOption[];
|
|
40
|
+
export declare function getSelectedOption(fontSizes: FontSize[], value: FontSizePickerProps['value']): FontSizeOption;
|
|
41
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/font-size-picker/utils.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EACX,QAAQ,EACR,cAAc,EACd,oBAAoB,EACpB,yBAAyB,EACzB,mBAAmB,EACnB,MAAM,SAAS,CAAC;AAOjB,eAAO,MAAM,gBAAgB,WAAW,CAAC;AAwBzC;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACxC,IAAI,EAAE,WAAW,CAAE,mBAAmB,CAAE,OAAO,CAAE,CAAE,YAYnD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,WAAW,CAAE,mBAAmB,CAAE,OAAO,CAAE,CAAE,WAIpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CACjC,gBAAgB,EAAE,OAAO,EACzB,YAAY,EAAE,QAAQ,EAAE,EACxB,sBAAsB,EAAE,OAAO,GAC7B,oBAAoB,EAAE,GAAG,yBAAyB,EAAE,GAAG,IAAI,CAO7D;AAoBD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACpC,YAAY,EAAE,QAAQ,EAAE,EACxB,YAAY,GAAE,MAAM,EAAuB,GACzC,yBAAyB,EAAE,CAS7B;AAED,wBAAgB,iBAAiB,CAChC,SAAS,EAAE,QAAQ,EAAE,EACrB,KAAK,EAAE,mBAAmB,CAAE,OAAO,CAAE,GACnC,cAAc,CAQhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-input.d.ts","sourceRoot":"","sources":["../../src/form-token-field/token-input.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAe,YAAY,
|
|
1
|
+
{"version":3,"file":"token-input.d.ts","sourceRoot":"","sources":["../../src/form-token-field/token-input.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAe,YAAY,EAAqB,MAAM,OAAO,CAAC;AAO1E;;GAEG;AACH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,uBAAuB,CAAE,eAAe,EAAE,OAAO,EAAE,KAAK,CAAE,EACjE,GAAG,EAAE,YAAY,CAAE,gBAAgB,CAAE,eA0ErC;AAED,eAAO,MAAM,UAAU,uVAAsC,CAAC;AAE9D,eAAe,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/navigator/navigator-screen/component.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAU,WAAW,EAAE,MAAM,eAAe,CAAC;AAgBpD;;GAEG;AACH,OAAO,EAGN,uBAAuB,EACvB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AASrD,aAAK,KAAK,GAAG,IAAI,CAChB,uBAAuB,CAAE,oBAAoB,EAAE,KAAK,EAAE,KAAK,CAAE,EAC7D,MAAM,WAAW,CACjB,CAAC;
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/navigator/navigator-screen/component.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAU,WAAW,EAAE,MAAM,eAAe,CAAC;AAgBpD;;GAEG;AACH,OAAO,EAGN,uBAAuB,EACvB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AASrD,aAAK,KAAK,GAAG,IAAI,CAChB,uBAAuB,CAAE,oBAAoB,EAAE,KAAK,EAAE,KAAK,CAAE,EAC7D,MAAM,WAAW,CACjB,CAAC;AA6IF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,QAAA,MAAM,wBAAwB,sIAG7B,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot-fill-context.d.ts","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/slot-fill-context.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"slot-fill-context.d.ts","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/slot-fill-context.js"],"names":[],"mappings":";AAWA;;;;;;;;GAaI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot-fill-provider.d.ts","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/slot-fill-provider.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"slot-fill-provider.d.ts","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/slot-fill-provider.js"],"names":[],"mappings":"AAmGA;;gBAOC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-slot-fills.d.ts","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/use-slot-fills.js"],"names":[],"mappings":"AAgBA,qDAOC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-slot.d.ts","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/use-slot.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-slot.d.ts","sourceRoot":"","sources":["../../../src/slot-fill/bubbles-virtually/use-slot.js"],"names":[],"mappings":"AAgBA,gDA2CC"}
|
|
@@ -14,6 +14,7 @@ export function createSlotFill(name: any): {
|
|
|
14
14
|
__unstableName: any;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
|
+
export { default as useSlotFills } from "./bubbles-virtually/use-slot-fills";
|
|
17
18
|
export const Slot: import("react").ForwardRefExoticComponent<import("react").RefAttributes<any>>;
|
|
18
19
|
export { useSlot };
|
|
19
20
|
import useSlot from "./bubbles-virtually/use-slot";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/slot-fill/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/slot-fill/index.js"],"names":[],"mappings":"AAkBA,8CAUC;AAQD;;;gBAQC;AAED;;;;;;;;;;EAYC;;AA7BD,iGAKI"}
|
|
@@ -6,7 +6,6 @@ export declare const LabelView: import("@emotion/styled").StyledComponent<{
|
|
|
6
6
|
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
7
7
|
export declare const labelBlock: import("@emotion/utils").SerializedStyles;
|
|
8
8
|
export declare const buttonView: import("@emotion/utils").SerializedStyles;
|
|
9
|
-
export declare const buttonActive: import("@emotion/utils").SerializedStyles;
|
|
10
9
|
export declare const ButtonContentView: import("@emotion/styled").StyledComponent<{
|
|
11
10
|
theme?: import("@emotion/react").Theme | undefined;
|
|
12
11
|
as?: import("react").ElementType<any> | undefined;
|
|
@@ -15,4 +14,5 @@ export declare const separatorActive: import("@emotion/utils").SerializedStyles;
|
|
|
15
14
|
export declare const isIcon: ({ size, }: {
|
|
16
15
|
size: NonNullable<ToggleGroupControlProps['size']>;
|
|
17
16
|
}) => import("@emotion/utils").SerializedStyles;
|
|
17
|
+
export declare const buttonActive: import("@emotion/utils").SerializedStyles;
|
|
18
18
|
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/toggle-group-control/toggle-group-control-option-base/styles.ts"],"names":[],"mappings":";AAUA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAExD,eAAO,MAAM,SAAS;;;yGAKrB,CAAC;AAEF,eAAO,MAAM,UAAU,2CAEtB,CAAC;AAEF,eAAO,MAAM,UAAU,2CAgCtB,CAAC;AAEF,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/toggle-group-control/toggle-group-control-option-base/styles.ts"],"names":[],"mappings":";AAUA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAExD,eAAO,MAAM,SAAS;;;yGAKrB,CAAC;AAEF,eAAO,MAAM,UAAU,2CAEtB,CAAC;AAEF,eAAO,MAAM,UAAU,2CAgCtB,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;yGAG7B,CAAC;AAEF,eAAO,MAAM,eAAe,2CAE3B,CAAC;AAEF,eAAO,MAAM,MAAM;UAGZ,YAAa,uBAAuB,CAAE,MAAM,CAAE,CAAE;+CAatD,CAAC;AAEF,eAAO,MAAM,YAAY,2CAMxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/components",
|
|
3
|
-
"version": "21.
|
|
3
|
+
"version": "21.2.0",
|
|
4
4
|
"description": "UI components for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -38,21 +38,21 @@
|
|
|
38
38
|
"@emotion/utils": "^1.0.0",
|
|
39
39
|
"@floating-ui/react-dom": "^1.0.0",
|
|
40
40
|
"@use-gesture/react": "^10.2.6",
|
|
41
|
-
"@wordpress/a11y": "^3.
|
|
42
|
-
"@wordpress/compose": "^5.
|
|
43
|
-
"@wordpress/date": "^4.
|
|
44
|
-
"@wordpress/deprecated": "^3.
|
|
45
|
-
"@wordpress/dom": "^3.
|
|
46
|
-
"@wordpress/element": "^4.
|
|
47
|
-
"@wordpress/escape-html": "^2.
|
|
48
|
-
"@wordpress/hooks": "^3.
|
|
49
|
-
"@wordpress/i18n": "^4.
|
|
50
|
-
"@wordpress/icons": "^9.
|
|
51
|
-
"@wordpress/is-shallow-equal": "^4.
|
|
52
|
-
"@wordpress/keycodes": "^3.
|
|
53
|
-
"@wordpress/primitives": "^3.
|
|
54
|
-
"@wordpress/rich-text": "^5.
|
|
55
|
-
"@wordpress/warning": "^2.
|
|
41
|
+
"@wordpress/a11y": "^3.19.0",
|
|
42
|
+
"@wordpress/compose": "^5.17.0",
|
|
43
|
+
"@wordpress/date": "^4.19.0",
|
|
44
|
+
"@wordpress/deprecated": "^3.19.0",
|
|
45
|
+
"@wordpress/dom": "^3.19.0",
|
|
46
|
+
"@wordpress/element": "^4.17.0",
|
|
47
|
+
"@wordpress/escape-html": "^2.19.0",
|
|
48
|
+
"@wordpress/hooks": "^3.19.0",
|
|
49
|
+
"@wordpress/i18n": "^4.19.0",
|
|
50
|
+
"@wordpress/icons": "^9.10.0",
|
|
51
|
+
"@wordpress/is-shallow-equal": "^4.19.0",
|
|
52
|
+
"@wordpress/keycodes": "^3.19.0",
|
|
53
|
+
"@wordpress/primitives": "^3.17.0",
|
|
54
|
+
"@wordpress/rich-text": "^5.17.0",
|
|
55
|
+
"@wordpress/warning": "^2.19.0",
|
|
56
56
|
"change-case": "^4.1.2",
|
|
57
57
|
"classnames": "^2.3.1",
|
|
58
58
|
"colord": "^2.7.0",
|
|
@@ -69,7 +69,8 @@
|
|
|
69
69
|
"reakit": "^1.3.8",
|
|
70
70
|
"remove-accents": "^0.4.2",
|
|
71
71
|
"use-lilius": "^2.0.1",
|
|
72
|
-
"uuid": "^8.3.0"
|
|
72
|
+
"uuid": "^8.3.0",
|
|
73
|
+
"valtio": "^1.7.0"
|
|
73
74
|
},
|
|
74
75
|
"peerDependencies": {
|
|
75
76
|
"react": "^17.0.0",
|
|
@@ -78,5 +79,5 @@
|
|
|
78
79
|
"publishConfig": {
|
|
79
80
|
"access": "public"
|
|
80
81
|
},
|
|
81
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "8d42d2febb7d0ba8372a33e560a62f5a5f6a9112"
|
|
82
83
|
}
|
|
@@ -1,91 +1,46 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { render,
|
|
5
|
-
import { act } from 'react-dom/test-utils';
|
|
4
|
+
import { render, screen, within } from '@testing-library/react';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Internal dependencies
|
|
9
8
|
*/
|
|
10
9
|
import AlignmentMatrixControl from '../';
|
|
11
10
|
|
|
12
|
-
const __windowFocus = window.focus;
|
|
13
|
-
|
|
14
|
-
beforeAll( () => {
|
|
15
|
-
window.focus = jest.fn();
|
|
16
|
-
} );
|
|
17
|
-
|
|
18
|
-
afterAll( () => {
|
|
19
|
-
window.focus = __windowFocus;
|
|
20
|
-
} );
|
|
21
|
-
|
|
22
|
-
let container = null;
|
|
23
|
-
|
|
24
|
-
beforeEach( () => {
|
|
25
|
-
container = document.createElement( 'div' );
|
|
26
|
-
document.body.appendChild( container );
|
|
27
|
-
} );
|
|
28
|
-
|
|
29
|
-
afterEach( () => {
|
|
30
|
-
unmountComponentAtNode( container );
|
|
31
|
-
container.remove();
|
|
32
|
-
container = null;
|
|
33
|
-
} );
|
|
34
|
-
|
|
35
11
|
const getControl = () => {
|
|
36
|
-
return
|
|
12
|
+
return screen.getByRole( 'grid' );
|
|
37
13
|
};
|
|
38
14
|
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
return control.querySelectorAll( '[role="gridcell"]' );
|
|
15
|
+
const getCell = ( name ) => {
|
|
16
|
+
return within( getControl() ).getByRole( 'gridcell', { name } );
|
|
42
17
|
};
|
|
43
18
|
|
|
44
19
|
describe( 'AlignmentMatrixControl', () => {
|
|
45
20
|
describe( 'Basic rendering', () => {
|
|
46
21
|
it( 'should render', () => {
|
|
47
|
-
|
|
48
|
-
render( <AlignmentMatrixControl />, container );
|
|
49
|
-
} );
|
|
50
|
-
const control = getControl();
|
|
22
|
+
render( <AlignmentMatrixControl /> );
|
|
51
23
|
|
|
52
|
-
expect(
|
|
24
|
+
expect( getControl() ).toBeInTheDocument();
|
|
53
25
|
} );
|
|
54
26
|
} );
|
|
55
27
|
|
|
56
28
|
describe( 'Change value', () => {
|
|
57
|
-
|
|
58
|
-
|
|
29
|
+
const alignments = [ 'center left', 'center center', 'bottom center' ];
|
|
30
|
+
|
|
31
|
+
it.each( alignments )(
|
|
32
|
+
'should change value on %s cell click',
|
|
33
|
+
( alignment ) => {
|
|
34
|
+
const spy = jest.fn();
|
|
59
35
|
|
|
60
|
-
act( () => {
|
|
61
36
|
render(
|
|
62
|
-
<AlignmentMatrixControl
|
|
63
|
-
value={ 'center' }
|
|
64
|
-
onChange={ spy }
|
|
65
|
-
/>,
|
|
66
|
-
container
|
|
37
|
+
<AlignmentMatrixControl value="center" onChange={ spy } />
|
|
67
38
|
);
|
|
68
|
-
} );
|
|
69
|
-
|
|
70
|
-
const cells = getCells();
|
|
71
|
-
|
|
72
|
-
act( () => {
|
|
73
|
-
cells[ 3 ].focus();
|
|
74
|
-
} );
|
|
75
39
|
|
|
76
|
-
|
|
40
|
+
getCell( alignment ).focus();
|
|
77
41
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
expect( spy.mock.calls[ 1 ][ 0 ] ).toBe( 'center center' );
|
|
83
|
-
|
|
84
|
-
act( () => {
|
|
85
|
-
cells[ 7 ].focus();
|
|
86
|
-
} );
|
|
87
|
-
|
|
88
|
-
expect( spy.mock.calls[ 2 ][ 0 ] ).toBe( 'bottom center' );
|
|
89
|
-
} );
|
|
42
|
+
expect( spy ).toHaveBeenCalledWith( alignment );
|
|
43
|
+
}
|
|
44
|
+
);
|
|
90
45
|
} );
|
|
91
46
|
} );
|
|
@@ -244,6 +244,54 @@ describe( 'BorderBoxControl Utils', () => {
|
|
|
244
244
|
|
|
245
245
|
expect( getCommonBorder( sideBorders ) ).toEqual( commonBorder );
|
|
246
246
|
} );
|
|
247
|
+
|
|
248
|
+
it( 'should return most common unit selection if border widths are mixed', () => {
|
|
249
|
+
const sideBorders = {
|
|
250
|
+
top: { color: '#fff', style: 'solid', width: '10px' },
|
|
251
|
+
right: { color: '#000', style: 'solid', width: '1rem' },
|
|
252
|
+
bottom: { color: '#000', style: 'solid', width: '2em' },
|
|
253
|
+
left: { color: '#000', style: undefined, width: '2em' },
|
|
254
|
+
};
|
|
255
|
+
const commonBorder = {
|
|
256
|
+
color: undefined,
|
|
257
|
+
style: undefined,
|
|
258
|
+
width: 'em',
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
expect( getCommonBorder( sideBorders ) ).toEqual( commonBorder );
|
|
262
|
+
} );
|
|
263
|
+
|
|
264
|
+
it( 'should return first unit when multiple units are equal most common', () => {
|
|
265
|
+
const sideBorders = {
|
|
266
|
+
top: { color: '#fff', style: 'solid', width: '1rem' },
|
|
267
|
+
right: { color: '#000', style: 'solid', width: '0.75em' },
|
|
268
|
+
bottom: { color: '#000', style: 'solid', width: '1vw' },
|
|
269
|
+
left: { color: '#000', style: undefined, width: '2vh' },
|
|
270
|
+
};
|
|
271
|
+
const commonBorder = {
|
|
272
|
+
color: undefined,
|
|
273
|
+
style: undefined,
|
|
274
|
+
width: 'rem',
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
expect( getCommonBorder( sideBorders ) ).toEqual( commonBorder );
|
|
278
|
+
} );
|
|
279
|
+
|
|
280
|
+
it( 'should ignore undefined values in determining most common unit', () => {
|
|
281
|
+
const sideBorders = {
|
|
282
|
+
top: { color: '#fff', style: 'solid', width: undefined },
|
|
283
|
+
right: { color: '#000', style: 'solid', width: '5vw' },
|
|
284
|
+
bottom: { color: '#000', style: 'solid', width: undefined },
|
|
285
|
+
left: { color: '#000', style: undefined, width: '2vh' },
|
|
286
|
+
};
|
|
287
|
+
const commonBorder = {
|
|
288
|
+
color: undefined,
|
|
289
|
+
style: undefined,
|
|
290
|
+
width: 'vw',
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
expect( getCommonBorder( sideBorders ) ).toEqual( commonBorder );
|
|
294
|
+
} );
|
|
247
295
|
} );
|
|
248
296
|
|
|
249
297
|
describe( 'getShorthandBorderStyle', () => {
|
|
@@ -6,6 +6,7 @@ import type { CSSProperties } from 'react';
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
+
import { parseCSSUnitValue } from '../utils/unit-values';
|
|
9
10
|
import type { Border } from '../border-control/types';
|
|
10
11
|
import type { AnyBorder, Borders, BorderProp, BorderSide } from './types';
|
|
11
12
|
|
|
@@ -123,7 +124,7 @@ export const getCommonBorder = ( borders?: Borders ) => {
|
|
|
123
124
|
return {
|
|
124
125
|
color: allColorsMatch ? colors[ 0 ] : undefined,
|
|
125
126
|
style: allStylesMatch ? styles[ 0 ] : undefined,
|
|
126
|
-
width: allWidthsMatch ? widths[ 0 ] :
|
|
127
|
+
width: allWidthsMatch ? widths[ 0 ] : getMostCommonUnit( widths ),
|
|
127
128
|
};
|
|
128
129
|
};
|
|
129
130
|
|
|
@@ -152,3 +153,45 @@ export const getShorthandBorderStyle = (
|
|
|
152
153
|
|
|
153
154
|
return [ width, borderStyle, color ].filter( Boolean ).join( ' ' );
|
|
154
155
|
};
|
|
156
|
+
|
|
157
|
+
export const getMostCommonUnit = (
|
|
158
|
+
values: Array< string | number | undefined >
|
|
159
|
+
): string | undefined => {
|
|
160
|
+
// Collect all the CSS units.
|
|
161
|
+
const units = values.map( ( value ) =>
|
|
162
|
+
value === undefined ? undefined : parseCSSUnitValue( `${ value }` )[ 1 ]
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
// Return the most common unit out of only the defined CSS units.
|
|
166
|
+
const filteredUnits = units.filter( ( value ) => value !== undefined );
|
|
167
|
+
return mode( filteredUnits as string[] );
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Finds the mode value out of the array passed favouring the first value
|
|
172
|
+
* as a tiebreaker.
|
|
173
|
+
*
|
|
174
|
+
* @param values Values to determine the mode from.
|
|
175
|
+
*
|
|
176
|
+
* @return The mode value.
|
|
177
|
+
*/
|
|
178
|
+
function mode( values: Array< string > ): string | undefined {
|
|
179
|
+
if ( values.length === 0 ) {
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const map: { [ index: string ]: number } = {};
|
|
184
|
+
let maxCount = 0;
|
|
185
|
+
let currentMode;
|
|
186
|
+
|
|
187
|
+
values.forEach( ( value ) => {
|
|
188
|
+
map[ value ] = map[ value ] === undefined ? 1 : map[ value ] + 1;
|
|
189
|
+
|
|
190
|
+
if ( map[ value ] > maxCount ) {
|
|
191
|
+
currentMode = value;
|
|
192
|
+
maxCount = map[ value ];
|
|
193
|
+
}
|
|
194
|
+
} );
|
|
195
|
+
|
|
196
|
+
return currentMode;
|
|
197
|
+
}
|
|
@@ -247,11 +247,6 @@ function ComboboxControl( {
|
|
|
247
247
|
instanceId={ instanceId }
|
|
248
248
|
ref={ inputContainer }
|
|
249
249
|
value={ isExpanded ? inputValue : currentLabel }
|
|
250
|
-
aria-label={
|
|
251
|
-
currentLabel
|
|
252
|
-
? `${ currentLabel }, ${ label }`
|
|
253
|
-
: null
|
|
254
|
-
}
|
|
255
250
|
onFocus={ onFocus }
|
|
256
251
|
onBlur={ onBlur }
|
|
257
252
|
isExpanded={ isExpanded }
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
/**
|
|
2
3
|
* External dependencies
|
|
3
4
|
*/
|
|
@@ -15,7 +16,7 @@ import deprecated from '@wordpress/deprecated';
|
|
|
15
16
|
/**
|
|
16
17
|
* Internal dependencies
|
|
17
18
|
*/
|
|
18
|
-
import { VisuallyHidden } from '../';
|
|
19
|
+
import { VisuallyHidden } from '../visually-hidden';
|
|
19
20
|
import { Select as SelectControlSelect } from '../select-control/styles/select-control-styles';
|
|
20
21
|
import SelectControlChevronDown from '../select-control/chevron-down';
|
|
21
22
|
import { InputBaseWithBackCompatMinWidth } from './styles';
|