Skip to content

Commit

Permalink
See pewresearch/pewresearch-org@84e0ac9 from refs/heads/release/5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
prcdevgitbot committed Feb 21, 2024
1 parent d4a4f86 commit 7fb51dc
Show file tree
Hide file tree
Showing 30 changed files with 19,808 additions and 14,015 deletions.
6 changes: 3 additions & 3 deletions build.sh → .scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash

# Start at the /blocks directory
cd /blocks
cd blocks || exit

# Find all directories that contain a src/block.json file
for dir in $(find . -type d -name 'src' -exec test -e '{}/block.json' ';' -print -prune | sed 's/\/src//g'); do
# Go to the directory
cd $dir
cd $dir || exit
## Check for node_modules
if [ ! -d "node_modules" ]; then
echo "Running npm install in $dir"
Expand All @@ -16,5 +16,5 @@ for dir in $(find . -type d -name 'src' -exec test -e '{}/block.json' ';' -print
echo "Running npm build in $dir"
npm run build
# Go back to the /blocks directory
cd -
cd - || exit
done
7 changes: 7 additions & 0 deletions .scripts/count.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Start at the /blocks directory
cd blocks || exit

# Count the number of directories
ls -l | grep "^d" | wc -l
1 change: 0 additions & 1 deletion blocks/form-input-select/build/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
'filteredOptions' => array(),
'options' => $input_options,
)),
// 'data-wp-on-click' => 'actions.onOpen',
'data-wp-init' => 'callbacks.onInit',
'data-wp-bind--hidden' => 'context.isHidden',
'data-wp-class--is-open' => 'context.isOpen',
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' => '8bdf0212264b484ac787', 'type' => 'module');
<?php return array('dependencies' => array('@wordpress/interactivity', 'wp-polyfill'), 'version' => '7b6a2f34a168d07543d4', '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.

2 changes: 1 addition & 1 deletion blocks/form-input-select/build/view.js.map

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions blocks/form-input-select/src/render.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace PRC\Platform\Blocks;

$target_namespace = array_key_exists( 'interactiveNamespace', $attributes ) ? $attributes['interactiveNamespace'] : null;
$target_namespace = array_key_exists( 'interactiveNamespace', $attributes ) ? $attributes['interactiveNamespace'] : 'prc-block/form-input-select';

$input_placeholder = array_key_exists( 'placeholder', $attributes ) ? $attributes['placeholder'] : 'Click to select';
$input_name = array_key_exists('metadata', $attributes) && array_key_exists('name', $attributes['metadata']) ? $attributes['metadata']['name'] : 'prc-block/form-input-select';
Expand Down Expand Up @@ -71,7 +71,6 @@
'filteredOptions' => array(),
'options' => $input_options,
)),
// 'data-wp-on-click' => 'actions.onOpen',
'data-wp-init' => 'callbacks.onInit',
'data-wp-bind--hidden' => 'context.isHidden',
'data-wp-class--is-open' => 'context.isOpen',
Expand Down
26 changes: 16 additions & 10 deletions blocks/form-input-select/src/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ const { actions } = store('prc-block/form-input-select', {
onOpen: (event) => {
const context = getContext();
context.isOpen = true;
console.log('onOpen', context, event);
},
onClose: (event = null) => {
// By default this runs on the on-blur directive on the input element
// but we also use it as a shortcut to close the listbox on click so we need to
// support an event object being passed in as well as no event object
// but we also use it as a shortcut to close the listbox on click,
// so this is a quick check to see if we're using this as a shortcut or not.
if (null !== event) {
event.preventDefault();
}
const context = getContext();
// Because the on-blur event fires before the click event we need to slow things down a bit, 100 ms should do it
let isRunning = false;
if (!isRunning) {
isRunning = true;
Expand All @@ -30,6 +30,7 @@ const { actions } = store('prc-block/form-input-select', {
context.activeIndex = 0;
context.value = '';
context.label = '';
context.filteredOptions = context.options;
},
getOptionByValue: (value) => {
console.log('getOptionByValue', value);
Expand Down Expand Up @@ -91,7 +92,7 @@ const { actions } = store('prc-block/form-input-select', {
if (event.key === 'Escape') {
actions.onReset();
if (true === context.isOpen) {
actions.onClose();
ref.blur();
}
return;
}
Expand Down Expand Up @@ -123,7 +124,6 @@ const { actions } = store('prc-block/form-input-select', {
const { ref } = getElement();
const context = getContext();
const { options } = context;
console.log('setting value on click', context, ref, event);

const id = ref.getAttribute('aria-controls');
const val = ref.getAttribute('data-ref-value');
Expand All @@ -149,22 +149,28 @@ const { actions } = store('prc-block/form-input-select', {
callbacks: {
onInit: () => {
const context = getContext();
const { ref } = getElement();
const { options } = context;
// set the filteredOptions immediately...
// set filteredOptions immediately...
context.filteredOptions = options;
},
onValueChange: () => {
const { ref } = getElement();
const context = getContext();
const { targetNamespace, value } = context;
if (value) {
console.log('onValueChange', context);
// if the value is not empty and the targetNamespace is not the same as the current namespace
// then hoist the value up to the targetNamespace
if (value && 'prc-block/form-input-select' !== targetNamespace) {
const { actions: targetActions } = store(targetNamespace);
if (targetActions.onSelectChange) {
console.log(
'onValueChange -> onSelectChange:',
context,
value,
ref
);
targetActions.onSelectChange(value, ref);
}
}
}
},
},
});
2 changes: 1 addition & 1 deletion blocks/table-of-contents/build/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,5 @@
"prc-block-library--baseball-card",
"prc-block-library--additional-color-supports"
],
"viewScript": "file:./view.js"
"viewScriptModule": "file:./view.js"
}
2 changes: 1 addition & 1 deletion blocks/table-of-contents/build/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('classnames', 'prc-block-utils', 'prc-icons', 'react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '7f67ac699bd72ab0201e');
<?php return array('dependencies' => array('classnames', 'prc-block-utils', 'prc-icons', 'react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '372ced25c6d3d5574964');
Loading

0 comments on commit 7fb51dc

Please sign in to comment.