import { computed } from 'https://cdnjs.cloudflare.com/ajax/libs/vue/3.0.2/vue.esm-browser.js';
import { getWrapClass, generalizeOptions } from 'https://wws.jp/_export/code/vuejs/vue3/form_utils?codeblock=0';
const SelectForm = {
template: `
{{ msg }}
`,
props: {
value: { type: String },
options: { type: Array, default: [] },
errors: { type: Array, default: [] },
controlWrapperClasses: { type: Array, default: [] },
controlWrapperStyles: { type: Object, default: {} },
controlClasses: { type: Array, default: [] },
controlStyles: { type: Object, default: {} },
optionClasses: { type: Array, default: [] },
optionStyles: { type: Object, default: {} },
messageWrapperClasses: { type: Array, default: [] },
messageWrapperStyles: { type: Object, default: {} },
controlErrorClass: { type: String, default: 'has-error' },
messageErrorClass: { type: String, default: 'text-danger' },
},
setup(props, context) {
const computedControlWrapperClasses = computed(() => {
return getWrapClass(
props.errors,
props.controlWrapperClasses,
props.controlErrorClass
)
})
const computedMessageWrapperClasses = computed(() => {
return getWrapClass(
props.errors,
props.messageWrapperClasses,
props.messageErrorClass
)
})
const computedOptions = computed(() => {
return generalizeOptions(props.options)
})
function updateValue(v) {
context.emit('update:value', v)
}
function changeValue(v) {
context.emit('change:value', v)
}
return {
computedControlWrapperClasses,
computedMessageWrapperClasses,
computedOptions,
changeValue,
updateValue
}
}
};
export default SelectForm;