@nascentdigital/funnel-editor 6.1.7 → 7.0.0
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/collection/components/CollectionHeader.js +17 -3
- package/dist/core/components/fields/EnumField.js +3 -1
- package/dist/core/components/fields/FieldHeader.js +16 -23
- package/dist/core/components/fields/FieldLayout.d.ts +1 -1
- package/dist/core/components/fields/FieldLayout.js +10 -18
- package/dist/core/components/fields/collection/CollectionEditor.js +7 -7
- package/dist/core/components/index.d.ts +1 -0
- package/dist/core/components/index.js +1 -0
- package/dist/core/components/interaction/Combobox.js +17 -28
- package/dist/core/components/interaction/Popup.js +14 -2
- package/dist/core/components/interaction/QuickPicker.js +0 -1
- package/dist/core/components/panels/MessagePanel.d.ts +7 -0
- package/dist/core/components/panels/MessagePanel.js +53 -0
- package/dist/core/components/panels/index.d.ts +2 -0
- package/dist/core/components/panels/index.js +18 -0
- package/dist/core/components/panels/visual/MediaEditor.d.ts +12 -0
- package/dist/core/components/panels/visual/MediaEditor.js +47 -0
- package/dist/core/components/panels/visual/VisualPanel.d.ts +7 -0
- package/dist/core/components/panels/visual/VisualPanel.js +332 -0
- package/dist/core/components/panels/visual/index.d.ts +1 -0
- package/dist/core/components/panels/visual/index.js +17 -0
- package/dist/core/components/visuals/Icon.d.ts +1 -1
- package/dist/core/components/visuals/Icon.js +12 -0
- package/dist/core/domain/Block.d.ts +18 -8
- package/dist/core/domain/Block.js +101 -78
- package/dist/core/domain/BlockConfiguration.d.ts +38 -32
- package/dist/core/domain/BlockConfiguration.js +348 -255
- package/dist/core/domain/CollectionFieldProxy.d.ts +1 -0
- package/dist/core/domain/CollectionFieldProxy.js +5 -0
- package/dist/core/domain/CollectionSummary.d.ts +1 -1
- package/dist/core/domain/CollectionSummary.js +1 -1
- package/dist/core/domain/Collections.d.ts +2 -0
- package/dist/core/domain/Collections.js +6 -0
- package/dist/core/domain/IPage.d.ts +3 -2
- package/dist/core/domain/Item.d.ts +1 -1
- package/dist/core/domain/ItemBase.d.ts +2 -0
- package/dist/core/domain/ItemBase.js +9 -0
- package/dist/core/domain/Page.d.ts +1 -1
- package/dist/core/domain/SectionBlock.d.ts +4 -5
- package/dist/core/domain/SectionBlock.js +3 -10
- package/dist/core/hooks/useBlockConfiguration.d.ts +1 -7
- package/dist/core/hooks/useBlockConfiguration.js +1 -6
- package/dist/core/repository/PageSerializer.js +11 -10
- package/dist/core/repository/SerializeCollectionUpdate.js +4 -4
- package/dist/core/repository/SerializePageUpdate.d.ts +2 -1
- package/dist/core/repository/SerializePageUpdate.js +79 -24
- package/dist/page/components/BlockEditor.js +3 -3
- package/dist/page/components/config/BlockConfigButton.d.ts +3 -1
- package/dist/page/components/config/BlockConfigButton.js +12 -24
- package/dist/page/components/config/BlockPreview.d.ts +7 -6
- package/dist/page/components/config/BlockPreview.js +30 -15
- package/dist/page/components/config/index.d.ts +1 -2
- package/dist/page/components/config/index.js +1 -2
- package/dist/page/components/config/preview/ColumnLayout.d.ts +7 -4
- package/dist/page/components/config/preview/ColumnLayout.js +14 -2
- package/dist/page/components/config/preview/ItemLayout.d.ts +7 -4
- package/dist/page/components/config/preview/ItemLayout.js +24 -11
- package/dist/page/components/config/preview/ListPanel.d.ts +7 -4
- package/dist/page/components/config/preview/ListPanel.js +4 -2
- package/dist/page/components/config/preview/MessagePanel.d.ts +7 -4
- package/dist/page/components/config/preview/MessagePanel.js +6 -3
- package/dist/page/components/config/preview/Panel.d.ts +14 -4
- package/dist/page/components/config/preview/Panel.js +25 -7
- package/dist/page/components/config/preview/PreviewSize.d.ts +1 -0
- package/dist/page/components/config/preview/PreviewSize.js +2 -0
- package/dist/page/components/config/preview/RowLayout.d.ts +7 -4
- package/dist/page/components/config/preview/RowLayout.js +15 -3
- package/dist/page/components/config/preview/StackLayout.d.ts +7 -4
- package/dist/page/components/config/preview/StackLayout.js +14 -2
- package/dist/page/components/config/preview/VisualPanel.d.ts +7 -4
- package/dist/page/components/config/preview/VisualPanel.js +7 -5
- package/dist/page/components/config/preview/index.d.ts +2 -0
- package/dist/page/components/config/preview/index.js +2 -0
- package/dist/page/components/panels/BlockConfigPanel.d.ts +7 -1
- package/dist/page/components/panels/BlockConfigPanel.js +9 -7
- package/dist/page/screens/PageEditor.js +3 -4
- package/dist/styles/index.css +74 -56
- package/package.json +2 -2
- package/dist/page/components/config/BlockConfigurationProvider.d.ts +0 -16
- package/dist/page/components/config/BlockConfigurationProvider.js +0 -25
- package/dist/page/components/config/useBlockConfiguration$.d.ts +0 -3
- package/dist/page/components/config/useBlockConfiguration$.js +0 -22
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.VisualPanel = VisualPanel;
|
|
18
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
20
|
+
const funnel_ui_1 = require("@nascentdigital/funnel-ui");
|
|
21
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
22
|
+
const react_1 = require("react");
|
|
23
|
+
const domain_1 = require("../../../domain");
|
|
24
|
+
const hooks_1 = require("../../../hooks");
|
|
25
|
+
const feedback_1 = require("../../feedback");
|
|
26
|
+
const asset_1 = require("../../fields/asset");
|
|
27
|
+
const embed_1 = require("../../fields/embed");
|
|
28
|
+
const interaction_1 = require("../../interaction");
|
|
29
|
+
const visuals_1 = require("../../visuals");
|
|
30
|
+
const MediaEditor_1 = require("./MediaEditor");
|
|
31
|
+
// component
|
|
32
|
+
function VisualPanel({ fields }) {
|
|
33
|
+
// bind refs + state
|
|
34
|
+
const menu = (0, interaction_1.useMenuController)(menuOptions);
|
|
35
|
+
const addMediaMenu = (0, interaction_1.useMenuController)(addMediaMenuOptions);
|
|
36
|
+
const assetPickerRef = (0, react_1.useRef)(null);
|
|
37
|
+
const assetUploaderRef = (0, react_1.useRef)(null);
|
|
38
|
+
const embeddedVideoEditorRef = (0, react_1.useRef)(null);
|
|
39
|
+
const dialog = (0, feedback_1.useDialog)();
|
|
40
|
+
const addAnchorId = (0, react_1.useId)();
|
|
41
|
+
const menuAnchorId = (0, react_1.useId)();
|
|
42
|
+
const [fieldProxy, setFieldProxy] = (0, react_1.useState)();
|
|
43
|
+
const collectionRepository = (0, hooks_1.useCollectionRepository)();
|
|
44
|
+
const page = (0, hooks_1.usePage)();
|
|
45
|
+
const open = !!fieldProxy;
|
|
46
|
+
const valid = fieldProxy === null || fieldProxy === void 0 ? void 0 : fieldProxy.valid;
|
|
47
|
+
// try to find the visual field
|
|
48
|
+
const field = (0, react_1.useMemo)(() => {
|
|
49
|
+
// find visual field and verify schema
|
|
50
|
+
const mediaField = fields.find(field => field.id === 'visual');
|
|
51
|
+
if (mediaField && funnel_ui_1.Media.Schema.filter(mediaField.schema)) {
|
|
52
|
+
return mediaField;
|
|
53
|
+
}
|
|
54
|
+
// otherwise throw
|
|
55
|
+
else {
|
|
56
|
+
throw new funnel_core_1.IllegalStateError(`No valid visual fields`);
|
|
57
|
+
}
|
|
58
|
+
}, [fields]);
|
|
59
|
+
// setup proxy if there is a value
|
|
60
|
+
(0, react_1.useEffect)(() => {
|
|
61
|
+
// bail if there is no value
|
|
62
|
+
if (field.value === undefined) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
// create proxy using existing field value
|
|
66
|
+
const value = field.value.value;
|
|
67
|
+
domain_1.CollectionFieldProxy
|
|
68
|
+
.create({
|
|
69
|
+
collectionRepository,
|
|
70
|
+
collectionStore: page,
|
|
71
|
+
assetStore: page,
|
|
72
|
+
language: page.language,
|
|
73
|
+
initialValue: value,
|
|
74
|
+
schema: field.schema,
|
|
75
|
+
collectionSchema: funnel_ui_1.Media.Value.isImage(value)
|
|
76
|
+
? funnel_ui_1.Media.Image.collection
|
|
77
|
+
: funnel_ui_1.Media.Video.collection
|
|
78
|
+
}).then(field => setFieldProxy(field));
|
|
79
|
+
}, [collectionRepository, page, field]);
|
|
80
|
+
// auto save
|
|
81
|
+
(0, react_1.useEffect)(() => {
|
|
82
|
+
// bail if no field
|
|
83
|
+
if (!fieldProxy) {
|
|
84
|
+
console.debug('[VisualPanel] auto save setup bailed, field not ready');
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
// subscribe to field changes
|
|
88
|
+
const subscription = fieldProxy.fieldChanged$.subscribe(() => {
|
|
89
|
+
field.value = funnel_core_1.Schema.CollectionField.Value.ForInline.toData(fieldProxy.getInlineData());
|
|
90
|
+
});
|
|
91
|
+
// unmount
|
|
92
|
+
return () => subscription.unsubscribe();
|
|
93
|
+
}, [fieldProxy, field]);
|
|
94
|
+
// helper
|
|
95
|
+
const onMenuSelect = async (option) => {
|
|
96
|
+
switch (option) {
|
|
97
|
+
case 'delete': {
|
|
98
|
+
// confirm delete
|
|
99
|
+
const confirmed = await dialog.confirm({
|
|
100
|
+
title: 'Delete visual',
|
|
101
|
+
message: 'Are you really sure that you want to delete this visual?',
|
|
102
|
+
confirmLabel: 'Delete it',
|
|
103
|
+
destructive: true
|
|
104
|
+
});
|
|
105
|
+
if (!confirmed) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
// delete
|
|
109
|
+
field.value = undefined;
|
|
110
|
+
setFieldProxy(undefined);
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const onAddMediaMenuSelect = async (option) => {
|
|
116
|
+
var _a, _b, _c;
|
|
117
|
+
// process based on option
|
|
118
|
+
const args = {
|
|
119
|
+
assetUploader: (_a = assetUploaderRef.current) !== null && _a !== void 0 ? _a : undefined,
|
|
120
|
+
assetPicker: (_b = assetPickerRef.current) !== null && _b !== void 0 ? _b : undefined,
|
|
121
|
+
embeddedVideoEditor: (_c = embeddedVideoEditorRef.current) !== null && _c !== void 0 ? _c : undefined
|
|
122
|
+
};
|
|
123
|
+
const baseProxyArgs = {
|
|
124
|
+
collectionRepository,
|
|
125
|
+
collectionStore: page,
|
|
126
|
+
assetStore: page,
|
|
127
|
+
language: page.language
|
|
128
|
+
};
|
|
129
|
+
switch (option) {
|
|
130
|
+
case 'pick.asset':
|
|
131
|
+
case 'add.asset': {
|
|
132
|
+
// get visual (or cancel)
|
|
133
|
+
const asset = option === 'pick.asset'
|
|
134
|
+
? await pickAsset(args)
|
|
135
|
+
: await uploadAsset(args);
|
|
136
|
+
if (!asset) {
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
// image
|
|
140
|
+
if (funnel_core_1.Schema.AssetField.LinkedValue.Image.filter(asset)) {
|
|
141
|
+
const proxy = await createImageProxy(Object.assign(Object.assign({}, baseProxyArgs), { image: asset }));
|
|
142
|
+
setFieldProxy(proxy);
|
|
143
|
+
field.value = funnel_core_1.Schema.CollectionField.Value.ForInline.toData(proxy.getInlineData());
|
|
144
|
+
}
|
|
145
|
+
// local video
|
|
146
|
+
else {
|
|
147
|
+
const collection = await createVideoProxy(Object.assign(Object.assign({}, baseProxyArgs), { video: asset, type: 'local' }));
|
|
148
|
+
setFieldProxy(collection);
|
|
149
|
+
field.value = funnel_core_1.Schema.CollectionField.Value.ForInline.toData(collection.getInlineData());
|
|
150
|
+
}
|
|
151
|
+
// stop processing
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
case 'add.url': {
|
|
155
|
+
// link video (or cancel)
|
|
156
|
+
const video = await linkVideo(args);
|
|
157
|
+
if (!video) {
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
const collection = await createVideoProxy(Object.assign(Object.assign({}, baseProxyArgs), { video, type: 'remote' }));
|
|
161
|
+
setFieldProxy(collection);
|
|
162
|
+
field.value = funnel_core_1.Schema.CollectionField.Value.ForInline.toData(collection.getInlineData());
|
|
163
|
+
// stop processing
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
// render
|
|
169
|
+
const mediaType = determineMediaType(field);
|
|
170
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)('bg-surface1 rounded-sm', {
|
|
171
|
+
'border border-dashed border-border-l1': !open,
|
|
172
|
+
'border border-border-l1 focus-within:border-ix-primary': open && valid,
|
|
173
|
+
'border border-destructive': open && !valid
|
|
174
|
+
}), children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-row items-center gap-l5 px-l6 py-l5", children: [(0, jsx_runtime_1.jsx)("span", { className: (0, classnames_1.default)('w-32 h-32 inline-flex justify-center items-center rounded-full', 'bg-surface2 rounded-sm'), children: (0, jsx_runtime_1.jsx)(visuals_1.Icon, { className: "text-content-primary", variant: iconVariantForMediaType(mediaType), size: "sm" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col flex-grow", children: [(0, jsx_runtime_1.jsx)("h3", { className: "heading-sm", children: titleForMediaType(mediaType) }), !open &&
|
|
175
|
+
(0, jsx_runtime_1.jsx)("span", { className: "body-sm text-content-tertiary", children: "Image or video" })] }), open
|
|
176
|
+
? (0, jsx_runtime_1.jsx)(interaction_1.IconButton, { anchorId: menuAnchorId, icon: "EllipsisVertical", onClick: () => menu.open(menuAnchorId) })
|
|
177
|
+
: (0, jsx_runtime_1.jsx)(interaction_1.Button, { anchorId: addAnchorId, iconLeft: "Plus", size: "sm", variant: "secondary", onClick: () => addMediaMenu.open(addAnchorId), children: "Add Visual" })] }), fieldProxy &&
|
|
178
|
+
(0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('flex flex-row gap-l8 p-l8', 'border-t border-border-l1'), children: (0, jsx_runtime_1.jsx)(MediaEditor_1.MediaEditor, { field: fieldProxy }) }), (0, jsx_runtime_1.jsx)(interaction_1.Menu, { controller: menu, onItemClick: onMenuSelect }), (0, jsx_runtime_1.jsx)(interaction_1.Menu, { controller: addMediaMenu, onItemClick: onAddMediaMenuSelect }), (0, jsx_runtime_1.jsx)(asset_1.AssetUploader, { ref: assetUploaderRef }), (0, jsx_runtime_1.jsx)(asset_1.AssetPicker, { ref: assetPickerRef }), (0, jsx_runtime_1.jsx)(embed_1.EmbeddedVideoEditor, { ref: embeddedVideoEditorRef, language: page.language })] }));
|
|
179
|
+
}
|
|
180
|
+
const menuOptions = [
|
|
181
|
+
{
|
|
182
|
+
id: 'delete',
|
|
183
|
+
label: 'Remove',
|
|
184
|
+
icon: 'Trash',
|
|
185
|
+
destructive: true
|
|
186
|
+
}
|
|
187
|
+
];
|
|
188
|
+
const addMediaMenuOptions = [
|
|
189
|
+
{
|
|
190
|
+
id: 'pick.asset',
|
|
191
|
+
label: 'Select from library',
|
|
192
|
+
icon: 'Image'
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
id: 'add.asset',
|
|
196
|
+
label: 'Upload asset',
|
|
197
|
+
icon: 'Upload'
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
id: 'add.url',
|
|
201
|
+
label: 'Add video link',
|
|
202
|
+
icon: 'Link'
|
|
203
|
+
}
|
|
204
|
+
];
|
|
205
|
+
const mediaAssetSchema = funnel_core_1.Schema.Field.visual({ name: 'Image or Video' });
|
|
206
|
+
async function uploadAsset(args) {
|
|
207
|
+
// launch uploader (or skip if there's no result)
|
|
208
|
+
const { assetUploader, popupProps = {} } = args;
|
|
209
|
+
const result = await (assetUploader === null || assetUploader === void 0 ? void 0 : assetUploader.upload(Object.assign({ schema: mediaAssetSchema }, popupProps)));
|
|
210
|
+
if (!result) {
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
// or switch to picking
|
|
214
|
+
else if (result === 'pick') {
|
|
215
|
+
return pickAsset(args);
|
|
216
|
+
}
|
|
217
|
+
// create new image media
|
|
218
|
+
const { value: asset } = result;
|
|
219
|
+
if (funnel_core_1.Schema.AssetField.LinkedValue.Image.filter(asset)) {
|
|
220
|
+
console.debug('[MediaFactory] creating new image media');
|
|
221
|
+
return asset;
|
|
222
|
+
}
|
|
223
|
+
// or create new video media
|
|
224
|
+
else if (funnel_core_1.Schema.AssetField.LinkedValue.Video.filter(asset)) {
|
|
225
|
+
console.debug('[MediaFactory] creating new video media');
|
|
226
|
+
return asset;
|
|
227
|
+
}
|
|
228
|
+
// or abort
|
|
229
|
+
else {
|
|
230
|
+
return undefined;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
async function pickAsset(args) {
|
|
234
|
+
// launch picker (or cancel if nothing is selected)
|
|
235
|
+
const { assetPicker, popupProps = {} } = args;
|
|
236
|
+
const result = await (assetPicker === null || assetPicker === void 0 ? void 0 : assetPicker.pick(Object.assign({ schema: mediaAssetSchema }, popupProps)));
|
|
237
|
+
if (!result) {
|
|
238
|
+
return undefined;
|
|
239
|
+
}
|
|
240
|
+
// or launch uploader if the directive was received
|
|
241
|
+
else if (result === 'upload') {
|
|
242
|
+
return uploadAsset(args);
|
|
243
|
+
}
|
|
244
|
+
// create new image media
|
|
245
|
+
const { value: asset } = result;
|
|
246
|
+
if (funnel_core_1.Schema.AssetField.LinkedValue.Image.filter(asset)) {
|
|
247
|
+
console.debug('[MediaFactory] creating new image media');
|
|
248
|
+
return asset;
|
|
249
|
+
}
|
|
250
|
+
// or create new video media
|
|
251
|
+
else if (funnel_core_1.Schema.AssetField.LinkedValue.Video.filter(asset)) {
|
|
252
|
+
console.debug('[MediaFactory] creating new video media');
|
|
253
|
+
return asset;
|
|
254
|
+
}
|
|
255
|
+
// or abort
|
|
256
|
+
else {
|
|
257
|
+
return undefined;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
async function linkVideo({ embeddedVideoEditor, popupProps = {} }) {
|
|
261
|
+
var _a;
|
|
262
|
+
// start editor (cancel if dismissed)
|
|
263
|
+
const value = await (embeddedVideoEditor === null || embeddedVideoEditor === void 0 ? void 0 : embeddedVideoEditor.edit(Object.assign({ schema: funnel_ui_1.Media.Video.Source.schema.content.remote.schema }, popupProps)));
|
|
264
|
+
return (_a = value === null || value === void 0 ? void 0 : value.value) !== null && _a !== void 0 ? _a : undefined;
|
|
265
|
+
}
|
|
266
|
+
async function createImageProxy(_a) {
|
|
267
|
+
var { image } = _a, args = __rest(_a, ["image"]);
|
|
268
|
+
// create proxy
|
|
269
|
+
const collection = await domain_1.CollectionFieldProxy.create(Object.assign(Object.assign({}, args), { schema: funnel_ui_1.Media.schema, collectionSchema: funnel_ui_1.Media.Image.collection }));
|
|
270
|
+
// set fields
|
|
271
|
+
const imageField = collection.getField('image');
|
|
272
|
+
imageField.value = funnel_core_1.Schema.AssetField.Value.toData(image);
|
|
273
|
+
// return
|
|
274
|
+
return collection;
|
|
275
|
+
}
|
|
276
|
+
async function createVideoProxy(_a) {
|
|
277
|
+
var { video, type } = _a, args = __rest(_a, ["video", "type"]);
|
|
278
|
+
// create proxy
|
|
279
|
+
const collection = await domain_1.CollectionFieldProxy.create(Object.assign(Object.assign({}, args), { schema: funnel_ui_1.Media.schema, collectionSchema: funnel_ui_1.Media.Video.collection }));
|
|
280
|
+
// set fields
|
|
281
|
+
const videoField = collection.getField('video');
|
|
282
|
+
const typeField = videoField.getField('type');
|
|
283
|
+
typeField.value = funnel_core_1.Schema.EnumField.Value.toData(type);
|
|
284
|
+
const localOrRemoteVideoField = videoField.getField(type);
|
|
285
|
+
localOrRemoteVideoField.optIn();
|
|
286
|
+
localOrRemoteVideoField.value = type === 'local'
|
|
287
|
+
? funnel_core_1.Schema.AssetField.Value.toData(video)
|
|
288
|
+
: funnel_core_1.Schema.EmbeddedVideoField.Value.toData(video);
|
|
289
|
+
// return
|
|
290
|
+
return collection;
|
|
291
|
+
}
|
|
292
|
+
function determineMediaType(field) {
|
|
293
|
+
var _a;
|
|
294
|
+
const value = (_a = field.value) === null || _a === void 0 ? void 0 : _a.value;
|
|
295
|
+
if (value === undefined) {
|
|
296
|
+
return 'unknown';
|
|
297
|
+
}
|
|
298
|
+
else if (funnel_ui_1.Media.Value.isImage(value)) {
|
|
299
|
+
return 'image';
|
|
300
|
+
}
|
|
301
|
+
else if (funnel_ui_1.Media.Value.isVideo(value)) {
|
|
302
|
+
return value.fields.video.value.type.value === 'local'
|
|
303
|
+
? 'video.local'
|
|
304
|
+
: 'video.remote';
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
throw new funnel_core_1.IllegalStateError(`field value is not a media value`);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
function iconVariantForMediaType(type) {
|
|
311
|
+
switch (type) {
|
|
312
|
+
case 'unknown':
|
|
313
|
+
return 'File';
|
|
314
|
+
case 'image':
|
|
315
|
+
return 'Image';
|
|
316
|
+
case 'video.local':
|
|
317
|
+
case 'video.remote':
|
|
318
|
+
return 'SquarePlay';
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function titleForMediaType(type) {
|
|
322
|
+
switch (type) {
|
|
323
|
+
case 'unknown':
|
|
324
|
+
return 'Visual';
|
|
325
|
+
case 'image':
|
|
326
|
+
return 'Image';
|
|
327
|
+
case 'video.local':
|
|
328
|
+
return 'Video';
|
|
329
|
+
case 'video.remote':
|
|
330
|
+
return 'Video (streaming)';
|
|
331
|
+
}
|
|
332
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './VisualPanel';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./VisualPanel"), exports);
|
|
@@ -6,7 +6,7 @@ export declare namespace Icon {
|
|
|
6
6
|
size?: Size;
|
|
7
7
|
};
|
|
8
8
|
type Size = 'xl' | 'lg' | 'md' | 'sm' | 'xs' | 'xxs' | 'nav' | 'card' | Sizing;
|
|
9
|
-
type Variant = 'Archive' | 'ArrowDownUp' | 'ArrowLeft' | 'ArrowRight' | 'ArrowLeftRight' | 'Atom' | 'Blocks' | 'Bold' | 'Check' | 'ChevronDown' | 'ChevronRight' | 'ChevronUp' | 'Circle' | 'CircleAlert' | 'CircleCheck' | 'CircleCheckBig' | 'CirclePlus' | 'CircleQuestionMark' | 'CloudCheck' | 'CloudUpload' | 'Copy' | 'CornerDownRight' | 'Cuboid' | 'EllipsisVertical' | 'Eye' | 'EyeOff' | 'File' | 'FileDown' | 'FilePlusCorner' | 'FileSearchCorner' | 'Goal' | 'Globe' | 'GripVertical' | 'HatGlasses' | 'History' | 'Highlighter' | 'Image' | 'ImageDown' | 'Info' | 'Italic' | 'Layers' | 'LayoutTemplate' | 'Link' | 'Link2' | 'List' | 'ListChecks' | 'ListIndentDecrease' | 'ListIndentIncrease' | 'ListOrdered' | 'Lock' | 'LockOpen' | 'Mail' | 'MessageSquareQuote' | 'Minus' | 'Monitor' | 'MonitorCog' | 'Moon' | 'NotebookPen' | 'Pencil' | 'Pin' | 'Plus' | 'Redo' | 'RefreshCw' | 'RotateCcw' | 'RotateCw' | 'Search' | 'SearchCode' | 'Settings' | 'Smartphone' | 'SquarePlay' | 'Star' | 'Strikethrough' | 'Subscript' | 'Sun' | 'Superscript' | 'TextAlignStart' | 'Trash' | 'TriangleAlert' | 'Trophy' | 'Underline' | 'Undo' | 'Upload' | 'UserRound' | 'X';
|
|
9
|
+
type Variant = 'Archive' | 'ArrowDownUp' | 'ArrowLeft' | 'ArrowRight' | 'ArrowLeftRight' | 'Atom' | 'Blocks' | 'Bold' | 'Check' | 'ChevronDown' | 'ChevronRight' | 'ChevronUp' | 'Circle' | 'CircleAlert' | 'CircleCheck' | 'CircleCheckBig' | 'CirclePlus' | 'CircleQuestionMark' | 'CloudCheck' | 'CloudUpload' | 'Copy' | 'CornerDownRight' | 'Cuboid' | 'EllipsisVertical' | 'Eye' | 'EyeOff' | 'File' | 'FileDown' | 'FilePlusCorner' | 'FileSearchCorner' | 'Goal' | 'Globe' | 'GripVertical' | 'HatGlasses' | 'History' | 'Highlighter' | 'Image' | 'ImageDown' | 'Info' | 'Italic' | 'Layers' | 'LayoutTemplate' | 'Link' | 'Link2' | 'List' | 'ListChecks' | 'ListIndentDecrease' | 'ListIndentIncrease' | 'ListOrdered' | 'Lock' | 'LockOpen' | 'Mail' | 'MessageSquareQuote' | 'MessageSquareText' | 'Minus' | 'Monitor' | 'MonitorCog' | 'Moon' | 'NotebookPen' | 'Pencil' | 'Pin' | 'Plus' | 'Redo' | 'RefreshCw' | 'RotateCcw' | 'RotateCw' | 'Search' | 'SearchCode' | 'Settings' | 'Settings2' | 'Smartphone' | 'SquarePlay' | 'Star' | 'Strikethrough' | 'Subscript' | 'Sun' | 'Superscript' | 'Tablet' | 'TextAlignStart' | 'Trash' | 'TriangleAlert' | 'Trophy' | 'Type' | 'Underline' | 'Undo' | 'Upload' | 'UserRound' | 'X';
|
|
10
10
|
namespace Variant {
|
|
11
11
|
function filter(value: any): value is Variant;
|
|
12
12
|
}
|
|
@@ -71,6 +71,7 @@ function Icon({ className, variant, size: sizing = 'md' }) {
|
|
|
71
71
|
'LockOpen',
|
|
72
72
|
'Mail',
|
|
73
73
|
'MessageSquareQuote',
|
|
74
|
+
'MessageSquareText',
|
|
74
75
|
'Minus',
|
|
75
76
|
'Monitor',
|
|
76
77
|
'MonitorCog',
|
|
@@ -86,6 +87,7 @@ function Icon({ className, variant, size: sizing = 'md' }) {
|
|
|
86
87
|
'Search',
|
|
87
88
|
'SearchCode',
|
|
88
89
|
'Settings',
|
|
90
|
+
'Settings2',
|
|
89
91
|
'Smartphone',
|
|
90
92
|
'SquarePlay',
|
|
91
93
|
'Star',
|
|
@@ -93,10 +95,12 @@ function Icon({ className, variant, size: sizing = 'md' }) {
|
|
|
93
95
|
'Subscript',
|
|
94
96
|
'Sun',
|
|
95
97
|
'Superscript',
|
|
98
|
+
'Tablet',
|
|
96
99
|
'TextAlignStart',
|
|
97
100
|
'Trash',
|
|
98
101
|
'TriangleAlert',
|
|
99
102
|
'Trophy',
|
|
103
|
+
'Type',
|
|
100
104
|
'Underline',
|
|
101
105
|
'Undo',
|
|
102
106
|
'Upload',
|
|
@@ -221,6 +225,8 @@ function getIcon(variant) {
|
|
|
221
225
|
return lucide_react_1.Mail;
|
|
222
226
|
case 'MessageSquareQuote':
|
|
223
227
|
return lucide_react_1.MessageSquareQuote;
|
|
228
|
+
case 'MessageSquareText':
|
|
229
|
+
return lucide_react_1.MessageSquareText;
|
|
224
230
|
case 'Minus':
|
|
225
231
|
return lucide_react_1.Minus;
|
|
226
232
|
case 'Monitor':
|
|
@@ -251,6 +257,8 @@ function getIcon(variant) {
|
|
|
251
257
|
return lucide_react_1.SearchCode;
|
|
252
258
|
case 'Settings':
|
|
253
259
|
return lucide_react_1.Settings;
|
|
260
|
+
case 'Settings2':
|
|
261
|
+
return lucide_react_1.Settings2;
|
|
254
262
|
case 'Smartphone':
|
|
255
263
|
return lucide_react_1.Smartphone;
|
|
256
264
|
case 'SquarePlay':
|
|
@@ -265,6 +273,8 @@ function getIcon(variant) {
|
|
|
265
273
|
return lucide_react_1.Sun;
|
|
266
274
|
case 'Superscript':
|
|
267
275
|
return lucide_react_1.Superscript;
|
|
276
|
+
case 'Tablet':
|
|
277
|
+
return lucide_react_1.Tablet;
|
|
268
278
|
case 'TextAlignStart':
|
|
269
279
|
return lucide_react_1.TextAlignStart;
|
|
270
280
|
case 'Trash':
|
|
@@ -273,6 +283,8 @@ function getIcon(variant) {
|
|
|
273
283
|
return lucide_react_1.TriangleAlert;
|
|
274
284
|
case 'Trophy':
|
|
275
285
|
return lucide_react_1.Trophy;
|
|
286
|
+
case 'Type':
|
|
287
|
+
return lucide_react_1.Type;
|
|
276
288
|
case 'Underline':
|
|
277
289
|
return lucide_react_1.Underline;
|
|
278
290
|
case 'Undo':
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import { Field, FieldModel, Schema } from '@nascentdigital/funnel-core';
|
|
1
|
+
import { Field, FieldModel, Logger, Schema } from '@nascentdigital/funnel-core';
|
|
2
2
|
import { StringKeyOf } from 'type-fest';
|
|
3
3
|
import { BlockConfiguration } from './BlockConfiguration';
|
|
4
4
|
import { ItemBase } from './ItemBase';
|
|
5
|
+
import { SectionBlock } from './SectionBlock';
|
|
5
6
|
import ParentContext = ItemBase.ParentContext;
|
|
6
7
|
export declare class Block<TBlock extends Block.SchemaType = Block.SchemaType> extends ItemBase<Block<TBlock>> {
|
|
8
|
+
readonly log: Logger;
|
|
7
9
|
readonly schema: TBlock;
|
|
8
|
-
readonly config: ReadonlyArray<FieldModel.Config>;
|
|
9
10
|
readonly fields: ReadonlyArray<FieldModel>;
|
|
10
|
-
readonly nameField: Field<Schema.TextField>;
|
|
11
11
|
readonly messageFields: ReadonlyArray<FieldModel>;
|
|
12
12
|
readonly visualFields: ReadonlyArray<FieldModel>;
|
|
13
13
|
readonly listsFields: ReadonlyArray<FieldModel>;
|
|
14
14
|
readonly extendedFields: ReadonlyArray<FieldModel>;
|
|
15
|
+
private readonly _configData;
|
|
16
|
+
private _nameField?;
|
|
17
|
+
private _sectionBlock?;
|
|
18
|
+
private _configuration?;
|
|
15
19
|
private _modifiedOn?;
|
|
16
20
|
private _savingOn?;
|
|
17
21
|
constructor(args: Block.ConstructorArgs<TBlock>);
|
|
@@ -19,15 +23,16 @@ export declare class Block<TBlock extends Block.SchemaType = Block.SchemaType> e
|
|
|
19
23
|
get name(): string;
|
|
20
24
|
get state(): "undefined" | "invalid" | "valid";
|
|
21
25
|
get fieldChanged$(): import("rxjs").Observable<Field.Event>;
|
|
26
|
+
get configData(): Partial<Record<Schema.Block.Config.Variant, Block.ConfigVariantData>>;
|
|
27
|
+
get configuration(): BlockConfiguration;
|
|
22
28
|
get value(): Schema.Block.Data;
|
|
23
29
|
get modified(): boolean;
|
|
24
30
|
get changes(): Block.Changes;
|
|
25
31
|
get valid(): boolean;
|
|
26
32
|
get errors(): Block.Errors;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
setConfig(config: ReadonlyArray<FieldModel.Config>): void;
|
|
33
|
+
get sectionBlock(): SectionBlock<Schema.Block<string, any, any>> | undefined;
|
|
34
|
+
get nameField(): Field<Schema.TextField> | undefined;
|
|
35
|
+
protected onBind(parentContext: ParentContext): void;
|
|
31
36
|
getField(fieldId: Block.FieldId<TBlock>): FieldModel;
|
|
32
37
|
getTextField(fieldId: Block.FieldId<TBlock>): Field<Schema.TextField> | undefined;
|
|
33
38
|
repair(): void;
|
|
@@ -43,9 +48,14 @@ export declare namespace Block {
|
|
|
43
48
|
type ConstructorArgs<TBlock extends Schema.Block> = ItemBase.ConstructorArgs & {
|
|
44
49
|
name?: string;
|
|
45
50
|
schema: TBlock;
|
|
46
|
-
|
|
51
|
+
configData: ConfigData;
|
|
47
52
|
fields: ReadonlyArray<FieldModel>;
|
|
48
53
|
};
|
|
54
|
+
type ConfigData = Partial<Record<Schema.Block.Config.Variant, ConfigVariantData>>;
|
|
55
|
+
type ConfigVariantData = {
|
|
56
|
+
config: Schema.Block.Data['config'] | undefined;
|
|
57
|
+
configSnapshot: Schema.Block.Data['config'];
|
|
58
|
+
};
|
|
49
59
|
type ConfigId<TBlock extends Schema.Block> = StringKeyOf<TBlock['config']>;
|
|
50
60
|
type FieldId<TBlock extends Schema.Block> = StringKeyOf<TBlock['fields']>;
|
|
51
61
|
type Changes = {
|