@rettangoli/ui 1.0.0-rc8 → 1.0.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/dist/rettangoli-iife-layout.min.js +74 -42
- package/dist/rettangoli-iife-ui.min.js +161 -60
- package/dist/themes/base.css +4 -4
- package/dist/themes/theme-catppuccin.css +1 -1
- package/dist/themes/theme-rtgl-mono.css +1 -1
- package/dist/themes/theme-rtgl-slate.css +1 -1
- package/package.json +11 -7
- package/src/common/dimensions.js +85 -0
- package/src/common/responsive.js +72 -0
- package/src/common.js +6 -4
- package/src/components/dropdownMenu/dropdownMenu.schema.yaml +1 -1
- package/src/components/form/form.handlers.js +328 -152
- package/src/components/form/form.methods.js +205 -0
- package/src/components/form/form.schema.yaml +16 -271
- package/src/components/form/form.store.js +542 -97
- package/src/components/form/form.view.yaml +73 -52
- package/src/components/globalUi/globalUi.handlers.js +4 -4
- package/src/components/popoverInput/popoverInput.handlers.js +64 -50
- package/src/components/popoverInput/popoverInput.schema.yaml +3 -1
- package/src/components/popoverInput/popoverInput.store.js +9 -3
- package/src/components/popoverInput/popoverInput.view.yaml +4 -4
- package/src/components/select/select.handlers.js +15 -19
- package/src/components/select/select.schema.yaml +2 -0
- package/src/components/select/select.store.js +8 -6
- package/src/components/select/select.view.yaml +4 -4
- package/src/components/sliderInput/sliderInput.handlers.js +15 -1
- package/src/components/sliderInput/sliderInput.schema.yaml +3 -0
- package/src/components/sliderInput/sliderInput.store.js +2 -1
- package/src/components/sliderInput/sliderInput.view.yaml +2 -2
- package/src/components/tooltip/tooltip.schema.yaml +1 -1
- package/src/deps/createGlobalUI.js +4 -4
- package/src/entry-iife-layout.js +6 -0
- package/src/entry-iife-ui.js +8 -0
- package/src/index.js +8 -0
- package/src/primitives/checkbox.js +295 -0
- package/src/primitives/input-date.js +31 -0
- package/src/primitives/input-datetime.js +31 -0
- package/src/primitives/input-time.js +31 -0
- package/src/primitives/input.js +43 -1
- package/src/primitives/textarea.js +3 -0
- package/src/primitives/view.js +8 -2
- package/src/themes/base.css +4 -4
- package/src/themes/theme-catppuccin.css +1 -1
- package/src/themes/theme-rtgl-mono.css +1 -1
- package/src/themes/theme-rtgl-slate.css +1 -1
|
@@ -66,7 +66,7 @@ const createGlobalUI = (globalUIElement) => {
|
|
|
66
66
|
{
|
|
67
67
|
throw new Error("globalUIElement is not set. Make sure to initialize the global UI component and pass it to createGlobalUIManager.");
|
|
68
68
|
}
|
|
69
|
-
globalUIElement.transformedHandlers.
|
|
69
|
+
globalUIElement.transformedHandlers.handleShowAlert(options);
|
|
70
70
|
},
|
|
71
71
|
|
|
72
72
|
/**
|
|
@@ -87,7 +87,7 @@ const createGlobalUI = (globalUIElement) => {
|
|
|
87
87
|
{
|
|
88
88
|
throw new Error("globalUIElement is not set. Make sure to initialize the global UI component and pass it to createGlobalUIManager.");
|
|
89
89
|
}
|
|
90
|
-
return globalUIElement.transformedHandlers.
|
|
90
|
+
return globalUIElement.transformedHandlers.handleShowConfirm(options);
|
|
91
91
|
},
|
|
92
92
|
|
|
93
93
|
/**
|
|
@@ -109,7 +109,7 @@ const createGlobalUI = (globalUIElement) => {
|
|
|
109
109
|
{
|
|
110
110
|
throw new Error("globalUIElement is not set. Make sure to initialize the global UI component and pass it to createGlobalUIManager.");
|
|
111
111
|
}
|
|
112
|
-
return globalUIElement.transformedHandlers.
|
|
112
|
+
return globalUIElement.transformedHandlers.handleShowDropdownMenu(options);
|
|
113
113
|
},
|
|
114
114
|
|
|
115
115
|
/**
|
|
@@ -125,7 +125,7 @@ const createGlobalUI = (globalUIElement) => {
|
|
|
125
125
|
{
|
|
126
126
|
throw new Error("globalUIElement is not set. Make sure to initialize the global UI component and pass it to createGlobalUIManager.");
|
|
127
127
|
}
|
|
128
|
-
return globalUIElement.transformedHandlers.
|
|
128
|
+
return globalUIElement.transformedHandlers.handleCloseAll();
|
|
129
129
|
}
|
|
130
130
|
};
|
|
131
131
|
}
|
package/src/entry-iife-layout.js
CHANGED
|
@@ -4,6 +4,9 @@ import RettangoliText from './primitives/text.js';
|
|
|
4
4
|
import RettangoliImage from './primitives/image.js';
|
|
5
5
|
import RettangoliSvg from './primitives/svg.js';
|
|
6
6
|
import RettangoliInput from './primitives/input.js';
|
|
7
|
+
import RettangoliInputDate from './primitives/input-date.js';
|
|
8
|
+
import RettangoliInputTime from './primitives/input-time.js';
|
|
9
|
+
import RettangoliInputDateTime from './primitives/input-datetime.js';
|
|
7
10
|
import RettangoliInputNumber from './primitives/input-number.js';
|
|
8
11
|
import RettangoliTextArea from './primitives/textarea.js';
|
|
9
12
|
import RettangoliColorPicker from './primitives/colorPicker.js';
|
|
@@ -18,6 +21,9 @@ customElements.define("rtgl-text", RettangoliText({}));
|
|
|
18
21
|
customElements.define("rtgl-image", RettangoliImage({}));
|
|
19
22
|
customElements.define("rtgl-svg", RettangoliSvg({}));
|
|
20
23
|
customElements.define("rtgl-input", RettangoliInput({}));
|
|
24
|
+
customElements.define("rtgl-input-date", RettangoliInputDate({}));
|
|
25
|
+
customElements.define("rtgl-input-time", RettangoliInputTime({}));
|
|
26
|
+
customElements.define("rtgl-input-datetime", RettangoliInputDateTime({}));
|
|
21
27
|
customElements.define("rtgl-input-number", RettangoliInputNumber({}));
|
|
22
28
|
customElements.define("rtgl-textarea", RettangoliTextArea({}));
|
|
23
29
|
customElements.define("rtgl-color-picker", RettangoliColorPicker({}));
|
package/src/entry-iife-ui.js
CHANGED
|
@@ -4,10 +4,14 @@ import RettangoliText from './primitives/text.js';
|
|
|
4
4
|
import RettangoliImage from './primitives/image.js';
|
|
5
5
|
import RettangoliSvg from './primitives/svg.js';
|
|
6
6
|
import RettangoliInput from './primitives/input.js';
|
|
7
|
+
import RettangoliInputDate from './primitives/input-date.js';
|
|
8
|
+
import RettangoliInputTime from './primitives/input-time.js';
|
|
9
|
+
import RettangoliInputDateTime from './primitives/input-datetime.js';
|
|
7
10
|
import RettangoliInputNumber from './primitives/input-number.js';
|
|
8
11
|
import RettangoliTextArea from './primitives/textarea.js';
|
|
9
12
|
import RettangoliColorPicker from './primitives/colorPicker.js';
|
|
10
13
|
import RettangoliSlider from './primitives/slider.js';
|
|
14
|
+
import RettangoliCheckbox from './primitives/checkbox.js';
|
|
11
15
|
import RettangoliDialog from './primitives/dialog.js';
|
|
12
16
|
import RettangoliPopover from './primitives/popover.js';
|
|
13
17
|
|
|
@@ -17,10 +21,14 @@ customElements.define("rtgl-text", RettangoliText({}));
|
|
|
17
21
|
customElements.define("rtgl-image", RettangoliImage({}));
|
|
18
22
|
customElements.define("rtgl-svg", RettangoliSvg({}));
|
|
19
23
|
customElements.define("rtgl-input", RettangoliInput({}));
|
|
24
|
+
customElements.define("rtgl-input-date", RettangoliInputDate({}));
|
|
25
|
+
customElements.define("rtgl-input-time", RettangoliInputTime({}));
|
|
26
|
+
customElements.define("rtgl-input-datetime", RettangoliInputDateTime({}));
|
|
20
27
|
customElements.define("rtgl-input-number", RettangoliInputNumber({}));
|
|
21
28
|
customElements.define("rtgl-textarea", RettangoliTextArea({}));
|
|
22
29
|
customElements.define("rtgl-color-picker", RettangoliColorPicker({}));
|
|
23
30
|
customElements.define("rtgl-slider", RettangoliSlider({}));
|
|
31
|
+
customElements.define("rtgl-checkbox", RettangoliCheckbox({}));
|
|
24
32
|
customElements.define("rtgl-dialog", RettangoliDialog({}));
|
|
25
33
|
customElements.define("rtgl-popover", RettangoliPopover({}));
|
|
26
34
|
|
package/src/index.js
CHANGED
|
@@ -4,12 +4,16 @@ import RettangoliText from './primitives/text.js';
|
|
|
4
4
|
import RettangoliImage from './primitives/image.js';
|
|
5
5
|
import RettangoliSvg from './primitives/svg.js';
|
|
6
6
|
import RettangoliInput from './primitives/input.js';
|
|
7
|
+
import RettangoliInputDate from './primitives/input-date.js';
|
|
8
|
+
import RettangoliInputTime from './primitives/input-time.js';
|
|
9
|
+
import RettangoliInputDateTime from './primitives/input-datetime.js';
|
|
7
10
|
import RettangoliInputNumber from './primitives/input-number.js';
|
|
8
11
|
import RettangoliTextArea from './primitives/textarea.js';
|
|
9
12
|
import RettangoliDialog from './primitives/dialog.js';
|
|
10
13
|
import RettangoliPopover from './primitives/popover.js';
|
|
11
14
|
import RettangoliColorPicker from './primitives/colorPicker.js';
|
|
12
15
|
import RettangoliSlider from './primitives/slider.js';
|
|
16
|
+
import RettangoliCheckbox from './primitives/checkbox.js';
|
|
13
17
|
import createGlobalUI from './deps/createGlobalUI.js';
|
|
14
18
|
|
|
15
19
|
export {
|
|
@@ -19,11 +23,15 @@ export {
|
|
|
19
23
|
RettangoliImage,
|
|
20
24
|
RettangoliSvg,
|
|
21
25
|
RettangoliInput,
|
|
26
|
+
RettangoliInputDate,
|
|
27
|
+
RettangoliInputTime,
|
|
28
|
+
RettangoliInputDateTime,
|
|
22
29
|
RettangoliInputNumber,
|
|
23
30
|
RettangoliTextArea,
|
|
24
31
|
RettangoliDialog,
|
|
25
32
|
RettangoliPopover,
|
|
26
33
|
RettangoliColorPicker,
|
|
27
34
|
RettangoliSlider,
|
|
35
|
+
RettangoliCheckbox,
|
|
28
36
|
createGlobalUI,
|
|
29
37
|
}
|
|
@@ -0,0 +1,295 @@
|
|
|
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
|
+
class RettangoliCheckboxElement extends HTMLElement {
|
|
12
|
+
static styleSheet = null;
|
|
13
|
+
|
|
14
|
+
static initializeStyleSheet() {
|
|
15
|
+
if (!RettangoliCheckboxElement.styleSheet) {
|
|
16
|
+
RettangoliCheckboxElement.styleSheet = new CSSStyleSheet();
|
|
17
|
+
RettangoliCheckboxElement.styleSheet.replaceSync(css`
|
|
18
|
+
:host {
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
}
|
|
21
|
+
.checkbox-wrapper {
|
|
22
|
+
display: inline-flex;
|
|
23
|
+
align-items: flex-start;
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
color: var(--foreground);
|
|
26
|
+
}
|
|
27
|
+
:host([has-label]) .checkbox-wrapper {
|
|
28
|
+
gap: var(--spacing-sm);
|
|
29
|
+
}
|
|
30
|
+
:host([disabled]) .checkbox-wrapper {
|
|
31
|
+
cursor: not-allowed;
|
|
32
|
+
}
|
|
33
|
+
.checkbox-label {
|
|
34
|
+
display: none;
|
|
35
|
+
font-size: var(--sm-font-size);
|
|
36
|
+
font-weight: var(--sm-font-weight);
|
|
37
|
+
line-height: var(--sm-line-height);
|
|
38
|
+
letter-spacing: var(--sm-letter-spacing);
|
|
39
|
+
user-select: none;
|
|
40
|
+
}
|
|
41
|
+
:host([has-label]) .checkbox-label {
|
|
42
|
+
display: block;
|
|
43
|
+
}
|
|
44
|
+
input[type="checkbox"] {
|
|
45
|
+
-webkit-appearance: none;
|
|
46
|
+
appearance: none;
|
|
47
|
+
width: 18px;
|
|
48
|
+
height: 18px;
|
|
49
|
+
border: 2px solid var(--muted-foreground);
|
|
50
|
+
border-radius: var(--border-radius-sm);
|
|
51
|
+
background: var(--muted);
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
transition: all 0.2s ease;
|
|
54
|
+
position: relative;
|
|
55
|
+
margin: 0;
|
|
56
|
+
flex-shrink: 0;
|
|
57
|
+
}
|
|
58
|
+
input[type="checkbox"]:checked {
|
|
59
|
+
background: var(--muted);
|
|
60
|
+
border-color: var(--foreground);
|
|
61
|
+
}
|
|
62
|
+
input[type="checkbox"]:checked::after {
|
|
63
|
+
content: "";
|
|
64
|
+
position: absolute;
|
|
65
|
+
left: 4px;
|
|
66
|
+
top: 1px;
|
|
67
|
+
width: 6px;
|
|
68
|
+
height: 10px;
|
|
69
|
+
border: solid var(--foreground);
|
|
70
|
+
border-width: 0 2px 2px 0;
|
|
71
|
+
transform: rotate(45deg);
|
|
72
|
+
}
|
|
73
|
+
input[type="checkbox"]:hover {
|
|
74
|
+
border-color: var(--foreground);
|
|
75
|
+
}
|
|
76
|
+
input[type="checkbox"]:focus {
|
|
77
|
+
outline: 2px solid var(--ring);
|
|
78
|
+
outline-offset: 2px;
|
|
79
|
+
}
|
|
80
|
+
input[type="checkbox"]:disabled {
|
|
81
|
+
cursor: not-allowed;
|
|
82
|
+
opacity: 0.5;
|
|
83
|
+
}
|
|
84
|
+
${marginStyles}
|
|
85
|
+
${cursorStyles}
|
|
86
|
+
`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
constructor() {
|
|
91
|
+
super();
|
|
92
|
+
RettangoliCheckboxElement.initializeStyleSheet();
|
|
93
|
+
this.shadow = this.attachShadow({ mode: "open" });
|
|
94
|
+
this.shadow.adoptedStyleSheets = [RettangoliCheckboxElement.styleSheet];
|
|
95
|
+
|
|
96
|
+
this._styles = {
|
|
97
|
+
default: {},
|
|
98
|
+
sm: {},
|
|
99
|
+
md: {},
|
|
100
|
+
lg: {},
|
|
101
|
+
xl: {},
|
|
102
|
+
};
|
|
103
|
+
this._lastStyleString = "";
|
|
104
|
+
|
|
105
|
+
this._inputElement = document.createElement('input');
|
|
106
|
+
this._inputElement.type = 'checkbox';
|
|
107
|
+
this._wrapperElement = document.createElement('label');
|
|
108
|
+
this._wrapperElement.className = 'checkbox-wrapper';
|
|
109
|
+
this._labelElement = document.createElement('span');
|
|
110
|
+
this._labelElement.className = 'checkbox-label';
|
|
111
|
+
this._labelSlotElement = document.createElement('slot');
|
|
112
|
+
this._labelSlotElement.addEventListener('slotchange', () => {
|
|
113
|
+
this._updateLabelState();
|
|
114
|
+
});
|
|
115
|
+
this._labelElement.appendChild(this._labelSlotElement);
|
|
116
|
+
this._styleElement = document.createElement('style');
|
|
117
|
+
|
|
118
|
+
this.shadow.appendChild(this._styleElement);
|
|
119
|
+
this._wrapperElement.appendChild(this._inputElement);
|
|
120
|
+
this._wrapperElement.appendChild(this._labelElement);
|
|
121
|
+
this.shadow.appendChild(this._wrapperElement);
|
|
122
|
+
|
|
123
|
+
this._inputElement.addEventListener('change', this._onChange);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
static get observedAttributes() {
|
|
127
|
+
return [
|
|
128
|
+
"key",
|
|
129
|
+
"checked",
|
|
130
|
+
"disabled",
|
|
131
|
+
"label",
|
|
132
|
+
...permutateBreakpoints([
|
|
133
|
+
...styleMapKeys,
|
|
134
|
+
"wh",
|
|
135
|
+
"w",
|
|
136
|
+
"h",
|
|
137
|
+
"hide",
|
|
138
|
+
"show",
|
|
139
|
+
"op",
|
|
140
|
+
"z",
|
|
141
|
+
])
|
|
142
|
+
];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
get checked() {
|
|
146
|
+
return this._inputElement.checked;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
set checked(val) {
|
|
150
|
+
this._inputElement.checked = Boolean(val);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
get value() {
|
|
154
|
+
return this._inputElement.checked;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
set value(val) {
|
|
158
|
+
this._inputElement.checked = Boolean(val);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
_onChange = () => {
|
|
162
|
+
this.dispatchEvent(new CustomEvent('value-change', {
|
|
163
|
+
detail: {
|
|
164
|
+
value: this._inputElement.checked,
|
|
165
|
+
},
|
|
166
|
+
bubbles: true,
|
|
167
|
+
}));
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
171
|
+
if (name === "key" && oldValue !== newValue) {
|
|
172
|
+
requestAnimationFrame(() => {
|
|
173
|
+
const checked = this.hasAttribute("checked");
|
|
174
|
+
this._inputElement.checked = checked;
|
|
175
|
+
});
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (name === "checked") {
|
|
180
|
+
this._inputElement.checked = newValue !== null;
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (name === "disabled") {
|
|
185
|
+
if (newValue !== null) {
|
|
186
|
+
this._inputElement.setAttribute("disabled", "");
|
|
187
|
+
} else {
|
|
188
|
+
this._inputElement.removeAttribute("disabled");
|
|
189
|
+
}
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (name === "label") {
|
|
194
|
+
this._updateLabelState();
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
this._styles = {
|
|
199
|
+
default: {},
|
|
200
|
+
sm: {},
|
|
201
|
+
md: {},
|
|
202
|
+
lg: {},
|
|
203
|
+
xl: {},
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
["default", "sm", "md", "lg", "xl"].forEach((size) => {
|
|
207
|
+
const addSizePrefix = (tag) => {
|
|
208
|
+
return `${size === "default" ? "" : `${size}-`}${tag}`;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const wh = this.getAttribute(addSizePrefix("wh"));
|
|
212
|
+
const width = dimensionWithUnit(
|
|
213
|
+
wh === null ? this.getAttribute(addSizePrefix("w")) : wh,
|
|
214
|
+
);
|
|
215
|
+
const height = dimensionWithUnit(
|
|
216
|
+
wh === null ? this.getAttribute(addSizePrefix("h")) : wh,
|
|
217
|
+
);
|
|
218
|
+
const opacity = this.getAttribute(addSizePrefix("op"));
|
|
219
|
+
const zIndex = this.getAttribute(addSizePrefix("z"));
|
|
220
|
+
|
|
221
|
+
if (zIndex !== null) {
|
|
222
|
+
this._styles[size]["z-index"] = zIndex;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (opacity !== null) {
|
|
226
|
+
this._styles[size].opacity = opacity;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (width === "f") {
|
|
230
|
+
this._styles[size].width = "var(--width-stretch)";
|
|
231
|
+
} else if (width !== undefined) {
|
|
232
|
+
this._styles[size].width = width;
|
|
233
|
+
this._styles[size]["min-width"] = width;
|
|
234
|
+
this._styles[size]["max-width"] = width;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (height === "f") {
|
|
238
|
+
this._styles[size].height = "100%";
|
|
239
|
+
} else if (height !== undefined) {
|
|
240
|
+
this._styles[size].height = height;
|
|
241
|
+
this._styles[size]["min-height"] = height;
|
|
242
|
+
this._styles[size]["max-height"] = height;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (this.hasAttribute(addSizePrefix("hide"))) {
|
|
246
|
+
this._styles[size].display = "none";
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (this.hasAttribute(addSizePrefix("show"))) {
|
|
250
|
+
this._styles[size].display = "block";
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
const newStyleString = convertObjectToCssString(this._styles, 'input[type="checkbox"]');
|
|
255
|
+
if (newStyleString !== this._lastStyleString) {
|
|
256
|
+
this._styleElement.textContent = newStyleString;
|
|
257
|
+
this._lastStyleString = newStyleString;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
connectedCallback() {
|
|
262
|
+
const checked = this.hasAttribute("checked");
|
|
263
|
+
this._inputElement.checked = checked;
|
|
264
|
+
|
|
265
|
+
if (this.hasAttribute("disabled")) {
|
|
266
|
+
this._inputElement.setAttribute("disabled", "");
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
this._updateLabelState();
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
_updateLabelState() {
|
|
273
|
+
const fallbackLabel = this.getAttribute("label");
|
|
274
|
+
this._labelSlotElement.textContent = fallbackLabel ?? "";
|
|
275
|
+
|
|
276
|
+
const assignedNodes = this._labelSlotElement.assignedNodes({ flatten: true });
|
|
277
|
+
const hasAssignedLabel = assignedNodes.some((node) => {
|
|
278
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
279
|
+
return node.textContent.trim().length > 0;
|
|
280
|
+
}
|
|
281
|
+
return node.nodeType === Node.ELEMENT_NODE;
|
|
282
|
+
});
|
|
283
|
+
const hasFallbackLabel = typeof fallbackLabel === "string" && fallbackLabel.trim().length > 0;
|
|
284
|
+
|
|
285
|
+
if (hasAssignedLabel || hasFallbackLabel) {
|
|
286
|
+
this.setAttribute("has-label", "");
|
|
287
|
+
} else {
|
|
288
|
+
this.removeAttribute("has-label");
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export default ({ render, html }) => {
|
|
294
|
+
return RettangoliCheckboxElement;
|
|
295
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import RettangoliInput from "./input.js";
|
|
2
|
+
|
|
3
|
+
const BaseInputElement = RettangoliInput({});
|
|
4
|
+
const FORCED_TYPE = "date";
|
|
5
|
+
|
|
6
|
+
class RettangoliInputDateElement extends BaseInputElement {
|
|
7
|
+
connectedCallback() {
|
|
8
|
+
if (this.getAttribute("type") !== FORCED_TYPE) {
|
|
9
|
+
super.setAttribute("type", FORCED_TYPE);
|
|
10
|
+
}
|
|
11
|
+
if (super.connectedCallback) {
|
|
12
|
+
super.connectedCallback();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
17
|
+
if (name === "type" && newValue !== FORCED_TYPE) {
|
|
18
|
+
if (this.getAttribute("type") !== FORCED_TYPE) {
|
|
19
|
+
super.setAttribute("type", FORCED_TYPE);
|
|
20
|
+
}
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (super.attributeChangedCallback) {
|
|
24
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default ({ render, html }) => {
|
|
30
|
+
return RettangoliInputDateElement;
|
|
31
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import RettangoliInput from "./input.js";
|
|
2
|
+
|
|
3
|
+
const BaseInputElement = RettangoliInput({});
|
|
4
|
+
const FORCED_TYPE = "datetime-local";
|
|
5
|
+
|
|
6
|
+
class RettangoliInputDateTimeElement extends BaseInputElement {
|
|
7
|
+
connectedCallback() {
|
|
8
|
+
if (this.getAttribute("type") !== FORCED_TYPE) {
|
|
9
|
+
super.setAttribute("type", FORCED_TYPE);
|
|
10
|
+
}
|
|
11
|
+
if (super.connectedCallback) {
|
|
12
|
+
super.connectedCallback();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
17
|
+
if (name === "type" && newValue !== FORCED_TYPE) {
|
|
18
|
+
if (this.getAttribute("type") !== FORCED_TYPE) {
|
|
19
|
+
super.setAttribute("type", FORCED_TYPE);
|
|
20
|
+
}
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (super.attributeChangedCallback) {
|
|
24
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default ({ render, html }) => {
|
|
30
|
+
return RettangoliInputDateTimeElement;
|
|
31
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import RettangoliInput from "./input.js";
|
|
2
|
+
|
|
3
|
+
const BaseInputElement = RettangoliInput({});
|
|
4
|
+
const FORCED_TYPE = "time";
|
|
5
|
+
|
|
6
|
+
class RettangoliInputTimeElement extends BaseInputElement {
|
|
7
|
+
connectedCallback() {
|
|
8
|
+
if (this.getAttribute("type") !== FORCED_TYPE) {
|
|
9
|
+
super.setAttribute("type", FORCED_TYPE);
|
|
10
|
+
}
|
|
11
|
+
if (super.connectedCallback) {
|
|
12
|
+
super.connectedCallback();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
17
|
+
if (name === "type" && newValue !== FORCED_TYPE) {
|
|
18
|
+
if (this.getAttribute("type") !== FORCED_TYPE) {
|
|
19
|
+
super.setAttribute("type", FORCED_TYPE);
|
|
20
|
+
}
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (super.attributeChangedCallback) {
|
|
24
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default ({ render, html }) => {
|
|
30
|
+
return RettangoliInputTimeElement;
|
|
31
|
+
};
|
package/src/primitives/input.js
CHANGED
|
@@ -19,6 +19,9 @@ class RettangoliInputElement extends HTMLElement {
|
|
|
19
19
|
static inputSpecificAttributes = [
|
|
20
20
|
"type",
|
|
21
21
|
"disabled",
|
|
22
|
+
"min",
|
|
23
|
+
"max",
|
|
24
|
+
"step",
|
|
22
25
|
"s",
|
|
23
26
|
];
|
|
24
27
|
|
|
@@ -58,6 +61,35 @@ class RettangoliInputElement extends HTMLElement {
|
|
|
58
61
|
input:disabled {
|
|
59
62
|
cursor: not-allowed;
|
|
60
63
|
}
|
|
64
|
+
input[type="date"],
|
|
65
|
+
input[type="time"],
|
|
66
|
+
input[type="datetime-local"] {
|
|
67
|
+
color: var(--foreground);
|
|
68
|
+
min-width: 0;
|
|
69
|
+
}
|
|
70
|
+
input[type="date"]::-webkit-calendar-picker-indicator,
|
|
71
|
+
input[type="time"]::-webkit-calendar-picker-indicator,
|
|
72
|
+
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
|
|
73
|
+
cursor: pointer;
|
|
74
|
+
border-radius: var(--border-radius-sm);
|
|
75
|
+
opacity: 1;
|
|
76
|
+
padding: 2px;
|
|
77
|
+
}
|
|
78
|
+
input[type="date"]::-webkit-datetime-edit,
|
|
79
|
+
input[type="time"]::-webkit-datetime-edit,
|
|
80
|
+
input[type="datetime-local"]::-webkit-datetime-edit {
|
|
81
|
+
color: var(--foreground);
|
|
82
|
+
}
|
|
83
|
+
input[type="date"]::-webkit-datetime-edit-fields-wrapper,
|
|
84
|
+
input[type="time"]::-webkit-datetime-edit-fields-wrapper,
|
|
85
|
+
input[type="datetime-local"]::-webkit-datetime-edit-fields-wrapper {
|
|
86
|
+
padding: 0;
|
|
87
|
+
}
|
|
88
|
+
input[type="date"]::-webkit-date-and-time-value,
|
|
89
|
+
input[type="time"]::-webkit-date-and-time-value,
|
|
90
|
+
input[type="datetime-local"]::-webkit-date-and-time-value {
|
|
91
|
+
text-align: left;
|
|
92
|
+
}
|
|
61
93
|
${marginStyles}
|
|
62
94
|
${cursorStyles}
|
|
63
95
|
`);
|
|
@@ -93,6 +125,9 @@ class RettangoliInputElement extends HTMLElement {
|
|
|
93
125
|
"placeholder",
|
|
94
126
|
"disabled",
|
|
95
127
|
"value",
|
|
128
|
+
"min",
|
|
129
|
+
"max",
|
|
130
|
+
"step",
|
|
96
131
|
"s",
|
|
97
132
|
...permutateBreakpoints([
|
|
98
133
|
...inputStyleMapKeys,
|
|
@@ -242,10 +277,17 @@ class RettangoliInputElement extends HTMLElement {
|
|
|
242
277
|
|
|
243
278
|
_updateInputAttributes() {
|
|
244
279
|
const requestedType = this.getAttribute("type");
|
|
245
|
-
const
|
|
280
|
+
const allowedTypes = new Set(["text", "password", "date", "time", "datetime-local"]);
|
|
281
|
+
const type = allowedTypes.has(requestedType) ? requestedType : "text";
|
|
282
|
+
const min = this.getAttribute("min");
|
|
283
|
+
const max = this.getAttribute("max");
|
|
284
|
+
const step = this.getAttribute("step");
|
|
246
285
|
const isDisabled = this.hasAttribute('disabled');
|
|
247
286
|
|
|
248
287
|
this._setOrRemoveInputAttribute("type", type);
|
|
288
|
+
this._setOrRemoveInputAttribute("min", min);
|
|
289
|
+
this._setOrRemoveInputAttribute("max", max);
|
|
290
|
+
this._setOrRemoveInputAttribute("step", step);
|
|
249
291
|
|
|
250
292
|
if (isDisabled) {
|
|
251
293
|
this._inputElement.setAttribute("disabled", "");
|
package/src/primitives/view.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
createResponsiveStyleBuckets,
|
|
10
10
|
responsiveStyleSizes,
|
|
11
11
|
applyDimensionToStyleBucket,
|
|
12
|
+
getResponsiveAttribute,
|
|
12
13
|
} from "../common.js";
|
|
13
14
|
import flexDirectionStyles from "../styles/flexDirectionStyles.js";
|
|
14
15
|
import cursorStyles from "../styles/cursorStyles.js";
|
|
@@ -172,6 +173,11 @@ class RettangoliViewElement extends HTMLElement {
|
|
|
172
173
|
const direction = this.getAttribute(addSizePrefix("d"));
|
|
173
174
|
const alignHorizontal = this.getAttribute(addSizePrefix("ah"));
|
|
174
175
|
const alignVertical = this.getAttribute(addSizePrefix("av"));
|
|
176
|
+
const effectiveDirection = getResponsiveAttribute({
|
|
177
|
+
element: this,
|
|
178
|
+
size,
|
|
179
|
+
attr: "d",
|
|
180
|
+
});
|
|
175
181
|
|
|
176
182
|
|
|
177
183
|
if (direction === "h") {
|
|
@@ -190,8 +196,8 @@ class RettangoliViewElement extends HTMLElement {
|
|
|
190
196
|
}
|
|
191
197
|
|
|
192
198
|
// Handle alignment based on direction
|
|
193
|
-
const isHorizontal =
|
|
194
|
-
const isVerticalOrDefault =
|
|
199
|
+
const isHorizontal = effectiveDirection === "h";
|
|
200
|
+
const isVerticalOrDefault = effectiveDirection === "v" || !effectiveDirection;
|
|
195
201
|
|
|
196
202
|
// For horizontal direction: ah controls justify-content, av controls align-items
|
|
197
203
|
if (isHorizontal) {
|
package/src/themes/base.css
CHANGED
|
@@ -21,7 +21,7 @@ html {
|
|
|
21
21
|
|
|
22
22
|
body {
|
|
23
23
|
margin: 0;
|
|
24
|
-
line-height: 1.
|
|
24
|
+
line-height: 1.2;
|
|
25
25
|
-webkit-font-smoothing: antialiased;
|
|
26
26
|
text-rendering: optimizeLegibility;
|
|
27
27
|
}
|
|
@@ -266,7 +266,7 @@ pre {
|
|
|
266
266
|
white-space: pre;
|
|
267
267
|
font-size: var(--sm-font-size);
|
|
268
268
|
font-weight: var(--sm-font-weight);
|
|
269
|
-
line-height:
|
|
269
|
+
line-height: 1.2;
|
|
270
270
|
letter-spacing: var(--sm-letter-spacing);
|
|
271
271
|
padding: var(--spacing-lg);
|
|
272
272
|
flex: 1;
|
|
@@ -290,7 +290,7 @@ code:not(pre code) {
|
|
|
290
290
|
font-family: "Menlo", "Monaco", "Courier New", monospace;
|
|
291
291
|
font-size: var(--sm-font-size);
|
|
292
292
|
font-weight: var(--sm-font-weight);
|
|
293
|
-
line-height:
|
|
293
|
+
line-height: 1.2;
|
|
294
294
|
letter-spacing: var(--sm-letter-spacing);
|
|
295
295
|
background-color: var(--muted);
|
|
296
296
|
padding: 0.1em 0.35em;
|
|
@@ -300,7 +300,7 @@ code:not(pre code) {
|
|
|
300
300
|
|
|
301
301
|
a {
|
|
302
302
|
color: var(--anchor-color, inherit);
|
|
303
|
-
text-decoration: var(--anchor-text-decoration,
|
|
303
|
+
text-decoration: var(--anchor-text-decoration, underline);
|
|
304
304
|
}
|
|
305
305
|
|
|
306
306
|
a:hover {
|