@automattic/newspack-blocks 3.0.4 → 3.0.5-alpha.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.
Files changed (30) hide show
  1. package/.cache/babel/7170efa5ce57b069b83f283e91811450.json.gz +0 -0
  2. package/.cache/babel/b28476e53228af2a7d6a9e55a5d63e64.json.gz +0 -0
  3. package/.cache/babel/c19be800a50892a02f080513c40bccbd.json.gz +0 -0
  4. package/.cache/babel/daa1bb86cfbd47c4ba1fc391d8194453.json.gz +0 -0
  5. package/.eslintrc.js +3 -0
  6. package/CHANGELOG.md +12 -2
  7. package/composer.lock +12 -12
  8. package/dist/editor.asset.php +1 -1
  9. package/dist/editor.js +2 -2
  10. package/includes/class-modal-checkout.php +42 -0
  11. package/includes/class-newspack-blocks-api.php +10 -11
  12. package/includes/class-newspack-blocks.php +43 -0
  13. package/includes/plugins/class-the-events-calendar.php +84 -0
  14. package/newspack-blocks.php +4 -2
  15. package/package.json +2 -2
  16. package/src/blocks/author-profile/class-wp-rest-newspack-authors-controller.php +42 -30
  17. package/src/blocks/carousel/edit.js +2 -2
  18. package/src/blocks/homepage-articles/{edit.js → edit.tsx} +34 -33
  19. package/src/blocks/homepage-articles/templates/article.php +3 -2
  20. package/src/blocks/homepage-articles/utils.ts +8 -31
  21. package/src/components/editor-panels.js +14 -3
  22. package/src/types/index.d.ts +109 -0
  23. package/vendor/autoload.php +1 -1
  24. package/vendor/composer/autoload_real.php +4 -4
  25. package/vendor/composer/autoload_static.php +2 -2
  26. package/vendor/composer/installed.php +2 -2
  27. package/.cache/babel/2fa9c6a361abed0c298ce473e621c94c.json.gz +0 -0
  28. package/.cache/babel/538ade6c2456b5eff86c58dc45c63d8a.json.gz +0 -0
  29. package/.cache/babel/6868f766c1c67a550ee0fb3a6ac463de.json.gz +0 -0
  30. package/.cache/babel/fdd76bf50199728a7f02fe0f3bf347cd.json.gz +0 -0
@@ -44,34 +44,6 @@ const POST_QUERY_ATTRIBUTES = [
44
44
  'showCredit',
45
45
  ];
46
46
 
47
- type HomepageArticlesAttributes = {
48
- postsToShow: number;
49
- authors: AuthorId[];
50
- categories: CategoryId[];
51
- includeSubcategories: boolean;
52
- excerptLength: number;
53
- postType: PostType[];
54
- showExcerpt: boolean;
55
- tags: TagId[];
56
- customTaxonomies: Taxonomy[];
57
- specificPosts: string[];
58
- specificMode: boolean;
59
- tagExclusions: TagId[];
60
- categoryExclusions: CategoryId[];
61
- customTaxonomyExclusions: Taxonomy[];
62
- showCaption: boolean;
63
- showCredit: boolean;
64
- };
65
-
66
- type HomepageArticlesProps = {
67
- attributes: HomepageArticlesAttributes;
68
- topBlocksClientIdsInOrder: Block[ 'clientId' ][];
69
- latestPosts: Post[];
70
- isEditorBlock: boolean;
71
- isUIDisabled: boolean;
72
- error: undefined | string;
73
- };
74
-
75
47
  /**
76
48
  * Does the props change necessitate a reflow?
77
49
  * A reflow should happen if:
@@ -184,12 +156,16 @@ const generatePreviewPost = ( id: PostId ) => {
184
156
  content: {
185
157
  rendered: '<p>' + __( 'The post content.', 'newspack-blocks' ) + '</p>',
186
158
  },
187
- date_gmt: now.toISOString(),
159
+ date: now.toISOString(),
160
+ date_formatted: now.toLocaleString(),
161
+ article_meta_footer: '',
188
162
  excerpt: {
189
163
  rendered: '<p>' + __( 'The post excerpt.', 'newspack-blocks' ) + '</p>',
190
164
  },
165
+ post_link: '/',
191
166
  featured_media: '1',
192
167
  id,
168
+ post_type: 'post',
193
169
  meta: {
194
170
  newspack_post_subtitle: __( 'Post Subtitle', 'newspack-blocks' ),
195
171
  },
@@ -215,7 +191,8 @@ const generatePreviewPost = ( id: PostId ) => {
215
191
  uncropped: `${ PREVIEW_IMAGE_BASE }/newspack-1024x536.jpg`,
216
192
  },
217
193
  newspack_has_custom_excerpt: false,
218
- newspack_post_sponsors: false,
194
+ newspack_sponsors_show_categories: false,
195
+ newspack_sponsors_show_author: false,
219
196
  };
220
197
  };
221
198
 
@@ -244,7 +221,7 @@ export const postsBlockSelector = (
244
221
  clientId,
245
222
  attributes,
246
223
  }: { clientId: Block[ 'clientId' ]; attributes: HomepageArticlesAttributes }
247
- ): Omit< HomepageArticlesProps, 'attributes' > => {
224
+ ): HomepageArticlesPropsFromDataSelector => {
248
225
  const { getEditedPostAttribute } = select( 'core/editor' );
249
226
  const editorBlocks = getEditedPostAttribute( 'blocks' ) || [];
250
227
  const { getBlocks } = select( 'core/block-editor' );
@@ -31,10 +31,21 @@ const CheckboxesGroup = ( { options, values, onChange } ) => {
31
31
  export const PostTypesPanel = ( { attributes, setAttributes } ) => {
32
32
  const { availablePostTypes } = useSelect( select => {
33
33
  const { getPostTypes } = select( 'core' );
34
+ const listingsLabel = __( 'Listings', 'newspack-blocks' );
34
35
  return {
35
- availablePostTypes: getPostTypes( { per_page: -1 } )?.filter(
36
- ( { supports: { newspack_blocks: newspackBlocks } } ) => newspackBlocks
37
- ),
36
+ availablePostTypes: getPostTypes( { per_page: -1 } )
37
+ ?.filter( ( { supports: { newspack_blocks: newspackBlocks } } ) => newspackBlocks )
38
+ ?.map( postType => {
39
+ // Disambiguate the "Listings" post types.
40
+ if (
41
+ postType.slug.indexOf( 'newspack_lst' ) === 0 &&
42
+ postType.slug !== 'newspack_lst_generic' &&
43
+ postType.name.indexOf( listingsLabel ) === -1
44
+ ) {
45
+ postType.name = `${ postType.name } ${ listingsLabel }`;
46
+ }
47
+ return postType;
48
+ } ),
38
49
  };
39
50
  } );
40
51
 
@@ -8,6 +8,7 @@ declare global {
8
8
  supports_recaptcha: boolean;
9
9
  has_recaptcha: boolean;
10
10
  recaptcha_url: string;
11
+ post_subtitle: boolean;
11
12
  can_use_name_your_price: boolean;
12
13
  tier_amounts_template: string;
13
14
  };
@@ -54,6 +55,114 @@ declare global {
54
55
 
55
56
  type Post = {
56
57
  id: number;
58
+ title: {
59
+ rendered: string;
60
+ };
61
+ post_type: string;
62
+ date: string;
63
+ date_formatted: string;
64
+ article_meta_footer: string;
65
+ excerpt: {
66
+ rendered: string;
67
+ };
68
+ meta: {
69
+ newspack_post_subtitle: string;
70
+ };
71
+ post_link: string;
72
+ newspack_author_info: {
73
+ id: number;
74
+ author_link: string;
75
+ avatar: string;
76
+ }[];
77
+ newspack_article_classes: string;
78
+ newspack_featured_image_caption: string;
79
+ newspack_featured_image_src: {
80
+ large: string;
81
+ landscape: string;
82
+ portrait: string;
83
+ square: string;
84
+ uncropped: string;
85
+ };
86
+ newspack_category_info: string;
87
+ newspack_sponsors_show_categories: boolean;
88
+ newspack_sponsors_show_author: boolean;
89
+ newspack_post_sponsors?:
90
+ | {
91
+ flag: string;
92
+ }[]
93
+ | false;
94
+ newspack_listings_hide_author?: boolean;
95
+ newspack_listings_hide_publish_date?: boolean;
96
+ };
97
+
98
+ type HomepageArticlesAttributes = {
99
+ postsToShow: number;
100
+ authors: AuthorId[];
101
+ categories: CategoryId[];
102
+ includeSubcategories: boolean;
103
+ excerptLength: number;
104
+ postType: PostType[];
105
+ showImage: boolean;
106
+ showExcerpt: boolean;
107
+ tags: TagId[];
108
+ customTaxonomies: Taxonomy[];
109
+ specificPosts: string[];
110
+ specificMode: boolean;
111
+ tagExclusions: TagId[];
112
+ categoryExclusions: CategoryId[];
113
+ customTaxonomyExclusions: Taxonomy[];
114
+ className: string;
115
+ showExcerpt: boolean;
116
+ excerptLength: number;
117
+ showReadMore: boolean;
118
+ readMoreLabel: string;
119
+ showDate: boolean;
120
+ showImage: boolean;
121
+ showCaption: boolean;
122
+ showCredit: boolean;
123
+ disableImageLazyLoad: boolean;
124
+ fetchPriority: string;
125
+ imageShape: string;
126
+ minHeight: integer;
127
+ moreButton: boolean;
128
+ moreButtonText: string;
129
+ showAuthor: boolean;
130
+ showAvatar: boolean;
131
+ showCategory: boolean;
132
+ postLayout: string;
133
+ columns: integer;
134
+ colGap: integer;
135
+ postsToShow: integer;
136
+ mediaPosition: string;
137
+ showSubtitle: boolean;
138
+ sectionHeader: string;
139
+ imageScale: number;
140
+ mobileStack: boolean;
141
+ typeScale: number;
142
+ textAlign: string;
143
+ deduplicate: boolean;
144
+ };
145
+
146
+ type HomepageArticlesAttributesKey = keyof HomepageArticlesAttributes;
147
+
148
+ type HomepageArticlesPropsFromDataSelector = {
149
+ topBlocksClientIdsInOrder: Block['clientId'][];
150
+ latestPosts: Post[];
151
+ isEditorBlock: boolean;
152
+ isUIDisabled: boolean;
153
+ error: undefined | string;
154
+ };
155
+
156
+ type HomepageArticlesProps = HomepageArticlesPropsFromDataSelector & {
157
+ attributes: HomepageArticlesAttributes;
158
+ setAttributes: (attributes: Partial<HomepageArticlesAttributes>) => void;
159
+ textColor: {
160
+ color: string;
161
+ };
162
+ setTextColor: (color: string) => void;
163
+ triggerReflow: () => void;
164
+ className: string;
165
+ isSelected: boolean;
57
166
  };
58
167
  }
59
168
 
@@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
22
22
 
23
23
  require_once __DIR__ . '/composer/autoload_real.php';
24
24
 
25
- return ComposerAutoloaderInitbf41db5fd90f71daf81a6c15709bfd19::getLoader();
25
+ return ComposerAutoloaderInit06ec7c7a70a7eef8363b26d9e1fd4ba8::getLoader();
@@ -2,7 +2,7 @@
2
2
 
3
3
  // autoload_real.php @generated by Composer
4
4
 
5
- class ComposerAutoloaderInitbf41db5fd90f71daf81a6c15709bfd19
5
+ class ComposerAutoloaderInit06ec7c7a70a7eef8363b26d9e1fd4ba8
6
6
  {
7
7
  private static $loader;
8
8
 
@@ -22,12 +22,12 @@ class ComposerAutoloaderInitbf41db5fd90f71daf81a6c15709bfd19
22
22
  return self::$loader;
23
23
  }
24
24
 
25
- spl_autoload_register(array('ComposerAutoloaderInitbf41db5fd90f71daf81a6c15709bfd19', 'loadClassLoader'), true, true);
25
+ spl_autoload_register(array('ComposerAutoloaderInit06ec7c7a70a7eef8363b26d9e1fd4ba8', 'loadClassLoader'), true, true);
26
26
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
27
- spl_autoload_unregister(array('ComposerAutoloaderInitbf41db5fd90f71daf81a6c15709bfd19', 'loadClassLoader'));
27
+ spl_autoload_unregister(array('ComposerAutoloaderInit06ec7c7a70a7eef8363b26d9e1fd4ba8', 'loadClassLoader'));
28
28
 
29
29
  require __DIR__ . '/autoload_static.php';
30
- call_user_func(\Composer\Autoload\ComposerStaticInitbf41db5fd90f71daf81a6c15709bfd19::getInitializer($loader));
30
+ call_user_func(\Composer\Autoload\ComposerStaticInit06ec7c7a70a7eef8363b26d9e1fd4ba8::getInitializer($loader));
31
31
 
32
32
  $loader->register(true);
33
33
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  namespace Composer\Autoload;
6
6
 
7
- class ComposerStaticInitbf41db5fd90f71daf81a6c15709bfd19
7
+ class ComposerStaticInit06ec7c7a70a7eef8363b26d9e1fd4ba8
8
8
  {
9
9
  public static $classMap = array (
10
10
  'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
@@ -13,7 +13,7 @@ class ComposerStaticInitbf41db5fd90f71daf81a6c15709bfd19
13
13
  public static function getInitializer(ClassLoader $loader)
14
14
  {
15
15
  return \Closure::bind(function () use ($loader) {
16
- $loader->classMap = ComposerStaticInitbf41db5fd90f71daf81a6c15709bfd19::$classMap;
16
+ $loader->classMap = ComposerStaticInit06ec7c7a70a7eef8363b26d9e1fd4ba8::$classMap;
17
17
 
18
18
  }, null, ClassLoader::class);
19
19
  }
@@ -3,7 +3,7 @@
3
3
  'name' => 'automattic/newspack-blocks',
4
4
  'pretty_version' => 'dev-trunk',
5
5
  'version' => 'dev-trunk',
6
- 'reference' => '92a7bd33dd1b8a41ecd85a62a748e743015d634a',
6
+ 'reference' => 'c21c8f7a3424be79aa4f31628cdfa80f3245e297',
7
7
  'type' => 'wordpress-plugin',
8
8
  'install_path' => __DIR__ . '/../../',
9
9
  'aliases' => array(),
@@ -13,7 +13,7 @@
13
13
  'automattic/newspack-blocks' => array(
14
14
  'pretty_version' => 'dev-trunk',
15
15
  'version' => 'dev-trunk',
16
- 'reference' => '92a7bd33dd1b8a41ecd85a62a748e743015d634a',
16
+ 'reference' => 'c21c8f7a3424be79aa4f31628cdfa80f3245e297',
17
17
  'type' => 'wordpress-plugin',
18
18
  'install_path' => __DIR__ . '/../../',
19
19
  'aliases' => array(),