@wordpress/create-block-interactive-template 1.9.0 → 1.10.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/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 1.10.0 (2023-11-29)
6
+
7
+ ### Enhancement
8
+
9
+ - Update `view.js` and `render.php` templates to the new `store()` API. [#56613](https://github.com/WordPress/gutenberg/pull/56613)
10
+
5
11
  ## 1.9.0 (2023-11-16)
6
12
 
7
13
  ## 1.8.0 (2023-11-02)
@@ -11,26 +11,26 @@
11
11
  * @see https://github.com/WordPress/gutenberg/blob/trunk/docs/reference-guides/block-api/block-metadata.md#render
12
12
  */
13
13
 
14
- $unique_id = uniqid( 'p-' );
14
+ $unique_id = wp_unique_id( 'p-' );
15
15
  ?>
16
16
 
17
17
  <div
18
18
  <?php echo get_block_wrapper_attributes(); ?>
19
- data-wp-interactive
20
- data-wp-context='{ "{{namespace}}": { "isOpen": false } }'
21
- data-wp-effect="effects.{{namespace}}.logIsOpen"
19
+ data-wp-interactive='{ "namespace": "{{namespace}}" }'
20
+ data-wp-context='{ "isOpen": false }'
21
+ data-wp-watch="callbacks.logIsOpen"
22
22
  >
23
23
  <button
24
- data-wp-on--click="actions.{{namespace}}.toggle"
25
- data-wp-bind--aria-expanded="context.{{namespace}}.isOpen"
26
- aria-controls="p-<?php echo esc_attr( $unique_id ); ?>"
24
+ data-wp-on--click="actions.toggle"
25
+ data-wp-bind--aria-expanded="context.isOpen"
26
+ aria-controls="<?php echo esc_attr( $unique_id ); ?>"
27
27
  >
28
28
  <?php esc_html_e( 'Toggle', '{{textdomain}}' ); ?>
29
29
  </button>
30
30
 
31
31
  <p
32
- id="p-<?php echo esc_attr( $unique_id ); ?>"
33
- data-wp-bind--hidden="!context.{{namespace}}.isOpen"
32
+ id="<?php echo esc_attr( $unique_id ); ?>"
33
+ data-wp-bind--hidden="!context.isOpen"
34
34
  >
35
35
  <?php
36
36
  esc_html_e( '{{title}} - hello from an interactive block!', '{{textdomain}}' );
@@ -1,26 +1,23 @@
1
1
  {{#isBasicVariant}}
2
-
3
2
  /**
4
3
  * WordPress dependencies
5
4
  */
6
- import { store } from "@wordpress/interactivity";
5
+ import { store, getContext } from "@wordpress/interactivity";
7
6
 
8
- store( {
7
+ store( '{{namespace}}', {
9
8
  actions: {
10
- '{{namespace}}': {
11
- toggle: ( { context } ) => {
12
- context[ '{{namespace}}' ].isOpen = !context[ '{{namespace}}' ].isOpen;
13
- },
9
+ toggle: () => {
10
+ const context = getContext();
11
+ context.isOpen = ! context.isOpen;
14
12
  },
15
13
  },
16
- effects: {
17
- '{{namespace}}': {
18
- logIsOpen: ( { context } ) => {
19
- // Log the value of `isOpen` each time it changes.
20
- console.log( `Is open: ${ context[ '{{namespace}}' ].isOpen }` );
21
- },
14
+ callbacks: {
15
+ logIsOpen: () => {
16
+ const { isOpen } = getContext();
17
+ // Log the value of `isOpen` each time it changes.
18
+ console.log( `Is open: ${ isOpen }` );
22
19
  },
23
20
  },
24
21
  } );
25
22
 
26
- {{/isBasicVariant}}
23
+ {{/isBasicVariant}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/create-block-interactive-template",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "Template for @wordpress/create-block to create interactive blocks with the Interactivity API.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -22,5 +22,5 @@
22
22
  "publishConfig": {
23
23
  "access": "public"
24
24
  },
25
- "gitHead": "839018ff6029ba749780e288e08ff9cd898e50e8"
25
+ "gitHead": "d98dff8ea96f29cfea045bf964269f46f040d539"
26
26
  }