poe-svelte-ui-lib 1.0.1 → 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 -191
  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,260 +1,260 @@
1
- <!-- $lib/ElementsUI/SelectProps.svelte -->
2
- <script lang="ts">
3
- import { getContext } from 'svelte'
4
- import { t } from '../locales/i18n'
5
- import type { UIComponent, ISelectProps, ISelectOption } from '../types.js'
6
- import * as UI from '../index'
7
- import ButtonDelete from '../appIcons/ButtonDelete.svelte'
8
- import ButtonAdd from '../appIcons/ButtonAdd.svelte'
9
-
10
- import { optionsStore } from '../options.js'
11
-
12
- const { component, onPropertyChange } = $props<{
13
- component: UIComponent & { properties: Partial<ISelectProps> }
14
- onPropertyChange: (path: string, value: string | object) => void
15
- }>()
16
-
17
- const DeviceVariables = getContext<{ value: string; name: string }[]>('DeviceVariables')
18
- let VARIABLE_OPTIONS = $derived(
19
- DeviceVariables.map((variable: { value: string; name: string }) => ({
20
- id: variable.name,
21
- value: variable.value,
22
- name: `${variable.value} | ${variable.name}`,
23
- })),
24
- )
25
-
26
- type ValueTypeOption = {
27
- id: string
28
- value: 'text' | 'number'
29
- name: string
30
- class: string
31
- }
32
- let currentValueType = $derived(
33
- !component.properties.options[0]
34
- ? ($optionsStore.SELECT_VALUE_TYPE_OPTIONS[0] as ValueTypeOption)
35
- : typeof component.properties.options[0].value === 'number'
36
- ? $optionsStore.SELECT_VALUE_TYPE_OPTIONS[1]
37
- : ($optionsStore.SELECT_VALUE_TYPE_OPTIONS[0] as ValueTypeOption),
38
- )
39
-
40
- let Header: ISelectOption = $derived(
41
- $optionsStore.HEADER_OPTIONS.find((h) => h.value === component.properties.eventHandler.Header) ?? { id: '', name: '', value: '', class: '!w-1/4' },
42
- )
43
-
44
- let currentType = $derived($optionsStore.SELECT_TYPE_OPTIONS.find((t) => t.value === component.properties.type))
45
-
46
- const initialColor = $derived(
47
- $optionsStore.COLOR_OPTIONS.find((c) =>
48
- (c.value as string).includes(component.properties.wrapperClass?.split(' ').find((cls: string) => cls.startsWith('bg-'))),
49
- ),
50
- )
51
-
52
- const initialAlign = $derived(
53
- $optionsStore.ALIGN_OPTIONS.find((a) =>
54
- (a.value as string).includes(component.properties.label?.class?.split(' ').find((cls: string) => cls.startsWith('text-'))),
55
- ),
56
- )
57
-
58
- const handleLabelAlign = (align: string) => {
59
- let labelClass = component.properties.label.class || ''
60
- labelClass = labelClass
61
- .split(' ')
62
- .filter((cls: string) => !cls.startsWith('text-'))
63
- .join(' ')
64
- if (align) {
65
- labelClass += ` ${align}`
66
- }
67
- updateProperty('label.class', labelClass)
68
- }
69
-
70
- const handleOptionColorChange = (color: string) => {
71
- let wrapperClass = component.properties.wrapperClass || ''
72
- wrapperClass = wrapperClass
73
- .split(' ')
74
- .filter((cls: string) => !cls.startsWith('bg-'))
75
- .join(' ')
76
- if (color) {
77
- wrapperClass += ` ${color}`
78
- }
79
- updateProperty('wrapperClass', wrapperClass)
80
- }
81
-
82
- /* Обновление свойства */
83
- const updateProperty = (path: string, value: string | object) => {
84
- const newProperties = JSON.parse(JSON.stringify(component.properties))
85
- const parts = path.split('.')
86
- let obj = newProperties
87
-
88
- for (let i = 0; i < parts.length - 1; i++) {
89
- const part = parts[i]
90
- if (!obj[part]) obj[part] = {}
91
- obj = obj[part]
92
- }
93
-
94
- obj[parts[parts.length - 1]] = value
95
- onPropertyChange(newProperties)
96
- }
97
- </script>
98
-
99
- {#if component && component.properties}
100
- <div class="relative mb-4 flex flex-row items-start justify-center">
101
- <div class="flex w-1/3 flex-col items-center px-2">
102
- <UI.Select
103
- wrapperClass="w-full"
104
- label={{ name: $t('service.constructor.props.argument') }}
105
- type="buttons"
106
- value={$optionsStore.FULL_ARGUMENT_OPTION.find((h) => h.value === component.properties.eventHandler.Argument)}
107
- options={$optionsStore.FULL_ARGUMENT_OPTION}
108
- onUpdate={(option) => {
109
- updateProperty('eventHandler.Argument', option.value as string)
110
- }}
111
- />
112
- {#if component.properties.eventHandler.Argument !== 'Save' && component.properties.eventHandler.Argument !== 'NoSave'}
113
- <UI.Input
114
- wrapperClass="w-full {Header.value === 'SET' ? 'mt-1' : ''} "
115
- label={{ name: $t('service.constructor.props.argument') }}
116
- value={component.properties.eventHandler.Argument}
117
- type="text"
118
- autocomplete="on"
119
- componentClass="w-full"
120
- maxlength={32}
121
- regExp={/^[a-zA-Z0-9\-_]{0,32}$/}
122
- help={{ info: $t('service.constructor.props.argument.info') }}
123
- onUpdate={(value) => updateProperty('eventHandler.Argument', value as string)}
124
- />
125
- {/if}
126
- <UI.Select
127
- label={{ name: $t('service.constructor.props.variable') }}
128
- options={VARIABLE_OPTIONS}
129
- value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id.value)}
130
- onUpdate={(value) => {
131
- updateProperty('id.name', (value.name as string).split('|')[1].trim())
132
- updateProperty('id.value', value.value as string)
133
- updateProperty('eventHandler.Variables', value.value as string)
134
- }}
135
- />
136
- <UI.Select
137
- label={{ name: $t('service.constructor.props.type') }}
138
- type="buttons"
139
- value={currentType}
140
- options={$optionsStore.SELECT_TYPE_OPTIONS}
141
- onUpdate={(item) => updateProperty('type', item.value as string)}
142
- />
143
- </div>
144
- <div class="flex w-1/3 flex-col items-center px-2">
145
- <UI.Select
146
- wrapperClass="w-full h-14"
147
- label={{ name: $t('service.constructor.props.valuetype') }}
148
- type="buttons"
149
- options={$optionsStore.SELECT_VALUE_TYPE_OPTIONS}
150
- value={currentValueType}
151
- onUpdate={(value) => {
152
- currentValueType = value as ValueTypeOption
153
- const options = [...(component.properties?.options || [])]
154
- const newType = value.value
155
- options.forEach((option) => {
156
- if (newType === 'number') option.value = option.value !== undefined ? Number(option.value) : 0
157
- else option.value = option.value !== undefined ? String(option.value) : ''
158
- })
159
- updateProperty('options', options)
160
- }}
161
- />
162
- <UI.Select
163
- wrapperClass="w-full h-14"
164
- label={{ name: $t('service.constructor.props.colors') }}
165
- type="buttons"
166
- options={$optionsStore.COLOR_OPTIONS}
167
- value={initialColor}
168
- onUpdate={(option) => handleOptionColorChange(option.value as string)}
169
- />
170
- </div>
171
- <div class="flex w-1/3 flex-col items-center px-2">
172
- <UI.Input
173
- label={{ name: $t('service.constructor.props.label') }}
174
- value={component.properties.label.name}
175
- type="text"
176
- componentClass="w-full"
177
- onUpdate={(value) => updateProperty('label.name', value as string)}
178
- />
179
- <UI.Select
180
- wrapperClass="w-full"
181
- label={{ name: $t('service.constructor.props.align') }}
182
- type="buttons"
183
- value={initialAlign}
184
- options={$optionsStore.ALIGN_OPTIONS}
185
- onUpdate={(option) => handleLabelAlign(option.value as string)}
186
- />
187
- </div>
188
- </div>
189
-
190
- <hr class="border-gray-400" />
191
-
192
- <!-- Настройки опций -->
193
- <div class="space-y-4">
194
- <div class="m-0 flex items-center justify-center gap-2">
195
- <h4>{$t('service.constructor.props.options.title')}</h4>
196
- <UI.Button
197
- wrapperClass="!w-10"
198
- icon={{ component: ButtonAdd, properties: { height: '1.5rem', width: '1.5rem' } }}
199
- componentClass="h-10 border-none hover:shadow-none"
200
- onClick={() => {
201
- const newOption: ISelectOption = {
202
- id: crypto.randomUUID(),
203
- name: 'New Button',
204
- class: '',
205
- }
206
- const options = [...(component.properties?.options || []), newOption]
207
- updateProperty('options', options)
208
- }}
209
- />
210
- </div>
211
-
212
- {#each component.properties.options || [] as option, index (option.id)}
213
- <div class="m-0 flex items-end justify-around gap-2 border-gray-400">
214
- <UI.Input
215
- label={{ name: $t('service.constructor.props.optionname') }}
216
- wrapperClass="!w-3/10"
217
- value={option.name}
218
- type="text"
219
- onUpdate={(value) => {
220
- const options = [...(component.properties?.options || [])]
221
- options[index]['name'] = value
222
- updateProperty('options', options)
223
- }}
224
- />
225
- <UI.Input
226
- label={{ name: $t('service.constructor.props.optionvalue') }}
227
- wrapperClass="!w-3/10"
228
- value={option.value}
229
- type={currentValueType.value}
230
- onUpdate={(value) => {
231
- const options = [...(component.properties?.options || [])]
232
- options[index]['value'] = value
233
- updateProperty('options', options)
234
- }}
235
- />
236
- <UI.Input
237
- label={{ name: $t('service.constructor.props.optionclass') }}
238
- wrapperClass="!w-3/10"
239
- value={option.class}
240
- type="text"
241
- onUpdate={(value) => {
242
- const options = [...(component.properties?.options || [])]
243
- options[index]['class'] = value
244
- updateProperty('options', options)
245
- }}
246
- />
247
- <UI.Button
248
- wrapperClass="!w-1/10"
249
- icon={{ component: ButtonDelete, properties: { height: '1.5rem', width: '1.5rem' } }}
250
- componentClass="h-10 w-10 border-none hover:shadow-none"
251
- onClick={() => {
252
- const options = [...(component.properties?.options || [])]
253
- options.splice(index, 1)
254
- updateProperty('options', options)
255
- }}
256
- />
257
- </div>
258
- {/each}
259
- </div>
260
- {/if}
1
+ <!-- $lib/ElementsUI/SelectProps.svelte -->
2
+ <script lang="ts">
3
+ import { getContext } from 'svelte'
4
+ import { t } from '../locales/i18n'
5
+ import type { UIComponent, ISelectProps, ISelectOption } from '../types.js'
6
+ import * as UI from '../index'
7
+ import ButtonDelete from '../libIcons/ButtonDelete.svelte'
8
+ import ButtonAdd from '../libIcons/ButtonAdd.svelte'
9
+
10
+ import { optionsStore } from '../options.js'
11
+
12
+ const { component, onPropertyChange } = $props<{
13
+ component: UIComponent & { properties: Partial<ISelectProps> }
14
+ onPropertyChange: (path: string, value: string | object) => void
15
+ }>()
16
+
17
+ const DeviceVariables = getContext<{ value: string; name: string }[]>('DeviceVariables')
18
+ let VARIABLE_OPTIONS = $derived(
19
+ DeviceVariables.map((variable: { value: string; name: string }) => ({
20
+ id: variable.name,
21
+ value: variable.value,
22
+ name: `${variable.value} | ${variable.name}`,
23
+ })),
24
+ )
25
+
26
+ type ValueTypeOption = {
27
+ id: string
28
+ value: 'text' | 'number'
29
+ name: string
30
+ class: string
31
+ }
32
+ let currentValueType = $derived(
33
+ !component.properties.options[0]
34
+ ? ($optionsStore.SELECT_VALUE_TYPE_OPTIONS[0] as ValueTypeOption)
35
+ : typeof component.properties.options[0].value === 'number'
36
+ ? $optionsStore.SELECT_VALUE_TYPE_OPTIONS[1]
37
+ : ($optionsStore.SELECT_VALUE_TYPE_OPTIONS[0] as ValueTypeOption),
38
+ )
39
+
40
+ let Header: ISelectOption = $derived(
41
+ $optionsStore.HEADER_OPTIONS.find((h) => h.value === component.properties.eventHandler.Header) ?? { id: '', name: '', value: '', class: '!w-1/4' },
42
+ )
43
+
44
+ let currentType = $derived($optionsStore.SELECT_TYPE_OPTIONS.find((t) => t.value === component.properties.type))
45
+
46
+ const initialColor = $derived(
47
+ $optionsStore.COLOR_OPTIONS.find((c) =>
48
+ (c.value as string).includes(component.properties.wrapperClass?.split(' ').find((cls: string) => cls.startsWith('bg-'))),
49
+ ),
50
+ )
51
+
52
+ const initialAlign = $derived(
53
+ $optionsStore.ALIGN_OPTIONS.find((a) =>
54
+ (a.value as string).includes(component.properties.label?.class?.split(' ').find((cls: string) => cls.startsWith('text-'))),
55
+ ),
56
+ )
57
+
58
+ const handleLabelAlign = (align: string) => {
59
+ let labelClass = component.properties.label.class || ''
60
+ labelClass = labelClass
61
+ .split(' ')
62
+ .filter((cls: string) => !cls.startsWith('text-'))
63
+ .join(' ')
64
+ if (align) {
65
+ labelClass += ` ${align}`
66
+ }
67
+ updateProperty('label.class', labelClass)
68
+ }
69
+
70
+ const handleOptionColorChange = (color: string) => {
71
+ let wrapperClass = component.properties.wrapperClass || ''
72
+ wrapperClass = wrapperClass
73
+ .split(' ')
74
+ .filter((cls: string) => !cls.startsWith('bg-'))
75
+ .join(' ')
76
+ if (color) {
77
+ wrapperClass += ` ${color}`
78
+ }
79
+ updateProperty('wrapperClass', wrapperClass)
80
+ }
81
+
82
+ /* Обновление свойства */
83
+ const updateProperty = (path: string, value: string | object) => {
84
+ const newProperties = JSON.parse(JSON.stringify(component.properties))
85
+ const parts = path.split('.')
86
+ let obj = newProperties
87
+
88
+ for (let i = 0; i < parts.length - 1; i++) {
89
+ const part = parts[i]
90
+ if (!obj[part]) obj[part] = {}
91
+ obj = obj[part]
92
+ }
93
+
94
+ obj[parts[parts.length - 1]] = value
95
+ onPropertyChange(newProperties)
96
+ }
97
+ </script>
98
+
99
+ {#if component && component.properties}
100
+ <div class="relative mb-4 flex flex-row items-start justify-center">
101
+ <div class="flex w-1/3 flex-col items-center px-2">
102
+ <UI.Select
103
+ wrapperClass="w-full"
104
+ label={{ name: $t('service.constructor.props.argument') }}
105
+ type="buttons"
106
+ value={$optionsStore.FULL_ARGUMENT_OPTION.find((h) => h.value === component.properties.eventHandler.Argument)}
107
+ options={$optionsStore.FULL_ARGUMENT_OPTION}
108
+ onUpdate={(option) => {
109
+ updateProperty('eventHandler.Argument', option.value as string)
110
+ }}
111
+ />
112
+ {#if component.properties.eventHandler.Argument !== 'Save' && component.properties.eventHandler.Argument !== 'NoSave'}
113
+ <UI.Input
114
+ wrapperClass="w-full {Header.value === 'SET' ? 'mt-1' : ''} "
115
+ label={{ name: $t('service.constructor.props.argument') }}
116
+ value={component.properties.eventHandler.Argument}
117
+ type="text"
118
+ autocomplete="on"
119
+ componentClass="w-full"
120
+ maxlength={32}
121
+ regExp={/^[a-zA-Z0-9\-_]{0,32}$/}
122
+ help={{ info: $t('service.constructor.props.argument.info') }}
123
+ onUpdate={(value) => updateProperty('eventHandler.Argument', value as string)}
124
+ />
125
+ {/if}
126
+ <UI.Select
127
+ label={{ name: $t('service.constructor.props.variable') }}
128
+ options={VARIABLE_OPTIONS}
129
+ value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id.value)}
130
+ onUpdate={(value) => {
131
+ updateProperty('id.name', (value.name as string).split('|')[1].trim())
132
+ updateProperty('id.value', value.value as string)
133
+ updateProperty('eventHandler.Variables', value.value as string)
134
+ }}
135
+ />
136
+ <UI.Select
137
+ label={{ name: $t('service.constructor.props.type') }}
138
+ type="buttons"
139
+ value={currentType}
140
+ options={$optionsStore.SELECT_TYPE_OPTIONS}
141
+ onUpdate={(item) => updateProperty('type', item.value as string)}
142
+ />
143
+ </div>
144
+ <div class="flex w-1/3 flex-col items-center px-2">
145
+ <UI.Select
146
+ wrapperClass="w-full h-14"
147
+ label={{ name: $t('service.constructor.props.valuetype') }}
148
+ type="buttons"
149
+ options={$optionsStore.SELECT_VALUE_TYPE_OPTIONS}
150
+ value={currentValueType}
151
+ onUpdate={(value) => {
152
+ currentValueType = value as ValueTypeOption
153
+ const options = [...(component.properties?.options || [])]
154
+ const newType = value.value
155
+ options.forEach((option) => {
156
+ if (newType === 'number') option.value = option.value !== undefined ? Number(option.value) : 0
157
+ else option.value = option.value !== undefined ? String(option.value) : ''
158
+ })
159
+ updateProperty('options', options)
160
+ }}
161
+ />
162
+ <UI.Select
163
+ wrapperClass="w-full h-14"
164
+ label={{ name: $t('service.constructor.props.colors') }}
165
+ type="buttons"
166
+ options={$optionsStore.COLOR_OPTIONS}
167
+ value={initialColor}
168
+ onUpdate={(option) => handleOptionColorChange(option.value as string)}
169
+ />
170
+ </div>
171
+ <div class="flex w-1/3 flex-col items-center px-2">
172
+ <UI.Input
173
+ label={{ name: $t('service.constructor.props.label') }}
174
+ value={component.properties.label.name}
175
+ type="text"
176
+ componentClass="w-full"
177
+ onUpdate={(value) => updateProperty('label.name', value as string)}
178
+ />
179
+ <UI.Select
180
+ wrapperClass="w-full"
181
+ label={{ name: $t('service.constructor.props.align') }}
182
+ type="buttons"
183
+ value={initialAlign}
184
+ options={$optionsStore.ALIGN_OPTIONS}
185
+ onUpdate={(option) => handleLabelAlign(option.value as string)}
186
+ />
187
+ </div>
188
+ </div>
189
+
190
+ <hr class="border-gray-400" />
191
+
192
+ <!-- Настройки опций -->
193
+ <div class="space-y-4">
194
+ <div class="m-0 flex items-center justify-center gap-2">
195
+ <h4>{$t('service.constructor.props.options.title')}</h4>
196
+ <UI.Button
197
+ wrapperClass="!w-10"
198
+ icon={{ component: ButtonAdd, properties: { height: '1.5rem', width: '1.5rem' } }}
199
+ componentClass="h-10 border-none hover:shadow-none"
200
+ onClick={() => {
201
+ const newOption: ISelectOption = {
202
+ id: crypto.randomUUID(),
203
+ name: 'New Button',
204
+ class: '',
205
+ }
206
+ const options = [...(component.properties?.options || []), newOption]
207
+ updateProperty('options', options)
208
+ }}
209
+ />
210
+ </div>
211
+
212
+ {#each component.properties.options || [] as option, index (option.id)}
213
+ <div class="m-0 flex items-end justify-around gap-2 border-gray-400">
214
+ <UI.Input
215
+ label={{ name: $t('service.constructor.props.optionname') }}
216
+ wrapperClass="!w-3/10"
217
+ value={option.name}
218
+ type="text"
219
+ onUpdate={(value) => {
220
+ const options = [...(component.properties?.options || [])]
221
+ options[index]['name'] = value
222
+ updateProperty('options', options)
223
+ }}
224
+ />
225
+ <UI.Input
226
+ label={{ name: $t('service.constructor.props.optionvalue') }}
227
+ wrapperClass="!w-3/10"
228
+ value={option.value}
229
+ type={currentValueType.value}
230
+ onUpdate={(value) => {
231
+ const options = [...(component.properties?.options || [])]
232
+ options[index]['value'] = value
233
+ updateProperty('options', options)
234
+ }}
235
+ />
236
+ <UI.Input
237
+ label={{ name: $t('service.constructor.props.optionclass') }}
238
+ wrapperClass="!w-3/10"
239
+ value={option.class}
240
+ type="text"
241
+ onUpdate={(value) => {
242
+ const options = [...(component.properties?.options || [])]
243
+ options[index]['class'] = value
244
+ updateProperty('options', options)
245
+ }}
246
+ />
247
+ <UI.Button
248
+ wrapperClass="!w-1/10"
249
+ icon={{ component: ButtonDelete, properties: { height: '1.5rem', width: '1.5rem' } }}
250
+ componentClass="h-10 w-10 border-none hover:shadow-none"
251
+ onClick={() => {
252
+ const options = [...(component.properties?.options || [])]
253
+ options.splice(index, 1)
254
+ updateProperty('options', options)
255
+ }}
256
+ />
257
+ </div>
258
+ {/each}
259
+ </div>
260
+ {/if}