mldong-flow-designer-plus
Version:
本项目包含了作者为B站课堂视频[《工作流设计器开发最佳实践》](https://www.bilibili.com/cheese/play/ss24484)的过程源码。教程中开发的组件也可用于实际生产环境中。以下是和使用文档和课程章节说明。 ## 实战项目 [演示地址](https://flow-pro.mldong.com/)
429 lines (428 loc) • 14.4 kB
JavaScript
import { i as fromPairs, o as isPlainObject$1 } from "./index-C41_Bymr.js";
import { warn, getCurrentInstance, inject, ref, computed, unref, shallowRef, watchEffect, readonly, shallowReadonly, watch, toValue, getCurrentScope, onScopeDispose, onMounted, nextTick, hasInjectionContext } from "vue";
/**
* @vue/shared v3.5.35
* (c) 2018-present Yuxi (Evan) You and Vue contributors
* @license MIT
**/
!!(process.env.NODE_ENV !== "production") ? Object.freeze({}) : {};
!!(process.env.NODE_ENV !== "production") ? Object.freeze([]) : [];
const NOOP = () => {
};
const hasOwnProperty = Object.prototype.hasOwnProperty;
const hasOwn = (val, key) => hasOwnProperty.call(val, key);
const isArray = Array.isArray;
const isFunction = (val) => typeof val === "function";
const isString = (val) => typeof val === "string";
const isObject$1 = (val) => val !== null && typeof val === "object";
const objectToString = Object.prototype.toString;
const toTypeString = (value) => objectToString.call(value);
const isPlainObject = (val) => toTypeString(val) === "[object Object]";
const cacheStringFunction = (fn) => {
const cache = /* @__PURE__ */ Object.create(null);
return (str) => {
const hit = cache[str];
return hit || (cache[str] = fn(str));
};
};
const camelizeRE = /-\w/g;
const camelize = cacheStringFunction(
(str) => {
return str.replace(camelizeRE, (c) => c.slice(1).toUpperCase());
}
);
const withPropsDefaultsSetter = (target) => {
const _p = target.props;
const props = isArray(_p) ? fromPairs(_p.map((key) => [key, {}])) : _p;
target.setPropsDefaults = (defaults) => {
if (!props) return;
for (const [key, value] of Object.entries(defaults)) {
const prop = props[key];
if (!hasOwn(props, key)) continue;
if (isPlainObject$1(prop)) {
props[key] = {
...prop,
default: value
};
continue;
}
props[key] = {
type: prop,
default: value
};
}
target.props = props;
};
};
const withInstall = (main, extra) => {
main.install = (app) => {
for (const comp of [main, ...Object.values(extra ?? {})]) app.component(comp.name, comp);
};
if (extra) for (const [key, comp] of Object.entries(extra)) main[key] = comp;
withPropsDefaultsSetter(main);
return main;
};
const withInstallFunction = (fn, name) => {
fn.install = (app) => {
fn._context = app._context;
app.config.globalProperties[name] = fn;
};
return fn;
};
const withNoopInstall = (component) => {
component.install = NOOP;
withPropsDefaultsSetter(component);
return component;
};
const isUndefined = (val) => val === void 0;
const isBoolean = (val) => typeof val === "boolean";
const isNumber = (val) => typeof val === "number";
const isEmpty = (val) => !val && val !== 0 || isArray(val) && val.length === 0 || isObject$1(val) && !Object.keys(val).length;
const isElement = (e) => {
if (typeof Element === "undefined") return false;
return e instanceof Element;
};
const isStringNumber = (val) => {
if (!isString(val)) return false;
return !Number.isNaN(Number(val));
};
const epPropKey = "__epPropKey";
const definePropType = (val) => val;
const isEpProp = (val) => isObject$1(val) && !!val["__epPropKey"];
const buildProp = (prop, key) => {
if (!isObject$1(prop) || isEpProp(prop)) return prop;
const { values, required, default: defaultValue, type, validator } = prop;
const epProp = {
type,
required: !!required,
validator: values || validator ? (val) => {
let valid = false;
let allowedValues = [];
if (values) {
allowedValues = Array.from(values);
if (hasOwn(prop, "default")) allowedValues.push(defaultValue);
valid || (valid = allowedValues.includes(val));
}
if (validator) valid || (valid = validator(val));
if (!valid && allowedValues.length > 0) {
const allowValuesText = [...new Set(allowedValues)].map((value) => JSON.stringify(value)).join(", ");
warn(`Invalid prop: validation failed${key ? ` for prop "${key}"` : ""}. Expected one of [${allowValuesText}], got value ${JSON.stringify(val)}.`);
}
return valid;
} : void 0,
[epPropKey]: true
};
if (hasOwn(prop, "default")) epProp.default = defaultValue;
return epProp;
};
const buildProps = (props) => fromPairs(Object.entries(props).map(([key, option]) => [key, buildProp(option, key)]));
const statePrefix = "is-";
const _bem = (namespace, block, blockSuffix, element, modifier) => {
let cls = `${namespace}-${block}`;
if (blockSuffix) cls += `-${blockSuffix}`;
if (element) cls += `__${element}`;
if (modifier) cls += `--${modifier}`;
return cls;
};
const namespaceContextKey = Symbol("namespaceContextKey");
const useGetDerivedNamespace = (namespaceOverrides) => {
const derivedNamespace = namespaceOverrides || (getCurrentInstance() ? inject(namespaceContextKey, ref("el")) : ref("el"));
return computed(() => {
return unref(derivedNamespace) || "el";
});
};
const useNamespace = (block, namespaceOverrides) => {
const namespace = useGetDerivedNamespace(namespaceOverrides);
const b = (blockSuffix = "") => _bem(namespace.value, block, blockSuffix, "", "");
const e = (element) => element ? _bem(namespace.value, block, "", element, "") : "";
const m = (modifier) => modifier ? _bem(namespace.value, block, "", "", modifier) : "";
const be = (blockSuffix, element) => blockSuffix && element ? _bem(namespace.value, block, blockSuffix, element, "") : "";
const em = (element, modifier) => element && modifier ? _bem(namespace.value, block, "", element, modifier) : "";
const bm = (blockSuffix, modifier) => blockSuffix && modifier ? _bem(namespace.value, block, blockSuffix, "", modifier) : "";
const bem = (blockSuffix, element, modifier) => blockSuffix && element && modifier ? _bem(namespace.value, block, blockSuffix, element, modifier) : "";
const is = (name, ...args) => {
const state = args.length >= 1 ? args[0] : true;
return name && state ? `${statePrefix}${name}` : "";
};
const cssVar = (object) => {
const styles = {};
for (const key in object) if (object[key]) styles[`--${namespace.value}-${key}`] = object[key];
return styles;
};
const cssVarBlock = (object) => {
const styles = {};
for (const key in object) if (object[key]) styles[`--${namespace.value}-${block}-${key}`] = object[key];
return styles;
};
const cssVarName = (name) => `--${namespace.value}-${name}`;
const cssVarBlockName = (name) => `--${namespace.value}-${block}-${name}`;
return {
namespace,
b,
e,
m,
be,
em,
bm,
bem,
is,
cssVar,
cssVarName,
cssVarBlock,
cssVarBlockName
};
};
const isShadowRoot = (e) => {
if (typeof ShadowRoot === "undefined") return false;
return e instanceof ShadowRoot;
};
const isHTMLElement = (e) => {
if (typeof Element === "undefined") return false;
return e instanceof Element;
};
const isFocusable = (element) => {
if (element.tabIndex > 0 || element.tabIndex === 0 && element.getAttribute("tabIndex") !== null) return true;
if (element.tabIndex < 0 || element.hasAttribute("disabled") || element.getAttribute("aria-disabled") === "true") return false;
switch (element.nodeName) {
case "A":
return !!element.href && element.rel !== "ignore";
case "INPUT":
return !(element.type === "hidden" || element.type === "file");
case "BUTTON":
case "SELECT":
case "TEXTAREA":
return true;
default:
return false;
}
};
const focusElement = (el, options) => {
if (!el || !el.focus) return;
let cleanup = false;
if (isHTMLElement(el) && !isFocusable(el) && !el.getAttribute("tabindex")) {
el.setAttribute("tabindex", "-1");
cleanup = true;
}
el.focus(options);
if (isHTMLElement(el) && cleanup) el.removeAttribute("tabindex");
};
function computedEager(fn, options) {
var _options$flush;
const result = shallowRef();
watchEffect(() => {
result.value = fn();
}, {
...options,
flush: (_options$flush = options === null || options === void 0 ? void 0 : options.flush) !== null && _options$flush !== void 0 ? _options$flush : "sync"
});
return readonly(result);
}
function tryOnScopeDispose(fn, failSilently) {
if (getCurrentScope()) {
onScopeDispose(fn, failSilently);
return true;
}
return false;
}
const localProvidedStateMap = /* @__PURE__ */ new WeakMap();
const injectLocal = /* @__NO_SIDE_EFFECTS__ */ (...args) => {
var _getCurrentInstance;
const key = args[0];
const instance = (_getCurrentInstance = getCurrentInstance()) === null || _getCurrentInstance === void 0 ? void 0 : _getCurrentInstance.proxy;
const owner = instance !== null && instance !== void 0 ? instance : getCurrentScope();
if (owner == null && !hasInjectionContext()) throw new Error("injectLocal must be called in setup");
if (owner && localProvidedStateMap.has(owner) && key in localProvidedStateMap.get(owner)) return localProvidedStateMap.get(owner)[key];
return inject(...args);
};
const isClient = typeof window !== "undefined" && typeof document !== "undefined";
typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
const notNullish = (val) => val != null;
const toString = Object.prototype.toString;
const isObject = (val) => toString.call(val) === "[object Object]";
const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
const noop = () => {
};
const isIOS = /* @__PURE__ */ getIsIOS();
function getIsIOS() {
var _window, _window2, _window3;
return isClient && !!((_window = window) === null || _window === void 0 || (_window = _window.navigator) === null || _window === void 0 ? void 0 : _window.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.navigator) === null || _window2 === void 0 ? void 0 : _window2.maxTouchPoints) > 2 && /iPad|Macintosh/.test((_window3 = window) === null || _window3 === void 0 ? void 0 : _window3.navigator.userAgent));
}
function createFilterWrapper(filter, fn) {
function wrapper(...args) {
return new Promise((resolve, reject) => {
Promise.resolve(filter(() => fn.apply(this, args), {
fn,
thisArg: this,
args
})).then(resolve).catch(reject);
});
}
return wrapper;
}
function debounceFilter(ms, options = {}) {
let timer;
let maxTimer;
let lastRejector = noop;
const _clearTimeout = (timer2) => {
clearTimeout(timer2);
lastRejector();
lastRejector = noop;
};
let lastInvoker;
const filter = (invoke) => {
const duration = toValue(ms);
const maxDuration = toValue(options.maxWait);
if (timer) _clearTimeout(timer);
if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
if (maxTimer) {
_clearTimeout(maxTimer);
maxTimer = void 0;
}
return Promise.resolve(invoke());
}
return new Promise((resolve, reject) => {
lastRejector = options.rejectOnCancel ? reject : resolve;
lastInvoker = invoke;
if (maxDuration && !maxTimer) maxTimer = setTimeout(() => {
if (timer) _clearTimeout(timer);
maxTimer = void 0;
resolve(lastInvoker());
}, maxDuration);
timer = setTimeout(() => {
if (maxTimer) _clearTimeout(maxTimer);
maxTimer = void 0;
resolve(invoke());
}, duration);
});
};
return filter;
}
function pxValue(px) {
return px.endsWith("rem") ? Number.parseFloat(px) * 16 : Number.parseFloat(px);
}
function toArray(value) {
return Array.isArray(value) ? value : [value];
}
function getLifeCycleTarget(target) {
return getCurrentInstance();
}
// @__NO_SIDE_EFFECTS__
function useDebounceFn(fn, ms = 200, options = {}) {
return createFilterWrapper(debounceFilter(ms, options), fn);
}
function refDebounced(value, ms = 200, options = {}) {
const debounced = ref(toValue(value));
const updater = /* @__PURE__ */ useDebounceFn(() => {
debounced.value = value.value;
}, ms, options);
watch(value, () => updater());
return shallowReadonly(debounced);
}
function tryOnMounted(fn, sync = true, target) {
if (getLifeCycleTarget()) onMounted(fn, target);
else if (sync) fn();
else nextTick(fn);
}
function useTimeoutFn(cb, interval, options = {}) {
const { immediate = true, immediateCallback = false } = options;
const isPending = shallowRef(false);
let timer;
function clear() {
if (timer) {
clearTimeout(timer);
timer = void 0;
}
}
function stop() {
isPending.value = false;
clear();
}
function start(...args) {
if (immediateCallback) cb();
clear();
isPending.value = true;
timer = setTimeout(() => {
isPending.value = false;
timer = void 0;
cb(...args);
}, toValue(interval));
}
if (immediate) {
isPending.value = true;
if (isClient) start();
}
tryOnScopeDispose(stop);
return {
isPending: shallowReadonly(isPending),
start,
stop
};
}
function watchImmediate(source, cb, options) {
return watch(source, cb, {
...options,
immediate: true
});
}
var ElementPlusError = class extends Error {
constructor(m) {
super(m);
this.name = "ElementPlusError";
}
};
function throwError(scope, m) {
throw new ElementPlusError(`[${scope}] ${m}`);
}
function debugWarn(scope, message) {
{
const error = isString(scope) ? new ElementPlusError(`[${scope}] ${message}`) : scope;
console.warn(error);
}
}
export {
namespaceContextKey as A,
noop as B,
notNullish as C,
pxValue as D,
refDebounced as E,
throwError as F,
toArray as G,
tryOnMounted as H,
tryOnScopeDispose as I,
useDebounceFn as J,
useGetDerivedNamespace as K,
useNamespace as L,
useTimeoutFn as M,
NOOP as N,
watchImmediate as O,
withInstall as P,
withInstallFunction as Q,
withNoopInstall as R,
buildProps as a,
buildProp as b,
camelize as c,
clamp as d,
computedEager as e,
debugWarn as f,
definePropType as g,
focusElement as h,
hasOwn as i,
injectLocal as j,
isArray as k,
isBoolean as l,
isClient as m,
isElement as n,
isEmpty as o,
isFocusable as p,
isFunction as q,
isIOS as r,
isNumber as s,
isObject$1 as t,
isObject as u,
isPlainObject as v,
isShadowRoot as w,
isString as x,
isStringNumber as y,
isUndefined as z
};
//# sourceMappingURL=error-DEV4o0cD.js.map