@wordpress/block-editor 12.10.0 → 12.10.2

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 (76) hide show
  1. package/build/components/block-patterns-list/index.js +10 -5
  2. package/build/components/block-patterns-list/index.js.map +1 -1
  3. package/build/components/block-patterns-paging/index.js +4 -2
  4. package/build/components/block-patterns-paging/index.js.map +1 -1
  5. package/build/components/inserter/block-patterns-explorer/patterns-list.js +21 -32
  6. package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
  7. package/build/components/inserter/block-patterns-explorer/sidebar.js +0 -15
  8. package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
  9. package/build/components/inserter/block-patterns-filter.js +137 -0
  10. package/build/components/inserter/block-patterns-filter.js.map +1 -0
  11. package/build/components/inserter/block-patterns-tab.js +77 -37
  12. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  13. package/build/components/inserter/hooks/use-patterns-paging.js +4 -0
  14. package/build/components/inserter/hooks/use-patterns-paging.js.map +1 -1
  15. package/build/components/inserter/search-results.js +1 -1
  16. package/build/components/inserter/search-results.js.map +1 -1
  17. package/build/components/inspector-controls-tabs/styles-tab.js +1 -1
  18. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  19. package/build/hooks/background.js +28 -23
  20. package/build/hooks/background.js.map +1 -1
  21. package/build/hooks/block-rename-ui.js +2 -1
  22. package/build/hooks/block-rename-ui.js.map +1 -1
  23. package/build/store/private-selectors.js +2 -3
  24. package/build/store/private-selectors.js.map +1 -1
  25. package/build-module/components/block-patterns-list/index.js +11 -6
  26. package/build-module/components/block-patterns-list/index.js.map +1 -1
  27. package/build-module/components/block-patterns-paging/index.js +4 -2
  28. package/build-module/components/block-patterns-paging/index.js.map +1 -1
  29. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +23 -34
  30. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
  31. package/build-module/components/inserter/block-patterns-explorer/sidebar.js +0 -14
  32. package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
  33. package/build-module/components/inserter/block-patterns-filter.js +128 -0
  34. package/build-module/components/inserter/block-patterns-filter.js.map +1 -0
  35. package/build-module/components/inserter/block-patterns-tab.js +75 -35
  36. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  37. package/build-module/components/inserter/hooks/use-patterns-paging.js +5 -1
  38. package/build-module/components/inserter/hooks/use-patterns-paging.js.map +1 -1
  39. package/build-module/components/inserter/search-results.js +1 -1
  40. package/build-module/components/inserter/search-results.js.map +1 -1
  41. package/build-module/components/inspector-controls-tabs/styles-tab.js +1 -1
  42. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  43. package/build-module/hooks/background.js +30 -25
  44. package/build-module/hooks/background.js.map +1 -1
  45. package/build-module/hooks/block-rename-ui.js +2 -1
  46. package/build-module/hooks/block-rename-ui.js.map +1 -1
  47. package/build-module/store/private-selectors.js +2 -3
  48. package/build-module/store/private-selectors.js.map +1 -1
  49. package/build-style/style-rtl.css +54 -26
  50. package/build-style/style.css +54 -26
  51. package/package.json +32 -32
  52. package/src/components/block-patterns-list/index.js +19 -12
  53. package/src/components/block-patterns-paging/index.js +58 -55
  54. package/src/components/block-patterns-paging/style.scss +16 -13
  55. package/src/components/inserter/block-patterns-explorer/patterns-list.js +34 -76
  56. package/src/components/inserter/block-patterns-explorer/sidebar.js +0 -15
  57. package/src/components/inserter/block-patterns-filter.js +183 -0
  58. package/src/components/inserter/block-patterns-tab.js +106 -58
  59. package/src/components/inserter/hooks/use-patterns-paging.js +12 -1
  60. package/src/components/inserter/search-results.js +1 -1
  61. package/src/components/inserter/style.scss +14 -5
  62. package/src/components/inspector-controls-tabs/styles-tab.js +1 -1
  63. package/src/hooks/background.js +57 -46
  64. package/src/hooks/background.scss +36 -18
  65. package/src/hooks/block-rename-ui.js +1 -0
  66. package/src/store/private-selectors.js +7 -3
  67. package/build/components/inserter/block-patterns-source-filter.js +0 -54
  68. package/build/components/inserter/block-patterns-source-filter.js.map +0 -1
  69. package/build/components/inserter/block-patterns-sync-filter.js +0 -46
  70. package/build/components/inserter/block-patterns-sync-filter.js.map +0 -1
  71. package/build-module/components/inserter/block-patterns-source-filter.js +0 -44
  72. package/build-module/components/inserter/block-patterns-source-filter.js.map +0 -1
  73. package/build-module/components/inserter/block-patterns-sync-filter.js +0 -38
  74. package/build-module/components/inserter/block-patterns-sync-filter.js.map +0 -1
  75. package/src/components/inserter/block-patterns-source-filter.js +0 -40
  76. package/src/components/inserter/block-patterns-sync-filter.js +0 -35
@@ -903,20 +903,21 @@
903
903
  fill: var(--wp-block-synced-color);
904
904
  }
905
905
 
906
- .block-editor-patterns__grid-pagination {
906
+ .block-editor-patterns__grid-pagination-wrapper .block-editor-patterns__grid-pagination {
907
907
  border-top: 1px solid #2f2f2f;
908
908
  padding: 4px;
909
+ justify-content: center;
909
910
  }
910
- .block-editor-patterns__grid-pagination .components-button.is-tertiary {
911
+ .block-editor-patterns__grid-pagination-wrapper .block-editor-patterns__grid-pagination .components-button.is-tertiary {
911
912
  width: auto;
912
913
  height: 32px;
913
914
  justify-content: center;
914
915
  }
915
- .block-editor-patterns__grid-pagination .components-button.is-tertiary:disabled {
916
+ .block-editor-patterns__grid-pagination-wrapper .block-editor-patterns__grid-pagination .components-button.is-tertiary:disabled {
916
917
  color: #949494;
917
918
  background: none;
918
919
  }
919
- .block-editor-patterns__grid-pagination .components-button.is-tertiary:hover:not(:disabled) {
920
+ .block-editor-patterns__grid-pagination-wrapper .block-editor-patterns__grid-pagination .components-button.is-tertiary:hover:not(:disabled) {
920
921
  color: #fff;
921
922
  background-color: #757575;
922
923
  }
@@ -3200,51 +3201,68 @@
3200
3201
  flex-direction: row;
3201
3202
  }
3202
3203
 
3203
- .block-editor-hooks__background__inspector-upload-container {
3204
+ .block-editor-hooks__background__inspector-media-replace-container {
3204
3205
  position: relative;
3205
3206
  }
3206
- .block-editor-hooks__background__inspector-upload-container .components-drop-zone__content-icon {
3207
+ .block-editor-hooks__background__inspector-media-replace-container .components-drop-zone__content-icon {
3207
3208
  display: none;
3208
3209
  }
3209
-
3210
- .block-editor-hooks__background__inspector-upload-container button.components-button,
3211
3210
  .block-editor-hooks__background__inspector-media-replace-container button.components-button {
3212
3211
  color: #1e1e1e;
3213
- box-shadow: inset 0 0 0 1px #ccc;
3212
+ box-shadow: inset 0 0 0 1px #ddd;
3214
3213
  width: 100%;
3215
3214
  display: block;
3216
3215
  height: 40px;
3217
3216
  }
3218
- .block-editor-hooks__background__inspector-upload-container button.components-button:hover,
3219
3217
  .block-editor-hooks__background__inspector-media-replace-container button.components-button:hover {
3220
3218
  color: var(--wp-admin-theme-color);
3221
3219
  }
3222
- .block-editor-hooks__background__inspector-upload-container button.components-button:focus,
3223
3220
  .block-editor-hooks__background__inspector-media-replace-container button.components-button:focus {
3224
3221
  box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
3225
3222
  }
3226
- .block-editor-hooks__background__inspector-upload-container .block-editor-hooks__background__inspector-media-replace-title,
3227
3223
  .block-editor-hooks__background__inspector-media-replace-container .block-editor-hooks__background__inspector-media-replace-title {
3228
3224
  word-break: break-all;
3229
3225
  white-space: normal;
3230
3226
  text-align: start;
3231
3227
  text-align-last: center;
3232
3228
  }
3233
-
3234
3229
  .block-editor-hooks__background__inspector-media-replace-container .components-dropdown {
3235
3230
  display: block;
3236
3231
  }
3237
- .block-editor-hooks__background__inspector-media-replace-container img {
3238
- width: 20px;
3239
- min-width: 20px;
3240
- aspect-ratio: 1;
3241
- box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
3232
+
3233
+ .block-editor-hooks__background__inspector-image-indicator-wrapper {
3234
+ background: #fff linear-gradient(-45deg, transparent 48%, #ddd 48%, #ddd 52%, transparent 52%);
3242
3235
  border-radius: 50% !important;
3236
+ box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
3237
+ display: block;
3238
+ width: 20px;
3239
+ height: 20px;
3240
+ flex: none;
3243
3241
  }
3244
- .block-editor-hooks__background__inspector-media-replace-container .block-editor-hooks__background__inspector-readonly-logo-preview {
3245
- padding: 6px 12px;
3246
- display: flex;
3247
- height: 40px;
3242
+ .block-editor-hooks__background__inspector-image-indicator-wrapper.has-image {
3243
+ background: #fff;
3244
+ }
3245
+
3246
+ .block-editor-hooks__background__inspector-image-indicator {
3247
+ background-size: cover;
3248
+ border-radius: 50%;
3249
+ width: 20px;
3250
+ height: 20px;
3251
+ display: block;
3252
+ position: relative;
3253
+ }
3254
+
3255
+ .block-editor-hooks__background__inspector-image-indicator::after {
3256
+ content: "";
3257
+ position: absolute;
3258
+ top: -1px;
3259
+ left: -1px;
3260
+ bottom: -1px;
3261
+ right: -1px;
3262
+ border-radius: 50%;
3263
+ box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
3264
+ border: 1px solid transparent;
3265
+ box-sizing: inherit;
3248
3266
  }
3249
3267
 
3250
3268
  .border-block-support-panel .single-column {
@@ -3834,13 +3852,10 @@
3834
3852
  border-left: 1px solid #e0e0e0;
3835
3853
  border-right: 1px solid #e0e0e0;
3836
3854
  position: absolute;
3837
- padding: 32px 24px;
3838
3855
  top: 0;
3839
3856
  left: 0;
3840
3857
  height: 100%;
3841
3858
  width: 100%;
3842
- overflow-y: auto;
3843
- scrollbar-gutter: stable both-edges;
3844
3859
  }
3845
3860
  @media (min-width: 782px) {
3846
3861
  .block-editor-inserter__patterns-category-dialog {
@@ -3850,7 +3865,10 @@
3850
3865
  }
3851
3866
  }
3852
3867
  .block-editor-inserter__patterns-category-dialog .block-editor-block-patterns-list {
3853
- margin-top: 24px;
3868
+ overflow-y: auto;
3869
+ flex-grow: 1;
3870
+ height: 100%;
3871
+ padding: 32px 24px;
3854
3872
  }
3855
3873
 
3856
3874
  .block-editor-block-patterns-list__list-item .block-editor-block-preview__container {
@@ -3862,12 +3880,21 @@
3862
3880
 
3863
3881
  .block-editor-inserter__patterns-category-panel {
3864
3882
  padding: 0 16px;
3883
+ display: flex;
3884
+ flex-direction: column;
3885
+ height: 100%;
3865
3886
  }
3866
3887
  @media (min-width: 782px) {
3867
3888
  .block-editor-inserter__patterns-category-panel {
3868
3889
  padding: 0;
3869
3890
  }
3870
3891
  }
3892
+ .block-editor-inserter__patterns-category-panel .block-editor-inserter__patterns-category-panel-header {
3893
+ padding: 16px 24px;
3894
+ }
3895
+ .block-editor-inserter__patterns-category-panel .block-editor-inserter__patterns-category-no-results {
3896
+ margin-top: 24px;
3897
+ }
3871
3898
 
3872
3899
  .block-editor-inserter__preview-content {
3873
3900
  min-height: 144px;
@@ -3988,6 +4015,7 @@
3988
4015
  display: grid;
3989
4016
  grid-gap: 32px;
3990
4017
  grid-template-columns: repeat(1, 1fr);
4018
+ margin-bottom: 16px;
3991
4019
  }
3992
4020
  @media (min-width: 1080px) {
3993
4021
  .block-editor-block-patterns-explorer .block-editor-block-patterns-list {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-editor",
3
- "version": "12.10.0",
3
+ "version": "12.10.2",
4
4
  "description": "Generic block editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -35,36 +35,36 @@
35
35
  "@emotion/react": "^11.7.1",
36
36
  "@emotion/styled": "^11.6.0",
37
37
  "@react-spring/web": "^9.4.5",
38
- "@wordpress/a11y": "^3.42.0",
39
- "@wordpress/api-fetch": "^6.39.0",
40
- "@wordpress/blob": "^3.42.0",
41
- "@wordpress/blocks": "^12.19.0",
42
- "@wordpress/commands": "^0.13.0",
43
- "@wordpress/components": "^25.8.0",
44
- "@wordpress/compose": "^6.19.0",
45
- "@wordpress/data": "^9.12.0",
46
- "@wordpress/date": "^4.42.0",
47
- "@wordpress/deprecated": "^3.42.0",
48
- "@wordpress/dom": "^3.42.0",
49
- "@wordpress/element": "^5.19.0",
50
- "@wordpress/escape-html": "^2.42.0",
51
- "@wordpress/hooks": "^3.42.0",
52
- "@wordpress/html-entities": "^3.42.0",
53
- "@wordpress/i18n": "^4.42.0",
54
- "@wordpress/icons": "^9.33.0",
55
- "@wordpress/is-shallow-equal": "^4.42.0",
56
- "@wordpress/keyboard-shortcuts": "^4.19.0",
57
- "@wordpress/keycodes": "^3.42.0",
58
- "@wordpress/notices": "^4.10.0",
59
- "@wordpress/preferences": "^3.19.0",
60
- "@wordpress/private-apis": "^0.24.0",
61
- "@wordpress/rich-text": "^6.19.0",
62
- "@wordpress/shortcode": "^3.42.0",
63
- "@wordpress/style-engine": "^1.25.0",
64
- "@wordpress/token-list": "^2.42.0",
65
- "@wordpress/url": "^3.43.0",
66
- "@wordpress/warning": "^2.42.0",
67
- "@wordpress/wordcount": "^3.42.0",
38
+ "@wordpress/a11y": "^3.42.2",
39
+ "@wordpress/api-fetch": "^6.39.2",
40
+ "@wordpress/blob": "^3.42.2",
41
+ "@wordpress/blocks": "^12.19.2",
42
+ "@wordpress/commands": "^0.13.2",
43
+ "@wordpress/components": "^25.8.2",
44
+ "@wordpress/compose": "^6.19.2",
45
+ "@wordpress/data": "^9.12.2",
46
+ "@wordpress/date": "^4.42.2",
47
+ "@wordpress/deprecated": "^3.42.2",
48
+ "@wordpress/dom": "^3.42.2",
49
+ "@wordpress/element": "^5.19.2",
50
+ "@wordpress/escape-html": "^2.42.2",
51
+ "@wordpress/hooks": "^3.42.2",
52
+ "@wordpress/html-entities": "^3.42.2",
53
+ "@wordpress/i18n": "^4.42.2",
54
+ "@wordpress/icons": "^9.33.2",
55
+ "@wordpress/is-shallow-equal": "^4.42.2",
56
+ "@wordpress/keyboard-shortcuts": "^4.19.2",
57
+ "@wordpress/keycodes": "^3.42.2",
58
+ "@wordpress/notices": "^4.10.2",
59
+ "@wordpress/preferences": "^3.19.2",
60
+ "@wordpress/private-apis": "^0.24.2",
61
+ "@wordpress/rich-text": "^6.19.2",
62
+ "@wordpress/shortcode": "^3.42.2",
63
+ "@wordpress/style-engine": "^1.25.2",
64
+ "@wordpress/token-list": "^2.42.2",
65
+ "@wordpress/url": "^3.43.2",
66
+ "@wordpress/warning": "^2.42.2",
67
+ "@wordpress/wordcount": "^3.42.2",
68
68
  "change-case": "^4.1.2",
69
69
  "classnames": "^2.3.1",
70
70
  "colord": "^2.7.0",
@@ -86,5 +86,5 @@
86
86
  "publishConfig": {
87
87
  "access": "public"
88
88
  },
89
- "gitHead": "cc35f517ed017ab7131319af3e87c359e8de175d"
89
+ "gitHead": "5d2e3d07cc97af8090fc32c1e5d5013a2967e752"
90
90
  }
@@ -6,7 +6,7 @@ import classnames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { useState } from '@wordpress/element';
9
+ import { useState, forwardRef } from '@wordpress/element';
10
10
  import {
11
11
  VisuallyHidden,
12
12
  __unstableComposite as Composite,
@@ -24,6 +24,7 @@ import { Icon, symbol } from '@wordpress/icons';
24
24
  */
25
25
  import BlockPreview from '../block-preview';
26
26
  import InserterDraggableBlocks from '../inserter-draggable-blocks';
27
+ import BlockPatternsPaging from '../block-patterns-paging';
27
28
 
28
29
  const WithToolTip = ( { showTooltip, title, children } ) => {
29
30
  if ( showTooltip ) {
@@ -140,16 +141,20 @@ function BlockPatternPlaceholder() {
140
141
  );
141
142
  }
142
143
 
143
- function BlockPatternList( {
144
- isDraggable,
145
- blockPatterns,
146
- shownPatterns,
147
- onHover,
148
- onClickPattern,
149
- orientation,
150
- label = __( 'Block Patterns' ),
151
- showTitlesAsTooltip,
152
- } ) {
144
+ function BlockPatternList(
145
+ {
146
+ isDraggable,
147
+ blockPatterns,
148
+ shownPatterns,
149
+ onHover,
150
+ onClickPattern,
151
+ orientation,
152
+ label = __( 'Block patterns' ),
153
+ showTitlesAsTooltip,
154
+ pagingProps,
155
+ },
156
+ ref
157
+ ) {
153
158
  const composite = useCompositeState( { orientation } );
154
159
  return (
155
160
  <Composite
@@ -157,6 +162,7 @@ function BlockPatternList( {
157
162
  role="listbox"
158
163
  className="block-editor-block-patterns-list"
159
164
  aria-label={ label }
165
+ ref={ ref }
160
166
  >
161
167
  { blockPatterns.map( ( pattern ) => {
162
168
  const isShown = shownPatterns.includes( pattern );
@@ -174,8 +180,9 @@ function BlockPatternList( {
174
180
  <BlockPatternPlaceholder key={ pattern.name } />
175
181
  );
176
182
  } ) }
183
+ { pagingProps && <BlockPatternsPaging { ...pagingProps } /> }
177
184
  </Composite>
178
185
  );
179
186
  }
180
187
 
181
- export default BlockPatternList;
188
+ export default forwardRef( BlockPatternList );
@@ -16,7 +16,7 @@ export default function Pagination( {
16
16
  totalItems,
17
17
  } ) {
18
18
  return (
19
- <VStack>
19
+ <VStack className="block-editor-patterns__grid-pagination-wrapper">
20
20
  <Text variant="muted">
21
21
  {
22
22
  // translators: %s: Total number of patterns.
@@ -27,66 +27,69 @@ export default function Pagination( {
27
27
  )
28
28
  }
29
29
  </Text>
30
- <HStack
31
- expanded={ false }
32
- spacing={ 3 }
33
- justify="flex-start"
34
- className="block-editor-patterns__grid-pagination"
35
- >
36
- <HStack
37
- expanded={ false }
38
- spacing={ 1 }
39
- className="block-editor-patterns__grid-pagination-previous"
40
- >
41
- <Button
42
- variant="tertiary"
43
- onClick={ () => changePage( 1 ) }
44
- disabled={ currentPage === 1 }
45
- aria-label={ __( 'First page' ) }
46
- >
47
- <span>«</span>
48
- </Button>
49
- <Button
50
- variant="tertiary"
51
- onClick={ () => changePage( currentPage - 1 ) }
52
- disabled={ currentPage === 1 }
53
- aria-label={ __( 'Previous page' ) }
54
- >
55
- <span>‹</span>
56
- </Button>
57
- </HStack>
58
- <Text variant="muted">
59
- { sprintf(
60
- // translators: %1$s: Current page number, %2$s: Total number of pages.
61
- _x( '%1$s of %2$s', 'paging' ),
62
- currentPage,
63
- numPages
64
- ) }
65
- </Text>
30
+
31
+ { numPages > 1 && (
66
32
  <HStack
67
33
  expanded={ false }
68
- spacing={ 1 }
69
- className="block-editor-patterns__grid-pagination-next"
34
+ spacing={ 3 }
35
+ justify="flex-start"
36
+ className="block-editor-patterns__grid-pagination"
70
37
  >
71
- <Button
72
- variant="tertiary"
73
- onClick={ () => changePage( currentPage + 1 ) }
74
- disabled={ currentPage === numPages }
75
- aria-label={ __( 'Next page' ) }
38
+ <HStack
39
+ expanded={ false }
40
+ spacing={ 1 }
41
+ className="block-editor-patterns__grid-pagination-previous"
76
42
  >
77
- <span>›</span>
78
- </Button>
79
- <Button
80
- variant="tertiary"
81
- onClick={ () => changePage( numPages ) }
82
- disabled={ currentPage === numPages }
83
- aria-label={ __( 'Last page' ) }
84
- size="default"
43
+ <Button
44
+ variant="tertiary"
45
+ onClick={ () => changePage( 1 ) }
46
+ disabled={ currentPage === 1 }
47
+ aria-label={ __( 'First page' ) }
48
+ >
49
+ <span>«</span>
50
+ </Button>
51
+ <Button
52
+ variant="tertiary"
53
+ onClick={ () => changePage( currentPage - 1 ) }
54
+ disabled={ currentPage === 1 }
55
+ aria-label={ __( 'Previous page' ) }
56
+ >
57
+ <span>‹</span>
58
+ </Button>
59
+ </HStack>
60
+ <Text variant="muted">
61
+ { sprintf(
62
+ // translators: %1$s: Current page number, %2$s: Total number of pages.
63
+ _x( '%1$s of %2$s', 'paging' ),
64
+ currentPage,
65
+ numPages
66
+ ) }
67
+ </Text>
68
+ <HStack
69
+ expanded={ false }
70
+ spacing={ 1 }
71
+ className="block-editor-patterns__grid-pagination-next"
85
72
  >
86
- <span>»</span>
87
- </Button>
73
+ <Button
74
+ variant="tertiary"
75
+ onClick={ () => changePage( currentPage + 1 ) }
76
+ disabled={ currentPage === numPages }
77
+ aria-label={ __( 'Next page' ) }
78
+ >
79
+ <span>›</span>
80
+ </Button>
81
+ <Button
82
+ variant="tertiary"
83
+ onClick={ () => changePage( numPages ) }
84
+ disabled={ currentPage === numPages }
85
+ aria-label={ __( 'Last page' ) }
86
+ size="default"
87
+ >
88
+ <span>»</span>
89
+ </Button>
90
+ </HStack>
88
91
  </HStack>
89
- </HStack>
92
+ ) }
90
93
  </VStack>
91
94
  );
92
95
  }
@@ -1,20 +1,23 @@
1
- .block-editor-patterns__grid-pagination {
2
- border-top: 1px solid $gray-800;
3
- padding: $grid-unit-05;
1
+ .block-editor-patterns__grid-pagination-wrapper {
4
2
 
5
- .components-button.is-tertiary {
6
- width: auto;
7
- height: $button-size-compact;
3
+ .block-editor-patterns__grid-pagination {
4
+ border-top: 1px solid $gray-800;
5
+ padding: $grid-unit-05;
8
6
  justify-content: center;
7
+ .components-button.is-tertiary {
8
+ width: auto;
9
+ height: $button-size-compact;
10
+ justify-content: center;
9
11
 
10
- &:disabled {
11
- color: $gray-600;
12
- background: none;
13
- }
12
+ &:disabled {
13
+ color: $gray-600;
14
+ background: none;
15
+ }
14
16
 
15
- &:hover:not(:disabled) {
16
- color: $white;
17
- background-color: $gray-700;
17
+ &:hover:not(:disabled) {
18
+ color: $white;
19
+ background-color: $gray-700;
20
+ }
18
21
  }
19
22
  }
20
23
  }
@@ -17,31 +17,13 @@ import InserterListbox from '../../inserter-listbox';
17
17
  import { searchItems } from '../search-items';
18
18
  import BlockPatternsPaging from '../../block-patterns-paging';
19
19
  import usePatternsPaging from '../hooks/use-patterns-paging';
20
- import { allPatternsCategory, isPatternFiltered } from '../block-patterns-tab';
21
- import { BlockPatternsSyncFilter } from '../block-patterns-sync-filter';
22
- import {
23
- PATTERN_TYPES,
24
- PATTERN_SOURCE_FILTERS,
25
- } from '../block-patterns-source-filter';
26
-
27
- function PatternsListHeader( {
28
- filterValue,
29
- filteredBlockPatternsLength,
30
- selectedCategory,
31
- patternCategories,
32
- } ) {
20
+ import { allPatternsCategory, myPatternsCategory } from '../block-patterns-tab';
21
+
22
+ function PatternsListHeader( { filterValue, filteredBlockPatternsLength } ) {
33
23
  if ( ! filterValue ) {
34
24
  return null;
35
25
  }
36
- let filter = filterValue;
37
- if ( selectedCategory !== allPatternsCategory.name ) {
38
- const category = patternCategories.find(
39
- ( patternCategory ) => patternCategory.name === selectedCategory
40
- );
41
- if ( category ) {
42
- filter = `${ filter } - ${ category?.label }`;
43
- }
44
- }
26
+
45
27
  return (
46
28
  <Heading
47
29
  level={ 2 }
@@ -49,26 +31,19 @@ function PatternsListHeader( {
49
31
  className="block-editor-block-patterns-explorer__search-results-count"
50
32
  >
51
33
  { sprintf(
52
- /* translators: %d: number of patterns. %s: block pattern search query */
34
+ /* translators: %d: number of patterns. */
53
35
  _n(
54
- '%1$d pattern found for "%2$s"',
55
- '%1$d patterns found for "%2$s"',
36
+ '%d pattern found',
37
+ '%d patterns found',
56
38
  filteredBlockPatternsLength
57
39
  ),
58
- filteredBlockPatternsLength,
59
- filter
40
+ filteredBlockPatternsLength
60
41
  ) }
61
42
  </Heading>
62
43
  );
63
44
  }
64
45
 
65
- function PatternList( {
66
- searchValue,
67
- patternSourceFilter,
68
- selectedCategory,
69
- patternCategories,
70
- } ) {
71
- const [ patternSyncFilter, setPatternSyncFilter ] = useState( 'all' );
46
+ function PatternList( { searchValue, selectedCategory, patternCategories } ) {
72
47
  const container = useRef();
73
48
  const debouncedSpeak = useDebounce( speak, 500 );
74
49
  const [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {
@@ -89,20 +64,12 @@ function PatternList( {
89
64
 
90
65
  const filteredBlockPatterns = useMemo( () => {
91
66
  const filteredPatterns = patterns.filter( ( pattern ) => {
92
- if (
93
- isPatternFiltered(
94
- pattern,
95
- patternSourceFilter,
96
- patternSyncFilter
97
- )
98
- ) {
99
- return false;
100
- }
101
-
102
67
  if ( selectedCategory === allPatternsCategory.name ) {
103
68
  return true;
104
69
  }
105
-
70
+ if ( selectedCategory === myPatternsCategory.name && pattern.id ) {
71
+ return true;
72
+ }
106
73
  if ( selectedCategory === 'uncategorized' ) {
107
74
  const hasKnownCategory = pattern.categories.some(
108
75
  ( category ) =>
@@ -119,18 +86,12 @@ function PatternList( {
119
86
  return filteredPatterns;
120
87
  }
121
88
 
122
- return searchItems(
123
- filteredPatterns,
124
- searchValue,
125
- patternSourceFilter
126
- );
89
+ return searchItems( filteredPatterns, searchValue );
127
90
  }, [
128
91
  searchValue,
129
- patternSourceFilter,
130
92
  patterns,
131
93
  selectedCategory,
132
94
  registeredPatternCategories,
133
- patternSyncFilter,
134
95
  ] );
135
96
 
136
97
  // Announce search results on change.
@@ -150,10 +111,17 @@ function PatternList( {
150
111
  const pagingProps = usePatternsPaging(
151
112
  filteredBlockPatterns,
152
113
  selectedCategory,
153
- container,
154
- patternSourceFilter
114
+ container
155
115
  );
156
116
 
117
+ // Reset page when search value changes.
118
+ const [ previousSearchValue, setPreviousSearchValue ] =
119
+ useState( searchValue );
120
+ if ( searchValue !== previousSearchValue ) {
121
+ setPreviousSearchValue( searchValue );
122
+ pagingProps.changePage( 1 );
123
+ }
124
+
157
125
  const hasItems = !! filteredBlockPatterns?.length;
158
126
  return (
159
127
  <div
@@ -161,33 +129,23 @@ function PatternList( {
161
129
  ref={ container }
162
130
  >
163
131
  <PatternsListHeader
164
- filterValue={
165
- searchValue || PATTERN_SOURCE_FILTERS[ patternSourceFilter ]
166
- }
132
+ filterValue={ searchValue }
167
133
  filteredBlockPatternsLength={ filteredBlockPatterns.length }
168
- selectedCategory={ selectedCategory }
169
- patternCategories={ patternCategories }
170
134
  />
171
135
 
172
136
  <InserterListbox>
173
- { patternSourceFilter === PATTERN_TYPES.user &&
174
- ! searchValue && (
175
- <BlockPatternsSyncFilter
176
- patternSyncFilter={ patternSyncFilter }
177
- setPatternSyncFilter={ setPatternSyncFilter }
178
- />
179
- ) }
180
-
181
137
  { hasItems && (
182
- <BlockPatternsList
183
- shownPatterns={ pagingProps.categoryPatternsAsyncList }
184
- blockPatterns={ pagingProps.categoryPatterns }
185
- onClickPattern={ onClickPattern }
186
- isDraggable={ false }
187
- />
188
- ) }
189
- { pagingProps.numPages > 1 && (
190
- <BlockPatternsPaging { ...pagingProps } />
138
+ <>
139
+ <BlockPatternsList
140
+ shownPatterns={
141
+ pagingProps.categoryPatternsAsyncList
142
+ }
143
+ blockPatterns={ pagingProps.categoryPatterns }
144
+ onClickPattern={ onClickPattern }
145
+ isDraggable={ false }
146
+ />
147
+ <BlockPatternsPaging { ...pagingProps } />
148
+ </>
191
149
  ) }
192
150
  </InserterListbox>
193
151
  </div>