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.
- package/LICENSE +3 -3
- package/dist/Accordion/Accordion.svelte +53 -53
- package/dist/Accordion/AccordionProps.svelte +70 -70
- package/dist/Button/Button.svelte +144 -144
- package/dist/Button/ButtonProps.svelte +200 -200
- package/dist/ColorPicker/ColorPicker.svelte +207 -207
- package/dist/ColorPicker/ColorPickerProps.svelte +100 -100
- package/dist/FileAttach/FileAttach.svelte +103 -103
- package/dist/Graph/Graph.svelte +270 -270
- package/dist/Graph/GraphProps.svelte +56 -56
- package/dist/Input/Input.svelte +239 -239
- package/dist/Input/InputProps.svelte +221 -221
- package/dist/Loader.svelte +12 -12
- package/dist/MessageModal.svelte +54 -54
- package/dist/ProgressBar/ProgressBar.svelte +48 -48
- package/dist/ProgressBar/ProgressBarProps.svelte +145 -145
- package/dist/Select/Select.svelte +191 -187
- package/dist/Select/SelectProps.svelte +260 -260
- package/dist/Slider/Slider.svelte +260 -260
- package/dist/Slider/SliderProps.svelte +161 -161
- package/dist/Switch/Switch.svelte +83 -83
- package/dist/Switch/SwitchProps.svelte +144 -144
- package/dist/Table/Table.svelte +276 -276
- package/dist/Table/TableProps.svelte +286 -286
- package/dist/TextField/TextField.svelte +22 -22
- package/dist/TextField/TextFieldProps.svelte +92 -92
- package/dist/{appIcons → libIcons}/ButtonAdd.svelte +10 -10
- package/dist/{appIcons → libIcons}/ButtonDelete.svelte +13 -13
- package/dist/{appIcons → libIcons}/LoaderRotate.svelte +9 -9
- package/dist/locales/CircleFlagsEn.svelte +14 -14
- package/dist/locales/CircleFlagsRu.svelte +8 -8
- package/dist/locales/CircleFlagsZh.svelte +8 -8
- package/package.json +49 -47
- /package/dist/{appIcons → libIcons}/ButtonAdd.svelte.d.ts +0 -0
- /package/dist/{appIcons → libIcons}/ButtonDelete.svelte.d.ts +0 -0
- /package/dist/{appIcons → libIcons}/LoaderRotate.svelte.d.ts +0 -0
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
<!-- $lib/ElementsUI/ProgressBar.svelte -->
|
|
2
|
-
<script lang="ts">
|
|
3
|
-
import type { IProgressBarProps } from '../types'
|
|
4
|
-
|
|
5
|
-
let {
|
|
6
|
-
id = { name: '', value: crypto.randomUUID() },
|
|
7
|
-
label = { name: '', class: '' },
|
|
8
|
-
value = $bindable(0),
|
|
9
|
-
range = {
|
|
10
|
-
min: 0,
|
|
11
|
-
max: 100,
|
|
12
|
-
units: '%',
|
|
13
|
-
},
|
|
14
|
-
wrapperClass = '',
|
|
15
|
-
}: IProgressBarProps = $props()
|
|
16
|
-
|
|
17
|
-
let numericValue = $state(0)
|
|
18
|
-
const min = $derived(range.min ?? 0)
|
|
19
|
-
const max = $derived(range.max ?? 100)
|
|
20
|
-
|
|
21
|
-
$effect(() => {
|
|
22
|
-
if (typeof value === 'number' && !isNaN(value)) {
|
|
23
|
-
numericValue = Math.max(min, Math.min(max, value))
|
|
24
|
-
} else if (typeof value === 'string') {
|
|
25
|
-
const parsedValue = parseFloat(value)
|
|
26
|
-
if (!isNaN(parsedValue)) {
|
|
27
|
-
numericValue = Math.max(min, Math.min(max, parsedValue))
|
|
28
|
-
}
|
|
29
|
-
} else {
|
|
30
|
-
numericValue = min
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
let progressPercent = $derived((((value as number) - min) / (max - min)) * 100)
|
|
35
|
-
</script>
|
|
36
|
-
|
|
37
|
-
<div id={id.value} class={`relative flex w-full flex-col items-center ${wrapperClass}`}>
|
|
38
|
-
{#if label.name}
|
|
39
|
-
<h5 class={`mb-1 w-full px-4 text-center ${label.class}`}>{label.name}</h5>
|
|
40
|
-
{/if}
|
|
41
|
-
|
|
42
|
-
<div class="flex w-full flex-col items-center">
|
|
43
|
-
<div class="relative h-2 w-full rounded bg-gray-400">
|
|
44
|
-
<div class="absolute top-0 left-0 h-full rounded bg-[var(--bg-color)]" style="width: {progressPercent}%;"></div>
|
|
45
|
-
</div>
|
|
46
|
-
<span class="ml-2 font-semibold">{numericValue.toFixed(2)}{range.units}</span>
|
|
47
|
-
</div>
|
|
48
|
-
</div>
|
|
1
|
+
<!-- $lib/ElementsUI/ProgressBar.svelte -->
|
|
2
|
+
<script lang="ts">
|
|
3
|
+
import type { IProgressBarProps } from '../types'
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
id = { name: '', value: crypto.randomUUID() },
|
|
7
|
+
label = { name: '', class: '' },
|
|
8
|
+
value = $bindable(0),
|
|
9
|
+
range = {
|
|
10
|
+
min: 0,
|
|
11
|
+
max: 100,
|
|
12
|
+
units: '%',
|
|
13
|
+
},
|
|
14
|
+
wrapperClass = '',
|
|
15
|
+
}: IProgressBarProps = $props()
|
|
16
|
+
|
|
17
|
+
let numericValue = $state(0)
|
|
18
|
+
const min = $derived(range.min ?? 0)
|
|
19
|
+
const max = $derived(range.max ?? 100)
|
|
20
|
+
|
|
21
|
+
$effect(() => {
|
|
22
|
+
if (typeof value === 'number' && !isNaN(value)) {
|
|
23
|
+
numericValue = Math.max(min, Math.min(max, value))
|
|
24
|
+
} else if (typeof value === 'string') {
|
|
25
|
+
const parsedValue = parseFloat(value)
|
|
26
|
+
if (!isNaN(parsedValue)) {
|
|
27
|
+
numericValue = Math.max(min, Math.min(max, parsedValue))
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
numericValue = min
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
let progressPercent = $derived((((value as number) - min) / (max - min)) * 100)
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<div id={id.value} class={`relative flex w-full flex-col items-center ${wrapperClass}`}>
|
|
38
|
+
{#if label.name}
|
|
39
|
+
<h5 class={`mb-1 w-full px-4 text-center ${label.class}`}>{label.name}</h5>
|
|
40
|
+
{/if}
|
|
41
|
+
|
|
42
|
+
<div class="flex w-full flex-col items-center">
|
|
43
|
+
<div class="relative h-2 w-full rounded bg-gray-400">
|
|
44
|
+
<div class="absolute top-0 left-0 h-full rounded bg-[var(--bg-color)]" style="width: {progressPercent}%;"></div>
|
|
45
|
+
</div>
|
|
46
|
+
<span class="ml-2 font-semibold">{numericValue.toFixed(2)}{range.units}</span>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
<!-- $lib/ElementsUI/SwitchProps.svelte -->
|
|
2
|
-
<script lang="ts">
|
|
3
|
-
import { getContext } from 'svelte'
|
|
4
|
-
import { t } from '../locales/i18n'
|
|
5
|
-
import type { UIComponent, IProgressBarProps } from '../types'
|
|
6
|
-
import * as UI from '../index'
|
|
7
|
-
import { optionsStore } from '../options'
|
|
8
|
-
|
|
9
|
-
const { component, onPropertyChange } = $props<{
|
|
10
|
-
component: UIComponent & { properties: Partial<IProgressBarProps> }
|
|
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 initialColor = $derived(
|
|
30
|
-
$optionsStore.COLOR_OPTIONS.find((c) =>
|
|
31
|
-
(c.value as string).includes(component.properties.wrapperClass?.split(' ').find((cls: string) => cls.startsWith('bg-'))),
|
|
32
|
-
),
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
const handleLabelAlign = (align: string) => {
|
|
36
|
-
let labelClass = component.properties.label.class || ''
|
|
37
|
-
labelClass = labelClass
|
|
38
|
-
.split(' ')
|
|
39
|
-
.filter((cls: string) => !cls.startsWith('text-'))
|
|
40
|
-
.join(' ')
|
|
41
|
-
if (align) {
|
|
42
|
-
labelClass += ` ${align}`
|
|
43
|
-
}
|
|
44
|
-
updateProperty('label.class', labelClass)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const handleOptionColorChange = (color: string) => {
|
|
48
|
-
let wrapperClass = component.properties.wrapperClass || ''
|
|
49
|
-
wrapperClass = wrapperClass
|
|
50
|
-
.split(' ')
|
|
51
|
-
.filter((cls: string) => !cls.startsWith('bg-'))
|
|
52
|
-
.join(' ')
|
|
53
|
-
if (color) {
|
|
54
|
-
wrapperClass += ` ${color}`
|
|
55
|
-
}
|
|
56
|
-
updateProperty('wrapperClass', wrapperClass)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/* Обновление свойства */
|
|
60
|
-
const updateProperty = (path: string, value: number | string | object) => {
|
|
61
|
-
const newProperties = JSON.parse(JSON.stringify(component.properties))
|
|
62
|
-
const parts = path.split('.')
|
|
63
|
-
let obj = newProperties
|
|
64
|
-
|
|
65
|
-
for (let i = 0; i < parts.length - 1; i++) {
|
|
66
|
-
const part = parts[i]
|
|
67
|
-
if (!obj[part]) obj[part] = {}
|
|
68
|
-
obj = obj[part]
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
obj[parts[parts.length - 1]] = value
|
|
72
|
-
onPropertyChange(newProperties)
|
|
73
|
-
}
|
|
74
|
-
</script>
|
|
75
|
-
|
|
76
|
-
{#if component && component.properties}
|
|
77
|
-
<div class="relative flex flex-row items-start justify-center">
|
|
78
|
-
<div class="flex w-1/3 flex-col items-center px-2">
|
|
79
|
-
<UI.Select
|
|
80
|
-
label={{ name: $t('service.constructor.props.variable') }}
|
|
81
|
-
options={VARIABLE_OPTIONS}
|
|
82
|
-
value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id.value)}
|
|
83
|
-
onUpdate={(value) => {
|
|
84
|
-
updateProperty('id.name', (value.name as string).split('|')[1].trim())
|
|
85
|
-
updateProperty('id.value', value.value as string)
|
|
86
|
-
}}
|
|
87
|
-
/>
|
|
88
|
-
</div>
|
|
89
|
-
<div class="flex w-1/3 flex-col px-2">
|
|
90
|
-
<UI.Input
|
|
91
|
-
wrapperClass="w-full"
|
|
92
|
-
label={{ name: $t('service.constructor.props.min') }}
|
|
93
|
-
value={component.properties.range.min as number}
|
|
94
|
-
type="number"
|
|
95
|
-
onUpdate={(value) => {
|
|
96
|
-
updateProperty('range.min', Number(value))
|
|
97
|
-
updateProperty('value', component.properties.range.min + (component.properties.range.max - component.properties.range.min) / 3)
|
|
98
|
-
}}
|
|
99
|
-
/>
|
|
100
|
-
<UI.Input
|
|
101
|
-
wrapperClass="w-full"
|
|
102
|
-
label={{ name: $t('service.constructor.props.max') }}
|
|
103
|
-
value={component.properties.range.max as number}
|
|
104
|
-
type="number"
|
|
105
|
-
onUpdate={(value) => {
|
|
106
|
-
updateProperty('range.max', Number(value))
|
|
107
|
-
updateProperty('value', component.properties.range.min + (component.properties.range.max - component.properties.range.min) / 3)
|
|
108
|
-
}}
|
|
109
|
-
/>
|
|
110
|
-
<UI.Input
|
|
111
|
-
wrapperClass="w-full"
|
|
112
|
-
label={{ name: $t('service.constructor.props.units') }}
|
|
113
|
-
value={component.properties.range.units}
|
|
114
|
-
type="text"
|
|
115
|
-
onUpdate={(value) => updateProperty('range.units', value)}
|
|
116
|
-
/>
|
|
117
|
-
</div>
|
|
118
|
-
<div class="flex w-1/3 flex-col px-2">
|
|
119
|
-
<UI.Input
|
|
120
|
-
wrapperClass="w-full"
|
|
121
|
-
label={{ name: $t('service.constructor.props.label') }}
|
|
122
|
-
value={component.properties.label.name}
|
|
123
|
-
type="text"
|
|
124
|
-
componentClass="w-full"
|
|
125
|
-
onUpdate={(value) => updateProperty('label.name', value as string)}
|
|
126
|
-
/>
|
|
127
|
-
<UI.Select
|
|
128
|
-
wrapperClass="w-full"
|
|
129
|
-
label={{ name: $t('service.constructor.props.align') }}
|
|
130
|
-
type="buttons"
|
|
131
|
-
value={initialAlign}
|
|
132
|
-
options={$optionsStore.ALIGN_OPTIONS}
|
|
133
|
-
onUpdate={(option) => handleLabelAlign(option.value as string)}
|
|
134
|
-
/>
|
|
135
|
-
<UI.Select
|
|
136
|
-
wrapperClass="!h-14"
|
|
137
|
-
label={{ name: $t('service.constructor.props.colors') }}
|
|
138
|
-
type="buttons"
|
|
139
|
-
options={$optionsStore.COLOR_OPTIONS}
|
|
140
|
-
value={initialColor}
|
|
141
|
-
onUpdate={(option) => handleOptionColorChange(option.value as string)}
|
|
142
|
-
/>
|
|
143
|
-
</div>
|
|
144
|
-
</div>
|
|
145
|
-
{/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, IProgressBarProps } from '../types'
|
|
6
|
+
import * as UI from '../index'
|
|
7
|
+
import { optionsStore } from '../options'
|
|
8
|
+
|
|
9
|
+
const { component, onPropertyChange } = $props<{
|
|
10
|
+
component: UIComponent & { properties: Partial<IProgressBarProps> }
|
|
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 initialColor = $derived(
|
|
30
|
+
$optionsStore.COLOR_OPTIONS.find((c) =>
|
|
31
|
+
(c.value as string).includes(component.properties.wrapperClass?.split(' ').find((cls: string) => cls.startsWith('bg-'))),
|
|
32
|
+
),
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
const handleLabelAlign = (align: string) => {
|
|
36
|
+
let labelClass = component.properties.label.class || ''
|
|
37
|
+
labelClass = labelClass
|
|
38
|
+
.split(' ')
|
|
39
|
+
.filter((cls: string) => !cls.startsWith('text-'))
|
|
40
|
+
.join(' ')
|
|
41
|
+
if (align) {
|
|
42
|
+
labelClass += ` ${align}`
|
|
43
|
+
}
|
|
44
|
+
updateProperty('label.class', labelClass)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const handleOptionColorChange = (color: string) => {
|
|
48
|
+
let wrapperClass = component.properties.wrapperClass || ''
|
|
49
|
+
wrapperClass = wrapperClass
|
|
50
|
+
.split(' ')
|
|
51
|
+
.filter((cls: string) => !cls.startsWith('bg-'))
|
|
52
|
+
.join(' ')
|
|
53
|
+
if (color) {
|
|
54
|
+
wrapperClass += ` ${color}`
|
|
55
|
+
}
|
|
56
|
+
updateProperty('wrapperClass', wrapperClass)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* Обновление свойства */
|
|
60
|
+
const updateProperty = (path: string, value: number | string | object) => {
|
|
61
|
+
const newProperties = JSON.parse(JSON.stringify(component.properties))
|
|
62
|
+
const parts = path.split('.')
|
|
63
|
+
let obj = newProperties
|
|
64
|
+
|
|
65
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
66
|
+
const part = parts[i]
|
|
67
|
+
if (!obj[part]) obj[part] = {}
|
|
68
|
+
obj = obj[part]
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
obj[parts[parts.length - 1]] = value
|
|
72
|
+
onPropertyChange(newProperties)
|
|
73
|
+
}
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
{#if component && component.properties}
|
|
77
|
+
<div class="relative flex flex-row items-start justify-center">
|
|
78
|
+
<div class="flex w-1/3 flex-col items-center px-2">
|
|
79
|
+
<UI.Select
|
|
80
|
+
label={{ name: $t('service.constructor.props.variable') }}
|
|
81
|
+
options={VARIABLE_OPTIONS}
|
|
82
|
+
value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id.value)}
|
|
83
|
+
onUpdate={(value) => {
|
|
84
|
+
updateProperty('id.name', (value.name as string).split('|')[1].trim())
|
|
85
|
+
updateProperty('id.value', value.value as string)
|
|
86
|
+
}}
|
|
87
|
+
/>
|
|
88
|
+
</div>
|
|
89
|
+
<div class="flex w-1/3 flex-col px-2">
|
|
90
|
+
<UI.Input
|
|
91
|
+
wrapperClass="w-full"
|
|
92
|
+
label={{ name: $t('service.constructor.props.min') }}
|
|
93
|
+
value={component.properties.range.min as number}
|
|
94
|
+
type="number"
|
|
95
|
+
onUpdate={(value) => {
|
|
96
|
+
updateProperty('range.min', Number(value))
|
|
97
|
+
updateProperty('value', component.properties.range.min + (component.properties.range.max - component.properties.range.min) / 3)
|
|
98
|
+
}}
|
|
99
|
+
/>
|
|
100
|
+
<UI.Input
|
|
101
|
+
wrapperClass="w-full"
|
|
102
|
+
label={{ name: $t('service.constructor.props.max') }}
|
|
103
|
+
value={component.properties.range.max as number}
|
|
104
|
+
type="number"
|
|
105
|
+
onUpdate={(value) => {
|
|
106
|
+
updateProperty('range.max', Number(value))
|
|
107
|
+
updateProperty('value', component.properties.range.min + (component.properties.range.max - component.properties.range.min) / 3)
|
|
108
|
+
}}
|
|
109
|
+
/>
|
|
110
|
+
<UI.Input
|
|
111
|
+
wrapperClass="w-full"
|
|
112
|
+
label={{ name: $t('service.constructor.props.units') }}
|
|
113
|
+
value={component.properties.range.units}
|
|
114
|
+
type="text"
|
|
115
|
+
onUpdate={(value) => updateProperty('range.units', value)}
|
|
116
|
+
/>
|
|
117
|
+
</div>
|
|
118
|
+
<div class="flex w-1/3 flex-col px-2">
|
|
119
|
+
<UI.Input
|
|
120
|
+
wrapperClass="w-full"
|
|
121
|
+
label={{ name: $t('service.constructor.props.label') }}
|
|
122
|
+
value={component.properties.label.name}
|
|
123
|
+
type="text"
|
|
124
|
+
componentClass="w-full"
|
|
125
|
+
onUpdate={(value) => updateProperty('label.name', value as string)}
|
|
126
|
+
/>
|
|
127
|
+
<UI.Select
|
|
128
|
+
wrapperClass="w-full"
|
|
129
|
+
label={{ name: $t('service.constructor.props.align') }}
|
|
130
|
+
type="buttons"
|
|
131
|
+
value={initialAlign}
|
|
132
|
+
options={$optionsStore.ALIGN_OPTIONS}
|
|
133
|
+
onUpdate={(option) => handleLabelAlign(option.value as string)}
|
|
134
|
+
/>
|
|
135
|
+
<UI.Select
|
|
136
|
+
wrapperClass="!h-14"
|
|
137
|
+
label={{ name: $t('service.constructor.props.colors') }}
|
|
138
|
+
type="buttons"
|
|
139
|
+
options={$optionsStore.COLOR_OPTIONS}
|
|
140
|
+
value={initialColor}
|
|
141
|
+
onUpdate={(option) => handleOptionColorChange(option.value as string)}
|
|
142
|
+
/>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
{/if}
|