poe-svelte-ui-lib 1.111.0 → 2.0.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/README.md +208 -10
- package/dist/Accordion/Accordion.svelte +14 -25
- package/dist/Accordion/AccordionProps.svelte +50 -129
- package/dist/Accordion/AccordionProps.svelte.d.ts +4 -11
- package/dist/Accordion/README.md +22 -23
- package/dist/Button/Button.svelte +33 -78
- package/dist/Button/ButtonProps.svelte +81 -170
- package/dist/Button/ButtonProps.svelte.d.ts +4 -11
- package/dist/Button/README.md +26 -23
- package/dist/Carousel/Carousel.svelte +2 -2
- package/dist/CommonSnippets.svelte +154 -280
- package/dist/CommonSnippets.svelte.d.ts +3 -8
- package/dist/Divider/Divider.svelte +7 -6
- package/dist/Divider/DividerProps.svelte +37 -81
- package/dist/Divider/DividerProps.svelte.d.ts +4 -11
- package/dist/Divider/README.md +15 -16
- package/dist/Dragging.svelte +0 -1
- package/dist/FieldLabel.svelte +14 -0
- package/dist/FieldLabel.svelte.d.ts +12 -0
- package/dist/FileAttach/FileAttach.svelte +22 -37
- package/dist/FileAttach/FileAttachProps.svelte +23 -99
- package/dist/FileAttach/FileAttachProps.svelte.d.ts +4 -11
- package/dist/FileAttach/README.md +11 -13
- package/dist/GUIRenderer/DeviceTable.svelte +17 -0
- package/dist/GUIRenderer/DeviceTable.svelte.d.ts +10 -0
- package/dist/GUIRenderer/GUIRenderer.svelte +366 -0
- package/dist/GUIRenderer/GUIRenderer.svelte.d.ts +15 -0
- package/dist/Graph/Graph.svelte +123 -170
- package/dist/Graph/Graph.svelte.d.ts +5 -3
- package/dist/Graph/GraphProps.svelte +28 -55
- package/dist/Graph/GraphProps.svelte.d.ts +4 -11
- package/dist/Graph/README.md +26 -25
- package/dist/Graph/testSeries.d.ts +2 -0
- package/dist/Graph/testSeries.js +1 -0
- package/dist/Icon.svelte +18 -0
- package/dist/Icon.svelte.d.ts +8 -0
- package/dist/Input/Input.svelte +103 -155
- package/dist/Input/Input.svelte.d.ts +1 -1
- package/dist/Input/InputProps.svelte +144 -363
- package/dist/Input/InputProps.svelte.d.ts +4 -11
- package/dist/Input/README.md +30 -29
- package/dist/Joystick/Joystick.svelte +42 -128
- package/dist/Joystick/JoystickProps.svelte +43 -100
- package/dist/Joystick/JoystickProps.svelte.d.ts +4 -11
- package/dist/Joystick/README.md +18 -19
- package/dist/Modal.README.md +4 -3
- package/dist/Modal.svelte +34 -7
- package/dist/PeriodChart/PeriodChart.svelte +3 -7
- package/dist/PeriodChart/PeriodChartProps.svelte +35 -112
- package/dist/PeriodChart/PeriodChartProps.svelte.d.ts +4 -11
- package/dist/PeriodChart/README.md +19 -20
- package/dist/ProgressBar/ProgressBar.svelte +8 -15
- package/dist/ProgressBar/ProgressBarProps.svelte +80 -200
- package/dist/ProgressBar/ProgressBarProps.svelte.d.ts +4 -11
- package/dist/ProgressBar/README.md +10 -10
- package/dist/Select/README.md +38 -37
- package/dist/Select/Select.svelte +223 -221
- package/dist/Select/Select.svelte.d.ts +12 -12
- package/dist/Select/SelectProps.svelte +144 -282
- package/dist/Select/SelectProps.svelte.d.ts +4 -11
- package/dist/Slider/README.md +22 -21
- package/dist/Slider/Slider.svelte +80 -164
- package/dist/Slider/Slider.svelte.d.ts +1 -1
- package/dist/Slider/SliderProps.svelte +34 -90
- package/dist/Slider/SliderProps.svelte.d.ts +4 -11
- package/dist/Switch/README.md +28 -31
- package/dist/Switch/Switch.svelte +39 -60
- package/dist/Switch/SwitchProps.svelte +63 -209
- package/dist/Switch/SwitchProps.svelte.d.ts +4 -11
- package/dist/Table/CopyButton.svelte +27 -0
- package/dist/Table/CopyButton.svelte.d.ts +7 -0
- package/dist/Table/README.md +62 -45
- package/dist/Table/Table.svelte +274 -350
- package/dist/Table/Table.svelte.d.ts +29 -4
- package/dist/Table/TableProps.svelte +120 -160
- package/dist/Table/TableProps.svelte.d.ts +4 -11
- package/dist/Table/XPoeDebugModal.svelte +32 -0
- package/dist/Table/XPoeDebugModal.svelte.d.ts +21 -0
- package/dist/Table/xPoeDebugColumns.d.ts +1 -1
- package/dist/Table/xPoeDebugColumns.js +3 -2
- package/dist/Tabs/README.md +25 -26
- package/dist/Tabs/Tabs.svelte +7 -16
- package/dist/Tabs/TabsProps.svelte +105 -216
- package/dist/Tabs/TabsProps.svelte.d.ts +4 -11
- package/dist/TextField/README.md +16 -16
- package/dist/TextField/TextField.svelte +4 -9
- package/dist/TextField/TextFieldProps.svelte +59 -134
- package/dist/TextField/TextFieldProps.svelte.d.ts +4 -11
- package/dist/TextsEditor.svelte +5 -4
- package/dist/TextsEditor.svelte.d.ts +3 -7
- package/dist/VideoViewer/README.md +17 -17
- package/dist/VideoViewer/VideoViewer.svelte +9 -24
- package/dist/VideoViewer/VideoViewerProps.svelte +38 -74
- package/dist/VideoViewer/VideoViewerProps.svelte.d.ts +4 -12
- package/dist/Widget/README.md +28 -31
- package/dist/Widget/Widget.svelte +105 -211
- package/dist/Widget/Widget.svelte.d.ts +1 -1
- package/dist/Widget/WidgetProps.svelte +54 -131
- package/dist/Widget/WidgetProps.svelte.d.ts +4 -12
- package/dist/WidgetDeviceInfo/README.md +7 -7
- package/dist/WidgetDeviceInfo/WidgetDeviceInfo.svelte +29 -33
- package/dist/WidgetDeviceInfo/WidgetDeviceInfoProps.svelte +16 -23
- package/dist/WidgetDeviceInfo/WidgetDeviceInfoProps.svelte.d.ts +4 -9
- package/dist/WidgetFileSystem/README.md +23 -23
- package/dist/WidgetFileSystem/WidgetFileSystem.svelte +9 -14
- package/dist/WidgetFileSystem/WidgetFileSystemProps.svelte +14 -18
- package/dist/WidgetFileSystem/WidgetFileSystemProps.svelte.d.ts +4 -9
- package/dist/WidgetMap/README.md +40 -29
- package/dist/WidgetMap/WidgetMap.svelte +75 -125
- package/dist/WidgetMap/WidgetMap.svelte.d.ts +1 -1
- package/dist/WidgetMap/WidgetMapProps.svelte +20 -27
- package/dist/WidgetMap/WidgetMapProps.svelte.d.ts +4 -9
- package/dist/WidgetMap/mapTheme.svelte.d.ts +6 -0
- package/dist/WidgetMap/mapTheme.svelte.js +31 -0
- package/dist/WidgetMap/mapWrapper/MapLibre.svelte +7 -1
- package/dist/WidgetMap/mapWrapper/MapLibre.svelte.d.ts +1 -1
- package/dist/WidgetMap/mapWrapper/utils.d.ts +15 -0
- package/dist/WidgetMap/mapWrapper/utils.js +36 -19
- package/dist/WidgetMap/mission/MapAgro.svelte +50 -134
- package/dist/WidgetMap/mission/MapAgro.svelte.d.ts +2 -1
- package/dist/WidgetMap/mission/MapRoute.svelte +31 -106
- package/dist/WidgetMap/mission/MapRoute.svelte.d.ts +2 -1
- package/dist/WidgetMap/mission/MissionActions.svelte +69 -0
- package/dist/WidgetMap/mission/MissionActions.svelte.d.ts +10 -0
- package/dist/WidgetMap/mission/MissionLayers.svelte +1 -1
- package/dist/WidgetMap/mission/MissionLayers.svelte.d.ts +1 -1
- package/dist/WidgetMap/mission/MissionSim.svelte +1 -1
- package/dist/WidgetMap/mission/MissionSim.svelte.d.ts +1 -1
- package/dist/WidgetMap/simFleet.d.ts +5 -0
- package/dist/WidgetMap/simFleet.js +66 -0
- package/dist/WidgetPFD/README.md +16 -16
- package/dist/WidgetPFD/WidgetPFD.svelte +15 -10
- package/dist/WidgetPFD/WidgetPFDProps.svelte +11 -16
- package/dist/WidgetPFD/WidgetPFDProps.svelte.d.ts +4 -9
- package/dist/WidgetRGBStrip/ColorPicker.svelte +90 -109
- package/dist/WidgetRGBStrip/ColorPicker.svelte.d.ts +1 -6
- package/dist/WidgetRGBStrip/README.md +22 -22
- package/dist/WidgetRGBStrip/WidgetRGBStrip.svelte +18 -18
- package/dist/WidgetRGBStrip/WidgetRGBStripProps.svelte +9 -13
- package/dist/WidgetRGBStrip/WidgetRGBStripProps.svelte.d.ts +4 -9
- package/dist/WidgetStackInfo/README.md +7 -7
- package/dist/WidgetStackInfo/WidgetStackInfo.svelte +6 -13
- package/dist/WidgetStackInfo/WidgetStackInfoProps.svelte +13 -13
- package/dist/WidgetStackInfo/WidgetStackInfoProps.svelte.d.ts +4 -9
- package/dist/WidgetWiFi/README.md +22 -22
- package/dist/WidgetWiFi/WidgetWiFi.svelte +33 -41
- package/dist/WidgetWiFi/WidgetWiFiProps.svelte +19 -42
- package/dist/WidgetWiFi/WidgetWiFiProps.svelte.d.ts +4 -9
- package/dist/accent.d.ts +13 -0
- package/dist/accent.js +23 -0
- package/dist/clipboard.d.ts +1 -0
- package/dist/clipboard.js +10 -0
- package/dist/constructor.d.ts +35 -0
- package/dist/constructor.js +62 -0
- package/dist/defaults.d.ts +16 -0
- package/dist/defaults.js +123 -0
- package/dist/fsTransfer.d.ts +24 -0
- package/dist/fsTransfer.js +88 -0
- package/dist/gui.d.ts +153 -0
- package/dist/gui.js +221 -0
- package/dist/index.d.ts +10 -27
- package/dist/index.js +9 -26
- package/dist/libIcons/{CopyButton.svelte.d.ts → CopyIcon.svelte.d.ts} +3 -3
- package/dist/locales/constructor.d.ts +1683 -0
- package/dist/locales/constructor.js +497 -0
- package/dist/locales/i18n.d.ts +5 -1
- package/dist/locales/i18n.js +2 -0
- package/dist/locales/translations.d.ts +2262 -2
- package/dist/locales/translations.js +25 -508
- package/dist/migrate.d.ts +3 -0
- package/dist/migrate.js +143 -0
- package/dist/options.d.ts +572 -140
- package/dist/options.js +115 -171
- package/dist/propsEditor.d.ts +28 -0
- package/dist/propsEditor.js +25 -0
- package/dist/protocols/crc.d.ts +1 -0
- package/dist/protocols/crc.js +12 -0
- package/dist/protocols/index.d.ts +2 -2
- package/dist/protocols/index.js +3 -3
- package/dist/protocols/plotGroups.d.ts +1 -1
- package/dist/protocols/plotGroups.js +8 -12
- package/dist/protocols/xPoeDebug.d.ts +3 -1
- package/dist/protocols/xPoeDebug.js +15 -12
- package/dist/protocols/xPoeDebugView.d.ts +2 -5
- package/dist/protocols/xPoeDebugView.js +33 -132
- package/dist/registry.d.ts +13 -0
- package/dist/registry.js +61 -0
- package/dist/ring.d.ts +9 -0
- package/dist/ring.js +35 -0
- package/dist/types.d.ts +97 -164
- package/dist/types.js +1 -27
- package/package.json +5 -1
- package/dist/WidgetAccentPicker.svelte +0 -29
- package/dist/WidgetAccentPicker.svelte.d.ts +0 -8
- package/dist/widgetAccent.d.ts +0 -11
- package/dist/widgetAccent.js +0 -30
- /package/dist/libIcons/{CopyButton.svelte → CopyIcon.svelte} +0 -0
package/dist/Accordion/README.md
CHANGED
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
<details>
|
|
46
46
|
<summary>🎨 Оформление подробно</summary>
|
|
47
47
|
|
|
48
|
-
-
|
|
49
|
-
- Без
|
|
48
|
+
- Цвет `accent` работает как у смарт-виджетов: иконка, текст и стрелка заголовка окрашены цветом текста роли (70% `--accent-text` с цветом шрифта), фон заголовка 22% цвета поверх фона, при наведении 30%.
|
|
49
|
+
- Без `accent` используется акцент родителя или темы. Цвет из `label.class` перекрывает цвет текста.
|
|
50
50
|
- Раскрытое содержимое на чистом фоне `--back-color`, радиус блока 14.
|
|
51
51
|
|
|
52
52
|
</details>
|
|
@@ -54,20 +54,20 @@
|
|
|
54
54
|
<details>
|
|
55
55
|
<summary>⚙️ Пропсы</summary>
|
|
56
56
|
|
|
57
|
-
| Название
|
|
58
|
-
|
|
|
59
|
-
| `id`
|
|
60
|
-
| `isOpen`
|
|
61
|
-
| `wrapperClass`
|
|
62
|
-
| `
|
|
63
|
-
| `size`
|
|
64
|
-
| `label.name`
|
|
65
|
-
| `label.class`
|
|
66
|
-
| `label.icon`
|
|
67
|
-
| `chevron`
|
|
68
|
-
| `image`
|
|
69
|
-
| `children`
|
|
70
|
-
| `actions`
|
|
57
|
+
| Название | Тип | По умолчанию | Описание |
|
|
58
|
+
| -------------- | ----------------------------- | ------------- | ------------------------------------------------------------------------------- |
|
|
59
|
+
| `id` | `string` | | Идентификатор в конструкторе. Компонент его не использует |
|
|
60
|
+
| `isOpen` | `boolean` | `false` | Открыт ли. Можно связать через `bind:isOpen` |
|
|
61
|
+
| `wrapperClass` | `string` | `""` | Классы обёртки |
|
|
62
|
+
| `accent` | `AccentColor` | | Цвет заголовка: `red`, `green`, `blue` и другие. Без него - акцент темы |
|
|
63
|
+
| `size` | `{ width, height }` | `1 × 1` | Сетка содержимого: колонки и строки |
|
|
64
|
+
| `label.name` | `string` | `""` | Заголовок |
|
|
65
|
+
| `label.class` | `string` | `"text-left"` | Классы текста заголовка |
|
|
66
|
+
| `label.icon` | `Component \| string \| null` | `null` | Иконка заголовка: Svelte-компонент или SVG-строка |
|
|
67
|
+
| `chevron` | `boolean` | `true` | Стрелка раскрытия в заголовке. Без неё блок сворачивается нажатием на заголовок |
|
|
68
|
+
| `image` | `string` | `""` | Картинка фона содержимого |
|
|
69
|
+
| `children` | `Snippet` | | Содержимое |
|
|
70
|
+
| `actions` | `Snippet` | | Кнопки справа в заголовке. Нажатие на них не сворачивает блок |
|
|
71
71
|
|
|
72
72
|
Колбэков нет. Открытие и закрытие компонент обрабатывает сам.
|
|
73
73
|
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
let open = $state(false)
|
|
83
83
|
</script>
|
|
84
84
|
|
|
85
|
-
<UI.Accordion label={{ name: "Сеть" }}
|
|
85
|
+
<UI.Accordion label={{ name: "Сеть" }} accent="blue" bind:isOpen={open}>
|
|
86
86
|
<UI.Input label={{ name: "SSID" }} />
|
|
87
87
|
</UI.Accordion>
|
|
88
88
|
|
|
@@ -99,12 +99,11 @@
|
|
|
99
99
|
<details>
|
|
100
100
|
<summary>🛠️ Панель свойств (AccordionProps.svelte)</summary>
|
|
101
101
|
|
|
102
|
-
Панель для конструктора DevCloud. В ней задают доступ (без варианта «только просмотр»), заголовок, его выравнивание, иконку из библиотеки иконок,
|
|
102
|
+
Панель для конструктора DevCloud. В ней задают доступ (без варианта «только просмотр»), заголовок, его выравнивание, иконку из библиотеки иконок, цвет и картинку фона. Картинка загружается файлом PNG, JPEG или WebP и хранится как base64, рядом есть кнопка удаления.
|
|
103
103
|
|
|
104
|
-
| Пропс | Тип
|
|
105
|
-
| ------------------ |
|
|
106
|
-
| `component` | `UIComponent
|
|
107
|
-
| `onPropertyChange` | `(
|
|
108
|
-
| `forConstructor` | `boolean` | `true` - полная панель конструктора, `false` - упрощённая для редактирования |
|
|
104
|
+
| Пропс | Тип | Описание |
|
|
105
|
+
| ------------------ | ---------------------------------- | ----------------------------------------------------- |
|
|
106
|
+
| `component` | `UIComponent<"Accordion">` | Компонент и его свойства |
|
|
107
|
+
| `onPropertyChange` | `(change: PropertyChange) => void` | Сообщает об изменении: свойства, имя, доступ, событие |
|
|
109
108
|
|
|
110
109
|
</details>
|
|
@@ -1,68 +1,38 @@
|
|
|
1
|
-
<!-- $lib/Button/Button.svelte - кнопка:
|
|
1
|
+
<!-- $lib/Button/Button.svelte - кнопка: вид variant, цвет accent, радиус 10px (иконка без подписи - круг), высота 32px, кольцо фокуса -->
|
|
2
2
|
<script lang="ts">
|
|
3
|
-
import { sanitizeHtml } from "../html"
|
|
4
|
-
import { onMount } from "svelte"
|
|
5
3
|
import type { IButtonProps } from "../types"
|
|
6
4
|
import { twMerge } from "tailwind-merge"
|
|
5
|
+
import { accentStyle } from "../accent"
|
|
7
6
|
import Tooltip from "../Tooltip.svelte"
|
|
7
|
+
import Icon from "../Icon.svelte"
|
|
8
8
|
|
|
9
9
|
let {
|
|
10
|
-
id
|
|
10
|
+
id,
|
|
11
11
|
wrapperClass = "",
|
|
12
12
|
componentClass = "",
|
|
13
|
+
variant = "plain",
|
|
14
|
+
accent,
|
|
13
15
|
disabled = false,
|
|
14
|
-
content = {
|
|
15
|
-
name: "",
|
|
16
|
-
info: { text: "", side: "top" },
|
|
17
|
-
icon: null,
|
|
18
|
-
},
|
|
16
|
+
content = { name: "", info: { text: "", side: "top" }, icon: null },
|
|
19
17
|
keyBind = { showHint: true },
|
|
20
18
|
onClick,
|
|
21
19
|
}: IButtonProps = $props()
|
|
22
20
|
|
|
23
21
|
let showInfo = $state(false)
|
|
24
|
-
|
|
25
|
-
/* ─── Роль кнопки по последнему классу bg-* ───────────────────────── bg-blue / bg-green / bg-cyan / bg-purple / bg-orange / bg-yellow → primary (заливка + белый текст) bg-red → destructive bg-max / bg-gray / bg-*-soft → secondary (поверхность + контур) bg-transparent / без bg-* → plain (текст акцентом) */
|
|
26
|
-
const SURFACE_BG = ["bg-max", "bg-gray"]
|
|
27
|
-
const DANGER_BG = ["bg-red"]
|
|
28
|
-
|
|
29
|
-
const role = $derived.by(() => {
|
|
30
|
-
const bg =
|
|
31
|
-
componentClass
|
|
32
|
-
.split(/\s+/)
|
|
33
|
-
.filter((c) => c.startsWith("bg-"))
|
|
34
|
-
.at(-1) ?? ""
|
|
35
|
-
if (!bg || bg === "bg-transparent") return "plain"
|
|
36
|
-
if (SURFACE_BG.includes(bg) || bg.endsWith("-soft")) return "secondary"
|
|
37
|
-
if (DANGER_BG.includes(bg)) return "destructive"
|
|
38
|
-
return "primary"
|
|
39
|
-
})
|
|
40
|
-
|
|
41
22
|
const isIconOnly = $derived(!!content?.icon && !content.name?.trim())
|
|
42
23
|
|
|
43
|
-
/*
|
|
44
|
-
const
|
|
45
|
-
if (disabled) return "bg-(--gray-color)"
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const roleClass = $derived.by(() => {
|
|
51
|
-
if (disabled) return "text-(--muted-color) border border-transparent cursor-not-allowed"
|
|
52
|
-
switch (role) {
|
|
53
|
-
case "primary":
|
|
54
|
-
case "destructive":
|
|
55
|
-
return "text-(--on-accent) border border-transparent shadow-(--elevation-1) hover:brightness-90 dark:hover:brightness-115"
|
|
56
|
-
case "secondary":
|
|
57
|
-
return "text-(--font-color) border border-(--border-color) hover:bg-(--container-color)"
|
|
58
|
-
default:
|
|
59
|
-
return "text-(--accent-text) border border-transparent hover:bg-(--accent-soft)"
|
|
60
|
-
}
|
|
24
|
+
/* primary - заливка цветом роли, secondary - поверхность с контуром, plain - текст цветом роли */
|
|
25
|
+
const variantClass = $derived.by(() => {
|
|
26
|
+
if (disabled) return "bg-(--gray-color) text-(--muted-color) border border-transparent cursor-not-allowed"
|
|
27
|
+
if (variant === "primary")
|
|
28
|
+
return "bg-(--accent-color) text-(--on-accent) border border-transparent shadow-(--elevation-1) hover:brightness-90 dark:hover:brightness-115"
|
|
29
|
+
if (variant === "secondary") return "bg-(--back-color) text-(--font-color) border border-(--border-color) hover:bg-(--container-color)"
|
|
30
|
+
return "bg-transparent text-(--accent-text) border border-transparent hover:bg-(--accent-soft)"
|
|
61
31
|
})
|
|
62
32
|
|
|
63
33
|
const handleClick = (event: Event) => {
|
|
64
34
|
if (disabled || !onClick) return
|
|
65
|
-
event
|
|
35
|
+
event.stopPropagation()
|
|
66
36
|
onClick()
|
|
67
37
|
}
|
|
68
38
|
|
|
@@ -78,51 +48,36 @@
|
|
|
78
48
|
onClick()
|
|
79
49
|
}
|
|
80
50
|
}
|
|
81
|
-
|
|
82
|
-
onMount(() => {
|
|
83
|
-
if (keyBind) window.addEventListener("keydown", handleKeyDown)
|
|
84
|
-
return () => {
|
|
85
|
-
if (keyBind) window.removeEventListener("keydown", handleKeyDown)
|
|
86
|
-
}
|
|
87
|
-
})
|
|
88
51
|
</script>
|
|
89
52
|
|
|
90
|
-
<
|
|
53
|
+
<svelte:window onkeydown={handleKeyDown} />
|
|
54
|
+
|
|
55
|
+
<div class={twMerge(`relative flex w-full flex-col items-center`, wrapperClass)} style={accentStyle(accent)}>
|
|
91
56
|
<button
|
|
92
57
|
{id}
|
|
93
|
-
class={
|
|
58
|
+
class={twMerge(
|
|
94
59
|
`relative inline-flex w-full items-center justify-center gap-2 leading-none font-semibold text-[14px] select-none
|
|
95
60
|
transition-[background-color,filter,box-shadow] duration-150
|
|
96
61
|
focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--accent-text)
|
|
97
62
|
${isIconOnly ? "aspect-square rounded-full p-0" : "h-8 rounded-[10px] px-4 py-2"}
|
|
98
63
|
${disabled ? "" : "cursor-pointer active:scale-[0.97]"}`,
|
|
99
|
-
|
|
64
|
+
variantClass,
|
|
100
65
|
componentClass,
|
|
101
|
-
)}
|
|
102
|
-
onclick={
|
|
66
|
+
)}
|
|
67
|
+
onclick={handleClick}
|
|
103
68
|
{disabled}
|
|
104
|
-
aria-label={content.name || undefined}
|
|
105
|
-
onmouseenter={() =>
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (content.info?.text) showInfo = false
|
|
110
|
-
}}
|
|
69
|
+
aria-label={content.name || content.info?.text || undefined}
|
|
70
|
+
onmouseenter={() => (showInfo = !!content.info?.text)}
|
|
71
|
+
onmouseleave={() => (showInfo = false)}
|
|
72
|
+
onfocus={() => (showInfo = !!content.info?.text)}
|
|
73
|
+
onblur={() => (showInfo = false)}
|
|
111
74
|
>
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
{#if typeof content?.icon === "string"}
|
|
119
|
-
{@html sanitizeHtml(content.icon)}
|
|
120
|
-
{:else}
|
|
121
|
-
{@const IconComponent = content?.icon}
|
|
122
|
-
<IconComponent />
|
|
123
|
-
{/if}
|
|
124
|
-
</span>
|
|
125
|
-
{/if}
|
|
75
|
+
<Icon
|
|
76
|
+
icon={content?.icon}
|
|
77
|
+
class="flex shrink-0 items-center justify-center overflow-visible {content.name?.trim()
|
|
78
|
+
? 'h-[18px] w-[18px]'
|
|
79
|
+
: 'h-full w-full'} [&_svg]:h-full [&_svg]:max-h-full [&_svg]:w-full [&_svg]:max-w-full"
|
|
80
|
+
/>
|
|
126
81
|
|
|
127
82
|
{#if content.name?.trim()}
|
|
128
83
|
<span class="truncate">{content.name}</span>
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
<!-- $lib/Button/ButtonProps.svelte - панель свойств конструктора для Button -->
|
|
1
2
|
<script lang="ts">
|
|
2
3
|
import TextsEditor from "../TextsEditor.svelte"
|
|
3
4
|
import { localizeText } from "../locales/localize"
|
|
4
5
|
import { DEFAULT_LANGUAGE } from "../locales/languages"
|
|
5
6
|
import { T } from "../locales/i18n"
|
|
6
|
-
import {
|
|
7
|
+
import type { UIComponent, IButtonProps } from "../types"
|
|
8
|
+
import { createPropsEditor, optionByClass, type PropertyChange } from "../propsEditor"
|
|
7
9
|
import * as UI from ".."
|
|
8
|
-
import {
|
|
10
|
+
import { ACCENT_OPTIONS, optionsStore } from "../options"
|
|
9
11
|
import { twMerge } from "tailwind-merge"
|
|
10
12
|
import { ICONS } from "../icons"
|
|
11
13
|
import CommonSnippets from "../CommonSnippets.svelte"
|
|
@@ -15,190 +17,99 @@
|
|
|
15
17
|
const {
|
|
16
18
|
component,
|
|
17
19
|
onPropertyChange,
|
|
18
|
-
forConstructor = true,
|
|
19
20
|
}: {
|
|
20
|
-
component: UIComponent
|
|
21
|
-
onPropertyChange: (
|
|
22
|
-
forConstructor?: boolean
|
|
21
|
+
component: UIComponent<"Button">
|
|
22
|
+
onPropertyChange: (change: PropertyChange<IButtonProps>) => void
|
|
23
23
|
} = $props()
|
|
24
24
|
|
|
25
|
+
const edit = $derived(createPropsEditor(component, onPropertyChange))
|
|
26
|
+
const properties = $derived(component.properties)
|
|
27
|
+
const hasName = $derived(!!localizeText(properties.content?.name, DEFAULT_LANGUAGE).trim())
|
|
28
|
+
|
|
25
29
|
/* Argument пуст - поле ниже лишь визуально показывает "ModCfg", реальное значение нужно проставить в состояние */
|
|
26
30
|
$effect(() => {
|
|
27
31
|
if (!component.eventHandler?.Argument) onPropertyChange({ eventHandler: { Argument: "ModCfg" } })
|
|
28
32
|
})
|
|
29
33
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
/* Один выбор цвета: "-" - secondary, цвет - primary этого цвета, повторное нажатие на выбранный - plain (без фона) */
|
|
35
|
+
const colorValue = $derived(properties.variant === "primary" ? (properties.accent ?? "blue") : properties.variant === "secondary" ? "" : undefined)
|
|
36
|
+
const setColor = (accent: (typeof ACCENT_OPTIONS)[number]["value"]) =>
|
|
37
|
+
onPropertyChange({
|
|
38
|
+
properties:
|
|
39
|
+
accent === colorValue
|
|
40
|
+
? { variant: "plain", accent: undefined }
|
|
41
|
+
: accent
|
|
42
|
+
? { variant: "primary", accent: accent === "blue" ? undefined : accent }
|
|
43
|
+
: { variant: "secondary", accent: undefined },
|
|
44
|
+
})
|
|
37
45
|
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
)
|
|
47
|
-
updateProperty("componentClass", twMerge((component.properties as UI.IButtonProps).componentClass, "w-full px-1 py-1"), component, onPropertyChange)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const updateButtonColor = (option: UI.IOption<string>) => {
|
|
51
|
-
if (initialColor?.value === option.value)
|
|
52
|
-
updateProperty("componentClass", twMerge(component.properties.componentClass, "bg-transparent"), component, onPropertyChange)
|
|
53
|
-
else
|
|
54
|
-
updateProperty(
|
|
55
|
-
"componentClass",
|
|
56
|
-
twMerge((component.properties as UI.IButtonProps).componentClass, (option as UI.IOption<string>).value),
|
|
57
|
-
component,
|
|
58
|
-
onPropertyChange,
|
|
59
|
-
)
|
|
60
|
-
}
|
|
46
|
+
/* Иконка без подписи - круглая кнопка по размеру иконки */
|
|
47
|
+
const setIcon = (icon: string) =>
|
|
48
|
+
onPropertyChange({
|
|
49
|
+
properties: {
|
|
50
|
+
content: { ...properties.content, icon },
|
|
51
|
+
...(icon || !hasName ? { componentClass: twMerge(properties.componentClass, icon && !hasName ? "w-fit p-2" : "w-full px-1 py-1") } : {}),
|
|
52
|
+
},
|
|
53
|
+
})
|
|
61
54
|
</script>
|
|
62
55
|
|
|
63
|
-
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
type="buttons"
|
|
67
|
-
value={Header}
|
|
68
|
-
options={$optionsStore.HEADER_OPTIONS}
|
|
69
|
-
onUpdate={(option) => onPropertyChange({ eventHandler: { Header: (option as IOption<string>).value as string } })}
|
|
70
|
-
/>
|
|
71
|
-
<UI.Input
|
|
72
|
-
label={{ name: $T("constructor.props.argument") }}
|
|
73
|
-
value={component.eventHandler?.Argument || "ModCfg"}
|
|
74
|
-
maxlength={32}
|
|
75
|
-
help={{ info: $T("constructor.props.argument.info"), autocomplete: "on", regExp: /^[a-zA-Z0-9\-_]{0,32}$/ }}
|
|
76
|
-
onUpdate={(value) => onPropertyChange({ eventHandler: { Argument: value as string } })}
|
|
77
|
-
/>
|
|
78
|
-
{/snippet}
|
|
79
|
-
|
|
80
|
-
{#snippet ButtonVariables()}
|
|
81
|
-
{#if component.eventHandler?.Argument !== "ModCfg" || Header.value === "SET"}
|
|
82
|
-
<UI.Input
|
|
83
|
-
label={{ name: $T("constructor.props.value") }}
|
|
84
|
-
value={component.eventHandler?.Value}
|
|
85
|
-
help={{ info: $T("constructor.props.value.info") }}
|
|
86
|
-
maxlength={500}
|
|
87
|
-
onUpdate={(value) => onPropertyChange({ eventHandler: { Value: value as string } })}
|
|
88
|
-
/>
|
|
89
|
-
{/if}
|
|
90
|
-
<UI.Input
|
|
91
|
-
label={{ name: $T("constructor.props.variables") }}
|
|
92
|
-
disabled={hasValue}
|
|
93
|
-
value={component.eventHandler?.Variables?.join(" ")}
|
|
94
|
-
help={{ info: $T("constructor.props.variables.info"), autocomplete: "on", regExp: /^[a-zA-Z0-9.\-_ ":{}]{0,500}$/ }}
|
|
95
|
-
maxlength={500}
|
|
96
|
-
onUpdate={(value) => onPropertyChange({ eventHandler: { Variables: (value as string).trim().split(/\s+/) } })}
|
|
97
|
-
/>
|
|
98
|
-
{/snippet}
|
|
99
|
-
|
|
100
|
-
{#snippet ButtonName()}
|
|
101
|
-
<TextsEditor {component} {onPropertyChange} />
|
|
102
|
-
{/snippet}
|
|
103
|
-
|
|
104
|
-
{#snippet ButtonHeight()}
|
|
105
|
-
{#if !(!localizeText(component.properties.content?.name, DEFAULT_LANGUAGE).trim() && component.properties.content?.icon)}
|
|
56
|
+
<div class="flex flex-col gap-2">
|
|
57
|
+
<PropsGroup label={$T("constructor.props.group.general")}>
|
|
58
|
+
<CommonSnippets snippet="Access" {component} {onPropertyChange} />
|
|
106
59
|
<UI.Select
|
|
107
|
-
label={{ name: $T("constructor.props.
|
|
60
|
+
label={{ name: $T("constructor.props.header") }}
|
|
108
61
|
type="buttons"
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
onUpdate={(
|
|
112
|
-
updateProperty("componentClass", twMerge(component.properties.componentClass, (option as IOption<string>).value), component, onPropertyChange)}
|
|
62
|
+
value={component.eventHandler?.Header}
|
|
63
|
+
options={$optionsStore.HEADER_OPTIONS}
|
|
64
|
+
onUpdate={(Header) => onPropertyChange({ eventHandler: { Header } })}
|
|
113
65
|
/>
|
|
114
|
-
|
|
115
|
-
{
|
|
116
|
-
|
|
117
|
-
{
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
{
|
|
126
|
-
|
|
127
|
-
{
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
{
|
|
134
|
-
|
|
135
|
-
{
|
|
136
|
-
|
|
137
|
-
|
|
66
|
+
<UI.Input
|
|
67
|
+
label={{ name: $T("constructor.props.argument") }}
|
|
68
|
+
value={component.eventHandler?.Argument || "ModCfg"}
|
|
69
|
+
maxlength={32}
|
|
70
|
+
help={{ info: $T("constructor.props.argument.info"), autocomplete: "on", regExp: /^[a-zA-Z0-9\-_]{0,32}$/ }}
|
|
71
|
+
onUpdate={(value) => onPropertyChange({ eventHandler: { Argument: String(value) } })}
|
|
72
|
+
/>
|
|
73
|
+
</PropsGroup>
|
|
74
|
+
<PropsGroup label={$T("constructor.props.group.value")}>
|
|
75
|
+
{#if component.eventHandler?.Argument !== "ModCfg" || component.eventHandler?.Header === "SET"}
|
|
76
|
+
<UI.Input
|
|
77
|
+
label={{ name: $T("constructor.props.value") }}
|
|
78
|
+
value={component.eventHandler?.Value}
|
|
79
|
+
help={{ info: $T("constructor.props.value.info") }}
|
|
80
|
+
maxlength={500}
|
|
81
|
+
onUpdate={(value) => onPropertyChange({ eventHandler: { Value: String(value) } })}
|
|
82
|
+
/>
|
|
83
|
+
{/if}
|
|
84
|
+
<UI.Input
|
|
85
|
+
label={{ name: $T("constructor.props.variables") }}
|
|
86
|
+
disabled={!!component.eventHandler?.Value}
|
|
87
|
+
value={component.eventHandler?.Variables?.join(" ")}
|
|
88
|
+
help={{ info: $T("constructor.props.variables.info"), autocomplete: "on", regExp: /^[a-zA-Z0-9.\-_ ":{}]{0,500}$/ }}
|
|
89
|
+
maxlength={500}
|
|
90
|
+
onUpdate={(value) => onPropertyChange({ eventHandler: { Variables: String(value).trim().split(/\s+/) } })}
|
|
91
|
+
/>
|
|
92
|
+
<div class="flex items-end gap-2">
|
|
93
|
+
<UI.Button wrapperClass="w-8" content={{ icon: InfoIcon, info: { text: $T("constructor.props.button.colors.hint"), side: "right" } }} />
|
|
94
|
+
<UI.Select label={{ name: $T("constructor.props.colors") }} type="buttons" options={ACCENT_OPTIONS} value={colorValue} onUpdate={setColor} />
|
|
95
|
+
</div>
|
|
96
|
+
</PropsGroup>
|
|
97
|
+
<PropsGroup label={$T("constructor.props.group.appearance")}>
|
|
98
|
+
<TextsEditor {component} {onPropertyChange} />
|
|
138
99
|
<CommonSnippets
|
|
139
|
-
snippet="
|
|
140
|
-
initialValue={{
|
|
141
|
-
color: initialColor,
|
|
142
|
-
updateProperty: (option: UI.IOption<string>) => updateButtonColor(option),
|
|
143
|
-
}}
|
|
100
|
+
snippet="IconsLib"
|
|
101
|
+
initialValue={{ name: $T("constructor.props.buttonIcon"), icon: properties.content?.icon, onUpdate: setIcon, icons: { array: ICONS } }}
|
|
144
102
|
{component}
|
|
145
103
|
{onPropertyChange}
|
|
146
104
|
/>
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
{@render ButtonHeaderArgument()}
|
|
155
|
-
</PropsGroup>
|
|
156
|
-
<PropsGroup label={$T("constructor.props.group.value")}>
|
|
157
|
-
{@render ButtonVariables()}
|
|
158
|
-
{@render ButtonColors()}
|
|
159
|
-
</PropsGroup>
|
|
160
|
-
<PropsGroup label={$T("constructor.props.group.appearance")}>
|
|
161
|
-
{@render ButtonName()}
|
|
162
|
-
<CommonSnippets
|
|
163
|
-
snippet="IconsLib"
|
|
164
|
-
initialValue={{
|
|
165
|
-
name: $T("constructor.props.buttonIcon"),
|
|
166
|
-
icon: component.properties.content?.icon,
|
|
167
|
-
updateProperty: (icon: string) => updateIconProperty("content.icon", icon as string),
|
|
168
|
-
icons: { array: ICONS },
|
|
169
|
-
}}
|
|
170
|
-
{component}
|
|
171
|
-
{onPropertyChange}
|
|
172
|
-
/>
|
|
173
|
-
{@render ButtonHeight()}
|
|
174
|
-
</PropsGroup>
|
|
175
|
-
</div>
|
|
176
|
-
{:else}
|
|
177
|
-
<div class="flex flex-col gap-2">
|
|
178
|
-
<PropsGroup label={$T("constructor.props.group.general")}>
|
|
179
|
-
<CommonSnippets snippet="Identificator" {component} {onPropertyChange} />
|
|
180
|
-
<CommonSnippets snippet="Access" {component} {onPropertyChange} />
|
|
181
|
-
<CommonSnippets snippet="WrapperClass" {component} {onPropertyChange} />
|
|
182
|
-
<CommonSnippets snippet="Disabled" {component} {onPropertyChange} />
|
|
183
|
-
</PropsGroup>
|
|
184
|
-
<PropsGroup label={$T("constructor.props.group.content")}>
|
|
185
|
-
{@render ButtonName()}
|
|
186
|
-
{@render ButtonInfoSide()}
|
|
187
|
-
</PropsGroup>
|
|
188
|
-
<PropsGroup label={$T("constructor.props.group.appearance")}>
|
|
189
|
-
{@render ButtonComponentClass()}
|
|
190
|
-
{@render ButtonColors()}
|
|
191
|
-
<CommonSnippets
|
|
192
|
-
snippet="IconsLib"
|
|
193
|
-
initialValue={{
|
|
194
|
-
name: $T("constructor.props.buttonIcon"),
|
|
195
|
-
icon: component.properties.content?.icon,
|
|
196
|
-
updateProperty: (icon: string) => updateIconProperty("content.icon", icon as string),
|
|
197
|
-
icons: { array: ICONS },
|
|
198
|
-
}}
|
|
199
|
-
{component}
|
|
200
|
-
{onPropertyChange}
|
|
105
|
+
{#if hasName || !properties.content?.icon}
|
|
106
|
+
<UI.Select
|
|
107
|
+
label={{ name: $T("constructor.props.height") }}
|
|
108
|
+
type="buttons"
|
|
109
|
+
options={$optionsStore.HEIGHT_OPTIONS}
|
|
110
|
+
value={optionByClass($optionsStore.HEIGHT_OPTIONS, properties.componentClass)?.value}
|
|
111
|
+
onUpdate={(height) => edit.set("componentClass", twMerge(properties.componentClass, height))}
|
|
201
112
|
/>
|
|
202
|
-
|
|
203
|
-
</
|
|
204
|
-
|
|
113
|
+
{/if}
|
|
114
|
+
</PropsGroup>
|
|
115
|
+
</div>
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { UIComponent, IButtonProps } from "../types";
|
|
2
|
+
import { type PropertyChange } from "../propsEditor";
|
|
2
3
|
type $$ComponentProps = {
|
|
3
|
-
component: UIComponent
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
onPropertyChange: (updates: Partial<{
|
|
7
|
-
properties?: string | object;
|
|
8
|
-
name?: string;
|
|
9
|
-
access?: string;
|
|
10
|
-
eventHandler?: IUIComponentHandler;
|
|
11
|
-
}>) => void;
|
|
12
|
-
forConstructor?: boolean;
|
|
4
|
+
component: UIComponent<"Button">;
|
|
5
|
+
onPropertyChange: (change: PropertyChange<IButtonProps>) => void;
|
|
13
6
|
};
|
|
14
7
|
declare const ButtonProps: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
15
8
|
type ButtonProps = ReturnType<typeof ButtonProps>;
|