@plaudit/gutenberg-api-extensions 2.85.0 → 2.86.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.
- package/CHANGELOG.md +11 -0
- package/dist/blocks/basic-custom-block-bindings-support.js +1 -2
- package/dist/blocks/basic-custom-block-bindings-support.js.map +1 -1
- package/dist/blocks/conditions.js +4 -2
- package/dist/blocks/conditions.js.map +1 -1
- package/dist/blocks/data-controller/reducer.js +3 -2
- package/dist/blocks/data-controller/reducer.js.map +1 -1
- package/dist/blocks/data-controller/trigger-handlers.js +3 -3
- package/dist/blocks/data-controller/trigger-handlers.js.map +1 -1
- package/dist/blocks/data-controller/utils.d.ts +5 -2
- package/dist/blocks/data-controller/utils.js +25 -2
- package/dist/blocks/data-controller/utils.js.map +1 -1
- package/dist/blocks/data-controller.d.ts +1 -1
- package/dist/blocks/data-controller.js +1 -1
- package/dist/blocks/data-controller.js.map +1 -1
- package/dist/blocks/hooks/built-in-suspendable-option-protocols/select.js +2 -2
- package/dist/blocks/hooks/built-in-suspendable-option-protocols/select.js.map +1 -1
- package/dist/blocks/hooks/useSuspendableOptions.js +5 -5
- package/dist/blocks/hooks/useSuspendableOptions.js.map +1 -1
- package/dist/blocks/snp-data-store.d.ts +1 -1
- package/dist/blocks/utilities.d.ts +0 -14
- package/dist/blocks/utilities.js +0 -3
- package/dist/blocks/utilities.js.map +1 -1
- package/dist/controls/ExtendedFormTokenField.js +3 -3
- package/dist/controls/ExtendedFormTokenField.js.map +1 -1
- package/dist/controls/ExtendedTaxonomyPicker.js +2 -2
- package/dist/controls/ExtendedTaxonomyPicker.js.map +1 -1
- package/dist/controls/hooks/useImprovedTokenManager.d.ts +1 -1
- package/dist/controls/hooks/useImprovedTokenManager.js +2 -2
- package/dist/controls/hooks/useImprovedTokenManager.js.map +1 -1
- package/dist/editor/post-featured-image.js +1 -2
- package/dist/editor/post-featured-image.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/package.json +16 -16
- package/simple-native-properties.md +106 -92
- package/src/blocks/basic-custom-block-bindings-support.tsx +2 -3
- package/src/blocks/conditions.ts +4 -3
- package/src/blocks/data-controller/reducer.ts +4 -3
- package/src/blocks/data-controller/trigger-handlers.ts +5 -4
- package/src/blocks/data-controller/utils.ts +27 -4
- package/src/blocks/data-controller.ts +2 -2
- package/src/blocks/hooks/built-in-suspendable-option-protocols/select.ts +2 -2
- package/src/blocks/hooks/useSuspendableOptions.ts +3 -4
- package/src/blocks/utilities.ts +0 -10
- package/src/controls/ExtendedFormTokenField.tsx +3 -4
- package/src/controls/ExtendedTaxonomyPicker.tsx +2 -2
- package/src/controls/hooks/useImprovedTokenManager.ts +2 -3
- package/src/editor/post-featured-image.tsx +3 -5
- package/src/index.ts +0 -1
- package/dist/lib/use-select-typed.d.ts +0 -3
- package/dist/lib/use-select-typed.js +0 -12
- package/dist/lib/use-select-typed.js.map +0 -1
- package/src/lib/use-select-typed.ts +0 -8
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {store as blockEditorStore} from "@wordpress/block-editor";
|
|
2
|
+
import {MapSelect, useSelect} from "@wordpress/data";
|
|
2
3
|
import {useMemo} from "@wordpress/element";
|
|
3
4
|
import {applyFilters} from "@wordpress/hooks";
|
|
4
5
|
|
|
@@ -6,8 +7,6 @@ import type {CSNPConfig, PromisablePickableOptions, SuspendablePromisablePickabl
|
|
|
6
7
|
import type {PickableOptions} from "../../controls";
|
|
7
8
|
import {useNodeContext} from "../layout/NodeContext";
|
|
8
9
|
import {isPromise, use} from "../../lib/suspense/promise-handlers";
|
|
9
|
-
import {useSelectTyped} from "../../lib/use-select-typed";
|
|
10
|
-
import {blockEditorStore} from "../utilities";
|
|
11
10
|
|
|
12
11
|
type RefablePromisablePickableOptions<T> = T extends {options: PromisablePickableOptions<infer V, infer T>} ? PickableOptions<V, T> : never;
|
|
13
12
|
export function isSuspendableOptions<V extends string|number, T extends object = {}>(thing: PromisablePickableOptions<V, T>|string): thing is SuspendablePromisablePickableOptions {
|
|
@@ -35,7 +34,7 @@ export function useSuspendableOptions<T extends CSNPConfig&{options: PromisableP
|
|
|
35
34
|
} else {
|
|
36
35
|
mapSelect = wrappedSelect => [null, wrappedSelect(blockEditorStore).getBlockName(blockClientId)];
|
|
37
36
|
}
|
|
38
|
-
const [attributes, blockName] =
|
|
37
|
+
const [attributes, blockName] = useSelect(mapSelect, [blockClientId]);
|
|
39
38
|
|
|
40
39
|
const potentiallyPromisedOptions = applyFilters('plaudit.gutenbergApiExtensions.simpleNativeProperties.suspendableOptions.resolve',
|
|
41
40
|
undefined, selectorInfo, {attributes, blockName});
|
package/src/blocks/utilities.ts
CHANGED
|
@@ -59,16 +59,6 @@ export function convertToSelectControlOptions(response: unknown): PairNormalized
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
type AddArgument<FirstArg, Fn extends (...args: any[]) => any> =
|
|
63
|
-
Fn extends (...arg: [...infer PrevArg]) => infer Return
|
|
64
|
-
? (...args: [FirstArg, ...PrevArg]) => Return
|
|
65
|
-
: never;
|
|
66
|
-
type SelectorInflater<T extends {[name: string]: (...args: any[]) => any}> = {[name in keyof T]: AddArgument<any, T[name]>};
|
|
67
|
-
export interface BlockEditorStoreDescriptor extends StoreDescriptor<ReduxStoreConfig<any, typeof BlockEditorActions, SelectorInflater<typeof BlockEditorSelectors>>> {
|
|
68
|
-
name: "core/block-editor";
|
|
69
|
-
}
|
|
70
|
-
export const blockEditorStore = realBlockEditorStore as BlockEditorStoreDescriptor;
|
|
71
|
-
|
|
72
62
|
export function forStringOrStrings(stringOrStrings: string|string[], action: (string: string) => void) {
|
|
73
63
|
if (Array.isArray(stringOrStrings)) {
|
|
74
64
|
for (const string of stringOrStrings) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {Spinner, FormTokenField} from '@wordpress/components';
|
|
2
2
|
import {useDebounce} from "@wordpress/compose";
|
|
3
|
-
import {type MapSelect} from "@wordpress/data";
|
|
3
|
+
import {type MapSelect, useSelect} from "@wordpress/data";
|
|
4
4
|
import {useCallback, useEffect, useMemo, useRef, useState} from "@wordpress/element";
|
|
5
5
|
import {__} from "@wordpress/i18n";
|
|
6
6
|
|
|
@@ -8,7 +8,6 @@ import type {SNPControlSlots} from "../blocks";
|
|
|
8
8
|
import type {TokenItem} from "../lib/useful-types";
|
|
9
9
|
import {packDisplayTokenText, unpackDisplayedTokenText, useImprovedTokenManager, ValidationState} from "./hooks/useImprovedTokenManager";
|
|
10
10
|
import {useMultiSingleConversionLayer} from "./hooks/useMultiSingleConversionLayer";
|
|
11
|
-
import {useSelectTyped} from "../lib/use-select-typed";
|
|
12
11
|
|
|
13
12
|
export {packDisplayTokenText, unpackDisplayedTokenText, ValidationState};
|
|
14
13
|
|
|
@@ -48,7 +47,7 @@ export function ExtendedFormTokenField(props: ExtendedFormTokenFieldProps) {
|
|
|
48
47
|
tokenTitleCacheRef.current = new Map();
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
const {rawSuggestions, isLoading, hasLoadingError} =
|
|
50
|
+
const {rawSuggestions, isLoading, hasLoadingError} = useSelect((select, registry) => {
|
|
52
51
|
if (!debouncedInput && props.initialSuggestions !== undefined) {
|
|
53
52
|
return {rawSuggestions: props.initialSuggestions, isLoading: false};
|
|
54
53
|
}
|
|
@@ -76,7 +75,7 @@ export function ExtendedFormTokenField(props: ExtendedFormTokenFieldProps) {
|
|
|
76
75
|
}
|
|
77
76
|
}, [rawSuggestions, tokenStatusCache]);
|
|
78
77
|
|
|
79
|
-
const {hasValidationError} =
|
|
78
|
+
const {hasValidationError} = useSelect((select, registry) => ({
|
|
80
79
|
hasValidationError: props.hasValidationError?.(select, registry)
|
|
81
80
|
}), [props.hasLoadingError, props.hasValidationError]);
|
|
82
81
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {type BaseEntityRecords, store as coreStore, type Taxonomy} from "@wordpress/core-data";
|
|
2
|
+
import {useSelect} from "@wordpress/data";
|
|
2
3
|
import {useCallback, useMemo} from "@wordpress/element";
|
|
3
4
|
|
|
4
5
|
import type {SNPControlSlots} from "../blocks";
|
|
5
6
|
import type {TokenItem} from "../lib/useful-types";
|
|
6
7
|
import {useOutputMemoizingFilter} from "./hooks/useOutputMemoizingFilter";
|
|
7
|
-
import {useSelectTyped} from "../lib/use-select-typed";
|
|
8
8
|
import {ExtendedFormTokenField, unpackDisplayedTokenText, ValidationState} from "./ExtendedFormTokenField";
|
|
9
9
|
|
|
10
10
|
import type {ReactNode} from "react";
|
|
@@ -82,7 +82,7 @@ export function ExtendedTaxonomyPicker(props: ExtendedTaxonomyPickerProps) {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
function useTaxonomiesFilteredByVisibility(visibility: ExtendedTaxonomyPickerProps['visibility']) {
|
|
85
|
-
const taxonomies =
|
|
85
|
+
const taxonomies = useSelect(select => select(coreStore).getTaxonomies(), []);
|
|
86
86
|
return useMemo(() => filterTaxonomiesByVisibility(taxonomies, visibility), [taxonomies, visibility]);
|
|
87
87
|
}
|
|
88
88
|
function makeTaxonomyVisibilityFilter(visibility: Parameters<typeof filterTaxonomiesByVisibility>[1]) {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import {type MapSelect, useSelect} from "@wordpress/data";
|
|
2
2
|
import {useEffect, useMemo, useRef, useState} from "@wordpress/element";
|
|
3
3
|
|
|
4
4
|
import type {TokenItem} from "../../lib/useful-types";
|
|
5
|
-
import {useSelectTyped} from "../../lib/use-select-typed";
|
|
6
5
|
|
|
7
6
|
export function packDisplayTokenText(token: TokenItem) {
|
|
8
7
|
return `${token.title || token.value} (#${token.value})`;
|
|
@@ -133,7 +132,7 @@ function useTokenValidator(
|
|
|
133
132
|
return [res, res.map(token => token.value)];
|
|
134
133
|
}, [convertedTokens, tokenStatusCache]);
|
|
135
134
|
|
|
136
|
-
return
|
|
135
|
+
return useSelect((select, registry) => {
|
|
137
136
|
if (statusUpdatedConvertedTokens.some(token => token.status === undefined || token.status === ValidationState.Validating)) {
|
|
138
137
|
const res = validationQuery(statusUpdatedConvertedTokenValues, select, registry);
|
|
139
138
|
if (res !== undefined) {
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import {Button, FocalPointPicker, Spinner} from "@wordpress/components";
|
|
2
2
|
import type {Attachment} from "@wordpress/core-data";
|
|
3
|
-
import {dispatch, select} from "@wordpress/data";
|
|
3
|
+
import {dispatch, select, useSelect, type SelectFunction} from "@wordpress/data";
|
|
4
4
|
import {PostFeaturedImageCheck, store as editorStore} from "@wordpress/editor";
|
|
5
5
|
import {memo, useCallback, useEffect, useMemo, useState} from "@wordpress/element";
|
|
6
6
|
import {addFilter, applyFilters} from "@wordpress/hooks";
|
|
7
7
|
import {__} from "@wordpress/i18n";
|
|
8
8
|
|
|
9
|
-
import {useSelectTyped} from "../lib/use-select-typed";
|
|
10
|
-
|
|
11
9
|
import type {ComponentType} from "react";
|
|
12
10
|
|
|
13
11
|
type MediaDetailsArgs = Omit<Attachment, 'media_details'>&{media_details: Record<string, any>};
|
|
@@ -46,7 +44,7 @@ function getMediaDetails(media: MediaDetailsArgs, postId: any) {
|
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
type Position = {x: number, y: number};
|
|
49
|
-
function getLivePosition(selectFunction = select): Position {
|
|
47
|
+
function getLivePosition(selectFunction: SelectFunction = select): Position {
|
|
50
48
|
const {x = 50, y = 50} = (selectFunction(editorStore).getEditedPostAttribute('meta')?.["plaudit_card-image_pos"] ?? {}) as Record<string, any>;
|
|
51
49
|
return {x: x / 100, y: y / 100};
|
|
52
50
|
}
|
|
@@ -126,7 +124,7 @@ const NotInFocusMode = memo(({OriginalComponent, props, setInFocusMode}: NotInFo
|
|
|
126
124
|
type InFocusModeProps = {mediaSourceUrl: string, props: Record<string, any>, restorablePosition: Position, setInFocusMode(value: boolean): void};
|
|
127
125
|
const InFocusMode = memo(({mediaSourceUrl, props, restorablePosition, setInFocusMode}: InFocusModeProps) => {
|
|
128
126
|
// This assembly makes it so that we both get updates if something else triggers a position change while making the focus picker doesn't reset itself
|
|
129
|
-
const {x, y} =
|
|
127
|
+
const {x, y} = useSelect(getLivePosition, []);
|
|
130
128
|
const [position, setPosition] = useState({x, y});
|
|
131
129
|
useEffect(() => setPosition(getLivePosition()), [x, y]);
|
|
132
130
|
|
package/src/index.ts
CHANGED
|
@@ -8,7 +8,6 @@ export * from "./controls";
|
|
|
8
8
|
export * from "./editor/simple-gutenberg-endpoints-api";
|
|
9
9
|
export * from "./lib/plaudit-icons";
|
|
10
10
|
export * from "./lib/suspense";
|
|
11
|
-
export * from "./lib/use-select-typed";
|
|
12
11
|
export type * from "./lib/useful-types";
|
|
13
12
|
|
|
14
13
|
export function installGutenbergExtensions() {
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { select as baseSelect, type DataRegistry } from "@wordpress/data";
|
|
2
|
-
export declare function useSelectTyped<R extends any>(mapSelect: (select: typeof baseSelect, registry: DataRegistry) => R, deps?: unknown[] | undefined): R;
|
|
3
|
-
export declare function useSuspenseSelectTyped<R extends any>(mapSelect: (select: typeof baseSelect, registry: DataRegistry) => R, deps?: unknown[] | undefined): R;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useSelectTyped = useSelectTyped;
|
|
4
|
-
exports.useSuspenseSelectTyped = useSuspenseSelectTyped;
|
|
5
|
-
const data_1 = require("@wordpress/data");
|
|
6
|
-
function useSelectTyped(mapSelect, deps) {
|
|
7
|
-
return (0, data_1.useSelect)(mapSelect, deps);
|
|
8
|
-
}
|
|
9
|
-
function useSuspenseSelectTyped(mapSelect, deps) {
|
|
10
|
-
return (0, data_1.useSuspenseSelect)(mapSelect, deps);
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=use-select-typed.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-select-typed.js","sourceRoot":"","sources":["../../src/lib/use-select-typed.ts"],"names":[],"mappings":";;AAEA,wCAEC;AACD,wDAEC;AAPD,0CAAsH;AAEtH,SAAgB,cAAc,CAAgB,SAAmE,EAAE,IAA0B;IAC5I,OAAO,IAAA,gBAAS,EAAC,SAAiC,EAAE,IAAI,CAAC,CAAC;AAC3D,CAAC;AACD,SAAgB,sBAAsB,CAAgB,SAAmE,EAAE,IAA0B;IACpJ,OAAO,IAAA,wBAAiB,EAAC,SAAiC,EAAE,IAAa,CAAC,CAAC;AAC5E,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import {select as baseSelect, type DataRegistry, type MapSelect, useSelect, useSuspenseSelect} from "@wordpress/data";
|
|
2
|
-
|
|
3
|
-
export function useSelectTyped<R extends any>(mapSelect: (select: typeof baseSelect, registry: DataRegistry) => R, deps?: unknown[]|undefined): R {
|
|
4
|
-
return useSelect(mapSelect as unknown as MapSelect, deps);
|
|
5
|
-
}
|
|
6
|
-
export function useSuspenseSelectTyped<R extends any>(mapSelect: (select: typeof baseSelect, registry: DataRegistry) => R, deps?: unknown[]|undefined): R {
|
|
7
|
-
return useSuspenseSelect(mapSelect as unknown as MapSelect, deps as any[]);
|
|
8
|
-
}
|