poe-svelte-ui-lib 1.0.5 → 1.0.7
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/Accordion/Accordion.svelte +56 -34
- package/dist/Accordion/AccordionProps.svelte +76 -0
- package/dist/Accordion/AccordionProps.svelte.d.ts +10 -0
- package/dist/Button/Button.svelte +28 -34
- package/dist/Button/ButtonProps.svelte +113 -0
- package/dist/Button/ButtonProps.svelte.d.ts +10 -0
- package/dist/ColorPicker/ColorPicker.svelte +27 -14
- package/dist/ColorPicker/ColorPickerProps.svelte +71 -0
- package/dist/ColorPicker/ColorPickerProps.svelte.d.ts +10 -0
- package/dist/{FileAttach/FileAttach.svelte → FileAttach.svelte} +3 -11
- package/dist/{FileAttach/FileAttach.svelte.d.ts → FileAttach.svelte.d.ts} +1 -1
- package/dist/Graph/Graph.svelte +4 -6
- package/dist/Graph/GraphProps.svelte +41 -0
- package/dist/Graph/GraphProps.svelte.d.ts +10 -0
- package/dist/Input/Input.svelte +42 -48
- package/dist/Input/InputProps.svelte +205 -0
- package/dist/Input/InputProps.svelte.d.ts +10 -0
- package/dist/Modal.svelte +54 -0
- package/dist/Modal.svelte.d.ts +12 -0
- package/dist/ProgressBar/ProgressBar.svelte +23 -21
- package/dist/ProgressBar/ProgressBarProps.svelte +114 -0
- package/dist/ProgressBar/ProgressBarProps.svelte.d.ts +10 -0
- package/dist/Select/Select.svelte +38 -23
- package/dist/Select/SelectProps.svelte +216 -0
- package/dist/Select/SelectProps.svelte.d.ts +10 -0
- package/dist/Slider/Slider.svelte +74 -28
- package/dist/Slider/SliderProps.svelte +113 -0
- package/dist/Slider/SliderProps.svelte.d.ts +10 -0
- package/dist/Switch/Switch.svelte +22 -16
- package/dist/Switch/SwitchProps.svelte +99 -0
- package/dist/Switch/SwitchProps.svelte.d.ts +10 -0
- package/dist/Table/Table.svelte +58 -39
- package/dist/Table/Table.svelte.d.ts +1 -1
- package/dist/Table/TableProps.svelte +233 -0
- package/dist/Table/TableProps.svelte.d.ts +10 -0
- package/dist/TextField/TextField.svelte +18 -14
- package/dist/TextField/TextFieldProps.svelte +92 -0
- package/dist/TextField/TextFieldProps.svelte.d.ts +10 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/libIcons/ButtonAdd.svelte +5 -2
- package/dist/libIcons/ButtonDelete.svelte +1 -1
- package/dist/libIcons/CrossIcon.svelte +9 -0
- package/dist/libIcons/CrossIcon.svelte.d.ts +18 -0
- package/dist/libIcons/IconGripVerticalDual.svelte +12 -0
- package/dist/libIcons/IconGripVerticalDual.svelte.d.ts +18 -0
- package/dist/libIcons/IconGripVerticalLeft.svelte +9 -0
- package/dist/libIcons/IconGripVerticalLeft.svelte.d.ts +18 -0
- package/dist/libIcons/IconGripVerticalRight.svelte +9 -0
- package/dist/libIcons/IconGripVerticalRight.svelte.d.ts +18 -0
- package/dist/locales/i18n.d.ts +9 -0
- package/dist/locales/i18n.js +33 -0
- package/dist/locales/translations.d.ts +7 -0
- package/dist/locales/translations.js +93 -0
- package/dist/options.d.ts +18 -23
- package/dist/options.js +44 -33
- package/dist/types.d.ts +50 -91
- package/dist/types.js +13 -1
- package/package.json +10 -5
- package/dist/Loader.svelte +0 -12
- package/dist/Loader.svelte.d.ts +0 -5
- package/dist/MessageModal.svelte +0 -54
- package/dist/MessageModal.svelte.d.ts +0 -10
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
<!-- $lib/ElementsUI/Slider.svelte -->
|
|
2
2
|
<script lang="ts">
|
|
3
3
|
import type { ISliderProps } from '../types'
|
|
4
|
+
import IconGripVerticalLeft from '../libIcons/IconGripVerticalLeft.svelte'
|
|
5
|
+
import IconGripVerticalRight from '../libIcons/IconGripVerticalRight.svelte'
|
|
6
|
+
import IconGripVerticalDual from '../libIcons/IconGripVerticalDual.svelte'
|
|
7
|
+
import { twMerge } from 'tailwind-merge'
|
|
4
8
|
|
|
5
9
|
let {
|
|
6
|
-
id =
|
|
10
|
+
id = crypto.randomUUID(),
|
|
7
11
|
wrapperClass = '',
|
|
8
12
|
label = { name: '', class: '' },
|
|
9
13
|
type = 'single',
|
|
@@ -88,23 +92,23 @@
|
|
|
88
92
|
}
|
|
89
93
|
</script>
|
|
90
94
|
|
|
91
|
-
<div class={`relative flex w-full flex-col items-center gap-2
|
|
95
|
+
<div class={twMerge(`relative flex w-full flex-col items-center gap-2`, wrapperClass)}>
|
|
92
96
|
{#if label.name}
|
|
93
|
-
<h5 class={`w-full px-4 text-center
|
|
97
|
+
<h5 class={twMerge(`w-full px-4 text-center`, label.class)}>{label.name}</h5>
|
|
94
98
|
{/if}
|
|
95
99
|
|
|
96
100
|
<!-- Слайдер -->
|
|
97
|
-
<div class="relative flex h-
|
|
101
|
+
<div {id} class="relative flex h-8 w-full justify-center rounded-full {disabled ? 'cursor-not-allowed opacity-50' : ''}">
|
|
98
102
|
{#if isRange}
|
|
99
103
|
<!-- Трек и активная зона -->
|
|
100
104
|
<div
|
|
101
|
-
class={`absolute h-full w-full rounded bg-gray-
|
|
105
|
+
class={`absolute h-full w-full rounded-full bg-[var(--gray-color)] ${disabled ? '' : 'cursor-pointer'}`}
|
|
102
106
|
role="button"
|
|
103
107
|
tabindex={null}
|
|
104
108
|
onkeydown={null}
|
|
105
109
|
onclick={disabled ? undefined : handleTrackClick}
|
|
106
110
|
>
|
|
107
|
-
<div class="absolute h-full rounded" style={`left: ${lowerPosition}%; right: ${100 - upperPosition}
|
|
111
|
+
<div class="absolute h-full rounded-full bg-[var(--bg-color)]" style={`left: ${lowerPosition}%; right: ${100 - upperPosition}%;`}></div>
|
|
108
112
|
</div>
|
|
109
113
|
|
|
110
114
|
<!-- Ползунки -->
|
|
@@ -125,6 +129,12 @@
|
|
|
125
129
|
{disabled}
|
|
126
130
|
class={`absolute h-full w-full appearance-none bg-transparent ${activeThumb === 'lower' ? 'z-30' : 'z-20'}`}
|
|
127
131
|
/>
|
|
132
|
+
<div
|
|
133
|
+
class="pointer-events-none absolute z-40 rounded-full bg-[var(--field-color)]"
|
|
134
|
+
style={`left: calc(${lowerPosition}% + 0rem); top: 50%; transform: translateY(-50%)`}
|
|
135
|
+
>
|
|
136
|
+
<IconGripVerticalLeft />
|
|
137
|
+
</div>
|
|
128
138
|
|
|
129
139
|
<input
|
|
130
140
|
type="range"
|
|
@@ -143,16 +153,25 @@
|
|
|
143
153
|
{disabled}
|
|
144
154
|
class={`absolute h-full w-full appearance-none bg-transparent ${activeThumb === 'upper' ? 'z-30' : 'z-20'}`}
|
|
145
155
|
/>
|
|
156
|
+
<div
|
|
157
|
+
class="pointer-events-none absolute z-40 rounded-full bg-[var(--field-color)]"
|
|
158
|
+
style={`left: calc(${upperPosition}% - 2rem); top: 50%; transform: translateY(-50%)`}
|
|
159
|
+
>
|
|
160
|
+
<IconGripVerticalRight />
|
|
161
|
+
</div>
|
|
146
162
|
{:else}
|
|
147
163
|
<!-- Одиночный слайдер -->
|
|
148
164
|
<div
|
|
149
|
-
class={`absolute h-full w-full rounded bg-gray-
|
|
165
|
+
class={`absolute h-full w-full rounded-full bg-[var(--gray-color)] ${disabled ? '' : 'cursor-pointer'}`}
|
|
150
166
|
role="button"
|
|
151
167
|
tabindex={null}
|
|
152
168
|
onkeydown={null}
|
|
153
169
|
onclick={disabled ? undefined : handleTrackClick}
|
|
154
170
|
>
|
|
155
|
-
<div
|
|
171
|
+
<div
|
|
172
|
+
class="absolute h-full {singlePosition === 100 ? 'z-10 rounded-full' : 'z-10 rounded-l-full'}"
|
|
173
|
+
style={`width: ${singlePosition}%; background-color: var(--bg-color)`}
|
|
174
|
+
></div>
|
|
156
175
|
</div>
|
|
157
176
|
|
|
158
177
|
<input
|
|
@@ -168,8 +187,14 @@
|
|
|
168
187
|
}}
|
|
169
188
|
onmouseup={disabled ? undefined : () => onUpdate(singleValue)}
|
|
170
189
|
{disabled}
|
|
171
|
-
class="absolute z-
|
|
190
|
+
class="absolute z-20 h-full w-full appearance-none bg-transparent"
|
|
172
191
|
/>
|
|
192
|
+
<div
|
|
193
|
+
class="pointer-events-none absolute z-30 rounded-full bg-[var(--field-color)]"
|
|
194
|
+
style={`left: clamp(1rem, ${singlePosition}%, calc(100% - 1rem)); top: 50%; transform: translate(-50%, -50%)`}
|
|
195
|
+
>
|
|
196
|
+
<IconGripVerticalDual />
|
|
197
|
+
</div>
|
|
173
198
|
{/if}
|
|
174
199
|
</div>
|
|
175
200
|
|
|
@@ -177,7 +202,10 @@
|
|
|
177
202
|
<div class={`flex w-full ${isRange ? 'justify-between' : 'justify-center'} gap-2`}>
|
|
178
203
|
{#if isRange}
|
|
179
204
|
{#each ['lower', 'upper'] as type (type)}
|
|
180
|
-
<div
|
|
205
|
+
<div
|
|
206
|
+
class={`flex items-center justify-center gap-2 rounded-full px-2 ${disabled ? 'opacity-70' : ''}`}
|
|
207
|
+
style="background-color: var(--bg-color)"
|
|
208
|
+
>
|
|
181
209
|
<button
|
|
182
210
|
class="h-full w-4 {disabled ? '' : 'cursor-pointer'}"
|
|
183
211
|
onclick={disabled ? undefined : () => adjustValue(type as 'lower' | 'upper', 'decrement')}
|
|
@@ -194,7 +222,10 @@
|
|
|
194
222
|
</div>
|
|
195
223
|
{/each}
|
|
196
224
|
{:else}
|
|
197
|
-
<div
|
|
225
|
+
<div
|
|
226
|
+
class={`flex items-center justify-center gap-2 rounded-full px-2 ${disabled ? 'opacity-70' : ''}`}
|
|
227
|
+
style="background-color: var(--bg-color)"
|
|
228
|
+
>
|
|
198
229
|
<button
|
|
199
230
|
class="h-full w-4 {disabled ? '' : 'cursor-pointer'}"
|
|
200
231
|
onclick={disabled ? undefined : () => adjustValue('single', 'decrement')}
|
|
@@ -220,41 +251,56 @@
|
|
|
220
251
|
margin: 0;
|
|
221
252
|
padding: 0;
|
|
222
253
|
pointer-events: none;
|
|
254
|
+
outline: none;
|
|
223
255
|
}
|
|
224
256
|
|
|
225
|
-
|
|
226
|
-
cursor: auto;
|
|
227
|
-
}
|
|
228
|
-
|
|
257
|
+
/* Webkit thumb */
|
|
229
258
|
input[type='range']::-webkit-slider-thumb {
|
|
230
259
|
-webkit-appearance: none;
|
|
231
260
|
appearance: none;
|
|
232
|
-
width:
|
|
233
|
-
height:
|
|
261
|
+
width: 2rem;
|
|
262
|
+
height: 2rem;
|
|
234
263
|
border-radius: 50%;
|
|
235
|
-
background:
|
|
264
|
+
background: transparent;
|
|
236
265
|
cursor: pointer;
|
|
237
266
|
pointer-events: auto;
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
input[type='range']:disabled::-webkit-slider-thumb {
|
|
242
|
-
background: var(--gray-color);
|
|
267
|
+
border: none;
|
|
243
268
|
}
|
|
244
269
|
|
|
270
|
+
/* Firefox thumb */
|
|
245
271
|
input[type='range']::-moz-range-thumb {
|
|
246
|
-
width:
|
|
247
|
-
height:
|
|
272
|
+
width: 2rem;
|
|
273
|
+
height: 2rem;
|
|
248
274
|
border-radius: 50%;
|
|
249
|
-
background:
|
|
275
|
+
background: transparent;
|
|
250
276
|
cursor: pointer;
|
|
251
277
|
pointer-events: auto;
|
|
252
278
|
border: none;
|
|
253
|
-
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/* Webkit track */
|
|
282
|
+
input[type='range']::-webkit-slider-runnable-track {
|
|
283
|
+
width: 100%;
|
|
284
|
+
height: 100%;
|
|
285
|
+
background: transparent;
|
|
286
|
+
border-radius: 0;
|
|
287
|
+
border: none;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/* Firefox track */
|
|
291
|
+
input[type='range']::-moz-range-track {
|
|
292
|
+
width: 100%;
|
|
293
|
+
height: 100%;
|
|
294
|
+
background: transparent;
|
|
295
|
+
border-radius: 0;
|
|
296
|
+
border: none;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
input[type='range']:disabled::-webkit-slider-thumb {
|
|
300
|
+
cursor: not-allowed;
|
|
254
301
|
}
|
|
255
302
|
|
|
256
303
|
input[type='range']:disabled::-moz-range-thumb {
|
|
257
|
-
background: var(--gray-color);
|
|
258
304
|
cursor: not-allowed;
|
|
259
305
|
}
|
|
260
306
|
</style>
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
<!-- $lib/ElementsUI/SwitchProps.svelte -->
|
|
2
|
+
<script lang="ts">
|
|
3
|
+
import { getContext } from 'svelte'
|
|
4
|
+
import { t } from '../locales/i18n'
|
|
5
|
+
import { type UIComponent, type ISliderProps, updateProperty } from '../types'
|
|
6
|
+
import * as UI from '..'
|
|
7
|
+
import { optionsStore } from '../options'
|
|
8
|
+
|
|
9
|
+
const { component, onPropertyChange } = $props<{
|
|
10
|
+
component: UIComponent & { properties: Partial<ISliderProps> }
|
|
11
|
+
onPropertyChange: (value: string | object) => void
|
|
12
|
+
}>()
|
|
13
|
+
|
|
14
|
+
const DeviceVariables = getContext<{ value: string; name: string }[]>('DeviceVariables')
|
|
15
|
+
let VARIABLE_OPTIONS = $derived(
|
|
16
|
+
DeviceVariables && Array.isArray(DeviceVariables)
|
|
17
|
+
? DeviceVariables.map((variable) => ({
|
|
18
|
+
id: variable.name,
|
|
19
|
+
value: variable.value,
|
|
20
|
+
name: `${variable.value} | ${variable.name}`,
|
|
21
|
+
}))
|
|
22
|
+
: [],
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
const initialAlign = $derived(
|
|
26
|
+
$optionsStore.ALIGN_OPTIONS.find((a) =>
|
|
27
|
+
(a.value as string).includes(component.properties.label?.class?.split(' ').find((cls: string) => cls.startsWith('text-'))),
|
|
28
|
+
),
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
const initialColor = $derived(
|
|
32
|
+
$optionsStore.COLOR_OPTIONS.find((c) =>
|
|
33
|
+
(c.value as string).includes(component.properties.wrapperClass?.split(' ').find((cls: string) => cls.startsWith('bg-'))),
|
|
34
|
+
),
|
|
35
|
+
)
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
{#if component && component.properties}
|
|
39
|
+
<div class="relative flex flex-row items-start justify-center">
|
|
40
|
+
<div class="flex w-1/3 flex-col items-center px-2">
|
|
41
|
+
<UI.Select
|
|
42
|
+
label={{ name: $t('constructor.props.variable') }}
|
|
43
|
+
options={VARIABLE_OPTIONS}
|
|
44
|
+
value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id.value)}
|
|
45
|
+
onUpdate={(value) => {
|
|
46
|
+
updateProperty('id', value.value as string, component, onPropertyChange)
|
|
47
|
+
updateProperty('eventHandler.Variables', value.value as string, component, onPropertyChange)
|
|
48
|
+
}}
|
|
49
|
+
/>
|
|
50
|
+
<UI.Select
|
|
51
|
+
label={{ name: $t('constructor.props.action') }}
|
|
52
|
+
type="buttons"
|
|
53
|
+
value={$optionsStore.SHORT_ARGUMENT_OPTION.find((h) => h.value === component.properties.eventHandler.Argument)}
|
|
54
|
+
options={$optionsStore.SHORT_ARGUMENT_OPTION}
|
|
55
|
+
onUpdate={(option) => {
|
|
56
|
+
updateProperty('eventHandler.Argument', option.value as string, component, onPropertyChange)
|
|
57
|
+
}}
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
<div class="flex w-1/3 flex-col px-2">
|
|
61
|
+
<UI.Select
|
|
62
|
+
label={{ name: $t('constructor.props.type') }}
|
|
63
|
+
type="buttons"
|
|
64
|
+
value={$optionsStore.SLIDER_TYPE_OPTIONS.find((opt) => opt.value === (component.properties.type || 'single'))}
|
|
65
|
+
options={$optionsStore.SLIDER_TYPE_OPTIONS}
|
|
66
|
+
onUpdate={(type) => {
|
|
67
|
+
updateProperty('value', type.value === 'single' ? 5 : [2, 7], component, onPropertyChange)
|
|
68
|
+
updateProperty('type', type.value as string, component, onPropertyChange)
|
|
69
|
+
}}
|
|
70
|
+
/>
|
|
71
|
+
<UI.Input
|
|
72
|
+
label={{ name: $t('constructor.props.minnum') }}
|
|
73
|
+
value={component.properties.number.minNum as number}
|
|
74
|
+
type="number"
|
|
75
|
+
onUpdate={(value) => updateProperty('number.minNum', Number(value), component, onPropertyChange)}
|
|
76
|
+
/>
|
|
77
|
+
<UI.Input
|
|
78
|
+
label={{ name: $t('constructor.props.maxnum') }}
|
|
79
|
+
value={component.properties.number.maxNum as number}
|
|
80
|
+
type="number"
|
|
81
|
+
onUpdate={(value) => updateProperty('number.maxNum', Number(value), component, onPropertyChange)}
|
|
82
|
+
/>
|
|
83
|
+
<UI.Input
|
|
84
|
+
label={{ name: $t('constructor.props.step') }}
|
|
85
|
+
value={component.properties.number.step as number}
|
|
86
|
+
type="number"
|
|
87
|
+
onUpdate={(value) => updateProperty('number.step', Number(value), component, onPropertyChange)}
|
|
88
|
+
/>
|
|
89
|
+
</div>
|
|
90
|
+
<div class="flex w-1/3 flex-col px-2">
|
|
91
|
+
<UI.Input
|
|
92
|
+
label={{ name: $t('constructor.props.label') }}
|
|
93
|
+
value={component.properties.label.name}
|
|
94
|
+
onUpdate={(value) => updateProperty('label.name', value as string, component, onPropertyChange)}
|
|
95
|
+
/>
|
|
96
|
+
<UI.Select
|
|
97
|
+
label={{ name: $t('constructor.props.align') }}
|
|
98
|
+
type="buttons"
|
|
99
|
+
value={initialAlign}
|
|
100
|
+
options={$optionsStore.ALIGN_OPTIONS}
|
|
101
|
+
onUpdate={(option) => updateProperty('label.class', `${component.properties.label.class} ${option.value}`, component, onPropertyChange)}
|
|
102
|
+
/>
|
|
103
|
+
<UI.Select
|
|
104
|
+
wrapperClass="!h-14"
|
|
105
|
+
label={{ name: $t('constructor.props.colors') }}
|
|
106
|
+
type="buttons"
|
|
107
|
+
options={$optionsStore.COLOR_OPTIONS}
|
|
108
|
+
value={initialColor}
|
|
109
|
+
onUpdate={(option) => updateProperty('wrapperClass', `${component.properties.wrapperClass} ${option.value}`, component, onPropertyChange)}
|
|
110
|
+
/>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
{/if}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type UIComponent, type ISliderProps } from '../types';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
component: UIComponent & {
|
|
4
|
+
properties: Partial<ISliderProps>;
|
|
5
|
+
};
|
|
6
|
+
onPropertyChange: (value: string | object) => void;
|
|
7
|
+
};
|
|
8
|
+
declare const SliderProps: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
9
|
+
type SliderProps = ReturnType<typeof SliderProps>;
|
|
10
|
+
export default SliderProps;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
<!-- $lib/ElementsUI/Switch.svelte -->
|
|
2
2
|
<script lang="ts">
|
|
3
|
+
import { twMerge } from 'tailwind-merge'
|
|
3
4
|
import type { ISwitchProps } from '../types'
|
|
4
5
|
|
|
5
6
|
let {
|
|
6
|
-
id =
|
|
7
|
-
wrapperClass = '',
|
|
7
|
+
id = crypto.randomUUID(),
|
|
8
8
|
disabled = false,
|
|
9
|
-
|
|
9
|
+
wrapperClass = '',
|
|
10
|
+
label = { name: '', captionLeft: '', captionRight: '' },
|
|
10
11
|
height = '2rem',
|
|
11
12
|
value = $bindable(),
|
|
12
13
|
onChange = () => {},
|
|
@@ -15,7 +16,7 @@
|
|
|
15
16
|
const options = [1, 2]
|
|
16
17
|
let checked = $derived(value === options[1])
|
|
17
18
|
|
|
18
|
-
let knobTransform = $derived(checked ? `translateX(calc(${height}
|
|
19
|
+
let knobTransform = $derived(checked ? `translateX(calc(${height}))` : 'translateX(0)')
|
|
19
20
|
|
|
20
21
|
$effect(() => {
|
|
21
22
|
if (value === undefined || value === null) value = options[0]
|
|
@@ -43,14 +44,16 @@
|
|
|
43
44
|
)
|
|
44
45
|
</script>
|
|
45
46
|
|
|
46
|
-
<div class=
|
|
47
|
+
<div class={twMerge(`bg-blue relative flex w-full flex-col items-center justify-center`, wrapperClass)}>
|
|
47
48
|
{#if label.name}
|
|
48
|
-
<h5 class={`w-full px-4 text-center
|
|
49
|
+
<h5 class={`w-full px-4 text-center`}>{label.name}</h5>
|
|
49
50
|
{/if}
|
|
50
51
|
|
|
51
52
|
<div class="relative flex w-full grow items-center justify-center !bg-transparent">
|
|
52
|
-
<button
|
|
53
|
-
|
|
53
|
+
<button
|
|
54
|
+
class="mr-2 {disabled ? 'opacity-60' : 'cursor-pointer'}"
|
|
55
|
+
style="width: {maxCaptionWidth}; text-align: end;"
|
|
56
|
+
onclick={() => handleCaptionClick(1)}>{label.captionLeft}</button
|
|
54
57
|
>
|
|
55
58
|
<label
|
|
56
59
|
class="relative flex items-center justify-between rounded-full border-1
|
|
@@ -58,7 +61,7 @@
|
|
|
58
61
|
{disabled ? 'opacity-60' : ''}"
|
|
59
62
|
>
|
|
60
63
|
<input
|
|
61
|
-
|
|
64
|
+
{id}
|
|
62
65
|
type="checkbox"
|
|
63
66
|
class="absolute left-1/2 h-full w-full -translate-x-1/2 cursor-pointer appearance-none rounded-md"
|
|
64
67
|
bind:checked
|
|
@@ -66,19 +69,22 @@
|
|
|
66
69
|
onchange={handleToggle}
|
|
67
70
|
/>
|
|
68
71
|
<span
|
|
69
|
-
class="relative flex items-center rounded-full transition-all duration-250
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
class="relative flex items-center rounded-full transition-all duration-250
|
|
73
|
+
{checked ? '!bg-[var(--bg-color)]' : '!bg-[var(--gray-color)]'}
|
|
74
|
+
{disabled ? '' : 'cursor-pointer'}"
|
|
72
75
|
style="width: {`calc(${height} * 2)`}; height: {height};"
|
|
73
76
|
>
|
|
74
77
|
<span
|
|
75
|
-
class="absolute rounded-full bg-[var(--back-color)] transition-all duration-250
|
|
76
|
-
|
|
78
|
+
class="absolute rounded-full bg-[var(--back-color)] transition-all duration-250
|
|
79
|
+
{disabled ? 'opacity-60' : 'cursor-pointer'}"
|
|
80
|
+
style="width: {`calc(${height} * 0.75)`}; height: {`calc(${height} * 0.75)`}; margin: 0 {`calc(${height} * 0.1)`}; transform: {knobTransform};"
|
|
77
81
|
></span>
|
|
78
82
|
</span>
|
|
79
83
|
</label>
|
|
80
|
-
<button
|
|
81
|
-
|
|
84
|
+
<button
|
|
85
|
+
class="ml-2 {disabled ? 'opacity-60' : 'cursor-pointer'}"
|
|
86
|
+
style="width: {maxCaptionWidth}; text-align: start;"
|
|
87
|
+
onclick={() => handleCaptionClick(2)}>{label.captionRight}</button
|
|
82
88
|
>
|
|
83
89
|
</div>
|
|
84
90
|
</div>
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<!-- $lib/ElementsUI/SwitchProps.svelte -->
|
|
2
|
+
<script lang="ts">
|
|
3
|
+
import { getContext } from 'svelte'
|
|
4
|
+
import { t } from '../locales/i18n'
|
|
5
|
+
import { type UIComponent, type ISwitchProps, updateProperty, type ISelectOption } from '../types'
|
|
6
|
+
import * as UI from '..'
|
|
7
|
+
import { optionsStore } from '../options'
|
|
8
|
+
import { twMerge } from 'tailwind-merge'
|
|
9
|
+
|
|
10
|
+
const { component, onPropertyChange } = $props<{
|
|
11
|
+
component: UIComponent & { properties: Partial<ISwitchProps> }
|
|
12
|
+
onPropertyChange: (value: string | object) => void
|
|
13
|
+
}>()
|
|
14
|
+
|
|
15
|
+
const DeviceVariables = getContext<{ value: string; name: string }[]>('DeviceVariables')
|
|
16
|
+
let VARIABLE_OPTIONS = $derived(
|
|
17
|
+
DeviceVariables && Array.isArray(DeviceVariables)
|
|
18
|
+
? DeviceVariables.map((variable) => ({
|
|
19
|
+
id: variable.name,
|
|
20
|
+
value: variable.value,
|
|
21
|
+
name: `${variable.value} | ${variable.name}`,
|
|
22
|
+
}))
|
|
23
|
+
: [],
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
const initialColor = $derived(
|
|
27
|
+
$optionsStore.COLOR_OPTIONS.find((c) =>
|
|
28
|
+
(c.value as string).includes(component.properties.wrapperClass?.split(' ').find((cls: string) => cls.startsWith('bg-'))),
|
|
29
|
+
),
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
const initialAlign = $derived(
|
|
33
|
+
$optionsStore.ALIGN_OPTIONS.find((a) =>
|
|
34
|
+
(a.value as string).includes(component.properties.label?.class?.split(' ').find((cls: string) => cls.startsWith('text-'))),
|
|
35
|
+
),
|
|
36
|
+
)
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
{#if component && component.properties}
|
|
40
|
+
<div class="relative flex flex-row items-start justify-center">
|
|
41
|
+
<!-- Сообщение для отправки в ws по нажатию кнопки -->
|
|
42
|
+
<div class="flex w-1/3 flex-col items-center px-2">
|
|
43
|
+
<UI.Select
|
|
44
|
+
label={{ name: $t('constructor.props.variable') }}
|
|
45
|
+
options={VARIABLE_OPTIONS}
|
|
46
|
+
value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id.value)}
|
|
47
|
+
onUpdate={(value) => {
|
|
48
|
+
updateProperty('id', value.value as string, component, onPropertyChange)
|
|
49
|
+
updateProperty('eventHandler.Variables', value.value as string, component, onPropertyChange)
|
|
50
|
+
}}
|
|
51
|
+
/>
|
|
52
|
+
<UI.Select
|
|
53
|
+
label={{ name: $t('constructor.props.action') }}
|
|
54
|
+
type="buttons"
|
|
55
|
+
value={$optionsStore.SHORT_ARGUMENT_OPTION.find((h) => h.value === component.properties.eventHandler.Argument)}
|
|
56
|
+
options={$optionsStore.SHORT_ARGUMENT_OPTION}
|
|
57
|
+
onUpdate={(option) => {
|
|
58
|
+
updateProperty('eventHandler.Argument', option.value as string, component, onPropertyChange)
|
|
59
|
+
}}
|
|
60
|
+
/>
|
|
61
|
+
</div>
|
|
62
|
+
<div class="flex w-1/3 flex-col px-2">
|
|
63
|
+
<UI.Input
|
|
64
|
+
label={{ name: $t('constructor.props.caption.left') }}
|
|
65
|
+
value={component.properties.label.captionLeft}
|
|
66
|
+
type="text"
|
|
67
|
+
onUpdate={(value) => updateProperty('label.captionLeft', value as string, component, onPropertyChange)}
|
|
68
|
+
/>
|
|
69
|
+
<UI.Input
|
|
70
|
+
label={{ name: $t('constructor.props.caption.right') }}
|
|
71
|
+
value={component.properties.label.captionRight}
|
|
72
|
+
type="text"
|
|
73
|
+
onUpdate={(value) => updateProperty('label.captionRight', value as string, component, onPropertyChange)}
|
|
74
|
+
/>
|
|
75
|
+
<UI.Switch
|
|
76
|
+
wrapperClass="bg-blue"
|
|
77
|
+
label={{ name: $t('constructor.props.disabled') }}
|
|
78
|
+
value={component.properties.disabled ? 2 : 1}
|
|
79
|
+
onChange={(value) => updateProperty('disabled', value === 2, component, onPropertyChange)}
|
|
80
|
+
/>
|
|
81
|
+
</div>
|
|
82
|
+
<div class="flex w-1/3 flex-col px-2">
|
|
83
|
+
<UI.Input
|
|
84
|
+
label={{ name: $t('constructor.props.label') }}
|
|
85
|
+
value={component.properties.label.name}
|
|
86
|
+
type="text"
|
|
87
|
+
onUpdate={(value) => updateProperty('label.name', value as string, component, onPropertyChange)}
|
|
88
|
+
/>
|
|
89
|
+
<UI.Select
|
|
90
|
+
wrapperClass="!h-14"
|
|
91
|
+
label={{ name: $t('constructor.props.colors') }}
|
|
92
|
+
type="buttons"
|
|
93
|
+
options={$optionsStore.COLOR_OPTIONS.filter((option) => option.value !== 'bg-max')}
|
|
94
|
+
value={initialColor}
|
|
95
|
+
onUpdate={(option) => updateProperty('wrapperClass', `${component.properties.wrapperClass} ${option.value}`, component, onPropertyChange)}
|
|
96
|
+
/>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
{/if}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type UIComponent, type ISwitchProps } from '../types';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
component: UIComponent & {
|
|
4
|
+
properties: Partial<ISwitchProps>;
|
|
5
|
+
};
|
|
6
|
+
onPropertyChange: (value: string | object) => void;
|
|
7
|
+
};
|
|
8
|
+
declare const SwitchProps: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
9
|
+
type SwitchProps = ReturnType<typeof SwitchProps>;
|
|
10
|
+
export default SwitchProps;
|