@axos-web-dev/shared-components 1.0.77-patch.61 → 1.0.77-patch.63

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.
@@ -1,8 +1,12 @@
1
1
  const appendQueryParams = () => {
2
- const searchParams = new URLSearchParams(window.location.search);
3
- const filterParams = (href) => {
2
+ const currentOrigin = window.location.origin;
3
+ const currentPathname = window.location.pathname;
4
+ const filterParams = (href, currentSearch) => {
4
5
  try {
5
- const url = new URL(href, window.location.origin);
6
+ const search = currentSearch ?? window.location.search;
7
+ const searchParams = new URLSearchParams(search);
8
+ const base = window.location.origin + window.location.pathname + window.location.search;
9
+ const url = new URL(href, base);
6
10
  const existingParams = new URLSearchParams(url.search);
7
11
  const newParams = new URLSearchParams();
8
12
  const addedKeys = /* @__PURE__ */ new Set();
@@ -25,17 +29,44 @@ const appendQueryParams = () => {
25
29
  }
26
30
  const mergedParams = new URLSearchParams(existingParams);
27
31
  newParams.forEach((value, key) => mergedParams.append(key, value));
28
- return `${url.origin}${url.pathname}?${mergedParams.toString()}`;
32
+ return `${url.origin}${url.pathname}?${mergedParams.toString()}${url.hash}`;
29
33
  } catch (e) {
30
34
  console.error(e);
31
35
  return href;
32
36
  }
33
37
  };
38
+ const handleSamePageClick = (e) => {
39
+ const anchor = e.target?.closest?.("a[href]");
40
+ if (!anchor || anchor.classList.contains("ext-link"))
41
+ return;
42
+ const href = anchor.getAttribute("href")?.trim();
43
+ if (!href || href.startsWith("tel:") || href.startsWith("mailto:") || href === "#" || href === "" || href.startsWith("#"))
44
+ return;
45
+ const base = window.location.origin + window.location.pathname + window.location.search;
46
+ const url = new URL(href, base);
47
+ if (url.origin !== currentOrigin || url.pathname !== currentPathname)
48
+ return;
49
+ e.preventDefault();
50
+ e.stopImmediatePropagation();
51
+ const merged = filterParams(href, window.location.search);
52
+ const mergedUrl = new URL(merged, window.location.origin);
53
+ const fullUrl = `${mergedUrl.pathname}${mergedUrl.search}${mergedUrl.hash}`;
54
+ window.history.replaceState({ ...window.history.state }, "", fullUrl);
55
+ window.dispatchEvent(
56
+ new PopStateEvent("popstate", { state: window.history.state })
57
+ );
58
+ if (mergedUrl.hash) {
59
+ const el = document.querySelector(mergedUrl.hash);
60
+ el?.scrollIntoView({ behavior: "smooth" });
61
+ }
62
+ };
63
+ document.addEventListener("click", handleSamePageClick, true);
34
64
  if (window.location.search.length) {
65
+ const searchParams = new URLSearchParams(window.location.search);
35
66
  document.querySelectorAll("a[href]:not(.ext-link)").forEach((anchor) => {
36
67
  const href = anchor.getAttribute("href")?.trim();
37
68
  if (href && !href.startsWith("tel:") && !href.startsWith("mailto:") && href !== "#" && href !== "" && !href.startsWith("#")) {
38
- anchor.href = filterParams(href);
69
+ anchor.href = filterParams(href, searchParams.toString());
39
70
  }
40
71
  });
41
72
  }
@@ -8,12 +8,10 @@ const shortUrl = (url) => {
8
8
  return uri.hostname;
9
9
  };
10
10
  const isEmailLink = (url) => {
11
- const uri = new URL(url, location.href);
12
- return uri.protocol == "mailto:";
11
+ return typeof url === "string" && url.trim().toLowerCase().startsWith("mailto:");
13
12
  };
14
13
  const isPhoneLink = (url) => {
15
- const uri = new URL(url, location.href);
16
- return uri.protocol === "tel:";
14
+ return typeof url === "string" && url.trim().toLowerCase().startsWith("tel:");
17
15
  };
18
16
  const validateLink = (url) => {
19
17
  let openModal = false;
package/package.json CHANGED
@@ -1,135 +1,135 @@
1
- {
2
- "name": "@axos-web-dev/shared-components",
3
- "description": "Axos shared components library for web.",
4
- "version": "1.0.77-patch.61",
5
- "type": "module",
6
- "module": "dist/main.js",
7
- "types": "dist/main.d.ts",
8
- "files": [
9
- "dist"
10
- ],
11
- "sideEffects": [
12
- "dist/assets/**/*.css"
13
- ],
14
- "scripts": {
15
- "dev": "vite",
16
- "build": "tsc --p ./tsconfig.build.json && vite build",
17
- "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
18
- "preview": "vite preview",
19
- "prepublishOnly": "npm run build",
20
- "check-types": "tsc --pretty --noEmit",
21
- "check-format": "prettier --check .",
22
- "check-lint": "eslint . --ext ts --ext tsx --ext js",
23
- "format": "prettier --write .",
24
- "test-all": "npm run check-format && npm run check-lint && npm run check-types && npm run build",
25
- "prepare": "husky",
26
- "storybook": "storybook dev -p 6006",
27
- "build-storybook": "storybook build",
28
- "npm:link": "npm run build && npm link"
29
- },
30
- "dependencies": {
31
- "@headlessui/react": "^2.2.0",
32
- "@hookform/resolvers": "^3.10.0",
33
- "@next-safe-action/adapter-react-hook-form": "^2.0.0",
34
- "@react-input/mask": "^1.2.15",
35
- "@react-input/number-format": "^1.1.3",
36
- "@storybook/icons": "^1.3.0",
37
- "@storybook/preview-api": "^8.4.7",
38
- "@types/iframe-resizer": "3.5.13",
39
- "@ujet/websdk-headless": "^3.41.4",
40
- "@vanilla-extract/css": "^1.16.1",
41
- "@vanilla-extract/recipes": "^0.5.1",
42
- "antd": "^5.22.5",
43
- "clsx": "^2.1.1",
44
- "framer-motion": "^12.9.2",
45
- "iframe-resizer": "^3.6.6",
46
- "lodash": "^4.17.21",
47
- "moment": "^2.30.1",
48
- "next-safe-action": "^8.0.2",
49
- "react-date-picker": "^11.0.0",
50
- "react-date-range": "^2.0.1",
51
- "react-hook-form": "^7.54.2",
52
- "react-markdown": "^9.0.1",
53
- "react-popper": "^2.3.0",
54
- "react-slick": "^0.30.2",
55
- "react-use": "^17.6.0",
56
- "react-wrap-balancer": "^1.1.1",
57
- "remark-gfm": "^4.0.1",
58
- "rsuite": "^5.75.0",
59
- "slick-carousel": "^1.8.1",
60
- "typed-css-modules": "^0.9.1",
61
- "vite-plugin-svgr": "^4.3.0",
62
- "zod": "^3.24.1",
63
- "zustand": "^4.5.5"
64
- },
65
- "peerDependencies": {
66
- "@vanilla-extract/css-utils": "^0.1.3",
67
- "@vanilla-extract/recipes": "^0.5.1",
68
- "@vanilla-extract/vite-plugin": "^4.0.3",
69
- "next": "^14.1.4",
70
- "react": "^18.2.0",
71
- "react-date-range": "^2.0.1",
72
- "react-dom": "^18.2.0",
73
- "react-popper": "^2.3.0",
74
- "react-slick": "^0.30.2",
75
- "slick-carousel": "^1.8.1"
76
- },
77
- "devDependencies": {
78
- "@chromatic-com/storybook": "^1.9.0",
79
- "@rollup/plugin-alias": "^5.1.1",
80
- "@storybook/addon-essentials": "^8.4.7",
81
- "@storybook/addon-interactions": "^8.4.7",
82
- "@storybook/addon-links": "^8.4.7",
83
- "@storybook/addon-mdx-gfm": "^8.4.7",
84
- "@storybook/addon-onboarding": "^8.4.7",
85
- "@storybook/addon-themes": "^8.4.7",
86
- "@storybook/blocks": "^8.4.7",
87
- "@storybook/react": "^8.6.14",
88
- "@storybook/react-vite": "^8.4.7",
89
- "@storybook/test": "^8.6.14",
90
- "@svgr/core": "^8.1.0",
91
- "@svgr/plugin-prettier": "^8.1.0",
92
- "@svgr/plugin-svgo": "^8.1.0",
93
- "@types/lodash": "^4.17.17",
94
- "@types/node": "^20.19.0",
95
- "@types/react": "^18.3.23",
96
- "@types/react-date-range": "^1.4.9",
97
- "@types/react-datepicker": "^6.2.0",
98
- "@types/react-dom": "^18.3.7",
99
- "@types/react-slick": "^0.23.13",
100
- "@typescript-eslint/eslint-plugin": "^7.18.0",
101
- "@typescript-eslint/parser": "^7.18.0",
102
- "@vanilla-extract/css-utils": "^0.1.4",
103
- "@vanilla-extract/recipes": "^0.5.5",
104
- "@vanilla-extract/vite-plugin": "^4.0.18",
105
- "@vitejs/plugin-react-swc": "^3.7.2",
106
- "esbuild-vanilla-image-loader": "^0.1.3",
107
- "eslint": "^8.57.1",
108
- "eslint-plugin-react-hooks": "^4.6.2",
109
- "eslint-plugin-react-refresh": "^0.4.16",
110
- "eslint-plugin-storybook": "^0.8.0",
111
- "glob": "^10.4.5",
112
- "husky": "^9.1.7",
113
- "next": "^14.1.4",
114
- "prettier": "3.2.5",
115
- "react": "^18.3.1",
116
- "react-dom": "^18.3.1",
117
- "rollup-plugin-preserve-directives": "^0.4.0",
118
- "rollup-plugin-svg-import": "^3.0.0",
119
- "rollup-plugin-svgo": "^2.0.0",
120
- "storybook": "^8.4.7",
121
- "typescript": "^5.7.2",
122
- "typescript-plugin-css-modules": "^5.1.0",
123
- "vite": "^5.4.11",
124
- "vite-plugin-dts": "^3.9.1",
125
- "vite-plugin-lib-inject-css": "^2.1.1",
126
- "vite-plugin-setting-css-module": "^1.1.4",
127
- "vite-tsconfig-paths": "^4.3.2"
128
- },
129
- "main": "index.js",
130
- "directories": {
131
- "lib": "lib"
132
- },
133
- "author": "axos-web-dev",
134
- "license": "ISC"
135
- }
1
+ {
2
+ "name": "@axos-web-dev/shared-components",
3
+ "description": "Axos shared components library for web.",
4
+ "version": "1.0.77-patch.63",
5
+ "type": "module",
6
+ "module": "dist/main.js",
7
+ "types": "dist/main.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "sideEffects": [
12
+ "dist/assets/**/*.css"
13
+ ],
14
+ "scripts": {
15
+ "dev": "vite",
16
+ "build": "tsc --p ./tsconfig.build.json && vite build",
17
+ "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
18
+ "preview": "vite preview",
19
+ "prepublishOnly": "npm run build",
20
+ "check-types": "tsc --pretty --noEmit",
21
+ "check-format": "prettier --check .",
22
+ "check-lint": "eslint . --ext ts --ext tsx --ext js",
23
+ "format": "prettier --write .",
24
+ "test-all": "npm run check-format && npm run check-lint && npm run check-types && npm run build",
25
+ "prepare": "husky",
26
+ "storybook": "storybook dev -p 6006",
27
+ "build-storybook": "storybook build",
28
+ "npm:link": "npm run build && npm link"
29
+ },
30
+ "dependencies": {
31
+ "@headlessui/react": "^2.2.0",
32
+ "@hookform/resolvers": "^3.10.0",
33
+ "@next-safe-action/adapter-react-hook-form": "^2.0.0",
34
+ "@react-input/mask": "^1.2.15",
35
+ "@react-input/number-format": "^1.1.3",
36
+ "@storybook/icons": "^1.3.0",
37
+ "@storybook/preview-api": "^8.4.7",
38
+ "@types/iframe-resizer": "3.5.13",
39
+ "@ujet/websdk-headless": "^3.41.4",
40
+ "@vanilla-extract/css": "^1.16.1",
41
+ "@vanilla-extract/recipes": "^0.5.1",
42
+ "antd": "^5.22.5",
43
+ "clsx": "^2.1.1",
44
+ "framer-motion": "^12.9.2",
45
+ "iframe-resizer": "^3.6.6",
46
+ "lodash": "^4.17.21",
47
+ "moment": "^2.30.1",
48
+ "next-safe-action": "^8.0.2",
49
+ "react-date-picker": "^11.0.0",
50
+ "react-date-range": "^2.0.1",
51
+ "react-hook-form": "^7.54.2",
52
+ "react-markdown": "^9.0.1",
53
+ "react-popper": "^2.3.0",
54
+ "react-slick": "^0.30.2",
55
+ "react-use": "^17.6.0",
56
+ "react-wrap-balancer": "^1.1.1",
57
+ "remark-gfm": "^4.0.1",
58
+ "rsuite": "^5.75.0",
59
+ "slick-carousel": "^1.8.1",
60
+ "typed-css-modules": "^0.9.1",
61
+ "vite-plugin-svgr": "^4.3.0",
62
+ "zod": "^3.24.1",
63
+ "zustand": "^4.5.5"
64
+ },
65
+ "peerDependencies": {
66
+ "@vanilla-extract/css-utils": "^0.1.3",
67
+ "@vanilla-extract/recipes": "^0.5.1",
68
+ "@vanilla-extract/vite-plugin": "^4.0.3",
69
+ "next": "^14.1.4",
70
+ "react": "^18.2.0",
71
+ "react-date-range": "^2.0.1",
72
+ "react-dom": "^18.2.0",
73
+ "react-popper": "^2.3.0",
74
+ "react-slick": "^0.30.2",
75
+ "slick-carousel": "^1.8.1"
76
+ },
77
+ "devDependencies": {
78
+ "@chromatic-com/storybook": "^1.9.0",
79
+ "@rollup/plugin-alias": "^5.1.1",
80
+ "@storybook/addon-essentials": "^8.4.7",
81
+ "@storybook/addon-interactions": "^8.4.7",
82
+ "@storybook/addon-links": "^8.4.7",
83
+ "@storybook/addon-mdx-gfm": "^8.4.7",
84
+ "@storybook/addon-onboarding": "^8.4.7",
85
+ "@storybook/addon-themes": "^8.4.7",
86
+ "@storybook/blocks": "^8.4.7",
87
+ "@storybook/react": "^8.6.14",
88
+ "@storybook/react-vite": "^8.4.7",
89
+ "@storybook/test": "^8.6.14",
90
+ "@svgr/core": "^8.1.0",
91
+ "@svgr/plugin-prettier": "^8.1.0",
92
+ "@svgr/plugin-svgo": "^8.1.0",
93
+ "@types/lodash": "^4.17.17",
94
+ "@types/node": "^20.19.0",
95
+ "@types/react": "^18.3.23",
96
+ "@types/react-date-range": "^1.4.9",
97
+ "@types/react-datepicker": "^6.2.0",
98
+ "@types/react-dom": "^18.3.7",
99
+ "@types/react-slick": "^0.23.13",
100
+ "@typescript-eslint/eslint-plugin": "^7.18.0",
101
+ "@typescript-eslint/parser": "^7.18.0",
102
+ "@vanilla-extract/css-utils": "^0.1.4",
103
+ "@vanilla-extract/recipes": "^0.5.5",
104
+ "@vanilla-extract/vite-plugin": "^4.0.18",
105
+ "@vitejs/plugin-react-swc": "^3.7.2",
106
+ "esbuild-vanilla-image-loader": "^0.1.3",
107
+ "eslint": "^8.57.1",
108
+ "eslint-plugin-react-hooks": "^4.6.2",
109
+ "eslint-plugin-react-refresh": "^0.4.16",
110
+ "eslint-plugin-storybook": "^0.8.0",
111
+ "glob": "^10.4.5",
112
+ "husky": "^9.1.7",
113
+ "next": "^14.1.4",
114
+ "prettier": "3.2.5",
115
+ "react": "^18.3.1",
116
+ "react-dom": "^18.3.1",
117
+ "rollup-plugin-preserve-directives": "^0.4.0",
118
+ "rollup-plugin-svg-import": "^3.0.0",
119
+ "rollup-plugin-svgo": "^2.0.0",
120
+ "storybook": "^8.4.7",
121
+ "typescript": "^5.7.2",
122
+ "typescript-plugin-css-modules": "^5.1.0",
123
+ "vite": "^5.4.11",
124
+ "vite-plugin-dts": "^3.9.1",
125
+ "vite-plugin-lib-inject-css": "^2.1.1",
126
+ "vite-plugin-setting-css-module": "^1.1.4",
127
+ "vite-tsconfig-paths": "^4.3.2"
128
+ },
129
+ "main": "index.js",
130
+ "directories": {
131
+ "lib": "lib"
132
+ },
133
+ "author": "axos-web-dev",
134
+ "license": "ISC"
135
+ }