poe-svelte-ui-lib 1.6.8 → 1.6.9

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.
@@ -107,8 +107,7 @@
107
107
  }
108
108
  }
109
109
 
110
- let isDropdownOpen: number | null = $state(null)
111
-
110
+ let isDropdownOpen: { x: number; y: number } | null = $state(null)
112
111
  const selectOption = (index: number, key: any, option: ISelectOption<string | number>, event: MouseEvent) => {
113
112
  event.stopPropagation()
114
113
 
@@ -121,7 +120,7 @@
121
120
  )
122
121
  }
123
122
 
124
- let copiedCell = $state({ x: "", y: -1 })
123
+ let copiedCell: { x: number; y: number } | null = $state(null)
125
124
  let tooltip = $state({ show: false, text: "", x: 0, y: 0 })
126
125
 
127
126
  const showModal = async (text: string, formatting?: (text: string) => string) => {
@@ -269,21 +268,15 @@
269
268
  {/if}
270
269
 
271
270
  <div
272
- class="relative flex h-full w-full flex-col overflow-hidden rounded-xl border shadow-sm transition duration-200 hover:shadow-md {outline
273
- ? ' border-(--border-color)'
274
- : 'border-transparent'} ">
271
+ class="relative flex h-full w-full flex-col overflow-hidden rounded-xl border shadow-sm transition duration-200 hover:shadow-md
272
+ {outline ? ' border-(--border-color)' : 'border-transparent'} ">
275
273
  <!-- Table Header -->
276
274
  <div class="grid font-semibold" style={`grid-template-columns: ${header.map(c => c.width || "minmax(0, 1fr)").join(" ")};`}>
277
275
  {#each header as column, index (column)}
278
276
  <div
279
277
  class={twMerge(
280
- `items-center justify-center border-l ${outline && index !== 0 ? " border-(--border-color)" : "border-transparent"} ${
281
- column.align === "center"
282
- ? "flex justify-center text-center"
283
- : column.align === "right"
284
- ? "flex justify-end text-right"
285
- : "flex justify-start text-left"
286
- } gap-1 bg-(--bg-color) p-2 text-left`,
278
+ `items-center justify-center flex border-l ${outline && index !== 0 ? " border-(--border-color)" : "border-transparent"}
279
+ ${column.align === "center" ? "justify-center text-center" : column.align === "right" ? "justify-end text-right" : "justify-start text-left"} gap-1 bg-(--bg-color) p-2 text-left`,
287
280
  column.label?.class,
288
281
  )}>
289
282
  <span>{column.label?.name}</span>
@@ -309,7 +302,6 @@
309
302
  {/if}
310
303
 
311
304
  {#if body || buffer}
312
- <!-- {@const isSliced = buffer.length - (dataBuffer.rowsAmmount ?? 10) > 0 ? buffer.length - ((dataBuffer.rowsAmmount ?? 10) % 2) !== 0 : false} -->
313
305
  {@const rows =
314
306
  type == "logger"
315
307
  ? buffer.filter(str => logType.includes(str.type)).slice(-(dataBuffer.rowsAmmount ?? 10))
@@ -319,19 +311,13 @@
319
311
  <!-- Table Body с прокруткой -->
320
312
  <div class="flex-1 overflow-y-auto bg-(--container-color)/50" bind:this={container} onscroll={handleScroll}>
321
313
  <div class="grid min-w-0" style={`grid-template-columns: ${header.map(c => c.width || "minmax(0, 1fr)").join(" ")};`}>
322
- {#each rows as row, index (row)}
314
+ {#each rows as row, i (row)}
323
315
  {#each header as column, j (column)}
324
316
  <div
325
317
  class="relative flex w-full min-w-0 items-center px-2 py-1 wrap-break-word
326
- {index % 2 ? 'bg-(--back-color)/40' : 'bg-[#edeef3] dark:bg-[#1f2a3a]'}
327
- {column.align === 'center'
328
- ? 'flex justify-center text-center'
329
- : column.align === 'right'
330
- ? 'flex justify-end text-right'
331
- : 'flex justify-start text-left'}
332
- border-t
333
- {j !== 0 ? ' border-l ' : ''}
334
- {outline ? 'border-(--border-color)' : 'border-transparent'} ">
318
+ {i % 2 ? 'bg-(--back-color)/40' : 'bg-[#edeef3] dark:bg-[#1f2a3a]'}
319
+ {column.align === 'center' ? 'justify-center text-center' : column.align === 'right' ? 'justify-end text-right' : 'justify-start text-left'}
320
+ border-t {j !== 0 ? ' border-l ' : ''} {outline ? 'border-(--border-color)' : 'border-transparent'}">
335
321
  {#if column.action?.type == "buttons" && column.action?.buttons}
336
322
  <div class="flex w-full flex-col gap-1">
337
323
  {#each column.action?.buttons as button (button)}
@@ -346,24 +332,18 @@
346
332
  </div>
347
333
  {:else if column.action?.type == "select" && column.action?.select}
348
334
  {@const options = Array.isArray(row[column.key])
349
- ? row[column.key].map((option: string | number) => ({
350
- id: crypto.randomUUID(),
351
- value: option,
352
- name: option,
353
- class: "",
354
- disabled: false,
355
- }))
335
+ ? row[column.key].map((option: string | number) => ({ id: crypto.randomUUID(), value: option, name: option }))
356
336
  : []}
357
337
 
358
338
  <div class="relative w-full">
359
339
  <button
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
361
- cursor-pointer hover:shadow-[0_0_6px_rgb(0_0_0_/0.25)]`}
362
- onclick={() => (isDropdownOpen = isDropdownOpen === index ? null : index)}>
340
+ 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
341
+ cursor-pointer hover:shadow-[0_0_6px_rgb(0_0_0_/0.25)]"
342
+ onclick={() => (isDropdownOpen = isDropdownOpen?.x === j && isDropdownOpen.y === i ? null : { x: j, y: i })}>
363
343
  {options[0]?.name || $t("common.select_tag")}
364
344
  </button>
365
345
 
366
- {#if isDropdownOpen === index}
346
+ {#if isDropdownOpen?.x === j && isDropdownOpen.y === i}
367
347
  <div
368
348
  class="absolute top-full left-1/2 z-50 -translate-x-1/2 rounded-b-2xl shadow-[0_0_3px_rgb(0_0_0_/0.25)]"
369
349
  style="width: calc(100% - 1.8rem);"
@@ -374,10 +354,10 @@
374
354
  value={option?.value ? String(option.value) : ""}
375
355
  class={twMerge(
376
356
  `flex h-full w-full cursor-pointer items-center justify-center p-1 inset-shadow-[0_10px_10px_-15px_rgb(0_0_0_/0.5)] duration-250 hover:bg-(--field-color)! bg-(--back-color)
377
- ${option_index === options.length - 1 ? "rounded-b-2xl" : ""} `,
357
+ ${option_index === options.length - 1 ? "rounded-b-2xl" : ""}`,
378
358
  option.class,
379
359
  )}
380
- onclick={e => selectOption(index, column.key, option, e)}>
360
+ onclick={e => selectOption(i, column.key, option, e)}>
381
361
  {option.name}
382
362
  </button>
383
363
  {/each}
@@ -436,12 +416,12 @@
436
416
  onclick={e => {
437
417
  e.preventDefault()
438
418
  navigator.clipboard.writeText(row[column.key])
439
- copiedCell = { x: column.key as string, y: index }
440
- setTimeout(() => (copiedCell = { x: "", y: -1 }), 1000)
419
+ copiedCell = { x: j, y: i }
420
+ setTimeout(() => (copiedCell = null), 1000)
441
421
  }}
442
422
  aria-label="Копировать текст">
443
- <div class=" size-5 text-sm [&_svg]:h-full [&_svg]:max-h-full [&_svg]:w-full [&_svg]:max-w-full">
444
- {#if copiedCell.y === index && copiedCell.x === column.key}
423
+ <div class="size-5 text-sm [&_svg]:h-full [&_svg]:max-h-full [&_svg]:w-full [&_svg]:max-w-full">
424
+ {#if copiedCell?.y === i && copiedCell.x === j}
445
425
  <div
446
426
  class="absolute top-1/2 right-3.5 -translate-y-1/2 transform rounded-md bg-(--green-color) px-1.5 py-1 shadow-lg"
447
427
  transition:fade={{ duration: 200 }}>
@@ -470,8 +450,8 @@
470
450
  {#if tooltip.show}
471
451
  <div
472
452
  class="fixed z-50 w-max max-w-[30%] rounded-md px-2 py-1 text-left text-sm whitespace-pre-wrap shadow-lg"
473
- style="background: color-mix(in srgb, var(--yellow-color) 30%, var(--back-color)); transform: translateX(-50%); left: {tooltip.x +
474
- 10}px; top: {tooltip.y + 10}px;"
453
+ style="background: color-mix(in srgb, var(--yellow-color) 30%, var(--back-color)); transform: translateX(-50%);
454
+ left: {tooltip.x + 10}px; top: {tooltip.y + 10}px;"
475
455
  transition:fly={{ y: 10, duration: 200 }}
476
456
  role="tooltip">
477
457
  {@html tooltip.text}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-svelte-ui-lib",
3
- "version": "1.6.8",
3
+ "version": "1.6.9",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {