@redneckz/wildless-cms-uni-blocks 0.8.5 → 0.8.7
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/bundle/bundle.umd.js +38 -43
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/Footer/Sitemap.d.ts +0 -2
- package/bundle/components/Header/Header.fallback.d.ts +1 -2
- package/bundle/hooks/useLink.d.ts +6 -5
- package/bundle/services/sitemap/fallbackWCMSResource.d.ts +2 -0
- package/bundle/services/sitemap/isHrefActive.d.ts +4 -2
- package/bundle/services/sitemap/useSWRResource.d.ts +1 -1
- package/bundle/utils/url.d.ts +1 -3
- package/dist/components/Footer/Footer.fallback.js +3 -6
- package/dist/components/Footer/Footer.fallback.js.map +1 -1
- package/dist/components/Footer/Sitemap.d.ts +0 -2
- package/dist/components/Footer/Sitemap.js +2 -4
- package/dist/components/Footer/Sitemap.js.map +1 -1
- package/dist/components/Header/Header.fallback.d.ts +1 -2
- package/dist/components/Header/Header.fallback.js +2 -7
- package/dist/components/Header/Header.fallback.js.map +1 -1
- package/dist/hooks/useLink.d.ts +6 -5
- package/dist/hooks/useLink.js +26 -18
- package/dist/hooks/useLink.js.map +1 -1
- package/dist/services/BlockRouter/BlockRouter.js +1 -1
- package/dist/services/BlockRouter/BlockRouter.js.map +1 -1
- package/dist/services/sitemap/fallbackWCMSResource.d.ts +2 -0
- package/dist/services/sitemap/fallbackWCMSResource.js +8 -0
- package/dist/services/sitemap/fallbackWCMSResource.js.map +1 -0
- package/dist/services/sitemap/isHrefActive.d.ts +4 -2
- package/dist/services/sitemap/isHrefActive.js +1 -6
- package/dist/services/sitemap/isHrefActive.js.map +1 -1
- package/dist/services/sitemap/isTopItemActive.js +4 -1
- package/dist/services/sitemap/isTopItemActive.js.map +1 -1
- package/dist/services/sitemap/useSWRResource.d.ts +1 -1
- package/dist/services/sitemap/useSWRResource.js +2 -2
- package/dist/setup-fixture.js +3 -1
- package/dist/setup-fixture.js.map +1 -1
- package/dist/utils/url.d.ts +1 -3
- package/dist/utils/url.js +4 -8
- package/dist/utils/url.js.map +1 -1
- package/lib/components/Footer/Footer.fallback.js +1 -4
- package/lib/components/Footer/Footer.fallback.js.map +1 -1
- package/lib/components/Footer/Sitemap.d.ts +0 -2
- package/lib/components/Footer/Sitemap.js +2 -4
- package/lib/components/Footer/Sitemap.js.map +1 -1
- package/lib/components/Header/Header.fallback.d.ts +1 -2
- package/lib/components/Header/Header.fallback.js +2 -7
- package/lib/components/Header/Header.fallback.js.map +1 -1
- package/lib/hooks/useLink.d.ts +6 -5
- package/lib/hooks/useLink.js +27 -19
- package/lib/hooks/useLink.js.map +1 -1
- package/lib/services/BlockRouter/BlockRouter.js +1 -1
- package/lib/services/BlockRouter/BlockRouter.js.map +1 -1
- package/lib/services/sitemap/fallbackWCMSResource.d.ts +2 -0
- package/lib/services/sitemap/fallbackWCMSResource.js +5 -0
- package/lib/services/sitemap/fallbackWCMSResource.js.map +1 -0
- package/lib/services/sitemap/isHrefActive.d.ts +4 -2
- package/lib/services/sitemap/isHrefActive.js +1 -6
- package/lib/services/sitemap/isHrefActive.js.map +1 -1
- package/lib/services/sitemap/isTopItemActive.js +4 -1
- package/lib/services/sitemap/isTopItemActive.js.map +1 -1
- package/lib/services/sitemap/useSWRResource.d.ts +1 -1
- package/lib/services/sitemap/useSWRResource.js +2 -2
- package/lib/setup-fixture.js +3 -1
- package/lib/setup-fixture.js.map +1 -1
- package/lib/utils/url.d.ts +1 -3
- package/lib/utils/url.js +2 -4
- package/lib/utils/url.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +36 -35
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/Footer/Sitemap.d.ts +0 -2
- package/mobile/bundle/components/Header/Header.fallback.d.ts +1 -2
- package/mobile/bundle/hooks/useLink.d.ts +6 -5
- package/mobile/bundle/services/sitemap/fallbackWCMSResource.d.ts +2 -0
- package/mobile/bundle/services/sitemap/isHrefActive.d.ts +4 -2
- package/mobile/bundle/services/sitemap/useSWRResource.d.ts +1 -1
- package/mobile/bundle/utils/url.d.ts +1 -3
- package/mobile/dist/components/Footer/Footer.fallback.js +3 -6
- package/mobile/dist/components/Footer/Footer.fallback.js.map +1 -1
- package/mobile/dist/components/Footer/Sitemap.d.ts +0 -2
- package/mobile/dist/components/Footer/Sitemap.js +2 -4
- package/mobile/dist/components/Footer/Sitemap.js.map +1 -1
- package/mobile/dist/components/Header/Header.fallback.d.ts +1 -2
- package/mobile/dist/components/Header/Header.fallback.js +2 -7
- package/mobile/dist/components/Header/Header.fallback.js.map +1 -1
- package/mobile/dist/hooks/useLink.d.ts +6 -5
- package/mobile/dist/hooks/useLink.js +26 -18
- package/mobile/dist/hooks/useLink.js.map +1 -1
- package/mobile/dist/services/BlockRouter/BlockRouter.js +1 -1
- package/mobile/dist/services/BlockRouter/BlockRouter.js.map +1 -1
- package/mobile/dist/services/sitemap/fallbackWCMSResource.d.ts +2 -0
- package/mobile/dist/services/sitemap/fallbackWCMSResource.js +8 -0
- package/mobile/dist/services/sitemap/fallbackWCMSResource.js.map +1 -0
- package/mobile/dist/services/sitemap/isHrefActive.d.ts +4 -2
- package/mobile/dist/services/sitemap/isHrefActive.js +1 -6
- package/mobile/dist/services/sitemap/isHrefActive.js.map +1 -1
- package/mobile/dist/services/sitemap/isTopItemActive.js +4 -1
- package/mobile/dist/services/sitemap/isTopItemActive.js.map +1 -1
- package/mobile/dist/services/sitemap/useSWRResource.d.ts +1 -1
- package/mobile/dist/services/sitemap/useSWRResource.js +2 -2
- package/mobile/dist/setup-fixture.js +3 -1
- package/mobile/dist/setup-fixture.js.map +1 -1
- package/mobile/dist/utils/url.d.ts +1 -3
- package/mobile/dist/utils/url.js +4 -8
- package/mobile/dist/utils/url.js.map +1 -1
- package/mobile/lib/components/Footer/Footer.fallback.js +1 -4
- package/mobile/lib/components/Footer/Footer.fallback.js.map +1 -1
- package/mobile/lib/components/Footer/Sitemap.d.ts +0 -2
- package/mobile/lib/components/Footer/Sitemap.js +2 -4
- package/mobile/lib/components/Footer/Sitemap.js.map +1 -1
- package/mobile/lib/components/Header/Header.fallback.d.ts +1 -2
- package/mobile/lib/components/Header/Header.fallback.js +2 -7
- package/mobile/lib/components/Header/Header.fallback.js.map +1 -1
- package/mobile/lib/hooks/useLink.d.ts +6 -5
- package/mobile/lib/hooks/useLink.js +27 -19
- package/mobile/lib/hooks/useLink.js.map +1 -1
- package/mobile/lib/services/BlockRouter/BlockRouter.js +1 -1
- package/mobile/lib/services/BlockRouter/BlockRouter.js.map +1 -1
- package/mobile/lib/services/sitemap/fallbackWCMSResource.d.ts +2 -0
- package/mobile/lib/services/sitemap/fallbackWCMSResource.js +5 -0
- package/mobile/lib/services/sitemap/fallbackWCMSResource.js.map +1 -0
- package/mobile/lib/services/sitemap/isHrefActive.d.ts +4 -2
- package/mobile/lib/services/sitemap/isHrefActive.js +1 -6
- package/mobile/lib/services/sitemap/isHrefActive.js.map +1 -1
- package/mobile/lib/services/sitemap/isTopItemActive.js +4 -1
- package/mobile/lib/services/sitemap/isTopItemActive.js.map +1 -1
- package/mobile/lib/services/sitemap/useSWRResource.d.ts +1 -1
- package/mobile/lib/services/sitemap/useSWRResource.js +2 -2
- package/mobile/lib/setup-fixture.js +3 -1
- package/mobile/lib/setup-fixture.js.map +1 -1
- package/mobile/lib/utils/url.d.ts +1 -3
- package/mobile/lib/utils/url.js +2 -4
- package/mobile/lib/utils/url.js.map +1 -1
- package/mobile/src/components/Footer/Footer.fallback.ts +1 -6
- package/mobile/src/components/Footer/Sitemap.tsx +2 -6
- package/mobile/src/components/Header/Header.fallback.ts +2 -12
- package/mobile/src/hooks/useLink.ts +31 -20
- package/mobile/src/services/BlockRouter/BlockRouter.ts +1 -1
- package/mobile/src/services/sitemap/fallbackWCMSResource.ts +7 -0
- package/mobile/src/services/sitemap/isHrefActive.ts +3 -12
- package/mobile/src/services/sitemap/isTopItemActive.ts +4 -1
- package/mobile/src/services/sitemap/useSWRResource.ts +2 -2
- package/mobile/src/setup-fixture.ts +3 -1
- package/mobile/src/utils/url.ts +4 -4
- package/package.json +1 -1
- package/src/components/Footer/Footer.fallback.ts +1 -6
- package/src/components/Footer/Sitemap.tsx +2 -6
- package/src/components/Header/Header.fallback.ts +2 -12
- package/src/hooks/useLink.ts +31 -20
- package/src/services/BlockRouter/BlockRouter.ts +1 -1
- package/src/services/sitemap/fallbackWCMSResource.ts +7 -0
- package/src/services/sitemap/isHrefActive.ts +3 -12
- package/src/services/sitemap/isTopItemActive.ts +4 -1
- package/src/services/sitemap/useSWRResource.ts +2 -2
- package/src/setup-fixture.ts +3 -1
- package/src/utils/url.ts +4 -4
- package/bundle/services/sitemap/mergeTopItems.d.ts +0 -2
- package/dist/services/sitemap/mergeTopItems.d.ts +0 -2
- package/dist/services/sitemap/mergeTopItems.js +0 -8
- package/dist/services/sitemap/mergeTopItems.js.map +0 -1
- package/lib/services/sitemap/mergeTopItems.d.ts +0 -2
- package/lib/services/sitemap/mergeTopItems.js +0 -5
- package/lib/services/sitemap/mergeTopItems.js.map +0 -1
- package/mobile/bundle/services/sitemap/mergeTopItems.d.ts +0 -2
- package/mobile/dist/services/sitemap/mergeTopItems.d.ts +0 -2
- package/mobile/dist/services/sitemap/mergeTopItems.js +0 -8
- package/mobile/dist/services/sitemap/mergeTopItems.js.map +0 -1
- package/mobile/lib/services/sitemap/mergeTopItems.d.ts +0 -2
- package/mobile/lib/services/sitemap/mergeTopItems.js +0 -5
- package/mobile/lib/services/sitemap/mergeTopItems.js.map +0 -1
- package/mobile/src/services/sitemap/mergeTopItems.ts +0 -12
- package/src/services/sitemap/mergeTopItems.ts +0 -12
package/bundle/bundle.umd.js
CHANGED
|
@@ -342,7 +342,7 @@
|
|
|
342
342
|
.concat(1);
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
-
const normalizeAnchor = (rawAnchor) => rawAnchor?.replace('#', '');
|
|
345
|
+
const normalizeAnchor = (rawAnchor) => rawAnchor?.replace('#', '') || '';
|
|
346
346
|
const getURLWithAnchor = (rawAnchor) => `${globalThis.location?.pathname}#${normalizeAnchor(rawAnchor)}`;
|
|
347
347
|
class BlockRouter {
|
|
348
348
|
static inst = new BlockRouter();
|
|
@@ -658,10 +658,8 @@
|
|
|
658
658
|
const isURL = (href) => Boolean(href?.includes('//'));
|
|
659
659
|
const isLocalURL = (href, target) => Boolean(href && !isURL(href) && (!target || target === '_self'));
|
|
660
660
|
const isHash = (href) => Boolean(href?.startsWith('#'));
|
|
661
|
-
const withoutQuery = (href) => (href || '').replace(
|
|
662
|
-
const
|
|
663
|
-
const getPathname = (href) => (isURL(href) ? new URL(href).pathname : undefined);
|
|
664
|
-
const getHash = (href) => (isURL(href) ? new URL(href).hash : undefined);
|
|
661
|
+
const withoutQuery = (href) => (href || '').replace(/\?.*/, '').replace(/\/$/, '');
|
|
662
|
+
const joinPath = (...path) => path.filter(Boolean).join('/').replace(/\/+/g, '/');
|
|
665
663
|
|
|
666
664
|
var url = /*#__PURE__*/Object.freeze({
|
|
667
665
|
__proto__: null,
|
|
@@ -669,9 +667,7 @@
|
|
|
669
667
|
isLocalURL: isLocalURL,
|
|
670
668
|
isHash: isHash,
|
|
671
669
|
withoutQuery: withoutQuery,
|
|
672
|
-
|
|
673
|
-
getPathname: getPathname,
|
|
674
|
-
getHash: getHash
|
|
670
|
+
joinPath: joinPath
|
|
675
671
|
});
|
|
676
672
|
|
|
677
673
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
@@ -704,28 +700,35 @@
|
|
|
704
700
|
function useLink(isRemote) {
|
|
705
701
|
const router = useRouter();
|
|
706
702
|
const blockRouter = useBlockRouter();
|
|
707
|
-
const handleLocalURL = (href, target) => (ev) => {
|
|
708
|
-
if (isRemote || !isLocalURL(href, target)) {
|
|
709
|
-
// Proceed with native handle
|
|
710
|
-
return;
|
|
711
|
-
}
|
|
712
|
-
// Client routing
|
|
713
|
-
ev?.preventDefault();
|
|
714
|
-
if (isHash(href)) {
|
|
715
|
-
blockRouter.goto(href);
|
|
716
|
-
}
|
|
717
|
-
else if (href) {
|
|
718
|
-
router.push(href);
|
|
719
|
-
}
|
|
720
|
-
};
|
|
721
703
|
return (props) => ({
|
|
722
704
|
...props,
|
|
705
|
+
href: adjustHref(props.href),
|
|
723
706
|
'aria-label': props.text,
|
|
724
|
-
onClick: handlerDecorator((
|
|
725
|
-
props.onClick && props.onClick(ev);
|
|
726
|
-
handleLocalURL(props.href, props.target)(ev);
|
|
727
|
-
}, props),
|
|
707
|
+
onClick: handlerDecorator(handleHref(props), props),
|
|
728
708
|
});
|
|
709
|
+
function adjustHref(href) {
|
|
710
|
+
const isRelativeToBase = !isRemote && href?.startsWith('/');
|
|
711
|
+
return projectSettings.BASE_PATH && href && isRelativeToBase
|
|
712
|
+
? joinPath(projectSettings.BASE_PATH, href)
|
|
713
|
+
: href;
|
|
714
|
+
}
|
|
715
|
+
function handleHref({ href, target, onClick }) {
|
|
716
|
+
return (ev) => {
|
|
717
|
+
onClick && onClick(ev);
|
|
718
|
+
if (isRemote || !isLocalURL(href, target)) {
|
|
719
|
+
// Default routing
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
// Client routing
|
|
723
|
+
ev?.preventDefault();
|
|
724
|
+
if (isHash(href)) {
|
|
725
|
+
blockRouter.goto(href);
|
|
726
|
+
}
|
|
727
|
+
else if (href) {
|
|
728
|
+
router.push(href);
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
}
|
|
729
732
|
}
|
|
730
733
|
|
|
731
734
|
const buttonStyleMap = {
|
|
@@ -2457,8 +2460,8 @@
|
|
|
2457
2460
|
return currencies?.filter((_) => _?.currency?.id === 1 || _?.currency?.id === 2) || [];
|
|
2458
2461
|
};
|
|
2459
2462
|
|
|
2460
|
-
function useSWRResource(
|
|
2461
|
-
const { data } = useAsyncData(`/wcms-resources/${
|
|
2463
|
+
function useSWRResource(filename, fallback = {}) {
|
|
2464
|
+
const { data } = useAsyncData(`/wcms-resources/${filename}.json`, fetchJSONUnsafe, {
|
|
2462
2465
|
fallback,
|
|
2463
2466
|
});
|
|
2464
2467
|
return data || {};
|
|
@@ -2544,16 +2547,10 @@
|
|
|
2544
2547
|
return (jsx("div", { className: className, children: links?.length ? (jsx("div", { className: "flex justify-between items-center gap-5 py-5 border-solid border-x-0 border-y border-y-main-divider", children: links.map((_, i) => (jsx(HorizontalNavigationLink, { index: i, className: "text-l-light max-w-[292px]", ..._ }, String(i)))) })) : null }));
|
|
2545
2548
|
});
|
|
2546
2549
|
|
|
2547
|
-
const
|
|
2548
|
-
const substitute = (items, substitution) => (items || []).map((_) => substitution?.find(cmp(_)) || _);
|
|
2549
|
-
const subtract = (minuend, subtrahend) => (minuend || []).filter((_) => !subtrahend?.find(cmp(_)));
|
|
2550
|
-
const mergeTopItems = (left, right) => substitute(left, right).concat(subtract(right, left));
|
|
2551
|
-
|
|
2552
|
-
const Sitemap = JSX(({ className = '', items, fallback }) => {
|
|
2550
|
+
const Sitemap = JSX(({ className = '', fallback }) => {
|
|
2553
2551
|
const link = useLink();
|
|
2554
2552
|
const sitemap = useSWRResource(projectSettings.SITEMAP || 'sitemap', fallback);
|
|
2555
|
-
|
|
2556
|
-
return (jsx("div", { className: `flex flex-grow items-start justify-between gap-[54px] xl:gap-5 ${className}`, children: mergedItems?.map((_, i) => renderColumn(link(_), i)) }));
|
|
2553
|
+
return (jsx("div", { className: `flex flex-grow items-start justify-between gap-[54px] xl:gap-5 ${className}`, children: sitemap.topItems?.map((_, i) => renderColumn(link(_), i)) }));
|
|
2557
2554
|
});
|
|
2558
2555
|
const renderColumn = (menuItem, index) => {
|
|
2559
2556
|
const { text, items, href, target, onClick } = menuItem;
|
|
@@ -2640,13 +2637,11 @@
|
|
|
2640
2637
|
const renderMonthNames = (item, colSize) => item.month?.map((_, i) => (jsx("div", { style: { flexBasis: `${colSize}%` }, children: _.text }, `monthName-${i}`)));
|
|
2641
2638
|
const renderMonthImages = (item) => item.month?.map((_) => _.image?.src ? (jsx("div", { className: "h-[207px] border-r pr-3 mr-3 border-main-divider last:border-r-0 last:pr-0 last:mr-0", children: jsx(ImgInner, { image: _.image, className: "flex" }) }, `monthImage-${_.image.src}`)) : null);
|
|
2642
2639
|
|
|
2643
|
-
const isHrefActive = (router) => ({ href }) =>
|
|
2644
|
-
const { BASE_PATH } = projectSettings;
|
|
2645
|
-
const relativeHref = BASE_PATH && href?.startsWith(BASE_PATH) ? href.substring(BASE_PATH.length) : href;
|
|
2646
|
-
return withoutQuery(isURL(href) ? router.href : router.pathname).startsWith(withoutQuery(relativeHref));
|
|
2647
|
-
};
|
|
2640
|
+
const isHrefActive = (router) => ({ href }) => withoutQuery(isURL(href) ? router.href : router.pathname).startsWith(withoutQuery(href));
|
|
2648
2641
|
|
|
2649
|
-
const isTopItemActive = (router) => (topItem) =>
|
|
2642
|
+
const isTopItemActive = (router) => (topItem) => projectSettings.BASE_PATH
|
|
2643
|
+
? isHrefActive({ pathname: projectSettings.BASE_PATH })(topItem)
|
|
2644
|
+
: topItem.items?.some(isHrefActive(router)) || isHrefActive(router)(topItem);
|
|
2650
2645
|
|
|
2651
2646
|
const TopItem = JSX(({ className = '', active, flat, children, ...rest }) => {
|
|
2652
2647
|
const link = useLink(true);
|
|
@@ -4562,7 +4557,7 @@
|
|
|
4562
4557
|
return (jsx("div", { className: "flex items-end absolute bottom-0 right-0 h-full pointer-events-none", children: jsx(LikeControl, { className: "rounded-tl-lg sticky bottom-0 pointer-events-auto" }) }));
|
|
4563
4558
|
}
|
|
4564
4559
|
|
|
4565
|
-
const packageVersion = "0.8.
|
|
4560
|
+
const packageVersion = "0.8.7";
|
|
4566
4561
|
|
|
4567
4562
|
exports.Blocks = Blocks;
|
|
4568
4563
|
exports.ContentPage = ContentPage;
|