fluent-svelte-extra 2.1.7 → 2.1.9
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.
|
@@ -7,6 +7,7 @@ const dispatch = createEventDispatcher();
|
|
|
7
7
|
export let selected = false;
|
|
8
8
|
export let group = "";
|
|
9
9
|
export let singleSelect = false;
|
|
10
|
+
export let disableUnselectionIfGrouped = false;
|
|
10
11
|
const id = Math.random();
|
|
11
12
|
/**
|
|
12
13
|
* Sets the selected state of the grid view item.
|
|
@@ -26,6 +27,13 @@ function setSelected(value, __depth) {
|
|
|
26
27
|
}
|
|
27
28
|
selected = value;
|
|
28
29
|
}
|
|
30
|
+
function handleInteraction() {
|
|
31
|
+
if (disableUnselectionIfGrouped && group.length > 0 && selected) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
setSelected(!selected, false);
|
|
35
|
+
dispatch("change", { selected: selected });
|
|
36
|
+
}
|
|
29
37
|
if (group.length) {
|
|
30
38
|
const getAvailableGroupItems = (_a = getKey(`group:${group}`)) !== null && _a !== void 0 ? _a : [];
|
|
31
39
|
getAvailableGroupItems.push({
|
|
@@ -42,14 +50,10 @@ if (group.length) {
|
|
|
42
50
|
class:selected
|
|
43
51
|
{...$$restProps}
|
|
44
52
|
tabindex="0"
|
|
45
|
-
on:click={
|
|
46
|
-
setSelected(!selected, false);
|
|
47
|
-
dispatch("change", { selected: selected });
|
|
48
|
-
}}
|
|
53
|
+
on:click={handleInteraction}
|
|
49
54
|
on:keydown={e => {
|
|
50
55
|
if (e.key !== "Enter") return;
|
|
51
|
-
|
|
52
|
-
dispatch("change", { selected: selected });
|
|
56
|
+
handleInteraction();
|
|
53
57
|
}}
|
|
54
58
|
>
|
|
55
59
|
{#if !singleSelect}
|
|
@@ -58,6 +62,10 @@ if (group.length) {
|
|
|
58
62
|
tabindex="-1"
|
|
59
63
|
bind:checked={selected}
|
|
60
64
|
on:change={() => {
|
|
65
|
+
if (disableUnselectionIfGrouped && group.length > 0 && !selected) {
|
|
66
|
+
selected = true;
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
61
69
|
dispatch("change", { selected: !selected });
|
|
62
70
|
}}
|
|
63
71
|
/>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script >export let query;
|
|
2
|
+
export let destroyable = true;
|
|
3
|
+
export let teleportToTop = false;
|
|
4
|
+
export let style = "";
|
|
5
|
+
function teleport(node) {
|
|
6
|
+
let teleportContainer = document.querySelector(query);
|
|
7
|
+
if (teleportToTop && teleportContainer.firstChild) {
|
|
8
|
+
teleportContainer.insertBefore(node, teleportContainer.firstChild);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
teleportContainer.appendChild(node);
|
|
12
|
+
}
|
|
13
|
+
if (destroyable) {
|
|
14
|
+
return {
|
|
15
|
+
destroy() {
|
|
16
|
+
node.remove();
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<div class="portal" use:teleport {style}>
|
|
24
|
+
<slot></slot>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<style>.portal{display:contents}</style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
query: string;
|
|
5
|
+
destroyable?: boolean;
|
|
6
|
+
teleportToTop?: boolean;
|
|
7
|
+
style?: string;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {
|
|
13
|
+
default: {};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare type PortalProps = typeof __propDef.props;
|
|
17
|
+
export declare type PortalEvents = typeof __propDef.events;
|
|
18
|
+
export declare type PortalSlots = typeof __propDef.slots;
|
|
19
|
+
export default class Portal extends SvelteComponentTyped<PortalProps, PortalEvents, PortalSlots> {
|
|
20
|
+
}
|
|
21
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fluent-svelte-extra",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.9",
|
|
4
4
|
"description": "A faithful implementation of Microsoft's Fluent Design System in Svelte.",
|
|
5
5
|
"homepage": "https://github.com/OpenAnime/fluent-svelte-extra",
|
|
6
6
|
"license": "MIT",
|
|
@@ -135,6 +135,7 @@
|
|
|
135
135
|
"./NumberBox/NumberBox.svelte": "./NumberBox/NumberBox.svelte",
|
|
136
136
|
"./PersonPicture/PersonPicture.scss": "./PersonPicture/PersonPicture.scss",
|
|
137
137
|
"./PersonPicture/PersonPicture.svelte": "./PersonPicture/PersonPicture.svelte",
|
|
138
|
+
"./Portal/Portal.svelte": "./Portal/Portal.svelte",
|
|
138
139
|
"./ProgressBar/ProgressBar.scss": "./ProgressBar/ProgressBar.scss",
|
|
139
140
|
"./ProgressBar/ProgressBar.svelte": "./ProgressBar/ProgressBar.svelte",
|
|
140
141
|
"./ProgressRing/ProgressRing.scss": "./ProgressRing/ProgressRing.scss",
|