@skeletonlabs/skeleton 2.7.1-dev.69b68256 → 2.7.1-dev.979e08b0
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.
|
@@ -62,73 +62,48 @@ onMount(() => {
|
|
|
62
62
|
function onInputHandler() {
|
|
63
63
|
inputValid = true;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
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)
|
|
65
|
+
function validate() {
|
|
66
|
+
if (!input)
|
|
82
67
|
return false;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
chipValues.splice(chipIndex, 1);
|
|
98
|
-
chipValues = chipValues;
|
|
68
|
+
input = input.trim();
|
|
69
|
+
if (validation !== void 0 && !validation(input))
|
|
70
|
+
return false;
|
|
71
|
+
if (max !== -1 && value.length >= max)
|
|
72
|
+
return false;
|
|
73
|
+
if (minlength !== -1 && input.length < minlength)
|
|
74
|
+
return false;
|
|
75
|
+
if (maxlength !== -1 && input.length > maxlength)
|
|
76
|
+
return false;
|
|
77
|
+
if (whitelist.length > 0 && !whitelist.includes(input))
|
|
78
|
+
return false;
|
|
79
|
+
if (allowDuplicates === false && value.includes(input))
|
|
80
|
+
return false;
|
|
81
|
+
return true;
|
|
99
82
|
}
|
|
100
|
-
function
|
|
83
|
+
function addChip(event) {
|
|
101
84
|
event.preventDefault();
|
|
102
85
|
inputValid = validate();
|
|
103
86
|
if (inputValid === false) {
|
|
104
87
|
dispatch("invalid", { event, input });
|
|
105
88
|
return;
|
|
106
89
|
}
|
|
107
|
-
|
|
90
|
+
input = allowUpperCase ? input : input.toLowerCase();
|
|
91
|
+
value.push(input);
|
|
92
|
+
value = value;
|
|
93
|
+
chipValues.push({ val: input, id: Math.random() });
|
|
94
|
+
chipValues = chipValues;
|
|
108
95
|
dispatch("add", { event, chipIndex: value.length - 1, chipValue: input });
|
|
109
96
|
input = "";
|
|
110
97
|
}
|
|
111
|
-
function
|
|
98
|
+
function removeChip(event, chipIndex, chipValue) {
|
|
112
99
|
if ($$restProps.disabled)
|
|
113
100
|
return;
|
|
114
|
-
|
|
101
|
+
value.splice(chipIndex, 1);
|
|
102
|
+
value = value;
|
|
103
|
+
chipValues.splice(chipIndex, 1);
|
|
104
|
+
chipValues = chipValues;
|
|
115
105
|
dispatch("remove", { event, chipIndex, chipValue });
|
|
116
106
|
}
|
|
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
|
-
}
|
|
132
107
|
$:
|
|
133
108
|
classesInvalid = inputValid === false ? invalid : "";
|
|
134
109
|
$:
|
|
@@ -158,7 +133,7 @@ $:
|
|
|
158
133
|
<!-- Chip Wrapper -->
|
|
159
134
|
<div class="input-chip-wrapper {classesChipWrapper}">
|
|
160
135
|
<!-- Input Field -->
|
|
161
|
-
<form on:submit={
|
|
136
|
+
<form on:submit={addChip}>
|
|
162
137
|
<input
|
|
163
138
|
type="text"
|
|
164
139
|
bind:value={input}
|
|
@@ -184,7 +159,9 @@ $:
|
|
|
184
159
|
<button
|
|
185
160
|
type="button"
|
|
186
161
|
class="chip {chips}"
|
|
187
|
-
on:click={(e) =>
|
|
162
|
+
on:click={(e) => {
|
|
163
|
+
removeChip(e, i, val);
|
|
164
|
+
}}
|
|
188
165
|
on:click
|
|
189
166
|
on:keypress
|
|
190
167
|
on:keydown
|
|
@@ -64,8 +64,6 @@ declare class __sveltets_Render<ListTransitionIn extends Transition = FlyTransit
|
|
|
64
64
|
chipTransitionOut?: ChipTransitionOut | undefined;
|
|
65
65
|
/** Transition params provided to `ChipTransitionOut`.*/
|
|
66
66
|
chipTransitionOutParams?: TransitionParams<ChipTransitionOut> | undefined;
|
|
67
|
-
addChip?: ((chip: string) => void) | undefined;
|
|
68
|
-
removeChip?: ((chip: string) => void) | undefined;
|
|
69
67
|
};
|
|
70
68
|
events(): {
|
|
71
69
|
input: Event;
|
|
@@ -85,20 +83,10 @@ declare class __sveltets_Render<ListTransitionIn extends Transition = FlyTransit
|
|
|
85
83
|
chipIndex: number;
|
|
86
84
|
chipValue: string;
|
|
87
85
|
}>;
|
|
88
|
-
addManually: CustomEvent<{
|
|
89
|
-
chipIndex: number;
|
|
90
|
-
chipValue: string;
|
|
91
|
-
}>;
|
|
92
|
-
removeManually: CustomEvent<{
|
|
93
|
-
chipValue: string;
|
|
94
|
-
}>;
|
|
95
86
|
invalid: CustomEvent<{
|
|
96
87
|
event: SubmitEvent;
|
|
97
88
|
input: string;
|
|
98
89
|
}>;
|
|
99
|
-
invalidManually: CustomEvent<{
|
|
100
|
-
input: string;
|
|
101
|
-
}>;
|
|
102
90
|
} & {
|
|
103
91
|
[evt: string]: CustomEvent<any>;
|
|
104
92
|
};
|
|
@@ -108,7 +96,5 @@ export type InputChipProps<ListTransitionIn extends Transition = FlyTransition,
|
|
|
108
96
|
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']>;
|
|
109
97
|
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']>;
|
|
110
98
|
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;
|
|
113
99
|
}
|
|
114
100
|
export {};
|