@cntwg/html-ctrls-lists 0.0.31 → 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 +10 -0
- package/doc/html-ctrls-list.md +11 -10
- package/index.d.ts +19 -0
- package/lib/list.d.ts +278 -0
- package/lib/list.js +103 -76
- 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 +11 -3
- package/package.json +10 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
#### *v0.0.32*
|
|
2
|
+
|
|
3
|
+
Pre-release version.
|
|
4
|
+
|
|
5
|
+
> - update `html-ctrls-list.md`;
|
|
6
|
+
> - update dependency on `@ygracs/lists-lib-js` module to v0.2.1;
|
|
7
|
+
> - update dependency on `@cntwg/html-ctrls-buttons` module to v0.1.1;
|
|
8
|
+
> - (THtmlStubItemsSet) change method behavior: `loadItems`;
|
|
9
|
+
> - some fixes.
|
|
10
|
+
|
|
1
11
|
#### *v0.0.31*
|
|
2
12
|
|
|
3
13
|
Pre-release version.
|
package/doc/html-ctrls-list.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
>|***rev.*:**|0.1.
|
|
1
|
+
>|***rev.*:**|0.1.27|
|
|
2
2
|
>|:---|---:|
|
|
3
|
-
>|date:|2026-
|
|
3
|
+
>|date:|2026-05-05|
|
|
4
4
|
|
|
5
5
|
## Introduction
|
|
6
6
|
|
|
@@ -119,12 +119,12 @@ This method returns `true` if the container has at least one item.
|
|
|
119
119
|
<a name="THtmlItemsListContainer+chkIndex"></a>
|
|
120
120
|
###### **chkIndex(value)** => `boolean`
|
|
121
121
|
|
|
122
|
-
> WARNING: \[since `v0.0.
|
|
122
|
+
> WARNING: \[since `v0.0.31`] this method deprecated (*use [`checkIndex`](#THtmlItemsListContainer+checkIndex) method instead*).
|
|
123
123
|
|
|
124
124
|
<a name="THtmlItemsListContainer+checkIndex"></a>
|
|
125
125
|
###### **checkIndex(value)** => `boolean`
|
|
126
126
|
|
|
127
|
-
> since: \[`v0.0.
|
|
127
|
+
> since: \[`v0.0.31`]
|
|
128
128
|
|
|
129
129
|
This method checks if the given `value` represents a valid index value and fits the range of all possible indexes belonging to the list instance. If so `true` is returned.
|
|
130
130
|
|
|
@@ -135,7 +135,7 @@ This method checks if the given `value` represents a valid index value and fits
|
|
|
135
135
|
<a name="THtmlItemsListContainer+tryIndex"></a>
|
|
136
136
|
###### **tryIndex(value)** => `number`
|
|
137
137
|
|
|
138
|
-
> since: \[`v0.0.
|
|
138
|
+
> since: \[`v0.0.31`]
|
|
139
139
|
|
|
140
140
|
This method evaluates whether the given `value` represents a valid index value and fits the range of all possible indexes belonging to the list instance. If so an index value returned. If failed a `-1` will be returned.
|
|
141
141
|
|
|
@@ -159,7 +159,7 @@ The `mode` parameter treats as follows:
|
|
|
159
159
|
- if set to `true`, the result returned by the method is an index;
|
|
160
160
|
- if not given or has a type of not a `boolean`, the default value is used.
|
|
161
161
|
|
|
162
|
-
> WARNING: \[since `v0.0.
|
|
162
|
+
> WARNING: \[since `v0.0.31`] this method deprecated (*use [`checkIndex`](#THtmlItemsListContainer+checkIndex) or [`tryIndex`](#THtmlItemsListContainer+tryIndex) method instead*).
|
|
163
163
|
|
|
164
164
|
<a name="THtmlItemsListContainer+srchIndex"></a>
|
|
165
165
|
###### **srchIndex(item)** => `number`
|
|
@@ -452,12 +452,12 @@ This method returns `true` if the list has at least one item.
|
|
|
452
452
|
<a name="THtmlItemsListController+chkIndex"></a>
|
|
453
453
|
###### **chkIndex(value)** => `boolean`
|
|
454
454
|
|
|
455
|
-
> WARNING: \[since `v0.0.
|
|
455
|
+
> WARNING: \[since `v0.0.31`] this method deprecated (*use [`checkIndex`](#THtmlItemsListController+checkIndex) method instead*).
|
|
456
456
|
|
|
457
457
|
<a name="THtmlItemsListController+checkIndex"></a>
|
|
458
458
|
###### **checkIndex(value)** => `boolean`
|
|
459
459
|
|
|
460
|
-
> since: \[`v0.0.
|
|
460
|
+
> since: \[`v0.0.31`]
|
|
461
461
|
|
|
462
462
|
This method checks if the given `value` represents a valid index value and fits the range of all possible indexes belonging to the list instance. If so `true` is returned.
|
|
463
463
|
|
|
@@ -468,7 +468,7 @@ This method checks if the given `value` represents a valid index value and fits
|
|
|
468
468
|
<a name="THtmlItemsListController+tryIndex"></a>
|
|
469
469
|
###### **tryIndex(value)** => `number`
|
|
470
470
|
|
|
471
|
-
> since: \[`v0.0.
|
|
471
|
+
> since: \[`v0.0.31`]
|
|
472
472
|
|
|
473
473
|
This method evaluates whether the given `value` represents a valid index value and fits the range of all possible indexes belonging to the list instance. If so an index value returned. If failed a `-1` will be returned.
|
|
474
474
|
|
|
@@ -490,7 +490,7 @@ If `mode` parameter set to `false` (*its default value*), the result returned by
|
|
|
490
490
|
|
|
491
491
|
If `mode` parameter set to `true`, the result returned by the method has an index type.
|
|
492
492
|
|
|
493
|
-
> WARNING: \[since `v0.0.
|
|
493
|
+
> WARNING: \[since `v0.0.31`] this method deprecated (*use [`checkIndex`](#THtmlItemsListController+checkIndex) or [`tryIndex`](#THtmlItemsListController+tryIndex) method instead*).
|
|
494
494
|
|
|
495
495
|
<a name="THtmlItemsListController+srchIndex"></a>
|
|
496
496
|
###### **srchIndex(item)** => `number`
|
|
@@ -816,6 +816,7 @@ This class methods loads an items given by `list` in the set and returned quanti
|
|
|
816
816
|
| `options` | `boolean`, `object` | --- | an options |
|
|
817
817
|
|
|
818
818
|
> \[!] NOTE: *`[since v0.0.25]`* the use of a booleans as an `options` value is deprecated and will be dropped soon.
|
|
819
|
+
> \[!] NOTE: *`[since v0.0.32]`* the use of an array as an `data` value is deprecated and will be dropped soon.
|
|
819
820
|
|
|
820
821
|
If the `data` parameter is an `object` that contains the following set of values:
|
|
821
822
|
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
THtmlStubItemsSet,
|
|
3
|
+
} from "./lib/lists-stubs";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
BTS_DEF_GROUP_NAME,
|
|
7
|
+
THtmlListButtonsController,
|
|
8
|
+
} from "./lib/lists-btn";
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
THtmlItemsListContainer, THtmlItemsListController,
|
|
12
|
+
} from "./lib/list";
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
THtmlStubItemsSet,
|
|
16
|
+
THtmlItemsListContainer, THtmlItemsListController,
|
|
17
|
+
BTS_DEF_GROUP_NAME,
|
|
18
|
+
THtmlListButtonsController,
|
|
19
|
+
};
|
package/lib/list.d.ts
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
export type ISearchListElementResultOnFail = {
|
|
2
|
+
/**
|
|
3
|
+
* - element index
|
|
4
|
+
*/
|
|
5
|
+
index: number;
|
|
6
|
+
/**
|
|
7
|
+
* - found element
|
|
8
|
+
*/
|
|
9
|
+
item: null;
|
|
10
|
+
};
|
|
11
|
+
export type ISearchListElementResultOnSuccess = {
|
|
12
|
+
/**
|
|
13
|
+
* - element index
|
|
14
|
+
*/
|
|
15
|
+
index: number;
|
|
16
|
+
/**
|
|
17
|
+
* - found element
|
|
18
|
+
*/
|
|
19
|
+
item: any;
|
|
20
|
+
};
|
|
21
|
+
export type ISearchListElementResult = ISearchListElementResultOnFail | ISearchListElementResultOnSuccess;
|
|
22
|
+
/**
|
|
23
|
+
* An options set for `THtmlItemsListContainer`-class
|
|
24
|
+
*/
|
|
25
|
+
export type OPT_hlconsett = {
|
|
26
|
+
/**
|
|
27
|
+
* - indicates whether to hide a new element
|
|
28
|
+
*/
|
|
29
|
+
autoHideNewItems?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* - indicates whether to mark a current element
|
|
32
|
+
*/
|
|
33
|
+
markCurrentItem?: boolean | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* - contains a base class
|
|
36
|
+
* attributes applayed to each a newly added list member
|
|
37
|
+
*/
|
|
38
|
+
itemBaseClassID?: string | string[];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* An options set for `THtmlItemsListController`-class
|
|
42
|
+
*/
|
|
43
|
+
export type OPT_hlctlsett = {
|
|
44
|
+
/**
|
|
45
|
+
* - indicates whether to hide a new element
|
|
46
|
+
*/
|
|
47
|
+
autoHideNewItems?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* - indicates whether to mark a current element
|
|
50
|
+
*/
|
|
51
|
+
markCurrentItem?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* - contains a base class
|
|
54
|
+
* attributes applayed to each a newly added list member
|
|
55
|
+
*/
|
|
56
|
+
itemBaseClassID?: string | string[];
|
|
57
|
+
/**
|
|
58
|
+
* - indicates whether to show stubs if empty
|
|
59
|
+
*/
|
|
60
|
+
showStubsIfEmpty?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* - indicates whether a selection of the elements group is allowed
|
|
63
|
+
*/
|
|
64
|
+
allowGroupSelection?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* - indicates whether locking of an element selection is allowed
|
|
67
|
+
*/
|
|
68
|
+
allowSelectionLocks?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* - stub elements options
|
|
71
|
+
*/
|
|
72
|
+
stubs?: IStubItemsSetOptions | undefined;
|
|
73
|
+
};
|
|
74
|
+
import type { IStubItemsSetOptions } from "./lists-stubs";
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* This class implements an interfaco for a list container
|
|
78
|
+
*/
|
|
79
|
+
export class THtmlItemsListContainer {
|
|
80
|
+
/**
|
|
81
|
+
* Creates an instance of a list container
|
|
82
|
+
*/
|
|
83
|
+
constructor(host: HTMLElement | null, opt?: OPT_hlconsett);
|
|
84
|
+
/**
|
|
85
|
+
* Contains a Qty of an elements
|
|
86
|
+
*/
|
|
87
|
+
get count(): number;
|
|
88
|
+
/**
|
|
89
|
+
* Contains an index of the current element
|
|
90
|
+
*/
|
|
91
|
+
get curIndex(): number;
|
|
92
|
+
/**
|
|
93
|
+
* Returns a minimum value of an index
|
|
94
|
+
*/
|
|
95
|
+
get minIndex(): number;
|
|
96
|
+
/**
|
|
97
|
+
* Returns a maximum value of an index
|
|
98
|
+
*/
|
|
99
|
+
get maxIndex(): number;
|
|
100
|
+
/**
|
|
101
|
+
* Returns a value of a previous index
|
|
102
|
+
*/
|
|
103
|
+
get prevIndex(): number;
|
|
104
|
+
/**
|
|
105
|
+
* Returns a value of a next index
|
|
106
|
+
*/
|
|
107
|
+
get nextIndex(): number;
|
|
108
|
+
/**
|
|
109
|
+
* Returns an element in the current index
|
|
110
|
+
*/
|
|
111
|
+
get curItem(): HTMLElement | null;
|
|
112
|
+
/**
|
|
113
|
+
* Clears an instance content.
|
|
114
|
+
*/
|
|
115
|
+
clear(): void;
|
|
116
|
+
/**
|
|
117
|
+
* Checks if an instance contains no items.
|
|
118
|
+
*/
|
|
119
|
+
isEmpty(): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Checks if an instance contains any items.
|
|
122
|
+
*/
|
|
123
|
+
isNotEmpty(): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Checks if a given value is a valid index and
|
|
126
|
+
* it fits an index range within an instance.
|
|
127
|
+
* @deprecated
|
|
128
|
+
* @todo \[since v0.0.31] deprecated. Use
|
|
129
|
+
* {@link THtmlItemsListContainer.checkIndex} instead
|
|
130
|
+
*/
|
|
131
|
+
chkIndex(value: number | string): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Checks if a given value is a valid index and
|
|
134
|
+
* it fits an index range within an instance.
|
|
135
|
+
* @since 0.0.31
|
|
136
|
+
*/
|
|
137
|
+
checkIndex(value: number | string): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Checks if a given value is a valid index and
|
|
140
|
+
* it fits an index range within an instance.
|
|
141
|
+
* @deprecated
|
|
142
|
+
* @todo \[since v0.0.31] deprecated. Use
|
|
143
|
+
* {@link THtmlItemsListContainer.checkIndex} or
|
|
144
|
+
* {@link THtmlItemsListContainer.tryIndex} instead
|
|
145
|
+
*/
|
|
146
|
+
chkIndexEx(value: number | string, opt?: boolean): boolean | number;
|
|
147
|
+
/**
|
|
148
|
+
* Returns an index in case a given value is a valid index value and not exceeds
|
|
149
|
+
* an index range within the list. If failed a `-1` returned
|
|
150
|
+
* @since 0.0.31
|
|
151
|
+
*/
|
|
152
|
+
tryIndex(value: any): number;
|
|
153
|
+
/**
|
|
154
|
+
* Returns an index of a given element.
|
|
155
|
+
* @param {HTMLElement} item - element to search
|
|
156
|
+
* @todo add 2nd param
|
|
157
|
+
* @see TItemsListEx.srchIndex
|
|
158
|
+
*/
|
|
159
|
+
srchIndex(item: HTMLElement): number;
|
|
160
|
+
/**
|
|
161
|
+
* Returns an index of an element wich has an attribute
|
|
162
|
+
* with a given name and value.
|
|
163
|
+
*/
|
|
164
|
+
srchIndexByAttr(name: string, value?: any): number;
|
|
165
|
+
/**
|
|
166
|
+
* Returns an index of an element wich has a given ID.
|
|
167
|
+
*/
|
|
168
|
+
srchIndexByID(value: string): number;
|
|
169
|
+
/**
|
|
170
|
+
* Sets a current index.
|
|
171
|
+
*/
|
|
172
|
+
setCurIndex(index: number | string): boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Resets a current index.
|
|
175
|
+
*/
|
|
176
|
+
rstCurIndex(): void;
|
|
177
|
+
/**
|
|
178
|
+
* Returns an item addressed by a given index.
|
|
179
|
+
*/
|
|
180
|
+
getItem(index: number | string): HTMLElement | null;
|
|
181
|
+
/**
|
|
182
|
+
* Returns an item wich has an attribute with a given name and value.
|
|
183
|
+
*/
|
|
184
|
+
getItemByAttr(name: string, value?: any): HTMLElement | null;
|
|
185
|
+
/**
|
|
186
|
+
* Returns an item wich has a given ID.
|
|
187
|
+
*/
|
|
188
|
+
getItemByID(value: string): HTMLElement | null;
|
|
189
|
+
/**
|
|
190
|
+
* Adds an item to an instance.
|
|
191
|
+
*/
|
|
192
|
+
addItem(item: HTMLElement, opt?: boolean): number;
|
|
193
|
+
/**
|
|
194
|
+
* Deletes an item from an instance.
|
|
195
|
+
*/
|
|
196
|
+
delItem(index: number | string, opt?: any, optEx?: boolean): boolean;
|
|
197
|
+
/**
|
|
198
|
+
* Selects an item addressed by a given index.
|
|
199
|
+
*/
|
|
200
|
+
selectItem(index: number | string, opt?: boolean): boolean;
|
|
201
|
+
/**
|
|
202
|
+
* Unselects an item addressed by a given index.
|
|
203
|
+
*/
|
|
204
|
+
unselectItem(index: number | string): boolean;
|
|
205
|
+
/**
|
|
206
|
+
* Hides an item addressed by a given index.
|
|
207
|
+
*/
|
|
208
|
+
hideItem(index: number | string): boolean;
|
|
209
|
+
/**
|
|
210
|
+
* Shows an item addressed by a given index.
|
|
211
|
+
*/
|
|
212
|
+
showItem(index: number | string): boolean;
|
|
213
|
+
/**
|
|
214
|
+
* Checks whether an item is selected.
|
|
215
|
+
*/
|
|
216
|
+
isSelectedItem(index: number | string): boolean;
|
|
217
|
+
/**
|
|
218
|
+
* Checks whether an item is hidden.
|
|
219
|
+
*/
|
|
220
|
+
isHiddenItem(index: number | string): boolean;
|
|
221
|
+
[Symbol.iterator](): {
|
|
222
|
+
next: () => {
|
|
223
|
+
done: boolean;
|
|
224
|
+
value: HTMLElement | null;
|
|
225
|
+
} | {
|
|
226
|
+
done: boolean;
|
|
227
|
+
value: undefined;
|
|
228
|
+
};
|
|
229
|
+
return(): {
|
|
230
|
+
done: boolean;
|
|
231
|
+
value: undefined;
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
#private;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* This class enhanced a capabilities implemented
|
|
239
|
+
* in the `THtmlItemsListContainer` class
|
|
240
|
+
*/
|
|
241
|
+
export class THtmlItemsListController extends THtmlItemsListContainer {
|
|
242
|
+
/**
|
|
243
|
+
* Creates a new instance of the class.
|
|
244
|
+
*/
|
|
245
|
+
constructor(host: HTMLElement | null, opt?: OPT_hlctlsett);
|
|
246
|
+
/**
|
|
247
|
+
* Returns a list of the selected elements
|
|
248
|
+
*/
|
|
249
|
+
get SelectedItems(): HTMLElement[];
|
|
250
|
+
/**
|
|
251
|
+
* Returns a `THtmlStubItemsSet` instance
|
|
252
|
+
*/
|
|
253
|
+
get StubItems(): THtmlStubItemsSet;
|
|
254
|
+
/**
|
|
255
|
+
* Indicates whether a selection is locked
|
|
256
|
+
*/
|
|
257
|
+
get isSelectionLocked(): boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Locks an element selection.
|
|
260
|
+
*/
|
|
261
|
+
lockItemsSelection(): void;
|
|
262
|
+
/**
|
|
263
|
+
* Unlocks an element selection.
|
|
264
|
+
*/
|
|
265
|
+
unlockItemsSelection(): void;
|
|
266
|
+
/**
|
|
267
|
+
* Deletes an element from an instance members.
|
|
268
|
+
* @fires THtmlItemsListController#list-clear
|
|
269
|
+
* @fires THtmlItemsListController#item-removed
|
|
270
|
+
*/
|
|
271
|
+
delItem(index: number | string, opt?: any): boolean;
|
|
272
|
+
/**
|
|
273
|
+
* Sets a callback function to handle event.
|
|
274
|
+
*/
|
|
275
|
+
on(name: string, evnt: Function): void;
|
|
276
|
+
#private;
|
|
277
|
+
}
|
|
278
|
+
import { THtmlStubItemsSet } from "./lists-stubs";
|
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]() {
|
|
@@ -256,7 +294,7 @@ class THtmlItemsListContainer {
|
|
|
256
294
|
* @param {number|string} value - index value
|
|
257
295
|
* @returns {boolean}
|
|
258
296
|
* @deprecated
|
|
259
|
-
* @todo \[since v0.0.
|
|
297
|
+
* @todo \[since v0.0.31] deprecated. Use
|
|
260
298
|
* {@link THtmlItemsListContainer.checkIndex} instead
|
|
261
299
|
*/
|
|
262
300
|
chkIndex(value) {
|
|
@@ -266,7 +304,7 @@ class THtmlItemsListContainer {
|
|
|
266
304
|
/**
|
|
267
305
|
* Checks if a given value is a valid index and
|
|
268
306
|
* it fits an index range within an instance.
|
|
269
|
-
* @since 0.0.
|
|
307
|
+
* @since 0.0.31
|
|
270
308
|
* @param {number|string} value - index value
|
|
271
309
|
* @returns {boolean}
|
|
272
310
|
*/
|
|
@@ -280,8 +318,8 @@ class THtmlItemsListContainer {
|
|
|
280
318
|
* @param {number|string} value - value to check
|
|
281
319
|
* @param {boolean} [opt=false] - defines a type of result
|
|
282
320
|
* @returns {boolean|number}
|
|
283
|
-
* @
|
|
284
|
-
* @todo \[since v0.0.
|
|
321
|
+
* @deprecated
|
|
322
|
+
* @todo \[since v0.0.31] deprecated. Use
|
|
285
323
|
* {@link THtmlItemsListContainer.checkIndex} or
|
|
286
324
|
* {@link THtmlItemsListContainer.tryIndex} instead
|
|
287
325
|
*/
|
|
@@ -292,7 +330,7 @@ class THtmlItemsListContainer {
|
|
|
292
330
|
/**
|
|
293
331
|
* Returns an index in case a given value is a valid index value and not exceeds
|
|
294
332
|
* an index range within the list. If failed a `-1` returned
|
|
295
|
-
* @since 0.0.
|
|
333
|
+
* @since 0.0.31
|
|
296
334
|
* @param {any} value - value to evaluate
|
|
297
335
|
* @returns {number}
|
|
298
336
|
*/
|
|
@@ -336,13 +374,13 @@ class THtmlItemsListContainer {
|
|
|
336
374
|
|
|
337
375
|
/**
|
|
338
376
|
* Sets a current index.
|
|
339
|
-
* @param {
|
|
377
|
+
* @param {number|string} index - element index
|
|
340
378
|
* @returns {boolean}
|
|
341
379
|
*/
|
|
342
380
|
setCurIndex(index) {
|
|
343
381
|
const isSUCCEED = this.#_items.setIndex(index);
|
|
344
382
|
if (isSUCCEED) {
|
|
345
|
-
const markCurrentItem = this.#
|
|
383
|
+
const markCurrentItem = this.#_config.markCurrentItem;
|
|
346
384
|
const _status = this.#_status;
|
|
347
385
|
if (markCurrentItem && _status.curIndex !== -1) {
|
|
348
386
|
unmarkCurrentHTMLElement(_status.curItem);
|
|
@@ -361,7 +399,7 @@ class THtmlItemsListContainer {
|
|
|
361
399
|
*/
|
|
362
400
|
rstCurIndex() {
|
|
363
401
|
const _status = this.#_status;
|
|
364
|
-
if (this.#
|
|
402
|
+
if (this.#_config.markCurrentItem && _status.curIndex !== -1) {
|
|
365
403
|
unmarkCurrentHTMLElement(_status.curItem);
|
|
366
404
|
};
|
|
367
405
|
this.#_items.rstIndex();
|
|
@@ -371,7 +409,7 @@ class THtmlItemsListContainer {
|
|
|
371
409
|
|
|
372
410
|
/**
|
|
373
411
|
* Returns an item addressed by a given index.
|
|
374
|
-
* @param {
|
|
412
|
+
* @param {number|string} index - element index
|
|
375
413
|
* @returns {?HTMLElement}
|
|
376
414
|
*/
|
|
377
415
|
getItem(index) {
|
|
@@ -416,7 +454,7 @@ class THtmlItemsListContainer {
|
|
|
416
454
|
);
|
|
417
455
|
const isSUCCEED = index !== -1;
|
|
418
456
|
if (isSUCCEED) {
|
|
419
|
-
const { autoHideNewItems, itemBaseClassID } = this.#
|
|
457
|
+
const { autoHideNewItems, itemBaseClassID } = this.#_config;
|
|
420
458
|
if (autoHideNewItems) hideHTMLElement(item);
|
|
421
459
|
if (itemBaseClassID.length > 0) item.classList.add(...itemBaseClassID);
|
|
422
460
|
if (forceCI) this.setCurIndex(index);
|
|
@@ -428,7 +466,7 @@ class THtmlItemsListContainer {
|
|
|
428
466
|
|
|
429
467
|
/**
|
|
430
468
|
* Deletes an item from an instance.
|
|
431
|
-
* @param {
|
|
469
|
+
* @param {number|string} index - element index
|
|
432
470
|
* @param {any} [opt]
|
|
433
471
|
* @param {boolean} [optEx=true]
|
|
434
472
|
* @returns {boolean}
|
|
@@ -454,7 +492,7 @@ class THtmlItemsListContainer {
|
|
|
454
492
|
|
|
455
493
|
/**
|
|
456
494
|
* Selects an item addressed by a given index.
|
|
457
|
-
* @param {
|
|
495
|
+
* @param {number|string} index - element index
|
|
458
496
|
* @param {boolean} [opt=false] - indicates whether to correct a current index
|
|
459
497
|
* @returns {boolean}
|
|
460
498
|
*/
|
|
@@ -467,7 +505,7 @@ class THtmlItemsListContainer {
|
|
|
467
505
|
|
|
468
506
|
/**
|
|
469
507
|
* Unselects an item addressed by a given index.
|
|
470
|
-
* @param {
|
|
508
|
+
* @param {number|string} index - element index
|
|
471
509
|
* @returns {boolean}
|
|
472
510
|
*/
|
|
473
511
|
unselectItem(index) {
|
|
@@ -476,7 +514,7 @@ class THtmlItemsListContainer {
|
|
|
476
514
|
|
|
477
515
|
/**
|
|
478
516
|
* Hides an item addressed by a given index.
|
|
479
|
-
* @param {
|
|
517
|
+
* @param {number|string} index - element index
|
|
480
518
|
* @returns {boolean}
|
|
481
519
|
*/
|
|
482
520
|
hideItem(index) {
|
|
@@ -485,7 +523,7 @@ class THtmlItemsListContainer {
|
|
|
485
523
|
|
|
486
524
|
/**
|
|
487
525
|
* Shows an item addressed by a given index.
|
|
488
|
-
* @param {
|
|
526
|
+
* @param {number|string} index - element index
|
|
489
527
|
* @returns {boolean}
|
|
490
528
|
*/
|
|
491
529
|
showItem(index) {
|
|
@@ -494,7 +532,7 @@ class THtmlItemsListContainer {
|
|
|
494
532
|
|
|
495
533
|
/**
|
|
496
534
|
* Checks whether an item is selected.
|
|
497
|
-
* @param {
|
|
535
|
+
* @param {number|string} index - element index
|
|
498
536
|
* @returns {boolean}
|
|
499
537
|
*/
|
|
500
538
|
isSelectedItem(index) {
|
|
@@ -503,7 +541,7 @@ class THtmlItemsListContainer {
|
|
|
503
541
|
|
|
504
542
|
/**
|
|
505
543
|
* Checks whether an item is hidden.
|
|
506
|
-
* @param {
|
|
544
|
+
* @param {number|string} index - element index
|
|
507
545
|
* @returns {boolean}
|
|
508
546
|
*/
|
|
509
547
|
isHiddenItem(index) {
|
|
@@ -511,15 +549,7 @@ class THtmlItemsListContainer {
|
|
|
511
549
|
}
|
|
512
550
|
|
|
513
551
|
};
|
|
514
|
-
exports.THtmlItemsListContainer = THtmlItemsListContainer;
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* A an options set for a `THtmlStubItemsSet`-class constructor
|
|
518
|
-
* @typedef {Object} OPT_stubconsett
|
|
519
|
-
* @property {(any[])} items - array of `name`-`element` pairs
|
|
520
|
-
* @property {string} [defaultItem] - a default element name
|
|
521
|
-
* @property {boolean} [force=false] - run in a force mode
|
|
522
|
-
*/
|
|
552
|
+
module.exports.THtmlItemsListContainer = THtmlItemsListContainer;
|
|
523
553
|
|
|
524
554
|
/**
|
|
525
555
|
* An options set for `THtmlItemsListController`-class
|
|
@@ -528,7 +558,7 @@ exports.THtmlItemsListContainer = THtmlItemsListContainer;
|
|
|
528
558
|
* a new element
|
|
529
559
|
* @property {boolean} [markCurrentItem=false] - indicates whether to mark
|
|
530
560
|
* a current element
|
|
531
|
-
* @property {
|
|
561
|
+
* @property {string|string[]} [itemBaseClassID] - contains a base class
|
|
532
562
|
* attributes applayed to each a newly added list member
|
|
533
563
|
* @property {boolean} [showStubsIfEmpty=false] - indicates whether to show
|
|
534
564
|
* stubs if empty
|
|
@@ -536,7 +566,7 @@ exports.THtmlItemsListContainer = THtmlItemsListContainer;
|
|
|
536
566
|
* a selection of the elements group is allowed
|
|
537
567
|
* @property {boolean} [allowSelectionLocks=false] - indicates whether locking
|
|
538
568
|
* of an element selection is allowed
|
|
539
|
-
* @property {
|
|
569
|
+
* @property {IStubItemsSetOptions} [stubs] - stub elements options
|
|
540
570
|
*/
|
|
541
571
|
|
|
542
572
|
/**
|
|
@@ -635,9 +665,8 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
635
665
|
}
|
|
636
666
|
|
|
637
667
|
/**
|
|
638
|
-
* @param {
|
|
668
|
+
* @param {UIEvent} e - event
|
|
639
669
|
* @returns {void}
|
|
640
|
-
* @private
|
|
641
670
|
*/
|
|
642
671
|
#_on_will_select_item = (e) => {
|
|
643
672
|
//console.log('THtmlItemsListController._on_will_select_item() ==> was called...');
|
|
@@ -702,7 +731,6 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
702
731
|
* @param {string} name - event name
|
|
703
732
|
* @param {...any} args
|
|
704
733
|
* @returns {void}
|
|
705
|
-
* @private
|
|
706
734
|
* @see triggerEventHandler
|
|
707
735
|
*/
|
|
708
736
|
#_triggerEvent = (name, ...args) => {
|
|
@@ -782,10 +810,9 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
782
810
|
|
|
783
811
|
/**
|
|
784
812
|
* Sets a current index.
|
|
785
|
-
* @param {
|
|
813
|
+
* @param {number|string} index - element index
|
|
786
814
|
* @returns {boolean}
|
|
787
815
|
* @fires THtmlItemsListController#current-item-chosen
|
|
788
|
-
* @private
|
|
789
816
|
*/
|
|
790
817
|
#_setCurIndex(index) {
|
|
791
818
|
const isSUCCEED = super.setCurIndex(index);
|
|
@@ -804,7 +831,7 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
804
831
|
|
|
805
832
|
/**
|
|
806
833
|
* Sets a current index.
|
|
807
|
-
* @param {
|
|
834
|
+
* @param {number|string} index - element index
|
|
808
835
|
* @returns {boolean}
|
|
809
836
|
*/
|
|
810
837
|
setCurIndex(index) {
|
|
@@ -896,7 +923,7 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
896
923
|
|
|
897
924
|
/**
|
|
898
925
|
* Deletes an element from an instance members.
|
|
899
|
-
* @param {
|
|
926
|
+
* @param {number|string} index - element index
|
|
900
927
|
* @param {any} [opt]
|
|
901
928
|
* @returns {boolean}
|
|
902
929
|
* @fires THtmlItemsListController#list-clear
|
|
@@ -956,15 +983,14 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
956
983
|
|
|
957
984
|
/**
|
|
958
985
|
* Selects an element.
|
|
959
|
-
* @param {
|
|
986
|
+
* @param {number|string} index - element index
|
|
960
987
|
* @returns {boolean}
|
|
961
|
-
* @private
|
|
962
988
|
* @fires THtmlItemsListController#item-selected
|
|
963
989
|
*/
|
|
964
990
|
#_selectItem(index) {
|
|
965
991
|
const item = super.getItem(index);
|
|
966
|
-
|
|
967
|
-
if (
|
|
992
|
+
let isSucceed = false;
|
|
993
|
+
if (item && (isSucceed = selectHTMLElement(item))) {
|
|
968
994
|
this.#_selects.add(item);
|
|
969
995
|
/**
|
|
970
996
|
* @event THtmlItemsListController#item-selected
|
|
@@ -977,18 +1003,22 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
977
1003
|
item: item,
|
|
978
1004
|
});
|
|
979
1005
|
};
|
|
980
|
-
return
|
|
1006
|
+
return isSucceed;
|
|
981
1007
|
}
|
|
982
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
|
+
|
|
983
1017
|
/**
|
|
984
1018
|
* Selects an element.
|
|
985
|
-
* @param {
|
|
986
|
-
* @param {
|
|
987
|
-
* @param {boolean} [opt.ctrlKey=false]
|
|
988
|
-
* @param {boolean} [opt.shiftKey=false]
|
|
989
|
-
* @param {boolean} [opt.forceCI=false]
|
|
1019
|
+
* @param {HTMLElement} item - element
|
|
1020
|
+
* @param {OPT_selectStat} opt - select options
|
|
990
1021
|
* @returns {void}
|
|
991
|
-
* @private
|
|
992
1022
|
*/
|
|
993
1023
|
#_selectItemEx(item, opt){
|
|
994
1024
|
const _selects = this.#_selects;
|
|
@@ -1044,34 +1074,35 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
1044
1074
|
|
|
1045
1075
|
/**
|
|
1046
1076
|
* Selects an element.
|
|
1047
|
-
* @param {
|
|
1077
|
+
* @param {number|string} index - element index
|
|
1048
1078
|
* @param {boolean} [opt=false] - indicates whether to correct a current index
|
|
1049
1079
|
* @returns {boolean}
|
|
1050
1080
|
*/
|
|
1051
1081
|
selectItem(index, opt) {
|
|
1052
1082
|
const item = super.getItem(index);
|
|
1053
|
-
let
|
|
1054
|
-
if (
|
|
1083
|
+
let isSucceed = false;
|
|
1084
|
+
if (isHTMLElement(item)) {
|
|
1055
1085
|
const forceCI = typeof opt === 'boolean' ? opt : false;
|
|
1056
1086
|
this.#_selectItemEx(item, {
|
|
1057
1087
|
ctrlKey: false,
|
|
1058
1088
|
shiftKey: false,
|
|
1059
1089
|
forceCI: forceCI,
|
|
1060
1090
|
});
|
|
1091
|
+
isSucceed = true;
|
|
1061
1092
|
};
|
|
1062
|
-
return
|
|
1093
|
+
return isSucceed;
|
|
1063
1094
|
}
|
|
1064
1095
|
|
|
1065
1096
|
/**
|
|
1066
1097
|
* Unselects an element.
|
|
1067
|
-
* @param {
|
|
1098
|
+
* @param {number|string} index - element index
|
|
1068
1099
|
* @returns {boolean}
|
|
1069
1100
|
* @fires THtmlItemsListController#item-unselected
|
|
1070
1101
|
*/
|
|
1071
1102
|
unselectItem(index) {
|
|
1072
1103
|
const item = super.getItem(index);
|
|
1073
|
-
let
|
|
1074
|
-
if (
|
|
1104
|
+
let isSucceed = false;
|
|
1105
|
+
if (item && (isSucceed = unselectHTMLElement(item))) {
|
|
1075
1106
|
this.#_selects.delete(item);
|
|
1076
1107
|
/**
|
|
1077
1108
|
* @event THtmlItemsListController#item-unselected
|
|
@@ -1084,19 +1115,19 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
1084
1115
|
item: item,
|
|
1085
1116
|
});
|
|
1086
1117
|
};
|
|
1087
|
-
return
|
|
1118
|
+
return isSucceed;
|
|
1088
1119
|
}
|
|
1089
1120
|
|
|
1090
1121
|
/**
|
|
1091
1122
|
* Hides an element.
|
|
1092
|
-
* @param {
|
|
1123
|
+
* @param {number|string} index - element index
|
|
1093
1124
|
* @returns {boolean}
|
|
1094
1125
|
* @fires THtmlItemsListController#item-hidden
|
|
1095
1126
|
*/
|
|
1096
1127
|
hideItem(index) {
|
|
1097
1128
|
const item = super.getItem(index);
|
|
1098
|
-
let
|
|
1099
|
-
if (
|
|
1129
|
+
let isSucceed = false;
|
|
1130
|
+
if (item && (isSucceed = hideHTMLElement(item))) {
|
|
1100
1131
|
/**
|
|
1101
1132
|
* @event THtmlItemsListController#item-hidden
|
|
1102
1133
|
* @type {Object}
|
|
@@ -1108,19 +1139,19 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
1108
1139
|
item: item,
|
|
1109
1140
|
});
|
|
1110
1141
|
};
|
|
1111
|
-
return
|
|
1142
|
+
return isSucceed;
|
|
1112
1143
|
}
|
|
1113
1144
|
|
|
1114
1145
|
/**
|
|
1115
1146
|
* Shows an element.
|
|
1116
|
-
* @param {
|
|
1147
|
+
* @param {number|string} index - element index
|
|
1117
1148
|
* @returns {boolean}
|
|
1118
1149
|
* @fires THtmlItemsListController#item-shown
|
|
1119
1150
|
*/
|
|
1120
1151
|
showItem(index) {
|
|
1121
1152
|
const item = super.getItem(index);
|
|
1122
|
-
let
|
|
1123
|
-
if (
|
|
1153
|
+
let isSucceed = false;
|
|
1154
|
+
if (item && (isSucceed = showHTMLElement(item))) {
|
|
1124
1155
|
/**
|
|
1125
1156
|
* @event THtmlItemsListController#item-shown
|
|
1126
1157
|
* @type {Object}
|
|
@@ -1132,7 +1163,7 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
1132
1163
|
item: item,
|
|
1133
1164
|
});
|
|
1134
1165
|
};
|
|
1135
|
-
return
|
|
1166
|
+
return isSucceed;
|
|
1136
1167
|
}
|
|
1137
1168
|
|
|
1138
1169
|
/**
|
|
@@ -1146,8 +1177,4 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
1146
1177
|
}
|
|
1147
1178
|
|
|
1148
1179
|
};
|
|
1149
|
-
exports.THtmlItemsListController = THtmlItemsListController;
|
|
1150
|
-
|
|
1151
|
-
// === module exports block ===
|
|
1152
|
-
|
|
1153
|
-
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;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A set of options for a `THtmlStubItemsSet`-class constructor
|
|
3
|
+
*/
|
|
4
|
+
export type IStubItemsSetOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* - array of `name`-`element` pairs
|
|
7
|
+
*/
|
|
8
|
+
items: pairOfNameAndElement[];
|
|
9
|
+
/**
|
|
10
|
+
* - a default element name
|
|
11
|
+
*/
|
|
12
|
+
defaultItem?: string;
|
|
13
|
+
/**
|
|
14
|
+
* - run in a force mode
|
|
15
|
+
*/
|
|
16
|
+
force?: boolean | undefined;
|
|
17
|
+
};
|
|
18
|
+
export const IStubItemsSetOptions: IStubItemsSetOptions;
|
|
19
|
+
/**
|
|
20
|
+
* A `name`-`element` pair
|
|
21
|
+
*/
|
|
22
|
+
export type pairOfNameAndElement = [ name: string, item: HTMLElement ];
|
|
23
|
+
/**
|
|
24
|
+
* A settings to load a stub-elements.
|
|
25
|
+
*/
|
|
26
|
+
export type OPT_ldstubs = {
|
|
27
|
+
/**
|
|
28
|
+
* - a default element name
|
|
29
|
+
* @deprecated
|
|
30
|
+
*/
|
|
31
|
+
defaultItem?: string;
|
|
32
|
+
/**
|
|
33
|
+
* - to clear before load an elements
|
|
34
|
+
*/
|
|
35
|
+
useClear?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* - run in a force mode
|
|
38
|
+
*/
|
|
39
|
+
force?: boolean;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* A stub-elements list descriptor
|
|
43
|
+
*/
|
|
44
|
+
export type IStubEListDesc = {
|
|
45
|
+
/**
|
|
46
|
+
* - array of `name`-`element` pairs
|
|
47
|
+
*/
|
|
48
|
+
items: pairOfNameAndElement[];
|
|
49
|
+
/**
|
|
50
|
+
* - a default element name
|
|
51
|
+
*/
|
|
52
|
+
defaultItem?: string;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* This class implements an interface of a stub-items set
|
|
57
|
+
*/
|
|
58
|
+
export class THtmlStubItemsSet {
|
|
59
|
+
/**
|
|
60
|
+
* Creates an instance of a stub-items set
|
|
61
|
+
* @todo [since v0.0.26] use of an `array`-type as a value of an `opt` is deprecated
|
|
62
|
+
*/
|
|
63
|
+
constructor(host: HTMLElement, opt?: pairOfNameAndElement[] | IStubEListDesc | IStubItemsSetOptions);
|
|
64
|
+
/**
|
|
65
|
+
* Defines a default element name
|
|
66
|
+
* @type {string}
|
|
67
|
+
*/
|
|
68
|
+
set defItem(name: string);
|
|
69
|
+
get defItem(): string;
|
|
70
|
+
/**
|
|
71
|
+
* Contains a Qty of an elements
|
|
72
|
+
* @type {number}
|
|
73
|
+
*/
|
|
74
|
+
get count(): number;
|
|
75
|
+
/**
|
|
76
|
+
* Clears an instance content.
|
|
77
|
+
* @todo check if any item is shown
|
|
78
|
+
*/
|
|
79
|
+
clear(): void;
|
|
80
|
+
/**
|
|
81
|
+
* Sets a default item.
|
|
82
|
+
*/
|
|
83
|
+
setDefItem(name: string): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Resets a default item.
|
|
86
|
+
* @todo check if item is shown
|
|
87
|
+
*/
|
|
88
|
+
rstDefItem(): void;
|
|
89
|
+
/**
|
|
90
|
+
* Checks if an item exists.
|
|
91
|
+
*/
|
|
92
|
+
hasItem(name: string): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Checks if any items exists.
|
|
95
|
+
*/
|
|
96
|
+
hasItems(): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Returns an item by its name.
|
|
99
|
+
*/
|
|
100
|
+
getItem(name: string): HTMLElement | null;
|
|
101
|
+
/**
|
|
102
|
+
* Adds an item to an instance members.
|
|
103
|
+
*/
|
|
104
|
+
addItem(name: string, item: HTMLElement, opt?: boolean): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Deletes an item from an instance members.
|
|
107
|
+
* @todo check if item is shown
|
|
108
|
+
*/
|
|
109
|
+
delItem(name: string): boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Shows an item.
|
|
112
|
+
*/
|
|
113
|
+
showItem(name: string): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Shows a default item.
|
|
116
|
+
*/
|
|
117
|
+
showDefItem(): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Hides an item.
|
|
120
|
+
*/
|
|
121
|
+
hideItem(name: string): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Hides a default item.
|
|
124
|
+
*/
|
|
125
|
+
hideDefItem(): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Adds an items to an instance members.
|
|
128
|
+
* @todo [since 0.0.25] deprecate use of `opt` as `boolean`
|
|
129
|
+
* @todo [since v0.0.26] for `OPT_ldstubs` a `defaultItem`-option deprecated
|
|
130
|
+
* @todo [since 0.0.32] deprecate use of `data` as `array`
|
|
131
|
+
*/
|
|
132
|
+
loadItems(data: pairOfNameAndElement[] | IStubEListDesc, opt?: boolean | OPT_ldstubs): number;
|
|
133
|
+
#private;
|
|
134
|
+
}
|
package/lib/lists-stubs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.057-20260505]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
@@ -14,6 +14,11 @@ const {
|
|
|
14
14
|
|
|
15
15
|
// === module main block ===
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* A `name`-`element` pair
|
|
19
|
+
* @typedef {any[]} pairOfNameAndElement
|
|
20
|
+
*/
|
|
21
|
+
|
|
17
22
|
/**
|
|
18
23
|
* A settings to load a stub-elements.
|
|
19
24
|
* @typedef {Object} OPT_ldstubs
|
|
@@ -24,19 +29,24 @@ const {
|
|
|
24
29
|
*/
|
|
25
30
|
|
|
26
31
|
/**
|
|
27
|
-
* A stub-elements
|
|
28
|
-
* @typedef {Object}
|
|
29
|
-
* @property {
|
|
32
|
+
* A stub-elements list descriptor
|
|
33
|
+
* @typedef {Object} IStubEListDesc
|
|
34
|
+
* @property {pairOfNameAndElement[]} items - array of `name`-`element` pairs
|
|
30
35
|
* @property {string} [defaultItem] - a default element name
|
|
31
36
|
*/
|
|
32
37
|
|
|
33
38
|
/**
|
|
34
|
-
* A
|
|
35
|
-
* @typedef {Object}
|
|
36
|
-
* @property {
|
|
39
|
+
* A set of options for a `THtmlStubItemsSet`-class constructor
|
|
40
|
+
* @typedef {Object} IStubItemsSetOptions
|
|
41
|
+
* @property {pairOfNameAndElement[]} items - array of `name`-`element` pairs
|
|
37
42
|
* @property {string} [defaultItem] - a default element name
|
|
38
43
|
* @property {boolean} [force=false] - run in a force mode
|
|
39
44
|
*/
|
|
45
|
+
/**
|
|
46
|
+
* A virtual constant meant for support jsdoc notation:
|
|
47
|
+
* @type {IStubItemsSetOptions}
|
|
48
|
+
*/
|
|
49
|
+
module.exports.IStubItemsSetOptions = { items: [] };
|
|
40
50
|
|
|
41
51
|
/**
|
|
42
52
|
* @classdesc This class implements an interface of a stub-items set
|
|
@@ -53,7 +63,7 @@ class THtmlStubItemsSet {
|
|
|
53
63
|
/**
|
|
54
64
|
* Creates an instance of a stub-items set
|
|
55
65
|
* @param {HTMLElement} host - host element
|
|
56
|
-
* @param {
|
|
66
|
+
* @param {pairOfNameAndElement[]|IStubEListDesc|IStubItemsSetOptions} [opt] - options
|
|
57
67
|
* @todo [since v0.0.26] use of an `array`-type as a value of an `opt` is deprecated
|
|
58
68
|
*/
|
|
59
69
|
constructor(host, opt) {
|
|
@@ -62,7 +72,7 @@ class THtmlStubItemsSet {
|
|
|
62
72
|
this.#_defItem = '';
|
|
63
73
|
this.#_shownItem = null;
|
|
64
74
|
if (isObject(opt)) {
|
|
65
|
-
/** @type {
|
|
75
|
+
/** @type {IStubItemsSetOptions} */
|
|
66
76
|
const obj = isArray(opt) ? { items: opt } : opt;
|
|
67
77
|
const { items, defaultItem, force } = obj;
|
|
68
78
|
this.loadItems({
|
|
@@ -205,9 +215,12 @@ class THtmlStubItemsSet {
|
|
|
205
215
|
*/
|
|
206
216
|
showItem(name) {
|
|
207
217
|
const item = this.getItem(name);
|
|
208
|
-
|
|
209
|
-
if (
|
|
210
|
-
|
|
218
|
+
let isSucceed = false;
|
|
219
|
+
if (this.#_host && item) {
|
|
220
|
+
this.#_host.append(item);
|
|
221
|
+
isSucceed = true;
|
|
222
|
+
};
|
|
223
|
+
return isSucceed;
|
|
211
224
|
}
|
|
212
225
|
|
|
213
226
|
/**
|
|
@@ -225,9 +238,12 @@ class THtmlStubItemsSet {
|
|
|
225
238
|
*/
|
|
226
239
|
hideItem(name) {
|
|
227
240
|
const item = this.getItem(name);
|
|
228
|
-
|
|
229
|
-
if (
|
|
230
|
-
|
|
241
|
+
let isSucceed = false;
|
|
242
|
+
if (this.#_host && item && this.#_host.contains(item)) {
|
|
243
|
+
isSucceed = true;
|
|
244
|
+
item.remove();
|
|
245
|
+
};
|
|
246
|
+
return isSucceed;
|
|
231
247
|
}
|
|
232
248
|
|
|
233
249
|
/**
|
|
@@ -240,14 +256,15 @@ class THtmlStubItemsSet {
|
|
|
240
256
|
|
|
241
257
|
/**
|
|
242
258
|
* Adds an items to an instance members.
|
|
243
|
-
* @param {
|
|
244
|
-
* @param {
|
|
259
|
+
* @param {pairOfNameAndElement[]|IStubEListDesc} data - an array of entries or special object
|
|
260
|
+
* @param {boolean|OPT_ldstubs} [opt] - an options
|
|
245
261
|
* @returns {number}
|
|
246
262
|
* @todo [since 0.0.25] deprecate use of `opt` as `boolean`
|
|
247
263
|
* @todo [since v0.0.26] for `OPT_ldstubs` a `defaultItem`-option deprecated
|
|
264
|
+
* @todo [since 0.0.32] deprecate use of `data` as `array`
|
|
248
265
|
*/
|
|
249
266
|
loadItems(data, opt) {
|
|
250
|
-
/** @type {
|
|
267
|
+
/** @type {IStubEListDesc} */
|
|
251
268
|
let {
|
|
252
269
|
items,
|
|
253
270
|
defaultItem,
|
|
@@ -280,4 +297,4 @@ class THtmlStubItemsSet {
|
|
|
280
297
|
}
|
|
281
298
|
|
|
282
299
|
};
|
|
283
|
-
exports.THtmlStubItemsSet = THtmlStubItemsSet;
|
|
300
|
+
module.exports.THtmlStubItemsSet = THtmlStubItemsSet;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type IClickEventInfo = {
|
|
2
|
+
/**
|
|
3
|
+
* - some target element
|
|
4
|
+
*/
|
|
5
|
+
item: object | null;
|
|
6
|
+
/**
|
|
7
|
+
* - reflects a current click count
|
|
8
|
+
*/
|
|
9
|
+
onClickNum: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @function readOnClickEventInfo
|
|
14
|
+
* @param {UIEvent} e - event
|
|
15
|
+
* @returns {IClickEventInfo}
|
|
16
|
+
* @inner
|
|
17
|
+
*/
|
|
18
|
+
export function readOnClickEventInfo(e: UIEvent): IClickEventInfo;
|
package/lib/mod-hfunc.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.068-20260422]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
@@ -6,10 +6,18 @@
|
|
|
6
6
|
|
|
7
7
|
// === module main block ===
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @typedef {Object} IClickEventInfo
|
|
12
|
+
* @property {?object} item - some target element
|
|
13
|
+
* @property {number} onClickNum - reflects a current click count
|
|
14
|
+
* @inner
|
|
15
|
+
*/
|
|
16
|
+
|
|
9
17
|
/**
|
|
10
18
|
* @function readOnClickEventInfo
|
|
11
|
-
* @param {
|
|
12
|
-
* @returns {
|
|
19
|
+
* @param {UIEvent} e - event
|
|
20
|
+
* @returns {IClickEventInfo}
|
|
13
21
|
* @inner
|
|
14
22
|
*/
|
|
15
23
|
function readOnClickEventInfo(e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cntwg/html-ctrls-lists",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.32",
|
|
4
4
|
"description": "An HTML-form component: lists",
|
|
5
5
|
"author": "ygracs <cs70th-om@rambler.ru>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,35 +14,40 @@
|
|
|
14
14
|
"component"
|
|
15
15
|
],
|
|
16
16
|
"main": "./index.js",
|
|
17
|
+
"types": "./index.d.ts",
|
|
17
18
|
"files": [
|
|
18
19
|
"doc/*.md",
|
|
19
20
|
"lib/lists-stubs.js",
|
|
20
21
|
"lib/lists-btn.js",
|
|
21
22
|
"lib/list.js",
|
|
22
23
|
"lib/mod-hfunc.js",
|
|
24
|
+
"lib/*.d.ts",
|
|
23
25
|
"index.js",
|
|
26
|
+
"index.d.ts",
|
|
24
27
|
"CHANGELOG.md"
|
|
25
28
|
],
|
|
26
29
|
"scripts": {
|
|
27
30
|
"test": "jest",
|
|
28
31
|
"build-doc-md": "jsdoc2md",
|
|
29
|
-
"build-doc-html": "jsdoc"
|
|
32
|
+
"build-doc-html": "jsdoc",
|
|
33
|
+
"gen-dts": "npx -p typescript tsc"
|
|
30
34
|
},
|
|
31
35
|
"imports": {
|
|
32
36
|
"#lib/*": "./lib/*",
|
|
33
37
|
"#test-dir/*": "./__test__/*"
|
|
34
38
|
},
|
|
35
39
|
"dependencies": {
|
|
36
|
-
"@cntwg/html-ctrls-buttons": "~0.1.
|
|
40
|
+
"@cntwg/html-ctrls-buttons": "~0.1.1",
|
|
37
41
|
"@cntwg/html-helper": "~0.1.3",
|
|
38
42
|
"@ygracs/bsfoc-lib-js": "~0.3.4",
|
|
39
|
-
"@ygracs/lists-lib-js": "~0.2.
|
|
43
|
+
"@ygracs/lists-lib-js": "~0.2.1"
|
|
40
44
|
},
|
|
41
45
|
"devDependencies": {
|
|
42
46
|
"@ygracs/test-helper": "~0.0.2-b",
|
|
43
47
|
"jest": "^30.3.0",
|
|
44
48
|
"jest-environment-jsdom": "^30.3.0",
|
|
45
49
|
"jsdoc-to-markdown": "^9.1.3",
|
|
46
|
-
"minimist": "^1.2.8"
|
|
50
|
+
"minimist": "^1.2.8",
|
|
51
|
+
"typescript": "~5.9.3"
|
|
47
52
|
}
|
|
48
53
|
}
|