poe-svelte-ui-lib 1.0.5 → 1.0.7
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 +56 -34
- package/dist/Accordion/AccordionProps.svelte +76 -0
- package/dist/Accordion/AccordionProps.svelte.d.ts +10 -0
- package/dist/Button/Button.svelte +28 -34
- package/dist/Button/ButtonProps.svelte +113 -0
- package/dist/Button/ButtonProps.svelte.d.ts +10 -0
- package/dist/ColorPicker/ColorPicker.svelte +27 -14
- package/dist/ColorPicker/ColorPickerProps.svelte +71 -0
- package/dist/ColorPicker/ColorPickerProps.svelte.d.ts +10 -0
- package/dist/{FileAttach/FileAttach.svelte → FileAttach.svelte} +3 -11
- package/dist/{FileAttach/FileAttach.svelte.d.ts → FileAttach.svelte.d.ts} +1 -1
- package/dist/Graph/Graph.svelte +4 -6
- package/dist/Graph/GraphProps.svelte +41 -0
- package/dist/Graph/GraphProps.svelte.d.ts +10 -0
- package/dist/Input/Input.svelte +42 -48
- package/dist/Input/InputProps.svelte +205 -0
- package/dist/Input/InputProps.svelte.d.ts +10 -0
- package/dist/Modal.svelte +54 -0
- package/dist/Modal.svelte.d.ts +12 -0
- package/dist/ProgressBar/ProgressBar.svelte +23 -21
- package/dist/ProgressBar/ProgressBarProps.svelte +114 -0
- package/dist/ProgressBar/ProgressBarProps.svelte.d.ts +10 -0
- package/dist/Select/Select.svelte +38 -23
- package/dist/Select/SelectProps.svelte +216 -0
- package/dist/Select/SelectProps.svelte.d.ts +10 -0
- package/dist/Slider/Slider.svelte +74 -28
- package/dist/Slider/SliderProps.svelte +113 -0
- package/dist/Slider/SliderProps.svelte.d.ts +10 -0
- package/dist/Switch/Switch.svelte +22 -16
- package/dist/Switch/SwitchProps.svelte +99 -0
- package/dist/Switch/SwitchProps.svelte.d.ts +10 -0
- package/dist/Table/Table.svelte +58 -39
- package/dist/Table/Table.svelte.d.ts +1 -1
- package/dist/Table/TableProps.svelte +233 -0
- package/dist/Table/TableProps.svelte.d.ts +10 -0
- package/dist/TextField/TextField.svelte +18 -14
- package/dist/TextField/TextFieldProps.svelte +92 -0
- package/dist/TextField/TextFieldProps.svelte.d.ts +10 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/libIcons/ButtonAdd.svelte +5 -2
- package/dist/libIcons/ButtonDelete.svelte +1 -1
- package/dist/libIcons/CrossIcon.svelte +9 -0
- package/dist/libIcons/CrossIcon.svelte.d.ts +18 -0
- package/dist/libIcons/IconGripVerticalDual.svelte +12 -0
- package/dist/libIcons/IconGripVerticalDual.svelte.d.ts +18 -0
- package/dist/libIcons/IconGripVerticalLeft.svelte +9 -0
- package/dist/libIcons/IconGripVerticalLeft.svelte.d.ts +18 -0
- package/dist/libIcons/IconGripVerticalRight.svelte +9 -0
- package/dist/libIcons/IconGripVerticalRight.svelte.d.ts +18 -0
- package/dist/locales/i18n.d.ts +9 -0
- package/dist/locales/i18n.js +33 -0
- package/dist/locales/translations.d.ts +7 -0
- package/dist/locales/translations.js +93 -0
- package/dist/options.d.ts +18 -23
- package/dist/options.js +44 -33
- package/dist/types.d.ts +50 -91
- package/dist/types.js +13 -1
- package/package.json +10 -5
- package/dist/Loader.svelte +0 -12
- package/dist/Loader.svelte.d.ts +0 -5
- package/dist/MessageModal.svelte +0 -54
- package/dist/MessageModal.svelte.d.ts +0 -10
package/dist/Table/Table.svelte
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
import { get } from 'svelte/store'
|
|
4
4
|
import type { ITableHeader, ITableProps } from '../types'
|
|
5
5
|
import { fly } from 'svelte/transition'
|
|
6
|
+
import { twMerge } from 'tailwind-merge'
|
|
7
|
+
import { Button, Modal } from '..'
|
|
8
|
+
import { t } from '../locales/i18n'
|
|
6
9
|
|
|
7
10
|
let {
|
|
8
|
-
id =
|
|
9
|
-
wrapperClass = '
|
|
11
|
+
id = crypto.randomUUID(),
|
|
12
|
+
wrapperClass = '',
|
|
10
13
|
label = { name: '', class: '' },
|
|
11
14
|
body = [],
|
|
12
15
|
header = [],
|
|
@@ -14,10 +17,11 @@
|
|
|
14
17
|
cursor = null,
|
|
15
18
|
loader,
|
|
16
19
|
getData = () => {},
|
|
17
|
-
modalData = $bindable({ isOpen: false, rawData: '', formattedData: '' }),
|
|
18
20
|
onClick,
|
|
19
21
|
}: ITableProps<any> = $props()
|
|
20
22
|
|
|
23
|
+
let modalData = $state({ isOpen: false, rawData: '', formattedData: '' })
|
|
24
|
+
|
|
21
25
|
/* Сортировка */
|
|
22
26
|
let sortState: {
|
|
23
27
|
key: string | null
|
|
@@ -119,40 +123,37 @@
|
|
|
119
123
|
}
|
|
120
124
|
</script>
|
|
121
125
|
|
|
122
|
-
<div
|
|
126
|
+
<div {id} class={twMerge(`bg-blue flex h-full w-full flex-col overflow-hidden`, wrapperClass)}>
|
|
123
127
|
{#if label.name}
|
|
124
|
-
<h5 class={`w-full px-4 text-center
|
|
128
|
+
<h5 class={twMerge(`w-full px-4 text-center`, label.class)}>{label.name}</h5>
|
|
125
129
|
{/if}
|
|
126
130
|
|
|
127
131
|
<div class="flex h-full flex-col overflow-hidden rounded-xl border-[var(--border-color)]">
|
|
128
132
|
<!-- Table Header -->
|
|
129
133
|
<div class="grid font-semibold" style={`grid-template-columns: ${header.map((c) => c.width || 'minmax(0, 1fr)').join(' ')};`}>
|
|
130
134
|
{#each header as column (column)}
|
|
131
|
-
<div class=
|
|
132
|
-
<
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
{/if}
|
|
142
|
-
</div>
|
|
135
|
+
<div class={twMerge(`justify-center bg-[var(--bg-color)] p-2 text-left`, column.label?.class)}>
|
|
136
|
+
<span>{column.label?.name}</span>
|
|
137
|
+
{#if column.sortable}
|
|
138
|
+
<button
|
|
139
|
+
class="inline-block cursor-pointer font-bold transition-transform duration-75 hover:scale-110 active:scale-95"
|
|
140
|
+
onclick={() => sortRows(column.key as string)}
|
|
141
|
+
>
|
|
142
|
+
↑↓
|
|
143
|
+
</button>
|
|
144
|
+
{/if}
|
|
143
145
|
</div>
|
|
144
146
|
{/each}
|
|
145
147
|
</div>
|
|
146
148
|
|
|
147
149
|
<!-- Table Body с прокруткой -->
|
|
148
|
-
<div class="flex-1 overflow-y-auto bg-[var(--
|
|
150
|
+
<div class="flex-1 overflow-y-auto bg-[var(--container-color)]/50" bind:this={container} onscroll={handleScroll}>
|
|
149
151
|
<div class="grid min-w-0" style={`grid-template-columns: ${header.map((c) => c.width || 'minmax(0, 1fr)').join(' ')};`}>
|
|
150
152
|
{#each body as row, index (row)}
|
|
151
153
|
{#each header as column (column)}
|
|
152
154
|
<div
|
|
153
155
|
class="relative flex w-full min-w-0 items-center px-2 py-1 break-words
|
|
154
156
|
{index % 2 ? '!bg-[var(--back-color)]/40' : ''}
|
|
155
|
-
{column.cellClass}
|
|
156
157
|
{column.align === 'center'
|
|
157
158
|
? 'flex justify-center text-center'
|
|
158
159
|
: column.align === 'right'
|
|
@@ -163,11 +164,9 @@
|
|
|
163
164
|
<div class="flex w-full flex-col gap-1">
|
|
164
165
|
{#each column.buttons as button (button)}
|
|
165
166
|
<button
|
|
166
|
-
class="
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
{typeof button.class === 'function' ? button.class(row) : button.class}
|
|
170
|
-
"
|
|
167
|
+
class="{twMerge(`cursor-pointer rounded-full
|
|
168
|
+
px-4 py-1 font-medium transition-shadow outline-none select-none hover:shadow-md
|
|
169
|
+
${typeof button.class === 'function' ? button.class(row) : button.class}`)} bg-[var(--bg-color)]"
|
|
171
170
|
onclick={() => buttonClick(row, button)}
|
|
172
171
|
>
|
|
173
172
|
{typeof button.name === 'function' ? button.name(row) : button.name}
|
|
@@ -175,12 +174,15 @@
|
|
|
175
174
|
{/each}
|
|
176
175
|
</div>
|
|
177
176
|
{:else if column.image}
|
|
178
|
-
<div
|
|
177
|
+
<div
|
|
178
|
+
class="flex items-center justify-center"
|
|
179
|
+
style={`width: ${column.image.width || '5rem'}; height: ${column.image.height || '5rem'};`}
|
|
180
|
+
>
|
|
179
181
|
{#if hasImage(column, row)}
|
|
180
182
|
<img
|
|
181
183
|
src={typeof column.image?.src === 'function' ? column.image.src(row) : column.image?.src || ''}
|
|
182
184
|
alt={column.image.alt ?? 'Image'}
|
|
183
|
-
class=
|
|
185
|
+
class={twMerge(`h-full w-full object-cover ${column.image.class || ''}`)}
|
|
184
186
|
loading="lazy"
|
|
185
187
|
/>
|
|
186
188
|
{:else if column.image.defaultIcon}
|
|
@@ -189,7 +191,9 @@
|
|
|
189
191
|
</div>
|
|
190
192
|
{:else}
|
|
191
193
|
<div
|
|
192
|
-
class="w-full max-w-full break-words {column.overflow?.truncated
|
|
194
|
+
class="w-full max-w-full break-words {column.overflow?.truncated
|
|
195
|
+
? 'overflow-hidden text-ellipsis whitespace-nowrap'
|
|
196
|
+
: 'whitespace-normal'}"
|
|
193
197
|
onmouseenter={column.overflow?.truncated ? (e) => showTooltip(e, row[column.key], column.overflow?.formatting) : undefined}
|
|
194
198
|
onmouseleave={column.overflow?.truncated ? hideTooltip : undefined}
|
|
195
199
|
onmousemove={column.overflow?.truncated
|
|
@@ -218,7 +222,7 @@
|
|
|
218
222
|
|
|
219
223
|
{#if column.overflow?.copy}
|
|
220
224
|
<button
|
|
221
|
-
class="
|
|
225
|
+
class="m-2 flex cursor-pointer border-none bg-transparent text-2xl"
|
|
222
226
|
onclick={(e) => {
|
|
223
227
|
e.preventDefault()
|
|
224
228
|
navigator.clipboard.writeText(row[column.key])
|
|
@@ -227,7 +231,15 @@
|
|
|
227
231
|
}}
|
|
228
232
|
aria-label="Копировать текст"
|
|
229
233
|
>
|
|
230
|
-
|
|
234
|
+
{#if copiedCell.y === index && copiedCell.x === column.key}
|
|
235
|
+
<div
|
|
236
|
+
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"
|
|
237
|
+
transition:fly={{ x: 10, duration: 200 }}
|
|
238
|
+
>
|
|
239
|
+
✓
|
|
240
|
+
</div>
|
|
241
|
+
{/if}
|
|
242
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
|
|
231
243
|
<g fill="none" stroke="currentColor" stroke-width="1.5">
|
|
232
244
|
<path
|
|
233
245
|
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"
|
|
@@ -236,15 +248,6 @@
|
|
|
236
248
|
</g>
|
|
237
249
|
</svg>
|
|
238
250
|
</button>
|
|
239
|
-
|
|
240
|
-
{#if copiedCell.y === index && copiedCell.x === column.key}
|
|
241
|
-
<div
|
|
242
|
-
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"
|
|
243
|
-
transition:fly={{ x: 10, duration: 200 }}
|
|
244
|
-
>
|
|
245
|
-
✓
|
|
246
|
-
</div>
|
|
247
|
-
{/if}
|
|
248
251
|
{/if}
|
|
249
252
|
{/if}
|
|
250
253
|
</div>
|
|
@@ -266,10 +269,26 @@
|
|
|
266
269
|
{/if}
|
|
267
270
|
|
|
268
271
|
<!-- Нижнее поле для сводной информации -->
|
|
269
|
-
{#if footer
|
|
272
|
+
{#if footer}
|
|
270
273
|
<div class="flex h-8 items-center justify-center bg-[var(--bg-color)]">
|
|
271
274
|
<h5>{footer}</h5>
|
|
272
275
|
</div>
|
|
273
276
|
{/if}
|
|
274
277
|
</div>
|
|
275
278
|
</div>
|
|
279
|
+
|
|
280
|
+
<Modal isOpen={modalData.isOpen} title={$t('debug.baud_rate_data')}>
|
|
281
|
+
{#snippet main()}
|
|
282
|
+
{@html modalData.formattedData}
|
|
283
|
+
{/snippet}
|
|
284
|
+
{#snippet footer()}
|
|
285
|
+
<Button
|
|
286
|
+
content={{ name: 'Copy' }}
|
|
287
|
+
wrapperClass="w-20 bg-pink"
|
|
288
|
+
onClick={() => {
|
|
289
|
+
navigator.clipboard.writeText(modalData.rawData)
|
|
290
|
+
modalData.isOpen = false
|
|
291
|
+
}}
|
|
292
|
+
/>
|
|
293
|
+
{/snippet}
|
|
294
|
+
</Modal>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ITableProps } from '../types';
|
|
2
|
-
declare const Table: import("svelte").Component<ITableProps<any>, {}, "
|
|
2
|
+
declare const Table: import("svelte").Component<ITableProps<any>, {}, "">;
|
|
3
3
|
type Table = ReturnType<typeof Table>;
|
|
4
4
|
export default Table;
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
<!-- $lib/ElementsUI/TableProps.svelte -->
|
|
2
|
+
<script lang="ts">
|
|
3
|
+
import { getContext } from 'svelte'
|
|
4
|
+
import { t } from '../locales/i18n'
|
|
5
|
+
import { type UIComponent, type ITableProps, type ITableHeader, updateProperty } from '../types'
|
|
6
|
+
import * as UI from '..'
|
|
7
|
+
import ButtonDelete from '../libIcons/ButtonDelete.svelte'
|
|
8
|
+
import ButtonAdd from '../libIcons/ButtonAdd.svelte'
|
|
9
|
+
import { optionsStore } from '../options'
|
|
10
|
+
|
|
11
|
+
const { component, onPropertyChange } = $props<{
|
|
12
|
+
component: UIComponent & { properties: Partial<ITableProps<object>> }
|
|
13
|
+
onPropertyChange: (value: string | object) => void
|
|
14
|
+
}>()
|
|
15
|
+
|
|
16
|
+
const DeviceVariables = getContext<{ value: string; name: string }[]>('DeviceVariables')
|
|
17
|
+
let VARIABLE_OPTIONS = $derived(
|
|
18
|
+
DeviceVariables && Array.isArray(DeviceVariables)
|
|
19
|
+
? DeviceVariables.map((variable) => ({
|
|
20
|
+
id: variable.name,
|
|
21
|
+
value: variable.value,
|
|
22
|
+
name: `${variable.value} | ${variable.name}`,
|
|
23
|
+
}))
|
|
24
|
+
: [],
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
const initialColor = $derived(
|
|
28
|
+
$optionsStore.COLOR_OPTIONS.find((c) =>
|
|
29
|
+
(c.value as string).includes(component.properties.wrapperClass?.split(' ').find((cls: string) => cls.startsWith('bg-'))),
|
|
30
|
+
),
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
const initialAlign = $derived(
|
|
34
|
+
$optionsStore.ALIGN_OPTIONS.find((a) =>
|
|
35
|
+
(a.value as string).includes(component.properties.label?.class?.split(' ').find((cls: string) => cls.startsWith('text-'))),
|
|
36
|
+
),
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
const updateTableHeader = (index: number, field: string, value: any) => {
|
|
40
|
+
const headers = [...component.properties.header]
|
|
41
|
+
headers[index] = { ...headers[index], [field]: value }
|
|
42
|
+
updateProperty('header', headers, component, onPropertyChange)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const updateButtonProperty = (columnIndex: number, buttonIndex: number, field: string, value: any) => {
|
|
46
|
+
const headers = [...component.properties.header]
|
|
47
|
+
const buttons = [...headers[columnIndex].buttons]
|
|
48
|
+
buttons[buttonIndex] = { ...buttons[buttonIndex], [field]: value }
|
|
49
|
+
headers[columnIndex].buttons = buttons
|
|
50
|
+
updateProperty('header', headers, component, onPropertyChange)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const removeButtonFromColumn = (columnIndex: number, buttonIndex: number) => {
|
|
54
|
+
const headers = [...component.properties.header]
|
|
55
|
+
const buttons = [...headers[columnIndex].buttons]
|
|
56
|
+
buttons.splice(buttonIndex, 1)
|
|
57
|
+
headers[columnIndex].buttons = buttons.length ? buttons : undefined
|
|
58
|
+
updateProperty('header', headers, component, onPropertyChange)
|
|
59
|
+
}
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
{#if component && component.properties}
|
|
63
|
+
<div class="relative flex flex-row items-start justify-center">
|
|
64
|
+
<div class="flex w-1/3 flex-col items-center px-2">
|
|
65
|
+
<UI.Select
|
|
66
|
+
label={{ name: $t('constructor.props.variable') }}
|
|
67
|
+
options={VARIABLE_OPTIONS}
|
|
68
|
+
value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id.value)}
|
|
69
|
+
onUpdate={(value) => {
|
|
70
|
+
updateProperty('id', value.value as string, component, onPropertyChange)
|
|
71
|
+
updateProperty('eventHandler.Variables', value.value as string, component, onPropertyChange)
|
|
72
|
+
}}
|
|
73
|
+
/>
|
|
74
|
+
</div>
|
|
75
|
+
<div class="flex w-1/3 flex-col px-2">
|
|
76
|
+
<UI.Select
|
|
77
|
+
wrapperClass="!h-14"
|
|
78
|
+
label={{ name: $t('constructor.props.colors') }}
|
|
79
|
+
type="buttons"
|
|
80
|
+
options={$optionsStore.COLOR_OPTIONS}
|
|
81
|
+
value={initialColor}
|
|
82
|
+
onUpdate={(option) => updateProperty('wrapperClass', `${component.properties.wrapperClass} ${option.value}`, component, onPropertyChange)}
|
|
83
|
+
/>
|
|
84
|
+
</div>
|
|
85
|
+
<div class="flex w-1/3 flex-col px-2">
|
|
86
|
+
<UI.Input
|
|
87
|
+
label={{ name: $t('constructor.props.label') }}
|
|
88
|
+
value={component.properties.label.name}
|
|
89
|
+
onUpdate={(value) => updateProperty('label.name', value as string, component, onPropertyChange)}
|
|
90
|
+
/>
|
|
91
|
+
<UI.Select
|
|
92
|
+
label={{ name: $t('constructor.props.align') }}
|
|
93
|
+
type="buttons"
|
|
94
|
+
value={initialAlign}
|
|
95
|
+
options={$optionsStore.ALIGN_OPTIONS}
|
|
96
|
+
onUpdate={(option) => updateProperty('label.class', `${component.properties.label.class} ${option.value}`, component, onPropertyChange)}
|
|
97
|
+
/>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
<hr class="border-[var(--border-color)]" />
|
|
102
|
+
|
|
103
|
+
<!-- Настройки столбцов таблицы -->
|
|
104
|
+
<div class="space-y-4">
|
|
105
|
+
<div class="m-0 flex items-center justify-center gap-2">
|
|
106
|
+
<h4>{$t('constructor.props.table.columns')}</h4>
|
|
107
|
+
<UI.Button
|
|
108
|
+
wrapperClass="!w-10"
|
|
109
|
+
content={{ icon: ButtonAdd }}
|
|
110
|
+
componentClass="bg-transparent h-10 border-none !shadow-none hover:shadow-none"
|
|
111
|
+
onClick={() => {
|
|
112
|
+
const newColumn: ITableHeader<any> = {
|
|
113
|
+
key: `column${(component.properties.header?.length || 0) + 1}`,
|
|
114
|
+
label: { name: `Column ${(component.properties.header?.length || 0) + 1}`, class: '' },
|
|
115
|
+
width: '100px',
|
|
116
|
+
sortable: false,
|
|
117
|
+
}
|
|
118
|
+
const headers = [...(component.properties.header || []), newColumn]
|
|
119
|
+
updateProperty('header', headers, component, onPropertyChange)
|
|
120
|
+
}}
|
|
121
|
+
/>
|
|
122
|
+
</div>
|
|
123
|
+
|
|
124
|
+
{#each component.properties.header as column, columnIndex (columnIndex)}
|
|
125
|
+
<div class="m-0 flex items-end justify-around gap-2">
|
|
126
|
+
<UI.Input
|
|
127
|
+
label={{ name: $t('constructor.props.table.columns.key') }}
|
|
128
|
+
wrapperClass="!w-2/10"
|
|
129
|
+
value={column.key}
|
|
130
|
+
help={{ regExp: /^[0-9a-zA-Z_-]{0,16}$/ }}
|
|
131
|
+
onUpdate={(value) => updateTableHeader(columnIndex, 'key', value)}
|
|
132
|
+
/>
|
|
133
|
+
<UI.Input
|
|
134
|
+
label={{ name: $t('constructor.props.table.columns.label') }}
|
|
135
|
+
wrapperClass="!w-2/10"
|
|
136
|
+
value={column.label.name}
|
|
137
|
+
onUpdate={(value) => updateTableHeader(columnIndex, 'label.name', value)}
|
|
138
|
+
/>
|
|
139
|
+
<UI.Input
|
|
140
|
+
label={{ name: $t('constructor.props.table.columns.width') }}
|
|
141
|
+
wrapperClass="!w-2/10"
|
|
142
|
+
value={column.width}
|
|
143
|
+
onUpdate={(value) => updateTableHeader(columnIndex, 'width', value)}
|
|
144
|
+
/>
|
|
145
|
+
<UI.Switch
|
|
146
|
+
wrapperClass="!w-1/10 bg-blue"
|
|
147
|
+
label={{ name: $t('constructor.props.table.columns.sortable') }}
|
|
148
|
+
value={column.sortable ? 2 : 1}
|
|
149
|
+
onChange={(value) => updateTableHeader(columnIndex, 'sortable', value === 2)}
|
|
150
|
+
/>
|
|
151
|
+
<UI.Button
|
|
152
|
+
wrapperClass="w-10"
|
|
153
|
+
content={{ icon: ButtonAdd, info: $t('constructor.props.table.addaction') }}
|
|
154
|
+
componentClass="bg-transparent h-10 w-10 border-none !shadow-none hover:shadow-none"
|
|
155
|
+
onClick={() => {
|
|
156
|
+
const newButton = {
|
|
157
|
+
name: `button${(component.properties.header[columnIndex].buttons.length || 0) + 1}`,
|
|
158
|
+
class: 'bg-blue',
|
|
159
|
+
eventHandler: { Header: 'SET', Argument: 'Save', Variables: [] },
|
|
160
|
+
onClick: () => {},
|
|
161
|
+
}
|
|
162
|
+
const buttons = [...(component.properties.header[columnIndex].buttons || []), newButton]
|
|
163
|
+
updateTableHeader(columnIndex, 'buttons', buttons)
|
|
164
|
+
}}
|
|
165
|
+
/>
|
|
166
|
+
<UI.Button
|
|
167
|
+
wrapperClass="w-10"
|
|
168
|
+
content={{ icon: ButtonDelete, info: $t('constructor.props.table.deletecolumn') }}
|
|
169
|
+
componentClass=" bg-transparent h-10 w-10 border-none !shadow-none hover:shadow-none"
|
|
170
|
+
onClick={() => {
|
|
171
|
+
const headers = [...(component.properties.header || [])]
|
|
172
|
+
headers.splice(columnIndex, 1)
|
|
173
|
+
updateProperty('header', headers, component, onPropertyChange)
|
|
174
|
+
}}
|
|
175
|
+
/>
|
|
176
|
+
</div>
|
|
177
|
+
{#if column.buttons && column.buttons.length > 0}
|
|
178
|
+
<div class="mb-5 rounded-lg p-1">
|
|
179
|
+
{#each column.buttons as button, buttonIndex (buttonIndex)}
|
|
180
|
+
<div class="mx-14 flex items-end justify-around gap-2">
|
|
181
|
+
<UI.Input
|
|
182
|
+
label={{ name: $t('constructor.props.name') }}
|
|
183
|
+
wrapperClass="!w-3/10"
|
|
184
|
+
value={button.name}
|
|
185
|
+
onUpdate={(value) => updateButtonProperty(columnIndex, buttonIndex, 'name', value)}
|
|
186
|
+
/>
|
|
187
|
+
<UI.Select
|
|
188
|
+
wrapperClass="!w-2/10"
|
|
189
|
+
label={{ name: $t('constructor.props.header') }}
|
|
190
|
+
type="buttons"
|
|
191
|
+
value={$optionsStore.HEADER_OPTIONS.find((h) => h.value === button.eventHandler?.Header)}
|
|
192
|
+
options={$optionsStore.HEADER_OPTIONS}
|
|
193
|
+
onUpdate={(option) => {
|
|
194
|
+
const handler = button.eventHandler
|
|
195
|
+
handler.Header = option.value as string
|
|
196
|
+
updateButtonProperty(columnIndex, buttonIndex, 'eventHandler', handler)
|
|
197
|
+
}}
|
|
198
|
+
/>
|
|
199
|
+
<UI.Input
|
|
200
|
+
wrapperClass="!w-2/10"
|
|
201
|
+
label={{ name: $t('constructor.props.argument') }}
|
|
202
|
+
value={button.eventHandler?.Argument}
|
|
203
|
+
onUpdate={(value) => {
|
|
204
|
+
const handler = button.eventHandler
|
|
205
|
+
handler.Argument = value as string
|
|
206
|
+
updateButtonProperty(columnIndex, buttonIndex, 'eventHandler', handler)
|
|
207
|
+
}}
|
|
208
|
+
/>
|
|
209
|
+
<UI.Input
|
|
210
|
+
wrapperClass="!w-2/10"
|
|
211
|
+
label={{ name: $t('constructor.props.table.keys') }}
|
|
212
|
+
value={button.eventHandler?.Variables.join(' ')}
|
|
213
|
+
maxlength={500}
|
|
214
|
+
help={{ info: $t('constructor.props.table.keys.info'), regExp: /^[a-zA-Z0-9\-_ ]{0,500}$/ }}
|
|
215
|
+
onUpdate={(value) => {
|
|
216
|
+
const handler = { ...button.eventHandler }
|
|
217
|
+
handler.Variables = (value as string).trim().split(/\s+/)
|
|
218
|
+
updateButtonProperty(columnIndex, buttonIndex, 'eventHandler', handler)
|
|
219
|
+
}}
|
|
220
|
+
/>
|
|
221
|
+
<UI.Button
|
|
222
|
+
wrapperClass="w-10 m"
|
|
223
|
+
content={{ icon: ButtonDelete }}
|
|
224
|
+
componentClass="bg-transparent h-10 w-10 border-none !shadow-none hover:shadow-none"
|
|
225
|
+
onClick={() => removeButtonFromColumn(columnIndex, buttonIndex)}
|
|
226
|
+
/>
|
|
227
|
+
</div>
|
|
228
|
+
{/each}
|
|
229
|
+
</div>
|
|
230
|
+
{/if}
|
|
231
|
+
{/each}
|
|
232
|
+
</div>
|
|
233
|
+
{/if}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type UIComponent, type ITableProps } from '../types';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
component: UIComponent & {
|
|
4
|
+
properties: Partial<ITableProps<object>>;
|
|
5
|
+
};
|
|
6
|
+
onPropertyChange: (value: string | object) => void;
|
|
7
|
+
};
|
|
8
|
+
declare const TableProps: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
9
|
+
type TableProps = ReturnType<typeof TableProps>;
|
|
10
|
+
export default TableProps;
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { twMerge } from 'tailwind-merge'
|
|
2
3
|
import type { ITextFieldProps } from '../types'
|
|
3
4
|
|
|
4
|
-
let {
|
|
5
|
-
id = { value: crypto.randomUUID(), name: '' },
|
|
6
|
-
wrapperClass = '',
|
|
7
|
-
label = { name: '', class: '' },
|
|
8
|
-
type = 'small',
|
|
9
|
-
bold = false,
|
|
10
|
-
italic = false,
|
|
11
|
-
}: ITextFieldProps = $props()
|
|
5
|
+
let { id = crypto.randomUUID(), wrapperClass = '', background = false, content = { name: '', class: '', size: 'base' } }: ITextFieldProps = $props()
|
|
12
6
|
|
|
13
7
|
const textSize = {
|
|
14
|
-
small: 'text-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
small: 'text-sm',
|
|
9
|
+
base: 'text-base',
|
|
10
|
+
large: 'text-2xl',
|
|
11
|
+
huge: 'text-4xl',
|
|
12
|
+
massive: 'text-5xl',
|
|
13
|
+
} as const
|
|
18
14
|
</script>
|
|
19
15
|
|
|
20
|
-
<div
|
|
21
|
-
|
|
16
|
+
<div
|
|
17
|
+
{id}
|
|
18
|
+
class="{twMerge(
|
|
19
|
+
`relative flex w-full flex-col items-center ${background ? 'rounded-2xl bg-[var(--container-color)] px-6 py-2' : ''}`,
|
|
20
|
+
wrapperClass,
|
|
21
|
+
)} "
|
|
22
|
+
>
|
|
23
|
+
<p class={twMerge(`w-full text-center ${textSize[content.size ?? 'base']}`, content.class)}>
|
|
24
|
+
{content.name}
|
|
25
|
+
</p>
|
|
22
26
|
</div>
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<!-- $lib/ElementsUI/GridAccordionProps.svelte -->
|
|
2
|
+
<script lang="ts">
|
|
3
|
+
import { t } from '../locales/i18n'
|
|
4
|
+
import { updateProperty, type ITextFieldProps, type UIComponent } from '../types'
|
|
5
|
+
import * as UI from '../index'
|
|
6
|
+
import { optionsStore } from '../options'
|
|
7
|
+
|
|
8
|
+
const { component, onPropertyChange } = $props<{
|
|
9
|
+
component: UIComponent & { properties: Partial<ITextFieldProps> }
|
|
10
|
+
onPropertyChange: (value: string | object) => void
|
|
11
|
+
}>()
|
|
12
|
+
|
|
13
|
+
let currentType = $derived($optionsStore.TEXTFIELD_SIZE_OPTIONS.find((t) => t.value === component.properties.content.size))
|
|
14
|
+
|
|
15
|
+
const initialAlign = $derived(
|
|
16
|
+
$optionsStore.ALIGN_OPTIONS.find((a) =>
|
|
17
|
+
(a.value as string).includes(component.properties.content?.class?.split(' ').find((cls: string) => cls.startsWith('text-'))),
|
|
18
|
+
),
|
|
19
|
+
)
|
|
20
|
+
const initialColor = $derived(
|
|
21
|
+
$optionsStore.TEXT_COLOR_OPTIONS.find((c) =>
|
|
22
|
+
(c.value as string).includes(component.properties.wrapperClass?.split(' ').find((cls: string) => cls.startsWith('text-'))),
|
|
23
|
+
),
|
|
24
|
+
)
|
|
25
|
+
const initialBold = $derived(component.properties.content?.class?.split(' ').find((cls: string) => cls.startsWith('font-bold')))
|
|
26
|
+
const initialItalic = $derived(component.properties.content?.class?.split(' ').find((cls: string) => cls.startsWith('italic')))
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
{#if component && component.properties}
|
|
30
|
+
<div class="relative flex flex-row items-start justify-center">
|
|
31
|
+
<div class="flex w-1/3 flex-col px-2">
|
|
32
|
+
<UI.Input
|
|
33
|
+
label={{ name: $t('constructor.props.label') }}
|
|
34
|
+
value={component.properties.content.name}
|
|
35
|
+
onUpdate={(value) => updateProperty('content.name', value as string, component, onPropertyChange)}
|
|
36
|
+
/>
|
|
37
|
+
<UI.Select
|
|
38
|
+
label={{ name: $t('constructor.props.size') }}
|
|
39
|
+
type="buttons"
|
|
40
|
+
value={currentType}
|
|
41
|
+
options={$optionsStore.TEXTFIELD_SIZE_OPTIONS}
|
|
42
|
+
onUpdate={(item) => updateProperty('content.size', item.value as string, component, onPropertyChange)}
|
|
43
|
+
/>
|
|
44
|
+
</div>
|
|
45
|
+
<div class="flex w-1/3 flex-col px-2">
|
|
46
|
+
<UI.Select
|
|
47
|
+
label={{ name: $t('constructor.props.align') }}
|
|
48
|
+
type="buttons"
|
|
49
|
+
value={initialAlign}
|
|
50
|
+
options={$optionsStore.ALIGN_OPTIONS}
|
|
51
|
+
onUpdate={(option) => updateProperty('content.class', `${component.properties.content.class} ${option.value}`, component, onPropertyChange)}
|
|
52
|
+
/>
|
|
53
|
+
<UI.Select
|
|
54
|
+
wrapperClass="!h-14"
|
|
55
|
+
label={{ name: $t('constructor.props.colors') }}
|
|
56
|
+
type="buttons"
|
|
57
|
+
options={$optionsStore.TEXT_COLOR_OPTIONS}
|
|
58
|
+
value={initialColor}
|
|
59
|
+
onUpdate={(option) => updateProperty('wrapperClass', `${component.properties.wrapperClass} ${option.value}`, component, onPropertyChange)}
|
|
60
|
+
/>
|
|
61
|
+
</div>
|
|
62
|
+
<div class="flex w-1/3 flex-col px-2">
|
|
63
|
+
<UI.Switch
|
|
64
|
+
label={{ name: $t('constructor.props.bold') }}
|
|
65
|
+
value={initialBold ? 2 : 1}
|
|
66
|
+
onChange={(value) =>
|
|
67
|
+
updateProperty(
|
|
68
|
+
'content.class',
|
|
69
|
+
`${component.properties.content.class} ${value === 2 ? 'font-bold' : 'font-normal'}`,
|
|
70
|
+
component,
|
|
71
|
+
onPropertyChange,
|
|
72
|
+
)}
|
|
73
|
+
/>
|
|
74
|
+
<UI.Switch
|
|
75
|
+
label={{ name: $t('constructor.props.italic') }}
|
|
76
|
+
value={initialItalic ? 2 : 1}
|
|
77
|
+
onChange={(value) =>
|
|
78
|
+
updateProperty(
|
|
79
|
+
'content.class',
|
|
80
|
+
`${component.properties.content.class} ${value === 2 ? 'italic' : 'not-italic'}`,
|
|
81
|
+
component,
|
|
82
|
+
onPropertyChange,
|
|
83
|
+
)}
|
|
84
|
+
/>
|
|
85
|
+
<UI.Switch
|
|
86
|
+
label={{ name: $t('constructor.props.background') }}
|
|
87
|
+
value={component.properties.background ? 2 : 1}
|
|
88
|
+
onChange={(value) => updateProperty('background', value === 2, component, onPropertyChange)}
|
|
89
|
+
/>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
{/if}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ITextFieldProps, type UIComponent } from '../types';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
component: UIComponent & {
|
|
4
|
+
properties: Partial<ITextFieldProps>;
|
|
5
|
+
};
|
|
6
|
+
onPropertyChange: (value: string | object) => void;
|
|
7
|
+
};
|
|
8
|
+
declare const TextFieldProps: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
9
|
+
type TextFieldProps = ReturnType<typeof TextFieldProps>;
|
|
10
|
+
export default TextFieldProps;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export { default as Accordion } from './Accordion/Accordion.svelte';
|
|
2
2
|
export { default as Button } from './Button/Button.svelte';
|
|
3
3
|
export { default as ColorPicker } from './ColorPicker/ColorPicker.svelte';
|
|
4
|
-
export { default as FileAttach } from './FileAttach
|
|
4
|
+
export { default as FileAttach } from './FileAttach.svelte';
|
|
5
5
|
export { default as Graph } from './Graph/Graph.svelte';
|
|
6
6
|
export { default as Input } from './Input/Input.svelte';
|
|
7
|
+
export { default as Modal } from './Modal.svelte';
|
|
7
8
|
export { default as ProgressBar } from './ProgressBar/ProgressBar.svelte';
|
|
8
9
|
export { default as Select } from './Select/Select.svelte';
|
|
9
10
|
export { default as Slider } from './Slider/Slider.svelte';
|
|
10
11
|
export { default as Switch } from './Switch/Switch.svelte';
|
|
11
12
|
export { default as Table } from './Table/Table.svelte';
|
|
12
13
|
export { default as TextField } from './TextField/TextField.svelte';
|
|
13
|
-
export { default as
|
|
14
|
-
export { default as MessageModal } from './MessageModal.svelte';
|
|
14
|
+
export { default as TextFieldProps } from './TextField/TextFieldProps.svelte';
|
|
15
15
|
export { type UIComponent, type Position, type IUIComponentHandler, type IButtonProps, type IAccordionProps, type IInputProps, type ISelectProps, type ISelectOption, type ISwitchProps, type IColorPickerProps, type ISliderProps, type ITextFieldProps, type IProgressBarProps, type IGraphProps, type IGraphDataObject, type ITableHeader, type ITableProps, } from './types';
|
package/dist/index.js
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
export { default as Accordion } from './Accordion/Accordion.svelte';
|
|
3
3
|
export { default as Button } from './Button/Button.svelte';
|
|
4
4
|
export { default as ColorPicker } from './ColorPicker/ColorPicker.svelte';
|
|
5
|
-
export { default as FileAttach } from './FileAttach
|
|
5
|
+
export { default as FileAttach } from './FileAttach.svelte';
|
|
6
6
|
export { default as Graph } from './Graph/Graph.svelte';
|
|
7
7
|
export { default as Input } from './Input/Input.svelte';
|
|
8
|
+
export { default as Modal } from './Modal.svelte';
|
|
8
9
|
export { default as ProgressBar } from './ProgressBar/ProgressBar.svelte';
|
|
9
10
|
export { default as Select } from './Select/Select.svelte';
|
|
10
11
|
export { default as Slider } from './Slider/Slider.svelte';
|
|
11
12
|
export { default as Switch } from './Switch/Switch.svelte';
|
|
12
13
|
export { default as Table } from './Table/Table.svelte';
|
|
13
14
|
export { default as TextField } from './TextField/TextField.svelte';
|
|
14
|
-
export { default as
|
|
15
|
-
export { default as MessageModal } from './MessageModal.svelte';
|
|
15
|
+
export { default as TextFieldProps } from './TextField/TextFieldProps.svelte';
|
|
16
16
|
export {} from './types';
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
<script lang="ts"></script>
|
|
2
2
|
|
|
3
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="
|
|
4
|
-
><path
|
|
3
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="1.5em" height="1.5em" viewBox="0 0 24 24"
|
|
4
|
+
><path
|
|
5
|
+
fill="currentColor"
|
|
6
|
+
d="M12.75 9a.75.75 0 0 0-1.5 0v2.25H9a.75.75 0 0 0 0 1.5h2.25V15a.75.75 0 0 0 1.5 0v-2.25H15a.75.75 0 0 0 0-1.5h-2.25z"
|
|
7
|
+
/><path
|
|
5
8
|
fill="currentColor"
|
|
6
9
|
fill-rule="evenodd"
|
|
7
10
|
d="M12.057 1.25h-.114c-2.309 0-4.118 0-5.53.19c-1.444.194-2.584.6-3.479 1.494c-.895.895-1.3 2.035-1.494 3.48c-.19 1.411-.19 3.22-.19 5.529v.114c0 2.309 0 4.118.19 5.53c.194 1.444.6 2.584 1.494 3.479c.895.895 2.035 1.3 3.48 1.494c1.411.19 3.22.19 5.529.19h.114c2.309 0 4.118 0 5.53-.19c1.444-.194 2.584-.6 3.479-1.494c.895-.895 1.3-2.035 1.494-3.48c.19-1.411.19-3.22.19-5.529v-.114c0-2.309 0-4.118-.19-5.53c-.194-1.444-.6-2.584-1.494-3.479c-.895-.895-2.035-1.3-3.48-1.494c-1.411-.19-3.22-.19-5.529-.19M3.995 3.995c.57-.57 1.34-.897 2.619-1.069c1.3-.174 3.008-.176 5.386-.176s4.086.002 5.386.176c1.279.172 2.05.5 2.62 1.069c.569.57.896 1.34 1.068 2.619c.174 1.3.176 3.008.176 5.386s-.002 4.086-.176 5.386c-.172 1.279-.5 2.05-1.069 2.62c-.57.569-1.34.896-2.619 1.068c-1.3.174-3.008.176-5.386.176s-4.086-.002-5.386-.176c-1.279-.172-2.05-.5-2.62-1.069c-.569-.57-.896-1.34-1.068-2.619c-.174-1.3-.176-3.008-.176-5.386s.002-4.086.176-5.386c.172-1.279.5-2.05 1.069-2.62"
|