@deneb-ui/ui 2.0.99 → 2.0.101
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/dist/EditableFooter.js +15 -3
- package/dist/EditableProductCard.js +12 -1
- package/dist/EditableProductShowcase.js +8 -2
- package/dist/SiteDataProvider.d.ts +24 -0
- package/dist/SiteDataProvider.js +115 -37
- package/dist/StickyMobileBar.js +6 -4
- package/dist/contact/EmailButton.js +7 -2
- package/dist/contact/PhoneButton.js +9 -2
- package/dist/contact/WhatsAppButton.d.ts +1 -0
- package/dist/contact/WhatsAppButton.js +10 -3
- package/package.json +2 -2
package/dist/EditableFooter.js
CHANGED
|
@@ -93,13 +93,25 @@ function EditableFooter({ defaultLinks = DEFAULT_FOOTER_PAGES, links, basePath =
|
|
|
93
93
|
: ['twitter', 'github', 'linkedin', 'instagram'];
|
|
94
94
|
// Direct message / WhatsApp action
|
|
95
95
|
const directMessageLabel = String(contact?.directMessageText || common?.directMessageText || props.directMessageText || 'Send us a direct message');
|
|
96
|
-
const
|
|
96
|
+
const liveWhatsapp = shopContact?.whatsapp ||
|
|
97
|
+
shop?.businessWhatsapp ||
|
|
98
|
+
shop?.whatsappNumber ||
|
|
99
|
+
shop?.whatsapp;
|
|
100
|
+
const rawWhatsapp = String(liveWhatsapp ||
|
|
101
|
+
contact?.whatsapp ||
|
|
102
|
+
contact?.whatsappUrl ||
|
|
103
|
+
common?.whatsapp ||
|
|
104
|
+
common?.whatsappNumber ||
|
|
105
|
+
business?.whatsapp ||
|
|
106
|
+
props.whatsappUrl ||
|
|
107
|
+
phone ||
|
|
108
|
+
'94771234567');
|
|
97
109
|
const cleanDigits = rawWhatsapp.replace(/[^\d]/g, '');
|
|
98
110
|
const whatsappHref = rawWhatsapp.startsWith('http')
|
|
99
|
-
? rawWhatsapp
|
|
111
|
+
? (rawWhatsapp.includes('wa.me') && cleanDigits ? `https://wa.me/${cleanDigits}` : rawWhatsapp)
|
|
100
112
|
: cleanDigits
|
|
101
113
|
? `https://wa.me/${cleanDigits}`
|
|
102
|
-
: 'https://wa.me/';
|
|
114
|
+
: 'https://wa.me/94771234567';
|
|
103
115
|
// Route filtering
|
|
104
116
|
const navigationItems = links || defaultLinks;
|
|
105
117
|
const requiredPages = Array.isArray(siteData?.requirements?.requiredPages)
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EditableProductCard = EditableProductCard;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const SiteDataProvider_1 = require("./SiteDataProvider");
|
|
5
6
|
const react_1 = require("react");
|
|
6
7
|
const EditableText_1 = require("./EditableText");
|
|
7
8
|
const EditableImage_1 = require("./EditableImage");
|
|
@@ -134,7 +135,17 @@ function EditableProductCard({ itemPath, product: productProp, item: itemProp, c
|
|
|
134
135
|
: ('photo' in (product || {}) && !('imageUrl' in (product || {}) && product.imageUrl)
|
|
135
136
|
? 'photo'
|
|
136
137
|
: 'imageUrl');
|
|
137
|
-
const
|
|
138
|
+
const siteDataCard = (0, SiteDataProvider_1.useSiteData)();
|
|
139
|
+
const liveShopCard = siteDataCard?.shop;
|
|
140
|
+
const liveWaCard = liveShopCard?.contact?.whatsapp ||
|
|
141
|
+
liveShopCard?.businessWhatsapp ||
|
|
142
|
+
liveShopCard?.whatsappNumber ||
|
|
143
|
+
liveShopCard?.whatsapp;
|
|
144
|
+
const resolvedPhone = String(product?.whatsappNumber ||
|
|
145
|
+
(whatsappPhoneProp || whatsappNumberProp ? whatsappNumber : null) ||
|
|
146
|
+
liveWaCard ||
|
|
147
|
+
whatsappNumber ||
|
|
148
|
+
'94771234567');
|
|
138
149
|
const resolvedWhatsAppText = String(product?.whatsappButtonText || whatsappActionLabel);
|
|
139
150
|
const resolvedAddToCartText = String(product?.addToCartButtonText || addToCartLabel);
|
|
140
151
|
const isHorizontal = cardVariant === 'horizontal';
|
|
@@ -160,11 +160,17 @@ function EditableProductShowcase({ sectionPath = 'home', listPath = 'featuredPho
|
|
|
160
160
|
});
|
|
161
161
|
}, [normalizedProducts, selectedFilter]);
|
|
162
162
|
// Resolve merchant WhatsApp target dynamically ([DNB-WHA-008])
|
|
163
|
-
const
|
|
163
|
+
const liveShopShowcase = siteData?.shop;
|
|
164
|
+
const liveWaShowcase = liveShopShowcase?.contact?.whatsapp ||
|
|
165
|
+
liveShopShowcase?.businessWhatsapp ||
|
|
166
|
+
liveShopShowcase?.whatsappNumber ||
|
|
167
|
+
liveShopShowcase?.whatsapp;
|
|
168
|
+
const rawWhatsAppTarget = liveWaShowcase ||
|
|
169
|
+
secContent.whatsappOrderUrl ||
|
|
164
170
|
secContent.whatsappNumber ||
|
|
165
171
|
siteData?.content?.common?.business?.whatsapp ||
|
|
166
172
|
siteData?.content?.merchant?.whatsapp ||
|
|
167
|
-
'https://wa.me/
|
|
173
|
+
'https://wa.me/94771234567';
|
|
168
174
|
const handleWhatsAppOrder = (product, colorName, e) => {
|
|
169
175
|
e.stopPropagation();
|
|
170
176
|
const productName = product.name || product.title || 'Product';
|
|
@@ -151,9 +151,33 @@ export declare function useReviews(fallback?: GenericRecord[]): GenericRecord[];
|
|
|
151
151
|
* with safe hierarchical fallbacks across content.common, shop profile, and user fallbacks.
|
|
152
152
|
* Never throws ReferenceError or crashes on missing data.
|
|
153
153
|
*/
|
|
154
|
+
export declare const DUMMY_PREVIEW_PHONE = "+94 11 234 5678";
|
|
155
|
+
export declare const DUMMY_PREVIEW_WHATSAPP = "94771234567";
|
|
156
|
+
export declare const DUMMY_PREVIEW_EMAIL = "info@store.com";
|
|
157
|
+
export declare const DUMMY_PREVIEW_ADDRESS = "Flagship Studio: Galle Face Promenade, Colombo 03, Sri Lanka";
|
|
158
|
+
export declare const DUMMY_PREVIEW_SHOP_NAME = "Storefront";
|
|
159
|
+
/**
|
|
160
|
+
* Checks whether the active storefront runtime is running in visual editor preview,
|
|
161
|
+
* template authoring frame, or automated template validation.
|
|
162
|
+
*/
|
|
163
|
+
export declare function isPreviewValidation(siteData?: any): boolean;
|
|
154
164
|
export declare function useCommon(fallback?: GenericRecord): GenericRecord;
|
|
155
165
|
/**
|
|
156
166
|
* Hook to retrieve contact information (WhatsApp, phone, address, email, map link)
|
|
157
167
|
* with robust fallbacks across contact, common, and shop profile.
|
|
158
168
|
*/
|
|
159
169
|
export declare function useContact(fallback?: GenericRecord): GenericRecord;
|
|
170
|
+
export interface SyncedBranding {
|
|
171
|
+
logoUrl: string;
|
|
172
|
+
websiteTitle: string;
|
|
173
|
+
brandSubtext: string;
|
|
174
|
+
slogan: string;
|
|
175
|
+
faviconUrl: string;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Universal Synced Branding Hook:
|
|
179
|
+
* Guarantees real-time live synchronization for brand identity across visual editor preview,
|
|
180
|
+
* merchant DB profile, and template defaults.
|
|
181
|
+
* Hierarchy: Visual Editor Edits (content.common) -> Live Merchant Shop Profile -> Template Fallback.
|
|
182
|
+
*/
|
|
183
|
+
export declare function useSyncedBranding(fallback?: Partial<SyncedBranding>): SyncedBranding;
|
package/dist/SiteDataProvider.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
'use client';
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.DenebDataContext = exports.useDenebData = exports.DenebDataProvider = exports.SiteDataContext = exports.DENEB_STYLE_PATCH_MESSAGE = exports.STYLE_PATCH_MESSAGE = exports.PREVIEW_FIELD_ATTRIBUTE = exports.LEGACY_PREVIEW_FOCUS_MESSAGE = exports.PREVIEW_FOCUS_MESSAGE = exports.DENEB_PREVIEW_FOCUS_MESSAGE = exports.LEGACY_PREVIEW_READY_MESSAGE = exports.PREVIEW_READY_MESSAGE = exports.DENEB_PREVIEW_READY_MESSAGE = exports.LEGACY_PREVIEW_DATA_MESSAGE = exports.PREVIEW_DATA_MESSAGE = exports.DENEB_PREVIEW_DATA_MESSAGE = void 0;
|
|
4
|
+
exports.DUMMY_PREVIEW_SHOP_NAME = exports.DUMMY_PREVIEW_ADDRESS = exports.DUMMY_PREVIEW_EMAIL = exports.DUMMY_PREVIEW_WHATSAPP = exports.DUMMY_PREVIEW_PHONE = exports.DenebDataContext = exports.useDenebData = exports.DenebDataProvider = exports.SiteDataContext = exports.DENEB_STYLE_PATCH_MESSAGE = exports.STYLE_PATCH_MESSAGE = exports.PREVIEW_FIELD_ATTRIBUTE = exports.LEGACY_PREVIEW_FOCUS_MESSAGE = exports.PREVIEW_FOCUS_MESSAGE = exports.DENEB_PREVIEW_FOCUS_MESSAGE = exports.LEGACY_PREVIEW_READY_MESSAGE = exports.PREVIEW_READY_MESSAGE = exports.DENEB_PREVIEW_READY_MESSAGE = exports.LEGACY_PREVIEW_DATA_MESSAGE = exports.PREVIEW_DATA_MESSAGE = exports.DENEB_PREVIEW_DATA_MESSAGE = void 0;
|
|
5
5
|
exports.isRecord = isRecord;
|
|
6
6
|
exports.isDarkColor = isDarkColor;
|
|
7
7
|
exports.syncThemeToDocument = syncThemeToDocument;
|
|
@@ -26,8 +26,10 @@ exports.useSiteApi = useSiteApi;
|
|
|
26
26
|
exports.useSiteCatalog = useSiteCatalog;
|
|
27
27
|
exports.useShop = useShop;
|
|
28
28
|
exports.useReviews = useReviews;
|
|
29
|
+
exports.isPreviewValidation = isPreviewValidation;
|
|
29
30
|
exports.useCommon = useCommon;
|
|
30
31
|
exports.useContact = useContact;
|
|
32
|
+
exports.useSyncedBranding = useSyncedBranding;
|
|
31
33
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
32
34
|
const react_1 = require("react");
|
|
33
35
|
const core_1 = require("@deneb-ui/core");
|
|
@@ -251,13 +253,20 @@ function SiteDataProvider({ children, initialSiteData, fallbackSiteData, liveCat
|
|
|
251
253
|
window.location.pathname.includes('/preview/')))) {
|
|
252
254
|
return;
|
|
253
255
|
}
|
|
256
|
+
const isLocalhost = typeof window !== 'undefined' &&
|
|
257
|
+
(window.location.hostname === 'localhost' ||
|
|
258
|
+
window.location.hostname === '127.0.0.1');
|
|
254
259
|
const endpoint = liveCatalogEndpoint ||
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
:
|
|
259
|
-
|
|
260
|
-
|
|
260
|
+
(isLocalhost &&
|
|
261
|
+
initialSiteData?.api?.catalogUrl &&
|
|
262
|
+
initialSiteData.api.catalogUrl.includes('api.fivora.site')
|
|
263
|
+
? `http://localhost:3000/site-catalog/${candidateSlug}/live-data`
|
|
264
|
+
: initialSiteData?.api?.catalogUrl ||
|
|
265
|
+
(candidateSlug && initialSiteData?.api?.baseUrl
|
|
266
|
+
? `${initialSiteData.api.baseUrl.replace(/\/+$/, '')}/site-catalog/${candidateSlug}/live-data`
|
|
267
|
+
: candidateSlug
|
|
268
|
+
? `/site-catalog/${candidateSlug}/live-data`
|
|
269
|
+
: null));
|
|
261
270
|
if (!endpoint)
|
|
262
271
|
return;
|
|
263
272
|
let stopped = false;
|
|
@@ -288,40 +297,50 @@ function SiteDataProvider({ children, initialSiteData, fallbackSiteData, liveCat
|
|
|
288
297
|
nextMerchant = mergeSiteData(nextMerchant, live.shop);
|
|
289
298
|
const contact = isRecord(live.shop.contact) ? live.shop.contact : null;
|
|
290
299
|
const address = isRecord(live.shop.address) ? live.shop.address : null;
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
300
|
+
const phoneVal = (contact && typeof contact.phone === 'string' && contact.phone.trim()) ||
|
|
301
|
+
(typeof live.shop.businessPhone === 'string' && live.shop.businessPhone.trim()) ||
|
|
302
|
+
null;
|
|
303
|
+
if (phoneVal) {
|
|
304
|
+
nextContact.phone = phoneVal;
|
|
305
|
+
nextContact.contactNumber = phoneVal;
|
|
306
|
+
nextCommon.contactNumber = phoneVal;
|
|
307
|
+
nextCommon.phone = phoneVal;
|
|
308
|
+
}
|
|
309
|
+
const whatsappVal = (contact && typeof contact.whatsapp === 'string' && contact.whatsapp.trim()) ||
|
|
310
|
+
(typeof live.shop.businessWhatsapp === 'string' && live.shop.businessWhatsapp.trim()) ||
|
|
311
|
+
null;
|
|
312
|
+
if (whatsappVal) {
|
|
313
|
+
nextContact.whatsapp = whatsappVal;
|
|
314
|
+
nextCommon.whatsapp = whatsappVal;
|
|
315
|
+
const cleanWa = whatsappVal.replace(/\D/g, '');
|
|
316
|
+
if (cleanWa) {
|
|
317
|
+
nextContact.whatsappNumber = cleanWa;
|
|
318
|
+
nextCommon.whatsappNumber = cleanWa;
|
|
319
|
+
nextHome.whatsappNumber = cleanWa;
|
|
320
|
+
// Dynamically update any hardcoded or static wa.me URLs across home and common
|
|
321
|
+
const waRegex = /(https?:\/\/(?:wa\.me|api\.whatsapp\.com\/send\?phone=))\d+/gi;
|
|
322
|
+
for (const key of ['whatsappCtaUrl', 'whatsappOrderUrl', 'whatsappUrl']) {
|
|
323
|
+
if (typeof nextHome[key] === 'string' && waRegex.test(nextHome[key])) {
|
|
324
|
+
nextHome[key] = nextHome[key].replace(waRegex, `$1${cleanWa}`);
|
|
315
325
|
}
|
|
316
|
-
if (
|
|
317
|
-
nextCommon
|
|
326
|
+
if (typeof nextCommon[key] === 'string' && waRegex.test(nextCommon[key])) {
|
|
327
|
+
nextCommon[key] = nextCommon[key].replace(waRegex, `$1${cleanWa}`);
|
|
318
328
|
}
|
|
319
329
|
}
|
|
330
|
+
if (!nextCommon.whatsappUrl || waRegex.test(nextCommon.whatsappUrl)) {
|
|
331
|
+
nextCommon.whatsappUrl = `https://wa.me/${cleanWa}`;
|
|
332
|
+
}
|
|
320
333
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
334
|
+
}
|
|
335
|
+
const emailVal = (contact && typeof contact.email === 'string' && contact.email.trim()) ||
|
|
336
|
+
(typeof live.shop.businessEmail === 'string' && live.shop.businessEmail.trim()) ||
|
|
337
|
+
null;
|
|
338
|
+
if (emailVal) {
|
|
339
|
+
nextContact.email = emailVal;
|
|
340
|
+
nextCommon.email = emailVal;
|
|
341
|
+
}
|
|
342
|
+
if (typeof live.shop.businessName === 'string' && live.shop.businessName.trim()) {
|
|
343
|
+
nextCommon.websiteTitle = live.shop.businessName.trim();
|
|
325
344
|
}
|
|
326
345
|
if (address) {
|
|
327
346
|
const street = address.street || address.line1;
|
|
@@ -958,6 +977,31 @@ function useReviews(fallback = []) {
|
|
|
958
977
|
* with safe hierarchical fallbacks across content.common, shop profile, and user fallbacks.
|
|
959
978
|
* Never throws ReferenceError or crashes on missing data.
|
|
960
979
|
*/
|
|
980
|
+
exports.DUMMY_PREVIEW_PHONE = '+94 11 234 5678';
|
|
981
|
+
exports.DUMMY_PREVIEW_WHATSAPP = '94771234567';
|
|
982
|
+
exports.DUMMY_PREVIEW_EMAIL = 'info@store.com';
|
|
983
|
+
exports.DUMMY_PREVIEW_ADDRESS = 'Flagship Studio: Galle Face Promenade, Colombo 03, Sri Lanka';
|
|
984
|
+
exports.DUMMY_PREVIEW_SHOP_NAME = 'Storefront';
|
|
985
|
+
/**
|
|
986
|
+
* Checks whether the active storefront runtime is running in visual editor preview,
|
|
987
|
+
* template authoring frame, or automated template validation.
|
|
988
|
+
*/
|
|
989
|
+
function isPreviewValidation(siteData) {
|
|
990
|
+
if (!siteData)
|
|
991
|
+
return true;
|
|
992
|
+
const slug = siteData?.project?.slug || siteData?.siteInstance?.slug;
|
|
993
|
+
const id = siteData?.project?.id;
|
|
994
|
+
if (slug === 'template-validation' || id === 'template-validation' || slug === 'preview' || id === 'preview') {
|
|
995
|
+
return true;
|
|
996
|
+
}
|
|
997
|
+
if (typeof window !== 'undefined') {
|
|
998
|
+
const path = window.location.pathname || '';
|
|
999
|
+
if (path.includes('/template-validation') || path.includes('/template-preview') || path.includes('/preview/')) {
|
|
1000
|
+
return true;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
return false;
|
|
1004
|
+
}
|
|
961
1005
|
function useCommon(fallback = {}) {
|
|
962
1006
|
const siteData = useSiteData();
|
|
963
1007
|
const content = isRecord(siteData?.content) ? siteData.content : null;
|
|
@@ -1043,3 +1087,37 @@ function useContact(fallback = {}) {
|
|
|
1043
1087
|
googleMapLink,
|
|
1044
1088
|
};
|
|
1045
1089
|
}
|
|
1090
|
+
/**
|
|
1091
|
+
* Universal Synced Branding Hook:
|
|
1092
|
+
* Guarantees real-time live synchronization for brand identity across visual editor preview,
|
|
1093
|
+
* merchant DB profile, and template defaults.
|
|
1094
|
+
* Hierarchy: Visual Editor Edits (content.common) -> Live Merchant Shop Profile -> Template Fallback.
|
|
1095
|
+
*/
|
|
1096
|
+
function useSyncedBranding(fallback = {}) {
|
|
1097
|
+
const siteData = useSiteData();
|
|
1098
|
+
const content = isRecord(siteData?.content) ? siteData.content : null;
|
|
1099
|
+
const common = isRecord(content?.common) ? content.common : {};
|
|
1100
|
+
const shop = useShop();
|
|
1101
|
+
const websiteTitle = (typeof common.websiteTitle === 'string' && common.websiteTitle.trim()) ||
|
|
1102
|
+
(typeof common.siteName === 'string' && common.siteName.trim()) ||
|
|
1103
|
+
(typeof shop.businessName === 'string' && shop.businessName.trim()) ||
|
|
1104
|
+
(typeof shop.name === 'string' && shop.name.trim()) ||
|
|
1105
|
+
(typeof fallback.websiteTitle === 'string' && fallback.websiteTitle.trim()) ||
|
|
1106
|
+
'Storefront';
|
|
1107
|
+
const logoUrl = (typeof common.logoUrl === 'string' && common.logoUrl.trim()) ||
|
|
1108
|
+
(typeof shop.logoUrl === 'string' && shop.logoUrl.trim()) ||
|
|
1109
|
+
(typeof fallback.logoUrl === 'string' && fallback.logoUrl.trim()) ||
|
|
1110
|
+
'';
|
|
1111
|
+
const brandSubtext = (typeof common.brandSubtext === 'string' && common.brandSubtext.trim()) ||
|
|
1112
|
+
(typeof common.slogan === 'string' && common.slogan.trim()) ||
|
|
1113
|
+
(typeof fallback.brandSubtext === 'string' && fallback.brandSubtext.trim()) ||
|
|
1114
|
+
'';
|
|
1115
|
+
const faviconUrl = logoUrl || fallback.faviconUrl || '';
|
|
1116
|
+
return {
|
|
1117
|
+
logoUrl,
|
|
1118
|
+
websiteTitle,
|
|
1119
|
+
brandSubtext,
|
|
1120
|
+
slogan: brandSubtext,
|
|
1121
|
+
faviconUrl,
|
|
1122
|
+
};
|
|
1123
|
+
}
|
package/dist/StickyMobileBar.js
CHANGED
|
@@ -18,11 +18,13 @@ const SiteDataProvider_1 = require("./SiteDataProvider");
|
|
|
18
18
|
* Created by Chamika Gayashan & Induranga Kawishwara
|
|
19
19
|
*/
|
|
20
20
|
function StickyMobileBar({ fieldPath, actions, showOnDesktop = false, className = '', style = {}, phone: propPhone, whatsapp: propWhatsapp, primaryActionLabel = 'Shop Now', primaryActionHref = '#products', onPrimaryAction, }) {
|
|
21
|
-
const
|
|
21
|
+
const siteData = (0, SiteDataProvider_1.useSiteData)();
|
|
22
22
|
// Resolve merchant contacts from siteData if not explicitly provided
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
23
|
+
const shop = siteData?.shop || siteData?.merchant || {};
|
|
24
|
+
const livePhone = shop?.contact?.phone || shop?.businessPhone || shop?.phone || shop?.supportPhone || '';
|
|
25
|
+
const liveWa = shop?.contact?.whatsapp || shop?.businessWhatsapp || shop?.whatsapp || shop?.phone || '';
|
|
26
|
+
const phone = propPhone || livePhone || '+94 11 234 5678';
|
|
27
|
+
const whatsapp = propWhatsapp || liveWa || '94771234567';
|
|
26
28
|
// Default action buttons if custom actions array is not provided
|
|
27
29
|
const resolvedActions = actions || [
|
|
28
30
|
...(phone
|
|
@@ -8,17 +8,22 @@ const SiteDataProvider_1 = require("../SiteDataProvider");
|
|
|
8
8
|
function EmailButton({ email, value, label = 'Email Us', fieldPath = 'common.business.email', variant = 'outline', ...rest }) {
|
|
9
9
|
const liveShop = (0, SiteDataProvider_1.useShop)();
|
|
10
10
|
const siteData = (0, SiteDataProvider_1.useSiteData)();
|
|
11
|
+
const isPreview = (0, SiteDataProvider_1.isPreviewValidation)(siteData);
|
|
11
12
|
const content = (siteData?.content && typeof siteData.content === 'object' ? siteData.content : {});
|
|
12
13
|
const common = (content.common && typeof content.common === 'object' ? content.common : {});
|
|
13
14
|
const contact = (content.contact && typeof content.contact === 'object' ? content.contact : (common.contact && typeof common.contact === 'object' ? common.contact : {}));
|
|
14
15
|
const merchant = (siteData && 'merchant' in siteData && typeof siteData.merchant === 'object' ? siteData.merchant : {});
|
|
16
|
+
const liveEmail = liveShop?.contact?.email ||
|
|
17
|
+
(typeof liveShop?.businessEmail === 'string' ? liveShop.businessEmail : null);
|
|
15
18
|
const effectiveEmail = email ||
|
|
19
|
+
(!isPreview ? liveEmail : null) ||
|
|
16
20
|
value ||
|
|
17
|
-
liveShop?.contact?.email ||
|
|
18
21
|
contact.email ||
|
|
22
|
+
contact.emailAddress ||
|
|
19
23
|
common.email ||
|
|
24
|
+
common.emailAddress ||
|
|
20
25
|
merchant.email ||
|
|
21
|
-
'';
|
|
26
|
+
(isPreview ? SiteDataProvider_1.DUMMY_PREVIEW_EMAIL : '');
|
|
22
27
|
if (!effectiveEmail && !fieldPath)
|
|
23
28
|
return null;
|
|
24
29
|
return ((0, jsx_runtime_1.jsx)(ContactButton_1.ContactButton, { type: "email", value: effectiveEmail, label: label, fieldPath: fieldPath, variant: variant, ...rest }));
|
|
@@ -8,17 +8,24 @@ const SiteDataProvider_1 = require("../SiteDataProvider");
|
|
|
8
8
|
function PhoneButton({ phoneNumber, value, label = 'Call Us', fieldPath = 'common.business.phone', variant = 'primary', ...rest }) {
|
|
9
9
|
const liveShop = (0, SiteDataProvider_1.useShop)();
|
|
10
10
|
const siteData = (0, SiteDataProvider_1.useSiteData)();
|
|
11
|
+
const isPreview = (0, SiteDataProvider_1.isPreviewValidation)(siteData);
|
|
11
12
|
const content = (siteData?.content && typeof siteData.content === 'object' ? siteData.content : {});
|
|
12
13
|
const common = (content.common && typeof content.common === 'object' ? content.common : {});
|
|
13
14
|
const contact = (content.contact && typeof content.contact === 'object' ? content.contact : (common.contact && typeof common.contact === 'object' ? common.contact : {}));
|
|
14
15
|
const merchant = (siteData && 'merchant' in siteData && typeof siteData.merchant === 'object' ? siteData.merchant : {});
|
|
16
|
+
const liveNumber = liveShop?.contact?.phone ||
|
|
17
|
+
(typeof liveShop?.businessPhone === 'string' ? liveShop.businessPhone : null) ||
|
|
18
|
+
liveShop?.contact?.whatsapp ||
|
|
19
|
+
(typeof liveShop?.businessWhatsapp === 'string' ? liveShop.businessWhatsapp : null);
|
|
15
20
|
const effectiveNumber = phoneNumber ||
|
|
21
|
+
(!isPreview ? liveNumber : null) ||
|
|
16
22
|
value ||
|
|
17
|
-
liveShop?.contact?.phone ||
|
|
18
23
|
contact.phone ||
|
|
24
|
+
contact.contactNumber ||
|
|
19
25
|
common.phone ||
|
|
26
|
+
common.contactNumber ||
|
|
20
27
|
merchant.phone ||
|
|
21
|
-
'';
|
|
28
|
+
(isPreview ? SiteDataProvider_1.DUMMY_PREVIEW_PHONE : '');
|
|
22
29
|
if (!effectiveNumber && !fieldPath)
|
|
23
30
|
return null;
|
|
24
31
|
return ((0, jsx_runtime_1.jsx)(ContactButton_1.ContactButton, { type: "phone", value: effectiveNumber, label: label, fieldPath: fieldPath, variant: variant, ...rest }));
|
|
@@ -6,5 +6,6 @@ export interface WhatsAppButtonProps extends Omit<ContactButtonProps, 'type'> {
|
|
|
6
6
|
/**
|
|
7
7
|
* WhatsAppButton automatically connects customers directly to the shop's WhatsApp chat.
|
|
8
8
|
* Self-hydrates from live shop registration, contact config, and merchant profile if phoneNumber is omitted.
|
|
9
|
+
* In preview mode, defaults to template dummy preview data.
|
|
9
10
|
*/
|
|
10
11
|
export declare function WhatsAppButton({ phoneNumber, value, label, fieldPath, variant, message, ...rest }: WhatsAppButtonProps): React.JSX.Element | null;
|
|
@@ -8,27 +8,34 @@ const SiteDataProvider_1 = require("../SiteDataProvider");
|
|
|
8
8
|
/**
|
|
9
9
|
* WhatsAppButton automatically connects customers directly to the shop's WhatsApp chat.
|
|
10
10
|
* Self-hydrates from live shop registration, contact config, and merchant profile if phoneNumber is omitted.
|
|
11
|
+
* In preview mode, defaults to template dummy preview data.
|
|
11
12
|
*/
|
|
12
13
|
function WhatsAppButton({ phoneNumber, value, label = 'Chat on WhatsApp', fieldPath = 'common.business.whatsapp', variant = 'whatsapp', message, ...rest }) {
|
|
13
14
|
const liveShop = (0, SiteDataProvider_1.useShop)();
|
|
14
15
|
const siteData = (0, SiteDataProvider_1.useSiteData)();
|
|
16
|
+
const isPreview = (0, SiteDataProvider_1.isPreviewValidation)(siteData);
|
|
15
17
|
const content = (siteData?.content && typeof siteData.content === 'object' ? siteData.content : {});
|
|
16
18
|
const common = (content.common && typeof content.common === 'object' ? content.common : {});
|
|
17
19
|
const contact = (content.contact && typeof content.contact === 'object' ? content.contact : (common.contact && typeof common.contact === 'object' ? common.contact : {}));
|
|
18
20
|
const home = (content.home && typeof content.home === 'object' ? content.home : {});
|
|
19
21
|
const merchant = (siteData && 'merchant' in siteData && typeof siteData.merchant === 'object' ? siteData.merchant : {});
|
|
22
|
+
const liveNumber = liveShop?.contact?.whatsapp ||
|
|
23
|
+
(typeof liveShop?.businessWhatsapp === 'string' ? liveShop.businessWhatsapp : null) ||
|
|
24
|
+
liveShop?.contact?.phone ||
|
|
25
|
+
(typeof liveShop?.businessPhone === 'string' ? liveShop.businessPhone : null);
|
|
20
26
|
const effectiveNumber = phoneNumber ||
|
|
27
|
+
(!isPreview ? liveNumber : null) ||
|
|
21
28
|
value ||
|
|
22
|
-
liveShop?.contact?.whatsapp ||
|
|
23
|
-
liveShop?.contact?.phone ||
|
|
24
29
|
contact.whatsapp ||
|
|
30
|
+
contact.whatsappNumber ||
|
|
25
31
|
contact.phone ||
|
|
26
32
|
home.whatsappNumber ||
|
|
27
33
|
home.whatsappCtaUrl ||
|
|
28
34
|
common.whatsapp ||
|
|
35
|
+
common.whatsappNumber ||
|
|
29
36
|
merchant.whatsapp ||
|
|
30
37
|
merchant.phone ||
|
|
31
|
-
'';
|
|
38
|
+
(isPreview ? SiteDataProvider_1.DUMMY_PREVIEW_WHATSAPP : '');
|
|
32
39
|
if (!effectiveNumber && !fieldPath)
|
|
33
40
|
return null;
|
|
34
41
|
return ((0, jsx_runtime_1.jsx)(ContactButton_1.ContactButton, { type: "whatsapp", value: effectiveNumber, label: label, fieldPath: fieldPath, variant: variant, message: message, ...rest }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deneb-ui/ui",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.101",
|
|
4
4
|
"description": "Visual-first React component library for editable commerce storefronts. Built for Next.js and Fivora.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
],
|
|
51
51
|
"license": "MIT",
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@deneb-ui/core": "^2.0.
|
|
53
|
+
"@deneb-ui/core": "^2.0.101"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"react": "^18.0.0 || ^19.0.0",
|