@rettangoli/ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -0
- package/dist/rettangoli-iife-layout.min.js +728 -0
- package/dist/rettangoli-iife-ui.min.js +830 -0
- package/package.json +53 -0
- package/src/common/BaseElement.js +182 -0
- package/src/common.js +190 -0
- package/src/components/dialog/dialog.handlers.js +5 -0
- package/src/components/dialog/dialog.store.js +25 -0
- package/src/components/dialog/dialog.view.yaml +44 -0
- package/src/components/dropdownMenu/dropdownMenu.handlers.js +18 -0
- package/src/components/dropdownMenu/dropdownMenu.store.js +25 -0
- package/src/components/dropdownMenu/dropdownMenu.view.yaml +54 -0
- package/src/components/form/form.handlers.js +63 -0
- package/src/components/form/form.store.js +45 -0
- package/src/components/form/form.view.yaml +174 -0
- package/src/components/navbar/navbar.examples.yaml +86 -0
- package/src/components/navbar/navbar.handlers.js +10 -0
- package/src/components/navbar/navbar.store.js +46 -0
- package/src/components/navbar/navbar.view.yaml +74 -0
- package/src/components/pageOutline/pageOutline.handlers.js +69 -0
- package/src/components/pageOutline/pageOutline.store.js +40 -0
- package/src/components/pageOutline/pageOutline.view.yaml +34 -0
- package/src/components/popover/popover.handlers.js +5 -0
- package/src/components/popover/popover.store.js +12 -0
- package/src/components/popover/popover.view.yaml +57 -0
- package/src/components/select/select.handlers.js +61 -0
- package/src/components/select/select.store.js +65 -0
- package/src/components/select/select.view.yaml +50 -0
- package/src/components/sidebar/sidebar.handlers.js +36 -0
- package/src/components/sidebar/sidebar.store.js +142 -0
- package/src/components/sidebar/sidebar.view.yaml +190 -0
- package/src/components/table/table.handlers.js +55 -0
- package/src/components/table/table.store.js +72 -0
- package/src/components/table/table.view.yaml +103 -0
- package/src/entry-iife-layout.js +15 -0
- package/src/entry-iife-ui.js +22 -0
- package/src/index.js +17 -0
- package/src/lib/uhtml.js +9 -0
- package/src/primitives/button.js +306 -0
- package/src/primitives/colorPicker.js +213 -0
- package/src/primitives/image.js +234 -0
- package/src/primitives/input.js +218 -0
- package/src/primitives/slider.js +269 -0
- package/src/primitives/svg.js +95 -0
- package/src/primitives/text.js +141 -0
- package/src/primitives/textarea.js +103 -0
- package/src/primitives/view.js +217 -0
- package/src/setup.js +16 -0
- package/src/styles/anchorStyles.js +13 -0
- package/src/styles/buttonMarginStyles.js +84 -0
- package/src/styles/cursorStyles.js +12 -0
- package/src/styles/flexChildStyles.js +43 -0
- package/src/styles/flexDirectionStyles.js +74 -0
- package/src/styles/marginStyles.js +13 -0
- package/src/styles/paddingSvgStyles.js +120 -0
- package/src/styles/scrollStyles.js +22 -0
- package/src/styles/textColorStyles.js +14 -0
- package/src/styles/textStyles.js +62 -0
- package/src/styles/viewStyles.js +114 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { css, dimensionWithUnit } from "../common.js";
|
|
2
|
+
import flexChildStyles from "../styles/flexChildStyles.js";
|
|
3
|
+
import paddingSvgStyles from "../styles/paddingSvgStyles.js";
|
|
4
|
+
import cursorStyles from "../styles/cursorStyles.js";
|
|
5
|
+
import textColorStyles from "../styles/textColorStyles.js";
|
|
6
|
+
|
|
7
|
+
// Internal implementation without uhtml
|
|
8
|
+
class RettangoliSvgElement extends HTMLElement {
|
|
9
|
+
static styleSheet = null;
|
|
10
|
+
static _icons = {};
|
|
11
|
+
|
|
12
|
+
static initializeStyleSheet() {
|
|
13
|
+
if (!RettangoliSvgElement.styleSheet) {
|
|
14
|
+
RettangoliSvgElement.styleSheet = new CSSStyleSheet();
|
|
15
|
+
RettangoliSvgElement.styleSheet.replaceSync(css`
|
|
16
|
+
:host {
|
|
17
|
+
color: var(--foreground);
|
|
18
|
+
}
|
|
19
|
+
${textColorStyles}
|
|
20
|
+
${paddingSvgStyles}
|
|
21
|
+
${flexChildStyles}
|
|
22
|
+
${cursorStyles}
|
|
23
|
+
`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
constructor() {
|
|
28
|
+
super();
|
|
29
|
+
RettangoliSvgElement.initializeStyleSheet();
|
|
30
|
+
this.shadow = this.attachShadow({ mode: "closed" });
|
|
31
|
+
this.shadow.adoptedStyleSheets = [RettangoliSvgElement.styleSheet];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static get observedAttributes() {
|
|
35
|
+
return ["key", "svg", "w", "h", "wh"];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static get icons() {
|
|
39
|
+
return RettangoliSvgElement._icons;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static addIcon(iconName, icon) {
|
|
43
|
+
RettangoliSvgElement._icons[iconName] = icon;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
connectedCallback() {
|
|
47
|
+
this._updateSizing();
|
|
48
|
+
this._render();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
52
|
+
this._updateSizing();
|
|
53
|
+
this._render();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
_updateSizing() {
|
|
57
|
+
const wh = this.getAttribute("wh");
|
|
58
|
+
const width = dimensionWithUnit(
|
|
59
|
+
wh === null ? this.getAttribute("w") : wh
|
|
60
|
+
);
|
|
61
|
+
const height = dimensionWithUnit(
|
|
62
|
+
wh === null ? this.getAttribute("h") : wh
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
if (width) {
|
|
66
|
+
this.style.width = width;
|
|
67
|
+
}
|
|
68
|
+
if (height) {
|
|
69
|
+
this.style.height = height;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
_render() {
|
|
74
|
+
try {
|
|
75
|
+
const iconName = this.getAttribute("svg");
|
|
76
|
+
const svgStringContent =
|
|
77
|
+
RettangoliSvgElement._icons[iconName] ||
|
|
78
|
+
(window["rtglIcons"] || {})[iconName];
|
|
79
|
+
if (svgStringContent) {
|
|
80
|
+
this.shadow.innerHTML = svgStringContent;
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
} catch (error) {
|
|
84
|
+
console.log("error in rtgl-svg render", error);
|
|
85
|
+
}
|
|
86
|
+
this.shadow.innerHTML = "";
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Export factory function to maintain API compatibility
|
|
91
|
+
export default ({ render, html }) => {
|
|
92
|
+
// Note: render and html parameters are accepted but not used
|
|
93
|
+
// This maintains backward compatibility with existing code
|
|
94
|
+
return RettangoliSvgElement;
|
|
95
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { css, dimensionWithUnit } from "../common.js";
|
|
2
|
+
import cursorStyles from "../styles/cursorStyles.js";
|
|
3
|
+
import textStyles from "../styles/textStyles.js";
|
|
4
|
+
import textColorStyles from "../styles/textColorStyles.js";
|
|
5
|
+
import marginStyles from "../styles/marginStyles.js";
|
|
6
|
+
|
|
7
|
+
// Internal implementation without uhtml
|
|
8
|
+
class RettangoliTextElement extends HTMLElement {
|
|
9
|
+
static styleSheet = null;
|
|
10
|
+
|
|
11
|
+
static initializeStyleSheet() {
|
|
12
|
+
if (!RettangoliTextElement.styleSheet) {
|
|
13
|
+
RettangoliTextElement.styleSheet = new CSSStyleSheet();
|
|
14
|
+
RettangoliTextElement.styleSheet.replaceSync(css`
|
|
15
|
+
:host {
|
|
16
|
+
display: block;
|
|
17
|
+
font-size: var(--md-font-size);
|
|
18
|
+
font-weight: var(--md-font-weight);
|
|
19
|
+
line-height: var(--md-line-height);
|
|
20
|
+
letter-spacing: var(--md-letter-spacing);
|
|
21
|
+
}
|
|
22
|
+
slot {
|
|
23
|
+
display: contents;
|
|
24
|
+
}
|
|
25
|
+
:host ::slotted(a) {
|
|
26
|
+
text-decoration: var(--anchor-text-decoration);
|
|
27
|
+
color: var(--anchor-color);
|
|
28
|
+
}
|
|
29
|
+
:host ::slotted(a:hover) {
|
|
30
|
+
text-decoration: var(--anchor-text-decoration-hover);
|
|
31
|
+
color: var(--anchor-color-hover);
|
|
32
|
+
}
|
|
33
|
+
:host([href]) {
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
position: relative;
|
|
36
|
+
}
|
|
37
|
+
:host([href]) a {
|
|
38
|
+
position: absolute;
|
|
39
|
+
top: 0;
|
|
40
|
+
left: 0;
|
|
41
|
+
right: 0;
|
|
42
|
+
bottom: 0;
|
|
43
|
+
z-index: 1;
|
|
44
|
+
}
|
|
45
|
+
${textStyles}
|
|
46
|
+
${textColorStyles}
|
|
47
|
+
${marginStyles}
|
|
48
|
+
${cursorStyles}
|
|
49
|
+
`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
constructor() {
|
|
54
|
+
super();
|
|
55
|
+
RettangoliTextElement.initializeStyleSheet();
|
|
56
|
+
this.shadow = this.attachShadow({ mode: "closed" });
|
|
57
|
+
this.shadow.adoptedStyleSheets = [RettangoliTextElement.styleSheet];
|
|
58
|
+
|
|
59
|
+
// Create initial DOM structure
|
|
60
|
+
this._slotElement = document.createElement('slot');
|
|
61
|
+
this._linkElement = null;
|
|
62
|
+
this._updateDOM();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static get observedAttributes() {
|
|
66
|
+
return ["key", "w", "ellipsis", "href", "target"];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
connectedCallback() {
|
|
70
|
+
this._updateStyling();
|
|
71
|
+
this._updateDOM();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
75
|
+
if (name === "href" || name === "target") {
|
|
76
|
+
this._updateDOM();
|
|
77
|
+
} else {
|
|
78
|
+
this._updateStyling();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
_updateStyling() {
|
|
83
|
+
const width = dimensionWithUnit(this.getAttribute("w"));
|
|
84
|
+
const ellipsis = this.hasAttribute("ellipsis");
|
|
85
|
+
|
|
86
|
+
if (ellipsis) {
|
|
87
|
+
this.style.overflow = "hidden";
|
|
88
|
+
this.style.textOverflow = "ellipsis";
|
|
89
|
+
this.style.whiteSpace = "nowrap";
|
|
90
|
+
} else {
|
|
91
|
+
this.style.overflow = "";
|
|
92
|
+
this.style.textOverflow = "";
|
|
93
|
+
this.style.whiteSpace = "";
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (width === "f") {
|
|
97
|
+
this.style.width = "var(--width-stretch)";
|
|
98
|
+
} else if (width !== undefined) {
|
|
99
|
+
this.style.width = width;
|
|
100
|
+
} else {
|
|
101
|
+
this.style.width = "";
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
_updateDOM() {
|
|
106
|
+
const href = this.getAttribute("href");
|
|
107
|
+
const target = this.getAttribute("target");
|
|
108
|
+
|
|
109
|
+
// Ensure slot is always in the shadow DOM
|
|
110
|
+
if (this._slotElement.parentNode !== this.shadow) {
|
|
111
|
+
this.shadow.appendChild(this._slotElement);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (href) {
|
|
115
|
+
if (!this._linkElement) {
|
|
116
|
+
// Create link overlay only if it doesn't exist
|
|
117
|
+
this._linkElement = document.createElement("a");
|
|
118
|
+
this.shadow.appendChild(this._linkElement);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Update link attributes
|
|
122
|
+
this._linkElement.href = href;
|
|
123
|
+
if (target) {
|
|
124
|
+
this._linkElement.target = target;
|
|
125
|
+
} else {
|
|
126
|
+
this._linkElement.removeAttribute("target");
|
|
127
|
+
}
|
|
128
|
+
} else if (this._linkElement) {
|
|
129
|
+
// Remove link overlay
|
|
130
|
+
this.shadow.removeChild(this._linkElement);
|
|
131
|
+
this._linkElement = null;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Export factory function to maintain API compatibility
|
|
137
|
+
export default ({ render, html }) => {
|
|
138
|
+
// Note: render and html parameters are accepted but not used
|
|
139
|
+
// This maintains backward compatibility with existing code
|
|
140
|
+
return RettangoliTextElement;
|
|
141
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { css, dimensionWithUnit } from "../common.js";
|
|
2
|
+
import cursorStyles from "../styles/cursorStyles.js";
|
|
3
|
+
import marginStyles from "../styles/marginStyles.js";
|
|
4
|
+
|
|
5
|
+
// Internal implementation without uhtml
|
|
6
|
+
class RettangoliTextAreaElement extends HTMLElement {
|
|
7
|
+
static styleSheet = null;
|
|
8
|
+
|
|
9
|
+
static initializeStyleSheet() {
|
|
10
|
+
if (!RettangoliTextAreaElement.styleSheet) {
|
|
11
|
+
RettangoliTextAreaElement.styleSheet = new CSSStyleSheet();
|
|
12
|
+
RettangoliTextAreaElement.styleSheet.replaceSync(css`
|
|
13
|
+
:host {
|
|
14
|
+
display: contents;
|
|
15
|
+
}
|
|
16
|
+
textarea {
|
|
17
|
+
font-family: inherit;
|
|
18
|
+
background-color: var(--background);
|
|
19
|
+
font-size: var(--sm-font-size);
|
|
20
|
+
font-weight: var(--sm-font-weight);
|
|
21
|
+
line-height: var(--sm-line-height);
|
|
22
|
+
letter-spacing: var(--sm-letter-spacing);
|
|
23
|
+
border: 1px solid var(--ring);
|
|
24
|
+
border-radius: var(--border-radius-lg);
|
|
25
|
+
padding-top: var(--spacing-md);
|
|
26
|
+
padding-bottom: var(--spacing-md);
|
|
27
|
+
padding-left: var(--spacing-md);
|
|
28
|
+
padding-right: var(--spacing-md);
|
|
29
|
+
color: var(--foreground);
|
|
30
|
+
outline: none;
|
|
31
|
+
}
|
|
32
|
+
textarea:focus {
|
|
33
|
+
border-color: var(--foreground);
|
|
34
|
+
}
|
|
35
|
+
${marginStyles}
|
|
36
|
+
${cursorStyles}
|
|
37
|
+
`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
constructor() {
|
|
42
|
+
super();
|
|
43
|
+
RettangoliTextAreaElement.initializeStyleSheet();
|
|
44
|
+
this.shadow = this.attachShadow({ mode: "closed" });
|
|
45
|
+
this.shadow.adoptedStyleSheets = [RettangoliTextAreaElement.styleSheet];
|
|
46
|
+
|
|
47
|
+
// Create initial DOM structure
|
|
48
|
+
this._textareaElement = document.createElement('textarea');
|
|
49
|
+
this._textareaElement.setAttribute('type', 'text');
|
|
50
|
+
this.shadow.appendChild(this._textareaElement);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static get observedAttributes() {
|
|
54
|
+
return ["key", "w", "ellipsis", "cols", "rows", "placeholder"];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get value() {
|
|
58
|
+
return this._textareaElement.value;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
set value(val) {
|
|
62
|
+
this._textareaElement.value = val;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
connectedCallback() {
|
|
66
|
+
this._updateTextareaAttributes();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
70
|
+
this._updateTextareaAttributes();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
_updateTextareaAttributes() {
|
|
74
|
+
const cols = this.getAttribute("cols");
|
|
75
|
+
const rows = this.getAttribute("rows");
|
|
76
|
+
const placeholder = this.getAttribute("placeholder");
|
|
77
|
+
|
|
78
|
+
if (cols !== null) {
|
|
79
|
+
this._textareaElement.setAttribute("cols", cols);
|
|
80
|
+
} else {
|
|
81
|
+
this._textareaElement.removeAttribute("cols");
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (rows !== null) {
|
|
85
|
+
this._textareaElement.setAttribute("rows", rows);
|
|
86
|
+
} else {
|
|
87
|
+
this._textareaElement.removeAttribute("rows");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (placeholder !== null) {
|
|
91
|
+
this._textareaElement.setAttribute("placeholder", placeholder);
|
|
92
|
+
} else {
|
|
93
|
+
this._textareaElement.removeAttribute("placeholder");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Export factory function to maintain API compatibility
|
|
99
|
+
export default ({ render, html }) => {
|
|
100
|
+
// Note: render and html parameters are accepted but not used
|
|
101
|
+
// This maintains backward compatibility with existing code
|
|
102
|
+
return RettangoliTextAreaElement;
|
|
103
|
+
};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import {
|
|
2
|
+
css,
|
|
3
|
+
dimensionWithUnit,
|
|
4
|
+
convertObjectToCssString,
|
|
5
|
+
styleMapKeys,
|
|
6
|
+
permutateBreakpoints,
|
|
7
|
+
} from "../common.js";
|
|
8
|
+
import flexDirectionStyles from "../styles/flexDirectionStyles.js";
|
|
9
|
+
import cursorStyles from "../styles/cursorStyles.js";
|
|
10
|
+
import scrollStyle from "../styles/scrollStyles.js";
|
|
11
|
+
import stylesGenerator from "../styles/viewStyles.js";
|
|
12
|
+
import marginStyles from "../styles/marginStyles.js";
|
|
13
|
+
import flexChildStyles from "../styles/flexChildStyles.js";
|
|
14
|
+
import anchorStyles from "../styles/anchorStyles.js";
|
|
15
|
+
|
|
16
|
+
// Internal implementation without uhtml
|
|
17
|
+
class RettangoliViewElement extends HTMLElement {
|
|
18
|
+
static styleSheet = null;
|
|
19
|
+
|
|
20
|
+
static initializeStyleSheet() {
|
|
21
|
+
if (!RettangoliViewElement.styleSheet) {
|
|
22
|
+
RettangoliViewElement.styleSheet = new CSSStyleSheet();
|
|
23
|
+
RettangoliViewElement.styleSheet.replaceSync(css`
|
|
24
|
+
slot {
|
|
25
|
+
display: contents;
|
|
26
|
+
}
|
|
27
|
+
:host {
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
align-self: auto;
|
|
31
|
+
align-content: flex-start;
|
|
32
|
+
border-style: solid;
|
|
33
|
+
border-width: 0;
|
|
34
|
+
box-sizing: border-box;
|
|
35
|
+
border-color: var(--border);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
:host([fw="w"]) {
|
|
39
|
+
flex-wrap: wrap;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
${flexChildStyles}
|
|
43
|
+
${scrollStyle}
|
|
44
|
+
${flexDirectionStyles}
|
|
45
|
+
${marginStyles}
|
|
46
|
+
${cursorStyles}
|
|
47
|
+
${stylesGenerator}
|
|
48
|
+
${anchorStyles}
|
|
49
|
+
|
|
50
|
+
:host([href]) {
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
position: relative;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
:host([href]) a {
|
|
56
|
+
position: absolute;
|
|
57
|
+
top: 0;
|
|
58
|
+
left: 0;
|
|
59
|
+
right: 0;
|
|
60
|
+
bottom: 0;
|
|
61
|
+
z-index: 1;
|
|
62
|
+
}
|
|
63
|
+
`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
constructor() {
|
|
68
|
+
super();
|
|
69
|
+
RettangoliViewElement.initializeStyleSheet();
|
|
70
|
+
this.shadow = this.attachShadow({ mode: "closed" });
|
|
71
|
+
this.shadow.adoptedStyleSheets = [RettangoliViewElement.styleSheet];
|
|
72
|
+
|
|
73
|
+
// Create initial DOM structure
|
|
74
|
+
this._styleElement = document.createElement("style");
|
|
75
|
+
this._slotElement = document.createElement("slot");
|
|
76
|
+
this._linkElement = null;
|
|
77
|
+
|
|
78
|
+
this.shadow.appendChild(this._styleElement);
|
|
79
|
+
this._updateDOM();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
static get observedAttributes() {
|
|
83
|
+
return [
|
|
84
|
+
"href",
|
|
85
|
+
"target",
|
|
86
|
+
"op",
|
|
87
|
+
...permutateBreakpoints([
|
|
88
|
+
...styleMapKeys,
|
|
89
|
+
"wh",
|
|
90
|
+
"w",
|
|
91
|
+
"h",
|
|
92
|
+
"hidden",
|
|
93
|
+
"sh",
|
|
94
|
+
"sv",
|
|
95
|
+
]),
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
_styles = {
|
|
100
|
+
default: {},
|
|
101
|
+
sm: {},
|
|
102
|
+
md: {},
|
|
103
|
+
lg: {},
|
|
104
|
+
xl: {},
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
_lastStyleString = "";
|
|
108
|
+
|
|
109
|
+
_updateDOM() {
|
|
110
|
+
const href = this.getAttribute("href");
|
|
111
|
+
const target = this.getAttribute("target");
|
|
112
|
+
|
|
113
|
+
// Ensure slot is always in the shadow DOM
|
|
114
|
+
if (this._slotElement.parentNode !== this.shadow) {
|
|
115
|
+
this.shadow.appendChild(this._slotElement);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (href) {
|
|
119
|
+
if (!this._linkElement) {
|
|
120
|
+
// Create link overlay only if it doesn't exist
|
|
121
|
+
this._linkElement = document.createElement("a");
|
|
122
|
+
this.shadow.appendChild(this._linkElement);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Update link attributes
|
|
126
|
+
this._linkElement.href = href;
|
|
127
|
+
if (target) {
|
|
128
|
+
this._linkElement.target = target;
|
|
129
|
+
} else {
|
|
130
|
+
this._linkElement.removeAttribute("target");
|
|
131
|
+
}
|
|
132
|
+
} else if (this._linkElement) {
|
|
133
|
+
// Remove link overlay
|
|
134
|
+
this.shadow.removeChild(this._linkElement);
|
|
135
|
+
this._linkElement = null;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
140
|
+
// Handle href and target changes
|
|
141
|
+
if (name === "href" || name === "target") {
|
|
142
|
+
this._updateDOM();
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Reset styles for fresh calculation
|
|
147
|
+
this._styles = {
|
|
148
|
+
default: {},
|
|
149
|
+
sm: {},
|
|
150
|
+
md: {},
|
|
151
|
+
lg: {},
|
|
152
|
+
xl: {},
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
["default", "sm", "md", "lg", "xl"].forEach((size) => {
|
|
156
|
+
const addSizePrefix = (tag) => {
|
|
157
|
+
return `${size === "default" ? "" : `${size}-`}${tag}`;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const wh = this.getAttribute(addSizePrefix("wh"));
|
|
161
|
+
const width = dimensionWithUnit(
|
|
162
|
+
wh === null ? this.getAttribute(addSizePrefix("w")) : wh,
|
|
163
|
+
);
|
|
164
|
+
const height = dimensionWithUnit(
|
|
165
|
+
wh === null ? this.getAttribute(addSizePrefix("h")) : wh,
|
|
166
|
+
);
|
|
167
|
+
const opacity = this.getAttribute(addSizePrefix("op"));
|
|
168
|
+
const zIndex = this.getAttribute(addSizePrefix("z"));
|
|
169
|
+
|
|
170
|
+
if (zIndex !== null) {
|
|
171
|
+
this._styles[size]["z-index"] = zIndex;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (opacity !== null) {
|
|
175
|
+
this._styles[size].opacity = opacity;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (width === "f") {
|
|
179
|
+
this._styles[size].width = "var(--width-stretch)";
|
|
180
|
+
} else if (width !== undefined) {
|
|
181
|
+
this._styles[size].width = width;
|
|
182
|
+
this._styles[size]["min-width"] = width;
|
|
183
|
+
this._styles[size]["max-width"] = width;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (height === "f") {
|
|
187
|
+
this._styles[size].height = "100%";
|
|
188
|
+
} else if (height !== undefined) {
|
|
189
|
+
this._styles[size].height = height;
|
|
190
|
+
this._styles[size]["min-height"] = height;
|
|
191
|
+
this._styles[size]["max-height"] = height;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (this.hasAttribute(addSizePrefix("hidden"))) {
|
|
195
|
+
this._styles[size].display = "none !important";
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (this.hasAttribute(addSizePrefix("visible"))) {
|
|
199
|
+
this._styles[size].display = "flex !important";
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
// Update styles only if changed
|
|
204
|
+
const newStyleString = convertObjectToCssString(this._styles);
|
|
205
|
+
if (newStyleString !== this._lastStyleString) {
|
|
206
|
+
this._styleElement.textContent = newStyleString;
|
|
207
|
+
this._lastStyleString = newStyleString;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Export factory function to maintain API compatibility
|
|
213
|
+
export default ({ render, html }) => {
|
|
214
|
+
// Note: render and html parameters are accepted but not used
|
|
215
|
+
// This maintains backward compatibility with existing code
|
|
216
|
+
return RettangoliViewElement;
|
|
217
|
+
};
|
package/src/setup.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createWebPatch } from 'rettangoli-fe';
|
|
2
|
+
import { h } from 'snabbdom/build/h';
|
|
3
|
+
|
|
4
|
+
const componentDependencies = {}
|
|
5
|
+
|
|
6
|
+
const deps = {
|
|
7
|
+
components: componentDependencies,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const patch = createWebPatch();
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
h,
|
|
14
|
+
patch,
|
|
15
|
+
deps,
|
|
16
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { generateCSS, spacing } from "../common.js";
|
|
2
|
+
|
|
3
|
+
const styles = {
|
|
4
|
+
mt: spacing,
|
|
5
|
+
mr: spacing,
|
|
6
|
+
mb: spacing,
|
|
7
|
+
ml: spacing,
|
|
8
|
+
m: spacing,
|
|
9
|
+
mh: spacing,
|
|
10
|
+
mv: spacing,
|
|
11
|
+
s: {
|
|
12
|
+
sm: `
|
|
13
|
+
height: 28px;
|
|
14
|
+
padding-left: 12px;
|
|
15
|
+
padding-right: 12px;
|
|
16
|
+
border-radius: 4px;
|
|
17
|
+
font-size: var(--xs-font-size);
|
|
18
|
+
font-weight: var(--xs-font-weight);
|
|
19
|
+
line-height: var(--xs-line-height);
|
|
20
|
+
letter-spacing: var(--xs-letter-spacing);
|
|
21
|
+
`,
|
|
22
|
+
md: `
|
|
23
|
+
height: 32px;
|
|
24
|
+
padding-left: 16px;
|
|
25
|
+
padding-right: 16px;
|
|
26
|
+
border-radius: 4px;
|
|
27
|
+
font-size: var(--sm-font-size);
|
|
28
|
+
font-weight: var(--sm-font-weight);
|
|
29
|
+
line-height: var(--sm-line-height);
|
|
30
|
+
letter-spacing: var(--sm-letter-spacing);
|
|
31
|
+
`,
|
|
32
|
+
lg: `
|
|
33
|
+
height: 40px;
|
|
34
|
+
padding-left: 20px;
|
|
35
|
+
padding-right: 20px;
|
|
36
|
+
border-radius: 4px;
|
|
37
|
+
font-size: var(--md-font-size);
|
|
38
|
+
font-weight: var(--md-font-weight);
|
|
39
|
+
line-height: var(--md-line-height);
|
|
40
|
+
letter-spacing: var(--md-letter-spacing);
|
|
41
|
+
`,
|
|
42
|
+
},
|
|
43
|
+
v: {
|
|
44
|
+
pr: `
|
|
45
|
+
background-color: var(--primary);
|
|
46
|
+
color: var(--primary-foreground);
|
|
47
|
+
`,
|
|
48
|
+
se: `
|
|
49
|
+
background-color: var(--secondary);
|
|
50
|
+
color: var(--secondary-foreground);
|
|
51
|
+
`,
|
|
52
|
+
de: `
|
|
53
|
+
background-color: var(--destructive);
|
|
54
|
+
color: var(--primary-foreground);
|
|
55
|
+
`,
|
|
56
|
+
ol: `
|
|
57
|
+
background-color: transparent;
|
|
58
|
+
color: var(--foreground);
|
|
59
|
+
border-width: 1px;
|
|
60
|
+
`,
|
|
61
|
+
gh: `
|
|
62
|
+
background-color: transparent;
|
|
63
|
+
color: var(--foreground);
|
|
64
|
+
`,
|
|
65
|
+
lk: `
|
|
66
|
+
background-color: transparent;
|
|
67
|
+
color: var(--foreground);
|
|
68
|
+
`,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const descendants = {
|
|
73
|
+
mt: "button",
|
|
74
|
+
mr: "button",
|
|
75
|
+
mb: "button",
|
|
76
|
+
ml: "button",
|
|
77
|
+
m: "button",
|
|
78
|
+
mh: "button",
|
|
79
|
+
mv: "button",
|
|
80
|
+
s: "button",
|
|
81
|
+
v: "button",
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export default generateCSS(styles, descendants);
|