@cntwg/html-helper 0.0.22 → 0.0.24

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.037-20250220]
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;
@@ -220,43 +273,58 @@ function unlockHtmlElement(obj) {
220
273
  obj.disabled = false;
221
274
  break;
222
275
  }
223
- default: {
224
- break;
225
- }
276
+ default: {}
226
277
  };
227
278
  };
228
279
  return isSUCCEED;
229
280
  };
230
281
 
282
+ /** @deprecated */
283
+ function unlockHtmlElement(obj) {
284
+ return unlockHTMLElement(obj);
285
+ };
286
+
231
287
  /**
232
- * @function inactivateHtmlElements
233
- * @param {...HTMLElement}
234
- * @return {none}
235
- * @description Disables an HTML-elements given by a list of a function params.
288
+ * @since v0.0.23
289
+ * @function activateHTMLElements
290
+ * @param {...HTMLElement} obj - some element
291
+ * @return {void}
292
+ * @description Enables an HTML-elements given by a list of a function params.
236
293
  */
237
- function inactivateHtmlElements(...args) {
294
+ function activateHTMLElements(...args) {
238
295
  for (let item of args) {
239
- lockHtmlElement(item);
296
+ unlockHTMLElement(item);
240
297
  };
241
298
  };
242
299
 
300
+ /** @deprecated */
301
+ function activateHtmlElements(...args) {
302
+ activateHTMLElements(...args);
303
+ };
304
+
243
305
  /**
244
- * @function activateHtmlElements
245
- * @param {...HTMLElement}
246
- * @return {none}
247
- * @description Enables an HTML-elements given by a list of a function params.
306
+ * @since v0.0.23
307
+ * @function inactivateHTMLElements
308
+ * @param {...HTMLElement} obj - some element
309
+ * @return {void}
310
+ * @description Disables an HTML-elements given by a list of a function params.
248
311
  */
249
- function activateHtmlElements(...args) {
312
+ function inactivateHTMLElements(...args) {
250
313
  for (let item of args) {
251
- unlockHtmlElement(item);
314
+ lockHTMLElement(item);
252
315
  };
253
316
  };
254
317
 
318
+ /** @deprecated */
319
+ function inactivateHtmlElements(...args) {
320
+ inactivateHTMLElements(...args);
321
+ };
322
+
255
323
  /**
324
+ * @since v0.0.21
256
325
  * @function readAsTagName
257
- * @param {any}
326
+ * @param {any} value - some value
258
327
  * @return {string}
259
- * @since v0.0.21
260
328
  * @description Tries to convert a given value to a valid name of an HTML-tag.
261
329
  */
262
330
  function readAsTagName(value) {
@@ -276,10 +344,10 @@ function readAsTagName(value) {
276
344
  };
277
345
 
278
346
  /**
347
+ * @since v0.0.21
279
348
  * @function readAsAttrName
280
- * @param {any}
349
+ * @param {any} value - some value
281
350
  * @return {string}
282
- * @since v0.0.21
283
351
  * @description Tries to convert a given value to a valid name
284
352
  * of an HTML-attribute.
285
353
  */
@@ -299,10 +367,10 @@ function readAsAttrName(value) {
299
367
  };
300
368
 
301
369
  /**
370
+ * @since v0.0.18
302
371
  * @function readAsAttrValue
303
- * @param {any}
372
+ * @param {any} value - some value
304
373
  * @return {?string}
305
- * @since v0.0.18
306
374
  * @description Tries to convert a given value to a valid "attribute value".
307
375
  */
308
376
  function readAsAttrValue(value) {
@@ -321,19 +389,17 @@ function readAsAttrValue(value) {
321
389
  result = value.trim();
322
390
  break;
323
391
  }
324
- default: {
325
- break;
326
- }
392
+ default: {}
327
393
  };
328
394
  return result;
329
395
  };
330
396
 
331
397
  /**
332
- * @function valueToClassList
333
- * @param {any}
334
- * @param {bool} [opt]
335
- * @return {array}
336
398
  * @since v0.0.13
399
+ * @function valueToClassList
400
+ * @param {any} value - some value
401
+ * @param {boolean} [opt] - flag that indicates whether a dups allowed
402
+ * @return {string[]}
337
403
  * @description Tries to convert a given value to a list of a valid
338
404
  * "class attributes".
339
405
  */
@@ -357,10 +423,10 @@ function valueToClassList(value, opt) {
357
423
  };
358
424
 
359
425
  /**
426
+ * @since v0.0.22
360
427
  * @function valueToElementID
361
- * @param {any}
428
+ * @param {any} value - some value
362
429
  * @return {string}
363
- * @since v0.0.22
364
430
  * @description Tries to convert a given value to a valid identifier
365
431
  * suitable as a value for an "ID-attribute" of an HTML-element.
366
432
  */
@@ -379,15 +445,20 @@ function valueToElementID(value) {
379
445
  return id;
380
446
  };
381
447
 
448
+ /**
449
+ * @typedef {Object} elemDesc
450
+ * @property {string} [id] - element ID
451
+ * @property {string} [text] - some text
452
+ * @property {object} [attr] - an attributes list
453
+ * @property {string|string[]} [classNames] - a class names list (added since v0.0.19)
454
+ * @property {object} [data] - a 'dataset'-attributes list
455
+ * @description An element description.
456
+ */
457
+
382
458
  /**
383
459
  * @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]
460
+ * @param {string} tagName - an element tag name
461
+ * @param {elemDesc} [opt] - an element description object
391
462
  * @return {?HTMLElement}
392
463
  * @description Creates a new HTML-element.
393
464
  */
@@ -482,18 +553,19 @@ module.exports.isCurrentHTMLElement = isCurrentHTMLElement;
482
553
  module.exports.isSelectedHTMLElement = isSelectedHTMLElement;
483
554
  module.exports.isActiveHTMLElement = isActiveHTMLElement;
484
555
  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;
556
+
557
+ module.exports.showHTMLElement = showHTMLElement;
558
+ module.exports.hideHTMLElement = hideHTMLElement;
559
+ module.exports.selectHTMLElement = selectHTMLElement;
560
+ module.exports.unselectHTMLElement = unselectHTMLElement;
561
+ module.exports.markHTMLElementAsCurrent = markHTMLElementAsCurrent;
562
+ module.exports.unmarkCurrentHTMLElement = unmarkCurrentHTMLElement;
563
+ module.exports.markHTMLElementAsActive = markHTMLElementAsActive;
564
+ module.exports.unmarkActiveHTMLElement = unmarkActiveHTMLElement;
565
+ module.exports.lockHTMLElement = lockHTMLElement;
566
+ module.exports.unlockHTMLElement = unlockHTMLElement;
567
+ module.exports.activateHTMLElements = activateHTMLElements;
568
+ module.exports.inactivateHTMLElements = inactivateHTMLElements;
497
569
 
498
570
  module.exports.valueToClassList = valueToClassList;
499
571
 
@@ -506,3 +578,17 @@ module.exports.valueToElementID = valueToElementID;
506
578
 
507
579
  // re-exported
508
580
  module.exports.valueToIDString = valueToIDString;
581
+
582
+ // @deprecated
583
+ module.exports.showHtmlElement = showHtmlElement;
584
+ module.exports.hideHtmlElement = hideHtmlElement;
585
+ module.exports.selectHtmlElement = selectHtmlElement;
586
+ module.exports.unselectHtmlElement = unselectHtmlElement;
587
+ module.exports.markHtmlElementAsCurrent = markHtmlElementAsCurrent;
588
+ module.exports.unmarkCurrentHtmlElement = unmarkCurrentHtmlElement;
589
+ module.exports.markHtmlElementAsActive = markHtmlElementAsActive;
590
+ module.exports.unmarkActiveHtmlElement = unmarkActiveHtmlElement;
591
+ module.exports.lockHtmlElement = lockHtmlElement;
592
+ module.exports.unlockHtmlElement = unlockHtmlElement;
593
+ module.exports.activateHtmlElements = activateHtmlElements;
594
+ 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.24",
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
  ],
@@ -54,12 +52,12 @@
54
52
  "#test-dir/*": "./__test__/*"
55
53
  },
56
54
  "dependencies": {
57
- "@ygracs/bsfoc-lib-js": "^0.2.1"
55
+ "@ygracs/bsfoc-lib-js": "^0.2.2"
58
56
  },
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.1.1",
63
61
  "minimist": "^1.2.8"
64
62
  }
65
63
  }