@massimo-cassandro/minimo 1.27.2 → 1.27.4
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/charts/src/helpers/chart-utils.js +7 -7
- package/charts/src/rating-display/index.js +25 -25
- package/package.json +1 -1
- package/src/components/autocomplete/autocomplete-engine.js +2 -3
- package/src/components/modal-alert/modal-alert.js +34 -34
- package/src/components/modal-popup/modal-popup.js +21 -21
- package/src/components/overlay/overlay.js +3 -3
- package/src/components/sf-macro/sf-macro.js +24 -9
- package/src/components/slide-up-down-toggle/slide-up-down-toggle.js +9 -9
- package/src/components/snackbar/snackbar.js +6 -6
- package/src/components/unsplash-page/unsplash-page.js +4 -4
- package/src/utilities/better-text.js +1 -1
- package/src/utilities/cookies.js +3 -3
- package/src/utilities/dom-builder/dom-builder.js +8 -8
- package/src/utilities/dom-builder-helpers/form-tags.js +45 -45
- package/src/utilities/dom-builder-helpers/picture-tag.js +16 -16
- package/src/utilities/enable-submit-btns.js +1 -1
- package/src/utilities/generate-pwd.js +1 -1
- package/src/utilities/linked-dates.js +1 -1
- package/src/utilities/parse-file-size.js +1 -1
- package/src/utilities/relative-date.js +24 -24
- package/src/utilities/truncate-string.js +1 -1
- package/src/web-components/s-datatable-component/s-datatable-component.js +7 -7
- package/src/web-components/s-datatable-component/src/search-method.js +4 -4
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* Tronca un numero a un numero specifico di decimali.
|
|
7
7
|
* @param {number} number - Il numero da troncare.
|
|
8
|
-
* @param {number} [decimals=4] - Il numero di decimali da mantenere.
|
|
8
|
+
* @param {number} [decimals=4] - Il numero di decimali da mantenere. (default: 4)
|
|
9
9
|
* @returns {number} Il numero troncato.
|
|
10
10
|
*/
|
|
11
11
|
export function truncateDecimal(number, decimals = 4) {
|
|
@@ -50,14 +50,14 @@ export function polarToCartesianString(degrees_angle, cx, cy, circleRadius) {
|
|
|
50
50
|
* Lo `start_angle` è il punto di inizio e `percentage` è la lunghezza percentuale dell'arco rispetto a `max_angle`.
|
|
51
51
|
*
|
|
52
52
|
* @param {Object} options - Opzioni di configurazione.
|
|
53
|
-
* @param {number} [options.start_angle=0] - Angolo di partenza in gradi.
|
|
53
|
+
* @param {number} [options.start_angle=0] - Angolo di partenza in gradi. (default: 0)
|
|
54
54
|
* @param {number|null} options.percentage - Lunghezza dell'arco in percentuale (da 0 a 1).
|
|
55
|
-
* @param {number} [options.max_arc=360] - L'estensione massima dell'arco in gradi.
|
|
55
|
+
* @param {number} [options.max_arc=360] - L'estensione massima dell'arco in gradi. (default: 360)
|
|
56
56
|
* @param {Object} options.center - Coordinate del centro.
|
|
57
57
|
* @param {number|null} options.center.x - Coordinata X del centro.
|
|
58
58
|
* @param {number|null} options.center.y - Coordinata Y del centro.
|
|
59
59
|
* @param {number|null} options.radius - Raggio dell'arco.
|
|
60
|
-
* @param {boolean} [options.clockwise=true] - Direzione oraria se true.
|
|
60
|
+
* @param {boolean} [options.clockwise=true] - Direzione oraria se true. (default: true)
|
|
61
61
|
* @returns {{arc_length: number, start: {x: number, y: number}, end: {x: number, y: number}}} Coordinate di inizio, fine e lunghezza.
|
|
62
62
|
*/
|
|
63
63
|
export function calcArcCoords(options) {
|
|
@@ -141,9 +141,9 @@ export function getElementFromContainer(container) {
|
|
|
141
141
|
/**
|
|
142
142
|
* Analizza il contenitore e restituisce informazioni sulle sue dimensioni, eseguendo alcune azioni di base.
|
|
143
143
|
* @param {Object} params - Parametri di input.
|
|
144
|
-
* @param {string|Element|null} [params.container=null] - Il contenitore del grafico.
|
|
145
|
-
* @param {number|null} [params.width=null] - Larghezza predefinita (opzionale).
|
|
146
|
-
* @param {number|null} [params.height=null] - Altezza predefinita (opzionale).
|
|
144
|
+
* @param {string|Element|null} [params.container=null] - Il contenitore del grafico. (default: null)
|
|
145
|
+
* @param {number|null} [params.width=null] - Larghezza predefinita (opzionale). (default: null)
|
|
146
|
+
* @param {number|null} [params.height=null] - Altezza predefinita (opzionale). (default: null)
|
|
147
147
|
* @returns {[Element|null, number|null, number|null]} Un array contenente l'elemento, la larghezza e l'altezza.
|
|
148
148
|
*/
|
|
149
149
|
export function parseContainer({ container = null, width = null, height = null }) {
|
|
@@ -15,115 +15,115 @@ import { rad30, getDisplayBackgroundPath, calcolaPuntoInterno, normalizeAngle, i
|
|
|
15
15
|
export async function ratingDisplay({
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* @param {boolean} [debug=false] - Modalità debug: se attiva mostra i riferimenti grafici (centri di rotazione, angoli) e i metadati data-debug-info.
|
|
18
|
+
* @param {boolean} [debug=false] - Modalità debug: se attiva mostra i riferimenti grafici (centri di rotazione, angoli) e i metadati data-debug-info. (default: false)
|
|
19
19
|
*/
|
|
20
20
|
debug = false,
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* @param {HTMLElement|string|null} [container=null] - Elemento DOM o selettore CSS dove iniettare il grafico. Se null, la funzione restituisce l'SVG come stringa.
|
|
23
|
+
* @param {HTMLElement|string|null} [container=null] - Elemento DOM o selettore CSS dove iniettare il grafico. Se null, la funzione restituisce l'SVG come stringa. (default: null)
|
|
24
24
|
*/
|
|
25
25
|
container = null,
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* @param {number|null} [width=null] - Larghezza del documento SVG. Obbligatoria se eseguito in ambiente Node.
|
|
28
|
+
* @param {number|null} [width=null] - Larghezza del documento SVG. Obbligatoria se eseguito in ambiente Node. (default: null)
|
|
29
29
|
*/
|
|
30
30
|
width = null,
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* @param {number|function} [centerGap=r=>r/8] - Distanza tra il centro della circonferenza esterna e ciascuna delle circonferenze interne (*dA* e *dB* nella documentzione).
|
|
34
|
-
* Numero o funzione del raggio dato.
|
|
34
|
+
* Numero o funzione del raggio dato. (default: r => r/9)
|
|
35
35
|
*/
|
|
36
36
|
centerGap = r => r/9,
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* @param {number|function} [scaleEndThickness=r=>r/8] - Spessore finale della scala (indicato con *s* nella documentazione).
|
|
40
|
-
* Numero o funzione del raggio dato.
|
|
40
|
+
* Numero o funzione del raggio dato. (default: r => r/5)
|
|
41
41
|
*/
|
|
42
42
|
scaleEndThickness = r => r/5,
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
* @param {number} [portions=5] - Numero di porzioni (sezioni di colore) in cui è diviso il tachimetro.
|
|
45
|
+
* @param {number} [portions=5] - Numero di porzioni (sezioni di colore) in cui è diviso il tachimetro. (default: 5)
|
|
46
46
|
*/
|
|
47
47
|
portions = 5,
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* @param {number} [portionGap=10] - Distanza tra una porzione e la successiva.
|
|
51
51
|
* Corrisponde all'angolo in gradi tra le due semirette passanti per il centro della circonferenza esterna e i segmenti laterali delle porzioni.
|
|
52
|
-
* Indicato con *gamma* nella documentazione
|
|
52
|
+
* Indicato con *gamma* nella documentazione (default: 2)
|
|
53
53
|
*/
|
|
54
54
|
portionGap = 2,
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
|
-
* @param {Object} [svgAttrs={}] - Attributi aggiuntivi (es. class, id) da applicare al tag SVG radice.
|
|
57
|
+
* @param {Object} [svgAttrs={}] - Attributi aggiuntivi (es. class, id) da applicare al tag SVG radice. (default: {})
|
|
58
58
|
*/
|
|
59
59
|
svgAttrs = {},
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
* @param {Object} [displayBackgroundAttrs] - Attributi grafici (fill, stroke) per l'arco di sfondo esterno.
|
|
62
|
+
* @param {Object} [displayBackgroundAttrs] - Attributi grafici (fill, stroke) per l'arco di sfondo esterno. (default: { fill: 'none' })
|
|
63
63
|
*/
|
|
64
64
|
displayBackgroundAttrs = {
|
|
65
65
|
fill: 'none',
|
|
66
66
|
},
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
|
-
* @param {number} [displayPadding=10] - Spazio tra il bordo del background e gli elementi interni del display.
|
|
69
|
+
* @param {number} [displayPadding=10] - Spazio tra il bordo del background e gli elementi interni del display. (default: 10)
|
|
70
70
|
*/
|
|
71
71
|
displayPadding = 10,
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
* @param {number} [scaleStartValue=0] - Valore minimo della scala numerica da cui parte il calcolo della posizione.
|
|
74
|
+
* @param {number} [scaleStartValue=0] - Valore minimo della scala numerica da cui parte il calcolo della posizione. (default: 0)
|
|
75
75
|
*/
|
|
76
76
|
scaleStartValue = 0,
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
|
-
* @param {boolean} [rodPositionForceCenter=false] - Se true, l'asticella punta sempre al centro della fascia; se false, segue la proporzione del valore esatto.
|
|
79
|
+
* @param {boolean} [rodPositionForceCenter=false] - Se true, l'asticella punta sempre al centro della fascia; se false, segue la proporzione del valore esatto. (default: false)
|
|
80
80
|
*/
|
|
81
81
|
rodPositionForceCenter = false,
|
|
82
82
|
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
|
-
* @param {number|null} [value=null] - Valore numerico da rappresentare. Determina il colore e la posizione dell'asticella.
|
|
85
|
+
* @param {number|null} [value=null] - Valore numerico da rappresentare. Determina il colore e la posizione dell'asticella. (default: null)
|
|
86
86
|
*/
|
|
87
87
|
value = null,
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
|
-
* @param {string[]|null} [scaleColors=null] - Array di colori per le porzioni della scala. Se null, usa i colori di default della chartInstance.
|
|
90
|
+
* @param {string[]|null} [scaleColors=null] - Array di colori per le porzioni della scala. Se null, usa i colori di default della chartInstance. (default: null)
|
|
91
91
|
*/
|
|
92
92
|
scaleColors = null,
|
|
93
93
|
|
|
94
|
-
/** * @param {Object|null} [scaleAttrs=null] - Attributi SVG aggiuntivi applicati ai percorsi (path) delle porzioni della scala.
|
|
94
|
+
/** * @param {Object|null} [scaleAttrs=null] - Attributi SVG aggiuntivi applicati ai percorsi (path) delle porzioni della scala. (default: null)
|
|
95
95
|
*/
|
|
96
96
|
scaleAttrs = null,
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
|
-
* @param {string|null} [scaleTicksColor=null] - Colore dei segni di separazione tra le porzioni. Se null, usa lo stesso colore della porzione adiacente.
|
|
99
|
+
* @param {string|null} [scaleTicksColor=null] - Colore dei segni di separazione tra le porzioni. Se null, usa lo stesso colore della porzione adiacente. (default: null)
|
|
100
100
|
*/
|
|
101
101
|
scaleTicksColor = null,
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
|
-
* @param {Object} [rodAttrs] - Attributi per l'asticella indicatrice e il suo anello centrale.
|
|
104
|
+
* @param {Object} [rodAttrs] - Attributi per l'asticella indicatrice e il suo anello centrale. (default: { fill: '#000' })
|
|
105
105
|
*/
|
|
106
106
|
rodAttrs = {
|
|
107
107
|
fill: '#000'
|
|
108
108
|
},
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
|
-
* @param {Object[]|null} [displayLabel=null] - Testo centrale sotto l'asticella. Array di max 2 oggetti: {label, font, fill, fontFilePath}.
|
|
111
|
+
* @param {Object[]|null} [displayLabel=null] - Testo centrale sotto l'asticella. Array di max 2 oggetti: {label, font, fill, fontFilePath}. (default: null)
|
|
112
112
|
*/
|
|
113
113
|
displayLabel = null,
|
|
114
114
|
|
|
115
115
|
/**
|
|
116
|
-
* @param {number} [displayLabelTopMargin=4] - Distanza verticale tra l'anello dell'asticella e la prima riga dell'etichetta.
|
|
116
|
+
* @param {number} [displayLabelTopMargin=4] - Distanza verticale tra l'anello dell'asticella e la prima riga dell'etichetta. (default: 4)
|
|
117
117
|
*/
|
|
118
118
|
displayLabelTopMargin = 4,
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
|
-
* @param {number} [displayLabelRowGap=2] - Spazio verticale tra la prima e la seconda riga dell'etichetta principale.
|
|
121
|
+
* @param {number} [displayLabelRowGap=2] - Spazio verticale tra la prima e la seconda riga dell'etichetta principale. (default: 2)
|
|
122
122
|
*/
|
|
123
123
|
displayLabelRowGap = 2,
|
|
124
124
|
|
|
125
125
|
/**
|
|
126
|
-
* @param {Object[]|null} [miniDisplay=null] - Configurazione mini display secondari (max 2). Srray di uno o due oggetti
|
|
126
|
+
* @param {Object[]|null} [miniDisplay=null] - Configurazione mini display secondari (max 2). Srray di uno o due oggetti (default: null)
|
|
127
127
|
* @param {string} miniDisplay[].position - Posizione: 'sx' | 'dx' (alias: 'left' | 'right').
|
|
128
128
|
* @param {number} miniDisplay[].value - Valore numerico da rappresentare.
|
|
129
129
|
* @param {string} miniDisplay[].type - Tipo di visualizzazione: 'gauge' (tachimetro) o 'value' (testo di `value`).
|
|
@@ -135,22 +135,22 @@ export async function ratingDisplay({
|
|
|
135
135
|
miniDisplay = null,
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
|
-
* @param {number} [miniDisplayTopMargin=0] - Distanza verticale tra la base del display principale e l'inizio dei mini display.
|
|
138
|
+
* @param {number} [miniDisplayTopMargin=0] - Distanza verticale tra la base del display principale e l'inizio dei mini display. (default: 0)
|
|
139
139
|
*/
|
|
140
140
|
miniDisplayTopMargin = 0,
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
|
-
* @param {number} [miniDisplayLabelTopMargin=0] - Distanza verticale tra la base dell'arco del mini display e le sue etichette.
|
|
143
|
+
* @param {number} [miniDisplayLabelTopMargin=0] - Distanza verticale tra la base dell'arco del mini display e le sue etichette. (default: 0)
|
|
144
144
|
*/
|
|
145
145
|
miniDisplayLabelTopMargin = 0,
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
|
-
* @param {number} [miniDisplayLabelRowGap=2] - Distanza tra le righe di testo (mdLabel) del mini display.
|
|
148
|
+
* @param {number} [miniDisplayLabelRowGap=2] - Distanza tra le righe di testo (mdLabel) del mini display. (default: 2)
|
|
149
149
|
*/
|
|
150
150
|
miniDisplayLabelRowGap = 2,
|
|
151
151
|
|
|
152
152
|
/**
|
|
153
|
-
* @param {boolean} [animation=false] - Se true, abilita l'animazione dell'asticella (richiede implementazione specifica).
|
|
153
|
+
* @param {boolean} [animation=false] - Se true, abilita l'animazione dell'asticella (richiede implementazione specifica). (default: false)
|
|
154
154
|
*/
|
|
155
155
|
animation = false,
|
|
156
156
|
|
package/package.json
CHANGED
|
@@ -98,7 +98,7 @@ export const ac_default_params = {
|
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
100
|
* Initialises an autocomplete field using @tarekraafat/autocomplete.js.
|
|
101
|
-
* @param {Record<string, any>} [params={}]
|
|
101
|
+
* @param {Record<string, any>} [params={}] (default: {})
|
|
102
102
|
* @returns {void}
|
|
103
103
|
*/
|
|
104
104
|
export default function (params = {}) {
|
|
@@ -284,8 +284,7 @@ export default function (params = {}) {
|
|
|
284
284
|
}
|
|
285
285
|
}); // end autoComplete
|
|
286
286
|
|
|
287
|
-
// TODO
|
|
288
|
-
// improve and make the callback invocation more efficient
|
|
287
|
+
// TODO improve and make the callback invocation more efficient
|
|
289
288
|
|
|
290
289
|
// reset hidden field when the autocomplete value is cleared or mismatched
|
|
291
290
|
const check_ac = () => {
|
|
@@ -100,26 +100,26 @@ const defaults = {
|
|
|
100
100
|
* @typedef {Object} ModalAlertParams
|
|
101
101
|
* @property {string} [type] - Dialog type: `success`, `error`, `warning`, `info`, or `confirm`.
|
|
102
102
|
* @property {string | null} [title] - title text
|
|
103
|
-
* @property {string | null} [mes] - text message (plain or html)
|
|
104
|
-
* @property {((arg?: *) => void) | null} [callback] - optional callback dialog after user choice
|
|
105
|
-
* @property {number | null} [timer] - timer for autoclose (ms). `null` for disable
|
|
106
|
-
* @property {(() => void) | null} [onOpen] - optional callback on dialog open
|
|
107
|
-
* @property {(() => void) | null} [onClose] - optional callback on dialog close
|
|
108
|
-
* @property {string | null} [extraClass] - optional dialog extra class
|
|
109
|
-
* @property {string} [okBtnText] - text for 'ok' button
|
|
103
|
+
* @property {string | null} [mes] - text message (plain or html) (default: null)
|
|
104
|
+
* @property {((arg?: *) => void) | null} [callback] - optional callback dialog after user choice (default: null)
|
|
105
|
+
* @property {number | null} [timer] - timer for autoclose (ms). `null` for disable (default: null, except type 'success' which defaults to 4000)
|
|
106
|
+
* @property {(() => void) | null} [onOpen] - optional callback on dialog open (default: null)
|
|
107
|
+
* @property {(() => void) | null} [onClose] - optional callback on dialog close (default: null)
|
|
108
|
+
* @property {string | null} [extraClass] - optional dialog extra class (default: null)
|
|
109
|
+
* @property {string} [okBtnText] - text for 'ok' button (default: 'OK')
|
|
110
110
|
* @property {string} [okBtnClass] - alternative class for 'ok' button. It replaces the default one
|
|
111
|
-
* @property {string} [cancelBtnText] - text for 'cancel' button
|
|
111
|
+
* @property {string} [cancelBtnText] - text for 'cancel' button (default: 'Annulla', type 'confirm' only)
|
|
112
112
|
* @property {string} [cancelBtnClass] - alternative class for 'cancel' button. It replaces the default one
|
|
113
|
-
* @property {boolean} [cancelBtnFocus] - true if the cancel button should be focused when the dialog box opens. It has no effect if an extraBtn is set
|
|
114
|
-
* @property {string | null} [headingClass] - optional extra class for heading
|
|
115
|
-
* @property {DomBuilderItem | null} [extraBtn] - optional extra button (as domBuilder object)
|
|
116
|
-
* @property {boolean} [extraBtnFocus] - true if the extra button should be focused when the dialog box opens (overrides any focus assigned to the 'cancel' button)
|
|
117
|
-
* @property {boolean} [animation] - if true, dialog will be animated
|
|
118
|
-
* @property {boolean} [showMarks] - if true, mark iconswill be showed
|
|
119
|
-
* @property {string | null} [textClass] - optional extra class for text
|
|
113
|
+
* @property {boolean} [cancelBtnFocus] - true if the cancel button should be focused when the dialog box opens. It has no effect if an extraBtn is set (default: true, type 'confirm' only)
|
|
114
|
+
* @property {string | null} [headingClass] - optional extra class for heading (default: null)
|
|
115
|
+
* @property {DomBuilderItem | null} [extraBtn] - optional extra button (as domBuilder object) (default: null)
|
|
116
|
+
* @property {boolean} [extraBtnFocus] - true if the extra button should be focused when the dialog box opens (overrides any focus assigned to the 'cancel' button) (default: true)
|
|
117
|
+
* @property {boolean} [animation] - if true, dialog will be animated (default: true)
|
|
118
|
+
* @property {boolean} [showMarks] - if true, mark iconswill be showed (default: true)
|
|
119
|
+
* @property {string | null} [textClass] - optional extra class for text (default: null)
|
|
120
120
|
* @property {string | null} [icon] - Icon markup used for the dialog; defaults to the type's icon.
|
|
121
121
|
* @property {string | null} [altIcon] - Alternate icon markup, used instead of `icon` when `useAltIcon` is `true`.
|
|
122
|
-
* @property {boolean} [useAltIcon] - When `true`, uses `altIcon` instead of `icon` (e.g. the `danger` icon on a `warning` dialog, or the `warning` icon on a `confirm` dialog).
|
|
122
|
+
* @property {boolean} [useAltIcon] - When `true`, uses `altIcon` instead of `icon` (e.g. the `danger` icon on a `warning` dialog, or the `warning` icon on a `confirm` dialog). (default: false)
|
|
123
123
|
*/
|
|
124
124
|
|
|
125
125
|
/**
|
|
@@ -133,29 +133,29 @@ const defaults = {
|
|
|
133
133
|
* The base param type below is intentionally `object` (not `ModalAlertParams`): TypeScript only
|
|
134
134
|
* expands dotted `@param` properties (needed for editor IntelliSense to list each property) when
|
|
135
135
|
* the base type is the literal `object`; a named typedef there would error (TS8032).
|
|
136
|
-
* @param {object} [params] - Dialog parameters (merged with defaults by type).
|
|
136
|
+
* @param {object} [params] - Dialog parameters (merged with defaults by type). (default: {})
|
|
137
137
|
* @param {string} [params.type] - Dialog type: `success`, `error`, `warning`, `info`, or `confirm`.
|
|
138
|
-
* @param {string | null} [params.extraClass] - optional dialog extra class
|
|
139
|
-
* @param {(() => void) | null} [params.onOpen] - optional callback on dialog open
|
|
140
|
-
* @param {(() => void) | null} [params.onClose] - optional callback on dialog close
|
|
141
|
-
* @param {boolean} [params.animation] - if true, dialog will be animated
|
|
142
|
-
* @param {boolean} [params.showMarks] - if true, mark icons will be showed
|
|
143
|
-
* @param {((arg?: *) => void) | null} [params.callback] - optional callback dialog after user choice
|
|
144
|
-
* @param {number | null} [params.timer] - timer for autoclose (ms). `null` for disable
|
|
138
|
+
* @param {string | null} [params.extraClass] - optional dialog extra class (default: null)
|
|
139
|
+
* @param {(() => void) | null} [params.onOpen] - optional callback on dialog open (default: null)
|
|
140
|
+
* @param {(() => void) | null} [params.onClose] - optional callback on dialog close (default: null)
|
|
141
|
+
* @param {boolean} [params.animation] - if true, dialog will be animated (default: true)
|
|
142
|
+
* @param {boolean} [params.showMarks] - if true, mark icons will be showed (default: true)
|
|
143
|
+
* @param {((arg?: *) => void) | null} [params.callback] - optional callback dialog after user choice (default: null)
|
|
144
|
+
* @param {number | null} [params.timer] - timer for autoclose (ms). `null` for disable (default: null, except type 'success' which defaults to 4000)
|
|
145
145
|
* @param {string | null} [params.title] - title text
|
|
146
|
-
* @param {string | null} [params.mes] - text message (plain or html)
|
|
147
|
-
* @param {string | null} [params.headingClass] - optional extra class for heading
|
|
148
|
-
* @param {string | null} [params.textClass] - optional extra class for text
|
|
146
|
+
* @param {string | null} [params.mes] - text message (plain or html) (default: null)
|
|
147
|
+
* @param {string | null} [params.headingClass] - optional extra class for heading (default: null)
|
|
148
|
+
* @param {string | null} [params.textClass] - optional extra class for text (default: null)
|
|
149
149
|
* @param {string | null} [params.icon] - Icon markup used for the dialog; defaults to the type's icon.
|
|
150
150
|
* @param {string | null} [params.altIcon] - Alternate icon markup, used instead of `icon` when `useAltIcon` is `true`.
|
|
151
|
-
* @param {boolean} [params.useAltIcon] - When `true`, uses `altIcon` instead of `icon` (e.g. the `danger` icon on a `warning` dialog, or the `warning` icon on a `confirm` dialog).
|
|
152
|
-
* @param {DomBuilderItem | null} [params.extraBtn] - optional extra button (as domBuilder object)
|
|
153
|
-
* @param {boolean} [params.extraBtnFocus] - true if the extra button should be focused when the dialog box opens (overrides any focus assigned to the 'cancel' button)
|
|
154
|
-
* @param {string} [params.okBtnText] - text for 'ok' button
|
|
151
|
+
* @param {boolean} [params.useAltIcon] - When `true`, uses `altIcon` instead of `icon` (e.g. the `danger` icon on a `warning` dialog, or the `warning` icon on a `confirm` dialog). (default: false)
|
|
152
|
+
* @param {DomBuilderItem | null} [params.extraBtn] - optional extra button (as domBuilder object) (default: null)
|
|
153
|
+
* @param {boolean} [params.extraBtnFocus] - true if the extra button should be focused when the dialog box opens (overrides any focus assigned to the 'cancel' button) (default: true)
|
|
154
|
+
* @param {string} [params.okBtnText] - text for 'ok' button (default: 'OK')
|
|
155
155
|
* @param {string} [params.okBtnClass] - alternative class for 'ok' button. It replaces the default one
|
|
156
|
-
* @param {string} [params.cancelBtnText] - text for 'cancel' button
|
|
156
|
+
* @param {string} [params.cancelBtnText] - text for 'cancel' button (default: 'Annulla', type 'confirm' only)
|
|
157
157
|
* @param {string} [params.cancelBtnClass] - alternative class for 'cancel' button. It replaces the default one
|
|
158
|
-
* @param {boolean} [params.cancelBtnFocus] - true if the cancel button should be focused when the dialog box opens. It has no effect if an extraBtn is set
|
|
158
|
+
* @param {boolean} [params.cancelBtnFocus] - true if the cancel button should be focused when the dialog box opens. It has no effect if an extraBtn is set (default: true, type 'confirm' only)
|
|
159
159
|
* @returns {Promise<string | boolean | undefined>} Resolves when the dialog closes. If the
|
|
160
160
|
* dismissing button has a `data-malert-result` attribute, that string is used; otherwise, for
|
|
161
161
|
* `confirm` dialogs, resolves `true`/`false` for the OK/Cancel button; otherwise `undefined`.
|
|
@@ -311,7 +311,7 @@ export function modalAlert(params = {}) {
|
|
|
311
311
|
let timeoutID;
|
|
312
312
|
|
|
313
313
|
/**
|
|
314
|
-
* @param {HTMLElement | null} [btn]
|
|
314
|
+
* @param {HTMLElement | null} [btn] (default: null)
|
|
315
315
|
* @returns {void}
|
|
316
316
|
*/
|
|
317
317
|
const dialogDismiss = (btn = null) => {
|
|
@@ -39,27 +39,27 @@ function closeDialog(el) {
|
|
|
39
39
|
* When multiple options conflict, the first applicable one in the list above takes precedence.
|
|
40
40
|
*
|
|
41
41
|
* @param {Object} params
|
|
42
|
-
* @param {string | null} [params.dialogExtraClassName=null] - Extra class added to the dialog element.
|
|
43
|
-
* @param {string | DomBuilderItem[] | null} [params.content=null] - Plain text, HTML, or a domBuilder array.
|
|
44
|
-
* @param {string | null} [params.contentExtraClassName=null] - Extra class added to the content wrapper.
|
|
45
|
-
* @param {HTMLElement | null} [params.triggerElement=null] - Optional element that triggered the popup; when set, `aria-haspopup`, `aria-controls` and `aria-expanded` are managed on it.
|
|
46
|
-
* @param {boolean} [params.addFocus=true] - if true, dialog receives focus after opening
|
|
47
|
-
* @param {string | null} [params.headerExtraClassName=null] - Extra class added to the header wrapper.
|
|
48
|
-
* @param {string | null} [params.footerExtraClassName=null] - Extra class added to the footer wrapper.
|
|
49
|
-
* @param {string | number | null} [params.dialogWidth=null] - optional dialog width value - if set, overrides main css custom prop
|
|
50
|
-
* @param {string | number | null} [params.dialogMinWidth=null] - optional dialog min-width value - if set, overrides main css custom prop
|
|
51
|
-
* @param {string | number | null} [params.dialogMaxWidth=null] - optional dialog max-width value - if set, overrides main css custom prop
|
|
52
|
-
* @param {string | number | null} [params.dialogHeight=null] - optional dialog height value - if set, overrides main css custom prop
|
|
53
|
-
* @param {string | number | null} [params.dialogMinHeight=null] - optional dialog min-height value - if set, overrides main css custom prop
|
|
54
|
-
* @param {string | number | null} [params.dialogMaxHeight=null] - optional dialog max-height value - if set, overrides main css custom prop
|
|
55
|
-
* @param {string | null} [params.iframeUrl=null] - URL to load in an iframe.
|
|
56
|
-
* @param {string | null} [params.ajaxUrl=null] - URL for Ajax content loading.
|
|
57
|
-
* @param {((el: HTMLDialogElement) => void) | null} [params.openCallback=null] - Called with the dialog element after opening, receives the dialog element (`openCallback(dialogEl)`).
|
|
58
|
-
* @param {((el: HTMLDialogElement) => void) | null} [params.closeCallback=null] - Called with the dialog element just before it is removed, receives the dialog element (`closeCallback(dialogEl)`). NB: `dialogEl` is removed immediately after closing.
|
|
59
|
-
* @param {((data: *, el: Element) => void) | null} [params.ajaxCallback=null] - Called with the Ajax response and the content element.
|
|
60
|
-
* @param {boolean} [params.addScrollbarPadding=false] - Adds right padding to compensate for the scrollbar.
|
|
61
|
-
* @param {string | DomBuilderItem[] | null} [params.headerContent=null] - Header content: plain text, HTML, or a domBuilder array.
|
|
62
|
-
* @param {string | DomBuilderItem[] | null} [params.footerContent=null] - Footer content: plain text, HTML, or a domBuilder array.
|
|
42
|
+
* @param {string | null} [params.dialogExtraClassName=null] - Extra class added to the dialog element. (default: null)
|
|
43
|
+
* @param {string | DomBuilderItem[] | null} [params.content=null] - Plain text, HTML, or a domBuilder array. (default: null)
|
|
44
|
+
* @param {string | null} [params.contentExtraClassName=null] - Extra class added to the content wrapper. (default: null)
|
|
45
|
+
* @param {HTMLElement | null} [params.triggerElement=null] - Optional element that triggered the popup; when set, `aria-haspopup`, `aria-controls` and `aria-expanded` are managed on it. (default: null)
|
|
46
|
+
* @param {boolean} [params.addFocus=true] - if true, dialog receives focus after opening (default: true)
|
|
47
|
+
* @param {string | null} [params.headerExtraClassName=null] - Extra class added to the header wrapper. (default: null)
|
|
48
|
+
* @param {string | null} [params.footerExtraClassName=null] - Extra class added to the footer wrapper. (default: null)
|
|
49
|
+
* @param {string | number | null} [params.dialogWidth=null] - optional dialog width value - if set, overrides main css custom prop (default: null)
|
|
50
|
+
* @param {string | number | null} [params.dialogMinWidth=null] - optional dialog min-width value - if set, overrides main css custom prop (default: null)
|
|
51
|
+
* @param {string | number | null} [params.dialogMaxWidth=null] - optional dialog max-width value - if set, overrides main css custom prop (default: null)
|
|
52
|
+
* @param {string | number | null} [params.dialogHeight=null] - optional dialog height value - if set, overrides main css custom prop (default: null)
|
|
53
|
+
* @param {string | number | null} [params.dialogMinHeight=null] - optional dialog min-height value - if set, overrides main css custom prop (default: null)
|
|
54
|
+
* @param {string | number | null} [params.dialogMaxHeight=null] - optional dialog max-height value - if set, overrides main css custom prop (default: null)
|
|
55
|
+
* @param {string | null} [params.iframeUrl=null] - URL to load in an iframe. (default: null)
|
|
56
|
+
* @param {string | null} [params.ajaxUrl=null] - URL for Ajax content loading. (default: null)
|
|
57
|
+
* @param {((el: HTMLDialogElement) => void) | null} [params.openCallback=null] - Called with the dialog element after opening, receives the dialog element (`openCallback(dialogEl)`). (default: null)
|
|
58
|
+
* @param {((el: HTMLDialogElement) => void) | null} [params.closeCallback=null] - Called with the dialog element just before it is removed, receives the dialog element (`closeCallback(dialogEl)`). NB: `dialogEl` is removed immediately after closing. (default: null)
|
|
59
|
+
* @param {((data: *, el: Element) => void) | null} [params.ajaxCallback=null] - Called with the Ajax response and the content element. (default: null)
|
|
60
|
+
* @param {boolean} [params.addScrollbarPadding=false] - Adds right padding to compensate for the scrollbar. (default: false)
|
|
61
|
+
* @param {string | DomBuilderItem[] | null} [params.headerContent=null] - Header content: plain text, HTML, or a domBuilder array. (default: null)
|
|
62
|
+
* @param {string | DomBuilderItem[] | null} [params.footerContent=null] - Footer content: plain text, HTML, or a domBuilder array. (default: null)
|
|
63
63
|
* @returns {HTMLDialogElement} The dialog element.
|
|
64
64
|
*/
|
|
65
65
|
|
|
@@ -3,8 +3,8 @@ import './overlay.css';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Appends an overlay `div` to the given context element.
|
|
6
|
-
* @param {Element} [context=document.body]
|
|
7
|
-
* @param {boolean} [scroll_lock=false] - When true, locks body scroll via `overflow-hidden`.
|
|
6
|
+
* @param {Element} [context=document.body] (default: document.body)
|
|
7
|
+
* @param {boolean} [scroll_lock=false] - When true, locks body scroll via `overflow-hidden`. (default: false)
|
|
8
8
|
* @returns {void}
|
|
9
9
|
*/
|
|
10
10
|
export function overlay(context = document.body, scroll_lock = false) {
|
|
@@ -16,7 +16,7 @@ export function overlay(context = document.body, scroll_lock = false) {
|
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Removes the overlay element from the given context and re-enables body scroll.
|
|
19
|
-
* @param {Element} [context=document.body]
|
|
19
|
+
* @param {Element} [context=document.body] (default: document.body)
|
|
20
20
|
* @returns {void}
|
|
21
21
|
*/
|
|
22
22
|
export function removeOverlay(context = document.body) {
|
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
/*! minimo - Symfony Macro Manager */
|
|
2
2
|
import './sf-macro.css';
|
|
3
3
|
|
|
4
|
+
// TODO[epic=v2] in una v. 2 di minimo, rinominare wrapper_selector e row_selector in
|
|
5
|
+
// wrapperClass e rowClass (NB: classi, non selettori, per uniformità con closeBtnClass/addBtnClass/containerClass
|
|
6
|
+
// aggiunti sotto) e rendere tutti i parametri camelCase.
|
|
7
|
+
// TODO[epic=v2] valutare se rendere opzionale, tramite parametro, l'importazione statica
|
|
8
|
+
// di sf-macro.css qui sopra (questione lasciata in sospeso).
|
|
9
|
+
|
|
4
10
|
/**
|
|
5
11
|
* Initialises Symfony macro collection fields (repeatable fieldsets).
|
|
6
|
-
* @param {Object} [options={}]
|
|
7
|
-
* @param {string} [options.wrapper_selector='.sf-macro-wrapper'] - Selector for the outer wrapper element.
|
|
8
|
-
* @param {string} [options.row_selector='.sf-macro-riga'] - Selector for each repeatable row.
|
|
9
|
-
* @param {
|
|
10
|
-
* @param {
|
|
11
|
-
* @param {
|
|
12
|
+
* @param {Object} [options={}] (default: {})
|
|
13
|
+
* @param {string} [options.wrapper_selector='.sf-macro-wrapper'] - Selector for the outer wrapper element. (default: '.sf-macro-wrapper')
|
|
14
|
+
* @param {string} [options.row_selector='.sf-macro-riga'] - Selector for each repeatable row. (default: '.sf-macro-riga')
|
|
15
|
+
* @param {string} [options.closeBtnClass='sf-macro-close-btn'] - Class name of the row-remove button. (default: 'sf-macro-close-btn')
|
|
16
|
+
* @param {string} [options.addBtnClass='sf-macro-riga-add'] - Class name of the row-add button. (default: 'sf-macro-riga-add')
|
|
17
|
+
* @param {string} [options.containerClass='sf-macro-container'] - Class name of the rows container. (default: 'sf-macro-container')
|
|
18
|
+
* @param {((newRow: Element | null, addBtn: Element | null) => void) | null} [options.add_callback=null] - Called after a row is added; receives the new row and the add button. (default: null)
|
|
19
|
+
* @param {(() => void) | null} [options.del_callback=null] - Called after a row is removed. (default: null)
|
|
20
|
+
* @param {boolean} [options.insertAtTop=false] - When true, new rows are inserted at the top. (default: false)
|
|
12
21
|
* @returns {void}
|
|
13
22
|
*/
|
|
14
23
|
export function sf_macro({
|
|
15
24
|
wrapper_selector = '.sf-macro-wrapper',
|
|
16
25
|
row_selector = '.sf-macro-riga',
|
|
26
|
+
// Change closeBtnClass/addBtnClass/containerClass only if you don't want to use
|
|
27
|
+
// the default sf-macro.css: unused default classes are not stripped by this
|
|
28
|
+
// component, that cleanup is delegated to PurgeCSS (or equivalent) downstream.
|
|
29
|
+
closeBtnClass = 'sf-macro-close-btn',
|
|
30
|
+
addBtnClass = 'sf-macro-riga-add',
|
|
31
|
+
containerClass = 'sf-macro-container',
|
|
17
32
|
add_callback = null,
|
|
18
33
|
del_callback = null,
|
|
19
34
|
insertAtTop = false
|
|
@@ -30,17 +45,17 @@ export function sf_macro({
|
|
|
30
45
|
const target = /** @type {HTMLElement} */ (e.target);
|
|
31
46
|
|
|
32
47
|
const action_btn = /** @type {HTMLElement | null} */ (
|
|
33
|
-
target.closest(
|
|
48
|
+
target.closest(`.${addBtnClass}, .${closeBtnClass}`)
|
|
34
49
|
);
|
|
35
50
|
if (!action_btn) return;
|
|
36
51
|
|
|
37
52
|
const fset = /** @type {HTMLElement | null} */ (target.closest(wrapper_selector));
|
|
38
53
|
if (!fset) return;
|
|
39
54
|
|
|
40
|
-
const macro_container = /** @type {HTMLElement | null} */ (fset.querySelector(
|
|
55
|
+
const macro_container = /** @type {HTMLElement | null} */ (fset.querySelector(`.${containerClass}`));
|
|
41
56
|
if (!macro_container) return;
|
|
42
57
|
|
|
43
|
-
if(action_btn.matches(
|
|
58
|
+
if(action_btn.matches(`.${addBtnClass}`)) {
|
|
44
59
|
|
|
45
60
|
const macro_template = macro_container.dataset.template ?? '';
|
|
46
61
|
const righe_macro = macro_container.querySelectorAll(row_selector).length;
|
|
@@ -199,10 +199,10 @@ export function disposeSliding(target) {
|
|
|
199
199
|
* CSS animates height to 0, then snaps display to none.
|
|
200
200
|
*
|
|
201
201
|
* @param {HTMLElement} target
|
|
202
|
-
* @param {object} [options]
|
|
203
|
-
* @param {boolean} [options.wrap=true] - auto-generates a wrapper `<div class="slide">` around `target` (see module docs above); when `false`, the `.slide` class is added directly to `target`.
|
|
202
|
+
* @param {object} [options] (default: {})
|
|
203
|
+
* @param {boolean} [options.wrap=true] - auto-generates a wrapper `<div class="slide">` around `target` (see module docs above); when `false`, the `.slide` class is added directly to `target`. (default: true)
|
|
204
204
|
* @param {number} [options.duration] - overrides the `--slide-duration` CSS var (ms); if omitted, the CSS value is used.
|
|
205
|
-
* @param {(() => void) | null} [options.callback] - invoked after the transition ends.
|
|
205
|
+
* @param {(() => void) | null} [options.callback] - invoked after the transition ends. (default: null)
|
|
206
206
|
* @returns {Promise<void>}
|
|
207
207
|
*/
|
|
208
208
|
export async function slideUp(target, options = {}) {
|
|
@@ -218,10 +218,10 @@ export async function slideUp(target, options = {}) {
|
|
|
218
218
|
* display snaps to block, then CSS animates height from 0 (via @starting-style) to auto.
|
|
219
219
|
*
|
|
220
220
|
* @param {HTMLElement} target
|
|
221
|
-
* @param {object} [options]
|
|
222
|
-
* @param {boolean} [options.wrap=true] - auto-generates a wrapper `<div class="slide">` around `target` (see module docs above); when `false`, the `.slide` class is added directly to `target`.
|
|
221
|
+
* @param {object} [options] (default: {})
|
|
222
|
+
* @param {boolean} [options.wrap=true] - auto-generates a wrapper `<div class="slide">` around `target` (see module docs above); when `false`, the `.slide` class is added directly to `target`. (default: true)
|
|
223
223
|
* @param {number} [options.duration] - overrides the `--slide-duration` CSS var (ms); if omitted, the CSS value is used.
|
|
224
|
-
* @param {(() => void) | null} [options.callback] - invoked after the transition ends.
|
|
224
|
+
* @param {(() => void) | null} [options.callback] - invoked after the transition ends. (default: null)
|
|
225
225
|
* @returns {Promise<void>}
|
|
226
226
|
*/
|
|
227
227
|
export async function slideDown(target, options = {}) {
|
|
@@ -237,10 +237,10 @@ export async function slideDown(target, options = {}) {
|
|
|
237
237
|
* Reads the current data-slide value on the slide element to decide direction.
|
|
238
238
|
*
|
|
239
239
|
* @param {HTMLElement} target
|
|
240
|
-
* @param {object} [options]
|
|
241
|
-
* @param {boolean} [options.wrap=true] - auto-generates a wrapper `<div class="slide">` around `target` (see module docs above); when `false`, the `.slide` class is added directly to `target`.
|
|
240
|
+
* @param {object} [options] (default: {})
|
|
241
|
+
* @param {boolean} [options.wrap=true] - auto-generates a wrapper `<div class="slide">` around `target` (see module docs above); when `false`, the `.slide` class is added directly to `target`. (default: true)
|
|
242
242
|
* @param {number} [options.duration] - overrides the `--slide-duration` CSS var (ms); if omitted, the CSS value is used.
|
|
243
|
-
* @param {(() => void) | null} [options.callback] - invoked after the transition ends.
|
|
243
|
+
* @param {(() => void) | null} [options.callback] - invoked after the transition ends. (default: null)
|
|
244
244
|
* @returns {Promise<void>}
|
|
245
245
|
*/
|
|
246
246
|
export async function slideToggle(target, options = {}) {
|
|
@@ -21,12 +21,12 @@ References
|
|
|
21
21
|
/**
|
|
22
22
|
* Displays a snackbar / toast notification using the Popover API.
|
|
23
23
|
* @param {string} message - The message to display.
|
|
24
|
-
* @param {Object} [options={}]
|
|
25
|
-
* @param {string | null} [options.status=null] - Status variant: `danger`, `warning`, `info`, or `success`.
|
|
26
|
-
* @param {number | false | null} [options.duration=4000] - Auto-close delay in ms; `false` or `null` disables auto-close.
|
|
27
|
-
* @param {boolean} [options.close_btn=true] - Whether to show the close button.
|
|
28
|
-
* @param {Function | null} [options.action=null] - Action callback.
|
|
29
|
-
* @param {string | null} [options.action_text=null] - Label for the action button.
|
|
24
|
+
* @param {Object} [options={}] (default: {})
|
|
25
|
+
* @param {string | null} [options.status=null] - Status variant: `danger`, `warning`, `info`, or `success`. (default: null)
|
|
26
|
+
* @param {number | false | null} [options.duration=4000] - Auto-close delay in ms; `false` or `null` disables auto-close. (default: 4000)
|
|
27
|
+
* @param {boolean} [options.close_btn=true] - Whether to show the close button. (default: true)
|
|
28
|
+
* @param {Function | null} [options.action=null] - Action callback. (default: null)
|
|
29
|
+
* @param {string | null} [options.action_text=null] - Label for the action button. (default: null)
|
|
30
30
|
* @returns {{ close: function(): void }}
|
|
31
31
|
*/
|
|
32
32
|
export function snackbar(message, options = {}){
|
|
@@ -13,13 +13,13 @@ import * as styles from './unsplash-page.module.css';
|
|
|
13
13
|
* and attribution overlay.
|
|
14
14
|
* @param {Object} settings
|
|
15
15
|
* @param {HTMLElement | null} settings.targetElement - Container element where the photo will be rendered.
|
|
16
|
-
* @param {string | null} [settings.className=null] - Extra class added to the container.
|
|
16
|
+
* @param {string | null} [settings.className=null] - Extra class added to the container. (default: null)
|
|
17
17
|
* @param {string | null} settings.unsplashDataUrl - URL returning Unsplash photo JSON.
|
|
18
18
|
* @param {string | null} settings.utmSource - UTM source value for attribution links.
|
|
19
19
|
* @param {string | null} settings.title - Main heading text.
|
|
20
|
-
* @param {string | null} [settings.text=null] - Optional body text.
|
|
21
|
-
* @param {string | null} [settings.backLink=null] - Optional back-link HTML.
|
|
22
|
-
* @param {boolean} [settings.hidePhotoLink=true] - When true, the Unsplash link is shown only on hover.
|
|
20
|
+
* @param {string | null} [settings.text=null] - Optional body text. (default: null)
|
|
21
|
+
* @param {string | null} [settings.backLink=null] - Optional back-link HTML. (default: null)
|
|
22
|
+
* @param {boolean} [settings.hidePhotoLink=true] - When true, the Unsplash link is shown only on hover. (default: true)
|
|
23
23
|
* @returns {Promise<void>}
|
|
24
24
|
*/
|
|
25
25
|
|
|
@@ -43,7 +43,7 @@ const PARTICLE_CASING_MAP = new Map(PARTICELLE.map(term => [term.toLowerCase(),
|
|
|
43
43
|
* and optionally enforcing the exact casing of custom words.
|
|
44
44
|
*
|
|
45
45
|
* @param {string} str - input string to process
|
|
46
|
-
* @param {string[]} custom_words - list of words whose exact casing must be preserved (e.g. `['iPhone', 'macOS']`)
|
|
46
|
+
* @param {string[]} [custom_words] - list of words whose exact casing must be preserved (e.g. `['iPhone', 'macOS']`) (default: [])
|
|
47
47
|
* @returns {string} processed string, or empty string if input is falsy
|
|
48
48
|
*/
|
|
49
49
|
export function betterText(str, custom_words = []) {
|
package/src/utilities/cookies.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Returns the value of a cookie by name.
|
|
6
6
|
* @param {string} name
|
|
7
7
|
* @param {object} [options]
|
|
8
|
-
* @param {boolean} [options.parseJson=false] - If true, JSON-parses the value and returns an object instead of a string.
|
|
8
|
+
* @param {boolean} [options.parseJson=false] - If true, JSON-parses the value and returns an object instead of a string. (default: false)
|
|
9
9
|
* @returns {string | object | null}
|
|
10
10
|
*/
|
|
11
11
|
export function getCookie(name, {parseJson = false} = {}) {
|
|
@@ -25,8 +25,8 @@ export function getCookie(name, {parseJson = false} = {}) {
|
|
|
25
25
|
* @param {object} params
|
|
26
26
|
* @param {string} params.name
|
|
27
27
|
* @param {string} params.value
|
|
28
|
-
* @param {string|null} [params.path=null]
|
|
29
|
-
* @param {number|null} [params.expire=null] - Max-Age in seconds
|
|
28
|
+
* @param {string|null} [params.path=null] (default: null)
|
|
29
|
+
* @param {number|null} [params.expire=null] - Max-Age in seconds (default: null)
|
|
30
30
|
* @example
|
|
31
31
|
* // Cookie scoped to the current page only, lasting 15 days
|
|
32
32
|
* setCookie({
|
|
@@ -7,8 +7,8 @@ import { parseDomString } from './parseDomString.js';
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @typedef {Object} DomBuilderItem
|
|
10
|
-
* @property {string | string[]} [tag='div'] - HTML tag name or array of nested tags (each is parent of the next). Also `tagName`.
|
|
11
|
-
* @property {string | string[]} [tagName='div'] - Alias for `tag`.
|
|
10
|
+
* @property {string | string[]} [tag='div'] - HTML tag name or array of nested tags (each is parent of the next). Also `tagName`. (default: 'div')
|
|
11
|
+
* @property {string | string[]} [tagName='div'] - Alias for `tag`. (default: 'div')
|
|
12
12
|
* @property {string | string[]} [className] - CSS class(es): a single string or an array (falsy values filtered out).
|
|
13
13
|
* @property {string | string[]} [class] - Alias for `className`.
|
|
14
14
|
* @property {string | string[]} [classname] - Alias for `className`.
|
|
@@ -23,7 +23,7 @@ import { parseDomString } from './parseDomString.js';
|
|
|
23
23
|
* parsed as markup) in place of an element, so it can sit as a sibling of tags within `children`/`content`
|
|
24
24
|
* arrays. Mutually exclusive with `tag`/`content`/`children`: when set (and `tag` is absent), every other
|
|
25
25
|
* property except `condition` and `callback` is ignored.
|
|
26
|
-
* @property {boolean} [condition=true] - When false, the element (or text node) is skipped.
|
|
26
|
+
* @property {boolean} [condition=true] - When false, the element (or text node) is skipped. (default: true)
|
|
27
27
|
* @property {(function(HTMLElement|Text): void) | null} [callback] - Callback invoked after the element (or text node) is created.
|
|
28
28
|
* @property {Array<DomBuilderItem|string|Node>} [children] - Configuration array for child elements. Accepts strings (shorthand per `parseDomString`), configuration objects, and/or `Node`s (an `Element`, a `DocumentFragment`, ...) inserted as-is.
|
|
29
29
|
*/
|
|
@@ -96,12 +96,12 @@ import { parseDomString } from './parseDomString.js';
|
|
|
96
96
|
* - `callback` {(function(HTMLElement|Text): void) | null} - Invoked after the element (or text node) is created.
|
|
97
97
|
* - `children` {Array<DomBuilderItem|string|Node>} - Configuration array for child elements (same format, nested; also accepts `Node`s inserted as-is).
|
|
98
98
|
*
|
|
99
|
-
* IDs and classes can be specified either as top-level object keys or inside `attrs`; top-level properties take precedence.
|
|
99
|
+
* IDs and classes can be specified either as top-level object keys or inside `attrs`; top-level properties take precedence. (default: [])
|
|
100
100
|
* @param {HTMLElement} [parent] - Parent element the structure is attached to (see `options.insertMode`).
|
|
101
|
-
* @param {Object} [options={}] - Configuration options.
|
|
102
|
-
* @param {boolean} [options.emptyParent=false] - When true, the parent element is emptied before building.
|
|
103
|
-
* @param {'append'|'before'|'after'} [options.insertMode='append'] - How each root element of `structureArray` is attached to `parent`: `append` inserts it as a child (default), `before`/`after` insert it as a previous/next sibling of `parent`, preserving `structureArray` order. Only applies to the elements produced by this call — nested `domBuilder` calls (`content`, `children`) always append.
|
|
104
|
-
* @param {boolean} [options.debug=false] - When true, logs `structureArray` to the console after each string item has been parsed via `parseDomString` (i.e. the elaborated array actually used to build the DOM).
|
|
101
|
+
* @param {Object} [options={}] - Configuration options. (default: {})
|
|
102
|
+
* @param {boolean} [options.emptyParent=false] - When true, the parent element is emptied before building. (default: false)
|
|
103
|
+
* @param {'append'|'before'|'after'} [options.insertMode='append'] - How each root element of `structureArray` is attached to `parent`: `append` inserts it as a child (default), `before`/`after` insert it as a previous/next sibling of `parent`, preserving `structureArray` order. Only applies to the elements produced by this call — nested `domBuilder` calls (`content`, `children`) always append. (default: 'append')
|
|
104
|
+
* @param {boolean} [options.debug=false] - When true, logs `structureArray` to the console after each string item has been parsed via `parseDomString` (i.e. the elaborated array actually used to build the DOM). (default: false)
|
|
105
105
|
* @returns {HTMLElement|null} The first created element, or null if nothing was created.
|
|
106
106
|
*/
|
|
107
107
|
|
|
@@ -9,9 +9,9 @@ import { randomId } from '../random-id.js';
|
|
|
9
9
|
* (typically the label + control).
|
|
10
10
|
*
|
|
11
11
|
* @param {Object} args
|
|
12
|
-
* @param {boolean} [args.condition=true] - When false, returns `null` without building anything.
|
|
13
|
-
* @param {string | null} [args.wrapperClass=null] - optional class to be added to the `.form-group` wrapper.
|
|
14
|
-
* @param {string | HTMLElement | null} [args.help=null] - Optional help text.
|
|
12
|
+
* @param {boolean} [args.condition=true] - When false, returns `null` without building anything. (default: true)
|
|
13
|
+
* @param {string | null} [args.wrapperClass=null] - optional class to be added to the `.form-group` wrapper. (default: null)
|
|
14
|
+
* @param {string | HTMLElement | null} [args.help=null] - Optional help text. (default: null)
|
|
15
15
|
* @param {Array<Object>} args.children - domBuilder children to render inside the `.form-group` (before the help text).
|
|
16
16
|
* @returns {DomBuilderItem|null} The `.form-group` domBuilder item, or `null` when `condition` is false.
|
|
17
17
|
*/
|
|
@@ -48,15 +48,15 @@ function buildFormGroup({
|
|
|
48
48
|
* @param {string | null} args.name - input `name` attribute.
|
|
49
49
|
* @param {string | null} args.id - `id` attribute.
|
|
50
50
|
* @param {string | number | null} args.value - input `value` attribute.
|
|
51
|
-
* @param {string | null} [args.type='text'] - input `type` attribute.
|
|
52
|
-
* @param {string | null} [args.wrapperClass=null] - optional class to be added to the `.form-group` wrapper.
|
|
53
|
-
* @param {string | null} [args.class=null] - optional class to be added to the `input`.
|
|
54
|
-
* @param {string | null} [args.classname=null] - Alias for `class`.
|
|
55
|
-
* @param {string | null} [args.className=null] - Alias for `class`.
|
|
56
|
-
* @param {boolean} [args.condition=true] - When false, the function returns `null` without building anything.
|
|
51
|
+
* @param {string | null} [args.type='text'] - input `type` attribute. (default: 'text')
|
|
52
|
+
* @param {string | null} [args.wrapperClass=null] - optional class to be added to the `.form-group` wrapper. (default: null)
|
|
53
|
+
* @param {string | null} [args.class=null] - optional class to be added to the `input`. (default: null)
|
|
54
|
+
* @param {string | null} [args.classname=null] - Alias for `class`. (default: null)
|
|
55
|
+
* @param {string | null} [args.className=null] - Alias for `class`. (default: null)
|
|
56
|
+
* @param {boolean} [args.condition=true] - When false, the function returns `null` without building anything. (default: true)
|
|
57
57
|
* @param {string | HTMLElement | null} args.help - Optional help text.
|
|
58
58
|
* @param {(function(HTMLElement|Text): void) | null} args.callback - Optional callback function.
|
|
59
|
-
* @param {Record<string, any> | null} [args.attrs={}] - Optional attributes object.
|
|
59
|
+
* @param {Record<string, any> | null} [args.attrs={}] - Optional attributes object. (default: {})
|
|
60
60
|
* @returns {DomBuilderItem|null} The `input` domBuilder item, or `null` when `condition` is false.
|
|
61
61
|
*/
|
|
62
62
|
export function buildInput({
|
|
@@ -112,16 +112,16 @@ export function buildInput({
|
|
|
112
112
|
* @param {Array<[string|number, string]> | Array<Record<string, string>> | Record<string, string> | null} args.options -
|
|
113
113
|
* options value/text pairs, as an array of two-element `[[value, text], ...]` arrays,
|
|
114
114
|
* as an array of objects `[{somekey: value, somekey2: text},...]` objects, or as a single `{value: text, ...}` object
|
|
115
|
-
* @param {boolean} [args.addEmptyOption=true] - When true, and empty option tag is added at top
|
|
116
|
-
* @param {string | null} [args.wrapperClass=null] - optional class to be added to the `.form-group` wrapper.
|
|
117
|
-
* @param {string | null} [args.class=null] - optional class to be added to the `input`.
|
|
118
|
-
* @param {string | null} [args.classname=null] - Alias for `class`.
|
|
119
|
-
* @param {string | null} [args.className=null] - Alias for `class`.
|
|
120
|
-
* @param {boolean} [args.condition=true] - When false, the function returns `null` without building anything.
|
|
121
|
-
* @param {boolean} [args.useBsClass=false] - When true, uses BS5 class (`form-select`) instead of `form-control`
|
|
115
|
+
* @param {boolean} [args.addEmptyOption=true] - When true, and empty option tag is added at top (default: true)
|
|
116
|
+
* @param {string | null} [args.wrapperClass=null] - optional class to be added to the `.form-group` wrapper. (default: null)
|
|
117
|
+
* @param {string | null} [args.class=null] - optional class to be added to the `input`. (default: null)
|
|
118
|
+
* @param {string | null} [args.classname=null] - Alias for `class`. (default: null)
|
|
119
|
+
* @param {string | null} [args.className=null] - Alias for `class`. (default: null)
|
|
120
|
+
* @param {boolean} [args.condition=true] - When false, the function returns `null` without building anything. (default: true)
|
|
121
|
+
* @param {boolean} [args.useBsClass=false] - When true, uses BS5 class (`form-select`) instead of `form-control` (default: false)
|
|
122
122
|
* @param {string | HTMLElement | null} args.help - Optional help text.
|
|
123
123
|
* @param {(function(HTMLElement|Text): void) | null} args.callback - Optional callback function.
|
|
124
|
-
* @param {Record<string, any> | null} [args.attrs={}] - Optional attributes object.
|
|
124
|
+
* @param {Record<string, any> | null} [args.attrs={}] - Optional attributes object. (default: {})
|
|
125
125
|
* @returns {DomBuilderItem|null} The `input` domBuilder item, or `null` when `condition` is false.
|
|
126
126
|
*/
|
|
127
127
|
export function buildSelect({
|
|
@@ -204,16 +204,16 @@ export function buildSelect({
|
|
|
204
204
|
* @param {string} args.label - checkbox label.
|
|
205
205
|
* @param {string | null} args.name - checkbox `name` attribute.
|
|
206
206
|
* @param {string | null} args.id - `id` attribute.
|
|
207
|
-
* @param {string | number | null} [args.value=1] - checkbox `value` attribute.
|
|
208
|
-
* @param {boolean} [args.checked=false] - checkbox `checked` attribute.
|
|
207
|
+
* @param {string | number | null} [args.value=1] - checkbox `value` attribute. (default: 1)
|
|
208
|
+
* @param {boolean} [args.checked=false] - checkbox `checked` attribute. (default: false)
|
|
209
209
|
* @param {boolean} [args.switch=false] - When true, the checkbox is rendered as a switch
|
|
210
|
-
* (`.form-switch` wrapper, `role="switch"` and the native `switch` attribute).
|
|
211
|
-
* @param {string | null} [args.wrapperClass=null] - optional class to be added to the `.form-group` wrapper (used only when `addFormGroup` is true).
|
|
212
|
-
* @param {boolean} [args.addFormGroup=true] - When true, wraps the checkbox in a `.form-group` element.
|
|
213
|
-
* @param {boolean} [args.condition=true] - When false, the function returns `null` without building anything.
|
|
210
|
+
* (`.form-switch` wrapper, `role="switch"` and the native `switch` attribute). (default: false)
|
|
211
|
+
* @param {string | null} [args.wrapperClass=null] - optional class to be added to the `.form-group` wrapper (used only when `addFormGroup` is true). (default: null)
|
|
212
|
+
* @param {boolean} [args.addFormGroup=true] - When true, wraps the checkbox in a `.form-group` element. (default: true)
|
|
213
|
+
* @param {boolean} [args.condition=true] - When false, the function returns `null` without building anything. (default: true)
|
|
214
214
|
* @param {string | HTMLElement | null} args.help - Optional help text.
|
|
215
215
|
* @param {(function(HTMLElement|Text): void) | null} args.callback - Optional callback function.
|
|
216
|
-
* @param {Record<string, any> | null} [args.attrs={}] - Optional attributes object.
|
|
216
|
+
* @param {Record<string, any> | null} [args.attrs={}] - Optional attributes object. (default: {})
|
|
217
217
|
* @returns {DomBuilderItem|null} The `.form-check` (or `.form-group`-wrapped) domBuilder item, or `null` when `condition` is false.
|
|
218
218
|
*/
|
|
219
219
|
export function buildCheckbox({
|
|
@@ -296,15 +296,15 @@ export function buildCheckbox({
|
|
|
296
296
|
* @param {string | null} args.name - textarea `name` attribute.
|
|
297
297
|
* @param {string | null} args.id - `id` attribute.
|
|
298
298
|
* @param {string | number | null} args.value - textarea content.
|
|
299
|
-
* @param {boolean} [args.autosize=true] - adds `autosize` class
|
|
300
|
-
* @param {string | null} [args.wrapperClass=null] - optional class to be added to the `.form-group` wrapper.
|
|
301
|
-
* @param {string | null} [args.class=null] - optional class to be added to the textarea element.
|
|
302
|
-
* @param {string | null} [args.classname=null] - Alias for `class`.
|
|
303
|
-
* @param {string | null} [args.className=null] - Alias for `class`.
|
|
304
|
-
* @param {boolean} [args.condition=true] - When false, the function returns `null` without building anything.
|
|
299
|
+
* @param {boolean} [args.autosize=true] - adds `autosize` class (default: true)
|
|
300
|
+
* @param {string | null} [args.wrapperClass=null] - optional class to be added to the `.form-group` wrapper. (default: null)
|
|
301
|
+
* @param {string | null} [args.class=null] - optional class to be added to the textarea element. (default: null)
|
|
302
|
+
* @param {string | null} [args.classname=null] - Alias for `class`. (default: null)
|
|
303
|
+
* @param {string | null} [args.className=null] - Alias for `class`. (default: null)
|
|
304
|
+
* @param {boolean} [args.condition=true] - When false, the function returns `null` without building anything. (default: true)
|
|
305
305
|
* @param {string | HTMLElement | null} args.help - Optional help text.
|
|
306
306
|
* @param {(function(HTMLElement|Text): void) | null} args.callback - Optional callback function.
|
|
307
|
-
* @param {Record<string, any> | null} [args.attrs={}] - Optional attributes object.
|
|
307
|
+
* @param {Record<string, any> | null} [args.attrs={}] - Optional attributes object. (default: {})
|
|
308
308
|
* @returns {DomBuilderItem|null} The `textarea` domBuilder item, or `null` when `condition` is false.
|
|
309
309
|
*/
|
|
310
310
|
export function buildTextarea({
|
|
@@ -354,15 +354,15 @@ export function buildTextarea({
|
|
|
354
354
|
* @param {Object} args
|
|
355
355
|
* @param {string} args.label - label.
|
|
356
356
|
* @param {string | number | null} args.value - text content.
|
|
357
|
-
* @param {string | null} [args.wrapperClass=null] - optional class to be added to the `.form-group` wrapper.
|
|
358
|
-
* @param {boolean} [args.noBorder=true] - adds `no-border` class.
|
|
359
|
-
* @param {string | null} [args.class=null] - optional class to be added to the fake field.
|
|
360
|
-
* @param {string | null} [args.classname=null] - Alias for `class`.
|
|
361
|
-
* @param {string | null} [args.className=null] - Alias for `class`.
|
|
362
|
-
* @param {boolean} [args.condition=true] - When false, the function returns `null` without building anything.
|
|
357
|
+
* @param {string | null} [args.wrapperClass=null] - optional class to be added to the `.form-group` wrapper. (default: null)
|
|
358
|
+
* @param {boolean} [args.noBorder=true] - adds `no-border` class. (default: true)
|
|
359
|
+
* @param {string | null} [args.class=null] - optional class to be added to the fake field. (default: null)
|
|
360
|
+
* @param {string | null} [args.classname=null] - Alias for `class`. (default: null)
|
|
361
|
+
* @param {string | null} [args.className=null] - Alias for `class`. (default: null)
|
|
362
|
+
* @param {boolean} [args.condition=true] - When false, the function returns `null` without building anything. (default: true)
|
|
363
363
|
* @param {string | HTMLElement | null} args.help - Optional help text.
|
|
364
364
|
* @param {(function(HTMLElement|Text): void) | null} args.callback - Optional callback function.
|
|
365
|
-
* @param {Record<string, any> | null} [args.attrs={}] - Optional attributes object.
|
|
365
|
+
* @param {Record<string, any> | null} [args.attrs={}] - Optional attributes object. (default: {})
|
|
366
366
|
* @returns {DomBuilderItem|null} The fake field domBuilder item, or `null` when `condition` is false.
|
|
367
367
|
*/
|
|
368
368
|
export function buildFakeField({
|
|
@@ -407,14 +407,14 @@ export function buildFakeField({
|
|
|
407
407
|
* @param {Object} args
|
|
408
408
|
* @param {string|HTMLElement|Array<DomBuilderItem>} args.content - button content. When an array of
|
|
409
409
|
* domBuilder items is passed, it is rendered via `children` instead of `content`.
|
|
410
|
-
* @param {string} [args.type=button] - button type.
|
|
410
|
+
* @param {string} [args.type=button] - button type. (default: 'button')
|
|
411
411
|
* @param {string | null} args.id - `id` attribute.
|
|
412
|
-
* @param {string | null} [args.class=null] - optional class to be added to the button element.
|
|
413
|
-
* @param {string | null} [args.classname=null] - Alias for `class`.
|
|
414
|
-
* @param {string | null} [args.className=null] - Alias for `class`.
|
|
415
|
-
* @param {boolean} [args.condition=true] - When false, the function returns `null` without building anything.
|
|
412
|
+
* @param {string | null} [args.class=null] - optional class to be added to the button element. (default: null)
|
|
413
|
+
* @param {string | null} [args.classname=null] - Alias for `class`. (default: null)
|
|
414
|
+
* @param {string | null} [args.className=null] - Alias for `class`. (default: null)
|
|
415
|
+
* @param {boolean} [args.condition=true] - When false, the function returns `null` without building anything. (default: true)
|
|
416
416
|
* @param {(function(HTMLElement|Text): void) | null} args.callback - Optional callback function.
|
|
417
|
-
* @param {Record<string, any> | null} [args.attrs={}] - Optional attributes object.
|
|
417
|
+
* @param {Record<string, any> | null} [args.attrs={}] - Optional attributes object. (default: {})
|
|
418
418
|
* @returns {DomBuilderItem|null} The `button` domBuilder item, or `null` when `condition` is false.
|
|
419
419
|
*/
|
|
420
420
|
export function buildButton({
|
|
@@ -69,22 +69,22 @@ import { classnames } from '../classnames.js';
|
|
|
69
69
|
*
|
|
70
70
|
* @param {Object} args
|
|
71
71
|
* @param {string} args.baseSrc - Image base URL (viewer endpoint); its query params are preserved.
|
|
72
|
-
* @param {(number | [number, number] | PictureSizeEntry)[]} [args.sizes=[250]] - Rendered image sizes, in any order. Each entry is a `{from, size}` object (see {@link PictureSizeEntry}); a bare number or `[width, height]` pair is a shorthand for the mobile-first default entry (the one without `from`), expected exactly once.
|
|
73
|
-
* @param {number|null} [args.ratio=null] - Default aspect ratio (width / height, as in the CSS `aspect-ratio` property) used to compute the height of numeric sizes. When null, no height is computed: the height-related output (`height` attribute, height in the `bb` param) is omitted and the viewer preserves the image's own ratio.
|
|
74
|
-
* @param {number} [args.dpr=2] - Maximum pixel density (integer): `srcset` candidates are generated for every density from 1 to `dpr`.
|
|
75
|
-
* @param {[string, string|number][]} [args.img_params=[['q','60']]] - Query params (`[name, value]` pairs) added to every generated URL.
|
|
76
|
-
* @param {string[]} [args.formats=['avif','webp','pjpg']] - Image formats: the last one is used for the `img` fallback element, the others for the `source` elements.
|
|
77
|
-
* @param {boolean} [args.devMode=false] - When true, `avif` is excluded from `formats` (not supported by the local dev environment).
|
|
78
|
-
* @param {boolean} [args.lazy=true] - When true, the `img` element gets `loading="lazy"`.
|
|
79
|
-
* @param {'high'|'low'|null} [args.fetchpriority=null] - `fetchpriority` attribute for the `img` element: use `high` for the LCP/above-the-fold image (typically with `lazy: false`). When null the attribute is omitted (browser default `auto`).
|
|
80
|
-
* @param {((img: HTMLImageElement) => void) | null} [args.onLoad=null] - Called once the image has finished loading, receiving the `img` element (called immediately if the image is already complete).
|
|
81
|
-
* @param {boolean} [args.condition=true] - When false, the function returns `null` without building anything.
|
|
82
|
-
* @param {boolean} [args.legacyMediaSyntax=false] - When true, the `sizes` media conditions use `(min-width: …)` instead of the range syntax `(width >= …)`, for older browsers (pre Chrome/Edge 104, Firefox 102, Safari 16.4).
|
|
83
|
-
* @param {string|null} [args.pictureExtraClass=null] - Extra class(es) for the `picture` element.
|
|
84
|
-
* @param {Object<string, *>} [args.pictureExtraAttrs={}] - Extra attributes for the `picture` element.
|
|
85
|
-
* @param {string|null} [args.imgExtraClass=null] - Extra class(es) for the `img` element.
|
|
86
|
-
* @param {Object<string, *>} [args.imgExtraAttrs={}] - Extra attributes for the `img` element.
|
|
87
|
-
* @param {string} [args.alt=''] - `alt` text for the `img` element.
|
|
72
|
+
* @param {(number | [number, number] | PictureSizeEntry)[]} [args.sizes=[250]] - Rendered image sizes, in any order. Each entry is a `{from, size}` object (see {@link PictureSizeEntry}); a bare number or `[width, height]` pair is a shorthand for the mobile-first default entry (the one without `from`), expected exactly once. (default: [250])
|
|
73
|
+
* @param {number|null} [args.ratio=null] - Default aspect ratio (width / height, as in the CSS `aspect-ratio` property) used to compute the height of numeric sizes. When null, no height is computed: the height-related output (`height` attribute, height in the `bb` param) is omitted and the viewer preserves the image's own ratio. (default: null)
|
|
74
|
+
* @param {number} [args.dpr=2] - Maximum pixel density (integer): `srcset` candidates are generated for every density from 1 to `dpr`. (default: 2)
|
|
75
|
+
* @param {[string, string|number][]} [args.img_params=[['q','60']]] - Query params (`[name, value]` pairs) added to every generated URL. (default: [['q','60']])
|
|
76
|
+
* @param {string[]} [args.formats=['avif','webp','pjpg']] - Image formats: the last one is used for the `img` fallback element, the others for the `source` elements. (default: ['avif','webp','pjpg'])
|
|
77
|
+
* @param {boolean} [args.devMode=false] - When true, `avif` is excluded from `formats` (not supported by the local dev environment). (default: false)
|
|
78
|
+
* @param {boolean} [args.lazy=true] - When true, the `img` element gets `loading="lazy"`. (default: true)
|
|
79
|
+
* @param {'high'|'low'|null} [args.fetchpriority=null] - `fetchpriority` attribute for the `img` element: use `high` for the LCP/above-the-fold image (typically with `lazy: false`). When null the attribute is omitted (browser default `auto`). (default: null)
|
|
80
|
+
* @param {((img: HTMLImageElement) => void) | null} [args.onLoad=null] - Called once the image has finished loading, receiving the `img` element (called immediately if the image is already complete). (default: null)
|
|
81
|
+
* @param {boolean} [args.condition=true] - When false, the function returns `null` without building anything. (default: true)
|
|
82
|
+
* @param {boolean} [args.legacyMediaSyntax=false] - When true, the `sizes` media conditions use `(min-width: …)` instead of the range syntax `(width >= …)`, for older browsers (pre Chrome/Edge 104, Firefox 102, Safari 16.4). (default: false)
|
|
83
|
+
* @param {string|null} [args.pictureExtraClass=null] - Extra class(es) for the `picture` element. (default: null)
|
|
84
|
+
* @param {Object<string, *>} [args.pictureExtraAttrs={}] - Extra attributes for the `picture` element. (default: {})
|
|
85
|
+
* @param {string|null} [args.imgExtraClass=null] - Extra class(es) for the `img` element. (default: null)
|
|
86
|
+
* @param {Object<string, *>} [args.imgExtraAttrs={}] - Extra attributes for the `img` element. (default: {})
|
|
87
|
+
* @param {string} [args.alt=''] - `alt` text for the `img` element. (default: '')
|
|
88
88
|
* @returns {DomBuilderItem|null} The `picture` domBuilder item, or `null` when `baseSrc` is missing or `condition` is false.
|
|
89
89
|
*/
|
|
90
90
|
export function buildPictureTag({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! minimo - Enable Submit Buttons */
|
|
2
2
|
/**
|
|
3
3
|
* Re-enables all submit and non-disabled button elements within the given context.
|
|
4
|
-
* @param {Document | Element} [context=document]
|
|
4
|
+
* @param {Document | Element} [context=document] (default: document)
|
|
5
5
|
* @returns {void}
|
|
6
6
|
*/
|
|
7
7
|
export function enableSubmitBtns(context = document) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Generates a random password using uppercase letters and digits,
|
|
4
4
|
* excluding visually ambiguous characters (O, I, 0).
|
|
5
5
|
*
|
|
6
|
-
* @param {number} [min_length=8] - Minimum password length (matches `minlength` attribute).
|
|
6
|
+
* @param {number} [min_length=8] - Minimum password length (matches `minlength` attribute). (default: 8)
|
|
7
7
|
* @returns {string} The generated password.
|
|
8
8
|
*/
|
|
9
9
|
export function generatePwd(min_length = 8) {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* If the linked field is disabled, the constraint is removed on focus
|
|
14
14
|
* and restored when the linked field is re-enabled.
|
|
15
15
|
*
|
|
16
|
-
* @param {Document|Element} context - root element to search within (
|
|
16
|
+
* @param {Document|Element} context - root element to search within (default: document)
|
|
17
17
|
* @returns {void}
|
|
18
18
|
*/
|
|
19
19
|
export function linkedDates(context = document) {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* parseFileSize(10485760); // "10 MB"
|
|
11
11
|
*
|
|
12
12
|
* @param {number} bytes - file size in bytes
|
|
13
|
-
* @param {number} [decimals=1] - max number of decimal digits
|
|
13
|
+
* @param {number} [decimals=1] - max number of decimal digits (default: 1)
|
|
14
14
|
* @returns {string} formatted size (e.g. "1.5 MB")
|
|
15
15
|
*/
|
|
16
16
|
export function parseFileSize(bytes, decimals = 1) {
|
|
@@ -6,17 +6,17 @@
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @typedef {object} RelativeDateOptions
|
|
9
|
-
* @property {boolean} [useRelativeTime=true] - Show times near the date as "in xx minutes" (before) or "now" (within `relativeTimeMinutesAfter`)
|
|
10
|
-
* @property {string} [nowString] - String to display when the date is right now
|
|
11
|
-
* @property {number} [relativeTimeMinutesBefore] - Minutes before the date within which to show "in xx minutes"
|
|
12
|
-
* @property {number} [relativeTimeMinutesAfter] - Minutes after the date within which to show the now string
|
|
13
|
-
* @property {boolean} [relativeTimeShowTime] - Show the actual time alongside relative date labels
|
|
14
|
-
* @property {string} [relativeTimeShowTimeMarkup] - HTML markup for the time portion; `@@time@@` is replaced with the localized time string
|
|
15
|
-
* @property {boolean} [firstLetterUpperCase] - Capitalize the first letter of the returned string
|
|
16
|
-
* @property {Intl.DateTimeFormatOptions} [dateFormat] - Format for non-relative dates (beyond day after tomorrow)
|
|
17
|
-
* @property {Intl.DateTimeFormatOptions} [timeFormat] - Format for time displayed in relative date labels
|
|
18
|
-
* @property {string[]} [relativeStrings] - Labels for yesterday / today / tomorrow / day after tomorrow (in chronological order)
|
|
19
|
-
* @property {string} [locale] - Locale string for date/time formatting
|
|
9
|
+
* @property {boolean} [useRelativeTime=true] - Show times near the date as "in xx minutes" (before) or "now" (within `relativeTimeMinutesAfter`) (default: true)
|
|
10
|
+
* @property {string} [nowString] - String to display when the date is right now (default: 'adesso')
|
|
11
|
+
* @property {number} [relativeTimeMinutesBefore] - Minutes before the date within which to show "in xx minutes" (default: 30)
|
|
12
|
+
* @property {number} [relativeTimeMinutesAfter] - Minutes after the date within which to show the now string (default: 30)
|
|
13
|
+
* @property {boolean} [relativeTimeShowTime] - Show the actual time alongside relative date labels (default: true)
|
|
14
|
+
* @property {string} [relativeTimeShowTimeMarkup] - HTML markup for the time portion; `@@time@@` is replaced with the localized time string (default: ' <span class="time-info">(alle @@time@@)</span>')
|
|
15
|
+
* @property {boolean} [firstLetterUpperCase] - Capitalize the first letter of the returned string (default: true)
|
|
16
|
+
* @property {Intl.DateTimeFormatOptions} [dateFormat] - Format for non-relative dates (beyond day after tomorrow) (default: { weekday: 'short', year: 'numeric', month: 'short', day: 'numeric', hour12: false, hour: '2-digit', minute: '2-digit' })
|
|
17
|
+
* @property {Intl.DateTimeFormatOptions} [timeFormat] - Format for time displayed in relative date labels (default: { hour12: false, hour: '2-digit', minute: '2-digit' })
|
|
18
|
+
* @property {string[]} [relativeStrings] - Labels for yesterday / today / tomorrow / day after tomorrow (in chronological order) (default: ['ieri alle', 'oggi alle', 'domani alle', 'dopodomani alle'])
|
|
19
|
+
* @property {string} [locale] - Locale string for date/time formatting (default: 'it-IT')
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -27,18 +27,18 @@
|
|
|
27
27
|
* expands dotted `@param` properties (needed for editor IntelliSense to list each property) when
|
|
28
28
|
* the base type is the literal `object`; a named typedef there would error (TS8032).
|
|
29
29
|
* @param {Date | string} date - Date to display (Date object or ISO string)
|
|
30
|
-
* @param {object} [options={}]
|
|
31
|
-
* @param {boolean} [options.useRelativeTime=true] - Show times near the date as "in xx minutes" (before) or "now" (within `relativeTimeMinutesAfter`)
|
|
32
|
-
* @param {string} [options.nowString] - String to display when the date is right now
|
|
33
|
-
* @param {number} [options.relativeTimeMinutesBefore] - Minutes before the date within which to show "in xx minutes"
|
|
34
|
-
* @param {number} [options.relativeTimeMinutesAfter] - Minutes after the date within which to show the now string
|
|
35
|
-
* @param {boolean} [options.relativeTimeShowTime] - Show the actual time alongside relative date labels
|
|
36
|
-
* @param {string} [options.relativeTimeShowTimeMarkup] - HTML markup for the time portion; `@@time@@` is replaced with the localized time string
|
|
37
|
-
* @param {boolean} [options.firstLetterUpperCase] - Capitalize the first letter of the returned string
|
|
38
|
-
* @param {Intl.DateTimeFormatOptions} [options.dateFormat] - Format for non-relative dates (beyond day after tomorrow)
|
|
39
|
-
* @param {Intl.DateTimeFormatOptions} [options.timeFormat] - Format for time displayed in relative date labels
|
|
40
|
-
* @param {string[]} [options.relativeStrings] - Labels for yesterday / today / tomorrow / day after tomorrow (in chronological order)
|
|
41
|
-
* @param {string} [options.locale] - Locale string for date/time formatting
|
|
30
|
+
* @param {object} [options={}] (default: {})
|
|
31
|
+
* @param {boolean} [options.useRelativeTime=true] - Show times near the date as "in xx minutes" (before) or "now" (within `relativeTimeMinutesAfter`) (default: true)
|
|
32
|
+
* @param {string} [options.nowString] - String to display when the date is right now (default: 'adesso')
|
|
33
|
+
* @param {number} [options.relativeTimeMinutesBefore] - Minutes before the date within which to show "in xx minutes" (default: 30)
|
|
34
|
+
* @param {number} [options.relativeTimeMinutesAfter] - Minutes after the date within which to show the now string (default: 30)
|
|
35
|
+
* @param {boolean} [options.relativeTimeShowTime] - Show the actual time alongside relative date labels (default: true)
|
|
36
|
+
* @param {string} [options.relativeTimeShowTimeMarkup] - HTML markup for the time portion; `@@time@@` is replaced with the localized time string (default: ' <span class="time-info">(alle @@time@@)</span>')
|
|
37
|
+
* @param {boolean} [options.firstLetterUpperCase] - Capitalize the first letter of the returned string (default: true)
|
|
38
|
+
* @param {Intl.DateTimeFormatOptions} [options.dateFormat] - Format for non-relative dates (beyond day after tomorrow) (default: { weekday: 'short', year: 'numeric', month: 'short', day: 'numeric', hour12: false, hour: '2-digit', minute: '2-digit' })
|
|
39
|
+
* @param {Intl.DateTimeFormatOptions} [options.timeFormat] - Format for time displayed in relative date labels (default: { hour12: false, hour: '2-digit', minute: '2-digit' })
|
|
40
|
+
* @param {string[]} [options.relativeStrings] - Labels for yesterday / today / tomorrow / day after tomorrow (in chronological order) (default: ['ieri alle', 'oggi alle', 'domani alle', 'dopodomani alle'])
|
|
41
|
+
* @param {string} [options.locale] - Locale string for date/time formatting (default: 'it-IT')
|
|
42
42
|
* @returns {string} HTML `<time>` element as a string
|
|
43
43
|
*
|
|
44
44
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat
|
|
@@ -83,7 +83,7 @@ export function relativeDate(date, options = {}) {
|
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
85
|
* @param {Date | string} dateInput
|
|
86
|
-
* @param {RelativeDateOptions} [overrideOptions={}]
|
|
86
|
+
* @param {RelativeDateOptions} [overrideOptions={}] (default: {})
|
|
87
87
|
* @returns {string}
|
|
88
88
|
*/
|
|
89
89
|
const parseDate = (dateInput, overrideOptions = {}) => {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @param {string} str - string yo be truncated
|
|
10
10
|
* @param {number} maxLength - truncated string max length
|
|
11
|
-
* @param {string} suffix
|
|
11
|
+
* @param {string} suffix (default: '…')
|
|
12
12
|
* @returns {string|undefined} truncated string, or undefined if str is falsy
|
|
13
13
|
*
|
|
14
14
|
*/
|
|
@@ -73,7 +73,7 @@ import caretRightIcon from '../../icons/caret-right.svg?inline';
|
|
|
73
73
|
* @property {string} [_renderNullAs] Stringa da mostrare al posto di valori null/undefined.
|
|
74
74
|
* Default: `'—'` (trattino em).
|
|
75
75
|
* Applicato al valore della cella e ai segnaposto
|
|
76
|
-
* di `_cellRender` che si risolvono a null.
|
|
76
|
+
* di `_cellRender` che si risolvono a null. (default: '—')
|
|
77
77
|
* @property {'id'|'email'|'sf_datetime'} [_renderMode]
|
|
78
78
|
* Modalità di visualizzazione predefinita:
|
|
79
79
|
* - `id` – colonna numerica, non ricercabile, allineata a destra
|
|
@@ -96,22 +96,22 @@ import caretRightIcon from '../../icons/caret-right.svg?inline';
|
|
|
96
96
|
* @param {ColDefinition[]} cols Definizione delle colonne. Le chiavi con prefisso `_` sono
|
|
97
97
|
* proprietà di questo componente; le restanti vengono passate
|
|
98
98
|
* direttamente a simple-datatables (es. `sortable`, `searchable`).
|
|
99
|
-
* Default: `[]`
|
|
99
|
+
* Default: `[]` (default: [])
|
|
100
100
|
*
|
|
101
101
|
* @param {number} perPage Numero di righe per pagina.
|
|
102
|
-
* Default: `25`
|
|
102
|
+
* Default: `25` (default: 25)
|
|
103
103
|
*
|
|
104
104
|
* @param {string} renderNullAs Stringa globale da mostrare al posto di valori null/undefined
|
|
105
105
|
* in tutte le colonne. Può essere sovrascritto per singola
|
|
106
106
|
* colonna con `_renderNullAs`.
|
|
107
|
-
* Default: `\u2014` (em dash)
|
|
107
|
+
* Default: `\u2014` (em dash) (default: '\u2014')
|
|
108
108
|
*
|
|
109
109
|
* @param {boolean} updateFooterOnPageChange Se true, la callback `_footerRender` riceve i soli record
|
|
110
110
|
* della pagina corrente (subtotale di pagina). Se false
|
|
111
111
|
* (default), riceve l'intero set filtrato indipendentemente
|
|
112
112
|
* dalla paginazione (totale complessivo).
|
|
113
113
|
* Quando è false il footer si aggiorna solo al cambio di
|
|
114
|
-
* filtro, non al cambio pagina.
|
|
114
|
+
* filtro, non al cambio pagina. (default: false)
|
|
115
115
|
*
|
|
116
116
|
* @param {string[]} refs Elenco di percorsi URL da cui, se si proviene,
|
|
117
117
|
* la pagina corrente viene ripristinata dal cookie
|
|
@@ -166,7 +166,7 @@ function getNestedValue(obj, path) {
|
|
|
166
166
|
*
|
|
167
167
|
* @param {string|Function|Node} tpl Template da risolvere.
|
|
168
168
|
* @param {object|null} row Oggetto riga corrente (null per le intestazioni).
|
|
169
|
-
* @param {object} [opts] Opzioni aggiuntive.
|
|
169
|
+
* @param {object} [opts] Opzioni aggiuntive. (default: {})
|
|
170
170
|
* @param {string} [opts.nullAs] Stringa da usare come fallback per i segnaposto
|
|
171
171
|
* che si risolvono a null (default: `''`).
|
|
172
172
|
* Se non fornita i segnaposto non trovati diventano ''.
|
|
@@ -380,7 +380,7 @@ class SimpleDatatableAdapter extends HTMLElement {
|
|
|
380
380
|
* Ricarica i dati (eventualmente da un nuovo URL e/o con nuove colonne),
|
|
381
381
|
* con possibilità di applicare un filtro contestuale al termine del fetch.
|
|
382
382
|
*
|
|
383
|
-
* @param {object} [overrides]
|
|
383
|
+
* @param {object} [overrides] (default: {})
|
|
384
384
|
* @param {string} [overrides.json] Nuovo URL dati (ignorato se `data` è presente)
|
|
385
385
|
* @param {Array} [overrides.data] Dati inline (array di oggetti); ha precedenza su `json`
|
|
386
386
|
* @param {Array} [overrides.cols] Nuove colonne
|
|
@@ -23,13 +23,13 @@ const PUNCTUATION_RX = /[.,/#!$%^&*;:{}=\-_`~()]/g;
|
|
|
23
23
|
* troverebbe "S.p.A.".
|
|
24
24
|
*
|
|
25
25
|
* @param {*} str Valore da normalizzare (convertito con String()).
|
|
26
|
-
* @param {object} [opts]
|
|
26
|
+
* @param {object} [opts] (default: {})
|
|
27
27
|
* @param {'base'|'accent'|'case'|'variant'} [opts.sensitivity='base']
|
|
28
28
|
* 'base' → ignora maiuscole/minuscole e diacritici
|
|
29
29
|
* 'accent' → ignora maiuscole/minuscole, mantiene i diacritici
|
|
30
30
|
* 'case' → distingue maiuscole/minuscole, ignora i diacritici
|
|
31
|
-
* 'variant' → distingue tutto
|
|
32
|
-
* @param {boolean} [opts.ignorePunctuation=true]
|
|
31
|
+
* 'variant' → distingue tutto (default: 'base')
|
|
32
|
+
* @param {boolean} [opts.ignorePunctuation=true] (default: true)
|
|
33
33
|
* @returns {string}
|
|
34
34
|
*/
|
|
35
35
|
export function normalizeSearchString(str, opts = {}) {
|
|
@@ -63,7 +63,7 @@ export function normalizeSearchString(str, opts = {}) {
|
|
|
63
63
|
* Comportamento AND: tutti i termini devono essere presenti
|
|
64
64
|
* (come nella demo https://fiduswriter.github.io/simple-datatables/demos/22-and-search/).
|
|
65
65
|
*
|
|
66
|
-
* @param {object} [colSettings] Definizione della colonna (per `sensitivity` / `ignorePunctuation`).
|
|
66
|
+
* @param {object} [colSettings] Definizione della colonna (per `sensitivity` / `ignorePunctuation`). (default: {})
|
|
67
67
|
* @returns {(terms: string[], cell: object) => boolean}
|
|
68
68
|
*/
|
|
69
69
|
export function makeSearchMethod(colSettings = {}) {
|