@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 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.5|
1
+ >|***rev.*:**|0.1.7|
2
2
  >|:---|---:|
3
- >|date:|2024-07-13|
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
- - `THtmlListButtonsController`,
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
- - `THtmlItemsListContainer`,
26
- - `THtmlItemsListController`,
27
- - `THtmlStubItemsSet`.
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
- - `THtmlInputField` (experimental, beta stage).
32
+ - `THtmlInputField` (experimental, beta stage).
33
33
 
34
34
  > *For more details see `html-ctrls-fields.md` in module `doc` directory*.
35
35
 
@@ -1,6 +1,6 @@
1
- >|***rev.*:**|0.1.11|
1
+ >|***rev.*:**|0.1.15|
2
2
  >|:---|---:|
3
- >|date:|2024-07-13|
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
- The table below describes a properties of a `THtmlButtonsSet` class:
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
- ##### **renameItem(oldName, newName)**
48
+ | property type | read only | description |
49
+ |---|---|:---|
50
+ | `string[]` | yes | contains a list of all buttons names |
63
51
 
64
- This method renames a "button" element addressed by `oldName` to its `newName`.
52
+ <a name="THtmlButtonsSet+GroupNames"></a>
53
+ ##### **GroupNames**
65
54
 
66
- ##### **enableItem(name)**
55
+ | property type | read only | description |
56
+ |---|---|:---|
57
+ | `string[]` | yes | contains a list of all buttons groups |
67
58
 
68
- This methods activates a "button" element named by `name`.
59
+ #### class methods
69
60
 
70
- ##### **disableItem(name)**
61
+ <a name="THtmlButtonsSet+hasItem"></a>
62
+ ##### **hasItem(name)** => `boolean`
71
63
 
72
- This methods inactivates a "button" element named by `name`.
64
+ This method returns `true` if item named by `name` exist in the collection and `false` if else.
73
65
 
74
- ##### **hasGroup(name)**
66
+ | parameter name | value type | default value | description |
67
+ |:---|---|---:|:---|
68
+ | `name` | `string` | --- | an element name |
75
69
 
76
- This method returns `true` if an items group named by `name` exist in the collection and `false` if else.
70
+ <a name="THtmlButtonsSet+addItem"></a>
71
+ ##### **addItem(name, item\[, group_1\[, group_2\[, group_N]]])** => `boolean`
77
72
 
78
- ##### **addGroup(name)**
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
- This method adds a group given by `name`. If succeed `true` is returned.
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
- ##### **delGroup(name)**
81
+ <a name="THtmlButtonsSet+addItemToGroup"></a>
82
+ ##### **addItemToGroup(name, group_1\[, group_2\[, group_N]])** => `boolean`
83
83
 
84
- This method deletes the group given by `name`. If succeed `true` is returned.
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
- ##### **renameGroup(oldName, newName)**
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
- This method renames a group addressed by `oldName` to its `newName`.
91
+ <a name="THtmlButtonsSet+delItem"></a>
92
+ ##### **delItem(name)** => `boolean`
89
93
 
90
- ##### **enableGroup(name)**
94
+ This method deletes a "button" element named by `name` and returned `true` if succeed.
91
95
 
92
- This method activates all "button" elements present in a group named by `name`.
96
+ | parameter name | value type | default value | description |
97
+ |:---|---|---:|:---|
98
+ | `name` | `string` | --- | an element name |
93
99
 
94
- ##### **disableGroup(name)**
100
+ <a name="THtmlButtonsSet+delItemFromGroup"></a>
101
+ ##### **delItemFromGroup(name, group_1\[, group_2\[, group_N]])** => `boolean`
95
102
 
96
- This method inactivates all "button" elements present in a group named by `name`.
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
- #### class methods (*static*)
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
- ##### **isHTMLButton(object)**
110
+ <a name="THtmlButtonsSet+renameItem"></a>
111
+ ##### **renameItem(name, value)** => `boolean`
101
112
 
102
- This method checks if the given object represents a "button" element and if so `true` is returned.
113
+ This method renames a "button" element addressed by `name` to its new name given by a `value` parameter.
103
114
 
104
- ### **THtmlListButtonsController**
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
- This class provide a buttons controller to use with a list components to performs actions for list elements selection.
120
+ <a name="THtmlButtonsSet+enableItem"></a>
121
+ ##### **enableItem(name)** => `void`
107
122
 
108
- #### class constructor
123
+ This methods activates a "button" element named by `name`.
109
124
 
110
- The class constructor creates a new instance of the class.
125
+ | parameter name | value type | default value | description |
126
+ |:---|---|---:|:---|
127
+ | `name` | `string` | --- | an element name |
111
128
 
112
- ##### constructor parameters
129
+ <a name="THtmlButtonsSet+disableItem"></a>
130
+ ##### **disableItem(name)** => `void`
113
131
 
114
- The class constructor receives an `options` parameter which structure has listed below:
132
+ This methods inactivates a "button" element named by `name`.
115
133
 
116
- |option name|option type|default value|description|
134
+ | parameter name | value type | default value | description |
117
135
  |:---|---|---:|:---|
118
- |`btnFirst`|`HTMLElement`|---|define HTML-button which will select the first element|
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
- #### class properties
124
-
125
- This class has none.
138
+ <a name="THtmlButtonsSet+hasGroup"></a>
139
+ ##### **hasGroup(name)** => `boolean`
126
140
 
127
- #### class methods
141
+ This method returns `true` if an items group named by `name` exist in the collection and `false` if else.
128
142
 
129
- ##### **disableAll()**
143
+ | parameter name | value type | default value | description |
144
+ |:---|---|---:|:---|
145
+ | `name` | `string` | --- | a group name |
130
146
 
131
- This method disables all buttons that holds by the controller.
147
+ <a name="THtmlButtonsSet+addGroup"></a>
148
+ ##### **addGroup(name)** => `boolean`
132
149
 
133
- ##### **disableBkwd()**
150
+ This method adds a group given by `name`. If succeed `true` is returned.
134
151
 
135
- This method disables all buttons in *'move backward'* group (*i.e. `btnFirst` and `btnPrev`*) that holds by the controller.
152
+ | parameter name | value type | default value | description |
153
+ |:---|---|---:|:---|
154
+ | `name` | `string` | --- | a group name |
136
155
 
137
- ##### **disableFrwd()**
156
+ <a name="THtmlButtonsSet+delGroup"></a>
157
+ ##### **delGroup(name)** => `boolean`
138
158
 
139
- This method disables all buttons in *'move forward'* group (*i.e. `btnNext` and `btnLast`*) that holds by the controller.
159
+ This method deletes the group given by `name`. If succeed `true` is returned.
140
160
 
141
- ##### **enableAll()**
161
+ | parameter name | value type | default value | description |
162
+ |:---|---|---:|:---|
163
+ | `name` | `string` | --- | a group name |
142
164
 
143
- This method enables all buttons that holds by the controller.
165
+ <a name="THtmlButtonsSet+renameGroup"></a>
166
+ ##### **renameGroup(name, value)** => `boolean`
144
167
 
145
- ##### **enableBkwd()**
168
+ This method renames a group addressed by `name` to its new name given by a `value` parameter.
146
169
 
147
- This method enables all buttons in *'move backward'* group (*i.e. `btnFirst` and `btnPrev`*) that holds by the controller.
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
- ##### **enableFrwd()**
175
+ <a name="THtmlButtonsSet+enableGroup"></a>
176
+ ##### **enableGroup(name)** => `void`
150
177
 
151
- This method enables all buttons in *'move forward'* group (*i.e. `btnNext` and `btnLast`*) that holds by the controller.
178
+ This method activates all "button" elements present in a group named by `name`.
152
179
 
153
- #### class methods (*special*)
180
+ | parameter name | value type | default value | description |
181
+ |:---|---|---:|:---|
182
+ | `name` | `string` | --- | a group name |
154
183
 
155
- ##### **on(name, event)**
184
+ <a name="THtmlButtonsSet+disableGroup"></a>
185
+ ##### **disableGroup(name)** => `void`
156
186
 
157
- This method sets event handler addressed by `name` parameter for the class instance.
187
+ This method inactivates all "button" elements present in a group named by `name`.
158
188
 
159
- > 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.
189
+ | parameter name | value type | default value | description |
190
+ |:---|---|---:|:---|
191
+ | `name` | `string` | --- | a group name |
160
192
 
161
- #### class events
193
+ #### class properties (*static*)
162
194
 
163
- The class generates the events listed in the table bellow:
195
+ <a name="THtmlButtonsSet.isHTMLButton"></a>
196
+ ##### **isHTMLButton**
164
197
 
165
- |event name|description|
166
- |:---|:---|
167
- |`btn-first-pressed`|fired if the `btnFirst` was pressed|
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
- |`btnApply`|`HTMLElement`|---|define HTML-button which will accept all changes|
187
- |`btnReset`|`HTMLElement`|---|define HTML-button that will require reset all changes to data if made|
188
- |`btnCancel`|`HTMLElement`|---|define HTML-button that will require reject all changes and close the form|
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
- ##### **disableAll()**
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
- ##### **disableMain()**
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
- ##### **enableAll()**
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
- ##### **enableMain()**
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
- ##### **on(name, event)**
250
+ <a name="THtmlButtonsControllerARCSet+on"></a>
251
+ ##### **on(name, event)** => `void`
216
252
 
217
- This method sets event handler addressed by `name` parameter for the class instance.
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
- |`btn-apply-pressed`|fired if the `btnApply` was pressed|
228
- |`btn-reset-pressed`|fired if the `btnReset` was pressed|
229
- |`btn-cancel-pressed`|fired if the `btnCancel` was pressed|
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 |