@onsvisual/svelte-components 0.1.61 → 0.1.62

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.
@@ -37,7 +37,7 @@
37
37
 
38
38
  onMount(() => {
39
39
  if (sections && observer) {
40
- $sections = [...$sections, { title, id, subsection }];
40
+ $sections = [...section.parentElement.childNodes].filter((c) => c.tagName === "SECTION");
41
41
  $observer.observe(section);
42
42
  }
43
43
  });
@@ -50,7 +50,14 @@
50
50
  });
51
51
  </script>
52
52
 
53
- <section id="{id}" class="{cls}" aria-label="{title}" bind:this="{section}">
53
+ <section
54
+ id="{id}"
55
+ title="{title}"
56
+ data-subsection="{subsection}"
57
+ class="{cls}"
58
+ aria-label="{title}"
59
+ bind:this="{section}"
60
+ >
54
61
  {#if title}
55
62
  {#if subsection}
56
63
  <h3 class="subsection-title ons-u-fs-m" class:ons-u-vh="{hideTitle}">{title}</h3>
@@ -114,7 +114,10 @@
114
114
  {/if}
115
115
  <ol class="ons-list ons-u-mb-m ons-list--dashed">
116
116
  {#each $sections as section}
117
- <li class="ons-list__item" class:ons-list__item-indented="{section.subsection}">
117
+ <li
118
+ class="ons-list__item"
119
+ class:ons-list__item-indented="{section.dataset.subsection === 'true'}"
120
+ >
118
121
  <a
119
122
  href="#{section.id}"
120
123
  class="ons-list__link"
@@ -25,20 +25,22 @@
25
25
 
26
26
  onMount(() => {
27
27
  if (sections) {
28
- if (!$selected) $selected = id;
29
- $sections = [...$sections, { title, id, el }];
28
+ $sections = [...el.parentElement.childNodes].filter((c) => c.tagName === "SECTION");
29
+ if ($selected === null || $selected === undefined) $selected = $sections[0]?.id;
30
30
  }
31
31
  });
32
32
 
33
33
  onDestroy(() => {
34
34
  if (sections) {
35
35
  $sections = $sections.filter((s) => s.id !== id);
36
+ if ($selected === id) $selected = $sections.length > 0 ? $sections[0].id : null;
36
37
  }
37
38
  });
38
39
  </script>
39
40
 
40
41
  <section
41
42
  id="{id}"
43
+ title="{title}"
42
44
  class="ons-tabs__panel"
43
45
  bind:this="{el}"
44
46
  class:ons-tabs__panel--hidden="{$selected !== id}"
@@ -29,8 +29,7 @@
29
29
  $_selected = id;
30
30
  [...$sections].forEach(
31
31
  (s) =>
32
- (s.el.className =
33
- s.id === id ? "ons-tabs__panel" : "ons-tabs__panel ons-tabs__panel--hidden")
32
+ (s.className = s.id === id ? "ons-tabs__panel" : "ons-tabs__panel ons-tabs__panel--hidden")
34
33
  );
35
34
  dispatch("change", { id });
36
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onsvisual/svelte-components",
3
- "version": "0.1.61",
3
+ "version": "0.1.62",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://onsvisual.github.io/svelte-components",