@measured/puck 0.16.1 → 0.16.2-canary.18657a4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/chunk-YNVK2PUD.mjs +248 -0
- package/dist/index.css +10 -10
- package/dist/index.d.mts +3 -5
- package/dist/index.d.ts +3 -5
- package/dist/index.js +3 -3
- package/dist/index.mjs +14 -136
- package/dist/{actions-9pHbVtMU.d.mts → resolve-all-data-CaDAfEAK.d.mts} +3 -1
- package/dist/{actions-9pHbVtMU.d.ts → resolve-all-data-CaDAfEAK.d.ts} +3 -1
- package/dist/rsc.d.mts +2 -1
- package/dist/rsc.d.ts +2 -1
- package/dist/rsc.js +144 -2
- package/dist/rsc.mjs +4 -2
- package/package.json +1 -1
- package/dist/chunk-LM7YWFFF.mjs +0 -114
@@ -0,0 +1,248 @@
|
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __defProps = Object.defineProperties;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
12
|
+
var __spreadValues = (a, b) => {
|
13
|
+
for (var prop in b || (b = {}))
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
16
|
+
if (__getOwnPropSymbols)
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
18
|
+
if (__propIsEnum.call(b, prop))
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
20
|
+
}
|
21
|
+
return a;
|
22
|
+
};
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
24
|
+
var __objRest = (source, exclude) => {
|
25
|
+
var target = {};
|
26
|
+
for (var prop in source)
|
27
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
28
|
+
target[prop] = source[prop];
|
29
|
+
if (source != null && __getOwnPropSymbols)
|
30
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
31
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
32
|
+
target[prop] = source[prop];
|
33
|
+
}
|
34
|
+
return target;
|
35
|
+
};
|
36
|
+
var __esm = (fn, res) => function __init() {
|
37
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
38
|
+
};
|
39
|
+
var __commonJS = (cb, mod) => function __require() {
|
40
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
41
|
+
};
|
42
|
+
var __copyProps = (to, from, except, desc) => {
|
43
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
44
|
+
for (let key of __getOwnPropNames(from))
|
45
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
46
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
47
|
+
}
|
48
|
+
return to;
|
49
|
+
};
|
50
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
51
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
52
|
+
// file that has been converted to a CommonJS file using a Babel-
|
53
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
54
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
55
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
56
|
+
mod
|
57
|
+
));
|
58
|
+
var __async = (__this, __arguments, generator) => {
|
59
|
+
return new Promise((resolve, reject) => {
|
60
|
+
var fulfilled = (value) => {
|
61
|
+
try {
|
62
|
+
step(generator.next(value));
|
63
|
+
} catch (e) {
|
64
|
+
reject(e);
|
65
|
+
}
|
66
|
+
};
|
67
|
+
var rejected = (value) => {
|
68
|
+
try {
|
69
|
+
step(generator.throw(value));
|
70
|
+
} catch (e) {
|
71
|
+
reject(e);
|
72
|
+
}
|
73
|
+
};
|
74
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
75
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
76
|
+
});
|
77
|
+
};
|
78
|
+
|
79
|
+
// ../tsup-config/react-import.js
|
80
|
+
import React from "react";
|
81
|
+
var init_react_import = __esm({
|
82
|
+
"../tsup-config/react-import.js"() {
|
83
|
+
"use strict";
|
84
|
+
}
|
85
|
+
});
|
86
|
+
|
87
|
+
// lib/resolve-all-data.ts
|
88
|
+
init_react_import();
|
89
|
+
|
90
|
+
// lib/resolve-component-data.ts
|
91
|
+
init_react_import();
|
92
|
+
|
93
|
+
// lib/get-changed.ts
|
94
|
+
init_react_import();
|
95
|
+
var getChanged = (newItem, oldItem) => {
|
96
|
+
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
97
|
+
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
98
|
+
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
99
|
+
return __spreadProps(__spreadValues({}, acc), {
|
100
|
+
[item]: oldItemProps[item] !== newItemProps[item]
|
101
|
+
});
|
102
|
+
}, {}) : {};
|
103
|
+
};
|
104
|
+
|
105
|
+
// lib/resolve-component-data.ts
|
106
|
+
var cache = { lastChange: {} };
|
107
|
+
var resolveAllComponentData = (content, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
|
108
|
+
return yield Promise.all(
|
109
|
+
content.map((item) => __async(void 0, null, function* () {
|
110
|
+
return yield resolveComponentData(
|
111
|
+
item,
|
112
|
+
config,
|
113
|
+
onResolveStart,
|
114
|
+
onResolveEnd
|
115
|
+
);
|
116
|
+
}))
|
117
|
+
);
|
118
|
+
});
|
119
|
+
var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
|
120
|
+
const configForItem = config.components[item.type];
|
121
|
+
if (configForItem.resolveData) {
|
122
|
+
const { item: oldItem = null, resolved = {} } = cache.lastChange[item.props.id] || {};
|
123
|
+
if (item && item === oldItem) {
|
124
|
+
return resolved;
|
125
|
+
}
|
126
|
+
const changed = getChanged(item, oldItem);
|
127
|
+
if (onResolveStart) {
|
128
|
+
onResolveStart(item);
|
129
|
+
}
|
130
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, { changed, lastData: oldItem });
|
131
|
+
const { readOnly: existingReadOnly = {} } = item || {};
|
132
|
+
const newReadOnly = __spreadValues(__spreadValues({}, existingReadOnly), readOnly);
|
133
|
+
const resolvedItem = __spreadProps(__spreadValues({}, item), {
|
134
|
+
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
135
|
+
});
|
136
|
+
if (Object.keys(newReadOnly).length) {
|
137
|
+
resolvedItem.readOnly = newReadOnly;
|
138
|
+
}
|
139
|
+
cache.lastChange[item.props.id] = {
|
140
|
+
item,
|
141
|
+
resolved: resolvedItem
|
142
|
+
};
|
143
|
+
if (onResolveEnd) {
|
144
|
+
onResolveEnd(resolvedItem);
|
145
|
+
}
|
146
|
+
return resolvedItem;
|
147
|
+
}
|
148
|
+
return item;
|
149
|
+
});
|
150
|
+
|
151
|
+
// lib/resolve-root-data.ts
|
152
|
+
init_react_import();
|
153
|
+
var cache2 = {};
|
154
|
+
function resolveRootData(data, config) {
|
155
|
+
return __async(this, null, function* () {
|
156
|
+
var _a, _b, _c, _d, _e;
|
157
|
+
if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
|
158
|
+
if (((_b = cache2.lastChange) == null ? void 0 : _b.original) === data.root) {
|
159
|
+
return cache2.lastChange.resolved;
|
160
|
+
}
|
161
|
+
const changed = getChanged(data.root, (_c = cache2.lastChange) == null ? void 0 : _c.original);
|
162
|
+
const rootWithProps = data.root;
|
163
|
+
const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
|
164
|
+
changed,
|
165
|
+
lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {}
|
166
|
+
});
|
167
|
+
cache2.lastChange = {
|
168
|
+
original: data.root,
|
169
|
+
resolved: resolvedRoot
|
170
|
+
};
|
171
|
+
return __spreadProps(__spreadValues(__spreadValues({}, data.root), resolvedRoot), {
|
172
|
+
props: __spreadValues(__spreadValues({}, data.root.props), resolvedRoot.props)
|
173
|
+
});
|
174
|
+
}
|
175
|
+
return data.root;
|
176
|
+
});
|
177
|
+
}
|
178
|
+
|
179
|
+
// lib/default-data.ts
|
180
|
+
init_react_import();
|
181
|
+
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
182
|
+
root: data.root || {},
|
183
|
+
content: data.content || []
|
184
|
+
});
|
185
|
+
|
186
|
+
// lib/resolve-all-data.ts
|
187
|
+
function resolveAllData(data, config, onResolveStart, onResolveEnd) {
|
188
|
+
return __async(this, null, function* () {
|
189
|
+
const defaultedData = defaultData(data);
|
190
|
+
const dynamicRoot = yield resolveRootData(defaultedData, config);
|
191
|
+
const { zones = {} } = data;
|
192
|
+
const zoneKeys = Object.keys(zones);
|
193
|
+
const resolvedZones = {};
|
194
|
+
for (let i = 0; i < zoneKeys.length; i++) {
|
195
|
+
const zoneKey = zoneKeys[i];
|
196
|
+
resolvedZones[zoneKey] = yield resolveAllComponentData(
|
197
|
+
zones[zoneKey],
|
198
|
+
config,
|
199
|
+
onResolveStart,
|
200
|
+
onResolveEnd
|
201
|
+
);
|
202
|
+
}
|
203
|
+
return __spreadProps(__spreadValues({}, defaultedData), {
|
204
|
+
root: dynamicRoot,
|
205
|
+
content: yield resolveAllComponentData(
|
206
|
+
defaultedData.content,
|
207
|
+
config,
|
208
|
+
onResolveStart,
|
209
|
+
onResolveEnd
|
210
|
+
),
|
211
|
+
zones: resolvedZones
|
212
|
+
});
|
213
|
+
});
|
214
|
+
}
|
215
|
+
|
216
|
+
// lib/root-droppable-id.ts
|
217
|
+
init_react_import();
|
218
|
+
var rootDroppableId = "default-zone";
|
219
|
+
|
220
|
+
// lib/setup-zone.ts
|
221
|
+
init_react_import();
|
222
|
+
var setupZone = (data, zoneKey) => {
|
223
|
+
if (zoneKey === rootDroppableId) {
|
224
|
+
return data;
|
225
|
+
}
|
226
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
227
|
+
zones: data.zones || {}
|
228
|
+
});
|
229
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
230
|
+
return newData;
|
231
|
+
};
|
232
|
+
|
233
|
+
export {
|
234
|
+
__spreadValues,
|
235
|
+
__spreadProps,
|
236
|
+
__objRest,
|
237
|
+
__commonJS,
|
238
|
+
__toESM,
|
239
|
+
__async,
|
240
|
+
init_react_import,
|
241
|
+
rootDroppableId,
|
242
|
+
setupZone,
|
243
|
+
getChanged,
|
244
|
+
resolveComponentData,
|
245
|
+
resolveRootData,
|
246
|
+
defaultData,
|
247
|
+
resolveAllData
|
248
|
+
};
|
package/dist/index.css
CHANGED
@@ -137,7 +137,7 @@
|
|
137
137
|
/* styles.css */
|
138
138
|
|
139
139
|
/* css-module:/home/runner/work/puck/puck/packages/core/components/ActionBar/styles.module.css/#css-module-data */
|
140
|
-
.
|
140
|
+
._ActionBar_151w5_1 {
|
141
141
|
display: flex;
|
142
142
|
width: auto;
|
143
143
|
padding: 4px;
|
@@ -151,7 +151,7 @@
|
|
151
151
|
gap: 4px;
|
152
152
|
min-height: 26px;
|
153
153
|
}
|
154
|
-
._ActionBar-
|
154
|
+
._ActionBar-actionsLabel_151w5_16 {
|
155
155
|
color: var(--puck-color-grey-08);
|
156
156
|
display: flex;
|
157
157
|
font-size: var(--puck-font-size-xxxs);
|
@@ -163,19 +163,19 @@
|
|
163
163
|
text-overflow: ellipsis;
|
164
164
|
white-space: nowrap;
|
165
165
|
}
|
166
|
-
._ActionBar-
|
167
|
-
border-
|
166
|
+
._ActionBar-group_151w5_29 {
|
167
|
+
border-inline-start: 0.5px solid var(--puck-color-grey-05);
|
168
168
|
display: flex;
|
169
169
|
padding-left: 4px;
|
170
170
|
padding-right: 4px;
|
171
171
|
}
|
172
|
-
._ActionBar-
|
172
|
+
._ActionBar-group_151w5_29:last-of-type {
|
173
173
|
padding-right: 0;
|
174
174
|
}
|
175
|
-
._ActionBar-
|
175
|
+
._ActionBar-group_151w5_29:empty {
|
176
176
|
display: none;
|
177
177
|
}
|
178
|
-
._ActionBar-
|
178
|
+
._ActionBar-action_151w5_16 {
|
179
179
|
background: transparent;
|
180
180
|
border: none;
|
181
181
|
color: var(--puck-color-grey-08);
|
@@ -188,17 +188,17 @@
|
|
188
188
|
justify-content: center;
|
189
189
|
transition: color 50ms ease-in;
|
190
190
|
}
|
191
|
-
._ActionBar-
|
191
|
+
._ActionBar-action_151w5_16:focus-visible {
|
192
192
|
outline: 2px solid var(--puck-color-azure-05);
|
193
193
|
outline-offset: -2px;
|
194
194
|
}
|
195
195
|
@media (hover: hover) and (pointer: fine) {
|
196
|
-
._ActionBar-
|
196
|
+
._ActionBar-action_151w5_16:hover {
|
197
197
|
color: var(--puck-color-azure-06);
|
198
198
|
transition: none;
|
199
199
|
}
|
200
200
|
}
|
201
|
-
._ActionBar-
|
201
|
+
._ActionBar-action_151w5_16:active {
|
202
202
|
color: var(--puck-color-azure-07);
|
203
203
|
transition: none;
|
204
204
|
}
|
package/dist/index.d.mts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { F as Field, a as FieldProps, C as Config, D as Data, I as ItemSelector, P as PuckAction, b as DropZoneProps, U as UserGenerics, c as UiState, O as OnAction, d as Permissions, e as Plugin, f as Overrides, V as Viewports, g as IframeConfig, h as InitialHistory, i as DefaultComponentProps, j as DefaultRootFieldProps,
|
2
|
-
export { L as Adaptor, J as ArrayField,
|
1
|
+
import { F as Field, a as FieldProps, C as Config, D as Data, I as ItemSelector, P as PuckAction, b as DropZoneProps, U as UserGenerics, c as UiState, O as OnAction, d as Permissions, e as Plugin, f as Overrides, V as Viewports, g as IframeConfig, h as InitialHistory, i as DefaultComponentProps, j as DefaultRootFieldProps, H as History, A as AppState, E as ExtractPropsFromConfig, k as ExtractRootPropsFromConfig, l as ComponentDataMap } from './resolve-all-data-CaDAfEAK.mjs';
|
2
|
+
export { L as Adaptor, J as ArrayField, r as ArrayState, a2 as AsFieldProps, B as BaseData, y as BaseField, t as ComponentConfig, w as ComponentData, x as Content, X as CustomField, $ as DefaultRootProps, _ as DefaultRootRenderProps, W as ExternalField, Q as ExternalFieldWithAdaptor, p as FieldRenderFunctions, Y as Fields, q as ItemWithId, M as MappedItem, N as NumberField, K as ObjectField, n as OverrideKey, s as PuckComponent, Z as PuckContext, G as RadioField, v as RootData, R as RootDataWithProps, u as RootDataWithoutProps, S as SelectField, T as TextField, z as TextareaField, m as Viewport, a3 as WithChildren, a0 as WithId, a1 as WithPuckProps, o as overrideKeys, a4 as resolveAllData } from './resolve-all-data-CaDAfEAK.mjs';
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
4
4
|
import * as react from 'react';
|
5
5
|
import { ReactNode, SyntheticEvent, ReactElement, CSSProperties } from 'react';
|
@@ -202,8 +202,6 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
|
|
202
202
|
}>;
|
203
203
|
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
|
204
204
|
|
205
|
-
declare function resolveAllData<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Props, RootProps>>;
|
206
|
-
|
207
205
|
type HistoryStore<D = any> = {
|
208
206
|
index: number;
|
209
207
|
hasPast: boolean;
|
@@ -247,4 +245,4 @@ declare const usePuck: <UserConfig extends Config = Config>() => {
|
|
247
245
|
selectedItem: ComponentDataMap<ExtractPropsFromConfig<UserConfig>> | null;
|
248
246
|
};
|
249
247
|
|
250
|
-
export { Action, ActionBar, AppState, AutoField, AutoFieldPrivate, Button,
|
248
|
+
export { Action, ActionBar, AppState, AutoField, AutoFieldPrivate, Button, ComponentDataMap, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, DropZone, DropZoneProvider, ExtractPropsFromConfig, ExtractRootPropsFromConfig, Field, FieldLabel, FieldLabelInternal, FieldProps, type FieldPropsInternal, Group, History, IconButton, IframeConfig, InitialHistory, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, Render, UiState, UserGenerics, Viewports, dropZoneContext, migrate, transformProps, usePuck };
|
package/dist/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { F as Field, a as FieldProps, C as Config, D as Data, I as ItemSelector, P as PuckAction, b as DropZoneProps, U as UserGenerics, c as UiState, O as OnAction, d as Permissions, e as Plugin, f as Overrides, V as Viewports, g as IframeConfig, h as InitialHistory, i as DefaultComponentProps, j as DefaultRootFieldProps,
|
2
|
-
export { L as Adaptor, J as ArrayField,
|
1
|
+
import { F as Field, a as FieldProps, C as Config, D as Data, I as ItemSelector, P as PuckAction, b as DropZoneProps, U as UserGenerics, c as UiState, O as OnAction, d as Permissions, e as Plugin, f as Overrides, V as Viewports, g as IframeConfig, h as InitialHistory, i as DefaultComponentProps, j as DefaultRootFieldProps, H as History, A as AppState, E as ExtractPropsFromConfig, k as ExtractRootPropsFromConfig, l as ComponentDataMap } from './resolve-all-data-CaDAfEAK.js';
|
2
|
+
export { L as Adaptor, J as ArrayField, r as ArrayState, a2 as AsFieldProps, B as BaseData, y as BaseField, t as ComponentConfig, w as ComponentData, x as Content, X as CustomField, $ as DefaultRootProps, _ as DefaultRootRenderProps, W as ExternalField, Q as ExternalFieldWithAdaptor, p as FieldRenderFunctions, Y as Fields, q as ItemWithId, M as MappedItem, N as NumberField, K as ObjectField, n as OverrideKey, s as PuckComponent, Z as PuckContext, G as RadioField, v as RootData, R as RootDataWithProps, u as RootDataWithoutProps, S as SelectField, T as TextField, z as TextareaField, m as Viewport, a3 as WithChildren, a0 as WithId, a1 as WithPuckProps, o as overrideKeys, a4 as resolveAllData } from './resolve-all-data-CaDAfEAK.js';
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
4
4
|
import * as react from 'react';
|
5
5
|
import { ReactNode, SyntheticEvent, ReactElement, CSSProperties } from 'react';
|
@@ -202,8 +202,6 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
|
|
202
202
|
}>;
|
203
203
|
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
|
204
204
|
|
205
|
-
declare function resolveAllData<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Props, RootProps>>;
|
206
|
-
|
207
205
|
type HistoryStore<D = any> = {
|
208
206
|
index: number;
|
209
207
|
hasPast: boolean;
|
@@ -247,4 +245,4 @@ declare const usePuck: <UserConfig extends Config = Config>() => {
|
|
247
245
|
selectedItem: ComponentDataMap<ExtractPropsFromConfig<UserConfig>> | null;
|
248
246
|
};
|
249
247
|
|
250
|
-
export { Action, ActionBar, AppState, AutoField, AutoFieldPrivate, Button,
|
248
|
+
export { Action, ActionBar, AppState, AutoField, AutoFieldPrivate, Button, ComponentDataMap, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, DropZone, DropZoneProvider, ExtractPropsFromConfig, ExtractRootPropsFromConfig, Field, FieldLabel, FieldLabelInternal, FieldProps, type FieldPropsInternal, Group, History, IconButton, IframeConfig, InitialHistory, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, Render, UiState, UserGenerics, Viewports, dropZoneContext, migrate, transformProps, usePuck };
|
package/dist/index.js
CHANGED
@@ -243,7 +243,7 @@ var get_class_name_factory_default = getClassNameFactory;
|
|
243
243
|
|
244
244
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ActionBar/styles.module.css#css-module
|
245
245
|
init_react_import();
|
246
|
-
var styles_module_default = { "ActionBar": "
|
246
|
+
var styles_module_default = { "ActionBar": "_ActionBar_151w5_1", "ActionBar-actionsLabel": "_ActionBar-actionsLabel_151w5_16", "ActionBar-group": "_ActionBar-group_151w5_29", "ActionBar-action": "_ActionBar-action_151w5_16" };
|
247
247
|
|
248
248
|
// components/ActionBar/index.tsx
|
249
249
|
var import_jsx_runtime = require("react/jsx-runtime");
|
@@ -840,12 +840,12 @@ var useResolvedPermissions = (config, appState, globalPermissions, setComponentL
|
|
840
840
|
({ item, type, root } = {}) => {
|
841
841
|
if (item) {
|
842
842
|
const componentConfig = config.components[item.type];
|
843
|
-
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
843
|
+
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
|
844
844
|
const resolvedForItem = resolvedPermissions[item.props.id];
|
845
845
|
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
846
846
|
} else if (type) {
|
847
847
|
const componentConfig = config.components[type];
|
848
|
-
return __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
848
|
+
return __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
|
849
849
|
} else if (root) {
|
850
850
|
const rootConfig = config.root;
|
851
851
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
|
package/dist/index.mjs
CHANGED
@@ -5,10 +5,15 @@ import {
|
|
5
5
|
__spreadProps,
|
6
6
|
__spreadValues,
|
7
7
|
__toESM,
|
8
|
+
defaultData,
|
9
|
+
getChanged,
|
8
10
|
init_react_import,
|
11
|
+
resolveAllData,
|
12
|
+
resolveComponentData,
|
13
|
+
resolveRootData,
|
9
14
|
rootDroppableId,
|
10
15
|
setupZone
|
11
|
-
} from "./chunk-
|
16
|
+
} from "./chunk-YNVK2PUD.mjs";
|
12
17
|
|
13
18
|
// ../../node_modules/classnames/index.js
|
14
19
|
var require_classnames = __commonJS({
|
@@ -138,7 +143,7 @@ var get_class_name_factory_default = getClassNameFactory;
|
|
138
143
|
|
139
144
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ActionBar/styles.module.css#css-module
|
140
145
|
init_react_import();
|
141
|
-
var styles_module_default = { "ActionBar": "
|
146
|
+
var styles_module_default = { "ActionBar": "_ActionBar_151w5_1", "ActionBar-actionsLabel": "_ActionBar-actionsLabel_151w5_16", "ActionBar-group": "_ActionBar-group_151w5_29", "ActionBar-action": "_ActionBar-action_151w5_16" };
|
142
147
|
|
143
148
|
// components/ActionBar/index.tsx
|
144
149
|
import { jsx, jsxs } from "react/jsx-runtime";
|
@@ -634,21 +639,9 @@ var flattenData = (data) => {
|
|
634
639
|
);
|
635
640
|
};
|
636
641
|
|
637
|
-
// lib/get-changed.ts
|
638
|
-
init_react_import();
|
639
|
-
var getChanged = (newItem, oldItem) => {
|
640
|
-
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
641
|
-
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
642
|
-
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
643
|
-
return __spreadProps(__spreadValues({}, acc), {
|
644
|
-
[item]: oldItemProps[item] !== newItemProps[item]
|
645
|
-
});
|
646
|
-
}, {}) : {};
|
647
|
-
};
|
648
|
-
|
649
642
|
// lib/use-resolved-permissions.ts
|
650
643
|
var useResolvedPermissions = (config, appState, globalPermissions, setComponentLoading, unsetComponentLoading) => {
|
651
|
-
const [
|
644
|
+
const [cache, setCache] = useState2({});
|
652
645
|
const [resolvedPermissions, setResolvedPermissions] = useState2({});
|
653
646
|
const resolveDataForItem = useCallback(
|
654
647
|
(item, force = false) => __async(void 0, null, function* () {
|
@@ -659,17 +652,17 @@ var useResolvedPermissions = (config, appState, globalPermissions, setComponentL
|
|
659
652
|
}
|
660
653
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
661
654
|
if (componentConfig.resolvePermissions) {
|
662
|
-
const changed = getChanged(item, (_a =
|
655
|
+
const changed = getChanged(item, (_a = cache[item.props.id]) == null ? void 0 : _a.lastData);
|
663
656
|
if (Object.values(changed).some((el) => el === true) || force) {
|
664
657
|
setComponentLoading == null ? void 0 : setComponentLoading(item.props.id);
|
665
658
|
const resolvedPermissions2 = yield componentConfig.resolvePermissions(
|
666
659
|
item,
|
667
660
|
{
|
668
661
|
changed,
|
669
|
-
lastPermissions: ((_b =
|
662
|
+
lastPermissions: ((_b = cache[item.props.id]) == null ? void 0 : _b.lastPermissions) || null,
|
670
663
|
permissions: initialPermissions,
|
671
664
|
appState,
|
672
|
-
lastData: ((_c =
|
665
|
+
lastData: ((_c = cache[item.props.id]) == null ? void 0 : _c.lastData) || null
|
673
666
|
}
|
674
667
|
);
|
675
668
|
setCache((_cache) => __spreadProps(__spreadValues({}, _cache), {
|
@@ -685,7 +678,7 @@ var useResolvedPermissions = (config, appState, globalPermissions, setComponentL
|
|
685
678
|
}
|
686
679
|
}
|
687
680
|
}),
|
688
|
-
[config, globalPermissions, appState,
|
681
|
+
[config, globalPermissions, appState, cache]
|
689
682
|
);
|
690
683
|
const resolveDataForRoot = (force = false) => {
|
691
684
|
resolveDataForItem(
|
@@ -729,12 +722,12 @@ var useResolvedPermissions = (config, appState, globalPermissions, setComponentL
|
|
729
722
|
({ item, type, root } = {}) => {
|
730
723
|
if (item) {
|
731
724
|
const componentConfig = config.components[item.type];
|
732
|
-
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
725
|
+
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
|
733
726
|
const resolvedForItem = resolvedPermissions[item.props.id];
|
734
727
|
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
735
728
|
} else if (type) {
|
736
729
|
const componentConfig = config.components[type];
|
737
|
-
return __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
730
|
+
return __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
|
738
731
|
} else if (root) {
|
739
732
|
const rootConfig = config.root;
|
740
733
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
|
@@ -755,53 +748,6 @@ var useResolvedPermissions = (config, appState, globalPermissions, setComponentL
|
|
755
748
|
init_react_import();
|
756
749
|
import { useCallback as useCallback2, useEffect as useEffect2, useState as useState3 } from "react";
|
757
750
|
|
758
|
-
// lib/resolve-component-data.ts
|
759
|
-
init_react_import();
|
760
|
-
var cache = { lastChange: {} };
|
761
|
-
var resolveAllComponentData = (content, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
|
762
|
-
return yield Promise.all(
|
763
|
-
content.map((item) => __async(void 0, null, function* () {
|
764
|
-
return yield resolveComponentData(
|
765
|
-
item,
|
766
|
-
config,
|
767
|
-
onResolveStart,
|
768
|
-
onResolveEnd
|
769
|
-
);
|
770
|
-
}))
|
771
|
-
);
|
772
|
-
});
|
773
|
-
var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
|
774
|
-
const configForItem = config.components[item.type];
|
775
|
-
if (configForItem.resolveData) {
|
776
|
-
const { item: oldItem = null, resolved = {} } = cache.lastChange[item.props.id] || {};
|
777
|
-
if (item && item === oldItem) {
|
778
|
-
return resolved;
|
779
|
-
}
|
780
|
-
const changed = getChanged(item, oldItem);
|
781
|
-
if (onResolveStart) {
|
782
|
-
onResolveStart(item);
|
783
|
-
}
|
784
|
-
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, { changed, lastData: oldItem });
|
785
|
-
const { readOnly: existingReadOnly = {} } = item || {};
|
786
|
-
const newReadOnly = __spreadValues(__spreadValues({}, existingReadOnly), readOnly);
|
787
|
-
const resolvedItem = __spreadProps(__spreadValues({}, item), {
|
788
|
-
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
789
|
-
});
|
790
|
-
if (Object.keys(newReadOnly).length) {
|
791
|
-
resolvedItem.readOnly = newReadOnly;
|
792
|
-
}
|
793
|
-
cache.lastChange[item.props.id] = {
|
794
|
-
item,
|
795
|
-
resolved: resolvedItem
|
796
|
-
};
|
797
|
-
if (onResolveEnd) {
|
798
|
-
onResolveEnd(resolvedItem);
|
799
|
-
}
|
800
|
-
return resolvedItem;
|
801
|
-
}
|
802
|
-
return item;
|
803
|
-
});
|
804
|
-
|
805
751
|
// lib/apply-dynamic-props.ts
|
806
752
|
init_react_import();
|
807
753
|
var applyDynamicProps = (data, dynamicProps, rootData) => {
|
@@ -820,34 +766,6 @@ var applyDynamicProps = (data, dynamicProps, rootData) => {
|
|
820
766
|
});
|
821
767
|
};
|
822
768
|
|
823
|
-
// lib/resolve-root-data.ts
|
824
|
-
init_react_import();
|
825
|
-
var cache2 = {};
|
826
|
-
function resolveRootData(data, config) {
|
827
|
-
return __async(this, null, function* () {
|
828
|
-
var _a, _b, _c, _d, _e;
|
829
|
-
if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
|
830
|
-
if (((_b = cache2.lastChange) == null ? void 0 : _b.original) === data.root) {
|
831
|
-
return cache2.lastChange.resolved;
|
832
|
-
}
|
833
|
-
const changed = getChanged(data.root, (_c = cache2.lastChange) == null ? void 0 : _c.original);
|
834
|
-
const rootWithProps = data.root;
|
835
|
-
const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
|
836
|
-
changed,
|
837
|
-
lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {}
|
838
|
-
});
|
839
|
-
cache2.lastChange = {
|
840
|
-
original: data.root,
|
841
|
-
resolved: resolvedRoot
|
842
|
-
};
|
843
|
-
return __spreadProps(__spreadValues(__spreadValues({}, data.root), resolvedRoot), {
|
844
|
-
props: __spreadValues(__spreadValues({}, data.root.props), resolvedRoot.props)
|
845
|
-
});
|
846
|
-
}
|
847
|
-
return data.root;
|
848
|
-
});
|
849
|
-
}
|
850
|
-
|
851
769
|
// lib/use-resolved-data.ts
|
852
770
|
var useResolvedData = (appState, config, dispatch, setComponentLoading, unsetComponentLoading, refreshPermissions) => {
|
853
771
|
const [{ resolverKey, newAppState }, setResolverState] = useState3({
|
@@ -5683,15 +5601,6 @@ function migrate(data) {
|
|
5683
5601
|
|
5684
5602
|
// lib/transform-props.ts
|
5685
5603
|
init_react_import();
|
5686
|
-
|
5687
|
-
// lib/default-data.ts
|
5688
|
-
init_react_import();
|
5689
|
-
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
5690
|
-
root: data.root || {},
|
5691
|
-
content: data.content || []
|
5692
|
-
});
|
5693
|
-
|
5694
|
-
// lib/transform-props.ts
|
5695
5604
|
function transformProps(data, propTransforms) {
|
5696
5605
|
const mapItem = (item) => {
|
5697
5606
|
if (propTransforms[item.type]) {
|
@@ -5724,37 +5633,6 @@ function transformProps(data, propTransforms) {
|
|
5724
5633
|
return afterPropTransforms;
|
5725
5634
|
}
|
5726
5635
|
|
5727
|
-
// lib/resolve-all-data.ts
|
5728
|
-
init_react_import();
|
5729
|
-
function resolveAllData(data, config, onResolveStart, onResolveEnd) {
|
5730
|
-
return __async(this, null, function* () {
|
5731
|
-
const defaultedData = defaultData(data);
|
5732
|
-
const dynamicRoot = yield resolveRootData(defaultedData, config);
|
5733
|
-
const { zones = {} } = data;
|
5734
|
-
const zoneKeys = Object.keys(zones);
|
5735
|
-
const resolvedZones = {};
|
5736
|
-
for (let i = 0; i < zoneKeys.length; i++) {
|
5737
|
-
const zoneKey = zoneKeys[i];
|
5738
|
-
resolvedZones[zoneKey] = yield resolveAllComponentData(
|
5739
|
-
zones[zoneKey],
|
5740
|
-
config,
|
5741
|
-
onResolveStart,
|
5742
|
-
onResolveEnd
|
5743
|
-
);
|
5744
|
-
}
|
5745
|
-
return __spreadProps(__spreadValues({}, defaultedData), {
|
5746
|
-
root: dynamicRoot,
|
5747
|
-
content: yield resolveAllComponentData(
|
5748
|
-
defaultedData.content,
|
5749
|
-
config,
|
5750
|
-
onResolveStart,
|
5751
|
-
onResolveEnd
|
5752
|
-
),
|
5753
|
-
zones: resolvedZones
|
5754
|
-
});
|
5755
|
-
});
|
5756
|
-
}
|
5757
|
-
|
5758
5636
|
// lib/use-puck.ts
|
5759
5637
|
init_react_import();
|
5760
5638
|
var usePuck = () => {
|
@@ -440,4 +440,6 @@ type PuckAction = {
|
|
440
440
|
recordHistory?: boolean;
|
441
441
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
442
442
|
|
443
|
-
|
443
|
+
declare function resolveAllData<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Props, RootProps>>;
|
444
|
+
|
445
|
+
export { type DefaultRootProps as $, type AppState as A, type BaseData as B, type Config as C, type Data as D, type ExtractPropsFromConfig as E, type Field as F, type RadioField as G, type History as H, type ItemSelector as I, type ArrayField as J, type ObjectField as K, type Adaptor as L, type MappedItem as M, type NumberField as N, type OnAction as O, type PuckAction as P, type ExternalFieldWithAdaptor as Q, type RootDataWithProps as R, type SelectField as S, type TextField as T, type UserGenerics as U, type Viewports as V, type ExternalField as W, type CustomField as X, type Fields as Y, type PuckContext as Z, type DefaultRootRenderProps as _, type FieldProps as a, type WithId as a0, type WithPuckProps as a1, type AsFieldProps as a2, type WithChildren as a3, resolveAllData as a4, type DropZoneProps as b, type UiState as c, type Permissions as d, type Plugin as e, type Overrides as f, type IframeConfig as g, type InitialHistory as h, type DefaultComponentProps as i, type DefaultRootFieldProps as j, type ExtractRootPropsFromConfig as k, type ComponentDataMap as l, type Viewport as m, type OverrideKey as n, overrideKeys as o, type FieldRenderFunctions as p, type ItemWithId as q, type ArrayState as r, type PuckComponent as s, type ComponentConfig as t, type RootDataWithoutProps as u, type RootData as v, type ComponentData as w, type Content as x, type BaseField as y, type TextareaField as z };
|
@@ -440,4 +440,6 @@ type PuckAction = {
|
|
440
440
|
recordHistory?: boolean;
|
441
441
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
442
442
|
|
443
|
-
|
443
|
+
declare function resolveAllData<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Props, RootProps>>;
|
444
|
+
|
445
|
+
export { type DefaultRootProps as $, type AppState as A, type BaseData as B, type Config as C, type Data as D, type ExtractPropsFromConfig as E, type Field as F, type RadioField as G, type History as H, type ItemSelector as I, type ArrayField as J, type ObjectField as K, type Adaptor as L, type MappedItem as M, type NumberField as N, type OnAction as O, type PuckAction as P, type ExternalFieldWithAdaptor as Q, type RootDataWithProps as R, type SelectField as S, type TextField as T, type UserGenerics as U, type Viewports as V, type ExternalField as W, type CustomField as X, type Fields as Y, type PuckContext as Z, type DefaultRootRenderProps as _, type FieldProps as a, type WithId as a0, type WithPuckProps as a1, type AsFieldProps as a2, type WithChildren as a3, resolveAllData as a4, type DropZoneProps as b, type UiState as c, type Permissions as d, type Plugin as e, type Overrides as f, type IframeConfig as g, type InitialHistory as h, type DefaultComponentProps as i, type DefaultRootFieldProps as j, type ExtractRootPropsFromConfig as k, type ComponentDataMap as l, type Viewport as m, type OverrideKey as n, overrideKeys as o, type FieldRenderFunctions as p, type ItemWithId as q, type ArrayState as r, type PuckComponent as s, type ComponentConfig as t, type RootDataWithoutProps as u, type RootData as v, type ComponentData as w, type Content as x, type BaseField as y, type TextareaField as z };
|
package/dist/rsc.d.mts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
2
|
-
import { C as Config, D as Data } from './
|
2
|
+
import { C as Config, D as Data } from './resolve-all-data-CaDAfEAK.mjs';
|
3
|
+
export { a4 as resolveAllData } from './resolve-all-data-CaDAfEAK.mjs';
|
3
4
|
import 'react';
|
4
5
|
|
5
6
|
declare function Render<UserConfig extends Config = Config>({ config, data, }: {
|
package/dist/rsc.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
2
|
-
import { C as Config, D as Data } from './
|
2
|
+
import { C as Config, D as Data } from './resolve-all-data-CaDAfEAK.js';
|
3
|
+
export { a4 as resolveAllData } from './resolve-all-data-CaDAfEAK.js';
|
3
4
|
import 'react';
|
4
5
|
|
5
6
|
declare function Render<UserConfig extends Config = Config>({ config, data, }: {
|
package/dist/rsc.js
CHANGED
@@ -43,11 +43,32 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
43
43
|
mod
|
44
44
|
));
|
45
45
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
46
|
+
var __async = (__this, __arguments, generator) => {
|
47
|
+
return new Promise((resolve, reject) => {
|
48
|
+
var fulfilled = (value) => {
|
49
|
+
try {
|
50
|
+
step(generator.next(value));
|
51
|
+
} catch (e) {
|
52
|
+
reject(e);
|
53
|
+
}
|
54
|
+
};
|
55
|
+
var rejected = (value) => {
|
56
|
+
try {
|
57
|
+
step(generator.throw(value));
|
58
|
+
} catch (e) {
|
59
|
+
reject(e);
|
60
|
+
}
|
61
|
+
};
|
62
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
63
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
64
|
+
});
|
65
|
+
};
|
46
66
|
|
47
67
|
// rsc.tsx
|
48
68
|
var rsc_exports = {};
|
49
69
|
__export(rsc_exports, {
|
50
|
-
Render: () => Render
|
70
|
+
Render: () => Render,
|
71
|
+
resolveAllData: () => resolveAllData
|
51
72
|
});
|
52
73
|
module.exports = __toCommonJS(rsc_exports);
|
53
74
|
|
@@ -134,7 +155,128 @@ function Render({
|
|
134
155
|
}
|
135
156
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropZoneRender, { config, data, zone: rootDroppableId });
|
136
157
|
}
|
158
|
+
|
159
|
+
// lib/get-changed.ts
|
160
|
+
var getChanged = (newItem, oldItem) => {
|
161
|
+
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
162
|
+
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
163
|
+
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
164
|
+
return __spreadProps(__spreadValues({}, acc), {
|
165
|
+
[item]: oldItemProps[item] !== newItemProps[item]
|
166
|
+
});
|
167
|
+
}, {}) : {};
|
168
|
+
};
|
169
|
+
|
170
|
+
// lib/resolve-component-data.ts
|
171
|
+
var cache = { lastChange: {} };
|
172
|
+
var resolveAllComponentData = (content, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
|
173
|
+
return yield Promise.all(
|
174
|
+
content.map((item) => __async(void 0, null, function* () {
|
175
|
+
return yield resolveComponentData(
|
176
|
+
item,
|
177
|
+
config,
|
178
|
+
onResolveStart,
|
179
|
+
onResolveEnd
|
180
|
+
);
|
181
|
+
}))
|
182
|
+
);
|
183
|
+
});
|
184
|
+
var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
|
185
|
+
const configForItem = config.components[item.type];
|
186
|
+
if (configForItem.resolveData) {
|
187
|
+
const { item: oldItem = null, resolved = {} } = cache.lastChange[item.props.id] || {};
|
188
|
+
if (item && item === oldItem) {
|
189
|
+
return resolved;
|
190
|
+
}
|
191
|
+
const changed = getChanged(item, oldItem);
|
192
|
+
if (onResolveStart) {
|
193
|
+
onResolveStart(item);
|
194
|
+
}
|
195
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, { changed, lastData: oldItem });
|
196
|
+
const { readOnly: existingReadOnly = {} } = item || {};
|
197
|
+
const newReadOnly = __spreadValues(__spreadValues({}, existingReadOnly), readOnly);
|
198
|
+
const resolvedItem = __spreadProps(__spreadValues({}, item), {
|
199
|
+
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
200
|
+
});
|
201
|
+
if (Object.keys(newReadOnly).length) {
|
202
|
+
resolvedItem.readOnly = newReadOnly;
|
203
|
+
}
|
204
|
+
cache.lastChange[item.props.id] = {
|
205
|
+
item,
|
206
|
+
resolved: resolvedItem
|
207
|
+
};
|
208
|
+
if (onResolveEnd) {
|
209
|
+
onResolveEnd(resolvedItem);
|
210
|
+
}
|
211
|
+
return resolvedItem;
|
212
|
+
}
|
213
|
+
return item;
|
214
|
+
});
|
215
|
+
|
216
|
+
// lib/resolve-root-data.ts
|
217
|
+
var cache2 = {};
|
218
|
+
function resolveRootData(data, config) {
|
219
|
+
return __async(this, null, function* () {
|
220
|
+
var _a, _b, _c, _d, _e;
|
221
|
+
if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
|
222
|
+
if (((_b = cache2.lastChange) == null ? void 0 : _b.original) === data.root) {
|
223
|
+
return cache2.lastChange.resolved;
|
224
|
+
}
|
225
|
+
const changed = getChanged(data.root, (_c = cache2.lastChange) == null ? void 0 : _c.original);
|
226
|
+
const rootWithProps = data.root;
|
227
|
+
const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
|
228
|
+
changed,
|
229
|
+
lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {}
|
230
|
+
});
|
231
|
+
cache2.lastChange = {
|
232
|
+
original: data.root,
|
233
|
+
resolved: resolvedRoot
|
234
|
+
};
|
235
|
+
return __spreadProps(__spreadValues(__spreadValues({}, data.root), resolvedRoot), {
|
236
|
+
props: __spreadValues(__spreadValues({}, data.root.props), resolvedRoot.props)
|
237
|
+
});
|
238
|
+
}
|
239
|
+
return data.root;
|
240
|
+
});
|
241
|
+
}
|
242
|
+
|
243
|
+
// lib/default-data.ts
|
244
|
+
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
245
|
+
root: data.root || {},
|
246
|
+
content: data.content || []
|
247
|
+
});
|
248
|
+
|
249
|
+
// lib/resolve-all-data.ts
|
250
|
+
function resolveAllData(data, config, onResolveStart, onResolveEnd) {
|
251
|
+
return __async(this, null, function* () {
|
252
|
+
const defaultedData = defaultData(data);
|
253
|
+
const dynamicRoot = yield resolveRootData(defaultedData, config);
|
254
|
+
const { zones = {} } = data;
|
255
|
+
const zoneKeys = Object.keys(zones);
|
256
|
+
const resolvedZones = {};
|
257
|
+
for (let i = 0; i < zoneKeys.length; i++) {
|
258
|
+
const zoneKey = zoneKeys[i];
|
259
|
+
resolvedZones[zoneKey] = yield resolveAllComponentData(
|
260
|
+
zones[zoneKey],
|
261
|
+
config,
|
262
|
+
onResolveStart,
|
263
|
+
onResolveEnd
|
264
|
+
);
|
265
|
+
}
|
266
|
+
return __spreadProps(__spreadValues({}, defaultedData), {
|
267
|
+
root: dynamicRoot,
|
268
|
+
content: yield resolveAllComponentData(
|
269
|
+
defaultedData.content,
|
270
|
+
config,
|
271
|
+
onResolveStart,
|
272
|
+
onResolveEnd
|
273
|
+
),
|
274
|
+
zones: resolvedZones
|
275
|
+
});
|
276
|
+
});
|
277
|
+
}
|
137
278
|
// Annotate the CommonJS export names for ESM import in node:
|
138
279
|
0 && (module.exports = {
|
139
|
-
Render
|
280
|
+
Render,
|
281
|
+
resolveAllData
|
140
282
|
});
|
package/dist/rsc.mjs
CHANGED
@@ -2,9 +2,10 @@ import {
|
|
2
2
|
__spreadProps,
|
3
3
|
__spreadValues,
|
4
4
|
init_react_import,
|
5
|
+
resolveAllData,
|
5
6
|
rootDroppableId,
|
6
7
|
setupZone
|
7
|
-
} from "./chunk-
|
8
|
+
} from "./chunk-YNVK2PUD.mjs";
|
8
9
|
|
9
10
|
// rsc.tsx
|
10
11
|
init_react_import();
|
@@ -76,5 +77,6 @@ function Render({
|
|
76
77
|
return /* @__PURE__ */ jsx(DropZoneRender, { config, data, zone: rootDroppableId });
|
77
78
|
}
|
78
79
|
export {
|
79
|
-
Render
|
80
|
+
Render,
|
81
|
+
resolveAllData
|
80
82
|
};
|
package/package.json
CHANGED
package/dist/chunk-LM7YWFFF.mjs
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
var __create = Object.create;
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __defProps = Object.defineProperties;
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
12
|
-
var __spreadValues = (a, b) => {
|
13
|
-
for (var prop in b || (b = {}))
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
16
|
-
if (__getOwnPropSymbols)
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
18
|
-
if (__propIsEnum.call(b, prop))
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
20
|
-
}
|
21
|
-
return a;
|
22
|
-
};
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
24
|
-
var __objRest = (source, exclude) => {
|
25
|
-
var target = {};
|
26
|
-
for (var prop in source)
|
27
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
28
|
-
target[prop] = source[prop];
|
29
|
-
if (source != null && __getOwnPropSymbols)
|
30
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
31
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
32
|
-
target[prop] = source[prop];
|
33
|
-
}
|
34
|
-
return target;
|
35
|
-
};
|
36
|
-
var __esm = (fn, res) => function __init() {
|
37
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
38
|
-
};
|
39
|
-
var __commonJS = (cb, mod) => function __require() {
|
40
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
41
|
-
};
|
42
|
-
var __copyProps = (to, from, except, desc) => {
|
43
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
44
|
-
for (let key of __getOwnPropNames(from))
|
45
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
46
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
47
|
-
}
|
48
|
-
return to;
|
49
|
-
};
|
50
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
51
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
52
|
-
// file that has been converted to a CommonJS file using a Babel-
|
53
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
54
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
55
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
56
|
-
mod
|
57
|
-
));
|
58
|
-
var __async = (__this, __arguments, generator) => {
|
59
|
-
return new Promise((resolve, reject) => {
|
60
|
-
var fulfilled = (value) => {
|
61
|
-
try {
|
62
|
-
step(generator.next(value));
|
63
|
-
} catch (e) {
|
64
|
-
reject(e);
|
65
|
-
}
|
66
|
-
};
|
67
|
-
var rejected = (value) => {
|
68
|
-
try {
|
69
|
-
step(generator.throw(value));
|
70
|
-
} catch (e) {
|
71
|
-
reject(e);
|
72
|
-
}
|
73
|
-
};
|
74
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
75
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
76
|
-
});
|
77
|
-
};
|
78
|
-
|
79
|
-
// ../tsup-config/react-import.js
|
80
|
-
import React from "react";
|
81
|
-
var init_react_import = __esm({
|
82
|
-
"../tsup-config/react-import.js"() {
|
83
|
-
"use strict";
|
84
|
-
}
|
85
|
-
});
|
86
|
-
|
87
|
-
// lib/root-droppable-id.ts
|
88
|
-
init_react_import();
|
89
|
-
var rootDroppableId = "default-zone";
|
90
|
-
|
91
|
-
// lib/setup-zone.ts
|
92
|
-
init_react_import();
|
93
|
-
var setupZone = (data, zoneKey) => {
|
94
|
-
if (zoneKey === rootDroppableId) {
|
95
|
-
return data;
|
96
|
-
}
|
97
|
-
const newData = __spreadProps(__spreadValues({}, data), {
|
98
|
-
zones: data.zones || {}
|
99
|
-
});
|
100
|
-
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
101
|
-
return newData;
|
102
|
-
};
|
103
|
-
|
104
|
-
export {
|
105
|
-
__spreadValues,
|
106
|
-
__spreadProps,
|
107
|
-
__objRest,
|
108
|
-
__commonJS,
|
109
|
-
__toESM,
|
110
|
-
__async,
|
111
|
-
init_react_import,
|
112
|
-
rootDroppableId,
|
113
|
-
setupZone
|
114
|
-
};
|