@updog/data-editor 0.1.87 → 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
@@ -411,6 +411,8 @@ declare var export_default = {
411
411
  validation: {
412
412
  alreadyExists: "Already exists in your database",
413
413
  endDateBeforeStart: "End date must be after start date",
414
+ invalidCountry: "Invalid country",
415
+ invalidCurrency: "Invalid currency",
414
416
  invalidDate: "Invalid date",
415
417
  invalidEmail: "Invalid email address",
416
418
  invalidFormat: "Invalid format",
@@ -537,6 +539,8 @@ declare var export_default = {
537
539
  showAll: "Show all",
538
540
  showMatched: "Show matched",
539
541
  allMatched: "All values are matched",
542
+ corrected: "Corrected",
543
+ possibleMatch: "Possible match",
540
544
  tooManyValues: "Showing first {{shown}} of {{total}} values",
541
545
  unmatchedWarning:
542
546
  "Unmatched values won't be imported. Match this value to keep the data. You can edit values after importing.",
@@ -792,6 +796,47 @@ type MultiSelectEditorCell = {
792
796
  /** Splits a raw imported cell and joins on export. Omitted: import auto-detects, export joins with `", "`. */
793
797
  delimiter?: string;
794
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
+ };
795
840
  /** Number input cell with locale-aware formatting. Bounds and decimal digits come from the column's `{ type: "number" }` validator. */
796
841
  type NumberEditorCell = {
797
842
  type: "number";
@@ -808,9 +853,11 @@ type NumberEditorCell = {
808
853
  * - `"time"` — plain text input for a time of day; the column is checked against `{ type: "time" }`.
809
854
  * - `"select"` — dropdown with a fixed list of options.
810
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.
811
858
  * - `"number"` — number input with locale-aware formatting.
812
859
  */
813
- type CellEditor = TextEditorCell | DateEditorCell | TimeEditorCell | SelectEditorCell | MultiSelectEditorCell | NumberEditorCell;
860
+ type CellEditor = TextEditorCell | DateEditorCell | TimeEditorCell | SelectEditorCell | MultiSelectEditorCell | CountryEditorCell | CurrencyEditorCell | NumberEditorCell;
814
861
  /** Dropdown filter shown in the sidebar Filters panel. */
815
862
  type SelectColumnFilter = {
816
863
  type: "select";
@@ -941,6 +988,16 @@ type BuiltInValidator = {
941
988
  type: "oneOf";
942
989
  values: string[];
943
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;
944
1001
  } | {
945
1002
  type: "number";
946
1003
  /** Inclusive lower bound. */
@@ -1206,6 +1263,24 @@ type DataEditorChat<TRow extends DataEditorRow = DataEditorRow> = {
1206
1263
  onCancel?: () => void;
1207
1264
  };
1208
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
+
1209
1284
  /**
1210
1285
  * Categories of internal errors surfaced through the `onError` callback.
1211
1286
  * `license.*` codes cover license validation failures (previously a separate
@@ -1243,16 +1318,6 @@ declare class ErrorHandler {
1243
1318
  handleError(error: UpdogError): void;
1244
1319
  }
1245
1320
 
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
1321
  type FormatScope = string;
1257
1322
  type FormatField = {
1258
1323
  key: string;
@@ -1391,6 +1456,7 @@ type NormalizedColumn = Omit<DataEditorColumn, "validators"> & {
1391
1456
  numberConfig?: NumberConfig;
1392
1457
  dateConfig?: DateConfig;
1393
1458
  timeConfig?: TimeConfig;
1459
+ addedOptions?: readonly string[];
1394
1460
  };
1395
1461
  type NumberConfig = {
1396
1462
  min?: number;
@@ -1495,7 +1561,7 @@ type IFilterEngine<TRow extends DataEditorRow = DataEditorRow> = {
1495
1561
  getWordsPerRow(): number;
1496
1562
  getShowOnlyDeletedRows(): boolean;
1497
1563
  getSortState(): SortState;
1498
- setColumns(columns: DataEditorColumn[]): void;
1564
+ setColumns(columns: DataEditorColumn[], ctx?: FormatContext): void;
1499
1565
  setFilters(filters: Partial<Filters>): void;
1500
1566
  setSortState(state: SortState, sortType?: SortType, locales?: string[]): Promise<void>;
1501
1567
  updateRowText(rowId: TRowId, row: TRow): void;
@@ -1923,10 +1989,12 @@ type SelectionRect = {
1923
1989
  readonly rowIds: readonly TRowId[];
1924
1990
  };
1925
1991
 
1926
- 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 = {
1927
1995
  options: string[];
1928
1996
  delimiter?: string;
1929
- enableCustomValue?: boolean;
1997
+ allowsCustom: boolean;
1930
1998
  };
1931
1999
 
1932
2000
  /**
@@ -1946,7 +2014,7 @@ type MultiSelectEditorConfig = {
1946
2014
 
1947
2015
  type MultiSelectTarget = {
1948
2016
  delimiter: string;
1949
- editor: MultiSelectEditorConfig;
2017
+ editor: ListCell;
1950
2018
  };
1951
2019
  type PasteSpec = {
1952
2020
  sourceColumnIds: string[];
@@ -2051,6 +2119,10 @@ declare class DataStore<TRow extends DataEditorRow = DataEditorRow> {
2051
2119
  getRowId(index: number): TRowId | undefined;
2052
2120
  getLocalRowCount(): number;
2053
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
+ */
2054
2126
  setI18n(i18n: {
2055
2127
  t: TFunction;
2056
2128
  locale: string;
@@ -2170,7 +2242,7 @@ declare class DataStore<TRow extends DataEditorRow = DataEditorRow> {
2170
2242
  * has already normalised through buildImportRow — never transforms twice.
2171
2243
  */
2172
2244
  appendClientRows(sourceId: DataSourceId, newRows: TRow[]): TRowId[];
2173
- private formatContext;
2245
+ getFormatContext(): FormatContext;
2174
2246
  /**
2175
2247
  * A column nothing separated is a signal to whoever integrated the SDK, so
2176
2248
  * it goes out in English through `onError` rather than to the person at the