@jsb188/mday 1.1.8 → 1.1.11
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/package.json +105 -35
- package/src/constants/agentDoc.ts +12 -0
- package/src/constants/agentMemory.ts +154 -0
- package/src/constants/aiChat.ts +5 -0
- package/src/constants/campaign.ts +127 -0
- package/src/constants/dataTable.ts +48 -0
- package/src/constants/dataTableFieldTypes.generated.ts +63 -0
- package/src/constants/docAccess.ts +32 -0
- package/src/constants/email.ts +44 -0
- package/src/constants/fieldDoc.ts +34 -0
- package/src/constants/graphqlReactivity.ts +113 -0
- package/src/constants/inboundContact.ts +8 -0
- package/src/constants/integration.ts +13 -0
- package/src/constants/log.ts +7 -366
- package/src/constants/logActivityGroupColors.generated.ts +19 -0
- package/src/constants/logTaxonomy.generated.ts +1103 -0
- package/src/constants/noteDoc.ts +77 -0
- package/src/constants/organization.ts +18 -11
- package/src/constants/pageRoute.ts +23 -0
- package/src/constants/schedule.ts +220 -0
- package/src/constants/scheduleRuleTemplateSeed.ts +138 -0
- package/src/constants/scheduleRuleTemplates.generated.ts +145 -0
- package/src/constants/sheet.ts +168 -0
- package/src/constants/sheetRegionSources.generated.ts +578 -0
- package/src/constants/square.ts +16 -0
- package/src/constants/storage.ts +61 -0
- package/src/constants/usage.ts +79 -0
- package/src/schemas/editLogEntry.ts +1017 -738
- package/src/schemas/fieldDocsQuery.ts +12 -0
- package/src/schemas/inboundContact.ts +77 -0
- package/src/schemas/logsQuery.ts +57 -316
- package/src/schemas/organization.ts +53 -213
- package/src/types/account.d.ts +81 -0
- package/src/types/agentDoc.d.ts +64 -0
- package/src/types/agentMemory.d.ts +74 -0
- package/src/types/campaign.d.ts +683 -0
- package/src/types/dataTable.d.ts +366 -0
- package/src/types/docAccess.d.ts +96 -0
- package/src/types/email.d.ts +142 -0
- package/src/types/fieldDoc.d.ts +273 -0
- package/src/types/inboundContact.d.ts +57 -0
- package/src/types/integration.d.ts +42 -0
- package/src/types/log.d.ts +169 -190
- package/src/types/noteDoc.d.ts +86 -0
- package/src/types/organization.d.ts +175 -76
- package/src/types/pageRoute.d.ts +48 -0
- package/src/types/schedule.d.ts +391 -0
- package/src/types/sheet.d.ts +1130 -0
- package/src/types/storage.d.ts +242 -0
- package/src/types/usage.d.ts +106 -0
- package/src/types/workflow.d.ts +305 -0
- package/src/utils/agentDoc.ts +109 -0
- package/src/utils/aiChat.ts +26 -0
- package/src/utils/campaign.ts +741 -0
- package/src/utils/campaignFormEditor.ts +871 -0
- package/src/utils/dataTable.ts +849 -0
- package/src/utils/dataTableFieldTypeRegistry.ts +105 -0
- package/src/utils/dataTableRealtimeAuthority.ts +209 -0
- package/src/utils/dataTableRealtimeSelection.ts +134 -0
- package/src/utils/dataTableRowDocument.ts +508 -0
- package/src/utils/dataTableSource.ts +230 -0
- package/src/utils/docAccess.ts +383 -0
- package/src/utils/documentName.ts +53 -0
- package/src/utils/email.ts +172 -0
- package/src/utils/fieldDoc.ts +113 -0
- package/src/utils/log.ts +173 -778
- package/src/utils/logRegistryValue.ts +90 -0
- package/src/utils/logStoreRead.ts +266 -0
- package/src/utils/logTaxonomy.ts +76 -0
- package/src/utils/logTaxonomyDisplay.ts +439 -0
- package/src/utils/noteDoc.ts +827 -0
- package/src/utils/organization.ts +683 -81
- package/src/utils/pageRoute.ts +71 -0
- package/src/utils/schedule.ts +799 -0
- package/src/utils/scheduleEvaluation.ts +1994 -0
- package/src/utils/scheduleICS.ts +246 -0
- package/src/utils/scheduleRuleTemplates.ts +188 -0
- package/src/utils/sheet.ts +4973 -0
- package/src/utils/sheetAxisMove.ts +830 -0
- package/src/utils/sheetBootstrap.ts +1769 -0
- package/src/utils/sheetCommand.ts +423 -0
- package/src/utils/sheetExport.ts +238 -0
- package/src/utils/sheetFormulaEvaluation.ts +914 -0
- package/src/utils/sheetFormulaEvaluator.ts +852 -0
- package/src/utils/sheetJournal.ts +78 -0
- package/src/utils/sheetNumberFormat.ts +1211 -0
- package/src/utils/sheetRegion.ts +374 -0
- package/src/utils/sheetRegionFilter.ts +1259 -0
- package/src/utils/sheetRegionSourceRegistry.ts +594 -0
- package/src/utils/sheetSequence.ts +148 -0
- package/src/utils/sheetSnapshot.ts +992 -0
- package/src/utils/sheetStructureEdit.ts +1284 -0
- package/src/utils/square.ts +32 -0
- package/src/utils/storage.ts +152 -0
- package/src/utils/table-route.ts +262 -0
- package/src/utils/workflow.ts +380 -0
- package/tests/dataTableFieldTypeRegistry.test.ts +110 -0
- package/tests/docAccess.test.ts +525 -0
- package/tests/editLogEntry.test.ts +112 -0
- package/tests/noteDoc.test.ts +669 -0
- package/tests/schedule.test.ts +693 -0
- package/tests/scheduleEvaluation.test.ts +1970 -0
- package/tests/scheduleICS.test.ts +208 -0
- package/tests/scheduleRuleTemplates.test.ts +176 -0
- package/tests/scheduleSweepInvariants.test.ts +428 -0
- package/tests/sheetAxisMove.test.ts +343 -0
- package/tests/sheetFormulaEvaluator.test.ts +575 -0
- package/tests/sheetRegionFilter.test.ts +1135 -0
- package/tests/sheetSequence.test.ts +41 -0
- package/tests/sheetStructureEdit.test.ts +82 -0
- package/tsconfig.json +12 -0
- package/vitest.config.ts +8 -0
- package/src/constants/log-activityTexts.ts +0 -209
- package/src/constants/product.ts +0 -66
- package/src/constants/report.ts +0 -25
- package/src/schemas/childOrganizationsQuery.ts +0 -44
- package/src/schemas/productsQuery.ts +0 -145
- package/src/schemas/reportsQuery.ts +0 -107
- package/src/types/action.d.ts +0 -42
- package/src/types/product.d.ts +0 -173
- package/src/types/report.d.ts +0 -203
- package/src/utils/product-calEvent.ts +0 -508
- package/src/utils/route-helpers.ts +0 -583
|
@@ -0,0 +1,849 @@
|
|
|
1
|
+
import { stringifyJSON } from '@jsb188/app/utils/object.ts';
|
|
2
|
+
import {
|
|
3
|
+
formatCalDateInTimeZone,
|
|
4
|
+
parseDateInTimezone,
|
|
5
|
+
} from '@jsb188/app/utils/timeZone.ts';
|
|
6
|
+
import {
|
|
7
|
+
DATA_TABLE_COLUMN_MAX_WIDTH,
|
|
8
|
+
DATA_TABLE_COLUMN_MIN_WIDTH,
|
|
9
|
+
} from '../constants/dataTable.ts';
|
|
10
|
+
import { DATA_TABLE_FIELD_TYPE_SEMANTICS } from '../constants/dataTableFieldTypes.generated.ts';
|
|
11
|
+
import type { DataTableFieldTypeSemanticsKey } from './dataTableFieldTypeRegistry.ts';
|
|
12
|
+
import type {
|
|
13
|
+
DataTableDesignCellObj,
|
|
14
|
+
DataTableDesignObj,
|
|
15
|
+
DataTableFieldTypeEnum,
|
|
16
|
+
DataTableRecordValue,
|
|
17
|
+
} from '../types/dataTable.d.ts';
|
|
18
|
+
|
|
19
|
+
const DATA_TABLE_ROW_IDENTIFIER_MAX_LENGTH = 120;
|
|
20
|
+
|
|
21
|
+
/*
|
|
22
|
+
* Parse one canonical non-negative PostgreSQL BIGINT without accepting unsafe
|
|
23
|
+
* JavaScript numbers, signed text, or values outside the database range.
|
|
24
|
+
*/
|
|
25
|
+
export function parseDataTableStorageBigInt(value: unknown): bigint | null {
|
|
26
|
+
if (typeof value === 'number' && !Number.isSafeInteger(value)) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
if (
|
|
30
|
+
typeof value !== 'number' &&
|
|
31
|
+
typeof value !== 'bigint' &&
|
|
32
|
+
typeof value !== 'string'
|
|
33
|
+
) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
if (typeof value === 'string' && !/^(0|[1-9]\d*)$/.test(value)) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
const parsed = BigInt(value);
|
|
42
|
+
return parsed >= 0n && parsed <= 9_223_372_036_854_775_807n ? parsed : null;
|
|
43
|
+
} catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/*
|
|
49
|
+
* Parse one canonical positive PostgreSQL BIGINT.
|
|
50
|
+
*/
|
|
51
|
+
export function parsePositiveDataTableStorageBigInt(
|
|
52
|
+
value: unknown,
|
|
53
|
+
): bigint | null {
|
|
54
|
+
const parsed = parseDataTableStorageBigInt(value);
|
|
55
|
+
return parsed !== null && parsed > 0n ? parsed : null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/*
|
|
59
|
+
* Keep a user-resized dataTable column width inside the usable spreadsheet range.
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
export function clampDataTableColumnWidth(width: number) {
|
|
63
|
+
return Math.min(
|
|
64
|
+
DATA_TABLE_COLUMN_MAX_WIDTH,
|
|
65
|
+
Math.max(DATA_TABLE_COLUMN_MIN_WIDTH, Math.round(width)),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/*
|
|
70
|
+
* Check whether a value is a non-array object.
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
function isPlainObject(value: any): value is Record<string, any> {
|
|
74
|
+
return (
|
|
75
|
+
!!value &&
|
|
76
|
+
typeof value === 'object' &&
|
|
77
|
+
!(value instanceof Date) &&
|
|
78
|
+
!Array.isArray(value)
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/*
|
|
83
|
+
* Return a normalized ordered list of design cell keys used to identify rows.
|
|
84
|
+
*/
|
|
85
|
+
export function normalizeDataTableDesignRowIdentifier(value: unknown) {
|
|
86
|
+
if (!Array.isArray(value)) {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return value
|
|
91
|
+
.map((key) => (typeof key === 'string' ? key.trim() : ''))
|
|
92
|
+
.filter(Boolean);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/*
|
|
96
|
+
* Return the saved ordered row identifier keys from a dataTable design object.
|
|
97
|
+
*/
|
|
98
|
+
export function getDataTableDesignRowIdentifier(
|
|
99
|
+
design: DataTableDesignObj | null | undefined,
|
|
100
|
+
) {
|
|
101
|
+
return normalizeDataTableDesignRowIdentifier(design?.rowIdentifier);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/*
|
|
105
|
+
* Return whether one value is missing for row-identifier purposes.
|
|
106
|
+
*/
|
|
107
|
+
function isMissingDataTableRowIdentifierValue(value: unknown) {
|
|
108
|
+
return (
|
|
109
|
+
value === null ||
|
|
110
|
+
value === undefined ||
|
|
111
|
+
(typeof value === 'string' && value.trim() === '')
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/*
|
|
116
|
+
* Return a deterministic JSON-compatible value for one row identifier part.
|
|
117
|
+
*/
|
|
118
|
+
function normalizeDataTableRowIdentifierPart(value: unknown): unknown {
|
|
119
|
+
if (value instanceof Date) {
|
|
120
|
+
return value.toISOString();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (Array.isArray(value)) {
|
|
124
|
+
return value.map(normalizeDataTableRowIdentifierPart);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (isPlainObject(value)) {
|
|
128
|
+
if ('value' in value) {
|
|
129
|
+
return normalizeDataTableRowIdentifierPart(value.value);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return Object.keys(value)
|
|
133
|
+
.sort()
|
|
134
|
+
.reduce(
|
|
135
|
+
(acc, key) => {
|
|
136
|
+
acc[key] = normalizeDataTableRowIdentifierPart(value[key]);
|
|
137
|
+
return acc;
|
|
138
|
+
},
|
|
139
|
+
{} as Record<string, unknown>,
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return value;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/*
|
|
147
|
+
* Return a stable text form for one normalized row identifier part.
|
|
148
|
+
*/
|
|
149
|
+
function stringifyDataTableRowIdentifierPart(value: unknown) {
|
|
150
|
+
if (typeof value === 'string') {
|
|
151
|
+
return value.trim();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (
|
|
155
|
+
typeof value === 'number' ||
|
|
156
|
+
typeof value === 'boolean' ||
|
|
157
|
+
typeof value === 'bigint'
|
|
158
|
+
) {
|
|
159
|
+
return String(value);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return stringifyJSON(value, true);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/*
|
|
166
|
+
* Return a compact FNV-1a hash for long canonical row identifier payloads.
|
|
167
|
+
*/
|
|
168
|
+
function hashDataTableRowIdentifierText(text: string) {
|
|
169
|
+
let hash = 0xcbf29ce484222325n;
|
|
170
|
+
const prime = 0x100000001b3n;
|
|
171
|
+
const mask = 0xffffffffffffffffn;
|
|
172
|
+
|
|
173
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
174
|
+
hash ^= BigInt(text.charCodeAt(i));
|
|
175
|
+
hash = (hash * prime) & mask;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return hash.toString(36);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/*
|
|
182
|
+
* Return a persisted row identifier from ordered design keys and raw values.
|
|
183
|
+
*/
|
|
184
|
+
export function buildDataTableDesignRowIdentifier(
|
|
185
|
+
rowIdentifierKeys: string[],
|
|
186
|
+
valuesByKey: Record<string, unknown>,
|
|
187
|
+
) {
|
|
188
|
+
const missingKeys: string[] = [];
|
|
189
|
+
const parts = rowIdentifierKeys.map((key) => {
|
|
190
|
+
const normalizedValue = normalizeDataTableRowIdentifierPart(
|
|
191
|
+
valuesByKey[key],
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
if (isMissingDataTableRowIdentifierValue(normalizedValue)) {
|
|
195
|
+
missingKeys.push(key);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return [key, stringifyDataTableRowIdentifierPart(normalizedValue)] as const;
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
if (missingKeys.length) {
|
|
202
|
+
return {
|
|
203
|
+
identifier: null,
|
|
204
|
+
missingKeys,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const readableIdentifier = parts
|
|
209
|
+
.map(
|
|
210
|
+
([key, value]) =>
|
|
211
|
+
`${encodeURIComponent(key)}=${encodeURIComponent(value)}`,
|
|
212
|
+
)
|
|
213
|
+
.join('|');
|
|
214
|
+
|
|
215
|
+
if (readableIdentifier.length <= DATA_TABLE_ROW_IDENTIFIER_MAX_LENGTH) {
|
|
216
|
+
return {
|
|
217
|
+
identifier: readableIdentifier,
|
|
218
|
+
missingKeys,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return {
|
|
223
|
+
identifier: `ri_${hashDataTableRowIdentifierText(readableIdentifier)}`,
|
|
224
|
+
missingKeys,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/*
|
|
229
|
+
* Return non-hidden master dataTable design cells in their saved order.
|
|
230
|
+
*/
|
|
231
|
+
|
|
232
|
+
export function getOrderedDataTableDesignCells(
|
|
233
|
+
design: DataTableDesignObj | null | undefined,
|
|
234
|
+
) {
|
|
235
|
+
const cells = Array.isArray(design?.cells) ? design.cells : [];
|
|
236
|
+
const cellsByKey = new Map(cells.map((cell) => [cell.key, cell]));
|
|
237
|
+
const orderedCells = (design?.cellsOrder || [])
|
|
238
|
+
.map((key) => cellsByKey.get(key))
|
|
239
|
+
.filter((cell) => cell && !cell.hidden) as DataTableDesignCellObj[];
|
|
240
|
+
const orderedKeys = new Set(orderedCells.map((cell) => cell.key));
|
|
241
|
+
const remainingCells = cells.filter(
|
|
242
|
+
(cell) => !cell.hidden && !orderedKeys.has(cell.key),
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
return orderedCells.concat(remainingCells);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/* Field type keys whose registry semantics family is one of S, derived from
|
|
249
|
+
* the const-asserted registry snapshot so helper type predicates narrow to
|
|
250
|
+
* exactly the registry-bound keys. */
|
|
251
|
+
type DataTableFieldTypeOfSemantics<S extends DataTableFieldTypeSemanticsKey> = {
|
|
252
|
+
[K in keyof typeof DATA_TABLE_FIELD_TYPE_SEMANTICS]: (typeof DATA_TABLE_FIELD_TYPE_SEMANTICS)[K] extends S
|
|
253
|
+
? K
|
|
254
|
+
: never;
|
|
255
|
+
}[keyof typeof DATA_TABLE_FIELD_TYPE_SEMANTICS];
|
|
256
|
+
|
|
257
|
+
/*
|
|
258
|
+
* Return the registry semantics family one dataTable field type binds to.
|
|
259
|
+
*/
|
|
260
|
+
function getDataTableFieldTypeSemanticsKey(
|
|
261
|
+
fieldType: DataTableFieldTypeEnum | null | undefined,
|
|
262
|
+
): DataTableFieldTypeSemanticsKey | undefined {
|
|
263
|
+
return (
|
|
264
|
+
DATA_TABLE_FIELD_TYPE_SEMANTICS as Record<
|
|
265
|
+
string,
|
|
266
|
+
DataTableFieldTypeSemanticsKey
|
|
267
|
+
>
|
|
268
|
+
)[fieldType || ''];
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/*
|
|
272
|
+
* Return whether one dataTable field type stores and compares values as numbers.
|
|
273
|
+
*/
|
|
274
|
+
|
|
275
|
+
export function isDataTableNumberLikeFieldType(
|
|
276
|
+
fieldType: DataTableFieldTypeEnum | null | undefined,
|
|
277
|
+
): fieldType is DataTableFieldTypeOfSemantics<'NUMBER'> {
|
|
278
|
+
return getDataTableFieldTypeSemanticsKey(fieldType) === 'NUMBER';
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/*
|
|
282
|
+
* Return whether one dataTable field type stores and compares values as dates.
|
|
283
|
+
*/
|
|
284
|
+
|
|
285
|
+
export function isDataTableDateLikeFieldType(
|
|
286
|
+
fieldType: DataTableFieldTypeEnum | null | undefined,
|
|
287
|
+
): fieldType is DataTableFieldTypeOfSemantics<'DATE' | 'WEEK'> {
|
|
288
|
+
const semanticsKey = getDataTableFieldTypeSemanticsKey(fieldType);
|
|
289
|
+
return semanticsKey === 'DATE' || semanticsKey === 'WEEK';
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/*
|
|
293
|
+
* Return typed cell fields for an already-formatted display value.
|
|
294
|
+
*/
|
|
295
|
+
export function getDataTableDisplayCellTypedValues(
|
|
296
|
+
value: unknown,
|
|
297
|
+
fieldType: DataTableFieldTypeEnum | null | undefined,
|
|
298
|
+
) {
|
|
299
|
+
const stringValue =
|
|
300
|
+
value === null || value === undefined ? '' : String(value);
|
|
301
|
+
const hasValue = stringValue.trim() !== '';
|
|
302
|
+
const numberValue =
|
|
303
|
+
isDataTableNumberLikeFieldType(fieldType) && hasValue
|
|
304
|
+
? Number(stringValue)
|
|
305
|
+
: null;
|
|
306
|
+
|
|
307
|
+
return {
|
|
308
|
+
textValue:
|
|
309
|
+
fieldType === 'DATETIME' || isDataTableDateLikeFieldType(fieldType)
|
|
310
|
+
? null
|
|
311
|
+
: stringValue,
|
|
312
|
+
numberValue:
|
|
313
|
+
numberValue !== null && Number.isFinite(numberValue) ? numberValue : null,
|
|
314
|
+
booleanValue: null,
|
|
315
|
+
dateValue:
|
|
316
|
+
isDataTableDateLikeFieldType(fieldType) && hasValue ? stringValue : null,
|
|
317
|
+
datetimeValue: fieldType === 'DATETIME' && hasValue ? stringValue : null,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/*
|
|
322
|
+
* Return whether one dataTable field type displays a calendar week range.
|
|
323
|
+
*/
|
|
324
|
+
|
|
325
|
+
export function isDataTableWeekFieldType(
|
|
326
|
+
fieldType: DataTableFieldTypeEnum | null | undefined,
|
|
327
|
+
): fieldType is DataTableFieldTypeOfSemantics<'WEEK'> {
|
|
328
|
+
return getDataTableFieldTypeSemanticsKey(fieldType) === 'WEEK';
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/*
|
|
332
|
+
* Return the UTC day-of-week index used as the start for a week field type.
|
|
333
|
+
*/
|
|
334
|
+
|
|
335
|
+
function getDataTableWeekStartDay(
|
|
336
|
+
fieldType: DataTableFieldTypeEnum | null | undefined,
|
|
337
|
+
) {
|
|
338
|
+
return fieldType === 'WEEK_OF_SUN' ? 0 : 1;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/*
|
|
342
|
+
* Return the scalar value from a dataTable record-like object input.
|
|
343
|
+
*/
|
|
344
|
+
|
|
345
|
+
function getDataTableRecordScalarValue(value: DataTableRecordValue | Date) {
|
|
346
|
+
if (isPlainObject(value) && 'value' in value) {
|
|
347
|
+
return value.value as DataTableRecordValue;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
return value;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/*
|
|
354
|
+
* Return whether one value is a valid finite number input for a dataTable cell.
|
|
355
|
+
*/
|
|
356
|
+
|
|
357
|
+
function isValidDataTableNumberValue(value: DataTableRecordValue) {
|
|
358
|
+
const numberValue = typeof value === 'number' ? value : Number(value);
|
|
359
|
+
|
|
360
|
+
return Number.isFinite(numberValue);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/*
|
|
364
|
+
* Return whether a date string points at a real calendar date.
|
|
365
|
+
*/
|
|
366
|
+
|
|
367
|
+
function isValidDataTableDateKey(value: string) {
|
|
368
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
const [year, month, day] = value.split('-').map(Number);
|
|
373
|
+
const date = new Date(Date.UTC(year, month - 1, day));
|
|
374
|
+
|
|
375
|
+
return (
|
|
376
|
+
date.getUTCFullYear() === year &&
|
|
377
|
+
date.getUTCMonth() === month - 1 &&
|
|
378
|
+
date.getUTCDate() === day
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/*
|
|
383
|
+
* Return a UTC date parsed from a YYYY-MM-DD string.
|
|
384
|
+
*/
|
|
385
|
+
|
|
386
|
+
function parseDateKey(value: string | null | undefined) {
|
|
387
|
+
if (!value || !/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
388
|
+
return null;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
const [year, month, day] = value.split('-').map(Number);
|
|
392
|
+
const date = new Date(Date.UTC(year, month - 1, day));
|
|
393
|
+
|
|
394
|
+
if (
|
|
395
|
+
date.getUTCFullYear() !== year ||
|
|
396
|
+
date.getUTCMonth() !== month - 1 ||
|
|
397
|
+
date.getUTCDate() !== day
|
|
398
|
+
) {
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
return date;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/*
|
|
406
|
+
* Return whether one date-like string includes an explicit time component.
|
|
407
|
+
*/
|
|
408
|
+
function dataTableDateStringHasTimeComponent(value: string) {
|
|
409
|
+
return /(?:T|\s+\d{1,2}:\d{2}|\d{1,2}:\d{2}\s*(?:am|pm)\b)/i.test(
|
|
410
|
+
value.trim(),
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/*
|
|
415
|
+
* Return a date key parsed from date-only strings without applying timezone conversion.
|
|
416
|
+
*/
|
|
417
|
+
function getDataTableDateOnlyStringCalendarKey(value: string) {
|
|
418
|
+
const stringValue = value.trim();
|
|
419
|
+
if (!stringValue || dataTableDateStringHasTimeComponent(stringValue)) {
|
|
420
|
+
return null;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
if (isValidDataTableDateKey(stringValue)) {
|
|
424
|
+
return stringValue;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
const slashDate = stringValue.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
|
|
428
|
+
if (slashDate) {
|
|
429
|
+
const [, monthText, dayText, yearText] = slashDate;
|
|
430
|
+
const month = Number(monthText);
|
|
431
|
+
const day = Number(dayText);
|
|
432
|
+
const dateKey = `${yearText}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
|
|
433
|
+
|
|
434
|
+
return isValidDataTableDateKey(dateKey) ? dateKey : null;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
const parsedDate = new Date(stringValue);
|
|
438
|
+
if (!Number.isFinite(parsedDate.getTime())) {
|
|
439
|
+
return null;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
const dateKey = formatDateKey(parsedDate);
|
|
443
|
+
|
|
444
|
+
return isValidDataTableDateKey(dateKey) ? dateKey : null;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/*
|
|
448
|
+
* Return a YYYY-MM-DD string for one date using UTC calendar fields.
|
|
449
|
+
*/
|
|
450
|
+
|
|
451
|
+
function formatDateKey(date: Date) {
|
|
452
|
+
const year = date.getUTCFullYear();
|
|
453
|
+
const month = String(date.getUTCMonth() + 1).padStart(2, '0');
|
|
454
|
+
const day = String(date.getUTCDate()).padStart(2, '0');
|
|
455
|
+
|
|
456
|
+
return `${year}-${month}-${day}`;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/*
|
|
460
|
+
* Return a new UTC date offset by a number of days.
|
|
461
|
+
*/
|
|
462
|
+
|
|
463
|
+
function addDays(date: Date, days: number) {
|
|
464
|
+
const nextDate = new Date(date.getTime());
|
|
465
|
+
nextDate.setUTCDate(nextDate.getUTCDate() + days);
|
|
466
|
+
|
|
467
|
+
return nextDate;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/*
|
|
471
|
+
* Return whether one value can be stored as a dataTable date cell.
|
|
472
|
+
*/
|
|
473
|
+
|
|
474
|
+
function isValidDataTableDateValue(value: DataTableRecordValue | Date) {
|
|
475
|
+
const scalarValue = getDataTableRecordScalarValue(value);
|
|
476
|
+
|
|
477
|
+
if (scalarValue instanceof Date) {
|
|
478
|
+
return Number.isFinite(scalarValue.getTime());
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
if (isValidDataTableDateKey(String(scalarValue).split('T')[0])) {
|
|
482
|
+
return true;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
return Number.isFinite(new Date(String(scalarValue)).getTime());
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/*
|
|
489
|
+
* Return the calendar date key represented by one date value in a timezone.
|
|
490
|
+
*/
|
|
491
|
+
|
|
492
|
+
function getDataTableDateValueCalendarKey(
|
|
493
|
+
value: DataTableRecordValue | Date,
|
|
494
|
+
timeZone?: string | null,
|
|
495
|
+
) {
|
|
496
|
+
const scalarValue = getDataTableRecordScalarValue(value);
|
|
497
|
+
|
|
498
|
+
if (scalarValue instanceof Date) {
|
|
499
|
+
return formatCalDateInTimeZone(scalarValue, timeZone || null);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
const stringValue = String(scalarValue);
|
|
503
|
+
const dateOnlyKey = getDataTableDateOnlyStringCalendarKey(stringValue);
|
|
504
|
+
if (dateOnlyKey) {
|
|
505
|
+
return dateOnlyKey;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
const parsedDate = parseDateInTimezone(
|
|
509
|
+
stringValue,
|
|
510
|
+
timeZone,
|
|
511
|
+
0,
|
|
512
|
+
stringValue.includes('T'),
|
|
513
|
+
);
|
|
514
|
+
if (Number.isFinite(parsedDate.getTime())) {
|
|
515
|
+
return formatCalDateInTimeZone(parsedDate, timeZone || null);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
return stringValue.split('T')[0];
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/*
|
|
522
|
+
* Return the canonical date key for a dataTable date-like value.
|
|
523
|
+
*/
|
|
524
|
+
|
|
525
|
+
export function getDataTableDateValueKey(value: DataTableRecordValue | Date) {
|
|
526
|
+
const scalarValue = getDataTableRecordScalarValue(value);
|
|
527
|
+
|
|
528
|
+
return scalarValue instanceof Date
|
|
529
|
+
? scalarValue.toISOString().split('T')[0]
|
|
530
|
+
: String(scalarValue).split('T')[0];
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/*
|
|
534
|
+
* Return a date string normalized to the configured dataTable week start.
|
|
535
|
+
*/
|
|
536
|
+
|
|
537
|
+
export function normalizeDataTableWeekDateValue(
|
|
538
|
+
value: DataTableRecordValue | Date,
|
|
539
|
+
fieldType: DataTableFieldTypeEnum,
|
|
540
|
+
timeZone?: string | null,
|
|
541
|
+
) {
|
|
542
|
+
const dateKey = getDataTableDateValueCalendarKey(value, timeZone);
|
|
543
|
+
const date = parseDateKey(dateKey);
|
|
544
|
+
if (!date || !isDataTableWeekFieldType(fieldType)) {
|
|
545
|
+
return dateKey;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
const startDay = getDataTableWeekStartDay(fieldType);
|
|
549
|
+
const offset = (date.getUTCDay() - startDay + 7) % 7;
|
|
550
|
+
|
|
551
|
+
return formatDateKey(addDays(date, -offset));
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/*
|
|
555
|
+
* Return a date string normalized for storage by one date-like dataTable field.
|
|
556
|
+
*/
|
|
557
|
+
|
|
558
|
+
export function normalizeDataTableDateLikeValue(
|
|
559
|
+
value: DataTableRecordValue | Date,
|
|
560
|
+
fieldType: DataTableFieldTypeEnum,
|
|
561
|
+
timeZone?: string | null,
|
|
562
|
+
) {
|
|
563
|
+
return isDataTableWeekFieldType(fieldType)
|
|
564
|
+
? normalizeDataTableWeekDateValue(value, fieldType, timeZone)
|
|
565
|
+
: getDataTableDateValueCalendarKey(value, timeZone);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
/*
|
|
569
|
+
* Return the canonical ISO datetime string for a dataTable datetime value in one timezone.
|
|
570
|
+
*/
|
|
571
|
+
|
|
572
|
+
export function normalizeDataTableDateTimeValue(
|
|
573
|
+
value: DataTableRecordValue | Date,
|
|
574
|
+
timeZone?: string | null,
|
|
575
|
+
) {
|
|
576
|
+
const scalarValue = getDataTableRecordScalarValue(value);
|
|
577
|
+
|
|
578
|
+
return parseDateInTimezone(
|
|
579
|
+
scalarValue instanceof Date ? scalarValue : String(scalarValue),
|
|
580
|
+
timeZone,
|
|
581
|
+
0,
|
|
582
|
+
typeof scalarValue === 'string',
|
|
583
|
+
).toISOString();
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/*
|
|
587
|
+
* Return whether one value can be stored as a dataTable datetime cell.
|
|
588
|
+
*/
|
|
589
|
+
|
|
590
|
+
function isValidDataTableDateTimeValue(value: DataTableRecordValue) {
|
|
591
|
+
const scalarValue = getDataTableRecordScalarValue(value);
|
|
592
|
+
const date =
|
|
593
|
+
scalarValue instanceof Date ? scalarValue : new Date(String(scalarValue));
|
|
594
|
+
|
|
595
|
+
return Number.isFinite(date.getTime());
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/*
|
|
599
|
+
* Return whether one value is included in a dataTable cell's saved options.
|
|
600
|
+
*/
|
|
601
|
+
|
|
602
|
+
function isDataTableOptionValue(cell: DataTableDesignCellObj, value: unknown) {
|
|
603
|
+
const validValues = new Set(
|
|
604
|
+
(cell.options || []).map((option) => String(option.value)),
|
|
605
|
+
);
|
|
606
|
+
|
|
607
|
+
return validValues.has(String(value));
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/*
|
|
611
|
+
* Return the normalized string used for case-insensitive dataTable option matching.
|
|
612
|
+
*/
|
|
613
|
+
|
|
614
|
+
function getNormalizedDataTableOptionText(value: unknown) {
|
|
615
|
+
return String(value).toLowerCase();
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/*
|
|
619
|
+
* Return whether one dataTable design cell should normalize select option values.
|
|
620
|
+
*/
|
|
621
|
+
|
|
622
|
+
function isDataTableSelectOptionNormalizeField(cell: DataTableDesignCellObj) {
|
|
623
|
+
return cell.fieldType === 'SELECT' || cell.fieldType === 'SELECT_OR_TEXT';
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/*
|
|
627
|
+
* Return the saved option value when one select-style cell input matches an option value or label.
|
|
628
|
+
*/
|
|
629
|
+
|
|
630
|
+
export function normalizeDataTableSelectOptionValue(
|
|
631
|
+
cell: DataTableDesignCellObj,
|
|
632
|
+
value: DataTableRecordValue,
|
|
633
|
+
) {
|
|
634
|
+
if (value === null || !isDataTableSelectOptionNormalizeField(cell)) {
|
|
635
|
+
return value;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
if (isDataTableOptionValue(cell, value)) {
|
|
639
|
+
return value;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
const normalizedValue = getNormalizedDataTableOptionText(value);
|
|
643
|
+
const option = (cell.options || []).find(
|
|
644
|
+
(item) =>
|
|
645
|
+
getNormalizedDataTableOptionText(item.value) === normalizedValue ||
|
|
646
|
+
getNormalizedDataTableOptionText(item.label) === normalizedValue,
|
|
647
|
+
);
|
|
648
|
+
|
|
649
|
+
return option ? option.value : value;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/*
|
|
653
|
+
* Return a user-readable validation error for an invalid dataTable cell value.
|
|
654
|
+
*/
|
|
655
|
+
|
|
656
|
+
export function getDataTableCellValueValidationError(
|
|
657
|
+
cell: DataTableDesignCellObj,
|
|
658
|
+
value: DataTableRecordValue,
|
|
659
|
+
) {
|
|
660
|
+
if (value === null) {
|
|
661
|
+
return null;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
if (
|
|
665
|
+
isDataTableNumberLikeFieldType(cell.fieldType) &&
|
|
666
|
+
!isValidDataTableNumberValue(value)
|
|
667
|
+
) {
|
|
668
|
+
return `${cell.key} must be a valid number.`;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
if (
|
|
672
|
+
isDataTableDateLikeFieldType(cell.fieldType) &&
|
|
673
|
+
!isValidDataTableDateValue(value)
|
|
674
|
+
) {
|
|
675
|
+
return `${cell.key} must be a valid date.`;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
if (cell.fieldType === 'DATETIME' && !isValidDataTableDateTimeValue(value)) {
|
|
679
|
+
return `${cell.key} must be a valid datetime.`;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
if (
|
|
683
|
+
cell.fieldType === 'SELECT' &&
|
|
684
|
+
cell.options?.length &&
|
|
685
|
+
!isDataTableOptionValue(cell, value)
|
|
686
|
+
) {
|
|
687
|
+
return `${cell.key} must be one of: ${(cell.options || []).map((option) => option.value).join(', ')}`;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
if (
|
|
691
|
+
cell.fieldType === 'SELECT_OR_TEXT' &&
|
|
692
|
+
!isDataTableOptionValue(cell, value) &&
|
|
693
|
+
typeof value !== 'string'
|
|
694
|
+
) {
|
|
695
|
+
const optionsText = (cell.options || [])
|
|
696
|
+
.map((option) => option.value)
|
|
697
|
+
.join(', ');
|
|
698
|
+
return optionsText
|
|
699
|
+
? `${cell.key} must be one of: ${optionsText}, or a text string.`
|
|
700
|
+
: `${cell.key} must be a text string.`;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
if (cell.fieldType === 'MULTI_SELECT') {
|
|
704
|
+
if (!Array.isArray(value)) {
|
|
705
|
+
return `${cell.key} must be an array of option values.`;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
if (cell.options?.length) {
|
|
709
|
+
const invalidValues = value.filter(
|
|
710
|
+
(item) => !isDataTableOptionValue(cell, item),
|
|
711
|
+
);
|
|
712
|
+
if (invalidValues.length) {
|
|
713
|
+
return (
|
|
714
|
+
`${cell.key} contains invalid option values: ${invalidValues.map((item) => String(item)).join(', ')}. ` +
|
|
715
|
+
`Allowed values: ${(cell.options || []).map((option) => option.value).join(', ')}`
|
|
716
|
+
);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
return null;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
/*
|
|
725
|
+
* Return a compact month-day string for dataTable week display labels.
|
|
726
|
+
*/
|
|
727
|
+
|
|
728
|
+
function getDataTableWeekDisplayMonthDay(date: Date, showMonth: boolean) {
|
|
729
|
+
const day = String(date.getUTCDate());
|
|
730
|
+
if (!showMonth) {
|
|
731
|
+
return day;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
const month = date.toLocaleString('en-US', {
|
|
735
|
+
month: 'short',
|
|
736
|
+
timeZone: 'UTC',
|
|
737
|
+
});
|
|
738
|
+
|
|
739
|
+
return `${month} ${day}`;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/*
|
|
743
|
+
* Return the display text for one date as a dataTable week range.
|
|
744
|
+
*/
|
|
745
|
+
|
|
746
|
+
export function formatDataTableWeekDateRange(
|
|
747
|
+
value: DataTableRecordValue | Date,
|
|
748
|
+
fieldType: DataTableFieldTypeEnum,
|
|
749
|
+
) {
|
|
750
|
+
if (!isDataTableWeekFieldType(fieldType)) {
|
|
751
|
+
return '';
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
const start = parseDateKey(normalizeDataTableWeekDateValue(value, fieldType));
|
|
755
|
+
if (!start) {
|
|
756
|
+
return '';
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
const end = addDays(start, 6);
|
|
760
|
+
const startText = getDataTableWeekDisplayMonthDay(start, true);
|
|
761
|
+
const endText = getDataTableWeekDisplayMonthDay(
|
|
762
|
+
end,
|
|
763
|
+
start.getUTCMonth() !== end.getUTCMonth(),
|
|
764
|
+
);
|
|
765
|
+
|
|
766
|
+
return `${startText} - ${endText}`;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/*
|
|
770
|
+
* Return every column key once, honoring a saved order before appending missing keys.
|
|
771
|
+
*/
|
|
772
|
+
|
|
773
|
+
export function getCompleteDataTableColumnOrder(
|
|
774
|
+
columnKeys: string[],
|
|
775
|
+
savedOrder?: string[] | null,
|
|
776
|
+
) {
|
|
777
|
+
const validKeys = new Set(columnKeys);
|
|
778
|
+
const orderedKeys: string[] = [];
|
|
779
|
+
const seenKeys = new Set<string>();
|
|
780
|
+
|
|
781
|
+
(savedOrder || []).forEach((key) => {
|
|
782
|
+
if (!validKeys.has(key) || seenKeys.has(key)) {
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
orderedKeys.push(key);
|
|
787
|
+
seenKeys.add(key);
|
|
788
|
+
});
|
|
789
|
+
|
|
790
|
+
columnKeys.forEach((key) => {
|
|
791
|
+
if (seenKeys.has(key)) {
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
orderedKeys.push(key);
|
|
796
|
+
seenKeys.add(key);
|
|
797
|
+
});
|
|
798
|
+
|
|
799
|
+
return orderedKeys;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
/*
|
|
803
|
+
* Move one visible dataTable column while preserving hidden or unrendered key slots.
|
|
804
|
+
*/
|
|
805
|
+
|
|
806
|
+
export function moveVisibleDataTableColumnKeyInOrder(params: {
|
|
807
|
+
allColumnKeys: string[];
|
|
808
|
+
fromKey: string;
|
|
809
|
+
savedOrder?: string[] | null;
|
|
810
|
+
toVisibleIndex: number;
|
|
811
|
+
visibleColumnKeys: string[];
|
|
812
|
+
}) {
|
|
813
|
+
const fullOrder = getCompleteDataTableColumnOrder(
|
|
814
|
+
params.allColumnKeys,
|
|
815
|
+
params.savedOrder,
|
|
816
|
+
);
|
|
817
|
+
const visibleKeySet = new Set(params.visibleColumnKeys);
|
|
818
|
+
const visibleOrder = fullOrder.filter((key) => visibleKeySet.has(key));
|
|
819
|
+
const fromIndex = visibleOrder.indexOf(params.fromKey);
|
|
820
|
+
|
|
821
|
+
if (fromIndex < 0) {
|
|
822
|
+
return fullOrder;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
const nextVisibleOrder = visibleOrder.slice(0);
|
|
826
|
+
const [movedKey] = nextVisibleOrder.splice(fromIndex, 1);
|
|
827
|
+
const toIndex = Math.max(
|
|
828
|
+
0,
|
|
829
|
+
Math.min(params.toVisibleIndex, nextVisibleOrder.length),
|
|
830
|
+
);
|
|
831
|
+
|
|
832
|
+
if (!movedKey) {
|
|
833
|
+
return fullOrder;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
nextVisibleOrder.splice(toIndex, 0, movedKey);
|
|
837
|
+
|
|
838
|
+
let visibleIndex = 0;
|
|
839
|
+
return fullOrder.map((key) => {
|
|
840
|
+
if (!visibleKeySet.has(key)) {
|
|
841
|
+
return key;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
const nextKey = nextVisibleOrder[visibleIndex] || key;
|
|
845
|
+
visibleIndex += 1;
|
|
846
|
+
|
|
847
|
+
return nextKey;
|
|
848
|
+
});
|
|
849
|
+
}
|