feat: initial commit - Phase 1 & 2 core features

This commit is contained in:
hiderfong
2026-04-22 17:07:33 +08:00
commit 1773bda06b
25005 changed files with 6252106 additions and 0 deletions
@@ -0,0 +1,13 @@
import { SFCWithInstall } from "../../utils/vue/typescript.js";
import { Nullable } from "../../utils/typescript.js";
import "../../utils/index.js";
import { Node } from "./src/node.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 { CascaderMenuInstance, CascaderPanelInstance } from "./src/instance.js";
import { CascaderCommonProps, CascaderPanelProps, CommonProps, DefaultProps, cascaderPanelEmits, cascaderPanelProps, useCascaderConfig } from "./src/config.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_INJECTION_KEY, 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 };
@@ -0,0 +1,19 @@
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_INJECTION_KEY = require_types.CASCADER_PANEL_INJECTION_KEY;
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
@@ -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,4BAAYC,sBAAc"}
@@ -0,0 +1,83 @@
import { EpPropFinalized, EpPropMergeType } from "../../../utils/vue/props/types.js";
import "../../../utils/index.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;
}
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>;
};
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>;
};
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 { CascaderCommonProps, CascaderPanelProps, CommonProps, DefaultProps, cascaderPanelEmits, cascaderPanelProps, useCascaderConfig };
@@ -0,0 +1,73 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = 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
const CommonProps = require_runtime$1.buildProps({
modelValue: { type: require_runtime$1.definePropType([
Number,
String,
Array,
Object
]) },
options: {
type: require_runtime$1.definePropType(Array),
default: () => []
},
props: {
type: require_runtime$1.definePropType(Object),
default: () => ({})
}
});
const DefaultProps = {
expandTrigger: "click",
multiple: false,
checkStrictly: false,
emitPath: true,
lazy: false,
lazyLoad: _vue_shared.NOOP,
value: "value",
label: "label",
children: "children",
leaf: "leaf",
disabled: "disabled",
hoverThreshold: 500,
checkOnClickNode: false,
checkOnClickLeaf: true,
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.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
@@ -0,0 +1,9 @@
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const require_index_vue_vue_type_script_setup_true_lang = require('./index.vue_vue_type_script_setup_true_lang.js');
//#region ../../packages/components/cascader-panel/src/index.vue
var src_default = require_index_vue_vue_type_script_setup_true_lang.default;
//#endregion
exports.default = src_default;
//# sourceMappingURL=index.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,293 @@
import { Node } from "./node.js";
import { CascaderNodePathValue, CascaderNodeValue, CascaderOption, CascaderProps, CascaderValue, ExpandTrigger, LazyLoad, isDisabled, isLeaf } from "./types.js";
import { CascaderMenuInstance } from "./instance.js";
import { CascaderPanelProps } from "./config.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: any[];
readonly pathValues: CascaderNodeValue[];
readonly pathLabels: string[];
childrenData: {
[x: string]: unknown;
label?: string | undefined;
value?: CascaderNodeValue | undefined;
children?: any[] | undefined;
disabled?: boolean | undefined;
leaf?: boolean | undefined;
}[] | undefined;
children: any[];
text: string;
loaded: boolean;
checked: boolean;
indeterminate: boolean;
loading: boolean;
readonly data: {
[x: string]: unknown;
label?: string | undefined;
value?: CascaderNodeValue | undefined;
children?: 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?: 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: any[];
readonly pathValues: CascaderNodeValue[];
readonly pathLabels: string[];
childrenData: {
[x: string]: unknown;
label?: string | undefined;
value?: CascaderNodeValue | undefined;
children?: any[] | undefined;
disabled?: boolean | undefined;
leaf?: boolean | undefined;
}[] | undefined;
children: any[];
text: string;
loaded: boolean;
checked: boolean;
indeterminate: boolean;
loading: boolean;
readonly data: {
[x: string]: unknown;
label?: string | undefined;
value?: CascaderNodeValue | undefined;
children?: 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?: 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: any[];
readonly pathValues: CascaderNodeValue[];
readonly pathLabels: string[];
childrenData: {
[x: string]: unknown;
label?: string | undefined;
value?: CascaderNodeValue | undefined;
children?: any[] | undefined;
disabled?: boolean | undefined;
leaf?: boolean | undefined;
}[] | undefined;
children: any[];
text: string;
loaded: boolean;
checked: boolean;
indeterminate: boolean;
loading: boolean;
readonly data: {
[x: string]: unknown;
label?: string | undefined;
value?: CascaderNodeValue | undefined;
children?: 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?: 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: any[];
readonly pathValues: CascaderNodeValue[];
readonly pathLabels: string[];
childrenData: {
[x: string]: unknown;
label?: string | undefined;
value?: CascaderNodeValue | undefined;
children?: any[] | undefined;
disabled?: boolean | undefined;
leaf?: boolean | undefined;
}[] | undefined;
children: any[];
text: string;
loaded: boolean;
checked: boolean;
indeterminate: boolean;
loading: boolean;
readonly data: {
[x: string]: unknown;
label?: string | undefined;
value?: CascaderNodeValue | undefined;
children?: 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?: 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<{
onChange?: ((value: CascaderValue | null | undefined) => any) | undefined;
onClose?: (() => any) | undefined;
"onUpdate:modelValue"?: ((value: CascaderValue | null | undefined) => any) | undefined;
"onExpand-change"?: ((value: CascaderNodePathValue) => any) | undefined;
}>, {
props: CascaderProps;
border: boolean;
options: CascaderOption[];
}, {}, {}, {}, 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 };
@@ -0,0 +1,270 @@
const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
const require_aria = require('../../../constants/aria.js');
const require_event = require('../../../constants/event.js');
const require_aria$1 = require('../../../utils/dom/aria.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 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) {
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.EVENT_CODE.up:
case require_aria.EVENT_CODE.down:
e.preventDefault();
require_aria$1.focusNode(require_aria$1.getSibling(target, code === require_aria.EVENT_CODE.up ? -1 : 1, `.${ns.b("node")}[tabindex="-1"]`));
break;
case require_aria.EVENT_CODE.left: {
e.preventDefault();
const expandedNode = menuList.value[require_utils.getMenuIndex(target) - 1]?.$el.querySelector(`.${ns.b("node")}[aria-expanded="true"]`);
require_aria$1.focusNode(expandedNode);
break;
}
case require_aria.EVENT_CODE.right: {
e.preventDefault();
const firstNode = menuList.value[require_utils.getMenuIndex(target) + 1]?.$el.querySelector(`.${ns.b("node")}[tabindex="-1"]`);
require_aria$1.focusNode(firstNode);
break;
}
case require_aria.EVENT_CODE.enter:
case require_aria.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,
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,
getCheckedNodes,
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]
}, {
empty: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "empty")]),
_: 3
}, 8, ["index", "nodes"]);
}), 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
@@ -0,0 +1,8 @@
import { _default } from "./menu.vue.js";
import { _default as _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 };
@@ -0,0 +1 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
@@ -0,0 +1,9 @@
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const require_menu_vue_vue_type_script_setup_true_lang = require('./menu.vue_vue_type_script_setup_true_lang.js');
//#region ../../packages/components/cascader-panel/src/menu.vue
var menu_default = require_menu_vue_vue_type_script_setup_true_lang.default;
//#endregion
exports.default = menu_default;
//# sourceMappingURL=menu.js.map
@@ -0,0 +1 @@
{"version":3,"file":"menu.js","names":[],"sources":["../../../../../../packages/components/cascader-panel/src/menu.vue"],"sourcesContent":["<template>\n <el-scrollbar\n :key=\"menuId\"\n tag=\"ul\"\n role=\"menu\"\n :class=\"ns.b()\"\n :wrap-class=\"ns.e('wrap')\"\n :view-class=\"[ns.e('list'), ns.is('empty', isEmpty)]\"\n @mousemove=\"handleMouseMove\"\n @mouseleave=\"clearHoverZone\"\n >\n <el-cascader-node\n v-for=\"node in nodes\"\n :key=\"node.uid\"\n :node=\"node\"\n :menu-id=\"menuId\"\n @expand=\"handleExpand\"\n />\n <div v-if=\"isLoading\" :class=\"ns.e('empty-text')\">\n <el-icon size=\"14\" :class=\"ns.is('loading')\">\n <loading />\n </el-icon>\n {{ t('el.cascader.loading') }}\n </div>\n <div v-else-if=\"isEmpty\" :class=\"ns.e('empty-text')\">\n <slot name=\"empty\">{{ t('el.cascader.noData') }}</slot>\n </div>\n <!-- eslint-disable vue/html-self-closing -->\n <svg\n v-else-if=\"panel?.isHoverMenu\"\n ref=\"hoverZone\"\n :class=\"ns.e('hover-zone')\"\n ></svg>\n <!-- eslint-enable vue/html-self-closing -->\n </el-scrollbar>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, getCurrentInstance, inject, ref } from 'vue'\nimport ElScrollbar from '@element-plus/components/scrollbar'\nimport { useId, useLocale, useNamespace } from '@element-plus/hooks'\nimport { Loading } from '@element-plus/icons-vue'\nimport ElIcon from '@element-plus/components/icon'\nimport ElCascaderNode from './node.vue'\nimport { CASCADER_PANEL_INJECTION_KEY } from './types'\n\nimport type { CascaderNode } from './types'\nimport type { PropType } from 'vue'\n\ndefineOptions({\n name: 'ElCascaderMenu',\n})\n\nconst props = defineProps({\n nodes: {\n type: Array as PropType<CascaderNode[]>,\n required: true,\n },\n index: {\n type: Number,\n required: true,\n },\n})\n\nconst instance = getCurrentInstance()!\nconst ns = useNamespace('cascader-menu')\n\nconst { t } = useLocale()\nconst id = useId()\nlet activeNode: HTMLElement\nlet hoverTimer: number | undefined\n\nconst panel = inject(CASCADER_PANEL_INJECTION_KEY)!\n\nconst hoverZone = ref<SVGSVGElement>()\n\nconst isEmpty = computed(() => !props.nodes.length)\nconst isLoading = computed(() => !panel.initialLoaded)\nconst menuId = computed(() => `${id.value}-${props.index}`)\n\nconst handleExpand = (e: MouseEvent) => {\n activeNode = e.target as HTMLElement\n}\n\nconst handleMouseMove = (e: MouseEvent) => {\n if (!panel.isHoverMenu || !activeNode || !hoverZone.value) return\n\n if (activeNode.contains(e.target as HTMLElement)) {\n clearHoverTimer()\n\n const el = instance.vnode.el as HTMLElement\n const { left } = el.getBoundingClientRect()\n const { offsetWidth, offsetHeight } = el\n const startX = e.clientX - left\n const top = activeNode.offsetTop\n const bottom = top + activeNode.offsetHeight\n const scrollTop = el.querySelector(`.${ns.e('wrap')}`)?.scrollTop || 0\n\n hoverZone.value.innerHTML = `\n <path style=\"pointer-events: auto;\" fill=\"transparent\" d=\"M${startX} ${top} L${offsetWidth} ${scrollTop} V${top} Z\" />\n <path style=\"pointer-events: auto;\" fill=\"transparent\" d=\"M${startX} ${bottom} L${offsetWidth} ${offsetHeight + scrollTop} V${bottom} Z\" />\n `\n } else if (!hoverTimer) {\n hoverTimer = window.setTimeout(clearHoverZone, panel.config.hoverThreshold)\n }\n}\n\nconst clearHoverTimer = () => {\n if (!hoverTimer) return\n clearTimeout(hoverTimer)\n hoverTimer = undefined\n}\n\nconst clearHoverZone = () => {\n if (!hoverZone.value) return\n hoverZone.value.innerHTML = ''\n clearHoverTimer()\n}\n</script>\n"],"mappings":""}
@@ -0,0 +1,38 @@
import { Node } from "./node.js";
import "./types.js";
import * as vue from "vue";
import { PropType } from "vue";
//#region ../../packages/components/cascader-panel/src/menu.vue.d.ts
declare var __VLS_29: {};
type __VLS_Slots = {} & {
empty?: (props: typeof __VLS_29) => any;
};
declare const __VLS_base: vue.DefineComponent<vue.ExtractPropTypes<{
nodes: {
type: PropType<Node[]>;
required: true;
};
index: {
type: NumberConstructor;
required: true;
};
}>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
nodes: {
type: PropType<Node[]>;
required: true;
};
index: {
type: NumberConstructor;
required: true;
};
}>> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, 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 };
@@ -0,0 +1,120 @@
const require_runtime = require('../../../_virtual/_rolldown/runtime.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');
const require_types = require('./types.js');
const require_node = require('./node2.js');
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
}
},
setup(__props) {
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 isEmpty = (0, vue.computed)(() => !props.nodes.length);
const isLoading = (0, vue.computed)(() => !panel.initialLoaded);
const menuId = (0, vue.computed)(() => `${id.value}-${props.index}`);
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 = 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();
};
return (_ctx, _cache) => {
return (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
@@ -0,0 +1,35 @@
const require_runtime = 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
@@ -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;AAC9C,QAAO,CAAC,2BAAUA,OAAO,GACrBA,OAAOC,OAAO,EAAEC,WAAWA,SAASX,YAAQ,GAC5CS,QAAQE,SAASX;;AAGvB,2BAAeC,yCAAgB;CAC7BW,MAAM;CACNC,OAAO,EACLC,MAAM;EACJH,MAAMI;EACNC,UAAU;EACZ,EACD;CACDC,MAAMJ,OAAO;EACX,MAAMK,KAAKb,2BAAa,gBAAgB;EACxC,MAAM,EAAEc,kCAAyBZ,2CAA8B;EAC/D,MAAM,EAAEO,SAASD;EACjB,MAAM,EAAEO,MAAMC,OAAOC,cAAcR;EAEnC,MAAMO,cAAc;GAClB,MAAME,cAAcJ,gBAAgB;IAAEL;IAAMM;IAAM,CAAC;AACnD,UAAOZ,aAAae,YAAY,GAAGD,YAAaC,eAAeD;;AAEjE,oCAAO,QAAA,EAAA,SAAmBJ,GAAGM,EAAE,QAAO,EAAC,EAAA,CAAGH,OAAO,CAAA,CAAQ;;CAE5D,CAAC"}
@@ -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 };
@@ -0,0 +1,114 @@
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const require_runtime = 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
@@ -0,0 +1,167 @@
const require_runtime = 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: String
},
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
@@ -0,0 +1,9 @@
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const require_node_vue_vue_type_script_setup_true_lang = require('./node.vue_vue_type_script_setup_true_lang.js');
//#region ../../packages/components/cascader-panel/src/node.vue
var node_default = require_node_vue_vue_type_script_setup_true_lang.default;
//#endregion
exports.default = node_default;
//# sourceMappingURL=node2.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,60 @@
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const require_runtime = 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
@@ -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;AACtD,QAAO,MAAM,QAAQ,KAAK,SAAS;AACjC,MAAI,KAAK,OACP,KAAI,KAAK,KAAK;OACT;AACL,IAAC,YAAY,IAAI,KAAK,KAAK;AAC3B,SAAM,IAAI,OAAO,UAAU,KAAK,UAAU,SAAS,CAAC;;AAEtD,SAAO;IACN,EAAE,CAAW;;AAGlB,IAAqB,QAArB,MAA2B;CAKzB,YACE,MACA,AAAS,QACT;EADS;EAET,MAAM,SAAS,QAAQ,EAAE,EAAE,KACxB,aAAa,IAAIA,qBAAK,UAAU,KAAK,OAAO,CAC9C;AACD,OAAK,QAAQ;AACb,OAAK,WAAW,UAAU,OAAO,MAAM;AACvC,OAAK,YAAY,UAAU,OAAO,KAAK;;CAGzC,WAAW;AACT,SAAO,KAAK;;CAGd,gBAAgB,UAAmB;AACjC,SAAO,WAAW,KAAK,YAAY,KAAK;;CAG1C,WAAW,UAA0B,YAAmB;EACtD,MAAM,OAAO,aACT,WAAW,YAAY,SAAS,GAChC,IAAIA,qBAAK,UAAU,KAAK,OAAO;AAEnC,MAAI,CAAC,WAAY,MAAK,MAAM,KAAK,KAAK;AAEtC,OAAK,2BAA2B,KAAK;;CAGvC,YAAY,cAAgC,YAAkB;AAC5D,MAAI,aAAa,SAAS,EACxB,cAAa,SAAS,aAAa,KAAK,WAAW,UAAU,WAAW,CAAC;MAEzE,eAAc,WAAW,UAAU,KAAK,UAAU,KAAK,WAAW;;CAItE,2BAA2B,MAAY;AACrC,OAAK,SAAS,KAAK,KAAK;AACxB,OAAK,UAAU,KAAK,UAAU,KAAK,KAAK;AACxC,MAAI,KAAK,SACP,MAAK,SAAS,SAAS,YAAY;AACjC,QAAK,2BAA2B,QAAQ;IACxC;;CAKN,eACE,OACA,WAAW,OACK;AAChB,MAAIC,2BAAa,MAAM,CAAE,QAAO;AAMhC,SAJa,KAAK,gBAAgB,SAAS,CAAC,MACzC,qCAAiB,KAAK,OAAO,MAAM,gCAAY,KAAK,YAAY,MAAM,CACxE,IAEc;;CAGjB,YAAY,MAA4B;AACtC,MAAI,CAAC,KAAM,QAAO;AAMlB,SAJc,KAAK,gBAAgB,MAAM,CAAC,MACvC,EAAE,OAAO,wCAAoB,KAAK,OAAO,MAAM,IAAI,KAAK,UAAU,MACpE,IAEe"}
@@ -0,0 +1,65 @@
import { Nullable } from "../../../utils/typescript.js";
import "../../../utils/index.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;
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, CascaderNodePathValue, CascaderNodeValue, CascaderOption, CascaderProps, CascaderValue, ElCascaderPanelContext, ExpandTrigger, LazyLoad, RenderLabel, RenderLabelProps, Resolve, Tag, isDisabled, isLeaf };
@@ -0,0 +1,8 @@
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
@@ -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 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":";;;AA+EA,MAAa,+BACX,QAAQ"}
@@ -0,0 +1,36 @@
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
@@ -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;AAC/C,KAAI,CAAC,GAAI,QAAO;CAChB,MAAM,SAAS,GAAG,GAAG,MAAM,IAAI;AAC/B,QAAO,OAAO,OAAO,OAAO,SAAS,GAAG;;AAG1C,MAAa,aAAa,OAAoB;AAC5C,KAAI,CAAC,GAAI;CAET,MAAM,QAAQ,GAAG,cAAc,QAAQ;AACvC,KAAI,MACF,OAAM,OAAO;UACJA,oBAAO,GAAG,CACnB,IAAG,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;AACtC,MAAI,QAAQ,IAAI;AACd,OAAI,KAAK,KAAK;AACd,gBAAa,OAAO,OAAO,EAAE;AAC7B,UAAO,OAAO,OAAO,EAAE;;AAEzB,SAAO;IACN,EAAE,CAAmB;AAExB,KAAI,KAAK,GAAG,aAAa;AAEzB,QAAO"}
@@ -0,0 +1,6 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
require('../../base/style/css.js');
require('../../scrollbar/style/css.js');
require('../../checkbox/style/css.js');
require('../../radio/style/css.js');
require("element-plus/theme-chalk/el-cascader-panel.css");
@@ -0,0 +1,6 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
require('../../base/style/index.js');
require('../../scrollbar/style/index.js');
require('../../checkbox/style/index.js');
require('../../radio/style/index.js');
require("element-plus/theme-chalk/src/cascader-panel.scss");