@rettangoli/ui 0.1.2-rc23 → 0.1.2-rc24
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 +29 -29
- package/dist/rettangoli-iife-ui.min.js +25 -25
- package/package.json +2 -2
- package/src/components/form/form.store.js +4 -2
- package/src/components/form/form.view.yaml +5 -5
- package/src/components/select/select.handlers.js +23 -0
- package/src/components/select/select.store.js +5 -0
- package/src/components/sliderInput/sliderInput.handlers.js +18 -1
- package/src/components/sliderInput/sliderInput.store.js +1 -0
- package/src/components/sliderInput/sliderInput.view.yaml +2 -2
- package/src/primitives/colorPicker.js +9 -0
- package/src/primitives/input.js +9 -0
- package/src/primitives/slider.js +10 -0
- package/src/primitives/textarea.js +25 -1
- package/src/styles/cursorStyles.js +38 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rettangoli/ui",
|
|
3
|
-
"version": "0.1.2-
|
|
3
|
+
"version": "0.1.2-rc24",
|
|
4
4
|
"description": "A UI component library for building web interfaces.",
|
|
5
5
|
"main": "dist/rettangoli-esm.min.js",
|
|
6
6
|
"type": "module",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"homepage": "https://github.com/yuusoft-org/rettangoli#readme",
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@floating-ui/dom": "^1.6.13",
|
|
52
|
-
"@rettangoli/fe": "0.0.7-
|
|
52
|
+
"@rettangoli/fe": "0.0.7-rc12",
|
|
53
53
|
"commander": "^13.1.0",
|
|
54
54
|
"jempl": "0.1.4-rc1",
|
|
55
55
|
"js-yaml": "^4.1.0",
|
|
@@ -14,7 +14,7 @@ export const INITIAL_STATE = Object.freeze({
|
|
|
14
14
|
// Lodash-like utility functions for nested property access
|
|
15
15
|
const get = (obj, path, defaultValue = undefined) => {
|
|
16
16
|
if (!path) {
|
|
17
|
-
|
|
17
|
+
return;
|
|
18
18
|
}
|
|
19
19
|
const keys = path.split(/[\[\].]/).filter((key) => key !== "");
|
|
20
20
|
let current = obj;
|
|
@@ -84,7 +84,8 @@ export const toViewData = ({ state, props, attrs }) => {
|
|
|
84
84
|
const form = selectForm({ state, props });
|
|
85
85
|
const fields = structuredClone(form.fields || []);
|
|
86
86
|
fields.forEach((field) => {
|
|
87
|
-
|
|
87
|
+
// Use formValues from state if available, otherwise fall back to defaultValues from props
|
|
88
|
+
field.defaultValue = get(state.formValues, field.name) ?? get(defaultValues, field.name);
|
|
88
89
|
|
|
89
90
|
if (field.inputType === "image") {
|
|
90
91
|
const src = field.src;
|
|
@@ -103,6 +104,7 @@ export const toViewData = ({ state, props, attrs }) => {
|
|
|
103
104
|
});
|
|
104
105
|
|
|
105
106
|
return {
|
|
107
|
+
key: attrs?.key,
|
|
106
108
|
containerAttrString,
|
|
107
109
|
title: form?.title || "",
|
|
108
110
|
description: form?.description || "",
|
|
@@ -256,17 +256,17 @@ template:
|
|
|
256
256
|
- $if field.inputType == "read-only-text":
|
|
257
257
|
- rtgl-text s=sm: ${field.defaultValue}
|
|
258
258
|
- $if field.inputType == "inputText":
|
|
259
|
-
- rtgl-input#input-${field.name} w=f placeholder=${field.placeholder} value=${field.defaultValue}:
|
|
259
|
+
- rtgl-input#input-${field.name} key=${key} w=f placeholder=${field.placeholder} value=${field.defaultValue}:
|
|
260
260
|
- $if field.inputType == "popover-input":
|
|
261
261
|
- rtgl-popover-input#popover-input-${field.name} label="${field.label}" .defaultValue=fields[${i}].defaultValue:
|
|
262
262
|
- $if field.inputType == "select":
|
|
263
|
-
- rtgl-select#select-${field.name} w=f .options=fields[${i}].options .placeholder=fields[${i}].placeholder .selectedValue=fields[${i}].defaultValue:
|
|
263
|
+
- rtgl-select#select-${field.name} key=${key} w=f .options=fields[${i}].options .placeholder=fields[${i}].placeholder .selectedValue=fields[${i}].defaultValue:
|
|
264
264
|
- $if field.inputType == "colorPicker":
|
|
265
|
-
- rtgl-color-picker#colorpicker-${field.name} value=${field.defaultValue}:
|
|
265
|
+
- rtgl-color-picker#colorpicker-${field.name} key=${key} value=${field.defaultValue}:
|
|
266
266
|
- $if field.inputType == "slider":
|
|
267
|
-
- rtgl-slider#slider-${field.name} w=f min=${field.min} max=${field.max} step=${field.step} value=${field.defaultValue}:
|
|
267
|
+
- rtgl-slider#slider-${field.name} key=${key} w=f min=${field.min} max=${field.max} step=${field.step} value=${field.defaultValue}:
|
|
268
268
|
- $if field.inputType == "slider-input":
|
|
269
|
-
- rtgl-slider-input#slider-input-${field.name} w=f min=${field.min} max=${field.max} step=${field.step} defaultValue=${field.defaultValue}:
|
|
269
|
+
- rtgl-slider-input#slider-input-${field.name} key=${key} w=f min=${field.min} max=${field.max} step=${field.step} defaultValue=${field.defaultValue}:
|
|
270
270
|
- $if field.inputType == "image" && field.imageSrc:
|
|
271
271
|
- rtgl-image#image-${field.name} src=${field.imageSrc} w=${field.width} h=${field.height} cur=p:
|
|
272
272
|
- $if field.inputType == "image" && !field.imageSrc:
|
|
@@ -11,6 +11,29 @@ export const handleBeforeMount = (deps) => {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
export const handleOnUpdate = (changes, deps) => {
|
|
15
|
+
const { oldAttrs, newAttrs, oldProps, newProps } = changes;
|
|
16
|
+
const { store, props, render } = deps;
|
|
17
|
+
|
|
18
|
+
// Check if key changed
|
|
19
|
+
if (oldAttrs?.key !== newAttrs?.key && newAttrs?.key) {
|
|
20
|
+
// Clear current state using store action
|
|
21
|
+
store.resetSelection();
|
|
22
|
+
|
|
23
|
+
// Re-apply the prop value if available
|
|
24
|
+
const selectedValue = newProps?.selectedValue || props?.selectedValue;
|
|
25
|
+
const options = newProps?.options || props?.options;
|
|
26
|
+
|
|
27
|
+
if (selectedValue !== null && selectedValue !== undefined && options) {
|
|
28
|
+
const selectedOption = options.find(opt => opt.value === selectedValue);
|
|
29
|
+
if (selectedOption) {
|
|
30
|
+
store.updateSelectOption(selectedOption);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
render();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
14
37
|
export const handleButtonClick = (e, deps) => {
|
|
15
38
|
const { store, render, getRefIds } = deps;
|
|
16
39
|
store.openOptionsPopover({
|
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
export const handleBeforeMount = (deps) => {
|
|
2
2
|
const { store, attrs } = deps;
|
|
3
3
|
store.setValue(attrs.defaultValue || 0);
|
|
4
|
-
}
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export const handleOnUpdate = (changes, deps) => {
|
|
7
|
+
const { oldAttrs, newAttrs } = changes;
|
|
8
|
+
const { store, render, attrs } = deps;
|
|
9
|
+
|
|
10
|
+
// Reset when key changes
|
|
11
|
+
if (oldAttrs?.key !== newAttrs?.key && newAttrs?.key) {
|
|
12
|
+
const defaultValue = newAttrs?.defaultValue || attrs?.defaultValue || 0;
|
|
13
|
+
store.setValue(defaultValue);
|
|
14
|
+
render();
|
|
15
|
+
} else if (oldAttrs?.defaultValue !== newAttrs?.defaultValue) {
|
|
16
|
+
// Also reset when defaultValue changes
|
|
17
|
+
const defaultValue = newAttrs?.defaultValue || 0;
|
|
18
|
+
store.setValue(defaultValue);
|
|
19
|
+
render();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
5
22
|
|
|
6
23
|
export const handleValueChange = (e, deps) => {
|
|
7
24
|
const { store, render, dispatchEvent } = deps;
|
|
@@ -37,6 +37,6 @@ events:
|
|
|
37
37
|
|
|
38
38
|
template:
|
|
39
39
|
- rtgl-view d=h av=c g=md w=${w}:
|
|
40
|
-
- rtgl-slider#slider w=f type=range min=${min} max=${max} step=${step} value=${value}:
|
|
40
|
+
- rtgl-slider#slider key=${key} w=f type=range min=${min} max=${max} step=${step} value=${value}:
|
|
41
41
|
- rtgl-view w=84:
|
|
42
|
-
- rtgl-input#input w=f type=number min=${min} max=${max} step=${step} value=${value}:
|
|
42
|
+
- rtgl-input#input key=${key} w=f type=number min=${min} max=${max} step=${step} value=${value}:
|
|
@@ -114,6 +114,15 @@ class RettangoliColorPickerElement extends HTMLElement {
|
|
|
114
114
|
};
|
|
115
115
|
|
|
116
116
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
117
|
+
// Handle key attribute change - reset value
|
|
118
|
+
if (name === "key" && oldValue !== newValue) {
|
|
119
|
+
requestAnimationFrame(() => {
|
|
120
|
+
const value = this.getAttribute("value");
|
|
121
|
+
this._inputElement.value = value ?? "#000000";
|
|
122
|
+
});
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
117
126
|
// Handle input-specific attributes first
|
|
118
127
|
if (["value", "disabled"].includes(name)) {
|
|
119
128
|
this._updateInputAttributes();
|
package/src/primitives/input.js
CHANGED
|
@@ -123,6 +123,15 @@ class RettangoliInputElement extends HTMLElement {
|
|
|
123
123
|
};
|
|
124
124
|
|
|
125
125
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
126
|
+
// Handle key attribute change - reset value
|
|
127
|
+
if (name === "key" && oldValue !== newValue) {
|
|
128
|
+
requestAnimationFrame((() => {
|
|
129
|
+
const value = this.getAttribute("value");
|
|
130
|
+
this._inputElement.value = value ?? "";
|
|
131
|
+
}))
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
126
135
|
// Handle input-specific attributes first
|
|
127
136
|
if (["type", "placeholder", "disabled", "value", "step", "s"].includes(name)) {
|
|
128
137
|
this._updateInputAttributes();
|
package/src/primitives/slider.js
CHANGED
|
@@ -148,6 +148,16 @@ class RettangoliSliderElement extends HTMLElement {
|
|
|
148
148
|
};
|
|
149
149
|
|
|
150
150
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
151
|
+
// Handle key attribute change - reset value
|
|
152
|
+
if (name === "key" && oldValue !== newValue) {
|
|
153
|
+
requestAnimationFrame(() => {
|
|
154
|
+
const value = this.getAttribute("value");
|
|
155
|
+
const min = this.getAttribute("min") || "0";
|
|
156
|
+
this._inputElement.value = value ?? min;
|
|
157
|
+
});
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
151
161
|
// Handle input-specific attributes first
|
|
152
162
|
if (["value", "min", "max", "step", "disabled"].includes(name)) {
|
|
153
163
|
this._updateInputAttributes();
|
|
@@ -48,10 +48,21 @@ class RettangoliTextAreaElement extends HTMLElement {
|
|
|
48
48
|
this._textareaElement = document.createElement('textarea');
|
|
49
49
|
this._textareaElement.setAttribute('type', 'text');
|
|
50
50
|
this.shadow.appendChild(this._textareaElement);
|
|
51
|
+
|
|
52
|
+
// Bind event handler
|
|
53
|
+
this._textareaElement.addEventListener('input', this._onChange);
|
|
51
54
|
}
|
|
52
55
|
|
|
56
|
+
_onChange = (event) => {
|
|
57
|
+
this.dispatchEvent(new CustomEvent('textarea-change', {
|
|
58
|
+
detail: {
|
|
59
|
+
value: this._textareaElement.value,
|
|
60
|
+
},
|
|
61
|
+
}));
|
|
62
|
+
};
|
|
63
|
+
|
|
53
64
|
static get observedAttributes() {
|
|
54
|
-
return ["key", "w", "ellipsis", "cols", "rows", "placeholder"];
|
|
65
|
+
return ["key", "w", "ellipsis", "cols", "rows", "placeholder", "value"];
|
|
55
66
|
}
|
|
56
67
|
|
|
57
68
|
get value() {
|
|
@@ -67,6 +78,14 @@ class RettangoliTextAreaElement extends HTMLElement {
|
|
|
67
78
|
}
|
|
68
79
|
|
|
69
80
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
81
|
+
// Handle key attribute change - reset value
|
|
82
|
+
if (name === "key" && oldValue !== newValue) {
|
|
83
|
+
requestAnimationFrame(() => {
|
|
84
|
+
const value = this.getAttribute("value");
|
|
85
|
+
this._textareaElement.value = value ?? "";
|
|
86
|
+
});
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
70
89
|
this._updateTextareaAttributes();
|
|
71
90
|
}
|
|
72
91
|
|
|
@@ -74,6 +93,7 @@ class RettangoliTextAreaElement extends HTMLElement {
|
|
|
74
93
|
const cols = this.getAttribute("cols");
|
|
75
94
|
const rows = this.getAttribute("rows");
|
|
76
95
|
const placeholder = this.getAttribute("placeholder");
|
|
96
|
+
const value = this.getAttribute("value");
|
|
77
97
|
|
|
78
98
|
if (cols !== null) {
|
|
79
99
|
this._textareaElement.setAttribute("cols", cols);
|
|
@@ -92,6 +112,10 @@ class RettangoliTextAreaElement extends HTMLElement {
|
|
|
92
112
|
} else {
|
|
93
113
|
this._textareaElement.removeAttribute("placeholder");
|
|
94
114
|
}
|
|
115
|
+
|
|
116
|
+
if (value !== null) {
|
|
117
|
+
this._textareaElement.value = value;
|
|
118
|
+
}
|
|
95
119
|
}
|
|
96
120
|
}
|
|
97
121
|
|
|
@@ -2,10 +2,46 @@ import { generateCSS } from '../common.js'
|
|
|
2
2
|
|
|
3
3
|
const styles = {
|
|
4
4
|
"cur": {
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"alias": "alias",
|
|
6
|
+
"all-scroll": "all-scroll",
|
|
7
|
+
"auto": "auto",
|
|
8
|
+
"cell": "cell",
|
|
9
|
+
"col-resize": "col-resize",
|
|
10
|
+
"context-menu": "context-menu",
|
|
11
|
+
"copy": "copy",
|
|
12
|
+
"crosshair": "crosshair",
|
|
13
|
+
"default": "default",
|
|
14
|
+
"e-resize": "e-resize",
|
|
15
|
+
"ew-resize": "ew-resize",
|
|
7
16
|
"grab": "grab",
|
|
8
17
|
"grabbing": "grabbing",
|
|
18
|
+
"help": "help",
|
|
19
|
+
"move": "move",
|
|
20
|
+
"n-resize": "n-resize",
|
|
21
|
+
"ne-resize": "ne-resize",
|
|
22
|
+
"nesw-resize": "nesw-resize",
|
|
23
|
+
"ns-resize": "ns-resize",
|
|
24
|
+
"nw-resize": "nw-resize",
|
|
25
|
+
"nwse-resize": "nwse-resize",
|
|
26
|
+
"no-drop": "no-drop",
|
|
27
|
+
"none": "none",
|
|
28
|
+
"not-allowed": "not-allowed",
|
|
29
|
+
"pointer": "pointer",
|
|
30
|
+
"progress": "progress",
|
|
31
|
+
"row-resize": "row-resize",
|
|
32
|
+
"s-resize": "s-resize",
|
|
33
|
+
"se-resize": "se-resize",
|
|
34
|
+
"sw-resize": "sw-resize",
|
|
35
|
+
"text": "text",
|
|
36
|
+
"url": "url",
|
|
37
|
+
"w-resize": "w-resize",
|
|
38
|
+
"wait": "wait",
|
|
39
|
+
"zoom-in": "zoom-in",
|
|
40
|
+
"zoom-out": "zoom-out",
|
|
41
|
+
|
|
42
|
+
// Keep short aliases for common cursors
|
|
43
|
+
"p": "pointer",
|
|
44
|
+
"m": "move",
|
|
9
45
|
},
|
|
10
46
|
};
|
|
11
47
|
|