Skip to content

Commit

Permalink
See pewresearch/pewresearch-org@94b715b from refs/tags/v1.0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
prcdevgitbot committed Aug 15, 2024
1 parent c375037 commit 079fb93
Show file tree
Hide file tree
Showing 22 changed files with 9,628 additions and 653 deletions.
2 changes: 1 addition & 1 deletion build/@prc/components/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('classnames', 'lodash', 'prc-hooks', 'react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-element', 'wp-html-entities', 'wp-i18n', 'wp-media-utils', 'wp-notices', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => '058ce2a60c6efcb1e1d0');
<?php return array('dependencies' => array('classnames', 'lodash', 'prc-hooks', 'react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-element', 'wp-html-entities', 'wp-i18n', 'wp-media-utils', 'wp-notices', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => 'f8ee5db07b971c41da15');
34 changes: 17 additions & 17 deletions build/@prc/components/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/@prc/components/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/@prc/controls/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('comma-separated-values', 'react', 'react-dom', 'wp-components', 'wp-i18n', 'wp-polyfill'), 'version' => '3abeac5cdfad484304f9');
<?php return array('dependencies' => array('comma-separated-values', 'prc-icons', 'react', 'react-dom', 'wp-components', 'wp-i18n', 'wp-polyfill'), 'version' => '1dfc5da9c0ef515fa514');
4,571 changes: 4,569 additions & 2 deletions build/@prc/controls/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/@prc/controls/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/@prc/functions/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wp-api-fetch', 'wp-core-data', 'wp-polyfill', 'wp-url'), 'version' => '56e71af2b459bde4b2a4');
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-api-fetch', 'wp-components', 'wp-core-data', 'wp-element', 'wp-polyfill', 'wp-url'), 'version' => '29927fe727b1e587d73d');
2 changes: 1 addition & 1 deletion build/@prc/functions/index.js

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

2 changes: 1 addition & 1 deletion build/@prc/functions/index.js.map

Large diffs are not rendered by default.

44 changes: 24 additions & 20 deletions src/@prc/components/term-select/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ import styled from '@emotion/styled';
* WordPress Dependencies
*/
import { FormTokenField, Spinner } from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { useEffect, useState, useMemo } from '@wordpress/element';
import { useEntityRecords } from '@wordpress/core-data';
import { useDebounce } from '@wordpress/compose';
import { decodeEntities } from '@wordpress/html-entities';
import { isEmpty } from 'lodash';
import apiFetch from '@wordpress/api-fetch';
import { addQueryArgs } from '@wordpress/url';

const TermSelectControl = styled('div')`
& .components-spinner {
Expand All @@ -26,21 +23,21 @@ const TermSelectControl = styled('div')`
}
`;

function TermSelect({
className,
onChange,
taxonomy,
value,
maxTerms,
}) {
function TermSelect({ className, onChange, taxonomy, value, maxTerms, label }) {
const l = label !== undefined ? label : `Select a ${taxonomy} term`;

const [searchTerm, setSearchTerm] = useState('');
const debounceSearchTerm = useDebounce(setSearchTerm, 500);

const { records, isResolving, hasResolved } = useEntityRecords('taxonomy', taxonomy, {
per_page: 10,
context: 'view',
search: searchTerm,
});
const { records, isResolving, hasResolved } = useEntityRecords(
'taxonomy',
taxonomy,
{
per_page: 10,
context: 'view',
search: searchTerm,
}
);

const suggestions = useMemo(() => {
if (hasResolved && records) {
Expand Down Expand Up @@ -70,28 +67,35 @@ function TermSelect({
}
const termToMatch = e[e.length - 1];
const selectedTerm = records.find(
(record) => record.name === termToMatch,
(record) => record.name === termToMatch
);

if (selectedTerm) {
// Clean the selected term so it only contains the properties we need.
const filteredTerm = Object.keys(selectedTerm)
.filter((key) =>
['id', 'name', 'slug', 'taxonomy', 'parent', 'link'].includes(
key,
[
'id',
'name',
'slug',
'taxonomy',
'parent',
'link',
].includes(
key
// eslint-disable-next-line prettier/prettier
))
.reduce(
(obj, key) => ({
...obj,
[key]: selectedTerm[key],
}),
{},
{}
);
onChange(filteredTerm);
}
}}
label={`Select a ${taxonomy} term`}
label={l}
maxLength={maxTerms}
__experimentalShowHowTo={false}
/>
Expand Down
84 changes: 6 additions & 78 deletions src/@prc/controls/package-lock.json

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

Loading

0 comments on commit 079fb93

Please sign in to comment.