@updog/data-editor 0.1.86 → 0.1.88

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/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",
@@ -409,15 +411,19 @@ declare var export_default = {
409
411
  validation: {
410
412
  alreadyExists: "Already exists in your database",
411
413
  endDateBeforeStart: "End date must be after start date",
414
+ invalidCountry: "Invalid country",
415
+ invalidCurrency: "Invalid currency",
412
416
  invalidDate: "Invalid date",
413
417
  invalidEmail: "Invalid email address",
414
418
  invalidFormat: "Invalid format",
415
419
  invalidNumber: "Invalid number",
416
420
  invalidOption: "Invalid option",
421
+ invalidTime: "Invalid time",
417
422
  outOfRange: "Out of range",
418
423
  required: "This field is required",
419
424
  structuralMismatch: "This might be in the wrong column.",
420
425
  tooManyDecimals: "Too many decimal places",
426
+ tooPreciseTime: "Too precise for this column",
421
427
  valueMustBeUnique: "Value must be unique",
422
428
  },
423
429
  license: {
@@ -533,6 +539,8 @@ declare var export_default = {
533
539
  showAll: "Show all",
534
540
  showMatched: "Show matched",
535
541
  allMatched: "All values are matched",
542
+ corrected: "Corrected",
543
+ possibleMatch: "Possible match",
536
544
  tooManyValues: "Showing first {{shown}} of {{total}} values",
537
545
  unmatchedWarning:
538
546
  "Unmatched values won't be imported. Match this value to keep the data. You can edit values after importing.",
@@ -708,6 +716,11 @@ type Filters = {
708
716
  min?: string;
709
717
  max?: string;
710
718
  }>;
719
+ /** Per-column time-of-day range filters. Key = column ID, values are canonical times. */
720
+ columnTimeRangeFilters: Record<string, {
721
+ min?: string;
722
+ max?: string;
723
+ }>;
711
724
  };
712
725
 
713
726
  /**
@@ -752,6 +765,16 @@ type TextEditorCell = {
752
765
  type DateEditorCell = {
753
766
  type: "date";
754
767
  };
768
+ /** Time-of-day cell. Bounds come from the column's `{ type: "time" }` validator. */
769
+ type TimeEditorCell = {
770
+ type: "time";
771
+ /**
772
+ * The clock the cell draws, `h23` for `18:00` and `h12` for `6:00 PM`.
773
+ * Defaults to the clock the reader's own browser uses. Whichever is drawn,
774
+ * both forms stay readable when the person types.
775
+ */
776
+ hourCycle?: "h12" | "h23";
777
+ };
755
778
  /** Dropdown select cell. The user picks from a fixed list of options. */
756
779
  type SelectEditorCell = {
757
780
  type: "select";
@@ -773,6 +796,47 @@ type MultiSelectEditorCell = {
773
796
  /** Splits a raw imported cell and joins on export. Omitted: import auto-detects, export joins with `", "`. */
774
797
  delimiter?: string;
775
798
  };
799
+ /**
800
+ * Country cell. Stores the ISO 3166-1 alpha-2 code in upper case; the screen
801
+ * shows the country name in the interface language. The list is the 249
802
+ * assigned ISO codes plus `XK` for Kosovo, which ISO does not assign.
803
+ */
804
+ type CountryEditorCell = {
805
+ type: "country";
806
+ /** Pick zero or more countries; the stored value becomes `string[]`. */
807
+ multiple?: boolean;
808
+ /**
809
+ * Let users add a value the list has not got. Defaults to **false** — the
810
+ * country list is closed until the client opens it. A created value reaches
811
+ * `onComplete` next to `DE` and `FR` with no code of its own.
812
+ */
813
+ enableCustomValue?: boolean;
814
+ /** Splits a raw imported cell and joins on export, when `multiple`. Omitted:
815
+ * import auto-detects, export joins with `", "`. */
816
+ delimiter?: string;
817
+ /**
818
+ * The codes the column takes, alpha-2, in the order the dropdown shows them
819
+ * under `currency` and before the name sort under `country`. A code the ISO
820
+ * list has not got is dropped with a warning. Omitted: the whole list.
821
+ */
822
+ only?: string[];
823
+ };
824
+ /**
825
+ * Currency cell. Stores the ISO 4217 code in upper case and shows it as is;
826
+ * the list is the 178 codes of the current ISO list. Reads codes, numeric
827
+ * codes, names in 26 languages, ISO names and symbols on the way in.
828
+ */
829
+ type CurrencyEditorCell = {
830
+ type: "currency";
831
+ /**
832
+ * Let users add a value the list has not got. Defaults to **false** — the
833
+ * currency list is closed until the client opens it. A created value reaches
834
+ * `onComplete` next to `USD` and `EUR` with no code of its own.
835
+ */
836
+ enableCustomValue?: boolean;
837
+ /** The ISO 4217 codes the column takes, in the order the dropdown shows them. */
838
+ only?: string[];
839
+ };
776
840
  /** Number input cell with locale-aware formatting. Bounds and decimal digits come from the column's `{ type: "number" }` validator. */
777
841
  type NumberEditorCell = {
778
842
  type: "number";
@@ -786,11 +850,14 @@ type NumberEditorCell = {
786
850
  *
787
851
  * - `"text"` — plain text input (default).
788
852
  * - `"date"` — date picker; the calendar honours the column's date validator bounds.
853
+ * - `"time"` — plain text input for a time of day; the column is checked against `{ type: "time" }`.
789
854
  * - `"select"` — dropdown with a fixed list of options.
790
855
  * - `"multiselect"` — dropdown allowing zero or more options; stored as `string[]`.
856
+ * - `"country"` — dropdown over the ISO country list; stores the alpha-2 code, shows the name.
857
+ * - `"currency"` — dropdown over the ISO 4217 list; stores and shows the three-letter code.
791
858
  * - `"number"` — number input with locale-aware formatting.
792
859
  */
793
- type CellEditor = TextEditorCell | DateEditorCell | SelectEditorCell | MultiSelectEditorCell | NumberEditorCell;
860
+ type CellEditor = TextEditorCell | DateEditorCell | TimeEditorCell | SelectEditorCell | MultiSelectEditorCell | CountryEditorCell | CurrencyEditorCell | NumberEditorCell;
794
861
  /** Dropdown filter shown in the sidebar Filters panel. */
795
862
  type SelectColumnFilter = {
796
863
  type: "select";
@@ -815,14 +882,21 @@ type DateRangeColumnFilter = {
815
882
  /** Label displayed above the filter. */
816
883
  label?: string;
817
884
  };
885
+ /** Time-of-day min/max range filter shown in the sidebar Filters panel. */
886
+ type TimeRangeColumnFilter = {
887
+ type: "time-range";
888
+ /** Label displayed above the filter. */
889
+ label?: string;
890
+ };
818
891
  /**
819
892
  * Filter control shown in the sidebar Filters panel for a column.
820
893
  *
821
894
  * - `"select"` — dropdown to pick one or more values.
822
895
  * - `"number-range"` — two inputs for min and max number.
823
896
  * - `"date-range"` — two date pickers for start and end date.
897
+ * - `"time-range"` — two time fields for the earliest and latest time of day.
824
898
  */
825
- type ColumnFilter = SelectColumnFilter | NumberRangeColumnFilter | DateRangeColumnFilter;
899
+ type ColumnFilter = SelectColumnFilter | NumberRangeColumnFilter | DateRangeColumnFilter | TimeRangeColumnFilter;
826
900
  /** Lock mode for a column. `"all"` locks for every row; `"default"` locks only default-source rows. */
827
901
  type ColumnLockMode = "all" | "default";
828
902
  /**
@@ -897,6 +971,8 @@ type DataEditorColumn = {
897
971
  locked?: boolean | ColumnLockMode;
898
972
  };
899
973
 
974
+ /** How precisely a time-of-day column is written. */
975
+ type TimePrecision = "minutes" | "seconds" | "milliseconds";
900
976
  /**
901
977
  * A built-in declarative validator — a declarative object the SDK interprets.
902
978
  */
@@ -912,6 +988,16 @@ type BuiltInValidator = {
912
988
  type: "oneOf";
913
989
  values: string[];
914
990
  message?: string;
991
+ }
992
+ /** The cell holds a code from the country list. Implicit on every country column. */
993
+ | {
994
+ type: "country";
995
+ message?: string;
996
+ }
997
+ /** The cell holds a code from the currency list. Implicit on every currency column. */
998
+ | {
999
+ type: "currency";
1000
+ message?: string;
915
1001
  } | {
916
1002
  type: "number";
917
1003
  /** Inclusive lower bound. */
@@ -929,6 +1015,15 @@ type BuiltInValidator = {
929
1015
  min?: string;
930
1016
  max?: string;
931
1017
  message?: string;
1018
+ } | {
1019
+ type: "time";
1020
+ /** Inclusive lower bound, canonical, any of the three precisions. */
1021
+ min?: string;
1022
+ /** Inclusive upper bound, canonical, any of the three precisions. */
1023
+ max?: string;
1024
+ /** The finest the column is written. A value carrying more is flagged, never trimmed. */
1025
+ precision?: TimePrecision;
1026
+ message?: string;
932
1027
  } | {
933
1028
  type: "unique";
934
1029
  message?: string;
@@ -1168,6 +1263,24 @@ type DataEditorChat<TRow extends DataEditorRow = DataEditorRow> = {
1168
1263
  onCancel?: () => void;
1169
1264
  };
1170
1265
 
1266
+ /**
1267
+ * The parts of a column every cell type reads. Both `DataEditorColumn` and
1268
+ * `NormalizedColumn` satisfy it, so core and the UI pass the column they hold.
1269
+ */
1270
+ type TypedColumn = Pick<DataEditorColumn, "id" | "editor" | "formatter"> & {
1271
+ /** Values the person created at the screen; `options()` lists them after
1272
+ * the column's own. */
1273
+ addedOptions?: readonly string[];
1274
+ };
1275
+ type FormatContext = {
1276
+ locale: string | null;
1277
+ t: TFunction | null;
1278
+ };
1279
+ type ColumnFormat = {
1280
+ readonly typeId: string;
1281
+ readonly candidateId: string;
1282
+ };
1283
+
1171
1284
  /**
1172
1285
  * Categories of internal errors surfaced through the `onError` callback.
1173
1286
  * `license.*` codes cover license validation failures (previously a separate
@@ -1205,16 +1318,6 @@ declare class ErrorHandler {
1205
1318
  handleError(error: UpdogError): void;
1206
1319
  }
1207
1320
 
1208
- /**
1209
- * The parts of a column every cell type reads. Both `DataEditorColumn` and
1210
- * `NormalizedColumn` satisfy it, so core and the UI pass the column they hold.
1211
- */
1212
- type TypedColumn = Pick<DataEditorColumn, "id" | "editor" | "formatter">;
1213
- type ColumnFormat = {
1214
- readonly typeId: string;
1215
- readonly candidateId: string;
1216
- };
1217
-
1218
1321
  type FormatScope = string;
1219
1322
  type FormatField = {
1220
1323
  key: string;
@@ -1352,6 +1455,8 @@ type NormalizedColumn = Omit<DataEditorColumn, "validators"> & {
1352
1455
  asyncConfig?: AsyncFunctionValidator[];
1353
1456
  numberConfig?: NumberConfig;
1354
1457
  dateConfig?: DateConfig;
1458
+ timeConfig?: TimeConfig;
1459
+ addedOptions?: readonly string[];
1355
1460
  };
1356
1461
  type NumberConfig = {
1357
1462
  min?: number;
@@ -1362,6 +1467,11 @@ type DateConfig = {
1362
1467
  min?: string;
1363
1468
  max?: string;
1364
1469
  };
1470
+ type TimeConfig = {
1471
+ min?: string;
1472
+ max?: string;
1473
+ precision?: TimePrecision;
1474
+ };
1365
1475
 
1366
1476
  type PrimaryKeyInput = string | readonly string[];
1367
1477
 
@@ -1451,7 +1561,7 @@ type IFilterEngine<TRow extends DataEditorRow = DataEditorRow> = {
1451
1561
  getWordsPerRow(): number;
1452
1562
  getShowOnlyDeletedRows(): boolean;
1453
1563
  getSortState(): SortState;
1454
- setColumns(columns: DataEditorColumn[]): void;
1564
+ setColumns(columns: DataEditorColumn[], ctx?: FormatContext): void;
1455
1565
  setFilters(filters: Partial<Filters>): void;
1456
1566
  setSortState(state: SortState, sortType?: SortType, locales?: string[]): Promise<void>;
1457
1567
  updateRowText(rowId: TRowId, row: TRow): void;
@@ -1879,10 +1989,12 @@ type SelectionRect = {
1879
1989
  readonly rowIds: readonly TRowId[];
1880
1990
  };
1881
1991
 
1882
- type MultiSelectEditorConfig = {
1992
+ /** What a list column's type answers, gathered by the caller: the options,
1993
+ * the declared delimiter if any, and whether a value outside the list stays. */
1994
+ type ListCell = {
1883
1995
  options: string[];
1884
1996
  delimiter?: string;
1885
- enableCustomValue?: boolean;
1997
+ allowsCustom: boolean;
1886
1998
  };
1887
1999
 
1888
2000
  /**
@@ -1902,7 +2014,7 @@ type MultiSelectEditorConfig = {
1902
2014
 
1903
2015
  type MultiSelectTarget = {
1904
2016
  delimiter: string;
1905
- editor: MultiSelectEditorConfig;
2017
+ editor: ListCell;
1906
2018
  };
1907
2019
  type PasteSpec = {
1908
2020
  sourceColumnIds: string[];
@@ -2007,6 +2119,10 @@ declare class DataStore<TRow extends DataEditorRow = DataEditorRow> {
2007
2119
  getRowId(index: number): TRowId | undefined;
2008
2120
  getLocalRowCount(): number;
2009
2121
  setValidator(validator: IValidator<TRow>): void;
2122
+ /**
2123
+ * The filter engine printed its formatters with the language it had when
2124
+ * the columns arrived, and the columns arrive before the language does.
2125
+ */
2010
2126
  setI18n(i18n: {
2011
2127
  t: TFunction;
2012
2128
  locale: string;
@@ -2126,7 +2242,7 @@ declare class DataStore<TRow extends DataEditorRow = DataEditorRow> {
2126
2242
  * has already normalised through buildImportRow — never transforms twice.
2127
2243
  */
2128
2244
  appendClientRows(sourceId: DataSourceId, newRows: TRow[]): TRowId[];
2129
- private formatContext;
2245
+ getFormatContext(): FormatContext;
2130
2246
  /**
2131
2247
  * A column nothing separated is a signal to whoever integrated the SDK, so
2132
2248
  * it goes out in English through `onError` rather than to the person at the
@@ -2355,7 +2471,7 @@ type ColumnDelta = {
2355
2471
 
2356
2472
  /** Numeric row identifier. V8 stores small integers (Smi) inline — no heap allocation. */
2357
2473
  type TRowId = number;
2358
- type SortType = "text" | "number" | "date";
2474
+ type SortType = "text" | "number" | "date" | "time";
2359
2475
 
2360
2476
  /** A pointer to a specific cell in the grid. */
2361
2477
  type CellLocation = {