@pisodev/test-component-library 2.1.0 → 2.1.3

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.
@@ -0,0 +1,6 @@
1
+ // This file exists for TypeScript type resolution
2
+ // The actual implementation is in ThemeProvider.web.tsx and ThemeProvider.native.tsx
3
+ // Metro bundler and Rollup will automatically pick the correct platform-specific file
4
+
5
+ export { ThemeProvider } from './ThemeProvider.native';
6
+ export type { ThemeProviderProps } from './ThemeProvider.native';
@@ -1,4 +1,5 @@
1
- export { ThemeProvider } from './ThemeProvider.native';
1
+ export { ThemeProvider } from './ThemeProvider';
2
+ export type { ThemeProviderProps } from './ThemeProvider';
2
3
  export { useTheme } from './useTheme';
3
4
  export { lightTheme, darkTheme } from './colors';
4
5
  export type { Theme, ThemeMode, ColorScale, SemanticColors, PaperColors } from './colors.types';
@@ -0,0 +1,2 @@
1
+ export { ThemeProvider } from './ThemeProvider.native';
2
+ export type { ThemeProviderProps } from './ThemeProvider.native';
@@ -1,4 +1,5 @@
1
- export { ThemeProvider } from './ThemeProvider.native';
1
+ export { ThemeProvider } from './ThemeProvider';
2
+ export type { ThemeProviderProps } from './ThemeProvider';
2
3
  export { useTheme } from './useTheme';
3
4
  export { lightTheme, darkTheme } from './colors';
4
5
  export type { Theme, ThemeMode, ColorScale, SemanticColors, PaperColors } from './colors.types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisodev/test-component-library",
3
- "version": "2.1.0",
3
+ "version": "2.1.3",
4
4
  "description": "웹과 React Native를 위한 컴포넌트 라이브러리",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -51,6 +51,7 @@
51
51
  "rollup": "^4.54.0",
52
52
  "rollup-plugin-peer-deps-external": "^2.2.4",
53
53
  "rollup-plugin-postcss": "^4.0.2",
54
+ "postcss": "^8.4.49",
54
55
  "sass": "^1.97.1",
55
56
  "tslib": "^2.8.1",
56
57
  "typescript": "^5.9.3"
@@ -1,195 +0,0 @@
1
- # 컴포넌트 가이드
2
-
3
- ## 컴포넌트 타입
4
-
5
- ### 1. 크로스 플랫폼 컴포넌트 (웹 + RN 모두 지원)
6
-
7
- ```
8
- ComponentName/
9
- ├── ComponentName.types.ts # 공유 타입
10
- ├── ComponentName.web.tsx # 웹 구현
11
- ├── ComponentName.native.tsx # RN 구현
12
- ├── index.ts # export
13
- └── README.md
14
- ```
15
-
16
- **예시**: Anchor, Button, Card
17
-
18
- **index.ts**:
19
- ```typescript
20
- export { ComponentName } from './ComponentName';
21
- export type { ComponentNameProps } from './ComponentName.types';
22
- ```
23
-
24
- ---
25
-
26
- ### 2. 웹 전용 컴포넌트
27
-
28
- ```
29
- WebOnlyComponent/
30
- ├── WebOnlyComponent.types.ts # 타입
31
- ├── WebOnlyComponent.tsx # 웹 구현 (.web.tsx 아님!)
32
- ├── WebOnlyComponent.module.scss # 스타일
33
- ├── index.ts # export
34
- └── README.md
35
- ```
36
-
37
- **예시**: Table, Tooltip, Dropdown
38
-
39
- **index.ts**:
40
- ```typescript
41
- export { WebOnlyComponent } from './WebOnlyComponent';
42
- export type { WebOnlyComponentProps } from './WebOnlyComponent.types';
43
- ```
44
-
45
- **중요**: RN에서 import 시 에러 방지를 위한 처리
46
-
47
- **Option 1 - 타입만 제공**:
48
- ```typescript
49
- // index.native.ts (별도 파일)
50
- import { WebOnlyComponentProps } from './WebOnlyComponent.types';
51
-
52
- export const WebOnlyComponent = () => {
53
- if (__DEV__) {
54
- console.warn('WebOnlyComponent is not available on React Native');
55
- }
56
- return null;
57
- };
58
-
59
- export type { WebOnlyComponentProps };
60
- ```
61
-
62
- **Option 2 - 완전히 제외**:
63
- ```typescript
64
- // components/index.ts에서
65
- export * from './Anchor';
66
- export * from './Button';
67
-
68
- // 조건부 export (빌드 설정에서 처리)
69
- if (typeof window !== 'undefined') {
70
- export * from './WebOnlyComponent';
71
- }
72
- ```
73
-
74
- ---
75
-
76
- ### 3. React Native 전용 컴포넌트
77
-
78
- ```
79
- NativeOnlyComponent/
80
- ├── NativeOnlyComponent.types.ts # 타입
81
- ├── NativeOnlyComponent.tsx # RN 구현 (.native.tsx 아님!)
82
- ├── index.ts # export
83
- └── README.md
84
- ```
85
-
86
- **예시**: MapView, Camera, BiometricAuth
87
-
88
- **index.ts**:
89
- ```typescript
90
- export { NativeOnlyComponent } from './NativeOnlyComponent';
91
- export type { NativeOnlyComponentProps } from './NativeOnlyComponent.types';
92
- ```
93
-
94
- **웹에서 import 시 에러 방지**:
95
-
96
- **index.web.ts (별도 파일)**:
97
- ```typescript
98
- import { NativeOnlyComponentProps } from './NativeOnlyComponent.types';
99
-
100
- export const NativeOnlyComponent = () => {
101
- if (process.env.NODE_ENV === 'development') {
102
- console.warn('NativeOnlyComponent is only available on React Native');
103
- }
104
- return null;
105
- };
106
-
107
- export type { NativeOnlyComponentProps };
108
- ```
109
-
110
- ---
111
-
112
- ## 실전 예시
113
-
114
- ### 예시 1: Tooltip (웹 전용)
115
-
116
- DOM API를 사용하므로 RN에서 불가능
117
-
118
- ```
119
- Tooltip/
120
- ├── Tooltip.types.ts
121
- ├── Tooltip.tsx # 웹 구현
122
- ├── Tooltip.module.scss
123
- ├── index.ts # 웹용 export
124
- ├── index.native.ts # RN용 - null 반환 또는 대안
125
- └── README.md
126
- ```
127
-
128
- **index.native.ts**:
129
- ```typescript
130
- import { TooltipProps } from './Tooltip.types';
131
-
132
- // RN에서는 React Native의 Tooltip 사용 권장
133
- export const Tooltip: React.FC<TooltipProps> = ({ children }) => {
134
- return <>{children}</>; // 툴팁 없이 children만 렌더
135
- };
136
-
137
- export type { TooltipProps };
138
- ```
139
-
140
- ### 예시 2: DatePicker (플랫폼별 구현 차이가 큼)
141
-
142
- 웹과 RN에서 완전히 다른 API 사용
143
-
144
- ```
145
- DatePicker/
146
- ├── DatePicker.types.ts # 공통 props만
147
- ├── DatePicker.web.tsx # HTML input type="date"
148
- ├── DatePicker.native.tsx # @react-native-community/datetimepicker
149
- ├── index.ts
150
- └── README.md
151
- ```
152
-
153
- ### 예시 3: MapView (RN 전용)
154
-
155
- react-native-maps 사용
156
-
157
- ```
158
- MapView/
159
- ├── MapView.types.ts
160
- ├── MapView.tsx # RN 구현
161
- ├── index.ts # RN export
162
- ├── index.web.ts # 웹에서는 에러 또는 대안
163
- └── README.md
164
- ```
165
-
166
- **index.web.ts**:
167
- ```typescript
168
- export const MapView = () => {
169
- throw new Error(
170
- 'MapView is only available on React Native. Use a web map library like react-leaflet instead.'
171
- );
172
- };
173
- ```
174
-
175
- ---
176
-
177
- ## 권장 사항
178
-
179
- ### 플랫폼 전용 컴포넌트를 만들기 전에
180
-
181
- 1. **정말 플랫폼 전용이 필요한가?**
182
- - 대부분의 UI 컴포넌트는 크로스 플랫폼 가능
183
- - 로직만 분리하고 렌더링만 다르게 할 수 있는지 검토
184
-
185
- 2. **대안 제공**
186
- - 웹 전용: RN에서는 null 반환 + 경고
187
- - RN 전용: 웹에서는 에러 throw + 대안 라이브러리 제안
188
-
189
- 3. **문서화**
190
- - README.md에 플랫폼 제한 명시
191
- - 대안 라이브러리/방법 제시
192
-
193
- 4. **TypeScript 타입은 공유**
194
- - Props 타입은 양쪽에서 사용 가능하도록
195
- - 개발자 경험(DX) 향상