@redneckz/wildless-cms-uni-blocks 0.6.42 → 0.6.44
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/bin/migration-scripts/0.6.34.js +2 -0
- package/bin/migration-scripts/0.6.43.js +29 -0
- package/bundle/ProjectSettings.d.ts +2 -0
- package/bundle/blocks.schema.json +1 -1
- package/bundle/bundle.umd.js +122 -91
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/ProductTile/ProductTileContent.d.ts +24 -2
- package/bundle/components/ProductTile/renderAdditionalDescription.d.ts +4 -0
- package/bundle/components/ProductTile/renderBenefit.d.ts +4 -0
- package/bundle/components/ProductTile/renderImage.d.ts +3 -0
- package/bundle/content-page-repository/transformImg.d.ts +1 -1
- package/bundle/services/BlockRouter/BlockRouter.d.ts +1 -1
- package/bundle/services/sitemap/checkIsHrefSameOrigin.d.ts +2 -4
- package/bundle/ui-kit/MarkdownText/MarkdownText.d.ts +2 -0
- package/bundle/ui-kit/MarkdownText/MarkdownTextProps.d.ts +6 -0
- package/bundle/utils/normalizeURLPath.d.ts +1 -0
- package/bundle/utils/url.d.ts +1 -0
- package/dist/ProjectSettings.d.ts +2 -0
- package/dist/ProjectSettings.js +5 -0
- package/dist/ProjectSettings.js.map +1 -1
- package/dist/api/LikeAPI.js +2 -2
- package/dist/api/LikeAPI.js.map +1 -1
- package/dist/components/Header/Header.js +1 -6
- package/dist/components/Header/Header.js.map +1 -1
- package/dist/components/ProductTile/ProductTile.js +9 -22
- package/dist/components/ProductTile/ProductTile.js.map +1 -1
- package/dist/components/ProductTile/ProductTileContent.d.ts +24 -2
- package/dist/components/ProductTile/renderAdditionalDescription.d.ts +4 -0
- package/dist/components/ProductTile/renderAdditionalDescription.js +18 -0
- package/dist/components/ProductTile/renderAdditionalDescription.js.map +1 -0
- package/dist/components/ProductTile/renderBenefit.d.ts +4 -0
- package/dist/components/ProductTile/renderBenefit.js +32 -0
- package/dist/components/ProductTile/renderBenefit.js.map +1 -0
- package/dist/components/ProductTile/renderImage.d.ts +3 -0
- package/dist/components/ProductTile/renderImage.js +12 -0
- package/dist/components/ProductTile/renderImage.js.map +1 -0
- package/dist/components/TextBlock/TextBlock.js +13 -28
- package/dist/components/TextBlock/TextBlock.js.map +1 -1
- package/dist/content-page-repository/transformImg.d.ts +1 -1
- package/dist/content-page-repository/transformImg.js +4 -10
- package/dist/content-page-repository/transformImg.js.map +1 -1
- package/dist/content-page-repository/transformMarkdown.js +3 -3
- package/dist/content-page-repository/transformMarkdown.js.map +1 -1
- package/dist/hooks/useLink.js +3 -5
- package/dist/hooks/useLink.js.map +1 -1
- package/dist/hooks/useLocation.js +11 -5
- package/dist/hooks/useLocation.js.map +1 -1
- package/dist/services/BlockRouter/BlockRouter.d.ts +1 -1
- package/dist/services/BlockRouter/BlockRouter.js.map +1 -1
- package/dist/services/sitemap/checkIsHrefSameOrigin.d.ts +2 -4
- package/dist/services/sitemap/checkIsHrefSameOrigin.js +1 -1
- package/dist/services/sitemap/checkIsHrefSameOrigin.js.map +1 -1
- package/dist/services/sitemap/isHrefActive.js +2 -3
- package/dist/services/sitemap/isHrefActive.js.map +1 -1
- package/dist/setup-fixture.js +3 -3
- package/dist/setup-fixture.js.map +1 -1
- package/dist/ui-kit/MarkdownText/MarkdownText.d.ts +2 -0
- package/dist/ui-kit/MarkdownText/MarkdownText.js +9 -0
- package/dist/ui-kit/MarkdownText/MarkdownText.js.map +1 -0
- package/dist/ui-kit/MarkdownText/MarkdownTextProps.d.ts +6 -0
- package/dist/ui-kit/MarkdownText/MarkdownTextProps.js +2 -0
- package/dist/ui-kit/MarkdownText/MarkdownTextProps.js.map +1 -0
- package/dist/ui-kit/Text/Text.js +1 -5
- package/dist/ui-kit/Text/Text.js.map +1 -1
- package/dist/utils/normalizeURLPath.d.ts +1 -0
- package/dist/utils/normalizeURLPath.js +12 -0
- package/dist/utils/normalizeURLPath.js.map +1 -0
- package/dist/utils/url.d.ts +1 -0
- package/dist/utils/url.js +9 -1
- package/dist/utils/url.js.map +1 -1
- package/dist/wlc.json +3 -1
- package/lib/ProjectSettings.d.ts +2 -0
- package/lib/ProjectSettings.js +5 -0
- package/lib/ProjectSettings.js.map +1 -1
- package/lib/api/LikeAPI.js +2 -2
- package/lib/api/LikeAPI.js.map +1 -1
- package/lib/common.css +1 -1
- package/lib/components/Header/Header.js +1 -6
- package/lib/components/Header/Header.js.map +1 -1
- package/lib/components/ProductTile/ProductTile.js +10 -23
- package/lib/components/ProductTile/ProductTile.js.map +1 -1
- package/lib/components/ProductTile/ProductTileContent.d.ts +24 -2
- package/lib/components/ProductTile/renderAdditionalDescription.d.ts +4 -0
- package/lib/components/ProductTile/renderAdditionalDescription.js +15 -0
- package/lib/components/ProductTile/renderAdditionalDescription.js.map +1 -0
- package/lib/components/ProductTile/renderBenefit.d.ts +4 -0
- package/lib/components/ProductTile/renderBenefit.js +29 -0
- package/lib/components/ProductTile/renderBenefit.js.map +1 -0
- package/lib/components/ProductTile/renderImage.d.ts +3 -0
- package/lib/components/ProductTile/renderImage.js +9 -0
- package/lib/components/ProductTile/renderImage.js.map +1 -0
- package/lib/components/TextBlock/TextBlock.js +13 -28
- package/lib/components/TextBlock/TextBlock.js.map +1 -1
- package/lib/content-page-repository/transformImg.d.ts +1 -1
- package/lib/content-page-repository/transformImg.js +4 -10
- package/lib/content-page-repository/transformImg.js.map +1 -1
- package/lib/content-page-repository/transformMarkdown.js +3 -3
- package/lib/content-page-repository/transformMarkdown.js.map +1 -1
- package/lib/hooks/useLink.js +3 -5
- package/lib/hooks/useLink.js.map +1 -1
- package/lib/hooks/useLocation.js +11 -5
- package/lib/hooks/useLocation.js.map +1 -1
- package/lib/services/BlockRouter/BlockRouter.d.ts +1 -1
- package/lib/services/BlockRouter/BlockRouter.js.map +1 -1
- package/lib/services/sitemap/checkIsHrefSameOrigin.d.ts +2 -4
- package/lib/services/sitemap/checkIsHrefSameOrigin.js +1 -1
- package/lib/services/sitemap/checkIsHrefSameOrigin.js.map +1 -1
- package/lib/services/sitemap/isHrefActive.js +3 -4
- package/lib/services/sitemap/isHrefActive.js.map +1 -1
- package/lib/setup-fixture.js +3 -3
- package/lib/setup-fixture.js.map +1 -1
- package/lib/ui-kit/MarkdownText/MarkdownText.d.ts +2 -0
- package/lib/ui-kit/MarkdownText/MarkdownText.js +7 -0
- package/lib/ui-kit/MarkdownText/MarkdownText.js.map +1 -0
- package/lib/ui-kit/MarkdownText/MarkdownTextProps.d.ts +6 -0
- package/lib/ui-kit/MarkdownText/MarkdownTextProps.js +2 -0
- package/lib/ui-kit/MarkdownText/MarkdownTextProps.js.map +1 -0
- package/lib/ui-kit/Text/Text.js +1 -5
- package/lib/ui-kit/Text/Text.js.map +1 -1
- package/lib/utils/normalizeURLPath.d.ts +1 -0
- package/lib/utils/normalizeURLPath.js +9 -0
- package/lib/utils/normalizeURLPath.js.map +1 -0
- package/lib/utils/url.d.ts +1 -0
- package/lib/utils/url.js +7 -0
- package/lib/utils/url.js.map +1 -1
- package/lib/wlc.json +3 -1
- package/mobile/bundle/ProjectSettings.d.ts +2 -0
- package/mobile/bundle/bundle.umd.js +39 -21
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/ProductTile/ProductTileContent.d.ts +24 -2
- package/mobile/bundle/components/ProductTile/renderAdditionalDescription.d.ts +4 -0
- package/mobile/bundle/components/ProductTile/renderBenefit.d.ts +4 -0
- package/mobile/bundle/components/ProductTile/renderImage.d.ts +3 -0
- package/mobile/bundle/content-page-repository/transformImg.d.ts +1 -1
- package/mobile/bundle/services/BlockRouter/BlockRouter.d.ts +1 -1
- package/mobile/bundle/services/sitemap/checkIsHrefSameOrigin.d.ts +2 -4
- package/mobile/bundle/ui-kit/MarkdownText/MarkdownText.d.ts +2 -0
- package/mobile/bundle/ui-kit/MarkdownText/MarkdownTextProps.d.ts +6 -0
- package/mobile/bundle/utils/normalizeURLPath.d.ts +1 -0
- package/mobile/bundle/utils/url.d.ts +1 -0
- package/mobile/dist/ProjectSettings.d.ts +2 -0
- package/mobile/dist/ProjectSettings.js +5 -0
- package/mobile/dist/ProjectSettings.js.map +1 -1
- package/mobile/dist/api/LikeAPI.js +2 -2
- package/mobile/dist/api/LikeAPI.js.map +1 -1
- package/mobile/dist/components/ProductTile/ProductTile.js +9 -22
- package/mobile/dist/components/ProductTile/ProductTile.js.map +1 -1
- package/mobile/dist/components/ProductTile/ProductTileContent.d.ts +24 -2
- package/mobile/dist/components/ProductTile/renderAdditionalDescription.d.ts +4 -0
- package/mobile/dist/components/ProductTile/renderAdditionalDescription.js +18 -0
- package/mobile/dist/components/ProductTile/renderAdditionalDescription.js.map +1 -0
- package/mobile/dist/components/ProductTile/renderBenefit.d.ts +4 -0
- package/mobile/dist/components/ProductTile/renderBenefit.js +32 -0
- package/mobile/dist/components/ProductTile/renderBenefit.js.map +1 -0
- package/mobile/dist/components/ProductTile/renderImage.d.ts +3 -0
- package/mobile/dist/components/ProductTile/renderImage.js +12 -0
- package/mobile/dist/components/ProductTile/renderImage.js.map +1 -0
- package/mobile/dist/content-page-repository/transformImg.d.ts +1 -1
- package/mobile/dist/content-page-repository/transformImg.js +4 -10
- package/mobile/dist/content-page-repository/transformImg.js.map +1 -1
- package/mobile/dist/content-page-repository/transformMarkdown.js +3 -3
- package/mobile/dist/content-page-repository/transformMarkdown.js.map +1 -1
- package/mobile/dist/hooks/useLink.js +3 -5
- package/mobile/dist/hooks/useLink.js.map +1 -1
- package/mobile/dist/hooks/useLocation.js +11 -5
- package/mobile/dist/hooks/useLocation.js.map +1 -1
- package/mobile/dist/services/BlockRouter/BlockRouter.d.ts +1 -1
- package/mobile/dist/services/BlockRouter/BlockRouter.js.map +1 -1
- package/mobile/dist/services/sitemap/checkIsHrefSameOrigin.d.ts +2 -4
- package/mobile/dist/services/sitemap/checkIsHrefSameOrigin.js +1 -1
- package/mobile/dist/services/sitemap/checkIsHrefSameOrigin.js.map +1 -1
- package/mobile/dist/services/sitemap/isHrefActive.js +2 -3
- package/mobile/dist/services/sitemap/isHrefActive.js.map +1 -1
- package/mobile/dist/setup-fixture.js +3 -3
- package/mobile/dist/setup-fixture.js.map +1 -1
- package/mobile/dist/ui-kit/MarkdownText/MarkdownText.d.ts +2 -0
- package/mobile/dist/ui-kit/MarkdownText/MarkdownText.js +9 -0
- package/mobile/dist/ui-kit/MarkdownText/MarkdownText.js.map +1 -0
- package/mobile/dist/ui-kit/MarkdownText/MarkdownTextProps.d.ts +6 -0
- package/mobile/dist/ui-kit/MarkdownText/MarkdownTextProps.js +2 -0
- package/mobile/dist/ui-kit/MarkdownText/MarkdownTextProps.js.map +1 -0
- package/mobile/dist/ui-kit/Text/Text.js +1 -5
- package/mobile/dist/ui-kit/Text/Text.js.map +1 -1
- package/mobile/dist/utils/normalizeURLPath.d.ts +1 -0
- package/mobile/dist/utils/normalizeURLPath.js +12 -0
- package/mobile/dist/utils/normalizeURLPath.js.map +1 -0
- package/mobile/dist/utils/url.d.ts +1 -0
- package/mobile/dist/utils/url.js +9 -1
- package/mobile/dist/utils/url.js.map +1 -1
- package/mobile/dist/wlc.json +3 -1
- package/mobile/lib/ProjectSettings.d.ts +2 -0
- package/mobile/lib/ProjectSettings.js +5 -0
- package/mobile/lib/ProjectSettings.js.map +1 -1
- package/mobile/lib/api/LikeAPI.js +2 -2
- package/mobile/lib/api/LikeAPI.js.map +1 -1
- package/mobile/lib/components/ProductTile/ProductTile.js +10 -23
- package/mobile/lib/components/ProductTile/ProductTile.js.map +1 -1
- package/mobile/lib/components/ProductTile/ProductTileContent.d.ts +24 -2
- package/mobile/lib/components/ProductTile/renderAdditionalDescription.d.ts +4 -0
- package/mobile/lib/components/ProductTile/renderAdditionalDescription.js +15 -0
- package/mobile/lib/components/ProductTile/renderAdditionalDescription.js.map +1 -0
- package/mobile/lib/components/ProductTile/renderBenefit.d.ts +4 -0
- package/mobile/lib/components/ProductTile/renderBenefit.js +29 -0
- package/mobile/lib/components/ProductTile/renderBenefit.js.map +1 -0
- package/mobile/lib/components/ProductTile/renderImage.d.ts +3 -0
- package/mobile/lib/components/ProductTile/renderImage.js +9 -0
- package/mobile/lib/components/ProductTile/renderImage.js.map +1 -0
- package/mobile/lib/content-page-repository/transformImg.d.ts +1 -1
- package/mobile/lib/content-page-repository/transformImg.js +4 -10
- package/mobile/lib/content-page-repository/transformImg.js.map +1 -1
- package/mobile/lib/content-page-repository/transformMarkdown.js +3 -3
- package/mobile/lib/content-page-repository/transformMarkdown.js.map +1 -1
- package/mobile/lib/hooks/useLink.js +3 -5
- package/mobile/lib/hooks/useLink.js.map +1 -1
- package/mobile/lib/hooks/useLocation.js +11 -5
- package/mobile/lib/hooks/useLocation.js.map +1 -1
- package/mobile/lib/services/BlockRouter/BlockRouter.d.ts +1 -1
- package/mobile/lib/services/BlockRouter/BlockRouter.js.map +1 -1
- package/mobile/lib/services/sitemap/checkIsHrefSameOrigin.d.ts +2 -4
- package/mobile/lib/services/sitemap/checkIsHrefSameOrigin.js +1 -1
- package/mobile/lib/services/sitemap/checkIsHrefSameOrigin.js.map +1 -1
- package/mobile/lib/services/sitemap/isHrefActive.js +3 -4
- package/mobile/lib/services/sitemap/isHrefActive.js.map +1 -1
- package/mobile/lib/setup-fixture.js +3 -3
- package/mobile/lib/setup-fixture.js.map +1 -1
- package/mobile/lib/ui-kit/MarkdownText/MarkdownText.d.ts +2 -0
- package/mobile/lib/ui-kit/MarkdownText/MarkdownText.js +7 -0
- package/mobile/lib/ui-kit/MarkdownText/MarkdownText.js.map +1 -0
- package/mobile/lib/ui-kit/MarkdownText/MarkdownTextProps.d.ts +6 -0
- package/mobile/lib/ui-kit/MarkdownText/MarkdownTextProps.js +2 -0
- package/mobile/lib/ui-kit/MarkdownText/MarkdownTextProps.js.map +1 -0
- package/mobile/lib/ui-kit/Text/Text.js +1 -5
- package/mobile/lib/ui-kit/Text/Text.js.map +1 -1
- package/mobile/lib/utils/normalizeURLPath.d.ts +1 -0
- package/mobile/lib/utils/normalizeURLPath.js +9 -0
- package/mobile/lib/utils/normalizeURLPath.js.map +1 -0
- package/mobile/lib/utils/url.d.ts +1 -0
- package/mobile/lib/utils/url.js +7 -0
- package/mobile/lib/utils/url.js.map +1 -1
- package/mobile/lib/wlc.json +3 -1
- package/mobile/src/ProjectSettings.ts +6 -0
- package/mobile/src/api/LikeAPI.ts +2 -2
- package/mobile/src/common.css +50 -0
- package/mobile/src/components/ProductTile/ProductTile.example.json +3 -0
- package/mobile/src/components/ProductTile/ProductTile.tsx +13 -44
- package/mobile/src/components/ProductTile/ProductTile.ui.json +14 -1
- package/mobile/src/components/ProductTile/ProductTileContent.ts +26 -2
- package/mobile/src/components/ProductTile/renderAdditionalDescription.tsx +30 -0
- package/mobile/src/components/ProductTile/renderBenefit.tsx +39 -0
- package/mobile/src/components/ProductTile/renderImage.tsx +15 -0
- package/mobile/src/content-page-repository/transformImg.ts +6 -14
- package/mobile/src/content-page-repository/transformMarkdown.ts +3 -3
- package/mobile/src/hooks/useLink.ts +6 -7
- package/mobile/src/hooks/useLocation.ts +12 -6
- package/mobile/src/services/BlockRouter/BlockRouter.ts +1 -1
- package/mobile/src/services/sitemap/checkIsHrefSameOrigin.ts +5 -4
- package/mobile/src/services/sitemap/isHrefActive.ts +7 -4
- package/mobile/src/setup-fixture.ts +3 -3
- package/mobile/src/ui-kit/MarkdownText/MarkdownText.tsx +8 -0
- package/mobile/src/ui-kit/MarkdownText/MarkdownTextProps.ts +6 -0
- package/mobile/src/ui-kit/Text/Text.tsx +5 -7
- package/mobile/src/utils/normalizeURLPath.ts +10 -0
- package/mobile/src/utils/url.ts +10 -0
- package/mobile/src/wlc.json +3 -1
- package/package.json +1 -1
- package/src/ProjectSettings.ts +6 -0
- package/src/api/LikeAPI.ts +2 -2
- package/src/common.css +50 -0
- package/src/components/Header/Header.tsx +2 -10
- package/src/components/ProductTile/ProductTile.example.json +3 -0
- package/src/components/ProductTile/ProductTile.fixture.tsx +11 -4
- package/src/components/ProductTile/ProductTile.tsx +13 -44
- package/src/components/ProductTile/ProductTile.ui.json +14 -1
- package/src/components/ProductTile/ProductTileContent.ts +26 -2
- package/src/components/ProductTile/renderAdditionalDescription.tsx +30 -0
- package/src/components/ProductTile/renderBenefit.tsx +39 -0
- package/src/components/ProductTile/renderImage.tsx +15 -0
- package/src/components/TextBlock/TextBlock.tsx +49 -41
- package/src/content-page-repository/transformImg.ts +6 -14
- package/src/content-page-repository/transformMarkdown.ts +3 -3
- package/src/hooks/useLink.ts +6 -7
- package/src/hooks/useLocation.ts +12 -6
- package/src/services/BlockRouter/BlockRouter.ts +1 -1
- package/src/services/sitemap/checkIsHrefSameOrigin.ts +5 -4
- package/src/services/sitemap/isHrefActive.ts +7 -4
- package/src/setup-fixture.ts +3 -3
- package/src/ui-kit/MarkdownText/MarkdownText.tsx +8 -0
- package/src/ui-kit/MarkdownText/MarkdownTextProps.ts +6 -0
- package/src/ui-kit/Text/Text.tsx +5 -7
- package/src/utils/normalizeURLPath.ts +10 -0
- package/src/utils/url.ts +10 -0
- package/src/wlc.json +3 -1
package/src/hooks/useLink.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LinkProps } from '../model/LinkProps';
|
|
1
|
+
import type { LinkProps, Target } from '../model/LinkProps';
|
|
2
2
|
import { useBlockRouter } from '../services/BlockRouter/useBlockRouter';
|
|
3
3
|
import { adjustHref } from '../utils/adjustHref';
|
|
4
4
|
import { isHash, isURL } from '../utils/url';
|
|
@@ -25,11 +25,7 @@ export function useLink(): <L extends Partial<LinkProps & ClickHandler>>(
|
|
|
25
25
|
onClick: handlerDecorator((ev?: { preventDefault: () => void }) => {
|
|
26
26
|
props.onClick && props.onClick(ev);
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
const isLocalTarget = !props.target || props.target === '_self';
|
|
30
|
-
|
|
31
|
-
if (!isLocalHref || !isLocalTarget) {
|
|
32
|
-
// Default handle
|
|
28
|
+
if (isRemoteHref(href, props.target)) {
|
|
33
29
|
return;
|
|
34
30
|
}
|
|
35
31
|
|
|
@@ -37,9 +33,12 @@ export function useLink(): <L extends Partial<LinkProps & ClickHandler>>(
|
|
|
37
33
|
if (isHash(href)) {
|
|
38
34
|
blockRouter.goto(href);
|
|
39
35
|
} else {
|
|
40
|
-
router.push(href);
|
|
36
|
+
href && router.push(href);
|
|
41
37
|
}
|
|
42
38
|
}, props),
|
|
43
39
|
};
|
|
44
40
|
};
|
|
45
41
|
}
|
|
42
|
+
|
|
43
|
+
const isRemoteHref = (href?: string, target?: Target) =>
|
|
44
|
+
isURL(href) || (target && target !== '_self') || href?.startsWith('/');
|
package/src/hooks/useLocation.ts
CHANGED
|
@@ -15,14 +15,10 @@ interface LocationStorageData {
|
|
|
15
15
|
region: RegionData;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const localStorageLocation = globalThis?.localStorage.getItem('location');
|
|
19
|
-
const currentLocation: LocationStorageData | null = localStorageLocation
|
|
20
|
-
? JSON.parse(localStorageLocation)
|
|
21
|
-
: null;
|
|
22
|
-
|
|
23
18
|
export function useLocation(
|
|
24
19
|
defaultLocation: string,
|
|
25
20
|
): [RegionData, (newLocation: RegionData) => void] {
|
|
21
|
+
const currentLocation = getLocalStorageLocation();
|
|
26
22
|
const [location, setLocation] = useState<RegionData>(
|
|
27
23
|
currentLocation?.region ?? { name: defaultLocation },
|
|
28
24
|
);
|
|
@@ -38,7 +34,7 @@ export function useLocation(
|
|
|
38
34
|
|
|
39
35
|
const onChangeLocation = useCallback(
|
|
40
36
|
(region: RegionData) => {
|
|
41
|
-
globalThis?.
|
|
37
|
+
globalThis.localStorage?.setItem('location', JSON.stringify({ manual: true, region }));
|
|
42
38
|
setLocation(region);
|
|
43
39
|
},
|
|
44
40
|
[setLocation],
|
|
@@ -46,3 +42,13 @@ export function useLocation(
|
|
|
46
42
|
|
|
47
43
|
return [location, onChangeLocation];
|
|
48
44
|
}
|
|
45
|
+
|
|
46
|
+
const getLocalStorageLocation = (): LocationStorageData | null => {
|
|
47
|
+
const localStorageLocation = globalThis.localStorage?.getItem('location');
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
return localStorageLocation ? JSON.parse(localStorageLocation) : null;
|
|
51
|
+
} catch (_) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { Router } from '../../hooks/useRouter';
|
|
1
2
|
import { getOrigin } from '../../utils/url';
|
|
2
3
|
|
|
3
|
-
export const checkIsHrefSameOrigin = (
|
|
4
|
-
href
|
|
5
|
-
|
|
6
|
-
)
|
|
4
|
+
export const checkIsHrefSameOrigin = (href: string | undefined, router: Router) =>
|
|
5
|
+
[getOrigin(href), getOrigin(router.href)].every(
|
|
6
|
+
(link, _, arr) => Boolean(link) && link === arr[0],
|
|
7
|
+
);
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeURLPath } from '../../utils/normalizeURLPath';
|
|
2
|
+
import { getPathname, isURL, withoutQuery } from '../../utils/url';
|
|
2
3
|
|
|
3
4
|
export const isHrefActive = (
|
|
4
5
|
href: string | undefined,
|
|
5
6
|
router: { pathname?: string; href?: string },
|
|
6
7
|
cmp: (targetHref: string, baseHref: string) => boolean = (targetHref, baseHref) =>
|
|
7
8
|
baseHref.startsWith(targetHref),
|
|
8
|
-
) =>
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
) =>
|
|
10
|
+
cmp(
|
|
11
|
+
withoutQuery(normalizeURLPath(href)),
|
|
12
|
+
withoutQuery(isURL(href) ? router.href : getPathname(router.href)),
|
|
13
|
+
);
|
package/src/setup-fixture.ts
CHANGED
|
@@ -8,11 +8,11 @@ import wlc from './wlc.json';
|
|
|
8
8
|
projectSettings.setup(wlc);
|
|
9
9
|
|
|
10
10
|
useRouter.setup(() => {
|
|
11
|
-
const [
|
|
11
|
+
const [, setHref] = useState<string>(globalThis.location.href);
|
|
12
12
|
|
|
13
13
|
return {
|
|
14
|
-
href:
|
|
15
|
-
pathname: '/
|
|
14
|
+
href: `${globalThis.location.origin}${projectSettings.BASE_PATH}cards-credit`, //for header active links
|
|
15
|
+
pathname: '/cards-credit',
|
|
16
16
|
query: {},
|
|
17
17
|
push: (url: string) => {
|
|
18
18
|
globalThis.history.pushState(null, '', url);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import type { MarkdownTextProps } from './MarkdownTextProps';
|
|
3
|
+
|
|
4
|
+
export const MarkdownText = JSX<MarkdownTextProps>((props) => {
|
|
5
|
+
const { md = '' } = props;
|
|
6
|
+
|
|
7
|
+
return <div className="md-container" dangerouslySetInnerHTML={{ __html: md }} />;
|
|
8
|
+
});
|
package/src/ui-kit/Text/Text.tsx
CHANGED
|
@@ -8,10 +8,8 @@ interface TextProps {
|
|
|
8
8
|
font?: FontWeight;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const Text = JSX<TextProps>((
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return <span className={textClasses}>{children}</span>;
|
|
17
|
-
});
|
|
11
|
+
export const Text = JSX<TextProps>(({ size, color, align, font, children }) => (
|
|
12
|
+
<span className={['font-sans', size, color, align, font].filter(Boolean).join(' ')}>
|
|
13
|
+
{children}
|
|
14
|
+
</span>
|
|
15
|
+
));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { projectSettings } from '../ProjectSettings';
|
|
2
|
+
import { isURL } from './url';
|
|
3
|
+
|
|
4
|
+
export const normalizeURLPath = (href?: string) => {
|
|
5
|
+
if (isURL(href) || href?.startsWith('/')) {
|
|
6
|
+
return href;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return `${projectSettings.BASE_PATH || ''}${href}`;
|
|
10
|
+
};
|
package/src/utils/url.ts
CHANGED
|
@@ -15,6 +15,16 @@ export const getOrigin = (href?: string) => {
|
|
|
15
15
|
return endOfOrigin !== -1 ? url.substring(0, endOfOrigin) : url;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
export const getPathname = (href?: string) => {
|
|
19
|
+
if (!href || !isURL(href)) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const url = new URL(href);
|
|
24
|
+
|
|
25
|
+
return url.pathname;
|
|
26
|
+
};
|
|
27
|
+
|
|
18
28
|
export const getHash = (href?: string) => {
|
|
19
29
|
if (!href || !isURL(href)) {
|
|
20
30
|
return undefined;
|
package/src/wlc.json
CHANGED