@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/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";