UNPKG

@aplus-frontend/ui

Version:

53 lines (52 loc) 1.32 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, c = "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 e = "#"; for (let n = 1; n < 4; n += 1) e += t.slice(n, n + 1).concat(t.slice(n, n + 1)); t = e; } const r = []; for (let e = 1; e < 7; e += 2) r.push(parseInt("0x" + t.slice(e, e + 2))); return "rgba(" + r.join(",") + "," + c + ")"; } if (t && t.startsWith("rgb")) { let r = t.match(/(\d(\.\d+)?)+/g); return r = r?.slice(0, 3)?.concat(c), "rgba(" + r.join(",") + ")"; } return t; } catch { return; } }, p = (o) => { const { onOk: c = () => ({}) } = o; return new Promise((t, s) => { i.confirm({ onOk: async () => { try { await c(), t(!0); } catch (r) { s(r); } }, onCancel: () => { t(!1); }, ...a(o, ["onOk"]) }); }); }; export { p as confirmHandle, m as isAsynchronous, f as isPromise, h as transferOpacityColor };