@onsvisual/svelte-components 0.1.63 → 0.1.65
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.
|
@@ -5,6 +5,8 @@ export default class Twisty extends SvelteComponentTyped<{
|
|
|
5
5
|
title?: string;
|
|
6
6
|
open?: boolean;
|
|
7
7
|
}, {
|
|
8
|
+
toggle: CustomEvent<any>;
|
|
9
|
+
} & {
|
|
8
10
|
[evt: string]: CustomEvent<any>;
|
|
9
11
|
}, {
|
|
10
12
|
default: {};
|
|
@@ -20,6 +22,8 @@ declare const __propDef: {
|
|
|
20
22
|
open?: boolean;
|
|
21
23
|
};
|
|
22
24
|
events: {
|
|
25
|
+
toggle: CustomEvent<any>;
|
|
26
|
+
} & {
|
|
23
27
|
[evt: string]: CustomEvent<any>;
|
|
24
28
|
};
|
|
25
29
|
slots: {
|
|
@@ -23,12 +23,11 @@
|
|
|
23
23
|
const elements = getContext("elements");
|
|
24
24
|
const allOpen = getContext("allOpen");
|
|
25
25
|
|
|
26
|
-
function updateAllOpen(
|
|
26
|
+
function updateAllOpen(e) {
|
|
27
27
|
if (el && $elements) {
|
|
28
|
-
$allOpen = open ? [...$elements].every((el) => el.open) : false;
|
|
28
|
+
$allOpen = e.newState === "open" ? [...$elements].every((el) => el.open) : false;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
$: updateAllOpen(open);
|
|
32
31
|
|
|
33
32
|
onMount(() => {
|
|
34
33
|
$elements.add(el);
|
|
@@ -38,25 +37,25 @@
|
|
|
38
37
|
|
|
39
38
|
<details
|
|
40
39
|
id="accordion-1"
|
|
41
|
-
class="ons-
|
|
40
|
+
class="ons-collapsible ons-js-collapsible ons-details--accordion"
|
|
42
41
|
data-group="accordion"
|
|
43
42
|
bind:this="{el}"
|
|
44
43
|
bind:open="{open}"
|
|
44
|
+
on:toggle="{updateAllOpen}"
|
|
45
45
|
>
|
|
46
|
-
<summary class="ons-
|
|
47
|
-
<h2 class="ons-
|
|
48
|
-
<span class="ons-
|
|
46
|
+
<summary class="ons-collapsible__heading ons-js-collapsible-heading ons-details__heading">
|
|
47
|
+
<h2 class="ons-collapsible__title">{title}</h2>
|
|
48
|
+
<span class="ons-collapsible__icon">
|
|
49
49
|
<svg
|
|
50
|
-
class="ons-
|
|
50
|
+
class="ons-icon"
|
|
51
51
|
viewBox="0 0 8 13"
|
|
52
52
|
xmlns="http://www.w3.org/2000/svg"
|
|
53
53
|
focusable="false"
|
|
54
54
|
fill="currentColor"
|
|
55
|
-
|
|
56
|
-
<path
|
|
55
|
+
><path
|
|
57
56
|
d="M5.74,14.28l-.57-.56a.5.5,0,0,1,0-.71h0l5-5-5-5a.5.5,0,0,1,0-.71h0l.57-.56a.5.5,0,0,1,.71,0h0l5.93,5.93a.5.5,0,0,1,0,.7L6.45,14.28a.5.5,0,0,1-.71,0Z"
|
|
58
|
-
transform="translate(-5.02 -1.59)"></path
|
|
59
|
-
|
|
57
|
+
transform="translate(-5.02 -1.59)"></path></svg
|
|
58
|
+
>
|
|
60
59
|
</span>
|
|
61
60
|
</summary>
|
|
62
61
|
<div id="{id}-content" class="ons-details__content ons-js-details-content">
|
|
@@ -78,4 +77,10 @@
|
|
|
78
77
|
.ons-details__heading:hover:not(:focus) .ons-details__title {
|
|
79
78
|
-webkit-text-decoration: underline solid var(--link-hover, --ons-color-text-link-hover) 2px;
|
|
80
79
|
text-decoration: underline solid var(--link-hover, --ons-color-text-link-hover) 2px;
|
|
80
|
+
}
|
|
81
|
+
.ons-collapsible .ons-collapsible__icon {
|
|
82
|
+
top: 0.8rem;
|
|
83
|
+
}
|
|
84
|
+
.ons-collapsible[open] .ons-collapsible__icon {
|
|
85
|
+
top: 1.2rem;
|
|
81
86
|
}</style>
|
|
@@ -37,7 +37,9 @@
|
|
|
37
37
|
|
|
38
38
|
onMount(() => {
|
|
39
39
|
if (sections && observer) {
|
|
40
|
-
$sections = [...section.parentElement.
|
|
40
|
+
$sections = [...section.parentElement.getElementsByTagName("section")].filter(
|
|
41
|
+
(c) => c.id && c.title
|
|
42
|
+
);
|
|
41
43
|
$observer.observe(section);
|
|
42
44
|
}
|
|
43
45
|
});
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
<script>
|
|
2
|
+
import { createEventDispatcher } from "svelte";
|
|
3
|
+
|
|
4
|
+
const dispatch = createEventDispatcher();
|
|
5
|
+
|
|
2
6
|
/**
|
|
3
7
|
* A title for the element
|
|
4
8
|
* @type {string}
|
|
@@ -9,9 +13,13 @@
|
|
|
9
13
|
* @type {boolean}
|
|
10
14
|
*/
|
|
11
15
|
export let open = false;
|
|
16
|
+
|
|
17
|
+
function doToggle(e) {
|
|
18
|
+
dispatch("toggle", { open: e.newState === "open", e });
|
|
19
|
+
}
|
|
12
20
|
</script>
|
|
13
21
|
|
|
14
|
-
<details class="ons-collapsible ons-js-collapsible" bind:open="{open}">
|
|
22
|
+
<details class="ons-collapsible ons-js-collapsible" bind:open="{open}" on:toggle="{doToggle}">
|
|
15
23
|
<summary
|
|
16
24
|
class="ons-collapsible__heading ons-js-collapsible-heading"
|
|
17
25
|
data-ga-action="{open ? 'Close panel' : 'Open panel'}"
|