bootstrap-vue-next
Version:
Seamless integration of Vue 3, Bootstrap 5, and TypeScript for modern, type-safe UI development
51 lines (50 loc) • 1.71 kB
JavaScript
require("./chunk-CoQrYLCe.js");
const require_object = require("./object-BN7QwMcz.js");
let vue = require("vue");
//#region src/composables/useFormSelect.ts
var useFormSelect = (options, props) => {
const isComplex = (option) => typeof option === "object" && option !== null && "options" in option && Array.isArray(option.options);
const normalizeOption = (option) => {
const propsValue = (0, vue.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 = require_object.get(option, propsValue.valueField);
const text = require_object.get(option, propsValue.textField);
const disabled = require_object.get(option, propsValue.disabledField);
const opts = propsValue.optionsField ? require_object.get(option, propsValue.optionsField) : void 0;
const label = (propsValue.labelField ? require_object.get(option, propsValue.labelField) : void 0) || text;
if (opts !== void 0 && Array.isArray(opts)) return {
label,
options: opts
};
return {
...typeof option === "object" ? option : void 0,
value,
text,
disabled
};
};
const normalizeOptions = (opts) => opts.map((option) => normalizeOption(option));
return {
normalizedOptions: (0, vue.computed)(() => normalizeOptions((0, vue.toValue)(options))),
isComplex
};
};
//#endregion
Object.defineProperty(exports, "useFormSelect", {
enumerable: true,
get: function() {
return useFormSelect;
}
});
//# sourceMappingURL=useFormSelect-CiIMUolC.js.map