@rettangoli/ui 0.1.2-rc2 → 0.1.2-rc20
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 +102 -32
- package/dist/rettangoli-iife-ui.min.js +182 -69
- package/package.json +5 -3
- package/src/cli/buildSvg.js +86 -0
- package/src/cli/index.js +1 -0
- package/src/components/breadcrumb/breadcrumb.handlers.js +9 -0
- package/src/components/breadcrumb/breadcrumb.store.js +29 -0
- package/src/components/breadcrumb/breadcrumb.view.yaml +64 -0
- package/src/components/dropdownMenu/dropdownMenu.handlers.js +4 -4
- package/src/components/dropdownMenu/dropdownMenu.store.js +5 -17
- package/src/components/dropdownMenu/dropdownMenu.view.yaml +15 -13
- package/src/components/form/form.handlers.js +133 -24
- package/src/components/form/form.store.js +123 -23
- package/src/components/form/form.view.yaml +137 -29
- package/src/components/pageOutline/pageOutline.handlers.js +1 -1
- package/src/components/popoverInput/popoverInput.handlers.js +99 -0
- package/src/components/popoverInput/popoverInput.store.js +48 -0
- package/src/components/popoverInput/popoverInput.view.yaml +55 -0
- package/src/components/select/select.handlers.js +2 -5
- package/src/components/select/select.view.yaml +3 -3
- package/src/components/sidebar/sidebar.view.yaml +1 -1
- package/src/components/sliderInput/sliderInput.handlers.js +24 -0
- package/src/components/sliderInput/sliderInput.store.js +17 -0
- package/src/components/sliderInput/sliderInput.view.yaml +42 -0
- package/src/components/table/table.handlers.js +1 -1
- package/src/components/tabs/tabs.handlers.js +10 -0
- package/src/components/tabs/tabs.store.js +29 -0
- package/src/components/tabs/tabs.view.yaml +64 -0
- package/src/components/waveform/waveform.handlers.js +92 -0
- package/src/components/waveform/waveform.store.js +17 -0
- package/src/components/waveform/waveform.view.yaml +38 -0
- package/src/entry-iife-layout.js +3 -0
- package/src/entry-iife-ui.js +4 -0
- package/src/index.js +5 -1
- package/src/primitives/dialog.js +208 -0
- package/src/primitives/input.js +32 -11
- package/src/primitives/popover.js +275 -0
- package/src/primitives/slider.js +8 -9
- package/src/styles/viewStyles.js +1 -0
- package/src/components/dialog/dialog.handlers.js +0 -5
- package/src/components/dialog/dialog.store.js +0 -25
- package/src/components/dialog/dialog.view.yaml +0 -44
- package/src/components/popover/popover.handlers.js +0 -5
- package/src/components/popover/popover.store.js +0 -12
- package/src/components/popover/popover.view.yaml +0 -57
|
@@ -8,6 +8,8 @@ propsSchema:
|
|
|
8
8
|
properties:
|
|
9
9
|
defaultValues:
|
|
10
10
|
type: object
|
|
11
|
+
context:
|
|
12
|
+
type: object
|
|
11
13
|
form:
|
|
12
14
|
type: object
|
|
13
15
|
properties:
|
|
@@ -21,7 +23,7 @@ propsSchema:
|
|
|
21
23
|
anyOf:
|
|
22
24
|
- type: object
|
|
23
25
|
properties:
|
|
24
|
-
|
|
26
|
+
name:
|
|
25
27
|
type: string
|
|
26
28
|
label:
|
|
27
29
|
type: string
|
|
@@ -32,13 +34,13 @@ propsSchema:
|
|
|
32
34
|
placeholder:
|
|
33
35
|
type: string
|
|
34
36
|
required:
|
|
35
|
-
-
|
|
37
|
+
- name
|
|
36
38
|
- label
|
|
37
39
|
- inputType
|
|
38
40
|
additionalProperties: false
|
|
39
41
|
- type: object
|
|
40
42
|
properties:
|
|
41
|
-
|
|
43
|
+
name:
|
|
42
44
|
type: string
|
|
43
45
|
label:
|
|
44
46
|
type: string
|
|
@@ -64,14 +66,14 @@ propsSchema:
|
|
|
64
66
|
- label
|
|
65
67
|
- value
|
|
66
68
|
required:
|
|
67
|
-
-
|
|
69
|
+
- name
|
|
68
70
|
- label
|
|
69
71
|
- inputType
|
|
70
72
|
- options
|
|
71
73
|
additionalProperties: false
|
|
72
74
|
- type: object
|
|
73
75
|
properties:
|
|
74
|
-
|
|
76
|
+
name:
|
|
75
77
|
type: string
|
|
76
78
|
label:
|
|
77
79
|
type: string
|
|
@@ -82,13 +84,13 @@ propsSchema:
|
|
|
82
84
|
value:
|
|
83
85
|
type: string
|
|
84
86
|
required:
|
|
85
|
-
-
|
|
87
|
+
- name
|
|
86
88
|
- label
|
|
87
89
|
- inputType
|
|
88
90
|
additionalProperties: false
|
|
89
91
|
- type: object
|
|
90
92
|
properties:
|
|
91
|
-
|
|
93
|
+
name:
|
|
92
94
|
type: string
|
|
93
95
|
label:
|
|
94
96
|
type: string
|
|
@@ -105,7 +107,76 @@ propsSchema:
|
|
|
105
107
|
value:
|
|
106
108
|
type: number
|
|
107
109
|
required:
|
|
108
|
-
-
|
|
110
|
+
- name
|
|
111
|
+
- label
|
|
112
|
+
- inputType
|
|
113
|
+
additionalProperties: false
|
|
114
|
+
- type: object
|
|
115
|
+
properties:
|
|
116
|
+
name:
|
|
117
|
+
type: string
|
|
118
|
+
label:
|
|
119
|
+
type: string
|
|
120
|
+
description:
|
|
121
|
+
type: string
|
|
122
|
+
inputType:
|
|
123
|
+
const: slider-input
|
|
124
|
+
min:
|
|
125
|
+
type: number
|
|
126
|
+
max:
|
|
127
|
+
type: number
|
|
128
|
+
step:
|
|
129
|
+
type: number
|
|
130
|
+
value:
|
|
131
|
+
type: number
|
|
132
|
+
required:
|
|
133
|
+
- name
|
|
134
|
+
- label
|
|
135
|
+
- inputType
|
|
136
|
+
additionalProperties: false
|
|
137
|
+
- type: object
|
|
138
|
+
properties:
|
|
139
|
+
name:
|
|
140
|
+
type: string
|
|
141
|
+
label:
|
|
142
|
+
type: string
|
|
143
|
+
description:
|
|
144
|
+
type: string
|
|
145
|
+
inputType:
|
|
146
|
+
const: image
|
|
147
|
+
width:
|
|
148
|
+
type: number
|
|
149
|
+
height:
|
|
150
|
+
type: number
|
|
151
|
+
placeholder:
|
|
152
|
+
type: string
|
|
153
|
+
required:
|
|
154
|
+
- name
|
|
155
|
+
- label
|
|
156
|
+
- inputType
|
|
157
|
+
additionalProperties: false
|
|
158
|
+
- type: object
|
|
159
|
+
properties:
|
|
160
|
+
name:
|
|
161
|
+
type: string
|
|
162
|
+
label:
|
|
163
|
+
type: string
|
|
164
|
+
description:
|
|
165
|
+
type: string
|
|
166
|
+
inputType:
|
|
167
|
+
const: waveform
|
|
168
|
+
width:
|
|
169
|
+
type: number
|
|
170
|
+
height:
|
|
171
|
+
type: number
|
|
172
|
+
placeholder:
|
|
173
|
+
type: string
|
|
174
|
+
defaultValue:
|
|
175
|
+
type: object
|
|
176
|
+
waveformData:
|
|
177
|
+
type: object
|
|
178
|
+
required:
|
|
179
|
+
- name
|
|
109
180
|
- label
|
|
110
181
|
- inputType
|
|
111
182
|
additionalProperties: false
|
|
@@ -146,30 +217,67 @@ refs:
|
|
|
146
217
|
eventListeners:
|
|
147
218
|
slider-change:
|
|
148
219
|
handler: handleSliderChange
|
|
220
|
+
slider-input-*:
|
|
221
|
+
eventListeners:
|
|
222
|
+
slider-input-value-change:
|
|
223
|
+
handler: handleSliderInputChange
|
|
224
|
+
image-*:
|
|
225
|
+
eventListeners:
|
|
226
|
+
click:
|
|
227
|
+
handler: handleImageClick
|
|
228
|
+
contextmenu:
|
|
229
|
+
handler: handleImageClick
|
|
230
|
+
waveform-*:
|
|
231
|
+
eventListeners:
|
|
232
|
+
click:
|
|
233
|
+
handler: handleWaveformClick
|
|
234
|
+
contextmenu:
|
|
235
|
+
handler: handleWaveformClick
|
|
236
|
+
popover-input-*:
|
|
237
|
+
eventListeners:
|
|
238
|
+
input-change:
|
|
239
|
+
handler: handlePopoverInputChange
|
|
149
240
|
|
|
150
241
|
events:
|
|
151
242
|
form-change: {}
|
|
243
|
+
extra-event: {}
|
|
152
244
|
|
|
153
245
|
template:
|
|
154
246
|
- rtgl-view w=f h=f p=md g=lg ${containerAttrString}:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
247
|
+
- rtgl-view g=sm w=f:
|
|
248
|
+
- rtgl-text s=lg: ${title}
|
|
249
|
+
- rtgl-text c=mu-fg: ${description}
|
|
250
|
+
- rtgl-view g=lg w=f:
|
|
251
|
+
- $for field, i in fields:
|
|
252
|
+
- rtgl-view g=md w=f:
|
|
253
|
+
- rtgl-view g=sm:
|
|
254
|
+
- rtgl-text: ${field.label}
|
|
255
|
+
- rtgl-text s=sm c=mu-fg: ${field.description}
|
|
256
|
+
- $if field.inputType == "read-only-text":
|
|
257
|
+
- rtgl-text s=sm: ${field.defaultValue}
|
|
258
|
+
- $if field.inputType == "inputText":
|
|
259
|
+
- rtgl-input#input-${field.name} w=f placeholder=${field.placeholder} value=${field.defaultValue}:
|
|
260
|
+
- $if field.inputType == "popover-input":
|
|
261
|
+
- rtgl-popover-input#popover-input-${field.name} label="${field.label}" .defaultValue=fields[${i}].defaultValue:
|
|
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:
|
|
264
|
+
- $if field.inputType == "colorPicker":
|
|
265
|
+
- rtgl-color-picker#colorpicker-${field.name} value=${field.defaultValue}:
|
|
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}:
|
|
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}:
|
|
270
|
+
- $if field.inputType == "image" && field.imageSrc:
|
|
271
|
+
- rtgl-image#image-${field.name} src=${field.imageSrc} w=${field.width} h=${field.height} cur=p:
|
|
272
|
+
- $if field.inputType == "image" && !field.imageSrc:
|
|
273
|
+
- rtgl-view#image-${field.name} w=${field.width} h=${field.height} bc=ac bw=sm ah=c av=c cur=p p=md:
|
|
274
|
+
- rtgl-text c=mu-fg ta=c: ${field.placeholderText}
|
|
275
|
+
- $if field.inputType == "waveform" && field.waveformData:
|
|
276
|
+
- rtgl-waveform#waveform-${field.name} .waveformData=fields[${i}].waveformData w=${field.width} h=${field.height} cur=p:
|
|
277
|
+
- $if field.inputType == "waveform" && !field.waveformData:
|
|
278
|
+
- rtgl-view#waveform-${field.name} w=${field.width} h=${field.height} bc=ac bw=sm ah=c av=c cur=p p=md:
|
|
279
|
+
- rtgl-text c=mu-fg ta=c: ${field.placeholder}
|
|
280
|
+
- rtgl-view g=sm w=f:
|
|
281
|
+
- rtgl-view d=h ah=e g=sm w=f:
|
|
282
|
+
- $for button, i in actions.buttons:
|
|
283
|
+
- rtgl-button#action-${button.id}: ${button.content}
|
|
@@ -57,7 +57,7 @@ const startListening = (contentContainer, deps) => {
|
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
export const
|
|
60
|
+
export const handleBeforeMount = (deps) => {
|
|
61
61
|
const { attrs } = deps;
|
|
62
62
|
requestAnimationFrame(() => {
|
|
63
63
|
const targetElement = document.getElementById(attrs['target-id'])
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export const handleBeforeMount = (deps) => {
|
|
2
|
+
const { store, props } = deps;
|
|
3
|
+
|
|
4
|
+
if (props.value !== undefined || props.defaultValue !== undefined) {
|
|
5
|
+
store.setValue(props.value || props.defaultValue || '');
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const handleOnUpdate = (changes, deps) => {
|
|
10
|
+
const { oldProps, newProps} = changes
|
|
11
|
+
const { store, props, render } = deps;
|
|
12
|
+
|
|
13
|
+
if (oldProps.defaultValue !== newProps.defaultValue) {
|
|
14
|
+
store.setValue(props.defaultValue || '');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
render();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const handleTextClick = (e, deps) => {
|
|
21
|
+
const { store, render, getRefIds, attrs } = deps;
|
|
22
|
+
|
|
23
|
+
const value = store.selectValue();
|
|
24
|
+
store.setTempValue(value)
|
|
25
|
+
|
|
26
|
+
store.openPopover({
|
|
27
|
+
position: {
|
|
28
|
+
x: e.currentTarget.getBoundingClientRect().left,
|
|
29
|
+
y: e.currentTarget.getBoundingClientRect().bottom,
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const { input } = getRefIds();
|
|
34
|
+
input.elm.value = value;
|
|
35
|
+
render();
|
|
36
|
+
|
|
37
|
+
if (attrs['auto-focus']) {
|
|
38
|
+
setTimeout(() => {
|
|
39
|
+
input.elm.focus();
|
|
40
|
+
}, 50)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const handlePopoverClose = (e, deps) => {
|
|
45
|
+
const { store, render } = deps;
|
|
46
|
+
store.closePopover();
|
|
47
|
+
render();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const handleInputChange = (e, deps) => {
|
|
51
|
+
const { store, render, dispatchEvent } = deps;
|
|
52
|
+
const value = e.detail.value;
|
|
53
|
+
|
|
54
|
+
store.setTempValue(value);
|
|
55
|
+
|
|
56
|
+
dispatchEvent(new CustomEvent('temp-input-change', {
|
|
57
|
+
detail: { value },
|
|
58
|
+
bubbles: true
|
|
59
|
+
}));
|
|
60
|
+
|
|
61
|
+
render();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const handleSubmitClick = (e, deps) => {
|
|
65
|
+
const { store, render, dispatchEvent, getRefIds } = deps;
|
|
66
|
+
const { input } = getRefIds()
|
|
67
|
+
const value = input.elm.value;
|
|
68
|
+
|
|
69
|
+
store.setValue(value)
|
|
70
|
+
store.closePopover();
|
|
71
|
+
|
|
72
|
+
dispatchEvent(new CustomEvent('input-change', {
|
|
73
|
+
detail: { value },
|
|
74
|
+
bubbles: true
|
|
75
|
+
}));
|
|
76
|
+
|
|
77
|
+
render();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const handleInputKeydown = (e, deps) => {
|
|
81
|
+
const { store, render, dispatchEvent, getRefIds } = deps;
|
|
82
|
+
|
|
83
|
+
if (e.key === 'Enter') {
|
|
84
|
+
const { input } = getRefIds()
|
|
85
|
+
const value = input.elm.value;
|
|
86
|
+
|
|
87
|
+
store.closePopover();
|
|
88
|
+
// Dispatch custom event
|
|
89
|
+
dispatchEvent(new CustomEvent('input-change', {
|
|
90
|
+
detail: { value },
|
|
91
|
+
bubbles: true
|
|
92
|
+
}));
|
|
93
|
+
|
|
94
|
+
render();
|
|
95
|
+
} else if (e.key === 'Escape') {
|
|
96
|
+
store.closePopover();
|
|
97
|
+
render();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export const INITIAL_STATE = Object.freeze({
|
|
2
|
+
isOpen: false,
|
|
3
|
+
position: {
|
|
4
|
+
x: 0,
|
|
5
|
+
y: 0,
|
|
6
|
+
},
|
|
7
|
+
value: '',
|
|
8
|
+
tempValue: '',
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const toViewData = ({ attrs, state, props }) => {
|
|
12
|
+
// Use state's current value if it has been modified, otherwise use props
|
|
13
|
+
const value = state.value || '-';
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
isOpen: state.isOpen,
|
|
17
|
+
position: state.position,
|
|
18
|
+
value: value ?? '-',
|
|
19
|
+
tempValue: state.tempValue,
|
|
20
|
+
placeholder: props.placeholder ?? '',
|
|
21
|
+
label: attrs.label,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const setTempValue = (state, value) => {
|
|
26
|
+
state.tempValue = value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const openPopover = (state, payload) => {
|
|
30
|
+
const { position } = payload;
|
|
31
|
+
state.position = position;
|
|
32
|
+
state.isOpen = true;
|
|
33
|
+
// Reset the current value to match the display value when opening
|
|
34
|
+
state.hasUnsavedChanges = false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const closePopover = (state) => {
|
|
38
|
+
state.isOpen = false;
|
|
39
|
+
state.tempValue = '';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const setValue = (state, value) => {
|
|
43
|
+
state.value = value;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const selectValue = ({ state }) => {
|
|
47
|
+
return state.value;
|
|
48
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
elementName: rtgl-popover-input
|
|
2
|
+
|
|
3
|
+
viewDataSchema:
|
|
4
|
+
type: object
|
|
5
|
+
|
|
6
|
+
attrsSchema:
|
|
7
|
+
type: object
|
|
8
|
+
properties:
|
|
9
|
+
auto-focus:
|
|
10
|
+
type: boolean
|
|
11
|
+
|
|
12
|
+
propsSchema:
|
|
13
|
+
type: object
|
|
14
|
+
properties:
|
|
15
|
+
value:
|
|
16
|
+
type: string
|
|
17
|
+
defaultValue:
|
|
18
|
+
type: string
|
|
19
|
+
placeholder:
|
|
20
|
+
type: string
|
|
21
|
+
onChange:
|
|
22
|
+
type: function
|
|
23
|
+
|
|
24
|
+
refs:
|
|
25
|
+
text-display:
|
|
26
|
+
eventListeners:
|
|
27
|
+
click:
|
|
28
|
+
handler: handleTextClick
|
|
29
|
+
popover:
|
|
30
|
+
eventListeners:
|
|
31
|
+
close:
|
|
32
|
+
handler: handlePopoverClose
|
|
33
|
+
input:
|
|
34
|
+
eventListeners:
|
|
35
|
+
input-change:
|
|
36
|
+
handler: handleInputChange
|
|
37
|
+
keydown:
|
|
38
|
+
handler: handleInputKeydown
|
|
39
|
+
submit:
|
|
40
|
+
eventListeners:
|
|
41
|
+
click:
|
|
42
|
+
handler: handleSubmitClick
|
|
43
|
+
|
|
44
|
+
events:
|
|
45
|
+
input-change: {}
|
|
46
|
+
|
|
47
|
+
template:
|
|
48
|
+
- rtgl-view#text-display w=f cur=p:
|
|
49
|
+
- rtgl-text: ${value}
|
|
50
|
+
- rtgl-popover#popover ?open=${isOpen} x=${position.x} y=${position.y}:
|
|
51
|
+
- rtgl-view g=md w=240 slot=content bgc=background br=md:
|
|
52
|
+
- rtgl-text: ${label}
|
|
53
|
+
- rtgl-input#input w=f placeholder=${placeholder}:
|
|
54
|
+
- rtgl-view w=f ah=e:
|
|
55
|
+
- rtgl-button#submit: Submit
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
|
|
2
|
-
export const
|
|
2
|
+
export const handleBeforeMount = (deps) => {
|
|
3
3
|
const { store, props, render } = deps;
|
|
4
4
|
|
|
5
5
|
if (props.selectedValue !== null && props.selectedValue !== undefined && props.options) {
|
|
6
6
|
const selectedOption = props.options.find(opt => opt.value === props.selectedValue);
|
|
7
7
|
if (selectedOption) {
|
|
8
|
-
store.
|
|
9
|
-
state.selectedValue = selectedOption.value;
|
|
10
|
-
state.selectedLabel = selectedOption.label;
|
|
11
|
-
});
|
|
8
|
+
store.updateSelectOption(selectedOption);
|
|
12
9
|
render();
|
|
13
10
|
}
|
|
14
11
|
}
|
|
@@ -31,7 +31,7 @@ refs:
|
|
|
31
31
|
handler: handleButtonClick
|
|
32
32
|
popover:
|
|
33
33
|
eventListeners:
|
|
34
|
-
|
|
34
|
+
close:
|
|
35
35
|
handler: handleClickOptionsPopoverOverlay
|
|
36
36
|
option-*:
|
|
37
37
|
eventListeners:
|
|
@@ -43,8 +43,8 @@ events: {}
|
|
|
43
43
|
template:
|
|
44
44
|
- rtgl-button#select-button v=ol:
|
|
45
45
|
- ${selectedLabel}
|
|
46
|
-
- rtgl-popover#popover
|
|
47
|
-
- rtgl-view wh=300 g=xs slot=content bgc=background br=md:
|
|
46
|
+
- rtgl-popover#popover ?open=${isOpen} x=${position.x} y=${position.y}:
|
|
47
|
+
- rtgl-view wh=300 g=xs slot=content bgc=background br=md sv=true:
|
|
48
48
|
- $for option, i in options:
|
|
49
49
|
- rtgl-view#option-${i} w=f h-bgc=ac ph=lg pv=md cur=p br=md bgc=${option.bgc}:
|
|
50
50
|
- rtgl-text: ${option.label}
|
|
@@ -174,7 +174,7 @@ template:
|
|
|
174
174
|
$else:
|
|
175
175
|
- rtgl-view mt=md h=1 bgc=mu-bg:
|
|
176
176
|
$else:
|
|
177
|
-
- rtgl-view#item-${item.id} ${item.hrefAttr} h=${itemHeight} av=c ${itemAlignAttr} ph=${itemPadding} w=${itemWidth} h-bgc=${item.itemHoverBgc} br=lg bgc=${item.itemBgc} cur=p
|
|
177
|
+
- rtgl-view#item-${item.id} ${item.hrefAttr} h=${itemHeight} av=c ${itemAlignAttr} ph=${itemPadding} w=${itemWidth} h-bgc=${item.itemHoverBgc} br=lg bgc=${item.itemBgc} cur=p:
|
|
178
178
|
- $if item.icon:
|
|
179
179
|
- $if showLabels:
|
|
180
180
|
- rtgl-view d=h ah=${itemContentAlign} g=sm:
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const handleBeforeMount = (deps) => {
|
|
2
|
+
const { store, attrs } = deps;
|
|
3
|
+
store.setValue(attrs.defaultValue || 0);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export const handleValueChange = (e, deps) => {
|
|
7
|
+
const { store, render, dispatchEvent } = deps;
|
|
8
|
+
const newValue = Number(e.detail.value);
|
|
9
|
+
|
|
10
|
+
store.setValue(newValue);
|
|
11
|
+
|
|
12
|
+
// Re-render to sync slider and input
|
|
13
|
+
render();
|
|
14
|
+
|
|
15
|
+
// Dispatch event for external listeners
|
|
16
|
+
dispatchEvent(
|
|
17
|
+
new CustomEvent("slider-input-value-change", {
|
|
18
|
+
detail: {
|
|
19
|
+
value: newValue,
|
|
20
|
+
},
|
|
21
|
+
bubbles: true,
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
24
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const INITIAL_STATE = Object.freeze({
|
|
2
|
+
value: 0
|
|
3
|
+
});
|
|
4
|
+
|
|
5
|
+
export const toViewData = ({ state, attrs }) => {
|
|
6
|
+
return {
|
|
7
|
+
value: state.value,
|
|
8
|
+
w: attrs.w || '',
|
|
9
|
+
min: attrs.min || 0,
|
|
10
|
+
max: attrs.max || 100,
|
|
11
|
+
step: attrs.step || 1
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const setValue = (state, newValue) => {
|
|
16
|
+
state.value = newValue;
|
|
17
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
elementName: rtgl-slider-input
|
|
2
|
+
|
|
3
|
+
viewDataSchema:
|
|
4
|
+
type: object
|
|
5
|
+
|
|
6
|
+
attrsSchema:
|
|
7
|
+
type: object
|
|
8
|
+
properties:
|
|
9
|
+
defaultValue:
|
|
10
|
+
type: string
|
|
11
|
+
default: '0'
|
|
12
|
+
w:
|
|
13
|
+
type: string
|
|
14
|
+
default: ''
|
|
15
|
+
min:
|
|
16
|
+
type: string
|
|
17
|
+
default: '0'
|
|
18
|
+
max:
|
|
19
|
+
type: string
|
|
20
|
+
default: '100'
|
|
21
|
+
step:
|
|
22
|
+
type: string
|
|
23
|
+
default: '1'
|
|
24
|
+
|
|
25
|
+
refs:
|
|
26
|
+
input:
|
|
27
|
+
eventListeners:
|
|
28
|
+
input-change:
|
|
29
|
+
handler: handleValueChange
|
|
30
|
+
slider:
|
|
31
|
+
eventListeners:
|
|
32
|
+
slider-change:
|
|
33
|
+
handler: handleValueChange
|
|
34
|
+
|
|
35
|
+
events:
|
|
36
|
+
form-change: {}
|
|
37
|
+
|
|
38
|
+
template:
|
|
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}:
|
|
41
|
+
- rtgl-view w=84:
|
|
42
|
+
- rtgl-input#input w=f type=number min=${min} max=${max} step=${step} value=${value}:
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const INITIAL_STATE = Object.freeze({});
|
|
2
|
+
|
|
3
|
+
const blacklistedAttrs = ['id', 'class', 'style', 'slot'];
|
|
4
|
+
|
|
5
|
+
const stringifyAttrs = (attrs) => {
|
|
6
|
+
return Object.entries(attrs).filter(([key]) => !blacklistedAttrs.includes(key)).map(([key, value]) => `${key}=${value}`).join(' ');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const toViewData = ({ state, props, attrs }) => {
|
|
10
|
+
const containerAttrString = stringifyAttrs(attrs);
|
|
11
|
+
|
|
12
|
+
const items = props.items || [];
|
|
13
|
+
const selectedTab = attrs['selected-tab'];
|
|
14
|
+
|
|
15
|
+
// Mark selected tab with styling
|
|
16
|
+
const itemsWithSelection = items.map(item => ({
|
|
17
|
+
...item,
|
|
18
|
+
isSelected: item.id === selectedTab,
|
|
19
|
+
bgColor: item.id === selectedTab ? 'ac' : '',
|
|
20
|
+
borderColor: item.id === selectedTab ? '' : 'tr',
|
|
21
|
+
textColor: item.id === selectedTab ? '' : 'mu-fg'
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
containerAttrString,
|
|
26
|
+
items: itemsWithSelection,
|
|
27
|
+
selectedTab
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
elementName: rtgl-tabs
|
|
2
|
+
|
|
3
|
+
viewDataSchema:
|
|
4
|
+
type: object
|
|
5
|
+
properties:
|
|
6
|
+
containerAttrString:
|
|
7
|
+
type: string
|
|
8
|
+
items:
|
|
9
|
+
type: array
|
|
10
|
+
items:
|
|
11
|
+
type: object
|
|
12
|
+
properties:
|
|
13
|
+
label:
|
|
14
|
+
type: string
|
|
15
|
+
id:
|
|
16
|
+
type: string
|
|
17
|
+
isSelected:
|
|
18
|
+
type: boolean
|
|
19
|
+
bgColor:
|
|
20
|
+
type: string
|
|
21
|
+
textColor:
|
|
22
|
+
type: string
|
|
23
|
+
borderColor:
|
|
24
|
+
type: string
|
|
25
|
+
selectedTab:
|
|
26
|
+
type: string
|
|
27
|
+
|
|
28
|
+
propsSchema:
|
|
29
|
+
type: object
|
|
30
|
+
properties:
|
|
31
|
+
items:
|
|
32
|
+
type: array
|
|
33
|
+
items:
|
|
34
|
+
type: object
|
|
35
|
+
properties:
|
|
36
|
+
label:
|
|
37
|
+
type: string
|
|
38
|
+
id:
|
|
39
|
+
type: string
|
|
40
|
+
|
|
41
|
+
attrsSchema:
|
|
42
|
+
type: object
|
|
43
|
+
properties:
|
|
44
|
+
selected-tab:
|
|
45
|
+
type: string
|
|
46
|
+
|
|
47
|
+
refs:
|
|
48
|
+
tab-*:
|
|
49
|
+
eventListeners:
|
|
50
|
+
click:
|
|
51
|
+
handler: handleClickItem
|
|
52
|
+
|
|
53
|
+
events:
|
|
54
|
+
item-click:
|
|
55
|
+
type: object
|
|
56
|
+
properties:
|
|
57
|
+
id:
|
|
58
|
+
type: string
|
|
59
|
+
|
|
60
|
+
template:
|
|
61
|
+
- rtgl-view d=h g=sm bgc=mu p=sm br=lg ${containerAttrString}:
|
|
62
|
+
- $for item in items:
|
|
63
|
+
- rtgl-view#tab-${item.id} data-id=${item.id} cur=p bgc=${item.bgColor} bw=xs bc=${item.borderColor} pv=md ph=lg br=lg:
|
|
64
|
+
- rtgl-text s=sm c=${item.textColor}: "${item.label}"
|