@updog/data-editor-wc 0.1.82 → 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.
Files changed (4) hide show
  1. package/README.md +5 -6
  2. package/index.d.ts +14 -20
  3. package/index.js +4906 -4803
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -258,7 +258,7 @@ editor.columns = [
258
258
  ];
259
259
  ```
260
260
 
261
- **Cell editors**: `{ type: "text" }` (default), `{ type: "date", minDate?, maxDate? }`, `{ type: "select", options: string[] }`, `{ type: "number", decimalPlaces?, decimalSeparator?, thousandsSeparator?, allowChars? }`.
261
+ **Cell editors**: `{ type: "text" }` (default), `{ type: "date" }`, `{ type: "select", options: string[] }`, `{ type: "number", decimalSeparator?, thousandsSeparator? }`.
262
262
 
263
263
  **Column filters**: `{ type: "select", label?, placeholder?, options?, multiple? }`, `{ type: "number-range", label? }`, `{ type: "date-range", label? }`.
264
264
 
@@ -270,11 +270,10 @@ Validators are declarative objects passed in the `validators` array on each colu
270
270
  |---|---|---|
271
271
  | `"required"` | `message?` | Value must be non-empty. |
272
272
  | `"email"` | `message?` | Value must look like an email address. |
273
- | `"numeric"` | `message?` | Value must parse as a number. Commas are stripped before parsing. |
274
273
  | `"regex"` | `pattern`, `flags?`, `message?` | Value must match the regular expression. Empty values are skipped. |
275
- | `"range"` | `min?`, `max?`, `message?` | Value must be numerically within `[min, max]`. Either bound is optional. |
274
+ | `"number"` | `min?`, `max?`, `decimalPlaces?`, `message?` | Value must be the canonical form — plain digits, a dot for decimals, no grouping, no leading zeros. `min` and `max` are inclusive; `decimalPlaces` caps the decimal digits (`0` means integers) and flags rather than rounds. `min` and `decimalPlaces` also configure the column's number editor. |
276
275
  | `"oneOf"` | `values: string[]`, `message?` | Value must be one of the listed strings. |
277
- | `"date"` | `format?: "YYYY-MM-DD" \| "DD/MM/YYYY"`, `message?` | Value must parse as a date in the given format. When `format` is omitted, either format is accepted. |
276
+ | `"date"` | `min?`, `max?`, `message?` | Value must be an ISO `YYYY-MM-DD` date that exists in the calendar. `min` and `max` are inclusive ISO bounds, and they also set the range the cell's date picker offers. |
278
277
  | `"unique"` | `message?` | Value must not appear in any other row of the column. Always checked last, after all other validators pass — list position is ignored. |
279
278
 
280
279
  ```js
@@ -288,7 +287,7 @@ editor.columns = [
288
287
  { type: "email", message: "Invalid email" },
289
288
  ],
290
289
  },
291
- { id: "salary", title: "Salary", validators: [{ type: "numeric", message: "Must be a number" }] },
290
+ { id: "salary", title: "Salary", validators: [{ type: "number", min: 0, decimalPlaces: 2 }] },
292
291
  {
293
292
  id: "status",
294
293
  title: "Status",
@@ -297,7 +296,7 @@ editor.columns = [
297
296
  {
298
297
  id: "startDate",
299
298
  title: "Start",
300
- validators: [{ type: "date", format: "YYYY-MM-DD", message: "Use YYYY-MM-DD" }],
299
+ validators: [{ type: "date", message: "Use a valid date" }],
301
300
  editor: { type: "date" },
302
301
  dependentFields: ["endDate"],
303
302
  },
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: {
@@ -657,13 +658,9 @@ type CellValidator = (value: unknown, row: DataEditorRow) => ValidationError | n
657
658
  type TextEditorCell = {
658
659
  type: "text";
659
660
  };
660
- /** Date picker cell. Optionally restrict the selectable date range. */
661
+ /** Date picker cell. Bounds come from the column's `{ type: "date" }` validator. */
661
662
  type DateEditorCell = {
662
663
  type: "date";
663
- /** Earliest selectable date. */
664
- minDate?: Date;
665
- /** Latest selectable date. */
666
- maxDate?: Date;
667
664
  };
668
665
  /** Dropdown select cell. The user picks from a fixed list of options. */
669
666
  type SelectEditorCell = {
@@ -686,23 +683,19 @@ type MultiSelectEditorCell = {
686
683
  /** Splits a raw imported cell and joins on export. Omitted: import auto-detects, export joins with `", "`. */
687
684
  delimiter?: string;
688
685
  };
689
- /** 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. */
690
687
  type NumberEditorCell = {
691
688
  type: "number";
692
- /** Maximum number of decimal digits allowed. When omitted, decimals are unrestricted. */
693
- decimalPlaces?: number;
694
689
  /** Character used as the decimal point (e.g. `"."` or `","`). Defaults to the browser locale. */
695
690
  decimalSeparator?: string;
696
691
  /** Character inserted between groups of three digits (e.g. `","` or `"."`). Defaults to the browser locale. */
697
692
  thousandsSeparator?: string;
698
- /** Extra characters to allow beyond digits, decimal separator, and minus sign (e.g. `"%-"`). When defined, minus is only kept if explicitly included. */
699
- allowChars?: string;
700
693
  };
701
694
  /**
702
695
  * Controls how a cell is edited.
703
696
  *
704
697
  * - `"text"` — plain text input (default).
705
- * - `"date"` — date picker with optional min/max bounds.
698
+ * - `"date"` — date picker; the calendar honours the column's date validator bounds.
706
699
  * - `"select"` — dropdown with a fixed list of options.
707
700
  * - `"multiselect"` — dropdown allowing zero or more options; stored as `string[]`.
708
701
  * - `"number"` — number input with locale-aware formatting.
@@ -751,7 +744,7 @@ type ColumnLockMode = "all" | "default";
751
744
  * { id: "name", title: "Full Name", size: 200, validators: [{ type: "required", message: "Name is required" }] },
752
745
  * { id: "email", title: "Email", size: 250, validators: [{ type: "required", message: "Email is required" }, { type: "email", message: "Invalid email" }, { type: "unique" }] },
753
746
  * { id: "role", title: "Role", editor: { type: "select", options: ["Admin", "Editor", "Viewer"] } },
754
- * { 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}` : "" },
755
748
  * ];
756
749
  * ```
757
750
  */
@@ -762,7 +755,7 @@ type DataEditorColumn = {
762
755
  title: string;
763
756
  /**
764
757
  * One or more validators run on every edit. Accepts:
765
- * - Built-in object literals: `{ type: "required" | "email" | "regex" | "range" | "oneOf" | "date" | "numeric" | "unique", ... }`.
758
+ * - Built-in object literals: `{ type: "required" | "email" | "regex" | "number" | "oneOf" | "date" | "unique", ... }`.
766
759
  * - `{ type: "function", fn }` — a JS predicate run inline.
767
760
  * - `{ type: "asyncFunction", fn }` — batched remote checks.
768
761
  */
@@ -802,8 +795,7 @@ type DataEditorColumn = {
802
795
  };
803
796
 
804
797
  /**
805
- * A built-in declarative validator — a declarative object the SDK interprets,
806
- * per `api/validators.json`.
798
+ * A built-in declarative validator — a declarative object the SDK interprets.
807
799
  */
808
800
  type BuiltInValidator = {
809
801
  type: "required";
@@ -818,19 +810,21 @@ type BuiltInValidator = {
818
810
  values: string[];
819
811
  message?: string;
820
812
  } | {
821
- type: "range";
813
+ type: "number";
814
+ /** Inclusive lower bound. */
822
815
  min?: number;
816
+ /** Inclusive upper bound. */
823
817
  max?: number;
818
+ /** Maximum decimal digits; `0` means integers. Values with more are flagged, never rounded. */
819
+ decimalPlaces?: number;
824
820
  message?: string;
825
821
  } | {
826
822
  type: "email";
827
823
  message?: string;
828
824
  } | {
829
825
  type: "date";
830
- format?: "YYYY-MM-DD" | "DD/MM/YYYY";
831
- message?: string;
832
- } | {
833
- type: "numeric";
826
+ min?: string;
827
+ max?: string;
834
828
  message?: string;
835
829
  } | {
836
830
  type: "unique";