<script setup lang="ts">
import { computed } from 'vue'
import type { KbxFieldState } from '@kbx/contracts'
import KbxNumberField from './KbxNumberField.vue'
const props=withDefaults(defineProps<{modelValue?:number|null;label:string;unit?:string;required?:boolean;readonly?:boolean;disabled?:boolean;error?:string;warning?:string;helpText?:string;state?:KbxFieldState;availableQuantity?:number|null;allowNegative?:boolean;precision?:number}>(),{unit:'EA',allowNegative:false,precision:0,state:'default'})
const emit=defineEmits<{ 'update:modelValue':[number|null] }>()
const effectiveError=computed(()=>props.error ?? (props.availableQuantity!=null && props.modelValue!=null && props.modelValue>props.availableQuantity ? `출고 가능 수량은 ${props.availableQuantity}${props.unit}입니다.` : undefined))
</script>
<template><KbxNumberField :model-value="modelValue" :label="label" :required="required" :readonly="readonly" :disabled="disabled" :error="effectiveError" :warning="warning" :help-text="helpText" :state="state" :precision="precision" :min="allowNegative?undefined:0" :suffix="unit" @update:model-value="emit('update:modelValue',$event)" /></template>
