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,200 +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}
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}