This commit is contained in:
2025-09-19 14:25:20 +08:00
parent 269893a435
commit fbf3f77229
24949 changed files with 2839404 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
import type { PropType } from 'vue';
export type CacheOption = {
value: string | number | boolean | object;
currentLabel: string | number;
isDisabled: boolean;
};
declare const _default: import("vue").DefineComponent<{
data: {
type: PropType<CacheOption[]>;
default: () => never[];
};
}, () => undefined, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
data: {
type: PropType<CacheOption[]>;
default: () => never[];
};
}>>, {
data: CacheOption[];
}>;
export default _default;

View File

@@ -0,0 +1,35 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var token = require('../../select/src/token.js');
var core = require('@vueuse/core');
var CacheOptions = vue.defineComponent({
props: {
data: {
type: Array,
default: () => []
}
},
setup(props) {
const select = vue.inject(token.selectKey);
vue.watch(() => props.data, () => {
var _a;
props.data.forEach((item) => {
if (!select.states.cachedOptions.has(item.value)) {
select.states.cachedOptions.set(item.value, item);
}
});
const inputs = ((_a = select.selectRef) == null ? void 0 : _a.querySelectorAll("input")) || [];
if (core.isClient && !Array.from(inputs).includes(document.activeElement)) {
select.setSelected();
}
}, { flush: "post", immediate: true });
return () => void 0;
}
});
exports["default"] = CacheOptions;
//# sourceMappingURL=cache-options.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"cache-options.js","sources":["../../../../../../packages/components/tree-select/src/cache-options.ts"],"sourcesContent":["import { defineComponent, inject, watch } from 'vue'\nimport { selectKey } from '@element-plus/components/select'\nimport { isClient } from '@element-plus/utils'\n\nimport type { SelectContext } from '@element-plus/components/select'\nimport type { PropType } from 'vue'\n\n// same as el-option instance,\n// these are required for `cachedOptions`\nexport type CacheOption = {\n value: string | number | boolean | object\n currentLabel: string | number\n isDisabled: boolean\n}\n\nexport default defineComponent({\n props: {\n data: {\n type: Array as PropType<CacheOption[]>,\n default: () => [],\n },\n },\n setup(props) {\n const select = inject(selectKey) as NonNullable<SelectContext>\n\n watch(\n () => props.data,\n () => {\n props.data.forEach((item) => {\n if (!select.states.cachedOptions.has(item.value)) {\n // TODO: the type of 'item' is not compatible with the type of 'cachedOptions',\n // which may indicate potential runtime issues.\n // @ts-expect-error\n select.states.cachedOptions.set(item.value, item)\n }\n })\n\n // fork from packages/select/src/useSelect.ts#330\n const inputs = select.selectRef?.querySelectorAll('input') || []\n if (\n isClient &&\n !Array.from(inputs).includes(\n document.activeElement as HTMLInputElement\n )\n ) {\n select.setSelected()\n }\n },\n { flush: 'post', immediate: true }\n )\n\n return () => undefined\n },\n})\n"],"names":["defineComponent","inject","selectKey","watch","isClient"],"mappings":";;;;;;;;AAGA,mBAAeA,mBAAe,CAAC;AAC/B,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE;AACV,MAAM,IAAI,EAAE,KAAK;AACjB,MAAM,OAAO,EAAE,MAAM,EAAE;AACvB,KAAK;AACL,GAAG;AACH,EAAE,KAAK,CAAC,KAAK,EAAE;AACf,IAAI,MAAM,MAAM,GAAGC,UAAM,CAACC,eAAS,CAAC,CAAC;AACrC,IAAIC,SAAK,CAAC,MAAM,KAAK,CAAC,IAAI,EAAE,MAAM;AAClC,MAAM,IAAI,EAAE,CAAC;AACb,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,KAAK;AACnC,QAAQ,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;AAC1D,UAAU,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAC5D,SAAS;AACT,OAAO,CAAC,CAAC;AACT,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,SAAS,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;AACrG,MAAM,IAAIC,aAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE;AAC5E,QAAQ,MAAM,CAAC,WAAW,EAAE,CAAC;AAC7B,OAAO;AACP,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAC3C,IAAI,OAAO,MAAM,KAAK,CAAC,CAAC;AACxB,GAAG;AACH,CAAC,CAAC;;;;"}

View File

@@ -0,0 +1,11 @@
import type { Ref } from 'vue';
import type { SelectInstance } from 'element-plus/es/components/select';
import type { TreeInstance } from 'element-plus/es/components/tree';
export declare const useSelect: (props: any, { attrs, emit }: {
attrs: any;
emit: any;
}, { select, tree, key, }: {
select: Ref<SelectInstance | undefined>;
tree: Ref<TreeInstance | undefined>;
key: Ref<string>;
}) => any;

View File

@@ -0,0 +1,53 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var lodashUnified = require('lodash-unified');
var index$1 = require('../../select/index.js');
var index = require('../../../hooks/use-namespace/index.js');
var event = require('../../../constants/event.js');
const useSelect = (props, { attrs, emit }, {
select,
tree,
key
}) => {
const ns = index.useNamespace("tree-select");
vue.watch(() => props.data, () => {
if (props.filterable) {
vue.nextTick(() => {
var _a, _b;
(_b = tree.value) == null ? void 0 : _b.filter((_a = select.value) == null ? void 0 : _a.states.inputValue);
});
}
}, { flush: "post" });
const result = {
...lodashUnified.pick(vue.toRefs(props), Object.keys(index$1.ElSelect.props)),
...attrs,
class: vue.computed(() => attrs.class),
style: vue.computed(() => attrs.style),
"onUpdate:modelValue": (value) => emit(event.UPDATE_MODEL_EVENT, value),
valueKey: key,
popperClass: vue.computed(() => {
const classes = [ns.e("popper")];
if (props.popperClass)
classes.push(props.popperClass);
return classes.join(" ");
}),
filterMethod: (keyword = "") => {
var _a;
if (props.filterMethod) {
props.filterMethod(keyword);
} else if (props.remoteMethod) {
props.remoteMethod(keyword);
} else {
(_a = tree.value) == null ? void 0 : _a.filter(keyword);
}
}
};
return result;
};
exports.useSelect = useSelect;
//# sourceMappingURL=select.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"select.js","sources":["../../../../../../packages/components/tree-select/src/select.ts"],"sourcesContent":["// @ts-nocheck\nimport { computed, nextTick, toRefs, watch } from 'vue'\nimport { pick } from 'lodash-unified'\nimport ElSelect from '@element-plus/components/select'\nimport { useNamespace } from '@element-plus/hooks'\nimport { UPDATE_MODEL_EVENT } from '@element-plus/constants'\n\nimport type { Ref } from 'vue'\nimport type { SelectInstance } from '@element-plus/components/select'\nimport type { TreeInstance } from '@element-plus/components/tree'\n\nexport const useSelect = (\n props,\n { attrs, emit },\n {\n select,\n tree,\n key,\n }: {\n select: Ref<SelectInstance | undefined>\n tree: Ref<TreeInstance | undefined>\n key: Ref<string>\n }\n) => {\n const ns = useNamespace('tree-select')\n\n // update tree data when use filterMethod/remoteMethod\n watch(\n () => props.data,\n () => {\n if (props.filterable) {\n nextTick(() => {\n // let tree node expand only, same with tree filter\n tree.value?.filter(select.value?.states.inputValue)\n })\n }\n },\n { flush: 'post' }\n )\n\n const result = {\n ...pick(toRefs(props), Object.keys(ElSelect.props)),\n ...attrs,\n class: computed(() => attrs.class),\n style: computed(() => attrs.style),\n // attrs is not reactive, when v-model binding source changes,\n // this listener is still old, see the bug(or test 'v-model source change'):\n // https://github.com/element-plus/element-plus/issues/14204\n 'onUpdate:modelValue': (value) => emit(UPDATE_MODEL_EVENT, value),\n valueKey: key,\n popperClass: computed(() => {\n const classes = [ns.e('popper')]\n if (props.popperClass) classes.push(props.popperClass)\n return classes.join(' ')\n }),\n filterMethod: (keyword = '') => {\n if (props.filterMethod) {\n props.filterMethod(keyword)\n } else if (props.remoteMethod) {\n props.remoteMethod(keyword)\n } else {\n // let tree node expand only, same with tree filter\n tree.value?.filter(keyword)\n }\n },\n }\n\n return result\n}\n"],"names":["useNamespace","watch","nextTick","pick","toRefs","ElSelect","computed","UPDATE_MODEL_EVENT"],"mappings":";;;;;;;;;;AAKY,MAAC,SAAS,GAAG,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;AAClD,EAAE,MAAM;AACR,EAAE,IAAI;AACN,EAAE,GAAG;AACL,CAAC,KAAK;AACN,EAAE,MAAM,EAAE,GAAGA,kBAAY,CAAC,aAAa,CAAC,CAAC;AACzC,EAAEC,SAAK,CAAC,MAAM,KAAK,CAAC,IAAI,EAAE,MAAM;AAChC,IAAI,IAAI,KAAK,CAAC,UAAU,EAAE;AAC1B,MAAMC,YAAQ,CAAC,MAAM;AACrB,QAAQ,IAAI,EAAE,EAAE,EAAE,CAAC;AACnB,QAAQ,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,KAAK,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AACpH,OAAO,CAAC,CAAC;AACT,KAAK;AACL,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;AACxB,EAAE,MAAM,MAAM,GAAG;AACjB,IAAI,GAAGC,kBAAI,CAACC,UAAM,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,IAAI,CAACC,gBAAQ,CAAC,KAAK,CAAC,CAAC;AACvD,IAAI,GAAG,KAAK;AACZ,IAAI,KAAK,EAAEC,YAAQ,CAAC,MAAM,KAAK,CAAC,KAAK,CAAC;AACtC,IAAI,KAAK,EAAEA,YAAQ,CAAC,MAAM,KAAK,CAAC,KAAK,CAAC;AACtC,IAAI,qBAAqB,EAAE,CAAC,KAAK,KAAK,IAAI,CAACC,wBAAkB,EAAE,KAAK,CAAC;AACrE,IAAI,QAAQ,EAAE,GAAG;AACjB,IAAI,WAAW,EAAED,YAAQ,CAAC,MAAM;AAChC,MAAM,MAAM,OAAO,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;AACvC,MAAM,IAAI,KAAK,CAAC,WAAW;AAC3B,QAAQ,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AACxC,MAAM,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/B,KAAK,CAAC;AACN,IAAI,YAAY,EAAE,CAAC,OAAO,GAAG,EAAE,KAAK;AACpC,MAAM,IAAI,EAAE,CAAC;AACb,MAAM,IAAI,KAAK,CAAC,YAAY,EAAE;AAC9B,QAAQ,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AACpC,OAAO,MAAM,IAAI,KAAK,CAAC,YAAY,EAAE;AACrC,QAAQ,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AACpC,OAAO,MAAM;AACb,QAAQ,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAChE,OAAO;AACP,KAAK;AACL,GAAG,CAAC;AACJ,EAAE,OAAO,MAAM,CAAC;AAChB;;;;"}

View File

@@ -0,0 +1,443 @@
import { nextTick } from 'vue';
declare const component: import("vue").DefineComponent<{}, any, {}, {}, {
selectOptionClick(): void;
}, import("vue").ComponentOptionsMixin, ({
new (...args: any[]): {
$: import("vue").ComponentInternalInstance;
$data: {};
$props: Partial<{
disabled: boolean;
created: boolean;
}> & Omit<Readonly<import("vue").ExtractPropTypes<{
value: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(ObjectConstructor | BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown>>;
readonly required: true;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
label: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(NumberConstructor | StringConstructor)[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
created: BooleanConstructor;
disabled: BooleanConstructor;
}>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "disabled" | "created">;
$attrs: {
[x: string]: unknown;
};
$refs: {
[x: string]: unknown;
};
$slots: import("vue").Slots;
$root: import("vue").ComponentPublicInstance | null;
$parent: import("vue").ComponentPublicInstance | null;
$emit: (event: string, ...args: any[]) => void;
$el: any;
$options: import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
value: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(ObjectConstructor | BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown>>;
readonly required: true;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
label: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(NumberConstructor | StringConstructor)[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
created: BooleanConstructor;
disabled: BooleanConstructor;
}>>, {
ns: {
namespace: import("vue").ComputedRef<string>;
b: (blockSuffix?: string) => string;
e: (element?: string) => string;
m: (modifier?: string) => string;
be: (blockSuffix?: string, element?: string) => string;
em: (element?: string, modifier?: string) => string;
bm: (blockSuffix?: string, modifier?: string) => string;
bem: (blockSuffix?: string, element?: string, modifier?: string) => string;
is: {
(name: string, state: boolean | undefined): string;
(name: string): string;
};
cssVar: (object: Record<string, string>) => Record<string, string>;
cssVarName: (name: string) => string;
cssVarBlock: (object: Record<string, string>) => Record<string, string>;
cssVarBlockName: (name: string) => string;
};
id: import("vue").Ref<string>;
containerKls: import("vue").ComputedRef<string[]>;
currentLabel: import("vue").ComputedRef<boolean | import("element-plus/es/utils").EpPropMergeType<(NumberConstructor | StringConstructor)[], unknown, unknown>>;
itemSelected: import("vue").ComputedRef<boolean>;
isDisabled: import("vue").ComputedRef<boolean>;
select: import("element-plus/es/components/select").SelectContext;
visible: import("vue").Ref<boolean>;
hover: import("vue").Ref<boolean>;
states: {
index: number;
groupDisabled: boolean;
visible: boolean;
hover: boolean;
};
hoverItem: () => void;
updateOption: (query: string) => void;
selectOptionClick: () => void;
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, {
disabled: boolean;
created: boolean;
}> & {
beforeCreate?: (() => void) | (() => void)[];
created?: (() => void) | (() => void)[];
beforeMount?: (() => void) | (() => void)[];
mounted?: (() => void) | (() => void)[];
beforeUpdate?: (() => void) | (() => void)[];
updated?: (() => void) | (() => void)[];
activated?: (() => void) | (() => void)[];
deactivated?: (() => void) | (() => void)[];
beforeDestroy?: (() => void) | (() => void)[];
beforeUnmount?: (() => void) | (() => void)[];
destroyed?: (() => void) | (() => void)[];
unmounted?: (() => void) | (() => void)[];
renderTracked?: ((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[];
renderTriggered?: ((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[];
errorCaptured?: ((err: unknown, instance: import("vue").ComponentPublicInstance | null, info: string) => boolean | void) | ((err: unknown, instance: import("vue").ComponentPublicInstance | null, info: string) => boolean | void)[];
};
$forceUpdate: () => void;
$nextTick: typeof nextTick;
$watch(source: string | Function, cb: Function, options?: import("vue").WatchOptions): import("vue").WatchStopHandle;
} & Readonly<import("vue").ExtractPropTypes<{
value: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(ObjectConstructor | BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown>>;
readonly required: true;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
label: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(NumberConstructor | StringConstructor)[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
created: BooleanConstructor;
disabled: BooleanConstructor;
}>> & import("vue").ShallowUnwrapRef<{
ns: {
namespace: import("vue").ComputedRef<string>;
b: (blockSuffix?: string) => string;
e: (element?: string) => string;
m: (modifier?: string) => string;
be: (blockSuffix?: string, element?: string) => string;
em: (element?: string, modifier?: string) => string;
bm: (blockSuffix?: string, modifier?: string) => string;
bem: (blockSuffix?: string, element?: string, modifier?: string) => string;
is: {
(name: string, state: boolean | undefined): string;
(name: string): string;
};
cssVar: (object: Record<string, string>) => Record<string, string>;
cssVarName: (name: string) => string;
cssVarBlock: (object: Record<string, string>) => Record<string, string>;
cssVarBlockName: (name: string) => string;
};
id: import("vue").Ref<string>;
containerKls: import("vue").ComputedRef<string[]>;
currentLabel: import("vue").ComputedRef<boolean | import("element-plus/es/utils").EpPropMergeType<(NumberConstructor | StringConstructor)[], unknown, unknown>>;
itemSelected: import("vue").ComputedRef<boolean>;
isDisabled: import("vue").ComputedRef<boolean>;
select: import("element-plus/es/components/select").SelectContext;
visible: import("vue").Ref<boolean>;
hover: import("vue").Ref<boolean>;
states: {
index: number;
groupDisabled: boolean;
visible: boolean;
hover: boolean;
};
hoverItem: () => void;
updateOption: (query: string) => void;
selectOptionClick: () => void;
}> & {} & import("vue").ComponentCustomProperties;
__isFragment?: never;
__isTeleport?: never;
__isSuspense?: never;
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
value: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(ObjectConstructor | BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown>>;
readonly required: true;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
label: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(NumberConstructor | StringConstructor)[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
created: BooleanConstructor;
disabled: BooleanConstructor;
}>>, {
ns: {
namespace: import("vue").ComputedRef<string>;
b: (blockSuffix?: string) => string;
e: (element?: string) => string;
m: (modifier?: string) => string;
be: (blockSuffix?: string, element?: string) => string;
em: (element?: string, modifier?: string) => string;
bm: (blockSuffix?: string, modifier?: string) => string;
bem: (blockSuffix?: string, element?: string, modifier?: string) => string;
is: {
(name: string, state: boolean | undefined): string;
(name: string): string;
};
cssVar: (object: Record<string, string>) => Record<string, string>;
cssVarName: (name: string) => string;
cssVarBlock: (object: Record<string, string>) => Record<string, string>;
cssVarBlockName: (name: string) => string;
};
id: import("vue").Ref<string>;
containerKls: import("vue").ComputedRef<string[]>;
currentLabel: import("vue").ComputedRef<boolean | import("element-plus/es/utils").EpPropMergeType<(NumberConstructor | StringConstructor)[], unknown, unknown>>;
itemSelected: import("vue").ComputedRef<boolean>;
isDisabled: import("vue").ComputedRef<boolean>;
select: import("element-plus/es/components/select").SelectContext;
visible: import("vue").Ref<boolean>;
hover: import("vue").Ref<boolean>;
states: {
index: number;
groupDisabled: boolean;
visible: boolean;
hover: boolean;
};
hoverItem: () => void;
updateOption: (query: string) => void;
selectOptionClick: () => void;
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, {
disabled: boolean;
created: boolean;
}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & ((app: import("vue").App, ...options: any[]) => any) & {
install?: (app: import("vue").App, ...options: any[]) => any;
}) | ({
new (...args: any[]): {
$: import("vue").ComponentInternalInstance;
$data: {};
$props: Partial<{
disabled: boolean;
created: boolean;
}> & Omit<Readonly<import("vue").ExtractPropTypes<{
value: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(ObjectConstructor | BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown>>;
readonly required: true;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
label: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(NumberConstructor | StringConstructor)[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
created: BooleanConstructor;
disabled: BooleanConstructor;
}>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "disabled" | "created">;
$attrs: {
[x: string]: unknown;
};
$refs: {
[x: string]: unknown;
};
$slots: import("vue").Slots;
$root: import("vue").ComponentPublicInstance | null;
$parent: import("vue").ComponentPublicInstance | null;
$emit: (event: string, ...args: any[]) => void;
$el: any;
$options: import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
value: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(ObjectConstructor | BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown>>;
readonly required: true;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
label: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(NumberConstructor | StringConstructor)[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
created: BooleanConstructor;
disabled: BooleanConstructor;
}>>, {
ns: {
namespace: import("vue").ComputedRef<string>;
b: (blockSuffix?: string) => string;
e: (element?: string) => string;
m: (modifier?: string) => string;
be: (blockSuffix?: string, element?: string) => string;
em: (element?: string, modifier?: string) => string;
bm: (blockSuffix?: string, modifier?: string) => string;
bem: (blockSuffix?: string, element?: string, modifier?: string) => string;
is: {
(name: string, state: boolean | undefined): string;
(name: string): string;
};
cssVar: (object: Record<string, string>) => Record<string, string>;
cssVarName: (name: string) => string;
cssVarBlock: (object: Record<string, string>) => Record<string, string>;
cssVarBlockName: (name: string) => string;
};
id: import("vue").Ref<string>;
containerKls: import("vue").ComputedRef<string[]>;
currentLabel: import("vue").ComputedRef<boolean | import("element-plus/es/utils").EpPropMergeType<(NumberConstructor | StringConstructor)[], unknown, unknown>>;
itemSelected: import("vue").ComputedRef<boolean>;
isDisabled: import("vue").ComputedRef<boolean>;
select: import("element-plus/es/components/select").SelectContext;
visible: import("vue").Ref<boolean>;
hover: import("vue").Ref<boolean>;
states: {
index: number;
groupDisabled: boolean;
visible: boolean;
hover: boolean;
};
hoverItem: () => void;
updateOption: (query: string) => void;
selectOptionClick: () => void;
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, {
disabled: boolean;
created: boolean;
}> & {
beforeCreate?: (() => void) | (() => void)[];
created?: (() => void) | (() => void)[];
beforeMount?: (() => void) | (() => void)[];
mounted?: (() => void) | (() => void)[];
beforeUpdate?: (() => void) | (() => void)[];
updated?: (() => void) | (() => void)[];
activated?: (() => void) | (() => void)[];
deactivated?: (() => void) | (() => void)[];
beforeDestroy?: (() => void) | (() => void)[];
beforeUnmount?: (() => void) | (() => void)[];
destroyed?: (() => void) | (() => void)[];
unmounted?: (() => void) | (() => void)[];
renderTracked?: ((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[];
renderTriggered?: ((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[];
errorCaptured?: ((err: unknown, instance: import("vue").ComponentPublicInstance | null, info: string) => boolean | void) | ((err: unknown, instance: import("vue").ComponentPublicInstance | null, info: string) => boolean | void)[];
};
$forceUpdate: () => void;
$nextTick: typeof nextTick;
$watch(source: string | Function, cb: Function, options?: import("vue").WatchOptions): import("vue").WatchStopHandle;
} & Readonly<import("vue").ExtractPropTypes<{
value: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(ObjectConstructor | BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown>>;
readonly required: true;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
label: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(NumberConstructor | StringConstructor)[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
created: BooleanConstructor;
disabled: BooleanConstructor;
}>> & import("vue").ShallowUnwrapRef<{
ns: {
namespace: import("vue").ComputedRef<string>;
b: (blockSuffix?: string) => string;
e: (element?: string) => string;
m: (modifier?: string) => string;
be: (blockSuffix?: string, element?: string) => string;
em: (element?: string, modifier?: string) => string;
bm: (blockSuffix?: string, modifier?: string) => string;
bem: (blockSuffix?: string, element?: string, modifier?: string) => string;
is: {
(name: string, state: boolean | undefined): string;
(name: string): string;
};
cssVar: (object: Record<string, string>) => Record<string, string>;
cssVarName: (name: string) => string;
cssVarBlock: (object: Record<string, string>) => Record<string, string>;
cssVarBlockName: (name: string) => string;
};
id: import("vue").Ref<string>;
containerKls: import("vue").ComputedRef<string[]>;
currentLabel: import("vue").ComputedRef<boolean | import("element-plus/es/utils").EpPropMergeType<(NumberConstructor | StringConstructor)[], unknown, unknown>>;
itemSelected: import("vue").ComputedRef<boolean>;
isDisabled: import("vue").ComputedRef<boolean>;
select: import("element-plus/es/components/select").SelectContext;
visible: import("vue").Ref<boolean>;
hover: import("vue").Ref<boolean>;
states: {
index: number;
groupDisabled: boolean;
visible: boolean;
hover: boolean;
};
hoverItem: () => void;
updateOption: (query: string) => void;
selectOptionClick: () => void;
}> & {} & import("vue").ComponentCustomProperties;
__isFragment?: never;
__isTeleport?: never;
__isSuspense?: never;
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
value: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(ObjectConstructor | BooleanConstructor | NumberConstructor | StringConstructor)[], unknown, unknown>>;
readonly required: true;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
label: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(NumberConstructor | StringConstructor)[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
created: BooleanConstructor;
disabled: BooleanConstructor;
}>>, {
ns: {
namespace: import("vue").ComputedRef<string>;
b: (blockSuffix?: string) => string;
e: (element?: string) => string;
m: (modifier?: string) => string;
be: (blockSuffix?: string, element?: string) => string;
em: (element?: string, modifier?: string) => string;
bm: (blockSuffix?: string, modifier?: string) => string;
bem: (blockSuffix?: string, element?: string, modifier?: string) => string;
is: {
(name: string, state: boolean | undefined): string;
(name: string): string;
};
cssVar: (object: Record<string, string>) => Record<string, string>;
cssVarName: (name: string) => string;
cssVarBlock: (object: Record<string, string>) => Record<string, string>;
cssVarBlockName: (name: string) => string;
};
id: import("vue").Ref<string>;
containerKls: import("vue").ComputedRef<string[]>;
currentLabel: import("vue").ComputedRef<boolean | import("element-plus/es/utils").EpPropMergeType<(NumberConstructor | StringConstructor)[], unknown, unknown>>;
itemSelected: import("vue").ComputedRef<boolean>;
isDisabled: import("vue").ComputedRef<boolean>;
select: import("element-plus/es/components/select").SelectContext;
visible: import("vue").Ref<boolean>;
hover: import("vue").Ref<boolean>;
states: {
index: number;
groupDisabled: boolean;
visible: boolean;
hover: boolean;
};
hoverItem: () => void;
updateOption: (query: string) => void;
selectOptionClick: () => void;
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, {
disabled: boolean;
created: boolean;
}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & {
install: (app: import("vue").App, ...options: any[]) => any;
}), import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
export default component;

View File

@@ -0,0 +1,36 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var index = require('../../select/index.js');
const component = vue.defineComponent({
extends: index.ElOption,
setup(props, ctx) {
const result = index.ElOption.setup(props, ctx);
delete result.selectOptionClick;
const vm = vue.getCurrentInstance().proxy;
vue.nextTick(() => {
if (!result.select.states.cachedOptions.get(vm.value)) {
result.select.onOptionCreate(vm);
}
});
vue.watch(() => ctx.attrs.visible, (val) => {
vue.nextTick(() => {
result.states.visible = val;
});
}, {
immediate: true
});
return result;
},
methods: {
selectOptionClick() {
this.$el.parentElement.click();
}
}
});
exports["default"] = component;
//# sourceMappingURL=tree-select-option.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"tree-select-option.js","sources":["../../../../../../packages/components/tree-select/src/tree-select-option.ts"],"sourcesContent":["import { defineComponent, getCurrentInstance, nextTick, watch } from 'vue'\nimport { ElOption } from '@element-plus/components/select'\n\nconst component = defineComponent({\n extends: ElOption,\n setup(props, ctx) {\n const result = (ElOption.setup as NonNullable<any>)(props, ctx)\n\n // use methods.selectOptionClick\n delete result.selectOptionClick\n\n const vm = (getCurrentInstance() as NonNullable<any>).proxy\n\n // Fix: https://github.com/element-plus/element-plus/issues/7917\n // `el-option` will delete the cache before unmount,\n // This is normal for flat arrays `<el-select><el-option v-for=\"3\"></el-select>`,\n // Because the same node key does not create a difference node,\n // But in tree data, the same key at different levels will create diff nodes,\n // So the destruction of `el-option` in `nextTick` will be slower than\n // the creation of new `el-option`, which will delete the new node,\n // here restore the deleted node.\n // @link https://github.com/element-plus/element-plus/blob/6df6e49db07b38d6cc3b5e9a960782bd30879c11/packages/components/select/src/option.vue#L78\n nextTick(() => {\n if (!result.select.states.cachedOptions.get(vm.value)) {\n result.select.onOptionCreate(vm)\n }\n })\n\n watch(\n () => ctx.attrs.visible,\n (val) => {\n nextTick(() => {\n result.states.visible = val\n })\n },\n {\n immediate: true,\n }\n )\n\n return result\n },\n methods: {\n selectOptionClick() {\n // $el.parentElement => el-tree-node__content\n this.$el.parentElement.click()\n },\n },\n})\n\nexport default component\n"],"names":["defineComponent","ElOption","getCurrentInstance","nextTick","watch"],"mappings":";;;;;;;AAEK,MAAC,SAAS,GAAGA,mBAAe,CAAC;AAClC,EAAE,OAAO,EAAEC,cAAQ;AACnB,EAAE,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE;AACpB,IAAI,MAAM,MAAM,GAAGA,cAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC9C,IAAI,OAAO,MAAM,CAAC,iBAAiB,CAAC;AACpC,IAAI,MAAM,EAAE,GAAGC,sBAAkB,EAAE,CAAC,KAAK,CAAC;AAC1C,IAAIC,YAAQ,CAAC,MAAM;AACnB,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE;AAC7D,QAAQ,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;AACzC,OAAO;AACP,KAAK,CAAC,CAAC;AACP,IAAIC,SAAK,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,GAAG,KAAK;AAC5C,MAAMD,YAAQ,CAAC,MAAM;AACrB,QAAQ,MAAM,CAAC,MAAM,CAAC,OAAO,GAAG,GAAG,CAAC;AACpC,OAAO,CAAC,CAAC;AACT,KAAK,EAAE;AACP,MAAM,SAAS,EAAE,IAAI;AACrB,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,MAAM,CAAC;AAClB,GAAG;AACH,EAAE,OAAO,EAAE;AACX,IAAI,iBAAiB,GAAG;AACxB,MAAM,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;AACrC,KAAK;AACL,GAAG;AACH,CAAC;;;;"}

View File

@@ -0,0 +1,83 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var lodashUnified = require('lodash-unified');
var index = require('../../select/index.js');
var index$1 = require('../../tree/index.js');
var select = require('./select.js');
var tree = require('./tree.js');
var cacheOptions = require('./cache-options.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
const _sfc_main = vue.defineComponent({
name: "ElTreeSelect",
inheritAttrs: false,
props: {
...index.ElSelect.props,
...index$1.ElTree.props,
cacheData: {
type: Array,
default: () => []
}
},
setup(props, context) {
const { slots, expose } = context;
const select$1 = vue.ref();
const tree$1 = vue.ref();
const key = vue.computed(() => props.nodeKey || props.valueKey || "value");
const selectProps = select.useSelect(props, context, { select: select$1, tree: tree$1, key });
const { cacheOptions: cacheOptions$1, ...treeProps } = tree.useTree(props, context, {
select: select$1,
tree: tree$1,
key
});
const methods = vue.reactive({});
expose(methods);
vue.onMounted(() => {
Object.assign(methods, {
...lodashUnified.pick(tree$1.value, [
"filter",
"updateKeyChildren",
"getCheckedNodes",
"setCheckedNodes",
"getCheckedKeys",
"setCheckedKeys",
"setChecked",
"getHalfCheckedNodes",
"getHalfCheckedKeys",
"getCurrentKey",
"getCurrentNode",
"setCurrentKey",
"setCurrentNode",
"getNode",
"remove",
"append",
"insertBefore",
"insertAfter"
]),
...lodashUnified.pick(select$1.value, ["focus", "blur", "selectedLabel"]),
treeRef: tree$1.value,
selectRef: select$1.value
});
});
return () => vue.h(index.ElSelect, vue.reactive({
...selectProps,
ref: (ref2) => select$1.value = ref2
}), {
...slots,
default: () => [
vue.h(cacheOptions["default"], { data: cacheOptions$1.value }),
vue.h(index$1.ElTree, vue.reactive({
...treeProps,
ref: (ref2) => tree$1.value = ref2
}))
]
});
}
});
var TreeSelect = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "tree-select.vue"]]);
exports["default"] = TreeSelect;
//# sourceMappingURL=tree-select.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,6 @@
declare const _default: import("vue").DefineComponent<any, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}>, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<any>, {} | {
[x: string]: any;
}>;
export default _default;

View File

@@ -0,0 +1,12 @@
import type { Ref } from 'vue';
import type { SelectInstance } from 'element-plus/es/components/select';
import type { TreeInstance } from 'element-plus/es/components/tree';
export declare const useTree: (props: any, { attrs, slots, emit }: {
attrs: any;
slots: any;
emit: any;
}, { select, tree, key, }: {
select: Ref<SelectInstance | undefined>;
tree: Ref<TreeInstance | undefined>;
key: Ref<string>;
}) => any;

View File

@@ -0,0 +1,171 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var lodashUnified = require('lodash-unified');
var index = require('../../tree/index.js');
var treeSelectOption = require('./tree-select-option.js');
var utils = require('./utils.js');
var strings = require('../../../utils/strings.js');
var event = require('../../../constants/event.js');
var shared = require('@vue/shared');
var types = require('../../../utils/types.js');
const useTree = (props, { attrs, slots, emit }, {
select,
tree,
key
}) => {
vue.watch([() => props.modelValue, tree], () => {
if (props.showCheckbox) {
vue.nextTick(() => {
const treeInstance = tree.value;
if (treeInstance && !lodashUnified.isEqual(treeInstance.getCheckedKeys(), utils.toValidArray(props.modelValue))) {
treeInstance.setCheckedKeys(utils.toValidArray(props.modelValue));
}
});
}
}, {
immediate: true,
deep: true
});
const propsMap = vue.computed(() => ({
value: key.value,
label: "label",
children: "children",
disabled: "disabled",
isLeaf: "isLeaf",
...props.props
}));
const getNodeValByProp = (prop, data) => {
var _a;
const propVal = propsMap.value[prop];
if (shared.isFunction(propVal)) {
return propVal(data, (_a = tree.value) == null ? void 0 : _a.getNode(getNodeValByProp("value", data)));
} else {
return data[propVal];
}
};
const defaultExpandedParentKeys = utils.toValidArray(props.modelValue).map((value) => {
return utils.treeFind(props.data || [], (data) => getNodeValByProp("value", data) === value, (data) => getNodeValByProp("children", data), (data, index, array, parent) => parent && getNodeValByProp("value", parent));
}).filter((item) => utils.isValidValue(item));
const cacheOptions = vue.computed(() => {
if (!props.renderAfterExpand && !props.lazy)
return [];
const options = [];
utils.treeEach(props.data.concat(props.cacheData), (node) => {
const value = getNodeValByProp("value", node);
options.push({
value,
currentLabel: getNodeValByProp("label", node),
isDisabled: getNodeValByProp("disabled", node)
});
}, (data) => getNodeValByProp("children", data));
return options;
});
const getChildCheckedKeys = () => {
var _a;
return (_a = tree.value) == null ? void 0 : _a.getCheckedKeys().filter((checkedKey) => {
var _a2;
const node = (_a2 = tree.value) == null ? void 0 : _a2.getNode(checkedKey);
return !lodashUnified.isNil(node) && types.isEmpty(node.childNodes);
});
};
return {
...lodashUnified.pick(vue.toRefs(props), Object.keys(index.ElTree.props)),
...attrs,
nodeKey: key,
expandOnClickNode: vue.computed(() => {
return !props.checkStrictly && props.expandOnClickNode;
}),
defaultExpandedKeys: vue.computed(() => {
return props.defaultExpandedKeys ? props.defaultExpandedKeys.concat(defaultExpandedParentKeys) : defaultExpandedParentKeys;
}),
renderContent: (h, { node, data, store }) => {
return h(treeSelectOption["default"], {
value: getNodeValByProp("value", data),
label: getNodeValByProp("label", data),
disabled: getNodeValByProp("disabled", data),
visible: node.visible
}, props.renderContent ? () => props.renderContent(h, { node, data, store }) : slots.default ? () => slots.default({ node, data, store }) : void 0);
},
filterNodeMethod: (value, data, node) => {
if (props.filterNodeMethod)
return props.filterNodeMethod(value, data, node);
if (!value)
return true;
const regexp = new RegExp(strings.escapeStringRegexp(value), "i");
return regexp.test(getNodeValByProp("label", data) || "");
},
onNodeClick: (data, node, e) => {
var _a, _b, _c, _d;
(_a = attrs.onNodeClick) == null ? void 0 : _a.call(attrs, data, node, e);
if (props.showCheckbox && props.checkOnClickNode)
return;
if (!props.showCheckbox && (props.checkStrictly || node.isLeaf)) {
if (!getNodeValByProp("disabled", data)) {
const option = (_b = select.value) == null ? void 0 : _b.states.options.get(getNodeValByProp("value", data));
(_c = select.value) == null ? void 0 : _c.handleOptionSelect(option);
}
} else if (props.expandOnClickNode) {
e.proxy.handleExpandIconClick();
}
(_d = select.value) == null ? void 0 : _d.focus();
},
onCheck: (data, params) => {
var _a;
if (!props.showCheckbox)
return;
const dataValue = getNodeValByProp("value", data);
const dataMap = {};
utils.treeEach([tree.value.store.root], (node) => dataMap[node.key] = node, (node) => node.childNodes);
const uncachedCheckedKeys = params.checkedKeys;
const cachedKeys = props.multiple ? utils.toValidArray(props.modelValue).filter((item) => !(item in dataMap) && !uncachedCheckedKeys.includes(item)) : [];
const checkedKeys = cachedKeys.concat(uncachedCheckedKeys);
if (props.checkStrictly) {
emit(event.UPDATE_MODEL_EVENT, props.multiple ? checkedKeys : checkedKeys.includes(dataValue) ? dataValue : void 0);
} else {
if (props.multiple) {
const childKeys = getChildCheckedKeys();
emit(event.UPDATE_MODEL_EVENT, cachedKeys.concat(childKeys));
} else {
const firstLeaf = utils.treeFind([data], (data2) => !utils.isValidArray(getNodeValByProp("children", data2)) && !getNodeValByProp("disabled", data2), (data2) => getNodeValByProp("children", data2));
const firstLeafKey = firstLeaf ? getNodeValByProp("value", firstLeaf) : void 0;
const hasCheckedChild = utils.isValidValue(props.modelValue) && !!utils.treeFind([data], (data2) => getNodeValByProp("value", data2) === props.modelValue, (data2) => getNodeValByProp("children", data2));
emit(event.UPDATE_MODEL_EVENT, firstLeafKey === props.modelValue || hasCheckedChild ? void 0 : firstLeafKey);
}
}
vue.nextTick(() => {
var _a2;
const checkedKeys2 = utils.toValidArray(props.modelValue);
tree.value.setCheckedKeys(checkedKeys2);
(_a2 = attrs.onCheck) == null ? void 0 : _a2.call(attrs, data, {
checkedKeys: tree.value.getCheckedKeys(),
checkedNodes: tree.value.getCheckedNodes(),
halfCheckedKeys: tree.value.getHalfCheckedKeys(),
halfCheckedNodes: tree.value.getHalfCheckedNodes()
});
});
(_a = select.value) == null ? void 0 : _a.focus();
},
onNodeExpand: (data, node, e) => {
var _a;
(_a = attrs.onNodeExpand) == null ? void 0 : _a.call(attrs, data, node, e);
vue.nextTick(() => {
if (!props.checkStrictly && props.lazy && props.multiple && node.checked) {
const dataMap = {};
const uncachedCheckedKeys = tree.value.getCheckedKeys();
utils.treeEach([tree.value.store.root], (node2) => dataMap[node2.key] = node2, (node2) => node2.childNodes);
const cachedKeys = utils.toValidArray(props.modelValue).filter((item) => !(item in dataMap) && !uncachedCheckedKeys.includes(item));
const childKeys = getChildCheckedKeys();
emit(event.UPDATE_MODEL_EVENT, cachedKeys.concat(childKeys));
}
});
},
cacheOptions
};
};
exports.useTree = useTree;
//# sourceMappingURL=tree.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
import type { TreeNodeData } from 'element-plus/es/components/tree/src/tree.type';
export declare function isValidValue(val: any): any;
export declare function isValidArray(val: any): number | false;
export declare function toValidArray(val: any): any[];
type TreeCallback<T extends TreeNodeData, R> = (data: T, index: number, array: T[], parent?: T) => R;
type TreeFindCallback<T extends TreeNodeData> = TreeCallback<T, boolean>;
export declare function treeFind<T extends TreeNodeData>(treeData: T[], findCallback: TreeFindCallback<T>, getChildren: (data: T) => T[]): T | undefined;
export declare function treeFind<T extends TreeNodeData, R>(treeData: T[], findCallback: TreeFindCallback<T>, getChildren: (data: T) => T[], resultCallback?: TreeCallback<T, R>, parent?: T): R | undefined;
export declare function treeEach<T extends TreeNodeData>(treeData: T[], callback: TreeCallback<T, void>, getChildren: (data: T) => T[], parent?: T): void;
export {};

View File

@@ -0,0 +1,47 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var shared = require('@vue/shared');
function isValidValue(val) {
return val || val === 0;
}
function isValidArray(val) {
return shared.isArray(val) && val.length;
}
function toValidArray(val) {
return shared.isArray(val) ? val : isValidValue(val) ? [val] : [];
}
function treeFind(treeData, findCallback, getChildren, resultCallback, parent) {
for (let i = 0; i < treeData.length; i++) {
const data = treeData[i];
if (findCallback(data, i, treeData, parent)) {
return resultCallback ? resultCallback(data, i, treeData, parent) : data;
} else {
const children = getChildren(data);
if (isValidArray(children)) {
const find = treeFind(children, findCallback, getChildren, resultCallback, data);
if (find)
return find;
}
}
}
}
function treeEach(treeData, callback, getChildren, parent) {
for (let i = 0; i < treeData.length; i++) {
const data = treeData[i];
callback(data, i, treeData, parent);
const children = getChildren(data);
if (isValidArray(children)) {
treeEach(children, callback, getChildren, data);
}
}
}
exports.isValidArray = isValidArray;
exports.isValidValue = isValidValue;
exports.toValidArray = toValidArray;
exports.treeEach = treeEach;
exports.treeFind = treeFind;
//# sourceMappingURL=utils.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"utils.js","sources":["../../../../../../packages/components/tree-select/src/utils.ts"],"sourcesContent":["import { isArray } from '@element-plus/utils'\n\nimport type { TreeNodeData } from '@element-plus/components/tree/src/tree.type'\n\nexport function isValidValue(val: any) {\n return val || val === 0\n}\n\nexport function isValidArray(val: any) {\n return isArray(val) && val.length\n}\n\nexport function toValidArray(val: any) {\n return isArray(val) ? val : isValidValue(val) ? [val] : []\n}\n\ntype TreeCallback<T extends TreeNodeData, R> = (\n data: T,\n index: number,\n array: T[],\n parent?: T\n) => R\n\ntype TreeFindCallback<T extends TreeNodeData> = TreeCallback<T, boolean>\n\nexport function treeFind<T extends TreeNodeData>(\n treeData: T[],\n findCallback: TreeFindCallback<T>,\n getChildren: (data: T) => T[]\n): T | undefined\nexport function treeFind<T extends TreeNodeData, R>(\n treeData: T[],\n findCallback: TreeFindCallback<T>,\n getChildren: (data: T) => T[],\n resultCallback?: TreeCallback<T, R>,\n parent?: T\n): R | undefined\nexport function treeFind<T extends TreeNodeData, R>(\n treeData: T[],\n findCallback: TreeFindCallback<T>,\n getChildren: (data: T) => T[],\n resultCallback?: TreeCallback<T, R>,\n parent?: T\n): T | R | undefined {\n for (let i = 0; i < treeData.length; i++) {\n const data = treeData[i]\n if (findCallback(data, i, treeData, parent)) {\n return resultCallback ? resultCallback(data, i, treeData, parent) : data\n } else {\n const children = getChildren(data)\n if (isValidArray(children)) {\n const find = treeFind(\n children,\n findCallback,\n getChildren,\n resultCallback,\n data\n )\n if (find) return find\n }\n }\n }\n}\n\nexport function treeEach<T extends TreeNodeData>(\n treeData: T[],\n callback: TreeCallback<T, void>,\n getChildren: (data: T) => T[],\n parent?: T\n) {\n for (let i = 0; i < treeData.length; i++) {\n const data = treeData[i]\n callback(data, i, treeData, parent)\n\n const children = getChildren(data)\n if (isValidArray(children)) {\n treeEach(children, callback, getChildren, data)\n }\n }\n}\n"],"names":["isArray"],"mappings":";;;;;;AACO,SAAS,YAAY,CAAC,GAAG,EAAE;AAClC,EAAE,OAAO,GAAG,IAAI,GAAG,KAAK,CAAC,CAAC;AAC1B,CAAC;AACM,SAAS,YAAY,CAAC,GAAG,EAAE;AAClC,EAAE,OAAOA,cAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC;AACpC,CAAC;AACM,SAAS,YAAY,CAAC,GAAG,EAAE;AAClC,EAAE,OAAOA,cAAO,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;AAC7D,CAAC;AACM,SAAS,QAAQ,CAAC,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,EAAE;AACtF,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC5C,IAAI,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;AAC7B,IAAI,IAAI,YAAY,CAAC,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE;AACjD,MAAM,OAAO,cAAc,GAAG,cAAc,CAAC,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;AAC/E,KAAK,MAAM;AACX,MAAM,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;AACzC,MAAM,IAAI,YAAY,CAAC,QAAQ,CAAC,EAAE;AAClC,QAAQ,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC;AACzF,QAAQ,IAAI,IAAI;AAChB,UAAU,OAAO,IAAI,CAAC;AACtB,OAAO;AACP,KAAK;AACL,GAAG;AACH,CAAC;AACM,SAAS,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE;AAClE,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC5C,IAAI,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;AAC7B,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AACxC,IAAI,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;AACvC,IAAI,IAAI,YAAY,CAAC,QAAQ,CAAC,EAAE;AAChC,MAAM,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;AACtD,KAAK;AACL,GAAG;AACH;;;;;;;;"}