poe-svelte-ui-lib 1.5.10 → 1.5.12

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.
@@ -14,7 +14,7 @@
14
14
  body = $bindable(),
15
15
  header = [],
16
16
  footer = '',
17
- dataBuffer = { stashData: false, rowsAmmount: 10, cleanButton: true, cleanClass: '' },
17
+ dataBuffer = { stashData: false, rowsAmmount: 10, clearButton: true, clearClass: '' },
18
18
  type = 'table',
19
19
  outline = false,
20
20
  cursor = null,
@@ -165,8 +165,8 @@
165
165
  },
166
166
  ]
167
167
 
168
- if (dataBuffer && buffer.length > (dataBuffer.rowsAmmount ?? 10) * 5) {
169
- buffer = buffer.slice(-((dataBuffer.rowsAmmount ?? 10) * 5))
168
+ if (dataBuffer && buffer.length > (dataBuffer.rowsAmmount ?? 10)) {
169
+ buffer = buffer.slice(-(dataBuffer.rowsAmmount ?? 10))
170
170
  }
171
171
 
172
172
  body = null
@@ -309,9 +309,9 @@
309
309
  </div>
310
310
  {/each}
311
311
  </div>
312
- {#if dataBuffer.cleanButton}
312
+ {#if dataBuffer.clearButton}
313
313
  <button
314
- class={twMerge('absolute right-2 bg-(--back-color) rounded-full p-1 cursor-pointer', dataBuffer.cleanClass)}
314
+ class={twMerge('absolute right-2 bg-(--back-color) rounded-full p-1 cursor-pointer', dataBuffer.clearClass)}
315
315
  onclick={() => (buffer = [])}
316
316
  >
317
317
  <ButtonClear />
@@ -100,6 +100,8 @@
100
100
  onUpdate={(option) => {
101
101
  updateProperty('type', option.value as string, component, onPropertyChange)
102
102
  if (option.value === 'logger') updateProperty('dataBuffer.stashData', true, component, onPropertyChange)
103
+ if (option.value === 'logger') updateProperty('dataBuffer.clearButton', true, component, onPropertyChange)
104
+ if (option.value === 'table') updateProperty('dataBuffer.clearButton', false, component, onPropertyChange)
103
105
  }}
104
106
  />
105
107
  </div>
@@ -150,160 +152,161 @@
150
152
  {/if}
151
153
  </div>
152
154
  </div>
155
+ {#if component.properties.type === 'table'}
156
+ <hr class="border-(--border-color)" />
153
157
 
154
- <hr class="border-(--border-color)" />
155
-
156
- <!-- Настройки столбцов таблицы -->
157
- <div>
158
- <div class=" flex items-center justify-center gap-2">
159
- <h4>{$t('constructor.props.table.columns')}</h4>
160
- <UI.Button
161
- wrapperClass="w-8"
162
- content={{ icon: ButtonAdd }}
163
- onClick={() => {
164
- const newColumn: ITableHeader<any> = {
165
- key: `column${(component.properties.header?.length || 0) + 1}`,
166
- label: { name: `Column ${(component.properties.header?.length || 0) + 1}`, class: '' },
167
- width: '10%',
168
- sortable: false,
169
- }
170
- const headers = [...(component.properties.header || []), newColumn]
171
- updateProperty('header', headers, component, onPropertyChange)
172
- headers.forEach((h) => {
173
- updateTableHeader(headers.indexOf(h), 'width', `${(100 / headers.length).toFixed(2)}%`)
174
- })
175
- updateTableBody()
176
- }}
177
- />
178
- </div>
179
-
180
- {#each component.properties.header as column, columnIndex (columnIndex)}
181
- <div class="mr-2 grid grid-cols-[minmax(5rem,10rem)_1fr_minmax(5rem,10rem)_minmax(10rem,21rem)_6rem_6rem_2rem_2rem] items-end gap-6">
182
- <UI.Input
183
- label={{ name: $t('constructor.props.table.columns.key') }}
184
- value={column.key}
185
- help={{ regExp: /^[0-9a-zA-Z_-]{0,16}$/ }}
186
- onUpdate={(value) => {
187
- updateTableHeader(columnIndex, 'key', value)
188
- updateTableBody()
189
- }}
190
- />
191
- <UI.Input
192
- label={{ name: $t('constructor.props.table.columns.label') }}
193
- value={column.label.name}
194
- onUpdate={(value) => {
195
- updateTableHeader(columnIndex, 'label', { ['name']: value })
196
- }}
197
- />
198
- <UI.Input
199
- label={{ name: $t('constructor.props.table.columns.width') }}
200
- type="number"
201
- value={Number(column.width.replace('%', ''))}
202
- onUpdate={(value) => updateTableHeader(columnIndex, 'width', `${value}%`)}
203
- />
204
- <UI.Select
205
- label={{ name: $t('constructor.props.align.content') }}
206
- type="buttons"
207
- value={$optionsStore.ALIGN_OPTIONS.find((a) => (a.value as string).includes(column.align))}
208
- options={$optionsStore.ALIGN_OPTIONS}
209
- onUpdate={(option) => updateTableHeader(columnIndex, 'align', option.value)}
210
- />
211
- <UI.Switch
212
- label={{ name: $t('constructor.props.table.columns.sortable'), class: 'px-0' }}
213
- options={[{ id: crypto.randomUUID(), value: 0, class: '' }]}
214
- value={column.sortable}
215
- onChange={(value) => updateTableHeader(columnIndex, 'sortable', value)}
216
- />
217
- <UI.Switch
218
- label={{ name: $t('constructor.props.copy'), class: 'px-0' }}
219
- options={[{ id: crypto.randomUUID(), value: 0, class: '' }]}
220
- value={column.overflow?.copy}
221
- onChange={(value) => updateTableHeader(columnIndex, 'overflow', { copy: value })}
222
- />
158
+ <!-- Настройки столбцов таблицы -->
159
+ <div>
160
+ <div class=" flex items-center justify-center gap-2">
161
+ <h4>{$t('constructor.props.table.columns')}</h4>
223
162
  <UI.Button
224
163
  wrapperClass="w-8"
225
- content={{ icon: ButtonAdd, info: { text: $t('constructor.props.table.addaction'), side: 'top' } }}
164
+ content={{ icon: ButtonAdd }}
226
165
  onClick={() => {
227
- const newButton = {
228
- name: `button${(component.properties.header[columnIndex].buttons ? component.properties.header[columnIndex].buttons.length : 0) + 1}`,
229
- class: 'bg-blue',
230
- eventHandler: { Header: 'SET', Argument: 'Save', Variables: [] },
231
- onClick: () => {},
166
+ const newColumn: ITableHeader<any> = {
167
+ key: `column${(component.properties.header?.length || 0) + 1}`,
168
+ label: { name: `Column ${(component.properties.header?.length || 0) + 1}`, class: '' },
169
+ width: '10%',
170
+ sortable: false,
232
171
  }
233
- const buttons = [...(component.properties.header[columnIndex].buttons || []), newButton]
234
- updateTableHeader(columnIndex, 'buttons', buttons)
235
- }}
236
- />
237
- <UI.Button
238
- wrapperClass="w-8"
239
- content={{ icon: ButtonDelete }}
240
- onClick={() => {
241
- const headers = [...(component.properties.header || [])]
242
- headers.splice(columnIndex, 1)
172
+ const headers = [...(component.properties.header || []), newColumn]
243
173
  updateProperty('header', headers, component, onPropertyChange)
244
174
  headers.forEach((h) => {
245
175
  updateTableHeader(headers.indexOf(h), 'width', `${(100 / headers.length).toFixed(2)}%`)
246
176
  })
177
+ updateTableBody()
247
178
  }}
248
179
  />
249
180
  </div>
250
- {#if column.buttons && column.buttons.length > 0}
251
- <div class="mb-5 rounded-lg py-1">
252
- {#each column.buttons as button, buttonIndex (buttonIndex)}
253
- <div class="ml-14 flex items-end justify-around gap-2">
254
- <UI.Input
255
- label={{ name: $t('constructor.props.name') }}
256
- wrapperClass="!w-3/10"
257
- value={button.name}
258
- onUpdate={(value) => updateButtonProperty(columnIndex, buttonIndex, 'name', value)}
259
- />
260
- <UI.Select
261
- wrapperClass="!w-2/10"
262
- label={{ name: $t('constructor.props.header') }}
263
- type="buttons"
264
- value={$optionsStore.HEADER_OPTIONS.find((h) => h.value === button.eventHandler?.Header)}
265
- options={$optionsStore.HEADER_OPTIONS}
266
- onUpdate={(option) => {
267
- const handler = button.eventHandler
268
- handler.Header = option.value as string
269
- updateButtonProperty(columnIndex, buttonIndex, 'eventHandler', handler)
270
- }}
271
- />
272
- <UI.Input
273
- wrapperClass="!w-2/10"
274
- label={{ name: $t('constructor.props.argument') }}
275
- value={button.eventHandler?.Argument}
276
- onUpdate={(value) => {
277
- const handler = button.eventHandler
278
- handler.Argument = value as string
279
- updateButtonProperty(columnIndex, buttonIndex, 'eventHandler', handler)
280
- }}
281
- />
282
- <UI.Input
283
- wrapperClass="!w-2/10"
284
- label={{ name: $t('constructor.props.table.keys') }}
285
- value={button.eventHandler?.Variables.join(' ')}
286
- maxlength={500}
287
- help={{ info: $t('constructor.props.table.keys.info'), regExp: /^[a-zA-Z0-9\-_ ]{0,500}$/ }}
288
- onUpdate={(value) => {
289
- const handler = { ...button.eventHandler }
290
- handler.Variables = (value as string).trim().split(/\s+/)
291
- updateButtonProperty(columnIndex, buttonIndex, 'eventHandler', handler)
292
- }}
293
- />
294
- <UI.Button
295
- wrapperClass="w-8"
296
- content={{ icon: ButtonDelete }}
297
- onClick={() => {
298
- removeButtonFromColumn(columnIndex, buttonIndex)
299
- }}
300
- />
301
- </div>
302
- {/each}
181
+
182
+ {#each component.properties.header as column, columnIndex (columnIndex)}
183
+ <div class="mr-2 grid grid-cols-[minmax(5rem,10rem)_1fr_minmax(5rem,10rem)_minmax(10rem,21rem)_6rem_6rem_2rem_2rem] items-end gap-6">
184
+ <UI.Input
185
+ label={{ name: $t('constructor.props.table.columns.key') }}
186
+ value={column.key}
187
+ help={{ regExp: /^[0-9a-zA-Z_-]{0,16}$/ }}
188
+ onUpdate={(value) => {
189
+ updateTableHeader(columnIndex, 'key', value)
190
+ updateTableBody()
191
+ }}
192
+ />
193
+ <UI.Input
194
+ label={{ name: $t('constructor.props.table.columns.label') }}
195
+ value={column.label.name}
196
+ onUpdate={(value) => {
197
+ updateTableHeader(columnIndex, 'label', { ['name']: value })
198
+ }}
199
+ />
200
+ <UI.Input
201
+ label={{ name: $t('constructor.props.table.columns.width') }}
202
+ type="number"
203
+ value={Number(column.width.replace('%', ''))}
204
+ onUpdate={(value) => updateTableHeader(columnIndex, 'width', `${value}%`)}
205
+ />
206
+ <UI.Select
207
+ label={{ name: $t('constructor.props.align.content') }}
208
+ type="buttons"
209
+ value={$optionsStore.ALIGN_OPTIONS.find((a) => (a.value as string).includes(column.align))}
210
+ options={$optionsStore.ALIGN_OPTIONS}
211
+ onUpdate={(option) => updateTableHeader(columnIndex, 'align', option.value)}
212
+ />
213
+ <UI.Switch
214
+ label={{ name: $t('constructor.props.table.columns.sortable'), class: 'px-0' }}
215
+ options={[{ id: crypto.randomUUID(), value: 0, class: '' }]}
216
+ value={column.sortable}
217
+ onChange={(value) => updateTableHeader(columnIndex, 'sortable', value)}
218
+ />
219
+ <UI.Switch
220
+ label={{ name: $t('constructor.props.copy'), class: 'px-0' }}
221
+ options={[{ id: crypto.randomUUID(), value: 0, class: '' }]}
222
+ value={column.overflow?.copy}
223
+ onChange={(value) => updateTableHeader(columnIndex, 'overflow', { copy: value })}
224
+ />
225
+ <UI.Button
226
+ wrapperClass="w-8"
227
+ content={{ icon: ButtonAdd, info: { text: $t('constructor.props.table.addaction'), side: 'top' } }}
228
+ onClick={() => {
229
+ const newButton = {
230
+ name: `button${(component.properties.header[columnIndex].buttons ? component.properties.header[columnIndex].buttons.length : 0) + 1}`,
231
+ class: 'bg-blue',
232
+ eventHandler: { Header: 'SET', Argument: 'Save', Variables: [] },
233
+ onClick: () => {},
234
+ }
235
+ const buttons = [...(component.properties.header[columnIndex].buttons || []), newButton]
236
+ updateTableHeader(columnIndex, 'buttons', buttons)
237
+ }}
238
+ />
239
+ <UI.Button
240
+ wrapperClass="w-8"
241
+ content={{ icon: ButtonDelete }}
242
+ onClick={() => {
243
+ const headers = [...(component.properties.header || [])]
244
+ headers.splice(columnIndex, 1)
245
+ updateProperty('header', headers, component, onPropertyChange)
246
+ headers.forEach((h) => {
247
+ updateTableHeader(headers.indexOf(h), 'width', `${(100 / headers.length).toFixed(2)}%`)
248
+ })
249
+ }}
250
+ />
303
251
  </div>
304
- {/if}
305
- {/each}
306
- </div>
252
+ {#if column.buttons && column.buttons.length > 0}
253
+ <div class="mb-5 rounded-lg py-1">
254
+ {#each column.buttons as button, buttonIndex (buttonIndex)}
255
+ <div class="ml-14 flex items-end justify-around gap-2">
256
+ <UI.Input
257
+ label={{ name: $t('constructor.props.name') }}
258
+ wrapperClass="!w-3/10"
259
+ value={button.name}
260
+ onUpdate={(value) => updateButtonProperty(columnIndex, buttonIndex, 'name', value)}
261
+ />
262
+ <UI.Select
263
+ wrapperClass="!w-2/10"
264
+ label={{ name: $t('constructor.props.header') }}
265
+ type="buttons"
266
+ value={$optionsStore.HEADER_OPTIONS.find((h) => h.value === button.eventHandler?.Header)}
267
+ options={$optionsStore.HEADER_OPTIONS}
268
+ onUpdate={(option) => {
269
+ const handler = button.eventHandler
270
+ handler.Header = option.value as string
271
+ updateButtonProperty(columnIndex, buttonIndex, 'eventHandler', handler)
272
+ }}
273
+ />
274
+ <UI.Input
275
+ wrapperClass="!w-2/10"
276
+ label={{ name: $t('constructor.props.argument') }}
277
+ value={button.eventHandler?.Argument}
278
+ onUpdate={(value) => {
279
+ const handler = button.eventHandler
280
+ handler.Argument = value as string
281
+ updateButtonProperty(columnIndex, buttonIndex, 'eventHandler', handler)
282
+ }}
283
+ />
284
+ <UI.Input
285
+ wrapperClass="!w-2/10"
286
+ label={{ name: $t('constructor.props.table.keys') }}
287
+ value={button.eventHandler?.Variables.join(' ')}
288
+ maxlength={500}
289
+ help={{ info: $t('constructor.props.table.keys.info'), regExp: /^[a-zA-Z0-9\-_ ]{0,500}$/ }}
290
+ onUpdate={(value) => {
291
+ const handler = { ...button.eventHandler }
292
+ handler.Variables = (value as string).trim().split(/\s+/)
293
+ updateButtonProperty(columnIndex, buttonIndex, 'eventHandler', handler)
294
+ }}
295
+ />
296
+ <UI.Button
297
+ wrapperClass="w-8"
298
+ content={{ icon: ButtonDelete }}
299
+ onClick={() => {
300
+ removeButtonFromColumn(columnIndex, buttonIndex)
301
+ }}
302
+ />
303
+ </div>
304
+ {/each}
305
+ </div>
306
+ {/if}
307
+ {/each}
308
+ </div>
309
+ {/if}
307
310
  {:else}
308
311
  <div class="relative flex flex-row items-start justify-center pb-4">
309
312
  <div class="flex w-1/3 flex-col px-2">
@@ -374,22 +377,37 @@
374
377
  onUpdate={(option) => {
375
378
  updateProperty('type', option.value as string, component, onPropertyChange)
376
379
  if (option.value === 'logger') updateProperty('dataBuffer.stashData', true, component, onPropertyChange)
380
+ if (option.value === 'table') updateProperty('dataBuffer.clearButton', false, component, onPropertyChange)
377
381
  }}
378
382
  />
379
- <UI.Switch
380
- label={{ name: $t('constructor.props.table.stashData') }}
381
- value={component.properties.dataBuffer.stashData}
382
- options={[{ id: crypto.randomUUID(), value: 0, class: '', disabled: component.properties.type === 'logger' }]}
383
- onChange={(value) => {
384
- updateProperty('dataBuffer.stashData', value, component, onPropertyChange)
385
- }}
386
- />
387
- {#if component.properties.stashData}
388
- <UI.Input
383
+ <div class="flex">
384
+ <UI.Switch
385
+ label={{ name: $t('constructor.props.table.stashData') }}
386
+ value={component.properties.dataBuffer.stashData}
387
+ options={[{ id: crypto.randomUUID(), value: 0, class: '', disabled: component.properties.type === 'logger' }]}
388
+ onChange={(value) => {
389
+ updateProperty('dataBuffer.stashData', value, component, onPropertyChange)
390
+ }}
391
+ />
392
+ {#if component.properties.type === 'logger'}
393
+ <UI.Switch
394
+ label={{ name: $t('constructor.props.table.clearButton') }}
395
+ value={component.properties.dataBuffer.clearButton}
396
+ options={[{ id: crypto.randomUUID(), value: 0, class: '' }]}
397
+ onChange={(value) => {
398
+ updateProperty('dataBuffer.clearButton', value, component, onPropertyChange)
399
+ }}
400
+ />
401
+ {/if}
402
+ </div>
403
+
404
+ {#if component.properties.dataBuffer.stashData}
405
+ <UI.Select
389
406
  label={{ name: $t('constructor.props.table.buffersize') }}
390
- type="number"
391
- value={component.properties.dataBuffer.rowsAmmount}
392
- onUpdate={(value) => updateProperty('dataBuffer.rowsAmmount', value as string, component, onPropertyChange)}
407
+ type="buttons"
408
+ options={$optionsStore.BUFFER_SIFE_OPTIONS}
409
+ value={$optionsStore.BUFFER_SIFE_OPTIONS.find((o) => o.value === component.properties.dataBuffer.rowsAmmount)}
410
+ onUpdate={(value) => updateProperty('dataBuffer.rowsAmmount', value.value as number, component, onPropertyChange)}
393
411
  />
394
412
  {/if}
395
413
  </div>
@@ -153,6 +153,7 @@ const translations = {
153
153
  'constructor.props.table.keys.info': 'Ключи таблицы, значения которых будут возвращаться',
154
154
  'constructor.props.table.stashData': 'Накопление данных',
155
155
  'constructor.props.table.buffersize': 'Размер буфера',
156
+ 'constructor.props.table.clearButton': 'Кнопка очистки',
156
157
  'constructor.props.icon.access': 'Доступ',
157
158
  'constructor.props.icon.common': 'Общее',
158
159
  'constructor.props.icon.scenarios': 'Сценарии',
package/dist/options.d.ts CHANGED
@@ -120,6 +120,11 @@ export declare const optionsStore: import("svelte/store").Readable<{
120
120
  value: string;
121
121
  name: string;
122
122
  }[];
123
+ BUFFER_SIFE_OPTIONS: {
124
+ id: `${string}-${string}-${string}-${string}-${string}`;
125
+ value: number;
126
+ name: string;
127
+ }[];
123
128
  AUTOCOMPLETE_CONSTRUCTOR_OPTIONS: {
124
129
  id: string;
125
130
  value: string;
package/dist/options.js CHANGED
@@ -128,6 +128,13 @@ export const optionsStore = derived(t, ($t) => {
128
128
  { id: id(), value: 'table', name: $t('constructor.props.table.type.table') },
129
129
  { id: id(), value: 'logger', name: $t('constructor.props.table.type.logger') },
130
130
  ],
131
+ BUFFER_SIFE_OPTIONS: [
132
+ { id: crypto.randomUUID(), value: 10, name: '10' },
133
+ { id: crypto.randomUUID(), value: 50, name: '50' },
134
+ { id: crypto.randomUUID(), value: 100, name: '100' },
135
+ { id: crypto.randomUUID(), value: 500, name: '500' },
136
+ { id: crypto.randomUUID(), value: 1000, name: '1000' },
137
+ ],
131
138
  AUTOCOMPLETE_CONSTRUCTOR_OPTIONS: [
132
139
  { id: id(), value: 'on', name: $t('constructor.props.autocomplete.on') },
133
140
  { id: id(), value: 'off', name: $t('constructor.props.autocomplete.off') },
package/dist/types.d.ts CHANGED
@@ -270,8 +270,8 @@ export interface ITableProps<T extends object> {
270
270
  dataBuffer?: {
271
271
  stashData?: boolean;
272
272
  rowsAmmount?: number;
273
- cleanButton?: boolean;
274
- cleanClass?: string;
273
+ clearButton?: boolean;
274
+ clearClass?: string;
275
275
  };
276
276
  outline?: boolean;
277
277
  cursor?: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-svelte-ui-lib",
3
- "version": "1.5.10",
3
+ "version": "1.5.12",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {