@orangelogic/design-system 2.130.0 → 2.131.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.
Files changed (23) hide show
  1. package/library/assets/validation.worker-Dc_pkZlD.js +1 -0
  2. package/library/chunks/{color-swatch-group.DPaKBfvX.js → color-swatch-group.Cy-M_lbx.js} +1 -1
  3. package/library/chunks/{list-editor.DfOsqO4y.js → list-editor.CdMU7vNF.js} +1 -1
  4. package/library/chunks/{table.Cf3C72Lv.js → table.C6YsaNOh.js} +2460 -2081
  5. package/library/components/atoms.js +1 -1
  6. package/library/components/color-swatch-group.js +2 -2
  7. package/library/components/list-editor.js +2 -2
  8. package/library/components/molecules.js +1 -1
  9. package/library/components/organisms.js +1 -1
  10. package/library/components/table.js +52 -50
  11. package/library/components/types.js +4 -4
  12. package/library/package.json +1 -1
  13. package/library/packages/atoms/src/components/table/table.d.ts +43 -0
  14. package/library/packages/events/src/cx-table-validation-change.d.ts +8 -0
  15. package/library/packages/events/src/events.d.ts +7 -6
  16. package/library/packages/hybrid/table-core/src/tabulator-tables/index.d.ts +1 -0
  17. package/library/packages/hybrid/table-core/src/tabulator-tables/modules/Validate/Validate.d.ts +81 -13
  18. package/library/packages/hybrid/table-core/src/tabulator-tables/modules/Validate/defaults/rule-functions.d.ts +20 -0
  19. package/library/packages/hybrid/table-core/src/tabulator-tables/modules/Validate/defaults/validators.d.ts +9 -18
  20. package/library/packages/hybrid/table-core/src/tabulator-tables/modules/Validate/validation-worker-client.d.ts +13 -0
  21. package/library/packages/types/src/table.d.ts +55 -1
  22. package/library/react-web-component.d.ts +11 -3
  23. package/package.json +1 -1
@@ -75,7 +75,7 @@ import { default as Xo } from "./stepper.js";
75
75
  import { default as Zo } from "./switch.js";
76
76
  import { default as et } from "./tab.js";
77
77
  import { C as tt } from "../chunks/tab-group.GA4X3LL2.js";
78
- import { C as rt } from "../chunks/table.Cf3C72Lv.js";
78
+ import { C as rt } from "../chunks/table.C6YsaNOh.js";
79
79
  import { default as ft } from "./tab-panel.js";
80
80
  import { default as st } from "./tag.js";
81
81
  import { default as Ct } from "./textarea.js";
@@ -1,10 +1,10 @@
1
1
  import "./space.js";
2
- import "../chunks/table.Cf3C72Lv.js";
2
+ import "../chunks/table.C6YsaNOh.js";
3
3
  import "../chunks/typography.DJC_UXgs.js";
4
4
  import "../chunks/lib-cortex-element.CVMmyPMC.js";
5
5
  import "../chunks/color-swatch.U-wztpLf.js";
6
6
  import "../chunks/component.styles.CRO4Odto.js";
7
- import { C as w } from "../chunks/color-swatch-group.DPaKBfvX.js";
7
+ import { C as w } from "../chunks/color-swatch-group.Cy-M_lbx.js";
8
8
  import "../chunks/content-builder.BGzxZUgi.js";
9
9
  import "../chunks/custom-element.L4WJXn1j.js";
10
10
  import "../chunks/debounce.DaHuiSGU.js";
@@ -9,7 +9,7 @@ import "./radio.js";
9
9
  import "./radio-group.js";
10
10
  import "./select.js";
11
11
  import "./space.js";
12
- import "../chunks/table.Cf3C72Lv.js";
12
+ import "../chunks/table.C6YsaNOh.js";
13
13
  import "../chunks/typography.DJC_UXgs.js";
14
14
  import "../chunks/lib-cortex-element.CVMmyPMC.js";
15
15
  import "./dynamic-select.js";
@@ -18,7 +18,7 @@ import "../chunks/custom-element.L4WJXn1j.js";
18
18
  import "../chunks/debounce.DaHuiSGU.js";
19
19
  import "../chunks/i18n.NAH4U8Lw.js";
20
20
  import "../chunks/watch.CThbualB.js";
21
- import { c as E, C as F } from "../chunks/list-editor.DfOsqO4y.js";
21
+ import { c as E, C as F } from "../chunks/list-editor.CdMU7vNF.js";
22
22
  import "../chunks/lit-element.jLBm65_O.js";
23
23
  import "../chunks/state.CSDxrqLd.js";
24
24
  import "../chunks/query.BBf1UFkC.js";
@@ -6,7 +6,7 @@ import { default as s } from "./corner-position-input-group.js";
6
6
  import { default as m } from "./cropper.js";
7
7
  import { default as i } from "./dynamic-select.js";
8
8
  import { C as c } from "../chunks/folder-select.DMpO7oQF.js";
9
- import { C as P } from "../chunks/list-editor.DfOsqO4y.js";
9
+ import { C as P } from "../chunks/list-editor.CdMU7vNF.js";
10
10
  import { default as I } from "./masonry.js";
11
11
  import { default as y } from "./padding-input-group.js";
12
12
  import { default as w } from "./position-picker.js";
@@ -1,5 +1,5 @@
1
1
  import { default as a } from "./asset-link-format.js";
2
- import { C as t } from "../chunks/color-swatch-group.DPaKBfvX.js";
2
+ import { C as t } from "../chunks/color-swatch-group.Cy-M_lbx.js";
3
3
  import { C } from "../chunks/file-on-demand.Dr05DdkU.js";
4
4
  export {
5
5
  a as CxAssetLinkFormat,
@@ -6,10 +6,11 @@ import "../chunks/icon-button.COTH_z-J.js";
6
6
  import "./select.js";
7
7
  import "./space.js";
8
8
  import "./spinner.js";
9
+ import "./tooltip.js";
9
10
  import "../chunks/lib-cortex-element.CVMmyPMC.js";
10
11
  import "../chunks/component.styles.CRO4Odto.js";
11
12
  import "../chunks/overlayscrollbars.BMav4RQ4.js";
12
- import { A as z, l as P, m as g, d as y, h as A, b as S, j as D, n as I, o as f, c as h, a3 as E, a4 as G, a5 as H, D as j, p as k, E as K, q as L, F as V, r as q, s as B, t as J, G as N, u as O, v as Q, k as U, w as W, I as X, x as Y, K as Z, y as _, M as $, z as oo, B as eo, J as ao, L as so, N as lo, O as to, Q as uo, P as ro, e as Mo, U as io, i as po, V as mo, W as no, X as Co, Y as Ro, g as co, R as bo, _ as wo, Z as To, f as xo, $ as Fo, a0 as vo, T as zo, a as Po, a1 as go, a2 as yo, C as Ao } from "../chunks/table.Cf3C72Lv.js";
13
+ import { A as S, l as v, m as z, d as E, h as P, b as g, j as y, n as D, o as G, c as f, a4 as h, a5 as H, a6 as L, D as V, p as _, E as j, q as k, F as B, r as K, s as N, t as O, G as U, u as q, v as J, k as Q, w as W, I as X, x as Y, K as Z, y as $, M as oo, z as eo, B as ao, J as so, L as lo, N as to, O as uo, Q as ro, P as Mo, e as io, U as po, i as mo, W as no, X as Co, Y as Ro, Z as To, g as co, R as bo, $ as wo, _ as Ao, f as xo, a0 as Fo, a1 as Io, T as So, a as vo, a2 as zo, V as Eo, a3 as Po, C as go } from "../chunks/table.C6YsaNOh.js";
13
14
  import "../chunks/pagination.tSkuYrqk.js";
14
15
  import "../chunks/custom-element.L4WJXn1j.js";
15
16
  import "../chunks/i18n.NAH4U8Lw.js";
@@ -21,62 +22,63 @@ import "../chunks/class-map.BiVq-cVR.js";
21
22
  import "../chunks/if-defined.BRoBj_Rp.js";
22
23
  import "../chunks/when.Dr1es41R.js";
23
24
  export {
24
- z as AccessibilityModule,
25
- P as AccessorModule,
26
- g as AjaxModule,
27
- y as CalcComponent,
28
- A as Cell,
29
- S as CellComponent,
30
- D as ClickableCellModule,
31
- I as ClipboardModule,
32
- f as ColumnCalcsModule,
33
- h as ColumnComponent,
34
- E as CxTableFooter,
35
- G as CxTableRowActions,
36
- H as CxTableToolbar,
37
- j as DataTreeModule,
38
- k as DownloadModule,
39
- K as EditModule,
40
- L as ExportModule,
41
- V as FilterModule,
42
- q as FormatModule,
43
- B as FrozenColumnsModule,
44
- J as FrozenRowsModule,
45
- N as GroupComponent,
46
- O as GroupRowsModule,
47
- Q as HistoryModule,
48
- U as HoverMenuModule,
25
+ S as AccessibilityModule,
26
+ v as AccessorModule,
27
+ z as AjaxModule,
28
+ E as CalcComponent,
29
+ P as Cell,
30
+ g as CellComponent,
31
+ y as ClickableCellModule,
32
+ D as ClipboardModule,
33
+ G as ColumnCalcsModule,
34
+ f as ColumnComponent,
35
+ h as CxTableFooter,
36
+ H as CxTableRowActions,
37
+ L as CxTableToolbar,
38
+ V as DataTreeModule,
39
+ _ as DownloadModule,
40
+ j as EditModule,
41
+ k as ExportModule,
42
+ B as FilterModule,
43
+ K as FormatModule,
44
+ N as FrozenColumnsModule,
45
+ O as FrozenRowsModule,
46
+ U as GroupComponent,
47
+ q as GroupRowsModule,
48
+ J as HistoryModule,
49
+ Q as HoverMenuModule,
49
50
  W as HtmlTableImportModule,
50
51
  X as ImportModule,
51
52
  Y as InteractionModule,
52
53
  Z as KeybindingsModule,
53
- _ as MenuModule,
54
- $ as Module,
55
- oo as MoveColumnsModule,
56
- eo as MoveRowsModule,
57
- ao as MutatorModule,
58
- so as PageModule,
59
- lo as PersistenceModule,
60
- to as PopupModule,
61
- uo as PrintModule,
62
- ro as PseudoRow,
63
- Mo as RangeComponent,
64
- io as ReactiveDataModule,
65
- po as Renderer,
66
- mo as ResizeColumnsModule,
67
- no as ResizeRowsModule,
68
- Co as ResizeTableModule,
69
- Ro as ResponsiveLayoutModule,
54
+ $ as MenuModule,
55
+ oo as Module,
56
+ eo as MoveColumnsModule,
57
+ ao as MoveRowsModule,
58
+ so as MutatorModule,
59
+ lo as PageModule,
60
+ to as PersistenceModule,
61
+ uo as PopupModule,
62
+ ro as PrintModule,
63
+ Mo as PseudoRow,
64
+ io as RangeComponent,
65
+ po as ReactiveDataModule,
66
+ mo as Renderer,
67
+ no as ResizeColumnsModule,
68
+ Co as ResizeRowsModule,
69
+ Ro as ResizeTableModule,
70
+ To as ResponsiveLayoutModule,
70
71
  co as Row,
71
72
  bo as RowComponent,
72
73
  wo as SelectRangeModule,
73
- To as SelectRowModule,
74
+ Ao as SelectRowModule,
74
75
  xo as SheetComponent,
75
76
  Fo as SortModule,
76
- vo as SpreadsheetModule,
77
- zo as Tabulator,
78
- Po as TabulatorFull,
79
- go as TooltipModule,
80
- yo as ValidateModule,
81
- Ao as default
77
+ Io as SpreadsheetModule,
78
+ So as Tabulator,
79
+ vo as TabulatorFull,
80
+ zo as TooltipModule,
81
+ Eo as VALIDATION_MESSAGE_ATTRIBUTE,
82
+ Po as ValidateModule,
83
+ go as default
82
84
  };
@@ -76,7 +76,7 @@ import { default as UKt } from "./stepper.js";
76
76
  import gw from "./switch.js";
77
77
  import k5 from "./tab.js";
78
78
  import { C as _5, T as EB, a as AB, b as OB, g as nI } from "../chunks/tab-group.GA4X3LL2.js";
79
- import { S as CX, C as C5 } from "../chunks/table.Cf3C72Lv.js";
79
+ import { S as CX, C as C5 } from "../chunks/table.C6YsaNOh.js";
80
80
  import IB from "./tab-panel.js";
81
81
  import SX from "./tag.js";
82
82
  import DB from "./textarea.js";
@@ -120,7 +120,7 @@ import { a as S0, e as oJ, f as HB, g as aJ, h as Y1, i as X1, j as J1, k as qv,
120
120
  import { H as W_ } from "../chunks/slot.j5oheLJC.js";
121
121
  import { a as ZYt, g as QYt } from "../chunks/slot.j5oheLJC.js";
122
122
  import { c as Lr, d as lJ, H as Oi, e as ca, f as Ka, a as cJ, b as Wn } from "../chunks/resizable-component.styles.BVhOesNE.js";
123
- import { a as E5, C as VB, u as qu, I as UB } from "../chunks/list-editor.DfOsqO4y.js";
123
+ import { a as E5, C as VB, u as qu, I as UB } from "../chunks/list-editor.CdMU7vNF.js";
124
124
  import qB from "./bicolor-picker.js";
125
125
  import WB from "./border-input-group.js";
126
126
  import { C as tXt } from "../chunks/color-swatch.U-wztpLf.js";
@@ -184,8 +184,8 @@ import { c as RI, w as JJ } from "../chunks/event.BeKOsirN.js";
184
184
  import { a as GXt, p as KXt, b as YXt, s as XXt } from "../chunks/event.BeKOsirN.js";
185
185
  import { b as BI, e as ZJ } from "../chunks/number.B4PQLJIg.js";
186
186
  import { a as ZXt, c as QXt, d as eJt, f as tJt, g as iJt, r as nJt, s as rJt } from "../chunks/number.B4PQLJIg.js";
187
- import { a as y1 } from "../chunks/color-swatch-group.DPaKBfvX.js";
188
- import { C as aJt } from "../chunks/color-swatch-group.DPaKBfvX.js";
187
+ import { a as y1 } from "../chunks/color-swatch-group.Cy-M_lbx.js";
188
+ import { C as aJt } from "../chunks/color-swatch-group.Cy-M_lbx.js";
189
189
  import { t as Pc, f as Gg, i as c$, r as QJ, m as eZ, a as $I, g as FI } from "../chunks/toast.D3AW3RWv.js";
190
190
  import { e as lJt, c as cJt, d as dJt, b as uJt } from "../chunks/toast.D3AW3RWv.js";
191
191
  import { p as tZ } from "../chunks/purify.es.BIuh5IAZ.js";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orangelogic/design-system",
3
3
  "type": "module",
4
- "version": "2.130.0",
4
+ "version": "2.131.0",
5
5
  "license": "UNLICENSED",
6
6
  "types": "library/types.d.ts",
7
7
  "scripts": {
@@ -6,6 +6,7 @@ import { default as CxIconButton } from '../icon-button/icon-button.ts';
6
6
  import { default as CxSelect } from '../select/select.ts';
7
7
  import { default as CxSpace } from '../space/space.ts';
8
8
  import { default as CxSpinner } from '../spinner/spinner.ts';
9
+ import { default as CxTooltip } from '../tooltip/tooltip.ts';
9
10
  import { default as CortexElement } from '../../../../base/src/cortex-element.ts';
10
11
  import { RowComponent, TabulatorFull as Tabulator } from '../../../../hybrid/table-core/src/index.ts';
11
12
  import { PaginationCounter } from '../../../../types/src/pagination';
@@ -65,6 +66,7 @@ import { CxTableFooter, CxTableRowActions, CxTableToolbar } from './components';
65
66
  * E.g: `cx-table.rowMoved` will fire when `rowMoved` event is emitted.
66
67
  * @event {{ url: string, format: string, rowCount: number }} cx-table-data-load - Emitted when data is successfully loaded from dataUrl.
67
68
  * @event {{ url: string, error: unknown }} cx-table-data-load-error - Emitted when fetching or parsing data from dataUrl fails.
69
+ * @event {{ invalidCellCount: number, invalidCells: ICellComponent[] }} cx-table-validation-change - Emitted when the set of cells failing column `validator` rules changes (edit, load validation, or programmatic validate).
68
70
  */
69
71
  export default class CxTable extends CortexElement {
70
72
  #private;
@@ -82,6 +84,7 @@ export default class CxTable extends CortexElement {
82
84
  'cx-table-footer': typeof CxTableFooter;
83
85
  'cx-table-row-actions': typeof CxTableRowActions;
84
86
  'cx-table-toolbar': typeof CxTableToolbar;
87
+ 'cx-tooltip': typeof CxTooltip;
85
88
  };
86
89
  private verticalOsInstance;
87
90
  private horizontalOsInstance;
@@ -94,6 +97,18 @@ export default class CxTable extends CortexElement {
94
97
  private readonly table;
95
98
  private readonly tableToolbar;
96
99
  private readonly tableFooter;
100
+ private readonly validationTooltip;
101
+ /** Cell element the shared validation tooltip is currently anchored to. */
102
+ private validationTooltipAnchor;
103
+ /** Pending delayed hide of the shared validation tooltip. */
104
+ private validationTooltipHideTimeout?;
105
+ /**
106
+ * In-flight hide transition of the shared validation tooltip. Calling
107
+ * show() while a hide animation is still running would race its tail
108
+ * (which deactivates the popup after the animation), leaving `open` true
109
+ * but the tooltip invisible — show waits for this to settle instead.
110
+ */
111
+ private validationTooltipHidePromise;
97
112
  movableRows: boolean;
98
113
  movableColumns: boolean;
99
114
  data: Options['data'];
@@ -175,6 +190,16 @@ export default class CxTable extends CortexElement {
175
190
  * If 'basic', virtual DOM is disabled.
176
191
  */
177
192
  renderVertical: Options['renderVertical'];
193
+ /**
194
+ * When true, the whole dataset is validated against the column `validator`
195
+ * definitions each time data is loaded or replaced.
196
+ */
197
+ validateOnLoad: Options['validateOnLoad'];
198
+ /**
199
+ * Row-count threshold above which table-wide validation passes are offloaded
200
+ * to a Web Worker to keep the main thread responsive.
201
+ */
202
+ validationWorkerThreshold: Options['validationWorkerThreshold'];
178
203
  /**
179
204
  * The columnDefaults option allows you to set default configs for all columns in the table.
180
205
  */
@@ -717,6 +742,24 @@ export default class CxTable extends CortexElement {
717
742
  * All logic that needs to run when the table is built should be placed here.
718
743
  */
719
744
  private readonly handleTableBuilt;
745
+ /** Re-emits table-core validation summaries as a typed Cortex event. */
746
+ private readonly handleValidationChanged;
747
+ /**
748
+ * One shared tooltip serves every invalid cell: on hover it is re-anchored
749
+ * to the hovered cell and filled with that cell's failure messages, instead
750
+ * of rendering a tooltip per cell.
751
+ */
752
+ private handleValidationMouseOver;
753
+ private showValidationTooltip;
754
+ private hideValidationTooltip;
755
+ /**
756
+ * cx-popup restarts its positioner with a debounce after an anchor change,
757
+ * which would leave a re-anchored (still open) tooltip hovering over the
758
+ * previous cell while already showing the new cell's content — force an
759
+ * immediate reposition once the popup has adopted the new anchor.
760
+ */
761
+ private repositionValidationTooltipNow;
762
+ private handleValidationMouseOut;
720
763
  disconnectedCallback(): void;
721
764
  private initVerticalScrollbar;
722
765
  private initHorizontalScrollbar;
@@ -0,0 +1,8 @@
1
+ import { ValidationSummary } from '../../types/src/table';
2
+
3
+ export type CxTableValidationChangeEvent = CustomEvent<ValidationSummary>;
4
+ declare global {
5
+ interface GlobalEventHandlersEventMap {
6
+ 'cx-table-validation-change': CxTableValidationChangeEvent;
7
+ }
8
+ }
@@ -11,6 +11,7 @@ export * from './cx-after-expand';
11
11
  export * from './cx-after-hide';
12
12
  export * from './cx-after-show';
13
13
  export * from './cx-asset-data-display-slot-change';
14
+ export * from './cx-asset-format-picker-select';
14
15
  export * from './cx-asset-picker-delete';
15
16
  export * from './cx-asset-picker-select';
16
17
  export * from './cx-asset-request-status';
@@ -63,7 +64,6 @@ export * from './cx-dot-status-click';
63
64
  export * from './cx-download-format-picker-delete';
64
65
  export * from './cx-download-format-picker-select';
65
66
  export * from './cx-download-format-request-status';
66
- export * from './cx-asset-format-picker-select';
67
67
  export * from './cx-drag-end';
68
68
  export * from './cx-drag-start';
69
69
  export * from './cx-e-chart-drill-down';
@@ -79,8 +79,8 @@ export * from './cx-file-on-demand-unpin';
79
79
  export * from './cx-find-and-replace';
80
80
  export * from './cx-finish';
81
81
  export * from './cx-focus';
82
- export * from './cx-folder-select-search-term-change';
83
82
  export * from './cx-folder-select-children-loaded';
83
+ export * from './cx-folder-select-search-term-change';
84
84
  export * from './cx-gallery-chunk-request';
85
85
  export * from './cx-gallery-config-save';
86
86
  export * from './cx-gallery-item-click';
@@ -162,7 +162,6 @@ export * from './cx-save';
162
162
  export * from './cx-save-settings';
163
163
  export * from './cx-sb-button-click';
164
164
  export * from './cx-sb-dam-view-config-change';
165
- export * from './cx-video-thumbnail-resolved';
166
165
  export * from './cx-search';
167
166
  export * from './cx-select';
168
167
  export * from './cx-selected-change';
@@ -170,8 +169,8 @@ export * from './cx-selection-change';
170
169
  export * from './cx-shadow-input-group-change';
171
170
  export * from './cx-share-option-list-item-selected';
172
171
  export * from './cx-show';
173
- export * from './cx-special-characters-insert';
174
172
  export * from './cx-slide-change';
173
+ export * from './cx-special-characters-insert';
175
174
  export * from './cx-start';
176
175
  export * from './cx-swatch-add';
177
176
  export * from './cx-tab-hide';
@@ -183,9 +182,10 @@ export * from './cx-table-export';
183
182
  export * from './cx-table-row-action-click';
184
183
  export * from './cx-table-save-search-select';
185
184
  export * from './cx-table-switch-change';
185
+ export * from './cx-table-validation-change';
186
186
  export * from './cx-time-based-change';
187
- export * from './cx-timeline-data-resolved';
188
187
  export * from './cx-time-update';
188
+ export * from './cx-timeline-data-resolved';
189
189
  export * from './cx-tiptap-code-block-doc-request';
190
190
  export * from './cx-tiptap-image-doc-request';
191
191
  export * from './cx-tiptap-image-host-feedback';
@@ -193,11 +193,12 @@ export * from './cx-tiptap-video-doc-request';
193
193
  export * from './cx-tiptap-video-host-feedback';
194
194
  export * from './cx-typeface-change';
195
195
  export * from './cx-typeface-download';
196
- export * from './cx-undo';
197
196
  export * from './cx-unauthorized';
197
+ export * from './cx-undo';
198
198
  export * from './cx-unmark-favorite';
199
199
  export * from './cx-video-click';
200
200
  export * from './cx-video-editor-track-canvas-ready';
201
201
  export * from './cx-video-editor-track-click';
202
202
  export * from './cx-video-editor-transition-click';
203
+ export * from './cx-video-thumbnail-resolved';
203
204
  export * from './cx-view-logs';
@@ -13,3 +13,4 @@ export { default as Row } from './core/row/Row';
13
13
  export { default as Cell } from './core/cell/Cell';
14
14
  export { default as Module } from './core/Module';
15
15
  export { default as Renderer } from './core/rendering/Renderer';
16
+ export { VALIDATION_MESSAGE_ATTRIBUTE } from './modules/Validate/Validate';
@@ -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
- type ValidatorFunction = (cell: any, value: any, parameters: any) => boolean;
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
- params: any;
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
- invalidCells: Cell[];
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: any, _previousValue: any): boolean | any;
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): boolean | any;
24
- columnValidate(column: Column): any[] | boolean;
25
- rowValidate(row: Row): any[] | boolean;
26
- userClearCellValidation(cells?: any): void;
27
- userValidate(_cells?: any): any[] | boolean;
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: any): ValidatorConfig | false;
31
- _buildValidator(type: string | ValidatorFunction, params?: any): ValidatorConfig | false;
32
- validate(validators: ValidatorConfig[] | false | undefined, cell: Cell, value: any): any[] | boolean;
33
- getInvalidCells(): any[];
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
- declare const _default: {
2
- alphanumeric: (_cell: any, value: any, _parameters: any) => boolean;
3
- ends: (_cell: any, value: any, parameters: any) => boolean;
4
- float: (_cell: any, value: any, _parameters: any) => boolean;
5
- in: (_cell: any, value: any, parameters: any) => boolean;
6
- integer: (_cell: any, value: any, _parameters: any) => boolean;
7
- max: (_cell: any, value: any, parameters: any) => boolean;
8
- maxLength: (_cell: any, value: any, parameters: any) => boolean;
9
- min: (_cell: any, value: any, parameters: any) => boolean;
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[]>;