poe-svelte-ui-lib 1.5.6 → 1.5.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.
@@ -81,8 +81,8 @@
81
81
  <div class="flex w-full flex-col gap-2">
82
82
  {#each innerValue as val}
83
83
  <div class="flex h-7 w-full items-center gap-2 rounded-full bg-(--bg-color) px-2 shadow-sm">
84
- <span class="m-auto font-semibold">{roundToClean(Number(numericValue(val)))}{number.units}</span>
85
- <div class="relative my-auto h-3.5 w-[85%] rounded-full bg-(--back-color)/40">
84
+ <span class="m-auto w-20 font-semibold">{roundToClean(Number(numericValue(val)))}{number.units}</span>
85
+ <div class="relative my-auto h-3.5 flex-1 rounded-full bg-(--back-color)/40">
86
86
  <div class="absolute top-0 left-0 flex h-full rounded-full bg-(--field-color)" style="width: {progressPercent(val)}%;"></div>
87
87
  </div>
88
88
  </div>
@@ -20,7 +20,7 @@
20
20
  onUpdate,
21
21
  }: ISelectProps<T> = $props()
22
22
 
23
- let searchValue = $state('')
23
+ let searchValue: any = $state('')
24
24
  let filteredOptions = $state<ISelectOption<T>[]>([])
25
25
 
26
26
  /* Закрытие при клике вне компонента */
@@ -31,7 +31,16 @@
31
31
  }
32
32
 
33
33
  $effect(() => {
34
- searchValue = value?.name ?? ''
34
+ if (value?.name) {
35
+ searchValue = value?.name
36
+ } else if (value == undefined) {
37
+ const newOption: ISelectOption<T> = {
38
+ id: `input-${searchValue}`,
39
+ name: searchValue,
40
+ value: searchValue as T,
41
+ }
42
+ searchValue = newOption.value
43
+ }
35
44
  })
36
45
 
37
46
  onMount(() => {
@@ -2,11 +2,13 @@
2
2
  <script lang="ts">
3
3
  import { twMerge } from 'tailwind-merge'
4
4
  import type { ISwitchProps } from '../types'
5
+ import { fly } from 'svelte/transition'
5
6
 
6
7
  let {
7
8
  id = crypto.randomUUID(),
8
9
  wrapperClass = '',
9
10
  label = { name: '', class: '', captionLeft: '', captionRight: '' },
11
+ hiddenInfo = '',
10
12
  height = '2rem',
11
13
  type = 'horizontal',
12
14
  options = [],
@@ -15,6 +17,8 @@
15
17
  onChange = () => {},
16
18
  }: ISwitchProps = $props()
17
19
 
20
+ let showInfo = $state(false)
21
+
18
22
  let localOptions = $derived(bitMode ? options : options.slice(0, 1))
19
23
 
20
24
  let checkedOptions: boolean[] = $derived(
@@ -118,12 +122,12 @@
118
122
  </div>
119
123
  </div>
120
124
  {:else}
121
- <div class={twMerge('bg-blue m-1 flex items-center justify-center gap-2', wrapperClass)}>
125
+ <div class={twMerge(' relative bg-blue m-1 flex items-center justify-center gap-2', wrapperClass)}>
122
126
  <input
123
127
  id={ID}
124
128
  type="checkbox"
125
129
  checked={checkedOptions[0]}
126
- disabled={localOptions[0].disabled}
130
+ disabled={localOptions[0].disabled ?? false}
127
131
  class="
128
132
  relative size-8 cursor-pointer appearance-none rounded-2xl border border-(--bg-color)
129
133
  bg-white shadow-sm transition duration-200 after:origin-bottom-left after:opacity-0
@@ -137,9 +141,27 @@
137
141
  disabled:cursor-not-allowed disabled:opacity-70
138
142
  "
139
143
  onchange={() => handleToggle(0)}
144
+ onmouseenter={() => {
145
+ if (hiddenInfo) showInfo = true
146
+ }}
147
+ onmouseleave={() => {
148
+ if (hiddenInfo) showInfo = false
149
+ }}
140
150
  />
141
- <label for={ID} class={twMerge("{disabled ? 'cursor-not-allowed opacity-70' : 'cursor-pointer'} ml-1 select-none", label.class)}>
142
- {label.name}
143
- </label>
151
+ {#if showInfo && hiddenInfo}
152
+ <div
153
+ transition:fly={{ y: -15, duration: 300 }}
154
+ class="absolute bottom-full left-1/2 z-50 mb-2 w-max max-w-xs rounded-md bg-(--container-color) px-3 py-1 text-sm shadow-lg"
155
+ style="transform: translateX(-50%);"
156
+ >
157
+ {hiddenInfo}
158
+ <div class="absolute top-full left-1/2 h-2 w-2 -translate-x-1/2 -translate-y-1/2 rotate-45 transform bg-(--container-color)"></div>
159
+ </div>
160
+ {/if}
161
+ {#if label.name}
162
+ <label for={ID} class={twMerge("{disabled ? 'cursor-not-allowed opacity-70' : 'cursor-pointer'} ml-1 select-none", label.class)}>
163
+ {label.name}
164
+ </label>
165
+ {/if}
144
166
  </div>
145
167
  {/if}
@@ -311,12 +311,14 @@
311
311
  </div>
312
312
 
313
313
  {#if body || dataBuffer}
314
+ {@const isSliced = dataBuffer.length - rowsAmmount > 0 ? dataBuffer.length - (rowsAmmount % 2) !== 0 : false}
314
315
  {@const rows =
315
316
  type == 'logger'
316
317
  ? dataBuffer.filter((str) => logType.includes(str.type)).slice(-rowsAmmount)
317
318
  : stashData
318
319
  ? dataBuffer.slice(-rowsAmmount)
319
320
  : body}
321
+
320
322
  <!-- Table Body с прокруткой -->
321
323
  <div class="flex-1 overflow-y-auto bg-(--container-color)/50" bind:this={container} onscroll={handleScroll}>
322
324
  <div class="grid min-w-0" style={`grid-template-columns: ${header.map((c) => c.width || 'minmax(0, 1fr)').join(' ')};`}>
package/dist/types.d.ts CHANGED
@@ -149,6 +149,7 @@ export interface ISwitchProps {
149
149
  captionLeft?: string;
150
150
  captionRight?: string;
151
151
  };
152
+ hiddenInfo?: string;
152
153
  options?: ISelectOption<number>[];
153
154
  bitMode?: boolean;
154
155
  type?: 'horizontal' | 'vertical' | 'checkbox';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-svelte-ui-lib",
3
- "version": "1.5.6",
3
+ "version": "1.5.9",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -48,7 +48,7 @@
48
48
  "@sveltejs/package": "^2.5.7",
49
49
  "@sveltejs/vite-plugin-svelte": "^6.2.1",
50
50
  "@types/node": "^24.10.2",
51
- "publint": "^0.3.15",
51
+ "publint": "^0.3.16",
52
52
  "svelte": "^5.45.8",
53
53
  "svelte-preprocess": "^6.0.3",
54
54
  "vite": "^7.2.7",