UNPKG

vue-data-ui

Version:

A user-empowering data visualization Vue 3 components library for eloquent data storytelling

136 lines (135 loc) 3.56 kB
import { ref as l, computed as k, watch as I, withDirectives as P, createElementBlock as r, openBlock as n, withKeys as S, createElementVNode as u, createCommentVNode as z, normalizeStyle as a, createVNode as F, Fragment as E, renderList as N, unref as O } from "vue"; import C from "./BaseIcon-CCivwZUq.js"; import { F as V } from "./index-q-LPw2IT.js"; import { v as D } from "./vClickOutside-C6WiFswA.js"; import { _ as K } from "./_plugin-vue_export-helper-CHgC5LLL.js"; const $ = ["onClick"], L = { style: { position: "absolute", top: "50%", left: "50%", transform: "translate(-50%, -46%)" } }, T = ["value"], j = { __name: "ColorPicker", props: { value: { type: String, default: "#ffffff" }, size: { type: String, default: "50px" }, backgroundColor: { type: String, default: "#FFFFFF" }, buttonBorderColor: { type: String, default: "#FFFFFF" } }, emits: ["update:value"], setup(e, { emit: m }) { const c = e, s = m, g = l(null), y = k(() => ({ backgroundColor: c.value, width: "100%", height: "100%", cursor: "pointer" })), i = l(null), o = l(!1), b = () => { i.value?.click(); }; function h(t) { s("update:value", t), o.value = !1; } function _() { o.value = !1; } function d() { o.value && _(); } const x = (t) => { const v = t.target.value; s("update:value", v); }, p = k(() => V(c.value)); async function w() { o.value = !o.value; } I( () => c.value, (t) => { i.value.value = t; } ); const B = l([ "#000000", "#FFFFFF", "#FF5733", "#33FF57", "#3357FF", "#FFC300", "#800080", "#FF1493", "#00CED1" ]); return (t, v) => P((n(), r("div", { onKeydown: S(d, ["esc"]), style: { height: "100%", width: "100%", position: "relative" } }, [ u("button", { class: "icon", onClick: w, style: a(y.value) }, [ F(C, { name: "palette", stroke: p.value, size: 22 }, null, 8, ["stroke"]) ], 4), o.value ? (n(), r("div", { key: 0, ref_key: "picker", ref: g, tabindex: "0", class: "vue-ui-color-picker", style: a({ backgroundColor: e.backgroundColor }) }, [ (n(!0), r(E, null, N(B.value, (f) => (n(), r("button", { tabindex: "0", class: "vue-ui-color-picker-option", style: a({ backgroundColor: f, outline: `1px solid ${e.buttonBorderColor}` }), onClick: () => h(f) }, null, 12, $))), 256)), u("button", { class: "vue-ui-color-picker-option", onClick: b, style: a({ backgroundColor: e.value, outline: `1px solid ${e.buttonBorderColor}` }) }, [ u("div", L, [ F(C, { name: "colorPicker", stroke: p.value, size: 22 }, null, 8, ["stroke"]) ]), u("input", { ref_key: "colorInput", ref: i, type: "color", value: e.value, class: "hidden-input", onInput: x }, null, 40, T) ], 4) ], 4)) : z("", !0) ], 32)), [ [O(D), d] ]); } }, M = /* @__PURE__ */ K(j, [["__scopeId", "data-v-f6dd9192"]]); export { M as C };