@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
|
@@ -63,11 +63,25 @@ function CollectionHeader({ className, target, onBack }) {
|
|
|
63
63
|
});
|
|
64
64
|
};
|
|
65
65
|
const onDuplicate = async (source, targetLanguage) => {
|
|
66
|
+
// skip if there is no collection group
|
|
67
|
+
if (!collectionGroup) {
|
|
68
|
+
console.warn('[CollectionHeader/onDuplicate] no collection group');
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// skip if there is no collection in group
|
|
72
|
+
const collection = collectionGroup === null || collectionGroup === void 0 ? void 0 : collectionGroup.collections.find(collection => collection.id === source);
|
|
73
|
+
if (!collection) {
|
|
74
|
+
console.warn('[CollectionHeader/onDuplicate] cannot find collection in group', { collectionGroup, source });
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
66
77
|
// duplicate collection
|
|
67
78
|
await editorApi.duplicateCollection({
|
|
68
|
-
source:
|
|
69
|
-
|
|
70
|
-
|
|
79
|
+
source: {
|
|
80
|
+
groupId: collectionGroup.groupId,
|
|
81
|
+
language: collection.language
|
|
82
|
+
},
|
|
83
|
+
operation: 'extend',
|
|
84
|
+
language: targetLanguage
|
|
71
85
|
});
|
|
72
86
|
};
|
|
73
87
|
// render
|
|
@@ -30,7 +30,9 @@ function EnumField({ className, field, variant, size = 'md', disabled, disableDe
|
|
|
30
30
|
throw new funnel_core_1.NotImplementedError('No support for EnumField with "radio" semantics');
|
|
31
31
|
}
|
|
32
32
|
// render
|
|
33
|
-
return ((0, jsx_runtime_1.jsx)(FieldLayout_1.FieldLayout, { className: (0, classnames_1.default)(className,
|
|
33
|
+
return ((0, jsx_runtime_1.jsx)(FieldLayout_1.FieldLayout, { className: (0, classnames_1.default)(className, {
|
|
34
|
+
'w-full': variant !== 'config'
|
|
35
|
+
}), field: field, variant: variant, size: size, disableDelete: disableDelete, children: picker }));
|
|
34
36
|
}
|
|
35
37
|
// helper
|
|
36
38
|
function getComboboxOptions(schema) {
|
|
@@ -48,29 +48,22 @@ function FieldHeader({ className, size = 'md', fieldId, label, tip, embedded = f
|
|
|
48
48
|
}
|
|
49
49
|
}, [fieldActive, focused]);
|
|
50
50
|
// render
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
});
|
|
56
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(className, 'flex items-center text-content-secondary gap-l2', {
|
|
57
|
-
'h-32': size === 'md',
|
|
58
|
-
'h-20': size !== 'md'
|
|
51
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(className, 'nd-FieldHeader', {
|
|
52
|
+
'nd-FieldHeader-md': size === 'md',
|
|
53
|
+
'nd-FieldHeader-sm': size === 'sm',
|
|
54
|
+
'nd-FieldHeader-xs': size === 'xs'
|
|
59
55
|
}), children: [fieldId && !embedded
|
|
60
|
-
? (0, jsx_runtime_1.jsx)("label", { className:
|
|
61
|
-
: (0, jsx_runtime_1.jsx)("span", { className:
|
|
62
|
-
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(interaction_1.Popup.AnchorElement, { tag: "div", anchorId: id, className: (0, classnames_1.default)({
|
|
63
|
-
'
|
|
64
|
-
'
|
|
65
|
-
|
|
66
|
-
'
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
(0, jsx_runtime_1.jsx)(interaction_1.IconButton, { className: (0, classnames_1.default)({
|
|
73
|
-
'opacity-none pointer-events-none interpolate-fast': !active,
|
|
74
|
-
'opacity-full pointer-events-auto interpolate': active
|
|
56
|
+
? (0, jsx_runtime_1.jsx)("label", { className: "nd-FieldHeaderLabel", htmlFor: fieldId, children: label })
|
|
57
|
+
: (0, jsx_runtime_1.jsx)("span", { className: "nd-FieldHeaderLabel", children: embedded ? '' : label }), tip && !embedded &&
|
|
58
|
+
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(interaction_1.Popup.AnchorElement, { tag: "div", anchorId: id, className: (0, classnames_1.default)('nd-FieldHeaderTip', {
|
|
59
|
+
'nd-FieldHeaderTip-md': size === 'md',
|
|
60
|
+
'nd-FieldHeaderTip-sm': size === 'sm',
|
|
61
|
+
'nd-FieldHeaderTip-xs': size === 'xs',
|
|
62
|
+
'nd-FieldHeaderTip-active': !active
|
|
63
|
+
}), onPointerEnter: e => setTipAnchor(id), onPointerLeave: () => setTipAnchor(undefined), children: (0, jsx_runtime_1.jsx)(visuals_1.Icon, { variant: "Info", size: size === 'md' ? 'sm' : 'xs' }) }), (0, jsx_runtime_1.jsx)(interaction_1.Popup, { className: (0, classnames_1.default)('nd-FieldHeaderTip-popup', {
|
|
64
|
+
'nd-FieldHeaderTip-popup-md': size === 'md'
|
|
65
|
+
}), open: !!tipAnchor, anchor: tipAnchor, anchorOffset: 4, placement: "top", disableOverlay: true, onClose: () => setTipAnchor(undefined), children: (0, jsx_runtime_1.jsx)(funnel_ui_1.Markup, { className: "nd-FieldHeaderTip-message", markdown: tip }) })] }), onDelete &&
|
|
66
|
+
(0, jsx_runtime_1.jsx)(interaction_1.IconButton, { className: (0, classnames_1.default)('nd-FieldHeaderDelete', {
|
|
67
|
+
'nd-FieldHeaderDelete-active': active
|
|
75
68
|
}), icon: "X", size: size === 'md' ? 'xs' : 'xxs', disabled: !active, onFocus: () => setFocused(true), onBlur: () => setFocused(false), onClick: () => onDelete() })] }));
|
|
76
69
|
}
|
|
@@ -3,7 +3,7 @@ import { ReactNode } from 'react';
|
|
|
3
3
|
import { FieldSize } from './FieldSize';
|
|
4
4
|
export declare function FieldLayout({ field, className, label: rawLabel, variant, size, disableDelete, onActiveChanged, children }: FieldLayout.Props): import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
export declare namespace FieldLayout {
|
|
6
|
-
type Variant = 'default' | 'wide' | 'minimal';
|
|
6
|
+
type Variant = 'default' | 'wide' | 'config' | 'minimal';
|
|
7
7
|
type Props = {
|
|
8
8
|
field?: Field;
|
|
9
9
|
variant?: Variant;
|
|
@@ -52,23 +52,15 @@ function FieldLayout({ field, className, label: rawLabel, variant = 'default', s
|
|
|
52
52
|
(_a = fieldRef.current) === null || _a === void 0 ? void 0 : _a.optOut();
|
|
53
53
|
};
|
|
54
54
|
// render
|
|
55
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(className, {
|
|
56
|
-
'
|
|
57
|
-
'
|
|
55
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(className, 'nd-FieldLayout', {
|
|
56
|
+
'nd-FieldLayout-default': variant === 'default',
|
|
57
|
+
'nd-FieldLayout-minimal': variant === 'minimal',
|
|
58
|
+
'nd-FieldLayout-config': variant === 'config',
|
|
59
|
+
'nd-FieldLayout-wide': variant === 'wide',
|
|
60
|
+
'nd-FieldLayout-md': size === 'md',
|
|
61
|
+
'nd-FieldLayout-sm': size === 'sm',
|
|
62
|
+
'nd-FieldLayout-xs': size === 'xs'
|
|
58
63
|
}), onPointerEnter: onActive, onPointerLeave: onInactive, children: [!minimal &&
|
|
59
|
-
(0, jsx_runtime_1.jsx)(FieldHeader_1.FieldHeader, { fieldId: field === null || field === void 0 ? void 0 : field.id, size: size, label: label, tip: description, active: active || (field === null || field === void 0 ? void 0 : field.editing) === true, onDelete: canOptOut && !disableDelete ? onOptOut : undefined }), (0, jsx_runtime_1.jsxs)("div", { className:
|
|
60
|
-
|
|
61
|
-
'min-w-[180px]': size !== 'sm',
|
|
62
|
-
'min-w-[120px]': size !== 'xs'
|
|
63
|
-
}), children: [children, !minimal && hasErrors &&
|
|
64
|
-
(0, jsx_runtime_1.jsx)("ul", { className: (0, classnames_1.default)('flex flex-col', {
|
|
65
|
-
'gap-l2 mt-l3': size === 'md',
|
|
66
|
-
'gap-l1 mt-l2': size !== 'md'
|
|
67
|
-
}), "aria-live": "polite", children: errors.map((error, index) => (0, jsx_runtime_1.jsxs)("li", { className: (0, classnames_1.default)('flex items-center text-destructive', {
|
|
68
|
-
'gap-l2': size === 'md',
|
|
69
|
-
'gap-l1': size !== 'md'
|
|
70
|
-
}), children: [(0, jsx_runtime_1.jsx)(visuals_1.Icon, { variant: "TriangleAlert", size: size === 'md' ? 'sm' : 'xxs' }), (0, jsx_runtime_1.jsx)("span", { className: (0, classnames_1.default)('ellipsis', {
|
|
71
|
-
'label-sm': size === 'md',
|
|
72
|
-
'label-xxs': size !== 'md'
|
|
73
|
-
}), children: error.message })] }, `error_${index}`)) })] })] }));
|
|
64
|
+
(0, jsx_runtime_1.jsx)(FieldHeader_1.FieldHeader, { fieldId: field === null || field === void 0 ? void 0 : field.id, size: size, label: label, tip: description, active: active || (field === null || field === void 0 ? void 0 : field.editing) === true, onDelete: canOptOut && !disableDelete ? onOptOut : undefined }), (0, jsx_runtime_1.jsxs)("div", { className: "nd-FieldLayout-content", children: [children, !minimal && hasErrors &&
|
|
65
|
+
(0, jsx_runtime_1.jsx)("ul", { className: "nd-FieldLayout-errors", "aria-live": "polite", children: errors.map((error, index) => (0, jsx_runtime_1.jsxs)("li", { className: "nd-FieldLayout-error", children: [(0, jsx_runtime_1.jsx)(visuals_1.Icon, { variant: "TriangleAlert", size: size === 'md' ? 'sm' : 'xxs' }), (0, jsx_runtime_1.jsx)("span", { className: "nd-FieldLayout-errorLabel", children: error.message })] }, `error_${index}`)) })] })] }));
|
|
74
66
|
}
|
|
@@ -36,9 +36,9 @@ exports.CollectionEditor = (0, react_1.forwardRef)(function CollectionEditor({ l
|
|
|
36
36
|
const [field, setField] = (0, react_1.useState)();
|
|
37
37
|
const [shared, setShared] = (0, react_1.useState)(false);
|
|
38
38
|
const page = (0, hooks_1.usePossiblePage)();
|
|
39
|
-
const collection = (0, hooks_1.usePossibleCollection)();
|
|
40
39
|
const collectionRepository = (0, hooks_1.useCollectionRepository)();
|
|
41
|
-
const collectionStore =
|
|
40
|
+
const collectionStore = (0, hooks_1.useCollectionStore)();
|
|
41
|
+
const assetStore = (0, hooks_1.useAssetStore)();
|
|
42
42
|
const dialog = (0, feedback_1.useDialog)();
|
|
43
43
|
// sync field
|
|
44
44
|
(0, hooks_1.useCollectionFieldProxy)(field);
|
|
@@ -64,25 +64,25 @@ exports.CollectionEditor = (0, react_1.forwardRef)(function CollectionEditor({ l
|
|
|
64
64
|
// create field
|
|
65
65
|
(0, react_1.useEffect)(() => {
|
|
66
66
|
// ignore if schemas aren't set
|
|
67
|
-
if (!schema || !collectionSchema
|
|
67
|
+
if (!schema || !collectionSchema) {
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
70
|
// create new field (wraps existing data for editing)
|
|
71
71
|
domain_1.CollectionFieldProxy
|
|
72
72
|
.create({
|
|
73
|
-
collectionRepository,
|
|
74
|
-
collectionStore,
|
|
75
|
-
assetStore: collectionStore,
|
|
76
73
|
schema,
|
|
77
74
|
collectionSchema,
|
|
78
75
|
language,
|
|
76
|
+
assetStore,
|
|
77
|
+
collectionStore,
|
|
78
|
+
collectionRepository,
|
|
79
79
|
initialValue
|
|
80
80
|
})
|
|
81
81
|
.then(field => {
|
|
82
82
|
setField(field);
|
|
83
83
|
setShared(!field.isNew && field.isRef);
|
|
84
84
|
});
|
|
85
|
-
}, [language,
|
|
85
|
+
}, [schema, collectionSchema, language, assetStore, collectionStore, collectionRepository, initialValue]);
|
|
86
86
|
// skip if not ready
|
|
87
87
|
if (!schema || !collectionSchema || !popupProps) {
|
|
88
88
|
return null;
|
|
@@ -19,6 +19,7 @@ __exportStar(require("./fields"), exports);
|
|
|
19
19
|
__exportStar(require("./interaction"), exports);
|
|
20
20
|
__exportStar(require("./languageDialog"), exports);
|
|
21
21
|
__exportStar(require("./layout"), exports);
|
|
22
|
+
__exportStar(require("./panels"), exports);
|
|
22
23
|
__exportStar(require("./transitions"), exports);
|
|
23
24
|
__exportStar(require("./visuals"), exports);
|
|
24
25
|
__exportStar(require("./AutoSave"), exports);
|
|
@@ -61,14 +61,16 @@ function Combobox({ id: externalId, className, size = 'md', maxRows = 6, rowHeig
|
|
|
61
61
|
setOpen(false);
|
|
62
62
|
};
|
|
63
63
|
// render
|
|
64
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("button", { ref: buttonRef, id: id, className: (0, classnames_1.default)(className, Popup_1.Popup.anchorClassName,
|
|
65
|
-
'
|
|
66
|
-
'
|
|
67
|
-
'
|
|
68
|
-
'
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
'
|
|
64
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("button", { ref: buttonRef, id: id, className: (0, classnames_1.default)(className, 'nd-Combobox', Popup_1.Popup.anchorClassName, {
|
|
65
|
+
'nd-Combobox-md': size === 'md',
|
|
66
|
+
'nd-Combobox-sm': size === 'sm',
|
|
67
|
+
'nd-Combobox-xs': size === 'xs',
|
|
68
|
+
'nd-Combobox-open': open,
|
|
69
|
+
'nd-Combobox-noSelection': !selectedOption
|
|
70
|
+
}), style: Popup_1.Popup.getAnchorStyle(id), type: "button", disabled: disabled, role: "combobox", "aria-expanded": open, "aria-controls": popupId, "aria-owns": popupId, onClick: onOpen, onKeyDown: client_1.OnKey.enter(onOpen), children: [renderSelection(selectedOption), (0, jsx_runtime_1.jsx)(visuals_1.Icon, { className: "nd-Combobox-icon", variant: "ChevronDown", size: size })] }), (0, jsx_runtime_1.jsx)(Popup_1.Popup, { open: open, anchor: id, anchorOffset: 2, placement: "bottom", onClose: onOptionsClose, children: (0, jsx_runtime_1.jsx)("div", { id: popupId, className: (0, classnames_1.default)('nd-Combobox-popup', {
|
|
71
|
+
'nd-Combobox-popup-md': size === 'md',
|
|
72
|
+
'nd-Combobox-popup-sm': size === 'sm',
|
|
73
|
+
'nd-Combobox-popup-xs': size === 'xs'
|
|
72
74
|
}), style: {
|
|
73
75
|
minWidth: button ? `${button.offsetWidth}px` : 'auto',
|
|
74
76
|
maxHeight: maxRows * rowHeight + (rowPaddingY * 2)
|
|
@@ -76,14 +78,10 @@ function Combobox({ id: externalId, className, size = 'md', maxRows = 6, rowHeig
|
|
|
76
78
|
// render
|
|
77
79
|
const optionKey = getOptionId(id, option);
|
|
78
80
|
const selected = option.id === selectedOptionId;
|
|
79
|
-
return ((0, jsx_runtime_1.jsx)("button", { id: optionKey, style: { height: `${rowHeight}px` }, role: "option", "aria-selected": selected, autoFocus: (index === 0 && !selected) || (index === 1 && options[0].id === selectedOptionId), onClick: e => onOptionSelect(e, option), onKeyDown: client_1.OnKey.enter(e => onOptionSelect(e, option)), children: (0, jsx_runtime_1.jsx)("span", { className: (0, classnames_1.default)('
|
|
80
|
-
'
|
|
81
|
-
'
|
|
82
|
-
'
|
|
83
|
-
'text-content-link-highlight': selected,
|
|
84
|
-
'text-content-primary hover:bg-ix-util-hover/tint1 active:bg-ix-util-press/tint2': !selected && !disabled,
|
|
85
|
-
'focus-visible:bg-interactive focus-visible:border-border-l1': !selected && !disabled,
|
|
86
|
-
'text-ix-disabled-content': disabled
|
|
81
|
+
return ((0, jsx_runtime_1.jsx)("button", { id: optionKey, style: { height: `${rowHeight}px` }, role: "option", "aria-selected": selected, autoFocus: (index === 0 && !selected) || (index === 1 && options[0].id === selectedOptionId), onClick: e => onOptionSelect(e, option), onKeyDown: client_1.OnKey.enter(e => onOptionSelect(e, option)), children: (0, jsx_runtime_1.jsx)("span", { className: (0, classnames_1.default)('nd-ComboboxItem', {
|
|
82
|
+
'nd-ComboboxItem-selected': selected,
|
|
83
|
+
'nd-ComboboxItem-disabled': disabled,
|
|
84
|
+
'nd-ComboboxItem-option': !selected && !disabled
|
|
87
85
|
}), children: renderOption({ option, selected, size }) }) }, optionKey));
|
|
88
86
|
}) }) })] }));
|
|
89
87
|
}
|
|
@@ -108,20 +106,11 @@ function getOptionId(comboboxId, option) {
|
|
|
108
106
|
}
|
|
109
107
|
function onRenderSelection({ option, size }, noSelectionText) {
|
|
110
108
|
var _a;
|
|
111
|
-
return ((0, jsx_runtime_1.jsx)("span", { className: (0, classnames_1.default)('
|
|
112
|
-
'
|
|
113
|
-
'label-sm': size === 'sm',
|
|
114
|
-
'label-xs': size === 'xs',
|
|
115
|
-
'text-content-primary': !!option,
|
|
116
|
-
'text-ix-disabled-content': !option
|
|
109
|
+
return ((0, jsx_runtime_1.jsx)("span", { className: (0, classnames_1.default)('nd-Combobox-selection', {
|
|
110
|
+
'nd-Combobox-selection': !!option
|
|
117
111
|
}), children: (_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : noSelectionText }));
|
|
118
112
|
}
|
|
119
113
|
function onRenderOption({ option, selected, size }) {
|
|
120
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className:
|
|
121
|
-
'label-md': size === 'md',
|
|
122
|
-
'label-sm': size === 'sm',
|
|
123
|
-
'label-xs': size === 'xs',
|
|
124
|
-
'label-strong': selected
|
|
125
|
-
}), children: option.label }), selected &&
|
|
114
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: "nd-ComboboxItem-label", children: option.label }), selected &&
|
|
126
115
|
(0, jsx_runtime_1.jsx)(visuals_1.Icon, { variant: "Check", size: size })] }));
|
|
127
116
|
}
|
|
@@ -36,6 +36,8 @@ function Popup(_a) {
|
|
|
36
36
|
const [contentRef, contentElement] = (0, client_1.useRefElement)();
|
|
37
37
|
const openRef = (0, react_1.useRef)(open);
|
|
38
38
|
openRef.current = open;
|
|
39
|
+
const wasOpenedRef = (0, react_1.useRef)(open);
|
|
40
|
+
wasOpenedRef.current = wasOpenedRef.current || open;
|
|
39
41
|
const onOpenedRef = (0, react_1.useRef)(onOpenedRaw);
|
|
40
42
|
onOpenedRef.current = onOpenedRaw;
|
|
41
43
|
const onClosedRef = (0, react_1.useRef)(onClosedRaw);
|
|
@@ -50,6 +52,18 @@ function Popup(_a) {
|
|
|
50
52
|
// unlock on unmount
|
|
51
53
|
return () => unlock && unlock();
|
|
52
54
|
}, [open, containerId]);
|
|
55
|
+
// invoke opened/close callback if required (otherwise we won't get an event)
|
|
56
|
+
(0, react_1.useEffect)(() => {
|
|
57
|
+
if (open && animation === 'out') {
|
|
58
|
+
onOpenedRef.current();
|
|
59
|
+
}
|
|
60
|
+
else if (!open && wasOpenedRef.current) {
|
|
61
|
+
wasOpenedRef.current = false;
|
|
62
|
+
if (animation === 'in') {
|
|
63
|
+
onClosedRef.current();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}, [open, animation]);
|
|
53
67
|
// skip for SSR
|
|
54
68
|
if (!funnel_core_1.Browser.available) {
|
|
55
69
|
return null;
|
|
@@ -59,7 +73,6 @@ function Popup(_a) {
|
|
|
59
73
|
// handle escape
|
|
60
74
|
if (e.key === 'Escape') {
|
|
61
75
|
// stop propagation
|
|
62
|
-
e.preventDefault();
|
|
63
76
|
e.stopPropagation();
|
|
64
77
|
// close if open
|
|
65
78
|
if (openRef.current) {
|
|
@@ -102,7 +115,6 @@ function Popup(_a) {
|
|
|
102
115
|
const onGuardClick = (e) => {
|
|
103
116
|
// stop propagation
|
|
104
117
|
e.stopPropagation();
|
|
105
|
-
e.preventDefault();
|
|
106
118
|
if (onClick) {
|
|
107
119
|
onClick(e);
|
|
108
120
|
}
|
|
@@ -38,7 +38,6 @@ exports.QuickPicker = (0, react_1.forwardRef)(function QuickPicker({ variant, ti
|
|
|
38
38
|
},
|
|
39
39
|
open: async (_a) => {
|
|
40
40
|
var { items, selectedItem } = _a, popupProps = __rest(_a, ["items", "selectedItem"]);
|
|
41
|
-
console.debug('[QuickPicker] opening with', { items, selectedItem });
|
|
42
41
|
// reset
|
|
43
42
|
setItems(items);
|
|
44
43
|
setSelectedItem(selectedItem);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FieldModel } from '@nascentdigital/funnel-core';
|
|
2
|
+
export declare function MessagePanel({ fields }: MessagePanel.Props): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare namespace MessagePanel {
|
|
4
|
+
type Props = {
|
|
5
|
+
fields: ReadonlyArray<FieldModel>;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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.MessagePanel = MessagePanel;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
9
|
+
const fields_1 = require("../fields");
|
|
10
|
+
const OptInField_1 = require("../fields/OptInField");
|
|
11
|
+
const interaction_1 = require("../interaction");
|
|
12
|
+
const visuals_1 = require("../visuals");
|
|
13
|
+
// component
|
|
14
|
+
function MessagePanel({ fields }) {
|
|
15
|
+
// states
|
|
16
|
+
const open = fields.some(field => field.exists);
|
|
17
|
+
const valid = fields.every(field => field.valid);
|
|
18
|
+
const { optInFields, existingFields } = groupFields(fields);
|
|
19
|
+
// helper
|
|
20
|
+
const onAdd = () => {
|
|
21
|
+
var _a;
|
|
22
|
+
(_a = fields.find(field => field.id === 'headline')) === null || _a === void 0 ? void 0 : _a.optIn();
|
|
23
|
+
};
|
|
24
|
+
// render
|
|
25
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)('bg-surface1 rounded-sm', {
|
|
26
|
+
'border border-dashed border-border-l1': !open,
|
|
27
|
+
'border border-border-l1 focus-within:border-ix-primary': open && valid,
|
|
28
|
+
'border border-destructive': open && !valid
|
|
29
|
+
}), 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: "Type", 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: "Message" }), !open &&
|
|
30
|
+
(0, jsx_runtime_1.jsx)("span", { className: "body-sm text-content-tertiary", children: "Headline, caption, ctas" })] }), !open &&
|
|
31
|
+
(0, jsx_runtime_1.jsx)(interaction_1.Button, { iconLeft: "Plus", size: "sm", variant: "secondary", onClick: onAdd, children: "Add Message" })] }), open &&
|
|
32
|
+
(0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)('flex flex-col gap-l8 p-l8', 'border-t border-border-l1'), children: [optInFields.length > 0 &&
|
|
33
|
+
(0, jsx_runtime_1.jsx)("section", { className: "flex flex-row flex-wrap items-center gap-l8", children: optInFields.map(field => (0, jsx_runtime_1.jsx)(OptInField_1.OptInField, { field: field }, field.id)) }), existingFields.length > 0 &&
|
|
34
|
+
(0, jsx_runtime_1.jsx)("section", { className: "flex flex-col gap-l7", children: existingFields.map(field => (0, jsx_runtime_1.jsx)(fields_1.FieldEditor, { className: "w-full max-w-full", field: field }, field.id)) })] })] }));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Group fields into two groups:
|
|
38
|
+
* 1. Optional fields that don't exist yet (optInFields)
|
|
39
|
+
* 2. Existing fields (existingFields)
|
|
40
|
+
*/
|
|
41
|
+
function groupFields(fields) {
|
|
42
|
+
const optInFields = [];
|
|
43
|
+
const existingFields = [];
|
|
44
|
+
for (const field of fields) {
|
|
45
|
+
if (!field.required && !field.exists) {
|
|
46
|
+
optInFields.push(field);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
existingFields.push(field);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return { optInFields, existingFields };
|
|
53
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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("./visual"), exports);
|
|
18
|
+
__exportStar(require("./MessagePanel"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FieldValidator } from '@nascentdigital/funnel-core';
|
|
2
|
+
import { Media } from '@nascentdigital/funnel-ui';
|
|
3
|
+
import { CollectionFieldProxy } from '../../../domain';
|
|
4
|
+
import { ErrorMessage } from '../../feedback';
|
|
5
|
+
export declare function MediaEditor({ field, errorLevel }: MediaEditor.Props): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare namespace MediaEditor {
|
|
7
|
+
type Props = {
|
|
8
|
+
field: CollectionFieldProxy<Media.Collection>;
|
|
9
|
+
error?: ErrorMessage.Error;
|
|
10
|
+
errorLevel?: FieldValidator.Error.Level;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MediaEditor = MediaEditor;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const funnel_ui_1 = require("@nascentdigital/funnel-ui");
|
|
6
|
+
const fields_1 = require("../../fields");
|
|
7
|
+
// component
|
|
8
|
+
function MediaEditor({ field, errorLevel = 'none' }) {
|
|
9
|
+
// render image fields
|
|
10
|
+
let content;
|
|
11
|
+
const value = field.value;
|
|
12
|
+
if (funnel_ui_1.Media.Value.isImage(value)) {
|
|
13
|
+
content = renderImageFields(field);
|
|
14
|
+
}
|
|
15
|
+
// or video fields
|
|
16
|
+
else {
|
|
17
|
+
content = renderVideoFields(field);
|
|
18
|
+
}
|
|
19
|
+
// render
|
|
20
|
+
return ((0, jsx_runtime_1.jsx)(fields_1.FieldErrorController, { errorLevel: errorLevel, children: content }));
|
|
21
|
+
}
|
|
22
|
+
// helpers
|
|
23
|
+
function renderImageFields(field) {
|
|
24
|
+
// resolve fields
|
|
25
|
+
const desktopImageField = field.getField('image');
|
|
26
|
+
const mobileImageField = field.getField('mobileImage');
|
|
27
|
+
// render
|
|
28
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(fields_1.FieldEditor, { field: desktopImageField, disableDelete: true }), (0, jsx_runtime_1.jsx)(fields_1.FieldEditor, { field: mobileImageField })] }));
|
|
29
|
+
}
|
|
30
|
+
function renderVideoFields(field) {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
// resolve fields
|
|
33
|
+
const sourceField = field.getField('video');
|
|
34
|
+
const localVideoField = sourceField.getField('local');
|
|
35
|
+
const localVideo = (_a = localVideoField.value) === null || _a === void 0 ? void 0 : _a.value;
|
|
36
|
+
const remoteVideoField = sourceField.getField('remote');
|
|
37
|
+
const remoteVideo = (_b = remoteVideoField.value) === null || _b === void 0 ? void 0 : _b.value;
|
|
38
|
+
const coverField = field.getField('cover');
|
|
39
|
+
// TODO render error if there's no video source
|
|
40
|
+
if (!localVideo && !remoteVideo) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
// render
|
|
44
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(fields_1.FieldEditor, { field: localVideo
|
|
45
|
+
? localVideoField
|
|
46
|
+
: remoteVideoField, disableDelete: true }), (0, jsx_runtime_1.jsx)(fields_1.FieldEditor, { field: coverField })] }));
|
|
47
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FieldModel } from '@nascentdigital/funnel-core';
|
|
2
|
+
export declare function VisualPanel({ fields }: VisualPanel.Props): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare namespace VisualPanel {
|
|
4
|
+
type Props = {
|
|
5
|
+
fields: ReadonlyArray<FieldModel>;
|
|
6
|
+
};
|
|
7
|
+
}
|