@adminide-stack/yantra-mobile 12.0.137 → 12.0.139-alpha.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 (96) hide show
  1. package/lib/components/CustomDrawer.js +17 -1
  2. package/lib/components/CustomDrawer.js.map +1 -1
  3. package/lib/compute.js +106 -1
  4. package/lib/compute.js.map +1 -1
  5. package/lib/config/env-config.js +12 -0
  6. package/lib/config/env-config.js.map +1 -1
  7. package/lib/features/chat/ChatTranscript.js +2 -2
  8. package/lib/features/chat/ChatTranscript.js.map +1 -1
  9. package/lib/features/chat/surfaceNotes.js +4 -0
  10. package/lib/features/chat/surfaceNotes.js.map +1 -0
  11. package/lib/features/devices/readings.js.map +1 -1
  12. package/lib/features/devices/session.js +2 -22
  13. package/lib/features/devices/session.js.map +1 -1
  14. package/lib/features/dictate/backgroundRecording.js.map +1 -1
  15. package/lib/features/dictate/useDictationRecorder.js +42 -1
  16. package/lib/features/dictate/useDictationRecorder.js.map +1 -1
  17. package/lib/features/home/useHomeWeather.js +85 -0
  18. package/lib/features/home/useHomeWeather.js.map +1 -0
  19. package/lib/features/home/weather.js +139 -0
  20. package/lib/features/home/weather.js.map +1 -0
  21. package/lib/features/notion/NotionPageView.js +819 -0
  22. package/lib/features/notion/NotionPageView.js.map +1 -0
  23. package/lib/features/notion/NotionSheets.js +452 -0
  24. package/lib/features/notion/NotionSheets.js.map +1 -0
  25. package/lib/features/notion/NotionTrashSheet.js +415 -0
  26. package/lib/features/notion/NotionTrashSheet.js.map +1 -0
  27. package/lib/features/notion/NotionWorkspaceView.js +837 -0
  28. package/lib/features/notion/NotionWorkspaceView.js.map +1 -0
  29. package/lib/features/notion/notionBlocks.js +203 -0
  30. package/lib/features/notion/notionBlocks.js.map +1 -0
  31. package/lib/features/notion/notionDocuments.js +182 -0
  32. package/lib/features/notion/notionDocuments.js.map +1 -0
  33. package/lib/features/notion/notionEditorModel.js +180 -0
  34. package/lib/features/notion/notionEditorModel.js.map +1 -0
  35. package/lib/features/notion/notionTemplates.js +406 -0
  36. package/lib/features/notion/notionTemplates.js.map +1 -0
  37. package/lib/features/notion/notionTheme.js +34 -0
  38. package/lib/features/notion/notionTheme.js.map +1 -0
  39. package/lib/features/notion/notionTrash.js +100 -0
  40. package/lib/features/notion/notionTrash.js.map +1 -0
  41. package/lib/features/notion/notionUi.js +310 -0
  42. package/lib/features/notion/notionUi.js.map +1 -0
  43. package/lib/features/notion/useNotionWorkspace.js +181 -0
  44. package/lib/features/notion/useNotionWorkspace.js.map +1 -0
  45. package/lib/features/webbuilder/buildFragments.js +15 -9
  46. package/lib/features/webbuilder/buildFragments.js.map +1 -1
  47. package/lib/features/webbuilder/buildJob.js +3 -3
  48. package/lib/features/webbuilder/buildJob.js.map +1 -1
  49. package/lib/features/webbuilder/publicSandboxDomain.js +5 -0
  50. package/lib/features/webbuilder/publicSandboxDomain.js.map +1 -0
  51. package/lib/features/webbuilder/sandboxPublicHost.js +74 -0
  52. package/lib/features/webbuilder/sandboxPublicHost.js.map +1 -0
  53. package/lib/features/webbuilder/siteAddress.js +2 -1
  54. package/lib/features/webbuilder/siteAddress.js.map +1 -1
  55. package/lib/features/webbuilder/webbuilderPrompts.js +3 -2
  56. package/lib/features/webbuilder/webbuilderPrompts.js.map +1 -1
  57. package/lib/features/webbuilder/workflow.js +2 -2
  58. package/lib/features/webbuilder/workflow.js.map +1 -1
  59. package/lib/hooks/useChatApi.js +15 -3
  60. package/lib/hooks/useChatApi.js.map +1 -1
  61. package/lib/hooks/usePrerequisiteIds.js +15 -2
  62. package/lib/hooks/usePrerequisiteIds.js.map +1 -1
  63. package/lib/routes.json +107 -0
  64. package/lib/screens/Devices/index.js +3 -205
  65. package/lib/screens/Devices/index.js.map +1 -1
  66. package/lib/screens/Home/HomeScreen.js +20 -5
  67. package/lib/screens/Home/HomeScreen.js.map +1 -1
  68. package/lib/screens/Home/components/HomeHero.js +117 -0
  69. package/lib/screens/Home/components/HomeHero.js.map +1 -0
  70. package/lib/screens/Home/components/HomeSuggestions.js +108 -85
  71. package/lib/screens/Home/components/HomeSuggestions.js.map +1 -1
  72. package/lib/screens/Home/components/HomeWash.js +44 -0
  73. package/lib/screens/Home/components/HomeWash.js.map +1 -0
  74. package/lib/screens/Home/components/homeCatalog.js +125 -0
  75. package/lib/screens/Home/components/homeCatalog.js.map +1 -0
  76. package/lib/screens/Notion/index.js +18 -0
  77. package/lib/screens/Notion/index.js.map +1 -0
  78. package/lib/screens/NotionPage/index.js +19 -0
  79. package/lib/screens/NotionPage/index.js.map +1 -0
  80. package/lib/screens/WebBuilderNative/sandboxProxyApi.js +2 -2
  81. package/lib/screens/WebBuilderNative/sandboxProxyApi.js.map +1 -1
  82. package/lib/screens/WebBuilderNative/useRestoredSandboxes.js +16 -8
  83. package/lib/screens/WebBuilderNative/useRestoredSandboxes.js.map +1 -1
  84. package/lib/screens/WebBuilderNative/useWebBuilderGallery.js +6 -5
  85. package/lib/screens/WebBuilderNative/useWebBuilderGallery.js.map +1 -1
  86. package/lib/screens/WebBuilderNative/useWebBuilderHost.js +5 -4
  87. package/lib/screens/WebBuilderNative/useWebBuilderHost.js.map +1 -1
  88. package/lib/screens/WebBuilderNative/webbuilderTransport.js +4 -3
  89. package/lib/screens/WebBuilderNative/webbuilderTransport.js.map +1 -1
  90. package/lib/services/savedWorkspace.js +44 -0
  91. package/lib/services/savedWorkspace.js.map +1 -0
  92. package/lib/theme/mobileTokens.js +1 -0
  93. package/lib/theme/mobileTokens.js.map +1 -1
  94. package/package.json +4 -4
  95. package/lib/features/devices/bodyComposition.js +0 -116
  96. package/lib/features/devices/bodyComposition.js.map +0 -1
@@ -0,0 +1,819 @@
1
+ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useState,useRef,useCallback,useEffect,useMemo}from'react';import {View,StyleSheet,ActivityIndicator,Text,Pressable,KeyboardAvoidingView,ScrollView,TextInput,RefreshControl,Keyboard,Platform,Alert}from'react-native';import {Ionicons}from'@expo/vector-icons';import {useNavigation,StackActions}from'@react-navigation/native';import {useApolloClient,useQuery}from'@apollo/client/index.js';import {useSafeAreaInsets}from'react-native-safe-area-context';import {mobileTokens}from'../../theme/mobileTokens.js';import {notionPalette}from'./notionTheme.js';import {NATIVE_NOTION_PAGE_TREE,NATIVE_NOTION_BLOCK,NATIVE_NOTION_UPDATE_BLOCK,NATIVE_NOTION_APPEND_CHILDREN,NATIVE_NOTION_TRANSFORM_BLOCK,NATIVE_NOTION_DELETE_BLOCK}from'./notionDocuments.js';import {blockTitle,blockIcon,toTitleProperty,editedLabel,isPageBlock,pageTitle,richTextToPlain}from'./notionBlocks.js';import {modelFromTree,newBlockId,isTextType,insertAfter,patchBlock,previousLineId,removeBlock,flattenModel,nextTypeAfter,TURN_INTO}from'./notionEditorModel.js';var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ const SAVE_DELAY_MS = 500;
21
+ const PAGE_EMOJIS = ["\u{1F4C4}", "\u{1F4DD}", "\u{1F4CC}", "\u{1F4A1}", "\u{1F3AF}", "\u{1F680}", "\u{1F4DA}", "\u2705", "\u{1F5D3}\uFE0F", "\u{1F4BC}", "\u{1F3E0}", "\u2764\uFE0F", "\u2B50", "\u{1F525}", "\u{1F9E0}", "\u{1F3A8}"];
22
+ const PLACEHOLDER = {
23
+ heading_1: "Heading 1",
24
+ heading_2: "Heading 2",
25
+ heading_3: "Heading 3",
26
+ bulleted_list: "List",
27
+ numbered_list: "List",
28
+ todo: "To-do",
29
+ toggle: "Toggle",
30
+ quote: "Quote",
31
+ callout: "Callout",
32
+ code: "Code"
33
+ };
34
+ const TEXT_STYLE = {
35
+ heading_1: {
36
+ fontSize: 26,
37
+ lineHeight: 32,
38
+ fontWeight: "800"
39
+ },
40
+ heading_2: {
41
+ fontSize: 21,
42
+ lineHeight: 28,
43
+ fontWeight: "700"
44
+ },
45
+ heading_3: {
46
+ fontSize: 18,
47
+ lineHeight: 25,
48
+ fontWeight: "700"
49
+ }
50
+ };
51
+ function saveLabelOf(save, lastEdited) {
52
+ if (save === "saving") return "Saving\u2026";
53
+ if (save === "error") return "Not saved \u2014 check your connection";
54
+ if (save === "saved") return "Saved";
55
+ return editedLabel(lastEdited);
56
+ }
57
+ function NotionPageView({
58
+ orgName,
59
+ blockId,
60
+ isDark
61
+ }) {
62
+ var _a, _b, _c, _d;
63
+ const palette = notionPalette(isDark);
64
+ const navigation = useNavigation();
65
+ const client = useApolloClient();
66
+ const insets = useSafeAreaInsets();
67
+ const {
68
+ data,
69
+ loading,
70
+ error,
71
+ refetch
72
+ } = useQuery(NATIVE_NOTION_PAGE_TREE, {
73
+ variables: {
74
+ input: {
75
+ blockId: blockId != null ? blockId : "",
76
+ includeChildren: true,
77
+ maxDepth: 5
78
+ }
79
+ },
80
+ skip: !blockId,
81
+ fetchPolicy: "network-only"
82
+ });
83
+ const tree = (_a = data == null ? void 0 : data.getBlockTree) != null ? _a : null;
84
+ const pageQuery = useQuery(NATIVE_NOTION_BLOCK, {
85
+ variables: {
86
+ input: {
87
+ blockId: blockId != null ? blockId : ""
88
+ }
89
+ },
90
+ skip: !blockId,
91
+ fetchPolicy: "network-only"
92
+ });
93
+ const page = (_c = (_b = pageQuery.data) == null ? void 0 : _b.getBlock) != null ? _c : null;
94
+ const [model, setModel] = useState(null);
95
+ const [title, setTitle] = useState("");
96
+ const [icon, setIcon] = useState(null);
97
+ const [focusedId, setFocusedId] = useState(null);
98
+ const [pendingFocus, setPendingFocus] = useState(null);
99
+ const [save, setSave] = useState("idle");
100
+ const [iconPicker, setIconPicker] = useState(false);
101
+ const [refreshing, setRefreshing] = useState(false);
102
+ const modelRef = useRef(null);
103
+ modelRef.current = model;
104
+ const inputs = useRef(/* @__PURE__ */ new Map());
105
+ const pending = useRef(/* @__PURE__ */ new Map());
106
+ const chains = useRef(/* @__PURE__ */ new Map());
107
+ const savedTitles = useRef(/* @__PURE__ */ new Map());
108
+ const inFlight = useRef(0);
109
+ const applyTree = useCallback((next, pageBlock) => {
110
+ var _a2;
111
+ setModel(modelFromTree(next));
112
+ const t = blockTitle(pageBlock);
113
+ setTitle(t);
114
+ setIcon(blockIcon(pageBlock));
115
+ savedTitles.current.set(pageBlock.id, t);
116
+ const remember = (node) => {
117
+ var _a3;
118
+ savedTitles.current.set(node.block.id, blockTitle(node.block));
119
+ ((_a3 = node.children) != null ? _a3 : []).forEach(remember);
120
+ };
121
+ ((_a2 = next.children) != null ? _a2 : []).forEach(remember);
122
+ }, []);
123
+ const seeded = useRef(false);
124
+ useEffect(() => {
125
+ if (!tree || !page || seeded.current) return;
126
+ seeded.current = true;
127
+ applyTree(tree, page);
128
+ }, [tree, page, applyTree]);
129
+ useEffect(() => {
130
+ if (!pendingFocus) return void 0;
131
+ const id = pendingFocus;
132
+ const handle = setTimeout(() => {
133
+ var _a2;
134
+ (_a2 = inputs.current.get(id)) == null ? void 0 : _a2.focus();
135
+ setPendingFocus(null);
136
+ }, 30);
137
+ return () => clearTimeout(handle);
138
+ }, [pendingFocus, model]);
139
+ const write = useCallback(async (options) => {
140
+ var _a2;
141
+ const res = await client.mutate(__spreadProps(__spreadValues({}, options), {
142
+ errorPolicy: "none"
143
+ }));
144
+ if ((_a2 = res.errors) == null ? void 0 : _a2.length) throw new Error(res.errors[0].message);
145
+ if (!res.data) throw new Error("The server returned no data");
146
+ return res;
147
+ }, [client]);
148
+ const enqueue = useCallback((id, op) => {
149
+ var _a2;
150
+ inFlight.current += 1;
151
+ setSave("saving");
152
+ const prev = (_a2 = chains.current.get(id)) != null ? _a2 : Promise.resolve();
153
+ const next = prev.catch(() => void 0).then(op).then(() => {
154
+ inFlight.current -= 1;
155
+ if (!inFlight.current && !pending.current.size) setSave("saved");
156
+ }, (err) => {
157
+ inFlight.current -= 1;
158
+ setSave("error");
159
+ if (__DEV__) console.warn("[NotionPage] save failed", err);
160
+ });
161
+ chains.current.set(id, next);
162
+ return next;
163
+ }, []);
164
+ const writeTitle = useCallback((id, text) => {
165
+ var _a2;
166
+ const baseTitle = (_a2 = savedTitles.current.get(id)) != null ? _a2 : "";
167
+ savedTitles.current.set(id, text);
168
+ return enqueue(id, () => write({
169
+ mutation: NATIVE_NOTION_UPDATE_BLOCK,
170
+ variables: {
171
+ input: {
172
+ id,
173
+ properties: {
174
+ title: toTitleProperty(text)
175
+ },
176
+ baseTitle
177
+ }
178
+ }
179
+ }));
180
+ }, [write, enqueue]);
181
+ const scheduleTitle = useCallback((id, text) => {
182
+ var _a2;
183
+ (_a2 = pending.current.get(id)) == null ? void 0 : _a2.cancel();
184
+ setSave("saving");
185
+ const handle = setTimeout(() => {
186
+ pending.current.delete(id);
187
+ writeTitle(id, text);
188
+ }, SAVE_DELAY_MS);
189
+ const cancel = () => {
190
+ clearTimeout(handle);
191
+ pending.current.delete(id);
192
+ };
193
+ pending.current.set(id, {
194
+ cancel,
195
+ flush: () => {
196
+ cancel();
197
+ writeTitle(id, text);
198
+ }
199
+ });
200
+ }, [writeTitle]);
201
+ useEffect(() => () => {
202
+ [...pending.current.values()].forEach((p) => p.flush());
203
+ }, []);
204
+ const updateProps = useCallback((id, properties) => enqueue(id, () => write({
205
+ mutation: NATIVE_NOTION_UPDATE_BLOCK,
206
+ variables: {
207
+ input: {
208
+ id,
209
+ properties
210
+ }
211
+ }
212
+ })), [write, enqueue]);
213
+ const addBlock = useCallback((parentId, afterId, type, extra = {}) => {
214
+ const id = newBlockId();
215
+ const properties = __spreadValues(__spreadValues(__spreadValues({}, isTextType(type) || type === "page" ? {
216
+ title: []
217
+ } : {}), type === "todo" ? {
218
+ checked: false
219
+ } : {}), extra);
220
+ const block = {
221
+ id,
222
+ type,
223
+ parentId,
224
+ text: "",
225
+ properties
226
+ };
227
+ setModel((m) => m ? insertAfter(m, block, afterId) : m);
228
+ savedTitles.current.set(id, "");
229
+ if (isTextType(type)) setPendingFocus(id);
230
+ enqueue(id, () => write({
231
+ mutation: NATIVE_NOTION_APPEND_CHILDREN,
232
+ variables: {
233
+ input: __spreadProps(__spreadValues({
234
+ parentId
235
+ }, afterId ? {
236
+ after: afterId
237
+ } : {}), {
238
+ children: [{
239
+ id,
240
+ type,
241
+ parent: {
242
+ type: "block",
243
+ id: parentId
244
+ },
245
+ properties
246
+ }]
247
+ })
248
+ }
249
+ }));
250
+ return id;
251
+ }, [write, enqueue]);
252
+ const turnInto = useCallback((id, type) => {
253
+ var _a2;
254
+ const block = (_a2 = modelRef.current) == null ? void 0 : _a2.blocks[id];
255
+ if (!block || block.type === type) return;
256
+ setModel((cur) => cur ? patchBlock(cur, id, {
257
+ type
258
+ }) : cur);
259
+ enqueue(id, async () => {
260
+ await write({
261
+ mutation: NATIVE_NOTION_TRANSFORM_BLOCK,
262
+ variables: {
263
+ blockId: id,
264
+ newType: type
265
+ }
266
+ });
267
+ if (type === "todo") {
268
+ await write({
269
+ mutation: NATIVE_NOTION_UPDATE_BLOCK,
270
+ variables: {
271
+ input: {
272
+ id,
273
+ properties: {
274
+ checked: false
275
+ }
276
+ }
277
+ }
278
+ });
279
+ }
280
+ });
281
+ }, [write, enqueue]);
282
+ const deleteLine = useCallback((id) => {
283
+ var _a2;
284
+ const m = modelRef.current;
285
+ if (!m) return;
286
+ const prev = previousLineId(m, id);
287
+ (_a2 = pending.current.get(id)) == null ? void 0 : _a2.cancel();
288
+ setModel(removeBlock(m, id));
289
+ if (prev) setPendingFocus(prev);
290
+ else setFocusedId(null);
291
+ enqueue(id, () => write({
292
+ mutation: NATIVE_NOTION_DELETE_BLOCK,
293
+ variables: {
294
+ blockId: id
295
+ }
296
+ }));
297
+ }, [write, enqueue]);
298
+ const openPage = useCallback((id) => navigation.dispatch(StackActions.push("MainStack.NotionPage", {
299
+ orgName,
300
+ blockId: id
301
+ })), [navigation, orgName]);
302
+ const onTitle = (text) => {
303
+ setTitle(text);
304
+ if (blockId) scheduleTitle(blockId, text);
305
+ };
306
+ const pickIcon = (emoji) => {
307
+ setIconPicker(false);
308
+ setIcon(emoji);
309
+ if (blockId) updateProps(blockId, {
310
+ icon: emoji ? {
311
+ type: "emoji",
312
+ emoji
313
+ } : null
314
+ });
315
+ };
316
+ const trashPage = () => {
317
+ if (!blockId) return;
318
+ Alert.alert("Move to Trash?", "You can restore it from Trash.", [{
319
+ text: "Cancel",
320
+ style: "cancel"
321
+ }, {
322
+ text: "Move to Trash",
323
+ style: "destructive",
324
+ onPress: async () => {
325
+ try {
326
+ await write({
327
+ mutation: NATIVE_NOTION_DELETE_BLOCK,
328
+ variables: {
329
+ blockId
330
+ }
331
+ });
332
+ client.refetchQueries({
333
+ include: ["NativeNotionChildren"]
334
+ }).catch(() => void 0);
335
+ navigation.goBack();
336
+ } catch (err) {
337
+ Alert.alert("Couldn't move to Trash", err instanceof Error ? err.message : void 0);
338
+ }
339
+ }
340
+ }]);
341
+ };
342
+ const onChangeText = (id, text) => {
343
+ setModel((m) => m ? patchBlock(m, id, {
344
+ text
345
+ }) : m);
346
+ scheduleTitle(id, text);
347
+ };
348
+ const onSubmit = (line) => {
349
+ const {
350
+ block
351
+ } = line;
352
+ if (!block.text && block.type !== "paragraph" && nextTypeAfter(block.type) === block.type) {
353
+ turnInto(block.id, "paragraph");
354
+ return;
355
+ }
356
+ addBlock(block.parentId, block.id, nextTypeAfter(block.type));
357
+ };
358
+ const onBackspace = (line) => {
359
+ const {
360
+ block
361
+ } = line;
362
+ if (block.text) return;
363
+ if (block.type !== "paragraph" && block.type !== "text") turnInto(block.id, "paragraph");
364
+ else deleteLine(block.id);
365
+ };
366
+ const toggleTodo = (block) => {
367
+ const checked = block.properties.checked !== true;
368
+ setModel((m) => m ? patchBlock(m, block.id, {
369
+ properties: __spreadProps(__spreadValues({}, block.properties), {
370
+ checked
371
+ })
372
+ }) : m);
373
+ updateProps(block.id, {
374
+ checked
375
+ });
376
+ };
377
+ const addSubPage = () => {
378
+ var _a2, _b2, _c2;
379
+ const m = modelRef.current;
380
+ if (!m) return;
381
+ const anchor = focusedId ? m.blocks[focusedId] : null;
382
+ const id = addBlock((_a2 = anchor == null ? void 0 : anchor.parentId) != null ? _a2 : m.rootId, (_b2 = anchor == null ? void 0 : anchor.id) != null ? _b2 : null, "page");
383
+ Keyboard.dismiss();
384
+ (_c2 = chains.current.get(id)) == null ? void 0 : _c2.then(() => openPage(id));
385
+ };
386
+ const appendAtEnd = () => {
387
+ var _a2;
388
+ const m = modelRef.current;
389
+ if (!m) return;
390
+ const top = (_a2 = m.children[m.rootId]) != null ? _a2 : [];
391
+ const last = top.length ? m.blocks[top[top.length - 1]] : null;
392
+ if (last && isTextType(last.type) && !last.text) setPendingFocus(last.id);
393
+ else addBlock(m.rootId, null, "paragraph");
394
+ };
395
+ const lines = useMemo(() => model ? flattenModel(model) : [], [model]);
396
+ const focused = focusedId && model ? (_d = model.blocks[focusedId]) != null ? _d : null : null;
397
+ if (!model || !tree || !page) {
398
+ return /* @__PURE__ */ jsx(View, { style: [styles.center, {
399
+ backgroundColor: palette.card
400
+ }], children: loading || pageQuery.loading || !blockId ? /* @__PURE__ */ jsx(ActivityIndicator, { color: palette.primary }) : /* @__PURE__ */ jsxs(Fragment, { children: [
401
+ /* @__PURE__ */ jsx(Text, { style: [styles.muted, {
402
+ color: error || pageQuery.error ? palette.danger : palette.textMuted
403
+ }], children: error || pageQuery.error ? "Couldn't load this page." : "This page was not found." }),
404
+ /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", onPress: () => {
405
+ refetch();
406
+ pageQuery.refetch();
407
+ }, style: styles.retry, children: /* @__PURE__ */ jsx(Text, { style: {
408
+ color: palette.primary,
409
+ fontWeight: "600"
410
+ }, children: "Try again" }) })
411
+ ] }) });
412
+ }
413
+ return /* @__PURE__ */ jsxs(KeyboardAvoidingView, { style: [styles.flex, {
414
+ backgroundColor: palette.card
415
+ }], behavior: Platform.OS === "ios" ? "padding" : void 0, keyboardVerticalOffset: Platform.OS === "ios" ? insets.top + 56 : 0, children: [
416
+ /* @__PURE__ */ jsxs(ScrollView, { style: styles.flex, contentContainerStyle: styles.content, keyboardShouldPersistTaps: "handled", refreshControl: /* @__PURE__ */ jsx(RefreshControl, { refreshing, onRefresh: async () => {
417
+ var _a2, _b2;
418
+ setRefreshing(true);
419
+ try {
420
+ const [res, pageRes] = await Promise.all([refetch(), pageQuery.refetch()]);
421
+ const next = (_a2 = res.data) == null ? void 0 : _a2.getBlockTree;
422
+ const nextPage = (_b2 = pageRes.data) == null ? void 0 : _b2.getBlock;
423
+ if (next && nextPage && !pending.current.size && !inFlight.current) {
424
+ applyTree(next, nextPage);
425
+ }
426
+ } finally {
427
+ setRefreshing(false);
428
+ }
429
+ } }), children: [
430
+ /* @__PURE__ */ jsxs(View, { style: styles.pageActions, children: [
431
+ /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: icon ? "Change icon" : "Add icon", onPress: () => setIconPicker((v) => !v), style: ({
432
+ pressed
433
+ }) => [styles.pageAction, pressed && {
434
+ backgroundColor: palette.pressed
435
+ }], children: icon ? /* @__PURE__ */ jsx(Text, { style: styles.pageEmoji, children: icon }) : /* @__PURE__ */ jsxs(Fragment, { children: [
436
+ /* @__PURE__ */ jsx(Ionicons, { name: "happy-outline", size: 16, color: palette.textMuted }),
437
+ /* @__PURE__ */ jsx(Text, { style: [styles.pageActionLabel, {
438
+ color: palette.textMuted
439
+ }], children: "Add icon" })
440
+ ] }) }),
441
+ /* @__PURE__ */ jsx(View, { style: styles.flex }),
442
+ /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: "Move page to Trash", onPress: trashPage, hitSlop: 8, style: ({
443
+ pressed
444
+ }) => [styles.pageAction, pressed && {
445
+ backgroundColor: palette.pressed
446
+ }], children: /* @__PURE__ */ jsx(Ionicons, { name: "trash-outline", size: 18, color: palette.textMuted }) })
447
+ ] }),
448
+ iconPicker ? /* @__PURE__ */ jsxs(View, { style: [styles.emojiGrid, {
449
+ backgroundColor: palette.fill
450
+ }], children: [
451
+ PAGE_EMOJIS.map((e) => /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", onPress: () => pickIcon(e), style: styles.emojiCell, children: /* @__PURE__ */ jsx(Text, { style: styles.emoji, children: e }) }, e)),
452
+ icon ? /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", onPress: () => pickIcon(null), style: styles.emojiRemove, children: /* @__PURE__ */ jsx(Text, { style: {
453
+ color: palette.danger,
454
+ fontWeight: "600"
455
+ }, children: "Remove icon" }) }) : null
456
+ ] }) : null,
457
+ /* @__PURE__ */ jsx(TextInput, { value: title, onChangeText: onTitle, placeholder: "Untitled", placeholderTextColor: palette.textFaint, multiline: true, scrollEnabled: false, submitBehavior: "submit", returnKeyType: "next", onSubmitEditing: () => {
458
+ const first = lines.find((l) => isTextType(l.block.type));
459
+ if (first) setPendingFocus(first.block.id);
460
+ else addBlock(model.rootId, null, "paragraph");
461
+ }, onFocus: () => setFocusedId(null), style: [styles.title, {
462
+ color: palette.text
463
+ }] }),
464
+ /* @__PURE__ */ jsx(Text, { style: [styles.meta, {
465
+ color: save === "error" ? palette.danger : palette.textMuted
466
+ }], children: saveLabelOf(save, page.lastEditedTime) }),
467
+ /* @__PURE__ */ jsx(View, { style: styles.body, children: lines.map((line) => /* @__PURE__ */ jsx(BlockLine, { line, palette, focused: line.block.id === focusedId, registerInput: (input) => inputs.current.set(line.block.id, input), onFocus: () => setFocusedId(line.block.id), onChangeText: (t) => onChangeText(line.block.id, t), onSubmit: () => onSubmit(line), onBackspace: () => onBackspace(line), onToggleTodo: () => toggleTodo(line.block), onOpenPage: openPage, onDelete: () => deleteLine(line.block.id) }, line.block.id)) }),
468
+ /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: "Add a block", onPress: appendAtEnd, style: styles.appendArea, children: lines.length === 0 ? /* @__PURE__ */ jsx(Text, { style: [styles.startHint, {
469
+ color: palette.textFaint
470
+ }], children: "Tap here to start writing\u2026" }) : null })
471
+ ] }),
472
+ focused ? /* @__PURE__ */ jsx(EditorToolbar, { palette, block: focused, onTurnInto: (type) => turnInto(focused.id, type), onDivider: () => {
473
+ addBlock(focused.parentId, focused.id, "divider");
474
+ }, onSubPage: addSubPage, onDelete: () => deleteLine(focused.id), onDone: () => {
475
+ Keyboard.dismiss();
476
+ setFocusedId(null);
477
+ } }) : null
478
+ ] });
479
+ }
480
+ function BlockLine({
481
+ line,
482
+ palette,
483
+ focused,
484
+ registerInput,
485
+ onFocus,
486
+ onChangeText,
487
+ onSubmit,
488
+ onBackspace,
489
+ onToggleTodo,
490
+ onOpenPage,
491
+ onDelete
492
+ }) {
493
+ var _a, _b, _c;
494
+ const {
495
+ block,
496
+ depth,
497
+ number
498
+ } = line;
499
+ const indent = {
500
+ marginLeft: depth * 22
501
+ };
502
+ const confirmDelete = () => Alert.alert("Delete block?", void 0, [{
503
+ text: "Cancel",
504
+ style: "cancel"
505
+ }, {
506
+ text: "Delete",
507
+ style: "destructive",
508
+ onPress: onDelete
509
+ }]);
510
+ if (isPageBlock(block)) {
511
+ const emoji = blockIcon(block);
512
+ return /* @__PURE__ */ jsxs(Pressable, { accessibilityRole: "link", onPress: () => onOpenPage(block.id), onLongPress: confirmDelete, style: ({
513
+ pressed
514
+ }) => [styles.row, styles.linkRow, indent, pressed && {
515
+ backgroundColor: palette.pressed
516
+ }], children: [
517
+ emoji ? /* @__PURE__ */ jsx(Text, { style: styles.inlineEmoji, children: emoji }) : /* @__PURE__ */ jsx(Ionicons, { name: block.type === "database" ? "grid-outline" : "document-text-outline", size: 18, color: palette.textMuted }),
518
+ /* @__PURE__ */ jsx(Text, { style: [styles.text, styles.link, {
519
+ color: palette.text,
520
+ borderBottomColor: palette.hairline
521
+ }], children: block.text.trim() || pageTitle({
522
+ properties: block.properties
523
+ }) })
524
+ ] });
525
+ }
526
+ if (block.type === "divider") {
527
+ return /* @__PURE__ */ jsx(Pressable, { onLongPress: confirmDelete, style: [styles.dividerHit, indent], children: /* @__PURE__ */ jsx(View, { style: [styles.divider, {
528
+ backgroundColor: palette.hairline
529
+ }] }) });
530
+ }
531
+ if (!isTextType(block.type)) {
532
+ const caption = block.text || richTextToPlain(block.properties.caption) || block.type.replace(/_/g, " ");
533
+ return /* @__PURE__ */ jsxs(Pressable, { onLongPress: confirmDelete, style: [styles.row, styles.unsupported, {
534
+ borderColor: palette.hairline
535
+ }, indent], children: [
536
+ /* @__PURE__ */ jsx(Ionicons, { name: "cube-outline", size: 16, color: palette.textMuted }),
537
+ /* @__PURE__ */ jsx(Text, { style: [styles.unsupportedText, {
538
+ color: palette.textMuted
539
+ }], numberOfLines: 2, children: caption }),
540
+ /* @__PURE__ */ jsx(Text, { style: [styles.webOnly, {
541
+ color: palette.textFaint
542
+ }], children: "Web" })
543
+ ] });
544
+ }
545
+ const checked = block.properties.checked === true;
546
+ let gutter = null;
547
+ if (block.type === "bulleted_list") {
548
+ gutter = /* @__PURE__ */ jsx(Text, { style: [styles.text, styles.marker, {
549
+ color: palette.text
550
+ }], children: "\u2022" });
551
+ } else if (block.type === "numbered_list") {
552
+ gutter = /* @__PURE__ */ jsx(Text, { style: [styles.text, styles.marker, {
553
+ color: palette.text
554
+ }], children: `${number != null ? number : 1}.` });
555
+ } else if (block.type === "todo") {
556
+ gutter = /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "checkbox", accessibilityState: {
557
+ checked
558
+ }, onPress: onToggleTodo, hitSlop: 8, style: styles.check, children: /* @__PURE__ */ jsx(Ionicons, { name: checked ? "checkbox" : "square-outline", size: 21, color: checked ? palette.primary : palette.textMuted }) });
559
+ } else if (block.type === "toggle") {
560
+ gutter = /* @__PURE__ */ jsx(Ionicons, { name: "caret-down", size: 14, color: palette.textMuted, style: styles.caret });
561
+ } else if (block.type === "callout") {
562
+ gutter = /* @__PURE__ */ jsx(Text, { style: styles.inlineEmoji, children: (_a = blockIcon({
563
+ properties: block.properties
564
+ })) != null ? _a : "\u{1F4A1}" });
565
+ }
566
+ return /* @__PURE__ */ jsxs(View, { style: [styles.row, indent, block.type === "quote" && [styles.quote, {
567
+ borderLeftColor: palette.text
568
+ }], block.type === "callout" && [styles.callout, {
569
+ backgroundColor: palette.fill
570
+ }], block.type === "code" && [styles.code, {
571
+ backgroundColor: palette.fill
572
+ }], block.type.startsWith("heading") && styles.headingRow], children: [
573
+ gutter,
574
+ /* @__PURE__ */ jsx(TextInput, { ref: registerInput, value: block.text, onChangeText, onFocus, multiline: true, scrollEnabled: false, submitBehavior: block.type === "code" ? "newline" : "submit", onSubmitEditing: block.type === "code" ? void 0 : onSubmit, onKeyPress: (e) => {
575
+ if (e.nativeEvent.key === "Backspace") onBackspace();
576
+ }, autoCorrect: block.type !== "code", autoCapitalize: block.type === "code" ? "none" : "sentences", placeholder: focused ? (_b = PLACEHOLDER[block.type]) != null ? _b : "Type something\u2026" : PLACEHOLDER[block.type], placeholderTextColor: palette.textFaint, style: [styles.input, (_c = TEXT_STYLE[block.type]) != null ? _c : styles.text, {
577
+ color: palette.text
578
+ }, block.type === "todo" && checked && styles.done, block.type === "todo" && checked && {
579
+ color: palette.textMuted
580
+ }, block.type === "code" && styles.codeText], textAlignVertical: "top" })
581
+ ] });
582
+ }
583
+ function EditorToolbar({
584
+ palette,
585
+ block,
586
+ onTurnInto,
587
+ onDivider,
588
+ onSubPage,
589
+ onDelete,
590
+ onDone
591
+ }) {
592
+ return /* @__PURE__ */ jsxs(View, { style: [styles.toolbar, {
593
+ backgroundColor: palette.card,
594
+ borderTopColor: palette.hairline
595
+ }], children: [
596
+ /* @__PURE__ */ jsxs(ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, keyboardShouldPersistTaps: "always", contentContainerStyle: styles.toolbarContent, children: [
597
+ TURN_INTO.map((t) => {
598
+ const active = t.type === block.type || t.type === "paragraph" && block.type === "text";
599
+ return /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: `Turn into ${t.label}`, accessibilityState: {
600
+ selected: active
601
+ }, onPress: () => onTurnInto(t.type), style: [styles.tool, {
602
+ backgroundColor: active ? palette.primarySoft : palette.fill
603
+ }], children: /* @__PURE__ */ jsx(Text, { style: [styles.toolLabel, {
604
+ color: active ? palette.primary : palette.text
605
+ }], children: t.short }) }, t.type);
606
+ }),
607
+ /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: "Insert divider", onPress: onDivider, style: [styles.tool, {
608
+ backgroundColor: palette.fill
609
+ }], children: /* @__PURE__ */ jsx(Ionicons, { name: "remove-outline", size: 18, color: palette.text }) }),
610
+ /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: "Insert sub-page", onPress: onSubPage, style: [styles.tool, {
611
+ backgroundColor: palette.fill
612
+ }], children: /* @__PURE__ */ jsx(Ionicons, { name: "document-text-outline", size: 17, color: palette.text }) }),
613
+ /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: "Delete block", onPress: onDelete, style: [styles.tool, {
614
+ backgroundColor: palette.fill
615
+ }], children: /* @__PURE__ */ jsx(Ionicons, { name: "trash-outline", size: 17, color: palette.danger }) })
616
+ ] }),
617
+ /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: "Done editing", onPress: onDone, style: styles.toolDone, hitSlop: 6, children: /* @__PURE__ */ jsx(Ionicons, { name: "chevron-down", size: 22, color: palette.text }) })
618
+ ] });
619
+ }
620
+ const styles = StyleSheet.create({
621
+ flex: {
622
+ flex: 1
623
+ },
624
+ center: {
625
+ flex: 1,
626
+ alignItems: "center",
627
+ justifyContent: "center",
628
+ padding: 24
629
+ },
630
+ content: {
631
+ paddingHorizontal: 20,
632
+ paddingTop: 12,
633
+ paddingBottom: 40
634
+ },
635
+ muted: {
636
+ fontSize: 15,
637
+ textAlign: "center"
638
+ },
639
+ retry: {
640
+ marginTop: 12,
641
+ padding: 8
642
+ },
643
+ pageActions: {
644
+ flexDirection: "row",
645
+ alignItems: "center",
646
+ marginBottom: 4
647
+ },
648
+ pageAction: {
649
+ flexDirection: "row",
650
+ alignItems: "center",
651
+ gap: 6,
652
+ paddingHorizontal: 8,
653
+ paddingVertical: 6,
654
+ borderRadius: 8
655
+ },
656
+ pageActionLabel: {
657
+ fontSize: 14,
658
+ fontWeight: "500"
659
+ },
660
+ pageEmoji: {
661
+ fontSize: 40
662
+ },
663
+ emojiGrid: {
664
+ flexDirection: "row",
665
+ flexWrap: "wrap",
666
+ padding: 8,
667
+ borderRadius: 14,
668
+ marginBottom: 8
669
+ },
670
+ emojiCell: {
671
+ width: "12.5%",
672
+ aspectRatio: 1,
673
+ alignItems: "center",
674
+ justifyContent: "center"
675
+ },
676
+ emoji: {
677
+ fontSize: 24
678
+ },
679
+ emojiRemove: {
680
+ width: "100%",
681
+ alignItems: "center",
682
+ paddingVertical: 8
683
+ },
684
+ title: {
685
+ fontSize: 32,
686
+ fontWeight: "800",
687
+ lineHeight: 38,
688
+ padding: 0,
689
+ letterSpacing: -0.5
690
+ },
691
+ meta: {
692
+ fontSize: 12,
693
+ marginTop: 6
694
+ },
695
+ body: {
696
+ marginTop: 16,
697
+ gap: 2
698
+ },
699
+ row: {
700
+ flexDirection: "row",
701
+ alignItems: "flex-start",
702
+ gap: 8,
703
+ borderRadius: 6
704
+ },
705
+ headingRow: {
706
+ marginTop: 10
707
+ },
708
+ linkRow: {
709
+ alignItems: "center",
710
+ paddingVertical: 6
711
+ },
712
+ input: {
713
+ flex: 1,
714
+ padding: 0,
715
+ paddingVertical: 3,
716
+ margin: 0,
717
+ minHeight: 30
718
+ },
719
+ text: {
720
+ fontSize: 16,
721
+ lineHeight: 24
722
+ },
723
+ done: {
724
+ textDecorationLine: "line-through"
725
+ },
726
+ marker: {
727
+ minWidth: 18,
728
+ paddingTop: 3
729
+ },
730
+ check: {
731
+ paddingTop: 4
732
+ },
733
+ caret: {
734
+ paddingTop: 9
735
+ },
736
+ link: {
737
+ fontWeight: "600",
738
+ borderBottomWidth: 1,
739
+ flexShrink: 1
740
+ },
741
+ quote: {
742
+ borderLeftWidth: 3,
743
+ paddingLeft: 12
744
+ },
745
+ callout: {
746
+ padding: 12,
747
+ borderRadius: mobileTokens.radius.sm
748
+ },
749
+ inlineEmoji: {
750
+ fontSize: 18,
751
+ lineHeight: 30
752
+ },
753
+ code: {
754
+ padding: 12,
755
+ borderRadius: mobileTokens.radius.sm
756
+ },
757
+ codeText: {
758
+ fontFamily: Platform.OS === "ios" ? "Menlo" : "monospace",
759
+ fontSize: 13,
760
+ lineHeight: 19
761
+ },
762
+ dividerHit: {
763
+ paddingVertical: 10
764
+ },
765
+ divider: {
766
+ height: StyleSheet.hairlineWidth
767
+ },
768
+ unsupported: {
769
+ borderWidth: 1,
770
+ borderStyle: "dashed",
771
+ padding: 10,
772
+ alignItems: "center",
773
+ marginVertical: 2
774
+ },
775
+ unsupportedText: {
776
+ flex: 1,
777
+ fontSize: 14,
778
+ textTransform: "capitalize"
779
+ },
780
+ webOnly: {
781
+ fontSize: 12,
782
+ fontWeight: "600"
783
+ },
784
+ appendArea: {
785
+ minHeight: 160,
786
+ paddingTop: 8
787
+ },
788
+ startHint: {
789
+ fontSize: 16
790
+ },
791
+ toolbar: {
792
+ flexDirection: "row",
793
+ alignItems: "center",
794
+ borderTopWidth: StyleSheet.hairlineWidth,
795
+ paddingVertical: 6
796
+ },
797
+ toolbarContent: {
798
+ gap: 6,
799
+ paddingHorizontal: 10,
800
+ alignItems: "center"
801
+ },
802
+ tool: {
803
+ minWidth: 40,
804
+ height: 36,
805
+ paddingHorizontal: 10,
806
+ borderRadius: 10,
807
+ alignItems: "center",
808
+ justifyContent: "center"
809
+ },
810
+ toolLabel: {
811
+ fontSize: 15,
812
+ fontWeight: "700"
813
+ },
814
+ toolDone: {
815
+ paddingHorizontal: 12,
816
+ height: 36,
817
+ justifyContent: "center"
818
+ }
819
+ });export{NotionPageView};//# sourceMappingURL=NotionPageView.js.map