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
|
@@ -0,0 +1,114 @@
|
|
|
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 IProgressBarProps, updateProperty } from '../types'
|
|
6
|
+
import * as UI from '..'
|
|
7
|
+
import { optionsStore } from '../options'
|
|
8
|
+
|
|
9
|
+
const { component, onPropertyChange } = $props<{
|
|
10
|
+
component: UIComponent & { properties: Partial<IProgressBarProps> }
|
|
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
|
+
}}
|
|
48
|
+
/>
|
|
49
|
+
</div>
|
|
50
|
+
<div class="flex w-1/3 flex-col px-2">
|
|
51
|
+
<UI.Input
|
|
52
|
+
label={{ name: $t('constructor.props.min') }}
|
|
53
|
+
value={component.properties.number.minNum as number}
|
|
54
|
+
type="number"
|
|
55
|
+
onUpdate={(value) => {
|
|
56
|
+
// if ((value as number) >= component.properties.number.maxNum) {
|
|
57
|
+
// value = component.properties.number.maxNum - 1
|
|
58
|
+
// }
|
|
59
|
+
updateProperty('number.minNum', Number(value), component, onPropertyChange)
|
|
60
|
+
updateProperty(
|
|
61
|
+
'value',
|
|
62
|
+
component.properties.number.minNum + (component.properties.number.maxNum - component.properties.number.minNum) / 3,
|
|
63
|
+
component,
|
|
64
|
+
onPropertyChange,
|
|
65
|
+
)
|
|
66
|
+
}}
|
|
67
|
+
/>
|
|
68
|
+
<UI.Input
|
|
69
|
+
label={{ name: $t('constructor.props.max') }}
|
|
70
|
+
value={component.properties.number.maxNum as number}
|
|
71
|
+
type="number"
|
|
72
|
+
onUpdate={(value) => {
|
|
73
|
+
// if ((value as number) <= component.properties.number.minNum) {
|
|
74
|
+
// value = component.properties.number.minNum + 1
|
|
75
|
+
// }
|
|
76
|
+
updateProperty('number.maxNum', Number(value), component, onPropertyChange)
|
|
77
|
+
updateProperty(
|
|
78
|
+
'value',
|
|
79
|
+
component.properties.number.minNum + (component.properties.number.maxNum - component.properties.number.minNum) / 3,
|
|
80
|
+
component,
|
|
81
|
+
onPropertyChange,
|
|
82
|
+
)
|
|
83
|
+
}}
|
|
84
|
+
/>
|
|
85
|
+
<UI.Input
|
|
86
|
+
label={{ name: $t('constructor.props.units') }}
|
|
87
|
+
value={component.properties.number.units}
|
|
88
|
+
onUpdate={(value) => updateProperty('number.units', value, component, onPropertyChange)}
|
|
89
|
+
/>
|
|
90
|
+
</div>
|
|
91
|
+
<div class="flex w-1/3 flex-col px-2">
|
|
92
|
+
<UI.Input
|
|
93
|
+
label={{ name: $t('constructor.props.label') }}
|
|
94
|
+
value={component.properties.label.name}
|
|
95
|
+
onUpdate={(value) => updateProperty('label.name', value as string, component, onPropertyChange)}
|
|
96
|
+
/>
|
|
97
|
+
<UI.Select
|
|
98
|
+
label={{ name: $t('constructor.props.align') }}
|
|
99
|
+
type="buttons"
|
|
100
|
+
value={initialAlign}
|
|
101
|
+
options={$optionsStore.ALIGN_OPTIONS}
|
|
102
|
+
onUpdate={(option) => updateProperty('label.class', `${component.properties.label.class} ${option.value}`, component, onPropertyChange)}
|
|
103
|
+
/>
|
|
104
|
+
<UI.Select
|
|
105
|
+
wrapperClass="!h-14"
|
|
106
|
+
label={{ name: $t('constructor.props.colors') }}
|
|
107
|
+
type="buttons"
|
|
108
|
+
options={$optionsStore.COLOR_OPTIONS}
|
|
109
|
+
value={initialColor}
|
|
110
|
+
onUpdate={(option) => updateProperty('wrapperClass', `${component.properties.wrapperClass} ${option.value}`, component, onPropertyChange)}
|
|
111
|
+
/>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
{/if}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type UIComponent, type IProgressBarProps } from '../types';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
component: UIComponent & {
|
|
4
|
+
properties: Partial<IProgressBarProps>;
|
|
5
|
+
};
|
|
6
|
+
onPropertyChange: (value: string | object) => void;
|
|
7
|
+
};
|
|
8
|
+
declare const ProgressBarProps: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
9
|
+
type ProgressBarProps = ReturnType<typeof ProgressBarProps>;
|
|
10
|
+
export default ProgressBarProps;
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
import { slide } from 'svelte/transition'
|
|
4
4
|
import { onMount } from 'svelte'
|
|
5
5
|
import type { ISelectOption, ISelectProps } from '../types'
|
|
6
|
+
import { twMerge } from 'tailwind-merge'
|
|
7
|
+
import { t } from '../locales/i18n'
|
|
6
8
|
|
|
7
9
|
let isDropdownOpen = $state(false)
|
|
8
10
|
let dropdownElement: HTMLDivElement
|
|
@@ -11,14 +13,13 @@
|
|
|
11
13
|
let filteredOptions = $state<ISelectOption<T>[]>([])
|
|
12
14
|
|
|
13
15
|
let {
|
|
14
|
-
id =
|
|
15
|
-
wrapperClass = '
|
|
16
|
+
id = crypto.randomUUID(),
|
|
17
|
+
wrapperClass = '',
|
|
16
18
|
disabled = false,
|
|
17
19
|
label = { name: '', class: '' },
|
|
18
20
|
type = 'select',
|
|
19
21
|
value = $bindable(),
|
|
20
22
|
options = [],
|
|
21
|
-
placeholder= '---',
|
|
22
23
|
onUpdate,
|
|
23
24
|
}: ISelectProps<T> = $props()
|
|
24
25
|
|
|
@@ -86,23 +87,26 @@
|
|
|
86
87
|
}
|
|
87
88
|
</script>
|
|
88
89
|
|
|
89
|
-
<div class={`bg-max relative flex w-full flex-col items-center
|
|
90
|
+
<div class={twMerge(`bg-max relative flex w-full flex-col items-center `, wrapperClass)} bind:this={dropdownElement}>
|
|
90
91
|
{#if label.name}
|
|
91
|
-
<h5 class={`w-full px-4
|
|
92
|
+
<h5 class={twMerge(`w-full px-4`, label.class)}>{label.name}</h5>
|
|
92
93
|
{/if}
|
|
93
94
|
{#if type === 'select'}
|
|
94
95
|
<button
|
|
95
|
-
|
|
96
|
+
{id}
|
|
96
97
|
value={value?.value ? String(value.value) : ''}
|
|
97
|
-
class=
|
|
98
|
-
|
|
98
|
+
class={twMerge(
|
|
99
|
+
`w-full rounded-2xl border border-[var(--border-color)] p-1 text-center duration-250
|
|
100
|
+
${disabled ? 'opacity-50' : 'cursor-pointer hover:shadow-lg'}`,
|
|
101
|
+
value?.class,
|
|
102
|
+
)}
|
|
99
103
|
style="background: color-mix(in srgb, var(--bg-color), var(--back-color) 70%);"
|
|
100
104
|
onclick={toggleDropdown}
|
|
101
105
|
aria-haspopup="true"
|
|
102
106
|
aria-expanded={isDropdownOpen}
|
|
103
107
|
{disabled}
|
|
104
108
|
>
|
|
105
|
-
{value?.name ||
|
|
109
|
+
{value?.name || $t('common.select_tag')}
|
|
106
110
|
</button>
|
|
107
111
|
|
|
108
112
|
{#if isDropdownOpen}
|
|
@@ -115,8 +119,11 @@
|
|
|
115
119
|
<button
|
|
116
120
|
id={option.id}
|
|
117
121
|
value={option?.value ? String(option.value) : ''}
|
|
118
|
-
class=
|
|
119
|
-
|
|
122
|
+
class={twMerge(
|
|
123
|
+
`flex h-full w-full cursor-pointer items-center justify-center p-1 duration-250 hover:!bg-[var(--field-color)]
|
|
124
|
+
${index === options.length - 1 ? 'rounded-b-2xl' : ''} `,
|
|
125
|
+
option.class,
|
|
126
|
+
)}
|
|
120
127
|
onclick={(e) => selectOption(option, e)}
|
|
121
128
|
{disabled}
|
|
122
129
|
style="background: color-mix(in srgb, var(--bg-color), var(--back-color) 70%);"
|
|
@@ -127,22 +134,21 @@
|
|
|
127
134
|
</div>
|
|
128
135
|
{/if}
|
|
129
136
|
{:else if type === 'buttons'}
|
|
130
|
-
<div
|
|
137
|
+
<div {id} class="flex h-full w-full flex-row justify-center">
|
|
131
138
|
{#each options as option, index (option.id)}
|
|
132
139
|
<button
|
|
133
140
|
id={option.id}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
141
|
+
class="{twMerge(
|
|
142
|
+
`m-0 inline-block min-w-0 flex-1 items-center px-2 py-1 font-semibold shadow-sm transition-all duration-300 select-none
|
|
143
|
+
${option.disabled || disabled ? 'opacity-50' : 'cursor-pointer hover:shadow-md'}
|
|
144
|
+
${option.value === value?.value && value !== null ? 'z-10 py-0 text-[1.1rem] shadow-[0_0_10px_var(--shadow-color)] hover:shadow-[0_0_15px_var(--shadow-color)]' : ''}
|
|
145
|
+
${options.length > 0 && index === 0 ? 'rounded-l-2xl' : ''} ${index === options.length - 1 ? 'rounded-r-2xl' : ''}`,
|
|
146
|
+
option.class,
|
|
147
|
+
)} bg-[var(--bg-color)]"
|
|
138
148
|
onclick={(e) => selectOption(option, e)}
|
|
139
149
|
disabled={option.disabled}
|
|
140
150
|
>
|
|
141
151
|
<span class="flex flex-row items-center justify-center gap-4">
|
|
142
|
-
{#if option.icon?.component}
|
|
143
|
-
{@const IconComponent = option.icon?.component}
|
|
144
|
-
<IconComponent {...option.icon?.properties} />
|
|
145
|
-
{/if}
|
|
146
152
|
{#if option.name}
|
|
147
153
|
<div class="flex-1">
|
|
148
154
|
{option.name}
|
|
@@ -160,9 +166,15 @@
|
|
|
160
166
|
[&::-webkit-inner-spin-button]:hidden [&::-webkit-outer-spin-button]:hidden
|
|
161
167
|
{disabled ? 'cursor-not-allowed opacity-50' : 'cursor-text'} border-[var(--border-color)]"
|
|
162
168
|
style="background: color-mix(in srgb, var(--bg-color), var(--back-color) 70%);"
|
|
163
|
-
|
|
169
|
+
{id}
|
|
164
170
|
{disabled}
|
|
165
171
|
oninput={(e) => handleSearch((e.currentTarget as HTMLInputElement).value)}
|
|
172
|
+
onclick={(e) => {
|
|
173
|
+
if (searchValue == '') {
|
|
174
|
+
filteredOptions = options
|
|
175
|
+
isDropdownOpen = true
|
|
176
|
+
}
|
|
177
|
+
}}
|
|
166
178
|
/>
|
|
167
179
|
|
|
168
180
|
{#if isDropdownOpen}
|
|
@@ -175,8 +187,11 @@
|
|
|
175
187
|
<button
|
|
176
188
|
id={option.id}
|
|
177
189
|
value={option?.value ? String(option.value) : ''}
|
|
178
|
-
class=
|
|
179
|
-
|
|
190
|
+
class={twMerge(
|
|
191
|
+
`flex h-full w-full cursor-pointer items-center justify-center p-1 duration-250 hover:!bg-[var(--field-color)]
|
|
192
|
+
${index === filteredOptions.length - 1 ? 'rounded-b-2xl' : ''} `,
|
|
193
|
+
option.class,
|
|
194
|
+
)}
|
|
180
195
|
onclick={(e) => selectOption(option, e)}
|
|
181
196
|
{disabled}
|
|
182
197
|
style="background: color-mix(in srgb, var(--bg-color), var(--back-color) 70%);"
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
<!-- $lib/ElementsUI/SelectProps.svelte -->
|
|
2
|
+
<script lang="ts">
|
|
3
|
+
import { getContext } from 'svelte'
|
|
4
|
+
import { t } from '../locales/i18n'
|
|
5
|
+
import { type UIComponent, type ISelectProps, type ISelectOption, updateProperty } from '../types'
|
|
6
|
+
import * as UI from '..'
|
|
7
|
+
import ButtonDelete from '../libIcons/ButtonDelete.svelte'
|
|
8
|
+
import ButtonAdd from '../libIcons/ButtonAdd.svelte'
|
|
9
|
+
import { optionsStore } from '../options.js'
|
|
10
|
+
|
|
11
|
+
const { component, onPropertyChange } = $props<{
|
|
12
|
+
component: UIComponent & { properties: Partial<ISelectProps> }
|
|
13
|
+
onPropertyChange: (path: string, value: string | object) => void
|
|
14
|
+
}>()
|
|
15
|
+
|
|
16
|
+
const DeviceVariables = getContext<{ value: string; name: string }[]>('DeviceVariables')
|
|
17
|
+
let VARIABLE_OPTIONS = $derived(
|
|
18
|
+
DeviceVariables && Array.isArray(DeviceVariables)
|
|
19
|
+
? DeviceVariables.map((variable) => ({
|
|
20
|
+
id: variable.name,
|
|
21
|
+
value: variable.value,
|
|
22
|
+
name: `${variable.value} | ${variable.name}`,
|
|
23
|
+
}))
|
|
24
|
+
: [],
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
type ValueTypeOption = {
|
|
28
|
+
id: string
|
|
29
|
+
value: 'text' | 'number'
|
|
30
|
+
name: string
|
|
31
|
+
class: string
|
|
32
|
+
}
|
|
33
|
+
let currentValueType = $derived(
|
|
34
|
+
!component.properties.options[0]
|
|
35
|
+
? ($optionsStore.SELECT_VALUE_TYPE_OPTIONS[0] as ValueTypeOption)
|
|
36
|
+
: typeof component.properties.options[0].value === 'number'
|
|
37
|
+
? $optionsStore.SELECT_VALUE_TYPE_OPTIONS[1]
|
|
38
|
+
: ($optionsStore.SELECT_VALUE_TYPE_OPTIONS[0] as ValueTypeOption),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
let Header: ISelectOption = $derived(
|
|
42
|
+
$optionsStore.HEADER_OPTIONS.find((h) => h.value === component.properties.eventHandler.Header) ?? {
|
|
43
|
+
id: '',
|
|
44
|
+
name: '',
|
|
45
|
+
value: '',
|
|
46
|
+
class: '!w-1/4',
|
|
47
|
+
},
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
let currentType = $derived($optionsStore.SELECT_TYPE_OPTIONS.find((t) => t.value === component.properties.type))
|
|
51
|
+
|
|
52
|
+
const initialColor = $derived(
|
|
53
|
+
$optionsStore.COLOR_OPTIONS.find((c) =>
|
|
54
|
+
(c.value as string).includes(component.properties.wrapperClass?.split(' ').find((cls: string) => cls.startsWith('bg-'))),
|
|
55
|
+
),
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
const initialAlign = $derived(
|
|
59
|
+
$optionsStore.ALIGN_OPTIONS.find((a) =>
|
|
60
|
+
(a.value as string).includes(component.properties.label?.class?.split(' ').find((cls: string) => cls.startsWith('text-'))),
|
|
61
|
+
),
|
|
62
|
+
)
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
{#if component && component.properties}
|
|
66
|
+
<div class="relative mb-4 flex flex-row items-start justify-center">
|
|
67
|
+
<div class="flex w-1/3 flex-col items-center px-2">
|
|
68
|
+
<UI.Select
|
|
69
|
+
label={{ name: $t('constructor.props.argument') }}
|
|
70
|
+
type="buttons"
|
|
71
|
+
value={$optionsStore.FULL_ARGUMENT_OPTION.find((h) => h.value === component.properties.eventHandler.Argument)}
|
|
72
|
+
options={$optionsStore.FULL_ARGUMENT_OPTION}
|
|
73
|
+
onUpdate={(option) => {
|
|
74
|
+
updateProperty('eventHandler.Argument', option.value as string, component, onPropertyChange)
|
|
75
|
+
}}
|
|
76
|
+
/>
|
|
77
|
+
|
|
78
|
+
<UI.Input
|
|
79
|
+
wrapperClass="{Header.value === 'SET' ? 'mt-1' : ''} "
|
|
80
|
+
value={component.properties.eventHandler.Argument}
|
|
81
|
+
maxlength={32}
|
|
82
|
+
disabled={component.properties.eventHandler.Argument == 'Save' || component.properties.eventHandler.Argument == 'NoSave'}
|
|
83
|
+
help={{ info: $t('constructor.props.argument.info'), autocomplete: 'on', regExp: /^[a-zA-Z0-9\-_]{0,32}$/ }}
|
|
84
|
+
onUpdate={(value) => updateProperty('eventHandler.Argument', value as string, component, onPropertyChange)}
|
|
85
|
+
/>
|
|
86
|
+
<UI.Select
|
|
87
|
+
label={{ name: $t('constructor.props.variable') }}
|
|
88
|
+
options={VARIABLE_OPTIONS}
|
|
89
|
+
value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id.value)}
|
|
90
|
+
onUpdate={(value) => {
|
|
91
|
+
updateProperty('id', value.value as string, component, onPropertyChange)
|
|
92
|
+
updateProperty('eventHandler.Variables', value.value as string, component, onPropertyChange)
|
|
93
|
+
}}
|
|
94
|
+
/>
|
|
95
|
+
<UI.Select
|
|
96
|
+
label={{ name: $t('constructor.props.type') }}
|
|
97
|
+
type="buttons"
|
|
98
|
+
value={currentType}
|
|
99
|
+
options={$optionsStore.SELECT_TYPE_OPTIONS}
|
|
100
|
+
onUpdate={(item) => updateProperty('type', item.value as string, component, onPropertyChange)}
|
|
101
|
+
/>
|
|
102
|
+
</div>
|
|
103
|
+
<div class="flex w-1/3 flex-col items-center px-2">
|
|
104
|
+
<UI.Select
|
|
105
|
+
wrapperClass="h-14"
|
|
106
|
+
label={{ name: $t('constructor.props.valuetype') }}
|
|
107
|
+
type="buttons"
|
|
108
|
+
options={$optionsStore.SELECT_VALUE_TYPE_OPTIONS}
|
|
109
|
+
value={currentValueType}
|
|
110
|
+
onUpdate={(value) => {
|
|
111
|
+
currentValueType = value as ValueTypeOption
|
|
112
|
+
const options = [...(component.properties?.options || [])]
|
|
113
|
+
const newType = value.value
|
|
114
|
+
options.forEach((option) => {
|
|
115
|
+
if (newType === 'number') option.value = option.value !== undefined ? Number(option.value) : 0
|
|
116
|
+
else option.value = option.value !== undefined ? String(option.value) : ''
|
|
117
|
+
})
|
|
118
|
+
updateProperty('options', options, component, onPropertyChange)
|
|
119
|
+
}}
|
|
120
|
+
/>
|
|
121
|
+
<UI.Select
|
|
122
|
+
wrapperClass=" h-14"
|
|
123
|
+
label={{ name: $t('constructor.props.colors') }}
|
|
124
|
+
type="buttons"
|
|
125
|
+
options={$optionsStore.COLOR_OPTIONS}
|
|
126
|
+
value={initialColor}
|
|
127
|
+
onUpdate={(option) => updateProperty('wrapperClass', `${component.properties.wrapperClass} ${option.value}`, component, onPropertyChange)}
|
|
128
|
+
/>
|
|
129
|
+
</div>
|
|
130
|
+
<div class="flex w-1/3 flex-col items-center px-2">
|
|
131
|
+
<UI.Input
|
|
132
|
+
label={{ name: $t('constructor.props.label') }}
|
|
133
|
+
value={component.properties.label.name}
|
|
134
|
+
onUpdate={(value) => updateProperty('label.name', value as string, component, onPropertyChange)}
|
|
135
|
+
/>
|
|
136
|
+
<UI.Select
|
|
137
|
+
label={{ name: $t('constructor.props.align') }}
|
|
138
|
+
type="buttons"
|
|
139
|
+
value={initialAlign}
|
|
140
|
+
options={$optionsStore.ALIGN_OPTIONS}
|
|
141
|
+
onUpdate={(option) => updateProperty('label.class', `${component.properties.label.class} ${option.value}`, component, onPropertyChange)}
|
|
142
|
+
/>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
|
|
146
|
+
<hr class="border-gray-400" />
|
|
147
|
+
|
|
148
|
+
<!-- Настройки опций -->
|
|
149
|
+
<div class="space-y-4">
|
|
150
|
+
<div class="m-0 flex items-center justify-center gap-2">
|
|
151
|
+
<h4>{$t('constructor.props.options.title')}</h4>
|
|
152
|
+
<UI.Button
|
|
153
|
+
wrapperClass="!w-10"
|
|
154
|
+
content={{ icon: ButtonAdd }}
|
|
155
|
+
componentClass="bg-transparent h-10 border-none !shadow-none hover:shadow-none"
|
|
156
|
+
onClick={() => {
|
|
157
|
+
const newOption: ISelectOption = {
|
|
158
|
+
id: crypto.randomUUID(),
|
|
159
|
+
name: 'New Button',
|
|
160
|
+
class: 'bg-max',
|
|
161
|
+
}
|
|
162
|
+
const options = [...(component.properties?.options || []), newOption]
|
|
163
|
+
updateProperty('options', options, component, onPropertyChange)
|
|
164
|
+
}}
|
|
165
|
+
/>
|
|
166
|
+
</div>
|
|
167
|
+
|
|
168
|
+
{#each component.properties.options || [] as option, index (option.id)}
|
|
169
|
+
<div class="m-0 flex items-end justify-around gap-2 border-gray-400">
|
|
170
|
+
<UI.Input
|
|
171
|
+
label={{ name: $t('constructor.props.optionname') }}
|
|
172
|
+
wrapperClass="!w-3/10"
|
|
173
|
+
value={option.name}
|
|
174
|
+
onUpdate={(value) => {
|
|
175
|
+
const options = [...(component.properties?.options || [])]
|
|
176
|
+
options[index]['name'] = value
|
|
177
|
+
updateProperty('options', options, component, onPropertyChange)
|
|
178
|
+
}}
|
|
179
|
+
/>
|
|
180
|
+
<UI.Input
|
|
181
|
+
label={{ name: $t('constructor.props.optionvalue') }}
|
|
182
|
+
wrapperClass="!w-3/10"
|
|
183
|
+
value={option.value}
|
|
184
|
+
type={currentValueType.value}
|
|
185
|
+
onUpdate={(value) => {
|
|
186
|
+
const options = [...(component.properties?.options || [])]
|
|
187
|
+
options[index]['value'] = value
|
|
188
|
+
updateProperty('options', options, component, onPropertyChange)
|
|
189
|
+
}}
|
|
190
|
+
/>
|
|
191
|
+
<UI.Select
|
|
192
|
+
wrapperClass="w-80 h-14.5"
|
|
193
|
+
label={{ name: $t('constructor.props.colors') }}
|
|
194
|
+
type="buttons"
|
|
195
|
+
options={$optionsStore.COLOR_OPTIONS}
|
|
196
|
+
value={initialColor}
|
|
197
|
+
onUpdate={(option) => {
|
|
198
|
+
const options = [...(component.properties?.options || [])]
|
|
199
|
+
options[index]['class'] = option.value
|
|
200
|
+
updateProperty('options', options, component, onPropertyChange)
|
|
201
|
+
}}
|
|
202
|
+
/>
|
|
203
|
+
<UI.Button
|
|
204
|
+
wrapperClass="!w-1/10"
|
|
205
|
+
content={{ icon: ButtonDelete }}
|
|
206
|
+
componentClass="bg-transparent h-10 w-10 border-none !shadow-none hover:shadow-none"
|
|
207
|
+
onClick={() => {
|
|
208
|
+
const options = [...(component.properties?.options || [])]
|
|
209
|
+
options.splice(index, 1)
|
|
210
|
+
updateProperty('options', options, component, onPropertyChange)
|
|
211
|
+
}}
|
|
212
|
+
/>
|
|
213
|
+
</div>
|
|
214
|
+
{/each}
|
|
215
|
+
</div>
|
|
216
|
+
{/if}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type UIComponent, type ISelectProps } from '../types';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
component: UIComponent & {
|
|
4
|
+
properties: Partial<ISelectProps>;
|
|
5
|
+
};
|
|
6
|
+
onPropertyChange: (path: string, value: string | object) => void;
|
|
7
|
+
};
|
|
8
|
+
declare const SelectProps: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
9
|
+
type SelectProps = ReturnType<typeof SelectProps>;
|
|
10
|
+
export default SelectProps;
|