poe-svelte-ui-lib 1.5.9 → 1.5.10

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.
@@ -5,6 +5,7 @@
5
5
  import { fade, fly } from 'svelte/transition'
6
6
  import { twMerge } from 'tailwind-merge'
7
7
  import { onMount } from 'svelte'
8
+ import ButtonClear from '../libIcons/ButtonClear.svelte'
8
9
 
9
10
  let {
10
11
  id = crypto.randomUUID(),
@@ -13,9 +14,8 @@
13
14
  body = $bindable(),
14
15
  header = [],
15
16
  footer = '',
16
- stashData = false,
17
+ dataBuffer = { stashData: false, rowsAmmount: 10, cleanButton: true, cleanClass: '' },
17
18
  type = 'table',
18
- rowsAmmount = 10,
19
19
  outline = false,
20
20
  cursor = null,
21
21
  loader,
@@ -25,7 +25,7 @@
25
25
  onClick,
26
26
  }: ITableProps<any> = $props()
27
27
 
28
- let dataBuffer: any[] = $state([])
28
+ let buffer: any[] = $state([])
29
29
 
30
30
  /* Сортировка */
31
31
  let sortState: {
@@ -101,7 +101,7 @@
101
101
  }
102
102
 
103
103
  $effect(() => {
104
- if (autoscroll && dataBuffer && dataBuffer.length > 0) {
104
+ if (autoscroll && buffer && buffer.length > 0) {
105
105
  scrollToBottom()
106
106
  }
107
107
  })
@@ -156,8 +156,8 @@
156
156
 
157
157
  $effect(() => {
158
158
  if (body && type == 'logger') {
159
- dataBuffer = [
160
- ...dataBuffer,
159
+ buffer = [
160
+ ...buffer,
161
161
  {
162
162
  type: Object.entries(body)[0][1] as string,
163
163
  color: `<div class='size-6 rounded-full ${logTypeOptions.find((o) => o.value == body.logLevel)?.color}'></div>`,
@@ -165,8 +165,8 @@
165
165
  },
166
166
  ]
167
167
 
168
- if (dataBuffer.length > rowsAmmount * 5) {
169
- dataBuffer = dataBuffer.slice(-(rowsAmmount * 5))
168
+ if (dataBuffer && buffer.length > (dataBuffer.rowsAmmount ?? 10) * 5) {
169
+ buffer = buffer.slice(-((dataBuffer.rowsAmmount ?? 10) * 5))
170
170
  }
171
171
 
172
172
  body = null
@@ -174,10 +174,10 @@
174
174
  })
175
175
 
176
176
  $effect(() => {
177
- if (body && stashData && type == 'table') {
178
- dataBuffer = [...dataBuffer, body]
179
- if (dataBuffer.length > rowsAmmount) {
180
- dataBuffer = dataBuffer.slice(-rowsAmmount)
177
+ if (body && dataBuffer.stashData && type == 'table') {
178
+ buffer = [...buffer, body]
179
+ if (buffer.length > (dataBuffer.rowsAmmount ?? 10)) {
180
+ buffer = buffer.slice(-(dataBuffer.rowsAmmount ?? 10))
181
181
  }
182
182
 
183
183
  body = null
@@ -201,7 +201,7 @@
201
201
  ]
202
202
  }
203
203
  return () => {
204
- dataBuffer = []
204
+ buffer = []
205
205
  }
206
206
  })
207
207
 
@@ -236,7 +236,7 @@
236
236
 
237
237
  <div
238
238
  id={`${id}-${crypto.randomUUID().slice(0, 6)}`}
239
- class={twMerge(`bg-blue flex h-full w-full gap-2 items-center flex-col overflow-hidden`, wrapperClass)}
239
+ class={twMerge(`bg-blue flex h-full w-full items-center ${type == 'logger' ? 'gap-2' : ''} flex-col overflow-hidden`, wrapperClass)}
240
240
  >
241
241
  {#if label.name}
242
242
  <h5 class={twMerge(`w-full px-4 text-center`, label.class)}>{label.name}</h5>
@@ -278,7 +278,7 @@
278
278
  {/if}
279
279
 
280
280
  <div
281
- class="flex h-full w-full flex-col overflow-hidden rounded-xl border shadow-sm transition duration-200 hover:shadow-md {outline
281
+ class="relative flex h-full w-full flex-col overflow-hidden rounded-xl border shadow-sm transition duration-200 hover:shadow-md {outline
282
282
  ? ' border-(--border-color)'
283
283
  : 'border-transparent'} "
284
284
  >
@@ -309,14 +309,22 @@
309
309
  </div>
310
310
  {/each}
311
311
  </div>
312
+ {#if dataBuffer.cleanButton}
313
+ <button
314
+ class={twMerge('absolute right-2 bg-(--back-color) rounded-full p-1 cursor-pointer', dataBuffer.cleanClass)}
315
+ onclick={() => (buffer = [])}
316
+ >
317
+ <ButtonClear />
318
+ </button>
319
+ {/if}
312
320
 
313
- {#if body || dataBuffer}
314
- {@const isSliced = dataBuffer.length - rowsAmmount > 0 ? dataBuffer.length - (rowsAmmount % 2) !== 0 : false}
321
+ {#if body || buffer}
322
+ {@const isSliced = buffer.length - (dataBuffer.rowsAmmount ?? 10) > 0 ? buffer.length - ((dataBuffer.rowsAmmount ?? 10) % 2) !== 0 : false}
315
323
  {@const rows =
316
324
  type == 'logger'
317
- ? dataBuffer.filter((str) => logType.includes(str.type)).slice(-rowsAmmount)
318
- : stashData
319
- ? dataBuffer.slice(-rowsAmmount)
325
+ ? buffer.filter((str) => logType.includes(str.type)).slice(-(dataBuffer.rowsAmmount ?? 10))
326
+ : dataBuffer.stashData
327
+ ? buffer.slice(-(dataBuffer.rowsAmmount ?? 10))
320
328
  : body}
321
329
 
322
330
  <!-- Table Body с прокруткой -->
@@ -99,7 +99,7 @@
99
99
  value={$optionsStore.TABLE_TYPE_OPTIONS.find((o) => o.value === component.properties.type)}
100
100
  onUpdate={(option) => {
101
101
  updateProperty('type', option.value as string, component, onPropertyChange)
102
- if (option.value === 'logger') updateProperty('stashData', true, component, onPropertyChange)
102
+ if (option.value === 'logger') updateProperty('dataBuffer.stashData', true, component, onPropertyChange)
103
103
  }}
104
104
  />
105
105
  </div>
@@ -120,10 +120,10 @@
120
120
  />
121
121
  <UI.Switch
122
122
  label={{ name: $t('constructor.props.table.stashData') }}
123
- value={component.properties.stashData}
123
+ value={component.properties.dataBuffer.stashData}
124
124
  options={[{ id: crypto.randomUUID(), value: 0, class: '', disabled: component.properties.type === 'logger' }]}
125
125
  onChange={(value) => {
126
- updateProperty('stashData', value, component, onPropertyChange)
126
+ updateProperty('dataBuffer.stashData', value, component, onPropertyChange)
127
127
  }}
128
128
  />
129
129
  </div>
@@ -144,8 +144,8 @@
144
144
  <UI.Input
145
145
  label={{ name: $t('constructor.props.table.buffersize') }}
146
146
  type="number"
147
- value={component.properties.rowsAmmount}
148
- onUpdate={(value) => updateProperty('rowsAmmount', value as string, component, onPropertyChange)}
147
+ value={component.properties.dataBuffer.rowsAmmount}
148
+ onUpdate={(value) => updateProperty('dataBuffer.rowsAmmount', value as string, component, onPropertyChange)}
149
149
  />
150
150
  {/if}
151
151
  </div>
@@ -373,23 +373,23 @@
373
373
  value={$optionsStore.TABLE_TYPE_OPTIONS.find((o) => o.value === component.properties.type)}
374
374
  onUpdate={(option) => {
375
375
  updateProperty('type', option.value as string, component, onPropertyChange)
376
- if (option.value === 'logger') updateProperty('stashData', true, component, onPropertyChange)
376
+ if (option.value === 'logger') updateProperty('dataBuffer.stashData', true, component, onPropertyChange)
377
377
  }}
378
378
  />
379
379
  <UI.Switch
380
380
  label={{ name: $t('constructor.props.table.stashData') }}
381
- value={component.properties.stashData}
381
+ value={component.properties.dataBuffer.stashData}
382
382
  options={[{ id: crypto.randomUUID(), value: 0, class: '', disabled: component.properties.type === 'logger' }]}
383
383
  onChange={(value) => {
384
- updateProperty('stashData', value, component, onPropertyChange)
384
+ updateProperty('dataBuffer.stashData', value, component, onPropertyChange)
385
385
  }}
386
386
  />
387
387
  {#if component.properties.stashData}
388
388
  <UI.Input
389
389
  label={{ name: $t('constructor.props.table.buffersize') }}
390
390
  type="number"
391
- value={component.properties.rowsAmmount}
392
- onUpdate={(value) => updateProperty('rowsAmmount', value as string, component, onPropertyChange)}
391
+ value={component.properties.dataBuffer.rowsAmmount}
392
+ onUpdate={(value) => updateProperty('dataBuffer.rowsAmmount', value as string, component, onPropertyChange)}
393
393
  />
394
394
  {/if}
395
395
  </div>
@@ -0,0 +1,12 @@
1
+ <script lang="ts"></script>
2
+
3
+ <svg xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 24 24"
4
+ ><g fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="1.5"
5
+ ><path
6
+ stroke-linecap="round"
7
+ d="m12 13l3 2m-3-2c-4.48 2.746-7.118 1.78-9 .85c0 2.08.681 3.82 1.696 5.15M12 13l3-4.586M15 15c-.219 2.037-1.573 6.185-4.844 7c-1.815 0-3.988-1.07-5.46-3M15 15l2.598-5m0 0l3.278-6.31a1.166 1.166 0 0 0-.524-1.567a1.174 1.174 0 0 0-1.544.47L15 8.414M17.598 10L15 8.414M4.696 19c1.038.167 3.584.2 5.46-1"
8
+ /><path
9
+ d="m6 4l.221.597c.29.784.435 1.176.72 1.461c.286.286.678.431 1.462.72L9 7l-.597.221c-.784.29-1.176.435-1.461.72c-.286.286-.431.678-.72 1.462L6 10l-.221-.597c-.29-.784-.435-1.176-.72-1.461c-.286-.286-.678-.431-1.462-.72L3 7l.597-.221c.784-.29 1.176-.435 1.461-.72c.286-.286.431-.678.72-1.462z"
10
+ /></g
11
+ ></svg
12
+ >
@@ -0,0 +1,18 @@
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
14
+ declare const ButtonClear: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
15
+ [evt: string]: CustomEvent<any>;
16
+ }, {}, {}, string>;
17
+ type ButtonClear = InstanceType<typeof ButtonClear>;
18
+ export default ButtonClear;
package/dist/types.d.ts CHANGED
@@ -267,8 +267,12 @@ export interface ITableProps<T extends object> {
267
267
  body: T[] | T | null;
268
268
  footer?: string;
269
269
  type?: 'table' | 'logger';
270
- stashData?: boolean;
271
- rowsAmmount?: number;
270
+ dataBuffer?: {
271
+ stashData?: boolean;
272
+ rowsAmmount?: number;
273
+ cleanButton?: boolean;
274
+ cleanClass?: string;
275
+ };
272
276
  outline?: boolean;
273
277
  cursor?: string | null;
274
278
  loader?: Writable<boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-svelte-ui-lib",
3
- "version": "1.5.9",
3
+ "version": "1.5.10",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -32,13 +32,13 @@
32
32
  "svelte": "^5.0.0"
33
33
  },
34
34
  "dependencies": {
35
- "@tailwindcss/vite": "^4.1.17",
35
+ "@tailwindcss/vite": "^4.1.18",
36
36
  "prettier": "^3.6.2",
37
37
  "prettier-plugin-svelte": "^3.4.0",
38
38
  "prettier-plugin-tailwindcss": "^0.7.2",
39
39
  "svelte-maplibre-gl": "^1.0.2",
40
40
  "tailwind-merge": "^3.4.0",
41
- "tailwindcss": "^4.1.17",
41
+ "tailwindcss": "^4.1.18",
42
42
  "tsx": "^4.21.0",
43
43
  "typescript": "^5.9.3"
44
44
  },
@@ -47,9 +47,9 @@
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": "^24.10.2",
50
+ "@types/node": "^25.0.1",
51
51
  "publint": "^0.3.16",
52
- "svelte": "^5.45.8",
52
+ "svelte": "^5.45.10",
53
53
  "svelte-preprocess": "^6.0.3",
54
54
  "vite": "^7.2.7",
55
55
  "vite-plugin-compression": "^0.5.1"