@plaudit/gutenberg-api-extensions 2.80.0 → 2.81.0

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.
@@ -93,7 +93,7 @@ export function installCustomBlockBindingsSupport() {
93
93
  );
94
94
 
95
95
  type BlockBindingToolProps = {
96
- value: { source: string, args?: { [key: string]: any } } | undefined,
96
+ value: { source: string, args: { [key: string]: any } } | undefined,
97
97
  currentPost: any,
98
98
  label: string,
99
99
  binding: string
@@ -119,7 +119,7 @@ export function installCustomBlockBindingsSupport() {
119
119
  key="source"
120
120
  label="Source"
121
121
  __nextHasNoMarginBottom={true}
122
- onChange={source => updateBlockBindings({[binding]: {source}})}
122
+ onChange={source => updateBlockBindings({[binding]: {source, args: {}}})}
123
123
  options={[
124
124
  {
125
125
  disabled: true,
@@ -158,11 +158,11 @@ export function installCustomBlockBindingsSupport() {
158
158
 
159
159
  const subfieldKeys = useMemo<SelectableOptions[number]['subfields']>(() => {
160
160
  if (Array.isArray(selectableOptions)) {
161
- const key = value?.args?.['key'];
161
+ const key = value?.args['key'];
162
162
  return key ? selectableOptions.find(option => option.value === key)?.subfields ?? [] : [];
163
163
  }
164
164
  return [];
165
- }, [selectableOptions, value?.args?.['key']]);
165
+ }, [selectableOptions, value?.args['key']]);
166
166
 
167
167
  const controls: ReactElement[] = [];
168
168
  if (selectableOptions.length) {
@@ -180,7 +180,7 @@ export function installCustomBlockBindingsSupport() {
180
180
  },
181
181
  ...selectableOptions
182
182
  ]}
183
- value={value?.args?.['key'] ?? ''}
183
+ value={value?.args['key'] ?? ''}
184
184
  />);
185
185
 
186
186
  if (subfieldKeys.length) {
@@ -190,7 +190,7 @@ export function installCustomBlockBindingsSupport() {
190
190
  label="Subfield"
191
191
  __nextHasNoMarginBottom={true}
192
192
  onChange={subfield => updateBlockBindings({[binding]: (value ? {...value, args: {...value.args, subfield}} : undefined)})}
193
- value={value?.args?.['subfield'] ?? ''}
193
+ value={value?.args['subfield'] ?? ''}
194
194
  help="Please enter the name of a subfield. You may need to inspect the raw data from this binding to determine the subfield."
195
195
  />);
196
196
  } else {
@@ -207,28 +207,28 @@ export function installCustomBlockBindingsSupport() {
207
207
  },
208
208
  ...subfieldKeys
209
209
  ]}
210
- value={value?.args?.['subfield'] ?? ''}
210
+ value={value?.args['subfield'] ?? ''}
211
211
  />);
212
212
  }
213
213
  }
214
214
 
215
- if (value?.args?.['key'] && dbSources?.length) {
215
+ if (value?.args['key'] && dbSources?.length) {
216
216
  controls.push(<SelectControl
217
217
  key="db-source"
218
218
  label="DB Source"
219
219
  __nextHasNoMarginBottom={true}
220
220
  onChange={db_source => updateBlockBindings({[binding]: (value ? {...value, args: {...value.args, db_source}} : undefined)})}
221
221
  options={dbSources}
222
- value={value?.args?.['db_source'] ?? dbSources[0]!.value}
223
- help={dbSources.find(dbs => dbs.value === value?.args?.['db_source'])?.help}
222
+ value={value?.args['db_source'] ?? dbSources[0]!.value}
223
+ help={dbSources.find(dbs => dbs.value === value?.args['db_source'])?.help}
224
224
  />);
225
- } else if (value?.args?.['db_source']) {
225
+ } else if (value?.args['db_source']) {
226
226
  const {db_source, ...updatedArgs} = value.args;
227
227
  updateBlockBindings({[binding]: {...value, args: updatedArgs}});
228
228
  }
229
229
  }
230
230
  if (controls.length === 0) {
231
- controls.push(<p>No Options Found</p>);
231
+ controls.push(<p key="no-options-found-text">No Options Found</p>);
232
232
  }
233
233
  return controls;
234
234
  });
@@ -2,7 +2,7 @@ import {type BlockStyle, type BlockVariation, registerBlockStyle, registerBlockV
2
2
  import {store as realBlockEditorStore} from "@wordpress/block-editor";
3
3
  import type * as BlockEditorActions from "@wordpress/block-editor/store/actions";
4
4
  import type * as BlockEditorSelectors from "@wordpress/block-editor/store/selectors";
5
- import type {ReduxStoreConfig, StoreDescriptor} from "@wordpress/data/types";
5
+ import type {ReduxStoreConfig, StoreDescriptor} from "@wordpress/data";
6
6
  import domReady from "@wordpress/dom-ready";
7
7
 
8
8
  import type {PairNormalizedPickableOptions} from "../controls";
@@ -1,7 +1,6 @@
1
1
  import {Spinner, FormTokenField} from '@wordpress/components';
2
2
  import {useDebounce} from "@wordpress/compose";
3
- import {useSelect} from "@wordpress/data";
4
- import type {MapSelect} from "@wordpress/data/types";
3
+ import {type MapSelect, useSelect} from "@wordpress/data";
5
4
  import {useCallback, useEffect, useMemo, useRef, useState} from "@wordpress/element";
6
5
  import {__} from "@wordpress/i18n";
7
6
 
@@ -1,5 +1,4 @@
1
- import {useSelect} from "@wordpress/data";
2
- import type {MapSelect} from "@wordpress/data/types";
1
+ import {type MapSelect, useSelect} from "@wordpress/data";
3
2
  import {useEffect, useMemo, useRef, useState} from "@wordpress/element";
4
3
 
5
4
  import type {TokenItem} from "../../lib/useful-types";
@@ -31,7 +31,8 @@ export namespace installSimpleGutenbergApisSupport {
31
31
 
32
32
  type Selectors = {
33
33
  get(name: string, args?: ApiCallArgs): unknown,
34
- resolve(name: string, args?: ApiCallArgs): Promise<unknown>
34
+ resolve(name: string, args?: ApiCallArgs): Promise<unknown>,
35
+ registeredEndpoints(): string[]
35
36
  };
36
37
  type Actions = {
37
38
  registerEndpoint(
@@ -94,6 +95,9 @@ export const store: ReturnType<typeof createReduxStore<{}, Actions, AddBSStateAr
94
95
  },
95
96
  resolve(name, args?) {
96
97
  return handleCacheMiss(name, args);
98
+ },
99
+ registeredEndpoints(): string[] {
100
+ return Object.keys(endpoints);
97
101
  }
98
102
  };
99
103
  const suspendSelectors: Selectors = {
@@ -102,6 +106,9 @@ export const store: ReturnType<typeof createReduxStore<{}, Actions, AddBSStateAr
102
106
  },
103
107
  resolve(name, args?) {
104
108
  return useToPromise(handleCacheMiss(name, args));
109
+ },
110
+ registeredEndpoints(): string[] {
111
+ return Object.keys(endpoints);
105
112
  }
106
113
  };
107
114
 
@@ -1,5 +1,4 @@
1
- import {resolveSelect, type select} from "@wordpress/data";
2
- import type {ActionCreator, ReduxStoreConfig} from "@wordpress/data/types";
1
+ import {type ActionCreator, type ReduxStoreConfig, resolveSelect, type select} from "@wordpress/data";
3
2
  import type * as MetaActions from "@wordpress/data/redux-store/metadata/actions";
4
3
  import type * as MetaSelectors from "@wordpress/data/redux-store/metadata/selectors";
5
4
 
@@ -0,0 +1 @@
1
+ See `Deploy Schema` section of ../README.md