@wordpress/components 29.7.0 → 29.9.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/.stylelintrc.js +1 -1
- package/CHANGELOG.md +37 -0
- package/build/guide/index.js +4 -2
- package/build/guide/index.js.map +1 -1
- package/build/guide/types.js.map +1 -1
- package/build/item-group/styles.js +10 -10
- package/build/item-group/styles.js.map +1 -1
- package/build/popover/index.js +38 -18
- package/build/popover/index.js.map +1 -1
- package/build/popover/types.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build/unit-control/utils.js +9 -8
- package/build/unit-control/utils.js.map +1 -1
- package/build-module/guide/index.js +4 -2
- package/build-module/guide/index.js.map +1 -1
- package/build-module/guide/types.js.map +1 -1
- package/build-module/item-group/styles.js +10 -10
- package/build-module/item-group/styles.js.map +1 -1
- package/build-module/popover/index.js +37 -17
- package/build-module/popover/index.js.map +1 -1
- package/build-module/popover/types.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js +1 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build-module/unit-control/utils.js +9 -8
- package/build-module/unit-control/utils.js.map +1 -1
- package/build-style/style-rtl.css +17 -12
- package/build-style/style.css +17 -12
- package/build-types/guide/index.d.ts +1 -1
- package/build-types/guide/index.d.ts.map +1 -1
- package/build-types/guide/stories/index.story.d.ts.map +1 -1
- package/build-types/guide/types.d.ts +12 -0
- package/build-types/guide/types.d.ts.map +1 -1
- package/build-types/popover/index.d.ts +18 -2
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/popover/stories/e2e/index.story.d.ts +8 -1
- package/build-types/popover/stories/e2e/index.story.d.ts.map +1 -1
- package/build-types/popover/stories/index.story.d.ts +1 -0
- package/build-types/popover/stories/index.story.d.ts.map +1 -1
- package/build-types/popover/test/utils/index.d.ts.map +1 -1
- package/build-types/popover/types.d.ts +9 -0
- package/build-types/popover/types.d.ts.map +1 -1
- package/build-types/unit-control/utils.d.ts.map +1 -1
- package/package.json +20 -20
- package/src/button/style.scss +1 -1
- package/src/color-picker/test/index.tsx +103 -26
- package/src/combobox-control/style.scss +4 -2
- package/src/duotone-picker/style.scss +4 -0
- package/src/form-token-field/style.scss +5 -5
- package/src/guide/README.md +16 -0
- package/src/guide/index.tsx +4 -2
- package/src/guide/stories/index.story.tsx +2 -0
- package/src/guide/types.ts +12 -0
- package/src/item-group/styles.ts +1 -1
- package/src/item-group/test/__snapshots__/index.js.snap +1 -1
- package/src/popover/index.tsx +46 -21
- package/src/popover/stories/index.story.tsx +83 -2
- package/src/popover/test/utils/index.tsx +0 -1
- package/src/popover/types.ts +10 -0
- package/src/toggle-group-control/toggle-group-control/component.tsx +1 -1
- package/src/unit-control/test/utils.ts +36 -0
- package/src/unit-control/utils.ts +8 -11
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -42,6 +42,42 @@ describe( 'UnitControl utils', () => {
|
|
|
42
42
|
] );
|
|
43
43
|
} );
|
|
44
44
|
|
|
45
|
+
it( 'should not mutate default units argument definiton', () => {
|
|
46
|
+
const unitsA = useCustomUnits( {
|
|
47
|
+
availableUnits: [ 'px', 'em', 'rem' ],
|
|
48
|
+
defaultValues: { px: 8, em: 0.5, rem: 0.5 },
|
|
49
|
+
} );
|
|
50
|
+
|
|
51
|
+
const unitsB = useCustomUnits( {
|
|
52
|
+
availableUnits: [ 'px', 'em', 'rem' ],
|
|
53
|
+
defaultValues: { px: 16, em: 1, rem: 1 },
|
|
54
|
+
} );
|
|
55
|
+
|
|
56
|
+
expect( unitsA ).not.toEqual( unitsB );
|
|
57
|
+
} );
|
|
58
|
+
|
|
59
|
+
it( 'should not mutate custon units argument definitons', () => {
|
|
60
|
+
const units = [
|
|
61
|
+
{ value: 'px', label: 'pixel' },
|
|
62
|
+
{ value: 'em', label: 'em' },
|
|
63
|
+
{ value: 'rem', label: 'rem' },
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
const unitsA = useCustomUnits( {
|
|
67
|
+
availableUnits: [ 'px', 'em', 'rem' ],
|
|
68
|
+
defaultValues: { px: 8, em: 0.5, rem: 0.5 },
|
|
69
|
+
units,
|
|
70
|
+
} );
|
|
71
|
+
|
|
72
|
+
const unitsB = useCustomUnits( {
|
|
73
|
+
availableUnits: [ 'px', 'em', 'rem' ],
|
|
74
|
+
defaultValues: { px: 16, em: 1, rem: 1 },
|
|
75
|
+
units,
|
|
76
|
+
} );
|
|
77
|
+
|
|
78
|
+
expect( unitsA ).not.toEqual( unitsB );
|
|
79
|
+
} );
|
|
80
|
+
|
|
45
81
|
it( 'should add default values to available units even if the default values are strings', () => {
|
|
46
82
|
// Although the public APIs of the component expect a `number` as the type of the
|
|
47
83
|
// default values, it's still good to test for strings (as it can happen in un-typed
|
|
@@ -428,19 +428,16 @@ export const useCustomUnits = ( {
|
|
|
428
428
|
units
|
|
429
429
|
);
|
|
430
430
|
|
|
431
|
-
if ( defaultValues ) {
|
|
432
|
-
customUnitsToReturn
|
|
433
|
-
if ( defaultValues[ unit.value ] ) {
|
|
434
|
-
const [ parsedDefaultValue ] = parseQuantityAndUnitFromRawValue(
|
|
435
|
-
defaultValues[ unit.value ]
|
|
436
|
-
);
|
|
437
|
-
|
|
438
|
-
customUnitsToReturn[ i ].default = parsedDefaultValue;
|
|
439
|
-
}
|
|
440
|
-
} );
|
|
431
|
+
if ( ! defaultValues ) {
|
|
432
|
+
return customUnitsToReturn;
|
|
441
433
|
}
|
|
442
434
|
|
|
443
|
-
return customUnitsToReturn
|
|
435
|
+
return customUnitsToReturn.map( ( unit ) => {
|
|
436
|
+
const [ defaultValue ] = defaultValues[ unit.value ]
|
|
437
|
+
? parseQuantityAndUnitFromRawValue( defaultValues[ unit.value ] )
|
|
438
|
+
: [];
|
|
439
|
+
return { ...unit, default: defaultValue };
|
|
440
|
+
} );
|
|
444
441
|
};
|
|
445
442
|
|
|
446
443
|
/**
|