UNPKG

@aplus-frontend/ui

Version:

53 lines (52 loc) 1.31 kB
import { Modal as i } from "@aplus-frontend/antdv"; import { omit as a } from "lodash-unified"; function f(o) { return typeof o == "object" && typeof o.then == "function" ? o : !1; } const m = (o) => typeof o == "function" && f(o?.()), h = (o, s = "0.7") => { try { let t = o?.toLowerCase(); if (t && /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(t)) { if (t.length === 4) { let r = "#"; for (let n = 1; n < 4; n += 1) r += t.slice(n, n + 1).concat(t.slice(n, n + 1)); t = r; } const e = []; for (let r = 1; r < 7; r += 2) e.push(parseInt("0x" + t.slice(r, r + 2))); return "rgba(" + e.join(",") + "," + s + ")"; } if (t && t.startsWith("rgb")) { let e = t.match(/(\d(\.\d+)?)+/g); return e = e?.slice(0, 3)?.concat(s), "rgba(" + e.join(",") + ")"; } return t; } catch { return; } }, p = (o) => { const { onOk: s = () => ({}) } = o; return new Promise((t, c) => { i.confirm({ onOk: async () => { try { await s(), t(!0); } catch { c(); } }, onCancel: () => { c(); }, ...a(o, ["onOk"]) }); }); }; export { p as confirmHandle, m as isAsynchronous, f as isPromise, h as transferOpacityColor };