@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.
Files changed (2) hide show
  1. package/README.md +51 -35
  2. package/package.json +16 -1
package/README.md CHANGED
@@ -1,49 +1,65 @@
1
1
  # @wordpress-gcb/fields
2
2
 
3
- GCB's typed-field UI as a standalone package: the control components, the
4
- inspector renderer (`block.fields.json` settings panel), and the
5
- conditional-logic / validation helpers — **with no dependency on the GCB
6
- WordPress plugin's globals or REST endpoints**.
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. The Lite plugin consumes it; headless setups
9
- can use it directly. See `~/sites/gcb/README.md` for how this fits the whole
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
- **Status: skeleton.** The public API surface and the injected-config contract are
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
- ## Why it exists
15
+ ```bash
16
+ npm install @wordpress-gcb/fields
17
+ ```
17
18
 
18
- The plugin currently bakes the controls into itself and feeds them via
19
- `window.gcbLite` + plugin REST. That couples the field UI to the plugin. Pulling
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
- - headless editors get the exact same controls without the plugin;
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
- ## Host contract (what you inject)
24
+ ```jsx
25
+ import { GcbFieldsProvider, renderInspector } from '@wordpress-gcb/fields';
27
26
 
28
- The plugin used to read these off `window.gcbLite`; here they're explicit:
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
- | Inject | Replaces | For |
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
- ## Not included (stays in the plugin)
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
- The `gcb/repeater` **block** + `useRepeaterSeeding` / `useRepeaterValidation`
42
- (editor-coupled: clientId, block/editor stores, the validation transient), the
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
- ## Peer vs bundled deps
47
+ ## Exports
47
48
 
48
- - **peerDependencies:** all `@wordpress/*` — provided by the host editor.
49
- - **bundled:** `@dnd-kit/*`, `@tiptap/*` not part of the WP runtime.
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.0",
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": {