@adminide-stack/yantra-mobile 12.0.141-alpha.1 → 12.0.142-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.
- package/lib/features/agent-chat/NativeAgentChat.js +21 -4
- package/lib/features/agent-chat/NativeAgentChat.js.map +1 -1
- package/lib/features/chat/ApprovalCard.js +353 -0
- package/lib/features/chat/ApprovalCard.js.map +1 -0
- package/lib/features/chat/AskUserCard.js +9 -2
- package/lib/features/chat/AskUserCard.js.map +1 -1
- package/lib/features/chat/askUser.js +25 -3
- package/lib/features/chat/askUser.js.map +1 -1
- package/lib/features/chat/queuedFollowUpRows.js +13 -0
- package/lib/features/chat/queuedFollowUpRows.js.map +1 -0
- package/lib/features/dictate/DictateExperience.js +59 -7
- package/lib/features/dictate/DictateExperience.js.map +1 -1
- package/lib/features/dictate/components/NoteView.js +227 -12
- package/lib/features/dictate/components/NoteView.js.map +1 -1
- package/lib/features/dictate/dictateClient.js +93 -23
- package/lib/features/dictate/dictateClient.js.map +1 -1
- package/lib/features/dictate/dictatePreference.js +19 -0
- package/lib/features/dictate/dictatePreference.js.map +1 -0
- package/lib/features/dictate/noteText.js +17 -2
- package/lib/features/dictate/noteText.js.map +1 -1
- package/lib/features/dictate/privacy.js +96 -0
- package/lib/features/dictate/privacy.js.map +1 -0
- package/lib/features/dictate/shownNote.js +24 -0
- package/lib/features/dictate/shownNote.js.map +1 -0
- package/lib/features/discover/DiscoverArticle.js +105 -92
- package/lib/features/discover/DiscoverArticle.js.map +1 -1
- package/lib/features/discover/DiscoverFeed.js +97 -48
- package/lib/features/discover/DiscoverFeed.js.map +1 -1
- package/lib/features/discover/DiscoverFollowUp.js +135 -0
- package/lib/features/discover/DiscoverFollowUp.js.map +1 -0
- package/lib/features/discover/DiscoverSidebar.js +555 -0
- package/lib/features/discover/DiscoverSidebar.js.map +1 -0
- package/lib/features/discover/DiscoverSkeletons.js +123 -0
- package/lib/features/discover/DiscoverSkeletons.js.map +1 -0
- package/lib/features/discover/DiscoverStoryCards.js +193 -87
- package/lib/features/discover/DiscoverStoryCards.js.map +1 -1
- package/lib/features/discover/followUpQuery.js +42 -0
- package/lib/features/discover/followUpQuery.js.map +1 -0
- package/lib/features/discover/markets.js +37 -0
- package/lib/features/discover/markets.js.map +1 -0
- package/lib/features/discover/useDiscoverSidebar.js +148 -0
- package/lib/features/discover/useDiscoverSidebar.js.map +1 -0
- package/lib/features/discover/weather.js +42 -0
- package/lib/features/discover/weather.js.map +1 -0
- package/lib/features/expenses/ExpensesAgentChatPane.js +1 -1
- package/lib/features/expenses/ExpensesAgentChatPane.js.map +1 -1
- package/lib/features/inbox/InboxAgentChatPane.js +1 -1
- package/lib/features/inbox/InboxAgentChatPane.js.map +1 -1
- package/lib/features/job-search/JobSearchAgentChatPane.js +1 -0
- package/lib/features/job-search/JobSearchAgentChatPane.js.map +1 -1
- package/lib/features/local-services/LocalServicesAgentChatPane.js +1 -1
- package/lib/features/local-services/LocalServicesAgentChatPane.js.map +1 -1
- package/lib/features/movies/MoviesAgentChatPane.js +1 -1
- package/lib/features/movies/MoviesAgentChatPane.js.map +1 -1
- package/lib/features/notion/NotionBlockSheets.js +206 -0
- package/lib/features/notion/NotionBlockSheets.js.map +1 -0
- package/lib/features/notion/NotionBlockView.js +36 -0
- package/lib/features/notion/NotionBlockView.js.map +1 -0
- package/lib/features/notion/NotionCommentsSheet.js +461 -0
- package/lib/features/notion/NotionCommentsSheet.js.map +1 -0
- package/lib/features/notion/NotionConnectionsSheet.js +244 -0
- package/lib/features/notion/NotionConnectionsSheet.js.map +1 -0
- package/lib/features/notion/NotionHistorySheet.js +439 -0
- package/lib/features/notion/NotionHistorySheet.js.map +1 -0
- package/lib/features/notion/NotionMediaBlocks.js +803 -0
- package/lib/features/notion/NotionMediaBlocks.js.map +1 -0
- package/lib/features/notion/NotionMentionSheet.js +279 -0
- package/lib/features/notion/NotionMentionSheet.js.map +1 -0
- package/lib/features/notion/NotionPageMenu.js +585 -0
- package/lib/features/notion/NotionPageMenu.js.map +1 -0
- package/lib/features/notion/NotionPageTree.js +220 -0
- package/lib/features/notion/NotionPageTree.js.map +1 -0
- package/lib/features/notion/NotionPageView.js +1253 -152
- package/lib/features/notion/NotionPageView.js.map +1 -1
- package/lib/features/notion/NotionShareSheet.js +606 -0
- package/lib/features/notion/NotionShareSheet.js.map +1 -0
- package/lib/features/notion/NotionSheets.js +87 -15
- package/lib/features/notion/NotionSheets.js.map +1 -1
- package/lib/features/notion/NotionSidebarSections.js +492 -0
- package/lib/features/notion/NotionSidebarSections.js.map +1 -0
- package/lib/features/notion/NotionWorkspaceAdmin.js +659 -0
- package/lib/features/notion/NotionWorkspaceAdmin.js.map +1 -0
- package/lib/features/notion/NotionWorkspaceView.js +257 -45
- package/lib/features/notion/NotionWorkspaceView.js.map +1 -1
- package/lib/features/notion/database/DatabaseCells.js +554 -0
- package/lib/features/notion/database/DatabaseCells.js.map +1 -0
- package/lib/features/notion/database/DatabaseDateLayouts.js +792 -0
- package/lib/features/notion/database/DatabaseDateLayouts.js.map +1 -0
- package/lib/features/notion/database/DatabaseLayouts.js +461 -0
- package/lib/features/notion/database/DatabaseLayouts.js.map +1 -0
- package/lib/features/notion/database/DatabaseSheets.js +791 -0
- package/lib/features/notion/database/DatabaseSheets.js.map +1 -0
- package/lib/features/notion/database/NotionDatabaseView.js +817 -0
- package/lib/features/notion/database/NotionDatabaseView.js.map +1 -0
- package/lib/features/notion/database/RowPropertiesPanel.js +162 -0
- package/lib/features/notion/database/RowPropertiesPanel.js.map +1 -0
- package/lib/features/notion/database/chartData.js +89 -0
- package/lib/features/notion/database/chartData.js.map +1 -0
- package/lib/features/notion/database/chartView.js +112 -0
- package/lib/features/notion/database/chartView.js.map +1 -0
- package/lib/features/notion/database/connectorButton.js +33 -0
- package/lib/features/notion/database/connectorButton.js.map +1 -0
- package/lib/features/notion/database/databaseCalc.js +208 -0
- package/lib/features/notion/database/databaseCalc.js.map +1 -0
- package/lib/features/notion/database/databaseCalendar.js +157 -0
- package/lib/features/notion/database/databaseCalendar.js.map +1 -0
- package/lib/features/notion/database/databaseCsv.js +98 -0
- package/lib/features/notion/database/databaseCsv.js.map +1 -0
- package/lib/features/notion/database/databaseCsvActions.js +58 -0
- package/lib/features/notion/database/databaseCsvActions.js.map +1 -0
- package/lib/features/notion/database/databaseFilter.js +473 -0
- package/lib/features/notion/database/databaseFilter.js.map +1 -0
- package/lib/features/notion/database/databaseFormula.js +1072 -0
- package/lib/features/notion/database/databaseFormula.js.map +1 -0
- package/lib/features/notion/database/databaseGroup.js +151 -0
- package/lib/features/notion/database/databaseGroup.js.map +1 -0
- package/lib/features/notion/database/databaseRollup.js +58 -0
- package/lib/features/notion/database/databaseRollup.js.map +1 -0
- package/lib/features/notion/database/databaseTimeline.js +156 -0
- package/lib/features/notion/database/databaseTimeline.js.map +1 -0
- package/lib/features/notion/database/databaseView.js +1188 -0
- package/lib/features/notion/database/databaseView.js.map +1 -0
- package/lib/features/notion/database/databaseViews.js +310 -0
- package/lib/features/notion/database/databaseViews.js.map +1 -0
- package/lib/features/notion/database/relationSource.js +92 -0
- package/lib/features/notion/database/relationSource.js.map +1 -0
- package/lib/features/notion/database/uniqueId.js +17 -0
- package/lib/features/notion/database/uniqueId.js.map +1 -0
- package/lib/features/notion/database/useNotionDatabase.js +617 -0
- package/lib/features/notion/database/useNotionDatabase.js.map +1 -0
- package/lib/features/notion/notionAgentRunStatus.js +39 -0
- package/lib/features/notion/notionAgentRunStatus.js.map +1 -0
- package/lib/features/notion/notionCodeLanguages.js +112 -0
- package/lib/features/notion/notionCodeLanguages.js.map +1 -0
- package/lib/features/notion/notionComments.js +86 -0
- package/lib/features/notion/notionComments.js.map +1 -0
- package/lib/features/notion/notionConnections.js +74 -0
- package/lib/features/notion/notionConnections.js.map +1 -0
- package/lib/features/notion/notionDocuments.js +453 -1
- package/lib/features/notion/notionDocuments.js.map +1 -1
- package/lib/features/notion/notionEditorModel.js +142 -7
- package/lib/features/notion/notionEditorModel.js.map +1 -1
- package/lib/features/notion/notionMarkdownShortcuts.js +51 -0
- package/lib/features/notion/notionMarkdownShortcuts.js.map +1 -0
- package/lib/features/notion/notionMedia.js +119 -0
- package/lib/features/notion/notionMedia.js.map +1 -0
- package/lib/features/notion/notionMentionDate.js +32 -0
- package/lib/features/notion/notionMentionDate.js.map +1 -0
- package/lib/features/notion/notionMentionOptions.js +162 -0
- package/lib/features/notion/notionMentionOptions.js.map +1 -0
- package/lib/features/notion/notionNotesAgent.js +445 -0
- package/lib/features/notion/notionNotesAgent.js.map +1 -0
- package/lib/features/notion/notionPageAccess.js +168 -0
- package/lib/features/notion/notionPageAccess.js.map +1 -0
- package/lib/features/notion/notionPageActions.js +138 -0
- package/lib/features/notion/notionPageActions.js.map +1 -0
- package/lib/features/notion/notionPageHistory.js +154 -0
- package/lib/features/notion/notionPageHistory.js.map +1 -0
- package/lib/features/notion/notionPageKinds.js +200 -0
- package/lib/features/notion/notionPageKinds.js.map +1 -0
- package/lib/features/notion/notionRecents.js +48 -0
- package/lib/features/notion/notionRecents.js.map +1 -0
- package/lib/features/notion/notionRichText.js +177 -0
- package/lib/features/notion/notionRichText.js.map +1 -0
- package/lib/features/notion/notionRichTitle.js +336 -0
- package/lib/features/notion/notionRichTitle.js.map +1 -0
- package/lib/features/notion/useNotionWorkspace.js +272 -13
- package/lib/features/notion/useNotionWorkspace.js.map +1 -1
- package/lib/features/notion/usePageActions.js +155 -0
- package/lib/features/notion/usePageActions.js.map +1 -0
- package/lib/features/resume/ResumeAgentChatPane.js +1 -1
- package/lib/features/resume/ResumeAgentChatPane.js.map +1 -1
- package/lib/features/shopping/ShoppingAgentChatPane.js +1 -1
- package/lib/features/shopping/ShoppingAgentChatPane.js.map +1 -1
- package/lib/features/study/StudyAgentChatPane.js +1 -1
- package/lib/features/study/StudyAgentChatPane.js.map +1 -1
- package/lib/features/travel/TravelAgentChatPane.js +1 -1
- package/lib/features/travel/TravelAgentChatPane.js.map +1 -1
- package/lib/features/webbuilder/WebBuilderExperience.js +40 -8
- package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -1
- package/lib/features/webbuilder/buildFragments.js +1 -1
- package/lib/features/webbuilder/buildFragments.js.map +1 -1
- package/lib/features/webbuilder/codeFiles.js +302 -0
- package/lib/features/webbuilder/codeFiles.js.map +1 -0
- package/lib/features/webbuilder/codeHighlight.js +209 -0
- package/lib/features/webbuilder/codeHighlight.js.map +1 -0
- package/lib/features/webbuilder/components/CodeView.js +682 -52
- package/lib/features/webbuilder/components/CodeView.js.map +1 -1
- package/lib/features/webbuilder/components/PreviewScreen.js +59 -38
- package/lib/features/webbuilder/components/PreviewScreen.js.map +1 -1
- package/lib/features/webbuilder/components/ProjectChat.js +3 -3
- package/lib/features/webbuilder/components/ProjectChat.js.map +1 -1
- package/lib/features/webbuilder/stepLabels.js +68 -0
- package/lib/features/webbuilder/stepLabels.js.map +1 -0
- package/lib/hooks/useHostChatSteering.js +45 -0
- package/lib/hooks/useHostChatSteering.js.map +1 -0
- package/lib/screens/Chat/index.js +2 -12
- package/lib/screens/Chat/index.js.map +1 -1
- package/lib/screens/ExpensesNative/useExpensesHostChat.js +25 -5
- package/lib/screens/ExpensesNative/useExpensesHostChat.js.map +1 -1
- package/lib/screens/InboxNative/useInboxHostChat.js +25 -5
- package/lib/screens/InboxNative/useInboxHostChat.js.map +1 -1
- package/lib/screens/JobSearchNative/useJobSearchHostChat.js +25 -5
- package/lib/screens/JobSearchNative/useJobSearchHostChat.js.map +1 -1
- package/lib/screens/LocalServicesNative/useLocalServicesHostChat.js +25 -5
- package/lib/screens/LocalServicesNative/useLocalServicesHostChat.js.map +1 -1
- package/lib/screens/MoviesNative/useMoviesHostChat.js +25 -5
- package/lib/screens/MoviesNative/useMoviesHostChat.js.map +1 -1
- package/lib/screens/NotionPage/index.js +2 -2
- package/lib/screens/NotionPage/index.js.map +1 -1
- package/lib/screens/ResumeNative/useResumeHostChat.js +25 -5
- package/lib/screens/ResumeNative/useResumeHostChat.js.map +1 -1
- package/lib/screens/ShoppingNative/useShoppingHostChat.js +25 -5
- package/lib/screens/ShoppingNative/useShoppingHostChat.js.map +1 -1
- package/lib/screens/StudyNative/useStudyHostChat.js +25 -5
- package/lib/screens/StudyNative/useStudyHostChat.js.map +1 -1
- package/lib/screens/TravelNative/useTravelHostChat.js +25 -5
- package/lib/screens/TravelNative/useTravelHostChat.js.map +1 -1
- package/lib/screens/WebBuilderNative/codeWorkspaceApi.js +222 -0
- package/lib/screens/WebBuilderNative/codeWorkspaceApi.js.map +1 -0
- package/lib/screens/WebBuilderNative/index.js +1 -1
- package/lib/screens/WebBuilderNative/index.js.map +1 -1
- package/lib/screens/WebBuilderNative/sandboxProxyApi.js +126 -4
- package/lib/screens/WebBuilderNative/sandboxProxyApi.js.map +1 -1
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js +120 -11
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,817 @@
|
|
|
1
|
+
import {jsx,jsxs}from'react/jsx-runtime';import {useState,useMemo,useEffect,useCallback}from'react';import {Share,View,StyleSheet,ActivityIndicator,Pressable,Text,ScrollView,TextInput}from'react-native';import {Ionicons}from'@expo/vector-icons';import {useMutation}from'@apollo/client/index.js';import {useNavigation,StackActions}from'@react-navigation/native';import {useSafeAreaInsets}from'react-native-safe-area-context';import {NATIVE_NOTION_DUPLICATE_BLOCK}from'../notionDocuments.js';import {useNotionToast,TextPromptDialog,NotionToast}from'../NotionPageMenu.js';import {notionPalette}from'../notionTheme.js';import {ui,EmptyState}from'../notionUi.js';import {recordRecent}from'../notionRecents.js';import {rowTitle,CellEditorSheet}from'./DatabaseCells.js';import {TableLayout,ListLayout,GalleryLayout,BoardLayout}from'./DatabaseLayouts.js';import {ChartLayout,TimelineLayout,CalendarLayout}from'./DatabaseDateLayouts.js';import {FilterSheet,SortSheet,PropertiesSheet,PropertyEditorSheet,ViewOptionsSheet,NewViewSheet,ChoiceSheet}from'./DatabaseSheets.js';import {applyRowFilter,renameConditionProperty,dropConditionProperty,activeConditions}from'./databaseFilter.js';import {databaseCsv,planDatabaseCsvImport}from'./databaseCsvActions.js';import {makeCellGetter}from'./databaseFormula.js';import {rollupResolver}from'./databaseRollup.js';import {useRelationSource,RelationProvider}from'./relationSource.js';import {prefillForGroup}from'./databaseGroup.js';import {sortRows,renameSchemaProperty,renameRowPatch,renameSortProperty,changeSchemaPropertyType,convertCellValue,removeSchemaProperty,dropSortProperty,uniquePropertyName,addSchemaProperty,normalizeStatusOptions,groupRows,selectValueToCell}from'./databaseView.js';import {parseVisibleProperties,parseHiddenProperties,parseViewWidths,tableDisplayColumns,shownProperties,renameViewProperty,remapSettingsProperty,uniqueViewName,DEFAULT_VIEW_ID,serializeVisibleProperties,mergeViewSettings}from'./databaseViews.js';import {useNotionDatabase}from'./useNotionDatabase.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
|
+
var _a;
|
|
21
|
+
let pickDocument = null;
|
|
22
|
+
try {
|
|
23
|
+
pickDocument = (_a = require("expo-document-picker").getDocumentAsync) != null ? _a : null;
|
|
24
|
+
} catch (e) {
|
|
25
|
+
pickDocument = null;
|
|
26
|
+
}
|
|
27
|
+
const VIEW_ICONS = {
|
|
28
|
+
table: "grid-outline",
|
|
29
|
+
board: "albums-outline",
|
|
30
|
+
calendar: "calendar-outline",
|
|
31
|
+
timeline: "git-commit-outline",
|
|
32
|
+
gallery: "images-outline",
|
|
33
|
+
list: "list-outline",
|
|
34
|
+
chart: "bar-chart-outline"
|
|
35
|
+
};
|
|
36
|
+
function NotionDatabaseView({
|
|
37
|
+
orgName,
|
|
38
|
+
blockId,
|
|
39
|
+
isDark
|
|
40
|
+
}) {
|
|
41
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
42
|
+
const palette = notionPalette(isDark);
|
|
43
|
+
const navigation = useNavigation();
|
|
44
|
+
const insets = useSafeAreaInsets();
|
|
45
|
+
const db = useNotionDatabase(blockId);
|
|
46
|
+
const {
|
|
47
|
+
toast,
|
|
48
|
+
show: showToast,
|
|
49
|
+
hide: hideToast
|
|
50
|
+
} = useNotionToast();
|
|
51
|
+
const [duplicateBlock] = useMutation(NATIVE_NOTION_DUPLICATE_BLOCK);
|
|
52
|
+
const [sheet, setSheet] = useState(null);
|
|
53
|
+
const [search, setSearch] = useState("");
|
|
54
|
+
const [searching, setSearching] = useState(false);
|
|
55
|
+
const [selecting, setSelecting] = useState(false);
|
|
56
|
+
const [selected, setSelected] = useState(/* @__PURE__ */ new Set());
|
|
57
|
+
const [menuRow, setMenuRow] = useState(null);
|
|
58
|
+
const [menuView, setMenuView] = useState(null);
|
|
59
|
+
const [editing, setEditing] = useState(null);
|
|
60
|
+
const [editProperty, setEditProperty] = useState(null);
|
|
61
|
+
const [refreshing, setRefreshing] = useState(false);
|
|
62
|
+
const view = db.activeView;
|
|
63
|
+
const columns = db.columns;
|
|
64
|
+
const relations = useRelationSource(columns, blockId, db.rows, db.schema);
|
|
65
|
+
const getValue = useMemo(() => makeCellGetter(columns, /* @__PURE__ */ new Date(), rollupResolver(columns, relations)), [columns, relations]);
|
|
66
|
+
const workspaceId = (_b = (_a2 = db.block) == null ? void 0 : _a2.workspaceId) != null ? _b : null;
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (workspaceId) recordRecent(workspaceId, {
|
|
69
|
+
id: blockId,
|
|
70
|
+
title: db.title,
|
|
71
|
+
icon: db.icon
|
|
72
|
+
});
|
|
73
|
+
}, [blockId, db.icon, db.title, workspaceId]);
|
|
74
|
+
const shownRows = useMemo(() => {
|
|
75
|
+
const filtered = applyRowFilter(db.rows, columns, {
|
|
76
|
+
search
|
|
77
|
+
}, view.conditions, {
|
|
78
|
+
getValue
|
|
79
|
+
});
|
|
80
|
+
return sortRows(filtered, view.sorts, columns, getValue);
|
|
81
|
+
}, [columns, db.rows, getValue, search, view.conditions, view.sorts]);
|
|
82
|
+
const visible = useMemo(() => parseVisibleProperties(view.properties, columns), [columns, view.properties]);
|
|
83
|
+
const hidden = useMemo(() => parseHiddenProperties(view.properties), [view.properties]);
|
|
84
|
+
const widths = useMemo(() => parseViewWidths(view.properties), [view.properties]);
|
|
85
|
+
const tableColumns = useMemo(() => tableDisplayColumns(columns, visible, widths, hidden), [columns, hidden, visible, widths]);
|
|
86
|
+
const visibleNames = useMemo(() => tableColumns.filter((c) => c.type !== "title").map((c) => c.name), [tableColumns]);
|
|
87
|
+
const cardProps = useMemo(() => shownProperties(columns, visible, {
|
|
88
|
+
exclude: view.groupBy ? [view.groupBy] : []
|
|
89
|
+
}), [columns, view.groupBy, visible]);
|
|
90
|
+
const nonTitleNames = useMemo(() => columns.filter((c) => c.type !== "title").map((c) => c.name), [columns]);
|
|
91
|
+
const thenOpen = useCallback((next) => {
|
|
92
|
+
setSheet(null);
|
|
93
|
+
setTimeout(() => setSheet(next), 450);
|
|
94
|
+
}, []);
|
|
95
|
+
const report = useCallback((err) => err && showToast({
|
|
96
|
+
message: err
|
|
97
|
+
}), [showToast]);
|
|
98
|
+
const changeView = useCallback((change) => db.changeView(view.id, change).then(report), [db, report, view.id]);
|
|
99
|
+
const changeSettings = (patch) => changeView({
|
|
100
|
+
settings: mergeViewSettings(view.settings, patch)
|
|
101
|
+
});
|
|
102
|
+
const setVisibleNames = (names) => changeView({
|
|
103
|
+
properties: serializeVisibleProperties(names, widths, nonTitleNames)
|
|
104
|
+
});
|
|
105
|
+
const openRow = useCallback((row) => navigation.dispatch(StackActions.push("MainStack.NotionPage", {
|
|
106
|
+
orgName,
|
|
107
|
+
blockId: row.id
|
|
108
|
+
})), [navigation, orgName]);
|
|
109
|
+
const addRow = useCallback(async (group, values) => {
|
|
110
|
+
const initial = __spreadValues({}, values);
|
|
111
|
+
if (group) {
|
|
112
|
+
const v = prefillForGroup(group.column, group.value);
|
|
113
|
+
if (v !== void 0) initial[group.column.name] = v;
|
|
114
|
+
}
|
|
115
|
+
const res = await db.addRow(initial);
|
|
116
|
+
if (res.error) showToast({
|
|
117
|
+
message: `Couldn't add a row. ${res.error}`
|
|
118
|
+
});
|
|
119
|
+
else if (res.id) {
|
|
120
|
+
const created = {
|
|
121
|
+
id: res.id};
|
|
122
|
+
const title = columns.find((c) => c.type === "title");
|
|
123
|
+
if (title) setEditing({
|
|
124
|
+
rowId: created.id,
|
|
125
|
+
column: title.name
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}, [columns, db, showToast]);
|
|
129
|
+
const deleteRows = useCallback(async (ids) => {
|
|
130
|
+
if (!ids.length) return;
|
|
131
|
+
const {
|
|
132
|
+
deleted,
|
|
133
|
+
error
|
|
134
|
+
} = await db.deleteRows(ids);
|
|
135
|
+
setSelected(/* @__PURE__ */ new Set());
|
|
136
|
+
setSelecting(false);
|
|
137
|
+
if (error) showToast({
|
|
138
|
+
message: `Couldn't delete ${ids.length - deleted.length} row(s). ${error}`
|
|
139
|
+
});
|
|
140
|
+
else showToast({
|
|
141
|
+
message: deleted.length === 1 ? "Row deleted" : `${deleted.length} rows deleted`,
|
|
142
|
+
actionLabel: "Undo",
|
|
143
|
+
onAction: () => db.restoreRows(deleted)
|
|
144
|
+
});
|
|
145
|
+
}, [db, showToast]);
|
|
146
|
+
const duplicateRow = useCallback(async (row) => {
|
|
147
|
+
var _a3;
|
|
148
|
+
try {
|
|
149
|
+
await duplicateBlock({
|
|
150
|
+
variables: {
|
|
151
|
+
blockId: row.id,
|
|
152
|
+
includeChildren: true
|
|
153
|
+
},
|
|
154
|
+
errorPolicy: "none"
|
|
155
|
+
});
|
|
156
|
+
await db.reloadRows();
|
|
157
|
+
showToast({
|
|
158
|
+
message: "Row duplicated"
|
|
159
|
+
});
|
|
160
|
+
} catch (err) {
|
|
161
|
+
showToast({
|
|
162
|
+
message: `Couldn't duplicate. ${(_a3 = err == null ? void 0 : err.message) != null ? _a3 : ""}`
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}, [db, duplicateBlock, showToast]);
|
|
166
|
+
const toggleCheckbox = useCallback((row, column) => {
|
|
167
|
+
var _a3;
|
|
168
|
+
return db.updateCell(row.id, column.name, !(((_a3 = row.properties) == null ? void 0 : _a3[column.name]) === true)).then(report);
|
|
169
|
+
}, [db, report]);
|
|
170
|
+
const forEachView = useCallback(async (fn) => {
|
|
171
|
+
for (const v of db.views) {
|
|
172
|
+
const change = fn(v);
|
|
173
|
+
if (change) await db.changeView(v.id, change);
|
|
174
|
+
}
|
|
175
|
+
}, [db]);
|
|
176
|
+
const renameProperty = useCallback(async (from, to) => {
|
|
177
|
+
const result = renameSchemaProperty(db.schema, from, to);
|
|
178
|
+
if (!result.ok) return result.error;
|
|
179
|
+
const all = await db.loadAll();
|
|
180
|
+
const err = await db.saveSchema(result.schema);
|
|
181
|
+
if (err) return err;
|
|
182
|
+
await Promise.allSettled(all.map((r) => {
|
|
183
|
+
const patch = renameRowPatch(r.properties, from, to);
|
|
184
|
+
return patch ? db.patchRow(r.id, patch) : null;
|
|
185
|
+
}));
|
|
186
|
+
await forEachView((v) => {
|
|
187
|
+
var _a3;
|
|
188
|
+
const layout = (_a3 = renameViewProperty(v, from, to)) != null ? _a3 : {};
|
|
189
|
+
const sorts = renameSortProperty(v.sorts, from, to);
|
|
190
|
+
const conditions = renameConditionProperty(v.conditions, from, to);
|
|
191
|
+
const change = __spreadValues(__spreadValues(__spreadValues({}, layout), JSON.stringify(sorts) !== JSON.stringify(v.sorts) ? {
|
|
192
|
+
sorts
|
|
193
|
+
} : {}), JSON.stringify(conditions) !== JSON.stringify(v.conditions) ? {
|
|
194
|
+
conditions
|
|
195
|
+
} : {});
|
|
196
|
+
return Object.keys(change).length ? change : null;
|
|
197
|
+
});
|
|
198
|
+
setEditProperty({
|
|
199
|
+
name: to
|
|
200
|
+
});
|
|
201
|
+
return null;
|
|
202
|
+
}, [db, forEachView]);
|
|
203
|
+
const changePropertyType = useCallback(async (name, type) => {
|
|
204
|
+
var _a3;
|
|
205
|
+
const before = db.schema[name];
|
|
206
|
+
const result = changeSchemaPropertyType(db.schema, name, type);
|
|
207
|
+
if (!result.ok) return result.error;
|
|
208
|
+
const all = await db.loadAll();
|
|
209
|
+
const err = await db.saveSchema(result.schema);
|
|
210
|
+
if (err) return err;
|
|
211
|
+
const fromType = String((_a3 = before == null ? void 0 : before.type) != null ? _a3 : "text");
|
|
212
|
+
await Promise.allSettled(all.map((r) => {
|
|
213
|
+
var _a4;
|
|
214
|
+
const value = (_a4 = r.properties) == null ? void 0 : _a4[name];
|
|
215
|
+
if (value === void 0) return null;
|
|
216
|
+
const next = convertCellValue(value, fromType, type);
|
|
217
|
+
return JSON.stringify(next) === JSON.stringify(value) ? null : db.patchRow(r.id, {
|
|
218
|
+
[name]: next
|
|
219
|
+
});
|
|
220
|
+
}));
|
|
221
|
+
return null;
|
|
222
|
+
}, [db]);
|
|
223
|
+
const deleteProperty = useCallback(async (name) => {
|
|
224
|
+
const result = removeSchemaProperty(db.schema, name);
|
|
225
|
+
if (!result.ok) {
|
|
226
|
+
showToast({
|
|
227
|
+
message: result.error
|
|
228
|
+
});
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
const err = await db.saveSchema(result.schema);
|
|
232
|
+
if (err) {
|
|
233
|
+
showToast({
|
|
234
|
+
message: err
|
|
235
|
+
});
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
setEditProperty(null);
|
|
239
|
+
await forEachView((v) => {
|
|
240
|
+
const sorts = dropSortProperty(v.sorts, name);
|
|
241
|
+
const conditions = dropConditionProperty(v.conditions, name);
|
|
242
|
+
const settings = remapSettingsProperty(v.settings, name, null);
|
|
243
|
+
const change = {};
|
|
244
|
+
if (sorts.length !== v.sorts.length) change.sorts = sorts;
|
|
245
|
+
if (conditions.length !== v.conditions.length) change.conditions = conditions;
|
|
246
|
+
if (settings) change.settings = settings;
|
|
247
|
+
if (v.groupBy === name) change.groupBy = null;
|
|
248
|
+
return Object.keys(change).length ? change : null;
|
|
249
|
+
});
|
|
250
|
+
showToast({
|
|
251
|
+
message: `Deleted \u201C${name}\u201D`
|
|
252
|
+
});
|
|
253
|
+
}, [db, forEachView, showToast]);
|
|
254
|
+
const createProperty = useCallback(
|
|
255
|
+
async (name, type) => {
|
|
256
|
+
const finalName = name || uniquePropertyName(db.schema);
|
|
257
|
+
const result = addSchemaProperty(db.schema, finalName, type);
|
|
258
|
+
if (!result.ok) return result.error;
|
|
259
|
+
const err = await db.saveSchema(result.schema);
|
|
260
|
+
if (err) return err;
|
|
261
|
+
if (visible) setVisibleNames([...visibleNames, finalName]);
|
|
262
|
+
return null;
|
|
263
|
+
},
|
|
264
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
265
|
+
[db, visible, visibleNames]
|
|
266
|
+
);
|
|
267
|
+
const exportCsv = useCallback(async () => {
|
|
268
|
+
const all = db.hasMore ? await db.loadAll() : db.rows;
|
|
269
|
+
const rows = sortRows(applyRowFilter(all, columns, {
|
|
270
|
+
search
|
|
271
|
+
}, view.conditions, {
|
|
272
|
+
getValue
|
|
273
|
+
}), view.sorts, columns, getValue);
|
|
274
|
+
const csv = databaseCsv(rows, tableColumns, getValue);
|
|
275
|
+
try {
|
|
276
|
+
await Share.share({
|
|
277
|
+
title: `${db.title || "Database"}.csv`,
|
|
278
|
+
message: csv
|
|
279
|
+
});
|
|
280
|
+
} catch (e) {
|
|
281
|
+
}
|
|
282
|
+
}, [columns, db, getValue, search, tableColumns, view.conditions, view.sorts]);
|
|
283
|
+
const importCsv = useCallback(async (text) => {
|
|
284
|
+
const plan = planDatabaseCsvImport(text, db.schema);
|
|
285
|
+
if (!plan.ok) {
|
|
286
|
+
showToast({
|
|
287
|
+
message: plan.error
|
|
288
|
+
});
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
if (plan.schemaChanged) {
|
|
292
|
+
const err = await db.saveSchema(plan.schema);
|
|
293
|
+
if (err) {
|
|
294
|
+
showToast({
|
|
295
|
+
message: `Couldn't add the CSV columns. ${err}`
|
|
296
|
+
});
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
showToast({
|
|
301
|
+
message: `Importing ${plan.rows.length} rows\u2026`
|
|
302
|
+
});
|
|
303
|
+
let created = 0;
|
|
304
|
+
for (const properties of plan.rows) {
|
|
305
|
+
const res = await db.addRow(properties);
|
|
306
|
+
if (res.id) created += 1;
|
|
307
|
+
}
|
|
308
|
+
showToast({
|
|
309
|
+
message: created === plan.rows.length ? `Imported ${created} ${created === 1 ? "row" : "rows"}` : `Imported ${created} of ${plan.rows.length} rows`
|
|
310
|
+
});
|
|
311
|
+
}, [db, showToast]);
|
|
312
|
+
const importCsvFile = useCallback(async () => {
|
|
313
|
+
var _a3, _b2;
|
|
314
|
+
if (!pickDocument) {
|
|
315
|
+
setSheet("pasteCsv");
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
try {
|
|
319
|
+
const picked = await pickDocument({
|
|
320
|
+
type: ["text/csv", "text/comma-separated-values", "text/plain", "public.comma-separated-values-text"],
|
|
321
|
+
copyToCacheDirectory: true
|
|
322
|
+
});
|
|
323
|
+
const asset = picked.canceled ? null : (_a3 = picked.assets) == null ? void 0 : _a3[0];
|
|
324
|
+
if (!asset) return;
|
|
325
|
+
const text = await (await fetch(asset.uri)).text();
|
|
326
|
+
await importCsv(text);
|
|
327
|
+
} catch (err) {
|
|
328
|
+
showToast({
|
|
329
|
+
message: `Couldn't read that file. ${(_b2 = err == null ? void 0 : err.message) != null ? _b2 : ""}`.trim()
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
}, [importCsv, showToast]);
|
|
333
|
+
const groupColumn = view.groupBy ? columns.find((c) => c.name === view.groupBy) : void 0;
|
|
334
|
+
const moveTargets = useMemo(() => {
|
|
335
|
+
var _a3;
|
|
336
|
+
if (!groupColumn || groupColumn.type !== "select" && groupColumn.type !== "status") return [];
|
|
337
|
+
const options = groupColumn.type === "status" ? normalizeStatusOptions(groupColumn.options) : (_a3 = groupColumn.options) != null ? _a3 : [];
|
|
338
|
+
return groupRows([], groupColumn.name, options);
|
|
339
|
+
}, [groupColumn]);
|
|
340
|
+
const refresh = useCallback(async () => {
|
|
341
|
+
setRefreshing(true);
|
|
342
|
+
await db.refresh();
|
|
343
|
+
setRefreshing(false);
|
|
344
|
+
}, [db]);
|
|
345
|
+
const editingRow = editing ? (_c = db.rows.find((r) => r.id === editing.rowId)) != null ? _c : null : null;
|
|
346
|
+
const editingColumn = editing ? (_d = columns.find((c) => c.name === editing.column)) != null ? _d : null : null;
|
|
347
|
+
const propertyColumn = (editProperty == null ? void 0 : editProperty.name) ? (_e = columns.find((c) => c.name === editProperty.name)) != null ? _e : null : null;
|
|
348
|
+
const activeFilterCount = activeConditions(view.conditions, columns).length;
|
|
349
|
+
if (db.loading && !db.rows.length && !db.block) {
|
|
350
|
+
return /* @__PURE__ */ jsx(View, { style: [styles.center, {
|
|
351
|
+
backgroundColor: palette.bg
|
|
352
|
+
}], children: /* @__PURE__ */ jsx(ActivityIndicator, { color: palette.textMuted }) });
|
|
353
|
+
}
|
|
354
|
+
if (db.error && !db.block) {
|
|
355
|
+
return /* @__PURE__ */ jsx(View, { style: [ui.flex, {
|
|
356
|
+
backgroundColor: palette.bg
|
|
357
|
+
}], children: /* @__PURE__ */ jsx(EmptyState, { palette, icon: "cloud-offline-outline", title: "Couldn't open this database", text: db.error, action: {
|
|
358
|
+
label: "Try again",
|
|
359
|
+
onPress: refresh
|
|
360
|
+
} }) });
|
|
361
|
+
}
|
|
362
|
+
const layoutProps = {
|
|
363
|
+
rows: shownRows,
|
|
364
|
+
columns: tableColumns,
|
|
365
|
+
allColumns: columns,
|
|
366
|
+
getValue,
|
|
367
|
+
groupBy: view.groupBy,
|
|
368
|
+
settings: view.settings,
|
|
369
|
+
isDark,
|
|
370
|
+
palette,
|
|
371
|
+
selecting,
|
|
372
|
+
selected,
|
|
373
|
+
onToggleSelect: (row) => setSelected((prev) => {
|
|
374
|
+
const next = new Set(prev);
|
|
375
|
+
if (next.has(row.id)) next.delete(row.id);
|
|
376
|
+
else next.add(row.id);
|
|
377
|
+
return next;
|
|
378
|
+
}),
|
|
379
|
+
onOpenRow: openRow,
|
|
380
|
+
onRowMenu: (row) => {
|
|
381
|
+
setMenuRow(row);
|
|
382
|
+
setSheet("rowMenu");
|
|
383
|
+
},
|
|
384
|
+
onEditCell: (row, column) => setEditing({
|
|
385
|
+
rowId: row.id,
|
|
386
|
+
column: column.name
|
|
387
|
+
}),
|
|
388
|
+
onToggleCheckbox: toggleCheckbox,
|
|
389
|
+
onAddRow: addRow,
|
|
390
|
+
hasMore: db.hasMore,
|
|
391
|
+
loadingMore: db.loadingMore,
|
|
392
|
+
onLoadMore: db.loadMore,
|
|
393
|
+
refreshing,
|
|
394
|
+
onRefresh: refresh
|
|
395
|
+
};
|
|
396
|
+
const dateProps = __spreadProps(__spreadValues({}, layoutProps), {
|
|
397
|
+
rowProps: cardProps,
|
|
398
|
+
onChangeSettings: changeSettings,
|
|
399
|
+
onAddRowWith: (values) => addRow(void 0, values)
|
|
400
|
+
});
|
|
401
|
+
const body = () => {
|
|
402
|
+
switch (view.type) {
|
|
403
|
+
case "board":
|
|
404
|
+
return /* @__PURE__ */ jsx(BoardLayout, __spreadProps(__spreadValues({}, layoutProps), { cardProps }));
|
|
405
|
+
case "gallery":
|
|
406
|
+
return /* @__PURE__ */ jsx(GalleryLayout, __spreadProps(__spreadValues({}, layoutProps), { cardProps }));
|
|
407
|
+
case "list":
|
|
408
|
+
return /* @__PURE__ */ jsx(ListLayout, __spreadProps(__spreadValues({}, layoutProps), { rowProps: cardProps }));
|
|
409
|
+
case "table":
|
|
410
|
+
return /* @__PURE__ */ jsx(TableLayout, __spreadValues({}, layoutProps));
|
|
411
|
+
case "calendar":
|
|
412
|
+
return /* @__PURE__ */ jsx(CalendarLayout, __spreadValues({}, dateProps));
|
|
413
|
+
case "timeline":
|
|
414
|
+
return /* @__PURE__ */ jsx(TimelineLayout, __spreadValues({}, dateProps));
|
|
415
|
+
case "chart":
|
|
416
|
+
return /* @__PURE__ */ jsx(ChartLayout, __spreadValues({}, dateProps));
|
|
417
|
+
default:
|
|
418
|
+
return /* @__PURE__ */ jsx(TableLayout, __spreadValues({}, layoutProps));
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
const total = (_f = db.totalCount) != null ? _f : db.rows.length;
|
|
422
|
+
return /* @__PURE__ */ jsx(RelationProvider, { source: relations, children: /* @__PURE__ */ jsxs(View, { style: [ui.flex, {
|
|
423
|
+
backgroundColor: palette.bg
|
|
424
|
+
}], children: [
|
|
425
|
+
/* @__PURE__ */ jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: "Rename database", onPress: () => setSheet("renameDb"), style: styles.titleRow, children: [
|
|
426
|
+
/* @__PURE__ */ jsx(Text, { style: styles.icon, children: db.icon || "\u{1F5C2}\uFE0F" }),
|
|
427
|
+
/* @__PURE__ */ jsxs(View, { style: ui.flex, children: [
|
|
428
|
+
/* @__PURE__ */ jsx(Text, { numberOfLines: 2, style: [styles.title, {
|
|
429
|
+
color: db.title ? palette.text : palette.textFaint
|
|
430
|
+
}], children: db.title || "Untitled database" }),
|
|
431
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.meta, {
|
|
432
|
+
color: palette.textMuted
|
|
433
|
+
}], children: `${total} ${total === 1 ? "row" : "rows"}${shownRows.length !== db.rows.length ? ` \xB7 ${shownRows.length} shown` : ""}` })
|
|
434
|
+
] }),
|
|
435
|
+
/* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: "Database actions", onPress: () => setSheet("dbMenu"), hitSlop: 8, style: [styles.more, {
|
|
436
|
+
backgroundColor: palette.fill
|
|
437
|
+
}], children: /* @__PURE__ */ jsx(Ionicons, { name: "ellipsis-horizontal", size: 18, color: palette.text }) })
|
|
438
|
+
] }),
|
|
439
|
+
/* @__PURE__ */ jsxs(ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, contentContainerStyle: styles.tabs, style: styles.tabsBar, children: [
|
|
440
|
+
db.views.map((v) => {
|
|
441
|
+
const on = v.id === view.id;
|
|
442
|
+
return /* @__PURE__ */ jsxs(Pressable, { accessibilityRole: "tab", accessibilityState: {
|
|
443
|
+
selected: on
|
|
444
|
+
}, onPress: () => db.setActiveViewId(v.id), onLongPress: () => {
|
|
445
|
+
setMenuView(v);
|
|
446
|
+
setSheet("viewMenu");
|
|
447
|
+
}, style: [styles.tab, {
|
|
448
|
+
backgroundColor: on ? palette.card : "transparent"
|
|
449
|
+
}, on && styles.tabOn], children: [
|
|
450
|
+
/* @__PURE__ */ jsx(Ionicons, { name: VIEW_ICONS[v.type], size: 15, color: on ? palette.text : palette.textMuted }),
|
|
451
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.tabText, {
|
|
452
|
+
color: on ? palette.text : palette.textMuted
|
|
453
|
+
}], children: v.name })
|
|
454
|
+
] }, v.id);
|
|
455
|
+
}),
|
|
456
|
+
/* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: "New view", onPress: () => setSheet("newView"), style: styles.tab, children: /* @__PURE__ */ jsx(Ionicons, { name: "add", size: 18, color: palette.textMuted }) })
|
|
457
|
+
] }),
|
|
458
|
+
selecting ? /* @__PURE__ */ jsxs(View, { style: [styles.toolbar, {
|
|
459
|
+
borderBottomColor: palette.hairline
|
|
460
|
+
}], children: [
|
|
461
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.selCount, {
|
|
462
|
+
color: palette.text
|
|
463
|
+
}], children: `${selected.size} selected` }),
|
|
464
|
+
/* @__PURE__ */ jsx(View, { style: ui.flex }),
|
|
465
|
+
/* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", onPress: () => setSelected(selected.size === shownRows.length ? /* @__PURE__ */ new Set() : new Set(shownRows.map((r) => r.id))), style: [styles.tool, {
|
|
466
|
+
backgroundColor: palette.fill
|
|
467
|
+
}], children: /* @__PURE__ */ jsx(Text, { style: [styles.toolText, {
|
|
468
|
+
color: palette.text
|
|
469
|
+
}], children: selected.size === shownRows.length ? "None" : "All" }) }),
|
|
470
|
+
/* @__PURE__ */ jsxs(Pressable, { accessibilityRole: "button", disabled: !selected.size, onPress: () => deleteRows([...selected]), style: [styles.tool, {
|
|
471
|
+
backgroundColor: palette.dangerSoft,
|
|
472
|
+
opacity: selected.size ? 1 : 0.5
|
|
473
|
+
}], children: [
|
|
474
|
+
/* @__PURE__ */ jsx(Ionicons, { name: "trash-outline", size: 16, color: palette.danger }),
|
|
475
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.toolText, {
|
|
476
|
+
color: palette.danger
|
|
477
|
+
}], children: "Delete" })
|
|
478
|
+
] }),
|
|
479
|
+
/* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", onPress: () => {
|
|
480
|
+
setSelecting(false);
|
|
481
|
+
setSelected(/* @__PURE__ */ new Set());
|
|
482
|
+
}, style: styles.tool, children: /* @__PURE__ */ jsx(Text, { style: [styles.toolText, {
|
|
483
|
+
color: palette.primary
|
|
484
|
+
}], children: "Done" }) })
|
|
485
|
+
] }) : /* @__PURE__ */ jsxs(View, { style: [styles.toolbarWrap, {
|
|
486
|
+
borderBottomColor: palette.hairline
|
|
487
|
+
}], children: [
|
|
488
|
+
/* @__PURE__ */ jsxs(ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, contentContainerStyle: styles.toolbar, children: [
|
|
489
|
+
/* @__PURE__ */ jsx(ToolButton, { palette, icon: "search", active: searching || Boolean(search), onPress: () => setSearching((s) => !s) }),
|
|
490
|
+
/* @__PURE__ */ jsx(ToolButton, { palette, icon: "filter", label: activeFilterCount ? `Filter \xB7 ${activeFilterCount}` : "Filter", active: activeFilterCount > 0, onPress: () => setSheet("filter") }),
|
|
491
|
+
/* @__PURE__ */ jsx(ToolButton, { palette, icon: "swap-vertical", label: view.sorts.length ? `Sort \xB7 ${view.sorts.length}` : "Sort", active: view.sorts.length > 0, onPress: () => setSheet("sort") }),
|
|
492
|
+
/* @__PURE__ */ jsx(ToolButton, { palette, icon: "eye-outline", label: "Properties", onPress: () => setSheet("properties") }),
|
|
493
|
+
/* @__PURE__ */ jsx(ToolButton, { palette, icon: "options-outline", label: "View", onPress: () => setSheet("options") }),
|
|
494
|
+
/* @__PURE__ */ jsx(ToolButton, { palette, icon: "checkmark-circle-outline", label: "Select", onPress: () => setSelecting(true) })
|
|
495
|
+
] }),
|
|
496
|
+
/* @__PURE__ */ jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: "New row", onPress: () => addRow(), style: [styles.newButton, {
|
|
497
|
+
backgroundColor: palette.primary
|
|
498
|
+
}], children: [
|
|
499
|
+
/* @__PURE__ */ jsx(Ionicons, { name: "add", size: 18, color: palette.onPrimary }),
|
|
500
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.newText, {
|
|
501
|
+
color: palette.onPrimary
|
|
502
|
+
}], children: "New" })
|
|
503
|
+
] })
|
|
504
|
+
] }),
|
|
505
|
+
searching ? /* @__PURE__ */ jsxs(View, { style: [styles.search, {
|
|
506
|
+
backgroundColor: palette.fill
|
|
507
|
+
}], children: [
|
|
508
|
+
/* @__PURE__ */ jsx(Ionicons, { name: "search", size: 16, color: palette.textMuted }),
|
|
509
|
+
/* @__PURE__ */ jsx(TextInput, { value: search, onChangeText: setSearch, autoFocus: true, placeholder: "Search rows", placeholderTextColor: palette.textFaint, clearButtonMode: "while-editing", style: [styles.searchInput, {
|
|
510
|
+
color: palette.text
|
|
511
|
+
}] })
|
|
512
|
+
] }) : null,
|
|
513
|
+
/* @__PURE__ */ jsx(View, { style: [ui.flex, {
|
|
514
|
+
paddingBottom: insets.bottom
|
|
515
|
+
}], children: db.rows.length || db.loading ? body() : /* @__PURE__ */ jsx(EmptyState, { palette, icon: "grid-outline", title: "No rows yet", text: "Add the first row to this database.", action: {
|
|
516
|
+
label: "New row",
|
|
517
|
+
onPress: () => addRow()
|
|
518
|
+
} }) }),
|
|
519
|
+
/* @__PURE__ */ jsx(FilterSheet, { visible: sheet === "filter", palette, columns, conditions: view.conditions, onChange: (conditions) => changeView({
|
|
520
|
+
conditions
|
|
521
|
+
}), onClose: () => setSheet(null) }),
|
|
522
|
+
/* @__PURE__ */ jsx(SortSheet, { visible: sheet === "sort", palette, columns, sorts: view.sorts, onChange: (sorts) => changeView({
|
|
523
|
+
sorts
|
|
524
|
+
}), onClose: () => setSheet(null) }),
|
|
525
|
+
/* @__PURE__ */ jsx(PropertiesSheet, { visible: sheet === "properties", palette, columns, visibleNames, onChangeVisible: setVisibleNames, onEdit: (c) => setEditProperty({
|
|
526
|
+
name: c.name
|
|
527
|
+
}), onAdd: () => setEditProperty({
|
|
528
|
+
name: null
|
|
529
|
+
}), onClose: () => {
|
|
530
|
+
setEditProperty(null);
|
|
531
|
+
setSheet(null);
|
|
532
|
+
}, children: /* @__PURE__ */ jsx(PropertyEditorSheet, { visible: editProperty !== null, palette, column: propertyColumn, isNew: (editProperty == null ? void 0 : editProperty.name) === null, calculation: propertyColumn ? (_g = view.settings.calculations) == null ? void 0 : _g[propertyColumn.name] : void 0, onClose: () => setEditProperty(null), onRename: (to) => propertyColumn ? renameProperty(propertyColumn.name, to) : Promise.resolve(null), onChangeType: (type) => propertyColumn ? changePropertyType(propertyColumn.name, type) : Promise.resolve(null), onDelete: () => propertyColumn && deleteProperty(propertyColumn.name), onCalculation: (kind) => {
|
|
533
|
+
var _a3;
|
|
534
|
+
if (!propertyColumn) return;
|
|
535
|
+
const calcs = __spreadValues({}, (_a3 = view.settings.calculations) != null ? _a3 : {});
|
|
536
|
+
if (kind === "none") delete calcs[propertyColumn.name];
|
|
537
|
+
else calcs[propertyColumn.name] = kind;
|
|
538
|
+
changeSettings({
|
|
539
|
+
calculations: Object.keys(calcs).length ? calcs : void 0
|
|
540
|
+
});
|
|
541
|
+
}, onCreate: createProperty }) }),
|
|
542
|
+
/* @__PURE__ */ jsx(ViewOptionsSheet, { visible: sheet === "options", palette, type: view.type, groupBy: view.groupBy, settings: view.settings, columns, onChangeType: (type) => changeView({
|
|
543
|
+
type
|
|
544
|
+
}), onChangeGroupBy: (groupBy) => changeView({
|
|
545
|
+
groupBy
|
|
546
|
+
}), onChangeSettings: changeSettings, onClose: () => setSheet(null) }),
|
|
547
|
+
/* @__PURE__ */ jsx(NewViewSheet, { visible: sheet === "newView", palette, columns, onCreate: (input) => {
|
|
548
|
+
var _a3;
|
|
549
|
+
return db.addView({
|
|
550
|
+
name: input.name,
|
|
551
|
+
type: input.type,
|
|
552
|
+
groupBy: (_a3 = input.groupBy) != null ? _a3 : null
|
|
553
|
+
});
|
|
554
|
+
}, onClose: () => setSheet(null) }),
|
|
555
|
+
/* @__PURE__ */ jsx(ChoiceSheet, { visible: sheet === "viewMenu", title: (_h = menuView == null ? void 0 : menuView.name) != null ? _h : "View", palette, choices: [{
|
|
556
|
+
value: "rename",
|
|
557
|
+
label: "Rename",
|
|
558
|
+
icon: "pencil-outline"
|
|
559
|
+
}, {
|
|
560
|
+
value: "duplicate",
|
|
561
|
+
label: "Duplicate",
|
|
562
|
+
icon: "copy-outline"
|
|
563
|
+
}, ...menuView && menuView.id !== DEFAULT_VIEW_ID && db.views.length > 1 ? [{
|
|
564
|
+
value: "delete",
|
|
565
|
+
label: "Delete view",
|
|
566
|
+
icon: "trash-outline"
|
|
567
|
+
}] : []], onClose: () => setSheet(null), onPick: async (action) => {
|
|
568
|
+
const target = menuView;
|
|
569
|
+
if (!target) return;
|
|
570
|
+
if (action === "rename") {
|
|
571
|
+
thenOpen("renameView");
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
setSheet(null);
|
|
575
|
+
if (action === "duplicate") {
|
|
576
|
+
report(await db.duplicateView(target, uniqueViewName(db.views, target.name)));
|
|
577
|
+
} else if (action === "delete") {
|
|
578
|
+
report(await db.removeView(target.id));
|
|
579
|
+
}
|
|
580
|
+
} }),
|
|
581
|
+
/* @__PURE__ */ jsx(ChoiceSheet, { visible: sheet === "rowMenu", title: menuRow ? rowTitle(menuRow) || "Untitled" : "Row", palette, choices: [{
|
|
582
|
+
value: "open",
|
|
583
|
+
label: "Open",
|
|
584
|
+
icon: "open-outline"
|
|
585
|
+
}, {
|
|
586
|
+
value: "rename",
|
|
587
|
+
label: "Rename",
|
|
588
|
+
icon: "pencil-outline"
|
|
589
|
+
}, ...moveTargets.length ? [{
|
|
590
|
+
value: "move",
|
|
591
|
+
label: `Move to\u2026`,
|
|
592
|
+
icon: "swap-horizontal-outline"
|
|
593
|
+
}] : [], {
|
|
594
|
+
value: "duplicate",
|
|
595
|
+
label: "Duplicate",
|
|
596
|
+
icon: "copy-outline"
|
|
597
|
+
}, {
|
|
598
|
+
value: "select",
|
|
599
|
+
label: "Select",
|
|
600
|
+
icon: "checkmark-circle-outline"
|
|
601
|
+
}, {
|
|
602
|
+
value: "delete",
|
|
603
|
+
label: "Delete",
|
|
604
|
+
icon: "trash-outline"
|
|
605
|
+
}], onClose: () => setSheet(null), onPick: (action) => {
|
|
606
|
+
const row = menuRow;
|
|
607
|
+
if (!row) return;
|
|
608
|
+
if (action === "move") {
|
|
609
|
+
thenOpen("moveTo");
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
setSheet(null);
|
|
613
|
+
if (action === "open") openRow(row);
|
|
614
|
+
else if (action === "rename") {
|
|
615
|
+
const title = columns.find((c) => c.type === "title");
|
|
616
|
+
if (title) setTimeout(() => setEditing({
|
|
617
|
+
rowId: row.id,
|
|
618
|
+
column: title.name
|
|
619
|
+
}), 350);
|
|
620
|
+
} else if (action === "duplicate") duplicateRow(row);
|
|
621
|
+
else if (action === "select") {
|
|
622
|
+
setSelecting(true);
|
|
623
|
+
setSelected(/* @__PURE__ */ new Set([row.id]));
|
|
624
|
+
} else if (action === "delete") deleteRows([row.id]);
|
|
625
|
+
} }),
|
|
626
|
+
/* @__PURE__ */ jsx(ChoiceSheet, { visible: sheet === "moveTo", title: "Move to", palette, value: menuRow && groupColumn ? (_k = (_j = (_i = menuRow.properties) == null ? void 0 : _i[groupColumn.name]) == null ? void 0 : _j.name) != null ? _k : null : null, choices: moveTargets.map((g) => {
|
|
627
|
+
var _a3;
|
|
628
|
+
return {
|
|
629
|
+
value: (_a3 = g.value) != null ? _a3 : "__none",
|
|
630
|
+
label: g.name
|
|
631
|
+
};
|
|
632
|
+
}), onClose: () => setSheet(null), onPick: (value) => {
|
|
633
|
+
setSheet(null);
|
|
634
|
+
if (!menuRow || !groupColumn) return;
|
|
635
|
+
db.updateCell(menuRow.id, groupColumn.name, value === "__none" ? null : selectValueToCell(value)).then(report);
|
|
636
|
+
} }),
|
|
637
|
+
/* @__PURE__ */ jsx(TextPromptDialog, { visible: sheet === "renameView", palette, title: "Rename view", initial: (_l = menuView == null ? void 0 : menuView.name) != null ? _l : "", confirmLabel: "Rename", onClose: () => setSheet(null), onConfirm: async (name) => {
|
|
638
|
+
if (!menuView) return;
|
|
639
|
+
const err = await db.changeView(menuView.id, {
|
|
640
|
+
name: name.trim()
|
|
641
|
+
});
|
|
642
|
+
if (err) throw new Error(err);
|
|
643
|
+
} }),
|
|
644
|
+
/* @__PURE__ */ jsx(TextPromptDialog, { visible: sheet === "renameDb", palette, title: "Rename database", initial: db.title, placeholder: "Untitled database", confirmLabel: "Rename", onClose: () => setSheet(null), onConfirm: async (name) => {
|
|
645
|
+
const err = await db.renameDatabase(name.trim());
|
|
646
|
+
if (err) throw new Error(err);
|
|
647
|
+
await db.refresh();
|
|
648
|
+
} }),
|
|
649
|
+
/* @__PURE__ */ jsx(ChoiceSheet, { visible: sheet === "dbMenu", title: db.title || "Database", palette, choices: [{
|
|
650
|
+
value: "rename",
|
|
651
|
+
label: "Rename",
|
|
652
|
+
icon: "pencil-outline"
|
|
653
|
+
}, {
|
|
654
|
+
value: "export",
|
|
655
|
+
label: "Export CSV",
|
|
656
|
+
icon: "share-outline"
|
|
657
|
+
}, ...pickDocument ? [{
|
|
658
|
+
value: "importFile",
|
|
659
|
+
label: "Import CSV file",
|
|
660
|
+
icon: "document-attach-outline"
|
|
661
|
+
}] : [], {
|
|
662
|
+
value: "paste",
|
|
663
|
+
label: "Paste CSV",
|
|
664
|
+
icon: "clipboard-outline"
|
|
665
|
+
}], onClose: () => setSheet(null), onPick: (action) => {
|
|
666
|
+
if (action === "rename" || action === "paste") {
|
|
667
|
+
thenOpen(action === "rename" ? "renameDb" : "pasteCsv");
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
setSheet(null);
|
|
671
|
+
setTimeout(() => action === "export" ? exportCsv() : importCsvFile(), 450);
|
|
672
|
+
} }),
|
|
673
|
+
/* @__PURE__ */ jsx(TextPromptDialog, { visible: sheet === "pasteCsv", palette, title: "Import CSV", message: "Paste CSV with a header row. Columns that match a property fill it; new ones become properties.", placeholder: "Name,Status\nFirst task,Done", multiline: true, confirmLabel: "Import", onClose: () => setSheet(null), onConfirm: (text) => {
|
|
674
|
+
setSheet(null);
|
|
675
|
+
importCsv(text);
|
|
676
|
+
} }),
|
|
677
|
+
/* @__PURE__ */ jsx(CellEditorSheet, { visible: Boolean(editingRow && editingColumn), row: editingRow, column: editingColumn, schema: db.schema, getValue, isDark, palette, onClose: () => setEditing(null), onSave: (value) => editingRow && editingColumn ? db.updateCell(editingRow.id, editingColumn.name, value) : Promise.resolve(null), onSaveSchema: db.saveSchema }),
|
|
678
|
+
/* @__PURE__ */ jsx(NotionToast, { toast, palette, onHide: hideToast })
|
|
679
|
+
] }) });
|
|
680
|
+
}
|
|
681
|
+
function ToolButton({
|
|
682
|
+
palette,
|
|
683
|
+
icon,
|
|
684
|
+
label,
|
|
685
|
+
active,
|
|
686
|
+
onPress
|
|
687
|
+
}) {
|
|
688
|
+
return /* @__PURE__ */ jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: label != null ? label : icon, onPress, style: [styles.tool, {
|
|
689
|
+
backgroundColor: active ? palette.primarySoft : palette.fill
|
|
690
|
+
}], children: [
|
|
691
|
+
/* @__PURE__ */ jsx(Ionicons, { name: icon, size: 16, color: active ? palette.primary : palette.text }),
|
|
692
|
+
label ? /* @__PURE__ */ jsx(Text, { style: [styles.toolText, {
|
|
693
|
+
color: active ? palette.primary : palette.text
|
|
694
|
+
}], children: label }) : null
|
|
695
|
+
] });
|
|
696
|
+
}
|
|
697
|
+
const styles = StyleSheet.create({
|
|
698
|
+
center: {
|
|
699
|
+
flex: 1,
|
|
700
|
+
alignItems: "center",
|
|
701
|
+
justifyContent: "center"
|
|
702
|
+
},
|
|
703
|
+
titleRow: {
|
|
704
|
+
flexDirection: "row",
|
|
705
|
+
alignItems: "center",
|
|
706
|
+
gap: 12,
|
|
707
|
+
paddingHorizontal: 16,
|
|
708
|
+
paddingTop: 14,
|
|
709
|
+
paddingBottom: 8
|
|
710
|
+
},
|
|
711
|
+
icon: {
|
|
712
|
+
fontSize: 30
|
|
713
|
+
},
|
|
714
|
+
more: {
|
|
715
|
+
width: 34,
|
|
716
|
+
height: 34,
|
|
717
|
+
borderRadius: 10,
|
|
718
|
+
alignItems: "center",
|
|
719
|
+
justifyContent: "center"
|
|
720
|
+
},
|
|
721
|
+
title: {
|
|
722
|
+
fontSize: 24,
|
|
723
|
+
fontWeight: "800",
|
|
724
|
+
letterSpacing: -0.3
|
|
725
|
+
},
|
|
726
|
+
meta: {
|
|
727
|
+
fontSize: 13,
|
|
728
|
+
marginTop: 2
|
|
729
|
+
},
|
|
730
|
+
tabsBar: {
|
|
731
|
+
flexGrow: 0
|
|
732
|
+
},
|
|
733
|
+
tabs: {
|
|
734
|
+
paddingHorizontal: 12,
|
|
735
|
+
gap: 4,
|
|
736
|
+
alignItems: "center",
|
|
737
|
+
paddingVertical: 4
|
|
738
|
+
},
|
|
739
|
+
tab: {
|
|
740
|
+
flexDirection: "row",
|
|
741
|
+
alignItems: "center",
|
|
742
|
+
gap: 6,
|
|
743
|
+
paddingHorizontal: 12,
|
|
744
|
+
height: 34,
|
|
745
|
+
borderRadius: 10
|
|
746
|
+
},
|
|
747
|
+
tabOn: {
|
|
748
|
+
shadowColor: "#000",
|
|
749
|
+
shadowOpacity: 0.06,
|
|
750
|
+
shadowRadius: 4,
|
|
751
|
+
shadowOffset: {
|
|
752
|
+
width: 0,
|
|
753
|
+
height: 1
|
|
754
|
+
},
|
|
755
|
+
elevation: 1
|
|
756
|
+
},
|
|
757
|
+
tabText: {
|
|
758
|
+
fontSize: 14,
|
|
759
|
+
fontWeight: "600"
|
|
760
|
+
},
|
|
761
|
+
toolbarWrap: {
|
|
762
|
+
flexDirection: "row",
|
|
763
|
+
alignItems: "center",
|
|
764
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
765
|
+
paddingRight: 12
|
|
766
|
+
},
|
|
767
|
+
toolbar: {
|
|
768
|
+
flexDirection: "row",
|
|
769
|
+
alignItems: "center",
|
|
770
|
+
gap: 8,
|
|
771
|
+
paddingHorizontal: 12,
|
|
772
|
+
paddingVertical: 8
|
|
773
|
+
},
|
|
774
|
+
tool: {
|
|
775
|
+
flexDirection: "row",
|
|
776
|
+
alignItems: "center",
|
|
777
|
+
gap: 5,
|
|
778
|
+
paddingHorizontal: 11,
|
|
779
|
+
height: 34,
|
|
780
|
+
borderRadius: 10
|
|
781
|
+
},
|
|
782
|
+
toolText: {
|
|
783
|
+
fontSize: 14,
|
|
784
|
+
fontWeight: "600"
|
|
785
|
+
},
|
|
786
|
+
newButton: {
|
|
787
|
+
flexDirection: "row",
|
|
788
|
+
alignItems: "center",
|
|
789
|
+
gap: 4,
|
|
790
|
+
paddingHorizontal: 12,
|
|
791
|
+
height: 34,
|
|
792
|
+
borderRadius: 10
|
|
793
|
+
},
|
|
794
|
+
newText: {
|
|
795
|
+
fontSize: 14,
|
|
796
|
+
fontWeight: "700"
|
|
797
|
+
},
|
|
798
|
+
selCount: {
|
|
799
|
+
fontSize: 15,
|
|
800
|
+
fontWeight: "700"
|
|
801
|
+
},
|
|
802
|
+
search: {
|
|
803
|
+
flexDirection: "row",
|
|
804
|
+
alignItems: "center",
|
|
805
|
+
gap: 8,
|
|
806
|
+
marginHorizontal: 12,
|
|
807
|
+
marginTop: 8,
|
|
808
|
+
paddingHorizontal: 12,
|
|
809
|
+
height: 40,
|
|
810
|
+
borderRadius: 12
|
|
811
|
+
},
|
|
812
|
+
searchInput: {
|
|
813
|
+
flex: 1,
|
|
814
|
+
fontSize: 16,
|
|
815
|
+
paddingVertical: 0
|
|
816
|
+
}
|
|
817
|
+
});export{NotionDatabaseView};//# sourceMappingURL=NotionDatabaseView.js.map
|