@teammodlr/ui-kit 2.1.5 → 2.1.7
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 +108 -0
- package/lib/components/tree/TreeNode.vue.d.ts +22 -0
- package/lib/components/tree/TreeNodeToggle.vue.d.ts +26 -0
- package/lib/components/tree/props.d.ts +72 -0
- package/lib/components/tree/types.d.ts +58 -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 +4804 -2847
- 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 +137 -0
- package/src/components/tree/TreeNode.vue +103 -0
- package/src/components/tree/TreeNodeToggle.vue +36 -0
- package/src/components/tree/examples/basic.vue +13 -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 +95 -0
- package/src/components/tree/types.ts +104 -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,36 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
@click="onClick"
|
|
4
|
+
style="width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; vertical-align: bottom;"
|
|
5
|
+
>
|
|
6
|
+
<template v-if="!hide">
|
|
7
|
+
<svg v-if="expanded" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-down"><path d="m6 9 6 6 6-6"/></svg>
|
|
8
|
+
<svg v-else xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-right"><path d="m9 18 6-6-6-6"/></svg>
|
|
9
|
+
</template>
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
import {defineComponent, type PropType} from "vue";
|
|
15
|
+
import type {TmNode} from "./types";
|
|
16
|
+
|
|
17
|
+
export default defineComponent({
|
|
18
|
+
name: "TreeNodeToggle",
|
|
19
|
+
props: {
|
|
20
|
+
expanded: Boolean,
|
|
21
|
+
selected: Boolean,
|
|
22
|
+
onClick: Function as PropType<(e: MouseEvent) => void>,
|
|
23
|
+
hide: Boolean,
|
|
24
|
+
node: {
|
|
25
|
+
type: Object as PropType<TmNode>,
|
|
26
|
+
required: true
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
setup (props) {
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
</script>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<MTree :data="data" label-field="name" key-field="id" @dblclick="dblclick"/>
|
|
3
|
+
</template>
|
|
4
|
+
<script lang="ts" setup>
|
|
5
|
+
import {ref} from 'vue'
|
|
6
|
+
import type {TmNode} from "../../../../lib/components/tree/types";
|
|
7
|
+
|
|
8
|
+
const data = ref([{"children":[{"children":[{"name":"Advertising & Marketing","weight":1,"type":"N","childrenCount":0,"id":"b5511a25-f9d4-402f-9f49-7bb9cff0bd97"},{"children":[],"name":"Finance","weight":1,"type":"N","childrenCount":0,"id":"b21ac382-ae7d-4cb0-b504-10a7ef6eac55"},{"children":[],"name":"Information Technology","weight":1,"type":"N","childrenCount":0,"id":"af71b879-0ea0-4cf6-8b70-4e764f08210b"},{"children":[],"name":"Legal","weight":1,"type":"N","childrenCount":0,"id":"c7d58cb8-d70c-4f70-99fb-7e8fdbb44b80"},{"children":[],"name":"Management","weight":1,"type":"N","childrenCount":0,"id":"2fef19d7-c744-4c36-9066-b077d1641f58"}],"name":"Cost Centers","weight":1,"type":"N","childrenCount":5,"id":"9bb9a4e9-749e-468a-9d39-d98625d8f3a1"},{"children":[{"children":[{"children":[{"children":[],"name":"Brisbane 01","weight":1,"type":"N","childrenCount":0,"id":"3beab845-9660-4cc3-8943-deb5672a72d1"},{"children":[],"name":"Brisbane 02","weight":1,"type":"N","childrenCount":0,"id":"812c3874-2103-4e35-b129-861811e9e582"},{"children":[],"name":"Brisbane 03","weight":1,"type":"N","childrenCount":0,"id":"df622e95-b7d9-41f5-9bd3-473bd0305b02"},{"children":[],"name":"Brisbane 04","weight":1,"type":"N","childrenCount":0,"id":"926b904c-4392-4bbb-b824-acaa1f62bb00"}],"name":"Queensland","weight":1,"type":"N","childrenCount":4,"id":"09661d2c-a90f-4c18-991b-d69500ffbdd5"},{"children":[{"children":[],"name":"Melbourne 01","weight":1,"type":"N","childrenCount":0,"id":"9ac3ce45-1bef-43dc-a3ac-227b1759b720"},{"children":[],"name":"Melbourne 02","weight":1,"type":"N","childrenCount":0,"id":"c66ec03a-431a-43e6-94aa-6b72dae73f98"},{"children":[],"name":"Melbourne 03","weight":1,"type":"N","childrenCount":0,"id":"3177b5e0-1b6e-4c7e-90bd-8e55b85880a4"},{"children":[],"name":"Melbourne 04","weight":1,"type":"N","childrenCount":0,"id":"88a1dd59-1b17-47fe-9a66-710cdff04a4f"},{"children":[],"name":"Melbourne 05","weight":1,"type":"N","childrenCount":0,"id":"400ac864-de9d-4afe-802e-880e41bb227c"}],"name":"Victoria","weight":1,"type":"N","childrenCount":5,"id":"063612b1-2cf3-47a6-a4c3-8fb552146d07"},{"children":[{"children":[],"name":"Sydney 01","weight":1,"type":"N","childrenCount":0,"id":"fed2081a-edf5-4823-bdc8-2860dd6e8a5d"},{"children":[],"name":"Sydney 02","weight":1,"type":"N","childrenCount":0,"id":"1b80744b-f2d3-4bbf-b4e5-63d9318d9538"},{"children":[],"name":"Sydney 03","weight":1,"type":"N","childrenCount":0,"id":"3aa2f7f7-8299-4ac9-95d8-d98f97cddda3"},{"children":[],"name":"Sydney 04","weight":1,"type":"N","childrenCount":0,"id":"657b512c-e77e-495a-bb75-bee4c8cd8ee0"},{"children":[],"name":"Sydney 05","weight":1,"type":"N","childrenCount":0,"id":"da5efcc4-3e88-4b5c-a0c5-7c096c5b83c5"},{"children":[],"name":"Sydney 06","weight":1,"type":"N","childrenCount":0,"id":"10fcae0f-3614-4e44-ace4-0c0423f19952"}],"name":"New South Wales","weight":1,"type":"N","childrenCount":6,"id":"3bdf2a0f-41ef-411c-9749-84301dd8088f"},{"children":[{"children":[],"name":"Perth 01","weight":1,"type":"N","childrenCount":0,"id":"0880d1ac-c7d3-4059-b0a8-25bed41496c7"},{"children":[],"name":"Perth 02","weight":1,"type":"N","childrenCount":0,"id":"0998eb28-769d-4a11-a609-10043a7d482f"}],"name":"Western Australia","weight":1,"type":"N","childrenCount":2,"id":"1b8c1791-fc09-4d2e-b681-cd58f027f2fe"},{"children":[{"children":[],"name":"Darwin 01","weight":1,"type":"N","childrenCount":0,"id":"068e40e2-6fde-4d65-a11c-357f694af697"},{"children":[],"name":"Darwin 02","weight":1,"type":"N","childrenCount":0,"id":"1411b083-7c4e-4810-b92e-372f521f2e7c"},{"children":[],"name":"Darwin 03","weight":1,"type":"N","childrenCount":0,"id":"4684a7ea-aabe-47d2-81fc-00d68196d3f6"},{"children":[],"name":"Darwin 04","weight":1,"type":"N","childrenCount":0,"id":"3fdd5254-639f-4efb-bd40-5c0dc5c1c314"}],"name":"Northern Territory","weight":1,"type":"N","childrenCount":4,"id":"c2ca2fa5-07ce-4529-8745-94567d785736"}],"name":"Australia","weight":1,"type":"N","childrenCount":5,"id":"70a043fc-e70c-4a30-8fbb-7784123c85a5"},{"children":[{"children":[],"name":"Auckland 01","weight":1,"type":"N","childrenCount":0,"id":"6293f121-f50e-42b4-a996-15263c45c3ee"},{"children":[],"name":"Auckland 02","weight":1,"type":"N","childrenCount":0,"id":"2cd3eda8-ab87-46da-8300-27261ee91d68"},{"children":[],"name":"Auckland 03","weight":1,"type":"N","childrenCount":0,"id":"88e6c0ae-e891-4faf-9b62-4270207fea91"},{"children":[],"name":"Wellington 01","weight":1,"type":"N","childrenCount":0,"id":"13ecbd3f-0b53-4a96-8627-07886173c8a6"},{"children":[],"name":"Wellington 02","weight":1,"type":"N","childrenCount":0,"id":"767b982c-ac81-44aa-90a3-b2f276919779"}],"name":"New Zealand","weight":1,"type":"N","childrenCount":5,"id":"c987df16-0757-4d04-97ec-386a423aef8d"},{"children":[],"name":"Online","weight":1,"type":"N","childrenCount":0,"id":"367a3afb-cc66-42d7-a022-f7f92683d768"}],"name":"Profit Centers","weight":1,"type":"N","childrenCount":3,"id":"782c9acf-dfdb-4e60-ace9-0f420aeecae6"}],"name":"All Departments","type":"N","childrenCount":2,"id":"a4b0784f-3d57-4a4d-a849-9700b27e6a6f"}]);
|
|
9
|
+
|
|
10
|
+
function dblclick(node: TmNode) {
|
|
11
|
+
console.log(node);
|
|
12
|
+
}
|
|
13
|
+
</script>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import MTree from "../Tree.vue";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
MTreeBasic
|
|
5
|
+
} from "./index";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
createStory,
|
|
9
|
+
} from "../../../__storybook__";
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
component: MTree,
|
|
13
|
+
title: "Components/Tree"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const Basic = createStory(MTreeBasic)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as MTreeBasic } from './basic.vue';
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type {ExtractPublicPropTypes, PropType} from "vue";
|
|
2
|
+
import type {
|
|
3
|
+
TreeOptions,
|
|
4
|
+
Key,
|
|
5
|
+
TreeNodeProps,
|
|
6
|
+
OnUpdateIndeterminateKeys,
|
|
7
|
+
onUpdateExpandedKeys,
|
|
8
|
+
TreeNodeDoubleClick
|
|
9
|
+
} from "./types";
|
|
10
|
+
import type {TreeMateOptions} from "treemate";
|
|
11
|
+
import type {MaybeArray} from "../../call";
|
|
12
|
+
|
|
13
|
+
export const treeSharedProps = {
|
|
14
|
+
expandedKeys: Array as PropType<Key[]>,
|
|
15
|
+
defaultExpandAll: Boolean,
|
|
16
|
+
keyField: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: 'key',
|
|
19
|
+
},
|
|
20
|
+
labelField: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: 'label',
|
|
23
|
+
},
|
|
24
|
+
childrenField: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: 'children',
|
|
27
|
+
},
|
|
28
|
+
onDblClick: Function as PropType<TreeNodeDoubleClick>,
|
|
29
|
+
onUpdateIndeterminateKeys: [Function, Array] as PropType<
|
|
30
|
+
MaybeArray<OnUpdateIndeterminateKeys>
|
|
31
|
+
>,
|
|
32
|
+
'onUpdate:indeterminateKeys': [Function, Array] as PropType<
|
|
33
|
+
MaybeArray<OnUpdateIndeterminateKeys>
|
|
34
|
+
>,
|
|
35
|
+
onUpdateExpandedKeys: [Function, Array] as PropType<
|
|
36
|
+
MaybeArray<onUpdateExpandedKeys>
|
|
37
|
+
>,
|
|
38
|
+
'onUpdate:expandedKeys': [Function, Array] as PropType<
|
|
39
|
+
MaybeArray<onUpdateExpandedKeys>
|
|
40
|
+
>
|
|
41
|
+
} as const;
|
|
42
|
+
|
|
43
|
+
export const treeProps= {
|
|
44
|
+
data: {
|
|
45
|
+
type: Array as PropType<TreeOptions>,
|
|
46
|
+
default: () => []
|
|
47
|
+
},
|
|
48
|
+
checkedKeys: Array as PropType<Key[]>,
|
|
49
|
+
defaultCheckedKeys: {
|
|
50
|
+
type: Array as PropType<Key[]>,
|
|
51
|
+
default: () => []
|
|
52
|
+
},
|
|
53
|
+
selectedKeys: Array as PropType<Key[]>,
|
|
54
|
+
defaultSelectedKeys: {
|
|
55
|
+
type: Array as PropType<Key[]>,
|
|
56
|
+
default: () => []
|
|
57
|
+
},
|
|
58
|
+
multiple: Boolean,
|
|
59
|
+
indent: {
|
|
60
|
+
type: Number,
|
|
61
|
+
default: 16
|
|
62
|
+
},
|
|
63
|
+
expandOnClick: Boolean,
|
|
64
|
+
virtualScroll: Boolean,
|
|
65
|
+
nodeProps: Function as PropType<TreeNodeProps>,
|
|
66
|
+
getChildren: Function as PropType<GetChildren>,
|
|
67
|
+
...treeSharedProps,
|
|
68
|
+
} as const;
|
|
69
|
+
|
|
70
|
+
export type TreeProps = ExtractPublicPropTypes<typeof treeProps>;
|
|
71
|
+
export type GetChildren = (option: any) => unknown
|
|
72
|
+
|
|
73
|
+
export function createTreeMateOptions<T> (
|
|
74
|
+
keyField: string,
|
|
75
|
+
childrenField: string,
|
|
76
|
+
disabledField: string,
|
|
77
|
+
getChildren: GetChildren | undefined,
|
|
78
|
+
): TreeMateOptions<T, T, T> {
|
|
79
|
+
const settledGetChildren: GetChildren = getChildren || ((node: T) => {
|
|
80
|
+
return (node as any)[childrenField]
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
getIsGroup() {
|
|
85
|
+
return false;
|
|
86
|
+
},
|
|
87
|
+
getKey(node: T) {
|
|
88
|
+
return (node as any)[keyField]
|
|
89
|
+
},
|
|
90
|
+
getChildren: settledGetChildren,
|
|
91
|
+
getDisabled(node: T) {
|
|
92
|
+
return !!((node as any)[disabledField]);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
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 = (
|
|
17
|
+
node: TreeOption,
|
|
18
|
+
) => HTMLAttributes & Record<string, unknown>;
|
|
19
|
+
|
|
20
|
+
export type TreeNodeDoubleClick = (info: {
|
|
21
|
+
option: TreeOption,
|
|
22
|
+
}) => void;
|
|
23
|
+
|
|
24
|
+
export interface TreeInjection {
|
|
25
|
+
mergedExpandedKeysRef: Ref<Key[]>,
|
|
26
|
+
indentRef: Ref<number>,
|
|
27
|
+
expandOnClickRef: Ref<boolean>,
|
|
28
|
+
nodePropsRef: Ref<TreeNodeProps | undefined>,
|
|
29
|
+
labelFieldRef: Ref<string>,
|
|
30
|
+
keyFieldRef: Ref<string>,
|
|
31
|
+
handleToggleClick: (node: TreeNode<TreeOption>) => void,
|
|
32
|
+
handleDoubleClick: (node: TreeOption) => void,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const treeInjectionKey = createInjectionKey<TreeInjection>('tree')
|
|
36
|
+
|
|
37
|
+
export type TmNode = TreeNode<TreeOption>
|
|
38
|
+
|
|
39
|
+
export type OnUpdateCheckedKeys = (
|
|
40
|
+
value: Array<string & number>,
|
|
41
|
+
option: Array<TreeOption | null>,
|
|
42
|
+
meta: {
|
|
43
|
+
node: TreeOption | null
|
|
44
|
+
action: 'check' | 'uncheck'
|
|
45
|
+
}
|
|
46
|
+
) => void
|
|
47
|
+
export type OnUpdateCheckedKeysImpl = (
|
|
48
|
+
value: Key[],
|
|
49
|
+
option: Array<TreeOption | null>,
|
|
50
|
+
meta: {
|
|
51
|
+
node: TreeOption | null
|
|
52
|
+
action: 'check' | 'uncheck'
|
|
53
|
+
}
|
|
54
|
+
) => void
|
|
55
|
+
export type OnUpdateIndeterminateKeys = (
|
|
56
|
+
value: Array<string & number>,
|
|
57
|
+
option: Array<TreeOption | null>
|
|
58
|
+
) => void
|
|
59
|
+
export type OnUpdateIndeterminateKeysImpl = (
|
|
60
|
+
value: Key[],
|
|
61
|
+
option: Array<TreeOption | null>
|
|
62
|
+
) => void
|
|
63
|
+
export type OnUpdateSelectedKeys = (
|
|
64
|
+
value: Array<string & number>,
|
|
65
|
+
option: Array<TreeOption | null>,
|
|
66
|
+
meta: {
|
|
67
|
+
node: TreeOption | null
|
|
68
|
+
action: 'select' | 'unselect'
|
|
69
|
+
}
|
|
70
|
+
) => void
|
|
71
|
+
export type OnUpdateSelectedKeysImpl = (
|
|
72
|
+
value: Key[],
|
|
73
|
+
option: Array<TreeOption | null>,
|
|
74
|
+
meta: {
|
|
75
|
+
node: TreeOption | null
|
|
76
|
+
action: 'select' | 'unselect'
|
|
77
|
+
}
|
|
78
|
+
) => void
|
|
79
|
+
export type onUpdateExpandedKeys = (
|
|
80
|
+
value: Array<string & number>,
|
|
81
|
+
option: Array<TreeOption | null>,
|
|
82
|
+
meta:
|
|
83
|
+
| {
|
|
84
|
+
node: TreeOption
|
|
85
|
+
action: 'expand' | 'collapse'
|
|
86
|
+
}
|
|
87
|
+
| {
|
|
88
|
+
node: null
|
|
89
|
+
action: 'filter'
|
|
90
|
+
}
|
|
91
|
+
) => void
|
|
92
|
+
export type OnUpdateExpandedKeysImpl = (
|
|
93
|
+
value: Key[],
|
|
94
|
+
option: Array<TreeOption | null>,
|
|
95
|
+
meta:
|
|
96
|
+
| {
|
|
97
|
+
node: TreeOption
|
|
98
|
+
action: 'expand' | 'collapse'
|
|
99
|
+
}
|
|
100
|
+
| {
|
|
101
|
+
node: null
|
|
102
|
+
action: 'filter'
|
|
103
|
+
}
|
|
104
|
+
) => 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
|