poe-svelte-ui-lib 0.2.0 → 0.3.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 +14 -0
- package/dist/Accordion/AccordionProps.svelte +70 -0
- package/dist/Accordion/AccordionProps.svelte.d.ts +14 -0
- package/dist/{Button.svelte → Button/Button.svelte} +34 -45
- package/dist/Button/Button.svelte.d.ts +14 -0
- package/dist/Button/ButtonProps.svelte +200 -0
- package/dist/Button/ButtonProps.svelte.d.ts +14 -0
- package/dist/ColorPicker/ColorPicker.svelte +207 -0
- package/dist/ColorPicker/ColorPicker.svelte.d.ts +14 -0
- package/dist/ColorPicker/ColorPickerProps.svelte +100 -0
- package/dist/ColorPicker/ColorPickerProps.svelte.d.ts +14 -0
- package/dist/FileAttach/FileAttach.svelte +103 -0
- package/dist/FileAttach/FileAttach.svelte.d.ts +14 -0
- package/dist/Graph/Graph.svelte +270 -0
- package/dist/Graph/Graph.svelte.d.ts +14 -0
- package/dist/Graph/GraphProps.svelte +56 -0
- package/dist/Graph/GraphProps.svelte.d.ts +14 -0
- package/dist/Input/Input.svelte +239 -0
- package/dist/Input/Input.svelte.d.ts +14 -0
- package/dist/Input/InputProps.svelte +221 -0
- package/dist/Input/InputProps.svelte.d.ts +14 -0
- package/dist/Loader.svelte +12 -0
- package/dist/Loader.svelte.d.ts +14 -0
- package/dist/MessageModal.svelte +54 -0
- package/dist/MessageModal.svelte.d.ts +14 -0
- package/dist/ProgressBar/ProgressBar.svelte +48 -0
- package/dist/ProgressBar/ProgressBar.svelte.d.ts +14 -0
- package/dist/ProgressBar/ProgressBarProps.svelte +145 -0
- package/dist/ProgressBar/ProgressBarProps.svelte.d.ts +14 -0
- package/dist/Select/Select.svelte +187 -0
- package/dist/Select/Select.svelte.d.ts +14 -0
- package/dist/Select/SelectProps.svelte +260 -0
- package/dist/Select/SelectProps.svelte.d.ts +14 -0
- package/dist/Slider/Slider.svelte +260 -0
- package/dist/Slider/Slider.svelte.d.ts +14 -0
- package/dist/Slider/SliderProps.svelte +161 -0
- package/dist/Slider/SliderProps.svelte.d.ts +14 -0
- package/dist/Switch/Switch.svelte +83 -0
- package/dist/Switch/Switch.svelte.d.ts +14 -0
- package/dist/Switch/SwitchProps.svelte +144 -0
- package/dist/Switch/SwitchProps.svelte.d.ts +14 -0
- package/dist/Table/Table.svelte +276 -0
- package/dist/Table/Table.svelte.d.ts +14 -0
- package/dist/Table/TableProps.svelte +286 -0
- package/dist/Table/TableProps.svelte.d.ts +14 -0
- package/dist/TextField/TextField.svelte +22 -0
- package/dist/TextField/TextField.svelte.d.ts +14 -0
- package/dist/TextField/TextFieldProps.svelte +92 -0
- package/dist/TextField/TextFieldProps.svelte.d.ts +14 -0
- package/dist/appIcons/ButtonAdd.svelte +10 -0
- package/dist/appIcons/ButtonAdd.svelte.d.ts +14 -0
- package/dist/appIcons/ButtonDelete.svelte +13 -0
- package/dist/appIcons/ButtonDelete.svelte.d.ts +14 -0
- package/dist/appIcons/LoaderRotate.svelte +9 -0
- package/dist/appIcons/LoaderRotate.svelte.d.ts +14 -0
- package/dist/index.d.ts +25 -1
- package/dist/index.js +26 -2
- package/dist/locales/CircleFlagsEn.svelte +14 -0
- package/dist/locales/CircleFlagsEn.svelte.d.ts +23 -0
- package/dist/locales/CircleFlagsRu.svelte +8 -0
- package/dist/locales/CircleFlagsRu.svelte.d.ts +23 -0
- package/dist/locales/CircleFlagsZh.svelte +8 -0
- package/dist/locales/CircleFlagsZh.svelte.d.ts +23 -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 +24 -20
- package/dist/Button.svelte.d.ts +0 -37
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { slide } from 'svelte/transition'
|
|
3
|
+
import type { IAccordionProps } from '../types'
|
|
4
|
+
|
|
5
|
+
const props: IAccordionProps = $props()
|
|
6
|
+
let isOpen = $state(props.isOpen)
|
|
7
|
+
|
|
8
|
+
const toggle = () => (isOpen = !isOpen)
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<div
|
|
12
|
+
id={props.id?.value}
|
|
13
|
+
class="border-[var(--border-color)] p-0 transition-shadow duration-250 {props.type === 'sub'
|
|
14
|
+
? 'border-none'
|
|
15
|
+
: 'rounded-xl border bg-[var(--conteiner-color)] hover:shadow-md'}
|
|
16
|
+
{props.componentClass}"
|
|
17
|
+
transition:slide={{ duration: 250 }}
|
|
18
|
+
>
|
|
19
|
+
<button
|
|
20
|
+
class="flex w-full cursor-pointer items-center justify-between transition-shadow duration-250 sm:p-4 sm:px-6
|
|
21
|
+
{props.type === 'sub' ? 'border-b border-[var(--border-color)]' : ''}"
|
|
22
|
+
onclick={toggle}
|
|
23
|
+
>
|
|
24
|
+
<span class="toggle m-0 cursor-pointer text-lg font-semibold {props.label?.class}">
|
|
25
|
+
{props.label?.name}
|
|
26
|
+
</span>
|
|
27
|
+
<svg
|
|
28
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
29
|
+
class="arrow h-[1.1rem] w-[1.1rem] transition-transform duration-250"
|
|
30
|
+
style="transform: rotate({isOpen ? 180 : 0}deg)"
|
|
31
|
+
viewBox="0 0 24 24"
|
|
32
|
+
>
|
|
33
|
+
<path
|
|
34
|
+
fill="none"
|
|
35
|
+
stroke="currentColor"
|
|
36
|
+
stroke-linecap="round"
|
|
37
|
+
stroke-linejoin="round"
|
|
38
|
+
stroke-width="1.5"
|
|
39
|
+
d="M18 12.5s-4.419 6-6 6s-6-6-6-6m12-7s-4.419 6-6 6s-6-6-6-6"
|
|
40
|
+
color="currentColor"
|
|
41
|
+
/>
|
|
42
|
+
</svg>
|
|
43
|
+
</button>
|
|
44
|
+
|
|
45
|
+
{#if isOpen}
|
|
46
|
+
<div
|
|
47
|
+
class="flex w-full flex-wrap items-start justify-around p-4 sm:p-3 {props.type === 'sub' ? '' : 'border-t border-[var(--border-color)]'}"
|
|
48
|
+
transition:slide={{ duration: 250 }}
|
|
49
|
+
>
|
|
50
|
+
{@render props.children?.()}
|
|
51
|
+
</div>
|
|
52
|
+
{/if}
|
|
53
|
+
</div>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: Record<string, never>;
|
|
4
|
+
events: {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
};
|
|
7
|
+
slots: {};
|
|
8
|
+
};
|
|
9
|
+
export type AccordionProps = typeof __propDef.props;
|
|
10
|
+
export type AccordionEvents = typeof __propDef.events;
|
|
11
|
+
export type AccordionSlots = typeof __propDef.slots;
|
|
12
|
+
export default class Accordion extends SvelteComponentTyped<AccordionProps, AccordionEvents, AccordionSlots> {
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<!-- $lib/ElementsUI/AccordionProps.svelte -->
|
|
2
|
+
<script lang="ts">
|
|
3
|
+
import { t } from '../locales/i18n'
|
|
4
|
+
import type { IAccordionProps, UIComponent } from '../types'
|
|
5
|
+
import * as UI from '../index'
|
|
6
|
+
import { optionsStore } from '../options'
|
|
7
|
+
|
|
8
|
+
const { component, onPropertyChange } = $props<{
|
|
9
|
+
component: UIComponent & { properties: Partial<IAccordionProps> }
|
|
10
|
+
onPropertyChange: (value: string | object) => void
|
|
11
|
+
}>()
|
|
12
|
+
|
|
13
|
+
let currentType = $derived($optionsStore.ACCORDION_TYPE_OPTIONS.find((t) => t.value === component.properties.type))
|
|
14
|
+
|
|
15
|
+
/* Обновление свойства */
|
|
16
|
+
const updateProperty = (path: string, value: string | object) => {
|
|
17
|
+
const newProperties = JSON.parse(JSON.stringify(component.properties))
|
|
18
|
+
const parts = path.split('.')
|
|
19
|
+
let obj = newProperties
|
|
20
|
+
|
|
21
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
22
|
+
const part = parts[i]
|
|
23
|
+
if (!obj[part]) obj[part] = {}
|
|
24
|
+
obj = obj[part]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
obj[parts[parts.length - 1]] = value
|
|
28
|
+
onPropertyChange(newProperties)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const handleImageUpload = (event: Event) => {
|
|
32
|
+
const input = event.target as HTMLInputElement
|
|
33
|
+
if (!input.files || input.files.length === 0) return
|
|
34
|
+
|
|
35
|
+
const file = input.files[0]
|
|
36
|
+
const reader = new FileReader()
|
|
37
|
+
reader.onload = (e) => {
|
|
38
|
+
const base64String = e.target?.result as string
|
|
39
|
+
updateProperty('image', base64String)
|
|
40
|
+
}
|
|
41
|
+
reader.readAsDataURL(file)
|
|
42
|
+
}
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
{#if component && component.properties}
|
|
46
|
+
<div class="flex items-center justify-center gap-8">
|
|
47
|
+
<UI.Input
|
|
48
|
+
label={{ name: $t('service.constructor.props.label') }}
|
|
49
|
+
wrapperClass="!w-1/3"
|
|
50
|
+
value={component.properties.label.name}
|
|
51
|
+
onUpdate={(value) => updateProperty('label.name', value as string)}
|
|
52
|
+
type="text"
|
|
53
|
+
/>
|
|
54
|
+
<UI.Select
|
|
55
|
+
wrapperClass="!w-1/3"
|
|
56
|
+
label={{ name: $t('service.constructor.props.type') }}
|
|
57
|
+
type="buttons"
|
|
58
|
+
value={currentType}
|
|
59
|
+
options={$optionsStore.ACCORDION_TYPE_OPTIONS}
|
|
60
|
+
onUpdate={(item) => updateProperty('type', item.value as string)}
|
|
61
|
+
/>
|
|
62
|
+
<UI.FileAttach
|
|
63
|
+
type="image"
|
|
64
|
+
label={{ name: $t('service.constructor.props.image') }}
|
|
65
|
+
accept="image/png, image/jpeg, image/webp"
|
|
66
|
+
onChange={handleImageUpload}
|
|
67
|
+
/>
|
|
68
|
+
<UI.Button name={$t('service.constructor.props.removeimage')} wrapperClass="!w-auto" componentClass="px-4" onClick={() => updateProperty('image', '')} />
|
|
69
|
+
</div>
|
|
70
|
+
{/if}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: Record<string, never>;
|
|
4
|
+
events: {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
};
|
|
7
|
+
slots: {};
|
|
8
|
+
};
|
|
9
|
+
export type AccordionPropsProps = typeof __propDef.props;
|
|
10
|
+
export type AccordionPropsEvents = typeof __propDef.events;
|
|
11
|
+
export type AccordionPropsSlots = typeof __propDef.slots;
|
|
12
|
+
export default class AccordionProps extends SvelteComponentTyped<AccordionPropsProps, AccordionPropsEvents, AccordionPropsSlots> {
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -1,62 +1,33 @@
|
|
|
1
1
|
<!-- $lib/ElementsUI/Button.svelte -->
|
|
2
2
|
<script lang="ts">
|
|
3
3
|
import { onMount } from 'svelte'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export interface IUIComponentHandler {
|
|
7
|
-
Action: string // Действие (имя функции, как правило отправка в WebSocket)
|
|
8
|
-
Header?: string // Заголовок пакета
|
|
9
|
-
Argument?: string // Аргумент
|
|
10
|
-
Variables?: string[] // Массив переменных
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/* Интерфейс кнопки */
|
|
14
|
-
export interface IButtonProps {
|
|
15
|
-
id?: { value?: string; name?: string }
|
|
16
|
-
wrapperClass?: string
|
|
17
|
-
label?: { name?: string; class?: string }
|
|
18
|
-
componentClass?: string
|
|
19
|
-
name?: string
|
|
20
|
-
icon?: {
|
|
21
|
-
component?: ConstructorOfATypedSvelteComponent | null
|
|
22
|
-
properties?: Record<string, unknown>
|
|
23
|
-
}
|
|
24
|
-
keyBind?: {
|
|
25
|
-
key?: string
|
|
26
|
-
ctrlKey?: boolean
|
|
27
|
-
shiftKey?: boolean
|
|
28
|
-
altKey?: boolean
|
|
29
|
-
metaKey?: boolean /* Поддержка Meta (Cmd на Mac) */
|
|
30
|
-
}
|
|
31
|
-
disabled?: boolean
|
|
32
|
-
eventHandler?: IUIComponentHandler
|
|
33
|
-
onClick?: (id: string, eventHandler: IUIComponentHandler) => void
|
|
34
|
-
onKeyBind?: (id: string, eventHandler: IUIComponentHandler) => void
|
|
35
|
-
}
|
|
4
|
+
import { type IButtonProps } from '../types'
|
|
5
|
+
import { fly } from 'svelte/transition'
|
|
36
6
|
|
|
37
7
|
let {
|
|
38
8
|
id = { value: crypto.randomUUID(), name: '' },
|
|
39
|
-
wrapperClass = '',
|
|
9
|
+
wrapperClass = 'bg-blue',
|
|
40
10
|
label = { name: '', class: '' },
|
|
41
11
|
name = '',
|
|
42
12
|
componentClass = '',
|
|
43
13
|
icon = { component: null, properties: {} },
|
|
14
|
+
info = '',
|
|
44
15
|
disabled = false,
|
|
45
16
|
keyBind,
|
|
46
|
-
eventHandler = { Action: 'none' },
|
|
47
17
|
onClick,
|
|
48
|
-
onKeyBind,
|
|
49
18
|
}: IButtonProps = $props()
|
|
50
19
|
|
|
20
|
+
let showInfo = $state(false)
|
|
21
|
+
|
|
51
22
|
/* Обработчик клика */
|
|
52
23
|
const handleClick = () => {
|
|
53
24
|
if (disabled || !onClick) return
|
|
54
|
-
onClick(
|
|
25
|
+
onClick()
|
|
55
26
|
}
|
|
56
27
|
|
|
57
28
|
/* Обработчик горячих клавиш */
|
|
58
29
|
const handleKeyDown = (event: KeyboardEvent) => {
|
|
59
|
-
if (disabled || !keyBind || !
|
|
30
|
+
if (disabled || !keyBind || !onClick) return
|
|
60
31
|
|
|
61
32
|
const isKeyMatch = event.key === keyBind.key
|
|
62
33
|
const isCtrlMatch = keyBind.ctrlKey === undefined || event.ctrlKey === keyBind.ctrlKey
|
|
@@ -66,7 +37,7 @@
|
|
|
66
37
|
|
|
67
38
|
if (isKeyMatch && isCtrlMatch && isShiftMatch && isAltMatch && isMetaMatch) {
|
|
68
39
|
event.preventDefault()
|
|
69
|
-
|
|
40
|
+
onClick()
|
|
70
41
|
}
|
|
71
42
|
}
|
|
72
43
|
|
|
@@ -92,16 +63,22 @@
|
|
|
92
63
|
<button
|
|
93
64
|
id={id.value}
|
|
94
65
|
class={`
|
|
95
|
-
relative m-0 inline-block w-full items-center rounded-2xl border border-[var(--
|
|
66
|
+
relative m-0 inline-block w-full items-center rounded-2xl border border-[var(--bg-color)] bg-[var(--bg-color)]
|
|
96
67
|
px-2 py-1 font-semibold transition duration-200 select-none
|
|
97
|
-
${disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer hover:shadow-md active:scale-
|
|
68
|
+
${disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer hover:shadow-md active:scale-97'}
|
|
98
69
|
${componentClass}
|
|
99
70
|
`}
|
|
100
71
|
onclick={handleClick}
|
|
101
72
|
{disabled}
|
|
102
73
|
aria-label={name || label.name}
|
|
74
|
+
onmouseenter={() => {
|
|
75
|
+
if (info) showInfo = true
|
|
76
|
+
}}
|
|
77
|
+
onmouseleave={() => {
|
|
78
|
+
if (info) showInfo = false
|
|
79
|
+
}}
|
|
103
80
|
>
|
|
104
|
-
<span class="flex flex-row items-center justify-center gap-
|
|
81
|
+
<span class="flex flex-row items-center justify-center gap-2">
|
|
105
82
|
{#if icon?.component}
|
|
106
83
|
{@const IconComponent = icon?.component}
|
|
107
84
|
<IconComponent {...icon?.properties} />
|
|
@@ -111,15 +88,27 @@
|
|
|
111
88
|
{name}
|
|
112
89
|
{#if keyBind}
|
|
113
90
|
<div class="text-xs opacity-70">
|
|
114
|
-
({keyBind.ctrlKey ? 'Ctrl+' : ''}
|
|
115
|
-
{keyBind.shiftKey ? 'Shift+' : ''}
|
|
116
|
-
{keyBind.altKey ? 'Alt+' : ''}
|
|
117
|
-
{keyBind.key})
|
|
91
|
+
({keyBind.ctrlKey ? 'Ctrl+' : ''}{keyBind.shiftKey ? 'Shift+' : ''}{keyBind.altKey ? 'Alt+' : ''}{keyBind.key})
|
|
118
92
|
</div>
|
|
119
93
|
{/if}
|
|
120
94
|
</div>
|
|
121
95
|
{/if}
|
|
122
96
|
</span>
|
|
123
97
|
</button>
|
|
98
|
+
|
|
99
|
+
{#if showInfo}
|
|
100
|
+
<div
|
|
101
|
+
transition:fly={{ y: -15, duration: 300 }}
|
|
102
|
+
class="absolute bottom-full left-1/2 z-50 mb-2 w-max max-w-xs rounded-md px-3 py-1 text-sm shadow-lg"
|
|
103
|
+
style="background: color-mix(in srgb, var(--yellow-color) 30%, var(--back-color)); transform: translateX(-50%);"
|
|
104
|
+
>
|
|
105
|
+
{info}
|
|
106
|
+
<!-- Треугольная стрелка -->
|
|
107
|
+
<div
|
|
108
|
+
class="absolute top-full left-1/2 h-2 w-2 -translate-x-1/2 -translate-y-1/2 rotate-45 transform"
|
|
109
|
+
style="background: color-mix(in srgb, var(--yellow-color) 30%, var(--back-color));"
|
|
110
|
+
></div>
|
|
111
|
+
</div>
|
|
112
|
+
{/if}
|
|
124
113
|
</div>
|
|
125
114
|
</div>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: Record<string, never>;
|
|
4
|
+
events: {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
};
|
|
7
|
+
slots: {};
|
|
8
|
+
};
|
|
9
|
+
export type ButtonProps = typeof __propDef.props;
|
|
10
|
+
export type ButtonEvents = typeof __propDef.events;
|
|
11
|
+
export type ButtonSlots = typeof __propDef.slots;
|
|
12
|
+
export default class Button extends SvelteComponentTyped<ButtonProps, ButtonEvents, ButtonSlots> {
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
<!-- $lib/ElementsUI/ButtonProps.svelte -->
|
|
2
|
+
<script lang="ts">
|
|
3
|
+
import { t } from '../locales/i18n'
|
|
4
|
+
import type { UIComponent, IButtonProps, ISelectOption } from '../types'
|
|
5
|
+
import * as UI from '../index'
|
|
6
|
+
import { optionsStore } from '../options'
|
|
7
|
+
|
|
8
|
+
const { component, onPropertyChange } = $props<{
|
|
9
|
+
component: UIComponent & { properties: Partial<IButtonProps> }
|
|
10
|
+
onPropertyChange: (value: string | object) => void
|
|
11
|
+
}>()
|
|
12
|
+
|
|
13
|
+
let Header: ISelectOption = $derived(
|
|
14
|
+
$optionsStore.HEADER_OPTIONS.find((h) => h.value === component.properties.eventHandler.Header) ?? { id: '', name: '', value: '', class: '!w-1/4' },
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
const initialColor = $derived(
|
|
18
|
+
$optionsStore.COLOR_OPTIONS.find((c) =>
|
|
19
|
+
(c.value as string).includes(component.properties.componentClass?.split(' ').find((cls: string) => cls.startsWith('bg-'))),
|
|
20
|
+
),
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
const initialAlign = $derived(
|
|
24
|
+
$optionsStore.ALIGN_OPTIONS.find((a) =>
|
|
25
|
+
(a.value as string).includes(component.properties.label?.class?.split(' ').find((cls: string) => cls.startsWith('text-'))),
|
|
26
|
+
),
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
const initialHeight = $derived(
|
|
30
|
+
$optionsStore.HEIGHT_OPTIONS.find((h) =>
|
|
31
|
+
(h.value as string).includes(component.properties.componentClass?.split(' ').find((cls: string) => cls.startsWith('py-'))),
|
|
32
|
+
),
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
/* Добавление цветов через селект */
|
|
36
|
+
const handleOptionColorChange = (color: string) => {
|
|
37
|
+
let componentClass = component.properties.componentClass || ''
|
|
38
|
+
componentClass = componentClass
|
|
39
|
+
.split(' ')
|
|
40
|
+
.filter((cls: string) => !cls.startsWith('bg-'))
|
|
41
|
+
.join(' ')
|
|
42
|
+
if (color) {
|
|
43
|
+
componentClass += ` ${color}`
|
|
44
|
+
}
|
|
45
|
+
updateProperty('componentClass', componentClass)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const handleLabelAlign = (align: string) => {
|
|
49
|
+
let labelClass = component.properties.label.class || ''
|
|
50
|
+
labelClass = labelClass
|
|
51
|
+
.split(' ')
|
|
52
|
+
.filter((cls: string) => !cls.startsWith('text-'))
|
|
53
|
+
.join(' ')
|
|
54
|
+
if (align) {
|
|
55
|
+
labelClass += ` ${align}`
|
|
56
|
+
}
|
|
57
|
+
updateProperty('label.class', labelClass)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const handleButtonHeight = (height: string) => {
|
|
61
|
+
let buttonClass = component.properties.componentClass || ''
|
|
62
|
+
buttonClass = buttonClass
|
|
63
|
+
.split(' ')
|
|
64
|
+
.filter((cls: string) => !cls.startsWith('py-'))
|
|
65
|
+
.join(' ')
|
|
66
|
+
if (height) {
|
|
67
|
+
buttonClass += ` ${height}`
|
|
68
|
+
}
|
|
69
|
+
updateProperty('componentClass', buttonClass)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* Обновление свойства */
|
|
73
|
+
const updateProperty = (path: string, value: string | object | string[]) => {
|
|
74
|
+
const newProperties = JSON.parse(JSON.stringify(component.properties))
|
|
75
|
+
const parts = path.split('.')
|
|
76
|
+
let obj = newProperties
|
|
77
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
78
|
+
const part = parts[i]
|
|
79
|
+
if (!obj[part]) obj[part] = {}
|
|
80
|
+
obj = obj[part]
|
|
81
|
+
}
|
|
82
|
+
obj[parts[parts.length - 1]] = value
|
|
83
|
+
onPropertyChange(newProperties)
|
|
84
|
+
}
|
|
85
|
+
</script>
|
|
86
|
+
|
|
87
|
+
{#if component && component.properties}
|
|
88
|
+
<div class="relative flex flex-row items-start justify-center">
|
|
89
|
+
<!-- Сообщение для отправки в ws по нажатию кнопки -->
|
|
90
|
+
<div class="flex w-1/3 flex-col items-center px-2">
|
|
91
|
+
<UI.Select
|
|
92
|
+
wrapperClass="w-full"
|
|
93
|
+
label={{ name: $t('service.constructor.props.header') }}
|
|
94
|
+
type="buttons"
|
|
95
|
+
value={Header}
|
|
96
|
+
options={$optionsStore.HEADER_OPTIONS}
|
|
97
|
+
onUpdate={(option) => {
|
|
98
|
+
Header = option
|
|
99
|
+
updateProperty('eventHandler.Header', Header.value as string)
|
|
100
|
+
}}
|
|
101
|
+
/>
|
|
102
|
+
{#if Header.value === 'SET'}
|
|
103
|
+
<UI.Select
|
|
104
|
+
wrapperClass="w-full"
|
|
105
|
+
label={{ name: $t('service.constructor.props.argument') }}
|
|
106
|
+
type="buttons"
|
|
107
|
+
value={$optionsStore.FULL_ARGUMENT_OPTION.find((h) => h.value === component.properties.eventHandler.Argument)}
|
|
108
|
+
options={$optionsStore.FULL_ARGUMENT_OPTION}
|
|
109
|
+
onUpdate={(option) => {
|
|
110
|
+
updateProperty('eventHandler.Argument', option.value as string)
|
|
111
|
+
}}
|
|
112
|
+
/>
|
|
113
|
+
{/if}
|
|
114
|
+
{#if (component.properties.eventHandler.Argument !== 'Save' && component.properties.eventHandler.Argument !== 'NoSave') || Header.value !== 'SET'}
|
|
115
|
+
<UI.Input
|
|
116
|
+
wrapperClass="w-full {Header.value === 'SET' ? 'mt-1' : ''} "
|
|
117
|
+
label={{ name: Header.value === 'SET' ? '' : $t('service.constructor.props.argument') }}
|
|
118
|
+
value={component.properties.eventHandler.Argument}
|
|
119
|
+
type="text"
|
|
120
|
+
autocomplete="on"
|
|
121
|
+
componentClass="w-full"
|
|
122
|
+
maxlength={32}
|
|
123
|
+
regExp={/^[a-zA-Z0-9\-_]{0,32}$/}
|
|
124
|
+
help={{ info: $t('service.constructor.props.argument.info') }}
|
|
125
|
+
onUpdate={(value) => updateProperty('eventHandler.Argument', value as string)}
|
|
126
|
+
/>
|
|
127
|
+
<UI.Input
|
|
128
|
+
wrapperClass="w-full"
|
|
129
|
+
label={{ name: $t('service.constructor.props.value') }}
|
|
130
|
+
value={component.properties.eventHandler.Value}
|
|
131
|
+
type="text"
|
|
132
|
+
autocomplete="on"
|
|
133
|
+
componentClass="w-full"
|
|
134
|
+
maxlength={500}
|
|
135
|
+
regExp={/^[a-zA-Z0-9\-_ ":{}]{0,500}$/}
|
|
136
|
+
help={{ info: $t('service.constructor.props.value.info') }}
|
|
137
|
+
onUpdate={(value) => updateProperty('eventHandler.Value', value as string)}
|
|
138
|
+
/>
|
|
139
|
+
{/if}
|
|
140
|
+
<UI.Input
|
|
141
|
+
wrapperClass="w-full"
|
|
142
|
+
label={{ name: $t('service.constructor.props.variables') }}
|
|
143
|
+
value={component.properties.eventHandler.Variables.join(' ')}
|
|
144
|
+
type="text"
|
|
145
|
+
autocomplete="on"
|
|
146
|
+
componentClass="w-full"
|
|
147
|
+
maxlength={500}
|
|
148
|
+
regExp={/^[a-zA-Z0-9\-_ ]{0,500}$/}
|
|
149
|
+
help={{ info: $t('service.constructor.props.variables.info') }}
|
|
150
|
+
onUpdate={(value) => {
|
|
151
|
+
const parts = (value as string).trim().split(/\s+/)
|
|
152
|
+
updateProperty('eventHandler.Variables', parts)
|
|
153
|
+
}}
|
|
154
|
+
/>
|
|
155
|
+
</div>
|
|
156
|
+
<div class="flex w-1/3 flex-col px-2">
|
|
157
|
+
<UI.Input
|
|
158
|
+
wrapperClass="w-full"
|
|
159
|
+
label={{ name: $t('service.constructor.props.name') }}
|
|
160
|
+
value={component.properties.name}
|
|
161
|
+
type="text"
|
|
162
|
+
onUpdate={(value) => updateProperty('name', value as string)}
|
|
163
|
+
/>
|
|
164
|
+
<UI.Select
|
|
165
|
+
wrapperClass="w-full"
|
|
166
|
+
label={{ name: $t('service.constructor.props.height') }}
|
|
167
|
+
type="buttons"
|
|
168
|
+
options={$optionsStore.HEIGHT_OPTIONS}
|
|
169
|
+
value={initialHeight}
|
|
170
|
+
onUpdate={(option) => handleButtonHeight(option.value as string)}
|
|
171
|
+
/>
|
|
172
|
+
<UI.Select
|
|
173
|
+
wrapperClass="w-full h-14"
|
|
174
|
+
label={{ name: $t('service.constructor.props.colors') }}
|
|
175
|
+
type="buttons"
|
|
176
|
+
options={$optionsStore.COLOR_OPTIONS}
|
|
177
|
+
value={initialColor}
|
|
178
|
+
onUpdate={(option) => handleOptionColorChange(option.value as string)}
|
|
179
|
+
/>
|
|
180
|
+
</div>
|
|
181
|
+
<div class="flex w-1/3 flex-col px-2">
|
|
182
|
+
<UI.Input
|
|
183
|
+
wrapperClass="w-full"
|
|
184
|
+
label={{ name: $t('service.constructor.props.label') }}
|
|
185
|
+
value={component.properties.label.name}
|
|
186
|
+
type="text"
|
|
187
|
+
componentClass="w-full"
|
|
188
|
+
onUpdate={(value) => updateProperty('label.name', value as string)}
|
|
189
|
+
/>
|
|
190
|
+
<UI.Select
|
|
191
|
+
wrapperClass="w-full"
|
|
192
|
+
label={{ name: $t('service.constructor.props.align') }}
|
|
193
|
+
type="buttons"
|
|
194
|
+
value={initialAlign}
|
|
195
|
+
options={$optionsStore.ALIGN_OPTIONS}
|
|
196
|
+
onUpdate={(option) => handleLabelAlign(option.value as string)}
|
|
197
|
+
/>
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
{/if}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: Record<string, never>;
|
|
4
|
+
events: {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
};
|
|
7
|
+
slots: {};
|
|
8
|
+
};
|
|
9
|
+
export type ButtonPropsProps = typeof __propDef.props;
|
|
10
|
+
export type ButtonPropsEvents = typeof __propDef.events;
|
|
11
|
+
export type ButtonPropsSlots = typeof __propDef.slots;
|
|
12
|
+
export default class ButtonProps extends SvelteComponentTyped<ButtonPropsProps, ButtonPropsEvents, ButtonPropsSlots> {
|
|
13
|
+
}
|
|
14
|
+
export {};
|