@nascentdigital/funnel-editor 4.4.21 → 4.5.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/core/components/interaction/Animate.d.ts +2 -2
- package/dist/core/components/interaction/Animate.js +12 -10
- package/dist/core/components/interaction/QuickPicker.d.ts +23 -0
- package/dist/core/components/interaction/QuickPicker.js +95 -0
- package/dist/core/components/interaction/Tabs.d.ts +16 -0
- package/dist/core/components/interaction/Tabs.js +24 -0
- package/dist/core/components/interaction/index.d.ts +2 -0
- package/dist/core/components/interaction/index.js +2 -0
- package/dist/core/components/visuals/Icon.d.ts +1 -1
- package/dist/core/components/visuals/Icon.js +3 -0
- package/dist/core/components/visuals/SkeletonLayout.js +226 -33
- package/dist/core/domain/BlockConfiguration.d.ts +7 -1
- package/dist/core/domain/BlockConfiguration.js +27 -1
- package/dist/core/domain/Section.js +1 -1
- package/dist/page/components/BlockEditor.js +3 -3
- package/dist/page/components/{BlockConfig.d.ts → config/BlockConfig.d.ts} +1 -1
- package/dist/page/components/config/BlockConfig.js +43 -0
- package/dist/page/components/config/BlockConfigEditor.d.ts +13 -0
- package/dist/page/components/config/BlockConfigEditor.js +94 -0
- package/dist/page/components/config/BlockPreview.d.ts +8 -0
- package/dist/page/components/config/BlockPreview.js +13 -0
- package/dist/page/components/config/BlockView.d.ts +4 -0
- package/dist/page/components/config/BlockView.js +9 -0
- package/dist/page/components/config/LegacyBlockConfigEditor.d.ts +13 -0
- package/dist/page/components/{BlockConfig.js → config/LegacyBlockConfigEditor.js} +4 -29
- package/dist/page/components/config/ListLayoutPicker.d.ts +6 -0
- package/dist/page/components/config/ListLayoutPicker.js +13 -0
- package/dist/page/components/config/ListPanelEditor.d.ts +6 -0
- package/dist/page/components/config/ListPanelEditor.js +13 -0
- package/dist/page/components/config/MessagePanelEditor.d.ts +6 -0
- package/dist/page/components/config/MessagePanelEditor.js +13 -0
- package/dist/page/components/config/VisualPanelEditor.d.ts +6 -0
- package/dist/page/components/config/VisualPanelEditor.js +13 -0
- package/dist/page/components/config/index.d.ts +1 -0
- package/dist/page/components/config/index.js +17 -0
- package/dist/page/hooks/PageController.js +1 -1
- package/dist/styles/index.css +90 -3
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { BlockLayout, EventBus, FieldModel } from '@nascentdigital/funnel-core';
|
|
1
|
+
import { BlockLayout, EventBus, Field, FieldModel, Schema } from '@nascentdigital/funnel-core';
|
|
2
|
+
import { PanelLayout } from '@nascentdigital/funnel-ui';
|
|
2
3
|
import { Block } from './Block';
|
|
3
4
|
import { IAssetStore } from './IAssetStore';
|
|
4
5
|
import { SectionBlock } from './SectionBlock';
|
|
@@ -15,6 +16,11 @@ export declare class BlockConfiguration {
|
|
|
15
16
|
constructor({ block: blockOrSectionBlock, assetStore }: BlockConfiguration.ConstructorArgs);
|
|
16
17
|
get editableFields(): ReadonlyArray<FieldModel.Config>;
|
|
17
18
|
set editableFields(fields: ReadonlyArray<FieldModel.Config>);
|
|
19
|
+
get desktopFields(): FieldModel.Config[];
|
|
20
|
+
get mobileFields(): FieldModel.Config[];
|
|
21
|
+
get nameField(): FieldModel.Config | undefined;
|
|
22
|
+
get themeField(): FieldModel.Config | undefined;
|
|
23
|
+
get layoutField(): Field<Schema.EnumField<Schema.EnumField.Options<PanelLayout>>> | undefined;
|
|
18
24
|
get layout(): BlockLayout | undefined;
|
|
19
25
|
get events$(): import("rxjs").Observable<EventBus.Event<string, string>>;
|
|
20
26
|
get valid(): boolean;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BlockConfiguration = void 0;
|
|
4
4
|
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
5
|
+
const funnel_ui_1 = require("@nascentdigital/funnel-ui");
|
|
5
6
|
const rxjs_1 = require("rxjs");
|
|
6
7
|
const SectionBlock_1 = require("./SectionBlock");
|
|
7
8
|
// model
|
|
@@ -46,6 +47,31 @@ class BlockConfiguration {
|
|
|
46
47
|
this._editableFields = fields;
|
|
47
48
|
this.raiseEvent('changed');
|
|
48
49
|
}
|
|
50
|
+
get desktopFields() {
|
|
51
|
+
return [
|
|
52
|
+
this.nameField,
|
|
53
|
+
this.themeField,
|
|
54
|
+
this._editableFields.find(field => field.id === 'contentAlign')
|
|
55
|
+
].filter(funnel_core_1.Value.isDefined);
|
|
56
|
+
}
|
|
57
|
+
get mobileFields() {
|
|
58
|
+
return [
|
|
59
|
+
this.nameField,
|
|
60
|
+
this.themeField
|
|
61
|
+
].filter(funnel_core_1.Value.isDefined);
|
|
62
|
+
}
|
|
63
|
+
get nameField() {
|
|
64
|
+
const { block, sectionBlock } = this;
|
|
65
|
+
return sectionBlock
|
|
66
|
+
? this._editableFields.find(field => field.id === block.nameField.id)
|
|
67
|
+
: undefined;
|
|
68
|
+
}
|
|
69
|
+
get themeField() {
|
|
70
|
+
return this._editableFields.find(field => field.id === funnel_ui_1.BlockConfig.Presets.ThemeOnly.key);
|
|
71
|
+
}
|
|
72
|
+
get layoutField() {
|
|
73
|
+
return this._editableFields.find(field => field.id === 'layout');
|
|
74
|
+
}
|
|
49
75
|
get layout() {
|
|
50
76
|
return this._layout;
|
|
51
77
|
}
|
|
@@ -204,7 +230,7 @@ class BlockConfiguration {
|
|
|
204
230
|
});
|
|
205
231
|
// resolve layouts
|
|
206
232
|
this._layout = getLayout
|
|
207
|
-
? getLayout({ config:
|
|
233
|
+
? getLayout({ config: updatedConfig, fields: fieldData })
|
|
208
234
|
: undefined;
|
|
209
235
|
// assign to editable fields (raised event)
|
|
210
236
|
this.editableFields = configFields;
|
|
@@ -88,7 +88,7 @@ class Section extends ItemBase_1.ItemBase {
|
|
|
88
88
|
this._blocks.push(block);
|
|
89
89
|
this._modifiedOn = Date.now();
|
|
90
90
|
// bind block
|
|
91
|
-
block.bind(this);
|
|
91
|
+
block.bind({ parent: this, area: this.area });
|
|
92
92
|
// raise change
|
|
93
93
|
this.raiseEvent('changed');
|
|
94
94
|
// return block
|
|
@@ -7,7 +7,7 @@ exports.BlockEditor = BlockEditor;
|
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const classnames_1 = __importDefault(require("classnames"));
|
|
9
9
|
const core_1 = require("../../core");
|
|
10
|
-
const
|
|
10
|
+
const config_1 = require("./config");
|
|
11
11
|
// component
|
|
12
12
|
function BlockEditor({ className, block, onSelectItem }) {
|
|
13
13
|
// bind props + hooks
|
|
@@ -39,7 +39,7 @@ function BlockEditor({ className, block, onSelectItem }) {
|
|
|
39
39
|
// delete the block
|
|
40
40
|
block.delete();
|
|
41
41
|
// and select the nearest neighbour (if any)
|
|
42
|
-
if (
|
|
42
|
+
if (nearestBlock) {
|
|
43
43
|
onSelectItem(nearestBlock);
|
|
44
44
|
}
|
|
45
45
|
};
|
|
@@ -54,7 +54,7 @@ function BlockEditor({ className, block, onSelectItem }) {
|
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
// render editor
|
|
57
|
-
return ((0, jsx_runtime_1.jsx)(core_1.FieldsPanel, { className: (0, classnames_1.default)(className, 'px-l6 py-l10'), title: block.name, actions: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(
|
|
57
|
+
return ((0, jsx_runtime_1.jsx)(core_1.FieldsPanel, { className: (0, classnames_1.default)(className, 'px-l6 py-l10'), title: block.name, actions: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(config_1.BlockConfig, { className: "shrink-0", block: block }), block.canDelete &&
|
|
58
58
|
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(core_1.IconButton, { className: "DeleteAction text-content-primary hover:text-destructive shrink-0", variant: "util", icon: "EllipsisVertical", onClick: e => menu.open(e.currentTarget) }), (0, jsx_runtime_1.jsx)(core_1.Menu, { controller: menu, onItemClick: onMenuClick })] })] }), fields: block.fields }));
|
|
59
59
|
}
|
|
60
60
|
const blockMenu = [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Block, SectionBlock } from '
|
|
1
|
+
import { Block, SectionBlock } from '../../../core';
|
|
2
2
|
export declare function BlockConfig({ className, block: blockOrSectionBlock }: BlockConfig.Props): import("react/jsx-runtime").JSX.Element | undefined;
|
|
3
3
|
export declare namespace BlockConfig {
|
|
4
4
|
type Props = {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BlockConfig = BlockConfig;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const core_1 = require("../../../core");
|
|
7
|
+
const BlockConfigEditor_1 = require("./BlockConfigEditor");
|
|
8
|
+
const LegacyBlockConfigEditor_1 = require("./LegacyBlockConfigEditor");
|
|
9
|
+
// component
|
|
10
|
+
function BlockConfig({ className, block: blockOrSectionBlock }) {
|
|
11
|
+
// bind ref
|
|
12
|
+
const editorRef = (0, react_1.useRef)(null);
|
|
13
|
+
const legacyEditorRef = (0, react_1.useRef)(null);
|
|
14
|
+
// skip if there's no config
|
|
15
|
+
const block = blockOrSectionBlock instanceof core_1.SectionBlock
|
|
16
|
+
? blockOrSectionBlock.block
|
|
17
|
+
: blockOrSectionBlock;
|
|
18
|
+
const { config } = block;
|
|
19
|
+
if (config.length === 0) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
// helpers
|
|
23
|
+
const onEdit = async (event) => {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
// use new configurator (if enabled)
|
|
26
|
+
if (process.env.NEXT_PUBLIC_EDITOR_BLOCK_CONFIG === 'experimental') {
|
|
27
|
+
await ((_a = editorRef.current) === null || _a === void 0 ? void 0 : _a.edit({
|
|
28
|
+
block: blockOrSectionBlock,
|
|
29
|
+
anchor: event.currentTarget
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
// or use legacy version
|
|
33
|
+
else {
|
|
34
|
+
await ((_b = legacyEditorRef.current) === null || _b === void 0 ? void 0 : _b.edit({
|
|
35
|
+
block: blockOrSectionBlock,
|
|
36
|
+
anchor: event.currentTarget
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
// render
|
|
41
|
+
const valid = config.every(field => field.valid);
|
|
42
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(core_1.StatusChip, { className: className, variant: valid ? 'success' : 'error', onClick: onEdit, children: "Configure" }), (0, jsx_runtime_1.jsx)(BlockConfigEditor_1.BlockConfigEditor, { ref: editorRef }), (0, jsx_runtime_1.jsx)(LegacyBlockConfigEditor_1.LegacyBlockConfigEditor, { ref: legacyEditorRef })] }));
|
|
43
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Rect } from '@nascentdigital/funnel-core';
|
|
2
|
+
import { Block, SectionBlock } from '../../../core';
|
|
3
|
+
export declare const BlockConfigEditor: import("react").ForwardRefExoticComponent<import("react").RefAttributes<BlockConfigEditor.Ref>>;
|
|
4
|
+
export declare namespace BlockConfigEditor {
|
|
5
|
+
type Props = {};
|
|
6
|
+
interface Ref {
|
|
7
|
+
edit(options: Options): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
type Options = {
|
|
10
|
+
block: Block | SectionBlock;
|
|
11
|
+
anchor: HTMLElement | Rect;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BlockConfigEditor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
6
|
+
const client_1 = require("@nascentdigital/funnel-ui/client");
|
|
7
|
+
const react_1 = require("motion/react");
|
|
8
|
+
const react_2 = require("react");
|
|
9
|
+
const rxjs_1 = require("rxjs");
|
|
10
|
+
const core_1 = require("../../../core");
|
|
11
|
+
const hooks_1 = require("../../hooks");
|
|
12
|
+
const BlockPreview_1 = require("./BlockPreview");
|
|
13
|
+
// editor
|
|
14
|
+
exports.BlockConfigEditor = (0, react_2.forwardRef)(function BlockConfigEditor(_, ref) {
|
|
15
|
+
// bind state + hooks
|
|
16
|
+
const [deferral, setDeferral] = (0, react_2.useState)(undefined);
|
|
17
|
+
const [configuration, setConfiguration] = (0, react_2.useState)();
|
|
18
|
+
const [anchor, setAnchor] = (0, react_2.useState)();
|
|
19
|
+
const [blockView, setBlockView] = (0, react_2.useState)('desktop');
|
|
20
|
+
const pageController = (0, hooks_1.usePageController)();
|
|
21
|
+
const touch = (0, client_1.useTouch)();
|
|
22
|
+
const panelLayoutPickerRef = (0, react_2.useRef)(null);
|
|
23
|
+
const { modified = false, valid = false } = configuration !== null && configuration !== void 0 ? configuration : {};
|
|
24
|
+
// sync w/ configuration
|
|
25
|
+
(0, core_1.useBlockConfiguration)(configuration);
|
|
26
|
+
// bind ref
|
|
27
|
+
(0, react_2.useImperativeHandle)(ref, () => ({
|
|
28
|
+
edit: async ({ block, anchor }) => {
|
|
29
|
+
// reset state
|
|
30
|
+
setConfiguration(block.getConfiguration());
|
|
31
|
+
setAnchor(anchor);
|
|
32
|
+
setBlockView('desktop');
|
|
33
|
+
// create deferral
|
|
34
|
+
const deferral = new funnel_core_1.Deferral();
|
|
35
|
+
setDeferral(deferral);
|
|
36
|
+
// wait until deferral is resolved
|
|
37
|
+
return deferral.promise;
|
|
38
|
+
}
|
|
39
|
+
}), []);
|
|
40
|
+
// helpers
|
|
41
|
+
const onSave = async () => {
|
|
42
|
+
// save config
|
|
43
|
+
configuration === null || configuration === void 0 ? void 0 : configuration.save();
|
|
44
|
+
// wait for page to save
|
|
45
|
+
await (0, rxjs_1.firstValueFrom)(pageController.saved$);
|
|
46
|
+
// complete (we're done)
|
|
47
|
+
deferral === null || deferral === void 0 ? void 0 : deferral.resolve();
|
|
48
|
+
// refresh
|
|
49
|
+
touch();
|
|
50
|
+
};
|
|
51
|
+
const onCancel = () => {
|
|
52
|
+
// skip if missing or already completed
|
|
53
|
+
if (!deferral || deferral.isComplete) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
// cancel
|
|
57
|
+
deferral.resolve(undefined);
|
|
58
|
+
// touch
|
|
59
|
+
touch();
|
|
60
|
+
};
|
|
61
|
+
const onChangePanelLayout = async (e) => {
|
|
62
|
+
var _a;
|
|
63
|
+
// skip if there's no layout field (shouldn't happen)
|
|
64
|
+
const { layoutField } = configuration !== null && configuration !== void 0 ? configuration : {};
|
|
65
|
+
if (!layoutField) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
// pick new layout (if ignore if skipped)
|
|
69
|
+
const { schema: layoutSchema, value: layoutData } = layoutField;
|
|
70
|
+
const selectedLayout = await ((_a = panelLayoutPickerRef.current) === null || _a === void 0 ? void 0 : _a.open({
|
|
71
|
+
anchor: e.currentTarget,
|
|
72
|
+
anchorOffset: 4,
|
|
73
|
+
placement: 'top',
|
|
74
|
+
items: Object.entries(layoutSchema.options).map(([layout, option]) => ({
|
|
75
|
+
id: layout,
|
|
76
|
+
label: option.name
|
|
77
|
+
})),
|
|
78
|
+
selectedItem: layoutData === null || layoutData === void 0 ? void 0 : layoutData.value
|
|
79
|
+
}));
|
|
80
|
+
if (!selectedLayout) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
// skip if there's no config
|
|
85
|
+
if (!configuration) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
// render
|
|
89
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(core_1.MiniEditor, { className: "w-[550px] max-w-full", title: "Block Configuration", open: !!deferral && !deferral.isComplete, anchor: anchor, anchorOffset: 4, onSave: onSave, onClose: onCancel, disableSave: !modified || !valid, customActions: (0, jsx_runtime_1.jsx)(core_1.Button, { variant: "secondary", size: "sm", disabled: configuration.isConfigInDefault, onClick: () => configuration.reset(), children: "Reset to Default" }), wide: true, children: [(0, jsx_runtime_1.jsxs)("section", { className: "flex items-center gap-l4", children: [(0, jsx_runtime_1.jsx)("span", { className: "label-sm text-content-primary flex-1", children: "Layout" }), (0, jsx_runtime_1.jsx)(core_1.Button, { variant: "secondary", size: "sm", iconLeft: "ArrowLeftRight", children: "Rearrange" }), (0, jsx_runtime_1.jsx)(core_1.Button, { variant: "secondary", size: "sm", iconLeft: "LayoutTemplate", onClick: onChangePanelLayout, children: "Change" })] }), (0, jsx_runtime_1.jsx)(core_1.Tabs, { items: blockViews, selectedItem: blockView, onSelect: setBlockView }), (0, jsx_runtime_1.jsx)("h4", { className: "heading-sm text-content-primary", children: "Settings" }), (0, jsx_runtime_1.jsx)("section", { className: "stacked p-l10 bg-surface1 rounded-md", children: (0, jsx_runtime_1.jsx)(react_1.AnimatePresence, { children: (0, jsx_runtime_1.jsx)(core_1.Animate, { effect: "fade", present: true, children: (0, jsx_runtime_1.jsx)(BlockPreview_1.BlockPreview, { variant: blockView }) }, blockView) }) }), (0, jsx_runtime_1.jsx)("section", { className: "grid grid-cols-2 auto-rows-auto items-start gap-l6", children: (0, jsx_runtime_1.jsx)(core_1.FieldErrorController, { children: (blockView === 'desktop' ? configuration.desktopFields : configuration.mobileFields).map(field => (0, jsx_runtime_1.jsx)(core_1.FieldEditor, { className: "col-span-2", field: field, variant: "wide" }, field.id)) }) }), (0, jsx_runtime_1.jsx)("hr", { className: "divider border-border-l1" })] }), (0, jsx_runtime_1.jsx)(core_1.QuickPicker, { ref: panelLayoutPickerRef, title: "Pick Block Layout", description: "Select an available layout for this block." })] }));
|
|
90
|
+
});
|
|
91
|
+
const blockViews = [
|
|
92
|
+
{ id: 'desktop', label: 'Desktop' },
|
|
93
|
+
{ id: 'mobile', label: 'Mobile' },
|
|
94
|
+
];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function BlockPreview({ className, variant }: BlockPreview.Props): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare namespace BlockPreview {
|
|
3
|
+
type Variant = 'desktop' | 'mobile';
|
|
4
|
+
type Props = {
|
|
5
|
+
className?: string;
|
|
6
|
+
variant: Variant;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BlockPreview = BlockPreview;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
9
|
+
// component
|
|
10
|
+
function BlockPreview({ className, variant }) {
|
|
11
|
+
// render
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(className, 'w-full flex justify-center items-center text-center'), children: variant === 'desktop' ? 'Desktop' : 'Mobile' }));
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BlockView = void 0;
|
|
4
|
+
// extension
|
|
5
|
+
var BlockView;
|
|
6
|
+
(function (BlockView) {
|
|
7
|
+
// values
|
|
8
|
+
BlockView.values = ['desktop', 'mobile'];
|
|
9
|
+
})(BlockView || (exports.BlockView = BlockView = {}));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Rect } from '@nascentdigital/funnel-core';
|
|
2
|
+
import { Block, SectionBlock } from '../../../core';
|
|
3
|
+
export declare const LegacyBlockConfigEditor: import("react").ForwardRefExoticComponent<import("react").RefAttributes<LegacyBlockConfigEditor.Ref>>;
|
|
4
|
+
export declare namespace LegacyBlockConfigEditor {
|
|
5
|
+
type Props = {};
|
|
6
|
+
interface Ref {
|
|
7
|
+
edit(options: Options): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
type Options = {
|
|
10
|
+
block: Block | SectionBlock;
|
|
11
|
+
anchor: HTMLElement | Rect;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -1,40 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.LegacyBlockConfigEditor = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
6
6
|
const client_1 = require("@nascentdigital/funnel-ui/client");
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const rxjs_1 = require("rxjs");
|
|
9
|
-
const core_1 = require("
|
|
10
|
-
const hooks_1 = require("
|
|
11
|
-
// component
|
|
12
|
-
function BlockConfig({ className, block: blockOrSectionBlock }) {
|
|
13
|
-
// bind ref
|
|
14
|
-
const editorRef = (0, react_1.useRef)(null);
|
|
15
|
-
// skip if there's no config
|
|
16
|
-
const block = blockOrSectionBlock instanceof core_1.SectionBlock
|
|
17
|
-
? blockOrSectionBlock.block
|
|
18
|
-
: blockOrSectionBlock;
|
|
19
|
-
const { config } = block;
|
|
20
|
-
if (config.length === 0) {
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
// helpers
|
|
24
|
-
const onEdit = async (event) => {
|
|
25
|
-
var _a;
|
|
26
|
-
// edit configuration
|
|
27
|
-
await ((_a = editorRef.current) === null || _a === void 0 ? void 0 : _a.edit({
|
|
28
|
-
block: blockOrSectionBlock,
|
|
29
|
-
anchor: event.currentTarget
|
|
30
|
-
}));
|
|
31
|
-
};
|
|
32
|
-
// render
|
|
33
|
-
const valid = config.every(field => field.valid);
|
|
34
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(core_1.StatusChip, { className: className, variant: valid ? 'success' : 'error', onClick: onEdit, children: "Configure" }), (0, jsx_runtime_1.jsx)(BlockConfigEditor, { ref: editorRef })] }));
|
|
35
|
-
}
|
|
9
|
+
const core_1 = require("../../../core");
|
|
10
|
+
const hooks_1 = require("../../hooks");
|
|
36
11
|
// editor
|
|
37
|
-
|
|
12
|
+
exports.LegacyBlockConfigEditor = (0, react_1.forwardRef)(function LegacyBlockConfigEditor(_, ref) {
|
|
38
13
|
// bind state + hooks
|
|
39
14
|
const [deferral, setDeferral] = (0, react_1.useState)(undefined);
|
|
40
15
|
const [configuration, setConfiguration] = (0, react_1.useState)();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ListLayoutPicker = ListLayoutPicker;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
9
|
+
// component
|
|
10
|
+
function ListLayoutPicker({ className }) {
|
|
11
|
+
// render
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(className), children: "ListLayoutPicker" }));
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ListPanelEditor = ListPanelEditor;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
9
|
+
// component
|
|
10
|
+
function ListPanelEditor({ className }) {
|
|
11
|
+
// render
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(className), children: "ListPanelEditor" }));
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MessagePanelEditor = MessagePanelEditor;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
9
|
+
// component
|
|
10
|
+
function MessagePanelEditor({ className }) {
|
|
11
|
+
// render
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(className), children: "MessagePanelEditor" }));
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.VisualPanelEditor = VisualPanelEditor;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
9
|
+
// component
|
|
10
|
+
function VisualPanelEditor({ className }) {
|
|
11
|
+
// render
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(className), children: "MessagePanelEditor" }));
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './BlockConfig';
|
|
@@ -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("./BlockConfig"), exports);
|
|
@@ -146,7 +146,7 @@ class PageController {
|
|
|
146
146
|
});
|
|
147
147
|
// save page immediately if modified (this is a re-entrant call, so we can't await it - trust me)
|
|
148
148
|
if (page.modified) {
|
|
149
|
-
console.
|
|
149
|
+
console.debug('[PageController/setPage] save triggered by page modification', page);
|
|
150
150
|
this.save().catch(console.error);
|
|
151
151
|
}
|
|
152
152
|
}
|