@ezpg/app-ui 0.15.0 → 0.17.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 (141) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/lib/module/adjust/dial-strip.js +2 -2
  3. package/lib/module/blocks/detail-editor/compare-slider.js +117 -0
  4. package/lib/module/blocks/detail-editor/compare-slider.js.map +1 -0
  5. package/lib/module/blocks/detail-editor/detail-canvas.js +339 -0
  6. package/lib/module/blocks/detail-editor/detail-canvas.js.map +1 -0
  7. package/lib/module/blocks/detail-editor/detail-composer.js +254 -0
  8. package/lib/module/blocks/detail-editor/detail-composer.js.map +1 -0
  9. package/lib/module/blocks/detail-editor/detail-editor-template.js +102 -0
  10. package/lib/module/blocks/detail-editor/detail-editor-template.js.map +1 -0
  11. package/lib/module/blocks/detail-editor/detail-types.js +64 -0
  12. package/lib/module/blocks/detail-editor/detail-types.js.map +1 -0
  13. package/lib/module/blocks/detail-editor/draft-strip.js +97 -0
  14. package/lib/module/blocks/detail-editor/draft-strip.js.map +1 -0
  15. package/lib/module/blocks/detail-editor/editor-bar.js +96 -0
  16. package/lib/module/blocks/detail-editor/editor-bar.js.map +1 -0
  17. package/lib/module/blocks/detail-editor/focus-context.js +5 -0
  18. package/lib/module/blocks/detail-editor/focus-context.js.map +1 -0
  19. package/lib/module/blocks/detail-editor/font-picker.js +74 -0
  20. package/lib/module/blocks/detail-editor/font-picker.js.map +1 -0
  21. package/lib/module/blocks/detail-editor/index.js +14 -0
  22. package/lib/module/blocks/detail-editor/index.js.map +1 -0
  23. package/lib/module/blocks/detail-editor/layout-picker.js +173 -0
  24. package/lib/module/blocks/detail-editor/layout-picker.js.map +1 -0
  25. package/lib/module/blocks/detail-editor/photo-tray.js +144 -0
  26. package/lib/module/blocks/detail-editor/photo-tray.js.map +1 -0
  27. package/lib/module/blocks/detail-editor/tool-row.js +63 -0
  28. package/lib/module/blocks/detail-editor/tool-row.js.map +1 -0
  29. package/lib/module/blocks/index.js +1 -0
  30. package/lib/module/blocks/index.js.map +1 -1
  31. package/lib/module/blocks/invite-card/invite-card.js +0 -2
  32. package/lib/module/blocks/invite-card/invite-card.js.map +1 -1
  33. package/lib/module/blocks/task-tiles/task-tiles.js +1 -1
  34. package/lib/module/blocks/task-tiles/task-tiles.js.map +1 -1
  35. package/lib/module/charts/mini-bars.js +1 -1
  36. package/lib/module/charts/mini-bars.js.map +1 -1
  37. package/lib/module/components/button/button.js +10 -3
  38. package/lib/module/components/button/button.js.map +1 -1
  39. package/lib/module/components/floating-tab-bar/floating-tab-bar.js +103 -0
  40. package/lib/module/components/floating-tab-bar/floating-tab-bar.js.map +1 -0
  41. package/lib/module/components/floating-tab-bar/index.js +4 -0
  42. package/lib/module/components/floating-tab-bar/index.js.map +1 -0
  43. package/lib/module/components/list-row/list-row.js +1 -1
  44. package/lib/module/components/list-row/list-row.js.map +1 -1
  45. package/lib/module/components/slider/index.js +4 -0
  46. package/lib/module/components/slider/index.js.map +1 -0
  47. package/lib/module/components/slider/slider.js +151 -0
  48. package/lib/module/components/slider/slider.js.map +1 -0
  49. package/lib/module/index.js +2 -0
  50. package/lib/module/index.js.map +1 -1
  51. package/lib/module/internal/pressable-base.js +3 -2
  52. package/lib/module/internal/pressable-base.js.map +1 -1
  53. package/lib/module/internal/tab-icon-pairs.js +25 -0
  54. package/lib/module/internal/tab-icon-pairs.js.map +1 -0
  55. package/lib/module/sortable/block-strip.js +151 -0
  56. package/lib/module/sortable/block-strip.js.map +1 -0
  57. package/lib/module/sortable/index.js +1 -0
  58. package/lib/module/sortable/index.js.map +1 -1
  59. package/lib/module/templates/parts.js +1 -1
  60. package/lib/module/theme/base.js +17 -17
  61. package/lib/typescript/src/blocks/detail-editor/compare-slider.d.ts +8 -0
  62. package/lib/typescript/src/blocks/detail-editor/compare-slider.d.ts.map +1 -0
  63. package/lib/typescript/src/blocks/detail-editor/detail-canvas.d.ts +13 -0
  64. package/lib/typescript/src/blocks/detail-editor/detail-canvas.d.ts.map +1 -0
  65. package/lib/typescript/src/blocks/detail-editor/detail-composer.d.ts +25 -0
  66. package/lib/typescript/src/blocks/detail-editor/detail-composer.d.ts.map +1 -0
  67. package/lib/typescript/src/blocks/detail-editor/detail-editor-template.d.ts +13 -0
  68. package/lib/typescript/src/blocks/detail-editor/detail-editor-template.d.ts.map +1 -0
  69. package/lib/typescript/src/blocks/detail-editor/detail-types.d.ts +55 -0
  70. package/lib/typescript/src/blocks/detail-editor/detail-types.d.ts.map +1 -0
  71. package/lib/typescript/src/blocks/detail-editor/draft-strip.d.ts +16 -0
  72. package/lib/typescript/src/blocks/detail-editor/draft-strip.d.ts.map +1 -0
  73. package/lib/typescript/src/blocks/detail-editor/editor-bar.d.ts +18 -0
  74. package/lib/typescript/src/blocks/detail-editor/editor-bar.d.ts.map +1 -0
  75. package/lib/typescript/src/blocks/detail-editor/focus-context.d.ts +6 -0
  76. package/lib/typescript/src/blocks/detail-editor/focus-context.d.ts.map +1 -0
  77. package/lib/typescript/src/blocks/detail-editor/font-picker.d.ts +8 -0
  78. package/lib/typescript/src/blocks/detail-editor/font-picker.d.ts.map +1 -0
  79. package/lib/typescript/src/blocks/detail-editor/index.d.ts +12 -0
  80. package/lib/typescript/src/blocks/detail-editor/index.d.ts.map +1 -0
  81. package/lib/typescript/src/blocks/detail-editor/layout-picker.d.ts +8 -0
  82. package/lib/typescript/src/blocks/detail-editor/layout-picker.d.ts.map +1 -0
  83. package/lib/typescript/src/blocks/detail-editor/photo-tray.d.ts +15 -0
  84. package/lib/typescript/src/blocks/detail-editor/photo-tray.d.ts.map +1 -0
  85. package/lib/typescript/src/blocks/detail-editor/tool-row.d.ts +13 -0
  86. package/lib/typescript/src/blocks/detail-editor/tool-row.d.ts.map +1 -0
  87. package/lib/typescript/src/blocks/index.d.ts +1 -0
  88. package/lib/typescript/src/blocks/index.d.ts.map +1 -1
  89. package/lib/typescript/src/blocks/invite-card/invite-card.d.ts.map +1 -1
  90. package/lib/typescript/src/components/button/button.d.ts.map +1 -1
  91. package/lib/typescript/src/components/floating-tab-bar/floating-tab-bar.d.ts +20 -0
  92. package/lib/typescript/src/components/floating-tab-bar/floating-tab-bar.d.ts.map +1 -0
  93. package/lib/typescript/src/components/floating-tab-bar/index.d.ts +2 -0
  94. package/lib/typescript/src/components/floating-tab-bar/index.d.ts.map +1 -0
  95. package/lib/typescript/src/components/slider/index.d.ts +2 -0
  96. package/lib/typescript/src/components/slider/index.d.ts.map +1 -0
  97. package/lib/typescript/src/components/slider/slider.d.ts +14 -0
  98. package/lib/typescript/src/components/slider/slider.d.ts.map +1 -0
  99. package/lib/typescript/src/index.d.ts +2 -0
  100. package/lib/typescript/src/index.d.ts.map +1 -1
  101. package/lib/typescript/src/internal/pressable-base.d.ts +2 -1
  102. package/lib/typescript/src/internal/pressable-base.d.ts.map +1 -1
  103. package/lib/typescript/src/internal/tab-icon-pairs.d.ts +23 -0
  104. package/lib/typescript/src/internal/tab-icon-pairs.d.ts.map +1 -0
  105. package/lib/typescript/src/sortable/block-strip.d.ts +14 -0
  106. package/lib/typescript/src/sortable/block-strip.d.ts.map +1 -0
  107. package/lib/typescript/src/sortable/index.d.ts +1 -0
  108. package/lib/typescript/src/sortable/index.d.ts.map +1 -1
  109. package/lib/typescript/src/theme/base.d.ts +17 -17
  110. package/package.json +1 -1
  111. package/src/adjust/dial-strip.tsx +2 -2
  112. package/src/blocks/detail-editor/compare-slider.tsx +112 -0
  113. package/src/blocks/detail-editor/detail-canvas.tsx +369 -0
  114. package/src/blocks/detail-editor/detail-composer.tsx +261 -0
  115. package/src/blocks/detail-editor/detail-editor-template.tsx +109 -0
  116. package/src/blocks/detail-editor/detail-types.ts +113 -0
  117. package/src/blocks/detail-editor/draft-strip.tsx +102 -0
  118. package/src/blocks/detail-editor/editor-bar.tsx +116 -0
  119. package/src/blocks/detail-editor/focus-context.ts +7 -0
  120. package/src/blocks/detail-editor/font-picker.tsx +75 -0
  121. package/src/blocks/detail-editor/index.ts +51 -0
  122. package/src/blocks/detail-editor/layout-picker.tsx +158 -0
  123. package/src/blocks/detail-editor/photo-tray.tsx +140 -0
  124. package/src/blocks/detail-editor/tool-row.tsx +66 -0
  125. package/src/blocks/index.tsx +1 -0
  126. package/src/blocks/invite-card/invite-card.tsx +2 -4
  127. package/src/blocks/task-tiles/task-tiles.tsx +1 -1
  128. package/src/charts/mini-bars.tsx +1 -1
  129. package/src/components/button/button.tsx +10 -3
  130. package/src/components/floating-tab-bar/floating-tab-bar.tsx +121 -0
  131. package/src/components/floating-tab-bar/index.ts +7 -0
  132. package/src/components/list-row/list-row.tsx +1 -1
  133. package/src/components/slider/index.ts +1 -0
  134. package/src/components/slider/slider.tsx +142 -0
  135. package/src/index.tsx +2 -0
  136. package/src/internal/pressable-base.tsx +3 -1
  137. package/src/internal/tab-icon-pairs.ts +22 -0
  138. package/src/sortable/block-strip.tsx +168 -0
  139. package/src/sortable/index.ts +5 -0
  140. package/src/templates/parts.tsx +1 -1
  141. package/src/theme/base.ts +17 -17
@@ -0,0 +1,369 @@
1
+ import {
2
+ createContext,
3
+ useContext,
4
+ useEffect,
5
+ useMemo,
6
+ useRef,
7
+ type ComponentRef,
8
+ type ReactNode,
9
+ type RefObject,
10
+ } from 'react';
11
+ import {
12
+ Image,
13
+ Text as RNText,
14
+ View,
15
+ type StyleProp,
16
+ type TextStyle,
17
+ type ViewStyle,
18
+ } from 'react-native';
19
+ import { PressableBase } from '../../internal/pressable-base';
20
+ import { useTheme } from '../../theme/theme-provider';
21
+ import { makeStyles } from '../../utils/styles';
22
+ import { DetailFocusContext, type DetailFocusRect } from './focus-context';
23
+ import {
24
+ DETAIL_FONT_FAMILY,
25
+ detailBlockSpace,
26
+ detailFontSize,
27
+ detailLineHeight,
28
+ detailTracking,
29
+ type DetailBlock,
30
+ type DetailDocValue,
31
+ type DetailLayer,
32
+ type DetailSelection,
33
+ } from './detail-types';
34
+
35
+ export type DetailCanvasProps = {
36
+ doc: DetailDocValue;
37
+ selection?: DetailSelection;
38
+ onSelect?: (selection: DetailSelection) => void;
39
+ scale?: number;
40
+ ink?: string;
41
+ paper?: string;
42
+ };
43
+
44
+ const HANDLE = 10;
45
+
46
+ type TapProps = {
47
+ onPress?: () => void;
48
+ label: string;
49
+ style?: StyleProp<ViewStyle>;
50
+ children?: ReactNode;
51
+ };
52
+
53
+ function Tap({ onPress, label, style, children }: TapProps) {
54
+ if (!onPress) {
55
+ return <View style={style}>{children}</View>;
56
+ }
57
+ return (
58
+ <PressableBase
59
+ onPress={onPress}
60
+ accessibilityLabel={label}
61
+ pressedStyle={{}}
62
+ style={style}
63
+ >
64
+ {children}
65
+ </PressableBase>
66
+ );
67
+ }
68
+
69
+ const useStyles = makeStyles((t) => ({
70
+ page: { overflow: 'hidden' },
71
+ texts: { gap: t.space[2] },
72
+ row: { flexDirection: 'row', alignItems: 'center' },
73
+ half: { flex: 1 },
74
+ full: { width: '100%' },
75
+ fill: { position: 'absolute', left: 0, right: 0, top: 0, bottom: 0 },
76
+ pair: { flexDirection: 'row', gap: t.space[2] },
77
+ card: { overflow: 'hidden', borderRadius: t.radius.lg },
78
+ ring: {
79
+ position: 'absolute',
80
+ left: 0,
81
+ right: 0,
82
+ top: 0,
83
+ bottom: 0,
84
+ borderWidth: 2,
85
+ borderColor: t.colors.primary,
86
+ },
87
+ tagText: {
88
+ fontSize: t.typography.caption.fontSize,
89
+ fontWeight: '700',
90
+ },
91
+ tag: {
92
+ position: 'absolute',
93
+ left: t.space[1],
94
+ top: t.space[1],
95
+ minWidth: t.space[6],
96
+ height: t.space[6],
97
+ borderRadius: t.radius.full,
98
+ alignItems: 'center',
99
+ justifyContent: 'center',
100
+ backgroundColor: t.colors.primary,
101
+ },
102
+ handle: {
103
+ position: 'absolute',
104
+ width: HANDLE,
105
+ height: HANDLE,
106
+ borderRadius: HANDLE / 2,
107
+ borderWidth: 2,
108
+ borderColor: t.colors.primary,
109
+ backgroundColor: t.colors.surface,
110
+ },
111
+ }));
112
+
113
+ type FocusTarget = {
114
+ root: RefObject<ComponentRef<typeof View> | null>;
115
+ report: (rect: DetailFocusRect | null) => void;
116
+ };
117
+
118
+ const FocusTargetContext = createContext<FocusTarget | null>(null);
119
+
120
+ function Handles() {
121
+ const s = useStyles();
122
+ const edge = -HANDLE / 2;
123
+ const target = useContext(FocusTargetContext);
124
+ const ring = useRef<ComponentRef<typeof View>>(null);
125
+ useEffect(() => () => target?.report(null), [target]);
126
+ const measure = () => {
127
+ const root = target?.root.current;
128
+ if (!target || !root || !ring.current) return;
129
+ ring.current.measureLayout(
130
+ root,
131
+ (_x, y, _w, height) => target.report({ y, height }),
132
+ () => undefined
133
+ );
134
+ };
135
+ return (
136
+ <>
137
+ <View ref={ring} onLayout={measure} pointerEvents="none" style={s.ring} />
138
+ <View style={[s.handle, { left: edge, top: edge }]} />
139
+ <View style={[s.handle, { right: edge, top: edge }]} />
140
+ <View style={[s.handle, { left: edge, bottom: edge }]} />
141
+ <View style={[s.handle, { right: edge, bottom: edge }]} />
142
+ </>
143
+ );
144
+ }
145
+
146
+ export function textStyleOf(
147
+ layer: DetailLayer,
148
+ scale: number,
149
+ ink: string,
150
+ paper?: string
151
+ ): TextStyle {
152
+ const st = layer.style ?? {};
153
+ const size = detailFontSize(st.size) * scale;
154
+ const color = st.color ?? ink;
155
+ const base: TextStyle = {
156
+ fontFamily: DETAIL_FONT_FAMILY[st.font ?? 'gothic'][st.weight ?? 'regular'],
157
+ fontSize: size,
158
+ lineHeight: size * detailLineHeight(st.line),
159
+ letterSpacing: size * detailTracking(st.tracking),
160
+ color,
161
+ textAlign: st.align ?? 'left',
162
+ };
163
+ if (st.effect === 'shadow') {
164
+ return {
165
+ ...base,
166
+ textShadowColor: 'rgba(0, 0, 0, 0.35)',
167
+ textShadowOffset: { width: 0, height: 1 },
168
+ textShadowRadius: 3,
169
+ };
170
+ }
171
+ if (st.effect === 'outline') {
172
+ return {
173
+ ...base,
174
+ borderWidth: 1.5,
175
+ borderColor: color,
176
+ paddingHorizontal: 8 * scale,
177
+ alignSelf: alignSelfOf(st.align),
178
+ };
179
+ }
180
+ if (st.effect === 'band') {
181
+ return {
182
+ ...base,
183
+ color: paper ?? color,
184
+ backgroundColor: color,
185
+ paddingHorizontal: 8 * scale,
186
+ alignSelf: alignSelfOf(st.align),
187
+ };
188
+ }
189
+ return base;
190
+ }
191
+
192
+ function alignSelfOf(align?: 'left' | 'center' | 'right') {
193
+ return align === 'center'
194
+ ? 'center'
195
+ : align === 'right'
196
+ ? 'flex-end'
197
+ : 'flex-start';
198
+ }
199
+
200
+ export function DetailCanvas({
201
+ doc,
202
+ selection,
203
+ onSelect,
204
+ scale = 1,
205
+ ink,
206
+ paper,
207
+ }: DetailCanvasProps) {
208
+ const t = useTheme();
209
+ const s = useStyles();
210
+ const report = useContext(DetailFocusContext);
211
+ const root = useRef<ComponentRef<typeof View>>(null);
212
+ const target = useMemo(() => (report ? { root, report } : null), [report]);
213
+ const pad = t.space[5] * scale;
214
+ const fg = ink ?? t.colors.foreground;
215
+ const bandText = paper ?? t.colors.surface;
216
+
217
+ const picked = (block: DetailBlock, layer?: DetailLayer) =>
218
+ selection?.block === block.id &&
219
+ (layer ? selection.layer === layer.id : !selection.layer);
220
+
221
+ const press = (next: DetailSelection) =>
222
+ onSelect ? () => onSelect(next) : undefined;
223
+
224
+ const image = (
225
+ block: DetailBlock,
226
+ layer: DetailLayer,
227
+ flex = false,
228
+ ratio = 1
229
+ ) => (
230
+ <Tap
231
+ key={layer.id}
232
+ onPress={press({ block: block.id, layer: layer.id })}
233
+ label={'사진'}
234
+ style={flex ? s.half : undefined}
235
+ >
236
+ {layer.url ? (
237
+ <Image
238
+ source={{ uri: layer.url }}
239
+ resizeMode="cover"
240
+ style={[s.full, { aspectRatio: ratio }]}
241
+ />
242
+ ) : (
243
+ <View
244
+ style={[
245
+ s.full,
246
+ { aspectRatio: ratio, backgroundColor: t.colors.muted },
247
+ ]}
248
+ />
249
+ )}
250
+ {picked(block, layer) ? <Handles /> : null}
251
+ </Tap>
252
+ );
253
+
254
+ const texts = (block: DetailBlock, shown: DetailLayer[]) => {
255
+ const list = shown.filter((l) => l.type === 'text' && l.text);
256
+ if (!list.length) return null;
257
+ return (
258
+ <View style={[s.texts, { padding: pad }]}>
259
+ {list.map((l) => {
260
+ const style = textStyleOf(l, scale, fg, bandText);
261
+ return (
262
+ <Tap
263
+ key={l.id}
264
+ onPress={press({ block: block.id, layer: l.id })}
265
+ label={l.text ?? ''}
266
+ >
267
+ <RNText style={style}>{l.text}</RNText>
268
+ {picked(block, l) ? <Handles /> : null}
269
+ </Tap>
270
+ );
271
+ })}
272
+ </View>
273
+ );
274
+ };
275
+
276
+ const body = (block: DetailBlock): ReactNode => {
277
+ const shown = block.layers.filter((l) => !l.hidden);
278
+ const images = shown.filter((l) => l.type === 'image');
279
+ switch (block.layout) {
280
+ case 'text':
281
+ return texts(block, shown);
282
+ case 'image':
283
+ return images.map((l) => image(block, l, false, 4 / 5));
284
+ case 'text_top':
285
+ return (
286
+ <>
287
+ {texts(block, shown)}
288
+ {images.map((l) => image(block, l, false, 4 / 5))}
289
+ </>
290
+ );
291
+ case 'side':
292
+ return (
293
+ <View style={s.row}>
294
+ {images.slice(0, 1).map((l) => image(block, l, true))}
295
+ <View style={s.half}>{texts(block, shown)}</View>
296
+ </View>
297
+ );
298
+ case 'two_images':
299
+ return (
300
+ <>
301
+ <View style={[s.pair, { paddingHorizontal: pad, paddingTop: pad }]}>
302
+ {images.slice(0, 2).map((l) => image(block, l, true))}
303
+ </View>
304
+ {texts(block, shown)}
305
+ </>
306
+ );
307
+ case 'card':
308
+ return (
309
+ <View style={{ padding: pad }}>
310
+ <View style={[s.card, { backgroundColor: t.colors.surface }]}>
311
+ {images.slice(0, 1).map((l) => image(block, l))}
312
+ {texts(block, shown)}
313
+ </View>
314
+ </View>
315
+ );
316
+ default:
317
+ return (
318
+ <>
319
+ {images.map((l) => image(block, l, false, 4 / 5))}
320
+ {texts(block, shown)}
321
+ </>
322
+ );
323
+ }
324
+ };
325
+
326
+ return (
327
+ <FocusTargetContext.Provider value={target}>
328
+ <View
329
+ ref={root}
330
+ style={[
331
+ s.page,
332
+ { backgroundColor: doc.background ?? paper ?? t.colors.surface },
333
+ ]}
334
+ >
335
+ {doc.blocks.map((block, index) => (
336
+ <Tap
337
+ key={block.id}
338
+ onPress={press({ block: block.id })}
339
+ label={'블록'}
340
+ style={{
341
+ backgroundColor: block.background?.color ?? undefined,
342
+ paddingTop: detailBlockSpace(block.space_top) * scale,
343
+ paddingBottom: detailBlockSpace(block.space_bottom) * scale,
344
+ }}
345
+ >
346
+ {block.background?.url ? (
347
+ <Image
348
+ source={{ uri: block.background.url }}
349
+ resizeMode="cover"
350
+ style={s.fill}
351
+ />
352
+ ) : null}
353
+ {body(block)}
354
+ {picked(block) ? <Handles /> : null}
355
+ {selection?.block === block.id ? (
356
+ <View pointerEvents="none" style={s.tag}>
357
+ <RNText
358
+ style={[s.tagText, { color: t.colors.primaryForeground }]}
359
+ >
360
+ {String(index + 1)}
361
+ </RNText>
362
+ </View>
363
+ ) : null}
364
+ </Tap>
365
+ ))}
366
+ </View>
367
+ </FocusTargetContext.Provider>
368
+ );
369
+ }
@@ -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
+ }