Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/eslint-plugin-sort-d…
Browse files Browse the repository at this point in the history
…estructure-keys-1.5.0
  • Loading branch information
mattheu authored Sep 21, 2023
2 parents e69fb90 + 950f3e7 commit d633f15
Show file tree
Hide file tree
Showing 10 changed files with 4,847 additions and 4,209 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16.16.0
v18.18.0
19 changes: 19 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@ When you're done, you can unlink the package by running the following:
npm unlink @humanmade/block-editor-components
```

**Note on usage with `@humanmade/webpack-helpers`:** You may hit eslint errors trying to build your assets when linked to a local copy of this. As a workaround, you need to restrict eslint to the current project directory when configuring your webpack build. Do this by filtering the loader options.

```
const path = require( 'node:path' );
presets.production( {
// ...
}, {
filterLoaders: ( loader, loaderType ) => {
// Handle symlinked node_modules.
if ( loaderType === 'eslint' ) {
loader.include = path.dirname( path.resolve( __dirname ) );
}
return loader;
}
} );
```

### Automatic Build

Whilst developing, it is useful have Webpack watch for changes and rebuild the distributed files automatically.
Expand Down
1 change: 1 addition & 0 deletions dist/index.asset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-dom', 'wp-element', 'wp-html-entities', 'wp-i18n', 'wp-server-side-render', 'wp-url'), 'version' => '27efa55df920e54bd9f2');
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

8,476 changes: 4,271 additions & 4,205 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@humanmade/block-editor-components",
"version": "0.4.0",
"version": "0.5.0",
"description": "Reusable components, hooks and helper functions for the WordPress block editor(s).",
"keywords": [
"block editor",
Expand Down Expand Up @@ -51,7 +51,7 @@
"webpack-cli": "^4.10.0"
},
"engines": {
"node": "^16.16.0"
"node": ">=16"
},
"publishConfig": {
"access": "public"
Expand Down
81 changes: 81 additions & 0 deletions src/components/PostPicker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# PostPicker

There are several `PostPicker` controls.

* `PostPickerButton` A simple button.
* `PostPickerToolbarButton` A button for use within `BlockControls` toolbar.
* `PostPickerModal` The actual modal interface, that can be integrated into your own UI.

## `PostPickerButton`

```jsx
import { PostPickerButton } from '@humanmade/block-editor-components';

...

<PostPickerButton
taxonomies={ [ 'category', 'post_tag' ] }
onChange={ newValue => setAttributes( { postIds: newValue } ) }
values={ attributes.postIds || [] }
/>
```

### Props

The `LinkToolbar` component does not have any custom props other than `opensInNewTab`, `value` and `onChange`, which are all passed on as is to the nested [`LinkControl`](https://github.com/WordPress/gutenberg/blob/trunk/packages/block-editor/src/components/link-control/index.js) component.

#### `values`

The saved values. Array of post IDs.

| Type | Required | Default |
|--------------------------------------|--------------------------------------|--------------------------------------|
| `Array` | yes | `undefined` |


#### `onChange`

The callback to use for handling changing the selected posts. `onChange` will receive an array of post IDs.

| Type | Required | Default |
|--------------------------------------|--------------------------------------|--------------------------------------|
| `Function` | yes | `undefined` |

#### `title`

The title, used by button and modal title.

| Type | Required | Default |
|--------------------------------------|--------------------------------------|--------------------------------------|
| `String` | no | `Select Posts`

#### `postType`

Post type to select from.

| Type | Required | Default |
|--------------------------------------|--------------------------------------|--------------------------------------|
| `String` | no | `post`

#### `taxonomies`

Taxonomies that results can be filtered by. Array of taxonomy slugs. e.g. `[ 'category', 'post_tag' ]`.

| Type | Required | Default |
|--------------------------------------|--------------------------------------|--------------------------------------|
| `Array` | no | `[]`


## Post Picker Toolbar Button

There is also a `PostPickerToolbarButton` component available if you import it directly from the source file, which is intended for use within the BlockControls. It supports all the same props as the PostPicker component, with the addition of an `icon`.

## props

#### `icon`

Button icon. Passed through to `ToolbarButton`, refer to the documentation of that component for more info.

| Type | Required | Default |
|--------------------------------------|--------------------------------------|--------------------------------------|
| `string` | no | `edit`
Loading

0 comments on commit d633f15

Please sign in to comment.