@measured/puck-plugin-heading-analyzer 0.21.0-canary.ec77dd9f → 0.21.0-canary.ed10e2a4
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/dist/index.d.mts +7 -5
- package/dist/index.d.ts +7 -5
- package/dist/index.js +21 -12
- package/dist/index.mjs +21 -12
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactElement, CSSProperties,
|
|
1
|
+
import { ReactElement, ReactNode, CSSProperties, ElementType, JSX } from 'react';
|
|
2
2
|
|
|
3
3
|
type ItemSelector = {
|
|
4
4
|
index: number;
|
|
@@ -53,7 +53,7 @@ interface ArrayField<Props extends {
|
|
|
53
53
|
} ? Field<Props[0][SubPropName], UserField> | UserField : Field<Props[0][SubPropName], UserField>;
|
|
54
54
|
};
|
|
55
55
|
defaultItemProps?: Props[0] | ((index: number) => Props[0]);
|
|
56
|
-
getItemSummary?: (item: Props[0], index?: number) =>
|
|
56
|
+
getItemSummary?: (item: Props[0], index?: number) => ReactNode;
|
|
57
57
|
max?: number;
|
|
58
58
|
min?: number;
|
|
59
59
|
}
|
|
@@ -80,7 +80,7 @@ type ExternalFieldWithAdaptor<Props extends any = {
|
|
|
80
80
|
placeholder?: string;
|
|
81
81
|
adaptor: Adaptor<any, any, Props>;
|
|
82
82
|
adaptorParams?: object;
|
|
83
|
-
getItemSummary: (item: NotUndefined<Props>, index?: number) =>
|
|
83
|
+
getItemSummary: (item: NotUndefined<Props>, index?: number) => ReactNode;
|
|
84
84
|
};
|
|
85
85
|
type CacheOpts = {
|
|
86
86
|
enabled?: boolean;
|
|
@@ -97,7 +97,7 @@ interface ExternalField<Props extends any = {
|
|
|
97
97
|
}) => Promise<any[] | null>;
|
|
98
98
|
mapProp?: (value: any) => Props;
|
|
99
99
|
mapRow?: (value: any) => Record<string, string | number | ReactElement>;
|
|
100
|
-
getItemSummary?: (item: NotUndefined<Props>, index?: number) =>
|
|
100
|
+
getItemSummary?: (item: NotUndefined<Props>, index?: number) => ReactNode;
|
|
101
101
|
showSearch?: boolean;
|
|
102
102
|
renderFooter?: (props: {
|
|
103
103
|
items: any[];
|
|
@@ -146,9 +146,10 @@ type DropZoneProps = {
|
|
|
146
146
|
allow?: string[];
|
|
147
147
|
disallow?: string[];
|
|
148
148
|
style?: CSSProperties;
|
|
149
|
-
minEmptyHeight?: number;
|
|
149
|
+
minEmptyHeight?: CSSProperties["minHeight"] | number;
|
|
150
150
|
className?: string;
|
|
151
151
|
collisionAxis?: DragAxis;
|
|
152
|
+
as?: ElementType;
|
|
152
153
|
};
|
|
153
154
|
|
|
154
155
|
type PuckContext = {
|
|
@@ -237,6 +238,7 @@ UserField extends BaseField = {}> = {
|
|
|
237
238
|
permissions: Partial<Permissions>;
|
|
238
239
|
appState: AppState;
|
|
239
240
|
lastData: DataShape | null;
|
|
241
|
+
parent: ComponentData | null;
|
|
240
242
|
}) => Promise<Partial<Permissions>> | Partial<Permissions>;
|
|
241
243
|
metadata?: ComponentMetadata;
|
|
242
244
|
} & ComponentConfigExtensions;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactElement, CSSProperties,
|
|
1
|
+
import { ReactElement, ReactNode, CSSProperties, ElementType, JSX } from 'react';
|
|
2
2
|
|
|
3
3
|
type ItemSelector = {
|
|
4
4
|
index: number;
|
|
@@ -53,7 +53,7 @@ interface ArrayField<Props extends {
|
|
|
53
53
|
} ? Field<Props[0][SubPropName], UserField> | UserField : Field<Props[0][SubPropName], UserField>;
|
|
54
54
|
};
|
|
55
55
|
defaultItemProps?: Props[0] | ((index: number) => Props[0]);
|
|
56
|
-
getItemSummary?: (item: Props[0], index?: number) =>
|
|
56
|
+
getItemSummary?: (item: Props[0], index?: number) => ReactNode;
|
|
57
57
|
max?: number;
|
|
58
58
|
min?: number;
|
|
59
59
|
}
|
|
@@ -80,7 +80,7 @@ type ExternalFieldWithAdaptor<Props extends any = {
|
|
|
80
80
|
placeholder?: string;
|
|
81
81
|
adaptor: Adaptor<any, any, Props>;
|
|
82
82
|
adaptorParams?: object;
|
|
83
|
-
getItemSummary: (item: NotUndefined<Props>, index?: number) =>
|
|
83
|
+
getItemSummary: (item: NotUndefined<Props>, index?: number) => ReactNode;
|
|
84
84
|
};
|
|
85
85
|
type CacheOpts = {
|
|
86
86
|
enabled?: boolean;
|
|
@@ -97,7 +97,7 @@ interface ExternalField<Props extends any = {
|
|
|
97
97
|
}) => Promise<any[] | null>;
|
|
98
98
|
mapProp?: (value: any) => Props;
|
|
99
99
|
mapRow?: (value: any) => Record<string, string | number | ReactElement>;
|
|
100
|
-
getItemSummary?: (item: NotUndefined<Props>, index?: number) =>
|
|
100
|
+
getItemSummary?: (item: NotUndefined<Props>, index?: number) => ReactNode;
|
|
101
101
|
showSearch?: boolean;
|
|
102
102
|
renderFooter?: (props: {
|
|
103
103
|
items: any[];
|
|
@@ -146,9 +146,10 @@ type DropZoneProps = {
|
|
|
146
146
|
allow?: string[];
|
|
147
147
|
disallow?: string[];
|
|
148
148
|
style?: CSSProperties;
|
|
149
|
-
minEmptyHeight?: number;
|
|
149
|
+
minEmptyHeight?: CSSProperties["minHeight"] | number;
|
|
150
150
|
className?: string;
|
|
151
151
|
collisionAxis?: DragAxis;
|
|
152
|
+
as?: ElementType;
|
|
152
153
|
};
|
|
153
154
|
|
|
154
155
|
type PuckContext = {
|
|
@@ -237,6 +238,7 @@ UserField extends BaseField = {}> = {
|
|
|
237
238
|
permissions: Partial<Permissions>;
|
|
238
239
|
appState: AppState;
|
|
239
240
|
lastData: DataShape | null;
|
|
241
|
+
parent: ComponentData | null;
|
|
240
242
|
}) => Promise<Partial<Permissions>> | Partial<Permissions>;
|
|
241
243
|
metadata?: ComponentMetadata;
|
|
242
244
|
} & ComponentConfigExtensions;
|
package/dist/index.js
CHANGED
|
@@ -2090,26 +2090,34 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2090
2090
|
const resolvePermissions = (..._0) => __async(null, [..._0], function* (params = {}, force) {
|
|
2091
2091
|
const { state, permissions, config } = get();
|
|
2092
2092
|
const { cache: cache2, globalPermissions } = permissions;
|
|
2093
|
-
const
|
|
2094
|
-
var _a, _b
|
|
2093
|
+
const resolvePermissionsForItem = (item2, force2 = false) => __async(null, null, function* () {
|
|
2094
|
+
var _a, _b;
|
|
2095
2095
|
const { config: config2, state: appState, setComponentLoading } = get();
|
|
2096
|
+
const itemCache = cache2[item2.props.id];
|
|
2097
|
+
const nodes = appState.indexes.nodes;
|
|
2098
|
+
const parentId = (_a = nodes[item2.props.id]) == null ? void 0 : _a.parentId;
|
|
2099
|
+
const parentNode = parentId ? nodes[parentId] : null;
|
|
2100
|
+
const parentData = (_b = parentNode == null ? void 0 : parentNode.data) != null ? _b : null;
|
|
2096
2101
|
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
|
2097
2102
|
if (!componentConfig) {
|
|
2098
2103
|
return;
|
|
2099
2104
|
}
|
|
2100
2105
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
|
2101
2106
|
if (componentConfig.resolvePermissions) {
|
|
2102
|
-
const changed = getChanged(item2,
|
|
2103
|
-
|
|
2107
|
+
const changed = getChanged(item2, itemCache == null ? void 0 : itemCache.lastData);
|
|
2108
|
+
const propsChanged = Object.values(changed).some((el) => el === true);
|
|
2109
|
+
const parentChanged = (itemCache == null ? void 0 : itemCache.lastParentId) !== parentId;
|
|
2110
|
+
if (propsChanged || parentChanged || force2) {
|
|
2104
2111
|
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
|
2105
2112
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
|
2106
2113
|
item2,
|
|
2107
2114
|
{
|
|
2108
2115
|
changed,
|
|
2109
|
-
lastPermissions: (
|
|
2116
|
+
lastPermissions: (itemCache == null ? void 0 : itemCache.lastPermissions) || null,
|
|
2110
2117
|
permissions: initialPermissions,
|
|
2111
2118
|
appState: makeStatePublic(appState),
|
|
2112
|
-
lastData: (
|
|
2119
|
+
lastData: (itemCache == null ? void 0 : itemCache.lastData) || null,
|
|
2120
|
+
parent: parentData
|
|
2113
2121
|
}
|
|
2114
2122
|
);
|
|
2115
2123
|
const latest = get().permissions;
|
|
@@ -2117,6 +2125,7 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2117
2125
|
permissions: __spreadProps(__spreadValues({}, latest), {
|
|
2118
2126
|
cache: __spreadProps(__spreadValues({}, latest.cache), {
|
|
2119
2127
|
[item2.props.id]: {
|
|
2128
|
+
lastParentId: parentId,
|
|
2120
2129
|
lastData: item2,
|
|
2121
2130
|
lastPermissions: resolvedPermissions
|
|
2122
2131
|
}
|
|
@@ -2130,9 +2139,9 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2130
2139
|
}
|
|
2131
2140
|
}
|
|
2132
2141
|
});
|
|
2133
|
-
const
|
|
2142
|
+
const resolvePermissionsForRoot = (force2 = false) => {
|
|
2134
2143
|
const { state: appState } = get();
|
|
2135
|
-
|
|
2144
|
+
resolvePermissionsForItem(
|
|
2136
2145
|
// Shim the root data in by conforming to component data shape
|
|
2137
2146
|
{
|
|
2138
2147
|
type: "root",
|
|
@@ -2143,16 +2152,16 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2143
2152
|
};
|
|
2144
2153
|
const { item, type, root } = params;
|
|
2145
2154
|
if (item) {
|
|
2146
|
-
yield
|
|
2155
|
+
yield resolvePermissionsForItem(item, force);
|
|
2147
2156
|
} else if (type) {
|
|
2148
2157
|
flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(null, null, function* () {
|
|
2149
|
-
yield
|
|
2158
|
+
yield resolvePermissionsForItem(item2, force);
|
|
2150
2159
|
}));
|
|
2151
2160
|
} else if (root) {
|
|
2152
|
-
|
|
2161
|
+
resolvePermissionsForRoot(force);
|
|
2153
2162
|
} else {
|
|
2154
2163
|
flattenData(state, config).map((item2) => __async(null, null, function* () {
|
|
2155
|
-
yield
|
|
2164
|
+
yield resolvePermissionsForItem(item2, force);
|
|
2156
2165
|
}));
|
|
2157
2166
|
}
|
|
2158
2167
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -2078,26 +2078,34 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2078
2078
|
const resolvePermissions = (..._0) => __async(null, [..._0], function* (params = {}, force) {
|
|
2079
2079
|
const { state, permissions, config } = get();
|
|
2080
2080
|
const { cache: cache2, globalPermissions } = permissions;
|
|
2081
|
-
const
|
|
2082
|
-
var _a, _b
|
|
2081
|
+
const resolvePermissionsForItem = (item2, force2 = false) => __async(null, null, function* () {
|
|
2082
|
+
var _a, _b;
|
|
2083
2083
|
const { config: config2, state: appState, setComponentLoading } = get();
|
|
2084
|
+
const itemCache = cache2[item2.props.id];
|
|
2085
|
+
const nodes = appState.indexes.nodes;
|
|
2086
|
+
const parentId = (_a = nodes[item2.props.id]) == null ? void 0 : _a.parentId;
|
|
2087
|
+
const parentNode = parentId ? nodes[parentId] : null;
|
|
2088
|
+
const parentData = (_b = parentNode == null ? void 0 : parentNode.data) != null ? _b : null;
|
|
2084
2089
|
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
|
2085
2090
|
if (!componentConfig) {
|
|
2086
2091
|
return;
|
|
2087
2092
|
}
|
|
2088
2093
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
|
2089
2094
|
if (componentConfig.resolvePermissions) {
|
|
2090
|
-
const changed = getChanged(item2,
|
|
2091
|
-
|
|
2095
|
+
const changed = getChanged(item2, itemCache == null ? void 0 : itemCache.lastData);
|
|
2096
|
+
const propsChanged = Object.values(changed).some((el) => el === true);
|
|
2097
|
+
const parentChanged = (itemCache == null ? void 0 : itemCache.lastParentId) !== parentId;
|
|
2098
|
+
if (propsChanged || parentChanged || force2) {
|
|
2092
2099
|
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
|
2093
2100
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
|
2094
2101
|
item2,
|
|
2095
2102
|
{
|
|
2096
2103
|
changed,
|
|
2097
|
-
lastPermissions: (
|
|
2104
|
+
lastPermissions: (itemCache == null ? void 0 : itemCache.lastPermissions) || null,
|
|
2098
2105
|
permissions: initialPermissions,
|
|
2099
2106
|
appState: makeStatePublic(appState),
|
|
2100
|
-
lastData: (
|
|
2107
|
+
lastData: (itemCache == null ? void 0 : itemCache.lastData) || null,
|
|
2108
|
+
parent: parentData
|
|
2101
2109
|
}
|
|
2102
2110
|
);
|
|
2103
2111
|
const latest = get().permissions;
|
|
@@ -2105,6 +2113,7 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2105
2113
|
permissions: __spreadProps(__spreadValues({}, latest), {
|
|
2106
2114
|
cache: __spreadProps(__spreadValues({}, latest.cache), {
|
|
2107
2115
|
[item2.props.id]: {
|
|
2116
|
+
lastParentId: parentId,
|
|
2108
2117
|
lastData: item2,
|
|
2109
2118
|
lastPermissions: resolvedPermissions
|
|
2110
2119
|
}
|
|
@@ -2118,9 +2127,9 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2118
2127
|
}
|
|
2119
2128
|
}
|
|
2120
2129
|
});
|
|
2121
|
-
const
|
|
2130
|
+
const resolvePermissionsForRoot = (force2 = false) => {
|
|
2122
2131
|
const { state: appState } = get();
|
|
2123
|
-
|
|
2132
|
+
resolvePermissionsForItem(
|
|
2124
2133
|
// Shim the root data in by conforming to component data shape
|
|
2125
2134
|
{
|
|
2126
2135
|
type: "root",
|
|
@@ -2131,16 +2140,16 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2131
2140
|
};
|
|
2132
2141
|
const { item, type, root } = params;
|
|
2133
2142
|
if (item) {
|
|
2134
|
-
yield
|
|
2143
|
+
yield resolvePermissionsForItem(item, force);
|
|
2135
2144
|
} else if (type) {
|
|
2136
2145
|
flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(null, null, function* () {
|
|
2137
|
-
yield
|
|
2146
|
+
yield resolvePermissionsForItem(item2, force);
|
|
2138
2147
|
}));
|
|
2139
2148
|
} else if (root) {
|
|
2140
|
-
|
|
2149
|
+
resolvePermissionsForRoot(force);
|
|
2141
2150
|
} else {
|
|
2142
2151
|
flattenData(state, config).map((item2) => __async(null, null, function* () {
|
|
2143
|
-
yield
|
|
2152
|
+
yield resolvePermissionsForItem(item2, force);
|
|
2144
2153
|
}));
|
|
2145
2154
|
}
|
|
2146
2155
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@measured/puck-plugin-heading-analyzer",
|
|
3
|
-
"version": "0.21.0-canary.
|
|
3
|
+
"version": "0.21.0-canary.ed10e2a4",
|
|
4
4
|
"author": "Chris Villa <chris@puckeditor.com>",
|
|
5
5
|
"repository": "measuredco/puck",
|
|
6
6
|
"bugs": "https://github.com/measuredco/puck/issues",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@measured/puck": "^0.21.0-canary.
|
|
28
|
+
"@measured/puck": "^0.21.0-canary.ed10e2a4",
|
|
29
29
|
"@types/minimatch": "3.0.5",
|
|
30
30
|
"@types/react": "^19.0.1",
|
|
31
31
|
"@types/react-dom": "^19.0.2",
|