@cntwg/html-helper 0.0.22 → 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,4 +1,4 @@
1
- // [v0.1.033-20240714]
1
+ // [v0.1.036-20241110]
2
2
 
3
3
  // === module init block ===
4
4
 
@@ -28,8 +28,8 @@ const CSS_CLASS_HIDDEN = 'hidden';
28
28
 
29
29
  /**
30
30
  * @function isHTMLElement
31
- * @param {any}
32
- * @return {bool}
31
+ * @param {any} obj - some element
32
+ * @return {boolean}
33
33
  * @description Checks if the given object is an instance of an `HTMLElement`.
34
34
  */
35
35
  function isHTMLElement(obj) {
@@ -38,8 +38,8 @@ function isHTMLElement(obj) {
38
38
 
39
39
  /**
40
40
  * @function isSelectedHTMLElement
41
- * @param {HTMLElement}
42
- * @return {bool}
41
+ * @param {HTMLElement} obj - some element
42
+ * @return {boolean}
43
43
  * @description Checks if the given object is an instance of a `HTMLElement`
44
44
  * and if so it's marked as "selected".
45
45
  */
@@ -49,8 +49,8 @@ function isSelectedHTMLElement(obj) {
49
49
 
50
50
  /**
51
51
  * @function isCurrentHTMLElement
52
- * @param {HTMLElement}
53
- * @return {bool}
52
+ * @param {HTMLElement} obj - some element
53
+ * @return {boolean}
54
54
  * @description Checks if the given object is an instance of a `HTMLElement`
55
55
  * and if so it's marked as "current".
56
56
  */
@@ -60,8 +60,8 @@ function isCurrentHTMLElement(obj) {
60
60
 
61
61
  /**
62
62
  * @function isActiveHTMLElement
63
- * @param {HTMLElement}
64
- * @return {bool}
63
+ * @param {HTMLElement} obj - some element
64
+ * @return {boolean}
65
65
  * @description Checks if the given object is an instance of a `HTMLElement`
66
66
  * and if so it's marked as "active".
67
67
  */
@@ -71,8 +71,8 @@ function isActiveHTMLElement(obj) {
71
71
 
72
72
  /**
73
73
  * @function isHiddenHTMLElement
74
- * @param {HTMLElement}
75
- * @return {bool}
74
+ * @param {HTMLElement} obj - some element
75
+ * @return {boolean}
76
76
  * @description Checks if the given object is an instance of a `HTMLElement`
77
77
  * and if so it's marked as "hidden".
78
78
  */
@@ -81,109 +81,157 @@ function isHiddenHTMLElement(obj) {
81
81
  };
82
82
 
83
83
  /**
84
- * @function hideHtmlElement
85
- * @param {HTMLElement}
86
- * @return {bool}
84
+ * @since v0.0.23
85
+ * @function hideHTMLElement
86
+ * @param {HTMLElement} obj - some element
87
+ * @return {boolean}
87
88
  * @description Hides a given HTML-element.
88
89
  */
89
- function hideHtmlElement(obj) {
90
+ function hideHTMLElement(obj) {
90
91
  const isSUCCEED = isHTMLElement(obj);
91
92
  if (isSUCCEED) obj.classList.add(CSS_CLASS_HIDDEN);
92
93
  return isSUCCEED;
93
94
  };
94
95
 
96
+ /** @deprecated */
97
+ function hideHtmlElement(obj) {
98
+ return hideHTMLElement(obj);
99
+ };
100
+
95
101
  /**
96
- * @function showHtmlElement
97
- * @param {HTMLElement}
98
- * @return {bool}
102
+ * @since v0.0.23
103
+ * @function showHTMLElement
104
+ * @param {HTMLElement} obj - some element
105
+ * @return {boolean}
99
106
  * @description Shows a given HTML-element.
100
107
  */
101
- function showHtmlElement(obj) {
108
+ function showHTMLElement(obj) {
102
109
  const isSUCCEED = isHTMLElement(obj);
103
110
  if (isSUCCEED) obj.classList.remove(CSS_CLASS_HIDDEN);
104
111
  return isSUCCEED;
105
112
  };
106
113
 
114
+ /** @deprecated */
115
+ function showHtmlElement(obj) {
116
+ return showHTMLElement(obj);
117
+ };
118
+
107
119
  /**
108
- * @function selectHtmlElement
109
- * @param {HTMLElement}
110
- * @return {bool}
120
+ * @since v0.0.23
121
+ * @function selectHTMLElement
122
+ * @param {HTMLElement} obj - some element
123
+ * @return {boolean}
111
124
  * @description Makes selected a given HTML-element.
112
125
  */
113
- function selectHtmlElement(obj) {
126
+ function selectHTMLElement(obj) {
114
127
  const isSUCCEED = isHTMLElement(obj);
115
128
  if (isSUCCEED) obj.classList.add(CSS_CLASS_SELECTED);
116
129
  return isSUCCEED;
117
130
  };
118
131
 
132
+ /** @deprecated */
133
+ function selectHtmlElement(obj) {
134
+ return selectHTMLElement(obj);
135
+ };
136
+
119
137
  /**
120
- * @function unselectHtmlElement
121
- * @param {HTMLElement}
122
- * @return {bool}
138
+ * @since v0.0.23
139
+ * @function unselectHTMLElement
140
+ * @param {HTMLElement} obj - some element
141
+ * @return {boolean}
123
142
  * @description Makes unselected a given HTML-element.
124
143
  */
125
- function unselectHtmlElement(obj) {
144
+ function unselectHTMLElement(obj) {
126
145
  const isSUCCEED = isHTMLElement(obj);
127
146
  if (isSUCCEED) obj.classList.remove(CSS_CLASS_SELECTED);
128
147
  return isSUCCEED;
129
148
  };
130
149
 
150
+ /** @deprecated */
151
+ function unselectHtmlElement(obj) {
152
+ return unselectHTMLElement(obj);
153
+ };
154
+
131
155
  /**
132
- * @function markHtmlElementAsCurrent
133
- * @param {HTMLElement}
134
- * @return {bool} - `true` if succeed.
156
+ * @since v0.0.23
157
+ * @function markHTMLElementAsCurrent
158
+ * @param {HTMLElement} obj - some element
159
+ * @return {boolean} - `true` if succeed.
135
160
  * @description Marks a given HTML-element as "current".
136
161
  */
137
- function markHtmlElementAsCurrent(obj) {
162
+ function markHTMLElementAsCurrent(obj) {
138
163
  const isSUCCEED = isHTMLElement(obj);
139
164
  if (isSUCCEED) obj.classList.add(CSS_CLASS_CURRENT);
140
165
  return isSUCCEED;
141
166
  };
142
167
 
168
+ /** @deprecated */
169
+ function markHtmlElementAsCurrent(obj) {
170
+ return markHTMLElementAsCurrent(obj);
171
+ };
172
+
143
173
  /**
144
- * @function unmarkCurrentHtmlElement
145
- * @param {HTMLElement}
146
- * @return {bool}
174
+ * @since v0.0.23
175
+ * @function unmarkCurrentHTMLElement
176
+ * @param {HTMLElement} obj - some element
177
+ * @return {boolean}
147
178
  * @description Unmarks a given HTML-element previous marked as "current".
148
179
  */
149
- function unmarkCurrentHtmlElement(obj) {
180
+ function unmarkCurrentHTMLElement(obj) {
150
181
  const isSUCCEED = isHTMLElement(obj);
151
182
  if (isSUCCEED) obj.classList.remove(CSS_CLASS_CURRENT);
152
183
  return isSUCCEED;
153
184
  };
154
185
 
186
+ /** @deprecated */
187
+ function unmarkCurrentHtmlElement(obj) {
188
+ return unmarkCurrentHTMLElement(obj);
189
+ };
190
+
155
191
  /**
156
- * @function markHtmlElementAsActive
157
- * @param {HTMLElement}
158
- * @return {bool}
192
+ * @since v0.0.23
193
+ * @function markHTMLElementAsActive
194
+ * @param {HTMLElement} obj - some element
195
+ * @return {boolean}
159
196
  * @description Marks a given HTML-element as "active".
160
197
  */
161
- function markHtmlElementAsActive(obj) {
198
+ function markHTMLElementAsActive(obj) {
162
199
  const isSUCCEED = isHTMLElement(obj);
163
200
  if (isSUCCEED) obj.classList.add(CSS_CLASS_ACTIVE);
164
201
  return isSUCCEED;
165
202
  };
166
203
 
204
+ /** @deprecated */
205
+ function markHtmlElementAsActive(obj) {
206
+ return markHTMLElementAsActive(obj);
207
+ };
208
+
167
209
  /**
168
- * @function unmarkActiveHtmlElement
169
- * @param {HTMLElement}
170
- * @return {bool}
210
+ * @since v0.0.23
211
+ * @function unmarkActiveHTMLElement
212
+ * @param {HTMLElement} obj - some element
213
+ * @return {boolean}
171
214
  * @description Unmarks a given HTML-element previous marked as "active".
172
215
  */
173
- function unmarkActiveHtmlElement(obj) {
216
+ function unmarkActiveHTMLElement(obj) {
174
217
  const isSUCCEED = isHTMLElement(obj);
175
218
  if (isSUCCEED) obj.classList.remove(CSS_CLASS_ACTIVE);
176
219
  return isSUCCEED;
177
220
  };
178
221
 
222
+ /** @deprecated */
223
+ function unmarkActiveHtmlElement(obj) {
224
+ return unmarkActiveHTMLElement(obj);
225
+ };
226
+
179
227
  /**
180
- * @function lockHtmlElement
181
- * @param {HTMLElement}
182
- * @return {bool}
228
+ * @since v0.0.23
229
+ * @function lockHTMLElement
230
+ * @param {HTMLElement} obj - some element
231
+ * @return {boolean}
183
232
  * @description Disables a given HTML-element.
184
- * @since v0.0.19
185
233
  */
186
- function lockHtmlElement(obj) {
234
+ function lockHTMLElement(obj) {
187
235
  let isSUCCEED = isHTMLElement(obj);
188
236
  if (isSUCCEED) {
189
237
  const { classList, tagName } = obj;
@@ -202,14 +250,19 @@ function lockHtmlElement(obj) {
202
250
  return isSUCCEED;
203
251
  };
204
252
 
253
+ /** @deprecated */
254
+ function lockHtmlElement(obj) {
255
+ return lockHTMLElement(obj);
256
+ };
257
+
205
258
  /**
206
- * @function unlockHtmlElement
207
- * @param {HTMLElement}
208
- * @return {bool}
259
+ * @since v0.0.23
260
+ * @function unlockHTMLElement
261
+ * @param {HTMLElement} obj - some element
262
+ * @return {boolean}
209
263
  * @description Enables a given HTML-element.
210
- * @since v0.0.19
211
264
  */
212
- function unlockHtmlElement(obj) {
265
+ function unlockHTMLElement(obj) {
213
266
  let isSUCCEED = isHTMLElement(obj);
214
267
  if (isSUCCEED) {
215
268
  const { classList, tagName } = obj;
@@ -228,35 +281,52 @@ function unlockHtmlElement(obj) {
228
281
  return isSUCCEED;
229
282
  };
230
283
 
284
+ /** @deprecated */
285
+ function unlockHtmlElement(obj) {
286
+ return unlockHTMLElement(obj);
287
+ };
288
+
231
289
  /**
232
- * @function inactivateHtmlElements
233
- * @param {...HTMLElement}
234
- * @return {none}
235
- * @description Disables an HTML-elements given by a list of a function params.
290
+ * @since v0.0.23
291
+ * @function activateHTMLElements
292
+ * @param {...HTMLElement} obj - some element
293
+ * @return {void}
294
+ * @description Enables an HTML-elements given by a list of a function params.
236
295
  */
237
- function inactivateHtmlElements(...args) {
296
+ function activateHTMLElements(...args) {
238
297
  for (let item of args) {
239
- lockHtmlElement(item);
298
+ unlockHTMLElement(item);
240
299
  };
241
300
  };
242
301
 
302
+ /** @deprecated */
303
+ function activateHtmlElements(...args) {
304
+ activateHTMLElements(...args);
305
+ };
306
+
243
307
  /**
244
- * @function activateHtmlElements
245
- * @param {...HTMLElement}
246
- * @return {none}
247
- * @description Enables an HTML-elements given by a list of a function params.
308
+ * @since v0.0.23
309
+ * @function inactivateHTMLElements
310
+ * @param {...HTMLElement} obj - some element
311
+ * @return {void}
312
+ * @description Disables an HTML-elements given by a list of a function params.
248
313
  */
249
- function activateHtmlElements(...args) {
314
+ function inactivateHTMLElements(...args) {
250
315
  for (let item of args) {
251
- unlockHtmlElement(item);
316
+ lockHTMLElement(item);
252
317
  };
253
318
  };
254
319
 
320
+ /** @deprecated */
321
+ function inactivateHtmlElements(...args) {
322
+ inactivateHTMLElements(...args);
323
+ };
324
+
255
325
  /**
326
+ * @since v0.0.21
256
327
  * @function readAsTagName
257
- * @param {any}
328
+ * @param {any} value - some value
258
329
  * @return {string}
259
- * @since v0.0.21
260
330
  * @description Tries to convert a given value to a valid name of an HTML-tag.
261
331
  */
262
332
  function readAsTagName(value) {
@@ -276,10 +346,10 @@ function readAsTagName(value) {
276
346
  };
277
347
 
278
348
  /**
349
+ * @since v0.0.21
279
350
  * @function readAsAttrName
280
- * @param {any}
351
+ * @param {any} value - some value
281
352
  * @return {string}
282
- * @since v0.0.21
283
353
  * @description Tries to convert a given value to a valid name
284
354
  * of an HTML-attribute.
285
355
  */
@@ -299,10 +369,10 @@ function readAsAttrName(value) {
299
369
  };
300
370
 
301
371
  /**
372
+ * @since v0.0.18
302
373
  * @function readAsAttrValue
303
- * @param {any}
374
+ * @param {any} value - some value
304
375
  * @return {?string}
305
- * @since v0.0.18
306
376
  * @description Tries to convert a given value to a valid "attribute value".
307
377
  */
308
378
  function readAsAttrValue(value) {
@@ -329,11 +399,11 @@ function readAsAttrValue(value) {
329
399
  };
330
400
 
331
401
  /**
332
- * @function valueToClassList
333
- * @param {any}
334
- * @param {bool} [opt]
335
- * @return {array}
336
402
  * @since v0.0.13
403
+ * @function valueToClassList
404
+ * @param {any} value - some value
405
+ * @param {boolean} [opt] - flag that indicates whether a dups allowed
406
+ * @return {string[]}
337
407
  * @description Tries to convert a given value to a list of a valid
338
408
  * "class attributes".
339
409
  */
@@ -357,10 +427,10 @@ function valueToClassList(value, opt) {
357
427
  };
358
428
 
359
429
  /**
430
+ * @since v0.0.22
360
431
  * @function valueToElementID
361
- * @param {any}
432
+ * @param {any} value - some value
362
433
  * @return {string}
363
- * @since v0.0.22
364
434
  * @description Tries to convert a given value to a valid identifier
365
435
  * suitable as a value for an "ID-attribute" of an HTML-element.
366
436
  */
@@ -379,15 +449,20 @@ function valueToElementID(value) {
379
449
  return id;
380
450
  };
381
451
 
452
+ /**
453
+ * @typedef {Object} elemDesc
454
+ * @property {string} [id] - element ID
455
+ * @property {string} [text] - some text
456
+ * @property {object} [attr] - an attributes list
457
+ * @property {string|string[]} [classNames] - a class names list (added since v0.0.19)
458
+ * @property {object} [data] - a 'dataset'-attributes list
459
+ * @description An element description.
460
+ */
461
+
382
462
  /**
383
463
  * @function createNewHtmlElement
384
- * @param {string}
385
- * @param {object} [opt]
386
- * @param {string} [opt.id]
387
- * @param {string} [opt.text]
388
- * @param {object} [opt.attr]
389
- * @param {string|array} [opt.classNames] (added since v0.0.19),
390
- * @param {object} [opt.data]
464
+ * @param {string} tagName - an element tag name
465
+ * @param {elemDesc} [opt] - an element description object
391
466
  * @return {?HTMLElement}
392
467
  * @description Creates a new HTML-element.
393
468
  */
@@ -482,18 +557,19 @@ module.exports.isCurrentHTMLElement = isCurrentHTMLElement;
482
557
  module.exports.isSelectedHTMLElement = isSelectedHTMLElement;
483
558
  module.exports.isActiveHTMLElement = isActiveHTMLElement;
484
559
  module.exports.isHiddenHTMLElement = isHiddenHTMLElement;
485
- module.exports.showHtmlElement = showHtmlElement;
486
- module.exports.hideHtmlElement = hideHtmlElement;
487
- module.exports.selectHtmlElement = selectHtmlElement;
488
- module.exports.unselectHtmlElement = unselectHtmlElement;
489
- module.exports.markHtmlElementAsCurrent = markHtmlElementAsCurrent;
490
- module.exports.unmarkCurrentHtmlElement = unmarkCurrentHtmlElement;
491
- module.exports.markHtmlElementAsActive = markHtmlElementAsActive;
492
- module.exports.unmarkActiveHtmlElement = unmarkActiveHtmlElement;
493
- module.exports.lockHtmlElement = lockHtmlElement;
494
- module.exports.unlockHtmlElement = unlockHtmlElement;
495
- module.exports.activateHtmlElements = activateHtmlElements;
496
- module.exports.inactivateHtmlElements = inactivateHtmlElements;
560
+
561
+ module.exports.showHTMLElement = showHTMLElement;
562
+ module.exports.hideHTMLElement = hideHTMLElement;
563
+ module.exports.selectHTMLElement = selectHTMLElement;
564
+ module.exports.unselectHTMLElement = unselectHTMLElement;
565
+ module.exports.markHTMLElementAsCurrent = markHTMLElementAsCurrent;
566
+ module.exports.unmarkCurrentHTMLElement = unmarkCurrentHTMLElement;
567
+ module.exports.markHTMLElementAsActive = markHTMLElementAsActive;
568
+ module.exports.unmarkActiveHTMLElement = unmarkActiveHTMLElement;
569
+ module.exports.lockHTMLElement = lockHTMLElement;
570
+ module.exports.unlockHTMLElement = unlockHTMLElement;
571
+ module.exports.activateHTMLElements = activateHTMLElements;
572
+ module.exports.inactivateHTMLElements = inactivateHTMLElements;
497
573
 
498
574
  module.exports.valueToClassList = valueToClassList;
499
575
 
@@ -506,3 +582,17 @@ module.exports.valueToElementID = valueToElementID;
506
582
 
507
583
  // re-exported
508
584
  module.exports.valueToIDString = valueToIDString;
585
+
586
+ // @deprecated
587
+ module.exports.showHtmlElement = showHtmlElement;
588
+ module.exports.hideHtmlElement = hideHtmlElement;
589
+ module.exports.selectHtmlElement = selectHtmlElement;
590
+ module.exports.unselectHtmlElement = unselectHtmlElement;
591
+ module.exports.markHtmlElementAsCurrent = markHtmlElementAsCurrent;
592
+ module.exports.unmarkCurrentHtmlElement = unmarkCurrentHtmlElement;
593
+ module.exports.markHtmlElementAsActive = markHtmlElementAsActive;
594
+ module.exports.unmarkActiveHtmlElement = unmarkActiveHtmlElement;
595
+ module.exports.lockHtmlElement = lockHtmlElement;
596
+ module.exports.unlockHtmlElement = unlockHtmlElement;
597
+ module.exports.activateHtmlElements = activateHtmlElements;
598
+ module.exports.inactivateHtmlElements = inactivateHtmlElements;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntwg/html-helper",
3
- "version": "0.0.22",
3
+ "version": "0.0.23",
4
4
  "description": "A base HTML-helper library for js",
5
5
  "author": "ygracs <cs70th-om@rambler.ru>",
6
6
  "license": "MIT",
@@ -15,17 +15,15 @@
15
15
  ],
16
16
  "main": "./index.js",
17
17
  "files": [
18
- "doc/html-helper-lib.md",
19
- "doc/html-ctrls-list.md",
20
- "doc/html-ctrls-btn.md",
21
- "doc/html-ctrls-fields.md",
22
- "lib/html-helper-lib.js",
18
+ "doc/*.md",
23
19
  "lib/html-ctrls/lists-stubs.js",
24
20
  "lib/html-ctrls/lists-btn.js",
25
21
  "lib/html-ctrls/list.js",
26
22
  "lib/html-ctrls/buttons.js",
27
23
  "lib/html-ctrls/fields.js",
28
24
  "lib/html-ctrls/mod-hfunc.js",
25
+ "lib/html-helper-lib.js",
26
+ "lib/event-hfunc.js",
29
27
  "index.js",
30
28
  "CHANGELOG.md"
31
29
  ],
@@ -59,7 +57,7 @@
59
57
  "devDependencies": {
60
58
  "jest": "^29.7.0",
61
59
  "jest-environment-jsdom": "^29.7.0",
62
- "jsdoc-to-markdown": "^8.0.1",
60
+ "jsdoc-to-markdown": "^9.0.5",
63
61
  "minimist": "^1.2.8"
64
62
  }
65
63
  }