@nascentdigital/funnel-editor 6.0.0 → 6.1.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/feedback/StatusBadge.js +6 -6
- package/dist/core/components/interaction/Combobox.js +4 -2
- package/dist/core/components/interaction/RadioButtons.d.ts +20 -0
- package/dist/core/components/interaction/RadioButtons.js +47 -0
- package/dist/core/components/interaction/Tabs.js +13 -19
- package/dist/core/components/interaction/index.d.ts +1 -0
- package/dist/core/components/interaction/index.js +1 -0
- package/dist/core/components/visuals/Icon.d.ts +1 -1
- package/dist/core/components/visuals/Icon.js +6 -0
- package/dist/core/config/EditorConfig.d.ts +7 -0
- package/dist/core/config/EditorConfig.js +22 -0
- package/dist/core/config/index.d.ts +1 -0
- package/dist/core/config/index.js +17 -0
- package/dist/core/domain/BlockConfiguration.d.ts +1 -0
- package/dist/core/domain/BlockConfiguration.js +5 -0
- package/dist/core/domain/CollectionFieldProxy.js +30 -16
- package/dist/core/domain/ICollection.d.ts +2 -0
- package/dist/core/domain/IPage.d.ts +2 -0
- package/dist/core/domain/IPage.js +4 -1
- package/dist/core/domain/PageOverview.d.ts +1 -1
- package/dist/core/domain/Pages.d.ts +1 -1
- package/dist/core/domain/Section.d.ts +2 -0
- package/dist/core/domain/Section.js +8 -0
- package/dist/core/repository/CollectionRepository.d.ts +3 -6
- package/dist/core/repository/CollectionRepository.js +14 -8
- package/dist/core/repository/ICollectionRepository.d.ts +2 -11
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/page/hooks/PageController.d.ts +1 -1
- package/dist/styles/index.css +1577 -1615
- package/dist/styles/tailwind.js +0 -1
- package/package.json +3 -2
|
@@ -21,11 +21,11 @@ const classnames_1 = __importDefault(require("classnames"));
|
|
|
21
21
|
function StatusBadge(_a) {
|
|
22
22
|
var { className, color, label, variant = 'default', onClick } = _a, props = __rest(_a, ["className", "color", "label", "variant", "onClick"]);
|
|
23
23
|
// render
|
|
24
|
-
return ((0, jsx_runtime_1.jsx)("span", Object.assign({ className: (0, classnames_1.default)(className, '
|
|
25
|
-
'
|
|
26
|
-
'
|
|
27
|
-
'
|
|
28
|
-
'
|
|
29
|
-
'
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)("span", Object.assign({ className: (0, classnames_1.default)(className, 'nd-StatusBadge', {
|
|
25
|
+
'nd-StatusBadge-default': variant === 'default',
|
|
26
|
+
'nd-StatusBadge-info': variant === 'info',
|
|
27
|
+
'nd-StatusBadge-success': variant === 'success',
|
|
28
|
+
'nd-StatusBadge-warn': variant === 'warn',
|
|
29
|
+
'nd-StatusBadge-error': variant === 'error'
|
|
30
30
|
}), tabIndex: onClick ? 0 : -1, onClick: onClick }, props, { children: label })));
|
|
31
31
|
}
|
|
@@ -50,7 +50,9 @@ function Combobox({ id: externalId, className, size = 'md', maxRows = 6, rowHeig
|
|
|
50
50
|
e.preventDefault();
|
|
51
51
|
e.stopPropagation();
|
|
52
52
|
// update selection
|
|
53
|
-
|
|
53
|
+
if (option.id !== selectedOptionId) {
|
|
54
|
+
onSelect(option.id);
|
|
55
|
+
}
|
|
54
56
|
// close popup
|
|
55
57
|
onOptionsClose();
|
|
56
58
|
};
|
|
@@ -74,7 +76,7 @@ function Combobox({ id: externalId, className, size = 'md', maxRows = 6, rowHeig
|
|
|
74
76
|
// render
|
|
75
77
|
const optionKey = getOptionId(id, option);
|
|
76
78
|
const selected = option.id === selectedOptionId;
|
|
77
|
-
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),
|
|
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)('h-full flex items-center justify-between appearance-none select-none outline-none interpolate', {
|
|
78
80
|
'gap-l4 px-l6': size === 'md',
|
|
79
81
|
'gap-l3 px-l5': size === 'sm',
|
|
80
82
|
'gap-l2 px-l4': size === 'xs',
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Callback } from '@nascentdigital/funnel-core';
|
|
2
|
+
import { FieldSize } from '../fields';
|
|
3
|
+
export declare function RadioButtons<TOptionId extends string>({ id: externalId, className, size, disabled, options, selectedOption: selectedOptionId, onSelect }: RadioButtons.Props<TOptionId>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare namespace RadioButtons {
|
|
5
|
+
type Props<TOptionId extends string> = {
|
|
6
|
+
id?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
size?: FieldSize;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
options: ReadonlyArray<Option<TOptionId>>;
|
|
11
|
+
selectedOption?: TOptionId | undefined;
|
|
12
|
+
onSelect?: Callback<TOptionId>;
|
|
13
|
+
};
|
|
14
|
+
type Option<TOptionId extends string = string> = {
|
|
15
|
+
id: TOptionId;
|
|
16
|
+
label: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
disabled?: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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.RadioButtons = RadioButtons;
|
|
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 react_1 = require("react");
|
|
11
|
+
// component
|
|
12
|
+
function RadioButtons({ id: externalId, className, size = 'md', disabled = false, options, selectedOption: selectedOptionId, onSelect = funnel_core_1.Fn.NoOp }) {
|
|
13
|
+
// bind state
|
|
14
|
+
const autoId = (0, react_1.useId)();
|
|
15
|
+
const id = externalId !== null && externalId !== void 0 ? externalId : autoId;
|
|
16
|
+
// helpers
|
|
17
|
+
const onOptionSelect = (e, option) => {
|
|
18
|
+
// stop propagation
|
|
19
|
+
e.preventDefault();
|
|
20
|
+
e.stopPropagation();
|
|
21
|
+
// update selection
|
|
22
|
+
onSelect(option.id);
|
|
23
|
+
};
|
|
24
|
+
// render
|
|
25
|
+
return ((0, jsx_runtime_1.jsx)("ul", { id: id, className: (0, classnames_1.default)('radio-buttons', className, {
|
|
26
|
+
'radio-buttons-xs': size === 'xs',
|
|
27
|
+
'radio-buttons-sm': size === 'sm',
|
|
28
|
+
'radio-buttons-md': size === 'md',
|
|
29
|
+
'radio-buttons-disabled': disabled
|
|
30
|
+
}), tabIndex: -1, children: options.map((option, index) => {
|
|
31
|
+
var _a;
|
|
32
|
+
const optionKey = getOptionId(id, option);
|
|
33
|
+
const selected = option.id === selectedOptionId;
|
|
34
|
+
const isDisabled = (_a = disabled !== null && disabled !== void 0 ? disabled : option.disabled) !== null && _a !== void 0 ? _a : false;
|
|
35
|
+
return ((0, jsx_runtime_1.jsxs)("li", { className: (0, classnames_1.default)('radio-button', {
|
|
36
|
+
'radio-button-selected': selected,
|
|
37
|
+
'radio-button-disabled': isDisabled
|
|
38
|
+
}), onClick: isDisabled
|
|
39
|
+
? undefined
|
|
40
|
+
: e => onOptionSelect(e, option), tabIndex: isDisabled ? -1 : 0, children: [(0, jsx_runtime_1.jsx)("span", { className: "radio-button-indicator-wrap", children: (0, jsx_runtime_1.jsx)("span", { className: "radio-button-indicator" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "radio-button-copy", children: [(0, jsx_runtime_1.jsx)("span", { className: "radio-button-label", children: option.label }), option.description &&
|
|
41
|
+
(0, jsx_runtime_1.jsx)("span", { className: "radio-button-desc", children: option.description })] })] }, optionKey));
|
|
42
|
+
}) }));
|
|
43
|
+
}
|
|
44
|
+
// helpers
|
|
45
|
+
function getOptionId(comboboxId, option) {
|
|
46
|
+
return `${comboboxId}::option::${option.id}`;
|
|
47
|
+
}
|
|
@@ -8,27 +8,21 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
8
8
|
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
9
9
|
const classnames_1 = __importDefault(require("classnames"));
|
|
10
10
|
const framer_motion_1 = require("framer-motion");
|
|
11
|
+
const react_1 = require("react");
|
|
11
12
|
const visuals_1 = require("../visuals");
|
|
12
13
|
// component
|
|
13
14
|
function Tabs({ className, variant = 'underlined', size = 'md', items, selectedItem, onSelect = funnel_core_1.Fn.NoOp }) {
|
|
15
|
+
// bind hook
|
|
16
|
+
const layoutId = (0, react_1.useId)();
|
|
14
17
|
// render
|
|
15
|
-
return ((0, jsx_runtime_1.jsx)("nav", { className: (0, classnames_1.default)(className), children: (0, jsx_runtime_1.jsx)("ul", { className: (0, classnames_1.default)('
|
|
16
|
-
'
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
'text-content-primary': item.id === selectedItem,
|
|
26
|
-
'text-content-secondary group-hover:text-content-primary group-active:text-content-tertiary': item.id !== selectedItem,
|
|
27
|
-
'py-l6 label-md': variant === 'underlined' && size === 'md',
|
|
28
|
-
'py-l3 label-xs': variant === 'underlined' && size === 'sm',
|
|
29
|
-
'py-l3 label-md': variant === 'highlighted' && size === 'md',
|
|
30
|
-
'py-l2 label-xs': variant === 'highlighted' && size === 'sm'
|
|
31
|
-
}), children: item.label })] }), variant === 'underlined' && item.id === selectedItem &&
|
|
32
|
-
(0, jsx_runtime_1.jsx)(framer_motion_1.motion.span, { id: "underline", layoutId: "underline", className: "absolute inset-x-0 -bottom-px block divider border-b-2 border-ix-primary -mb-px z-supersurface" }), variant === 'highlighted' && item.id === selectedItem &&
|
|
33
|
-
(0, jsx_runtime_1.jsx)(framer_motion_1.motion.span, { layoutId: "active-tab", className: "absolute z-surface inset-0 bg-surface-placeholder rounded-lg" })] }, item.id)) }) }));
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)("nav", { className: (0, classnames_1.default)(className, 'nd-Tabs-wrap'), children: (0, jsx_runtime_1.jsx)("ul", { className: (0, classnames_1.default)('nd-Tabs', {
|
|
19
|
+
'nd-Tabs-highlighted': variant === 'highlighted',
|
|
20
|
+
'nd-Tabs-underlined': variant === 'underlined',
|
|
21
|
+
'nd-Tabs-sm': size === 'sm',
|
|
22
|
+
'nd-Tabs-md': size === 'md'
|
|
23
|
+
}), children: items.map(item => (0, jsx_runtime_1.jsxs)("li", { className: (0, classnames_1.default)('nd-TabItem', {
|
|
24
|
+
'nd-TabItem-selected': item.id === selectedItem
|
|
25
|
+
}), onClick: () => onSelect(item.id), children: [(0, jsx_runtime_1.jsxs)("div", { className: "nd-TabItem-content", children: [item.icon &&
|
|
26
|
+
(0, jsx_runtime_1.jsx)(visuals_1.Icon, { className: "nd-TabItem-icon", variant: item.icon, size: "nav" }), (0, jsx_runtime_1.jsx)("span", { className: "nd-TabItem-label", children: item.label })] }), item.id === selectedItem &&
|
|
27
|
+
(0, jsx_runtime_1.jsx)(framer_motion_1.motion.span, { layoutId: layoutId, className: "nd-TabItem-selection" })] }, item.id)) }) }));
|
|
34
28
|
}
|
|
@@ -25,6 +25,7 @@ export * from './Profile';
|
|
|
25
25
|
export * from './QuickEditor';
|
|
26
26
|
export * from './QuickInput';
|
|
27
27
|
export * from './QuickPicker';
|
|
28
|
+
export * from './RadioButtons';
|
|
28
29
|
export * from './SegmentedButton';
|
|
29
30
|
export * from './SideSheet';
|
|
30
31
|
export * from './Sortable';
|
|
@@ -41,6 +41,7 @@ __exportStar(require("./Profile"), exports);
|
|
|
41
41
|
__exportStar(require("./QuickEditor"), exports);
|
|
42
42
|
__exportStar(require("./QuickInput"), exports);
|
|
43
43
|
__exportStar(require("./QuickPicker"), exports);
|
|
44
|
+
__exportStar(require("./RadioButtons"), exports);
|
|
44
45
|
__exportStar(require("./SegmentedButton"), exports);
|
|
45
46
|
__exportStar(require("./SideSheet"), exports);
|
|
46
47
|
__exportStar(require("./Sortable"), 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' | 'ArrowLeft' | 'ArrowRight' | 'ArrowLeftRight' | 'Atom' | 'Blocks' | 'Bold' | 'Check' | 'ChevronDown' | 'ChevronRight' | 'ChevronUp' | 'Circle' | 'CircleAlert' | 'CircleCheck' | 'CircleCheckBig' | 'CirclePlus' | 'CircleQuestionMark' | 'CloudCheck' | 'CloudUpload' | 'Copy' | 'CornerDownRight' | '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' | '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';
|
|
10
10
|
namespace Variant {
|
|
11
11
|
function filter(value: any): value is Variant;
|
|
12
12
|
}
|
|
@@ -19,6 +19,7 @@ function Icon({ className, variant, size: sizing = 'md' }) {
|
|
|
19
19
|
// constants
|
|
20
20
|
const values = [
|
|
21
21
|
'Archive',
|
|
22
|
+
'ArrowDownUp',
|
|
22
23
|
'ArrowLeft',
|
|
23
24
|
'ArrowRight',
|
|
24
25
|
'ArrowLeftRight',
|
|
@@ -39,6 +40,7 @@ function Icon({ className, variant, size: sizing = 'md' }) {
|
|
|
39
40
|
'CloudUpload',
|
|
40
41
|
'Copy',
|
|
41
42
|
'CornerDownRight',
|
|
43
|
+
'Cuboid',
|
|
42
44
|
'EllipsisVertical',
|
|
43
45
|
'Eye',
|
|
44
46
|
'EyeOff',
|
|
@@ -115,6 +117,8 @@ function getIcon(variant) {
|
|
|
115
117
|
switch (variant) {
|
|
116
118
|
case 'Archive':
|
|
117
119
|
return lucide_react_1.Archive;
|
|
120
|
+
case 'ArrowDownUp':
|
|
121
|
+
return lucide_react_1.ArrowDownUp;
|
|
118
122
|
case 'ArrowLeft':
|
|
119
123
|
return lucide_react_1.ArrowLeft;
|
|
120
124
|
case 'ArrowRight':
|
|
@@ -155,6 +159,8 @@ function getIcon(variant) {
|
|
|
155
159
|
return lucide_react_1.Copy;
|
|
156
160
|
case 'CornerDownRight':
|
|
157
161
|
return lucide_react_1.CornerDownRight;
|
|
162
|
+
case 'Cuboid':
|
|
163
|
+
return lucide_react_1.Cuboid;
|
|
158
164
|
case 'EllipsisVertical':
|
|
159
165
|
return lucide_react_1.EllipsisVertical;
|
|
160
166
|
case 'Eye':
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EditorConfig = void 0;
|
|
4
|
+
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
5
|
+
var EditorConfig;
|
|
6
|
+
(function (EditorConfig) {
|
|
7
|
+
function set(value) {
|
|
8
|
+
config = Object.assign(Object.assign({}, config), value);
|
|
9
|
+
}
|
|
10
|
+
EditorConfig.set = set;
|
|
11
|
+
function get() {
|
|
12
|
+
// throw if config isn't set
|
|
13
|
+
if (!config) {
|
|
14
|
+
throw new funnel_core_1.IllegalStateError('Attempt to access EditorConfig before first call to EditorConfig.set()');
|
|
15
|
+
}
|
|
16
|
+
// return
|
|
17
|
+
return config;
|
|
18
|
+
}
|
|
19
|
+
EditorConfig.get = get;
|
|
20
|
+
})(EditorConfig || (exports.EditorConfig = EditorConfig = {}));
|
|
21
|
+
// global content
|
|
22
|
+
let config = undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './EditorConfig';
|
|
@@ -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("./EditorConfig"), exports);
|
|
@@ -33,6 +33,7 @@ export declare class BlockConfiguration {
|
|
|
33
33
|
get slotState(): Readonly<BlockConfiguration.SlotState>;
|
|
34
34
|
gotToNextSlot(): void;
|
|
35
35
|
gotToPreviousSlot(): void;
|
|
36
|
+
get hasBlockConfig(): boolean;
|
|
36
37
|
get hasPanels(): boolean;
|
|
37
38
|
get messageFields(): Record<keyof MessagePanel.Config.Keys<'message'>, FieldModel.Config | undefined>;
|
|
38
39
|
get listFields(): Record<keyof ListPanel.Config.Keys<'list'>, FieldModel.Config | undefined>;
|
|
@@ -195,6 +195,11 @@ class BlockConfiguration {
|
|
|
195
195
|
};
|
|
196
196
|
field.value = funnel_core_1.Schema.EnumField.Value.toData(newOption);
|
|
197
197
|
}
|
|
198
|
+
get hasBlockConfig() {
|
|
199
|
+
return this.blocksFields.length > 0
|
|
200
|
+
|| this.desktopFields.length > 0
|
|
201
|
+
|| this.mobileFields.length > 0;
|
|
202
|
+
}
|
|
198
203
|
get hasPanels() {
|
|
199
204
|
// build list of panel keys
|
|
200
205
|
const panelKeys = [
|
|
@@ -314,36 +314,51 @@ class CollectionFieldProxy {
|
|
|
314
314
|
if (!initialData) {
|
|
315
315
|
console.debug('[CollectionFieldProxy/save] creating remote instance');
|
|
316
316
|
// create item (fail if we don't get a collection - shouldn't happen)
|
|
317
|
-
const { collection
|
|
317
|
+
const { collection } = await collectionRepository.create({
|
|
318
318
|
template: collectionSchema,
|
|
319
319
|
language,
|
|
320
320
|
name,
|
|
321
321
|
tags: []
|
|
322
322
|
});
|
|
323
|
-
if (!
|
|
323
|
+
if (!collection) {
|
|
324
324
|
throw new funnel_core_1.IllegalStateError('Failed to create collection');
|
|
325
325
|
}
|
|
326
|
-
//
|
|
327
|
-
initialData =
|
|
326
|
+
// set initial data from created collection model
|
|
327
|
+
initialData = {
|
|
328
|
+
data: {
|
|
329
|
+
__root: 'collection',
|
|
330
|
+
id: collection.id,
|
|
331
|
+
groupId: collection.groupId,
|
|
332
|
+
version: collectionSchema.version,
|
|
333
|
+
type: collection.type,
|
|
334
|
+
name,
|
|
335
|
+
language,
|
|
336
|
+
tags: [],
|
|
337
|
+
fields: {},
|
|
338
|
+
errors: !collection.valid,
|
|
339
|
+
state: collection.state,
|
|
340
|
+
createdOn: collection.createdOn,
|
|
341
|
+
updatedOn: collection.updatedOn,
|
|
342
|
+
publishedOn: collection.publishedOn
|
|
343
|
+
},
|
|
344
|
+
collections: {},
|
|
345
|
+
pages: {},
|
|
346
|
+
files: {}
|
|
347
|
+
};
|
|
328
348
|
// update initial value
|
|
329
349
|
this._initialValue = {
|
|
330
|
-
id:
|
|
331
|
-
type:
|
|
350
|
+
id: collection.id,
|
|
351
|
+
type: collection.type
|
|
332
352
|
};
|
|
333
353
|
}
|
|
334
354
|
console.debug('[CollectionFieldProxy/save] updating remote instance', initialData);
|
|
335
|
-
// create update
|
|
336
|
-
const savables = [];
|
|
337
|
-
const update = collectionRepository.serializeUpdate(this, savables);
|
|
338
|
-
console.debug('[CollectionFieldProxy/save] created update', update);
|
|
339
355
|
// start all updates
|
|
340
356
|
this.onSaveStart();
|
|
341
|
-
savables.forEach(savable => savable.onSaveStart());
|
|
342
357
|
// update page
|
|
343
|
-
const { collection } = await collectionRepository.update(
|
|
344
|
-
// update
|
|
358
|
+
const { collection } = await collectionRepository.update(this);
|
|
359
|
+
// update local fields if we have updated collection data
|
|
345
360
|
if (collection) {
|
|
346
|
-
//
|
|
361
|
+
// update collection store
|
|
347
362
|
collectionStore.addCollection(collection.data);
|
|
348
363
|
// reset fields
|
|
349
364
|
nameField.reset(funnel_core_1.Schema.TextField.Value.toData(collection.data.name));
|
|
@@ -362,7 +377,7 @@ class CollectionFieldProxy {
|
|
|
362
377
|
// update data
|
|
363
378
|
initialData = collection;
|
|
364
379
|
}
|
|
365
|
-
//
|
|
380
|
+
// otherwise use local values to update initial data
|
|
366
381
|
else {
|
|
367
382
|
// update data
|
|
368
383
|
initialData.data = Object.assign(Object.assign({}, initialData.data), this.getInlineData());
|
|
@@ -370,7 +385,6 @@ class CollectionFieldProxy {
|
|
|
370
385
|
collectionStore.addCollection(initialData.data);
|
|
371
386
|
}
|
|
372
387
|
// complete all updates
|
|
373
|
-
savables.forEach(savable => savable.onSaveComplete());
|
|
374
388
|
this.onSaveComplete();
|
|
375
389
|
// update initial data
|
|
376
390
|
this._initialData = initialData;
|
|
@@ -19,6 +19,7 @@ export interface ICollection extends IAssetStore, ICollectionStore, IPageRefStor
|
|
|
19
19
|
readonly state: Schema.Collection.State;
|
|
20
20
|
readonly published: boolean;
|
|
21
21
|
readonly valid: boolean;
|
|
22
|
+
readonly initialErrors: boolean;
|
|
22
23
|
readonly errors: ICollection.Errors;
|
|
23
24
|
readonly changeSetId?: Schema.ChangeSet.Id;
|
|
24
25
|
readonly publishedOn?: number;
|
|
@@ -60,6 +61,7 @@ export declare namespace ICollection {
|
|
|
60
61
|
collection: ICollection;
|
|
61
62
|
fields: Array<FieldModel>;
|
|
62
63
|
};
|
|
64
|
+
type ForUpdate = Pick<ICollection, 'id' | 'nameField' | 'name' | 'initialTags' | 'tags' | 'fields' | 'initialErrors' | 'valid'>;
|
|
63
65
|
type Events = Event | Item.Event | Field.Event | ObjectField.Event | FieldList.Event;
|
|
64
66
|
interface Event extends EventBus.Event<'Collection', Event.Type> {
|
|
65
67
|
collection: ICollection;
|
|
@@ -22,6 +22,7 @@ export interface IPage extends IAssetStore, ICollectionStore, IPageRefStore, ITa
|
|
|
22
22
|
readonly events$: Observable<IPage.Events>;
|
|
23
23
|
readonly settings: PageSettings;
|
|
24
24
|
readonly discover: ReadonlyArray<Block>;
|
|
25
|
+
readonly seo: Block;
|
|
25
26
|
readonly content: IPage.Content;
|
|
26
27
|
readonly published: boolean;
|
|
27
28
|
readonly hasSlug: boolean;
|
|
@@ -34,6 +35,7 @@ export interface IPage extends IAssetStore, ICollectionStore, IPageRefStore, ITa
|
|
|
34
35
|
publication: number | undefined;
|
|
35
36
|
slug: string | undefined;
|
|
36
37
|
deleteBlock(area: IPage.Area, key: string): void;
|
|
38
|
+
getItem(identifier: string | undefined): Block | SectionBlock | Section | PageSettings | undefined;
|
|
37
39
|
}
|
|
38
40
|
export declare namespace IPage {
|
|
39
41
|
type Content = ReadonlyArray<Block | Section>;
|
|
@@ -13,6 +13,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.IPage = void 0;
|
|
15
15
|
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
16
|
+
const config_1 = require("../config");
|
|
16
17
|
// extension
|
|
17
18
|
var IPage;
|
|
18
19
|
(function (IPage) {
|
|
@@ -39,8 +40,10 @@ var IPage;
|
|
|
39
40
|
})(Event = IPage.Event || (IPage.Event = {}));
|
|
40
41
|
// helpers
|
|
41
42
|
function getPreviewUrl(path) {
|
|
43
|
+
// get preview api path
|
|
44
|
+
const { previewApiPath } = config_1.EditorConfig.get();
|
|
42
45
|
// get base url
|
|
43
|
-
const url = new URL(
|
|
46
|
+
const url = new URL(previewApiPath, window.location.href);
|
|
44
47
|
// apply args
|
|
45
48
|
url.searchParams.set('redirect', path);
|
|
46
49
|
// return url
|
|
@@ -17,7 +17,7 @@ export declare class StaticPageOverview extends PageOverviewBase {
|
|
|
17
17
|
readonly refs: Readonly<Record<Language, Schema.Page.Data.AsLink>>;
|
|
18
18
|
readonly languages: ReadonlyArray<Language>;
|
|
19
19
|
constructor({ refs, ...args }: StaticPageOverview.ConstructorArgs);
|
|
20
|
-
get pages(): Schema.Page.Data.AsLink<Schema.Page<
|
|
20
|
+
get pages(): Schema.Page.Data.AsLink<Schema.Page<any, any>, string>[];
|
|
21
21
|
get isEmpty(): boolean;
|
|
22
22
|
hasLanguage(language: Language): boolean;
|
|
23
23
|
findPage({ region, language }: StaticPageOverview.FindPageArgs): Schema.Page.Data.AsLink | undefined;
|
|
@@ -11,7 +11,7 @@ export declare class Pages {
|
|
|
11
11
|
private _items;
|
|
12
12
|
constructor(args: Pages.ConstructorArgs);
|
|
13
13
|
get events$(): Observable<Pages.Event>;
|
|
14
|
-
get template(): Schema.Page<
|
|
14
|
+
get template(): Schema.Page<any, any>;
|
|
15
15
|
get state(): Site.State;
|
|
16
16
|
private set state(value);
|
|
17
17
|
get ready(): boolean;
|
|
@@ -20,6 +20,8 @@ export declare class Section extends ItemBase<Section> {
|
|
|
20
20
|
get valid(): boolean;
|
|
21
21
|
get changes(): Section.Changes;
|
|
22
22
|
get errors(): Section.Errors;
|
|
23
|
+
get missingBlocks(): number;
|
|
24
|
+
get canAddBlocks(): boolean;
|
|
23
25
|
bind(parentContext: ItemBase.ParentContext): void;
|
|
24
26
|
addBlock(identifier: string): SectionBlock<Schema.Block<string, any, any>>;
|
|
25
27
|
deleteBlock(id: SectionBlock.Id): undefined;
|
|
@@ -71,6 +71,14 @@ class Section extends ItemBase_1.ItemBase {
|
|
|
71
71
|
blocks: this.blocks.filter(block => !block.valid)
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
+
get missingBlocks() {
|
|
75
|
+
const { schema, blocks } = this;
|
|
76
|
+
return Math.max(0, schema.min - blocks.length);
|
|
77
|
+
}
|
|
78
|
+
get canAddBlocks() {
|
|
79
|
+
const { schema, blocks } = this;
|
|
80
|
+
return blocks.length < schema.max;
|
|
81
|
+
}
|
|
74
82
|
bind(parentContext) {
|
|
75
83
|
// invoke base
|
|
76
84
|
super.bind(parentContext);
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { Schema } from '@nascentdigital/funnel-core';
|
|
2
|
-
import { UpdateCollectionCommand } from '../../api/collections';
|
|
3
1
|
import { EditorApiClient } from '../client';
|
|
4
|
-
import { Collection,
|
|
2
|
+
import { Collection, ICollection } from '../domain';
|
|
5
3
|
import { CollectionTarget } from './CollectionTarget';
|
|
6
4
|
import { ICollectionRepository } from './ICollectionRepository';
|
|
7
5
|
export declare class CollectionRepository implements ICollectionRepository {
|
|
@@ -11,7 +9,6 @@ export declare class CollectionRepository implements ICollectionRepository {
|
|
|
11
9
|
collection: Collection | undefined;
|
|
12
10
|
group: import("../domain").CollectionGroup;
|
|
13
11
|
} | undefined>;
|
|
14
|
-
createRaw(args: ICollectionRepository.CreateRaw.Args): Promise<Schema.Collection.Data.AsGroup>;
|
|
15
12
|
create({ eventBus, ...args }: ICollectionRepository.Create.Args): Promise<{
|
|
16
13
|
collection: Collection | undefined;
|
|
17
14
|
group: import("../domain").CollectionGroup;
|
|
@@ -25,6 +22,6 @@ export declare class CollectionRepository implements ICollectionRepository {
|
|
|
25
22
|
getOverview(args: ICollectionRepository.GetOverview.Args): Promise<ICollectionRepository.GetOverview.Result>;
|
|
26
23
|
getItems(args: ICollectionRepository.GetItems.Args): Promise<ICollectionRepository.GetItems.Result>;
|
|
27
24
|
get(args: ICollectionRepository.Get.Args): Promise<ICollectionRepository.Get.Result>;
|
|
28
|
-
update(
|
|
29
|
-
serializeUpdate
|
|
25
|
+
update(collection: ICollection.ForUpdate): Promise<ICollectionRepository.Update.Result>;
|
|
26
|
+
private serializeUpdate;
|
|
30
27
|
}
|
|
@@ -30,15 +30,11 @@ class CollectionRepository {
|
|
|
30
30
|
// deserialize collection (if any)
|
|
31
31
|
return CollectionSerializer_1.CollectionSerializer.deserializeCollectionGroup(Object.assign(Object.assign({}, args), data));
|
|
32
32
|
}
|
|
33
|
-
async createRaw(args) {
|
|
34
|
-
// resolve collection (get or create)
|
|
35
|
-
const { template } = args, query = __rest(args, ["template"]);
|
|
36
|
-
return this.editorApi.createCollection(Object.assign(Object.assign({}, query), { type: template.type, version: template.version }));
|
|
37
|
-
}
|
|
38
33
|
async create(_a) {
|
|
39
34
|
var { eventBus } = _a, args = __rest(_a, ["eventBus"]);
|
|
40
35
|
// create
|
|
41
|
-
const
|
|
36
|
+
const { template } = args, query = __rest(args, ["template"]);
|
|
37
|
+
const data = await this.editorApi.createCollection(Object.assign(Object.assign({}, query), { type: template.type, version: template.version }));
|
|
42
38
|
// return collection
|
|
43
39
|
return CollectionSerializer_1.CollectionSerializer.deserializeCollectionGroup(Object.assign(Object.assign({ eventBus: eventBus !== null && eventBus !== void 0 ? eventBus : new funnel_core_1.EventBus() }, args), data));
|
|
44
40
|
}
|
|
@@ -91,8 +87,18 @@ class CollectionRepository {
|
|
|
91
87
|
get(args) {
|
|
92
88
|
return this.editorApi.getCollection(args);
|
|
93
89
|
}
|
|
94
|
-
async update(
|
|
95
|
-
|
|
90
|
+
async update(collection) {
|
|
91
|
+
// create update
|
|
92
|
+
const savables = [];
|
|
93
|
+
const update = this.serializeUpdate(collection, savables);
|
|
94
|
+
// start all updates
|
|
95
|
+
savables.forEach(savable => savable.onSaveStart());
|
|
96
|
+
// update request
|
|
97
|
+
const response = await this.editorApi.updateCollection(update);
|
|
98
|
+
// complete all updates
|
|
99
|
+
savables.forEach(savable => savable.onSaveComplete());
|
|
100
|
+
// return
|
|
101
|
+
return response;
|
|
96
102
|
}
|
|
97
103
|
serializeUpdate(collection, savables) {
|
|
98
104
|
// add name updates
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { CollectionClient } from '@nascentdigital/funnel-cms';
|
|
2
2
|
import { EventBus, Schema } from '@nascentdigital/funnel-core';
|
|
3
|
-
import {
|
|
3
|
+
import { ICollection } from '../domain';
|
|
4
4
|
export interface ICollectionRepository {
|
|
5
5
|
create(args: ICollectionRepository.Create.Args): Promise<ICollectionRepository.Create.Result>;
|
|
6
|
-
createRaw(args: ICollectionRepository.CreateRaw.Args): Promise<ICollectionRepository.CreateRaw.Result>;
|
|
7
6
|
createLanguage(args: ICollectionRepository.CreateLang.Args): Promise<ICollectionRepository.CreateLang.Result>;
|
|
8
7
|
save(collection: ICollection): Promise<ICollection>;
|
|
9
8
|
unpublish(collection: ICollection): Promise<void>;
|
|
10
9
|
getOverview(args: ICollectionRepository.GetOverview.Args): Promise<ICollectionRepository.GetOverview.Result>;
|
|
11
10
|
getItems(args: ICollectionRepository.GetItems.Args): Promise<ICollectionRepository.GetItems.Result>;
|
|
12
11
|
get(args: ICollectionRepository.Get.Args): Promise<ICollectionRepository.Get.Result>;
|
|
13
|
-
update(
|
|
14
|
-
serializeUpdate(collection: ICollection | CollectionFieldProxy, savables: ICollection.Savable[]): ICollectionRepository.SerializeUpdates.Result;
|
|
12
|
+
update(collection: ICollection.ForUpdate): Promise<ICollectionRepository.Update.Result>;
|
|
15
13
|
}
|
|
16
14
|
export declare namespace ICollectionRepository {
|
|
17
15
|
namespace Create {
|
|
@@ -21,12 +19,6 @@ export declare namespace ICollectionRepository {
|
|
|
21
19
|
};
|
|
22
20
|
type Result = ICollection.WithGroup;
|
|
23
21
|
}
|
|
24
|
-
namespace CreateRaw {
|
|
25
|
-
type Args = Omit<CollectionClient.Create.NewArgs, 'brand' | 'type' | 'version'> & {
|
|
26
|
-
template: Schema.Collection;
|
|
27
|
-
};
|
|
28
|
-
type Result = Schema.Collection.Data.AsGroup;
|
|
29
|
-
}
|
|
30
22
|
namespace CreateLang {
|
|
31
23
|
type Args = Omit<CollectionClient.Create.NewLanguageArgs, 'brand'> & {
|
|
32
24
|
template: Schema.Collection;
|
|
@@ -52,7 +44,6 @@ export declare namespace ICollectionRepository {
|
|
|
52
44
|
type Result = CollectionClient.Get.Result;
|
|
53
45
|
}
|
|
54
46
|
namespace Update {
|
|
55
|
-
type Args = CollectionClient.Update.Args;
|
|
56
47
|
type Result = CollectionClient.Update.Result;
|
|
57
48
|
}
|
|
58
49
|
namespace SerializeUpdates {
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -22,7 +22,7 @@ export declare class PageController implements IPageController {
|
|
|
22
22
|
get language(): "cy" | "fr" | "fy" | "to" | "br" | "hr" | "li" | "th" | "tr" | "id" | "is" | "tw" | "no" | "aa" | "ab" | "ae" | "af" | "ak" | "am" | "an" | "ar" | "as" | "av" | "ay" | "az" | "ba" | "be" | "bg" | "bh" | "bi" | "bm" | "bn" | "bo" | "bs" | "ca" | "ce" | "ch" | "co" | "cr" | "cs" | "cu" | "cv" | "da" | "de" | "dv" | "dz" | "ee" | "el" | "en" | "eo" | "es" | "et" | "eu" | "fa" | "ff" | "fi" | "fj" | "fo" | "ga" | "gd" | "gl" | "gn" | "gu" | "gv" | "ha" | "he" | "hi" | "ho" | "ht" | "hu" | "hy" | "hz" | "ia" | "ie" | "ig" | "ii" | "ik" | "io" | "it" | "iu" | "ja" | "jv" | "ka" | "kg" | "ki" | "kj" | "kk" | "kl" | "km" | "kn" | "ko" | "kr" | "ks" | "ku" | "kv" | "kw" | "ky" | "la" | "lb" | "lg" | "ln" | "lo" | "lt" | "lu" | "lv" | "mg" | "mh" | "mi" | "mk" | "ml" | "mn" | "mr" | "ms" | "mt" | "my" | "na" | "nb" | "nd" | "ne" | "ng" | "nl" | "nn" | "nr" | "nv" | "ny" | "oc" | "oj" | "om" | "or" | "os" | "pa" | "pi" | "pl" | "ps" | "pt" | "qu" | "rm" | "rn" | "ro" | "ru" | "rw" | "sa" | "sc" | "sd" | "se" | "sg" | "si" | "sk" | "sl" | "sm" | "sn" | "so" | "sq" | "sr" | "ss" | "st" | "su" | "sv" | "sw" | "ta" | "te" | "tg" | "ti" | "tk" | "tl" | "tn" | "ts" | "tt" | "ty" | "ug" | "uk" | "ur" | "uz" | "ve" | "vi" | "vo" | "wa" | "wo" | "xh" | "yi" | "yo" | "za" | "zh" | "zu";
|
|
23
23
|
get languages(): ("cy" | "fr" | "fy" | "to" | "br" | "hr" | "li" | "th" | "tr" | "id" | "is" | "tw" | "no" | "aa" | "ab" | "ae" | "af" | "ak" | "am" | "an" | "ar" | "as" | "av" | "ay" | "az" | "ba" | "be" | "bg" | "bh" | "bi" | "bm" | "bn" | "bo" | "bs" | "ca" | "ce" | "ch" | "co" | "cr" | "cs" | "cu" | "cv" | "da" | "de" | "dv" | "dz" | "ee" | "el" | "en" | "eo" | "es" | "et" | "eu" | "fa" | "ff" | "fi" | "fj" | "fo" | "ga" | "gd" | "gl" | "gn" | "gu" | "gv" | "ha" | "he" | "hi" | "ho" | "ht" | "hu" | "hy" | "hz" | "ia" | "ie" | "ig" | "ii" | "ik" | "io" | "it" | "iu" | "ja" | "jv" | "ka" | "kg" | "ki" | "kj" | "kk" | "kl" | "km" | "kn" | "ko" | "kr" | "ks" | "ku" | "kv" | "kw" | "ky" | "la" | "lb" | "lg" | "ln" | "lo" | "lt" | "lu" | "lv" | "mg" | "mh" | "mi" | "mk" | "ml" | "mn" | "mr" | "ms" | "mt" | "my" | "na" | "nb" | "nd" | "ne" | "ng" | "nl" | "nn" | "nr" | "nv" | "ny" | "oc" | "oj" | "om" | "or" | "os" | "pa" | "pi" | "pl" | "ps" | "pt" | "qu" | "rm" | "rn" | "ro" | "ru" | "rw" | "sa" | "sc" | "sd" | "se" | "sg" | "si" | "sk" | "sl" | "sm" | "sn" | "so" | "sq" | "sr" | "ss" | "st" | "su" | "sv" | "sw" | "ta" | "te" | "tg" | "ti" | "tk" | "tl" | "tn" | "ts" | "tt" | "ty" | "ug" | "uk" | "ur" | "uz" | "ve" | "vi" | "vo" | "wa" | "wo" | "xh" | "yi" | "yo" | "za" | "zh" | "zu")[];
|
|
24
24
|
get templates(): Schema.Site.Pages;
|
|
25
|
-
get currentTemplate(): Schema.Page<
|
|
25
|
+
get currentTemplate(): Schema.Page<any, any>;
|
|
26
26
|
get pageTarget(): IPageController.Target | undefined;
|
|
27
27
|
get pageSummary(): PageSummary | undefined;
|
|
28
28
|
private set pageSummary(value);
|