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,4 @@
import TreeSelect from './src/tree-select.vue';
import type { SFCWithInstall } from 'element-plus/es/utils';
export declare const ElTreeSelect: SFCWithInstall<typeof TreeSelect>;
export default ElTreeSelect;

View File

@@ -0,0 +1,7 @@
import TreeSelect from './src/tree-select.mjs';
import { withInstall } from '../../utils/vue/install.mjs';
const ElTreeSelect = withInstall(TreeSelect);
export { ElTreeSelect, ElTreeSelect as default };
//# sourceMappingURL=index.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../../../../../packages/components/tree-select/index.ts"],"sourcesContent":["import { withInstall } from '@element-plus/utils'\nimport TreeSelect from './src/tree-select.vue'\n\nimport type { SFCWithInstall } from '@element-plus/utils'\n\nexport const ElTreeSelect: SFCWithInstall<typeof TreeSelect> =\n withInstall(TreeSelect)\n\nexport default ElTreeSelect\n"],"names":[],"mappings":";;;AAEY,MAAC,YAAY,GAAG,WAAW,CAAC,UAAU;;;;"}

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,31 @@
import { defineComponent, inject, watch } from 'vue';
import { selectKey } from '../../select/src/token.mjs';
import { isClient } from '@vueuse/core';
var CacheOptions = defineComponent({
props: {
data: {
type: Array,
default: () => []
}
},
setup(props) {
const select = inject(selectKey);
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 (isClient && !Array.from(inputs).includes(document.activeElement)) {
select.setSelected();
}
}, { flush: "post", immediate: true });
return () => void 0;
}
});
export { CacheOptions as default };
//# sourceMappingURL=cache-options.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"cache-options.mjs","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":[],"mappings":";;;;AAGA,mBAAe,eAAe,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,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AACrC,IAAI,KAAK,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,IAAI,QAAQ,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,49 @@
import { watch, nextTick, toRefs, computed } from 'vue';
import { pick } from 'lodash-unified';
import { ElSelect } from '../../select/index.mjs';
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
import { UPDATE_MODEL_EVENT } from '../../../constants/event.mjs';
const useSelect = (props, { attrs, emit }, {
select,
tree,
key
}) => {
const ns = useNamespace("tree-select");
watch(() => props.data, () => {
if (props.filterable) {
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 = {
...pick(toRefs(props), Object.keys(ElSelect.props)),
...attrs,
class: computed(() => attrs.class),
style: computed(() => attrs.style),
"onUpdate:modelValue": (value) => emit(UPDATE_MODEL_EVENT, value),
valueKey: key,
popperClass: 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;
};
export { useSelect };
//# sourceMappingURL=select.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"select.mjs","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":[],"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,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC;AACzC,EAAE,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,EAAE,MAAM;AAChC,IAAI,IAAI,KAAK,CAAC,UAAU,EAAE;AAC1B,MAAM,QAAQ,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,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACvD,IAAI,GAAG,KAAK;AACZ,IAAI,KAAK,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC,KAAK,CAAC;AACtC,IAAI,KAAK,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC,KAAK,CAAC;AACtC,IAAI,qBAAqB,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,kBAAkB,EAAE,KAAK,CAAC;AACrE,IAAI,QAAQ,EAAE,GAAG;AACjB,IAAI,WAAW,EAAE,QAAQ,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,32 @@
import { defineComponent, getCurrentInstance, nextTick, watch } from 'vue';
import { ElOption } from '../../select/index.mjs';
const component = defineComponent({
extends: ElOption,
setup(props, ctx) {
const result = ElOption.setup(props, ctx);
delete result.selectOptionClick;
const vm = getCurrentInstance().proxy;
nextTick(() => {
if (!result.select.states.cachedOptions.get(vm.value)) {
result.select.onOptionCreate(vm);
}
});
watch(() => ctx.attrs.visible, (val) => {
nextTick(() => {
result.states.visible = val;
});
}, {
immediate: true
});
return result;
},
methods: {
selectOptionClick() {
this.$el.parentElement.click();
}
}
});
export { component as default };
//# sourceMappingURL=tree-select-option.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"tree-select-option.mjs","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":[],"mappings":";;;AAEK,MAAC,SAAS,GAAG,eAAe,CAAC;AAClC,EAAE,OAAO,EAAE,QAAQ;AACnB,EAAE,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE;AACpB,IAAI,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC9C,IAAI,OAAO,MAAM,CAAC,iBAAiB,CAAC;AACpC,IAAI,MAAM,EAAE,GAAG,kBAAkB,EAAE,CAAC,KAAK,CAAC;AAC1C,IAAI,QAAQ,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,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,GAAG,KAAK;AAC5C,MAAM,QAAQ,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,79 @@
import { defineComponent, ref, computed, reactive, onMounted, h } from 'vue';
import { pick } from 'lodash-unified';
import { ElSelect } from '../../select/index.mjs';
import { ElTree } from '../../tree/index.mjs';
import { useSelect } from './select.mjs';
import { useTree } from './tree.mjs';
import CacheOptions from './cache-options.mjs';
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
const _sfc_main = defineComponent({
name: "ElTreeSelect",
inheritAttrs: false,
props: {
...ElSelect.props,
...ElTree.props,
cacheData: {
type: Array,
default: () => []
}
},
setup(props, context) {
const { slots, expose } = context;
const select = ref();
const tree = ref();
const key = computed(() => props.nodeKey || props.valueKey || "value");
const selectProps = useSelect(props, context, { select, tree, key });
const { cacheOptions, ...treeProps } = useTree(props, context, {
select,
tree,
key
});
const methods = reactive({});
expose(methods);
onMounted(() => {
Object.assign(methods, {
...pick(tree.value, [
"filter",
"updateKeyChildren",
"getCheckedNodes",
"setCheckedNodes",
"getCheckedKeys",
"setCheckedKeys",
"setChecked",
"getHalfCheckedNodes",
"getHalfCheckedKeys",
"getCurrentKey",
"getCurrentNode",
"setCurrentKey",
"setCurrentNode",
"getNode",
"remove",
"append",
"insertBefore",
"insertAfter"
]),
...pick(select.value, ["focus", "blur", "selectedLabel"]),
treeRef: tree.value,
selectRef: select.value
});
});
return () => h(ElSelect, reactive({
...selectProps,
ref: (ref2) => select.value = ref2
}), {
...slots,
default: () => [
h(CacheOptions, { data: cacheOptions.value }),
h(ElTree, reactive({
...treeProps,
ref: (ref2) => tree.value = ref2
}))
]
});
}
});
var TreeSelect = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "tree-select.vue"]]);
export { TreeSelect as default };
//# sourceMappingURL=tree-select.mjs.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,167 @@
import { toRefs, computed, nextTick, watch } from 'vue';
import { pick, isEqual, isNil } from 'lodash-unified';
import { ElTree } from '../../tree/index.mjs';
import component from './tree-select-option.mjs';
import { treeEach, toValidArray, treeFind, isValidValue, isValidArray } from './utils.mjs';
import { escapeStringRegexp } from '../../../utils/strings.mjs';
import { UPDATE_MODEL_EVENT } from '../../../constants/event.mjs';
import { isFunction } from '@vue/shared';
import { isEmpty } from '../../../utils/types.mjs';
const useTree = (props, { attrs, slots, emit }, {
select,
tree,
key
}) => {
watch([() => props.modelValue, tree], () => {
if (props.showCheckbox) {
nextTick(() => {
const treeInstance = tree.value;
if (treeInstance && !isEqual(treeInstance.getCheckedKeys(), toValidArray(props.modelValue))) {
treeInstance.setCheckedKeys(toValidArray(props.modelValue));
}
});
}
}, {
immediate: true,
deep: true
});
const propsMap = 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 (isFunction(propVal)) {
return propVal(data, (_a = tree.value) == null ? void 0 : _a.getNode(getNodeValByProp("value", data)));
} else {
return data[propVal];
}
};
const defaultExpandedParentKeys = toValidArray(props.modelValue).map((value) => {
return treeFind(props.data || [], (data) => getNodeValByProp("value", data) === value, (data) => getNodeValByProp("children", data), (data, index, array, parent) => parent && getNodeValByProp("value", parent));
}).filter((item) => isValidValue(item));
const cacheOptions = computed(() => {
if (!props.renderAfterExpand && !props.lazy)
return [];
const options = [];
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 !isNil(node) && isEmpty(node.childNodes);
});
};
return {
...pick(toRefs(props), Object.keys(ElTree.props)),
...attrs,
nodeKey: key,
expandOnClickNode: computed(() => {
return !props.checkStrictly && props.expandOnClickNode;
}),
defaultExpandedKeys: computed(() => {
return props.defaultExpandedKeys ? props.defaultExpandedKeys.concat(defaultExpandedParentKeys) : defaultExpandedParentKeys;
}),
renderContent: (h, { node, data, store }) => {
return h(component, {
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(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 = {};
treeEach([tree.value.store.root], (node) => dataMap[node.key] = node, (node) => node.childNodes);
const uncachedCheckedKeys = params.checkedKeys;
const cachedKeys = props.multiple ? toValidArray(props.modelValue).filter((item) => !(item in dataMap) && !uncachedCheckedKeys.includes(item)) : [];
const checkedKeys = cachedKeys.concat(uncachedCheckedKeys);
if (props.checkStrictly) {
emit(UPDATE_MODEL_EVENT, props.multiple ? checkedKeys : checkedKeys.includes(dataValue) ? dataValue : void 0);
} else {
if (props.multiple) {
const childKeys = getChildCheckedKeys();
emit(UPDATE_MODEL_EVENT, cachedKeys.concat(childKeys));
} else {
const firstLeaf = treeFind([data], (data2) => !isValidArray(getNodeValByProp("children", data2)) && !getNodeValByProp("disabled", data2), (data2) => getNodeValByProp("children", data2));
const firstLeafKey = firstLeaf ? getNodeValByProp("value", firstLeaf) : void 0;
const hasCheckedChild = isValidValue(props.modelValue) && !!treeFind([data], (data2) => getNodeValByProp("value", data2) === props.modelValue, (data2) => getNodeValByProp("children", data2));
emit(UPDATE_MODEL_EVENT, firstLeafKey === props.modelValue || hasCheckedChild ? void 0 : firstLeafKey);
}
}
nextTick(() => {
var _a2;
const checkedKeys2 = 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);
nextTick(() => {
if (!props.checkStrictly && props.lazy && props.multiple && node.checked) {
const dataMap = {};
const uncachedCheckedKeys = tree.value.getCheckedKeys();
treeEach([tree.value.store.root], (node2) => dataMap[node2.key] = node2, (node2) => node2.childNodes);
const cachedKeys = toValidArray(props.modelValue).filter((item) => !(item in dataMap) && !uncachedCheckedKeys.includes(item));
const childKeys = getChildCheckedKeys();
emit(UPDATE_MODEL_EVENT, cachedKeys.concat(childKeys));
}
});
},
cacheOptions
};
};
export { useTree };
//# sourceMappingURL=tree.mjs.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,39 @@
import { isArray } from '@vue/shared';
function isValidValue(val) {
return val || val === 0;
}
function isValidArray(val) {
return isArray(val) && val.length;
}
function toValidArray(val) {
return 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);
}
}
}
export { isValidArray, isValidValue, toValidArray, treeEach, treeFind };
//# sourceMappingURL=utils.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"utils.mjs","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":[],"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,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC;AACpC,CAAC;AACM,SAAS,YAAY,CAAC,GAAG,EAAE;AAClC,EAAE,OAAO,OAAO,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;;;;"}

View File

@@ -0,0 +1,3 @@
import 'element-plus/es/components/select/style/css';
import 'element-plus/es/components/tree/style/css';
import 'element-plus/theme-chalk/el-tree-select.css';

View File

@@ -0,0 +1,4 @@
import '../../select/style/css.mjs';
import '../../tree/style/css.mjs';
import 'element-plus/theme-chalk/el-tree-select.css';
//# sourceMappingURL=css.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"css.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}

View File

@@ -0,0 +1,3 @@
import 'element-plus/es/components/select/style';
import 'element-plus/es/components/tree/style';
import 'element-plus/theme-chalk/src/tree-select.scss';

View File

@@ -0,0 +1,4 @@
import '../../select/style/index.mjs';
import '../../tree/style/index.mjs';
import 'element-plus/theme-chalk/src/tree-select.scss';
//# sourceMappingURL=index.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}