@wordpress/components 25.1.1 → 25.1.3
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 +6 -0
- package/build/button/index.js +13 -4
- package/build/button/index.js.map +1 -1
- package/build/confirm-dialog/component.js +9 -1
- package/build/confirm-dialog/component.js.map +1 -1
- package/build/font-size-picker/index.js +5 -3
- package/build/font-size-picker/index.js.map +1 -1
- package/build/font-size-picker/styles.js +19 -26
- package/build/font-size-picker/styles.js.map +1 -1
- package/build/item-group/styles.js +10 -10
- package/build/item-group/styles.js.map +1 -1
- package/build/number-control/index.js +8 -4
- package/build/number-control/index.js.map +1 -1
- package/build/number-control/styles/number-control-styles.js +9 -15
- package/build/number-control/styles/number-control-styles.js.map +1 -1
- package/build/select-control/index.js +2 -1
- package/build/select-control/index.js.map +1 -1
- package/build/z-stack/component.js +5 -3
- package/build/z-stack/component.js.map +1 -1
- package/build/z-stack/styles.js +23 -42
- package/build/z-stack/styles.js.map +1 -1
- package/build-module/button/index.js +13 -4
- package/build-module/button/index.js.map +1 -1
- package/build-module/confirm-dialog/component.js +10 -2
- package/build-module/confirm-dialog/component.js.map +1 -1
- package/build-module/font-size-picker/index.js +5 -4
- package/build-module/font-size-picker/index.js.map +1 -1
- package/build-module/font-size-picker/styles.js +17 -23
- package/build-module/font-size-picker/styles.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/number-control/index.js +8 -5
- package/build-module/number-control/index.js.map +1 -1
- package/build-module/number-control/styles/number-control-styles.js +7 -14
- package/build-module/number-control/styles/number-control-styles.js.map +1 -1
- package/build-module/select-control/index.js +2 -1
- package/build-module/select-control/index.js.map +1 -1
- package/build-module/z-stack/component.js +5 -3
- package/build-module/z-stack/component.js.map +1 -1
- package/build-module/z-stack/styles.js +22 -44
- package/build-module/z-stack/styles.js.map +1 -1
- package/build-style/style-rtl.css +10 -9
- package/build-style/style.css +10 -9
- package/build-types/button/deprecated.d.ts +6 -6
- package/build-types/button/index.d.ts.map +1 -1
- package/build-types/button/types.d.ts +16 -9
- package/build-types/button/types.d.ts.map +1 -1
- package/build-types/confirm-dialog/component.d.ts.map +1 -1
- package/build-types/font-size-picker/index.d.ts.map +1 -1
- package/build-types/font-size-picker/styles.d.ts +0 -6
- package/build-types/font-size-picker/styles.d.ts.map +1 -1
- package/build-types/navigator/navigator-back-button/component.d.ts +1 -1
- package/build-types/navigator/navigator-back-button/hook.d.ts +1 -1
- package/build-types/navigator/navigator-button/component.d.ts +1 -1
- package/build-types/navigator/navigator-button/hook.d.ts +1 -1
- package/build-types/navigator/navigator-to-parent-button/component.d.ts +1 -1
- package/build-types/number-control/index.d.ts.map +1 -1
- package/build-types/number-control/styles/number-control-styles.d.ts +5 -3
- package/build-types/number-control/styles/number-control-styles.d.ts.map +1 -1
- package/build-types/select-control/index.d.ts.map +1 -1
- package/build-types/select-control/types.d.ts +6 -0
- package/build-types/select-control/types.d.ts.map +1 -1
- package/build-types/toolbar/toolbar-button/index.d.ts +6 -6
- package/build-types/z-stack/component.d.ts.map +1 -1
- package/build-types/z-stack/stories/index.d.ts.map +1 -1
- package/build-types/z-stack/styles.d.ts +5 -4
- package/build-types/z-stack/styles.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/button/README.md +15 -0
- package/src/button/index.tsx +11 -4
- package/src/button/style.scss +13 -12
- package/src/button/test/index.tsx +13 -0
- package/src/button/types.ts +17 -9
- package/src/confirm-dialog/component.tsx +12 -2
- package/src/confirm-dialog/stories/index.js +8 -15
- package/src/confirm-dialog/test/index.js +42 -0
- package/src/font-size-picker/index.tsx +9 -5
- package/src/font-size-picker/styles.ts +0 -10
- package/src/item-group/styles.ts +1 -1
- package/src/modal/style.scss +3 -2
- package/src/number-control/index.tsx +6 -3
- package/src/number-control/styles/number-control-styles.ts +8 -16
- package/src/select-control/index.tsx +1 -0
- package/src/select-control/types.ts +6 -0
- package/src/z-stack/component.tsx +4 -2
- package/src/z-stack/stories/index.tsx +6 -13
- package/src/z-stack/styles.ts +23 -24
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -16,7 +16,7 @@ import deprecated from '@wordpress/deprecated';
|
|
|
16
16
|
/**
|
|
17
17
|
* Internal dependencies
|
|
18
18
|
*/
|
|
19
|
-
import { Input, SpinButton } from './styles/number-control-styles';
|
|
19
|
+
import { Input, SpinButton, styles } from './styles/number-control-styles';
|
|
20
20
|
import * as inputControlActionTypes from '../input-control/reducer/actions';
|
|
21
21
|
import { add, subtract, roundClamp } from '../utils/math';
|
|
22
22
|
import { ensureNumber, isValueEmpty } from '../utils/values';
|
|
@@ -24,6 +24,7 @@ import type { WordPressComponentProps } from '../ui/context/wordpress-component'
|
|
|
24
24
|
import type { NumberControlProps } from './types';
|
|
25
25
|
import { HStack } from '../h-stack';
|
|
26
26
|
import { Spacer } from '../spacer';
|
|
27
|
+
import { useCx } from '../utils';
|
|
27
28
|
|
|
28
29
|
const noop = () => {};
|
|
29
30
|
|
|
@@ -78,6 +79,8 @@ function UnforwardedNumberControl(
|
|
|
78
79
|
|
|
79
80
|
const autoComplete = typeProp === 'number' ? 'off' : undefined;
|
|
80
81
|
const classes = classNames( 'components-number-control', className );
|
|
82
|
+
const cx = useCx();
|
|
83
|
+
const spinButtonClasses = cx( size === 'small' && styles.smallSpinButtons );
|
|
81
84
|
|
|
82
85
|
const spinValue = (
|
|
83
86
|
value: string | number | undefined,
|
|
@@ -236,6 +239,7 @@ function UnforwardedNumberControl(
|
|
|
236
239
|
<Spacer marginBottom={ 0 } marginRight={ 2 }>
|
|
237
240
|
<HStack spacing={ 1 }>
|
|
238
241
|
<SpinButton
|
|
242
|
+
className={ spinButtonClasses }
|
|
239
243
|
icon={ plusIcon }
|
|
240
244
|
isSmall
|
|
241
245
|
aria-hidden="true"
|
|
@@ -244,9 +248,9 @@ function UnforwardedNumberControl(
|
|
|
244
248
|
onClick={ buildSpinButtonClickHandler(
|
|
245
249
|
'up'
|
|
246
250
|
) }
|
|
247
|
-
size={ size }
|
|
248
251
|
/>
|
|
249
252
|
<SpinButton
|
|
253
|
+
className={ spinButtonClasses }
|
|
250
254
|
icon={ resetIcon }
|
|
251
255
|
isSmall
|
|
252
256
|
aria-hidden="true"
|
|
@@ -255,7 +259,6 @@ function UnforwardedNumberControl(
|
|
|
255
259
|
onClick={ buildSpinButtonClickHandler(
|
|
256
260
|
'down'
|
|
257
261
|
) }
|
|
258
|
-
size={ size }
|
|
259
262
|
/>
|
|
260
263
|
</HStack>
|
|
261
264
|
</Spacer>
|
|
@@ -11,7 +11,6 @@ import InputControl from '../../input-control';
|
|
|
11
11
|
import { COLORS } from '../../utils';
|
|
12
12
|
import Button from '../../button';
|
|
13
13
|
import { space } from '../../ui/utils/space';
|
|
14
|
-
import type { NumberControlProps } from '../types';
|
|
15
14
|
|
|
16
15
|
const htmlArrowStyles = ( { hideHTMLArrows }: { hideHTMLArrows: boolean } ) => {
|
|
17
16
|
if ( ! hideHTMLArrows ) {
|
|
@@ -35,23 +34,16 @@ export const Input = styled( InputControl )`
|
|
|
35
34
|
${ htmlArrowStyles };
|
|
36
35
|
`;
|
|
37
36
|
|
|
38
|
-
const spinButtonSizeStyles = ( {
|
|
39
|
-
size,
|
|
40
|
-
}: Pick< NumberControlProps, 'size' > ) => {
|
|
41
|
-
if ( size !== 'small' ) {
|
|
42
|
-
return ``;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return css`
|
|
46
|
-
width: ${ space( 5 ) };
|
|
47
|
-
min-width: ${ space( 5 ) };
|
|
48
|
-
height: ${ space( 5 ) };
|
|
49
|
-
`;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
37
|
export const SpinButton = styled( Button )`
|
|
53
38
|
&&&&& {
|
|
54
39
|
color: ${ COLORS.ui.theme };
|
|
55
|
-
${ spinButtonSizeStyles }
|
|
56
40
|
}
|
|
57
41
|
`;
|
|
42
|
+
|
|
43
|
+
const smallSpinButtons = css`
|
|
44
|
+
width: ${ space( 5 ) };
|
|
45
|
+
min-width: ${ space( 5 ) };
|
|
46
|
+
height: ${ space( 5 ) };
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
export const styles = { smallSpinButtons };
|
|
@@ -40,6 +40,12 @@ type SelectControlBaseProps = Pick<
|
|
|
40
40
|
* @default false
|
|
41
41
|
*/
|
|
42
42
|
disabled?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Whether or not the option should be hidden.
|
|
45
|
+
*
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
hidden?: boolean;
|
|
43
49
|
}[];
|
|
44
50
|
/**
|
|
45
51
|
* As an alternative to the `options` prop, `optgroup`s and `options` can be
|
|
@@ -35,13 +35,14 @@ function UnconnectedZStack(
|
|
|
35
35
|
|
|
36
36
|
const clonedChildren = validChildren.map( ( child, index ) => {
|
|
37
37
|
const zIndex = isReversed ? childrenLastIndex - index : index;
|
|
38
|
-
|
|
38
|
+
// Only when the component is layered, the offset needs to be multiplied by
|
|
39
|
+
// the item's index, so that items can correctly stack at the right distance
|
|
40
|
+
const offsetAmount = isLayered ? offset * index : offset;
|
|
39
41
|
|
|
40
42
|
const key = isValidElement( child ) ? child.key : index;
|
|
41
43
|
|
|
42
44
|
return (
|
|
43
45
|
<ZStackChildView
|
|
44
|
-
isLayered={ isLayered }
|
|
45
46
|
offsetAmount={ offsetAmount }
|
|
46
47
|
zIndex={ zIndex }
|
|
47
48
|
key={ key }
|
|
@@ -55,6 +56,7 @@ function UnconnectedZStack(
|
|
|
55
56
|
<ZStackView
|
|
56
57
|
{ ...otherProps }
|
|
57
58
|
className={ className }
|
|
59
|
+
isLayered={ isLayered }
|
|
58
60
|
ref={ forwardedRef }
|
|
59
61
|
>
|
|
60
62
|
{ clonedChildren }
|
|
@@ -8,7 +8,6 @@ import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
10
|
import { Elevation } from '../../elevation';
|
|
11
|
-
import { HStack } from '../../h-stack';
|
|
12
11
|
import { View } from '../../view';
|
|
13
12
|
import { ZStack } from '..';
|
|
14
13
|
|
|
@@ -55,18 +54,12 @@ const Avatar = ( {
|
|
|
55
54
|
|
|
56
55
|
const Template: ComponentStory< typeof ZStack > = ( args ) => {
|
|
57
56
|
return (
|
|
58
|
-
<
|
|
59
|
-
<
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
<Avatar backgroundColor="#aaa" />
|
|
65
|
-
<Avatar backgroundColor="#fff" />
|
|
66
|
-
</ZStack>
|
|
67
|
-
</View>
|
|
68
|
-
</HStack>
|
|
69
|
-
</View>
|
|
57
|
+
<ZStack { ...args }>
|
|
58
|
+
<Avatar backgroundColor="#444" />
|
|
59
|
+
<Avatar backgroundColor="#777" />
|
|
60
|
+
<Avatar backgroundColor="#aaa" />
|
|
61
|
+
<Avatar backgroundColor="#fff" />
|
|
62
|
+
</ZStack>
|
|
70
63
|
);
|
|
71
64
|
};
|
|
72
65
|
|
package/src/z-stack/styles.ts
CHANGED
|
@@ -4,36 +4,35 @@
|
|
|
4
4
|
import { css } from '@emotion/react';
|
|
5
5
|
import styled from '@emotion/styled';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { rtl } from '../utils';
|
|
11
|
-
|
|
12
|
-
export const ZStackView = styled.div`
|
|
13
|
-
display: flex;
|
|
14
|
-
position: relative;
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
7
|
export const ZStackChildView = styled.div< {
|
|
18
|
-
isLayered: boolean;
|
|
19
8
|
offsetAmount: number;
|
|
20
9
|
zIndex: number;
|
|
21
10
|
} >`
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
&:not( :first-of-type ) {
|
|
12
|
+
${ ( { offsetAmount } ) =>
|
|
13
|
+
css( {
|
|
14
|
+
marginInlineStart: offsetAmount,
|
|
15
|
+
} ) };
|
|
16
|
+
}
|
|
26
17
|
|
|
27
|
-
${ ( {
|
|
28
|
-
isLayered ? positionAbsolute : positionRelative }
|
|
29
|
-
|
|
30
|
-
${ ( { zIndex } ) => css( { zIndex } ) }
|
|
31
|
-
`;
|
|
32
|
-
|
|
33
|
-
const positionAbsolute = css`
|
|
34
|
-
position: absolute;
|
|
18
|
+
${ ( { zIndex } ) => css( { zIndex } ) };
|
|
35
19
|
`;
|
|
36
20
|
|
|
37
|
-
const
|
|
21
|
+
export const ZStackView = styled.div< {
|
|
22
|
+
isLayered: boolean;
|
|
23
|
+
} >`
|
|
24
|
+
display: inline-grid;
|
|
25
|
+
grid-auto-flow: column;
|
|
38
26
|
position: relative;
|
|
27
|
+
|
|
28
|
+
& > ${ ZStackChildView } {
|
|
29
|
+
position: relative;
|
|
30
|
+
justify-self: start;
|
|
31
|
+
|
|
32
|
+
${ ( { isLayered } ) =>
|
|
33
|
+
isLayered
|
|
34
|
+
? // When `isLayered` is true, all items overlap in the same grid cell
|
|
35
|
+
css( { gridRowStart: 1, gridColumnStart: 1 } )
|
|
36
|
+
: undefined };
|
|
37
|
+
}
|
|
39
38
|
`;
|