poe-svelte-ui-lib 1.6.6 → 1.6.8

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.
@@ -47,7 +47,7 @@
47
47
  {#if !isAtStart}
48
48
  <button
49
49
  transition:slide={{ axis: "x" }}
50
- class="absolute z-10 size-10 translate-y-1/2 cursor-pointer left-1 p-2 rounded-full bg-(--field-color) [&_svg]:h-full [&_svg]:max-h-full [&_svg]:w-full shadow-[0_0_6px_var(--shadow-color)] rotate-180"
50
+ class="absolute z-10 size-10 -translate-y-1/2 cursor-pointer top-1/2 left-1 p-2 rounded-full bg-(--field-color) [&_svg]:h-full [&_svg]:max-h-full [&_svg]:w-full shadow-[0_0_6px_var(--shadow-color)] rotate-180"
51
51
  onclick={() => scrollCarousel(-scrollValue)}>
52
52
  <ArrowIcon />
53
53
  </button>
@@ -55,13 +55,13 @@
55
55
  {#if !isAtEnd}
56
56
  <button
57
57
  transition:slide={{ axis: "x" }}
58
- class="absolute z-10 size-10 translate-y-1/2 cursor-pointer right-1 p-2 rounded-full bg-(--field-color) [&_svg]:h-full [&_svg]:max-h-full [&_svg]:w-full shadow-[0_0_6px_var(--shadow-color)]"
58
+ class="absolute z-10 size-10 -translate-y-1/2 cursor-pointer top-1/2 right-1 p-2 rounded-full bg-(--field-color) [&_svg]:h-full [&_svg]:max-h-full [&_svg]:w-full shadow-[0_0_6px_var(--shadow-color)]"
59
59
  onclick={() => scrollCarousel(scrollValue)}>
60
60
  <ArrowIcon />
61
61
  </button>
62
62
  {/if}
63
63
 
64
- <div {id} bind:this={carouselRef} class="flex overflow-y-hidden gap-2 p-2 h-24">
64
+ <div {id} bind:this={carouselRef} class="flex overflow-hidden gap-2 p-2">
65
65
  {@render children?.()}
66
66
  </div>
67
67
  </div>
@@ -27,21 +27,12 @@
27
27
  }: ITableProps<any> = $props()
28
28
 
29
29
  let buffer: any[] = $state([])
30
-
31
30
  export const clearBuffer = () => {
32
31
  buffer = []
33
32
  }
34
33
  /* Сортировка */
35
- let sortState: {
36
- key: string | null
37
- direction: "asc" | "desc" | null
38
- } = {
39
- key: null,
40
- direction: null,
41
- }
42
-
34
+ let sortState: { key: string | null; direction: "asc" | "desc" | null } = { key: null, direction: null }
43
35
  let isAutoscroll = $state(false)
44
-
45
36
  const logTypeOptions = [
46
37
  { id: crypto.randomUUID(), name: "Error", value: "error", color: "bg-(--red-color)" },
47
38
  { id: crypto.randomUUID(), name: "Warning", value: "warning", color: "bg-(--yellow-color)" },
@@ -73,9 +64,7 @@
73
64
  const numB = strB.match(/\d+/g)?.[0] || ""
74
65
  if (numA && numB) {
75
66
  const numCompare = parseInt(numA, 10) - parseInt(numB, 10)
76
- if (numCompare !== 0) {
77
- return sortState.direction === "asc" ? numCompare : -numCompare
78
- }
67
+ if (numCompare !== 0) return sortState.direction === "asc" ? numCompare : -numCompare
79
68
  }
80
69
  const stringCompare = strA.localeCompare(strB)
81
70
  return sortState.direction === "asc" ? stringCompare : -stringCompare
@@ -95,19 +84,14 @@
95
84
  /* Обработчик автоскролла */
96
85
  const handleAutoScroll = () => {
97
86
  if (!container) return
98
-
99
87
  isAutoscroll = !(container.scrollHeight - container.scrollTop <= container.clientHeight + 50)
100
88
  }
101
89
  const scrollToBottom = () => {
102
- if (!isAutoscroll && container) {
103
- container.scrollTop = container.scrollHeight
104
- }
90
+ if (!isAutoscroll && container) container.scrollTop = container.scrollHeight
105
91
  }
106
92
 
107
93
  $effect(() => {
108
- if (autoscroll && buffer && buffer.length > 0) {
109
- scrollToBottom()
110
- }
94
+ if (autoscroll && buffer && buffer.length > 0) scrollToBottom()
111
95
  })
112
96
 
113
97
  function buttonClick(row: any, button: any) {
@@ -115,41 +99,30 @@
115
99
  else if (button.eventHandler && onClick) {
116
100
  let value: Record<string, boolean | string | number | number[] | object | null> = {}
117
101
  button.eventHandler.Variables.forEach((v: string) => {
118
- if (header.some(h => h.key === v && h.action?.type === "select")) {
119
- value[v] = row[v][0]
120
- } else {
121
- value[v] = row[v]
122
- }
123
- button.eventHandler.Value = JSON.stringify(value)
124
- onClick(button.eventHandler)
102
+ if (header.some(h => h.key === v && h.action?.type === "select")) value[v] = row[v][0]
103
+ else value[v] = row[v]
125
104
  })
105
+ button.eventHandler.Value = JSON.stringify(value)
106
+ onClick(button.eventHandler)
126
107
  }
127
108
  }
128
109
 
129
110
  let isDropdownOpen: number | null = $state(null)
130
- let changedOptions: { index: number; options: ISelectOption<string | number>[] | null }[] = $state([])
131
111
 
132
- const selectOption = (index: number, options: ISelectOption<string | number>[], option: ISelectOption<string | number>, event: MouseEvent) => {
112
+ const selectOption = (index: number, key: any, option: ISelectOption<string | number>, event: MouseEvent) => {
133
113
  event.stopPropagation()
134
114
 
135
- const existingItem = changedOptions.find(item => item.index === index)
136
-
137
- if (existingItem) {
138
- existingItem.options = [option, ...options.filter(opt => opt.id !== option.id)]
139
- } else {
140
- changedOptions = [...changedOptions, { index, options: [option, ...options.filter(opt => opt.id !== option.id)] }]
141
- }
142
-
115
+ let existingItem = body[index][key]
143
116
  isDropdownOpen = null
117
+
118
+ if (existingItem)
119
+ body = [...body].map((row, i) =>
120
+ i === index ? (row = { ...row, [key]: [option.value, ...existingItem.filter((opt: string | number) => opt !== option.value)] }) : row,
121
+ )
144
122
  }
145
123
 
146
124
  let copiedCell = $state({ x: "", y: -1 })
147
- let tooltip = $state({
148
- show: false,
149
- text: "",
150
- x: 0,
151
- y: 0,
152
- })
125
+ let tooltip = $state({ show: false, text: "", x: 0, y: 0 })
153
126
 
154
127
  const showModal = async (text: string, formatting?: (text: string) => string) => {
155
128
  modalData = {
@@ -183,21 +156,11 @@
183
156
  const currentType = type
184
157
  if (currentType === "logger") {
185
158
  header = [
186
- {
187
- key: "color",
188
- label: { name: "Type" },
189
- width: "3rem",
190
- } as ITableHeader<any>,
191
- {
192
- key: "data",
193
- label: { name: "Data" },
194
- width: "calc(100% - 3rem)",
195
- } as ITableHeader<any>,
159
+ { key: "color", label: { name: "Type" }, width: "3rem" } as ITableHeader<any>,
160
+ { key: "data", label: { name: "Data" }, width: "calc(100% - 3rem)" } as ITableHeader<any>,
196
161
  ]
197
162
  }
198
- return () => {
199
- buffer = []
200
- }
163
+ return () => (buffer = [])
201
164
  })
202
165
 
203
166
  $effect(() => {
@@ -255,23 +218,13 @@
255
218
 
256
219
  if (type === "logger") {
257
220
  header = [
258
- {
259
- key: "color",
260
- label: { name: "Type" },
261
- width: "3rem",
262
- } as ITableHeader<any>,
263
- {
264
- key: "data",
265
- label: { name: "Data" },
266
- width: "calc(100% - 3rem)",
267
- } as ITableHeader<any>,
221
+ { key: "color", label: { name: "Type" }, width: "3rem" } as ITableHeader<any>,
222
+ { key: "data", label: { name: "Data" }, width: "calc(100% - 3rem)" } as ITableHeader<any>,
268
223
  ]
269
224
  }
270
225
 
271
226
  return () => {
272
- if (autoscroll) {
273
- container?.removeEventListener("scroll", handleAutoScroll)
274
- }
227
+ if (autoscroll) container?.removeEventListener("scroll", handleAutoScroll)
275
228
  }
276
229
  })
277
230
  </script>
@@ -356,7 +309,7 @@
356
309
  {/if}
357
310
 
358
311
  {#if body || buffer}
359
- {@const isSliced = buffer.length - (dataBuffer.rowsAmmount ?? 10) > 0 ? buffer.length - ((dataBuffer.rowsAmmount ?? 10) % 2) !== 0 : false}
312
+ <!-- {@const isSliced = buffer.length - (dataBuffer.rowsAmmount ?? 10) > 0 ? buffer.length - ((dataBuffer.rowsAmmount ?? 10) % 2) !== 0 : false} -->
360
313
  {@const rows =
361
314
  type == "logger"
362
315
  ? buffer.filter(str => logType.includes(str.type)).slice(-(dataBuffer.rowsAmmount ?? 10))
@@ -392,8 +345,7 @@
392
345
  {/each}
393
346
  </div>
394
347
  {:else if column.action?.type == "select" && column.action?.select}
395
- {@const currentOptions = changedOptions.find(item => item.index === index)?.options}
396
- {@const defaultOptions = Array.isArray(row[column.key])
348
+ {@const options = Array.isArray(row[column.key])
397
349
  ? row[column.key].map((option: string | number) => ({
398
350
  id: crypto.randomUUID(),
399
351
  value: option,
@@ -402,7 +354,7 @@
402
354
  disabled: false,
403
355
  }))
404
356
  : []}
405
- {@const options = currentOptions || defaultOptions}
357
+
406
358
  <div class="relative w-full">
407
359
  <button
408
360
  class={`w-full rounded-2xl border border-(--blue-color) bg-(--back-color) p-1 text-center shadow-[0_0_3px_rgb(0_0_0_/0.25)] transition duration-200
@@ -425,7 +377,7 @@
425
377
  ${option_index === options.length - 1 ? "rounded-b-2xl" : ""} `,
426
378
  option.class,
427
379
  )}
428
- onclick={e => selectOption(index, options, option, e)}>
380
+ onclick={e => selectOption(index, column.key, option, e)}>
429
381
  {option.name}
430
382
  </button>
431
383
  {/each}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-svelte-ui-lib",
3
- "version": "1.6.6",
3
+ "version": "1.6.8",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -46,12 +46,12 @@
46
46
  "@sveltejs/adapter-static": "^3.0.10",
47
47
  "@sveltejs/kit": "^2.49.3",
48
48
  "@sveltejs/package": "^2.5.7",
49
- "@sveltejs/vite-plugin-svelte": "^6.2.1",
49
+ "@sveltejs/vite-plugin-svelte": "^6.2.3",
50
50
  "@types/node": "^25.0.3",
51
51
  "publint": "^0.3.16",
52
52
  "svelte": "^5.46.1",
53
53
  "svelte-preprocess": "^6.0.3",
54
- "vite": "^7.3.0",
54
+ "vite": "^7.3.1",
55
55
  "vite-plugin-compression": "^0.5.1"
56
56
  }
57
57
  }