@xn-lib/component 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -61
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +9 -81
- package/dist/index.iife.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/types/cascader/CascaderMenu.vue.d.ts +45 -0
- package/dist/types/cascader/CascaderOption.vue.d.ts +20 -0
- package/dist/types/cascader/CascaderSelectMenu.vue.d.ts +38 -0
- package/dist/types/cascader/index.d.ts +6 -0
- package/dist/types/cascader/index.vue.d.ts +90 -0
- package/dist/types/cascader/props.d.ts +119 -0
- package/dist/types/cascader/types.d.ts +69 -0
- package/dist/types/cascader/utils.d.ts +53 -0
- package/dist/types/index.d.ts +9 -0
- package/package.json +1 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export type ValueAtom = string | number;
|
|
2
|
+
export type CascaderValue = ValueAtom | ValueAtom[] | ValueAtom[][];
|
|
3
|
+
export type Key = ValueAtom;
|
|
4
|
+
export interface CascaderOption {
|
|
5
|
+
label?: string;
|
|
6
|
+
value?: ValueAtom;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
children?: CascaderOption[];
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
export type ExpandTrigger = 'hover' | 'click';
|
|
12
|
+
export type CheckStrategy = 'all' | 'parent' | 'child';
|
|
13
|
+
export type Filter = (pattern: string, option: CascaderOption, path: CascaderOption[]) => boolean;
|
|
14
|
+
export type OnLoad = (option: CascaderOption) => Promise<void>;
|
|
15
|
+
export type OnUpdateValue = (value: CascaderValue | null, option: CascaderOption | null | Array<CascaderOption | null>, path: Array<CascaderOption[] | null> | CascaderOption[] | null) => void;
|
|
16
|
+
export interface TreeNode {
|
|
17
|
+
key: Key;
|
|
18
|
+
rawNode: CascaderOption;
|
|
19
|
+
level: number;
|
|
20
|
+
index: number;
|
|
21
|
+
isLeaf: boolean;
|
|
22
|
+
isGroup: boolean;
|
|
23
|
+
ignored: boolean;
|
|
24
|
+
disabled: boolean;
|
|
25
|
+
shallowLoaded: boolean;
|
|
26
|
+
parent: TreeNode | null;
|
|
27
|
+
children?: TreeNode[];
|
|
28
|
+
siblings: TreeNode[];
|
|
29
|
+
}
|
|
30
|
+
export interface CascaderInst {
|
|
31
|
+
focus: () => void;
|
|
32
|
+
blur: () => void;
|
|
33
|
+
getCheckedData: () => {
|
|
34
|
+
keys: Key[];
|
|
35
|
+
options: Array<CascaderOption | null>;
|
|
36
|
+
};
|
|
37
|
+
getIndeterminateData: () => {
|
|
38
|
+
keys: Key[];
|
|
39
|
+
options: Array<CascaderOption | null>;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export interface CascaderContext {
|
|
43
|
+
mergedValue: CascaderValue | null;
|
|
44
|
+
checkedKeys: Key[];
|
|
45
|
+
indeterminateKeys: Key[];
|
|
46
|
+
hoverKeyPath: Key[];
|
|
47
|
+
keyboardKey: Key | null;
|
|
48
|
+
hoverKey: Key | null;
|
|
49
|
+
loadingKeySet: Set<Key>;
|
|
50
|
+
multiple: boolean;
|
|
51
|
+
cascade: boolean;
|
|
52
|
+
checkStrategy: CheckStrategy;
|
|
53
|
+
expandTrigger: ExpandTrigger;
|
|
54
|
+
remote: boolean;
|
|
55
|
+
showCheckbox: boolean;
|
|
56
|
+
labelField: string;
|
|
57
|
+
valueField: string;
|
|
58
|
+
childrenField: string;
|
|
59
|
+
disabledField: string;
|
|
60
|
+
onLoad?: OnLoad;
|
|
61
|
+
updateHoverKey: (key: Key | null) => void;
|
|
62
|
+
updateKeyboardKey: (key: Key | null) => void;
|
|
63
|
+
addLoadingKey: (key: Key) => void;
|
|
64
|
+
deleteLoadingKey: (key: Key) => void;
|
|
65
|
+
doCheck: (key: Key) => boolean;
|
|
66
|
+
doUncheck: (key: Key) => void;
|
|
67
|
+
closeMenu: (returnFocus?: boolean) => void;
|
|
68
|
+
clearPattern: () => void;
|
|
69
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { CascaderOption, TreeNode, Key, CheckStrategy } from './types';
|
|
2
|
+
export declare function createTreeMate(options: CascaderOption[], config: {
|
|
3
|
+
getKey: (node: CascaderOption) => Key;
|
|
4
|
+
getChildren: (node: CascaderOption) => CascaderOption[] | undefined;
|
|
5
|
+
getDisabled: (node: CascaderOption) => boolean;
|
|
6
|
+
}): {
|
|
7
|
+
treeNodes: TreeNode[];
|
|
8
|
+
getNode: (key: Key) => TreeNode | null;
|
|
9
|
+
getPath: (key: Key | null) => {
|
|
10
|
+
treeNodePath: TreeNode[];
|
|
11
|
+
keyPath: Key[];
|
|
12
|
+
treeNode: TreeNode | null;
|
|
13
|
+
};
|
|
14
|
+
getCheckedKeys: (keys: Key[], options: {
|
|
15
|
+
cascade: boolean;
|
|
16
|
+
checkStrategy: CheckStrategy;
|
|
17
|
+
allowNotLoaded?: boolean;
|
|
18
|
+
}) => {
|
|
19
|
+
checkedKeys: Key[];
|
|
20
|
+
indeterminateKeys: Key[];
|
|
21
|
+
};
|
|
22
|
+
check: (key: Key, checkedKeys: Key[], options: {
|
|
23
|
+
cascade: boolean;
|
|
24
|
+
checkStrategy: CheckStrategy;
|
|
25
|
+
allowNotLoaded?: boolean;
|
|
26
|
+
}) => {
|
|
27
|
+
checkedKeys: Key[];
|
|
28
|
+
};
|
|
29
|
+
uncheck: (key: Key, checkedKeys: Key[], options: {
|
|
30
|
+
cascade: boolean;
|
|
31
|
+
checkStrategy: CheckStrategy;
|
|
32
|
+
allowNotLoaded?: boolean;
|
|
33
|
+
}) => {
|
|
34
|
+
checkedKeys: Key[];
|
|
35
|
+
};
|
|
36
|
+
getPrev: (key: Key, options: {
|
|
37
|
+
loop: boolean;
|
|
38
|
+
}) => TreeNode | null;
|
|
39
|
+
getNext: (key: Key, options: {
|
|
40
|
+
loop: boolean;
|
|
41
|
+
}) => TreeNode | null;
|
|
42
|
+
getChild: (key: Key) => TreeNode | null;
|
|
43
|
+
getParent: (key: Key) => TreeNode | null;
|
|
44
|
+
getFirstAvailableNode: () => TreeNode | null;
|
|
45
|
+
};
|
|
46
|
+
export declare function getRawNodePath(tmNodes: TreeNode[] | undefined): CascaderOption[] | null;
|
|
47
|
+
export declare function getPathLabel(node: TreeNode | null, separator: string, labelField: string): string;
|
|
48
|
+
export declare function createSelectOptions(tmNodes: TreeNode[], checkStrategyIsChild: boolean, labelField: string, separator: string): Array<{
|
|
49
|
+
label: string;
|
|
50
|
+
value: Key;
|
|
51
|
+
rawNode: CascaderOption;
|
|
52
|
+
path: CascaderOption[];
|
|
53
|
+
}>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Plugin } from 'vue';
|
|
2
|
+
import Cascader from './cascader/index';
|
|
3
|
+
import type { Component } from 'vue';
|
|
4
|
+
export { Cascader };
|
|
5
|
+
export declare const components: Record<string, Component>;
|
|
6
|
+
export type { CascaderProps } from './cascader/props';
|
|
7
|
+
export type { CascaderOption, CascaderValue, CascaderInst, ExpandTrigger, CheckStrategy, Filter, OnLoad, ValueAtom, Key, TreeNode, OnUpdateValue } from './cascader/types';
|
|
8
|
+
declare const plugin: Plugin;
|
|
9
|
+
export default plugin;
|