x4js 2.0.20 → 2.0.22

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 (173) hide show
  1. package/lib/cjs/x4.css +1 -1
  2. package/lib/cjs/x4.js +2 -2
  3. package/lib/esm/x4.css +1 -1
  4. package/lib/esm/x4.mjs +2 -2
  5. package/lib/styles/x4.css +1 -1
  6. package/lib/types/x4js.d.ts +93 -77
  7. package/package.json +1 -1
  8. package/src/components/boxes/boxes.ts +33 -1
  9. package/src/components/canvas/canvas.ts +9 -3
  10. package/src/components/combobox/combobox.module.scss +13 -0
  11. package/src/components/combobox/combobox.ts +7 -0
  12. package/src/components/form/form.ts +4 -4
  13. package/src/components/gridview/gridview.ts +12 -9
  14. package/src/components/header/header.module.scss +2 -1
  15. package/src/components/header/header.ts +17 -5
  16. package/src/components/icon/icon.module.scss +1 -0
  17. package/src/components/label/label.module.scss +6 -1
  18. package/src/components/listbox/listbox.module.scss +35 -31
  19. package/src/components/listbox/listbox.ts +50 -12
  20. package/src/components/messages/messages.ts +14 -0
  21. package/src/components/notification/notification.ts +1 -1
  22. package/src/components/popup/popup.ts +13 -2
  23. package/src/components/propgrid/propgrid.ts +4 -2
  24. package/src/components/sizers/sizer.ts +4 -4
  25. package/src/components/tabs/tabs.module.scss +2 -2
  26. package/src/components/tabs/tabs.ts +28 -4
  27. package/src/components/textedit/textedit.ts +1 -1
  28. package/src/components/treeview/treeview.module.scss +9 -1
  29. package/src/components/treeview/treeview.ts +52 -13
  30. package/src/core/component.ts +46 -9
  31. package/src/core/core_data.ts +8 -8
  32. package/src/core/core_state.ts +1 -1
  33. package/src/core/core_tools.ts +2 -0
  34. package/lib/src/components/base.scss +0 -25
  35. package/lib/src/components/boxes/boxes.module.scss +0 -54
  36. package/lib/src/components/boxes/boxes.ts +0 -370
  37. package/lib/src/components/breadcrumb/breadcrumb.scss +0 -56
  38. package/lib/src/components/breadcrumb/breadcrumb.ts +0 -93
  39. package/lib/src/components/breadcrumb/chevron-right.svg +0 -1
  40. package/lib/src/components/btngroup/btngroup.module.scss +0 -41
  41. package/lib/src/components/btngroup/btngroup.ts +0 -153
  42. package/lib/src/components/button/button.module.scss +0 -173
  43. package/lib/src/components/button/button.ts +0 -185
  44. package/lib/src/components/calendar/calendar-check-sharp-light.svg +0 -1
  45. package/lib/src/components/calendar/calendar.module.scss +0 -163
  46. package/lib/src/components/calendar/calendar.ts +0 -327
  47. package/lib/src/components/calendar/chevron-left-sharp-light.svg +0 -1
  48. package/lib/src/components/calendar/chevron-right-sharp-light.svg +0 -1
  49. package/lib/src/components/canvas/canvas.module.scss +0 -25
  50. package/lib/src/components/canvas/canvas.ts +0 -189
  51. package/lib/src/components/canvas/canvas_ex.ts +0 -276
  52. package/lib/src/components/checkbox/check.svg +0 -4
  53. package/lib/src/components/checkbox/checkbox.module.scss +0 -142
  54. package/lib/src/components/checkbox/checkbox.ts +0 -140
  55. package/lib/src/components/colorinput/colorinput.module.scss +0 -65
  56. package/lib/src/components/colorinput/colorinput.ts +0 -91
  57. package/lib/src/components/colorinput/crosshairs-simple-sharp-light.svg +0 -1
  58. package/lib/src/components/colorpicker/colorpicker.module.scss +0 -133
  59. package/lib/src/components/colorpicker/colorpicker.ts +0 -482
  60. package/lib/src/components/combobox/combobox.module.scss +0 -133
  61. package/lib/src/components/combobox/combobox.ts +0 -275
  62. package/lib/src/components/combobox/updown.svg +0 -4
  63. package/lib/src/components/components.ts +0 -42
  64. package/lib/src/components/dialog/dialog.module.scss +0 -104
  65. package/lib/src/components/dialog/dialog.ts +0 -229
  66. package/lib/src/components/dialog/xmark-sharp-light.svg +0 -1
  67. package/lib/src/components/filedrop/cloud-arrow-up.svg +0 -1
  68. package/lib/src/components/filedrop/filedrop.module.scss +0 -70
  69. package/lib/src/components/filedrop/filedrop.ts +0 -131
  70. package/lib/src/components/form/form.module.scss +0 -38
  71. package/lib/src/components/form/form.ts +0 -172
  72. package/lib/src/components/gridview/arrow-down-light.svg +0 -1
  73. package/lib/src/components/gridview/arrow-up-light.svg +0 -1
  74. package/lib/src/components/gridview/gridview.module.scss +0 -324
  75. package/lib/src/components/gridview/gridview.ts +0 -1175
  76. package/lib/src/components/header/header.module.scss +0 -40
  77. package/lib/src/components/header/header.ts +0 -130
  78. package/lib/src/components/icon/icon.module.scss +0 -31
  79. package/lib/src/components/icon/icon.ts +0 -137
  80. package/lib/src/components/image/image.module.scss +0 -28
  81. package/lib/src/components/image/image.ts +0 -168
  82. package/lib/src/components/input/input.module.scss +0 -74
  83. package/lib/src/components/input/input.ts +0 -422
  84. package/lib/src/components/keyboard/arrow-up.svg +0 -1
  85. package/lib/src/components/keyboard/delete-left.svg +0 -1
  86. package/lib/src/components/keyboard/eye-slash.svg +0 -1
  87. package/lib/src/components/keyboard/keyboard.module.scss +0 -134
  88. package/lib/src/components/keyboard/keyboard.ts +0 -526
  89. package/lib/src/components/label/label.module.scss +0 -76
  90. package/lib/src/components/label/label.ts +0 -97
  91. package/lib/src/components/link/link.ts +0 -81
  92. package/lib/src/components/listbox/listbox.module.scss +0 -161
  93. package/lib/src/components/listbox/listbox.ts +0 -539
  94. package/lib/src/components/menu/caret-right-solid.svg +0 -1
  95. package/lib/src/components/menu/menu.module.scss +0 -117
  96. package/lib/src/components/menu/menu.ts +0 -174
  97. package/lib/src/components/messages/circle-exclamation.svg +0 -1
  98. package/lib/src/components/messages/messages.module.scss +0 -92
  99. package/lib/src/components/messages/messages.ts +0 -215
  100. package/lib/src/components/messages/pen-field.svg +0 -1
  101. package/lib/src/components/normalize.scss +0 -391
  102. package/lib/src/components/notification/circle-check-solid.svg +0 -1
  103. package/lib/src/components/notification/circle-exclamation-solid.svg +0 -1
  104. package/lib/src/components/notification/circle-notch-light.svg +0 -1
  105. package/lib/src/components/notification/notification.module.scss +0 -84
  106. package/lib/src/components/notification/notification.ts +0 -107
  107. package/lib/src/components/notification/xmark-sharp-light.svg +0 -1
  108. package/lib/src/components/panel/panel.module.scss +0 -60
  109. package/lib/src/components/panel/panel.ts +0 -58
  110. package/lib/src/components/popup/popup.module.scss +0 -51
  111. package/lib/src/components/popup/popup.ts +0 -442
  112. package/lib/src/components/progress/progress.module.scss +0 -57
  113. package/lib/src/components/progress/progress.ts +0 -44
  114. package/lib/src/components/propgrid/folder-closed.svg +0 -1
  115. package/lib/src/components/propgrid/folder-open.svg +0 -1
  116. package/lib/src/components/propgrid/progrid.module.scss +0 -112
  117. package/lib/src/components/propgrid/propgrid.ts +0 -288
  118. package/lib/src/components/propgrid/updown.svg +0 -4
  119. package/lib/src/components/radio/radio.module.scss +0 -147
  120. package/lib/src/components/radio/radio.svg +0 -4
  121. package/lib/src/components/radio/radio.ts +0 -142
  122. package/lib/src/components/rating/rating.module.scss +0 -23
  123. package/lib/src/components/rating/rating.ts +0 -131
  124. package/lib/src/components/rating/star-sharp-light.svg +0 -1
  125. package/lib/src/components/rating/star-sharp-solid.svg +0 -1
  126. package/lib/src/components/select/select.module.scss +0 -9
  127. package/lib/src/components/select/select.ts +0 -134
  128. package/lib/src/components/shared.scss +0 -137
  129. package/lib/src/components/sizers/sizer.module.scss +0 -90
  130. package/lib/src/components/sizers/sizer.ts +0 -132
  131. package/lib/src/components/slider/slider.module.scss +0 -118
  132. package/lib/src/components/slider/slider.ts +0 -198
  133. package/lib/src/components/switch/switch.module.scss +0 -127
  134. package/lib/src/components/switch/switch.ts +0 -62
  135. package/lib/src/components/tabs/tabs.module.scss +0 -45
  136. package/lib/src/components/tabs/tabs.ts +0 -205
  137. package/lib/src/components/textarea/textarea.module.scss +0 -63
  138. package/lib/src/components/textarea/textarea.ts +0 -125
  139. package/lib/src/components/textedit/textedit.module.scss +0 -116
  140. package/lib/src/components/textedit/textedit.ts +0 -115
  141. package/lib/src/components/themes.scss +0 -88
  142. package/lib/src/components/tickline/tickline.module.scss +0 -26
  143. package/lib/src/components/tickline/tickline.ts +0 -82
  144. package/lib/src/components/tooltips/circle-info-sharp-light.svg +0 -1
  145. package/lib/src/components/tooltips/comments-question.svg +0 -1
  146. package/lib/src/components/tooltips/tooltips.scss +0 -72
  147. package/lib/src/components/tooltips/tooltips.ts +0 -109
  148. package/lib/src/components/treeview/chevron-down-light.svg +0 -1
  149. package/lib/src/components/treeview/treeview.module.scss +0 -185
  150. package/lib/src/components/treeview/treeview.ts +0 -445
  151. package/lib/src/components/viewport/viewport.module.scss +0 -32
  152. package/lib/src/components/viewport/viewport.ts +0 -41
  153. package/lib/src/core/component.ts +0 -1066
  154. package/lib/src/core/core_application.ts +0 -265
  155. package/lib/src/core/core_colors.ts +0 -250
  156. package/lib/src/core/core_data.ts +0 -1310
  157. package/lib/src/core/core_dom.ts +0 -471
  158. package/lib/src/core/core_dragdrop.ts +0 -201
  159. package/lib/src/core/core_element.ts +0 -115
  160. package/lib/src/core/core_events.ts +0 -177
  161. package/lib/src/core/core_i18n.ts +0 -393
  162. package/lib/src/core/core_react.ts +0 -79
  163. package/lib/src/core/core_router.ts +0 -237
  164. package/lib/src/core/core_state.ts +0 -62
  165. package/lib/src/core/core_styles.ts +0 -214
  166. package/lib/src/core/core_svg.ts +0 -712
  167. package/lib/src/core/core_tools.ts +0 -906
  168. package/lib/src/types/scss.d.ts +0 -4
  169. package/lib/src/types/svg.d.ts +0 -1
  170. package/lib/src/types/x4react.d.ts +0 -9
  171. package/lib/src/x4.scss +0 -19
  172. package/lib/src/x4.ts +0 -35
  173. package/lib/src/x4tsx.d.ts +0 -25
@@ -1,539 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|
7
- *
8
- * @file listbox.ts
9
- * @author Etienne Cochard
10
- *
11
- * @copyright (c) 2024 R-libre ingenierie
12
- *
13
- * Use of this source code is governed by an MIT-style license
14
- * that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
15
- **/
16
-
17
- import { Component, ComponentEvent, ComponentEvents, componentFromDOM, ComponentProps, EvChange, EvClick, EvContextMenu, EvDblClick, EvSelectionChange } from '../../core/component';
18
- import { EventCallback } from '../../core/core_events';
19
- import { kbNav, class_ns, isArray, UnsafeHtml } from '../../core/core_tools';
20
-
21
- import { ScrollView, Viewport } from '../viewport/viewport';
22
- import { HBox } from '../boxes/boxes';
23
- import { Label } from '../label/label';
24
-
25
- import "./listbox.module.scss"
26
-
27
- export type ListboxID = number | string;
28
-
29
- export interface ListItem {
30
- id: ListboxID;
31
- text: string | UnsafeHtml;
32
-
33
- iconId?: string;
34
- data?: any;
35
- cls?: string;
36
- checked?: boolean;
37
- }
38
-
39
- /**
40
- *
41
- */
42
-
43
- interface ListboxEvents extends ComponentEvents {
44
- //change: EvChange;
45
- click?: EvClick;
46
- dblClick?: EvDblClick;
47
- contextMenu?: EvContextMenu;
48
- selectionChange?: EvSelectionChange;
49
- }
50
-
51
- /**
52
- *
53
- */
54
-
55
- interface ListboxProps extends Omit<ComponentProps,'content'> {
56
- items?: ListItem[];
57
- renderer?: ( item: ListItem ) => Component;
58
- //header?: Header;
59
- footer?: Component,
60
- checkable?: true,
61
- multisel?: true,
62
-
63
- dblClick?: EventCallback<EvDblClick>;
64
- selectionChange?: EventCallback<EvSelectionChange>;
65
- contextMenu?: EventCallback<EvContextMenu>;
66
- }
67
-
68
- /**
69
- *
70
- */
71
-
72
- @class_ns( "x4" )
73
- export class Listbox extends Component<ListboxProps,ListboxEvents> {
74
-
75
- private _view: Viewport;
76
- //private _selection: ListboxID;
77
- //private _selitem: Component;
78
-
79
- private _lastsel: ListboxID;
80
-
81
- private _multisel: Set<ListboxID>;
82
- private _items: ListItem[];
83
-
84
- preventFocus = false;
85
-
86
- constructor( props: ListboxProps ) {
87
- super( { ...props } );
88
-
89
- this.setAttribute( "tabindex", 0 );
90
- this.mapPropEvents( props, "dblClick", "selectionChange", "contextMenu" );
91
-
92
- const scroller = new ScrollView( { cls: "body" } );
93
- this._view = scroller.getViewport( );
94
- this._multisel = new Set( );
95
- this._items = [];
96
-
97
- if( props.footer ) {
98
- props.footer.setAttribute( "id", "footer" );
99
- }
100
-
101
- this.setContent( [
102
- //props.header ? props.header : null,
103
- scroller,
104
- props.footer,
105
- ] );
106
-
107
- this.setDOMEvents( {
108
- click: (ev) => this._on_click( ev ),
109
- keydown: ( ev ) => this._on_key( ev ),
110
- dblclick: (e) => this._on_click(e),
111
- contextmenu: (e) => this._on_ctx_menu(e),
112
- } );
113
-
114
- if( props.items ) {
115
- this.setItems( props.items );
116
- }
117
- }
118
-
119
- /**
120
- *
121
- */
122
-
123
- private _on_key( ev: KeyboardEvent ) {
124
- if( this.isDisabled() ) {
125
- return;
126
- }
127
-
128
- switch( ev.key ) {
129
- case "ArrowDown": {
130
- this.navigate( kbNav.next );
131
- break;
132
- }
133
-
134
- case "ArrowUp": {
135
- this.navigate( kbNav.prev );
136
- break;
137
- }
138
-
139
- case "Home": {
140
- this.navigate( kbNav.first );
141
- break;
142
- }
143
-
144
- case "End": {
145
- this.navigate( kbNav.last );
146
- break;
147
- }
148
-
149
- default:
150
- return;
151
- }
152
-
153
- ev.preventDefault( );
154
- ev.stopPropagation( );
155
- }
156
-
157
- /**
158
- *
159
- */
160
-
161
- navigate( sens: kbNav ) {
162
-
163
- if( !this._lastsel ) {
164
- if( sens==kbNav.next ) sens = kbNav.first;
165
- else sens = kbNav.last;
166
- }
167
-
168
- const next_visible = ( el: Component, down: boolean ) => {
169
-
170
- while( el && !el.isVisible() ) {
171
- el = down ? el.nextElement() : el.prevElement();
172
- }
173
-
174
- return el;
175
- }
176
-
177
- if( sens==kbNav.first || sens==kbNav.last ) {
178
- let fel = sens==kbNav.first ? this._view.firstChild() : this._view.lastChild( );
179
- fel = next_visible( fel, sens==kbNav.first );
180
-
181
- if( fel ) {
182
- const id = fel.getInternalData( "id" );
183
- this._selectItem( id, fel, 'single' );
184
- return true;
185
- }
186
- }
187
- else {
188
- const selitem = this._itemWithID( this._lastsel );
189
- let nel = sens==kbNav.next ? selitem.nextElement() : selitem.prevElement();
190
- nel = next_visible( nel, sens==kbNav.next );
191
-
192
- if( nel ) {
193
- const id = nel.getInternalData( "id" );
194
- this._selectItem( id, nel, 'single' );
195
- return true;
196
- }
197
- }
198
-
199
- return false;
200
- }
201
-
202
- /**
203
- *
204
- */
205
-
206
- private _itemWithID( id: ListboxID ) {
207
- //const itm = this.query( `[data-id="${id}"]` );
208
- const all = this._view.enumChildComponents( false );
209
- return all.find( x => x.getInternalData("id")===id )
210
- }
211
-
212
- /**
213
- *
214
- */
215
-
216
- private _on_click( ev: MouseEvent ) {
217
- let target = ev.target as HTMLElement;
218
-
219
- while( target && target!=this.dom ) {
220
- const c = componentFromDOM( target );
221
-
222
- // avoid trapping child ckick
223
- if( c.dom.tagName==='INPUT' ) {
224
- return;
225
- }
226
-
227
- if( c && c.hasClass("x4item") ) {
228
- const id = c.getInternalData( "id" );
229
- const fev: ComponentEvent = { context:id };
230
- if (ev.type == 'click') {
231
- this.fire('click', fev );
232
- }
233
- else {
234
- this.fire('dblClick', fev );
235
- }
236
-
237
- if (!fev.defaultPrevented) {
238
- this._selectItem( id, c, ev.ctrlKey ? 'toggle' : 'single' );
239
- }
240
-
241
- return;
242
- }
243
-
244
- target = target.parentElement;
245
- }
246
-
247
- this.clearSelection( );
248
-
249
- ev.stopImmediatePropagation();
250
- ev.preventDefault( );
251
- }
252
-
253
- /**
254
- *
255
- */
256
-
257
- private _on_ctx_menu(ev: MouseEvent) {
258
-
259
- ev.preventDefault();
260
-
261
- let target = ev.target as HTMLElement;
262
- while( target && target!=this.dom ) {
263
- const c = componentFromDOM( target );
264
- if( c && c.hasClass("x4item") ) {
265
- const id = c.getInternalData( "id" );
266
-
267
- this._selectItem(id, c, 'single' );
268
- this.fire('contextMenu', {uievent: ev, context: id } );
269
-
270
- return;
271
- }
272
-
273
- target = target.parentElement;
274
- }
275
-
276
- this.fire('contextMenu', { uievent:ev, context: null } );
277
- }
278
-
279
- /**
280
- *
281
- */
282
-
283
- private _selectItem( id: ListboxID, item: Component, mode: "single" | "toggle" ) {
284
-
285
- if( !this.props.multisel ) {
286
- mode = 'single';
287
- }
288
-
289
- this._lastsel = id;
290
-
291
- if( mode=='single' ) {
292
- if( this._multisel.has(id) ) {
293
- return;
294
- }
295
-
296
- this._clearSelection( );
297
- if( item ) {
298
- this._multisel.add( id );
299
- item.addClass( "selected" );
300
- }
301
- }
302
- else { // toggle
303
- if( item ) {
304
- if( this._multisel.has(id) ) {
305
- item.removeClass( "selected" );
306
- this._multisel.delete( id );
307
- }
308
- else {
309
- this._multisel.add( id );
310
- item.addClass( "selected" );
311
- }
312
- }
313
- }
314
-
315
- if( item ) {
316
- item.scrollIntoView( {
317
- behavior: "smooth",
318
- block: "nearest"
319
- } );
320
- }
321
-
322
- this.fire( "selectionChange", { selection: this.getSelection(), empty: this._multisel.size==0 } );
323
- }
324
-
325
- /**
326
- *
327
- */
328
-
329
- getItem( id: ListboxID ): ListItem {
330
- return this._items.find( x => x.id===id );
331
- }
332
-
333
- /**
334
- * select an item by it's id
335
- */
336
-
337
- select( ids: ListboxID | ListboxID[], notify = true ) {
338
-
339
- if( !isArray(ids) ) {
340
- ids = [ids];
341
- }
342
-
343
- if( !ids.length ) {
344
- if( this._multisel.size ) {
345
- this.clearSelection( );
346
- }
347
-
348
- return;
349
- }
350
-
351
- // if one of new selection not in old selection...
352
- if( ids.some( x => !this._multisel.has(x)) ) {
353
- this._clearSelection( );
354
- const all = this._view.enumChildComponents( false );
355
-
356
- ids.forEach( id => {
357
- const itm = all.find( x => x.getInternalData("id")===id ); //this.query( `[data-id="${id}"]` );
358
- if( itm ) {
359
- this._multisel.add( id );
360
- itm.addClass( "selected" );
361
- }
362
- });
363
-
364
- this.fire( "selectionChange", { selection: this.getSelection(), empty: this._multisel.size==0 } );
365
- }
366
- }
367
-
368
- /**
369
- *
370
- */
371
-
372
- private _findItemIndex( id: ListboxID ) {
373
- return this._items.findIndex( x => x.id==id );
374
- }
375
-
376
- /**
377
- *
378
- */
379
-
380
- private _clearSelection( ) {
381
-
382
- const all = this._view.enumChildComponents( false );
383
-
384
- if( this._multisel.size ) {
385
- const ids = Array.from( this._multisel );
386
- ids.forEach( id => {
387
- const itm = all.find( x => x.getInternalData("id")===id ); //this.query( `[data-id="${id}"]` );
388
- if( itm ) {
389
- itm.removeClass( "selected" );
390
- }
391
- } );
392
- }
393
-
394
- this._multisel.clear( );
395
- }
396
-
397
- clearSelection( ) {
398
- if( this._multisel.size ) {
399
- this._clearSelection( );
400
- this.fire( "selectionChange", { selection: [], empty: true } );
401
- }
402
- }
403
-
404
- /**
405
- *
406
- */
407
-
408
- setItems( items: ListItem[], keepSel = false ) {
409
-
410
- const oldSel = this.getSelection( );
411
-
412
- this.clearSelection( );
413
- this._view.clearContent( );
414
- this._items = items;
415
-
416
- if( items ) {
417
- const content = items.map( x => this.renderItem(x) );
418
- this._view.setContent( content );
419
-
420
- if( keepSel ) {
421
- this.select( oldSel );
422
- }
423
- }
424
- }
425
-
426
- /**
427
- *
428
- */
429
-
430
- renderItem( item: ListItem ) {
431
- const renderer = this.props.renderer ?? this.defaultRenderer;
432
- const line = renderer( item );
433
-
434
- line.addClass( "x4item" );
435
- line.setInternalData( "id", item.id );
436
-
437
- return line;
438
- }
439
-
440
- /**
441
- *
442
- */
443
-
444
- defaultRenderer( item: ListItem ): Component {
445
- return new HBox( {
446
- cls: item.cls,
447
- content: new Label( { icon: item.iconId, text: item.text })
448
- } )
449
- }
450
-
451
- /**
452
- *
453
- */
454
-
455
- filter( filter: string ) {
456
- const childs = this._view.enumChildComponents( false );
457
-
458
- if( !filter ) {
459
- childs.forEach( x => x.show( true ) );
460
- }
461
- else {
462
- // get list of visible items
463
- const filtred = this._items
464
- .filter( x => x.text.includes(filter) )
465
- .map( x => x.id+'' );
466
-
467
- // now hide all elements not in list
468
- childs.forEach( x => {
469
- x.show( filtred.includes( x.getInternalData( "id" ) ) );
470
- });
471
- }
472
- }
473
-
474
- /**
475
- * append or prepend a new item
476
- * @param item
477
- * @param prepend
478
- * @param select
479
- */
480
-
481
- appendItem( item: ListItem, prepend = false, select = true ) {
482
-
483
- if( select ) {
484
- this._clearSelection( );
485
- }
486
-
487
- let el = this.renderItem( item );
488
-
489
- if( prepend ) {
490
- this._items.unshift( item );
491
- this._view.prependContent( el );
492
- }
493
- else {
494
- this._items.push( item );
495
- this._view.appendContent( el );
496
- }
497
-
498
- if( select ) {
499
- this._selectItem( item.id, el, 'single' );
500
- }
501
- }
502
-
503
- /**
504
- * update an item
505
- */
506
-
507
- updateItem( id: any, item: ListItem ) {
508
-
509
- // find item
510
- const idx = this._findItemIndex( id );
511
- if( idx<0 ) {
512
- return;
513
- }
514
-
515
- // take care of selection
516
- let was_sel = false;
517
- if( this._multisel.has(id) ) {
518
- was_sel = true;
519
- }
520
-
521
- // replace it in the list
522
- this._items[idx] = item;
523
-
524
- // rebuild & replace it's line
525
- const old = this._itemWithID( item.id );
526
- if( old?.dom ) {
527
- const _new = this.renderItem( item );
528
- if( was_sel ) {
529
- _new.addClass( "selected" );
530
- }
531
-
532
- this._view.dom.replaceChild( _new.dom, old.dom );
533
- }
534
- }
535
-
536
- getSelection( ) {
537
- return Array.from( this._multisel );
538
- }
539
- }
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 512" fill="var(--color-gray-8)"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M246.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-128-128c-9.2-9.2-22.9-11.9-34.9-6.9s-19.8 16.6-19.8 29.6l0 256c0 12.9 7.8 24.6 19.8 29.6s25.7 2.2 34.9-6.9l128-128z"/></svg>
@@ -1,117 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|
7
- *
8
- * @file menu.module.scss
9
- * @author Etienne Cochard
10
- *
11
- * @copyright (c) 2024 R-libre ingenierie
12
- *
13
- * Use of this source code is governed by an MIT-style license
14
- * that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
15
- **/
16
-
17
- @use "../shared.scss";
18
-
19
- :root {
20
- --menu-background: var( --background-primary );
21
- --menu-border: var( --border-hover );
22
-
23
- --menuitem-color: var( --text-ternary );;
24
- --menuitem-background-active: var( --accent-background-active );
25
- --menuitem-color-active: var( --accent-color-active );
26
- --menuitem-background-hover: var( --accent-background-hover );
27
- --menuitem-color-hover: var( --accent-color-hover );
28
- }
29
-
30
- .x4menu {
31
- @extend .shadow-lg;
32
-
33
- position: absolute;
34
- overflow-y: auto;
35
-
36
- border-radius: var(--bradius);
37
- padding: 8px 0;
38
- min-width: 150px;
39
-
40
- background-color: var(--menu-background);
41
- border: 1px solid var(--menu-border);
42
-
43
- max-height: calc( 100vh - 32px );
44
-
45
- .x4cmenuitem {
46
- @extend .hbox;
47
-
48
- transition: background-color 0.3s, color 0.3s;
49
-
50
- align-items: center;
51
- color: var(--menuitem-color);
52
-
53
- padding: 6px;
54
- gap: 10px;
55
-
56
- cursor: pointer;
57
-
58
- #icon {
59
- width: 16px;
60
- height: 16px;
61
-
62
- .fa-primary {
63
- fill: var( --color-primary-a50 );
64
- }
65
-
66
- .fa-secondary {
67
- fill: var( --color-primary-a30 );
68
- opacity: 1;
69
- }
70
- }
71
-
72
- #text {
73
- @extend .flex;
74
- }
75
-
76
- &.title {
77
- color: var( --text-primary );
78
- cursor: auto;
79
- margin-left: -16px;
80
- margin-top: -6px;
81
- font-weight: 600;
82
- }
83
-
84
- &.popup {
85
- &:after {
86
- content: url("./caret-right-solid.svg");
87
- width: 6px;
88
- }
89
- }
90
-
91
- &:hover:not(.title),
92
- &.opened {
93
- background-color: var(--menuitem-background-hover);
94
- color: var(--menuitem-color-hover);
95
- }
96
-
97
- &:active:not(.title) {
98
- background-color: var(--menuitem-background-active);
99
- color: var(--menuitem-color-active);
100
- }
101
-
102
- &[disabled] {
103
- &:hover {
104
- background-color: var(--disabled-background) !important;
105
- }
106
- color: var( --disabled-color-dark ) !important;
107
- }
108
-
109
- transition: background-color 0.1s;
110
- }
111
-
112
- .x4cmenusep {
113
- padding-top: 4px;
114
- border-bottom: 1px solid var(--border);
115
- margin-bottom: 4px;
116
- }
117
- }