UNPKG

bootstrap-vue-next

Version:

Seamless integration of Vue 3, Bootstrap 5, and TypeScript for modern, type-safe UI development

45 lines (44 loc) 1.44 kB
import { n as get } from "./object-CHQkkner.mjs"; import { computed, toValue } from "vue"; //#region src/composables/useFormSelect.ts var useFormSelect = (options, props) => { const isComplex = (option) => typeof option === "object" && option !== null && "options" in option; const normalizeOption = (option) => { const propsValue = toValue(props); if (typeof option === "string") return { value: option, text: option }; if (typeof option === "number" || typeof option === "boolean") return { value: option, text: `${option}` }; if (option instanceof Date) return { value: option, text: option.toLocaleString() }; const value = get(option, propsValue.valueField); const text = get(option, propsValue.textField); const disabled = get(option, propsValue.disabledField); const opts = propsValue.optionsField ? get(option, propsValue.optionsField) : void 0; const label = (propsValue.labelField ? get(option, propsValue.labelField) : void 0) || text; if (opts !== void 0) return { label, options: opts }; return { ...typeof option === "object" ? option : void 0, value, text, disabled }; }; const normalizeOptions = (opts) => opts.map((option) => normalizeOption(option)); return { normalizedOptions: computed(() => normalizeOptions(toValue(options))), isComplex }; }; //#endregion export { useFormSelect as t }; //# sourceMappingURL=useFormSelect-CANw3ZJG.mjs.map