@massimo-cassandro/minimo 1.8.1 → 1.8.3

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Massimo Cassandro
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massimo-cassandro/minimo",
3
- "version": "1.8.1",
3
+ "version": "1.8.3",
4
4
  "description": "Light css framework & utilities",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -54,9 +54,9 @@
54
54
  }
55
55
  },
56
56
  "devDependencies": {
57
- "@massimo-cassandro/dev-updater": "^3.0.6",
58
- "@massimo-cassandro/eslint-config": "^3.0.9",
59
- "@massimo-cassandro/stylelint-config": "^2.3.9",
60
- "style-dictionary": "^5.4.4"
57
+ "@massimo-cassandro/dev-updater": "^3.0.7",
58
+ "@massimo-cassandro/eslint-config": "^3.0.11",
59
+ "@massimo-cassandro/stylelint-config": "^2.3.11",
60
+ "style-dictionary": "^5.5.0"
61
61
  }
62
62
  }
@@ -40,14 +40,16 @@ function closeDialog(el) {
40
40
  * @param {Object} params
41
41
  * @param {string | null} [params.dialogExtraClassName=null] - Extra class added to the dialog element.
42
42
  * @param {string | null} [params.contentExtraClassName=null] - Extra class added to the content wrapper.
43
+ * @param {string | null} [params.headerExtraClassName=null] - Extra class added to the header wrapper.
44
+ * @param {string | null} [params.footerExtraClassName=null] - Extra class added to the footer wrapper.
43
45
  * @param {string | null} [params.iframeUrl=null] - URL to load in an iframe.
44
46
  * @param {string | any[] | null} [params.content=null] - Plain text, HTML, or a domBuilder array.
45
47
  * @param {string | null} [params.ajaxUrl=null] - URL for Ajax content loading.
46
48
  * @param {((data: *, el: Element) => void) | null} [params.ajaxCallback=null] - Called with the Ajax response and the content element.
47
49
  * @param {((el: HTMLDialogElement) => void) | null} [params.closeCallback=null] - Called with the dialog element just before it is removed.
48
50
  * @param {boolean} [params.addScrollbarPadding=false] - Adds right padding to compensate for the scrollbar.
49
- * @param {string | null} [params.headerContent=null] - Header content: plain text or HTML.
50
- * @param {string | null} [params.footerContent=null] - Footer content: plain text or HTML.
51
+ * @param {string | any[] | null} [params.headerContent=null] - Header content: plain text, HTML, or a domBuilder array.
52
+ * @param {string | any[] | null} [params.footerContent=null] - Footer content: plain text, HTML, or a domBuilder array.
51
53
  * @returns {HTMLDialogElement} The dialog element.
52
54
  */
53
55
  export function modalPopup({
@@ -58,6 +60,12 @@ export function modalPopup({
58
60
  /** extra classname added to dialogInner */
59
61
  contentExtraClassName = null,
60
62
 
63
+ /** extra classname added to header */
64
+ headerExtraClassName = null,
65
+
66
+ /** extra classname added to footer */
67
+ footerExtraClassName = null,
68
+
61
69
  /** iframe url */
62
70
  iframeUrl = null,
63
71
 
@@ -78,10 +86,10 @@ export function modalPopup({
78
86
  closeCallback = null,
79
87
  addScrollbarPadding = false, // adds extra right padding to compensate for the scrollbar
80
88
 
81
- /** header content: plain text or HTML */
89
+ /** header content: plain text, HTML or domBuilder array */
82
90
  headerContent = null,
83
91
 
84
- /** footer content: plain text or HTML */
92
+ /** footer content: plain text, HTML or domBuilder array */
85
93
  footerContent = null,
86
94
  }) {
87
95
 
@@ -129,13 +137,13 @@ export function modalPopup({
129
137
  className: styles.contentWrapper,
130
138
  children: [
131
139
  {
132
- className: styles.header,
140
+ className: classnames(styles.header, headerExtraClassName),
133
141
  condition: headerContent != null,
134
- content: headerContent
142
+ content: Array.isArray(headerContent) ? null : headerContent,
143
+ children: Array.isArray(headerContent) ? headerContent : undefined
135
144
  },
136
145
  {
137
146
  className: classnames(styles.content, contentExtraClassName),
138
-
139
147
  content: mode === 'html'
140
148
  ? content
141
149
  : mode === 'ajax'
@@ -177,9 +185,10 @@ export function modalPopup({
177
185
  },
178
186
  },
179
187
  {
180
- className: styles.footer,
188
+ className: classnames(styles.footer, footerExtraClassName),
181
189
  condition: footerContent != null,
182
- content: footerContent
190
+ content: Array.isArray(footerContent) ? null : footerContent,
191
+ children: Array.isArray(footerContent) ? footerContent : undefined
183
192
  },
184
193
  ]
185
194
  }
@@ -6,8 +6,12 @@ example:
6
6
 
7
7
  const form = document.getElementById('form-__xxxx___');
8
8
  form.addEventListener('submit', e => {
9
+
10
+ // TODO disableBtnOnSubmit ??
11
+
9
12
  form.querySelectorAll('.is-invalid').forEach(item => {
10
13
  item.classList.remove('is-invalid');
14
+ item.setCustomValidity('');
11
15
  });
12
16
  form.classList.add('was-validated');
13
17
  try {
@@ -16,12 +20,22 @@ form.addEventListener('submit', e => {
16
20
  }
17
21
  } catch( error ) {
18
22
  e.preventDefault();
19
- form.querySelector('[type="submit"]').disabled = false;
23
+ enableSubmitBtns();
20
24
 
21
25
  if (error instanceof ValidationError) {
22
26
 
23
27
  (error.fields??[]).forEach(field => {
24
28
  field.classList.add('is-invalid');
29
+ field.setCustomValidity(error.message);
30
+
31
+ // rimuove il setCustomValidity alla modifica del campo
32
+ field.addEventListener('input', () => {
33
+ field.setCustomValidity('');
34
+ field.classList.remove('is-invalid');
35
+
36
+ // rimuove la classe che attiva la visualizzaione
37
+ form.classList.remove('was-validated');
38
+ }, {once: true});
25
39
  });
26
40
 
27
41
  error.fields[0]?.focus({preventScroll:false});