@cntwg/html-helper 0.0.21 → 0.0.23
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 +22 -0
- package/README.md +8 -8
- package/doc/html-ctrls-btn.md +145 -104
- package/doc/html-ctrls-fields.md +104 -57
- package/doc/html-ctrls-list.md +570 -136
- package/doc/html-helper-lib.md +182 -48
- package/index.js +40 -15
- package/lib/event-hfunc.js +60 -0
- package/lib/html-ctrls/buttons.js +122 -101
- package/lib/html-ctrls/fields.js +126 -80
- package/lib/html-ctrls/list.js +254 -206
- package/lib/html-ctrls/lists-btn.js +44 -45
- package/lib/html-ctrls/lists-stubs.js +71 -71
- package/lib/html-ctrls/mod-hfunc.js +8 -38
- package/lib/html-helper-lib.js +227 -98
- package/package.json +5 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
#### *v0.0.23*
|
|
2
|
+
|
|
3
|
+
Pre-release version.
|
|
4
|
+
|
|
5
|
+
> - `html-helper-lib.md` updated;
|
|
6
|
+
> - `html-ctrls-list.md` updated;
|
|
7
|
+
> - `html-ctrls-btn.md` updated;
|
|
8
|
+
> - `html-ctrls-fields.md` updated;
|
|
9
|
+
> - added property `type` to `THtmlInputField` class;
|
|
10
|
+
> - change pattern for an element manipulation functions (*see docs for details*);
|
|
11
|
+
> - deprecate a `force` option in an `options` parameter of the `THtmlStubItemsSet` class constructor;
|
|
12
|
+
> - some other fixes.
|
|
13
|
+
|
|
14
|
+
#### *v0.0.22*
|
|
15
|
+
|
|
16
|
+
Pre-release version.
|
|
17
|
+
|
|
18
|
+
> - `html-helper-lib.md` updated;
|
|
19
|
+
> - add functions `valueToElementID` into `html-helper-lib.js` module;
|
|
20
|
+
> - improve behavior for `createNewHtmlElement` function.
|
|
21
|
+
|
|
1
22
|
#### *v0.0.21*
|
|
2
23
|
|
|
3
24
|
Pre-release version.
|
|
@@ -8,6 +29,7 @@ Pre-release version.
|
|
|
8
29
|
> - updated dependency on `@ygracs/bsfoc-lib-js` module to v0.2.1;
|
|
9
30
|
> - remove some deprecates (*see docs for details*);
|
|
10
31
|
> - change behavior for `loadItems` method of `THtmlStubItemsSet` class in handling `options` parameter (*see docs for details*);
|
|
32
|
+
> - add functions `readAsTagName` and `readAsAttrName` into `html-helper-lib.js` module;
|
|
11
33
|
> - added 'components' property for module exports;
|
|
12
34
|
> - some other fixes.
|
|
13
35
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
>|***rev.*:**|0.1.
|
|
1
|
+
>|***rev.*:**|0.1.7|
|
|
2
2
|
>|:---|---:|
|
|
3
|
-
>|date:|2024-
|
|
3
|
+
>|date:|2024-11-20|
|
|
4
4
|
|
|
5
5
|
## Introduction
|
|
6
6
|
|
|
@@ -16,20 +16,20 @@ This module contains the following components:
|
|
|
16
16
|
|
|
17
17
|
- classes for working with instances maintaining a buttons set support such as:
|
|
18
18
|
- `THtmlButtonsSet`,
|
|
19
|
-
|
|
20
|
-
- `THtmlButtonsControllerARCSet`.
|
|
19
|
+
- `THtmlButtonsControllerARCSet`.
|
|
21
20
|
|
|
22
21
|
> *For more details see `html-ctrls-btn.md` in module `doc` directory*.
|
|
23
22
|
|
|
24
23
|
- classes for working with instances maintaining a lists support such as:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
- `THtmlItemsListContainer`,
|
|
25
|
+
- `THtmlItemsListController`,
|
|
26
|
+
- `THtmlListButtonsController`,
|
|
27
|
+
- `THtmlStubItemsSet`.
|
|
28
28
|
|
|
29
29
|
> *For more details see `html-ctrls-list.md` in module `doc` directory*.
|
|
30
30
|
|
|
31
31
|
- classes for working with instances maintaining an input fields support such as:
|
|
32
|
-
|
|
32
|
+
- `THtmlInputField` (experimental, beta stage).
|
|
33
33
|
|
|
34
34
|
> *For more details see `html-ctrls-fields.md` in module `doc` directory*.
|
|
35
35
|
|
package/doc/html-ctrls-btn.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
>|***rev.*:**|0.1.
|
|
1
|
+
>|***rev.*:**|0.1.15|
|
|
2
2
|
>|:---|---:|
|
|
3
|
-
>|date:|2024-
|
|
3
|
+
>|date:|2024-11-15|
|
|
4
4
|
|
|
5
5
|
## Introduction
|
|
6
6
|
|
|
@@ -14,8 +14,20 @@ By module, constants that is provided listed in the following table:
|
|
|
14
14
|
|:---|---:|
|
|
15
15
|
|`BTS_DEF_GROUP_NAME`|'all'|
|
|
16
16
|
|
|
17
|
+
## Module functions
|
|
18
|
+
|
|
19
|
+
<a name="isHTMLButton"></a>
|
|
20
|
+
#### **isHTMLButton(obj)** => `boolean`
|
|
21
|
+
|
|
22
|
+
This function checks whether or not a given object represents an HTML-button element and if so returns `true` or `false` if else.
|
|
23
|
+
|
|
24
|
+
| parameter name | value type | default value | description |
|
|
25
|
+
|:---|---|---:|:---|
|
|
26
|
+
| `obj` | `any` | --- | some element to be checked |
|
|
27
|
+
|
|
17
28
|
## Module classes
|
|
18
29
|
|
|
30
|
+
<a name="THtmlButtonsSet"></a>
|
|
19
31
|
### **THtmlButtonsSet**
|
|
20
32
|
|
|
21
33
|
This class provide a manageable collection which used to group buttons placed on an HTML-form and controls those groups and all its members.
|
|
@@ -30,145 +42,164 @@ The class constructor receives no arguments.
|
|
|
30
42
|
|
|
31
43
|
#### class properties
|
|
32
44
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|property name|property type|read only|description|
|
|
36
|
-
|:---|---|---|:---|
|
|
37
|
-
|`ItemNames`|`array`|yes|contains a list of all buttons names|
|
|
38
|
-
|`GroupNames`|`array`|yes|contains a list of all buttons groups|
|
|
39
|
-
|
|
40
|
-
#### class methods
|
|
41
|
-
|
|
42
|
-
##### **hasItem(name)**
|
|
43
|
-
|
|
44
|
-
This method returns `true` if item named by `name` exist in the collection and `false` if else.
|
|
45
|
-
|
|
46
|
-
##### **addItem(name, item\[, groups])**
|
|
47
|
-
|
|
48
|
-
This method adds a "button" element given by `item` named by `name` to a set members and returns `true` if succeed. If `groups` is given the `item` will be added to a groups members listed by `groups` but only if such a group was already declared.
|
|
49
|
-
|
|
50
|
-
##### **addItemToGroup(name, args)**
|
|
51
|
-
|
|
52
|
-
This method adds an existing item addressed by 'name' to a members of a groups listed by 'args'. If succeed `true` is returned.
|
|
53
|
-
|
|
54
|
-
##### **delItem(name)**
|
|
55
|
-
|
|
56
|
-
This method deletes a "button" element named by `name` and returned `true` if succeed.
|
|
57
|
-
|
|
58
|
-
##### **delItemFromGroup(name, args)**
|
|
59
|
-
|
|
60
|
-
This method deletes an existing item addressed by 'name' from a members of a groups listed by 'args'. If succeed `true` is returned.
|
|
45
|
+
<a name="THtmlButtonsSet+ItemNames"></a>
|
|
46
|
+
##### **ItemNames**
|
|
61
47
|
|
|
62
|
-
|
|
48
|
+
| property type | read only | description |
|
|
49
|
+
|---|---|:---|
|
|
50
|
+
| `string[]` | yes | contains a list of all buttons names |
|
|
63
51
|
|
|
64
|
-
|
|
52
|
+
<a name="THtmlButtonsSet+GroupNames"></a>
|
|
53
|
+
##### **GroupNames**
|
|
65
54
|
|
|
66
|
-
|
|
55
|
+
| property type | read only | description |
|
|
56
|
+
|---|---|:---|
|
|
57
|
+
| `string[]` | yes | contains a list of all buttons groups |
|
|
67
58
|
|
|
68
|
-
|
|
59
|
+
#### class methods
|
|
69
60
|
|
|
70
|
-
|
|
61
|
+
<a name="THtmlButtonsSet+hasItem"></a>
|
|
62
|
+
##### **hasItem(name)** => `boolean`
|
|
71
63
|
|
|
72
|
-
This
|
|
64
|
+
This method returns `true` if item named by `name` exist in the collection and `false` if else.
|
|
73
65
|
|
|
74
|
-
|
|
66
|
+
| parameter name | value type | default value | description |
|
|
67
|
+
|:---|---|---:|:---|
|
|
68
|
+
| `name` | `string` | --- | an element name |
|
|
75
69
|
|
|
76
|
-
|
|
70
|
+
<a name="THtmlButtonsSet+addItem"></a>
|
|
71
|
+
##### **addItem(name, item\[, group_1\[, group_2\[, group_N]]])** => `boolean`
|
|
77
72
|
|
|
78
|
-
|
|
73
|
+
This method adds a "button" element given by `item` named by `name` to a set members and returns `true` if succeed. If any of a `group` is given the `item` will be added to that group if such was already declared.
|
|
79
74
|
|
|
80
|
-
|
|
75
|
+
| parameter name | value type | default value | description |
|
|
76
|
+
|:---|---|---:|:---|
|
|
77
|
+
| `name` | `string` | --- | an element name |
|
|
78
|
+
| `item` | `HTMLElement` | --- | an element |
|
|
79
|
+
| `group[1...N]` | `string` | --- | a group name |
|
|
81
80
|
|
|
82
|
-
|
|
81
|
+
<a name="THtmlButtonsSet+addItemToGroup"></a>
|
|
82
|
+
##### **addItemToGroup(name, group_1\[, group_2\[, group_N]])** => `boolean`
|
|
83
83
|
|
|
84
|
-
This method
|
|
84
|
+
This method adds an existing item addressed by `name` to a members of a groups received by a `group` parameters. If succeed `true` is returned.
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
| parameter name | value type | default value | description |
|
|
87
|
+
|:---|---|---:|:---|
|
|
88
|
+
| `name` | `string` | --- | an element name |
|
|
89
|
+
| `group[1...N]` | `string` | --- | a group name |
|
|
87
90
|
|
|
88
|
-
|
|
91
|
+
<a name="THtmlButtonsSet+delItem"></a>
|
|
92
|
+
##### **delItem(name)** => `boolean`
|
|
89
93
|
|
|
90
|
-
|
|
94
|
+
This method deletes a "button" element named by `name` and returned `true` if succeed.
|
|
91
95
|
|
|
92
|
-
|
|
96
|
+
| parameter name | value type | default value | description |
|
|
97
|
+
|:---|---|---:|:---|
|
|
98
|
+
| `name` | `string` | --- | an element name |
|
|
93
99
|
|
|
94
|
-
|
|
100
|
+
<a name="THtmlButtonsSet+delItemFromGroup"></a>
|
|
101
|
+
##### **delItemFromGroup(name, group_1\[, group_2\[, group_N]])** => `boolean`
|
|
95
102
|
|
|
96
|
-
This method
|
|
103
|
+
This method deletes an existing item addressed by `name` from a groups received by a `group` parameters. If succeed `true` is returned.
|
|
97
104
|
|
|
98
|
-
|
|
105
|
+
| parameter name | value type | default value | description |
|
|
106
|
+
|:---|---|---:|:---|
|
|
107
|
+
| `name` | `string` | --- | an element name |
|
|
108
|
+
| `group[1...N]` | `string` | --- | a group name |
|
|
99
109
|
|
|
100
|
-
|
|
110
|
+
<a name="THtmlButtonsSet+renameItem"></a>
|
|
111
|
+
##### **renameItem(name, value)** => `boolean`
|
|
101
112
|
|
|
102
|
-
This method
|
|
113
|
+
This method renames a "button" element addressed by `name` to its new name given by a `value` parameter.
|
|
103
114
|
|
|
104
|
-
|
|
115
|
+
| parameter name | value type | default value | description |
|
|
116
|
+
|:---|---|---:|:---|
|
|
117
|
+
| `name` | `string` | --- | an element name |
|
|
118
|
+
| `value` | `string` | --- | some new name for the element |
|
|
105
119
|
|
|
106
|
-
|
|
120
|
+
<a name="THtmlButtonsSet+enableItem"></a>
|
|
121
|
+
##### **enableItem(name)** => `void`
|
|
107
122
|
|
|
108
|
-
|
|
123
|
+
This methods activates a "button" element named by `name`.
|
|
109
124
|
|
|
110
|
-
|
|
125
|
+
| parameter name | value type | default value | description |
|
|
126
|
+
|:---|---|---:|:---|
|
|
127
|
+
| `name` | `string` | --- | an element name |
|
|
111
128
|
|
|
112
|
-
|
|
129
|
+
<a name="THtmlButtonsSet+disableItem"></a>
|
|
130
|
+
##### **disableItem(name)** => `void`
|
|
113
131
|
|
|
114
|
-
|
|
132
|
+
This methods inactivates a "button" element named by `name`.
|
|
115
133
|
|
|
116
|
-
|
|
|
134
|
+
| parameter name | value type | default value | description |
|
|
117
135
|
|:---|---|---:|:---|
|
|
118
|
-
|
|
119
|
-
|`btnPrev`|`HTMLElement`|---|define HTML-button which will select the previous element|
|
|
120
|
-
|`btnNext`|`HTMLElement`|---|define HTML-button which will select the next element|
|
|
121
|
-
|`btnLast`|`HTMLElement`|---|define HTML-button which will select the last element|
|
|
136
|
+
| `name` | `string` | --- | an element name |
|
|
122
137
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
This class has none.
|
|
138
|
+
<a name="THtmlButtonsSet+hasGroup"></a>
|
|
139
|
+
##### **hasGroup(name)** => `boolean`
|
|
126
140
|
|
|
127
|
-
|
|
141
|
+
This method returns `true` if an items group named by `name` exist in the collection and `false` if else.
|
|
128
142
|
|
|
129
|
-
|
|
143
|
+
| parameter name | value type | default value | description |
|
|
144
|
+
|:---|---|---:|:---|
|
|
145
|
+
| `name` | `string` | --- | a group name |
|
|
130
146
|
|
|
131
|
-
|
|
147
|
+
<a name="THtmlButtonsSet+addGroup"></a>
|
|
148
|
+
##### **addGroup(name)** => `boolean`
|
|
132
149
|
|
|
133
|
-
|
|
150
|
+
This method adds a group given by `name`. If succeed `true` is returned.
|
|
134
151
|
|
|
135
|
-
|
|
152
|
+
| parameter name | value type | default value | description |
|
|
153
|
+
|:---|---|---:|:---|
|
|
154
|
+
| `name` | `string` | --- | a group name |
|
|
136
155
|
|
|
137
|
-
|
|
156
|
+
<a name="THtmlButtonsSet+delGroup"></a>
|
|
157
|
+
##### **delGroup(name)** => `boolean`
|
|
138
158
|
|
|
139
|
-
This method
|
|
159
|
+
This method deletes the group given by `name`. If succeed `true` is returned.
|
|
140
160
|
|
|
141
|
-
|
|
161
|
+
| parameter name | value type | default value | description |
|
|
162
|
+
|:---|---|---:|:---|
|
|
163
|
+
| `name` | `string` | --- | a group name |
|
|
142
164
|
|
|
143
|
-
|
|
165
|
+
<a name="THtmlButtonsSet+renameGroup"></a>
|
|
166
|
+
##### **renameGroup(name, value)** => `boolean`
|
|
144
167
|
|
|
145
|
-
|
|
168
|
+
This method renames a group addressed by `name` to its new name given by a `value` parameter.
|
|
146
169
|
|
|
147
|
-
|
|
170
|
+
| parameter name | value type | default value | description |
|
|
171
|
+
|:---|---|---:|:---|
|
|
172
|
+
| `name` | `string` | --- | a group name |
|
|
173
|
+
| `value` | `string` | --- | some new name for the group |
|
|
148
174
|
|
|
149
|
-
|
|
175
|
+
<a name="THtmlButtonsSet+enableGroup"></a>
|
|
176
|
+
##### **enableGroup(name)** => `void`
|
|
150
177
|
|
|
151
|
-
This method
|
|
178
|
+
This method activates all "button" elements present in a group named by `name`.
|
|
152
179
|
|
|
153
|
-
|
|
180
|
+
| parameter name | value type | default value | description |
|
|
181
|
+
|:---|---|---:|:---|
|
|
182
|
+
| `name` | `string` | --- | a group name |
|
|
154
183
|
|
|
155
|
-
|
|
184
|
+
<a name="THtmlButtonsSet+disableGroup"></a>
|
|
185
|
+
##### **disableGroup(name)** => `void`
|
|
156
186
|
|
|
157
|
-
This method
|
|
187
|
+
This method inactivates all "button" elements present in a group named by `name`.
|
|
158
188
|
|
|
159
|
-
|
|
189
|
+
| parameter name | value type | default value | description |
|
|
190
|
+
|:---|---|---:|:---|
|
|
191
|
+
| `name` | `string` | --- | a group name |
|
|
160
192
|
|
|
161
|
-
#### class
|
|
193
|
+
#### class properties (*static*)
|
|
162
194
|
|
|
163
|
-
|
|
195
|
+
<a name="THtmlButtonsSet.isHTMLButton"></a>
|
|
196
|
+
##### **isHTMLButton**
|
|
164
197
|
|
|
165
|
-
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|`btn-prev-pressed`|fired if the `btnPrev` was pressed|
|
|
169
|
-
|`btn-next-pressed`|fired if the `btnNext` was pressed|
|
|
170
|
-
|`btn-last-pressed`|fired if the `btnLast` was pressed|
|
|
198
|
+
| property type | read only | description |
|
|
199
|
+
|---|---|:---|
|
|
200
|
+
| `function` | yes | contains a default function that verified validity of an element. The function receives element and returns result for validation as a `boolean`. |
|
|
171
201
|
|
|
202
|
+
<a name="THtmlButtonsControllerARCSet"></a>
|
|
172
203
|
### **THtmlButtonsControllerARCSet**
|
|
173
204
|
|
|
174
205
|
This class provide a buttons controller to use with a form components to performs apply/reject actions on a form data when editing.
|
|
@@ -181,11 +212,11 @@ The class constructor creates a new instance of the class.
|
|
|
181
212
|
|
|
182
213
|
The class constructor receives an `options` parameter which structure has listed below:
|
|
183
214
|
|
|
184
|
-
|option name|option type|default value|description|
|
|
215
|
+
| option name | option type | default value | description |
|
|
185
216
|
|:---|---|---:|:---|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
217
|
+
| `btnApply` | `HTMLElement` | --- | define HTML-button which will accept all changes |
|
|
218
|
+
| `btnReset` | `HTMLElement` | --- | define HTML-button that will require reset all changes to data if made |
|
|
219
|
+
| `btnCancel` | `HTMLElement` | --- | define HTML-button that will require reject all changes and close the form |
|
|
189
220
|
|
|
190
221
|
|
|
191
222
|
#### class properties
|
|
@@ -194,27 +225,37 @@ This class has none.
|
|
|
194
225
|
|
|
195
226
|
#### class methods
|
|
196
227
|
|
|
197
|
-
|
|
228
|
+
<a name="THtmlButtonsControllerARCSet+disableAll"></a>
|
|
229
|
+
##### **disableAll()** => `void`
|
|
198
230
|
|
|
199
231
|
This method disables all buttons that holds by the controller.
|
|
200
232
|
|
|
201
|
-
|
|
233
|
+
<a name="THtmlButtonsControllerARCSet+disableMain"></a>
|
|
234
|
+
##### **disableMain()** => `void`
|
|
202
235
|
|
|
203
236
|
This method disables all buttons in *'main'* group (*i.e. `btnApply` and `btnReset`*) that holds by the controller.
|
|
204
237
|
|
|
205
|
-
|
|
238
|
+
<a name="THtmlButtonsControllerARCSet+enableAll"></a>
|
|
239
|
+
##### **enableAll()** => `void`
|
|
206
240
|
|
|
207
241
|
This method enables all buttons that holds by the controller.
|
|
208
242
|
|
|
209
|
-
|
|
243
|
+
<a name="THtmlButtonsControllerARCSet+enableMain"></a>
|
|
244
|
+
##### **enableMain()** => `void`
|
|
210
245
|
|
|
211
246
|
This method enables all buttons in *'main'* group (*i.e. `btnApply` and `btnReset`*) that holds by the controller.
|
|
212
247
|
|
|
213
248
|
#### class methods (*special*)
|
|
214
249
|
|
|
215
|
-
|
|
250
|
+
<a name="THtmlButtonsControllerARCSet+on"></a>
|
|
251
|
+
##### **on(name, event)** => `void`
|
|
216
252
|
|
|
217
|
-
This method sets event handler addressed by `name` parameter
|
|
253
|
+
This method sets event handler addressed by a `name` parameter.
|
|
254
|
+
|
|
255
|
+
| parameter name | value type | default value | description |
|
|
256
|
+
|:---|---|---:|:---|
|
|
257
|
+
| `name` | `string` | --- | an event name |
|
|
258
|
+
| `event` | `function` | --- | a callback function |
|
|
218
259
|
|
|
219
260
|
> Note: for current implementation you can't reset or set new event handler (*especially another one*) if a handler with the same name exists already.
|
|
220
261
|
|
|
@@ -222,8 +263,8 @@ This method sets event handler addressed by `name` parameter for the class insta
|
|
|
222
263
|
|
|
223
264
|
The class generates the events listed in the table bellow:
|
|
224
265
|
|
|
225
|
-
|event name|description|
|
|
266
|
+
| event name | description |
|
|
226
267
|
|:---|:---|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
268
|
+
| `btn-apply-pressed` | fired if the `btnApply` was pressed |
|
|
269
|
+
| `btn-reset-pressed` | fired if the `btnReset` was pressed |
|
|
270
|
+
| `btn-cancel-pressed` | fired if the `btnCancel` was pressed |
|