@measured/puck 0.13.0-canary.d1baf8f → 0.13.0-canary.d7540e3

Sign up to get free protection for your applications and to get access to all the features.
@@ -155,7 +155,7 @@ type Config<Props extends {
155
155
  [key: string]: any;
156
156
  } = {
157
157
  [key: string]: any;
158
- }, RootProps extends DefaultRootProps = DefaultRootProps, CategoryName extends string = string> = {
158
+ }, RootProps extends DefaultRootProps = DefaultRootProps, CategoryName extends string = any> = {
159
159
  categories?: Record<CategoryName, Category<keyof Props>> & {
160
160
  other?: Category<Props>;
161
161
  };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { D as Data, C as Config, I as ItemSelector, U as UiState, A as AppState, F as Field, a as DefaultComponentProps, b as DefaultRootProps, M as MappedItem, R as RootDataWithProps, c as RootData } from './Config-4367c689.js';
2
- export { g as Adaptor, f as ArrayField, r as ArrayState, n as BaseData, B as BaseField, m as ComponentConfig, o as ComponentData, k as Content, i as CustomField, s as DropZone, h as ExternalField, E as ExternalFieldWithAdaptor, j as Fields, q as ItemWithId, N as NumberField, O as ObjectField, P as PuckComponent, l as PuckContext, e as RadioField, p as RootDataWithoutProps, S as SelectField, T as TextField, d as TextareaField } from './Config-4367c689.js';
1
+ import { C as Config, D as Data, I as ItemSelector, U as UiState, A as AppState, F as Field, a as DefaultComponentProps, b as DefaultRootProps, M as MappedItem, R as RootDataWithProps, c as RootData } from './Config-5804f327.js';
2
+ export { g as Adaptor, f as ArrayField, r as ArrayState, n as BaseData, B as BaseField, m as ComponentConfig, o as ComponentData, k as Content, i as CustomField, s as DropZone, h as ExternalField, E as ExternalFieldWithAdaptor, j as Fields, q as ItemWithId, N as NumberField, O as ObjectField, P as PuckComponent, l as PuckContext, e as RadioField, p as RootDataWithoutProps, S as SelectField, T as TextField, d as TextareaField } from './Config-5804f327.js';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react from 'react';
5
5
  import { ReactNode, CSSProperties, ReactElement, SyntheticEvent } from 'react';
@@ -9,9 +9,9 @@ type PathData = Record<string, {
9
9
  path: string[];
10
10
  label: string;
11
11
  }>;
12
- type DropZoneContext = {
12
+ type DropZoneContext<UserConfig extends Config<any, any, any> = Config<any, any, any>> = {
13
13
  data: Data;
14
- config: Config;
14
+ config: UserConfig;
15
15
  componentState?: Record<string, any>;
16
16
  itemSelector?: ItemSelector | null;
17
17
  setItemSelector?: (newIndex: ItemSelector | null) => void;
@@ -35,7 +35,7 @@ type DropZoneContext = {
35
35
  mode?: "edit" | "render";
36
36
  disableZoom?: boolean;
37
37
  } | null;
38
- declare const dropZoneContext: react.Context<DropZoneContext>;
38
+ declare const dropZoneContext: react.Context<DropZoneContext<Config<any, any, any>>>;
39
39
  declare const DropZoneProvider: ({ children, value, }: {
40
40
  children: ReactNode;
41
41
  value: DropZoneContext;
@@ -217,9 +217,9 @@ type Plugin = {
217
217
  overrides: Partial<Overrides>;
218
218
  };
219
219
 
220
- declare function Puck({ children, config, data: initialData, ui: initialUi, onChange, onPublish, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, }: {
220
+ declare function Puck<UserConfig extends Config<any, any, any> = Config<any, any, any>>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, }: {
221
221
  children?: ReactNode;
222
- config: Config<any, any, any>;
222
+ config: UserConfig;
223
223
  data: Data;
224
224
  ui?: Partial<UiState>;
225
225
  onChange?: (data: Data) => void;
@@ -247,8 +247,8 @@ declare namespace Puck {
247
247
  }) => react_jsx_runtime.JSX.Element;
248
248
  }
249
249
 
250
- declare function Render({ config, data, }: {
251
- config: Config<any, any, any>;
250
+ declare function Render<UserConfig extends Config<any, any, any> = Config<any, any, any>>({ config, data }: {
251
+ config: UserConfig;
252
252
  data: Data;
253
253
  }): react_jsx_runtime.JSX.Element;
254
254
 
@@ -273,9 +273,7 @@ declare const resolveAllData: (data: Data, config: Config<any, any, any>, onReso
273
273
 
274
274
  declare const usePuck: () => {
275
275
  appState: AppState;
276
- config: Config<{
277
- [key: string]: any;
278
- }, DefaultRootProps, string>;
276
+ config: Config<any, any, any>;
279
277
  dispatch: (action: PuckAction) => void;
280
278
  };
281
279
 
package/dist/index.js CHANGED
@@ -29915,7 +29915,7 @@ var appContext = (0, import_react8.createContext)({
29915
29915
  history: {}
29916
29916
  });
29917
29917
  var AppProvider = appContext.Provider;
29918
- var useAppContext = () => {
29918
+ function useAppContext() {
29919
29919
  const mainContext = (0, import_react8.useContext)(appContext);
29920
29920
  const selectedItem = mainContext.state.ui.itemSelector ? getItem(mainContext.state.ui.itemSelector, mainContext.state.data) : void 0;
29921
29921
  return __spreadProps(__spreadValues({}, mainContext), {
@@ -29929,7 +29929,7 @@ var useAppContext = () => {
29929
29929
  });
29930
29930
  }
29931
29931
  });
29932
- };
29932
+ }
29933
29933
 
29934
29934
  // components/DropZone/index.tsx
29935
29935
  var import_jsx_runtime7 = require("react/jsx-runtime");
@@ -30825,17 +30825,19 @@ var setAction = (state, action) => {
30825
30825
  }
30826
30826
  return __spreadValues(__spreadValues({}, state), action.state(state));
30827
30827
  };
30828
- var createReducer = ({
30828
+ function createReducer({
30829
30829
  config,
30830
30830
  record
30831
- }) => storeInterceptor((state, action) => {
30832
- const data = reduceData(state.data, action, config);
30833
- const ui = reduceUi(state.ui, action);
30834
- if (action.type === "set") {
30835
- return setAction(state, action);
30836
- }
30837
- return { data, ui };
30838
- }, record);
30831
+ }) {
30832
+ return storeInterceptor((state, action) => {
30833
+ const data = reduceData(state.data, action, config);
30834
+ const ui = reduceUi(state.ui, action);
30835
+ if (action.type === "set") {
30836
+ return setAction(state, action);
30837
+ }
30838
+ return { data, ui };
30839
+ }, record);
30840
+ }
30839
30841
 
30840
30842
  // lib/flush-zones.ts
30841
30843
  init_react_import();
@@ -32833,7 +32835,7 @@ function Puck({
32833
32835
  [loadedOverrides]
32834
32836
  );
32835
32837
  const disableZoom = children || loadedOverrides.puck ? true : false;
32836
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { children: [
32838
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "Puck", children: [
32837
32839
  /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
32838
32840
  AppProvider,
32839
32841
  {
@@ -33054,10 +33056,7 @@ Puck.Preview = Preview;
33054
33056
  // components/Render/index.tsx
33055
33057
  init_react_import();
33056
33058
  var import_jsx_runtime30 = require("react/jsx-runtime");
33057
- function Render({
33058
- config,
33059
- data
33060
- }) {
33059
+ function Render({ config, data }) {
33061
33060
  var _a;
33062
33061
  const rootProps = data.root.props || data.root;
33063
33062
  const title = (rootProps == null ? void 0 : rootProps.title) || "";
package/dist/rsc.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as Config, D as Data } from './Config-4367c689.js';
2
+ import { C as Config, D as Data } from './Config-5804f327.js';
3
3
  import 'react';
4
4
 
5
- declare function Render({ config, data, }: {
6
- config: Config<any, any, any>;
5
+ declare function Render<UserConfig extends Config<any, any, any> = Config<any, any, any>>({ config, data }: {
6
+ config: UserConfig;
7
7
  data: Data;
8
8
  }): react_jsx_runtime.JSX.Element;
9
9
 
package/dist/rsc.js CHANGED
@@ -109,10 +109,7 @@ function DropZoneRender({
109
109
  return null;
110
110
  }) });
111
111
  }
112
- function Render({
113
- config,
114
- data
115
- }) {
112
+ function Render({ config, data }) {
116
113
  var _a;
117
114
  if ((_a = config.root) == null ? void 0 : _a.render) {
118
115
  const rootProps = data.root.props || data.root;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.13.0-canary.d1baf8f",
3
+ "version": "0.13.0-canary.d7540e3",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",