@nascentdigital/funnel-editor 4.5.6 → 4.6.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/hooks/CollectionController.d.ts +1 -1
- package/dist/core/components/ColorModeToggle.js +6 -4
- package/dist/core/components/Header.js +3 -2
- package/dist/core/components/UserEditor.d.ts +2 -2
- package/dist/core/components/feedback/Badge.d.ts +2 -1
- package/dist/core/components/feedback/Badge.js +4 -3
- package/dist/core/components/fields/DynamicPagesEditor.js +7 -6
- package/dist/core/components/fields/EmptyFieldCard.js +4 -4
- package/dist/core/components/fields/FieldCardLayout.js +5 -5
- package/dist/core/components/fields/FieldHeader.js +3 -2
- package/dist/core/components/fields/FieldsPanel.js +4 -4
- package/dist/core/components/fields/FormEditor.js +5 -4
- package/dist/core/components/fields/asset/AssetEditor.d.ts +3 -2
- package/dist/core/components/fields/asset/AssetEditor.js +1 -1
- package/dist/core/components/fields/asset/AssetUploader.d.ts +3 -2
- package/dist/core/components/fields/asset/AssetUploader.js +1 -1
- package/dist/core/components/fields/collection/CollectionCard.js +1 -11
- package/dist/core/components/fields/collection/CollectionPicker.js +3 -2
- package/dist/core/components/fields/collection/previews/index.d.ts +0 -1
- package/dist/core/components/fields/collection/previews/index.js +0 -1
- package/dist/core/components/fields/embed/EmbeddedVideoEditor.d.ts +2 -2
- package/dist/core/components/fields/factories/AssetFactory.d.ts +1 -1
- package/dist/core/components/fields/factories/CollectionFactory.d.ts +1 -1
- package/dist/core/components/fields/factories/EmbeddedVideoFactory.d.ts +2 -2
- package/dist/core/components/fields/factories/FieldValueFactory.d.ts +1 -1
- package/dist/core/components/fields/factories/FieldValueFactory.js +1 -1
- package/dist/core/components/fields/factories/LinkFactory.d.ts +2 -2
- package/dist/core/components/fields/factories/TextFactory.d.ts +2 -2
- package/dist/core/components/fields/form/FormFieldEditor.d.ts +3 -2
- package/dist/core/components/fields/index.d.ts +1 -0
- package/dist/core/components/fields/index.js +1 -0
- package/dist/core/components/fields/link/LinkEditor.d.ts +2 -2
- package/dist/core/components/fields/link/LinkEditor.js +4 -0
- package/dist/core/components/fields/list/CreateFieldButton.d.ts +1 -1
- package/dist/core/components/fields/list/CreateFieldButton.js +4 -5
- package/dist/core/components/fields/list/CreateFieldCard.js +4 -4
- package/dist/core/components/fields/page/PagePicker.js +4 -2
- package/dist/core/components/fields/richtext/FloatingToolbarPlugin.js +3 -2
- package/dist/core/components/fields/richtext/LinkEditor.js +17 -4
- package/dist/core/components/fields/richtext/LinkPopup.js +11 -7
- package/dist/core/components/interaction/AvatarButton.d.ts +2 -1
- package/dist/core/components/interaction/AvatarButton.js +3 -2
- package/dist/core/components/interaction/Button.d.ts +2 -0
- package/dist/core/components/interaction/Button.js +3 -2
- package/dist/core/components/interaction/Combobox.js +2 -2
- package/dist/core/components/interaction/IconButton.d.ts +2 -0
- package/dist/core/components/interaction/IconButton.js +3 -2
- package/dist/core/components/interaction/IconLink.d.ts +1 -1
- package/dist/core/components/interaction/MiniEditor.d.ts +3 -2
- package/dist/core/components/interaction/MiniEditor.js +7 -5
- package/dist/core/components/interaction/Popup.d.ts +20 -15
- package/dist/core/components/interaction/Popup.js +63 -66
- package/dist/core/components/interaction/QuickInput.js +2 -0
- package/dist/core/components/interaction/QuickPicker.d.ts +1 -0
- package/dist/core/components/interaction/QuickPicker.js +5 -5
- package/dist/core/components/interaction/Tabs.d.ts +5 -1
- package/dist/core/components/interaction/Tabs.js +18 -8
- package/dist/core/components/interaction/menu/useMenuController.d.ts +2 -2
- package/dist/core/components/interaction/table/TableItem.d.ts +2 -1
- package/dist/core/components/interaction/table/TableItem.js +5 -3
- package/dist/core/components/layout/InfoPanel.js +4 -2
- package/dist/core/components/visuals/Icon.d.ts +1 -1
- package/dist/core/components/visuals/Icon.js +6 -0
- package/dist/core/components/visuals/index.d.ts +0 -1
- package/dist/core/components/visuals/index.js +0 -1
- package/dist/core/domain/Block.d.ts +4 -0
- package/dist/core/domain/Block.js +7 -0
- package/dist/core/domain/BlockConfiguration.d.ts +11 -3
- package/dist/core/domain/BlockConfiguration.js +77 -14
- package/dist/core/domain/CollectionBrowser.d.ts +2 -2
- package/dist/core/domain/CollectionFieldProxy.d.ts +7 -2
- package/dist/core/domain/CollectionFieldProxy.js +55 -66
- package/dist/core/domain/SectionBlock.d.ts +5 -0
- package/dist/core/domain/SectionBlock.js +15 -0
- package/dist/core/hooks/useBlockConfiguration.d.ts +7 -1
- package/dist/core/hooks/useBlockConfiguration.js +8 -1
- package/dist/core/hooks/usePage.d.ts +2 -2
- package/dist/core/hooks/usePage.js +5 -4
- package/dist/core/repository/CollectionRepository.js +1 -1
- package/dist/core/repository/CollectionSerializer.d.ts +3 -2
- package/dist/core/repository/CollectionSerializer.js +12 -7
- package/dist/core/repository/PageRepository.js +2 -2
- package/dist/core/repository/PageSerializer.d.ts +5 -3
- package/dist/core/repository/PageSerializer.js +10 -11
- package/dist/explore/components/CreateCollectionDialog.d.ts +2 -3
- package/dist/explore/components/CreateCollectionDialog.js +1 -1
- package/dist/explore/components/CreatePageDialog.d.ts +3 -3
- package/dist/explore/components/CreatePageDialog.js +2 -2
- package/dist/explore/screens/CollectionExplorer.js +4 -4
- package/dist/explore/screens/PageExplorer.js +4 -4
- package/dist/page/components/BlockEditor.js +10 -2
- package/dist/page/components/config/BlockConfigButton.d.ts +8 -0
- package/dist/page/components/config/BlockConfigButton.js +320 -0
- package/dist/page/components/config/BlockConfigurationProvider.d.ts +8 -0
- package/dist/page/components/config/BlockConfigurationProvider.js +17 -0
- package/dist/page/components/config/LegacyBlockPreview.d.ts +8 -0
- package/dist/page/components/config/{BlockPreview.js → LegacyBlockPreview.js} +30 -40
- package/dist/page/components/config/index.d.ts +3 -1
- package/dist/page/components/config/index.js +3 -1
- package/dist/page/components/index.d.ts +1 -1
- package/dist/page/components/index.js +1 -1
- package/dist/page/components/nav/NavSection.js +4 -3
- package/dist/page/components/panels/BlockConfigPanel.d.ts +1 -0
- package/dist/page/components/panels/BlockConfigPanel.js +25 -0
- package/dist/page/components/{PageStatus.d.ts → panels/PageStatus.d.ts} +3 -3
- package/dist/page/components/{PageStatus.js → panels/PageStatus.js} +10 -14
- package/dist/page/components/panels/index.d.ts +2 -0
- package/dist/page/components/{status → panels}/index.js +2 -1
- package/dist/page/hooks/PageController.d.ts +2 -2
- package/dist/page/screens/PageEditor.js +8 -1
- package/dist/styles/index.css +174 -56
- package/dist/styles/tailwind.js +7 -3
- package/dist/users/screens/UserExplorer.js +7 -6
- package/package.json +3 -2
- package/dist/core/components/fields/collection/previews/ClientPreview.d.ts +0 -10
- package/dist/core/components/fields/collection/previews/ClientPreview.js +0 -29
- package/dist/core/components/visuals/SkeletonLayout.d.ts +0 -9
- package/dist/core/components/visuals/SkeletonLayout.js +0 -429
- package/dist/page/components/config/BlockConfig.d.ts +0 -8
- package/dist/page/components/config/BlockConfig.js +0 -28
- package/dist/page/components/config/BlockConfigEditor.d.ts +0 -9
- package/dist/page/components/config/BlockConfigEditor.js +0 -114
- package/dist/page/components/config/BlockPreview.d.ts +0 -10
- package/dist/page/components/config/BlockView.d.ts +0 -4
- package/dist/page/components/config/BlockView.js +0 -9
- package/dist/page/components/config/LegacyBlockConfigEditor.d.ts +0 -9
- package/dist/page/components/config/LegacyBlockConfigEditor.js +0 -27
- package/dist/page/components/config/ListPanelEditor.d.ts +0 -8
- package/dist/page/components/config/ListPanelEditor.js +0 -89
- package/dist/page/components/config/MessagePanelEditor.d.ts +0 -8
- package/dist/page/components/config/MessagePanelEditor.js +0 -17
- package/dist/page/components/config/VisualPanelEditor.d.ts +0 -8
- package/dist/page/components/config/VisualPanelEditor.js +0 -76
- package/dist/page/components/status/index.d.ts +0 -1
- /package/dist/page/components/{status → panels}/AutoSave.d.ts +0 -0
- /package/dist/page/components/{status → panels}/AutoSave.js +0 -0
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LegacyBlockConfigEditor = LegacyBlockConfigEditor;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const rxjs_1 = require("rxjs");
|
|
6
|
-
const core_1 = require("../../../core");
|
|
7
|
-
const hooks_1 = require("../../hooks");
|
|
8
|
-
// editor
|
|
9
|
-
function LegacyBlockConfigEditor({ configuration, onClose }) {
|
|
10
|
-
// bind state + hooks
|
|
11
|
-
const pageController = (0, hooks_1.usePageController)();
|
|
12
|
-
const { modified = false, valid = false } = configuration !== null && configuration !== void 0 ? configuration : {};
|
|
13
|
-
// sync w/ configuration
|
|
14
|
-
(0, core_1.useBlockConfiguration)(configuration);
|
|
15
|
-
// helpers
|
|
16
|
-
const onSave = async () => {
|
|
17
|
-
// save config
|
|
18
|
-
configuration === null || configuration === void 0 ? void 0 : configuration.save();
|
|
19
|
-
// wait for page to save
|
|
20
|
-
await (0, rxjs_1.firstValueFrom)(pageController.saved$);
|
|
21
|
-
// complete
|
|
22
|
-
onClose();
|
|
23
|
-
};
|
|
24
|
-
// render
|
|
25
|
-
const { layout } = configuration !== null && configuration !== void 0 ? configuration : {};
|
|
26
|
-
return ((0, jsx_runtime_1.jsx)(core_1.SideSheet, { size: "lg", title: "Block Configuration", backdrop: "glass", open: !!configuration, onSave: onSave, onClose: onClose, disableSave: !modified || !valid, customActions: (0, jsx_runtime_1.jsx)(core_1.Button, { variant: "secondary", size: "sm", disabled: configuration === null || configuration === void 0 ? void 0 : configuration.isConfigInDefault, onClick: () => configuration === null || configuration === void 0 ? void 0 : configuration.reset(), children: "Reset to Default" }), children: (0, jsx_runtime_1.jsxs)("div", { className: "h-full flex flex-col gap-l9 p-l8", children: [(0, jsx_runtime_1.jsxs)("section", { className: "flex flex-wrap justify-center items-start gap-l8", children: [(0, jsx_runtime_1.jsx)(core_1.SkeletonLayout, { variant: "desktop", layout: layout }), (0, jsx_runtime_1.jsx)(core_1.SkeletonLayout, { variant: "mobile", layout: layout })] }), (0, jsx_runtime_1.jsx)("div", { className: "grid grid-cols-[max-content_1fr] auto-rows-auto items-start gap-l6", children: (0, jsx_runtime_1.jsx)(core_1.FieldErrorController, { children: configuration === null || configuration === void 0 ? void 0 : configuration.editableFields.map(field => (0, jsx_runtime_1.jsx)(core_1.FieldEditor, { className: "col-span-2", field: field, variant: "wide" }, field.id)) }) })] }) }));
|
|
27
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { BlockConfiguration, Popup } from '../../../core';
|
|
2
|
-
export declare function ListPanelEditor({ className, anchor, open, onClose, configuration }: ListPanelEditor.Props): import("react/jsx-runtime").JSX.Element;
|
|
3
|
-
export declare namespace ListPanelEditor {
|
|
4
|
-
type Props = Pick<Popup.Props, 'open' | 'onClose' | 'anchor'> & {
|
|
5
|
-
className?: string;
|
|
6
|
-
configuration: BlockConfiguration;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
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.ListPanelEditor = ListPanelEditor;
|
|
18
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
-
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
20
|
-
const classnames_1 = __importDefault(require("classnames"));
|
|
21
|
-
const react_1 = require("react");
|
|
22
|
-
const core_1 = require("../../../core");
|
|
23
|
-
// component
|
|
24
|
-
function ListPanelEditor({ className, anchor, open, onClose, configuration }) {
|
|
25
|
-
// bind props + refs
|
|
26
|
-
const _a = configuration.listFields, { layout: layoutField } = _a, listFields = __rest(_a, ["layout"]);
|
|
27
|
-
const layoutPickerRef = (0, react_1.useRef)(null);
|
|
28
|
-
// helpers
|
|
29
|
-
const onChangeLayout = async (e) => {
|
|
30
|
-
var _a;
|
|
31
|
-
// skip if there's no layout field (shouldn't happen)
|
|
32
|
-
const layoutSchema = layoutField === null || layoutField === void 0 ? void 0 : layoutField.schema;
|
|
33
|
-
if (!layoutField || !layoutSchema) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
// pick new layout
|
|
37
|
-
const { value: layoutData } = layoutField;
|
|
38
|
-
const selectedLayout = await ((_a = layoutPickerRef.current) === null || _a === void 0 ? void 0 : _a.open({
|
|
39
|
-
anchor: e.currentTarget,
|
|
40
|
-
anchorOffset: 4,
|
|
41
|
-
placement: 'top',
|
|
42
|
-
items: Object.entries(layoutSchema.options).map(([layout, option]) => ({
|
|
43
|
-
id: layout,
|
|
44
|
-
label: option.name
|
|
45
|
-
})),
|
|
46
|
-
selectedItem: layoutData === null || layoutData === void 0 ? void 0 : layoutData.value
|
|
47
|
-
}));
|
|
48
|
-
// update if something was picked
|
|
49
|
-
if (selectedLayout) {
|
|
50
|
-
layoutField.value = funnel_core_1.Schema.EnumField.Value.toData(selectedLayout);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
// render
|
|
54
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(core_1.QuickEditor, { className: (0, classnames_1.default)(className), title: "List Configuration", tip: "Lorem ipsum.", anchor: anchor, placement: "left", anchorOffset: 4, viewportPadding: 4, open: open, onClose: onClose, size: "sm", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-l4", children: [(0, jsx_runtime_1.jsx)(core_1.Button, { variant: "secondary", size: "xs", iconLeft: "LayoutTemplate", onClick: onChangeLayout, children: "Change" }), Object.values(listFields)
|
|
55
|
-
.filter(funnel_core_1.Value.isDefined)
|
|
56
|
-
.map(field => (0, jsx_runtime_1.jsx)(core_1.FieldEditor, { field: field, size: "xs" }, field.id))] }) }), (0, jsx_runtime_1.jsx)(core_1.QuickPicker, { ref: layoutPickerRef, variant: "card", title: "Pick List Layout", description: "Select an available layout for this list.", renderItem: (item) => renderListLayoutItem(item) })] }));
|
|
57
|
-
}
|
|
58
|
-
function renderListLayoutItem(item) {
|
|
59
|
-
// panel
|
|
60
|
-
const panel = (className = 'w-full') => ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('bg-surface-placeholder rounded-[3px]', className) }));
|
|
61
|
-
// get content
|
|
62
|
-
const panelClassName = 'w-full h-full';
|
|
63
|
-
const panelPaddedX = 'px-10';
|
|
64
|
-
const panelPaddedY = 'py-10';
|
|
65
|
-
const panelPadded = (0, classnames_1.default)(panelPaddedX, panelPaddedY);
|
|
66
|
-
let content;
|
|
67
|
-
switch (item.id) {
|
|
68
|
-
case 'grid':
|
|
69
|
-
content = ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(panelClassName, panelPadded, 'grid grid-cols-3 auto-cols-fr gap-x-l3 gap-y-l2 '), children: [panel(), panel(), panel(), panel(), panel()] }));
|
|
70
|
-
break;
|
|
71
|
-
case 'verticalStack':
|
|
72
|
-
content = ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(panelClassName, panelPadded, 'grid grid-cols-1 auto-rows-fr gap-y-l2 '), children: [panel(), panel(), panel()] }));
|
|
73
|
-
break;
|
|
74
|
-
case 'horizontalStack':
|
|
75
|
-
content = ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(panelClassName, panelPadded, 'grid grid-rows-1 auto-cols-fr grid-flow-col gap-x-l3 '), children: [panel(), panel(), panel()] }));
|
|
76
|
-
break;
|
|
77
|
-
case 'masonry':
|
|
78
|
-
content = ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(panelClassName, panelPaddedX, 'grid grid-cols-3 grid-flow-col gap-x-l3 pt-10'), children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-l2", children: [panel('h-l5'), panel('h-l6'), panel('h-l5')] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-l2", children: [panel('h-22'), panel('h-l6')] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-l2", children: [panel('h-l4'), panel('h-l7'), panel('h-l5')] })] }));
|
|
79
|
-
break;
|
|
80
|
-
case 'bento':
|
|
81
|
-
content = ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(panelClassName, panelPadded, 'grid auto-rows-auto auto-cols-auto gap-l3'), children: [panel('w-20 row-start-1 row-span-2 col-start-1'), panel('w-28 row-start-1 col-start-2'), panel('w-18 row-start-2 col-start-2')] }));
|
|
82
|
-
break;
|
|
83
|
-
default:
|
|
84
|
-
content = ((0, jsx_runtime_1.jsx)("div", { children: item.id }));
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
// render item in frame
|
|
88
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('w-full h-full flex justify-center items-center'), children: content }));
|
|
89
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { BlockConfiguration, Popup } from '../../../core';
|
|
2
|
-
export declare function MessagePanelEditor({ className, anchor, open, onClose, configuration }: MessagePanelEditor.Props): import("react/jsx-runtime").JSX.Element;
|
|
3
|
-
export declare namespace MessagePanelEditor {
|
|
4
|
-
type Props = Pick<Popup.Props, 'open' | 'onClose' | 'anchor'> & {
|
|
5
|
-
className?: string;
|
|
6
|
-
configuration: BlockConfiguration;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
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 funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
9
|
-
const classnames_1 = __importDefault(require("classnames"));
|
|
10
|
-
const core_1 = require("../../../core");
|
|
11
|
-
// component
|
|
12
|
-
function MessagePanelEditor({ className, anchor, open, onClose, configuration }) {
|
|
13
|
-
// render
|
|
14
|
-
return ((0, jsx_runtime_1.jsx)(core_1.QuickEditor, { className: (0, classnames_1.default)(className), title: "Message Configuration", tip: "Medium and Large are relative to this block's text area, not the page width.", anchor: anchor, placement: "left", anchorOffset: 4, viewportPadding: 4, open: open, onClose: onClose, size: "sm", children: (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col gap-l4", children: Object.values(configuration.messageFields)
|
|
15
|
-
.filter(funnel_core_1.Value.isDefined)
|
|
16
|
-
.map(field => (0, jsx_runtime_1.jsx)(core_1.FieldEditor, { field: field, size: "xs" }, field.id)) }) }));
|
|
17
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { BlockConfiguration, Popup } from '../../../core';
|
|
2
|
-
export declare function VisualPanelEditor({ className, anchor, open, onClose, configuration }: VisualPanelEditor.Props): import("react/jsx-runtime").JSX.Element;
|
|
3
|
-
export declare namespace VisualPanelEditor {
|
|
4
|
-
type Props = Pick<Popup.Props, 'open' | 'onClose' | 'anchor'> & {
|
|
5
|
-
className?: string;
|
|
6
|
-
configuration: BlockConfiguration;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
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
|
-
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
10
|
-
const core_1 = require("../../../core");
|
|
11
|
-
const FieldHeader_1 = require("../../../core/components/fields/FieldHeader");
|
|
12
|
-
const framer_motion_1 = require("framer-motion");
|
|
13
|
-
// component
|
|
14
|
-
function VisualPanelEditor({ className, anchor, open, onClose, configuration }) {
|
|
15
|
-
var _a;
|
|
16
|
-
// get fields
|
|
17
|
-
const { visualFields: { aspect: aspectField, anchor: anchorField, width: widthField, horizontalAlign: horizontalAlignField } } = configuration;
|
|
18
|
-
const { value } = (_a = configuration.getFieldData('visual')) !== null && _a !== void 0 ? _a : {};
|
|
19
|
-
const visual = funnel_core_1.Schema.AssetField.LinkedValue.Visual.filter(value)
|
|
20
|
-
? value
|
|
21
|
-
: undefined;
|
|
22
|
-
// sync config
|
|
23
|
-
(0, core_1.useBlockConfiguration)(configuration);
|
|
24
|
-
// render
|
|
25
|
-
return ((0, jsx_runtime_1.jsx)(core_1.QuickEditor, { className: (0, classnames_1.default)(className), title: "Visual Configuration", tip: "Cropping changes how the image appears on your site, not your original file.", anchor: anchor, placement: "left", anchorOffset: 4, viewportPadding: 4, open: open, onClose: onClose, size: "sm", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-l9", children: [(0, jsx_runtime_1.jsxs)("section", { className: "flex flex-col gap-l4", children: [aspectField &&
|
|
26
|
-
(0, jsx_runtime_1.jsx)(core_1.FieldEditor, { field: aspectField, size: "xs" }), anchorField
|
|
27
|
-
? (0, jsx_runtime_1.jsx)(core_1.FieldEditor, { field: anchorField, size: "xs" })
|
|
28
|
-
:
|
|
29
|
-
(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(FieldHeader_1.FieldHeader, { label: "Anchor", size: "xs" }), (0, jsx_runtime_1.jsx)("p", { className: "label-xs text-content-secondary text-pretty", children: "Your current image size and aspect ratio don't require and anchor (there's no cropping)." })] })] }), visual && renderVisual({
|
|
30
|
-
configuration,
|
|
31
|
-
visual,
|
|
32
|
-
aspectField: aspectField,
|
|
33
|
-
anchorField: anchorField
|
|
34
|
-
})] }) }));
|
|
35
|
-
}
|
|
36
|
-
function renderVisual({ configuration, visual, aspectField, anchorField }) {
|
|
37
|
-
var _a, _b, _c;
|
|
38
|
-
// determine layout info
|
|
39
|
-
const { metadata, name, description } = visual;
|
|
40
|
-
const { dimensions: { width, height } } = metadata;
|
|
41
|
-
const isPortrait = width < height;
|
|
42
|
-
const aspect = (_b = (_a = aspectField === null || aspectField === void 0 ? void 0 : aspectField.value) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 'auto';
|
|
43
|
-
const anchor = (_c = anchorField === null || anchorField === void 0 ? void 0 : anchorField.value) === null || _c === void 0 ? void 0 : _c.value;
|
|
44
|
-
const anchorDirection = anchorField
|
|
45
|
-
? anchorField.schema.isValidOption('left')
|
|
46
|
-
? 'x'
|
|
47
|
-
: 'y'
|
|
48
|
-
: undefined;
|
|
49
|
-
// render
|
|
50
|
-
return ((0, jsx_runtime_1.jsx)("section", { className: (0, classnames_1.default)('w-full h-[210px]', 'flex flex-col justify-center items-center', 'bg-background rounded-xs'), children: (0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)('relative bg-destructive', {
|
|
51
|
-
'h-full max-h-full w-auto': isPortrait,
|
|
52
|
-
'w-full': !isPortrait
|
|
53
|
-
}), children: [funnel_core_1.Schema.AssetField.LinkedValue.Image.filter(visual)
|
|
54
|
-
? renderImage({ configuration, visual })
|
|
55
|
-
: renderVideo({ configuration, visual }), aspect !== 'auto' && anchor && anchorDirection &&
|
|
56
|
-
(0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('absolute inset-0 z-supersurface flex', {
|
|
57
|
-
'flex-col': anchorDirection === 'y'
|
|
58
|
-
}), children: (0, jsx_runtime_1.jsxs)(framer_motion_1.AnimatePresence, { mode: "popLayout", children: [anchor !== 'left' && anchor !== 'top' &&
|
|
59
|
-
(0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { className: "flex-1 bg-content-button-contrast/backdrop", layout: true, variants: core_1.Animate.Variants.fade, initial: "initial", animate: "animate", exit: "exit" }, "crop.start"), (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { className: (0, classnames_1.default)('shrink-0 outline outline-1 outline-ix-primary', {
|
|
60
|
-
'h-full w-auto': anchorDirection === 'x',
|
|
61
|
-
'w-full h-auto': anchorDirection === 'y',
|
|
62
|
-
'aspect-square': aspect === 'square',
|
|
63
|
-
'aspect-phone': aspect === 'phone',
|
|
64
|
-
'aspect-tv': aspect === 'tv',
|
|
65
|
-
'aspect-widescreen': aspect === 'widescreen',
|
|
66
|
-
'aspect-cinema': aspect === 'cinema'
|
|
67
|
-
}), layout: true }, "visible"), anchor !== 'right' && anchor !== 'bottom' &&
|
|
68
|
-
(0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { className: "flex-1 bg-content-button-contrast/backdrop", layout: true, variants: core_1.Animate.Variants.fade, initial: "initial", animate: "animate", exit: "exit" }, "crop.end")] }) })] }) }));
|
|
69
|
-
}
|
|
70
|
-
function renderImage({ visual }) {
|
|
71
|
-
var _a;
|
|
72
|
-
return ((0, jsx_runtime_1.jsx)("img", { className: "max-w-full max-h-full", src: visual.url, alt: (_a = visual.description) !== null && _a !== void 0 ? _a : visual.name }));
|
|
73
|
-
}
|
|
74
|
-
function renderVideo({ visual }) {
|
|
75
|
-
return ((0, jsx_runtime_1.jsx)("video", { className: "max-w-full max-h-full", src: visual.url, autoPlay: true, muted: true, loop: true, playsInline: true }));
|
|
76
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './AutoSave';
|
|
File without changes
|
|
File without changes
|