UNPKG

vuestic-ui

Version:
40 lines (39 loc) 1.43 kB
import { computed, unref, watch } from "vue"; import { u as useSyncProp } from "./useSyncProp.mjs"; import { V as VaDropdown } from "../components/va-dropdown/index.mjs"; import { e as extractComponentProps } from "../utils/component-options/extract-component-options.mjs"; import { f as filterComponentProps } from "../utils/component-options/filter-props.mjs"; const VaDropdownProps = extractComponentProps( VaDropdown, ["innerAnchorSelector", "stateful", "keyboardNavigation", "modelValue"] ); const useDropdownableProps = { ...VaDropdownProps, modelValue: {}, /** * Close dropdown on value updated. * @default null - behavior controlled by component */ closeOnChange: { type: Boolean, default: null }, isOpen: { type: Boolean, default: void 0 } }; const useDropdownableEmits = ["update:isOpen"]; const useDropdownable = function(props, emit, options = {}) { const [isOpenSync] = useSyncProp("isOpen", props, emit, false); const doWatch = computed(() => props.closeOnChange !== null ? props.closeOnChange : unref(options.defaultCloseOnValueUpdate || false)); watch(() => props.modelValue, () => { if (doWatch.value) { isOpenSync.value = false; } }); return { dropdownProps: filterComponentProps(VaDropdownProps), isOpenSync }; }; export { useDropdownableEmits as a, useDropdownable as b, useDropdownableProps as u }; //# sourceMappingURL=useDropdownable.mjs.map