@okam/next-component 0.4.1 → 1.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@okam/next-component",
3
- "version": "0.4.1",
3
+ "version": "1.0.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -8,8 +8,11 @@
8
8
  "url": "https://github.com/OKAMca/stack.git"
9
9
  },
10
10
  "dependencies": {
11
- "@okam/stack-ui": "1.31.1",
12
- "next": "^14.1.1"
11
+ "next": "^14.1.1",
12
+ "react-use": "17.5.1",
13
+ "react": "18.3.1",
14
+ "tailwind-variants": "^0.3.0",
15
+ "@okam/stack-ui": "1.34.0"
13
16
  },
14
17
  "module": "./index.esm.js",
15
18
  "type": "module",
@@ -0,0 +1,3 @@
1
+ import type { TLinkProps } from './interface';
2
+ declare const Link: import("react").ForwardRefExoticComponent<TLinkProps<import("@okam/stack-ui").TToken> & import("react").RefAttributes<HTMLButtonElement & HTMLAnchorElement>>;
3
+ export default Link;
@@ -0,0 +1,4 @@
1
+ import type { TDefaultComponent, TToken } from '@okam/stack-ui';
2
+ import type { TLink } from '../../hooks/useLink/interface';
3
+ export interface TLinkProps<T = TToken> extends Omit<TDefaultComponent<T>, keyof TLink>, TLink {
4
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * A hook that lets you read the current URL's hash.
3
+ *
4
+ * @returns The current `window.location.hash`, including the leading `#` character.
5
+ */
6
+ export declare function useHash(): string;
@@ -0,0 +1,13 @@
1
+ import type { TLink, TUseLinkReturn } from './interface';
2
+ /**
3
+ * Tries to get the locale, in order of priority:
4
+ * 1. The locale prop. Still has priority even when set to `false`
5
+ * 2. The locale from react-aria `useLocale`
6
+ * 3. The locale from next/navigation `useParams`
7
+ * @returns The best matched locale
8
+ */
9
+ export declare function useLinkLocale(props: TLink): any;
10
+ /**
11
+ * @params {props.locale} - The direct locale prop always gets priority. If no `locale` prop is provided, the prop will try to fall back to react-aria `useLocale` and then next/navigation `useParams`. If a locale is found, it will be automatically prepended to the href. Otherwise, href will be returned as is.
12
+ */
13
+ export declare function useLink(props: TLink): TUseLinkReturn;
@@ -0,0 +1,23 @@
1
+ import type { LinkProps as NextLinkProps } from 'next/link';
2
+ import type { ReadonlyURLSearchParams } from 'next/navigation';
3
+ export interface TLink extends Omit<NextLinkProps, 'scroll' | 'as'> {
4
+ /**
5
+ * @default true
6
+ * - `true`: Scrolls to the top of the clicked anchor (default Next.js behavior)
7
+ * - `false`: Prevents any automatic scrolling
8
+ * - `'top'`: Always scrolls to the top of the page, regardless of anchor
9
+ */
10
+ scroll?: 'top' | boolean;
11
+ urlDecorator?: NextLinkProps['as'];
12
+ /**
13
+ * Used for the automatic scroll when `scroll = 'top'`
14
+ * @default instant
15
+ */
16
+ behavior?: ScrollBehavior;
17
+ onPathnameChange?: (pathname: string) => void;
18
+ onSearchParamsChange?: (searchParams: ReadonlyURLSearchParams) => void;
19
+ onHashChange?: (hash: string) => void;
20
+ }
21
+ export interface TUseLinkReturn extends Omit<NextLinkProps, 'href'> {
22
+ href: string;
23
+ }
package/src/index.d.ts CHANGED
@@ -1,2 +1,7 @@
1
1
  export { default as Img } from './components/Img';
2
+ export { default as Link } from './components/Link';
3
+ export { useLink } from './hooks/useLink';
4
+ export { useHash } from './hooks/useHash';
2
5
  export type { default as TImgProps } from './components/Img/interface';
6
+ export type { TLinkProps } from './components/Link/interface';
7
+ export type { TLink } from './hooks/useLink/interface';
@@ -0,0 +1,156 @@
1
+ declare const linkTheme: import("tailwind-variants").TVReturnType<{
2
+ type: {
3
+ button: string;
4
+ menu: string;
5
+ };
6
+ buttonStyle: {
7
+ default: string;
8
+ outline: string;
9
+ hollow: string;
10
+ ghost: string;
11
+ };
12
+ intent: {
13
+ error: string;
14
+ };
15
+ size: {
16
+ default: string;
17
+ large: string;
18
+ };
19
+ shape: {
20
+ rounded: string;
21
+ circular: string;
22
+ };
23
+ }, undefined, "\n flex\n items-center\n justify-center\n gap-4\n transition\n duration-300\n ease-in-out\n disabled:pointer-events-none\n disabled:opacity-30\n focus-ring-black\n ", import("tailwind-variants/dist/config.js").TVConfig<{
24
+ type: {
25
+ button: string;
26
+ menu: string;
27
+ };
28
+ buttonStyle: {
29
+ default: string;
30
+ outline: string;
31
+ hollow: string;
32
+ ghost: string;
33
+ };
34
+ intent: {
35
+ error: string;
36
+ };
37
+ size: {
38
+ default: string;
39
+ large: string;
40
+ };
41
+ shape: {
42
+ rounded: string;
43
+ circular: string;
44
+ };
45
+ }, {
46
+ type: {
47
+ button: string;
48
+ menu: string;
49
+ };
50
+ buttonStyle: {
51
+ default: string;
52
+ outline: string;
53
+ hollow: string;
54
+ ghost: string;
55
+ };
56
+ intent: {
57
+ error: string;
58
+ };
59
+ size: {
60
+ default: string;
61
+ large: string;
62
+ };
63
+ shape: {
64
+ rounded: string;
65
+ circular: string;
66
+ };
67
+ }>, {
68
+ type: {
69
+ button: string;
70
+ menu: string;
71
+ };
72
+ buttonStyle: {
73
+ default: string;
74
+ outline: string;
75
+ hollow: string;
76
+ ghost: string;
77
+ };
78
+ intent: {
79
+ error: string;
80
+ };
81
+ size: {
82
+ default: string;
83
+ large: string;
84
+ };
85
+ shape: {
86
+ rounded: string;
87
+ circular: string;
88
+ };
89
+ }, undefined, import("tailwind-variants").TVReturnType<{
90
+ type: {
91
+ button: string;
92
+ menu: string;
93
+ };
94
+ buttonStyle: {
95
+ default: string;
96
+ outline: string;
97
+ hollow: string;
98
+ ghost: string;
99
+ };
100
+ intent: {
101
+ error: string;
102
+ };
103
+ size: {
104
+ default: string;
105
+ large: string;
106
+ };
107
+ shape: {
108
+ rounded: string;
109
+ circular: string;
110
+ };
111
+ }, undefined, "\n flex\n items-center\n justify-center\n gap-4\n transition\n duration-300\n ease-in-out\n disabled:pointer-events-none\n disabled:opacity-30\n focus-ring-black\n ", import("tailwind-variants/dist/config.js").TVConfig<{
112
+ type: {
113
+ button: string;
114
+ menu: string;
115
+ };
116
+ buttonStyle: {
117
+ default: string;
118
+ outline: string;
119
+ hollow: string;
120
+ ghost: string;
121
+ };
122
+ intent: {
123
+ error: string;
124
+ };
125
+ size: {
126
+ default: string;
127
+ large: string;
128
+ };
129
+ shape: {
130
+ rounded: string;
131
+ circular: string;
132
+ };
133
+ }, {
134
+ type: {
135
+ button: string;
136
+ menu: string;
137
+ };
138
+ buttonStyle: {
139
+ default: string;
140
+ outline: string;
141
+ hollow: string;
142
+ ghost: string;
143
+ };
144
+ intent: {
145
+ error: string;
146
+ };
147
+ size: {
148
+ default: string;
149
+ large: string;
150
+ };
151
+ shape: {
152
+ rounded: string;
153
+ circular: string;
154
+ };
155
+ }>, unknown, unknown, undefined>>;
156
+ export default linkTheme;
@@ -0,0 +1,4 @@
1
+ declare const _default: import("react").MemoExoticComponent<({ children }: {
2
+ children: React.ReactNode;
3
+ }) => import("react/jsx-runtime").JSX.Element>;
4
+ export default _default;