@cntwg/html-helper 0.0.27 → 0.1.1

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.
@@ -1,263 +0,0 @@
1
- >|***rev.*:**|0.1.16|
2
- >|:---|---:|
3
- >|date:|2025-08-27|
4
-
5
- ## Introduction
6
-
7
- This paper describes a classes provided by `html-ctrls-btn.js` module.
8
-
9
- ## Module constants
10
-
11
- By module, constants that is provided listed in the following table:
12
-
13
- |name|value|
14
- |:---|---:|
15
- |`BTS_DEF_GROUP_NAME`|'all'|
16
-
17
- ## Module functions
18
-
19
- ## Module classes
20
-
21
- <a name="THtmlButtonsSet"></a>
22
- ### **THtmlButtonsSet**
23
-
24
- This class provide a manageable collection which used to group buttons placed on an HTML-form and controls those groups and all its members.
25
-
26
- #### class constructor
27
-
28
- The class constructor creates a new instance of the class.
29
-
30
- ##### constructor parameters
31
-
32
- The class constructor receives no arguments.
33
-
34
- #### class properties
35
-
36
- <a name="THtmlButtonsSet+ItemNames"></a>
37
- ##### **ItemNames**
38
-
39
- | property type | read only | description |
40
- |---|---|:---|
41
- | `string[]` | yes | contains a list of all buttons names |
42
-
43
- <a name="THtmlButtonsSet+GroupNames"></a>
44
- ##### **GroupNames**
45
-
46
- | property type | read only | description |
47
- |---|---|:---|
48
- | `string[]` | yes | contains a list of all buttons groups |
49
-
50
- #### class methods
51
-
52
- <a name="THtmlButtonsSet+hasItem"></a>
53
- ##### **hasItem(name)** => `boolean`
54
-
55
- This method returns `true` if item named by `name` exist in the collection and `false` if else.
56
-
57
- | parameter name | value type | default value | description |
58
- |:---|---|---:|:---|
59
- | `name` | `string` | --- | an element name |
60
-
61
- <a name="THtmlButtonsSet+addItem"></a>
62
- ##### **addItem(name, item\[, group_1\[, group_2\[, group_N]]])** => `boolean`
63
-
64
- 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.
65
-
66
- | parameter name | value type | default value | description |
67
- |:---|---|---:|:---|
68
- | `name` | `string` | --- | an element name |
69
- | `item` | `HTMLElement` | --- | an element |
70
- | `group[1...N]` | `string` | --- | a group name |
71
-
72
- <a name="THtmlButtonsSet+addItemToGroup"></a>
73
- ##### **addItemToGroup(name, group_1\[, group_2\[, group_N]])** => `boolean`
74
-
75
- 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.
76
-
77
- | parameter name | value type | default value | description |
78
- |:---|---|---:|:---|
79
- | `name` | `string` | --- | an element name |
80
- | `group[1...N]` | `string` | --- | a group name |
81
-
82
- <a name="THtmlButtonsSet+delItem"></a>
83
- ##### **delItem(name)** => `boolean`
84
-
85
- This method deletes a "button" element named by `name` and returned `true` if succeed.
86
-
87
- | parameter name | value type | default value | description |
88
- |:---|---|---:|:---|
89
- | `name` | `string` | --- | an element name |
90
-
91
- <a name="THtmlButtonsSet+delItemFromGroup"></a>
92
- ##### **delItemFromGroup(name, group_1\[, group_2\[, group_N]])** => `boolean`
93
-
94
- This method deletes an existing item addressed by `name` from a groups received by a `group` parameters. If succeed `true` is returned.
95
-
96
- | parameter name | value type | default value | description |
97
- |:---|---|---:|:---|
98
- | `name` | `string` | --- | an element name |
99
- | `group[1...N]` | `string` | --- | a group name |
100
-
101
- <a name="THtmlButtonsSet+renameItem"></a>
102
- ##### **renameItem(name, value)** => `boolean`
103
-
104
- This method renames a "button" element addressed by `name` to its new name given by a `value` parameter.
105
-
106
- | parameter name | value type | default value | description |
107
- |:---|---|---:|:---|
108
- | `name` | `string` | --- | an element name |
109
- | `value` | `string` | --- | some new name for the element |
110
-
111
- <a name="THtmlButtonsSet+enableItem"></a>
112
- ##### **enableItem(name)** => `void`
113
-
114
- This methods activates a "button" element named by `name`.
115
-
116
- | parameter name | value type | default value | description |
117
- |:---|---|---:|:---|
118
- | `name` | `string` | --- | an element name |
119
-
120
- <a name="THtmlButtonsSet+disableItem"></a>
121
- ##### **disableItem(name)** => `void`
122
-
123
- This methods inactivates a "button" element named by `name`.
124
-
125
- | parameter name | value type | default value | description |
126
- |:---|---|---:|:---|
127
- | `name` | `string` | --- | an element name |
128
-
129
- <a name="THtmlButtonsSet+hasGroup"></a>
130
- ##### **hasGroup(name)** => `boolean`
131
-
132
- This method returns `true` if an items group named by `name` exist in the collection and `false` if else.
133
-
134
- | parameter name | value type | default value | description |
135
- |:---|---|---:|:---|
136
- | `name` | `string` | --- | a group name |
137
-
138
- <a name="THtmlButtonsSet+addGroup"></a>
139
- ##### **addGroup(name)** => `boolean`
140
-
141
- This method adds a group given by `name`. If succeed `true` is returned.
142
-
143
- | parameter name | value type | default value | description |
144
- |:---|---|---:|:---|
145
- | `name` | `string` | --- | a group name |
146
-
147
- <a name="THtmlButtonsSet+delGroup"></a>
148
- ##### **delGroup(name)** => `boolean`
149
-
150
- This method deletes the group given by `name`. If succeed `true` is returned.
151
-
152
- | parameter name | value type | default value | description |
153
- |:---|---|---:|:---|
154
- | `name` | `string` | --- | a group name |
155
-
156
- <a name="THtmlButtonsSet+renameGroup"></a>
157
- ##### **renameGroup(name, value)** => `boolean`
158
-
159
- This method renames a group addressed by `name` to its new name given by a `value` parameter.
160
-
161
- | parameter name | value type | default value | description |
162
- |:---|---|---:|:---|
163
- | `name` | `string` | --- | a group name |
164
- | `value` | `string` | --- | some new name for the group |
165
-
166
- <a name="THtmlButtonsSet+enableGroup"></a>
167
- ##### **enableGroup(name)** => `void`
168
-
169
- This method activates all "button" elements present in a group named by `name`.
170
-
171
- | parameter name | value type | default value | description |
172
- |:---|---|---:|:---|
173
- | `name` | `string` | --- | a group name |
174
-
175
- <a name="THtmlButtonsSet+disableGroup"></a>
176
- ##### **disableGroup(name)** => `void`
177
-
178
- This method inactivates all "button" elements present in a group named by `name`.
179
-
180
- | parameter name | value type | default value | description |
181
- |:---|---|---:|:---|
182
- | `name` | `string` | --- | a group name |
183
-
184
- #### class properties (*static*)
185
-
186
- <a name="THtmlButtonsSet.isHTMLButton"></a>
187
- ##### **isHTMLButton**
188
-
189
- | property type | read only | description |
190
- |---|---|:---|
191
- | `function` | yes | contains a default function that verified validity of an element. The function receives element and returns result for validation as a `boolean`. |
192
-
193
- > For more details see [`isHTMLButton`](html-helper-lib.md#isHTMLButton).
194
-
195
- <a name="THtmlButtonsControllerARCSet"></a>
196
- ### **THtmlButtonsControllerARCSet**
197
-
198
- This class provide a buttons controller to use with a form components to performs apply/reject actions on a form data when editing.
199
-
200
- #### class constructor
201
-
202
- The class constructor creates a new instance of the class.
203
-
204
- ##### constructor parameters
205
-
206
- The class constructor receives an `options` parameter which structure has listed below:
207
-
208
- | option name | option type | default value | description |
209
- |:---|---|---:|:---|
210
- | `btnApply` | `HTMLElement` | --- | define HTML-button which will accept all changes |
211
- | `btnReset` | `HTMLElement` | --- | define HTML-button that will require reset all changes to data if made |
212
- | `btnCancel` | `HTMLElement` | --- | define HTML-button that will require reject all changes and close the form |
213
-
214
-
215
- #### class properties
216
-
217
- This class has none.
218
-
219
- #### class methods
220
-
221
- <a name="THtmlButtonsControllerARCSet+disableAll"></a>
222
- ##### **disableAll()** => `void`
223
-
224
- This method disables all buttons that holds by the controller.
225
-
226
- <a name="THtmlButtonsControllerARCSet+disableMain"></a>
227
- ##### **disableMain()** => `void`
228
-
229
- This method disables all buttons in *'main'* group (*i.e. `btnApply` and `btnReset`*) that holds by the controller.
230
-
231
- <a name="THtmlButtonsControllerARCSet+enableAll"></a>
232
- ##### **enableAll()** => `void`
233
-
234
- This method enables all buttons that holds by the controller.
235
-
236
- <a name="THtmlButtonsControllerARCSet+enableMain"></a>
237
- ##### **enableMain()** => `void`
238
-
239
- This method enables all buttons in *'main'* group (*i.e. `btnApply` and `btnReset`*) that holds by the controller.
240
-
241
- #### class methods (*special*)
242
-
243
- <a name="THtmlButtonsControllerARCSet+on"></a>
244
- ##### **on(name, event)** => `void`
245
-
246
- This method sets event handler addressed by a `name` parameter.
247
-
248
- | parameter name | value type | default value | description |
249
- |:---|---|---:|:---|
250
- | `name` | `string` | --- | an event name |
251
- | `event` | `function` | --- | a callback function |
252
-
253
- > 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.
254
-
255
- #### class events
256
-
257
- The class generates the events listed in the table bellow:
258
-
259
- | event name | description |
260
- |:---|:---|
261
- | `btn-apply-pressed` | fired if the `btnApply` was pressed |
262
- | `btn-reset-pressed` | fired if the `btnReset` was pressed |
263
- | `btn-cancel-pressed` | fired if the `btnCancel` was pressed |
@@ -1,195 +0,0 @@
1
- >|***rev.*:**|0.0.7|
2
- >|:---|---:|
3
- >|date:|2024-11-20|
4
-
5
- ## Introduction
6
-
7
- This paper describes a classes provided by `html-ctrls-fields.js` module.
8
-
9
- ## Module classes
10
-
11
- <a name="THtmlInputField"></a>
12
- ### **THtmlInputField**
13
-
14
- This class provide a container useful when dealing with an elements such an input fields or a checkboxes placed on an HTML-form.
15
-
16
- #### class constructor
17
-
18
- The class constructor creates a new instance of the class.
19
-
20
- ##### constructor parameters
21
-
22
- The class constructor receives a parameters listed below:
23
-
24
- | parameter name | value type | default value | description |
25
- |:---|---|---:|:---|
26
- | `name` | `string` | --- | \<*reserved*> |
27
- | `eholds` | `object`| --- | contains ref-list for container elements |
28
- | `options` | `object` | --- | contains a container settings |
29
-
30
- ##### `eholds` parameter
31
-
32
- The `eholds` structure has listed below:
33
-
34
- | parameter name | value type | default value | description |
35
- |:---|---|---:|:---|
36
- | `host` | `HTMLElement` | --- | points to a host element which holds all other items |
37
- | `label` | `HTMLElement` | --- | points to a label item |
38
- | `field` | `HTMLElement` | --- | points to a field item |
39
-
40
- ##### `options` parameter
41
-
42
- The `options` structure has listed below:
43
-
44
- | option name | value type | default value | description |
45
- |:---|---|---:|:---|
46
- | `idPref` | 'string' | --- | \<*reserved*> |
47
- | `baseClassID` | --- | --- | \<*reserved*> |
48
- | `hint` | `string` | --- | \<*reserved*> |
49
- | `fldType` | `string` | `default` | defines an input field type |
50
- | `isReadOnly` | `boolean` | `true` | defines whether an element value can be modified |
51
-
52
- The `fldType` option value can be: `text`, `field`, `checkbox`, `switch` or `default` (*the latter is the same as `field`*).
53
-
54
- #### class properties
55
-
56
- ##### **isModified**
57
-
58
- | property type | read only | description |
59
- |---|---|:---|
60
- | `boolean` | yes | shows whether or not the field content was modified |
61
-
62
- <a name="THtmlInputField+type"></a>
63
- ##### **type**
64
-
65
- > since: `v0.0.23`
66
-
67
- | property type | read only | description |
68
- |---|---|:---|
69
- | `string` | yes | contains a container type |
70
-
71
- <a name="THtmlInputField+value"></a>
72
- ##### **value**
73
-
74
- | property type | read only | description |
75
- |---|---|:---|
76
- | `string`, *`boolean`* | no | contains a container value |
77
-
78
- #### class methods
79
-
80
- <a name="THtmlInputField+clear"></a>
81
- ##### **clear()** => `void`
82
-
83
- > Note: \<*reserved*>
84
-
85
- <a name="THtmlInputField+isEmpty"></a>
86
- ##### **isEmpty()** => `boolean`
87
-
88
- This method returns `true` if the container field element contains an empty string.
89
-
90
- <a name="THtmlInputField+isNotEmpty"></a>
91
- ##### **isNotEmpty()** => `boolean`
92
-
93
- This method returns `true` if the container field element contains a non-empty string.
94
-
95
- <a name="THtmlInputField+hide"></a>
96
- ##### **hideItem()** => `void`
97
-
98
- This method hides a container on the Web-form.
99
-
100
- <a name="THtmlInputField+show"></a>
101
- ##### **showItem()** => `void`
102
-
103
- This method shows a container on the Web-form.
104
-
105
- <a name="THtmlInputField+attachTo"></a>
106
- ##### **attachTo(target)** => `boolean`
107
-
108
- This method attaches a container to a parent HTML-element given by a `target` parameter. If succeed `true` returned.
109
-
110
- | parameter name | value type | default value | description |
111
- |:---|---|---:|:---|
112
- | `target` | `HTMLElement` | --- | a target element |
113
-
114
- #### class methods (*static*)
115
-
116
- <a name="THtmlInputField.create"></a>
117
- ##### **create(name\[, options])** => `?THtmlInputField`
118
-
119
- This method creates an instance of the class. If failed `null` returned.
120
-
121
- | parameter name | value type | default value | description |
122
- |:---|---|---:|:---|
123
- | `name` | `string` | --- | an ID of the created container |
124
- | `options` | `object` | --- | an options |
125
-
126
- For details of `options` parameter see a `createElement` method description.
127
-
128
- <a name="THtmlInputField.createElement"></a>
129
- ##### **createElement(name\[, options\[, bRetChild]])** => `null|object|HTMLElement`
130
-
131
- This method creates a container with all elements needed for input field component to function.
132
-
133
- | parameter name | value type | default value | description |
134
- |:---|---|---:|:---|
135
- | `name` | `string` | --- | an ID of the created container |
136
- | `options` | `object` | --- | an options |
137
- | `bRetChild` | `boolean` | `false` | a flag to change a result value type |
138
-
139
- The `options` structure has listed below:
140
-
141
- | option name | value type | default value | description |
142
- |:---|---|---:|:---|
143
- | `host` | `HTMLElement`| --- | an HTML-element which is a host for all container elements |
144
- | `idPref` | `string` | --- | a prefix which modified a container ID, if given |
145
- | `label` | `string` | --- | a text for the field label |
146
- | `labelPosition` | `string` | --- | defines a position to place a label |
147
- | `useDelim` | `boolean` | `true` | defines whether a delimiter is used within a text of a label |
148
- | `baseClassID` | `object` | --- | contains a list of class name attributes for container elements |
149
- | `hint` | `string` | --- | defines a helper string which is shown when a field content is empty |
150
- | `fldType` | `string` | `default` | defines a field type |
151
- | `isReadOnly` | `boolean` | `true` | defines whether a field content can be modified |
152
-
153
- The `labelPosition` option value can be: `before`, `after` or `default` (*the latter is the same as `before`*).
154
-
155
- The `baseClassID` structure has listed below:
156
-
157
- | option name | value type | default value | description |
158
- |:---|---|---:|:---|
159
- | `main` | `string`, `string[]` | --- | contains a list of class name attributes for all elements |
160
- | `host` | `string`, `string[]` | --- | contains a list of class name attributes for container host |
161
- | `label` | `string`, `string[]` | --- | contains a list of class name attributes for label element |
162
- | `field` | `string`, `string[]` | --- | contains a list of class name attributes for field element |
163
-
164
- The `fldType` option value can be: `text`, `field`, `checkbox`, `switch` or `default` (*the latter is the same as `field`*).
165
-
166
- The `bRetChild` parameter, if given, changes the result value of the method. It must be of a `boolean` type. If value is `false` the only host element is returned as a result (a default behavior). If `true`, an `object` of the following structure is returned:
167
-
168
- | property name | value type | description |
169
- |:---|---|:---|
170
- | `host` | `HTMLElement` | a container host element |
171
- | `label` | `HTMLElement` | a container label element |
172
- | `field` | `HTMLElement` | a container field element |
173
-
174
- #### class methods (*special*)
175
-
176
- <a name="THtmlInputField+on"></a>
177
- ##### **on(name, event)** => `void`
178
-
179
- This method sets event handler for the list event addressed by a `name` parameter.
180
-
181
- | parameter name | value type | default value | description |
182
- |:---|---|---:|:---|
183
- | `name` | `string` | --- | an event name |
184
- | `event` | `function` | --- | a callback function |
185
-
186
- > 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.
187
-
188
- #### class events
189
-
190
- The class generates the events listed in the table bellow:
191
-
192
- | event name | description |
193
- |:---|:---|
194
- | `value-changed` | fired when value is changed |
195
- | `value-empty` | fired due editing of the field when its value become an empty string |