@massimo-cassandro/minimo 0.1.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/README.md +5 -0
- package/package.json +27 -0
- package/src/TODO custom-properties.scss +230 -0
- package/src/components/auto-datatable/auto-datatable.css +355 -0
- package/src/components/auto-datatable/auto-datatable.js +154 -0
- package/src/components/init.js +7 -0
- package/src/components/modal-alert/flash-alerts.js +32 -0
- package/src/components/modal-alert/modal-alert.css +47 -0
- package/src/components/modal-alert/modal-alert.js +85 -0
- package/src/components/modal-alert/svg/check-circle-duotone.svg +1 -0
- package/src/components/modal-alert/svg/info-duotone.svg +1 -0
- package/src/components/modal-alert/svg/question-duotone.svg +1 -0
- package/src/components/modal-alert/svg/warning-duotone.svg +1 -0
- package/src/components/modal-alert/svg/x-circle-duotone.svg +1 -0
- package/src/components/modal-content/modal-content.js +152 -0
- package/src/components/modal-content/modal-content.module.css +142 -0
- package/src/components/recaptcha/recaptcha.css +74 -0
- package/src/components/sf-macro/sf-macro.css +104 -0
- package/src/components/sf-macro/sf-macro.js +44 -0
- package/src/components/vanilla-cookie-consent/cookie-consent.css +20 -0
- package/src/components/vanilla-cookie-consent/cookie-consent.js +76 -0
- package/src/components/vanilla-cookie-consent/render-cookie-list.js +32 -0
- package/src/components/vanilla-cookie-consent/src/cookie-list.js +85 -0
- package/src/components/vanilla-cookie-consent/src/it-translation.js +38 -0
- package/src/components/vanilla-cookie-consent/src/run-analytics.js +54 -0
- package/src/components/vanilla-cookie-consent/src/run-recaptcha.js +71 -0
- package/src/css/alerts.css +95 -0
- package/src/css/anchors.css +40 -0
- package/src/css/buttons/btn-close.css +41 -0
- package/src/css/buttons/buttons.css +187 -0
- package/src/css/buttons/status-buttons.css +107 -0
- package/src/css/container.css +15 -0
- package/src/css/data-formats.css +30 -0
- package/src/css/details.css +19 -0
- package/src/css/dialog-content.css +72 -0
- package/src/css/flex.css +30 -0
- package/src/css/forms/form-edit-info.css +17 -0
- package/src/css/forms/forms.css +315 -0
- package/src/css/forms/select-indicator.svg +3 -0
- package/src/css/grid.css +63 -0
- package/src/css/headings.css +34 -0
- package/src/css/icons.css +114 -0
- package/src/css/inner-nav.css +11 -0
- package/src/css/layout-base.css +11 -0
- package/src/css/overlay.css +11 -0
- package/src/css/reset.css +59 -0
- package/src/css/spinners/TODO spinner-circle.css +54 -0
- package/src/css/spinners/TODO spinner-three-dots.css +14 -0
- package/src/css/spinners/readme.md +1 -0
- package/src/css/spinners/spinner-circle-basic.css +15 -0
- package/src/css/spinners/spinner-trailing-dots.css +51 -0
- package/src/css/spinners/spinner-wrapper.css +20 -0
- package/src/css/svg.css +3 -0
- package/src/css/table.css +66 -0
- package/src/css/text.css +114 -0
- package/src/css/utilities.css +128 -0
- package/src/custom-media-default.css +16 -0
- package/src/custom-properties-default.css +273 -0
- package/src/index.css +49 -0
- package/src/index.js +0 -0
- package/src/js/alert-autoclose.js +9 -0
- package/src/js/create-blurhash-canvas.js +47 -0
- package/src/js/dialog-content.js +82 -0
- package/src/js/dismiss-alerts.js +6 -0
- package/src/js/forms.js +36 -0
- package/src/js/img-viewer-dom-builder.js +196 -0
- package/src/js/inner-nav.js +11 -0
- package/src/js/overlay.js +12 -0
- package/src/js/print-icon.js +51 -0
- package/src/js/spinner.js +30 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/* global process */
|
|
2
|
+
|
|
3
|
+
import 'jquery?as_asset';
|
|
4
|
+
import 'datatables.net/js/jquery.dataTables.js?as_asset';
|
|
5
|
+
|
|
6
|
+
import { spinner } from '@minimo/spinner.js';
|
|
7
|
+
import svg_icons from '@imgs/icone.svg';
|
|
8
|
+
|
|
9
|
+
import { creaDT } from '@massimo-cassandro/auto-datatables-bs5';
|
|
10
|
+
import './auto-datatable.css?inline';
|
|
11
|
+
/*
|
|
12
|
+
per personalizzazioni datatable
|
|
13
|
+
da usare insieme alle opzioni globali
|
|
14
|
+
|
|
15
|
+
import {default_dt_options} from 'path/to/datatable.js';
|
|
16
|
+
import { dt_default_options, dt_classes } from '@massimo-cassandro/auto-datatables-bs5';
|
|
17
|
+
|
|
18
|
+
$.extend( $.fn.dataTable.ext.classes, dt_classes );
|
|
19
|
+
$(__table__).DataTable($.extend(true, {}, dt_default_options, ada_default_dt_options,
|
|
20
|
+
|
|
21
|
+
// opzioni specifiche, se necessarie, ad esempio per tabelle non ajax:
|
|
22
|
+
{
|
|
23
|
+
processing : false,
|
|
24
|
+
serverSide : false,
|
|
25
|
+
pageLength : 25,
|
|
26
|
+
order : [[ 1, 'asc' ]],
|
|
27
|
+
columns : null
|
|
28
|
+
}
|
|
29
|
+
));
|
|
30
|
+
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
export const default_dt_options = {
|
|
34
|
+
|
|
35
|
+
dom:
|
|
36
|
+
// controlli
|
|
37
|
+
'<\'dt-controls\'lf>' +
|
|
38
|
+
// table + processing
|
|
39
|
+
//"<'position-relative'tr>" +
|
|
40
|
+
// table + processing
|
|
41
|
+
'<\'dt-table-wrapper\'t>r' +
|
|
42
|
+
// info + paginazione
|
|
43
|
+
'<\'dt-footer\'ip>',
|
|
44
|
+
|
|
45
|
+
// renderer: 'bootstrap',
|
|
46
|
+
|
|
47
|
+
// serverSide : true,
|
|
48
|
+
// paging : true,
|
|
49
|
+
// pageLength : 25,
|
|
50
|
+
language: {
|
|
51
|
+
processing: spinner(),
|
|
52
|
+
|
|
53
|
+
lengthMenu:
|
|
54
|
+
'<di class"dt-control-label">Mostra</di>' +
|
|
55
|
+
'<div class="dt-control">_MENU_</div>' +
|
|
56
|
+
'<div>record per pagina</div>',
|
|
57
|
+
search:
|
|
58
|
+
'<div class="dt-control-label">Filtra risultati:</div>' +
|
|
59
|
+
'<div class="dt-control">_INPUT_</div>',
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
responsive : true,
|
|
63
|
+
stateSave : process.env.NODE_ENV === 'development',
|
|
64
|
+
stateDuration : -1, //sessionStorage
|
|
65
|
+
// columnDefs : [{
|
|
66
|
+
// orderable : true,
|
|
67
|
+
// targets : ['_all']
|
|
68
|
+
// }],
|
|
69
|
+
// ajax : null,
|
|
70
|
+
// order : [],
|
|
71
|
+
// columns : []
|
|
72
|
+
}, // end dt_options
|
|
73
|
+
|
|
74
|
+
default_cdt_options = {
|
|
75
|
+
|
|
76
|
+
icone: {
|
|
77
|
+
ok : `<svg class="icon text-success"><use href="${svg_icons}#check-circle-bold"></use></svg>`,
|
|
78
|
+
off : `<svg class="icon text-danger"><use href="${svg_icons}#x-circle-bold"></use></svg>`,
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
id_visible_default: true,
|
|
82
|
+
|
|
83
|
+
formats: {
|
|
84
|
+
decimals_class: 'data-dec',
|
|
85
|
+
euro_class: 'data-euro',
|
|
86
|
+
|
|
87
|
+
date: {
|
|
88
|
+
year: '2-digit',
|
|
89
|
+
month: 'short',
|
|
90
|
+
day: 'numeric'
|
|
91
|
+
},
|
|
92
|
+
time: {
|
|
93
|
+
hour12: false,
|
|
94
|
+
hour: '2-digit',
|
|
95
|
+
minute: '2-digit'
|
|
96
|
+
},
|
|
97
|
+
datetime: {
|
|
98
|
+
date: {
|
|
99
|
+
year: 'numeric',
|
|
100
|
+
month: 'short',
|
|
101
|
+
day: 'numeric'
|
|
102
|
+
},
|
|
103
|
+
time: {
|
|
104
|
+
hour12: false,
|
|
105
|
+
hour: '2-digit',
|
|
106
|
+
minute: '2-digit'
|
|
107
|
+
},
|
|
108
|
+
separator: ' ', // date-time separator
|
|
109
|
+
date_wrapper: '<span class="text-nowrap"></span>', // HTML string or null or ''
|
|
110
|
+
time_wrapper: '<small></small>' // HTML string or null or ''
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
use_sorting_arrow: false, // se true viene aggiunta al container la classe `w-arrow` che attiva la visualizzazione delle frecce dell'ordinamento
|
|
115
|
+
|
|
116
|
+
// container_header: '', //'Risultato della ricerca', // se presente aggiunge un header prima della tabella
|
|
117
|
+
|
|
118
|
+
// container_class: 'dt-container', // classe che viene assegnata al div che contiene la tabella
|
|
119
|
+
//container_header_level: 2, // livello gerarchico dell'header (h2, h3, ecc...)
|
|
120
|
+
// table_id: 'table_result',
|
|
121
|
+
table_class: 'table table-bordered'
|
|
122
|
+
//table_caption: '',
|
|
123
|
+
//table_footer: false, // se true aggiunge una riga tfoot alla tabella, da popolare con un callback
|
|
124
|
+
//extra_info:''
|
|
125
|
+
}
|
|
126
|
+
;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* _datatable
|
|
130
|
+
* crea e renderizza un datatable da un flusso json
|
|
131
|
+
*
|
|
132
|
+
*/
|
|
133
|
+
|
|
134
|
+
export function _datatable(container, options = {}) {
|
|
135
|
+
|
|
136
|
+
options.dt_options = {...default_dt_options, ...(options.dt_options?? {}) };
|
|
137
|
+
options.cdt_options = {...default_cdt_options, ...(options.cdt_options?? {}) };
|
|
138
|
+
|
|
139
|
+
container.innerHTML = '<div class="datatable-spinner-wrapper">' +
|
|
140
|
+
spinner() +
|
|
141
|
+
'</div>';
|
|
142
|
+
|
|
143
|
+
creaDT(container, options.cdt_options, options.dt_options, options.dt_columns?? []);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
// utilizza _datatable per generare in modo automatico i datatable
|
|
148
|
+
// negli elementi con classe 'dt-container'
|
|
149
|
+
// i parametri datatable sono ricavati dagli attributi data di '.dt-container'
|
|
150
|
+
|
|
151
|
+
document.querySelectorAll('.dt-container').forEach(container => {
|
|
152
|
+
_datatable(container);
|
|
153
|
+
});
|
|
154
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { mAlert } from './modal-alert.js';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
twig message labels:
|
|
6
|
+
- success
|
|
7
|
+
- notice
|
|
8
|
+
- error
|
|
9
|
+
- warning
|
|
10
|
+
*/
|
|
11
|
+
document.querySelectorAll('.flash-alert').forEach(item => {
|
|
12
|
+
|
|
13
|
+
mAlert({
|
|
14
|
+
// test
|
|
15
|
+
// type : 'confirm',
|
|
16
|
+
// timer: null,
|
|
17
|
+
|
|
18
|
+
type : item.dataset.label === 'notice'? 'warning' : item.dataset.label,
|
|
19
|
+
// title : item.message,
|
|
20
|
+
mes : item.dataset.message
|
|
21
|
+
// use_warning_icon: true, // solo confirm
|
|
22
|
+
// ok_btn_text: 'OK',
|
|
23
|
+
// cancel_btn_text: 'Annulla',
|
|
24
|
+
// callback: function(esito) {}, // confirm: console.log( esito? 'Confermato' : 'Annullato')
|
|
25
|
+
// timer: 4000 // ms
|
|
26
|
+
// extra_btn: '<button type="button" data-confirm-result="annulla" class="stop-btn btn btn-confirm">Annulla</button>',
|
|
27
|
+
// extra_btn_selector: '.stop-btn',
|
|
28
|
+
// extra_btn_focus: true,
|
|
29
|
+
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* NB incluso nel css principale */
|
|
2
|
+
|
|
3
|
+
@import '@massimo-cassandro/modal-alert';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
.modal-alert {
|
|
7
|
+
--malert-success-color: var(--status-success-color);
|
|
8
|
+
--malert-success-color-fg: var(--status-success-fg-color);
|
|
9
|
+
|
|
10
|
+
--malert-info-color: var(--status-info-color);
|
|
11
|
+
--malert-info-color-fg: var(--status-info-fg-color);
|
|
12
|
+
|
|
13
|
+
--malert-warning-color: var(--status-warning-color);
|
|
14
|
+
--malert-warning-color-fg: var(--status-warning-fg-color);
|
|
15
|
+
|
|
16
|
+
--malert-error-color: var(--status-danger-color);
|
|
17
|
+
--malert-error-color-fg: var(--status-danger-fg-color);
|
|
18
|
+
|
|
19
|
+
--malert-confirm-color: var(--status-warning-color);
|
|
20
|
+
--malert-confirm-color-fg: var(--status-warning-fg-color);
|
|
21
|
+
|
|
22
|
+
/* --malert-marks-stroke-width: 6px; */
|
|
23
|
+
--malert-backdrop: rgb(0 0 0 / .3);
|
|
24
|
+
--malert-border-radius: var(--radius-md);
|
|
25
|
+
/* --malert-box-shadow: var(--box-shadow); */
|
|
26
|
+
--malert-heading-font-family: var(--font-family);
|
|
27
|
+
/* --malert-heading-line-height: */
|
|
28
|
+
--malert-heading-font-size: 1.8rem;
|
|
29
|
+
--malert-heading-font-weigth: var(--font-size-base);
|
|
30
|
+
--malert-body-font-family: var(--font-family);
|
|
31
|
+
|
|
32
|
+
top: 50%;
|
|
33
|
+
left: 50%;
|
|
34
|
+
translate: -50% -50%;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
.malert-mark {
|
|
40
|
+
svg {
|
|
41
|
+
width: 7rem;
|
|
42
|
+
max-width: none;
|
|
43
|
+
height: 7rem;
|
|
44
|
+
fill: var(--malert-color-fg);
|
|
45
|
+
stroke: none;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// import './modal-alert.css'; // importato direttamente dal css principale per ottimizzarne l'uso
|
|
2
|
+
|
|
3
|
+
import modalAlert from '@massimo-cassandro/modal-alert';
|
|
4
|
+
|
|
5
|
+
import checkIcon from './svg/check-circle-duotone.svg?inline';
|
|
6
|
+
import infoIcon from './svg/info-duotone.svg?inline';
|
|
7
|
+
import confirmIcon from './svg/question-duotone.svg?inline';
|
|
8
|
+
import warningIcon from './svg/warning-duotone.svg?inline';
|
|
9
|
+
import errorIcon from './svg/x-circle-duotone.svg?inline';
|
|
10
|
+
|
|
11
|
+
const custom_defaults = {
|
|
12
|
+
|
|
13
|
+
globals: {
|
|
14
|
+
onOpen: () => {
|
|
15
|
+
document.body.classList.add('overflow-hidden');
|
|
16
|
+
},
|
|
17
|
+
onClose: () => {
|
|
18
|
+
document.body.classList.remove('overflow-hidden');
|
|
19
|
+
},
|
|
20
|
+
cssFile: null,
|
|
21
|
+
animation: true,
|
|
22
|
+
showMarks: true,
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
success: {
|
|
26
|
+
title: 'Operazione completata',
|
|
27
|
+
mes: null,
|
|
28
|
+
ok_btn_text: 'OK',
|
|
29
|
+
heading_class: null,
|
|
30
|
+
ok_btn_class: 'btn btn-success',
|
|
31
|
+
timer: 4000, // ms
|
|
32
|
+
},
|
|
33
|
+
error: {
|
|
34
|
+
title: 'Si è verificato un errore',
|
|
35
|
+
mes: null,
|
|
36
|
+
ok_btn_text: 'OK',
|
|
37
|
+
heading_class: null,
|
|
38
|
+
text_class: null,
|
|
39
|
+
ok_btn_class: 'btn btn-danger',
|
|
40
|
+
timer: null,
|
|
41
|
+
},
|
|
42
|
+
warning: {
|
|
43
|
+
title: 'Attenzione!',
|
|
44
|
+
mes: null,
|
|
45
|
+
ok_btn_text: 'OK',
|
|
46
|
+
heading_class: null,
|
|
47
|
+
text_class: null,
|
|
48
|
+
ok_btn_class: 'btn btn-warning',
|
|
49
|
+
timer: null,
|
|
50
|
+
},
|
|
51
|
+
info: {
|
|
52
|
+
title: null,
|
|
53
|
+
mes: null,
|
|
54
|
+
ok_btn_text: 'OK',
|
|
55
|
+
heading_class: null,
|
|
56
|
+
text_class: null,
|
|
57
|
+
ok_btn_class: 'btn btn-info',
|
|
58
|
+
timer: null,
|
|
59
|
+
},
|
|
60
|
+
confirm: {
|
|
61
|
+
title: 'Confermi?',
|
|
62
|
+
mes: null,
|
|
63
|
+
ok_btn_text: 'OK',
|
|
64
|
+
cancel_btn_text: 'Cancel',
|
|
65
|
+
cancel_focus: true, // false to give focus to the ok button
|
|
66
|
+
heading_class: null,
|
|
67
|
+
text_class: null,
|
|
68
|
+
ok_btn_class: 'btn btn-warning',
|
|
69
|
+
cancel_btn_class: 'btn btn-outline-secondary',
|
|
70
|
+
callback: null,
|
|
71
|
+
timer: null
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const marks = {
|
|
76
|
+
success: checkIcon,
|
|
77
|
+
error: errorIcon,
|
|
78
|
+
warning: warningIcon,
|
|
79
|
+
info: infoIcon,
|
|
80
|
+
confirm: confirmIcon
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export function mAlert(params) {
|
|
84
|
+
modalAlert(params, custom_defaults, marks);
|
|
85
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="#000000" viewBox="0 0 256 256"><path d="M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z" opacity="0.2"></path><path d="M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z"></path></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="#000000" viewBox="0 0 256 256"><path d="M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z" opacity="0.2"></path><path d="M144,176a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176Zm88-48A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128ZM124,96a12,12,0,1,0-12-12A12,12,0,0,0,124,96Z"></path></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="#000000" viewBox="0 0 256 256"><path d="M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z" opacity="0.2"></path><path d="M140,180a12,12,0,1,1-12-12A12,12,0,0,1,140,180ZM128,72c-22.06,0-40,16.15-40,36v4a8,8,0,0,0,16,0v-4c0-11,10.77-20,24-20s24,9,24,20-10.77,20-24,20a8,8,0,0,0-8,8v8a8,8,0,0,0,16,0v-.72c18.24-3.35,32-17.9,32-35.28C168,88.15,150.06,72,128,72Zm104,56A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z"></path></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="#000000" viewBox="0 0 256 256"><path d="M215.46,216H40.54C27.92,216,20,202.79,26.13,192.09L113.59,40.22c6.3-11,22.52-11,28.82,0l87.46,151.87C236,202.79,228.08,216,215.46,216Z" opacity="0.2"></path><path d="M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM222.93,203.8a8.5,8.5,0,0,1-7.48,4.2H40.55a8.5,8.5,0,0,1-7.48-4.2,7.59,7.59,0,0,1,0-7.72L120.52,44.21a8.75,8.75,0,0,1,15,0l87.45,151.87A7.59,7.59,0,0,1,222.93,203.8ZM120,144V104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,180Z"></path></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="#000000" viewBox="0 0 256 256"><path d="M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z" opacity="0.2"></path><path d="M165.66,101.66,139.31,128l26.35,26.34a8,8,0,0,1-11.32,11.32L128,139.31l-26.34,26.35a8,8,0,0,1-11.32-11.32L116.69,128,90.34,101.66a8,8,0,0,1,11.32-11.32L128,116.69l26.34-26.35a8,8,0,0,1,11.32,11.32ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z"></path></svg>
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { domBuilder, classnames } from '@node_modules/@massimo-cassandro/js-utilities/index.js';
|
|
2
|
+
import { spinner } from '@minimo/spinner.js';
|
|
3
|
+
import * as styles from './modal-content.module.css?inline';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement
|
|
9
|
+
|
|
10
|
+
export function modalContent({
|
|
11
|
+
|
|
12
|
+
/** iframe | content */
|
|
13
|
+
mode = 'iframe',
|
|
14
|
+
|
|
15
|
+
/** dialog extra class */
|
|
16
|
+
dialogClassName = null,
|
|
17
|
+
|
|
18
|
+
/** iframe url */
|
|
19
|
+
iframeUrl = null,
|
|
20
|
+
|
|
21
|
+
/** content string (markup) o array */
|
|
22
|
+
content = null,
|
|
23
|
+
|
|
24
|
+
/** content extra classname */
|
|
25
|
+
contentClassName = null,
|
|
26
|
+
|
|
27
|
+
/** dimensione modal: full, large, medium o small */
|
|
28
|
+
size = 'large',
|
|
29
|
+
|
|
30
|
+
/** padding: std (var(--spacing-md) 0) o none */
|
|
31
|
+
padding = 'std'
|
|
32
|
+
}) {
|
|
33
|
+
|
|
34
|
+
if(!['content', 'iframe'].includes(mode)) {
|
|
35
|
+
throw `modalContent: parametro 'mode' non corretto (${mode})`;
|
|
36
|
+
}
|
|
37
|
+
if(!iframeUrl && mode === 'iframe') {
|
|
38
|
+
throw 'modalContent: parametro `iframeUrl` mancante';
|
|
39
|
+
}
|
|
40
|
+
if(content == null && mode === 'content') {
|
|
41
|
+
throw 'modalContent: parametro `content` mancante';
|
|
42
|
+
}
|
|
43
|
+
if(!['full', 'large', 'medium', 'small'].includes(size)) {
|
|
44
|
+
throw `modalContent: parametro 'size' non corretto (${size})`;
|
|
45
|
+
}
|
|
46
|
+
if(!['std', 'none'].includes(padding)) {
|
|
47
|
+
throw `modalContent: parametro 'padding' non corretto (${padding})`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let dialog_element, dialog_inner, iframe_element = null, content_element = null;
|
|
51
|
+
const iframeLoadEventHandler = () => {
|
|
52
|
+
dialog_element.classList.add(styles.on);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
if(!dialog_element) {
|
|
56
|
+
|
|
57
|
+
domBuilder([
|
|
58
|
+
{
|
|
59
|
+
tag: 'dialog',
|
|
60
|
+
className: styles.dialog,
|
|
61
|
+
attrs: {
|
|
62
|
+
'closedby': 'any'
|
|
63
|
+
},
|
|
64
|
+
children: [
|
|
65
|
+
{
|
|
66
|
+
tag: 'button',
|
|
67
|
+
className: styles.closeButton, // TODO standardizzare close btn
|
|
68
|
+
attrs: {
|
|
69
|
+
'aria-label': 'Chiudi'
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
className: styles.dialogInner,
|
|
74
|
+
children: [
|
|
75
|
+
{
|
|
76
|
+
className: styles.modalSpinner,
|
|
77
|
+
content: spinner({container: null, withOverlay: false })
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
], document.body);
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
dialog_element = document.querySelector(`.${styles.dialog}`);
|
|
88
|
+
dialog_inner = dialog_element.querySelector(`.${styles.dialogInner}`);
|
|
89
|
+
|
|
90
|
+
dialog_element.querySelector(`.${styles.closeButton}`).addEventListener('click', () => {
|
|
91
|
+
dialog_element.close();
|
|
92
|
+
}, false);
|
|
93
|
+
|
|
94
|
+
// listener chiusura
|
|
95
|
+
dialog_element.addEventListener('close', () => {
|
|
96
|
+
|
|
97
|
+
iframe_element?.removeEventListener('load', iframeLoadEventHandler, false);
|
|
98
|
+
iframe_element?.remove();
|
|
99
|
+
content_element?.remove();
|
|
100
|
+
|
|
101
|
+
document.body.classList.remove('overflow-hidden');
|
|
102
|
+
dialog_element.classList.remove(styles.on);
|
|
103
|
+
}, false);
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
// aggiunta classi extra
|
|
109
|
+
dialog_element.className = classnames(
|
|
110
|
+
styles.dialog,
|
|
111
|
+
dialogClassName,
|
|
112
|
+
styles[`size-${size}`],
|
|
113
|
+
styles[`padding-${padding}`]
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
domBuilder([
|
|
117
|
+
{
|
|
118
|
+
condition: mode === 'iframe',
|
|
119
|
+
className: styles.iframeEl,
|
|
120
|
+
tag: 'iframe',
|
|
121
|
+
attrs: {
|
|
122
|
+
src: ''
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
condition: mode === 'content',
|
|
127
|
+
className: classnames(styles.contentEl, contentClassName),
|
|
128
|
+
content: (content && !Array.isArray(content))? content : null,
|
|
129
|
+
children: (content && Array.isArray(content))? content : null
|
|
130
|
+
}
|
|
131
|
+
], dialog_inner);
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
document.body.classList.add('overflow-hidden');
|
|
135
|
+
dialog_element.showModal();
|
|
136
|
+
dialog_element.focus();
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
if(mode === 'iframe') {
|
|
140
|
+
iframe_element = dialog_element.querySelector(`.${styles.iframeEl}`);
|
|
141
|
+
iframe_element.src = iframeUrl;
|
|
142
|
+
|
|
143
|
+
// listener load per i frame
|
|
144
|
+
iframe_element?.addEventListener('load', iframeLoadEventHandler, false);
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
} else if (mode === 'content') {
|
|
148
|
+
content_element = dialog_element.querySelector(`.${styles.contentEl}`);
|
|
149
|
+
dialog_element.classList.add(styles.on);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/* TODO custom props nel file generale */
|
|
2
|
+
/* TODO prevedere opzione con bordo del pulsante di chiusura (NB: si disallinea) */
|
|
3
|
+
/* TODO cambiare icona chiusura con svg? */
|
|
4
|
+
/* TODO aggiungere wrapper intorno a dialogInner (a filo con il dialog) per la scroll bar */
|
|
5
|
+
|
|
6
|
+
.dialog { /* dialog */
|
|
7
|
+
--modal-border-radius: var(--radius-md, 1.2rem);
|
|
8
|
+
position: fixed;
|
|
9
|
+
max-width: 80dvw;
|
|
10
|
+
max-height: 90dvh;
|
|
11
|
+
padding: 0;
|
|
12
|
+
margin: auto;
|
|
13
|
+
overflow: visible;
|
|
14
|
+
background-color: var(--body-bg-color, #fff);
|
|
15
|
+
border: none;
|
|
16
|
+
border-radius: var(--modal-border-radius);
|
|
17
|
+
box-shadow: 0 0 2rem .5rem rgb(0 0 0 / .5);
|
|
18
|
+
transition: scale .2s ease-out;
|
|
19
|
+
scale: 0;
|
|
20
|
+
|
|
21
|
+
/* stylelint-disable selector-class-pattern */
|
|
22
|
+
&.size-full {
|
|
23
|
+
width: 80dvw;
|
|
24
|
+
height: 90dvh;
|
|
25
|
+
}
|
|
26
|
+
/* dimensioni std -> size == 'large' */
|
|
27
|
+
&.size-large {
|
|
28
|
+
width: 50rem; /* 800px */
|
|
29
|
+
height: auto;
|
|
30
|
+
}
|
|
31
|
+
&.size-medium {
|
|
32
|
+
width: 37.5rem; /* 600px */
|
|
33
|
+
height: 37.5rem;
|
|
34
|
+
}
|
|
35
|
+
&.size-small {
|
|
36
|
+
width: 32rem; /* ~500 x 400 */
|
|
37
|
+
height: 25rem;
|
|
38
|
+
}
|
|
39
|
+
/* stylelint-enable selector-class-pattern */
|
|
40
|
+
|
|
41
|
+
&.on {
|
|
42
|
+
scale: 1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&::backdrop {
|
|
46
|
+
overscroll-behavior: contain;
|
|
47
|
+
background-color: rgb(0 0 0 / .7);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.dialogInner {
|
|
53
|
+
width: 100%;
|
|
54
|
+
height: 100%;
|
|
55
|
+
padding-inline-end: var(--spacing-md);
|
|
56
|
+
overflow-x: hidden;
|
|
57
|
+
overflow-y: auto;
|
|
58
|
+
/* scrollbar-gutter: stable; */
|
|
59
|
+
border-radius: var(--modal-border-radius);
|
|
60
|
+
|
|
61
|
+
/* stylelint-disable selector-class-pattern */
|
|
62
|
+
.padding-std & {
|
|
63
|
+
padding: var(--spacing-md) 0;
|
|
64
|
+
}
|
|
65
|
+
.padding-none & {
|
|
66
|
+
padding: 0;
|
|
67
|
+
}
|
|
68
|
+
/* stylelint-enable selector-class-pattern */
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.modalSpinner {
|
|
72
|
+
position: relative;
|
|
73
|
+
padding-block-start: var(--spacing-2xl);
|
|
74
|
+
|
|
75
|
+
.dialog.on & {
|
|
76
|
+
display: none;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.iframeEl, .contentEl {
|
|
81
|
+
width: 100%;
|
|
82
|
+
overscroll-behavior: contain;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.iframeEl {
|
|
86
|
+
height: 100%;
|
|
87
|
+
padding: 0;
|
|
88
|
+
margin: 0;
|
|
89
|
+
border: none;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.contentEl {
|
|
93
|
+
min-height: 100%;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.closeButton {
|
|
97
|
+
--btn-color: var(--secondary-fg, #000);
|
|
98
|
+
--btn-bg-color: var(--secondary, #fff);
|
|
99
|
+
--btn-hover-color: var(--secondary, #fff);
|
|
100
|
+
--btn-hover-bg-color: var(--secondary-fg, #000);
|
|
101
|
+
--icon-size: 2.5rem;
|
|
102
|
+
--btn-padding: var(--spacing-xs, .5rem);
|
|
103
|
+
--icon-bars-thickness: 3px;
|
|
104
|
+
|
|
105
|
+
position: absolute;
|
|
106
|
+
top: calc(-1 * var(--icon-size) / 3);
|
|
107
|
+
right: calc(-1 * var(--icon-size) / 3);
|
|
108
|
+
display: block;
|
|
109
|
+
width: var(--icon-size);
|
|
110
|
+
height: var(--icon-size);
|
|
111
|
+
padding: var(--btn-padding);
|
|
112
|
+
color: var(--btn-color);
|
|
113
|
+
cursor: pointer;
|
|
114
|
+
background-color: var(--btn-bg-color);
|
|
115
|
+
/* border: var(--icon-bars-thickness) solid currentColor; */
|
|
116
|
+
border: none;
|
|
117
|
+
border-radius: 50%;
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
&:hover {
|
|
121
|
+
--btn-color: var(--btn-hover-color);
|
|
122
|
+
--btn-bg-color: var(--btn-hover-bg-color);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
&::before, &::after {
|
|
126
|
+
position: absolute;
|
|
127
|
+
top: 50%;
|
|
128
|
+
left: var(--btn-padding);
|
|
129
|
+
display: block;
|
|
130
|
+
width: calc(var(--icon-size) - (var(--btn-padding) * 2));
|
|
131
|
+
height: var(--icon-bars-thickness);
|
|
132
|
+
content: '';
|
|
133
|
+
background: currentColor;
|
|
134
|
+
}
|
|
135
|
+
&::before {
|
|
136
|
+
transform: translateY(-50%) rotate(45deg);
|
|
137
|
+
}
|
|
138
|
+
&::after {
|
|
139
|
+
transform: translateY(-50%) rotate(-45deg);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|