完全跑通1.0版本

This commit is contained in:
2026-05-26 12:56:03 +08:00
parent 2ece5174a7
commit 93c714a93b
11557 changed files with 1648225 additions and 36 deletions

View File

@@ -0,0 +1,12 @@
import { SFCWithInstall } from "../../utils/vue/typescript.js";
import { Nullable } from "../../utils/typescript.js";
import { CASCADER_PANEL_INJECTION_KEY, CascaderConfig, CascaderNodePathValue, CascaderNodeValue, CascaderOption, CascaderProps, CascaderValue, ElCascaderPanelContext, ExpandTrigger, LazyLoad, RenderLabel, RenderLabelProps, Resolve, Tag, isDisabled, isLeaf } from "./src/types.js";
import Node from "./src/node.js";
import { CASCADER_PANEL_HEIGHT, CASCADER_PANEL_ITEM_SIZE, CascaderCommonProps, CascaderPanelProps, CommonProps, DefaultProps, cascaderPanelEmits, cascaderPanelProps, useCascaderConfig } from "./src/config.js";
import { CascaderMenuInstance, CascaderPanelInstance } from "./src/instance.js";
import _default from "./src/index.vue.js";
//#region ../../packages/components/cascader-panel/index.d.ts
declare const ElCascaderPanel: SFCWithInstall<typeof _default>;
//#endregion
export { CASCADER_PANEL_HEIGHT, CASCADER_PANEL_INJECTION_KEY, CASCADER_PANEL_ITEM_SIZE, CascaderCommonProps, CascaderConfig, CascaderMenuInstance, Node as CascaderNode, CascaderNodePathValue, CascaderNodeValue, CascaderOption, CascaderPanelInstance, CascaderPanelProps, CascaderProps, CascaderValue, CommonProps, DefaultProps, ElCascaderPanel, ElCascaderPanel as default, ElCascaderPanelContext, ExpandTrigger, LazyLoad, Nullable, RenderLabel, RenderLabelProps, Resolve, Tag, cascaderPanelEmits, cascaderPanelProps, isDisabled, isLeaf, useCascaderConfig };

View File

@@ -0,0 +1,23 @@
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
const require_install = require("../../utils/vue/install.js");
const require_config = require("./src/config.js");
const require_types = require("./src/types.js");
const require_index = require("./src/index.js");
//#region ../../packages/components/cascader-panel/index.ts
const ElCascaderPanel = require_install.withInstall(require_index.default);
//#endregion
exports.CASCADER_PANEL_HEIGHT = require_config.CASCADER_PANEL_HEIGHT;
exports.CASCADER_PANEL_INJECTION_KEY = require_types.CASCADER_PANEL_INJECTION_KEY;
exports.CASCADER_PANEL_ITEM_SIZE = require_config.CASCADER_PANEL_ITEM_SIZE;
exports.CommonProps = require_config.CommonProps;
exports.DefaultProps = require_config.DefaultProps;
exports.ElCascaderPanel = ElCascaderPanel;
exports.default = ElCascaderPanel;
exports.cascaderPanelEmits = require_config.cascaderPanelEmits;
exports.cascaderPanelProps = require_config.cascaderPanelProps;
exports.useCascaderConfig = require_config.useCascaderConfig;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","names":["withInstall","CascaderPanel"],"sources":["../../../../../packages/components/cascader-panel/index.ts"],"sourcesContent":["import { withInstall } from '@element-plus/utils'\nimport CascaderPanel from './src/index.vue'\n\nimport type { SFCWithInstall } from '@element-plus/utils'\n\nexport const ElCascaderPanel: SFCWithInstall<typeof CascaderPanel> =\n withInstall(CascaderPanel)\n\nexport default ElCascaderPanel\nexport * from './src/types'\nexport * from './src/config'\nexport * from './src/instance'\n"],"mappings":";;;;;;;;;AAKA,MAAa,kBACXA,gBAAAA,YAAYC,cAAAA,QAAc"}

View File

@@ -0,0 +1,108 @@
import { EpPropFinalized, EpPropMergeType } from "../../../utils/vue/props/types.js";
import { CascaderConfig, CascaderNodePathValue, CascaderNodeValue, CascaderOption, CascaderProps, CascaderValue, ExpandTrigger, LazyLoad, RenderLabel, isDisabled, isLeaf } from "./types.js";
import * as _$vue from "vue";
import { PropType } from "vue";
//#region ../../packages/components/cascader-panel/src/config.d.ts
interface CascaderCommonProps {
/**
* @description specify which key of node object is used as the node's value
*/
modelValue?: CascaderValue | null;
/**
* @description data of the options, the key of `value` and `label` can be customize by `CascaderProps`.
*/
options?: CascaderOption[];
/**
* @description configuration options, see the following `CascaderProps` table.
*/
props?: CascaderProps;
/**
* @description whether to enable virtual scrolling
*/
virtualScroll?: boolean;
/**
* @description node height for virtual scrolling
*/
itemSize?: number;
/**
* @description menu height for virtual scrolling
*/
height?: number;
}
/**
* @description node height for virtual scrolling
*/
declare const CASCADER_PANEL_ITEM_SIZE = 34;
/**
* @description menu height for virtual scrolling
*/
declare const CASCADER_PANEL_HEIGHT = 204;
declare const CommonProps: {
readonly modelValue: {
readonly type: PropType<EpPropMergeType<(new (...args: any[]) => string | number | Record<string, any> | CascaderNodePathValue | (CascaderNodeValue | CascaderNodePathValue)[]) | (() => CascaderValue | null) | (((new (...args: any[]) => string | number | Record<string, any> | CascaderNodePathValue | (CascaderNodeValue | CascaderNodePathValue)[]) | (() => CascaderValue | null)) | null)[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly options: EpPropFinalized<(new (...args: any[]) => CascaderOption[]) | (() => CascaderOption[]) | (((new (...args: any[]) => CascaderOption[]) | (() => CascaderOption[])) | null)[], unknown, unknown, () => CascaderOption[], boolean>;
readonly props: EpPropFinalized<(new (...args: any[]) => CascaderProps) | (() => CascaderProps) | (((new (...args: any[]) => CascaderProps) | (() => CascaderProps)) | null)[], unknown, unknown, () => CascaderProps, boolean>;
readonly virtualScroll: BooleanConstructor;
readonly itemSize: EpPropFinalized<NumberConstructor, unknown, unknown, 34, boolean>;
readonly height: EpPropFinalized<NumberConstructor, unknown, unknown, 204, boolean>;
};
interface CascaderPanelProps extends CascaderCommonProps {
border?: boolean;
renderLabel?: RenderLabel;
}
declare const DefaultProps: CascaderConfig;
/**
* @deprecated Removed after 3.0.0, Use `CascaderPanelProps` instead.
*/
declare const cascaderPanelProps: {
border: EpPropFinalized<BooleanConstructor, unknown, unknown, boolean, boolean>;
renderLabel: {
readonly type: PropType<RenderLabel>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
modelValue: {
readonly type: PropType<EpPropMergeType<(new (...args: any[]) => string | number | Record<string, any> | CascaderNodePathValue | (CascaderNodeValue | CascaderNodePathValue)[]) | (() => CascaderValue | null) | (((new (...args: any[]) => string | number | Record<string, any> | CascaderNodePathValue | (CascaderNodeValue | CascaderNodePathValue)[]) | (() => CascaderValue | null)) | null)[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
options: EpPropFinalized<(new (...args: any[]) => CascaderOption[]) | (() => CascaderOption[]) | (((new (...args: any[]) => CascaderOption[]) | (() => CascaderOption[])) | null)[], unknown, unknown, () => CascaderOption[], boolean>;
props: EpPropFinalized<(new (...args: any[]) => CascaderProps) | (() => CascaderProps) | (((new (...args: any[]) => CascaderProps) | (() => CascaderProps)) | null)[], unknown, unknown, () => CascaderProps, boolean>;
virtualScroll: BooleanConstructor;
itemSize: EpPropFinalized<NumberConstructor, unknown, unknown, 34, boolean>;
height: EpPropFinalized<NumberConstructor, unknown, unknown, 204, boolean>;
};
declare const cascaderPanelEmits: {
"update:modelValue": (value: CascaderValue | undefined | null) => boolean;
change: (value: CascaderValue | undefined | null) => boolean;
close: () => boolean;
'expand-change': (value: CascaderNodePathValue) => CascaderNodePathValue;
};
declare const useCascaderConfig: (props: {
props: CascaderProps;
}) => _$vue.ComputedRef<{
expandTrigger: ExpandTrigger;
multiple: boolean;
checkStrictly: boolean;
emitPath: boolean;
lazy: boolean;
lazyLoad: LazyLoad;
value: string;
label: string;
children: string;
disabled: string | isDisabled;
leaf: string | isLeaf;
hoverThreshold: number;
checkOnClickNode: boolean;
checkOnClickLeaf: boolean;
showPrefix: boolean;
}>;
//#endregion
export { CASCADER_PANEL_HEIGHT, CASCADER_PANEL_ITEM_SIZE, CascaderCommonProps, CascaderPanelProps, CommonProps, DefaultProps, cascaderPanelEmits, cascaderPanelProps, useCascaderConfig };

View File

@@ -0,0 +1,154 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
require("../../../_virtual/_rolldown/runtime.js");
const require_event = require("../../../constants/event.js");
const require_runtime$1 = require("../../../utils/vue/props/runtime.js");
let vue = require("vue");
let _vue_shared = require("@vue/shared");
//#region ../../packages/components/cascader-panel/src/config.ts
/**
* @description node height for virtual scrolling
*/
const CASCADER_PANEL_ITEM_SIZE = 34;
/**
* @description menu height for virtual scrolling
*/
const CASCADER_PANEL_HEIGHT = 204;
const CommonProps = require_runtime$1.buildProps({
/**
* @description specify which key of node object is used as the node's value
*/
modelValue: { type: require_runtime$1.definePropType([
Number,
String,
Array,
Object
]) },
/**
* @description data of the options, the key of `value` and `label` can be customize by `CascaderProps`.
*/
options: {
type: require_runtime$1.definePropType(Array),
default: () => []
},
/**
* @description configuration options, see the following `CascaderProps` table.
*/
props: {
type: require_runtime$1.definePropType(Object),
default: () => ({})
},
/**
* @description whether to enable virtual scrolling
*/
virtualScroll: Boolean,
/**
* @description node height for virtual scrolling
*/
itemSize: {
type: Number,
default: 34
},
/**
* @description menu height for virtual scrolling
*/
height: {
type: Number,
default: 204
}
});
const DefaultProps = {
/**
* @description trigger mode of expanding options
*/
expandTrigger: "click",
/**
* @description whether multiple selection is enabled
*/
multiple: false,
/**
* @description whether checked state of a node not affects its parent and child nodes
*/
checkStrictly: false,
/**
* @description when checked nodes change, whether to emit an array of node's path, if false, only emit the value of node.
*/
emitPath: true,
/**
* @description whether to dynamic load child nodes, use with `lazyload` attribute
*/
lazy: false,
/**
* @description method for loading child nodes data, only works when `lazy` is true
*/
lazyLoad: _vue_shared.NOOP,
/**
* @description specify which key of node object is used as the node's value
*/
value: "value",
/**
* @description specify which key of node object is used as the node's label
*/
label: "label",
/**
* @description specify which key of node object is used as the node's children
*/
children: "children",
/**
* @description specify which key of node object is used as the node's leaf
*/
leaf: "leaf",
/**
* @description specify which key of node object is used as the node's disabled
*/
disabled: "disabled",
/**
* @description hover threshold of expanding options
*/
hoverThreshold: 500,
/**
* @description whether to check or uncheck node when clicking on the node
*/
checkOnClickNode: false,
/**
* @description whether to check or uncheck node when clicking on leaf node (last children).
*/
checkOnClickLeaf: true,
/**
* @description whether to show the radio or checkbox prefix
*/
showPrefix: true
};
/**
* @deprecated Removed after 3.0.0, Use `CascaderPanelProps` instead.
*/
const cascaderPanelProps = require_runtime$1.buildProps({
...CommonProps,
border: {
type: Boolean,
default: true
},
renderLabel: { type: Function }
});
const emitChangeFn = (value) => true;
const cascaderPanelEmits = {
[require_event.UPDATE_MODEL_EVENT]: emitChangeFn,
[require_event.CHANGE_EVENT]: emitChangeFn,
close: () => true,
"expand-change": (value) => value
};
const useCascaderConfig = (props) => {
return (0, vue.computed)(() => ({
...DefaultProps,
...props.props
}));
};
//#endregion
exports.CASCADER_PANEL_HEIGHT = CASCADER_PANEL_HEIGHT;
exports.CASCADER_PANEL_ITEM_SIZE = CASCADER_PANEL_ITEM_SIZE;
exports.CommonProps = CommonProps;
exports.DefaultProps = DefaultProps;
exports.cascaderPanelEmits = cascaderPanelEmits;
exports.cascaderPanelProps = cascaderPanelProps;
exports.useCascaderConfig = useCascaderConfig;
//# sourceMappingURL=config.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
//#region ../../packages/components/cascader-panel/src/index.vue
var src_default = require("./index.vue_vue_type_script_setup_true_lang.js").default;
//#endregion
exports.default = src_default;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,295 @@
import { CascaderNodePathValue, CascaderNodeValue, CascaderOption, CascaderProps, CascaderValue, ExpandTrigger, LazyLoad, isDisabled, isLeaf } from "./types.js";
import Node from "./node.js";
import { CascaderPanelProps } from "./config.js";
import { CascaderMenuInstance } from "./instance.js";
import * as _$vue from "vue";
//#region ../../packages/components/cascader-panel/src/index.vue.d.ts
declare var __VLS_8: {};
type __VLS_Slots = {} & {
empty?: (props: typeof __VLS_8) => any;
};
declare const __VLS_base: _$vue.DefineComponent<CascaderPanelProps, {
menuList: _$vue.Ref<CascaderMenuInstance[], CascaderMenuInstance[]>;
menus: _$vue.Ref<{
readonly uid: number;
readonly level: number;
readonly value: CascaderNodeValue;
readonly label: string;
readonly pathNodes: /*elided*/any[];
readonly pathValues: CascaderNodeValue[];
readonly pathLabels: string[];
childrenData: {
[x: string]: unknown;
label?: string | undefined;
value?: CascaderNodeValue | undefined;
children?: /*elided*/any[] | undefined;
disabled?: boolean | undefined;
leaf?: boolean | undefined;
}[] | undefined;
children: /*elided*/any[];
text: string;
loaded: boolean;
checked: boolean;
indeterminate: boolean;
loading: boolean;
readonly data: {
[x: string]: unknown;
label?: string | undefined;
value?: CascaderNodeValue | undefined;
children?: /*elided*/any[] | undefined;
disabled?: boolean | undefined;
leaf?: boolean | undefined;
};
readonly config: {
expandTrigger: ExpandTrigger;
multiple: boolean;
checkStrictly: boolean;
emitPath: boolean;
lazy: boolean;
lazyLoad: LazyLoad;
value: string;
label: string;
children: string;
disabled: string | isDisabled;
leaf: string | isLeaf;
hoverThreshold: number;
checkOnClickNode: boolean;
checkOnClickLeaf: boolean;
showPrefix: boolean;
};
readonly parent?: /*elided*/any | undefined;
readonly root: boolean;
readonly isDisabled: boolean;
readonly isLeaf: boolean;
readonly valueByOption: CascaderNodeValue | CascaderNodeValue[];
appendChild: (childData: CascaderOption) => Node;
calcText: (allLevels: boolean, separator: string) => string;
broadcast: (checked: boolean) => void;
emit: () => void;
onParentCheck: (checked: boolean) => void;
onChildCheck: () => void;
setCheckState: (checked: boolean) => void;
doCheck: (checked: boolean) => void;
}[][], Node[][] | {
readonly uid: number;
readonly level: number;
readonly value: CascaderNodeValue;
readonly label: string;
readonly pathNodes: /*elided*/any[];
readonly pathValues: CascaderNodeValue[];
readonly pathLabels: string[];
childrenData: {
[x: string]: unknown;
label?: string | undefined;
value?: CascaderNodeValue | undefined;
children?: /*elided*/any[] | undefined;
disabled?: boolean | undefined;
leaf?: boolean | undefined;
}[] | undefined;
children: /*elided*/any[];
text: string;
loaded: boolean;
checked: boolean;
indeterminate: boolean;
loading: boolean;
readonly data: {
[x: string]: unknown;
label?: string | undefined;
value?: CascaderNodeValue | undefined;
children?: /*elided*/any[] | undefined;
disabled?: boolean | undefined;
leaf?: boolean | undefined;
};
readonly config: {
expandTrigger: ExpandTrigger;
multiple: boolean;
checkStrictly: boolean;
emitPath: boolean;
lazy: boolean;
lazyLoad: LazyLoad;
value: string;
label: string;
children: string;
disabled: string | isDisabled;
leaf: string | isLeaf;
hoverThreshold: number;
checkOnClickNode: boolean;
checkOnClickLeaf: boolean;
showPrefix: boolean;
};
readonly parent?: /*elided*/any | undefined;
readonly root: boolean;
readonly isDisabled: boolean;
readonly isLeaf: boolean;
readonly valueByOption: CascaderNodeValue | CascaderNodeValue[];
appendChild: (childData: CascaderOption) => Node;
calcText: (allLevels: boolean, separator: string) => string;
broadcast: (checked: boolean) => void;
emit: () => void;
onParentCheck: (checked: boolean) => void;
onChildCheck: () => void;
setCheckState: (checked: boolean) => void;
doCheck: (checked: boolean) => void;
}[][]>;
checkedNodes: _$vue.Ref<{
readonly uid: number;
readonly level: number;
readonly value: CascaderNodeValue;
readonly label: string;
readonly pathNodes: /*elided*/any[];
readonly pathValues: CascaderNodeValue[];
readonly pathLabels: string[];
childrenData: {
[x: string]: unknown;
label?: string | undefined;
value?: CascaderNodeValue | undefined;
children?: /*elided*/any[] | undefined;
disabled?: boolean | undefined;
leaf?: boolean | undefined;
}[] | undefined;
children: /*elided*/any[];
text: string;
loaded: boolean;
checked: boolean;
indeterminate: boolean;
loading: boolean;
readonly data: {
[x: string]: unknown;
label?: string | undefined;
value?: CascaderNodeValue | undefined;
children?: /*elided*/any[] | undefined;
disabled?: boolean | undefined;
leaf?: boolean | undefined;
};
readonly config: {
expandTrigger: ExpandTrigger;
multiple: boolean;
checkStrictly: boolean;
emitPath: boolean;
lazy: boolean;
lazyLoad: LazyLoad;
value: string;
label: string;
children: string;
disabled: string | isDisabled;
leaf: string | isLeaf;
hoverThreshold: number;
checkOnClickNode: boolean;
checkOnClickLeaf: boolean;
showPrefix: boolean;
};
readonly parent?: /*elided*/any | undefined;
readonly root: boolean;
readonly isDisabled: boolean;
readonly isLeaf: boolean;
readonly valueByOption: CascaderNodeValue | CascaderNodeValue[];
appendChild: (childData: CascaderOption) => Node;
calcText: (allLevels: boolean, separator: string) => string;
broadcast: (checked: boolean) => void;
emit: () => void;
onParentCheck: (checked: boolean) => void;
onChildCheck: () => void;
setCheckState: (checked: boolean) => void;
doCheck: (checked: boolean) => void;
}[], Node[] | {
readonly uid: number;
readonly level: number;
readonly value: CascaderNodeValue;
readonly label: string;
readonly pathNodes: /*elided*/any[];
readonly pathValues: CascaderNodeValue[];
readonly pathLabels: string[];
childrenData: {
[x: string]: unknown;
label?: string | undefined;
value?: CascaderNodeValue | undefined;
children?: /*elided*/any[] | undefined;
disabled?: boolean | undefined;
leaf?: boolean | undefined;
}[] | undefined;
children: /*elided*/any[];
text: string;
loaded: boolean;
checked: boolean;
indeterminate: boolean;
loading: boolean;
readonly data: {
[x: string]: unknown;
label?: string | undefined;
value?: CascaderNodeValue | undefined;
children?: /*elided*/any[] | undefined;
disabled?: boolean | undefined;
leaf?: boolean | undefined;
};
readonly config: {
expandTrigger: ExpandTrigger;
multiple: boolean;
checkStrictly: boolean;
emitPath: boolean;
lazy: boolean;
lazyLoad: LazyLoad;
value: string;
label: string;
children: string;
disabled: string | isDisabled;
leaf: string | isLeaf;
hoverThreshold: number;
checkOnClickNode: boolean;
checkOnClickLeaf: boolean;
showPrefix: boolean;
};
readonly parent?: /*elided*/any | undefined;
readonly root: boolean;
readonly isDisabled: boolean;
readonly isLeaf: boolean;
readonly valueByOption: CascaderNodeValue | CascaderNodeValue[];
appendChild: (childData: CascaderOption) => Node;
calcText: (allLevels: boolean, separator: string) => string;
broadcast: (checked: boolean) => void;
emit: () => void;
onParentCheck: (checked: boolean) => void;
onChildCheck: () => void;
setCheckState: (checked: boolean) => void;
doCheck: (checked: boolean) => void;
}[]>;
handleKeyDown: (e: KeyboardEvent) => void;
handleCheckChange: (node: Node, checked: boolean, emitClose?: boolean) => void;
getFlattedNodes: (leafOnly: boolean) => Node[];
/**
* @description get an array of currently selected node,(leafOnly) whether only return the leaf checked nodes, default is `false`
*/
getCheckedNodes: (leafOnly: boolean) => Node[];
/**
* @description clear checked nodes
*/
clearCheckedNodes: () => void;
calculateCheckedValue: () => void;
scrollToExpandingNode: () => void;
loadLazyRootNodes: () => void;
}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {
close: () => void;
change: (value: CascaderValue | null | undefined) => void;
"update:modelValue": (value: CascaderValue | null | undefined) => void;
"expand-change": (value: CascaderNodePathValue) => void;
}, string, _$vue.PublicProps, Readonly<CascaderPanelProps> & Readonly<{
onClose?: (() => any) | undefined;
"onUpdate:modelValue"?: ((value: CascaderValue | null | undefined) => any) | undefined;
onChange?: ((value: CascaderValue | null | undefined) => any) | undefined;
"onExpand-change"?: ((value: CascaderNodePathValue) => any) | undefined;
}>, {
props: CascaderProps;
height: number;
border: boolean;
options: CascaderOption[];
itemSize: number;
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
declare const _default: typeof __VLS_export;
type __VLS_WithSlots<T, S> = T & {
new (): {
$slots: S;
};
};
//#endregion
export { _default as default };

View File

@@ -0,0 +1,314 @@
require("../../../_virtual/_rolldown/runtime.js");
const require_aria = require("../../../utils/dom/aria.js");
const require_aria$1 = require("../../../constants/aria.js");
const require_event = require("../../../constants/event.js");
const require_event$1 = require("../../../utils/dom/event.js");
const require_types = require("../../../utils/types.js");
const require_scroll = require("../../../utils/dom/scroll.js");
const require_arrays = require("../../../utils/arrays.js");
const require_index = require("../../../hooks/use-namespace/index.js");
const require_config = require("./config.js");
const require_types$1 = require("./types.js");
const require_menu = require("./menu.js");
const require_node = require("./node.js");
const require_store = require("./store.js");
const require_utils = require("./utils.js");
let lodash_unified = require("lodash-unified");
let vue = require("vue");
let _vueuse_core = require("@vueuse/core");
//#region ../../packages/components/cascader-panel/src/index.vue?vue&type=script&setup=true&lang.ts
var index_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.defineComponent)({
name: "ElCascaderPanel",
__name: "index",
props: require_config.cascaderPanelProps,
emits: require_config.cascaderPanelEmits,
setup(__props, { expose: __expose, emit: __emit }) {
const props = __props;
const emit = __emit;
let manualChecked = false;
const ns = require_index.useNamespace("cascader");
const config = require_config.useCascaderConfig(props);
const slots = (0, vue.useSlots)();
let store;
const initialLoaded = (0, vue.ref)(true);
const initialLoadedOnce = (0, vue.ref)(false);
const menuList = (0, vue.ref)([]);
const checkedValue = (0, vue.ref)();
const menus = (0, vue.ref)([]);
const expandingNode = (0, vue.ref)();
const checkedNodes = (0, vue.ref)([]);
const isHoverMenu = (0, vue.computed)(() => config.value.expandTrigger === "hover");
const renderLabelFn = (0, vue.computed)(() => props.renderLabel || slots.default);
const virtualScroll = (0, vue.computed)(() => props.virtualScroll);
const itemSize = (0, vue.computed)(() => props.itemSize);
const height = (0, vue.computed)(() => props.height);
const initStore = () => {
const { options } = props;
const cfg = config.value;
manualChecked = false;
store = new require_store.default(options, cfg);
menus.value = [store.getNodes()];
if (cfg.lazy && require_types.isEmpty(props.options)) {
initialLoaded.value = false;
lazyLoad(void 0, (list) => {
if (list) {
store = new require_store.default(list, cfg);
menus.value = [store.getNodes()];
}
initialLoaded.value = true;
syncCheckedValue(false, true);
});
} else syncCheckedValue(false, true);
};
const lazyLoad = (node, cb) => {
const cfg = config.value;
node = node || new require_node.default({}, cfg, void 0, true);
node.loading = true;
const resolve = (dataList) => {
const _node = node;
const parent = _node.root ? null : _node;
_node.loading = false;
_node.loaded = true;
_node.childrenData = _node.childrenData || [];
dataList && store?.appendNodes(dataList, parent);
dataList && cb?.(dataList);
if (node.level === 0) initialLoadedOnce.value = true;
};
const reject = () => {
node.loading = false;
node.loaded = false;
if (node.level === 0) initialLoaded.value = true;
};
cfg.lazyLoad(node, resolve, reject);
};
const expandNode = (node, silent) => {
const { level } = node;
const newMenus = menus.value.slice(0, level);
let newExpandingNode;
if (node.isLeaf) newExpandingNode = node.pathNodes[level - 2];
else {
newExpandingNode = node;
newMenus.push(node.children);
}
if (expandingNode.value?.uid !== newExpandingNode?.uid) {
expandingNode.value = node;
menus.value = newMenus;
!silent && emit("expand-change", node?.pathValues || []);
}
};
const handleCheckChange = (node, checked, emitClose = true) => {
const { checkStrictly, multiple } = config.value;
const oldNode = checkedNodes.value[0];
manualChecked = true;
!multiple && oldNode?.doCheck(false);
node.doCheck(checked);
calculateCheckedValue();
emitClose && !multiple && !checkStrictly && emit("close");
!emitClose && !multiple && expandParentNode(node);
};
const expandParentNode = (node) => {
if (!node) return;
node = node.parent;
expandParentNode(node);
node && expandNode(node);
};
const getFlattedNodes = (leafOnly) => store?.getFlattedNodes(leafOnly);
const getCheckedNodes = (leafOnly) => {
return getFlattedNodes(leafOnly)?.filter(({ checked }) => checked !== false);
};
const clearCheckedNodes = () => {
checkedNodes.value.forEach((node) => node.doCheck(false));
calculateCheckedValue();
menus.value = menus.value.slice(0, 1);
expandingNode.value = void 0;
emit("expand-change", []);
};
const calculateCheckedValue = () => {
const { checkStrictly, multiple } = config.value;
const oldNodes = checkedNodes.value;
const nodes = require_utils.sortByOriginalOrder(oldNodes, getCheckedNodes(!checkStrictly));
const values = nodes.map((node) => node.valueByOption);
checkedNodes.value = nodes;
checkedValue.value = multiple ? values : values[0] ?? null;
};
const syncCheckedValue = (loaded = false, forced = false) => {
const { modelValue } = props;
const { lazy, multiple, checkStrictly } = config.value;
const leafOnly = !checkStrictly;
if (!initialLoaded.value || manualChecked || !forced && (0, lodash_unified.isEqual)(modelValue, checkedValue.value)) return;
if (lazy && !loaded) {
const nodes = require_arrays.unique((0, lodash_unified.flattenDeep)(require_arrays.castArray(modelValue))).map((val) => store?.getNodeByValue(val)).filter((node) => !!node && !node.loaded && !node.loading);
if (nodes.length) nodes.forEach((node) => {
lazyLoad(node, () => syncCheckedValue(false, forced));
});
else syncCheckedValue(true, forced);
} else {
syncMenuState(require_arrays.unique((multiple ? require_arrays.castArray(modelValue) : [modelValue]).map((val) => store?.getNodeByValue(val, leafOnly))), forced);
checkedValue.value = (0, lodash_unified.cloneDeep)(modelValue ?? void 0);
}
};
const syncMenuState = (newCheckedNodes, reserveExpandingState = true) => {
const { checkStrictly } = config.value;
const oldNodes = checkedNodes.value;
const newNodes = newCheckedNodes.filter((node) => !!node && (checkStrictly || node.isLeaf));
const oldExpandingNode = store?.getSameNode(expandingNode.value);
const newExpandingNode = reserveExpandingState && oldExpandingNode || newNodes[0];
if (newExpandingNode) newExpandingNode.pathNodes.forEach((node) => expandNode(node, true));
else expandingNode.value = void 0;
oldNodes.forEach((node) => node.doCheck(false));
(0, vue.reactive)(newNodes).forEach((node) => node.doCheck(true));
checkedNodes.value = newNodes;
(0, vue.nextTick)(scrollToExpandingNode);
};
const scrollToExpandingNode = () => {
if (!_vueuse_core.isClient) return;
menuList.value.forEach((menu) => {
const menuElement = menu?.$el;
if (menuElement) if (virtualScroll.value) {
const activeIndex = menu?.getActiveNodeIndex?.();
if (activeIndex !== void 0 && activeIndex >= 0) menu?.scrollToItem?.(activeIndex);
} else {
const container = menuElement.querySelector(`.${ns.namespace.value}-scrollbar__wrap`);
let activeNode = menuElement.querySelector(`.${ns.b("node")}.in-active-path`);
if (!activeNode) {
const activeElements = menuElement.querySelectorAll(`.${ns.b("node")}.${ns.is("active")}`);
activeNode = activeElements[activeElements.length - 1];
}
require_scroll.scrollIntoView(container, activeNode);
}
});
};
const handleKeyDown = (e) => {
const target = e.target;
const code = require_event$1.getEventCode(e);
switch (code) {
case require_aria$1.EVENT_CODE.up:
case require_aria$1.EVENT_CODE.down: {
e.preventDefault();
const distance = code === require_aria$1.EVENT_CODE.up ? -1 : 1;
if (virtualScroll.value) {
const menuIndex = require_utils.getMenuIndex(target);
const menu = menuList.value[menuIndex];
if (menu) {
const currentIndex = menu.getNodeIndexById(target.id);
if (currentIndex >= 0) {
const nodesInMenu = menus.value[menuIndex] ?? [];
const nodesCount = nodesInMenu.length;
let targetIndex = currentIndex + distance;
while (targetIndex >= 0 && targetIndex < nodesCount) {
if (!nodesInMenu[targetIndex].isDisabled) {
menu.focusNodeAt(targetIndex);
return;
}
targetIndex += distance;
}
}
}
}
require_aria.focusNode(require_aria.getSibling(target, distance, `.${ns.b("node")}[tabindex="-1"]`));
break;
}
case require_aria$1.EVENT_CODE.left: {
e.preventDefault();
const expandedNode = menuList.value[require_utils.getMenuIndex(target) - 1]?.$el.querySelector(`.${ns.b("node")}[aria-expanded="true"]`);
require_aria.focusNode(expandedNode);
break;
}
case require_aria$1.EVENT_CODE.right: {
e.preventDefault();
const firstNode = menuList.value[require_utils.getMenuIndex(target) + 1]?.$el.querySelector(`.${ns.b("node")}[tabindex="-1"]`);
require_aria.focusNode(firstNode);
break;
}
case require_aria$1.EVENT_CODE.enter:
case require_aria$1.EVENT_CODE.numpadEnter:
require_utils.checkNode(target);
break;
}
};
(0, vue.provide)(require_types$1.CASCADER_PANEL_INJECTION_KEY, (0, vue.reactive)({
config,
expandingNode,
checkedNodes,
isHoverMenu,
initialLoaded,
renderLabelFn,
virtualScroll,
itemSize,
height,
lazyLoad,
expandNode,
handleCheckChange
}));
(0, vue.watch)(config, (newVal, oldVal) => {
if ((0, lodash_unified.isEqual)(newVal, oldVal)) return;
initStore();
}, { immediate: true });
(0, vue.watch)(() => props.options, initStore, { deep: true });
(0, vue.watch)(() => props.modelValue, () => {
manualChecked = false;
syncCheckedValue();
}, { deep: true });
(0, vue.watch)(() => checkedValue.value, (val) => {
if (!(0, lodash_unified.isEqual)(val, props.modelValue)) {
emit(require_event.UPDATE_MODEL_EVENT, val);
emit(require_event.CHANGE_EVENT, val);
}
});
const loadLazyRootNodes = () => {
if (initialLoadedOnce.value) return;
initStore();
};
(0, vue.onBeforeUpdate)(() => menuList.value = []);
(0, vue.onMounted)(() => !require_types.isEmpty(props.modelValue) && syncCheckedValue());
__expose({
menuList,
menus,
checkedNodes,
handleKeyDown,
handleCheckChange,
getFlattedNodes,
/**
* @description get an array of currently selected node,(leafOnly) whether only return the leaf checked nodes, default is `false`
*/
getCheckedNodes,
/**
* @description clear checked nodes
*/
clearCheckedNodes,
calculateCheckedValue,
scrollToExpandingNode,
loadLazyRootNodes
});
return (_ctx, _cache) => {
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
class: (0, vue.normalizeClass)([(0, vue.unref)(ns).b("panel"), (0, vue.unref)(ns).is("bordered", __props.border)]),
onKeydown: handleKeyDown
}, [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(menus.value, (menu, index) => {
return (0, vue.openBlock)(), (0, vue.createBlock)(require_menu.default, {
key: index,
ref_for: true,
ref: (item) => menuList.value[index] = item,
index,
nodes: [...menu],
"virtual-scroll": virtualScroll.value,
"item-size": itemSize.value,
height: height.value
}, {
empty: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "empty")]),
_: 3
}, 8, [
"index",
"nodes",
"virtual-scroll",
"item-size",
"height"
]);
}), 128))], 34);
};
}
});
//#endregion
exports.default = index_vue_vue_type_script_setup_true_lang_default;
//# sourceMappingURL=index.vue_vue_type_script_setup_true_lang.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,8 @@
import _default from "./menu.vue.js";
import _default$1 from "./index.vue.js";
//#region ../../packages/components/cascader-panel/src/instance.d.ts
type CascaderMenuInstance = InstanceType<typeof _default> & unknown;
type CascaderPanelInstance = InstanceType<typeof _default$1> & unknown;
//#endregion
export { CascaderMenuInstance, CascaderPanelInstance };

View File

@@ -0,0 +1 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });

View File

@@ -0,0 +1,10 @@
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
//#region ../../packages/components/cascader-panel/src/menu.vue
var menu_default = require("./menu.vue_vue_type_script_setup_true_lang.js").default;
//#endregion
exports.default = menu_default;
//# sourceMappingURL=menu.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,37 @@
import Node from "./node.js";
import { CascaderCommonProps } from "./config.js";
import { FixedSizeListInstance } from "../../virtual-list/src/components/fixed-size-list.js";
import * as _$vue from "vue";
//#region ../../packages/components/cascader-panel/src/menu.vue.d.ts
type __VLS_Props = {
nodes: Node[];
index: number;
} & Pick<CascaderCommonProps, 'virtualScroll' | 'itemSize' | 'height'>;
declare var __VLS_28: {}, __VLS_58: {};
type __VLS_Slots = {} & {
empty?: (props: typeof __VLS_28) => any;
} & {
empty?: (props: typeof __VLS_58) => any;
};
declare const __VLS_base: _$vue.DefineComponent<__VLS_Props, {
getActiveNodeIndex: () => number;
getNodeIndexById: (nodeId: string | undefined) => number;
scrollToItem: (index: number) => void;
focusNodeAt: (index: number) => void;
virtualListRef: _$vue.Ref<FixedSizeListInstance | undefined, FixedSizeListInstance | undefined>;
readonly $el: HTMLElement;
}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
height: number;
virtualScroll: boolean;
itemSize: number;
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
declare const _default: typeof __VLS_export;
type __VLS_WithSlots<T, S> = T & {
new (): {
$slots: S;
};
};
//#endregion
export { _default as default };

View File

@@ -0,0 +1,233 @@
require("../../../_virtual/_rolldown/runtime.js");
const require_aria = require("../../../utils/dom/aria.js");
const require_index = require("../../../hooks/use-locale/index.js");
const require_index$1 = require("../../../hooks/use-namespace/index.js");
const require_index$2 = require("../../../hooks/use-id/index.js");
const require_index$3 = require("../../icon/index.js");
const require_index$4 = require("../../scrollbar/index.js");
require("./config.js");
const require_fixed_size_list = require("../../virtual-list/src/components/fixed-size-list.js");
const require_types = require("./types.js");
const require_node = require("./node2.js");
let lodash_unified = require("lodash-unified");
let _element_plus_icons_vue = require("@element-plus/icons-vue");
let vue = require("vue");
//#region ../../packages/components/cascader-panel/src/menu.vue?vue&type=script&setup=true&lang.ts
var menu_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.defineComponent)({
name: "ElCascaderMenu",
__name: "menu",
props: {
nodes: {
type: Array,
required: true
},
index: {
type: Number,
required: true
},
virtualScroll: {
type: Boolean,
required: false,
default: false
},
itemSize: {
type: Number,
required: false,
default: 34
},
height: {
type: Number,
required: false,
default: 204
}
},
setup(__props, { expose: __expose }) {
const props = __props;
const instance = (0, vue.getCurrentInstance)();
const ns = require_index$1.useNamespace("cascader-menu");
const { t } = require_index.useLocale();
const id = require_index$2.useId();
let activeNode;
let hoverTimer;
const panel = (0, vue.inject)(require_types.CASCADER_PANEL_INJECTION_KEY);
const hoverZone = (0, vue.ref)();
const virtualListRef = (0, vue.ref)();
const isEmpty = (0, vue.computed)(() => !props.nodes.length);
const isLoading = (0, vue.computed)(() => !panel.initialLoaded);
const menuId = (0, vue.computed)(() => `${id.value}-${props.index}`);
const getActiveNodeIndex = () => {
let activeNodeId;
if (panel.expandingNode) {
const { level, pathNodes } = panel.expandingNode;
if (props.index < level) activeNodeId = pathNodes[props.index]?.uid;
else if (props.index === level && panel.checkedNodes.length > 0) activeNodeId = panel.checkedNodes[0]?.pathNodes[props.index]?.uid;
} else if (panel.checkedNodes.length > 0 && props.index < panel.checkedNodes[0].pathNodes.length) activeNodeId = panel.checkedNodes[0].pathNodes[props.index]?.uid;
return activeNodeId !== void 0 ? props.nodes.findIndex((node) => node.uid === activeNodeId) : -1;
};
const getNodeIndexById = (nodeId) => {
if (!nodeId) return -1;
return props.nodes.findIndex((node) => `${menuId.value}-${node.uid}` === nodeId);
};
const scrollToItem = (index) => {
const targetIndex = (0, lodash_unified.clamp)(index, 0, props.nodes.length - 1);
virtualListRef.value?.scrollToItem(targetIndex);
};
const focusNodeAt = (index) => {
if (!props.nodes.length) return;
const targetIndex = (0, lodash_unified.clamp)(index, 0, props.nodes.length - 1);
scrollToItem(targetIndex);
(0, vue.nextTick)(() => {
const node = instance.vnode.el?.querySelector(`#${menuId.value}-${props.nodes[targetIndex].uid}`);
if (node) require_aria.focusNode(node);
});
};
const handleExpand = (e) => {
activeNode = e.target;
};
const handleMouseMove = (e) => {
if (!panel.isHoverMenu || !activeNode || !hoverZone.value) return;
if (activeNode.contains(e.target)) {
clearHoverTimer();
const el = instance.vnode.el;
const { left } = el.getBoundingClientRect();
const { offsetWidth, offsetHeight } = el;
const startX = e.clientX - left;
const top = activeNode.offsetTop;
const bottom = top + activeNode.offsetHeight;
const scrollTop = props.virtualScroll ? virtualListRef.value?.states?.scrollOffset || 0 : el.querySelector(`.${ns.e("wrap")}`)?.scrollTop || 0;
hoverZone.value.innerHTML = `
<path style="pointer-events: auto;" fill="transparent" d="M${startX} ${top} L${offsetWidth} ${scrollTop} V${top} Z" />
<path style="pointer-events: auto;" fill="transparent" d="M${startX} ${bottom} L${offsetWidth} ${offsetHeight + scrollTop} V${bottom} Z" />
`;
} else if (!hoverTimer) hoverTimer = window.setTimeout(clearHoverZone, panel.config.hoverThreshold);
};
const clearHoverTimer = () => {
if (!hoverTimer) return;
clearTimeout(hoverTimer);
hoverTimer = void 0;
};
const clearHoverZone = () => {
if (!hoverZone.value) return;
hoverZone.value.innerHTML = "";
clearHoverTimer();
};
__expose({
getActiveNodeIndex,
getNodeIndexById,
scrollToItem,
focusNodeAt,
virtualListRef,
get $el() {
return instance.vnode.el;
}
});
return (_ctx, _cache) => {
return __props.virtualScroll ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
key: menuId.value,
class: (0, vue.normalizeClass)((0, vue.unref)(ns).b()),
onMousemove: handleMouseMove,
onMouseleave: clearHoverZone
}, [
(0, vue.createVNode)((0, vue.unref)(require_fixed_size_list.default), {
ref_key: "virtualListRef",
ref: virtualListRef,
height: __props.height,
"item-size": __props.itemSize,
data: __props.nodes,
total: __props.nodes.length,
"class-name": (0, vue.unref)(ns).e("list"),
"inner-element": "ul",
"inner-props": {
role: "menu",
class: (0, vue.unref)(ns).is("empty", isEmpty.value)
}
}, {
default: (0, vue.withCtx)(({ data, index: nodeIndex, style }) => [((0, vue.openBlock)(), (0, vue.createBlock)(require_node.default, {
key: data[nodeIndex].uid,
node: data[nodeIndex],
"menu-id": menuId.value,
style: (0, vue.normalizeStyle)(style),
onExpand: handleExpand
}, null, 8, [
"node",
"menu-id",
"style"
]))]),
_: 1
}, 8, [
"height",
"item-size",
"data",
"total",
"class-name",
"inner-props"
]),
isLoading.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
key: 0,
class: (0, vue.normalizeClass)((0, vue.unref)(ns).e("empty-text"))
}, [(0, vue.createVNode)((0, vue.unref)(require_index$3.ElIcon), {
size: 14,
class: (0, vue.normalizeClass)((0, vue.unref)(ns).is("loading"))
}, {
default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(_element_plus_icons_vue.Loading))]),
_: 1
}, 8, ["class"]), (0, vue.createTextVNode)(" " + (0, vue.toDisplayString)((0, vue.unref)(t)("el.cascader.loading")), 1)], 2)) : isEmpty.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
key: 1,
class: (0, vue.normalizeClass)((0, vue.unref)(ns).e("empty-text"))
}, [(0, vue.renderSlot)(_ctx.$slots, "empty", {}, () => [(0, vue.createTextVNode)((0, vue.toDisplayString)((0, vue.unref)(t)("el.cascader.noData")), 1)])], 2)) : (0, vue.unref)(panel)?.isHoverMenu ? ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 2 }, [(0, vue.createCommentVNode)(" eslint-disable vue/html-self-closing "), ((0, vue.openBlock)(), (0, vue.createElementBlock)("svg", {
ref_key: "hoverZone",
ref: hoverZone,
class: (0, vue.normalizeClass)((0, vue.unref)(ns).e("hover-zone"))
}, null, 2))], 2112)) : (0, vue.createCommentVNode)("v-if", true),
(0, vue.createCommentVNode)(" eslint-enable vue/html-self-closing ")
], 34)) : ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(require_index$4.ElScrollbar), {
key: menuId.value,
tag: "ul",
role: "menu",
class: (0, vue.normalizeClass)((0, vue.unref)(ns).b()),
"wrap-class": (0, vue.unref)(ns).e("wrap"),
"view-class": [(0, vue.unref)(ns).e("list"), (0, vue.unref)(ns).is("empty", isEmpty.value)],
onMousemove: handleMouseMove,
onMouseleave: clearHoverZone
}, {
default: (0, vue.withCtx)(() => [
((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(__props.nodes, (node) => {
return (0, vue.openBlock)(), (0, vue.createBlock)(require_node.default, {
key: node.uid,
node,
"menu-id": menuId.value,
onExpand: handleExpand
}, null, 8, ["node", "menu-id"]);
}), 128)),
isLoading.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
key: 0,
class: (0, vue.normalizeClass)((0, vue.unref)(ns).e("empty-text"))
}, [(0, vue.createVNode)((0, vue.unref)(require_index$3.ElIcon), {
size: 14,
class: (0, vue.normalizeClass)((0, vue.unref)(ns).is("loading"))
}, {
default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(_element_plus_icons_vue.Loading))]),
_: 1
}, 8, ["class"]), (0, vue.createTextVNode)(" " + (0, vue.toDisplayString)((0, vue.unref)(t)("el.cascader.loading")), 1)], 2)) : isEmpty.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
key: 1,
class: (0, vue.normalizeClass)((0, vue.unref)(ns).e("empty-text"))
}, [(0, vue.renderSlot)(_ctx.$slots, "empty", {}, () => [(0, vue.createTextVNode)((0, vue.toDisplayString)((0, vue.unref)(t)("el.cascader.noData")), 1)])], 2)) : (0, vue.unref)(panel)?.isHoverMenu ? ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 2 }, [(0, vue.createCommentVNode)(" eslint-disable vue/html-self-closing "), ((0, vue.openBlock)(), (0, vue.createElementBlock)("svg", {
ref_key: "hoverZone",
ref: hoverZone,
class: (0, vue.normalizeClass)((0, vue.unref)(ns).e("hover-zone"))
}, null, 2))], 2112)) : (0, vue.createCommentVNode)("v-if", true),
(0, vue.createCommentVNode)(" eslint-enable vue/html-self-closing ")
]),
_: 3
}, 8, [
"class",
"wrap-class",
"view-class"
]));
};
}
});
//#endregion
exports.default = menu_vue_vue_type_script_setup_true_lang_default;
//# sourceMappingURL=menu.vue_vue_type_script_setup_true_lang.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,19 @@
import Node from "./node.js";
import * as _$vue from "vue";
import { PropType } from "vue";
import * as _$vue_jsx_runtime0 from "vue/jsx-runtime";
//#region ../../packages/components/cascader-panel/src/node-content.d.ts
declare const _default: _$vue.DefineComponent<_$vue.ExtractPropTypes<{
node: {
type: PropType<Node>;
required: true;
};
}>, () => _$vue_jsx_runtime0.JSX.Element, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<_$vue.ExtractPropTypes<{
node: {
type: PropType<Node>;
required: true;
};
}>> & Readonly<{}>, {}, {}, {}, {}, string, _$vue.ComponentProvideOptions, true, {}, any>;
//#endregion
export { _default as default };

View File

@@ -0,0 +1,34 @@
require("../../../_virtual/_rolldown/runtime.js");
const require_index = require("../../../hooks/use-namespace/index.js");
const require_types = require("./types.js");
let vue = require("vue");
let _vue_shared = require("@vue/shared");
//#region ../../packages/components/cascader-panel/src/node-content.tsx
function isVNodeEmpty(vnodes) {
return !!((0, _vue_shared.isArray)(vnodes) ? vnodes.every(({ type }) => type === vue.Comment) : vnodes?.type === vue.Comment);
}
var node_content_default = /* @__PURE__ */ (0, vue.defineComponent)({
name: "NodeContent",
props: { node: {
type: Object,
required: true
} },
setup(props) {
const ns = require_index.useNamespace("cascader-node");
const { renderLabelFn } = (0, vue.inject)(require_types.CASCADER_PANEL_INJECTION_KEY);
const { node } = props;
const { data, label: nodeLabel } = node;
const label = () => {
const renderLabel = renderLabelFn?.({
node,
data
});
return isVNodeEmpty(renderLabel) ? nodeLabel : renderLabel ?? nodeLabel;
};
return () => (0, vue.createVNode)("span", { "class": ns.e("label") }, [label()]);
}
});
//#endregion
exports.default = node_content_default;
//# sourceMappingURL=node-content.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"node-content.js","names":["Comment","defineComponent","inject","createVNode","_createVNode","useNamespace","isArray","CASCADER_PANEL_INJECTION_KEY","isVNodeEmpty","vnodes","every","type","name","props","node","Object","required","setup","ns","renderLabelFn","data","label","nodeLabel","renderLabel","e"],"sources":["../../../../../../packages/components/cascader-panel/src/node-content.tsx"],"sourcesContent":["import { Comment, defineComponent, inject } from 'vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport { isArray } from '@element-plus/utils'\nimport { CASCADER_PANEL_INJECTION_KEY } from './types'\n\nimport type { PropType, VNode } from 'vue'\nimport type { CascaderNode } from './types'\n\nfunction isVNodeEmpty(vnodes?: VNode[] | VNode) {\n return !!(isArray(vnodes)\n ? vnodes.every(({ type }) => type === Comment)\n : vnodes?.type === Comment)\n}\n\nexport default defineComponent({\n name: 'NodeContent',\n props: {\n node: {\n type: Object as PropType<CascaderNode>,\n required: true,\n },\n },\n setup(props) {\n const ns = useNamespace('cascader-node')\n const { renderLabelFn } = inject(CASCADER_PANEL_INJECTION_KEY)!\n const { node } = props\n const { data, label: nodeLabel } = node\n\n const label = () => {\n const renderLabel = renderLabelFn?.({ node, data })\n return isVNodeEmpty(renderLabel) ? nodeLabel : (renderLabel ?? nodeLabel)\n }\n return () => <span class={ns.e('label')}>{label()}</span>\n },\n})\n"],"mappings":";;;;;;AAQA,SAASQ,aAAaC,QAA0B;CAC9C,OAAO,CAAC,GAAA,GAAA,YAAA,SAAUA,OAAO,GACrBA,OAAOC,OAAO,EAAEC,WAAWA,SAASX,IAAAA,QAAQ,GAC5CS,QAAQE,SAASX,IAAAA;;AAGvB,IAAA,uBAAeC,iBAAAA,GAAAA,IAAAA,iBAAgB;CAC7BW,MAAM;CACNC,OAAO,EACLC,MAAM;EACJH,MAAMI;EACNC,UAAU;EACZ,EACD;CACDC,MAAMJ,OAAO;EACX,MAAMK,KAAKb,cAAAA,aAAa,gBAAgB;EACxC,MAAM,EAAEc,mBAAAA,GAAAA,IAAAA,QAAyBZ,cAAAA,6BAA8B;EAC/D,MAAM,EAAEO,SAASD;EACjB,MAAM,EAAEO,MAAMC,OAAOC,cAAcR;EAEnC,MAAMO,cAAc;GAClB,MAAME,cAAcJ,gBAAgB;IAAEL;IAAMM;IAAM,CAAC;GACnD,OAAOZ,aAAae,YAAY,GAAGD,YAAaC,eAAeD;;EAEjE,cAAA,GAAA,IAAA,aAAO,QAAA,EAAA,SAAmBJ,GAAGM,EAAE,QAAO,EAAC,EAAA,CAAGH,OAAO,CAAA,CAAQ;;CAE5D,CAAC"}

View File

@@ -0,0 +1,53 @@
import { CascaderConfig, CascaderNodePathValue, CascaderNodeValue, CascaderOption } from "./types.js";
//#region ../../packages/components/cascader-panel/src/node.d.ts
type ChildrenData = CascaderOption[] | undefined;
declare class Node {
readonly data: CascaderOption;
readonly config: CascaderConfig;
readonly parent?: Node | undefined;
readonly root: boolean;
readonly uid: number;
readonly level: number;
readonly value: CascaderNodeValue;
readonly label: string;
readonly pathNodes: Node[];
readonly pathValues: CascaderNodePathValue;
readonly pathLabels: string[];
childrenData: ChildrenData;
children: Node[];
text: string;
loaded: boolean;
/**
* Is it checked
*
* @default false
*/
checked: boolean;
/**
* Used to indicate the intermediate state of unchecked and fully checked child nodes
*
* @default false
*/
indeterminate: boolean;
/**
* Loading Status
*
* @default false
*/
loading: boolean;
constructor(data: CascaderOption, config: CascaderConfig, parent?: Node | undefined, root?: boolean);
get isDisabled(): boolean;
get isLeaf(): boolean;
get valueByOption(): CascaderNodeValue | CascaderNodePathValue;
appendChild(childData: CascaderOption): Node;
calcText(allLevels: boolean, separator: string): string;
broadcast(checked: boolean): void;
emit(): void;
onParentCheck(checked: boolean): void;
onChildCheck(): void;
setCheckState(checked: boolean): void;
doCheck(checked: boolean): void;
}
//#endregion
export { Node as default };

View File

@@ -0,0 +1,116 @@
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
require("../../../_virtual/_rolldown/runtime.js");
const require_types = require("../../../utils/types.js");
let _vue_shared = require("@vue/shared");
//#region ../../packages/components/cascader-panel/src/node.ts
let uid = 0;
const calculatePathNodes = (node) => {
const nodes = [node];
let { parent } = node;
while (parent) {
nodes.unshift(parent);
parent = parent.parent;
}
return nodes;
};
var Node = class Node {
constructor(data, config, parent, root = false) {
this.data = data;
this.config = config;
this.parent = parent;
this.root = root;
this.uid = uid++;
this.checked = false;
this.indeterminate = false;
this.loading = false;
const { value: valueKey, label: labelKey, children: childrenKey } = config;
const childrenData = data[childrenKey];
const pathNodes = calculatePathNodes(this);
this.level = root ? 0 : parent ? parent.level + 1 : 1;
this.value = data[valueKey];
this.label = data[labelKey];
this.pathNodes = pathNodes;
this.pathValues = pathNodes.map((node) => node.value);
this.pathLabels = pathNodes.map((node) => node.label);
this.childrenData = childrenData;
this.children = (childrenData || []).map((child) => new Node(child, config, this));
this.loaded = !config.lazy || this.isLeaf || !require_types.isEmpty(childrenData);
this.text = "";
}
get isDisabled() {
const { data, parent, config } = this;
const { disabled, checkStrictly } = config;
return ((0, _vue_shared.isFunction)(disabled) ? disabled(data, this) : !!data[disabled]) || !checkStrictly && !!parent?.isDisabled;
}
get isLeaf() {
const { data, config, childrenData, loaded } = this;
const { lazy, leaf } = config;
const isLeaf = (0, _vue_shared.isFunction)(leaf) ? leaf(data, this) : data[leaf];
return require_types.isUndefined(isLeaf) ? lazy && !loaded ? false : !((0, _vue_shared.isArray)(childrenData) && childrenData.length) : !!isLeaf;
}
get valueByOption() {
return this.config.emitPath ? this.pathValues : this.value;
}
appendChild(childData) {
const { childrenData, children } = this;
const node = new Node(childData, this.config, this);
if ((0, _vue_shared.isArray)(childrenData)) childrenData.push(childData);
else this.childrenData = [childData];
children.push(node);
return node;
}
calcText(allLevels, separator) {
const text = allLevels ? this.pathLabels.join(separator) : this.label;
this.text = text;
return text;
}
broadcast(checked) {
this.children.forEach((child) => {
if (child) {
child.broadcast(checked);
child.onParentCheck?.(checked);
}
});
}
emit() {
const { parent } = this;
if (parent) {
parent.onChildCheck?.();
parent.emit();
}
}
onParentCheck(checked) {
if (!this.isDisabled) this.setCheckState(checked);
}
onChildCheck() {
const { children } = this;
const validChildren = children.filter((child) => !child.isDisabled);
const checked = validChildren.length ? validChildren.every((child) => child.checked) : false;
this.setCheckState(checked);
}
setCheckState(checked) {
const totalNum = this.children.length;
const checkedNum = this.children.reduce((c, p) => {
return c + (p.checked ? 1 : p.indeterminate ? .5 : 0);
}, 0);
this.checked = this.loaded && this.children.filter((child) => !child.isDisabled).every((child) => child.loaded && child.checked) && checked;
this.indeterminate = this.loaded && checkedNum !== totalNum && checkedNum > 0;
}
doCheck(checked) {
if (this.checked === checked) return;
const { checkStrictly, multiple } = this.config;
if (checkStrictly || !multiple) this.checked = checked;
else {
this.broadcast(checked);
this.setCheckState(checked);
this.emit();
}
}
};
//#endregion
exports.default = Node;
//# sourceMappingURL=node.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,16 @@
import Node from "./node.js";
import * as _$vue from "vue";
//#region ../../packages/components/cascader-panel/src/node.vue.d.ts
type __VLS_Props = {
node: Node;
menuId?: string;
};
declare const __VLS_export: _$vue.DefineComponent<__VLS_Props, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {
expand: (...args: any[]) => void;
}, string, _$vue.PublicProps, Readonly<__VLS_Props> & Readonly<{
onExpand?: ((...args: any[]) => any) | undefined;
}>, {}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
declare const _default: typeof __VLS_export;
//#endregion
export { _default as default };

View File

@@ -0,0 +1,169 @@
require("../../../_virtual/_rolldown/runtime.js");
const require_index = require("../../../hooks/use-namespace/index.js");
const require_index$1 = require("../../icon/index.js");
const require_index$2 = require("../../checkbox/index.js");
const require_index$3 = require("../../radio/index.js");
const require_types = require("./types.js");
const require_node_content = require("./node-content.js");
let _element_plus_icons_vue = require("@element-plus/icons-vue");
let vue = require("vue");
//#region ../../packages/components/cascader-panel/src/node.vue?vue&type=script&setup=true&lang.ts
const _hoisted_1 = [
"id",
"aria-haspopup",
"aria-owns",
"aria-expanded",
"tabindex"
];
var node_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.defineComponent)({
name: "ElCascaderNode",
__name: "node",
props: {
node: {
type: Object,
required: true
},
menuId: {
type: String,
required: false
}
},
emits: ["expand"],
setup(__props, { emit: __emit }) {
const props = __props;
const emit = __emit;
const panel = (0, vue.inject)(require_types.CASCADER_PANEL_INJECTION_KEY);
const ns = require_index.useNamespace("cascader-node");
const isHoverMenu = (0, vue.computed)(() => panel.isHoverMenu);
const multiple = (0, vue.computed)(() => panel.config.multiple);
const checkStrictly = (0, vue.computed)(() => panel.config.checkStrictly);
const showPrefix = (0, vue.computed)(() => panel.config.showPrefix);
const checkedNodeId = (0, vue.computed)(() => panel.checkedNodes[0]?.uid);
const isDisabled = (0, vue.computed)(() => props.node.isDisabled);
const isLeaf = (0, vue.computed)(() => props.node.isLeaf);
const expandable = (0, vue.computed)(() => checkStrictly.value && !isLeaf.value || !isDisabled.value);
const inExpandingPath = (0, vue.computed)(() => isInPath(panel.expandingNode));
const inCheckedPath = (0, vue.computed)(() => checkStrictly.value && panel.checkedNodes.some(isInPath));
const isInPath = (node) => {
const { level, uid } = props.node;
return node?.pathNodes[level - 1]?.uid === uid;
};
const doExpand = () => {
if (inExpandingPath.value) return;
panel.expandNode(props.node);
};
const doCheck = (checked) => {
const { node } = props;
if (checked === node.checked) return;
panel.handleCheckChange(node, checked);
};
const doLoad = () => {
panel.lazyLoad(props.node, () => {
if (!isLeaf.value) doExpand();
});
};
const handleHoverExpand = (e) => {
if (!isHoverMenu.value) return;
handleExpand();
!isLeaf.value && emit("expand", e);
};
const handleExpand = () => {
const { node } = props;
if (!expandable.value || node.loading) return;
node.loaded ? doExpand() : doLoad();
};
const handleClick = () => {
if (isLeaf.value && !isDisabled.value && !checkStrictly.value && !multiple.value) handleCheck(true);
else if ((panel.config.checkOnClickNode && (multiple.value || checkStrictly.value) || isLeaf.value && panel.config.checkOnClickLeaf) && !isDisabled.value) handleSelectCheck(!props.node.checked);
else if (!isHoverMenu.value) handleExpand();
};
const handleSelectCheck = (checked) => {
if (checkStrictly.value) {
doCheck(checked);
if (props.node.loaded) doExpand();
} else handleCheck(checked);
};
const handleCheck = (checked) => {
if (!props.node.loaded) doLoad();
else {
doCheck(checked);
!checkStrictly.value && doExpand();
}
};
return (_ctx, _cache) => {
return (0, vue.openBlock)(), (0, vue.createElementBlock)("li", {
id: `${__props.menuId}-${__props.node.uid}`,
role: "menuitem",
"aria-haspopup": !isLeaf.value,
"aria-owns": isLeaf.value ? void 0 : __props.menuId,
"aria-expanded": inExpandingPath.value,
tabindex: expandable.value ? -1 : void 0,
class: (0, vue.normalizeClass)([
(0, vue.unref)(ns).b(),
(0, vue.unref)(ns).is("selectable", checkStrictly.value),
(0, vue.unref)(ns).is("active", __props.node.checked),
(0, vue.unref)(ns).is("disabled", !expandable.value),
inExpandingPath.value && "in-active-path",
inCheckedPath.value && "in-checked-path"
]),
onMouseenter: handleHoverExpand,
onFocus: handleHoverExpand,
onClick: handleClick
}, [
(0, vue.createCommentVNode)(" prefix "),
multiple.value && showPrefix.value ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(require_index$2.ElCheckbox), {
key: 0,
"model-value": __props.node.checked,
indeterminate: __props.node.indeterminate,
disabled: isDisabled.value,
onClick: _cache[0] || (_cache[0] = (0, vue.withModifiers)(() => {}, ["stop"])),
"onUpdate:modelValue": handleSelectCheck
}, null, 8, [
"model-value",
"indeterminate",
"disabled"
])) : checkStrictly.value && showPrefix.value ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(require_index$3.ElRadio), {
key: 1,
"model-value": checkedNodeId.value,
label: __props.node.uid,
disabled: isDisabled.value,
"onUpdate:modelValue": handleSelectCheck,
onClick: _cache[1] || (_cache[1] = (0, vue.withModifiers)(() => {}, ["stop"]))
}, {
default: (0, vue.withCtx)(() => [(0, vue.createCommentVNode)("\n Add an empty element to avoid render label,\n do not use empty fragment here for https://github.com/vuejs/vue-next/pull/2485\n "), _cache[2] || (_cache[2] = (0, vue.createElementVNode)("span", null, null, -1))]),
_: 1
}, 8, [
"model-value",
"label",
"disabled"
])) : isLeaf.value && __props.node.checked ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(require_index$1.ElIcon), {
key: 2,
class: (0, vue.normalizeClass)((0, vue.unref)(ns).e("prefix"))
}, {
default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(_element_plus_icons_vue.Check))]),
_: 1
}, 8, ["class"])) : (0, vue.createCommentVNode)("v-if", true),
(0, vue.createCommentVNode)(" content "),
(0, vue.createVNode)((0, vue.unref)(require_node_content.default), { node: __props.node }, null, 8, ["node"]),
(0, vue.createCommentVNode)(" postfix "),
!isLeaf.value ? ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 3 }, [__props.node.loading ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(require_index$1.ElIcon), {
key: 0,
class: (0, vue.normalizeClass)([(0, vue.unref)(ns).is("loading"), (0, vue.unref)(ns).e("postfix")])
}, {
default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(_element_plus_icons_vue.Loading))]),
_: 1
}, 8, ["class"])) : ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(require_index$1.ElIcon), {
key: 1,
class: (0, vue.normalizeClass)(["arrow-right", (0, vue.unref)(ns).e("postfix")])
}, {
default: (0, vue.withCtx)(() => [(0, vue.createVNode)((0, vue.unref)(_element_plus_icons_vue.ArrowRight))]),
_: 1
}, 8, ["class"]))], 64)) : (0, vue.createCommentVNode)("v-if", true)
], 42, _hoisted_1);
};
}
});
//#endregion
exports.default = node_vue_vue_type_script_setup_true_lang_default;
//# sourceMappingURL=node.vue_vue_type_script_setup_true_lang.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
//#region ../../packages/components/cascader-panel/src/node.vue
var node_default = require("./node.vue_vue_type_script_setup_true_lang.js").default;
//#endregion
exports.default = node_default;
//# sourceMappingURL=node2.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,21 @@
import { Nullable } from "../../../utils/typescript.js";
import { CascaderConfig, CascaderNodePathValue, CascaderNodeValue, CascaderOption } from "./types.js";
import Node from "./node.js";
//#region ../../packages/components/cascader-panel/src/store.d.ts
declare class Store {
readonly config: CascaderConfig;
readonly nodes: Node[];
readonly allNodes: Node[];
readonly leafNodes: Node[];
constructor(data: CascaderOption[], config: CascaderConfig);
getNodes(): Node[];
getFlattedNodes(leafOnly: boolean): Node[];
appendNode(nodeData: CascaderOption, parentNode?: Node): void;
appendNodes(nodeDataList: CascaderOption[], parentNode: Node): void;
appendAllNodesAndLeafNodes(node: Node): void;
getNodeByValue(value: CascaderNodeValue | CascaderNodePathValue, leafOnly?: boolean): Nullable<Node>;
getSameNode(node: Node): Nullable<Node>;
}
//#endregion
export { Store as default };

View File

@@ -0,0 +1,62 @@
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
require("../../../_virtual/_rolldown/runtime.js");
const require_types = require("../../../utils/types.js");
const require_node = require("./node.js");
let lodash_unified = require("lodash-unified");
//#region ../../packages/components/cascader-panel/src/store.ts
const flatNodes = (nodes, leafOnly) => {
return nodes.reduce((res, node) => {
if (node.isLeaf) res.push(node);
else {
!leafOnly && res.push(node);
res = res.concat(flatNodes(node.children, leafOnly));
}
return res;
}, []);
};
var Store = class {
constructor(data, config) {
this.config = config;
const nodes = (data || []).map((nodeData) => new require_node.default(nodeData, this.config));
this.nodes = nodes;
this.allNodes = flatNodes(nodes, false);
this.leafNodes = flatNodes(nodes, true);
}
getNodes() {
return this.nodes;
}
getFlattedNodes(leafOnly) {
return leafOnly ? this.leafNodes : this.allNodes;
}
appendNode(nodeData, parentNode) {
const node = parentNode ? parentNode.appendChild(nodeData) : new require_node.default(nodeData, this.config);
if (!parentNode) this.nodes.push(node);
this.appendAllNodesAndLeafNodes(node);
}
appendNodes(nodeDataList, parentNode) {
if (nodeDataList.length > 0) nodeDataList.forEach((nodeData) => this.appendNode(nodeData, parentNode));
else parentNode && parentNode.isLeaf && this.leafNodes.push(parentNode);
}
appendAllNodesAndLeafNodes(node) {
this.allNodes.push(node);
node.isLeaf && this.leafNodes.push(node);
if (node.children) node.children.forEach((subNode) => {
this.appendAllNodesAndLeafNodes(subNode);
});
}
getNodeByValue(value, leafOnly = false) {
if (require_types.isPropAbsent(value)) return null;
return this.getFlattedNodes(leafOnly).find((node) => (0, lodash_unified.isEqual)(node.value, value) || (0, lodash_unified.isEqual)(node.pathValues, value)) || null;
}
getSameNode(node) {
if (!node) return null;
return this.getFlattedNodes(false).find(({ value, level }) => (0, lodash_unified.isEqual)(node.value, value) && node.level === level) || null;
}
};
//#endregion
exports.default = Store;
//# sourceMappingURL=store.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"store.js","names":["Node","isPropAbsent"],"sources":["../../../../../../packages/components/cascader-panel/src/store.ts"],"sourcesContent":["import { isEqual } from 'lodash-unified'\nimport { isPropAbsent } from '@element-plus/utils'\nimport Node from './node'\n\nimport type { Nullable } from '@element-plus/utils'\nimport type {\n CascaderConfig,\n CascaderNodePathValue,\n CascaderNodeValue,\n CascaderOption,\n} from './types'\n\nconst flatNodes = (nodes: Node[], leafOnly: boolean) => {\n return nodes.reduce((res, node) => {\n if (node.isLeaf) {\n res.push(node)\n } else {\n !leafOnly && res.push(node)\n res = res.concat(flatNodes(node.children, leafOnly))\n }\n return res\n }, [] as Node[])\n}\n\nexport default class Store {\n readonly nodes: Node[]\n readonly allNodes: Node[]\n readonly leafNodes: Node[]\n\n constructor(\n data: CascaderOption[],\n readonly config: CascaderConfig\n ) {\n const nodes = (data || []).map(\n (nodeData) => new Node(nodeData, this.config)\n )\n this.nodes = nodes\n this.allNodes = flatNodes(nodes, false)\n this.leafNodes = flatNodes(nodes, true)\n }\n\n getNodes() {\n return this.nodes\n }\n\n getFlattedNodes(leafOnly: boolean) {\n return leafOnly ? this.leafNodes : this.allNodes\n }\n\n appendNode(nodeData: CascaderOption, parentNode?: Node) {\n const node = parentNode\n ? parentNode.appendChild(nodeData)\n : new Node(nodeData, this.config)\n\n if (!parentNode) this.nodes.push(node)\n\n this.appendAllNodesAndLeafNodes(node)\n }\n\n appendNodes(nodeDataList: CascaderOption[], parentNode: Node) {\n if (nodeDataList.length > 0) {\n nodeDataList.forEach((nodeData) => this.appendNode(nodeData, parentNode))\n } else {\n parentNode && parentNode.isLeaf && this.leafNodes.push(parentNode)\n }\n }\n\n appendAllNodesAndLeafNodes(node: Node) {\n this.allNodes.push(node)\n node.isLeaf && this.leafNodes.push(node)\n if (node.children) {\n node.children.forEach((subNode) => {\n this.appendAllNodesAndLeafNodes(subNode)\n })\n }\n }\n\n // when checkStrictly, leaf node first\n getNodeByValue(\n value: CascaderNodeValue | CascaderNodePathValue,\n leafOnly = false\n ): Nullable<Node> {\n if (isPropAbsent(value)) return null\n\n const node = this.getFlattedNodes(leafOnly).find(\n (node) => isEqual(node.value, value) || isEqual(node.pathValues, value)\n )\n\n return node || null\n }\n\n getSameNode(node: Node): Nullable<Node> {\n if (!node) return null\n\n const node_ = this.getFlattedNodes(false).find(\n ({ value, level }) => isEqual(node.value, value) && node.level === level\n )\n\n return node_ || null\n }\n}\n"],"mappings":";;;;;;;;;AAYA,MAAM,aAAa,OAAe,aAAsB;CACtD,OAAO,MAAM,QAAQ,KAAK,SAAS;EACjC,IAAI,KAAK,QACP,IAAI,KAAK,KAAK;OACT;GACL,CAAC,YAAY,IAAI,KAAK,KAAK;GAC3B,MAAM,IAAI,OAAO,UAAU,KAAK,UAAU,SAAS,CAAC;;EAEtD,OAAO;IACN,EAAE,CAAW;;AAGlB,IAAqB,QAArB,MAA2B;CAKzB,YACE,MACA,QACA;EADS,KAAA,SAAA;EAET,MAAM,SAAS,QAAQ,EAAE,EAAE,KACxB,aAAa,IAAIA,aAAAA,QAAK,UAAU,KAAK,OAAO,CAC9C;EACD,KAAK,QAAQ;EACb,KAAK,WAAW,UAAU,OAAO,MAAM;EACvC,KAAK,YAAY,UAAU,OAAO,KAAK;;CAGzC,WAAW;EACT,OAAO,KAAK;;CAGd,gBAAgB,UAAmB;EACjC,OAAO,WAAW,KAAK,YAAY,KAAK;;CAG1C,WAAW,UAA0B,YAAmB;EACtD,MAAM,OAAO,aACT,WAAW,YAAY,SAAS,GAChC,IAAIA,aAAAA,QAAK,UAAU,KAAK,OAAO;EAEnC,IAAI,CAAC,YAAY,KAAK,MAAM,KAAK,KAAK;EAEtC,KAAK,2BAA2B,KAAK;;CAGvC,YAAY,cAAgC,YAAkB;EAC5D,IAAI,aAAa,SAAS,GACxB,aAAa,SAAS,aAAa,KAAK,WAAW,UAAU,WAAW,CAAC;OAEzE,cAAc,WAAW,UAAU,KAAK,UAAU,KAAK,WAAW;;CAItE,2BAA2B,MAAY;EACrC,KAAK,SAAS,KAAK,KAAK;EACxB,KAAK,UAAU,KAAK,UAAU,KAAK,KAAK;EACxC,IAAI,KAAK,UACP,KAAK,SAAS,SAAS,YAAY;GACjC,KAAK,2BAA2B,QAAQ;IACxC;;CAKN,eACE,OACA,WAAW,OACK;EAChB,IAAIC,cAAAA,aAAa,MAAM,EAAE,OAAO;EAMhC,OAJa,KAAK,gBAAgB,SAAS,CAAC,MACzC,UAAA,GAAA,eAAA,SAAiB,KAAK,OAAO,MAAM,KAAA,GAAA,eAAA,SAAY,KAAK,YAAY,MAAM,CAG9D,IAAI;;CAGjB,YAAY,MAA4B;EACtC,IAAI,CAAC,MAAM,OAAO;EAMlB,OAJc,KAAK,gBAAgB,MAAM,CAAC,MACvC,EAAE,OAAO,aAAA,GAAA,eAAA,SAAoB,KAAK,OAAO,MAAM,IAAI,KAAK,UAAU,MAGzD,IAAI"}

View File

@@ -0,0 +1,67 @@
import { Nullable } from "../../../utils/typescript.js";
import Node from "./node.js";
import { InjectionKey, VNode } from "vue";
//#region ../../packages/components/cascader-panel/src/types.d.ts
type CascaderNodeValue = string | number | Record<string, any>;
type CascaderNodePathValue = CascaderNodeValue[];
type CascaderValue = CascaderNodeValue | CascaderNodePathValue | (CascaderNodeValue | CascaderNodePathValue)[];
type CascaderConfig = Required<CascaderProps>;
type ExpandTrigger = 'click' | 'hover';
type isDisabled = (data: CascaderOption, node: Node) => boolean;
type isLeaf = (data: CascaderOption, node: Node) => boolean;
type Resolve = (dataList?: CascaderOption[]) => void;
type LazyLoad = (node: Node, resolve: Resolve, reject: () => void) => void;
interface RenderLabelProps {
node: Node;
data: CascaderOption;
}
type RenderLabel = (props: RenderLabelProps) => VNode | VNode[];
interface CascaderOption extends Record<string, unknown> {
label?: string;
value?: CascaderNodeValue;
children?: CascaderOption[];
disabled?: boolean;
leaf?: boolean;
}
interface CascaderProps {
expandTrigger?: ExpandTrigger;
multiple?: boolean;
checkStrictly?: boolean;
emitPath?: boolean;
lazy?: boolean;
lazyLoad?: LazyLoad;
value?: string;
label?: string;
children?: string;
disabled?: string | isDisabled;
leaf?: string | isLeaf;
hoverThreshold?: number;
checkOnClickNode?: boolean;
checkOnClickLeaf?: boolean;
showPrefix?: boolean;
}
interface Tag {
node?: Node;
key: number;
text: string;
hitState?: boolean;
closable: boolean;
}
interface ElCascaderPanelContext {
config: CascaderConfig;
expandingNode: Node | undefined;
checkedNodes: Node[];
isHoverMenu: boolean;
initialLoaded: boolean;
renderLabelFn?: RenderLabel;
virtualScroll: boolean;
itemSize: number;
height: number;
lazyLoad: (node?: Node, cb?: (dataList: CascaderOption[]) => void) => void;
expandNode: (node: Node, silent?: boolean) => void;
handleCheckChange: (node: Node, checked: boolean, emitClose?: boolean) => void;
}
declare const CASCADER_PANEL_INJECTION_KEY: InjectionKey<ElCascaderPanelContext>;
//#endregion
export { CASCADER_PANEL_INJECTION_KEY, CascaderConfig, type Node as CascaderNode, CascaderNodePathValue, CascaderNodeValue, CascaderOption, CascaderProps, CascaderValue, ElCascaderPanelContext, ExpandTrigger, LazyLoad, type Nullable, RenderLabel, RenderLabelProps, Resolve, Tag, isDisabled, isLeaf };

View File

@@ -0,0 +1,7 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
//#region ../../packages/components/cascader-panel/src/types.ts
const CASCADER_PANEL_INJECTION_KEY = Symbol();
//#endregion
exports.CASCADER_PANEL_INJECTION_KEY = CASCADER_PANEL_INJECTION_KEY;
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","names":[],"sources":["../../../../../../packages/components/cascader-panel/src/types.ts"],"sourcesContent":["import type { InjectionKey, VNode } from 'vue'\nimport type { Nullable } from '@element-plus/utils'\nimport type { default as CascaderNode } from './node'\n\nexport type { CascaderNode, Nullable }\nexport type CascaderNodeValue = string | number | Record<string, any>\nexport type CascaderNodePathValue = CascaderNodeValue[]\nexport type CascaderValue =\n | CascaderNodeValue\n | CascaderNodePathValue\n | (CascaderNodeValue | CascaderNodePathValue)[]\nexport type CascaderConfig = Required<CascaderProps>\nexport type ExpandTrigger = 'click' | 'hover'\nexport type isDisabled = (data: CascaderOption, node: CascaderNode) => boolean\nexport type isLeaf = (data: CascaderOption, node: CascaderNode) => boolean\nexport type Resolve = (dataList?: CascaderOption[]) => void\nexport type LazyLoad = (\n node: CascaderNode,\n resolve: Resolve,\n reject: () => void\n) => void\nexport interface RenderLabelProps {\n node: CascaderNode\n data: CascaderOption\n}\nexport type RenderLabel = (props: RenderLabelProps) => VNode | VNode[]\nexport interface CascaderOption extends Record<string, unknown> {\n label?: string\n value?: CascaderNodeValue\n children?: CascaderOption[]\n disabled?: boolean\n leaf?: boolean\n}\n\nexport interface CascaderProps {\n expandTrigger?: ExpandTrigger\n multiple?: boolean\n checkStrictly?: boolean\n emitPath?: boolean\n lazy?: boolean\n lazyLoad?: LazyLoad\n value?: string\n label?: string\n children?: string\n disabled?: string | isDisabled\n leaf?: string | isLeaf\n hoverThreshold?: number\n checkOnClickNode?: boolean\n checkOnClickLeaf?: boolean\n showPrefix?: boolean\n}\n\nexport interface Tag {\n node?: CascaderNode\n key: number\n text: string\n hitState?: boolean\n closable: boolean\n}\n\nexport interface ElCascaderPanelContext {\n config: CascaderConfig\n expandingNode: CascaderNode | undefined\n checkedNodes: CascaderNode[]\n isHoverMenu: boolean\n initialLoaded: boolean\n renderLabelFn?: RenderLabel\n virtualScroll: boolean\n itemSize: number\n height: number\n lazyLoad: (\n node?: CascaderNode,\n cb?: (dataList: CascaderOption[]) => void\n ) => void\n expandNode: (node: CascaderNode, silent?: boolean) => void\n handleCheckChange: (\n node: CascaderNode,\n checked: boolean,\n emitClose?: boolean\n ) => void\n}\n\nexport const CASCADER_PANEL_INJECTION_KEY: InjectionKey<ElCascaderPanelContext> =\n Symbol()\n"],"mappings":";;AAkFA,MAAa,+BACX,QAAQ"}

View File

@@ -0,0 +1,8 @@
import Node from "./node.js";
//#region ../../packages/components/cascader-panel/src/utils.d.ts
declare const getMenuIndex: (el: HTMLElement) => number;
declare const checkNode: (el: HTMLElement) => void;
declare const sortByOriginalOrder: (oldNodes: Node[], newNodes: Node[]) => Node[];
//#endregion
export { checkNode, getMenuIndex, sortByOriginalOrder };

View File

@@ -0,0 +1,35 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require_aria = require("../../../utils/dom/aria.js");
//#region ../../packages/components/cascader-panel/src/utils.ts
const getMenuIndex = (el) => {
if (!el) return 0;
const pieces = el.id.split("-");
return Number(pieces[pieces.length - 2]);
};
const checkNode = (el) => {
if (!el) return;
const input = el.querySelector("input");
if (input) input.click();
else if (require_aria.isLeaf(el)) el.click();
};
const sortByOriginalOrder = (oldNodes, newNodes) => {
const newNodesCopy = newNodes.slice(0);
const newIds = newNodesCopy.map((node) => node.uid);
const res = oldNodes.reduce((acc, item) => {
const index = newIds.indexOf(item.uid);
if (index > -1) {
acc.push(item);
newNodesCopy.splice(index, 1);
newIds.splice(index, 1);
}
return acc;
}, []);
res.push(...newNodesCopy);
return res;
};
//#endregion
exports.checkNode = checkNode;
exports.getMenuIndex = getMenuIndex;
exports.sortByOriginalOrder = sortByOriginalOrder;
//# sourceMappingURL=utils.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"utils.js","names":["isLeaf"],"sources":["../../../../../../packages/components/cascader-panel/src/utils.ts"],"sourcesContent":["import { isLeaf } from '@element-plus/utils'\n\nimport type { CascaderNode } from './types'\n\nexport const getMenuIndex = (el: HTMLElement) => {\n if (!el) return 0\n const pieces = el.id.split('-')\n return Number(pieces[pieces.length - 2])\n}\n\nexport const checkNode = (el: HTMLElement) => {\n if (!el) return\n\n const input = el.querySelector('input')\n if (input) {\n input.click()\n } else if (isLeaf(el)) {\n el.click()\n }\n}\n\nexport const sortByOriginalOrder = (\n oldNodes: CascaderNode[],\n newNodes: CascaderNode[]\n) => {\n const newNodesCopy = newNodes.slice(0)\n const newIds = newNodesCopy.map((node) => node.uid)\n const res = oldNodes.reduce((acc, item) => {\n const index = newIds.indexOf(item.uid)\n if (index > -1) {\n acc.push(item)\n newNodesCopy.splice(index, 1)\n newIds.splice(index, 1)\n }\n return acc\n }, [] as CascaderNode[])\n\n res.push(...newNodesCopy)\n\n return res\n}\n"],"mappings":";;;AAIA,MAAa,gBAAgB,OAAoB;CAC/C,IAAI,CAAC,IAAI,OAAO;CAChB,MAAM,SAAS,GAAG,GAAG,MAAM,IAAI;CAC/B,OAAO,OAAO,OAAO,OAAO,SAAS,GAAG;;AAG1C,MAAa,aAAa,OAAoB;CAC5C,IAAI,CAAC,IAAI;CAET,MAAM,QAAQ,GAAG,cAAc,QAAQ;CACvC,IAAI,OACF,MAAM,OAAO;MACR,IAAIA,aAAAA,OAAO,GAAG,EACnB,GAAG,OAAO;;AAId,MAAa,uBACX,UACA,aACG;CACH,MAAM,eAAe,SAAS,MAAM,EAAE;CACtC,MAAM,SAAS,aAAa,KAAK,SAAS,KAAK,IAAI;CACnD,MAAM,MAAM,SAAS,QAAQ,KAAK,SAAS;EACzC,MAAM,QAAQ,OAAO,QAAQ,KAAK,IAAI;EACtC,IAAI,QAAQ,IAAI;GACd,IAAI,KAAK,KAAK;GACd,aAAa,OAAO,OAAO,EAAE;GAC7B,OAAO,OAAO,OAAO,EAAE;;EAEzB,OAAO;IACN,EAAE,CAAmB;CAExB,IAAI,KAAK,GAAG,aAAa;CAEzB,OAAO"}

View File

@@ -0,0 +1,6 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
require("../../base/style/css.js");
require("../../checkbox/style/css.js");
require("../../radio/style/css.js");
require("../../virtual-list/style/css.js");
require("element-plus/theme-chalk/el-cascader-panel.css");

View File

@@ -0,0 +1,6 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
require("../../base/style/index.js");
require("../../checkbox/style/index.js");
require("../../radio/style/index.js");
require("../../virtual-list/style/index.js");
require("element-plus/theme-chalk/src/cascader-panel.scss");