nodality 1.0.135 → 1.0.136
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/dist/bundle.umd.js +1 -1
- package/dist/finalresult.esm.js +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/layout/animator.js +1 -1
- package/layout/audio.js +1 -1
- package/layout/audionew.js +1 -1
- package/layout/base-2.js +1 -1
- package/layout/base.js +1 -1
- package/layout/beta-desktop-bar.js +1 -1
- package/layout/beta-mobile-bar.js +1 -1
- package/layout/box.js +1 -1
- package/layout/button.js +1 -1
- package/layout/cards.js +1 -1
- package/layout/center.js +1 -1
- package/layout/checkbox.js +1 -1
- package/layout/circle.js +1 -1
- package/layout/clean-row.js +1 -1
- package/layout/code.js +1 -1
- package/layout/container.js +1 -1
- package/layout/custom.js +1 -1
- package/layout/div-image.js +1 -1
- package/layout/dropdown-2025.js +1 -1
- package/layout/dropdown.js +1 -1
- package/layout/empty-element.js +1 -1
- package/layout/external-stylesheet.js +1 -1
- package/layout/flex-card.js +1 -1
- package/layout/flex-grid.js +1 -1
- package/layout/flex-row.js +1 -1
- package/layout/footer.js +1 -1
- package/layout/form-components/custom.js +1 -1
- package/layout/form-components/data-list.js +1 -1
- package/layout/form-components/floating-input.js +1 -1
- package/layout/form-components/form-all.js +1 -1
- package/layout/form-components/form.js +1 -1
- package/layout/form-components/image-picker.js +1 -1
- package/layout/form-components/picker.js +1 -1
- package/layout/form-components/radio.js +1 -1
- package/layout/form-components/radiogroup.js +1 -1
- package/layout/form-components/range.js +1 -1
- package/layout/free.js +1 -1
- package/layout/grid-new.js +1 -1
- package/layout/grid-switcher.js +1 -1
- package/layout/grid.js +1 -1
- package/layout/group.js +1 -1
- package/layout/header.js +1 -1
- package/layout/horizontal-scroller.js +1 -1
- package/layout/image-old.js +1 -1
- package/layout/image.js +1 -1
- package/layout/index.js +5 -1
- package/layout/label.js +1 -1
- package/layout/link.js +1 -1
- package/layout/list-OLD.js +1 -1
- package/layout/list.js +1 -1
- package/layout/meta-adder.js +1 -1
- package/layout/modal-2025.js +1 -1
- package/layout/modernwrap.js +1 -1
- package/layout/multiswitcher.js +1 -1
- package/layout/multiswitcherBeta.js +1 -1
- package/layout/nav-bar.js +1 -1
- package/layout/nav-factor/custom-div.js +1 -1
- package/layout/navBar-OLD.js +1 -1
- package/layout/new-flat-adder.js +1 -1
- package/layout/new-nav-bar.js +1 -1
- package/layout/offset-container.js +1 -1
- package/layout/polygon.js +1 -1
- package/layout/progress.js +1 -1
- package/layout/row.js +1 -1
- package/layout/saved-new-nav-bar.js +1 -1
- package/layout/scroll-video.js +1 -1
- package/layout/side-bar.js +1 -1
- package/layout/side-nav-bar.js +1 -1
- package/layout/simple-bar.js +1 -1
- package/layout/slider-2025.js +1 -1
- package/layout/spacer.js +1 -1
- package/layout/stack.js +1 -1
- package/layout/styler.js +1 -1
- package/layout/svg.js +112 -0
- package/layout/switcher.js +1 -1
- package/layout/table.js +1 -1
- package/layout/text-field.js +1 -1
- package/layout/text.js +1 -1
- package/layout/ulist.js +1 -1
- package/layout/video.js +1 -1
- package/layout/without-new.js +1 -1
- package/layout/wrap.js +1 -1
- package/layout/zoom-card.js +1 -1
- package/lib/card-getter.js +1 -1
- package/lib/designer.js +1 -1
- package/lib/element-mapper.js +1 -1
- package/lib/keyframe-animation.js +1 -1
- package/lib/link-getter.js +1 -1
- package/lib/scroll-video.js +1 -1
- package/lib/stacker.js +1 -1
- package/lib/theme.js +1 -1
- package/lib/transform-anim.js +1 -1
- package/package.json +1 -1
package/layout/svg.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* nodality v1.0.136
|
|
3
|
+
* (c) 2026 Filip Vabrousek
|
|
4
|
+
* License: MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Wrapper } from "./container.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Svg — a Nodality primitive for inline SVG icons.
|
|
11
|
+
*
|
|
12
|
+
* Fills the gap that `Image` can't: `<img src=data:…svg…>` doesn't inherit
|
|
13
|
+
* `currentColor`, so you can't recolor an icon via the host's `color` style.
|
|
14
|
+
* `Svg` mounts raw SVG markup *into* the host element, so strokes/fills using
|
|
15
|
+
* `stroke="currentColor"` / `fill="currentColor"` follow the host's color —
|
|
16
|
+
* and they transition when `color` transitions.
|
|
17
|
+
*
|
|
18
|
+
* Usage:
|
|
19
|
+
* new Svg(`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
|
20
|
+
* stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
21
|
+
* <polyline points="6 9 12 15 18 9"/>
|
|
22
|
+
* </svg>`).set({
|
|
23
|
+
* width: "20px",
|
|
24
|
+
* height: "20px",
|
|
25
|
+
* color: "#6B7280",
|
|
26
|
+
* keySet: [{ key: "transition", value: "transform 0.25s ease, color 0.25s ease" }],
|
|
27
|
+
* })
|
|
28
|
+
*
|
|
29
|
+
* Swap the glyph after mount:
|
|
30
|
+
* chev.setSvg(newSvgMarkup);
|
|
31
|
+
*/
|
|
32
|
+
class Svg extends Wrapper {
|
|
33
|
+
constructor(markup) {
|
|
34
|
+
// Wrapper's constructor accepts `obj` that controls the element type.
|
|
35
|
+
// We always want a <div>-style host for the SVG, so pass nothing.
|
|
36
|
+
super();
|
|
37
|
+
this.svgMarkup = typeof markup === "string" ? markup : "";
|
|
38
|
+
|
|
39
|
+
// Defaults that make an icon behave like one: shrink-stable, inline with
|
|
40
|
+
// adjacent text, SVG centered inside whatever width/height the caller sets.
|
|
41
|
+
this.res.style.display = "inline-flex";
|
|
42
|
+
this.res.style.alignItems = "center";
|
|
43
|
+
this.res.style.justifyContent = "center";
|
|
44
|
+
this.res.style.flexShrink = "0";
|
|
45
|
+
// Prevent the host's line-box from padding above/below the SVG glyph.
|
|
46
|
+
this.res.style.lineHeight = "0";
|
|
47
|
+
|
|
48
|
+
this.res.innerHTML = this.svgMarkup;
|
|
49
|
+
|
|
50
|
+
// Best-effort: make the inner <svg> fill the host so the caller's
|
|
51
|
+
// width/height on the host controls the glyph size even if the SVG
|
|
52
|
+
// markup didn't declare width/height attributes.
|
|
53
|
+
this._sizeInner();
|
|
54
|
+
|
|
55
|
+
this.code = [];
|
|
56
|
+
this.code.push("\n new Svg() \n");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
_sizeInner() {
|
|
60
|
+
const svg = this.res.querySelector("svg");
|
|
61
|
+
if (!svg) return;
|
|
62
|
+
if (!svg.getAttribute("width")) svg.setAttribute("width", "100%");
|
|
63
|
+
if (!svg.getAttribute("height")) svg.setAttribute("height", "100%");
|
|
64
|
+
// display:block kills the baseline gap some browsers add under inline SVG.
|
|
65
|
+
svg.style.display = "block";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Replace the SVG markup after mount — handy for state-change icon swaps
|
|
70
|
+
* (e.g. chevron ↔ x, sun ↔ moon). Returns `this` for chaining.
|
|
71
|
+
*/
|
|
72
|
+
setSvg(markup) {
|
|
73
|
+
this.svgMarkup = typeof markup === "string" ? markup : "";
|
|
74
|
+
this.res.innerHTML = this.svgMarkup;
|
|
75
|
+
this._sizeInner();
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Shortcut for setting a square size on both axes.
|
|
81
|
+
* new Svg(markup).size(20) // 20×20
|
|
82
|
+
* new Svg(markup).size("1.25rem")
|
|
83
|
+
*/
|
|
84
|
+
size(dim) {
|
|
85
|
+
const v = typeof dim === "number" ? `${dim}px` : dim;
|
|
86
|
+
this.res.style.width = v;
|
|
87
|
+
this.res.style.height = v;
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
toCode(indent = 0) {
|
|
92
|
+
if (this.excludeFromCodeTrue) return [""];
|
|
93
|
+
const pad = " ".repeat(indent);
|
|
94
|
+
// Use a template literal so the SVG's inner quotes survive round-trips.
|
|
95
|
+
const esc = (this.svgMarkup || "").replace(/`/g, "\\`").replace(/\$\{/g, "\\${");
|
|
96
|
+
let code = `${pad}new Svg(\`${esc}\`)`;
|
|
97
|
+
|
|
98
|
+
if (this.obj && Object.keys(this.obj).length) {
|
|
99
|
+
const cleanedObj = Object.fromEntries(
|
|
100
|
+
Object.entries(this.obj).filter(([k, v]) => v !== null)
|
|
101
|
+
);
|
|
102
|
+
const objString = JSON
|
|
103
|
+
.stringify(cleanedObj, null, 2)
|
|
104
|
+
.replace(/"([^"]+)":/g, "$1:");
|
|
105
|
+
code += `\n${pad} .set(${objString})`;
|
|
106
|
+
}
|
|
107
|
+
code += `\n${pad}`;
|
|
108
|
+
return [code];
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export { Svg };
|
package/layout/switcher.js
CHANGED
package/layout/table.js
CHANGED
package/layout/text-field.js
CHANGED
package/layout/text.js
CHANGED
package/layout/ulist.js
CHANGED
package/layout/video.js
CHANGED
package/layout/without-new.js
CHANGED
package/layout/wrap.js
CHANGED
package/layout/zoom-card.js
CHANGED
package/lib/card-getter.js
CHANGED
package/lib/designer.js
CHANGED
package/lib/element-mapper.js
CHANGED
package/lib/link-getter.js
CHANGED
package/lib/scroll-video.js
CHANGED
package/lib/stacker.js
CHANGED
package/lib/theme.js
CHANGED
package/lib/transform-anim.js
CHANGED