@teammodlr/ui-kit 2.1.5 → 2.1.6
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/lib/call.d.ts +7 -0
- package/lib/components/confirm/Confirm.vue.d.ts +46 -0
- package/lib/components/{dialog/DialogProvider.vue.d.ts → confirm/ConfirmProvider.vue.d.ts} +5 -5
- package/lib/components/{dialog → confirm}/props.d.ts +2 -2
- package/lib/components/confirm/types.d.ts +27 -0
- package/lib/components/confirm/useConfirm.d.ts +2 -0
- package/lib/components/dialog/Dialog.vue.d.ts +90 -41
- package/lib/components/dialog/style/Dialog.css.d.ts +11 -0
- package/lib/components/dialog/style/index.d.ts +1 -0
- package/lib/components/dialog/types.d.ts +0 -27
- package/lib/components/index.d.ts +3 -1
- package/lib/components/tree/Tree.vue.d.ts +103 -0
- package/lib/components/tree/TreeNode.vue.d.ts +18 -0
- package/lib/components/tree/props.d.ts +70 -0
- package/lib/components/tree/types.d.ts +53 -0
- package/lib/composables/index.d.ts +1 -1
- package/lib/composables/useMergedState.d.ts +2 -0
- package/lib/index.cjs.js +18 -2
- package/lib/index.es.js +4688 -2817
- package/lib/style.css +1 -1
- package/lib/utils/injection.d.ts +2 -0
- package/package.json +6 -4
- package/src/call.ts +34 -0
- package/src/components/confirm/Confirm.vue +60 -0
- package/src/components/{dialog/DialogProvider.vue → confirm/ConfirmProvider.vue} +18 -18
- package/src/components/confirm/examples/basic.vue +48 -0
- package/src/components/confirm/examples/index.stories.ts +29 -0
- package/src/components/confirm/examples/index.ts +1 -0
- package/src/components/{dialog → confirm}/props.ts +2 -2
- package/src/components/confirm/types.ts +34 -0
- package/src/components/confirm/useConfirm.ts +12 -0
- package/src/components/dialog/Dialog.vue +102 -44
- package/src/components/dialog/examples/basic.vue +8 -40
- package/src/components/dialog/examples/index.stories.ts +11 -22
- package/src/components/dialog/examples/index.ts +1 -1
- package/src/components/dialog/style/Dialog.css.ts +99 -0
- package/src/components/dialog/style/index.ts +1 -0
- package/src/components/dialog/types.ts +0 -34
- package/src/components/index.ts +3 -1
- package/src/components/select/Select.vue +4 -0
- package/src/components/tree/Tree.vue +126 -0
- package/src/components/tree/TreeNode.vue +71 -0
- package/src/components/tree/examples/basic.vue +33 -0
- package/src/components/tree/examples/index.stories.ts +16 -0
- package/src/components/tree/examples/index.ts +1 -0
- package/src/components/tree/props.ts +87 -0
- package/src/components/tree/types.ts +96 -0
- package/src/composables/index.ts +1 -1
- package/src/composables/useMergedState.ts +18 -0
- package/src/utils/injection.ts +5 -0
- package/lib/components/dialog/useDialog.d.ts +0 -2
- package/src/components/dialog/useDialog.ts +0 -12
- /package/lib/components/{dialog → confirm}/providerProps.d.ts +0 -0
- /package/src/components/{dialog → confirm}/examples/wrapper.vue +0 -0
- /package/src/components/{dialog → confirm}/providerProps.ts +0 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type {ExtractPublicPropTypes, PropType} from "vue";
|
|
2
|
+
import type {TreeOptions, Key, TreeNodeProps, OnUpdateIndeterminateKeys, onUpdateExpandedKeys} from "./types";
|
|
3
|
+
import type {TreeMateOptions} from "treemate";
|
|
4
|
+
import type {MaybeArray} from "../../call";
|
|
5
|
+
|
|
6
|
+
export const treeSharedProps = {
|
|
7
|
+
expandedKeys: Array as PropType<Key[]>,
|
|
8
|
+
defaultExpandAll: Boolean,
|
|
9
|
+
keyField: {
|
|
10
|
+
type: String,
|
|
11
|
+
default: 'key',
|
|
12
|
+
},
|
|
13
|
+
labelField: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: 'label',
|
|
16
|
+
},
|
|
17
|
+
childrenField: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: 'children',
|
|
20
|
+
},
|
|
21
|
+
onUpdateIndeterminateKeys: [Function, Array] as PropType<
|
|
22
|
+
MaybeArray<OnUpdateIndeterminateKeys>
|
|
23
|
+
>,
|
|
24
|
+
'onUpdate:indeterminateKeys': [Function, Array] as PropType<
|
|
25
|
+
MaybeArray<OnUpdateIndeterminateKeys>
|
|
26
|
+
>,
|
|
27
|
+
onUpdateExpandedKeys: [Function, Array] as PropType<
|
|
28
|
+
MaybeArray<onUpdateExpandedKeys>
|
|
29
|
+
>,
|
|
30
|
+
'onUpdate:expandedKeys': [Function, Array] as PropType<
|
|
31
|
+
MaybeArray<onUpdateExpandedKeys>
|
|
32
|
+
>
|
|
33
|
+
} as const;
|
|
34
|
+
|
|
35
|
+
export const treeProps= {
|
|
36
|
+
data: {
|
|
37
|
+
type: Array as PropType<TreeOptions>,
|
|
38
|
+
default: () => []
|
|
39
|
+
},
|
|
40
|
+
checkedKeys: Array as PropType<Key[]>,
|
|
41
|
+
defaultCheckedKeys: {
|
|
42
|
+
type: Array as PropType<Key[]>,
|
|
43
|
+
default: () => []
|
|
44
|
+
},
|
|
45
|
+
selectedKeys: Array as PropType<Key[]>,
|
|
46
|
+
defaultSelectedKeys: {
|
|
47
|
+
type: Array as PropType<Key[]>,
|
|
48
|
+
default: () => []
|
|
49
|
+
},
|
|
50
|
+
multiple: Boolean,
|
|
51
|
+
indent: {
|
|
52
|
+
type: Number,
|
|
53
|
+
default: 16
|
|
54
|
+
},
|
|
55
|
+
expandOnClick: Boolean,
|
|
56
|
+
virtualScroll: Boolean,
|
|
57
|
+
nodeProps: Function as PropType<TreeNodeProps>,
|
|
58
|
+
getChildren: Function as PropType<GetChildren>,
|
|
59
|
+
...treeSharedProps,
|
|
60
|
+
} as const;
|
|
61
|
+
|
|
62
|
+
export type TreeProps = ExtractPublicPropTypes<typeof treeProps>;
|
|
63
|
+
export type GetChildren = (option: any) => unknown
|
|
64
|
+
|
|
65
|
+
export function createTreeMateOptions<T> (
|
|
66
|
+
keyField: string,
|
|
67
|
+
childrenField: string,
|
|
68
|
+
disabledField: string,
|
|
69
|
+
getChildren: GetChildren | undefined,
|
|
70
|
+
): TreeMateOptions<T, T, T> {
|
|
71
|
+
const settledGetChildren: GetChildren = getChildren || ((node: T) => {
|
|
72
|
+
return (node as any)[childrenField]
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
getIsGroup() {
|
|
77
|
+
return false;
|
|
78
|
+
},
|
|
79
|
+
getKey(node: T) {
|
|
80
|
+
return (node as any)[keyField]
|
|
81
|
+
},
|
|
82
|
+
getChildren: settledGetChildren,
|
|
83
|
+
getDisabled(node: T) {
|
|
84
|
+
return !!((node as any)[disabledField]);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type {HTMLAttributes, Ref, InjectionKey} from "vue";
|
|
2
|
+
import type {TreeNode} from "treemate";
|
|
3
|
+
import {createInjectionKey} from "../../utils/injection";
|
|
4
|
+
|
|
5
|
+
export type Key = string | number
|
|
6
|
+
|
|
7
|
+
export interface TreeOptionBase {
|
|
8
|
+
key?: Key,
|
|
9
|
+
label?: string,
|
|
10
|
+
children?: TreeOption[]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type TreeOption = TreeOptionBase & Record<string, unknown>;
|
|
14
|
+
export type TreeOptions = TreeOption[];
|
|
15
|
+
|
|
16
|
+
export type TreeNodeProps = (info: {
|
|
17
|
+
option: TreeOption,
|
|
18
|
+
}) => HTMLAttributes & Record<string, unknown>;
|
|
19
|
+
|
|
20
|
+
export interface TreeInjection {
|
|
21
|
+
indentRef: Ref<number>,
|
|
22
|
+
expandOnClickRef: Ref<boolean>,
|
|
23
|
+
nodePropsRef: Ref<TreeNodeProps | undefined>,
|
|
24
|
+
handleSwitcherClick: (node: TreeNode<TreeOption>) => void
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const treeInjectionKey = createInjectionKey<TreeInjection>('tree')
|
|
28
|
+
|
|
29
|
+
export type TmNode = TreeNode<TreeOption>
|
|
30
|
+
|
|
31
|
+
export type OnUpdateCheckedKeys = (
|
|
32
|
+
value: Array<string & number>,
|
|
33
|
+
option: Array<TreeOption | null>,
|
|
34
|
+
meta: {
|
|
35
|
+
node: TreeOption | null
|
|
36
|
+
action: 'check' | 'uncheck'
|
|
37
|
+
}
|
|
38
|
+
) => void
|
|
39
|
+
export type OnUpdateCheckedKeysImpl = (
|
|
40
|
+
value: Key[],
|
|
41
|
+
option: Array<TreeOption | null>,
|
|
42
|
+
meta: {
|
|
43
|
+
node: TreeOption | null
|
|
44
|
+
action: 'check' | 'uncheck'
|
|
45
|
+
}
|
|
46
|
+
) => void
|
|
47
|
+
export type OnUpdateIndeterminateKeys = (
|
|
48
|
+
value: Array<string & number>,
|
|
49
|
+
option: Array<TreeOption | null>
|
|
50
|
+
) => void
|
|
51
|
+
export type OnUpdateIndeterminateKeysImpl = (
|
|
52
|
+
value: Key[],
|
|
53
|
+
option: Array<TreeOption | null>
|
|
54
|
+
) => void
|
|
55
|
+
export type OnUpdateSelectedKeys = (
|
|
56
|
+
value: Array<string & number>,
|
|
57
|
+
option: Array<TreeOption | null>,
|
|
58
|
+
meta: {
|
|
59
|
+
node: TreeOption | null
|
|
60
|
+
action: 'select' | 'unselect'
|
|
61
|
+
}
|
|
62
|
+
) => void
|
|
63
|
+
export type OnUpdateSelectedKeysImpl = (
|
|
64
|
+
value: Key[],
|
|
65
|
+
option: Array<TreeOption | null>,
|
|
66
|
+
meta: {
|
|
67
|
+
node: TreeOption | null
|
|
68
|
+
action: 'select' | 'unselect'
|
|
69
|
+
}
|
|
70
|
+
) => void
|
|
71
|
+
export type onUpdateExpandedKeys = (
|
|
72
|
+
value: Array<string & number>,
|
|
73
|
+
option: Array<TreeOption | null>,
|
|
74
|
+
meta:
|
|
75
|
+
| {
|
|
76
|
+
node: TreeOption
|
|
77
|
+
action: 'expand' | 'collapse'
|
|
78
|
+
}
|
|
79
|
+
| {
|
|
80
|
+
node: null
|
|
81
|
+
action: 'filter'
|
|
82
|
+
}
|
|
83
|
+
) => void
|
|
84
|
+
export type OnUpdateExpandedKeysImpl = (
|
|
85
|
+
value: Key[],
|
|
86
|
+
option: Array<TreeOption | null>,
|
|
87
|
+
meta:
|
|
88
|
+
| {
|
|
89
|
+
node: TreeOption
|
|
90
|
+
action: 'expand' | 'collapse'
|
|
91
|
+
}
|
|
92
|
+
| {
|
|
93
|
+
node: null
|
|
94
|
+
action: 'filter'
|
|
95
|
+
}
|
|
96
|
+
) => void
|
package/src/composables/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { useMessage } from '../components/messageprovider/useMessage';
|
|
2
|
-
export {
|
|
2
|
+
export { useConfirm } from '../components/confirm/useConfirm';
|
|
3
3
|
export { usePopper } from './usePopper';
|
|
4
4
|
export { useZIndex } from './useZIndex';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Ref, watch, type ComputedRef, computed } from 'vue'
|
|
2
|
+
|
|
3
|
+
export default function useMergedState<T> (
|
|
4
|
+
controlledStateRef: Ref<T | undefined>,
|
|
5
|
+
uncontrolledStateRef: Ref<T>
|
|
6
|
+
): ComputedRef<T> {
|
|
7
|
+
watch(controlledStateRef, value => {
|
|
8
|
+
if (value !== undefined) {
|
|
9
|
+
uncontrolledStateRef.value = value
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
return computed(() => {
|
|
13
|
+
if (controlledStateRef.value === undefined) {
|
|
14
|
+
return uncontrolledStateRef.value
|
|
15
|
+
}
|
|
16
|
+
return controlledStateRef.value
|
|
17
|
+
})
|
|
18
|
+
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { inject } from 'vue';
|
|
2
|
-
import type { DialogApiInjection } from './types';
|
|
3
|
-
|
|
4
|
-
export function useDialog(): DialogApiInjection {
|
|
5
|
-
const api = inject('m-dialog', null);
|
|
6
|
-
|
|
7
|
-
if (api === null) {
|
|
8
|
-
throw new Error('m-dialog api is not provided, ensure the component is wrapped in <m-dialog-provider />.');
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return api;
|
|
12
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|