@redneckz/wildless-cms-uni-blocks 0.8.5 → 0.8.6
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 +34 -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 +22 -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 +23 -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 +32 -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 +22 -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 +23 -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 +26 -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 +26 -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,31 @@
|
|
|
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: projectSettings.BASE_PATH && props.href && !(isRemote || isURL(props.href))
|
|
706
|
+
? joinPath(projectSettings.BASE_PATH, props.href)
|
|
707
|
+
: props.href,
|
|
723
708
|
'aria-label': props.text,
|
|
724
|
-
onClick: handlerDecorator((
|
|
725
|
-
props.onClick && props.onClick(ev);
|
|
726
|
-
handleLocalURL(props.href, props.target)(ev);
|
|
727
|
-
}, props),
|
|
709
|
+
onClick: handlerDecorator(handleHref(props), props),
|
|
728
710
|
});
|
|
711
|
+
function handleHref({ href, target, onClick }) {
|
|
712
|
+
return (ev) => {
|
|
713
|
+
onClick && onClick(ev);
|
|
714
|
+
if (isRemote || !isLocalURL(href, target)) {
|
|
715
|
+
// Default routing
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
// Client routing
|
|
719
|
+
ev?.preventDefault();
|
|
720
|
+
if (isHash(href)) {
|
|
721
|
+
blockRouter.goto(href);
|
|
722
|
+
}
|
|
723
|
+
else if (href) {
|
|
724
|
+
router.push(href);
|
|
725
|
+
}
|
|
726
|
+
};
|
|
727
|
+
}
|
|
729
728
|
}
|
|
730
729
|
|
|
731
730
|
const buttonStyleMap = {
|
|
@@ -2457,8 +2456,8 @@
|
|
|
2457
2456
|
return currencies?.filter((_) => _?.currency?.id === 1 || _?.currency?.id === 2) || [];
|
|
2458
2457
|
};
|
|
2459
2458
|
|
|
2460
|
-
function useSWRResource(
|
|
2461
|
-
const { data } = useAsyncData(`/wcms-resources/${
|
|
2459
|
+
function useSWRResource(filename, fallback = {}) {
|
|
2460
|
+
const { data } = useAsyncData(`/wcms-resources/${filename}.json`, fetchJSONUnsafe, {
|
|
2462
2461
|
fallback,
|
|
2463
2462
|
});
|
|
2464
2463
|
return data || {};
|
|
@@ -2544,16 +2543,10 @@
|
|
|
2544
2543
|
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
2544
|
});
|
|
2546
2545
|
|
|
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 }) => {
|
|
2546
|
+
const Sitemap = JSX(({ className = '', fallback }) => {
|
|
2553
2547
|
const link = useLink();
|
|
2554
2548
|
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)) }));
|
|
2549
|
+
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
2550
|
});
|
|
2558
2551
|
const renderColumn = (menuItem, index) => {
|
|
2559
2552
|
const { text, items, href, target, onClick } = menuItem;
|
|
@@ -2640,13 +2633,11 @@
|
|
|
2640
2633
|
const renderMonthNames = (item, colSize) => item.month?.map((_, i) => (jsx("div", { style: { flexBasis: `${colSize}%` }, children: _.text }, `monthName-${i}`)));
|
|
2641
2634
|
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
2635
|
|
|
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
|
-
};
|
|
2636
|
+
const isHrefActive = (router) => ({ href }) => withoutQuery(isURL(href) ? router.href : router.pathname).startsWith(withoutQuery(href));
|
|
2648
2637
|
|
|
2649
|
-
const isTopItemActive = (router) => (topItem) =>
|
|
2638
|
+
const isTopItemActive = (router) => (topItem) => projectSettings.BASE_PATH
|
|
2639
|
+
? isHrefActive({ pathname: projectSettings.BASE_PATH })(topItem)
|
|
2640
|
+
: topItem.items?.some(isHrefActive(router)) || isHrefActive(router)(topItem);
|
|
2650
2641
|
|
|
2651
2642
|
const TopItem = JSX(({ className = '', active, flat, children, ...rest }) => {
|
|
2652
2643
|
const link = useLink(true);
|
|
@@ -4562,7 +4553,7 @@
|
|
|
4562
4553
|
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
4554
|
}
|
|
4564
4555
|
|
|
4565
|
-
const packageVersion = "0.8.
|
|
4556
|
+
const packageVersion = "0.8.6";
|
|
4566
4557
|
|
|
4567
4558
|
exports.Blocks = Blocks;
|
|
4568
4559
|
exports.ContentPage = ContentPage;
|