@webx-ui/module-blocks 0.14.0 → 0.16.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.
@@ -51,21 +51,23 @@ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {},
51
51
  reload?: number;
52
52
  compact?: boolean;
53
53
  hidden?: string[];
54
+ region?: string | null;
54
55
  }> & Readonly<{
55
- onSelect?: ((key: string | null) => any) | undefined;
56
56
  onEdit?: (() => any) | undefined;
57
+ onSelect?: ((key: string | null) => any) | undefined;
57
58
  }>, {
58
59
  replace: (key: string, html: string) => boolean;
59
60
  refresh: () => void;
60
61
  open: () => boolean;
61
62
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
62
- select: (key: string | null) => any;
63
63
  edit: () => any;
64
+ select: (key: string | null) => any;
64
65
  }, import('vue').PublicProps, {
66
+ reload: number;
67
+ region: string | null;
65
68
  hidden: string[];
66
69
  selected: string | null;
67
70
  compact: boolean;
68
- reload: number;
69
71
  }, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {
70
72
  bar: HTMLDivElement;
71
73
  box: HTMLDivElement;
@@ -83,18 +85,20 @@ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {},
83
85
  reload?: number;
84
86
  compact?: boolean;
85
87
  hidden?: string[];
88
+ region?: string | null;
86
89
  }> & Readonly<{
87
- onSelect?: ((key: string | null) => any) | undefined;
88
90
  onEdit?: (() => any) | undefined;
91
+ onSelect?: ((key: string | null) => any) | undefined;
89
92
  }>, {
90
93
  replace: (key: string, html: string) => boolean;
91
94
  refresh: () => void;
92
95
  open: () => boolean;
93
96
  }, {}, {}, {}, {
97
+ reload: number;
98
+ region: string | null;
94
99
  hidden: string[];
95
100
  selected: string | null;
96
101
  compact: boolean;
97
- reload: number;
98
102
  }> | null;
99
103
  }, any>;
100
104
  export default _default;
@@ -19,6 +19,11 @@ type __VLS_Props = {
19
19
  compact?: boolean;
20
20
  /** Keys of the blocks switched off: marked in the page until it reloads without them. */
21
21
  hidden?: string[];
22
+ /**
23
+ * A region to frame and scroll to: a shared block, which is wherever the page placed it and
24
+ * not where a header always is — down the page under the content, more often than not.
25
+ */
26
+ region?: string | null;
22
27
  };
23
28
  /** Swap one block's markup in place; false when the page has to be reloaded instead. */
24
29
  declare function replace(key: string, html: string): boolean;
@@ -28,16 +33,17 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {
28
33
  refresh: typeof refresh;
29
34
  open: () => boolean;
30
35
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
31
- select: (key: string | null) => any;
32
36
  edit: () => any;
37
+ select: (key: string | null) => any;
33
38
  }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
34
- onSelect?: ((key: string | null) => any) | undefined;
35
39
  onEdit?: (() => any) | undefined;
40
+ onSelect?: ((key: string | null) => any) | undefined;
36
41
  }>, {
42
+ reload: number;
43
+ region: string | null;
37
44
  hidden: string[];
38
45
  selected: string | null;
39
46
  compact: boolean;
40
- reload: number;
41
47
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
42
48
  bar: HTMLDivElement;
43
49
  box: HTMLDivElement;
@@ -0,0 +1,30 @@
1
+ import { SiteBarContext } from '@webx-ui/module-admin';
2
+ /**
3
+ * The «Blocks» tab of the panel on the site (WEBX_UI_SITE_BAR.md, §8–§9, SB4).
4
+ *
5
+ * Two states, like the constructor's narrow column: maps of the blocks, or one block's fields.
6
+ * The maps are the record's — the page behind the address — and the layout's regions', the
7
+ * header and the footer, each under its own name; a row under the pointer frames its block on the
8
+ * page. The pencil is the way from the page: with it on, a click on a block picks it there
9
+ * instead of following its link, whichever tree it belongs to.
10
+ *
11
+ * The form is the constructor's own — the block's schema through the same steps, drawn by the
12
+ * same renderer with the panel's field types — and its values are the draft's, never the
13
+ * site's: an edit goes into the draft of whatever holds the block, and a form that showed what
14
+ * is published would write over whatever a colleague prepared. «Save» writes the fields that
15
+ * changed and puts the block, drawn from the draft, in place of the old one on the page.
16
+ *
17
+ * The record's draft is published from the head of the bar; a region's — with its own buttons
18
+ * over its map and over the form of its block, since it is a draft of its own and goes on every
19
+ * page at once.
20
+ *
21
+ * The structure too (SB5): a block added — below another, at the end of a tree, inside a
22
+ * container — duplicated, moved up or down, hidden, shown or deleted, each one an operation of the
23
+ * agent's dictionary into the same draft. The picker is the constructor's, held to the same rules
24
+ * of the place; what cannot be done right now is greyed with the reason rather than missing.
25
+ */
26
+ type __VLS_Props = {
27
+ context: SiteBarContext;
28
+ };
29
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
30
+ export default _default;
@@ -25,21 +25,21 @@ type __VLS_Props = {
25
25
  };
26
26
  declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
27
27
  add: (parentKey: string | null, field: string | null, node: ScreenNode | null, index?: number | undefined) => any;
28
- remove: (key: string) => any;
28
+ move: (key: string) => any;
29
29
  duplicate: (key: string) => any;
30
+ remove: (key: string) => any;
30
31
  copy: (key: string) => any;
31
32
  paste: (parentKey: string | null, field: string | null, node: ScreenNode | null, index?: number | undefined) => any;
32
- move: (key: string) => any;
33
33
  select: (key: string) => any;
34
34
  visibility: (key: string, hidden: boolean) => any;
35
35
  reorder: (parentKey: string | null, field: string | null, list: BlockNode[]) => any;
36
36
  }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
37
37
  onAdd?: ((parentKey: string | null, field: string | null, node: ScreenNode | null, index?: number | undefined) => any) | undefined;
38
- onRemove?: ((key: string) => any) | undefined;
38
+ onMove?: ((key: string) => any) | undefined;
39
39
  onDuplicate?: ((key: string) => any) | undefined;
40
+ onRemove?: ((key: string) => any) | undefined;
40
41
  onCopy?: ((key: string) => any) | undefined;
41
42
  onPaste?: ((parentKey: string | null, field: string | null, node: ScreenNode | null, index?: number | undefined) => any) | undefined;
42
- onMove?: ((key: string) => any) | undefined;
43
43
  onSelect?: ((key: string) => any) | undefined;
44
44
  onVisibility?: ((key: string, hidden: boolean) => any) | undefined;
45
45
  onReorder?: ((parentKey: string | null, field: string | null, list: BlockNode[]) => any) | undefined;
@@ -0,0 +1,17 @@
1
+ import { RegionRow } from './types';
2
+ type __VLS_Props = {
3
+ modelValue?: string | null;
4
+ disabled?: boolean;
5
+ /** The shared blocks to choose from. Fetched from the panel when absent — a demo hands them in. */
6
+ fragments?: RegionRow[] | null;
7
+ };
8
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
9
+ "update:modelValue": (value: string | null) => any;
10
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
11
+ "onUpdate:modelValue"?: ((value: string | null) => any) | undefined;
12
+ }>, {
13
+ modelValue: string | null;
14
+ disabled: boolean;
15
+ fragments: RegionRow[] | null;
16
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
17
+ export default _default;
@@ -0,0 +1,28 @@
1
+ import { SiteBarRegion } from './types';
2
+ /**
3
+ * A region's unpublished draft in the panel on the site, with the buttons that publish it or
4
+ * throw it away.
5
+ *
6
+ * Drawn over the region's map and over the form of one of its blocks alike: the head of the bar
7
+ * speaks for the record only, so the form is where an editor who has just saved a block of the
8
+ * footer is looking — and a notice that only the map carried was found after a reload.
9
+ */
10
+ type __VLS_Props = {
11
+ region: SiteBarRegion;
12
+ /** This region's publication or discard is under way. */
13
+ busy?: boolean;
14
+ /** Another region's is: one at a time, since each reloads the page. */
15
+ blocked?: boolean;
16
+ /** Why the publication was refused — the blocks of the draft that fail. */
17
+ refusals?: string[];
18
+ /** The region's draft drawn on this page: after a reload the page shows the site again. */
19
+ preview?: string | null;
20
+ };
21
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
22
+ publish: () => any;
23
+ discard: () => any;
24
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
25
+ onPublish?: (() => any) | undefined;
26
+ onDiscard?: (() => any) | undefined;
27
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
28
+ export default _default;
package/dist/api.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AdminContext } from '@webx-ui/module-admin';
2
- import { BlockExport, BlockImportRow, BlockInput, BlockList, BlockType, BlockUsage, BlockVersion, BlockNode, BlockVersionMeta, RegionAdopted, RegionDetail, RegionRow, RegionVersion, RenderInput, RenderResult } from './types';
2
+ import { BlockExport, BlockImportRow, BlockInput, BlockList, BlockType, BlockUsage, BlockVersion, BlockNode, BlockVersionMeta, RegionAdopted, RegionDetail, RegionRow, RegionVersion, RenderInput, RenderResult, SiteBarBlockEdit, SiteBarBlockEdited, SiteBarBlocks } from './types';
3
3
  export interface BlocksApi {
4
4
  /** Every type, without content: the section's list. */
5
5
  list(): Promise<BlockType[]>;
@@ -19,6 +19,8 @@ export interface BlocksApi {
19
19
  }): Promise<BlockType>;
20
20
  render(id: number, input?: RenderInput): Promise<RenderResult>;
21
21
  usage(id: number): Promise<BlockUsage[]>;
22
+ /** The shared blocks a page may place, with their state; open to whoever reads the catalog. */
23
+ fragments(): Promise<RegionRow[]>;
22
24
  versions(id: number): Promise<BlockVersionMeta[]>;
23
25
  version(id: number, number: number): Promise<BlockVersion>;
24
26
  restore(id: number, number: number): Promise<BlockType>;
@@ -40,6 +42,17 @@ export interface BlocksApi {
40
42
  }
41
43
  /** Everything under `/blocks`, below the panel's API path. */
42
44
  export declare function createBlocksApi(admin: AdminContext): BlocksApi;
45
+ export interface SiteBarBlocksApi {
46
+ /** A record's blocks: the draft's, or the site's when there is no draft. */
47
+ read(type: string, id: number | string): Promise<SiteBarBlocks>;
48
+ /**
49
+ * One block's fields into the record's draft. A revision that moved is answered 409 — the
50
+ * error's body names who moved it.
51
+ */
52
+ edit(type: string, id: number | string, input: SiteBarBlockEdit): Promise<SiteBarBlockEdited>;
53
+ }
54
+ /** The two addresses of the «Blocks» tab of the panel on the site, by the record's address type. */
55
+ export declare function createSiteBarBlocksApi(admin: AdminContext): SiteBarBlocksApi;
43
56
  export interface RegionsApi {
44
57
  /** Every region the site's config declares, saved or not. */
45
58
  list(): Promise<RegionRow[]>;
@@ -62,6 +75,11 @@ export interface RegionsApi {
62
75
  restoreVersion(name: string, number: number): Promise<RegionDetail>;
63
76
  /** The fallback view made into a block type, and one of it put into the draft. */
64
77
  adopt(name: string): Promise<RegionAdopted>;
78
+ /**
79
+ * A shared block's published tree with fresh keys, to put in a page in its place. Writes nothing;
80
+ * 409 while the shared block is not published.
81
+ */
82
+ copy(name: string): Promise<BlockNode[]>;
65
83
  }
66
84
  /** Everything under `/regions`, below the panel's API path. */
67
85
  export declare function createRegionsApi(admin: AdminContext): RegionsApi;
package/dist/content.d.ts CHANGED
@@ -44,6 +44,11 @@ export declare function cloneNode(node: BlockNode): BlockNode;
44
44
  * save says so.
45
45
  */
46
46
  export declare function setHidden(tree: BlockNode[], key: string, hidden: boolean): BlockNode[];
47
+ /**
48
+ * One block taken out and others put where it stood, in its list — what «Make it this page's own»
49
+ * does to a shared block. The tree as it was when the key is not in it.
50
+ */
51
+ export declare function swapNode(tree: BlockNode[], key: string, nodes: BlockNode[]): BlockNode[];
47
52
  export declare function insertNode(tree: BlockNode[], parentKey: string | null, field: string | null, index: number, node: BlockNode): BlockNode[];
48
53
  export declare function removeNode(tree: BlockNode[], key: string): BlockNode[];
49
54
  export declare function updateValues(tree: BlockNode[], key: string, values: Record<string, unknown>): BlockNode[];
package/dist/frame.d.ts CHANGED
@@ -15,14 +15,44 @@ export interface MarkerRange {
15
15
  }
16
16
  /** The pair of markers around a block, or null when the page does not hold it. */
17
17
  export declare function findRange(root: Node, key: string): MarkerRange | null;
18
+ /**
19
+ * The pair around a region — `<!--wx-region:name-->` — which the region's own preview prints
20
+ * whatever the region holds, its fallback included.
21
+ */
22
+ export declare function findRegion(root: Node, name: string): MarkerRange | null;
18
23
  /**
19
24
  * Swap the block's markup — markers included, since the new HTML carries its own — and let
20
25
  * the runtime mount whatever script the new markup needs. False when the key is not on the
21
26
  * page, which means the page has to be reloaded rather than patched.
22
27
  */
23
28
  export declare function replaceBlock(doc: Document, key: string, html: string): boolean;
24
- /** The first element a block prints — where a highlight goes. */
29
+ /**
30
+ * The element a block is pointed at by — the outline, the scroll: the first one it prints that
31
+ * takes room on the page. One that draws nothing at all, or where the layout cannot be measured,
32
+ * gives the first it prints that could.
33
+ */
25
34
  export declare function blockElement(root: Node, key: string): Element | null;
35
+ /**
36
+ * Where a region stands on the page: one box around everything it printed, in the page's own
37
+ * coordinates. Null when the page does not print it, or it printed nothing that takes room.
38
+ */
39
+ export declare function regionRect(doc: Document, name: string): {
40
+ top: number;
41
+ left: number;
42
+ width: number;
43
+ height: number;
44
+ } | null;
45
+ export declare const REGION_FRAME_ID = "wx-preview-region";
46
+ /**
47
+ * Draw a frame around a region of the page, or take it away (null).
48
+ *
49
+ * A box laid over the page rather than a class on an element, as a block has: a region is any
50
+ * number of blocks side by side, and wrapping them in an element of ours would break the site's
51
+ * own rules — `.site-main > section` stops matching the moment there is a `div` in between.
52
+ * Hangs off the root element and not the body, which a site may have positioned: there its top
53
+ * is the page's top, whatever the body's margins.
54
+ */
55
+ export declare function frameRegion(doc: Document, name: string | null): void;
26
56
  /** Mark one block as the selected one, and nothing else. Null clears the selection. */
27
57
  export declare function highlightBlock(doc: Document, key: string | null): Element | null;
28
58
  export declare const HIDDEN_CLASS = "wx-preview-hidden";
package/dist/i18n.d.ts CHANGED
@@ -1,2 +1,8 @@
1
+ import { I18n } from '@webx-ui/module-admin';
2
+ /**
3
+ * Puts this package's English under a panel's dictionary, once per panel. For what runs outside
4
+ * a component's setup — the label of a tab on the panel on the site is asked for by the frame.
5
+ */
6
+ export declare function seedBlocksMessages(i18n: I18n): void;
1
7
  /** Puts this package's English under the panel's dictionary, once per panel. */
2
8
  export declare function useBlocksMessages(): void;
package/dist/index.d.ts CHANGED
@@ -1,17 +1,19 @@
1
1
  export { blocks, regions, type BlocksOptions, type RegionsOptions } from './module';
2
- export { createBlocksApi, createRegionsApi, type BlocksApi, type RegionsApi } from './api';
2
+ export { createBlocksApi, createRegionsApi, createSiteBarBlocksApi, type BlocksApi, type RegionsApi, type SiteBarBlocksApi, } from './api';
3
3
  export { blocksMessages } from './messages';
4
- export { blocksPreviewKey, blocksTopKey, provideBlocksPreview, provideBlocksTop, useBlocksPreview, type BlocksPreview, type BlocksTop, } from './preview';
5
- export { cloneNode, countType, insertNode, isNode, isNodeList, locate, makeNode, newKey, removeNode, replaceList, typesIn, updateValues, walk, type Located, } from './content';
4
+ export { blocksFragmentKey, blocksPreviewKey, blocksTopKey, provideBlocksPreview, provideBlocksTop, useBlocksPreview, type BlocksFragmentHost, type BlocksPreview, type BlocksTop, } from './preview';
5
+ export { cloneNode, countType, insertNode, isNode, isNodeList, locate, makeNode, newKey, removeNode, replaceList, swapNode, typesIn, updateValues, walk, type Located, } from './content';
6
6
  export { lintBlock, undeclared } from './lint';
7
- export { findRange, highlightBlock, replaceBlock, stageDocument } from './frame';
7
+ export { findRange, findRegion, frameRegion, highlightBlock, regionRect, replaceBlock, stageDocument, } from './frame';
8
8
  export { callTag, formSchema, kindOf } from './schema';
9
9
  export { default as WxBlocks } from './BlocksField';
10
+ export { default as WxBlocksSiteBarTab } from './BlocksSiteBarTab';
10
11
  export { default as WxBlocksPage } from './BlocksPage';
11
12
  export { default as WxBlockEditorPage } from './BlockEditorPage';
12
13
  export { default as WxBlockPicker } from './BlockPicker';
13
14
  export { default as WxBlockThumb } from './BlockThumb';
14
15
  export { default as WxBlockStage } from './BlockStage';
16
+ export { default as WxFragmentField } from './FragmentField';
15
17
  export { default as WxRegionsPage } from './RegionsPage';
16
18
  export { default as WxRegionEditorPage } from './RegionEditorPage';
17
- export type { BlockContent, BlockInput, BlockKind, BlockList, BlockNode, BlockParent, BlockSource, BlocksMeta, BlockThumbnail, BlockType, BlockUsage, BlockVersion, BlockVersionMeta, DeclaredComponent, Lint, PublishRefusal, RegionAdopted, RegionConflict, RegionDetail, RegionRow, RegionVersion, RenderInput, RenderResult, ShapeField, } from './types';
19
+ export type { BlockContent, BlockInput, BlockKind, BlockList, BlockNode, BlockParent, BlockSource, BlocksMeta, BlockThumbnail, BlockType, BlockUsage, BlockVersion, BlockVersionMeta, DeclaredComponent, FragmentUse, Lint, PublishRefusal, RegionAdopted, RegionConflict, RegionDetail, RegionRow, RegionVersion, RenderInput, RenderResult, ShapeField, } from './types';