@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.
Files changed (85) hide show
  1. package/build/accordion-content/edit.js +8 -8
  2. package/build/accordion-content/edit.js.map +1 -1
  3. package/build/accordion-content/index.js +2 -1
  4. package/build/accordion-content/index.js.map +1 -1
  5. package/build/accordion-panel/index.js +2 -1
  6. package/build/accordion-panel/index.js.map +1 -1
  7. package/build/navigation/constants.js +5 -1
  8. package/build/navigation/constants.js.map +1 -1
  9. package/build/navigation/edit/index.js +45 -1
  10. package/build/navigation/edit/index.js.map +1 -1
  11. package/build/navigation/edit/leaf-more-menu.js +0 -1
  12. package/build/navigation/edit/leaf-more-menu.js.map +1 -1
  13. package/build/navigation/edit/menu-inspector-controls.js +40 -5
  14. package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
  15. package/build/navigation-link/block-inserter.js +69 -0
  16. package/build/navigation-link/block-inserter.js.map +1 -0
  17. package/build/navigation-link/dialog-wrapper.js +80 -0
  18. package/build/navigation-link/dialog-wrapper.js.map +1 -0
  19. package/build/navigation-link/link-ui.js +80 -120
  20. package/build/navigation-link/link-ui.js.map +1 -1
  21. package/build/navigation-link/page-creator.js +137 -0
  22. package/build/navigation-link/page-creator.js.map +1 -0
  23. package/build/search/edit.js +22 -14
  24. package/build/search/edit.js.map +1 -1
  25. package/build-module/accordion-content/edit.js +8 -8
  26. package/build-module/accordion-content/edit.js.map +1 -1
  27. package/build-module/accordion-content/index.js +2 -1
  28. package/build-module/accordion-content/index.js.map +1 -1
  29. package/build-module/accordion-panel/index.js +2 -1
  30. package/build-module/accordion-panel/index.js.map +1 -1
  31. package/build-module/navigation/constants.js +5 -1
  32. package/build-module/navigation/constants.js.map +1 -1
  33. package/build-module/navigation/edit/index.js +50 -4
  34. package/build-module/navigation/edit/index.js.map +1 -1
  35. package/build-module/navigation/edit/leaf-more-menu.js +0 -1
  36. package/build-module/navigation/edit/leaf-more-menu.js.map +1 -1
  37. package/build-module/navigation/edit/menu-inspector-controls.js +40 -5
  38. package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
  39. package/build-module/navigation-link/block-inserter.js +61 -0
  40. package/build-module/navigation-link/block-inserter.js.map +1 -0
  41. package/build-module/navigation-link/dialog-wrapper.js +75 -0
  42. package/build-module/navigation-link/dialog-wrapper.js.map +1 -0
  43. package/build-module/navigation-link/link-ui.js +85 -125
  44. package/build-module/navigation-link/link-ui.js.map +1 -1
  45. package/build-module/navigation-link/page-creator.js +130 -0
  46. package/build-module/navigation-link/page-creator.js.map +1 -0
  47. package/build-module/search/edit.js +22 -14
  48. package/build-module/search/edit.js.map +1 -1
  49. package/build-style/accordion/style-rtl.css +5 -6
  50. package/build-style/accordion/style.css +5 -6
  51. package/build-style/editor-rtl.css +14 -0
  52. package/build-style/editor.css +14 -0
  53. package/build-style/form-input/style-rtl.css +4 -3
  54. package/build-style/form-input/style.css +4 -3
  55. package/build-style/navigation-link/editor-rtl.css +14 -0
  56. package/build-style/navigation-link/editor.css +14 -0
  57. package/build-style/navigation-link/style-rtl.css +1 -1
  58. package/build-style/navigation-link/style.css +1 -1
  59. package/build-style/post-comments-form/style-rtl.css +8 -5
  60. package/build-style/post-comments-form/style.css +8 -5
  61. package/build-style/search/style-rtl.css +11 -12
  62. package/build-style/search/style.css +11 -12
  63. package/build-style/style-rtl.css +29 -27
  64. package/build-style/style.css +29 -27
  65. package/package.json +35 -35
  66. package/src/accordion/style.scss +6 -6
  67. package/src/accordion-content/block.json +2 -1
  68. package/src/accordion-content/edit.js +21 -27
  69. package/src/accordion-panel/block.json +2 -1
  70. package/src/cover/test/edit.js +1 -5
  71. package/src/form-input/style.scss +3 -2
  72. package/src/navigation/constants.js +4 -0
  73. package/src/navigation/edit/index.js +50 -1
  74. package/src/navigation/edit/leaf-more-menu.js +0 -1
  75. package/src/navigation/edit/menu-inspector-controls.js +40 -5
  76. package/src/navigation-link/block-inserter.js +65 -0
  77. package/src/navigation-link/dialog-wrapper.js +74 -0
  78. package/src/navigation-link/editor.scss +17 -0
  79. package/src/navigation-link/link-ui.js +108 -164
  80. package/src/navigation-link/page-creator.js +157 -0
  81. package/src/navigation-link/style.scss +1 -1
  82. package/src/post-comments-form/style.scss +11 -11
  83. package/src/search/edit.js +44 -13
  84. package/src/search/index.php +16 -2
  85. 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
+ }
@@ -16,7 +16,7 @@
16
16
  }
17
17
 
18
18
  .link-ui-tools {
19
- border-top: 1px solid $gray-100;
19
+ outline: 1px solid $gray-100;
20
20
  padding: $grid-unit-10;
21
21
  }
22
22
 
@@ -1,16 +1,16 @@
1
1
  // Allow these default styles to be overridden by global styles.
2
- :where(.wp-block-post-comments-form) {
3
- textarea,
4
- input:not([type="submit"]) {
5
- border: 1px solid $gray-600;
6
- font-size: 1em;
7
- font-family: inherit;
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
- textarea,
11
- input:where(:not([type="submit"]):not([type="checkbox"])) {
12
- padding: calc(0.667em + 2px); // The extra 2px is added to match outline buttons.
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 {
@@ -228,7 +228,17 @@ export default function SearchEdit( {
228
228
  );
229
229
  const textFieldStyles = {
230
230
  ...( isButtonPositionInside
231
- ? { borderRadius }
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
- ? { borderRadius }
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
- radius ? `calc(${ radius } + ${ DEFAULT_INNER_PADDING })` : undefined;
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
- const isNonZeroBorderRadius =
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 { topLeft, topRight, bottomLeft, bottomRight } =
528
- borderRadius;
549
+ const {
550
+ borderTopLeftRadius,
551
+ borderTopRightRadius,
552
+ borderBottomLeftRadius,
553
+ borderBottomRightRadius,
554
+ } = borderProps.style;
529
555
 
530
556
  return {
531
557
  ...styles,
532
- borderTopLeftRadius: padBorderRadius( topLeft ),
533
- borderTopRightRadius: padBorderRadius( topRight ),
534
- borderBottomLeftRadius: padBorderRadius( bottomLeft ),
535
- borderBottomRightRadius: padBorderRadius( bottomRight ),
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
 
@@ -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 = is_numeric( $border_radius ) ? $border_radius . 'px' : $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;
@@ -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 solid $gray-600;
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