@massimo-cassandro/minimo 1.18.4 → 1.19.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.
- package/README.md +5 -1
- package/design-tokens/{utilities/readme.md → README.md} +26 -16
- package/design-tokens/tokens/src/components/unsplash-page/unsplash-page.minimo.tokens.jsonc +69 -31
- package/design-tokens/{utilities/tokens-config-sample.mjs → tokens-config-sample.mjs} +18 -10
- package/design-tokens/utilities/build-tokens-src/config.mjs +5 -0
- package/design-tokens/utilities/build-tokens-src/formats/css.mjs +18 -2
- package/design-tokens/utilities/build-tokens-src/merge-css.mjs +60 -0
- package/design-tokens/utilities/build-tokens.mjs +12 -0
- package/dev-tools/README.md +8 -0
- package/dev-tools/starter-kit/starter-install.sh +46 -26
- package/package.json +6 -2
- package/snippets/error-pages/error-pages.js +3 -2
- package/src/components/unsplash-page/unsplash-page.minimo.tokens.mjs +78 -39
- package/src/components/unsplash-page/unsplash-page.module.css +25 -6
- package/src/custom-properties.css +8 -1
- package/src/minimo.css +1 -1
- package/src/web-components/s-datatable-component/s-datatable-component.js +4 -1
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/index.js +0 -92
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/hbars.js +0 -356
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/pie.js +0 -245
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/radial-bars.js +0 -177
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/rating-display.js +0 -835
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/settimanale-mensile-src/costruzione-assi.js +0 -212
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/settimanale-mensile-src/costruzione-linee.js +0 -101
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/settimanale-mensile-src/defaults.js +0 -185
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/settimanale-mensile-src/display-current.js +0 -27
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/settimanale-mensile-src/grid-areas.js +0 -129
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/settimanale-mensile-src/parse-opts.js +0 -64
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/settimanale-mensile-src/paths-setup.js +0 -73
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/settimanale-mensile.js +0 -126
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/charts/signal-bars.js +0 -290
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/src/week-utils.js +0 -122
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/browser-test/src/hbars-test.js +0 -52
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/browser-test/src/mcn-test.js +0 -74
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/browser-test/src/pie-test.js +0 -16
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/browser-test/src/radial-bars-test.js +0 -48
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/browser-test/src/settimanale-mensile-dati-settimanale.js +0 -426
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/browser-test/src/settimanale-mensile-test.js +0 -260
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/browser-test/src/signal-bars-test.js +0 -64
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/node-test/node-test.mjs +0 -86
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/node-test/src/hBars-node-test.mjs +0 -40
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/node-test/src/lines-node-test.mjs +0 -73
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/node-test/src/mcn-node-test.mjs +0 -64
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/node-test/src/pie-node-test.mjs +0 -12
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/node-test/src/radialsBar-node-test.mjs +0 -44
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/node-test/src/settimanale-mensile-node-test.mjs +0 -258
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/node-test/src/signalBars-node-test.mjs +0 -36
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/test-readme.md +0 -24
- package/charts/TODO charts/1a-vers DA RIFATTORIZZARE/test/textToPath-test.mjs +0 -14
- package/charts/TODO charts/???/InfoBox.js +0 -456
- package/charts/TODO charts/???/README-upg OLD/342/206/222NEW.md" +0 -53
- package/charts/TODO charts/???/README.md +0 -1
- package/charts/TODO charts/???/TODO.md +0 -39
- package/charts/TODO charts/???/base-cfg.js +0 -66
- package/charts/TODO charts/???/rating-displayOLD.js +0 -837
- package/charts/TODO charts/docs/TODO.md +0 -1
- package/charts/TODO charts/docs/costruzione display rating.md +0 -145
- package/charts/TODO charts/test/node-test.mjs +0 -92
- package/charts/TODO charts/test/test-readme.md +0 -23
- package/charts/TODO charts/test/test-src/rating-display-extra-test.js +0 -132
- package/charts/TODO charts/test/test-src/rating-display-test.js +0 -155
- package/charts/TODO charts/test/textToPath-test.mjs +0 -14
- package/charts/TODO.md +0 -7
- package/charts/src/node-helpers/TODO.md +0 -2
- package/dev-tools/starter-kit/TODO.md +0 -135
- package/src/components/TODO form-multiselect/form-multiselect.css +0 -40
- package/src/components/TODO form-multiselect/form-multiselect.js +0 -83
- package/src/components/TODO vanilla-cookie-consent/cookie-consent.css +0 -20
- package/src/components/TODO vanilla-cookie-consent/cookie-consent.js +0 -76
- package/src/components/TODO vanilla-cookie-consent/render-cookie-list.js +0 -32
- package/src/components/TODO vanilla-cookie-consent/src/cookie-list.js +0 -85
- package/src/components/TODO vanilla-cookie-consent/src/it-translation.js +0 -38
- package/src/components/TODO vanilla-cookie-consent/src/run-analytics.js +0 -54
- package/src/components/TODO vanilla-cookie-consent/src/run-recaptcha.js +0 -71
- package/src/components/autocomplete/TODO.md +0 -4
- package/src/web-components/TODO json-table/README.md +0 -67
- package/src/web-components/TODO json-table/TODO.md +0 -12
- package/src/web-components/TODO json-table/_work/OLD/docs/custom-props-list.md +0 -69
- package/src/web-components/TODO json-table/_work/OLD/script/create-css-custom-props-doc.mjs +0 -113
- package/src/web-components/TODO json-table/_work/OLD/script/src/custom-props-end.md +0 -4
- package/src/web-components/TODO json-table/_work/OLD/script/src/custom-props-start.md +0 -30
- package/src/web-components/TODO json-table/_work/OLD/src/css/icons.module.css +0 -22
- package/src/web-components/TODO json-table/_work/OLD/src/css/info.module.css +0 -42
- package/src/web-components/TODO json-table/_work/OLD/src/css/main-wrapper.module.css +0 -4
- package/src/web-components/TODO json-table/_work/OLD/src/css/table.module.css +0 -154
- package/src/web-components/TODO json-table/_work/OLD/src/css/utility.module.css +0 -9
- package/src/web-components/TODO json-table/_work/OLD/src/icons/false.svg +0 -1
- package/src/web-components/TODO json-table/_work/OLD/src/icons/search-arrows.svg +0 -1
- package/src/web-components/TODO json-table/_work/OLD/src/icons/true.svg +0 -1
- package/src/web-components/TODO json-table/_work/OLD/src/index.js +0 -56
- package/src/web-components/TODO json-table/_work/OLD/src/js/default-columns-data-types.js +0 -172
- package/src/web-components/TODO json-table/_work/OLD/src/js/defaults.js +0 -156
- package/src/web-components/TODO json-table/_work/OLD/src/js/info-section.js +0 -31
- package/src/web-components/TODO json-table/_work/OLD/src/js/listeners.js +0 -17
- package/src/web-components/TODO json-table/_work/OLD/src/js/main-builder.js +0 -26
- package/src/web-components/TODO json-table/_work/OLD/src/js/parse-params.js +0 -121
- package/src/web-components/TODO json-table/_work/OLD/src/js/set-column-classname.js +0 -22
- package/src/web-components/TODO json-table/_work/OLD/src/js/table-builder.js +0 -64
- package/src/web-components/TODO json-table/_work/OLD/src/js/table-foot.js +0 -8
- package/src/web-components/TODO json-table/_work/OLD/src/js/table-head.js +0 -47
- package/src/web-components/TODO json-table/_work/OLD/src/js/table-row.js +0 -83
- package/src/web-components/TODO json-table/_work/OLD/src/js/utilities.js +0 -5
- package/src/web-components/TODO json-table/_work/__json-table-react/index.js +0 -4
- package/src/web-components/TODO json-table/_work/__json-table-react/src/build-page-array.js +0 -73
- package/src/web-components/TODO json-table/_work/__json-table-react/src/columns-data-types.js +0 -73
- package/src/web-components/TODO json-table/_work/__json-table-react/src/defaults.js +0 -50
- package/src/web-components/TODO json-table/_work/__json-table-react/src/download-excel.js +0 -156
- package/src/web-components/TODO json-table/_work/__json-table-react/src/set-className.js +0 -19
- package/src/web-components/TODO json-table/_work/__json-table-react/src/set-download-filename.js +0 -17
- package/src/web-components/TODO json-table/_work/__json-table-react/src/table-to-csv.js +0 -48
- package/src/web-components/TODO json-table/_work/archived/table-to-csv.js +0 -48
- package/src/web-components/TODO json-table/_work/arrow.svg +0 -3
- package/src/web-components/TODO json-table/_work/da decidere/get-cell-data.js +0 -18
- package/src/web-components/TODO json-table/_work/download-button.js +0 -29
- package/src/web-components/TODO json-table/_work/download-excel.js +0 -155
- package/src/web-components/TODO json-table/_work/pagination-array-builder.js +0 -73
- package/src/web-components/TODO json-table/_work/pagination.js +0 -37
- package/src/web-components/TODO json-table/_work/set-download-filename.js +0 -19
- package/src/web-components/TODO json-table/_work/table-info.js +0 -24
- package/src/web-components/TODO json-table/demo/README.md +0 -66
- package/src/web-components/TODO json-table/demo/assets/link-simple.svg +0 -1
- package/src/web-components/TODO json-table/demo/demo-data/json-static-table-demo-data.js +0 -512
- package/src/web-components/TODO json-table/demo/demo.css +0 -32
- package/src/web-components/TODO json-table/demo/demo.js +0 -24
- package/src/web-components/TODO json-table/demo/js/demo-ajax-table.js +0 -165
- package/src/web-components/TODO json-table/demo/js/demo-static-table.js +0 -180
- package/src/web-components/TODO json-table/demo/webpack-modules/css-rules.mjs +0 -122
- package/src/web-components/TODO json-table/demo/webpack-modules/get-jsConfig-aliases.mjs +0 -33
- package/src/web-components/TODO json-table/demo/webpack-modules/svg-rules.mjs +0 -108
- package/src/web-components/TODO json-table/demo/webpack-modules/svgo.config.mjs +0 -26
- package/src/web-components/TODO json-table/demo/webpack.config.mjs +0 -333
- package/src/web-components/TODO json-table/docs/custom-props-list.md +0 -74
- package/src/web-components/TODO json-table/docs-builder/create-css-custom-props-doc.mjs +0 -157
- package/src/web-components/TODO json-table/docs-builder/src/custom-props-end.md +0 -6
- package/src/web-components/TODO json-table/docs-builder/src/custom-props-start.md +0 -29
- package/src/web-components/TODO json-table/src/TODO.md +0 -1
- package/src/web-components/TODO json-table/src/__json-table-react/build-page-array.js +0 -73
- package/src/web-components/TODO json-table/src/__json-table-react/columns-data-types.js +0 -73
- package/src/web-components/TODO json-table/src/__json-table-react/defaults.js +0 -50
- package/src/web-components/TODO json-table/src/__json-table-react/download-excel.js +0 -156
- package/src/web-components/TODO json-table/src/__json-table-react/set-className.js +0 -19
- package/src/web-components/TODO json-table/src/__json-table-react/set-download-filename.js +0 -17
- package/src/web-components/TODO json-table/src/__json-table-react/table-to-csv.js +0 -48
- package/src/web-components/TODO json-table/src/css/custom-media.css +0 -16
- package/src/web-components/TODO json-table/src/css/icons.module.css +0 -22
- package/src/web-components/TODO json-table/src/css/info-section.module.css +0 -78
- package/src/web-components/TODO json-table/src/css/main-builder.module.css +0 -6
- package/src/web-components/TODO json-table/src/css/table.module.css +0 -172
- package/src/web-components/TODO json-table/src/css/utility.module.css +0 -9
- package/src/web-components/TODO json-table/src/icons/arrow-down-bold.svg +0 -1
- package/src/web-components/TODO json-table/src/icons/false.svg +0 -1
- package/src/web-components/TODO json-table/src/icons/true.svg +0 -1
- package/src/web-components/TODO json-table/src/index.js +0 -125
- package/src/web-components/TODO json-table/src/js/default-columns-data-types.js +0 -172
- package/src/web-components/TODO json-table/src/js/defaults.js +0 -510
- package/src/web-components/TODO json-table/src/js/get-ajax-data.js +0 -72
- package/src/web-components/TODO json-table/src/js/info-section.js +0 -39
- package/src/web-components/TODO json-table/src/js/init-ajax-table.js +0 -30
- package/src/web-components/TODO json-table/src/js/init-static-table.js +0 -18
- package/src/web-components/TODO json-table/src/js/main-builder.js +0 -87
- package/src/web-components/TODO json-table/src/js/parse-data-row.js +0 -123
- package/src/web-components/TODO json-table/src/js/parse-params.js +0 -118
- package/src/web-components/TODO json-table/src/js/set-search-listener.js +0 -62
- package/src/web-components/TODO json-table/src/js/set-sort-listeners.js +0 -115
- package/src/web-components/TODO json-table/src/js/static-data-sorting.js +0 -23
- package/src/web-components/TODO json-table/src/js/table-builder.js +0 -45
- package/src/web-components/TODO json-table/src/js/table-row.js +0 -43
- package/src/web-components/TODO json-table/src/js/table-tfoot.js +0 -9
- package/src/web-components/TODO json-table/src/js/table-thead.js +0 -91
- package/src/web-components/TODO json-table/src/js/update-info.js +0 -42
- package/src/web-components/TODO json-table/src/js/utilities.js +0 -5
|
@@ -1,125 +0,0 @@
|
|
|
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 './css/custom-media.css';
|
|
10
|
-
|
|
11
|
-
import { initStaticTable } from './js/init-static-table.js';
|
|
12
|
-
import { initAjaxTable } from './js/init-ajax-table.js';
|
|
13
|
-
import { getAjaxData } from './js/get-ajax-data.js';
|
|
14
|
-
|
|
15
|
-
import { parseParams } from './js/parse-params.js';
|
|
16
|
-
import { parseDataRow } from './js/parse-data-row.js';
|
|
17
|
-
import { mainBuilder } from './js/main-builder.js';
|
|
18
|
-
import { infoSection } from './js/info-section.js';
|
|
19
|
-
import { tableBuilder } from './js/table-builder.js';
|
|
20
|
-
import { tableThead } from './js/table-thead.js';
|
|
21
|
-
import { tableTfoot } from './js/table-tfoot.js';
|
|
22
|
-
import { tableRow } from './js/table-row.js';
|
|
23
|
-
import { updateInfo } from './js/update-info.js';
|
|
24
|
-
import { setSearchListener } from './js/set-search-listener.js';
|
|
25
|
-
import { setSortListeners } from './js/set-sort-listeners.js';
|
|
26
|
-
// import { staticDataSorting } from './js/static-data-sorting.js';
|
|
27
|
-
|
|
28
|
-
class JsonTable {
|
|
29
|
-
|
|
30
|
-
constructor(custom_params, custom_data_types) {
|
|
31
|
-
this.params = parseParams({
|
|
32
|
-
custom_params: custom_params,
|
|
33
|
-
custom_data_types: custom_data_types,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
if(this.params.err) {
|
|
37
|
-
// eslint-disable-next-line no-console
|
|
38
|
-
console.error(this.params.err);
|
|
39
|
-
|
|
40
|
-
} else {
|
|
41
|
-
|
|
42
|
-
this.appInit();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async appInit() {
|
|
48
|
-
|
|
49
|
-
if(this.params.ajax === false) {
|
|
50
|
-
this.initStaticTable();
|
|
51
|
-
|
|
52
|
-
} else {
|
|
53
|
-
await this.initAjaxTable();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Add aria attributes to icons
|
|
57
|
-
// and convert all icon variables to DOM nodes (if they aren't)
|
|
58
|
-
const div = document.createElement('div');
|
|
59
|
-
[
|
|
60
|
-
'boolTrueIcon',
|
|
61
|
-
'boolFalseIcon',
|
|
62
|
-
'sortArrowIcon'
|
|
63
|
-
].forEach(icon => {
|
|
64
|
-
if(this.params[icon] instanceof Element) {
|
|
65
|
-
div.replaceChildren(this.params[icon]);
|
|
66
|
-
} else {
|
|
67
|
-
div.innerHTML = this.params[icon] || 'missing icon';
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
div.querySelector('svg').setAttribute('aria-hidden', true);
|
|
71
|
-
|
|
72
|
-
this.params[icon] = div.firstElementChild;
|
|
73
|
-
|
|
74
|
-
});
|
|
75
|
-
div.remove();
|
|
76
|
-
|
|
77
|
-
this.mainBuilder();
|
|
78
|
-
|
|
79
|
-
if(this.params.debug) {
|
|
80
|
-
/* eslint-disable no-console */
|
|
81
|
-
console.groupCollapsed('JsonTable params & elements');
|
|
82
|
-
console.log('this.params');
|
|
83
|
-
console.log(this.params);
|
|
84
|
-
console.log('generated elements (this.params.elements)');
|
|
85
|
-
console.log(this.params.elements);
|
|
86
|
-
console.log('this.parsedData (static table only)');
|
|
87
|
-
console.log(this.parsedData?? 'n/a');
|
|
88
|
-
console.groupEnd();
|
|
89
|
-
/* eslint-enable no-console */
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
JsonTable.prototype.initStaticTable = initStaticTable;
|
|
95
|
-
JsonTable.prototype.initAjaxTable = initAjaxTable;
|
|
96
|
-
JsonTable.prototype.getAjaxData = getAjaxData;
|
|
97
|
-
JsonTable.prototype.parseDataRow = parseDataRow;
|
|
98
|
-
JsonTable.prototype.mainBuilder = mainBuilder;
|
|
99
|
-
JsonTable.prototype.infoSection = infoSection;
|
|
100
|
-
JsonTable.prototype.tableBuilder = tableBuilder;
|
|
101
|
-
JsonTable.prototype.tableThead = tableThead;
|
|
102
|
-
JsonTable.prototype.tableTfoot = tableTfoot;
|
|
103
|
-
JsonTable.prototype.tableRow = tableRow;
|
|
104
|
-
JsonTable.prototype.updateInfo = updateInfo;
|
|
105
|
-
JsonTable.prototype.setSearchListener = setSearchListener;
|
|
106
|
-
JsonTable.prototype.setSortListeners = setSortListeners;
|
|
107
|
-
// JsonTable.prototype.staticDataSorting = staticDataSorting;
|
|
108
|
-
|
|
109
|
-
export default JsonTable;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
// TODO opzione per acquisire i dati dal markup di una tabella
|
|
113
|
-
// TODO local storage per opzioni di ordinamento e ricerca
|
|
114
|
-
// TODO Alternativa excel : https://gitlab.com/catamphetamine/write-excel-file ??
|
|
115
|
-
// TODO jsdoc
|
|
116
|
-
// TODO opzione per usare parametri più semplici non compatibili con dt
|
|
117
|
-
// TODO add parse cell method (unificare tipi con static Table)
|
|
118
|
-
// TODO versione con css separato?
|
|
119
|
-
|
|
120
|
-
// TODO see:
|
|
121
|
-
// https://www.raymondcamden.com/2022/05/23/building-table-sorting-and-pagination-in-a-web-component
|
|
122
|
-
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table?retiredLocale=it#table_sorting
|
|
123
|
-
// https://pencilandpaper.io/articles/user-experience/ux-pattern-analysis-enterprise-data-tables/
|
|
124
|
-
// https://medium.com/design-with-figma/the-ultimate-guide-to-designing-data-tables-7db29713a85a
|
|
125
|
-
// https://medium.com/nextux/design-better-data-tables-4ecc99d23356
|
|
@@ -1,172 +0,0 @@
|
|
|
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.sortValueParser - the value used for sorting (static table only). If not defined, the raw value is used
|
|
19
|
-
* @param {Function} datatypes.searchValueParser - the value used for searching (static table only). 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
|
-
sortValueParser: (d/* , global_params */) => parseDateString(d)?.toISOString()?? '',
|
|
59
|
-
searchValueParser: (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
|
-
sortValueParser : val => parseNum(val),
|
|
121
|
-
searchValueParser : 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
|
-
sortValueParser : val => parseNum(val),
|
|
130
|
-
searchValueParser : 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
|
-
sortValueParser : val => parseNum(val),
|
|
139
|
-
searchValueParser : 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
|
-
sortValueParser : val => parseNum(val),
|
|
148
|
-
searchValueParser : 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
|
-
}
|