@cntwg/html-ctrls-lists 0.0.32 → 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 CHANGED
@@ -1,3 +1,9 @@
1
+ #### *v0.0.33*
2
+
3
+ Pre-release version.
4
+
5
+ > - some fixes.
6
+
1
7
  #### *v0.0.32*
2
8
 
3
9
  Pre-release version.
package/index.d.ts CHANGED
@@ -1,19 +1,32 @@
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
- };
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.031-20260309]
1
+ // [v0.1.034-20260510]
2
2
 
3
3
  // === module init block ===
4
4
 
5
- const list = require('./lib/list');
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 = stubs.THtmlStubItemsSet;
31
+ module.exports.THtmlStubItemsSet = THtmlStubItemsSet;
16
32
 
17
- module.exports.THtmlItemsListContainer = list.THtmlItemsListContainer;
18
- module.exports.THtmlItemsListController = list.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;
@@ -1,278 +1,207 @@
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";
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
+ }