poe-svelte-ui-lib 1.0.10 → 1.0.11

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.
@@ -58,9 +58,9 @@
58
58
  {id}
59
59
  class="{twMerge(
60
60
  `relative m-0 inline-block w-full items-center rounded-2xl
61
- px-2 py-1 font-semibold shadow-sm transition duration-200 select-none
62
- ${content.icon && !content.name ? 'bg-transparent' : 'border border-[var(--bg-color)] '}
63
- ${disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer hover:shadow-md active:scale-97'} `,
61
+ px-2 py-1 font-semibold transition duration-200 select-none
62
+ ${content.icon && !content.name ? 'bg-transparent p-0' : 'border border-[var(--bg-color)] '}
63
+ ${disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer active:scale-97'} `,
64
64
  componentClass,
65
65
  )} bg-[var(--bg-color)]"
66
66
  onclick={handleClick}
@@ -73,10 +73,11 @@
73
73
  if (content.info) showInfo = false
74
74
  }}
75
75
  >
76
- <span class="flex flex-row items-center justify-center gap-2">
76
+ <span class=" flex flex-row items-center justify-center gap-2">
77
77
  {#if content?.icon}
78
78
  <span
79
- class={`flex h-8 w-8 shrink-0 items-center justify-center overflow-visible [&_svg]:h-full [&_svg]:max-h-full [&_svg]:w-full [&_svg]:max-w-full`}
79
+ class={`flex items-center justify-center overflow-visible
80
+ ${content.name ? 'h-8 w-8' : `${componentClass}`} [&_svg]:h-full [&_svg]:max-h-full [&_svg]:w-full [&_svg]:max-w-full`}
80
81
  >
81
82
  {#if content?.icon}
82
83
  {@const IconComponent = content?.icon}
@@ -131,7 +131,7 @@
131
131
 
132
132
  <div {id} class={twMerge(`relative flex w-full flex-col items-center`, wrapperClass)}>
133
133
  {#if label.name}
134
- <h5 class={twMerge(`mb-2 w-full px-4 text-center`, label.class)}>{label.name}</h5>
134
+ <h5 class={twMerge(`w-full px-4 text-center`, label.class)}>{label.name}</h5>
135
135
  {/if}
136
136
 
137
137
  <div class="flex w-full flex-row items-center gap-2">
@@ -201,18 +201,12 @@
201
201
 
202
202
  <!-- Превью цвета -->
203
203
 
204
- <div class="flex w-24 flex-col items-center">
204
+ <div class="flex w-25 flex-col items-center">
205
205
  <div
206
206
  class={`flex size-15 flex-col justify-center gap-1 rounded-full px-2 font-mono text-sm shadow-md select-none ${textColor()}`}
207
207
  style={`background: rgb(${previewBaseColor().join(',')})`}
208
208
  ></div>
209
209
  <div class="w-full text-center font-semibold">{hex()}</div>
210
210
  </div>
211
- <!-- <div>
212
- <div class="flex flex-col items-center">
213
- <span class="w-full flex-shrink-0">{mode === 'white' ? 'White' : 'RGB'}</span>
214
- <div class="пфз-1 w-full text-center tracking-wide">{hex()}</div>
215
- </div>
216
- </div> -->
217
211
  </div>
218
212
  </div>
@@ -11,13 +11,13 @@
11
11
  onPropertyChange: (value: string | object) => void
12
12
  }>()
13
13
 
14
- const DeviceVariables = getContext<{ value: string; name: string }[]>('DeviceVariables')
14
+ const DeviceVariables = getContext<string[]>('DeviceVariables')
15
15
  let VARIABLE_OPTIONS = $derived(
16
16
  DeviceVariables && Array.isArray(DeviceVariables)
17
17
  ? DeviceVariables.map((variable) => ({
18
- id: variable.name,
19
- value: variable.value,
20
- name: `${variable.value} | ${variable.name}`,
18
+ id: variable,
19
+ value: variable,
20
+ name: variable,
21
21
  }))
22
22
  : [],
23
23
  )
@@ -36,7 +36,7 @@
36
36
  <UI.Select
37
37
  label={{ name: $t('constructor.props.variable') }}
38
38
  options={VARIABLE_OPTIONS}
39
- value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id.value)}
39
+ value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
40
40
  onUpdate={(value) => {
41
41
  updateProperty('id', value.value as string, component, onPropertyChange)
42
42
  updateProperty('eventHandler.Variables', value.value as string, component, onPropertyChange)
@@ -117,7 +117,6 @@
117
117
  }
118
118
  }, 10)
119
119
  }
120
- console.log(streamingData.data)
121
120
  return () => clearInterval(intervalId)
122
121
  })
123
122
 
@@ -10,13 +10,13 @@
10
10
  onPropertyChange: (value: string | object) => void
11
11
  }>()
12
12
 
13
- const DeviceVariables = getContext<{ value: string; name: string }[]>('DeviceVariables')
13
+ const DeviceVariables = getContext<string[]>('DeviceVariables')
14
14
  let VARIABLE_OPTIONS = $derived(
15
15
  DeviceVariables && Array.isArray(DeviceVariables)
16
16
  ? DeviceVariables.map((variable) => ({
17
- id: variable.name,
18
- value: variable.value,
19
- name: `${variable.value} | ${variable.name}`,
17
+ id: variable,
18
+ value: variable,
19
+ name: variable,
20
20
  }))
21
21
  : [],
22
22
  )
@@ -29,7 +29,7 @@
29
29
  <UI.Select
30
30
  label={{ name: $t('constructor.props.variable') }}
31
31
  options={VARIABLE_OPTIONS}
32
- value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id.value)}
32
+ value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
33
33
  onUpdate={(value) => {
34
34
  updateProperty('id', value.value as string, component, onPropertyChange)
35
35
  }}
@@ -12,13 +12,13 @@
12
12
  }>()
13
13
 
14
14
  let isValidRegExp = $state(true)
15
- const DeviceVariables = getContext<{ value: string; name: string }[]>('DeviceVariables')
16
- let VARIABLE_OPTIONS: ISelectOption<string>[] = $derived(
15
+ const DeviceVariables = getContext<string[]>('DeviceVariables')
16
+ let VARIABLE_OPTIONS = $derived(
17
17
  DeviceVariables && Array.isArray(DeviceVariables)
18
18
  ? DeviceVariables.map((variable) => ({
19
- id: variable.name,
20
- value: variable.value,
21
- name: `${variable.value} | ${variable.name}`,
19
+ id: variable,
20
+ value: variable,
21
+ name: variable,
22
22
  }))
23
23
  : [],
24
24
  )
@@ -97,7 +97,7 @@
97
97
  <UI.Select
98
98
  label={{ name: $t('constructor.props.variable') }}
99
99
  options={VARIABLE_OPTIONS}
100
- value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id.value)}
100
+ value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
101
101
  onUpdate={(selectedOption) => {
102
102
  if (selectedOption && selectedOption.name) {
103
103
  updateProperty('id', selectedOption.value as string)
@@ -33,17 +33,21 @@
33
33
  })(),
34
34
  )
35
35
 
36
- let progressPercent = $derived((((value as number) - min) / (max - min)) * 100)
36
+ const progressPercent = $derived(() => {
37
+ if (value) {
38
+ return (((Math.min(Math.max(value, min), max) - min) / (max - min)) * 100) as number
39
+ }
40
+ })
37
41
  </script>
38
42
 
39
43
  <div {id} class={twMerge(`relative flex w-full flex-col items-center`, wrapperClass)}>
40
44
  {#if label.name}
41
- <h5 class={twMerge(`mb-1 w-full px-4 text-center`, label.class)}>{label.name}</h5>
45
+ <h5 class={twMerge(` w-full px-4 text-center`, label.class)}>{label.name}</h5>
42
46
  {/if}
43
47
 
44
48
  <div class="flex w-full flex-col items-center">
45
49
  <div class="relative h-2 w-full rounded bg-gray-400">
46
- <div class="absolute top-0 left-0 h-full rounded bg-[var(--bg-color)]" style="width: {progressPercent}%;"></div>
50
+ <div class="absolute top-0 left-0 h-full rounded bg-[var(--bg-color)]" style="width: {progressPercent()}%;"></div>
47
51
  </div>
48
52
  <span class="ml-2 font-semibold">{numericValue?.toFixed(2)}{number.units}</span>
49
53
  </div>
@@ -11,13 +11,13 @@
11
11
  onPropertyChange: (value: string | object) => void
12
12
  }>()
13
13
 
14
- const DeviceVariables = getContext<{ value: string; name: string }[]>('DeviceVariables')
14
+ const DeviceVariables = getContext<string[]>('DeviceVariables')
15
15
  let VARIABLE_OPTIONS = $derived(
16
16
  DeviceVariables && Array.isArray(DeviceVariables)
17
17
  ? DeviceVariables.map((variable) => ({
18
- id: variable.name,
19
- value: variable.value,
20
- name: `${variable.value} | ${variable.name}`,
18
+ id: variable,
19
+ value: variable,
20
+ name: variable,
21
21
  }))
22
22
  : [],
23
23
  )
@@ -41,7 +41,7 @@
41
41
  <UI.Select
42
42
  label={{ name: $t('constructor.props.variable') }}
43
43
  options={VARIABLE_OPTIONS}
44
- value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id.value)}
44
+ value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
45
45
  onUpdate={(value) => {
46
46
  updateProperty('id', value.value as string, component, onPropertyChange)
47
47
  }}
@@ -141,7 +141,7 @@
141
141
  class="{twMerge(
142
142
  `m-0 inline-block min-w-0 flex-1 items-center px-2 py-1 font-semibold shadow-sm transition-all duration-300 select-none
143
143
  ${option.disabled || disabled ? 'opacity-50' : 'cursor-pointer hover:shadow-md'}
144
- ${option.value === value?.value && value !== null ? 'z-10 py-0 text-[1.1rem] shadow-[0_0_10px_var(--shadow-color)] hover:shadow-[0_0_15px_var(--shadow-color)]' : ''}
144
+ ${option.value === value?.value && value !== null ? 'z-10 py-0 shadow-[0_0_10px_var(--shadow-color)] hover:shadow-[0_0_15px_var(--shadow-color)]' : ''}
145
145
  ${options.length > 0 && index === 0 ? 'rounded-l-2xl' : ''} ${index === options.length - 1 ? 'rounded-r-2xl' : ''}`,
146
146
  option.class,
147
147
  )} bg-[var(--bg-color)]"
@@ -13,13 +13,13 @@
13
13
  onPropertyChange: (path: string, value: string | object) => void
14
14
  }>()
15
15
 
16
- const DeviceVariables = getContext<{ value: string; name: string }[]>('DeviceVariables')
16
+ const DeviceVariables = getContext<string[]>('DeviceVariables')
17
17
  let VARIABLE_OPTIONS = $derived(
18
18
  DeviceVariables && Array.isArray(DeviceVariables)
19
19
  ? DeviceVariables.map((variable) => ({
20
- id: variable.name,
21
- value: variable.value,
22
- name: `${variable.value} | ${variable.name}`,
20
+ id: variable,
21
+ value: variable,
22
+ name: variable,
23
23
  }))
24
24
  : [],
25
25
  )
@@ -86,7 +86,7 @@
86
86
  <UI.Select
87
87
  label={{ name: $t('constructor.props.variable') }}
88
88
  options={VARIABLE_OPTIONS}
89
- value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id.value)}
89
+ value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
90
90
  onUpdate={(value) => {
91
91
  updateProperty('id', value.value as string, component, onPropertyChange)
92
92
  updateProperty('eventHandler.Variables', value.value as string, component, onPropertyChange)
@@ -92,7 +92,7 @@
92
92
  }
93
93
  </script>
94
94
 
95
- <div class={twMerge(`relative flex w-full flex-col items-center gap-2`, wrapperClass)}>
95
+ <div class={twMerge(`relative flex w-full flex-col items-center `, wrapperClass)}>
96
96
  {#if label.name}
97
97
  <h5 class={twMerge(`w-full px-4 text-center`, label.class)}>{label.name}</h5>
98
98
  {/if}
@@ -199,7 +199,7 @@
199
199
  </div>
200
200
 
201
201
  <!-- Кнопки управления -->
202
- <div class={`flex w-full ${isRange ? 'justify-between' : 'justify-center'} gap-2`}>
202
+ <div class={`mt-3 flex w-full ${isRange ? 'justify-between' : 'justify-center'} gap-2`}>
203
203
  {#if isRange}
204
204
  {#each ['lower', 'upper'] as type (type)}
205
205
  <div
@@ -11,13 +11,13 @@
11
11
  onPropertyChange: (value: string | object) => void
12
12
  }>()
13
13
 
14
- const DeviceVariables = getContext<{ value: string; name: string }[]>('DeviceVariables')
14
+ const DeviceVariables = getContext<string[]>('DeviceVariables')
15
15
  let VARIABLE_OPTIONS = $derived(
16
16
  DeviceVariables && Array.isArray(DeviceVariables)
17
17
  ? DeviceVariables.map((variable) => ({
18
- id: variable.name,
19
- value: variable.value,
20
- name: `${variable.value} | ${variable.name}`,
18
+ id: variable,
19
+ value: variable,
20
+ name: variable,
21
21
  }))
22
22
  : [],
23
23
  )
@@ -41,7 +41,7 @@
41
41
  <UI.Select
42
42
  label={{ name: $t('constructor.props.variable') }}
43
43
  options={VARIABLE_OPTIONS}
44
- value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id.value)}
44
+ value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
45
45
  onUpdate={(value) => {
46
46
  updateProperty('id', value.value as string, component, onPropertyChange)
47
47
  updateProperty('eventHandler.Variables', value.value as string, component, onPropertyChange)
@@ -5,35 +5,27 @@
5
5
  import { type UIComponent, type ISwitchProps, updateProperty, type ISelectOption } from '../types'
6
6
  import * as UI from '..'
7
7
  import { optionsStore } from '../options'
8
- import { twMerge } from 'tailwind-merge'
9
8
 
10
9
  const { component, onPropertyChange } = $props<{
11
10
  component: UIComponent & { properties: Partial<ISwitchProps> }
12
11
  onPropertyChange: (value: string | object) => void
13
12
  }>()
14
13
 
15
- const DeviceVariables = getContext<{ value: string; name: string }[]>('DeviceVariables')
14
+ const DeviceVariables = getContext<string[]>('DeviceVariables')
16
15
  let VARIABLE_OPTIONS = $derived(
17
16
  DeviceVariables && Array.isArray(DeviceVariables)
18
17
  ? DeviceVariables.map((variable) => ({
19
- id: variable.name,
20
- value: variable.value,
21
- name: `${variable.value} | ${variable.name}`,
18
+ id: variable,
19
+ value: variable,
20
+ name: variable,
22
21
  }))
23
22
  : [],
24
23
  )
25
-
26
24
  const initialColor = $derived(
27
25
  $optionsStore.COLOR_OPTIONS.find((c) =>
28
26
  (c.value as string).includes(component.properties.wrapperClass?.split(' ').find((cls: string) => cls.startsWith('bg-'))),
29
27
  ),
30
28
  )
31
-
32
- const initialAlign = $derived(
33
- $optionsStore.ALIGN_OPTIONS.find((a) =>
34
- (a.value as string).includes(component.properties.label?.class?.split(' ').find((cls: string) => cls.startsWith('text-'))),
35
- ),
36
- )
37
29
  </script>
38
30
 
39
31
  {#if component && component.properties}
@@ -43,7 +35,7 @@
43
35
  <UI.Select
44
36
  label={{ name: $t('constructor.props.variable') }}
45
37
  options={VARIABLE_OPTIONS}
46
- value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id.value)}
38
+ value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
47
39
  onUpdate={(value) => {
48
40
  updateProperty('id', value.value as string, component, onPropertyChange)
49
41
  updateProperty('eventHandler.Variables', value.value as string, component, onPropertyChange)
@@ -4,7 +4,7 @@
4
4
  import type { ITableHeader, ITableProps } from '../types'
5
5
  import { fade, fly, slide } from 'svelte/transition'
6
6
  import { twMerge } from 'tailwind-merge'
7
- import { Button, Modal } from '..'
7
+ import { Button, Modal, Slider } from '..'
8
8
  import { t } from '../locales/i18n'
9
9
 
10
10
  let {
@@ -13,13 +13,13 @@
13
13
  onPropertyChange: (value: string | object) => void
14
14
  }>()
15
15
 
16
- const DeviceVariables = getContext<{ value: string; name: string }[]>('DeviceVariables')
16
+ const DeviceVariables = getContext<string[]>('DeviceVariables')
17
17
  let VARIABLE_OPTIONS = $derived(
18
18
  DeviceVariables && Array.isArray(DeviceVariables)
19
19
  ? DeviceVariables.map((variable) => ({
20
- id: variable.name,
21
- value: variable.value,
22
- name: `${variable.value} | ${variable.name}`,
20
+ id: variable,
21
+ value: variable,
22
+ name: variable,
23
23
  }))
24
24
  : [],
25
25
  )
@@ -65,7 +65,7 @@
65
65
  <UI.Select
66
66
  label={{ name: $t('constructor.props.variable') }}
67
67
  options={VARIABLE_OPTIONS}
68
- value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id.value)}
68
+ value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
69
69
  onUpdate={(value) => {
70
70
  updateProperty('id', value.value as string, component, onPropertyChange)
71
71
  updateProperty('eventHandler.Variables', value.value as string, component, onPropertyChange)
@@ -154,7 +154,7 @@
154
154
  componentClass="bg-transparent h-10 w-10 border-none !shadow-none hover:shadow-none"
155
155
  onClick={() => {
156
156
  const newButton = {
157
- name: `button${(component.properties.header[columnIndex].buttons.length || 0) + 1}`,
157
+ name: `button${(component.properties.header[columnIndex].buttons ? component.properties.header[columnIndex].buttons.length : 0) + 1}`,
158
158
  class: 'bg-blue',
159
159
  eventHandler: { Header: 'SET', Argument: 'Save', Variables: [] },
160
160
  onClick: () => {},
@@ -4,12 +4,23 @@
4
4
  import { updateProperty, type ITextFieldProps, type UIComponent } from '../types'
5
5
  import * as UI from '../index'
6
6
  import { optionsStore } from '../options'
7
+ import { getContext } from 'svelte'
7
8
 
8
9
  const { component, onPropertyChange } = $props<{
9
10
  component: UIComponent & { properties: Partial<ITextFieldProps> }
10
11
  onPropertyChange: (value: string | object) => void
11
12
  }>()
12
13
 
14
+ const DeviceVariables = getContext<string[]>('DeviceVariables')
15
+ let VARIABLE_OPTIONS = $derived(
16
+ DeviceVariables && Array.isArray(DeviceVariables)
17
+ ? DeviceVariables.map((variable) => ({
18
+ id: variable,
19
+ value: variable,
20
+ name: variable,
21
+ }))
22
+ : [],
23
+ )
13
24
  let currentType = $derived($optionsStore.TEXTFIELD_SIZE_OPTIONS.find((t) => t.value === component.properties.content.size))
14
25
 
15
26
  const initialAlign = $derived(
@@ -29,6 +40,15 @@
29
40
  {#if component && component.properties}
30
41
  <div class="relative flex flex-row items-start justify-center">
31
42
  <div class="flex w-1/3 flex-col px-2">
43
+ <UI.Select
44
+ label={{ name: $t('constructor.props.variable') }}
45
+ options={VARIABLE_OPTIONS}
46
+ value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
47
+ onUpdate={(value) => {
48
+ updateProperty('id', value.value as string, component, onPropertyChange)
49
+ updateProperty('eventHandler.Variables', value.value as string, component, onPropertyChange)
50
+ }}
51
+ />
32
52
  <UI.Input
33
53
  label={{ name: $t('constructor.props.label') }}
34
54
  value={component.properties.content.name}
package/dist/options.js CHANGED
@@ -54,7 +54,8 @@ export const optionsStore = derived(t, ($t) => {
54
54
  { id: id(), name: '', value: 'bg-red', class: 'bg-red' },
55
55
  { id: id(), name: '', value: 'bg-yellow', class: 'bg-yellow' },
56
56
  { id: id(), name: '', value: 'bg-green', class: 'bg-green' },
57
- { id: id(), name: '', value: 'bg-blue', class: 'bg-blue' },
57
+ { id: id(), name: '', value: 'bg-cyan', class: 'bg-cyan' },
58
+ { id: id(), name: '', value: 'bg-purple', class: 'bg-purple' },
58
59
  ],
59
60
  TEXT_COLOR_OPTIONS: [
60
61
  { id: id(), name: '', value: 'text-[#333] dark:text-[#e2e3e7]', class: 'bg-[var(--shadow-color)] dark:bg-[#e2e3e7] ' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-svelte-ui-lib",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {