@measured/puck 0.14.0-canary.16fff43 → 0.14.0-canary.1b907cb

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -125,6 +125,7 @@ declare const Drawer: {
125
125
  name: string;
126
126
  children?: ((props: {
127
127
  children: ReactNode;
128
+ name: string;
128
129
  }) => ReactElement) | undefined;
129
130
  id?: string | undefined;
130
131
  index: number;
@@ -167,7 +168,7 @@ type RenderFunc<Props extends {
167
168
  [key: string]: any;
168
169
  } = {
169
170
  children: ReactNode;
170
- }> = React.FunctionComponent<Props>;
171
+ }> = (props: Props) => ReactElement;
171
172
  declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "components", "componentItem", "outline", "puck", "preview"];
172
173
  type OverrideKey = (typeof overrideKeys)[number];
173
174
  type OverridesGeneric<Shape extends {
@@ -197,7 +198,10 @@ type Overrides = OverridesGeneric<{
197
198
  className?: string;
198
199
  }>;
199
200
  components: RenderFunc;
200
- componentItem: RenderFunc;
201
+ componentItem: RenderFunc<{
202
+ children: ReactNode;
203
+ name: string;
204
+ }>;
201
205
  outline: RenderFunc;
202
206
  puck: RenderFunc;
203
207
  }>;
@@ -271,10 +275,34 @@ declare const resolveAllData: (data: Data, config: Config<any, any, any>, onReso
271
275
  zones: Record<string, MappedItem[]>;
272
276
  }>;
273
277
 
278
+ type History<D = any> = {
279
+ id: string;
280
+ data: D;
281
+ };
282
+ type HistoryStore<D = any> = {
283
+ index: number;
284
+ currentHistory: History;
285
+ hasPast: boolean;
286
+ hasFuture: boolean;
287
+ record: (data: D) => void;
288
+ back: VoidFunction;
289
+ forward: VoidFunction;
290
+ nextHistory: History<D> | null;
291
+ prevHistory: History<D> | null;
292
+ histories: History<D>[];
293
+ };
294
+
295
+ type PuckHistory = {
296
+ back: VoidFunction;
297
+ forward: VoidFunction;
298
+ historyStore: HistoryStore;
299
+ };
300
+
274
301
  declare const usePuck: () => {
275
302
  appState: AppState;
276
303
  config: Config<any, any, any>;
277
304
  dispatch: (action: PuckAction) => void;
305
+ history: Partial<PuckHistory>;
278
306
  };
279
307
 
280
308
  export { AppState, Button, Config, Data, DefaultComponentProps, DefaultRootProps, Drawer, DropZoneProvider, Field, FieldLabel, IconButton, MappedItem, Puck, PuckAction, Render, RootData, RootDataWithProps, UiState, dropZoneContext, migrate, resolveAllData, transformProps, usePuck };
package/dist/index.js CHANGED
@@ -29387,10 +29387,10 @@ var DrawerItem = ({
29387
29387
  const ctx = (0, import_react3.useContext)(drawerContext);
29388
29388
  const resolvedId = `${ctx.droppableId}::${id || name}`;
29389
29389
  const CustomInner = (0, import_react3.useMemo)(
29390
- () => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassNameItem("default"), children: children2 })),
29390
+ () => children || (({ children: children2, name: name2 }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassNameItem("default"), children: children2 })),
29391
29391
  [children]
29392
29392
  );
29393
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(DrawerDraggable, { id: resolvedId, index, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CustomInner, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassNameItem("draggableWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: getClassNameItem("draggable"), children: [
29393
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(DrawerDraggable, { id: resolvedId, index, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CustomInner, { name, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassNameItem("draggableWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: getClassNameItem("draggable"), children: [
29394
29394
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassNameItem("name"), children: name }),
29395
29395
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassNameItem("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(DragIcon, {}) })
29396
29396
  ] }) }) }) });
@@ -31011,7 +31011,10 @@ var useResolvedData = (appState, config, dispatch) => {
31011
31011
  );
31012
31012
  const runResolvers = () => __async(void 0, null, function* () {
31013
31013
  const newData = newAppState.data;
31014
- const flatContent = Object.keys(newData.zones || {}).reduce((acc, zone) => [...acc, ...newData.zones[zone]], newData.content).filter((item) => !!config.components[item.type].resolveData);
31014
+ const flatContent = Object.keys(newData.zones || {}).reduce((acc, zone) => [...acc, ...newData.zones[zone]], newData.content).filter((item) => {
31015
+ var _a;
31016
+ return !!((_a = config.components[item.type]) == null ? void 0 : _a.resolveData);
31017
+ });
31015
31018
  const applyIfChange = (dynamicDataMap, dynamicRoot) => {
31016
31019
  const processed = applyDynamicProps(
31017
31020
  appState.data,
@@ -33225,8 +33228,8 @@ var resolveAllData = (data, config, onResolveStart, onResolveEnd) => __async(voi
33225
33228
  // lib/use-puck.ts
33226
33229
  init_react_import();
33227
33230
  var usePuck = () => {
33228
- const { state: appState, config, dispatch } = useAppContext();
33229
- return { appState, config, dispatch };
33231
+ const { state: appState, config, history, dispatch } = useAppContext();
33232
+ return { appState, config, dispatch, history };
33230
33233
  };
33231
33234
  // Annotate the CommonJS export names for ESM import in node:
33232
33235
  0 && (module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.14.0-canary.16fff43",
3
+ "version": "0.14.0-canary.1b907cb",
4
4
  "author": "Measured Corporation Ltd <hello@measured.co>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",