@designcrowd/library.brand-page 6.0.0 → 6.0.1-ast-bg-shape
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/lib/src/{CreatedOnBrandCrowd-de-de-BhimVEpD.js → CreatedOnBrandCrowd-de-de-Dxp4ebC_.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-en-us-CcBSmedR.js → CreatedOnBrandCrowd-en-us-2m-52z9q.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-es-es-Bywf3OqP.js → CreatedOnBrandCrowd-es-es-vyViBkgn.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-fr-CWpYmK2m.js → CreatedOnBrandCrowd-fr-ca-WKIdCeR9.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-ca-CWpYmK2m.js → CreatedOnBrandCrowd-fr-fr-WKIdCeR9.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-pt-DHM9G51s.js → CreatedOnBrandCrowd-pt-br-C5gZ1FOh.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-br-DHM9G51s.js → CreatedOnBrandCrowd-pt-pt-C5gZ1FOh.js} +1 -1
- package/lib/src/{CreatedOnDcom-de-de-BnUSIarY.js → CreatedOnDcom-de-de-DvS2wMv_.js} +1 -1
- package/lib/src/{CreatedOnDcom-en-us-DzU8X52o.js → CreatedOnDcom-en-us-C9LSUVh8.js} +1 -1
- package/lib/src/{CreatedOnDcom-es-es-rpp-c_OZ.js → CreatedOnDcom-es-es-DTrd5sLX.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-ca-MJ7nCJTH.js → CreatedOnDcom-fr-ca-BRC4S6qm.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-fr-B3USPvBZ.js → CreatedOnDcom-fr-fr-B0vfWw2S.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-br-DJv7sfEZ.js → CreatedOnDcom-pt-br-7SFPnAev.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-pt-DAPP7A-E.js → CreatedOnDcom-pt-pt-DYLzspou.js} +1 -1
- package/lib/src/brand-page/models/index.d.ts +2 -0
- package/lib/src/brand-page/models/index.js +2 -0
- package/lib/src/brand-page-maker/components/admin-background-settings/AdminBackgroundSettings.mixin.d.ts +19 -18
- package/lib/src/brand-page-maker/components/admin-background-settings/AdminBackgroundSettings.mixin.js +3 -54
- package/lib/src/brand-page-maker/stores/ai-checkpoint/ai-checkpoint-store.d.ts +6 -0
- package/lib/src/{bundled-translations-BUyt4scr.js → bundled-translations-CgiJ3pXh.js} +1 -1
- package/lib/src/bundles/bundled-translations.json +9 -1
- package/lib/src/composables/useSnapshot.js +18 -18
- package/lib/src/index.mjs +1 -1
- package/lib/src/{lib-Cfx4mNMR.js → lib-Dfr7gLQv.js} +22006 -21796
- package/lib/src/metadata-builder/builders/footer-builder.js +103 -70
- package/lib/src/metadata-builder/builders/section-field-utils.d.ts +7 -0
- package/lib/src/metadata-builder/builders/section-field-utils.js +1 -1
- package/lib/src/metadata-builder/parsers/ai-toolcall-parser.d.ts +3 -3
- package/lib/src/shared/background-settings/background-settings-models.d.ts +2 -2
- package/lib/src/shared/background-settings/components/background-shapes/BackgroundShapeSettings.mixin.d.ts +11 -0
- package/lib/src/shared/background-settings/composables/useBackgroundShapeControls.d.ts +40 -0
- package/lib/src/shared/background-settings/composables/useBackgroundShapeControls.js +58 -0
- package/lib/src/shared/background-settings/composables/useSingleBackgroundShape.d.ts +21 -0
- package/lib/src/shared/background-settings/composables/useSingleBackgroundShape.js +51 -0
- package/lib/src/shared/background-settings/store/background-settings-store.d.ts +11 -1
- package/lib/src/shared/background-settings/store/background-settings-store.js +24 -0
- package/lib/src/shared/content-settings/components/radio-field/RadioField.mixin.d.ts +1 -1
- package/lib/src/shared/style-settings/components/StyleSettings.mixin.d.ts +10 -0
- package/package.json +1 -1
- package/src/brand-page/models/index.ts +5 -0
- package/src/brand-page/utils/__snapshots__/migration.util.test.ts.snap +3 -0
- package/src/brand-page/utils/__snapshots__/migration2.util.test.ts.snap +1 -0
- package/src/brand-page/utils/__snapshots__/model.util.test.ts.snap +2 -0
- package/src/brand-page-maker/components/admin-background-settings/AdminBackgroundSettings.mixin.ts +3 -88
- package/src/bundles/bundled-translations.json +9 -1
- package/src/composables/useSnapshot.ts +19 -22
- package/src/metadata-builder/builders/footer-builder.test.ts +200 -1
- package/src/metadata-builder/builders/footer-builder.ts +151 -95
- package/src/metadata-builder/builders/section-field-utils.ts +1 -1
- package/src/metadata-builder/parsers/ai-toolcall-parser.ts +3 -3
- package/src/shared/background-settings/background-settings-models.ts +3 -2
- package/src/shared/background-settings/components/BackgroundSettings.vue +79 -114
- package/src/shared/background-settings/components/MultiBackgroundShapes.vue +304 -0
- package/src/shared/background-settings/components/SingleBackgroundShape.vue +106 -0
- package/src/shared/background-settings/components/i18n/background-settings.json +9 -1
- package/src/shared/background-settings/composables/useBackgroundShapeControls.ts +124 -0
- package/src/shared/background-settings/composables/useSingleBackgroundShape.ts +82 -0
- package/src/shared/background-settings/store/background-settings-store.ts +44 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {} from '../../brand-page/models';
|
|
2
2
|
import { BaseMetadataBuilder, } from '../models';
|
|
3
3
|
import { FOOTER_CHECKS } from './section-rules/footer.rules';
|
|
4
|
-
import { applyDetachedStyleOverride } from './section-field-utils';
|
|
4
|
+
import { applyDetachedStyleOverride, normalizeStyleValue, } from './section-field-utils';
|
|
5
5
|
const normaliseSocialUrl = (url) => {
|
|
6
6
|
for (const prefix of ['mailto:', 'tel:']) {
|
|
7
7
|
if (url.startsWith(prefix))
|
|
@@ -9,75 +9,100 @@ const normaliseSocialUrl = (url) => {
|
|
|
9
9
|
}
|
|
10
10
|
return url;
|
|
11
11
|
};
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
const makeSocialLink = (icon, url) => ({
|
|
13
|
+
imageUrl: icon || '',
|
|
14
|
+
url: normaliseSocialUrl(url || ''),
|
|
15
|
+
imageTitle: '',
|
|
16
|
+
width: 0,
|
|
17
|
+
height: 0,
|
|
18
|
+
imageLink: '',
|
|
19
|
+
});
|
|
20
|
+
const hasSocialLinkMutation = (args) => args._replace_social_links === true ||
|
|
21
|
+
(args._remove_social_link_indices?.length ?? 0) > 0 ||
|
|
22
|
+
(args._reorder_social_links?.length ?? 0) > 0 ||
|
|
23
|
+
(args.social_links?.length ?? 0) > 0;
|
|
24
|
+
/**
|
|
25
|
+
* Social links are a GLOBAL footer concern — one logical list that both
|
|
26
|
+
* viewports render identically. Derive the new list ONCE from the current one
|
|
27
|
+
* WITHOUT mutating the input, so the caller can assign an independent copy to
|
|
28
|
+
* each viewport.
|
|
29
|
+
*
|
|
30
|
+
* Why this can't mutate per-viewport in place: footers migrated from the legacy
|
|
31
|
+
* single `footerStyles` model (migration-01) share ONE `socialLinks` array
|
|
32
|
+
* reference across pageFooterDesktop and pageFooterMobile, and `cloneDeep`
|
|
33
|
+
* preserves that shared reference. Running an in-place `splice` once per
|
|
34
|
+
* viewport therefore applies it TWICE to the same array — e.g. one requested
|
|
35
|
+
* removal index drops two links. Compute-once + assign-fresh is correct for
|
|
36
|
+
* both shared (legacy) and independent (new-model) footers.
|
|
37
|
+
*/
|
|
38
|
+
const computeSocialLinks = (current, args) => {
|
|
18
39
|
// _replace_social_links: replace entire list (empty/absent social_links = clear all).
|
|
19
|
-
//
|
|
20
|
-
// they are superseded by the replacement and running them would cause duplicates.
|
|
40
|
+
// A replacement supersedes every other social link mutation.
|
|
21
41
|
if (args._replace_social_links) {
|
|
22
|
-
|
|
23
|
-
imageUrl: l.social_link_icon || '',
|
|
24
|
-
url: normaliseSocialUrl(l.url || ''),
|
|
25
|
-
imageTitle: '',
|
|
26
|
-
width: 0,
|
|
27
|
-
height: 0,
|
|
28
|
-
imageLink: '',
|
|
29
|
-
}));
|
|
42
|
+
return (args.social_links ?? []).map((l) => makeSocialLink(l.social_link_icon, l.url));
|
|
30
43
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
const links = [...(current ?? [])];
|
|
45
|
+
// item_index-based updates for existing links — replace the item reference
|
|
46
|
+
// (never mutate the original object, which may be shared across viewports).
|
|
47
|
+
for (const link of args.social_links ?? []) {
|
|
48
|
+
if (link.item_index === undefined)
|
|
49
|
+
continue;
|
|
50
|
+
const existing = links[link.item_index];
|
|
51
|
+
if (!existing)
|
|
52
|
+
continue;
|
|
53
|
+
links[link.item_index] = {
|
|
54
|
+
...existing,
|
|
55
|
+
...(link.social_link_icon !== undefined
|
|
56
|
+
? { imageUrl: link.social_link_icon }
|
|
57
|
+
: {}),
|
|
58
|
+
...(link.url !== undefined ? { url: normaliseSocialUrl(link.url) } : {}),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
// Remove by index (descending order to preserve indices during splice).
|
|
62
|
+
if (args._remove_social_link_indices?.length) {
|
|
63
|
+
const sorted = [...args._remove_social_link_indices].sort((a, b) => b - a);
|
|
64
|
+
for (const idx of sorted) {
|
|
65
|
+
if (idx >= 0 && idx < links.length)
|
|
66
|
+
links.splice(idx, 1);
|
|
54
67
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
}
|
|
69
|
+
// Insert new links (descending insert_at order to preserve positions).
|
|
70
|
+
const insertLinks = (args.social_links ?? []).filter((l) => l.insert_at !== undefined && l.item_index === undefined);
|
|
71
|
+
const sortedInserts = [...insertLinks].sort((a, b) => b.insert_at - a.insert_at);
|
|
72
|
+
for (const link of sortedInserts) {
|
|
73
|
+
const pos = Math.max(0, Math.min(link.insert_at, links.length));
|
|
74
|
+
links.splice(pos, 0, makeSocialLink(link.social_link_icon, link.url));
|
|
75
|
+
}
|
|
76
|
+
// Reorder (requires ALL indices — partial reorder is not supported).
|
|
77
|
+
if (args._reorder_social_links?.length) {
|
|
78
|
+
const newOrder = args._reorder_social_links;
|
|
79
|
+
const unique = new Set(newOrder);
|
|
80
|
+
if (unique.size === newOrder.length &&
|
|
81
|
+
newOrder.every((idx) => idx >= 0 && idx < links.length)) {
|
|
82
|
+
const reordered = newOrder.map((idx) => links[idx]);
|
|
83
|
+
if (reordered.length === links.length)
|
|
84
|
+
return reordered;
|
|
69
85
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
86
|
+
}
|
|
87
|
+
return links;
|
|
88
|
+
};
|
|
89
|
+
const applyGlobalFooterChanges = (footer, args, textStyleOptions) => {
|
|
90
|
+
if (args.copyright_text !== undefined)
|
|
91
|
+
footer.copyrightText = args.copyright_text;
|
|
92
|
+
// copyright_text_style is the same text-style object sections use (typography
|
|
93
|
+
// + colour). Normalise each value the way section styles are normalised
|
|
94
|
+
// (letterSpacing int→em, lineHeight snap, null→''), then detach from the
|
|
95
|
+
// global preset via the override helper so a single call resolves the preset
|
|
96
|
+
// and clears textStyleType once — see resolveGlobalPresetIntoStyle (BP-5420).
|
|
97
|
+
if (args.copyright_text_style) {
|
|
98
|
+
const updates = {};
|
|
99
|
+
for (const [key, value] of Object.entries(args.copyright_text_style)) {
|
|
100
|
+
const normalized = normalizeStyleValue(key, value);
|
|
101
|
+
if (normalized !== undefined)
|
|
102
|
+
updates[key] = normalized;
|
|
80
103
|
}
|
|
104
|
+
if (Object.keys(updates).length > 0)
|
|
105
|
+
footer.copyrightStyle = applyDetachedStyleOverride(footer.copyrightStyle, updates, textStyleOptions);
|
|
81
106
|
}
|
|
82
107
|
};
|
|
83
108
|
const applyViewportFooterChanges = (footer, overrides) => {
|
|
@@ -95,11 +120,6 @@ const applyViewportFooterChanges = (footer, overrides) => {
|
|
|
95
120
|
color: overrides.icon_color,
|
|
96
121
|
fill: overrides.icon_color,
|
|
97
122
|
};
|
|
98
|
-
if (overrides.copyright_text_color !== undefined)
|
|
99
|
-
footer.copyrightStyle = {
|
|
100
|
-
...footer.copyrightStyle,
|
|
101
|
-
color: overrides.copyright_text_color,
|
|
102
|
-
};
|
|
103
123
|
if (overrides.is_logo_visible !== undefined)
|
|
104
124
|
footer.isLogoVisible = overrides.is_logo_visible;
|
|
105
125
|
if (overrides.logo_image_height !== undefined)
|
|
@@ -136,11 +156,24 @@ export class FooterBuilder extends BaseMetadataBuilder {
|
|
|
136
156
|
}
|
|
137
157
|
const args = this.request.payload ?? {};
|
|
138
158
|
const textStyleOptions = model.styles?.textStyles?.textStyleOptions;
|
|
139
|
-
// Global fields (
|
|
159
|
+
// Global scalar/style fields (copyright text + font) apply to both
|
|
160
|
+
// viewports. These are idempotent assignments, safe to run per-viewport.
|
|
140
161
|
if (model.pageFooterDesktop)
|
|
141
162
|
applyGlobalFooterChanges(model.pageFooterDesktop, args, textStyleOptions);
|
|
142
163
|
if (model.pageFooterMobile)
|
|
143
164
|
applyGlobalFooterChanges(model.pageFooterMobile, args, textStyleOptions);
|
|
165
|
+
// Social links are a single global list. Derive the new list ONCE, then
|
|
166
|
+
// assign an INDEPENDENT copy to each viewport — never mutate a (possibly
|
|
167
|
+
// shared) viewport array in place. See computeSocialLinks.
|
|
168
|
+
if (hasSocialLinkMutation(args)) {
|
|
169
|
+
const current = model.pageFooterDesktop?.socialLinks ??
|
|
170
|
+
model.pageFooterMobile?.socialLinks;
|
|
171
|
+
const updated = computeSocialLinks(current, args);
|
|
172
|
+
if (model.pageFooterDesktop)
|
|
173
|
+
model.pageFooterDesktop.socialLinks = updated.map((l) => ({ ...l }));
|
|
174
|
+
if (model.pageFooterMobile)
|
|
175
|
+
model.pageFooterMobile.socialLinks = updated.map((l) => ({ ...l }));
|
|
176
|
+
}
|
|
144
177
|
// Viewport-specific styling via explicit sub-objects.
|
|
145
178
|
if (args.desktop && model.pageFooterDesktop)
|
|
146
179
|
applyViewportFooterChanges(model.pageFooterDesktop, args.desktop);
|
|
@@ -21,6 +21,13 @@ interface ButtonLinkArgs {
|
|
|
21
21
|
*/
|
|
22
22
|
export declare const applyButtonLink: (content: ButtonLinkContent, args: ButtonLinkArgs) => void;
|
|
23
23
|
export declare const applyScalarFields: (content: Content, args: SectionToolArguments, sectionType: string) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Convert AI-sent style value to the format expected by the model.
|
|
26
|
+
* - letterSpacing: unitless 0-100 → em string (e.g., 50 → '0.5em')
|
|
27
|
+
* - null → '' (explicitly clear/reset the property)
|
|
28
|
+
* - everything else passes through as-is
|
|
29
|
+
*/
|
|
30
|
+
export declare const normalizeStyleValue: (key: string, value: unknown) => unknown;
|
|
24
31
|
/**
|
|
25
32
|
* When an executor is about to mark a content-level text style "custom" by
|
|
26
33
|
* clearing `textStyleType`, the resolved preset values (font, size, spacing,
|
|
@@ -58,7 +58,7 @@ export const applyScalarFields = (content, args, sectionType) => {
|
|
|
58
58
|
* - null → '' (explicitly clear/reset the property)
|
|
59
59
|
* - everything else passes through as-is
|
|
60
60
|
*/
|
|
61
|
-
const normalizeStyleValue = (key, value) => {
|
|
61
|
+
export const normalizeStyleValue = (key, value) => {
|
|
62
62
|
if (value === null)
|
|
63
63
|
return '';
|
|
64
64
|
if (value === undefined)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AiAssistantToolCall } from '../../clients/ai-assistant-client';
|
|
2
2
|
import type { FooterDisplayStyle, HeaderDisplayStyle, NavigationDisplayType } from '../../brand-page/constants';
|
|
3
|
-
import type { SectionType } from './section-tool-arguments';
|
|
3
|
+
import type { SectionType, TextStyleArguments } from './section-tool-arguments';
|
|
4
4
|
export declare const AI_ASSISTANT_TOOL_NAMES: {
|
|
5
5
|
readonly UPDATE_TEXT: "updateText";
|
|
6
6
|
readonly UPDATE_STYLE: "updateStyle";
|
|
@@ -111,7 +111,6 @@ export interface FooterSocialLinkItem {
|
|
|
111
111
|
export interface ViewportFooterOverrides {
|
|
112
112
|
display_style?: FooterDisplayStyle;
|
|
113
113
|
background_color?: string | null;
|
|
114
|
-
copyright_text_color?: string;
|
|
115
114
|
icon_color?: string;
|
|
116
115
|
is_logo_visible?: boolean;
|
|
117
116
|
logo_image_height?: string;
|
|
@@ -119,7 +118,8 @@ export interface ViewportFooterOverrides {
|
|
|
119
118
|
}
|
|
120
119
|
export interface UpdateFooterArguments {
|
|
121
120
|
copyright_text?: string;
|
|
122
|
-
|
|
121
|
+
/** Copyright line text-style object (typography + colour) — same shape as a section's *_style. Global: applies to both viewports. */
|
|
122
|
+
copyright_text_style?: TextStyleArguments;
|
|
123
123
|
social_links?: FooterSocialLinkItem[];
|
|
124
124
|
_replace_social_links?: boolean;
|
|
125
125
|
_remove_social_link_indices?: number[];
|
|
@@ -7,8 +7,8 @@ export interface SetBackgroundShapeSettingsPayload {
|
|
|
7
7
|
screenTop: number;
|
|
8
8
|
originLeft: number;
|
|
9
9
|
originTop: number;
|
|
10
|
-
scale: number;
|
|
11
|
-
opacity: number;
|
|
10
|
+
scale: number | string;
|
|
11
|
+
opacity: number | string;
|
|
12
12
|
}
|
|
13
13
|
export interface SetRecommendedLogoColorsPayload {
|
|
14
14
|
recommendedLogoColors: string[];
|
|
@@ -148,6 +148,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
148
148
|
wordBreak?: string | undefined;
|
|
149
149
|
};
|
|
150
150
|
}[];
|
|
151
|
+
shapeMode?: import("../../../../brand-page").BackgroundShapeMode | undefined;
|
|
151
152
|
personalisationRole?: import("../../../../brand-page").PersonalisationRole | undefined;
|
|
152
153
|
media?: {
|
|
153
154
|
type: import("../../../../brand-page").MediaTypes;
|
|
@@ -216,6 +217,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
216
217
|
backgroundStyle: import("../../../../brand-page").BackgroundStyle;
|
|
217
218
|
}): void;
|
|
218
219
|
setBackgroundShapes(payload: import("../../../../brand-page").BackgroundShape[]): void;
|
|
220
|
+
setShapeMode(payload: {
|
|
221
|
+
shapeMode: import("../../../../brand-page").BackgroundShapeMode;
|
|
222
|
+
}): void;
|
|
219
223
|
setBackgroundPersonalisationRole(payload: {
|
|
220
224
|
personalisationRole: import("../../../../brand-page").PersonalisationRole | undefined;
|
|
221
225
|
}): void;
|
|
@@ -233,6 +237,13 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
233
237
|
deleteBackgroundShape({ shapeIndex }: {
|
|
234
238
|
shapeIndex: number;
|
|
235
239
|
}): void;
|
|
240
|
+
replaceBackgroundShape({ shapeIndex, shapeUrl, width, height, aspectRatio, }: {
|
|
241
|
+
shapeIndex: number;
|
|
242
|
+
shapeUrl: string;
|
|
243
|
+
width?: number;
|
|
244
|
+
height?: number;
|
|
245
|
+
aspectRatio?: number;
|
|
246
|
+
}): void;
|
|
236
247
|
setLogoColors({ logoColors }: import("../../background-settings-models").SetLogoColorsPayload): void;
|
|
237
248
|
clearUserImageBackgroundImageUrl(): void;
|
|
238
249
|
setAdminBackgroundOptionDefaultValues(): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A multi background shape mapped from raw CSS style to the percentage values the
|
|
3
|
+
* placement/size/opacity controls work in. Shared by the admin panel and the
|
|
4
|
+
* customer panel so both read/write shapes through the same conversion (BP-4024).
|
|
5
|
+
*/
|
|
6
|
+
export interface BackgroundShapePosition {
|
|
7
|
+
name: string;
|
|
8
|
+
screenLeft: number;
|
|
9
|
+
screenTop: number;
|
|
10
|
+
originLeft: number;
|
|
11
|
+
originTop: number;
|
|
12
|
+
scalePercentage: number;
|
|
13
|
+
opacityPercentage: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A shape chosen from the ShapeLibrary. The asset's natural dimensions must be
|
|
17
|
+
* stored on the shape so it renders at its real size — without them BackgroundShape
|
|
18
|
+
* falls back to the SVG's tiny intrinsic size (BP-4024).
|
|
19
|
+
*/
|
|
20
|
+
export interface BackgroundShapeSelection {
|
|
21
|
+
url: string;
|
|
22
|
+
width?: number;
|
|
23
|
+
height?: number;
|
|
24
|
+
aspectRatio?: number | null;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Per-shape controls for the multi background shapes — the percentage mapping plus the
|
|
28
|
+
* change/delete handlers, extracted from AdminBackgroundSettings so the customer panel can
|
|
29
|
+
* reuse size/opacity without duplicating the conversion or re-deriving scale/opacity.
|
|
30
|
+
*/
|
|
31
|
+
export declare const useBackgroundShapeControls: () => {
|
|
32
|
+
backgroundShapes: import("vue").ComputedRef<BackgroundShapePosition[]>;
|
|
33
|
+
onShapeScreenXChange: (index: number, value: number) => void;
|
|
34
|
+
onShapeScreenYChange: (index: number, value: number) => void;
|
|
35
|
+
onShapeOriginXChange: (index: number, value: number) => void;
|
|
36
|
+
onShapeOriginYChange: (index: number, value: number) => void;
|
|
37
|
+
onShapeSizeChange: (index: number, value: number | string) => void;
|
|
38
|
+
onShapeOpacityChange: (index: number, value: number | string) => void;
|
|
39
|
+
onDeleteShape: (index: number) => void;
|
|
40
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
import { useUiBackgroundSettingsStore } from '../store';
|
|
3
|
+
/**
|
|
4
|
+
* Per-shape controls for the multi background shapes — the percentage mapping plus the
|
|
5
|
+
* change/delete handlers, extracted from AdminBackgroundSettings so the customer panel can
|
|
6
|
+
* reuse size/opacity without duplicating the conversion or re-deriving scale/opacity.
|
|
7
|
+
*/
|
|
8
|
+
export const useBackgroundShapeControls = () => {
|
|
9
|
+
const backgroundSettingsStore = useUiBackgroundSettingsStore();
|
|
10
|
+
const backgroundShapes = computed(() => backgroundSettingsStore.backgroundStyles.backgroundShapes?.map((shape) => {
|
|
11
|
+
const translate = shape.style.transform
|
|
12
|
+
?.match(/\((.*)\)/)
|
|
13
|
+
?.pop()
|
|
14
|
+
?.split(',');
|
|
15
|
+
return {
|
|
16
|
+
name: shape.name,
|
|
17
|
+
screenLeft: parseInt(shape.style.left?.replace('%', '') || '50'),
|
|
18
|
+
screenTop: parseInt(shape.style.top?.replace('%', '') || '50'),
|
|
19
|
+
originLeft: parseInt(translate ? translate[0] : '-50'),
|
|
20
|
+
originTop: parseInt(translate ? translate[1] : '-50'),
|
|
21
|
+
scalePercentage: Math.round(parseFloat(shape.style.transform?.match(/(?:scale)\(([^)]+)\)/)?.pop() ||
|
|
22
|
+
'1') * 100),
|
|
23
|
+
opacityPercentage: Math.round(parseFloat(shape.style.opacity || '1') * 100),
|
|
24
|
+
};
|
|
25
|
+
}) || []);
|
|
26
|
+
const onShapeSettingChange = (index, updatedSettings) => {
|
|
27
|
+
const scale = (backgroundShapes.value[index]?.scalePercentage / 100 || 1).toFixed(2);
|
|
28
|
+
const opacity = (backgroundShapes.value[index]?.opacityPercentage / 100 || 1).toFixed(2);
|
|
29
|
+
backgroundSettingsStore.setBackgroundShapeSettings({
|
|
30
|
+
index,
|
|
31
|
+
...backgroundShapes.value[index],
|
|
32
|
+
scale,
|
|
33
|
+
opacity,
|
|
34
|
+
...updatedSettings,
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
const onShapeScreenXChange = (index, value) => onShapeSettingChange(index, { screenLeft: value });
|
|
38
|
+
const onShapeScreenYChange = (index, value) => onShapeSettingChange(index, { screenTop: value });
|
|
39
|
+
const onShapeOriginXChange = (index, value) => onShapeSettingChange(index, { originLeft: value });
|
|
40
|
+
const onShapeOriginYChange = (index, value) => onShapeSettingChange(index, { originTop: value });
|
|
41
|
+
const onShapeSizeChange = (index, value) => onShapeSettingChange(index, {
|
|
42
|
+
scale: (parseFloat(`${value}`) / 100).toFixed(2),
|
|
43
|
+
});
|
|
44
|
+
const onShapeOpacityChange = (index, value) => onShapeSettingChange(index, {
|
|
45
|
+
opacity: (parseFloat(`${value}`) / 100).toFixed(2),
|
|
46
|
+
});
|
|
47
|
+
const onDeleteShape = (index) => backgroundSettingsStore.deleteBackgroundShape({ shapeIndex: index });
|
|
48
|
+
return {
|
|
49
|
+
backgroundShapes,
|
|
50
|
+
onShapeScreenXChange,
|
|
51
|
+
onShapeScreenYChange,
|
|
52
|
+
onShapeOriginXChange,
|
|
53
|
+
onShapeOriginYChange,
|
|
54
|
+
onShapeSizeChange,
|
|
55
|
+
onShapeOpacityChange,
|
|
56
|
+
onDeleteShape,
|
|
57
|
+
};
|
|
58
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { BackgroundShapeSelection } from './useBackgroundShapeControls';
|
|
2
|
+
/**
|
|
3
|
+
* The single background shape is the MAIN shape — stored in `backgroundImageUrl`
|
|
4
|
+
* (an `.svg`) and styled via `backgroundShapeStyle`. It renders full-size (100%)
|
|
5
|
+
* and is kept entirely separate from the multi `backgroundShapes[]` array, so the
|
|
6
|
+
* single and multiple shape modes never share a shape (BP-4024).
|
|
7
|
+
*/
|
|
8
|
+
export declare const useSingleBackgroundShape: () => {
|
|
9
|
+
shapeUrl: import("vue").ComputedRef<string>;
|
|
10
|
+
shapeCount: import("vue").ComputedRef<number>;
|
|
11
|
+
opacityPercentage: import("vue").ComputedRef<number>;
|
|
12
|
+
shapeColorValue: import("vue").ComputedRef<any>;
|
|
13
|
+
onColorChange: (payload: {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
value: string;
|
|
17
|
+
}) => void;
|
|
18
|
+
onReplace: (shape: BackgroundShapeSelection) => void;
|
|
19
|
+
onRemove: () => void;
|
|
20
|
+
onOpacityChange: (value: number | string) => void;
|
|
21
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
import { useUiBackgroundSettingsStore } from '../store';
|
|
3
|
+
import { RGBAtoHex, hexToRGBA } from '@utils/helpers';
|
|
4
|
+
import { isColorMatched } from '@brand-page-maker/utils';
|
|
5
|
+
/**
|
|
6
|
+
* The single background shape is the MAIN shape — stored in `backgroundImageUrl`
|
|
7
|
+
* (an `.svg`) and styled via `backgroundShapeStyle`. It renders full-size (100%)
|
|
8
|
+
* and is kept entirely separate from the multi `backgroundShapes[]` array, so the
|
|
9
|
+
* single and multiple shape modes never share a shape (BP-4024).
|
|
10
|
+
*/
|
|
11
|
+
export const useSingleBackgroundShape = () => {
|
|
12
|
+
const store = useUiBackgroundSettingsStore();
|
|
13
|
+
const shapeUrl = computed(() => {
|
|
14
|
+
const url = store.backgroundStyles.backgroundImageUrl || '';
|
|
15
|
+
return url.endsWith('.svg') ? url : '';
|
|
16
|
+
});
|
|
17
|
+
// Single (main) + multi shapes — drives the admin mode toggle's count-based fallback.
|
|
18
|
+
const shapeCount = computed(() => (shapeUrl.value ? 1 : 0) +
|
|
19
|
+
(store.backgroundStyles.backgroundShapes?.length || 0));
|
|
20
|
+
const opacityPercentage = computed(() => Math.round(parseFloat(`${store.backgroundStyles.backgroundShapeStyle?.opacity ?? 1}`) * 100));
|
|
21
|
+
// Shape colour — normalise to hex (or pass a theme key through) for the swatch.
|
|
22
|
+
const shapeColorValue = computed(() => {
|
|
23
|
+
const color = store.backgroundStyles.backgroundShapeStyle?.color || '';
|
|
24
|
+
if (color.startsWith('rgb')) {
|
|
25
|
+
return RGBAtoHex(color).toUpperCase();
|
|
26
|
+
}
|
|
27
|
+
return color;
|
|
28
|
+
});
|
|
29
|
+
const onColorChange = (payload) => {
|
|
30
|
+
// Colour-matched values are theme keys — pass through; otherwise store rgba.
|
|
31
|
+
const color = isColorMatched(payload.value)
|
|
32
|
+
? payload.value
|
|
33
|
+
: hexToRGBA(payload.value);
|
|
34
|
+
store.setPrimaryBackgroundShapeStyle({ color });
|
|
35
|
+
};
|
|
36
|
+
const onReplace = (shape) => store.setBackgroundImageUrl({ backgroundImageUrl: shape.url });
|
|
37
|
+
const onRemove = () => store.setBackgroundImageUrl({ backgroundImageUrl: '' });
|
|
38
|
+
const onOpacityChange = (value) => store.setPrimaryBackgroundShapeStyle({
|
|
39
|
+
opacity: (Number(value) / 100).toFixed(2),
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
shapeUrl,
|
|
43
|
+
shapeCount,
|
|
44
|
+
opacityPercentage,
|
|
45
|
+
shapeColorValue,
|
|
46
|
+
onColorChange,
|
|
47
|
+
onReplace,
|
|
48
|
+
onRemove,
|
|
49
|
+
onOpacityChange,
|
|
50
|
+
};
|
|
51
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BackgroundShape, BackgroundStyle, BackgroundStyles, PersonalisationRole } from '@brand-page';
|
|
1
|
+
import type { BackgroundShape, BackgroundShapeMode, BackgroundStyle, BackgroundStyles, PersonalisationRole } from '@brand-page';
|
|
2
2
|
import { type BrandPageSettingsMode } from '@brand-page-maker/stores/brandpage-maker/brandpage-maker-store';
|
|
3
3
|
import type { SetBackgroundShapeSettingsPayload, SetLogoColorsPayload, SetRecommendedLogoColorsPayload } from '../background-settings-models';
|
|
4
4
|
import type { BackgroundSetStatePayload, BackgroundSettingsTabId } from '../models';
|
|
@@ -19,6 +19,9 @@ export declare const useUiBackgroundSettingsStore: import("pinia").StoreDefiniti
|
|
|
19
19
|
backgroundStyle: BackgroundStyle;
|
|
20
20
|
}): void;
|
|
21
21
|
setBackgroundShapes(payload: BackgroundShape[]): void;
|
|
22
|
+
setShapeMode(payload: {
|
|
23
|
+
shapeMode: BackgroundShapeMode;
|
|
24
|
+
}): void;
|
|
22
25
|
setBackgroundPersonalisationRole(payload: {
|
|
23
26
|
personalisationRole: PersonalisationRole | undefined;
|
|
24
27
|
}): void;
|
|
@@ -36,6 +39,13 @@ export declare const useUiBackgroundSettingsStore: import("pinia").StoreDefiniti
|
|
|
36
39
|
deleteBackgroundShape({ shapeIndex }: {
|
|
37
40
|
shapeIndex: number;
|
|
38
41
|
}): void;
|
|
42
|
+
replaceBackgroundShape({ shapeIndex, shapeUrl, width, height, aspectRatio, }: {
|
|
43
|
+
shapeIndex: number;
|
|
44
|
+
shapeUrl: string;
|
|
45
|
+
width?: number;
|
|
46
|
+
height?: number;
|
|
47
|
+
aspectRatio?: number;
|
|
48
|
+
}): void;
|
|
39
49
|
setLogoColors({ logoColors }: SetLogoColorsPayload): void;
|
|
40
50
|
clearUserImageBackgroundImageUrl(): void;
|
|
41
51
|
setAdminBackgroundOptionDefaultValues(): void;
|
|
@@ -42,6 +42,10 @@ export const useUiBackgroundSettingsStore = defineStore('uiBackgroundSettings',
|
|
|
42
42
|
setBackgroundShapes(payload) {
|
|
43
43
|
this.backgroundStyles.backgroundShapes = payload || [];
|
|
44
44
|
},
|
|
45
|
+
setShapeMode(payload) {
|
|
46
|
+
this.backgroundStyles.shapeMode = payload.shapeMode;
|
|
47
|
+
this.onBackgroundChanged();
|
|
48
|
+
},
|
|
45
49
|
setBackgroundPersonalisationRole(payload) {
|
|
46
50
|
this.backgroundStyles.personalisationRole = payload.personalisationRole;
|
|
47
51
|
},
|
|
@@ -88,6 +92,25 @@ export const useUiBackgroundSettingsStore = defineStore('uiBackgroundSettings',
|
|
|
88
92
|
deleteBackgroundShape({ shapeIndex }) {
|
|
89
93
|
this.backgroundStyles.backgroundShapes.splice(shapeIndex, 1);
|
|
90
94
|
},
|
|
95
|
+
replaceBackgroundShape({ shapeIndex, shapeUrl, width, height, aspectRatio, }) {
|
|
96
|
+
const shape = this.backgroundStyles.backgroundShapes[shapeIndex];
|
|
97
|
+
if (!shape) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
// Swap the asset and adopt the new asset's natural dimensions (size is
|
|
101
|
+
// intrinsic to the asset), keeping placement/scale/opacity/colour.
|
|
102
|
+
shape.name = shapeUrl;
|
|
103
|
+
if (width) {
|
|
104
|
+
shape.style.width = `${width}px`;
|
|
105
|
+
}
|
|
106
|
+
if (height) {
|
|
107
|
+
shape.style.height = `${height}px`;
|
|
108
|
+
}
|
|
109
|
+
if (aspectRatio) {
|
|
110
|
+
shape.style.aspectRatio = aspectRatio;
|
|
111
|
+
}
|
|
112
|
+
this.onBackgroundChanged();
|
|
113
|
+
},
|
|
91
114
|
setLogoColors({ logoColors }) {
|
|
92
115
|
this.logoColors = logoColors;
|
|
93
116
|
},
|
|
@@ -117,6 +140,7 @@ export const useUiBackgroundSettingsStore = defineStore('uiBackgroundSettings',
|
|
|
117
140
|
}
|
|
118
141
|
this.setBackgroundStyle({ backgroundStyle: backgroundStyles.style });
|
|
119
142
|
this.setBackgroundShapes(backgroundStyles.backgroundShapes);
|
|
143
|
+
this.backgroundStyles.shapeMode = backgroundStyles.shapeMode;
|
|
120
144
|
this.setBackgroundImageUrl({
|
|
121
145
|
backgroundImageUrl: backgroundStyles.backgroundImageUrl,
|
|
122
146
|
});
|
|
@@ -107,10 +107,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
107
107
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
108
108
|
}>, {
|
|
109
109
|
fields: Record<string, MultiFieldOption>;
|
|
110
|
+
multiple: boolean;
|
|
110
111
|
placeholder: string;
|
|
111
112
|
variant: string;
|
|
112
113
|
value: string | boolean | Record<string, any>;
|
|
113
|
-
multiple: boolean;
|
|
114
114
|
optionsConvertor: OptionsConvertor<unknown>;
|
|
115
115
|
isRequired: boolean;
|
|
116
116
|
}, {}, {
|
|
@@ -888,6 +888,9 @@ declare const _default: import("vue").DefineComponent<{}, {
|
|
|
888
888
|
backgroundStyle: import("@brand-page").BackgroundStyle;
|
|
889
889
|
}): void;
|
|
890
890
|
setBackgroundShapes(payload: import("@brand-page").BackgroundShape[]): void;
|
|
891
|
+
setShapeMode(payload: {
|
|
892
|
+
shapeMode: import("@brand-page").BackgroundShapeMode;
|
|
893
|
+
}): void;
|
|
891
894
|
setBackgroundPersonalisationRole(payload: {
|
|
892
895
|
personalisationRole: import("@brand-page").PersonalisationRole | undefined;
|
|
893
896
|
}): void;
|
|
@@ -905,6 +908,13 @@ declare const _default: import("vue").DefineComponent<{}, {
|
|
|
905
908
|
deleteBackgroundShape({ shapeIndex }: {
|
|
906
909
|
shapeIndex: number;
|
|
907
910
|
}): void;
|
|
911
|
+
replaceBackgroundShape({ shapeIndex, shapeUrl, width, height, aspectRatio, }: {
|
|
912
|
+
shapeIndex: number;
|
|
913
|
+
shapeUrl: string;
|
|
914
|
+
width?: number;
|
|
915
|
+
height?: number;
|
|
916
|
+
aspectRatio?: number;
|
|
917
|
+
}): void;
|
|
908
918
|
setLogoColors({ logoColors }: import("../../background-settings/background-settings-models").SetLogoColorsPayload): void;
|
|
909
919
|
clearUserImageBackgroundImageUrl(): void;
|
|
910
920
|
setAdminBackgroundOptionDefaultValues(): void;
|
package/package.json
CHANGED
|
@@ -77,11 +77,15 @@ export type BackgroundStyle = Partial<
|
|
|
77
77
|
Omit<BrandPageCssStyle, 'backgroundColor'>
|
|
78
78
|
>;
|
|
79
79
|
|
|
80
|
+
// Admin-chosen shape configuration for a template (BP-4024).
|
|
81
|
+
export type BackgroundShapeMode = 'single' | 'multiple';
|
|
82
|
+
|
|
80
83
|
export class BackgroundStyles {
|
|
81
84
|
public style: BackgroundStyle;
|
|
82
85
|
public backgroundShapeStyle: BackgroundStyle;
|
|
83
86
|
public backgroundImageUrl: string;
|
|
84
87
|
public backgroundShapes: BackgroundShape[];
|
|
88
|
+
public shapeMode?: BackgroundShapeMode;
|
|
85
89
|
public personalisationRole?: PersonalisationRole;
|
|
86
90
|
public media?: AbstractMedia;
|
|
87
91
|
public mediaOverlayStyle: BrandPageCssStyle;
|
|
@@ -90,6 +94,7 @@ export class BackgroundStyles {
|
|
|
90
94
|
this.backgroundImageUrl = option.backgroundImageUrl || '';
|
|
91
95
|
this.backgroundShapes = (option.backgroundShapes ||
|
|
92
96
|
[]) as BackgroundShape[];
|
|
97
|
+
this.shapeMode = option.shapeMode;
|
|
93
98
|
this.style = (option.style as BackgroundStyle) || {
|
|
94
99
|
background: '',
|
|
95
100
|
};
|