@ichaingo/link 1.1.0

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/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # link
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build link` to build the library.
8
+
9
+ ## Running unit tests
10
+
11
+ Run `nx test link` to execute the unit tests via [Vitest](https://vitest.dev/).
@@ -0,0 +1,13 @@
1
+ import { LinkProps } from 'next/link';
2
+ interface LinkBarProps extends LinkProps {
3
+ href: string;
4
+ isOldProject?: boolean;
5
+ withLocale?: boolean;
6
+ baseUrl?: string;
7
+ children?: React.ReactNode;
8
+ prefetch?: boolean;
9
+ [key: string]: any;
10
+ }
11
+ declare const LinkBar: React.FC<LinkBarProps>;
12
+ export default LinkBar;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAM3C,UAAU,YAAa,SAAQ,SAAS;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,QAAA,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CA+EnC,CAAC;AAEF,eAAe,OAAO,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,49 @@
1
+ 'use client';
2
+ import { jsx as k } from "react/jsx-runtime";
3
+ import W from "next/link";
4
+ import { usePathname as _ } from "@ichaingo/i18n/navigation";
5
+ import { useLocale as v } from "next-intl";
6
+ import { useRouter as y, useSearchParams as B } from "next/navigation";
7
+ import { useTransition as H, useMemo as S } from "react";
8
+ import { useProgressBar as T } from "@ichaingo/providers/TopProgressBarProvider";
9
+ const z = ({
10
+ href: r,
11
+ isOldProject: c,
12
+ withLocale: m = !0,
13
+ baseUrl: o = "",
14
+ children: p,
15
+ target: a = "_self",
16
+ onClick: i,
17
+ prefetch: l = !1,
18
+ ...f
19
+ }) => {
20
+ const d = y(), g = _(), P = B(), [, $] = H(), { start: w } = T(), e = v(), n = (t) => o.includes(".ichaingo.com") || t.includes(".ichaingo.com") || o === "" && !/^(https?:\/\/|\/\/)/.test(t) ? !1 : /^(https?:\/\/|\/\/)/.test(t), x = (t) => t.replace(`/${e}`, "") === g.replace(`/${e}`, "") + P.toString(), L = (t, s) => {
21
+ if (i == null || i(t), t.stopPropagation(), t.preventDefault(), x(s)) {
22
+ window.location.reload();
23
+ return;
24
+ }
25
+ c || n(s) ? window.open(s, n(s) ? "_blank" : a) : (w(), $(() => {
26
+ d.push(s);
27
+ }));
28
+ }, u = S(() => {
29
+ if (n(r)) return r;
30
+ const t = `/${e}`;
31
+ return r === t || r.startsWith(`${t}/`) || !m ? o + r : r.startsWith("/") ? `${o}${t}${r}` : r;
32
+ }, [r, e, o]);
33
+ return /* @__PURE__ */ k(
34
+ W,
35
+ {
36
+ suppressHydrationWarning: !0,
37
+ prefetch: l,
38
+ href: u,
39
+ target: n(r) ? "_blank" : a,
40
+ onClick: (t) => L(t, u),
41
+ rel: n(r) ? "noopener noreferrer" : void 0,
42
+ ...f,
43
+ children: p
44
+ }
45
+ );
46
+ };
47
+ export {
48
+ z as default
49
+ };
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@ichaingo/link",
3
+ "version": "1.1.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "!**/*.tsbuildinfo"
18
+ ],
19
+ "peerDependencies": {
20
+ "next": "^15.4.5",
21
+ "next-intl": "^4.3.4",
22
+ "react": "^19.1.0",
23
+ "@ichaingo/i18n": "1.1.0",
24
+ "@ichaingo/providers": "1.1.0"
25
+ },
26
+ "devDependencies": {
27
+ "rollup-plugin-preserve-use-client": "^3.0.1"
28
+ }
29
+ }