sh-ui-cli 0.33.0 → 0.38.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/data/changelog/versions.json +33 -0
- package/data/registry/react/components/date-picker/index.tsx +21 -4
- package/data/registry/react/components/date-picker/styles.css +12 -12
- package/package.json +1 -1
- package/src/api.d.ts +24 -0
- package/src/api.js +1 -0
- package/src/create/generator.js +77 -2
- package/src/create/index.mjs +4 -1
- package/src/create/theme/decode.js +106 -3
- package/src/create/theme/inject.js +317 -33
- package/src/create/theme/presets.js +147 -0
- package/src/mcp.mjs +3 -1
- package/templates/flutter-standalone/lib/sh_ui/foundation/sh_ui_tokens.dart +43 -2
- package/templates/nextjs-app/package.json +2 -0
- package/templates/nextjs-app/src/shared/lib/formatDate.ts +22 -0
- package/templates/nextjs-app/src/shared/lib/formatPrice.ts +10 -0
- package/templates/nextjs-app/src/shared/lib/getQueryClient.ts +14 -0
- package/templates/nextjs-app/src/shared/test/createTestQueryClient.ts +18 -0
- package/templates/nextjs-app/src/shared/test/index.ts +2 -0
- package/templates/nextjs-app/src/shared/test/renderWithProviders.tsx +40 -0
- package/templates/nextjs-app/src/shared/ui/FallbackBoundary/index.tsx +89 -0
- package/templates/nextjs-app/src/shared/ui/PrefetchBoundary/index.tsx +35 -0
- package/templates/nextjs-standalone/package.json +2 -0
- package/templates/nextjs-standalone/src/shared/lib/formatDate.ts +22 -0
- package/templates/nextjs-standalone/src/shared/lib/formatPrice.ts +10 -0
- package/templates/nextjs-standalone/src/shared/lib/getQueryClient.ts +14 -0
- package/templates/nextjs-standalone/src/shared/styles/tokens.css +21 -0
- package/templates/nextjs-standalone/src/shared/test/createTestQueryClient.ts +18 -0
- package/templates/nextjs-standalone/src/shared/test/index.ts +2 -0
- package/templates/nextjs-standalone/src/shared/test/renderWithProviders.tsx +40 -0
- package/templates/nextjs-standalone/src/shared/ui/FallbackBoundary/index.tsx +89 -0
- package/templates/nextjs-standalone/src/shared/ui/PrefetchBoundary/index.tsx +35 -0
- package/templates/ui-app-template/src/styles/tokens.css +21 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Component,
|
|
5
|
+
type ComponentType,
|
|
6
|
+
type ErrorInfo,
|
|
7
|
+
type ReactNode,
|
|
8
|
+
Suspense,
|
|
9
|
+
} from 'react';
|
|
10
|
+
import { QueryErrorResetBoundary } from '@tanstack/react-query';
|
|
11
|
+
|
|
12
|
+
export type ErrorFallbackProps = {
|
|
13
|
+
error: Error | null;
|
|
14
|
+
resetErrorBoundary: () => void;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type ErrorBoundaryProps = {
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
fallback?: ComponentType<ErrorFallbackProps>;
|
|
20
|
+
onReset: () => void;
|
|
21
|
+
onError?: (error: Error, info: ErrorInfo) => void;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type ErrorBoundaryState = {
|
|
25
|
+
hasError: boolean;
|
|
26
|
+
error: Error | null;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
30
|
+
state: ErrorBoundaryState = { hasError: false, error: null };
|
|
31
|
+
|
|
32
|
+
static getDerivedStateFromError(error: Error): ErrorBoundaryState {
|
|
33
|
+
return { hasError: true, error };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
componentDidCatch(error: Error, info: ErrorInfo) {
|
|
37
|
+
this.props.onError?.(error, info);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
resetErrorBoundary = () => {
|
|
41
|
+
this.props.onReset();
|
|
42
|
+
this.setState({ hasError: false, error: null });
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
render() {
|
|
46
|
+
const { hasError, error } = this.state;
|
|
47
|
+
const { children, fallback: Fallback } = this.props;
|
|
48
|
+
|
|
49
|
+
if (hasError && Fallback) {
|
|
50
|
+
return (
|
|
51
|
+
<Fallback error={error} resetErrorBoundary={this.resetErrorBoundary} />
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return children;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
type FallbackBoundaryProps = {
|
|
60
|
+
children: ReactNode;
|
|
61
|
+
errorFallback?: ComponentType<ErrorFallbackProps>;
|
|
62
|
+
suspenseFallback?: ReactNode;
|
|
63
|
+
onError?: (error: Error, info: ErrorInfo) => void;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Suspense + ErrorBoundary 합성. React Query 의 reset 신호에 맞춰
|
|
68
|
+
* `errorFallback` 의 `resetErrorBoundary` 가 쿼리까지 함께 리셋한다.
|
|
69
|
+
*/
|
|
70
|
+
export function FallbackBoundary({
|
|
71
|
+
children,
|
|
72
|
+
errorFallback,
|
|
73
|
+
suspenseFallback,
|
|
74
|
+
onError,
|
|
75
|
+
}: FallbackBoundaryProps) {
|
|
76
|
+
return (
|
|
77
|
+
<QueryErrorResetBoundary>
|
|
78
|
+
{({ reset }) => (
|
|
79
|
+
<ErrorBoundary
|
|
80
|
+
onReset={reset}
|
|
81
|
+
fallback={errorFallback}
|
|
82
|
+
onError={onError}
|
|
83
|
+
>
|
|
84
|
+
<Suspense fallback={suspenseFallback}>{children}</Suspense>
|
|
85
|
+
</ErrorBoundary>
|
|
86
|
+
)}
|
|
87
|
+
</QueryErrorResetBoundary>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
dehydrate,
|
|
5
|
+
type FetchQueryOptions,
|
|
6
|
+
HydrationBoundary,
|
|
7
|
+
} from '@tanstack/react-query';
|
|
8
|
+
|
|
9
|
+
import getQueryClient from '@/src/shared/lib/getQueryClient';
|
|
10
|
+
|
|
11
|
+
export type FetchOptions = Pick<FetchQueryOptions, 'queryKey' | 'queryFn'>;
|
|
12
|
+
|
|
13
|
+
type Props = {
|
|
14
|
+
fetchOptions?: FetchOptions[] | FetchOptions | null;
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* RSC 에서 prefetch 를 끝낸 뒤 dehydrated state 로 클라이언트에 hydrate.
|
|
20
|
+
* 단일/배열 둘 다 받는다.
|
|
21
|
+
*/
|
|
22
|
+
export async function PrefetchBoundary({ fetchOptions, children }: Props) {
|
|
23
|
+
const queryClient = getQueryClient();
|
|
24
|
+
|
|
25
|
+
if (fetchOptions) {
|
|
26
|
+
const list = Array.isArray(fetchOptions) ? fetchOptions : [fetchOptions];
|
|
27
|
+
await Promise.all(list.map((opt) => queryClient.prefetchQuery(opt)));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<HydrationBoundary state={dehydrate(queryClient)}>
|
|
32
|
+
{children}
|
|
33
|
+
</HydrationBoundary>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
/* sh-ui:theme-radius-start */
|
|
43
43
|
--radius: 0.5rem;
|
|
44
44
|
/* sh-ui:theme-radius-end */
|
|
45
|
+
/* sh-ui:theme-space-start */
|
|
45
46
|
--space-0: 0px;
|
|
46
47
|
--space-1: 4px;
|
|
47
48
|
--space-2: 8px;
|
|
@@ -53,6 +54,8 @@
|
|
|
53
54
|
--space-10: 40px;
|
|
54
55
|
--space-12: 48px;
|
|
55
56
|
--space-16: 64px;
|
|
57
|
+
/* sh-ui:theme-space-end */
|
|
58
|
+
/* sh-ui:theme-text-start */
|
|
56
59
|
--text-xs: 12px;
|
|
57
60
|
--text-sm: 14px;
|
|
58
61
|
--text-base: 16px;
|
|
@@ -61,24 +64,42 @@
|
|
|
61
64
|
--text-2xl: 24px;
|
|
62
65
|
--text-3xl: 30px;
|
|
63
66
|
--text-4xl: 36px;
|
|
67
|
+
/* sh-ui:theme-text-end */
|
|
68
|
+
/* sh-ui:theme-weight-start */
|
|
64
69
|
--weight-regular: 400;
|
|
65
70
|
--weight-medium: 500;
|
|
66
71
|
--weight-semibold: 600;
|
|
67
72
|
--weight-bold: 700;
|
|
73
|
+
/* sh-ui:theme-weight-end */
|
|
74
|
+
/* sh-ui:theme-shadow-start */
|
|
68
75
|
--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.08);
|
|
69
76
|
--shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
|
|
70
77
|
--shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
|
|
71
78
|
--shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.18);
|
|
79
|
+
/* sh-ui:theme-shadow-end */
|
|
80
|
+
/* sh-ui:theme-duration-start */
|
|
72
81
|
--duration-fast: 120ms;
|
|
73
82
|
--duration-base: 160ms;
|
|
74
83
|
--duration-slow: 200ms;
|
|
84
|
+
/* sh-ui:theme-duration-end */
|
|
85
|
+
/* sh-ui:theme-ease-start */
|
|
75
86
|
--ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
|
|
76
87
|
--ease-emphasized: cubic-bezier(0.2, 0, 0, 1);
|
|
88
|
+
/* sh-ui:theme-ease-end */
|
|
89
|
+
/* sh-ui:theme-control-start */
|
|
77
90
|
--control-sm: 32px;
|
|
78
91
|
--control-md: 40px;
|
|
79
92
|
--control-lg: 48px;
|
|
93
|
+
/* sh-ui:theme-control-end */
|
|
94
|
+
/* sh-ui:theme-border-width-start */
|
|
80
95
|
--border-width: 1px;
|
|
81
96
|
--border-width-strong: 2px;
|
|
97
|
+
/* sh-ui:theme-border-width-end */
|
|
98
|
+
/* sh-ui:theme-gradient-start */
|
|
99
|
+
--gradient-primary: linear-gradient(135deg, #171717 0%, #525252 100%);
|
|
100
|
+
--gradient-surface: linear-gradient(180deg, #FFFFFF 0%, #F5F5F5 100%);
|
|
101
|
+
--gradient-overlay: linear-gradient(180deg, #000000 0%, #1F1F1F 100%);
|
|
102
|
+
/* sh-ui:theme-gradient-end */
|
|
82
103
|
--opacity-disabled: 0.5;
|
|
83
104
|
--z-base: 0;
|
|
84
105
|
--z-sticky: 100;
|