sveltekit-ui 1.1.16 → 1.1.18
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/Components/Alert/index.svelte +88 -0
- package/dist/Components/Alert/index.svelte.js +101 -0
- package/dist/Components/Audio/index.svelte +193 -0
- package/dist/Components/Audio/index.svelte.js +463 -0
- package/dist/Components/AuthCodeInput/index.svelte +85 -0
- package/dist/Components/AuthCodeInput/index.svelte.js +95 -0
- package/dist/Components/Button/index.svelte +721 -0
- package/dist/Components/Button/index.svelte.js +375 -0
- package/dist/Components/Checkbox/index.svelte +411 -0
- package/dist/Components/Checkbox/index.svelte.js +178 -0
- package/dist/Components/Code/index.svelte +23 -0
- package/dist/Components/Code/index.svelte.js +33 -0
- package/dist/Components/EmailAddress/index.svelte +22 -0
- package/dist/Components/EmailAddress/index.svelte.js +45 -0
- package/dist/Components/Eye/index.svelte +57 -0
- package/dist/Components/Icon/index.svelte +412 -0
- package/dist/Components/Icon/index.svelte.js +116 -0
- package/dist/Components/InfoBox/index.svelte +89 -0
- package/dist/Components/Json/index.svelte +60 -0
- package/dist/Components/Json/index.svelte.js +594 -0
- package/dist/Components/Link/index.svelte +47 -0
- package/dist/Components/Link/index.svelte.js +136 -0
- package/dist/Components/LoadingSuccessDiv/index.svelte +51 -0
- package/dist/Components/Location/index.svelte +79 -0
- package/dist/Components/Location/index.svelte.js +288 -0
- package/dist/Components/PhoneNumber/index.svelte +22 -0
- package/dist/Components/PhoneNumber/index.svelte.js +41 -0
- package/dist/Components/Qr/index.svelte +85 -0
- package/dist/Components/Qr/index.svelte.js +301 -0
- package/dist/Components/QrInput/index.svelte +47 -0
- package/dist/Components/QrInput/index.svelte.js +218 -0
- package/dist/Components/Slider/index.svelte +239 -0
- package/dist/Components/Slider/index.svelte.js +469 -0
- package/dist/Components/SuccessCheck/index.svelte +56 -0
- package/dist/Components/TableAdvanced/index.svelte +275 -0
- package/dist/Components/TableAdvanced/index.svelte.js +1565 -0
- package/dist/Components/TextInput/index.svelte +223 -0
- package/dist/Components/TextInput/index.svelte.js +447 -0
- package/dist/Components/Time/index.svelte +7 -0
- package/dist/Components/Time/index.svelte.js +38 -0
- package/dist/Components/VideoTBD/index.svelte +100 -0
- package/dist/Components/XPost/index.svelte +52 -0
- package/dist/Components/XPost/index.svelte.js +64 -0
- package/package.json +1 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { create_popover_manager } from "../Popover/index.svelte.js"
|
|
2
|
+
import { create_button_manager } from "../Button/index.svelte.js"
|
|
3
|
+
import { create_qr_manager } from "../Qr/index.svelte.js"
|
|
4
|
+
import { copy_to_clipboard, create_unique_id, set_closurable, set_closurable_color } from "../../client/index.js"
|
|
5
|
+
import { goto } from "$app/navigation"
|
|
6
|
+
// import { page } from "$app/state"
|
|
7
|
+
|
|
8
|
+
export function create_link_manager(config) {
|
|
9
|
+
const id = config?.id ?? create_unique_id(null, 20)
|
|
10
|
+
let popover_manager = $state(null)
|
|
11
|
+
let copy_link_button_manager = $state(null)
|
|
12
|
+
let goto_link_button_manager = $state(null)
|
|
13
|
+
let goto_link_same_tab_button_manager = $state(null)
|
|
14
|
+
let inline_goto_link_button_manager = $state(null)
|
|
15
|
+
let qr_manager = $state(null)
|
|
16
|
+
|
|
17
|
+
let href = $derived(set_closurable(config?.href, null))
|
|
18
|
+
let display_text = $derived(set_closurable(config?.display_text, null))
|
|
19
|
+
let text_color = $derived(set_closurable_color(config?.text_color, null))
|
|
20
|
+
let is_internal_link = $derived(href && href.startsWith("/"))
|
|
21
|
+
// let is_internal_link = $derived(new URL(href, page?.url?.origin)?.origin === page?.url?.origin)
|
|
22
|
+
let is_show_preview = $derived(set_closurable(config?.is_show_preview, !is_internal_link))
|
|
23
|
+
|
|
24
|
+
function handle_a_click(e) {
|
|
25
|
+
console.log("handle_a_click", e)
|
|
26
|
+
e.preventDefault()
|
|
27
|
+
if (is_internal_link) {
|
|
28
|
+
goto(href)
|
|
29
|
+
} else if (is_show_preview) {
|
|
30
|
+
popover_manager.open()
|
|
31
|
+
} else {
|
|
32
|
+
open_link()
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function open_link(is_open_same_tab = false) {
|
|
37
|
+
if (is_internal_link) {
|
|
38
|
+
goto(href)
|
|
39
|
+
} else {
|
|
40
|
+
if (typeof config?.on_goto_external_link == "function") {
|
|
41
|
+
config?.on_goto_external_link(href)
|
|
42
|
+
}
|
|
43
|
+
if (is_open_same_tab) {
|
|
44
|
+
window.location.href = href
|
|
45
|
+
} else {
|
|
46
|
+
window.open(href, "_blank", "noopener,noreferrer")
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function init(config) {
|
|
52
|
+
popover_manager = create_popover_manager({
|
|
53
|
+
type: "dropdown",
|
|
54
|
+
header: "Link Preview",
|
|
55
|
+
target_width: 400,
|
|
56
|
+
target_height: 460,
|
|
57
|
+
anchor_id: () => `link_${id}`,
|
|
58
|
+
})
|
|
59
|
+
copy_link_button_manager = create_button_manager({
|
|
60
|
+
type: "outlined",
|
|
61
|
+
text: "Copy Link",
|
|
62
|
+
is_success_animation: true,
|
|
63
|
+
support_icon: "clipboard",
|
|
64
|
+
text_align: "left",
|
|
65
|
+
on_click: () => copy_to_clipboard(href),
|
|
66
|
+
})
|
|
67
|
+
goto_link_button_manager = create_button_manager({
|
|
68
|
+
support_icon: "link",
|
|
69
|
+
text: "Open Link In New Tab",
|
|
70
|
+
text_align: "left",
|
|
71
|
+
on_click: () => open_link(),
|
|
72
|
+
})
|
|
73
|
+
goto_link_same_tab_button_manager = create_button_manager({
|
|
74
|
+
support_icon: "link_internal",
|
|
75
|
+
text: "Open Link In Same Tab",
|
|
76
|
+
text_align: "left",
|
|
77
|
+
on_click: () => open_link(true),
|
|
78
|
+
})
|
|
79
|
+
inline_goto_link_button_manager = create_button_manager({
|
|
80
|
+
type: "soft",
|
|
81
|
+
min_height: 2,
|
|
82
|
+
ml: 0.5,
|
|
83
|
+
border_radius: 0.5,
|
|
84
|
+
pt: 0,
|
|
85
|
+
is_uniform: true,
|
|
86
|
+
support_icon: () => (is_internal_link ? "link_internnal" : "link"),
|
|
87
|
+
on_click: () => open_link(),
|
|
88
|
+
})
|
|
89
|
+
qr_manager = create_qr_manager({
|
|
90
|
+
data: href,
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
init(config)
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
id,
|
|
97
|
+
get popover_manager() {
|
|
98
|
+
return popover_manager
|
|
99
|
+
},
|
|
100
|
+
get is_internal_link() {
|
|
101
|
+
return is_internal_link
|
|
102
|
+
},
|
|
103
|
+
get is_show_preview() {
|
|
104
|
+
return is_show_preview
|
|
105
|
+
},
|
|
106
|
+
get href() {
|
|
107
|
+
return href
|
|
108
|
+
},
|
|
109
|
+
get copy_link_button_manager() {
|
|
110
|
+
return copy_link_button_manager
|
|
111
|
+
},
|
|
112
|
+
get goto_link_button_manager() {
|
|
113
|
+
return goto_link_button_manager
|
|
114
|
+
},
|
|
115
|
+
get goto_link_same_tab_button_manager() {
|
|
116
|
+
return goto_link_same_tab_button_manager
|
|
117
|
+
},
|
|
118
|
+
get inline_goto_link_button_manager() {
|
|
119
|
+
return inline_goto_link_button_manager
|
|
120
|
+
},
|
|
121
|
+
get href() {
|
|
122
|
+
return href
|
|
123
|
+
},
|
|
124
|
+
get display_text() {
|
|
125
|
+
return display_text
|
|
126
|
+
},
|
|
127
|
+
get text_color() {
|
|
128
|
+
return text_color
|
|
129
|
+
},
|
|
130
|
+
get qr_manager() {
|
|
131
|
+
return qr_manager
|
|
132
|
+
},
|
|
133
|
+
handle_a_click,
|
|
134
|
+
open_link,
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import LoadingWheel from "../LoadingWheel/index.svelte"
|
|
3
|
+
import SuccessCheck from "../SuccessCheck/index.svelte"
|
|
4
|
+
import ErrorX from "../ErrorX/index.svelte"
|
|
5
|
+
|
|
6
|
+
let { message, show_screen = "loading", size = 8, ml = 1, mr = 1, mt = 1, mb = 1, flex = 1 } = $props()
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<div
|
|
10
|
+
class="success_container"
|
|
11
|
+
style="margin-left: {ml}rem; margin-right: {mr}rem; margin-top: {mt}rem; margin-bottom: {mb}rem;
|
|
12
|
+
flex: {flex};"
|
|
13
|
+
>
|
|
14
|
+
<div class="check_container">
|
|
15
|
+
<div class="icon_frame" style="--size: {size}rem;">
|
|
16
|
+
{#if show_screen === "loading"}
|
|
17
|
+
<LoadingWheel />
|
|
18
|
+
{:else if show_screen === "success"}
|
|
19
|
+
<SuccessCheck color="var(--success-t)" />
|
|
20
|
+
{:else if show_screen === "error"}
|
|
21
|
+
<ErrorX />
|
|
22
|
+
{/if}
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
{#if message}
|
|
26
|
+
<h3 class="message">{message}</h3>
|
|
27
|
+
{/if}
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
<style>
|
|
31
|
+
.success_container {
|
|
32
|
+
display: flex;
|
|
33
|
+
flex-direction: column;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
text-align: center;
|
|
36
|
+
}
|
|
37
|
+
.check_container {
|
|
38
|
+
display: flex;
|
|
39
|
+
justify-content: center;
|
|
40
|
+
}
|
|
41
|
+
.icon_frame {
|
|
42
|
+
width: var(--size);
|
|
43
|
+
height: var(--size);
|
|
44
|
+
}
|
|
45
|
+
.message {
|
|
46
|
+
color: var(--g4-t);
|
|
47
|
+
margin-top: 2rem;
|
|
48
|
+
font-weight: 500;
|
|
49
|
+
font-size: 2rem;
|
|
50
|
+
}
|
|
51
|
+
</style>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Popover from "../Popover/index.svelte"
|
|
3
|
+
import Button from "../Button/index.svelte"
|
|
4
|
+
import LoadingWheel from "../LoadingWheel/index.svelte"
|
|
5
|
+
import { slide } from "svelte/transition"
|
|
6
|
+
import { intersection_observer } from "../../actions/index.js"
|
|
7
|
+
|
|
8
|
+
let { manager } = $props()
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
{#snippet location_content()}
|
|
12
|
+
<div class="container" style="height: {manager?.height}; width: {manager?.width}; max-width: 100%;">
|
|
13
|
+
<div class="loading_container" style="height: {manager?.height}; width: {manager?.width}; max-width: 100%;">
|
|
14
|
+
<div style="display: flex; flex-direction: column; gap: 1rem; justify-content: center; align-items: center;">
|
|
15
|
+
<LoadingWheel size={8} />
|
|
16
|
+
<p>Loading Map</p>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
<div use:intersection_observer onappeared={() => manager?.initialize_map()}></div>
|
|
20
|
+
{#key manager?.id}
|
|
21
|
+
<div id="map_{manager?.id}" class="map" style="height: {manager?.height}; max-width: 100%;"></div>
|
|
22
|
+
{/key}
|
|
23
|
+
</div>
|
|
24
|
+
{/snippet}
|
|
25
|
+
|
|
26
|
+
{#if manager?.is_popover}
|
|
27
|
+
{#if manager?.is_inline}
|
|
28
|
+
<div style="display: flex; gap: .5rem;">
|
|
29
|
+
<p>{manager?.val?.name}</p>
|
|
30
|
+
<Button manager={manager?.toggle_popover_manager} />
|
|
31
|
+
</div>
|
|
32
|
+
{/if}
|
|
33
|
+
<Popover manager={manager?.popover_manager}>
|
|
34
|
+
{#snippet content()}
|
|
35
|
+
{@render location_content()}
|
|
36
|
+
{/snippet}
|
|
37
|
+
</Popover>
|
|
38
|
+
{:else}
|
|
39
|
+
{@render location_content()}
|
|
40
|
+
{/if}
|
|
41
|
+
|
|
42
|
+
<style>
|
|
43
|
+
@-webkit-keyframes scale-and-fadein {
|
|
44
|
+
0% {
|
|
45
|
+
-webkit-transform: scale(0.2);
|
|
46
|
+
opacity: 0;
|
|
47
|
+
}
|
|
48
|
+
100% {
|
|
49
|
+
-webkit-transform: scale(1);
|
|
50
|
+
opacity: 1;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
@keyframes scale-and-fadein {
|
|
54
|
+
0% {
|
|
55
|
+
transform: scale(0.2);
|
|
56
|
+
opacity: 0;
|
|
57
|
+
}
|
|
58
|
+
100% {
|
|
59
|
+
transform: scale(1);
|
|
60
|
+
opacity: 1;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
.container {
|
|
64
|
+
display: grid;
|
|
65
|
+
grid-template-areas: "stack";
|
|
66
|
+
animation: scale-and-fadein 0.3s;
|
|
67
|
+
}
|
|
68
|
+
.map {
|
|
69
|
+
grid-area: stack;
|
|
70
|
+
border-radius: 1rem;
|
|
71
|
+
overflow: hidden;
|
|
72
|
+
}
|
|
73
|
+
.loading_container {
|
|
74
|
+
grid-area: stack;
|
|
75
|
+
place-content: center;
|
|
76
|
+
background-color: var(--shadow2-t);
|
|
77
|
+
border-radius: 1rem;
|
|
78
|
+
}
|
|
79
|
+
</style>
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { create_unique_id, set_closurable } from "../../client/index.js"
|
|
2
|
+
import { create_popover_manager } from "../Popover/index.svelte.js"
|
|
3
|
+
import { create_button_manager } from "../Button/index.svelte.js"
|
|
4
|
+
import { browser } from "$app/environment"
|
|
5
|
+
|
|
6
|
+
export function create_location_manager(config) {
|
|
7
|
+
const id = create_unique_id(null, 20)
|
|
8
|
+
|
|
9
|
+
let popover_manager = $state(null)
|
|
10
|
+
let toggle_popover_manager = $state(null)
|
|
11
|
+
|
|
12
|
+
let height = $derived(
|
|
13
|
+
set_closurable(config?.height, null) ? `${set_closurable(config?.height, null)}rem` : "min(40rem, 50vh)"
|
|
14
|
+
)
|
|
15
|
+
let width = $derived(
|
|
16
|
+
set_closurable(config?.width, null) ? `${set_closurable(config?.width, null)}rem` : "clamp(60rem, 80vw, 100%)"
|
|
17
|
+
)
|
|
18
|
+
let is_popover = $derived(set_closurable(config?.is_popover, false))
|
|
19
|
+
let mapkit_js_token = $derived(set_closurable(config?.mapkit_js_token, null))
|
|
20
|
+
let is_dark_color_scheme = $derived(set_closurable(config?.is_dark_color_scheme, true))
|
|
21
|
+
let is_inline = $derived(set_closurable(config?.is_inline ?? config?.is_popover, true))
|
|
22
|
+
|
|
23
|
+
let val = $state(null)
|
|
24
|
+
let map = $state(null)
|
|
25
|
+
|
|
26
|
+
let mapkit_load_promise = $state(null)
|
|
27
|
+
async function load_mapkit_script() {
|
|
28
|
+
if (!mapkit_load_promise) {
|
|
29
|
+
mapkit_load_promise = new Promise(async (resolve, reject) => {
|
|
30
|
+
if (browser && !document?.querySelector('script[src="https://cdn.apple-mapkit.com/mk/5.x.x/mapkit.core.js"]')) {
|
|
31
|
+
window.init_map_kit = () => {
|
|
32
|
+
delete window.init_map_kit
|
|
33
|
+
window.init_map_kit_loaded = true
|
|
34
|
+
resolve()
|
|
35
|
+
}
|
|
36
|
+
const script = document.createElement("script")
|
|
37
|
+
script.src = "https://cdn.apple-mapkit.com/mk/5.x.x/mapkit.core.js"
|
|
38
|
+
script.crossOrigin = "anonymous"
|
|
39
|
+
script.async = true
|
|
40
|
+
script.setAttribute("data-callback", "init_map_kit")
|
|
41
|
+
script.setAttribute("data-libraries", "full-map,services")
|
|
42
|
+
script.setAttribute("data-token", mapkit_js_token)
|
|
43
|
+
document.head.appendChild(script)
|
|
44
|
+
} else {
|
|
45
|
+
let attempt_count = 0
|
|
46
|
+
const max_attempts = 50
|
|
47
|
+
const check_init_mapkit = setInterval(() => {
|
|
48
|
+
attempt_count++
|
|
49
|
+
if (window.init_map_kit_loaded) {
|
|
50
|
+
clearInterval(check_init_mapkit)
|
|
51
|
+
resolve()
|
|
52
|
+
} else if (attempt_count > max_attempts) {
|
|
53
|
+
clearInterval(check_init_mapkit)
|
|
54
|
+
reject(new Error("MapKit initialization timeout"))
|
|
55
|
+
}
|
|
56
|
+
}, 100)
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
return mapkit_load_promise
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function initialize_map() {
|
|
64
|
+
if (!browser) {
|
|
65
|
+
console.log("browser is not defined")
|
|
66
|
+
return
|
|
67
|
+
}
|
|
68
|
+
await load_mapkit_script()
|
|
69
|
+
if (!window.mapkit) {
|
|
70
|
+
console.log("mapkit is not defined")
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
const map_div = document?.querySelector(`#map_${id}`)
|
|
74
|
+
if (!map_div) {
|
|
75
|
+
console.log("map div not found")
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
const { center_lat, center_lng, lat_span, lng_span } = get_map_region(val)
|
|
79
|
+
const center = new mapkit.Coordinate(center_lat, center_lng)
|
|
80
|
+
const span = new mapkit.CoordinateSpan(lat_span, lng_span)
|
|
81
|
+
const initial_region = new mapkit.CoordinateRegion(center, span)
|
|
82
|
+
if (!map) {
|
|
83
|
+
map = new mapkit.Map(`map_${id}`)
|
|
84
|
+
}
|
|
85
|
+
map.annotations = []
|
|
86
|
+
map.region = initial_region
|
|
87
|
+
map.colorScheme = is_dark_color_scheme ? "dark" : "light"
|
|
88
|
+
add_map_vals(val)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function get_map_region(val) {
|
|
92
|
+
let center_lat, center_lng, lat_span, lng_span
|
|
93
|
+
if (Array.isArray(val) && val.length > 0) {
|
|
94
|
+
const lats = val.map((item) => item?.latitude).filter((latitude) => latitude != null)
|
|
95
|
+
const lngs = val.map((item) => item?.longitude).filter((longitude) => longitude != null)
|
|
96
|
+
if (lats.length && lngs.length) {
|
|
97
|
+
const min_lat = Math.min(...lats)
|
|
98
|
+
const max_lat = Math.max(...lats)
|
|
99
|
+
const min_lng = Math.min(...lngs)
|
|
100
|
+
const max_lng = Math.max(...lngs)
|
|
101
|
+
center_lat = (min_lat + max_lat) / 2
|
|
102
|
+
center_lng = (min_lng + max_lng) / 2
|
|
103
|
+
lat_span = (max_lat - min_lat) * 1.2 || 0.1
|
|
104
|
+
lng_span = (max_lng - min_lng) * 1.2 || 0.1
|
|
105
|
+
} else {
|
|
106
|
+
center_lat = 37.3316850890998
|
|
107
|
+
center_lng = -122.030067374026
|
|
108
|
+
lat_span = 0.1
|
|
109
|
+
lng_span = 0.1
|
|
110
|
+
}
|
|
111
|
+
} else {
|
|
112
|
+
center_lat = val?.latitude ?? 37.3316850890998
|
|
113
|
+
center_lng = val?.longitude ?? -122.030067374026
|
|
114
|
+
lat_span = 0.1
|
|
115
|
+
lng_span = 0.1
|
|
116
|
+
}
|
|
117
|
+
return { center_lat, center_lng, lat_span, lng_span }
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function add_map_val(val_item, is_selected = false) {
|
|
121
|
+
if (val_item?.type === "route") {
|
|
122
|
+
if (val_item.from && val_item.to) {
|
|
123
|
+
if (val_item?.method == "path") {
|
|
124
|
+
add_custom_route(map, val_item)
|
|
125
|
+
} else {
|
|
126
|
+
add_detailed_route(map, {
|
|
127
|
+
from: new mapkit.Coordinate(val_item.from.latitude, val_item.from.longitude),
|
|
128
|
+
to: new mapkit.Coordinate(val_item.to.latitude, val_item.to.longitude),
|
|
129
|
+
stroke_color: val_item.stroke_color || "#000",
|
|
130
|
+
line_width: val_item.line_width || 3,
|
|
131
|
+
})
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
} else if (val_item?.place_id) {
|
|
135
|
+
const lookup = new mapkit.PlaceLookup()
|
|
136
|
+
lookup.getPlace(val_item.place_id, (error, place) => {
|
|
137
|
+
if (error) {
|
|
138
|
+
console.error("place lookup error:", error)
|
|
139
|
+
return
|
|
140
|
+
}
|
|
141
|
+
const options = { title: val_item.name || place.formattedAddress }
|
|
142
|
+
const marker = new mapkit.PlaceAnnotation(place, options)
|
|
143
|
+
map.addAnnotation(marker)
|
|
144
|
+
marker.selectionAccessory = new mapkit.PlaceSelectionAccessory()
|
|
145
|
+
if (is_selected) {
|
|
146
|
+
marker.selected = true
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
} else if (val_item?.name && val_item?.latitude && val_item?.longitude) {
|
|
150
|
+
const coord = new mapkit.Coordinate(val_item.latitude, val_item.longitude)
|
|
151
|
+
const marker = new mapkit.MarkerAnnotation(coord, { title: val_item.name })
|
|
152
|
+
map.addAnnotation(marker)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function add_map_vals(map_val) {
|
|
157
|
+
if (Array.isArray(map_val) && map_val.length > 0) {
|
|
158
|
+
map_val.forEach((item) => add_map_val(item, false))
|
|
159
|
+
} else if (map_val) {
|
|
160
|
+
add_map_val(map_val, true)
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function add_detailed_route(map, leg) {
|
|
165
|
+
const directions = new mapkit.Directions()
|
|
166
|
+
const request = {
|
|
167
|
+
origin: leg.from,
|
|
168
|
+
destination: leg.to,
|
|
169
|
+
transportType: mapkit.Directions.Transport.Automobile,
|
|
170
|
+
}
|
|
171
|
+
directions.route(request, (error, response) => {
|
|
172
|
+
if (error) {
|
|
173
|
+
console.error("directions error for leg", leg, error)
|
|
174
|
+
return
|
|
175
|
+
}
|
|
176
|
+
const route = response.routes[0]
|
|
177
|
+
if (route.polyline) {
|
|
178
|
+
route.polyline.style = new mapkit.Style({
|
|
179
|
+
strokeColor: leg.stroke_color || "#0000ff",
|
|
180
|
+
lineWidth: leg.line_width || 3,
|
|
181
|
+
})
|
|
182
|
+
map.addOverlay(route.polyline)
|
|
183
|
+
} else {
|
|
184
|
+
console.warn("no polyline found for route", route)
|
|
185
|
+
}
|
|
186
|
+
})
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function add_custom_route(map, leg) {
|
|
190
|
+
const coords = []
|
|
191
|
+
if (leg.from && typeof leg.from === "object" && leg.from.latitude != null && leg.from.longitude != null) {
|
|
192
|
+
coords.push(new mapkit.Coordinate(leg.from.latitude, leg.from.longitude))
|
|
193
|
+
} else {
|
|
194
|
+
console.warn("invalid 'from' coordinate", leg.from)
|
|
195
|
+
}
|
|
196
|
+
if (Array.isArray(leg.way_points)) {
|
|
197
|
+
leg.way_points.forEach((wp) => {
|
|
198
|
+
if (wp && typeof wp === "object" && wp.latitude != null && wp.longitude != null) {
|
|
199
|
+
coords.push(new mapkit.Coordinate(wp.latitude, wp.longitude))
|
|
200
|
+
} else {
|
|
201
|
+
console.warn("invalid waypoint object: missing coordinates", wp)
|
|
202
|
+
}
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
if (leg.to && typeof leg.to === "object" && leg.to.latitude != null && leg.to.longitude != null) {
|
|
206
|
+
coords.push(new mapkit.Coordinate(leg.to.latitude, leg.to.longitude))
|
|
207
|
+
} else {
|
|
208
|
+
console.warn("invalid 'to' coordinate", leg.to)
|
|
209
|
+
}
|
|
210
|
+
const overlay_style = new mapkit.Style({
|
|
211
|
+
strokeColor: leg.stroke_color || "oklch(70% 0.3 210)",
|
|
212
|
+
lineWidth: leg.line_width || 3,
|
|
213
|
+
})
|
|
214
|
+
const polyline = new mapkit.PolylineOverlay(coords, { style: overlay_style })
|
|
215
|
+
map.addOverlay(polyline)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function set_val(input) {
|
|
219
|
+
val = input
|
|
220
|
+
if (map) {
|
|
221
|
+
initialize_map()
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function init(config) {
|
|
226
|
+
val = config?.val
|
|
227
|
+
popover_manager = create_popover_manager({
|
|
228
|
+
type: "center",
|
|
229
|
+
target_height: config?.height ?? 440,
|
|
230
|
+
target_width: config?.width ?? 600,
|
|
231
|
+
on_open: () => {
|
|
232
|
+
if (!map) {
|
|
233
|
+
setTimeout(() => {
|
|
234
|
+
initialize_map()
|
|
235
|
+
}, 20)
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
})
|
|
239
|
+
toggle_popover_manager = create_button_manager({
|
|
240
|
+
type: "soft",
|
|
241
|
+
support_icon: "pinpoint",
|
|
242
|
+
is_uniform: true,
|
|
243
|
+
min_height: 2.2,
|
|
244
|
+
icon_size: 1.4,
|
|
245
|
+
icon_sw: 40,
|
|
246
|
+
border_radius: 0.5,
|
|
247
|
+
popover_target: () => `popover_${popover_manager?.id}`,
|
|
248
|
+
})
|
|
249
|
+
if (!is_popover) {
|
|
250
|
+
initialize_map()
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
init(config)
|
|
255
|
+
|
|
256
|
+
return {
|
|
257
|
+
id,
|
|
258
|
+
get val() {
|
|
259
|
+
return val
|
|
260
|
+
},
|
|
261
|
+
get map() {
|
|
262
|
+
return map
|
|
263
|
+
},
|
|
264
|
+
get is_popover() {
|
|
265
|
+
return is_popover
|
|
266
|
+
},
|
|
267
|
+
get is_inline() {
|
|
268
|
+
return is_inline
|
|
269
|
+
},
|
|
270
|
+
get popover_manager() {
|
|
271
|
+
return popover_manager
|
|
272
|
+
},
|
|
273
|
+
get toggle_popover_manager() {
|
|
274
|
+
return toggle_popover_manager
|
|
275
|
+
},
|
|
276
|
+
get height() {
|
|
277
|
+
return height
|
|
278
|
+
},
|
|
279
|
+
get width() {
|
|
280
|
+
return width
|
|
281
|
+
},
|
|
282
|
+
get mapkit_js_token() {
|
|
283
|
+
return mapkit_js_token
|
|
284
|
+
},
|
|
285
|
+
initialize_map,
|
|
286
|
+
set_val,
|
|
287
|
+
}
|
|
288
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Button from "../Button/index.svelte"
|
|
3
|
+
|
|
4
|
+
let { manager } = $props()
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<div class="container">
|
|
8
|
+
{#if manager?.phone_number_to_use}
|
|
9
|
+
<p>{manager?.phone_number_to_use}</p>
|
|
10
|
+
<Button manager={manager?.button_manager} />
|
|
11
|
+
{:else}
|
|
12
|
+
<p>-</p>
|
|
13
|
+
{/if}
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<style>
|
|
17
|
+
.container {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex: 0;
|
|
20
|
+
gap: 0.5rem;
|
|
21
|
+
}
|
|
22
|
+
</style>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { create_button_manager } from "../Button/index.svelte.js"
|
|
2
|
+
import { set_closurable } from "../../client/index.js"
|
|
3
|
+
|
|
4
|
+
export function create_phone_number_manager(config) {
|
|
5
|
+
let val = $derived(set_closurable(config?.val, null))
|
|
6
|
+
let main_number = $derived(set_closurable(config?.main_number, null))
|
|
7
|
+
let country_code = $derived(set_closurable(config?.country_code, null))
|
|
8
|
+
|
|
9
|
+
let phone_number_to_use = $derived(
|
|
10
|
+
val
|
|
11
|
+
? typeof val == "object"
|
|
12
|
+
? `${val?.country_code}${val?.main_number}`
|
|
13
|
+
: val
|
|
14
|
+
: country_code || main_number
|
|
15
|
+
? `${country_code}${main_number}`
|
|
16
|
+
: null
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
let button_manager = $state(
|
|
20
|
+
create_button_manager({
|
|
21
|
+
type: "soft",
|
|
22
|
+
pl: 0.2,
|
|
23
|
+
pr: 0.2,
|
|
24
|
+
support_icon: "link",
|
|
25
|
+
icon_size: 1.5,
|
|
26
|
+
on_click: () => call_number(),
|
|
27
|
+
})
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
function call_number() {
|
|
31
|
+
Object.assign(document.createElement("a"), {
|
|
32
|
+
href: "tel:" + phone_number_to_use,
|
|
33
|
+
}).click()
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
get phone_number_to_use() {
|
|
37
|
+
return phone_number_to_use
|
|
38
|
+
},
|
|
39
|
+
button_manager,
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Button from "../Button/index.svelte"
|
|
3
|
+
import TextInput from "../TextInput/index.svelte"
|
|
4
|
+
import Dropdown from "../Dropdown/index.svelte"
|
|
5
|
+
import LoadingWheel from "../LoadingWheel/index.svelte"
|
|
6
|
+
import InfoBox from "../InfoBox/index.svelte"
|
|
7
|
+
import { onMount } from "svelte"
|
|
8
|
+
|
|
9
|
+
let { manager } = $props()
|
|
10
|
+
|
|
11
|
+
onMount(() => {
|
|
12
|
+
if (typeof manager?.on_mount == "function") {
|
|
13
|
+
manager?.on_mount()
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<div style="display: flex; flex-direction: column; gap: .5rem;">
|
|
19
|
+
<div
|
|
20
|
+
class="qr_wrap"
|
|
21
|
+
style="--base: {manager?.size}px; --scale: {manager?.scale}; --target: calc(var(--base) * var(--scale));"
|
|
22
|
+
>
|
|
23
|
+
<div class="qr_fit">
|
|
24
|
+
<div
|
|
25
|
+
class="qr_container"
|
|
26
|
+
style="
|
|
27
|
+
width: var(--base);
|
|
28
|
+
height: var(--base);
|
|
29
|
+
background-color: {manager?.background_color};
|
|
30
|
+
border-radius: {manager?.border_radius}rem;
|
|
31
|
+
box-shadow: 0 0 0 {manager?.border_width}px {manager?.border_color};
|
|
32
|
+
"
|
|
33
|
+
>
|
|
34
|
+
<div style="grid-area: stack;" id={`qr_${manager?.id}`}></div>
|
|
35
|
+
{#if !manager?.is_loaded}
|
|
36
|
+
<div class="load"><LoadingWheel color={"var(--g14-t)"} sw={0.4} /></div>
|
|
37
|
+
{/if}
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
{#if manager?.is_show_copy}
|
|
42
|
+
<div style="display: flex; flex-wrap: wrap; gap: .5rem; max-width: 30rem;">
|
|
43
|
+
<span
|
|
44
|
+
style="margin: 0; padding: 0 1rem; display: grid; place-content: center; border-radius: 1rem; border: 1px solid var(--shadow4-t);"
|
|
45
|
+
>{manager?.data}</span
|
|
46
|
+
>
|
|
47
|
+
<Button manager={manager?.copy_button_manager} />
|
|
48
|
+
</div>
|
|
49
|
+
{/if}
|
|
50
|
+
{#if manager?.is_show_download}
|
|
51
|
+
<div style="display: flex; flex-wrap: wrap; gap: .5rem; max-width: 30rem;">
|
|
52
|
+
<Dropdown manager={manager?.extention_dropdown_manager} />
|
|
53
|
+
<Button manager={manager?.download_button_manager} />
|
|
54
|
+
</div>
|
|
55
|
+
{/if}
|
|
56
|
+
<InfoBox message={manager?.error_message} />
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<style>
|
|
60
|
+
.qr_container {
|
|
61
|
+
aspect-ratio: 1;
|
|
62
|
+
overflow: hidden;
|
|
63
|
+
display: grid;
|
|
64
|
+
grid-template-areas: "stack";
|
|
65
|
+
}
|
|
66
|
+
.qr_wrap {
|
|
67
|
+
width: var(--target);
|
|
68
|
+
height: var(--target);
|
|
69
|
+
position: relative;
|
|
70
|
+
}
|
|
71
|
+
.qr_fit {
|
|
72
|
+
position: absolute;
|
|
73
|
+
inset: 0;
|
|
74
|
+
width: var(--base);
|
|
75
|
+
height: var(--base);
|
|
76
|
+
transform: scale(var(--scale));
|
|
77
|
+
transform-origin: top left;
|
|
78
|
+
}
|
|
79
|
+
.load {
|
|
80
|
+
grid-area: stack;
|
|
81
|
+
width: 50%;
|
|
82
|
+
height: 50%;
|
|
83
|
+
margin: auto;
|
|
84
|
+
}
|
|
85
|
+
</style>
|