@wordpress/components 29.4.0 → 29.5.1
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 +28 -0
- package/build/border-control/border-control-dropdown/component.js +19 -21
- package/build/border-control/border-control-dropdown/component.js.map +1 -1
- package/build/border-control/border-control-dropdown/hook.js +3 -3
- package/build/border-control/border-control-dropdown/hook.js.map +1 -1
- package/build/border-control/styles.js +24 -19
- package/build/border-control/styles.js.map +1 -1
- package/build/circular-option-picker/circular-option-picker.js +1 -0
- package/build/circular-option-picker/circular-option-picker.js.map +1 -1
- package/build/circular-option-picker/index.js +7 -0
- package/build/circular-option-picker/index.js.map +1 -1
- package/build/circular-option-picker/types.js.map +1 -1
- package/build/circular-option-picker/utils.js +31 -0
- package/build/circular-option-picker/utils.js.map +1 -0
- package/build/color-palette/index.js +9 -29
- package/build/color-palette/index.js.map +1 -1
- package/build/duotone-picker/duotone-picker.js +8 -28
- package/build/duotone-picker/duotone-picker.js.map +1 -1
- package/build/font-size-picker/types.js.map +1 -1
- package/build/gradient-picker/index.js +8 -28
- package/build/gradient-picker/index.js.map +1 -1
- package/build/input-control/styles/input-control-styles.js +22 -22
- package/build/input-control/styles/input-control-styles.js.map +1 -1
- package/build/mobile/bottom-sheet/switch-cell.native.js +1 -1
- package/build/mobile/bottom-sheet/switch-cell.native.js.map +1 -1
- package/build/number-control/index.js +2 -2
- package/build/number-control/index.js.map +1 -1
- package/build/query-controls/index.js +18 -16
- package/build/query-controls/index.js.map +1 -1
- package/build/query-controls/index.native.js +3 -2
- package/build/query-controls/index.native.js.map +1 -1
- package/build/query-controls/types.js.map +1 -1
- package/build/textarea-control/styles/textarea-control-styles.js +3 -3
- package/build/textarea-control/styles/textarea-control-styles.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/component.js +19 -21
- package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/hook.js +3 -3
- package/build-module/border-control/border-control-dropdown/hook.js.map +1 -1
- package/build-module/border-control/styles.js +22 -13
- package/build-module/border-control/styles.js.map +1 -1
- package/build-module/circular-option-picker/circular-option-picker.js +1 -0
- package/build-module/circular-option-picker/circular-option-picker.js.map +1 -1
- package/build-module/circular-option-picker/index.js +1 -0
- package/build-module/circular-option-picker/index.js.map +1 -1
- package/build-module/circular-option-picker/types.js.map +1 -1
- package/build-module/circular-option-picker/utils.js +25 -0
- package/build-module/circular-option-picker/utils.js.map +1 -0
- package/build-module/color-palette/index.js +7 -29
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/duotone-picker/duotone-picker.js +6 -28
- package/build-module/duotone-picker/duotone-picker.js.map +1 -1
- package/build-module/font-size-picker/types.js.map +1 -1
- package/build-module/gradient-picker/index.js +6 -28
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/input-control/styles/input-control-styles.js +22 -22
- package/build-module/input-control/styles/input-control-styles.js.map +1 -1
- package/build-module/mobile/bottom-sheet/switch-cell.native.js +1 -1
- package/build-module/mobile/bottom-sheet/switch-cell.native.js.map +1 -1
- package/build-module/number-control/index.js +2 -2
- package/build-module/number-control/index.js.map +1 -1
- package/build-module/query-controls/index.js +18 -16
- package/build-module/query-controls/index.js.map +1 -1
- package/build-module/query-controls/index.native.js +3 -2
- package/build-module/query-controls/index.native.js.map +1 -1
- package/build-module/query-controls/types.js.map +1 -1
- package/build-module/textarea-control/styles/textarea-control-styles.js +3 -3
- package/build-module/textarea-control/styles/textarea-control-styles.js.map +1 -1
- package/build-style/style-rtl.css +6 -6
- package/build-style/style.css +7 -6
- package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/hook.d.ts +1 -1
- package/build-types/border-control/styles.d.ts +1 -1
- package/build-types/border-control/styles.d.ts.map +1 -1
- package/build-types/circular-option-picker/index.d.ts +1 -0
- package/build-types/circular-option-picker/index.d.ts.map +1 -1
- package/build-types/circular-option-picker/types.d.ts +11 -7
- package/build-types/circular-option-picker/types.d.ts.map +1 -1
- package/build-types/circular-option-picker/utils.d.ts +17 -0
- package/build-types/circular-option-picker/utils.d.ts.map +1 -0
- package/build-types/color-palette/index.d.ts.map +1 -1
- package/build-types/duotone-picker/duotone-picker.d.ts.map +1 -1
- package/build-types/font-size-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/font-size-picker/types.d.ts +4 -0
- package/build-types/font-size-picker/types.d.ts.map +1 -1
- package/build-types/gradient-picker/index.d.ts.map +1 -1
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/query-controls/index.d.ts +2 -2
- package/build-types/query-controls/index.d.ts.map +1 -1
- package/build-types/query-controls/types.d.ts +15 -1
- package/build-types/query-controls/types.d.ts.map +1 -1
- package/build-types/textarea-control/styles/textarea-control-styles.d.ts.map +1 -1
- package/package.json +19 -19
- package/src/border-box-control/test/index.tsx +1 -1
- package/src/border-control/border-control-dropdown/component.tsx +8 -12
- package/src/border-control/border-control-dropdown/hook.ts +3 -3
- package/src/border-control/styles.ts +4 -10
- package/src/border-control/test/index.js +1 -1
- package/src/circular-option-picker/README.md +13 -0
- package/src/circular-option-picker/circular-option-picker.tsx +1 -1
- package/src/circular-option-picker/index.tsx +1 -0
- package/src/circular-option-picker/stories/index.story.tsx +1 -1
- package/src/circular-option-picker/test/index.tsx +1 -0
- package/src/circular-option-picker/types.ts +11 -10
- package/src/circular-option-picker/utils.tsx +27 -0
- package/src/color-palette/index.tsx +11 -29
- package/src/color-palette/test/index.tsx +1 -1
- package/src/duotone-picker/duotone-picker.tsx +10 -28
- package/src/font-size-picker/README.md +2 -0
- package/src/font-size-picker/stories/index.story.tsx +4 -0
- package/src/font-size-picker/types.ts +4 -0
- package/src/gradient-picker/index.tsx +10 -28
- package/src/input-control/styles/input-control-styles.tsx +9 -1
- package/src/mobile/bottom-sheet/switch-cell.native.js +1 -1
- package/src/notice/README.md +1 -1
- package/src/notice/style.scss +1 -0
- package/src/number-control/README.md +1 -1
- package/src/number-control/index.tsx +2 -2
- package/src/query-controls/README.md +10 -3
- package/src/query-controls/index.native.js +3 -2
- package/src/query-controls/index.tsx +25 -21
- package/src/query-controls/types.ts +16 -1
- package/src/text-control/style.scss +6 -0
- package/src/textarea-control/styles/textarea-control-styles.ts +0 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -19,7 +19,9 @@ import { useCallback, useMemo, useState, forwardRef } from '@wordpress/element';
|
|
|
19
19
|
*/
|
|
20
20
|
import Dropdown from '../dropdown';
|
|
21
21
|
import { ColorPicker } from '../color-picker';
|
|
22
|
-
import CircularOptionPicker
|
|
22
|
+
import CircularOptionPicker, {
|
|
23
|
+
getComputeCircularOptionPickerCommonProps,
|
|
24
|
+
} from '../circular-option-picker';
|
|
23
25
|
import { VStack } from '../v-stack';
|
|
24
26
|
import { Truncate } from '../truncate';
|
|
25
27
|
import { ColorHeading } from './styles';
|
|
@@ -233,7 +235,7 @@ function UnforwardedColorPalette(
|
|
|
233
235
|
buttonLabelName,
|
|
234
236
|
displayValue
|
|
235
237
|
)
|
|
236
|
-
: __( 'Custom color picker
|
|
238
|
+
: __( 'Custom color picker' );
|
|
237
239
|
|
|
238
240
|
const paletteCommonProps = {
|
|
239
241
|
clearColor,
|
|
@@ -251,33 +253,12 @@ function UnforwardedColorPalette(
|
|
|
251
253
|
</CircularOptionPicker.ButtonAction>
|
|
252
254
|
);
|
|
253
255
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
metaProps = { asButtons: true };
|
|
261
|
-
} else {
|
|
262
|
-
const _metaProps: { asButtons: false; loop?: boolean } = {
|
|
263
|
-
asButtons: false,
|
|
264
|
-
loop,
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
if ( ariaLabel ) {
|
|
268
|
-
metaProps = { ..._metaProps, 'aria-label': ariaLabel };
|
|
269
|
-
} else if ( ariaLabelledby ) {
|
|
270
|
-
metaProps = {
|
|
271
|
-
..._metaProps,
|
|
272
|
-
'aria-labelledby': ariaLabelledby,
|
|
273
|
-
};
|
|
274
|
-
} else {
|
|
275
|
-
metaProps = {
|
|
276
|
-
..._metaProps,
|
|
277
|
-
'aria-label': __( 'Custom color picker.' ),
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
}
|
|
256
|
+
const { metaProps, labelProps } = getComputeCircularOptionPickerCommonProps(
|
|
257
|
+
asButtons,
|
|
258
|
+
loop,
|
|
259
|
+
ariaLabel,
|
|
260
|
+
ariaLabelledby
|
|
261
|
+
);
|
|
281
262
|
|
|
282
263
|
return (
|
|
283
264
|
<VStack spacing={ 3 } ref={ forwardedRef } { ...additionalProps }>
|
|
@@ -335,6 +316,7 @@ function UnforwardedColorPalette(
|
|
|
335
316
|
{ ( colors.length > 0 || actions ) && (
|
|
336
317
|
<CircularOptionPicker
|
|
337
318
|
{ ...metaProps }
|
|
319
|
+
{ ...labelProps }
|
|
338
320
|
actions={ actions }
|
|
339
321
|
options={
|
|
340
322
|
hasMultipleColorOrigins ? (
|
|
@@ -258,7 +258,7 @@ describe( 'ColorPalette', () => {
|
|
|
258
258
|
expect( screen.queryByText( colorCode ) ).not.toBeInTheDocument();
|
|
259
259
|
expect(
|
|
260
260
|
screen.getByRole( 'button', {
|
|
261
|
-
name: /^Custom color picker
|
|
261
|
+
name: /^Custom color picker$/,
|
|
262
262
|
} )
|
|
263
263
|
).toBeInTheDocument();
|
|
264
264
|
} );
|
|
@@ -13,7 +13,9 @@ import { __, sprintf } from '@wordpress/i18n';
|
|
|
13
13
|
* Internal dependencies
|
|
14
14
|
*/
|
|
15
15
|
import ColorListPicker from './color-list-picker';
|
|
16
|
-
import CircularOptionPicker
|
|
16
|
+
import CircularOptionPicker, {
|
|
17
|
+
getComputeCircularOptionPickerCommonProps,
|
|
18
|
+
} from '../circular-option-picker';
|
|
17
19
|
import { VStack } from '../v-stack';
|
|
18
20
|
|
|
19
21
|
import CustomDuotoneBar from './custom-duotone-bar';
|
|
@@ -127,33 +129,12 @@ function DuotonePicker( {
|
|
|
127
129
|
);
|
|
128
130
|
} );
|
|
129
131
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
metaProps = { asButtons: true };
|
|
137
|
-
} else {
|
|
138
|
-
const _metaProps: { asButtons: false; loop?: boolean } = {
|
|
139
|
-
asButtons: false,
|
|
140
|
-
loop,
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
if ( ariaLabel ) {
|
|
144
|
-
metaProps = { ..._metaProps, 'aria-label': ariaLabel };
|
|
145
|
-
} else if ( ariaLabelledby ) {
|
|
146
|
-
metaProps = {
|
|
147
|
-
..._metaProps,
|
|
148
|
-
'aria-labelledby': ariaLabelledby,
|
|
149
|
-
};
|
|
150
|
-
} else {
|
|
151
|
-
metaProps = {
|
|
152
|
-
..._metaProps,
|
|
153
|
-
'aria-label': __( 'Custom color picker.' ),
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
}
|
|
132
|
+
const { metaProps, labelProps } = getComputeCircularOptionPickerCommonProps(
|
|
133
|
+
asButtons,
|
|
134
|
+
loop,
|
|
135
|
+
ariaLabel,
|
|
136
|
+
ariaLabelledby
|
|
137
|
+
);
|
|
157
138
|
|
|
158
139
|
const options = unsetable
|
|
159
140
|
? [ unsetOption, ...duotoneOptions ]
|
|
@@ -163,6 +144,7 @@ function DuotonePicker( {
|
|
|
163
144
|
<CircularOptionPicker
|
|
164
145
|
{ ...otherProps }
|
|
165
146
|
{ ...metaProps }
|
|
147
|
+
{ ...labelProps }
|
|
166
148
|
options={ options }
|
|
167
149
|
actions={
|
|
168
150
|
!! clearable && (
|
|
@@ -99,6 +99,8 @@ Available units for custom font size selection.
|
|
|
99
99
|
|
|
100
100
|
The current font size value.
|
|
101
101
|
|
|
102
|
+
**Note**: For the `units` property to work, the current font size value must be specified as strings with units (e.g., `'12px'` instead of `12`). When the font size is provided as a number, the component operates in "unitless mode" where the `units` property has no effect.
|
|
103
|
+
|
|
102
104
|
- Required: No
|
|
103
105
|
|
|
104
106
|
### `withReset`: `boolean`
|
|
@@ -18,6 +18,10 @@ const meta: Meta< typeof FontSizePicker > = {
|
|
|
18
18
|
component: FontSizePicker,
|
|
19
19
|
argTypes: {
|
|
20
20
|
value: { control: false },
|
|
21
|
+
units: {
|
|
22
|
+
control: 'inline-check',
|
|
23
|
+
options: [ 'px', 'em', 'rem', 'vw', 'vh' ],
|
|
24
|
+
},
|
|
21
25
|
},
|
|
22
26
|
parameters: {
|
|
23
27
|
actions: { argTypesRegex: '^on.*' },
|
|
@@ -34,6 +34,10 @@ export type FontSizePickerProps = {
|
|
|
34
34
|
units?: string[];
|
|
35
35
|
/**
|
|
36
36
|
* The current font size value.
|
|
37
|
+
*
|
|
38
|
+
* Note: For the `units` property to work, the current font size value must be specified
|
|
39
|
+
* as strings with units (e.g., '12px' instead of 12). When the font size is provided
|
|
40
|
+
* as a number, the component operates in "unitless mode" where the `units` property has no effect.
|
|
37
41
|
*/
|
|
38
42
|
value?: number | string;
|
|
39
43
|
/**
|
|
@@ -8,7 +8,9 @@ import { useCallback, useMemo } from '@wordpress/element';
|
|
|
8
8
|
/**
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
11
|
-
import CircularOptionPicker
|
|
11
|
+
import CircularOptionPicker, {
|
|
12
|
+
getComputeCircularOptionPickerCommonProps,
|
|
13
|
+
} from '../circular-option-picker';
|
|
12
14
|
import CustomGradientPicker from '../custom-gradient-picker';
|
|
13
15
|
import { VStack } from '../v-stack';
|
|
14
16
|
import { ColorHeading } from '../color-palette/styles';
|
|
@@ -128,37 +130,17 @@ function Component( props: PickerProps< any > ) {
|
|
|
128
130
|
<SingleOrigin { ...additionalProps } />
|
|
129
131
|
);
|
|
130
132
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
metaProps = { asButtons: true };
|
|
138
|
-
} else {
|
|
139
|
-
const _metaProps: { asButtons: false; loop?: boolean } = {
|
|
140
|
-
asButtons: false,
|
|
141
|
-
loop,
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
if ( ariaLabel ) {
|
|
145
|
-
metaProps = { ..._metaProps, 'aria-label': ariaLabel };
|
|
146
|
-
} else if ( ariaLabelledby ) {
|
|
147
|
-
metaProps = {
|
|
148
|
-
..._metaProps,
|
|
149
|
-
'aria-labelledby': ariaLabelledby,
|
|
150
|
-
};
|
|
151
|
-
} else {
|
|
152
|
-
metaProps = {
|
|
153
|
-
..._metaProps,
|
|
154
|
-
'aria-label': __( 'Custom color picker.' ),
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
}
|
|
133
|
+
const { metaProps, labelProps } = getComputeCircularOptionPickerCommonProps(
|
|
134
|
+
asButtons,
|
|
135
|
+
loop,
|
|
136
|
+
ariaLabel,
|
|
137
|
+
ariaLabelledby
|
|
138
|
+
);
|
|
158
139
|
|
|
159
140
|
return (
|
|
160
141
|
<CircularOptionPicker
|
|
161
142
|
{ ...metaProps }
|
|
143
|
+
{ ...labelProps }
|
|
162
144
|
actions={ actions }
|
|
163
145
|
options={ options }
|
|
164
146
|
/>
|
|
@@ -285,7 +285,15 @@ export const Input = styled.input< InputProps >`
|
|
|
285
285
|
${ customPaddings }
|
|
286
286
|
|
|
287
287
|
&::-webkit-input-placeholder {
|
|
288
|
-
|
|
288
|
+
color: ${ COLORS.ui.darkGrayPlaceholder };
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
&::-moz-placeholder {
|
|
292
|
+
color: ${ COLORS.ui.darkGrayPlaceholder };
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
&:-ms-input-placeholder {
|
|
296
|
+
color: ${ COLORS.ui.darkGrayPlaceholder };
|
|
289
297
|
}
|
|
290
298
|
|
|
291
299
|
&[type='email'],
|
|
@@ -57,7 +57,7 @@ export default function BottomSheetSwitchCell( props ) {
|
|
|
57
57
|
accessibilityRole="none"
|
|
58
58
|
accessibilityHint={
|
|
59
59
|
/* translators: accessibility text (hint for switches) */
|
|
60
|
-
__( 'Double tap to
|
|
60
|
+
__( 'Double tap to change setting' )
|
|
61
61
|
}
|
|
62
62
|
onPress={ onPress }
|
|
63
63
|
editable={ false }
|
package/src/notice/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Notices are color-coded to indicate the type of message being communicated:
|
|
|
19
19
|
- **Informational** notices are **blue** by default.
|
|
20
20
|
- If there is a parent `Theme` component with an `accent` color prop, informational notices will take on that color instead.
|
|
21
21
|
- **Success** notices are **green.**
|
|
22
|
-
- **Warning** notices are **yellow
|
|
22
|
+
- **Warning** notices are **yellow.**
|
|
23
23
|
- **Error** notices are **red.**
|
|
24
24
|
|
|
25
25
|
If an icon is included in the Notice, it should be color-coded to match the Notice state.
|
package/src/notice/style.scss
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
|
|
5
5
|
</div>
|
|
6
6
|
|
|
7
|
-
NumberControl is an enhanced HTML [`input[type="number]`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number) element.
|
|
7
|
+
NumberControl is an enhanced HTML [`input[type="number"]`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number) element.
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
@@ -229,8 +229,8 @@ function UnforwardedNumberControl(
|
|
|
229
229
|
hideHTMLArrows={ spinControls !== 'native' }
|
|
230
230
|
isDragEnabled={ isDragEnabled }
|
|
231
231
|
label={ label }
|
|
232
|
-
max={ max }
|
|
233
|
-
min={ min }
|
|
232
|
+
max={ max === Infinity ? undefined : max }
|
|
233
|
+
min={ min === -Infinity ? undefined : min }
|
|
234
234
|
ref={ mergedRef }
|
|
235
235
|
required={ required }
|
|
236
236
|
step={ step }
|
|
@@ -36,7 +36,7 @@ const QUERY_DEFAULTS = {
|
|
|
36
36
|
|
|
37
37
|
const MyQueryControls = () => {
|
|
38
38
|
const [ query, setQuery ] = useState( QUERY_DEFAULTS );
|
|
39
|
-
const { category, categories, maxItems, minItems, numberOfItems, order, orderBy
|
|
39
|
+
const { category, categories, maxItems, minItems, numberOfItems, order, orderBy } = query;
|
|
40
40
|
|
|
41
41
|
const updateQuery = ( newQuery ) => {
|
|
42
42
|
setQuery( { ...query, ...newQuery } );
|
|
@@ -213,7 +213,14 @@ The order in which to retrieve posts.
|
|
|
213
213
|
- Required: No
|
|
214
214
|
- Platform: Web
|
|
215
215
|
|
|
216
|
-
#### `orderBy`: `'date' | 'title'`
|
|
216
|
+
#### `orderBy`: `'date' | 'title' | 'menu_order'`
|
|
217
|
+
|
|
218
|
+
The meta key by which to order posts.
|
|
219
|
+
|
|
220
|
+
- Required: No
|
|
221
|
+
- Platform: Web
|
|
222
|
+
|
|
223
|
+
#### `orderByOptions`: `OrderByOption[]`
|
|
217
224
|
|
|
218
225
|
The meta key by which to order posts.
|
|
219
226
|
|
|
@@ -246,4 +253,4 @@ The selected category for the `categoriesList` prop.
|
|
|
246
253
|
Start opting into the larger default height that will become the default size in a future version.
|
|
247
254
|
|
|
248
255
|
- Required: No
|
|
249
|
-
- Default: `false`
|
|
256
|
+
- Default: `false`
|
|
@@ -14,7 +14,7 @@ import CategorySelect from './category-select';
|
|
|
14
14
|
const DEFAULT_MIN_ITEMS = 1;
|
|
15
15
|
const DEFAULT_MAX_ITEMS = 100;
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const defaultOrderByOptions = [
|
|
18
18
|
{
|
|
19
19
|
label: __( 'Newest to oldest' ),
|
|
20
20
|
value: 'date/desc',
|
|
@@ -42,6 +42,7 @@ const QueryControls = memo(
|
|
|
42
42
|
numberOfItems,
|
|
43
43
|
order,
|
|
44
44
|
orderBy,
|
|
45
|
+
orderByOptions = defaultOrderByOptions,
|
|
45
46
|
maxItems = DEFAULT_MAX_ITEMS,
|
|
46
47
|
minItems = DEFAULT_MIN_ITEMS,
|
|
47
48
|
onCategoryChange,
|
|
@@ -68,7 +69,7 @@ const QueryControls = memo(
|
|
|
68
69
|
<SelectControl
|
|
69
70
|
label={ __( 'Order by' ) }
|
|
70
71
|
value={ `${ orderBy }/${ order }` }
|
|
71
|
-
options={
|
|
72
|
+
options={ orderByOptions }
|
|
72
73
|
onChange={ onChange }
|
|
73
74
|
hideCancelButton
|
|
74
75
|
/>
|
|
@@ -16,6 +16,7 @@ import type {
|
|
|
16
16
|
QueryControlsProps,
|
|
17
17
|
QueryControlsWithMultipleCategorySelectionProps,
|
|
18
18
|
QueryControlsWithSingleCategorySelectionProps,
|
|
19
|
+
OrderByOption,
|
|
19
20
|
} from './types';
|
|
20
21
|
|
|
21
22
|
const DEFAULT_MIN_ITEMS = 1;
|
|
@@ -34,13 +35,34 @@ function isMultipleCategorySelection(
|
|
|
34
35
|
return 'categorySuggestions' in props;
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
const defaultOrderByOptions: OrderByOption[] = [
|
|
39
|
+
{
|
|
40
|
+
label: __( 'Newest to oldest' ),
|
|
41
|
+
value: 'date/desc',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
label: __( 'Oldest to newest' ),
|
|
45
|
+
value: 'date/asc',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
/* translators: Label for ordering posts by title in ascending order. */
|
|
49
|
+
label: __( 'A → Z' ),
|
|
50
|
+
value: 'title/asc',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
/* translators: Label for ordering posts by title in descending order. */
|
|
54
|
+
label: __( 'Z → A' ),
|
|
55
|
+
value: 'title/desc',
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
|
|
37
59
|
/**
|
|
38
60
|
* Controls to query for posts.
|
|
39
61
|
*
|
|
40
62
|
* ```jsx
|
|
41
63
|
* const MyQueryControls = () => (
|
|
42
64
|
* <QueryControls
|
|
43
|
-
* { ...{ maxItems, minItems, numberOfItems, order, orderBy } }
|
|
65
|
+
* { ...{ maxItems, minItems, numberOfItems, order, orderBy, orderByOptions } }
|
|
44
66
|
* onOrderByChange={ ( newOrderBy ) => {
|
|
45
67
|
* updateQuery( { orderBy: newOrderBy } )
|
|
46
68
|
* }
|
|
@@ -65,6 +87,7 @@ export function QueryControls( {
|
|
|
65
87
|
numberOfItems,
|
|
66
88
|
order,
|
|
67
89
|
orderBy,
|
|
90
|
+
orderByOptions = defaultOrderByOptions,
|
|
68
91
|
maxItems = DEFAULT_MAX_ITEMS,
|
|
69
92
|
minItems = DEFAULT_MIN_ITEMS,
|
|
70
93
|
onAuthorChange,
|
|
@@ -89,26 +112,7 @@ export function QueryControls( {
|
|
|
89
112
|
? undefined
|
|
90
113
|
: `${ orderBy }/${ order }`
|
|
91
114
|
}
|
|
92
|
-
options={
|
|
93
|
-
{
|
|
94
|
-
label: __( 'Newest to oldest' ),
|
|
95
|
-
value: 'date/desc',
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
label: __( 'Oldest to newest' ),
|
|
99
|
-
value: 'date/asc',
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
/* translators: Label for ordering posts by title in ascending order. */
|
|
103
|
-
label: __( 'A → Z' ),
|
|
104
|
-
value: 'title/asc',
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
/* translators: Label for ordering posts by title in descending order. */
|
|
108
|
-
label: __( 'Z → A' ),
|
|
109
|
-
value: 'title/desc',
|
|
110
|
-
},
|
|
111
|
-
] }
|
|
115
|
+
options={ orderByOptions }
|
|
112
116
|
onChange={ ( value ) => {
|
|
113
117
|
if ( typeof value !== 'string' ) {
|
|
114
118
|
return;
|
|
@@ -45,7 +45,18 @@ export type AuthorSelectProps = Pick<
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
type Order = 'asc' | 'desc';
|
|
48
|
-
type OrderBy = 'date' | 'title';
|
|
48
|
+
type OrderBy = 'date' | 'title' | 'menu_order';
|
|
49
|
+
|
|
50
|
+
export type OrderByOption = {
|
|
51
|
+
/**
|
|
52
|
+
* The label to be shown to the user.
|
|
53
|
+
*/
|
|
54
|
+
label: string;
|
|
55
|
+
/**
|
|
56
|
+
* Option value passed to `onChange` when the option is selected.
|
|
57
|
+
*/
|
|
58
|
+
value: `${ OrderBy }/${ Order }`;
|
|
59
|
+
};
|
|
49
60
|
|
|
50
61
|
type BaseQueryControlsProps = {
|
|
51
62
|
/**
|
|
@@ -99,6 +110,10 @@ type BaseQueryControlsProps = {
|
|
|
99
110
|
* The meta key by which to order posts.
|
|
100
111
|
*/
|
|
101
112
|
orderBy?: OrderBy;
|
|
113
|
+
/**
|
|
114
|
+
* List of available ordering options.
|
|
115
|
+
*/
|
|
116
|
+
orderByOptions?: OrderByOption[];
|
|
102
117
|
/**
|
|
103
118
|
* The selected author ID.
|
|
104
119
|
*/
|
|
@@ -62,7 +62,6 @@ export const StyledTextarea = styled.textarea`
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
&::-moz-placeholder {
|
|
65
|
-
opacity: 1; // Necessary because Firefox reduces this from 1.
|
|
66
65
|
color: ${ COLORS.ui.darkGrayPlaceholder };
|
|
67
66
|
}
|
|
68
67
|
|
|
@@ -76,7 +75,6 @@ export const StyledTextarea = styled.textarea`
|
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
&::-moz-placeholder {
|
|
79
|
-
opacity: 1; // Necessary because Firefox reduces this from 1.
|
|
80
78
|
color: ${ COLORS.ui.lightGrayPlaceholder };
|
|
81
79
|
}
|
|
82
80
|
|