Files
site/nova/resources/js/components/Form/CurrencyField.vue
2025-04-21 16:03:20 +02:00

61 lines
1.7 KiB
Vue

<template>
<default-field :field="field" :errors="errors" :show-help-text="showHelpText">
<template slot="field">
<div class="flex flex-wrap items-stretch w-full relative">
<div class="flex -mr-px">
<span
class="flex items-center leading-normal rounded rounded-r-none border border-r-0 border-60 px-3 whitespace-no-wrap bg-30 text-80 text-sm font-bold"
>
{{ field.currency }}
</span>
</div>
<input
class="flex-shrink flex-grow flex-auto leading-normal w-px flex-1 rounded-l-none form-control form-input form-input-bordered"
:id="field.attribute"
:dusk="field.attribute"
v-bind="extraAttributes"
:disabled="isReadonly"
@input="handleChange"
:value="value"
/>
</div>
</template>
</default-field>
</template>
<script>
import { FormField, HandlesValidationErrors } from 'laravel-nova'
export default {
mixins: [FormField, HandlesValidationErrors],
props: ['resourceName', 'resourceId', 'field'],
computed: {
defaultAttributes() {
return {
type: 'number',
min: this.field.min,
max: this.field.max,
step: this.field.step,
pattern: this.field.pattern,
placeholder: this.field.placeholder || this.field.name,
class: this.errorClasses,
}
},
extraAttributes() {
const attrs = this.field.extraAttributes
return {
// Leave the default attributes even though we can now specify
// whatever attributes we like because the old number field still
// uses the old field attributes
...this.defaultAttributes,
...attrs,
}
},
},
}
</script>