@wordpress-gcb/fields 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -35
- package/package.json +16 -1
package/README.md
CHANGED
|
@@ -1,49 +1,65 @@
|
|
|
1
1
|
# @wordpress-gcb/fields
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
conditional-logic
|
|
6
|
-
|
|
3
|
+
Typed-field UI for the WordPress block editor: control components, an inspector
|
|
4
|
+
renderer that turns a `block.fields.json` schema into a settings panel, plus
|
|
5
|
+
conditional-logic and validation helpers — **decoupled from any plugin**. Host
|
|
6
|
+
data (design tokens, media picker, etc.) is injected, so the same controls run
|
|
7
|
+
inside the [GCB Lite plugin](https://github.com/wordpress-gcb/gutenberg-control-blocks-lite),
|
|
8
|
+
a meta box, or a headless editor.
|
|
7
9
|
|
|
8
|
-
This is the free, open core of GCB.
|
|
9
|
-
|
|
10
|
-
project, and `gcb-pro/docs/eject-blocks-scope.md` for the architecture rationale.
|
|
10
|
+
This is the free, open core of **[GCB](https://gutenbergcontrolblocks.com)** —
|
|
11
|
+
[Gutenberg Control Blocks](https://gutenbergcontrolblocks.com).
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
defined (`src/index.js`); the control source is extracted from the plugin in a
|
|
14
|
-
later step — see `EXTRACTION.md`.
|
|
13
|
+
## Install
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
```bash
|
|
16
|
+
npm install @wordpress-gcb/fields
|
|
17
|
+
```
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
it into `@wordpress-gcb/fields` means:
|
|
19
|
+
`@wordpress/*` are peer dependencies — provided by the WordPress editor runtime
|
|
20
|
+
(or your build's externals). `@dnd-kit/*` and `@tiptap/*` ship bundled.
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
- "eject" can scaffold a block that uses the SDK and works plugin-free;
|
|
24
|
-
- graceful degradation: static `block.json` is the floor, the SDK restores live UI.
|
|
22
|
+
## Usage
|
|
25
23
|
|
|
26
|
-
|
|
24
|
+
```jsx
|
|
25
|
+
import { GcbFieldsProvider, renderInspector } from '@wordpress-gcb/fields';
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
// controls = the `controls` array from a block.fields.json
|
|
28
|
+
<GcbFieldsProvider value={{ tokens, googleMapsEnabled: true }}>
|
|
29
|
+
{renderInspector(controls, attributes, setAttributes)}
|
|
30
|
+
</GcbFieldsProvider>
|
|
31
|
+
```
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
| `controls` (arg to `renderInspector`) | `window.gcbLite.blocks[name].controls` | the fields to render |
|
|
33
|
-
| `tokens` | `window.gcbLite.tokens` | token-aware controls (select, range, spacing) |
|
|
34
|
-
| `googleMapsEnabled` | `window.gcbLite.googleMaps.hasApiKey` | the google-map control |
|
|
35
|
-
| `media` adapter | `wp.media` / block-editor `MediaUpload` | image / gallery / file / richtext |
|
|
36
|
-
| `apiFetch` (optional) | `@wordpress/api-fetch` | reference controls — **core `wp/v2` only** |
|
|
37
|
-
| `variant` | `ControlContext` | `'sidebar'` (popovers) vs `'metabox'` (modals) |
|
|
33
|
+
Each control receives `{ control, value, onChange, attributes }`. The provider
|
|
34
|
+
supplies what the controls need from the host:
|
|
38
35
|
|
|
39
|
-
|
|
36
|
+
| Inject | For |
|
|
37
|
+
| --- | --- |
|
|
38
|
+
| `tokens` | token-aware controls (select, range, spacing) |
|
|
39
|
+
| `googleMapsEnabled` | the google-map control |
|
|
40
|
+
| `media` | media picker adapter (image / gallery / file / richtext) |
|
|
41
|
+
| `apiFetch` | reference controls — calls core `wp/v2` (optional; defaults to `@wordpress/api-fetch`) |
|
|
42
|
+
| `variant` | `'sidebar'` (popovers) vs `'metabox'` (modals) |
|
|
40
43
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
PHP-preview pipeline, focus-field handling, the admin builder. The `repeater`
|
|
44
|
-
**control** (form-of-forms field) IS included — don't confuse the two.
|
|
44
|
+
All are optional; with none provided the package falls back to the WordPress
|
|
45
|
+
editor globals.
|
|
45
46
|
|
|
46
|
-
##
|
|
47
|
+
## Exports
|
|
47
48
|
|
|
48
|
-
-
|
|
49
|
-
-
|
|
49
|
+
- `renderInspector(controls, attributes, setAttributes, options?)`
|
|
50
|
+
- `controlComponents` — the control registry (`type` → component)
|
|
51
|
+
- `GcbFieldsProvider`, `useGcbFieldsConfig`
|
|
52
|
+
- `shouldRender`, `panelsContainingErrors`, `STRUCTURAL_TYPES`
|
|
53
|
+
- `ValidationContext`, `ControlContext`
|
|
54
|
+
- token helpers: `useTokens`, `getTokensByGroup`, `getAllTokenGroups`
|
|
55
|
+
|
|
56
|
+
## Links
|
|
57
|
+
|
|
58
|
+
- **Website:** <https://gutenbergcontrolblocks.com>
|
|
59
|
+
- **Source:** <https://github.com/wordpress-gcb/gcb-fields>
|
|
60
|
+
- **Issues:** <https://github.com/wordpress-gcb/gcb-fields/issues>
|
|
61
|
+
- **GCB Lite plugin:** <https://github.com/wordpress-gcb/gutenberg-control-blocks-lite>
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
GPL-2.0-or-later
|
package/package.json
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress-gcb/fields",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "GCB typed-field controls, inspector renderer, and schema — decoupled from the WordPress plugin so any Gutenberg/headless editor can use them.",
|
|
5
5
|
"license": "GPL-2.0-or-later",
|
|
6
|
+
"homepage": "https://gutenbergcontrolblocks.com",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/wordpress-gcb/gcb-fields.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/wordpress-gcb/gcb-fields/issues"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"wordpress",
|
|
16
|
+
"gutenberg",
|
|
17
|
+
"block-editor",
|
|
18
|
+
"fields",
|
|
19
|
+
"gcb"
|
|
20
|
+
],
|
|
6
21
|
"//type": "Intentionally NOT \"type\": \"module\" — the source is ESM syntax consumed by the host's bundler (wp-scripts/webpack), which handles extensionless relative imports. Marking it a strict ESM module would force fully-specified .js extensions on every import.",
|
|
7
22
|
"main": "./src/index.js",
|
|
8
23
|
"exports": {
|