@massimo-cassandro/minimo 1.7.1 → 1.8.0
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/design-tokens/tokens/size.minimo.tokens.jsonc +16 -16
- package/index.js +4 -2
- package/package.json +1 -1
- package/src/components/TODO form-multiselect/form-multiselect.css +40 -0
- package/src/components/TODO form-multiselect/form-multiselect.js +83 -0
- package/src/components/TODO vanilla-cookie-consent/cookie-consent.css +20 -0
- package/src/components/TODO vanilla-cookie-consent/cookie-consent.js +76 -0
- package/src/components/TODO vanilla-cookie-consent/render-cookie-list.js +32 -0
- package/src/components/TODO vanilla-cookie-consent/src/cookie-list.js +85 -0
- package/src/components/TODO vanilla-cookie-consent/src/it-translation.js +38 -0
- package/src/components/TODO vanilla-cookie-consent/src/run-analytics.js +54 -0
- package/src/components/TODO vanilla-cookie-consent/src/run-recaptcha.js +71 -0
- package/src/components/modal-alert/TODO modal-alert-demo/demo.css +63 -0
- package/src/components/modal-alert/TODO modal-alert-demo/demo.js +155 -0
- package/src/components/modal-popup/modal-popup.js +2 -1
- package/src/components/slide-up-down-toggle/slide-up-down-toggle.js +246 -0
- package/src/components/slide-up-down-toggle/slide-up-down-toggle.module.css +97 -0
- package/src/components/snackbar/snackbar.js +2 -1
- package/src/components/spinner/spinner.js +2 -1
- package/src/components/unsplash-page/TODO unsplash-page-demo/README.md +194 -0
- package/src/components/unsplash-page/TODO unsplash-page-demo/changelog.md +5 -0
- package/src/components/unsplash-page/TODO unsplash-page-demo/unsplash-page/demo.js +15 -0
- package/src/components/unsplash-page/TODO unsplash-page-demo/unsplash-page/rollup.config.mjs +26 -0
- package/src/components/unsplash-page/TODO unsplash-page-demo/unsplash-page/unsplash-page-demo.min.js +3 -0
- package/src/utilities/generate-pwd.js +22 -0
- package/src/web-components/TODO json-table/README.md +67 -0
- package/src/web-components/TODO json-table/TODO.md +12 -0
- package/src/web-components/TODO json-table/_work/OLD/docs/custom-props-list.md +69 -0
- package/src/web-components/TODO json-table/_work/OLD/script/create-css-custom-props-doc.mjs +113 -0
- package/src/web-components/TODO json-table/_work/OLD/script/src/custom-props-end.md +4 -0
- package/src/web-components/TODO json-table/_work/OLD/script/src/custom-props-start.md +30 -0
- package/src/web-components/TODO json-table/_work/OLD/src/css/icons.module.css +22 -0
- package/src/web-components/TODO json-table/_work/OLD/src/css/info.module.css +42 -0
- package/src/web-components/TODO json-table/_work/OLD/src/css/main-wrapper.module.css +4 -0
- package/src/web-components/TODO json-table/_work/OLD/src/css/table.module.css +154 -0
- package/src/web-components/TODO json-table/_work/OLD/src/css/utility.module.css +9 -0
- package/src/web-components/TODO json-table/_work/OLD/src/icons/false.svg +1 -0
- package/src/web-components/TODO json-table/_work/OLD/src/icons/search-arrows.svg +1 -0
- package/src/web-components/TODO json-table/_work/OLD/src/icons/true.svg +1 -0
- package/src/web-components/TODO json-table/_work/OLD/src/index.js +56 -0
- package/src/web-components/TODO json-table/_work/OLD/src/js/default-columns-data-types.js +172 -0
- package/src/web-components/TODO json-table/_work/OLD/src/js/defaults.js +156 -0
- package/src/web-components/TODO json-table/_work/OLD/src/js/info-section.js +31 -0
- package/src/web-components/TODO json-table/_work/OLD/src/js/listeners.js +17 -0
- package/src/web-components/TODO json-table/_work/OLD/src/js/main-builder.js +26 -0
- package/src/web-components/TODO json-table/_work/OLD/src/js/parse-params.js +121 -0
- package/src/web-components/TODO json-table/_work/OLD/src/js/set-column-classname.js +22 -0
- package/src/web-components/TODO json-table/_work/OLD/src/js/table-builder.js +64 -0
- package/src/web-components/TODO json-table/_work/OLD/src/js/table-foot.js +8 -0
- package/src/web-components/TODO json-table/_work/OLD/src/js/table-head.js +47 -0
- package/src/web-components/TODO json-table/_work/OLD/src/js/table-row.js +83 -0
- package/src/web-components/TODO json-table/_work/OLD/src/js/utilities.js +5 -0
- package/src/web-components/TODO json-table/_work/__json-table-react/index.js +4 -0
- package/src/web-components/TODO json-table/_work/__json-table-react/src/build-page-array.js +73 -0
- package/src/web-components/TODO json-table/_work/__json-table-react/src/columns-data-types.js +73 -0
- package/src/web-components/TODO json-table/_work/__json-table-react/src/defaults.js +50 -0
- package/src/web-components/TODO json-table/_work/__json-table-react/src/download-excel.js +156 -0
- package/src/web-components/TODO json-table/_work/__json-table-react/src/set-className.js +19 -0
- package/src/web-components/TODO json-table/_work/__json-table-react/src/set-download-filename.js +17 -0
- package/src/web-components/TODO json-table/_work/__json-table-react/src/table-to-csv.js +48 -0
- package/src/web-components/TODO json-table/_work/archived/table-to-csv.js +48 -0
- package/src/web-components/TODO json-table/_work/arrow.svg +3 -0
- package/src/web-components/TODO json-table/_work/da decidere/get-cell-data.js +18 -0
- package/src/web-components/TODO json-table/_work/download-button.js +29 -0
- package/src/web-components/TODO json-table/_work/download-excel.js +155 -0
- package/src/web-components/TODO json-table/_work/pagination-array-builder.js +73 -0
- package/src/web-components/TODO json-table/_work/pagination.js +37 -0
- package/src/web-components/TODO json-table/_work/set-download-filename.js +19 -0
- package/src/web-components/TODO json-table/_work/table-info.js +24 -0
- package/src/web-components/TODO json-table/demo/README.md +66 -0
- package/src/web-components/TODO json-table/demo/assets/link-simple.svg +1 -0
- package/src/web-components/TODO json-table/demo/demo-data/json-static-table-demo-data.js +512 -0
- package/src/web-components/TODO json-table/demo/demo.css +32 -0
- package/src/web-components/TODO json-table/demo/demo.js +24 -0
- package/src/web-components/TODO json-table/demo/js/demo-ajax-table.js +165 -0
- package/src/web-components/TODO json-table/demo/js/demo-static-table.js +180 -0
- package/src/web-components/TODO json-table/demo/webpack-modules/css-rules.mjs +122 -0
- package/src/web-components/TODO json-table/demo/webpack-modules/get-jsConfig-aliases.mjs +33 -0
- package/src/web-components/TODO json-table/demo/webpack-modules/svg-rules.mjs +108 -0
- package/src/web-components/TODO json-table/demo/webpack-modules/svgo.config.mjs +26 -0
- package/src/web-components/TODO json-table/demo/webpack.config.mjs +333 -0
- package/src/web-components/TODO json-table/docs/custom-props-list.md +74 -0
- package/src/web-components/TODO json-table/docs-builder/create-css-custom-props-doc.mjs +157 -0
- package/src/web-components/TODO json-table/docs-builder/src/custom-props-end.md +6 -0
- package/src/web-components/TODO json-table/docs-builder/src/custom-props-start.md +29 -0
- package/src/web-components/TODO json-table/src/TODO.md +1 -0
- package/src/web-components/TODO json-table/src/__json-table-react/build-page-array.js +73 -0
- package/src/web-components/TODO json-table/src/__json-table-react/columns-data-types.js +73 -0
- package/src/web-components/TODO json-table/src/__json-table-react/defaults.js +50 -0
- package/src/web-components/TODO json-table/src/__json-table-react/download-excel.js +156 -0
- package/src/web-components/TODO json-table/src/__json-table-react/set-className.js +19 -0
- package/src/web-components/TODO json-table/src/__json-table-react/set-download-filename.js +17 -0
- package/src/web-components/TODO json-table/src/__json-table-react/table-to-csv.js +48 -0
- package/src/web-components/TODO json-table/src/css/custom-media.css +16 -0
- package/src/web-components/TODO json-table/src/css/icons.module.css +22 -0
- package/src/web-components/TODO json-table/src/css/info-section.module.css +78 -0
- package/src/web-components/TODO json-table/src/css/main-builder.module.css +6 -0
- package/src/web-components/TODO json-table/src/css/table.module.css +172 -0
- package/src/web-components/TODO json-table/src/css/utility.module.css +9 -0
- package/src/web-components/TODO json-table/src/icons/arrow-down-bold.svg +1 -0
- package/src/web-components/TODO json-table/src/icons/false.svg +1 -0
- package/src/web-components/TODO json-table/src/icons/true.svg +1 -0
- package/src/web-components/TODO json-table/src/index.js +125 -0
- package/src/web-components/TODO json-table/src/js/default-columns-data-types.js +172 -0
- package/src/web-components/TODO json-table/src/js/defaults.js +510 -0
- package/src/web-components/TODO json-table/src/js/get-ajax-data.js +72 -0
- package/src/web-components/TODO json-table/src/js/info-section.js +39 -0
- package/src/web-components/TODO json-table/src/js/init-ajax-table.js +30 -0
- package/src/web-components/TODO json-table/src/js/init-static-table.js +18 -0
- package/src/web-components/TODO json-table/src/js/main-builder.js +87 -0
- package/src/web-components/TODO json-table/src/js/parse-data-row.js +123 -0
- package/src/web-components/TODO json-table/src/js/parse-params.js +118 -0
- package/src/web-components/TODO json-table/src/js/set-search-listener.js +62 -0
- package/src/web-components/TODO json-table/src/js/set-sort-listeners.js +115 -0
- package/src/web-components/TODO json-table/src/js/static-data-sorting.js +23 -0
- package/src/web-components/TODO json-table/src/js/table-builder.js +45 -0
- package/src/web-components/TODO json-table/src/js/table-row.js +43 -0
- package/src/web-components/TODO json-table/src/js/table-tfoot.js +9 -0
- package/src/web-components/TODO json-table/src/js/table-thead.js +91 -0
- package/src/web-components/TODO json-table/src/js/update-info.js +42 -0
- package/src/web-components/TODO json-table/src/js/utilities.js +5 -0
- package/src/web-components/s-datatable-component/s-datatable-component.js +2 -1
- package/src/web-components/s-datatable-component/src/parse-cols.js +2 -1
|
@@ -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 @@
|
|
|
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;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* data types default settings
|
|
3
|
+
*
|
|
4
|
+
* standard render function and classnames for each data type
|
|
5
|
+
* each of the them can be overridden in the columns definition
|
|
6
|
+
* the formatClassName is used to add a class to the tbody cells for formatting purposes
|
|
7
|
+
*
|
|
8
|
+
* default data types can be expanded with custom values when instatiating the JsonTable class
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} params - the global params object. For clarity, render functions
|
|
11
|
+
* use a `global_params` argument, instead of `params`, but it's the same thing
|
|
12
|
+
* @param {Object} datatypes - the default datatypes object
|
|
13
|
+
* @param {String} datatypes.className - default className for the data type
|
|
14
|
+
* @param {Function} datatypes.parse - parse function, to normalize/process data before rendering,
|
|
15
|
+
* its argument is the complete data row, and must be applied to the column definition
|
|
16
|
+
* (not with this function)
|
|
17
|
+
* @param {Function} datatypes.render - render function
|
|
18
|
+
* @param {Function} datatypes.sortValue - the value used for sorting. If not defined, the raw value is used
|
|
19
|
+
* @param {Function} datatypes.searchValue - the value used for searching. If not defined, the raw value is used
|
|
20
|
+
* @param {Object} datatypes.colDefaultsOverrides - Object with default values for the columns.
|
|
21
|
+
* They override the default values in the `columns_default` object for the columns with the given dataType
|
|
22
|
+
* @returns {Object} - the default datatypes object
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import * as styles from '../css/utility.module.css';
|
|
26
|
+
import * as iconsStyles from '../css/icons.module.css';
|
|
27
|
+
|
|
28
|
+
export function defaultDataTypes(params) {
|
|
29
|
+
|
|
30
|
+
const inlineEndAlignClassName = params.inlineEndAlignClassName?? styles.endAlign
|
|
31
|
+
// ,centerAlignClassName = params.centerAlignClassName?? styles.centerAlign
|
|
32
|
+
,nowrapClassName = params.nowrapClassName?? styles.nowrap
|
|
33
|
+
|
|
34
|
+
,date_datetime_datatype = isDatetime => {
|
|
35
|
+
|
|
36
|
+
const parseDateString = d => {
|
|
37
|
+
let date;
|
|
38
|
+
if(!d) {
|
|
39
|
+
date = null;
|
|
40
|
+
|
|
41
|
+
// allow using date objects (like the ones returned by symfony)
|
|
42
|
+
// like `{'date': '2022-12-02 06:18:55', 'timezone_type': 3, 'timezone': 'Europe/Berlin' }`
|
|
43
|
+
// added for compatibility reasons
|
|
44
|
+
// ENHANCEMENT parse timezones
|
|
45
|
+
} else if(typeof d === 'object' && Object.hasOwn(d, 'date')) {
|
|
46
|
+
|
|
47
|
+
date = new Date(d.date);
|
|
48
|
+
|
|
49
|
+
} else {
|
|
50
|
+
date = new Date(d);
|
|
51
|
+
}
|
|
52
|
+
return date;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
className: inlineEndAlignClassName + (params.datesNowrap? ` ${nowrapClassName}` : ''),
|
|
57
|
+
|
|
58
|
+
sortValue: (d/* , global_params */) => parseDateString(d)?.toISOString()?? '',
|
|
59
|
+
searchValue: (d, global_params) => {
|
|
60
|
+
// normalize the date string
|
|
61
|
+
const date = parseDateString(d);
|
|
62
|
+
if (date) {
|
|
63
|
+
return date.toLocaleString(global_params.locale, {
|
|
64
|
+
...global_params.datesLocaleOpts,
|
|
65
|
+
...(isDatetime? global_params.timesLocaleOpts : {})
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
return '';
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
render: (d, global_params) => {
|
|
73
|
+
|
|
74
|
+
// normalize the date string
|
|
75
|
+
const date = parseDateString(d);
|
|
76
|
+
|
|
77
|
+
if(date) {
|
|
78
|
+
const dateISO = date.toISOString();
|
|
79
|
+
return `<time datetime="${isDatetime? dateISO : dateISO.substring(0,10)}">` +
|
|
80
|
+
date.toLocaleString(global_params.locale, global_params.datesLocaleOpts) +
|
|
81
|
+
(isDatetime?
|
|
82
|
+
'\u00A0' +
|
|
83
|
+
'<small>' +
|
|
84
|
+
date.toLocaleString(global_params.locale, global_params.timesLocaleOpts) +
|
|
85
|
+
'</small>'
|
|
86
|
+
: '') +
|
|
87
|
+
'</time>';
|
|
88
|
+
|
|
89
|
+
} else {
|
|
90
|
+
return '';
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
// force some columns default values (`columns_default` variable) for this dataType.
|
|
94
|
+
// All of these values can in turn be overridden in the column definition.
|
|
95
|
+
colDefaultsOverrides: {
|
|
96
|
+
tfoot: false, // avoid rendering this value inside the tfoot element
|
|
97
|
+
}
|
|
98
|
+
}; // end of returned object
|
|
99
|
+
} // end date_datetime_datatype
|
|
100
|
+
|
|
101
|
+
,parseNum = (val) => {
|
|
102
|
+
const num = +(val?? 0);
|
|
103
|
+
if(isNaN(num) && params.isNaNChar !== false) {
|
|
104
|
+
return params.isNaNChar;
|
|
105
|
+
} else {
|
|
106
|
+
return num;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
;
|
|
110
|
+
|
|
111
|
+
const datatypes = {
|
|
112
|
+
|
|
113
|
+
string: {}, // default type
|
|
114
|
+
|
|
115
|
+
date: date_datetime_datatype(false),
|
|
116
|
+
datetime: date_datetime_datatype(true),
|
|
117
|
+
|
|
118
|
+
num: {
|
|
119
|
+
className : inlineEndAlignClassName,
|
|
120
|
+
sortValue : val => parseNum(val),
|
|
121
|
+
searchValue : val => parseNum(val),
|
|
122
|
+
render : (val, global_params) => {
|
|
123
|
+
const num = parseNum(val);
|
|
124
|
+
return isNaN(num)? num : num.toLocaleString(global_params.locale, global_params.numbersLocaleOpts);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
perc: {
|
|
128
|
+
className : inlineEndAlignClassName,
|
|
129
|
+
sortValue : val => parseNum(val),
|
|
130
|
+
searchValue : val => parseNum(val),
|
|
131
|
+
render : (val, global_params) => {
|
|
132
|
+
const num = parseNum(val);
|
|
133
|
+
return isNaN(num)? num : num.toLocaleString(global_params.locale, global_params.currPercLocaleOpts) + '\u202F<small>%</small>';
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
percDecimal: {
|
|
137
|
+
className : inlineEndAlignClassName,
|
|
138
|
+
sortValue : val => parseNum(val),
|
|
139
|
+
searchValue : val => parseNum(val),
|
|
140
|
+
render : (val, global_params) => {
|
|
141
|
+
const num = parseNum(val);
|
|
142
|
+
return isNaN(num)? num : (num * 100).toLocaleString(global_params.locale, global_params.currPercLocaleOpts) + '\u202F<small>%</small>';
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
euro: {
|
|
146
|
+
className : inlineEndAlignClassName,
|
|
147
|
+
sortValue : val => parseNum(val),
|
|
148
|
+
searchValue : val => parseNum(val),
|
|
149
|
+
render : (val, global_params) => {
|
|
150
|
+
const num = parseNum(val);
|
|
151
|
+
return isNaN(num)? num : '<small>\u20AC</small>\u202F' + num.toLocaleString(global_params.locale, global_params.currPercLocaleOpts);
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
bool: {
|
|
156
|
+
// NB: `true` and `false` classes are added by the `table-row.js` script
|
|
157
|
+
className : params.boolValuesClassName?? iconsStyles.icon,
|
|
158
|
+
render : (val, global_params) => val === true? global_params.boolTrueIcon : (val === false? global_params.boolFalseIcon : ''),
|
|
159
|
+
|
|
160
|
+
// force some columns default values (`columns_default` variable) for this dataType.
|
|
161
|
+
// All of these values can in turn be overridden in the column definition.
|
|
162
|
+
colDefaultsOverrides: {
|
|
163
|
+
tfoot : false, // avoid rendering this value inside the tfoot element
|
|
164
|
+
searchable : false, // disable searching
|
|
165
|
+
sortable : false // disable sorting
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
return datatypes;
|
|
172
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parametri di configurazione
|
|
3
|
+
*
|
|
4
|
+
*/
|
|
5
|
+
import trueIcon from '../icons/true.svg?inline';
|
|
6
|
+
import falseIcon from '../icons/false.svg?inline';
|
|
7
|
+
|
|
8
|
+
export const defaults_params = {
|
|
9
|
+
|
|
10
|
+
// if true, logs debug info to the console
|
|
11
|
+
debug : false,
|
|
12
|
+
|
|
13
|
+
// element to insert the table into. Required
|
|
14
|
+
container : null,
|
|
15
|
+
|
|
16
|
+
// if true, jsonTable uses the same json schema and query parameters (simplified)
|
|
17
|
+
// of jQuery Datatable (currently it is always active, setting it to false has no effect)
|
|
18
|
+
jqDatatableCompliant : true,
|
|
19
|
+
|
|
20
|
+
columns : [], // coluns definitions
|
|
21
|
+
ajax : false, // true: uses `ajaxUrl` and ignores `data`
|
|
22
|
+
ajaxUrl : null, // ajax url for rows data
|
|
23
|
+
data : [], // rows data (static version)
|
|
24
|
+
footerData : [], // TODO che succede con ajax???
|
|
25
|
+
caption : null,
|
|
26
|
+
addRowIndex : false, // if true adds a data-index attribute to the `tr` with the json record index
|
|
27
|
+
|
|
28
|
+
// activate search and sort features
|
|
29
|
+
search : true,
|
|
30
|
+
sort : true,
|
|
31
|
+
// object of column keys with 'asc` or `desc` for default sorting
|
|
32
|
+
// keys order must reflect the order of the database sorting statement
|
|
33
|
+
// example: { key1: 'asc', key2: 'desc' }
|
|
34
|
+
// sort directions strings will be forced to lowercase
|
|
35
|
+
defaultSorting : {},
|
|
36
|
+
|
|
37
|
+
locale : 'it-IT', // locale string
|
|
38
|
+
datesLocaleOpts : { year: 'numeric', month: 'short', day: 'numeric' },
|
|
39
|
+
timesLocaleOpts : { hour12: false, hour:'2-digit', minute:'2-digit' },
|
|
40
|
+
numbersLocaleOpts : { maximumFractionDigits: 2 }, // numbers
|
|
41
|
+
currPercLocaleOpts : { maximumFractionDigits: 2, minimumFractionDigits: 2 }, // currency and percentages
|
|
42
|
+
|
|
43
|
+
tableId : null, // custom table id, if needed
|
|
44
|
+
|
|
45
|
+
// extra or alternative classes for the main wrapper (contains info and table), info section or table
|
|
46
|
+
// extra classes are added to the default classes
|
|
47
|
+
// alternative classes replace them completely (and any extra classes are not taken into account)
|
|
48
|
+
// If `infoAltClassName` is defined, no default classes are added to the elements in the info section
|
|
49
|
+
// (anyway, the class specified in `searchInputClassName`, if defined, is added to the input element)
|
|
50
|
+
mainWrapperExtraClassName : null,
|
|
51
|
+
mainWrapperAltClassName : null,
|
|
52
|
+
infoExtraClassName : null,
|
|
53
|
+
infoAltClassName : null,
|
|
54
|
+
tableExtraClassName : null,
|
|
55
|
+
tableAltClassName : null,
|
|
56
|
+
|
|
57
|
+
// if true, wraps the table in a div to prevent overly large tables from breaking the layout
|
|
58
|
+
// since it uses the `overflow` property, it is not suitable for tables with sticky headers
|
|
59
|
+
addTableWrapper : true,
|
|
60
|
+
// alternative class for the div that wraps table.
|
|
61
|
+
tableWrapperClassName : null,
|
|
62
|
+
|
|
63
|
+
// custom classes for align and styling, if not defined or null, the default ones are used
|
|
64
|
+
// centerAlignClassName : null, // currently unused
|
|
65
|
+
inlineEndAlignClassName : null,
|
|
66
|
+
nowrapClassName : null,
|
|
67
|
+
euroClassName : null,
|
|
68
|
+
percClassName : null,
|
|
69
|
+
|
|
70
|
+
datesNowrap : true, // if true, renders cells containing a date “nowrap”
|
|
71
|
+
useZeroAltChar : true, // enables value conversions === `0`, overrides any column rendering function
|
|
72
|
+
zeroAltChar : '\u2014', // dash, used for values === `0` if useZeroAltChar === true
|
|
73
|
+
isNaNChar : '\u2014', // dash, used for NaN values of numeric datatypes, set it to false to avoid rendering
|
|
74
|
+
|
|
75
|
+
// class to be assigned to the cell containing boolean values, used for styling svg icons. Overrides the default class
|
|
76
|
+
// you may need to change it if you use a different icon set
|
|
77
|
+
boolValuesClassName : null,
|
|
78
|
+
|
|
79
|
+
// Optional custom class names for `true` and `false` boolean values.
|
|
80
|
+
// They are added to the containing cell (`td`) beside the `boolValuesClassName` class,
|
|
81
|
+
// but only if the `boolValuesClassName` parameter is not null
|
|
82
|
+
boolTrueClassName : null,
|
|
83
|
+
boolFalseClassName : null,
|
|
84
|
+
|
|
85
|
+
// icons svg code for boolean values
|
|
86
|
+
boolTrueIcon : trueIcon, // icon for boolean true
|
|
87
|
+
boolFalseIcon : falseIcon, // icon for boolean false
|
|
88
|
+
|
|
89
|
+
searchInputClassName : null, // custom class for the search input, overrides the default one,
|
|
90
|
+
searchInputTitle : 'Filtra records',
|
|
91
|
+
searchInputPlaceholder : 'INVIO per eseguire la ricerca',
|
|
92
|
+
searchInputAriaLabel : 'Filtra risultati',
|
|
93
|
+
|
|
94
|
+
// TODO (??) alternative templates markups
|
|
95
|
+
|
|
96
|
+
// callback functions after `tr` elements rendering, it's called for each row
|
|
97
|
+
// It is invoked with three arguments: the tr element, the corresponding data object and the whole parsed params object
|
|
98
|
+
trCallback : null,
|
|
99
|
+
|
|
100
|
+
// TODO download button (xlsx) (???)
|
|
101
|
+
/*
|
|
102
|
+
showDownloadBtn : false, // se `ajax` === true, è forzato su false
|
|
103
|
+
downloadBtnLabel : 'Download',
|
|
104
|
+
downloadBtnClassName : 'btn btn-outline-secondary btn-sm',
|
|
105
|
+
separateDownloadBtn : false, // se true viene restituito un array con tabella e pulsante download separati
|
|
106
|
+
downloadFilename : 'download',
|
|
107
|
+
downloadFormat : 'excel', // 'excel' o 'csv'
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Columns default values
|
|
116
|
+
* Some default (tfoot, searchable, sortable,...) can be changed for specific data types,
|
|
117
|
+
* according to the `colDefaultsOverrides` object in dataTypes
|
|
118
|
+
* (see the `default-columns-data-types.js` file)
|
|
119
|
+
*
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
export const columns_default = {
|
|
123
|
+
|
|
124
|
+
// column title (th text)
|
|
125
|
+
title : null,
|
|
126
|
+
|
|
127
|
+
// json object key
|
|
128
|
+
key : null,
|
|
129
|
+
|
|
130
|
+
// cell data type, it must be one of the keys of the `data_types` object
|
|
131
|
+
dataType : 'string',
|
|
132
|
+
|
|
133
|
+
// class to be assigned to the cell. If present it overrides the default class of the data_types object
|
|
134
|
+
className : null,
|
|
135
|
+
|
|
136
|
+
// rendering function for the cell. If present it overrides the default render function of the data_types object
|
|
137
|
+
render : null,
|
|
138
|
+
|
|
139
|
+
// parsing function for the cell. If present the value is passed to this function before rendering
|
|
140
|
+
parse : null,
|
|
141
|
+
|
|
142
|
+
// if true, the cell is a th[scope=row] instead of a td
|
|
143
|
+
rowHeading : false,
|
|
144
|
+
|
|
145
|
+
// if false, the cell will not be rendered in the tfoot element
|
|
146
|
+
tfoot : true,
|
|
147
|
+
|
|
148
|
+
// if true, the column content is searchable
|
|
149
|
+
searchable : true,
|
|
150
|
+
|
|
151
|
+
// if true, the column content is sortable
|
|
152
|
+
sortable : true,
|
|
153
|
+
|
|
154
|
+
// custom sort function for the column, overrides the default one
|
|
155
|
+
customSortFunction : null,
|
|
156
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as styles from '../css/info.module.css';
|
|
2
|
+
|
|
3
|
+
export function infoSection() {
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const searchInputClassName = this.params.searchInputClassName?? (this.params.infoAltClassName?? styles.searchInput),
|
|
7
|
+
searchInput =
|
|
8
|
+
`<div class="${styles.search}">` +
|
|
9
|
+
'<input' +
|
|
10
|
+
` title="${this.params.searchInputTitle}"` +
|
|
11
|
+
` placeholder="${this.params.searchInputPlaceholder}"` +
|
|
12
|
+
` aria-label="${this.params.searchInputAriaLabel}"` +
|
|
13
|
+
(searchInputClassName? ` class="${searchInputClassName}"` : '') +
|
|
14
|
+
' type="search"' +
|
|
15
|
+
'/>' +
|
|
16
|
+
'</div>';
|
|
17
|
+
|
|
18
|
+
const infoSection = document.createElement('div');
|
|
19
|
+
infoSection.className = this.params.infoAltClassName??
|
|
20
|
+
styles.info + (this.params.infoExtraClassName? ` ${this.params.infoExtraClassName}` : '');
|
|
21
|
+
|
|
22
|
+
infoSection.innerHTML = '<div' +
|
|
23
|
+
(this.params.infoAltClassName? '' : ` class="${styles.resultInfo}"`) +
|
|
24
|
+
'>{{TODO resultInfoText}}</div>' +
|
|
25
|
+
(this.params.search? searchInput : '');
|
|
26
|
+
|
|
27
|
+
// TODO add event listener to search input
|
|
28
|
+
|
|
29
|
+
return infoSection;
|
|
30
|
+
}
|
|
31
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
onKeyDown={ e => {
|
|
4
|
+
if(e.code === 'Enter'){
|
|
5
|
+
updateUrl(1, e.target.value);
|
|
6
|
+
}
|
|
7
|
+
}}
|
|
8
|
+
onInput={ e => { // per il pulsante di reset
|
|
9
|
+
if(e.target.value === '') {
|
|
10
|
+
updateUrl(1, '');
|
|
11
|
+
}
|
|
12
|
+
}}
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// TODO defaultSorting => conversione nel formato datatable se jqDatatableCompliant = true
|
|
17
|
+
// TODO customSortFunction
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as styles from '../css/main-wrapper.module.css';
|
|
2
|
+
|
|
3
|
+
export function mainBuilder() {
|
|
4
|
+
|
|
5
|
+
// console.log(this);
|
|
6
|
+
|
|
7
|
+
const wrapper = document.createElement('section');
|
|
8
|
+
wrapper.className = this.params.mainWrapperAltClassNam??
|
|
9
|
+
styles.wrapper + (this.params.mainWrapperExtraClassName? ` ${this.params.mainWrapperExtraClassName}` : '');
|
|
10
|
+
|
|
11
|
+
// info section
|
|
12
|
+
wrapper.appendChild(this.infoSection());
|
|
13
|
+
|
|
14
|
+
// table responsive wrapper & table
|
|
15
|
+
wrapper.appendChild(this.tableBuilder());
|
|
16
|
+
|
|
17
|
+
// TODO pagination -> https://www.taniarascia.com/front-end-tables-sort-filter-paginate/
|
|
18
|
+
// TODO search
|
|
19
|
+
// TODO sort
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
this.params.container.replaceChildren(wrapper);
|
|
23
|
+
|
|
24
|
+
// TODO ready listeners
|
|
25
|
+
// this.params.container.dispatchEvent(new CustomEvent('jt:ready', { detail: { table: this } }));
|
|
26
|
+
}
|