@wordpress/patterns 1.6.0 → 1.8.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 (45) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/category-selector.js +2 -1
  3. package/build/components/category-selector.js.map +1 -1
  4. package/build/components/create-pattern-modal.js +7 -4
  5. package/build/components/create-pattern-modal.js.map +1 -1
  6. package/build/components/duplicate-pattern-modal.js +3 -3
  7. package/build/components/duplicate-pattern-modal.js.map +1 -1
  8. package/build/components/index.js +4 -2
  9. package/build/components/index.js.map +1 -1
  10. package/build/components/pattern-convert-button.js +7 -4
  11. package/build/components/pattern-convert-button.js.map +1 -1
  12. package/build/components/patterns-manage-button.js +4 -5
  13. package/build/components/patterns-manage-button.js.map +1 -1
  14. package/build/constants.js +3 -3
  15. package/build/constants.js.map +1 -1
  16. package/build/private-apis.js +1 -1
  17. package/build/private-apis.js.map +1 -1
  18. package/build-module/components/category-selector.js +2 -1
  19. package/build-module/components/category-selector.js.map +1 -1
  20. package/build-module/components/create-pattern-modal.js +8 -5
  21. package/build-module/components/create-pattern-modal.js.map +1 -1
  22. package/build-module/components/duplicate-pattern-modal.js +4 -4
  23. package/build-module/components/duplicate-pattern-modal.js.map +1 -1
  24. package/build-module/components/index.js +4 -2
  25. package/build-module/components/index.js.map +1 -1
  26. package/build-module/components/pattern-convert-button.js +7 -4
  27. package/build-module/components/pattern-convert-button.js.map +1 -1
  28. package/build-module/components/patterns-manage-button.js +4 -5
  29. package/build-module/components/patterns-manage-button.js.map +1 -1
  30. package/build-module/constants.js +1 -1
  31. package/build-module/constants.js.map +1 -1
  32. package/build-module/private-apis.js +2 -2
  33. package/build-module/private-apis.js.map +1 -1
  34. package/build-style/style-rtl.css +6 -9
  35. package/build-style/style.css +6 -9
  36. package/package.json +16 -16
  37. package/src/components/category-selector.js +1 -0
  38. package/src/components/create-pattern-modal.js +10 -4
  39. package/src/components/duplicate-pattern-modal.js +7 -6
  40. package/src/components/index.js +2 -1
  41. package/src/components/pattern-convert-button.js +10 -4
  42. package/src/components/patterns-manage-button.js +37 -40
  43. package/src/components/style.scss +9 -14
  44. package/src/constants.js +1 -2
  45. package/src/private-apis.js +2 -2
@@ -16,41 +16,40 @@ import { store as patternsStore } from '../store';
16
16
  import { unlock } from '../lock-unlock';
17
17
 
18
18
  function PatternsManageButton( { clientId } ) {
19
- const { canRemove, isVisible, innerBlockCount, managePatternsUrl } =
20
- useSelect(
21
- ( select ) => {
22
- const { getBlock, canRemoveBlock, getBlockCount, getSettings } =
23
- select( blockEditorStore );
24
- const { canUser } = select( coreStore );
25
- const reusableBlock = getBlock( clientId );
26
- const isBlockTheme = getSettings().__unstableIsBlockBasedTheme;
19
+ const { canRemove, isVisible, managePatternsUrl } = useSelect(
20
+ ( select ) => {
21
+ const { getBlock, canRemoveBlock, getBlockCount, getSettings } =
22
+ select( blockEditorStore );
23
+ const { canUser } = select( coreStore );
24
+ const reusableBlock = getBlock( clientId );
25
+ const isBlockTheme = getSettings().__unstableIsBlockBasedTheme;
27
26
 
28
- return {
29
- canRemove: canRemoveBlock( clientId ),
30
- isVisible:
31
- !! reusableBlock &&
32
- isReusableBlock( reusableBlock ) &&
33
- !! canUser(
34
- 'update',
35
- 'blocks',
36
- reusableBlock.attributes.ref
37
- ),
38
- innerBlockCount: getBlockCount( clientId ),
39
- // The site editor and templates both check whether the user
40
- // has edit_theme_options capabilities. We can leverage that here
41
- // and omit the manage patterns link if the user can't access it.
42
- managePatternsUrl:
43
- isBlockTheme && canUser( 'read', 'templates' )
44
- ? addQueryArgs( 'site-editor.php', {
45
- path: '/patterns',
46
- } )
47
- : addQueryArgs( 'edit.php', {
48
- post_type: 'wp_block',
49
- } ),
50
- };
51
- },
52
- [ clientId ]
53
- );
27
+ return {
28
+ canRemove: canRemoveBlock( clientId ),
29
+ isVisible:
30
+ !! reusableBlock &&
31
+ isReusableBlock( reusableBlock ) &&
32
+ !! canUser(
33
+ 'update',
34
+ 'blocks',
35
+ reusableBlock.attributes.ref
36
+ ),
37
+ innerBlockCount: getBlockCount( clientId ),
38
+ // The site editor and templates both check whether the user
39
+ // has edit_theme_options capabilities. We can leverage that here
40
+ // and omit the manage patterns link if the user can't access it.
41
+ managePatternsUrl:
42
+ isBlockTheme && canUser( 'read', 'templates' )
43
+ ? addQueryArgs( 'site-editor.php', {
44
+ path: '/patterns',
45
+ } )
46
+ : addQueryArgs( 'edit.php', {
47
+ post_type: 'wp_block',
48
+ } ),
49
+ };
50
+ },
51
+ [ clientId ]
52
+ );
54
53
 
55
54
  // Ignore reason: false positive of the lint rule.
56
55
  // eslint-disable-next-line @wordpress/no-unused-vars-before-return
@@ -64,18 +63,16 @@ function PatternsManageButton( { clientId } ) {
64
63
 
65
64
  return (
66
65
  <>
67
- <MenuItem href={ managePatternsUrl }>
68
- { __( 'Manage patterns' ) }
69
- </MenuItem>
70
66
  { canRemove && (
71
67
  <MenuItem
72
68
  onClick={ () => convertSyncedPatternToStatic( clientId ) }
73
69
  >
74
- { innerBlockCount > 1
75
- ? __( 'Detach patterns' )
76
- : __( 'Detach pattern' ) }
70
+ { __( 'Detach' ) }
77
71
  </MenuItem>
78
72
  ) }
73
+ <MenuItem href={ managePatternsUrl }>
74
+ { __( 'Manage patterns' ) }
75
+ </MenuItem>
79
76
  </>
80
77
  );
81
78
  }
@@ -7,32 +7,27 @@
7
7
  }
8
8
 
9
9
  .patterns-menu-items__convert-modal-categories {
10
- width: 100%;
11
10
  position: relative;
12
- min-height: 40px;
13
11
  }
14
- .components-form-token-field__suggestions-list {
12
+
13
+ .components-form-token-field__suggestions-list:not(:empty) {
15
14
  position: absolute;
15
+ border: $border-width solid var(--wp-admin-theme-color);
16
+ border-bottom-left-radius: $radius-block-ui;
17
+ border-bottom-right-radius: $radius-block-ui;
18
+ box-shadow: 0 0 0.5px 0.5px var(--wp-admin-theme-color);
16
19
  box-sizing: border-box;
17
20
  z-index: 1;
18
21
  background-color: $white;
19
- // Account for the border width of the token field.
20
- width: calc(100% + 2px);
22
+ width: calc(100% + 2px); // Account for the border width of the token field.
21
23
  left: -1px;
22
24
  min-width: initial;
23
- border: 1px solid var(--wp-admin-theme-color);
24
- border-top: none;
25
- box-shadow: 0 0 0 0.5px var(--wp-admin-theme-color);
26
- border-bottom-left-radius: 2px;
27
- border-bottom-right-radius: 2px;
25
+ max-height: $grid-unit-60 * 2; // Adjust to not cover the save button, showing three items.
28
26
  }
29
27
  }
30
28
 
31
29
  .patterns-create-modal__name-input input[type="text"] {
32
- // Match the minimal height of the category selector.
33
- min-height: 40px;
34
- // Override the default 1px margin-x.
35
- margin: 0;
30
+ margin: 0; // Override the default 1px margin-x.
36
31
  }
37
32
 
38
33
  .patterns-rename-pattern-category-modal__validation-message {
package/src/constants.js CHANGED
@@ -5,11 +5,10 @@ export const PATTERN_TYPES = {
5
5
 
6
6
  export const PATTERN_DEFAULT_CATEGORY = 'all-patterns';
7
7
  export const PATTERN_USER_CATEGORY = 'my-patterns';
8
- export const PATTERN_CORE_SOURCES = [
8
+ export const EXCLUDED_PATTERN_SOURCES = [
9
9
  'core',
10
10
  'pattern-directory/core',
11
11
  'pattern-directory/featured',
12
- 'pattern-directory/theme',
13
12
  ];
14
13
  export const PATTERN_SYNC_TYPES = {
15
14
  full: 'fully',
@@ -11,7 +11,7 @@ import {
11
11
  PATTERN_TYPES,
12
12
  PATTERN_DEFAULT_CATEGORY,
13
13
  PATTERN_USER_CATEGORY,
14
- PATTERN_CORE_SOURCES,
14
+ EXCLUDED_PATTERN_SOURCES,
15
15
  PATTERN_SYNC_TYPES,
16
16
  } from './constants';
17
17
 
@@ -25,6 +25,6 @@ lock( privateApis, {
25
25
  PATTERN_TYPES,
26
26
  PATTERN_DEFAULT_CATEGORY,
27
27
  PATTERN_USER_CATEGORY,
28
- PATTERN_CORE_SOURCES,
28
+ EXCLUDED_PATTERN_SOURCES,
29
29
  PATTERN_SYNC_TYPES,
30
30
  } );