@bluepic/embed 0.6.49 → 0.6.51

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.
@@ -1,4 +1,4 @@
1
- import { Studio } from '@bluepic/types';
1
+ import { Studio, V4 } from '@bluepic/types';
2
2
  import { z } from '@hono/zod-openapi';
3
3
  /**
4
4
  * The floor every descriptor shape this file handles satisfies — the legacy
@@ -116,4 +116,86 @@ export declare function flatPortalItems<T extends BaseTemplateDescriptor>(templa
116
116
  export declare function collectPortalCategories<T extends BaseTemplateDescriptor>(templates: {
117
117
  [k: string]: T;
118
118
  }, assets: PortalAsset[] | undefined, categories: CampaignCategory[] | undefined): string[];
119
+ export type PageStructure = V4.PageStructure;
120
+ /** A rendered entry of a page section: a portal item (name group / asset) or a group ref (the host builds the folder card). */
121
+ export type PageGalleryCard<T> = PortalItem<T> | {
122
+ kind: 'group';
123
+ id: string;
124
+ };
125
+ export type PageGallerySection<T> = V4.PageNavigationSection & {
126
+ /** Cards in display order. Group refs stay refs; group members are not expanded here. */
127
+ cards: PageGalleryCard<T>[];
128
+ };
129
+ export type PageGallery<T> = Omit<V4.PageNavigation, 'sections'> & {
130
+ sections: PageGallerySection<T>[];
131
+ };
132
+ export type PageGalleryOptions = {
133
+ /** `?tab=` token or subpage id. Unknown → the first visible subpage. */
134
+ activeSubpage?: string | null;
135
+ /** What the layout shows. Default `V4.PAGE_LAYOUT_FULL` (Gallery); strip and sidebar pass `V4.PAGE_LAYOUT_FLAT`. */
136
+ layout?: V4.PageLayoutCapabilities;
137
+ /** Edit mode: empty subpages and sections count and are returned. */
138
+ includeEmpty?: boolean;
139
+ /** `false` (version 2+ pages): every template is its own card. Default: same-named templates merge (legacy). */
140
+ mergeSameName?: boolean;
141
+ };
142
+ /**
143
+ * The cards of ONE list of refs (a section, or a flat layout's merged list).
144
+ * Leaf refs become portal items: same-named templates merge into one card at
145
+ * their first member's slot (unless `mergeSameName` is false), exactly as
146
+ * `orderPortalItems` does for a category. A group ref keeps its slot. Refs
147
+ * whose data is missing are skipped.
148
+ */
149
+ export declare function pageSectionCards<T extends BaseTemplateDescriptor>(items: readonly V4.PageItemRef[], templates: {
150
+ [k: string]: T;
151
+ }, assets: readonly PortalAsset[] | undefined, mergeSameName?: boolean): PageGalleryCard<T>[];
152
+ /**
153
+ * The page as the visitor (or the editor) sees it: tabs, anchors and the
154
+ * sections of the active subpage with their cards. Counted over what has data:
155
+ * a template missing from `templates` or an asset missing from `assets` is not
156
+ * visible, and a group shows when one of its members is.
157
+ */
158
+ export declare function buildPageGallery<T extends BaseTemplateDescriptor>(structure: PageStructure, templates: {
159
+ [k: string]: T;
160
+ }, assets: readonly PortalAsset[] | undefined, options?: PageGalleryOptions): PageGallery<T>;
161
+ export type LegacyPageStructure = {
162
+ structure: PageStructure;
163
+ /** Section id → index into `config.categories`; `null` for the uncategorised (or only) section. */
164
+ categoryIndex: Record<string, number | null>;
165
+ /** Top-level group id → the member whose slot its card takes (edit mode puts it first in the card's ids). */
166
+ slotLeaf: Record<string, string>;
167
+ /** The page has a manual order. `false` → the order was seeded alphabetically (placeholders cannot be placed). */
168
+ manualOrder: boolean;
169
+ };
170
+ export type LegacyPageStructureOptions = {
171
+ /** The page id (container ids are derived from it). */
172
+ pageId: string | number;
173
+ /**
174
+ * Categories are rendered as sections. Legacy pages show them only with
175
+ * `config.sortByCategories` on and in the Gallery layout; otherwise the page
176
+ * is ONE unnamed section in the global order, exactly as it renders today.
177
+ */
178
+ showCategories: boolean;
179
+ /** `Studio.campaignMergesSameNameTemplates(config)`. Default true (legacy merge). */
180
+ mergeSameName?: boolean;
181
+ /** A template / asset id whose data has not arrived (a placeholder). Placed after the known ones in an alphabetical order. */
182
+ isPending?: (id: string) => boolean;
183
+ };
184
+ /**
185
+ * A structure from the v3 fields (`config.categories`, `config.order`,
186
+ * `config.groups`) for what the page has data for. Built with
187
+ * `V4.pageStructureFromLegacy`, with the alphabetical order of a page without
188
+ * `config.order` written down first with the gallery's own comparator
189
+ * (`localeCompare` in this browser), so the result renders card for card what
190
+ * `groupPortalItemsByCategory` / `flatPortalItems` render.
191
+ *
192
+ * Group ids stay the legacy ones (the studio's editor protocol addresses them).
193
+ */
194
+ export declare function legacyPageStructure<T extends BaseTemplateDescriptor>(config: {
195
+ categories?: unknown;
196
+ order?: unknown;
197
+ groups?: unknown;
198
+ } | null | undefined, templates: {
199
+ [k: string]: T;
200
+ }, assets: readonly PortalAsset[] | undefined, options: LegacyPageStructureOptions): LegacyPageStructure;
119
201
  export {};
@@ -1,8 +1,20 @@
1
1
  import { VNode } from 'vue';
2
- export declare function useSlotVNodes(slot: (...args: any[]) => VNode[] | VNode): {
2
+ type SlotFn = (...args: any[]) => VNode[] | VNode;
3
+ /**
4
+ * Renders a slot (usually `trigger`) as a list of VNodes and collects the DOM
5
+ * elements they mount to.
6
+ *
7
+ * Takes a GETTER for the slot, not the slot itself: when the parent re-renders,
8
+ * Vue swaps in a new slot function on `slots`, and a function captured at setup
9
+ * keeps rendering the old closure forever. That froze trigger contents (labels,
10
+ * click handlers of v-for items). `onBeforeUpdate` dirties the VNode list so
11
+ * every render of the owner calls the current slot function.
12
+ */
13
+ export declare function useSlotVNodes(getSlot: () => SlotFn | undefined): {
3
14
  setSlotRef: (index: number) => (vnode: any) => void;
4
15
  slotElements: import("vue").Ref<Node[], Node[]>;
5
16
  vNodes: import("vue").ComputedRef<VNode<import("vue").RendererNode, import("vue").RendererElement, {
6
17
  [key: string]: any;
7
18
  }>[]>;
8
19
  };
20
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluepic/embed",
3
- "version": "0.6.49",
3
+ "version": "0.6.51",
4
4
  "description": "Bluepic embed sdk",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -46,14 +46,15 @@
46
46
  "test:imagestates": "tsx src/util/imageStates/imageStates.test.ts",
47
47
  "test:imageaspect": "tsx src/util/imageAspect/imageAspect.test.ts",
48
48
  "test:blankdata": "tsx src/util/blankData.test.ts",
49
- "test:fieldstatus": "tsx src/util/fieldStatus.test.ts"
49
+ "test:fieldstatus": "tsx src/util/fieldStatus.test.ts",
50
+ "test:slotvnodes": "tsx src/util/slotVNodes.test.ts"
50
51
  },
51
52
  "peerDependencies": {
52
53
  "vue": "^3.5.23"
53
54
  },
54
55
  "devDependencies": {
55
56
  "@auth0/auth0-vue": "^2.4.0",
56
- "@bluepic/types": "^0.9.56",
57
+ "@bluepic/types": "^0.9.62",
57
58
  "@hono/zod-openapi": "^1.1.4",
58
59
  "@types/css": "^0.0.38",
59
60
  "@types/downloadjs": "^1.4.6",