poe-svelte-ui-lib 1.5.18 → 1.6.1

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.
@@ -204,7 +204,7 @@
204
204
 
205
205
  <!-- Превью цвета -->
206
206
 
207
- <div class="flex w-25 flex-col items-center">
207
+ <div class="flex flex-col items-center" style="width: 7rem;">
208
208
  <div
209
209
  class={`flex size-15 flex-col justify-center gap-1 rounded-full px-2 font-mono text-sm shadow-sm transition duration-200 select-none ${textColor()}`}
210
210
  style={`background: rgb(${previewBaseColor().join(',')})`}
@@ -36,7 +36,7 @@
36
36
  value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
37
37
  onUpdate={(value) => {
38
38
  updateProperty('id', value.value as string, component, onPropertyChange)
39
- onPropertyChange({ name: value.name?.split('—')[1].trim(), eventHandler: { Variables: value.value as string } })
39
+ onPropertyChange({ name: value.name?.split('—')[1].trim(), eventHandler: { Variables: [value.value as string] } })
40
40
  }}
41
41
  />
42
42
  <UI.Select
@@ -36,7 +36,7 @@
36
36
  value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
37
37
  onUpdate={(value) => {
38
38
  updateProperty('id', value.value as string, component, onPropertyChange)
39
- onPropertyChange({ name: value.name?.split('—')[1].trim(), eventHandler: { Variables: value.value as string } })
39
+ onPropertyChange({ name: value.name?.split('—')[1].trim(), eventHandler: { Variables: [value.value as string] } })
40
40
  }}
41
41
  />
42
42
  </div>
@@ -52,6 +52,24 @@
52
52
  onUpdate?.(value as string)
53
53
  }
54
54
  }
55
+
56
+ $effect(() => {
57
+ if (type === 'number' && typeof value == 'number') {
58
+ value = roundToClean(value)
59
+ }
60
+ })
61
+
62
+ const roundToClean = (num: number): number => {
63
+ if (Number.isInteger(num)) return num
64
+
65
+ const rounded1 = Number(num.toFixed(1))
66
+ if (Math.abs(rounded1 - num) < 1e-10) return rounded1
67
+
68
+ const rounded2 = Number(num.toFixed(2))
69
+ if (Math.abs(rounded2 - num) < 1e-10) return rounded2
70
+
71
+ return rounded2
72
+ }
55
73
  </script>
56
74
 
57
75
  <div class={twMerge(`bg-max ${type === 'text-area' ? 'h-full' : ''} relative flex w-full flex-col px-1 items-center`, wrapperClass)}>
@@ -97,7 +97,7 @@
97
97
  value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
98
98
  onUpdate={(value) => {
99
99
  updateProperty('id', value.value as string)
100
- onPropertyChange({ name: value.name?.split('—')[1].trim(), eventHandler: { Variables: value.value as string } })
100
+ onPropertyChange({ name: value.name?.split('—')[1].trim(), eventHandler: { Variables: [value.value as string] } })
101
101
  }}
102
102
  />
103
103
  <UI.Select
@@ -20,7 +20,7 @@
20
20
  {
21
21
  id: 'right',
22
22
  angle: 30.5,
23
- content: true,
23
+ mainButton: true,
24
24
  onClick: () => {
25
25
  updateValue(2, +sensitivity)
26
26
  onUpdate(value)
@@ -29,7 +29,7 @@
29
29
  {
30
30
  id: 'bottom-right',
31
31
  angle: 58,
32
- content: false,
32
+ mainButton: false,
33
33
  onClick: () => {
34
34
  updateValue(2, +sensitivity)
35
35
  updateValue(1, -sensitivity)
@@ -39,7 +39,7 @@
39
39
  {
40
40
  id: 'bottom',
41
41
  angle: 122,
42
- content: true,
42
+ mainButton: true,
43
43
  onClick: () => {
44
44
  updateValue(1, -sensitivity)
45
45
  onUpdate(value)
@@ -48,7 +48,7 @@
48
48
  {
49
49
  id: 'bottom-left',
50
50
  angle: 149.5,
51
- content: false,
51
+ mainButton: false,
52
52
  onClick: () => {
53
53
  updateValue(2, -sensitivity)
54
54
  updateValue(1, -sensitivity)
@@ -58,7 +58,7 @@
58
58
  {
59
59
  id: 'left',
60
60
  angle: 212,
61
- content: true,
61
+ mainButton: true,
62
62
  onClick: () => {
63
63
  updateValue(2, -sensitivity)
64
64
  onUpdate(value)
@@ -67,7 +67,7 @@
67
67
  {
68
68
  id: 'top-left',
69
69
  angle: 239,
70
- content: false,
70
+ mainButton: false,
71
71
  onClick: () => {
72
72
  updateValue(1, +sensitivity)
73
73
  updateValue(2, -sensitivity)
@@ -77,7 +77,7 @@
77
77
  {
78
78
  id: 'top',
79
79
  angle: 301,
80
- content: true,
80
+ mainButton: true,
81
81
  onClick: () => {
82
82
  updateValue(1, +sensitivity)
83
83
  onUpdate(value)
@@ -86,7 +86,7 @@
86
86
  {
87
87
  id: 'top-right',
88
88
  angle: 328,
89
- content: false,
89
+ mainButton: false,
90
90
  onClick: () => {
91
91
  updateValue(1, +sensitivity)
92
92
  updateValue(2, +sensitivity)
@@ -140,17 +140,23 @@
140
140
  title=""
141
141
  >
142
142
  <span
143
- class="relative flex w-full origin-left items-center justify-center pl-[60%] h-[{direction.content
144
- ? 2 * 5 * Math.sin((Math.PI * 65) / 360)
145
- : 2 * 5 * Math.sin((Math.PI * 25) / 360)}rem] pointer-events-auto
146
- {direction.content ? 'bg-(--bg-color)' : ''}
143
+ class="relative flex w-full origin-left items-center justify-center pl-[60%] pointer-events-auto
144
+ {direction.mainButton ? 'bg-(--bg-color)' : ''}
147
145
  "
148
- style="transform: rotate({angle * index}deg); clip-path: polygon(100% 0, {clipPos}% 0, 0 50%, {clipPos}% 100%, 100% 100%)"
146
+ style=" height: {direction.mainButton
147
+ ? 2 * 5 * Math.sin((Math.PI * 65) / 360)
148
+ : 2 * 5 * Math.sin((Math.PI * 25) / 360)}rem; transform: rotate({angle *
149
+ index}deg); clip-path: polygon(100% 0, {clipPos}% 0, 0 50%, {clipPos}% 100%, 100% 100%)
150
+ "
149
151
  role="application"
150
152
  onmouseenter={(e) => (e.currentTarget.style.backgroundColor = 'color-mix(in srgb, var(--bg-color), var(--shadow-color) 20%)')}
151
153
  onmouseleave={(e) => (e.currentTarget.style.backgroundColor = 'var(--bg-color)')}
152
154
  >
153
- <svg xmlns="http://www.w3.org/2000/svg" width={direction.content ? 32 : 16} height={direction.content ? 32 : 16} viewBox="0 0 24 24"
155
+ <svg
156
+ xmlns="http://www.w3.org/2000/svg"
157
+ width={direction.mainButton ? 32 : 16}
158
+ height={direction.mainButton ? 32 : 16}
159
+ viewBox="0 0 24 24"
154
160
  ><path
155
161
  fill="currentColor"
156
162
  d="M12.6 12L8.7 8.1q-.275-.275-.275-.7t.275-.7t.7-.275t.7.275l4.6 4.6q.15.15.213.325t.062.375t-.062.375t-.213.325l-4.6 4.6q-.275.275-.7.275t-.7-.275t-.275-.7t.275-.7z"
@@ -22,14 +22,8 @@
22
22
 
23
23
  let showIconLib = $state(false)
24
24
 
25
- let Header: ISelectOption = $derived(
26
- $optionsStore.HEADER_OPTIONS.find((h) => h.value === component.eventHandler.Header) ?? {
27
- id: '',
28
- name: '',
29
- value: '',
30
- class: '!w-1/4',
31
- },
32
- )
25
+ const DeviceVariables = getContext<{ id: string; value: string; name: string }[]>('DeviceVariables')
26
+ let VARIABLE_OPTIONS = $derived(DeviceVariables && Array.isArray(DeviceVariables) ? DeviceVariables : [])
33
27
 
34
28
  const initialAlign = $derived(
35
29
  $optionsStore.TEXT_ALIGN_OPTIONS.find((a) =>
@@ -50,45 +44,25 @@
50
44
  <!-- Сообщение для отправки в ws по нажатию кнопки -->
51
45
  <div class="flex w-1/3 flex-col items-center px-2">
52
46
  <UI.Select
53
- label={{ name: $t('constructor.props.header') }}
47
+ label={{ name: $t('constructor.props.variable') }}
48
+ options={VARIABLE_OPTIONS}
49
+ value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
50
+ onUpdate={(value) => {
51
+ updateProperty('id', value.value as string, component, onPropertyChange)
52
+ onPropertyChange({ name: value.name?.split('—')[1].trim(), eventHandler: { Variables: [value.value as string] } })
53
+ }}
54
+ />
55
+ <UI.Select
56
+ label={{ name: $t('constructor.props.action') }}
54
57
  type="buttons"
55
- value={Header}
56
- options={$optionsStore.HEADER_OPTIONS}
58
+ value={$optionsStore.SHORT_ARGUMENT_OPTION.find((h) => h.value === component.eventHandler.Argument)}
59
+ options={$optionsStore.SHORT_ARGUMENT_OPTION}
57
60
  onUpdate={(option) => {
58
- Header = { ...option }
59
- onPropertyChange({ eventHandler: { Header: Header.value as string } })
61
+ updateProperty('eventHandler.Argument', option.value as string, component, onPropertyChange)
62
+
63
+ onPropertyChange({ eventHandler: { Argument: option.value as string } })
60
64
  }}
61
65
  />
62
- {#if Header.value === 'SET'}
63
- <UI.Select
64
- label={{ name: $t('constructor.props.argument') }}
65
- type="buttons"
66
- value={$optionsStore.FULL_ARGUMENT_OPTION.find((h) => h.value === component.eventHandler.Argument) ??
67
- $optionsStore.FULL_ARGUMENT_OPTION.find((h) => h.value === '')}
68
- options={$optionsStore.FULL_ARGUMENT_OPTION}
69
- onUpdate={(option) => {
70
- onPropertyChange({ eventHandler: { Argument: option.value as string } })
71
- }}
72
- />
73
- {/if}
74
- <UI.Input
75
- label={{ name: Header.value !== 'SET' ? $t('constructor.props.argument') : '' }}
76
- wrapperClass="{Header.value === 'SET' ? 'mt-1' : ''} "
77
- value={component.eventHandler.Argument}
78
- maxlength={32}
79
- disabled={Header.value === 'SET' && (component.eventHandler.Argument == 'Save' || component.eventHandler.Argument == 'NoSave')}
80
- help={{ info: $t('constructor.props.argument.info'), autocomplete: 'on', regExp: /^[a-zA-Z0-9\-_]{0,32}$/ }}
81
- onUpdate={(value) => onPropertyChange({ eventHandler: { Argument: value as string } })}
82
- />
83
- {#if (component.eventHandler.Argument !== 'Save' && component.eventHandler.Argument !== 'NoSave') || Header.value === 'SET'}
84
- <UI.Input
85
- label={{ name: $t('constructor.props.value') }}
86
- value={component.eventHandler.Value}
87
- help={{ info: $t('constructor.props.value.info') }}
88
- maxlength={500}
89
- onUpdate={(value) => onPropertyChange({ eventHandler: { Value: value as string } })}
90
- />
91
- {/if}
92
66
  </div>
93
67
  <div class="flex w-1/3 flex-col px-2">
94
68
  <UI.Select
@@ -42,7 +42,7 @@
42
42
  value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
43
43
  onUpdate={(value) => {
44
44
  updateProperty('id', value.value as string, component, onPropertyChange)
45
- onPropertyChange({ name: value.name?.split('—')[1].trim(), eventHandler: { Variables: value.value as string } })
45
+ onPropertyChange({ name: value.name?.split('—')[1].trim(), eventHandler: { Variables: [value.value as string] } })
46
46
  }}
47
47
  />
48
48
  </div>
@@ -41,7 +41,7 @@
41
41
  value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
42
42
  onUpdate={(value) => {
43
43
  updateProperty('id', value.value as string, component, onPropertyChange)
44
- onPropertyChange({ name: value.name?.split('—')[1].trim(), eventHandler: { Variables: value.value as string } })
44
+ onPropertyChange({ name: value.name?.split('—')[1].trim(), eventHandler: { Variables: [value.value as string] } })
45
45
  }}
46
46
  />
47
47
  <UI.Select
@@ -81,7 +81,7 @@
81
81
  value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
82
82
  onUpdate={(value) => {
83
83
  updateProperty('id', value.value as string, component, onPropertyChange)
84
- onPropertyChange({ eventHandler: { Variables: value.value as string } })
84
+ onPropertyChange({ eventHandler: { Variables: [value.value as string] } })
85
85
  }}
86
86
  />
87
87
  <UI.Select
@@ -41,7 +41,7 @@
41
41
  value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
42
42
  onUpdate={(value) => {
43
43
  updateProperty('id', value.value as string, component, onPropertyChange)
44
- onPropertyChange({ name: value.name?.split('—')[1].trim(), eventHandler: { Variables: value.value as string } })
44
+ onPropertyChange({ name: value.name?.split('—')[1].trim(), eventHandler: { Variables: [value.value as string] } })
45
45
  }}
46
46
  />
47
47
  <UI.Select
@@ -37,7 +37,7 @@
37
37
  value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
38
38
  onUpdate={(value) => {
39
39
  updateProperty('id', value.value as string, component, onPropertyChange)
40
- onPropertyChange({ name: value.name?.split('—')[1].trim(), eventHandler: { Variables: value.value as string } })
40
+ onPropertyChange({ name: value.name?.split('—')[1].trim(), eventHandler: { Variables: [value.value as string] } })
41
41
  }}
42
42
  />
43
43
  <UI.Select
@@ -212,6 +212,11 @@
212
212
 
213
213
  $effect(() => {
214
214
  if (body && dataBuffer.stashData && type == 'table') {
215
+ if (Array.isArray(body)) {
216
+ for (let i = 0; i < body.length; i++) {
217
+ buffer = [...buffer, body[i]]
218
+ }
219
+ } else buffer = [...buffer, body]
215
220
  buffer = [...buffer, body]
216
221
  if (buffer.length > (dataBuffer.rowsAmmount ?? 10)) {
217
222
  buffer = buffer.slice(-(dataBuffer.rowsAmmount ?? 10))
@@ -101,7 +101,7 @@
101
101
  value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
102
102
  onUpdate={(value) => {
103
103
  updateProperty('id', value.value as string, component, onPropertyChange)
104
- onPropertyChange({ name: value.name?.split('—')[1].trim(), eventHandler: { Variables: value.value as string } })
104
+ onPropertyChange({ name: value.name?.split('—')[1].trim(), eventHandler: { Variables: [value.value as string] } })
105
105
  }}
106
106
  />
107
107
  <UI.Select
@@ -43,7 +43,7 @@
43
43
  value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
44
44
  onUpdate={(value) => {
45
45
  updateProperty('id', value.value as string, component, onPropertyChange)
46
- onPropertyChange({ name: value.name?.split('—')[1].trim(), eventHandler: { Variables: value.value as string } })
46
+ onPropertyChange({ name: value.name?.split('—')[1].trim(), eventHandler: { Variables: [value.value as string] } })
47
47
  }}
48
48
  />
49
49
  <UI.Input
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-svelte-ui-lib",
3
- "version": "1.5.18",
3
+ "version": "1.6.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -47,7 +47,7 @@
47
47
  "@sveltejs/kit": "^2.49.2",
48
48
  "@sveltejs/package": "^2.5.7",
49
49
  "@sveltejs/vite-plugin-svelte": "^6.2.1",
50
- "@types/node": "^25.0.2",
50
+ "@types/node": "^25.0.3",
51
51
  "publint": "^0.3.16",
52
52
  "svelte": "^5.46.0",
53
53
  "svelte-preprocess": "^6.0.3",