@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.
@@ -1,6 +1,6 @@
1
- >|***rev.*:**|0.0.5|
1
+ >|***rev.*:**|0.0.7|
2
2
  >|:---|---:|
3
- >|date:|2023-10-05|
3
+ >|date:|2024-11-20|
4
4
 
5
5
  ## Introduction
6
6
 
@@ -8,6 +8,7 @@ This paper describes a classes provided by `html-ctrls-fields.js` module.
8
8
 
9
9
  ## Module classes
10
10
 
11
+ <a name="THtmlInputField"></a>
11
12
  ### **THtmlInputField**
12
13
 
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.
@@ -20,129 +21,175 @@ The class constructor creates a new instance of the class.
20
21
 
21
22
  The class constructor receives a parameters listed below:
22
23
 
23
- |parameter name|value type|default value|description|
24
+ | parameter name | value type | default value | description |
24
25
  |:---|---|---:|:---|
25
- |`name`|`string`|---|\<*reserved*>|
26
- |`eholds`|`object`|---|contains ref-list for container elements|
27
- |`options`|`object`|---|contains a container settings|
26
+ | `name` | `string` | --- | \<*reserved*> |
27
+ | `eholds` | `object`| --- | contains ref-list for container elements |
28
+ | `options` | `object` | --- | contains a container settings |
28
29
 
29
30
  ##### `eholds` parameter
30
31
 
31
32
  The `eholds` structure has listed below:
32
33
 
33
- |parameter name|value type|default value|description|
34
+ | parameter name | value type | default value | description |
34
35
  |:---|---|---:|:---|
35
- |`host`|`HTMLElement`|---|points to a host element which holds all other items|
36
- |`label`|`HTMLElement`|---|points to a label item|
37
- |`field`|`HTMLElement`|---|points to a field item|
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 |
38
39
 
39
40
  ##### `options` parameter
40
41
 
41
42
  The `options` structure has listed below:
42
43
 
43
- |option name|value type|default value|description|
44
+ | option name | value type | default value | description |
44
45
  |:---|---|---:|:---|
45
- |`idPref`|---|---|\<*reserved*>|
46
- |`baseClassID`|---|---|\<*reserved*>|
47
- |`hint`|---|---|\<*reserved*>|
48
- |`fldType`|---|---|\<*reserved*>|
49
- |`isReadOnly`|---|---|\<*reserved*>|
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`*).
50
53
 
51
54
  #### class properties
52
55
 
53
- The table below describes a properties of a `THtmlInputField` class:
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`
54
66
 
55
- |property name|property type|read only|description|
56
- |:---|---|---|:---|
57
- |`value`|`string` or `boolean`|no|contains a container value|
58
- |`isModified`|`boolean`|yes|show whether or not the field content was modified|
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 |
59
77
 
60
78
  #### class methods
61
79
 
62
- ##### **clear()**
80
+ <a name="THtmlInputField+clear"></a>
81
+ ##### **clear()** => `void`
63
82
 
64
83
  > Note: \<*reserved*>
65
84
 
66
- ##### **isEmpty()**
85
+ <a name="THtmlInputField+isEmpty"></a>
86
+ ##### **isEmpty()** => `boolean`
67
87
 
68
88
  This method returns `true` if the container field element contains an empty string.
69
89
 
70
- ##### **isNotEmpty()**
90
+ <a name="THtmlInputField+isNotEmpty"></a>
91
+ ##### **isNotEmpty()** => `boolean`
71
92
 
72
93
  This method returns `true` if the container field element contains a non-empty string.
73
94
 
74
- ##### **hideItem()**
95
+ <a name="THtmlInputField+hide"></a>
96
+ ##### **hideItem()** => `void`
75
97
 
76
98
  This method hides a container on the Web-form.
77
99
 
78
- ##### **showItem()**
100
+ <a name="THtmlInputField+show"></a>
101
+ ##### **showItem()** => `void`
79
102
 
80
103
  This method shows a container on the Web-form.
81
104
 
82
- ##### **attachTo(target)**
105
+ <a name="THtmlInputField+attachTo"></a>
106
+ ##### **attachTo(target)** => `boolean`
83
107
 
84
108
  This method attaches a container to a parent HTML-element given by a `target` parameter. If succeed `true` returned.
85
109
 
110
+ | parameter name | value type | default value | description |
111
+ |:---|---|---:|:---|
112
+ | `target` | `HTMLElement` | --- | a target element |
113
+
86
114
  #### class methods (*static*)
87
115
 
88
- ##### **create(name\[, options])**
116
+ <a name="THtmlInputField.create"></a>
117
+ ##### **create(name\[, options])** => `?THtmlInputField`
89
118
 
90
119
  This method creates an instance of the class. If failed `null` returned.
91
120
 
92
- The `name` parameter represents an ID of the created container.
121
+ | parameter name | value type | default value | description |
122
+ |:---|---|---:|:---|
123
+ | `name` | `string` | --- | an ID of the created container |
124
+ | `options` | `object` | --- | an options |
93
125
 
94
126
  For details of `options` parameter see a `createElement` method description.
95
127
 
96
- ##### **createElement(name\[, options\[, bRetChild]])**
128
+ <a name="THtmlInputField.createElement"></a>
129
+ ##### **createElement(name\[, options\[, bRetChild]])** => `null|object|HTMLElement`
97
130
 
98
131
  This method creates a container with all elements needed for input field component to function.
99
132
 
100
- The `name` parameter represents an ID of the created container.
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 |
101
138
 
102
139
  The `options` structure has listed below:
103
140
 
104
- |option name|value type|default value|description|
141
+ | option name | value type | default value | description |
105
142
  |:---|---|---:|:---|
106
- |`host`|`HTMLElement`|---|an HTML-element which is a host for all container elements|
107
- |`idPref`|`string`|---|a prefix which modified a container ID, if given|
108
- |`label`|`string`|---|a text for the field label|
109
- |`labelPosition`|`string`|---|defines a position to place a label|
110
- |`useDelim`|`boolean`|`true`|defines whether a delimeter is used within a text of a label|
111
- |`baseClassID`|`object`|---|containes a list of class name attributes for container elements|
112
- |`hint`|`string`|---|defines a helper string which is shown when a field content is empty|
113
- |`fldType`|`string`|---|defines a field type|
114
- |`isReadOnly`|`boolean`|`true`|defines whether a field content can be modified|
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`*).
115
154
 
116
155
  The `baseClassID` structure has listed below:
117
156
 
118
- |option name|value type|default value|description|
157
+ | option name | value type | default value | description |
119
158
  |:---|---|---:|:---|
120
- |`main`|---|---|containes a list of class name attributes for all elements|
121
- |`host`|---|---|containes a list of class name attributes for container host|
122
- |`label`|---|---|containes a list of class name attributes for label element|
123
- |`field`|---|---|containes a list of class name attributes for field element|
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 |
124
163
 
125
- 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 behavoir). If `true`, an `object` of the following structure is returned:
164
+ The `fldType` option value can be: `text`, `field`, `checkbox`, `switch` or `default` (*the latter is the same as `field`*).
126
165
 
127
- |property name|value type|description|
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 |
128
169
  |:---|---|:---|
129
- |`host`|`HTMLElement`|a container host element|
130
- |`label`|`HTMLElement`|a container label element|
131
- |`field`|`HTMLElement`|a container field element|
170
+ | `host` | `HTMLElement` | a container host element |
171
+ | `label` | `HTMLElement` | a container label element |
172
+ | `field` | `HTMLElement` | a container field element |
132
173
 
133
174
  #### class methods (*special*)
134
175
 
135
- ##### **on(name, event)**
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.
136
180
 
137
- This method sets event handler addressed by `name` parameter for the class instance.
181
+ | parameter name | value type | default value | description |
182
+ |:---|---|---:|:---|
183
+ | `name` | `string` | --- | an event name |
184
+ | `event` | `function` | --- | a callback function |
138
185
 
139
- > 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.
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.
140
187
 
141
188
  #### class events
142
189
 
143
190
  The class generates the events listed in the table bellow:
144
191
 
145
- |event name|description|
192
+ | event name | description |
146
193
  |:---|:---|
147
- |`value-changed`|fired when value is changed|
148
- |`value-empty`|fired due editing of the field when its value become an empty string|
194
+ | `value-changed` | fired when value is changed |
195
+ | `value-empty` | fired due editing of the field when its value become an empty string |