@plaudit/gutenberg-api-extensions 2.64.1 → 2.64.2
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/build/lib/gutenberg-api-extensions-state/custom-block-bindings-support-logic.d.ts +10 -2
- package/build/lib/gutenberg-api-extensions-state/custom-block-bindings-support-logic.js +9 -0
- package/build/lib/gutenberg-api-extensions-state/custom-block-bindings-support-logic.js.map +1 -1
- package/build/lib/gutenberg-api-extensions-state/general-logic.d.ts +29 -0
- package/build/lib/gutenberg-api-extensions-state/general-logic.js +34 -0
- package/build/lib/gutenberg-api-extensions-state/general-logic.js.map +1 -0
- package/build/lib/gutenberg-api-extensions-state/layered-block-styles-logic.d.ts +13 -4
- package/build/lib/gutenberg-api-extensions-state/layered-block-styles-logic.js +17 -0
- package/build/lib/gutenberg-api-extensions-state/layered-block-styles-logic.js.map +1 -1
- package/build/lib/gutenberg-api-extensions-state/snp-logic.d.ts +24 -8
- package/build/lib/gutenberg-api-extensions-state/snp-logic.js +44 -0
- package/build/lib/gutenberg-api-extensions-state/snp-logic.js.map +1 -1
- package/build/lib/gutenberg-api-extensions-state.d.ts +78 -65
- package/build/lib/gutenberg-api-extensions-state.js +34 -92
- package/build/lib/gutenberg-api-extensions-state.js.map +1 -1
- package/build/lib/helpers.d.ts +20 -0
- package/build/lib/helpers.js +10 -0
- package/build/lib/helpers.js.map +1 -1
- package/build/lib/useful-types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { registerBlockBindingsSource } from "@wordpress/blocks";
|
|
2
2
|
import type { DbSource } from "../../blocks";
|
|
3
|
-
import type {
|
|
3
|
+
import type { WordPressMetaActions } from "../useful-types";
|
|
4
4
|
export type CustomBlockBindingsSupportLogicActions = {
|
|
5
5
|
type: 'ADD_CUSTOM_BLOCK_BINDINGS_SOURCE';
|
|
6
6
|
name: string;
|
|
@@ -8,6 +8,13 @@ export type CustomBlockBindingsSupportLogicActions = {
|
|
|
8
8
|
dbSources?: DbSource[];
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
+
export type CustomBlockBindingsSupportLogicState = {
|
|
12
|
+
customBlockBindingsSupport: {
|
|
13
|
+
[name in string]?: {
|
|
14
|
+
dbSources?: DbSource[];
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
11
18
|
export declare const customBlockBindingsSupportLogicActions: {
|
|
12
19
|
registerCustomBlockBindingsSource(args: Parameters<typeof registerBlockBindingsSource>[0] & {
|
|
13
20
|
dbSources?: DbSource[];
|
|
@@ -20,7 +27,8 @@ export declare const customBlockBindingsSupportLogicActions: {
|
|
|
20
27
|
};
|
|
21
28
|
};
|
|
22
29
|
export declare const customBlockBindingsSupportLogicSelectors: {
|
|
23
|
-
customBlockBindingsSource(state:
|
|
30
|
+
customBlockBindingsSource(state: CustomBlockBindingsSupportLogicState, name: string): {
|
|
24
31
|
dbSources?: DbSource[];
|
|
25
32
|
} | undefined;
|
|
26
33
|
};
|
|
34
|
+
export declare function customBlockBindingsSupportLogic(state: CustomBlockBindingsSupportLogicState, action: CustomBlockBindingsSupportLogicActions | WordPressMetaActions): typeof state;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { registerBlockBindingsSource } from "@wordpress/blocks";
|
|
2
|
+
import { produce } from "immer";
|
|
2
3
|
export const customBlockBindingsSupportLogicActions = {
|
|
3
4
|
registerCustomBlockBindingsSource(args) {
|
|
4
5
|
const { dbSources, ...actualArgs } = args;
|
|
@@ -11,4 +12,12 @@ export const customBlockBindingsSupportLogicSelectors = {
|
|
|
11
12
|
return state.customBlockBindingsSupport[name];
|
|
12
13
|
}
|
|
13
14
|
};
|
|
15
|
+
export function customBlockBindingsSupportLogic(state, action) {
|
|
16
|
+
if (action.type === "ADD_CUSTOM_BLOCK_BINDINGS_SOURCE") {
|
|
17
|
+
return produce(state, (draft) => {
|
|
18
|
+
draft.customBlockBindingsSupport[action.name] = action.value;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return state;
|
|
22
|
+
}
|
|
14
23
|
//# sourceMappingURL=custom-block-bindings-support-logic.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-block-bindings-support-logic.js","sourceRoot":"","sources":["../../../src/lib/gutenberg-api-extensions-state/custom-block-bindings-support-logic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,2BAA2B,EAAC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"custom-block-bindings-support-logic.js","sourceRoot":"","sources":["../../../src/lib/gutenberg-api-extensions-state/custom-block-bindings-support-logic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,2BAA2B,EAAC,MAAM,mBAAmB,CAAC;AAI9D,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAO9B,MAAM,CAAC,MAAM,sCAAsC,GAAG;IACrD,iCAAiC,CAAC,IAAgF;QACjH,MAAM,EAAC,SAAS,EAAE,GAAG,UAAU,EAAC,GAAG,IAAI,CAAC;QACxC,2BAA2B,CAAC,UAAU,IAAI,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAC,GAAG,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAC,CAAC,CAAC;QAC3G,OAAO,EAAC,IAAI,EAAE,kCAAkC,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,EAAC,SAAS,EAAC,EAAC,CAAC;IAC9F,CAAC;CACD,CAAC;AACF,MAAM,CAAC,MAAM,wCAAwC,GAAG;IACvD,yBAAyB,CAAC,KAA2C,EAAE,IAAY;QAClF,OAAO,KAAK,CAAC,0BAA0B,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;CACD,CAAC;AAEF,MAAM,UAAU,+BAA+B,CAC9C,KAA2C,EAAE,MAAmE;IAEhH,IAAI,MAAM,CAAC,IAAI,KAAK,kCAAkC,EAAE,CAAC;QACxD,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC,KAAmB,EAAE,EAAE;YAC7C,KAAK,CAAC,0BAA0B,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;QAC9D,CAAC,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { BlockName, RegisterBlockAttrs } from "../../blocks/snp-api";
|
|
2
|
+
export type GeneralLogicActions = {
|
|
3
|
+
type: 'RECORD_BASELINE_BLOCK_ATTRS';
|
|
4
|
+
attrs: RegisterBlockAttrs<Record<string, any>>;
|
|
5
|
+
} | {
|
|
6
|
+
type: "SET_FEATURE_PROP";
|
|
7
|
+
feature: string;
|
|
8
|
+
prop: string;
|
|
9
|
+
value: any;
|
|
10
|
+
};
|
|
11
|
+
export type GeneralLogicState = {
|
|
12
|
+
baselineBlockAttrs: {
|
|
13
|
+
[blockName in BlockName]?: RegisterBlockAttrs<Record<string, any>>;
|
|
14
|
+
};
|
|
15
|
+
features: {
|
|
16
|
+
[name in string]?: {
|
|
17
|
+
[prop in string]: any;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare function generalLogic(state: GeneralLogicState, action: GeneralLogicActions): typeof state;
|
|
22
|
+
export declare const generalLogicActions: {
|
|
23
|
+
recordBaselineBlockAttrs(attrs: RegisterBlockAttrs<Record<string, any>>): GeneralLogicActions;
|
|
24
|
+
setFeatureProp(feature: string, prop: string, value: any): GeneralLogicActions;
|
|
25
|
+
};
|
|
26
|
+
export declare const generalLogicSelectors: {
|
|
27
|
+
baselineBlockAttrs(state: GeneralLogicState, blockName: BlockName): RegisterBlockAttrs<Record<string, any>> | undefined;
|
|
28
|
+
featureProp(state: GeneralLogicState, feature: string, prop: string): any;
|
|
29
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { produce } from "immer";
|
|
2
|
+
import { clone } from "../helpers";
|
|
3
|
+
export function generalLogic(state, action) {
|
|
4
|
+
if (action.type === "RECORD_BASELINE_BLOCK_ATTRS") {
|
|
5
|
+
return produce(state, (draft) => {
|
|
6
|
+
if (!(action.attrs.name in draft.baselineBlockAttrs)) {
|
|
7
|
+
draft.baselineBlockAttrs[action.attrs.name] = clone(action.attrs);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
else if (action.type === "SET_FEATURE_PROP") {
|
|
12
|
+
return produce(state, (draft) => {
|
|
13
|
+
(draft.features[action.feature] ?? (draft.features[action.feature] = {}))[action.prop] = action.value;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return state;
|
|
17
|
+
}
|
|
18
|
+
export const generalLogicActions = {
|
|
19
|
+
recordBaselineBlockAttrs(attrs) {
|
|
20
|
+
return { type: "RECORD_BASELINE_BLOCK_ATTRS", attrs };
|
|
21
|
+
},
|
|
22
|
+
setFeatureProp(feature, prop, value) {
|
|
23
|
+
return { type: "SET_FEATURE_PROP", feature, prop, value };
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export const generalLogicSelectors = {
|
|
27
|
+
baselineBlockAttrs(state, blockName) {
|
|
28
|
+
return state.baselineBlockAttrs[blockName];
|
|
29
|
+
},
|
|
30
|
+
featureProp(state, feature, prop) {
|
|
31
|
+
return state.features[feature]?.[prop];
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=general-logic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"general-logic.js","sourceRoot":"","sources":["../../../src/lib/gutenberg-api-extensions-state/general-logic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAE9B,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AAQjC,MAAM,UAAU,YAAY,CAAC,KAAwB,EAAE,MAA2B;IACjF,IAAI,MAAM,CA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,OAAe,EAAE,IAAY;QAClE,OAAO,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;CACD,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { BlockName, PDSimpleNativeProperty } from "../../blocks";
|
|
2
|
-
import { NamedBlockAction
|
|
1
|
+
import type { BlockName, PDSimpleNativeProperty } from "../../blocks";
|
|
2
|
+
import type { NamedBlockAction } from "../gutenberg-api-extensions-state";
|
|
3
|
+
import type { WordPressMetaActions } from "../useful-types";
|
|
3
4
|
export type LayeredBlockStylesLogicActions = NamedBlockAction<'ADD_LAYERED_BLOCK_STYLES', {
|
|
4
5
|
properties: PDSimpleNativeProperty[];
|
|
5
6
|
}> | NamedBlockAction<'SET_LAYERED_BLOCK_STYLES', {
|
|
@@ -7,6 +8,13 @@ export type LayeredBlockStylesLogicActions = NamedBlockAction<'ADD_LAYERED_BLOCK
|
|
|
7
8
|
[name in string]: PDSimpleNativeProperty;
|
|
8
9
|
};
|
|
9
10
|
}>;
|
|
11
|
+
export type LayeredBlockStylesLogicState = {
|
|
12
|
+
layeredBlockStyles: {
|
|
13
|
+
[blockName in BlockName]?: {
|
|
14
|
+
[name in string]: PDSimpleNativeProperty;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
10
18
|
export declare const layeredBlockStylesLogicActions: {
|
|
11
19
|
addLayeredBlockStyles(blockName: BlockName, properties: PDSimpleNativeProperty[]): {
|
|
12
20
|
type: string;
|
|
@@ -15,8 +23,9 @@ export declare const layeredBlockStylesLogicActions: {
|
|
|
15
23
|
};
|
|
16
24
|
};
|
|
17
25
|
export declare const layeredBlockStylesLogicSelectors: {
|
|
18
|
-
blockStylesLayer(state:
|
|
19
|
-
blockStylesLayers(state:
|
|
26
|
+
blockStylesLayer(state: LayeredBlockStylesLogicState, blockName: BlockName, layerName: string): PDSimpleNativeProperty | undefined;
|
|
27
|
+
blockStylesLayers(state: LayeredBlockStylesLogicState, blockName: BlockName): {
|
|
20
28
|
[x: string]: PDSimpleNativeProperty;
|
|
21
29
|
} | undefined;
|
|
22
30
|
};
|
|
31
|
+
export declare function layeredBlockStylesLogic(state: LayeredBlockStylesLogicState, action: LayeredBlockStylesLogicActions | WordPressMetaActions): typeof state;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { produce } from "immer";
|
|
1
2
|
export const layeredBlockStylesLogicActions = {
|
|
2
3
|
addLayeredBlockStyles(blockName, properties) {
|
|
3
4
|
return { type: 'ADD_LAYERED_BLOCK_STYLES', blockName, properties };
|
|
@@ -11,4 +12,20 @@ export const layeredBlockStylesLogicSelectors = {
|
|
|
11
12
|
return state.layeredBlockStyles[blockName];
|
|
12
13
|
}
|
|
13
14
|
};
|
|
15
|
+
export function layeredBlockStylesLogic(state, action) {
|
|
16
|
+
if (action.type === "ADD_LAYERED_BLOCK_STYLES") {
|
|
17
|
+
return produce(state, (draft) => {
|
|
18
|
+
const blockLayeredStyles = draft.layeredBlockStyles[action.blockName] ?? (draft.layeredBlockStyles[action.blockName] = {});
|
|
19
|
+
for (const layer of action.properties) {
|
|
20
|
+
blockLayeredStyles[layer.name] = layer;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
else if (action.type === "SET_LAYERED_BLOCK_STYLES") {
|
|
25
|
+
return produce(state, (draft) => {
|
|
26
|
+
draft.layeredBlockStyles[action.blockName] = action.properties;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return state;
|
|
30
|
+
}
|
|
14
31
|
//# sourceMappingURL=layered-block-styles-logic.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layered-block-styles-logic.js","sourceRoot":"","sources":["../../../src/lib/gutenberg-api-extensions-state/layered-block-styles-logic.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"layered-block-styles-logic.js","sourceRoot":"","sources":["../../../src/lib/gutenberg-api-extensions-state/lay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CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC;QAChE,CAAC,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC"}
|
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
import { BlockName, PropertiesParameter, SimpleNativePanel, SimpleNativeTab } from "../../blocks";
|
|
2
|
-
import { ExtraPropTransformsConfig, PerBlockExtraPropTransforms, PreppedSimpleNativePanelsAndTabs } from "../../blocks/simple-native-property-internal-shared";
|
|
1
|
+
import type { BlockName, PropertiesParameter, SimpleNativePanel, SimpleNativeTab } from "../../blocks";
|
|
2
|
+
import type { ExtraPropTransformsConfig, PerBlockExtraPropTransforms, PreppedSimpleNativePanelsAndTabs } from "../../blocks/simple-native-property-internal-shared";
|
|
3
3
|
import { RegisterBlockAttrs } from "../../blocks/snp-api";
|
|
4
|
-
import { BareProperties, NamedBlockAction
|
|
4
|
+
import { type BareProperties, type NamedBlockAction } from "../gutenberg-api-extensions-state";
|
|
5
|
+
import type { WordPressMetaActions } from "../useful-types";
|
|
6
|
+
export type SNPLogicState = {
|
|
7
|
+
desiccatedProperties: {
|
|
8
|
+
[blockName in BlockName]?: Array<SimpleNativePanel | SimpleNativeTab>;
|
|
9
|
+
};
|
|
10
|
+
preppedProperties: {
|
|
11
|
+
[blockName in BlockName]?: PreppedSimpleNativePanelsAndTabs | false;
|
|
12
|
+
};
|
|
13
|
+
extraPropTransforms: {
|
|
14
|
+
[blockName in BlockName]?: ExtraPropTransformsConfig;
|
|
15
|
+
};
|
|
16
|
+
computedExtraPropTransforms: {
|
|
17
|
+
[blockName in BlockName]?: PerBlockExtraPropTransforms | false;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
5
20
|
export type SNPLogicActions = {
|
|
6
21
|
type: 'ADD_PROPERTIES';
|
|
7
22
|
blockName: BlockName | BlockName[];
|
|
@@ -23,12 +38,13 @@ export declare const snpLogicActions: {
|
|
|
23
38
|
setPreppedProperties(blockName: BlockName, properties: PreppedSimpleNativePanelsAndTabs | false): SNPLogicActions;
|
|
24
39
|
};
|
|
25
40
|
export declare const snpLogicSelectors: {
|
|
26
|
-
desiccatedProperties(state:
|
|
27
|
-
preppedProperties(state:
|
|
28
|
-
extraPropTransforms(state:
|
|
29
|
-
computedExtraPropTransforms(state:
|
|
41
|
+
desiccatedProperties(state: SNPLogicState, blockName: BlockName): (SimpleNativePanel | SimpleNativeTab)[] | undefined;
|
|
42
|
+
preppedProperties(state: SNPLogicState, blockName: BlockName): false | PreppedSimpleNativePanelsAndTabs;
|
|
43
|
+
extraPropTransforms(state: SNPLogicState, blockName: BlockName): ExtraPropTransformsConfig | undefined;
|
|
44
|
+
computedExtraPropTransforms(state: SNPLogicState, blockName: BlockName): false | PerBlockExtraPropTransforms;
|
|
30
45
|
};
|
|
31
|
-
export declare function
|
|
46
|
+
export declare function snpLogic(state: SNPLogicState, action: SNPLogicActions | WordPressMetaActions): SNPLogicState;
|
|
47
|
+
export declare function addProperties(block: BlockName, properties: PropertiesParameter, simpleNativePanelsAndTabs: SNPLogicState['desiccatedProperties']): void;
|
|
32
48
|
/**
|
|
33
49
|
* This performs the one-time prep for rendering the registered SNP panels and tabs for a Block.
|
|
34
50
|
*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getBlockType } from "@wordpress/blocks";
|
|
2
2
|
import { dispatch } from "@wordpress/data";
|
|
3
|
+
import { produce } from "immer";
|
|
3
4
|
import { hydrateSimpleNativeProperty } from "../../blocks/common-native-property-constructors";
|
|
4
5
|
import { isBlockJsonNativePropsConfig } from "../../blocks/snp-api";
|
|
5
6
|
import { store } from "../gutenberg-api-extensions-state";
|
|
@@ -41,6 +42,49 @@ export const snpLogicSelectors = {
|
|
|
41
42
|
return res;
|
|
42
43
|
}
|
|
43
44
|
};
|
|
45
|
+
export function snpLogic(state, action) {
|
|
46
|
+
switch (action.type) {
|
|
47
|
+
case "ADD_PROPERTIES":
|
|
48
|
+
return produce(state, (draft) => {
|
|
49
|
+
if (Array.isArray(action.blockName)) {
|
|
50
|
+
for (const bn of action.blockName) {
|
|
51
|
+
addProperties(bn, action.properties, draft.desiccatedProperties);
|
|
52
|
+
draft.preppedProperties[bn] = undefined;
|
|
53
|
+
draft.extraPropTransforms[bn] = undefined;
|
|
54
|
+
draft.computedExtraPropTransforms[bn] = undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
addProperties(action.blockName, action.properties, draft.desiccatedProperties);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
case "ADD_OR_UPDATE_EXTRA_PROP_TRANSFORM":
|
|
62
|
+
return produce(state, (draft) => {
|
|
63
|
+
const blockTransforms = draft.extraPropTransforms[action.blockName] ?? (draft.extraPropTransforms[action.blockName] = {});
|
|
64
|
+
if (blockTransforms[action.propPath]) {
|
|
65
|
+
blockTransforms[action.propPath].styleProperty = action.extraPropTransform.styleProperty;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
blockTransforms[action.propPath] = action.extraPropTransform;
|
|
69
|
+
}
|
|
70
|
+
draft.computedExtraPropTransforms[action.blockName] = undefined;
|
|
71
|
+
});
|
|
72
|
+
case "SET_PREPPED_PROPERTIES":
|
|
73
|
+
return produce(state, (draft) => {
|
|
74
|
+
draft.preppedProperties[action.blockName] = action.properties;
|
|
75
|
+
});
|
|
76
|
+
case "SET_EXTRA_PROP_TRANSFORMS":
|
|
77
|
+
return produce(state, (draft) => {
|
|
78
|
+
draft.extraPropTransforms[action.blockName] = action.extraPropTransforms;
|
|
79
|
+
});
|
|
80
|
+
case "SET_COMPUTED_EXTRA_PROP_TRANSFORMS":
|
|
81
|
+
return produce(state, (draft) => {
|
|
82
|
+
draft.computedExtraPropTransforms[action.blockName] = action.computedExtraPropTransforms;
|
|
83
|
+
});
|
|
84
|
+
default:
|
|
85
|
+
return state;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
44
88
|
export function addProperties(block, properties, simpleNativePanelsAndTabs) {
|
|
45
89
|
const panels = (simpleNativePanelsAndTabs[block] ?? (simpleNativePanelsAndTabs[block] = []));
|
|
46
90
|
if ('title' in properties) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snp-logic.js","sourceRoot":"","sources":["../../../src/lib/gutenberg-api-extensions-state/snp-logic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAC,QAAQ,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"snp-logic.js","sourceRoot":"","sources":["../../../src/lib/gutenberg-api-extensions-state/snp-logic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAC,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAG9B,OAAO,EAAC,2BAA2B,EAA4B,MAAM,kDAAkD,CAAC;AAQxH,OAAO,EAAC,4BAA4B,EAAqB,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAA6C,KAAK,EAAC,MAAM,mCAAmC,CAAC;AAgBpG,MAAM,CAAC,MAAM,eAAe,GAAG;IAC9B,aAAa,CAAC,SAAgC,EAAE,UAA0B;QACzE,OAAO,EAAC,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,UAAU,EAAC,CAAC;IACxD,CAAC;IACD,6BAA6B,CAAC,SAAoB,EAAE,QAAgB,EAAE,kBAAqD;QAC1H,OAAO,EAAC,IAAI,EAAE,oCAAoC,EAAE,SAAS,EAAE,QAAQ,EAAE,kBAAkB,EAAC,CAAC;IAC9F,CAAC;IACD,8BAA8B,CAAC,SAAoB,EAAE,2BAA8D;QAClH,OAAO,EAAC,IAAI,EAAE,oCAAoC,EAAE,SAAS,EAAE,2BAA2B,EAAC,CAAC;IAC7F,CAAC;IACD,oBAAoB,CAAC,SAAoB,EAAE,UAAkD;QAC5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CAAC,CAAC,KAAK,CAAC;IACT,OAAO,UAAU,CAAC,CAAC,CAAC,EAAC,UAAU,EAAE,eAAe,EAAE,CAAC,4BAA4B,CAAC,SAAS,CAAC,OAAO,CAAC,EAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC7G,CAAC"}
|
|
@@ -1,42 +1,15 @@
|
|
|
1
1
|
import { dispatch, select, StoreDescriptor } from "@wordpress/data";
|
|
2
|
-
import type { BlockName,
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { LayeredBlockStylesLogicActions } from "./gutenberg-api-extensions-state/layered-block-styles-logic";
|
|
6
|
-
import { SNPLogicActions } from "./gutenberg-api-extensions-state/snp-logic";
|
|
7
|
-
import { CustomBlockBindingsSupportLogicActions } from "./gutenberg-api-extensions-state/custom-block-bindings-support-logic";
|
|
2
|
+
import type { BlockName, LaidOutProperties, SimpleNativePanel, SimpleNativeTab } from "../blocks";
|
|
3
|
+
import { CustomBlockBindingsSupportLogicActions, CustomBlockBindingsSupportLogicState } from "./gutenberg-api-extensions-state/custom-block-bindings-support-logic";
|
|
4
|
+
import { GeneralLogicActions, GeneralLogicState } from "./gutenberg-api-extensions-state/general-logic";
|
|
5
|
+
import { LayeredBlockStylesLogicActions, LayeredBlockStylesLogicState } from "./gutenberg-api-extensions-state/layered-block-styles-logic";
|
|
6
|
+
import { SNPLogicActions, SNPLogicState } from "./gutenberg-api-extensions-state/snp-logic";
|
|
8
7
|
import type { WordPressMetaActions } from "./useful-types";
|
|
9
8
|
export type State = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
layeredBlockStyles: {
|
|
16
|
-
[blockName in BlockName]?: {
|
|
17
|
-
[name in string]: PDSimpleNativeProperty;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
desiccatedProperties: {
|
|
21
|
-
[blockName in BlockName]?: Array<SimpleNativePanel | SimpleNativeTab>;
|
|
22
|
-
};
|
|
23
|
-
preppedProperties: {
|
|
24
|
-
[blockName in BlockName]?: PreppedSimpleNativePanelsAndTabs | false;
|
|
25
|
-
};
|
|
26
|
-
extraPropTransforms: {
|
|
27
|
-
[blockName in BlockName]?: ExtraPropTransformsConfig;
|
|
28
|
-
};
|
|
29
|
-
computedExtraPropTransforms: {
|
|
30
|
-
[blockName in BlockName]?: PerBlockExtraPropTransforms | false;
|
|
31
|
-
};
|
|
32
|
-
baselineBlockAttrs: {
|
|
33
|
-
[blockName in BlockName]?: RegisterBlockAttrs<Record<string, any>>;
|
|
34
|
-
};
|
|
35
|
-
features: {
|
|
36
|
-
[name in string]?: {
|
|
37
|
-
[prop in string]: any;
|
|
38
|
-
};
|
|
39
|
-
};
|
|
9
|
+
customBlockBindingsSupportLogic: CustomBlockBindingsSupportLogicState;
|
|
10
|
+
layeredBlockStylesLogic: LayeredBlockStylesLogicState;
|
|
11
|
+
snpLogic: SNPLogicState;
|
|
12
|
+
generalLogic: GeneralLogicState;
|
|
40
13
|
};
|
|
41
14
|
export type BareProperties = SimpleNativePanel | SimpleNativeTab | Array<LaidOutProperties[number] | SimpleNativePanel | SimpleNativeTab>;
|
|
42
15
|
export type NamedBlockAction<A extends string, P = {}> = {
|
|
@@ -58,49 +31,89 @@ export type PromisifyFunctionReturns<T extends {
|
|
|
58
31
|
}> = {
|
|
59
32
|
[K in keyof T]: (...args: Parameters<T[K]>) => Promise<ReturnType<T[K]>>;
|
|
60
33
|
};
|
|
61
|
-
type ReducerActions = CustomBlockBindingsSupportLogicActions | LayeredBlockStylesLogicActions | SNPLogicActions |
|
|
62
|
-
type: 'RECORD_BASELINE_BLOCK_ATTRS';
|
|
63
|
-
attrs: RegisterBlockAttrs<Record<string, any>>;
|
|
64
|
-
} | {
|
|
65
|
-
type: "SET_FEATURE_PROP";
|
|
66
|
-
feature: string;
|
|
67
|
-
prop: string;
|
|
68
|
-
value: any;
|
|
69
|
-
};
|
|
34
|
+
type ReducerActions = CustomBlockBindingsSupportLogicActions | LayeredBlockStylesLogicActions | SNPLogicActions | GeneralLogicActions;
|
|
70
35
|
export declare const store: import("@wordpress/data/build-types/types").StoreDescriptor<import("@wordpress/data/build-types/types").ReduxStoreConfig<State, {
|
|
71
|
-
recordBaselineBlockAttrs(attrs: RegisterBlockAttrs<Record<string, any>>):
|
|
72
|
-
setFeatureProp(feature: string, prop: string, value: any):
|
|
36
|
+
recordBaselineBlockAttrs(attrs: import("../blocks/snp-api").RegisterBlockAttrs<Record<string, any>>): GeneralLogicActions;
|
|
37
|
+
setFeatureProp(feature: string, prop: string, value: any): GeneralLogicActions;
|
|
73
38
|
addProperties(blockName: BlockName | BlockName[], properties: BareProperties): SNPLogicActions;
|
|
74
|
-
addOrUpdateExtraPropTransform(blockName: BlockName, propPath: string, extraPropTransform: ExtraPropTransformsConfig[string]): SNPLogicActions;
|
|
75
|
-
setComputedExtraPropTransforms(blockName: BlockName, computedExtraPropTransforms: PerBlockExtraPropTransforms | false): SNPLogicActions;
|
|
76
|
-
setPreppedProperties(blockName: BlockName, properties: PreppedSimpleNativePanelsAndTabs | false): SNPLogicActions;
|
|
77
|
-
addLayeredBlockStyles(blockName: BlockName, properties: PDSimpleNativeProperty[]): {
|
|
39
|
+
addOrUpdateExtraPropTransform(blockName: BlockName, propPath: string, extraPropTransform: import("../blocks/simple-native-property-internal-shared").ExtraPropTransformsConfig[string]): SNPLogicActions;
|
|
40
|
+
setComputedExtraPropTransforms(blockName: BlockName, computedExtraPropTransforms: import("../blocks/simple-native-property-internal-shared").PerBlockExtraPropTransforms | false): SNPLogicActions;
|
|
41
|
+
setPreppedProperties(blockName: BlockName, properties: import("../blocks/simple-native-property-internal-shared").PreppedSimpleNativePanelsAndTabs | false): SNPLogicActions;
|
|
42
|
+
addLayeredBlockStyles(blockName: BlockName, properties: import("../blocks").PDSimpleNativeProperty[]): {
|
|
78
43
|
type: string;
|
|
79
44
|
blockName: `${string}/${string}`;
|
|
80
|
-
properties: PDSimpleNativeProperty[];
|
|
45
|
+
properties: import("../blocks").PDSimpleNativeProperty[];
|
|
81
46
|
};
|
|
82
47
|
registerCustomBlockBindingsSource(args: Parameters<typeof import("@wordpress/blocks").registerBlockBindingsSource>[0] & {
|
|
83
|
-
dbSources?: DbSource[];
|
|
48
|
+
dbSources?: import("../blocks").DbSource[];
|
|
84
49
|
}): {
|
|
85
50
|
type: string;
|
|
86
51
|
name: string;
|
|
87
52
|
value: {
|
|
88
|
-
dbSources: (DBSource[] & DbSource[]) | undefined;
|
|
53
|
+
dbSources: (DBSource[] & import("../blocks").DbSource[]) | undefined;
|
|
89
54
|
};
|
|
90
55
|
};
|
|
91
56
|
}, {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
blockStylesLayers(state: State, blockName: BlockName): {
|
|
100
|
-
[x: string]: PDSimpleNativeProperty;
|
|
57
|
+
customBlockBindingsSource: (state: {
|
|
58
|
+
customBlockBindingsSupportLogic: CustomBlockBindingsSupportLogicState;
|
|
59
|
+
layeredBlockStylesLogic: LayeredBlockStylesLogicState;
|
|
60
|
+
snpLogic: SNPLogicState;
|
|
61
|
+
generalLogic: GeneralLogicState;
|
|
62
|
+
}, name: string) => {
|
|
63
|
+
dbSources?: import("../blocks").DbSource[];
|
|
101
64
|
} | undefined;
|
|
102
|
-
|
|
103
|
-
|
|
65
|
+
} & {
|
|
66
|
+
blockStylesLayer: (state: {
|
|
67
|
+
customBlockBindingsSupportLogic: CustomBlockBindingsSupportLogicState;
|
|
68
|
+
layeredBlockStylesLogic: LayeredBlockStylesLogicState;
|
|
69
|
+
snpLogic: SNPLogicState;
|
|
70
|
+
generalLogic: GeneralLogicState;
|
|
71
|
+
}, blockName: `${string}/${string}`, layerName: string) => import("../blocks").PDSimpleNativeProperty | undefined;
|
|
72
|
+
blockStylesLayers: (state: {
|
|
73
|
+
customBlockBindingsSupportLogic: CustomBlockBindingsSupportLogicState;
|
|
74
|
+
layeredBlockStylesLogic: LayeredBlockStylesLogicState;
|
|
75
|
+
snpLogic: SNPLogicState;
|
|
76
|
+
generalLogic: GeneralLogicState;
|
|
77
|
+
}, blockName: `${string}/${string}`) => {
|
|
78
|
+
[x: string]: import("../blocks").PDSimpleNativeProperty;
|
|
104
79
|
} | undefined;
|
|
80
|
+
} & {
|
|
81
|
+
desiccatedProperties: (state: {
|
|
82
|
+
customBlockBindingsSupportLogic: CustomBlockBindingsSupportLogicState;
|
|
83
|
+
layeredBlockStylesLogic: LayeredBlockStylesLogicState;
|
|
84
|
+
snpLogic: SNPLogicState;
|
|
85
|
+
generalLogic: GeneralLogicState;
|
|
86
|
+
}, blockName: `${string}/${string}`) => (SimpleNativePanel | SimpleNativeTab)[] | undefined;
|
|
87
|
+
preppedProperties: (state: {
|
|
88
|
+
customBlockBindingsSupportLogic: CustomBlockBindingsSupportLogicState;
|
|
89
|
+
layeredBlockStylesLogic: LayeredBlockStylesLogicState;
|
|
90
|
+
snpLogic: SNPLogicState;
|
|
91
|
+
generalLogic: GeneralLogicState;
|
|
92
|
+
}, blockName: `${string}/${string}`) => false | import("../blocks/simple-native-property-internal-shared").PreppedSimpleNativePanelsAndTabs;
|
|
93
|
+
extraPropTransforms: (state: {
|
|
94
|
+
customBlockBindingsSupportLogic: CustomBlockBindingsSupportLogicState;
|
|
95
|
+
layeredBlockStylesLogic: LayeredBlockStylesLogicState;
|
|
96
|
+
snpLogic: SNPLogicState;
|
|
97
|
+
generalLogic: GeneralLogicState;
|
|
98
|
+
}, blockName: `${string}/${string}`) => import("../blocks/simple-native-property-internal-shared").ExtraPropTransformsConfig | undefined;
|
|
99
|
+
computedExtraPropTransforms: (state: {
|
|
100
|
+
customBlockBindingsSupportLogic: CustomBlockBindingsSupportLogicState;
|
|
101
|
+
layeredBlockStylesLogic: LayeredBlockStylesLogicState;
|
|
102
|
+
snpLogic: SNPLogicState;
|
|
103
|
+
generalLogic: GeneralLogicState;
|
|
104
|
+
}, blockName: `${string}/${string}`) => false | import("../blocks/simple-native-property-internal-shared").PerBlockExtraPropTransforms;
|
|
105
|
+
} & {
|
|
106
|
+
baselineBlockAttrs: (state: {
|
|
107
|
+
customBlockBindingsSupportLogic: CustomBlockBindingsSupportLogicState;
|
|
108
|
+
layeredBlockStylesLogic: LayeredBlockStylesLogicState;
|
|
109
|
+
snpLogic: SNPLogicState;
|
|
110
|
+
generalLogic: GeneralLogicState;
|
|
111
|
+
}, blockName: `${string}/${string}`) => import("../blocks/snp-api").RegisterBlockAttrs<Record<string, any>> | undefined;
|
|
112
|
+
featureProp: (state: {
|
|
113
|
+
customBlockBindingsSupportLogic: CustomBlockBindingsSupportLogicState;
|
|
114
|
+
layeredBlockStylesLogic: LayeredBlockStylesLogicState;
|
|
115
|
+
snpLogic: SNPLogicState;
|
|
116
|
+
generalLogic: GeneralLogicState;
|
|
117
|
+
}, feature: string, prop: string) => any;
|
|
105
118
|
}>>;
|
|
106
119
|
export {};
|
|
@@ -1,104 +1,46 @@
|
|
|
1
|
-
import { createReduxStore, register } from "@wordpress/data";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { combineReducers, createReduxStore, register } from "@wordpress/data";
|
|
2
|
+
import { customBlockBindingsSupportLogic, customBlockBindingsSupportLogicActions, customBlockBindingsSupportLogicSelectors } from "./gutenberg-api-extensions-state/custom-block-bindings-support-logic";
|
|
3
|
+
import { generalLogic, generalLogicActions, generalLogicSelectors } from "./gutenberg-api-extensions-state/general-logic";
|
|
4
|
+
import { layeredBlockStylesLogic, layeredBlockStylesLogicActions, layeredBlockStylesLogicSelectors } from "./gutenberg-api-extensions-state/layered-block-styles-logic";
|
|
5
|
+
import { snpLogic, snpLogicActions, snpLogicSelectors } from "./gutenberg-api-extensions-state/snp-logic";
|
|
6
|
+
import { combineSelectors } from "./helpers";
|
|
7
7
|
const DEFAULT_STATE = {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
customBlockBindingsSupportLogic: {
|
|
9
|
+
customBlockBindingsSupport: {}
|
|
10
|
+
},
|
|
11
|
+
layeredBlockStylesLogic: {
|
|
12
|
+
layeredBlockStyles: {}
|
|
13
|
+
},
|
|
14
|
+
snpLogic: {
|
|
15
|
+
desiccatedProperties: {},
|
|
16
|
+
preppedProperties: {},
|
|
17
|
+
extraPropTransforms: {},
|
|
18
|
+
computedExtraPropTransforms: {}
|
|
19
|
+
},
|
|
20
|
+
generalLogic: {
|
|
21
|
+
baselineBlockAttrs: {}, features: {}
|
|
22
|
+
}
|
|
10
23
|
};
|
|
11
24
|
export const store = createReduxStore('gutenberg-api-extensions-state', {
|
|
12
25
|
initialState: DEFAULT_STATE,
|
|
13
|
-
reducer(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
case "ADD_LAYERED_BLOCK_STYLES":
|
|
20
|
-
return produce(state, (result) => {
|
|
21
|
-
const blockLayeredStyles = result.layeredBlockStyles[action.blockName] ?? (result.layeredBlockStyles[action.blockName] = {});
|
|
22
|
-
for (const layer of action.properties) {
|
|
23
|
-
blockLayeredStyles[layer.name] = layer;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
case "SET_LAYERED_BLOCK_STYLES":
|
|
27
|
-
return produce(state, (result) => {
|
|
28
|
-
result.layeredBlockStyles[action.blockName] = action.properties;
|
|
29
|
-
});
|
|
30
|
-
case "ADD_PROPERTIES":
|
|
31
|
-
return produce(state, (result) => {
|
|
32
|
-
if (Array.isArray(action.blockName)) {
|
|
33
|
-
for (const bn of action.blockName) {
|
|
34
|
-
addProperties(bn, action.properties, result.desiccatedProperties);
|
|
35
|
-
result.preppedProperties[bn] = undefined;
|
|
36
|
-
result.extraPropTransforms[bn] = undefined;
|
|
37
|
-
result.computedExtraPropTransforms[bn] = undefined;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
addProperties(action.blockName, action.properties, result.desiccatedProperties);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
case "ADD_OR_UPDATE_EXTRA_PROP_TRANSFORM":
|
|
45
|
-
return produce(state, (result) => {
|
|
46
|
-
const blockTransforms = result.extraPropTransforms[action.blockName] ?? (result.extraPropTransforms[action.blockName] = {});
|
|
47
|
-
if (blockTransforms[action.propPath]) {
|
|
48
|
-
blockTransforms[action.propPath].styleProperty = action.extraPropTransform.styleProperty;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
blockTransforms[action.propPath] = action.extraPropTransform;
|
|
52
|
-
}
|
|
53
|
-
result.computedExtraPropTransforms[action.blockName] = undefined;
|
|
54
|
-
});
|
|
55
|
-
case "SET_PREPPED_PROPERTIES":
|
|
56
|
-
return produce(state, (result) => {
|
|
57
|
-
result.preppedProperties[action.blockName] = action.properties;
|
|
58
|
-
});
|
|
59
|
-
case "SET_EXTRA_PROP_TRANSFORMS":
|
|
60
|
-
return produce(state, (result) => {
|
|
61
|
-
result.extraPropTransforms[action.blockName] = action.extraPropTransforms;
|
|
62
|
-
});
|
|
63
|
-
case "SET_COMPUTED_EXTRA_PROP_TRANSFORMS":
|
|
64
|
-
return produce(state, (result) => {
|
|
65
|
-
result.computedExtraPropTransforms[action.blockName] = action.computedExtraPropTransforms;
|
|
66
|
-
});
|
|
67
|
-
case "RECORD_BASELINE_BLOCK_ATTRS":
|
|
68
|
-
return produce(state, (result) => {
|
|
69
|
-
if (!(action.attrs.name in result.baselineBlockAttrs)) {
|
|
70
|
-
result.baselineBlockAttrs[action.attrs.name] = clone(action.attrs);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
case "SET_FEATURE_PROP":
|
|
74
|
-
return produce(state, (result) => {
|
|
75
|
-
(result.features[action.feature] ?? (result.features[action.feature] = {}))[action.prop] = action.value;
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
return state;
|
|
79
|
-
},
|
|
26
|
+
reducer: combineReducers({
|
|
27
|
+
customBlockBindingsSupportLogic,
|
|
28
|
+
layeredBlockStylesLogic,
|
|
29
|
+
snpLogic,
|
|
30
|
+
generalLogic
|
|
31
|
+
}),
|
|
80
32
|
actions: {
|
|
81
33
|
...customBlockBindingsSupportLogicActions,
|
|
82
34
|
...layeredBlockStylesLogicActions,
|
|
83
35
|
...snpLogicActions,
|
|
84
|
-
|
|
85
|
-
return { type: "RECORD_BASELINE_BLOCK_ATTRS", attrs };
|
|
86
|
-
},
|
|
87
|
-
setFeatureProp(feature, prop, value) {
|
|
88
|
-
return { type: "SET_FEATURE_PROP", feature, prop, value };
|
|
89
|
-
}
|
|
36
|
+
...generalLogicActions
|
|
90
37
|
},
|
|
91
|
-
selectors: {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
},
|
|
98
|
-
featureProp(state, feature, prop) {
|
|
99
|
-
return state.features[feature]?.[prop];
|
|
100
|
-
}
|
|
101
|
-
}
|
|
38
|
+
selectors: combineSelectors({
|
|
39
|
+
customBlockBindingsSupportLogic: customBlockBindingsSupportLogicSelectors,
|
|
40
|
+
layeredBlockStylesLogic: layeredBlockStylesLogicSelectors,
|
|
41
|
+
snpLogic: snpLogicSelectors,
|
|
42
|
+
generalLogic: generalLogicSelectors
|
|
43
|
+
})
|
|
102
44
|
});
|
|
103
45
|
register(store);
|
|
104
46
|
//# sourceMappingURL=gutenberg-api-extensions-state.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gutenberg-api-extensions-state.js","sourceRoot":"","sources":["../../src/lib/gutenberg-api-extensions-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAY,QAAQ,EAA0B,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"gutenberg-api-extensions-state.js","sourceRoot":"","sources":["../../src/lib/gutenberg-api-extensions-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,gBAAgB,EAAY,QAAQ,EA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,KAAK,CAAC,CAAC"}
|
package/build/lib/helpers.d.ts
CHANGED
|
@@ -1 +1,21 @@
|
|
|
1
|
+
import type { SubsequentArgsOfFunc } from "./useful-types";
|
|
1
2
|
export declare function clone(value: any): any;
|
|
3
|
+
type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends ((x: infer I) => void) ? I : never;
|
|
4
|
+
type SelectorsForT<S, ST> = S extends {
|
|
5
|
+
[SELECTOR in string]: (state: any, ...args: any[]) => any;
|
|
6
|
+
} ? {
|
|
7
|
+
[SL in keyof S]: (state: ST, ...args: SubsequentArgsOfFunc<S[SL]>) => ReturnType<S[SL]>;
|
|
8
|
+
} : never;
|
|
9
|
+
type StateFromSelectorsArg<S extends SelectorsArg<any>> = {
|
|
10
|
+
[K in keyof S]: Parameters<S[K][keyof S[K]]>[0];
|
|
11
|
+
};
|
|
12
|
+
type CombinedSelectors<S extends SelectorsArg<any>> = UnionToIntersection<{
|
|
13
|
+
[K in keyof S]: SelectorsForT<S[K], StateFromSelectorsArg<S>>;
|
|
14
|
+
}[keyof S]>;
|
|
15
|
+
type SelectorsArg<S extends {}> = {
|
|
16
|
+
[K in keyof S]: {
|
|
17
|
+
[SELECTOR in string]: (state: S[K], ...args: any[]) => any;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare function combineSelectors<S extends SelectorsArg<any>>(selectors: S): CombinedSelectors<typeof selectors>;
|
|
21
|
+
export {};
|
package/build/lib/helpers.js
CHANGED
|
@@ -7,4 +7,14 @@ export function clone(value) {
|
|
|
7
7
|
}
|
|
8
8
|
return typeof value === 'object' ? Object.fromEntries(Object.entries(value).map(([k, v]) => [k, clone(v)])) : value;
|
|
9
9
|
}
|
|
10
|
+
export function combineSelectors(selectors) {
|
|
11
|
+
return Object.fromEntries(Object.entries(selectors).flatMap(sel => {
|
|
12
|
+
const key = sel[0];
|
|
13
|
+
return (Object.entries(sel[1])).map(nestedSel => {
|
|
14
|
+
return [nestedSel[0], (state, ...args) => {
|
|
15
|
+
return nestedSel[1](state[key], ...args);
|
|
16
|
+
}];
|
|
17
|
+
});
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
10
20
|
//# sourceMappingURL=helpers.js.map
|
package/build/lib/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/lib/helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/lib/helpers.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,KAAK,CAAC,KAAU;IAC/B,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC3C,OAAO,KAAK,CAAC;IACd,CAAC;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACrH,CAAC;AAmBD,MAAM,UAAU,gBAAgB,CAA8B,SAAY;IACzE,OAAO,MAAM,CAAC,WAAW,CAAE,MAAM,CAAC,OAAO,CAAC,SAAS,CAA6B,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAC9F,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QACnB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAC/C,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,KAA+B,EAAE,GAAG,IAA+C,EAAE,EAAE;oBAC7G,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;gBAC1C,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAwC,CAAC;AAC5C,CAAC"}
|
|
@@ -7,3 +7,4 @@ export type NormalizedReduxActionExtractor<V> = V extends {
|
|
|
7
7
|
type: string;
|
|
8
8
|
} ? ReturnType<V> : never);
|
|
9
9
|
export type WordPressMetaActions = NormalizedReduxActionExtractor<typeof MetaActions>;
|
|
10
|
+
export type SubsequentArgsOfFunc<F> = F extends (arg: any, ...args: infer R) => any ? R : never;
|