x4js 1.6.4 → 2.0.1

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 (282) hide show
  1. package/README.md +3 -14
  2. package/lib/README.txt +3 -14
  3. package/lib/src/assets/house-light.svg +1 -0
  4. package/lib/src/assets/radio.svg +4 -0
  5. package/lib/src/components/base.scss +26 -0
  6. package/lib/src/components/boxes/boxes.module.scss +37 -0
  7. package/lib/src/components/boxes/boxes.ts +125 -0
  8. package/lib/src/components/btngroup/btngroup.module.scss +29 -0
  9. package/lib/src/components/btngroup/btngroup.ts +106 -0
  10. package/lib/src/components/button/button.module.scss +154 -0
  11. package/lib/src/components/button/button.ts +117 -0
  12. package/lib/src/components/calendar/calendar-check-sharp-light.svg +1 -0
  13. package/lib/src/components/calendar/calendar.module.scss +163 -0
  14. package/lib/src/{calendar.ts → components/calendar/calendar.ts} +81 -83
  15. package/lib/src/components/calendar/chevron-left-sharp-light.svg +1 -0
  16. package/lib/src/components/calendar/chevron-right-sharp-light.svg +1 -0
  17. package/lib/src/components/checkbox/check.svg +4 -0
  18. package/lib/src/components/checkbox/checkbox.module.scss +142 -0
  19. package/lib/src/components/checkbox/checkbox.ts +125 -0
  20. package/lib/src/components/colorinput/colorinput.module.scss +65 -0
  21. package/lib/src/components/colorinput/colorinput.ts +88 -0
  22. package/lib/src/components/colorinput/crosshairs-simple-sharp-light.svg +1 -0
  23. package/lib/src/components/colorpicker/colorpicker.module.scss +133 -0
  24. package/lib/src/components/colorpicker/colorpicker.ts +477 -0
  25. package/lib/src/components/combobox/combobox.module.scss +121 -0
  26. package/lib/src/components/combobox/combobox.ts +190 -0
  27. package/lib/src/components/combobox/updown.svg +4 -0
  28. package/lib/src/components/dialog/dialog.module.scss +71 -0
  29. package/lib/src/components/dialog/dialog.ts +91 -0
  30. package/lib/src/components/dialog/xmark-sharp-light.svg +1 -0
  31. package/lib/src/components/form/form.module.scss +34 -0
  32. package/lib/src/components/form/form.ts +36 -0
  33. package/lib/src/components/header/header.module.scss +40 -0
  34. package/lib/src/components/header/header.ts +124 -0
  35. package/lib/src/components/icon/icon.module.scss +30 -0
  36. package/lib/src/components/icon/icon.ts +134 -0
  37. package/lib/src/components/image/image.module.scss +21 -0
  38. package/lib/src/components/image/image.ts +67 -0
  39. package/lib/src/components/input/input.module.scss +69 -0
  40. package/lib/src/components/input/input.ts +274 -0
  41. package/lib/src/components/label/label.module.scss +52 -0
  42. package/lib/src/components/label/label.ts +55 -0
  43. package/lib/src/components/listbox/listbox.module.scss +103 -0
  44. package/lib/src/components/listbox/listbox.ts +427 -0
  45. package/lib/src/components/menu/caret-right-solid.svg +1 -0
  46. package/lib/src/components/menu/menu.module.scss +108 -0
  47. package/lib/src/components/menu/menu.ts +168 -0
  48. package/lib/src/components/messages/circle-exclamation.svg +1 -0
  49. package/lib/src/components/messages/messages.module.scss +47 -0
  50. package/lib/src/components/messages/messages.ts +64 -0
  51. package/lib/src/components/normalize.scss +386 -0
  52. package/lib/src/components/notification/circle-check-solid.svg +1 -0
  53. package/lib/src/components/notification/circle-exclamation-solid.svg +1 -0
  54. package/lib/src/components/notification/circle-notch-light.svg +1 -0
  55. package/lib/src/components/notification/notification.module.scss +82 -0
  56. package/lib/src/components/notification/notification.ts +108 -0
  57. package/lib/src/components/notification/xmark-sharp-light.svg +1 -0
  58. package/lib/src/components/panel/panel.module.scss +48 -0
  59. package/lib/src/components/panel/panel.ts +57 -0
  60. package/lib/src/components/popup/popup.module.scss +43 -0
  61. package/lib/src/components/popup/popup.ts +395 -0
  62. package/lib/src/components/progress/progress.module.scss +57 -0
  63. package/lib/src/components/progress/progress.ts +43 -0
  64. package/lib/src/components/rating/rating.module.scss +23 -0
  65. package/lib/src/components/rating/rating.ts +125 -0
  66. package/lib/src/components/rating/star-sharp-light.svg +1 -0
  67. package/lib/src/components/rating/star-sharp-solid.svg +1 -0
  68. package/lib/src/components/shared.scss +76 -0
  69. package/lib/src/components/sizers/sizer.module.scss +90 -0
  70. package/lib/src/components/sizers/sizer.ts +120 -0
  71. package/lib/src/components/slider/slider.module.scss +71 -0
  72. package/lib/src/components/slider/slider.ts +143 -0
  73. package/lib/src/components/switch/switch.module.scss +127 -0
  74. package/lib/src/components/switch/switch.ts +56 -0
  75. package/lib/src/components/tabs/tabs.module.scss +46 -0
  76. package/lib/src/components/tabs/tabs.ts +157 -0
  77. package/lib/src/components/textarea/textarea.module.scss +59 -0
  78. package/lib/src/components/textarea/textarea.ts +54 -0
  79. package/lib/src/components/textedit/textedit.module.scss +114 -0
  80. package/lib/src/components/textedit/textedit.ts +82 -0
  81. package/lib/src/components/themes.scss +77 -0
  82. package/lib/src/components/tooltips/circle-info-sharp-light.svg +1 -0
  83. package/lib/src/components/tooltips/tooltips.scss +51 -0
  84. package/lib/src/components/tooltips/tooltips.ts +103 -0
  85. package/lib/src/components/treeview/chevron-down-light.svg +1 -0
  86. package/lib/src/components/treeview/treeview.module.scss +116 -0
  87. package/lib/src/components/treeview/treeview.ts +403 -0
  88. package/lib/src/components/viewport/viewport.module.scss +25 -0
  89. package/lib/src/components/viewport/viewport.ts +38 -0
  90. package/lib/src/core/component.ts +979 -0
  91. package/lib/src/core/core_colors.ts +250 -0
  92. package/lib/src/{dom_events.ts → core/core_dom.ts} +195 -39
  93. package/lib/src/{drag_manager.ts → core/core_dragdrop.ts} +29 -44
  94. package/lib/src/core/core_element.ts +98 -0
  95. package/lib/src/core/core_events.ts +149 -0
  96. package/lib/src/{i18n.ts → core/core_i18n.ts} +43 -42
  97. package/lib/src/{router.ts → core/core_router.ts} +27 -40
  98. package/lib/src/core/core_styles.ts +215 -0
  99. package/lib/src/core/core_svg.ts +550 -0
  100. package/lib/src/core/core_tools.ts +673 -0
  101. package/lib/src/main.scss +21 -0
  102. package/lib/src/main.tsx +323 -0
  103. package/lib/src/x4.scss +19 -0
  104. package/lib/types/x4.d.ts +2624 -0
  105. package/package.json +67 -59
  106. package/scripts/build.mjs +351 -0
  107. package/scripts/prepack.mjs +15 -0
  108. package/src/assets/house-light.svg +1 -0
  109. package/src/assets/radio.svg +4 -0
  110. package/src/components/base.scss +26 -0
  111. package/src/components/boxes/boxes.module.scss +37 -0
  112. package/src/components/boxes/boxes.ts +125 -0
  113. package/src/components/btngroup/btngroup.module.scss +29 -0
  114. package/src/components/btngroup/btngroup.ts +106 -0
  115. package/src/components/button/button.module.scss +154 -0
  116. package/src/components/button/button.ts +117 -0
  117. package/src/components/calendar/calendar-check-sharp-light.svg +1 -0
  118. package/src/components/calendar/calendar.module.scss +163 -0
  119. package/src/components/calendar/calendar.ts +326 -0
  120. package/src/components/calendar/chevron-left-sharp-light.svg +1 -0
  121. package/src/components/calendar/chevron-right-sharp-light.svg +1 -0
  122. package/src/components/checkbox/check.svg +4 -0
  123. package/src/components/checkbox/checkbox.module.scss +142 -0
  124. package/src/components/checkbox/checkbox.ts +125 -0
  125. package/src/components/colorinput/colorinput.module.scss +65 -0
  126. package/src/components/colorinput/colorinput.ts +88 -0
  127. package/src/components/colorinput/crosshairs-simple-sharp-light.svg +1 -0
  128. package/src/components/colorpicker/colorpicker.module.scss +133 -0
  129. package/src/components/colorpicker/colorpicker.ts +477 -0
  130. package/src/components/combobox/combobox.module.scss +121 -0
  131. package/src/components/combobox/combobox.ts +190 -0
  132. package/src/components/combobox/updown.svg +4 -0
  133. package/src/components/dialog/dialog.module.scss +71 -0
  134. package/src/components/dialog/dialog.ts +91 -0
  135. package/src/components/dialog/xmark-sharp-light.svg +1 -0
  136. package/src/components/form/form.module.scss +34 -0
  137. package/src/components/form/form.ts +36 -0
  138. package/src/components/header/header.module.scss +40 -0
  139. package/src/components/header/header.ts +124 -0
  140. package/src/components/icon/icon.module.scss +30 -0
  141. package/src/components/icon/icon.ts +134 -0
  142. package/src/components/image/image.module.scss +21 -0
  143. package/src/components/image/image.ts +67 -0
  144. package/src/components/input/input.module.scss +69 -0
  145. package/src/components/input/input.ts +274 -0
  146. package/src/components/label/label.module.scss +52 -0
  147. package/src/components/label/label.ts +55 -0
  148. package/src/components/listbox/listbox.module.scss +103 -0
  149. package/src/components/listbox/listbox.ts +427 -0
  150. package/src/components/menu/caret-right-solid.svg +1 -0
  151. package/src/components/menu/menu.module.scss +108 -0
  152. package/src/components/menu/menu.ts +168 -0
  153. package/src/components/messages/circle-exclamation.svg +1 -0
  154. package/src/components/messages/messages.module.scss +47 -0
  155. package/src/components/messages/messages.ts +64 -0
  156. package/src/components/normalize.scss +386 -0
  157. package/src/components/notification/circle-check-solid.svg +1 -0
  158. package/src/components/notification/circle-exclamation-solid.svg +1 -0
  159. package/src/components/notification/circle-notch-light.svg +1 -0
  160. package/src/components/notification/notification.module.scss +82 -0
  161. package/src/components/notification/notification.ts +108 -0
  162. package/src/components/notification/xmark-sharp-light.svg +1 -0
  163. package/src/components/panel/panel.module.scss +48 -0
  164. package/src/components/panel/panel.ts +57 -0
  165. package/src/components/popup/popup.module.scss +43 -0
  166. package/src/components/popup/popup.ts +395 -0
  167. package/src/components/progress/progress.module.scss +57 -0
  168. package/src/components/progress/progress.ts +43 -0
  169. package/src/components/rating/rating.module.scss +23 -0
  170. package/src/components/rating/rating.ts +125 -0
  171. package/src/components/rating/star-sharp-light.svg +1 -0
  172. package/src/components/rating/star-sharp-solid.svg +1 -0
  173. package/src/components/shared.scss +76 -0
  174. package/src/components/sizers/sizer.module.scss +90 -0
  175. package/src/components/sizers/sizer.ts +120 -0
  176. package/src/components/slider/slider.module.scss +71 -0
  177. package/src/components/slider/slider.ts +143 -0
  178. package/src/components/switch/switch.module.scss +127 -0
  179. package/src/components/switch/switch.ts +56 -0
  180. package/src/components/tabs/tabs.module.scss +46 -0
  181. package/src/components/tabs/tabs.ts +157 -0
  182. package/src/components/textarea/textarea.module.scss +59 -0
  183. package/src/components/textarea/textarea.ts +54 -0
  184. package/src/components/textedit/textedit.module.scss +114 -0
  185. package/src/components/textedit/textedit.ts +82 -0
  186. package/src/components/themes.scss +77 -0
  187. package/src/components/tooltips/circle-info-sharp-light.svg +1 -0
  188. package/src/components/tooltips/tooltips.scss +51 -0
  189. package/src/components/tooltips/tooltips.ts +103 -0
  190. package/src/components/treeview/chevron-down-light.svg +1 -0
  191. package/src/components/treeview/treeview.module.scss +116 -0
  192. package/src/components/treeview/treeview.ts +403 -0
  193. package/src/components/viewport/viewport.module.scss +25 -0
  194. package/src/components/viewport/viewport.ts +38 -0
  195. package/src/core/component.ts +979 -0
  196. package/src/core/core_colors.ts +250 -0
  197. package/src/core/core_dom.ts +471 -0
  198. package/src/core/core_dragdrop.ts +201 -0
  199. package/src/core/core_element.ts +98 -0
  200. package/src/core/core_events.ts +149 -0
  201. package/src/core/core_i18n.ts +377 -0
  202. package/src/core/core_router.ts +221 -0
  203. package/src/core/core_styles.ts +215 -0
  204. package/src/core/core_svg.ts +550 -0
  205. package/src/core/core_tools.ts +673 -0
  206. package/src/main.scss +21 -0
  207. package/src/main.tsx +323 -0
  208. package/src/x4.scss +19 -0
  209. package/tsconfig.json +14 -0
  210. package/types/scss.d.ts +4 -0
  211. package/types/svg.d.ts +4 -0
  212. package/types/x4react.d.ts +9 -0
  213. package/lib/changelog.txt +0 -23
  214. package/lib/cjs/x4js.js +0 -39
  215. package/lib/cjs/x4js.js.map +0 -7
  216. package/lib/esm/x4js.mjs +0 -15972
  217. package/lib/esm/x4js.mjs.map +0 -7
  218. package/lib/licence.md +0 -21
  219. package/lib/src/MIT-license.md +0 -14
  220. package/lib/src/action.ts +0 -88
  221. package/lib/src/alpha.jpg +0 -0
  222. package/lib/src/app_sockets.ts +0 -81
  223. package/lib/src/application.ts +0 -262
  224. package/lib/src/autocomplete.ts +0 -232
  225. package/lib/src/base64.ts +0 -166
  226. package/lib/src/base_component.ts +0 -152
  227. package/lib/src/button.ts +0 -355
  228. package/lib/src/canvas.ts +0 -510
  229. package/lib/src/cardview.ts +0 -228
  230. package/lib/src/checkbox.ts +0 -188
  231. package/lib/src/color.ts +0 -752
  232. package/lib/src/colorpicker.ts +0 -1649
  233. package/lib/src/combobox.ts +0 -512
  234. package/lib/src/component.ts +0 -2367
  235. package/lib/src/copyright.txt +0 -27
  236. package/lib/src/datastore.ts +0 -1302
  237. package/lib/src/dialog.ts +0 -656
  238. package/lib/src/drawtext.ts +0 -355
  239. package/lib/src/fileupload.ts +0 -213
  240. package/lib/src/form.ts +0 -413
  241. package/lib/src/formatters.ts +0 -105
  242. package/lib/src/gridview.ts +0 -1185
  243. package/lib/src/icon.ts +0 -362
  244. package/lib/src/image.ts +0 -225
  245. package/lib/src/index.ts +0 -89
  246. package/lib/src/input.ts +0 -297
  247. package/lib/src/label.ts +0 -153
  248. package/lib/src/layout.ts +0 -442
  249. package/lib/src/link.ts +0 -86
  250. package/lib/src/listview.ts +0 -765
  251. package/lib/src/md5.ts +0 -438
  252. package/lib/src/menu.ts +0 -425
  253. package/lib/src/messagebox.ts +0 -224
  254. package/lib/src/panel.ts +0 -86
  255. package/lib/src/popup.ts +0 -494
  256. package/lib/src/property_editor.ts +0 -337
  257. package/lib/src/radiobtn.ts +0 -197
  258. package/lib/src/rating.ts +0 -135
  259. package/lib/src/request.ts +0 -300
  260. package/lib/src/settings.ts +0 -77
  261. package/lib/src/sidebarview.ts +0 -108
  262. package/lib/src/spreadsheet.ts +0 -1449
  263. package/lib/src/styles.ts +0 -343
  264. package/lib/src/svgcomponent.ts +0 -592
  265. package/lib/src/tabbar.ts +0 -151
  266. package/lib/src/tabview.ts +0 -110
  267. package/lib/src/textarea.ts +0 -235
  268. package/lib/src/textedit.ts +0 -533
  269. package/lib/src/toaster.ts +0 -80
  270. package/lib/src/tools.ts +0 -1473
  271. package/lib/src/tooltips.ts +0 -191
  272. package/lib/src/treeview.ts +0 -716
  273. package/lib/src/version.ts +0 -30
  274. package/lib/src/x4.less +0 -2242
  275. package/lib/src/x4dom.ts +0 -57
  276. package/lib/src/x4events.ts +0 -585
  277. package/lib/src/x4js.ts +0 -89
  278. package/lib/src/x4react.ts +0 -90
  279. package/lib/styles/x4.css +0 -1785
  280. package/lib/styles/x4.less +0 -2242
  281. package/lib/types/x4js.d.ts +0 -6728
  282. package/license.md +0 -21
@@ -1,1185 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|
7
- *
8
- * @file gridview.ts
9
- * @author Etienne Cochard
10
- *
11
- * Copyright (c) 2019-2023 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
-