@nascentdigital/funnel-editor 6.0.1 → 6.1.1

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.
Files changed (37) hide show
  1. package/dist/core/components/feedback/StatusBadge.js +6 -6
  2. package/dist/core/components/interaction/Combobox.js +4 -2
  3. package/dist/core/components/interaction/RadioButtons.d.ts +20 -0
  4. package/dist/core/components/interaction/RadioButtons.js +47 -0
  5. package/dist/core/components/interaction/Tabs.js +13 -19
  6. package/dist/core/components/interaction/index.d.ts +1 -0
  7. package/dist/core/components/interaction/index.js +1 -0
  8. package/dist/core/components/visuals/Icon.d.ts +1 -1
  9. package/dist/core/components/visuals/Icon.js +6 -0
  10. package/dist/core/config/EditorConfig.d.ts +7 -0
  11. package/dist/core/config/EditorConfig.js +22 -0
  12. package/dist/core/config/index.d.ts +1 -0
  13. package/dist/core/config/index.js +17 -0
  14. package/dist/core/domain/Block.d.ts +2 -2
  15. package/dist/core/domain/Block.js +16 -1
  16. package/dist/core/domain/BlockConfiguration.d.ts +4 -1
  17. package/dist/core/domain/BlockConfiguration.js +38 -1
  18. package/dist/core/domain/CollectionFieldProxy.js +30 -16
  19. package/dist/core/domain/ICollection.d.ts +2 -0
  20. package/dist/core/domain/IPage.d.ts +1 -0
  21. package/dist/core/domain/IPage.js +4 -1
  22. package/dist/core/domain/PageOverview.d.ts +1 -1
  23. package/dist/core/domain/Pages.d.ts +1 -1
  24. package/dist/core/domain/Section.d.ts +2 -0
  25. package/dist/core/domain/Section.js +13 -19
  26. package/dist/core/domain/SectionBlock.d.ts +5 -1
  27. package/dist/core/domain/SectionBlock.js +11 -3
  28. package/dist/core/repository/CollectionRepository.d.ts +3 -6
  29. package/dist/core/repository/CollectionRepository.js +14 -8
  30. package/dist/core/repository/ICollectionRepository.d.ts +2 -11
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.js +1 -0
  33. package/dist/page/components/config/BlockConfigButton.js +1 -2
  34. package/dist/page/hooks/PageController.d.ts +1 -1
  35. package/dist/styles/index.css +1577 -1615
  36. package/dist/styles/tailwind.js +0 -1
  37. 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, 'h-20 inline-flex items-center px-10 whitespace-nowrap', 'label-xs label-strong uppercase', 'border border-solid rounded-full', {
25
- 'text-draft-content bg-draft/tint1 border-draft/tint3': variant === 'default',
26
- 'text-info-content bg-info/tint1 border-info/tint3': variant === 'info',
27
- 'text-success-content bg-success/tint1 border-success/tint3': variant === 'success',
28
- 'text-warn-content bg-warn/tint1 border-warn/tint3': variant === 'warn',
29
- 'text-destructive-content bg-destructive/tint1 border-destructive/tint3': variant === 'error',
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
- onSelect(option.id);
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), disabled: selected, 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', {
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)('grid auto-cols-fr grid-flow-col items-center cursor-pointer', {
16
- 'rounded-lg bg-surface-placeholder-raised p-l1': variant === 'highlighted',
17
- }), children: items.map(item => (0, jsx_runtime_1.jsxs)("li", { className: (0, classnames_1.default)('group relative interpolate', {
18
- 'border-b border-solid border-content-tertiary': variant === 'underlined',
19
- 'pointer-events-none': item.id === selectedItem,
20
- 'hover:border-content-secondary active:border-content-tertiary': item.id !== selectedItem,
21
- }), onClick: () => onSelect(item.id), children: [(0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)('flex justify-center items-center gap-l6', {
22
- 'relative z-supersurface': variant === 'highlighted'
23
- }), children: [item.icon &&
24
- (0, jsx_runtime_1.jsx)(visuals_1.Icon, { variant: item.icon, size: "nav" }), (0, jsx_runtime_1.jsx)("span", { className: (0, classnames_1.default)('inline-block interpolate', {
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,7 @@
1
+ export type EditorConfig = {
2
+ previewApiPath: string;
3
+ };
4
+ export declare namespace EditorConfig {
5
+ function set(value: EditorConfig): void;
6
+ function get(): EditorConfig;
7
+ }
@@ -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);
@@ -26,14 +26,14 @@ export declare class Block<TBlock extends Schema.Block = Schema.Block> extends I
26
26
  get errors(): Block.Errors;
27
27
  bind(parentContext: ParentContext): void;
28
28
  getConfiguration(): BlockConfiguration;
29
- getConfig(fieldId: Block.ConfigId<TBlock>): FieldModel;
29
+ getConfig(fieldId: Block.ConfigId<TBlock>): FieldModel.Config;
30
30
  setConfig(config: ReadonlyArray<FieldModel.Config>): void;
31
31
  getField(fieldId: Block.FieldId<TBlock>): FieldModel;
32
32
  getTextField(fieldId: Block.FieldId<TBlock>): Field<Schema.TextField> | undefined;
33
33
  repair(): void;
34
34
  onSaveStart(): void;
35
35
  onSaveComplete(): void;
36
- clone(forceExists?: boolean): Block;
36
+ clone(forceExists?: boolean, parentContext?: ItemBase.ParentContext): Block;
37
37
  protected onActivate(): void;
38
38
  protected syncBlockConfig(): void;
39
39
  protected onFieldChange(event: Field.Event): void;
@@ -277,7 +277,7 @@ class Block extends ItemBase_1.ItemBase {
277
277
  // clear saving flag
278
278
  delete this._savingOn;
279
279
  }
280
- clone(forceExists = false) {
280
+ clone(forceExists = false, parentContext) {
281
281
  // create block
282
282
  const block = new Block({
283
283
  key: this.key,
@@ -288,6 +288,10 @@ class Block extends ItemBase_1.ItemBase {
288
288
  required: this.required,
289
289
  exists: forceExists || this.activated
290
290
  });
291
+ // bind parent context
292
+ if (parentContext) {
293
+ block.bind(parentContext);
294
+ }
291
295
  // activate it
292
296
  if (forceExists) {
293
297
  block.onActivate();
@@ -299,6 +303,17 @@ class Block extends ItemBase_1.ItemBase {
299
303
  // call base
300
304
  super.onActivate();
301
305
  this._modifiedOn = Date.now();
306
+ // apply default content if specified
307
+ const { defaultContent } = this.schema;
308
+ if (defaultContent) {
309
+ // opt into array of fields
310
+ if (Array.isArray(defaultContent)) {
311
+ for (const fieldId of defaultContent) {
312
+ const field = this.getField(fieldId);
313
+ field.optIn();
314
+ }
315
+ }
316
+ }
302
317
  // pre-populate all fields
303
318
  this.fields.forEach(field => {
304
319
  // skip if there's an existing value OR it's not required
@@ -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>;
@@ -42,14 +43,16 @@ export declare class BlockConfiguration {
42
43
  get events$(): import("rxjs").Observable<EventBus.Event<string, string>>;
43
44
  get valid(): boolean;
44
45
  get modified(): boolean;
45
- getField(fieldId: string): FieldModel;
46
+ getField(fieldId: string): FieldModel.Config;
46
47
  getFieldData(fieldId: string): Schema.Field.LinkedData | undefined;
47
48
  getEditableField(fieldId: string): FieldModel.Config | undefined;
48
49
  save(): void;
49
50
  resetToDefault(): void;
50
51
  get isConfigInDefault(): boolean | undefined;
52
+ setLayout(layout: PanelLayout): void;
51
53
  sync(): void;
52
54
  reset(): void;
55
+ private setConfigValues;
53
56
  private raiseEvent;
54
57
  }
55
58
  export declare namespace BlockConfiguration {
@@ -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 = [
@@ -393,6 +398,30 @@ class BlockConfiguration {
393
398
  get isConfigInDefault() {
394
399
  return this._isConfigInDefault;
395
400
  }
401
+ setLayout(layout) {
402
+ var _a;
403
+ // bail if no layout field (shouldn't happen)
404
+ const { block, layoutField } = this;
405
+ if (!layoutField) {
406
+ return;
407
+ }
408
+ // bail if no change in layout
409
+ const previousLayout = (_a = layoutField.value) === null || _a === void 0 ? void 0 : _a.value;
410
+ if (previousLayout === layout) {
411
+ return;
412
+ }
413
+ // update layout if different
414
+ layoutField.value = funnel_core_1.Schema.EnumField.Value.toData(layout);
415
+ // finish here if no layout change
416
+ if (!block.schema.defaultLayoutConfigs) {
417
+ return;
418
+ }
419
+ // set config for layout
420
+ const configForLayout = block.schema.defaultLayoutConfigs[layout];
421
+ if (configForLayout) {
422
+ this.setConfigValues(configForLayout);
423
+ }
424
+ }
396
425
  sync() {
397
426
  var _a;
398
427
  // recompute the editable fields
@@ -406,7 +435,7 @@ class BlockConfiguration {
406
435
  const blockSchema = block.schema;
407
436
  const { getConfig, getLayout } = blockSchema;
408
437
  const { updatedConfig = configData, updatedConfigSchema = blockSchema.config, defaultConfig = {} } = getConfig
409
- ? getConfig({ configSchema: blockSchema.config, config: configData, fields: fieldData })
438
+ ? getConfig({ config: configData, fields: fieldData, block: block.schema })
410
439
  : {};
411
440
  // create new config fields
412
441
  const configFields = fields
@@ -476,6 +505,14 @@ class BlockConfiguration {
476
505
  // force sync
477
506
  this.sync();
478
507
  }
508
+ setConfigValues(config) {
509
+ Object.entries(config).forEach(([fieldId, value]) => {
510
+ const field = this.getEditableField(fieldId);
511
+ if (field) {
512
+ field.value = funnel_core_1.Schema.Field.Data.ForSimpleType.fromValue(field.schema, value);
513
+ }
514
+ });
515
+ }
479
516
  raiseEvent(type) {
480
517
  this.eventBus.publish(BlockConfiguration.Event.create({ type, configuration: this }));
481
518
  }
@@ -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: collectionData } = await collectionRepository.createRaw({
317
+ const { collection } = await collectionRepository.create({
318
318
  template: collectionSchema,
319
319
  language,
320
320
  name,
321
321
  tags: []
322
322
  });
323
- if (!collectionData) {
323
+ if (!collection) {
324
324
  throw new funnel_core_1.IllegalStateError('Failed to create collection');
325
325
  }
326
- // update data
327
- initialData = collectionData;
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: collectionData.data.id,
331
- type: collectionData.data.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(update);
344
- // update collection in store and reset if updated
358
+ const { collection } = await collectionRepository.update(this);
359
+ // update local fields if we have updated collection data
345
360
  if (collection) {
346
- // add to collection store
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
- // update collection store with updated local values
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;
@@ -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('/api/preview', window.location.href);
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<Schema.Page.Content, string>, string>[];
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<Schema.Page.Content, string>;
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;