TagInput maximale Länge
This commit is contained in:
@@ -152,8 +152,9 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
|
|||||||
<TagInput
|
<TagInput
|
||||||
name="baujahr_gebaeude"
|
name="baujahr_gebaeude"
|
||||||
type="number"
|
type="number"
|
||||||
|
minlength={4}
|
||||||
|
maxlength={4}
|
||||||
onlyUnique={true}
|
onlyUnique={true}
|
||||||
minChars={4}
|
|
||||||
onFocusIn={() => {
|
onFocusIn={() => {
|
||||||
addNotification({
|
addNotification({
|
||||||
message: "Info",
|
message: "Info",
|
||||||
@@ -193,7 +194,8 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
|
|||||||
name="baujahr_heizung"
|
name="baujahr_heizung"
|
||||||
type="number"
|
type="number"
|
||||||
onlyUnique={true}
|
onlyUnique={true}
|
||||||
minChars={4}
|
minlength={4}
|
||||||
|
maxlength={4}
|
||||||
onFocusIn={() => {
|
onFocusIn={() => {
|
||||||
addNotification({
|
addNotification({
|
||||||
message: "Info",
|
message: "Info",
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
export let splitWith: string = ",";
|
export let splitWith: string = ",";
|
||||||
export let name: string = "";
|
export let name: string = "";
|
||||||
export let disable: boolean = false;
|
export let disable: boolean = false;
|
||||||
export let minChars: number = 0;
|
export let minlength: number = 0;
|
||||||
|
export let maxlength: number = Infinity;
|
||||||
export let readonly: boolean = false;
|
export let readonly: boolean = false;
|
||||||
export let onTagClick: Function = ()=>{};
|
export let onTagClick: Function = ()=>{};
|
||||||
export let onFocusIn: () => any = () => {};
|
export let onFocusIn: () => any = () => {};
|
||||||
@@ -25,7 +26,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (minChars > tag.toString().length) {
|
if (minlength > tag.toString().length || tag.toString().length > maxlength) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,15 +51,14 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="flex flex-row gap-1 h-10 p-0"
|
class="flex flex-row h-10 p-0"
|
||||||
>
|
>
|
||||||
{#if tags.length > 0}
|
{#if tags.length > 0}
|
||||||
{#each tags as tag, i}
|
{#each tags as tag, i}
|
||||||
<button class="rounded-lg bg-white px-1.5 border border-gray-300 flex flex-row items-center justify-between gap-2" type="button" on:click={onTagClick(tag)}>
|
<button class="bg-white px-1.5 border border-gray-300 flex flex-row items-center justify-between gap-2" type="button" on:click={onTagClick(tag)}>
|
||||||
{tag}
|
{tag}
|
||||||
{#if !disable && !readonly}
|
{#if !disable && !readonly}
|
||||||
<span
|
<span
|
||||||
class="svelte-tags-input-tag-remove"
|
|
||||||
on:pointerdown={() => removeTag(i)}
|
on:pointerdown={() => removeTag(i)}
|
||||||
>
|
>
|
||||||
×</span
|
×</span
|
||||||
@@ -75,12 +75,14 @@
|
|||||||
on:focusin={onFocusIn}
|
on:focusin={onFocusIn}
|
||||||
on:focusout={onFocusOut}
|
on:focusout={onFocusOut}
|
||||||
on:blur={() => {
|
on:blur={() => {
|
||||||
if (tag.toString().length >= minChars) {
|
if (tag.toString().length >= minlength && tag.toString().length < maxlength) {
|
||||||
addTag(tag)
|
addTag(tag)
|
||||||
tag = ""
|
tag = ""
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
class="input input-bordered h-10 px-2 py-1.5 {className}"
|
class="input input-bordered h-10 px-2 py-1.5 {className}"
|
||||||
|
{minlength}
|
||||||
|
{maxlength}
|
||||||
disabled={disable}
|
disabled={disable}
|
||||||
readonly={readonly}
|
readonly={readonly}
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
|
|||||||
Reference in New Issue
Block a user