aprog 1.3.3 → 1.3.4

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/README.md CHANGED
@@ -147,7 +147,7 @@ onInput: (event) => {
147
147
  - *redirect(url, { newTab: bool, replace: bool }), reload(delaySeconds)*
148
148
  - *encrypt(str), decrypt(encryptedStr)*
149
149
 
150
- - *div, span, button, a, img, meta, label, input, select, option, options, form, hr, textarea, table, thead, tbody, tr, th, td, pre*
150
+ - *div, span, button, a, img, meta, label, input, select, option, options, form, hr, textarea, table, caption, thead, tbody, tr, th, td, pre*
151
151
  - *_get, GUID, apState, cookie, date, pause, apFetch, chars, elementToObject, copyText, scrollToTop, scrollToBottom, firstKey, checkArrays, ucfirst, deepEqual, nodeListToObject*
152
152
  - *isEmpty, isNull, isFloat, isNumeric, isObject, isArray, isNumber, isString, isPromise, isNull, isFloat, isNumeric, isObject*
153
153
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aprog",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "description": "Допоміжна бібліотека js",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/aprog.js CHANGED
@@ -894,6 +894,63 @@ export const table = (attributes = {}) => {
894
894
  }
895
895
 
896
896
 
897
+ export const caption = (attributes = {}) => {
898
+ let caption = document.createElement("caption");
899
+ if (attributes) {
900
+ Object.entries(attributes).forEach(([name, attrValue]) => {
901
+ if (name.startsWith('on') && typeof attrValue === 'function') {
902
+ const eventType = name.slice(2).toLowerCase();
903
+ caption.addEventListener(eventType, attrValue);
904
+ } else {
905
+ switch (name) {
906
+ case "top":
907
+ caption.style.captionSide = "top";
908
+ break;
909
+ case "bottom":
910
+ caption.style.captionSide = "bottom";
911
+ break;
912
+ case "class":
913
+ caption.className = String(attrValue);
914
+ break;
915
+ case "value":
916
+ if (isArray(attrValue)) {
917
+ attrValue.forEach((element) => {
918
+ isHtmlElement(element) ? caption.append(element) : caption.innerHTML = String(element)
919
+ })
920
+ } else {
921
+ isHtmlElement(attrValue) ? caption.append(attrValue) : caption.innerHTML = String(attrValue)
922
+ }
923
+ break;
924
+ case "style":
925
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
926
+ switch (styleName) {
927
+ case "zIndex":
928
+ caption.style[styleName] = `99999${styleValue}`;
929
+ break;
930
+ default:
931
+ caption.style[styleName] = styleValue;
932
+ break;
933
+ }
934
+ });
935
+ break;
936
+ default:
937
+ if (name.startsWith("data")) {
938
+ const kebabName = name
939
+ .replace(/^data/, "data")
940
+ .replace(/([A-Z])/g, "-$1")
941
+ .toLowerCase();
942
+ caption.setAttribute(kebabName, String(attrValue));
943
+ } else {
944
+ caption.setAttribute(name, String(attrValue));
945
+ }
946
+ }
947
+ }
948
+ });
949
+ }
950
+ return caption;
951
+ }
952
+
953
+
897
954
  export const thead = (attributes = {}) => {
898
955
  let thead = document.createElement("thead");
899
956
  if (attributes) {