@wordpress/block-library 9.30.0 → 9.30.1-next.6870dfe5b.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/build/accordion-content/edit.js +8 -8
- package/build/accordion-content/edit.js.map +1 -1
- package/build/accordion-content/index.js +2 -1
- package/build/accordion-content/index.js.map +1 -1
- package/build/accordion-panel/index.js +2 -1
- package/build/accordion-panel/index.js.map +1 -1
- package/build/navigation/constants.js +5 -1
- package/build/navigation/constants.js.map +1 -1
- package/build/navigation/edit/index.js +45 -1
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/leaf-more-menu.js +0 -1
- package/build/navigation/edit/leaf-more-menu.js.map +1 -1
- package/build/navigation/edit/menu-inspector-controls.js +40 -5
- package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build/navigation-link/block-inserter.js +69 -0
- package/build/navigation-link/block-inserter.js.map +1 -0
- package/build/navigation-link/dialog-wrapper.js +80 -0
- package/build/navigation-link/dialog-wrapper.js.map +1 -0
- package/build/navigation-link/link-ui.js +80 -120
- package/build/navigation-link/link-ui.js.map +1 -1
- package/build/navigation-link/page-creator.js +137 -0
- package/build/navigation-link/page-creator.js.map +1 -0
- package/build/search/edit.js +22 -14
- package/build/search/edit.js.map +1 -1
- package/build-module/accordion-content/edit.js +8 -8
- package/build-module/accordion-content/edit.js.map +1 -1
- package/build-module/accordion-content/index.js +2 -1
- package/build-module/accordion-content/index.js.map +1 -1
- package/build-module/accordion-panel/index.js +2 -1
- package/build-module/accordion-panel/index.js.map +1 -1
- package/build-module/navigation/constants.js +5 -1
- package/build-module/navigation/constants.js.map +1 -1
- package/build-module/navigation/edit/index.js +50 -4
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/leaf-more-menu.js +0 -1
- package/build-module/navigation/edit/leaf-more-menu.js.map +1 -1
- package/build-module/navigation/edit/menu-inspector-controls.js +40 -5
- package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build-module/navigation-link/block-inserter.js +61 -0
- package/build-module/navigation-link/block-inserter.js.map +1 -0
- package/build-module/navigation-link/dialog-wrapper.js +75 -0
- package/build-module/navigation-link/dialog-wrapper.js.map +1 -0
- package/build-module/navigation-link/link-ui.js +85 -125
- package/build-module/navigation-link/link-ui.js.map +1 -1
- package/build-module/navigation-link/page-creator.js +130 -0
- package/build-module/navigation-link/page-creator.js.map +1 -0
- package/build-module/search/edit.js +22 -14
- package/build-module/search/edit.js.map +1 -1
- package/build-style/accordion/style-rtl.css +5 -6
- package/build-style/accordion/style.css +5 -6
- package/build-style/editor-rtl.css +14 -0
- package/build-style/editor.css +14 -0
- package/build-style/form-input/style-rtl.css +4 -3
- package/build-style/form-input/style.css +4 -3
- package/build-style/navigation-link/editor-rtl.css +14 -0
- package/build-style/navigation-link/editor.css +14 -0
- package/build-style/navigation-link/style-rtl.css +1 -1
- package/build-style/navigation-link/style.css +1 -1
- package/build-style/post-comments-form/style-rtl.css +8 -5
- package/build-style/post-comments-form/style.css +8 -5
- package/build-style/search/style-rtl.css +11 -12
- package/build-style/search/style.css +11 -12
- package/build-style/style-rtl.css +29 -27
- package/build-style/style.css +29 -27
- package/package.json +35 -35
- package/src/accordion/style.scss +6 -6
- package/src/accordion-content/block.json +2 -1
- package/src/accordion-content/edit.js +21 -27
- package/src/accordion-panel/block.json +2 -1
- package/src/cover/test/edit.js +1 -5
- package/src/form-input/style.scss +3 -2
- package/src/navigation/constants.js +4 -0
- package/src/navigation/edit/index.js +50 -1
- package/src/navigation/edit/leaf-more-menu.js +0 -1
- package/src/navigation/edit/menu-inspector-controls.js +40 -5
- package/src/navigation-link/block-inserter.js +65 -0
- package/src/navigation-link/dialog-wrapper.js +74 -0
- package/src/navigation-link/editor.scss +17 -0
- package/src/navigation-link/link-ui.js +108 -164
- package/src/navigation-link/page-creator.js +157 -0
- package/src/navigation-link/style.scss +1 -1
- package/src/post-comments-form/style.scss +11 -11
- package/src/search/edit.js +44 -13
- package/src/search/index.php +16 -2
- package/src/search/style.scss +15 -16
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
TextControl,
|
|
7
|
+
Notice,
|
|
8
|
+
CheckboxControl,
|
|
9
|
+
__experimentalVStack as VStack,
|
|
10
|
+
__experimentalHStack as HStack,
|
|
11
|
+
} from '@wordpress/components';
|
|
12
|
+
import { __ } from '@wordpress/i18n';
|
|
13
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
14
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
15
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
16
|
+
import { useState } from '@wordpress/element';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Internal dependencies
|
|
20
|
+
*/
|
|
21
|
+
import DialogWrapper from './dialog-wrapper';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Component for creating new pages within the Navigation Link UI.
|
|
25
|
+
*
|
|
26
|
+
* @param {Object} props Component props.
|
|
27
|
+
* @param {string} props.postType The post type to create.
|
|
28
|
+
* @param {Function} props.onBack Callback when user wants to go back.
|
|
29
|
+
* @param {Function} props.onPageCreated Callback when page is successfully created.
|
|
30
|
+
* @param {string} [props.initialTitle] Initial title to pre-fill the form.
|
|
31
|
+
*/
|
|
32
|
+
export function LinkUIPageCreator( {
|
|
33
|
+
postType,
|
|
34
|
+
onBack,
|
|
35
|
+
onPageCreated,
|
|
36
|
+
initialTitle = '',
|
|
37
|
+
} ) {
|
|
38
|
+
const [ title, setTitle ] = useState( initialTitle );
|
|
39
|
+
const [ shouldPublish, setShouldPublish ] = useState( false );
|
|
40
|
+
|
|
41
|
+
// Check if the title is valid for submission
|
|
42
|
+
const isTitleValid = title.trim().length > 0;
|
|
43
|
+
|
|
44
|
+
// Get the last created entity record (without ID) to track creation state
|
|
45
|
+
const { lastError, isSaving } = useSelect(
|
|
46
|
+
( select ) => ( {
|
|
47
|
+
lastError: select( coreStore ).getLastEntitySaveError(
|
|
48
|
+
'postType',
|
|
49
|
+
postType
|
|
50
|
+
),
|
|
51
|
+
isSaving: select( coreStore ).isSavingEntityRecord(
|
|
52
|
+
'postType',
|
|
53
|
+
postType
|
|
54
|
+
),
|
|
55
|
+
} ),
|
|
56
|
+
[ postType ]
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const { saveEntityRecord } = useDispatch( coreStore );
|
|
60
|
+
|
|
61
|
+
async function createPage( event ) {
|
|
62
|
+
event.preventDefault();
|
|
63
|
+
if ( isSaving || ! isTitleValid ) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
const savedRecord = await saveEntityRecord(
|
|
69
|
+
'postType',
|
|
70
|
+
postType,
|
|
71
|
+
{
|
|
72
|
+
title,
|
|
73
|
+
status: shouldPublish ? 'publish' : 'draft',
|
|
74
|
+
},
|
|
75
|
+
{ throwOnError: true }
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
if ( savedRecord ) {
|
|
79
|
+
// Create the page link object from the saved record
|
|
80
|
+
const pageLink = {
|
|
81
|
+
id: savedRecord.id,
|
|
82
|
+
type: postType,
|
|
83
|
+
title: decodeEntities( savedRecord.title.rendered ),
|
|
84
|
+
url: savedRecord.link,
|
|
85
|
+
kind: 'post-type',
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
onPageCreated( pageLink );
|
|
89
|
+
}
|
|
90
|
+
} catch ( error ) {
|
|
91
|
+
// Error handling is done via the data store selectors
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const isSubmitDisabled = isSaving || ! isTitleValid;
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<DialogWrapper
|
|
99
|
+
className="link-ui-page-creator"
|
|
100
|
+
title={ __( 'Create page' ) }
|
|
101
|
+
description={ __( 'Create a new page to add to your Navigation.' ) }
|
|
102
|
+
onBack={ onBack }
|
|
103
|
+
>
|
|
104
|
+
<VStack className="link-ui-page-creator__inner" spacing={ 4 }>
|
|
105
|
+
<form onSubmit={ createPage }>
|
|
106
|
+
<VStack spacing={ 4 }>
|
|
107
|
+
<TextControl
|
|
108
|
+
__next40pxDefaultSize
|
|
109
|
+
__nextHasNoMarginBottom
|
|
110
|
+
label={ __( 'Title' ) }
|
|
111
|
+
onChange={ setTitle }
|
|
112
|
+
placeholder={ __( 'No title' ) }
|
|
113
|
+
value={ title }
|
|
114
|
+
/>
|
|
115
|
+
|
|
116
|
+
<CheckboxControl
|
|
117
|
+
__nextHasNoMarginBottom
|
|
118
|
+
label={ __( 'Publish immediately' ) }
|
|
119
|
+
help={ __(
|
|
120
|
+
'If unchecked, the page will be created as a draft.'
|
|
121
|
+
) }
|
|
122
|
+
checked={ shouldPublish }
|
|
123
|
+
onChange={ setShouldPublish }
|
|
124
|
+
/>
|
|
125
|
+
|
|
126
|
+
{ lastError && (
|
|
127
|
+
<Notice status="error" isDismissible={ false }>
|
|
128
|
+
{ lastError.message }
|
|
129
|
+
</Notice>
|
|
130
|
+
) }
|
|
131
|
+
|
|
132
|
+
<HStack spacing={ 2 } justify="flex-end">
|
|
133
|
+
<Button
|
|
134
|
+
__next40pxDefaultSize
|
|
135
|
+
variant="tertiary"
|
|
136
|
+
onClick={ onBack }
|
|
137
|
+
disabled={ isSaving }
|
|
138
|
+
accessibleWhenDisabled
|
|
139
|
+
>
|
|
140
|
+
{ __( 'Cancel' ) }
|
|
141
|
+
</Button>
|
|
142
|
+
<Button
|
|
143
|
+
__next40pxDefaultSize
|
|
144
|
+
variant="primary"
|
|
145
|
+
type="submit"
|
|
146
|
+
isBusy={ isSaving }
|
|
147
|
+
aria-disabled={ isSubmitDisabled }
|
|
148
|
+
>
|
|
149
|
+
{ __( 'Create page' ) }
|
|
150
|
+
</Button>
|
|
151
|
+
</HStack>
|
|
152
|
+
</VStack>
|
|
153
|
+
</form>
|
|
154
|
+
</VStack>
|
|
155
|
+
</DialogWrapper>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// Allow these default styles to be overridden by global styles.
|
|
2
|
-
:where(.wp-block-post-comments-form)
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
:where(.wp-block-post-comments-form textarea),
|
|
3
|
+
:where(.wp-block-post-comments-form input:not([type="submit"])) {
|
|
4
|
+
border-width: 1px;
|
|
5
|
+
border-style: solid;
|
|
6
|
+
border-color: $gray-600;
|
|
7
|
+
font-size: 1em;
|
|
8
|
+
font-family: inherit;
|
|
9
|
+
}
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
11
|
+
:where(.wp-block-post-comments-form textarea),
|
|
12
|
+
:where(.wp-block-post-comments-form input:where(:not([type="submit"]):not([type="checkbox"]))) {
|
|
13
|
+
padding: calc(0.667em + 2px); // The extra 2px is added to match outline buttons.
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
.wp-block-post-comments-form {
|
package/src/search/edit.js
CHANGED
|
@@ -228,7 +228,17 @@ export default function SearchEdit( {
|
|
|
228
228
|
);
|
|
229
229
|
const textFieldStyles = {
|
|
230
230
|
...( isButtonPositionInside
|
|
231
|
-
? {
|
|
231
|
+
? {
|
|
232
|
+
borderRadius: borderProps.style?.borderRadius,
|
|
233
|
+
borderTopLeftRadius:
|
|
234
|
+
borderProps.style?.borderTopLeftRadius,
|
|
235
|
+
borderTopRightRadius:
|
|
236
|
+
borderProps.style?.borderTopRightRadius,
|
|
237
|
+
borderBottomLeftRadius:
|
|
238
|
+
borderProps.style?.borderBottomLeftRadius,
|
|
239
|
+
borderBottomRightRadius:
|
|
240
|
+
borderProps.style?.borderBottomRightRadius,
|
|
241
|
+
}
|
|
232
242
|
: borderProps.style ),
|
|
233
243
|
...typographyProps.style,
|
|
234
244
|
textDecoration: undefined,
|
|
@@ -269,7 +279,17 @@ export default function SearchEdit( {
|
|
|
269
279
|
...colorProps.style,
|
|
270
280
|
...typographyProps.style,
|
|
271
281
|
...( isButtonPositionInside
|
|
272
|
-
? {
|
|
282
|
+
? {
|
|
283
|
+
borderRadius: borderProps.style?.borderRadius,
|
|
284
|
+
borderTopLeftRadius:
|
|
285
|
+
borderProps.style?.borderTopLeftRadius,
|
|
286
|
+
borderTopRightRadius:
|
|
287
|
+
borderProps.style?.borderTopRightRadius,
|
|
288
|
+
borderBottomLeftRadius:
|
|
289
|
+
borderProps.style?.borderBottomLeftRadius,
|
|
290
|
+
borderBottomRightRadius:
|
|
291
|
+
borderProps.style?.borderBottomRightRadius,
|
|
292
|
+
}
|
|
273
293
|
: borderProps.style ),
|
|
274
294
|
};
|
|
275
295
|
const handleButtonClick = () => {
|
|
@@ -495,8 +515,13 @@ export default function SearchEdit( {
|
|
|
495
515
|
</>
|
|
496
516
|
);
|
|
497
517
|
|
|
518
|
+
const isNonZeroBorderRadius = ( radius ) =>
|
|
519
|
+
radius !== undefined && parseInt( radius, 10 ) !== 0;
|
|
520
|
+
|
|
498
521
|
const padBorderRadius = ( radius ) =>
|
|
499
|
-
|
|
522
|
+
isNonZeroBorderRadius( radius )
|
|
523
|
+
? `calc(${ radius } + ${ DEFAULT_INNER_PADDING })`
|
|
524
|
+
: undefined;
|
|
500
525
|
|
|
501
526
|
const getWrapperStyles = () => {
|
|
502
527
|
const styles = isButtonPositionInside
|
|
@@ -512,10 +537,7 @@ export default function SearchEdit( {
|
|
|
512
537
|
borderProps.style?.borderBottomRightRadius,
|
|
513
538
|
};
|
|
514
539
|
|
|
515
|
-
|
|
516
|
-
borderRadius !== undefined && parseInt( borderRadius, 10 ) !== 0;
|
|
517
|
-
|
|
518
|
-
if ( isButtonPositionInside && isNonZeroBorderRadius ) {
|
|
540
|
+
if ( isButtonPositionInside ) {
|
|
519
541
|
// We have button inside wrapper and a border radius value to apply.
|
|
520
542
|
// Add default padding so we don't get "fat" corners.
|
|
521
543
|
//
|
|
@@ -524,15 +546,24 @@ export default function SearchEdit( {
|
|
|
524
546
|
|
|
525
547
|
if ( typeof borderRadius === 'object' ) {
|
|
526
548
|
// Individual corner border radii present.
|
|
527
|
-
const {
|
|
528
|
-
|
|
549
|
+
const {
|
|
550
|
+
borderTopLeftRadius,
|
|
551
|
+
borderTopRightRadius,
|
|
552
|
+
borderBottomLeftRadius,
|
|
553
|
+
borderBottomRightRadius,
|
|
554
|
+
} = borderProps.style;
|
|
529
555
|
|
|
530
556
|
return {
|
|
531
557
|
...styles,
|
|
532
|
-
borderTopLeftRadius: padBorderRadius(
|
|
533
|
-
borderTopRightRadius:
|
|
534
|
-
|
|
535
|
-
|
|
558
|
+
borderTopLeftRadius: padBorderRadius( borderTopLeftRadius ),
|
|
559
|
+
borderTopRightRadius:
|
|
560
|
+
padBorderRadius( borderTopRightRadius ),
|
|
561
|
+
borderBottomLeftRadius: padBorderRadius(
|
|
562
|
+
borderBottomLeftRadius
|
|
563
|
+
),
|
|
564
|
+
borderBottomRightRadius: padBorderRadius(
|
|
565
|
+
borderBottomRightRadius
|
|
566
|
+
),
|
|
536
567
|
};
|
|
537
568
|
}
|
|
538
569
|
|
package/src/search/index.php
CHANGED
|
@@ -372,6 +372,13 @@ function styles_for_block_core_search( $attributes ) {
|
|
|
372
372
|
if ( is_array( $border_radius ) ) {
|
|
373
373
|
// Apply styles for individual corner border radii.
|
|
374
374
|
foreach ( $border_radius as $key => $value ) {
|
|
375
|
+
// Get border-radius CSS variable from preset value if provided.
|
|
376
|
+
if ( is_string( $value ) && str_contains( $value, 'var:preset|border-radius|' ) ) {
|
|
377
|
+
$index_to_splice = strrpos( $value, '|' ) + 1;
|
|
378
|
+
$slug = _wp_to_kebab_case( substr( $value, $index_to_splice ) );
|
|
379
|
+
$value = "var(--wp--preset--border-radius--$slug)";
|
|
380
|
+
}
|
|
381
|
+
|
|
375
382
|
if ( null !== $value ) {
|
|
376
383
|
// Convert camelCase key to kebab-case.
|
|
377
384
|
$name = strtolower( preg_replace( '/(?<!^)[A-Z]/', '-$0', $key ) );
|
|
@@ -387,7 +394,7 @@ function styles_for_block_core_search( $attributes ) {
|
|
|
387
394
|
|
|
388
395
|
// Add adjusted border radius styles for the wrapper element
|
|
389
396
|
// if button is positioned inside.
|
|
390
|
-
if ( $is_button_inside && intval( $value ) !== 0 ) {
|
|
397
|
+
if ( $is_button_inside && ( intval( $value ) !== 0 || str_contains( $value, 'var(--wp--preset--border-radius--' ) ) ) {
|
|
391
398
|
$wrapper_styles[] = sprintf(
|
|
392
399
|
'border-%s-radius: calc(%s + %s);',
|
|
393
400
|
esc_attr( $name ),
|
|
@@ -399,7 +406,14 @@ function styles_for_block_core_search( $attributes ) {
|
|
|
399
406
|
}
|
|
400
407
|
} else {
|
|
401
408
|
// Numeric check is for backwards compatibility purposes.
|
|
402
|
-
$border_radius
|
|
409
|
+
$border_radius = is_numeric( $border_radius ) ? $border_radius . 'px' : $border_radius;
|
|
410
|
+
// Get border-radius CSS variable from preset value if provided.
|
|
411
|
+
if ( is_string( $border_radius ) && str_contains( $border_radius, 'var:preset|border-radius|' ) ) {
|
|
412
|
+
$index_to_splice = strrpos( $border_radius, '|' ) + 1;
|
|
413
|
+
$slug = _wp_to_kebab_case( substr( $border_radius, $index_to_splice ) );
|
|
414
|
+
$border_radius = "var(--wp--preset--border-radius--$slug)";
|
|
415
|
+
}
|
|
416
|
+
|
|
403
417
|
$border_style = sprintf( 'border-radius: %s;', esc_attr( $border_radius ) );
|
|
404
418
|
$input_styles[] = $border_style;
|
|
405
419
|
$button_styles[] = $border_style;
|
package/src/search/style.scss
CHANGED
|
@@ -37,21 +37,6 @@ $button-spacing-y: math.div($grid-unit-15, 2); // 6px
|
|
|
37
37
|
width: 100%;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
.wp-block-search__input {
|
|
41
|
-
padding: $grid-unit-10;
|
|
42
|
-
flex-grow: 1;
|
|
43
|
-
margin-left: 0;
|
|
44
|
-
margin-right: 0;
|
|
45
|
-
min-width: 3rem;
|
|
46
|
-
border: 1px solid $gray-600;
|
|
47
|
-
// !important used to forcibly prevent undesired application of
|
|
48
|
-
// text-decoration styles on the input field.
|
|
49
|
-
text-decoration: unset !important;
|
|
50
|
-
|
|
51
|
-
// Hides a redundant extra search icon on Mobile Safari.
|
|
52
|
-
appearance: initial;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
40
|
.wp-block-search.wp-block-search__button-only {
|
|
56
41
|
.wp-block-search__button {
|
|
57
42
|
margin-left: 0;
|
|
@@ -104,12 +89,26 @@ $button-spacing-y: math.div($grid-unit-15, 2); // 6px
|
|
|
104
89
|
letter-spacing: inherit;
|
|
105
90
|
text-transform: inherit;
|
|
106
91
|
font-style: inherit;
|
|
92
|
+
padding: $grid-unit-10;
|
|
93
|
+
flex-grow: 1;
|
|
94
|
+
margin-left: 0;
|
|
95
|
+
margin-right: 0;
|
|
96
|
+
min-width: 3rem;
|
|
97
|
+
border: 1px solid $gray-600;
|
|
98
|
+
// !important used to forcibly prevent undesired application of
|
|
99
|
+
// text-decoration styles on the input field.
|
|
100
|
+
text-decoration: unset !important;
|
|
101
|
+
|
|
102
|
+
// Hides a redundant extra search icon on Mobile Safari.
|
|
103
|
+
appearance: initial;
|
|
107
104
|
}
|
|
108
105
|
|
|
109
106
|
// We are lowering the specificity so that the button element can override the rule for the button inside the search block.
|
|
110
107
|
:where(.wp-block-search__button-inside .wp-block-search__inside-wrapper) {
|
|
111
108
|
padding: $grid-unit-05;
|
|
112
|
-
border: 1px
|
|
109
|
+
border-width: 1px;
|
|
110
|
+
border-style: solid;
|
|
111
|
+
border-color: $gray-600;
|
|
113
112
|
background-color: $white;
|
|
114
113
|
box-sizing: border-box;
|
|
115
114
|
|