@measured/puck 0.21.0-canary.38e79ba8 → 0.21.0-canary.501341c5
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/Editor-F2LSS6SE.css +403 -0
- package/dist/Editor-O447AVCX.mjs +204 -0
- package/dist/Render-OFE6QLI2.mjs +55 -0
- package/dist/Render-QEMDIDQC.css +101 -0
- package/dist/{walk-tree-bsPSSmt9.d.mts → actions-CJibIB0m.d.mts} +204 -30
- package/dist/{walk-tree-bsPSSmt9.d.ts → actions-CJibIB0m.d.ts} +204 -30
- package/dist/chunk-2Q4PACDA.mjs +111 -0
- package/dist/chunk-62AAYNXG.mjs +63 -0
- package/dist/chunk-BSDEIOEK.mjs +706 -0
- package/dist/chunk-CSSRLPHM.mjs +11 -0
- package/dist/chunk-DAQLMM2T.mjs +1722 -0
- package/dist/chunk-M6W7YEVX.mjs +95 -0
- package/dist/chunk-NLUHDYVR.mjs +416 -0
- package/dist/chunk-PLXSMBAA.mjs +53 -0
- package/dist/chunk-QAWJTCV5.mjs +33 -0
- package/dist/chunk-QBGM4ELA.mjs +528 -0
- package/dist/chunk-T3WX7XJ6.mjs +132 -0
- package/dist/chunk-V5I7CVLT.mjs +103 -0
- package/dist/chunk-Y2EFNT5P.mjs +108 -0
- package/dist/chunk-Y656T6AQ.mjs +419 -0
- package/dist/{chunk-CISJM3HZ.mjs → chunk-Z476VA6G.mjs} +1176 -2860
- package/dist/full-2GJTAAZE.css +301 -0
- package/dist/full-BEMDJKDS.mjs +93 -0
- package/dist/index-Bss1jupB.d.ts +116 -0
- package/dist/index-DOcD_H3b.d.mts +116 -0
- package/dist/index.css +278 -22
- package/dist/index.d.mts +94 -113
- package/dist/index.d.ts +94 -113
- package/dist/index.js +5870 -2561
- package/dist/index.mjs +28 -9
- package/dist/internal.d.mts +27 -0
- package/dist/internal.d.ts +27 -0
- package/dist/internal.js +908 -0
- package/dist/internal.mjs +13 -0
- package/dist/loaded-JU3A7Y4L.mjs +57 -0
- package/dist/loaded-N3FYGF2Y.mjs +57 -0
- package/dist/loaded-OBY7OMS6.mjs +60 -0
- package/dist/loaded-RVWBFK7L.css +87 -0
- package/dist/no-external.css +278 -22
- package/dist/no-external.d.mts +19 -2
- package/dist/no-external.d.ts +19 -2
- package/dist/no-external.js +5870 -2561
- package/dist/no-external.mjs +28 -9
- package/dist/rsc.css +101 -0
- package/dist/rsc.d.mts +17 -2
- package/dist/rsc.d.ts +17 -2
- package/dist/rsc.js +407 -21
- package/dist/rsc.mjs +18 -9
- package/dist/walk-tree-BL55zQ9b.d.ts +29 -0
- package/dist/walk-tree-BYuI81Ik.d.mts +29 -0
- package/package.json +31 -4
- package/dist/chunk-JA7SEUEH.mjs +0 -966
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__spreadValues,
|
|
3
|
+
init_react_import
|
|
4
|
+
} from "./chunk-M6W7YEVX.mjs";
|
|
5
|
+
|
|
6
|
+
// components/RichTextEditor/extension.ts
|
|
7
|
+
init_react_import();
|
|
8
|
+
import { Extension } from "@tiptap/core";
|
|
9
|
+
import { Blockquote } from "@tiptap/extension-blockquote";
|
|
10
|
+
import { Bold } from "@tiptap/extension-bold";
|
|
11
|
+
import { Code } from "@tiptap/extension-code";
|
|
12
|
+
import { CodeBlock } from "@tiptap/extension-code-block";
|
|
13
|
+
import { Document } from "@tiptap/extension-document";
|
|
14
|
+
import { HardBreak } from "@tiptap/extension-hard-break";
|
|
15
|
+
import { Heading } from "@tiptap/extension-heading";
|
|
16
|
+
import { HorizontalRule } from "@tiptap/extension-horizontal-rule";
|
|
17
|
+
import { Italic } from "@tiptap/extension-italic";
|
|
18
|
+
import { Link } from "@tiptap/extension-link";
|
|
19
|
+
import {
|
|
20
|
+
BulletList,
|
|
21
|
+
ListItem,
|
|
22
|
+
ListKeymap,
|
|
23
|
+
OrderedList
|
|
24
|
+
} from "@tiptap/extension-list";
|
|
25
|
+
import { Paragraph } from "@tiptap/extension-paragraph";
|
|
26
|
+
import { Strike } from "@tiptap/extension-strike";
|
|
27
|
+
import { Text } from "@tiptap/extension-text";
|
|
28
|
+
import TextAlign from "@tiptap/extension-text-align";
|
|
29
|
+
import { Underline } from "@tiptap/extension-underline";
|
|
30
|
+
var defaultPuckRichTextOptions = {
|
|
31
|
+
textAlign: {
|
|
32
|
+
types: ["heading", "paragraph"]
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var PuckRichText = Extension.create({
|
|
36
|
+
name: "puckRichText",
|
|
37
|
+
addExtensions() {
|
|
38
|
+
const extensions = [];
|
|
39
|
+
const options = __spreadValues(__spreadValues({}, this.options), defaultPuckRichTextOptions);
|
|
40
|
+
if (options.bold !== false) {
|
|
41
|
+
extensions.push(Bold.configure(options.bold));
|
|
42
|
+
}
|
|
43
|
+
if (options.blockquote !== false) {
|
|
44
|
+
extensions.push(Blockquote.configure(options.blockquote));
|
|
45
|
+
}
|
|
46
|
+
if (options.bulletList !== false) {
|
|
47
|
+
extensions.push(BulletList.configure(options.bulletList));
|
|
48
|
+
}
|
|
49
|
+
if (options.code !== false) {
|
|
50
|
+
extensions.push(Code.configure(options.code));
|
|
51
|
+
}
|
|
52
|
+
if (options.codeBlock !== false) {
|
|
53
|
+
extensions.push(CodeBlock.configure(options.codeBlock));
|
|
54
|
+
}
|
|
55
|
+
if (options.document !== false) {
|
|
56
|
+
extensions.push(Document.configure(options.document));
|
|
57
|
+
}
|
|
58
|
+
if (options.hardBreak !== false) {
|
|
59
|
+
extensions.push(HardBreak.configure(options.hardBreak));
|
|
60
|
+
}
|
|
61
|
+
if (options.heading !== false) {
|
|
62
|
+
extensions.push(Heading.configure(options.heading));
|
|
63
|
+
}
|
|
64
|
+
if (options.horizontalRule !== false) {
|
|
65
|
+
extensions.push(HorizontalRule.configure(options.horizontalRule));
|
|
66
|
+
}
|
|
67
|
+
if (options.italic !== false) {
|
|
68
|
+
extensions.push(Italic.configure(options.italic));
|
|
69
|
+
}
|
|
70
|
+
if (options.listItem !== false) {
|
|
71
|
+
extensions.push(ListItem.configure(options.listItem));
|
|
72
|
+
}
|
|
73
|
+
if (options.listKeymap !== false) {
|
|
74
|
+
extensions.push(ListKeymap.configure(options == null ? void 0 : options.listKeymap));
|
|
75
|
+
}
|
|
76
|
+
if (options.link !== false) {
|
|
77
|
+
extensions.push(Link.configure(options == null ? void 0 : options.link));
|
|
78
|
+
}
|
|
79
|
+
if (options.orderedList !== false) {
|
|
80
|
+
extensions.push(OrderedList.configure(options.orderedList));
|
|
81
|
+
}
|
|
82
|
+
if (options.paragraph !== false) {
|
|
83
|
+
extensions.push(Paragraph.configure(options.paragraph));
|
|
84
|
+
}
|
|
85
|
+
if (options.strike !== false) {
|
|
86
|
+
extensions.push(Strike.configure(options.strike));
|
|
87
|
+
}
|
|
88
|
+
if (options.text !== false) {
|
|
89
|
+
extensions.push(Text.configure(options.text));
|
|
90
|
+
}
|
|
91
|
+
if (options.textAlign !== false) {
|
|
92
|
+
extensions.push(TextAlign.configure(options.textAlign));
|
|
93
|
+
}
|
|
94
|
+
if (options.underline !== false) {
|
|
95
|
+
extensions.push(Underline.configure(options == null ? void 0 : options.underline));
|
|
96
|
+
}
|
|
97
|
+
return extensions;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
export {
|
|
102
|
+
PuckRichText
|
|
103
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__commonJS,
|
|
3
|
+
__spreadValues,
|
|
4
|
+
__toESM,
|
|
5
|
+
init_react_import
|
|
6
|
+
} from "./chunk-M6W7YEVX.mjs";
|
|
7
|
+
|
|
8
|
+
// ../../node_modules/classnames/index.js
|
|
9
|
+
var require_classnames = __commonJS({
|
|
10
|
+
"../../node_modules/classnames/index.js"(exports, module) {
|
|
11
|
+
"use strict";
|
|
12
|
+
init_react_import();
|
|
13
|
+
(function() {
|
|
14
|
+
"use strict";
|
|
15
|
+
var hasOwn = {}.hasOwnProperty;
|
|
16
|
+
function classNames() {
|
|
17
|
+
var classes = "";
|
|
18
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
19
|
+
var arg = arguments[i];
|
|
20
|
+
if (arg) {
|
|
21
|
+
classes = appendClass(classes, parseValue(arg));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return classes;
|
|
25
|
+
}
|
|
26
|
+
function parseValue(arg) {
|
|
27
|
+
if (typeof arg === "string" || typeof arg === "number") {
|
|
28
|
+
return arg;
|
|
29
|
+
}
|
|
30
|
+
if (typeof arg !== "object") {
|
|
31
|
+
return "";
|
|
32
|
+
}
|
|
33
|
+
if (Array.isArray(arg)) {
|
|
34
|
+
return classNames.apply(null, arg);
|
|
35
|
+
}
|
|
36
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
|
37
|
+
return arg.toString();
|
|
38
|
+
}
|
|
39
|
+
var classes = "";
|
|
40
|
+
for (var key in arg) {
|
|
41
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
42
|
+
classes = appendClass(classes, key);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return classes;
|
|
46
|
+
}
|
|
47
|
+
function appendClass(value, newClass) {
|
|
48
|
+
if (!newClass) {
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
if (value) {
|
|
52
|
+
return value + " " + newClass;
|
|
53
|
+
}
|
|
54
|
+
return value + newClass;
|
|
55
|
+
}
|
|
56
|
+
if (typeof module !== "undefined" && module.exports) {
|
|
57
|
+
classNames.default = classNames;
|
|
58
|
+
module.exports = classNames;
|
|
59
|
+
} else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
|
|
60
|
+
define("classnames", [], function() {
|
|
61
|
+
return classNames;
|
|
62
|
+
});
|
|
63
|
+
} else {
|
|
64
|
+
window.classNames = classNames;
|
|
65
|
+
}
|
|
66
|
+
})();
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// lib/get-class-name-factory.ts
|
|
71
|
+
init_react_import();
|
|
72
|
+
var import_classnames = __toESM(require_classnames());
|
|
73
|
+
var getClassNameFactory = (rootClass, styles, config = { baseClass: "" }) => (options = {}) => {
|
|
74
|
+
if (typeof options === "string") {
|
|
75
|
+
const descendant = options;
|
|
76
|
+
const style = styles[`${rootClass}-${descendant}`];
|
|
77
|
+
if (style) {
|
|
78
|
+
return config.baseClass + styles[`${rootClass}-${descendant}`] || "";
|
|
79
|
+
}
|
|
80
|
+
return "";
|
|
81
|
+
} else if (typeof options === "object") {
|
|
82
|
+
const modifiers = options;
|
|
83
|
+
const prefixedModifiers = {};
|
|
84
|
+
for (let modifier in modifiers) {
|
|
85
|
+
prefixedModifiers[styles[`${rootClass}--${modifier}`]] = modifiers[modifier];
|
|
86
|
+
}
|
|
87
|
+
const c = styles[rootClass];
|
|
88
|
+
return config.baseClass + (0, import_classnames.default)(__spreadValues({
|
|
89
|
+
[c]: !!c
|
|
90
|
+
}, prefixedModifiers));
|
|
91
|
+
} else {
|
|
92
|
+
return config.baseClass + styles[rootClass] || "";
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var get_class_name_factory_default = getClassNameFactory;
|
|
96
|
+
|
|
97
|
+
export {
|
|
98
|
+
get_class_name_factory_default
|
|
99
|
+
};
|
|
100
|
+
/*! Bundled license information:
|
|
101
|
+
|
|
102
|
+
classnames/index.js:
|
|
103
|
+
(*!
|
|
104
|
+
Copyright (c) 2018 Jed Watson.
|
|
105
|
+
Licensed under the MIT License (MIT), see
|
|
106
|
+
http://jedwatson.github.io/classnames
|
|
107
|
+
*)
|
|
108
|
+
*/
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
import {
|
|
2
|
+
styles_module_default
|
|
3
|
+
} from "./chunk-CSSRLPHM.mjs";
|
|
4
|
+
import {
|
|
5
|
+
defaultAppState,
|
|
6
|
+
resolveComponentData
|
|
7
|
+
} from "./chunk-T3WX7XJ6.mjs";
|
|
8
|
+
import {
|
|
9
|
+
get_class_name_factory_default
|
|
10
|
+
} from "./chunk-Y2EFNT5P.mjs";
|
|
11
|
+
import {
|
|
12
|
+
mapFields,
|
|
13
|
+
walkAppState,
|
|
14
|
+
walkTree
|
|
15
|
+
} from "./chunk-NLUHDYVR.mjs";
|
|
16
|
+
import {
|
|
17
|
+
__async,
|
|
18
|
+
__objRest,
|
|
19
|
+
__spreadProps,
|
|
20
|
+
__spreadValues,
|
|
21
|
+
init_react_import
|
|
22
|
+
} from "./chunk-M6W7YEVX.mjs";
|
|
23
|
+
|
|
24
|
+
// lib/migrate.ts
|
|
25
|
+
init_react_import();
|
|
26
|
+
var migrations = [
|
|
27
|
+
// Migrate root to root.props
|
|
28
|
+
(data) => {
|
|
29
|
+
const rootProps = data.root.props || data.root;
|
|
30
|
+
if (Object.keys(data.root).length > 0 && !data.root.props) {
|
|
31
|
+
console.warn(
|
|
32
|
+
"Migration applied: Root props moved from `root` to `root.props`."
|
|
33
|
+
);
|
|
34
|
+
return __spreadProps(__spreadValues({}, data), {
|
|
35
|
+
root: {
|
|
36
|
+
props: __spreadValues({}, rootProps)
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return data;
|
|
41
|
+
},
|
|
42
|
+
// Migrate zones to slots
|
|
43
|
+
(data, config, migrationOptions) => {
|
|
44
|
+
var _a, _b;
|
|
45
|
+
if (!config) return data;
|
|
46
|
+
console.log("Migrating DropZones to slots...");
|
|
47
|
+
const updatedItems = {};
|
|
48
|
+
const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
|
|
49
|
+
const { indexes } = walkAppState(appState, config);
|
|
50
|
+
const deletedCompounds = [];
|
|
51
|
+
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
|
52
|
+
var _a2, _b2, _c;
|
|
53
|
+
if (zoneType === "dropzone") {
|
|
54
|
+
const [id, slotName] = zoneCompound.split(":");
|
|
55
|
+
const nodeData = indexes.nodes[id].data;
|
|
56
|
+
const componentType = nodeData.type;
|
|
57
|
+
const configForComponent = id === "root" ? config.root : config.components[componentType];
|
|
58
|
+
if (((_b2 = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b2.type) === "slot") {
|
|
59
|
+
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
|
60
|
+
props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
|
|
61
|
+
[slotName]: content
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
deletedCompounds.push(zoneCompound);
|
|
65
|
+
}
|
|
66
|
+
return content;
|
|
67
|
+
}
|
|
68
|
+
return content;
|
|
69
|
+
});
|
|
70
|
+
const updated = walkAppState(
|
|
71
|
+
appState,
|
|
72
|
+
config,
|
|
73
|
+
(content) => content,
|
|
74
|
+
(item) => {
|
|
75
|
+
var _a2;
|
|
76
|
+
return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
deletedCompounds.forEach((zoneCompound) => {
|
|
80
|
+
var _a2;
|
|
81
|
+
const [_, propName] = zoneCompound.split(":");
|
|
82
|
+
console.log(
|
|
83
|
+
`\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
|
|
84
|
+
);
|
|
85
|
+
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
|
86
|
+
});
|
|
87
|
+
if (migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) {
|
|
88
|
+
const unmigratedZonesGrouped = {};
|
|
89
|
+
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
|
90
|
+
var _a2;
|
|
91
|
+
const [componentId, propName] = zoneCompound.split(":");
|
|
92
|
+
const content = (_a2 = updated.data.zones) == null ? void 0 : _a2[zoneCompound];
|
|
93
|
+
if (!content) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (!unmigratedZonesGrouped[componentId]) {
|
|
97
|
+
unmigratedZonesGrouped[componentId] = {};
|
|
98
|
+
}
|
|
99
|
+
if (!unmigratedZonesGrouped[componentId][propName]) {
|
|
100
|
+
unmigratedZonesGrouped[componentId][propName] = content;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
Object.keys(unmigratedZonesGrouped).forEach((componentId) => {
|
|
104
|
+
updated.data = walkTree(updated.data, config, (content) => {
|
|
105
|
+
return content.map((child) => {
|
|
106
|
+
var _a2;
|
|
107
|
+
if (child.props.id !== componentId) {
|
|
108
|
+
return child;
|
|
109
|
+
}
|
|
110
|
+
const migrateFn = (_a2 = migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) == null ? void 0 : _a2[child.type];
|
|
111
|
+
if (!migrateFn) {
|
|
112
|
+
return child;
|
|
113
|
+
}
|
|
114
|
+
const zones = unmigratedZonesGrouped[componentId];
|
|
115
|
+
const migratedProps = migrateFn(child.props, zones);
|
|
116
|
+
Object.keys(zones).forEach((propName) => {
|
|
117
|
+
var _a3;
|
|
118
|
+
const zoneCompound = `${componentId}:${propName}`;
|
|
119
|
+
console.log(`\u2713 Success: Migrated "${zoneCompound}" DropZone`);
|
|
120
|
+
(_a3 = updated.data.zones) == null ? true : delete _a3[zoneCompound];
|
|
121
|
+
});
|
|
122
|
+
return __spreadProps(__spreadValues({}, child), {
|
|
123
|
+
props: migratedProps
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
Object.keys((_b = updated.data.zones) != null ? _b : {}).forEach((zoneCompound) => {
|
|
130
|
+
const [_, propName] = zoneCompound.split(":");
|
|
131
|
+
throw new Error(
|
|
132
|
+
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
|
133
|
+
);
|
|
134
|
+
});
|
|
135
|
+
delete updated.data.zones;
|
|
136
|
+
return updated.data;
|
|
137
|
+
}
|
|
138
|
+
];
|
|
139
|
+
function migrate(data, config, migrationOptions) {
|
|
140
|
+
return migrations == null ? void 0 : migrations.reduce(
|
|
141
|
+
(acc, migration) => migration(acc, config, migrationOptions),
|
|
142
|
+
data
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// lib/transform-props.ts
|
|
147
|
+
init_react_import();
|
|
148
|
+
|
|
149
|
+
// lib/data/default-data.ts
|
|
150
|
+
init_react_import();
|
|
151
|
+
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
|
152
|
+
root: data.root || {},
|
|
153
|
+
content: data.content || []
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// lib/transform-props.ts
|
|
157
|
+
function transformProps(data, propTransforms, config = { components: {} }) {
|
|
158
|
+
const mapItem = (item) => {
|
|
159
|
+
if (propTransforms[item.type]) {
|
|
160
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
161
|
+
props: __spreadValues({
|
|
162
|
+
id: item.props.id
|
|
163
|
+
}, propTransforms[item.type](item.props))
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return item;
|
|
167
|
+
};
|
|
168
|
+
const defaultedData = defaultData(data);
|
|
169
|
+
const rootProps = defaultedData.root.props || defaultedData.root;
|
|
170
|
+
let newRoot = __spreadValues({}, defaultedData.root);
|
|
171
|
+
if (propTransforms["root"]) {
|
|
172
|
+
newRoot.props = propTransforms["root"](rootProps);
|
|
173
|
+
}
|
|
174
|
+
const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
|
|
175
|
+
const updatedData = walkTree(
|
|
176
|
+
dataWithUpdatedRoot,
|
|
177
|
+
config,
|
|
178
|
+
(content) => content.map(mapItem)
|
|
179
|
+
);
|
|
180
|
+
if (!defaultedData.root.props) {
|
|
181
|
+
updatedData.root = updatedData.root.props;
|
|
182
|
+
}
|
|
183
|
+
return updatedData;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// lib/resolve-all-data.ts
|
|
187
|
+
init_react_import();
|
|
188
|
+
|
|
189
|
+
// lib/data/to-component.ts
|
|
190
|
+
init_react_import();
|
|
191
|
+
var toComponent = (item) => {
|
|
192
|
+
return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
|
|
193
|
+
props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
|
|
194
|
+
type: "root"
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// lib/resolve-all-data.ts
|
|
199
|
+
function resolveAllData(_0, _1) {
|
|
200
|
+
return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
|
|
201
|
+
var _a;
|
|
202
|
+
const defaultedData = defaultData(data);
|
|
203
|
+
const resolveNode = (_node) => __async(null, null, function* () {
|
|
204
|
+
const node = toComponent(_node);
|
|
205
|
+
onResolveStart == null ? void 0 : onResolveStart(node);
|
|
206
|
+
const resolved = (yield resolveComponentData(
|
|
207
|
+
node,
|
|
208
|
+
config,
|
|
209
|
+
metadata,
|
|
210
|
+
() => {
|
|
211
|
+
},
|
|
212
|
+
() => {
|
|
213
|
+
},
|
|
214
|
+
"force"
|
|
215
|
+
)).node;
|
|
216
|
+
const resolvedDeep = yield mapFields(
|
|
217
|
+
resolved,
|
|
218
|
+
{ slot: ({ value }) => processContent(value) },
|
|
219
|
+
config
|
|
220
|
+
);
|
|
221
|
+
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
|
222
|
+
return resolvedDeep;
|
|
223
|
+
});
|
|
224
|
+
const processContent = (content) => __async(null, null, function* () {
|
|
225
|
+
return Promise.all(content.map(resolveNode));
|
|
226
|
+
});
|
|
227
|
+
const processZones = () => __async(null, null, function* () {
|
|
228
|
+
var _a2;
|
|
229
|
+
const zones = (_a2 = data.zones) != null ? _a2 : {};
|
|
230
|
+
Object.entries(zones).forEach((_02) => __async(null, [_02], function* ([zoneKey, content]) {
|
|
231
|
+
zones[zoneKey] = yield Promise.all(content.map(resolveNode));
|
|
232
|
+
}));
|
|
233
|
+
return zones;
|
|
234
|
+
});
|
|
235
|
+
const dynamic = {
|
|
236
|
+
root: yield resolveNode(defaultedData.root),
|
|
237
|
+
content: yield processContent(defaultedData.content),
|
|
238
|
+
zones: yield processZones()
|
|
239
|
+
};
|
|
240
|
+
Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(null, null, function* () {
|
|
241
|
+
const content = defaultedData.zones[zoneKey];
|
|
242
|
+
dynamic.zones[zoneKey] = yield processContent(content);
|
|
243
|
+
}), {});
|
|
244
|
+
return dynamic;
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// lib/field-transforms/use-field-transforms.tsx
|
|
249
|
+
init_react_import();
|
|
250
|
+
import { useMemo } from "react";
|
|
251
|
+
function useFieldTransforms(config, item, transforms, readOnly, forceReadOnly) {
|
|
252
|
+
const mappers = useMemo(() => {
|
|
253
|
+
return Object.keys(transforms).reduce((acc, _fieldType) => {
|
|
254
|
+
const fieldType = _fieldType;
|
|
255
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
256
|
+
[fieldType]: (_a) => {
|
|
257
|
+
var _b = _a, {
|
|
258
|
+
parentId
|
|
259
|
+
} = _b, params = __objRest(_b, [
|
|
260
|
+
"parentId"
|
|
261
|
+
]);
|
|
262
|
+
const wildcardPath = params.propPath.replace(/\[\d+\]/g, "[*]");
|
|
263
|
+
const isReadOnly = (readOnly == null ? void 0 : readOnly[params.propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly || false;
|
|
264
|
+
const fn = transforms[fieldType];
|
|
265
|
+
return fn == null ? void 0 : fn(__spreadProps(__spreadValues({}, params), {
|
|
266
|
+
isReadOnly,
|
|
267
|
+
componentId: parentId
|
|
268
|
+
}));
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
}, {});
|
|
272
|
+
}, [transforms, readOnly, forceReadOnly]);
|
|
273
|
+
const transformedProps = useMemo(() => {
|
|
274
|
+
const mapped = mapFields(item, mappers, config).props;
|
|
275
|
+
return mapped;
|
|
276
|
+
}, [config, item, mappers]);
|
|
277
|
+
const mergedProps = useMemo(
|
|
278
|
+
() => __spreadValues(__spreadValues({}, item.props), transformedProps),
|
|
279
|
+
[item.props, transformedProps]
|
|
280
|
+
);
|
|
281
|
+
return mergedProps;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// lib/field-transforms/default-transforms/slot-transform.tsx
|
|
285
|
+
init_react_import();
|
|
286
|
+
var getSlotTransform = (renderSlotEdit, renderSlotRender = renderSlotEdit) => ({
|
|
287
|
+
slot: ({ value: content, propName, field, isReadOnly }) => {
|
|
288
|
+
const render = isReadOnly ? renderSlotRender : renderSlotEdit;
|
|
289
|
+
const Slot = (dzProps) => render(__spreadProps(__spreadValues({
|
|
290
|
+
allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
|
|
291
|
+
disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
|
|
292
|
+
}, dzProps), {
|
|
293
|
+
zone: propName,
|
|
294
|
+
content
|
|
295
|
+
}));
|
|
296
|
+
return Slot;
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
// lib/use-slots.tsx
|
|
301
|
+
init_react_import();
|
|
302
|
+
function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
|
303
|
+
return useFieldTransforms(
|
|
304
|
+
config,
|
|
305
|
+
item,
|
|
306
|
+
getSlotTransform(renderSlotEdit, renderSlotRender),
|
|
307
|
+
readOnly,
|
|
308
|
+
forceReadOnly
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// components/RichTextEditor/lib/use-richtext-props.tsx
|
|
313
|
+
init_react_import();
|
|
314
|
+
import { lazy, Suspense, useMemo as useMemo2 } from "react";
|
|
315
|
+
|
|
316
|
+
// components/RichTextEditor/components/RenderFallback.tsx
|
|
317
|
+
init_react_import();
|
|
318
|
+
import { jsx } from "react/jsx-runtime";
|
|
319
|
+
var getClassName = get_class_name_factory_default("RichTextEditor", styles_module_default);
|
|
320
|
+
function RichTextRenderFallback({ content }) {
|
|
321
|
+
return /* @__PURE__ */ jsx("div", { className: getClassName(), children: /* @__PURE__ */ jsx(
|
|
322
|
+
"div",
|
|
323
|
+
{
|
|
324
|
+
className: "rich-text",
|
|
325
|
+
dangerouslySetInnerHTML: { __html: content }
|
|
326
|
+
}
|
|
327
|
+
) });
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// components/RichTextEditor/lib/use-richtext-props.tsx
|
|
331
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
332
|
+
function useRichtextProps(fields, props) {
|
|
333
|
+
const findAllRichtextKeys = (fields2) => {
|
|
334
|
+
if (!fields2) return [];
|
|
335
|
+
const result = [];
|
|
336
|
+
for (const [key, field] of Object.entries(fields2)) {
|
|
337
|
+
if (field.type === "richtext") {
|
|
338
|
+
result.push(key);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return result;
|
|
342
|
+
};
|
|
343
|
+
const richtextKeys = useMemo2(() => findAllRichtextKeys(fields), [fields]);
|
|
344
|
+
const richtextProps = useMemo2(() => {
|
|
345
|
+
if (!(richtextKeys == null ? void 0 : richtextKeys.length)) return {};
|
|
346
|
+
const RichTextRender = lazy(
|
|
347
|
+
() => import("./Render-OFE6QLI2.mjs").then((m) => ({
|
|
348
|
+
default: m.RichTextRender
|
|
349
|
+
}))
|
|
350
|
+
);
|
|
351
|
+
return richtextKeys.reduce((acc, key) => {
|
|
352
|
+
acc[key] = /* @__PURE__ */ jsx2(Suspense, { fallback: /* @__PURE__ */ jsx2(RichTextRenderFallback, { content: props[key] }), children: /* @__PURE__ */ jsx2(
|
|
353
|
+
RichTextRender,
|
|
354
|
+
{
|
|
355
|
+
content: props[key],
|
|
356
|
+
field: fields[key]
|
|
357
|
+
}
|
|
358
|
+
) });
|
|
359
|
+
return acc;
|
|
360
|
+
}, {});
|
|
361
|
+
}, [richtextKeys, props, fields]);
|
|
362
|
+
return richtextProps;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// components/SlotRender/server.tsx
|
|
366
|
+
init_react_import();
|
|
367
|
+
import { forwardRef } from "react";
|
|
368
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
369
|
+
var SlotRenderPure = (props) => /* @__PURE__ */ jsx3(SlotRender, __spreadValues({}, props));
|
|
370
|
+
var Item = ({
|
|
371
|
+
config,
|
|
372
|
+
item,
|
|
373
|
+
metadata
|
|
374
|
+
}) => {
|
|
375
|
+
const Component = config.components[item.type];
|
|
376
|
+
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ jsx3(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
|
377
|
+
const richtextProps = useRichtextProps(Component.fields, props);
|
|
378
|
+
return /* @__PURE__ */ jsx3(
|
|
379
|
+
Component.render,
|
|
380
|
+
__spreadProps(__spreadValues(__spreadValues({}, props), richtextProps), {
|
|
381
|
+
puck: __spreadProps(__spreadValues({}, props.puck), {
|
|
382
|
+
metadata: metadata || {}
|
|
383
|
+
})
|
|
384
|
+
})
|
|
385
|
+
);
|
|
386
|
+
};
|
|
387
|
+
var SlotRender = forwardRef(
|
|
388
|
+
function SlotRenderInternal({ className, style, content, config, metadata, as }, ref) {
|
|
389
|
+
const El = as != null ? as : "div";
|
|
390
|
+
return /* @__PURE__ */ jsx3(El, { className, style, ref, children: content.map((item) => {
|
|
391
|
+
if (!config.components[item.type]) {
|
|
392
|
+
return null;
|
|
393
|
+
}
|
|
394
|
+
return /* @__PURE__ */ jsx3(
|
|
395
|
+
Item,
|
|
396
|
+
{
|
|
397
|
+
config,
|
|
398
|
+
item,
|
|
399
|
+
metadata
|
|
400
|
+
},
|
|
401
|
+
item.props.id
|
|
402
|
+
);
|
|
403
|
+
}) });
|
|
404
|
+
}
|
|
405
|
+
);
|
|
406
|
+
|
|
407
|
+
export {
|
|
408
|
+
useFieldTransforms,
|
|
409
|
+
getSlotTransform,
|
|
410
|
+
useSlots,
|
|
411
|
+
RichTextRenderFallback,
|
|
412
|
+
useRichtextProps,
|
|
413
|
+
SlotRenderPure,
|
|
414
|
+
SlotRender,
|
|
415
|
+
toComponent,
|
|
416
|
+
migrate,
|
|
417
|
+
transformProps,
|
|
418
|
+
resolveAllData
|
|
419
|
+
};
|