@crediblemark/build 0.25.6 → 0.25.8
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/ArrayField-HYHS4HCO.mjs +17 -0
- package/dist/{ArrayField-PAJW74AC.css → ArrayField-MCFJLKAL.css} +15 -15
- package/dist/{Editor-Y342RWPN.css → Editor-CVT4RKSU.css} +7 -7
- package/dist/{Editor-OFA3KX3N.mjs → Editor-P3UUWNSZ.mjs} +9 -11
- package/dist/ObjectField-4N5XWAFL.mjs +17 -0
- package/dist/{ObjectField-WACQHQ4N.css → ObjectField-YPHZU7G2.css} +15 -15
- package/dist/{Render-HVM2KISU.css → Render-DOE2LXKX.css} +1 -1
- package/dist/{Render-5WYR4VZX.mjs → Render-I6PZ5MEA.mjs} +1 -1
- package/dist/{actions-LaZpJ1KE.d.mts → actions-CKSDxt4l.d.mts} +1 -1
- package/dist/{actions-LaZpJ1KE.d.ts → actions-CKSDxt4l.d.ts} +1 -1
- package/dist/{chunk-QHJGER7I.mjs → chunk-44PQTFGV.mjs} +7 -9
- package/dist/{chunk-STIUFJT2.mjs → chunk-AZFZRLP7.mjs} +12 -12
- package/dist/{chunk-JX7LICWE.mjs → chunk-E4F5M5JH.mjs} +2 -2
- package/dist/chunk-HHKM5MBJ.mjs +3163 -0
- package/dist/{chunk-H6RPI3T6.mjs → chunk-ISXFLTBM.mjs} +1 -1
- package/dist/{chunk-MZXW5F5R.mjs → chunk-KN26YZZJ.mjs} +286 -131
- package/dist/chunk-MWCFPGI6.mjs +4807 -0
- package/dist/{chunk-64A37UUC.mjs → chunk-O44M27KT.mjs} +442 -7
- package/dist/{chunk-XAD7XPP2.mjs → chunk-P2AZFZ7Q.mjs} +3 -3
- package/dist/{chunk-SLKHXT3Q.mjs → chunk-PFHKXXSV.mjs} +1 -1
- package/dist/{chunk-RUJOMPX6.mjs → chunk-S32JZ2HU.mjs} +1 -1
- package/dist/{chunk-KAOWYQIB.mjs → chunk-T2LBDQLG.mjs} +12 -12
- package/dist/{chunk-4NZUDTR6.mjs → chunk-XLRMLBFR.mjs} +1 -1
- package/dist/{chunk-WSTUSWZT.mjs → chunk-Z7DDX2XU.mjs} +2 -2
- package/dist/{full-ECZCK3RE.mjs → full-3VRJOFG5.mjs} +6 -8
- package/dist/{full-PLJRDIMB.css → full-C7RVGAUA.css} +6 -6
- package/dist/{index-CD3PszvP.d.mts → index-Ds4Dkkyr.d.mts} +1 -1
- package/dist/{index-Bj2x5pZ7.d.ts → index-DwajIHZf.d.ts} +1 -1
- package/dist/index.css +231 -43
- package/dist/index.d.mts +8 -40
- package/dist/index.d.ts +8 -40
- package/dist/index.js +1306 -649
- package/dist/index.mjs +26 -26
- package/dist/internal.d.mts +2 -2
- package/dist/internal.d.ts +2 -2
- package/dist/internal.mjs +1 -2
- package/dist/{loaded-FY2TCG5Y.css → loaded-4FAPBCAU.css} +1 -1
- package/dist/{loaded-NRHNHJPM.mjs → loaded-C2JGMUXV.mjs} +3 -5
- package/dist/{loaded-5D7VRSXM.mjs → loaded-FJHWTGH6.mjs} +3 -5
- package/dist/{loaded-3MKTRGL5.mjs → loaded-NTEK7RT3.mjs} +3 -5
- package/dist/no-external.css +225 -39
- package/dist/no-external.d.mts +4 -4
- package/dist/no-external.d.ts +4 -4
- package/dist/no-external.js +1306 -649
- package/dist/no-external.mjs +26 -26
- package/dist/rsc.css +1421 -1
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +10328 -1011
- package/dist/rsc.mjs +21 -4
- package/dist/{walk-tree-BO8uRNcW.d.mts → walk-tree-B_jHFa3L.d.mts} +39 -2
- package/dist/{walk-tree-BEw6kTXm.d.ts → walk-tree-DHMRjk5Z.d.ts} +39 -2
- package/package.json +1 -1
- package/dist/ArrayField-PGZLQW7G.mjs +0 -19
- package/dist/ObjectField-N7ES6H3B.mjs +0 -19
- package/dist/chunk-7LXZOPYT.mjs +0 -445
- package/dist/chunk-HIE6KXP6.mjs +0 -455
- package/dist/chunk-SMAWAXVX.mjs +0 -139
- package/dist/chunk-W7LED3JG.mjs +0 -6890
package/dist/rsc.mjs
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ColorPickerField,
|
|
3
|
+
DropZone,
|
|
4
|
+
ResponsiveSliderField,
|
|
5
|
+
SliderField,
|
|
2
6
|
SlotRenderPure,
|
|
3
7
|
migrate,
|
|
4
8
|
resolveAllData,
|
|
5
9
|
transformProps,
|
|
6
10
|
useRichtextProps,
|
|
7
11
|
useSlots
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-HHKM5MBJ.mjs";
|
|
13
|
+
import "./chunk-Z7DDX2XU.mjs";
|
|
14
|
+
import "./chunk-44PQTFGV.mjs";
|
|
15
|
+
import "./chunk-P2AZFZ7Q.mjs";
|
|
16
|
+
import "./chunk-T2LBDQLG.mjs";
|
|
17
|
+
import "./chunk-E4F5M5JH.mjs";
|
|
18
|
+
import "./chunk-ISXFLTBM.mjs";
|
|
19
|
+
import "./chunk-AZFZRLP7.mjs";
|
|
20
|
+
import "./chunk-XLRMLBFR.mjs";
|
|
21
|
+
import "./chunk-PFHKXXSV.mjs";
|
|
22
|
+
import "./chunk-S32JZ2HU.mjs";
|
|
23
|
+
import "./chunk-KN26YZZJ.mjs";
|
|
11
24
|
import "./chunk-BFHV72KK.mjs";
|
|
12
25
|
import {
|
|
13
26
|
rootAreaId,
|
|
@@ -15,7 +28,7 @@ import {
|
|
|
15
28
|
rootZone,
|
|
16
29
|
setupZone,
|
|
17
30
|
walkTree
|
|
18
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-O44M27KT.mjs";
|
|
19
32
|
import "./chunk-AFVEAZTD.mjs";
|
|
20
33
|
|
|
21
34
|
// components/ServerRender/index.tsx
|
|
@@ -133,7 +146,11 @@ function Render({
|
|
|
133
146
|
);
|
|
134
147
|
}
|
|
135
148
|
export {
|
|
149
|
+
ColorPickerField,
|
|
150
|
+
DropZone,
|
|
136
151
|
Render,
|
|
152
|
+
ResponsiveSliderField,
|
|
153
|
+
SliderField,
|
|
137
154
|
migrate,
|
|
138
155
|
resolveAllData,
|
|
139
156
|
transformProps,
|
|
@@ -1,4 +1,41 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import react__default from 'react';
|
|
4
|
+
import { k as ResponsiveValue, l as DropZoneProps, a as Config, D as Data, W as WithId, U as UserGenerics, m as Content, c as ComponentData, n as DefaultComponents, o as DefaultComponentProps, p as DefaultRootFieldProps, M as Metadata, q as RootData } from './actions-CKSDxt4l.mjs';
|
|
5
|
+
|
|
6
|
+
type SliderFieldProps = {
|
|
7
|
+
value: string | number;
|
|
8
|
+
onChange: (value: string | number) => void;
|
|
9
|
+
label?: string;
|
|
10
|
+
min?: number;
|
|
11
|
+
max?: number;
|
|
12
|
+
step?: number;
|
|
13
|
+
unit?: string;
|
|
14
|
+
defaultValue?: string | number;
|
|
15
|
+
useUnits?: boolean;
|
|
16
|
+
style?: react__default.CSSProperties;
|
|
17
|
+
};
|
|
18
|
+
declare const SliderField: ({ value, onChange, min, max, step, unit, defaultValue, useUnits, style }: SliderFieldProps) => react_jsx_runtime.JSX.Element;
|
|
19
|
+
|
|
20
|
+
type ResponsiveSliderFieldProps = {
|
|
21
|
+
value: ResponsiveValue;
|
|
22
|
+
onChange: (value: ResponsiveValue) => void;
|
|
23
|
+
label?: string;
|
|
24
|
+
unit?: string;
|
|
25
|
+
max?: number;
|
|
26
|
+
min?: number;
|
|
27
|
+
step?: number;
|
|
28
|
+
defaultValue?: number | ResponsiveValue;
|
|
29
|
+
};
|
|
30
|
+
declare const ResponsiveSliderField: ({ value, onChange, label, unit, max, min, step, defaultValue }: ResponsiveSliderFieldProps) => react_jsx_runtime.JSX.Element;
|
|
31
|
+
|
|
32
|
+
type ColorPickerFieldProps = {
|
|
33
|
+
value: string;
|
|
34
|
+
onChange: (value: string) => void;
|
|
35
|
+
};
|
|
36
|
+
declare const ColorPickerField: ({ value, onChange }: ColorPickerFieldProps) => react_jsx_runtime.JSX.Element;
|
|
37
|
+
|
|
38
|
+
declare const DropZone: react.ForwardRefExoticComponent<Omit<DropZoneProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
2
39
|
|
|
3
40
|
type MigrationOptions<UserConfig extends Config> = {
|
|
4
41
|
migrateDynamicZonesForComponent?: {
|
|
@@ -26,4 +63,4 @@ type WalkTreeOptions = {
|
|
|
26
63
|
};
|
|
27
64
|
declare function walkTree<T extends ComponentData | RootData | G["UserData"], UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(data: T, config: UserConfig, callbackFn: (data: Content, options: WalkTreeOptions) => Content | null | void): T;
|
|
28
65
|
|
|
29
|
-
export { migrate as m, resolveAllData as r, transformProps as t, walkTree as w };
|
|
66
|
+
export { ColorPickerField as C, DropZone as D, ResponsiveSliderField as R, SliderField as S, migrate as m, resolveAllData as r, transformProps as t, walkTree as w };
|
|
@@ -1,4 +1,41 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import react__default from 'react';
|
|
4
|
+
import { k as ResponsiveValue, l as DropZoneProps, a as Config, D as Data, W as WithId, U as UserGenerics, m as Content, c as ComponentData, n as DefaultComponents, o as DefaultComponentProps, p as DefaultRootFieldProps, M as Metadata, q as RootData } from './actions-CKSDxt4l.js';
|
|
5
|
+
|
|
6
|
+
type SliderFieldProps = {
|
|
7
|
+
value: string | number;
|
|
8
|
+
onChange: (value: string | number) => void;
|
|
9
|
+
label?: string;
|
|
10
|
+
min?: number;
|
|
11
|
+
max?: number;
|
|
12
|
+
step?: number;
|
|
13
|
+
unit?: string;
|
|
14
|
+
defaultValue?: string | number;
|
|
15
|
+
useUnits?: boolean;
|
|
16
|
+
style?: react__default.CSSProperties;
|
|
17
|
+
};
|
|
18
|
+
declare const SliderField: ({ value, onChange, min, max, step, unit, defaultValue, useUnits, style }: SliderFieldProps) => react_jsx_runtime.JSX.Element;
|
|
19
|
+
|
|
20
|
+
type ResponsiveSliderFieldProps = {
|
|
21
|
+
value: ResponsiveValue;
|
|
22
|
+
onChange: (value: ResponsiveValue) => void;
|
|
23
|
+
label?: string;
|
|
24
|
+
unit?: string;
|
|
25
|
+
max?: number;
|
|
26
|
+
min?: number;
|
|
27
|
+
step?: number;
|
|
28
|
+
defaultValue?: number | ResponsiveValue;
|
|
29
|
+
};
|
|
30
|
+
declare const ResponsiveSliderField: ({ value, onChange, label, unit, max, min, step, defaultValue }: ResponsiveSliderFieldProps) => react_jsx_runtime.JSX.Element;
|
|
31
|
+
|
|
32
|
+
type ColorPickerFieldProps = {
|
|
33
|
+
value: string;
|
|
34
|
+
onChange: (value: string) => void;
|
|
35
|
+
};
|
|
36
|
+
declare const ColorPickerField: ({ value, onChange }: ColorPickerFieldProps) => react_jsx_runtime.JSX.Element;
|
|
37
|
+
|
|
38
|
+
declare const DropZone: react.ForwardRefExoticComponent<Omit<DropZoneProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
2
39
|
|
|
3
40
|
type MigrationOptions<UserConfig extends Config> = {
|
|
4
41
|
migrateDynamicZonesForComponent?: {
|
|
@@ -26,4 +63,4 @@ type WalkTreeOptions = {
|
|
|
26
63
|
};
|
|
27
64
|
declare function walkTree<T extends ComponentData | RootData | G["UserData"], UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(data: T, config: UserConfig, callbackFn: (data: Content, options: WalkTreeOptions) => Content | null | void): T;
|
|
28
65
|
|
|
29
|
-
export { migrate as m, resolveAllData as r, transformProps as t, walkTree as w };
|
|
66
|
+
export { ColorPickerField as C, DropZone as D, ResponsiveSliderField as R, SliderField as S, migrate as m, resolveAllData as r, transformProps as t, walkTree as w };
|
package/package.json
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ArrayField
|
|
3
|
-
} from "./chunk-QHJGER7I.mjs";
|
|
4
|
-
import "./chunk-KAOWYQIB.mjs";
|
|
5
|
-
import "./chunk-JX7LICWE.mjs";
|
|
6
|
-
import "./chunk-H6RPI3T6.mjs";
|
|
7
|
-
import "./chunk-STIUFJT2.mjs";
|
|
8
|
-
import "./chunk-4NZUDTR6.mjs";
|
|
9
|
-
import "./chunk-SLKHXT3Q.mjs";
|
|
10
|
-
import "./chunk-RUJOMPX6.mjs";
|
|
11
|
-
import "./chunk-MZXW5F5R.mjs";
|
|
12
|
-
import "./chunk-64A37UUC.mjs";
|
|
13
|
-
import "./chunk-SMAWAXVX.mjs";
|
|
14
|
-
import "./chunk-BFHV72KK.mjs";
|
|
15
|
-
import "./chunk-7LXZOPYT.mjs";
|
|
16
|
-
import "./chunk-AFVEAZTD.mjs";
|
|
17
|
-
export {
|
|
18
|
-
ArrayField
|
|
19
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ObjectField
|
|
3
|
-
} from "./chunk-XAD7XPP2.mjs";
|
|
4
|
-
import "./chunk-KAOWYQIB.mjs";
|
|
5
|
-
import "./chunk-JX7LICWE.mjs";
|
|
6
|
-
import "./chunk-H6RPI3T6.mjs";
|
|
7
|
-
import "./chunk-STIUFJT2.mjs";
|
|
8
|
-
import "./chunk-4NZUDTR6.mjs";
|
|
9
|
-
import "./chunk-SLKHXT3Q.mjs";
|
|
10
|
-
import "./chunk-RUJOMPX6.mjs";
|
|
11
|
-
import "./chunk-MZXW5F5R.mjs";
|
|
12
|
-
import "./chunk-64A37UUC.mjs";
|
|
13
|
-
import "./chunk-SMAWAXVX.mjs";
|
|
14
|
-
import "./chunk-BFHV72KK.mjs";
|
|
15
|
-
import "./chunk-7LXZOPYT.mjs";
|
|
16
|
-
import "./chunk-AFVEAZTD.mjs";
|
|
17
|
-
export {
|
|
18
|
-
ObjectField
|
|
19
|
-
};
|
package/dist/chunk-7LXZOPYT.mjs
DELETED
|
@@ -1,445 +0,0 @@
|
|
|
1
|
-
// lib/data/default-slots.ts
|
|
2
|
-
var defaultSlots = (value, fields) => Object.keys(fields).reduce(
|
|
3
|
-
(acc, fieldName) => fields[fieldName].type === "slot" ? { [fieldName]: [], ...acc } : acc,
|
|
4
|
-
value
|
|
5
|
-
);
|
|
6
|
-
|
|
7
|
-
// lib/data/map-fields.ts
|
|
8
|
-
var isPromise = (v) => !!v && typeof v.then === "function";
|
|
9
|
-
var flatten = (values) => values.reduce((acc, item) => ({ ...acc, ...item }), {});
|
|
10
|
-
var containsPromise = (arr) => arr.some(isPromise);
|
|
11
|
-
var walkField = ({
|
|
12
|
-
value,
|
|
13
|
-
fields,
|
|
14
|
-
mappers,
|
|
15
|
-
propKey = "",
|
|
16
|
-
propPath = "",
|
|
17
|
-
id = "",
|
|
18
|
-
config,
|
|
19
|
-
recurseSlots = false
|
|
20
|
-
}) => {
|
|
21
|
-
const fieldType = fields[propKey]?.type;
|
|
22
|
-
const map = mappers[fieldType];
|
|
23
|
-
if (map && fieldType === "slot") {
|
|
24
|
-
const content = value || [];
|
|
25
|
-
const mappedContent = recurseSlots ? content.map((el) => {
|
|
26
|
-
const componentConfig = config.components[el.type];
|
|
27
|
-
if (!componentConfig) {
|
|
28
|
-
throw new Error(`Could not find component config for ${el.type}`);
|
|
29
|
-
}
|
|
30
|
-
const fields2 = componentConfig.fields ?? {};
|
|
31
|
-
return walkField({
|
|
32
|
-
value: { ...el, props: defaultSlots(el.props, fields2) },
|
|
33
|
-
fields: fields2,
|
|
34
|
-
mappers,
|
|
35
|
-
id: el.props.id,
|
|
36
|
-
config,
|
|
37
|
-
recurseSlots
|
|
38
|
-
});
|
|
39
|
-
}) : content;
|
|
40
|
-
if (containsPromise(mappedContent)) {
|
|
41
|
-
return Promise.all(mappedContent);
|
|
42
|
-
}
|
|
43
|
-
return map({
|
|
44
|
-
value: mappedContent,
|
|
45
|
-
parentId: id,
|
|
46
|
-
propName: propPath,
|
|
47
|
-
field: fields[propKey],
|
|
48
|
-
propPath
|
|
49
|
-
});
|
|
50
|
-
} else if (map && fields[propKey]) {
|
|
51
|
-
return map({
|
|
52
|
-
value,
|
|
53
|
-
parentId: id,
|
|
54
|
-
propName: propKey,
|
|
55
|
-
field: fields[propKey],
|
|
56
|
-
propPath
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
if (value && typeof value === "object") {
|
|
60
|
-
if (Array.isArray(value)) {
|
|
61
|
-
const arrayFields = fields[propKey]?.type === "array" ? fields[propKey].arrayFields : null;
|
|
62
|
-
if (!arrayFields) return value;
|
|
63
|
-
const newValue = value.map(
|
|
64
|
-
(el, idx) => walkField({
|
|
65
|
-
value: el,
|
|
66
|
-
fields: arrayFields,
|
|
67
|
-
mappers,
|
|
68
|
-
propKey,
|
|
69
|
-
propPath: `${propPath}[${idx}]`,
|
|
70
|
-
id,
|
|
71
|
-
config,
|
|
72
|
-
recurseSlots
|
|
73
|
-
})
|
|
74
|
-
);
|
|
75
|
-
if (containsPromise(newValue)) {
|
|
76
|
-
return Promise.all(newValue);
|
|
77
|
-
}
|
|
78
|
-
return newValue;
|
|
79
|
-
} else if ("$$typeof" in value) {
|
|
80
|
-
return value;
|
|
81
|
-
} else {
|
|
82
|
-
const objectFields = fields[propKey]?.type === "object" ? fields[propKey].objectFields : fields;
|
|
83
|
-
return walkObject({
|
|
84
|
-
value,
|
|
85
|
-
fields: objectFields,
|
|
86
|
-
mappers,
|
|
87
|
-
id,
|
|
88
|
-
getPropPath: (k) => `${propPath}.${k}`,
|
|
89
|
-
config,
|
|
90
|
-
recurseSlots
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return value;
|
|
95
|
-
};
|
|
96
|
-
var walkObject = ({
|
|
97
|
-
value,
|
|
98
|
-
fields,
|
|
99
|
-
mappers,
|
|
100
|
-
id,
|
|
101
|
-
getPropPath,
|
|
102
|
-
config,
|
|
103
|
-
recurseSlots
|
|
104
|
-
}) => {
|
|
105
|
-
const newProps = Object.entries(value).map(([k, v]) => {
|
|
106
|
-
const opts = {
|
|
107
|
-
value: v,
|
|
108
|
-
fields,
|
|
109
|
-
mappers,
|
|
110
|
-
propKey: k,
|
|
111
|
-
propPath: getPropPath(k),
|
|
112
|
-
id,
|
|
113
|
-
config,
|
|
114
|
-
recurseSlots
|
|
115
|
-
};
|
|
116
|
-
const newValue = walkField(opts);
|
|
117
|
-
if (isPromise(newValue)) {
|
|
118
|
-
return newValue.then((resolvedValue) => ({
|
|
119
|
-
[k]: resolvedValue
|
|
120
|
-
}));
|
|
121
|
-
}
|
|
122
|
-
return {
|
|
123
|
-
[k]: newValue
|
|
124
|
-
};
|
|
125
|
-
}, {});
|
|
126
|
-
if (containsPromise(newProps)) {
|
|
127
|
-
return Promise.all(newProps).then(flatten);
|
|
128
|
-
}
|
|
129
|
-
return flatten(newProps);
|
|
130
|
-
};
|
|
131
|
-
function mapFields(item, mappers, config, recurseSlots = false, shouldDefaultSlots = true) {
|
|
132
|
-
const itemType = "type" in item ? item.type : "root";
|
|
133
|
-
const componentConfig = itemType === "root" ? config.root : config.components?.[itemType];
|
|
134
|
-
const newProps = walkObject({
|
|
135
|
-
value: shouldDefaultSlots ? defaultSlots(item.props ?? {}, componentConfig?.fields ?? {}) : item.props,
|
|
136
|
-
fields: componentConfig?.fields ?? {},
|
|
137
|
-
mappers,
|
|
138
|
-
id: item.props ? item.props.id ?? "root" : "root",
|
|
139
|
-
getPropPath: (k) => k,
|
|
140
|
-
config,
|
|
141
|
-
recurseSlots
|
|
142
|
-
});
|
|
143
|
-
if (isPromise(newProps)) {
|
|
144
|
-
return newProps.then((resolvedProps) => ({
|
|
145
|
-
...item,
|
|
146
|
-
props: resolvedProps
|
|
147
|
-
}));
|
|
148
|
-
}
|
|
149
|
-
return {
|
|
150
|
-
...item,
|
|
151
|
-
props: newProps
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// lib/data/walk-tree.ts
|
|
156
|
-
function walkTree(data, config, callbackFn) {
|
|
157
|
-
const walkItem = (item) => {
|
|
158
|
-
return mapFields(
|
|
159
|
-
item,
|
|
160
|
-
{
|
|
161
|
-
slot: ({ value, parentId, propName }) => {
|
|
162
|
-
const content = value;
|
|
163
|
-
return callbackFn(content, { parentId, propName }) ?? content;
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
config,
|
|
167
|
-
true
|
|
168
|
-
);
|
|
169
|
-
};
|
|
170
|
-
if ("props" in data) {
|
|
171
|
-
return walkItem(data);
|
|
172
|
-
}
|
|
173
|
-
const _data = data;
|
|
174
|
-
const zones = _data.zones ?? {};
|
|
175
|
-
const mappedContent = _data.content.map(walkItem);
|
|
176
|
-
return {
|
|
177
|
-
root: walkItem(_data.root),
|
|
178
|
-
content: callbackFn(mappedContent, {
|
|
179
|
-
parentId: "root",
|
|
180
|
-
propName: "default-zone"
|
|
181
|
-
}) ?? mappedContent,
|
|
182
|
-
zones: Object.keys(zones).reduce(
|
|
183
|
-
(acc, zoneCompound) => ({
|
|
184
|
-
...acc,
|
|
185
|
-
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
|
186
|
-
}),
|
|
187
|
-
{}
|
|
188
|
-
)
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// lib/generate-id.ts
|
|
193
|
-
import { v4 as uuidv4 } from "uuid";
|
|
194
|
-
var generateId = (type) => type ? `${type}-${uuidv4()}` : uuidv4();
|
|
195
|
-
|
|
196
|
-
// lib/root-droppable-id.ts
|
|
197
|
-
var rootAreaId = "root";
|
|
198
|
-
var rootZone = "default-zone";
|
|
199
|
-
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
|
200
|
-
|
|
201
|
-
// lib/data/flatten-node.ts
|
|
202
|
-
import flat from "flat";
|
|
203
|
-
|
|
204
|
-
// lib/data/strip-slots.ts
|
|
205
|
-
var stripSlots = (data, config) => {
|
|
206
|
-
return mapFields(data, { slot: () => null }, config);
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
// lib/data/flatten-node.ts
|
|
210
|
-
var { flatten: flatten2, unflatten } = flat;
|
|
211
|
-
var isPureObject = (val) => val != null && Object.prototype.toString.call(val) === "[object Object]";
|
|
212
|
-
var emptyArrayStr = "__credbuild_[]";
|
|
213
|
-
var emptyObjectStr = "__credbuild_{}";
|
|
214
|
-
function encodeEmptyObjects(props = {}) {
|
|
215
|
-
const result = {};
|
|
216
|
-
for (const key in props) {
|
|
217
|
-
if (!Object.prototype.hasOwnProperty.call(props, key)) continue;
|
|
218
|
-
const val = props[key];
|
|
219
|
-
if (Array.isArray(val) && val.length === 0) {
|
|
220
|
-
result[key] = emptyArrayStr;
|
|
221
|
-
} else if (isPureObject(val) && Object.keys(val).length === 0) {
|
|
222
|
-
result[key] = emptyObjectStr;
|
|
223
|
-
} else {
|
|
224
|
-
result[key] = val;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
return result;
|
|
228
|
-
}
|
|
229
|
-
function decodeEmptyObjects(props = {}) {
|
|
230
|
-
const result = {};
|
|
231
|
-
for (const key in props) {
|
|
232
|
-
if (!Object.prototype.hasOwnProperty.call(props, key)) continue;
|
|
233
|
-
const val = props[key];
|
|
234
|
-
if (val === emptyArrayStr) {
|
|
235
|
-
result[key] = [];
|
|
236
|
-
} else if (val === emptyObjectStr) {
|
|
237
|
-
result[key] = {};
|
|
238
|
-
} else {
|
|
239
|
-
result[key] = val;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
return result;
|
|
243
|
-
}
|
|
244
|
-
var flattenNode = (node, config) => {
|
|
245
|
-
return {
|
|
246
|
-
...node,
|
|
247
|
-
props: encodeEmptyObjects(flatten2(stripSlots(node, config).props))
|
|
248
|
-
};
|
|
249
|
-
};
|
|
250
|
-
var expandNode = (node) => {
|
|
251
|
-
const props = unflatten(decodeEmptyObjects(node.props));
|
|
252
|
-
return {
|
|
253
|
-
...node,
|
|
254
|
-
props
|
|
255
|
-
};
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
// lib/data/to-component.ts
|
|
259
|
-
var toComponent = (item) => {
|
|
260
|
-
return "type" in item ? item : {
|
|
261
|
-
...item,
|
|
262
|
-
props: { ...item.props, id: "root" },
|
|
263
|
-
type: "root"
|
|
264
|
-
};
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
// lib/get-zone-id.ts
|
|
268
|
-
var getZoneId = (zoneCompound) => {
|
|
269
|
-
if (!zoneCompound) {
|
|
270
|
-
return [];
|
|
271
|
-
}
|
|
272
|
-
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
|
273
|
-
return zoneCompound.split(":");
|
|
274
|
-
}
|
|
275
|
-
return [rootDroppableId, zoneCompound];
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
// lib/data/for-related-zones.ts
|
|
279
|
-
function forRelatedZones(item, data, cb, path = []) {
|
|
280
|
-
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
|
281
|
-
const [parentId] = getZoneId(zoneCompound);
|
|
282
|
-
if (parentId === item.props.id) {
|
|
283
|
-
cb(path, zoneCompound, content);
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
// lib/data/walk-app-state.ts
|
|
289
|
-
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
|
290
|
-
let newZones = {};
|
|
291
|
-
const newZoneIndex = {};
|
|
292
|
-
const newNodeIndex = {};
|
|
293
|
-
const processContent = (path, zoneCompound, content, zoneType, newId) => {
|
|
294
|
-
const [parentId] = zoneCompound.split(":");
|
|
295
|
-
const mappedContent = (mapContent(content, zoneCompound, zoneType) ?? content) || [];
|
|
296
|
-
const [_2, zone] = zoneCompound.split(":");
|
|
297
|
-
const newZoneCompound = `${newId || parentId}:${zone}`;
|
|
298
|
-
const newContent2 = mappedContent.map(
|
|
299
|
-
(zoneChild, index) => processItem(zoneChild, [...path, newZoneCompound], index)
|
|
300
|
-
);
|
|
301
|
-
newZoneIndex[newZoneCompound] = {
|
|
302
|
-
contentIds: newContent2.map((item) => item.props.id),
|
|
303
|
-
type: zoneType
|
|
304
|
-
};
|
|
305
|
-
return [newZoneCompound, newContent2];
|
|
306
|
-
};
|
|
307
|
-
const processRelatedZones = (item, newId, initialPath) => {
|
|
308
|
-
forRelatedZones(
|
|
309
|
-
item,
|
|
310
|
-
state.data,
|
|
311
|
-
(relatedPath, relatedZoneCompound, relatedContent) => {
|
|
312
|
-
const [zoneCompound, newContent2] = processContent(
|
|
313
|
-
relatedPath,
|
|
314
|
-
relatedZoneCompound,
|
|
315
|
-
relatedContent,
|
|
316
|
-
"dropzone",
|
|
317
|
-
newId
|
|
318
|
-
);
|
|
319
|
-
newZones[zoneCompound] = newContent2;
|
|
320
|
-
},
|
|
321
|
-
initialPath
|
|
322
|
-
);
|
|
323
|
-
};
|
|
324
|
-
const processItem = (item, path, index) => {
|
|
325
|
-
const mappedItem = mapNodeOrSkip(item, path, index);
|
|
326
|
-
if (!mappedItem) return item;
|
|
327
|
-
const id = mappedItem.props.id;
|
|
328
|
-
const newProps = {
|
|
329
|
-
...mapFields(
|
|
330
|
-
mappedItem,
|
|
331
|
-
{
|
|
332
|
-
slot: ({ value, parentId: parentId2, propPath }) => {
|
|
333
|
-
const content = value;
|
|
334
|
-
const zoneCompound = `${parentId2}:${propPath}`;
|
|
335
|
-
const [_2, newContent2] = processContent(
|
|
336
|
-
path,
|
|
337
|
-
zoneCompound,
|
|
338
|
-
content,
|
|
339
|
-
"slot",
|
|
340
|
-
parentId2
|
|
341
|
-
);
|
|
342
|
-
return newContent2;
|
|
343
|
-
}
|
|
344
|
-
},
|
|
345
|
-
config
|
|
346
|
-
).props,
|
|
347
|
-
id
|
|
348
|
-
};
|
|
349
|
-
processRelatedZones(item, id, path);
|
|
350
|
-
const newItem = { ...mappedItem, props: newProps };
|
|
351
|
-
const thisZoneCompound = path[path.length - 1];
|
|
352
|
-
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
|
353
|
-
newNodeIndex[id] = {
|
|
354
|
-
data: newItem,
|
|
355
|
-
flatData: flattenNode(newItem, config),
|
|
356
|
-
path,
|
|
357
|
-
parentId,
|
|
358
|
-
zone
|
|
359
|
-
};
|
|
360
|
-
const finalData = { ...newItem, props: { ...newItem.props } };
|
|
361
|
-
if (newProps.id === "root") {
|
|
362
|
-
delete finalData["type"];
|
|
363
|
-
delete finalData.props["id"];
|
|
364
|
-
}
|
|
365
|
-
return finalData;
|
|
366
|
-
};
|
|
367
|
-
const zones = state.data.zones || {};
|
|
368
|
-
const [_, newContent] = processContent(
|
|
369
|
-
[],
|
|
370
|
-
rootDroppableId,
|
|
371
|
-
state.data.content,
|
|
372
|
-
"root"
|
|
373
|
-
);
|
|
374
|
-
const processedContent = newContent;
|
|
375
|
-
const zonesAlreadyProcessed = Object.keys(newZones);
|
|
376
|
-
Object.keys(zones || {}).forEach((zoneCompound) => {
|
|
377
|
-
const [parentId] = zoneCompound.split(":");
|
|
378
|
-
if (zonesAlreadyProcessed.includes(zoneCompound)) {
|
|
379
|
-
return;
|
|
380
|
-
}
|
|
381
|
-
const [_2, newContent2] = processContent(
|
|
382
|
-
[rootDroppableId],
|
|
383
|
-
zoneCompound,
|
|
384
|
-
zones[zoneCompound],
|
|
385
|
-
"dropzone",
|
|
386
|
-
parentId
|
|
387
|
-
);
|
|
388
|
-
newZones[zoneCompound] = newContent2;
|
|
389
|
-
}, newZones);
|
|
390
|
-
let rootAsComponent = toComponent({
|
|
391
|
-
props: { ...state.data.root.props ?? state.data.root }
|
|
392
|
-
});
|
|
393
|
-
if (state.data.root.readOnly) {
|
|
394
|
-
rootAsComponent.readOnly = state.data.root.readOnly;
|
|
395
|
-
}
|
|
396
|
-
const processedRoot = processItem(rootAsComponent, [], -1);
|
|
397
|
-
const root = {
|
|
398
|
-
...state.data.root,
|
|
399
|
-
...processedRoot
|
|
400
|
-
};
|
|
401
|
-
return {
|
|
402
|
-
...state,
|
|
403
|
-
data: {
|
|
404
|
-
root,
|
|
405
|
-
content: processedContent,
|
|
406
|
-
zones: {
|
|
407
|
-
...state.data.zones,
|
|
408
|
-
...newZones
|
|
409
|
-
}
|
|
410
|
-
},
|
|
411
|
-
indexes: {
|
|
412
|
-
nodes: { ...state.indexes.nodes, ...newNodeIndex },
|
|
413
|
-
zones: { ...state.indexes.zones, ...newZoneIndex }
|
|
414
|
-
}
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
// lib/data/setup-zone.ts
|
|
419
|
-
var setupZone = (data, zoneKey) => {
|
|
420
|
-
if (zoneKey === rootDroppableId) {
|
|
421
|
-
return data;
|
|
422
|
-
}
|
|
423
|
-
const newData = {
|
|
424
|
-
...data,
|
|
425
|
-
zones: data.zones ? { ...data.zones } : {}
|
|
426
|
-
};
|
|
427
|
-
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
|
428
|
-
return newData;
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
export {
|
|
432
|
-
generateId,
|
|
433
|
-
rootAreaId,
|
|
434
|
-
rootZone,
|
|
435
|
-
rootDroppableId,
|
|
436
|
-
getZoneId,
|
|
437
|
-
defaultSlots,
|
|
438
|
-
walkField,
|
|
439
|
-
mapFields,
|
|
440
|
-
expandNode,
|
|
441
|
-
toComponent,
|
|
442
|
-
walkAppState,
|
|
443
|
-
walkTree,
|
|
444
|
-
setupZone
|
|
445
|
-
};
|