Skip to content

Commit 4696bee

Browse files
authored
Merge pull request #22 from MEOM/feature/allow-multiple-terms
Add multiple terms support to TermSelect component
2 parents e62db28 + dc1bca8 commit 4696bee

File tree

6 files changed

+35
-3
lines changed

6 files changed

+35
-3
lines changed

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Changelog
22

3+
## Version 1.3.0 released May 6, 2024
4+
- Add `useMultiple` prop to `TermSelect` component.
5+
36
## Version 1.2.0 released May 6, 2024
47
- Add `useMediaToolbar` prop.

dist/index.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-components', 'wp-core-data', 'wp-data', 'wp-i18n'), 'version' => '8f7e20b57d64e16fb8de');
1+
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-components', 'wp-core-data', 'wp-data', 'wp-i18n'), 'version' => '6afcf74866286596fb72');

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@meom/block-components",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"description": "MEOM block components",
55
"homepage": "https://github.com/MEOM/block-components",
66
"repository": {

src/components/TermSelect/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,30 @@ Remember to define `termId` in `block.json` file as attribute:
3434
}
3535
}
3636
```
37+
38+
### `useMultiple`
39+
40+
Boolean which determines do we want to select multiple terms.
41+
42+
Usage:
43+
44+
```js
45+
<TermSelect
46+
useMultiple={ true }
47+
taxonomyName="category" {...props}
48+
/>
49+
```
50+
51+
When using `multiple` remember to define `termId` in `block.json` file as an array:
52+
53+
```json
54+
"attributes": {
55+
"termId": {
56+
"type": "array"
57+
}
58+
}
59+
```
60+
61+
- Type: `boolean`
62+
- Required: No
63+
- Default: `false`

src/components/TermSelect/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function TermSelect( props ) {
1717
queryArgs = { per_page: 99 },
1818
queryOptions = { enabled: true },
1919
setAttributes,
20+
useMultiple = false,
2021
} = props;
2122

2223
const options = [];
@@ -61,6 +62,7 @@ function TermSelect( props ) {
6162
setAttributes( { termId: newTermId } );
6263
} }
6364
value={ termId }
65+
{ ...( useMultiple ? { multiple: true } : {} ) }
6466
/>
6567
</>
6668
) }

0 commit comments

Comments
 (0)