UNPKG

ai-form-designer

Version:

vue3+adv的设计器,可视化开发页面表单

1,358 lines (1,357 loc) 42.8 kB
import { c as B } from "./_commonjsHelpers-BVfed4GL.js"; import { s as Rt, c as Je, _ as me, r as W, i as Ae, a as Mt, b as At, f as Dt, e as Vt } from "./index-CFbzusj4.js"; import { r as Ht } from "./index-B5s4z2wp.js"; import { r as D } from "./_vue_commonjs-external-NwvjgbHK.js"; import { s as Qe, b as zt } from "./index-3xKF5qWq.js"; import { s as We, a as et } from "./index-BAsJ4AfL.js"; import { f as It } from "./fade-in-scale-up.cssr-Ce2i0ZnO.js"; function Bt(e, o) { for (var r = 0; r < o.length; r++) { const l = o[r]; if (typeof l != "string" && !Array.isArray(l)) { for (const a in l) if (a !== "default" && !(a in e)) { const t = Object.getOwnPropertyDescriptor(l, a); t && Object.defineProperty(e, a, t.get ? t : { enumerable: !0, get: () => l[a] }); } } } return Object.freeze(Object.defineProperty(e, Symbol.toStringTag, { value: "Module" })); } var tt = {}, rt = {}, ot = {}, De = {}, se = {}; Object.defineProperty(se, "__esModule", { value: !0 }); se.self = nt; const Ot = Rt, jt = Je, Ft = Qe, Et = We; function nt(e) { const { fontSize: o, boxShadow2: r, popoverColor: l, textColor2: a, borderRadius: t, borderColor: i, heightSmall: s, heightMedium: f, heightLarge: y, fontSizeSmall: te, fontSizeMedium: O, fontSizeLarge: j, dividerColor: re } = e; return { panelFontSize: o, boxShadow: r, color: l, textColor: a, borderRadius: t, border: `1px solid ${i}`, heightSmall: s, heightMedium: f, heightLarge: y, fontSizeSmall: te, fontSizeMedium: O, fontSizeLarge: j, dividerColor: re }; } const Tt = (0, Ot.createTheme)({ name: "ColorPicker", common: jt.commonLight, peers: { Input: Et.inputLight, Button: Ft.buttonLight }, self: nt }); se.default = Tt; Object.defineProperty(De, "__esModule", { value: !0 }); const qt = Je, Nt = Qe, Lt = We, Kt = se, Xt = { name: "ColorPicker", common: qt.commonDark, peers: { Input: Lt.inputDark, Button: Nt.buttonDark }, self: Kt.self }; De.default = Xt; (function(e) { var o = B && B.__importDefault || function(a) { return a && a.__esModule ? a : { default: a }; }; Object.defineProperty(e, "__esModule", { value: !0 }), e.colorPickerLight = e.colorPickerDark = void 0; var r = De; Object.defineProperty(e, "colorPickerDark", { enumerable: !0, get: function() { return o(r).default; } }); var l = se; Object.defineProperty(e, "colorPickerLight", { enumerable: !0, get: function() { return o(l).default; } }); })(ot); var Ve = {}, $ = {}; Object.defineProperty($, "__esModule", { value: !0 }); $.deriveDefaultValue = Gt; $.getModeFromValue = lt; $.floor = Yt; $.normalizeHue = Jt; $.normalizeAlpha = Qt; $.convertColor = er; const d = W, Zt = me; function Gt(e, o) { switch (e[0]) { case "hex": return o ? "#000000FF" : "#000000"; case "rgb": return o ? "rgba(0, 0, 0, 1)" : "rgb(0, 0, 0)"; case "hsl": return o ? "hsla(0, 0%, 0%, 1)" : "hsl(0, 0%, 0%)"; case "hsv": return o ? "hsva(0, 0%, 0%, 1)" : "hsv(0, 0%, 0%)"; } return process.env.NODE_ENV !== "production" && (0, Zt.warn)("color-picker", "props.modes is invalid."), "#000000"; } function lt(e) { return e === null ? null : /^ *#/.test(e) ? "hex" : e.includes("rgb") ? "rgb" : e.includes("hsl") ? "hsl" : e.includes("hsv") ? "hsv" : null; } function Yt(e) { return e.map((o) => Math.floor(o)); } function Jt(e) { return e = Math.round(e), e >= 360 ? 359 : e < 0 ? 0 : e; } function Qt(e) { return e = Math.round(e * 100) / 100, e > 1 ? 1 : e < 0 ? 0 : e; } const Wt = { rgb: { hex(e) { return (0, d.toHexaString)((0, d.rgba)(e)); }, hsl(e) { const [o, r, l, a] = (0, d.rgba)(e); return (0, d.toHslaString)([...(0, d.rgb2hsl)(o, r, l), a]); }, hsv(e) { const [o, r, l, a] = (0, d.rgba)(e); return (0, d.toHsvaString)([...(0, d.rgb2hsv)(o, r, l), a]); } }, hex: { rgb(e) { return (0, d.toRgbaString)((0, d.rgba)(e)); }, hsl(e) { const [o, r, l, a] = (0, d.rgba)(e); return (0, d.toHslaString)([...(0, d.rgb2hsl)(o, r, l), a]); }, hsv(e) { const [o, r, l, a] = (0, d.rgba)(e); return (0, d.toHsvaString)([...(0, d.rgb2hsv)(o, r, l), a]); } }, hsl: { hex(e) { const [o, r, l, a] = (0, d.hsla)(e); return (0, d.toHexaString)([...(0, d.hsl2rgb)(o, r, l), a]); }, rgb(e) { const [o, r, l, a] = (0, d.hsla)(e); return (0, d.toRgbaString)([...(0, d.hsl2rgb)(o, r, l), a]); }, hsv(e) { const [o, r, l, a] = (0, d.hsla)(e); return (0, d.toHsvaString)([...(0, d.hsl2hsv)(o, r, l), a]); } }, hsv: { hex(e) { const [o, r, l, a] = (0, d.hsva)(e); return (0, d.toHexaString)([...(0, d.hsv2rgb)(o, r, l), a]); }, rgb(e) { const [o, r, l, a] = (0, d.hsva)(e); return (0, d.toRgbaString)([...(0, d.hsv2rgb)(o, r, l), a]); }, hsl(e) { const [o, r, l, a] = (0, d.hsva)(e); return (0, d.toHslaString)([...(0, d.hsv2hsl)(o, r, l), a]); } } }; function er(e, o, r) { return r = r || lt(e), r ? r === o ? e : Wt[r][o](e) : null; } Object.defineProperty(Ve, "__esModule", { value: !0 }); const he = Ae, tr = W, U = D, rr = $, le = "12px", or = 12, q = "6px"; Ve.default = (0, U.defineComponent)({ name: "AlphaSlider", props: { clsPrefix: { type: String, required: !0 }, rgba: { type: Array, default: null }, alpha: { type: Number, default: 0 }, onUpdateAlpha: { type: Function, required: !0 }, onComplete: Function }, setup(e) { const o = (0, U.ref)(null); function r(t) { !o.value || !e.rgba || ((0, he.on)("mousemove", document, l), (0, he.on)("mouseup", document, a), l(t)); } function l(t) { const { value: i } = o; if (!i) return; const { width: s, left: f } = i.getBoundingClientRect(), y = (t.clientX - f) / (s - or); e.onUpdateAlpha((0, rr.normalizeAlpha)(y)); } function a() { var t; (0, he.off)("mousemove", document, l), (0, he.off)("mouseup", document, a), (t = e.onComplete) === null || t === void 0 || t.call(e); } return { railRef: o, railBackgroundImage: (0, U.computed)(() => { const { rgba: t } = e; return t ? `linear-gradient(to right, rgba(${t[0]}, ${t[1]}, ${t[2]}, 0) 0%, rgba(${t[0]}, ${t[1]}, ${t[2]}, 1) 100%)` : ""; }), handleMouseDown: r }; }, render() { const { clsPrefix: e } = this; return (0, U.h)( "div", { class: `${e}-color-picker-slider`, ref: "railRef", style: { height: le, borderRadius: q }, onMousedown: this.handleMouseDown }, (0, U.h)( "div", { style: { borderRadius: q, position: "absolute", left: 0, right: 0, top: 0, bottom: 0, overflow: "hidden" } }, (0, U.h)("div", { class: `${e}-color-picker-checkboard` }), (0, U.h)("div", { class: `${e}-color-picker-slider__image`, style: { backgroundImage: this.railBackgroundImage } }) ), this.rgba && (0, U.h)( "div", { style: { position: "absolute", left: q, right: q, top: 0, bottom: 0 } }, (0, U.h)( "div", { class: `${e}-color-picker-handle`, style: { left: `calc(${this.alpha * 100}% - ${q})`, borderRadius: q, width: le, height: le } }, (0, U.h)("div", { class: `${e}-color-picker-handle__fill`, style: { backgroundColor: (0, tr.toRgbaString)(this.rgba), borderRadius: q, width: le, height: le } }) ) ) ); } }); var He = {}, ze = {}, ee = {}; Object.defineProperty(ee, "__esModule", { value: !0 }); ee.colorPickerInjectionKey = void 0; const nr = me; ee.colorPickerInjectionKey = (0, nr.createInjectionKey)("n-color-picker"); Object.defineProperty(ze, "__esModule", { value: !0 }); const ae = D, lr = et, ar = ee; function ir(e) { return /^\d{1,3}\.?\d*$/.test(e.trim()) ? Math.max(0, Math.min(Number.parseInt(e), 255)) : !1; } function sr(e) { return /^\d{1,3}\.?\d*$/.test(e.trim()) ? Math.max(0, Math.min(Number.parseInt(e), 360)) : !1; } function ur(e) { return /^\d{1,3}\.?\d*$/.test(e.trim()) ? Math.max(0, Math.min(Number.parseInt(e), 100)) : !1; } function cr(e) { const o = e.trim(); return /^#[0-9a-fA-F]+$/.test(o) ? [4, 5, 7, 9].includes(o.length) : !1; } function dr(e) { return /^\d{1,3}\.?\d*%$/.test(e.trim()) ? Math.max(0, Math.min(Number.parseInt(e) / 100, 100)) : !1; } const hr = { paddingSmall: "0 4px" }; ze.default = (0, ae.defineComponent)({ name: "ColorInputUnit", props: { label: { type: String, required: !0 }, value: { type: [Number, String], default: null }, showAlpha: Boolean, onUpdateValue: { type: Function, required: !0 } }, setup(e) { const o = (0, ae.ref)(""), { themeRef: r } = (0, ae.inject)(ar.colorPickerInjectionKey, null); (0, ae.watchEffect)(() => { o.value = l(); }); function l() { const { value: i } = e; if (i === null) return ""; const { label: s } = e; return s === "HEX" ? i : s === "A" ? `${Math.floor(i * 100)}%` : String(Math.floor(i)); } function a(i) { o.value = i; } function t(i) { let s, f; switch (e.label) { case "HEX": f = cr(i), f && e.onUpdateValue(i), o.value = l(); break; case "H": s = sr(i), s === !1 ? o.value = l() : e.onUpdateValue(s); break; case "S": case "L": case "V": s = ur(i), s === !1 ? o.value = l() : e.onUpdateValue(s); break; case "A": s = dr(i), s === !1 ? o.value = l() : e.onUpdateValue(s); break; case "R": case "G": case "B": s = ir(i), s === !1 ? o.value = l() : e.onUpdateValue(s); break; } } return { mergedTheme: r, inputValue: o, handleInputChange: t, handleInputUpdateValue: a }; }, render() { const { mergedTheme: e } = this; return (0, ae.h)(lr.NInput, { size: "small", placeholder: this.label, theme: e.peers.Input, themeOverrides: e.peerOverrides.Input, builtinThemeOverrides: hr, value: this.inputValue, onUpdateValue: this.handleInputUpdateValue, onChange: this.handleInputChange, // add more space for xxx% input style: this.label === "A" ? "flex-grow: 1.25;" : "" }); } }); var fr = B && B.__importDefault || function(e) { return e && e.__esModule ? e : { default: e }; }; Object.defineProperty(He, "__esModule", { value: !0 }); const R = W, J = D, pr = et, Ze = fr(ze); He.default = (0, J.defineComponent)({ name: "ColorInput", props: { clsPrefix: { type: String, required: !0 }, mode: { type: String, required: !0 }, modes: { type: Array, required: !0 }, showAlpha: { type: Boolean, required: !0 }, value: { // for hex to get percise value type: String, default: null }, valueArr: { type: Array, default: null }, onUpdateValue: { type: Function, required: !0 }, onUpdateMode: { type: Function, required: !0 } }, setup(e) { return { handleUnitUpdateValue(o, r) { const { showAlpha: l } = e; if (e.mode === "hex") { e.onUpdateValue((l ? R.toHexaString : R.toHexString)(r)); return; } let a; switch (e.valueArr === null ? a = [0, 0, 0, 0] : a = Array.from(e.valueArr), e.mode) { case "hsv": a[o] = r, e.onUpdateValue((l ? R.toHsvaString : R.toHsvString)(a)); break; case "rgb": a[o] = r, e.onUpdateValue((l ? R.toRgbaString : R.toRgbString)(a)); break; case "hsl": a[o] = r, e.onUpdateValue((l ? R.toHslaString : R.toHslString)(a)); break; } } }; }, render() { const { clsPrefix: e, modes: o } = this; return (0, J.h)( "div", { class: `${e}-color-picker-input` }, (0, J.h)("div", { class: `${e}-color-picker-input__mode`, onClick: this.onUpdateMode, style: { cursor: o.length === 1 ? "" : "pointer" } }, this.mode.toUpperCase() + (this.showAlpha ? "A" : "")), (0, J.h)(pr.NInputGroup, null, { default: () => { const { mode: r, valueArr: l, showAlpha: a } = this; if (r === "hex") { let t = null; try { t = l === null ? null : (a ? R.toHexaString : R.toHexString)(l); } catch { } return (0, J.h)(Ze.default, { label: "HEX", showAlpha: a, value: t, onUpdateValue: (i) => { this.handleUnitUpdateValue(0, i); } }); } return (r + (a ? "a" : "")).split("").map((t, i) => (0, J.h)(Ze.default, { label: t.toUpperCase(), value: l === null ? null : l[i], onUpdateValue: (s) => { this.handleUnitUpdateValue(i, s); } })); } }) ); } }); var Ie = {}; Object.defineProperty(Ie, "__esModule", { value: !0 }); const Me = W, ie = D, gr = me, Ge = $; function vr(e, o) { if (o === "hsv") { const [r, l, a, t] = (0, Me.hsva)(e); return (0, Me.toRgbaString)([...(0, Me.hsv2rgb)(r, l, a), t]); } return e; } function br(e) { const o = document.createElement("canvas").getContext("2d"); return o ? (o.fillStyle = e, o.fillStyle) : "#000000"; } Ie.default = (0, ie.defineComponent)({ name: "ColorPickerSwatches", props: { clsPrefix: { type: String, required: !0 }, mode: { type: String, required: !0 }, swatches: { type: Array, required: !0 }, onUpdateColor: { type: Function, required: !0 } }, setup(e) { const o = (0, ie.computed)(() => e.swatches.map((t) => { const i = (0, Ge.getModeFromValue)(t); return { value: t, mode: i, legalValue: vr(t, i) }; })); function r(t) { const { mode: i } = e; let { value: s, mode: f } = t; return f || (f = "hex", /^[a-zA-Z]+$/.test(s) ? s = br(s) : ((0, gr.warn)("color-picker", `color ${s} in swatches is invalid.`), s = "#000000")), f === i ? s : (0, Ge.convertColor)(s, i, f); } function l(t) { e.onUpdateColor(r(t)); } function a(t, i) { t.key === "Enter" && l(i); } return { parsedSwatchesRef: o, handleSwatchSelect: l, handleSwatchKeyDown: a }; }, render() { const { clsPrefix: e } = this; return (0, ie.h)("div", { class: `${e}-color-picker-swatches` }, this.parsedSwatchesRef.map((o) => (0, ie.h)( "div", { class: `${e}-color-picker-swatch`, tabindex: 0, onClick: () => { this.handleSwatchSelect(o); }, onKeydown: (r) => { this.handleSwatchKeyDown(r, o); } }, (0, ie.h)("div", { class: `${e}-color-picker-swatch__fill`, style: { background: o.legalValue } }) ))); } }); var Be = {}; Object.defineProperty(Be, "__esModule", { value: !0 }); const mr = W, N = D, _r = ee; Be.default = (0, N.defineComponent)({ name: "ColorPickerTrigger", slots: Object, props: { clsPrefix: { type: String, required: !0 }, value: { type: String, default: null }, hsla: { type: Array, default: null }, disabled: Boolean, onClick: Function }, setup(e) { const { colorPickerSlots: o, renderLabelRef: r } = (0, N.inject)(_r.colorPickerInjectionKey, null); return () => { const { hsla: l, value: a, clsPrefix: t, onClick: i, disabled: s } = e, f = o.label || r.value; return (0, N.h)( "div", { class: [ `${t}-color-picker-trigger`, s && `${t}-color-picker-trigger--disabled` ], onClick: s ? void 0 : i }, (0, N.h)( "div", { class: `${t}-color-picker-trigger__fill` }, (0, N.h)("div", { class: `${t}-color-picker-checkboard` }), (0, N.h)("div", { style: { position: "absolute", left: 0, right: 0, top: 0, bottom: 0, backgroundColor: l ? (0, mr.toHslaString)(l) : "" } }), a && l ? (0, N.h)("div", { class: `${t}-color-picker-trigger__value`, style: { color: l[2] > 50 || l[3] < 0.5 ? "black" : "white" } }, f ? f(a) : a) : null ) ); }; } }); var Oe = {}; Object.defineProperty(Oe, "__esModule", { value: !0 }); const fe = D, Ye = $; Oe.default = (0, fe.defineComponent)({ name: "ColorPreview", props: { clsPrefix: { type: String, required: !0 }, mode: { type: String, required: !0 }, color: { type: String, default: null, validator: (e) => { const o = (0, Ye.getModeFromValue)(e); return !!(!e || o && o !== "hsv"); } }, onUpdateColor: { type: Function, required: !0 } }, setup(e) { function o(r) { var l; const a = r.target.value; (l = e.onUpdateColor) === null || l === void 0 || l.call(e, (0, Ye.convertColor)(a.toUpperCase(), e.mode, "hex")), r.stopPropagation(); } return { handleChange: o }; }, render() { const { clsPrefix: e } = this; return (0, fe.h)( "div", { class: `${e}-color-picker-preview__preview` }, (0, fe.h)("span", { class: `${e}-color-picker-preview__fill`, style: { background: this.color || "#000000" } }), (0, fe.h)("input", { class: `${e}-color-picker-preview__input`, type: "color", value: this.color, onChange: this.handleChange }) ); } }); var je = {}; Object.defineProperty(je, "__esModule", { value: !0 }); const pe = Ae, L = D, xr = $, Q = "12px", kr = 12, K = "6px", yr = 6, Sr = "linear-gradient(90deg,red,#ff0 16.66%,#0f0 33.33%,#0ff 50%,#00f 66.66%,#f0f 83.33%,red)"; je.default = (0, L.defineComponent)({ name: "HueSlider", props: { clsPrefix: { type: String, required: !0 }, hue: { type: Number, required: !0 }, onUpdateHue: { type: Function, required: !0 }, onComplete: Function }, setup(e) { const o = (0, L.ref)(null); function r(t) { o.value && ((0, pe.on)("mousemove", document, l), (0, pe.on)("mouseup", document, a), l(t)); } function l(t) { const { value: i } = o; if (!i) return; const { width: s, left: f } = i.getBoundingClientRect(), y = (0, xr.normalizeHue)((t.clientX - f - yr) / (s - kr) * 360); e.onUpdateHue(y); } function a() { var t; (0, pe.off)("mousemove", document, l), (0, pe.off)("mouseup", document, a), (t = e.onComplete) === null || t === void 0 || t.call(e); } return { railRef: o, handleMouseDown: r }; }, render() { const { clsPrefix: e } = this; return (0, L.h)( "div", { class: `${e}-color-picker-slider`, style: { height: Q, borderRadius: K } }, (0, L.h)( "div", { ref: "railRef", style: { boxShadow: "inset 0 0 2px 0 rgba(0, 0, 0, .24)", boxSizing: "border-box", backgroundImage: Sr, height: Q, borderRadius: K, position: "relative" }, onMousedown: this.handleMouseDown }, (0, L.h)( "div", { style: { position: "absolute", left: K, right: K, top: 0, bottom: 0 } }, (0, L.h)( "div", { class: `${e}-color-picker-handle`, style: { left: `calc((${this.hue}%) / 359 * 100 - ${K})`, borderRadius: K, width: Q, height: Q } }, (0, L.h)("div", { class: `${e}-color-picker-handle__fill`, style: { backgroundColor: `hsl(${this.hue}, 100%, 50%)`, borderRadius: K, width: Q, height: Q } }) ) ) ) ); } }); var Fe = {}; Object.defineProperty(Fe, "__esModule", { value: !0 }); const ge = Ae, I = D, ve = "12px", be = "6px"; Fe.default = (0, I.defineComponent)({ name: "Pallete", props: { clsPrefix: { type: String, required: !0 }, rgba: { type: Array, default: null }, // 0 - 360 displayedHue: { type: Number, required: !0 }, displayedSv: { type: Array, required: !0 }, onUpdateSV: { type: Function, required: !0 }, onComplete: Function }, setup(e) { const o = (0, I.ref)(null); function r(t) { o.value && ((0, ge.on)("mousemove", document, l), (0, ge.on)("mouseup", document, a), l(t)); } function l(t) { const { value: i } = o; if (!i) return; const { width: s, height: f, left: y, bottom: te } = i.getBoundingClientRect(), O = (te - t.clientY) / f, j = (t.clientX - y) / s, re = 100 * (j > 1 ? 1 : j < 0 ? 0 : j), _e = 100 * (O > 1 ? 1 : O < 0 ? 0 : O); e.onUpdateSV(re, _e); } function a() { var t; (0, ge.off)("mousemove", document, l), (0, ge.off)("mouseup", document, a), (t = e.onComplete) === null || t === void 0 || t.call(e); } return { palleteRef: o, handleColor: (0, I.computed)(() => { const { rgba: t } = e; return t ? `rgb(${t[0]}, ${t[1]}, ${t[2]})` : ""; }), handleMouseDown: r }; }, render() { const { clsPrefix: e } = this; return (0, I.h)( "div", { class: `${e}-color-picker-pallete`, onMousedown: this.handleMouseDown, ref: "palleteRef" }, (0, I.h)("div", { class: `${e}-color-picker-pallete__layer`, style: { backgroundImage: `linear-gradient(90deg, white, hsl(${this.displayedHue}, 100%, 50%))` } }), (0, I.h)("div", { class: `${e}-color-picker-pallete__layer ${e}-color-picker-pallete__layer--shadowed`, style: { backgroundImage: "linear-gradient(180deg, rgba(0, 0, 0, 0%), rgba(0, 0, 0, 100%))" } }), this.rgba && (0, I.h)( "div", { class: `${e}-color-picker-handle`, style: { width: ve, height: ve, borderRadius: be, left: `calc(${this.displayedSv[0]}% - ${be})`, bottom: `calc(${this.displayedSv[1]}% - ${be})` } }, (0, I.h)("div", { class: `${e}-color-picker-handle__fill`, style: { backgroundColor: this.handleColor, borderRadius: be, width: ve, height: ve } }) ) ); } }); var Ee = {}; Object.defineProperty(Ee, "__esModule", { value: !0 }); const wr = It, u = Mt; Ee.default = (0, u.c)([(0, u.cB)("color-picker", ` display: inline-block; box-sizing: border-box; height: var(--n-height); font-size: var(--n-font-size); width: 100%; position: relative; `), (0, u.cB)("color-picker-panel", ` margin: 4px 0; width: 240px; font-size: var(--n-panel-font-size); color: var(--n-text-color); background-color: var(--n-color); transition: box-shadow .3s var(--n-bezier), color .3s var(--n-bezier), background-color .3s var(--n-bezier); border-radius: var(--n-border-radius); box-shadow: var(--n-box-shadow); `, [(0, wr.fadeInScaleUpTransition)(), (0, u.cB)("input", ` text-align: center; `)]), (0, u.cB)("color-picker-checkboard", ` background: white; position: absolute; left: 0; right: 0; top: 0; bottom: 0; `, [(0, u.c)("&::after", ` background-image: linear-gradient(45deg, #DDD 25%, #0000 25%), linear-gradient(-45deg, #DDD 25%, #0000 25%), linear-gradient(45deg, #0000 75%, #DDD 75%), linear-gradient(-45deg, #0000 75%, #DDD 75%); background-size: 12px 12px; background-position: 0 0, 0 6px, 6px -6px, -6px 0px; background-repeat: repeat; content: ""; position: absolute; left: 0; right: 0; top: 0; bottom: 0; `)]), (0, u.cB)("color-picker-slider", ` margin-bottom: 8px; position: relative; box-sizing: border-box; `, [(0, u.cE)("image", ` position: absolute; left: 0; right: 0; top: 0; bottom: 0; `), (0, u.c)("&::after", ` content: ""; position: absolute; border-radius: inherit; left: 0; right: 0; top: 0; bottom: 0; box-shadow: inset 0 0 2px 0 rgba(0, 0, 0, .24); pointer-events: none; `)]), (0, u.cB)("color-picker-handle", ` z-index: 1; box-shadow: 0 0 2px 0 rgba(0, 0, 0, .45); position: absolute; background-color: white; overflow: hidden; `, [(0, u.cE)("fill", ` box-sizing: border-box; border: 2px solid white; `)]), (0, u.cB)("color-picker-pallete", ` height: 180px; position: relative; margin-bottom: 8px; cursor: crosshair; `, [(0, u.cE)("layer", ` position: absolute; left: 0; right: 0; top: 0; bottom: 0; `, [(0, u.cM)("shadowed", ` box-shadow: inset 0 0 2px 0 rgba(0, 0, 0, .24); `)])]), (0, u.cB)("color-picker-preview", ` display: flex; `, [(0, u.cE)("sliders", ` flex: 1 0 auto; `), (0, u.cE)("preview", ` position: relative; height: 30px; width: 30px; margin: 0 0 8px 6px; border-radius: 50%; box-shadow: rgba(0, 0, 0, .15) 0px 0px 0px 1px inset; overflow: hidden; `), (0, u.cE)("fill", ` display: block; width: 30px; height: 30px; `), (0, u.cE)("input", ` position: absolute; top: 0; left: 0; width: 30px; height: 30px; opacity: 0; z-index: 1; `)]), (0, u.cB)("color-picker-input", ` display: flex; align-items: center; `, [(0, u.cB)("input", ` flex-grow: 1; flex-basis: 0; `), (0, u.cE)("mode", ` width: 72px; text-align: center; `)]), (0, u.cB)("color-picker-control", ` padding: 12px; `), (0, u.cB)("color-picker-action", ` display: flex; margin-top: -4px; border-top: 1px solid var(--n-divider-color); padding: 8px 12px; justify-content: flex-end; `, [(0, u.cB)("button", "margin-left: 8px;")]), (0, u.cB)("color-picker-trigger", ` border: var(--n-border); height: 100%; box-sizing: border-box; border-radius: var(--n-border-radius); transition: border-color .3s var(--n-bezier); cursor: pointer; `, [(0, u.cE)("value", ` white-space: nowrap; position: relative; `), (0, u.cE)("fill", ` border-radius: var(--n-border-radius); position: absolute; display: flex; align-items: center; justify-content: center; left: 4px; right: 4px; top: 4px; bottom: 4px; `), (0, u.cM)("disabled", "cursor: not-allowed"), (0, u.cB)("color-picker-checkboard", ` border-radius: var(--n-border-radius); `, [(0, u.c)("&::after", ` --n-block-size: calc((var(--n-height) - 8px) / 3); background-size: calc(var(--n-block-size) * 2) calc(var(--n-block-size) * 2); background-position: 0 0, 0 var(--n-block-size), var(--n-block-size) calc(-1 * var(--n-block-size)), calc(-1 * var(--n-block-size)) 0px; `)])]), (0, u.cB)("color-picker-swatches", ` display: grid; grid-gap: 8px; flex-wrap: wrap; position: relative; grid-template-columns: repeat(auto-fill, 18px); margin-top: 10px; `, [(0, u.cB)("color-picker-swatch", ` width: 18px; height: 18px; background-image: linear-gradient(45deg, #DDD 25%, #0000 25%), linear-gradient(-45deg, #DDD 25%, #0000 25%), linear-gradient(45deg, #0000 75%, #DDD 75%), linear-gradient(-45deg, #0000 75%, #DDD 75%); background-size: 8px 8px; background-position: 0px 0, 0px 4px, 4px -4px, -4px 0px; background-repeat: repeat; `, [(0, u.cE)("fill", ` position: relative; width: 100%; height: 100%; border-radius: 3px; box-shadow: rgba(0, 0, 0, .15) 0px 0px 0px 1px inset; cursor: pointer; `), (0, u.c)("&:focus", ` outline: none; `, [(0, u.cE)("fill", [(0, u.c)("&::after", ` position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: inherit; filter: blur(2px); content: ""; `)])])])])]); (function(e) { var o = B && B.__importDefault || function(c) { return c && c.__esModule ? c : { default: c }; }; Object.defineProperty(e, "__esModule", { value: !0 }), e.colorPickerProps = void 0; const r = W, l = Ht, a = Vt, t = D, i = Dt, s = At, f = me, y = zt, te = ot, O = o(Ve), j = o(He), re = o(Ie), _e = o(Be), at = o(Oe), it = ee, st = o(je), ut = o(Fe), ct = o(Ee), xe = $; e.colorPickerProps = Object.assign(Object.assign({}, s.useTheme.props), { value: String, show: { type: Boolean, default: void 0 }, defaultShow: Boolean, defaultValue: String, modes: { type: Array, // no hsva by default since browser doesn't support it default: () => ["rgb", "hex", "hsl"] }, placement: { type: String, default: "bottom-start" }, to: f.useAdjustedTo.propTo, showAlpha: { type: Boolean, default: !0 }, showPreview: Boolean, swatches: Array, disabled: { type: Boolean, default: void 0 }, actions: { type: Array, default: null }, internalActions: Array, size: String, renderLabel: Function, onComplete: Function, onConfirm: Function, onClear: Function, "onUpdate:show": [Function, Array], onUpdateShow: [Function, Array], "onUpdate:value": [Function, Array], onUpdateValue: [Function, Array] }), e.default = (0, t.defineComponent)({ name: "ColorPicker", props: e.colorPickerProps, slots: Object, setup(c, { slots: F }) { const Te = (0, t.ref)(null); let oe = null; const ke = (0, s.useFormItem)(c), { mergedSizeRef: qe, mergedDisabledRef: dt } = ke, { localeRef: ue } = (0, s.useLocale)("global"), { mergedClsPrefixRef: ye, namespaceRef: ht, inlineThemeDisabled: Se } = (0, s.useConfig)(c), we = (0, s.useTheme)("ColorPicker", "-color-picker", ct.default, te.colorPickerLight, c, ye); (0, t.provide)(it.colorPickerInjectionKey, { themeRef: we, renderLabelRef: (0, t.toRef)(c, "renderLabel"), colorPickerSlots: F }); const Ne = (0, t.ref)(c.defaultShow), Le = (0, a.useMergedState)((0, t.toRef)(c, "show"), Ne); function ce(n) { const { onUpdateShow: h, "onUpdate:show": g } = c; h && (0, f.call)(h, n), g && (0, f.call)(g, n), Ne.value = n; } const { defaultValue: Ke } = c, Xe = (0, t.ref)(Ke === void 0 ? (0, xe.deriveDefaultValue)(c.modes, c.showAlpha) : Ke), x = (0, a.useMergedState)((0, t.toRef)(c, "value"), Xe), X = (0, t.ref)([x.value]), M = (0, t.ref)(0), Ce = (0, t.computed)(() => (0, xe.getModeFromValue)(x.value)), { modes: ft } = c, P = (0, t.ref)((0, xe.getModeFromValue)(x.value) || ft[0] || "rgb"); function pt() { const { modes: n } = c, { value: h } = P, g = n.findIndex((v) => v === h); ~g ? P.value = n[(g + 1) % n.length] : P.value = "rgb"; } let S, w, Z, G, V, H, z, C; const ne = (0, t.computed)(() => { const { value: n } = x; if (!n) return null; switch (Ce.value) { case "hsv": return (0, r.hsva)(n); case "hsl": return [S, w, Z, C] = (0, r.hsla)(n), [...(0, r.hsl2hsv)(S, w, Z), C]; case "rgb": case "hex": return [V, H, z, C] = (0, r.rgba)(n), [...(0, r.rgb2hsv)(V, H, z), C]; } }), E = (0, t.computed)(() => { const { value: n } = x; if (!n) return null; switch (Ce.value) { case "rgb": case "hex": return (0, r.rgba)(n); case "hsv": return [S, w, G, C] = (0, r.hsva)(n), [...(0, r.hsv2rgb)(S, w, G), C]; case "hsl": return [S, w, Z, C] = (0, r.hsla)(n), [...(0, r.hsl2rgb)(S, w, Z), C]; } }), $e = (0, t.computed)(() => { const { value: n } = x; if (!n) return null; switch (Ce.value) { case "hsl": return (0, r.hsla)(n); case "hsv": return [S, w, G, C] = (0, r.hsva)(n), [...(0, r.hsv2hsl)(S, w, G), C]; case "rgb": case "hex": return [V, H, z, C] = (0, r.rgba)(n), [...(0, r.rgb2hsl)(V, H, z), C]; } }), gt = (0, t.computed)(() => { switch (P.value) { case "rgb": case "hex": return E.value; case "hsv": return ne.value; case "hsl": return $e.value; } }), de = (0, t.ref)(0), Pe = (0, t.ref)(1), Ue = (0, t.ref)([0, 0]); function vt(n, h) { const { value: g } = ne, v = de.value, b = g ? g[3] : 1; Ue.value = [n, h]; const { showAlpha: p } = c; switch (P.value) { case "hsv": m((p ? r.toHsvaString : r.toHsvString)([v, n, h, b]), "cursor"); break; case "hsl": m((p ? r.toHslaString : r.toHslString)([ ...(0, r.hsv2hsl)(v, n, h), b ]), "cursor"); break; case "rgb": m((p ? r.toRgbaString : r.toRgbString)([ ...(0, r.hsv2rgb)(v, n, h), b ]), "cursor"); break; case "hex": m((p ? r.toHexaString : r.toHexString)([ ...(0, r.hsv2rgb)(v, n, h), b ]), "cursor"); break; } } function bt(n) { de.value = n; const { value: h } = ne; if (!h) return; const [, g, v, b] = h, { showAlpha: p } = c; switch (P.value) { case "hsv": m((p ? r.toHsvaString : r.toHsvString)([n, g, v, b]), "cursor"); break; case "rgb": m((p ? r.toRgbaString : r.toRgbString)([ ...(0, r.hsv2rgb)(n, g, v), b ]), "cursor"); break; case "hex": m((p ? r.toHexaString : r.toHexString)([ ...(0, r.hsv2rgb)(n, g, v), b ]), "cursor"); break; case "hsl": m((p ? r.toHslaString : r.toHslString)([ ...(0, r.hsv2hsl)(n, g, v), b ]), "cursor"); break; } } function mt(n) { switch (P.value) { case "hsv": [S, w, G] = ne.value, m((0, r.toHsvaString)([S, w, G, n]), "cursor"); break; case "rgb": [V, H, z] = E.value, m((0, r.toRgbaString)([V, H, z, n]), "cursor"); break; case "hex": [V, H, z] = E.value, m((0, r.toHexaString)([V, H, z, n]), "cursor"); break; case "hsl": [S, w, Z] = $e.value, m((0, r.toHslaString)([S, w, Z, n]), "cursor"); break; } Pe.value = n; } function m(n, h) { h === "cursor" ? oe = n : oe = null; const { nTriggerFormChange: g, nTriggerFormInput: v } = ke, { onUpdateValue: b, "onUpdate:value": p } = c; b && (0, f.call)(b, n), p && (0, f.call)(p, n), g(), v(), Xe.value = n; } function _t(n) { m(n, "input"), (0, t.nextTick)(Y); } function Y(n = !0) { const { value: h } = x; if (h) { const { nTriggerFormChange: g, nTriggerFormInput: v } = ke, { onComplete: b } = c; b && b(h); const { value: p } = X, { value: k } = M; n && (p.splice(k + 1, p.length, h), M.value = k + 1), g(), v(); } } function xt() { const { value: n } = M; n - 1 < 0 || (m(X.value[n - 1], "input"), Y(!1), M.value = n - 1); } function kt() { const { value: n } = M; n < 0 || n + 1 >= X.value.length || (m(X.value[n + 1], "input"), Y(!1), M.value = n + 1); } function yt() { m(null, "input"); const { onClear: n } = c; n && n(), ce(!1); } function St() { const { value: n } = x, { onConfirm: h } = c; h && h(n), ce(!1); } const wt = (0, t.computed)(() => M.value >= 1), Ct = (0, t.computed)(() => { const { value: n } = X; return n.length > 1 && M.value < n.length - 1; }); (0, t.watch)(Le, (n) => { n || (X.value = [x.value], M.value = 0); }), (0, t.watchEffect)(() => { if (!(oe && oe === x.value)) { const { value: n } = ne; n && (de.value = n[0], Pe.value = n[3], Ue.value = [n[1], n[2]]); } oe = null; }); const Re = (0, t.computed)(() => { const { value: n } = qe, { common: { cubicBezierEaseInOut: h }, self: { textColor: g, color: v, panelFontSize: b, boxShadow: p, border: k, borderRadius: _, dividerColor: T, [(0, f.createKey)("height", n)]: Pt, [(0, f.createKey)("fontSize", n)]: Ut } } = we.value; return { "--n-bezier": h, "--n-text-color": g, "--n-color": v, "--n-panel-font-size": b, "--n-font-size": Ut, "--n-box-shadow": p, "--n-border": k, "--n-border-radius": _, "--n-height": Pt, "--n-divider-color": T }; }), A = Se ? (0, s.useThemeClass)("color-picker", (0, t.computed)(() => qe.value[0]), Re, c) : void 0; function $t() { var n; const { value: h } = E, { value: g } = de, { internalActions: v, modes: b, actions: p } = c, { value: k } = we, { value: _ } = ye; return (0, t.h)( "div", { class: [ `${_}-color-picker-panel`, A == null ? void 0 : A.themeClass.value ], onDragstart: (T) => { T.preventDefault(); }, style: Se ? void 0 : Re.value }, (0, t.h)( "div", { class: `${_}-color-picker-control` }, (0, t.h)(ut.default, { clsPrefix: _, rgba: h, displayedHue: g, displayedSv: Ue.value, onUpdateSV: vt, onComplete: Y }), (0, t.h)( "div", { class: `${_}-color-picker-preview` }, (0, t.h)( "div", { class: `${_}-color-picker-preview__sliders` }, (0, t.h)(st.default, { clsPrefix: _, hue: g, onUpdateHue: bt, onComplete: Y }), c.showAlpha ? (0, t.h)(O.default, { clsPrefix: _, rgba: h, alpha: Pe.value, onUpdateAlpha: mt, onComplete: Y }) : null ), c.showPreview ? (0, t.h)(at.default, { clsPrefix: _, mode: P.value, color: E.value && (0, r.toHexString)(E.value), onUpdateColor: (T) => { m(T, "input"); } }) : null ), (0, t.h)(j.default, { clsPrefix: _, showAlpha: c.showAlpha, mode: P.value, modes: b, onUpdateMode: pt, value: x.value, valueArr: gt.value, onUpdateValue: _t }), ((n = c.swatches) === null || n === void 0 ? void 0 : n.length) && (0, t.h)(re.default, { clsPrefix: _, mode: P.value, swatches: c.swatches, onUpdateColor: (T) => { m(T, "input"); } }) ), p != null && p.length ? (0, t.h)( "div", { class: `${_}-color-picker-action` }, p.includes("confirm") && (0, t.h)(y.NButton, { size: "small", onClick: St, theme: k.peers.Button, themeOverrides: k.peerOverrides.Button }, { default: () => ue.value.confirm }), p.includes("clear") && (0, t.h)(y.NButton, { size: "small", onClick: yt, disabled: !x.value, theme: k.peers.Button, themeOverrides: k.peerOverrides.Button }, { default: () => ue.value.clear }) ) : null, F.action ? (0, t.h)("div", { class: `${_}-color-picker-action` }, { default: F.action }) : v ? (0, t.h)( "div", { class: `${_}-color-picker-action` }, v.includes("undo") && (0, t.h)(y.NButton, { size: "small", onClick: xt, disabled: !wt.value, theme: k.peers.Button, themeOverrides: k.peerOverrides.Button }, { default: () => ue.value.undo }), v.includes("redo") && (0, t.h)(y.NButton, { size: "small", onClick: kt, disabled: !Ct.value, theme: k.peers.Button, themeOverrides: k.peerOverrides.Button }, { default: () => ue.value.redo }) ) : null ); } return { mergedClsPrefix: ye, namespace: ht, selfRef: Te, hsla: $e, rgba: E, mergedShow: Le, mergedDisabled: dt, isMounted: (0, a.useIsMounted)(), adjustedTo: (0, f.useAdjustedTo)(c), mergedValue: x, handleTriggerClick() { ce(!0); }, handleClickOutside(n) { var h; !((h = Te.value) === null || h === void 0) && h.contains((0, r.getPreciseEventTarget)(n)) || ce(!1); }, renderPanel: $t, cssVars: Se ? void 0 : Re, themeClass: A == null ? void 0 : A.themeClass, onRender: A == null ? void 0 : A.onRender }; }, render() { const { mergedClsPrefix: c, onRender: F } = this; return F == null || F(), (0, t.h)( "div", { class: [this.themeClass, `${c}-color-picker`], ref: "selfRef", style: this.cssVars }, (0, t.h)(i.VBinder, null, { default: () => [ (0, t.h)(i.VTarget, null, { default: () => (0, t.h)(_e.default, { clsPrefix: c, value: this.mergedValue, hsla: this.hsla, disabled: this.mergedDisabled, onClick: this.handleTriggerClick }) }), (0, t.h)(i.VFollower, { placement: this.placement, show: this.mergedShow, containerClass: this.namespace, teleportDisabled: this.adjustedTo === f.useAdjustedTo.tdkey, to: this.adjustedTo }, { default: () => (0, t.h)(t.Transition, { name: "fade-in-scale-up-transition", appear: this.isMounted }, { default: () => this.mergedShow ? (0, t.withDirectives)(this.renderPanel(), [ [ l.clickoutside, this.handleClickOutside, void 0, { capture: !0 } ] ]) : null }) }) ] }) ); } }); })(rt); (function(e) { var o = B && B.__importDefault || function(l) { return l && l.__esModule ? l : { default: l }; }; Object.defineProperty(e, "__esModule", { value: !0 }), e.NColorPicker = e.colorPickerProps = void 0; var r = rt; Object.defineProperty(e, "colorPickerProps", { enumerable: !0, get: function() { return r.colorPickerProps; } }), Object.defineProperty(e, "NColorPicker", { enumerable: !0, get: function() { return o(r).default; } }); })(tt); const Dr = /* @__PURE__ */ Bt({ __proto__: null }, [tt]); export { Dr as i };