@cntwg/html-helper 0.0.26 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/doc/html-ctrls-btn.md +4 -11
- package/doc/html-helper-lib.md +11 -2
- package/index.js +2 -2
- package/lib/html-ctrls/buttons.js +31 -59
- package/lib/html-ctrls/fields.js +19 -19
- package/lib/html-ctrls/list.js +65 -64
- package/lib/html-ctrls/lists-btn.js +19 -19
- package/lib/html-ctrls/lists-stubs.js +18 -18
- package/lib/html-helper-lib.js +61 -34
- package/package.json +6 -6
package/lib/html-ctrls/list.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.072-20250827]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
@@ -35,17 +35,16 @@ const {
|
|
|
35
35
|
//CSS_CLASS_ACTIVE,
|
|
36
36
|
} = CSS_CLASS_STRING;
|
|
37
37
|
|
|
38
|
-
// === module
|
|
38
|
+
// === module inner block ===
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
+
* Searches an element in a list by a given attributes of that element.
|
|
41
42
|
* @function srchListElementByAttr
|
|
42
43
|
* @param {TItemsListEx} list
|
|
43
|
-
* @param {string} name
|
|
44
|
-
* @param {string} [value=""]
|
|
44
|
+
* @param {string} name - target attribute name
|
|
45
|
+
* @param {string} [value=""] - target attribute value
|
|
45
46
|
* @returns {object}
|
|
46
47
|
* @inner
|
|
47
|
-
* @description Searches an element in a list by a given attributes
|
|
48
|
-
* of that element.
|
|
49
48
|
*/
|
|
50
49
|
function srchListElementByAttr(list, name, value = '') {
|
|
51
50
|
const _value = readAsAttrValue(value);
|
|
@@ -90,11 +89,11 @@ const ILC_SMODE_CTRL = 2;
|
|
|
90
89
|
*/
|
|
91
90
|
|
|
92
91
|
/**
|
|
92
|
+
* An options set for `THtmlItemsListContainer`-class
|
|
93
93
|
* @typedef {Object} OPT_hlconsett
|
|
94
|
-
* @property {boolean} [autoHideNewItems=false]
|
|
95
|
-
* @property {boolean} [markCurrentItem=false]
|
|
94
|
+
* @property {boolean} [autoHideNewItems=false] - indicates whether to hide a new element
|
|
95
|
+
* @property {boolean} [markCurrentItem=false] - indicates whether to mark a current element
|
|
96
96
|
* @property {(string|string[])} [itemBaseClassID]
|
|
97
|
-
* @description An options set for `THtmlItemsListContainer`-class
|
|
98
97
|
*/
|
|
99
98
|
|
|
100
99
|
/**
|
|
@@ -108,19 +107,19 @@ class THtmlItemsListContainer {
|
|
|
108
107
|
/** @type {OPT_hlconsett} */
|
|
109
108
|
#_options;// = null;
|
|
110
109
|
/**
|
|
110
|
+
* A container status
|
|
111
111
|
* @typedef {Object} statILCont
|
|
112
112
|
* @property {number} curIndex
|
|
113
113
|
* @property {?HTMLElement} curItem
|
|
114
114
|
* @inner
|
|
115
|
-
* @description A container status
|
|
116
115
|
*/
|
|
117
116
|
/** @type {statILCont} */
|
|
118
117
|
#_status;
|
|
119
118
|
|
|
120
119
|
/**
|
|
121
|
-
*
|
|
120
|
+
* Creates an instance of a list container
|
|
121
|
+
* @param {HTMLElement} host - host element
|
|
122
122
|
* @param {OPT_hlconsett} [opt] - options
|
|
123
|
-
* @description Creates an instance of a list container
|
|
124
123
|
*/
|
|
125
124
|
constructor(host, opt) {
|
|
126
125
|
// check host
|
|
@@ -220,8 +219,8 @@ class THtmlItemsListContainer {
|
|
|
220
219
|
}
|
|
221
220
|
|
|
222
221
|
/**
|
|
222
|
+
* Clears an instance content.
|
|
223
223
|
* @returns {void}
|
|
224
|
-
* @description Clears an instance content.
|
|
225
224
|
*/
|
|
226
225
|
clear() {
|
|
227
226
|
this.#_items.clear();
|
|
@@ -233,58 +232,58 @@ class THtmlItemsListContainer {
|
|
|
233
232
|
}
|
|
234
233
|
|
|
235
234
|
/**
|
|
235
|
+
* Checks if an instance contains no items.
|
|
236
236
|
* @returns {boolean}
|
|
237
|
-
* @description Checks if an instance contains no items.
|
|
238
237
|
*/
|
|
239
238
|
isEmpty() {
|
|
240
239
|
return this.#_items.isEmpty();
|
|
241
240
|
}
|
|
242
241
|
|
|
243
242
|
/**
|
|
243
|
+
* Checks if an instance contains any items.
|
|
244
244
|
* @returns {boolean}
|
|
245
|
-
* @description Checks if an instance contains any items.
|
|
246
245
|
*/
|
|
247
246
|
isNotEmpty() {
|
|
248
247
|
return this.#_items.isNotEmpty();
|
|
249
248
|
}
|
|
250
249
|
|
|
251
250
|
/**
|
|
251
|
+
* Checks if a given value is a valid index and
|
|
252
|
+
* it fits an index range within an instance.
|
|
252
253
|
* @param {any} value - index value
|
|
253
254
|
* @returns {boolean}
|
|
254
|
-
* @description Checks if a given value is a valid index and
|
|
255
|
-
* it fits an index range within an instance.
|
|
256
255
|
*/
|
|
257
256
|
chkIndex(value) {
|
|
258
257
|
return this.#_items.chkIndex(value);
|
|
259
258
|
}
|
|
260
259
|
|
|
261
260
|
/**
|
|
261
|
+
* Checks if a given value is a valid index and
|
|
262
|
+
* it fits an index range within an instance.
|
|
262
263
|
* @param {any} value - value to check
|
|
263
264
|
* @param {boolean} [opt=false] - defines a type of result
|
|
264
265
|
* @returns {(boolean|number)}
|
|
265
266
|
* @see TItemsListEx.chkIndexEx
|
|
266
|
-
* @description Checks if a given value is a valid index and
|
|
267
|
-
* it fits an index range within an instance.
|
|
268
267
|
*/
|
|
269
268
|
chkIndexEx(...args) {
|
|
270
269
|
return this.#_items.chkIndexEx(...args);
|
|
271
270
|
}
|
|
272
271
|
|
|
273
272
|
/**
|
|
273
|
+
* Returns an index of a given element.
|
|
274
274
|
* @param {HTMLElement} item - element to search
|
|
275
275
|
* @returns {number}
|
|
276
|
-
* @description Returns an index of a given element.
|
|
277
276
|
*/
|
|
278
277
|
srchIndex(item) {
|
|
279
278
|
return isHTMLElement(item) ? this.#_items.srchIndex(item) : -1;
|
|
280
279
|
}
|
|
281
280
|
|
|
282
281
|
/**
|
|
282
|
+
* Returns an index of an element wich has an attribute
|
|
283
|
+
* with a given name and value.
|
|
283
284
|
* @param {string} name - attribute name
|
|
284
285
|
* @param {any} [value=""] - attribute value
|
|
285
286
|
* @returns {number}
|
|
286
|
-
* @description Returns an index of an element wich has an attribute
|
|
287
|
-
* with a given name and value.
|
|
288
287
|
*/
|
|
289
288
|
srchIndexByAttr(name, value = '') {
|
|
290
289
|
const _name = typeof name === 'string' ? name.trim() : '';
|
|
@@ -293,9 +292,9 @@ class THtmlItemsListContainer {
|
|
|
293
292
|
};
|
|
294
293
|
|
|
295
294
|
/**
|
|
295
|
+
* Returns an index of an element wich has a given ID.
|
|
296
296
|
* @param {string} value - element ID
|
|
297
297
|
* @returns {number}
|
|
298
|
-
* @description Returns an index of an element wich has a given ID.
|
|
299
298
|
*/
|
|
300
299
|
srchIndexByID(value) {
|
|
301
300
|
const { index } = srchListElementByAttr(this.#_items, 'id', value);
|
|
@@ -303,9 +302,9 @@ class THtmlItemsListContainer {
|
|
|
303
302
|
};
|
|
304
303
|
|
|
305
304
|
/**
|
|
305
|
+
* Sets a current index.
|
|
306
306
|
* @param {(number|string)} index - element index
|
|
307
307
|
* @returns {boolean}
|
|
308
|
-
* @description Sets a current index.
|
|
309
308
|
*/
|
|
310
309
|
setCurIndex(index) {
|
|
311
310
|
const isSUCCEED = this.#_items.setIndex(index);
|
|
@@ -324,8 +323,8 @@ class THtmlItemsListContainer {
|
|
|
324
323
|
}
|
|
325
324
|
|
|
326
325
|
/**
|
|
326
|
+
* Resets a current index.
|
|
327
327
|
* @returns {void}
|
|
328
|
-
* @description Resets a current index.
|
|
329
328
|
*/
|
|
330
329
|
rstCurIndex() {
|
|
331
330
|
const _status = this.#_status;
|
|
@@ -338,9 +337,9 @@ class THtmlItemsListContainer {
|
|
|
338
337
|
}
|
|
339
338
|
|
|
340
339
|
/**
|
|
340
|
+
* Returns an item addressed by a given index.
|
|
341
341
|
* @param {(number|string)} index - element index
|
|
342
342
|
* @returns {?HTMLElement}
|
|
343
|
-
* @description Returns an item addressed by a given index.
|
|
344
343
|
*/
|
|
345
344
|
getItem(index) {
|
|
346
345
|
const item = this.#_items.getItem(index);
|
|
@@ -348,11 +347,10 @@ class THtmlItemsListContainer {
|
|
|
348
347
|
}
|
|
349
348
|
|
|
350
349
|
/**
|
|
350
|
+
* Returns an item wich has an attribute with a given name and value.
|
|
351
351
|
* @param {string} name - attribute name
|
|
352
352
|
* @param {any} [value=""] - attribute value
|
|
353
353
|
* @returns {?HTMLElement}
|
|
354
|
-
* @description Returns an item wich has an attribute
|
|
355
|
-
* with a given name and value.
|
|
356
354
|
*/
|
|
357
355
|
getItemByAttr(name, value = '') {
|
|
358
356
|
const _name = typeof name === 'string' ? name.trim() : '';
|
|
@@ -361,9 +359,9 @@ class THtmlItemsListContainer {
|
|
|
361
359
|
}
|
|
362
360
|
|
|
363
361
|
/**
|
|
362
|
+
* Returns an item wich has a given ID.
|
|
364
363
|
* @param {string} value - element ID
|
|
365
364
|
* @returns {?HTMLElement}
|
|
366
|
-
* @description Returns an item wich has a given ID.
|
|
367
365
|
*/
|
|
368
366
|
getItemByID(value) {
|
|
369
367
|
const { item } = srchListElementByAttr(this.#_items, 'id', value);
|
|
@@ -371,10 +369,10 @@ class THtmlItemsListContainer {
|
|
|
371
369
|
}
|
|
372
370
|
|
|
373
371
|
/**
|
|
372
|
+
* Adds an item to an instance.
|
|
374
373
|
* @param {HTMLElement} item
|
|
375
374
|
* @param {boolean} [opt=false]
|
|
376
375
|
* @returns {number}
|
|
377
|
-
* @description Adds an item to an instance.
|
|
378
376
|
*/
|
|
379
377
|
addItem(item, opt) {
|
|
380
378
|
const forceCI = typeof opt === 'boolean' ? opt : false;
|
|
@@ -396,11 +394,11 @@ class THtmlItemsListContainer {
|
|
|
396
394
|
}
|
|
397
395
|
|
|
398
396
|
/**
|
|
397
|
+
* Deletes an item from an instance.
|
|
399
398
|
* @param {(number|string)} index - element index
|
|
400
399
|
* @param {any} [opt]
|
|
401
400
|
* @param {boolean} [optEx=true]
|
|
402
401
|
* @returns {boolean}
|
|
403
|
-
* @description Deletes an item from an instance.
|
|
404
402
|
*/
|
|
405
403
|
delItem(index, opt, optEx) {
|
|
406
404
|
const _items = this.#_items;
|
|
@@ -422,10 +420,10 @@ class THtmlItemsListContainer {
|
|
|
422
420
|
}
|
|
423
421
|
|
|
424
422
|
/**
|
|
423
|
+
* Selects an item addressed by a given index.
|
|
425
424
|
* @param {(number|string)} index - element index
|
|
426
425
|
* @param {boolean} [opt=false]
|
|
427
426
|
* @returns {boolean}
|
|
428
|
-
* @description Selects an item addressed by a given index.
|
|
429
427
|
*/
|
|
430
428
|
selectItem(index, opt) {
|
|
431
429
|
const forceCI = typeof opt === 'boolean' ? opt : false;
|
|
@@ -435,45 +433,45 @@ class THtmlItemsListContainer {
|
|
|
435
433
|
}
|
|
436
434
|
|
|
437
435
|
/**
|
|
436
|
+
* Unselects an item addressed by a given index.
|
|
438
437
|
* @param {(number|string)} index - element index
|
|
439
438
|
* @returns {boolean}
|
|
440
|
-
* @description Unselects an item addressed by a given index.
|
|
441
439
|
*/
|
|
442
440
|
unselectItem(index) {
|
|
443
441
|
return unselectHTMLElement(this.#_items.getItem(index));
|
|
444
442
|
}
|
|
445
443
|
|
|
446
444
|
/**
|
|
445
|
+
* Hides an item addressed by a given index.
|
|
447
446
|
* @param {(number|string)} index - element index
|
|
448
447
|
* @returns {boolean}
|
|
449
|
-
* @description Hides an item addressed by a given index.
|
|
450
448
|
*/
|
|
451
449
|
hideItem(index) {
|
|
452
450
|
return hideHTMLElement(this.#_items.getItem(index));
|
|
453
451
|
}
|
|
454
452
|
|
|
455
453
|
/**
|
|
454
|
+
* Shows an item addressed by a given index.
|
|
456
455
|
* @param {(number|string)} index - element index
|
|
457
456
|
* @returns {boolean}
|
|
458
|
-
* @description Shows an item addressed by a given index.
|
|
459
457
|
*/
|
|
460
458
|
showItem(index) {
|
|
461
459
|
return showHTMLElement(this.#_items.getItem(index));
|
|
462
460
|
}
|
|
463
461
|
|
|
464
462
|
/**
|
|
463
|
+
* Checks whether an item is selected.
|
|
465
464
|
* @param {(number|string)} index - element index
|
|
466
465
|
* @returns {boolean}
|
|
467
|
-
* @description Checks whether an item is selected.
|
|
468
466
|
*/
|
|
469
467
|
isSelectedItem(index) {
|
|
470
468
|
return isSelectedHTMLElement(this.#_items.getItem(index));
|
|
471
469
|
}
|
|
472
470
|
|
|
473
471
|
/**
|
|
472
|
+
* Checks whether an item is hidden.
|
|
474
473
|
* @param {(number|string)} index - element index
|
|
475
474
|
* @returns {boolean}
|
|
476
|
-
* @description Checks whether an item is hidden.
|
|
477
475
|
*/
|
|
478
476
|
isHiddenItem(index) {
|
|
479
477
|
return isHiddenHTMLElement(this.#_items.getItem(index));
|
|
@@ -483,13 +481,15 @@ class THtmlItemsListContainer {
|
|
|
483
481
|
|
|
484
482
|
/**
|
|
485
483
|
* @typedef {Object} OPT_hlctlsett
|
|
486
|
-
* @property {boolean} [autoHideNewItems=false]
|
|
487
|
-
* @property {boolean} [markCurrentItem=false]
|
|
484
|
+
* @property {boolean} [autoHideNewItems=false] - indicates whether to hide a new element
|
|
485
|
+
* @property {boolean} [markCurrentItem=false] - indicates whether to mark a current element
|
|
488
486
|
* @property {(string|string[])} [itemBaseClassID]
|
|
489
|
-
* @property {boolean} [showStubsIfEmpty=false]
|
|
490
|
-
* @property {boolean} [allowGroupSelection=false]
|
|
491
|
-
*
|
|
492
|
-
* @property {
|
|
487
|
+
* @property {boolean} [showStubsIfEmpty=false] - indicates whether to show stubs if empty
|
|
488
|
+
* @property {boolean} [allowGroupSelection=false] - indicates whether
|
|
489
|
+
* a selection of the elements group is allowed
|
|
490
|
+
* @property {boolean} [allowSelectionLocks=false] - indicates whether locking
|
|
491
|
+
* of an element selection is allowed
|
|
492
|
+
* @property {OPT_stubconsett} [stubs]
|
|
493
493
|
* @description An options set for `THtmlItemsListController`-class
|
|
494
494
|
*/
|
|
495
495
|
|
|
@@ -508,6 +508,7 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
508
508
|
/** @property {OPT_hlctlsett} */
|
|
509
509
|
#_options;// = null;
|
|
510
510
|
/**
|
|
511
|
+
* A controler status
|
|
511
512
|
* @typedef {Object} statILCtrl
|
|
512
513
|
* @property {boolean} isSelectionLocked
|
|
513
514
|
* @property {boolean} isStubItemShown
|
|
@@ -517,7 +518,6 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
517
518
|
* @property {number} execDelItemDI
|
|
518
519
|
* @property {number} execDelItemCI
|
|
519
520
|
* @inner
|
|
520
|
-
* @description A controler status
|
|
521
521
|
*/
|
|
522
522
|
/** @property {statILCtrl} */
|
|
523
523
|
#_status;
|
|
@@ -525,15 +525,16 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
525
525
|
#_events;
|
|
526
526
|
|
|
527
527
|
/**
|
|
528
|
-
*
|
|
529
|
-
* @param {
|
|
530
|
-
* @
|
|
528
|
+
* Creates a new instance of the class.
|
|
529
|
+
* @param {?HTMLElement} host - host element
|
|
530
|
+
* @param {OPT_hlctlsett} [opt] - options
|
|
531
531
|
*/
|
|
532
532
|
constructor(host, opt) {
|
|
533
533
|
// check host element
|
|
534
534
|
const isHostEnabled = isHTMLElement(host);
|
|
535
535
|
const _host = isHostEnabled ? host : null;
|
|
536
536
|
// check options
|
|
537
|
+
/** @type {OPT_hlctlsett} */
|
|
537
538
|
const _options = isPlainObject(opt) ? opt : {};
|
|
538
539
|
// call parent constructor
|
|
539
540
|
super(_host, _options);
|
|
@@ -652,7 +653,7 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
652
653
|
};
|
|
653
654
|
|
|
654
655
|
/**
|
|
655
|
-
* @param {string} name
|
|
656
|
+
* @param {string} name - event name
|
|
656
657
|
* @param {...any} args
|
|
657
658
|
* @returns {void}
|
|
658
659
|
* @private
|
|
@@ -696,9 +697,9 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
696
697
|
}
|
|
697
698
|
|
|
698
699
|
/**
|
|
700
|
+
* Clears an instance content.
|
|
699
701
|
* @returns {void}
|
|
700
702
|
* @fires THtmlItemsListController#list-clear
|
|
701
|
-
* @description Clears an instance content.
|
|
702
703
|
*/
|
|
703
704
|
clear() {
|
|
704
705
|
// // TODO: clear event handler on elements if set
|
|
@@ -716,8 +717,8 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
716
717
|
}
|
|
717
718
|
|
|
718
719
|
/**
|
|
720
|
+
* Locks an element selection.
|
|
719
721
|
* @returns {void}
|
|
720
|
-
* @description Locks an element selection.
|
|
721
722
|
*/
|
|
722
723
|
lockItemsSelection() {
|
|
723
724
|
if (this.#_options.allowSelectionLocks) {
|
|
@@ -726,19 +727,19 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
726
727
|
}
|
|
727
728
|
|
|
728
729
|
/**
|
|
730
|
+
* Unlocks an element selection.
|
|
729
731
|
* @returns {void}
|
|
730
|
-
* @description Unlocks an element selection.
|
|
731
732
|
*/
|
|
732
733
|
unlockItemsSelection() {
|
|
733
734
|
this.#_status.isSelectionLocked = false;
|
|
734
735
|
}
|
|
735
736
|
|
|
736
737
|
/**
|
|
738
|
+
* Sets a current index.
|
|
737
739
|
* @param {(number|string)} index - element index
|
|
738
740
|
* @returns {boolean}
|
|
739
741
|
* @fires THtmlItemsListController#current-item-chosen
|
|
740
742
|
* @private
|
|
741
|
-
* @description Sets a current index.
|
|
742
743
|
*/
|
|
743
744
|
#_setCurIndex(index) {
|
|
744
745
|
const isSUCCEED = super.setCurIndex(index);
|
|
@@ -756,17 +757,17 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
756
757
|
};
|
|
757
758
|
|
|
758
759
|
/**
|
|
760
|
+
* Sets a current index.
|
|
759
761
|
* @param {(number|string)} index - element index
|
|
760
762
|
* @returns {boolean}
|
|
761
|
-
* @description Sets a current index.
|
|
762
763
|
*/
|
|
763
764
|
setCurIndex(index) {
|
|
764
765
|
return this.selectItem(index, true);
|
|
765
766
|
}
|
|
766
767
|
|
|
767
768
|
/**
|
|
769
|
+
* Resets a current index.
|
|
768
770
|
* @returns {void}
|
|
769
|
-
* @description Resets a current index.
|
|
770
771
|
*/
|
|
771
772
|
rstCurIndex() {
|
|
772
773
|
const {
|
|
@@ -785,12 +786,12 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
785
786
|
}
|
|
786
787
|
|
|
787
788
|
/**
|
|
788
|
-
*
|
|
789
|
+
* Adds an element to an instance members.
|
|
790
|
+
* @param {HTMLElement} item - some element
|
|
789
791
|
* @param {boolean} [opt=false]
|
|
790
792
|
* @returns {number}
|
|
791
793
|
* @fires THtmlItemsListController#first-item-added
|
|
792
794
|
* @fires THtmlItemsListController#item-added
|
|
793
|
-
* @description Adds an element to an instance members.
|
|
794
795
|
*/
|
|
795
796
|
addItem(item, opt) {
|
|
796
797
|
const index = super.addItem(item, false);
|
|
@@ -848,12 +849,12 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
848
849
|
}
|
|
849
850
|
|
|
850
851
|
/**
|
|
852
|
+
* Deletes an element from an instance members.
|
|
851
853
|
* @param {(number|string)} index - element index
|
|
852
854
|
* @param {any} [opt]
|
|
853
855
|
* @returns {boolean}
|
|
854
856
|
* @fires THtmlItemsListController#list-clear
|
|
855
857
|
* @fires THtmlItemsListController#item-removed
|
|
856
|
-
* @description Deletes an element from an instance members.
|
|
857
858
|
*/
|
|
858
859
|
delItem(index, opt) {
|
|
859
860
|
const item = super.getItem(index);
|
|
@@ -908,11 +909,11 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
908
909
|
}
|
|
909
910
|
|
|
910
911
|
/**
|
|
912
|
+
* Selects an element.
|
|
911
913
|
* @param {(number|string)} index - element index
|
|
912
914
|
* @returns {boolean}
|
|
913
915
|
* @private
|
|
914
916
|
* @fires THtmlItemsListController#item-selected
|
|
915
|
-
* @description Selects an element.
|
|
916
917
|
*/
|
|
917
918
|
#_selectItem(index) {
|
|
918
919
|
const item = super.getItem(index);
|
|
@@ -934,6 +935,7 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
934
935
|
}
|
|
935
936
|
|
|
936
937
|
/**
|
|
938
|
+
* Selects an element.
|
|
937
939
|
* @param {?HTMLElement} item - element
|
|
938
940
|
* @param {object} [opt]
|
|
939
941
|
* @param {boolean} [opt.ctrlKey=false]
|
|
@@ -941,7 +943,6 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
941
943
|
* @param {boolean} [opt.forceCI=false]
|
|
942
944
|
* @returns {void}
|
|
943
945
|
* @private
|
|
944
|
-
* @description Selects an element.
|
|
945
946
|
*/
|
|
946
947
|
#_selectItemEx(item, opt){
|
|
947
948
|
const _selects = this.#_selects;
|
|
@@ -996,10 +997,10 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
996
997
|
}
|
|
997
998
|
|
|
998
999
|
/**
|
|
1000
|
+
* Selects an element.
|
|
999
1001
|
* @param {(number|string)} index - element index
|
|
1000
1002
|
* @param {boolean} [opt=false]
|
|
1001
1003
|
* @returns {boolean}
|
|
1002
|
-
* @description Selects an element.
|
|
1003
1004
|
*/
|
|
1004
1005
|
selectItem(index, opt) {
|
|
1005
1006
|
const item = super.getItem(index);
|
|
@@ -1016,10 +1017,10 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
1016
1017
|
}
|
|
1017
1018
|
|
|
1018
1019
|
/**
|
|
1020
|
+
* Unselects an element.
|
|
1019
1021
|
* @param {(number|string)} index - element index
|
|
1020
1022
|
* @returns {boolean}
|
|
1021
1023
|
* @fires THtmlItemsListController#item-unselected
|
|
1022
|
-
* @description Unselects an element.
|
|
1023
1024
|
*/
|
|
1024
1025
|
unselectItem(index) {
|
|
1025
1026
|
const item = super.getItem(index);
|
|
@@ -1041,10 +1042,10 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
1041
1042
|
}
|
|
1042
1043
|
|
|
1043
1044
|
/**
|
|
1045
|
+
* Hides an element.
|
|
1044
1046
|
* @param {(number|string)} index - element index
|
|
1045
1047
|
* @returns {boolean}
|
|
1046
1048
|
* @fires THtmlItemsListController#item-hidden
|
|
1047
|
-
* @description Hides an element.
|
|
1048
1049
|
*/
|
|
1049
1050
|
hideItem(index) {
|
|
1050
1051
|
const item = super.getItem(index);
|
|
@@ -1065,10 +1066,10 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
1065
1066
|
}
|
|
1066
1067
|
|
|
1067
1068
|
/**
|
|
1069
|
+
* Shows an element.
|
|
1068
1070
|
* @param {(number|string)} index - element index
|
|
1069
1071
|
* @returns {boolean}
|
|
1070
1072
|
* @fires THtmlItemsListController#item-shown
|
|
1071
|
-
* @description Shows an element.
|
|
1072
1073
|
*/
|
|
1073
1074
|
showItem(index) {
|
|
1074
1075
|
const item = super.getItem(index);
|
|
@@ -1089,10 +1090,10 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
1089
1090
|
}
|
|
1090
1091
|
|
|
1091
1092
|
/**
|
|
1093
|
+
* Sets a callback function to handle event.
|
|
1092
1094
|
* @param {string} name - event name
|
|
1093
1095
|
* @param {func} evnt
|
|
1094
1096
|
* @returns {void}
|
|
1095
|
-
* @description Sets a callback function to handle event.
|
|
1096
1097
|
*/
|
|
1097
1098
|
on(name, evnt) {
|
|
1098
1099
|
pushEventHandler(this.#_events, name, evnt);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.056-20250827]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
@@ -7,11 +7,11 @@ const {
|
|
|
7
7
|
} = require('@ygracs/bsfoc-lib-js');
|
|
8
8
|
|
|
9
9
|
const {
|
|
10
|
+
isHTMLButton,
|
|
10
11
|
CSS_CLASS_STRING,
|
|
11
12
|
} = require('../html-helper-lib.js');
|
|
12
13
|
|
|
13
14
|
const {
|
|
14
|
-
isHTMLButton,
|
|
15
15
|
THtmlButtonsSet,
|
|
16
16
|
} = require('./buttons.js');
|
|
17
17
|
|
|
@@ -42,6 +42,15 @@ const BTS_DEF_GROUP_NAME = 'all';
|
|
|
42
42
|
* (* class definitions *)
|
|
43
43
|
*/
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* A description for list buttons set.
|
|
47
|
+
* @typedef {Object} listButtonsSetDesc
|
|
48
|
+
* @property {?HTMLElement} btnFirst - button 'move to first'
|
|
49
|
+
* @property {?HTMLElement} btnPrev - button 'move to previous'
|
|
50
|
+
* @property {?HTMLElement} btnNext - button 'move to next'
|
|
51
|
+
* @property {?HTMLElement} btnLast - button 'move to last'
|
|
52
|
+
*/
|
|
53
|
+
|
|
45
54
|
/**
|
|
46
55
|
* @classdesc This class implements an interface of a pre-defined
|
|
47
56
|
* buttons set that is used in pair with a list elements.
|
|
@@ -54,17 +63,8 @@ class THtmlListButtonsController {
|
|
|
54
63
|
#_events;
|
|
55
64
|
|
|
56
65
|
/**
|
|
57
|
-
*
|
|
58
|
-
* @property {?HTMLElement} btnFirst - button 'move to first'
|
|
59
|
-
* @property {?HTMLElement} btnPrev - button 'move to previous'
|
|
60
|
-
* @property {?HTMLElement} btnNext - button 'move to next'
|
|
61
|
-
* @property {?HTMLElement} btnLast - button 'move to last'
|
|
62
|
-
* @description A description for list buttons set.
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
+
* Creates an instance of a buttons set.
|
|
66
67
|
* @param {listButtonsSetDesc} [opt] - an options
|
|
67
|
-
* @description Creates an instance of a buttons set.
|
|
68
68
|
*/
|
|
69
69
|
constructor(opt) {
|
|
70
70
|
// load controls
|
|
@@ -141,8 +141,8 @@ class THtmlListButtonsController {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
|
+
* Disables all buttons.
|
|
144
145
|
* @returns {void}
|
|
145
|
-
* @description Disables all buttons.
|
|
146
146
|
*/
|
|
147
147
|
disableAll() {
|
|
148
148
|
const _btnSet = this.#_btnSet;
|
|
@@ -151,24 +151,24 @@ class THtmlListButtonsController {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
/**
|
|
154
|
+
* Disables all buttons in 'move_bkwd' group.
|
|
154
155
|
* @returns {void}
|
|
155
|
-
* @description Disables all buttons in 'move_bkwd' group.
|
|
156
156
|
*/
|
|
157
157
|
disableBkwd() {
|
|
158
158
|
this.#_btnSet.disableGroup('move_bkwd');
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
/**
|
|
162
|
+
* Disables all buttons in 'move_frwd' group.
|
|
162
163
|
* @returns {void}
|
|
163
|
-
* @description Disables all buttons in 'move_frwd' group.
|
|
164
164
|
*/
|
|
165
165
|
disableFrwd() {
|
|
166
166
|
this.#_btnSet.disableGroup('move_frwd');
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
/**
|
|
170
|
+
* Enables all buttons.
|
|
170
171
|
* @returns {void}
|
|
171
|
-
* @description Enables all buttons.
|
|
172
172
|
*/
|
|
173
173
|
enableAll() {
|
|
174
174
|
const _btnSet = this.#_btnSet;
|
|
@@ -177,26 +177,26 @@ class THtmlListButtonsController {
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
/**
|
|
180
|
+
* Enables all buttons in 'move_bkwd' group.
|
|
180
181
|
* @returns {void}
|
|
181
|
-
* @description Enables all buttons in 'move_bkwd' group.
|
|
182
182
|
*/
|
|
183
183
|
enableBkwd() {
|
|
184
184
|
this.#_btnSet.enableGroup('move_bkwd');
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
/**
|
|
188
|
+
* Enables all buttons in 'move_frwd' group.
|
|
188
189
|
* @returns {void}
|
|
189
|
-
* @description Enables all buttons in 'move_frwd' group.
|
|
190
190
|
*/
|
|
191
191
|
enableFrwd() {
|
|
192
192
|
this.#_btnSet.enableGroup('move_frwd');
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
/**
|
|
196
|
+
* Sets a callback function to handle event.
|
|
196
197
|
* @param {string} name - event name
|
|
197
198
|
* @param {func} evnt - callback function
|
|
198
199
|
* @returns {void}
|
|
199
|
-
* @description Sets a callback function to handle event.
|
|
200
200
|
*/
|
|
201
201
|
on(name, evnt) {
|
|
202
202
|
pushEventHandler(this.#_events, name, evnt);
|