sveltekit-ui 1.0.6 → 1.0.8
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/ContentInput/index.svelte.js +1 -0
- package/dist/Components/FunctionInput/Node/helpers/Field/index.svelte.js +0 -1
- package/dist/Components/FunctionInput/Node/index.svelte.js +49 -45
- package/dist/Components/FunctionInput/index.svelte +3 -3
- package/dist/Components/FunctionInput/index.svelte.js +50 -50
- package/dist/Components/Location/index.svelte +5 -11
- package/dist/Components/Location/index.svelte.js +9 -13
- package/dist/Components/LocationInput/index.svelte +8 -11
- package/dist/Components/LocationInput/index.svelte.js +16 -1
- package/dist/client/types/index.js +2019 -1897
- package/package.json +5 -5
- package/src/lib/Components/ContentInput/index.svelte.js +1 -0
- package/src/lib/Components/FunctionInput/Node/helpers/Field/index.svelte.js +0 -1
- package/src/lib/Components/FunctionInput/Node/index.svelte.js +49 -45
- package/src/lib/Components/FunctionInput/index.svelte +3 -3
- package/src/lib/Components/FunctionInput/index.svelte.js +50 -50
- package/src/lib/Components/Location/index.svelte +5 -11
- package/src/lib/Components/Location/index.svelte.js +9 -13
- package/src/lib/Components/LocationInput/index.svelte +8 -11
- package/src/lib/Components/LocationInput/index.svelte.js +16 -1
- package/src/lib/client/types/index.js +2019 -1897
- package/src/routes/[component]/+page.svelte +2 -0
- package/src/routes/[component]/Showcase/FunctionInput/index.svelte +6 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sveltekit-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "A SvelteKit UI component library for building modern web applications",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -19,19 +19,19 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"context-filter-polyfill": "^0.3.23",
|
|
21
21
|
"qr-code-styling": "^1.9.2",
|
|
22
|
-
"svelte": "^5.35.
|
|
22
|
+
"svelte": "^5.35.5"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"@sveltejs/kit": "^2.22.2"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@sveltejs/adapter-vercel": "^5.7.2",
|
|
29
|
-
"@sveltejs/kit": "^2.22.
|
|
29
|
+
"@sveltejs/kit": "^2.22.5",
|
|
30
30
|
"@sveltejs/package": "^2.3.12",
|
|
31
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
31
|
+
"@sveltejs/vite-plugin-svelte": "^6.0.0",
|
|
32
32
|
"@vercel/analytics": "^1.5.0",
|
|
33
33
|
"typescript": "^5.8.3",
|
|
34
|
-
"vite": "^7.0.
|
|
34
|
+
"vite": "^7.0.4"
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://www.sveltekit-ui.com",
|
|
37
37
|
"keywords": [
|
|
@@ -134,6 +134,7 @@ export function create_content_input_manager(config) {
|
|
|
134
134
|
selector_id: element?.selector_id,
|
|
135
135
|
val: element?.attributes,
|
|
136
136
|
on_finish: (input) => {
|
|
137
|
+
console.log("on_finish_attribute", input)
|
|
137
138
|
attributes_input.popover_manager.close()
|
|
138
139
|
set_element_attributes(element?.selector_id, input)
|
|
139
140
|
},
|
|
@@ -7,31 +7,56 @@ import { create_field_manager } from "$lib/Components/FunctionInput/Node/helpers
|
|
|
7
7
|
export function create_node_manager(config) {
|
|
8
8
|
console.log("create_node_man", config)
|
|
9
9
|
let node_structure = $state(null)
|
|
10
|
+
let is_clickable_only = $state(false)
|
|
11
|
+
let node_path = $state(null)
|
|
12
|
+
let node_types = $state(null)
|
|
13
|
+
let node_type = $state(null)
|
|
14
|
+
let node_value = $state(null)
|
|
15
|
+
let node_categories = $state(null)
|
|
10
16
|
|
|
11
17
|
let preview_text = $derived(
|
|
12
|
-
`${
|
|
13
|
-
config?.node_types?.[config?.node_type]?.output?.type ?? "void"
|
|
14
|
-
})`
|
|
18
|
+
`${node_type}(${node_types?.[node_type]?.input?.type})→(${node_types?.[node_type]?.output?.type ?? "void"})`
|
|
15
19
|
)
|
|
16
20
|
|
|
17
|
-
let full_node_type = $derived(
|
|
18
|
-
let h = $derived(
|
|
21
|
+
let full_node_type = $derived(node_types?.[node_type])
|
|
22
|
+
let h = $derived(node_categories?.[node_types?.[node_type]?.category]?.h || 4)
|
|
19
23
|
|
|
20
|
-
function
|
|
21
|
-
|
|
24
|
+
function handle_drag_start(e) {
|
|
25
|
+
if (is_clickable_only || node_path == "main") {
|
|
26
|
+
e.preventDefault()
|
|
27
|
+
} else if (typeof config?.handle_node_drag_start == "function") {
|
|
28
|
+
config?.handle_node_drag_start()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function handle_drag_end(e) {
|
|
33
|
+
if (is_clickable_only) {
|
|
34
|
+
e.preventDefault()
|
|
35
|
+
} else if (typeof config?.handle_node_drag_start == "function") {
|
|
36
|
+
config?.handle_node_drag_end()
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function init(config) {
|
|
41
|
+
node_categories = config?.node_categories
|
|
42
|
+
node_path = config?.node_path
|
|
43
|
+
node_types = config?.node_types
|
|
44
|
+
node_type = config?.node_type
|
|
45
|
+
node_value = config?.node_value
|
|
46
|
+
is_clickable_only = !!config?.is_clickable_only
|
|
22
47
|
let node_structure_loc = []
|
|
23
48
|
if (Array.isArray(full_node_type?.node_structure)) {
|
|
24
49
|
for (let i = 0; i < full_node_type?.node_structure.length; i++) {
|
|
25
50
|
let node_item = deep_copy(full_node_type.node_structure?.[i])
|
|
26
51
|
if (node_item?.ui_type == "stack") {
|
|
27
52
|
node_item.stack_area_manager = create_stack_area_manager({
|
|
28
|
-
parent_node_type:
|
|
29
|
-
node_path: [...(Array.isArray(
|
|
53
|
+
parent_node_type: node_type,
|
|
54
|
+
node_path: [...(Array.isArray(node_path) ? node_path : []), node_item?.field].filter(
|
|
30
55
|
(item) => item !== null && item !== undefined
|
|
31
56
|
),
|
|
32
|
-
node_type:
|
|
33
|
-
node_value:
|
|
34
|
-
node_types:
|
|
57
|
+
node_type: node_value?.[node_item?.field]?.type,
|
|
58
|
+
node_value: node_value?.[node_item?.field]?.value,
|
|
59
|
+
node_types: node_types,
|
|
35
60
|
is_preview: false,
|
|
36
61
|
drag_or_select_node: config?.drag_or_select_node,
|
|
37
62
|
handle_node_drag_start: config?.handle_node_drag_start,
|
|
@@ -43,9 +68,9 @@ export function create_node_manager(config) {
|
|
|
43
68
|
if (node_item[j]?.ui_type == "input") {
|
|
44
69
|
node_item[j].field_manager = create_field_manager({
|
|
45
70
|
bar_item: node_item[j],
|
|
46
|
-
node_path:
|
|
47
|
-
node_type:
|
|
48
|
-
node_value:
|
|
71
|
+
node_path: node_path,
|
|
72
|
+
node_type: node_type,
|
|
73
|
+
node_value: node_value,
|
|
49
74
|
is_preview: !!config?.is_preview,
|
|
50
75
|
on_set_node_value: (input) => config?.on_set_node_value(input),
|
|
51
76
|
get_selected_version_node_at_path: (input) => config?.get_selected_version_node_at_path(input),
|
|
@@ -53,13 +78,12 @@ export function create_node_manager(config) {
|
|
|
53
78
|
} else {
|
|
54
79
|
node_item[j].field_manager = create_field_manager({
|
|
55
80
|
bar_item: node_item?.[j],
|
|
56
|
-
parent_node_type:
|
|
57
|
-
node_path: [
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
]
|
|
61
|
-
|
|
62
|
-
node_value: config?.node_value?.[node_item[j]?.field]?.value,
|
|
81
|
+
parent_node_type: node_type,
|
|
82
|
+
node_path: [...(Array.isArray(node_path) ? node_path : []), node_item[j]?.field].filter(
|
|
83
|
+
(item) => item !== null && item !== undefined
|
|
84
|
+
),
|
|
85
|
+
node_type: node_value?.[node_item[j]?.field]?.type,
|
|
86
|
+
node_value: node_value?.[node_item[j]?.field]?.value,
|
|
63
87
|
is_preview: !!config?.is_preview,
|
|
64
88
|
on_set_node_value: (input) => config?.on_set_node_value(input),
|
|
65
89
|
get_selected_version_node_at_path: (input) => config?.get_selected_version_node_at_path(input),
|
|
@@ -71,37 +95,17 @@ export function create_node_manager(config) {
|
|
|
71
95
|
node_structure_loc.push(node_item)
|
|
72
96
|
}
|
|
73
97
|
}
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function handle_drag_start(e) {
|
|
78
|
-
if (config?.is_clickable_only || config?.node_path == "main") {
|
|
79
|
-
e.preventDefault()
|
|
80
|
-
} else if (config?.handle_node_drag_start) {
|
|
81
|
-
config?.handle_node_drag_start()
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function handle_drag_end(e) {
|
|
86
|
-
if (config?.is_clickable_only) {
|
|
87
|
-
e.preventDefault()
|
|
88
|
-
} else if (config?.handle_node_drag_start) {
|
|
89
|
-
config?.handle_node_drag_end()
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function init(config) {
|
|
94
|
-
node_structure = get_node_structure()
|
|
98
|
+
node_structure = node_structure_loc
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
init(config)
|
|
98
102
|
|
|
99
103
|
return {
|
|
100
104
|
get node_path() {
|
|
101
|
-
return
|
|
105
|
+
return node_path
|
|
102
106
|
},
|
|
103
107
|
get node_type() {
|
|
104
|
-
return
|
|
108
|
+
return node_type
|
|
105
109
|
},
|
|
106
110
|
get is_preview() {
|
|
107
111
|
return !!config?.is_preview
|
|
@@ -101,11 +101,11 @@
|
|
|
101
101
|
{/if}
|
|
102
102
|
</div>
|
|
103
103
|
<div class="node_types_container">
|
|
104
|
-
{#if Array.isArray(manager?.
|
|
105
|
-
{#each manager?.
|
|
104
|
+
{#if Array.isArray(manager?.node_toolbox_items_prepped)}
|
|
105
|
+
{#each manager?.node_toolbox_items_prepped as node_toolbox_item_prepped}
|
|
106
106
|
<!-- aaa|{node_toolbox_item} -->
|
|
107
107
|
<!-- <pre>{JSON.stringify(node_toolbox_item, null, 2)}</pre> -->
|
|
108
|
-
<Node manager={
|
|
108
|
+
<Node manager={node_toolbox_item_prepped?.node_manager} />
|
|
109
109
|
{/each}
|
|
110
110
|
{/if}
|
|
111
111
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { create_unique_id, deep_copy, node_types, node_categories } from "$lib/client/index.js"
|
|
1
|
+
import { create_unique_id, deep_copy, node_types, function_types, node_categories } from "$lib/client/index.js"
|
|
2
2
|
import { create_button_manager } from "$lib/Components/Button/index.svelte.js"
|
|
3
3
|
import { create_icon_manager } from "$lib/Components/Icon/index.svelte.js"
|
|
4
4
|
import { create_node_manager } from "$lib/Components/FunctionInput/Node/index.svelte.js"
|
|
@@ -20,46 +20,49 @@ export function create_function_manager(config) {
|
|
|
20
20
|
let selected_category = $state("main")
|
|
21
21
|
let undo_version_button_manager = $state(null)
|
|
22
22
|
let redo_version_button_manager = $state(null)
|
|
23
|
-
let node_toolbox_items = $state(null)
|
|
24
23
|
let node_category_buttons = $state(null)
|
|
25
24
|
let dragging_node = $state(null)
|
|
26
25
|
let root_node_manager = $state(null)
|
|
27
26
|
let trashcan_icon_manager = $state(null)
|
|
28
27
|
|
|
28
|
+
let node_toolbox_items_prepped = $state(null)
|
|
29
|
+
|
|
29
30
|
let selected_version = $derived(versions?.[selected_version_index])
|
|
30
31
|
|
|
31
|
-
function
|
|
32
|
+
function set_node_toolbox_items_prepped() {
|
|
32
33
|
let node_toolbox_items_loc = []
|
|
33
|
-
if (Object.keys(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
34
|
+
if (Object.keys(function_types || {}).length > 0) {
|
|
35
|
+
console.log("function_types", function_types)
|
|
36
|
+
for (let node_type of Object.keys(function_types || {})) {
|
|
37
|
+
console.log("node_typeddd", node_type, function_types?.[node_type])
|
|
38
|
+
node_toolbox_items_loc.push({
|
|
39
|
+
category: function_types?.[node_type]?.category,
|
|
40
|
+
node_manager: create_node_manager({
|
|
41
|
+
is_clickable_only: false,
|
|
42
|
+
is_preview: true,
|
|
43
|
+
node_type: node_type,
|
|
44
|
+
node_types: function_types,
|
|
45
|
+
node_path,
|
|
46
|
+
node_categories,
|
|
47
|
+
c: 12,
|
|
48
|
+
drag_or_select_node: drag_or_select_node,
|
|
49
|
+
handle_node_drag_start: () =>
|
|
50
|
+
handle_node_drag_start({
|
|
51
|
+
node_path: node_path,
|
|
52
|
+
node_type: node_type,
|
|
53
|
+
}),
|
|
54
|
+
handle_node_drag_end: () =>
|
|
55
|
+
handle_node_drag_end({
|
|
56
|
+
node_path: node_path,
|
|
57
|
+
node_type: node_type,
|
|
58
|
+
}),
|
|
59
|
+
on_set_node_value: (input) => set_node_value(input),
|
|
60
|
+
}),
|
|
61
|
+
})
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
|
-
|
|
64
|
+
console.log("node_toolbox_items_loc", node_toolbox_items_loc)
|
|
65
|
+
node_toolbox_items_prepped = node_toolbox_items_loc
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
function get_node_category_buttons() {
|
|
@@ -83,10 +86,7 @@ export function create_function_manager(config) {
|
|
|
83
86
|
c: 10,
|
|
84
87
|
l: 16,
|
|
85
88
|
selected_type: () => (is_selected ? "selected" : null),
|
|
86
|
-
on_click: () =>
|
|
87
|
-
node_toolbox_items = get_node_toolbox_items() // prob instead do once for all then filter by category
|
|
88
|
-
selected_category = node_category?.id
|
|
89
|
-
},
|
|
89
|
+
on_click: () => (selected_category = node_category?.id),
|
|
90
90
|
}),
|
|
91
91
|
})
|
|
92
92
|
}
|
|
@@ -151,7 +151,7 @@ export function create_function_manager(config) {
|
|
|
151
151
|
if (!node || !Array.isArray(seek_until_node_path) || seek_until_node_path.length == 0) {
|
|
152
152
|
return { defined, is_path_found }
|
|
153
153
|
}
|
|
154
|
-
let full_node_type =
|
|
154
|
+
let full_node_type = function_types?.[node?.type]
|
|
155
155
|
// should add the other define things like in loop or sort or use node kind to find definitions
|
|
156
156
|
// maybe also if im showing type in ui then assignments should update type but prob too difficult to predit with if else stuff
|
|
157
157
|
if (node?.type == "define") {
|
|
@@ -214,21 +214,21 @@ export function create_function_manager(config) {
|
|
|
214
214
|
|
|
215
215
|
function get_default_node_value(node_type) {
|
|
216
216
|
let default_node = null
|
|
217
|
-
if (node_type && Object.keys(
|
|
217
|
+
if (node_type && Object.keys(function_types?.[node_type]?.fields || {}).length > 0) {
|
|
218
218
|
default_node = {
|
|
219
219
|
type: node_type,
|
|
220
220
|
value: {},
|
|
221
221
|
}
|
|
222
|
-
for (let [key, value] of Object.entries(
|
|
222
|
+
for (let [key, value] of Object.entries(function_types?.[node_type]?.fields)) {
|
|
223
223
|
default_node.value[key] = null
|
|
224
224
|
if (value?.forced_node) {
|
|
225
225
|
default_node.value[key] = get_default_node_value(value?.forced_node) // careful about triggering infinate recursion here
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
} else if (
|
|
228
|
+
} else if (function_types?.[node_type]?.kind == "literal") {
|
|
229
229
|
default_node = {
|
|
230
230
|
type: node_type,
|
|
231
|
-
value:
|
|
231
|
+
value: function_types?.[node_type]?.value ?? null,
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
return default_node
|
|
@@ -305,7 +305,7 @@ export function create_function_manager(config) {
|
|
|
305
305
|
node_value: node_value,
|
|
306
306
|
is_clickable_only: false,
|
|
307
307
|
is_preview: true,
|
|
308
|
-
node_types,
|
|
308
|
+
node_types: function_types,
|
|
309
309
|
node_categories,
|
|
310
310
|
c: 12,
|
|
311
311
|
handle_node_drag_start: () =>
|
|
@@ -349,10 +349,10 @@ export function create_function_manager(config) {
|
|
|
349
349
|
}
|
|
350
350
|
let drop_area_node_options = []
|
|
351
351
|
if (drop_area_node_type == "stack_literal") {
|
|
352
|
-
drop_area_node_options =
|
|
352
|
+
drop_area_node_options = function_types?.stack_literal?.child_node_options
|
|
353
353
|
} else {
|
|
354
354
|
drop_area_node_options =
|
|
355
|
-
|
|
355
|
+
function_types?.[drop_area_node_type]?.fields?.[
|
|
356
356
|
Array.isArray(drop_area_node_path) ? drop_area_node_path[drop_area_node_path.length - 1] : -1
|
|
357
357
|
]?.node_options
|
|
358
358
|
}
|
|
@@ -466,7 +466,7 @@ export function create_function_manager(config) {
|
|
|
466
466
|
defined[node_path] = { defined_in_node_path: parent_node_path }
|
|
467
467
|
return { logs, output, defined, is_return }
|
|
468
468
|
}
|
|
469
|
-
let found_node_type =
|
|
469
|
+
let found_node_type = function_types?.[structure?.[node_path]?.node_type]?.input
|
|
470
470
|
let crunch_literal_res = crunch_literal(
|
|
471
471
|
deep_copy(structure),
|
|
472
472
|
deep_copy(structure?.[node_path]?.input),
|
|
@@ -500,7 +500,7 @@ export function create_function_manager(config) {
|
|
|
500
500
|
]
|
|
501
501
|
break
|
|
502
502
|
}
|
|
503
|
-
// let found_node_type =
|
|
503
|
+
// let found_node_type = function_types?.[structure?.[input?.defined_function_node_path]?.node_type]?.input
|
|
504
504
|
// let crunch_literal_res = crunch_literal(
|
|
505
505
|
// deep_copy(structure),
|
|
506
506
|
// structure?.[input?.defined_function_node_path]?.input,
|
|
@@ -1122,7 +1122,7 @@ export function create_function_manager(config) {
|
|
|
1122
1122
|
})
|
|
1123
1123
|
node_category_buttons = get_node_category_buttons()
|
|
1124
1124
|
set_root_node_prepped()
|
|
1125
|
-
|
|
1125
|
+
set_node_toolbox_items_prepped()
|
|
1126
1126
|
}
|
|
1127
1127
|
init(config)
|
|
1128
1128
|
|
|
@@ -1149,7 +1149,7 @@ export function create_function_manager(config) {
|
|
|
1149
1149
|
return console_result
|
|
1150
1150
|
},
|
|
1151
1151
|
get node_types() {
|
|
1152
|
-
return
|
|
1152
|
+
return function_types
|
|
1153
1153
|
},
|
|
1154
1154
|
get dragging_node() {
|
|
1155
1155
|
return dragging_node
|
|
@@ -1193,15 +1193,15 @@ export function create_function_manager(config) {
|
|
|
1193
1193
|
get node_category_buttons() {
|
|
1194
1194
|
return node_category_buttons
|
|
1195
1195
|
},
|
|
1196
|
-
get node_toolbox_items() {
|
|
1197
|
-
return node_toolbox_items
|
|
1198
|
-
},
|
|
1199
1196
|
get root_node_manager() {
|
|
1200
1197
|
return root_node_manager
|
|
1201
1198
|
},
|
|
1202
1199
|
get trashcan_icon_manager() {
|
|
1203
1200
|
return trashcan_icon_manager
|
|
1204
1201
|
},
|
|
1202
|
+
get node_toolbox_items_prepped() {
|
|
1203
|
+
return node_toolbox_items_prepped
|
|
1204
|
+
},
|
|
1205
1205
|
update_function,
|
|
1206
1206
|
undo,
|
|
1207
1207
|
redo,
|
|
@@ -2,19 +2,10 @@
|
|
|
2
2
|
import Popover from "$lib/Components/Popover/index.svelte"
|
|
3
3
|
import Button from "$lib/Components/Button/index.svelte"
|
|
4
4
|
import LoadingWheel from "$lib/Components/LoadingWheel/index.svelte"
|
|
5
|
-
import { onMount } from "svelte"
|
|
6
5
|
import { slide } from "svelte/transition"
|
|
6
|
+
import intersection_observer from "$lib/actions/intersection_observer.js"
|
|
7
7
|
|
|
8
8
|
let { manager } = $props()
|
|
9
|
-
|
|
10
|
-
onMount(() => {
|
|
11
|
-
setTimeout(() => {
|
|
12
|
-
if (typeof manager?.initialize_map == "function" && !manager?.is_popover) {
|
|
13
|
-
console.log("on_mount_initialize_map")
|
|
14
|
-
manager.initialize_map()
|
|
15
|
-
}
|
|
16
|
-
}, 20)
|
|
17
|
-
})
|
|
18
9
|
</script>
|
|
19
10
|
|
|
20
11
|
{#snippet location_content()}
|
|
@@ -25,7 +16,10 @@
|
|
|
25
16
|
<p>Loading Map</p>
|
|
26
17
|
</div>
|
|
27
18
|
</div>
|
|
28
|
-
<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}
|
|
29
23
|
</div>
|
|
30
24
|
{/snippet}
|
|
31
25
|
|
|
@@ -61,8 +61,6 @@ export function create_location_manager(config) {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
async function initialize_map() {
|
|
64
|
-
console.log("initialize_map")
|
|
65
|
-
map = null
|
|
66
64
|
if (!browser) {
|
|
67
65
|
console.log("browser is not defined")
|
|
68
66
|
return
|
|
@@ -78,10 +76,9 @@ export function create_location_manager(config) {
|
|
|
78
76
|
return
|
|
79
77
|
}
|
|
80
78
|
const { center_lat, center_lng, lat_span, lng_span } = get_map_region(val)
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
)
|
|
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)
|
|
85
82
|
if (!map) {
|
|
86
83
|
map = new mapkit.Map(`map_${id}`)
|
|
87
84
|
}
|
|
@@ -177,14 +174,14 @@ export function create_location_manager(config) {
|
|
|
177
174
|
return
|
|
178
175
|
}
|
|
179
176
|
const route = response.routes[0]
|
|
180
|
-
if (route.
|
|
181
|
-
route.
|
|
177
|
+
if (route.polyline) {
|
|
178
|
+
route.polyline.style = new mapkit.Style({
|
|
182
179
|
strokeColor: leg.stroke_color || "#0000ff",
|
|
183
180
|
lineWidth: leg.line_width || 3,
|
|
184
181
|
})
|
|
185
|
-
map.addOverlay(route.
|
|
182
|
+
map.addOverlay(route.polyline)
|
|
186
183
|
} else {
|
|
187
|
-
console.warn("no
|
|
184
|
+
console.warn("no polyline found for route", route)
|
|
188
185
|
}
|
|
189
186
|
})
|
|
190
187
|
}
|
|
@@ -214,8 +211,8 @@ export function create_location_manager(config) {
|
|
|
214
211
|
strokeColor: leg.stroke_color || "oklch(70% 0.3 210)",
|
|
215
212
|
lineWidth: leg.line_width || 3,
|
|
216
213
|
})
|
|
217
|
-
const
|
|
218
|
-
map.addOverlay(
|
|
214
|
+
const polyline = new mapkit.PolylineOverlay(coords, { style: overlay_style })
|
|
215
|
+
map.addOverlay(polyline)
|
|
219
216
|
}
|
|
220
217
|
|
|
221
218
|
function set_val(input) {
|
|
@@ -232,7 +229,6 @@ export function create_location_manager(config) {
|
|
|
232
229
|
target_height: config?.height ?? 440,
|
|
233
230
|
target_width: config?.width ?? 600,
|
|
234
231
|
on_open: () => {
|
|
235
|
-
console.log("on_open")
|
|
236
232
|
if (!map) {
|
|
237
233
|
setTimeout(() => {
|
|
238
234
|
initialize_map()
|
|
@@ -5,16 +5,10 @@
|
|
|
5
5
|
import Checkbox from "$lib/Components/Checkbox/index.svelte"
|
|
6
6
|
import Dropdown from "$lib/Components/Dropdown/index.svelte"
|
|
7
7
|
import LoadingWheel from "$lib/Components/LoadingWheel/index.svelte"
|
|
8
|
-
import { onMount } from "svelte"
|
|
9
8
|
import { slide } from "svelte/transition"
|
|
9
|
+
import intersection_observer from "$lib/actions/intersection_observer.js"
|
|
10
10
|
|
|
11
11
|
let { manager } = $props()
|
|
12
|
-
|
|
13
|
-
onMount(() => {
|
|
14
|
-
if (!manager?.is_popover) {
|
|
15
|
-
manager?.initialize_map()
|
|
16
|
-
}
|
|
17
|
-
})
|
|
18
12
|
</script>
|
|
19
13
|
|
|
20
14
|
{#snippet location_content()}
|
|
@@ -25,7 +19,10 @@
|
|
|
25
19
|
<p>Loading Map</p>
|
|
26
20
|
</div>
|
|
27
21
|
</div>
|
|
28
|
-
<div
|
|
22
|
+
<div use:intersection_observer onappeared={() => manager?.initialize_map()}></div>
|
|
23
|
+
{#key manager?.id}
|
|
24
|
+
<div id="map_{manager?.id}" class="map" style="height: {manager?.height}; max-width: 100%;"></div>
|
|
25
|
+
{/key}
|
|
29
26
|
{#if manager?.is_show_search}
|
|
30
27
|
<div class="search_container">
|
|
31
28
|
<div class="text_input">
|
|
@@ -60,9 +57,9 @@
|
|
|
60
57
|
{#each manager?.suggestions_prepped as suggestion_prepped}
|
|
61
58
|
<div class="search_item_container">
|
|
62
59
|
<div class="search_item">
|
|
63
|
-
<h3>{suggestion_prepped?.
|
|
64
|
-
{#if suggestion_prepped?.
|
|
65
|
-
<p>{suggestion_prepped?.
|
|
60
|
+
<h3>{suggestion_prepped?.displayLines?.[0]}</h3>
|
|
61
|
+
{#if suggestion_prepped?.displayLines?.[1]}
|
|
62
|
+
<p>{suggestion_prepped?.displayLines?.[1]}</p>
|
|
66
63
|
{/if}
|
|
67
64
|
<!-- {#if Array.isArray(suggestion_prepped?.poi_category) && suggestion_prepped.poi_category.length > 0}
|
|
68
65
|
<div style="display: flex; flex-wrap: wrap; gap: .5rem;">
|
|
@@ -669,7 +669,7 @@ export function create_location_input_manager(config) {
|
|
|
669
669
|
choose_selection_button_manager = create_button_manager({
|
|
670
670
|
support_icon: "magnifying_glass",
|
|
671
671
|
is_uniform: true,
|
|
672
|
-
on_click: () => search_for(`${suggestion?.
|
|
672
|
+
on_click: () => search_for(`${suggestion?.displayLines?.[0]}`),
|
|
673
673
|
})
|
|
674
674
|
}
|
|
675
675
|
suggestions_prepped_loc.push({
|
|
@@ -687,6 +687,10 @@ export function create_location_input_manager(config) {
|
|
|
687
687
|
|
|
688
688
|
function search_for(input) {
|
|
689
689
|
const search_options = prepare_search_options()
|
|
690
|
+
if (!map) {
|
|
691
|
+
console.log("map not found")
|
|
692
|
+
return
|
|
693
|
+
}
|
|
690
694
|
map.removeAnnotations(map.annotations)
|
|
691
695
|
const place_search = new mapkit.Search()
|
|
692
696
|
place_search.search(
|
|
@@ -747,6 +751,16 @@ export function create_location_input_manager(config) {
|
|
|
747
751
|
}
|
|
748
752
|
}
|
|
749
753
|
|
|
754
|
+
function reset_map() {
|
|
755
|
+
// const el = document.getElementById(`map_${id}`)
|
|
756
|
+
// if (el) {
|
|
757
|
+
// // optional: remove child nodes or clear old map if you want
|
|
758
|
+
// // el.innerHTML = ''
|
|
759
|
+
// map = new mapkit.Map(`map_${id}`)
|
|
760
|
+
// }
|
|
761
|
+
initialize_map()
|
|
762
|
+
}
|
|
763
|
+
|
|
750
764
|
function finish() {
|
|
751
765
|
popover_manager.close()
|
|
752
766
|
if (typeof config?.on_finish == "function") {
|
|
@@ -946,5 +960,6 @@ export function create_location_input_manager(config) {
|
|
|
946
960
|
},
|
|
947
961
|
initialize_map,
|
|
948
962
|
set_val,
|
|
963
|
+
reset_map,
|
|
949
964
|
}
|
|
950
965
|
}
|