vue-amazing-ui
Version:
An Amazing Vue3 UI Components Library, Using TypeScript.
198 lines (197 loc) • 4.6 kB
JavaScript
import { defineComponent as M, reactive as u, provide as p, computed as g, watch as b, renderSlot as S, createBlock as A, openBlock as I, resolveDynamicComponent as _, withCtx as x } from "vue";
import { TinyColor as a } from "@ctrl/tinycolor";
import { generate as D } from "@ant-design/colors";
const j = /* @__PURE__ */ M({
__name: "ConfigProvider",
props: {
theme: { default: () => ({}) },
abstract: { type: Boolean, default: !0 },
tag: { default: "div" }
},
setup(B) {
const s = B, c = u({
colorPalettes: [],
shadowColor: ""
}), n = u({
Alert: {
colorPalettes: [],
shadowColor: ""
},
BackTop: {
colorPalettes: [],
shadowColor: ""
},
Button: {
colorPalettes: [],
shadowColor: ""
},
Calendar: {
colorPalettes: [],
shadowColor: ""
},
Carousel: {
colorPalettes: [],
shadowColor: ""
},
Checkbox: {
colorPalettes: [],
shadowColor: ""
},
ColorPicker: {
colorPalettes: [],
shadowColor: ""
},
DatePicker: {
colorPalettes: [],
shadowColor: ""
},
FloatButton: {
colorPalettes: [],
shadowColor: ""
},
Image: {
colorPalettes: [],
shadowColor: ""
},
Input: {
colorPalettes: [],
shadowColor: ""
},
InputNumber: {
colorPalettes: [],
shadowColor: ""
},
InputSearch: {
colorPalettes: [],
shadowColor: ""
},
LoadingBar: {
colorPalettes: [],
shadowColor: ""
},
Message: {
colorPalettes: [],
shadowColor: ""
},
Modal: {
colorPalettes: [],
shadowColor: ""
},
Notification: {
colorPalettes: [],
shadowColor: ""
},
Pagination: {
colorPalettes: [],
shadowColor: ""
},
Popconfirm: {
colorPalettes: [],
shadowColor: ""
},
Progress: {
colorPalettes: [],
shadowColor: ""
},
Radio: {
colorPalettes: [],
shadowColor: ""
},
Select: {
colorPalettes: [],
shadowColor: ""
},
Slider: {
colorPalettes: [],
shadowColor: ""
},
Spin: {
colorPalettes: [],
shadowColor: ""
},
Steps: {
colorPalettes: [],
shadowColor: ""
},
Swiper: {
colorPalettes: [],
shadowColor: ""
},
Switch: {
colorPalettes: [],
shadowColor: ""
},
Tabs: {
colorPalettes: [],
shadowColor: ""
},
Textarea: {
colorPalettes: [],
shadowColor: ""
},
TextScroll: {
colorPalettes: [],
shadowColor: ""
},
Upload: {
colorPalettes: [],
shadowColor: ""
}
});
p("common", c), p("components", n);
const h = g(() => "common" in s.theme ? s.theme.common : null), T = g(() => {
const o = { ...s.theme };
return "common" in o && delete o.common, o;
});
b(
h,
(o) => {
const e = i(o?.primaryColor || "#1677ff");
c.colorPalettes = e, c.shadowColor = C(e[0]);
},
{
immediate: !0
}
), b(
T,
(o) => {
Object.keys(o).forEach((e) => {
const l = o[e]?.primaryColor || h.value?.primaryColor || "#1677ff", r = i(l);
n[e].colorPalettes = r, n[e].shadowColor = C(r[0]);
});
},
{
immediate: !0
}
);
function i(o) {
return D(o);
}
function d(o) {
return o >= 0 && o <= 255;
}
function C(o, e = "#ffffff") {
const { r: l, g: r, b: m, a: y } = new a(o).toRgb();
if (y < 1) return o;
const { r: k, g: v, b: R } = new a(e).toRgb();
for (let t = 0.01; t <= 1; t += 0.01) {
const w = Math.round((l - k * (1 - t)) / t), P = Math.round((r - v * (1 - t)) / t), f = Math.round((m - R * (1 - t)) / t);
if (d(w) && d(P) && d(f))
return new a({ r: w, g: P, b: f, a: Math.round(t * 100) / 100 }).toRgbString();
}
return new a({ r: l, g: r, b: m, a: 1 }).toRgbString();
}
return (o, e) => o.abstract ? S(o.$slots, "default", { key: 0 }) : (I(), A(_(o.tag), {
key: 1,
class: "config-provider-wrap"
}, {
default: x(() => [
S(o.$slots, "default")
]),
_: 3
}));
}
});
export {
j as default
};