@skeletonlabs/skeleton 2.8.0 → 2.9.0-dev.a4897a44
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script>import { setContext } from "svelte";
|
|
2
2
|
export let multiple = false;
|
|
3
|
+
export let disabled = false;
|
|
3
4
|
export let spacing = "space-y-1";
|
|
4
5
|
export let rounded = "rounded-token";
|
|
5
6
|
export let active = "variant-filled";
|
|
@@ -9,6 +10,7 @@ export let regionLead = "";
|
|
|
9
10
|
export let regionDefault = "";
|
|
10
11
|
export let regionTrail = "";
|
|
11
12
|
export let labelledby = "";
|
|
13
|
+
setContext("disabled", disabled);
|
|
12
14
|
setContext("multiple", multiple);
|
|
13
15
|
setContext("rounded", rounded);
|
|
14
16
|
setContext("active", active);
|
|
@@ -4,6 +4,8 @@ declare const __propDef: {
|
|
|
4
4
|
[x: string]: any;
|
|
5
5
|
/** Enable selection of multiple items.*/
|
|
6
6
|
multiple?: boolean | undefined;
|
|
7
|
+
/** Disables selection of items.*/
|
|
8
|
+
disabled?: boolean | undefined;
|
|
7
9
|
/** Provide class to set the vertical spacing style.*/
|
|
8
10
|
spacing?: string | undefined;
|
|
9
11
|
/** Provide classes to set the listbox box radius styles.*/
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export let group;
|
|
3
3
|
export let name;
|
|
4
4
|
export let value;
|
|
5
|
+
export let disabled = getContext("disabled");
|
|
5
6
|
export let multiple = getContext("multiple");
|
|
6
7
|
export let rounded = getContext("rounded");
|
|
7
8
|
export let active = getContext("active");
|
|
@@ -11,6 +12,7 @@ export let regionLead = getContext("regionLead");
|
|
|
11
12
|
export let regionDefault = getContext("regionDefault");
|
|
12
13
|
export let regionTrail = getContext("regionTrail");
|
|
13
14
|
const cBase = "cursor-pointer -outline-offset-[3px]";
|
|
15
|
+
const cDisabled = "opacity-50 !cursor-default";
|
|
14
16
|
const cLabel = "flex items-center space-x-4";
|
|
15
17
|
let checked;
|
|
16
18
|
let elemInput;
|
|
@@ -66,9 +68,11 @@ const cRegionTrail = "";
|
|
|
66
68
|
$:
|
|
67
69
|
selected = multiple ? group.some((groupVal) => areDeeplyEqual(value, groupVal)) : areDeeplyEqual(group, value);
|
|
68
70
|
$:
|
|
69
|
-
classesActive = selected ? active : hover;
|
|
71
|
+
classesActive = selected ? active : !disabled ? hover : "";
|
|
70
72
|
$:
|
|
71
|
-
|
|
73
|
+
classesDisabled = disabled ? cDisabled : "";
|
|
74
|
+
$:
|
|
75
|
+
classesBase = `${cBase} ${classesDisabled} ${rounded} ${padding} ${classesActive} ${$$props.class ?? ""}`;
|
|
72
76
|
$:
|
|
73
77
|
classesLabel = `${cLabel}`;
|
|
74
78
|
$:
|
|
@@ -95,9 +99,9 @@ $:
|
|
|
95
99
|
<!-- NOTE: Don't use `hidden` as it prevents `required` from operating -->
|
|
96
100
|
<div class="h-0 w-0 overflow-hidden">
|
|
97
101
|
{#if multiple}
|
|
98
|
-
<input bind:this={elemInput} type="checkbox" {name} {value} bind:checked tabindex="-1" on:click on:change />
|
|
102
|
+
<input {disabled} bind:this={elemInput} type="checkbox" {name} {value} bind:checked tabindex="-1" on:click on:change />
|
|
99
103
|
{:else}
|
|
100
|
-
<input bind:this={elemInput} type="radio" bind:group {name} {value} tabindex="-1" on:click on:change />
|
|
104
|
+
<input {disabled} bind:this={elemInput} type="radio" bind:group {name} {value} tabindex="-1" on:click on:change />
|
|
101
105
|
{/if}
|
|
102
106
|
</div>
|
|
103
107
|
<!-- <slot /> -->
|