@sellmate/design-system-react 0.0.9 → 0.0.11
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/dist/hydrate.d.ts +2 -0
- package/dist/hydrate.js +44 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.js +2 -3
- package/dist/registerStencil.d.ts +1 -0
- package/dist/registerStencil.js +8 -0
- package/lib/hydrate.ts +52 -0
- package/lib/index.ts +3 -9
- package/lib/registerStencil.ts +9 -0
- package/package.json +15 -3
- package/dist/nextjs-utils.d.ts +0 -26
- package/dist/nextjs-utils.js +0 -37
- package/lib/nextjs-utils.tsx +0 -63
- package/lib/types/index.d.ts +0 -2
package/dist/hydrate.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { hydrateDocument, } from '@sellmate/design-system/hydrate';
|
|
2
|
+
// -------------------------------
|
|
3
|
+
// SSR용 서버사이드 렌더링 함수
|
|
4
|
+
// -------------------------------
|
|
5
|
+
export async function renderStencilToString(html) {
|
|
6
|
+
try {
|
|
7
|
+
const results = await hydrateDocument(html, {
|
|
8
|
+
staticComponents: [
|
|
9
|
+
'sd-button',
|
|
10
|
+
'sd-input',
|
|
11
|
+
'sd-select',
|
|
12
|
+
'sd-table',
|
|
13
|
+
'sd-icon',
|
|
14
|
+
'sd-checkbox',
|
|
15
|
+
'sd-tag',
|
|
16
|
+
'sd-pagination',
|
|
17
|
+
'sd-tooltip',
|
|
18
|
+
'sd-popover',
|
|
19
|
+
'sd-guide',
|
|
20
|
+
'sd-date-picker',
|
|
21
|
+
'sd-date-range-picker',
|
|
22
|
+
'sd-date-box',
|
|
23
|
+
'sd-portal',
|
|
24
|
+
'sd-tooltip-portal',
|
|
25
|
+
],
|
|
26
|
+
});
|
|
27
|
+
return results.html;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
console.warn('Stencil SSR failed, falling back to client-side rendering:', error);
|
|
31
|
+
return html;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// ----------------------------------------------
|
|
35
|
+
// 클라이언트 사이드 등록 함수
|
|
36
|
+
// ----------------------------------------------
|
|
37
|
+
export function registerStencilForNextjs() {
|
|
38
|
+
if (typeof window === 'undefined')
|
|
39
|
+
return;
|
|
40
|
+
// router 변경 시에도 재등록
|
|
41
|
+
import('@sellmate/design-system/loader').then(({ defineCustomElements }) => {
|
|
42
|
+
defineCustomElements(window);
|
|
43
|
+
});
|
|
44
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export * from './components/components';
|
|
2
|
-
export {
|
|
2
|
+
export { registerStencil } from './registerStencil';
|
|
3
3
|
export type { SdTableSortDir, SdTableColumn, Row as SdTableRow, } from '@sellmate/design-system';
|
|
4
|
-
export { WithNextjsSSR, ClientOnly, CLIENT_ONLY_COMPONENTS, isClientOnlyComponent, } from './nextjs-utils';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
export * from './components/components';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export { WithNextjsSSR, ClientOnly, CLIENT_ONLY_COMPONENTS, isClientOnlyComponent, } from './nextjs-utils';
|
|
3
|
+
// Optional manual registration (not automatically called)
|
|
4
|
+
export { registerStencil } from './registerStencil';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function registerStencil(): void;
|
package/lib/hydrate.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
renderToString,
|
|
3
|
+
hydrateDocument,
|
|
4
|
+
} from '@sellmate/design-system/hydrate';
|
|
5
|
+
|
|
6
|
+
// -------------------------------
|
|
7
|
+
// SSR용 서버사이드 렌더링 함수
|
|
8
|
+
// -------------------------------
|
|
9
|
+
export async function renderStencilToString(html: string) {
|
|
10
|
+
try {
|
|
11
|
+
const results = await hydrateDocument(html, {
|
|
12
|
+
staticComponents: [
|
|
13
|
+
'sd-button',
|
|
14
|
+
'sd-input',
|
|
15
|
+
'sd-select',
|
|
16
|
+
'sd-table',
|
|
17
|
+
'sd-icon',
|
|
18
|
+
'sd-checkbox',
|
|
19
|
+
'sd-tag',
|
|
20
|
+
'sd-pagination',
|
|
21
|
+
'sd-tooltip',
|
|
22
|
+
'sd-popover',
|
|
23
|
+
'sd-guide',
|
|
24
|
+
'sd-date-picker',
|
|
25
|
+
'sd-date-range-picker',
|
|
26
|
+
'sd-date-box',
|
|
27
|
+
'sd-portal',
|
|
28
|
+
'sd-tooltip-portal',
|
|
29
|
+
],
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return results.html;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
console.warn(
|
|
35
|
+
'Stencil SSR failed, falling back to client-side rendering:',
|
|
36
|
+
error
|
|
37
|
+
);
|
|
38
|
+
return html;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ----------------------------------------------
|
|
43
|
+
// 클라이언트 사이드 등록 함수
|
|
44
|
+
// ----------------------------------------------
|
|
45
|
+
export function registerStencilForNextjs() {
|
|
46
|
+
if (typeof window === 'undefined') return;
|
|
47
|
+
|
|
48
|
+
// router 변경 시에도 재등록
|
|
49
|
+
import('@sellmate/design-system/loader').then(({ defineCustomElements }) => {
|
|
50
|
+
defineCustomElements(window);
|
|
51
|
+
});
|
|
52
|
+
}
|
package/lib/index.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
export * from './components/components';
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
// Optional manual registration (not automatically called)
|
|
6
|
+
export { registerStencil } from './registerStencil';
|
|
5
7
|
|
|
6
8
|
// Export sd-table types for React usage
|
|
7
9
|
export type {
|
|
@@ -9,11 +11,3 @@ export type {
|
|
|
9
11
|
SdTableColumn,
|
|
10
12
|
Row as SdTableRow,
|
|
11
13
|
} from '@sellmate/design-system';
|
|
12
|
-
|
|
13
|
-
// Export Next.js utilities
|
|
14
|
-
export {
|
|
15
|
-
WithNextjsSSR,
|
|
16
|
-
ClientOnly,
|
|
17
|
-
CLIENT_ONLY_COMPONENTS,
|
|
18
|
-
isClientOnlyComponent,
|
|
19
|
-
} from './nextjs-utils';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sellmate/design-system-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "Design System - React Component Wrappers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -24,6 +24,18 @@
|
|
|
24
24
|
"main": "dist/index.js",
|
|
25
25
|
"module": "dist/index.js",
|
|
26
26
|
"types": "dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js",
|
|
31
|
+
"require": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./hydrate": {
|
|
34
|
+
"types": "./dist/hydrate.d.ts",
|
|
35
|
+
"import": "./dist/hydrate.js",
|
|
36
|
+
"require": "./dist/hydrate.js"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
27
39
|
"directories": {
|
|
28
40
|
"lib": "lib",
|
|
29
41
|
"test": "__tests__"
|
|
@@ -42,7 +54,7 @@
|
|
|
42
54
|
"dev": "tsc --watch"
|
|
43
55
|
},
|
|
44
56
|
"dependencies": {
|
|
45
|
-
"@sellmate/design-system": "^0.0.
|
|
57
|
+
"@sellmate/design-system": "^0.0.9",
|
|
46
58
|
"@stencil/react-output-target": "^1.2.0"
|
|
47
59
|
},
|
|
48
60
|
"peerDependencies": {
|
|
@@ -56,5 +68,5 @@
|
|
|
56
68
|
"rimraf": "^6.0.1",
|
|
57
69
|
"typescript": "^5.9.3"
|
|
58
70
|
},
|
|
59
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "8406a77cacf86efd489f6b4a42e362176fe81d7b"
|
|
60
72
|
}
|
package/dist/nextjs-utils.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface WithNextjsSSRProps {
|
|
3
|
-
children: React.ReactElement;
|
|
4
|
-
fallback?: React.ReactNode;
|
|
5
|
-
suppressHydrationWarning?: boolean;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Next.js에서 Stencil 기반 React 컴포넌트의 hydration 오류를 방지하는 HOC
|
|
9
|
-
*/
|
|
10
|
-
export declare const WithNextjsSSR: React.FC<WithNextjsSSRProps>;
|
|
11
|
-
/**
|
|
12
|
-
* Next.js에서 클라이언트 사이드에서만 렌더링되는 컴포넌트
|
|
13
|
-
*/
|
|
14
|
-
export declare const ClientOnly: React.FC<{
|
|
15
|
-
children: React.ReactNode;
|
|
16
|
-
fallback?: React.ReactNode;
|
|
17
|
-
}>;
|
|
18
|
-
/**
|
|
19
|
-
* 클라이언트 전용으로 렌더링해야 하는 컴포넌트들
|
|
20
|
-
*/
|
|
21
|
-
export declare const CLIENT_ONLY_COMPONENTS: readonly ["SdDatePicker", "SdDateRangePicker"];
|
|
22
|
-
/**
|
|
23
|
-
* 컴포넌트가 클라이언트 전용인지 확인
|
|
24
|
-
*/
|
|
25
|
-
export declare const isClientOnlyComponent: (componentName: string) => boolean;
|
|
26
|
-
export {};
|
package/dist/nextjs-utils.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Next.js에서 Stencil 기반 React 컴포넌트의 hydration 오류를 방지하는 HOC
|
|
4
|
-
*/
|
|
5
|
-
export const WithNextjsSSR = ({ children, fallback = null, suppressHydrationWarning = true }) => {
|
|
6
|
-
const [mounted, setMounted] = useState(false);
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
setMounted(true);
|
|
9
|
-
}, []);
|
|
10
|
-
if (!mounted) {
|
|
11
|
-
return (React.createElement("div", { suppressHydrationWarning: suppressHydrationWarning }, fallback));
|
|
12
|
-
}
|
|
13
|
-
return children;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Next.js에서 클라이언트 사이드에서만 렌더링되는 컴포넌트
|
|
17
|
-
*/
|
|
18
|
-
export const ClientOnly = ({ children, fallback = null }) => {
|
|
19
|
-
const [mounted, setMounted] = useState(false);
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
setMounted(true);
|
|
22
|
-
}, []);
|
|
23
|
-
return mounted ? React.createElement(React.Fragment, null, children) : React.createElement(React.Fragment, null, fallback);
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* 클라이언트 전용으로 렌더링해야 하는 컴포넌트들
|
|
27
|
-
*/
|
|
28
|
-
export const CLIENT_ONLY_COMPONENTS = [
|
|
29
|
-
'SdDatePicker',
|
|
30
|
-
'SdDateRangePicker',
|
|
31
|
-
];
|
|
32
|
-
/**
|
|
33
|
-
* 컴포넌트가 클라이언트 전용인지 확인
|
|
34
|
-
*/
|
|
35
|
-
export const isClientOnlyComponent = (componentName) => {
|
|
36
|
-
return CLIENT_ONLY_COMPONENTS.includes(componentName);
|
|
37
|
-
};
|
package/lib/nextjs-utils.tsx
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
interface WithNextjsSSRProps {
|
|
4
|
-
children: React.ReactElement;
|
|
5
|
-
fallback?: React.ReactNode;
|
|
6
|
-
suppressHydrationWarning?: boolean;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Next.js에서 Stencil 기반 React 컴포넌트의 hydration 오류를 방지하는 HOC
|
|
11
|
-
*/
|
|
12
|
-
export const WithNextjsSSR: React.FC<WithNextjsSSRProps> = ({
|
|
13
|
-
children,
|
|
14
|
-
fallback = null,
|
|
15
|
-
suppressHydrationWarning = true
|
|
16
|
-
}) => {
|
|
17
|
-
const [mounted, setMounted] = useState(false);
|
|
18
|
-
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
setMounted(true);
|
|
21
|
-
}, []);
|
|
22
|
-
|
|
23
|
-
if (!mounted) {
|
|
24
|
-
return (
|
|
25
|
-
<div suppressHydrationWarning={suppressHydrationWarning}>
|
|
26
|
-
{fallback}
|
|
27
|
-
</div>
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return children;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Next.js에서 클라이언트 사이드에서만 렌더링되는 컴포넌트
|
|
36
|
-
*/
|
|
37
|
-
export const ClientOnly: React.FC<{ children: React.ReactNode; fallback?: React.ReactNode }> = ({
|
|
38
|
-
children,
|
|
39
|
-
fallback = null
|
|
40
|
-
}) => {
|
|
41
|
-
const [mounted, setMounted] = useState(false);
|
|
42
|
-
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
setMounted(true);
|
|
45
|
-
}, []);
|
|
46
|
-
|
|
47
|
-
return mounted ? <>{children}</> : <>{fallback}</>;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* 클라이언트 전용으로 렌더링해야 하는 컴포넌트들
|
|
52
|
-
*/
|
|
53
|
-
export const CLIENT_ONLY_COMPONENTS = [
|
|
54
|
-
'SdDatePicker',
|
|
55
|
-
'SdDateRangePicker',
|
|
56
|
-
] as const;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* 컴포넌트가 클라이언트 전용인지 확인
|
|
60
|
-
*/
|
|
61
|
-
export const isClientOnlyComponent = (componentName: string): boolean => {
|
|
62
|
-
return CLIENT_ONLY_COMPONENTS.includes(componentName as any);
|
|
63
|
-
};
|
package/lib/types/index.d.ts
DELETED