@rettangoli/ui 0.1.30 → 0.1.32-rc1

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 (89) hide show
  1. package/README.md +20 -85
  2. package/dist/rettangoli-iife-layout.min.js +113 -173
  3. package/dist/rettangoli-iife-ui.min.js +123 -183
  4. package/package.json +5 -4
  5. package/src/common/dimensions.js +72 -0
  6. package/src/common/link.js +111 -0
  7. package/src/common/responsive.js +8 -0
  8. package/src/common.js +43 -8
  9. package/src/components/accordionItem/accordionItem.handlers.js +1 -1
  10. package/src/components/accordionItem/accordionItem.schema.yaml +14 -0
  11. package/src/components/accordionItem/accordionItem.store.js +8 -8
  12. package/src/components/accordionItem/accordionItem.view.yaml +9 -38
  13. package/src/components/breadcrumb/breadcrumb.handlers.js +24 -3
  14. package/src/components/breadcrumb/breadcrumb.schema.yaml +51 -0
  15. package/src/components/breadcrumb/breadcrumb.store.js +66 -10
  16. package/src/components/breadcrumb/breadcrumb.view.yaml +18 -58
  17. package/src/components/dropdownMenu/dropdownMenu.handlers.js +17 -3
  18. package/src/components/dropdownMenu/dropdownMenu.schema.yaml +64 -0
  19. package/src/components/dropdownMenu/dropdownMenu.store.js +48 -6
  20. package/src/components/dropdownMenu/dropdownMenu.view.yaml +24 -46
  21. package/src/components/form/form.handlers.js +25 -108
  22. package/src/components/form/form.schema.yaml +283 -0
  23. package/src/components/form/form.store.js +19 -14
  24. package/src/components/form/form.view.yaml +28 -319
  25. package/src/components/globalUi/globalUi.handlers.js +2 -2
  26. package/src/components/globalUi/globalUi.schema.yaml +8 -0
  27. package/src/components/globalUi/globalUi.store.js +8 -8
  28. package/src/components/globalUi/globalUi.view.yaml +9 -46
  29. package/src/components/navbar/navbar.handlers.js +1 -1
  30. package/src/components/navbar/navbar.schema.yaml +25 -0
  31. package/src/components/navbar/navbar.store.js +28 -14
  32. package/src/components/navbar/navbar.view.yaml +21 -65
  33. package/src/components/pageOutline/pageOutline.handlers.js +17 -11
  34. package/src/components/pageOutline/pageOutline.schema.yaml +16 -0
  35. package/src/components/pageOutline/pageOutline.store.js +6 -7
  36. package/src/components/pageOutline/pageOutline.view.yaml +1 -29
  37. package/src/components/popoverInput/popoverInput.handlers.js +31 -31
  38. package/src/components/popoverInput/popoverInput.schema.yaml +18 -0
  39. package/src/components/popoverInput/popoverInput.store.js +9 -9
  40. package/src/components/popoverInput/popoverInput.view.yaml +5 -22
  41. package/src/components/select/select.handlers.js +31 -35
  42. package/src/components/select/select.schema.yaml +36 -0
  43. package/src/components/select/select.store.js +34 -35
  44. package/src/components/select/select.view.yaml +13 -56
  45. package/src/components/sidebar/sidebar.handlers.js +5 -5
  46. package/src/components/sidebar/sidebar.schema.yaml +57 -0
  47. package/src/components/sidebar/sidebar.store.js +45 -23
  48. package/src/components/sidebar/sidebar.view.yaml +79 -174
  49. package/src/components/sliderInput/sliderInput.handlers.js +28 -8
  50. package/src/components/sliderInput/sliderInput.schema.yaml +27 -0
  51. package/src/components/sliderInput/sliderInput.store.js +9 -9
  52. package/src/components/sliderInput/sliderInput.view.yaml +8 -33
  53. package/src/components/table/table.handlers.js +3 -3
  54. package/src/components/table/table.schema.yaml +27 -0
  55. package/src/components/table/table.store.js +8 -8
  56. package/src/components/table/table.view.yaml +16 -62
  57. package/src/components/tabs/tabs.schema.yaml +26 -0
  58. package/src/components/tabs/tabs.store.js +12 -9
  59. package/src/components/tabs/tabs.view.yaml +4 -60
  60. package/src/components/tooltip/tooltip.schema.yaml +18 -0
  61. package/src/components/tooltip/tooltip.store.js +7 -7
  62. package/src/components/tooltip/tooltip.view.yaml +4 -22
  63. package/src/components/waveform/waveform.handlers.js +6 -6
  64. package/src/components/waveform/waveform.schema.yaml +25 -0
  65. package/src/components/waveform/waveform.store.js +6 -6
  66. package/src/components/waveform/waveform.view.yaml +6 -34
  67. package/src/deps/createGlobalUI.js +2 -2
  68. package/src/primitives/button.js +200 -114
  69. package/src/primitives/colorPicker.js +56 -50
  70. package/src/primitives/dialog.js +2 -1
  71. package/src/primitives/image.js +73 -103
  72. package/src/primitives/input-number.js +139 -93
  73. package/src/primitives/input.js +87 -64
  74. package/src/primitives/popover.js +36 -28
  75. package/src/primitives/slider.js +6 -4
  76. package/src/primitives/svg.js +9 -10
  77. package/src/primitives/text.js +26 -47
  78. package/src/primitives/textarea.js +25 -9
  79. package/src/primitives/view.js +49 -90
  80. package/src/setup.js +1 -7
  81. package/src/styles/buttonMarginStyles.js +1 -13
  82. package/src/styles/cursorStyles.js +1 -5
  83. package/src/styles/flexDirectionStyles.js +4 -4
  84. package/src/styles/marginStylesForTarget.js +13 -0
  85. package/src/styles/textColorStyles.js +14 -6
  86. package/src/styles/textStyles.js +4 -4
  87. package/src/styles/viewStyles.js +6 -6
  88. package/src/styles/viewStylesForTarget.js +58 -0
  89. package/src/styles/flexChildStyles.js +0 -43
@@ -4,13 +4,17 @@ import {
4
4
  convertObjectToCssString,
5
5
  styleMapKeys,
6
6
  permutateBreakpoints,
7
+ overlayLinkStyles,
8
+ syncLinkOverlay,
9
+ createResponsiveStyleBuckets,
10
+ responsiveStyleSizes,
11
+ applyDimensionToStyleBucket,
7
12
  } from "../common.js";
8
13
  import flexDirectionStyles from "../styles/flexDirectionStyles.js";
9
14
  import cursorStyles from "../styles/cursorStyles.js";
10
15
  import scrollStyle from "../styles/scrollStyles.js";
11
16
  import stylesGenerator from "../styles/viewStyles.js";
12
17
  import marginStyles from "../styles/marginStyles.js";
13
- import flexChildStyles from "../styles/flexChildStyles.js";
14
18
  import anchorStyles from "../styles/anchorStyles.js";
15
19
 
16
20
  // Internal implementation without uhtml
@@ -35,31 +39,14 @@ class RettangoliViewElement extends HTMLElement {
35
39
  border-color: var(--border);
36
40
  }
37
41
 
38
- :host([fw="w"]) {
39
- flex-wrap: wrap;
40
- }
41
42
 
42
- ${flexChildStyles}
43
43
  ${scrollStyle}
44
44
  ${flexDirectionStyles}
45
45
  ${marginStyles}
46
46
  ${cursorStyles}
47
47
  ${stylesGenerator}
48
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
- }
49
+ ${overlayLinkStyles}
63
50
  `);
64
51
  }
65
52
  }
@@ -82,10 +69,11 @@ class RettangoliViewElement extends HTMLElement {
82
69
  static get observedAttributes() {
83
70
  return [
84
71
  "href",
85
- "target",
86
- "op",
72
+ "new-tab",
73
+ "rel",
87
74
  ...permutateBreakpoints([
88
75
  ...styleMapKeys,
76
+ "op",
89
77
  "wh",
90
78
  "w",
91
79
  "h",
@@ -97,51 +85,30 @@ class RettangoliViewElement extends HTMLElement {
97
85
  "d",
98
86
  "ah",
99
87
  "av",
100
- "flex",
101
- "fw",
88
+ "wrap",
89
+ "no-wrap",
102
90
  "overflow"
103
91
  ]),
104
92
  ];
105
93
  }
106
94
 
107
- _styles = {
108
- default: {},
109
- sm: {},
110
- md: {},
111
- lg: {},
112
- xl: {},
113
- };
95
+ _styles = createResponsiveStyleBuckets();
114
96
 
115
97
  _lastStyleString = "";
116
98
 
117
99
  _updateDOM() {
118
100
  const href = this.getAttribute("href");
119
- const target = this.getAttribute("target");
120
-
121
- // Ensure slot is always in the shadow DOM
122
- if (this._slotElement.parentNode !== this.shadow) {
123
- this.shadow.appendChild(this._slotElement);
124
- }
125
-
126
- if (href) {
127
- if (!this._linkElement) {
128
- // Create link overlay only if it doesn't exist
129
- this._linkElement = document.createElement("a");
130
- this.shadow.appendChild(this._linkElement);
131
- }
132
-
133
- // Update link attributes
134
- this._linkElement.href = href;
135
- if (target) {
136
- this._linkElement.target = target;
137
- } else {
138
- this._linkElement.removeAttribute("target");
139
- }
140
- } else if (this._linkElement) {
141
- // Remove link overlay
142
- this.shadow.removeChild(this._linkElement);
143
- this._linkElement = null;
144
- }
101
+ const newTab = this.hasAttribute("new-tab");
102
+ const rel = this.getAttribute("rel");
103
+
104
+ this._linkElement = syncLinkOverlay({
105
+ shadowRoot: this.shadow,
106
+ slotElement: this._slotElement,
107
+ linkElement: this._linkElement,
108
+ href,
109
+ newTab,
110
+ rel,
111
+ });
145
112
  }
146
113
 
147
114
  connectedCallback() {
@@ -151,15 +118,9 @@ class RettangoliViewElement extends HTMLElement {
151
118
 
152
119
  updateStyles() {
153
120
  // Reset styles for fresh calculation
154
- this._styles = {
155
- default: {},
156
- sm: {},
157
- md: {},
158
- lg: {},
159
- xl: {},
160
- };
161
-
162
- ["default", "sm", "md", "lg", "xl"].forEach((size) => {
121
+ this._styles = createResponsiveStyleBuckets();
122
+
123
+ responsiveStyleSizes.forEach((size) => {
163
124
  const addSizePrefix = (tag) => {
164
125
  return `${size === "default" ? "" : `${size}-`}${tag}`;
165
126
  };
@@ -183,21 +144,21 @@ class RettangoliViewElement extends HTMLElement {
183
144
  this._styles[size].opacity = opacity;
184
145
  }
185
146
 
186
- if (width === "f") {
187
- this._styles[size].width = "var(--width-stretch)";
188
- } else if (width !== undefined) {
189
- this._styles[size].width = width;
190
- this._styles[size]["min-width"] = width;
191
- this._styles[size]["max-width"] = width;
192
- }
193
-
194
- if (height === "f") {
195
- this._styles[size].height = "100%";
196
- } else if (height !== undefined) {
197
- this._styles[size].height = height;
198
- this._styles[size]["min-height"] = height;
199
- this._styles[size]["max-height"] = height;
200
- }
147
+ applyDimensionToStyleBucket({
148
+ styleBucket: this._styles[size],
149
+ axis: "width",
150
+ dimension: width,
151
+ fillValue: "var(--width-stretch)",
152
+ allowFlexGrow: true,
153
+ });
154
+
155
+ applyDimensionToStyleBucket({
156
+ styleBucket: this._styles[size],
157
+ axis: "height",
158
+ dimension: height,
159
+ fillValue: "100%",
160
+ allowFlexGrow: true,
161
+ });
201
162
 
202
163
  if (this.hasAttribute(addSizePrefix("hide"))) {
203
164
  this._styles[size].display = "none";
@@ -272,17 +233,15 @@ class RettangoliViewElement extends HTMLElement {
272
233
  }
273
234
  }
274
235
 
275
- // Handle flex property
276
- const flex = this.getAttribute(addSizePrefix("flex"));
277
- if (flex !== null) {
278
- this._styles[size]["flex"] = flex;
279
- }
280
-
281
236
  // Handle flex-wrap
282
- const flexWrap = this.getAttribute(addSizePrefix("fw"));
283
- if (flexWrap === "w") {
237
+ const isWrap = this.hasAttribute(addSizePrefix("wrap"));
238
+ const isNoWrap = this.hasAttribute(addSizePrefix("no-wrap"));
239
+ if (isWrap) {
284
240
  this._styles[size]["flex-wrap"] = "wrap";
285
241
  }
242
+ if (isNoWrap) {
243
+ this._styles[size]["flex-wrap"] = "nowrap";
244
+ }
286
245
 
287
246
  // Handle scroll properties
288
247
  const scrollHorizontal = this.hasAttribute(addSizePrefix("sh"));
@@ -316,8 +275,8 @@ class RettangoliViewElement extends HTMLElement {
316
275
  }
317
276
 
318
277
  attributeChangedCallback(name, oldValue, newValue) {
319
- // Handle href and target changes
320
- if (name === "href" || name === "target") {
278
+ // Handle link-related changes
279
+ if (name === "href" || name === "new-tab" || name === "rel") {
321
280
  this._updateDOM();
322
281
  return;
323
282
  }
package/src/setup.js CHANGED
@@ -1,6 +1,4 @@
1
- import { createWebPatch } from '@rettangoli/fe';
2
1
  import createGlobalUI from './deps/createGlobalUI';
3
- import { h } from 'snabbdom/build/h';
4
2
 
5
3
  const globalUI = createGlobalUI();
6
4
 
@@ -12,10 +10,6 @@ const deps = {
12
10
  components: componentDependencies,
13
11
  }
14
12
 
15
- const patch = createWebPatch();
16
-
17
13
  export {
18
- h,
19
- patch,
20
14
  deps,
21
- }
15
+ }
@@ -72,16 +72,4 @@ const styles = {
72
72
  },
73
73
  };
74
74
 
75
- const descendants = {
76
- mt: "button",
77
- mr: "button",
78
- mb: "button",
79
- ml: "button",
80
- m: "button",
81
- mh: "button",
82
- mv: "button",
83
- s: "button",
84
- v: "button",
85
- };
86
-
87
- export default generateCSS(styles, descendants);
75
+ export default generateCSS(styles, {}, ".surface");
@@ -38,11 +38,7 @@ const styles = {
38
38
  "wait": "wait",
39
39
  "zoom-in": "zoom-in",
40
40
  "zoom-out": "zoom-out",
41
-
42
- // Keep short aliases for common cursors
43
- "p": "pointer",
44
- "m": "move",
45
41
  },
46
42
  };
47
43
 
48
- export default generateCSS(styles);
44
+ export default generateCSS(styles);
@@ -57,17 +57,17 @@ export default css`
57
57
  }
58
58
 
59
59
  @media screen and (max-width: 640px) {
60
- :host([s-d="v"]) {
60
+ :host([sm-d="v"]) {
61
61
  flex-direction: column;
62
62
  }
63
- :host([s-d="h"]) {
63
+ :host([sm-d="h"]) {
64
64
  flex-direction: row;
65
65
  }
66
- :host([s-d="h"][s-av="c"]) {
66
+ :host([sm-d="h"][sm-av="c"]) {
67
67
  align-items: center;
68
68
  align-content: center;
69
69
  }
70
- :host([s-d="v"][s-av="c"]) {
70
+ :host([sm-d="v"][sm-av="c"]) {
71
71
  justify-content: center;
72
72
  }
73
73
  }
@@ -0,0 +1,13 @@
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
+ };
12
+
13
+ export default (targetSelector) => generateCSS(styles, {}, targetSelector);
@@ -2,12 +2,20 @@ import { generateCSS } from "../common.js";
2
2
 
3
3
  const styles = {
4
4
  c: {
5
- "fg": "--foreground",
6
- "de": "--destructive",
7
- "pr-fg": "--primary-foreground",
8
- "se-fg": "--secondary-foreground",
9
- "mu-fg": "--muted-foreground",
10
- "ac-fg": "--accent-foreground",
5
+ "pr": "color: var(--primary);",
6
+ "se": "color: var(--secondary);",
7
+ "de": "color: var(--destructive);",
8
+ "fg": "color: var(--foreground);",
9
+ "bg": "color: var(--background);",
10
+ "mu": "color: var(--muted-foreground);",
11
+ "ac": "color: var(--accent);",
12
+ "bo": "color: var(--border);",
13
+ "tr": "color: transparent;",
14
+ "pr-fg": "color: var(--primary-foreground);",
15
+ "se-fg": "color: var(--secondary-foreground);",
16
+ "de-fg": "color: var(--destructive-foreground);",
17
+ "mu-fg": "color: var(--muted-foreground);",
18
+ "ac-fg": "color: var(--accent-foreground);",
11
19
  },
12
20
  };
13
21
 
@@ -2,10 +2,10 @@ import { generateCSS } from "../common.js";
2
2
 
3
3
  const styles = {
4
4
  ta: {
5
- s: 'start',
6
- c: 'center',
7
- e: 'end',
8
- j: 'justify'
5
+ s: "text-align: start;",
6
+ c: "text-align: center;",
7
+ e: "text-align: end;",
8
+ j: "text-align: justify;",
9
9
  },
10
10
  s: {
11
11
  h1: `
@@ -40,31 +40,31 @@ const styles = {
40
40
  abs: "absolute",
41
41
  fix: "fixed",
42
42
  },
43
- cor: {
44
- full: `
43
+ edge: {
44
+ f: `
45
45
  top: 0;
46
46
  right: 0;
47
47
  bottom: 0;
48
48
  left: 0;
49
49
  height: 100%;
50
50
  `,
51
- top: `
51
+ t: `
52
52
  top: 0;
53
53
  right: 0;
54
54
  left: 0;
55
55
  `,
56
- right: `
56
+ r: `
57
57
  top: 0;
58
58
  right: 0;
59
59
  bottom: 0;
60
60
  height: 100%;
61
61
  `,
62
- bottom: `
62
+ b: `
63
63
  right: 0;
64
64
  bottom: 0;
65
65
  left: 0;
66
66
  `,
67
- left: `
67
+ l: `
68
68
  bottom: 0;
69
69
  left: 0;
70
70
  top: 0;
@@ -0,0 +1,58 @@
1
+ import { generateCSS, spacing } from "../common.js";
2
+
3
+ const borderWidth = {
4
+ xs: "--border-width-xs",
5
+ sm: "--border-width-sm",
6
+ md: "--border-width-md",
7
+ lg: "--border-width-lg",
8
+ xl: "--border-width-xl",
9
+ };
10
+
11
+ const styles = {
12
+ bgc: {
13
+ pr: `background-color: var(--primary);`,
14
+ se: `background-color: var(--secondary);`,
15
+ de: `background-color: var(--destructive);`,
16
+ fg: `background-color: var(--foreground);`,
17
+ bg: `background-color: var(--background);`,
18
+ mu: `background-color: var(--muted);`,
19
+ ac: `background-color: var(--accent);`,
20
+ bo: `background-color: var(--border);`,
21
+ },
22
+ pos: {
23
+ rel: "relative",
24
+ abs: "absolute",
25
+ fix: "fixed",
26
+ },
27
+ shadow: {
28
+ sm: "--shadow-sm",
29
+ md: "--shadow-md",
30
+ lg: "--shadow-lg",
31
+ },
32
+ bw: borderWidth,
33
+ bwt: borderWidth,
34
+ bwr: borderWidth,
35
+ bwb: borderWidth,
36
+ bwl: borderWidth,
37
+ bc: {
38
+ pr: "--primary",
39
+ se: "--secondary",
40
+ de: "--destructive",
41
+ fg: "--foreground",
42
+ bg: "--background",
43
+ mu: "--muted",
44
+ ac: "--accent",
45
+ bo: "--border",
46
+ tr: "transparent",
47
+ },
48
+ br: {
49
+ xs: "--border-radius-xs",
50
+ sm: "--border-radius-sm",
51
+ md: "--border-radius-md",
52
+ lg: "--border-radius-lg",
53
+ xl: "--border-radius-xl",
54
+ f: "--border-radius-f",
55
+ },
56
+ };
57
+
58
+ export default (targetSelector) => generateCSS(styles, {}, targetSelector);
@@ -1,43 +0,0 @@
1
- import { css } from '../common.js'
2
-
3
- export default css`
4
- :host([flex="0"]) {
5
- flex: 0;
6
- }
7
- :host([flex="1"]) {
8
- flex: 1;
9
- }
10
- :host([flex="2"]) {
11
- flex: 2;
12
- }
13
- :host([flex="3"]) {
14
- flex: 3;
15
- }
16
- :host([flex="4"]) {
17
- flex: 4;
18
- }
19
- :host([flex="5"]) {
20
- flex: 5;
21
- }
22
- :host([flex="6"]) {
23
- flex: 6;
24
- }
25
- :host([flex="7"]) {
26
- flex: 7;
27
- }
28
- :host([flex="8"]) {
29
- flex: 8;
30
- }
31
- :host([flex="9"]) {
32
- flex: 9;
33
- }
34
- :host([flex="10"]) {
35
- flex: 10;
36
- }
37
- :host([flex="11"]) {
38
- flex: 11;
39
- }
40
- :host([flex="12"]) {
41
- flex: 12;
42
- }
43
- `