@updog/data-editor-wc 0.1.81 → 0.1.83

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
@@ -415,6 +415,7 @@ declare var export_default = {
415
415
  outOfRange: "Out of range",
416
416
  required: "This field is required",
417
417
  structuralMismatch: "This might be in the wrong column.",
418
+ tooManyDecimals: "Too many decimal places",
418
419
  valueMustBeUnique: "Value must be unique",
419
420
  },
420
421
  license: {
@@ -446,24 +447,6 @@ declare var export_default = {
446
447
  text: "Your subscription is no longer active. Please renew to continue.",
447
448
  },
448
449
  },
449
- scale: {
450
- bootstrap_failed: {
451
- title: "Couldn't connect to the server",
452
- text: "The server returned an error. Please refresh the page or contact support.",
453
- },
454
- workspace_lost: {
455
- title: "Connection lost",
456
- text: "The session ended unexpectedly. Refresh the page to reconnect.",
457
- },
458
- unreachable: {
459
- title: "Server unreachable",
460
- text: "Check your connection and refresh the page.",
461
- },
462
- server_error: {
463
- title: "Server error",
464
- text: "The server returned an error. Please refresh the page or contact support.",
465
- },
466
- },
467
450
  },
468
451
  uploader: {
469
452
  steps: {
@@ -638,98 +621,6 @@ type DataEditorTranslations = DeepPartial<ExpandPluralKeys<typeof export_default
638
621
  */
639
622
  type DataEditorRow = Record<string, unknown>;
640
623
 
641
- /**
642
- * A built-in declarative validator. Mode-symmetric: the SDK ships a TS
643
- * interpreter, the Updog Scale Go binary ships a Go interpreter, and both
644
- * agree on pass/fail outcomes per `api/validators.json`.
645
- */
646
- type BuiltInValidator = {
647
- type: "required";
648
- message?: string;
649
- } | {
650
- type: "regex";
651
- pattern: string;
652
- flags?: string;
653
- message?: string;
654
- } | {
655
- type: "oneOf";
656
- values: string[];
657
- message?: string;
658
- } | {
659
- type: "range";
660
- min?: number;
661
- max?: number;
662
- message?: string;
663
- } | {
664
- type: "email";
665
- message?: string;
666
- } | {
667
- type: "date";
668
- format?: "YYYY-MM-DD" | "DD/MM/YYYY";
669
- message?: string;
670
- } | {
671
- type: "numeric";
672
- message?: string;
673
- } | {
674
- type: "unique";
675
- message?: string;
676
- fn?: UniqueRemoteFn;
677
- };
678
- /** One cell in an asyncFunction batch. Row is passed by reference. */
679
- type AsyncValidatorCell = {
680
- /** Value of the validated column for this cell. */
681
- value: unknown;
682
- /** The full row — for row-dependent checks. */
683
- row: DataEditorRow;
684
- };
685
- /**
686
- * Remote existence check for `{ type: "unique" }`. Called once per sweep
687
- * with all distinct candidate values; report the subset that already exists —
688
- * return it and/or stream it via onChunk (results are unioned). `signal`
689
- * fires only when results can no longer be used. Client-mode only.
690
- */
691
- type UniqueRemoteFn = (values: unknown[], onChunk: (existing: unknown[]) => void, signal: AbortSignal) => Promise<unknown[] | void>;
692
- type AsyncFunctionValidator = {
693
- type: "asyncFunction";
694
- /**
695
- * Called once per column per operation with every affected cell. Report
696
- * failures by `index` into `cells`: return an array aligned with the input
697
- * (null = valid) and/or stream sparse failures via onChunk (unioned, any
698
- * order). `signal` fires only when results can no longer be used.
699
- * Client-mode only. For uniqueness use `unique.fn`, not this.
700
- */
701
- fn: (cells: AsyncValidatorCell[], onChunk: (failures: {
702
- index: number;
703
- error: ValidationError;
704
- }[]) => void, signal: AbortSignal) => Promise<(ValidationError | null)[] | void>;
705
- };
706
- /**
707
- * Server-mode-only escape hatch: an expression evaluated by the Go binary
708
- * via expr-lang. Skipped at runtime in client mode (warned at mount).
709
- */
710
- type ExpressionValidator = {
711
- type: "expression";
712
- expr: string;
713
- message?: string;
714
- };
715
- /**
716
- * Client-mode-only escape hatch: a JS predicate run inline. Dropped (with
717
- * one warn per column) when the SDK serializes the schema for server mode.
718
- */
719
- type FunctionValidator = {
720
- type: "function";
721
- fn: CellValidator;
722
- };
723
- /**
724
- * The validator-rule union accepted by `DataEditorColumn.validators`.
725
- * - Built-ins and `expression` are declarative objects (cross the wire).
726
- * - `function` wraps a `CellValidator`; client-mode-only, dropped+warned in server mode.
727
- *
728
- * Named `ValidatorRule` (not `Validator`) so it doesn't clash with the
729
- * runtime `Validator` class in `core/Validator.ts`.
730
- */
731
- type ValidatorRule = BuiltInValidator | ExpressionValidator | FunctionValidator | AsyncFunctionValidator;
732
-
733
624
  /**
734
625
  * Severity level for a validation message.
735
626
  * - `"error"` — a validation failure: marks the row invalid, counts as an error.
@@ -767,13 +658,9 @@ type CellValidator = (value: unknown, row: DataEditorRow) => ValidationError | n
767
658
  type TextEditorCell = {
768
659
  type: "text";
769
660
  };
770
- /** Date picker cell. Optionally restrict the selectable date range. */
661
+ /** Date picker cell. Bounds come from the column's `{ type: "date" }` validator. */
771
662
  type DateEditorCell = {
772
663
  type: "date";
773
- /** Earliest selectable date. */
774
- minDate?: Date;
775
- /** Latest selectable date. */
776
- maxDate?: Date;
777
664
  };
778
665
  /** Dropdown select cell. The user picks from a fixed list of options. */
779
666
  type SelectEditorCell = {
@@ -796,23 +683,19 @@ type MultiSelectEditorCell = {
796
683
  /** Splits a raw imported cell and joins on export. Omitted: import auto-detects, export joins with `", "`. */
797
684
  delimiter?: string;
798
685
  };
799
- /** Number input cell with locale-aware formatting. */
686
+ /** Number input cell with locale-aware formatting. Bounds and decimal digits come from the column's `{ type: "number" }` validator. */
800
687
  type NumberEditorCell = {
801
688
  type: "number";
802
- /** Maximum number of decimal digits allowed. When omitted, decimals are unrestricted. */
803
- decimalPlaces?: number;
804
689
  /** Character used as the decimal point (e.g. `"."` or `","`). Defaults to the browser locale. */
805
690
  decimalSeparator?: string;
806
691
  /** Character inserted between groups of three digits (e.g. `","` or `"."`). Defaults to the browser locale. */
807
692
  thousandsSeparator?: string;
808
- /** Extra characters to allow beyond digits, decimal separator, and minus sign (e.g. `"%-"`). When defined, minus is only kept if explicitly included. */
809
- allowChars?: string;
810
693
  };
811
694
  /**
812
695
  * Controls how a cell is edited.
813
696
  *
814
697
  * - `"text"` — plain text input (default).
815
- * - `"date"` — date picker with optional min/max bounds.
698
+ * - `"date"` — date picker; the calendar honours the column's date validator bounds.
816
699
  * - `"select"` — dropdown with a fixed list of options.
817
700
  * - `"multiselect"` — dropdown allowing zero or more options; stored as `string[]`.
818
701
  * - `"number"` — number input with locale-aware formatting.
@@ -861,7 +744,7 @@ type ColumnLockMode = "all" | "default";
861
744
  * { id: "name", title: "Full Name", size: 200, validators: [{ type: "required", message: "Name is required" }] },
862
745
  * { id: "email", title: "Email", size: 250, validators: [{ type: "required", message: "Email is required" }, { type: "email", message: "Invalid email" }, { type: "unique" }] },
863
746
  * { id: "role", title: "Role", editor: { type: "select", options: ["Admin", "Editor", "Viewer"] } },
864
- * { id: "salary", title: "Salary", validators: [{ type: "numeric", message: "Must be a number" }], formatter: (v) => v ? `$${v}` : "" },
747
+ * { id: "salary", title: "Salary", validators: [{ type: "number", message: "Must be a number" }], formatter: (v) => v ? `$${v}` : "" },
865
748
  * ];
866
749
  * ```
867
750
  */
@@ -872,11 +755,9 @@ type DataEditorColumn = {
872
755
  title: string;
873
756
  /**
874
757
  * One or more validators run on every edit. Accepts:
875
- * - Built-in object literals: `{ type: "required" | "email" | "regex" | "range" | "oneOf" | "date" | "numeric" | "unique", ... }`.
876
- * - `{ type: "expression", expr }` — server-mode only. Warned in client mode.
877
- * - `{ type: "function", fn }` — client-mode only. Dropped+warned in server mode.
878
- *
879
- * See `_specs/VALIDATIONS.md` §4.5 for the per-mode support matrix.
758
+ * - Built-in object literals: `{ type: "required" | "email" | "regex" | "number" | "oneOf" | "date" | "unique", ... }`.
759
+ * - `{ type: "function", fn }` — a JS predicate run inline.
760
+ * - `{ type: "asyncFunction", fn }` — batched remote checks.
880
761
  */
881
762
  validators?: ValidatorRule[];
882
763
  /**
@@ -913,6 +794,86 @@ type DataEditorColumn = {
913
794
  locked?: boolean | ColumnLockMode;
914
795
  };
915
796
 
797
+ /**
798
+ * A built-in declarative validator — a declarative object the SDK interprets.
799
+ */
800
+ type BuiltInValidator = {
801
+ type: "required";
802
+ message?: string;
803
+ } | {
804
+ type: "regex";
805
+ pattern: string;
806
+ flags?: string;
807
+ message?: string;
808
+ } | {
809
+ type: "oneOf";
810
+ values: string[];
811
+ message?: string;
812
+ } | {
813
+ type: "number";
814
+ /** Inclusive lower bound. */
815
+ min?: number;
816
+ /** Inclusive upper bound. */
817
+ max?: number;
818
+ /** Maximum decimal digits; `0` means integers. Values with more are flagged, never rounded. */
819
+ decimalPlaces?: number;
820
+ message?: string;
821
+ } | {
822
+ type: "email";
823
+ message?: string;
824
+ } | {
825
+ type: "date";
826
+ min?: string;
827
+ max?: string;
828
+ message?: string;
829
+ } | {
830
+ type: "unique";
831
+ message?: string;
832
+ fn?: UniqueRemoteFn;
833
+ };
834
+ /** One cell in an asyncFunction batch. Row is passed by reference. */
835
+ type AsyncValidatorCell = {
836
+ /** Value of the validated column for this cell. */
837
+ value: unknown;
838
+ /** The full row — for row-dependent checks. */
839
+ row: DataEditorRow;
840
+ };
841
+ /**
842
+ * Remote existence check for `{ type: "unique" }`. Called once per sweep
843
+ * with all distinct candidate values; report the subset that already exists —
844
+ * return it and/or stream it via onChunk (results are unioned). `signal`
845
+ * fires only when results can no longer be used. Client-mode only.
846
+ */
847
+ type UniqueRemoteFn = (values: unknown[], onChunk: (existing: unknown[]) => void, signal: AbortSignal) => Promise<unknown[] | void>;
848
+ type AsyncFunctionValidator = {
849
+ type: "asyncFunction";
850
+ /**
851
+ * Called once per column per operation with every affected cell. Report
852
+ * failures by `index` into `cells`: return an array aligned with the input
853
+ * (null = valid) and/or stream sparse failures via onChunk (unioned, any
854
+ * order). `signal` fires only when results can no longer be used.
855
+ * Client-mode only. For uniqueness use `unique.fn`, not this.
856
+ */
857
+ fn: (cells: AsyncValidatorCell[], onChunk: (failures: {
858
+ index: number;
859
+ error: ValidationError;
860
+ }[]) => void, signal: AbortSignal) => Promise<(ValidationError | null)[] | void>;
861
+ };
862
+ /**
863
+ * Escape hatch: a JS predicate run inline against the cell value and its row.
864
+ */
865
+ type FunctionValidator = {
866
+ type: "function";
867
+ fn: CellValidator;
868
+ };
869
+ /**
870
+ * The validator-rule union accepted by `DataEditorColumn.validators`.
871
+ *
872
+ * Named `ValidatorRule` (not `Validator`) so it doesn't clash with the
873
+ * runtime `Validator` class in `core/Validator.ts`.
874
+ */
875
+ type ValidatorRule = BuiltInValidator | FunctionValidator | AsyncFunctionValidator;
876
+
916
877
  /**
917
878
  * A single operation the LLM wants to apply to rows in the current filtered view.
918
879
  *
@@ -1053,12 +1014,10 @@ type DataEditorChat<TRow extends DataEditorRow = DataEditorRow> = {
1053
1014
 
1054
1015
  /**
1055
1016
  * Categories of internal errors surfaced through the `onError` callback.
1056
- *
1057
- * Existing categories cover client-side failures. `scale.*` codes cover
1058
- * server-mode (Updog Scale) failures. `license.*` codes cover license
1059
- * validation failures (previously a separate `LicenseErrorCode` enum).
1017
+ * `license.*` codes cover license validation failures (previously a separate
1018
+ * `LicenseErrorCode` enum).
1060
1019
  */
1061
- 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" | "scale.bootstrap_failed" | "scale.workspace_lost" | "scale.unreachable" | "scale.server_error";
1020
+ 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";
1062
1021
  /**
1063
1022
  * An internal error caught by the SDK and passed to `onError`. The SDK
1064
1023
  * recovers gracefully where possible — `onError` is for your logging and
@@ -1084,10 +1043,6 @@ type UpdogError = {
1084
1043
  originalError?: unknown;
1085
1044
  };
1086
1045
 
1087
- type ScaleServerConfig = {
1088
- url: string;
1089
- };
1090
-
1091
1046
  /**
1092
1047
  * A single row in the submit result, with orthogonal flags describing its state.
1093
1048
  *
@@ -1564,11 +1519,6 @@ type DataEditorMode = "modal" | "inline";
1564
1519
  type DataEditorCommonProps<TRow extends DataEditorRow = DataEditorRow> = DataEditorBaseProps<TRow> & {
1565
1520
  /** Your Updog license key. Validated on each open. */
1566
1521
  apiKey: string;
1567
- /**
1568
- * @internal
1569
- * Reserved for future server-delegated mode. Not part of the public API.
1570
- */
1571
- __server?: ScaleServerConfig;
1572
1522
  /**
1573
1523
  * Controls what the editor stores in `localStorage`. Set to `false` to
1574
1524
  * disable all local storage usage.