poe-svelte-ui-lib 0.2.0 → 1.0.0
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 +53 -0
- package/dist/Accordion/Accordion.svelte.d.ts +4 -0
- package/dist/Accordion/AccordionProps.svelte +70 -0
- package/dist/Accordion/AccordionProps.svelte.d.ts +10 -0
- package/dist/{Button.svelte → Button/Button.svelte} +43 -24
- package/dist/{Button.svelte.d.ts → Button/Button.svelte.d.ts} +5 -5
- package/dist/Button/ButtonProps.svelte +200 -0
- package/dist/Button/ButtonProps.svelte.d.ts +10 -0
- package/dist/ColorPicker/ColorPicker.svelte +207 -0
- package/dist/ColorPicker/ColorPicker.svelte.d.ts +4 -0
- package/dist/ColorPicker/ColorPickerProps.svelte +100 -0
- package/dist/ColorPicker/ColorPickerProps.svelte.d.ts +10 -0
- package/dist/FileAttach/FileAttach.svelte +103 -0
- package/dist/FileAttach/FileAttach.svelte.d.ts +22 -0
- package/dist/Graph/Graph.svelte +270 -0
- package/dist/Graph/Graph.svelte.d.ts +4 -0
- package/dist/Graph/GraphProps.svelte +56 -0
- package/dist/Graph/GraphProps.svelte.d.ts +10 -0
- package/dist/Input/Input.svelte +239 -0
- package/dist/Input/Input.svelte.d.ts +4 -0
- package/dist/Input/InputProps.svelte +221 -0
- package/dist/Input/InputProps.svelte.d.ts +10 -0
- package/dist/Loader.svelte +12 -0
- package/dist/Loader.svelte.d.ts +5 -0
- package/dist/MessageModal.svelte +54 -0
- package/dist/MessageModal.svelte.d.ts +10 -0
- package/dist/ProgressBar/ProgressBar.svelte +48 -0
- package/dist/ProgressBar/ProgressBar.svelte.d.ts +4 -0
- package/dist/ProgressBar/ProgressBarProps.svelte +145 -0
- package/dist/ProgressBar/ProgressBarProps.svelte.d.ts +10 -0
- package/dist/Select/Select.svelte +187 -0
- package/dist/Select/Select.svelte.d.ts +18 -0
- package/dist/Select/SelectProps.svelte +260 -0
- package/dist/Select/SelectProps.svelte.d.ts +10 -0
- package/dist/Slider/Slider.svelte +260 -0
- package/dist/Slider/Slider.svelte.d.ts +4 -0
- package/dist/Slider/SliderProps.svelte +161 -0
- package/dist/Slider/SliderProps.svelte.d.ts +10 -0
- package/dist/Switch/Switch.svelte +83 -0
- package/dist/Switch/Switch.svelte.d.ts +4 -0
- package/dist/Switch/SwitchProps.svelte +144 -0
- package/dist/Switch/SwitchProps.svelte.d.ts +10 -0
- package/dist/Table/Table.svelte +276 -0
- package/dist/Table/Table.svelte.d.ts +4 -0
- package/dist/Table/TableProps.svelte +286 -0
- package/dist/Table/TableProps.svelte.d.ts +10 -0
- package/dist/TextField/TextField.svelte +22 -0
- package/dist/TextField/TextField.svelte.d.ts +4 -0
- package/dist/TextField/TextFieldProps.svelte +92 -0
- package/dist/TextField/TextFieldProps.svelte.d.ts +10 -0
- package/dist/appIcons/ButtonAdd.svelte +10 -0
- package/dist/appIcons/ButtonAdd.svelte.d.ts +18 -0
- package/dist/appIcons/ButtonDelete.svelte +13 -0
- package/dist/appIcons/ButtonDelete.svelte.d.ts +18 -0
- package/dist/appIcons/LoaderRotate.svelte +9 -0
- package/dist/appIcons/LoaderRotate.svelte.d.ts +18 -0
- package/dist/index.d.ts +26 -1
- package/dist/index.js +27 -2
- package/dist/locales/CircleFlagsEn.svelte +14 -0
- package/dist/locales/CircleFlagsEn.svelte.d.ts +26 -0
- package/dist/locales/CircleFlagsRu.svelte +8 -0
- package/dist/locales/CircleFlagsRu.svelte.d.ts +26 -0
- package/dist/locales/CircleFlagsZh.svelte +8 -0
- package/dist/locales/CircleFlagsZh.svelte.d.ts +26 -0
- package/dist/locales/i18n.d.ts +10 -0
- package/dist/locales/i18n.js +36 -0
- package/dist/locales/translations.d.ts +7 -0
- package/dist/locales/translations.js +450 -0
- package/dist/options.d.ts +78 -0
- package/dist/options.js +71 -0
- package/dist/types.d.ts +284 -0
- package/dist/types.js +1 -0
- package/package.json +28 -21
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
<!-- $lib/ElementUI/Select.svelte -->
|
|
2
|
+
<script lang="ts" generics="T = unknown">
|
|
3
|
+
import { slide } from 'svelte/transition'
|
|
4
|
+
import { onMount } from 'svelte'
|
|
5
|
+
import type { ISelectOption, ISelectProps } from '../types'
|
|
6
|
+
import { t } from '../locales/i18n'
|
|
7
|
+
|
|
8
|
+
let isDropdownOpen = $state(false)
|
|
9
|
+
let dropdownElement: HTMLDivElement
|
|
10
|
+
|
|
11
|
+
let searchValue = $state('')
|
|
12
|
+
let filteredOptions = $state<ISelectOption<T>[]>([])
|
|
13
|
+
|
|
14
|
+
let {
|
|
15
|
+
id = { name: '', value: crypto.randomUUID() },
|
|
16
|
+
wrapperClass = 'bg-max',
|
|
17
|
+
disabled = false,
|
|
18
|
+
label = { name: '', class: '' },
|
|
19
|
+
type = 'select',
|
|
20
|
+
value = $bindable(),
|
|
21
|
+
options = [],
|
|
22
|
+
onUpdate,
|
|
23
|
+
}: ISelectProps<T> = $props()
|
|
24
|
+
|
|
25
|
+
/* Закрытие при клике вне компонента */
|
|
26
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
27
|
+
if (dropdownElement && !dropdownElement.contains(event.target as Node)) {
|
|
28
|
+
isDropdownOpen = false
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
onMount(() => {
|
|
33
|
+
if (type === 'select') document.addEventListener('click', handleClickOutside)
|
|
34
|
+
return () => {
|
|
35
|
+
if (type === 'select') document.removeEventListener('click', handleClickOutside)
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
const toggleDropdown = (event: MouseEvent) => {
|
|
40
|
+
event.stopPropagation()
|
|
41
|
+
if (!disabled) {
|
|
42
|
+
isDropdownOpen = !isDropdownOpen
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const selectOption = (option: ISelectOption<T>, event: MouseEvent) => {
|
|
47
|
+
event.stopPropagation()
|
|
48
|
+
if (!disabled) {
|
|
49
|
+
value = option
|
|
50
|
+
isDropdownOpen = false
|
|
51
|
+
onUpdate?.(value)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const handleSearch = (inputValue: string) => {
|
|
56
|
+
searchValue = inputValue
|
|
57
|
+
|
|
58
|
+
if (inputValue.trim() === '') {
|
|
59
|
+
isDropdownOpen = false
|
|
60
|
+
filteredOptions = []
|
|
61
|
+
} else {
|
|
62
|
+
filteredOptions = options.filter((option) => {
|
|
63
|
+
const optionName = option.name?.toString() || ''
|
|
64
|
+
return optionName.toLowerCase().includes(inputValue.toLowerCase())
|
|
65
|
+
})
|
|
66
|
+
isDropdownOpen = filteredOptions.length > 0
|
|
67
|
+
|
|
68
|
+
const selectedFromList = options.some((option) => option.name?.toString() === searchValue)
|
|
69
|
+
console.log(selectedFromList)
|
|
70
|
+
|
|
71
|
+
if (!selectedFromList) {
|
|
72
|
+
const newOption: ISelectOption<T> = {
|
|
73
|
+
id: `input-${searchValue}`,
|
|
74
|
+
name: searchValue,
|
|
75
|
+
value: searchValue as T,
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
value = newOption
|
|
79
|
+
onUpdate?.(newOption)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
</script>
|
|
84
|
+
|
|
85
|
+
<div class={`bg-max relative flex w-full flex-col items-center ${wrapperClass}`} bind:this={dropdownElement}>
|
|
86
|
+
{#if label.name}
|
|
87
|
+
<h5 class={`w-full px-4 ${label.class}`}>{label.name}</h5>
|
|
88
|
+
{/if}
|
|
89
|
+
{#if type === 'select'}
|
|
90
|
+
<button
|
|
91
|
+
id={id.value}
|
|
92
|
+
value={value?.value ? String(value.value) : ''}
|
|
93
|
+
class="w-full rounded-2xl border border-[var(--border-color)] p-1 text-center duration-250
|
|
94
|
+
{value?.class} {disabled ? 'opacity-50' : 'cursor-pointer hover:shadow-lg'}"
|
|
95
|
+
style="background: color-mix(in srgb, var(--bg-color), var(--back-color) 70%);"
|
|
96
|
+
onclick={toggleDropdown}
|
|
97
|
+
aria-haspopup="true"
|
|
98
|
+
aria-expanded={isDropdownOpen}
|
|
99
|
+
{disabled}
|
|
100
|
+
>
|
|
101
|
+
{value?.name || $t('common.select_tag')}
|
|
102
|
+
</button>
|
|
103
|
+
|
|
104
|
+
{#if isDropdownOpen}
|
|
105
|
+
<div
|
|
106
|
+
class="absolute top-full left-1/2 z-50 -translate-x-1/2 rounded-b-2xl border border-t-0 border-[var(--border-color)]"
|
|
107
|
+
style="width: calc(100% - 1.8rem);"
|
|
108
|
+
transition:slide={{ duration: 250 }}
|
|
109
|
+
>
|
|
110
|
+
{#each options as option, index (option.id)}
|
|
111
|
+
<button
|
|
112
|
+
id={option.id}
|
|
113
|
+
value={option?.value ? String(option.value) : ''}
|
|
114
|
+
class="flex h-full w-full cursor-pointer items-center justify-center p-1 duration-250 hover:!bg-[var(--field-color)]
|
|
115
|
+
{option.class} {index === options.length - 1 ? 'rounded-b-2xl' : ''} "
|
|
116
|
+
onclick={(e) => selectOption(option, e)}
|
|
117
|
+
{disabled}
|
|
118
|
+
style="background: color-mix(in srgb, var(--bg-color), var(--back-color) 70%);"
|
|
119
|
+
>
|
|
120
|
+
{option.name}
|
|
121
|
+
</button>
|
|
122
|
+
{/each}
|
|
123
|
+
</div>
|
|
124
|
+
{/if}
|
|
125
|
+
{:else if type === 'buttons'}
|
|
126
|
+
<div id={id.value} class="flex h-full w-full flex-row justify-center">
|
|
127
|
+
{#each options as option, index (option.id)}
|
|
128
|
+
<button
|
|
129
|
+
id={option.id}
|
|
130
|
+
class="m-0 inline-block min-w-0 flex-1 items-center border
|
|
131
|
+
border-[var(--border-color)] bg-[var(--bg-color)] px-2 py-1 font-semibold transition-all duration-200 select-none
|
|
132
|
+
{option.disabled || disabled ? 'opacity-50' : 'cursor-pointer hover:shadow-lg'}
|
|
133
|
+
{option.value === value?.value && value !== null ? 'z-10 text-blue-600 ring-2 ring-[var(--blue-color)]' : ''}
|
|
134
|
+
{option.class} {options.length > 0 && index === 0 ? 'rounded-l-2xl' : ''} {index === options.length - 1 ? 'rounded-r-2xl' : ''}"
|
|
135
|
+
onclick={(e) => selectOption(option, e)}
|
|
136
|
+
disabled={option.disabled}
|
|
137
|
+
>
|
|
138
|
+
<span class="flex flex-row items-center justify-center gap-4">
|
|
139
|
+
{#if option.icon?.component}
|
|
140
|
+
{@const IconComponent = option.icon?.component}
|
|
141
|
+
<IconComponent {...option.icon?.properties} />
|
|
142
|
+
{/if}
|
|
143
|
+
{#if option.name}
|
|
144
|
+
<div class="flex-1">
|
|
145
|
+
{option.name}
|
|
146
|
+
</div>
|
|
147
|
+
{/if}
|
|
148
|
+
</span>
|
|
149
|
+
</button>
|
|
150
|
+
{/each}
|
|
151
|
+
</div>
|
|
152
|
+
{:else if type === 'input'}
|
|
153
|
+
<input
|
|
154
|
+
bind:value={searchValue}
|
|
155
|
+
class="w-full appearance-none rounded-2xl border px-4 py-1 text-center transition-shadow
|
|
156
|
+
outline-none hover:shadow-md focus:border-blue-400
|
|
157
|
+
[&::-webkit-inner-spin-button]:hidden [&::-webkit-outer-spin-button]:hidden
|
|
158
|
+
{disabled ? 'cursor-not-allowed opacity-50' : 'cursor-text'} border-[var(--border-color)]"
|
|
159
|
+
style="background: color-mix(in srgb, var(--bg-color), var(--back-color) 70%);"
|
|
160
|
+
id={id.value}
|
|
161
|
+
{disabled}
|
|
162
|
+
oninput={(e) => handleSearch((e.currentTarget as HTMLInputElement).value)}
|
|
163
|
+
/>
|
|
164
|
+
|
|
165
|
+
{#if isDropdownOpen}
|
|
166
|
+
<div
|
|
167
|
+
class="absolute top-full left-1/2 z-50 -translate-x-1/2 rounded-b-2xl border border-t-0 border-[var(--border-color)]"
|
|
168
|
+
style="width: calc(100% - 1.8rem);"
|
|
169
|
+
transition:slide={{ duration: 250 }}
|
|
170
|
+
>
|
|
171
|
+
{#each filteredOptions as option, index (option.id)}
|
|
172
|
+
<button
|
|
173
|
+
id={option.id}
|
|
174
|
+
value={option?.value ? String(option.value) : ''}
|
|
175
|
+
class="flex h-full w-full cursor-pointer items-center justify-center p-1 duration-250 hover:!bg-[var(--field-color)]
|
|
176
|
+
{option.class} {index === filteredOptions.length - 1 ? 'rounded-b-2xl' : ''} "
|
|
177
|
+
onclick={(e) => selectOption(option, e)}
|
|
178
|
+
{disabled}
|
|
179
|
+
style="background: color-mix(in srgb, var(--bg-color), var(--back-color) 70%);"
|
|
180
|
+
>
|
|
181
|
+
{option.name}
|
|
182
|
+
</button>
|
|
183
|
+
{/each}
|
|
184
|
+
</div>
|
|
185
|
+
{/if}
|
|
186
|
+
{/if}
|
|
187
|
+
</div>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ISelectProps } from '../types';
|
|
2
|
+
declare class __sveltets_Render<T = unknown> {
|
|
3
|
+
props(): ISelectProps<T>;
|
|
4
|
+
events(): {};
|
|
5
|
+
slots(): {};
|
|
6
|
+
bindings(): "value";
|
|
7
|
+
exports(): {};
|
|
8
|
+
}
|
|
9
|
+
interface $$IsomorphicComponent {
|
|
10
|
+
new <T = unknown>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
11
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
12
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
13
|
+
<T = unknown>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
14
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
15
|
+
}
|
|
16
|
+
declare const Select: $$IsomorphicComponent;
|
|
17
|
+
type Select<T = unknown> = InstanceType<typeof Select<T>>;
|
|
18
|
+
export default Select;
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
<!-- $lib/ElementsUI/SelectProps.svelte -->
|
|
2
|
+
<script lang="ts">
|
|
3
|
+
import { getContext } from 'svelte'
|
|
4
|
+
import { t } from '../locales/i18n'
|
|
5
|
+
import type { UIComponent, ISelectProps, ISelectOption } from '../types.js'
|
|
6
|
+
import * as UI from '../index'
|
|
7
|
+
import ButtonDelete from '../appIcons/ButtonDelete.svelte'
|
|
8
|
+
import ButtonAdd from '../appIcons/ButtonAdd.svelte'
|
|
9
|
+
|
|
10
|
+
import { optionsStore } from '../options.js'
|
|
11
|
+
|
|
12
|
+
const { component, onPropertyChange } = $props<{
|
|
13
|
+
component: UIComponent & { properties: Partial<ISelectProps> }
|
|
14
|
+
onPropertyChange: (path: string, value: string | object) => void
|
|
15
|
+
}>()
|
|
16
|
+
|
|
17
|
+
const DeviceVariables = getContext<{ value: string; name: string }[]>('DeviceVariables')
|
|
18
|
+
let VARIABLE_OPTIONS = $derived(
|
|
19
|
+
DeviceVariables.map((variable: { value: string; name: string }) => ({
|
|
20
|
+
id: variable.name,
|
|
21
|
+
value: variable.value,
|
|
22
|
+
name: `${variable.value} | ${variable.name}`,
|
|
23
|
+
})),
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
type ValueTypeOption = {
|
|
27
|
+
id: string
|
|
28
|
+
value: 'text' | 'number'
|
|
29
|
+
name: string
|
|
30
|
+
class: string
|
|
31
|
+
}
|
|
32
|
+
let currentValueType = $derived(
|
|
33
|
+
!component.properties.options[0]
|
|
34
|
+
? ($optionsStore.SELECT_VALUE_TYPE_OPTIONS[0] as ValueTypeOption)
|
|
35
|
+
: typeof component.properties.options[0].value === 'number'
|
|
36
|
+
? $optionsStore.SELECT_VALUE_TYPE_OPTIONS[1]
|
|
37
|
+
: ($optionsStore.SELECT_VALUE_TYPE_OPTIONS[0] as ValueTypeOption),
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
let Header: ISelectOption = $derived(
|
|
41
|
+
$optionsStore.HEADER_OPTIONS.find((h) => h.value === component.properties.eventHandler.Header) ?? { id: '', name: '', value: '', class: '!w-1/4' },
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
let currentType = $derived($optionsStore.SELECT_TYPE_OPTIONS.find((t) => t.value === component.properties.type))
|
|
45
|
+
|
|
46
|
+
const initialColor = $derived(
|
|
47
|
+
$optionsStore.COLOR_OPTIONS.find((c) =>
|
|
48
|
+
(c.value as string).includes(component.properties.wrapperClass?.split(' ').find((cls: string) => cls.startsWith('bg-'))),
|
|
49
|
+
),
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
const initialAlign = $derived(
|
|
53
|
+
$optionsStore.ALIGN_OPTIONS.find((a) =>
|
|
54
|
+
(a.value as string).includes(component.properties.label?.class?.split(' ').find((cls: string) => cls.startsWith('text-'))),
|
|
55
|
+
),
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
const handleLabelAlign = (align: string) => {
|
|
59
|
+
let labelClass = component.properties.label.class || ''
|
|
60
|
+
labelClass = labelClass
|
|
61
|
+
.split(' ')
|
|
62
|
+
.filter((cls: string) => !cls.startsWith('text-'))
|
|
63
|
+
.join(' ')
|
|
64
|
+
if (align) {
|
|
65
|
+
labelClass += ` ${align}`
|
|
66
|
+
}
|
|
67
|
+
updateProperty('label.class', labelClass)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const handleOptionColorChange = (color: string) => {
|
|
71
|
+
let wrapperClass = component.properties.wrapperClass || ''
|
|
72
|
+
wrapperClass = wrapperClass
|
|
73
|
+
.split(' ')
|
|
74
|
+
.filter((cls: string) => !cls.startsWith('bg-'))
|
|
75
|
+
.join(' ')
|
|
76
|
+
if (color) {
|
|
77
|
+
wrapperClass += ` ${color}`
|
|
78
|
+
}
|
|
79
|
+
updateProperty('wrapperClass', wrapperClass)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* Обновление свойства */
|
|
83
|
+
const updateProperty = (path: string, value: string | object) => {
|
|
84
|
+
const newProperties = JSON.parse(JSON.stringify(component.properties))
|
|
85
|
+
const parts = path.split('.')
|
|
86
|
+
let obj = newProperties
|
|
87
|
+
|
|
88
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
89
|
+
const part = parts[i]
|
|
90
|
+
if (!obj[part]) obj[part] = {}
|
|
91
|
+
obj = obj[part]
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
obj[parts[parts.length - 1]] = value
|
|
95
|
+
onPropertyChange(newProperties)
|
|
96
|
+
}
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
{#if component && component.properties}
|
|
100
|
+
<div class="relative mb-4 flex flex-row items-start justify-center">
|
|
101
|
+
<div class="flex w-1/3 flex-col items-center px-2">
|
|
102
|
+
<UI.Select
|
|
103
|
+
wrapperClass="w-full"
|
|
104
|
+
label={{ name: $t('service.constructor.props.argument') }}
|
|
105
|
+
type="buttons"
|
|
106
|
+
value={$optionsStore.FULL_ARGUMENT_OPTION.find((h) => h.value === component.properties.eventHandler.Argument)}
|
|
107
|
+
options={$optionsStore.FULL_ARGUMENT_OPTION}
|
|
108
|
+
onUpdate={(option) => {
|
|
109
|
+
updateProperty('eventHandler.Argument', option.value as string)
|
|
110
|
+
}}
|
|
111
|
+
/>
|
|
112
|
+
{#if component.properties.eventHandler.Argument !== 'Save' && component.properties.eventHandler.Argument !== 'NoSave'}
|
|
113
|
+
<UI.Input
|
|
114
|
+
wrapperClass="w-full {Header.value === 'SET' ? 'mt-1' : ''} "
|
|
115
|
+
label={{ name: $t('service.constructor.props.argument') }}
|
|
116
|
+
value={component.properties.eventHandler.Argument}
|
|
117
|
+
type="text"
|
|
118
|
+
autocomplete="on"
|
|
119
|
+
componentClass="w-full"
|
|
120
|
+
maxlength={32}
|
|
121
|
+
regExp={/^[a-zA-Z0-9\-_]{0,32}$/}
|
|
122
|
+
help={{ info: $t('service.constructor.props.argument.info') }}
|
|
123
|
+
onUpdate={(value) => updateProperty('eventHandler.Argument', value as string)}
|
|
124
|
+
/>
|
|
125
|
+
{/if}
|
|
126
|
+
<UI.Select
|
|
127
|
+
label={{ name: $t('service.constructor.props.variable') }}
|
|
128
|
+
options={VARIABLE_OPTIONS}
|
|
129
|
+
value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id.value)}
|
|
130
|
+
onUpdate={(value) => {
|
|
131
|
+
updateProperty('id.name', (value.name as string).split('|')[1].trim())
|
|
132
|
+
updateProperty('id.value', value.value as string)
|
|
133
|
+
updateProperty('eventHandler.Variables', value.value as string)
|
|
134
|
+
}}
|
|
135
|
+
/>
|
|
136
|
+
<UI.Select
|
|
137
|
+
label={{ name: $t('service.constructor.props.type') }}
|
|
138
|
+
type="buttons"
|
|
139
|
+
value={currentType}
|
|
140
|
+
options={$optionsStore.SELECT_TYPE_OPTIONS}
|
|
141
|
+
onUpdate={(item) => updateProperty('type', item.value as string)}
|
|
142
|
+
/>
|
|
143
|
+
</div>
|
|
144
|
+
<div class="flex w-1/3 flex-col items-center px-2">
|
|
145
|
+
<UI.Select
|
|
146
|
+
wrapperClass="w-full h-14"
|
|
147
|
+
label={{ name: $t('service.constructor.props.valuetype') }}
|
|
148
|
+
type="buttons"
|
|
149
|
+
options={$optionsStore.SELECT_VALUE_TYPE_OPTIONS}
|
|
150
|
+
value={currentValueType}
|
|
151
|
+
onUpdate={(value) => {
|
|
152
|
+
currentValueType = value as ValueTypeOption
|
|
153
|
+
const options = [...(component.properties?.options || [])]
|
|
154
|
+
const newType = value.value
|
|
155
|
+
options.forEach((option) => {
|
|
156
|
+
if (newType === 'number') option.value = option.value !== undefined ? Number(option.value) : 0
|
|
157
|
+
else option.value = option.value !== undefined ? String(option.value) : ''
|
|
158
|
+
})
|
|
159
|
+
updateProperty('options', options)
|
|
160
|
+
}}
|
|
161
|
+
/>
|
|
162
|
+
<UI.Select
|
|
163
|
+
wrapperClass="w-full h-14"
|
|
164
|
+
label={{ name: $t('service.constructor.props.colors') }}
|
|
165
|
+
type="buttons"
|
|
166
|
+
options={$optionsStore.COLOR_OPTIONS}
|
|
167
|
+
value={initialColor}
|
|
168
|
+
onUpdate={(option) => handleOptionColorChange(option.value as string)}
|
|
169
|
+
/>
|
|
170
|
+
</div>
|
|
171
|
+
<div class="flex w-1/3 flex-col items-center px-2">
|
|
172
|
+
<UI.Input
|
|
173
|
+
label={{ name: $t('service.constructor.props.label') }}
|
|
174
|
+
value={component.properties.label.name}
|
|
175
|
+
type="text"
|
|
176
|
+
componentClass="w-full"
|
|
177
|
+
onUpdate={(value) => updateProperty('label.name', value as string)}
|
|
178
|
+
/>
|
|
179
|
+
<UI.Select
|
|
180
|
+
wrapperClass="w-full"
|
|
181
|
+
label={{ name: $t('service.constructor.props.align') }}
|
|
182
|
+
type="buttons"
|
|
183
|
+
value={initialAlign}
|
|
184
|
+
options={$optionsStore.ALIGN_OPTIONS}
|
|
185
|
+
onUpdate={(option) => handleLabelAlign(option.value as string)}
|
|
186
|
+
/>
|
|
187
|
+
</div>
|
|
188
|
+
</div>
|
|
189
|
+
|
|
190
|
+
<hr class="border-gray-400" />
|
|
191
|
+
|
|
192
|
+
<!-- Настройки опций -->
|
|
193
|
+
<div class="space-y-4">
|
|
194
|
+
<div class="m-0 flex items-center justify-center gap-2">
|
|
195
|
+
<h4>{$t('service.constructor.props.options.title')}</h4>
|
|
196
|
+
<UI.Button
|
|
197
|
+
wrapperClass="!w-10"
|
|
198
|
+
icon={{ component: ButtonAdd, properties: { height: '1.5rem', width: '1.5rem' } }}
|
|
199
|
+
componentClass="h-10 border-none hover:shadow-none"
|
|
200
|
+
onClick={() => {
|
|
201
|
+
const newOption: ISelectOption = {
|
|
202
|
+
id: crypto.randomUUID(),
|
|
203
|
+
name: 'New Button',
|
|
204
|
+
class: '',
|
|
205
|
+
}
|
|
206
|
+
const options = [...(component.properties?.options || []), newOption]
|
|
207
|
+
updateProperty('options', options)
|
|
208
|
+
}}
|
|
209
|
+
/>
|
|
210
|
+
</div>
|
|
211
|
+
|
|
212
|
+
{#each component.properties.options || [] as option, index (option.id)}
|
|
213
|
+
<div class="m-0 flex items-end justify-around gap-2 border-gray-400">
|
|
214
|
+
<UI.Input
|
|
215
|
+
label={{ name: $t('service.constructor.props.optionname') }}
|
|
216
|
+
wrapperClass="!w-3/10"
|
|
217
|
+
value={option.name}
|
|
218
|
+
type="text"
|
|
219
|
+
onUpdate={(value) => {
|
|
220
|
+
const options = [...(component.properties?.options || [])]
|
|
221
|
+
options[index]['name'] = value
|
|
222
|
+
updateProperty('options', options)
|
|
223
|
+
}}
|
|
224
|
+
/>
|
|
225
|
+
<UI.Input
|
|
226
|
+
label={{ name: $t('service.constructor.props.optionvalue') }}
|
|
227
|
+
wrapperClass="!w-3/10"
|
|
228
|
+
value={option.value}
|
|
229
|
+
type={currentValueType.value}
|
|
230
|
+
onUpdate={(value) => {
|
|
231
|
+
const options = [...(component.properties?.options || [])]
|
|
232
|
+
options[index]['value'] = value
|
|
233
|
+
updateProperty('options', options)
|
|
234
|
+
}}
|
|
235
|
+
/>
|
|
236
|
+
<UI.Input
|
|
237
|
+
label={{ name: $t('service.constructor.props.optionclass') }}
|
|
238
|
+
wrapperClass="!w-3/10"
|
|
239
|
+
value={option.class}
|
|
240
|
+
type="text"
|
|
241
|
+
onUpdate={(value) => {
|
|
242
|
+
const options = [...(component.properties?.options || [])]
|
|
243
|
+
options[index]['class'] = value
|
|
244
|
+
updateProperty('options', options)
|
|
245
|
+
}}
|
|
246
|
+
/>
|
|
247
|
+
<UI.Button
|
|
248
|
+
wrapperClass="!w-1/10"
|
|
249
|
+
icon={{ component: ButtonDelete, properties: { height: '1.5rem', width: '1.5rem' } }}
|
|
250
|
+
componentClass="h-10 w-10 border-none hover:shadow-none"
|
|
251
|
+
onClick={() => {
|
|
252
|
+
const options = [...(component.properties?.options || [])]
|
|
253
|
+
options.splice(index, 1)
|
|
254
|
+
updateProperty('options', options)
|
|
255
|
+
}}
|
|
256
|
+
/>
|
|
257
|
+
</div>
|
|
258
|
+
{/each}
|
|
259
|
+
</div>
|
|
260
|
+
{/if}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { UIComponent, ISelectProps } from '../types.js';
|
|
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;
|