UNPKG

ai-form-designer

Version:

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

391 lines (390 loc) 16.2 kB
import { c as d } from "./_commonjsHelpers-BVfed4GL.js"; import { c as I, r as K, a as be, b as ve, _ as pe, e as ge } from "./index-CFbzusj4.js"; import { r as me } from "./_vue_commonjs-external-NwvjgbHK.js"; import { a as _e, _ as we } from "./index-B5s4z2wp.js"; function ye(o, s) { for (var a = 0; a < s.length; a++) { const i = s[a]; if (typeof i != "string" && !Array.isArray(i)) { for (const r in i) if (r !== "default" && !(r in o)) { const u = Object.getOwnPropertyDescriptor(i, r); u && Object.defineProperty(o, r, u.get ? u : { enumerable: !0, get: () => i[r] }); } } } return Object.freeze(Object.defineProperty(o, Symbol.toStringTag, { value: "Module" })); } var q = {}, X = {}, Y = {}, N = {}, j = {}; Object.defineProperty(j, "__esModule", { value: !0 }); j.default = { buttonHeightSmall: "14px", buttonHeightMedium: "18px", buttonHeightLarge: "22px", buttonWidthSmall: "14px", buttonWidthMedium: "18px", buttonWidthLarge: "22px", buttonWidthPressedSmall: "20px", buttonWidthPressedMedium: "24px", buttonWidthPressedLarge: "28px", railHeightSmall: "18px", railHeightMedium: "22px", railHeightLarge: "26px", railWidthSmall: "32px", railWidthMedium: "40px", railWidthLarge: "48px" }; var xe = d && d.__importDefault || function(o) { return o && o.__esModule ? o : { default: o }; }; Object.defineProperty(N, "__esModule", { value: !0 }); const Se = K, ke = I, Ce = xe(j), $e = { name: "Switch", common: ke.commonDark, self(o) { const { primaryColorSuppl: s, opacityDisabled: a, borderRadius: i, primaryColor: r, textColor2: u, baseColor: g } = o; return Object.assign(Object.assign({}, Ce.default), { iconColor: g, textColor: u, loadingColor: s, opacityDisabled: a, railColor: "rgba(255, 255, 255, .20)", railColorActive: s, buttonBoxShadow: "0px 2px 4px 0 rgba(0, 0, 0, 0.4)", buttonColor: "#FFF", railBorderRadiusSmall: i, railBorderRadiusMedium: i, railBorderRadiusLarge: i, buttonBorderRadiusSmall: i, buttonBorderRadiusMedium: i, buttonBorderRadiusLarge: i, boxShadowFocus: `0 0 8px 0 ${(0, Se.changeColor)(r, { alpha: 0.3 })}` }); } }; N.default = $e; var T = {}, Be = d && d.__importDefault || function(o) { return o && o.__esModule ? o : { default: o }; }; Object.defineProperty(T, "__esModule", { value: !0 }); const Re = K, Me = I, Ee = Be(j); function Oe(o) { const { primaryColor: s, opacityDisabled: a, borderRadius: i, textColor3: r } = o; return Object.assign(Object.assign({}, Ee.default), { iconColor: r, textColor: "white", loadingColor: s, opacityDisabled: a, railColor: "rgba(0, 0, 0, .14)", railColorActive: s, buttonBoxShadow: "0 1px 4px 0 rgba(0, 0, 0, 0.3), inset 0 0 1px 0 rgba(0, 0, 0, 0.05)", buttonColor: "#FFF", railBorderRadiusSmall: i, railBorderRadiusMedium: i, railBorderRadiusLarge: i, buttonBorderRadiusSmall: i, buttonBorderRadiusMedium: i, buttonBorderRadiusLarge: i, boxShadowFocus: `0 0 0 2px ${(0, Re.changeColor)(s, { alpha: 0.2 })}` }); } const Pe = { name: "Switch", common: Me.commonLight, self: Oe }; T.default = Pe; (function(o) { var s = d && d.__importDefault || function(r) { return r && r.__esModule ? r : { default: r }; }; Object.defineProperty(o, "__esModule", { value: !0 }), o.switchLight = o.switchDark = void 0; var a = N; Object.defineProperty(o, "switchDark", { enumerable: !0, get: function() { return s(a).default; } }); var i = T; Object.defineProperty(o, "switchLight", { enumerable: !0, get: function() { return s(i).default; } }); })(Y); var H = {}; Object.defineProperty(H, "__esModule", { value: !0 }); const U = _e, t = be; H.default = (0, t.cB)("switch", ` height: var(--n-height); min-width: var(--n-width); vertical-align: middle; user-select: none; -webkit-user-select: none; display: inline-flex; outline: none; justify-content: center; align-items: center; `, [(0, t.cE)("children-placeholder", ` height: var(--n-rail-height); display: flex; flex-direction: column; overflow: hidden; pointer-events: none; visibility: hidden; `), (0, t.cE)("rail-placeholder", ` display: flex; flex-wrap: none; `), (0, t.cE)("button-placeholder", ` width: calc(1.75 * var(--n-rail-height)); height: var(--n-rail-height); `), (0, t.cB)("base-loading", ` position: absolute; top: 50%; left: 50%; transform: translateX(-50%) translateY(-50%); font-size: calc(var(--n-button-width) - 4px); color: var(--n-loading-color); transition: color .3s var(--n-bezier); `, [(0, U.iconSwitchTransition)({ left: "50%", top: "50%", originalTransform: "translateX(-50%) translateY(-50%)" })]), (0, t.cE)("checked, unchecked", ` transition: color .3s var(--n-bezier); color: var(--n-text-color); box-sizing: border-box; position: absolute; white-space: nowrap; top: 0; bottom: 0; display: flex; align-items: center; line-height: 1; `), (0, t.cE)("checked", ` right: 0; padding-right: calc(1.25 * var(--n-rail-height) - var(--n-offset)); `), (0, t.cE)("unchecked", ` left: 0; justify-content: flex-end; padding-left: calc(1.25 * var(--n-rail-height) - var(--n-offset)); `), (0, t.c)("&:focus", [(0, t.cE)("rail", ` box-shadow: var(--n-box-shadow-focus); `)]), (0, t.cM)("round", [(0, t.cE)("rail", "border-radius: calc(var(--n-rail-height) / 2);", [(0, t.cE)("button", "border-radius: calc(var(--n-button-height) / 2);")])]), (0, t.cNotM)("disabled", [(0, t.cNotM)("icon", [(0, t.cM)("rubber-band", [(0, t.cM)("pressed", [(0, t.cE)("rail", [(0, t.cE)("button", "max-width: var(--n-button-width-pressed);")])]), (0, t.cE)("rail", [(0, t.c)("&:active", [(0, t.cE)("button", "max-width: var(--n-button-width-pressed);")])]), (0, t.cM)("active", [(0, t.cM)("pressed", [(0, t.cE)("rail", [(0, t.cE)("button", "left: calc(100% - var(--n-offset) - var(--n-button-width-pressed));")])]), (0, t.cE)("rail", [(0, t.c)("&:active", [(0, t.cE)("button", "left: calc(100% - var(--n-offset) - var(--n-button-width-pressed));")])])])])])]), (0, t.cM)("active", [(0, t.cE)("rail", [(0, t.cE)("button", "left: calc(100% - var(--n-button-width) - var(--n-offset))")])]), (0, t.cE)("rail", ` overflow: hidden; height: var(--n-rail-height); min-width: var(--n-rail-width); border-radius: var(--n-rail-border-radius); cursor: pointer; position: relative; transition: opacity .3s var(--n-bezier), background .3s var(--n-bezier), box-shadow .3s var(--n-bezier); background-color: var(--n-rail-color); `, [(0, t.cE)("button-icon", ` color: var(--n-icon-color); transition: color .3s var(--n-bezier); font-size: calc(var(--n-button-height) - 4px); position: absolute; left: 0; right: 0; top: 0; bottom: 0; display: flex; justify-content: center; align-items: center; line-height: 1; `, [(0, U.iconSwitchTransition)()]), (0, t.cE)("button", ` align-items: center; top: var(--n-offset); left: var(--n-offset); height: var(--n-button-height); width: var(--n-button-width-pressed); max-width: var(--n-button-width); border-radius: var(--n-button-border-radius); background-color: var(--n-button-color); box-shadow: var(--n-button-box-shadow); box-sizing: border-box; cursor: inherit; content: ""; position: absolute; transition: background-color .3s var(--n-bezier), left .3s var(--n-bezier), opacity .3s var(--n-bezier), max-width .3s var(--n-bezier), box-shadow .3s var(--n-bezier); `)]), (0, t.cM)("active", [(0, t.cE)("rail", "background-color: var(--n-rail-color-active);")]), (0, t.cM)("loading", [(0, t.cE)("rail", ` cursor: wait; `)]), (0, t.cM)("disabled", [(0, t.cE)("rail", ` cursor: not-allowed; opacity: .5; `)])]); (function(o) { var s = d && d.__importDefault || function(e) { return e && e.__esModule ? e : { default: e }; }; Object.defineProperty(o, "__esModule", { value: !0 }), o.switchProps = void 0; const a = K, i = ge, r = me, u = we, g = ve, l = pe, G = Y, J = s(H); o.switchProps = Object.assign(Object.assign({}, g.useTheme.props), { size: { type: String, default: "medium" }, value: { type: [String, Number, Boolean], default: void 0 }, loading: Boolean, defaultValue: { type: [String, Number, Boolean], default: !1 }, disabled: { type: Boolean, default: void 0 }, round: { type: Boolean, default: !0 }, "onUpdate:value": [Function, Array], onUpdateValue: [Function, Array], checkedValue: { type: [String, Number, Boolean], default: !0 }, uncheckedValue: { type: [String, Number, Boolean], default: !1 }, railStyle: Function, rubberBand: { type: Boolean, default: !0 }, /** @deprecated */ onChange: [Function, Array] }); let x; o.default = (0, r.defineComponent)({ name: "Switch", props: o.switchProps, slots: Object, setup(e) { process.env.NODE_ENV !== "production" && (0, r.watchEffect)(() => { e.onChange && (0, l.warnOnce)("switch", "`on-change` is deprecated, please use `on-update:value` instead."); }), x === void 0 && (typeof CSS < "u" ? typeof CSS.supports < "u" ? x = CSS.supports("width", "max(1px)") : x = !1 : x = !0); const { mergedClsPrefixRef: B, inlineThemeDisabled: S } = (0, g.useConfig)(e), D = (0, g.useTheme)("Switch", "-switch", J.default, G.switchLight, e, B), h = (0, g.useFormItem)(e), { mergedSizeRef: R, mergedDisabledRef: m } = h, k = (0, r.ref)(e.defaultValue), M = (0, r.toRef)(e, "value"), _ = (0, i.useMergedState)(M, k), C = (0, r.computed)(() => _.value === e.checkedValue), w = (0, r.ref)(!1), c = (0, r.ref)(!1), f = (0, r.computed)(() => { const { railStyle: n } = e; if (n) return n({ focused: c.value, checked: C.value }); }); function b(n) { const { "onUpdate:value": E, onChange: O, onUpdateValue: P } = e, { nTriggerFormInput: F, nTriggerFormChange: V } = h; E && (0, l.call)(E, n), P && (0, l.call)(P, n), O && (0, l.call)(O, n), k.value = n, F(), V(); } function Q() { const { nTriggerFormFocus: n } = h; n(); } function Z() { const { nTriggerFormBlur: n } = h; n(); } function ee() { e.loading || m.value || (_.value !== e.checkedValue ? b(e.checkedValue) : b(e.uncheckedValue)); } function te() { c.value = !0, Q(); } function re() { c.value = !1, Z(), w.value = !1; } function oe(n) { e.loading || m.value || n.key === " " && (_.value !== e.checkedValue ? b(e.checkedValue) : b(e.uncheckedValue), w.value = !1); } function ie(n) { e.loading || m.value || n.key === " " && (n.preventDefault(), w.value = !0); } const A = (0, r.computed)(() => { const { value: n } = R, { self: { opacityDisabled: E, railColor: O, railColorActive: P, buttonBoxShadow: F, buttonColor: V, boxShadowFocus: ae, loadingColor: ne, textColor: le, iconColor: ce, [(0, l.createKey)("buttonHeight", n)]: v, [(0, l.createKey)("buttonWidth", n)]: se, [(0, l.createKey)("buttonWidthPressed", n)]: de, [(0, l.createKey)("railHeight", n)]: p, [(0, l.createKey)("railWidth", n)]: $, [(0, l.createKey)("railBorderRadius", n)]: ue, [(0, l.createKey)("buttonBorderRadius", n)]: he }, common: { cubicBezierEaseInOut: fe } } = D.value; let W, z, L; return x ? (W = `calc((${p} - ${v}) / 2)`, z = `max(${p}, ${v})`, L = `max(${$}, calc(${$} + ${v} - ${p}))`) : (W = (0, a.pxfy)(((0, a.depx)(p) - (0, a.depx)(v)) / 2), z = (0, a.pxfy)(Math.max((0, a.depx)(p), (0, a.depx)(v))), L = (0, a.depx)(p) > (0, a.depx)(v) ? $ : (0, a.pxfy)((0, a.depx)($) + (0, a.depx)(v) - (0, a.depx)(p))), { "--n-bezier": fe, "--n-button-border-radius": he, "--n-button-box-shadow": F, "--n-button-color": V, "--n-button-width": se, "--n-button-width-pressed": de, "--n-button-height": v, "--n-height": z, "--n-offset": W, "--n-opacity-disabled": E, "--n-rail-border-radius": ue, "--n-rail-color": O, "--n-rail-color-active": P, "--n-rail-height": p, "--n-rail-width": $, "--n-width": L, "--n-box-shadow-focus": ae, "--n-loading-color": ne, "--n-text-color": le, "--n-icon-color": ce }; }), y = S ? (0, g.useThemeClass)("switch", (0, r.computed)(() => R.value[0]), A, e) : void 0; return { handleClick: ee, handleBlur: re, handleFocus: te, handleKeyup: oe, handleKeydown: ie, mergedRailStyle: f, pressed: w, mergedClsPrefix: B, mergedValue: _, checked: C, mergedDisabled: m, cssVars: S ? void 0 : A, themeClass: y == null ? void 0 : y.themeClass, onRender: y == null ? void 0 : y.onRender }; }, render() { const { mergedClsPrefix: e, mergedDisabled: B, checked: S, mergedRailStyle: D, onRender: h, $slots: R } = this; h == null || h(); const { checked: m, unchecked: k, icon: M, "checked-icon": _, "unchecked-icon": C } = R, w = !((0, l.isSlotEmpty)(M) && (0, l.isSlotEmpty)(_) && (0, l.isSlotEmpty)(C)); return (0, r.h)( "div", { role: "switch", "aria-checked": S, class: [ `${e}-switch`, this.themeClass, w && `${e}-switch--icon`, S && `${e}-switch--active`, B && `${e}-switch--disabled`, this.round && `${e}-switch--round`, this.loading && `${e}-switch--loading`, this.pressed && `${e}-switch--pressed`, this.rubberBand && `${e}-switch--rubber-band` ], tabindex: this.mergedDisabled ? void 0 : 0, style: this.cssVars, onClick: this.handleClick, onFocus: this.handleFocus, onBlur: this.handleBlur, onKeyup: this.handleKeyup, onKeydown: this.handleKeydown }, (0, r.h)( "div", { class: `${e}-switch__rail`, "aria-hidden": "true", style: D }, (0, l.resolveWrappedSlot)(m, (c) => (0, l.resolveWrappedSlot)(k, (f) => c || f ? (0, r.h)( "div", { "aria-hidden": !0, class: `${e}-switch__children-placeholder` }, (0, r.h)( "div", { class: `${e}-switch__rail-placeholder` }, (0, r.h)("div", { class: `${e}-switch__button-placeholder` }), c ), (0, r.h)( "div", { class: `${e}-switch__rail-placeholder` }, (0, r.h)("div", { class: `${e}-switch__button-placeholder` }), f ) ) : null)), (0, r.h)( "div", { class: `${e}-switch__button` }, (0, l.resolveWrappedSlot)(M, (c) => (0, l.resolveWrappedSlot)(_, (f) => (0, l.resolveWrappedSlot)(C, (b) => (0, r.h)(u.NIconSwitchTransition, null, { default: () => this.loading ? (0, r.h)(u.NBaseLoading, { key: "loading", clsPrefix: e, strokeWidth: 20 }) : this.checked && (f || c) ? (0, r.h)("div", { class: `${e}-switch__button-icon`, key: f ? "checked-icon" : "icon" }, f || c) : !this.checked && (b || c) ? (0, r.h)("div", { class: `${e}-switch__button-icon`, key: b ? "unchecked-icon" : "icon" }, b || c) : null })))), (0, l.resolveWrappedSlot)(m, (c) => c && (0, r.h)("div", { key: "checked", class: `${e}-switch__checked` }, c)), (0, l.resolveWrappedSlot)(k, (c) => c && (0, r.h)("div", { key: "unchecked", class: `${e}-switch__unchecked` }, c)) ) ) ); } }); })(X); (function(o) { var s = d && d.__importDefault || function(i) { return i && i.__esModule ? i : { default: i }; }; Object.defineProperty(o, "__esModule", { value: !0 }), o.switchProps = o.NSwitch = void 0; var a = X; Object.defineProperty(o, "NSwitch", { enumerable: !0, get: function() { return s(a).default; } }), Object.defineProperty(o, "switchProps", { enumerable: !0, get: function() { return a.switchProps; } }); })(q); const We = /* @__PURE__ */ ye({ __proto__: null }, [q]); export { We as i };