@deneb-ui/ui 2.0.79 → 2.0.80
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/SiteDataProvider.d.ts +11 -0
- package/dist/SiteDataProvider.js +92 -0
- package/package.json +2 -2
|
@@ -135,3 +135,14 @@ export declare function useShop(fallback?: GenericRecord): GenericRecord;
|
|
|
135
135
|
* Hook to retrieve customer reviews / testimonials cleanly from SiteData.
|
|
136
136
|
*/
|
|
137
137
|
export declare function useReviews(fallback?: GenericRecord[]): GenericRecord[];
|
|
138
|
+
/**
|
|
139
|
+
* Hook to retrieve common storefront metadata (website title, slogan, branding, etc.)
|
|
140
|
+
* with safe hierarchical fallbacks across content.common, shop profile, and user fallbacks.
|
|
141
|
+
* Never throws ReferenceError or crashes on missing data.
|
|
142
|
+
*/
|
|
143
|
+
export declare function useCommon(fallback?: GenericRecord): GenericRecord;
|
|
144
|
+
/**
|
|
145
|
+
* Hook to retrieve contact information (WhatsApp, phone, address, email, map link)
|
|
146
|
+
* with robust fallbacks across contact, common, and shop profile.
|
|
147
|
+
*/
|
|
148
|
+
export declare function useContact(fallback?: GenericRecord): GenericRecord;
|
package/dist/SiteDataProvider.js
CHANGED
|
@@ -24,6 +24,8 @@ exports.useSiteApi = useSiteApi;
|
|
|
24
24
|
exports.useSiteCatalog = useSiteCatalog;
|
|
25
25
|
exports.useShop = useShop;
|
|
26
26
|
exports.useReviews = useReviews;
|
|
27
|
+
exports.useCommon = useCommon;
|
|
28
|
+
exports.useContact = useContact;
|
|
27
29
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
30
|
const react_1 = require("react");
|
|
29
31
|
const core_1 = require("@deneb-ui/core");
|
|
@@ -773,3 +775,93 @@ function useReviews(fallback = []) {
|
|
|
773
775
|
}
|
|
774
776
|
return fallback;
|
|
775
777
|
}
|
|
778
|
+
/**
|
|
779
|
+
* Hook to retrieve common storefront metadata (website title, slogan, branding, etc.)
|
|
780
|
+
* with safe hierarchical fallbacks across content.common, shop profile, and user fallbacks.
|
|
781
|
+
* Never throws ReferenceError or crashes on missing data.
|
|
782
|
+
*/
|
|
783
|
+
function useCommon(fallback = {}) {
|
|
784
|
+
const siteData = useSiteData();
|
|
785
|
+
const content = isRecord(siteData?.content) ? siteData.content : null;
|
|
786
|
+
const common = isRecord(content?.common) ? content.common : {};
|
|
787
|
+
const contact = isRecord(content?.contact) ? content.contact : {};
|
|
788
|
+
const shop = useShop();
|
|
789
|
+
const websiteTitle = (typeof common.websiteTitle === 'string' && common.websiteTitle.trim()) ||
|
|
790
|
+
(typeof shop.name === 'string' && shop.name.trim()) ||
|
|
791
|
+
(typeof shop.businessName === 'string' && shop.businessName.trim()) ||
|
|
792
|
+
(typeof fallback.websiteTitle === 'string' && fallback.websiteTitle.trim()) ||
|
|
793
|
+
'Store';
|
|
794
|
+
const whatsappNumber = (typeof common.whatsappNumber === 'string' && common.whatsappNumber.trim()) ||
|
|
795
|
+
(typeof contact.whatsappNumber === 'string' && contact.whatsappNumber.trim()) ||
|
|
796
|
+
(typeof shop.whatsappNumber === 'string' && shop.whatsappNumber.trim()) ||
|
|
797
|
+
(typeof shop.phone === 'string' && shop.phone.trim()) ||
|
|
798
|
+
(typeof fallback.whatsappNumber === 'string' && fallback.whatsappNumber.trim()) ||
|
|
799
|
+
'';
|
|
800
|
+
const cleanWa = whatsappNumber.replace(/\D+/g, '');
|
|
801
|
+
const whatsappUrl = (typeof common.whatsappUrl === 'string' && common.whatsappUrl.trim()) ||
|
|
802
|
+
(cleanWa ? `https://wa.me/${cleanWa}` : '') ||
|
|
803
|
+
(typeof fallback.whatsappUrl === 'string' && fallback.whatsappUrl.trim()) ||
|
|
804
|
+
'';
|
|
805
|
+
const address = (typeof common.address === 'string' && common.address.trim()) ||
|
|
806
|
+
(typeof common.footerAddress === 'string' && common.footerAddress.trim()) ||
|
|
807
|
+
(typeof contact.address === 'string' && contact.address.trim()) ||
|
|
808
|
+
(typeof shop.address === 'string' && shop.address.trim()) ||
|
|
809
|
+
(typeof fallback.address === 'string' && fallback.address.trim()) ||
|
|
810
|
+
'';
|
|
811
|
+
const logoUrl = (typeof common.logoUrl === 'string' && common.logoUrl.trim()) ||
|
|
812
|
+
(typeof shop.logoUrl === 'string' && shop.logoUrl.trim()) ||
|
|
813
|
+
(typeof fallback.logoUrl === 'string' && fallback.logoUrl.trim()) ||
|
|
814
|
+
'';
|
|
815
|
+
return {
|
|
816
|
+
...fallback,
|
|
817
|
+
...common,
|
|
818
|
+
websiteTitle,
|
|
819
|
+
whatsappNumber,
|
|
820
|
+
whatsappUrl,
|
|
821
|
+
address,
|
|
822
|
+
logoUrl,
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* Hook to retrieve contact information (WhatsApp, phone, address, email, map link)
|
|
827
|
+
* with robust fallbacks across contact, common, and shop profile.
|
|
828
|
+
*/
|
|
829
|
+
function useContact(fallback = {}) {
|
|
830
|
+
const siteData = useSiteData();
|
|
831
|
+
const content = isRecord(siteData?.content) ? siteData.content : null;
|
|
832
|
+
const contact = isRecord(content?.contact) ? content.contact : {};
|
|
833
|
+
const common = isRecord(content?.common) ? content.common : {};
|
|
834
|
+
const shop = useShop();
|
|
835
|
+
const whatsappNumber = (typeof contact.whatsappNumber === 'string' && contact.whatsappNumber.trim()) ||
|
|
836
|
+
(typeof common.whatsappNumber === 'string' && common.whatsappNumber.trim()) ||
|
|
837
|
+
(typeof shop.whatsappNumber === 'string' && shop.whatsappNumber.trim()) ||
|
|
838
|
+
(typeof shop.phone === 'string' && shop.phone.trim()) ||
|
|
839
|
+
(typeof fallback.whatsappNumber === 'string' && fallback.whatsappNumber.trim()) ||
|
|
840
|
+
'';
|
|
841
|
+
const cleanWa = whatsappNumber.replace(/\D+/g, '');
|
|
842
|
+
const whatsappUrl = (typeof contact.whatsappUrl === 'string' && contact.whatsappUrl.trim()) ||
|
|
843
|
+
(typeof common.whatsappUrl === 'string' && common.whatsappUrl.trim()) ||
|
|
844
|
+
(cleanWa ? `https://wa.me/${cleanWa}` : '') ||
|
|
845
|
+
'';
|
|
846
|
+
const address = (typeof contact.address === 'string' && contact.address.trim()) ||
|
|
847
|
+
(typeof common.address === 'string' && common.address.trim()) ||
|
|
848
|
+
(typeof shop.address === 'string' && shop.address.trim()) ||
|
|
849
|
+
(typeof fallback.address === 'string' && fallback.address.trim()) ||
|
|
850
|
+
'';
|
|
851
|
+
const email = (typeof contact.email === 'string' && contact.email.trim()) ||
|
|
852
|
+
(typeof shop.email === 'string' && shop.email.trim()) ||
|
|
853
|
+
(typeof fallback.email === 'string' && fallback.email.trim()) ||
|
|
854
|
+
'';
|
|
855
|
+
const googleMapLink = (typeof contact.googleMapLink === 'string' && contact.googleMapLink.trim()) ||
|
|
856
|
+
(typeof fallback.googleMapLink === 'string' && fallback.googleMapLink.trim()) ||
|
|
857
|
+
'';
|
|
858
|
+
return {
|
|
859
|
+
...fallback,
|
|
860
|
+
...contact,
|
|
861
|
+
whatsappNumber,
|
|
862
|
+
whatsappUrl,
|
|
863
|
+
address,
|
|
864
|
+
email,
|
|
865
|
+
googleMapLink,
|
|
866
|
+
};
|
|
867
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deneb-ui/ui",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.80",
|
|
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.80"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"react": "^18.0.0 || ^19.0.0",
|