mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-21 13:23:14 +01:00
* chore: get front end tests passing * chore: add @vue/runtime-core to fix types for $t * chore: sort lockfile * Discard changes to frontend/pnpm-lock.yaml * chore: sort lockfile * chore: fix some type errors * chore: switch from nuxi typecheck to vue-tsc to force a known good version * chore: linting * chore: update pnpm version in frontend test * feat: add proper pagination type (need to sort why it still doesn't work) * chore: format imports and initialize totalPrice in label page to null when no label is present * chore: update pnpm to v9.12.2, merge ItemSummaryPaginationResult with PaginationResult, and handle error in label generator more gracefully * chore: lint --------- Co-authored-by: Matt Kilgore <matthew@kilgore.dev>
102 lines
2.3 KiB
Vue
102 lines
2.3 KiB
Vue
<template>
|
|
<div v-if="!inline" class="form-control w-full">
|
|
<label class="label">
|
|
<span class="label-text"> {{ label }} </span>
|
|
<span
|
|
:class="{
|
|
'text-red-600':
|
|
typeof value === 'string' &&
|
|
((maxLength !== -1 && value.length > maxLength) || (minLength !== -1 && value.length < minLength)),
|
|
}"
|
|
>
|
|
{{ typeof value === "string" && (maxLength !== -1 || minLength !== -1) ? `${value.length}/${maxLength}` : "" }}
|
|
</span>
|
|
</label>
|
|
<input
|
|
ref="input"
|
|
v-model="value"
|
|
:placeholder="placeholder"
|
|
:type="type"
|
|
:required="required"
|
|
class="input input-bordered w-full"
|
|
/>
|
|
</div>
|
|
<div v-else class="sm:grid sm:grid-cols-4 sm:items-start sm:gap-4">
|
|
<label class="label">
|
|
<span class="label-text"> {{ label }} </span>
|
|
<span
|
|
:class="{
|
|
'text-red-600':
|
|
typeof value === 'string' &&
|
|
((maxLength !== -1 && value.length > maxLength) || (minLength !== -1 && value.length < minLength)),
|
|
}"
|
|
>
|
|
{{ typeof value === "string" && (maxLength !== -1 || minLength !== -1) ? `${value.length}/${maxLength}` : "" }}
|
|
</span>
|
|
</label>
|
|
<input
|
|
v-model="value"
|
|
:placeholder="placeholder"
|
|
:type="type"
|
|
:required="required"
|
|
class="input input-bordered col-span-3 mt-2 w-full"
|
|
/>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
const props = defineProps({
|
|
label: {
|
|
type: String,
|
|
default: "",
|
|
},
|
|
modelValue: {
|
|
type: [String, Number],
|
|
default: null,
|
|
},
|
|
required: {
|
|
type: [Boolean],
|
|
default: null,
|
|
},
|
|
type: {
|
|
type: String,
|
|
default: "text",
|
|
},
|
|
triggerFocus: {
|
|
type: Boolean,
|
|
default: null,
|
|
},
|
|
inline: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
placeholder: {
|
|
type: String,
|
|
default: "",
|
|
},
|
|
maxLength: {
|
|
type: Number,
|
|
default: -1,
|
|
required: false,
|
|
},
|
|
minLength: {
|
|
type: Number,
|
|
default: -1,
|
|
required: false,
|
|
},
|
|
});
|
|
|
|
const input = ref<HTMLElement | null>(null);
|
|
|
|
whenever(
|
|
() => props.triggerFocus,
|
|
() => {
|
|
if (input.value) {
|
|
input.value.focus();
|
|
}
|
|
}
|
|
);
|
|
|
|
const value = useVModel(props, "modelValue");
|
|
</script>
|