@massimo-cassandro/minimo 1.7.2 → 1.8.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.
Files changed (118) hide show
  1. package/design-tokens/tokens/size.minimo.tokens.jsonc +16 -16
  2. package/index.js +3 -2
  3. package/package.json +1 -1
  4. package/src/components/TODO form-multiselect/form-multiselect.css +40 -0
  5. package/src/components/TODO form-multiselect/form-multiselect.js +83 -0
  6. package/src/components/TODO vanilla-cookie-consent/cookie-consent.css +20 -0
  7. package/src/components/TODO vanilla-cookie-consent/cookie-consent.js +76 -0
  8. package/src/components/TODO vanilla-cookie-consent/render-cookie-list.js +32 -0
  9. package/src/components/TODO vanilla-cookie-consent/src/cookie-list.js +85 -0
  10. package/src/components/TODO vanilla-cookie-consent/src/it-translation.js +38 -0
  11. package/src/components/TODO vanilla-cookie-consent/src/run-analytics.js +54 -0
  12. package/src/components/TODO vanilla-cookie-consent/src/run-recaptcha.js +71 -0
  13. package/src/components/modal-alert/TODO modal-alert-demo/demo.css +63 -0
  14. package/src/components/modal-alert/TODO modal-alert-demo/demo.js +155 -0
  15. package/src/components/slide-up-down-toggle/slide-up-down-toggle.js +237 -0
  16. package/src/components/slide-up-down-toggle/slide-up-down-toggle.module.css +97 -0
  17. package/src/components/unsplash-page/TODO unsplash-page-demo/README.md +194 -0
  18. package/src/components/unsplash-page/TODO unsplash-page-demo/changelog.md +5 -0
  19. package/src/components/unsplash-page/TODO unsplash-page-demo/unsplash-page/demo.js +15 -0
  20. package/src/components/unsplash-page/TODO unsplash-page-demo/unsplash-page/rollup.config.mjs +26 -0
  21. package/src/components/unsplash-page/TODO unsplash-page-demo/unsplash-page/unsplash-page-demo.min.js +3 -0
  22. package/src/web-components/TODO json-table/README.md +67 -0
  23. package/src/web-components/TODO json-table/TODO.md +12 -0
  24. package/src/web-components/TODO json-table/_work/OLD/docs/custom-props-list.md +69 -0
  25. package/src/web-components/TODO json-table/_work/OLD/script/create-css-custom-props-doc.mjs +113 -0
  26. package/src/web-components/TODO json-table/_work/OLD/script/src/custom-props-end.md +4 -0
  27. package/src/web-components/TODO json-table/_work/OLD/script/src/custom-props-start.md +30 -0
  28. package/src/web-components/TODO json-table/_work/OLD/src/css/icons.module.css +22 -0
  29. package/src/web-components/TODO json-table/_work/OLD/src/css/info.module.css +42 -0
  30. package/src/web-components/TODO json-table/_work/OLD/src/css/main-wrapper.module.css +4 -0
  31. package/src/web-components/TODO json-table/_work/OLD/src/css/table.module.css +154 -0
  32. package/src/web-components/TODO json-table/_work/OLD/src/css/utility.module.css +9 -0
  33. package/src/web-components/TODO json-table/_work/OLD/src/icons/false.svg +1 -0
  34. package/src/web-components/TODO json-table/_work/OLD/src/icons/search-arrows.svg +1 -0
  35. package/src/web-components/TODO json-table/_work/OLD/src/icons/true.svg +1 -0
  36. package/src/web-components/TODO json-table/_work/OLD/src/index.js +56 -0
  37. package/src/web-components/TODO json-table/_work/OLD/src/js/default-columns-data-types.js +172 -0
  38. package/src/web-components/TODO json-table/_work/OLD/src/js/defaults.js +156 -0
  39. package/src/web-components/TODO json-table/_work/OLD/src/js/info-section.js +31 -0
  40. package/src/web-components/TODO json-table/_work/OLD/src/js/listeners.js +17 -0
  41. package/src/web-components/TODO json-table/_work/OLD/src/js/main-builder.js +26 -0
  42. package/src/web-components/TODO json-table/_work/OLD/src/js/parse-params.js +121 -0
  43. package/src/web-components/TODO json-table/_work/OLD/src/js/set-column-classname.js +22 -0
  44. package/src/web-components/TODO json-table/_work/OLD/src/js/table-builder.js +64 -0
  45. package/src/web-components/TODO json-table/_work/OLD/src/js/table-foot.js +8 -0
  46. package/src/web-components/TODO json-table/_work/OLD/src/js/table-head.js +47 -0
  47. package/src/web-components/TODO json-table/_work/OLD/src/js/table-row.js +83 -0
  48. package/src/web-components/TODO json-table/_work/OLD/src/js/utilities.js +5 -0
  49. package/src/web-components/TODO json-table/_work/__json-table-react/index.js +4 -0
  50. package/src/web-components/TODO json-table/_work/__json-table-react/src/build-page-array.js +73 -0
  51. package/src/web-components/TODO json-table/_work/__json-table-react/src/columns-data-types.js +73 -0
  52. package/src/web-components/TODO json-table/_work/__json-table-react/src/defaults.js +50 -0
  53. package/src/web-components/TODO json-table/_work/__json-table-react/src/download-excel.js +156 -0
  54. package/src/web-components/TODO json-table/_work/__json-table-react/src/set-className.js +19 -0
  55. package/src/web-components/TODO json-table/_work/__json-table-react/src/set-download-filename.js +17 -0
  56. package/src/web-components/TODO json-table/_work/__json-table-react/src/table-to-csv.js +48 -0
  57. package/src/web-components/TODO json-table/_work/archived/table-to-csv.js +48 -0
  58. package/src/web-components/TODO json-table/_work/arrow.svg +3 -0
  59. package/src/web-components/TODO json-table/_work/da decidere/get-cell-data.js +18 -0
  60. package/src/web-components/TODO json-table/_work/download-button.js +29 -0
  61. package/src/web-components/TODO json-table/_work/download-excel.js +155 -0
  62. package/src/web-components/TODO json-table/_work/pagination-array-builder.js +73 -0
  63. package/src/web-components/TODO json-table/_work/pagination.js +37 -0
  64. package/src/web-components/TODO json-table/_work/set-download-filename.js +19 -0
  65. package/src/web-components/TODO json-table/_work/table-info.js +24 -0
  66. package/src/web-components/TODO json-table/demo/README.md +66 -0
  67. package/src/web-components/TODO json-table/demo/assets/link-simple.svg +1 -0
  68. package/src/web-components/TODO json-table/demo/demo-data/json-static-table-demo-data.js +512 -0
  69. package/src/web-components/TODO json-table/demo/demo.css +32 -0
  70. package/src/web-components/TODO json-table/demo/demo.js +24 -0
  71. package/src/web-components/TODO json-table/demo/js/demo-ajax-table.js +165 -0
  72. package/src/web-components/TODO json-table/demo/js/demo-static-table.js +180 -0
  73. package/src/web-components/TODO json-table/demo/webpack-modules/css-rules.mjs +122 -0
  74. package/src/web-components/TODO json-table/demo/webpack-modules/get-jsConfig-aliases.mjs +33 -0
  75. package/src/web-components/TODO json-table/demo/webpack-modules/svg-rules.mjs +108 -0
  76. package/src/web-components/TODO json-table/demo/webpack-modules/svgo.config.mjs +26 -0
  77. package/src/web-components/TODO json-table/demo/webpack.config.mjs +333 -0
  78. package/src/web-components/TODO json-table/docs/custom-props-list.md +74 -0
  79. package/src/web-components/TODO json-table/docs-builder/create-css-custom-props-doc.mjs +157 -0
  80. package/src/web-components/TODO json-table/docs-builder/src/custom-props-end.md +6 -0
  81. package/src/web-components/TODO json-table/docs-builder/src/custom-props-start.md +29 -0
  82. package/src/web-components/TODO json-table/src/TODO.md +1 -0
  83. package/src/web-components/TODO json-table/src/__json-table-react/build-page-array.js +73 -0
  84. package/src/web-components/TODO json-table/src/__json-table-react/columns-data-types.js +73 -0
  85. package/src/web-components/TODO json-table/src/__json-table-react/defaults.js +50 -0
  86. package/src/web-components/TODO json-table/src/__json-table-react/download-excel.js +156 -0
  87. package/src/web-components/TODO json-table/src/__json-table-react/set-className.js +19 -0
  88. package/src/web-components/TODO json-table/src/__json-table-react/set-download-filename.js +17 -0
  89. package/src/web-components/TODO json-table/src/__json-table-react/table-to-csv.js +48 -0
  90. package/src/web-components/TODO json-table/src/css/custom-media.css +16 -0
  91. package/src/web-components/TODO json-table/src/css/icons.module.css +22 -0
  92. package/src/web-components/TODO json-table/src/css/info-section.module.css +78 -0
  93. package/src/web-components/TODO json-table/src/css/main-builder.module.css +6 -0
  94. package/src/web-components/TODO json-table/src/css/table.module.css +172 -0
  95. package/src/web-components/TODO json-table/src/css/utility.module.css +9 -0
  96. package/src/web-components/TODO json-table/src/icons/arrow-down-bold.svg +1 -0
  97. package/src/web-components/TODO json-table/src/icons/false.svg +1 -0
  98. package/src/web-components/TODO json-table/src/icons/true.svg +1 -0
  99. package/src/web-components/TODO json-table/src/index.js +125 -0
  100. package/src/web-components/TODO json-table/src/js/default-columns-data-types.js +172 -0
  101. package/src/web-components/TODO json-table/src/js/defaults.js +510 -0
  102. package/src/web-components/TODO json-table/src/js/get-ajax-data.js +72 -0
  103. package/src/web-components/TODO json-table/src/js/info-section.js +39 -0
  104. package/src/web-components/TODO json-table/src/js/init-ajax-table.js +30 -0
  105. package/src/web-components/TODO json-table/src/js/init-static-table.js +18 -0
  106. package/src/web-components/TODO json-table/src/js/main-builder.js +87 -0
  107. package/src/web-components/TODO json-table/src/js/parse-data-row.js +123 -0
  108. package/src/web-components/TODO json-table/src/js/parse-params.js +118 -0
  109. package/src/web-components/TODO json-table/src/js/set-search-listener.js +62 -0
  110. package/src/web-components/TODO json-table/src/js/set-sort-listeners.js +115 -0
  111. package/src/web-components/TODO json-table/src/js/static-data-sorting.js +23 -0
  112. package/src/web-components/TODO json-table/src/js/table-builder.js +45 -0
  113. package/src/web-components/TODO json-table/src/js/table-row.js +43 -0
  114. package/src/web-components/TODO json-table/src/js/table-tfoot.js +9 -0
  115. package/src/web-components/TODO json-table/src/js/table-thead.js +91 -0
  116. package/src/web-components/TODO json-table/src/js/update-info.js +42 -0
  117. package/src/web-components/TODO json-table/src/js/utilities.js +5 -0
  118. package/src/web-components/s-datatable-component/s-datatable-component.js +14 -0
@@ -0,0 +1,15 @@
1
+ import { unsplashPageJS } from '../src/unsplash-page.js';
2
+
3
+ unsplashPageJS({
4
+ targetElement : document.getElementById('root'),
5
+ unsplashDataUrl : window.location.origin.match('localhost')!== null ?
6
+ 'http://localhost:8000/demo/demo-data.php' // local test
7
+ : 'https://primominuto.altervista.org/proxy/getUnsplashPhotos.php'
8
+ ,
9
+ utmSource : 'vanilla-js-test',
10
+ title : 'Message title',
11
+ text : 'This is the message <strong>text</strong>',
12
+ backLink : '<a href="https://github.com/massimo-cassandro/unsplash-page">Back to repository home</a>',
13
+ hidePhotoLink : true,
14
+ cssModulesObj : null
15
+ });
@@ -0,0 +1,26 @@
1
+ import terser from '@rollup/plugin-terser';
2
+ import node_resolve from '@rollup/plugin-node-resolve';
3
+ import image from '@rollup/plugin-image';
4
+
5
+ import p from '../package.json' assert { type: 'json' };
6
+
7
+ export default [
8
+ {
9
+ input: './demo/demo.js',
10
+ plugins: [
11
+ node_resolve(),
12
+ // commonjs(),
13
+ image(),
14
+ terser({ compress: { passes: 2 } }),
15
+ ],
16
+ output: [
17
+ {
18
+ file: './demo/unsplash-page-demo.min.js',
19
+ format: 'iife',
20
+ sourcemap: true,
21
+ banner: `/*! Unsplash Page v.${p.version} - Massimo Cassandro ${new Date().toLocaleString('en-EN', {
22
+ year: 'numeric', month: 'long', day: 'numeric' })} */`
23
+ }
24
+ ]
25
+ }
26
+ ];
@@ -0,0 +1,3 @@
1
+ /*! Unsplash Page v.2.0.2 - Massimo Cassandro May 1, 2024 */
2
+ !function(){"use strict";const t=[{name:"xxl",mq:"(min-width: 1400px)",w:1920,h:1080,dpr2:!1},{name:"xl",mq:"(min-width: 1200px) and (max-width: 1399px)",w:1400,h:788,dpr2:!1},{name:"lg",mq:"(min-width: 992px) and (max-width: 1199px)",w:1200,h:675,dpr2:!1},{name:"md",ar:"16/9",mq:"(min-width: 768px) and (max-width: 991px)",w:992,h:558,dpr2:!0},{name:"sm",ar:"16/9",mq:"(min-width: 576px) and (max-width: 767px)",w:768,h:432,dpr2:!0},{name:"xs-portrait",ar:"16/9",mq:"(orientation: portrait) and (max-width: 575px)",w:324,h:576,dpr2:!0},{name:"xs-landscape",ar:"16/9",mq:"(orientation: landscape) and (max-width: 575px)",w:576,h:324,dpr2:!0}];var e=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","#","$","%","*","+",",","-",".",":",";","=","?","@","[","]","^","_","{","|","}","~"],a=t=>{let a=0;for(let c=0;c<t.length;c++){let r=t[c];a=83*a+e.indexOf(r)}return a},c=t=>{let e=t/255;return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)},r=t=>{let e=Math.max(0,Math.min(1,t));return e<=.0031308?Math.trunc(12.92*e*255+.5):Math.trunc(255*(1.055*Math.pow(e,.4166666666666667)-.055)+.5)},n=(t,e)=>(t=>t<0?-1:1)(t)*Math.pow(Math.abs(t),e),s=class extends Error{constructor(t){super(t),this.name="ValidationError",this.message=t}},l=t=>{let e=t>>8&255,a=255&t;return[c(t>>16),c(e),c(a)]},o=(t,e)=>{let a=Math.floor(t/361),c=Math.floor(t/19)%19,r=t%19;return[n((a-9)/9,2)*e,n((c-9)/9,2)*e,n((r-9)/9,2)*e]};!function(e){const c=["targetElement","unsplashDataUrl","utmSource","title"];e={targetElement:null,className:null,unsplashDataUrl:null,utmSource:null,title:null,text:null,backLink:null,hidePhotoLink:!0,cssModulesObj:null,...e};try{if(c.map((t=>e[t])).filter((t=>null!==t&&""!==t)).length!==c.length)throw new Error(`I parametri ${c.map((t=>`\`${t}\``)).join(",")} sono obbligatori`);const n=t=>e.cssModulesObj?e.cssModulesObj[t]:t;e.targetElement.innerHTML=`<div class="${n("upContainer")+(e.className?` ${e.className}`:"")}"></div>`;const i=e.targetElement.querySelector("."+n("upContainer"));i.innerHTML=`<div class="${n("upLoaderWrapper")}"><div class="${n("upLoader")}"></div></div>`,async function(t){t={unsplash_data_url:null,...t};try{if(!t.unsplash_data_url)throw new Error("Unsplash data url must be defined");return await(async()=>{const e=await fetch(t.unsplash_data_url);if(!e.ok)throw console.error("Ajax error on: "+t.unsplash_data_url),console.error(e),new Error(`Loading error: ${e.status}`);return await e.json()})().then((t=>({id:t.id,color:t.color,width:t.width,height:t.height,alt_description:t.alt_description,date:t.created_at,base_url:t.urls.raw,unsplash_url:t.links.html,author:t.user.name??t.user.username,author_profile:t.user.links.html,blur_hash:t.blur_hash,image_description:(()=>{let e=t.location.name,a=t.description??t.alt_description;return t.description&&e&&(e=new RegExp(e,"i").test(a)?null:e),[a,e].filter((t=>null!=t)).join(" / ")})()})))}catch(t){console.error(t)}}({unsplash_data_url:e.unsplashDataUrl}).then((c=>{const h=((t,e,c,n)=>{(t=>{if(!t||t.length<6)throw new s("The blurhash string must be at least 6 characters");let e=a(t[0]),c=Math.floor(e/9)+1,r=e%9+1;if(t.length!==4+2*r*c)throw new s(`blurhash length mismatch: length is ${t.length} but it should be ${4+2*r*c}`)})(t),n|=1;let i=a(t[0]),h=Math.floor(i/9)+1,u=i%9+1,p=(a(t[1])+1)/166,d=new Array(u*h);for(let e=0;e<d.length;e++)if(0===e){let c=a(t.substring(2,6));d[e]=l(c)}else{let c=a(t.substring(4+2*e,6+2*e));d[e]=o(c,p*n)}let m=4*e,g=new Uint8ClampedArray(m*c);for(let t=0;t<c;t++)for(let a=0;a<e;a++){let n=0,s=0,l=0;for(let r=0;r<h;r++)for(let o=0;o<u;o++){let i=Math.cos(Math.PI*a*o/e)*Math.cos(Math.PI*t*r/c),h=d[o+r*u];n+=h[0]*i,s+=h[1]*i,l+=h[2]*i}let o=r(n),i=r(s),p=r(l);g[4*a+0+t*m]=o,g[4*a+1+t*m]=i,g[4*a+2+t*m]=p,g[4*a+3+t*m]=255}return g})(c.blur_hash,i.offsetWidth,i.offsetHeight),u=document.createElement("canvas");u.className=n("upCanvas"),u.width=i.offsetWidth,u.height=i.offsetHeight;const p=u.getContext("2d"),d=p.createImageData(i.offsetWidth,i.offsetHeight);d.data.set(h),p.putImageData(d,0,0),i.insertAdjacentElement("afterbegin",u);const m=["avif","webp","pjpg"];i.insertAdjacentHTML("beforeend","<picture>"+t.map(((e,a)=>{const r=a===t.length-1;return m.map((t=>{const a=t===m.at(-1);let s=c.base_url+(/\?/.test(c.base_url)?"&":"?")+"fit=crop&crop=focalpoint&q=60"+`&w=${e.w}&h=${e.h}`+`&fm=${t}`;return r&&a?`<img class="${n("unsplashPhoto")}" src="${s}" srcset="${s}${e.dpr2?` 1x, ${s}&dpr=2 2x`:""}" alt="${c.alt_description??`${c.author} / Unsplash`}" width="${e.w}" height="${e.h}">`:`<source srcset="${s}${e.dpr2?` 1x, ${s}&dpr=2 2x`:""}" `+(a?"":`type="image/${t}" `)+`media="${e.mq}" `+`width="${e.w}" height="${e.h}">`})).join("")})).join("")+"</picture>"),i.querySelector("."+n("unsplashPhoto")).onload=()=>{i.querySelector("."+n("upLoaderWrapper")).remove(),i.classList.add(n("show")),i.insertAdjacentHTML("beforeend",`<div class="${n("upMessageBox")}">\n <div class="${n("upMessage")}">\n <h1>${e.title}</h1>\n ${e.text?`<p>${e.text}</p>`:""}\n ${e.backLink?`<p class="${n("upBackLink")}">${e.backLink}</p>`:""}\n\n <div class="${n("upArrowWrapper")}" role="button">\n <img src="data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' fill='black' viewBox='0 0 256 256'%3e%3cpath d='M152%2c80v96H120v48L24%2c128l96-96V80Z' opacity='0.2'%3e%3c/path%3e%3cpath d='M152%2c72H128V32a8%2c8%2c0%2c0%2c0-13.66-5.66l-96%2c96a8%2c8%2c0%2c0%2c0%2c0%2c11.32l96%2c96A8%2c8%2c0%2c0%2c0%2c128%2c224V184h24a8%2c8%2c0%2c0%2c0%2c8-8V80A8%2c8%2c0%2c0%2c0%2c152%2c72Zm-8%2c96H120a8%2c8%2c0%2c0%2c0-8%2c8v28.69L35.31%2c128%2c112%2c51.31V80a8%2c8%2c0%2c0%2c0%2c8%2c8h24Zm80-88v96a8%2c8%2c0%2c0%2c1-16%2c0V80a8%2c8%2c0%2c0%2c1%2c16%2c0Zm-32%2c0v96a8%2c8%2c0%2c0%2c1-16%2c0V80a8%2c8%2c0%2c0%2c1%2c16%2c0Z'%3e%3c/path%3e%3c/svg%3e" alt="Icona freccia">\n </div>\n </div>\n\n <div class="${n("upCredits")}">\n <em>${c.image_description}</em>\n <span>Photo\n <a href="${c.author_profile}?utmSource=${e.utmSource}&utm_medium=referral">\n ${c.author} / Unsplash\n </a>\n </span>\n </div>\n </div>\n <div class="${n("unsplashPhotoLink")}${e.hidePhotoLink?` ${n("upShowOnHover")}`:""}">\n <a href="${c.unsplash_url}?utm_source=${e.utmSource}&utm_medium=referral" target="_blank" rel="noopener noreferrer">\n <img src="data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' fill='black' viewBox='0 0 256 256'%3e%3cpath d='M224%2c56V178.06l-39.72-39.72a8%2c8%2c0%2c0%2c0-11.31%2c0L147.31%2c164%2c97.66%2c114.34a8%2c8%2c0%2c0%2c0-11.32%2c0L32%2c168.69V56a8%2c8%2c0%2c0%2c1%2c8-8H216A8%2c8%2c0%2c0%2c1%2c224%2c56Z' opacity='0.2'%3e%3c/path%3e%3cpath d='M216%2c40H40A16%2c16%2c0%2c0%2c0%2c24%2c56V200a16%2c16%2c0%2c0%2c0%2c16%2c16H216a16%2c16%2c0%2c0%2c0%2c16-16V56A16%2c16%2c0%2c0%2c0%2c216%2c40Zm0%2c16V158.75l-26.07-26.06a16%2c16%2c0%2c0%2c0-22.63%2c0l-20%2c20-44-44a16%2c16%2c0%2c0%2c0-22.62%2c0L40%2c149.37V56ZM40%2c172l52-52%2c80%2c80H40Zm176%2c28H194.63l-36-36%2c20-20L216%2c181.38V200ZM144%2c100a12%2c12%2c0%2c1%2c1%2c12%2c12A12%2c12%2c0%2c0%2c1%2c144%2c100Z'%3e%3c/path%3e%3c/svg%3e" alt="Icona immagine" />\n </a>\n </div>`),i.querySelector("."+n("upArrowWrapper")).addEventListener("click",(t=>{t.target.closest(`.${n("upMessage")}`).classList.toggle(n("hidden"))}),!1)}}))}catch(t){console.error(t)}}({targetElement:document.getElementById("root"),unsplashDataUrl:null!==window.location.origin.match("localhost")?"http://localhost:8000/demo/demo-data.php":"https://primominuto.altervista.org/proxy/getUnsplashPhotos.php",utmSource:"vanilla-js-test",title:"Message title",text:"This is the message <strong>text</strong>",backLink:'<a href="https://github.com/massimo-cassandro/unsplash-page">Back to repository home</a>',hidePhotoLink:!0,cssModulesObj:null})}();
3
+ //# sourceMappingURL=unsplash-page-demo.min.js.map
@@ -0,0 +1,67 @@
1
+ # jsonTable
2
+
3
+ HTML table generator from Ajax or static JSON. It can also add advanced functionality to static tables.
4
+
5
+ > NB: **In this first version, the static json option is disabled**.
6
+
7
+ > NB: **This first release only provides the json-table source code, not the compiled version. To use ikson-tabble you'll need to process the code with your own bundler, which must be able to process SVG files and CSS modules (if you want to use the default css files).**.
8
+
9
+
10
+ It allows you to create a table from a JSON file or stream, adding some extra features: search, sorting, pagination, etc.
11
+
12
+ It's inspired by [jQuery Datatable](https://datatables.net/), but has far fewer features. However, it's much easier to use, highly customizable, and doesn't require jQuery.
13
+
14
+ In most cases, you simply need to modify the configuration parameters and CSS properties.
15
+
16
+ For more advanced customizations, you'll need to use the code in the `src` directory and customize the various CSS files.
17
+
18
+
19
+ [Changelog](changelog.txt).
20
+
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ npm i -D @massimo-cassandro/json-table
26
+ ```
27
+
28
+ ## Use
29
+
30
+ Create a *JsonTable*:
31
+
32
+ ```javascript
33
+ const jt = new JsonTable(table_params, optional_custom_data_types_obj);
34
+ ```
35
+
36
+ where: <!-- TODO --> TODO
37
+
38
+
39
+ ## Use with `data-*` attributes and automatic rendering
40
+
41
+ <!-- TODO --> TODO
42
+
43
+ ## Customizing CSS
44
+ You can customize the default CSS setting using custom properties; for more details, see [Custom CSS Properties List](docs/custom-props-list.md).
45
+
46
+ ## Generate elements params object
47
+ <!-- TODO --> TODO
48
+
49
+ ## Custom events
50
+
51
+ The library dispatches a custom event `jt:ready` on the table container when the instance is ready. The event `detail` property contains an object like `{ jsonTable: instance }`.
52
+
53
+ To make the event easier to catch, the library dispatches it asynchronously using `Promise.resolve().then(...)`. This schedules the dispatch in the microtask queue (that is, the callback runs after the current call stack finishes, but before the next macrotask). As a result, listeners registered immediately after calling `new JsonTable(...)` will still be able to intercept the event.
54
+
55
+ Example — register the listener before instantiation for maximum safety:
56
+
57
+ ```javascript
58
+ const container = document.getElementById('mytable');
59
+ container.addEventListener('jt:ready', e => { console.log(e.detail.jsonTable); });
60
+ new JsonTable({ container, ... });
61
+ ```
62
+
63
+
64
+ ## Limitations
65
+
66
+ * Only one `tr` element is allowed for `thead`
67
+
@@ -0,0 +1,12 @@
1
+ # json-table
2
+
3
+ ## core
4
+ * meccanismo acquisizione json per grandi quantità di records basato sulla paginazione
5
+ * opzione `condition` per renderizzare o meno una colonna (vedi opzione `hidden` di simple-datatable)
6
+ * in generale ogni elemento (cella) deve acceyyare contenuti in forma di stringa plain text, stringa html, elemento DOM, array domBuilder...
7
+ * possibilità di utilizzare un campo solo a fini di ricerca senza mostrarlo nella tabella
8
+ * possibilità di definire valori per ordinamento e ricerca diversi da quelli effettivamente presenti nel josn. Il default dovrebbe corrispondere a quanto mostrato
9
+
10
+ ## altro
11
+ * nei campi di tipo numerico prevedere classi di default text-end e text-numeric o classe ad hoc socrascrivibile
12
+ * footerRender: possibilità di funzioni predefinite per calcoli base (somma, media ecc) di una determinata colonna
@@ -0,0 +1,69 @@
1
+ # CSS Custom Properties List
2
+
3
+ List of all CSS custom properties used in css files.
4
+
5
+ If you don't want to use a new CSS, you can use the default one, just by customizing the values ​​of the custom properties.
6
+
7
+ You can set the custom values ​​in the `:root` element, or directly in the json-table wrapper by assigning it a specific class:
8
+
9
+ In the json-table config:
10
+
11
+ ```javascript
12
+ new jsonTable({
13
+ container: '...',
14
+ mainWrapperExtraClassName: 'my-custom-classname',
15
+
16
+ /* other config parameters */
17
+ });
18
+ ```
19
+
20
+ In your css:
21
+
22
+ ```css
23
+ .my-custom-classname {
24
+ --jt-search-input-bg-color: #efefef;
25
+ --jt-search-input-border-color: #666;
26
+
27
+ /* other custom properties */
28
+ }
29
+
30
+ ```
31
+
32
+
33
+ ## Properties
34
+ | Property | Default value | Description |
35
+ | :--- | :--- | :--- |
36
+ | `--jt-bool-false-color` | `#c00` | color for _false_ boolean values icon |
37
+ | `--jt-bool-icon-size` | `1.3em` | boolean icons size |
38
+ | `--jt-bool-true-color` | `#0a7202` | color for _true_ boolean values icon |
39
+ | `--jt-placeholder-color` | `#999` | color for placeholder text |
40
+ | `--jt-search-input-bg-color` | `transparent` | background color for search input element |
41
+ | `--jt-search-input-border-color` | `#999` | border color for search input element |
42
+ | `--jt-search-input-font-size` | `clamp(.85rem, 6vw, 1rem)` | font size for search input element |
43
+ | `--jt-search-input-padding-x` | `.75rem` | left and right padding for search input element |
44
+ | `--jt-search-input-padding-y` | `.375rem` | top and bottom padding for search input element |
45
+ | `--jt-search-input-text-color` | `currentColor` | text color for search input element |
46
+ | `--jt-table-border-color` | `#999` | table `border-color` |
47
+ | `--jt-table-border-style` | `solid` | table `border-style` |
48
+ | `--jt-table-border-width` | `1px` | table `border-width` |
49
+ | `--jt-table-caption-side` | `bottom` | table `caption-side` (`top` or `bottom`) |
50
+ | `--jt-table-cell-bg-color` | `#fff` | td `background-color` |
51
+ | `--jt-table-cell-border-color` | `#999` | td `border-color` |
52
+ | `--jt-table-cell-border-style` | `solid` | td `border-style` |
53
+ | `--jt-table-cell-border-width` | `1px` | td `border-width` |
54
+ | `--jt-table-cell-padding-x` | `.5rem` | left and right padding for td |
55
+ | `--jt-table-cell-padding-y` | `.5rem` | top and bottom padding for td |
56
+ | `--jt-table-cell-vertical-border-width` | `1px` | td `border-width` for vertical borders |
57
+ | `--jt-table-margin-block` | `1rem` | top and bottom margins for table |
58
+ | `--jt-table-tfoot-cell-bg-color` | `#f4f4f4` | background color for tfoot cells |
59
+ | `--jt-table-tfoot-cell-border-color` | `#666` | border color for tfoot cells (applied to the bottom border of the first tr of tfoot) |
60
+ | `--jt-table-tfoot-cell-border-width` | `3px` | border width for tfoot cells (applied to the bottom border of the first tr of tfoot) |
61
+ | `--jt-table-thead-cell-bg-color` | `#e4e4e4` | background color for thead cells |
62
+ | `--jt-table-thead-cell-border-color` | `#666` | border color for thead cells (applied to the bottom border of the last tr of thead) |
63
+ | `--jt-table-thead-cell-border-width` | `3px` | border width for thead cells (applied to the bottom border of the last tr of thead) |
64
+ | `--jt-wrapper-margin-block` | `1rem` | top and bottom margins for main wrapper element |
65
+
66
+ ## Notes
67
+ * `--jt-search-input-*`: you'll need that custom properties only if the `search`
68
+ parameter is set to `true` (default) and the `searchInputClassName`
69
+ (custom classname for search input, default `true`) parameter is not set.
@@ -0,0 +1,113 @@
1
+ #!/usr/bin/env node
2
+ /* eslint-disable no-console */
3
+
4
+ import * as fs from 'fs';
5
+ import * as path from 'path';
6
+ import { styleText } from 'node:util';
7
+
8
+ // parse all css files and extract all custom properties
9
+ // then create a markdown document adding a description for each property
10
+
11
+ // tke key is a camelCase version of the css property name (without leading --jt-)
12
+ const descriptions = {
13
+
14
+ boolFalseColor : 'color for _false_ boolean values icon',
15
+ boolIconSize : 'boolean icons size',
16
+ boolTrueColor : 'color for _true_ boolean values icon',
17
+ placeholderColor : 'color for placeholder text',
18
+ searchInputBgColor : 'background color for search input element',
19
+ searchInputBorderColor : 'border color for search input element',
20
+ searchInputFontSize : 'font size for search input element',
21
+ searchInputPaddingX : 'left and right padding for search input element',
22
+ searchInputPaddingY : 'top and bottom padding for search input element',
23
+ searchInputTextColor : 'text color for search input element',
24
+ tableBorderColor : 'table `border-color`',
25
+ tableBorderStyle : 'table `border-style`',
26
+ tableBorderWidth : 'table `border-width`',
27
+ tableCaptionSide : 'table `caption-side` (`top` or `bottom`)',
28
+ tableCellBgColor : 'td `background-color`',
29
+ tableCellBorderColor : 'td `border-color`',
30
+ tableCellBorderStyle : 'td `border-style`',
31
+ tableCellBorderWidth : 'td `border-width`',
32
+ tableCellPaddingX : 'left and right padding for td',
33
+ tableCellPaddingY : 'top and bottom padding for td',
34
+ tableCellVerticalBorderWidth : 'td `border-width` for vertical borders',
35
+ tableMarginBlock : 'top and bottom margins for table',
36
+ tableTfootCellBgColor : 'background color for tfoot cells',
37
+ tableTfootCellBorderColor : 'border color for tfoot cells (applied to the bottom border of the first tr of tfoot)',
38
+ tableTfootCellBorderWidth : 'border width for tfoot cells (applied to the bottom border of the first tr of tfoot)',
39
+ tableTheadCellBgColor : 'background color for thead cells',
40
+ tableTheadCellBorderColor : 'border color for thead cells (applied to the bottom border of the last tr of thead)',
41
+ tableTheadCellBorderWidth : 'border width for thead cells (applied to the bottom border of the last tr of thead)',
42
+ wrapperMarginBlock : 'top and bottom margins for main wrapper element',
43
+
44
+ };
45
+
46
+
47
+ const props = {},
48
+ css_folder = '../src/css',
49
+ target_file = path.resolve(new URL('.', import.meta.url).pathname, '../docs/custom-props-list.md'),
50
+ show_props_list = false // to create the descriptions
51
+ ;
52
+
53
+
54
+ try {
55
+
56
+ fs.readdirSync(css_folder).forEach(file => {
57
+ if(file.endsWith('.css')) {
58
+ const css_content = fs.readFileSync(path.join(css_folder, file), 'utf8'),
59
+ matches = css_content.matchAll(/var\(--jt-(?<name>(.*?))(?:, (?<def>(.*?))\)[ ;])/g);
60
+
61
+ for (const match of matches) {
62
+ if(match?.groups) {
63
+
64
+ if(props[match.groups.name]) {
65
+ if(props[match.groups.name].default !== match.groups.def) {
66
+ throw new Error( `Default values of the same property cannot be different (${match.groups.name})` );
67
+ }
68
+ props[match.groups.name].files.push(file);
69
+
70
+ } else {
71
+ props[match.groups.name] = {
72
+ files: [file],
73
+ default: match.groups.def
74
+ };
75
+ }
76
+
77
+ }
78
+ }
79
+ }
80
+ });
81
+
82
+ let descriptionsKeys = '';
83
+
84
+ const table = '## Properties\n' +
85
+ '| Property | Default value | Description |\n' +
86
+ '| :--- | :--- | :--- |\n' +
87
+ Object.keys(props).toSorted((a, b) => a.localeCompare(b)).map(key => {
88
+
89
+ const descrKey = key.replace(/-([a-z])/g, function (part) { return part[1].toUpperCase(); });
90
+
91
+ if(show_props_list) {
92
+ descriptionsKeys +=`${descrKey}: '${descriptions[descrKey]??''}',\n`;
93
+ }
94
+
95
+ return `| \`--jt-${key}\` | \`${props[key].default}\` | ${descriptions[descrKey] ?? ''} |`;
96
+ }).join('\n')
97
+ ;
98
+
99
+ const start_text = fs.readFileSync( './src/custom-props-start.md', 'utf8' ),
100
+ end_text = fs.readFileSync( './src/custom-props-end.md', 'utf8' );
101
+
102
+ fs.writeFileSync( target_file, start_text + '\n\n' + table + '\n\n' + end_text );
103
+
104
+ if(show_props_list) {
105
+ console.log('\n' +styleText(['yellow'], descriptionsKeys) + '\n'); // lista chiavi
106
+ }
107
+
108
+ console.log( '\n' + styleText(['bgGreen'], ' Done ' ) + '\n' );
109
+
110
+ } catch(e) {
111
+ let message = styleText('bgRed', ` ${e} `);
112
+ console.error( '\n' + message + '\n');
113
+ }
@@ -0,0 +1,4 @@
1
+ ## Notes
2
+ * `--jt-search-input-*`: you'll need that custom properties only if the `search`
3
+ parameter is set to `true` (default) and the `searchInputClassName`
4
+ (custom classname for search input, default `true`) parameter is not set.
@@ -0,0 +1,30 @@
1
+ # CSS Custom Properties List
2
+
3
+ List of all CSS custom properties used in css files.
4
+
5
+ If you don't want to use a new CSS, you can use the default one, just by customizing the values ​​of the custom properties.
6
+
7
+ You can set the custom values ​​in the `:root` element, or directly in the json-table wrapper by assigning it a specific class:
8
+
9
+ In the json-table config:
10
+
11
+ ```javascript
12
+ new jsonTable({
13
+ container: '...',
14
+ mainWrapperExtraClassName: 'my-custom-classname',
15
+
16
+ /* other config parameters */
17
+ });
18
+ ```
19
+
20
+ In your css:
21
+
22
+ ```css
23
+ .my-custom-classname {
24
+ --jt-search-input-bg-color: #efefef;
25
+ --jt-search-input-border-color: #666;
26
+
27
+ /* other custom properties */
28
+ }
29
+
30
+ ```
@@ -0,0 +1,22 @@
1
+ .icon { /* applied to the td */
2
+ text-align: center;
3
+
4
+ svg {
5
+ position: relative;
6
+ top: -3px;
7
+ width: var(--jt-bool-icon-size, 1.3em);
8
+ aspect-ratio: 1;
9
+ fill: none;
10
+ stroke: currentColor;
11
+ stroke-linecap: round;
12
+ stroke-linejoin: round;
13
+ stroke-width: 8px;
14
+ }
15
+
16
+ &.true {
17
+ color: var(--jt-bool-true-color, #0a7202);
18
+ }
19
+ &.false {
20
+ color: var(--jt-bool-false-color, #c00);
21
+ }
22
+ }
@@ -0,0 +1,42 @@
1
+ .info {
2
+ display: flex;
3
+ align-items: center;
4
+
5
+ }
6
+ .resultInfo {
7
+ flex: 1;
8
+ }
9
+ .search {
10
+ flex: 0 1 15rem;
11
+ }
12
+ .searchInput {
13
+ display: block;
14
+ width: 100%;
15
+ padding: var(--jt-search-input-padding-y, .375rem) var(--jt-search-input-padding-x, .75rem);
16
+ font-size: var(--jt-search-input-font-size, clamp(.85rem, 6vw, 1rem));
17
+ color: var(--jt-search-input-text-color, currentColor);
18
+ background-color: var(--jt-search-input-bg-color, transparent);
19
+ border: 1px solid var(--jt-search-input-border-color, #999);
20
+ border-radius: .4rem;
21
+
22
+ &:focus {
23
+ outline: 2px solid hsl(192deg 84% 63% / .7);
24
+ }
25
+ &::placeholder {
26
+ color: var(--jt-placeholder-color, #999);
27
+ opacity: 1;
28
+ }
29
+ &[disabled] {
30
+ opacity: .6;
31
+ &::placeholder {
32
+ font-style: italic;
33
+ }
34
+ }
35
+
36
+ /* @media (prefers-color-scheme: dark) {
37
+ border-color: var(--jt -search-input-border-color-dark, #ecede8);
38
+ &:focus {
39
+ outline-color: var(--green-2);
40
+ }
41
+ } */
42
+ }
@@ -0,0 +1,4 @@
1
+ .wrapper {
2
+ display: block;
3
+ margin-block: var(--jt-wrapper-margin-block, 1rem);
4
+ }
@@ -0,0 +1,154 @@
1
+ /* stylelint-disable selector-max-compound-selectors */
2
+ /* stylelint-disable max-nesting-depth */
3
+ .tableWrapper {
4
+ max-width: 100%;
5
+ overflow-x: auto;
6
+
7
+ /* TODO ombra su scroll vedi pannello staff e https://css-tricks.com/books/greatest-css-tricks/scroll-shadows/ */
8
+
9
+ }
10
+
11
+ .table {
12
+ width: 100%;
13
+ margin-block: var(--jt-table-margin-block, 1rem);
14
+ caption-side: var(--jt-table-caption-side, bottom);
15
+ border-spacing: 0;
16
+ border-collapse: collapse;
17
+ border-color: var(--jt-table-border-color, #999);
18
+ border-style: var(--jt-table-border-style, solid);
19
+ border-width: var(--jt-table-border-width, 1px);
20
+
21
+ caption {
22
+ padding-block: .2rem;
23
+ margin-block: 0;
24
+ }
25
+
26
+ th, td {
27
+ padding: var(--jt-table-cell-padding-y, .5rem) var(--jt-table-cell-padding-x, .5rem);
28
+ vertical-align: top;
29
+ background-color: var(--jt-table-cell-bg-color, #fff);
30
+ border-color: var(--jt-table-cell-border-color, #999);
31
+ border-style: var(--jt-table-cell-border-style, solid);
32
+ border-bottom-width: var(--jt-table-cell-border-width, 1px);
33
+
34
+ &:not(:last-child) {
35
+ border-right-width: var(--jt-table-cell-vertical-border-width, 1px);
36
+ }
37
+ }
38
+ thead {
39
+
40
+ th, td {
41
+ font-weight: 700;
42
+ vertical-align: bottom;
43
+ background-color: var(--jt-table-thead-cell-bg-color, #e4e4e4);
44
+ }
45
+
46
+ /* currently only one tr is expected for thead, but the pseudo class `:last-child`
47
+ is used anyway, for compatibility with any future developments */
48
+ tr:last-child {
49
+ th, td {
50
+ border-bottom-color: var(--jt-table-thead-cell-border-color, #666);
51
+ border-bottom-width: var(--jt-table-thead-cell-border-width, 4px);
52
+ }
53
+
54
+ th {
55
+ /* sort feature is available */
56
+ &.sort {
57
+ > div {
58
+ display: flex;
59
+ flex-flow: row nowrap;
60
+ gap: .5rem;
61
+ align-items: flex-end;
62
+ justify-content: space-between;
63
+ }
64
+ @media (hover: hover) { /* @media (any-hover: hover) { */
65
+ &:has(.sortArrows > span:hover) {
66
+ background-color: var(--jt-table-thead-sort-cell-hover, #ebb8b8);
67
+ }
68
+ }
69
+ }
70
+
71
+ /* sorting has been activated */
72
+ &.sortingOn {
73
+ border-bottom-color: var(--jt-table-sort-color, #c00);
74
+ }
75
+
76
+ /* sorting ASC activated */
77
+ &.sortingAsc {
78
+ .sortArrowUp {
79
+ color: var(--jt-table-sort-arrow-on, #c00);
80
+ }
81
+ }
82
+
83
+ /* sorting DESC activated */
84
+ &.sortingDesc {
85
+ color: blue;
86
+ }
87
+
88
+ }
89
+ }
90
+ }
91
+
92
+ /*
93
+ sticky headers don't work if table wrapper is present since it has overflow
94
+ so this feature is added only if table is not wrapped
95
+ */
96
+ &.stickyHeaders {
97
+ position: relative;
98
+ thead {
99
+ position: sticky;
100
+ top: 0;
101
+ z-index: 1;
102
+ }
103
+ }
104
+
105
+ tfoot {
106
+ th, td {
107
+ font-weight: 700;
108
+ background-color: var(--jt-table-tfoot-cell-bg-color, #f4f4f4);
109
+ }
110
+ tr:first-child {
111
+ th, td {
112
+ border-top-color: var(--jt-table-tfoot-cell-border-color, #666);
113
+ border-top-width: var(--jt-table-tfoot-cell-border-width, 3px);
114
+ }
115
+ }
116
+ }
117
+ }
118
+
119
+ /* sort arrows container */
120
+ .sortArrows {
121
+ display: flex;
122
+ flex: 0;
123
+ flex-flow: column nowrap;
124
+ gap: 4px;
125
+ align-items: center;
126
+ justify-content: center;
127
+ padding-block-end: .2em;
128
+ color: var(--jt-table-sort-arrow-off, #333);
129
+
130
+
131
+ > span {
132
+ flex: 0;
133
+ @media (hover: hover) { /* @media (any-hover: hover) { */
134
+ &:hover {
135
+ color: var(--jt-table-sort-arrow-hover, #c00);
136
+ }
137
+ }
138
+ }
139
+ svg {
140
+ display: block;
141
+ width: .5em;
142
+ aspect-ratio: 1;
143
+ cursor: pointer;
144
+ fill: currentColor;
145
+ }
146
+
147
+ }
148
+ /* inside `.sortArrows` element */
149
+ /* .sortArrowUp {} */
150
+ .sortArrowDn {
151
+ svg {
152
+ rotate: .5turn;
153
+ }
154
+ }
@@ -0,0 +1,9 @@
1
+ .centerAlign {
2
+ text-align: center;
3
+ }
4
+ .endAlign {
5
+ text-align: end;
6
+ }
7
+ .nowrap {
8
+ white-space: nowrap;
9
+ }
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 96 96" xmlns="http://www.w3.org/2000/svg"><path d="M48 84c19.882 0 36-16.118 36-36S67.882 12 48 12 12 28.118 12 48s16.118 36 36 36zm16-52L33 63m31 0L33 32"/></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 80 80" xmlns="http://www.w3.org/2000/svg"><path d="m39.9 0-39.9 80h80z"/></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 96 96" xmlns="http://www.w3.org/2000/svg"><path d="m64.5 39-22.013 21-10.987-10.5"/><path d="m48 84c19.8823 0 36-16.1177 36-36s-16.1177-36-36-36-36 16.1177-36 36 16.1177 36 36 36z"/></svg>
@@ -0,0 +1,56 @@
1
+ /**
2
+ * JsonTable
3
+ * build a table from a static or ajax-imported JSON object.
4
+ *
5
+ * @param {object} params - parametri di configurazione.
6
+ * @author Massimo Cassandro
7
+ */
8
+
9
+ import { parseParams } from './js/parse-params';
10
+ import { mainBuilder } from './js/main-builder';
11
+ import { infoSection } from './js/info-section';
12
+ import { tableBuilder } from './js/table-builder';
13
+ import { tableHead } from './js/table-head';
14
+ import { tableFoot } from './js/table-foot';
15
+ import { tableRow } from './js/table-row';
16
+ import { setColumClassname } from './js/set-column-classname';
17
+
18
+
19
+ class JsonTable {
20
+
21
+ constructor(custom_params, custom_data_types) {
22
+ this.params = parseParams({
23
+ custom_params: custom_params,
24
+ custom_data_types: custom_data_types,
25
+ });
26
+
27
+ if(this.params.debug) {
28
+ /* eslint-disable no-console */
29
+ console.groupCollapsed('JsonTable params');
30
+ console.log(this.params);
31
+ console.groupEnd();
32
+ /* eslint-enable no-console */
33
+ }
34
+
35
+
36
+ if(this.params.err) {
37
+ // eslint-disable-next-line no-console
38
+ console.error(this.params.err);
39
+
40
+ } else {
41
+ this.build();
42
+
43
+ }
44
+ }
45
+
46
+ }
47
+
48
+ JsonTable.prototype.build = mainBuilder;
49
+ JsonTable.prototype.infoSection = infoSection;
50
+ JsonTable.prototype.tableBuilder = tableBuilder;
51
+ JsonTable.prototype.tableHead = tableHead;
52
+ JsonTable.prototype.tableFoot = tableFoot;
53
+ JsonTable.prototype.tableRow = tableRow;
54
+ JsonTable.prototype.setColumClassname = setColumClassname;
55
+
56
+ export default JsonTable;