rettangoli-ui 0.1.0-rc2 → 0.1.0-rc4

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.
Files changed (54) hide show
  1. package/README.md +16 -27
  2. package/dist/rettangoli-iife-layout.min.js +118 -45
  3. package/dist/rettangoli-iife-ui.min.js +86 -65
  4. package/package.json +11 -4
  5. package/src/common/BaseElement.js +182 -0
  6. package/src/common.js +190 -0
  7. package/src/components/dialog/dialog.handlers.js +5 -0
  8. package/src/components/dialog/dialog.store.js +24 -0
  9. package/src/components/dialog/dialog.view.yaml +41 -0
  10. package/src/components/dropdownMenu/dropdownMenu.handlers.js +5 -0
  11. package/src/components/dropdownMenu/dropdownMenu.store.js +25 -0
  12. package/src/components/dropdownMenu/dropdownMenu.view.yaml +52 -0
  13. package/src/components/form/form.handlers.js +30 -0
  14. package/src/components/form/form.store.js +45 -0
  15. package/src/components/form/form.view.yaml +47 -0
  16. package/src/components/navbar/navbar.examples.yaml +86 -0
  17. package/src/components/navbar/navbar.handlers.js +10 -0
  18. package/src/components/navbar/navbar.store.js +46 -0
  19. package/src/components/navbar/navbar.view.yaml +74 -0
  20. package/src/components/pageOutline/pageOutline.handlers.js +69 -0
  21. package/src/components/pageOutline/pageOutline.store.js +40 -0
  22. package/src/components/pageOutline/pageOutline.view.yaml +34 -0
  23. package/src/components/popover/popover.handlers.js +5 -0
  24. package/src/components/popover/popover.store.js +12 -0
  25. package/src/components/popover/popover.view.yaml +57 -0
  26. package/src/components/select/select.handlers.js +46 -0
  27. package/src/components/select/select.store.js +65 -0
  28. package/src/components/select/select.view.yaml +50 -0
  29. package/src/components/sidebar/sidebar.handlers.js +36 -0
  30. package/src/components/sidebar/sidebar.store.js +139 -0
  31. package/src/components/sidebar/sidebar.view.yaml +190 -0
  32. package/src/entry-iife-layout.js +15 -0
  33. package/src/entry-iife-ui.js +18 -0
  34. package/src/index.js +17 -0
  35. package/src/lib/uhtml.js +9 -0
  36. package/src/primitives/button.js +306 -0
  37. package/src/primitives/image.js +234 -0
  38. package/src/primitives/input.js +208 -0
  39. package/src/primitives/svg.js +95 -0
  40. package/src/primitives/text.js +141 -0
  41. package/src/primitives/textarea.js +103 -0
  42. package/src/primitives/view.js +217 -0
  43. package/src/setup.js +16 -0
  44. package/src/styles/anchorStyles.js +13 -0
  45. package/src/styles/buttonMarginStyles.js +84 -0
  46. package/src/styles/cursorStyles.js +12 -0
  47. package/src/styles/flexChildStyles.js +43 -0
  48. package/src/styles/flexDirectionStyles.js +74 -0
  49. package/src/styles/marginStyles.js +13 -0
  50. package/src/styles/paddingSvgStyles.js +120 -0
  51. package/src/styles/scrollStyles.js +22 -0
  52. package/src/styles/textColorStyles.js +14 -0
  53. package/src/styles/textStyles.js +62 -0
  54. package/src/styles/viewStyles.js +119 -0
@@ -0,0 +1,208 @@
1
+ import {
2
+ css,
3
+ dimensionWithUnit,
4
+ convertObjectToCssString,
5
+ styleMapKeys,
6
+ permutateBreakpoints,
7
+ } from "../common.js";
8
+ import cursorStyles from "../styles/cursorStyles.js";
9
+ import marginStyles from "../styles/marginStyles.js";
10
+
11
+ // Internal implementation without uhtml
12
+ class RettangoliInputElement extends HTMLElement {
13
+ static styleSheet = null;
14
+
15
+ static initializeStyleSheet() {
16
+ if (!RettangoliInputElement.styleSheet) {
17
+ RettangoliInputElement.styleSheet = new CSSStyleSheet();
18
+ RettangoliInputElement.styleSheet.replaceSync(css`
19
+ :host {
20
+ display: contents;
21
+ }
22
+ input {
23
+ background-color: var(--background);
24
+ font-size: var(--sm-font-size);
25
+ font-weight: var(--sm-font-weight);
26
+ line-height: var(--sm-line-height);
27
+ letter-spacing: var(--sm-letter-spacing);
28
+ border: 1px solid var(--ring);
29
+ border-radius: var(--border-radius-lg);
30
+ padding-left: var(--spacing-md);
31
+ padding-right: var(--spacing-md);
32
+ height: 32px;
33
+ color: var(--foreground);
34
+ outline: none;
35
+ }
36
+ input:focus {
37
+ border-color: var(--foreground);
38
+ }
39
+ input:disabled {
40
+ cursor: not-allowed;
41
+ }
42
+ ${marginStyles}
43
+ ${cursorStyles}
44
+ `);
45
+ }
46
+ }
47
+
48
+ constructor() {
49
+ super();
50
+ RettangoliInputElement.initializeStyleSheet();
51
+ this.shadow = this.attachShadow({ mode: "closed" });
52
+ this.shadow.adoptedStyleSheets = [RettangoliInputElement.styleSheet];
53
+
54
+ // Initialize style tracking properties
55
+ this._styles = {
56
+ default: {},
57
+ sm: {},
58
+ md: {},
59
+ lg: {},
60
+ xl: {},
61
+ };
62
+ this._lastStyleString = "";
63
+
64
+ // Create initial DOM structure
65
+ this._inputElement = document.createElement('input');
66
+ this._styleElement = document.createElement('style');
67
+
68
+ this.shadow.appendChild(this._styleElement);
69
+ this.shadow.appendChild(this._inputElement);
70
+
71
+ // Bind event handler
72
+ this._inputElement.addEventListener('keydown', this._onChange);
73
+ }
74
+
75
+ static get observedAttributes() {
76
+ return [
77
+ "key",
78
+ "type",
79
+ "placeholder",
80
+ "disabled",
81
+ ...permutateBreakpoints([
82
+ ...styleMapKeys,
83
+ "wh",
84
+ "w",
85
+ "h",
86
+ "hidden",
87
+ "visible",
88
+ "op",
89
+ "z",
90
+ ])
91
+ ];
92
+ }
93
+
94
+ get value() {
95
+ return this._inputElement.value;
96
+ }
97
+
98
+ _onChange = (event) => {
99
+ this.dispatchEvent(new CustomEvent('input-keydown', {
100
+ detail: {
101
+ value: this._inputElement.value,
102
+ },
103
+ }));
104
+ };
105
+
106
+ attributeChangedCallback(name, oldValue, newValue) {
107
+ // Handle input-specific attributes first
108
+ if (["type", "placeholder", "disabled"].includes(name)) {
109
+ this._updateInputAttributes();
110
+ return;
111
+ }
112
+
113
+ // Reset styles for fresh calculation
114
+ this._styles = {
115
+ default: {},
116
+ sm: {},
117
+ md: {},
118
+ lg: {},
119
+ xl: {},
120
+ };
121
+
122
+ ["default", "sm", "md", "lg", "xl"].forEach((size) => {
123
+ const addSizePrefix = (tag) => {
124
+ return `${size === "default" ? "" : `${size}-`}${tag}`;
125
+ };
126
+
127
+ const wh = this.getAttribute(addSizePrefix("wh"));
128
+ const width = dimensionWithUnit(
129
+ wh === null ? this.getAttribute(addSizePrefix("w")) : wh,
130
+ );
131
+ const height = dimensionWithUnit(
132
+ wh === null ? this.getAttribute(addSizePrefix("h")) : wh,
133
+ );
134
+ const opacity = this.getAttribute(addSizePrefix("op"));
135
+ const zIndex = this.getAttribute(addSizePrefix("z"));
136
+
137
+ if (zIndex !== null) {
138
+ this._styles[size]["z-index"] = zIndex;
139
+ }
140
+
141
+ if (opacity !== null) {
142
+ this._styles[size].opacity = opacity;
143
+ }
144
+
145
+ if (width === "f") {
146
+ this._styles[size].width = "var(--width-stretch)";
147
+ } else if (width !== undefined) {
148
+ this._styles[size].width = width;
149
+ this._styles[size]["min-width"] = width;
150
+ this._styles[size]["max-width"] = width;
151
+ }
152
+
153
+ if (height === "f") {
154
+ this._styles[size].height = "100%";
155
+ } else if (height !== undefined) {
156
+ this._styles[size].height = height;
157
+ this._styles[size]["min-height"] = height;
158
+ this._styles[size]["max-height"] = height;
159
+ }
160
+
161
+ if (this.hasAttribute(addSizePrefix("hidden"))) {
162
+ this._styles[size].display = "none !important";
163
+ }
164
+
165
+ if (this.hasAttribute(addSizePrefix("visible"))) {
166
+ this._styles[size].display = "block !important";
167
+ }
168
+ });
169
+
170
+ // Update styles only if changed - targeting input element
171
+ const newStyleString = convertObjectToCssString(this._styles, 'input');
172
+ if (newStyleString !== this._lastStyleString) {
173
+ this._styleElement.textContent = newStyleString;
174
+ this._lastStyleString = newStyleString;
175
+ }
176
+ }
177
+
178
+ _updateInputAttributes() {
179
+ const type = this.getAttribute("type") || "text";
180
+ const placeholder = this.getAttribute("placeholder");
181
+ const isDisabled = this.hasAttribute('disabled');
182
+
183
+ this._inputElement.setAttribute("type", type);
184
+
185
+ if (placeholder !== null) {
186
+ this._inputElement.setAttribute("placeholder", placeholder);
187
+ } else {
188
+ this._inputElement.removeAttribute("placeholder");
189
+ }
190
+
191
+ if (isDisabled) {
192
+ this._inputElement.setAttribute("disabled", "");
193
+ } else {
194
+ this._inputElement.removeAttribute("disabled");
195
+ }
196
+ }
197
+
198
+ connectedCallback() {
199
+ this._updateInputAttributes();
200
+ }
201
+ }
202
+
203
+ // Export factory function to maintain API compatibility
204
+ export default ({ render, html }) => {
205
+ // Note: render and html parameters are accepted but not used
206
+ // This maintains backward compatibility with existing code
207
+ return RettangoliInputElement;
208
+ };
@@ -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
+ };