| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- import { ref as C, computed as w, openBlock as d, createElementBlock as v, createVNode as f, withCtx as c, normalizeStyle as i, createElementVNode as t, Fragment as S, renderList as x, normalizeClass as I, toDisplayString as L } from "vue";
- import { n as N, I as z } from "./index2.js";
- import { _ as V } from "./index6.js";
- const $ = { class: "s-color-picker-common" }, B = { class: "picker-panel" }, E = { class: "palette" }, F = ["onClick"], P = { class: "native-row" }, U = ["value"], j = { class: "native-tip" }, A = {
- __name: "SColorPicker",
- props: {
- // 颜色值(hex),支持 v-model:value
- value: {
- type: String,
- default: ""
- },
- // 色块宽度,单位 px
- width: {
- type: Number,
- default: 40
- },
- // 透传给色块的样式
- blockStyle: {
- type: Object,
- default() {
- return {};
- }
- }
- },
- emits: ["update:value", "change"],
- setup(a, { emit: _ }) {
- const r = a, u = _, l = C(!1), m = [
- "#1677ff",
- "#1167ff",
- "#722ed1",
- "#eb2f96",
- "#f5222d",
- "#fa541c",
- "#fa8c16",
- "#faad14",
- "#13c2c2",
- "#52c41a",
- "#1afa29",
- "#44d7b6"
- ], n = w(
- () => /^#([0-9a-fA-F]{6})$/.test(r.value) ? r.value.toLowerCase() : "#1677ff"
- ), s = (e) => {
- u("update:value", e), u("change", e);
- }, k = (e) => {
- s(e), l.value = !1;
- }, h = (e) => {
- s(e.target.value);
- }, y = (e) => {
- s(e);
- };
- return (e, p) => {
- const b = z, g = V;
- return d(), v("div", $, [
- f(g, {
- trigger: "click",
- placement: "bottomLeft",
- open: l.value,
- "onUpdate:open": p[0] || (p[0] = (o) => l.value = o)
- }, {
- content: c(() => [
- t("div", B, [
- t("div", E, [
- (d(), v(S, null, x(m, (o) => t("span", {
- class: I(["swatch", { active: o.toLowerCase() === n.value }]),
- key: o,
- style: i({ backgroundColor: o }),
- onClick: (D) => k(o)
- }, null, 14, F)), 64))
- ]),
- t("div", P, [
- t("input", {
- type: "color",
- class: "native-color",
- value: n.value,
- onInput: h
- }, null, 40, U),
- t("span", j, L(e.$l("自定义颜色")), 1)
- ])
- ])
- ]),
- default: c(() => [
- f(b, {
- class: "color-input",
- value: a.value,
- style: i({ width: a.width + "px" }),
- placeholder: "",
- "onUpdate:value": y
- }, {
- prefix: c(() => [
- t("span", {
- class: "color-block",
- style: i([{ backgroundColor: n.value }, a.blockStyle])
- }, null, 4)
- ]),
- _: 1
- }, 8, ["value", "style"])
- ]),
- _: 1
- }, 8, ["open"])
- ]);
- };
- }
- }, H = /* @__PURE__ */ N(A, [["__scopeId", "data-v-4b31c826"]]);
- export {
- H as default
- };
|