@rettangoli/ui 0.1.3 → 0.1.5
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-ui.min.js +30 -30
- package/package.json +4 -4
- package/src/components/breadcrumb/breadcrumb.handlers.js +2 -1
- package/src/components/dropdownMenu/dropdownMenu.handlers.js +5 -4
- package/src/components/dropdownMenu/dropdownMenu.view.yaml +10 -10
- package/src/components/form/form.handlers.js +25 -14
- package/src/components/globalUi/globalUi.handlers.js +91 -13
- package/src/components/globalUi/globalUi.store.js +38 -2
- package/src/components/globalUi/globalUi.view.yaml +31 -11
- package/src/components/navbar/navbar.handlers.js +2 -1
- package/src/components/popoverInput/popoverInput.handlers.js +11 -7
- package/src/components/select/select.handlers.js +15 -11
- package/src/components/sidebar/sidebar.handlers.js +4 -2
- package/src/components/sliderInput/sliderInput.handlers.js +5 -4
- package/src/components/table/table.handlers.js +4 -2
- package/src/components/tabs/tabs.handlers.js +2 -1
- package/src/components/waveform/waveform.handlers.js +1 -1
- package/src/deps/createGlobalUI.js +77 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rettangoli/ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "A UI component library for building web interfaces.",
|
|
5
5
|
"main": "dist/rettangoli-esm.min.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"scripts": {
|
|
26
|
-
"build:dev": "rtgl fe build && bun run esbuild-dev.js",
|
|
26
|
+
"build:dev": "rtgl fe build -d && bun run esbuild-dev.js",
|
|
27
27
|
"build": "rtgl fe build && bun run esbuild.js",
|
|
28
|
-
"vt:generate": "rtgl fe build && bun run esbuild-dev.js && rtgl vt generate --skip-screenshots",
|
|
29
|
-
"vt:report": "bun run build:dev && rtgl vt generate && rtgl vt report",
|
|
28
|
+
"vt:generate": "rtgl fe build -d && bun run esbuild-dev.js && rtgl vt generate --skip-screenshots",
|
|
29
|
+
"vt:report": "bun run build:dev && rtgl vt generate --screenshot-wait-time 500 && rtgl vt report",
|
|
30
30
|
"vt:accept": "rtgl vt accept",
|
|
31
31
|
"serve": "bunx serve .rettangoli/vt/_site"
|
|
32
32
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export const handleClickItem = (deps,
|
|
1
|
+
export const handleClickItem = (deps, payload) => {
|
|
2
2
|
const { dispatchEvent } = deps;
|
|
3
|
+
const event = payload._event;
|
|
3
4
|
const id = event.currentTarget.dataset.id;
|
|
4
5
|
dispatchEvent(new CustomEvent('item-click', {
|
|
5
6
|
detail: {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
|
|
2
|
-
export const handleClosePopover = (deps,
|
|
2
|
+
export const handleClosePopover = (deps, payload) => {
|
|
3
3
|
const { dispatchEvent } = deps;
|
|
4
4
|
dispatchEvent(new CustomEvent('close'));
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export const handleClickMenuItem = (deps,
|
|
8
|
-
const { dispatchEvent } = deps;
|
|
7
|
+
export const handleClickMenuItem = (deps, payload) => {
|
|
8
|
+
const { dispatchEvent, props } = deps;
|
|
9
|
+
const event = payload._event;
|
|
9
10
|
const index = parseInt(event.currentTarget.id.replace('option-', ''));
|
|
10
|
-
const item =
|
|
11
|
+
const item = props.items[index];
|
|
11
12
|
|
|
12
13
|
dispatchEvent(new CustomEvent('click-item', {
|
|
13
14
|
detail: {
|
|
@@ -44,13 +44,13 @@ refs:
|
|
|
44
44
|
|
|
45
45
|
template:
|
|
46
46
|
- rtgl-popover#popover ?open=${open} x=${x} y=${y} placement=${placement}:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
- rtgl-view wh=300 sv g=xs slot=content bgc=background br=md:
|
|
48
|
+
- $for item, i in items:
|
|
49
|
+
- $if item.type == 'label':
|
|
50
|
+
- rtgl-view w=f ph=lg pv=md:
|
|
51
|
+
- rtgl-text s=sm c=mu-fg: ${item.label}
|
|
52
|
+
$elif item.type == 'item':
|
|
53
|
+
- rtgl-view#option-${i} w=f h-bgc=ac ph=lg pv=md cur=p br=md bgc=mu:
|
|
54
|
+
- rtgl-text: ${item.label}
|
|
55
|
+
$elif item.type == 'separator':
|
|
56
|
+
- rtgl-view w=f h=1 ph=lg mv=md bgc=bo:
|
|
@@ -3,8 +3,8 @@ export const handleBeforeMount = (deps) => {
|
|
|
3
3
|
store.setFormValues(props.defaultValues);
|
|
4
4
|
};
|
|
5
5
|
|
|
6
|
-
export const handleOnUpdate = (
|
|
7
|
-
const { oldAttrs, newAttrs } =
|
|
6
|
+
export const handleOnUpdate = (deps, payload) => {
|
|
7
|
+
const { oldAttrs, newAttrs } = payload;
|
|
8
8
|
const { store, props, render } = deps;
|
|
9
9
|
|
|
10
10
|
if (oldAttrs?.key === newAttrs?.key) {
|
|
@@ -27,8 +27,9 @@ const dispatchFormChange = (name, fieldValue, formValues, dispatchEvent) => {
|
|
|
27
27
|
);
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
export const handleActionClick = (deps,
|
|
30
|
+
export const handleActionClick = (deps, payload) => {
|
|
31
31
|
const { store, dispatchEvent } = deps;
|
|
32
|
+
const event = payload._event;
|
|
32
33
|
const id = event.currentTarget.id.replace("action-", "");
|
|
33
34
|
dispatchEvent(
|
|
34
35
|
new CustomEvent("action-click", {
|
|
@@ -40,8 +41,9 @@ export const handleActionClick = (deps, event) => {
|
|
|
40
41
|
);
|
|
41
42
|
};
|
|
42
43
|
|
|
43
|
-
export const handleInputChange = (deps,
|
|
44
|
+
export const handleInputChange = (deps, payload) => {
|
|
44
45
|
const { store, dispatchEvent, props } = deps;
|
|
46
|
+
const event = payload._event;
|
|
45
47
|
const name = event.currentTarget.id.replace("input-", "");
|
|
46
48
|
// TODO fix double event
|
|
47
49
|
if (name && event.detail.value !== undefined) {
|
|
@@ -59,8 +61,9 @@ export const handleInputChange = (deps, event) => {
|
|
|
59
61
|
}
|
|
60
62
|
};
|
|
61
63
|
|
|
62
|
-
export const handlePopoverInputChange = (deps,
|
|
64
|
+
export const handlePopoverInputChange = (deps, payload) => {
|
|
63
65
|
const { store, dispatchEvent, props } = deps;
|
|
66
|
+
const event = payload._event;
|
|
64
67
|
const name = event.currentTarget.id.replace("popover-input-", "");
|
|
65
68
|
// TODO fix double event
|
|
66
69
|
if (name && event.detail.value !== undefined) {
|
|
@@ -78,8 +81,9 @@ export const handlePopoverInputChange = (deps, event) => {
|
|
|
78
81
|
}
|
|
79
82
|
};
|
|
80
83
|
|
|
81
|
-
export const handleSelectChange = (deps,
|
|
84
|
+
export const handleSelectChange = (deps, payload) => {
|
|
82
85
|
const { store, dispatchEvent, render, props } = deps;
|
|
86
|
+
const event = payload._event;
|
|
83
87
|
const name = event.currentTarget.id.replace("select-", "");
|
|
84
88
|
if (name && event.detail.selectedValue !== undefined) {
|
|
85
89
|
store.setFormFieldValue({
|
|
@@ -97,8 +101,9 @@ export const handleSelectChange = (deps, event) => {
|
|
|
97
101
|
}
|
|
98
102
|
};
|
|
99
103
|
|
|
100
|
-
export const handleColorPickerChange = (deps,
|
|
104
|
+
export const handleColorPickerChange = (deps, payload) => {
|
|
101
105
|
const { store, dispatchEvent, props } = deps;
|
|
106
|
+
const event = payload._event;
|
|
102
107
|
const name = event.currentTarget.id.replace("colorpicker-", "");
|
|
103
108
|
if (name && event.detail.value !== undefined) {
|
|
104
109
|
store.setFormFieldValue({
|
|
@@ -115,8 +120,9 @@ export const handleColorPickerChange = (deps, event) => {
|
|
|
115
120
|
}
|
|
116
121
|
};
|
|
117
122
|
|
|
118
|
-
export const handleSliderChange = (deps,
|
|
123
|
+
export const handleSliderChange = (deps, payload) => {
|
|
119
124
|
const { store, dispatchEvent, props } = deps;
|
|
125
|
+
const event = payload._event;
|
|
120
126
|
const name = event.currentTarget.id.replace("slider-", "");
|
|
121
127
|
if (name && event.detail.value !== undefined) {
|
|
122
128
|
store.setFormFieldValue({
|
|
@@ -133,8 +139,9 @@ export const handleSliderChange = (deps, event) => {
|
|
|
133
139
|
}
|
|
134
140
|
};
|
|
135
141
|
|
|
136
|
-
export const handleSliderInputChange = (deps,
|
|
142
|
+
export const handleSliderInputChange = (deps, payload) => {
|
|
137
143
|
const { store, dispatchEvent, props } = deps;
|
|
144
|
+
const event = payload._event;
|
|
138
145
|
const name = event.currentTarget.id.replace("slider-input-", "");
|
|
139
146
|
if (name && event.detail.value !== undefined) {
|
|
140
147
|
store.setFormFieldValue({
|
|
@@ -151,7 +158,8 @@ export const handleSliderInputChange = (deps, event) => {
|
|
|
151
158
|
}
|
|
152
159
|
};
|
|
153
160
|
|
|
154
|
-
export const handleImageClick = (deps,
|
|
161
|
+
export const handleImageClick = (deps, payload) => {
|
|
162
|
+
const event = payload._event;
|
|
155
163
|
if (event.type === "contextmenu") {
|
|
156
164
|
event.preventDefault();
|
|
157
165
|
}
|
|
@@ -169,7 +177,8 @@ export const handleImageClick = (deps, event) => {
|
|
|
169
177
|
);
|
|
170
178
|
};
|
|
171
179
|
|
|
172
|
-
export const handleWaveformClick = (deps,
|
|
180
|
+
export const handleWaveformClick = (deps, payload) => {
|
|
181
|
+
const event = payload._event;
|
|
173
182
|
if (event.type === "contextmenu") {
|
|
174
183
|
event.preventDefault();
|
|
175
184
|
}
|
|
@@ -187,8 +196,9 @@ export const handleWaveformClick = (deps, event) => {
|
|
|
187
196
|
);
|
|
188
197
|
};
|
|
189
198
|
|
|
190
|
-
export const handleSelectAddOption = (deps,
|
|
199
|
+
export const handleSelectAddOption = (deps, payload) => {
|
|
191
200
|
const { store, dispatchEvent } = deps;
|
|
201
|
+
const event = payload._event;
|
|
192
202
|
const name = event.currentTarget.id.replace("select-", "");
|
|
193
203
|
dispatchEvent(
|
|
194
204
|
new CustomEvent("action-click", {
|
|
@@ -201,8 +211,9 @@ export const handleSelectAddOption = (deps, event) => {
|
|
|
201
211
|
);
|
|
202
212
|
};
|
|
203
213
|
|
|
204
|
-
export const handleTooltipMouseEnter = (deps,
|
|
214
|
+
export const handleTooltipMouseEnter = (deps, payload) => {
|
|
205
215
|
const { store, render, props } = deps;
|
|
216
|
+
const event = payload._event;
|
|
206
217
|
const fieldName = event.currentTarget.id.replace('tooltip-icon-', '');
|
|
207
218
|
|
|
208
219
|
// Find the field with matching name to get tooltip content
|
|
@@ -220,7 +231,7 @@ export const handleTooltipMouseEnter = (deps, event) => {
|
|
|
220
231
|
}
|
|
221
232
|
};
|
|
222
233
|
|
|
223
|
-
export const handleTooltipMouseLeave = (deps,
|
|
234
|
+
export const handleTooltipMouseLeave = (deps, payload) => {
|
|
224
235
|
const { store, render } = deps;
|
|
225
236
|
store.hideTooltip();
|
|
226
237
|
render();
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export const handleDialogClose = (
|
|
1
|
+
export const handleDialogClose = (deps, payload) => {
|
|
2
2
|
const { store, render } = deps;
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
store.closeDialog();
|
|
5
5
|
render();
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
export const handleConfirm = (
|
|
8
|
+
export const handleConfirm = (deps, payload) => {
|
|
9
9
|
const { store, render, globalUI } = deps;
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
store.closeDialog();
|
|
12
12
|
render();
|
|
13
13
|
globalUI.emit('event', true);
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export const handleCancel = (
|
|
16
|
+
export const handleCancel = (deps, payload) => {
|
|
17
17
|
const { store, render, globalUI } = deps;
|
|
18
18
|
|
|
19
19
|
store.closeDialog();
|
|
@@ -21,24 +21,64 @@ export const handleCancel = (_, deps) => {
|
|
|
21
21
|
globalUI.emit('event', false);
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
export const
|
|
24
|
+
export const handleDropdownClose = (deps, payload) => {
|
|
25
|
+
const { store, render, globalUI } = deps;
|
|
26
|
+
|
|
27
|
+
// Always process close events - the framework will handle if it's already closed
|
|
28
|
+
store.closeDialog();
|
|
29
|
+
render();
|
|
30
|
+
globalUI.emit('event', null);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const handleDropdownItemClick = (deps, payload) => {
|
|
34
|
+
const { store, render, globalUI } = deps;
|
|
35
|
+
const event = payload._event;
|
|
36
|
+
const { index, item } = event.detail;
|
|
37
|
+
|
|
38
|
+
// Always process click events - the framework will handle if it's already closed
|
|
39
|
+
store.closeDialog();
|
|
40
|
+
render();
|
|
41
|
+
globalUI.emit('event', { index, item });
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Shows an alert dialog with the specified options.
|
|
46
|
+
* Closes any existing dialog or dropdown before showing the alert.
|
|
47
|
+
*
|
|
48
|
+
* @param {Object} deps - Dependencies object
|
|
49
|
+
* @param {Object} deps.store - The globalUI store instance
|
|
50
|
+
* @param {Function} deps.render - Function to trigger re-rendering
|
|
51
|
+
* @param {Object} payload - Alert configuration options
|
|
52
|
+
* @param {string} payload.message - The alert message (required)
|
|
53
|
+
* @param {string} [payload.title] - Optional alert title
|
|
54
|
+
* @param {('info'|'warning'|'error')} [payload.status] - Optional status type
|
|
55
|
+
* @param {string} [payload.confirmText] - Text for the confirm button (default: "OK")
|
|
56
|
+
* @returns {void}
|
|
57
|
+
*/
|
|
58
|
+
export const showAlert = (deps, payload) => {
|
|
25
59
|
const { store, render } = deps;
|
|
26
|
-
|
|
60
|
+
const options = payload;
|
|
61
|
+
|
|
62
|
+
// Close any existing dialog/dropdown menu first
|
|
27
63
|
if (store.selectIsOpen()) {
|
|
28
|
-
|
|
64
|
+
store.closeDialog();
|
|
65
|
+
render();
|
|
29
66
|
}
|
|
30
|
-
|
|
67
|
+
|
|
31
68
|
store.setAlertConfig(options);
|
|
32
69
|
render();
|
|
33
70
|
};
|
|
34
71
|
|
|
35
|
-
export const showConfirm = async (
|
|
72
|
+
export const showConfirm = async (deps, payload) => {
|
|
36
73
|
const { store, render, globalUI } = deps;
|
|
37
|
-
|
|
74
|
+
const options = payload;
|
|
75
|
+
|
|
76
|
+
// Close any existing dialog/dropdown menu first
|
|
38
77
|
if (store.selectIsOpen()) {
|
|
39
|
-
|
|
78
|
+
store.closeDialog();
|
|
79
|
+
render();
|
|
40
80
|
}
|
|
41
|
-
|
|
81
|
+
|
|
42
82
|
store.setConfirmConfig(options);
|
|
43
83
|
render();
|
|
44
84
|
|
|
@@ -48,4 +88,42 @@ export const showConfirm = async (options, deps) => {
|
|
|
48
88
|
resolve(result)
|
|
49
89
|
});
|
|
50
90
|
});
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Shows a dropdown menu at the specified position with the given items.
|
|
95
|
+
* Closes any existing dialog or dropdown menu before showing the dropdown menu.
|
|
96
|
+
*
|
|
97
|
+
* @param {Object} deps - Dependencies object
|
|
98
|
+
* @param {Object} deps.store - The globalUI store instance
|
|
99
|
+
* @param {Function} deps.render - Function to trigger re-rendering
|
|
100
|
+
* @param {Object} deps.globalUI - The globalUI event emitter
|
|
101
|
+
* @param {Object} payload - Dropdown menu configuration options
|
|
102
|
+
* @param {Array<Object>} payload.items - Array of dropdown menu items (required)
|
|
103
|
+
* @param {number} payload.x - X coordinate position (required)
|
|
104
|
+
* @param {number} payload.y - Y coordinate position (required)
|
|
105
|
+
* @param {string} [payload.placement] - Dropdown menu placement (default: "bottom-start")
|
|
106
|
+
* @returns {Promise<Object|null>} Promise that resolves with clicked item info or null if closed without selection
|
|
107
|
+
* @returns {Object} [result.index] - Index of the clicked item
|
|
108
|
+
* @returns {Object} [result.item] - The clicked item object
|
|
109
|
+
*/
|
|
110
|
+
export const showDropdownMenu = async (deps, payload) => {
|
|
111
|
+
const { store, render, globalUI } = deps;
|
|
112
|
+
const options = payload;
|
|
113
|
+
|
|
114
|
+
// Close any existing dialog/dropdown menu first
|
|
115
|
+
if (store.selectIsOpen()) {
|
|
116
|
+
store.closeDialog();
|
|
117
|
+
render();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
store.setDropdownConfig(options);
|
|
121
|
+
render();
|
|
122
|
+
|
|
123
|
+
return new Promise((resolve) => {
|
|
124
|
+
globalUI.once('event', (result) => {
|
|
125
|
+
// result contains info of clicked item or null if closed without selection
|
|
126
|
+
resolve(result)
|
|
127
|
+
});
|
|
128
|
+
});
|
|
51
129
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export const createInitialState = () => Object.freeze({
|
|
2
2
|
isOpen: false,
|
|
3
|
+
uiType: "dialog", // "dialog" | "dropdown"
|
|
3
4
|
config: {
|
|
4
5
|
status: undefined, // undefined | info | warning | error
|
|
5
6
|
title: "",
|
|
@@ -8,13 +9,19 @@ export const createInitialState = () => Object.freeze({
|
|
|
8
9
|
cancelText: "Cancel",
|
|
9
10
|
mode: "alert", // alert | confirm
|
|
10
11
|
},
|
|
12
|
+
dropdownConfig: {
|
|
13
|
+
items: [],
|
|
14
|
+
x: 0,
|
|
15
|
+
y: 0,
|
|
16
|
+
placement: "bottom-start",
|
|
17
|
+
},
|
|
11
18
|
});
|
|
12
19
|
|
|
13
20
|
export const setAlertConfig = (state, options) => {
|
|
14
21
|
if (!options.message) {
|
|
15
22
|
throw new Error("message is required for showAlert");
|
|
16
23
|
}
|
|
17
|
-
|
|
24
|
+
|
|
18
25
|
state.config = {
|
|
19
26
|
status: options.status || undefined,
|
|
20
27
|
title: options.title || "",
|
|
@@ -23,6 +30,7 @@ export const setAlertConfig = (state, options) => {
|
|
|
23
30
|
cancelText: "",
|
|
24
31
|
mode: "alert",
|
|
25
32
|
};
|
|
33
|
+
state.uiType = "dialog";
|
|
26
34
|
state.isOpen = true;
|
|
27
35
|
};
|
|
28
36
|
|
|
@@ -30,7 +38,7 @@ export const setConfirmConfig = (state, options) => {
|
|
|
30
38
|
if (!options.message) {
|
|
31
39
|
throw new Error("message is required for showConfirm");
|
|
32
40
|
}
|
|
33
|
-
|
|
41
|
+
|
|
34
42
|
state.config = {
|
|
35
43
|
status: options.status || undefined,
|
|
36
44
|
title: options.title || "",
|
|
@@ -39,19 +47,47 @@ export const setConfirmConfig = (state, options) => {
|
|
|
39
47
|
cancelText: options.cancelText || "Cancel",
|
|
40
48
|
mode: "confirm",
|
|
41
49
|
};
|
|
50
|
+
state.uiType = "dialog";
|
|
51
|
+
state.isOpen = true;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const setDropdownConfig = (state, options) => {
|
|
55
|
+
if (!options.items || !Array.isArray(options.items)) {
|
|
56
|
+
throw new Error("items array is required for showDropdown");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
state.dropdownConfig = {
|
|
60
|
+
items: options.items,
|
|
61
|
+
x: options.x || 0,
|
|
62
|
+
y: options.y || 0,
|
|
63
|
+
placement: options.placement || "bottom-start",
|
|
64
|
+
};
|
|
65
|
+
state.uiType = "dropdown";
|
|
42
66
|
state.isOpen = true;
|
|
43
67
|
};
|
|
44
68
|
|
|
45
69
|
export const closeDialog = (state) => {
|
|
46
70
|
state.isOpen = false;
|
|
71
|
+
state.uiType = "dialog"; // Reset to default type
|
|
47
72
|
};
|
|
48
73
|
|
|
49
74
|
export const selectConfig = ({ state }) => state.config;
|
|
75
|
+
export const selectDropdownConfig = ({ state }) => state.dropdownConfig;
|
|
76
|
+
export const selectUiType = ({ state }) => state.uiType;
|
|
50
77
|
export const selectIsOpen = ({ state }) => state.isOpen;
|
|
51
78
|
|
|
52
79
|
export const selectViewData = ({ state }) => {
|
|
53
80
|
return {
|
|
54
81
|
isOpen: state.isOpen,
|
|
82
|
+
uiType: state.uiType,
|
|
55
83
|
config: state.config,
|
|
84
|
+
dropdownConfig: {
|
|
85
|
+
items: state.dropdownConfig?.items || [],
|
|
86
|
+
x: state.dropdownConfig?.x || 0,
|
|
87
|
+
y: state.dropdownConfig?.y || 0,
|
|
88
|
+
placement: state.dropdownConfig?.placement || 'bottom-start',
|
|
89
|
+
},
|
|
90
|
+
isDialogOpen: state.isOpen && state.uiType === 'dialog',
|
|
91
|
+
isDropdownOpen: state.isOpen && state.uiType === 'dropdown',
|
|
56
92
|
};
|
|
57
93
|
};
|
|
@@ -5,6 +5,8 @@ viewDataSchema:
|
|
|
5
5
|
properties:
|
|
6
6
|
isOpen:
|
|
7
7
|
type: boolean
|
|
8
|
+
uiType:
|
|
9
|
+
type: string
|
|
8
10
|
config:
|
|
9
11
|
type: object
|
|
10
12
|
properties:
|
|
@@ -20,6 +22,17 @@ viewDataSchema:
|
|
|
20
22
|
type: string
|
|
21
23
|
mode:
|
|
22
24
|
type: string
|
|
25
|
+
dropdownConfig:
|
|
26
|
+
type: object
|
|
27
|
+
properties:
|
|
28
|
+
items:
|
|
29
|
+
type: array
|
|
30
|
+
x:
|
|
31
|
+
type: number
|
|
32
|
+
y:
|
|
33
|
+
type: number
|
|
34
|
+
placement:
|
|
35
|
+
type: string
|
|
23
36
|
|
|
24
37
|
refs:
|
|
25
38
|
dialog:
|
|
@@ -34,17 +47,24 @@ refs:
|
|
|
34
47
|
eventListeners:
|
|
35
48
|
click:
|
|
36
49
|
handler: handleCancel
|
|
50
|
+
dropdown-menu:
|
|
51
|
+
eventListeners:
|
|
52
|
+
close:
|
|
53
|
+
handler: handleDropdownClose
|
|
54
|
+
click-item:
|
|
55
|
+
handler: handleDropdownItemClick
|
|
37
56
|
|
|
38
57
|
template:
|
|
39
|
-
- rtgl-dialog#dialog ?open=${
|
|
58
|
+
- rtgl-dialog#dialog ?open=${isDialogOpen} s=sm:
|
|
40
59
|
- rtgl-view slot=content g=lg p=lg:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
60
|
+
- rtgl-view d=h g=md:
|
|
61
|
+
- rtgl-view d=h ah=c av=c g=md:
|
|
62
|
+
- rtgl-view g=md:
|
|
63
|
+
- rtgl-view h=24 av=c:
|
|
64
|
+
- rtgl-text fw=600: ${config.title}
|
|
65
|
+
- rtgl-text: ${config.message}
|
|
66
|
+
- rtgl-view d=h g=md mt=lg w=f ah=e:
|
|
67
|
+
- $if config.mode == 'confirm':
|
|
68
|
+
- rtgl-button#cancel-button v=se: ${config.cancelText}
|
|
69
|
+
- rtgl-button#confirm-button v=pr: ${config.confirmText}
|
|
70
|
+
- rtgl-dropdown-menu#dropdown-menu ?open=${isDropdownOpen} x=${dropdownConfig.x} y=${dropdownConfig.y} placement=${dropdownConfig.placement} .items=dropdownConfig.items key=dropdown-${isDropdownOpen}:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
export const handleClickStart = (deps,
|
|
2
|
+
export const handleClickStart = (deps, payload) => {
|
|
3
3
|
const { dispatchEvent, store } = deps;
|
|
4
|
+
const event = payload._event;
|
|
4
5
|
console.log('handle click start', store.selectPath());
|
|
5
6
|
dispatchEvent(new CustomEvent('clickStart', {
|
|
6
7
|
detail: {
|
|
@@ -6,8 +6,8 @@ export const handleBeforeMount = (deps) => {
|
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export const handleOnUpdate = (
|
|
10
|
-
const { oldProps, newProps} =
|
|
9
|
+
export const handleOnUpdate = (deps, payload) => {
|
|
10
|
+
const { oldProps, newProps} = payload
|
|
11
11
|
const { store, props, render } = deps;
|
|
12
12
|
|
|
13
13
|
if (oldProps.defaultValue !== newProps.defaultValue) {
|
|
@@ -17,8 +17,9 @@ export const handleOnUpdate = (changes, deps) => {
|
|
|
17
17
|
render();
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export const handleTextClick = (deps,
|
|
20
|
+
export const handleTextClick = (deps, payload) => {
|
|
21
21
|
const { store, render, getRefIds, attrs } = deps;
|
|
22
|
+
const event = payload._event;
|
|
22
23
|
|
|
23
24
|
const value = store.selectValue();
|
|
24
25
|
store.setTempValue(value)
|
|
@@ -41,14 +42,15 @@ export const handleTextClick = (deps, event) => {
|
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
export const handlePopoverClose = (deps,
|
|
45
|
+
export const handlePopoverClose = (deps, payload) => {
|
|
45
46
|
const { store, render } = deps;
|
|
46
47
|
store.closePopover();
|
|
47
48
|
render();
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
export const handleInputChange = (deps,
|
|
51
|
+
export const handleInputChange = (deps, payload) => {
|
|
51
52
|
const { store, render, dispatchEvent } = deps;
|
|
53
|
+
const event = payload._event;
|
|
52
54
|
const value = event.detail.value;
|
|
53
55
|
|
|
54
56
|
store.setTempValue(value);
|
|
@@ -61,8 +63,9 @@ export const handleInputChange = (deps, event) => {
|
|
|
61
63
|
render();
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
export const handleSubmitClick = (deps,
|
|
66
|
+
export const handleSubmitClick = (deps, payload) => {
|
|
65
67
|
const { store, render, dispatchEvent, getRefIds } = deps;
|
|
68
|
+
const event = payload._event;
|
|
66
69
|
const { input } = getRefIds()
|
|
67
70
|
const value = input.elm.value;
|
|
68
71
|
|
|
@@ -77,8 +80,9 @@ export const handleSubmitClick = (deps, event) => {
|
|
|
77
80
|
render();
|
|
78
81
|
}
|
|
79
82
|
|
|
80
|
-
export const handleInputKeydown = (deps,
|
|
83
|
+
export const handleInputKeydown = (deps, payload) => {
|
|
81
84
|
const { store, render, dispatchEvent, getRefIds } = deps;
|
|
85
|
+
const event = payload._event;
|
|
82
86
|
|
|
83
87
|
if (event.key === 'Enter') {
|
|
84
88
|
const { input } = getRefIds()
|
|
@@ -12,8 +12,8 @@ export const handleBeforeMount = (deps) => {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export const handleOnUpdate = (
|
|
16
|
-
const { oldAttrs, newAttrs, oldProps, newProps } =
|
|
15
|
+
export const handleOnUpdate = (deps, payload) => {
|
|
16
|
+
const { oldAttrs, newAttrs, oldProps, newProps } = payload;
|
|
17
17
|
const { store, props, render } = deps;
|
|
18
18
|
|
|
19
19
|
// Check if key changed
|
|
@@ -35,8 +35,9 @@ export const handleOnUpdate = (changes, deps) => {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export const handleButtonClick = (deps,
|
|
38
|
+
export const handleButtonClick = (deps, payload) => {
|
|
39
39
|
const { store, render, getRefIds, props } = deps;
|
|
40
|
+
const event = payload._event;
|
|
40
41
|
|
|
41
42
|
const button = getRefIds()['select-button'].elm;
|
|
42
43
|
|
|
@@ -63,14 +64,15 @@ export const handleButtonClick = (deps, event) => {
|
|
|
63
64
|
render();
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
export const handleClickOptionsPopoverOverlay = (deps,
|
|
67
|
+
export const handleClickOptionsPopoverOverlay = (deps, payload) => {
|
|
67
68
|
const { store, render } = deps;
|
|
68
69
|
store.closeOptionsPopover();
|
|
69
70
|
render();
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
export const handleOptionClick = (deps,
|
|
73
|
+
export const handleOptionClick = (deps, payload) => {
|
|
73
74
|
const { render, dispatchEvent, props, store } = deps;
|
|
75
|
+
const event = payload._event;
|
|
74
76
|
const id = event.currentTarget.id.replace('option-', '');
|
|
75
77
|
|
|
76
78
|
const option = props.options[id];
|
|
@@ -98,21 +100,23 @@ export const handleOptionClick = (deps, event) => {
|
|
|
98
100
|
render();
|
|
99
101
|
}
|
|
100
102
|
|
|
101
|
-
export const handleOptionMouseEnter = (deps,
|
|
103
|
+
export const handleOptionMouseEnter = (deps, payload) => {
|
|
102
104
|
const { store, render } = deps;
|
|
105
|
+
const event = payload._event;
|
|
103
106
|
const id = parseInt(event.currentTarget.id.replace('option-', ''));
|
|
104
107
|
store.setHoveredOption(id);
|
|
105
108
|
render();
|
|
106
109
|
}
|
|
107
110
|
|
|
108
|
-
export const handleOptionMouseLeave = (deps,
|
|
111
|
+
export const handleOptionMouseLeave = (deps, payload) => {
|
|
109
112
|
const { store, render } = deps;
|
|
110
113
|
store.clearHoveredOption();
|
|
111
114
|
render();
|
|
112
115
|
}
|
|
113
116
|
|
|
114
|
-
export const handleClearClick = (deps,
|
|
117
|
+
export const handleClearClick = (deps, payload) => {
|
|
115
118
|
const { store, render, dispatchEvent, props } = deps;
|
|
119
|
+
const event = payload._event;
|
|
116
120
|
|
|
117
121
|
event.stopPropagation();
|
|
118
122
|
|
|
@@ -139,7 +143,7 @@ export const handleClearClick = (deps, event) => {
|
|
|
139
143
|
render();
|
|
140
144
|
}
|
|
141
145
|
|
|
142
|
-
export const handleAddOptionClick = (deps,
|
|
146
|
+
export const handleAddOptionClick = (deps, payload) => {
|
|
143
147
|
const { store, render, dispatchEvent } = deps;
|
|
144
148
|
|
|
145
149
|
// Close the popover
|
|
@@ -153,13 +157,13 @@ export const handleAddOptionClick = (deps, event) => {
|
|
|
153
157
|
render();
|
|
154
158
|
}
|
|
155
159
|
|
|
156
|
-
export const handleAddOptionMouseEnter = (deps,
|
|
160
|
+
export const handleAddOptionMouseEnter = (deps, payload) => {
|
|
157
161
|
const { store, render } = deps;
|
|
158
162
|
store.setHoveredAddOption(true);
|
|
159
163
|
render();
|
|
160
164
|
}
|
|
161
165
|
|
|
162
|
-
export const handleAddOptionMouseLeave = (deps,
|
|
166
|
+
export const handleAddOptionMouseLeave = (deps, payload) => {
|
|
163
167
|
const { store, render } = deps;
|
|
164
168
|
store.setHoveredAddOption(false);
|
|
165
169
|
render();
|