@okam/next-component 1.3.4 → 1.3.5

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/components/AdminBar/components/AdminBarError.d.ts +1 -2
  3. package/components/AdminBar/index.d.ts +1 -2
  4. package/components/AdminBar/index.js +5 -5
  5. package/components/AdminBar/index.mjs +4 -4
  6. package/components/AdminBar/interface.d.ts +0 -1
  7. package/components/Filter/index.d.ts +1 -2
  8. package/components/Filter/index.js +2 -2
  9. package/components/Filter/index.mjs +2 -2
  10. package/components/Filter/interface.d.ts +1 -2
  11. package/components/Img/index.d.ts +1 -2
  12. package/components/Img/index.js +3 -3
  13. package/components/Img/index.mjs +3 -3
  14. package/components/Img/interface.d.ts +0 -1
  15. package/components/Link/index.d.ts +7 -2
  16. package/components/Link/index.js +3 -4
  17. package/components/Link/index.mjs +3 -4
  18. package/components/Link/interface.d.ts +0 -1
  19. package/hooks/useFilterState/index.d.ts +0 -1
  20. package/hooks/useFilterState/index.js +3 -3
  21. package/hooks/useFilterState/index.mjs +3 -3
  22. package/hooks/useFilterState/interface.d.ts +0 -1
  23. package/hooks/useHash/index.js +6 -3
  24. package/hooks/useHash/index.mjs +6 -3
  25. package/hooks/useLink/index.d.ts +0 -1
  26. package/hooks/useLink/index.js +17 -15
  27. package/hooks/useLink/index.mjs +14 -12
  28. package/hooks/useLink/interface.d.ts +3 -4
  29. package/index.d.ts +8 -8
  30. package/index.js +16 -16
  31. package/index.mjs +9 -9
  32. package/package.json +22 -16
  33. package/providers/AdminBar/index.d.ts +1 -2
  34. package/providers/AdminBar/index.js +3 -2
  35. package/providers/AdminBar/index.mjs +3 -2
  36. package/providers/AdminBar/interface.d.ts +3 -4
  37. package/providers/DraftMode/index.d.ts +1 -2
  38. package/providers/DraftMode/index.js +3 -2
  39. package/providers/DraftMode/index.mjs +3 -2
  40. package/providers/DraftMode/interface.d.ts +2 -3
  41. package/providers/DraftMode/server.d.ts +1 -2
  42. package/providers/DraftMode/server.js +4 -4
  43. package/providers/DraftMode/server.mjs +3 -3
  44. package/server.d.ts +1 -1
  45. package/server.js +2 -2
  46. package/server.mjs +1 -1
  47. package/theme/AdminBar/index.d.ts +20 -524
  48. package/theme/Button/index.d.ts +2 -86
  49. package/theme/Filter/index.d.ts +98 -1184
  50. package/theme/Link/index.d.ts +2 -90
  51. package/theme/Typography/index.d.ts +2 -134
  52. package/theme/index.d.ts +1 -2
  53. package/theme/index.js +18 -1
  54. package/theme/index.mjs +2 -2
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 1.3.5 (2026-01-21)
2
+
3
+ ### 🧱 Updated Dependencies
4
+
5
+ - Updated stack-ui to 1.44.4
6
+ - Updated core-lib to 1.17.2
7
+
1
8
  ## 1.3.4 (2026-01-19)
2
9
 
3
10
  ### 🧱 Updated Dependencies
@@ -1,4 +1,3 @@
1
1
  import { TDefaultComponent } from '@okam/stack-ui';
2
-
3
- declare const AdminBarError: ({ themeName, tokens, customTheme }: TDefaultComponent) => import("react/jsx-runtime").JSX.Element | null;
2
+ declare function AdminBarError({ themeName, tokens, customTheme }: TDefaultComponent): import("react/jsx-runtime").JSX.Element | null;
4
3
  export default AdminBarError;
@@ -1,5 +1,4 @@
1
1
  import { TToken } from '@okam/stack-ui';
2
2
  import { TAdminBarProps } from './interface';
3
-
4
- declare const AdminBar: <T extends TToken>({ children, themeName, tokens, customTheme, }: TAdminBarProps<T>) => Promise<false | import("react/jsx-runtime").JSX.Element>;
3
+ declare function AdminBar<T extends TToken>({ children, themeName, tokens, customTheme, }: TAdminBarProps<T>): Promise<false | import("react/jsx-runtime").JSX.Element>;
5
4
  export default AdminBar;
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  const jsxRuntime = require("react/jsx-runtime");
3
3
  const stackUi = require("@okam/stack-ui");
4
- const headers_js = require("next/headers.js");
5
- const AdminBar = async ({
4
+ const headers = require("next/headers");
5
+ async function AdminBar({
6
6
  children,
7
7
  themeName = "adminBar",
8
8
  tokens,
9
9
  customTheme
10
- }) => {
11
- const { isEnabled } = await headers_js.draftMode();
10
+ }) {
11
+ const { isEnabled } = await headers.draftMode();
12
12
  return isEnabled && /* @__PURE__ */ jsxRuntime.jsx(stackUi.Box, { themeName: `${themeName}.container`, tokens, customTheme, children: /* @__PURE__ */ jsxRuntime.jsx(stackUi.Box, { themeName: `${themeName}.content`, tokens, children }) });
13
- };
13
+ }
14
14
  module.exports = AdminBar;
@@ -1,15 +1,15 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Box } from "@okam/stack-ui";
3
- import { draftMode } from "next/headers.js";
4
- const AdminBar = async ({
3
+ import { draftMode } from "next/headers";
4
+ async function AdminBar({
5
5
  children,
6
6
  themeName = "adminBar",
7
7
  tokens,
8
8
  customTheme
9
- }) => {
9
+ }) {
10
10
  const { isEnabled } = await draftMode();
11
11
  return isEnabled && /* @__PURE__ */ jsx(Box, { themeName: `${themeName}.container`, tokens, customTheme, children: /* @__PURE__ */ jsx(Box, { themeName: `${themeName}.content`, tokens, children }) });
12
- };
12
+ }
13
13
  export {
14
14
  AdminBar as default
15
15
  };
@@ -1,6 +1,5 @@
1
1
  import { TDefaultComponent, TToken } from '@okam/stack-ui';
2
2
  import { ReactNode } from 'react';
3
-
4
3
  /**
5
4
  * AdminBar Component Props
6
5
  *
@@ -1,6 +1,5 @@
1
1
  import { TToken } from '@okam/stack-ui';
2
2
  import { TFilterProps } from './interface';
3
-
4
3
  /**
5
4
  * ### Filter component for URL search params filtering.
6
5
  *
@@ -22,5 +21,5 @@ import { TFilterProps } from './interface';
22
21
  *
23
22
  * @returns
24
23
  */
25
- declare const Filter: <T extends TToken = TToken>(props: TFilterProps<T>) => import("react/jsx-runtime").JSX.Element;
24
+ declare function Filter<T extends TToken = TToken>(props: TFilterProps<T>): import("react/jsx-runtime").JSX.Element;
26
25
  export default Filter;
@@ -3,7 +3,7 @@
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const stackUi = require("@okam/stack-ui");
5
5
  const index = require("../../hooks/useFilterState/index.js");
6
- const Filter = (props) => {
6
+ function Filter(props) {
7
7
  const {
8
8
  // TagGroup-specific props
9
9
  children,
@@ -50,5 +50,5 @@ const Filter = (props) => {
50
50
  children: /* @__PURE__ */ jsxRuntime.jsx(stackUi.TagGroup, { themeName: `${themeName}.tagGroup`, tokens, ...tagGroupProps, ...state, children })
51
51
  }
52
52
  ) });
53
- };
53
+ }
54
54
  module.exports = Filter;
@@ -2,7 +2,7 @@
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { Box, PopoverButton, TagGroup } from "@okam/stack-ui";
4
4
  import { useFilterState } from "../../hooks/useFilterState/index.mjs";
5
- const Filter = (props) => {
5
+ function Filter(props) {
6
6
  const {
7
7
  // TagGroup-specific props
8
8
  children,
@@ -49,7 +49,7 @@ const Filter = (props) => {
49
49
  children: /* @__PURE__ */ jsx(TagGroup, { themeName: `${themeName}.tagGroup`, tokens, ...tagGroupProps, ...state, children })
50
50
  }
51
51
  ) });
52
- };
52
+ }
53
53
  export {
54
54
  Filter as default
55
55
  };
@@ -1,6 +1,5 @@
1
- import { TToken, TDefaultComponent, TPopoverButtonProps } from '@okam/stack-ui';
1
+ import { TDefaultComponent, TPopoverButtonProps, TToken } from '@okam/stack-ui';
2
2
  import { TFilter } from '../../hooks/useFilterState/interface';
3
-
4
3
  export interface TFilterTagGroupProps<T = TToken> extends Omit<TDefaultComponent<T>, 'children'>, TFilter {
5
4
  }
6
5
  export interface TFilterPopoverButtonProps<T = TToken> extends Omit<TPopoverButtonProps<T>, 'type' | 'placement'>, Pick<Partial<TPopoverButtonProps<T>>, 'type' | 'placement'> {
@@ -1,4 +1,3 @@
1
1
  import { default as TImgProps } from './interface';
2
-
3
- declare const Img: (props: TImgProps) => import("react/jsx-runtime").JSX.Element;
2
+ declare function Img(props: TImgProps): import("react/jsx-runtime").JSX.Element;
4
3
  export default Img;
@@ -2,8 +2,8 @@
2
2
  "use strict";
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const stackUi = require("@okam/stack-ui");
5
- const Image = require("next/image.js");
6
- const Img = (props) => {
5
+ const Image = require("next/image");
6
+ function Img(props) {
7
7
  const { src, width, height, themeName = "img", tokens, customTheme, ...rest } = props;
8
8
  const theme = stackUi.useThemeContext(themeName, tokens, customTheme);
9
9
  if (typeof src === "object") {
@@ -25,5 +25,5 @@ const Img = (props) => {
25
25
  );
26
26
  }
27
27
  return /* @__PURE__ */ jsxRuntime.jsx(Image, { width, height, className: theme, src, ...rest });
28
- };
28
+ }
29
29
  module.exports = Img;
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { useThemeContext } from "@okam/stack-ui";
4
- import Image from "next/image.js";
5
- const Img = (props) => {
4
+ import Image from "next/image";
5
+ function Img(props) {
6
6
  const { src, width, height, themeName = "img", tokens, customTheme, ...rest } = props;
7
7
  const theme = useThemeContext(themeName, tokens, customTheme);
8
8
  if (typeof src === "object") {
@@ -24,7 +24,7 @@ const Img = (props) => {
24
24
  );
25
25
  }
26
26
  return /* @__PURE__ */ jsx(Image, { width, height, className: theme, src, ...rest });
27
- };
27
+ }
28
28
  export {
29
29
  Img as default
30
30
  };
@@ -1,6 +1,5 @@
1
1
  import { TDefaultComponent } from '@okam/stack-ui';
2
2
  import { ImageProps, StaticImageData } from 'next/image';
3
-
4
3
  type TImgProps = TDefaultComponent & Omit<ImageProps, 'src'> & {
5
4
  src: string | StaticImageData;
6
5
  };
@@ -1,4 +1,9 @@
1
1
  import { TLinkProps } from './interface';
2
-
3
- declare const Link: import('react').ForwardRefExoticComponent<TLinkProps<import('@okam/stack-ui').TToken> & import('react').RefAttributes<HTMLButtonElement & HTMLAnchorElement>>;
2
+ import type * as React from 'react';
3
+ declare function Link({ ref, ...props }: TLinkProps & {
4
+ ref?: React.Ref<HTMLElement>;
5
+ }): import("react/jsx-runtime").JSX.Element;
6
+ declare namespace Link {
7
+ var displayName: string;
8
+ }
4
9
  export default Link;
@@ -2,10 +2,9 @@
2
2
  "use strict";
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const stackUi = require("@okam/stack-ui");
5
- const NextLink = require("next/link.js");
6
- const React = require("react");
5
+ const NextLink = require("next/link");
7
6
  const index = require("../../hooks/useLink/index.js");
8
- const Link = React.forwardRef((props, ref) => {
7
+ function Link({ ref, ...props }) {
9
8
  const {
10
9
  themeName = "link",
11
10
  tokens,
@@ -35,6 +34,6 @@ const Link = React.forwardRef((props, ref) => {
35
34
  children
36
35
  }
37
36
  );
38
- });
37
+ }
39
38
  Link.displayName = "Link";
40
39
  module.exports = Link;
@@ -1,10 +1,9 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { Anchor } from "@okam/stack-ui";
4
- import NextLink from "next/link.js";
5
- import { forwardRef } from "react";
4
+ import NextLink from "next/link";
6
5
  import { useLink } from "../../hooks/useLink/index.mjs";
7
- const Link = forwardRef((props, ref) => {
6
+ function Link({ ref, ...props }) {
8
7
  const {
9
8
  themeName = "link",
10
9
  tokens,
@@ -34,7 +33,7 @@ const Link = forwardRef((props, ref) => {
34
33
  children
35
34
  }
36
35
  );
37
- });
36
+ }
38
37
  Link.displayName = "Link";
39
38
  export {
40
39
  Link as default
@@ -1,5 +1,4 @@
1
1
  import { TDefaultComponent, TToken } from '@okam/stack-ui';
2
2
  import { TLink } from '../../hooks/useLink/interface';
3
-
4
3
  export interface TLinkProps<T = TToken> extends Omit<TDefaultComponent<T>, keyof TLink>, TLink {
5
4
  }
@@ -1,6 +1,5 @@
1
1
  import { Selection } from 'react-stately';
2
2
  import { TFilter } from './interface';
3
-
4
3
  /**
5
4
  * Manages the selection state of a single filter.
6
5
  * The state is managed by `useListState` from `react-stately`, which controls `useQueryState` from `nuqs` to display the selected keys in the URL search params.
@@ -25,9 +25,9 @@ function useFilterState(props) {
25
25
  );
26
26
  const [selectedKeys, setSelectedKeys] = nuqs.useQueryState(id, queryStateOptions);
27
27
  const onSelectedKeysChange = (keys) => {
28
- onSelectionChange == null ? void 0 : onSelectionChange(keys);
28
+ onSelectionChange?.(keys);
29
29
  const stringKeys = Array.from(keys).map((key) => key.toString());
30
- setSelectedKeys(stringKeys);
30
+ void setSelectedKeys(stringKeys);
31
31
  };
32
32
  const defaultSelectedKeys = /* @__PURE__ */ new Set([...defaultSelectedKeysProp, ...selectedKeys ?? []]);
33
33
  const state = reactStately.useListState({
@@ -43,7 +43,7 @@ function useFilterState(props) {
43
43
  if (radashi.isEqual(next, selectedKeys)) {
44
44
  return;
45
45
  }
46
- setSelectedKeys(next);
46
+ void setSelectedKeys(next);
47
47
  }, [state.selectionManager.selectedKeys]);
48
48
  return { ...state, onSelectionChange: onSelectedKeysChange, selectedKeys, defaultSelectedKeys };
49
49
  }
@@ -23,9 +23,9 @@ function useFilterState(props) {
23
23
  );
24
24
  const [selectedKeys, setSelectedKeys] = useQueryState(id, queryStateOptions);
25
25
  const onSelectedKeysChange = (keys) => {
26
- onSelectionChange == null ? void 0 : onSelectionChange(keys);
26
+ onSelectionChange?.(keys);
27
27
  const stringKeys = Array.from(keys).map((key) => key.toString());
28
- setSelectedKeys(stringKeys);
28
+ void setSelectedKeys(stringKeys);
29
29
  };
30
30
  const defaultSelectedKeys = /* @__PURE__ */ new Set([...defaultSelectedKeysProp, ...selectedKeys ?? []]);
31
31
  const state = useListState({
@@ -41,7 +41,7 @@ function useFilterState(props) {
41
41
  if (isEqual(next, selectedKeys)) {
42
42
  return;
43
43
  }
44
- setSelectedKeys(next);
44
+ void setSelectedKeys(next);
45
45
  }, [state.selectionManager.selectedKeys]);
46
46
  return { ...state, onSelectionChange: onSelectedKeysChange, selectedKeys, defaultSelectedKeys };
47
47
  }
@@ -2,7 +2,6 @@ import { TDefaultItemComponent, TToken } from '@okam/stack-ui';
2
2
  import { Options, ParserBuilder } from 'nuqs';
3
3
  import { AriaTagGroupProps } from 'react-aria';
4
4
  import { SelectionMode } from 'react-stately';
5
-
6
5
  export type TFilterValue = string[];
7
6
  export type TFilterItem<T extends TToken = TToken> = TDefaultItemComponent<never, T>;
8
7
  export interface TFilter extends Omit<AriaTagGroupProps<TFilterItem>, 'selectionMode'> {
@@ -4,16 +4,19 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  const React = require("react");
5
5
  const reactUse = require("react-use");
6
6
  function getHash() {
7
- if (typeof window === "undefined") return "";
7
+ if (typeof window === "undefined")
8
+ return "";
8
9
  return window.location.hash;
9
10
  }
10
11
  function useHash() {
11
12
  const defaultHash = getHash();
12
13
  const [hash, setHash] = React.useState(defaultHash);
13
14
  const handleHashChangeEvent = ({ newURL }) => {
14
- if (!URL.canParse(newURL)) return;
15
+ if (!URL.canParse(newURL))
16
+ return;
15
17
  const { hash: newHash } = new URL(newURL);
16
- if (!newHash || newHash === hash) return;
18
+ if (!newHash || newHash === hash)
19
+ return;
17
20
  setHash(newHash);
18
21
  };
19
22
  reactUse.useEvent("hashchange", handleHashChangeEvent);
@@ -2,16 +2,19 @@
2
2
  import { useState } from "react";
3
3
  import { useEvent } from "react-use";
4
4
  function getHash() {
5
- if (typeof window === "undefined") return "";
5
+ if (typeof window === "undefined")
6
+ return "";
6
7
  return window.location.hash;
7
8
  }
8
9
  function useHash() {
9
10
  const defaultHash = getHash();
10
11
  const [hash, setHash] = useState(defaultHash);
11
12
  const handleHashChangeEvent = ({ newURL }) => {
12
- if (!URL.canParse(newURL)) return;
13
+ if (!URL.canParse(newURL))
14
+ return;
13
15
  const { hash: newHash } = new URL(newURL);
14
- if (!newHash || newHash === hash) return;
16
+ if (!newHash || newHash === hash)
17
+ return;
15
18
  setHash(newHash);
16
19
  };
17
20
  useEvent("hashchange", handleHashChangeEvent);
@@ -1,6 +1,5 @@
1
1
  import { LinkProps } from 'next/link';
2
2
  import { TLink, TUseLinkReturn } from './interface';
3
-
4
3
  /**
5
4
  * Tries to get the locale, in order of priority:
6
5
  * 1. The locale prop. Still has priority even when set to `false`
@@ -1,22 +1,22 @@
1
1
  "use client";
2
2
  "use strict";
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const navigation_js = require("next/navigation.js");
4
+ const navigation = require("next/navigation");
5
5
  const React = require("react");
6
6
  const reactAria = require("react-aria");
7
7
  const index = require("../useHash/index.js");
8
8
  function scrollToTop(behavior) {
9
- var _a;
10
- (_a = window == null ? void 0 : window.scrollTo) == null ? void 0 : _a.call(window, { top: 0, behavior });
9
+ window?.scrollTo?.({ top: 0, behavior });
11
10
  }
12
11
  function getParamsLocale(params) {
13
12
  const { locale } = params ?? {};
14
- if (Array.isArray(locale)) return locale[0];
13
+ if (Array.isArray(locale))
14
+ return locale[0];
15
15
  return locale;
16
16
  }
17
17
  function useLinkLocale(props) {
18
18
  const { locale } = props;
19
- const params = navigation_js.useParams();
19
+ const params = navigation.useParams();
20
20
  const paramsLocale = getParamsLocale(params);
21
21
  const { locale: ctxLocale } = reactAria.useLocale();
22
22
  return locale ?? ctxLocale ?? paramsLocale ?? false;
@@ -24,8 +24,9 @@ function useLinkLocale(props) {
24
24
  function localizeHref(href, locale) {
25
25
  const hrefString = href.toString();
26
26
  const isExternal = /^[a-z]+:\/\//i.test(hrefString) || hrefString.startsWith("//");
27
- if (isExternal) return hrefString;
28
- if (locale) {
27
+ if (isExternal)
28
+ return hrefString;
29
+ if (locale != null && locale !== false) {
29
30
  return `/${locale}${hrefString}`;
30
31
  }
31
32
  return hrefString;
@@ -50,31 +51,32 @@ function useLink(props) {
50
51
  } = props;
51
52
  const locale = useLinkLocale(props);
52
53
  const localizedHref = localizeHref(href, locale);
53
- const pathname = navigation_js.usePathname();
54
- const searchParams = navigation_js.useSearchParams();
54
+ const pathname = navigation.usePathname();
55
+ const searchParams = navigation.useSearchParams();
55
56
  const hash = index.useHash();
56
57
  const isNextScroll = typeof scroll === "boolean";
57
58
  const nextScroll = isNextScroll ? scroll : false;
58
59
  const handleScroll = React.useCallback(() => {
59
- if (isNextScroll) return;
60
+ if (isNextScroll)
61
+ return;
60
62
  scrollToTop(behavior);
61
63
  }, [behavior, isNextScroll]);
62
64
  const handleClick = (event) => {
63
- onClick == null ? void 0 : onClick(event);
65
+ onClick?.(event);
64
66
  handleScroll();
65
67
  };
66
68
  const handleTouchStart = (event) => {
67
- onTouchStart == null ? void 0 : onTouchStart(event);
69
+ onTouchStart?.(event);
68
70
  handleScroll();
69
71
  };
70
72
  React.useEffect(() => {
71
- onPathnameChange == null ? void 0 : onPathnameChange(pathname);
73
+ onPathnameChange?.(pathname);
72
74
  }, [onPathnameChange, pathname]);
73
75
  React.useEffect(() => {
74
- onSearchParamsChange == null ? void 0 : onSearchParamsChange(searchParams);
76
+ onSearchParamsChange?.(searchParams);
75
77
  }, [onSearchParamsChange, searchParams]);
76
78
  React.useEffect(() => {
77
- onHashChange == null ? void 0 : onHashChange(hash);
79
+ onHashChange?.(hash);
78
80
  }, [onHashChange, hash]);
79
81
  return {
80
82
  href: localizedHref.toString(),
@@ -1,15 +1,15 @@
1
1
  "use client";
2
- import { usePathname, useSearchParams, useParams } from "next/navigation.js";
2
+ import { usePathname, useSearchParams, useParams } from "next/navigation";
3
3
  import { useCallback, useEffect } from "react";
4
4
  import { useLocale } from "react-aria";
5
5
  import { useHash } from "../useHash/index.mjs";
6
6
  function scrollToTop(behavior) {
7
- var _a;
8
- (_a = window == null ? void 0 : window.scrollTo) == null ? void 0 : _a.call(window, { top: 0, behavior });
7
+ window?.scrollTo?.({ top: 0, behavior });
9
8
  }
10
9
  function getParamsLocale(params) {
11
10
  const { locale } = params ?? {};
12
- if (Array.isArray(locale)) return locale[0];
11
+ if (Array.isArray(locale))
12
+ return locale[0];
13
13
  return locale;
14
14
  }
15
15
  function useLinkLocale(props) {
@@ -22,8 +22,9 @@ function useLinkLocale(props) {
22
22
  function localizeHref(href, locale) {
23
23
  const hrefString = href.toString();
24
24
  const isExternal = /^[a-z]+:\/\//i.test(hrefString) || hrefString.startsWith("//");
25
- if (isExternal) return hrefString;
26
- if (locale) {
25
+ if (isExternal)
26
+ return hrefString;
27
+ if (locale != null && locale !== false) {
27
28
  return `/${locale}${hrefString}`;
28
29
  }
29
30
  return hrefString;
@@ -54,25 +55,26 @@ function useLink(props) {
54
55
  const isNextScroll = typeof scroll === "boolean";
55
56
  const nextScroll = isNextScroll ? scroll : false;
56
57
  const handleScroll = useCallback(() => {
57
- if (isNextScroll) return;
58
+ if (isNextScroll)
59
+ return;
58
60
  scrollToTop(behavior);
59
61
  }, [behavior, isNextScroll]);
60
62
  const handleClick = (event) => {
61
- onClick == null ? void 0 : onClick(event);
63
+ onClick?.(event);
62
64
  handleScroll();
63
65
  };
64
66
  const handleTouchStart = (event) => {
65
- onTouchStart == null ? void 0 : onTouchStart(event);
67
+ onTouchStart?.(event);
66
68
  handleScroll();
67
69
  };
68
70
  useEffect(() => {
69
- onPathnameChange == null ? void 0 : onPathnameChange(pathname);
71
+ onPathnameChange?.(pathname);
70
72
  }, [onPathnameChange, pathname]);
71
73
  useEffect(() => {
72
- onSearchParamsChange == null ? void 0 : onSearchParamsChange(searchParams);
74
+ onSearchParamsChange?.(searchParams);
73
75
  }, [onSearchParamsChange, searchParams]);
74
76
  useEffect(() => {
75
- onHashChange == null ? void 0 : onHashChange(hash);
77
+ onHashChange?.(hash);
76
78
  }, [onHashChange, hash]);
77
79
  return {
78
80
  href: localizedHref.toString(),
@@ -1,6 +1,5 @@
1
1
  import { LinkProps as NextLinkProps } from 'next/link';
2
2
  import { ReadonlyURLSearchParams } from 'next/navigation';
3
-
4
3
  export interface TLink extends Omit<NextLinkProps, 'scroll' | 'as'> {
5
4
  /**
6
5
  * @default true
@@ -15,9 +14,9 @@ export interface TLink extends Omit<NextLinkProps, 'scroll' | 'as'> {
15
14
  * @default instant
16
15
  */
17
16
  behavior?: ScrollBehavior;
18
- onPathnameChange?: (pathname: string) => void;
19
- onSearchParamsChange?: (searchParams: ReadonlyURLSearchParams) => void;
20
- onHashChange?: (hash: string) => void;
17
+ onPathnameChange?: (_pathname: string) => void;
18
+ onSearchParamsChange?: (_searchParams: ReadonlyURLSearchParams) => void;
19
+ onHashChange?: (_hash: string) => void;
21
20
  }
22
21
  export interface TUseLinkReturn extends Omit<NextLinkProps, 'href'> {
23
22
  href: string;
package/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- export { default as Img } from './components/Img';
2
- export { default as Link } from './components/Link';
3
1
  export { default as Filter } from './components/Filter';
4
- export { useLink } from './hooks/useLink';
5
- export { useHash } from './hooks/useHash';
6
- export { useFilterState } from './hooks/useFilterState';
2
+ export type { TFilterProps } from './components/Filter/interface';
3
+ export { default as Img } from './components/Img';
7
4
  export type { default as TImgProps } from './components/Img/interface';
5
+ export { default as Link } from './components/Link';
8
6
  export type { TLinkProps } from './components/Link/interface';
9
- export type { TLink } from './hooks/useLink/interface';
7
+ export { useFilterState } from './hooks/useFilterState';
10
8
  export type { TFilter } from './hooks/useFilterState/interface';
11
- export type { TFilterProps } from './components/Filter/interface';
12
- export { DraftModeContextProvider, useDraftMode } from './providers/DraftMode';
9
+ export { useHash } from './hooks/useHash';
10
+ export { useLink } from './hooks/useLink';
11
+ export type { TLink } from './hooks/useLink/interface';
13
12
  export { AdminBarContextProvider, useAdminBar } from './providers/AdminBar';
13
+ export { DraftModeContextProvider, useDraftMode } from './providers/DraftMode';
14
14
  export { default as ThemeProvider } from './theme';
package/index.js CHANGED
@@ -1,22 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./components/Img/index.js");
4
- const index$1 = require("./components/Link/index.js");
5
- const index$2 = require("./components/Filter/index.js");
6
- const index$3 = require("./hooks/useLink/index.js");
3
+ const index = require("./components/Filter/index.js");
4
+ const index$1 = require("./components/Img/index.js");
5
+ const index$2 = require("./components/Link/index.js");
6
+ const index$3 = require("./hooks/useFilterState/index.js");
7
7
  const index$4 = require("./hooks/useHash/index.js");
8
- const index$5 = require("./hooks/useFilterState/index.js");
9
- const index$6 = require("./providers/DraftMode/index.js");
10
- const index$7 = require("./providers/AdminBar/index.js");
8
+ const index$5 = require("./hooks/useLink/index.js");
9
+ const index$6 = require("./providers/AdminBar/index.js");
10
+ const index$7 = require("./providers/DraftMode/index.js");
11
11
  const index$8 = require("./theme/index.js");
12
- exports.Img = index;
13
- exports.Link = index$1;
14
- exports.Filter = index$2;
15
- exports.useLink = index$3.useLink;
12
+ exports.Filter = index;
13
+ exports.Img = index$1;
14
+ exports.Link = index$2;
15
+ exports.useFilterState = index$3.useFilterState;
16
16
  exports.useHash = index$4.useHash;
17
- exports.useFilterState = index$5.useFilterState;
18
- exports.DraftModeContextProvider = index$6.DraftModeContextProvider;
19
- exports.useDraftMode = index$6.useDraftMode;
20
- exports.AdminBarContextProvider = index$7.AdminBarContextProvider;
21
- exports.useAdminBar = index$7.useAdminBar;
17
+ exports.useLink = index$5.useLink;
18
+ exports.AdminBarContextProvider = index$6.AdminBarContextProvider;
19
+ exports.useAdminBar = index$6.useAdminBar;
20
+ exports.DraftModeContextProvider = index$7.DraftModeContextProvider;
21
+ exports.useDraftMode = index$7.useDraftMode;
22
22
  exports.ThemeProvider = index$8;
package/index.mjs CHANGED
@@ -1,18 +1,18 @@
1
- import { default as default2 } from "./components/Img/index.mjs";
2
- import { default as default3 } from "./components/Link/index.mjs";
3
- import { default as default4 } from "./components/Filter/index.mjs";
4
- import { useLink } from "./hooks/useLink/index.mjs";
5
- import { useHash } from "./hooks/useHash/index.mjs";
1
+ import { default as default2 } from "./components/Filter/index.mjs";
2
+ import { default as default3 } from "./components/Img/index.mjs";
3
+ import { default as default4 } from "./components/Link/index.mjs";
6
4
  import { useFilterState } from "./hooks/useFilterState/index.mjs";
7
- import { DraftModeContextProvider, useDraftMode } from "./providers/DraftMode/index.mjs";
5
+ import { useHash } from "./hooks/useHash/index.mjs";
6
+ import { useLink } from "./hooks/useLink/index.mjs";
8
7
  import { AdminBarContextProvider, useAdminBar } from "./providers/AdminBar/index.mjs";
8
+ import { DraftModeContextProvider, useDraftMode } from "./providers/DraftMode/index.mjs";
9
9
  import { default as default5 } from "./theme/index.mjs";
10
10
  export {
11
11
  AdminBarContextProvider,
12
12
  DraftModeContextProvider,
13
- default4 as Filter,
14
- default2 as Img,
15
- default3 as Link,
13
+ default2 as Filter,
14
+ default3 as Img,
15
+ default4 as Link,
16
16
  default5 as ThemeProvider,
17
17
  useAdminBar,
18
18
  useDraftMode,