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,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,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,10 @@
|
|
|
1
|
+
import type { IAccordionProps, UIComponent } from '../types';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
component: UIComponent & {
|
|
4
|
+
properties: Partial<IAccordionProps>;
|
|
5
|
+
};
|
|
6
|
+
onPropertyChange: (value: string | object) => void;
|
|
7
|
+
};
|
|
8
|
+
declare const AccordionProps: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
9
|
+
type AccordionProps = ReturnType<typeof AccordionProps>;
|
|
10
|
+
export default AccordionProps;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
<!-- $lib/ElementsUI/Button.svelte -->
|
|
2
2
|
<script lang="ts">
|
|
3
3
|
import { onMount } from 'svelte'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Header?: string
|
|
9
|
-
Argument?: string
|
|
10
|
-
|
|
4
|
+
// import { type IButtonProps } from '../types'
|
|
5
|
+
import { fly } from 'svelte/transition'
|
|
6
|
+
|
|
7
|
+
interface IUIComponentHandler {
|
|
8
|
+
Header?: string
|
|
9
|
+
Argument?: string
|
|
10
|
+
Value?: string
|
|
11
|
+
Variables?: string[]
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
export interface IButtonProps {
|
|
14
|
+
interface IButtonProps {
|
|
15
15
|
id?: { value?: string; name?: string }
|
|
16
16
|
wrapperClass?: string
|
|
17
17
|
label?: { name?: string; class?: string }
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
component?: ConstructorOfATypedSvelteComponent | null
|
|
22
22
|
properties?: Record<string, unknown>
|
|
23
23
|
}
|
|
24
|
+
info?: string
|
|
24
25
|
keyBind?: {
|
|
25
26
|
key?: string
|
|
26
27
|
ctrlKey?: boolean
|
|
@@ -30,33 +31,33 @@
|
|
|
30
31
|
}
|
|
31
32
|
disabled?: boolean
|
|
32
33
|
eventHandler?: IUIComponentHandler
|
|
33
|
-
onClick?: (
|
|
34
|
-
onKeyBind?: (id: string, eventHandler: IUIComponentHandler) => void
|
|
34
|
+
onClick?: () => void
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
let {
|
|
38
38
|
id = { value: crypto.randomUUID(), name: '' },
|
|
39
|
-
wrapperClass = '',
|
|
39
|
+
wrapperClass = 'bg-blue',
|
|
40
40
|
label = { name: '', class: '' },
|
|
41
41
|
name = '',
|
|
42
42
|
componentClass = '',
|
|
43
43
|
icon = { component: null, properties: {} },
|
|
44
|
+
info = '',
|
|
44
45
|
disabled = false,
|
|
45
46
|
keyBind,
|
|
46
|
-
eventHandler = { Action: 'none' },
|
|
47
47
|
onClick,
|
|
48
|
-
onKeyBind,
|
|
49
48
|
}: IButtonProps = $props()
|
|
50
49
|
|
|
50
|
+
let showInfo = $state(false)
|
|
51
|
+
|
|
51
52
|
/* Обработчик клика */
|
|
52
53
|
const handleClick = () => {
|
|
53
54
|
if (disabled || !onClick) return
|
|
54
|
-
onClick(
|
|
55
|
+
onClick()
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
/* Обработчик горячих клавиш */
|
|
58
59
|
const handleKeyDown = (event: KeyboardEvent) => {
|
|
59
|
-
if (disabled || !keyBind || !
|
|
60
|
+
if (disabled || !keyBind || !onClick) return
|
|
60
61
|
|
|
61
62
|
const isKeyMatch = event.key === keyBind.key
|
|
62
63
|
const isCtrlMatch = keyBind.ctrlKey === undefined || event.ctrlKey === keyBind.ctrlKey
|
|
@@ -66,7 +67,7 @@
|
|
|
66
67
|
|
|
67
68
|
if (isKeyMatch && isCtrlMatch && isShiftMatch && isAltMatch && isMetaMatch) {
|
|
68
69
|
event.preventDefault()
|
|
69
|
-
|
|
70
|
+
onClick()
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
|
|
@@ -92,16 +93,22 @@
|
|
|
92
93
|
<button
|
|
93
94
|
id={id.value}
|
|
94
95
|
class={`
|
|
95
|
-
relative m-0 inline-block w-full items-center rounded-2xl border border-[var(--
|
|
96
|
+
relative m-0 inline-block w-full items-center rounded-2xl border border-[var(--bg-color)] bg-[var(--bg-color)]
|
|
96
97
|
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-
|
|
98
|
+
${disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer hover:shadow-md active:scale-97'}
|
|
98
99
|
${componentClass}
|
|
99
100
|
`}
|
|
100
101
|
onclick={handleClick}
|
|
101
102
|
{disabled}
|
|
102
103
|
aria-label={name || label.name}
|
|
104
|
+
onmouseenter={() => {
|
|
105
|
+
if (info) showInfo = true
|
|
106
|
+
}}
|
|
107
|
+
onmouseleave={() => {
|
|
108
|
+
if (info) showInfo = false
|
|
109
|
+
}}
|
|
103
110
|
>
|
|
104
|
-
<span class="flex flex-row items-center justify-center gap-
|
|
111
|
+
<span class="flex flex-row items-center justify-center gap-2">
|
|
105
112
|
{#if icon?.component}
|
|
106
113
|
{@const IconComponent = icon?.component}
|
|
107
114
|
<IconComponent {...icon?.properties} />
|
|
@@ -111,15 +118,27 @@
|
|
|
111
118
|
{name}
|
|
112
119
|
{#if keyBind}
|
|
113
120
|
<div class="text-xs opacity-70">
|
|
114
|
-
({keyBind.ctrlKey ? 'Ctrl+' : ''}
|
|
115
|
-
{keyBind.shiftKey ? 'Shift+' : ''}
|
|
116
|
-
{keyBind.altKey ? 'Alt+' : ''}
|
|
117
|
-
{keyBind.key})
|
|
121
|
+
({keyBind.ctrlKey ? 'Ctrl+' : ''}{keyBind.shiftKey ? 'Shift+' : ''}{keyBind.altKey ? 'Alt+' : ''}{keyBind.key})
|
|
118
122
|
</div>
|
|
119
123
|
{/if}
|
|
120
124
|
</div>
|
|
121
125
|
{/if}
|
|
122
126
|
</span>
|
|
123
127
|
</button>
|
|
128
|
+
|
|
129
|
+
{#if showInfo}
|
|
130
|
+
<div
|
|
131
|
+
transition:fly={{ y: -15, duration: 300 }}
|
|
132
|
+
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"
|
|
133
|
+
style="background: color-mix(in srgb, var(--yellow-color) 30%, var(--back-color)); transform: translateX(-50%);"
|
|
134
|
+
>
|
|
135
|
+
{info}
|
|
136
|
+
<!-- Треугольная стрелка -->
|
|
137
|
+
<div
|
|
138
|
+
class="absolute top-full left-1/2 h-2 w-2 -translate-x-1/2 -translate-y-1/2 rotate-45 transform"
|
|
139
|
+
style="background: color-mix(in srgb, var(--yellow-color) 30%, var(--back-color));"
|
|
140
|
+
></div>
|
|
141
|
+
</div>
|
|
142
|
+
{/if}
|
|
124
143
|
</div>
|
|
125
144
|
</div>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Action: string;
|
|
1
|
+
interface IUIComponentHandler {
|
|
3
2
|
Header?: string;
|
|
4
3
|
Argument?: string;
|
|
4
|
+
Value?: string;
|
|
5
5
|
Variables?: string[];
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
interface IButtonProps {
|
|
8
8
|
id?: {
|
|
9
9
|
value?: string;
|
|
10
10
|
name?: string;
|
|
@@ -20,6 +20,7 @@ export interface IButtonProps {
|
|
|
20
20
|
component?: ConstructorOfATypedSvelteComponent | null;
|
|
21
21
|
properties?: Record<string, unknown>;
|
|
22
22
|
};
|
|
23
|
+
info?: string;
|
|
23
24
|
keyBind?: {
|
|
24
25
|
key?: string;
|
|
25
26
|
ctrlKey?: boolean;
|
|
@@ -29,8 +30,7 @@ export interface IButtonProps {
|
|
|
29
30
|
};
|
|
30
31
|
disabled?: boolean;
|
|
31
32
|
eventHandler?: IUIComponentHandler;
|
|
32
|
-
onClick?: (
|
|
33
|
-
onKeyBind?: (id: string, eventHandler: IUIComponentHandler) => void;
|
|
33
|
+
onClick?: () => void;
|
|
34
34
|
}
|
|
35
35
|
declare const Button: import("svelte").Component<IButtonProps, {}, "">;
|
|
36
36
|
type Button = ReturnType<typeof Button>;
|
|
@@ -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,10 @@
|
|
|
1
|
+
import type { UIComponent, IButtonProps } from '../types';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
component: UIComponent & {
|
|
4
|
+
properties: Partial<IButtonProps>;
|
|
5
|
+
};
|
|
6
|
+
onPropertyChange: (value: string | object) => void;
|
|
7
|
+
};
|
|
8
|
+
declare const ButtonProps: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
9
|
+
type ButtonProps = ReturnType<typeof ButtonProps>;
|
|
10
|
+
export default ButtonProps;
|