@redneckz/wildless-cms-uni-blocks 0.8.4 → 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 +35 -44
- 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/Carousel/Carousel.js +1 -1
- package/dist/components/Carousel/Carousel.js.map +1 -1
- 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/Carousel/Carousel.js +1 -1
- package/lib/components/Carousel/Carousel.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/Carousel/Carousel.js +1 -1
- package/mobile/dist/components/Carousel/Carousel.js.map +1 -1
- 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/Carousel/Carousel.js +1 -1
- package/mobile/lib/components/Carousel/Carousel.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/Carousel/Carousel.tsx +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/Carousel/Carousel.tsx +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/lib/hooks/useLink.js
CHANGED
|
@@ -1,31 +1,35 @@
|
|
|
1
|
+
import { projectSettings } from '../ProjectSettings.js';
|
|
1
2
|
import { useBlockRouter } from '../services/BlockRouter/useBlockRouter.js';
|
|
2
|
-
import { isHash, isLocalURL } from '../utils/url.js';
|
|
3
|
+
import { isHash, isLocalURL, isURL, joinPath } from '../utils/url.js';
|
|
3
4
|
import { handlerDecorator } from './handlerDecorator.js';
|
|
4
5
|
import { useRouter } from './useRouter.js';
|
|
5
6
|
export function useLink(isRemote) {
|
|
6
7
|
const router = useRouter();
|
|
7
8
|
const blockRouter = useBlockRouter();
|
|
8
|
-
const handleLocalURL = (href, target) => (ev) => {
|
|
9
|
-
if (isRemote || !isLocalURL(href, target)) {
|
|
10
|
-
// Proceed with native handle
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
// Client routing
|
|
14
|
-
ev?.preventDefault();
|
|
15
|
-
if (isHash(href)) {
|
|
16
|
-
blockRouter.goto(href);
|
|
17
|
-
}
|
|
18
|
-
else if (href) {
|
|
19
|
-
router.push(href);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
9
|
return (props) => ({
|
|
23
10
|
...props,
|
|
11
|
+
href: projectSettings.BASE_PATH && props.href && !(isRemote || isURL(props.href))
|
|
12
|
+
? joinPath(projectSettings.BASE_PATH, props.href)
|
|
13
|
+
: props.href,
|
|
24
14
|
'aria-label': props.text,
|
|
25
|
-
onClick: handlerDecorator((
|
|
26
|
-
props.onClick && props.onClick(ev);
|
|
27
|
-
handleLocalURL(props.href, props.target)(ev);
|
|
28
|
-
}, props),
|
|
15
|
+
onClick: handlerDecorator(handleHref(props), props),
|
|
29
16
|
});
|
|
17
|
+
function handleHref({ href, target, onClick }) {
|
|
18
|
+
return (ev) => {
|
|
19
|
+
onClick && onClick(ev);
|
|
20
|
+
if (isRemote || !isLocalURL(href, target)) {
|
|
21
|
+
// Default routing
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
// Client routing
|
|
25
|
+
ev?.preventDefault();
|
|
26
|
+
if (isHash(href)) {
|
|
27
|
+
blockRouter.goto(href);
|
|
28
|
+
}
|
|
29
|
+
else if (href) {
|
|
30
|
+
router.push(href);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
30
34
|
}
|
|
31
35
|
//# sourceMappingURL=useLink.js.map
|
package/lib/hooks/useLink.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLink.js","sourceRoot":"","sources":["../../src/hooks/useLink.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"useLink.js","sourceRoot":"","sources":["../../src/hooks/useLink.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAUxC,MAAM,UAAU,OAAO,CAAC,QAAkB;IACxC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IAErC,OAAO,CAA2C,KAAQ,EAAiB,EAAE,CAAC,CAAC;QAC7E,GAAG,KAAK;QACR,IAAI,EACF,eAAe,CAAC,SAAS,IAAI,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACzE,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC;YACjD,CAAC,CAAC,KAAK,CAAC,IAAI;QAChB,YAAY,EAAE,KAAK,CAAC,IAAI;QACxB,OAAO,EAAE,gBAAgB,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;KACpD,CAAC,CAAC;IAEH,SAAS,UAAU,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAkC;QAC3E,OAAO,CAAC,EAAqB,EAAE,EAAE;YAC/B,OAAO,IAAI,OAAO,CAAC,EAAE,CAAC,CAAC;YAEvB,IAAI,QAAQ,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE;gBACzC,kBAAkB;gBAClB,OAAO;aACR;YAED,iBAAiB;YACjB,EAAE,EAAE,cAAc,EAAE,CAAC;YACrB,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE;gBAChB,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACxB;iBAAM,IAAI,IAAI,EAAE;gBACf,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACnB;QACH,CAAC,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventBus } from '../../EventBus/EventBus.js';
|
|
2
|
-
const normalizeAnchor = (rawAnchor) => rawAnchor?.replace('#', '');
|
|
2
|
+
const normalizeAnchor = (rawAnchor) => rawAnchor?.replace('#', '') || '';
|
|
3
3
|
const getURLWithAnchor = (rawAnchor) => `${globalThis.location?.pathname}#${normalizeAnchor(rawAnchor)}`;
|
|
4
4
|
export class BlockRouter {
|
|
5
5
|
static inst = new BlockRouter();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockRouter.js","sourceRoot":"","sources":["../../../src/services/Bl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CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,EAAE,EAAE,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,CAAC,SAAiB;QACvB,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;IAC1E,CAAC;IAED,KAAK;QACH,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,gBAAgB,EAAE,CAAC,CAAC;IACjE,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { readFile } from 'fs/promises';
|
|
2
|
+
export const fallbackWCMSResource = (filename) => ({
|
|
3
|
+
[`/wcms-resources/${filename}.json`]: async () => JSON.parse(await readFile(`./content/wcms-resources/${filename}.json`, 'utf-8')),
|
|
4
|
+
});
|
|
5
|
+
//# sourceMappingURL=fallbackWCMSResource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fallbackWCMSResource.js","sourceRoot":"","sources":["../../../src/services/sitemap/fallbackWCMSResource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,QAAgB,EAAe,EAAE,CAAC,CAAC;IACtE,CAAC,mBAAmB,QAAQ,OAAO,CAAC,EAAE,KAAK,IAAI,EAAE,CAC/C,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,4BAA4B,QAAQ,OAAO,EAAE,OAAO,CAAC,CAAC;CACnF,CAAC,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const isHrefActive: (router: {
|
|
2
|
+
href?: string;
|
|
3
|
+
pathname: string;
|
|
4
|
+
}) => ({ href }: {
|
|
3
5
|
href?: string | undefined;
|
|
4
6
|
}) => boolean;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import { projectSettings } from '../../ProjectSettings.js';
|
|
2
1
|
import { isURL, withoutQuery } from '../../utils/url.js';
|
|
3
|
-
export const isHrefActive = (router) => ({ href }) =>
|
|
4
|
-
const { BASE_PATH } = projectSettings;
|
|
5
|
-
const relativeHref = BASE_PATH && href?.startsWith(BASE_PATH) ? href.substring(BASE_PATH.length) : href;
|
|
6
|
-
return withoutQuery(isURL(href) ? router.href : router.pathname).startsWith(withoutQuery(relativeHref));
|
|
7
|
-
};
|
|
2
|
+
export const isHrefActive = (router) => ({ href }) => withoutQuery(isURL(href) ? router.href : router.pathname).startsWith(withoutQuery(href));
|
|
8
3
|
//# sourceMappingURL=isHrefActive.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isHrefActive.js","sourceRoot":"","sources":["../../../src/services/sitemap/isHrefActive.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isHrefActive.js","sourceRoot":"","sources":["../../../src/services/sitemap/isHrefActive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,CAAC,MAAM,YAAY,GACvB,CAAC,MAA2C,EAAE,EAAE,CAChD,CAAC,EAAE,IAAI,EAAqB,EAAW,EAAE,CACvC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { projectSettings } from '../../ProjectSettings.js';
|
|
1
2
|
import { isHrefActive } from './isHrefActive.js';
|
|
2
|
-
export const isTopItemActive = (router) => (topItem) =>
|
|
3
|
+
export const isTopItemActive = (router) => (topItem) => projectSettings.BASE_PATH
|
|
4
|
+
? isHrefActive({ pathname: projectSettings.BASE_PATH })(topItem)
|
|
5
|
+
: topItem.items?.some(isHrefActive(router)) || isHrefActive(router)(topItem);
|
|
3
6
|
//# sourceMappingURL=isTopItemActive.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isTopItemActive.js","sourceRoot":"","sources":["../../../src/services/sitemap/isTopItemActive.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,MAAM,CAAC,MAAM,eAAe,GAC1B,CAAC,MAAc,EAAE,EAAE,CACnB,CAAC,OAAoB,EAAW,EAAE,CAChC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"isTopItemActive.js","sourceRoot":"","sources":["../../../src/services/sitemap/isTopItemActive.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,MAAM,CAAC,MAAM,eAAe,GAC1B,CAAC,MAAc,EAAE,EAAE,CACnB,CAAC,OAAoB,EAAW,EAAE,CAChC,eAAe,CAAC,SAAS;IACvB,CAAC,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,eAAe,CAAC,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC;IAChE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Fallback } from '../../model/Fallback';
|
|
2
|
-
export declare function useSWRResource<Data>(
|
|
2
|
+
export declare function useSWRResource<Data>(filename: string, fallback?: Fallback): Data;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useAsyncData } from '@redneckz/uni-jsx/lib/hooks/useAsyncData';
|
|
2
2
|
import { fetchJSONUnsafe } from '../../utils/fetchJSON.js';
|
|
3
|
-
export function useSWRResource(
|
|
4
|
-
const { data } = useAsyncData(`/wcms-resources/${
|
|
3
|
+
export function useSWRResource(filename, fallback = {}) {
|
|
4
|
+
const { data } = useAsyncData(`/wcms-resources/${filename}.json`, fetchJSONUnsafe, {
|
|
5
5
|
fallback,
|
|
6
6
|
});
|
|
7
7
|
return data || {};
|
package/lib/setup-fixture.js
CHANGED
|
@@ -18,7 +18,9 @@ useRouter.setup(() => {
|
|
|
18
18
|
}, []);
|
|
19
19
|
return {
|
|
20
20
|
href,
|
|
21
|
-
pathname:
|
|
21
|
+
pathname: projectSettings.BASE_PATH
|
|
22
|
+
? new URL(href).pathname.substring(projectSettings.BASE_PATH.length - 1)
|
|
23
|
+
: '',
|
|
22
24
|
query: {},
|
|
23
25
|
push: (url) => {
|
|
24
26
|
globalThis.history.pushState(null, '', url);
|
package/lib/setup-fixture.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-fixture.js","sourceRoot":"","sources":["../src/setup-fixture.ts"],"names":[],"mappings":"AAAA,OAAO,mCAAmC,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAE3B,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE;IACnB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAC9B,GAAG,UAAU,CAAC,QAAQ,CAAC,MAAM,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EAAE,mBAAmB,CAAC,CAAC;QAE7D,OAAO,GAAG,EAAE;YACV,UAAU,CAAC,mBAAmB,CAAC,UAAU,EAAE,mBAAmB,CAAC,CAAC;QAClE,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,IAAI;QACJ,QAAQ,EAAE,eAAe,CAAC,SAAS;YACjC,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;YACxE,CAAC,CAAC,EAAE;QACN,KAAK,EAAE,EAAE;QACT,IAAI,EAAE,CAAC,GAAW,EAAE,EAAE;YACpB,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,EAAE,CAAC,GAAW,EAAE,EAAE;YACvB,UAAU,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;QACjD,CAAC;KACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,KAAK,CAAC,CAAC,OAAO,EAAO,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE;IAC9C,EAAE,CAAC,cAAc,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,CAAC,CAAC;AACd,CAAC,CAAC,CAAC"}
|
package/lib/utils/url.d.ts
CHANGED
|
@@ -3,6 +3,4 @@ export declare const isURL: (href?: string) => href is `${string}//${string}`;
|
|
|
3
3
|
export declare const isLocalURL: (href: string | undefined, target?: Target) => boolean;
|
|
4
4
|
export declare const isHash: (href?: string) => href is `#${string}`;
|
|
5
5
|
export declare const withoutQuery: (href?: string) => string;
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const getPathname: (href?: string) => string | undefined;
|
|
8
|
-
export declare const getHash: (href?: string) => string | undefined;
|
|
6
|
+
export declare const joinPath: (...path: string[]) => string;
|
package/lib/utils/url.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export const isURL = (href) => Boolean(href?.includes('//'));
|
|
2
2
|
export const isLocalURL = (href, target) => Boolean(href && !isURL(href) && (!target || target === '_self'));
|
|
3
3
|
export const isHash = (href) => Boolean(href?.startsWith('#'));
|
|
4
|
-
export const withoutQuery = (href) => (href || '').replace(
|
|
5
|
-
export const
|
|
6
|
-
export const getPathname = (href) => (isURL(href) ? new URL(href).pathname : undefined);
|
|
7
|
-
export const getHash = (href) => (isURL(href) ? new URL(href).hash : undefined);
|
|
4
|
+
export const withoutQuery = (href) => (href || '').replace(/\?.*/, '').replace(/\/$/, '');
|
|
5
|
+
export const joinPath = (...path) => path.filter(Boolean).join('/').replace(/\/+/g, '/');
|
|
8
6
|
//# sourceMappingURL=url.js.map
|
package/lib/utils/url.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAa,EAAkC,EAAE,CACrE,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AAEhC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAwB,EAAE,MAAe,EAAE,EAAE,CACtE,OAAO,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC;AAEnE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAa,EAAwB,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;AAE9F,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAa,EAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAa,EAAkC,EAAE,CACrE,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AAEhC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAwB,EAAE,MAAe,EAAE,EAAE,CACtE,OAAO,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC;AAEnE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAa,EAAwB,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;AAE9F,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAa,EAAU,EAAE,CACpD,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAEtD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAc,EAAU,EAAE,CACpD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC"}
|
|
@@ -336,7 +336,7 @@
|
|
|
336
336
|
.concat(1);
|
|
337
337
|
}
|
|
338
338
|
|
|
339
|
-
const normalizeAnchor = (rawAnchor) => rawAnchor?.replace('#', '');
|
|
339
|
+
const normalizeAnchor = (rawAnchor) => rawAnchor?.replace('#', '') || '';
|
|
340
340
|
const getURLWithAnchor = (rawAnchor) => `${globalThis.location?.pathname}#${normalizeAnchor(rawAnchor)}`;
|
|
341
341
|
class BlockRouter {
|
|
342
342
|
static inst = new BlockRouter();
|
|
@@ -710,10 +710,8 @@
|
|
|
710
710
|
const isURL = (href) => Boolean(href?.includes('//'));
|
|
711
711
|
const isLocalURL = (href, target) => Boolean(href && !isURL(href) && (!target || target === '_self'));
|
|
712
712
|
const isHash = (href) => Boolean(href?.startsWith('#'));
|
|
713
|
-
const withoutQuery = (href) => (href || '').replace(
|
|
714
|
-
const
|
|
715
|
-
const getPathname = (href) => (isURL(href) ? new URL(href).pathname : undefined);
|
|
716
|
-
const getHash = (href) => (isURL(href) ? new URL(href).hash : undefined);
|
|
713
|
+
const withoutQuery = (href) => (href || '').replace(/\?.*/, '').replace(/\/$/, '');
|
|
714
|
+
const joinPath = (...path) => path.filter(Boolean).join('/').replace(/\/+/g, '/');
|
|
717
715
|
|
|
718
716
|
var url = /*#__PURE__*/Object.freeze({
|
|
719
717
|
__proto__: null,
|
|
@@ -721,9 +719,7 @@
|
|
|
721
719
|
isLocalURL: isLocalURL,
|
|
722
720
|
isHash: isHash,
|
|
723
721
|
withoutQuery: withoutQuery,
|
|
724
|
-
|
|
725
|
-
getPathname: getPathname,
|
|
726
|
-
getHash: getHash
|
|
722
|
+
joinPath: joinPath
|
|
727
723
|
});
|
|
728
724
|
|
|
729
725
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
@@ -756,28 +752,31 @@
|
|
|
756
752
|
function useLink(isRemote) {
|
|
757
753
|
const router = useRouter();
|
|
758
754
|
const blockRouter = useBlockRouter();
|
|
759
|
-
const handleLocalURL = (href, target) => (ev) => {
|
|
760
|
-
if (isRemote || !isLocalURL(href, target)) {
|
|
761
|
-
// Proceed with native handle
|
|
762
|
-
return;
|
|
763
|
-
}
|
|
764
|
-
// Client routing
|
|
765
|
-
ev?.preventDefault();
|
|
766
|
-
if (isHash(href)) {
|
|
767
|
-
blockRouter.goto(href);
|
|
768
|
-
}
|
|
769
|
-
else if (href) {
|
|
770
|
-
router.push(href);
|
|
771
|
-
}
|
|
772
|
-
};
|
|
773
755
|
return (props) => ({
|
|
774
756
|
...props,
|
|
757
|
+
href: projectSettings.BASE_PATH && props.href && !(isRemote || isURL(props.href))
|
|
758
|
+
? joinPath(projectSettings.BASE_PATH, props.href)
|
|
759
|
+
: props.href,
|
|
775
760
|
'aria-label': props.text,
|
|
776
|
-
onClick: handlerDecorator((
|
|
777
|
-
props.onClick && props.onClick(ev);
|
|
778
|
-
handleLocalURL(props.href, props.target)(ev);
|
|
779
|
-
}, props),
|
|
761
|
+
onClick: handlerDecorator(handleHref(props), props),
|
|
780
762
|
});
|
|
763
|
+
function handleHref({ href, target, onClick }) {
|
|
764
|
+
return (ev) => {
|
|
765
|
+
onClick && onClick(ev);
|
|
766
|
+
if (isRemote || !isLocalURL(href, target)) {
|
|
767
|
+
// Default routing
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
// Client routing
|
|
771
|
+
ev?.preventDefault();
|
|
772
|
+
if (isHash(href)) {
|
|
773
|
+
blockRouter.goto(href);
|
|
774
|
+
}
|
|
775
|
+
else if (href) {
|
|
776
|
+
router.push(href);
|
|
777
|
+
}
|
|
778
|
+
};
|
|
779
|
+
}
|
|
781
780
|
}
|
|
782
781
|
|
|
783
782
|
const buttonStyleMap = {
|
|
@@ -964,8 +963,8 @@
|
|
|
964
963
|
return await response.json();
|
|
965
964
|
}
|
|
966
965
|
|
|
967
|
-
function useSWRResource(
|
|
968
|
-
const { data } = useAsyncData(`/wcms-resources/${
|
|
966
|
+
function useSWRResource(filename, fallback = {}) {
|
|
967
|
+
const { data } = useAsyncData(`/wcms-resources/${filename}.json`, fetchJSONUnsafe, {
|
|
969
968
|
fallback,
|
|
970
969
|
});
|
|
971
970
|
return data || {};
|
|
@@ -1153,11 +1152,7 @@
|
|
|
1153
1152
|
return (jsx("section", { className: "mt-3", children: items.map((item, i) => (jsxs("div", { children: [isDotted ? (jsx("div", { className: `rounded-full inline-block mr-3 mt-2 w-2 h-2 min-w-2 min-h-2 ${LIST_DOT_STYLE_MAP[version]}` })) : null, jsx("span", { className: "text-m font-medium", children: item.title }), jsx("span", { className: `text-s pl-2 ${version === 'primary' ? 'text-secondary-text' : ''}`, children: item.text })] }, String(i)))) }));
|
|
1154
1153
|
}
|
|
1155
1154
|
|
|
1156
|
-
const isHrefActive = (router) => ({ href }) =>
|
|
1157
|
-
const { BASE_PATH } = projectSettings;
|
|
1158
|
-
const relativeHref = BASE_PATH && href?.startsWith(BASE_PATH) ? href.substring(BASE_PATH.length) : href;
|
|
1159
|
-
return withoutQuery(isURL(href) ? router.href : router.pathname).startsWith(withoutQuery(relativeHref));
|
|
1160
|
-
};
|
|
1155
|
+
const isHrefActive = (router) => ({ href }) => withoutQuery(isURL(href) ? router.href : router.pathname).startsWith(withoutQuery(href));
|
|
1161
1156
|
|
|
1162
1157
|
const findActiveSubItem = (router) => (items = []) => {
|
|
1163
1158
|
const possibleActiveSubItems = items?.filter(isHrefActive(router));
|
|
@@ -1166,7 +1161,9 @@
|
|
|
1166
1161
|
: undefined;
|
|
1167
1162
|
};
|
|
1168
1163
|
|
|
1169
|
-
const isTopItemActive = (router) => (topItem) =>
|
|
1164
|
+
const isTopItemActive = (router) => (topItem) => projectSettings.BASE_PATH
|
|
1165
|
+
? isHrefActive({ pathname: projectSettings.BASE_PATH })(topItem)
|
|
1166
|
+
: topItem.items?.some(isHrefActive(router)) || isHrefActive(router)(topItem);
|
|
1170
1167
|
|
|
1171
1168
|
const HeaderItem = JSX(({ className = '', active, dataItemName, children, ...rest }) => {
|
|
1172
1169
|
const link = useLink();
|
|
@@ -1725,7 +1722,7 @@
|
|
|
1725
1722
|
return (list) => list.reduce((acc, el, i) => (acc.length ? acc.concat({ ...sep, key: i }, el) : [el]), []);
|
|
1726
1723
|
}
|
|
1727
1724
|
|
|
1728
|
-
const packageVersion = "0.8.
|
|
1725
|
+
const packageVersion = "0.8.6";
|
|
1729
1726
|
|
|
1730
1727
|
exports.Blocks = Blocks;
|
|
1731
1728
|
exports.ContentPage = ContentPage;
|