@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,510 @@
1
+ /** Module defaults and inline JSDoc for `defaults_params` */
2
+ /**
3
+ * @typedef {Object} DateLocaleOpts
4
+ * @property {'numeric'|'2-digit'|'short'|'long'|'narrow'} [year]
5
+ * @property {'numeric'|'2-digit'|'short'|'long'|'narrow'} [month]
6
+ * @property {'numeric'|'2-digit'|'short'|'long'|'narrow'} [day]
7
+ *
8
+ * @typedef {Object} TimeLocaleOpts
9
+ * @property {boolean} [hour12]
10
+ * @property {'2-digit'|'numeric'} [hour]
11
+ * @property {'2-digit'|'numeric'} [minute]
12
+ * @property {'2-digit'|'numeric'} [second]
13
+ *
14
+ * @typedef {Object} NumberFormatOpts
15
+ * @property {number} [maximumFractionDigits]
16
+ * @property {number} [minimumFractionDigits]
17
+ *
18
+ *
19
+ * @typedef {'string'|'number'|'date'|'boolean'|'currency'|'percentage'|'custom'} DataType
20
+ */
21
+
22
+ import trueIcon from '../icons/true.svg?inline';
23
+ import falseIcon from '../icons/false.svg?inline';
24
+ import sortArrow from '../icons/arrow-down-bold.svg?inline';
25
+
26
+ export const defaults_params = {
27
+ /**
28
+ * If true, logs debug info to the console.
29
+ * @type {boolean}
30
+ */
31
+ debug : false,
32
+
33
+ /**
34
+ * Element to insert the table into.
35
+ * @type {HTMLElement|null}
36
+ */
37
+ container : null,
38
+
39
+ /**
40
+ * Collection of generated DOM elements used by the table instance.
41
+ * @type {Object}
42
+ */
43
+ elements : {},
44
+
45
+ /**
46
+ * Columns definitions (see `columns_default`).
47
+ * @type {Array<ColumnDefault>}
48
+ */
49
+ columns : [],
50
+
51
+ /**
52
+ * If true, fetch rows from `ajaxUrl` and ignore `data`.
53
+ * @type {boolean}
54
+ */
55
+ ajax : false,
56
+
57
+ /**
58
+ * Ajax URL for rows data.
59
+ * @type {string|null}
60
+ */
61
+ ajaxUrl : null,
62
+
63
+ /**
64
+ * If null, default config (see `ajax_config_default` at bottom of this file) is used
65
+ * If Object, must provide parameters about ajax request, according to `ajax_config_default` obj
66
+ * @type {null|Object}
67
+ */
68
+ ajaxConfig : null,
69
+
70
+ /**
71
+ * Static rows data.
72
+ * @type {Array}
73
+ */
74
+ data : [],
75
+
76
+ /**
77
+ * Footer data for static tables.
78
+ * @type {Array}
79
+ */
80
+ footerData : [],
81
+
82
+ /**
83
+ * Table caption (string or HTML).
84
+ * @type {string|null}
85
+ */
86
+ caption : null,
87
+
88
+ /**
89
+ * Enable search input.
90
+ * @type {boolean}
91
+ */
92
+ search : true,
93
+
94
+ /**
95
+ * Enable column sorting.
96
+ * @type {boolean}
97
+ */
98
+ sort : true,
99
+
100
+ /**
101
+ * Default sorting object: { key: 'asc'|'desc' }.
102
+ * @type {Object}
103
+ */
104
+ defaultSorting : {},
105
+
106
+ /**
107
+ * Aria label for ascending sort button.
108
+ * @type {string}
109
+ */
110
+ sortButtonAriaLabelAsc : 'Ordina questa colonna in senso ascendente (A\u00A0→\u00A0Z)',
111
+
112
+ /**
113
+ * Aria label for descending sort button.
114
+ * @type {string}
115
+ */
116
+ sortButtonAriaLabelDesc : 'Ordina questa colonna in senso discendente (Z\u00A0→\u00A0A)',
117
+
118
+ /**
119
+ * Aria label to remove sorting.
120
+ * @type {string}
121
+ */
122
+ sortButtonAriaLabelNone : 'Rimuovi l’ordinamento a questa colonna',
123
+
124
+ /**
125
+ * Locale string used for date/number formatting.
126
+ * @type {string}
127
+ */
128
+ locale : 'it-IT',
129
+
130
+ /**
131
+ * Options passed to Intl.DateTimeFormat for dates.
132
+ * @type {DateLocaleOpts}
133
+ */
134
+ datesLocaleOpts : { year: 'numeric', month: 'short', day: 'numeric' },
135
+
136
+ /**
137
+ * Options passed to Intl.DateTimeFormat for times.
138
+ * @type {TimeLocaleOpts}
139
+ */
140
+ timesLocaleOpts : { hour12: false, hour:'2-digit', minute:'2-digit' },
141
+
142
+ /**
143
+ * Number formatting options.
144
+ * @type {NumberFormatOpts}
145
+ */
146
+ numbersLocaleOpts : { maximumFractionDigits: 2 },
147
+
148
+ /**
149
+ * Currency/percentage formatting options.
150
+ * @type {NumberFormatOpts}
151
+ */
152
+ currPercLocaleOpts : { maximumFractionDigits: 2, minimumFractionDigits: 2 },
153
+
154
+ /**
155
+ * Custom table id if needed.
156
+ * @type {string|null}
157
+ */
158
+ tableId : null,
159
+
160
+ /**
161
+ * Extra class for the div that wraps the table.
162
+ * @type {string|null}
163
+ */
164
+ tableWrapperExtraClassName : null,
165
+
166
+ /**
167
+ * Class name to assign to the <table> element.
168
+ * @type {string|null}
169
+ */
170
+ tableClassName : null,
171
+
172
+ /**
173
+ * Extra class for main wrapper (contains info and table).
174
+ * @type {string|null}
175
+ */
176
+ mainWrapperExtraClassName : null,
177
+
178
+ /**
179
+ * Extra class for outer info section.
180
+ * @type {string|null}
181
+ */
182
+ outerInfoExtraClassName : null,
183
+
184
+ /**
185
+ * Extra class for info section.
186
+ * @type {string|null}
187
+ */
188
+ infoExtraClassName : null,
189
+
190
+ /**
191
+ * If true, make info container sticky.
192
+ * @type {boolean}
193
+ */
194
+ stickyInfo : true,
195
+
196
+ /**
197
+ * If true, make the table header sticky.
198
+ * @type {boolean}
199
+ */
200
+ stickyThead : true,
201
+
202
+ /**
203
+ * Class for inline-end alignment.
204
+ * @type {string|null}
205
+ */
206
+ inlineEndAlignClassName : null,
207
+
208
+ /**
209
+ * Class to prevent wrapping of content.
210
+ * @type {string|null}
211
+ */
212
+ nowrapClassName : null,
213
+
214
+ /**
215
+ * Class for euro currency formatting.
216
+ * @type {string|null}
217
+ */
218
+ euroClassName : null,
219
+
220
+ /**
221
+ * Class for percentage formatting.
222
+ * @type {string|null}
223
+ */
224
+ percClassName : null,
225
+
226
+ /**
227
+ * If true, date cells are rendered with nowrap.
228
+ * @type {boolean}
229
+ */
230
+ datesNowrap : true,
231
+
232
+ /**
233
+ * If true, treat 0 as an alternate (dash) character.
234
+ * @type {boolean}
235
+ */
236
+ useZeroAltChar : true,
237
+
238
+ /**
239
+ * Character used for zero values when `useZeroAltChar` is true.
240
+ * @type {string}
241
+ */
242
+ zeroAltChar : '\u2014',
243
+
244
+ /**
245
+ * Character used for NaN numeric values or `false` to disable.
246
+ * @type {string|boolean}
247
+ */
248
+ isNaNChar : '\u2014',
249
+
250
+ /**
251
+ * Class added to both true/false boolean icon cells.
252
+ * @type {string|null}
253
+ */
254
+ boolValuesClassName : null,
255
+
256
+ /**
257
+ * Class added to true icons.
258
+ * @type {string|null}
259
+ */
260
+ boolTrueClassName : null,
261
+
262
+ /**
263
+ * Class added to false icons.
264
+ * @type {string|null}
265
+ */
266
+ boolFalseClassName : null,
267
+
268
+ /**
269
+ * Icons used by the table for booleans and sorting.
270
+ *
271
+ * - `boolTrueIcon`: icon/markup for boolean true
272
+ * - `boolFalseIcon`: icon/markup for boolean false
273
+ * - `sortArrowIcon`: icon/markup for the sort arrow
274
+ *
275
+ * Imported icons can be a string, HTMLElement, SVGElement or a function returning markup.
276
+ * Note: if you use custom icons, until you recompile the library, the default icons markup
277
+ * remains embedded in the build even if you provide custom icons.
278
+ * Note: The default sortArrowIcon is downward-oriented; if the custom one is upward-oriented,
279
+ * you'll need to change the CSS properties `--jt-sort-asc-arrow-rotate` and `--jt-sort-desc-arrow-rotate`
280
+ * or change something else in the CSS.
281
+ * @type {string|HTMLElement|SVGElement|Function}
282
+ */
283
+ boolTrueIcon : trueIcon,
284
+ boolFalseIcon : falseIcon,
285
+ sortArrowIcon : sortArrow,
286
+
287
+ /**
288
+ * Alternative class for the search input (overrides default).
289
+ * @type {string|null}
290
+ */
291
+ searchInputAltClassName : null,
292
+
293
+ /**
294
+ * Additional class for the search input.
295
+ * @type {string|null}
296
+ */
297
+ searchInputExtraClassName : null,
298
+
299
+ /**
300
+ * Title attribute for search input.
301
+ * @type {string}
302
+ */
303
+ searchInputTitle : 'Filtra records: inserisci un termine per eseguire la ricerca',
304
+
305
+ /**
306
+ * Placeholder text for search input.
307
+ * @type {string}
308
+ */
309
+ searchInputPlaceholder : 'Inserisci il termine da cercare',
310
+
311
+ /**
312
+ * Aria-label for search input.
313
+ * @type {string}
314
+ */
315
+ searchInputAriaLabel : 'Filtra risultati',
316
+
317
+ /**
318
+ * Callback invoked after each row (<tr>) rendering.
319
+ * Signature: (trElement: HTMLElement, rowData: Object, params: Object)
320
+ * @type {Function|null}
321
+ */
322
+ trCallback : null,
323
+
324
+ // TODO download button (xlsx) (???)
325
+ /*
326
+ showDownloadBtn : false, // se `ajax` === true, è forzato su false
327
+ downloadBtnLabel : 'Download',
328
+ downloadBtnClassName : 'btn btn-outline-secondary btn-sm',
329
+ separateDownloadBtn : false, // se true viene restituito un array con tabella e pulsante download separati
330
+ downloadFilename : 'download',
331
+ downloadFormat : 'excel', // 'excel' o 'csv'
332
+ */
333
+
334
+ };
335
+
336
+
337
+ /**
338
+ * Column default options.
339
+ * @typedef {Object} ColumnDefault
340
+ * @property {string|null} key - REQUIRED json object key (= db column name).
341
+ * @property {string|null} title - Column title (th text, can be an HTML string).
342
+ * @property {string} [dataType='string'] - Cell data type; must be one of keys of `data_types`.
343
+ * @property {string|null} className - Class assigned to the cell; overrides default.
344
+ * @property {Function|null} render - Rendering function for the cell.
345
+ * @property {Function|null} parse - Parsing function for the cell.
346
+ * @property {boolean} [rowHeading=false] - If true, the cell is a row heading (th[scope=row]).
347
+ * @property {boolean} [tfoot=true]
348
+ * @property {boolean} [searchable=true]
349
+ * @property {boolean} [sortable=true]
350
+ * @property {Function|null} sortValueCustomParser - Custom sort function for static tables.
351
+ * @property {Function|null} searchValueCustomParser - Custom search function for static tables.
352
+ */
353
+
354
+ export const columns_default = {
355
+
356
+ /**
357
+ * REQUIRED: json object key (db column name)
358
+ * @type {string|null}
359
+ */
360
+ key : null,
361
+
362
+ /**
363
+ * Column title (th text, can be an HTML string)
364
+ * @type {string|null}
365
+ */
366
+ title : null,
367
+
368
+ /**
369
+ * Cell data type (one of keys in `data_types`).
370
+ * @type {DataType}
371
+ */
372
+ dataType : 'string',
373
+
374
+ /**
375
+ * Class to assign to the cell; overrides default for the data type.
376
+ * @type {string|null}
377
+ */
378
+ className : null,
379
+
380
+ /**
381
+ * Custom rendering function for the cell.
382
+ * @type {Function|null}
383
+ */
384
+ render : null,
385
+
386
+ /**
387
+ * Parsing function applied to the raw value before rendering.
388
+ * @type {Function|null}
389
+ */
390
+ parse : null,
391
+
392
+ /**
393
+ * If true, render cell as a row heading (th[scope=row]).
394
+ * @type {boolean}
395
+ */
396
+ rowHeading : false,
397
+
398
+ /**
399
+ * If false, cell won't be rendered in the tfoot element.
400
+ * @type {boolean}
401
+ */
402
+ tfoot : true,
403
+
404
+ /**
405
+ * If true, column content is searchable.
406
+ * @type {boolean}
407
+ */
408
+ searchable : true,
409
+
410
+ /**
411
+ * If true, column content is sortable.
412
+ * @type {boolean}
413
+ */
414
+ sortable : true,
415
+
416
+ /**
417
+ * Custom sort function for static tables; should match default parser signature.
418
+ * @type {Function|null}
419
+ */
420
+ sortValueCustomParser : null,
421
+
422
+ /**
423
+ * Custom search function for static tables; should match default parser signature.
424
+ * @type {Function|null}
425
+ */
426
+ searchValueCustomParser : null,
427
+ };
428
+
429
+
430
+ /**
431
+ * ajax config default options.
432
+ * Defaults values are referred to datatables keys
433
+ * @typedef {Object} AjaxConfigDefault
434
+ */
435
+
436
+ export const ajax_config_default = {
437
+
438
+
439
+ /**
440
+ * Config for ajax url
441
+ * @type {Object|null}
442
+ */
443
+ urlParamsKeys: {
444
+
445
+
446
+ /**
447
+ * Key for start item, record or page, of the returned data
448
+ * @type {string|null}
449
+ */
450
+ startItem: `start`,
451
+
452
+ /**
453
+ * Key for number of record to be returned
454
+ * @type {string|null}
455
+ */
456
+ perPage : 'length',
457
+
458
+ /**
459
+ * Key for search strings
460
+ * @type {string|null}
461
+ */
462
+ search : 'search[value]',
463
+
464
+ // TODO columns + order
465
+ },
466
+
467
+ urlParams: {
468
+ /**
469
+ * array of static item to be appended to query string
470
+ * Each item is a key-value array
471
+ * @type {array|null}
472
+ */
473
+ staticValues: [['draw', 1]],
474
+
475
+ perPageValue: 25
476
+
477
+ },
478
+
479
+
480
+ /**
481
+ * Config for returned object keys
482
+ * @type {Object|null}
483
+ */
484
+ jsonKeys: {
485
+ /**
486
+ * array of static item to be appended to returned object
487
+ * Each item is a key-value array
488
+ * @type {array|null}
489
+ */
490
+ staticParams: [['draw', 1]],
491
+
492
+ /**
493
+ * Key for number of records found
494
+ * @type {string|null}
495
+ */
496
+ totRec : 'recordsTotal',
497
+
498
+ /**
499
+ * Key for number of records found when filtered by search
500
+ * @type {string|null}
501
+ */
502
+ totRecFiltered : 'recordsFiltered',
503
+
504
+ /**
505
+ * Key for data object
506
+ * @type {string|null}
507
+ */
508
+ data : 'data',
509
+ }
510
+ }
@@ -0,0 +1,72 @@
1
+ export async function getAjaxData(urlParams = {}){
2
+
3
+ urlParams = {
4
+ ...{
5
+ startValue: 0,
6
+ searchValue: null
7
+ },
8
+ ...urlParams
9
+ };
10
+
11
+
12
+ /* urlParamsKeys: {
13
+
14
+
15
+
16
+ startItem: `start`,
17
+
18
+
19
+ perPage : 'length',
20
+
21
+
22
+ search : 'search[value]',
23
+
24
+ // TODO columns + order
25
+ },
26
+
27
+ urlParams: {
28
+
29
+ staticValues: [['draw', 1]],
30
+
31
+ perPageValue: 25,
32
+
33
+
34
+ }, */
35
+
36
+ const searchParams = new URLSearchParams({
37
+ [this.params.ajaxConfig.urlParamsKeys.startItem]: urlParams.startValue,
38
+ [this.params.ajaxConfig.urlParamsKeys.perPage]: this.params.ajaxConfig.urlParams.perPageValue,
39
+
40
+ ...(urlParams.searchValue != null
41
+ ? {[this.params.ajaxConfig.urlParamsKeys.search]: urlParams.searchValue}
42
+ : {}
43
+ ),
44
+
45
+ ...(
46
+ (this.params.ajaxConfig.urlParams.staticValues != null && Array.isArray(this.params.ajaxConfig.urlParams.staticValues))
47
+ ? this.params.ajaxConfig.urlParams.staticValues.map(i => ({[i[0]]: i[1]}))
48
+ : {}
49
+ ),
50
+
51
+ '_': Date.now()
52
+ });
53
+
54
+
55
+ const url = new URL(this.params.ajaxUrl);
56
+ url.search = searchParams.toString();
57
+
58
+ try {
59
+ const response = await fetch(url.toString());
60
+
61
+ this.params.data = await response.json();
62
+
63
+
64
+ } catch(err) {
65
+ /* eslint-disable no-console */
66
+ console.error(url);
67
+ console.error(err);
68
+ /* eslint-enable no-console */
69
+ }
70
+
71
+
72
+ }
@@ -0,0 +1,39 @@
1
+ import * as styles from '../css/info-section.module.css';
2
+ import { classnames } from '@massimo-cassandro/js-utilities/index.js';
3
+
4
+ export function infoSection() {
5
+
6
+ return [
7
+ {
8
+ // TODO gestire this.params.stickyInfo
9
+
10
+ className: classnames(styles.infoOuterContainer, this.params.outerInfoExtraClassName),
11
+ children: [
12
+ {
13
+ className: classnames(styles.infoContainer, this.params.infoExtraClassName),
14
+ children: [
15
+ {
16
+ className: styles.resultInfo,
17
+ callback: el => this.params.elements.info = el
18
+ },
19
+ {
20
+ condition: this.params.search,
21
+
22
+ tag: [`div.${styles.search}`, 'input'],
23
+ className: this.params.searchInputAltClassName?? classnames(styles.searchInput, this.params.searchInputExtraClassName),
24
+ callback: el => this.params.elements.searchInput = el,
25
+ attrs: {
26
+ type: 'search',
27
+ title: this.params.searchInputTitle,
28
+ placeholder: this.params.searchInputPlaceholder,
29
+ 'aria-label': this.params.searchInputAriaLabel
30
+ }
31
+ }
32
+ ]
33
+ }
34
+ ]
35
+ }
36
+ ];
37
+
38
+ }
39
+
@@ -0,0 +1,30 @@
1
+ import { ajax_config_default } from './js/defaults.js';
2
+
3
+ export async function initAjaxTable(){
4
+
5
+ try {
6
+
7
+ if(!this.params.ajaxUrl) {
8
+ throw 'Missing `ajaxUrl` parameter';
9
+ }
10
+
11
+ if(this.params.ajaxConfig === null) {
12
+ this.params.ajaxConfig = structuredClone(ajax_config_default);
13
+
14
+ } else {
15
+
16
+ Object.keys(ajax_config_default).forEach(k => {
17
+ this.params.ajaxConfig[k] = {
18
+ ...ajax_config_default[k],
19
+ ...(this.params.ajaxConfig[k]?? {})
20
+ }
21
+ });
22
+ }
23
+
24
+ } catch(e) {
25
+ console.error( e ); // eslint-disable-line
26
+
27
+ }
28
+
29
+
30
+ }
@@ -0,0 +1,18 @@
1
+ export function initStaticTable() {
2
+
3
+ this.params.data = this.params.data.map((row, idx) => this.parseDataRow({
4
+ dataRow: row,
5
+ idx: idx,
6
+ }));
7
+
8
+ if (this.params.footerData.length) {
9
+ this.params.footerData = this.params.footerData.map((row, idx) => this.parseDataRow({
10
+ dataRow: row,
11
+ idx: idx,
12
+ isTbody: false
13
+ }));
14
+ }
15
+
16
+ // first sorting
17
+ this.params.data = this.staticDataSorting(true);
18
+ }