poe-svelte-ui-lib 1.0.1 → 1.0.4
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/LICENSE +3 -3
- package/README.md +1 -0
- package/dist/Accordion/Accordion.svelte +53 -53
- package/dist/Button/Button.svelte +111 -144
- package/dist/Button/Button.svelte.d.ts +1 -34
- package/dist/ColorPicker/ColorPicker.svelte +205 -207
- package/dist/FileAttach/FileAttach.svelte +103 -103
- package/dist/Graph/Graph.svelte +270 -270
- package/dist/Input/Input.svelte +240 -239
- package/dist/Loader.svelte +12 -12
- package/dist/MessageModal.svelte +54 -54
- package/dist/ProgressBar/ProgressBar.svelte +48 -48
- package/dist/Select/Select.svelte +189 -191
- package/dist/Slider/Slider.svelte +260 -260
- package/dist/Switch/Switch.svelte +84 -83
- package/dist/Table/Table.svelte +275 -276
- package/dist/TextField/TextField.svelte +22 -22
- package/dist/index.d.ts +0 -11
- package/dist/index.js +0 -11
- package/dist/{appIcons → libIcons}/ButtonAdd.svelte +10 -10
- package/dist/{appIcons → libIcons}/ButtonDelete.svelte +13 -13
- package/dist/{appIcons → libIcons}/LoaderRotate.svelte +9 -9
- package/dist/options.d.ts +11 -11
- package/dist/options.js +27 -27
- package/dist/types.d.ts +1 -1
- package/package.json +48 -47
- package/dist/Accordion/AccordionProps.svelte +0 -70
- package/dist/Accordion/AccordionProps.svelte.d.ts +0 -10
- package/dist/Button/ButtonProps.svelte +0 -200
- package/dist/Button/ButtonProps.svelte.d.ts +0 -10
- package/dist/ColorPicker/ColorPickerProps.svelte +0 -100
- package/dist/ColorPicker/ColorPickerProps.svelte.d.ts +0 -10
- package/dist/Graph/GraphProps.svelte +0 -56
- package/dist/Graph/GraphProps.svelte.d.ts +0 -10
- package/dist/Input/InputProps.svelte +0 -221
- package/dist/Input/InputProps.svelte.d.ts +0 -10
- package/dist/ProgressBar/ProgressBarProps.svelte +0 -145
- package/dist/ProgressBar/ProgressBarProps.svelte.d.ts +0 -10
- package/dist/Select/SelectProps.svelte +0 -260
- package/dist/Select/SelectProps.svelte.d.ts +0 -10
- package/dist/Slider/SliderProps.svelte +0 -161
- package/dist/Slider/SliderProps.svelte.d.ts +0 -10
- package/dist/Switch/SwitchProps.svelte +0 -144
- package/dist/Switch/SwitchProps.svelte.d.ts +0 -10
- package/dist/Table/TableProps.svelte +0 -286
- package/dist/Table/TableProps.svelte.d.ts +0 -10
- package/dist/TextField/TextFieldProps.svelte +0 -92
- package/dist/TextField/TextFieldProps.svelte.d.ts +0 -10
- package/dist/locales/CircleFlagsEn.svelte +0 -14
- package/dist/locales/CircleFlagsEn.svelte.d.ts +0 -26
- package/dist/locales/CircleFlagsRu.svelte +0 -8
- package/dist/locales/CircleFlagsRu.svelte.d.ts +0 -26
- package/dist/locales/CircleFlagsZh.svelte +0 -8
- package/dist/locales/CircleFlagsZh.svelte.d.ts +0 -26
- package/dist/locales/i18n.d.ts +0 -10
- package/dist/locales/i18n.js +0 -36
- package/dist/locales/translations.d.ts +0 -7
- package/dist/locales/translations.js +0 -450
- /package/dist/{appIcons → libIcons}/ButtonAdd.svelte.d.ts +0 -0
- /package/dist/{appIcons → libIcons}/ButtonDelete.svelte.d.ts +0 -0
- /package/dist/{appIcons → libIcons}/LoaderRotate.svelte.d.ts +0 -0
package/dist/Input/Input.svelte
CHANGED
|
@@ -1,239 +1,240 @@
|
|
|
1
|
-
<!-- $lib/ElementsUI/Input.svelte -->
|
|
2
|
-
<script lang="ts">
|
|
3
|
-
import { onMount } from 'svelte'
|
|
4
|
-
import { fly } from 'svelte/transition'
|
|
5
|
-
import type { IInputProps } from '../types'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
let
|
|
28
|
-
let
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
let
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
[
|
|
82
|
-
{
|
|
83
|
-
{
|
|
84
|
-
{
|
|
85
|
-
{
|
|
86
|
-
{
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
{
|
|
92
|
-
{
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
{
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
{
|
|
106
|
-
{
|
|
107
|
-
{
|
|
108
|
-
{
|
|
109
|
-
{
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
{
|
|
114
|
-
{
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
{
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
{:else}
|
|
137
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="1.5rem" height="1.5rem" viewBox="0 0 24 24"
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
{
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
{
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
{
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
{
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
</div>
|
|
1
|
+
<!-- $lib/ElementsUI/Input.svelte -->
|
|
2
|
+
<script lang="ts">
|
|
3
|
+
import { onMount } from 'svelte'
|
|
4
|
+
import { fly } from 'svelte/transition'
|
|
5
|
+
import type { IInputProps } from '../types'
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
id = { name: '', value: crypto.randomUUID() },
|
|
9
|
+
wrapperClass = '',
|
|
10
|
+
label = { name: '', class: '' },
|
|
11
|
+
disabled = false,
|
|
12
|
+
readonly = false,
|
|
13
|
+
value = $bindable(),
|
|
14
|
+
type = 'text',
|
|
15
|
+
autocomplete = 'off',
|
|
16
|
+
componentClass = '',
|
|
17
|
+
maxlength = 100,
|
|
18
|
+
number = { minNum: -1000000, maxNum: 1000000, step: 1 },
|
|
19
|
+
textareaRows = 3,
|
|
20
|
+
copyButton = false,
|
|
21
|
+
regExp = '^[\\s\\S]*$',
|
|
22
|
+
help = { placeholder: '', info: '' },
|
|
23
|
+
onUpdate = () => {},
|
|
24
|
+
}: IInputProps = $props()
|
|
25
|
+
|
|
26
|
+
let showPassword = $state(false)
|
|
27
|
+
let showInfo = $state(false)
|
|
28
|
+
let isCopied = $state(false)
|
|
29
|
+
|
|
30
|
+
/* Закрытие INFO при клике вне компонента */
|
|
31
|
+
onMount(() => {
|
|
32
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
33
|
+
const target = event.target as HTMLElement
|
|
34
|
+
if (!target.closest('.info-container') && !target.closest('.button-info')) {
|
|
35
|
+
showInfo = false
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
window.addEventListener('click', handleClickOutside)
|
|
39
|
+
return () => {
|
|
40
|
+
window.removeEventListener('click', handleClickOutside)
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
$effect(() => {
|
|
45
|
+
if (type === 'number') {
|
|
46
|
+
if (value === undefined || value === null || value === '') value = number.minNum
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
/* Обработка регулярного выражения */
|
|
51
|
+
const parseRegExp = (pattern: string | RegExp): RegExp => {
|
|
52
|
+
if (pattern instanceof RegExp) return pattern
|
|
53
|
+
const match = pattern.match(/^\/(.*)\/([gimsuy]*)$/)
|
|
54
|
+
return match ? new RegExp(match[1], match[2]) : new RegExp(pattern)
|
|
55
|
+
}
|
|
56
|
+
let RegExpObj = $derived(() => parseRegExp(regExp))
|
|
57
|
+
let isValid = $derived(RegExpObj().test(typeof value === 'string' ? value : String(value)))
|
|
58
|
+
|
|
59
|
+
const handleInputChange = (value: string | number) => {
|
|
60
|
+
if (type === 'number') {
|
|
61
|
+
const numValue = typeof value === 'string' ? parseFloat(value.replace(',', '.')) : Number(value)
|
|
62
|
+
if (!isNaN(numValue)) onUpdate?.(numValue)
|
|
63
|
+
else onUpdate?.(value as string)
|
|
64
|
+
} else {
|
|
65
|
+
onUpdate?.(value as string)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<div class="bg-max relative flex w-full flex-col items-center {type === 'text-area' ? 'h-full' : ''} {wrapperClass}">
|
|
71
|
+
{#if label.name}
|
|
72
|
+
<h5 class={`w-full px-4 text-center ${label.class}`}>{label.name}</h5>
|
|
73
|
+
{/if}
|
|
74
|
+
|
|
75
|
+
<div class="relative flex w-full items-center {type === 'text-area' ? 'h-full' : ''}">
|
|
76
|
+
{#if type === 'text' || type === 'password' || type === 'number'}
|
|
77
|
+
<input
|
|
78
|
+
bind:value
|
|
79
|
+
class="w-full rounded-2xl border px-4 py-1 text-center transition-all duration-300 outline-none focus:border-blue-400
|
|
80
|
+
[&::-webkit-inner-spin-button]:hidden [&::-webkit-outer-spin-button]:hidden
|
|
81
|
+
{isValid ? 'border-[var(--border-color)]' : '!border-red-400 shadow-[0_0_6px_var(--red-color)]'}
|
|
82
|
+
{disabled ? 'opacity-50' : 'hover:shadow-md'}
|
|
83
|
+
{readonly ? '' : 'hover:shadow-md'}
|
|
84
|
+
{help?.info ? 'pl-8' : ''}
|
|
85
|
+
{copyButton || type === 'password' || type === 'number' ? 'pr-8' : ''}
|
|
86
|
+
{componentClass}"
|
|
87
|
+
style="background: color-mix(in srgb, var(--bg-color), var(--back-color) 70%);"
|
|
88
|
+
id={id.value}
|
|
89
|
+
placeholder={help?.placeholder}
|
|
90
|
+
{disabled}
|
|
91
|
+
{autocomplete}
|
|
92
|
+
oninput={(e) => handleInputChange((e.currentTarget as HTMLInputElement).value)}
|
|
93
|
+
type={type === 'password' ? (showPassword ? 'text' : 'password') : type === 'number' ? 'number' : 'text'}
|
|
94
|
+
{maxlength}
|
|
95
|
+
min={number?.minNum}
|
|
96
|
+
max={number?.maxNum}
|
|
97
|
+
step={number?.step}
|
|
98
|
+
{readonly}
|
|
99
|
+
/>
|
|
100
|
+
{:else if type === 'text-area'}
|
|
101
|
+
<textarea
|
|
102
|
+
bind:value
|
|
103
|
+
class="h-full w-full resize-y rounded-2xl border border-[var(--border-color)] px-2 py-1 text-center font-mono transition-all duration-300 outline-none focus:border-blue-400
|
|
104
|
+
{isValid ? 'border-[var(--border-color)]' : '!border-red-400 shadow-[0_0_6px_var(--red-color)]'}
|
|
105
|
+
{disabled ? 'opacity-50' : 'hover:shadow-md'}
|
|
106
|
+
{readonly ? '' : 'hover:shadow-md'}
|
|
107
|
+
{help?.info ? 'pl-8' : ''}
|
|
108
|
+
{copyButton ? 'pr-8' : ''}
|
|
109
|
+
{componentClass}"
|
|
110
|
+
style="background: color-mix(in srgb, var(--bg-color), var(--back-color) 70%);"
|
|
111
|
+
id={id.value}
|
|
112
|
+
{disabled}
|
|
113
|
+
{maxlength}
|
|
114
|
+
rows={textareaRows}
|
|
115
|
+
placeholder={help?.placeholder}
|
|
116
|
+
{readonly}
|
|
117
|
+
oninput={(e) => handleInputChange((e.currentTarget as HTMLTextAreaElement).value)}
|
|
118
|
+
></textarea>
|
|
119
|
+
{/if}
|
|
120
|
+
|
|
121
|
+
{#if type === 'password' && !disabled}
|
|
122
|
+
<button
|
|
123
|
+
type="button"
|
|
124
|
+
class="absolute right-2 flex cursor-pointer border-none bg-transparent"
|
|
125
|
+
onclick={() => (showPassword = !showPassword)}
|
|
126
|
+
aria-label={showPassword ? 'Скрыть пароль' : 'Показать пароль'}
|
|
127
|
+
>
|
|
128
|
+
{#if showPassword}
|
|
129
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="1.5rem" height="1.5rem" viewBox="0 0 24 24"
|
|
130
|
+
><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"
|
|
131
|
+
><path d="M15 12a3 3 0 1 1-6 0a3 3 0 0 1 6 0" /><path
|
|
132
|
+
d="M2 12c1.6-4.097 5.336-7 10-7s8.4 2.903 10 7c-1.6 4.097-5.336 7-10 7s-8.4-2.903-10-7"
|
|
133
|
+
/></g
|
|
134
|
+
></svg
|
|
135
|
+
>
|
|
136
|
+
{:else}
|
|
137
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="1.5rem" height="1.5rem" viewBox="0 0 24 24"
|
|
138
|
+
><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"
|
|
139
|
+
><path
|
|
140
|
+
stroke-linejoin="round"
|
|
141
|
+
d="M10.73 5.073A11 11 0 0 1 12 5c4.664 0 8.4 2.903 10 7a11.6 11.6 0 0 1-1.555 2.788M6.52 6.519C4.48 7.764 2.9 9.693 2 12c1.6 4.097 5.336 7 10 7a10.44 10.44 0 0 0 5.48-1.52m-7.6-7.6a3 3 0 1 0 4.243 4.243"
|
|
142
|
+
/><path d="m4 4l16 16" /></g
|
|
143
|
+
></svg
|
|
144
|
+
>
|
|
145
|
+
{/if}
|
|
146
|
+
</button>
|
|
147
|
+
{/if}
|
|
148
|
+
|
|
149
|
+
{#if copyButton && (type === 'text' || type === 'text-area')}
|
|
150
|
+
<button
|
|
151
|
+
type="button"
|
|
152
|
+
class="absolute right-2 flex cursor-pointer border-none bg-transparent {type === 'text-area' ? 'top-2' : ''}"
|
|
153
|
+
onclick={(e) => {
|
|
154
|
+
e.preventDefault()
|
|
155
|
+
navigator.clipboard.writeText(value as string)
|
|
156
|
+
isCopied = true
|
|
157
|
+
setTimeout(() => (isCopied = false), 1000)
|
|
158
|
+
}}
|
|
159
|
+
aria-label="Копировать текст"
|
|
160
|
+
>
|
|
161
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="1.3em" height="1.3em" viewBox="0 0 24 24">
|
|
162
|
+
<g fill="none" stroke="currentColor" stroke-width="1.5">
|
|
163
|
+
<path
|
|
164
|
+
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"
|
|
165
|
+
/>
|
|
166
|
+
<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" />
|
|
167
|
+
</g>
|
|
168
|
+
</svg>
|
|
169
|
+
</button>
|
|
170
|
+
|
|
171
|
+
{#if isCopied}
|
|
172
|
+
<div
|
|
173
|
+
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"
|
|
174
|
+
transition:fly={{ x: 10, duration: 200 }}
|
|
175
|
+
>
|
|
176
|
+
✔
|
|
177
|
+
</div>
|
|
178
|
+
{/if}
|
|
179
|
+
{/if}
|
|
180
|
+
|
|
181
|
+
{#if type === 'number' && !readonly && !disabled}
|
|
182
|
+
<div class="absolute right-0 flex h-full w-8 flex-col items-center justify-center rounded-r-2xl border-l border-[var(--border-color)]">
|
|
183
|
+
<button
|
|
184
|
+
class="flex h-1/2 w-full items-center rounded-tr-2xl border-b border-[var(--border-color)] pl-2 transition-colors duration-150 hover:bg-[var(--gray-color)]/30 active:bg-[var(--gray-color)]/10"
|
|
185
|
+
onclick={() => {
|
|
186
|
+
if (!number.maxNum || !number.step) return
|
|
187
|
+
if (Number(value) + number.step >= number.maxNum) {
|
|
188
|
+
value = number.maxNum
|
|
189
|
+
onUpdate?.(value as number)
|
|
190
|
+
return
|
|
191
|
+
}
|
|
192
|
+
value = Number(value) + (number.step ?? 1)
|
|
193
|
+
onUpdate?.(value as number)
|
|
194
|
+
}}
|
|
195
|
+
aria-label="Увеличить">+</button
|
|
196
|
+
>
|
|
197
|
+
|
|
198
|
+
<button
|
|
199
|
+
class="flex h-1/2 w-full items-center rounded-br-2xl pl-2 transition-colors duration-150 hover:bg-[var(--gray-color)]/30 active:bg-[var(--gray-color)]/10"
|
|
200
|
+
onclick={() => {
|
|
201
|
+
if (number.minNum === null || number.minNum === undefined || !number.step) return
|
|
202
|
+
if (Number(value) - number.step <= number.minNum) {
|
|
203
|
+
value = number.minNum
|
|
204
|
+
onUpdate?.(value as number)
|
|
205
|
+
return
|
|
206
|
+
}
|
|
207
|
+
value = Number(value) - (number.step ?? 1)
|
|
208
|
+
onUpdate?.(value as number)
|
|
209
|
+
}}
|
|
210
|
+
aria-label="Уменьшить">−</button
|
|
211
|
+
>
|
|
212
|
+
</div>
|
|
213
|
+
{/if}
|
|
214
|
+
|
|
215
|
+
{#if help.info}
|
|
216
|
+
<button
|
|
217
|
+
type="button"
|
|
218
|
+
class="button-info absolute left-2 flex border-none bg-transparent {type === 'text-area' ? 'top-2' : ''} {disabled ? 'opacity-50' : 'cursor-pointer'}"
|
|
219
|
+
onclick={() => (showInfo = !showInfo)}
|
|
220
|
+
aria-label={showInfo ? 'Скрыть инфо' : 'Показать инфо'}
|
|
221
|
+
>
|
|
222
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="1.5rem" height="1.5rem" viewBox="0 0 24 24"
|
|
223
|
+
><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"
|
|
224
|
+
><circle cx="12" cy="12" r="10" stroke-width="1.3" /><path stroke-width="1.5" d="M12 16v-4.5" /><path stroke-width="1.8" d="M12 8.012v-.01" /></g
|
|
225
|
+
></svg
|
|
226
|
+
>
|
|
227
|
+
</button>
|
|
228
|
+
|
|
229
|
+
{#if showInfo}
|
|
230
|
+
<div
|
|
231
|
+
transition:fly={{ x: -15, duration: 250 }}
|
|
232
|
+
class="info-container absolute z-50 w-auto rounded px-2 py-1 shadow-lg"
|
|
233
|
+
style="left: 2.5rem; top: 50%; transform: translateY(-50%); background: color-mix(in srgb, var(--yellow-color) 20%, var(--back-color));"
|
|
234
|
+
>
|
|
235
|
+
{help?.info}
|
|
236
|
+
</div>
|
|
237
|
+
{/if}
|
|
238
|
+
{/if}
|
|
239
|
+
</div>
|
|
240
|
+
</div>
|
package/dist/Loader.svelte
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
<!-- $lib/ElementsUI/Loader.svelte -->
|
|
2
|
-
<script lang="ts">
|
|
3
|
-
import LoaderRotate from './
|
|
4
|
-
|
|
5
|
-
let { show = false } = $props()
|
|
6
|
-
</script>
|
|
7
|
-
|
|
8
|
-
{#if show}
|
|
9
|
-
<div class="absolute inset-0 z-50 flex items-center justify-center">
|
|
10
|
-
<LoaderRotate />
|
|
11
|
-
</div>
|
|
12
|
-
{/if}
|
|
1
|
+
<!-- $lib/ElementsUI/Loader.svelte -->
|
|
2
|
+
<script lang="ts">
|
|
3
|
+
import LoaderRotate from './libIcons/LoaderRotate.svelte'
|
|
4
|
+
|
|
5
|
+
let { show = false } = $props()
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
{#if show}
|
|
9
|
+
<div class="absolute inset-0 z-50 flex items-center justify-center">
|
|
10
|
+
<LoaderRotate />
|
|
11
|
+
</div>
|
|
12
|
+
{/if}
|
package/dist/MessageModal.svelte
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
<!-- $lib/ElementsUI/MessageModal.svelte -->
|
|
2
|
-
<script lang="ts">
|
|
3
|
-
import { onMount } from 'svelte'
|
|
4
|
-
import { fly } from 'svelte/transition'
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
message: { id: number; text: string }
|
|
8
|
-
onCLick: (messageId: number) => {}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
let { message, onCLick }: Props = $props()
|
|
12
|
-
|
|
13
|
-
const getMessageStyle = (text: string) => {
|
|
14
|
-
if (text.startsWith('ERR: ')) return 'text-red-500'
|
|
15
|
-
if (text.startsWith('OK: ')) return 'text-lime-500'
|
|
16
|
-
if (text.startsWith('WR: ')) return 'text-yellow-500'
|
|
17
|
-
return 'text-gray-400'
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const getMessageText = (text: string) => {
|
|
21
|
-
if (text.startsWith('ERR: ')) return text.replace('ERR: ', '')
|
|
22
|
-
if (text.startsWith('OK: ')) return text.replace('OK: ', '')
|
|
23
|
-
if (text.startsWith('WR: ')) return text.replace('WR: ', '')
|
|
24
|
-
return text
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
let progress = $state(100)
|
|
28
|
-
onMount(() => {
|
|
29
|
-
const duration = 5000
|
|
30
|
-
const interval = 50
|
|
31
|
-
const step = (interval / duration) * 100
|
|
32
|
-
const timer = setInterval(() => {
|
|
33
|
-
progress -= step
|
|
34
|
-
if (progress <= 0) {
|
|
35
|
-
clearInterval(timer)
|
|
36
|
-
onCLick(message.id)
|
|
37
|
-
}
|
|
38
|
-
}, interval)
|
|
39
|
-
})
|
|
40
|
-
</script>
|
|
41
|
-
|
|
42
|
-
<div
|
|
43
|
-
transition:fly={{ y: 5, duration: 250 }}
|
|
44
|
-
class="my-1 flex flex-col rounded-2xl border border-[var(--border-color)] bg-[var(--back-color)] px-4 py-2 shadow-lg"
|
|
45
|
-
>
|
|
46
|
-
<div class="flex items-center justify-between">
|
|
47
|
-
<p class={`font-semibold ${getMessageStyle(message.text)}`}>{getMessageText(message.text)}</p>
|
|
48
|
-
<button class="ml-2 cursor-pointer text-2xl" onclick={() => onCLick(message.id)}>×</button>
|
|
49
|
-
</div>
|
|
50
|
-
|
|
51
|
-
<div class="mt-2 h-2 w-full overflow-hidden rounded bg-gray-200">
|
|
52
|
-
<div class="h-full bg-[var(--green-color)]" style={`width: ${progress}%`}></div>
|
|
53
|
-
</div>
|
|
54
|
-
</div>
|
|
1
|
+
<!-- $lib/ElementsUI/MessageModal.svelte -->
|
|
2
|
+
<script lang="ts">
|
|
3
|
+
import { onMount } from 'svelte'
|
|
4
|
+
import { fly } from 'svelte/transition'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
message: { id: number; text: string }
|
|
8
|
+
onCLick: (messageId: number) => {}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let { message, onCLick }: Props = $props()
|
|
12
|
+
|
|
13
|
+
const getMessageStyle = (text: string) => {
|
|
14
|
+
if (text.startsWith('ERR: ')) return 'text-red-500'
|
|
15
|
+
if (text.startsWith('OK: ')) return 'text-lime-500'
|
|
16
|
+
if (text.startsWith('WR: ')) return 'text-yellow-500'
|
|
17
|
+
return 'text-gray-400'
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const getMessageText = (text: string) => {
|
|
21
|
+
if (text.startsWith('ERR: ')) return text.replace('ERR: ', '')
|
|
22
|
+
if (text.startsWith('OK: ')) return text.replace('OK: ', '')
|
|
23
|
+
if (text.startsWith('WR: ')) return text.replace('WR: ', '')
|
|
24
|
+
return text
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let progress = $state(100)
|
|
28
|
+
onMount(() => {
|
|
29
|
+
const duration = 5000
|
|
30
|
+
const interval = 50
|
|
31
|
+
const step = (interval / duration) * 100
|
|
32
|
+
const timer = setInterval(() => {
|
|
33
|
+
progress -= step
|
|
34
|
+
if (progress <= 0) {
|
|
35
|
+
clearInterval(timer)
|
|
36
|
+
onCLick(message.id)
|
|
37
|
+
}
|
|
38
|
+
}, interval)
|
|
39
|
+
})
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<div
|
|
43
|
+
transition:fly={{ y: 5, duration: 250 }}
|
|
44
|
+
class="my-1 flex flex-col rounded-2xl border border-[var(--border-color)] bg-[var(--back-color)] px-4 py-2 shadow-lg"
|
|
45
|
+
>
|
|
46
|
+
<div class="flex items-center justify-between">
|
|
47
|
+
<p class={`font-semibold ${getMessageStyle(message.text)}`}>{getMessageText(message.text)}</p>
|
|
48
|
+
<button class="ml-2 cursor-pointer text-2xl" onclick={() => onCLick(message.id)}>×</button>
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<div class="mt-2 h-2 w-full overflow-hidden rounded bg-gray-200">
|
|
52
|
+
<div class="h-full bg-[var(--green-color)]" style={`width: ${progress}%`}></div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|