@skeletonlabs/skeleton 2.7.1 → 2.8.0-dev.3a27212f
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.
- package/dist/components/Autocomplete/Autocomplete.svelte +1 -1
- package/dist/components/InputChip/InputChip.svelte +56 -32
- package/dist/components/InputChip/InputChip.svelte.d.ts +16 -0
- package/dist/components/ListBox/ListBox.svelte +2 -0
- package/dist/components/ListBox/ListBox.svelte.d.ts +2 -0
- package/dist/components/ListBox/ListBoxItem.svelte +8 -4
- package/dist/components/ListBox/ListBoxItem.svelte.d.ts +1 -0
- package/dist/components/TreeView/RecursiveTreeView.svelte +1 -12
- package/dist/components/TreeView/RecursiveTreeView.svelte.d.ts +0 -4
- package/dist/utilities/CodeBlock/CodeBlock.svelte +1 -1
- package/package.json +1 -1
|
@@ -28,6 +28,7 @@ export let rounded = "rounded-container-token";
|
|
|
28
28
|
export let regionChipWrapper = "";
|
|
29
29
|
export let regionChipList = "";
|
|
30
30
|
export let regionInput = "";
|
|
31
|
+
export let label = "Chips select";
|
|
31
32
|
export let transitions = !$prefersReducedMotionStore;
|
|
32
33
|
export let listTransitionIn = fly;
|
|
33
34
|
export let listTransitionInParams = { duration: 150, opacity: 0, y: -20 };
|
|
@@ -61,48 +62,73 @@ onMount(() => {
|
|
|
61
62
|
function onInputHandler() {
|
|
62
63
|
inputValid = true;
|
|
63
64
|
}
|
|
64
|
-
function
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
function validateCustom(chip) {
|
|
66
|
+
return validation === void 0 || validation(chip);
|
|
67
|
+
}
|
|
68
|
+
function validateCount() {
|
|
69
|
+
return max === -1 || value.length < max;
|
|
70
|
+
}
|
|
71
|
+
function validateLength(chip) {
|
|
72
|
+
return (minlength === -1 || chip.length >= minlength) && (maxlength === -1 || chip.length <= maxlength);
|
|
73
|
+
}
|
|
74
|
+
function validateWhiteList(chip) {
|
|
75
|
+
return whitelist.length === 0 || whitelist.includes(chip);
|
|
76
|
+
}
|
|
77
|
+
function validateDuplicates(chip) {
|
|
78
|
+
return allowDuplicates || !value.includes(chip);
|
|
79
|
+
}
|
|
80
|
+
function validate(chip = "") {
|
|
81
|
+
if (!chip && !input)
|
|
79
82
|
return false;
|
|
80
|
-
|
|
83
|
+
chip = chip !== "" ? chip.trim() : input.trim();
|
|
84
|
+
return validateCustom(chip) && validateCount() && validateLength(chip) && validateWhiteList(chip) && validateDuplicates(chip);
|
|
85
|
+
}
|
|
86
|
+
function addChipCommon(chip) {
|
|
87
|
+
chip = allowUpperCase ? chip : chip.toLowerCase();
|
|
88
|
+
value.push(chip);
|
|
89
|
+
value = value;
|
|
90
|
+
chipValues.push({ val: chip, id: Math.random() });
|
|
91
|
+
chipValues = chipValues;
|
|
92
|
+
}
|
|
93
|
+
function removeChipCommon(chip) {
|
|
94
|
+
let chipIndex = value.indexOf(chip);
|
|
95
|
+
value.splice(chipIndex, 1);
|
|
96
|
+
value = value;
|
|
97
|
+
chipValues.splice(chipIndex, 1);
|
|
98
|
+
chipValues = chipValues;
|
|
81
99
|
}
|
|
82
|
-
function
|
|
100
|
+
function addChipInternally(event) {
|
|
83
101
|
event.preventDefault();
|
|
84
102
|
inputValid = validate();
|
|
85
103
|
if (inputValid === false) {
|
|
86
104
|
dispatch("invalid", { event, input });
|
|
87
105
|
return;
|
|
88
106
|
}
|
|
89
|
-
input
|
|
90
|
-
value.push(input);
|
|
91
|
-
value = value;
|
|
92
|
-
chipValues.push({ val: input, id: Math.random() });
|
|
93
|
-
chipValues = chipValues;
|
|
107
|
+
addChipCommon(input);
|
|
94
108
|
dispatch("add", { event, chipIndex: value.length - 1, chipValue: input });
|
|
95
109
|
input = "";
|
|
96
110
|
}
|
|
97
|
-
function
|
|
111
|
+
function removeChipInternally(event, chipIndex, chipValue) {
|
|
98
112
|
if ($$restProps.disabled)
|
|
99
113
|
return;
|
|
100
|
-
|
|
101
|
-
value = value;
|
|
102
|
-
chipValues.splice(chipIndex, 1);
|
|
103
|
-
chipValues = chipValues;
|
|
114
|
+
removeChipCommon(chipValue);
|
|
104
115
|
dispatch("remove", { event, chipIndex, chipValue });
|
|
105
116
|
}
|
|
117
|
+
export function addChip(chip) {
|
|
118
|
+
inputValid = validate(chip);
|
|
119
|
+
if (inputValid === false) {
|
|
120
|
+
dispatch("invalidManually", { input: chip });
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
addChipCommon(chip);
|
|
124
|
+
dispatch("addManually", { chipIndex: value.length - 1, chipValue: chip });
|
|
125
|
+
}
|
|
126
|
+
export function removeChip(chip) {
|
|
127
|
+
if ($$restProps.disabled)
|
|
128
|
+
return;
|
|
129
|
+
removeChipCommon(chip);
|
|
130
|
+
dispatch("removeManually", { chipValue: chip });
|
|
131
|
+
}
|
|
106
132
|
$:
|
|
107
133
|
classesInvalid = inputValid === false ? invalid : "";
|
|
108
134
|
$:
|
|
@@ -124,7 +150,7 @@ $:
|
|
|
124
150
|
<div class="input-chip {classesBase}" class:opacity-50={$$restProps.disabled}>
|
|
125
151
|
<!-- NOTE: Don't use `hidden` as it prevents `required` from operating -->
|
|
126
152
|
<div class="h-0 overflow-hidden">
|
|
127
|
-
<select bind:this={selectElement} bind:value {name} multiple {required} tabindex="-1">
|
|
153
|
+
<select bind:this={selectElement} bind:value {name} multiple {required} aria-label={label} tabindex="-1">
|
|
128
154
|
<!-- NOTE: options are required! -->
|
|
129
155
|
{#each value as option}<option value={option}>{option}</option>{/each}
|
|
130
156
|
</select>
|
|
@@ -132,7 +158,7 @@ $:
|
|
|
132
158
|
<!-- Chip Wrapper -->
|
|
133
159
|
<div class="input-chip-wrapper {classesChipWrapper}">
|
|
134
160
|
<!-- Input Field -->
|
|
135
|
-
<form on:submit={
|
|
161
|
+
<form on:submit={addChipInternally}>
|
|
136
162
|
<input
|
|
137
163
|
type="text"
|
|
138
164
|
bind:value={input}
|
|
@@ -158,9 +184,7 @@ $:
|
|
|
158
184
|
<button
|
|
159
185
|
type="button"
|
|
160
186
|
class="chip {chips}"
|
|
161
|
-
on:click={(e) =>
|
|
162
|
-
removeChip(e, i, val);
|
|
163
|
-
}}
|
|
187
|
+
on:click={(e) => removeChipInternally(e, i, val)}
|
|
164
188
|
on:click
|
|
165
189
|
on:keypress
|
|
166
190
|
on:keydown
|
|
@@ -44,6 +44,8 @@ declare class __sveltets_Render<ListTransitionIn extends Transition = FlyTransit
|
|
|
44
44
|
regionChipList?: string | undefined;
|
|
45
45
|
/** Provide arbitrary classes to style the input field region.*/
|
|
46
46
|
regionInput?: string | undefined;
|
|
47
|
+
/** Provide the ARIA label for the select input.*/
|
|
48
|
+
label?: string | undefined;
|
|
47
49
|
/** Enable/Disable transitions*/
|
|
48
50
|
transitions?: boolean | undefined;
|
|
49
51
|
/** Provide the transition used in list on entry.*/
|
|
@@ -62,6 +64,8 @@ declare class __sveltets_Render<ListTransitionIn extends Transition = FlyTransit
|
|
|
62
64
|
chipTransitionOut?: ChipTransitionOut | undefined;
|
|
63
65
|
/** Transition params provided to `ChipTransitionOut`.*/
|
|
64
66
|
chipTransitionOutParams?: TransitionParams<ChipTransitionOut> | undefined;
|
|
67
|
+
addChip?: ((chip: string) => void) | undefined;
|
|
68
|
+
removeChip?: ((chip: string) => void) | undefined;
|
|
65
69
|
};
|
|
66
70
|
events(): {
|
|
67
71
|
input: Event;
|
|
@@ -81,10 +85,20 @@ declare class __sveltets_Render<ListTransitionIn extends Transition = FlyTransit
|
|
|
81
85
|
chipIndex: number;
|
|
82
86
|
chipValue: string;
|
|
83
87
|
}>;
|
|
88
|
+
addManually: CustomEvent<{
|
|
89
|
+
chipIndex: number;
|
|
90
|
+
chipValue: string;
|
|
91
|
+
}>;
|
|
92
|
+
removeManually: CustomEvent<{
|
|
93
|
+
chipValue: string;
|
|
94
|
+
}>;
|
|
84
95
|
invalid: CustomEvent<{
|
|
85
96
|
event: SubmitEvent;
|
|
86
97
|
input: string;
|
|
87
98
|
}>;
|
|
99
|
+
invalidManually: CustomEvent<{
|
|
100
|
+
input: string;
|
|
101
|
+
}>;
|
|
88
102
|
} & {
|
|
89
103
|
[evt: string]: CustomEvent<any>;
|
|
90
104
|
};
|
|
@@ -94,5 +108,7 @@ export type InputChipProps<ListTransitionIn extends Transition = FlyTransition,
|
|
|
94
108
|
export type InputChipEvents<ListTransitionIn extends Transition = FlyTransition, ListTransitionOut extends Transition = FlyTransition, ChipTransitionIn extends Transition = ScaleTransition, ChipTransitionOut extends Transition = ScaleTransition> = ReturnType<__sveltets_Render<ListTransitionIn, ListTransitionOut, ChipTransitionIn, ChipTransitionOut>['events']>;
|
|
95
109
|
export type InputChipSlots<ListTransitionIn extends Transition = FlyTransition, ListTransitionOut extends Transition = FlyTransition, ChipTransitionIn extends Transition = ScaleTransition, ChipTransitionOut extends Transition = ScaleTransition> = ReturnType<__sveltets_Render<ListTransitionIn, ListTransitionOut, ChipTransitionIn, ChipTransitionOut>['slots']>;
|
|
96
110
|
export default class InputChip<ListTransitionIn extends Transition = FlyTransition, ListTransitionOut extends Transition = FlyTransition, ChipTransitionIn extends Transition = ScaleTransition, ChipTransitionOut extends Transition = ScaleTransition> extends SvelteComponentTyped<InputChipProps<ListTransitionIn, ListTransitionOut, ChipTransitionIn, ChipTransitionOut>, InputChipEvents<ListTransitionIn, ListTransitionOut, ChipTransitionIn, ChipTransitionOut>, InputChipSlots<ListTransitionIn, ListTransitionOut, ChipTransitionIn, ChipTransitionOut>> {
|
|
111
|
+
get addChip(): (chip: string) => void;
|
|
112
|
+
get removeChip(): (chip: string) => void;
|
|
97
113
|
}
|
|
98
114
|
export {};
|
|
@@ -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 /> -->
|
|
@@ -10,8 +10,6 @@ export let checkedNodes = [];
|
|
|
10
10
|
export let indeterminateNodes = [];
|
|
11
11
|
export let width = "w-full";
|
|
12
12
|
export let spacing = "space-y-1";
|
|
13
|
-
export let open = false;
|
|
14
|
-
export let disabled = false;
|
|
15
13
|
export let padding = "py-4 px-4";
|
|
16
14
|
export let indent = "ml-4";
|
|
17
15
|
export let hover = "hover:variant-soft";
|
|
@@ -23,11 +21,9 @@ export let regionSummary = "";
|
|
|
23
21
|
export let regionSymbol = "";
|
|
24
22
|
export let regionChildren = "";
|
|
25
23
|
export let labelledby = "";
|
|
26
|
-
setContext("open", open);
|
|
27
24
|
setContext("selection", selection);
|
|
28
25
|
setContext("multiple", multiple);
|
|
29
26
|
setContext("relational", relational);
|
|
30
|
-
setContext("disabled", disabled);
|
|
31
27
|
setContext("padding", padding);
|
|
32
28
|
setContext("indent", indent);
|
|
33
29
|
setContext("hover", hover);
|
|
@@ -53,14 +49,7 @@ $:
|
|
|
53
49
|
classesBase = `${width} ${spacing} ${$$props.class ?? ""}`;
|
|
54
50
|
</script>
|
|
55
51
|
|
|
56
|
-
<div
|
|
57
|
-
class="tree {classesBase}"
|
|
58
|
-
data-testid="tree"
|
|
59
|
-
role="tree"
|
|
60
|
-
aria-multiselectable={multiple}
|
|
61
|
-
aria-label={labelledby}
|
|
62
|
-
aria-disabled={disabled}
|
|
63
|
-
>
|
|
52
|
+
<div class="tree {classesBase}" data-testid="tree" role="tree" aria-multiselectable={multiple} aria-label={labelledby}>
|
|
64
53
|
{#if nodes && nodes.length > 0}
|
|
65
54
|
<RecursiveTreeViewItem
|
|
66
55
|
{nodes}
|
|
@@ -23,10 +23,6 @@ declare const __propDef: {
|
|
|
23
23
|
width?: string | undefined;
|
|
24
24
|
/** Provide classes to set the vertical spacing between items.*/
|
|
25
25
|
spacing?: string | undefined;
|
|
26
|
-
/** Set open by default on load.*/
|
|
27
|
-
open?: boolean | undefined;
|
|
28
|
-
/** Set the tree disabled state*/
|
|
29
|
-
disabled?: boolean | undefined;
|
|
30
26
|
/** Provide classes to set the tree item padding styles.*/
|
|
31
27
|
padding?: string | undefined;
|
|
32
28
|
/** Provide classes to set the tree children indentation*/
|
|
@@ -60,7 +60,7 @@ $:
|
|
|
60
60
|
<!-- Language -->
|
|
61
61
|
<span class="codeblock-language">{languageFormatter(language)}</span>
|
|
62
62
|
<!-- Copy Button -->
|
|
63
|
-
<button class="codeblock-btn {button}" on:click={onCopyClick} use:clipboard={code}>
|
|
63
|
+
<button type="button" class="codeblock-btn {button}" on:click={onCopyClick} use:clipboard={code}>
|
|
64
64
|
{!copyState ? buttonLabel : buttonCopied}
|
|
65
65
|
</button>
|
|
66
66
|
</header>
|