@nascentdigital/funnel-editor 6.1.2 → 6.1.5

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.
@@ -20,7 +20,6 @@ const funnel_core_1 = require("@nascentdigital/funnel-core");
20
20
  const classnames_1 = __importDefault(require("classnames"));
21
21
  const react_1 = require("motion/react");
22
22
  const react_2 = require("react");
23
- const client_1 = require("../../../client");
24
23
  const hooks_1 = require("../../../hooks");
25
24
  const feedback_1 = require("../../feedback");
26
25
  const interaction_1 = require("../../interaction");
@@ -43,7 +42,7 @@ exports.AssetEditor = (0, react_2.forwardRef)(function AssetEditor(_, ref) {
43
42
  const [error, setError] = (0, react_2.useState)();
44
43
  const { nameField, descriptionField } = (0, useAssetFields_1.useAssetFields)();
45
44
  const [shared, setShared] = (0, react_2.useState)(false);
46
- const editorApi = (0, client_1.useEditorApi)();
45
+ const assetRepository = (0, hooks_1.useAssetRepository)();
47
46
  const assetStore = (0, hooks_1.useAssetStore)();
48
47
  const { valid, modified } = checkFields({ asset, nameField, descriptionField, shared });
49
48
  // export service
@@ -94,7 +93,7 @@ exports.AssetEditor = (0, react_2.forwardRef)(function AssetEditor(_, ref) {
94
93
  // create meta
95
94
  const metadata = await getAssetMetadata({ asset });
96
95
  // upload new file
97
- const updatedAsset = await editorApi.updateAsset({
96
+ const updatedAsset = await assetRepository.update({
98
97
  id: asset.id,
99
98
  name: (_a = funnel_core_1.Schema.TextField.Value.fromData(nameField.value)) !== null && _a !== void 0 ? _a : asset.name,
100
99
  description: descriptionField.exists
@@ -58,7 +58,6 @@ exports.AssetPicker = (0, react_1.forwardRef)(function AssetPicker(_, ref) {
58
58
  // fetch files
59
59
  assetRepo
60
60
  .search({
61
- brand: funnel_core_1.AppConfig.brand(),
62
61
  fileType: fileTypes,
63
62
  scope: assetStore.getSearchScope(),
64
63
  tags: schema.tags.map(funnel_core_1.Schema.Tag.toData),
@@ -7,7 +7,6 @@ exports.CenterSheet = void 0;
7
7
  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
- const framer_motion_1 = require("framer-motion");
11
10
  const react_1 = require("motion/react");
12
11
  const react_2 = require("react");
13
12
  const react_dom_1 = require("react-dom");
@@ -102,7 +101,7 @@ exports.CenterSheet = (0, react_2.forwardRef)(function CenterSheet({ className,
102
101
  }
103
102
  // render
104
103
  return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(react_1.AnimatePresence, { children: open &&
105
- (0, jsx_runtime_1.jsxs)(framer_motion_1.motion.div, { id: id, className: (0, classnames_1.default)('absolute inset-0 z-popup pointer-events-auto', 'flex flex-col justify-stretch items-center pt-l12 px-l6 md:px-l10 lg:px-l15'), variants: Animations.container, onAnimationComplete: definition => onAnimationComplete(definition), initial: "hidden", animate: "visible", exit: "exit", children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0", onClick: onClose }), (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(className, 'relative h-full w-full max-w-[1000px] max-h-full overflow-hidden', 'text-onSurface bg-background rounded-t-lg shadow-objectEditor'), children: children })] }, id) }), anchor);
104
+ (0, jsx_runtime_1.jsxs)(react_1.motion.div, { id: id, className: (0, classnames_1.default)('absolute inset-0 z-popup pointer-events-auto', 'flex flex-col justify-stretch items-center pt-l12 px-l6 md:px-l10 lg:px-l15'), variants: Animations.container, onAnimationComplete: definition => onAnimationComplete(definition), initial: "hidden", animate: "visible", exit: "exit", children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0", onClick: onClose }), (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(className, 'relative h-full w-full max-w-[1000px] max-h-full overflow-hidden', 'text-onSurface bg-background rounded-t-lg shadow-objectEditor'), children: children })] }, id) }), anchor);
106
105
  });
107
106
  // animations
108
107
  var Animations;
@@ -3,7 +3,7 @@ import { StringKeyOf } from 'type-fest';
3
3
  import { BlockConfiguration } from './BlockConfiguration';
4
4
  import { ItemBase } from './ItemBase';
5
5
  import ParentContext = ItemBase.ParentContext;
6
- export declare class Block<TBlock extends Schema.Block = Schema.Block> extends ItemBase<Block<TBlock>> {
6
+ export declare class Block<TBlock extends Block.SchemaType = Block.SchemaType> extends ItemBase<Block<TBlock>> {
7
7
  readonly schema: TBlock;
8
8
  readonly config: ReadonlyArray<FieldModel.Config>;
9
9
  readonly fields: ReadonlyArray<FieldModel>;
@@ -39,6 +39,7 @@ export declare class Block<TBlock extends Schema.Block = Schema.Block> extends I
39
39
  protected onFieldChange(event: Field.Event): void;
40
40
  }
41
41
  export declare namespace Block {
42
+ type SchemaType = Schema.Block | Schema.PanelledBlock;
42
43
  type ConstructorArgs<TBlock extends Schema.Block> = ItemBase.ConstructorArgs & {
43
44
  name?: string;
44
45
  schema: TBlock;
@@ -412,12 +412,17 @@ class BlockConfiguration {
412
412
  }
413
413
  // update layout if different
414
414
  layoutField.value = funnel_core_1.Schema.EnumField.Value.toData(layout);
415
+ // throw if this isn't a paneled layout (shouldn't happen)
416
+ const { schema } = block;
417
+ if (!(schema instanceof funnel_core_1.Schema.PanelledBlock)) {
418
+ throw new funnel_core_1.InvalidOperationError('Cannot set layout on non-PanelledBlock instance');
419
+ }
415
420
  // finish here if no layout change
416
- if (!block.schema.defaultLayoutConfigs) {
421
+ if (!schema.defaultLayoutConfigs) {
417
422
  return;
418
423
  }
419
424
  // set config for layout
420
- const configForLayout = block.schema.defaultLayoutConfigs[layout];
425
+ const configForLayout = schema.defaultLayoutConfigs[layout];
421
426
  if (configForLayout) {
422
427
  this.setConfigValues(configForLayout);
423
428
  }
@@ -433,7 +438,10 @@ class BlockConfiguration {
433
438
  }, {});
434
439
  // get customized schema (if there are effects)
435
440
  const blockSchema = block.schema;
436
- const { getConfig, getLayout } = blockSchema;
441
+ const { getConfig } = blockSchema;
442
+ const getLayout = blockSchema instanceof funnel_core_1.Schema.PanelledBlock
443
+ ? blockSchema.getLayout
444
+ : undefined;
437
445
  const { updatedConfig = configData, updatedConfigSchema = blockSchema.config, defaultConfig = {} } = getConfig
438
446
  ? getConfig({ config: configData, fields: fieldData, block: block.schema })
439
447
  : {};
@@ -35,12 +35,13 @@ export interface IPage extends IAssetStore, ICollectionStore, IPageRefStore, ITa
35
35
  publication: number | undefined;
36
36
  slug: string | undefined;
37
37
  deleteBlock(area: IPage.Area, key: string): void;
38
- getItem(identifier: string | undefined): Block | SectionBlock | Section | PageSettings | undefined;
38
+ getItem(identifier: string | undefined): IPage.Item | undefined;
39
39
  }
40
40
  export declare namespace IPage {
41
41
  type Content = ReadonlyArray<Block | Section>;
42
42
  type Area = 'discover' | 'content';
43
43
  type Savable = Section | Block | FieldModel;
44
+ type Item = Block | SectionBlock | Section | PageSettings;
44
45
  type Errors = {
45
46
  page: IPage;
46
47
  items: Array<Block | SectionBlock>;
@@ -70,11 +70,11 @@ export declare class Page implements IAssetStore, ICollectionStore, IPageRefStor
70
70
  get displayName(): string | Schema.Field.Data.ForSimpleType<Schema.TextField>;
71
71
  get discover(): ReadonlyArray<Block>;
72
72
  get content(): ReadonlyArray<Section | Block>;
73
- get seo(): Block<Schema.Block<string, any, any>>;
74
- get blocks(): (Block<Schema.Block<string, any, any>> | SectionBlock<Schema.Block<string, any, any>>)[];
73
+ get seo(): Block<Block.SchemaType>;
74
+ get blocks(): (Block<Block.SchemaType> | SectionBlock<Schema.Block<string, any, any>>)[];
75
75
  get deleteBlocks(): ReadonlyArray<Block>;
76
- get firstBlock(): Block<Schema.Block<string, any, any>> | SectionBlock<Schema.Block<string, any, any>> | undefined;
77
- get firstItem(): Section | Block<Schema.Block<string, any, any>>;
76
+ get firstBlock(): Block<Block.SchemaType> | SectionBlock<Schema.Block<string, any, any>> | undefined;
77
+ get firstItem(): Section | Block<Block.SchemaType>;
78
78
  get published(): boolean;
79
79
  get modified(): boolean;
80
80
  get updatedOn(): number;
@@ -23,7 +23,7 @@ export declare class Section extends ItemBase<Section> {
23
23
  get missingBlocks(): number;
24
24
  get canAddBlocks(): boolean;
25
25
  bind(parentContext: ItemBase.ParentContext): void;
26
- addBlock(identifier: string): SectionBlock<Schema.Block<string, any, any>>;
26
+ addBlock(identifier: string): SectionBlock<Block.SchemaType>;
27
27
  deleteBlock(id: SectionBlock.Id): undefined;
28
28
  moveBlock(blockId: SectionBlock.Id, newIndex: number): SectionBlock<Schema.Block<string, any, any>> | undefined;
29
29
  repair(): void;
@@ -42,8 +42,10 @@ class Section extends ItemBase_1.ItemBase {
42
42
  || _blocks.some(block => block.modified);
43
43
  }
44
44
  get valid() {
45
- // TODO: validate against section level rules
46
- return this.blocks.every(block => block.valid);
45
+ const { blocks, schema: { min, max } } = this;
46
+ return (blocks.length >= min
47
+ && blocks.length <= max
48
+ && blocks.every(block => block.valid));
47
49
  }
48
50
  get changes() {
49
51
  return {
@@ -26,7 +26,7 @@ export declare class SectionBlock<TBlock extends Schema.Block = Schema.Block> ex
26
26
  getConfiguration(): BlockConfiguration;
27
27
  bind(parentContext: ItemBase.ParentContext): void;
28
28
  repair(): void;
29
- static for({ block, parentContext }: SectionBlock.ForArgs): SectionBlock<Schema.Block<string, any, any>>;
29
+ static for({ block, parentContext }: SectionBlock.ForArgs): SectionBlock<Block.SchemaType>;
30
30
  }
31
31
  export declare namespace SectionBlock {
32
32
  type Id = Tagged<string, 'SectionBlock.Id'>;
@@ -1,6 +1,6 @@
1
1
  import { IPage } from '../domain';
2
- export declare function usePossiblePage(newPage?: IPage): IPage | undefined;
3
- export declare function usePage(newPage?: IPage): IPage;
2
+ export declare function usePossiblePage<TPage extends IPage = IPage>(newPage?: TPage): TPage | undefined;
3
+ export declare function usePage<TPage extends IPage = IPage>(newPage?: TPage): TPage;
4
4
  export declare const PageContext: import("react").Context<PageContext.Data>;
5
5
  export declare namespace PageContext {
6
6
  type Data = {
@@ -7,7 +7,7 @@ export interface IAssetRepository {
7
7
  }
8
8
  export declare namespace IAssetRepository {
9
9
  namespace Search {
10
- type Args = AssetClient.GetAssets.Args;
10
+ type Args = Omit<AssetClient.GetAssets.Args, 'brand'>;
11
11
  type Result = AssetClient.GetAssets.Result;
12
12
  }
13
13
  namespace Get {
@@ -501,10 +501,10 @@ video {
501
501
  }
502
502
 
503
503
  [popover]{
504
- inset: var(--toolwind-toggle-P1jy2UBqoP, 0px);
505
- background-color: var(--toolwind-toggle-sNXb0Mo8fj, canvas);
506
- color: var(--toolwind-toggle-qB02Svyt5l, canvastext);
507
- margin: var(--toolwind-toggle-p8tQUweuhM, auto);
504
+ inset: var(--toolwind-toggle-wrtbt8ZKY2, 0px);
505
+ background-color: var(--toolwind-toggle-x97g0FbT5G, canvas);
506
+ color: var(--toolwind-toggle-PleWOGPwR6, canvastext);
507
+ margin: var(--toolwind-toggle-SZfCM678rP, auto);
508
508
  }
509
509
  html, body, #__next, #root, .Editor-wrap{
510
510
  position: relative;
@@ -6012,10 +6012,10 @@ img.nd-Visual-image {
6012
6012
  .anchored\/\[--nd-popup-anchor\]:where(.anchored\/\[--nd-popup-anchor\]){
6013
6013
  position: absolute;
6014
6014
  view-transition-name: --tw-anchor-view-transition-2j1919322s193433343934192p322r2w33362l;
6015
- --toolwind-toggle-P1jy2UBqoP: auto;
6016
- --toolwind-toggle-sNXb0Mo8fj: transparent;
6017
- --toolwind-toggle-qB02Svyt5l: inherit;
6018
- --toolwind-toggle-p8tQUweuhM: 0px;
6015
+ --toolwind-toggle-wrtbt8ZKY2: auto;
6016
+ --toolwind-toggle-x97g0FbT5G: transparent;
6017
+ --toolwind-toggle-PleWOGPwR6: inherit;
6018
+ --toolwind-toggle-SZfCM678rP: 0px;
6019
6019
  }
6020
6020
  .counter-l1{
6021
6021
  counter-reset: l1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nascentdigital/funnel-editor",
3
- "version": "6.1.2",
3
+ "version": "6.1.5",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -92,5 +92,5 @@
92
92
  "ts-jest": "^29",
93
93
  "type-fest": "^4"
94
94
  },
95
- "gitHead": "d72a93d505884f030d595ecf66c64351ebfc8ed1"
95
+ "gitHead": "567edc7796b910ef548506fd659f267b80187c29"
96
96
  }