@wordpress/components 19.8.1 → 19.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/CHANGELOG.md +12 -0
- package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js +11 -11
- package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
- package/build/heading/hook.js +1 -1
- package/build/heading/hook.js.map +1 -1
- package/build/input-control/index.js +26 -4
- package/build/input-control/index.js.map +1 -1
- package/build/input-control/styles/input-control-styles.js +25 -25
- package/build/input-control/styles/input-control-styles.js.map +1 -1
- package/build/navigation/styles/navigation-styles.js +12 -12
- package/build/navigation/styles/navigation-styles.js.map +1 -1
- package/build/notice/index.native.js +44 -40
- package/build/notice/index.native.js.map +1 -1
- package/build/notice/list.native.js +27 -45
- package/build/notice/list.native.js.map +1 -1
- package/build/palette-edit/index.js +2 -1
- package/build/palette-edit/index.js.map +1 -1
- package/build/sandbox/index.js +2 -2
- package/build/sandbox/index.js.map +1 -1
- package/build/select-control/styles/select-control-styles.js +5 -5
- package/build/select-control/styles/select-control-styles.js.map +1 -1
- package/build/surface/styles.js +8 -8
- package/build/surface/styles.js.map +1 -1
- package/build/text/hook.js +5 -5
- package/build/text/hook.js.map +1 -1
- package/build/text/styles/text-mixins.native.js +1 -1
- package/build/text/styles/text-mixins.native.js.map +1 -1
- package/build/text/styles.js +7 -7
- package/build/text/styles.js.map +1 -1
- package/build/ui/spinner/component.js +1 -1
- package/build/ui/spinner/component.js.map +1 -1
- package/build/utils/colors-values.js +9 -24
- package/build/utils/colors-values.js.map +1 -1
- package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js +11 -11
- package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
- package/build-module/heading/hook.js +1 -1
- package/build-module/heading/hook.js.map +1 -1
- package/build-module/input-control/index.js +23 -3
- package/build-module/input-control/index.js.map +1 -1
- package/build-module/input-control/styles/input-control-styles.js +25 -25
- package/build-module/input-control/styles/input-control-styles.js.map +1 -1
- package/build-module/navigation/styles/navigation-styles.js +13 -13
- package/build-module/navigation/styles/navigation-styles.js.map +1 -1
- package/build-module/notice/index.native.js +45 -41
- package/build-module/notice/index.native.js.map +1 -1
- package/build-module/notice/list.native.js +28 -46
- package/build-module/notice/list.native.js.map +1 -1
- package/build-module/palette-edit/index.js +3 -2
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/sandbox/index.js +2 -2
- package/build-module/sandbox/index.js.map +1 -1
- package/build-module/select-control/styles/select-control-styles.js +5 -5
- package/build-module/select-control/styles/select-control-styles.js.map +1 -1
- package/build-module/surface/styles.js +8 -8
- package/build-module/surface/styles.js.map +1 -1
- package/build-module/text/hook.js +5 -5
- package/build-module/text/hook.js.map +1 -1
- package/build-module/text/styles/text-mixins.native.js +2 -2
- package/build-module/text/styles/text-mixins.native.js.map +1 -1
- package/build-module/text/styles.js +7 -7
- package/build-module/text/styles.js.map +1 -1
- package/build-module/ui/spinner/component.js +1 -1
- package/build-module/ui/spinner/component.js.map +1 -1
- package/build-module/utils/colors-values.js +19 -23
- package/build-module/utils/colors-values.js.map +1 -1
- package/build-style/style-rtl.css +17 -0
- package/build-style/style.css +17 -0
- package/build-types/color-picker/styles.d.ts +1 -1
- package/build-types/input-control/index.d.ts +22 -3
- package/build-types/input-control/index.d.ts.map +1 -1
- package/build-types/input-control/input-field.d.ts +1 -1
- package/build-types/input-control/input-field.d.ts.map +1 -1
- package/build-types/input-control/stories/index.d.ts +5 -5
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/input-control/types.d.ts +73 -3
- package/build-types/input-control/types.d.ts.map +1 -1
- package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
- package/build-types/text/test/index.d.ts +2 -0
- package/build-types/text/test/index.d.ts.map +1 -0
- package/build-types/utils/colors-values.d.ts +6 -146
- package/build-types/utils/colors-values.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/alignment-matrix-control/styles/alignment-matrix-control-styles.js +5 -3
- package/src/heading/hook.ts +1 -1
- package/src/heading/test/__snapshots__/index.js.snap +3 -3
- package/src/input-control/README.md +2 -2
- package/src/input-control/index.tsx +22 -3
- package/src/input-control/stories/index.tsx +63 -0
- package/src/input-control/styles/input-control-styles.tsx +1 -2
- package/src/input-control/types.ts +73 -2
- package/src/navigation/styles/navigation-styles.js +5 -5
- package/src/notice/index.native.js +44 -54
- package/src/notice/list.native.js +27 -51
- package/src/notice/style.native.scss +1 -0
- package/src/palette-edit/index.js +8 -2
- package/src/query-controls/README.md +2 -2
- package/src/sandbox/index.js +2 -2
- package/src/select-control/styles/select-control-styles.ts +1 -1
- package/src/surface/styles.js +1 -1
- package/src/text/hook.js +1 -1
- package/src/text/styles/text-mixins.native.js +2 -2
- package/src/text/styles.js +1 -1
- package/src/text/test/__snapshots__/{index.js.snap → index.tsx.snap} +16 -0
- package/src/text/test/{index.js → index.tsx} +12 -6
- package/src/toolbar-group/style.scss +20 -0
- package/src/tools-panel/test/__snapshots__/index.js.snap +1 -1
- package/src/ui/spinner/component.js +1 -1
- package/src/ui/spinner/test/__snapshots__/index.js.snap +3 -3
- package/src/utils/colors-values.js +18 -22
- package/tsconfig.json +8 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build-types/spinner/styles/spinner-styles.d.ts +0 -5
- package/build-types/spinner/styles/spinner-styles.d.ts.map +0 -1
- package/build-types/toggle-group-control/toggle-group-control-option/styles.d.ts +0 -15
- package/build-types/toggle-group-control/toggle-group-control-option/styles.d.ts.map +0 -1
- package/src/input-control/stories/index.js +0 -71
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
ChangeEvent,
|
|
8
8
|
SyntheticEvent,
|
|
9
9
|
PointerEvent,
|
|
10
|
+
HTMLInputTypeAttribute,
|
|
10
11
|
} from 'react';
|
|
11
12
|
import type { useDrag } from '@use-gesture/react';
|
|
12
13
|
|
|
@@ -14,8 +15,8 @@ import type { useDrag } from '@use-gesture/react';
|
|
|
14
15
|
* Internal dependencies
|
|
15
16
|
*/
|
|
16
17
|
import type { StateReducer } from './reducer/state';
|
|
17
|
-
import type { FlexProps } from '../flex/types';
|
|
18
18
|
import type { WordPressComponentProps } from '../ui/context';
|
|
19
|
+
import type { FlexProps } from '../flex/types';
|
|
19
20
|
|
|
20
21
|
export type LabelPosition = 'top' | 'bottom' | 'side' | 'edge';
|
|
21
22
|
|
|
@@ -27,9 +28,31 @@ export type Size = 'default' | 'small' | '__unstable-large';
|
|
|
27
28
|
|
|
28
29
|
interface BaseProps {
|
|
29
30
|
__unstableInputWidth?: CSSProperties[ 'width' ];
|
|
31
|
+
/**
|
|
32
|
+
* If true, the label will only be visible to screen readers.
|
|
33
|
+
*
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
30
36
|
hideLabelFromVision?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Whether the component should be in a focused state.
|
|
39
|
+
* Used to coordinate focus states when the actual focused element and the component handling
|
|
40
|
+
* visual focus are separate.
|
|
41
|
+
*
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
31
44
|
isFocused: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The position of the label.
|
|
47
|
+
*
|
|
48
|
+
* @default 'top'
|
|
49
|
+
*/
|
|
32
50
|
labelPosition?: LabelPosition;
|
|
51
|
+
/**
|
|
52
|
+
* Adjusts the size of the input.
|
|
53
|
+
*
|
|
54
|
+
* @default 'default'
|
|
55
|
+
*/
|
|
33
56
|
size?: Size;
|
|
34
57
|
}
|
|
35
58
|
|
|
@@ -39,10 +62,35 @@ export type InputChangeCallback<
|
|
|
39
62
|
> = ( nextValue: string | undefined, extra: { event: E } & P ) => void;
|
|
40
63
|
|
|
41
64
|
export interface InputFieldProps extends BaseProps {
|
|
65
|
+
/**
|
|
66
|
+
* Determines the drag axis.
|
|
67
|
+
*
|
|
68
|
+
* @default 'n'
|
|
69
|
+
*/
|
|
42
70
|
dragDirection?: DragDirection;
|
|
71
|
+
/**
|
|
72
|
+
* If `isDragEnabled` is true, this controls the amount of `px` to have been dragged before
|
|
73
|
+
* the drag gesture is actually triggered.
|
|
74
|
+
*
|
|
75
|
+
* @default 10
|
|
76
|
+
*/
|
|
43
77
|
dragThreshold?: number;
|
|
78
|
+
/**
|
|
79
|
+
* If true, enables mouse drag gestures.
|
|
80
|
+
*
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
44
83
|
isDragEnabled?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* If true, the `ENTER` key press is required in order to trigger an `onChange`.
|
|
86
|
+
* If enabled, a change is also triggered when tabbing away (`onBlur`).
|
|
87
|
+
*
|
|
88
|
+
* @default false
|
|
89
|
+
*/
|
|
45
90
|
isPressEnterToChange?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* A function that receives the value of the input.
|
|
93
|
+
*/
|
|
46
94
|
onChange?: InputChangeCallback;
|
|
47
95
|
onValidate?: (
|
|
48
96
|
nextValue: string,
|
|
@@ -50,24 +98,47 @@ export interface InputFieldProps extends BaseProps {
|
|
|
50
98
|
) => void;
|
|
51
99
|
setIsFocused: ( isFocused: boolean ) => void;
|
|
52
100
|
stateReducer?: StateReducer;
|
|
101
|
+
/**
|
|
102
|
+
* The current value of the input.
|
|
103
|
+
*/
|
|
53
104
|
value?: string;
|
|
54
105
|
onDragEnd?: ( dragProps: DragProps ) => void;
|
|
55
106
|
onDragStart?: ( dragProps: DragProps ) => void;
|
|
56
107
|
onDrag?: ( dragProps: DragProps ) => void;
|
|
108
|
+
/**
|
|
109
|
+
* Type of the input element to render.
|
|
110
|
+
*
|
|
111
|
+
* @default 'text'
|
|
112
|
+
*/
|
|
113
|
+
type?: HTMLInputTypeAttribute;
|
|
57
114
|
}
|
|
58
115
|
|
|
59
116
|
export interface InputBaseProps extends BaseProps, FlexProps {
|
|
60
117
|
children: ReactNode;
|
|
118
|
+
/**
|
|
119
|
+
* Renders an element on the left side of the input.
|
|
120
|
+
*/
|
|
61
121
|
prefix?: ReactNode;
|
|
122
|
+
/**
|
|
123
|
+
* Renders an element on the right side of the input.
|
|
124
|
+
*/
|
|
62
125
|
suffix?: ReactNode;
|
|
126
|
+
/**
|
|
127
|
+
* If true, the `input` will be disabled.
|
|
128
|
+
*
|
|
129
|
+
* @default false
|
|
130
|
+
*/
|
|
63
131
|
disabled?: boolean;
|
|
64
132
|
className?: string;
|
|
65
133
|
id?: string;
|
|
134
|
+
/**
|
|
135
|
+
* If this property is added, a label will be generated using label property as the content.
|
|
136
|
+
*/
|
|
66
137
|
label?: ReactNode;
|
|
67
138
|
}
|
|
68
139
|
|
|
69
140
|
export interface InputControlProps
|
|
70
|
-
extends Omit< InputBaseProps, 'children' | 'isFocused' >,
|
|
141
|
+
extends Omit< InputBaseProps, 'children' | 'isFocused' | keyof FlexProps >,
|
|
71
142
|
/**
|
|
72
143
|
* The `prefix` prop in `WordPressComponentProps< InputFieldProps, 'input', false >` comes from the
|
|
73
144
|
* `HTMLInputAttributes` and clashes with the one from `InputBaseProps`. So we have to omit it from
|
|
@@ -11,7 +11,7 @@ import { isRTL } from '@wordpress/i18n';
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
|
-
import {
|
|
14
|
+
import { COLORS } from '../../utils/colors-values';
|
|
15
15
|
import Button from '../../button';
|
|
16
16
|
import { Text } from '../../text';
|
|
17
17
|
import { Heading } from '../../heading';
|
|
@@ -155,18 +155,18 @@ export const ItemBaseUI = styled.li`
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
&.is-active {
|
|
158
|
-
background-color: ${
|
|
159
|
-
color: ${
|
|
158
|
+
background-color: ${ COLORS.ui.theme };
|
|
159
|
+
color: ${ COLORS.white };
|
|
160
160
|
|
|
161
161
|
> button,
|
|
162
162
|
> a {
|
|
163
|
-
color: ${
|
|
163
|
+
color: ${ COLORS.white };
|
|
164
164
|
opacity: 1;
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
> svg path {
|
|
169
|
-
color: ${
|
|
169
|
+
color: ${ COLORS.gray[ 600 ] };
|
|
170
170
|
}
|
|
171
171
|
`;
|
|
172
172
|
|
|
@@ -7,15 +7,14 @@ import {
|
|
|
7
7
|
Text,
|
|
8
8
|
TouchableWithoutFeedback,
|
|
9
9
|
View,
|
|
10
|
-
|
|
11
|
-
Platform,
|
|
10
|
+
useWindowDimensions,
|
|
12
11
|
} from 'react-native';
|
|
13
12
|
import { BlurView } from '@react-native-community/blur';
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* WordPress dependencies
|
|
17
16
|
*/
|
|
18
|
-
import { useEffect, useRef,
|
|
17
|
+
import { useEffect, useRef, Platform } from '@wordpress/element';
|
|
19
18
|
import { usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
20
19
|
|
|
21
20
|
/**
|
|
@@ -23,57 +22,48 @@ import { usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
|
23
22
|
*/
|
|
24
23
|
import styles from './style.scss';
|
|
25
24
|
|
|
26
|
-
const
|
|
27
|
-
const [ width, setWidth ] = useState( Dimensions.get( 'window' ).width );
|
|
28
|
-
const [ visible, setVisible ] = useState( true );
|
|
25
|
+
const HIDE_TIMER = 3000;
|
|
29
26
|
|
|
27
|
+
const Notice = ( { onNoticeHidden, content, id, status } ) => {
|
|
28
|
+
const { width } = useWindowDimensions();
|
|
30
29
|
const animationValue = useRef( new Animated.Value( 0 ) ).current;
|
|
31
30
|
const timer = useRef( null );
|
|
32
|
-
const isIOS = Platform.OS === 'ios';
|
|
33
|
-
|
|
34
|
-
const onDimensionsChange = () => {
|
|
35
|
-
setWidth( Dimensions.get( 'window' ).width );
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
useEffect( () => {
|
|
39
|
-
const dimensionsChangeSubscription = Dimensions.addEventListener(
|
|
40
|
-
'change',
|
|
41
|
-
onDimensionsChange
|
|
42
|
-
);
|
|
43
|
-
return () => {
|
|
44
|
-
dimensionsChangeSubscription.remove();
|
|
45
|
-
};
|
|
46
|
-
}, [] );
|
|
47
31
|
|
|
48
32
|
useEffect( () => {
|
|
49
33
|
startAnimation();
|
|
34
|
+
|
|
50
35
|
return () => {
|
|
51
36
|
clearTimeout( timer?.current );
|
|
52
37
|
};
|
|
53
|
-
}, [
|
|
38
|
+
}, [] );
|
|
54
39
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
40
|
+
function onHide() {
|
|
41
|
+
Animated.timing( animationValue, {
|
|
42
|
+
toValue: 0,
|
|
43
|
+
duration: 150,
|
|
44
|
+
useNativeDriver: true,
|
|
45
|
+
easing: Easing.out( Easing.quad ),
|
|
46
|
+
} ).start( ( { finished } ) => {
|
|
47
|
+
if ( finished && onNoticeHidden ) {
|
|
48
|
+
onNoticeHidden( id );
|
|
49
|
+
}
|
|
50
|
+
} );
|
|
51
|
+
}
|
|
58
52
|
|
|
59
|
-
|
|
53
|
+
function startAnimation() {
|
|
60
54
|
Animated.timing( animationValue, {
|
|
61
|
-
toValue:
|
|
62
|
-
duration:
|
|
55
|
+
toValue: 1,
|
|
56
|
+
duration: 300,
|
|
63
57
|
useNativeDriver: true,
|
|
64
58
|
easing: Easing.out( Easing.quad ),
|
|
65
|
-
} ).start( () => {
|
|
66
|
-
if (
|
|
59
|
+
} ).start( ( { finished } ) => {
|
|
60
|
+
if ( finished && onNoticeHidden ) {
|
|
67
61
|
timer.current = setTimeout( () => {
|
|
68
62
|
onHide();
|
|
69
|
-
},
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if ( ! visible && onNoticeHidden ) {
|
|
73
|
-
onNoticeHidden( id );
|
|
63
|
+
}, HIDE_TIMER );
|
|
74
64
|
}
|
|
75
65
|
} );
|
|
76
|
-
}
|
|
66
|
+
}
|
|
77
67
|
|
|
78
68
|
const noticeSolidStyles = usePreferredColorSchemeStyle(
|
|
79
69
|
styles.noticeSolid,
|
|
@@ -95,25 +85,25 @@ const Notice = ( { onNoticeHidden, content, id, status } ) => {
|
|
|
95
85
|
status === 'error' && errorTextStyles,
|
|
96
86
|
];
|
|
97
87
|
|
|
88
|
+
const containerStyles = [
|
|
89
|
+
styles.notice,
|
|
90
|
+
! Platform.isIOS && noticeSolidStyles,
|
|
91
|
+
{
|
|
92
|
+
width,
|
|
93
|
+
transform: [
|
|
94
|
+
{
|
|
95
|
+
translateY: animationValue.interpolate( {
|
|
96
|
+
inputRange: [ 0, 1 ],
|
|
97
|
+
outputRange: [ -24, 0 ],
|
|
98
|
+
} ),
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
|
|
98
104
|
return (
|
|
99
105
|
<>
|
|
100
|
-
<Animated.View
|
|
101
|
-
style={ [
|
|
102
|
-
styles.notice,
|
|
103
|
-
! isIOS && noticeSolidStyles,
|
|
104
|
-
{
|
|
105
|
-
width,
|
|
106
|
-
transform: [
|
|
107
|
-
{
|
|
108
|
-
translateY: animationValue.interpolate( {
|
|
109
|
-
inputRange: [ 0, 1 ],
|
|
110
|
-
outputRange: [ -24, 0 ],
|
|
111
|
-
} ),
|
|
112
|
-
},
|
|
113
|
-
],
|
|
114
|
-
},
|
|
115
|
-
] }
|
|
116
|
-
>
|
|
106
|
+
<Animated.View style={ containerStyles }>
|
|
117
107
|
<TouchableWithoutFeedback onPress={ onHide }>
|
|
118
108
|
<View style={ styles.noticeContent }>
|
|
119
109
|
<Text numberOfLines={ 3 } style={ textStyles }>
|
|
@@ -121,7 +111,7 @@ const Notice = ( { onNoticeHidden, content, id, status } ) => {
|
|
|
121
111
|
</Text>
|
|
122
112
|
</View>
|
|
123
113
|
</TouchableWithoutFeedback>
|
|
124
|
-
{ isIOS && (
|
|
114
|
+
{ Platform.isIOS && (
|
|
125
115
|
<BlurView
|
|
126
116
|
style={ styles.blurBackground }
|
|
127
117
|
blurType="prominent"
|
|
@@ -6,9 +6,8 @@ import { View } from 'react-native';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { compose } from '@wordpress/compose';
|
|
9
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
10
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Internal dependencies
|
|
@@ -16,60 +15,37 @@ import { compose } from '@wordpress/compose';
|
|
|
16
15
|
import Notice from './';
|
|
17
16
|
import styles from './style.scss';
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
function NoticeList() {
|
|
19
|
+
const { notices } = useSelect( ( select ) => {
|
|
20
|
+
const { getNotices } = select( noticesStore );
|
|
21
|
+
return {
|
|
22
|
+
notices: getNotices(),
|
|
23
|
+
};
|
|
24
|
+
}, [] );
|
|
24
25
|
|
|
25
|
-
removeNotice(
|
|
26
|
-
|
|
26
|
+
const { removeNotice } = useDispatch( noticesStore );
|
|
27
|
+
|
|
28
|
+
function onRemoveNotice( id ) {
|
|
27
29
|
removeNotice( id );
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if ( ! notices.length ) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
32
|
+
if ( ! notices.length ) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
.reverse()
|
|
42
|
-
.map( ( notice ) => (
|
|
43
|
-
<Notice
|
|
44
|
-
{ ...notice }
|
|
45
|
-
key={ notice.id }
|
|
46
|
-
onNoticeHidden={ this.removeNotice }
|
|
47
|
-
></Notice>
|
|
48
|
-
) )
|
|
49
|
-
) : (
|
|
36
|
+
return (
|
|
37
|
+
<View style={ styles.list }>
|
|
38
|
+
{ notices.map( ( notice ) => {
|
|
39
|
+
return (
|
|
50
40
|
<Notice
|
|
51
|
-
{ ...
|
|
52
|
-
|
|
41
|
+
{ ...notice }
|
|
42
|
+
key={ notice.id }
|
|
43
|
+
onNoticeHidden={ onRemoveNotice }
|
|
53
44
|
></Notice>
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
45
|
+
);
|
|
46
|
+
} ) }
|
|
47
|
+
</View>
|
|
48
|
+
);
|
|
58
49
|
}
|
|
59
50
|
|
|
60
|
-
export default
|
|
61
|
-
withSelect( ( select ) => {
|
|
62
|
-
const { getNotices } = select( 'core/notices' );
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
notices: getNotices(),
|
|
66
|
-
};
|
|
67
|
-
} ),
|
|
68
|
-
withDispatch( ( dispatch ) => {
|
|
69
|
-
const { removeNotice } = dispatch( 'core/notices' );
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
removeNotice,
|
|
73
|
-
};
|
|
74
|
-
} ),
|
|
75
|
-
] )( NoticeList );
|
|
51
|
+
export default NoticeList;
|
|
@@ -9,7 +9,10 @@ import { kebabCase } from 'lodash';
|
|
|
9
9
|
import { useState, useRef, useEffect } from '@wordpress/element';
|
|
10
10
|
import { __, sprintf } from '@wordpress/i18n';
|
|
11
11
|
import { lineSolid, moreVertical, plus } from '@wordpress/icons';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
__experimentalUseFocusOutside as useFocusOutside,
|
|
14
|
+
useDebounce,
|
|
15
|
+
} from '@wordpress/compose';
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
18
|
* Internal dependencies
|
|
@@ -197,6 +200,9 @@ function PaletteEditListView( {
|
|
|
197
200
|
}
|
|
198
201
|
};
|
|
199
202
|
}, [] );
|
|
203
|
+
|
|
204
|
+
const debounceOnChange = useDebounce( onChange, 100 );
|
|
205
|
+
|
|
200
206
|
return (
|
|
201
207
|
<VStack spacing={ 3 }>
|
|
202
208
|
<ItemGroup isRounded>
|
|
@@ -212,7 +218,7 @@ function PaletteEditListView( {
|
|
|
212
218
|
}
|
|
213
219
|
} }
|
|
214
220
|
onChange={ ( newElement ) => {
|
|
215
|
-
|
|
221
|
+
debounceOnChange(
|
|
216
222
|
elements.map(
|
|
217
223
|
( currentElement, currentIndex ) => {
|
|
218
224
|
if ( currentIndex === index ) {
|
|
@@ -51,7 +51,7 @@ const MyQueryControls = () => {
|
|
|
51
51
|
selectedCategoryId={ category }
|
|
52
52
|
onCategoryChange={ ( newCategory ) => updateQuery( { category: newCategory } ) }
|
|
53
53
|
onNumberOfItemsChange={ ( newNumberOfItems ) =>
|
|
54
|
-
updateQuery( { numberOfItems:
|
|
54
|
+
updateQuery( { numberOfItems: newNumberOfItems } )
|
|
55
55
|
}
|
|
56
56
|
/>
|
|
57
57
|
);
|
|
@@ -104,7 +104,7 @@ const MyQueryControls = () => {
|
|
|
104
104
|
selectedCategories={ selectedCategories }
|
|
105
105
|
onCategoryChange={ ( category ) => updateQuery( { selectedCategories: category } ) }
|
|
106
106
|
onNumberOfItemsChange={ ( newNumberOfItems ) =>
|
|
107
|
-
updateQuery( { numberOfItems:
|
|
107
|
+
updateQuery( { numberOfItems: newNumberOfItems } )
|
|
108
108
|
}
|
|
109
109
|
/>
|
|
110
110
|
);
|
package/src/sandbox/index.js
CHANGED
|
@@ -227,11 +227,11 @@ export default function Sandbox( {
|
|
|
227
227
|
|
|
228
228
|
useEffect( () => {
|
|
229
229
|
trySandbox();
|
|
230
|
-
}, [ title,
|
|
230
|
+
}, [ title, styles, scripts ] );
|
|
231
231
|
|
|
232
232
|
useEffect( () => {
|
|
233
233
|
trySandbox( true );
|
|
234
|
-
}, [ html ] );
|
|
234
|
+
}, [ html, type ] );
|
|
235
235
|
|
|
236
236
|
return (
|
|
237
237
|
<iframe
|
package/src/surface/styles.js
CHANGED
package/src/text/hook.js
CHANGED
|
@@ -105,7 +105,7 @@ export default function useText( props ) {
|
|
|
105
105
|
getOptimalTextShade( optimizeReadabilityFor ) === 'dark';
|
|
106
106
|
|
|
107
107
|
sx.optimalTextColor = isOptimalTextColorDark
|
|
108
|
-
? css( { color: COLORS.
|
|
108
|
+
? css( { color: COLORS.gray[ 900 ] } )
|
|
109
109
|
: css( { color: COLORS.white } );
|
|
110
110
|
}
|
|
111
111
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { fontFamily } from './font-family';
|
|
5
5
|
import css from './emotion-css';
|
|
6
|
-
import {
|
|
6
|
+
import { COLORS } from '../../utils/colors-values';
|
|
7
7
|
|
|
8
8
|
const fontWeightNormal = `font-weight: 400;`;
|
|
9
9
|
const fontWeightMedium = `font-weight: 500;`;
|
|
@@ -81,7 +81,7 @@ const sectionHeading = `
|
|
|
81
81
|
font-size: 11px;
|
|
82
82
|
line-height: 1.4;
|
|
83
83
|
text-transform: uppercase;
|
|
84
|
-
color: ${
|
|
84
|
+
color: ${ COLORS.gray[ 700 ] }
|
|
85
85
|
`;
|
|
86
86
|
|
|
87
87
|
/**
|
package/src/text/styles.js
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
+
exports[`Text should render align 1`] = `
|
|
4
|
+
Snapshot Diff:
|
|
5
|
+
- Received styles
|
|
6
|
+
+ Base styles
|
|
7
|
+
|
|
8
|
+
@@ -3,7 +3,8 @@
|
|
9
|
+
"color": "#1e1e1e",
|
|
10
|
+
"font-size": "calc((13 / 13) * 13px)",
|
|
11
|
+
"font-weight": "normal",
|
|
12
|
+
"line-height": "1.2",
|
|
13
|
+
"margin": "0",
|
|
14
|
+
+ "text-align": "center",
|
|
15
|
+
},
|
|
16
|
+
]
|
|
17
|
+
`;
|
|
18
|
+
|
|
3
19
|
exports[`Text should render highlighted words with highlightCaseSensitive 1`] = `
|
|
4
20
|
.emotion-0 {
|
|
5
21
|
color: #1e1e1e;
|
|
@@ -59,14 +59,20 @@ describe( 'Text', () => {
|
|
|
59
59
|
|
|
60
60
|
test( 'should render as another element', () => {
|
|
61
61
|
const { container } = render( <Text as="div">Lorem ipsum.</Text> );
|
|
62
|
-
expect( container.firstChild
|
|
62
|
+
expect( container.firstChild?.nodeName ).toBe( 'DIV' );
|
|
63
63
|
} );
|
|
64
64
|
|
|
65
65
|
test( 'should render align', () => {
|
|
66
|
-
const { container } = render(
|
|
66
|
+
const { container: centerAlignedContainer } = render(
|
|
67
67
|
<Text align="center">Lorem ipsum.</Text>
|
|
68
68
|
);
|
|
69
|
-
|
|
69
|
+
const { container: defaultAlignedContainer } = render(
|
|
70
|
+
<Text>Lorem ipsum.</Text>
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
expect(
|
|
74
|
+
defaultAlignedContainer.children[ 0 ]
|
|
75
|
+
).toMatchStyleDiffSnapshot( centerAlignedContainer.children[ 0 ] );
|
|
70
76
|
} );
|
|
71
77
|
|
|
72
78
|
test( 'should render color', () => {
|
|
@@ -89,7 +95,7 @@ describe( 'Text', () => {
|
|
|
89
95
|
const wrapper = render(
|
|
90
96
|
<Text highlightWords={ [ 'm' ] }>Lorem ipsum.</Text>
|
|
91
97
|
);
|
|
92
|
-
expect( wrapper.container.firstChild
|
|
98
|
+
expect( wrapper.container.firstChild?.childNodes ).toHaveLength( 5 );
|
|
93
99
|
const words = await wrapper.findAllByText( 'm' );
|
|
94
100
|
expect( words ).toHaveLength( 2 );
|
|
95
101
|
words.forEach( ( word ) => expect( word.tagName ).toEqual( 'MARK' ) );
|
|
@@ -100,7 +106,7 @@ describe( 'Text', () => {
|
|
|
100
106
|
<Text highlightWords={ undefined }>Lorem ipsum.</Text>
|
|
101
107
|
);
|
|
102
108
|
// It'll have a length of 1 because there shouldn't be anything but the single span being rendered.
|
|
103
|
-
expect( container.firstChild
|
|
109
|
+
expect( container.firstChild?.childNodes ).toHaveLength( 1 );
|
|
104
110
|
} );
|
|
105
111
|
|
|
106
112
|
test( 'should render highlighted words with highlightCaseSensitive', () => {
|
|
@@ -112,7 +118,7 @@ describe( 'Text', () => {
|
|
|
112
118
|
|
|
113
119
|
expect( container.firstChild ).toMatchSnapshot();
|
|
114
120
|
// It'll have a length of 1 because there shouldn't be anything but the single span being rendered.
|
|
115
|
-
expect( container.firstChild
|
|
121
|
+
expect( container.firstChild?.childNodes ).toHaveLength( 1 );
|
|
116
122
|
} );
|
|
117
123
|
|
|
118
124
|
test( 'should render isBlock', () => {
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
display: inline-flex;
|
|
6
6
|
flex-shrink: 0;
|
|
7
7
|
flex-wrap: wrap;
|
|
8
|
+
padding-left: $grid-unit-15 * 0.5; // 6px.
|
|
9
|
+
padding-right: $grid-unit-15 * 0.5;
|
|
8
10
|
|
|
9
11
|
// Unset for nested toolbar groups. Increase specificity.
|
|
10
12
|
& .components-toolbar-group.components-toolbar-group {
|
|
@@ -13,6 +15,24 @@
|
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
line-height: 0;
|
|
18
|
+
|
|
19
|
+
// Size multiple sequential buttons to be optically balanced.
|
|
20
|
+
// Icons are 36px, as set by a 24px icon and 12px padding.
|
|
21
|
+
.components-button.components-button, // This needs specificity to override padding values inherited from the button component.
|
|
22
|
+
.components-button.has-icon.has-icon {
|
|
23
|
+
min-width: $block-toolbar-height - $grid-unit-15;
|
|
24
|
+
padding-left: $grid-unit-15 * 0.5; // 6px.
|
|
25
|
+
padding-right: $grid-unit-15 * 0.5;
|
|
26
|
+
|
|
27
|
+
svg {
|
|
28
|
+
min-width: $button-size-small; // This is the optimal icon size, and we size the whole button after this.
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&::before {
|
|
32
|
+
left: 2px;
|
|
33
|
+
right: 2px;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
16
36
|
}
|
|
17
37
|
|
|
18
38
|
// Legacy toolbar group
|