@updog/data-editor-wc 0.1.87 → 0.1.89

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
@@ -409,6 +409,8 @@ declare var export_default = {
409
409
  validation: {
410
410
  alreadyExists: "Already exists in your database",
411
411
  endDateBeforeStart: "End date must be after start date",
412
+ invalidCountry: "Invalid country",
413
+ invalidCurrency: "Invalid currency",
412
414
  invalidDate: "Invalid date",
413
415
  invalidEmail: "Invalid email address",
414
416
  invalidFormat: "Invalid format",
@@ -535,6 +537,8 @@ declare var export_default = {
535
537
  showAll: "Show all",
536
538
  showMatched: "Show matched",
537
539
  allMatched: "All values are matched",
540
+ corrected: "Corrected",
541
+ possibleMatch: "Possible match",
538
542
  tooManyValues: "Showing first {{shown}} of {{total}} values",
539
543
  unmatchedWarning:
540
544
  "Unmatched values won't be imported. Match this value to keep the data. You can edit values after importing.",
@@ -698,6 +702,47 @@ type MultiSelectEditorCell = {
698
702
  /** Splits a raw imported cell and joins on export. Omitted: import auto-detects, export joins with `", "`. */
699
703
  delimiter?: string;
700
704
  };
705
+ /**
706
+ * Country cell. Stores the ISO 3166-1 alpha-2 code in upper case; the screen
707
+ * shows the country name in the interface language. The list is the 249
708
+ * assigned ISO codes plus `XK` for Kosovo, which ISO does not assign.
709
+ */
710
+ type CountryEditorCell = {
711
+ type: "country";
712
+ /** Pick zero or more countries; the stored value becomes `string[]`. */
713
+ multiple?: boolean;
714
+ /**
715
+ * Let users add a value the list has not got. Defaults to **false** — the
716
+ * country list is closed until the client opens it. A created value reaches
717
+ * `onComplete` next to `DE` and `FR` with no code of its own.
718
+ */
719
+ enableCustomValue?: boolean;
720
+ /** Splits a raw imported cell and joins on export, when `multiple`. Omitted:
721
+ * import auto-detects, export joins with `", "`. */
722
+ delimiter?: string;
723
+ /**
724
+ * The codes the column takes, alpha-2, in the order the dropdown shows them
725
+ * under `currency` and before the name sort under `country`. A code the ISO
726
+ * list has not got is dropped with a warning. Omitted: the whole list.
727
+ */
728
+ only?: string[];
729
+ };
730
+ /**
731
+ * Currency cell. Stores the ISO 4217 code in upper case and shows it as is;
732
+ * the list is the 178 codes of the current ISO list. Reads codes, numeric
733
+ * codes, names in 26 languages, ISO names and symbols on the way in.
734
+ */
735
+ type CurrencyEditorCell = {
736
+ type: "currency";
737
+ /**
738
+ * Let users add a value the list has not got. Defaults to **false** — the
739
+ * currency list is closed until the client opens it. A created value reaches
740
+ * `onComplete` next to `USD` and `EUR` with no code of its own.
741
+ */
742
+ enableCustomValue?: boolean;
743
+ /** The ISO 4217 codes the column takes, in the order the dropdown shows them. */
744
+ only?: string[];
745
+ };
701
746
  /** Number input cell with locale-aware formatting. Bounds and decimal digits come from the column's `{ type: "number" }` validator. */
702
747
  type NumberEditorCell = {
703
748
  type: "number";
@@ -714,9 +759,11 @@ type NumberEditorCell = {
714
759
  * - `"time"` — plain text input for a time of day; the column is checked against `{ type: "time" }`.
715
760
  * - `"select"` — dropdown with a fixed list of options.
716
761
  * - `"multiselect"` — dropdown allowing zero or more options; stored as `string[]`.
762
+ * - `"country"` — dropdown over the ISO country list; stores the alpha-2 code, shows the name.
763
+ * - `"currency"` — dropdown over the ISO 4217 list; stores and shows the three-letter code.
717
764
  * - `"number"` — number input with locale-aware formatting.
718
765
  */
719
- type CellEditor = TextEditorCell | DateEditorCell | TimeEditorCell | SelectEditorCell | MultiSelectEditorCell | NumberEditorCell;
766
+ type CellEditor = TextEditorCell | DateEditorCell | TimeEditorCell | SelectEditorCell | MultiSelectEditorCell | CountryEditorCell | CurrencyEditorCell | NumberEditorCell;
720
767
  /** Dropdown filter shown in the sidebar Filters panel. */
721
768
  type SelectColumnFilter = {
722
769
  type: "select";
@@ -847,6 +894,16 @@ type BuiltInValidator = {
847
894
  type: "oneOf";
848
895
  values: string[];
849
896
  message?: string;
897
+ }
898
+ /** The cell holds a code from the country list. Implicit on every country column. */
899
+ | {
900
+ type: "country";
901
+ message?: string;
902
+ }
903
+ /** The cell holds a code from the currency list. Implicit on every currency column. */
904
+ | {
905
+ type: "currency";
906
+ message?: string;
850
907
  } | {
851
908
  type: "number";
852
909
  /** Inclusive lower bound. */
@@ -1064,7 +1121,7 @@ type DataEditorChat<TRow extends DataEditorRow = DataEditorRow> = {
1064
1121
  * `license.*` codes cover license validation failures (previously a separate
1065
1122
  * `LicenseErrorCode` enum).
1066
1123
  */
1067
- type UpdogErrorCode = "PARSE_ERROR" | "RENDER_ERROR" | "TRANSFORM_ERROR" | "VALIDATION_ERROR" | "WORKER_ERROR" | "COMMAND_ERROR" | "OPERATION_ERROR" | "license.invalid" | "license.missing" | "license.domain_not_allowed" | "license.subscription_inactive" | "license.trial_expired";
1124
+ type UpdogErrorCode = "PARSE_ERROR" | "RENDER_ERROR" | "TRANSFORM_ERROR" | "VALIDATION_ERROR" | "WORKER_ERROR" | "COMMAND_ERROR" | "OPERATION_ERROR" | "HOOK_ERROR" | "license.invalid" | "license.missing" | "license.domain_not_allowed" | "license.subscription_inactive" | "license.trial_expired";
1068
1125
  /**
1069
1126
  * An internal error caught by the SDK and passed to `onError`. The SDK
1070
1127
  * recovers gracefully where possible — `onError` is for your logging and
@@ -1090,6 +1147,43 @@ type UpdogError = {
1090
1147
  originalError?: unknown;
1091
1148
  };
1092
1149
 
1150
+ /** One input row: the schema shape after reading plus the raw file row. */
1151
+ type RowImportInputRow = {
1152
+ /**
1153
+ * Keys are your schema column ids; values went through format reading,
1154
+ * value mapping, and the column's `transformer`.
1155
+ */
1156
+ row: Record<string, unknown>;
1157
+ /**
1158
+ * Keys are the file's headers, unmapped ones included; values are the
1159
+ * cell texts as they appear in the file.
1160
+ */
1161
+ raw: Record<string, string>;
1162
+ };
1163
+ type RowImportMeta = {
1164
+ /** Zero-based chunk number within the current workbook. */
1165
+ chunkIndex: number;
1166
+ /** Total number of chunks in the current workbook. */
1167
+ chunkCount: number;
1168
+ isLastChunk: boolean;
1169
+ /** The workbook being imported: source name, sheet (XLSX), file headers. */
1170
+ workbook: {
1171
+ name: string;
1172
+ sheetName?: string;
1173
+ headers: string[];
1174
+ };
1175
+ /** This workbook's column mapping: file header → schema column id. */
1176
+ mapping: Record<string, string | undefined>;
1177
+ /** The `context` prop, untouched. */
1178
+ context: unknown;
1179
+ };
1180
+ /**
1181
+ * Chunk in, chunk out. The returned array is positional: element `i` answers
1182
+ * `rows[i]`, `null` drops that row, elements past `rows.length` append new
1183
+ * rows. Returning nothing leaves the chunk as it is.
1184
+ */
1185
+ type RowImportHook = (rows: RowImportInputRow[], meta: RowImportMeta) => (Record<string, unknown> | null)[] | void | Promise<(Record<string, unknown> | null)[] | void>;
1186
+
1093
1187
  /**
1094
1188
  * A single row in the submit result, with orthogonal flags describing its state.
1095
1189
  *
@@ -1504,6 +1598,40 @@ type DataEditorBaseProps<TRow extends DataEditorRow = DataEditorRow> = {
1504
1598
  * ```
1505
1599
  */
1506
1600
  onValueMatch?: (valuesToMatch: Record<string, ValueMatchInput>) => ValueMatchOutput | Promise<ValueMatchOutput>;
1601
+ /**
1602
+ * Edit, drop, or append rows between the file and the editor. Called once
1603
+ * per chunk of 5,000 rows of each imported workbook, after every cell went
1604
+ * through format reading, value mapping, and the column's `transformer` —
1605
+ * the raw file row rides along in `raw`, unmapped headers included.
1606
+ *
1607
+ * The returned array is positional: element `i` replaces `rows[i].row`,
1608
+ * `null` drops that row, elements past `rows.length` append new rows.
1609
+ * Return nothing to leave the chunk as it is. Every field the hook changed
1610
+ * is re-read as if it came from the file — format reading, value mapping,
1611
+ * and `transformer` run again on it.
1612
+ *
1613
+ * A thrown error, a timeout of 30 seconds per chunk, or an array shorter
1614
+ * than the input counts as a failure: the chunk lands unchanged, one
1615
+ * `HOOK_ERROR` reaches `onError`, and the hook stays off for the rest of
1616
+ * that import run.
1617
+ *
1618
+ * @example
1619
+ * ```ts
1620
+ * // Split "USD 100" from the file's price column into two schema fields.
1621
+ * onRowImport={(rows) =>
1622
+ * rows.map(({ row, raw }) => {
1623
+ * const [currency, amount] = (raw["price"] ?? "").split(" ");
1624
+ * return { ...row, currency, amount };
1625
+ * })
1626
+ * }
1627
+ * ```
1628
+ */
1629
+ onRowImport?: RowImportHook;
1630
+ /**
1631
+ * Anything you want your hooks to see: `onRowImport` receives it untouched
1632
+ * as `meta.context`.
1633
+ */
1634
+ context?: unknown;
1507
1635
  /**
1508
1636
  * Extra synonyms layered on top of the built-ins, in two tables that stay
1509
1637
  * apart: `columns` scores a file header against your columns, `values`