@ezpg/app-ui 0.16.0 → 0.18.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.
Files changed (194) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/lib/module/blocks/cover-photos/cover-photos.js +165 -0
  3. package/lib/module/blocks/cover-photos/cover-photos.js.map +1 -0
  4. package/lib/module/blocks/cover-photos/index.js +4 -0
  5. package/lib/module/blocks/cover-photos/index.js.map +1 -0
  6. package/lib/module/blocks/detail-editor/compare-slider.js +117 -0
  7. package/lib/module/blocks/detail-editor/compare-slider.js.map +1 -0
  8. package/lib/module/blocks/detail-editor/detail-canvas.js +339 -0
  9. package/lib/module/blocks/detail-editor/detail-canvas.js.map +1 -0
  10. package/lib/module/blocks/detail-editor/detail-composer.js +254 -0
  11. package/lib/module/blocks/detail-editor/detail-composer.js.map +1 -0
  12. package/lib/module/blocks/detail-editor/detail-editor-template.js +102 -0
  13. package/lib/module/blocks/detail-editor/detail-editor-template.js.map +1 -0
  14. package/lib/module/blocks/detail-editor/detail-types.js +64 -0
  15. package/lib/module/blocks/detail-editor/detail-types.js.map +1 -0
  16. package/lib/module/blocks/detail-editor/draft-preview.js +39 -0
  17. package/lib/module/blocks/detail-editor/draft-preview.js.map +1 -0
  18. package/lib/module/blocks/detail-editor/draft-strip.js +97 -0
  19. package/lib/module/blocks/detail-editor/draft-strip.js.map +1 -0
  20. package/lib/module/blocks/detail-editor/editor-bar.js +96 -0
  21. package/lib/module/blocks/detail-editor/editor-bar.js.map +1 -0
  22. package/lib/module/blocks/detail-editor/focus-context.js +5 -0
  23. package/lib/module/blocks/detail-editor/focus-context.js.map +1 -0
  24. package/lib/module/blocks/detail-editor/font-picker.js +74 -0
  25. package/lib/module/blocks/detail-editor/font-picker.js.map +1 -0
  26. package/lib/module/blocks/detail-editor/index.js +16 -0
  27. package/lib/module/blocks/detail-editor/index.js.map +1 -0
  28. package/lib/module/blocks/detail-editor/layout-picker.js +173 -0
  29. package/lib/module/blocks/detail-editor/layout-picker.js.map +1 -0
  30. package/lib/module/blocks/detail-editor/photo-tray.js +144 -0
  31. package/lib/module/blocks/detail-editor/photo-tray.js.map +1 -0
  32. package/lib/module/blocks/detail-editor/structure-picker.js +75 -0
  33. package/lib/module/blocks/detail-editor/structure-picker.js.map +1 -0
  34. package/lib/module/blocks/detail-editor/tool-row.js +63 -0
  35. package/lib/module/blocks/detail-editor/tool-row.js.map +1 -0
  36. package/lib/module/blocks/index.js +3 -0
  37. package/lib/module/blocks/index.js.map +1 -1
  38. package/lib/module/blocks/slider-list/index.js +4 -0
  39. package/lib/module/blocks/slider-list/index.js.map +1 -0
  40. package/lib/module/blocks/slider-list/slider-list.js +45 -0
  41. package/lib/module/blocks/slider-list/slider-list.js.map +1 -0
  42. package/lib/module/blocks/task-tiles/task-tiles.js +1 -1
  43. package/lib/module/blocks/task-tiles/task-tiles.js.map +1 -1
  44. package/lib/module/charts/mini-bars.js +1 -1
  45. package/lib/module/charts/mini-bars.js.map +1 -1
  46. package/lib/module/components/button/button.js +10 -3
  47. package/lib/module/components/button/button.js.map +1 -1
  48. package/lib/module/components/floating-tab-bar/floating-tab-bar.js +103 -0
  49. package/lib/module/components/floating-tab-bar/floating-tab-bar.js.map +1 -0
  50. package/lib/module/components/floating-tab-bar/index.js +4 -0
  51. package/lib/module/components/floating-tab-bar/index.js.map +1 -0
  52. package/lib/module/components/list-row/list-row.js +9 -3
  53. package/lib/module/components/list-row/list-row.js.map +1 -1
  54. package/lib/module/components/section-tabs/index.js +4 -0
  55. package/lib/module/components/section-tabs/index.js.map +1 -0
  56. package/lib/module/components/section-tabs/section-tabs.js +73 -0
  57. package/lib/module/components/section-tabs/section-tabs.js.map +1 -0
  58. package/lib/module/components/slider/index.js +4 -0
  59. package/lib/module/components/slider/index.js.map +1 -0
  60. package/lib/module/components/slider/slider.js +151 -0
  61. package/lib/module/components/slider/slider.js.map +1 -0
  62. package/lib/module/index.js +3 -0
  63. package/lib/module/index.js.map +1 -1
  64. package/lib/module/internal/flush-row.js +5 -0
  65. package/lib/module/internal/flush-row.js.map +1 -0
  66. package/lib/module/internal/pressable-base.js +3 -2
  67. package/lib/module/internal/pressable-base.js.map +1 -1
  68. package/lib/module/internal/tab-icon-pairs.js +25 -0
  69. package/lib/module/internal/tab-icon-pairs.js.map +1 -0
  70. package/lib/module/sortable/block-strip.js +151 -0
  71. package/lib/module/sortable/block-strip.js.map +1 -0
  72. package/lib/module/sortable/index.js +1 -0
  73. package/lib/module/sortable/index.js.map +1 -1
  74. package/lib/module/templates/index.js +1 -0
  75. package/lib/module/templates/index.js.map +1 -1
  76. package/lib/module/templates/parts.js +42 -2
  77. package/lib/module/templates/parts.js.map +1 -1
  78. package/lib/module/templates/sheet-form-template.js +174 -0
  79. package/lib/module/templates/sheet-form-template.js.map +1 -0
  80. package/lib/module/theme/base.js +4 -4
  81. package/lib/typescript/src/blocks/cover-photos/cover-photos.d.ts +16 -0
  82. package/lib/typescript/src/blocks/cover-photos/cover-photos.d.ts.map +1 -0
  83. package/lib/typescript/src/blocks/cover-photos/index.d.ts +2 -0
  84. package/lib/typescript/src/blocks/cover-photos/index.d.ts.map +1 -0
  85. package/lib/typescript/src/blocks/detail-editor/compare-slider.d.ts +8 -0
  86. package/lib/typescript/src/blocks/detail-editor/compare-slider.d.ts.map +1 -0
  87. package/lib/typescript/src/blocks/detail-editor/detail-canvas.d.ts +13 -0
  88. package/lib/typescript/src/blocks/detail-editor/detail-canvas.d.ts.map +1 -0
  89. package/lib/typescript/src/blocks/detail-editor/detail-composer.d.ts +25 -0
  90. package/lib/typescript/src/blocks/detail-editor/detail-composer.d.ts.map +1 -0
  91. package/lib/typescript/src/blocks/detail-editor/detail-editor-template.d.ts +13 -0
  92. package/lib/typescript/src/blocks/detail-editor/detail-editor-template.d.ts.map +1 -0
  93. package/lib/typescript/src/blocks/detail-editor/detail-types.d.ts +55 -0
  94. package/lib/typescript/src/blocks/detail-editor/detail-types.d.ts.map +1 -0
  95. package/lib/typescript/src/blocks/detail-editor/draft-preview.d.ts +8 -0
  96. package/lib/typescript/src/blocks/detail-editor/draft-preview.d.ts.map +1 -0
  97. package/lib/typescript/src/blocks/detail-editor/draft-strip.d.ts +16 -0
  98. package/lib/typescript/src/blocks/detail-editor/draft-strip.d.ts.map +1 -0
  99. package/lib/typescript/src/blocks/detail-editor/editor-bar.d.ts +18 -0
  100. package/lib/typescript/src/blocks/detail-editor/editor-bar.d.ts.map +1 -0
  101. package/lib/typescript/src/blocks/detail-editor/focus-context.d.ts +6 -0
  102. package/lib/typescript/src/blocks/detail-editor/focus-context.d.ts.map +1 -0
  103. package/lib/typescript/src/blocks/detail-editor/font-picker.d.ts +8 -0
  104. package/lib/typescript/src/blocks/detail-editor/font-picker.d.ts.map +1 -0
  105. package/lib/typescript/src/blocks/detail-editor/index.d.ts +14 -0
  106. package/lib/typescript/src/blocks/detail-editor/index.d.ts.map +1 -0
  107. package/lib/typescript/src/blocks/detail-editor/layout-picker.d.ts +11 -0
  108. package/lib/typescript/src/blocks/detail-editor/layout-picker.d.ts.map +1 -0
  109. package/lib/typescript/src/blocks/detail-editor/photo-tray.d.ts +15 -0
  110. package/lib/typescript/src/blocks/detail-editor/photo-tray.d.ts.map +1 -0
  111. package/lib/typescript/src/blocks/detail-editor/structure-picker.d.ts +13 -0
  112. package/lib/typescript/src/blocks/detail-editor/structure-picker.d.ts.map +1 -0
  113. package/lib/typescript/src/blocks/detail-editor/tool-row.d.ts +13 -0
  114. package/lib/typescript/src/blocks/detail-editor/tool-row.d.ts.map +1 -0
  115. package/lib/typescript/src/blocks/index.d.ts +3 -0
  116. package/lib/typescript/src/blocks/index.d.ts.map +1 -1
  117. package/lib/typescript/src/blocks/slider-list/index.d.ts +2 -0
  118. package/lib/typescript/src/blocks/slider-list/index.d.ts.map +1 -0
  119. package/lib/typescript/src/blocks/slider-list/slider-list.d.ts +17 -0
  120. package/lib/typescript/src/blocks/slider-list/slider-list.d.ts.map +1 -0
  121. package/lib/typescript/src/components/button/button.d.ts.map +1 -1
  122. package/lib/typescript/src/components/floating-tab-bar/floating-tab-bar.d.ts +20 -0
  123. package/lib/typescript/src/components/floating-tab-bar/floating-tab-bar.d.ts.map +1 -0
  124. package/lib/typescript/src/components/floating-tab-bar/index.d.ts +2 -0
  125. package/lib/typescript/src/components/floating-tab-bar/index.d.ts.map +1 -0
  126. package/lib/typescript/src/components/list-row/list-row.d.ts.map +1 -1
  127. package/lib/typescript/src/components/section-tabs/index.d.ts +2 -0
  128. package/lib/typescript/src/components/section-tabs/index.d.ts.map +1 -0
  129. package/lib/typescript/src/components/section-tabs/section-tabs.d.ts +14 -0
  130. package/lib/typescript/src/components/section-tabs/section-tabs.d.ts.map +1 -0
  131. package/lib/typescript/src/components/slider/index.d.ts +2 -0
  132. package/lib/typescript/src/components/slider/index.d.ts.map +1 -0
  133. package/lib/typescript/src/components/slider/slider.d.ts +14 -0
  134. package/lib/typescript/src/components/slider/slider.d.ts.map +1 -0
  135. package/lib/typescript/src/index.d.ts +3 -0
  136. package/lib/typescript/src/index.d.ts.map +1 -1
  137. package/lib/typescript/src/internal/flush-row.d.ts +2 -0
  138. package/lib/typescript/src/internal/flush-row.d.ts.map +1 -0
  139. package/lib/typescript/src/internal/pressable-base.d.ts +2 -1
  140. package/lib/typescript/src/internal/pressable-base.d.ts.map +1 -1
  141. package/lib/typescript/src/internal/tab-icon-pairs.d.ts +23 -0
  142. package/lib/typescript/src/internal/tab-icon-pairs.d.ts.map +1 -0
  143. package/lib/typescript/src/sortable/block-strip.d.ts +14 -0
  144. package/lib/typescript/src/sortable/block-strip.d.ts.map +1 -0
  145. package/lib/typescript/src/sortable/index.d.ts +1 -0
  146. package/lib/typescript/src/sortable/index.d.ts.map +1 -1
  147. package/lib/typescript/src/templates/index.d.ts +2 -0
  148. package/lib/typescript/src/templates/index.d.ts.map +1 -1
  149. package/lib/typescript/src/templates/parts.d.ts +2 -1
  150. package/lib/typescript/src/templates/parts.d.ts.map +1 -1
  151. package/lib/typescript/src/templates/sheet-form-template.d.ts +31 -0
  152. package/lib/typescript/src/templates/sheet-form-template.d.ts.map +1 -0
  153. package/lib/typescript/src/theme/base.d.ts +4 -4
  154. package/package.json +1 -1
  155. package/src/blocks/cover-photos/cover-photos.tsx +176 -0
  156. package/src/blocks/cover-photos/index.ts +5 -0
  157. package/src/blocks/detail-editor/compare-slider.tsx +112 -0
  158. package/src/blocks/detail-editor/detail-canvas.tsx +369 -0
  159. package/src/blocks/detail-editor/detail-composer.tsx +261 -0
  160. package/src/blocks/detail-editor/detail-editor-template.tsx +109 -0
  161. package/src/blocks/detail-editor/detail-types.ts +113 -0
  162. package/src/blocks/detail-editor/draft-preview.tsx +34 -0
  163. package/src/blocks/detail-editor/draft-strip.tsx +102 -0
  164. package/src/blocks/detail-editor/editor-bar.tsx +116 -0
  165. package/src/blocks/detail-editor/focus-context.ts +7 -0
  166. package/src/blocks/detail-editor/font-picker.tsx +75 -0
  167. package/src/blocks/detail-editor/index.ts +57 -0
  168. package/src/blocks/detail-editor/layout-picker.tsx +158 -0
  169. package/src/blocks/detail-editor/photo-tray.tsx +140 -0
  170. package/src/blocks/detail-editor/structure-picker.tsx +75 -0
  171. package/src/blocks/detail-editor/tool-row.tsx +66 -0
  172. package/src/blocks/index.tsx +3 -0
  173. package/src/blocks/slider-list/index.ts +5 -0
  174. package/src/blocks/slider-list/slider-list.tsx +57 -0
  175. package/src/blocks/task-tiles/task-tiles.tsx +1 -1
  176. package/src/charts/mini-bars.tsx +1 -1
  177. package/src/components/button/button.tsx +10 -3
  178. package/src/components/floating-tab-bar/floating-tab-bar.tsx +121 -0
  179. package/src/components/floating-tab-bar/index.ts +7 -0
  180. package/src/components/list-row/list-row.tsx +7 -1
  181. package/src/components/section-tabs/index.ts +5 -0
  182. package/src/components/section-tabs/section-tabs.tsx +87 -0
  183. package/src/components/slider/index.ts +1 -0
  184. package/src/components/slider/slider.tsx +142 -0
  185. package/src/index.tsx +3 -0
  186. package/src/internal/flush-row.ts +3 -0
  187. package/src/internal/pressable-base.tsx +3 -1
  188. package/src/internal/tab-icon-pairs.ts +22 -0
  189. package/src/sortable/block-strip.tsx +168 -0
  190. package/src/sortable/index.ts +5 -0
  191. package/src/templates/index.ts +5 -0
  192. package/src/templates/parts.tsx +46 -1
  193. package/src/templates/sheet-form-template.tsx +190 -0
  194. package/src/theme/base.ts +4 -4
@@ -0,0 +1,261 @@
1
+ import { Image, ScrollView, TextInput, View } from 'react-native';
2
+ import { Text } from '../../components/text/text';
3
+ import {
4
+ CameraGlyph,
5
+ CloseGlyph,
6
+ ImageGlyph,
7
+ LinkGlyph,
8
+ ScanGlyph,
9
+ SparklesGlyph,
10
+ } from '../../internal/glyphs';
11
+ import { renderIcon, type IconSlot } from '../../internal/icon';
12
+ import { PressableBase } from '../../internal/pressable-base';
13
+ import { useTheme } from '../../theme/theme-provider';
14
+ import { makeStyles } from '../../utils/styles';
15
+
16
+ export type ComposerAttachment = {
17
+ key: string;
18
+ kind: 'image' | 'link';
19
+ uri?: string;
20
+ label?: string;
21
+ reference?: boolean;
22
+ };
23
+
24
+ export type ComposerSource = 'library' | 'camera' | 'capture' | 'link';
25
+
26
+ export type DetailComposerProps = {
27
+ value: string;
28
+ onChangeText: (text: string) => void;
29
+ placeholder: string;
30
+ onSend: () => void;
31
+ sending?: boolean;
32
+ disabled?: boolean;
33
+ attachments?: readonly ComposerAttachment[];
34
+ onRemove?: (key: string) => void;
35
+ onAttach?: (source: ComposerSource) => void;
36
+ menuOpen?: boolean;
37
+ onMenuOpenChange?: (open: boolean) => void;
38
+ suggestions?: readonly string[];
39
+ onSuggestion?: (text: string) => void;
40
+ };
41
+
42
+ const SOURCES: { key: ComposerSource; label: string; icon: IconSlot }[] = [
43
+ { key: 'library', label: '사진', icon: ImageGlyph },
44
+ { key: 'camera', label: '촬영', icon: CameraGlyph },
45
+ { key: 'capture', label: '캡처', icon: ScanGlyph },
46
+ { key: 'link', label: '링크', icon: LinkGlyph },
47
+ ];
48
+
49
+ const THUMB = 44;
50
+ const BUTTON = 40;
51
+
52
+ const useStyles = makeStyles((t) => ({
53
+ root: { gap: t.space[2], paddingHorizontal: t.space[3] },
54
+ box: {
55
+ gap: t.space[2],
56
+ padding: t.space[2],
57
+ borderRadius: t.radius.lg,
58
+ borderWidth: 1,
59
+ borderColor: t.colors.border,
60
+ backgroundColor: t.colors.surface,
61
+ },
62
+ attached: { gap: t.space[2], paddingHorizontal: t.space[1] },
63
+ thumb: { width: THUMB, height: THUMB, borderRadius: t.radius.md },
64
+ reference: { borderWidth: 2, borderColor: t.colors.primary },
65
+ link: {
66
+ flexDirection: 'row',
67
+ alignItems: 'center',
68
+ gap: t.space[1],
69
+ height: THUMB,
70
+ paddingHorizontal: t.space[3],
71
+ borderRadius: t.radius.md,
72
+ backgroundColor: t.colors.muted,
73
+ },
74
+ remove: {
75
+ position: 'absolute',
76
+ right: -t.space[1],
77
+ top: -t.space[1],
78
+ width: t.space[5],
79
+ height: t.space[5],
80
+ borderRadius: t.radius.full,
81
+ alignItems: 'center',
82
+ justifyContent: 'center',
83
+ backgroundColor: t.colors.foreground,
84
+ },
85
+ line: { flexDirection: 'row', alignItems: 'center', gap: t.space[2] },
86
+ round: {
87
+ width: BUTTON,
88
+ height: BUTTON,
89
+ borderRadius: t.radius.full,
90
+ alignItems: 'center',
91
+ justifyContent: 'center',
92
+ },
93
+ input: {
94
+ flex: 1,
95
+ fontSize: t.typography.body.fontSize,
96
+ color: t.colors.foreground,
97
+ paddingVertical: t.space[2],
98
+ },
99
+ plusH: { position: 'absolute', width: t.space[4], height: 2 },
100
+ plusV: { position: 'absolute', width: 2, height: t.space[4] },
101
+ sources: { flexDirection: 'row', justifyContent: 'space-around' },
102
+ source: { alignItems: 'center', gap: t.space[1], width: t.space[16] },
103
+ chips: { gap: t.space[2], paddingHorizontal: t.space[3] },
104
+ chip: {
105
+ height: t.controlSize.sm - t.space[2],
106
+ paddingHorizontal: t.space[4],
107
+ borderRadius: t.radius.full,
108
+ justifyContent: 'center',
109
+ borderWidth: 1,
110
+ borderColor: t.colors.border,
111
+ backgroundColor: t.colors.surface,
112
+ },
113
+ }));
114
+
115
+ export function DetailComposer({
116
+ value,
117
+ onChangeText,
118
+ placeholder,
119
+ onSend,
120
+ sending,
121
+ disabled,
122
+ attachments = [],
123
+ onRemove,
124
+ onAttach,
125
+ menuOpen,
126
+ onMenuOpenChange,
127
+ suggestions = [],
128
+ onSuggestion,
129
+ }: DetailComposerProps) {
130
+ const t = useTheme();
131
+ const s = useStyles();
132
+ const canSend = !disabled && !sending;
133
+ const plusColor = menuOpen ? t.colors.primaryForeground : t.colors.foreground;
134
+ return (
135
+ <View style={s.root}>
136
+ {suggestions.length ? (
137
+ <ScrollView
138
+ horizontal
139
+ showsHorizontalScrollIndicator={false}
140
+ contentContainerStyle={s.chips}
141
+ >
142
+ {suggestions.map((text) => (
143
+ <PressableBase
144
+ key={text}
145
+ onPress={() => onSuggestion?.(text)}
146
+ accessibilityLabel={text}
147
+ style={s.chip}
148
+ >
149
+ <Text variant="label">{text}</Text>
150
+ </PressableBase>
151
+ ))}
152
+ </ScrollView>
153
+ ) : null}
154
+ {menuOpen ? (
155
+ <View style={s.sources}>
156
+ {SOURCES.map((src) => (
157
+ <PressableBase
158
+ key={src.key}
159
+ onPress={() => onAttach?.(src.key)}
160
+ accessibilityLabel={src.label}
161
+ style={s.source}
162
+ >
163
+ <View style={[s.round, { backgroundColor: t.colors.surface }]}>
164
+ {renderIcon(src.icon, {
165
+ color: t.colors.foreground,
166
+ size: t.iconSize.md,
167
+ })}
168
+ </View>
169
+ <Text variant="caption">{src.label}</Text>
170
+ </PressableBase>
171
+ ))}
172
+ </View>
173
+ ) : null}
174
+ <View style={s.box}>
175
+ {attachments.length ? (
176
+ <ScrollView
177
+ horizontal
178
+ showsHorizontalScrollIndicator={false}
179
+ contentContainerStyle={s.attached}
180
+ >
181
+ {attachments.map((a) => (
182
+ <View key={a.key}>
183
+ {a.kind === 'image' ? (
184
+ <Image
185
+ source={{ uri: a.uri }}
186
+ style={[s.thumb, a.reference && s.reference]}
187
+ />
188
+ ) : (
189
+ <View style={s.link}>
190
+ {renderIcon(LinkGlyph, {
191
+ color: t.colors.mutedForeground,
192
+ size: t.iconSize.sm,
193
+ })}
194
+ <Text variant="caption" numberOfLines={1}>
195
+ {a.label ?? ''}
196
+ </Text>
197
+ </View>
198
+ )}
199
+ {onRemove ? (
200
+ <PressableBase
201
+ onPress={() => onRemove(a.key)}
202
+ accessibilityLabel="빼기"
203
+ touchHeight={t.space[5]}
204
+ style={s.remove}
205
+ >
206
+ <CloseGlyph
207
+ color={t.colors.surface}
208
+ size={t.iconSize.sm - t.space[1]}
209
+ />
210
+ </PressableBase>
211
+ ) : null}
212
+ </View>
213
+ ))}
214
+ </ScrollView>
215
+ ) : null}
216
+ <View style={s.line}>
217
+ {onAttach ? (
218
+ <PressableBase
219
+ onPress={() => onMenuOpenChange?.(!menuOpen)}
220
+ accessibilityLabel="첨부"
221
+ style={[
222
+ s.round,
223
+ {
224
+ backgroundColor: menuOpen ? t.colors.primary : t.colors.muted,
225
+ },
226
+ ]}
227
+ >
228
+ <View style={[s.plusH, { backgroundColor: plusColor }]} />
229
+ <View style={[s.plusV, { backgroundColor: plusColor }]} />
230
+ </PressableBase>
231
+ ) : null}
232
+ <TextInput
233
+ value={value}
234
+ onChangeText={onChangeText}
235
+ placeholder={placeholder}
236
+ placeholderTextColor={t.colors.mutedForeground}
237
+ maxFontSizeMultiplier={t.maxFontScale}
238
+ style={s.input}
239
+ multiline
240
+ />
241
+ <PressableBase
242
+ onPress={onSend}
243
+ disabled={!canSend}
244
+ accessibilityLabel="만들기"
245
+ style={[
246
+ s.round,
247
+ {
248
+ backgroundColor: canSend ? t.colors.primary : t.colors.input,
249
+ },
250
+ ]}
251
+ >
252
+ {renderIcon(SparklesGlyph, {
253
+ color: t.colors.primaryForeground,
254
+ size: t.iconSize.md,
255
+ })}
256
+ </PressableBase>
257
+ </View>
258
+ </View>
259
+ </View>
260
+ );
261
+ }
@@ -0,0 +1,109 @@
1
+ import {
2
+ useEffect,
3
+ useRef,
4
+ useState,
5
+ type ComponentRef,
6
+ type ReactNode,
7
+ } from 'react';
8
+ import { ScrollView, View } from 'react-native';
9
+ import { useTheme } from '../../theme/theme-provider';
10
+ import { makeStyles } from '../../utils/styles';
11
+ import { DetailFocusContext, type DetailFocusRect } from './focus-context';
12
+
13
+ export type DetailEditorTemplateProps = {
14
+ bar: ReactNode;
15
+ children: ReactNode;
16
+ bottom?: ReactNode;
17
+ bottomInset?: number;
18
+ wide?: boolean;
19
+ };
20
+
21
+ const useStyles = makeStyles((t) => ({
22
+ root: { flex: 1, backgroundColor: t.colors.muted },
23
+ scroll: { paddingVertical: t.space[3] },
24
+ page: {
25
+ alignSelf: 'center',
26
+ width: '86%',
27
+ boxShadow: t.shadow.md,
28
+ },
29
+ wide: { alignSelf: 'stretch', width: '100%', boxShadow: undefined },
30
+ bottom: { gap: t.space[3], paddingTop: t.space[2] },
31
+ panel: { gap: t.space[3], paddingHorizontal: t.layout.screenX },
32
+ }));
33
+
34
+ export function DetailEditorTemplate({
35
+ bar,
36
+ children,
37
+ bottom,
38
+ bottomInset = 0,
39
+ wide,
40
+ }: DetailEditorTemplateProps) {
41
+ const t = useTheme();
42
+ const s = useStyles();
43
+ const scroller = useRef<ComponentRef<typeof ScrollView>>(null);
44
+ const offset = useRef(0);
45
+ const pageTop = useRef(0);
46
+ const [viewport, setViewport] = useState(0);
47
+ const [focus, setFocus] = useState<DetailFocusRect | null>(null);
48
+ const report = useRef((rect: DetailFocusRect | null) =>
49
+ setFocus((now) =>
50
+ now === rect ||
51
+ (now && rect && now.y === rect.y && now.height === rect.height)
52
+ ? now
53
+ : rect
54
+ )
55
+ ).current;
56
+ const margin = t.space[4];
57
+
58
+ useEffect(() => {
59
+ if (!focus || viewport <= 0) return;
60
+ const top = pageTop.current + focus.y - margin;
61
+ const end = pageTop.current + focus.y + focus.height + margin;
62
+ const now = offset.current;
63
+ const next =
64
+ end - top > viewport || top < now
65
+ ? top
66
+ : end > now + viewport
67
+ ? end - viewport
68
+ : now;
69
+ if (next !== now) {
70
+ scroller.current?.scrollTo({ y: Math.max(0, next), animated: true });
71
+ }
72
+ }, [focus, viewport, margin]);
73
+
74
+ return (
75
+ <View style={s.root}>
76
+ {bar}
77
+ <ScrollView
78
+ ref={scroller}
79
+ contentContainerStyle={s.scroll}
80
+ scrollEventThrottle={16}
81
+ onScroll={(e) => {
82
+ offset.current = e.nativeEvent.contentOffset.y;
83
+ }}
84
+ onLayout={(e) => setViewport(e.nativeEvent.layout.height)}
85
+ >
86
+ <DetailFocusContext.Provider value={report}>
87
+ <View
88
+ style={[s.page, wide && s.wide]}
89
+ onLayout={(e) => {
90
+ pageTop.current = e.nativeEvent.layout.y;
91
+ }}
92
+ >
93
+ {children}
94
+ </View>
95
+ </DetailFocusContext.Provider>
96
+ </ScrollView>
97
+ {bottom ? (
98
+ <View style={[s.bottom, { paddingBottom: bottomInset + t.space[3] }]}>
99
+ {bottom}
100
+ </View>
101
+ ) : null}
102
+ </View>
103
+ );
104
+ }
105
+
106
+ export function EditorPanel({ children }: { children: ReactNode }) {
107
+ const s = useStyles();
108
+ return <View style={s.panel}>{children}</View>;
109
+ }
@@ -0,0 +1,113 @@
1
+ export type DetailFont = 'gothic' | 'serif' | 'display' | 'hand';
2
+ export type DetailWeight = 'regular' | 'bold' | 'heavy';
3
+ export type DetailEffect = 'none' | 'shadow' | 'outline' | 'band';
4
+ export type DetailLayout =
5
+ 'text' | 'image' | 'image_top' | 'text_top' | 'side' | 'two_images' | 'card';
6
+
7
+ export type DetailTextStyle = {
8
+ font?: DetailFont;
9
+ size?: number;
10
+ weight?: DetailWeight;
11
+ color?: string;
12
+ align?: 'left' | 'center' | 'right';
13
+ effect?: DetailEffect;
14
+ line?: number;
15
+ tracking?: number;
16
+ };
17
+
18
+ export type DetailLayer = {
19
+ id: string;
20
+ type: 'text' | 'image';
21
+ text?: string | null;
22
+ url?: string | null;
23
+ asset_id?: string | null;
24
+ style?: DetailTextStyle | null;
25
+ hidden?: boolean;
26
+ };
27
+
28
+ export type DetailBlock = {
29
+ id: string;
30
+ layout: DetailLayout;
31
+ background?: {
32
+ color?: string | null;
33
+ url?: string | null;
34
+ asset_id?: string | null;
35
+ };
36
+ space_top?: number;
37
+ space_bottom?: number;
38
+ layers: DetailLayer[];
39
+ };
40
+
41
+ export type DetailDocValue = {
42
+ version?: number;
43
+ background?: string | null;
44
+ blocks: DetailBlock[];
45
+ };
46
+
47
+ export type DetailSelection = { block: string; layer?: string } | null;
48
+
49
+ export const DETAIL_LAYOUTS: readonly DetailLayout[] = [
50
+ 'image_top',
51
+ 'text_top',
52
+ 'side',
53
+ 'image',
54
+ 'two_images',
55
+ 'card',
56
+ 'text',
57
+ ];
58
+
59
+ export const DETAIL_FONT_FAMILY: Record<
60
+ DetailFont,
61
+ Record<DetailWeight, string>
62
+ > = {
63
+ gothic: {
64
+ regular: 'Pretendard-Regular',
65
+ bold: 'Pretendard-Bold',
66
+ heavy: 'Pretendard-ExtraBold',
67
+ },
68
+ serif: {
69
+ regular: 'NanumMyeongjo',
70
+ bold: 'NanumMyeongjoBold',
71
+ heavy: 'NanumMyeongjoBold',
72
+ },
73
+ display: {
74
+ regular: 'BlackHanSans-Regular',
75
+ bold: 'BlackHanSans-Regular',
76
+ heavy: 'BlackHanSans-Regular',
77
+ },
78
+ hand: {
79
+ regular: 'NanumPen-Regular',
80
+ bold: 'NanumPen-Regular',
81
+ heavy: 'NanumPen-Regular',
82
+ },
83
+ };
84
+
85
+ const clamp = (value: number, lo: number, hi: number) =>
86
+ Math.min(hi, Math.max(lo, value));
87
+
88
+ export function detailFontSize(size = 5): number {
89
+ return 12 + (clamp(size, 1, 10) - 1) * 2;
90
+ }
91
+
92
+ export function detailLineHeight(line = 5): number {
93
+ return 1.05 + clamp(line, 1, 10) * 0.08;
94
+ }
95
+
96
+ export function detailTracking(tracking = 0): number {
97
+ return clamp(tracking, -5, 10) * 0.01;
98
+ }
99
+
100
+ export function detailBlockSpace(space = 0): number {
101
+ return clamp(space, 0, 10) * 8;
102
+ }
103
+
104
+ export const DETAIL_COLORS: readonly { value: string; label: string }[] = [
105
+ { value: '#1A1A1A', label: '잉크' },
106
+ { value: '#FFFFFF', label: '흰색' },
107
+ { value: '#F4F4F5', label: '연회색' },
108
+ { value: '#EFE7DC', label: '베이지' },
109
+ { value: '#3B2F25', label: '고동' },
110
+ { value: '#C54211', label: '주황' },
111
+ { value: '#2F4A2B', label: '초록' },
112
+ { value: '#1F3A5F', label: '남색' },
113
+ ];
@@ -0,0 +1,34 @@
1
+ import type { ReactNode } from 'react';
2
+ import { View } from 'react-native';
3
+ import { makeStyles } from '../../utils/styles';
4
+
5
+ export type DraftPreviewProps = {
6
+ height: number;
7
+ width: number;
8
+ children: ReactNode;
9
+ };
10
+
11
+ const useStyles = makeStyles((t) => ({
12
+ box: {
13
+ overflow: 'hidden',
14
+ alignItems: 'center',
15
+ paddingTop: t.space[4],
16
+ borderRadius: t.radius.lg,
17
+ backgroundColor: t.colors.muted,
18
+ },
19
+ page: {
20
+ overflow: 'hidden',
21
+ borderTopLeftRadius: t.radius.sm,
22
+ borderTopRightRadius: t.radius.sm,
23
+ backgroundColor: t.colors.surface,
24
+ },
25
+ }));
26
+
27
+ export function DraftPreview({ height, width, children }: DraftPreviewProps) {
28
+ const s = useStyles();
29
+ return (
30
+ <View style={[s.box, { height }]}>
31
+ <View style={[s.page, { width }]}>{children}</View>
32
+ </View>
33
+ );
34
+ }
@@ -0,0 +1,102 @@
1
+ import type { ReactNode } from 'react';
2
+ import { ScrollView, View } from 'react-native';
3
+ import { Text } from '../../components/text/text';
4
+ import { SparklesGlyph } from '../../internal/glyphs';
5
+ import { PressableBase } from '../../internal/pressable-base';
6
+ import { useTheme } from '../../theme/theme-provider';
7
+ import { makeStyles } from '../../utils/styles';
8
+
9
+ export type DraftStripItem = { key: string; label: string; thumb: ReactNode };
10
+
11
+ export type DraftStripProps = {
12
+ items: readonly DraftStripItem[];
13
+ value: string;
14
+ onValueChange: (key: string) => void;
15
+ onMore?: () => void;
16
+ moreLabel?: string;
17
+ };
18
+
19
+ const W = 64;
20
+ const H = 100;
21
+
22
+ const useStyles = makeStyles((t) => ({
23
+ row: { gap: t.space[2], paddingHorizontal: t.space[3] },
24
+ item: { gap: t.space[1], alignItems: 'center' },
25
+ frame: {
26
+ width: W,
27
+ height: H,
28
+ overflow: 'hidden',
29
+ borderRadius: t.radius.sm,
30
+ borderWidth: 1,
31
+ borderColor: t.colors.border,
32
+ backgroundColor: t.colors.surface,
33
+ },
34
+ on: { borderWidth: 3, borderColor: t.colors.primary },
35
+ more: {
36
+ width: W,
37
+ height: H,
38
+ borderRadius: t.radius.sm,
39
+ borderWidth: 1,
40
+ borderStyle: 'dashed',
41
+ borderColor: t.colors.input,
42
+ alignItems: 'center',
43
+ justifyContent: 'center',
44
+ },
45
+ }));
46
+
47
+ export function DraftStrip({
48
+ items,
49
+ value,
50
+ onValueChange,
51
+ onMore,
52
+ moreLabel = '더 만들기',
53
+ }: DraftStripProps) {
54
+ const t = useTheme();
55
+ const s = useStyles();
56
+ return (
57
+ <ScrollView
58
+ horizontal
59
+ showsHorizontalScrollIndicator={false}
60
+ contentContainerStyle={s.row}
61
+ accessibilityRole="tablist"
62
+ >
63
+ {items.map((item) => {
64
+ const on = item.key === value;
65
+ return (
66
+ <PressableBase
67
+ key={item.key}
68
+ accessibilityRole="tab"
69
+ accessibilityState={{ selected: on }}
70
+ accessibilityLabel={item.label}
71
+ onPress={() => onValueChange(item.key)}
72
+ style={s.item}
73
+ >
74
+ <View style={[s.frame, on && s.on]}>{item.thumb}</View>
75
+ <Text variant="caption" tone={on ? 'default' : 'muted'}>
76
+ {item.label}
77
+ </Text>
78
+ </PressableBase>
79
+ );
80
+ })}
81
+ {onMore ? (
82
+ <PressableBase
83
+ onPress={onMore}
84
+ accessibilityLabel={moreLabel}
85
+ style={s.item}
86
+ >
87
+ <View style={s.more}>
88
+ <SparklesGlyph
89
+ color={t.colors.mutedForeground}
90
+ size={t.iconSize.md}
91
+ />
92
+ </View>
93
+ <Text variant="caption" tone="muted">
94
+ {moreLabel}
95
+ </Text>
96
+ </PressableBase>
97
+ ) : null}
98
+ </ScrollView>
99
+ );
100
+ }
101
+
102
+ export const DRAFT_THUMB_WIDTH = W;