@redneckz/wildless-cms-uni-blocks 0.8.8 → 0.8.9
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/EventBus/EventBus.d.ts +1 -4
- package/bundle/EventBus/defaultEventBus.d.ts +7 -0
- package/bundle/blocks.schema.json +1 -1
- package/bundle/bundle.umd.js +31 -66
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/ButtonBlock/ButtonBlockContent.d.ts +5 -1
- package/bundle/hooks/useRouter.d.ts +6 -2
- package/bundle/services/BlockRouter/BlockRouter.d.ts +3 -22
- package/bundle/services/BlockRouter/blockRouterEventBus.d.ts +11 -0
- package/bundle/services/BlockRouter/useBlockIntersectionObserver.d.ts +1 -2
- package/bundle/services/BlockRouter/useBlockRouterProvider.d.ts +1 -2
- package/dist/EventBus/EventBus.d.ts +1 -4
- package/dist/EventBus/EventBus.js +0 -1
- package/dist/EventBus/EventBus.js.map +1 -1
- package/dist/EventBus/defaultEventBus.d.ts +7 -0
- package/dist/EventBus/defaultEventBus.js +5 -0
- package/dist/EventBus/defaultEventBus.js.map +1 -0
- package/dist/components/ButtonBlock/ButtonBlock.js +2 -1
- package/dist/components/ButtonBlock/ButtonBlock.js.map +1 -1
- package/dist/components/ButtonBlock/ButtonBlockContent.d.ts +5 -1
- package/dist/components/Tabs/Tabs.js +4 -4
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/hooks/useLink.js +2 -3
- package/dist/hooks/useLink.js.map +1 -1
- package/dist/hooks/useRouter.d.ts +6 -2
- package/dist/hooks/useRouter.js.map +1 -1
- package/dist/services/BlockRouter/BlockRouter.d.ts +3 -22
- package/dist/services/BlockRouter/BlockRouter.js +11 -30
- package/dist/services/BlockRouter/BlockRouter.js.map +1 -1
- package/dist/services/BlockRouter/blockRouterEventBus.d.ts +11 -0
- package/dist/services/BlockRouter/blockRouterEventBus.js +5 -0
- package/dist/services/BlockRouter/blockRouterEventBus.js.map +1 -0
- package/dist/services/BlockRouter/useBlockIntersectionObserver.d.ts +1 -2
- package/dist/services/BlockRouter/useBlockIntersectionObserver.js +5 -16
- package/dist/services/BlockRouter/useBlockIntersectionObserver.js.map +1 -1
- package/dist/services/BlockRouter/useBlockRouterProvider.d.ts +1 -2
- package/dist/services/BlockRouter/useBlockRouterProvider.js +11 -12
- package/dist/services/BlockRouter/useBlockRouterProvider.js.map +1 -1
- package/dist/ui-kit/BlockWrapper.js +2 -2
- package/dist/ui-kit/BlockWrapper.js.map +1 -1
- package/lib/EventBus/EventBus.d.ts +1 -4
- package/lib/EventBus/EventBus.js +0 -1
- package/lib/EventBus/EventBus.js.map +1 -1
- package/lib/EventBus/defaultEventBus.d.ts +7 -0
- package/lib/EventBus/defaultEventBus.js +3 -0
- package/lib/EventBus/defaultEventBus.js.map +1 -0
- package/lib/common.css +1 -1
- package/lib/components/ButtonBlock/ButtonBlock.js +2 -1
- package/lib/components/ButtonBlock/ButtonBlock.js.map +1 -1
- package/lib/components/ButtonBlock/ButtonBlockContent.d.ts +5 -1
- package/lib/components/Tabs/Tabs.js +4 -4
- package/lib/components/Tabs/Tabs.js.map +1 -1
- package/lib/hooks/useLink.js +2 -3
- package/lib/hooks/useLink.js.map +1 -1
- package/lib/hooks/useRouter.d.ts +6 -2
- package/lib/hooks/useRouter.js.map +1 -1
- package/lib/services/BlockRouter/BlockRouter.d.ts +3 -22
- package/lib/services/BlockRouter/BlockRouter.js +8 -28
- package/lib/services/BlockRouter/BlockRouter.js.map +1 -1
- package/lib/services/BlockRouter/blockRouterEventBus.d.ts +11 -0
- package/lib/services/BlockRouter/blockRouterEventBus.js +3 -0
- package/lib/services/BlockRouter/blockRouterEventBus.js.map +1 -0
- package/lib/services/BlockRouter/useBlockIntersectionObserver.d.ts +1 -2
- package/lib/services/BlockRouter/useBlockIntersectionObserver.js +6 -17
- package/lib/services/BlockRouter/useBlockIntersectionObserver.js.map +1 -1
- package/lib/services/BlockRouter/useBlockRouterProvider.d.ts +1 -2
- package/lib/services/BlockRouter/useBlockRouterProvider.js +12 -13
- package/lib/services/BlockRouter/useBlockRouterProvider.js.map +1 -1
- package/lib/ui-kit/BlockWrapper.js +2 -2
- package/lib/ui-kit/BlockWrapper.js.map +1 -1
- package/mobile/bundle/EventBus/EventBus.d.ts +1 -4
- package/mobile/bundle/EventBus/defaultEventBus.d.ts +7 -0
- package/mobile/bundle/bundle.umd.js +27 -62
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/ButtonBlock/ButtonBlockContent.d.ts +5 -1
- package/mobile/bundle/hooks/useRouter.d.ts +6 -2
- package/mobile/bundle/services/BlockRouter/BlockRouter.d.ts +3 -22
- package/mobile/bundle/services/BlockRouter/blockRouterEventBus.d.ts +11 -0
- package/mobile/bundle/services/BlockRouter/useBlockIntersectionObserver.d.ts +1 -2
- package/mobile/bundle/services/BlockRouter/useBlockRouterProvider.d.ts +1 -2
- package/mobile/dist/EventBus/EventBus.d.ts +1 -4
- package/mobile/dist/EventBus/EventBus.js +0 -1
- package/mobile/dist/EventBus/EventBus.js.map +1 -1
- package/mobile/dist/EventBus/defaultEventBus.d.ts +7 -0
- package/mobile/dist/EventBus/defaultEventBus.js +5 -0
- package/mobile/dist/EventBus/defaultEventBus.js.map +1 -0
- package/mobile/dist/components/ButtonBlock/ButtonBlock.js +2 -1
- package/mobile/dist/components/ButtonBlock/ButtonBlock.js.map +1 -1
- package/mobile/dist/components/ButtonBlock/ButtonBlockContent.d.ts +5 -1
- package/mobile/dist/components/Tabs/Tabs.js +4 -4
- package/mobile/dist/components/Tabs/Tabs.js.map +1 -1
- package/mobile/dist/hooks/useLink.js +2 -3
- package/mobile/dist/hooks/useLink.js.map +1 -1
- package/mobile/dist/hooks/useRouter.d.ts +6 -2
- package/mobile/dist/hooks/useRouter.js.map +1 -1
- package/mobile/dist/services/BlockRouter/BlockRouter.d.ts +3 -22
- package/mobile/dist/services/BlockRouter/BlockRouter.js +11 -30
- package/mobile/dist/services/BlockRouter/BlockRouter.js.map +1 -1
- package/mobile/dist/services/BlockRouter/blockRouterEventBus.d.ts +11 -0
- package/mobile/dist/services/BlockRouter/blockRouterEventBus.js +5 -0
- package/mobile/dist/services/BlockRouter/blockRouterEventBus.js.map +1 -0
- package/mobile/dist/services/BlockRouter/useBlockIntersectionObserver.d.ts +1 -2
- package/mobile/dist/services/BlockRouter/useBlockIntersectionObserver.js +5 -16
- package/mobile/dist/services/BlockRouter/useBlockIntersectionObserver.js.map +1 -1
- package/mobile/dist/services/BlockRouter/useBlockRouterProvider.d.ts +1 -2
- package/mobile/dist/services/BlockRouter/useBlockRouterProvider.js +11 -12
- package/mobile/dist/services/BlockRouter/useBlockRouterProvider.js.map +1 -1
- package/mobile/dist/ui-kit/BlockWrapper.js +2 -2
- package/mobile/dist/ui-kit/BlockWrapper.js.map +1 -1
- package/mobile/lib/EventBus/EventBus.d.ts +1 -4
- package/mobile/lib/EventBus/EventBus.js +0 -1
- package/mobile/lib/EventBus/EventBus.js.map +1 -1
- package/mobile/lib/EventBus/defaultEventBus.d.ts +7 -0
- package/mobile/lib/EventBus/defaultEventBus.js +3 -0
- package/mobile/lib/EventBus/defaultEventBus.js.map +1 -0
- package/mobile/lib/components/ButtonBlock/ButtonBlock.js +2 -1
- package/mobile/lib/components/ButtonBlock/ButtonBlock.js.map +1 -1
- package/mobile/lib/components/ButtonBlock/ButtonBlockContent.d.ts +5 -1
- package/mobile/lib/components/Tabs/Tabs.js +4 -4
- package/mobile/lib/components/Tabs/Tabs.js.map +1 -1
- package/mobile/lib/hooks/useLink.js +2 -3
- package/mobile/lib/hooks/useLink.js.map +1 -1
- package/mobile/lib/hooks/useRouter.d.ts +6 -2
- package/mobile/lib/hooks/useRouter.js.map +1 -1
- package/mobile/lib/services/BlockRouter/BlockRouter.d.ts +3 -22
- package/mobile/lib/services/BlockRouter/BlockRouter.js +8 -28
- package/mobile/lib/services/BlockRouter/BlockRouter.js.map +1 -1
- package/mobile/lib/services/BlockRouter/blockRouterEventBus.d.ts +11 -0
- package/mobile/lib/services/BlockRouter/blockRouterEventBus.js +3 -0
- package/mobile/lib/services/BlockRouter/blockRouterEventBus.js.map +1 -0
- package/mobile/lib/services/BlockRouter/useBlockIntersectionObserver.d.ts +1 -2
- package/mobile/lib/services/BlockRouter/useBlockIntersectionObserver.js +6 -17
- package/mobile/lib/services/BlockRouter/useBlockIntersectionObserver.js.map +1 -1
- package/mobile/lib/services/BlockRouter/useBlockRouterProvider.d.ts +1 -2
- package/mobile/lib/services/BlockRouter/useBlockRouterProvider.js +12 -13
- package/mobile/lib/services/BlockRouter/useBlockRouterProvider.js.map +1 -1
- package/mobile/lib/ui-kit/BlockWrapper.js +2 -2
- package/mobile/lib/ui-kit/BlockWrapper.js.map +1 -1
- package/mobile/src/EventBus/EventBus.ts +1 -7
- package/mobile/src/EventBus/defaultEventBus.ts +8 -0
- package/mobile/src/components/ButtonBlock/ButtonBlock.example.json +2 -2
- package/mobile/src/components/ButtonBlock/ButtonBlock.tsx +5 -2
- package/mobile/src/components/ButtonBlock/ButtonBlockContent.ts +5 -1
- package/mobile/src/components/Tabs/Tabs.tsx +4 -4
- package/mobile/src/hooks/useLink.ts +2 -3
- package/mobile/src/hooks/useRouter.ts +6 -2
- package/mobile/src/services/BlockRouter/BlockRouter.ts +8 -47
- package/mobile/src/services/BlockRouter/blockRouterEventBus.ts +13 -0
- package/mobile/src/services/BlockRouter/useBlockIntersectionObserver.ts +6 -23
- package/mobile/src/services/BlockRouter/useBlockRouterProvider.ts +13 -19
- package/mobile/src/ui-kit/BlockWrapper.tsx +2 -2
- package/package.json +1 -1
- package/src/EventBus/EventBus.ts +1 -7
- package/src/EventBus/defaultEventBus.ts +8 -0
- package/src/components/ButtonBlock/ButtonBlock.example.json +2 -2
- package/src/components/ButtonBlock/ButtonBlock.tsx +5 -2
- package/src/components/ButtonBlock/ButtonBlockContent.ts +5 -1
- package/src/components/Tabs/Tabs.tsx +4 -4
- package/src/hooks/useLink.ts +2 -3
- package/src/hooks/useRouter.ts +6 -2
- package/src/services/BlockRouter/BlockRouter.ts +8 -47
- package/src/services/BlockRouter/blockRouterEventBus.ts +13 -0
- package/src/services/BlockRouter/useBlockIntersectionObserver.ts +6 -23
- package/src/services/BlockRouter/useBlockRouterProvider.ts +13 -19
- package/src/ui-kit/BlockWrapper.tsx +2 -2
- package/bundle/EventBus/EventMap.d.ts +0 -4
- package/bundle/services/BlockRouter/useBlockRouter.d.ts +0 -2
- package/dist/EventBus/EventMap.d.ts +0 -4
- package/dist/EventBus/EventMap.js +0 -2
- package/dist/EventBus/EventMap.js.map +0 -1
- package/dist/services/BlockRouter/useBlockRouter.d.ts +0 -2
- package/dist/services/BlockRouter/useBlockRouter.js +0 -8
- package/dist/services/BlockRouter/useBlockRouter.js.map +0 -1
- package/lib/EventBus/EventMap.d.ts +0 -4
- package/lib/EventBus/EventMap.js +0 -2
- package/lib/EventBus/EventMap.js.map +0 -1
- package/lib/services/BlockRouter/useBlockRouter.d.ts +0 -2
- package/lib/services/BlockRouter/useBlockRouter.js +0 -5
- package/lib/services/BlockRouter/useBlockRouter.js.map +0 -1
- package/mobile/bundle/EventBus/EventMap.d.ts +0 -4
- package/mobile/bundle/services/BlockRouter/useBlockRouter.d.ts +0 -2
- package/mobile/dist/EventBus/EventMap.d.ts +0 -4
- package/mobile/dist/EventBus/EventMap.js +0 -2
- package/mobile/dist/EventBus/EventMap.js.map +0 -1
- package/mobile/dist/services/BlockRouter/useBlockRouter.d.ts +0 -2
- package/mobile/dist/services/BlockRouter/useBlockRouter.js +0 -8
- package/mobile/dist/services/BlockRouter/useBlockRouter.js.map +0 -1
- package/mobile/lib/EventBus/EventMap.d.ts +0 -4
- package/mobile/lib/EventBus/EventMap.js +0 -2
- package/mobile/lib/EventBus/EventMap.js.map +0 -1
- package/mobile/lib/services/BlockRouter/useBlockRouter.d.ts +0 -2
- package/mobile/lib/services/BlockRouter/useBlockRouter.js +0 -5
- package/mobile/lib/services/BlockRouter/useBlockRouter.js.map +0 -1
- package/mobile/src/EventBus/EventMap.ts +0 -5
- package/mobile/src/services/BlockRouter/useBlockRouter.ts +0 -5
- package/src/EventBus/EventMap.ts +0 -5
- package/src/services/BlockRouter/useBlockRouter.ts +0 -5
|
@@ -3,14 +3,14 @@ exports.Tabs = void 0;
|
|
|
3
3
|
const jsx_runtime_1 = require("@redneckz/uni-jsx/jsx-runtime");
|
|
4
4
|
const uni_jsx_1 = require("@redneckz/uni-jsx");
|
|
5
5
|
const hooks_1 = require("@redneckz/uni-jsx/lib/hooks");
|
|
6
|
-
const
|
|
6
|
+
const defaultEventBus_1 = require("../../EventBus/defaultEventBus");
|
|
7
7
|
const BlockWrapper_1 = require("../../ui-kit/BlockWrapper");
|
|
8
8
|
const renderTab_1 = require("./renderTab");
|
|
9
9
|
const ScrollableTabs_1 = require("./ScrollableTabs");
|
|
10
10
|
exports.Tabs = (0, uni_jsx_1.JSX)((props) => {
|
|
11
11
|
const { className = '', tabs, showCounter, isSticky, tabsMode, ...rest } = props;
|
|
12
12
|
const [currentTab, setCurrentTab] = (0, hooks_1.useState)(tabs ? tabs[0] : undefined);
|
|
13
|
-
(0, hooks_1.useEffect)(() =>
|
|
13
|
+
(0, hooks_1.useEffect)(() => defaultEventBus_1.defaultEventBus.subscribe('tab', (event) => {
|
|
14
14
|
const tab = tabs?.find(checkTab(event));
|
|
15
15
|
if (event.type === 'link' && tab) {
|
|
16
16
|
setCurrentTab(tab);
|
|
@@ -18,11 +18,11 @@ exports.Tabs = (0, uni_jsx_1.JSX)((props) => {
|
|
|
18
18
|
return [];
|
|
19
19
|
}), [tabs]);
|
|
20
20
|
(0, hooks_1.useEffect)(() => currentTab?.type === 'group'
|
|
21
|
-
?
|
|
21
|
+
? defaultEventBus_1.defaultEventBus.subject('tab', { type: currentTab.type, label: currentTab.ref })
|
|
22
22
|
: undefined, [currentTab]);
|
|
23
23
|
const handleClick = (0, hooks_1.useCallback)((selectedTab) => {
|
|
24
24
|
if (selectedTab?.type === 'group') {
|
|
25
|
-
|
|
25
|
+
defaultEventBus_1.defaultEventBus.fire('tab', { type: selectedTab.type, label: selectedTab.ref });
|
|
26
26
|
}
|
|
27
27
|
setCurrentTab(selectedTab);
|
|
28
28
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../../src/components/Tabs/Tabs.tsx"],"names":[],"mappings":";;;AAAA,+CAAwC;AACxC,uDAA+E;AAC/E,
|
|
1
|
+
{"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../../src/components/Tabs/Tabs.tsx"],"names":[],"mappings":";;;AAAA,+CAAwC;AACxC,uDAA+E;AAC/E,oEAAiE;AAEjE,4DAAyD;AACzD,2CAAwC;AACxC,qDAAkD;AAUrC,QAAA,IAAI,GAAG,IAAA,aAAG,EAAiB,CAAC,KAAK,EAAE,EAAE;IAChD,MAAM,EAAE,SAAS,GAAG,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAEjF,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAEzE,IAAA,iBAAS,EACP,GAAG,EAAE,CACH,iCAAe,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;QACzC,MAAM,GAAG,GAAG,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;QACxC,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,GAAG,EAAE;YAChC,aAAa,CAAC,GAAG,CAAC,CAAC;SACpB;QAED,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,EACJ,CAAC,IAAI,CAAC,CACP,CAAC;IAEF,IAAA,iBAAS,EACP,GAAG,EAAE,CACH,UAAU,EAAE,IAAI,KAAK,OAAO;QAC1B,CAAC,CAAC,iCAAe,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC;QAClF,CAAC,CAAC,SAAS,EACf,CAAC,UAAU,CAAC,CACb,CAAC;IAEF,MAAM,WAAW,GAAG,IAAA,mBAAW,EAAC,CAAC,WAAoB,EAAE,EAAE;QACvD,IAAI,WAAW,EAAE,IAAI,KAAK,OAAO,EAAE;YACjC,iCAAe,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC;SACjF;QACD,aAAa,CAAC,WAAW,CAAC,CAAC;IAC7B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,uBAAC,2BAAY,IACX,SAAS,EAAE,2CACT,QAAQ,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EACpC,IAAI,SAAS,EAAE,EACf,IAAI,EAAC,SAAS,KACV,IAAI,YAEP,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,CAC3B,uBAAC,+BAAc,IACb,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,KACpB,IAAI,GACR,CACH,CAAC,CAAC,CAAC,CACF,IAAI,EAAE,GAAG,CACP,IAAA,qBAAS,EAAC;YACR,OAAO,EAAE,WAAW;YACpB,UAAU;YACV,WAAW;YACX,GAAG,IAAI;SACR,CAAC,CACH,CACF,GACY,CAChB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,QAAQ,GAAG,CAAC,KAAyB,EAAE,EAAE,CAAC,CAAC,CAAU,EAAE,EAAE,CAC7D,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
2
|
exports.useLink = void 0;
|
|
3
3
|
const ProjectSettings_1 = require("../ProjectSettings");
|
|
4
|
-
const
|
|
4
|
+
const BlockRouter_1 = require("../services/BlockRouter/BlockRouter");
|
|
5
5
|
const url_1 = require("../utils/url");
|
|
6
6
|
const handlerDecorator_1 = require("./handlerDecorator");
|
|
7
7
|
const useRouter_1 = require("./useRouter");
|
|
8
8
|
function useLink(isRemote) {
|
|
9
9
|
const router = (0, useRouter_1.useRouter)();
|
|
10
|
-
const blockRouter = (0, useBlockRouter_1.useBlockRouter)();
|
|
11
10
|
return (props) => ({
|
|
12
11
|
...props,
|
|
13
12
|
href: adjustHref(props.href),
|
|
@@ -30,7 +29,7 @@ function useLink(isRemote) {
|
|
|
30
29
|
// Client routing
|
|
31
30
|
ev?.preventDefault();
|
|
32
31
|
if ((0, url_1.isHash)(href)) {
|
|
33
|
-
|
|
32
|
+
(0, BlockRouter_1.gotoBlock)(router, href);
|
|
34
33
|
}
|
|
35
34
|
else if (href) {
|
|
36
35
|
router.push(href);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLink.js","sourceRoot":"","sources":["../../src/hooks/useLink.ts"],"names":[],"mappings":";;AACA,wDAAqD;AACrD,
|
|
1
|
+
{"version":3,"file":"useLink.js","sourceRoot":"","sources":["../../src/hooks/useLink.ts"],"names":[],"mappings":";;AACA,wDAAqD;AACrD,qEAAgE;AAChE,sCAA4D;AAC5D,yDAAsD;AACtD,2CAAwC;AAUxC,SAAgB,OAAO,CAAC,QAAkB;IACxC,MAAM,MAAM,GAAG,IAAA,qBAAS,GAAE,CAAC;IAE3B,OAAO,CAA2C,KAAQ,EAAiB,EAAE,CAAC,CAAC;QAC7E,GAAG,KAAK;QACR,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC;QAC5B,YAAY,EAAE,KAAK,CAAC,IAAI;QACxB,OAAO,EAAE,IAAA,mCAAgB,EAAC,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;KACpD,CAAC,CAAC;IAEH,SAAS,UAAU,CAAC,IAAwB;QAC1C,MAAM,gBAAgB,GAAG,CAAC,QAAQ,IAAI,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;QAE5D,OAAO,iCAAe,CAAC,SAAS,IAAI,IAAI,IAAI,gBAAgB;YAC1D,CAAC,CAAC,IAAA,cAAQ,EAAC,iCAAe,CAAC,SAAS,EAAE,IAAI,CAAC;YAC3C,CAAC,CAAC,IAAI,CAAC;IACX,CAAC;IAED,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,IAAA,gBAAU,EAAC,IAAI,EAAE,MAAM,CAAC,EAAE;gBACzC,kBAAkB;gBAClB,OAAO;aACR;YAED,iBAAiB;YACjB,EAAE,EAAE,cAAc,EAAE,CAAC;YACrB,IAAI,IAAA,YAAM,EAAC,IAAI,CAAC,EAAE;gBAChB,IAAA,uBAAS,EAAC,MAAM,EAAE,IAAI,CAAC,CAAC;aACzB;iBAAM,IAAI,IAAI,EAAE;gBACf,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACnB;QACH,CAAC,CAAC;IACJ,CAAC;AACH,CAAC;AApCD,0BAoCC"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
interface RouterOptions {
|
|
2
|
+
scroll?: boolean;
|
|
3
|
+
}
|
|
1
4
|
export interface Router {
|
|
2
5
|
pathname: string;
|
|
3
6
|
query: Record<string, string | string[] | undefined>;
|
|
4
7
|
href?: string;
|
|
5
8
|
basePath?: string;
|
|
6
|
-
push: (url: string) => void;
|
|
7
|
-
replace: (url: string) => void;
|
|
9
|
+
push: (url: string, as?: string, options?: RouterOptions) => void;
|
|
10
|
+
replace: (url: string, as?: string, options?: RouterOptions) => void;
|
|
8
11
|
}
|
|
9
12
|
export declare function useRouter(): Router;
|
|
10
13
|
export declare namespace useRouter {
|
|
11
14
|
var _impl: () => Router;
|
|
12
15
|
var setup: (impl: () => Router) => void;
|
|
13
16
|
}
|
|
17
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRouter.js","sourceRoot":"","sources":["../../src/hooks/useRouter.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"useRouter.js","sourceRoot":"","sources":["../../src/hooks/useRouter.ts"],"names":[],"mappings":";;AAaA,SAAgB,SAAS;IACvB,OAAO,SAAS,CAAC,KAAK,EAAE,CAAC;AAC3B,CAAC;AAFD,8BAEC;AAED,SAAS,CAAC,KAAK,GAAG,GAAW,EAAE,CAAC,CAAC;IAC/B,IAAI,EAAE,UAAU,CAAC,QAAQ,EAAE,IAAI,IAAI,GAAG;IACtC,QAAQ,EAAE,UAAU,CAAC,QAAQ,EAAE,QAAQ,IAAI,GAAG;IAC9C,KAAK,EAAE,EAAE;IACT,IAAI,EAAE,GAAG,EAAE;QACT,aAAa;IACf,CAAC;IACD,OAAO,EAAE,GAAG,EAAE;QACZ,aAAa;IACf,CAAC;CACF,CAAC,CAAC;AAEH,SAAS,CAAC,KAAK,GAAG,CAAC,IAAkB,EAAE,EAAE;IACvC,SAAS,CAAC,KAAK,GAAG,IAAI,CAAC;AACzB,CAAC,CAAC"}
|
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Router } from '../../hooks/useRouter';
|
|
2
2
|
import type { BlockDef } from '../../model/ContentPageDef';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export interface BlockIntersectionEvent {
|
|
7
|
-
block: BlockDef;
|
|
8
|
-
intersection: IntersectionObserverEntry;
|
|
9
|
-
}
|
|
10
|
-
interface EventMap {
|
|
11
|
-
goto: GotoAnchorEvent;
|
|
12
|
-
intersection: BlockIntersectionEvent;
|
|
13
|
-
}
|
|
14
|
-
export declare class BlockRouter {
|
|
15
|
-
static readonly inst: BlockRouter;
|
|
16
|
-
readonly eventBus: EventBus<EventMap>;
|
|
17
|
-
constructor();
|
|
18
|
-
goto(rawAnchor?: string): void;
|
|
19
|
-
push(rawAnchor: string): void;
|
|
20
|
-
replace(rawAnchor: string): void;
|
|
21
|
-
reset(): void;
|
|
22
|
-
}
|
|
23
|
-
export {};
|
|
3
|
+
export declare function gotoBlock(router: Router, anchor?: string): void;
|
|
4
|
+
export declare function trackBlock(router: Router, block?: BlockDef): void;
|
|
@@ -1,33 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class BlockRouter {
|
|
7
|
-
static inst = new BlockRouter();
|
|
8
|
-
eventBus = new EventBus_1.EventBus();
|
|
9
|
-
constructor() {
|
|
10
|
-
const anchor = normalizeAnchor(globalThis.location?.hash);
|
|
11
|
-
if (anchor) {
|
|
12
|
-
this.eventBus.subject('goto', { anchor });
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
goto(rawAnchor) {
|
|
16
|
-
const anchor = normalizeAnchor(rawAnchor);
|
|
17
|
-
if (anchor) {
|
|
18
|
-
this.push(anchor);
|
|
19
|
-
this.eventBus.fire('goto', { anchor });
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
push(rawAnchor) {
|
|
23
|
-
globalThis.history?.pushState(null, '', getURLWithAnchor(rawAnchor));
|
|
24
|
-
}
|
|
25
|
-
replace(rawAnchor) {
|
|
26
|
-
globalThis.history?.replaceState(null, '', getURLWithAnchor(rawAnchor));
|
|
27
|
-
}
|
|
28
|
-
reset() {
|
|
29
|
-
globalThis.history?.replaceState(null, '', getURLWithAnchor());
|
|
30
|
-
}
|
|
2
|
+
exports.trackBlock = exports.gotoBlock = void 0;
|
|
3
|
+
const normalizeAnchor = (anchor) => anchor?.replace('#', '') || '';
|
|
4
|
+
function gotoBlock(router, anchor) {
|
|
5
|
+
router.replace(`#${normalizeAnchor(anchor)}`);
|
|
31
6
|
}
|
|
32
|
-
exports.
|
|
7
|
+
exports.gotoBlock = gotoBlock;
|
|
8
|
+
function trackBlock(router, block) {
|
|
9
|
+
router.replace(`#${normalizeAnchor(block?.anchor)}`, undefined, {
|
|
10
|
+
scroll: false,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
exports.trackBlock = trackBlock;
|
|
33
14
|
//# sourceMappingURL=BlockRouter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockRouter.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/BlockRouter.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"BlockRouter.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/BlockRouter.ts"],"names":[],"mappings":";;AAGA,MAAM,eAAe,GAAG,CAAC,MAAe,EAAE,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC;AAE5E,SAAgB,SAAS,CAAC,MAAc,EAAE,MAAe;IACvD,MAAM,CAAC,OAAO,CAAC,IAAI,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAChD,CAAC;AAFD,8BAEC;AAED,SAAgB,UAAU,CAAC,MAAc,EAAE,KAAgB;IACzD,MAAM,CAAC,OAAO,CAAC,IAAI,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE;QAC9D,MAAM,EAAE,KAAK;KACd,CAAC,CAAC;AACL,CAAC;AAJD,gCAIC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EventBus } from '../../EventBus/EventBus';
|
|
2
|
+
import type { BlockDef } from '../../model/ContentPageDef';
|
|
3
|
+
export interface BlockIntersectionEvent {
|
|
4
|
+
block: BlockDef;
|
|
5
|
+
intersection: IntersectionObserverEntry;
|
|
6
|
+
}
|
|
7
|
+
interface EventMap {
|
|
8
|
+
intersection: BlockIntersectionEvent;
|
|
9
|
+
}
|
|
10
|
+
export declare const blockRouterEventBus: EventBus<EventMap>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blockRouterEventBus.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/blockRouterEventBus.ts"],"names":[],"mappings":";;AAAA,sDAAmD;AAYtC,QAAA,mBAAmB,GAAG,IAAI,mBAAQ,EAAY,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { BlockDef } from '../../model/ContentPageDef';
|
|
2
|
-
|
|
3
|
-
export declare function useBlockIntersectionObserver(block?: BlockDef, router?: BlockRouter): {
|
|
2
|
+
export declare function useBlockIntersectionObserver(block?: BlockDef): {
|
|
4
3
|
current: Element | null;
|
|
5
4
|
};
|
|
@@ -2,27 +2,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
2
2
|
exports.useBlockIntersectionObserver = void 0;
|
|
3
3
|
const hooks_1 = require("@redneckz/uni-jsx/lib/hooks");
|
|
4
4
|
const useIntersectionObserver_1 = require("../../hooks/useIntersectionObserver");
|
|
5
|
-
const
|
|
6
|
-
function useBlockIntersectionObserver(block
|
|
5
|
+
const blockRouterEventBus_1 = require("./blockRouterEventBus");
|
|
6
|
+
function useBlockIntersectionObserver(block) {
|
|
7
7
|
const observerCallback = (0, hooks_1.useCallback)((entries) => {
|
|
8
8
|
if (!block || !entries?.length) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
11
|
const intersection = entries[entries.length - 1];
|
|
12
|
-
|
|
13
|
-
}, [block
|
|
14
|
-
|
|
15
|
-
(0, hooks_1.useEffect)(() => {
|
|
16
|
-
if (!ref.current) {
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
return router.eventBus.subscribe('goto', ({ anchor }) => {
|
|
20
|
-
if (ref.current && block?.anchor === anchor) {
|
|
21
|
-
ref.current.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}, [block, router]);
|
|
25
|
-
return ref;
|
|
12
|
+
blockRouterEventBus_1.blockRouterEventBus.fire('intersection', { block, intersection });
|
|
13
|
+
}, [block]);
|
|
14
|
+
return (0, useIntersectionObserver_1.useIntersectionObserver)(observerCallback, { sensitivity: 1 });
|
|
26
15
|
}
|
|
27
16
|
exports.useBlockIntersectionObserver = useBlockIntersectionObserver;
|
|
28
17
|
//# sourceMappingURL=useBlockIntersectionObserver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBlockIntersectionObserver.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/useBlockIntersectionObserver.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"useBlockIntersectionObserver.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/useBlockIntersectionObserver.ts"],"names":[],"mappings":";;AAAA,uDAA0D;AAC1D,iFAA8E;AAE9E,+DAA4D;AAE5D,SAAgB,4BAA4B,CAAC,KAAgB;IAC3D,MAAM,gBAAgB,GAAG,IAAA,mBAAW,EAClC,CAAC,OAAoC,EAAE,EAAE;QACvC,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE;YAC9B,OAAO;SACR;QAED,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjD,yCAAmB,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;IACpE,CAAC,EACD,CAAC,KAAK,CAAC,CACR,CAAC;IAEF,OAAO,IAAA,iDAAuB,EAAC,gBAAgB,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,CAAC;AACvE,CAAC;AAdD,oEAcC"}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function useBlockRouterProvider(router?: BlockRouter, scrollTarget?: EventTarget): void;
|
|
1
|
+
export declare function useBlockRouterProvider(scrollTarget?: EventTarget): void;
|
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
2
|
exports.useBlockRouterProvider = void 0;
|
|
3
3
|
const hooks_1 = require("@redneckz/uni-jsx/lib/hooks");
|
|
4
|
+
const useRouter_1 = require("../../hooks/useRouter");
|
|
4
5
|
const debounce_1 = require("../../utils/debounce");
|
|
5
6
|
const BlockRouter_1 = require("./BlockRouter");
|
|
7
|
+
const blockRouterEventBus_1 = require("./blockRouterEventBus");
|
|
6
8
|
const findActiveBlock_1 = require("./findActiveBlock");
|
|
7
9
|
const isScrolledEnough = () => globalThis.scrollY > (globalThis.innerHeight * 3) / 4;
|
|
8
|
-
function useBlockRouterProvider(
|
|
10
|
+
function useBlockRouterProvider(scrollTarget = globalThis) {
|
|
11
|
+
const router = (0, useRouter_1.useRouter)();
|
|
9
12
|
const intersectionsMapRef = (0, hooks_1.useRef)(new Map());
|
|
10
|
-
(0, hooks_1.useEffect)(() =>
|
|
13
|
+
(0, hooks_1.useEffect)(() => blockRouterEventBus_1.blockRouterEventBus.subscribe('intersection', ({ block, intersection }) => {
|
|
11
14
|
if (intersectionsMapRef.current) {
|
|
12
15
|
intersectionsMapRef.current.set(block, intersection);
|
|
13
16
|
}
|
|
14
|
-
}), [
|
|
17
|
+
}), []);
|
|
15
18
|
(0, hooks_1.useEffect)(() => {
|
|
16
19
|
const handleScroll = (0, debounce_1.debounce)(() => {
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
if (isScrolledEnough()) {
|
|
21
|
+
const activeBlock = (0, findActiveBlock_1.findActiveBlock)([...(intersectionsMapRef.current || [])]);
|
|
22
|
+
(0, BlockRouter_1.trackBlock)(router, activeBlock);
|
|
20
23
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
router.replace(activeBlock.anchor);
|
|
24
|
-
}
|
|
25
|
-
else if (!activeBlock) {
|
|
26
|
-
router.reset();
|
|
24
|
+
else {
|
|
25
|
+
(0, BlockRouter_1.trackBlock)(router);
|
|
27
26
|
}
|
|
28
27
|
}, 100);
|
|
29
28
|
scrollTarget.addEventListener('scroll', handleScroll);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBlockRouterProvider.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/useBlockRouterProvider.ts"],"names":[],"mappings":";;AAAA,uDAAgE;
|
|
1
|
+
{"version":3,"file":"useBlockRouterProvider.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/useBlockRouterProvider.ts"],"names":[],"mappings":";;AAAA,uDAAgE;AAChE,qDAAkD;AAElD,mDAAgD;AAChD,+CAA2C;AAC3C,+DAA4D;AAC5D,uDAAoD;AAEpD,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,UAAU,CAAC,WAAW,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AAErF,SAAgB,sBAAsB,CAAC,eAA4B,UAAU;IAC3E,MAAM,MAAM,GAAG,IAAA,qBAAS,GAAE,CAAC;IAE3B,MAAM,mBAAmB,GAAG,IAAA,cAAM,EAA2C,IAAI,GAAG,EAAE,CAAC,CAAC;IAExF,IAAA,iBAAS,EACP,GAAG,EAAE,CACH,yCAAmB,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE;QACxE,IAAI,mBAAmB,CAAC,OAAO,EAAE;YAC/B,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;SACtD;IACH,CAAC,CAAC,EACJ,EAAE,CACH,CAAC;IAEF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,YAAY,GAAG,IAAA,mBAAQ,EAAC,GAAG,EAAE;YACjC,IAAI,gBAAgB,EAAE,EAAE;gBACtB,MAAM,WAAW,GAAG,IAAA,iCAAe,EAAC,CAAC,GAAG,CAAC,mBAAmB,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;gBAC9E,IAAA,wBAAU,EAAC,MAAM,EAAE,WAAW,CAAC,CAAC;aACjC;iBAAM;gBACL,IAAA,wBAAU,EAAC,MAAM,CAAC,CAAC;aACpB;QACH,CAAC,EAAE,GAAG,CAAC,CAAC;QAER,YAAY,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAEtD,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,OAAO,EAAE,CAAC;YACvB,YAAY,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAC3D,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;AAC7B,CAAC;AAhCD,wDAgCC"}
|
|
@@ -3,7 +3,7 @@ exports.BlockWrapper = exports.blockStyles = void 0;
|
|
|
3
3
|
const jsx_runtime_1 = require("@redneckz/uni-jsx/jsx-runtime");
|
|
4
4
|
const uni_jsx_1 = require("@redneckz/uni-jsx");
|
|
5
5
|
const hooks_1 = require("@redneckz/uni-jsx/lib/hooks");
|
|
6
|
-
const
|
|
6
|
+
const defaultEventBus_1 = require("../EventBus/defaultEventBus");
|
|
7
7
|
const useBlockIntersectionObserver_1 = require("../services/BlockRouter/useBlockIntersectionObserver");
|
|
8
8
|
const style_1 = require("../utils/style");
|
|
9
9
|
exports.blockStyles = {
|
|
@@ -17,7 +17,7 @@ exports.BlockWrapper = (0, uni_jsx_1.JSX)(({ className = '', version = 'primary'
|
|
|
17
17
|
const Tag = tag;
|
|
18
18
|
const ref = (0, useBlockIntersectionObserver_1.useBlockIntersectionObserver)(block);
|
|
19
19
|
const [isVisible, setVisible] = (0, hooks_1.useState)(true);
|
|
20
|
-
(0, hooks_1.useEffect)(() =>
|
|
20
|
+
(0, hooks_1.useEffect)(() => defaultEventBus_1.defaultEventBus.subscribe('tab', (event) => {
|
|
21
21
|
if (event.type === 'group') {
|
|
22
22
|
const hasSettings = block?.labels?.length || block?.anchor;
|
|
23
23
|
setVisible(event.label ? !hasSettings || Boolean(block?.labels?.includes(event.label)) : true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockWrapper.js","sourceRoot":"","sources":["../../src/ui-kit/BlockWrapper.tsx"],"names":[],"mappings":";;;AAAA,+CAAwC;AACxC,uDAAkE;AAClE,
|
|
1
|
+
{"version":3,"file":"BlockWrapper.js","sourceRoot":"","sources":["../../src/ui-kit/BlockWrapper.tsx"],"names":[],"mappings":";;;AAAA,+CAAwC;AACxC,uDAAkE;AAClE,iEAA8D;AAG9D,uGAAoG;AACpG,0CAAuC;AAO1B,QAAA,WAAW,GAAiC;IACvD,OAAO,EAAE,4BAA4B;IACrC,SAAS,EAAE,4BAA4B;IACvC,IAAI,EAAE,mCAAmC;IACzC,WAAW,EAAE,kCAAkC;IAC/C,EAAE,EAAE,EAAE;CACP,CAAC;AAEW,QAAA,YAAY,GAAG,IAAA,aAAG,EAC7B,CAAC,EAAE,SAAS,GAAG,EAAE,EAAE,OAAO,GAAG,SAAS,EAAE,KAAK,EAAE,GAAG,GAAG,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;IAClF,MAAM,GAAG,GAAQ,GAAG,CAAC;IAErB,MAAM,GAAG,GAAG,IAAA,2DAA4B,EAAC,KAAK,CAAC,CAAC;IAEhD,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC;IAC/C,IAAA,iBAAS,EACP,GAAG,EAAE,CACH,iCAAe,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;QACzC,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE;YAC1B,MAAM,WAAW,GAAG,KAAK,EAAE,MAAM,EAAE,MAAM,IAAI,KAAK,EAAE,MAAM,CAAC;YAC3D,UAAU,CACR,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CACnF,CAAC;SACH;aAAM;YACL,UAAU,CAAC,IAAI,CAAC,CAAC;SAClB;IACH,CAAC,CAAC,EACJ,CAAC,KAAK,CAAC,CACR,CAAC;IAEF,OAAO,SAAS,CAAC,CAAC,CAAC,CACjB,uBAAC,GAAG,IACF,SAAS,EAAE,IAAA,aAAK,EAAC,OAAO,EAAE,mBAAW,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,KACtD,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KACxC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EACpD,IAAI,EAAE,IAAI,YAET,QAAQ,GACL,CACP,CAAC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CACF,CAAC"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare type BaseEventMap = Record<string, any>;
|
|
3
|
-
export declare class EventBus<EM extends BaseEventMap> {
|
|
4
|
-
static readonly inst: EventBus<EventMap>;
|
|
1
|
+
export declare class EventBus<EM extends Record<string, any>> {
|
|
5
2
|
private subscribers;
|
|
6
3
|
private subjectsStateMap;
|
|
7
4
|
subscribe<K extends keyof EM>(type: K, listener: (event: EM[K]) => void): () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventBus.js","sourceRoot":"","sources":["../../src/EventBus/EventBus.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EventBus.js","sourceRoot":"","sources":["../../src/EventBus/EventBus.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,QAAQ;IACX,WAAW,GAAiE,EAAE,CAAC;IAC/E,gBAAgB,GAAgB,EAAE,CAAC;IAE3C,SAAS,CAAqB,IAAO,EAAE,QAAgC;QACrE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAC5D,QAAsC,CACvC,CAAC;QAEF,MAAM,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAChD,IAAI,WAAW,EAAE;YACf,QAAQ,CAAC,WAAoB,CAAC,CAAC;SAChC;QAED,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACnC,CAAC,CAAC;IACJ,CAAC;IAEO,WAAW,CAAqB,IAAO,EAAE,QAAgC;QAC/E,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC;IACjF,CAAC;IAED,IAAI,CAAqB,IAAO,EAAE,KAAY;QAC5C,MAAM,iBAAiB,GAAG,IAAI,IAAI,IAAI,CAAC,gBAAgB,CAAC;QACxD,IAAI,iBAAiB,EAAE;YACrB,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;SACrC;QAED,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,CAAqB,IAAO,EAAE,KAAY;QAC/C,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IACtC,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultEventBus.js","sourceRoot":"","sources":["../../src/EventBus/defaultEventBus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAMtC,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,QAAQ,EAAkB,CAAC"}
|
|
@@ -2,5 +2,6 @@ import { jsx as _jsx } from "@redneckz/uni-jsx/jsx-runtime";
|
|
|
2
2
|
import { JSX } from '@redneckz/uni-jsx';
|
|
3
3
|
import { BlockWrapper } from '../../ui-kit/BlockWrapper.js';
|
|
4
4
|
import { renderButtonsSection } from '../../ui-kit/Button/renderButtonsSection.js';
|
|
5
|
-
|
|
5
|
+
import { style } from '../../utils/style.js';
|
|
6
|
+
export const ButtonBlock = JSX(({ button, className, ...rest }) => (_jsx(BlockWrapper, { className: style('!bg-transparent', className), ...rest, children: renderButtonsSection([button]) })));
|
|
6
7
|
//# sourceMappingURL=ButtonBlock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBlock.js","sourceRoot":"","sources":["../../../src/components/ButtonBlock/ButtonBlock.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"ButtonBlock.js","sourceRoot":"","sources":["../../../src/components/ButtonBlock/ButtonBlock.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAK1C,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAmB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC,CACnF,KAAC,YAAY,IAAC,SAAS,EAAE,KAAK,CAAC,iBAAiB,EAAE,SAAS,CAAC,KAAM,IAAI,YACnE,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC,GAClB,CAChB,CAAC,CAAC"}
|
|
@@ -3,6 +3,10 @@ import type { ButtonWithIconProps } from '../../ui-kit/Button/ButtonProps';
|
|
|
3
3
|
* @title Блок Кнопка
|
|
4
4
|
*/
|
|
5
5
|
export interface ButtonBlockContent {
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* @title Кнопка
|
|
8
|
+
* @default {"icon": {"format": "webp", "size": { "width": 24, "height": 24 }},
|
|
9
|
+
* "iconRight": {"format": "webp", "size": { "width": 24, "height": 24 }}}
|
|
10
|
+
*/
|
|
7
11
|
button?: ButtonWithIconProps;
|
|
8
12
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@redneckz/uni-jsx/jsx-runtime";
|
|
2
2
|
import { JSX } from '@redneckz/uni-jsx';
|
|
3
3
|
import { useCallback, useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
4
|
-
import {
|
|
4
|
+
import { defaultEventBus } from '../../EventBus/defaultEventBus.js';
|
|
5
5
|
import { BlockWrapper } from '../../ui-kit/BlockWrapper.js';
|
|
6
6
|
import { renderTab } from './renderTab.js';
|
|
7
7
|
import { ScrollableTabs } from './ScrollableTabs.js';
|
|
8
8
|
export const Tabs = JSX((props) => {
|
|
9
9
|
const { className = '', tabs, showCounter, isSticky, tabsMode, ...rest } = props;
|
|
10
10
|
const [currentTab, setCurrentTab] = useState(tabs ? tabs[0] : undefined);
|
|
11
|
-
useEffect(() =>
|
|
11
|
+
useEffect(() => defaultEventBus.subscribe('tab', (event) => {
|
|
12
12
|
const tab = tabs?.find(checkTab(event));
|
|
13
13
|
if (event.type === 'link' && tab) {
|
|
14
14
|
setCurrentTab(tab);
|
|
@@ -16,11 +16,11 @@ export const Tabs = JSX((props) => {
|
|
|
16
16
|
return [];
|
|
17
17
|
}), [tabs]);
|
|
18
18
|
useEffect(() => currentTab?.type === 'group'
|
|
19
|
-
?
|
|
19
|
+
? defaultEventBus.subject('tab', { type: currentTab.type, label: currentTab.ref })
|
|
20
20
|
: undefined, [currentTab]);
|
|
21
21
|
const handleClick = useCallback((selectedTab) => {
|
|
22
22
|
if (selectedTab?.type === 'group') {
|
|
23
|
-
|
|
23
|
+
defaultEventBus.fire('tab', { type: selectedTab.type, label: selectedTab.ref });
|
|
24
24
|
}
|
|
25
25
|
setCurrentTab(selectedTab);
|
|
26
26
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../../src/components/Tabs/Tabs.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../../src/components/Tabs/Tabs.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAUlD,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,CAAiB,CAAC,KAAK,EAAE,EAAE;IAChD,MAAM,EAAE,SAAS,GAAG,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAEjF,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAEzE,SAAS,CACP,GAAG,EAAE,CACH,eAAe,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;QACzC,MAAM,GAAG,GAAG,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;QACxC,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,GAAG,EAAE;YAChC,aAAa,CAAC,GAAG,CAAC,CAAC;SACpB;QAED,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,EACJ,CAAC,IAAI,CAAC,CACP,CAAC;IAEF,SAAS,CACP,GAAG,EAAE,CACH,UAAU,EAAE,IAAI,KAAK,OAAO;QAC1B,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC;QAClF,CAAC,CAAC,SAAS,EACf,CAAC,UAAU,CAAC,CACb,CAAC;IAEF,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,WAAoB,EAAE,EAAE;QACvD,IAAI,WAAW,EAAE,IAAI,KAAK,OAAO,EAAE;YACjC,eAAe,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC;SACjF;QACD,aAAa,CAAC,WAAW,CAAC,CAAC;IAC7B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,KAAC,YAAY,IACX,SAAS,EAAE,2CACT,QAAQ,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EACpC,IAAI,SAAS,EAAE,EACf,IAAI,EAAC,SAAS,KACV,IAAI,YAEP,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,CAC3B,KAAC,cAAc,IACb,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,KACpB,IAAI,GACR,CACH,CAAC,CAAC,CAAC,CACF,IAAI,EAAE,GAAG,CACP,SAAS,CAAC;YACR,OAAO,EAAE,WAAW;YACpB,UAAU;YACV,WAAW;YACX,GAAG,IAAI;SACR,CAAC,CACH,CACF,GACY,CAChB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,QAAQ,GAAG,CAAC,KAAyB,EAAE,EAAE,CAAC,CAAC,CAAU,EAAE,EAAE,CAC7D,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { projectSettings } from '../ProjectSettings.js';
|
|
2
|
-
import {
|
|
2
|
+
import { gotoBlock } from '../services/BlockRouter/BlockRouter.js';
|
|
3
3
|
import { isHash, isLocalURL, joinPath } from '../utils/url.js';
|
|
4
4
|
import { handlerDecorator } from './handlerDecorator.js';
|
|
5
5
|
import { useRouter } from './useRouter.js';
|
|
6
6
|
export function useLink(isRemote) {
|
|
7
7
|
const router = useRouter();
|
|
8
|
-
const blockRouter = useBlockRouter();
|
|
9
8
|
return (props) => ({
|
|
10
9
|
...props,
|
|
11
10
|
href: adjustHref(props.href),
|
|
@@ -28,7 +27,7 @@ export function useLink(isRemote) {
|
|
|
28
27
|
// Client routing
|
|
29
28
|
ev?.preventDefault();
|
|
30
29
|
if (isHash(href)) {
|
|
31
|
-
|
|
30
|
+
gotoBlock(router, href);
|
|
32
31
|
}
|
|
33
32
|
else if (href) {
|
|
34
33
|
router.push(href);
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC5D,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;IAE3B,OAAO,CAA2C,KAAQ,EAAiB,EAAE,CAAC,CAAC;QAC7E,GAAG,KAAK;QACR,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC;QAC5B,YAAY,EAAE,KAAK,CAAC,IAAI;QACxB,OAAO,EAAE,gBAAgB,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;KACpD,CAAC,CAAC;IAEH,SAAS,UAAU,CAAC,IAAwB;QAC1C,MAAM,gBAAgB,GAAG,CAAC,QAAQ,IAAI,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;QAE5D,OAAO,eAAe,CAAC,SAAS,IAAI,IAAI,IAAI,gBAAgB;YAC1D,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,SAAS,EAAE,IAAI,CAAC;YAC3C,CAAC,CAAC,IAAI,CAAC;IACX,CAAC;IAED,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,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;aACzB;iBAAM,IAAI,IAAI,EAAE;gBACf,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACnB;QACH,CAAC,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
interface RouterOptions {
|
|
2
|
+
scroll?: boolean;
|
|
3
|
+
}
|
|
1
4
|
export interface Router {
|
|
2
5
|
pathname: string;
|
|
3
6
|
query: Record<string, string | string[] | undefined>;
|
|
4
7
|
href?: string;
|
|
5
8
|
basePath?: string;
|
|
6
|
-
push: (url: string) => void;
|
|
7
|
-
replace: (url: string) => void;
|
|
9
|
+
push: (url: string, as?: string, options?: RouterOptions) => void;
|
|
10
|
+
replace: (url: string, as?: string, options?: RouterOptions) => void;
|
|
8
11
|
}
|
|
9
12
|
export declare function useRouter(): Router;
|
|
10
13
|
export declare namespace useRouter {
|
|
11
14
|
var _impl: () => Router;
|
|
12
15
|
var setup: (impl: () => Router) => void;
|
|
13
16
|
}
|
|
17
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRouter.js","sourceRoot":"","sources":["../../src/hooks/useRouter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useRouter.js","sourceRoot":"","sources":["../../src/hooks/useRouter.ts"],"names":[],"mappings":"AAaA,MAAM,UAAU,SAAS;IACvB,OAAO,SAAS,CAAC,KAAK,EAAE,CAAC;AAC3B,CAAC;AAED,SAAS,CAAC,KAAK,GAAG,GAAW,EAAE,CAAC,CAAC;IAC/B,IAAI,EAAE,UAAU,CAAC,QAAQ,EAAE,IAAI,IAAI,GAAG;IACtC,QAAQ,EAAE,UAAU,CAAC,QAAQ,EAAE,QAAQ,IAAI,GAAG;IAC9C,KAAK,EAAE,EAAE;IACT,IAAI,EAAE,GAAG,EAAE;QACT,aAAa;IACf,CAAC;IACD,OAAO,EAAE,GAAG,EAAE;QACZ,aAAa;IACf,CAAC;CACF,CAAC,CAAC;AAEH,SAAS,CAAC,KAAK,GAAG,CAAC,IAAkB,EAAE,EAAE;IACvC,SAAS,CAAC,KAAK,GAAG,IAAI,CAAC;AACzB,CAAC,CAAC"}
|
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Router } from '../../hooks/useRouter';
|
|
2
2
|
import type { BlockDef } from '../../model/ContentPageDef';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export interface BlockIntersectionEvent {
|
|
7
|
-
block: BlockDef;
|
|
8
|
-
intersection: IntersectionObserverEntry;
|
|
9
|
-
}
|
|
10
|
-
interface EventMap {
|
|
11
|
-
goto: GotoAnchorEvent;
|
|
12
|
-
intersection: BlockIntersectionEvent;
|
|
13
|
-
}
|
|
14
|
-
export declare class BlockRouter {
|
|
15
|
-
static readonly inst: BlockRouter;
|
|
16
|
-
readonly eventBus: EventBus<EventMap>;
|
|
17
|
-
constructor();
|
|
18
|
-
goto(rawAnchor?: string): void;
|
|
19
|
-
push(rawAnchor: string): void;
|
|
20
|
-
replace(rawAnchor: string): void;
|
|
21
|
-
reset(): void;
|
|
22
|
-
}
|
|
23
|
-
export {};
|
|
3
|
+
export declare function gotoBlock(router: Router, anchor?: string): void;
|
|
4
|
+
export declare function trackBlock(router: Router, block?: BlockDef): void;
|
|
@@ -1,30 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (anchor) {
|
|
10
|
-
this.eventBus.subject('goto', { anchor });
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
goto(rawAnchor) {
|
|
14
|
-
const anchor = normalizeAnchor(rawAnchor);
|
|
15
|
-
if (anchor) {
|
|
16
|
-
this.push(anchor);
|
|
17
|
-
this.eventBus.fire('goto', { anchor });
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
push(rawAnchor) {
|
|
21
|
-
globalThis.history?.pushState(null, '', getURLWithAnchor(rawAnchor));
|
|
22
|
-
}
|
|
23
|
-
replace(rawAnchor) {
|
|
24
|
-
globalThis.history?.replaceState(null, '', getURLWithAnchor(rawAnchor));
|
|
25
|
-
}
|
|
26
|
-
reset() {
|
|
27
|
-
globalThis.history?.replaceState(null, '', getURLWithAnchor());
|
|
28
|
-
}
|
|
1
|
+
const normalizeAnchor = (anchor) => anchor?.replace('#', '') || '';
|
|
2
|
+
export function gotoBlock(router, anchor) {
|
|
3
|
+
router.replace(`#${normalizeAnchor(anchor)}`);
|
|
4
|
+
}
|
|
5
|
+
export function trackBlock(router, block) {
|
|
6
|
+
router.replace(`#${normalizeAnchor(block?.anchor)}`, undefined, {
|
|
7
|
+
scroll: false,
|
|
8
|
+
});
|
|
29
9
|
}
|
|
30
10
|
//# sourceMappingURL=BlockRouter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockRouter.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/BlockRouter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BlockRouter.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/BlockRouter.ts"],"names":[],"mappings":"AAGA,MAAM,eAAe,GAAG,CAAC,MAAe,EAAE,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC;AAE5E,MAAM,UAAU,SAAS,CAAC,MAAc,EAAE,MAAe;IACvD,MAAM,CAAC,OAAO,CAAC,IAAI,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAc,EAAE,KAAgB;IACzD,MAAM,CAAC,OAAO,CAAC,IAAI,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE;QAC9D,MAAM,EAAE,KAAK;KACd,CAAC,CAAC;AACL,CAAC"}
|