poe-svelte-ui-lib 1.9.21 → 1.9.23
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/AccordionProps.svelte +7 -7
- package/dist/Accordion/README.md +1 -1
- package/dist/Button/ButtonProps.svelte +17 -17
- package/dist/Button/README.md +1 -1
- package/dist/ColorPicker/ColorPickerProps.svelte +2 -2
- package/dist/ColorPicker/README.md +1 -1
- package/dist/CommonSnippets.svelte +31 -16
- package/dist/CommonSnippets.svelte.d.ts +1 -1
- package/dist/ComponentExample.svelte +5 -5
- package/dist/FileAttach/FileAttach.svelte +3 -3
- package/dist/FileAttach/FileAttachProps.svelte +8 -8
- package/dist/FileAttach/README.md +1 -1
- package/dist/Graph/GraphProps.svelte +2 -2
- package/dist/Graph/README.md +1 -1
- package/dist/Input/InputProps.svelte +36 -28
- package/dist/Joystick/JoystickProps.svelte +6 -6
- package/dist/Joystick/README.md +1 -1
- package/dist/Map/Map.svelte +2 -2
- package/dist/Map/MapProps.svelte +3 -3
- package/dist/Map/README.md +1 -1
- package/dist/Map/mapWrapper/MapLibre.svelte +2 -2
- package/dist/ModalStackStore.d.ts +0 -2
- package/dist/ModalStackStore.js +1 -9
- package/dist/ProgressBar/ProgressBarProps.svelte +8 -8
- package/dist/ProgressBar/README.md +1 -1
- package/dist/Select/README.md +1 -1
- package/dist/Select/Select.svelte +2 -2
- package/dist/Select/SelectProps.svelte +15 -14
- package/dist/Slider/README.md +1 -1
- package/dist/Slider/SliderProps.svelte +3 -3
- package/dist/Switch/README.md +1 -1
- package/dist/Switch/SwitchProps.svelte +13 -13
- package/dist/Table/README.md +1 -1
- package/dist/Table/Table.svelte +6 -6
- package/dist/Table/TableProps.svelte +33 -33
- package/dist/Tabs/README.md +1 -1
- package/dist/Tabs/TabsProps.svelte +11 -11
- package/dist/TextField/README.md +1 -1
- package/dist/TextField/TextField.svelte +1 -1
- package/dist/TextField/TextFieldProps.svelte +6 -6
- package/dist/VideoViewer/VideoViewer.svelte +147 -0
- package/dist/VideoViewer/VideoViewer.svelte.d.ts +4 -0
- package/dist/Widget/README.md +1 -1
- package/dist/Widget/WidgetProps.svelte +10 -10
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -0
- package/dist/libIcons/Error.svelte +8 -0
- package/dist/libIcons/Error.svelte.d.ts +18 -0
- package/dist/locales/i18n.d.ts +1 -1
- package/dist/locales/i18n.js +1 -1
- package/dist/locales/translations.js +5 -0
- package/dist/options.js +161 -161
- package/dist/types.d.ts +8 -2
- package/package.json +9 -9
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Button from "../Button/Button.svelte"
|
|
3
|
+
import Error from "../libIcons/Error.svelte"
|
|
4
|
+
import { T } from "../locales/i18n"
|
|
5
|
+
import type { IVideoViewerProps } from "../types"
|
|
6
|
+
import { onMount } from "svelte"
|
|
7
|
+
|
|
8
|
+
let { id = crypto.randomUUID(), stream = $bindable(), onstream, ondevicechange }: IVideoViewerProps = $props()
|
|
9
|
+
|
|
10
|
+
let videoElement = $state<HTMLVideoElement | null>(null)
|
|
11
|
+
// let stream = $state<MediaStream | null>(null)
|
|
12
|
+
let error = $state<string | null>(null)
|
|
13
|
+
let isStreaming = $state(false)
|
|
14
|
+
// let source = $state<MediaDeviceInfo[]>([])
|
|
15
|
+
let loading = $state(false)
|
|
16
|
+
|
|
17
|
+
// const getDevices = async (): Promise<(MediaDeviceInfo)[]> => {
|
|
18
|
+
// try {
|
|
19
|
+
// const deviceList = await navigator.mediaDevices.enumerateDevices()
|
|
20
|
+
// source = deviceList.filter((d) => d.kind === "videoinput")
|
|
21
|
+
// ondevicechange?.(source)
|
|
22
|
+
// return source
|
|
23
|
+
// } catch (e) {
|
|
24
|
+
// console.error("Failed to enumerate source:", e)
|
|
25
|
+
// return []
|
|
26
|
+
// }
|
|
27
|
+
// }
|
|
28
|
+
|
|
29
|
+
const startStream = async () => {
|
|
30
|
+
loading = true
|
|
31
|
+
error = null
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
if (stream) stopStream()
|
|
35
|
+
|
|
36
|
+
if (videoElement) {
|
|
37
|
+
videoElement.srcObject = stream as MediaStream
|
|
38
|
+
await videoElement.play()
|
|
39
|
+
isStreaming = true
|
|
40
|
+
onstream?.(stream as MediaStream)
|
|
41
|
+
}
|
|
42
|
+
} catch (e: unknown) {
|
|
43
|
+
const errorMessage = e instanceof Error ? e.message : $T("constructor.props.video.viewer.no.access")
|
|
44
|
+
error = errorMessage
|
|
45
|
+
console.error("Camera error:", e)
|
|
46
|
+
} finally {
|
|
47
|
+
loading = false
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const stopStream = () => {
|
|
52
|
+
if (stream) {
|
|
53
|
+
stream.getTracks().forEach((track) => track.stop())
|
|
54
|
+
stream = null
|
|
55
|
+
}
|
|
56
|
+
if (videoElement) {
|
|
57
|
+
videoElement.srcObject = null
|
|
58
|
+
}
|
|
59
|
+
isStreaming = false
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// const captureScreenshot = (): string | null => {
|
|
63
|
+
// if (!videoElement || !isStreaming) return null
|
|
64
|
+
|
|
65
|
+
// const canvas = document.createElement("canvas")
|
|
66
|
+
// canvas.width = videoElement.videoWidth
|
|
67
|
+
// canvas.height = videoElement.videoHeight
|
|
68
|
+
|
|
69
|
+
// const context = canvas.getContext("2d")
|
|
70
|
+
// if (!context) return null
|
|
71
|
+
|
|
72
|
+
// context.drawImage(videoElement, 0, 0)
|
|
73
|
+
// return canvas.toDataURL("image/png")
|
|
74
|
+
// }
|
|
75
|
+
|
|
76
|
+
// const downloadScreenshot = (filename: string = "screenshot.png") => {
|
|
77
|
+
// const dataUrl = captureScreenshot()
|
|
78
|
+
// if (!dataUrl) return
|
|
79
|
+
|
|
80
|
+
// const link = document.createElement("a")
|
|
81
|
+
// link.href = dataUrl
|
|
82
|
+
// link.download = filename
|
|
83
|
+
// link.click()
|
|
84
|
+
// }
|
|
85
|
+
|
|
86
|
+
const handlePermission = async () => {
|
|
87
|
+
try {
|
|
88
|
+
const permission = await navigator.permissions.query({ name: "camera" as PermissionName })
|
|
89
|
+
if (permission.state === "granted") {
|
|
90
|
+
// await getDevices()
|
|
91
|
+
|
|
92
|
+
await startStream()
|
|
93
|
+
} else if (permission.state === "prompt") {
|
|
94
|
+
// await getDevices()
|
|
95
|
+
await startStream()
|
|
96
|
+
} else {
|
|
97
|
+
error = $T("constructor.props.video.viewer.no.permission")
|
|
98
|
+
}
|
|
99
|
+
} catch {
|
|
100
|
+
// await getDevices()
|
|
101
|
+
await startStream()
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
$effect(() => {
|
|
106
|
+
if (typeof window !== "undefined" && "mediaDevices" in navigator) {
|
|
107
|
+
handlePermission()
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return () => {
|
|
111
|
+
stopStream()
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
onMount(() => {
|
|
116
|
+
if (videoElement) {
|
|
117
|
+
videoElement.addEventListener("loadedmetadata", () => {
|
|
118
|
+
if (!videoElement!.paused) {
|
|
119
|
+
videoElement!.play().catch(console.error)
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
</script>
|
|
125
|
+
|
|
126
|
+
<div
|
|
127
|
+
id={`${id}-${crypto.randomUUID().slice(0, 6)}`}
|
|
128
|
+
class="relative h-full bg-(--border-color)/50 rounded-xl shadow-sm transition duration-200 hover:shadow-md"
|
|
129
|
+
>
|
|
130
|
+
{#if loading}
|
|
131
|
+
<div class="h-full w-full flex items-center justify-center rounded-xl bg-(--border-color)/50 z-10">
|
|
132
|
+
<h2>{$T("constructor.props.video.viewer.loading")}</h2>
|
|
133
|
+
</div>
|
|
134
|
+
{/if}
|
|
135
|
+
|
|
136
|
+
{#if error}
|
|
137
|
+
<div class="h-full w-full flex flex-col items-center justify-center rounded-xl bg-(--border-color)/50 gap-4 z-10">
|
|
138
|
+
<div class="flex flex-col items-center justify-center gap-4 text-red-500">
|
|
139
|
+
<Error />
|
|
140
|
+
<h4>{error}</h4>
|
|
141
|
+
</div>
|
|
142
|
+
<Button wrapperClass="w-fit" content={{ name: $T("library.retry") }} componentClass="bg-blue px-5" onClick={handlePermission} />
|
|
143
|
+
</div>
|
|
144
|
+
{/if}
|
|
145
|
+
|
|
146
|
+
<video bind:this={videoElement} class="w-full h-full block {!isStreaming || loading ? 'hidden' : 'visible'}"></video>
|
|
147
|
+
</div>
|
package/dist/Widget/README.md
CHANGED
|
@@ -173,7 +173,7 @@
|
|
|
173
173
|
- Поддерживает настройку типа управления (ввод, слайдер, переключатель)
|
|
174
174
|
- Включает настройки числового диапазона и иконок
|
|
175
175
|
- Имеет различные наборы полей в зависимости от режима (`forConstructor`)
|
|
176
|
-
- Использует систему локализации через `$
|
|
176
|
+
- Использует систему локализации через `$T('constructor.props.*')`
|
|
177
177
|
|
|
178
178
|
## Заметки
|
|
179
179
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { T } from "../locales/i18n"
|
|
3
3
|
import { updateProperty, type IUIComponentHandler, type UIComponent } from "../types"
|
|
4
4
|
import * as UI from ".."
|
|
5
5
|
import { optionsStore } from "../options"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
|
|
31
31
|
{#snippet WidgetSettingsLabel()}
|
|
32
32
|
<UI.Input
|
|
33
|
-
label={{ name: $
|
|
33
|
+
label={{ name: $T("constructor.props.settings.label") }}
|
|
34
34
|
value={component.properties.settings.label as string}
|
|
35
35
|
onUpdate={(value) => updateProperty("settings.label", value, component, onPropertyChange)}
|
|
36
36
|
/>
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
{#snippet WidgetSettingsColor()}
|
|
40
40
|
<UI.Select
|
|
41
41
|
wrapperClass="!h-14"
|
|
42
|
-
label={{ name: $
|
|
42
|
+
label={{ name: $T("constructor.props.componentcolor") }}
|
|
43
43
|
type="buttons"
|
|
44
44
|
options={$optionsStore.COLOR_OPTIONS}
|
|
45
45
|
value={initialColor}
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
{#snippet WidgetIconColor()}
|
|
53
53
|
<UI.Select
|
|
54
54
|
wrapperClass="!h-14"
|
|
55
|
-
label={{ name: $
|
|
55
|
+
label={{ name: $T("constructor.props.iconcolor") }}
|
|
56
56
|
type="buttons"
|
|
57
57
|
options={$optionsStore.TEXT_COLOR_OPTIONS}
|
|
58
58
|
value={$optionsStore.TEXT_COLOR_OPTIONS.find((c) =>
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
|
|
67
67
|
{#snippet WidgetType()}
|
|
68
68
|
<UI.Select
|
|
69
|
-
label={{ name: $
|
|
69
|
+
label={{ name: $T("constructor.props.settings.type") }}
|
|
70
70
|
type="buttons"
|
|
71
71
|
options={$optionsStore.WIDGET_TYPE_OPTIONS}
|
|
72
72
|
value={$optionsStore.WIDGET_TYPE_OPTIONS.find((o) => o.value == component.properties.settings.type)}
|
|
@@ -78,12 +78,12 @@
|
|
|
78
78
|
|
|
79
79
|
{#snippet WidgetSwitchCaptions()}
|
|
80
80
|
<UI.Input
|
|
81
|
-
label={{ name: $
|
|
81
|
+
label={{ name: $T("constructor.props.caption.left") }}
|
|
82
82
|
value={component.properties.settings.switch.captionLeft}
|
|
83
83
|
onUpdate={(value) => updateProperty("settings.switch.captionLeft", value as string, component, onPropertyChange)}
|
|
84
84
|
/>
|
|
85
85
|
<UI.Input
|
|
86
|
-
label={{ name: $
|
|
86
|
+
label={{ name: $T("constructor.props.caption.right") }}
|
|
87
87
|
value={component.properties.settings.switch.captionRight}
|
|
88
88
|
onUpdate={(value) => updateProperty("settings.switch.captionRight", value as string, component, onPropertyChange)}
|
|
89
89
|
/>
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
|
|
92
92
|
{#snippet WidgetUnits()}
|
|
93
93
|
<UI.Input
|
|
94
|
-
label={{ name: $
|
|
94
|
+
label={{ name: $T("constructor.props.units") }}
|
|
95
95
|
value={component.properties.settings.number.units as string}
|
|
96
96
|
onUpdate={(value) => updateProperty("settings.number.units", value, component, onPropertyChange)}
|
|
97
97
|
/>
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
|
|
100
100
|
{#snippet WidgetSwitchingMode()}
|
|
101
101
|
<UI.Switch
|
|
102
|
-
label={{ name: $
|
|
102
|
+
label={{ name: $T("constructor.props.widget.mode") }}
|
|
103
103
|
value={component.properties.icons.cycling}
|
|
104
104
|
options={[{ id: crypto.randomUUID(), value: 0, class: "" }]}
|
|
105
105
|
onChange={(value) => updateProperty("icons.cycling", value, component, onPropertyChange)}
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
<CommonSnippets
|
|
111
111
|
snippet="IconsLib"
|
|
112
112
|
initialValue={{
|
|
113
|
-
name: $
|
|
113
|
+
name: $T("constructor.props.labelicon"),
|
|
114
114
|
icon: component.properties.icons.array,
|
|
115
115
|
updateProperty: (icons: string[]) => updateProperty("icons.array", icons as string[], component, onPropertyChange),
|
|
116
116
|
icons: { array: ICONS_ARRAY, selectArray: true },
|
package/dist/index.d.ts
CHANGED
|
@@ -31,9 +31,10 @@ export { default as Tabs } from "./Tabs/Tabs.svelte";
|
|
|
31
31
|
export { default as TabsProps } from "./Tabs/TabsProps.svelte";
|
|
32
32
|
export { default as TextField } from "./TextField/TextField.svelte";
|
|
33
33
|
export { default as TextFieldProps } from "./TextField/TextFieldProps.svelte";
|
|
34
|
+
export { default as VideoViewer } from "./VideoViewer/VideoViewer.svelte";
|
|
34
35
|
export { default as Widget } from "./Widget/Widget.svelte";
|
|
35
36
|
export { default as WidgetProps } from "./Widget/WidgetProps.svelte";
|
|
36
37
|
export * from "./locales/i18n";
|
|
37
38
|
export * from "./locales/translations";
|
|
38
39
|
export * from "./ModalStackStore";
|
|
39
|
-
export { type UIComponent, type Position, type IUIComponentHandler, type IButtonProps, type IAccordionProps, type IInputProps, type ISelectProps, type IOption, type ISwitchProps, type IColorPickerProps, type ISliderProps, type ITextFieldProps, type IMapProps, type IProgressBarProps, type IWidgetProps, type IGraphProps, type IGraphDataObject, type ITableHeader, type ITableProps, type ITabsProps, type IJoystickProps, type IFileAttachProps, type IDeviceGNSS, type ICarouselProps, type IReceivingDataObject, } from "./types";
|
|
40
|
+
export { type UIComponent, type Position, type IUIComponentHandler, type IButtonProps, type IAccordionProps, type IInputProps, type ISelectProps, type IOption, type ISwitchProps, type IColorPickerProps, type ISliderProps, type ITextFieldProps, type IMapProps, type IProgressBarProps, type IWidgetProps, type IGraphProps, type IGraphDataObject, type ITableHeader, type ITableProps, type ITabsProps, type IJoystickProps, type IFileAttachProps, type IDeviceGNSS, type ICarouselProps, type IReceivingDataObject, type IVideoViewerProps, } from "./types";
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,8 @@ export { default as Tabs } from "./Tabs/Tabs.svelte";
|
|
|
32
32
|
export { default as TabsProps } from "./Tabs/TabsProps.svelte";
|
|
33
33
|
export { default as TextField } from "./TextField/TextField.svelte";
|
|
34
34
|
export { default as TextFieldProps } from "./TextField/TextFieldProps.svelte";
|
|
35
|
+
export { default as VideoViewer } from "./VideoViewer/VideoViewer.svelte";
|
|
36
|
+
// export { default as VideoViewerProps } from "./VideoViewer/VideoViewerProps.svelte"
|
|
35
37
|
export { default as Widget } from "./Widget/Widget.svelte";
|
|
36
38
|
export { default as WidgetProps } from "./Widget/WidgetProps.svelte";
|
|
37
39
|
export * from "./locales/i18n";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<script lang="ts"></script>
|
|
2
|
+
|
|
3
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 24 24"
|
|
4
|
+
><path
|
|
5
|
+
fill="currentColor"
|
|
6
|
+
d="M12 16.462q.262 0 .439-.177q.176-.177.176-.439q0-.261-.177-.438T12 15.23t-.438.177t-.177.438t.177.439t.438.177m0-3.308q.214 0 .357-.144t.143-.356v-5q0-.213-.144-.356t-.357-.144t-.356.144t-.143.356v5q0 .212.144.356t.357.144M12.003 21q-1.867 0-3.51-.708q-1.643-.709-2.859-1.924t-1.925-2.856T3 12.003t.709-3.51Q4.417 6.85 5.63 5.634t2.857-1.925T11.997 3t3.51.709q1.643.708 2.859 1.922t1.925 2.857t.709 3.509t-.708 3.51t-1.924 2.859t-2.856 1.925t-3.509.709M12 20q3.35 0 5.675-2.325T20 12t-2.325-5.675T12 4T6.325 6.325T4 12t2.325 5.675T12 20m0-8"
|
|
7
|
+
/></svg
|
|
8
|
+
>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const Error: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type Error = InstanceType<typeof Error>;
|
|
18
|
+
export default Error;
|
package/dist/locales/i18n.d.ts
CHANGED
package/dist/locales/i18n.js
CHANGED
|
@@ -33,4 +33,4 @@ export const LOCALES = [
|
|
|
33
33
|
function translate(locale, key) {
|
|
34
34
|
return translations[locale]?.[key] || key;
|
|
35
35
|
}
|
|
36
|
-
export const
|
|
36
|
+
export const T = derived(Language, ($lang) => (key) => translate($lang, key));
|
|
@@ -9,6 +9,7 @@ const translations = {
|
|
|
9
9
|
"library.palette": "Палитра",
|
|
10
10
|
"library.regexp": "Регулярные выражения",
|
|
11
11
|
"library.props": "Свойства",
|
|
12
|
+
"library.retry": "Повторить",
|
|
12
13
|
"library.props.name": "Название",
|
|
13
14
|
"library.props.type": "Тип",
|
|
14
15
|
"library.props.default": "По умолчанию",
|
|
@@ -84,6 +85,7 @@ const translations = {
|
|
|
84
85
|
"constructor.props.variables": "Перечень переменных",
|
|
85
86
|
"constructor.props.variables.info": "Поле для ввода имён переменных, разделенных пробелами",
|
|
86
87
|
"constructor.props.value": "Значение",
|
|
88
|
+
"constructor.props.defaultvalue": "Значение по умолчанию",
|
|
87
89
|
"constructor.props.value.info": "Поле для ввода Value пакета в формате JSON",
|
|
88
90
|
"constructor.props.align": "Выравнивание надписи",
|
|
89
91
|
"constructor.props.align.header": "Выравнивание заголовка",
|
|
@@ -174,6 +176,9 @@ const translations = {
|
|
|
174
176
|
"constructor.props.file.notselected": "Файл не выбран",
|
|
175
177
|
"constructor.props.map.loading": "Загрузка карты...",
|
|
176
178
|
"constructor.props.map.noconnection": "Карта не загружена. Нет подключения к интернету",
|
|
179
|
+
"constructor.props.video.viewer.loading": "Загрузка камеры...",
|
|
180
|
+
"constructor.props.video.viewer.no.permission": "Нет разрешения для доступа к камере",
|
|
181
|
+
"constructor.props.video.viewer.no.access": "Камера недоступна",
|
|
177
182
|
"constructor.props.widget.mode": "Зацикленный",
|
|
178
183
|
"constructor.props.table.type": "Тип таблицы",
|
|
179
184
|
"constructor.props.table.type.table": "Статическая таблица",
|