x4js 1.5.18 → 1.5.20

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 (242) hide show
  1. package/lib/{README.md → README.txt} +0 -0
  2. package/lib/cjs/index.js +39 -103
  3. package/lib/cjs/index.js.map +7 -0
  4. package/lib/esm/index.mjs +39 -87
  5. package/lib/esm/index.mjs.map +7 -0
  6. package/lib/{license.md → licence.md} +0 -0
  7. package/lib/src/MIT-license.md +14 -0
  8. package/lib/{types/action.d.ts → src/action.ts} +64 -33
  9. package/lib/src/alpha.jpg +0 -0
  10. package/lib/src/app_sockets.ts +81 -0
  11. package/lib/src/application.ts +251 -0
  12. package/lib/src/autocomplete.ts +197 -0
  13. package/lib/src/base64.ts +166 -0
  14. package/lib/src/base_component.ts +152 -0
  15. package/lib/src/button.ts +355 -0
  16. package/lib/src/calendar.ts +328 -0
  17. package/lib/src/canvas.ts +505 -0
  18. package/lib/src/cardview.ts +227 -0
  19. package/lib/src/checkbox.ts +188 -0
  20. package/lib/src/color.ts +752 -0
  21. package/lib/src/colorpicker.ts +1639 -0
  22. package/lib/src/combobox.ts +465 -0
  23. package/lib/src/component.ts +2329 -0
  24. package/lib/{esm/dom_events.js → src/copyright.txt} +27 -29
  25. package/lib/src/datastore.ts +1322 -0
  26. package/lib/src/dialog.ts +656 -0
  27. package/lib/src/dom_events.ts +315 -0
  28. package/lib/src/drag_manager.ts +199 -0
  29. package/lib/src/drawtext.ts +355 -0
  30. package/lib/src/fileupload.ts +213 -0
  31. package/lib/src/form.ts +375 -0
  32. package/lib/src/formatters.ts +105 -0
  33. package/lib/src/gridview.ts +1185 -0
  34. package/lib/src/i18n.ts +346 -0
  35. package/lib/src/icon.ts +335 -0
  36. package/lib/src/image.ts +204 -0
  37. package/lib/src/index.ts +89 -0
  38. package/lib/src/input.ts +249 -0
  39. package/lib/src/label.ts +128 -0
  40. package/lib/src/layout.ts +430 -0
  41. package/lib/src/link.ts +86 -0
  42. package/lib/src/listview.ts +765 -0
  43. package/lib/{esm/md5.js → src/md5.ts} +438 -403
  44. package/lib/src/menu.ts +425 -0
  45. package/lib/src/messagebox.ts +224 -0
  46. package/lib/src/panel.ts +86 -0
  47. package/lib/src/popup.ts +494 -0
  48. package/lib/src/property_editor.ts +337 -0
  49. package/lib/src/radiobtn.ts +197 -0
  50. package/lib/src/rating.ts +135 -0
  51. package/lib/src/request.ts +300 -0
  52. package/lib/src/router.ts +185 -0
  53. package/lib/src/settings.ts +77 -0
  54. package/lib/src/sidebarview.ts +103 -0
  55. package/lib/src/spreadsheet.ts +1449 -0
  56. package/lib/src/styles.ts +343 -0
  57. package/lib/src/svgcomponent.ts +577 -0
  58. package/lib/src/tabbar.ts +151 -0
  59. package/lib/src/tabview.ts +110 -0
  60. package/lib/src/textarea.ts +235 -0
  61. package/lib/src/textedit.ts +544 -0
  62. package/lib/src/toaster.ts +80 -0
  63. package/lib/src/tools.ts +1473 -0
  64. package/lib/src/tooltips.ts +191 -0
  65. package/lib/src/treeview.ts +716 -0
  66. package/lib/{esm/version.js → src/version.ts} +30 -29
  67. package/lib/{styles → src}/x4.less +0 -0
  68. package/lib/src/x4dom.ts +57 -0
  69. package/lib/src/x4events.ts +585 -0
  70. package/lib/src/x4react.ts +90 -0
  71. package/package.json +52 -46
  72. package/lib/cjs/action.js +0 -58
  73. package/lib/cjs/app_sockets.js +0 -74
  74. package/lib/cjs/application.js +0 -182
  75. package/lib/cjs/autocomplete.js +0 -155
  76. package/lib/cjs/base_component.js +0 -124
  77. package/lib/cjs/button.js +0 -263
  78. package/lib/cjs/calendar.js +0 -254
  79. package/lib/cjs/canvas.js +0 -361
  80. package/lib/cjs/cardview.js +0 -161
  81. package/lib/cjs/checkbox.js +0 -139
  82. package/lib/cjs/color.js +0 -591
  83. package/lib/cjs/colorpicker.js +0 -1468
  84. package/lib/cjs/combobox.js +0 -349
  85. package/lib/cjs/component.js +0 -1719
  86. package/lib/cjs/datastore.js +0 -985
  87. package/lib/cjs/dialog.js +0 -478
  88. package/lib/cjs/dom_events.js +0 -30
  89. package/lib/cjs/drag_manager.js +0 -145
  90. package/lib/cjs/drawtext.js +0 -276
  91. package/lib/cjs/fileupload.js +0 -167
  92. package/lib/cjs/form.js +0 -304
  93. package/lib/cjs/formatters.js +0 -90
  94. package/lib/cjs/gridview.js +0 -881
  95. package/lib/cjs/i18n.js +0 -266
  96. package/lib/cjs/icon.js +0 -272
  97. package/lib/cjs/image.js +0 -157
  98. package/lib/cjs/input.js +0 -174
  99. package/lib/cjs/label.js +0 -95
  100. package/lib/cjs/layout.js +0 -322
  101. package/lib/cjs/link.js +0 -64
  102. package/lib/cjs/listview.js +0 -546
  103. package/lib/cjs/md5.js +0 -403
  104. package/lib/cjs/menu.js +0 -301
  105. package/lib/cjs/messagebox.js +0 -177
  106. package/lib/cjs/panel.js +0 -68
  107. package/lib/cjs/popup.js +0 -383
  108. package/lib/cjs/property_editor.js +0 -252
  109. package/lib/cjs/radiobtn.js +0 -140
  110. package/lib/cjs/rating.js +0 -102
  111. package/lib/cjs/request.js +0 -246
  112. package/lib/cjs/router.js +0 -139
  113. package/lib/cjs/settings.js +0 -69
  114. package/lib/cjs/sidebarview.js +0 -82
  115. package/lib/cjs/spreadsheet.js +0 -1084
  116. package/lib/cjs/styles.js +0 -275
  117. package/lib/cjs/svgcomponent.js +0 -447
  118. package/lib/cjs/tabbar.js +0 -111
  119. package/lib/cjs/tabview.js +0 -85
  120. package/lib/cjs/textarea.js +0 -165
  121. package/lib/cjs/textedit.js +0 -415
  122. package/lib/cjs/toaster.js +0 -64
  123. package/lib/cjs/tools.js +0 -1197
  124. package/lib/cjs/tooltips.js +0 -157
  125. package/lib/cjs/treeview.js +0 -535
  126. package/lib/cjs/version.js +0 -32
  127. package/lib/cjs/x4dom.js +0 -32
  128. package/lib/cjs/x4events.js +0 -384
  129. package/lib/cjs/x4react.js +0 -72
  130. package/lib/esm/action.js +0 -53
  131. package/lib/esm/app_sockets.js +0 -70
  132. package/lib/esm/application.js +0 -184
  133. package/lib/esm/autocomplete.js +0 -155
  134. package/lib/esm/base_component.js +0 -107
  135. package/lib/esm/button.js +0 -257
  136. package/lib/esm/calendar.js +0 -249
  137. package/lib/esm/canvas.js +0 -358
  138. package/lib/esm/cardview.js +0 -159
  139. package/lib/esm/checkbox.js +0 -134
  140. package/lib/esm/color.js +0 -588
  141. package/lib/esm/colorpicker.js +0 -1475
  142. package/lib/esm/combobox.js +0 -351
  143. package/lib/esm/component.js +0 -1711
  144. package/lib/esm/datastore.js +0 -990
  145. package/lib/esm/dialog.js +0 -490
  146. package/lib/esm/drag_manager.js +0 -147
  147. package/lib/esm/drawtext.js +0 -271
  148. package/lib/esm/fileupload.js +0 -163
  149. package/lib/esm/form.js +0 -304
  150. package/lib/esm/formatters.js +0 -81
  151. package/lib/esm/gridview.js +0 -889
  152. package/lib/esm/i18n.js +0 -257
  153. package/lib/esm/icon.js +0 -261
  154. package/lib/esm/image.js +0 -154
  155. package/lib/esm/input.js +0 -182
  156. package/lib/esm/label.js +0 -90
  157. package/lib/esm/layout.js +0 -310
  158. package/lib/esm/link.js +0 -59
  159. package/lib/esm/listview.js +0 -534
  160. package/lib/esm/menu.js +0 -300
  161. package/lib/esm/messagebox.js +0 -161
  162. package/lib/esm/panel.js +0 -65
  163. package/lib/esm/popup.js +0 -379
  164. package/lib/esm/property_editor.js +0 -251
  165. package/lib/esm/radiobtn.js +0 -136
  166. package/lib/esm/rating.js +0 -97
  167. package/lib/esm/request.js +0 -224
  168. package/lib/esm/router.js +0 -136
  169. package/lib/esm/settings.js +0 -66
  170. package/lib/esm/sidebarview.js +0 -79
  171. package/lib/esm/spreadsheet.js +0 -1097
  172. package/lib/esm/styles.js +0 -270
  173. package/lib/esm/svgcomponent.js +0 -450
  174. package/lib/esm/tabbar.js +0 -107
  175. package/lib/esm/tabview.js +0 -83
  176. package/lib/esm/textarea.js +0 -160
  177. package/lib/esm/textedit.js +0 -412
  178. package/lib/esm/toaster.js +0 -62
  179. package/lib/esm/tools.js +0 -1158
  180. package/lib/esm/tooltips.js +0 -153
  181. package/lib/esm/treeview.js +0 -527
  182. package/lib/esm/x4dom.js +0 -29
  183. package/lib/esm/x4events.js +0 -376
  184. package/lib/esm/x4react.js +0 -71
  185. package/lib/types/app_sockets.d.ts +0 -29
  186. package/lib/types/application.d.ts +0 -104
  187. package/lib/types/autocomplete.d.ts +0 -58
  188. package/lib/types/base_component.d.ts +0 -88
  189. package/lib/types/button.d.ts +0 -151
  190. package/lib/types/calendar.d.ts +0 -82
  191. package/lib/types/canvas.d.ts +0 -92
  192. package/lib/types/cardview.d.ts +0 -87
  193. package/lib/types/checkbox.d.ts +0 -77
  194. package/lib/types/color.d.ts +0 -148
  195. package/lib/types/colorpicker.d.ts +0 -107
  196. package/lib/types/combobox.d.ts +0 -107
  197. package/lib/types/component.d.ts +0 -601
  198. package/lib/types/datastore.d.ts +0 -396
  199. package/lib/types/dialog.d.ts +0 -175
  200. package/lib/types/dom_events.d.ts +0 -302
  201. package/lib/types/drag_manager.d.ts +0 -54
  202. package/lib/types/drawtext.d.ts +0 -48
  203. package/lib/types/fileupload.d.ts +0 -64
  204. package/lib/types/form.d.ts +0 -133
  205. package/lib/types/formatters.d.ts +0 -35
  206. package/lib/types/gridview.d.ts +0 -175
  207. package/lib/types/i18n.d.ts +0 -73
  208. package/lib/types/icon.d.ts +0 -64
  209. package/lib/types/image.d.ts +0 -55
  210. package/lib/types/index.d.ts +0 -84
  211. package/lib/types/input.d.ts +0 -91
  212. package/lib/types/label.d.ts +0 -58
  213. package/lib/types/layout.d.ts +0 -87
  214. package/lib/types/link.d.ts +0 -50
  215. package/lib/types/listview.d.ts +0 -178
  216. package/lib/types/md5.d.ts +0 -61
  217. package/lib/types/menu.d.ts +0 -130
  218. package/lib/types/messagebox.d.ts +0 -69
  219. package/lib/types/panel.d.ts +0 -47
  220. package/lib/types/popup.d.ts +0 -75
  221. package/lib/types/property_editor.d.ts +0 -71
  222. package/lib/types/radiobtn.d.ts +0 -73
  223. package/lib/types/rating.d.ts +0 -53
  224. package/lib/types/request.d.ts +0 -52
  225. package/lib/types/router.d.ts +0 -42
  226. package/lib/types/settings.d.ts +0 -37
  227. package/lib/types/sidebarview.d.ts +0 -49
  228. package/lib/types/spreadsheet.d.ts +0 -222
  229. package/lib/types/styles.d.ts +0 -85
  230. package/lib/types/svgcomponent.d.ts +0 -215
  231. package/lib/types/tabbar.d.ts +0 -58
  232. package/lib/types/tabview.d.ts +0 -49
  233. package/lib/types/textarea.d.ts +0 -77
  234. package/lib/types/textedit.d.ts +0 -123
  235. package/lib/types/toaster.d.ts +0 -42
  236. package/lib/types/tools.d.ts +0 -394
  237. package/lib/types/tooltips.d.ts +0 -46
  238. package/lib/types/treeview.d.ts +0 -144
  239. package/lib/types/version.d.ts +0 -29
  240. package/lib/types/x4dom.d.ts +0 -49
  241. package/lib/types/x4events.d.ts +0 -269
  242. package/lib/types/x4react.d.ts +0 -41
@@ -0,0 +1,1185 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file gridview.ts
9
+ * @author Etienne Cochard
10
+ *
11
+ * Copyright (c) 2019-2022 R-libre ingenierie
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ * of this software and associated documentation files (the "Software"), to deal
15
+ * in the Software without restriction, including without limitation the rights
16
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
17
+ * of the Software, and to permit persons to whom the Software is furnished to do so,
18
+ * subject to the following conditions:
19
+ * The above copyright notice and this permission notice shall be included in all copies
20
+ * or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
23
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
24
+ * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
+ **/
29
+
30
+ const T_UPDATE = Symbol('update');
31
+
32
+ /**
33
+ * todo: sizable column
34
+ * todo: button in a column
35
+ */
36
+
37
+ import { x4document } from './x4dom'
38
+
39
+ import { HLayout, VLayout } from './layout'
40
+ import { Component, ContainerEventMap, EvSize, EvDblClick, CProps, flyWrap, html, HtmlString, SizerOverlay, Flex } from './component'
41
+ import { Label } from './label'
42
+ import { _tr } from './i18n'
43
+ import { FormatFunc } from './formatters'
44
+ import { downloadData, isFunction } from './tools'
45
+ import { DataView, DataStore, Record } from './datastore'
46
+
47
+ import { EvContextMenu, EvSelectionChange, BasicEvent, EventDisposer } from "./x4events";
48
+ import { Icon } from './icon.js';
49
+
50
+ export interface EvGridCheck extends BasicEvent {
51
+ rec: Record;
52
+ chk: boolean;
53
+ }
54
+
55
+ export function EvGridCheck(rec: Record, chk: boolean) {
56
+ return BasicEvent<EvGridCheck>( { rec, chk } );
57
+ }
58
+
59
+
60
+
61
+
62
+
63
+ /**
64
+ *
65
+ */
66
+
67
+ export interface GridColumn {
68
+ id: any;
69
+ title: string;
70
+ width: number;
71
+ flex?: number;
72
+ align?: 'left' | 'center' | 'right';
73
+ renderer?: CellRenderer;
74
+ formatter?: FormatFunc;
75
+ cls?: string;
76
+ sortable?: boolean;
77
+ }
78
+
79
+ interface GridColumnInternal extends GridColumn {
80
+ $hdr: ColHeader;
81
+ $ftr: Component;
82
+ }
83
+
84
+
85
+
86
+ export type CellRenderer = (rec: Record) => Component;
87
+ export type RowClassifier = (rec: Record, Row: Component) => void;
88
+ export type ContextMenuGridItem = (event: MouseEvent, item: Record, grid: GridView) => any;
89
+
90
+ type emptyFn = () => string;
91
+
92
+ interface GridViewEventMap extends ContainerEventMap {
93
+ dblClick?: EvDblClick;
94
+ selectionChange?: EvSelectionChange;
95
+ contextMenu?: EvContextMenu;
96
+ gridCheck?: EvGridCheck;
97
+ }
98
+
99
+ export interface GridViewProps extends CProps<GridViewEventMap> {
100
+ store: DataStore | DataView;
101
+ columns: GridColumn[];
102
+ calcRowClass?: RowClassifier;
103
+ empty_text?: string | emptyFn; // set or return '' to avoid message
104
+ hasMarks?: boolean; // if true add a checkbox on left side cf. clearMarks, getMarksIds
105
+ hasFooter?: boolean;
106
+ }
107
+
108
+
109
+ class ColHeader extends Component {
110
+
111
+ private m_sens: "up" | "dn";
112
+ private m_sorted: boolean;
113
+
114
+ constructor( props, title ) {
115
+ super( props );
116
+
117
+ this.m_sorted = false;
118
+ this.m_sens = 'dn';
119
+
120
+ this.setContent( [
121
+ new Component({
122
+ tag: 'span',
123
+ content: title
124
+ }),
125
+ new Icon( {
126
+ ref: 'sorter',
127
+ cls: '@hidden sort',
128
+ icon: 'var( --x4-icon-arrow-down )'
129
+ })
130
+ ]);
131
+ }
132
+
133
+ get sorted( ) {
134
+ return this.m_sorted;
135
+ }
136
+
137
+ //set sorted( v ) {
138
+ // this.m_sorted = v;
139
+ // this.m_sens = 'dn';
140
+ // this.itemWithRef<Icon>( 'sorter' ).show( v );
141
+ //}
142
+
143
+ sort( v: boolean, sens: "up" | "dn" ) {
144
+ this.m_sorted = v;
145
+ this.m_sens = sens;
146
+
147
+ const ic = this.itemWithRef<Icon>('sorter');
148
+ ic.icon = this.m_sens == 'up' ? 'var( --x4-icon-arrow-down )' : 'var( --x4-icon-arrow-up )';
149
+ ic.show(v);
150
+ }
151
+
152
+ get sens( ) {
153
+ return this.m_sens;
154
+ }
155
+
156
+ toggleSens( ) {
157
+ this.m_sens = this.m_sens=='up' ? 'dn' : 'up';
158
+ this.itemWithRef<Icon>( 'sorter' ).icon = this.m_sens=='up' ? 'var( --x4-icon-arrow-down )' : 'var( --x4-icon-arrow-up )';
159
+ }
160
+ }
161
+
162
+
163
+
164
+ /**
165
+ * gridview class
166
+ */
167
+
168
+ export class GridView extends VLayout<GridViewProps, GridViewEventMap> {
169
+
170
+ protected m_dataview: DataView;
171
+ protected m_data_cx: EventDisposer;
172
+
173
+ protected m_columns: GridColumn[];
174
+
175
+ protected m_view_el: Component;
176
+ protected m_container: Component;
177
+ protected m_header: Component;
178
+
179
+ protected m_footer: Component;
180
+
181
+ protected m_empty_msg: Label;
182
+ protected m_empty_text: string | emptyFn;
183
+
184
+ protected m_selection: any;
185
+ private m_itemHeight: number;
186
+ private m_topIndex: number;
187
+ protected m_visible_rows: Component[]; // shown elements
188
+
189
+ protected m_hasMarks: boolean;
190
+ protected m_marks: Set<any>; // checked elements
191
+
192
+ private m_recycler: Component[];
193
+
194
+ private m_rowClassifier: RowClassifier;
195
+
196
+ constructor(props: GridViewProps) {
197
+ super(props);
198
+
199
+ this.m_columns = props.columns;
200
+ this.m_hasMarks = props.hasMarks ?? false;
201
+ this.m_marks = new Set<any>();
202
+
203
+ // prepend the checkable column
204
+ if (this.m_hasMarks) {
205
+ this.m_columns.unshift({
206
+ id: 'id',
207
+ title: '',
208
+ width: 30,
209
+ renderer: (e) => this._renderCheck( e )
210
+ });
211
+ }
212
+
213
+ this.setAttribute('tabindex', 0);
214
+
215
+ this.m_topIndex = 0;
216
+ this.m_itemHeight = 0;
217
+ this.m_recycler = [];
218
+ this.m_rowClassifier = props.calcRowClass;
219
+
220
+ this.m_empty_text = props.empty_text ?? _tr.global.empty_list;
221
+
222
+ //this.setDomEvent('create', this._handleCreate, this);
223
+ this.setDomEvent('click', (e)=>this._itemClick(e));
224
+ this.setDomEvent('dblclick', (e)=>this._itemDblClick(e));
225
+ this.setDomEvent('contextmenu', (e)=>this._itemMenu(e));
226
+ this.setDomEvent('keydown', (e)=>this._handleKey(e));
227
+
228
+ this.setStore(props.store);
229
+ }
230
+
231
+ componentCreated() {
232
+ this._updateScroll(true);
233
+ }
234
+
235
+ /**
236
+ *
237
+ */
238
+
239
+ private _moveSel(sens: number, select = true) {
240
+
241
+ let sel = this.m_selection;
242
+ let scrolltype = null;
243
+
244
+ if (sel === undefined) {
245
+ sel = this.m_dataview.getByIndex(0).getID();
246
+ }
247
+ else {
248
+
249
+ let index = this.m_dataview.indexOfId(this.m_selection);
250
+
251
+ if (sens == 1) {
252
+ index++;
253
+ }
254
+ else if (sens == -1) {
255
+ index--;
256
+ }
257
+ else if (sens == 2) {
258
+ index += this.m_visible_rows.length - 1;
259
+ }
260
+ else if (sens == -2) {
261
+ index -= this.m_visible_rows.length - 1;
262
+ }
263
+
264
+ if (sens < 0) {
265
+ scrolltype = 'start';
266
+ }
267
+ else {
268
+ scrolltype = 'end';
269
+ }
270
+
271
+ if (index < 0) {
272
+ index = 0;
273
+ }
274
+ else if (index >= this.m_dataview.count) {
275
+ index = this.m_dataview.count - 1;
276
+ }
277
+
278
+ sel = this.m_dataview.getByIndex(index).getID();
279
+ }
280
+
281
+ if (this.m_selection != sel && select) {
282
+ this._selectItem(sel, null, scrolltype);
283
+ }
284
+
285
+ return sel;
286
+ }
287
+
288
+ /**
289
+ *
290
+ */
291
+
292
+ private _handleKey(event: KeyboardEvent) {
293
+ if (!this.m_dataview || this.m_dataview.count == 0) {
294
+ return;
295
+ }
296
+
297
+ switch (event.key) {
298
+ case 'ArrowDown':
299
+ case 'Down': {
300
+ this._moveSel(1);
301
+ break;
302
+ }
303
+
304
+ case 'ArrowUp':
305
+ case 'Up': {
306
+ this._moveSel(-1);
307
+ break;
308
+ }
309
+
310
+ case 'PageUp': {
311
+ this._moveSel(-2);
312
+ break;
313
+ }
314
+
315
+ case 'PageDown': {
316
+ this._moveSel(2);
317
+ break;
318
+ }
319
+ }
320
+ }
321
+
322
+ /**
323
+ *
324
+ */
325
+
326
+ getNextSel(sens: number) {
327
+ return this._moveSel(sens, false);
328
+ }
329
+
330
+ private _scrollIntoView(id: any, sens?: string) {
331
+
332
+ let itm = this._findItem(id);
333
+ if (itm) {
334
+ itm.scrollIntoView({
335
+ block: 'center' //<ScrollLogicalPosition>sens ?? 'nearest'
336
+ });
337
+ }
338
+ else {
339
+ this.m_topIndex = this.m_dataview.indexOfId(id);
340
+ this.m_view_el.dom.scrollTop = this.m_topIndex * this.m_itemHeight;
341
+ this._buildItems();
342
+
343
+ this._scrollIntoView(id);
344
+ }
345
+
346
+ }
347
+
348
+ /**
349
+ * change the list of item displayed
350
+ * @param items - new array of items
351
+ */
352
+
353
+ public setStore(store: DataStore | DataView) {
354
+
355
+ this.m_selection = undefined;
356
+
357
+ if (store instanceof DataStore) {
358
+ this.m_dataview = store.createView();
359
+ }
360
+ else {
361
+ this.m_dataview = store;
362
+ }
363
+
364
+ if( this.m_hasMarks ) {
365
+ this.clearMarks( );
366
+ }
367
+
368
+ // unlink previous observer
369
+ if (this.m_data_cx) {
370
+ this.m_data_cx.dispose( );
371
+ }
372
+
373
+ if (this.m_dataview) {
374
+
375
+ this.m_data_cx = this.m_dataview.on( 'view_change', ( ev ) => {
376
+ if (ev.action == 'change') {
377
+ this.m_selection = undefined;
378
+ }
379
+
380
+ this._updateScroll(true);
381
+ });
382
+
383
+ //this.update( );
384
+ this._updateScroll(true);
385
+ }
386
+ }
387
+
388
+ public getView(): DataView {
389
+ return this.m_dataview;
390
+ }
391
+
392
+ /**
393
+ * return the current selection (row id) or null
394
+ */
395
+
396
+ public getSelection(): any {
397
+ return this.m_selection;
398
+ }
399
+
400
+ public getSelRec(): Record {
401
+ if (this.m_selection) {
402
+ return this.m_dataview.getById(this.m_selection);
403
+ }
404
+
405
+ return null;
406
+ }
407
+
408
+ public setSelection(recId: any) {
409
+ this._selectItem(recId, null, 'center');
410
+ }
411
+
412
+ /** @ignore */
413
+ render() {
414
+
415
+ this.m_recycler = [];
416
+ this.m_container = new Component({
417
+ cls: 'content',
418
+ });
419
+
420
+ this.m_empty_msg = new Label({
421
+ cls: 'empty-msg',
422
+ text: ''
423
+ });
424
+
425
+ this.m_view_el = new Component({
426
+ cls: '@scroll-view',
427
+ flex: 1,
428
+ dom_events: {
429
+ sizechange: ( ) => this._updateScroll(true),
430
+ scroll: ( ) => this._updateScroll(false)
431
+ },
432
+ content: this.m_container
433
+ });
434
+
435
+ let flex = false;
436
+ let cols = this.m_columns.map((col, index) => {
437
+
438
+ let cls = '@cell';
439
+ if (col.cls) {
440
+ cls += ' ' + col.cls;
441
+ }
442
+
443
+ let comp = new ColHeader({
444
+ cls,
445
+ flex: col.flex,
446
+ sizable: 'right',
447
+ style: {
448
+ width: col.width
449
+ },
450
+ dom_events: {
451
+ click: (ev: MouseEvent) => {
452
+ let t = flyWrap(<HTMLElement>ev.target);
453
+ if (!t.hasClass('@sizer-overlay')) { // avoid sizer click
454
+ this._sortCol(col);
455
+ ev.preventDefault();
456
+ }
457
+ }
458
+ }
459
+ }, col.title );
460
+
461
+ const resizeCol = ( ev: EvSize ) => {
462
+ this._on_col_resize(index, ev.size.width);
463
+
464
+ if( this.m_footer ) {
465
+ let col = Component.getElement( this.m_footer.dom.childNodes[index] as HTMLElement );
466
+ if( col ) {
467
+ col.setStyleValue( 'width', ev.size.width );
468
+ }
469
+ }
470
+ }
471
+
472
+ new SizerOverlay({
473
+ target: comp,
474
+ sens: 'right',
475
+ events: {resize: ( e ) => resizeCol(e )}
476
+ });
477
+
478
+ if( col.flex ) {
479
+ flex = true;
480
+ }
481
+
482
+ (<any>col).$hdr = comp;
483
+ return comp;
484
+ });
485
+
486
+ (cols as any).push( new Flex( {
487
+ ref: 'flex',
488
+ cls: flex ? '@hidden' : ''
489
+ } ) );
490
+
491
+ // compute full width
492
+ let full_width = 0;
493
+ this.m_columns.forEach((col) => {
494
+ full_width += col.width ?? 0;
495
+ });
496
+
497
+ this.m_header = new HLayout({
498
+ cls: '@header',
499
+ content: <any>cols,
500
+ style: {
501
+ minWidth: full_width
502
+ }
503
+ });
504
+
505
+ if( this.m_props.hasFooter ) {
506
+ let foots = this.m_columns.map((col, index) => {
507
+
508
+ let cls = '@cell';
509
+
510
+ if (col.align) {
511
+ cls += ' ' + col.align;
512
+ }
513
+
514
+ if (col.cls) {
515
+ cls += ' ' + col.cls;
516
+ }
517
+
518
+ let comp = new Component({
519
+ cls,
520
+ data: { col: index },
521
+ flex: col.flex,
522
+ style: {
523
+ width: col.width
524
+ }
525
+ });
526
+
527
+ (col as GridColumnInternal).$ftr = comp;
528
+ return comp;
529
+ });
530
+
531
+ (foots as any).push( new Flex( {
532
+ ref: 'flex',
533
+ cls: flex ? '@hidden' : ''
534
+ } ) );
535
+
536
+ this.m_footer = new HLayout({
537
+ cls: '@footer',
538
+ content: <any>foots,
539
+ style: {
540
+ minWidth: full_width
541
+ }
542
+ });
543
+ }
544
+ else {
545
+ this.m_footer = null;
546
+ }
547
+
548
+ this.setContent([
549
+ this.m_header,
550
+ this.m_view_el,
551
+ this.m_footer,
552
+ this.m_empty_msg,
553
+ ]);
554
+
555
+ }
556
+
557
+ private _on_col_resize(col: number, width: number) {
558
+
559
+ const _col = this.m_columns[col] as GridColumnInternal;
560
+
561
+ let updateFlex = false;
562
+
563
+ if( width>=0 ) {
564
+ _col.width = width;
565
+ if( _col.flex ) {
566
+ _col.$hdr.removeClass( '@flex' );
567
+ _col.$ftr?.removeClass( '@flex' );
568
+ _col.flex = undefined;
569
+ updateFlex = true;
570
+ }
571
+ }
572
+ else if( width<0 && !_col.flex ) {
573
+ _col.$hdr.addClass( '@flex' );
574
+ _col.$ftr?.addClass( '@flex' );
575
+ _col.flex = 1;
576
+ updateFlex = true;
577
+ }
578
+
579
+ if( updateFlex ) {
580
+ let flex = false;
581
+ this.m_columns.forEach( c => {
582
+ if( c.flex ) {
583
+ flex = true;
584
+ }
585
+ });
586
+
587
+ this.m_header.itemWithRef( 'flex' )?.show( flex ? false : true );
588
+ if( this.m_footer ) {
589
+ this.m_footer.itemWithRef( 'flex' )?.show( flex ? false : true );
590
+ }
591
+ }
592
+
593
+ this._updateScroll(true);
594
+ }
595
+
596
+ /**
597
+ *
598
+ */
599
+
600
+ sortCol( name: string, asc = true ) {
601
+ const col = this.m_columns.find(c => c.id==name );
602
+ if( col===undefined ) {
603
+ console.assert( false, "unknown field "+name+" in grid.sortCol" );
604
+ return;
605
+ }
606
+
607
+ this._sortCol( col, asc ? "dn" : "up" );
608
+ }
609
+
610
+ /**
611
+ *
612
+ */
613
+
614
+ private _sortCol(col: GridColumn, sens: "up" | "dn" = "up" ) {
615
+
616
+ if (col.sortable === false) {
617
+ return;
618
+ }
619
+
620
+ this.m_columns.forEach((c) => {
621
+ if (c !== col) {
622
+ (c as GridColumnInternal).$hdr.sort( false, "dn" );
623
+ }
624
+ });
625
+
626
+ const $hdr = (col as GridColumnInternal).$hdr;
627
+
628
+ if ($hdr.sorted) {
629
+ $hdr.toggleSens( );
630
+ }
631
+ else {
632
+ $hdr.sort( true, sens );
633
+ }
634
+
635
+ if (this.m_dataview) {
636
+ this.m_dataview.sort([
637
+ { field: col.id, ascending: $hdr.sens=='dn' ? false : true }
638
+ ]);
639
+ }
640
+ }
641
+
642
+ /**
643
+ *
644
+ */
645
+
646
+ private _computeItemHeight() {
647
+ let gr = x4document.createElement('div');
648
+ gr.classList.add('x-row');
649
+
650
+ let gv = x4document.createElement('div');
651
+ gv.classList.add('x-grid-view');
652
+ gv.style.position = 'absolute';
653
+ gv.style.top = '-1000px';
654
+ gv.appendChild(gr);
655
+
656
+ this.dom.appendChild(gv);
657
+ let rc = gr.getBoundingClientRect();
658
+ this.dom.removeChild(gv);
659
+
660
+ this.m_itemHeight = rc.height;
661
+ }
662
+
663
+ private _createRow( props: CProps ): Component {
664
+
665
+ let row: Component;
666
+ if (this.m_recycler.length) {
667
+ row = this.m_recycler.pop();
668
+ row.clearClasses();
669
+ row.addClass( props.cls );
670
+ row.setContent( props.content );
671
+ row.setStyle( props.style );
672
+
673
+ for( let n in props.data ) {
674
+ row.setData( n, props.data[n] );
675
+ }
676
+ }
677
+ else {
678
+ row = new HLayout( props );
679
+ }
680
+
681
+ if (!row.dom) {
682
+ this.m_container.appendChild(row);
683
+ }
684
+
685
+ return row;
686
+ }
687
+
688
+ private _buildItems( canOpt = true ) {
689
+ let rc = this.getBoundingRect();
690
+ let rh = this.m_header.getBoundingRect();
691
+ let height = rc.height - rh.height + this.m_itemHeight;
692
+
693
+ if (this.m_itemHeight == 0) {
694
+ this._computeItemHeight();
695
+ }
696
+
697
+ let top = this.m_topIndex * this.m_itemHeight;
698
+ let y = 0;
699
+ let cidx = 0;
700
+ let index = this.m_topIndex;
701
+ let count = this.m_dataview ? this.m_dataview.count : 0;
702
+
703
+ let full_width = 0; // todo: +4 pixel of left border
704
+ let even = this.m_topIndex & 1 ? true : false;
705
+
706
+ // compute full width
707
+ this.m_columns.forEach((col) => {
708
+ full_width += col.width ?? 0;
709
+ });
710
+
711
+ // if items height make scroll visible, update header width
712
+ if (((count + 1) * this.m_itemHeight) >= height) {
713
+ let w = Component.getScrollbarSize();
714
+ this.m_header.setStyleValue("paddingRight", w);
715
+ this.m_footer?.setStyleValue("paddingRight", w);
716
+ }
717
+ else {
718
+ this.m_header.setStyleValue("paddingRight", 0);
719
+ this.m_footer?.setStyleValue("paddingRight", 0);
720
+ }
721
+
722
+ // passe 0 - all created cells are moved to the recycler
723
+ if( this.m_visible_rows ) {
724
+ this.m_visible_rows.forEach((c) => {
725
+ this.m_recycler.push(c);
726
+ });
727
+ }
728
+
729
+ this.m_visible_rows = [];
730
+ let limit = 100;
731
+ while (y < height && index < count && --limit > 0) {
732
+
733
+ let rec = this.m_dataview.getByIndex(index);
734
+ let rowid = rec.getID();
735
+
736
+ let crow = canOpt ? this.m_recycler.findIndex( ( r ) => r.getData('row-id')==rowid ) : -1;
737
+ if( crow>=0 ) {
738
+ let rrow = this.m_recycler.splice( crow, 1 )[ 0 ];
739
+ rrow.setStyle( {
740
+ top: y + top,
741
+ minWidth: full_width,
742
+ } );
743
+
744
+ if (this.m_hasMarks) {
745
+ rrow.setClass( '@marked', this.m_marks.has(rowid) );
746
+ }
747
+
748
+ rrow.removeClass( '@hidden' );
749
+ rrow.setClass( '@selected', this.m_selection === rowid );
750
+
751
+ this.m_visible_rows[cidx] = rrow;
752
+ }
753
+ else {
754
+ let cols = this.m_columns.map( col => {
755
+
756
+ let cls = '@cell';
757
+ if (col.align) {
758
+ cls += ' ' + col.align;
759
+ }
760
+
761
+ if (col.cls) {
762
+ cls += ' ' + col.cls;
763
+ }
764
+
765
+ let cell: Component;
766
+ if (col.renderer) {
767
+ cell = col.renderer(rec);
768
+ if (cell) {
769
+ cell.addClass(cls);
770
+ cell.setStyleValue('width', col.width);
771
+ if (col.flex !== undefined) {
772
+ cell.addClass('@flex');
773
+ cell.setStyleValue('flex', col.flex);
774
+ }
775
+ }
776
+ }
777
+ else {
778
+
779
+ let fmt = col.formatter;
780
+ let text;
781
+
782
+ if (fmt && fmt instanceof Function) {
783
+ text = fmt(rec.getRaw(col.id), rec);
784
+ }
785
+ else {
786
+ text = rec.getField(col.id);
787
+ }
788
+
789
+ cell = new Component({
790
+ cls,
791
+ width: col.width,
792
+ content: html`<span>${text}</span>`,
793
+ flex: col.flex
794
+ })
795
+ }
796
+
797
+ return cell;
798
+ });
799
+
800
+ let cls = '@row @hlayout center';
801
+ if (this.m_hasMarks) {
802
+ if (this.m_marks.has(rowid)) {
803
+ cls += ' @marked';
804
+ }
805
+ }
806
+
807
+ if (this.m_selection === rowid) {
808
+ cls += ' @selected';
809
+ }
810
+
811
+ let row = this.m_visible_rows[cidx] = this._createRow( {
812
+ cls,
813
+ content: <any>cols,
814
+ style: {
815
+ top: y + top,
816
+ minWidth: full_width,
817
+ },
818
+ data: {
819
+ 'row-id': rowid,
820
+ 'row-idx': index
821
+ }
822
+ });
823
+
824
+ row.addClass(even ? 'even' : 'odd');
825
+ even = !even;
826
+
827
+ if (this.m_rowClassifier) {
828
+ this.m_rowClassifier(rec, row);
829
+ }
830
+ }
831
+
832
+ y += this.m_itemHeight;
833
+
834
+ index++;
835
+ cidx++;
836
+ }
837
+
838
+ // if some cells are still in cache, hide them
839
+ this.m_recycler.forEach((c) => {
840
+ c.addClass('@hidden');
841
+ })
842
+
843
+ //this.m_container.setContent(<ComponentContent>this.m_visible_rows);
844
+
845
+ let show = !count;
846
+ let msg = (this.m_empty_text instanceof Function) ? this.m_empty_text() : this.m_empty_text;
847
+ this.m_empty_msg.text = msg;
848
+
849
+ if (show && msg.length == 0) {
850
+ show = false;
851
+ }
852
+
853
+ this.m_empty_msg.show(show);
854
+
855
+ if (full_width < rc.width) {
856
+ this.m_header.setStyleValue('width', null);
857
+ this.m_footer?.setStyleValue('width', null);
858
+ this.m_container.setStyle({
859
+ height: count * this.m_itemHeight,
860
+ width: null
861
+ });
862
+ }
863
+ else {
864
+ this.m_header.setStyleValue('width', full_width + 1000 );
865
+ this.m_footer?.setStyleValue('width', full_width + 1000 );
866
+ this.m_container.setStyle({
867
+ height: count * this.m_itemHeight,
868
+ width: full_width
869
+ });
870
+ }
871
+ }
872
+
873
+ /**
874
+ *
875
+ */
876
+
877
+ private _updateScroll(forceUpdate) {
878
+ if (!this.m_view_el || !this.m_view_el.dom) {
879
+ return;
880
+ }
881
+
882
+ const update = () => {
883
+
884
+ // element destroyed between updateScroll and now
885
+ if( !this.dom ) {
886
+ return;
887
+ }
888
+
889
+ let newTop = Math.floor(this.m_view_el.dom.scrollTop / (this.m_itemHeight || 1));
890
+
891
+ if (newTop != this.m_topIndex || forceUpdate) {
892
+ this.m_topIndex = newTop;
893
+ this._buildItems( !forceUpdate );
894
+ }
895
+
896
+ let newLeft = this.m_view_el.dom.scrollLeft;
897
+ this.m_header.setStyleValue('left', -newLeft);
898
+ this.m_footer?.setStyleValue('left', -newLeft);
899
+ }
900
+
901
+ if (forceUpdate) {
902
+ this.singleShot( update, 10 );
903
+ }
904
+ else {
905
+ update();
906
+ }
907
+ }
908
+
909
+ /** @ignore */
910
+
911
+ private _rowFromTarget(dom) {
912
+ let self = this.dom;
913
+
914
+ while (dom && dom != self) {
915
+ let itm = Component.getElement(dom);
916
+
917
+ if (itm) {
918
+ let id = itm.getData('row-id');
919
+ if (id !== undefined) {
920
+ return { id, itm };
921
+ }
922
+ }
923
+
924
+ dom = dom.parentElement;
925
+ }
926
+
927
+ return undefined;
928
+ }
929
+
930
+ private _itemClick(e: MouseEvent) {
931
+ let hit = this._rowFromTarget(e.target);
932
+ if (hit) {
933
+ this._selectItem(hit.id, hit.itm);
934
+ }
935
+ else {
936
+ this._selectItem(undefined, undefined);
937
+ }
938
+ }
939
+
940
+ private _itemDblClick(e: MouseEvent) {
941
+ let hit = this._rowFromTarget(e.target);
942
+ if (hit) {
943
+ this._selectItem(hit.id, hit.itm);
944
+
945
+ let rec = this.m_dataview.getById(hit.id);
946
+ this.emit( 'dblClick', EvDblClick(rec) );
947
+
948
+ if (this.m_hasMarks) {
949
+ this._toggleMark(rec);
950
+ }
951
+ }
952
+
953
+ }
954
+
955
+ /** @ignore */
956
+ private _itemMenu(e: MouseEvent) {
957
+
958
+ let dom = e.target as HTMLElement,
959
+ self = this.dom;
960
+
961
+ while (dom && dom != self) {
962
+ let itm = Component.getElement(dom),
963
+ id = itm?.getData('row-id');
964
+
965
+ if (id !== undefined) {
966
+ this._selectItem(id, itm);
967
+
968
+ let idx = itm.getData('row-idx');
969
+ let rec = this.m_dataview.getByIndex(idx);
970
+
971
+ this._showItemContextMenu(e, rec);
972
+ e.preventDefault();
973
+ return;
974
+ }
975
+
976
+ dom = dom.parentElement;
977
+ }
978
+ }
979
+
980
+ /**
981
+ *
982
+ */
983
+
984
+ private _findItem(id): Component {
985
+
986
+ for (let i = 0; i < this.m_visible_rows.length; i++) {
987
+ let itm = this.m_visible_rows[i];
988
+ if (itm.getData('row-id') === id) {
989
+ return itm;
990
+ }
991
+ }
992
+
993
+ return null;
994
+ }
995
+
996
+ /**
997
+ * @ignore
998
+ * called when an item is selected by mouse
999
+ */
1000
+
1001
+ protected _selectItem(item: any, dom_item: Component, scrollIntoView?: string) {
1002
+
1003
+ if (this.m_selection !== undefined) {
1004
+ let old = this._findItem(this.m_selection);
1005
+ if (old) {
1006
+ old.removeClass('@selected');
1007
+ }
1008
+ }
1009
+
1010
+ this.m_selection = item;
1011
+
1012
+ if (item) {
1013
+ if (scrollIntoView) {
1014
+ this._scrollIntoView(item, scrollIntoView);
1015
+ }
1016
+
1017
+ if (!dom_item) {
1018
+ dom_item = this._findItem(item);
1019
+ }
1020
+
1021
+ if (dom_item) {
1022
+ dom_item.addClass('@selected');
1023
+ }
1024
+
1025
+ let rec = this.m_dataview.getById(item);
1026
+ this.emit( 'selectionChange', EvSelectionChange(rec));
1027
+ }
1028
+ else {
1029
+ this.emit( 'selectionChange', EvSelectionChange(null));
1030
+ }
1031
+ }
1032
+
1033
+ /**
1034
+ *
1035
+ */
1036
+
1037
+ protected _showItemContextMenu(event: MouseEvent, item: Record) {
1038
+ this.emit( 'contextMenu', EvContextMenu(event,item));
1039
+ }
1040
+
1041
+ /**
1042
+ *
1043
+ */
1044
+
1045
+ public clearSelection() {
1046
+ this._selectItem(null, null);
1047
+ }
1048
+
1049
+ /**
1050
+ * todo: moveto datastore
1051
+ */
1052
+
1053
+ public exportData(filename) {
1054
+
1055
+ let data = '';
1056
+ const fsep = '\t';
1057
+ const lsep = '\r\n';
1058
+
1059
+ let rec = '';
1060
+ this.m_columns.map((col) => {
1061
+
1062
+ if (rec.length) {
1063
+ rec += fsep;
1064
+ }
1065
+
1066
+ rec += col.title;
1067
+ });
1068
+
1069
+ data += rec + lsep;
1070
+
1071
+ let count = this.m_dataview.count;
1072
+
1073
+ for (let i = 0; i < count; i++) {
1074
+
1075
+ let record = this.m_dataview.getByIndex(i);
1076
+
1077
+ rec = '';
1078
+ let cols = this.m_columns.map((col) => {
1079
+
1080
+ let text = record.getField(col.id);
1081
+ let fmt = col.formatter;
1082
+
1083
+ if (fmt && fmt instanceof Function) {
1084
+ text = fmt(text, record);
1085
+ }
1086
+
1087
+ if (rec.length > 0) {
1088
+ rec += fsep;
1089
+ }
1090
+
1091
+ rec += text;
1092
+ });
1093
+
1094
+ data += rec + lsep;
1095
+ }
1096
+
1097
+ //todo: review that
1098
+ data = data.replace(/[àâä]/gm, 'a');
1099
+ data = data.replace(/[éèê]/gm, 'e');
1100
+ data = data.replace(/[îï]/gm, 'i');
1101
+ data = data.replace(/[ûüù]/gm, 'u');
1102
+ data = data.replace(/ /gm, ' '); // non breaking space
1103
+
1104
+ downloadData(data, 'text/csv', filename);
1105
+ }
1106
+
1107
+ set empty_text(text: string | HtmlString) {
1108
+ this.m_empty_msg.text = text;
1109
+ }
1110
+
1111
+ private _renderCheck(rec: Record) {
1112
+ let icon = '--x4-icon-square';
1113
+ if (this.m_marks.has(rec.getID())) {
1114
+ icon = '--x4-icon-square-check';
1115
+ }
1116
+
1117
+ return new Icon({ icon: `var(${icon})` });
1118
+ }
1119
+
1120
+ private _toggleMark(rec: Record) {
1121
+
1122
+ let id = rec.getID();
1123
+ let chk = false;
1124
+
1125
+ if (this.m_marks.has(id)) {
1126
+ this.m_marks.delete(id);
1127
+ }
1128
+ else {
1129
+ this.m_marks.add(id);
1130
+ chk = true;
1131
+ }
1132
+
1133
+ this.emit( 'gridCheck', EvGridCheck(rec, chk));
1134
+ this._buildItems( false );
1135
+ }
1136
+
1137
+ public getMarks(): any[] {
1138
+ let ids = [];
1139
+ for (const v of this.m_marks.values()) {
1140
+ ids.push(v);
1141
+ }
1142
+
1143
+ return ids;
1144
+ }
1145
+
1146
+ public clearMarks() {
1147
+ if (this.m_marks.size) {
1148
+ this.m_marks = new Set<any>();
1149
+ this._buildItems( false );
1150
+ }
1151
+ }
1152
+
1153
+ public setFooterData( rec: any ) {
1154
+ if( !this.m_footer ) {
1155
+ return;
1156
+ }
1157
+
1158
+ this.m_footer.enumChilds( (c) => {
1159
+ let cid = c.getData( 'col' );
1160
+ if( cid ) {
1161
+ let col = this.m_columns[cid];
1162
+
1163
+ let value = rec[col.id];
1164
+ if( value!==undefined ) {
1165
+ if( isFunction(value) ) { // FooterRenderer
1166
+ value( c );
1167
+ }
1168
+ else {
1169
+ let text;
1170
+ const fmt = col.formatter;
1171
+ if (fmt && fmt instanceof Function) {
1172
+ text = fmt(value, rec);
1173
+ }
1174
+ else {
1175
+ text = value;
1176
+ }
1177
+
1178
+ c.setContent( text, false );
1179
+ }
1180
+ }
1181
+ }
1182
+ });
1183
+ }
1184
+ }
1185
+