mirror of
https://github.com/ecomfe/vue-echarts.git
synced 2025-10-28 19:43:37 +08:00
feat: rendering tooltips and dataView with slots (#838)
* feat: experimental component rendered tooltip * revert slot in VChart * feat: use tooltip composable * feat: try createApp * feat: use pie chart as tooltip * feat: switch to createVNode The limitation is that the tooltip detached from the current component tree, not provide/inject will try teleport next * feat: try component with teleport * wip * add xAxis example * refactor with shallowReactive * Support dynamic slot * fix: fill empty elements with object in array * shallow copy option along the path * ssr friendly * vibe docs * typo * update according to the review * add dataView slot * chore: fix warnings and errors in demo (#839) * chore: suppress warning in demo * chore: prevent multiple intializations of esbuild-wasm in demo HMR * feat: dynamically update the theme (#841) Co-authored-by: GU Yiling <justice360@gmail.com> * feat: add dataView slot * vibe docs --------- Co-authored-by: GU Yiling <justice360@gmail.com> * fix docs typo * update according to the review * small fix * remove wrapper around slotProp * update comments * remove anys * add tooltip slot prop type * target to vue 3.3 * move slot related codes to slot.ts --------- Co-authored-by: GU Yiling <justice360@gmail.com>
This commit is contained in:
33
src/utils.ts
33
src/utils.ts
@ -1,6 +1,3 @@
|
||||
import type { MaybeRefOrGetter } from "./types";
|
||||
import { unref } from "vue";
|
||||
|
||||
type Attrs = Record<string, any>;
|
||||
|
||||
// Copied from
|
||||
@ -19,13 +16,25 @@ export function omitOn(attrs: Attrs): Attrs {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Copied from
|
||||
// https://github.com/vuejs/core/blob/3cb4db21efa61852b0541475b4ddf57fdec4c479/packages/shared/src/general.ts#L49-L50
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
||||
const isFunction = (val: unknown): val is Function => typeof val === "function";
|
||||
|
||||
// Copied from
|
||||
// https://github.com/vuejs/core/blob/3cb4db21efa61852b0541475b4ddf57fdec4c479/packages/reactivity/src/ref.ts#L246-L248
|
||||
export function toValue<T>(source: MaybeRefOrGetter<T>): T {
|
||||
return isFunction(source) ? source() : unref(source);
|
||||
export function isValidArrayIndex(key: string): boolean {
|
||||
const num = Number(key);
|
||||
return (
|
||||
Number.isInteger(num) &&
|
||||
num >= 0 &&
|
||||
num < Math.pow(2, 32) - 1 &&
|
||||
String(num) === key
|
||||
);
|
||||
}
|
||||
|
||||
export function isSameSet<T>(a: T[], b: T[]): boolean {
|
||||
const setA = new Set(a);
|
||||
const setB = new Set(b);
|
||||
|
||||
if (setA.size !== setB.size) return false;
|
||||
|
||||
for (const val of setA) {
|
||||
if (!setB.has(val)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user