@cntwg/html-helper 0.0.17 → 0.0.18
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 +165 -0
- package/LICENSE +1 -1
- package/README.md +6 -2
- package/doc/html-ctrls-list.md +8 -4
- package/doc/html-helper-lib.md +6 -2
- package/index.js +8 -5
- package/lib/{html-ctrls-btn.js → html-ctrls/buttons.js} +58 -88
- package/lib/{html-ctrls-list.js → html-ctrls/list.js} +61 -68
- package/lib/html-ctrls/{lists-btns.js → lists-btn.js} +29 -107
- package/lib/html-ctrls/lists-stubs.js +6 -10
- package/lib/html-ctrls/mod-hfunc.js +33 -0
- package/lib/html-helper-lib.js +48 -15
- package/package.json +9 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
#### *v0.0.18*
|
|
2
|
+
|
|
3
|
+
Pre-release version.
|
|
4
|
+
|
|
5
|
+
> - `html-helper-lib.md` updated;
|
|
6
|
+
> - some fixes in `html-helper-lib.js` module;
|
|
7
|
+
> - add `mod-hfunc.js` module;
|
|
8
|
+
> - rename module `html-ctrls-list.js` to `html-ctrls/list.js`;
|
|
9
|
+
> - some fixes in `list.js` module;
|
|
10
|
+
> - rename module `html-ctrls-btn.js` to `html-ctrls/buttons.js`;
|
|
11
|
+
> - some fixes in `buttons.js` module;
|
|
12
|
+
> - some fixes in `lists-btn.js` module;
|
|
13
|
+
> - some fixes in `lists-stubs.js` module;
|
|
14
|
+
> - add function `readAsAttrValue` into `html-helper-lib.js` module;
|
|
15
|
+
> - add settings `itemBaseClassID` to `THtmlItemsListContainer` class constructor `options` parameter;
|
|
16
|
+
> - added 'component' property for module exports;
|
|
17
|
+
> - deprecated 'classes' property for module exports (*use `component` instead*);
|
|
18
|
+
|
|
19
|
+
#### *v0.0.17*
|
|
20
|
+
|
|
21
|
+
Pre-release version.
|
|
22
|
+
|
|
23
|
+
> improved event logic on items deletion for `THtmlItemsListController` class.
|
|
24
|
+
|
|
25
|
+
#### *v0.0.16*
|
|
26
|
+
|
|
27
|
+
Pre-release version.
|
|
28
|
+
|
|
29
|
+
> improved items selection logic for `THtmlItemsListController` class.
|
|
30
|
+
|
|
31
|
+
#### *v0.0.15*
|
|
32
|
+
|
|
33
|
+
Pre-release version.
|
|
34
|
+
|
|
35
|
+
> - `html-helper-lib.md` updated;
|
|
36
|
+
> - `html-ctrls-list.md` updated;
|
|
37
|
+
> - some fixes in `html-ctrls-btn.js` module;
|
|
38
|
+
> - some fixes in `html-ctrls-list.js` module;
|
|
39
|
+
> - alter behavior for the `srchIndexByAttr` method of a `THtmlItemsListContainer` class (*see docs for details*);
|
|
40
|
+
> - add settings `markCurrentItem` to `THtmlItemsListContainer` class constructor `options` parameter;
|
|
41
|
+
> - add function `valueToIDString` into `html-helper-lib.js` module;
|
|
42
|
+
|
|
43
|
+
#### *v0.0.14*
|
|
44
|
+
|
|
45
|
+
Pre-release version.
|
|
46
|
+
|
|
47
|
+
> - `html-ctrls-list.md` updated;
|
|
48
|
+
> - some fixes in `html-ctrls/list-stubs.js` module;
|
|
49
|
+
> - alter behavior for the `loadItems` method of a `THtmlStubItemsSet` class in case when its `options` parameter is set to `boolean` (see `html-ctrls-list.md` for details);
|
|
50
|
+
> - added method `rstDefItem` to `THtmlStubItemsSet` class;
|
|
51
|
+
> - added `THtmlButtonsControllerARCSet` class.
|
|
52
|
+
|
|
53
|
+
#### *v0.0.13*
|
|
54
|
+
|
|
55
|
+
Pre-release version.
|
|
56
|
+
|
|
57
|
+
> - `html-helper-lib.md` updated;
|
|
58
|
+
> - `html-ctrls-btn.md` updated;
|
|
59
|
+
> - `html-ctrls-list.md` updated;
|
|
60
|
+
> - some fixes in `html-helper-lib.js` module;
|
|
61
|
+
> - some fixes in `html-ctrls-btn.js` module;
|
|
62
|
+
> - some fixes in `html-ctrls-list.js` module;
|
|
63
|
+
> - move definition of `THtmlStubItemsSet` from `html-ctrls-list.js` module to `html-ctrls/lists-stubs.js` submodule;
|
|
64
|
+
> - add function `valueToClassList` into `html-helper-lib.js` module;
|
|
65
|
+
> - updated dependency on `@ygracs/bsfoc-lib-js` module to v0.1.2.
|
|
66
|
+
|
|
67
|
+
#### *v0.0.12*
|
|
68
|
+
|
|
69
|
+
Pre-release version.
|
|
70
|
+
|
|
71
|
+
> - updated dependency on `@ygracs/bsfoc-lib-js` module to v0.1.1.
|
|
72
|
+
|
|
73
|
+
#### *v0.0.11*
|
|
74
|
+
|
|
75
|
+
Pre-release version.
|
|
76
|
+
|
|
77
|
+
> - `html-ctrls-btn.md` updated;
|
|
78
|
+
> - `html-ctrls-list.md` updated;
|
|
79
|
+
> - some fixes in `html-ctrls-list.js` module;
|
|
80
|
+
> - some fixes in `html-ctrls-btn.js` module.
|
|
81
|
+
|
|
82
|
+
#### *v0.0.10*
|
|
83
|
+
|
|
84
|
+
Pre-release version.
|
|
85
|
+
|
|
86
|
+
> - `html-ctrls-btn.md` updated;
|
|
87
|
+
> - added `THtmlListButtonsController` class;
|
|
88
|
+
|
|
89
|
+
#### *v0.0.9*
|
|
90
|
+
|
|
91
|
+
Pre-release version.
|
|
92
|
+
|
|
93
|
+
> - switch dependency from `@cntwg/bsfoc-lib-js` module to `@ygracs/bsfoc-lib-js` module.
|
|
94
|
+
|
|
95
|
+
#### *v0.0.8*
|
|
96
|
+
|
|
97
|
+
Pre-release version.
|
|
98
|
+
|
|
99
|
+
> - updated dependency on `@cntwg/bsfoc-lib-js` module to v0.0.11.
|
|
100
|
+
|
|
101
|
+
#### *v0.0.7*
|
|
102
|
+
|
|
103
|
+
Pre-release version.
|
|
104
|
+
|
|
105
|
+
> - updated dependency on `@cntwg/bsfoc-lib-js` module to v0.0.10;
|
|
106
|
+
> - some fixes in `html-helper-lib.js` module;
|
|
107
|
+
> - some fixes in `html-ctrls-list.js` module.
|
|
108
|
+
|
|
109
|
+
#### *v0.0.6*
|
|
110
|
+
|
|
111
|
+
Pre-release version.
|
|
112
|
+
|
|
113
|
+
> - `html-ctrls-btn.md` updated;
|
|
114
|
+
> - `html-ctrls-list.md` updated;
|
|
115
|
+
> - `html-helper-lib.md` updated;
|
|
116
|
+
> - some fixes in `html-ctrls-btn.js` module;
|
|
117
|
+
> - some fixes in `html-ctrls-list.js` module.
|
|
118
|
+
|
|
119
|
+
#### *v0.0.5*
|
|
120
|
+
|
|
121
|
+
Pre-release version.
|
|
122
|
+
|
|
123
|
+
> - `$module/test/README.md` added;
|
|
124
|
+
> - updated dependency on `@cntwg/bsfoc-lib-js` module to v0.0.8;
|
|
125
|
+
> - `html-ctrls-list.md` updated;
|
|
126
|
+
> - added `minIndex` property to `THtmlItemsListContainer` class;
|
|
127
|
+
> - some fixes in `html-ctrls-list.js` module;
|
|
128
|
+
> - added 'classes' property for module exports;
|
|
129
|
+
> - MIT-license applied.
|
|
130
|
+
|
|
131
|
+
#### *v0.0.4*
|
|
132
|
+
|
|
133
|
+
Pre-release version.
|
|
134
|
+
|
|
135
|
+
> - updated dependency on `@cntwg/bsfoc-lib-js` module to v0.0.5.
|
|
136
|
+
|
|
137
|
+
#### *v0.0.3*
|
|
138
|
+
|
|
139
|
+
Pre-release version.
|
|
140
|
+
|
|
141
|
+
> - added `activateHTMLElements` function;
|
|
142
|
+
> - added `inactivateHTMLElements` function;
|
|
143
|
+
> - added `createNewHtmlElement` function (experimental);
|
|
144
|
+
> - `html-helper-lib.md` updated;
|
|
145
|
+
> - `html-ctrls-btn.md` updated;
|
|
146
|
+
> - `html-ctrls-list.md` updated.
|
|
147
|
+
|
|
148
|
+
#### *v0.0.2*
|
|
149
|
+
|
|
150
|
+
Pre-release version.
|
|
151
|
+
|
|
152
|
+
> - `README.md` added;
|
|
153
|
+
> - `html-helper-lib.md` added to `doc`;
|
|
154
|
+
> - `html-ctrls-btn.md` added to `doc`;
|
|
155
|
+
> - `html-ctrls-list.md` added to `doc`;
|
|
156
|
+
> - added `CSS_CLASS_ACTIVE` constant to `CSS_CLASS_STRING`;
|
|
157
|
+
> - added `isActiveHTMLElement` function;
|
|
158
|
+
> - added `markHtmlElementAsActive` function;
|
|
159
|
+
> - added `unmarkActiveHtmlElement` function;
|
|
160
|
+
> - `html-btn-ctrl.js` was renamed `html-ctrls-btn.js`;
|
|
161
|
+
> - `html-list-ctrl.js` was renamed `html-ctrls-list.js`.
|
|
162
|
+
|
|
163
|
+
#### *v0.0.1*
|
|
164
|
+
|
|
165
|
+
Pre-release version.
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2019-
|
|
3
|
+
Copyright (c) 2019-2023 Yuri Grachev
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
6
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
>|***rev.*:**|0.1.
|
|
1
|
+
>|***rev.*:**|0.1.3|
|
|
2
2
|
>|:---|---:|
|
|
3
|
-
>|date:|
|
|
3
|
+
>|date:|2023-04-09|
|
|
4
4
|
|
|
5
5
|
## Introduction
|
|
6
6
|
|
|
@@ -10,6 +10,10 @@ This module provide a base set of helpers for javascript. So your work can run a
|
|
|
10
10
|
|
|
11
11
|
This module was make for use as a library in a development of a Web-apps based on [Electron](https://en.wikipedia.org/wiki/Electron_(software_framework)) as main target.
|
|
12
12
|
|
|
13
|
+
### Installation
|
|
14
|
+
|
|
15
|
+
`npm install @cntwg/html-helper`
|
|
16
|
+
|
|
13
17
|
## Description
|
|
14
18
|
|
|
15
19
|
This module contains the following components:
|
package/doc/html-ctrls-list.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
>|***rev.*:**|0.1.
|
|
1
|
+
>|***rev.*:**|0.1.14|
|
|
2
2
|
>|:---|---:|
|
|
3
|
-
>|date:|
|
|
3
|
+
>|date:|2023-04-04|
|
|
4
4
|
|
|
5
5
|
## Introduction
|
|
6
6
|
|
|
@@ -27,6 +27,7 @@ The `options` structure has listed below:
|
|
|
27
27
|
|:---|---|---:|:---|
|
|
28
28
|
|`autoHideNewItems`|`boolean`|`false`|alters behavior of the `addItem` class method. If set to `true`, the item which was added to a container members will be automatically hidden|
|
|
29
29
|
|`markCurrentItem`|`boolean`|`false`|alters behavior of the `setCurIndex` class method. If set to `true`, the item which was added to a container members will be automatically marked as current|
|
|
30
|
+
|`itemBaseClassID`|`array`|---|alters behavior of the `addItem` class method. It accepts value of a string or an array of strings. For more see description of an `addItem` method|
|
|
30
31
|
|
|
31
32
|
#### class properties
|
|
32
33
|
|
|
@@ -112,6 +113,8 @@ This method adds a given item to a container members and if succeed returns its
|
|
|
112
113
|
|
|
113
114
|
If `options` parameter is given and is set to `true`, in case of success, the `curIndex` property is adjusted by the method.
|
|
114
115
|
|
|
116
|
+
If `itemBaseClassID` option of the container is set, the method will applied a value given by this option as a `class` attribute of an item which was successfully added.
|
|
117
|
+
|
|
115
118
|
##### **delItem(index\[, options])**
|
|
116
119
|
|
|
117
120
|
This method deletes an item addressed by the given `index` from a container members and if succeed `true` is returned.
|
|
@@ -161,8 +164,9 @@ The `options` structure has listed below:
|
|
|
161
164
|
|
|
162
165
|
|option name|value type|default value|description|
|
|
163
166
|
|:---|---|---:|:---|
|
|
164
|
-
|`autoHideNewItems`|`boolean`|`false`|
|
|
165
|
-
|`markCurrentItem`|`boolean`|`false`|
|
|
167
|
+
|`autoHideNewItems`|`boolean`|`false`|for details see options on `THtmlItemsListContainer` class constructor section|
|
|
168
|
+
|`markCurrentItem`|`boolean`|`false`|for details see options on `THtmlItemsListContainer` class constructor section|
|
|
169
|
+
|`itemBaseClassID`|`array`|---|for details see options on `THtmlItemsListContainer` class constructor section|
|
|
166
170
|
|`showStubsIfEmpty`|`boolean`|`false`|if set, in case of the empty list, the default stub-item will be displayed|
|
|
167
171
|
|`allowGroupSelection`|`boolean`|`false`|if set the more than one element can be selected in the list|
|
|
168
172
|
|`allowSelectionLocks`|`boolean`|`false`|<*reserved, experimental*>|
|
package/doc/html-helper-lib.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
>|***rev.*:**|0.1.
|
|
1
|
+
>|***rev.*:**|0.1.5|
|
|
2
2
|
>|:---|---:|
|
|
3
|
-
>|date:|
|
|
3
|
+
>|date:|2023-03-30|
|
|
4
4
|
|
|
5
5
|
## Introduction
|
|
6
6
|
|
|
@@ -120,3 +120,7 @@ This function make all the jobs under the hood. So there is no need to call DOM-
|
|
|
120
120
|
#### **valueToIDString(value)**
|
|
121
121
|
|
|
122
122
|
This function tries to convert a given `value` to `ID_STRING`. If failed an empty string is returned.
|
|
123
|
+
|
|
124
|
+
#### **readAsAttrValue(value)**
|
|
125
|
+
|
|
126
|
+
This function tries to convert a given `value` to the value of type which is suitable for an HTML-element's attribute. If failed a `null` is returned.
|
package/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.016-20230409]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
5
5
|
const html_helper = require('./lib/html-helper-lib.js');
|
|
6
|
-
const html_list = require('./lib/html-ctrls
|
|
7
|
-
const html_bts = require('./lib/html-ctrls
|
|
6
|
+
const html_list = require('./lib/html-ctrls/list.js');
|
|
7
|
+
const html_bts = require('./lib/html-ctrls/buttons.js');
|
|
8
8
|
|
|
9
|
-
const html_list_btn = require('./lib/html-ctrls/lists-
|
|
9
|
+
const html_list_btn = require('./lib/html-ctrls/lists-btn.js');
|
|
10
10
|
|
|
11
11
|
// === module extra block (helper functions) ===
|
|
12
12
|
|
|
@@ -44,9 +44,10 @@ exports.THtmlListButtonsController = html_list_btn.THtmlListButtonsController;
|
|
|
44
44
|
|
|
45
45
|
// experimental
|
|
46
46
|
exports.valueToIDString = html_helper.valueToIDString;
|
|
47
|
+
exports.readAsAttrValue = html_helper.readAsAttrValue;
|
|
47
48
|
exports.createNewHtmlElement = html_helper.createNewHtmlElement;
|
|
48
49
|
|
|
49
|
-
exports.
|
|
50
|
+
exports.component = {
|
|
50
51
|
THtmlStubItemsSet: exports.THtmlStubItemsSet,
|
|
51
52
|
THtmlItemsListContainer: exports.THtmlItemsListContainer,
|
|
52
53
|
THtmlItemsListController: exports.THtmlItemsListController,
|
|
@@ -54,3 +55,5 @@ exports.classes = {
|
|
|
54
55
|
THtmlListButtonsController: exports.THtmlListButtonsController,
|
|
55
56
|
THtmlButtonsControllerARCSet: exports.THtmlButtonsControllerARCSet,
|
|
56
57
|
};
|
|
58
|
+
// will deprecate
|
|
59
|
+
exports.classes = exports.component;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.047-20230408]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
|
-
readAsString,
|
|
6
|
+
//readAsString,
|
|
7
|
+
//readAsNumber,
|
|
8
|
+
isNotEmptyString,
|
|
7
9
|
isPlainObject, valueToArray,
|
|
8
10
|
TItemsICollection,
|
|
9
11
|
} = require('@ygracs/bsfoc-lib-js');
|
|
@@ -11,7 +13,11 @@ const {
|
|
|
11
13
|
const {
|
|
12
14
|
isHTMLElement, CSS_CLASS_STRING,
|
|
13
15
|
valueToIDString,
|
|
14
|
-
} = require('
|
|
16
|
+
} = require('../html-helper-lib.js');
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
pushEventHandler, triggerEventHandler,
|
|
20
|
+
} = require('./mod-hfunc.js');
|
|
15
21
|
|
|
16
22
|
const {
|
|
17
23
|
CSS_CLASS_SELECTED,
|
|
@@ -25,25 +31,54 @@ const etlHTagInputForBtn = new Set([
|
|
|
25
31
|
'button', 'submit', 'reset', 'image',
|
|
26
32
|
]);
|
|
27
33
|
|
|
28
|
-
// === module extra block (
|
|
34
|
+
// === module extra block (helper functions) ===
|
|
29
35
|
|
|
30
36
|
function isHTMLButton(obj){
|
|
31
37
|
let result = false;
|
|
32
38
|
if (isHTMLElement(obj)) {
|
|
33
39
|
switch (obj.tagName.toLowerCase()) {
|
|
34
|
-
case 'button':
|
|
40
|
+
case 'button': {
|
|
35
41
|
result = true;
|
|
36
42
|
break;
|
|
37
|
-
|
|
43
|
+
}
|
|
44
|
+
case 'input': {
|
|
38
45
|
result = etlHTagInputForBtn.has(obj.type.toLowerCase());
|
|
39
46
|
break;
|
|
40
|
-
|
|
47
|
+
}
|
|
48
|
+
default: {
|
|
41
49
|
break;
|
|
50
|
+
}
|
|
42
51
|
};
|
|
43
52
|
};
|
|
44
53
|
return result;
|
|
45
54
|
}
|
|
46
55
|
|
|
56
|
+
function readOnClickEventInfo(e) {
|
|
57
|
+
let item = null;
|
|
58
|
+
//let on_click_num = readAsNumber(e.detail, 0);
|
|
59
|
+
const { eventPhase, detail: onClickNum } = e;
|
|
60
|
+
//console.log('CHECK: e => ditail:['+onClickNum+']');
|
|
61
|
+
//console.log('CHECK: e => phase:['+eventPhase+']');
|
|
62
|
+
switch (eventPhase) {
|
|
63
|
+
//*case 1:
|
|
64
|
+
//* // NOTE: currently on eventPhase = 2 and 3
|
|
65
|
+
case 2: {
|
|
66
|
+
/**/// capturing stage
|
|
67
|
+
item = e.target;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
case 3: {
|
|
71
|
+
/**/// bubblig stage
|
|
72
|
+
item = e.currentTarget;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
default: {
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
return { item, onClickNum };
|
|
80
|
+
};
|
|
81
|
+
|
|
47
82
|
// === module main block (function definitions) ===
|
|
48
83
|
|
|
49
84
|
// === module main block (class definitions) ===
|
|
@@ -54,7 +89,6 @@ class THtmlButtonsSet {
|
|
|
54
89
|
constructor(){
|
|
55
90
|
// define default functions for manipulators
|
|
56
91
|
const __user_index_getter = (value) => {
|
|
57
|
-
//return readAsString(value, '', { useTrim: true, numberToString: true });
|
|
58
92
|
return valueToIDString(value);
|
|
59
93
|
};
|
|
60
94
|
const __user_item_getter = (value) => {
|
|
@@ -206,28 +240,11 @@ class THtmlButtonsControllerARCSet {
|
|
|
206
240
|
#_on_btn_apply_pressed = (e) => {
|
|
207
241
|
//console.log('THtmlListButtonsController._on_btn_apply_pressed() ==> was called...');
|
|
208
242
|
//e.preventDefault(); /* need to reconsider reason for use */
|
|
209
|
-
|
|
210
|
-
let on_click_num = readAsNumber(e.detail, 0);
|
|
211
|
-
//console.log('CHECK: e => ditail:['+on_click_num+']');
|
|
212
|
-
//console.log('CHECK: e => phase:['+e.eventPhase+']');
|
|
213
|
-
switch (e.eventPhase) {
|
|
214
|
-
//*case 1:
|
|
215
|
-
//* // NOTE: currently on eventPhase = 2 and 3
|
|
216
|
-
case 2:
|
|
217
|
-
/**/// capturing stage
|
|
218
|
-
curItem = e.target;
|
|
219
|
-
break;
|
|
220
|
-
case 3:
|
|
221
|
-
/**/// bubblig stage
|
|
222
|
-
curItem = e.currentTarget;
|
|
223
|
-
break;
|
|
224
|
-
default:
|
|
225
|
-
break;
|
|
226
|
-
};
|
|
243
|
+
const { item, onClickNum } = readOnClickEventInfo(e);
|
|
227
244
|
if (
|
|
228
|
-
|
|
229
|
-
&& (
|
|
230
|
-
&& !
|
|
245
|
+
item instanceof HTMLElement
|
|
246
|
+
&& (onClickNum === 0 || onClickNum === 1)
|
|
247
|
+
&& !item.classList.contains(CSS_CLASS_DISABLED)
|
|
231
248
|
) {
|
|
232
249
|
this.#_triggerEvent('btn-apply-pressed', e);
|
|
233
250
|
};
|
|
@@ -236,28 +253,11 @@ class THtmlButtonsControllerARCSet {
|
|
|
236
253
|
#_on_btn_reset_pressed = (e) => {
|
|
237
254
|
//console.log('THtmlListButtonsController._on_btn_reset_pressed() ==> was called...');
|
|
238
255
|
//e.preventDefault(); /* need to reconsider reason for use */
|
|
239
|
-
|
|
240
|
-
let on_click_num = readAsNumber(e.detail, 0);
|
|
241
|
-
//console.log('CHECK: e => ditail:['+on_click_num+']');
|
|
242
|
-
//console.log('CHECK: e => phase:['+e.eventPhase+']');
|
|
243
|
-
switch (e.eventPhase) {
|
|
244
|
-
//*case 1:
|
|
245
|
-
//* // NOTE: currently on eventPhase = 2 and 3
|
|
246
|
-
case 2:
|
|
247
|
-
/**/// capturing stage
|
|
248
|
-
curItem = e.target;
|
|
249
|
-
break;
|
|
250
|
-
case 3:
|
|
251
|
-
/**/// bubblig stage
|
|
252
|
-
curItem = e.currentTarget;
|
|
253
|
-
break;
|
|
254
|
-
default:
|
|
255
|
-
break;
|
|
256
|
-
};
|
|
256
|
+
const { item, onClickNum } = readOnClickEventInfo(e);
|
|
257
257
|
if (
|
|
258
|
-
|
|
259
|
-
&& (
|
|
260
|
-
&& !
|
|
258
|
+
item instanceof HTMLElement
|
|
259
|
+
&& (onClickNum === 0 || onClickNum === 1)
|
|
260
|
+
&& !item.classList.contains(CSS_CLASS_DISABLED)
|
|
261
261
|
) {
|
|
262
262
|
this.#_triggerEvent('btn-reset-pressed', e);
|
|
263
263
|
};
|
|
@@ -266,39 +266,18 @@ class THtmlButtonsControllerARCSet {
|
|
|
266
266
|
#_on_btn_cancel_pressed = (e) => {
|
|
267
267
|
//console.log('THtmlListButtonsController._on_btn_cancel_pressed() ==> was called...');
|
|
268
268
|
//e.preventDefault(); /* need to reconsider reason for use */
|
|
269
|
-
|
|
270
|
-
let on_click_num = readAsNumber(e.detail, 0);
|
|
271
|
-
//console.log('CHECK: e => ditail:['+on_click_num+']');
|
|
272
|
-
//console.log('CHECK: e => phase:['+e.eventPhase+']');
|
|
273
|
-
switch (e.eventPhase) {
|
|
274
|
-
//*case 1:
|
|
275
|
-
//* // NOTE: currently on eventPhase = 2 and 3
|
|
276
|
-
case 2:
|
|
277
|
-
/**/// capturing stage
|
|
278
|
-
curItem = e.target;
|
|
279
|
-
break;
|
|
280
|
-
case 3:
|
|
281
|
-
/**/// bubblig stage
|
|
282
|
-
curItem = e.currentTarget;
|
|
283
|
-
break;
|
|
284
|
-
default:
|
|
285
|
-
break;
|
|
286
|
-
};
|
|
269
|
+
const { item, onClickNum } = readOnClickEventInfo(e);
|
|
287
270
|
if (
|
|
288
|
-
|
|
289
|
-
&& (
|
|
290
|
-
&& !
|
|
271
|
+
item instanceof HTMLElement
|
|
272
|
+
&& (onClickNum === 0 || onClickNum === 1)
|
|
273
|
+
&& !item.classList.contains(CSS_CLASS_DISABLED)
|
|
291
274
|
) {
|
|
292
275
|
this.#_triggerEvent('btn-cancel-pressed', e);
|
|
293
276
|
};
|
|
294
277
|
}
|
|
295
278
|
|
|
296
279
|
#_triggerEvent = (name, ...args) => {
|
|
297
|
-
|
|
298
|
-
if (_name !== '') {
|
|
299
|
-
const _events = this.#_events;
|
|
300
|
-
if (_events.has(_name)) _events.get(name)(...args);
|
|
301
|
-
};
|
|
280
|
+
triggerEventHandler(this.#_events, name, ...args);
|
|
302
281
|
}
|
|
303
282
|
|
|
304
283
|
disableMain(){
|
|
@@ -318,18 +297,7 @@ class THtmlButtonsControllerARCSet {
|
|
|
318
297
|
}
|
|
319
298
|
|
|
320
299
|
on(name, evnt){
|
|
321
|
-
|
|
322
|
-
if (_name !== '' && typeof evnt === 'function') {
|
|
323
|
-
const _events = this.#_events;
|
|
324
|
-
if (!_events.has(_name)) {
|
|
325
|
-
_events.set(_name, evnt);
|
|
326
|
-
} else {
|
|
327
|
-
/* NOTE:
|
|
328
|
-
* for current you can't reset or set new one on the same event
|
|
329
|
-
*/
|
|
330
|
-
//console.log('THtmlListButtonsController.on() ==> event:['+name+'] - already exists...');
|
|
331
|
-
};
|
|
332
|
-
};
|
|
300
|
+
pushEventHandler(this.#_events, name, evnt);
|
|
333
301
|
}
|
|
334
302
|
};
|
|
335
303
|
|
|
@@ -341,3 +309,5 @@ exports.THtmlButtonsControllerARCSet = THtmlButtonsControllerARCSet;
|
|
|
341
309
|
exports.BTS_DEF_GROUP_NAME = BTS_DEF_GROUP_NAME;
|
|
342
310
|
|
|
343
311
|
exports.isHTMLButton = isHTMLButton;
|
|
312
|
+
|
|
313
|
+
exports.readOnClickEventInfo = readOnClickEventInfo;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.060-20230408]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
|
-
//readAsBool,
|
|
7
6
|
readAsNumber,
|
|
8
|
-
//valueToIndex,
|
|
9
|
-
//isArray, isObject,
|
|
10
7
|
isPlainObject,
|
|
11
8
|
TItemsListEx,
|
|
12
9
|
} = require('@ygracs/bsfoc-lib-js');
|
|
@@ -16,10 +13,15 @@ const {
|
|
|
16
13
|
showHtmlElement, hideHtmlElement,
|
|
17
14
|
selectHtmlElement, unselectHtmlElement,
|
|
18
15
|
markHtmlElementAsCurrent, unmarkCurrentHtmlElement,
|
|
16
|
+
readAsAttrValue, valueToClassList,
|
|
19
17
|
CSS_CLASS_STRING,
|
|
20
|
-
} = require('
|
|
18
|
+
} = require('../html-helper-lib.js');
|
|
21
19
|
|
|
22
|
-
const { THtmlStubItemsSet } = require('./
|
|
20
|
+
const { THtmlStubItemsSet } = require('./lists-stubs.js');
|
|
21
|
+
|
|
22
|
+
const {
|
|
23
|
+
pushEventHandler, triggerEventHandler,
|
|
24
|
+
} = require('./mod-hfunc.js');
|
|
23
25
|
|
|
24
26
|
const {
|
|
25
27
|
CSS_CLASS_SELECTED,
|
|
@@ -35,23 +37,28 @@ const ILC_SMODE_CTRL = 2;
|
|
|
35
37
|
|
|
36
38
|
// === module extra block (helper functions) ===
|
|
37
39
|
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
40
|
+
function srchListElementByAttr(list, name, value = '') {
|
|
41
|
+
const _value = readAsAttrValue(value);
|
|
42
|
+
let item = null;
|
|
43
|
+
let index = -1;
|
|
44
|
+
let count = list.count;
|
|
45
|
+
let isACCEPTED = false;
|
|
46
|
+
if (count > 0 && name !== '' && _value !== null) {
|
|
47
|
+
const acceptAnyVal = _value === '';
|
|
48
|
+
for (let i = 0; i < count; i++) {
|
|
49
|
+
item = list.getItem(i);
|
|
50
|
+
if (
|
|
51
|
+
isHTMLElement(item)
|
|
52
|
+
&& item.hasAttribute(name)
|
|
53
|
+
&& (acceptAnyVal || item.getAttribute(name) === value)
|
|
54
|
+
) {
|
|
55
|
+
index = i;
|
|
56
|
+
isACCEPTED = true;
|
|
57
|
+
break;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
53
60
|
};
|
|
54
|
-
return
|
|
61
|
+
return isACCEPTED ? { index, item } : { index, item: null };
|
|
55
62
|
};
|
|
56
63
|
|
|
57
64
|
// === module main block (function definitions) ===
|
|
@@ -75,6 +82,7 @@ class THtmlItemsListContainer {
|
|
|
75
82
|
let {
|
|
76
83
|
autoHideNewItems,
|
|
77
84
|
markCurrentItem,
|
|
85
|
+
itemBaseClassID,
|
|
78
86
|
} = _options;
|
|
79
87
|
if (typeof autoHideNewItems !== 'boolean') {
|
|
80
88
|
_options.autoHideNewItems = autoHideNewItems = false;
|
|
@@ -82,6 +90,8 @@ class THtmlItemsListContainer {
|
|
|
82
90
|
if (typeof markCurrentItem !== 'boolean') {
|
|
83
91
|
_options.markCurrentItem = markCurrentItem = false;
|
|
84
92
|
};
|
|
93
|
+
itemBaseClassID = valueToClassList(itemBaseClassID, true);
|
|
94
|
+
_options.itemBaseClassID = itemBaseClassID;
|
|
85
95
|
// init status
|
|
86
96
|
const _status = {
|
|
87
97
|
curIndex: _items.curIndex,
|
|
@@ -152,29 +162,13 @@ class THtmlItemsListContainer {
|
|
|
152
162
|
|
|
153
163
|
srchIndexByAttr(name, value = ''){
|
|
154
164
|
const _name = typeof name === 'string' ? name.trim() : '';
|
|
155
|
-
const
|
|
156
|
-
let index = -1;
|
|
157
|
-
if (_name !== '' && _value !== null) {
|
|
158
|
-
const acceptAnyVal = _value === '';
|
|
159
|
-
const _items = this.#_items;
|
|
160
|
-
let item = null;
|
|
161
|
-
for (let i = 0; i < _items.count; i++) {
|
|
162
|
-
item = _items.getItem(i);
|
|
163
|
-
if (
|
|
164
|
-
isHTMLElement(item)
|
|
165
|
-
&& item.hasAttribute(_name)
|
|
166
|
-
&& (acceptAnyVal || item.getAttribute(_name) === _value)
|
|
167
|
-
) {
|
|
168
|
-
index = i;
|
|
169
|
-
break;
|
|
170
|
-
};
|
|
171
|
-
};
|
|
172
|
-
};
|
|
165
|
+
const { index } = srchListElementByAttr(this.#_items, _name, value);
|
|
173
166
|
return index;
|
|
174
167
|
};
|
|
175
168
|
|
|
176
169
|
srchIndexByID(value){
|
|
177
|
-
|
|
170
|
+
const { index } = srchListElementByAttr(this.#_items, 'id', value);
|
|
171
|
+
return index;
|
|
178
172
|
};
|
|
179
173
|
|
|
180
174
|
setCurIndex(index){
|
|
@@ -208,12 +202,15 @@ class THtmlItemsListContainer {
|
|
|
208
202
|
return isHTMLElement(item) ? item : null;
|
|
209
203
|
}
|
|
210
204
|
|
|
211
|
-
getItemByAttr(
|
|
212
|
-
|
|
205
|
+
getItemByAttr(name, value = ''){
|
|
206
|
+
const _name = typeof name === 'string' ? name.trim() : '';
|
|
207
|
+
const { item } = srchListElementByAttr(this.#_items, _name, value);
|
|
208
|
+
return item;
|
|
213
209
|
}
|
|
214
210
|
|
|
215
211
|
getItemByID(value){
|
|
216
|
-
|
|
212
|
+
const { item } = srchListElementByAttr(this.#_items, 'id', value);
|
|
213
|
+
return item;
|
|
217
214
|
}
|
|
218
215
|
|
|
219
216
|
addItem(item, opt){
|
|
@@ -225,9 +222,12 @@ class THtmlItemsListContainer {
|
|
|
225
222
|
);
|
|
226
223
|
const isSUCCEED = index !== -1;
|
|
227
224
|
if (isSUCCEED) {
|
|
228
|
-
|
|
225
|
+
const { autoHideNewItems, itemBaseClassID } = this.#_options;
|
|
226
|
+
if (autoHideNewItems) hideHtmlElement(item);
|
|
227
|
+
if (itemBaseClassID.length > 0) item.classList.add(...itemBaseClassID);
|
|
229
228
|
if (forceCI) this.setCurIndex(index);
|
|
230
|
-
|
|
229
|
+
const _host = this.#_host;
|
|
230
|
+
if (_host) _host.append(item);
|
|
231
231
|
};
|
|
232
232
|
return isSUCCEED ? index : -1;
|
|
233
233
|
}
|
|
@@ -300,6 +300,7 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
300
300
|
let {
|
|
301
301
|
//autoHideNewItems, // [*] processed by parent
|
|
302
302
|
//markCurrentItem, // [*] processed by parent
|
|
303
|
+
//itemBaseClassID, // [*] processed by parent
|
|
303
304
|
showStubsIfEmpty,
|
|
304
305
|
allowGroupSelection,
|
|
305
306
|
allowSelectionLocks,
|
|
@@ -364,16 +365,19 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
364
365
|
//* // NOTE: currently on eventPhase = 2 and 3
|
|
365
366
|
//*case 1:
|
|
366
367
|
/**/// capturing stage
|
|
367
|
-
case 2:
|
|
368
|
+
case 2: {
|
|
368
369
|
/**/// target stage
|
|
369
370
|
if (target !== this.#_host) curItem = target;
|
|
370
371
|
break;
|
|
371
|
-
|
|
372
|
+
}
|
|
373
|
+
case 3: {
|
|
372
374
|
/**/// bubblig stage
|
|
373
375
|
curItem = catchEventOnHost ? target : currentTarget;
|
|
374
376
|
break;
|
|
375
|
-
|
|
377
|
+
}
|
|
378
|
+
default: {
|
|
376
379
|
break;
|
|
380
|
+
}
|
|
377
381
|
};
|
|
378
382
|
if (
|
|
379
383
|
!isSelectionLocked
|
|
@@ -391,11 +395,7 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
391
395
|
};
|
|
392
396
|
|
|
393
397
|
#_triggerEvent = (name, ...args) => {
|
|
394
|
-
|
|
395
|
-
if (_name !== '') {
|
|
396
|
-
const _events = this.#_events;
|
|
397
|
-
if (_events.has(_name)) _events.get(_name)(...args);
|
|
398
|
-
};
|
|
398
|
+
triggerEventHandler(this.#_events, name, ...args);
|
|
399
399
|
};
|
|
400
400
|
|
|
401
401
|
get SelectedItems(){
|
|
@@ -597,20 +597,23 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
597
597
|
_selects.clear();
|
|
598
598
|
};
|
|
599
599
|
switch (mode) {
|
|
600
|
-
case ILC_SMODE_SHFT:
|
|
600
|
+
case ILC_SMODE_SHFT: {
|
|
601
601
|
if (indexCI > indexNI) [ indexCI, indexNI ] = [ indexNI, indexCI ];
|
|
602
602
|
for (let i = indexCI; i < indexNI + 1; i++) {
|
|
603
603
|
this.#_selectItem(i);
|
|
604
604
|
};
|
|
605
605
|
break;
|
|
606
|
-
|
|
606
|
+
}
|
|
607
|
+
case ILC_SMODE_CTRL: {
|
|
607
608
|
this.#_selectItem(this.srchIndex(item));
|
|
608
609
|
break;
|
|
609
|
-
|
|
610
|
+
}
|
|
611
|
+
default: {
|
|
610
612
|
if (this.#_selectItem(this.srchIndex(item))) {
|
|
611
613
|
if (forceCI) this.#_setCurIndex(indexNI);
|
|
612
614
|
};
|
|
613
615
|
break;
|
|
616
|
+
}
|
|
614
617
|
};
|
|
615
618
|
}
|
|
616
619
|
|
|
@@ -666,17 +669,7 @@ class THtmlItemsListController extends THtmlItemsListContainer {
|
|
|
666
669
|
}
|
|
667
670
|
|
|
668
671
|
on(name, evnt){
|
|
669
|
-
|
|
670
|
-
if (_name !== '' && typeof evnt === 'function') {
|
|
671
|
-
const _events = this.#_events;
|
|
672
|
-
if (!_events.has(_name)) {
|
|
673
|
-
_events.set(_name, evnt);
|
|
674
|
-
} else {
|
|
675
|
-
/* NOTE:
|
|
676
|
-
* for current you can't reset or set new one on the same event
|
|
677
|
-
*/
|
|
678
|
-
};
|
|
679
|
-
};
|
|
672
|
+
pushEventHandler(this.#_events, name, evnt);
|
|
680
673
|
}
|
|
681
674
|
|
|
682
675
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.045-20230408]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
|
-
readAsString,
|
|
6
|
+
//readAsString,
|
|
7
7
|
readAsNumber,
|
|
8
|
-
isNotEmptyString,
|
|
8
|
+
//isNotEmptyString,
|
|
9
9
|
isPlainObject,
|
|
10
|
-
valueToArray,
|
|
11
|
-
TItemsICollection,
|
|
10
|
+
//valueToArray,
|
|
11
|
+
//TItemsICollection,
|
|
12
12
|
} = require('@ygracs/bsfoc-lib-js');
|
|
13
13
|
|
|
14
14
|
const {
|
|
@@ -19,7 +19,12 @@ const {
|
|
|
19
19
|
const {
|
|
20
20
|
isHTMLButton,
|
|
21
21
|
THtmlButtonsSet,
|
|
22
|
-
|
|
22
|
+
readOnClickEventInfo,
|
|
23
|
+
} = require('./buttons.js');
|
|
24
|
+
|
|
25
|
+
const {
|
|
26
|
+
pushEventHandler, triggerEventHandler,
|
|
27
|
+
} = require('./mod-hfunc.js');
|
|
23
28
|
|
|
24
29
|
const {
|
|
25
30
|
CSS_CLASS_SELECTED,
|
|
@@ -101,28 +106,11 @@ class THtmlListButtonsController {
|
|
|
101
106
|
#_on_btn_frst_pressed = (e) => {
|
|
102
107
|
//console.log('THtmlListButtonsController._on_btn_frst_pressed() ==> was called...');
|
|
103
108
|
//e.preventDefault(); /* need to reconsider reason for use */
|
|
104
|
-
|
|
105
|
-
let on_click_num = readAsNumber(e.detail, 0);
|
|
106
|
-
//console.log('CHECK: e => ditail:['+on_click_num+']');
|
|
107
|
-
//console.log('CHECK: e => phase:['+e.eventPhase+']');
|
|
108
|
-
switch (e.eventPhase) {
|
|
109
|
-
//*case 1:
|
|
110
|
-
//* // NOTE: currently on eventPhase = 2 and 3
|
|
111
|
-
case 2:
|
|
112
|
-
/**/// capturing stage
|
|
113
|
-
curItem = e.target;
|
|
114
|
-
break;
|
|
115
|
-
case 3:
|
|
116
|
-
/**/// bubblig stage
|
|
117
|
-
curItem = e.currentTarget;
|
|
118
|
-
break;
|
|
119
|
-
default:
|
|
120
|
-
break;
|
|
121
|
-
};
|
|
109
|
+
const { item, onClickNum } = readOnClickEventInfo(e);
|
|
122
110
|
if (
|
|
123
|
-
|
|
124
|
-
&& (
|
|
125
|
-
&& !
|
|
111
|
+
item instanceof HTMLElement
|
|
112
|
+
&& (onClickNum === 0 || onClickNum === 1)
|
|
113
|
+
&& !item.classList.contains(CSS_CLASS_DISABLED)
|
|
126
114
|
) {
|
|
127
115
|
this.#_triggerEvent('btn-first-pressed', e);
|
|
128
116
|
};
|
|
@@ -131,28 +119,11 @@ class THtmlListButtonsController {
|
|
|
131
119
|
#_on_btn_last_pressed = (e) => {
|
|
132
120
|
//console.log('THtmlListButtonsController._on_btn_last_pressed() ==> was called...');
|
|
133
121
|
//e.preventDefault(); /* need to reconsider reason for use */
|
|
134
|
-
|
|
135
|
-
let on_click_num = readAsNumber(e.detail, 0);
|
|
136
|
-
//console.log('CHECK: e => ditail:['+on_click_num+']');
|
|
137
|
-
//console.log('CHECK: e => phase:['+e.eventPhase+']');
|
|
138
|
-
switch (e.eventPhase) {
|
|
139
|
-
//*case 1:
|
|
140
|
-
//* // NOTE: currently on eventPhase = 2 and 3
|
|
141
|
-
case 2:
|
|
142
|
-
/**/// capturing stage
|
|
143
|
-
curItem = e.target;
|
|
144
|
-
break;
|
|
145
|
-
case 3:
|
|
146
|
-
/**/// bubblig stage
|
|
147
|
-
curItem = e.currentTarget;
|
|
148
|
-
break;
|
|
149
|
-
default:
|
|
150
|
-
break;
|
|
151
|
-
};
|
|
122
|
+
const { item, onClickNum } = readOnClickEventInfo(e);
|
|
152
123
|
if (
|
|
153
|
-
|
|
154
|
-
&& (
|
|
155
|
-
&& !
|
|
124
|
+
item instanceof HTMLElement
|
|
125
|
+
&& (onClickNum === 0 || onClickNum === 1)
|
|
126
|
+
&& !item.classList.contains(CSS_CLASS_DISABLED)
|
|
156
127
|
) {
|
|
157
128
|
this.#_triggerEvent('btn-last-pressed', e);
|
|
158
129
|
};
|
|
@@ -161,28 +132,11 @@ class THtmlListButtonsController {
|
|
|
161
132
|
#_on_btn_prev_pressed = (e) => {
|
|
162
133
|
//console.log('THtmlListButtonsController._on_btn_prev_pressed() ==> was called...');
|
|
163
134
|
//e.preventDefault(); /* need to reconsider reason for use */
|
|
164
|
-
|
|
165
|
-
let on_click_num = readAsNumber(e.detail, 0);
|
|
166
|
-
//console.log('CHECK: e => ditail:['+on_click_num+']');
|
|
167
|
-
//console.log('CHECK: e => phase:['+e.eventPhase+']');
|
|
168
|
-
switch (e.eventPhase) {
|
|
169
|
-
//*case 1:
|
|
170
|
-
//* // NOTE: currently on eventPhase = 2 and 3
|
|
171
|
-
case 2:
|
|
172
|
-
/**/// capturing stage
|
|
173
|
-
curItem = e.target;
|
|
174
|
-
break;
|
|
175
|
-
case 3:
|
|
176
|
-
/**/// bubblig stage
|
|
177
|
-
curItem = e.currentTarget;
|
|
178
|
-
break;
|
|
179
|
-
default:
|
|
180
|
-
break;
|
|
181
|
-
};
|
|
135
|
+
const { item, onClickNum } = readOnClickEventInfo(e);
|
|
182
136
|
if (
|
|
183
|
-
|
|
184
|
-
&& (
|
|
185
|
-
&& !
|
|
137
|
+
item instanceof HTMLElement
|
|
138
|
+
&& (onClickNum === 0 || onClickNum === 1)
|
|
139
|
+
&& !item.classList.contains(CSS_CLASS_DISABLED)
|
|
186
140
|
) {
|
|
187
141
|
this.#_triggerEvent('btn-prev-pressed', e);
|
|
188
142
|
};
|
|
@@ -191,39 +145,18 @@ class THtmlListButtonsController {
|
|
|
191
145
|
#_on_btn_next_pressed = (e) => {
|
|
192
146
|
//console.log('THtmlListButtonsController._on_btn_next_pressed() ==> was called...');
|
|
193
147
|
//e.preventDefault(); /* need to reconsider reason for use */
|
|
194
|
-
|
|
195
|
-
let on_click_num = readAsNumber(e.detail, 0);
|
|
196
|
-
//console.log('CHECK: e => ditail:['+on_click_num+']');
|
|
197
|
-
//console.log('CHECK: e => phase:['+e.eventPhase+']');
|
|
198
|
-
switch (e.eventPhase) {
|
|
199
|
-
//*case 1:
|
|
200
|
-
//* // NOTE: currently on eventPhase = 2 and 3
|
|
201
|
-
case 2:
|
|
202
|
-
/**/// capturing stage
|
|
203
|
-
curItem = e.target;
|
|
204
|
-
break;
|
|
205
|
-
case 3:
|
|
206
|
-
/**/// bubblig stage
|
|
207
|
-
curItem = e.currentTarget;
|
|
208
|
-
break;
|
|
209
|
-
default:
|
|
210
|
-
break;
|
|
211
|
-
};
|
|
148
|
+
const { item, onClickNum } = readOnClickEventInfo(e);
|
|
212
149
|
if (
|
|
213
|
-
|
|
214
|
-
&& (
|
|
215
|
-
&& !
|
|
150
|
+
item instanceof HTMLElement
|
|
151
|
+
&& (onClickNum === 0 || onClickNum === 1)
|
|
152
|
+
&& !item.classList.contains(CSS_CLASS_DISABLED)
|
|
216
153
|
) {
|
|
217
154
|
this.#_triggerEvent('btn-next-pressed', e);
|
|
218
155
|
};
|
|
219
156
|
}
|
|
220
157
|
|
|
221
158
|
#_triggerEvent = (name, ...args) => {
|
|
222
|
-
|
|
223
|
-
if (_name !== '') {
|
|
224
|
-
const _events = this.#_events;
|
|
225
|
-
if (_events.has(_name)) _events.get(name)(...args);
|
|
226
|
-
};
|
|
159
|
+
triggerEventHandler(this.#_events, name, ...args);
|
|
227
160
|
}
|
|
228
161
|
|
|
229
162
|
disableAll(){
|
|
@@ -255,18 +188,7 @@ class THtmlListButtonsController {
|
|
|
255
188
|
}
|
|
256
189
|
|
|
257
190
|
on(name, evnt){
|
|
258
|
-
|
|
259
|
-
if (_name !== '' && typeof evnt === 'function') {
|
|
260
|
-
const _events = this.#_events;
|
|
261
|
-
if (!_events.has(_name)) {
|
|
262
|
-
_events.set(_name, evnt);
|
|
263
|
-
} else {
|
|
264
|
-
/* NOTE:
|
|
265
|
-
* for current you can't reset or set new one on the same event
|
|
266
|
-
*/
|
|
267
|
-
//console.log('THtmlListButtonsController.on() ==> event:['+name+'] - already exists...');
|
|
268
|
-
};
|
|
269
|
-
};
|
|
191
|
+
pushEventHandler(this.#_events, name, evnt);
|
|
270
192
|
}
|
|
271
193
|
};
|
|
272
194
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.039-20230409]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
@@ -6,7 +6,6 @@ const {
|
|
|
6
6
|
//readAsBool, readAsNumber, readAsString,
|
|
7
7
|
//isEmptyString, isNotEmptyString,
|
|
8
8
|
isArray, isObject, isPlainObject,
|
|
9
|
-
//TItemsListEx,
|
|
10
9
|
} = require('@ygracs/bsfoc-lib-js');
|
|
11
10
|
|
|
12
11
|
const {
|
|
@@ -141,12 +140,9 @@ class THtmlStubItemsSet {
|
|
|
141
140
|
}
|
|
142
141
|
|
|
143
142
|
loadItems(list, opt){
|
|
144
|
-
let _options =
|
|
145
|
-
if (typeof
|
|
146
|
-
|
|
147
|
-
} else if (isPlainObject(opt)) {
|
|
148
|
-
_options = opt;
|
|
149
|
-
};
|
|
143
|
+
let _options = opt;
|
|
144
|
+
if (typeof _options === 'boolean') _options = { useClear: _options };
|
|
145
|
+
if (!isPlainObject(_options)) _options = {};
|
|
150
146
|
let {
|
|
151
147
|
defaultItem,
|
|
152
148
|
useClear,
|
|
@@ -154,8 +150,8 @@ class THtmlStubItemsSet {
|
|
|
154
150
|
load_as_new, //* will deprecate
|
|
155
151
|
} = _options;
|
|
156
152
|
if (useClear === undefined) useClear = load_as_new;
|
|
157
|
-
|
|
158
|
-
|
|
153
|
+
if (typeof useClear !== 'boolean') useClear = true;
|
|
154
|
+
if (typeof force !== 'boolean') force = false;
|
|
159
155
|
let _list = list;
|
|
160
156
|
if (isPlainObject(_list)) {
|
|
161
157
|
({ items: _list, defaultItem } = _list);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// [v0.1.059-20230408]
|
|
2
|
+
|
|
3
|
+
// === module init block ===
|
|
4
|
+
|
|
5
|
+
// === module extra block (helper functions) ===
|
|
6
|
+
|
|
7
|
+
// === module main block (function definitions) ===
|
|
8
|
+
|
|
9
|
+
function pushEventHandler(pool, name, evnt){
|
|
10
|
+
const _name = typeof name === 'string' ? name.trim() : '';
|
|
11
|
+
if (_name !== '' && typeof evnt === 'function') {
|
|
12
|
+
if (!pool.has(_name)) {
|
|
13
|
+
pool.set(_name, evnt);
|
|
14
|
+
} else {
|
|
15
|
+
/* NOTE:
|
|
16
|
+
* for current you can't reset or set new one on the same event
|
|
17
|
+
*/
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function triggerEventHandler(pool, name, ...args){
|
|
23
|
+
const _name = typeof name === 'string' ? name.trim() : '';
|
|
24
|
+
if (_name !== '') {
|
|
25
|
+
if (pool.has(_name)) pool.get(_name)(...args);
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
// === module main block (class definitions) ===
|
|
29
|
+
|
|
30
|
+
// === module exports block ===
|
|
31
|
+
|
|
32
|
+
exports.pushEventHandler = pushEventHandler;
|
|
33
|
+
exports.triggerEventHandler = triggerEventHandler;
|
package/lib/html-helper-lib.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.016-20230330]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
|
-
//isEmptyString, isNotEmptyString,
|
|
7
6
|
readAsString,
|
|
8
|
-
//readAsListS,
|
|
9
7
|
isArray, isObject, isPlainObject, valueToArray,
|
|
10
8
|
} = require('@ygracs/bsfoc-lib-js');
|
|
11
9
|
|
|
@@ -19,7 +17,9 @@ const CSS_CLASS_HIDDEN = 'hidden';
|
|
|
19
17
|
|
|
20
18
|
// === module main block (function definitions) ===
|
|
21
19
|
|
|
22
|
-
function isHTMLElement(obj){
|
|
20
|
+
function isHTMLElement(obj){
|
|
21
|
+
return obj instanceof HTMLElement;
|
|
22
|
+
};
|
|
23
23
|
|
|
24
24
|
function isSelectedHTMLElement(obj){
|
|
25
25
|
return isHTMLElement(obj) && obj.classList.contains(CSS_CLASS_SELECTED);
|
|
@@ -87,14 +87,17 @@ function unmarkActiveHtmlElement(obj){
|
|
|
87
87
|
|
|
88
88
|
function inactivateHtmlElements(...args) {
|
|
89
89
|
for (let item of args) {
|
|
90
|
-
if (item
|
|
90
|
+
if (isHTMLElement(item)) {
|
|
91
91
|
item.classList.add(CSS_CLASS_DISABLED);
|
|
92
92
|
switch (item.tagName.toLowerCase()) {
|
|
93
93
|
case 'button':
|
|
94
|
-
case 'input':
|
|
95
|
-
item.disabled = true;
|
|
96
|
-
|
|
94
|
+
case 'input': {
|
|
95
|
+
item.disabled = true;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
default: {
|
|
97
99
|
break;
|
|
100
|
+
}
|
|
98
101
|
};
|
|
99
102
|
};
|
|
100
103
|
};
|
|
@@ -102,19 +105,45 @@ function inactivateHtmlElements(...args) {
|
|
|
102
105
|
|
|
103
106
|
function activateHtmlElements(...args) {
|
|
104
107
|
for (let item of args) {
|
|
105
|
-
if (item
|
|
108
|
+
if (isHTMLElement(item)) {
|
|
106
109
|
item.classList.remove(CSS_CLASS_DISABLED);
|
|
107
110
|
switch (item.tagName.toLowerCase()) {
|
|
108
111
|
case 'button':
|
|
109
|
-
case 'input':
|
|
110
|
-
item.disabled = false;
|
|
111
|
-
default:
|
|
112
|
+
case 'input': {
|
|
113
|
+
item.disabled = false;
|
|
112
114
|
break;
|
|
115
|
+
}
|
|
116
|
+
default: {
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
113
119
|
};
|
|
114
120
|
};
|
|
115
121
|
};
|
|
116
122
|
};
|
|
117
123
|
|
|
124
|
+
function readAsAttrValue(value){
|
|
125
|
+
let result = null;
|
|
126
|
+
switch (typeof value) {
|
|
127
|
+
case 'boolean': {
|
|
128
|
+
result = value.toString();
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
case 'number': {
|
|
132
|
+
if (Number.isNaN(value)) break;
|
|
133
|
+
result = value.toString();
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
case 'string': {
|
|
137
|
+
result = value.trim();
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
default: {
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
return result;
|
|
145
|
+
};
|
|
146
|
+
|
|
118
147
|
function valueToClassList(value, opt){
|
|
119
148
|
let result = [];
|
|
120
149
|
let list = valueToArray(value);
|
|
@@ -137,16 +166,19 @@ function valueToClassList(value, opt){
|
|
|
137
166
|
function valueToIDString(value){
|
|
138
167
|
let result = '';
|
|
139
168
|
switch (typeof value) {
|
|
140
|
-
case 'number':
|
|
169
|
+
case 'number': {
|
|
141
170
|
if (Number.isNaN(value) || value < 0) break;
|
|
142
171
|
if (Number.isInteger(value)) result = value.toString();
|
|
143
172
|
break;
|
|
144
|
-
|
|
173
|
+
}
|
|
174
|
+
case 'string': {
|
|
145
175
|
result = value.trim();
|
|
146
176
|
// // TODO: check if a valid character sequencies
|
|
147
177
|
break;
|
|
148
|
-
|
|
178
|
+
}
|
|
179
|
+
default: {
|
|
149
180
|
break;
|
|
181
|
+
}
|
|
150
182
|
};
|
|
151
183
|
return result;
|
|
152
184
|
};
|
|
@@ -243,3 +275,4 @@ exports.valueToClassList = valueToClassList;
|
|
|
243
275
|
// experimental
|
|
244
276
|
exports.createNewHtmlElement = createNewHtmlElement;
|
|
245
277
|
exports.valueToIDString = valueToIDString;
|
|
278
|
+
exports.readAsAttrValue = readAsAttrValue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cntwg/html-helper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "A base HTML-helper library for js",
|
|
5
5
|
"author": "ygracs <cs70th-om@rambler.ru>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,14 +15,18 @@
|
|
|
15
15
|
"doc/html-ctrls-btn.md",
|
|
16
16
|
"lib/html-helper-lib.js",
|
|
17
17
|
"lib/html-ctrls/lists-stubs.js",
|
|
18
|
-
"lib/html-ctrls/lists-
|
|
19
|
-
"lib/html-ctrls
|
|
20
|
-
"lib/html-ctrls
|
|
21
|
-
"
|
|
18
|
+
"lib/html-ctrls/lists-btn.js",
|
|
19
|
+
"lib/html-ctrls/list.js",
|
|
20
|
+
"lib/html-ctrls/buttons.js",
|
|
21
|
+
"lib/html-ctrls/mod-hfunc.js",
|
|
22
|
+
"index.js",
|
|
23
|
+
"CHANGELOG.md"
|
|
22
24
|
],
|
|
23
25
|
"scripts": {
|
|
24
26
|
"test": "jest",
|
|
25
27
|
"test-bs": "jest base/",
|
|
28
|
+
"test-bs:g1": "jest base/fg-1",
|
|
29
|
+
"test-bs:g2": "jest base/fg-2",
|
|
26
30
|
"test-lc1": "jest THtmlItemsListContainer",
|
|
27
31
|
"test-lc2": "jest THtmlItemsListController",
|
|
28
32
|
"test-lc2:bs": "jest THtmlItemsListController/base",
|