@orangelogic/design-system 2.130.0 → 2.132.0
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/library/assets/validation.worker-Dc_pkZlD.js +1 -0
- package/library/chunks/{color-swatch-group.DPaKBfvX.js → color-swatch-group.Cy-M_lbx.js} +1 -1
- package/library/chunks/{document-viewer.Dn_vUYCW.js → document-viewer.CzGnnA_9.js} +2 -2
- package/library/chunks/{folder-select.DMpO7oQF.js → folder-select.CHzRsSGM.js} +45 -45
- package/library/chunks/image.BzmclWBR.js +150 -0
- package/library/chunks/{image.BC_hwk-b.js → image.DAtx64Jj.js} +1 -1
- package/library/chunks/{list-editor.DfOsqO4y.js → list-editor.CwCdVzMl.js} +2 -2
- package/library/chunks/{resizable-component.styles.BVhOesNE.js → resizable-component.styles.B5N-oYx6.js} +1 -1
- package/library/chunks/{table.Cf3C72Lv.js → table.C6YsaNOh.js} +2460 -2081
- package/library/components/asset-link-format.js +1 -1
- package/library/components/atoms.js +3 -3
- package/library/components/audio.js +1 -1
- package/library/components/color-swatch-group.js +2 -2
- package/library/components/cropper.js +1 -1
- package/library/components/document-viewer.js +3 -3
- package/library/components/folder-select.js +1 -1
- package/library/components/image.js +2 -2
- package/library/components/list-editor.js +2 -2
- package/library/components/masonry.js +1 -1
- package/library/components/molecules.js +2 -2
- package/library/components/organisms.js +1 -1
- package/library/components/table.js +52 -50
- package/library/components/types.js +10 -10
- package/library/components/video.js +2 -2
- package/library/package.json +1 -1
- package/library/packages/atoms/src/components/table/table.d.ts +43 -0
- package/library/packages/events/src/cx-table-validation-change.d.ts +8 -0
- package/library/packages/events/src/events.d.ts +7 -6
- package/library/packages/hybrid/table-core/src/tabulator-tables/index.d.ts +1 -0
- package/library/packages/hybrid/table-core/src/tabulator-tables/modules/Validate/Validate.d.ts +81 -13
- package/library/packages/hybrid/table-core/src/tabulator-tables/modules/Validate/defaults/rule-functions.d.ts +20 -0
- package/library/packages/hybrid/table-core/src/tabulator-tables/modules/Validate/defaults/validators.d.ts +9 -18
- package/library/packages/hybrid/table-core/src/tabulator-tables/modules/Validate/validation-worker-client.d.ts +13 -0
- package/library/packages/types/src/table.d.ts +55 -1
- package/library/react-web-component.d.ts +11 -3
- package/library/utils.js +1 -1
- package/package.json +1 -1
- package/library/chunks/image.9qwbjGNb.js +0 -150
package/library/packages/hybrid/table-core/src/tabulator-tables/modules/Validate/Validate.d.ts
CHANGED
|
@@ -1,36 +1,104 @@
|
|
|
1
|
+
import { CellValidationFailure, ICellComponent, StandardValidatorType, ValidationSummary, Validator } from '../../../../../../types/src/table';
|
|
1
2
|
import { default as Cell } from '../../core/cell/Cell';
|
|
2
3
|
import { default as Column } from '../../core/column/Column';
|
|
3
4
|
import { default as Module } from '../../core/Module';
|
|
4
5
|
import { default as Row } from '../../core/row/Row';
|
|
5
6
|
import { default as Tabulator } from '../../core/Tabulator';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Attribute carrying the joined failure messages of an invalid cell.
|
|
10
|
+
* Consumers (e.g. cx-table) read it to display a tooltip — a data attribute
|
|
11
|
+
* instead of `title` so the native browser tooltip does not compete with it.
|
|
12
|
+
*/
|
|
13
|
+
export declare const VALIDATION_MESSAGE_ATTRIBUTE = "data-validation-message";
|
|
14
|
+
type ValidatorFunction = (cell: ICellComponent, value: unknown, parameters?: unknown) => boolean;
|
|
8
15
|
type ValidatorConfig = {
|
|
9
16
|
func: ValidatorFunction;
|
|
10
|
-
|
|
17
|
+
message?: string;
|
|
18
|
+
params: unknown;
|
|
11
19
|
type: string;
|
|
12
20
|
};
|
|
13
21
|
export default class Validate extends Module {
|
|
14
22
|
static readonly moduleName = "validate";
|
|
15
23
|
static readonly validators: Record<string, ValidatorFunction>;
|
|
16
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Validation results keyed by row → column. Virtual renderers delete and
|
|
26
|
+
* recreate Cell objects as rows scroll in and out of the render window,
|
|
27
|
+
* while Row and Column objects persist — so keying by row/column keeps
|
|
28
|
+
* invalid state (and counts) stable across scrolling. Cells without a
|
|
29
|
+
* row/column (detached mocks) key by the cell itself.
|
|
30
|
+
*/
|
|
31
|
+
private readonly invalidState;
|
|
32
|
+
get invalidCells(): Cell[];
|
|
33
|
+
set invalidCells(cells: Cell[]);
|
|
34
|
+
/**
|
|
35
|
+
* Bumped whenever data is replaced or a new table-wide validation starts, so
|
|
36
|
+
* results of superseded async validations are discarded instead of applied.
|
|
37
|
+
*/
|
|
38
|
+
private validationGeneration;
|
|
39
|
+
/** Batch operations set this to emit one validationChanged instead of one per cell. */
|
|
40
|
+
private suppressValidationChanged;
|
|
17
41
|
constructor(table: Tabulator);
|
|
18
42
|
initialize(): void;
|
|
19
|
-
editValidate(cell: Cell, value:
|
|
43
|
+
editValidate(cell: Cell, value: unknown, _previousValue: unknown): boolean | CellValidationFailure[];
|
|
20
44
|
editorClear(cell: Cell, cancelled: boolean): void;
|
|
21
45
|
editedClear(cell: Cell): void;
|
|
46
|
+
/**
|
|
47
|
+
* A deleted cell must NOT drop its validation state: virtual renderers
|
|
48
|
+
* delete and recreate Cell objects as rows scroll in and out of the render
|
|
49
|
+
* window, and the row-keyed record is restored by layoutCell when the cell
|
|
50
|
+
* is rebuilt. True removals are handled by rowDeleted/columnDeleted.
|
|
51
|
+
*/
|
|
52
|
+
cellDeleted(cell: Cell): void;
|
|
53
|
+
rowDeleted(row: Row): void;
|
|
54
|
+
columnDeleted(column: Column): void;
|
|
55
|
+
/**
|
|
56
|
+
* Cells are recycled by the virtual renderers, so persisted validation state
|
|
57
|
+
* must be restored onto the freshly built cell whenever its DOM is (re)built.
|
|
58
|
+
*/
|
|
59
|
+
layoutCell(cell: Cell): void;
|
|
60
|
+
dataProcessed(): void;
|
|
22
61
|
cellIsValid(cell: Cell): boolean;
|
|
23
|
-
cellValidate(cell: Cell):
|
|
24
|
-
columnValidate(column: Column):
|
|
25
|
-
rowValidate(row: Row):
|
|
26
|
-
userClearCellValidation(cells?:
|
|
27
|
-
userValidate(_cells?:
|
|
62
|
+
cellValidate(cell: Cell): CellValidationFailure[] | boolean;
|
|
63
|
+
columnValidate(column: Column): ICellComponent[] | boolean;
|
|
64
|
+
rowValidate(row: Row): ICellComponent[] | boolean;
|
|
65
|
+
userClearCellValidation(cells?: ICellComponent | ICellComponent[]): void;
|
|
66
|
+
userValidate(_cells?: unknown): ICellComponent[] | boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Validates the whole dataset without blocking the main thread on large
|
|
69
|
+
* tables: below `validationWorkerThreshold` rows it runs synchronously,
|
|
70
|
+
* above it JSON rules are offloaded to a shared Web Worker (columns with
|
|
71
|
+
* function validators stay on the main thread, processed in yielding
|
|
72
|
+
* chunks). Superseded runs (new validation or data reload) are discarded.
|
|
73
|
+
*/
|
|
74
|
+
validateAsync(): Promise<ValidationSummary>;
|
|
75
|
+
getValidationSummary(): ValidationSummary;
|
|
28
76
|
initializeColumnCheck(column: Column): void;
|
|
29
77
|
initializeColumn(column: Column): void;
|
|
30
|
-
_extractValidator(value:
|
|
31
|
-
_buildValidator(type: string | ValidatorFunction, params?:
|
|
32
|
-
validate(validators: ValidatorConfig[] | false | undefined, cell: Cell, value:
|
|
33
|
-
getInvalidCells():
|
|
78
|
+
_extractValidator(value: StandardValidatorType | Validator | ValidatorFunction | string): ValidatorConfig | false;
|
|
79
|
+
_buildValidator(type: string | ValidatorFunction, params?: unknown, message?: string): ValidatorConfig | false;
|
|
80
|
+
validate(validators: ValidatorConfig[] | false | undefined, cell: Cell, value: unknown): CellValidationFailure[] | boolean;
|
|
81
|
+
getInvalidCells(): ICellComponent[];
|
|
34
82
|
clearValidation(cell: Cell): void;
|
|
83
|
+
private rowKeyOf;
|
|
84
|
+
private columnKeyOf;
|
|
85
|
+
private getInvalidRecord;
|
|
86
|
+
private registerInvalidCell;
|
|
87
|
+
private unregisterInvalidCell;
|
|
88
|
+
private countInvalidCells;
|
|
89
|
+
private getValidatedColumns;
|
|
90
|
+
private validateColumnsOnWorker;
|
|
91
|
+
private applyWorkerResults;
|
|
92
|
+
private applyBatchFailures;
|
|
93
|
+
/**
|
|
94
|
+
* Columns with function validators cannot run in the worker; validate them
|
|
95
|
+
* on the main thread in chunks, yielding between chunks to keep the UI
|
|
96
|
+
* responsive.
|
|
97
|
+
*/
|
|
98
|
+
private validateColumnsOnMainThread;
|
|
99
|
+
private applyCellInvalidState;
|
|
100
|
+
private clearCellInvalidState;
|
|
101
|
+
private runSuppressed;
|
|
102
|
+
private dispatchValidationChanged;
|
|
35
103
|
}
|
|
36
104
|
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure validation rule functions shared by the main-thread Validate module and
|
|
3
|
+
* the validation Web Worker.
|
|
4
|
+
*
|
|
5
|
+
* Every function is side-effect free and depends only on its arguments — no
|
|
6
|
+
* cell, DOM, or table access — so the same code can run inside a worker where
|
|
7
|
+
* only JSON-serializable data is available. Cell/table-dependent inputs (e.g.
|
|
8
|
+
* the column values needed by `unique`) are passed in through `RuleContext`.
|
|
9
|
+
*
|
|
10
|
+
* Semantics preserved from the original validators: an empty value
|
|
11
|
+
* (`''`, `null`, `undefined`) passes every rule except `required`.
|
|
12
|
+
*/
|
|
13
|
+
/** Extra inputs a rule may need that are not part of the cell value itself. */
|
|
14
|
+
export interface RuleContext {
|
|
15
|
+
/** All values of the cell's column (used by `unique`), excluding the cell's own row. */
|
|
16
|
+
columnValues?: unknown[];
|
|
17
|
+
}
|
|
18
|
+
export type RuleFunction = (value: unknown, parameters?: any, context?: RuleContext) => boolean;
|
|
19
|
+
declare const ruleFunctions: Record<string, RuleFunction>;
|
|
20
|
+
export default ruleFunctions;
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
minLength: (_cell: any, value: any, parameters: any) => boolean;
|
|
11
|
-
numeric: (_cell: any, value: any, _parameters: any) => boolean;
|
|
12
|
-
regex: (_cell: any, value: any, parameters: any) => boolean;
|
|
13
|
-
required: (_cell: any, value: any, _parameters: any) => boolean;
|
|
14
|
-
starts: (_cell: any, value: any, parameters: any) => boolean;
|
|
15
|
-
string: (_cell: any, value: any, _parameters: any) => boolean;
|
|
16
|
-
unique: (this: any, cell: any, value: any, _parameters: any) => boolean;
|
|
17
|
-
};
|
|
18
|
-
export default _default;
|
|
1
|
+
import { ICellComponent } from '../../../../../../../types/src/table';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Cell-facing validator signature expected by the Validate module and custom
|
|
5
|
+
* consumer validators. Mirrors `ValidatorFunction` in `Validate.ts`.
|
|
6
|
+
*/
|
|
7
|
+
export type CellValidator = (cell: ICellComponent, value: unknown, parameters?: unknown) => boolean;
|
|
8
|
+
declare const validators: Record<string, CellValidator>;
|
|
9
|
+
export default validators;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ValidationWorkerFailureEntry, ValidationWorkerField } from './validation.worker';
|
|
2
|
+
|
|
3
|
+
export type { ValidationWorkerFailureEntry, ValidationWorkerField };
|
|
4
|
+
/**
|
|
5
|
+
* Validates pre-extracted column values against JSON rules on the shared
|
|
6
|
+
* validation worker.
|
|
7
|
+
*
|
|
8
|
+
* Resolves with every failure entry once the worker finishes; `onChunk` fires
|
|
9
|
+
* per processed row chunk for progressive application. Rejects if the worker
|
|
10
|
+
* crashes or cannot start — callers should fall back to synchronous
|
|
11
|
+
* validation.
|
|
12
|
+
*/
|
|
13
|
+
export declare function validateBatch(fields: ValidationWorkerField[], onChunk?: (results: ValidationWorkerFailureEntry[]) => void): Promise<ValidationWorkerFailureEntry[]>;
|
|
@@ -928,6 +928,11 @@ export interface ITabulatorFull extends ITabulator {
|
|
|
928
928
|
createFilterFieldFunction: IFilter['createFilterFieldFunction'];
|
|
929
929
|
clearFilter: IFilter['clearFilter'];
|
|
930
930
|
setSort: (sortList: string | Sorter[], dir?: SortDirection) => void;
|
|
931
|
+
validate: () => true | ICellComponent[];
|
|
932
|
+
validateAsync: () => Promise<ValidationSummary>;
|
|
933
|
+
getValidationSummary: () => ValidationSummary;
|
|
934
|
+
getInvalidCells: () => ICellComponent[];
|
|
935
|
+
clearCellValidation: (cells?: ICellComponent | ICellComponent[]) => void;
|
|
931
936
|
}
|
|
932
937
|
/**
|
|
933
938
|
* Table type
|
|
@@ -1769,6 +1774,19 @@ export interface OptionsGeneral {
|
|
|
1769
1774
|
* manual - no validation is automatically performed on edit, but it can be triggered by calling the validate function on the table or any Component Object
|
|
1770
1775
|
*/
|
|
1771
1776
|
validationMode?: 'blocking' | 'highlight' | 'manual';
|
|
1777
|
+
/**
|
|
1778
|
+
* When true, the whole dataset is validated automatically each time data is
|
|
1779
|
+
* loaded or replaced (`data-processed`). Defaults to false for backward
|
|
1780
|
+
* compatibility.
|
|
1781
|
+
*/
|
|
1782
|
+
validateOnLoad?: boolean;
|
|
1783
|
+
/**
|
|
1784
|
+
* Row-count threshold above which table-wide validation passes
|
|
1785
|
+
* (`validateAsync` / `validateOnLoad`) are offloaded to a Web Worker instead
|
|
1786
|
+
* of running synchronously on the main thread. Set to `false` to always
|
|
1787
|
+
* validate synchronously. Defaults to 2000.
|
|
1788
|
+
*/
|
|
1789
|
+
validationWorkerThreshold?: number | false;
|
|
1772
1790
|
textDirection?: TextDirection;
|
|
1773
1791
|
/**
|
|
1774
1792
|
* Sometimes it can be useful to add a visual header to the start of a row.
|
|
@@ -2607,10 +2625,45 @@ export type JSONRecord = Record<string, string | number | boolean>;
|
|
|
2607
2625
|
* {title:"Example", field:"example", validator:"regex:\\.com$"} \\allow strings that end in '.com'
|
|
2608
2626
|
* ```
|
|
2609
2627
|
*/
|
|
2610
|
-
export type StandardValidatorType = 'required' | 'unique' | 'integer' | 'float' | 'numeric' | 'string' | 'alphanumeric';
|
|
2628
|
+
export type StandardValidatorType = 'required' | 'unique' | 'integer' | 'float' | 'numeric' | 'string' | 'alphanumeric' | 'boolean' | 'date' | 'in' | 'regex';
|
|
2629
|
+
/** Range constraints accepted by the numeric-type validators (`numeric`, `integer`, `float`). */
|
|
2630
|
+
export interface NumericValidatorParameters {
|
|
2631
|
+
min?: number;
|
|
2632
|
+
max?: number;
|
|
2633
|
+
}
|
|
2634
|
+
/** Length constraints accepted by the `string` validator. */
|
|
2635
|
+
export interface StringValidatorParameters {
|
|
2636
|
+
minLength?: number;
|
|
2637
|
+
maxLength?: number;
|
|
2638
|
+
}
|
|
2639
|
+
/**
|
|
2640
|
+
* Range constraints accepted by the `date` validator. `starts` / `ends` are
|
|
2641
|
+
* inclusive bounds as ISO date strings (or anything `Date.parse` understands).
|
|
2642
|
+
*/
|
|
2643
|
+
export interface DateValidatorParameters {
|
|
2644
|
+
starts?: string;
|
|
2645
|
+
ends?: string;
|
|
2646
|
+
}
|
|
2611
2647
|
export interface Validator {
|
|
2612
2648
|
type: StandardValidatorType | ((cell: ICellComponent, value: any, parameters?: any) => boolean);
|
|
2613
2649
|
parameters?: any;
|
|
2650
|
+
/**
|
|
2651
|
+
* Optional human-readable error message attached to validation failures for
|
|
2652
|
+
* this rule. Propagated to cell validation state, the cell `title` tooltip,
|
|
2653
|
+
* and validation events. JSON-serializable.
|
|
2654
|
+
*/
|
|
2655
|
+
message?: string;
|
|
2656
|
+
}
|
|
2657
|
+
/** A single failed validation rule on a cell. */
|
|
2658
|
+
export interface CellValidationFailure {
|
|
2659
|
+
type: string;
|
|
2660
|
+
parameters?: any;
|
|
2661
|
+
message?: string;
|
|
2662
|
+
}
|
|
2663
|
+
/** Aggregate result of a table-wide validation pass. */
|
|
2664
|
+
export interface ValidationSummary {
|
|
2665
|
+
invalidCellCount: number;
|
|
2666
|
+
invalidCells: ICellComponent[];
|
|
2614
2667
|
}
|
|
2615
2668
|
export type ColumnSorterParamLookupFunction = (column: IColumnComponent, dir: SortDirection) => Record<string, unknown>;
|
|
2616
2669
|
export type ColumnLookup = IColumn | IColumnComponent | ColumnDefinition | HTMLElement | string;
|
|
@@ -2815,6 +2868,7 @@ export interface RangeComponent {
|
|
|
2815
2868
|
}
|
|
2816
2869
|
export interface EventCallBackMethods {
|
|
2817
2870
|
validationFailed: (cell: ICellComponent, value: any, validators: Validator[]) => void;
|
|
2871
|
+
validationChanged: (summary: ValidationSummary) => void;
|
|
2818
2872
|
scrollHorizontal: (left: number, leftDir: boolean) => void;
|
|
2819
2873
|
scrollVertical: (top: number, topDir: boolean) => void;
|
|
2820
2874
|
rowAdded: (row: IRowComponent) => void;
|