@massimo-cassandro/minimo 1.24.12 → 1.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -25,7 +25,7 @@ To bootstrap a project **before** installing the whole package, download only th
25
25
 
26
26
  ```bash
27
27
  curl -sL "$(npm view @massimo-cassandro/minimo dist.tarball)" | tar xz package/dev-tools/starter-kit
28
- zsh package/dev-tools/starter-kit/starter-install.sh # --no-npm
28
+ zsh package/dev-tools/starter-kit/starter-install.sh
29
29
  rm -rf package
30
30
  ```
31
31
 
@@ -81,6 +81,10 @@ const config = {
81
81
  name: 'LAYOUT',
82
82
  prefixes: ['body', 'layout'],
83
83
  },
84
+ {
85
+ name: 'UI',
86
+ prefixes: ['ui'],
87
+ },
84
88
  ],
85
89
 
86
90
 
@@ -278,9 +278,9 @@ else
278
278
  safe_cat "${MINIMO_PKG_DIR}/dev-tools/create-favicons/src/default-params.mjs" "${FRONTEND_INSTALL_PATH}/favicons/create-favicons-cfg.mjs"
279
279
  fi
280
280
 
281
- # entry css critical (inlinata nei template html) e entry js, sulla root di
281
+ # entry css critical (inline nei template html) e entry js, sulla root di
282
282
  # installazione accanto a index.css
283
- safe_cat "${TEMPLATES_DIR}/index-critical.css" "${FRONTEND_INSTALL_PATH}/index-critical.css"
283
+ safe_cat "${TEMPLATES_DIR}/layout-critical.css" "${FRONTEND_INSTALL_PATH}/src/css/layout-critical.css"
284
284
  safe_cat "${TEMPLATES_DIR}/app_index.js" "${FRONTEND_INSTALL_PATH}/index.js"
285
285
 
286
286
  # favicons: istruzioni d'uso di `npx create-favicons`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massimo-cassandro/minimo",
3
- "version": "1.24.12",
3
+ "version": "1.25.0",
4
4
  "description": "Light css framework & utilities",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -14,10 +14,11 @@ import { parseDomString } from './parseDomString.js';
14
14
  * @property {string | string[]} [classname] - Alias for `className`.
15
15
  * @property {string | null} [id] - Unique element ID.
16
16
  * @property {[string, *] | [string, *][] | Object<string, *>} [attrs] - Attributes: a `[name, value]` pair, array of pairs, or `{name: value}` object.
17
- * @property {string | number | Function | Element | DomBuilderItem[] | null} [content] - Element content.
17
+ * @property {string | number | Function | Node | DomBuilderItem[] | null} [content] - Element content.
18
18
  * A string or number is set as plain text (`textContent`) unless it contains `<`, in which case it is
19
19
  * treated as markup: sanitized and inserted via the native Sanitizer API (`Element.setHTML`) where
20
- * supported, falling back to raw `innerHTML` on browsers without it.
20
+ * supported, falling back to raw `innerHTML` on browsers without it. A `Node` (an `Element`, a
21
+ * `DocumentFragment`, ...) is appended as-is, either directly or returned from a function.
21
22
  * @property {string | number} [text] - Literal text node shorthand: inserts a plain `Text` node (never
22
23
  * parsed as markup) in place of an element, so it can sit as a sibling of tags within `children`/`content`
23
24
  * arrays. Mutually exclusive with `tag`/`content`/`children`: when set (and `tag` is absent), every other
@@ -44,7 +45,7 @@ import { parseDomString } from './parseDomString.js';
44
45
  * className: 'xxx' | ['class1', 'class2'], // also `class`
45
46
  * id: 'element-id',
46
47
  * attrs: [attr_name, attr_value] | [[...], [...]] | {name: value},
47
- * content: 'xxx' | 'xxx <strong>yyy</strong>' | 123 | domBuilder Array | function | Element, // see DomBuilderItem.content above
48
+ * content: 'xxx' | 'xxx <strong>yyy</strong>' | 123 | domBuilder Array | function | Node, // see DomBuilderItem.content above
48
49
  * condition: true | false,
49
50
  * callback: el => ...,
50
51
  * children: [...]
@@ -89,7 +90,7 @@ import { parseDomString } from './parseDomString.js';
89
90
  * - `className` / `class` / `classname` {string | string[]} - CSS class(es): a single string or an array (falsy values filtered out).
90
91
  * - `id` {string | null} - Unique element ID.
91
92
  * - `attrs` {[string, *] | [string, *][] | Object<string, *>} - Attributes: a `[name, value]` pair, array of pairs, or `{name: value}` object.
92
- * - `content` {string | number | Function | Element | DomBuilderItem[] | null} - Element content. A string/number is set as `textContent` unless it contains `<`, in which case it's sanitized and inserted as markup (`Element.setHTML`, falling back to `innerHTML`).
93
+ * - `content` {string | number | Function | Node | DomBuilderItem[] | null} - Element content. A string/number is set as `textContent` unless it contains `<`, in which case it's sanitized and inserted as markup (`Element.setHTML`, falling back to `innerHTML`). A `Node` (`Element`, `DocumentFragment`, ...), passed directly or returned from a function, is appended as-is.
93
94
  * - `text` {string | number} - Literal text node shorthand: inserts a plain `Text` node (never parsed as markup) as a sibling of other items, in place of an element. Mutually exclusive with `tag`/`content`/`children`.
94
95
  * - `condition` {boolean} - When false, the element (or text node) is skipped. Default `true`.
95
96
  * - `callback` {(function(HTMLElement|Text): void) | null} - Invoked after the element (or text node) is created.
@@ -232,16 +233,21 @@ export function domBuilder(structureArray = [], parent, options = {}) {
232
233
 
233
234
  } else {
234
235
 
235
- /** @type {string | Element | null} */
236
+ /** @type {string | Node | null} */
236
237
  let content = null;
237
238
  if (typeof safeItem.content === 'function') {
238
239
  content = safeItem.content();
239
240
 
241
+ } else if (safeItem.content instanceof Node) {
242
+ content = safeItem.content;
243
+
240
244
  } else if (safeItem.content != null) {
241
245
  content = String(safeItem.content);
242
246
  }
243
247
 
244
- if (content instanceof Element) {
248
+ if (content instanceof Node) {
249
+ // Element, DocumentFragment, Text, ... appended as-is (a DocumentFragment's
250
+ // children are moved into `el`, emptying the fragment, per native DOM behavior)
245
251
  el.appendChild(content);
246
252
 
247
253
  } else if (content != null) {