@shotik/react-native 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +193 -2
- package/README.ru.md +192 -0
- package/dist/analytics/core.d.ts +104 -0
- package/dist/analytics/core.js +345 -0
- package/dist/analytics/index.d.ts +5 -0
- package/dist/analytics/index.js +3 -0
- package/dist/analytics/rn.d.ts +84 -0
- package/dist/analytics/rn.js +413 -0
- package/dist/analytics/wire.d.ts +53 -0
- package/dist/analytics/wire.js +56 -0
- package/dist/client.d.ts +153 -0
- package/dist/client.js +595 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +6 -0
- package/dist/native.d.ts +3 -0
- package/dist/native.js +77 -0
- package/dist/parts.d.ts +103 -0
- package/dist/parts.js +157 -0
- package/dist/react.d.ts +51 -0
- package/dist/react.js +88 -0
- package/dist/sheet.d.ts +12 -0
- package/dist/sheet.js +273 -0
- package/dist/support.d.ts +12 -0
- package/dist/support.js +60 -0
- package/dist/theme.d.ts +72 -0
- package/dist/theme.js +95 -0
- package/guide.json +136 -0
- package/package.json +114 -4
- package/recipe.json +263 -0
- package/src/analytics/README.md +32 -0
- package/src/analytics/core.ts +380 -0
- package/src/analytics/index.ts +7 -0
- package/src/analytics/recipe.json +263 -0
- package/src/analytics/rn.tsx +425 -0
- package/src/analytics/wire.ts +123 -0
- package/src/client.ts +685 -0
- package/src/index.ts +10 -0
- package/src/native.ts +90 -0
- package/src/parts.tsx +243 -0
- package/src/react.tsx +140 -0
- package/src/sheet.tsx +538 -0
- package/src/support.ts +55 -0
- package/src/theme.ts +141 -0
package/src/theme.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// Brand theme and copy for the widget. Colors follow the system scheme; the founder's brand sets accent, radius and
|
|
2
|
+
// font. Copy is a small en/ru catalog picked from the device locale (or the locale prop), falling back to en.
|
|
3
|
+
|
|
4
|
+
export interface Colors {
|
|
5
|
+
bg: string
|
|
6
|
+
raised: string
|
|
7
|
+
line: string
|
|
8
|
+
text: string
|
|
9
|
+
sub: string
|
|
10
|
+
faint: string
|
|
11
|
+
danger: string
|
|
12
|
+
ok: string
|
|
13
|
+
warn: string
|
|
14
|
+
backdrop: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface SupportTheme {
|
|
18
|
+
// Brand color for your bubbles, the send button, the launcher and links.
|
|
19
|
+
accent?: string
|
|
20
|
+
// Text and icons drawn on the accent (default white).
|
|
21
|
+
onAccent?: string
|
|
22
|
+
// Bubble corner radius (default 18); the sheet, chips and fields follow it.
|
|
23
|
+
radius?: number
|
|
24
|
+
// fontFamily for regular and semibold text (default: the system font).
|
|
25
|
+
font?: string
|
|
26
|
+
fontBold?: string
|
|
27
|
+
// Force a scheme instead of following the system.
|
|
28
|
+
scheme?: 'light' | 'dark'
|
|
29
|
+
light?: Partial<Colors>
|
|
30
|
+
dark?: Partial<Colors>
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const base: Record<'light' | 'dark', Colors> = {
|
|
34
|
+
light: { bg: '#FFFFFF', raised: '#F2F2F4', line: 'rgba(0,0,0,0.08)', text: '#0B0B0C', sub: '#6B6B73', faint: '#A3A3AB', danger: '#E5484D', ok: '#30A46C', warn: '#E38A1B', backdrop: 'rgba(0,0,0,0.32)' },
|
|
35
|
+
dark: { bg: '#161617', raised: '#252527', line: 'rgba(255,255,255,0.09)', text: '#F4F4F5', sub: '#9B9BA3', faint: '#6B6B73', danger: '#FF6369', ok: '#3DD68C', warn: '#FFB224', backdrop: 'rgba(0,0,0,0.5)' }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface Resolved extends Colors {
|
|
39
|
+
dark: boolean
|
|
40
|
+
accent: string
|
|
41
|
+
onAccent: string
|
|
42
|
+
radius: number
|
|
43
|
+
font?: string
|
|
44
|
+
fontBold?: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function resolveTheme(t: SupportTheme | undefined, system: 'light' | 'dark'): Resolved {
|
|
48
|
+
const scheme = t?.scheme ?? system
|
|
49
|
+
const dark = scheme === 'dark'
|
|
50
|
+
return { ...base[scheme], ...t?.[scheme], dark, accent: t?.accent ?? (dark ? '#0A84FF' : '#007AFF'), onAccent: t?.onAccent ?? '#FFFFFF', radius: t?.radius ?? 18, font: t?.font, fontBold: t?.fontBold }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const en = {
|
|
54
|
+
title: 'Support',
|
|
55
|
+
greeting: 'How can we help?',
|
|
56
|
+
online: 'Online',
|
|
57
|
+
connecting: 'Connecting',
|
|
58
|
+
offline: 'Offline',
|
|
59
|
+
queuedN: '{n} queued',
|
|
60
|
+
error: "Couldn't connect",
|
|
61
|
+
retry: 'Retry',
|
|
62
|
+
newMessage: 'New message',
|
|
63
|
+
placeholder: 'Message',
|
|
64
|
+
send: 'Send',
|
|
65
|
+
close: 'Close',
|
|
66
|
+
back: 'Back',
|
|
67
|
+
attach: 'Attach',
|
|
68
|
+
photo: 'Photo',
|
|
69
|
+
screenshot: 'Screenshot',
|
|
70
|
+
cancel: 'Cancel',
|
|
71
|
+
remove: 'Remove',
|
|
72
|
+
sending: 'Sending',
|
|
73
|
+
queued: "Will send when you're back online",
|
|
74
|
+
sent: 'Sent',
|
|
75
|
+
delivered: 'Delivered',
|
|
76
|
+
seen: 'Seen',
|
|
77
|
+
failed: 'Not sent · Retry',
|
|
78
|
+
ai: 'AI',
|
|
79
|
+
team: 'Team',
|
|
80
|
+
you: 'You',
|
|
81
|
+
talk: 'Talk to a person',
|
|
82
|
+
handedOff: 'A person will reply',
|
|
83
|
+
resolved: 'Resolved',
|
|
84
|
+
person: 'Person',
|
|
85
|
+
typing: '{who} is typing',
|
|
86
|
+
open: 'Open support',
|
|
87
|
+
unreadN: '{n} unread'
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export type Copy = typeof en
|
|
91
|
+
|
|
92
|
+
const ru: Copy = {
|
|
93
|
+
title: 'Поддержка',
|
|
94
|
+
greeting: 'Чем помочь?',
|
|
95
|
+
online: 'В сети',
|
|
96
|
+
connecting: 'Подключаемся',
|
|
97
|
+
offline: 'Нет сети',
|
|
98
|
+
queuedN: 'В очереди: {n}',
|
|
99
|
+
error: 'Не удалось подключиться',
|
|
100
|
+
retry: 'Повторить',
|
|
101
|
+
newMessage: 'Новое сообщение',
|
|
102
|
+
placeholder: 'Сообщение',
|
|
103
|
+
send: 'Отправить',
|
|
104
|
+
close: 'Закрыть',
|
|
105
|
+
back: 'Назад',
|
|
106
|
+
attach: 'Прикрепить',
|
|
107
|
+
photo: 'Фото',
|
|
108
|
+
screenshot: 'Снимок экрана',
|
|
109
|
+
cancel: 'Отмена',
|
|
110
|
+
remove: 'Убрать',
|
|
111
|
+
sending: 'Отправляется',
|
|
112
|
+
queued: 'Отправим, когда появится связь',
|
|
113
|
+
sent: 'Отправлено',
|
|
114
|
+
delivered: 'Доставлено',
|
|
115
|
+
seen: 'Прочитано',
|
|
116
|
+
failed: 'Не отправлено · Повторить',
|
|
117
|
+
ai: 'ИИ',
|
|
118
|
+
team: 'Команда',
|
|
119
|
+
you: 'Вы',
|
|
120
|
+
talk: 'Позвать человека',
|
|
121
|
+
handedOff: 'Ответит человек',
|
|
122
|
+
resolved: 'Решено',
|
|
123
|
+
person: 'Человек',
|
|
124
|
+
typing: '{who} печатает',
|
|
125
|
+
open: 'Открыть поддержку',
|
|
126
|
+
unreadN: 'Непрочитанных: {n}'
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export const catalogs: Record<string, Copy> = { en, ru }
|
|
130
|
+
|
|
131
|
+
export function copyFor(locale?: string): Copy {
|
|
132
|
+
let tag = locale
|
|
133
|
+
if (!tag) {
|
|
134
|
+
try {
|
|
135
|
+
tag = Intl.DateTimeFormat().resolvedOptions().locale
|
|
136
|
+
} catch {}
|
|
137
|
+
}
|
|
138
|
+
return catalogs[(tag ?? 'en').slice(0, 2).toLowerCase()] ?? en
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export const fill = (s: string, v: Record<string, string | number>) => s.replace(/\{(\w+)\}/g, (_, k: string) => String(v[k] ?? ''))
|