@cntwg/html-ctrls-lists 0.0.30 → 0.0.32
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 +22 -0
- package/doc/html-ctrls-list.md +180 -127
- package/index.d.ts +19 -0
- package/lib/list.d.ts +278 -0
- package/lib/list.js +133 -78
- package/lib/lists-btn.d.ts +63 -0
- package/lib/lists-btn.js +5 -10
- package/lib/lists-stubs.d.ts +134 -0
- package/lib/lists-stubs.js +36 -19
- package/lib/mod-hfunc.d.ts +18 -0
- package/lib/mod-hfunc.js +9 -30
- package/package.json +13 -8
package/lib/list.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.088-20260505]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
@@ -21,7 +21,11 @@ const {
|
|
|
21
21
|
CSS_CLASS_STRING,
|
|
22
22
|
} = require('@cntwg/html-helper');
|
|
23
23
|
|
|
24
|
-
const {
|
|
24
|
+
const {
|
|
25
|
+
THtmlStubItemsSet,
|
|
26
|
+
// * import types definitions *
|
|
27
|
+
IStubItemsSetOptions,
|
|
28
|
+
} = require('./lists-stubs');
|
|
25
29
|
|
|
26
30
|
// === module inner block ===
|
|
27
31
|
|
|
@@ -33,13 +37,29 @@ const {
|
|
|
33
37
|
CSS_CLASS_DISABLED,
|
|
34
38
|
} = CSS_CLASS_STRING;
|
|
35
39
|
|
|
40
|
+
/**
|
|
41
|
+
* @typedef {Object} ISearchListElementResultOnFail
|
|
42
|
+
* @property {number} index - element index
|
|
43
|
+
* @property {null} item - found element
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @typedef {Object} ISearchListElementResultOnSuccess
|
|
48
|
+
* @property {number} index - element index
|
|
49
|
+
* @property {any} item - found element
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @typedef {ISearchListElementResultOnFail|ISearchListElementResultOnSuccess} ISearchListElementResult
|
|
54
|
+
*/
|
|
55
|
+
|
|
36
56
|
/**
|
|
37
57
|
* Searches an element in a list by a given attributes of that element.
|
|
38
58
|
* @function srchListElementByAttr
|
|
39
59
|
* @param {TItemsListEx} list
|
|
40
60
|
* @param {string} name - target attribute name
|
|
41
61
|
* @param {string} [value=""] - target attribute value
|
|
42
|
-
* @returns {
|
|
62
|
+
* @returns {ISearchListElementResult}
|
|
43
63
|
* @inner
|
|
44
64
|
*/
|
|
45
65
|
function srchListElementByAttr(list, name, value = '') {
|
|
@@ -91,8 +111,17 @@ class THtmlItemsListContainer {
|
|
|
91
111
|
#_host;
|
|
92
112
|
/** @type {TItemsListEx} */
|
|
93
113
|
#_items;
|
|
94
|
-
/**
|
|
95
|
-
|
|
114
|
+
/**
|
|
115
|
+
* A container settings
|
|
116
|
+
* @typedef {Object} THtmlItemsListContainerConfig
|
|
117
|
+
* @property {boolean} autoHideNewItems - indicates whether to hide a new element
|
|
118
|
+
* @property {boolean} markCurrentItem - indicates whether to mark a new element
|
|
119
|
+
* as a current
|
|
120
|
+
* @property {string[]} itemBaseClassID - contains a base class attributes
|
|
121
|
+
* applayed to each a newly added list member
|
|
122
|
+
*/
|
|
123
|
+
/** @type {THtmlItemsListContainerConfig} */
|
|
124
|
+
#_config;
|
|
96
125
|
/**
|
|
97
126
|
* A container status
|
|
98
127
|
* @typedef {Object} statILCont
|
|
@@ -105,7 +134,7 @@ class THtmlItemsListContainer {
|
|
|
105
134
|
|
|
106
135
|
/**
|
|
107
136
|
* Creates an instance of a list container
|
|
108
|
-
* @param {HTMLElement} host - host element
|
|
137
|
+
* @param {?HTMLElement} host - host element
|
|
109
138
|
* @param {OPT_hlconsett} [opt] - options
|
|
110
139
|
*/
|
|
111
140
|
constructor(host, opt) {
|
|
@@ -123,12 +152,17 @@ class THtmlItemsListContainer {
|
|
|
123
152
|
itemBaseClassID,
|
|
124
153
|
} = _options;
|
|
125
154
|
if (typeof autoHideNewItems !== 'boolean') {
|
|
126
|
-
|
|
155
|
+
autoHideNewItems = false;
|
|
156
|
+
// // TODO: next line planned to be removed
|
|
157
|
+
_options.autoHideNewItems = autoHideNewItems;
|
|
127
158
|
};
|
|
128
159
|
if (typeof markCurrentItem !== 'boolean') {
|
|
129
|
-
|
|
160
|
+
markCurrentItem = false;
|
|
161
|
+
// // TODO: next line planned to be removed
|
|
162
|
+
_options.markCurrentItem = markCurrentItem;
|
|
130
163
|
};
|
|
131
164
|
itemBaseClassID = valueToClassList(itemBaseClassID, true);
|
|
165
|
+
// // TODO: next line planned to be removed
|
|
132
166
|
_options.itemBaseClassID = itemBaseClassID;
|
|
133
167
|
// init status
|
|
134
168
|
/** @type {statILCont} */
|
|
@@ -138,7 +172,11 @@ class THtmlItemsListContainer {
|
|
|
138
172
|
};
|
|
139
173
|
this.#_status = _status;
|
|
140
174
|
// save options
|
|
141
|
-
this.#
|
|
175
|
+
this.#_config = {
|
|
176
|
+
autoHideNewItems,
|
|
177
|
+
markCurrentItem,
|
|
178
|
+
itemBaseClassID,
|
|
179
|
+
};
|
|
142
180
|
}
|
|
143
181
|
|
|
144
182
|
[Symbol.iterator]() {
|
|
@@ -253,23 +291,51 @@ class THtmlItemsListContainer {
|
|
|
253
291
|
/**
|
|
254
292
|
* Checks if a given value is a valid index and
|
|
255
293
|
* it fits an index range within an instance.
|
|
256
|
-
* @param {
|
|
294
|
+
* @param {number|string} value - index value
|
|
257
295
|
* @returns {boolean}
|
|
296
|
+
* @deprecated
|
|
297
|
+
* @todo \[since v0.0.31] deprecated. Use
|
|
298
|
+
* {@link THtmlItemsListContainer.checkIndex} instead
|
|
258
299
|
*/
|
|
259
300
|
chkIndex(value) {
|
|
260
|
-
return this.#_items.
|
|
301
|
+
return this.#_items.checkIndex(value);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Checks if a given value is a valid index and
|
|
306
|
+
* it fits an index range within an instance.
|
|
307
|
+
* @since 0.0.31
|
|
308
|
+
* @param {number|string} value - index value
|
|
309
|
+
* @returns {boolean}
|
|
310
|
+
*/
|
|
311
|
+
checkIndex(value) {
|
|
312
|
+
return this.#_items.checkIndex(value);
|
|
261
313
|
}
|
|
262
314
|
|
|
263
315
|
/**
|
|
264
316
|
* Checks if a given value is a valid index and
|
|
265
317
|
* it fits an index range within an instance.
|
|
266
|
-
* @param {
|
|
318
|
+
* @param {number|string} value - value to check
|
|
267
319
|
* @param {boolean} [opt=false] - defines a type of result
|
|
268
|
-
* @returns {
|
|
269
|
-
* @
|
|
320
|
+
* @returns {boolean|number}
|
|
321
|
+
* @deprecated
|
|
322
|
+
* @todo \[since v0.0.31] deprecated. Use
|
|
323
|
+
* {@link THtmlItemsListContainer.checkIndex} or
|
|
324
|
+
* {@link THtmlItemsListContainer.tryIndex} instead
|
|
270
325
|
*/
|
|
271
|
-
chkIndexEx(
|
|
272
|
-
return this.#_items.
|
|
326
|
+
chkIndexEx(value, opt) {
|
|
327
|
+
return opt ? this.#_items.tryIndex(value) : this.#_items.checkIndex(value);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Returns an index in case a given value is a valid index value and not exceeds
|
|
332
|
+
* an index range within the list. If failed a `-1` returned
|
|
333
|
+
* @since 0.0.31
|
|
334
|
+
* @param {any} value - value to evaluate
|
|
335
|
+
* @returns {number}
|
|
336
|
+
*/
|
|
337
|
+
tryIndex(value) {
|
|
338
|
+
return this.#_items.tryIndex(value);
|
|
273
339
|
}
|
|
274
340
|
|
|
275
341
|
/**
|
|
@@ -308,13 +374,13 @@ class THtmlItemsListContainer {
|
|
|
308
374
|
|
|
309
375
|
/**
|
|
310
376
|
* Sets a current index.
|
|
311
|
-
* @param {
|
|
377
|
+
* @param {number|string} index - element index
|
|
312
378
|
* @returns {boolean}
|
|
313
379
|
*/
|
|
314
380
|
setCurIndex(index) {
|
|
315
381
|
const isSUCCEED = this.#_items.setIndex(index);
|
|
316
382
|
if (isSUCCEED) {
|
|
317
|
-
const markCurrentItem = this.#
|
|
383
|
+
const markCurrentItem = this.#_config.markCurrentItem;
|
|
318
384
|
const _status = this.#_status;
|
|
319
385
|
if (markCurrentItem && _status.curIndex !== -1) {
|
|
320
386
|
unmarkCurrentHTMLElement(_status.curItem);
|
|
@@ -333,7 +399,7 @@ class THtmlItemsListContainer {
|
|
|
333
399
|
*/
|
|
334
400
|
rstCurIndex() {
|
|
335
401
|
const _status = this.#_status;
|
|
336
|
-
if (this.#
|
|
402
|
+
if (this.#_config.markCurrentItem && _status.curIndex !== -1) {
|
|
337
403
|
unmarkCurrentHTMLElement(_status.curItem);
|
|
338
404
|
};
|
|
339
405
|
this.#_items.rstIndex();
|
|
@@ -343,7 +409,7 @@ class THtmlItemsListContainer {
|
|
|
343
409
|
|
|
344
410
|
/**
|
|
345
411
|
* Returns an item addressed by a given index.
|
|
346
|
-
* @param {
|
|
412
|
+
* @param {number|string} index - element index
|
|
347
413
|
* @returns {?HTMLElement}
|
|
348
414
|
*/
|
|
349
415
|
getItem(index) {
|
|
@@ -388,7 +454,7 @@ class THtmlItemsListContainer {
|
|
|
388
454
|
);
|
|
389
455
|
const isSUCCEED = index !== -1;
|
|
390
456
|
if (isSUCCEED) {
|
|
391
|
-
const { autoHideNewItems, itemBaseClassID } = this.#
|
|
457
|
+
const { autoHideNewItems, itemBaseClassID } = this.#_config;
|
|
392
458
|
if (autoHideNewItems) hideHTMLElement(item);
|
|
393
459
|
if (itemBaseClassID.length > 0) item.classList.add(...itemBaseClassID);
|
|
394
460
|
if (forceCI) this.setCurIndex(index);
|
|
@@ -400,7 +466,7 @@ class THtmlItemsListContainer {
|
|
|
400
466
|
|
|
401
467
|
/**
|
|
402
468
|
* Deletes an item from an instance.
|
|
403
|
-
* @param {
|
|
469
|
+
* @param {number|string} index - element index
|
|
404
470
|
* @param {any} [opt]
|
|
405
471
|
* @param {boolean} [optEx=true]
|
|
406
472
|
* @returns {boolean}
|
|
@@ -426,7 +492,7 @@ class THtmlItemsListContainer {
|
|
|
426
492
|
|
|
427
493
|
/**
|
|
428
494
|
* Selects an item addressed by a given index.
|
|
429
|
-
* @param {
|
|
495
|
+
* @param {number|string} index - element index
|
|
430
496
|
* @param {boolean} [opt=false] - indicates whether to correct a current index
|
|
431
497
|
* @returns {boolean}
|
|
432
498
|
*/
|
|
@@ -439,7 +505,7 @@ class THtmlItemsListContainer {
|
|
|
439
505
|
|
|
440
506
|
/**
|
|
441
507
|
* Unselects an item addressed by a given index.
|
|
442
|
-
* @param {
|
|
508
|
+
* @param {number|string} index - element index
|
|
443
509
|
* @returns {boolean}
|
|
444
510
|
*/
|
|
445
511
|
unselectItem(index) {
|
|
@@ -448,7 +514,7 @@ class THtmlItemsListContainer {
|
|
|
448
514
|
|
|
449
515
|
/**
|
|
450
516
|
* Hides an item addressed by a given index.
|
|
451
|
-
* @param {
|
|
517
|
+
* @param {number|string} index - element index
|
|
452
518
|
* @returns {boolean}
|
|
453
519
|
*/
|
|
454
520
|
hideItem(index) {
|
|
@@ -457,7 +523,7 @@ class THtmlItemsListContainer {
|
|
|
457
523
|
|
|
458
524
|
/**
|
|
459
525
|
* Shows an item addressed by a given index.
|
|
460
|
-
* @param {
|
|
526
|
+
* @param {number|string} index - element index
|
|
461
527
|
* @returns {boolean}
|
|
462
528
|
*/
|
|
463
529
|
showItem(index) {
|
|
@@ -466,7 +532,7 @@ class THtmlItemsListContainer {
|
|
|
466
532
|
|
|
467
533
|
/**
|
|
468
534
|
* Checks whether an item is selected.
|
|
469
|
-
* @param {
|
|
535
|
+
* @param {number|string} index - element index
|
|
470
536
|
* @returns {boolean}
|
|
471
537
|
*/
|
|
472
538
|
isSelectedItem(index) {
|
|
@@ -475,7 +541,7 @@ class THtmlItemsListContainer {
|
|
|
475
541
|
|
|
476
542
|
/**
|
|
477
543
|
* Checks whether an item is hidden.
|
|
478
|
-
* @param {
|
|
544
|
+
* @param {number|string} index - element index
|
|
479
545
|
* @returns {boolean}
|
|
480
546
|
*/
|
|
481
547
|
isHiddenItem(index) {
|
|
@@ -483,15 +549,7 @@ class THtmlItemsListContainer {
|
|
|
483
549
|
}
|
|
484
550
|
|
|
485
551
|
};
|
|
486
|
-
exports.THtmlItemsListContainer = THtmlItemsListContainer;
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* A an options set for a `THtmlStubItemsSet`-class constructor
|
|
490
|
-
* @typedef {Object} OPT_stubconsett
|
|
491
|
-
* @property {(any[])} items - array of `name`-`element` pairs
|
|
492
|
-
* @property {string} [defaultItem] - a default element name
|
|
493
|
-
* @property {boolean} [force=false] - run in a force mode
|
|
494
|
-
*/
|
|
552
|
+
module.exports.THtmlItemsListContainer = THtmlItemsListContainer;
|
|
495
553
|
|
|
496
554
|
/**
|
|
497
555
|
* An options set for `THtmlItemsListController`-class
|
|
@@ -500,7 +558,7 @@ exports.THtmlItemsListContainer = THtmlItemsListContainer;
|
|
|
500
558
|
* a new element
|
|
501
559
|
* @property {boolean} [markCurrentItem=false] - indicates whether to mark
|
|
502
560
|
* a current element
|
|
503
|
-
* @property {
|
|
561
|
+
* @property {string|string[]} [itemBaseClassID] - contains a base class
|
|
504
562
|
* attributes applayed to each a newly added list member
|
|
505
563
|
* @property {boolean} [showStubsIfEmpty=false] - indicates whether to show
|
|
506
564
|
* stubs if empty
|
|
@@ -508,7 +566,7 @@ exports.THtmlItemsListContainer = THtmlItemsListContainer;
|
|
|
508
566
|
* a selection of the elements group is allowed
|
|
509
567
|
* @property {boolean} [allowSelectionLocks=false] - indicates whether locking
|
|
510
568
|
* of an element selection is allowed
|
|
511
|
-
* @property {
|
|
569
|
+
* @property {IStubItemsSetOptions} [stubs] - stub elements options
|
|
512
570
|
*/
|
|
513
571
|
|
|
514
572
|
/**
|
|
@@ -607,9 +665,8 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
607
665
|
}
|
|
608
666
|
|
|
609
667
|
/**
|
|
610
|
-
* @param {
|
|
668
|
+
* @param {UIEvent} e - event
|
|
611
669
|
* @returns {void}
|
|
612
|
-
* @private
|
|
613
670
|
*/
|
|
614
671
|
#_on_will_select_item = (e) => {
|
|
615
672
|
//console.log('THtmlItemsListController._on_will_select_item() ==> was called...');
|
|
@@ -674,7 +731,6 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
674
731
|
* @param {string} name - event name
|
|
675
732
|
* @param {...any} args
|
|
676
733
|
* @returns {void}
|
|
677
|
-
* @private
|
|
678
734
|
* @see triggerEventHandler
|
|
679
735
|
*/
|
|
680
736
|
#_triggerEvent = (name, ...args) => {
|
|
@@ -754,10 +810,9 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
754
810
|
|
|
755
811
|
/**
|
|
756
812
|
* Sets a current index.
|
|
757
|
-
* @param {
|
|
813
|
+
* @param {number|string} index - element index
|
|
758
814
|
* @returns {boolean}
|
|
759
815
|
* @fires THtmlItemsListController#current-item-chosen
|
|
760
|
-
* @private
|
|
761
816
|
*/
|
|
762
817
|
#_setCurIndex(index) {
|
|
763
818
|
const isSUCCEED = super.setCurIndex(index);
|
|
@@ -776,7 +831,7 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
776
831
|
|
|
777
832
|
/**
|
|
778
833
|
* Sets a current index.
|
|
779
|
-
* @param {
|
|
834
|
+
* @param {number|string} index - element index
|
|
780
835
|
* @returns {boolean}
|
|
781
836
|
*/
|
|
782
837
|
setCurIndex(index) {
|
|
@@ -868,7 +923,7 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
868
923
|
|
|
869
924
|
/**
|
|
870
925
|
* Deletes an element from an instance members.
|
|
871
|
-
* @param {
|
|
926
|
+
* @param {number|string} index - element index
|
|
872
927
|
* @param {any} [opt]
|
|
873
928
|
* @returns {boolean}
|
|
874
929
|
* @fires THtmlItemsListController#list-clear
|
|
@@ -928,15 +983,14 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
928
983
|
|
|
929
984
|
/**
|
|
930
985
|
* Selects an element.
|
|
931
|
-
* @param {
|
|
986
|
+
* @param {number|string} index - element index
|
|
932
987
|
* @returns {boolean}
|
|
933
|
-
* @private
|
|
934
988
|
* @fires THtmlItemsListController#item-selected
|
|
935
989
|
*/
|
|
936
990
|
#_selectItem(index) {
|
|
937
991
|
const item = super.getItem(index);
|
|
938
|
-
|
|
939
|
-
if (
|
|
992
|
+
let isSucceed = false;
|
|
993
|
+
if (item && (isSucceed = selectHTMLElement(item))) {
|
|
940
994
|
this.#_selects.add(item);
|
|
941
995
|
/**
|
|
942
996
|
* @event THtmlItemsListController#item-selected
|
|
@@ -949,18 +1003,22 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
949
1003
|
item: item,
|
|
950
1004
|
});
|
|
951
1005
|
};
|
|
952
|
-
return
|
|
1006
|
+
return isSucceed;
|
|
953
1007
|
}
|
|
954
1008
|
|
|
1009
|
+
/**
|
|
1010
|
+
*
|
|
1011
|
+
* @typedef {Object} OPT_selectStat
|
|
1012
|
+
* @property {boolean} [ctrlKey=false]
|
|
1013
|
+
* @property {boolean} [shiftKey=false]
|
|
1014
|
+
* @property {boolean} [forceCI=false]
|
|
1015
|
+
*/
|
|
1016
|
+
|
|
955
1017
|
/**
|
|
956
1018
|
* Selects an element.
|
|
957
|
-
* @param {
|
|
958
|
-
* @param {
|
|
959
|
-
* @param {boolean} [opt.ctrlKey=false]
|
|
960
|
-
* @param {boolean} [opt.shiftKey=false]
|
|
961
|
-
* @param {boolean} [opt.forceCI=false]
|
|
1019
|
+
* @param {HTMLElement} item - element
|
|
1020
|
+
* @param {OPT_selectStat} opt - select options
|
|
962
1021
|
* @returns {void}
|
|
963
|
-
* @private
|
|
964
1022
|
*/
|
|
965
1023
|
#_selectItemEx(item, opt){
|
|
966
1024
|
const _selects = this.#_selects;
|
|
@@ -1016,34 +1074,35 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
1016
1074
|
|
|
1017
1075
|
/**
|
|
1018
1076
|
* Selects an element.
|
|
1019
|
-
* @param {
|
|
1077
|
+
* @param {number|string} index - element index
|
|
1020
1078
|
* @param {boolean} [opt=false] - indicates whether to correct a current index
|
|
1021
1079
|
* @returns {boolean}
|
|
1022
1080
|
*/
|
|
1023
1081
|
selectItem(index, opt) {
|
|
1024
1082
|
const item = super.getItem(index);
|
|
1025
|
-
let
|
|
1026
|
-
if (
|
|
1083
|
+
let isSucceed = false;
|
|
1084
|
+
if (isHTMLElement(item)) {
|
|
1027
1085
|
const forceCI = typeof opt === 'boolean' ? opt : false;
|
|
1028
1086
|
this.#_selectItemEx(item, {
|
|
1029
1087
|
ctrlKey: false,
|
|
1030
1088
|
shiftKey: false,
|
|
1031
1089
|
forceCI: forceCI,
|
|
1032
1090
|
});
|
|
1091
|
+
isSucceed = true;
|
|
1033
1092
|
};
|
|
1034
|
-
return
|
|
1093
|
+
return isSucceed;
|
|
1035
1094
|
}
|
|
1036
1095
|
|
|
1037
1096
|
/**
|
|
1038
1097
|
* Unselects an element.
|
|
1039
|
-
* @param {
|
|
1098
|
+
* @param {number|string} index - element index
|
|
1040
1099
|
* @returns {boolean}
|
|
1041
1100
|
* @fires THtmlItemsListController#item-unselected
|
|
1042
1101
|
*/
|
|
1043
1102
|
unselectItem(index) {
|
|
1044
1103
|
const item = super.getItem(index);
|
|
1045
|
-
let
|
|
1046
|
-
if (
|
|
1104
|
+
let isSucceed = false;
|
|
1105
|
+
if (item && (isSucceed = unselectHTMLElement(item))) {
|
|
1047
1106
|
this.#_selects.delete(item);
|
|
1048
1107
|
/**
|
|
1049
1108
|
* @event THtmlItemsListController#item-unselected
|
|
@@ -1056,19 +1115,19 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
1056
1115
|
item: item,
|
|
1057
1116
|
});
|
|
1058
1117
|
};
|
|
1059
|
-
return
|
|
1118
|
+
return isSucceed;
|
|
1060
1119
|
}
|
|
1061
1120
|
|
|
1062
1121
|
/**
|
|
1063
1122
|
* Hides an element.
|
|
1064
|
-
* @param {
|
|
1123
|
+
* @param {number|string} index - element index
|
|
1065
1124
|
* @returns {boolean}
|
|
1066
1125
|
* @fires THtmlItemsListController#item-hidden
|
|
1067
1126
|
*/
|
|
1068
1127
|
hideItem(index) {
|
|
1069
1128
|
const item = super.getItem(index);
|
|
1070
|
-
let
|
|
1071
|
-
if (
|
|
1129
|
+
let isSucceed = false;
|
|
1130
|
+
if (item && (isSucceed = hideHTMLElement(item))) {
|
|
1072
1131
|
/**
|
|
1073
1132
|
* @event THtmlItemsListController#item-hidden
|
|
1074
1133
|
* @type {Object}
|
|
@@ -1080,19 +1139,19 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
1080
1139
|
item: item,
|
|
1081
1140
|
});
|
|
1082
1141
|
};
|
|
1083
|
-
return
|
|
1142
|
+
return isSucceed;
|
|
1084
1143
|
}
|
|
1085
1144
|
|
|
1086
1145
|
/**
|
|
1087
1146
|
* Shows an element.
|
|
1088
|
-
* @param {
|
|
1147
|
+
* @param {number|string} index - element index
|
|
1089
1148
|
* @returns {boolean}
|
|
1090
1149
|
* @fires THtmlItemsListController#item-shown
|
|
1091
1150
|
*/
|
|
1092
1151
|
showItem(index) {
|
|
1093
1152
|
const item = super.getItem(index);
|
|
1094
|
-
let
|
|
1095
|
-
if (
|
|
1153
|
+
let isSucceed = false;
|
|
1154
|
+
if (item && (isSucceed = showHTMLElement(item))) {
|
|
1096
1155
|
/**
|
|
1097
1156
|
* @event THtmlItemsListController#item-shown
|
|
1098
1157
|
* @type {Object}
|
|
@@ -1104,7 +1163,7 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
1104
1163
|
item: item,
|
|
1105
1164
|
});
|
|
1106
1165
|
};
|
|
1107
|
-
return
|
|
1166
|
+
return isSucceed;
|
|
1108
1167
|
}
|
|
1109
1168
|
|
|
1110
1169
|
/**
|
|
@@ -1118,8 +1177,4 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
1118
1177
|
}
|
|
1119
1178
|
|
|
1120
1179
|
};
|
|
1121
|
-
exports.THtmlItemsListController = THtmlItemsListController;
|
|
1122
|
-
|
|
1123
|
-
// === module exports block ===
|
|
1124
|
-
|
|
1125
|
-
exports.THtmlStubItemsSet = THtmlStubItemsSet;
|
|
1180
|
+
module.exports.THtmlItemsListController = THtmlItemsListController;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A description for list buttons set.
|
|
3
|
+
*/
|
|
4
|
+
export type listButtonsSetDesc = {
|
|
5
|
+
/**
|
|
6
|
+
* - button 'move to first'
|
|
7
|
+
*/
|
|
8
|
+
btnFirst: HTMLElement | null;
|
|
9
|
+
/**
|
|
10
|
+
* - button 'move to previous'
|
|
11
|
+
*/
|
|
12
|
+
btnPrev: HTMLElement | null;
|
|
13
|
+
/**
|
|
14
|
+
* - button 'move to next'
|
|
15
|
+
*/
|
|
16
|
+
btnNext: HTMLElement | null;
|
|
17
|
+
/**
|
|
18
|
+
* - button 'move to last'
|
|
19
|
+
*/
|
|
20
|
+
btnLast: HTMLElement | null;
|
|
21
|
+
};
|
|
22
|
+
export const BTS_DEF_GROUP_NAME: "all";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* This class implements an interface of a pre-defined
|
|
26
|
+
* buttons set that is used in pair with a list elements.
|
|
27
|
+
* A set provide a buttons: <next>, <previous>, <first> and <last>.
|
|
28
|
+
*/
|
|
29
|
+
export class THtmlListButtonsController {
|
|
30
|
+
/**
|
|
31
|
+
* Creates an instance of a buttons set.
|
|
32
|
+
*/
|
|
33
|
+
constructor(opt?: listButtonsSetDesc);
|
|
34
|
+
/**
|
|
35
|
+
* Disables all buttons.
|
|
36
|
+
*/
|
|
37
|
+
disableAll(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Disables all buttons in 'move_bkwd' group.
|
|
40
|
+
*/
|
|
41
|
+
disableBkwd(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Disables all buttons in 'move_frwd' group.
|
|
44
|
+
*/
|
|
45
|
+
disableFrwd(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Enables all buttons.
|
|
48
|
+
*/
|
|
49
|
+
enableAll(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Enables all buttons in 'move_bkwd' group.
|
|
52
|
+
*/
|
|
53
|
+
enableBkwd(): void;
|
|
54
|
+
/**
|
|
55
|
+
* Enables all buttons in 'move_frwd' group.
|
|
56
|
+
*/
|
|
57
|
+
enableFrwd(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Sets a callback function to handle event.
|
|
60
|
+
*/
|
|
61
|
+
on(name: string, evnt: Function): void;
|
|
62
|
+
#private;
|
|
63
|
+
}
|
package/lib/lists-btn.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.063-20260505]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
@@ -18,7 +18,7 @@ const {
|
|
|
18
18
|
|
|
19
19
|
const {
|
|
20
20
|
readOnClickEventInfo,
|
|
21
|
-
} = require('./mod-hfunc
|
|
21
|
+
} = require('./mod-hfunc');
|
|
22
22
|
|
|
23
23
|
// === module inner block ===
|
|
24
24
|
|
|
@@ -33,6 +33,7 @@ const {
|
|
|
33
33
|
// === module main block ===
|
|
34
34
|
|
|
35
35
|
const BTS_DEF_GROUP_NAME = 'all';
|
|
36
|
+
module.exports.BTS_DEF_GROUP_NAME = BTS_DEF_GROUP_NAME;
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
* A description for list buttons set.
|
|
@@ -103,10 +104,9 @@ class THtmlListButtonsController {
|
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
/**
|
|
106
|
-
* @param {
|
|
107
|
+
* @param {UIEvent} e - event
|
|
107
108
|
* @param {string} key - button ID
|
|
108
109
|
* @returns {void}
|
|
109
|
-
* @private
|
|
110
110
|
*/
|
|
111
111
|
#_on_btn_pressed = (e, key) => {
|
|
112
112
|
//console.log(`THtmlListButtonsController._on_btn_pressed().key(${key}) ==> was called...`);
|
|
@@ -125,7 +125,6 @@ class THtmlListButtonsController {
|
|
|
125
125
|
* @param {string} name - event name
|
|
126
126
|
* @param {...any} args
|
|
127
127
|
* @returns {void}
|
|
128
|
-
* @private
|
|
129
128
|
* @see triggerEventHandler
|
|
130
129
|
*/
|
|
131
130
|
#_triggerEvent = (name, ...args) => {
|
|
@@ -194,8 +193,4 @@ class THtmlListButtonsController {
|
|
|
194
193
|
pushEventHandler(this.#_events, name, evnt);
|
|
195
194
|
}
|
|
196
195
|
};
|
|
197
|
-
exports.THtmlListButtonsController = THtmlListButtonsController;
|
|
198
|
-
|
|
199
|
-
// === module exports block ===
|
|
200
|
-
|
|
201
|
-
exports.BTS_DEF_GROUP_NAME = BTS_DEF_GROUP_NAME;
|
|
196
|
+
module.exports.THtmlListButtonsController = THtmlListButtonsController;
|