@updog/data-editor 0.1.85 → 0.1.87
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/{errors-QjijTHhG.js → errors-B6IWsH_J.js} +1 -1
- package/index.css +1 -1
- package/index.d.ts +211 -6
- package/index.js +5246 -4143
- package/package.json +1 -1
- package/{parsers-DZBqyDgS.js → parsers-B6HEb5c3.js} +1 -1
- package/{sheetWorkerSource.generated-BAJMh23Y.js → sheetWorkerSource.generated-Db-yDLRU.js} +1 -1
package/index.d.ts
CHANGED
|
@@ -67,6 +67,8 @@ declare var export_default = {
|
|
|
67
67
|
clearField: "Clear field",
|
|
68
68
|
showPassword: "Show password",
|
|
69
69
|
hidePassword: "Hide password",
|
|
70
|
+
switchToAm: "Switch to AM",
|
|
71
|
+
switchToPm: "Switch to PM",
|
|
70
72
|
},
|
|
71
73
|
select: {
|
|
72
74
|
noResults: "No results",
|
|
@@ -414,10 +416,12 @@ declare var export_default = {
|
|
|
414
416
|
invalidFormat: "Invalid format",
|
|
415
417
|
invalidNumber: "Invalid number",
|
|
416
418
|
invalidOption: "Invalid option",
|
|
419
|
+
invalidTime: "Invalid time",
|
|
417
420
|
outOfRange: "Out of range",
|
|
418
421
|
required: "This field is required",
|
|
419
422
|
structuralMismatch: "This might be in the wrong column.",
|
|
420
423
|
tooManyDecimals: "Too many decimal places",
|
|
424
|
+
tooPreciseTime: "Too precise for this column",
|
|
421
425
|
valueMustBeUnique: "Value must be unique",
|
|
422
426
|
},
|
|
423
427
|
license: {
|
|
@@ -575,6 +579,58 @@ declare var export_default = {
|
|
|
575
579
|
|
|
576
580
|
type PluralSuffixes = "_zero" | "_one" | "_two" | "_few" | "_many" | "_other";
|
|
577
581
|
|
|
582
|
+
/**
|
|
583
|
+
* Strips plural suffixes from a key to get the base form.
|
|
584
|
+
* e.g. "createRows_one" → "createRows", "createRows_other" → "createRows"
|
|
585
|
+
*/
|
|
586
|
+
type StripPluralSuffix<K extends string> =
|
|
587
|
+
K extends `${infer Base}${PluralSuffixes}` ? Base : K;
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Recursively derives dot-separated keys from a nested object type.
|
|
591
|
+
* - Plural keys (e.g. `createRows_one`, `createRows_other`) are collapsed to their base (`createRows`).
|
|
592
|
+
* - `Record<string, string>` leaf nodes (like `calendar.months`) are treated as terminal.
|
|
593
|
+
*/
|
|
594
|
+
type NestedKeyOf<T, Prefix extends string = ""> =
|
|
595
|
+
T extends Record<string, unknown>
|
|
596
|
+
? string extends keyof T
|
|
597
|
+
? Prefix extends ""
|
|
598
|
+
? never
|
|
599
|
+
: Prefix
|
|
600
|
+
: {
|
|
601
|
+
[K in keyof T & string]: T[K] extends Record<string, unknown>
|
|
602
|
+
? string extends keyof T[K]
|
|
603
|
+
?
|
|
604
|
+
| (Prefix extends ""
|
|
605
|
+
? StripPluralSuffix<K>
|
|
606
|
+
: `${Prefix}.${StripPluralSuffix<K>}`)
|
|
607
|
+
| NestedKeyOf<
|
|
608
|
+
T[K],
|
|
609
|
+
Prefix extends ""
|
|
610
|
+
? StripPluralSuffix<K>
|
|
611
|
+
: `${Prefix}.${StripPluralSuffix<K>}`
|
|
612
|
+
>
|
|
613
|
+
: NestedKeyOf<
|
|
614
|
+
T[K],
|
|
615
|
+
Prefix extends ""
|
|
616
|
+
? StripPluralSuffix<K>
|
|
617
|
+
: `${Prefix}.${StripPluralSuffix<K>}`
|
|
618
|
+
>
|
|
619
|
+
: Prefix extends ""
|
|
620
|
+
? StripPluralSuffix<K>
|
|
621
|
+
: `${Prefix}.${StripPluralSuffix<K>}`;
|
|
622
|
+
}[keyof T & string]
|
|
623
|
+
: never;
|
|
624
|
+
|
|
625
|
+
/** Union of all valid translation keys derived from the English locale. */
|
|
626
|
+
type TranslationKeys = NestedKeyOf<typeof export_default>;
|
|
627
|
+
|
|
628
|
+
/** Typed translation function. Accepts typed keys with autocomplete, and dynamic strings as fallback. */
|
|
629
|
+
type TFunction = (
|
|
630
|
+
key: TranslationKeys | (string & {}),
|
|
631
|
+
options?: Record<string, unknown>,
|
|
632
|
+
) => string;
|
|
633
|
+
|
|
578
634
|
/** Makes all properties optional recursively. */
|
|
579
635
|
type DeepPartial<T> = {
|
|
580
636
|
[P in keyof T]?: T[P] extends Record<string, unknown>
|
|
@@ -656,6 +712,11 @@ type Filters = {
|
|
|
656
712
|
min?: string;
|
|
657
713
|
max?: string;
|
|
658
714
|
}>;
|
|
715
|
+
/** Per-column time-of-day range filters. Key = column ID, values are canonical times. */
|
|
716
|
+
columnTimeRangeFilters: Record<string, {
|
|
717
|
+
min?: string;
|
|
718
|
+
max?: string;
|
|
719
|
+
}>;
|
|
659
720
|
};
|
|
660
721
|
|
|
661
722
|
/**
|
|
@@ -700,6 +761,16 @@ type TextEditorCell = {
|
|
|
700
761
|
type DateEditorCell = {
|
|
701
762
|
type: "date";
|
|
702
763
|
};
|
|
764
|
+
/** Time-of-day cell. Bounds come from the column's `{ type: "time" }` validator. */
|
|
765
|
+
type TimeEditorCell = {
|
|
766
|
+
type: "time";
|
|
767
|
+
/**
|
|
768
|
+
* The clock the cell draws, `h23` for `18:00` and `h12` for `6:00 PM`.
|
|
769
|
+
* Defaults to the clock the reader's own browser uses. Whichever is drawn,
|
|
770
|
+
* both forms stay readable when the person types.
|
|
771
|
+
*/
|
|
772
|
+
hourCycle?: "h12" | "h23";
|
|
773
|
+
};
|
|
703
774
|
/** Dropdown select cell. The user picks from a fixed list of options. */
|
|
704
775
|
type SelectEditorCell = {
|
|
705
776
|
type: "select";
|
|
@@ -734,11 +805,12 @@ type NumberEditorCell = {
|
|
|
734
805
|
*
|
|
735
806
|
* - `"text"` — plain text input (default).
|
|
736
807
|
* - `"date"` — date picker; the calendar honours the column's date validator bounds.
|
|
808
|
+
* - `"time"` — plain text input for a time of day; the column is checked against `{ type: "time" }`.
|
|
737
809
|
* - `"select"` — dropdown with a fixed list of options.
|
|
738
810
|
* - `"multiselect"` — dropdown allowing zero or more options; stored as `string[]`.
|
|
739
811
|
* - `"number"` — number input with locale-aware formatting.
|
|
740
812
|
*/
|
|
741
|
-
type CellEditor = TextEditorCell | DateEditorCell | SelectEditorCell | MultiSelectEditorCell | NumberEditorCell;
|
|
813
|
+
type CellEditor = TextEditorCell | DateEditorCell | TimeEditorCell | SelectEditorCell | MultiSelectEditorCell | NumberEditorCell;
|
|
742
814
|
/** Dropdown filter shown in the sidebar Filters panel. */
|
|
743
815
|
type SelectColumnFilter = {
|
|
744
816
|
type: "select";
|
|
@@ -763,14 +835,21 @@ type DateRangeColumnFilter = {
|
|
|
763
835
|
/** Label displayed above the filter. */
|
|
764
836
|
label?: string;
|
|
765
837
|
};
|
|
838
|
+
/** Time-of-day min/max range filter shown in the sidebar Filters panel. */
|
|
839
|
+
type TimeRangeColumnFilter = {
|
|
840
|
+
type: "time-range";
|
|
841
|
+
/** Label displayed above the filter. */
|
|
842
|
+
label?: string;
|
|
843
|
+
};
|
|
766
844
|
/**
|
|
767
845
|
* Filter control shown in the sidebar Filters panel for a column.
|
|
768
846
|
*
|
|
769
847
|
* - `"select"` — dropdown to pick one or more values.
|
|
770
848
|
* - `"number-range"` — two inputs for min and max number.
|
|
771
849
|
* - `"date-range"` — two date pickers for start and end date.
|
|
850
|
+
* - `"time-range"` — two time fields for the earliest and latest time of day.
|
|
772
851
|
*/
|
|
773
|
-
type ColumnFilter = SelectColumnFilter | NumberRangeColumnFilter | DateRangeColumnFilter;
|
|
852
|
+
type ColumnFilter = SelectColumnFilter | NumberRangeColumnFilter | DateRangeColumnFilter | TimeRangeColumnFilter;
|
|
774
853
|
/** Lock mode for a column. `"all"` locks for every row; `"default"` locks only default-source rows. */
|
|
775
854
|
type ColumnLockMode = "all" | "default";
|
|
776
855
|
/**
|
|
@@ -806,8 +885,21 @@ type DataEditorColumn = {
|
|
|
806
885
|
/** Format the display value without changing stored data. E.g. add `$` prefix. */
|
|
807
886
|
formatter?: (value: string) => string;
|
|
808
887
|
/**
|
|
809
|
-
* Transform a value
|
|
810
|
-
*
|
|
888
|
+
* Transform a value on its way into the store. Runs on every value arriving
|
|
889
|
+
* from outside the editor, so `loadData`, a file import, a remote source, a
|
|
890
|
+
* custom format, and a paste of text from another app all call it. A value
|
|
891
|
+
* moving inside the grid is left alone, so a manual edit, a fill, a paste of
|
|
892
|
+
* cells copied from the grid itself, undo, and redo never call it.
|
|
893
|
+
*
|
|
894
|
+
* The value arrives in the shape the cell is stored in. Numbers and dates
|
|
895
|
+
* canonicalize first, and a `select` value resolves through value matching
|
|
896
|
+
* first, so the transformer sees the option the user confirmed. On a
|
|
897
|
+
* `multiselect` column it runs once per token, the way `formatter` already
|
|
898
|
+
* reads that column. A token it empties leaves the list, and two tokens it
|
|
899
|
+
* makes equal collapse into one.
|
|
900
|
+
*
|
|
901
|
+
* It runs before validation, so a transformer that moves a value outside
|
|
902
|
+
* `editor.options` makes its own column fail a `oneOf` rule.
|
|
811
903
|
*/
|
|
812
904
|
transformer?: (value: unknown) => unknown;
|
|
813
905
|
/** How the cell is edited. Defaults to text input. */
|
|
@@ -832,6 +924,8 @@ type DataEditorColumn = {
|
|
|
832
924
|
locked?: boolean | ColumnLockMode;
|
|
833
925
|
};
|
|
834
926
|
|
|
927
|
+
/** How precisely a time-of-day column is written. */
|
|
928
|
+
type TimePrecision = "minutes" | "seconds" | "milliseconds";
|
|
835
929
|
/**
|
|
836
930
|
* A built-in declarative validator — a declarative object the SDK interprets.
|
|
837
931
|
*/
|
|
@@ -864,6 +958,15 @@ type BuiltInValidator = {
|
|
|
864
958
|
min?: string;
|
|
865
959
|
max?: string;
|
|
866
960
|
message?: string;
|
|
961
|
+
} | {
|
|
962
|
+
type: "time";
|
|
963
|
+
/** Inclusive lower bound, canonical, any of the three precisions. */
|
|
964
|
+
min?: string;
|
|
965
|
+
/** Inclusive upper bound, canonical, any of the three precisions. */
|
|
966
|
+
max?: string;
|
|
967
|
+
/** The finest the column is written. A value carrying more is flagged, never trimmed. */
|
|
968
|
+
precision?: TimePrecision;
|
|
969
|
+
message?: string;
|
|
867
970
|
} | {
|
|
868
971
|
type: "unique";
|
|
869
972
|
message?: string;
|
|
@@ -1140,6 +1243,54 @@ declare class ErrorHandler {
|
|
|
1140
1243
|
handleError(error: UpdogError): void;
|
|
1141
1244
|
}
|
|
1142
1245
|
|
|
1246
|
+
/**
|
|
1247
|
+
* The parts of a column every cell type reads. Both `DataEditorColumn` and
|
|
1248
|
+
* `NormalizedColumn` satisfy it, so core and the UI pass the column they hold.
|
|
1249
|
+
*/
|
|
1250
|
+
type TypedColumn = Pick<DataEditorColumn, "id" | "editor" | "formatter">;
|
|
1251
|
+
type ColumnFormat = {
|
|
1252
|
+
readonly typeId: string;
|
|
1253
|
+
readonly candidateId: string;
|
|
1254
|
+
};
|
|
1255
|
+
|
|
1256
|
+
type FormatScope = string;
|
|
1257
|
+
type FormatField = {
|
|
1258
|
+
key: string;
|
|
1259
|
+
column: TypedColumn;
|
|
1260
|
+
};
|
|
1261
|
+
type AmbiguousColumn = {
|
|
1262
|
+
field: string;
|
|
1263
|
+
applied: ColumnFormat;
|
|
1264
|
+
candidates: readonly ColumnFormat[];
|
|
1265
|
+
samples: readonly string[];
|
|
1266
|
+
};
|
|
1267
|
+
type FormatBatch = {
|
|
1268
|
+
reader(key: string): (value: unknown) => unknown;
|
|
1269
|
+
ambiguous: readonly AmbiguousColumn[];
|
|
1270
|
+
};
|
|
1271
|
+
/**
|
|
1272
|
+
* The one door every reading of raw text goes through. The verdict lives on
|
|
1273
|
+
* the pair of scope and column, so a column is never read by its neighbour's
|
|
1274
|
+
* verdict and a neighbouring source starts its own vote.
|
|
1275
|
+
*
|
|
1276
|
+
* The locale fallback needs no branch of its own: a tie falls to the first
|
|
1277
|
+
* candidate in declared order, and the lists are ordered so the reader's own
|
|
1278
|
+
* locale sits first among its peers.
|
|
1279
|
+
*/
|
|
1280
|
+
declare class FormatGate {
|
|
1281
|
+
private deps;
|
|
1282
|
+
private memory;
|
|
1283
|
+
constructor(deps: {
|
|
1284
|
+
columns: () => readonly TypedColumn[];
|
|
1285
|
+
i18n: () => {
|
|
1286
|
+
locale: string;
|
|
1287
|
+
t: TFunction;
|
|
1288
|
+
} | null;
|
|
1289
|
+
});
|
|
1290
|
+
prepare(scope: FormatScope, rows: readonly Record<string, unknown>[], fields?: readonly FormatField[]): FormatBatch;
|
|
1291
|
+
forget(scope?: FormatScope): void;
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1143
1294
|
type FormulaCellContext = {
|
|
1144
1295
|
value: unknown;
|
|
1145
1296
|
field: string;
|
|
@@ -1239,6 +1390,7 @@ type NormalizedColumn = Omit<DataEditorColumn, "validators"> & {
|
|
|
1239
1390
|
asyncConfig?: AsyncFunctionValidator[];
|
|
1240
1391
|
numberConfig?: NumberConfig;
|
|
1241
1392
|
dateConfig?: DateConfig;
|
|
1393
|
+
timeConfig?: TimeConfig;
|
|
1242
1394
|
};
|
|
1243
1395
|
type NumberConfig = {
|
|
1244
1396
|
min?: number;
|
|
@@ -1249,6 +1401,11 @@ type DateConfig = {
|
|
|
1249
1401
|
min?: string;
|
|
1250
1402
|
max?: string;
|
|
1251
1403
|
};
|
|
1404
|
+
type TimeConfig = {
|
|
1405
|
+
min?: string;
|
|
1406
|
+
max?: string;
|
|
1407
|
+
precision?: TimePrecision;
|
|
1408
|
+
};
|
|
1252
1409
|
|
|
1253
1410
|
type PrimaryKeyInput = string | readonly string[];
|
|
1254
1411
|
|
|
@@ -1848,6 +2005,8 @@ declare class DataStore<TRow extends DataEditorRow = DataEditorRow> {
|
|
|
1848
2005
|
readonly formulaRegistry: FormulaRegistry;
|
|
1849
2006
|
private _isLoading;
|
|
1850
2007
|
private sourceManager;
|
|
2008
|
+
/** The format verdict of every source and column pair that has one. */
|
|
2009
|
+
readonly formats: FormatGate;
|
|
1851
2010
|
readonly sourceLifecycle: SourceLifecycle<TRow>;
|
|
1852
2011
|
private dirtyTracker;
|
|
1853
2012
|
private filterEngine;
|
|
@@ -1887,10 +2046,15 @@ declare class DataStore<TRow extends DataEditorRow = DataEditorRow> {
|
|
|
1887
2046
|
private filterRowReader;
|
|
1888
2047
|
private bulkMutationHost;
|
|
1889
2048
|
private orchestrator;
|
|
2049
|
+
private i18n;
|
|
1890
2050
|
constructor(errorHandler?: ErrorHandler);
|
|
1891
2051
|
getRowId(index: number): TRowId | undefined;
|
|
1892
2052
|
getLocalRowCount(): number;
|
|
1893
2053
|
setValidator(validator: IValidator<TRow>): void;
|
|
2054
|
+
setI18n(i18n: {
|
|
2055
|
+
t: TFunction;
|
|
2056
|
+
locale: string;
|
|
2057
|
+
}): void;
|
|
1894
2058
|
isColumnLocked(field: string): boolean;
|
|
1895
2059
|
isColumnPreLocked(field: string): boolean;
|
|
1896
2060
|
lockColumn(field: string, mode?: ColumnLockMode): void;
|
|
@@ -2006,9 +2170,50 @@ declare class DataStore<TRow extends DataEditorRow = DataEditorRow> {
|
|
|
2006
2170
|
* has already normalised through buildImportRow — never transforms twice.
|
|
2007
2171
|
*/
|
|
2008
2172
|
appendClientRows(sourceId: DataSourceId, newRows: TRow[]): TRowId[];
|
|
2173
|
+
private formatContext;
|
|
2174
|
+
/**
|
|
2175
|
+
* A column nothing separated is a signal to whoever integrated the SDK, so
|
|
2176
|
+
* it goes out in English through `onError` rather than to the person at the
|
|
2177
|
+
* screen. The wizard could ask which shape instead; the seam is here and
|
|
2178
|
+
* the dialog is out of scope (spec section 10).
|
|
2179
|
+
*/
|
|
2180
|
+
private reportAmbiguity;
|
|
2181
|
+
/**
|
|
2182
|
+
* The column's reader with no verdict behind it. A formula result is one
|
|
2183
|
+
* value, so there is nothing to vote on; the reader is here to give the
|
|
2184
|
+
* column's storage shape, which for a number means digits rather than an
|
|
2185
|
+
* exponent or a JS number.
|
|
2186
|
+
*/
|
|
2187
|
+
private fieldReader;
|
|
2188
|
+
/**
|
|
2189
|
+
* The column's own reader over values an assistant produced. There is no
|
|
2190
|
+
* column of file text to vote on here, so the reader runs without a verdict,
|
|
2191
|
+
* the same way a formula result is read: it gives the value the shape its
|
|
2192
|
+
* column stores rather than a JS number or an exponent. A value that reads
|
|
2193
|
+
* back onto what the cell already holds leaves the delta, so an untouched
|
|
2194
|
+
* cell stays untouched.
|
|
2195
|
+
*/
|
|
2196
|
+
private readChatDeltas;
|
|
2009
2197
|
private normalizeClientRows;
|
|
2010
2198
|
appendRows(sourceId: DataSourceId, newRows: TRow[], rowIdMap?: Map<number, TRowId>): TRowId[];
|
|
2011
|
-
|
|
2199
|
+
/**
|
|
2200
|
+
* The declared transformers, resolved once so a per-row loop never rescans
|
|
2201
|
+
* the column list.
|
|
2202
|
+
*/
|
|
2203
|
+
private collectTransformers;
|
|
2204
|
+
/**
|
|
2205
|
+
* Runs the column transformers over a partial row the client states as a
|
|
2206
|
+
* baseline, so it is compared against the stored row in the same shape the
|
|
2207
|
+
* stored row was written in.
|
|
2208
|
+
*/
|
|
2209
|
+
private transformClientValues;
|
|
2210
|
+
/**
|
|
2211
|
+
* Reads a stated original the way the row itself was read, then transforms
|
|
2212
|
+
* it. The verdict is already in the gate's memory from the append that put
|
|
2213
|
+
* these rows in, so an empty batch reuses it rather than voting again.
|
|
2214
|
+
*/
|
|
2215
|
+
private normalizeClientValues;
|
|
2216
|
+
seedInitialChanges(sourceId: DataSourceId, assignedRowIds: TRowId[], currentRows: TRow[], changes: InitialRowChange<TRow>[]): void;
|
|
2012
2217
|
upsertRows(sourceId: DataSourceId, newRows: TRow[], options?: UpsertOptions): UpsertResult<TRow>;
|
|
2013
2218
|
private getAnchorMap;
|
|
2014
2219
|
private clearAnchorMapCache;
|
|
@@ -2194,7 +2399,7 @@ type ColumnDelta = {
|
|
|
2194
2399
|
|
|
2195
2400
|
/** Numeric row identifier. V8 stores small integers (Smi) inline — no heap allocation. */
|
|
2196
2401
|
type TRowId = number;
|
|
2197
|
-
type SortType = "text" | "number" | "date";
|
|
2402
|
+
type SortType = "text" | "number" | "date" | "time";
|
|
2198
2403
|
|
|
2199
2404
|
/** A pointer to a specific cell in the grid. */
|
|
2200
2405
|
type CellLocation = {
|