Skip to content

Commit

Permalink
See pewresearch/pewresearch-org@7f25139 from refs/heads/release/5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
prcdevgitbot committed Mar 17, 2024
1 parent ea95b6d commit 1749b7d
Show file tree
Hide file tree
Showing 10 changed files with 311 additions and 100 deletions.
33 changes: 19 additions & 14 deletions blocks/form-input-checkbox/src/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,26 @@
$input_value = array_key_exists('value', $attributes) ? $attributes['value'] : '';
$input_id = md5( $target_namespace . $input_name . $input_type );

// Hoist this block's values into the target interactive namespace state.
// State is no longer "global" store, in the sense that it is not shared across all blocks on the page and is instead shared by all blocks of the same namespace on the page.
// Whereas context is a "state" store instanced to each block of the namespace.
wp_interactivity_state(
$target_namespace,
array(
$input_id => array(
'value' => $input_value,
'checked' => $input_checked,
'type' => $input_type,
'required' => $input_required,
'name' => $input_name,
$is_part_of_a_template = false;
if ( false === $is_part_of_a_template ) {
// Hoist this block's values into the target interactive namespace state.
// State is no longer "global" store, in the sense that it is not shared across all blocks on the page and is instead shared by all blocks of the same namespace on the page.
// Whereas context is a "state" store instanced to each block of the namespace.
wp_interactivity_state(
$target_namespace,
array(
$input_id => array(
'value' => $input_value,
'checked' => $input_checked,
'type' => $input_type,
'required' => $input_required,
'name' => $input_name,
),
),
),
);
);
}

// if this is part of a template then our attrs need to change to be bound to the template's context and actions and such... effectively wp interactivity template context should drive these values, not something else.

$input_attrs = array(
'id' => $input_id,
Expand Down
11 changes: 2 additions & 9 deletions blocks/form-input-select/build/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
'data-wp-on--keyup' => 'actions.onKeyUp',
'data-wp-on--focus' => 'actions.onOpen', // open the list when the input is focused
'data-wp-on--blur' => 'actions.onClose', // close the list when the input is blurred
'data-wp-bind--disabled' => 'callbacks.isDisabled',
) );
$input = wp_sprintf(
'<input %1$s />',
Expand Down Expand Up @@ -79,21 +80,13 @@
'value' => $input_value,
'label' => $input_label,
'isOpen' => false,
'isHidden' => false,
'isDisabled' => $input_disabled,
'isError' => false,
'isSuccess' => false,
'isProcessing' => false,
'filteredOptions' => $input_options,
'options' => $input_options,
)),
'data-wp-init' => 'callbacks.onInit',
'data-wp-bind--hidden' => 'context.isHidden',
'data-wp-class--is-open' => 'context.isOpen',
'data-wp-class--is-disabled' => 'context.isDisabled',
'data-wp-class--is-error' => 'context.isError',
'data-wp-class--is-success' => 'context.isSuccess',
'data-wp-class--is-processing' => 'context.isProcessing',
'data-wp-class--is-processing' => 'callbacks.isProcessing',
'style' => '--block-gap:' . \PRC\Platform\Block_Utils\get_block_gap_support_value($attributes, 'horizontal') . ';',
) );

Expand Down
2 changes: 1 addition & 1 deletion blocks/form-input-select/build/view.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('@wordpress/interactivity', 'wp-polyfill'), 'version' => '81104a98711243b90a41', 'type' => 'module');
<?php return array('dependencies' => array('@wordpress/interactivity', 'wp-polyfill'), 'version' => 'c26f9af222636add2783', 'type' => 'module');
2 changes: 1 addition & 1 deletion blocks/form-input-select/build/view.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1749b7d

Please sign in to comment.