@measured/puck 0.11.3 → 0.12.0-canary.0c4514f

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/rsc.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { C as Config, D as Data } from './Config-60a50493.js';
3
+ import 'react';
4
+
5
+ declare function Render({ config, data }: {
6
+ config: Config;
7
+ data: Data;
8
+ }): react_jsx_runtime.JSX.Element;
9
+
10
+ export { Render };
package/dist/rsc.js ADDED
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __export = (target, all) => {
26
+ for (var name in all)
27
+ __defProp(target, name, { get: all[name], enumerable: true });
28
+ };
29
+ var __copyProps = (to, from, except, desc) => {
30
+ if (from && typeof from === "object" || typeof from === "function") {
31
+ for (let key of __getOwnPropNames(from))
32
+ if (!__hasOwnProp.call(to, key) && key !== except)
33
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
+ }
35
+ return to;
36
+ };
37
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
38
+ // If the importer is in node compatibility mode or this is not an ESM
39
+ // file that has been converted to a CommonJS file using a Babel-
40
+ // compatible transform (i.e. "__esModule" has not been set), then set
41
+ // "default" to the CommonJS "module.exports" for node compatibility.
42
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
43
+ mod
44
+ ));
45
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
+
47
+ // rsc.tsx
48
+ var rsc_exports = {};
49
+ __export(rsc_exports, {
50
+ Render: () => Render
51
+ });
52
+ module.exports = __toCommonJS(rsc_exports);
53
+
54
+ // ../tsup-config/react-import.js
55
+ var import_react = __toESM(require("react"));
56
+
57
+ // lib/root-droppable-id.ts
58
+ var rootDroppableId = "default-zone";
59
+
60
+ // lib/setup-zone.ts
61
+ var setupZone = (data, zoneKey) => {
62
+ if (zoneKey === rootDroppableId) {
63
+ return data;
64
+ }
65
+ const newData = __spreadValues({}, data);
66
+ newData.zones = data.zones || {};
67
+ newData.zones[zoneKey] = newData.zones[zoneKey] || [];
68
+ return newData;
69
+ };
70
+
71
+ // components/ServerRender/index.tsx
72
+ var import_jsx_runtime = require("react/jsx-runtime");
73
+ function DropZoneRender({
74
+ zone,
75
+ data,
76
+ areaId = "root",
77
+ config
78
+ }) {
79
+ let zoneCompound = rootDroppableId;
80
+ let content = (data == null ? void 0 : data.content) || [];
81
+ if (!data || !config) {
82
+ return null;
83
+ }
84
+ if (areaId && zone && zone !== rootDroppableId) {
85
+ zoneCompound = `${areaId}:${zone}`;
86
+ content = setupZone(data, zoneCompound).zones[zoneCompound];
87
+ }
88
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: content.map((item) => {
89
+ const Component = config.components[item.type];
90
+ if (Component) {
91
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
92
+ Component.render,
93
+ __spreadProps(__spreadValues({}, item.props), {
94
+ puck: {
95
+ renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
96
+ DropZoneRender,
97
+ {
98
+ zone: zone2,
99
+ data,
100
+ areaId: item.props.id,
101
+ config
102
+ }
103
+ )
104
+ }
105
+ }),
106
+ item.props.id
107
+ );
108
+ }
109
+ return null;
110
+ }) });
111
+ }
112
+ function Render({ config, data }) {
113
+ var _a;
114
+ if ((_a = config.root) == null ? void 0 : _a.render) {
115
+ const rootProps = data.root.props || data.root;
116
+ const title = rootProps.title || "";
117
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
118
+ config.root.render,
119
+ __spreadProps(__spreadValues({}, rootProps), {
120
+ puck: {
121
+ renderDropZone: ({ zone }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropZoneRender, { zone, data, config })
122
+ },
123
+ title,
124
+ editMode: false,
125
+ id: "puck-root",
126
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropZoneRender, { config, data, zone: rootDroppableId })
127
+ })
128
+ );
129
+ }
130
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropZoneRender, { config, data, zone: rootDroppableId });
131
+ }
132
+ // Annotate the CommonJS export names for ESM import in node:
133
+ 0 && (module.exports = {
134
+ Render
135
+ });
package/package.json CHANGED
@@ -1,13 +1,27 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.11.3",
3
+ "version": "0.12.0-canary.0c4514f",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ },
13
+ "./rsc": {
14
+ "import": "./dist/rsc.js",
15
+ "require": "./dist/rsc.js",
16
+ "types": "./dist/rsc.d.ts"
17
+ },
18
+ "./puck.css": "./dist/index.css",
19
+ "./dist/index.css": "./dist/index.css"
20
+ },
7
21
  "license": "MIT",
8
22
  "scripts": {
9
23
  "lint": "eslint \"**/*.ts*\"",
10
- "build": "rm -rf dist && tsup index.ts",
24
+ "build": "rm -rf dist && tsup index.ts rsc.tsx",
11
25
  "test": "jest",
12
26
  "prepare": "cp ../../README.md . && yarn build",
13
27
  "postpublish": "rm README.md"
@@ -21,7 +35,6 @@
21
35
  "@types/event-emitter": "^0.3.3",
22
36
  "@types/jest": "^29.5.4",
23
37
  "@types/react": "^18.2.0",
24
- "@types/react-beautiful-dnd": "^13.1.4",
25
38
  "@types/react-dom": "^18.2.0",
26
39
  "eslint": "^7.32.0",
27
40
  "eslint-config-custom": "*",
@@ -35,9 +48,9 @@
35
48
  "typescript": "^4.5.2"
36
49
  },
37
50
  "dependencies": {
51
+ "@hello-pangea/dnd": "^16.3.0",
38
52
  "deep-diff": "^1.0.2",
39
53
  "event-emitter": "^0.3.5",
40
- "react-beautiful-dnd": "^13.1.1",
41
54
  "react-hotkeys-hook": "^4.4.1",
42
55
  "react-spinners": "^0.13.8",
43
56
  "use-debounce": "^9.0.4"