@deneb-ui/ui 2.0.99 → 2.0.100
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 +10 -0
- package/dist/SiteDataProvider.js +80 -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,6 +151,16 @@ 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)
|
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,6 +26,7 @@ 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;
|
|
31
32
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
@@ -251,13 +252,20 @@ function SiteDataProvider({ children, initialSiteData, fallbackSiteData, liveCat
|
|
|
251
252
|
window.location.pathname.includes('/preview/')))) {
|
|
252
253
|
return;
|
|
253
254
|
}
|
|
255
|
+
const isLocalhost = typeof window !== 'undefined' &&
|
|
256
|
+
(window.location.hostname === 'localhost' ||
|
|
257
|
+
window.location.hostname === '127.0.0.1');
|
|
254
258
|
const endpoint = liveCatalogEndpoint ||
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
:
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
(isLocalhost &&
|
|
260
|
+
initialSiteData?.api?.catalogUrl &&
|
|
261
|
+
initialSiteData.api.catalogUrl.includes('api.fivora.site')
|
|
262
|
+
? `http://localhost:3000/site-catalog/${candidateSlug}/live-data`
|
|
263
|
+
: initialSiteData?.api?.catalogUrl ||
|
|
264
|
+
(candidateSlug && initialSiteData?.api?.baseUrl
|
|
265
|
+
? `${initialSiteData.api.baseUrl.replace(/\/+$/, '')}/site-catalog/${candidateSlug}/live-data`
|
|
266
|
+
: candidateSlug
|
|
267
|
+
? `/site-catalog/${candidateSlug}/live-data`
|
|
268
|
+
: null));
|
|
261
269
|
if (!endpoint)
|
|
262
270
|
return;
|
|
263
271
|
let stopped = false;
|
|
@@ -288,40 +296,50 @@ function SiteDataProvider({ children, initialSiteData, fallbackSiteData, liveCat
|
|
|
288
296
|
nextMerchant = mergeSiteData(nextMerchant, live.shop);
|
|
289
297
|
const contact = isRecord(live.shop.contact) ? live.shop.contact : null;
|
|
290
298
|
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
|
-
|
|
299
|
+
const phoneVal = (contact && typeof contact.phone === 'string' && contact.phone.trim()) ||
|
|
300
|
+
(typeof live.shop.businessPhone === 'string' && live.shop.businessPhone.trim()) ||
|
|
301
|
+
null;
|
|
302
|
+
if (phoneVal) {
|
|
303
|
+
nextContact.phone = phoneVal;
|
|
304
|
+
nextContact.contactNumber = phoneVal;
|
|
305
|
+
nextCommon.contactNumber = phoneVal;
|
|
306
|
+
nextCommon.phone = phoneVal;
|
|
307
|
+
}
|
|
308
|
+
const whatsappVal = (contact && typeof contact.whatsapp === 'string' && contact.whatsapp.trim()) ||
|
|
309
|
+
(typeof live.shop.businessWhatsapp === 'string' && live.shop.businessWhatsapp.trim()) ||
|
|
310
|
+
null;
|
|
311
|
+
if (whatsappVal) {
|
|
312
|
+
nextContact.whatsapp = whatsappVal;
|
|
313
|
+
nextCommon.whatsapp = whatsappVal;
|
|
314
|
+
const cleanWa = whatsappVal.replace(/\D/g, '');
|
|
315
|
+
if (cleanWa) {
|
|
316
|
+
nextContact.whatsappNumber = cleanWa;
|
|
317
|
+
nextCommon.whatsappNumber = cleanWa;
|
|
318
|
+
nextHome.whatsappNumber = cleanWa;
|
|
319
|
+
// Dynamically update any hardcoded or static wa.me URLs across home and common
|
|
320
|
+
const waRegex = /(https?:\/\/(?:wa\.me|api\.whatsapp\.com\/send\?phone=))\d+/gi;
|
|
321
|
+
for (const key of ['whatsappCtaUrl', 'whatsappOrderUrl', 'whatsappUrl']) {
|
|
322
|
+
if (typeof nextHome[key] === 'string' && waRegex.test(nextHome[key])) {
|
|
323
|
+
nextHome[key] = nextHome[key].replace(waRegex, `$1${cleanWa}`);
|
|
315
324
|
}
|
|
316
|
-
if (
|
|
317
|
-
nextCommon
|
|
325
|
+
if (typeof nextCommon[key] === 'string' && waRegex.test(nextCommon[key])) {
|
|
326
|
+
nextCommon[key] = nextCommon[key].replace(waRegex, `$1${cleanWa}`);
|
|
318
327
|
}
|
|
319
328
|
}
|
|
329
|
+
if (!nextCommon.whatsappUrl || waRegex.test(nextCommon.whatsappUrl)) {
|
|
330
|
+
nextCommon.whatsappUrl = `https://wa.me/${cleanWa}`;
|
|
331
|
+
}
|
|
320
332
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
333
|
+
}
|
|
334
|
+
const emailVal = (contact && typeof contact.email === 'string' && contact.email.trim()) ||
|
|
335
|
+
(typeof live.shop.businessEmail === 'string' && live.shop.businessEmail.trim()) ||
|
|
336
|
+
null;
|
|
337
|
+
if (emailVal) {
|
|
338
|
+
nextContact.email = emailVal;
|
|
339
|
+
nextCommon.email = emailVal;
|
|
340
|
+
}
|
|
341
|
+
if (typeof live.shop.businessName === 'string' && live.shop.businessName.trim()) {
|
|
342
|
+
nextCommon.websiteTitle = live.shop.businessName.trim();
|
|
325
343
|
}
|
|
326
344
|
if (address) {
|
|
327
345
|
const street = address.street || address.line1;
|
|
@@ -958,6 +976,31 @@ function useReviews(fallback = []) {
|
|
|
958
976
|
* with safe hierarchical fallbacks across content.common, shop profile, and user fallbacks.
|
|
959
977
|
* Never throws ReferenceError or crashes on missing data.
|
|
960
978
|
*/
|
|
979
|
+
exports.DUMMY_PREVIEW_PHONE = '+94 11 234 5678';
|
|
980
|
+
exports.DUMMY_PREVIEW_WHATSAPP = '94771234567';
|
|
981
|
+
exports.DUMMY_PREVIEW_EMAIL = 'info@store.com';
|
|
982
|
+
exports.DUMMY_PREVIEW_ADDRESS = 'Flagship Studio: Galle Face Promenade, Colombo 03, Sri Lanka';
|
|
983
|
+
exports.DUMMY_PREVIEW_SHOP_NAME = 'Storefront';
|
|
984
|
+
/**
|
|
985
|
+
* Checks whether the active storefront runtime is running in visual editor preview,
|
|
986
|
+
* template authoring frame, or automated template validation.
|
|
987
|
+
*/
|
|
988
|
+
function isPreviewValidation(siteData) {
|
|
989
|
+
if (!siteData)
|
|
990
|
+
return true;
|
|
991
|
+
const slug = siteData?.project?.slug || siteData?.siteInstance?.slug;
|
|
992
|
+
const id = siteData?.project?.id;
|
|
993
|
+
if (slug === 'template-validation' || id === 'template-validation' || slug === 'preview' || id === 'preview') {
|
|
994
|
+
return true;
|
|
995
|
+
}
|
|
996
|
+
if (typeof window !== 'undefined') {
|
|
997
|
+
const path = window.location.pathname || '';
|
|
998
|
+
if (path.includes('/template-validation') || path.includes('/template-preview') || path.includes('/preview/')) {
|
|
999
|
+
return true;
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
return false;
|
|
1003
|
+
}
|
|
961
1004
|
function useCommon(fallback = {}) {
|
|
962
1005
|
const siteData = useSiteData();
|
|
963
1006
|
const content = isRecord(siteData?.content) ? siteData.content : null;
|
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.100",
|
|
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.100"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"react": "^18.0.0 || ^19.0.0",
|