poe-svelte-ui-lib 1.0.0 → 1.0.2

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 (36) hide show
  1. package/LICENSE +3 -3
  2. package/dist/Accordion/Accordion.svelte +53 -53
  3. package/dist/Accordion/AccordionProps.svelte +70 -70
  4. package/dist/Button/Button.svelte +144 -144
  5. package/dist/Button/ButtonProps.svelte +200 -200
  6. package/dist/ColorPicker/ColorPicker.svelte +207 -207
  7. package/dist/ColorPicker/ColorPickerProps.svelte +100 -100
  8. package/dist/FileAttach/FileAttach.svelte +103 -103
  9. package/dist/Graph/Graph.svelte +270 -270
  10. package/dist/Graph/GraphProps.svelte +56 -56
  11. package/dist/Input/Input.svelte +239 -239
  12. package/dist/Input/InputProps.svelte +221 -221
  13. package/dist/Loader.svelte +12 -12
  14. package/dist/MessageModal.svelte +54 -54
  15. package/dist/ProgressBar/ProgressBar.svelte +48 -48
  16. package/dist/ProgressBar/ProgressBarProps.svelte +145 -145
  17. package/dist/Select/Select.svelte +191 -187
  18. package/dist/Select/SelectProps.svelte +260 -260
  19. package/dist/Slider/Slider.svelte +260 -260
  20. package/dist/Slider/SliderProps.svelte +161 -161
  21. package/dist/Switch/Switch.svelte +83 -83
  22. package/dist/Switch/SwitchProps.svelte +144 -144
  23. package/dist/Table/Table.svelte +276 -276
  24. package/dist/Table/TableProps.svelte +286 -286
  25. package/dist/TextField/TextField.svelte +22 -22
  26. package/dist/TextField/TextFieldProps.svelte +92 -92
  27. package/dist/{appIcons → libIcons}/ButtonAdd.svelte +10 -10
  28. package/dist/{appIcons → libIcons}/ButtonDelete.svelte +13 -13
  29. package/dist/{appIcons → libIcons}/LoaderRotate.svelte +9 -9
  30. package/dist/locales/CircleFlagsEn.svelte +14 -14
  31. package/dist/locales/CircleFlagsRu.svelte +8 -8
  32. package/dist/locales/CircleFlagsZh.svelte +8 -8
  33. package/package.json +49 -47
  34. /package/dist/{appIcons → libIcons}/ButtonAdd.svelte.d.ts +0 -0
  35. /package/dist/{appIcons → libIcons}/ButtonDelete.svelte.d.ts +0 -0
  36. /package/dist/{appIcons → libIcons}/LoaderRotate.svelte.d.ts +0 -0
@@ -1,144 +1,144 @@
1
- <!-- $lib/ElementsUI/SwitchProps.svelte -->
2
- <script lang="ts">
3
- import { getContext } from 'svelte'
4
- import { t } from '../locales/i18n'
5
- import type { UIComponent, ISwitchProps } from '../types'
6
- import * as UI from '../index'
7
- import { optionsStore } from '../options'
8
-
9
- const { component, onPropertyChange } = $props<{
10
- component: UIComponent & { properties: Partial<ISwitchProps> }
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 initialColor = $derived(
24
- $optionsStore.COLOR_OPTIONS.find((c) =>
25
- (c.value as string).includes(component.properties.wrapperClass?.split(' ').find((cls: string) => cls.startsWith('bg-'))),
26
- ),
27
- )
28
-
29
- const initialAlign = $derived(
30
- $optionsStore.ALIGN_OPTIONS.find((a) =>
31
- (a.value as string).includes(component.properties.label?.class?.split(' ').find((cls: string) => cls.startsWith('text-'))),
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('wrapperClass', 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
- /* Обновление свойства */
61
- const updateProperty = (path: string, value: string | object | boolean | number) => {
62
- const newProperties = JSON.parse(JSON.stringify(component.properties))
63
- const parts = path.split('.')
64
- let obj = newProperties
65
-
66
- for (let i = 0; i < parts.length - 1; i++) {
67
- const part = parts[i]
68
- if (!obj[part]) obj[part] = {}
69
- obj = obj[part]
70
- }
71
-
72
- obj[parts[parts.length - 1]] = value
73
- onPropertyChange(newProperties)
74
- }
75
- </script>
76
-
77
- {#if component && component.properties}
78
- <div class="relative flex flex-row items-start justify-center">
79
- <!-- Сообщение для отправки в ws по нажатию кнопки -->
80
- <div class="flex w-1/3 flex-col items-center px-2">
81
- <UI.Select
82
- label={{ name: $t('service.constructor.props.variable') }}
83
- options={VARIABLE_OPTIONS}
84
- value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id.value)}
85
- onUpdate={(value) => {
86
- updateProperty('id.name', (value.name as string).split('|')[1].trim())
87
- updateProperty('id.value', value.value as string)
88
- updateProperty('eventHandler.Variables', value.value as string)
89
- }}
90
- />
91
- <UI.Select
92
- label={{ name: $t('service.constructor.props.action') }}
93
- type="buttons"
94
- value={$optionsStore.SHORT_ARGUMENT_OPTION.find((h) => h.value === component.properties.eventHandler.Argument)}
95
- options={$optionsStore.SHORT_ARGUMENT_OPTION}
96
- onUpdate={(option) => {
97
- updateProperty('eventHandler.Argument', option.value as string)
98
- }}
99
- />
100
- </div>
101
- <div class="flex w-1/3 flex-col px-2">
102
- <UI.Input
103
- label={{ name: $t('service.constructor.props.caption.left') }}
104
- value={component.properties.label.captionLeft}
105
- type="text"
106
- onUpdate={(value) => updateProperty('label.captionLeft', value as string)}
107
- />
108
- <UI.Input
109
- label={{ name: $t('service.constructor.props.caption.right') }}
110
- value={component.properties.label.captionRight}
111
- type="text"
112
- onUpdate={(value) => updateProperty('label.captionRight', value as string)}
113
- />
114
- <UI.Switch
115
- label={{ name: $t('service.constructor.props.disabled') }}
116
- value={component.properties.disabled ? 2 : 1}
117
- onChange={(value) => updateProperty('disabled', value === 2)}
118
- />
119
- </div>
120
- <div class="flex w-1/3 flex-col px-2">
121
- <UI.Input
122
- label={{ name: $t('service.constructor.props.label') }}
123
- value={component.properties.label.name}
124
- type="text"
125
- onUpdate={(value) => updateProperty('label.name', value as string)}
126
- />
127
- <UI.Select
128
- label={{ name: $t('service.constructor.props.align') }}
129
- type="buttons"
130
- value={initialAlign}
131
- options={$optionsStore.ALIGN_OPTIONS}
132
- onUpdate={(option) => handleLabelAlign(option.value as string)}
133
- />
134
- <UI.Select
135
- wrapperClass="!h-14"
136
- label={{ name: $t('service.constructor.props.colors') }}
137
- type="buttons"
138
- options={$optionsStore.COLOR_OPTIONS}
139
- value={initialColor}
140
- onUpdate={(option) => handleOptionColorChange(option.value as string)}
141
- />
142
- </div>
143
- </div>
144
- {/if}
1
+ <!-- $lib/ElementsUI/SwitchProps.svelte -->
2
+ <script lang="ts">
3
+ import { getContext } from 'svelte'
4
+ import { t } from '../locales/i18n'
5
+ import type { UIComponent, ISwitchProps } from '../types'
6
+ import * as UI from '../index'
7
+ import { optionsStore } from '../options'
8
+
9
+ const { component, onPropertyChange } = $props<{
10
+ component: UIComponent & { properties: Partial<ISwitchProps> }
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 initialColor = $derived(
24
+ $optionsStore.COLOR_OPTIONS.find((c) =>
25
+ (c.value as string).includes(component.properties.wrapperClass?.split(' ').find((cls: string) => cls.startsWith('bg-'))),
26
+ ),
27
+ )
28
+
29
+ const initialAlign = $derived(
30
+ $optionsStore.ALIGN_OPTIONS.find((a) =>
31
+ (a.value as string).includes(component.properties.label?.class?.split(' ').find((cls: string) => cls.startsWith('text-'))),
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('wrapperClass', 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
+ /* Обновление свойства */
61
+ const updateProperty = (path: string, value: string | object | boolean | number) => {
62
+ const newProperties = JSON.parse(JSON.stringify(component.properties))
63
+ const parts = path.split('.')
64
+ let obj = newProperties
65
+
66
+ for (let i = 0; i < parts.length - 1; i++) {
67
+ const part = parts[i]
68
+ if (!obj[part]) obj[part] = {}
69
+ obj = obj[part]
70
+ }
71
+
72
+ obj[parts[parts.length - 1]] = value
73
+ onPropertyChange(newProperties)
74
+ }
75
+ </script>
76
+
77
+ {#if component && component.properties}
78
+ <div class="relative flex flex-row items-start justify-center">
79
+ <!-- Сообщение для отправки в ws по нажатию кнопки -->
80
+ <div class="flex w-1/3 flex-col items-center px-2">
81
+ <UI.Select
82
+ label={{ name: $t('service.constructor.props.variable') }}
83
+ options={VARIABLE_OPTIONS}
84
+ value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id.value)}
85
+ onUpdate={(value) => {
86
+ updateProperty('id.name', (value.name as string).split('|')[1].trim())
87
+ updateProperty('id.value', value.value as string)
88
+ updateProperty('eventHandler.Variables', value.value as string)
89
+ }}
90
+ />
91
+ <UI.Select
92
+ label={{ name: $t('service.constructor.props.action') }}
93
+ type="buttons"
94
+ value={$optionsStore.SHORT_ARGUMENT_OPTION.find((h) => h.value === component.properties.eventHandler.Argument)}
95
+ options={$optionsStore.SHORT_ARGUMENT_OPTION}
96
+ onUpdate={(option) => {
97
+ updateProperty('eventHandler.Argument', option.value as string)
98
+ }}
99
+ />
100
+ </div>
101
+ <div class="flex w-1/3 flex-col px-2">
102
+ <UI.Input
103
+ label={{ name: $t('service.constructor.props.caption.left') }}
104
+ value={component.properties.label.captionLeft}
105
+ type="text"
106
+ onUpdate={(value) => updateProperty('label.captionLeft', value as string)}
107
+ />
108
+ <UI.Input
109
+ label={{ name: $t('service.constructor.props.caption.right') }}
110
+ value={component.properties.label.captionRight}
111
+ type="text"
112
+ onUpdate={(value) => updateProperty('label.captionRight', value as string)}
113
+ />
114
+ <UI.Switch
115
+ label={{ name: $t('service.constructor.props.disabled') }}
116
+ value={component.properties.disabled ? 2 : 1}
117
+ onChange={(value) => updateProperty('disabled', value === 2)}
118
+ />
119
+ </div>
120
+ <div class="flex w-1/3 flex-col px-2">
121
+ <UI.Input
122
+ label={{ name: $t('service.constructor.props.label') }}
123
+ value={component.properties.label.name}
124
+ type="text"
125
+ onUpdate={(value) => updateProperty('label.name', value as string)}
126
+ />
127
+ <UI.Select
128
+ label={{ name: $t('service.constructor.props.align') }}
129
+ type="buttons"
130
+ value={initialAlign}
131
+ options={$optionsStore.ALIGN_OPTIONS}
132
+ onUpdate={(option) => handleLabelAlign(option.value as string)}
133
+ />
134
+ <UI.Select
135
+ wrapperClass="!h-14"
136
+ label={{ name: $t('service.constructor.props.colors') }}
137
+ type="buttons"
138
+ options={$optionsStore.COLOR_OPTIONS}
139
+ value={initialColor}
140
+ onUpdate={(option) => handleOptionColorChange(option.value as string)}
141
+ />
142
+ </div>
143
+ </div>
144
+ {/if}