poe-svelte-ui-lib 1.9.0 → 1.9.2
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.
- package/dist/Table/Table.svelte +18 -9
- package/dist/Table/TableProps.svelte +315 -314
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/types.d.ts +19 -17
- package/package.json +1 -1
package/dist/Table/Table.svelte
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!-- $lib/ElementsUI/Table.svelte -->
|
|
2
2
|
<script lang="ts">
|
|
3
3
|
import { get } from "svelte/store"
|
|
4
|
-
import type { IOption, ITableHeader, ITableImage, ITableProgressBar, ITableProps, ITableText } from "../types"
|
|
4
|
+
import type { IOption, ITableContent, ITableHeader, ITableImage, ITableProgressBar, ITableProps, ITableText } from "../types"
|
|
5
5
|
import { fade, fly, slide } from "svelte/transition"
|
|
6
6
|
import { twMerge } from "tailwind-merge"
|
|
7
7
|
import { onMount, tick } from "svelte"
|
|
@@ -106,7 +106,13 @@
|
|
|
106
106
|
else if (button.eventHandler && onClick) {
|
|
107
107
|
let value: Record<string, boolean | string | number | number[] | object | null> = {}
|
|
108
108
|
button.eventHandler.Variables.forEach((v: string) => {
|
|
109
|
-
if (
|
|
109
|
+
if (
|
|
110
|
+
header.some(
|
|
111
|
+
(h) =>
|
|
112
|
+
(h.content as ITableContent<any>[])?.some((c) => c.type == "select") &&
|
|
113
|
+
(h.content as ITableContent<any>[]).some((c) => c.type == "select" && c.data.key === v),
|
|
114
|
+
)
|
|
115
|
+
)
|
|
110
116
|
value[v.slice(0, -2)] = row[v.slice(0, -2)]
|
|
111
117
|
else value[v] = row[v]
|
|
112
118
|
})
|
|
@@ -152,13 +158,13 @@
|
|
|
152
158
|
/* Для работы этой проверки в описании столбцов таблицы нужно явно указать что строка будет пустая при отсутствии иконки в БД -
|
|
153
159
|
src: (row) => (row.icon ? `data:image/png;base64,${row.icon}` : '') */
|
|
154
160
|
const hasImage = (column: ITableHeader<any>, row: any, index: number): boolean => {
|
|
155
|
-
let content = column.content?.[index]
|
|
161
|
+
let content = (column.content as ITableContent<any>[])?.[index]
|
|
156
162
|
const src = content?.type === "image" && typeof content.data.src === "function" ? content.data.src(row) : (content?.data as ITableImage<object>).src
|
|
157
163
|
return !!src
|
|
158
164
|
}
|
|
159
165
|
|
|
160
|
-
const progressPercent = (
|
|
161
|
-
let progressBar =
|
|
166
|
+
const progressPercent = (content: ITableContent<any>, value: number) => {
|
|
167
|
+
let progressBar = content.data as ITableProgressBar<object>
|
|
162
168
|
|
|
163
169
|
let min = progressBar?.minNum ?? 0
|
|
164
170
|
let max = progressBar?.maxNum ?? 100
|
|
@@ -261,13 +267,14 @@
|
|
|
261
267
|
)}
|
|
262
268
|
>
|
|
263
269
|
<span>{column.label?.name}</span>
|
|
264
|
-
|
|
270
|
+
|
|
271
|
+
{#if typeof column.content !== "function" && (column.content as ITableContent<any>[])?.some((c) => c.type === "text" && c.data.sortable)}
|
|
265
272
|
<button
|
|
266
273
|
class="inline-block cursor-pointer font-bold transition-transform duration-75 hover:scale-110 active:scale-95"
|
|
267
274
|
onclick={() =>
|
|
268
275
|
sortRows(
|
|
269
276
|
(
|
|
270
|
-
column.content?.find((c) => {
|
|
277
|
+
(column.content as ITableContent<any>[])?.find((c) => {
|
|
271
278
|
c.type === "text" && c.data.sortable
|
|
272
279
|
})?.data as ITableText<object>
|
|
273
280
|
).key as string,
|
|
@@ -305,6 +312,8 @@
|
|
|
305
312
|
>
|
|
306
313
|
{#each header as column, j (column)}
|
|
307
314
|
{#if column.width !== "0%"}
|
|
315
|
+
{@const contentArray = typeof column.content === "function" ? column.content(row) : column.content}
|
|
316
|
+
|
|
308
317
|
<div
|
|
309
318
|
id="rowDiv{i}-{j}"
|
|
310
319
|
class="relative flex w-full min-w-0 items-center gap-x-2 px-2 py-1 wrap-break-word
|
|
@@ -313,7 +322,7 @@
|
|
|
313
322
|
? 'select-none'
|
|
314
323
|
: 'select-all'}"
|
|
315
324
|
>
|
|
316
|
-
{#each
|
|
325
|
+
{#each contentArray as content, index}
|
|
317
326
|
{#if content.type === "button"}
|
|
318
327
|
{@const button = typeof content.data === "function" ? content.data(row) : content.data}
|
|
319
328
|
<div class="flex flex-wrap w-full gap-1">
|
|
@@ -407,7 +416,7 @@
|
|
|
407
416
|
<div class="relative my-auto h-3.5 rounded-full bg-(--back-color)/40">
|
|
408
417
|
<div
|
|
409
418
|
class="absolute top-0 left-0 flex h-full rounded-full bg-(--field-color)"
|
|
410
|
-
style="width: {progressPercent(
|
|
419
|
+
style="width: {progressPercent(content, row[progressBar.key] as number)}%;"
|
|
411
420
|
></div>
|
|
412
421
|
</div>
|
|
413
422
|
</div>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { getContext } from "svelte"
|
|
3
3
|
import { t } from "../locales/i18n"
|
|
4
|
-
import { type UIComponent, type ITableProps, type ITableHeader, updateProperty, type IUIComponentHandler } from "../types"
|
|
4
|
+
import { type UIComponent, type ITableProps, type ITableHeader, updateProperty, type IUIComponentHandler, type ITableContent } from "../types"
|
|
5
5
|
import * as UI from ".."
|
|
6
6
|
import ButtonDelete from "../libIcons/ButtonDelete.svelte"
|
|
7
7
|
import ButtonAdd from "../libIcons/ButtonAdd.svelte"
|
|
@@ -194,9 +194,7 @@
|
|
|
194
194
|
role="button"
|
|
195
195
|
tabindex="0"
|
|
196
196
|
onmouseenter={() => (isDropdownOpen = columnIndex)}
|
|
197
|
-
onmouseleave={() =>
|
|
198
|
-
isDropdownOpen = -1
|
|
199
|
-
}}
|
|
197
|
+
onmouseleave={() => (isDropdownOpen = -1)}
|
|
200
198
|
>
|
|
201
199
|
<button class="size-8 [&_svg]:h-full [&_svg]:max-h-full [&_svg]:w-full [&_svg]:max-w-full cursor-pointer">
|
|
202
200
|
<ButtonAdd />
|
|
@@ -232,348 +230,351 @@
|
|
|
232
230
|
/>
|
|
233
231
|
</div>
|
|
234
232
|
<div class="flex flex-col gap-2" bind:this={settingsContainer[columnIndex]}>
|
|
235
|
-
{#
|
|
236
|
-
{#
|
|
237
|
-
{
|
|
238
|
-
|
|
239
|
-
<div class="
|
|
240
|
-
<
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
233
|
+
{#if typeof column.content !== "function"}
|
|
234
|
+
{#each column.content as content, index}
|
|
235
|
+
{#if content.type == "text"}
|
|
236
|
+
{@const text = content.data}
|
|
237
|
+
<div id={`item-${index}-${columnIndex}`} class="relative bg-(--container-color)/50 rounded-2xl p-2">
|
|
238
|
+
<div class="flex gap-2 mx-auto items-end" style="width: {forConstructor ? '65%' : '90%'}; ">
|
|
239
|
+
<UI.Input
|
|
240
|
+
wrapperClass="w-1/4"
|
|
241
|
+
label={{ name: $t("constructor.props.table.text.key") }}
|
|
242
|
+
value={text.key}
|
|
243
|
+
help={{ regExp: /^[0-9a-zA-Z_.-]{0,16}$/ }}
|
|
244
|
+
onUpdate={(value) => {
|
|
245
|
+
updateTableHeader(
|
|
246
|
+
columnIndex,
|
|
247
|
+
"content",
|
|
248
|
+
column.content.map((textItem: any, i: number) => (i == index ? { ...textItem, data: { ...textItem.data, key: value } } : textItem)),
|
|
249
|
+
)
|
|
250
|
+
// updateTableBody()
|
|
251
|
+
}}
|
|
252
|
+
/>
|
|
253
|
+
<UI.Select
|
|
254
|
+
label={{ name: $t("constructor.props.tablecolumn.settings") }}
|
|
255
|
+
type="buttons"
|
|
256
|
+
multiSelect={true}
|
|
257
|
+
value={$optionsStore.TABLE_TEXT_SETTING_OPTIONS.slice(0, forConstructor ? 3 : 5).filter((opt) => {
|
|
258
|
+
if (column.content[index].data[opt.value]) return opt
|
|
259
|
+
})}
|
|
260
|
+
options={$optionsStore.TABLE_TEXT_SETTING_OPTIONS.slice(0, forConstructor ? 3 : 5)}
|
|
261
|
+
onUpdate={(value) => changeColumnSettings(value, columnIndex, index)}
|
|
262
|
+
/>
|
|
263
|
+
</div>
|
|
265
264
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}}
|
|
279
|
-
/>
|
|
280
|
-
|
|
281
|
-
<UI.Button
|
|
282
|
-
wrapperClass="absolute right-2 bottom-2 w-8"
|
|
283
|
-
content={{ icon: ButtonDelete }}
|
|
284
|
-
onClick={() => {
|
|
285
|
-
const headers = [...(component.properties.header || [])]
|
|
286
|
-
;(headers as ITableHeader<object>[])[columnIndex].content?.splice(index, 1)
|
|
287
|
-
updateProperty("header", headers, component, onPropertyChange)
|
|
288
|
-
}}
|
|
289
|
-
/>
|
|
290
|
-
</div>
|
|
291
|
-
{:else if content.type == "select"}
|
|
292
|
-
{@const select = content.data}
|
|
293
|
-
<div id={`item-${index}-${columnIndex}`} class="relative bg-(--container-color)/50 rounded-2xl p-2">
|
|
294
|
-
<div class="flex w-1/3 mx-auto gap-2">
|
|
295
|
-
<UI.Input
|
|
296
|
-
wrapperClass="w-1/2"
|
|
297
|
-
label={{ name: $t("constructor.props.table.select.key") }}
|
|
298
|
-
value={select.key}
|
|
299
|
-
help={{ regExp: /^[0-9a-zA-Z_.-]{0,16}$/ }}
|
|
300
|
-
onUpdate={(value) => {
|
|
301
|
-
updateTableHeader(
|
|
302
|
-
columnIndex,
|
|
303
|
-
"content",
|
|
304
|
-
column.content.map((textItem: any, i: number) => (i == index ? { ...textItem, data: { ...textItem.data, key: value } } : textItem)),
|
|
305
|
-
)
|
|
306
|
-
// updateTableBody()
|
|
265
|
+
<Dragging
|
|
266
|
+
wrapperClass="absolute left-2 bottom-2"
|
|
267
|
+
container={settingsContainer[columnIndex]}
|
|
268
|
+
array={column.content}
|
|
269
|
+
elementIndex={index}
|
|
270
|
+
containerIndex={columnIndex}
|
|
271
|
+
onUpdate={(updatedArray, index) => {
|
|
272
|
+
if (index === columnIndex) {
|
|
273
|
+
const headers = [...component.properties.header]
|
|
274
|
+
headers[columnIndex].content = updatedArray
|
|
275
|
+
updateProperty("header", headers, component, onPropertyChange)
|
|
276
|
+
}
|
|
307
277
|
}}
|
|
308
278
|
/>
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
const headers = [...component.properties.header]
|
|
317
|
-
headers[columnIndex].content[index].data = { ...headers[columnIndex].content[index].data, keyCol: value }
|
|
279
|
+
|
|
280
|
+
<UI.Button
|
|
281
|
+
wrapperClass="absolute right-2 bottom-2 w-8"
|
|
282
|
+
content={{ icon: ButtonDelete }}
|
|
283
|
+
onClick={() => {
|
|
284
|
+
const headers = [...(component.properties.header || [])]
|
|
285
|
+
;((headers as ITableHeader<object>[])[columnIndex].content as ITableContent<object>[]).splice(index, 1)
|
|
318
286
|
updateProperty("header", headers, component, onPropertyChange)
|
|
319
287
|
}}
|
|
320
288
|
/>
|
|
321
289
|
</div>
|
|
290
|
+
{:else if content.type == "select"}
|
|
291
|
+
{@const select = content.data}
|
|
292
|
+
<div id={`item-${index}-${columnIndex}`} class="relative bg-(--container-color)/50 rounded-2xl p-2">
|
|
293
|
+
<div class="flex w-1/3 mx-auto gap-2">
|
|
294
|
+
<UI.Input
|
|
295
|
+
wrapperClass="w-1/2"
|
|
296
|
+
label={{ name: $t("constructor.props.table.select.key") }}
|
|
297
|
+
value={select.key}
|
|
298
|
+
help={{ regExp: /^[0-9a-zA-Z_.-]{0,16}$/ }}
|
|
299
|
+
onUpdate={(value) => {
|
|
300
|
+
updateTableHeader(
|
|
301
|
+
columnIndex,
|
|
302
|
+
"content",
|
|
303
|
+
column.content.map((textItem: any, i: number) => (i == index ? { ...textItem, data: { ...textItem.data, key: value } } : textItem)),
|
|
304
|
+
)
|
|
305
|
+
// updateTableBody()
|
|
306
|
+
}}
|
|
307
|
+
/>
|
|
308
|
+
<UI.Input
|
|
309
|
+
wrapperClass="w-1/2"
|
|
310
|
+
label={{ name: $t("constructor.props.table.select.keys") }}
|
|
311
|
+
value={select?.keyCol ?? ""}
|
|
312
|
+
maxlength={500}
|
|
313
|
+
help={{ info: $t("constructor.props.table.select.keys.info"), regExp: /^[a-zA-Z0-9\-_ ]{0,500}$/ }}
|
|
314
|
+
onUpdate={(value) => {
|
|
315
|
+
const headers = [...component.properties.header]
|
|
316
|
+
headers[columnIndex].content[index].data = { ...headers[columnIndex].content[index].data, keyCol: value }
|
|
317
|
+
updateProperty("header", headers, component, onPropertyChange)
|
|
318
|
+
}}
|
|
319
|
+
/>
|
|
320
|
+
</div>
|
|
322
321
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
/>
|
|
337
|
-
|
|
338
|
-
<UI.Button
|
|
339
|
-
wrapperClass="absolute right-2 bottom-2 w-8"
|
|
340
|
-
content={{ icon: ButtonDelete }}
|
|
341
|
-
onClick={() => {
|
|
342
|
-
const headers = [...(component.properties.header || [])]
|
|
343
|
-
;(headers as ITableHeader<object>[])[columnIndex].content?.splice(index, 1)
|
|
344
|
-
updateProperty("header", headers, component, onPropertyChange)
|
|
345
|
-
}}
|
|
346
|
-
/>
|
|
347
|
-
</div>
|
|
348
|
-
{:else if content.type == "button"}
|
|
349
|
-
{@const button = content.data}
|
|
350
|
-
<div id={`item-${index}-${columnIndex}`} class="relative w-full bg-(--container-color)/50 rounded-2xl p-2">
|
|
351
|
-
<div class="flex w-[95%] mx-auto items-end justify-between gap-2">
|
|
352
|
-
<UI.Input
|
|
353
|
-
label={{ name: $t("constructor.props.name") }}
|
|
354
|
-
wrapperClass="w-2/10"
|
|
355
|
-
value={button.name}
|
|
356
|
-
onUpdate={(value) => updateContentProperty(columnIndex, index, "name", value)}
|
|
322
|
+
<Dragging
|
|
323
|
+
wrapperClass="absolute left-2 bottom-2"
|
|
324
|
+
container={settingsContainer[columnIndex]}
|
|
325
|
+
array={column.content}
|
|
326
|
+
elementIndex={index}
|
|
327
|
+
containerIndex={columnIndex}
|
|
328
|
+
onUpdate={(updatedArray, index) => {
|
|
329
|
+
if (index === columnIndex) {
|
|
330
|
+
const headers = [...component.properties.header]
|
|
331
|
+
headers[columnIndex].content = updatedArray
|
|
332
|
+
updateProperty("header", headers, component, onPropertyChange)
|
|
333
|
+
}
|
|
334
|
+
}}
|
|
357
335
|
/>
|
|
358
336
|
|
|
359
|
-
<UI.
|
|
360
|
-
wrapperClass="
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
(
|
|
366
|
-
)}
|
|
367
|
-
onUpdate={(value) => {
|
|
368
|
-
updateContentProperty(columnIndex, index, "class", (value as UI.IOption).value)
|
|
337
|
+
<UI.Button
|
|
338
|
+
wrapperClass="absolute right-2 bottom-2 w-8"
|
|
339
|
+
content={{ icon: ButtonDelete }}
|
|
340
|
+
onClick={() => {
|
|
341
|
+
const headers = [...(component.properties.header || [])]
|
|
342
|
+
;((headers as ITableHeader<object>[])[columnIndex].content as ITableContent<object>[]).splice(index, 1)
|
|
343
|
+
updateProperty("header", headers, component, onPropertyChange)
|
|
369
344
|
}}
|
|
370
345
|
/>
|
|
346
|
+
</div>
|
|
347
|
+
{:else if content.type == "button"}
|
|
348
|
+
{@const button = content.data}
|
|
349
|
+
<div id={`item-${index}-${columnIndex}`} class="relative w-full bg-(--container-color)/50 rounded-2xl p-2">
|
|
350
|
+
<div class="flex w-[95%] mx-auto items-end justify-between gap-2">
|
|
351
|
+
<UI.Input
|
|
352
|
+
label={{ name: $t("constructor.props.name") }}
|
|
353
|
+
wrapperClass="w-2/10"
|
|
354
|
+
value={button.name}
|
|
355
|
+
onUpdate={(value) => updateContentProperty(columnIndex, index, "name", value)}
|
|
356
|
+
/>
|
|
371
357
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
358
|
+
<UI.Select
|
|
359
|
+
wrapperClass="w-80 h-14.5"
|
|
360
|
+
label={{ name: $t("constructor.props.colors") }}
|
|
361
|
+
type="buttons"
|
|
362
|
+
options={$optionsStore.COLOR_OPTIONS.filter((option) => option.value !== "bg-max")}
|
|
363
|
+
value={$optionsStore.COLOR_OPTIONS.find((c) =>
|
|
364
|
+
(c.value as string).includes(
|
|
365
|
+
(button.class ?? component.properties.wrapperClass).split(" ").find((cls: string) => cls.startsWith("bg-")),
|
|
366
|
+
),
|
|
367
|
+
)}
|
|
368
|
+
onUpdate={(value) => {
|
|
369
|
+
updateContentProperty(columnIndex, index, "class", (value as UI.IOption).value)
|
|
370
|
+
}}
|
|
371
|
+
/>
|
|
372
|
+
|
|
373
|
+
<div class="relative mt-6 flex w-1/4 gap-2">
|
|
374
|
+
<CommonSnippets
|
|
375
|
+
snippet="IconsLib"
|
|
376
|
+
initialValue={{
|
|
377
|
+
name: $t("constructor.props.table.type.icon"),
|
|
378
|
+
icon: column.content[index].data.icon,
|
|
379
|
+
updateProperty: (icon: string) => updateContentProperty(columnIndex, index, "icon", icon),
|
|
380
|
+
icons: { array: ICONS },
|
|
381
|
+
}}
|
|
382
|
+
{component}
|
|
383
|
+
{onPropertyChange}
|
|
384
|
+
/>
|
|
385
|
+
</div>
|
|
386
|
+
|
|
387
|
+
<UI.Select
|
|
388
|
+
wrapperClass="w-1/4"
|
|
389
|
+
label={{ name: $t("constructor.props.header") }}
|
|
390
|
+
type="buttons"
|
|
391
|
+
value={$optionsStore.HEADER_OPTIONS.find((h) => h.value === button.eventHandler?.Header)}
|
|
392
|
+
options={$optionsStore.HEADER_OPTIONS}
|
|
393
|
+
onUpdate={(option) => {
|
|
394
|
+
const handler = button.eventHandler
|
|
395
|
+
handler.Header = (option as UI.IOption).value as string
|
|
396
|
+
updateContentProperty(columnIndex, index, "eventHandler", handler)
|
|
397
|
+
}}
|
|
398
|
+
/>
|
|
399
|
+
<UI.Input
|
|
400
|
+
wrapperClass="w-2/10"
|
|
401
|
+
label={{ name: $t("constructor.props.argument") }}
|
|
402
|
+
value={button.eventHandler?.Argument}
|
|
403
|
+
onUpdate={(value) => {
|
|
404
|
+
const handler = button.eventHandler
|
|
405
|
+
handler.Argument = value as string
|
|
406
|
+
updateContentProperty(columnIndex, index, "eventHandler", handler)
|
|
407
|
+
}}
|
|
408
|
+
/>
|
|
409
|
+
<UI.Input
|
|
410
|
+
wrapperClass="w-2/10"
|
|
411
|
+
label={{ name: $t("constructor.props.table.keys") }}
|
|
412
|
+
value={button.eventHandler?.Variables.join(" ")}
|
|
413
|
+
maxlength={500}
|
|
414
|
+
help={{ info: $t("constructor.props.table.keys.info"), regExp: /^[a-zA-Z0-9\-._ ]{0,500}$/ }}
|
|
415
|
+
onUpdate={(value) => {
|
|
416
|
+
const handler = { ...button.eventHandler }
|
|
417
|
+
handler.Variables = (value as string).trim().split(/\s+/)
|
|
418
|
+
updateContentProperty(columnIndex, index, "eventHandler", handler)
|
|
380
419
|
}}
|
|
381
|
-
{component}
|
|
382
|
-
{onPropertyChange}
|
|
383
420
|
/>
|
|
384
421
|
</div>
|
|
385
422
|
|
|
386
|
-
<UI.
|
|
387
|
-
wrapperClass="w-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
const handler = button.eventHandler
|
|
394
|
-
handler.Header = (option as UI.IOption).value as string
|
|
395
|
-
updateContentProperty(columnIndex, index, "eventHandler", handler)
|
|
396
|
-
}}
|
|
397
|
-
/>
|
|
398
|
-
<UI.Input
|
|
399
|
-
wrapperClass="w-2/10"
|
|
400
|
-
label={{ name: $t("constructor.props.argument") }}
|
|
401
|
-
value={button.eventHandler?.Argument}
|
|
402
|
-
onUpdate={(value) => {
|
|
403
|
-
const handler = button.eventHandler
|
|
404
|
-
handler.Argument = value as string
|
|
405
|
-
updateContentProperty(columnIndex, index, "eventHandler", handler)
|
|
423
|
+
<UI.Button
|
|
424
|
+
wrapperClass="absolute right-2 bottom-2 w-8"
|
|
425
|
+
content={{ icon: ButtonDelete }}
|
|
426
|
+
onClick={() => {
|
|
427
|
+
const headers = [...(component.properties.header || [])]
|
|
428
|
+
;((headers as ITableHeader<object>[])[columnIndex].content as ITableContent<object>[]).splice(index, 1)
|
|
429
|
+
updateProperty("header", headers, component, onPropertyChange)
|
|
406
430
|
}}
|
|
407
431
|
/>
|
|
408
|
-
<
|
|
409
|
-
wrapperClass="
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
onUpdate={(
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
432
|
+
<Dragging
|
|
433
|
+
wrapperClass="absolute left-2 bottom-2"
|
|
434
|
+
container={settingsContainer[columnIndex]}
|
|
435
|
+
array={column.content}
|
|
436
|
+
elementIndex={index}
|
|
437
|
+
containerIndex={columnIndex}
|
|
438
|
+
onUpdate={(updatedArray, index) => {
|
|
439
|
+
if (index === columnIndex) {
|
|
440
|
+
const headers = [...component.properties.header]
|
|
441
|
+
headers[columnIndex].content = updatedArray
|
|
442
|
+
updateProperty("header", headers, component, onPropertyChange)
|
|
443
|
+
}
|
|
418
444
|
}}
|
|
419
445
|
/>
|
|
420
446
|
</div>
|
|
447
|
+
{:else if content.type == "progressBar"}
|
|
448
|
+
{@const progressBar = content.data}
|
|
449
|
+
<div id={`item-${index}-${columnIndex}`} class="relative bg-(--container-color)/50 rounded-2xl p-2">
|
|
450
|
+
<div class="w-3/5 flex mx-auto items-end gap-2">
|
|
451
|
+
<UI.Input
|
|
452
|
+
label={{ name: $t("constructor.props.table.progressBar.key") }}
|
|
453
|
+
value={progressBar.key}
|
|
454
|
+
help={{ regExp: /^[0-9a-zA-Z_.-]{0,16}$/ }}
|
|
455
|
+
onUpdate={(value) => {
|
|
456
|
+
updateTableHeader(
|
|
457
|
+
columnIndex,
|
|
458
|
+
"content",
|
|
459
|
+
column.content.map((textItem: any, i: number) => (i == index ? { ...textItem, data: { ...textItem.data, key: value } } : textItem)),
|
|
460
|
+
)
|
|
461
|
+
// updateTableBody()
|
|
462
|
+
}}
|
|
463
|
+
/>
|
|
464
|
+
<UI.Input
|
|
465
|
+
wrapperClass="w-1/2"
|
|
466
|
+
label={{ name: $t("constructor.props.min") }}
|
|
467
|
+
value={(progressBar?.minNum as number) ?? 0}
|
|
468
|
+
type="number"
|
|
469
|
+
onUpdate={(value) => updateContentProperty(columnIndex, index, "minNum", value as string)}
|
|
470
|
+
/>
|
|
471
|
+
<UI.Input
|
|
472
|
+
wrapperClass="w-1/2"
|
|
473
|
+
label={{ name: $t("constructor.props.max") }}
|
|
474
|
+
value={(progressBar?.maxNum as number) ?? 100}
|
|
475
|
+
type="number"
|
|
476
|
+
onUpdate={(value) => updateContentProperty(columnIndex, index, "maxNum", value as string)}
|
|
477
|
+
/>
|
|
478
|
+
<UI.Input
|
|
479
|
+
label={{ name: $t("constructor.props.units") }}
|
|
480
|
+
value={progressBar?.units}
|
|
481
|
+
onUpdate={(value) => updateContentProperty(columnIndex, index, "units", value as string)}
|
|
482
|
+
/>
|
|
483
|
+
</div>
|
|
421
484
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
array={column.content}
|
|
435
|
-
elementIndex={index}
|
|
436
|
-
containerIndex={columnIndex}
|
|
437
|
-
onUpdate={(updatedArray, index) => {
|
|
438
|
-
if (index === columnIndex) {
|
|
439
|
-
const headers = [...component.properties.header]
|
|
440
|
-
headers[columnIndex].content = updatedArray
|
|
441
|
-
updateProperty("header", headers, component, onPropertyChange)
|
|
442
|
-
}
|
|
443
|
-
}}
|
|
444
|
-
/>
|
|
445
|
-
</div>
|
|
446
|
-
{:else if content.type == "progressBar"}
|
|
447
|
-
{@const progressBar = content.data}
|
|
448
|
-
<div id={`item-${index}-${columnIndex}`} class="relative bg-(--container-color)/50 rounded-2xl p-2">
|
|
449
|
-
<div class="w-3/5 flex mx-auto items-end gap-2">
|
|
450
|
-
<UI.Input
|
|
451
|
-
label={{ name: $t("constructor.props.table.progressBar.key") }}
|
|
452
|
-
value={progressBar.key}
|
|
453
|
-
help={{ regExp: /^[0-9a-zA-Z_.-]{0,16}$/ }}
|
|
454
|
-
onUpdate={(value) => {
|
|
455
|
-
updateTableHeader(
|
|
456
|
-
columnIndex,
|
|
457
|
-
"content",
|
|
458
|
-
column.content.map((textItem: any, i: number) => (i == index ? { ...textItem, data: { ...textItem.data, key: value } } : textItem)),
|
|
459
|
-
)
|
|
460
|
-
// updateTableBody()
|
|
485
|
+
<Dragging
|
|
486
|
+
wrapperClass="absolute left-2 bottom-2"
|
|
487
|
+
container={settingsContainer[columnIndex]}
|
|
488
|
+
array={column.content}
|
|
489
|
+
elementIndex={index}
|
|
490
|
+
containerIndex={columnIndex}
|
|
491
|
+
onUpdate={(updatedArray, index) => {
|
|
492
|
+
if (index === columnIndex) {
|
|
493
|
+
const headers = [...component.properties.header]
|
|
494
|
+
headers[columnIndex].content = updatedArray
|
|
495
|
+
updateProperty("header", headers, component, onPropertyChange)
|
|
496
|
+
}
|
|
461
497
|
}}
|
|
462
498
|
/>
|
|
463
|
-
<UI.
|
|
464
|
-
wrapperClass="w-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
/>
|
|
470
|
-
<UI.Input
|
|
471
|
-
wrapperClass="w-1/2"
|
|
472
|
-
label={{ name: $t("constructor.props.max") }}
|
|
473
|
-
value={(progressBar?.maxNum as number) ?? 100}
|
|
474
|
-
type="number"
|
|
475
|
-
onUpdate={(value) => updateContentProperty(columnIndex, index, "maxNum", value as string)}
|
|
476
|
-
/>
|
|
477
|
-
<UI.Input
|
|
478
|
-
label={{ name: $t("constructor.props.units") }}
|
|
479
|
-
value={progressBar?.units}
|
|
480
|
-
onUpdate={(value) => updateContentProperty(columnIndex, index, "units", value as string)}
|
|
481
|
-
/>
|
|
482
|
-
</div>
|
|
483
|
-
|
|
484
|
-
<Dragging
|
|
485
|
-
wrapperClass="absolute left-2 bottom-2"
|
|
486
|
-
container={settingsContainer[columnIndex]}
|
|
487
|
-
array={column.content}
|
|
488
|
-
elementIndex={index}
|
|
489
|
-
containerIndex={columnIndex}
|
|
490
|
-
onUpdate={(updatedArray, index) => {
|
|
491
|
-
if (index === columnIndex) {
|
|
492
|
-
const headers = [...component.properties.header]
|
|
493
|
-
headers[columnIndex].content = updatedArray
|
|
499
|
+
<UI.Button
|
|
500
|
+
wrapperClass="absolute right-2 bottom-2 w-8"
|
|
501
|
+
content={{ icon: ButtonDelete }}
|
|
502
|
+
onClick={() => {
|
|
503
|
+
const headers = [...(component.properties.header || [])]
|
|
504
|
+
;((headers as ITableHeader<object>[])[columnIndex].content as ITableContent<object>[]).splice(index, 1)
|
|
494
505
|
updateProperty("header", headers, component, onPropertyChange)
|
|
495
|
-
}
|
|
496
|
-
}}
|
|
497
|
-
/>
|
|
498
|
-
<UI.Button
|
|
499
|
-
wrapperClass="absolute right-2 bottom-2 w-8"
|
|
500
|
-
content={{ icon: ButtonDelete }}
|
|
501
|
-
onClick={() => {
|
|
502
|
-
const headers = [...(component.properties.header || [])]
|
|
503
|
-
;(headers as ITableHeader<object>[])[columnIndex].content?.splice(index, 1)
|
|
504
|
-
updateProperty("header", headers, component, onPropertyChange)
|
|
505
|
-
}}
|
|
506
|
-
/>
|
|
507
|
-
</div>
|
|
508
|
-
{:else if !forConstructor && content.type == "image"}
|
|
509
|
-
{@const image = content.data}
|
|
510
|
-
<div id={`item-${index}-${columnIndex}`} class="relative bg-(--container-color)/50 rounded-2xl p-2">
|
|
511
|
-
<div class="flex items-end gap-2 w-[80%] mx-auto">
|
|
512
|
-
<CommonSnippets
|
|
513
|
-
snippet="IconsLib"
|
|
514
|
-
initialValue={{
|
|
515
|
-
name: $t("constructor.props.table.columns.defaultIcon"),
|
|
516
|
-
icon: image?.defaultIcon ?? "",
|
|
517
|
-
updateProperty: (icon: string) => {
|
|
518
|
-
updateContentProperty(columnIndex, index, "defaultIcon", icon)
|
|
519
|
-
if (!image?.width || image?.width === "0rem") updateContentProperty(columnIndex, index, "width", "1rem")
|
|
520
|
-
if (!image?.width || image?.height === "0rem") updateContentProperty(columnIndex, index, "height", "1rem")
|
|
521
|
-
},
|
|
522
|
-
icons: { array: ICONS },
|
|
523
506
|
}}
|
|
524
|
-
{component}
|
|
525
|
-
{onPropertyChange}
|
|
526
507
|
/>
|
|
508
|
+
</div>
|
|
509
|
+
{:else if !forConstructor && content.type == "image"}
|
|
510
|
+
{@const image = content.data}
|
|
511
|
+
<div id={`item-${index}-${columnIndex}`} class="relative bg-(--container-color)/50 rounded-2xl p-2">
|
|
512
|
+
<div class="flex items-end gap-2 w-[80%] mx-auto">
|
|
513
|
+
<CommonSnippets
|
|
514
|
+
snippet="IconsLib"
|
|
515
|
+
initialValue={{
|
|
516
|
+
name: $t("constructor.props.table.columns.defaultIcon"),
|
|
517
|
+
icon: image?.defaultIcon ?? "",
|
|
518
|
+
updateProperty: (icon: string) => {
|
|
519
|
+
updateContentProperty(columnIndex, index, "defaultIcon", icon)
|
|
520
|
+
if (!image?.width || image?.width === "0rem") updateContentProperty(columnIndex, index, "width", "1rem")
|
|
521
|
+
if (!image?.width || image?.height === "0rem") updateContentProperty(columnIndex, index, "height", "1rem")
|
|
522
|
+
},
|
|
523
|
+
icons: { array: ICONS },
|
|
524
|
+
}}
|
|
525
|
+
{component}
|
|
526
|
+
{onPropertyChange}
|
|
527
|
+
/>
|
|
527
528
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
529
|
+
<UI.Input
|
|
530
|
+
label={{ name: $t("constructor.props.table.columns.class") }}
|
|
531
|
+
value={image?.class}
|
|
532
|
+
onUpdate={(value) => updateContentProperty(columnIndex, index, "class", value)}
|
|
533
|
+
/>
|
|
534
|
+
<UI.Input
|
|
535
|
+
wrapperClass="w-4/10"
|
|
536
|
+
label={{ name: $t("constructor.props.table.columns.image.width"), class: "px-0" }}
|
|
537
|
+
type="number"
|
|
538
|
+
number={{ minNum: 0, maxNum: 1000, step: 1 }}
|
|
539
|
+
value={Number(image?.width?.replace("rem", "") ?? 0)}
|
|
540
|
+
onUpdate={(value) => updateContentProperty(columnIndex, index, "width", `${value ?? 0}rem`)}
|
|
541
|
+
/>
|
|
542
|
+
<UI.Input
|
|
543
|
+
wrapperClass="w-4/10"
|
|
544
|
+
label={{ name: $t("constructor.props.table.columns.image.height"), class: "px-0" }}
|
|
545
|
+
type="number"
|
|
546
|
+
number={{ minNum: 0, maxNum: 1000, step: 1 }}
|
|
547
|
+
value={Number(image?.height?.replace("rem", "") ?? 0)}
|
|
548
|
+
onUpdate={(value) => updateContentProperty(columnIndex, index, "height", `${value ?? 0}rem`)}
|
|
549
|
+
/>
|
|
550
|
+
</div>
|
|
551
|
+
<Dragging
|
|
552
|
+
wrapperClass="absolute left-2 bottom-2"
|
|
553
|
+
container={settingsContainer[columnIndex]}
|
|
554
|
+
array={column.content}
|
|
555
|
+
elementIndex={index}
|
|
556
|
+
containerIndex={columnIndex}
|
|
557
|
+
onUpdate={(updatedArray, index) => {
|
|
558
|
+
if (index === columnIndex) {
|
|
559
|
+
const headers = [...component.properties.header]
|
|
560
|
+
headers[columnIndex].content = updatedArray
|
|
561
|
+
updateProperty("header", headers, component, onPropertyChange)
|
|
562
|
+
}
|
|
563
|
+
}}
|
|
540
564
|
/>
|
|
541
|
-
<UI.
|
|
542
|
-
wrapperClass="w-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
565
|
+
<UI.Button
|
|
566
|
+
wrapperClass="absolute right-2 bottom-2 w-8"
|
|
567
|
+
content={{ icon: ButtonDelete }}
|
|
568
|
+
onClick={() => {
|
|
569
|
+
const headers = [...(component.properties.header || [])]
|
|
570
|
+
;((headers as ITableHeader<object>[])[columnIndex].content as ITableContent<object>[]).splice(index, 1)
|
|
571
|
+
updateProperty("header", headers, component, onPropertyChange)
|
|
572
|
+
}}
|
|
548
573
|
/>
|
|
549
574
|
</div>
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
array={column.content}
|
|
554
|
-
elementIndex={index}
|
|
555
|
-
containerIndex={columnIndex}
|
|
556
|
-
onUpdate={(updatedArray, index) => {
|
|
557
|
-
if (index === columnIndex) {
|
|
558
|
-
const headers = [...component.properties.header]
|
|
559
|
-
headers[columnIndex].content = updatedArray
|
|
560
|
-
updateProperty("header", headers, component, onPropertyChange)
|
|
561
|
-
}
|
|
562
|
-
}}
|
|
563
|
-
/>
|
|
564
|
-
<UI.Button
|
|
565
|
-
wrapperClass="absolute right-2 bottom-2 w-8"
|
|
566
|
-
content={{ icon: ButtonDelete }}
|
|
567
|
-
onClick={() => {
|
|
568
|
-
const headers = [...(component.properties.header || [])]
|
|
569
|
-
;(headers as ITableHeader<object>[])[columnIndex].content?.splice(index, 1)
|
|
570
|
-
updateProperty("header", headers, component, onPropertyChange)
|
|
571
|
-
}}
|
|
572
|
-
/>
|
|
573
|
-
</div>
|
|
574
|
-
{/if}
|
|
575
|
-
{/each}
|
|
576
|
-
|
|
575
|
+
{/if}
|
|
576
|
+
{/each}
|
|
577
|
+
{/if}
|
|
577
578
|
<div id={`item-${column.content.length}-${columnIndex}`} class="min-h-2"></div>
|
|
578
579
|
</div>
|
|
579
580
|
</div>
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { default as ButtonProps } from "./Button/ButtonProps.svelte";
|
|
|
5
5
|
export { default as Carousel } from "./Carousel/Carousel.svelte";
|
|
6
6
|
export { default as ColorPicker } from "./ColorPicker/ColorPicker.svelte";
|
|
7
7
|
export { default as ColorPickerProps } from "./ColorPicker/ColorPickerProps.svelte";
|
|
8
|
+
export { default as Dragging } from "./Dragging.svelte";
|
|
8
9
|
export { default as FileAttach } from "./FileAttach/FileAttach.svelte";
|
|
9
10
|
export { default as FileAttachProps } from "./FileAttach/FileAttachProps.svelte";
|
|
10
11
|
export { default as Graph } from "./Graph/Graph.svelte";
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { default as ButtonProps } from "./Button/ButtonProps.svelte";
|
|
|
6
6
|
export { default as Carousel } from "./Carousel/Carousel.svelte";
|
|
7
7
|
export { default as ColorPicker } from "./ColorPicker/ColorPicker.svelte";
|
|
8
8
|
export { default as ColorPickerProps } from "./ColorPicker/ColorPickerProps.svelte";
|
|
9
|
+
export { default as Dragging } from "./Dragging.svelte";
|
|
9
10
|
export { default as FileAttach } from "./FileAttach/FileAttach.svelte";
|
|
10
11
|
export { default as FileAttachProps } from "./FileAttach/FileAttachProps.svelte";
|
|
11
12
|
export { default as Graph } from "./Graph/Graph.svelte";
|
package/dist/types.d.ts
CHANGED
|
@@ -308,7 +308,7 @@ export interface ITableSelect<T extends object> {
|
|
|
308
308
|
keyCol: string;
|
|
309
309
|
onChange?: () => void;
|
|
310
310
|
}
|
|
311
|
-
export interface
|
|
311
|
+
export interface ITableButton<T extends object> {
|
|
312
312
|
name?: string | ((row: T) => string);
|
|
313
313
|
icon?: ConstructorOfATypedSvelteComponent | string;
|
|
314
314
|
class?: string | ((row: T) => string);
|
|
@@ -322,6 +322,7 @@ export interface ITableProgressBar<T extends object> {
|
|
|
322
322
|
units?: string;
|
|
323
323
|
}
|
|
324
324
|
export interface ITableImage<T extends object> {
|
|
325
|
+
key: keyof T;
|
|
325
326
|
src?: string | ((row: T) => string);
|
|
326
327
|
alt?: string;
|
|
327
328
|
class?: string;
|
|
@@ -329,6 +330,22 @@ export interface ITableImage<T extends object> {
|
|
|
329
330
|
height?: string;
|
|
330
331
|
defaultIcon?: ConstructorOfATypedSvelteComponent | string;
|
|
331
332
|
}
|
|
333
|
+
export type ITableContent<T extends object> = {
|
|
334
|
+
type: "text";
|
|
335
|
+
data: ITableText<T>;
|
|
336
|
+
} | {
|
|
337
|
+
type: "select";
|
|
338
|
+
data: ITableSelect<T>;
|
|
339
|
+
} | {
|
|
340
|
+
type: "button";
|
|
341
|
+
data: ITableButton<T> | ((row: T) => ITableButton<T>);
|
|
342
|
+
} | {
|
|
343
|
+
type: "progressBar";
|
|
344
|
+
data: ITableProgressBar<T>;
|
|
345
|
+
} | {
|
|
346
|
+
type: "image";
|
|
347
|
+
data: ITableImage<T>;
|
|
348
|
+
};
|
|
332
349
|
export interface ITableHeader<T extends object> {
|
|
333
350
|
label?: {
|
|
334
351
|
name?: string;
|
|
@@ -337,22 +354,7 @@ export interface ITableHeader<T extends object> {
|
|
|
337
354
|
width?: string;
|
|
338
355
|
align?: "left" | "center" | "right";
|
|
339
356
|
disableSelect?: boolean;
|
|
340
|
-
content?: (
|
|
341
|
-
type: "text";
|
|
342
|
-
data: ITableText<T>;
|
|
343
|
-
} | {
|
|
344
|
-
type: "select";
|
|
345
|
-
data: ITableSelect<T>;
|
|
346
|
-
} | {
|
|
347
|
-
type: "button";
|
|
348
|
-
data: ITableButtons<T> | ((row: T) => ITableButtons<T>);
|
|
349
|
-
} | {
|
|
350
|
-
type: "progressBar";
|
|
351
|
-
data: ITableProgressBar<T>;
|
|
352
|
-
} | {
|
|
353
|
-
type: "image";
|
|
354
|
-
data: ITableImage<T>;
|
|
355
|
-
})[];
|
|
357
|
+
content?: ITableContent<T>[] | ((row: T) => ITableContent<T>[]);
|
|
356
358
|
}
|
|
357
359
|
export interface ITableProps<T extends object> {
|
|
358
360
|
id?: string;
|