poe-svelte-ui-lib 1.9.4 → 1.9.6

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.
@@ -6,11 +6,12 @@
6
6
  id = crypto.randomUUID(),
7
7
  wrapperClass = "",
8
8
  label = { name: "", class: "" },
9
- value = $bindable([0, 0, 0, 0]),
9
+ value = $bindable([0, 0, 0]),
10
+ isHomeButton = false,
10
11
  readonly = false,
11
12
  axes = [
12
- { name: "Roll", minNum: -360, maxNum: 360 },
13
13
  { name: "Pitch", minNum: -360, maxNum: 360 },
14
+ { name: "Roll", minNum: -360, maxNum: 360 },
14
15
  { name: "Yaw", minNum: -360, maxNum: 360 },
15
16
  ],
16
17
  buttonIcon,
@@ -33,7 +34,7 @@
33
34
  mainButton: false,
34
35
  onClick: () => {
35
36
  updateValue(2, +sensitivity)
36
- updateValue(1, -sensitivity)
37
+ updateValue(0, -sensitivity)
37
38
  onUpdate(value)
38
39
  },
39
40
  },
@@ -42,7 +43,7 @@
42
43
  angle: 122,
43
44
  mainButton: true,
44
45
  onClick: () => {
45
- updateValue(1, -sensitivity)
46
+ updateValue(0, -sensitivity)
46
47
  onUpdate(value)
47
48
  },
48
49
  },
@@ -52,7 +53,7 @@
52
53
  mainButton: false,
53
54
  onClick: () => {
54
55
  updateValue(2, -sensitivity)
55
- updateValue(1, -sensitivity)
56
+ updateValue(0, -sensitivity)
56
57
  onUpdate(value)
57
58
  },
58
59
  },
@@ -70,7 +71,7 @@
70
71
  angle: 239,
71
72
  mainButton: false,
72
73
  onClick: () => {
73
- updateValue(1, +sensitivity)
74
+ updateValue(0, +sensitivity)
74
75
  updateValue(2, -sensitivity)
75
76
  onUpdate(value)
76
77
  },
@@ -80,7 +81,7 @@
80
81
  angle: 301,
81
82
  mainButton: true,
82
83
  onClick: () => {
83
- updateValue(1, +sensitivity)
84
+ updateValue(0, +sensitivity)
84
85
  onUpdate(value)
85
86
  },
86
87
  },
@@ -89,7 +90,7 @@
89
90
  angle: 328,
90
91
  mainButton: false,
91
92
  onClick: () => {
92
- updateValue(1, +sensitivity)
93
+ updateValue(0, +sensitivity)
93
94
  updateValue(2, +sensitivity)
94
95
  onUpdate(value)
95
96
  },
@@ -97,7 +98,7 @@
97
98
  ]
98
99
 
99
100
  const updateValue = (index: number, delta: number) => {
100
- const axis = axes[axes.length == 2 ? index - 1 : index]
101
+ const axis = axes[axes.length == 2 && index == 2 ? index - 1 : index]
101
102
  const min = axis.minNum ?? -360
102
103
  const max = axis.maxNum ?? 360
103
104
 
@@ -125,7 +126,7 @@
125
126
 
126
127
  <div id={`${id}-${crypto.randomUUID().slice(0, 6)}`} class={twMerge(`bg-blue relative flex w-full flex-col items-center`, wrapperClass)}>
127
128
  {#if label.name}
128
- <h5 class={twMerge(`w-full px-4 text-center`, label.class)}>{label.name}</h5>
129
+ <h5 class={twMerge(`w-full px-4 text-center`, label.class)}>{label.name} {value}</h5>
129
130
  {/if}
130
131
 
131
132
  {#if !readonly}
@@ -176,11 +177,18 @@
176
177
  {/each}
177
178
  </div>
178
179
  <!-- Кнопка по центру -->
179
- <div class="btn-segment z-20 flex size-20 items-center justify-center rounded-full bg-(--bg-color) shadow-[0_0_15px_rgb(0_0_0_/0.25)]">
180
+ <div class="z-20 flex size-20 items-center justify-center rounded-full bg-(--bg-color) shadow-[0_0_15px_rgb(0_0_0_/0.25)]">
180
181
  <button
181
- class="flex size-18 cursor-pointer items-center justify-center rounded-full p-3.5 [&_svg]:h-full [&_svg]:max-h-full [&_svg]:w-full [&_svg]:max-w-full"
182
- style="background: {value[3] == 1 ? 'color-mix(in srgb, var(--bg-color), var(--shadow-color) 10%)' : 'var(--bg-color)'}"
183
- onclick={() => (value[3] = value[3] == 0 ? 1 : 0)}
182
+ class="flex size-17 cursor-pointer rounded-full p-2 origin-center active:scale-95
183
+ [&_svg]:h-full [&_svg]:max-h-full [&_svg]:w-full [&_svg]:max-w-full"
184
+ style="background: {!isHomeButton && value[3] == 1 ? 'color-mix(in srgb, var(--bg-color), var(--shadow-color) 10%)' : 'var(--bg-color)'}"
185
+ onmouseenter={(e) => {
186
+ if (isHomeButton) e.currentTarget.style.backgroundColor = "color-mix(in srgb, var(--bg-color), var(--shadow-color) 20%)"
187
+ }}
188
+ onmouseleave={(e) => {
189
+ if (isHomeButton) e.currentTarget.style.backgroundColor = "var(--bg-color)"
190
+ }}
191
+ onclick={() => (isHomeButton ? (value = [0, 0, 0]) : (value[3] = value[3] == 0 ? 1 : 0))}
184
192
  >
185
193
  {#if buttonIcon}
186
194
  {#if typeof buttonIcon === "string"}
@@ -190,7 +198,7 @@
190
198
  <IconComponent />
191
199
  {/if}
192
200
  {:else}
193
- <svg xmlns="http://www.w3.org/2000/svg" class="segment-icon" width="32" height="32" viewBox="0 0 24 24"
201
+ <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"
194
202
  ><path
195
203
  fill="currentColor"
196
204
  d="M6 19h3v-5q0-.425.288-.712T10 13h4q.425 0 .713.288T15 14v5h3v-9l-6-4.5L6 10zm-2 0v-9q0-.475.213-.9t.587-.7l6-4.5q.525-.4 1.2-.4t1.2.4l6 4.5q.375.275.588.7T20 10v9q0 .825-.588 1.413T18 21h-4q-.425 0-.712-.288T13 20v-5h-2v5q0 .425-.288.713T10 21H6q-.825 0-1.412-.587T4 19m8-6.75"
@@ -210,12 +218,12 @@
210
218
  class="btn-segment h-full cursor-pointer rounded-l-full px-3.5"
211
219
  title=""
212
220
  onclick={() => {
213
- if (value[0] - sensitivity <= (axes[0].minNum ?? -360)) {
214
- value[0] = axes[0].minNum ?? -360
221
+ if (value[1] - sensitivity <= (axes[1].minNum ?? -360)) {
222
+ value[1] = axes[1].minNum ?? -360
215
223
  onUpdate(value)
216
224
  return
217
225
  }
218
- value[0] = roundToClean(value[0] - sensitivity)
226
+ value[1] = roundToClean(value[1] - sensitivity)
219
227
  onUpdate(value)
220
228
  }}
221
229
  onmouseenter={(e) => (e.currentTarget.style.backgroundColor = "color-mix(in srgb, var(--bg-color), var(--shadow-color) 30%)")}
@@ -234,12 +242,12 @@
234
242
  class="btn-segment h-full cursor-pointer rounded-r-full px-3.5"
235
243
  title=""
236
244
  onclick={() => {
237
- if (value[0] + sensitivity >= (axes[0].maxNum ?? 360)) {
238
- value[0] = axes[0].maxNum ?? 360
245
+ if (value[1] + sensitivity >= (axes[1].maxNum ?? 360)) {
246
+ value[1] = axes[1].maxNum ?? 360
239
247
  onUpdate(value)
240
248
  return
241
249
  }
242
- value[0] = roundToClean(value[0] + sensitivity)
250
+ value[1] = roundToClean(value[1] + sensitivity)
243
251
  onUpdate(value)
244
252
  }}
245
253
  onmouseenter={(e) => (e.currentTarget.style.backgroundColor = "color-mix(in srgb, var(--bg-color), var(--shadow-color) 30%)")}
@@ -302,7 +310,7 @@
302
310
  [&::-webkit-inner-spin-button]:hidden
303
311
  [&::-webkit-outer-spin-button]:hidden`}
304
312
  style="background: color-mix(in srgb, var(--bg-color), var(--back-color) 70%);"
305
- value={value[axes.length == 3 ? index : index + 1]}
313
+ value={value[axes.length == 2 && index == 1 ? index + 1 : index]}
306
314
  id={`${id}-${crypto.randomUUID().slice(0, 6)}`}
307
315
  readonly
308
316
  />
@@ -3,12 +3,8 @@
3
3
  import { t } from "../locales/i18n"
4
4
  import { type UIComponent, type IGraphProps, updateProperty, type IOption, type IUIComponentHandler } from "../types"
5
5
  import * as UI from ".."
6
- import Modal from "../Modal.svelte"
7
6
  import { ICONS } from "../icons"
8
- import Button from "../Button/Button.svelte"
9
- import CrossIcon from "../libIcons/CrossIcon.svelte"
10
7
  import { optionsStore } from "../options"
11
- import { twMerge } from "tailwind-merge"
12
8
  import CommonSnippets from "../CommonSnippets.svelte"
13
9
 
14
10
  const {
@@ -21,8 +17,6 @@
21
17
  forConstructor?: boolean
22
18
  }>()
23
19
 
24
- let showIconLib = $state(false)
25
-
26
20
  const DeviceVariables = getContext<{ id: string; value: string; name: string }[]>("DeviceVariables")
27
21
  let VARIABLE_OPTIONS = $derived(DeviceVariables && Array.isArray(DeviceVariables) ? DeviceVariables : [])
28
22
 
@@ -96,6 +90,16 @@
96
90
  </div>
97
91
  {/snippet}
98
92
 
93
+ {#snippet JoystickHomeButton()}
94
+ <UI.Switch
95
+ label={{ name: $t("constructor.props.joystick.homebutton") }}
96
+ value={component.properties.isHomeButton}
97
+ options={[{ id: crypto.randomUUID(), value: 0, class: "" }]}
98
+ onChange={(value) => {
99
+ updateProperty("isHomeButton", value, component, onPropertyChange)
100
+ }}
101
+ />{/snippet}
102
+
99
103
  {#if forConstructor}
100
104
  <div>
101
105
  <div class="relative flex flex-row items-start justify-center">
@@ -107,6 +111,7 @@
107
111
  <div class="flex w-1/3 flex-col px-2">
108
112
  <CommonSnippets snippet="Label" {component} {onPropertyChange} />
109
113
  <CommonSnippets snippet="LabelAlign" initialValue={initialAlign} {component} {onPropertyChange} />
114
+ {@render JoystickHomeButton()}
110
115
  </div>
111
116
  <div class="flex w-1/3 flex-col px-2">
112
117
  <CommonSnippets
@@ -137,6 +142,7 @@
137
142
  <div class="flex w-1/3 flex-col px-2">
138
143
  <CommonSnippets snippet="Label" {component} {onPropertyChange} />
139
144
  <CommonSnippets snippet="LabelClass" {component} {onPropertyChange} />
145
+ {@render JoystickHomeButton()}
140
146
  </div>
141
147
  <div class="flex w-1/3 flex-col px-2">
142
148
  <CommonSnippets
@@ -144,6 +144,7 @@ const translations = {
144
144
  "constructor.props.map.timeout": "Таймаут маркеров:",
145
145
  "constructor.props.joystick.axes": "Названия осей",
146
146
  "constructor.props.joystick.axes.info": "Поле для ввода названий осей, разделенных пробелами (2 или 3 названия)",
147
+ "constructor.props.joystick.homebutton": "Центральная кнопка сброса",
147
148
  "constructor.props.file.select": "Выберите файл",
148
149
  "constructor.props.file.notselected": "Файл не выбран",
149
150
  "constructor.props.map.loading": "Загрузка карты...",
package/dist/types.d.ts CHANGED
@@ -189,6 +189,7 @@ export interface IJoystickProps {
189
189
  name?: string;
190
190
  class?: string;
191
191
  };
192
+ isHomeButton?: boolean;
192
193
  value?: number[];
193
194
  readonly?: boolean;
194
195
  axes?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-svelte-ui-lib",
3
- "version": "1.9.4",
3
+ "version": "1.9.6",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -37,12 +37,12 @@
37
37
  },
38
38
  "devDependencies": {
39
39
  "@sveltejs/adapter-static": "^3.0.10",
40
- "@sveltejs/kit": "^2.55.0",
40
+ "@sveltejs/kit": "^2.56.1",
41
41
  "@sveltejs/package": "^2.5.7",
42
42
  "@sveltejs/vite-plugin-svelte": "^7.0.0",
43
43
  "@tailwindcss/vite": "^4.2.2",
44
44
  "@types/maplibre-gl": "^1.14.0",
45
- "@types/node": "^25.5.0",
45
+ "@types/node": "^25.5.2",
46
46
  "prettier": "^3.8.1",
47
47
  "prettier-plugin-svelte": "^3.5.1",
48
48
  "prettier-plugin-tailwindcss": "^0.7.2",
@@ -50,8 +50,8 @@
50
50
  "svelte": "^5.55.1",
51
51
  "tailwindcss": "^4.2.2",
52
52
  "tsx": "^4.21.0",
53
- "typescript": "^5.9.3",
54
- "vite": "^8.0.3",
53
+ "typescript": "^6.0.2",
54
+ "vite": "^8.0.5",
55
55
  "vite-plugin-compression": "^0.5.1"
56
56
  }
57
57
  }