poe-svelte-ui-lib 1.0.2 → 1.0.4

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.
Files changed (47) hide show
  1. package/README.md +1 -0
  2. package/dist/Button/Button.svelte +5 -38
  3. package/dist/Button/Button.svelte.d.ts +1 -34
  4. package/dist/ColorPicker/ColorPicker.svelte +1 -3
  5. package/dist/FileAttach/FileAttach.svelte +3 -3
  6. package/dist/Input/Input.svelte +21 -20
  7. package/dist/Select/Select.svelte +4 -6
  8. package/dist/Switch/Switch.svelte +3 -2
  9. package/dist/Table/Table.svelte +5 -6
  10. package/dist/index.d.ts +0 -11
  11. package/dist/index.js +0 -11
  12. package/dist/options.d.ts +11 -11
  13. package/dist/options.js +27 -27
  14. package/dist/types.d.ts +1 -1
  15. package/package.json +8 -9
  16. package/dist/Accordion/AccordionProps.svelte +0 -70
  17. package/dist/Accordion/AccordionProps.svelte.d.ts +0 -10
  18. package/dist/Button/ButtonProps.svelte +0 -200
  19. package/dist/Button/ButtonProps.svelte.d.ts +0 -10
  20. package/dist/ColorPicker/ColorPickerProps.svelte +0 -100
  21. package/dist/ColorPicker/ColorPickerProps.svelte.d.ts +0 -10
  22. package/dist/Graph/GraphProps.svelte +0 -56
  23. package/dist/Graph/GraphProps.svelte.d.ts +0 -10
  24. package/dist/Input/InputProps.svelte +0 -221
  25. package/dist/Input/InputProps.svelte.d.ts +0 -10
  26. package/dist/ProgressBar/ProgressBarProps.svelte +0 -145
  27. package/dist/ProgressBar/ProgressBarProps.svelte.d.ts +0 -10
  28. package/dist/Select/SelectProps.svelte +0 -260
  29. package/dist/Select/SelectProps.svelte.d.ts +0 -10
  30. package/dist/Slider/SliderProps.svelte +0 -161
  31. package/dist/Slider/SliderProps.svelte.d.ts +0 -10
  32. package/dist/Switch/SwitchProps.svelte +0 -144
  33. package/dist/Switch/SwitchProps.svelte.d.ts +0 -10
  34. package/dist/Table/TableProps.svelte +0 -286
  35. package/dist/Table/TableProps.svelte.d.ts +0 -10
  36. package/dist/TextField/TextFieldProps.svelte +0 -92
  37. package/dist/TextField/TextFieldProps.svelte.d.ts +0 -10
  38. package/dist/locales/CircleFlagsEn.svelte +0 -14
  39. package/dist/locales/CircleFlagsEn.svelte.d.ts +0 -26
  40. package/dist/locales/CircleFlagsRu.svelte +0 -8
  41. package/dist/locales/CircleFlagsRu.svelte.d.ts +0 -26
  42. package/dist/locales/CircleFlagsZh.svelte +0 -8
  43. package/dist/locales/CircleFlagsZh.svelte.d.ts +0 -26
  44. package/dist/locales/i18n.d.ts +0 -10
  45. package/dist/locales/i18n.js +0 -36
  46. package/dist/locales/translations.d.ts +0 -7
  47. package/dist/locales/translations.js +0 -450
@@ -1,70 +0,0 @@
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}
@@ -1,10 +0,0 @@
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,200 +0,0 @@
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}
@@ -1,10 +0,0 @@
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;
@@ -1,100 +0,0 @@
1
- <!-- $lib/ElementsUI/ButtonProps.svelte -->
2
- <script lang="ts">
3
- import { t } from '../locales/i18n'
4
- import type { UIComponent, IColorPickerProps } from '../types'
5
- import * as UI from '../index'
6
- import { getContext } from 'svelte'
7
- import { optionsStore } from '../options'
8
-
9
- const { component, onPropertyChange } = $props<{
10
- component: UIComponent & { properties: Partial<IColorPickerProps> }
11
- onPropertyChange: (value: string | object) => void
12
- }>()
13
-
14
- const DeviceVariables = getContext<{ value: string; name: string }[]>('DeviceVariables')
15
- let VARIABLE_OPTIONS = $derived(
16
- DeviceVariables.map((variable: { value: string; name: string }) => ({
17
- id: variable.name,
18
- value: variable.value,
19
- name: `${variable.value} | ${variable.name}`,
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 handleLabelAlign = (align: string) => {
30
- let labelClass = component.properties.label.class || ''
31
- labelClass = labelClass
32
- .split(' ')
33
- .filter((cls: string) => !cls.startsWith('text-'))
34
- .join(' ')
35
- if (align) {
36
- labelClass += ` ${align}`
37
- }
38
- updateProperty('label.class', labelClass)
39
- }
40
-
41
- /* Обновление свойства */
42
- const updateProperty = (path: string, value: string | object | string[]) => {
43
- const newProperties = JSON.parse(JSON.stringify(component.properties))
44
- const parts = path.split('.')
45
- let obj = newProperties
46
- for (let i = 0; i < parts.length - 1; i++) {
47
- const part = parts[i]
48
- if (!obj[part]) obj[part] = {}
49
- obj = obj[part]
50
- }
51
- obj[parts[parts.length - 1]] = value
52
- onPropertyChange(newProperties)
53
- }
54
- </script>
55
-
56
- {#if component && component.properties}
57
- <div class="relative flex flex-row items-start justify-center">
58
- <!-- Сообщение для отправки в ws по нажатию кнопки -->
59
- <div class="flex w-1/3 flex-col items-center px-2">
60
- <UI.Select
61
- label={{ name: $t('service.constructor.props.variable') }}
62
- options={VARIABLE_OPTIONS}
63
- value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id.value)}
64
- onUpdate={(value) => {
65
- updateProperty('id.name', (value.name as string).split('|')[1].trim())
66
- updateProperty('id.value', value.value as string)
67
- updateProperty('eventHandler.Variables', value.value as string)
68
- }}
69
- />
70
- <UI.Select
71
- wrapperClass="w-full"
72
- label={{ name: $t('service.constructor.props.action') }}
73
- type="buttons"
74
- value={$optionsStore.SHORT_ARGUMENT_OPTION.find((h) => h.value === component.properties.eventHandler.Argument)}
75
- options={$optionsStore.SHORT_ARGUMENT_OPTION}
76
- onUpdate={(option) => {
77
- updateProperty('eventHandler.Argument', option.value as string)
78
- }}
79
- />
80
- </div>
81
- <div class="flex w-1/3 flex-col px-2">
82
- <UI.Input
83
- wrapperClass="w-full"
84
- label={{ name: $t('service.constructor.props.label') }}
85
- value={component.properties.label.name}
86
- type="text"
87
- componentClass="w-full"
88
- onUpdate={(value) => updateProperty('label.name', value as string)}
89
- />
90
- <UI.Select
91
- wrapperClass="w-full"
92
- label={{ name: $t('service.constructor.props.align') }}
93
- type="buttons"
94
- value={initialAlign}
95
- options={$optionsStore.ALIGN_OPTIONS}
96
- onUpdate={(option) => handleLabelAlign(option.value as string)}
97
- />
98
- </div>
99
- </div>
100
- {/if}
@@ -1,10 +0,0 @@
1
- import type { UIComponent, IColorPickerProps } from '../types';
2
- type $$ComponentProps = {
3
- component: UIComponent & {
4
- properties: Partial<IColorPickerProps>;
5
- };
6
- onPropertyChange: (value: string | object) => void;
7
- };
8
- declare const ColorPickerProps: import("svelte").Component<$$ComponentProps, {}, "">;
9
- type ColorPickerProps = ReturnType<typeof ColorPickerProps>;
10
- export default ColorPickerProps;
@@ -1,56 +0,0 @@
1
- <!-- $lib/ElementsUI/SwitchProps.svelte -->
2
- <script lang="ts">
3
- import { getContext } from 'svelte'
4
- import { t } from '../locales/i18n'
5
- import type { UIComponent, IGraphProps } from '../types'
6
- import * as UI from '../index'
7
-
8
- const { component, onPropertyChange } = $props<{
9
- component: UIComponent & { properties: Partial<IGraphProps> }
10
- onPropertyChange: (value: string | object) => void
11
- }>()
12
-
13
- const DeviceVariables = getContext<{ value: string; name: string }[]>('DeviceVariables')
14
- let VARIABLE_OPTIONS = $derived(
15
- DeviceVariables.map((variable: { value: string; name: string }) => ({
16
- id: variable.name,
17
- value: variable.value,
18
- name: `${variable.value} | ${variable.name}`,
19
- })),
20
- )
21
-
22
- /* Обновление свойства */
23
- const updateProperty = (path: string, value: string | object) => {
24
- const newProperties = JSON.parse(JSON.stringify(component.properties))
25
- const parts = path.split('.')
26
- let obj = newProperties
27
-
28
- for (let i = 0; i < parts.length - 1; i++) {
29
- const part = parts[i]
30
- if (!obj[part]) obj[part] = {}
31
- obj = obj[part]
32
- }
33
-
34
- obj[parts[parts.length - 1]] = value
35
- onPropertyChange(newProperties)
36
- }
37
- </script>
38
-
39
- {#if component && component.properties}
40
- <div class="relative flex flex-row items-start justify-center">
41
- <!-- Сообщение для отправки в ws по нажатию кнопки -->
42
- <div class="flex w-1/3 flex-col items-center px-2">
43
- <UI.Select
44
- label={{ name: $t('service.constructor.props.variable') }}
45
- options={VARIABLE_OPTIONS}
46
- value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id.value)}
47
- onUpdate={(value) => {
48
- updateProperty('id.name', (value.name as string).split('|')[1].trim())
49
- updateProperty('id.value', value.value as string)
50
- }}
51
- />
52
- </div>
53
- <div class="flex w-1/3 flex-col px-2"></div>
54
- <div class="flex w-1/3 flex-col px-2"></div>
55
- </div>
56
- {/if}
@@ -1,10 +0,0 @@
1
- import type { UIComponent, IGraphProps } from '../types';
2
- type $$ComponentProps = {
3
- component: UIComponent & {
4
- properties: Partial<IGraphProps>;
5
- };
6
- onPropertyChange: (value: string | object) => void;
7
- };
8
- declare const GraphProps: import("svelte").Component<$$ComponentProps, {}, "">;
9
- type GraphProps = ReturnType<typeof GraphProps>;
10
- export default GraphProps;