poe-svelte-ui-lib 0.1.0 → 0.3.0
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/Accordion/Accordion.svelte +53 -0
- package/dist/Accordion/Accordion.svelte.d.ts +14 -0
- package/dist/Accordion/AccordionProps.svelte +70 -0
- package/dist/Accordion/AccordionProps.svelte.d.ts +14 -0
- package/{src/lib → dist/Button}/Button.svelte +34 -45
- package/dist/Button/Button.svelte.d.ts +14 -0
- package/dist/Button/ButtonProps.svelte +200 -0
- package/dist/Button/ButtonProps.svelte.d.ts +14 -0
- package/dist/ColorPicker/ColorPicker.svelte +207 -0
- package/dist/ColorPicker/ColorPicker.svelte.d.ts +14 -0
- package/dist/ColorPicker/ColorPickerProps.svelte +100 -0
- package/dist/ColorPicker/ColorPickerProps.svelte.d.ts +14 -0
- package/dist/FileAttach/FileAttach.svelte +103 -0
- package/dist/FileAttach/FileAttach.svelte.d.ts +14 -0
- package/dist/Graph/Graph.svelte +270 -0
- package/dist/Graph/Graph.svelte.d.ts +14 -0
- package/dist/Graph/GraphProps.svelte +56 -0
- package/dist/Graph/GraphProps.svelte.d.ts +14 -0
- package/dist/Input/Input.svelte +239 -0
- package/dist/Input/Input.svelte.d.ts +14 -0
- package/dist/Input/InputProps.svelte +221 -0
- package/dist/Input/InputProps.svelte.d.ts +14 -0
- package/dist/Loader.svelte +12 -0
- package/dist/Loader.svelte.d.ts +14 -0
- package/dist/MessageModal.svelte +54 -0
- package/dist/MessageModal.svelte.d.ts +14 -0
- package/dist/ProgressBar/ProgressBar.svelte +48 -0
- package/dist/ProgressBar/ProgressBar.svelte.d.ts +14 -0
- package/dist/ProgressBar/ProgressBarProps.svelte +145 -0
- package/dist/ProgressBar/ProgressBarProps.svelte.d.ts +14 -0
- package/dist/Select/Select.svelte +187 -0
- package/dist/Select/Select.svelte.d.ts +14 -0
- package/dist/Select/SelectProps.svelte +260 -0
- package/dist/Select/SelectProps.svelte.d.ts +14 -0
- package/dist/Slider/Slider.svelte +260 -0
- package/dist/Slider/Slider.svelte.d.ts +14 -0
- package/dist/Slider/SliderProps.svelte +161 -0
- package/dist/Slider/SliderProps.svelte.d.ts +14 -0
- package/dist/Switch/Switch.svelte +83 -0
- package/dist/Switch/Switch.svelte.d.ts +14 -0
- package/dist/Switch/SwitchProps.svelte +144 -0
- package/dist/Switch/SwitchProps.svelte.d.ts +14 -0
- package/dist/Table/Table.svelte +276 -0
- package/dist/Table/Table.svelte.d.ts +14 -0
- package/dist/Table/TableProps.svelte +286 -0
- package/dist/Table/TableProps.svelte.d.ts +14 -0
- package/dist/TextField/TextField.svelte +22 -0
- package/dist/TextField/TextField.svelte.d.ts +14 -0
- package/dist/TextField/TextFieldProps.svelte +92 -0
- package/dist/TextField/TextFieldProps.svelte.d.ts +14 -0
- package/dist/appIcons/ButtonAdd.svelte +10 -0
- package/dist/appIcons/ButtonAdd.svelte.d.ts +14 -0
- package/dist/appIcons/ButtonDelete.svelte +13 -0
- package/dist/appIcons/ButtonDelete.svelte.d.ts +14 -0
- package/dist/appIcons/LoaderRotate.svelte +9 -0
- package/dist/appIcons/LoaderRotate.svelte.d.ts +14 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +26 -0
- package/dist/locales/CircleFlagsEn.svelte +14 -0
- package/dist/locales/CircleFlagsEn.svelte.d.ts +23 -0
- package/dist/locales/CircleFlagsRu.svelte +8 -0
- package/dist/locales/CircleFlagsRu.svelte.d.ts +23 -0
- package/dist/locales/CircleFlagsZh.svelte +8 -0
- package/dist/locales/CircleFlagsZh.svelte.d.ts +23 -0
- package/dist/locales/i18n.d.ts +10 -0
- package/dist/locales/i18n.js +36 -0
- package/dist/locales/translations.d.ts +7 -0
- package/dist/locales/translations.js +450 -0
- package/dist/options.d.ts +78 -0
- package/dist/options.js +71 -0
- package/dist/types.d.ts +284 -0
- package/dist/types.js +1 -0
- package/package.json +44 -34
- package/dist/svelte-ui-lib.es.js +0 -1451
- package/dist/svelte-ui-lib.umd.js +0 -9
- package/src/lib/index.ts +0 -2
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
<!-- $lib/ElementsUI/SwitchProps.svelte -->
|
|
2
|
+
<script lang="ts">
|
|
3
|
+
import { getContext } from 'svelte'
|
|
4
|
+
import { t } from '../locales/i18n'
|
|
5
|
+
import type { UIComponent, ISwitchProps } from '../types'
|
|
6
|
+
import * as UI from '../index'
|
|
7
|
+
import { optionsStore } from '../options'
|
|
8
|
+
|
|
9
|
+
const { component, onPropertyChange } = $props<{
|
|
10
|
+
component: UIComponent & { properties: Partial<ISwitchProps> }
|
|
11
|
+
onPropertyChange: (value: string | object) => void
|
|
12
|
+
}>()
|
|
13
|
+
|
|
14
|
+
const DeviceVariables = getContext<{ value: string; name: string }[]>('DeviceVariables')
|
|
15
|
+
let VARIABLE_OPTIONS = $derived(
|
|
16
|
+
DeviceVariables.map((variable: { value: string; name: string }) => ({
|
|
17
|
+
id: variable.name,
|
|
18
|
+
value: variable.value,
|
|
19
|
+
name: `${variable.value} | ${variable.name}`,
|
|
20
|
+
})),
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
const initialColor = $derived(
|
|
24
|
+
$optionsStore.COLOR_OPTIONS.find((c) =>
|
|
25
|
+
(c.value as string).includes(component.properties.wrapperClass?.split(' ').find((cls: string) => cls.startsWith('bg-'))),
|
|
26
|
+
),
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
const initialAlign = $derived(
|
|
30
|
+
$optionsStore.ALIGN_OPTIONS.find((a) =>
|
|
31
|
+
(a.value as string).includes(component.properties.label?.class?.split(' ').find((cls: string) => cls.startsWith('text-'))),
|
|
32
|
+
),
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
/* Добавление цветов через селект */
|
|
36
|
+
const handleOptionColorChange = (color: string) => {
|
|
37
|
+
let componentClass = component.properties.componentClass || ''
|
|
38
|
+
componentClass = componentClass
|
|
39
|
+
.split(' ')
|
|
40
|
+
.filter((cls: string) => !cls.startsWith('bg-'))
|
|
41
|
+
.join(' ')
|
|
42
|
+
if (color) {
|
|
43
|
+
componentClass += ` ${color}`
|
|
44
|
+
}
|
|
45
|
+
updateProperty('wrapperClass', componentClass)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const handleLabelAlign = (align: string) => {
|
|
49
|
+
let labelClass = component.properties.label.class || ''
|
|
50
|
+
labelClass = labelClass
|
|
51
|
+
.split(' ')
|
|
52
|
+
.filter((cls: string) => !cls.startsWith('text-'))
|
|
53
|
+
.join(' ')
|
|
54
|
+
if (align) {
|
|
55
|
+
labelClass += ` ${align}`
|
|
56
|
+
}
|
|
57
|
+
updateProperty('label.class', labelClass)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* Обновление свойства */
|
|
61
|
+
const updateProperty = (path: string, value: string | object | boolean | number) => {
|
|
62
|
+
const newProperties = JSON.parse(JSON.stringify(component.properties))
|
|
63
|
+
const parts = path.split('.')
|
|
64
|
+
let obj = newProperties
|
|
65
|
+
|
|
66
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
67
|
+
const part = parts[i]
|
|
68
|
+
if (!obj[part]) obj[part] = {}
|
|
69
|
+
obj = obj[part]
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
obj[parts[parts.length - 1]] = value
|
|
73
|
+
onPropertyChange(newProperties)
|
|
74
|
+
}
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
{#if component && component.properties}
|
|
78
|
+
<div class="relative flex flex-row items-start justify-center">
|
|
79
|
+
<!-- Сообщение для отправки в ws по нажатию кнопки -->
|
|
80
|
+
<div class="flex w-1/3 flex-col items-center px-2">
|
|
81
|
+
<UI.Select
|
|
82
|
+
label={{ name: $t('service.constructor.props.variable') }}
|
|
83
|
+
options={VARIABLE_OPTIONS}
|
|
84
|
+
value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id.value)}
|
|
85
|
+
onUpdate={(value) => {
|
|
86
|
+
updateProperty('id.name', (value.name as string).split('|')[1].trim())
|
|
87
|
+
updateProperty('id.value', value.value as string)
|
|
88
|
+
updateProperty('eventHandler.Variables', value.value as string)
|
|
89
|
+
}}
|
|
90
|
+
/>
|
|
91
|
+
<UI.Select
|
|
92
|
+
label={{ name: $t('service.constructor.props.action') }}
|
|
93
|
+
type="buttons"
|
|
94
|
+
value={$optionsStore.SHORT_ARGUMENT_OPTION.find((h) => h.value === component.properties.eventHandler.Argument)}
|
|
95
|
+
options={$optionsStore.SHORT_ARGUMENT_OPTION}
|
|
96
|
+
onUpdate={(option) => {
|
|
97
|
+
updateProperty('eventHandler.Argument', option.value as string)
|
|
98
|
+
}}
|
|
99
|
+
/>
|
|
100
|
+
</div>
|
|
101
|
+
<div class="flex w-1/3 flex-col px-2">
|
|
102
|
+
<UI.Input
|
|
103
|
+
label={{ name: $t('service.constructor.props.caption.left') }}
|
|
104
|
+
value={component.properties.label.captionLeft}
|
|
105
|
+
type="text"
|
|
106
|
+
onUpdate={(value) => updateProperty('label.captionLeft', value as string)}
|
|
107
|
+
/>
|
|
108
|
+
<UI.Input
|
|
109
|
+
label={{ name: $t('service.constructor.props.caption.right') }}
|
|
110
|
+
value={component.properties.label.captionRight}
|
|
111
|
+
type="text"
|
|
112
|
+
onUpdate={(value) => updateProperty('label.captionRight', value as string)}
|
|
113
|
+
/>
|
|
114
|
+
<UI.Switch
|
|
115
|
+
label={{ name: $t('service.constructor.props.disabled') }}
|
|
116
|
+
value={component.properties.disabled ? 2 : 1}
|
|
117
|
+
onChange={(value) => updateProperty('disabled', value === 2)}
|
|
118
|
+
/>
|
|
119
|
+
</div>
|
|
120
|
+
<div class="flex w-1/3 flex-col px-2">
|
|
121
|
+
<UI.Input
|
|
122
|
+
label={{ name: $t('service.constructor.props.label') }}
|
|
123
|
+
value={component.properties.label.name}
|
|
124
|
+
type="text"
|
|
125
|
+
onUpdate={(value) => updateProperty('label.name', value as string)}
|
|
126
|
+
/>
|
|
127
|
+
<UI.Select
|
|
128
|
+
label={{ name: $t('service.constructor.props.align') }}
|
|
129
|
+
type="buttons"
|
|
130
|
+
value={initialAlign}
|
|
131
|
+
options={$optionsStore.ALIGN_OPTIONS}
|
|
132
|
+
onUpdate={(option) => handleLabelAlign(option.value as string)}
|
|
133
|
+
/>
|
|
134
|
+
<UI.Select
|
|
135
|
+
wrapperClass="!h-14"
|
|
136
|
+
label={{ name: $t('service.constructor.props.colors') }}
|
|
137
|
+
type="buttons"
|
|
138
|
+
options={$optionsStore.COLOR_OPTIONS}
|
|
139
|
+
value={initialColor}
|
|
140
|
+
onUpdate={(option) => handleOptionColorChange(option.value as string)}
|
|
141
|
+
/>
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
{/if}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: Record<string, never>;
|
|
4
|
+
events: {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
};
|
|
7
|
+
slots: {};
|
|
8
|
+
};
|
|
9
|
+
export type SwitchPropsProps = typeof __propDef.props;
|
|
10
|
+
export type SwitchPropsEvents = typeof __propDef.events;
|
|
11
|
+
export type SwitchPropsSlots = typeof __propDef.slots;
|
|
12
|
+
export default class SwitchProps extends SvelteComponentTyped<SwitchPropsProps, SwitchPropsEvents, SwitchPropsSlots> {
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
<!-- $lib/ElementsUI/Table.svelte -->
|
|
2
|
+
<script lang="ts">
|
|
3
|
+
import { t } from '../locales/i18n'
|
|
4
|
+
import { get } from 'svelte/store'
|
|
5
|
+
import type { ITableHeader, ITableProps } from '../types'
|
|
6
|
+
import { fly } from 'svelte/transition'
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
id = { value: crypto.randomUUID(), name: '' },
|
|
10
|
+
wrapperClass = 'bg-blue',
|
|
11
|
+
label = { name: '', class: '' },
|
|
12
|
+
tableBody = [],
|
|
13
|
+
tableHeader = [],
|
|
14
|
+
cursor = null,
|
|
15
|
+
loader,
|
|
16
|
+
getData = () => {},
|
|
17
|
+
showInfo = true,
|
|
18
|
+
modalData = $bindable({ isOpen: false, rawData: '', formattedData: '' }),
|
|
19
|
+
onClick,
|
|
20
|
+
}: ITableProps<any> = $props()
|
|
21
|
+
|
|
22
|
+
/* Сортировка */
|
|
23
|
+
let sortState: {
|
|
24
|
+
key: string | null
|
|
25
|
+
direction: 'asc' | 'desc' | null
|
|
26
|
+
} = {
|
|
27
|
+
key: null,
|
|
28
|
+
direction: null,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* Сортировка столбцов */
|
|
32
|
+
const sortRows = (key: string) => {
|
|
33
|
+
if (sortState.key === key) {
|
|
34
|
+
sortState.direction = sortState.direction === 'asc' ? 'desc' : 'asc'
|
|
35
|
+
} else {
|
|
36
|
+
sortState.key = key
|
|
37
|
+
sortState.direction = 'asc'
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
tableBody = [...tableBody].sort((a, b) => {
|
|
41
|
+
const aValue = a[key]
|
|
42
|
+
const bValue = b[key]
|
|
43
|
+
if (typeof aValue === 'number' && typeof bValue === 'number') {
|
|
44
|
+
return sortState.direction === 'asc' ? aValue - bValue : bValue - aValue
|
|
45
|
+
}
|
|
46
|
+
if (aValue instanceof Date && bValue instanceof Date) {
|
|
47
|
+
return sortState.direction === 'asc' ? aValue.getTime() - bValue.getTime() : bValue.getTime() - aValue.getTime()
|
|
48
|
+
}
|
|
49
|
+
const strA = String(aValue).toLowerCase()
|
|
50
|
+
const strB = String(bValue).toLowerCase()
|
|
51
|
+
const numA = strA.match(/\d+/g)?.[0] || ''
|
|
52
|
+
const numB = strB.match(/\d+/g)?.[0] || ''
|
|
53
|
+
if (numA && numB) {
|
|
54
|
+
const numCompare = parseInt(numA, 10) - parseInt(numB, 10)
|
|
55
|
+
if (numCompare !== 0) {
|
|
56
|
+
return sortState.direction === 'asc' ? numCompare : -numCompare
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const stringCompare = strA.localeCompare(strB)
|
|
60
|
+
return sortState.direction === 'asc' ? stringCompare : -stringCompare
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* Запрос данных, если в конце списка */
|
|
65
|
+
let container: HTMLElement | null = $state(null)
|
|
66
|
+
function handleScroll() {
|
|
67
|
+
if (!container) return
|
|
68
|
+
const { scrollTop, clientHeight, scrollHeight } = container
|
|
69
|
+
if (scrollTop + clientHeight >= scrollHeight - 50 && cursor !== null && loader && !get(loader)) {
|
|
70
|
+
getData()
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function buttonClick(row: any, button: any) {
|
|
75
|
+
if (button.onClick) button.onClick(row)
|
|
76
|
+
else if (button.eventHandler && onClick) {
|
|
77
|
+
let value: Record<string, boolean | string | number | number[] | object | null> = {}
|
|
78
|
+
button.eventHandler.Variables.forEach((v: string) => {
|
|
79
|
+
value[v] = row[v]
|
|
80
|
+
})
|
|
81
|
+
button.eventHandler.Value = JSON.stringify(value)
|
|
82
|
+
onClick(button.eventHandler)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
let copiedCell = $state({ x: '', y: -1 })
|
|
87
|
+
let tooltip = $state({
|
|
88
|
+
show: false,
|
|
89
|
+
text: '',
|
|
90
|
+
x: 0,
|
|
91
|
+
y: 0,
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
const showModal = async (text: string, formatting?: (text: string) => string) => {
|
|
95
|
+
modalData = {
|
|
96
|
+
isOpen: !modalData.isOpen,
|
|
97
|
+
rawData: text,
|
|
98
|
+
formattedData: formatting ? formatting(text) : (text ?? ''),
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const showTooltip = (event: MouseEvent, text: string, formatting?: (text: string) => string) => {
|
|
103
|
+
tooltip = {
|
|
104
|
+
show: true,
|
|
105
|
+
text: formatting ? formatting(text) : (text ?? ''),
|
|
106
|
+
x: event.clientX,
|
|
107
|
+
y: event.clientY,
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const hideTooltip = () => {
|
|
112
|
+
tooltip.show = false
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/* Для работы этой проверки в описании столбцов таблицы нужно явно указать что строка будет пустая при отсутствии иконки в БД -
|
|
116
|
+
src: (row) => (row.icon ? `data:image/png;base64,${row.icon}` : '') */
|
|
117
|
+
const hasImage = (column: ITableHeader<any>, row: any): boolean => {
|
|
118
|
+
const src = typeof column.image?.src === 'function' ? column.image.src(row) : column.image?.src
|
|
119
|
+
return !!src
|
|
120
|
+
}
|
|
121
|
+
</script>
|
|
122
|
+
|
|
123
|
+
<div id={id.value} class={`flex h-full w-full flex-col overflow-hidden ${wrapperClass}`}>
|
|
124
|
+
{#if label.name}
|
|
125
|
+
<h5 class={`w-full px-4 text-center ${label.class}`}>{label.name}</h5>
|
|
126
|
+
{/if}
|
|
127
|
+
|
|
128
|
+
<div class="flex h-full flex-col overflow-hidden rounded-xl border-[var(--border-color)]">
|
|
129
|
+
<!-- Table Header -->
|
|
130
|
+
<div class="grid font-semibold" style={`grid-template-columns: ${tableHeader.map((c) => c.width || 'minmax(0, 1fr)').join(' ')};`}>
|
|
131
|
+
{#each tableHeader as column (column)}
|
|
132
|
+
<div class="justify-center bg-[var(--bg-color)] p-2 text-center">
|
|
133
|
+
<div class="flex items-center justify-start gap-2">
|
|
134
|
+
<span>{column.label}</span>
|
|
135
|
+
{#if column.sortable}
|
|
136
|
+
<button
|
|
137
|
+
class="cursor-pointer font-bold transition-transform duration-75 hover:scale-110 active:scale-95"
|
|
138
|
+
onclick={() => sortRows(column.key as string)}
|
|
139
|
+
>
|
|
140
|
+
↑↓
|
|
141
|
+
</button>
|
|
142
|
+
{/if}
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
{/each}
|
|
146
|
+
</div>
|
|
147
|
+
|
|
148
|
+
<!-- Table Body с прокруткой -->
|
|
149
|
+
<div class="flex-1 overflow-y-auto bg-[var(--conteiner-color)]/50" bind:this={container} onscroll={handleScroll}>
|
|
150
|
+
<div class="grid min-w-0" style={`grid-template-columns: ${tableHeader.map((c) => c.width || 'minmax(0, 1fr)').join(' ')};`}>
|
|
151
|
+
{#each tableBody as row, index (row)}
|
|
152
|
+
{#each tableHeader as column (column)}
|
|
153
|
+
<div
|
|
154
|
+
class="relative flex w-full min-w-0 items-center px-2 py-1 break-words
|
|
155
|
+
{index % 2 ? '!bg-[var(--field-color)]' : ''}
|
|
156
|
+
{column.cellClass}
|
|
157
|
+
{column.align === 'center'
|
|
158
|
+
? 'flex justify-center text-center'
|
|
159
|
+
: column.align === 'right'
|
|
160
|
+
? 'flex justify-end text-right'
|
|
161
|
+
: 'flex justify-start text-left'}"
|
|
162
|
+
>
|
|
163
|
+
{#if column.buttons}
|
|
164
|
+
<div class="flex w-full flex-col gap-1">
|
|
165
|
+
{#each column.buttons as button (button)}
|
|
166
|
+
<button
|
|
167
|
+
class="
|
|
168
|
+
cursor-pointer rounded-full !bg-[var(--bg-color)] px-4 py-1 font-medium
|
|
169
|
+
transition-shadow outline-none select-none hover:shadow-md
|
|
170
|
+
{typeof button.class === 'function' ? button.class(row) : button.class}
|
|
171
|
+
"
|
|
172
|
+
onclick={() => buttonClick(row, button)}
|
|
173
|
+
>
|
|
174
|
+
{typeof button.name === 'function' ? button.name(row) : button.name}
|
|
175
|
+
</button>
|
|
176
|
+
{/each}
|
|
177
|
+
</div>
|
|
178
|
+
{:else if column.image}
|
|
179
|
+
<div class="flex items-center justify-center" style={`width: ${column.image.width || '5rem'}; height: ${column.image.height || '5rem'};`}>
|
|
180
|
+
{#if hasImage(column, row)}
|
|
181
|
+
<img
|
|
182
|
+
src={typeof column.image?.src === 'function' ? column.image.src(row) : column.image?.src || ''}
|
|
183
|
+
alt={column.image.alt ?? 'Image'}
|
|
184
|
+
class="h-full w-full object-cover {column.image.class || ''}"
|
|
185
|
+
loading="lazy"
|
|
186
|
+
/>
|
|
187
|
+
{:else if column.image.defaultIcon}
|
|
188
|
+
<column.image.defaultIcon />
|
|
189
|
+
{/if}
|
|
190
|
+
</div>
|
|
191
|
+
{:else}
|
|
192
|
+
<div
|
|
193
|
+
class="w-full max-w-full break-words {column.overflow?.truncated ? 'overflow-hidden text-ellipsis whitespace-nowrap' : 'whitespace-normal'}"
|
|
194
|
+
onmouseenter={column.overflow?.truncated ? (e) => showTooltip(e, row[column.key], column.overflow?.formatting) : undefined}
|
|
195
|
+
onmouseleave={column.overflow?.truncated ? hideTooltip : undefined}
|
|
196
|
+
onmousemove={column.overflow?.truncated
|
|
197
|
+
? (e) => {
|
|
198
|
+
tooltip.x = e.clientX
|
|
199
|
+
tooltip.y = e.clientY
|
|
200
|
+
}
|
|
201
|
+
: undefined}
|
|
202
|
+
role="columnheader"
|
|
203
|
+
tabindex={null}
|
|
204
|
+
>
|
|
205
|
+
{#if column.overflow?.modal}
|
|
206
|
+
<button
|
|
207
|
+
class="w-full cursor-pointer overflow-hidden text-left text-ellipsis whitespace-nowrap"
|
|
208
|
+
onclick={(e) => {
|
|
209
|
+
e.stopPropagation()
|
|
210
|
+
showModal(row[column.key], column.overflow?.formatting)
|
|
211
|
+
}}
|
|
212
|
+
>
|
|
213
|
+
{@html row[column.key]}
|
|
214
|
+
</button>
|
|
215
|
+
{:else}
|
|
216
|
+
{@html row[column.key]}
|
|
217
|
+
{/if}
|
|
218
|
+
</div>
|
|
219
|
+
|
|
220
|
+
{#if column.overflow?.copy}
|
|
221
|
+
<button
|
|
222
|
+
class="right-2 flex cursor-pointer border-none bg-transparent"
|
|
223
|
+
onclick={(e) => {
|
|
224
|
+
e.preventDefault()
|
|
225
|
+
navigator.clipboard.writeText(row[column.key])
|
|
226
|
+
copiedCell = { x: column.key as string, y: index }
|
|
227
|
+
setTimeout(() => (copiedCell = { x: '', y: -1 }), 1000)
|
|
228
|
+
}}
|
|
229
|
+
aria-label="Копировать текст"
|
|
230
|
+
>
|
|
231
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="1.3em" height="1.3em" viewBox="0 0 24 24">
|
|
232
|
+
<g fill="none" stroke="currentColor" stroke-width="1.5">
|
|
233
|
+
<path
|
|
234
|
+
d="M6 11c0-2.828 0-4.243.879-5.121C7.757 5 9.172 5 12 5h3c2.828 0 4.243 0 5.121.879C21 6.757 21 8.172 21 11v5c0 2.828 0 4.243-.879 5.121C19.243 22 17.828 22 15 22h-3c-2.828 0-4.243 0-5.121-.879C6 20.243 6 18.828 6 16z"
|
|
235
|
+
/>
|
|
236
|
+
<path d="M6 19a3 3 0 0 1-3-3v-6c0-3.771 0-5.657 1.172-6.828S7.229 2 11 2h4a3 3 0 0 1 3 3" />
|
|
237
|
+
</g>
|
|
238
|
+
</svg>
|
|
239
|
+
</button>
|
|
240
|
+
|
|
241
|
+
{#if copiedCell.y === index && copiedCell.x === column.key}
|
|
242
|
+
<div
|
|
243
|
+
class="absolute top-1/2 right-10 -translate-y-1/2 transform rounded-md bg-[var(--green-color)] px-2 py-1 text-sm shadow-lg"
|
|
244
|
+
transition:fly={{ x: 10, duration: 200 }}
|
|
245
|
+
>
|
|
246
|
+
{$t('component.input.copy')}
|
|
247
|
+
</div>
|
|
248
|
+
{/if}
|
|
249
|
+
{/if}
|
|
250
|
+
{/if}
|
|
251
|
+
</div>
|
|
252
|
+
{/each}
|
|
253
|
+
{/each}
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
|
|
257
|
+
{#if tooltip.show}
|
|
258
|
+
<div
|
|
259
|
+
class="fixed z-50 max-w-xs rounded-md px-2 py-1 text-sm whitespace-pre-wrap shadow-lg"
|
|
260
|
+
style="background: color-mix(in srgb, var(--yellow-color) 30%, var(--back-color)); transform: translateX(-50%); left: {tooltip.x +
|
|
261
|
+
10}px; top: {tooltip.y + 10}px;"
|
|
262
|
+
transition:fly={{ y: 10, duration: 200 }}
|
|
263
|
+
role="tooltip"
|
|
264
|
+
>
|
|
265
|
+
{@html tooltip.text}
|
|
266
|
+
</div>
|
|
267
|
+
{/if}
|
|
268
|
+
|
|
269
|
+
<!-- Нижнее поле для сводной информации -->
|
|
270
|
+
{#if showInfo}
|
|
271
|
+
<div class="flex h-8 items-center justify-center bg-[var(--bg-color)]">
|
|
272
|
+
<h5>{$t('catalog.nums')} {tableBody.length}</h5>
|
|
273
|
+
</div>
|
|
274
|
+
{/if}
|
|
275
|
+
</div>
|
|
276
|
+
</div>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: Record<string, never>;
|
|
4
|
+
events: {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
};
|
|
7
|
+
slots: {};
|
|
8
|
+
};
|
|
9
|
+
export type TableProps = typeof __propDef.props;
|
|
10
|
+
export type TableEvents = typeof __propDef.events;
|
|
11
|
+
export type TableSlots = typeof __propDef.slots;
|
|
12
|
+
export default class Table extends SvelteComponentTyped<TableProps, TableEvents, TableSlots> {
|
|
13
|
+
}
|
|
14
|
+
export {};
|