@cntwg/html-helper 0.0.24 → 0.0.26
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 +20 -0
- package/doc/html-ctrls-list.md +15 -13
- package/doc/html-helper-lib.md +5 -5
- package/index.js +4 -14
- package/lib/event-hfunc.js +26 -8
- package/lib/html-ctrls/buttons.js +24 -27
- package/lib/html-ctrls/fields.js +72 -61
- package/lib/html-ctrls/list.js +76 -51
- package/lib/html-ctrls/lists-btn.js +4 -6
- package/lib/html-ctrls/lists-stubs.js +55 -41
- package/lib/html-helper-lib.js +14 -82
- package/package.json +3 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
#### *v0.0.26*
|
|
2
|
+
|
|
3
|
+
Pre-release version.
|
|
4
|
+
|
|
5
|
+
> - `html-ctrls-list.md` updated;
|
|
6
|
+
> - improve a 'THtmlItemsListController' behavior on handling a `click`-event;
|
|
7
|
+
> - change behavior for a `THtmlStubItemsSet`-class constructor (*see docs for details*);
|
|
8
|
+
> - change behavior for a `loadItems`-method of a `THtmlStubItemsSet`-class (*see docs for details*);
|
|
9
|
+
> - some other fixes.
|
|
10
|
+
|
|
11
|
+
#### *v0.0.25*
|
|
12
|
+
|
|
13
|
+
Pre-release version.
|
|
14
|
+
|
|
15
|
+
> - update dependency on `@ygracs/bsfoc-lib-js` module to v0.2.3;
|
|
16
|
+
> - add dependency on `@ygracs/lists-lib-js` module;
|
|
17
|
+
> - remove some deprecates (*see docs for details*);
|
|
18
|
+
> - change pattern for an element manipulation functions (*see docs for details*);
|
|
19
|
+
> - change behavior for `loadItems` method of `THtmlStubItemsSet` class in handling `options` parameter (*see docs for details*).
|
|
20
|
+
|
|
1
21
|
#### *v0.0.24*
|
|
2
22
|
|
|
3
23
|
Pre-release version.
|
package/doc/html-ctrls-list.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
>|***rev.*:**|0.1.
|
|
1
|
+
>|***rev.*:**|0.1.24|
|
|
2
2
|
>|:---|---:|
|
|
3
|
-
>|date:|
|
|
3
|
+
>|date:|2025-05-05|
|
|
4
4
|
|
|
5
5
|
## Introduction
|
|
6
6
|
|
|
@@ -625,7 +625,9 @@ The class constructor receives a parameters listed below:
|
|
|
625
625
|
| parameter name | value type | default value | description |
|
|
626
626
|
|:---|---|---:|:---|
|
|
627
627
|
| `host` | `HTMLElement` | --- | points to a host element which holds a list items |
|
|
628
|
-
| `options` | `object`, `array` |
|
|
628
|
+
| `options` | `object`, `array` | --- | contains an object that is send to a class `loadItems` method |
|
|
629
|
+
|
|
630
|
+
> \[!] NOTE: `[since v0.0.26]` a use of a `array` type as a value of an `options` are deprecated and will be dropped soon.
|
|
629
631
|
|
|
630
632
|
##### `options` parameter
|
|
631
633
|
|
|
@@ -633,11 +635,9 @@ The `options` structure has listed below:
|
|
|
633
635
|
|
|
634
636
|
| option name | value type | default value | description |
|
|
635
637
|
|:---|---|---:|:---|
|
|
636
|
-
| `items` | `array` |
|
|
638
|
+
| `items` | `array`, `object` | --- | defines a list of the entries to load. For more details see a description of a [`loadItems`](#THtmlStubItemsSet+loadItems) class method |
|
|
637
639
|
| `defaultItem` | `string` | --- | if set it defines a name of the item used by default |
|
|
638
|
-
| `force` | `boolean` | `false` | if set to `true`, the item which is already present will be replaced with a new one
|
|
639
|
-
|
|
640
|
-
> NOTE: For more details on an `items` element see an description of a [`loadItems`](#THtmlStubItemsSet+loadItems) class method.
|
|
640
|
+
| `force` | `boolean` | `false` | if set to `true`, the item which is already present will be replaced with a new one |
|
|
641
641
|
|
|
642
642
|
#### class properties
|
|
643
643
|
|
|
@@ -754,25 +754,27 @@ This class method is similar to `showItem` method but is performed on a default
|
|
|
754
754
|
This class method is similar to `hideItem` method but is performed on a default item.
|
|
755
755
|
|
|
756
756
|
<a name="THtmlStubItemsSet+loadItems"></a>
|
|
757
|
-
##### **loadItems(
|
|
757
|
+
##### **loadItems(data\[, options])** => `number`
|
|
758
758
|
|
|
759
759
|
This class methods loads an items given by `list` in the set and returned quantity of how many items have been processed successfully.
|
|
760
760
|
|
|
761
761
|
| parameter name | value type | default value | description |
|
|
762
762
|
|:---|---|---:|:---|
|
|
763
|
-
| `
|
|
763
|
+
| `data` | `array`, `object` | --- | an array of entries or a special descriptive object |
|
|
764
764
|
| `options` | `boolean`, `object` | --- | an options |
|
|
765
765
|
|
|
766
|
-
|
|
766
|
+
> \[!] NOTE: *`[since v0.0.25]`* the use of a booleans as an `options` value is deprecated and will be dropped soon.
|
|
767
|
+
|
|
768
|
+
If the `data` parameter is an `object` that contains the following set of values:
|
|
767
769
|
|
|
768
770
|
| option name | value type | default value | description |
|
|
769
771
|
|:---|---|---:|:---|
|
|
770
772
|
| `items` | `array` | `undefined` | defines a list of the entries to load. Each entry contains a `name`-`element` pair. |
|
|
771
773
|
| `defaultItem` | `string` | --- | if set it defines a name of the item used by default |
|
|
772
774
|
|
|
773
|
-
If the `
|
|
775
|
+
If the `data` parameter is an `array` it used as value of a `data.items` options.
|
|
774
776
|
|
|
775
|
-
Note that each element of a `
|
|
777
|
+
Note that each element of a `data.items` can be:
|
|
776
778
|
|
|
777
779
|
- an `array` which contains a `key-value` pair
|
|
778
780
|
|
|
@@ -786,7 +788,7 @@ If the `options` parameter is an `object` that contains the following set of par
|
|
|
786
788
|
|
|
787
789
|
| option name | value type | default value | description |
|
|
788
790
|
|:---|---|---:|:---|
|
|
789
|
-
| `defaultItem` | `string` | --- | if set it defines a name of the item used by default |
|
|
791
|
+
| `defaultItem` | `string` | --- | (*deprecated **since `v0.0.26`***) if set it defines a name of the item used by default |
|
|
790
792
|
| `useClear` | `boolean` | `true` | if set to `true`, before the load of the items, the list is cleared |
|
|
791
793
|
| `force` | `boolean` | `false` | if set to `true`, the item which is already present will be replaced with a new one |
|
|
792
794
|
|
package/doc/html-helper-lib.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
>|***rev.*:**|0.1.
|
|
1
|
+
>|***rev.*:**|0.1.15|
|
|
2
2
|
>|:---|---:|
|
|
3
|
-
>|date:|
|
|
3
|
+
>|date:|2025-03-29|
|
|
4
4
|
|
|
5
5
|
## Introduction
|
|
6
6
|
|
|
@@ -170,7 +170,7 @@ This function enables a given HTML-element.
|
|
|
170
170
|
| `obj` | `HTMLElement` | --- | some element to be modified |
|
|
171
171
|
|
|
172
172
|
<a name="activateHTMLElements"></a>
|
|
173
|
-
#### **
|
|
173
|
+
#### **activateHTMLElements(arg_1\[, arg_2\[, ...arg_N]])** => `void`
|
|
174
174
|
|
|
175
175
|
This function enables all HTML-elements received as a function arguments.
|
|
176
176
|
|
|
@@ -207,8 +207,8 @@ The `options` parameter if sets to `true` force the function to remove all dupli
|
|
|
207
207
|
|
|
208
208
|
> Note: Purpose of those functions will be discussed and some may be deprecate and make obsolete or functionality may be altered. So use it with cautions in mind.
|
|
209
209
|
|
|
210
|
-
<a name="
|
|
211
|
-
#### **
|
|
210
|
+
<a name="createNewHTMLElement"></a>
|
|
211
|
+
#### **createNewHTMLElement(tagName\[, options])**
|
|
212
212
|
|
|
213
213
|
This function helps to simplify the process of creating a new HTML-element. It receives the tag name (`tagName` parameter) and the options as a second parameter:
|
|
214
214
|
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.028-20250503]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
@@ -27,6 +27,7 @@ const components = {
|
|
|
27
27
|
|
|
28
28
|
const eventHelper = {
|
|
29
29
|
pushEventHandler: ev_helper.pushEventHandler,
|
|
30
|
+
removeEventHandler: ev_helper.removeEventHandler,
|
|
30
31
|
triggerEventHandler: ev_helper.triggerEventHandler,
|
|
31
32
|
};
|
|
32
33
|
|
|
@@ -69,7 +70,7 @@ module.exports.readAsTagName = html_helper.readAsTagName;
|
|
|
69
70
|
module.exports.readAsAttrName = html_helper.readAsAttrName;
|
|
70
71
|
module.exports.readAsAttrValue = html_helper.readAsAttrValue;
|
|
71
72
|
module.exports.valueToElementID = html_helper.valueToElementID;
|
|
72
|
-
module.exports.
|
|
73
|
+
module.exports.createNewHTMLElement = html_helper.createNewHTMLElement;
|
|
73
74
|
|
|
74
75
|
module.exports.isHTMLButton = html_bts.isHTMLButton;
|
|
75
76
|
|
|
@@ -85,15 +86,4 @@ module.exports.classes = components;
|
|
|
85
86
|
|
|
86
87
|
// deprecated
|
|
87
88
|
module.exports.component = components;
|
|
88
|
-
module.exports.
|
|
89
|
-
module.exports.showHtmlElement = html_helper.showHtmlElement;
|
|
90
|
-
module.exports.selectHtmlElement = html_helper.selectHtmlElement;
|
|
91
|
-
module.exports.unselectHtmlElement = html_helper.unselectHtmlElement;
|
|
92
|
-
module.exports.markHtmlElementAsCurrent = html_helper.markHtmlElementAsCurrent;
|
|
93
|
-
module.exports.unmarkCurrentHtmlElement = html_helper.unmarkCurrentHtmlElement;
|
|
94
|
-
module.exports.markHtmlElementAsActive = html_helper.markHtmlElementAsActive;
|
|
95
|
-
module.exports.unmarkActiveHtmlElement = html_helper.unmarkActiveHtmlElement;
|
|
96
|
-
module.exports.lockHtmlElement = html_helper.lockHtmlElement;
|
|
97
|
-
module.exports.unlockHtmlElement = html_helper.unlockHtmlElement;
|
|
98
|
-
module.exports.inactivateHtmlElements = html_helper.inactivateHtmlElements;
|
|
99
|
-
module.exports.activateHtmlElements = html_helper.activateHtmlElements;
|
|
89
|
+
module.exports.createNewHtmlElement = html_helper.createNewHtmlElement;
|
package/lib/event-hfunc.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.063-20250503]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @function pushEventHandler
|
|
19
|
-
* @param {
|
|
19
|
+
* @param {Map<string, Function>} pool - pool object
|
|
20
20
|
* @param {string} name - event name
|
|
21
|
-
* @param {
|
|
21
|
+
* @param {Function} evnt - callback function
|
|
22
22
|
* @returns {void}
|
|
23
23
|
* @inner
|
|
24
24
|
*/
|
|
25
|
-
function pushEventHandler(pool, name, evnt){
|
|
25
|
+
function pushEventHandler(pool, name, evnt) {
|
|
26
26
|
const _name = typeof name === 'string' ? name.trim() : '';
|
|
27
27
|
if (_name !== '' && typeof evnt === 'function') {
|
|
28
28
|
if (!pool.has(_name)) {
|
|
@@ -35,15 +35,32 @@ function pushEventHandler(pool, name, evnt){
|
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* @function removeEventHandler
|
|
40
|
+
* @param {Map<string, Function>} pool - pool object
|
|
41
|
+
* @param {string} name - event name
|
|
42
|
+
* @returns {void}
|
|
43
|
+
* @inner
|
|
44
|
+
*/
|
|
45
|
+
function removeEventHandler(pool, name) {
|
|
46
|
+
const key = typeof name === 'string' ? name.trim() : '';
|
|
47
|
+
if (key !== '') {
|
|
48
|
+
/* NOTE:
|
|
49
|
+
* for current you can't reset or set new one on the same event
|
|
50
|
+
*/
|
|
51
|
+
if (pool.has(key)) pool.delete(key);
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
38
55
|
/**
|
|
39
56
|
* @function triggerEventHandler
|
|
40
|
-
* @param {
|
|
57
|
+
* @param {Map<string, Function>} pool - pool object
|
|
41
58
|
* @param {string} name - event name
|
|
42
59
|
* @param {...any} [args]
|
|
43
60
|
* @returns {void}
|
|
44
61
|
* @inner
|
|
45
62
|
*/
|
|
46
|
-
function triggerEventHandler(pool, name, ...args){
|
|
63
|
+
function triggerEventHandler(pool, name, ...args) {
|
|
47
64
|
const _name = typeof name === 'string' ? name.trim() : '';
|
|
48
65
|
if (_name !== '') {
|
|
49
66
|
if (pool.has(_name)) pool.get(_name)(...args);
|
|
@@ -56,5 +73,6 @@ function triggerEventHandler(pool, name, ...args){
|
|
|
56
73
|
|
|
57
74
|
// === module exports block ===
|
|
58
75
|
|
|
59
|
-
exports.pushEventHandler = pushEventHandler;
|
|
60
|
-
exports.triggerEventHandler = triggerEventHandler;
|
|
76
|
+
module.exports.pushEventHandler = pushEventHandler;
|
|
77
|
+
module.exports.triggerEventHandler = triggerEventHandler;
|
|
78
|
+
module.exports.removeEventHandler = removeEventHandler;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.062-20250509]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
6
|
isNotEmptyString,
|
|
7
7
|
isPlainObject, valueToArray,
|
|
8
|
-
TItemsICollection,
|
|
9
8
|
} = require('@ygracs/bsfoc-lib-js');
|
|
10
9
|
|
|
10
|
+
const {
|
|
11
|
+
TItemsICollection,
|
|
12
|
+
} = require('@ygracs/lists-lib-js');
|
|
13
|
+
|
|
11
14
|
const {
|
|
12
15
|
isHTMLElement,
|
|
13
16
|
valueToIDString,
|
|
@@ -21,15 +24,9 @@ const {
|
|
|
21
24
|
} = require('./mod-hfunc.js');
|
|
22
25
|
|
|
23
26
|
const {
|
|
24
|
-
//CSS_CLASS_SELECTED,
|
|
25
27
|
CSS_CLASS_DISABLED,
|
|
26
|
-
//CSS_CLASS_HIDDEN,
|
|
27
28
|
} = CSS_CLASS_STRING;
|
|
28
29
|
|
|
29
|
-
const etlHTagInputForBtn = new Set([
|
|
30
|
-
'button', 'submit', 'reset', 'image',
|
|
31
|
-
]);
|
|
32
|
-
|
|
33
30
|
// === module extra block (helper functions) ===
|
|
34
31
|
|
|
35
32
|
// === module main block ===
|
|
@@ -40,6 +37,10 @@ const etlHTagInputForBtn = new Set([
|
|
|
40
37
|
|
|
41
38
|
const BTS_DEF_GROUP_NAME = 'all';
|
|
42
39
|
|
|
40
|
+
const etlHTagInputForBtn = new Set([
|
|
41
|
+
'button', 'submit', 'reset', 'image',
|
|
42
|
+
]);
|
|
43
|
+
|
|
43
44
|
/***
|
|
44
45
|
* (* function definitions *)
|
|
45
46
|
*/
|
|
@@ -62,9 +63,7 @@ function isHTMLButton(obj) {
|
|
|
62
63
|
result = etlHTagInputForBtn.has(obj.type.toLowerCase());
|
|
63
64
|
break;
|
|
64
65
|
}
|
|
65
|
-
default: {
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
66
|
+
default: {}
|
|
68
67
|
};
|
|
69
68
|
};
|
|
70
69
|
return result;
|
|
@@ -78,7 +77,7 @@ function isHTMLButton(obj) {
|
|
|
78
77
|
* @classdesc This class implements an interface of a buttons set
|
|
79
78
|
*/
|
|
80
79
|
class THtmlButtonsSet {
|
|
81
|
-
/** @
|
|
80
|
+
/** @type {TItemsICollection} */
|
|
82
81
|
#_btnCol;
|
|
83
82
|
|
|
84
83
|
/**
|
|
@@ -103,20 +102,20 @@ class THtmlButtonsSet {
|
|
|
103
102
|
}
|
|
104
103
|
|
|
105
104
|
/**
|
|
106
|
-
*
|
|
105
|
+
* Contains a list of an element names
|
|
106
|
+
* @type {string[]}
|
|
107
107
|
* @readonly
|
|
108
108
|
* @see TItemsICollection.ItemNames
|
|
109
|
-
* @description Contains a list of an element names
|
|
110
109
|
*/
|
|
111
110
|
get ItemNames() {
|
|
112
111
|
return this.#_btnCol.ItemNames;
|
|
113
112
|
}
|
|
114
113
|
|
|
115
114
|
/**
|
|
116
|
-
*
|
|
115
|
+
* Contains a list of an elements group names
|
|
116
|
+
* @type {string[]}
|
|
117
117
|
* @readonly
|
|
118
118
|
* @see TItemsICollection.CategoryNames
|
|
119
|
-
* @description Contains a list of an elements group names
|
|
120
119
|
*/
|
|
121
120
|
get GroupNames() {
|
|
122
121
|
return this.#_btnCol.CategoryNames;
|
|
@@ -267,9 +266,9 @@ class THtmlButtonsSet {
|
|
|
267
266
|
}
|
|
268
267
|
|
|
269
268
|
/**
|
|
270
|
-
*
|
|
269
|
+
* Returns a function wich do a validation check.
|
|
270
|
+
* @type {isHTMLButton}
|
|
271
271
|
* @static
|
|
272
|
-
* @description Returns a function wich do a validation check.
|
|
273
272
|
*/
|
|
274
273
|
static get isHTMLButton() {
|
|
275
274
|
return isHTMLButton;
|
|
@@ -282,9 +281,9 @@ class THtmlButtonsSet {
|
|
|
282
281
|
* A set provide a three button: <apply>, <reset> and <cancel>.
|
|
283
282
|
*/
|
|
284
283
|
class THtmlButtonsControllerARCSet {
|
|
285
|
-
/** @
|
|
284
|
+
/** @type {THtmlButtonsSet} */
|
|
286
285
|
#_btnSet;
|
|
287
|
-
/** @
|
|
286
|
+
/** @type {Map<string, Function>} */
|
|
288
287
|
#_events;
|
|
289
288
|
|
|
290
289
|
/**
|
|
@@ -300,15 +299,13 @@ class THtmlButtonsControllerARCSet {
|
|
|
300
299
|
* @description Creates an instance of the buttons set.
|
|
301
300
|
*/
|
|
302
301
|
constructor(opt) {
|
|
303
|
-
// load options
|
|
304
|
-
const _options = isPlainObject(opt) ? opt : {};
|
|
305
302
|
// load controls
|
|
306
303
|
/** @type {arcButtonsDesc} */
|
|
307
304
|
let {
|
|
308
305
|
btnApply,
|
|
309
306
|
btnReset,
|
|
310
307
|
btnCancel,
|
|
311
|
-
} =
|
|
308
|
+
} = isPlainObject(opt) ? opt : {};
|
|
312
309
|
if (!isHTMLButton(btnApply)) btnApply = null;
|
|
313
310
|
if (!isHTMLButton(btnReset)) btnReset = null;
|
|
314
311
|
if (!isHTMLButton(btnCancel)) btnCancel = null;
|
|
@@ -409,9 +406,9 @@ class THtmlButtonsControllerARCSet {
|
|
|
409
406
|
|
|
410
407
|
// === module exports block ===
|
|
411
408
|
|
|
412
|
-
exports.THtmlButtonsSet = THtmlButtonsSet;
|
|
413
|
-
exports.THtmlButtonsControllerARCSet = THtmlButtonsControllerARCSet;
|
|
409
|
+
module.exports.THtmlButtonsSet = THtmlButtonsSet;
|
|
410
|
+
module.exports.THtmlButtonsControllerARCSet = THtmlButtonsControllerARCSet;
|
|
414
411
|
|
|
415
|
-
exports.BTS_DEF_GROUP_NAME = BTS_DEF_GROUP_NAME;
|
|
412
|
+
module.exports.BTS_DEF_GROUP_NAME = BTS_DEF_GROUP_NAME;
|
|
416
413
|
|
|
417
|
-
exports.isHTMLButton = isHTMLButton;
|
|
414
|
+
module.exports.isHTMLButton = isHTMLButton;
|
package/lib/html-ctrls/fields.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.022-20250509]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@ const {
|
|
|
9
9
|
} = require('@ygracs/bsfoc-lib-js');
|
|
10
10
|
|
|
11
11
|
const {
|
|
12
|
-
isHTMLElement,
|
|
12
|
+
isHTMLElement, createNewHTMLElement,
|
|
13
13
|
valueToIDString, valueToClassList,
|
|
14
14
|
readAsAttrValue,
|
|
15
15
|
showHTMLElement, hideHTMLElement,
|
|
@@ -29,14 +29,14 @@ const lpAllowedValues = new Map([
|
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* @typedef {Object} ifcTypeDesc
|
|
32
|
-
* @property {string} type - type
|
|
33
|
-
* @property {string} subtype -
|
|
32
|
+
* @property {string} type - field general type
|
|
33
|
+
* @property {string} subtype - field sub-type
|
|
34
34
|
* @description An input field type description
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* @function getInputFieldTypeDescr
|
|
39
|
-
* @param {string} value
|
|
39
|
+
* @param {string} value - field type
|
|
40
40
|
* @returns {ifcTypeDesc}
|
|
41
41
|
* @inner
|
|
42
42
|
* @description Returns field description by a given type.
|
|
@@ -70,13 +70,13 @@ function getInputFieldTypeDescr(value) {
|
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* @function getLabelPositionID
|
|
73
|
-
* @param {string} value
|
|
73
|
+
* @param {string} value - label position identifier
|
|
74
74
|
* @returns {number}
|
|
75
75
|
* @inner
|
|
76
76
|
* @description Returns label position ID by its name.
|
|
77
77
|
*/
|
|
78
78
|
function getLabelPositionID(value) {
|
|
79
|
-
let key = readAsString(value, true);
|
|
79
|
+
let key = readAsString(value, { useTrim: true });
|
|
80
80
|
if (!lpAllowedValues.has(key)) key = 'default';
|
|
81
81
|
return lpAllowedValues.get(key);
|
|
82
82
|
};
|
|
@@ -95,51 +95,70 @@ function getLabelPositionID(value) {
|
|
|
95
95
|
* (* class definitions *)
|
|
96
96
|
*/
|
|
97
97
|
|
|
98
|
+
/**
|
|
99
|
+
* @typedef {Object} OPT_ifcdesc
|
|
100
|
+
* @property {HTMLElement} [host] - host element
|
|
101
|
+
* @property {string} [idPref]
|
|
102
|
+
* @property {string} [label] - text of a label
|
|
103
|
+
* @property {object} [labelPosition]
|
|
104
|
+
* @property {boolean} [useDelim]
|
|
105
|
+
* @property {object} [baseClassID]
|
|
106
|
+
* @property {string} [hint] - hint to show when empty
|
|
107
|
+
* @property {string} [type] - field type
|
|
108
|
+
* @property {boolean} [readonly] - mode flag
|
|
109
|
+
* @description An options set for create ifc
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @typedef {Object} OPT_ifcsett
|
|
114
|
+
* @property {string} [idPref]
|
|
115
|
+
* @property {(string|string[])} [baseClassID]
|
|
116
|
+
* @property {string} [hint] - hint to show when empty
|
|
117
|
+
* @property {string} [type] - field type
|
|
118
|
+
* @property {boolean} [readonly=true] - mode flag
|
|
119
|
+
* @description An options set for `THtmlInputField`-class
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @typedef {Object} ifcElementsDesc
|
|
124
|
+
* @property {HTMLElement} host - host element
|
|
125
|
+
* @property {HTMLElement} label - label element
|
|
126
|
+
* @property {HTMLElement} field - field element
|
|
127
|
+
* @description A description for input field elements set.
|
|
128
|
+
*/
|
|
129
|
+
|
|
98
130
|
/**
|
|
99
131
|
* @classdesc This class implements an interface of an input field element
|
|
100
132
|
*/
|
|
101
133
|
class THtmlInputField {
|
|
102
|
-
/** @
|
|
134
|
+
/** @type {?HTMLElement} */
|
|
103
135
|
#_host;// = null;
|
|
104
|
-
/** @
|
|
136
|
+
/** @type {?HTMLElement} */
|
|
105
137
|
#_label;// = null;
|
|
106
|
-
/** @
|
|
138
|
+
/** @type {?HTMLElement} */
|
|
107
139
|
#_field;// = null;
|
|
108
140
|
#_id = '';
|
|
109
141
|
#_value = '';
|
|
110
|
-
/** @
|
|
142
|
+
/** @type {OPT_ifcsett} */
|
|
111
143
|
#_options = null;
|
|
112
144
|
/**
|
|
113
145
|
* @typedef {Object} statIFCtrl
|
|
114
|
-
* @property {string} fldType
|
|
115
|
-
* @property {string} fldSubType
|
|
116
|
-
* @property {boolean} isReadOnly
|
|
117
|
-
* @property {boolean} isModified
|
|
146
|
+
* @property {string} fldType - field general type
|
|
147
|
+
* @property {string} fldSubType - field sub-type
|
|
148
|
+
* @property {boolean} isReadOnly - mode flag
|
|
149
|
+
* @property {boolean} isModified - indicates whether any changes was made
|
|
118
150
|
* @inner
|
|
119
151
|
* @description A controller status
|
|
120
152
|
*/
|
|
121
|
-
/** @
|
|
153
|
+
/** @type {statIFCtrl} */
|
|
122
154
|
#_status;// = null;
|
|
123
|
-
/** @
|
|
155
|
+
/** @type {Map<string, Function>} */
|
|
124
156
|
#_events;// = null;
|
|
125
157
|
|
|
126
|
-
/**
|
|
127
|
-
* @typedef {Object} ifcElementsDesc
|
|
128
|
-
* @property {HTMLElement} host - host element
|
|
129
|
-
* @property {HTMLElement} label - label element
|
|
130
|
-
* @property {HTMLElement} field - field element
|
|
131
|
-
* @description A description for input field elements set.
|
|
132
|
-
*/
|
|
133
|
-
|
|
134
158
|
/**
|
|
135
159
|
* @param {string} name - <*reserved*>
|
|
136
160
|
* @param {ifcElementsDesc} eholds - elements set
|
|
137
|
-
* @param {
|
|
138
|
-
* @param {string} [opt.idPref]
|
|
139
|
-
* @param {(string|string[])} [opt.baseClassID]
|
|
140
|
-
* @param {string} [opt.hint]
|
|
141
|
-
* @param {string} [opt.type]
|
|
142
|
-
* @param {boolean} [opt.readonly=true]
|
|
161
|
+
* @param {OPT_ifcsett} [opt] - options
|
|
143
162
|
* @description Creates an instance of an input field element
|
|
144
163
|
*/
|
|
145
164
|
constructor(name, eholds, opt) {
|
|
@@ -185,28 +204,28 @@ class THtmlInputField {
|
|
|
185
204
|
}
|
|
186
205
|
|
|
187
206
|
/**
|
|
188
|
-
*
|
|
207
|
+
* Indicates whether element value was modified.
|
|
208
|
+
* @type {boolean}
|
|
189
209
|
* @readonly
|
|
190
|
-
* @description Indicates whether element value was modified.
|
|
191
210
|
*/
|
|
192
211
|
get isModified() {
|
|
193
212
|
return this.#_status.isModified;
|
|
194
213
|
}
|
|
195
214
|
|
|
196
215
|
/**
|
|
216
|
+
* Returns an input element origin type.
|
|
197
217
|
* @since v0.0.23
|
|
198
|
-
* @
|
|
218
|
+
* @type {string}
|
|
199
219
|
* @readonly
|
|
200
|
-
* @description Returns an input element origin type.
|
|
201
220
|
*/
|
|
202
221
|
get type() {
|
|
203
222
|
return this.#_status.fldType;
|
|
204
223
|
}
|
|
205
224
|
|
|
206
225
|
/**
|
|
207
|
-
*
|
|
226
|
+
* Containes an element value.
|
|
227
|
+
* @type {string}
|
|
208
228
|
* @fires THtmlInputField#value-empty
|
|
209
|
-
* @description Containes an element value.
|
|
210
229
|
*/
|
|
211
230
|
get value() {
|
|
212
231
|
const field = this.#_field;
|
|
@@ -252,7 +271,7 @@ class THtmlInputField {
|
|
|
252
271
|
};
|
|
253
272
|
|
|
254
273
|
/**
|
|
255
|
-
* @param {object} e
|
|
274
|
+
* @param {object} e - event
|
|
256
275
|
* @returns {void}
|
|
257
276
|
* @private
|
|
258
277
|
* @fires THtmlInputField#value-changed
|
|
@@ -275,7 +294,7 @@ class THtmlInputField {
|
|
|
275
294
|
};
|
|
276
295
|
|
|
277
296
|
/**
|
|
278
|
-
* @param {object} e
|
|
297
|
+
* @param {object} e - event
|
|
279
298
|
* @returns {void}
|
|
280
299
|
* @private
|
|
281
300
|
* @fires THtmlInputField#value-empty
|
|
@@ -301,7 +320,7 @@ class THtmlInputField {
|
|
|
301
320
|
};
|
|
302
321
|
|
|
303
322
|
/**
|
|
304
|
-
* @param {object} e
|
|
323
|
+
* @param {object} e - event
|
|
305
324
|
* @returns {void}
|
|
306
325
|
* @private
|
|
307
326
|
*/
|
|
@@ -371,10 +390,10 @@ class THtmlInputField {
|
|
|
371
390
|
|
|
372
391
|
/**
|
|
373
392
|
* @param {string} name - <*reserved*>
|
|
374
|
-
* @param {
|
|
393
|
+
* @param {OPT_ifcdesc} opt - options
|
|
375
394
|
* @returns {?THtmlInputField}
|
|
376
395
|
* @static
|
|
377
|
-
* @description Creates a new
|
|
396
|
+
* @description Creates a new instance.
|
|
378
397
|
*/
|
|
379
398
|
static create(name, opt) {
|
|
380
399
|
const eholds = THtmlInputField.createElement(name, opt, true);
|
|
@@ -388,17 +407,8 @@ class THtmlInputField {
|
|
|
388
407
|
|
|
389
408
|
/**
|
|
390
409
|
* @param {string} name
|
|
391
|
-
* @param {
|
|
392
|
-
* @param {
|
|
393
|
-
* @param {string} [opt.idPref]
|
|
394
|
-
* @param {object} [opt.label]
|
|
395
|
-
* @param {object} [opt.labelPosition]
|
|
396
|
-
* @param {boolean} [opt.useDelim]
|
|
397
|
-
* @param {object} [opt.baseClassID]
|
|
398
|
-
* @param {string} [opt.hint]
|
|
399
|
-
* @param {object} [opt.type]
|
|
400
|
-
* @param {boolean} [opt.readonly]
|
|
401
|
-
* @param {boolean} [doRetChild=false]
|
|
410
|
+
* @param {OPT_ifcdesc} [opt] - options
|
|
411
|
+
* @param {boolean} [doRetChild=false] - mode flag
|
|
402
412
|
* @returns {(HTMLElement|ifcElementsDesc)}
|
|
403
413
|
* @static
|
|
404
414
|
* @description Creates a new elements.
|
|
@@ -407,6 +417,7 @@ class THtmlInputField {
|
|
|
407
417
|
const id = valueToIDString(name);
|
|
408
418
|
const _options = isPlainObject(opt) ? opt : {};
|
|
409
419
|
let fldSubType = '';
|
|
420
|
+
/** @type {OPT_ifcdesc} */
|
|
410
421
|
let {
|
|
411
422
|
host,
|
|
412
423
|
idPref,
|
|
@@ -430,18 +441,18 @@ class THtmlInputField {
|
|
|
430
441
|
bcidLabel = valueToClassList(bcidLabel);
|
|
431
442
|
bcidField = valueToClassList(bcidField);
|
|
432
443
|
idPref = valueToIDString(idPref);
|
|
433
|
-
hint = readAsString(hint, true);
|
|
444
|
+
hint = readAsString(hint, { useTrim: true });
|
|
434
445
|
({ type: fldType, subtype: fldSubType } = getInputFieldTypeDescr(fldType));
|
|
435
446
|
if (fldSubType === 'switch') bcidField.push('switch');
|
|
436
447
|
labelPosition = getLabelPositionID(labelPosition);
|
|
437
448
|
if (typeof useDelim !== 'boolean') useDelim = true;
|
|
438
|
-
label = readAsString(label, true);
|
|
449
|
+
label = readAsString(label, { useTrim: true });
|
|
439
450
|
if (label !== '') label = `${label}${useDelim ? ':' : ''}`;
|
|
440
451
|
isReadOnly = readAsBool(isReadOnly, true);
|
|
441
452
|
let fldID = idPref === '' ? id : `${idPref}-${id}`;
|
|
442
453
|
if (!isHTMLElement(host)) {
|
|
443
|
-
host =
|
|
444
|
-
|
|
454
|
+
host = createNewHTMLElement('div', {
|
|
455
|
+
classNames: bcidHost,
|
|
445
456
|
});
|
|
446
457
|
};
|
|
447
458
|
let lblHolder = null;
|
|
@@ -450,23 +461,23 @@ class THtmlInputField {
|
|
|
450
461
|
if (host) {
|
|
451
462
|
lblHolder = host.querySelector(`label[for="${fldID}"]`);
|
|
452
463
|
if (!lblHolder) {
|
|
453
|
-
lblHolder =
|
|
464
|
+
lblHolder = createNewHTMLElement('label', {
|
|
454
465
|
text: label,
|
|
455
466
|
attr: {
|
|
456
467
|
for: fldID,
|
|
457
468
|
},
|
|
458
|
-
|
|
469
|
+
classNames: bcidLabel,
|
|
459
470
|
});
|
|
460
471
|
};
|
|
461
472
|
fldHolder = host.querySelector(`input#${fldID}`);
|
|
462
473
|
if (!fldHolder) {
|
|
463
|
-
fldHolder =
|
|
474
|
+
fldHolder = createNewHTMLElement('input', {
|
|
464
475
|
id: fldID,
|
|
465
476
|
attr: {
|
|
466
477
|
type: fldType,
|
|
467
478
|
placeholder: hint,
|
|
468
479
|
},
|
|
469
|
-
|
|
480
|
+
classNames: bcidField,
|
|
470
481
|
});
|
|
471
482
|
};
|
|
472
483
|
if (fldHolder) {
|