@domql/router 2.3.63 → 2.3.69

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/router",
3
- "version": "2.3.63",
3
+ "version": "2.3.69",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "dist/esm/index.js",
@@ -18,12 +18,11 @@
18
18
  "build:esm": "npx esbuild *.js --target=es2020 --format=esm --outdir=dist/esm",
19
19
  "build:cjs": "npx esbuild *.js --target=node16 --format=cjs --outdir=dist/cjs",
20
20
  "build:iife": "npx esbuild *.js --target=node16 --format=iife --outdir=dist/iife",
21
- "build": "yarn build:esm && yarn build:cjs && yarn build:iife",
22
- "postinstall": "yarn build",
21
+ "build": "yarn build:cjs",
23
22
  "prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
24
23
  },
25
24
  "dependencies": {
26
25
  "@domql/utils": "latest"
27
26
  },
28
- "gitHead": "285ed7de47df088045ea478552edc99c5bc77c16"
27
+ "gitHead": "7b43df6cfdae920a1602749f2cf29a9b44a40000"
29
28
  }
package/dist/esm/index.js DELETED
@@ -1,43 +0,0 @@
1
- import { window } from "@domql/globals";
2
- import { merge } from "@domql/utils";
3
- const getActiveRoute = (route = window.location.pathname, level) => `/${route.split("/")[level + 1]}`;
4
- let lastLevel = 0;
5
- const defaultOptions = {
6
- level: lastLevel,
7
- pushState: true,
8
- scrollToTop: true,
9
- scrollToNode: false,
10
- useFragment: false,
11
- updateState: true
12
- };
13
- const router = (element, path, state = {}, options = defaultOptions) => {
14
- merge(options, defaultOptions);
15
- lastLevel = options.lastLevel;
16
- const [pathname, hash] = path.split("#");
17
- const route = getActiveRoute(pathname, options.level);
18
- const content = element.routes[route] || element.routes["/*"];
19
- if (content) {
20
- if (options.pushState)
21
- window.history.pushState(state, null, pathname + (hash ? `#${hash}` : ""));
22
- element.set({ tag: options.useFragment && "fragment", extend: content });
23
- if (options.updateState)
24
- element.state.update({ route, hash });
25
- const rootNode = element.node;
26
- if (options.scrollToTop)
27
- rootNode.scrollTo({ behavior: "smooth", top: 0, left: 0 });
28
- if (options.scrollToNode)
29
- content.content.node.scrollTo({ behavior: "smooth", top: 0, left: 0 });
30
- if (hash) {
31
- const activeNode = document.getElementById(hash);
32
- if (activeNode) {
33
- const top = activeNode.getBoundingClientRect().top + rootNode.scrollToTopp - 140;
34
- rootNode.scrollTo({ behavior: "smooth", top, left: 0 });
35
- }
36
- }
37
- }
38
- };
39
- export {
40
- getActiveRoute,
41
- lastLevel,
42
- router
43
- };
@@ -1,41 +0,0 @@
1
- "use strict";
2
- (() => {
3
- var import_globals = require("@domql/globals");
4
- var import_utils = require("@domql/utils");
5
- const getActiveRoute = (route = import_globals.window.location.pathname, level) => `/${route.split("/")[level + 1]}`;
6
- let lastLevel = 0;
7
- const defaultOptions = {
8
- level: lastLevel,
9
- pushState: true,
10
- scrollToTop: true,
11
- scrollToNode: false,
12
- useFragment: false,
13
- updateState: true
14
- };
15
- const router = (element, path, state = {}, options = defaultOptions) => {
16
- (0, import_utils.merge)(options, defaultOptions);
17
- lastLevel = options.lastLevel;
18
- const [pathname, hash] = path.split("#");
19
- const route = getActiveRoute(pathname, options.level);
20
- const content = element.routes[route] || element.routes["/*"];
21
- if (content) {
22
- if (options.pushState)
23
- import_globals.window.history.pushState(state, null, pathname + (hash ? `#${hash}` : ""));
24
- element.set({ tag: options.useFragment && "fragment", extend: content });
25
- if (options.updateState)
26
- element.state.update({ route, hash });
27
- const rootNode = element.node;
28
- if (options.scrollToTop)
29
- rootNode.scrollTo({ behavior: "smooth", top: 0, left: 0 });
30
- if (options.scrollToNode)
31
- content.content.node.scrollTo({ behavior: "smooth", top: 0, left: 0 });
32
- if (hash) {
33
- const activeNode = document.getElementById(hash);
34
- if (activeNode) {
35
- const top = activeNode.getBoundingClientRect().top + rootNode.scrollToTopp - 140;
36
- rootNode.scrollTo({ behavior: "smooth", top, left: 0 });
37
- }
38
- }
39
- }
40
- };
41
- })();