sveltekit-ui 1.0.7 → 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.
@@ -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
  },
@@ -2,19 +2,10 @@
2
2
  import Popover from "../Popover/index.svelte"
3
3
  import Button from "../Button/index.svelte"
4
4
  import LoadingWheel from "../LoadingWheel/index.svelte"
5
- import { onMount } from "svelte"
6
5
  import { slide } from "svelte/transition"
6
+ import intersection_observer from "../../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 id="map_{manager?.id}" class="map" style="height: {manager?.height}; max-width: 100%;"></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 initial_region = new mapkit.CoordinateRegion(
82
- new mapkit.Coordinate(center_lat, center_lng),
83
- new mapkit.CoordinateSpan(lat_span, lng_span)
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.poly_line) {
181
- route.poly_line.style = new mapkit.Style({
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.poly_line)
182
+ map.addOverlay(route.polyline)
186
183
  } else {
187
- console.warn("no poly_line found for route", route)
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 poly_line = new mapkit.PolylineOverlay(coords, { style: overlay_style })
218
- map.addOverlay(poly_line)
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,18 +5,10 @@
5
5
  import Checkbox from "../Checkbox/index.svelte"
6
6
  import Dropdown from "../Dropdown/index.svelte"
7
7
  import LoadingWheel from "../LoadingWheel/index.svelte"
8
- import { onMount } from "svelte"
9
8
  import { slide } from "svelte/transition"
9
+ import intersection_observer from "../../actions/intersection_observer.js"
10
10
 
11
11
  let { manager } = $props()
12
-
13
- onMount(() => {
14
- if (!manager?.is_popover) {
15
- // setTimeout(() => {
16
- manager?.initialize_map()
17
- // }, 100)
18
- }
19
- })
20
12
  </script>
21
13
 
22
14
  {#snippet location_content()}
@@ -27,7 +19,10 @@
27
19
  <p>Loading Map</p>
28
20
  </div>
29
21
  </div>
30
- <div id="map_{manager?.id}" class="map" style="height: {manager?.height}; max-width: 100%;"></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}
31
26
  {#if manager?.is_show_search}
32
27
  <div class="search_container">
33
28
  <div class="text_input">
@@ -586,7 +586,6 @@ export function create_location_input_manager(config) {
586
586
  }
587
587
 
588
588
  function prepare_search_options(is_autocomplete = false) {
589
- console.log("prepare_search_options")
590
589
  const result_type = Array.isArray(search_filter_result_type_dropdown_manager?.val)
591
590
  ? search_filter_result_type_dropdown_manager?.val
592
591
  : []
@@ -638,7 +637,6 @@ export function create_location_input_manager(config) {
638
637
  )
639
638
  )
640
639
  }
641
- console.log("zzz", options)
642
640
  return options
643
641
  }
644
642
 
@@ -648,7 +646,6 @@ export function create_location_input_manager(config) {
648
646
  return
649
647
  }
650
648
  const autocomplete_search_options = prepare_search_options(true)
651
- console.log("autocomplete_search_options", autocomplete_search_options)
652
649
  const place_search = new mapkit.Search()
653
650
  place_search.autocomplete(
654
651
  input,
@@ -660,7 +657,6 @@ export function create_location_input_manager(config) {
660
657
  if (result.results.length > 0) {
661
658
  let suggestions_prepped_loc = []
662
659
  if (Array.isArray(result.results)) {
663
- console.log("suggestions_results", result.results)
664
660
  for (let suggestion of result.results) {
665
661
  let choose_selection_button_manager = $state(null)
666
662
  if (suggestion?.id) {
@@ -673,7 +669,7 @@ export function create_location_input_manager(config) {
673
669
  choose_selection_button_manager = create_button_manager({
674
670
  support_icon: "magnifying_glass",
675
671
  is_uniform: true,
676
- on_click: () => search_for(`${suggestion?.display_lines?.[0]}`),
672
+ on_click: () => search_for(`${suggestion?.displayLines?.[0]}`),
677
673
  })
678
674
  }
679
675
  suggestions_prepped_loc.push({
@@ -691,7 +687,10 @@ export function create_location_input_manager(config) {
691
687
 
692
688
  function search_for(input) {
693
689
  const search_options = prepare_search_options()
694
- console.log("search_options", search_options)
690
+ if (!map) {
691
+ console.log("map not found")
692
+ return
693
+ }
695
694
  map.removeAnnotations(map.annotations)
696
695
  const place_search = new mapkit.Search()
697
696
  place_search.search(
@@ -752,6 +751,16 @@ export function create_location_input_manager(config) {
752
751
  }
753
752
  }
754
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
+
755
764
  function finish() {
756
765
  popover_manager.close()
757
766
  if (typeof config?.on_finish == "function") {
@@ -951,5 +960,6 @@ export function create_location_input_manager(config) {
951
960
  },
952
961
  initialize_map,
953
962
  set_val,
963
+ reset_map,
954
964
  }
955
965
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sveltekit-ui",
3
- "version": "1.0.7",
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",
@@ -26,12 +26,12 @@
26
26
  },
27
27
  "devDependencies": {
28
28
  "@sveltejs/adapter-vercel": "^5.7.2",
29
- "@sveltejs/kit": "^2.22.3",
29
+ "@sveltejs/kit": "^2.22.5",
30
30
  "@sveltejs/package": "^2.3.12",
31
- "@sveltejs/vite-plugin-svelte": "^5.1.0",
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.3"
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
  },
@@ -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 id="map_{manager?.id}" class="map" style="height: {manager?.height}; max-width: 100%;"></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 initial_region = new mapkit.CoordinateRegion(
82
- new mapkit.Coordinate(center_lat, center_lng),
83
- new mapkit.CoordinateSpan(lat_span, lng_span)
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.poly_line) {
181
- route.poly_line.style = new mapkit.Style({
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.poly_line)
182
+ map.addOverlay(route.polyline)
186
183
  } else {
187
- console.warn("no poly_line found for route", route)
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 poly_line = new mapkit.PolylineOverlay(coords, { style: overlay_style })
218
- map.addOverlay(poly_line)
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,18 +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
- // setTimeout(() => {
16
- manager?.initialize_map()
17
- // }, 100)
18
- }
19
- })
20
12
  </script>
21
13
 
22
14
  {#snippet location_content()}
@@ -27,7 +19,10 @@
27
19
  <p>Loading Map</p>
28
20
  </div>
29
21
  </div>
30
- <div id="map_{manager?.id}" class="map" style="height: {manager?.height}; max-width: 100%;"></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}
31
26
  {#if manager?.is_show_search}
32
27
  <div class="search_container">
33
28
  <div class="text_input">
@@ -586,7 +586,6 @@ export function create_location_input_manager(config) {
586
586
  }
587
587
 
588
588
  function prepare_search_options(is_autocomplete = false) {
589
- console.log("prepare_search_options")
590
589
  const result_type = Array.isArray(search_filter_result_type_dropdown_manager?.val)
591
590
  ? search_filter_result_type_dropdown_manager?.val
592
591
  : []
@@ -638,7 +637,6 @@ export function create_location_input_manager(config) {
638
637
  )
639
638
  )
640
639
  }
641
- console.log("zzz", options)
642
640
  return options
643
641
  }
644
642
 
@@ -648,7 +646,6 @@ export function create_location_input_manager(config) {
648
646
  return
649
647
  }
650
648
  const autocomplete_search_options = prepare_search_options(true)
651
- console.log("autocomplete_search_options", autocomplete_search_options)
652
649
  const place_search = new mapkit.Search()
653
650
  place_search.autocomplete(
654
651
  input,
@@ -660,7 +657,6 @@ export function create_location_input_manager(config) {
660
657
  if (result.results.length > 0) {
661
658
  let suggestions_prepped_loc = []
662
659
  if (Array.isArray(result.results)) {
663
- console.log("suggestions_results", result.results)
664
660
  for (let suggestion of result.results) {
665
661
  let choose_selection_button_manager = $state(null)
666
662
  if (suggestion?.id) {
@@ -673,7 +669,7 @@ export function create_location_input_manager(config) {
673
669
  choose_selection_button_manager = create_button_manager({
674
670
  support_icon: "magnifying_glass",
675
671
  is_uniform: true,
676
- on_click: () => search_for(`${suggestion?.display_lines?.[0]}`),
672
+ on_click: () => search_for(`${suggestion?.displayLines?.[0]}`),
677
673
  })
678
674
  }
679
675
  suggestions_prepped_loc.push({
@@ -691,7 +687,10 @@ export function create_location_input_manager(config) {
691
687
 
692
688
  function search_for(input) {
693
689
  const search_options = prepare_search_options()
694
- console.log("search_options", search_options)
690
+ if (!map) {
691
+ console.log("map not found")
692
+ return
693
+ }
695
694
  map.removeAnnotations(map.annotations)
696
695
  const place_search = new mapkit.Search()
697
696
  place_search.search(
@@ -752,6 +751,16 @@ export function create_location_input_manager(config) {
752
751
  }
753
752
  }
754
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
+
755
764
  function finish() {
756
765
  popover_manager.close()
757
766
  if (typeof config?.on_finish == "function") {
@@ -951,5 +960,6 @@ export function create_location_input_manager(config) {
951
960
  },
952
961
  initialize_map,
953
962
  set_val,
963
+ reset_map,
954
964
  }
955
965
  }