@cntwg/html-ctrls-lists 0.0.31 → 0.0.33
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 +16 -0
- package/doc/html-ctrls-list.md +11 -10
- package/index.d.ts +32 -0
- package/index.js +27 -6
- package/lib/list-cont.d.ts +207 -0
- package/lib/list-cont.js +538 -0
- package/lib/list-ctrl.d.ts +85 -0
- package/lib/{list.js → list-ctrl.js} +74 -545
- 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 +37 -21
- package/lib/mod-hfunc.d.ts +18 -0
- package/lib/mod-hfunc.js +11 -3
- package/package.json +12 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
#### *v0.0.33*
|
|
2
|
+
|
|
3
|
+
Pre-release version.
|
|
4
|
+
|
|
5
|
+
> - some fixes.
|
|
6
|
+
|
|
7
|
+
#### *v0.0.32*
|
|
8
|
+
|
|
9
|
+
Pre-release version.
|
|
10
|
+
|
|
11
|
+
> - update `html-ctrls-list.md`;
|
|
12
|
+
> - update dependency on `@ygracs/lists-lib-js` module to v0.2.1;
|
|
13
|
+
> - update dependency on `@cntwg/html-ctrls-buttons` module to v0.1.1;
|
|
14
|
+
> - (THtmlStubItemsSet) change method behavior: `loadItems`;
|
|
15
|
+
> - some fixes.
|
|
16
|
+
|
|
1
17
|
#### *v0.0.31*
|
|
2
18
|
|
|
3
19
|
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,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
THtmlStubItemsSet,
|
|
3
|
+
type IStubItemsSetOptions,
|
|
4
|
+
} from "./lib/lists-stubs";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
BTS_DEF_GROUP_NAME,
|
|
8
|
+
THtmlListButtonsController,
|
|
9
|
+
} from "./lib/lists-btn";
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
THtmlItemsListContainer,
|
|
13
|
+
type ITHtmlItemsListContainerOptions,
|
|
14
|
+
} from "./lib/list-cont";
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
THtmlItemsListController,
|
|
18
|
+
type IHtmlItemsListControllerOptions,
|
|
19
|
+
} from "./lib/list-ctrl";
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
THtmlStubItemsSet,
|
|
23
|
+
THtmlItemsListContainer, THtmlItemsListController,
|
|
24
|
+
BTS_DEF_GROUP_NAME,
|
|
25
|
+
THtmlListButtonsController,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type {
|
|
29
|
+
ITHtmlItemsListContainerOptions,
|
|
30
|
+
IHtmlItemsListControllerOptions,
|
|
31
|
+
IStubItemsSetOptions,
|
|
32
|
+
};
|
package/index.js
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.034-20260510]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const {
|
|
6
|
+
THtmlItemsListContainer,
|
|
7
|
+
// * import types definitions *
|
|
8
|
+
ITHtmlItemsListContainerOptions,
|
|
9
|
+
} = require('./lib/list-cont');
|
|
10
|
+
|
|
11
|
+
const {
|
|
12
|
+
THtmlItemsListController,
|
|
13
|
+
// * import types definitions *
|
|
14
|
+
IHtmlItemsListControllerOptions,
|
|
15
|
+
} = require('./lib/list-ctrl');
|
|
16
|
+
|
|
17
|
+
const {
|
|
18
|
+
THtmlStubItemsSet,
|
|
19
|
+
// * import types definitions *
|
|
20
|
+
IStubItemsSetOptions,
|
|
21
|
+
} = require('./lib/lists-stubs');
|
|
22
|
+
|
|
6
23
|
const btn = require('./lib/lists-btn');
|
|
7
|
-
const stubs = require('./lib/lists-stubs');
|
|
8
24
|
|
|
9
25
|
// === module inner block ===
|
|
10
26
|
|
|
@@ -12,11 +28,16 @@ const stubs = require('./lib/lists-stubs');
|
|
|
12
28
|
|
|
13
29
|
// === module exports block ===
|
|
14
30
|
|
|
15
|
-
module.exports.THtmlStubItemsSet =
|
|
31
|
+
module.exports.THtmlStubItemsSet = THtmlStubItemsSet;
|
|
16
32
|
|
|
17
|
-
module.exports.THtmlItemsListContainer =
|
|
18
|
-
module.exports.THtmlItemsListController =
|
|
33
|
+
module.exports.THtmlItemsListContainer = THtmlItemsListContainer;
|
|
34
|
+
module.exports.THtmlItemsListController = THtmlItemsListController;
|
|
19
35
|
|
|
20
36
|
module.exports.BTS_DEF_GROUP_NAME = btn.BTS_DEF_GROUP_NAME;
|
|
21
37
|
|
|
22
38
|
module.exports.THtmlListButtonsController = btn.THtmlListButtonsController;
|
|
39
|
+
|
|
40
|
+
// * export types definitions *
|
|
41
|
+
module.exports.ITHtmlItemsListContainerOptions = ITHtmlItemsListContainerOptions;
|
|
42
|
+
module.exports.IHtmlItemsListControllerOptions = IHtmlItemsListControllerOptions;
|
|
43
|
+
module.exports.IStubItemsSetOptions = IStubItemsSetOptions;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An options set for `THtmlItemsListContainer`-class
|
|
3
|
+
*/
|
|
4
|
+
export type ITHtmlItemsListContainerOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* - indicates whether to hide a new element
|
|
7
|
+
*/
|
|
8
|
+
autoHideNewItems?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* - indicates whether to mark a current element
|
|
11
|
+
*/
|
|
12
|
+
markCurrentItem?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* - contains a base class
|
|
15
|
+
* attributes applayed to each a newly added list member
|
|
16
|
+
*/
|
|
17
|
+
itemBaseClassID?: string | string[];
|
|
18
|
+
/**
|
|
19
|
+
* - indicates a target scope chosen to select an ID-attribute of the element
|
|
20
|
+
* @since 0.0.33
|
|
21
|
+
*/
|
|
22
|
+
targetScopeForEID?: string | number;
|
|
23
|
+
};
|
|
24
|
+
export const ITHtmlItemsListContainerOptions: ITHtmlItemsListContainerOptions;
|
|
25
|
+
|
|
26
|
+
export type ISearchListElementResultOnFail = {
|
|
27
|
+
/**
|
|
28
|
+
* - element index
|
|
29
|
+
*/
|
|
30
|
+
index: number;
|
|
31
|
+
/**
|
|
32
|
+
* - found element
|
|
33
|
+
*/
|
|
34
|
+
item: null;
|
|
35
|
+
};
|
|
36
|
+
export type ISearchListElementResultOnSuccess = {
|
|
37
|
+
/**
|
|
38
|
+
* - element index
|
|
39
|
+
*/
|
|
40
|
+
index: number;
|
|
41
|
+
/**
|
|
42
|
+
* - found element
|
|
43
|
+
*/
|
|
44
|
+
item: any;
|
|
45
|
+
};
|
|
46
|
+
export type ISearchListElementResult = ISearchListElementResultOnFail | ISearchListElementResultOnSuccess;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* This class implements an interfaco for a list container
|
|
50
|
+
*/
|
|
51
|
+
export class THtmlItemsListContainer {
|
|
52
|
+
/**
|
|
53
|
+
* Creates an instance of a list container
|
|
54
|
+
*/
|
|
55
|
+
constructor(host: HTMLElement | null, opt?: ITHtmlItemsListContainerOptions);
|
|
56
|
+
/**
|
|
57
|
+
* Contains a Qty of an elements
|
|
58
|
+
*/
|
|
59
|
+
get count(): number;
|
|
60
|
+
/**
|
|
61
|
+
* Contains an index of the current element
|
|
62
|
+
*/
|
|
63
|
+
get curIndex(): number;
|
|
64
|
+
/**
|
|
65
|
+
* Returns a minimum value of an index
|
|
66
|
+
*/
|
|
67
|
+
get minIndex(): number;
|
|
68
|
+
/**
|
|
69
|
+
* Returns a maximum value of an index
|
|
70
|
+
*/
|
|
71
|
+
get maxIndex(): number;
|
|
72
|
+
/**
|
|
73
|
+
* Returns a value of a previous index
|
|
74
|
+
*/
|
|
75
|
+
get prevIndex(): number;
|
|
76
|
+
/**
|
|
77
|
+
* Returns a value of a next index
|
|
78
|
+
*/
|
|
79
|
+
get nextIndex(): number;
|
|
80
|
+
/**
|
|
81
|
+
* Returns an element in the current index
|
|
82
|
+
*/
|
|
83
|
+
get curItem(): HTMLElement | null;
|
|
84
|
+
/**
|
|
85
|
+
* Clears an instance content.
|
|
86
|
+
*/
|
|
87
|
+
clear(): void;
|
|
88
|
+
/**
|
|
89
|
+
* Checks if an instance contains no items.
|
|
90
|
+
*/
|
|
91
|
+
isEmpty(): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Checks if an instance contains any items.
|
|
94
|
+
*/
|
|
95
|
+
isNotEmpty(): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Checks if a given value is a valid index and
|
|
98
|
+
* it fits an index range within an instance.
|
|
99
|
+
* @deprecated
|
|
100
|
+
* @todo \[since v0.0.31] deprecated. Use
|
|
101
|
+
* {@link THtmlItemsListContainer.checkIndex} instead
|
|
102
|
+
*/
|
|
103
|
+
chkIndex(value: number | string): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Checks if a given value is a valid index and
|
|
106
|
+
* it fits an index range within an instance.
|
|
107
|
+
* @since 0.0.31
|
|
108
|
+
*/
|
|
109
|
+
checkIndex(value: number | string): boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Checks if a given value is a valid index and
|
|
112
|
+
* it fits an index range within an instance.
|
|
113
|
+
* @deprecated
|
|
114
|
+
* @todo \[since v0.0.31] deprecated. Use
|
|
115
|
+
* {@link THtmlItemsListContainer.checkIndex} or
|
|
116
|
+
* {@link THtmlItemsListContainer.tryIndex} instead
|
|
117
|
+
*/
|
|
118
|
+
chkIndexEx(value: number | string, opt?: boolean): boolean | number;
|
|
119
|
+
/**
|
|
120
|
+
* Returns an index in case a given value is a valid index value and not exceeds
|
|
121
|
+
* an index range within the list. If failed a `-1` returned
|
|
122
|
+
* @since 0.0.31
|
|
123
|
+
*/
|
|
124
|
+
tryIndex(value: any): number;
|
|
125
|
+
/**
|
|
126
|
+
* Returns an index of a given element.
|
|
127
|
+
* @param {HTMLElement} item - element to search
|
|
128
|
+
* @todo add 2nd param
|
|
129
|
+
* @see TItemsListEx.srchIndex
|
|
130
|
+
*/
|
|
131
|
+
srchIndex(item: HTMLElement): number;
|
|
132
|
+
/**
|
|
133
|
+
* Returns an index of an element wich has an attribute
|
|
134
|
+
* with a given name and value.
|
|
135
|
+
*/
|
|
136
|
+
srchIndexByAttr(name: string, value?: any): number;
|
|
137
|
+
/**
|
|
138
|
+
* Returns an index of an element wich has a given ID.
|
|
139
|
+
*/
|
|
140
|
+
srchIndexByID(value: string): number;
|
|
141
|
+
/**
|
|
142
|
+
* Sets a current index.
|
|
143
|
+
*/
|
|
144
|
+
setCurIndex(index: number | string): boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Resets a current index.
|
|
147
|
+
*/
|
|
148
|
+
rstCurIndex(): void;
|
|
149
|
+
/**
|
|
150
|
+
* Returns an item addressed by a given index.
|
|
151
|
+
*/
|
|
152
|
+
getItem(index: number | string): HTMLElement | null;
|
|
153
|
+
/**
|
|
154
|
+
* Returns an item wich has an attribute with a given name and value.
|
|
155
|
+
*/
|
|
156
|
+
getItemByAttr(name: string, value?: any): HTMLElement | null;
|
|
157
|
+
/**
|
|
158
|
+
* Returns an item wich has a given ID.
|
|
159
|
+
*/
|
|
160
|
+
getItemByID(value: string): HTMLElement | null;
|
|
161
|
+
/**
|
|
162
|
+
* Adds an item to an instance.
|
|
163
|
+
*/
|
|
164
|
+
addItem(item: HTMLElement, opt?: boolean): number;
|
|
165
|
+
/**
|
|
166
|
+
* Deletes an item from an instance.
|
|
167
|
+
*/
|
|
168
|
+
delItem(index: number | string, opt?: any, optEx?: boolean): boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Selects an item addressed by a given index.
|
|
171
|
+
*/
|
|
172
|
+
selectItem(index: number | string, opt?: boolean): boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Unselects an item addressed by a given index.
|
|
175
|
+
*/
|
|
176
|
+
unselectItem(index: number | string): boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Hides an item addressed by a given index.
|
|
179
|
+
*/
|
|
180
|
+
hideItem(index: number | string): boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Shows an item addressed by a given index.
|
|
183
|
+
*/
|
|
184
|
+
showItem(index: number | string): boolean;
|
|
185
|
+
/**
|
|
186
|
+
* Checks whether an item is selected.
|
|
187
|
+
*/
|
|
188
|
+
isSelectedItem(index: number | string): boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Checks whether an item is hidden.
|
|
191
|
+
*/
|
|
192
|
+
isHiddenItem(index: number | string): boolean;
|
|
193
|
+
[Symbol.iterator](): {
|
|
194
|
+
next: () => {
|
|
195
|
+
done: boolean;
|
|
196
|
+
value: HTMLElement | null;
|
|
197
|
+
} | {
|
|
198
|
+
done: boolean;
|
|
199
|
+
value: undefined;
|
|
200
|
+
};
|
|
201
|
+
return(): {
|
|
202
|
+
done: boolean;
|
|
203
|
+
value: undefined;
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
#private;
|
|
207
|
+
}
|