@adminide-stack/yantra-mobile 12.0.141-alpha.1 → 12.0.141
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/devices/bodyComposition.js +116 -0
- package/lib/features/devices/bodyComposition.js.map +1 -0
- package/lib/features/devices/readings.js.map +1 -1
- package/lib/features/devices/session.js +22 -2
- package/lib/features/devices/session.js.map +1 -1
- 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/Devices/index.js +205 -3
- package/lib/screens/Devices/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 +4 -4
|
@@ -0,0 +1,1188 @@
|
|
|
1
|
+
import {buttonCellText}from'./connectorButton.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 __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
const PROPERTY_TYPES = [{
|
|
33
|
+
type: "text",
|
|
34
|
+
label: "Text"
|
|
35
|
+
}, {
|
|
36
|
+
type: "number",
|
|
37
|
+
label: "Number"
|
|
38
|
+
}, {
|
|
39
|
+
type: "select",
|
|
40
|
+
label: "Select"
|
|
41
|
+
}, {
|
|
42
|
+
type: "status",
|
|
43
|
+
label: "Status"
|
|
44
|
+
}, {
|
|
45
|
+
type: "multi_select",
|
|
46
|
+
label: "Multi-select"
|
|
47
|
+
}, {
|
|
48
|
+
type: "date",
|
|
49
|
+
label: "Date"
|
|
50
|
+
}, {
|
|
51
|
+
type: "checkbox",
|
|
52
|
+
label: "Checkbox"
|
|
53
|
+
}, {
|
|
54
|
+
type: "url",
|
|
55
|
+
label: "URL"
|
|
56
|
+
}, {
|
|
57
|
+
type: "email",
|
|
58
|
+
label: "Email"
|
|
59
|
+
}, {
|
|
60
|
+
type: "phone",
|
|
61
|
+
label: "Phone"
|
|
62
|
+
}, {
|
|
63
|
+
type: "person",
|
|
64
|
+
label: "Person"
|
|
65
|
+
}, {
|
|
66
|
+
type: "files",
|
|
67
|
+
label: "Files & media"
|
|
68
|
+
}, {
|
|
69
|
+
type: "relation",
|
|
70
|
+
label: "Relation"
|
|
71
|
+
}, {
|
|
72
|
+
type: "formula",
|
|
73
|
+
label: "Formula"
|
|
74
|
+
}, {
|
|
75
|
+
type: "connector",
|
|
76
|
+
label: "Connector"
|
|
77
|
+
}, {
|
|
78
|
+
type: "button",
|
|
79
|
+
label: "Button"
|
|
80
|
+
}, {
|
|
81
|
+
type: "created_time",
|
|
82
|
+
label: "Created time"
|
|
83
|
+
}, {
|
|
84
|
+
type: "last_edited_time",
|
|
85
|
+
label: "Last edited time"
|
|
86
|
+
}, {
|
|
87
|
+
type: "created_by",
|
|
88
|
+
label: "Created by"
|
|
89
|
+
}, {
|
|
90
|
+
type: "last_edited_by",
|
|
91
|
+
label: "Last edited by"
|
|
92
|
+
}, {
|
|
93
|
+
type: "unique_id",
|
|
94
|
+
label: "ID"
|
|
95
|
+
}, {
|
|
96
|
+
type: "rollup",
|
|
97
|
+
label: "Rollup"
|
|
98
|
+
}];
|
|
99
|
+
const COMPUTED_TYPES = /* @__PURE__ */ new Set([
|
|
100
|
+
"formula",
|
|
101
|
+
"connector",
|
|
102
|
+
// A button cell holds the row's last run, written only when the button runs.
|
|
103
|
+
"button",
|
|
104
|
+
"created_time",
|
|
105
|
+
"last_edited_time",
|
|
106
|
+
"created_by",
|
|
107
|
+
"last_edited_by",
|
|
108
|
+
// Assigned by the app (create / duplicate / backfill), never typed.
|
|
109
|
+
"unique_id",
|
|
110
|
+
// Aggregated from related rows (utils/databaseRollup).
|
|
111
|
+
"rollup"
|
|
112
|
+
]);
|
|
113
|
+
function isComputedType(type) {
|
|
114
|
+
return COMPUTED_TYPES.has(type);
|
|
115
|
+
}
|
|
116
|
+
function isDateLikeType(type) {
|
|
117
|
+
return type === "date" || type === "created_time" || type === "last_edited_time";
|
|
118
|
+
}
|
|
119
|
+
function isNameListType(type) {
|
|
120
|
+
return type === "multi_select" || type === "person";
|
|
121
|
+
}
|
|
122
|
+
function propertyTypeLabel(type) {
|
|
123
|
+
var _a, _b;
|
|
124
|
+
if (type === "title") return "Title";
|
|
125
|
+
return (_b = (_a = PROPERTY_TYPES.find((t) => t.type === type)) == null ? void 0 : _a.label) != null ? _b : "Text";
|
|
126
|
+
}
|
|
127
|
+
const STATUS_GROUPS = [{
|
|
128
|
+
id: "todo",
|
|
129
|
+
label: "To-do",
|
|
130
|
+
color: "gray"
|
|
131
|
+
}, {
|
|
132
|
+
id: "in_progress",
|
|
133
|
+
label: "In progress",
|
|
134
|
+
color: "blue"
|
|
135
|
+
}, {
|
|
136
|
+
id: "complete",
|
|
137
|
+
label: "Complete",
|
|
138
|
+
color: "green"
|
|
139
|
+
}];
|
|
140
|
+
const DEFAULT_STATUS_OPTIONS = [{
|
|
141
|
+
name: "Not started",
|
|
142
|
+
color: "gray",
|
|
143
|
+
group: "todo"
|
|
144
|
+
}, {
|
|
145
|
+
name: "In progress",
|
|
146
|
+
color: "blue",
|
|
147
|
+
group: "in_progress"
|
|
148
|
+
}, {
|
|
149
|
+
name: "Done",
|
|
150
|
+
color: "green",
|
|
151
|
+
group: "complete"
|
|
152
|
+
}];
|
|
153
|
+
function isStatusGroup(value) {
|
|
154
|
+
return value === "todo" || value === "in_progress" || value === "complete";
|
|
155
|
+
}
|
|
156
|
+
function hasOptions(type) {
|
|
157
|
+
return type === "select" || type === "status" || type === "multi_select";
|
|
158
|
+
}
|
|
159
|
+
function guessStatusGroup(name) {
|
|
160
|
+
const n = name.toLowerCase();
|
|
161
|
+
if (/(done|complete|merged|shipped|closed|resolved|launched|finished|archived|cancel)/.test(n)) return "complete";
|
|
162
|
+
if (/(progress|doing|review|testing|active|track|started|blocked|wip|ready)/.test(n) && !/not started/.test(n)) {
|
|
163
|
+
return "in_progress";
|
|
164
|
+
}
|
|
165
|
+
return "todo";
|
|
166
|
+
}
|
|
167
|
+
function normalizeStatusOptions(options) {
|
|
168
|
+
const list = (options != null ? options : []).map((o) => __spreadProps(__spreadValues({}, o), {
|
|
169
|
+
group: isStatusGroup(o.group) ? o.group : guessStatusGroup(o.name)
|
|
170
|
+
}));
|
|
171
|
+
const rank = (g) => STATUS_GROUPS.findIndex((x) => x.id === g);
|
|
172
|
+
return list.map((o, i) => ({
|
|
173
|
+
o,
|
|
174
|
+
i
|
|
175
|
+
})).sort((a, b) => rank(a.o.group) - rank(b.o.group) || a.i - b.i).map((x) => x.o);
|
|
176
|
+
}
|
|
177
|
+
const EMPTY_FILTER_VALUE = "__empty__";
|
|
178
|
+
function connectorCellValue(raw) {
|
|
179
|
+
if (raw === null || raw === void 0) return null;
|
|
180
|
+
if (typeof raw === "string" || typeof raw === "number" || typeof raw === "boolean") return raw;
|
|
181
|
+
if (typeof raw === "object" && !Array.isArray(raw) && "value" in raw) {
|
|
182
|
+
const v = raw.value;
|
|
183
|
+
if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") return v;
|
|
184
|
+
}
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
const CONNECTOR_ISO_DATE = /^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/;
|
|
188
|
+
function connectorDisplayText(value) {
|
|
189
|
+
const v = connectorCellValue(value);
|
|
190
|
+
if (v === null) return "";
|
|
191
|
+
if (typeof v === "boolean") return v ? "Checked" : "";
|
|
192
|
+
if (typeof v === "number") return Number.isFinite(v) ? String(Number(v.toPrecision(10))) : "";
|
|
193
|
+
if (CONNECTOR_ISO_DATE.test(v) && !Number.isNaN(Date.parse(v))) {
|
|
194
|
+
const dateOnly = /^\d{4}-\d{2}-\d{2}$/.test(v);
|
|
195
|
+
const d = new Date(dateOnly ? `${v}T00:00:00Z` : v);
|
|
196
|
+
return dateOnly ? d.toLocaleDateString(void 0, {
|
|
197
|
+
year: "numeric",
|
|
198
|
+
month: "short",
|
|
199
|
+
day: "numeric",
|
|
200
|
+
timeZone: "UTC"
|
|
201
|
+
}) : d.toLocaleDateString(void 0, {
|
|
202
|
+
year: "numeric",
|
|
203
|
+
month: "short",
|
|
204
|
+
day: "numeric"
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
return v;
|
|
208
|
+
}
|
|
209
|
+
const baseCellValue = (row, column) => {
|
|
210
|
+
var _a, _b, _c, _d, _e, _f;
|
|
211
|
+
if (column.type === "created_time") return (_a = row.createdTime) != null ? _a : null;
|
|
212
|
+
if (column.type === "last_edited_time") return (_b = row.lastEditedTime) != null ? _b : null;
|
|
213
|
+
if (column.type === "created_by") return (_c = row.createdBy) != null ? _c : null;
|
|
214
|
+
if (column.type === "last_edited_by") return (_d = row.lastEditedBy) != null ? _d : null;
|
|
215
|
+
if (column.type === "connector") return connectorCellValue((_e = row.properties) == null ? void 0 : _e[column.name]);
|
|
216
|
+
return (_f = row.properties) == null ? void 0 : _f[column.name];
|
|
217
|
+
};
|
|
218
|
+
const OPTION_COLORS = ["gray", "blue", "green", "yellow", "orange", "red", "purple", "pink", "brown"];
|
|
219
|
+
function richTextToPlain(value) {
|
|
220
|
+
var _a;
|
|
221
|
+
if (value === null || value === void 0) return "";
|
|
222
|
+
if (typeof value === "string") return value;
|
|
223
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
224
|
+
if (Array.isArray(value)) {
|
|
225
|
+
return value.map((rt) => {
|
|
226
|
+
var _a2, _b, _c, _d;
|
|
227
|
+
if (typeof rt === "string") return rt;
|
|
228
|
+
return (_d = (_c = (_b = rt == null ? void 0 : rt.plainText) != null ? _b : (_a2 = rt == null ? void 0 : rt.text) == null ? void 0 : _a2.content) != null ? _c : rt == null ? void 0 : rt.plain_text) != null ? _d : "";
|
|
229
|
+
}).join("");
|
|
230
|
+
}
|
|
231
|
+
if (typeof value === "object") {
|
|
232
|
+
const v = value;
|
|
233
|
+
if (typeof v.plainText === "string") return v.plainText;
|
|
234
|
+
if (typeof ((_a = v.text) == null ? void 0 : _a.content) === "string") return v.text.content;
|
|
235
|
+
if (typeof v.name === "string") return v.name;
|
|
236
|
+
}
|
|
237
|
+
return "";
|
|
238
|
+
}
|
|
239
|
+
function selectName(value) {
|
|
240
|
+
if (value === null || value === void 0) return null;
|
|
241
|
+
if (typeof value === "string") return value.trim() ? value : null;
|
|
242
|
+
if (typeof value === "object" && typeof value.name === "string") {
|
|
243
|
+
return value.name || null;
|
|
244
|
+
}
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
function multiSelectNames(value) {
|
|
248
|
+
if (value === null || value === void 0) return [];
|
|
249
|
+
if (Array.isArray(value)) {
|
|
250
|
+
return value.map((v) => selectName(v)).filter((n) => !!n);
|
|
251
|
+
}
|
|
252
|
+
const single = selectName(value);
|
|
253
|
+
return single ? [single] : [];
|
|
254
|
+
}
|
|
255
|
+
function dateString(value) {
|
|
256
|
+
if (value === null || value === void 0) return null;
|
|
257
|
+
if (typeof value === "string") return value.trim() ? value : null;
|
|
258
|
+
if (typeof value === "object" && typeof value.start === "string") {
|
|
259
|
+
return value.start || null;
|
|
260
|
+
}
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
|
+
function toDateInputValue(value) {
|
|
264
|
+
const s = dateString(value);
|
|
265
|
+
if (!s) return "";
|
|
266
|
+
const m = /^(\d{4}-\d{2}-\d{2})/.exec(s);
|
|
267
|
+
if (m) return m[1];
|
|
268
|
+
const d = new Date(s);
|
|
269
|
+
if (Number.isNaN(d.getTime())) return "";
|
|
270
|
+
return d.toISOString().slice(0, 10);
|
|
271
|
+
}
|
|
272
|
+
function dateTime(value) {
|
|
273
|
+
const s = dateString(value);
|
|
274
|
+
if (!s) return null;
|
|
275
|
+
const t = new Date(s).getTime();
|
|
276
|
+
return Number.isNaN(t) ? null : t;
|
|
277
|
+
}
|
|
278
|
+
function dateEndString(value) {
|
|
279
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
280
|
+
const end = value.end;
|
|
281
|
+
return typeof end === "string" && end.trim() ? end : null;
|
|
282
|
+
}
|
|
283
|
+
function dateRangeValue(value) {
|
|
284
|
+
const start = toDateInputValue(value);
|
|
285
|
+
if (!start) return null;
|
|
286
|
+
const endRaw = dateEndString(value);
|
|
287
|
+
const end = endRaw ? toDateInputValue(endRaw) : "";
|
|
288
|
+
return {
|
|
289
|
+
start,
|
|
290
|
+
end: end || null
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
function serializeDateRange(start, end, previous) {
|
|
294
|
+
if (!start) return null;
|
|
295
|
+
let s = start;
|
|
296
|
+
let e = end || null;
|
|
297
|
+
if (e && e < s) [s, e] = [e, s];
|
|
298
|
+
const keepTime = (prev, day) => {
|
|
299
|
+
const m = prev ? /^\d{4}-\d{2}-\d{2}(T.*)$/.exec(prev) : null;
|
|
300
|
+
return m ? `${day}${m[1]}` : day;
|
|
301
|
+
};
|
|
302
|
+
const prevStart = dateString(previous);
|
|
303
|
+
const prevEnd = dateEndString(previous);
|
|
304
|
+
const nextStart = keepTime(prevStart, s);
|
|
305
|
+
if (previous && typeof previous === "object" && !Array.isArray(previous)) {
|
|
306
|
+
const next = __spreadProps(__spreadValues({}, previous), {
|
|
307
|
+
start: nextStart
|
|
308
|
+
});
|
|
309
|
+
if (e) next.end = keepTime(prevEnd, e);
|
|
310
|
+
else delete next.end;
|
|
311
|
+
return next;
|
|
312
|
+
}
|
|
313
|
+
return e ? {
|
|
314
|
+
start: nextStart,
|
|
315
|
+
end: keepTime(prevEnd, e)
|
|
316
|
+
} : nextStart;
|
|
317
|
+
}
|
|
318
|
+
function personEntries(value) {
|
|
319
|
+
var _a;
|
|
320
|
+
if (value === null || value === void 0) return [];
|
|
321
|
+
const list = Array.isArray(value) ? value : [value];
|
|
322
|
+
const out = [];
|
|
323
|
+
for (const v of list) {
|
|
324
|
+
if (typeof v === "string") {
|
|
325
|
+
if (v.trim()) out.push({
|
|
326
|
+
name: v.trim()
|
|
327
|
+
});
|
|
328
|
+
} else if (v && typeof v === "object" && typeof v.name === "string" && v.name.trim()) {
|
|
329
|
+
const e = {
|
|
330
|
+
name: v.name
|
|
331
|
+
};
|
|
332
|
+
if (typeof v.id === "string" && v.id) e.id = v.id;
|
|
333
|
+
const url = (_a = v.avatarUrl) != null ? _a : v.avatar_url;
|
|
334
|
+
if (typeof url === "string" && url) e.avatarUrl = url;
|
|
335
|
+
out.push(e);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return out;
|
|
339
|
+
}
|
|
340
|
+
function fileNameFromUrl(url) {
|
|
341
|
+
const clean = url.trim().replace(/[?#].*$/, "").replace(/\/+$/, "");
|
|
342
|
+
const noScheme = clean.replace(/^[a-z][a-z0-9+.-]*:\/\//i, "");
|
|
343
|
+
const parts = noScheme.split("/");
|
|
344
|
+
if (parts.length < 2) return noScheme || url.trim();
|
|
345
|
+
const last = parts[parts.length - 1];
|
|
346
|
+
try {
|
|
347
|
+
return decodeURIComponent(last) || noScheme;
|
|
348
|
+
} catch (e) {
|
|
349
|
+
return last || noScheme;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function filesValue(value) {
|
|
353
|
+
var _a, _b, _c, _d;
|
|
354
|
+
if (value === null || value === void 0 || value === "") return [];
|
|
355
|
+
const list = Array.isArray(value) ? value : [value];
|
|
356
|
+
const out = [];
|
|
357
|
+
for (const v of list) {
|
|
358
|
+
if (typeof v === "string") {
|
|
359
|
+
if (v.trim()) out.push({
|
|
360
|
+
name: fileNameFromUrl(v),
|
|
361
|
+
url: v.trim()
|
|
362
|
+
});
|
|
363
|
+
} else if (v && typeof v === "object") {
|
|
364
|
+
const url = (_d = (_b = v.url) != null ? _b : (_a = v.external) == null ? void 0 : _a.url) != null ? _d : (_c = v.file) == null ? void 0 : _c.url;
|
|
365
|
+
if (typeof url === "string" && url.trim()) {
|
|
366
|
+
const name = typeof v.name === "string" && v.name ? v.name : fileNameFromUrl(url);
|
|
367
|
+
out.push({
|
|
368
|
+
name,
|
|
369
|
+
url: url.trim()
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return out;
|
|
375
|
+
}
|
|
376
|
+
function relationIds(value) {
|
|
377
|
+
if (value === null || value === void 0) return [];
|
|
378
|
+
const list = Array.isArray(value) ? value : [value];
|
|
379
|
+
const seen = /* @__PURE__ */ new Set();
|
|
380
|
+
for (const v of list) {
|
|
381
|
+
const id = typeof v === "string" ? v : v && typeof v === "object" ? v.id : null;
|
|
382
|
+
if (typeof id === "string" && id) seen.add(id);
|
|
383
|
+
}
|
|
384
|
+
return [...seen];
|
|
385
|
+
}
|
|
386
|
+
function relationToCell(ids) {
|
|
387
|
+
return [...new Set(ids.filter(Boolean))].map((id) => ({
|
|
388
|
+
id
|
|
389
|
+
}));
|
|
390
|
+
}
|
|
391
|
+
function toggleRelation(value, id) {
|
|
392
|
+
const ids = relationIds(value);
|
|
393
|
+
return relationToCell(ids.includes(id) ? ids.filter((x) => x !== id) : [...ids, id]);
|
|
394
|
+
}
|
|
395
|
+
function numberValue(value) {
|
|
396
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
397
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : null;
|
|
398
|
+
if (typeof value === "string") {
|
|
399
|
+
const n = Number(value.trim());
|
|
400
|
+
return value.trim() && Number.isFinite(n) ? n : null;
|
|
401
|
+
}
|
|
402
|
+
return null;
|
|
403
|
+
}
|
|
404
|
+
function normalizeCellValue(value, type) {
|
|
405
|
+
switch (type) {
|
|
406
|
+
case "number":
|
|
407
|
+
return numberValue(value);
|
|
408
|
+
case "select":
|
|
409
|
+
case "status":
|
|
410
|
+
return selectName(value);
|
|
411
|
+
case "multi_select":
|
|
412
|
+
case "person":
|
|
413
|
+
return multiSelectNames(value);
|
|
414
|
+
case "date": {
|
|
415
|
+
const s = dateString(value);
|
|
416
|
+
const e = dateEndString(value);
|
|
417
|
+
return s && e ? `${s}/${e}` : s;
|
|
418
|
+
}
|
|
419
|
+
case "created_time":
|
|
420
|
+
case "last_edited_time":
|
|
421
|
+
return dateString(value);
|
|
422
|
+
case "checkbox":
|
|
423
|
+
return value === true || value === "true";
|
|
424
|
+
case "files":
|
|
425
|
+
return filesValue(value).map((f) => f.url);
|
|
426
|
+
case "relation":
|
|
427
|
+
return relationIds(value);
|
|
428
|
+
case "formula":
|
|
429
|
+
return formulaNormalize(value);
|
|
430
|
+
case "connector":
|
|
431
|
+
return connectorCellValue(value);
|
|
432
|
+
case "button":
|
|
433
|
+
return buttonCellText(value);
|
|
434
|
+
default: {
|
|
435
|
+
const s = richTextToPlain(value);
|
|
436
|
+
return s;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
function isFormulaList(value) {
|
|
441
|
+
return Array.isArray(value) && value.every((v) => v === null || v instanceof Date || Array.isArray(v) || typeof v !== "object");
|
|
442
|
+
}
|
|
443
|
+
function formulaNormalize(value) {
|
|
444
|
+
if (isFormulaList(value)) return value.map((v) => formulaDisplayText(v)).join(", ");
|
|
445
|
+
if (value instanceof Date) return Number.isNaN(value.getTime()) ? null : value.toISOString();
|
|
446
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : null;
|
|
447
|
+
if (typeof value === "boolean") return value;
|
|
448
|
+
if (value === null || value === void 0) return null;
|
|
449
|
+
return richTextToPlain(value);
|
|
450
|
+
}
|
|
451
|
+
function formulaDisplayText(value) {
|
|
452
|
+
if (isFormulaList(value)) return value.map((v) => formulaDisplayText(v)).filter(Boolean).join(", ");
|
|
453
|
+
if (value instanceof Date) {
|
|
454
|
+
if (Number.isNaN(value.getTime())) return "";
|
|
455
|
+
const midnight = value.getHours() === 0 && value.getMinutes() === 0 && value.getSeconds() === 0;
|
|
456
|
+
return midnight ? value.toLocaleDateString(void 0, {
|
|
457
|
+
year: "numeric",
|
|
458
|
+
month: "short",
|
|
459
|
+
day: "numeric"
|
|
460
|
+
}) : value.toLocaleString(void 0, {
|
|
461
|
+
dateStyle: "medium",
|
|
462
|
+
timeStyle: "short"
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
if (typeof value === "number") return Number.isFinite(value) ? String(Number(value.toPrecision(10))) : "";
|
|
466
|
+
if (typeof value === "boolean") return value ? "true" : "false";
|
|
467
|
+
return richTextToPlain(value);
|
|
468
|
+
}
|
|
469
|
+
function timestampDisplayText(value) {
|
|
470
|
+
const s = dateString(value);
|
|
471
|
+
if (!s) return "";
|
|
472
|
+
const d = new Date(s);
|
|
473
|
+
if (Number.isNaN(d.getTime())) return "";
|
|
474
|
+
return d.toLocaleString(void 0, {
|
|
475
|
+
dateStyle: "medium",
|
|
476
|
+
timeStyle: "short"
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
function isEmptyCell(value, type) {
|
|
480
|
+
const v = normalizeCellValue(value, type);
|
|
481
|
+
if (type === "checkbox") return false;
|
|
482
|
+
if (v === null || v === void 0 || v === "") return true;
|
|
483
|
+
if (Array.isArray(v)) return v.length === 0;
|
|
484
|
+
return false;
|
|
485
|
+
}
|
|
486
|
+
function cellDisplayText(value, type) {
|
|
487
|
+
var _a;
|
|
488
|
+
switch (type) {
|
|
489
|
+
case "number": {
|
|
490
|
+
const n = numberValue(value);
|
|
491
|
+
return n === null ? "" : String(n);
|
|
492
|
+
}
|
|
493
|
+
case "select":
|
|
494
|
+
case "status":
|
|
495
|
+
return (_a = selectName(value)) != null ? _a : "";
|
|
496
|
+
case "multi_select":
|
|
497
|
+
case "person":
|
|
498
|
+
return multiSelectNames(value).join(", ");
|
|
499
|
+
case "files":
|
|
500
|
+
return filesValue(value).map((f) => f.name).join(", ");
|
|
501
|
+
case "relation":
|
|
502
|
+
return relationIds(value).join(", ");
|
|
503
|
+
case "formula":
|
|
504
|
+
return formulaDisplayText(value);
|
|
505
|
+
case "connector":
|
|
506
|
+
return connectorDisplayText(value);
|
|
507
|
+
case "button":
|
|
508
|
+
return buttonCellText(value);
|
|
509
|
+
case "created_time":
|
|
510
|
+
case "last_edited_time":
|
|
511
|
+
return timestampDisplayText(value);
|
|
512
|
+
case "unique_id": {
|
|
513
|
+
const n = numberValue(value);
|
|
514
|
+
return n === null ? "" : String(n);
|
|
515
|
+
}
|
|
516
|
+
case "rollup":
|
|
517
|
+
return value === null || value === void 0 ? "" : String(value);
|
|
518
|
+
case "date": {
|
|
519
|
+
const range = dateRangeValue(value);
|
|
520
|
+
if (!range) return "";
|
|
521
|
+
const fmt = (day) => (/* @__PURE__ */ new Date(`${day}T00:00:00Z`)).toLocaleDateString(void 0, {
|
|
522
|
+
year: "numeric",
|
|
523
|
+
month: "short",
|
|
524
|
+
day: "numeric",
|
|
525
|
+
timeZone: "UTC"
|
|
526
|
+
});
|
|
527
|
+
if (!range.end) return fmt(range.start);
|
|
528
|
+
if (range.start.slice(0, 4) === range.end.slice(0, 4)) {
|
|
529
|
+
const short = (day) => (/* @__PURE__ */ new Date(`${day}T00:00:00Z`)).toLocaleDateString(void 0, {
|
|
530
|
+
month: "short",
|
|
531
|
+
day: "numeric",
|
|
532
|
+
timeZone: "UTC"
|
|
533
|
+
});
|
|
534
|
+
const thisYear = range.start.slice(0, 4) === String((/* @__PURE__ */ new Date()).getFullYear());
|
|
535
|
+
return `${short(range.start)} \u2192 ${thisYear ? short(range.end) : fmt(range.end)}`;
|
|
536
|
+
}
|
|
537
|
+
return `${fmt(range.start)} \u2192 ${fmt(range.end)}`;
|
|
538
|
+
}
|
|
539
|
+
case "checkbox":
|
|
540
|
+
return value === true || value === "true" ? "Checked" : "";
|
|
541
|
+
default:
|
|
542
|
+
return richTextToPlain(value);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
function cellToEditorString(value, type) {
|
|
546
|
+
var _a;
|
|
547
|
+
switch (type) {
|
|
548
|
+
case "number": {
|
|
549
|
+
const n = numberValue(value);
|
|
550
|
+
return n === null ? "" : String(n);
|
|
551
|
+
}
|
|
552
|
+
case "date":
|
|
553
|
+
return toDateInputValue(value);
|
|
554
|
+
case "select":
|
|
555
|
+
case "status":
|
|
556
|
+
return (_a = selectName(value)) != null ? _a : "";
|
|
557
|
+
case "multi_select":
|
|
558
|
+
case "person":
|
|
559
|
+
return multiSelectNames(value).join(", ");
|
|
560
|
+
case "files":
|
|
561
|
+
return filesValue(value).map((f) => f.url).join("\n");
|
|
562
|
+
case "checkbox":
|
|
563
|
+
return value === true || value === "true" ? "true" : "false";
|
|
564
|
+
default:
|
|
565
|
+
return richTextToPlain(value);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
function splitNames(input) {
|
|
569
|
+
return input.split(",").map((s) => s.trim()).filter(Boolean);
|
|
570
|
+
}
|
|
571
|
+
function isSafeLinkText(s) {
|
|
572
|
+
const t = s.trim();
|
|
573
|
+
if (!t || /\s/.test(t)) return false;
|
|
574
|
+
if (/^https?:\/\//i.test(t)) return true;
|
|
575
|
+
return !/^[a-z][a-z0-9+.-]*:/i.test(t) && /\./.test(t);
|
|
576
|
+
}
|
|
577
|
+
function toRichText(text) {
|
|
578
|
+
return [{
|
|
579
|
+
text: {
|
|
580
|
+
content: text
|
|
581
|
+
},
|
|
582
|
+
plainText: text
|
|
583
|
+
}];
|
|
584
|
+
}
|
|
585
|
+
function editorStringToCell(input, type, previous) {
|
|
586
|
+
var _a;
|
|
587
|
+
const raw = input != null ? input : "";
|
|
588
|
+
const trimmed = raw.trim();
|
|
589
|
+
switch (type) {
|
|
590
|
+
case "title":
|
|
591
|
+
return {
|
|
592
|
+
ok: true,
|
|
593
|
+
value: toRichText(raw)
|
|
594
|
+
};
|
|
595
|
+
case "text":
|
|
596
|
+
return {
|
|
597
|
+
ok: true,
|
|
598
|
+
value: Array.isArray(previous) ? toRichText(raw) : raw
|
|
599
|
+
};
|
|
600
|
+
case "number": {
|
|
601
|
+
if (!trimmed) return {
|
|
602
|
+
ok: true,
|
|
603
|
+
value: null
|
|
604
|
+
};
|
|
605
|
+
const n = Number(trimmed.replace(/,/g, ""));
|
|
606
|
+
if (!Number.isFinite(n)) return {
|
|
607
|
+
ok: false,
|
|
608
|
+
error: "Enter a number"
|
|
609
|
+
};
|
|
610
|
+
return {
|
|
611
|
+
ok: true,
|
|
612
|
+
value: n
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
case "date": {
|
|
616
|
+
if (!trimmed) return {
|
|
617
|
+
ok: true,
|
|
618
|
+
value: null
|
|
619
|
+
};
|
|
620
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(trimmed) || Number.isNaN(new Date(trimmed).getTime())) {
|
|
621
|
+
return {
|
|
622
|
+
ok: false,
|
|
623
|
+
error: "Enter a valid date"
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
if (previous && typeof previous === "object" && !Array.isArray(previous)) {
|
|
627
|
+
return {
|
|
628
|
+
ok: true,
|
|
629
|
+
value: __spreadProps(__spreadValues({}, previous), {
|
|
630
|
+
start: trimmed
|
|
631
|
+
})
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
return {
|
|
635
|
+
ok: true,
|
|
636
|
+
value: trimmed
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
case "select":
|
|
640
|
+
case "status":
|
|
641
|
+
return {
|
|
642
|
+
ok: true,
|
|
643
|
+
value: selectValueToCell(trimmed || null)
|
|
644
|
+
};
|
|
645
|
+
case "multi_select":
|
|
646
|
+
return {
|
|
647
|
+
ok: true,
|
|
648
|
+
value: multiSelectToCell(trimmed.split(",").map((s) => s.trim()).filter(Boolean))
|
|
649
|
+
};
|
|
650
|
+
case "checkbox":
|
|
651
|
+
return {
|
|
652
|
+
ok: true,
|
|
653
|
+
value: trimmed === "true"
|
|
654
|
+
};
|
|
655
|
+
case "email":
|
|
656
|
+
if (trimmed && !/^[^\s@]+@[^\s@]+$/.test(trimmed)) return {
|
|
657
|
+
ok: false,
|
|
658
|
+
error: "Enter a valid email"
|
|
659
|
+
};
|
|
660
|
+
return {
|
|
661
|
+
ok: true,
|
|
662
|
+
value: trimmed || null
|
|
663
|
+
};
|
|
664
|
+
case "phone":
|
|
665
|
+
if (trimmed && !/^[+\d\s().\-/x#*]+$/i.test(trimmed)) return {
|
|
666
|
+
ok: false,
|
|
667
|
+
error: "Enter a phone number"
|
|
668
|
+
};
|
|
669
|
+
if (trimmed && !/\d/.test(trimmed)) return {
|
|
670
|
+
ok: false,
|
|
671
|
+
error: "Enter a phone number"
|
|
672
|
+
};
|
|
673
|
+
return {
|
|
674
|
+
ok: true,
|
|
675
|
+
value: trimmed || null
|
|
676
|
+
};
|
|
677
|
+
case "person": {
|
|
678
|
+
const prev = personEntries(previous);
|
|
679
|
+
const seen = /* @__PURE__ */ new Set();
|
|
680
|
+
const out = [];
|
|
681
|
+
for (const name of splitNames(trimmed)) {
|
|
682
|
+
if (seen.has(name)) continue;
|
|
683
|
+
seen.add(name);
|
|
684
|
+
out.push((_a = prev.find((p) => p.name === name)) != null ? _a : {
|
|
685
|
+
name
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
return {
|
|
689
|
+
ok: true,
|
|
690
|
+
value: out
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
case "files": {
|
|
694
|
+
const urls = trimmed.split(/[\n\s]+/).filter(Boolean);
|
|
695
|
+
const bad = urls.find((u) => !isSafeLinkText(u));
|
|
696
|
+
if (bad) return {
|
|
697
|
+
ok: false,
|
|
698
|
+
error: `Not a web link: ${bad}`
|
|
699
|
+
};
|
|
700
|
+
const prev = filesValue(previous);
|
|
701
|
+
return {
|
|
702
|
+
ok: true,
|
|
703
|
+
value: urls.map((url) => {
|
|
704
|
+
var _a2;
|
|
705
|
+
return (_a2 = prev.find((f) => f.url === url)) != null ? _a2 : {
|
|
706
|
+
name: fileNameFromUrl(url),
|
|
707
|
+
url
|
|
708
|
+
};
|
|
709
|
+
})
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
case "relation":
|
|
713
|
+
return {
|
|
714
|
+
ok: true,
|
|
715
|
+
value: relationToCell(splitNames(trimmed))
|
|
716
|
+
};
|
|
717
|
+
case "formula":
|
|
718
|
+
case "connector":
|
|
719
|
+
case "button":
|
|
720
|
+
case "rollup":
|
|
721
|
+
case "created_time":
|
|
722
|
+
case "last_edited_time":
|
|
723
|
+
case "created_by":
|
|
724
|
+
case "last_edited_by":
|
|
725
|
+
return {
|
|
726
|
+
ok: false,
|
|
727
|
+
error: "This property is read-only"
|
|
728
|
+
};
|
|
729
|
+
case "url":
|
|
730
|
+
return {
|
|
731
|
+
ok: true,
|
|
732
|
+
value: trimmed || null
|
|
733
|
+
};
|
|
734
|
+
default:
|
|
735
|
+
return {
|
|
736
|
+
ok: true,
|
|
737
|
+
value: raw
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
function selectValueToCell(name) {
|
|
742
|
+
return name ? {
|
|
743
|
+
name
|
|
744
|
+
} : null;
|
|
745
|
+
}
|
|
746
|
+
function multiSelectToCell(names) {
|
|
747
|
+
const seen = /* @__PURE__ */ new Set();
|
|
748
|
+
const out = [];
|
|
749
|
+
for (const n of names) {
|
|
750
|
+
if (!n || seen.has(n)) continue;
|
|
751
|
+
seen.add(n);
|
|
752
|
+
out.push({
|
|
753
|
+
name: n
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
return out;
|
|
757
|
+
}
|
|
758
|
+
function toggleMultiSelect(value, name) {
|
|
759
|
+
const names = multiSelectNames(value);
|
|
760
|
+
return multiSelectToCell(names.includes(name) ? names.filter((n) => n !== name) : [...names, name]);
|
|
761
|
+
}
|
|
762
|
+
function compareCellValues(a, b, column) {
|
|
763
|
+
var _a, _b, _c, _d, _e;
|
|
764
|
+
switch (column.type) {
|
|
765
|
+
case "number":
|
|
766
|
+
case "unique_id":
|
|
767
|
+
return ((_a = numberValue(a)) != null ? _a : 0) - ((_b = numberValue(b)) != null ? _b : 0);
|
|
768
|
+
case "date":
|
|
769
|
+
case "created_time":
|
|
770
|
+
case "last_edited_time":
|
|
771
|
+
return ((_c = dateTime(a)) != null ? _c : 0) - ((_d = dateTime(b)) != null ? _d : 0);
|
|
772
|
+
case "formula":
|
|
773
|
+
return compareFormulaValues(a, b);
|
|
774
|
+
case "connector": {
|
|
775
|
+
const x = connectorCellValue(a);
|
|
776
|
+
const y = connectorCellValue(b);
|
|
777
|
+
if (((_e = column.connector) == null ? void 0 : _e.resultType) === "select" && typeof x === "string" && typeof y === "string") {
|
|
778
|
+
return compareOptionNames(x, y, column.options);
|
|
779
|
+
}
|
|
780
|
+
return compareFormulaValues(x, y);
|
|
781
|
+
}
|
|
782
|
+
case "checkbox": {
|
|
783
|
+
const x = a === true ? 1 : 0;
|
|
784
|
+
const y = b === true ? 1 : 0;
|
|
785
|
+
return x - y;
|
|
786
|
+
}
|
|
787
|
+
case "select":
|
|
788
|
+
return compareOptionNames(selectName(a), selectName(b), column.options);
|
|
789
|
+
case "status":
|
|
790
|
+
return compareOptionNames(selectName(a), selectName(b), normalizeStatusOptions(column.options));
|
|
791
|
+
case "person":
|
|
792
|
+
case "multi_select": {
|
|
793
|
+
const x = multiSelectNames(a);
|
|
794
|
+
const y = multiSelectNames(b);
|
|
795
|
+
const len = Math.min(x.length, y.length);
|
|
796
|
+
for (let i = 0; i < len; i++) {
|
|
797
|
+
const c = compareOptionNames(x[i], y[i], column.options);
|
|
798
|
+
if (c !== 0) return c;
|
|
799
|
+
}
|
|
800
|
+
return x.length - y.length;
|
|
801
|
+
}
|
|
802
|
+
default:
|
|
803
|
+
return cellDisplayText(a, column.type).localeCompare(cellDisplayText(b, column.type), void 0, {
|
|
804
|
+
numeric: true,
|
|
805
|
+
sensitivity: "base"
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
function compareFormulaValues(a, b) {
|
|
810
|
+
const x = formulaNormalize(a);
|
|
811
|
+
const y = formulaNormalize(b);
|
|
812
|
+
if (typeof x === "number" && typeof y === "number") return x - y;
|
|
813
|
+
if (typeof x === "boolean" && typeof y === "boolean") return Number(x) - Number(y);
|
|
814
|
+
return String(x != null ? x : "").localeCompare(String(y != null ? y : ""), void 0, {
|
|
815
|
+
numeric: true,
|
|
816
|
+
sensitivity: "base"
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
function compareOptionNames(a, b, options) {
|
|
820
|
+
const order = (n) => {
|
|
821
|
+
const i = (options != null ? options : []).findIndex((o) => o.name === n);
|
|
822
|
+
return i === -1 ? Number.MAX_SAFE_INTEGER : i;
|
|
823
|
+
};
|
|
824
|
+
const d = order(a) - order(b);
|
|
825
|
+
if (d !== 0) return d;
|
|
826
|
+
return (a != null ? a : "").localeCompare(b != null ? b : "", void 0, {
|
|
827
|
+
sensitivity: "base"
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
function sortRows(rows, sorts, columns, getValue = baseCellValue) {
|
|
831
|
+
const active = sorts.map((s) => __spreadProps(__spreadValues({}, s), {
|
|
832
|
+
column: columns.find((c) => c.name === s.property)
|
|
833
|
+
})).filter((s) => !!s.column);
|
|
834
|
+
if (active.length === 0) return rows;
|
|
835
|
+
return rows.map((row, index) => ({
|
|
836
|
+
row,
|
|
837
|
+
index
|
|
838
|
+
})).sort((x, y) => {
|
|
839
|
+
for (const s of active) {
|
|
840
|
+
const a = getValue(x.row, s.column);
|
|
841
|
+
const b = getValue(y.row, s.column);
|
|
842
|
+
const ea = isEmptyCell(a, s.column.type);
|
|
843
|
+
const eb = isEmptyCell(b, s.column.type);
|
|
844
|
+
if (ea && eb) continue;
|
|
845
|
+
if (ea) return 1;
|
|
846
|
+
if (eb) return -1;
|
|
847
|
+
const c = compareCellValues(a, b, s.column);
|
|
848
|
+
if (c !== 0) return s.direction === "descending" ? -c : c;
|
|
849
|
+
}
|
|
850
|
+
return x.index - y.index;
|
|
851
|
+
}).map((e) => e.row);
|
|
852
|
+
}
|
|
853
|
+
function parseViewSorts(sorts) {
|
|
854
|
+
var _a, _b, _c;
|
|
855
|
+
if (!Array.isArray(sorts)) return [];
|
|
856
|
+
const out = [];
|
|
857
|
+
for (const s of sorts) {
|
|
858
|
+
if (!s || typeof s !== "object") continue;
|
|
859
|
+
const property = (_b = (_a = s.property) != null ? _a : s.propertyName) != null ? _b : s.key;
|
|
860
|
+
if (typeof property !== "string" || !property) continue;
|
|
861
|
+
const dir = String((_c = s.direction) != null ? _c : "ascending").toLowerCase();
|
|
862
|
+
out.push({
|
|
863
|
+
property,
|
|
864
|
+
direction: dir === "descending" || dir === "desc" ? "descending" : "ascending"
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
return out;
|
|
868
|
+
}
|
|
869
|
+
function rowMatchesFilter(row, columns, filter, getValue = baseCellValue) {
|
|
870
|
+
var _a, _b, _c;
|
|
871
|
+
if (!filter) return true;
|
|
872
|
+
const q = ((_a = filter.search) != null ? _a : "").trim().toLowerCase();
|
|
873
|
+
if (q) {
|
|
874
|
+
const hit = columns.some((c) => cellDisplayText(getValue(row, c), c.type).toLowerCase().includes(q));
|
|
875
|
+
if (!hit) return false;
|
|
876
|
+
}
|
|
877
|
+
for (const [prop, accepted] of Object.entries((_b = filter.selects) != null ? _b : {})) {
|
|
878
|
+
if (!accepted || accepted.length === 0) continue;
|
|
879
|
+
const column = columns.find((c) => c.name === prop);
|
|
880
|
+
if (!column) continue;
|
|
881
|
+
const value = (_c = row.properties) == null ? void 0 : _c[prop];
|
|
882
|
+
const names = column.type === "multi_select" ? multiSelectNames(value) : [selectName(value)].filter(Boolean);
|
|
883
|
+
const ok = names.length === 0 ? accepted.includes(EMPTY_FILTER_VALUE) : names.some((n) => accepted.includes(n));
|
|
884
|
+
if (!ok) return false;
|
|
885
|
+
}
|
|
886
|
+
return true;
|
|
887
|
+
}
|
|
888
|
+
function renameSortProperty(sorts, from, to) {
|
|
889
|
+
if (!sorts.some((s) => s.property === from) || from === to) return sorts;
|
|
890
|
+
return sorts.map((s) => s.property === from ? __spreadProps(__spreadValues({}, s), {
|
|
891
|
+
property: to
|
|
892
|
+
}) : s);
|
|
893
|
+
}
|
|
894
|
+
function dropSortProperty(sorts, name) {
|
|
895
|
+
return sorts.some((s) => s.property === name) ? sorts.filter((s) => s.property !== name) : sorts;
|
|
896
|
+
}
|
|
897
|
+
const NO_GROUP = "No Status";
|
|
898
|
+
function boardGroupKey(group) {
|
|
899
|
+
return group.value === null ? "__none__" : `v:${group.value}`;
|
|
900
|
+
}
|
|
901
|
+
function groupRows(rows, property, options) {
|
|
902
|
+
var _a, _b;
|
|
903
|
+
const groups = /* @__PURE__ */ new Map();
|
|
904
|
+
for (const o of options) groups.set(o.name, {
|
|
905
|
+
name: o.name,
|
|
906
|
+
value: o.name,
|
|
907
|
+
color: o.color,
|
|
908
|
+
rows: []
|
|
909
|
+
});
|
|
910
|
+
const empty = {
|
|
911
|
+
name: NO_GROUP,
|
|
912
|
+
value: null,
|
|
913
|
+
rows: []
|
|
914
|
+
};
|
|
915
|
+
for (const row of rows) {
|
|
916
|
+
const stored = (_a = row.properties) == null ? void 0 : _a[property];
|
|
917
|
+
const isConnectorCell = !!stored && typeof stored === "object" && !Array.isArray(stored) && "value" in stored && "at" in stored;
|
|
918
|
+
const name = isConnectorCell ? selectName(String((_b = connectorCellValue(stored)) != null ? _b : "")) : selectName(stored);
|
|
919
|
+
if (!name) {
|
|
920
|
+
empty.rows.push(row);
|
|
921
|
+
continue;
|
|
922
|
+
}
|
|
923
|
+
let g = groups.get(name);
|
|
924
|
+
if (!g) {
|
|
925
|
+
g = {
|
|
926
|
+
name,
|
|
927
|
+
value: name,
|
|
928
|
+
rows: []
|
|
929
|
+
};
|
|
930
|
+
groups.set(name, g);
|
|
931
|
+
}
|
|
932
|
+
g.rows.push(row);
|
|
933
|
+
}
|
|
934
|
+
return [...groups.values(), empty];
|
|
935
|
+
}
|
|
936
|
+
function validatePropertyName(schema, name, except) {
|
|
937
|
+
const n = name.trim();
|
|
938
|
+
if (!n) return "Name is required";
|
|
939
|
+
const clash = Object.keys(schema).some((k) => k !== except && k.toLowerCase() === n.toLowerCase());
|
|
940
|
+
if (clash) return `A property named "${n}" already exists`;
|
|
941
|
+
if (["icon", "cover", "schema"].includes(n)) return `"${n}" is a reserved name`;
|
|
942
|
+
return null;
|
|
943
|
+
}
|
|
944
|
+
function uniquePropertyName(schema, base = "Property") {
|
|
945
|
+
const taken = new Set(Object.keys(schema).map((k) => k.toLowerCase()));
|
|
946
|
+
if (!taken.has(base.toLowerCase())) return base;
|
|
947
|
+
for (let i = 2; ; i++) {
|
|
948
|
+
const candidate = `${base} ${i}`;
|
|
949
|
+
if (!taken.has(candidate.toLowerCase())) return candidate;
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
function addSchemaProperty(schema, name, type, config = {}) {
|
|
953
|
+
var _a, _b;
|
|
954
|
+
const error = validatePropertyName(schema, name);
|
|
955
|
+
if (error) return {
|
|
956
|
+
ok: false,
|
|
957
|
+
error
|
|
958
|
+
};
|
|
959
|
+
if (type === "title") return {
|
|
960
|
+
ok: false,
|
|
961
|
+
error: "A database has exactly one title property"
|
|
962
|
+
};
|
|
963
|
+
if (type === "relation" && !config.databaseId) return {
|
|
964
|
+
ok: false,
|
|
965
|
+
error: "Pick a database to relate to"
|
|
966
|
+
};
|
|
967
|
+
const def = {
|
|
968
|
+
type
|
|
969
|
+
};
|
|
970
|
+
if (type === "select" || type === "multi_select") def.options = [];
|
|
971
|
+
if (type === "status") def.options = DEFAULT_STATUS_OPTIONS.map((o) => __spreadValues({}, o));
|
|
972
|
+
if (type === "formula") def.expression = (_a = config.expression) != null ? _a : "";
|
|
973
|
+
if (type === "relation") def.databaseId = config.databaseId;
|
|
974
|
+
if ((type === "connector" || type === "button") && config.connector) Object.assign(def, withoutType(config.connector));
|
|
975
|
+
for (const [k, v] of Object.entries((_b = config.settings) != null ? _b : {})) {
|
|
976
|
+
if (k !== "type" && k !== "options" && v !== void 0 && v !== null && v !== "") def[k] = v;
|
|
977
|
+
}
|
|
978
|
+
return {
|
|
979
|
+
ok: true,
|
|
980
|
+
schema: __spreadProps(__spreadValues({}, schema), {
|
|
981
|
+
[name.trim()]: def
|
|
982
|
+
})
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
function renameSchemaProperty(schema, from, to) {
|
|
986
|
+
if (!(from in schema)) return {
|
|
987
|
+
ok: false,
|
|
988
|
+
error: `Unknown property "${from}"`
|
|
989
|
+
};
|
|
990
|
+
const target = to.trim();
|
|
991
|
+
if (target === from) return {
|
|
992
|
+
ok: true,
|
|
993
|
+
schema
|
|
994
|
+
};
|
|
995
|
+
const error = validatePropertyName(schema, target, from);
|
|
996
|
+
if (error) return {
|
|
997
|
+
ok: false,
|
|
998
|
+
error
|
|
999
|
+
};
|
|
1000
|
+
const out = {};
|
|
1001
|
+
for (const [k, v] of Object.entries(schema)) out[k === from ? target : k] = v;
|
|
1002
|
+
return {
|
|
1003
|
+
ok: true,
|
|
1004
|
+
schema: out
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
function changeSchemaPropertyType(schema, name, type) {
|
|
1008
|
+
var _a, _b;
|
|
1009
|
+
const def = schema[name];
|
|
1010
|
+
if (!def) return {
|
|
1011
|
+
ok: false,
|
|
1012
|
+
error: `Unknown property "${name}"`
|
|
1013
|
+
};
|
|
1014
|
+
if (def.type === "title") return {
|
|
1015
|
+
ok: false,
|
|
1016
|
+
error: "The title property type cannot be changed"
|
|
1017
|
+
};
|
|
1018
|
+
if (type === "title") return {
|
|
1019
|
+
ok: false,
|
|
1020
|
+
error: "A database has exactly one title property"
|
|
1021
|
+
};
|
|
1022
|
+
const next = __spreadProps(__spreadValues({}, def), {
|
|
1023
|
+
type
|
|
1024
|
+
});
|
|
1025
|
+
if (type === "status") {
|
|
1026
|
+
next.options = ((_a = def.options) == null ? void 0 : _a.length) ? normalizeStatusOptions(def.options) : DEFAULT_STATUS_OPTIONS.map((o) => __spreadValues({}, o));
|
|
1027
|
+
} else if (type === "select" || type === "multi_select") {
|
|
1028
|
+
next.options = ((_b = def.options) != null ? _b : []).map((_c) => {
|
|
1029
|
+
var _d = _c, {
|
|
1030
|
+
group: _g
|
|
1031
|
+
} = _d, o = __objRest(_d, [
|
|
1032
|
+
"group"
|
|
1033
|
+
]);
|
|
1034
|
+
return o;
|
|
1035
|
+
});
|
|
1036
|
+
} else if (type === "connector") {
|
|
1037
|
+
if (def.options) next.options = def.options.map((_e) => {
|
|
1038
|
+
var _f = _e, {
|
|
1039
|
+
group: _g
|
|
1040
|
+
} = _f, o = __objRest(_f, [
|
|
1041
|
+
"group"
|
|
1042
|
+
]);
|
|
1043
|
+
return o;
|
|
1044
|
+
});
|
|
1045
|
+
} else delete next.options;
|
|
1046
|
+
if (type === "formula" && typeof next.expression !== "string") next.expression = "";
|
|
1047
|
+
if (type === "relation" && !next.databaseId) return {
|
|
1048
|
+
ok: false,
|
|
1049
|
+
error: "Pick a database to relate to"
|
|
1050
|
+
};
|
|
1051
|
+
return {
|
|
1052
|
+
ok: true,
|
|
1053
|
+
schema: __spreadProps(__spreadValues({}, schema), {
|
|
1054
|
+
[name]: next
|
|
1055
|
+
})
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
function withoutType(config) {
|
|
1059
|
+
const out = {};
|
|
1060
|
+
for (const [k, v] of Object.entries(config)) if (k !== "type" && v !== void 0) out[k] = v;
|
|
1061
|
+
return out;
|
|
1062
|
+
}
|
|
1063
|
+
function removeSchemaProperty(schema, name) {
|
|
1064
|
+
const def = schema[name];
|
|
1065
|
+
if (!def) return {
|
|
1066
|
+
ok: false,
|
|
1067
|
+
error: `Unknown property "${name}"`
|
|
1068
|
+
};
|
|
1069
|
+
if (def.type === "title") return {
|
|
1070
|
+
ok: false,
|
|
1071
|
+
error: "The title property cannot be deleted"
|
|
1072
|
+
};
|
|
1073
|
+
const out = __spreadValues({}, schema);
|
|
1074
|
+
delete out[name];
|
|
1075
|
+
return {
|
|
1076
|
+
ok: true,
|
|
1077
|
+
schema: out
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
1080
|
+
function addSchemaOption(schema, property, optionName, color, group) {
|
|
1081
|
+
var _a;
|
|
1082
|
+
const def = schema[property];
|
|
1083
|
+
if (!def) return {
|
|
1084
|
+
ok: false,
|
|
1085
|
+
error: `Unknown property "${property}"`
|
|
1086
|
+
};
|
|
1087
|
+
if (!hasOptions(String(def.type))) {
|
|
1088
|
+
return {
|
|
1089
|
+
ok: false,
|
|
1090
|
+
error: `"${property}" is not a select property`
|
|
1091
|
+
};
|
|
1092
|
+
}
|
|
1093
|
+
const name = optionName.trim();
|
|
1094
|
+
if (!name) return {
|
|
1095
|
+
ok: false,
|
|
1096
|
+
error: "Option name is required"
|
|
1097
|
+
};
|
|
1098
|
+
const options = (_a = def.options) != null ? _a : [];
|
|
1099
|
+
if (options.some((o) => o.name === name)) return {
|
|
1100
|
+
ok: true,
|
|
1101
|
+
schema
|
|
1102
|
+
};
|
|
1103
|
+
const nextColor = OPTION_COLORS[options.length % OPTION_COLORS.length];
|
|
1104
|
+
const option = {
|
|
1105
|
+
name,
|
|
1106
|
+
color: nextColor
|
|
1107
|
+
};
|
|
1108
|
+
if (def.type === "status") option.group = guessStatusGroup(name);
|
|
1109
|
+
return {
|
|
1110
|
+
ok: true,
|
|
1111
|
+
schema: __spreadProps(__spreadValues({}, schema), {
|
|
1112
|
+
[property]: __spreadProps(__spreadValues({}, def), {
|
|
1113
|
+
options: [...options, option]
|
|
1114
|
+
})
|
|
1115
|
+
})
|
|
1116
|
+
};
|
|
1117
|
+
}
|
|
1118
|
+
function renameRowPatch(properties, from, to) {
|
|
1119
|
+
if (!properties || !(from in properties) || properties[from] === null || properties[from] === void 0) {
|
|
1120
|
+
return null;
|
|
1121
|
+
}
|
|
1122
|
+
return {
|
|
1123
|
+
[to]: properties[from],
|
|
1124
|
+
[from]: null
|
|
1125
|
+
};
|
|
1126
|
+
}
|
|
1127
|
+
function convertCellValue(value, fromType, toType) {
|
|
1128
|
+
if (fromType === toType) return value;
|
|
1129
|
+
if (isComputedType(toType)) return value;
|
|
1130
|
+
if (value === null || value === void 0) return toType === "checkbox" ? false : null;
|
|
1131
|
+
if (fromType === "relation" || toType === "relation") return toType === "checkbox" ? false : null;
|
|
1132
|
+
const text = fromType === "date" || isDateLikeType(fromType) ? toDateInputValue(value) : fromType === "files" ? filesValue(value).map((f) => f.url).join(" ") : cellDisplayText(value, fromType);
|
|
1133
|
+
switch (toType) {
|
|
1134
|
+
case "number":
|
|
1135
|
+
return numberValue(fromType === "checkbox" ? value ? 1 : 0 : text);
|
|
1136
|
+
case "select":
|
|
1137
|
+
case "status": {
|
|
1138
|
+
const first = isNameListType(fromType) ? multiSelectNames(value)[0] : text.trim();
|
|
1139
|
+
return selectValueToCell(first || null);
|
|
1140
|
+
}
|
|
1141
|
+
case "multi_select":
|
|
1142
|
+
case "person":
|
|
1143
|
+
return multiSelectToCell((isNameListType(fromType) ? multiSelectNames(value) : text.split(",")).map((s) => s.trim()));
|
|
1144
|
+
case "files": {
|
|
1145
|
+
const urls = text.split(/[\s,]+/).filter((u) => isSafeLinkText(u));
|
|
1146
|
+
return urls.length ? urls.map((url) => ({
|
|
1147
|
+
name: fileNameFromUrl(url),
|
|
1148
|
+
url
|
|
1149
|
+
})) : null;
|
|
1150
|
+
}
|
|
1151
|
+
case "phone": {
|
|
1152
|
+
const r = editorStringToCell(text, "phone");
|
|
1153
|
+
return r.ok ? r.value : null;
|
|
1154
|
+
}
|
|
1155
|
+
case "date": {
|
|
1156
|
+
const r = editorStringToCell(toDateInputValue(text), "date");
|
|
1157
|
+
return r.ok ? r.value : null;
|
|
1158
|
+
}
|
|
1159
|
+
case "checkbox":
|
|
1160
|
+
return value === true || ["true", "yes", "1", "checked"].includes(text.trim().toLowerCase());
|
|
1161
|
+
case "title":
|
|
1162
|
+
return toRichText(text);
|
|
1163
|
+
default:
|
|
1164
|
+
return text || null;
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
function columnLabel(c) {
|
|
1168
|
+
return c.type === "title" && c.name === "title" ? "Name" : c.name;
|
|
1169
|
+
}
|
|
1170
|
+
function extraColumnFields(def) {
|
|
1171
|
+
const d = def != null ? def : {};
|
|
1172
|
+
const out = {};
|
|
1173
|
+
if (typeof d.numberFormat === "string") out.numberFormat = d.numberFormat;
|
|
1174
|
+
if (typeof d.numberDisplay === "string") out.numberDisplay = d.numberDisplay;
|
|
1175
|
+
if (typeof d.numberMax === "number" && Number.isFinite(d.numberMax)) out.numberMax = d.numberMax;
|
|
1176
|
+
if (typeof d.prefix === "string") out.uniquePrefix = d.prefix;
|
|
1177
|
+
if (d.limit === 1) out.relationLimit = 1;
|
|
1178
|
+
if (typeof d.dualProperty === "string" && d.dualProperty) out.dualProperty = d.dualProperty;
|
|
1179
|
+
const r = d.rollup;
|
|
1180
|
+
if (r && typeof r.relation === "string" && typeof r.target === "string") {
|
|
1181
|
+
out.rollup = {
|
|
1182
|
+
relation: r.relation,
|
|
1183
|
+
target: r.target,
|
|
1184
|
+
fn: typeof r.fn === "string" ? r.fn : "show_original"
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
return out;
|
|
1188
|
+
}export{COMPUTED_TYPES,DEFAULT_STATUS_OPTIONS,EMPTY_FILTER_VALUE,NO_GROUP,OPTION_COLORS,PROPERTY_TYPES,STATUS_GROUPS,addSchemaOption,addSchemaProperty,baseCellValue,boardGroupKey,cellDisplayText,cellToEditorString,changeSchemaPropertyType,columnLabel,compareCellValues,connectorCellValue,connectorDisplayText,convertCellValue,dateEndString,dateRangeValue,dateString,dateTime,dropSortProperty,editorStringToCell,extraColumnFields,fileNameFromUrl,filesValue,formulaDisplayText,groupRows,guessStatusGroup,hasOptions,isComputedType,isDateLikeType,isEmptyCell,isNameListType,isSafeLinkText,isStatusGroup,multiSelectNames,multiSelectToCell,normalizeCellValue,normalizeStatusOptions,numberValue,parseViewSorts,personEntries,propertyTypeLabel,relationIds,relationToCell,removeSchemaProperty,renameRowPatch,renameSchemaProperty,renameSortProperty,richTextToPlain,rowMatchesFilter,selectName,selectValueToCell,serializeDateRange,sortRows,splitNames,timestampDisplayText,toDateInputValue,toRichText,toggleMultiSelect,toggleRelation,uniquePropertyName,validatePropertyName};//# sourceMappingURL=databaseView.js.map
|