UNPKG

@aplus-frontend/ui

Version:

40 lines (39 loc) 854 B
import { onUnmounted as m } from "vue"; import { useCreateTableModal as f } from "./use-create-table-modal.mjs"; import { AsyncOpenResultError as w } from "../interface.mjs"; const a = (e) => e.id; function b(e) { const { finishCallback: c, getRowKey: r, ...l } = e, { destroy: n, openModal: i, closeModal: p, ...u } = f({ ...l, destroyOnUnmounted: !1, getRowKey: r || a }), y = async (t = [], d = {}) => { try { const o = await i(t, d) || { keys: [], rows: [] }; return c?.(o), o; } catch (o) { if (o === w.ModalCancel) return { keys: t?.map(r || a), rows: t }; throw o; } }, s = () => { p(); }; return m(() => { s(), n(); }), { open: y, destroy: n, close: s, ...u }; } export { b as useTableSelectModal };