sveltekit-ui 1.1.14 → 1.1.16
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/package.json +4 -4
- package/src/routes/+page.svelte +24 -0
- package/dist/Components/Alert/index.svelte +0 -88
- package/dist/Components/Alert/index.svelte.js +0 -101
- package/dist/Components/Audio/index.svelte +0 -193
- package/dist/Components/Audio/index.svelte.js +0 -463
- package/dist/Components/AuthCodeInput/index.svelte +0 -85
- package/dist/Components/AuthCodeInput/index.svelte.js +0 -95
- package/dist/Components/Button/index.svelte +0 -721
- package/dist/Components/Button/index.svelte.js +0 -375
- package/dist/Components/Checkbox/index.svelte +0 -411
- package/dist/Components/Checkbox/index.svelte.js +0 -178
- package/dist/Components/Code/index.svelte +0 -23
- package/dist/Components/Code/index.svelte.js +0 -33
- package/dist/Components/EmailAddress/index.svelte +0 -22
- package/dist/Components/EmailAddress/index.svelte.js +0 -45
- package/dist/Components/Eye/index.svelte +0 -57
- package/dist/Components/Icon/index.svelte +0 -412
- package/dist/Components/Icon/index.svelte.js +0 -116
- package/dist/Components/InfoBox/index.svelte +0 -89
- package/dist/Components/Json/index.svelte +0 -60
- package/dist/Components/Json/index.svelte.js +0 -594
- package/dist/Components/Link/index.svelte +0 -47
- package/dist/Components/Link/index.svelte.js +0 -136
- package/dist/Components/LoadingSuccessDiv/index.svelte +0 -51
- package/dist/Components/Location/index.svelte +0 -79
- package/dist/Components/Location/index.svelte.js +0 -288
- package/dist/Components/PhoneNumber/index.svelte +0 -22
- package/dist/Components/PhoneNumber/index.svelte.js +0 -41
- package/dist/Components/Qr/index.svelte +0 -85
- package/dist/Components/Qr/index.svelte.js +0 -301
- package/dist/Components/QrInput/index.svelte +0 -47
- package/dist/Components/QrInput/index.svelte.js +0 -218
- package/dist/Components/Slider/index.svelte +0 -239
- package/dist/Components/Slider/index.svelte.js +0 -469
- package/dist/Components/SuccessCheck/index.svelte +0 -56
- package/dist/Components/TableAdvanced/index.svelte +0 -275
- package/dist/Components/TableAdvanced/index.svelte.js +0 -1565
- package/dist/Components/TextInput/index.svelte +0 -223
- package/dist/Components/TextInput/index.svelte.js +0 -447
- package/dist/Components/Time/index.svelte +0 -7
- package/dist/Components/Time/index.svelte.js +0 -38
- package/dist/Components/VideoTBD/index.svelte +0 -100
- package/dist/Components/XPost/index.svelte +0 -52
- package/dist/Components/XPost/index.svelte.js +0 -64
|
@@ -1,463 +0,0 @@
|
|
|
1
|
-
import { browser } from "$app/environment"
|
|
2
|
-
import { create_button_manager } from "../Button/index.svelte.js"
|
|
3
|
-
import { create_popover_manager } from "../Popover/index.svelte.js"
|
|
4
|
-
import { create_slider_manager } from "../Slider/index.svelte.js"
|
|
5
|
-
import { create_unique_id, set_closurable, deep_copy } from "../../client/index.js"
|
|
6
|
-
|
|
7
|
-
export function create_audio_manager(config) {
|
|
8
|
-
let id = create_unique_id(null, 20)
|
|
9
|
-
let src = $state(null)
|
|
10
|
-
let type = $state("audio/mpeg")
|
|
11
|
-
let title = $state(null)
|
|
12
|
-
let artist = $state(null)
|
|
13
|
-
let album = $state(null)
|
|
14
|
-
let image_src = $state(null)
|
|
15
|
-
let image_type = $state(null)
|
|
16
|
-
let default_skip_time = $state(10)
|
|
17
|
-
let ui_type = $state("standard") // standard, short, square
|
|
18
|
-
let ml = $derived(set_closurable(config?.ml, 0))
|
|
19
|
-
let mr = $derived(set_closurable(config?.mr, 0))
|
|
20
|
-
let mt = $derived(set_closurable(config?.mt, 0))
|
|
21
|
-
let mb = $derived(set_closurable(config?.mb, 0))
|
|
22
|
-
let is_hide_image = $derived(set_closurable(config?.is_hide_image, false))
|
|
23
|
-
let play_pause_support_icon = $state("play")
|
|
24
|
-
let play_pause_button_manager = $state(null)
|
|
25
|
-
let time_slider_manager = $state(null)
|
|
26
|
-
let settings_popover_manager = $state(null)
|
|
27
|
-
let settings_button_manager = $state(null)
|
|
28
|
-
let volume_slider_manager = $state(null)
|
|
29
|
-
let rate_slider_manager = $state(null)
|
|
30
|
-
|
|
31
|
-
let time_loaded_until = $state(0)
|
|
32
|
-
let time_highlight_range_start_percent = $derived((100 * time_slider_manager?.val) / time_slider_manager?.max)
|
|
33
|
-
let time_highlight_range_end_percent = $derived((100 * time_loaded_until) / time_slider_manager?.max)
|
|
34
|
-
|
|
35
|
-
let storage_path = $state(null)
|
|
36
|
-
let is_loading = $state(true)
|
|
37
|
-
let formatted_duration = $derived(!isNaN(time_slider_manager?.max) ? format_time(time_slider_manager?.max) : "")
|
|
38
|
-
let formatted_current_time = $derived(!isNaN(time_slider_manager?.val) ? format_time(time_slider_manager?.val) : "")
|
|
39
|
-
|
|
40
|
-
function get_src(src, storage_id) {
|
|
41
|
-
if (src) {
|
|
42
|
-
return src
|
|
43
|
-
} else if (storage_id && storage_path) {
|
|
44
|
-
return storage_path.replace("{storage_id}", storage_id)
|
|
45
|
-
} else {
|
|
46
|
-
return null
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function handle_mount() {
|
|
51
|
-
if (!browser) {
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
let audio_el = document?.querySelector(`#audio_${id}`)
|
|
55
|
-
if (audio_el) {
|
|
56
|
-
if (audio_el.readyState >= 3) {
|
|
57
|
-
handle_loaded_metadata()
|
|
58
|
-
is_loading = false
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function handle_volume_change(volume) {
|
|
64
|
-
if (!browser) {
|
|
65
|
-
// tbd on this
|
|
66
|
-
return
|
|
67
|
-
}
|
|
68
|
-
let audio_el = document?.querySelector(`#audio_${id}`)
|
|
69
|
-
if (audio_el && volume) {
|
|
70
|
-
audio_el.volume = volume
|
|
71
|
-
volume_slider_manager.set_val(deep_copy(volume))
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function handle_rate_change(rate) {
|
|
76
|
-
if (!browser) {
|
|
77
|
-
// tbd on this
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
let audio_el = document?.querySelector(`#audio_${id}`)
|
|
81
|
-
if (audio_el && rate) {
|
|
82
|
-
audio_el.playbackRate = rate
|
|
83
|
-
rate_slider_manager.set_val(rate)
|
|
84
|
-
update_position_state()
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function format_time(seconds) {
|
|
89
|
-
const mins = Math.floor(seconds / 60)
|
|
90
|
-
.toString()
|
|
91
|
-
.padStart(2, "0")
|
|
92
|
-
const secs = Math.floor(seconds % 60)
|
|
93
|
-
.toString()
|
|
94
|
-
.padStart(2, "0")
|
|
95
|
-
return `${mins}:${secs}`
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function handle_loaded_metadata() {
|
|
99
|
-
if (!browser) {
|
|
100
|
-
// tbd on this
|
|
101
|
-
return
|
|
102
|
-
}
|
|
103
|
-
let audio_el = document?.querySelector(`#audio_${id}`)
|
|
104
|
-
if (audio_el) {
|
|
105
|
-
time_slider_manager.set_max(audio_el.duration)
|
|
106
|
-
is_loading = false
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function handle_progress() {
|
|
111
|
-
if (!browser) {
|
|
112
|
-
// tbd on this
|
|
113
|
-
return
|
|
114
|
-
}
|
|
115
|
-
let audio_el = document?.querySelector(`#audio_${id}`)
|
|
116
|
-
if (audio_el?.buffered?.length) {
|
|
117
|
-
time_loaded_until = audio_el.buffered.end(0)
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function handle_time_update() {
|
|
122
|
-
if (!browser) {
|
|
123
|
-
// tbd on this
|
|
124
|
-
return
|
|
125
|
-
}
|
|
126
|
-
let audio_el = document?.querySelector(`#audio_${id}`)
|
|
127
|
-
if (audio_el) {
|
|
128
|
-
time_slider_manager.set_val(audio_el.currentTime)
|
|
129
|
-
if (audio_el?.buffered?.length) {
|
|
130
|
-
time_loaded_until = audio_el.buffered.end(0)
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function seek_to_audio(time) {
|
|
136
|
-
if (!browser) {
|
|
137
|
-
// tbd on this
|
|
138
|
-
return
|
|
139
|
-
}
|
|
140
|
-
if (time > -1) {
|
|
141
|
-
time_slider_manager.set_val(time)
|
|
142
|
-
let audio_el = document?.querySelector(`#audio_${id}`)
|
|
143
|
-
if (audio_el) {
|
|
144
|
-
audio_el.currentTime = time
|
|
145
|
-
time_slider_manager.set_val(time)
|
|
146
|
-
if (audio_el?.buffered?.length) {
|
|
147
|
-
time_loaded_until = audio_el.buffered.end(0)
|
|
148
|
-
}
|
|
149
|
-
update_position_state()
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function resize_image(src, callback) {
|
|
155
|
-
let img = new Image()
|
|
156
|
-
img.crossOrigin = "anonymous" // Request CORS permissions
|
|
157
|
-
img.onload = function () {
|
|
158
|
-
let width = img.width
|
|
159
|
-
let height = img.height
|
|
160
|
-
if (width > height) {
|
|
161
|
-
if (width > 128) {
|
|
162
|
-
height *= 128 / width
|
|
163
|
-
width = 128
|
|
164
|
-
}
|
|
165
|
-
} else {
|
|
166
|
-
if (height > 128) {
|
|
167
|
-
width *= 128 / height
|
|
168
|
-
height = 128
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
let canvas = document.createElement("canvas")
|
|
172
|
-
let ctx = canvas.getContext("2d")
|
|
173
|
-
canvas.width = width
|
|
174
|
-
canvas.height = height
|
|
175
|
-
ctx.drawImage(img, 0, 0, width, height)
|
|
176
|
-
callback(canvas.toDataURL())
|
|
177
|
-
}
|
|
178
|
-
img.src = src
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
let has_setup_media_session = $state(false)
|
|
182
|
-
function setup_media_session() {
|
|
183
|
-
let metadata = {
|
|
184
|
-
title: title,
|
|
185
|
-
artist: artist || "",
|
|
186
|
-
album: album,
|
|
187
|
-
artwork: [],
|
|
188
|
-
}
|
|
189
|
-
if (image_src) {
|
|
190
|
-
//temp fix since ios mobile is trash and not working with sizes over 128x128 even though it did on ios idk 16.4 or something
|
|
191
|
-
resize_image(image_src, function (resized_image_src) {
|
|
192
|
-
metadata.artwork = [
|
|
193
|
-
{
|
|
194
|
-
src: resized_image_src,
|
|
195
|
-
sizes: "128x128", // maximum size is now 128x128
|
|
196
|
-
type: image_type,
|
|
197
|
-
},
|
|
198
|
-
// {
|
|
199
|
-
// src: image_src,
|
|
200
|
-
// sizes: "1000x1000", // seems as though need this even if not correct and max size of a size can be 1000px
|
|
201
|
-
// type: image_type,
|
|
202
|
-
// },
|
|
203
|
-
// {
|
|
204
|
-
// src: "https://dummyimage.com/1000x500",
|
|
205
|
-
// sizes: "1000x500",
|
|
206
|
-
// type: "image/png",
|
|
207
|
-
// },
|
|
208
|
-
]
|
|
209
|
-
navigator.mediaSession.metadata = new MediaMetadata(metadata)
|
|
210
|
-
navigator.mediaSession.setActionHandler("play", play_audio)
|
|
211
|
-
navigator.mediaSession.setActionHandler("pause", pause_audio)
|
|
212
|
-
navigator.mediaSession.setActionHandler("seekto", (details) => seek_to_audio(details.seekTime))
|
|
213
|
-
navigator.mediaSession.setActionHandler("seekbackward", (details) => nav_seek_backward(details))
|
|
214
|
-
navigator.mediaSession.setActionHandler("seekforward", (details) => nav_seek_forward(details))
|
|
215
|
-
})
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
function update_position_state() {
|
|
220
|
-
if ("setPositionState" in navigator.mediaSession) {
|
|
221
|
-
navigator.mediaSession.setPositionState({
|
|
222
|
-
duration: time_slider_manager?.max,
|
|
223
|
-
playback_rate: rate_slider_manager?.val,
|
|
224
|
-
position: time_slider_manager?.val,
|
|
225
|
-
})
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
function nav_seek_backward(details) {
|
|
230
|
-
const skip_time = details.seekOffset || default_skip_time
|
|
231
|
-
seek_to_audio(Math.max(time_slider_manager?.val - skip_time, 0))
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function nav_seek_forward(details) {
|
|
235
|
-
const skip_time = details.seekOffset || default_skip_time
|
|
236
|
-
seek_to_audio(Math.min(time_slider_manager?.val + skip_time, time_slider_manager?.max))
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
function toggle_play_pause() {
|
|
240
|
-
if (!browser) {
|
|
241
|
-
// tbd on this
|
|
242
|
-
return
|
|
243
|
-
}
|
|
244
|
-
let audio_el = document?.querySelector(`#audio_${id}`)
|
|
245
|
-
const is_playing = !audio_el ? false : !audio_el.paused && !audio_el.ended && audio_el.currentTime > 0
|
|
246
|
-
if (is_playing) {
|
|
247
|
-
pause_audio()
|
|
248
|
-
} else {
|
|
249
|
-
play_audio()
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
async function play_audio() {
|
|
254
|
-
if (!browser) {
|
|
255
|
-
// tbd on this
|
|
256
|
-
return
|
|
257
|
-
}
|
|
258
|
-
let audio_el = document?.querySelector(`#audio_${id}`)
|
|
259
|
-
const is_playing = !audio_el ? false : !audio_el.paused && !audio_el.ended && audio_el.currentTime > 0
|
|
260
|
-
play_pause_support_icon = "pause"
|
|
261
|
-
if (audio_el && !is_playing) {
|
|
262
|
-
if (!has_setup_media_session) {
|
|
263
|
-
setup_media_session()
|
|
264
|
-
}
|
|
265
|
-
await audio_el.play()
|
|
266
|
-
navigator.mediaSession.playbackState = "playing"
|
|
267
|
-
update_position_state()
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
function pause_audio() {
|
|
272
|
-
if (!browser) {
|
|
273
|
-
// tbd on this
|
|
274
|
-
return
|
|
275
|
-
}
|
|
276
|
-
let audio_el = document?.querySelector(`#audio_${id}`)
|
|
277
|
-
const is_playing = !audio_el ? false : !audio_el.paused && !audio_el.ended && audio_el.currentTime > 0
|
|
278
|
-
play_pause_support_icon = "play"
|
|
279
|
-
if (audio_el && is_playing) {
|
|
280
|
-
audio_el.pause()
|
|
281
|
-
navigator.mediaSession.playbackState = "paused"
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
function set_is_loading(input) {
|
|
286
|
-
is_loading = !!input
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
function handle_seeking() {
|
|
290
|
-
is_loading = true
|
|
291
|
-
}
|
|
292
|
-
function handle_can_play() {
|
|
293
|
-
is_loading = false
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
function init(config) {
|
|
297
|
-
storage_path = config?.storage_path
|
|
298
|
-
src = get_src(config?.src, config?.storage_id)
|
|
299
|
-
type = config?.type ?? "audio/mpeg"
|
|
300
|
-
title = config?.title ?? null
|
|
301
|
-
artist = config?.artist ?? null
|
|
302
|
-
album = config?.album ?? null
|
|
303
|
-
image_src = get_src(config?.image_src, config?.image_storage_id)
|
|
304
|
-
image_type = config?.image_type ?? null
|
|
305
|
-
default_skip_time = config?.default_skip_time ?? null
|
|
306
|
-
ui_type = config?.ui_type ?? "standard"
|
|
307
|
-
play_pause_button_manager = create_button_manager({
|
|
308
|
-
type: "soft",
|
|
309
|
-
is_uniform: true,
|
|
310
|
-
is_icon_bg_tint: false,
|
|
311
|
-
aria_label: "play_pause",
|
|
312
|
-
is_loading: () => is_loading,
|
|
313
|
-
support_icon: () => play_pause_support_icon ?? "play",
|
|
314
|
-
on_click: () => toggle_play_pause(),
|
|
315
|
-
})
|
|
316
|
-
time_slider_manager = create_slider_manager({
|
|
317
|
-
min: 0,
|
|
318
|
-
max: null,
|
|
319
|
-
step: 1,
|
|
320
|
-
ml: 0.5,
|
|
321
|
-
mr: 0.5,
|
|
322
|
-
is_show_text: false,
|
|
323
|
-
is_short: true,
|
|
324
|
-
val: 0,
|
|
325
|
-
highlight_range_start_percent: () => time_highlight_range_start_percent,
|
|
326
|
-
highlight_range_end_percent: () => time_highlight_range_end_percent,
|
|
327
|
-
on_change: (input) => seek_to_audio(input),
|
|
328
|
-
})
|
|
329
|
-
settings_popover_manager = create_popover_manager({
|
|
330
|
-
header: "Settings",
|
|
331
|
-
type: "dropdown",
|
|
332
|
-
min_width: 100,
|
|
333
|
-
target_width: 200,
|
|
334
|
-
min_height: 100,
|
|
335
|
-
target_height: 200,
|
|
336
|
-
anchor_id: () => `button_${settings_button_manager?.id}`,
|
|
337
|
-
})
|
|
338
|
-
settings_button_manager = create_button_manager({
|
|
339
|
-
type: "soft",
|
|
340
|
-
support_icon: "three_dots",
|
|
341
|
-
icon_sw: 60,
|
|
342
|
-
is_icon_bg_tint: false,
|
|
343
|
-
is_uniform: true,
|
|
344
|
-
aria_label: "settings",
|
|
345
|
-
popover_target: () => `popover_${settings_popover_manager?.id}`,
|
|
346
|
-
})
|
|
347
|
-
volume_slider_manager = create_slider_manager({
|
|
348
|
-
label: "Volume",
|
|
349
|
-
min: 0,
|
|
350
|
-
max: 1,
|
|
351
|
-
step: 0.05,
|
|
352
|
-
is_show_text: true,
|
|
353
|
-
is_short: false,
|
|
354
|
-
val: 1,
|
|
355
|
-
on_change: (input) => handle_volume_change(input),
|
|
356
|
-
})
|
|
357
|
-
rate_slider_manager = create_slider_manager({
|
|
358
|
-
label: "Rate",
|
|
359
|
-
min: 0.5,
|
|
360
|
-
max: 3,
|
|
361
|
-
step: 0.05,
|
|
362
|
-
is_show_text: true,
|
|
363
|
-
is_short: false,
|
|
364
|
-
val: 1,
|
|
365
|
-
on_change: (input) => handle_rate_change(input),
|
|
366
|
-
})
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
init(config)
|
|
370
|
-
|
|
371
|
-
return {
|
|
372
|
-
id,
|
|
373
|
-
get src() {
|
|
374
|
-
return src
|
|
375
|
-
},
|
|
376
|
-
get type() {
|
|
377
|
-
return type
|
|
378
|
-
},
|
|
379
|
-
get title() {
|
|
380
|
-
return title
|
|
381
|
-
},
|
|
382
|
-
get artist() {
|
|
383
|
-
return artist
|
|
384
|
-
},
|
|
385
|
-
get album() {
|
|
386
|
-
return album
|
|
387
|
-
},
|
|
388
|
-
get image_src() {
|
|
389
|
-
return image_src
|
|
390
|
-
},
|
|
391
|
-
get image_type() {
|
|
392
|
-
return image_type
|
|
393
|
-
},
|
|
394
|
-
get default_skip_time() {
|
|
395
|
-
return default_skip_time
|
|
396
|
-
},
|
|
397
|
-
get ui_type() {
|
|
398
|
-
return ui_type
|
|
399
|
-
},
|
|
400
|
-
get ml() {
|
|
401
|
-
return ml
|
|
402
|
-
},
|
|
403
|
-
get mr() {
|
|
404
|
-
return mr
|
|
405
|
-
},
|
|
406
|
-
get mt() {
|
|
407
|
-
return mt
|
|
408
|
-
},
|
|
409
|
-
get mb() {
|
|
410
|
-
return mb
|
|
411
|
-
},
|
|
412
|
-
get is_hide_image() {
|
|
413
|
-
return is_hide_image
|
|
414
|
-
},
|
|
415
|
-
get play_pause_button_manager() {
|
|
416
|
-
return play_pause_button_manager
|
|
417
|
-
},
|
|
418
|
-
get time_slider_manager() {
|
|
419
|
-
return time_slider_manager
|
|
420
|
-
},
|
|
421
|
-
get settings_popover_manager() {
|
|
422
|
-
return settings_popover_manager
|
|
423
|
-
},
|
|
424
|
-
get settings_button_manager() {
|
|
425
|
-
return settings_button_manager
|
|
426
|
-
},
|
|
427
|
-
get volume_slider_manager() {
|
|
428
|
-
return volume_slider_manager
|
|
429
|
-
},
|
|
430
|
-
get rate_slider_manager() {
|
|
431
|
-
return rate_slider_manager
|
|
432
|
-
},
|
|
433
|
-
get has_setup_media_session() {
|
|
434
|
-
return has_setup_media_session
|
|
435
|
-
},
|
|
436
|
-
get formatted_duration() {
|
|
437
|
-
return formatted_duration
|
|
438
|
-
},
|
|
439
|
-
get formatted_current_time() {
|
|
440
|
-
return formatted_current_time
|
|
441
|
-
},
|
|
442
|
-
get is_loading() {
|
|
443
|
-
return is_loading
|
|
444
|
-
},
|
|
445
|
-
handle_mount,
|
|
446
|
-
handle_loaded_metadata,
|
|
447
|
-
handle_progress,
|
|
448
|
-
handle_time_update,
|
|
449
|
-
handle_rate_change,
|
|
450
|
-
handle_seeking,
|
|
451
|
-
handle_can_play,
|
|
452
|
-
seek_to_audio,
|
|
453
|
-
resize_image,
|
|
454
|
-
setup_media_session,
|
|
455
|
-
update_position_state,
|
|
456
|
-
nav_seek_backward,
|
|
457
|
-
nav_seek_forward,
|
|
458
|
-
toggle_play_pause,
|
|
459
|
-
play_audio,
|
|
460
|
-
pause_audio,
|
|
461
|
-
set_is_loading,
|
|
462
|
-
}
|
|
463
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
let { manager } = $props()
|
|
3
|
-
</script>
|
|
4
|
-
|
|
5
|
-
<div class="container">
|
|
6
|
-
<div
|
|
7
|
-
class="code_wrapper"
|
|
8
|
-
style="--br: {manager?.border_radius}rem; margin-left: {manager?.ml}rem; margin-right: {manager?.mr}rem; margin-top: {manager?.mt}rem; margin-bottom: {manager?.mb}rem;"
|
|
9
|
-
>
|
|
10
|
-
<input
|
|
11
|
-
id={`auth_code_input_${manager?.id}`}
|
|
12
|
-
class="code_input"
|
|
13
|
-
class:is_disabled={manager?.is_disabled}
|
|
14
|
-
name={manager?.name}
|
|
15
|
-
required={manager?.is_required}
|
|
16
|
-
readonly={manager?.is_read_only}
|
|
17
|
-
disabled={manager?.is_disabled}
|
|
18
|
-
type="text"
|
|
19
|
-
inputmode="numeric"
|
|
20
|
-
pattern="[0-9]*"
|
|
21
|
-
autocomplete={manager?.autocomplete}
|
|
22
|
-
value={manager?.val}
|
|
23
|
-
maxlength={6}
|
|
24
|
-
oninput={(e) => manager?.set_val(e?.target?.value)}
|
|
25
|
-
/>
|
|
26
|
-
<div class="underscores"></div>
|
|
27
|
-
</div>
|
|
28
|
-
</div>
|
|
29
|
-
|
|
30
|
-
<style>
|
|
31
|
-
.container {
|
|
32
|
-
display: flex;
|
|
33
|
-
justify-content: center;
|
|
34
|
-
}
|
|
35
|
-
.code_wrapper {
|
|
36
|
-
position: relative;
|
|
37
|
-
display: flex;
|
|
38
|
-
justify-content: center;
|
|
39
|
-
width: 24rem;
|
|
40
|
-
height: 7.5rem;
|
|
41
|
-
border-radius: 1rem;
|
|
42
|
-
background: var(--bg2);
|
|
43
|
-
}
|
|
44
|
-
.code_input {
|
|
45
|
-
position: absolute;
|
|
46
|
-
display: flex;
|
|
47
|
-
border: none;
|
|
48
|
-
border-radius: 1rem;
|
|
49
|
-
letter-spacing: 0.2ch;
|
|
50
|
-
font-size: 50px;
|
|
51
|
-
padding: 5px 0 5px 18px;
|
|
52
|
-
border-radius: var(--br);
|
|
53
|
-
background: transparent;
|
|
54
|
-
box-shadow: 0 0 0 1px var(--shadow7-t);
|
|
55
|
-
-webkit-box-shadow: 0 0 0 1px var(--shadow7-t);
|
|
56
|
-
width: 24rem;
|
|
57
|
-
height: 7.5rem;
|
|
58
|
-
}
|
|
59
|
-
.underscores {
|
|
60
|
-
position: absolute;
|
|
61
|
-
display: flex;
|
|
62
|
-
bottom: 5px;
|
|
63
|
-
left: 20px;
|
|
64
|
-
width: 24rem;
|
|
65
|
-
height: 0.5rem;
|
|
66
|
-
letter-spacing: 0.1ch;
|
|
67
|
-
font-size: 40px;
|
|
68
|
-
background: repeating-linear-gradient(90deg, var(--g6-t) 0, var(--g6-t) 1ch, transparent 0, transparent 1.5ch) 0
|
|
69
|
-
100%/ 21rem 2px no-repeat;
|
|
70
|
-
}
|
|
71
|
-
.is_disabled {
|
|
72
|
-
color: var(--g12-t);
|
|
73
|
-
}
|
|
74
|
-
input:focus-visible {
|
|
75
|
-
outline: none;
|
|
76
|
-
}
|
|
77
|
-
*:focus-visible {
|
|
78
|
-
box-shadow:
|
|
79
|
-
0 0 0 1px var(--selected-t),
|
|
80
|
-
0 0 0 2px var(--g1-t) !important;
|
|
81
|
-
-webkit-box-shadow:
|
|
82
|
-
0 0 0 1px var(--selected-t),
|
|
83
|
-
0 0 0 2px var(--g1-t) !important;
|
|
84
|
-
}
|
|
85
|
-
</style>
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { create_unique_id } from "../../client/index.js"
|
|
2
|
-
|
|
3
|
-
export function create_auth_code_input_manager(config) {
|
|
4
|
-
const id = create_unique_id(null, 20)
|
|
5
|
-
let val = $state(config?.val)
|
|
6
|
-
let name = $state(config?.name ?? "code")
|
|
7
|
-
let is_required = $state(config?.is_required ?? false)
|
|
8
|
-
let is_read_only = $state(config?.is_read_only ?? false)
|
|
9
|
-
let autocomplete = $state(config?.autocomplete ?? "one-time-code")
|
|
10
|
-
let is_valid = $state(config?.is_valid)
|
|
11
|
-
let is_disabled = $state(config?.is_disabled ?? false)
|
|
12
|
-
let border_radius = $state(config?.border_radius ?? 1)
|
|
13
|
-
let ml = $state(config?.ml ?? 0)
|
|
14
|
-
let mr = $state(config?.mr ?? 0)
|
|
15
|
-
let mt = $state(config?.mt ?? 0)
|
|
16
|
-
let mb = $state(config?.mb ?? 0)
|
|
17
|
-
|
|
18
|
-
function set_val(input) {
|
|
19
|
-
const cleaned_val = input ? input.replace(/\D+/g, "") : null
|
|
20
|
-
val = cleaned_val
|
|
21
|
-
is_valid = val && val.length == 6
|
|
22
|
-
if (config?.on_change) {
|
|
23
|
-
config?.on_change(cleaned_val)
|
|
24
|
-
}
|
|
25
|
-
if (val.length == 6 && config?.on_sixth) {
|
|
26
|
-
config?.on_sixth(cleaned_val)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function set_focus() {
|
|
31
|
-
let input_el = document?.querySelector(`#auth_code_input_${id}`)
|
|
32
|
-
if (input_el) {
|
|
33
|
-
input_el.focus()
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function init(config) {
|
|
38
|
-
val = config?.val ?? null
|
|
39
|
-
name = config?.name ?? "code"
|
|
40
|
-
is_required = config?.is_required ?? false
|
|
41
|
-
is_read_only = config?.is_read_only ?? false
|
|
42
|
-
autocomplete = config?.autocomplete ?? "one-time-code"
|
|
43
|
-
is_valid = val && val.length == 6
|
|
44
|
-
is_disabled = config?.is_disabled ?? false
|
|
45
|
-
border_radius = config?.border_radius ?? 1
|
|
46
|
-
ml = config?.ml ?? 0
|
|
47
|
-
mr = config?.mr ?? 0
|
|
48
|
-
mt = config?.mt ?? 0
|
|
49
|
-
mb = config?.mb ?? 0
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
init(config)
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
id,
|
|
56
|
-
get val() {
|
|
57
|
-
return val
|
|
58
|
-
},
|
|
59
|
-
get name() {
|
|
60
|
-
return name
|
|
61
|
-
},
|
|
62
|
-
get is_required() {
|
|
63
|
-
return is_required
|
|
64
|
-
},
|
|
65
|
-
get is_read_only() {
|
|
66
|
-
return is_read_only
|
|
67
|
-
},
|
|
68
|
-
get autocomplete() {
|
|
69
|
-
return autocomplete
|
|
70
|
-
},
|
|
71
|
-
get is_valid() {
|
|
72
|
-
return is_valid
|
|
73
|
-
},
|
|
74
|
-
get is_disabled() {
|
|
75
|
-
return is_disabled
|
|
76
|
-
},
|
|
77
|
-
get border_radius() {
|
|
78
|
-
return border_radius
|
|
79
|
-
},
|
|
80
|
-
get ml() {
|
|
81
|
-
return ml
|
|
82
|
-
},
|
|
83
|
-
get mr() {
|
|
84
|
-
return mr
|
|
85
|
-
},
|
|
86
|
-
get mt() {
|
|
87
|
-
return mt
|
|
88
|
-
},
|
|
89
|
-
get mb() {
|
|
90
|
-
return mb
|
|
91
|
-
},
|
|
92
|
-
set_val,
|
|
93
|
-
set_focus,
|
|
94
|
-
}
|
|
95
|
-
}
|