@meethive/components 0.0.1
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/es/AutoComplete/AutoComplete.js +84 -0
- package/es/AutoComplete/index.js +7 -0
- package/es/BadgeStatus/Badge.js +51 -0
- package/es/BadgeStatus/color.js +14 -0
- package/es/BadgeStatus/index.js +8 -0
- package/es/CardSelect/CardSelect.js +141 -0
- package/es/CardSelect/index.js +7 -0
- package/es/CardSelect/style/index.js +29 -0
- package/es/CheckButton/CheckButton.js +122 -0
- package/es/CheckButton/index.js +7 -0
- package/es/CheckButton/style/index.js +44 -0
- package/es/ConfigProvider/ConfigProvider.js +73 -0
- package/es/ConfigProvider/context.js +26 -0
- package/es/ConfigProvider/index.js +9 -0
- package/es/DragModal/DragModal.js +212 -0
- package/es/DragModal/index.js +7 -0
- package/es/DragModal/style/index.js +86 -0
- package/es/EditTable/Body.js +189 -0
- package/es/EditTable/CellRender.js +12 -0
- package/es/EditTable/EditTable.js +434 -0
- package/es/EditTable/FormItem.js +169 -0
- package/es/EditTable/Group.js +204 -0
- package/es/EditTable/Header.js +63 -0
- package/es/EditTable/HeaderRender.js +12 -0
- package/es/EditTable/components/ContextMenu/Menu.js +86 -0
- package/es/EditTable/components/ContextMenu/index.js +96 -0
- package/es/EditTable/components/Search/Search.js +163 -0
- package/es/EditTable/components/Search/Sort.js +119 -0
- package/es/EditTable/components/Search/index.js +2 -0
- package/es/EditTable/consts.js +13 -0
- package/es/EditTable/context.js +88 -0
- package/es/EditTable/hooks/index.js +19 -0
- package/es/EditTable/hooks/useGroup.js +48 -0
- package/es/EditTable/hooks/useResizeObserver.js +27 -0
- package/es/EditTable/hooks/useValidate.js +112 -0
- package/es/EditTable/index.js +25 -0
- package/es/EditTable/props.js +60 -0
- package/es/EditTable/style/body.js +63 -0
- package/es/EditTable/style/form.js +33 -0
- package/es/EditTable/style/group.js +33 -0
- package/es/EditTable/style/header.js +72 -0
- package/es/EditTable/style/index.js +52 -0
- package/es/EditTable/style/menu.js +27 -0
- package/es/EditTable/style/table.js +46 -0
- package/es/EditTable/utils.js +110 -0
- package/es/Ellipsis/Ellipsis.js +148 -0
- package/es/Ellipsis/index.js +7 -0
- package/es/Ellipsis/style/index.js +26 -0
- package/es/Empty/Empty.js +63 -0
- package/es/Empty/image.js +3 -0
- package/es/Empty/index.js +7 -0
- package/es/FullPage/FullPage.js +19 -0
- package/es/FullPage/index.js +7 -0
- package/es/Icon/Icon.js +49 -0
- package/es/Icon/index.js +7 -0
- package/es/LocaleProvider/LocaleProvider.js +31 -0
- package/es/LocaleProvider/index.js +7 -0
- package/es/LocaleReciver/index.js +24 -0
- package/es/Markdown/Markdown.js +118 -0
- package/es/Markdown/index.js +7 -0
- package/es/PermissionButton/PermissionButton.js +118 -0
- package/es/PermissionButton/confirm.js +94 -0
- package/es/PermissionButton/index.js +9 -0
- package/es/PermissionButton/shared.js +1 -0
- package/es/ProLayout/Basic/BasicLayout.js +422 -0
- package/es/ProLayout/Basic/BasicLayoutStyle.js +51 -0
- package/es/ProLayout/Basic/Header.js +111 -0
- package/es/ProLayout/Basic/HeaderStyle.js +10 -0
- package/es/ProLayout/PageContainer/index.js +354 -0
- package/es/ProLayout/PageContainer/style.js +85 -0
- package/es/ProLayout/RouteContext.js +28 -0
- package/es/ProLayout/SiderMenu/BaseMenu.js +241 -0
- package/es/ProLayout/SiderMenu/SiderMenu.js +274 -0
- package/es/ProLayout/SiderMenu/index.js +2 -0
- package/es/ProLayout/SiderMenu/style.js +204 -0
- package/es/ProLayout/TopHeader/index.js +170 -0
- package/es/ProLayout/TopHeader/style.js +154 -0
- package/es/ProLayout/defaultSettings.js +113 -0
- package/es/ProLayout/index.js +10 -0
- package/es/ProLayout/style/index.js +14 -0
- package/es/ProLayout/util.js +58 -0
- package/es/ProTable/Alert.js +40 -0
- package/es/ProTable/Content.js +97 -0
- package/es/ProTable/Header.js +33 -0
- package/es/ProTable/Pagination.js +55 -0
- package/es/ProTable/ProTable.js +279 -0
- package/es/ProTable/hooks/index.js +2 -0
- package/es/ProTable/hooks/useTableInject.js +6 -0
- package/es/ProTable/hooks/useTableSelection.js +115 -0
- package/es/ProTable/index.js +8 -0
- package/es/ProTable/setting.js +138 -0
- package/es/ProTable/style/index.js +113 -0
- package/es/RadioButton/RadioButton.js +53 -0
- package/es/RadioButton/index.js +8 -0
- package/es/RadioButton/style/index.js +25 -0
- package/es/Scrollbar/Bar.js +76 -0
- package/es/Scrollbar/Scrollbar.js +161 -0
- package/es/Scrollbar/Thumb.js +150 -0
- package/es/Scrollbar/constants.js +1 -0
- package/es/Scrollbar/index.js +7 -0
- package/es/Scrollbar/scrollbarProps.js +100 -0
- package/es/Scrollbar/style/index.js +85 -0
- package/es/Scrollbar/thumbProps.js +10 -0
- package/es/Scrollbar/util.js +39 -0
- package/es/Search/Item.js +239 -0
- package/es/Search/Search.js +90 -0
- package/es/Search/hooks/index.js +117 -0
- package/es/Search/hooks/useRouteQuery.js +86 -0
- package/es/Search/hooks/useSearchItems.js +50 -0
- package/es/Search/hooks/useTermOptions.js +29 -0
- package/es/Search/index.js +10 -0
- package/es/Search/setting.js +245 -0
- package/es/Search/style/index.js +5 -0
- package/es/Search/style/item.js +40 -0
- package/es/Search/style/search.js +177 -0
- package/es/Search/util.js +270 -0
- package/es/Skeleton/Skeleton.js +27 -0
- package/es/Skeleton/components/DashBoardCard.js +27 -0
- package/es/Skeleton/components/DashBoardChart.js +27 -0
- package/es/Skeleton/components/Detail.js +27 -0
- package/es/Skeleton/components/Drawer.js +27 -0
- package/es/Skeleton/components/Item.js +54 -0
- package/es/Skeleton/components/List.js +27 -0
- package/es/Skeleton/components/ListCard.js +28 -0
- package/es/Skeleton/components/ListCardItem.js +20 -0
- package/es/Skeleton/components/ListTable.js +27 -0
- package/es/Skeleton/components/Page.js +26 -0
- package/es/Skeleton/components/Search.js +16 -0
- package/es/Skeleton/components/Tree.js +27 -0
- package/es/Skeleton/index.js +28 -0
- package/es/Skeleton/style/index.js +195 -0
- package/es/TimeFormat/TimeFormat.js +36 -0
- package/es/TimeFormat/index.js +7 -0
- package/es/Title/Title.js +26 -0
- package/es/Title/index.js +7 -0
- package/es/Title/style/index.js +34 -0
- package/es/ValueItem/ValueItem.js +113 -0
- package/es/ValueItem/index.js +7 -0
- package/es/ValueItem/util.js +17 -0
- package/es/VirtualTable/VirtualTable.js +271 -0
- package/es/VirtualTable/data.js +60 -0
- package/es/VirtualTable/index.js +7 -0
- package/es/VirtualTable/style/index.js +34 -0
- package/es/components.js +21 -0
- package/es/index.js +17 -0
- package/es/locale/en-US.js +120 -0
- package/es/locale/zh-CN.js +120 -0
- package/es/style/styleRegister.js +19 -0
- package/es/style/variable.js +4 -0
- package/es/style.js +1 -0
- package/es/utils/constants.js +10 -0
- package/lib/AutoComplete/AutoComplete.js +84 -0
- package/lib/AutoComplete/index.js +7 -0
- package/lib/BadgeStatus/Badge.js +51 -0
- package/lib/BadgeStatus/color.js +14 -0
- package/lib/BadgeStatus/index.js +8 -0
- package/lib/CardSelect/CardSelect.js +141 -0
- package/lib/CardSelect/index.js +7 -0
- package/lib/CardSelect/style/index.js +29 -0
- package/lib/CheckButton/CheckButton.js +122 -0
- package/lib/CheckButton/index.js +7 -0
- package/lib/CheckButton/style/index.js +44 -0
- package/lib/ConfigProvider/ConfigProvider.js +73 -0
- package/lib/ConfigProvider/context.js +26 -0
- package/lib/ConfigProvider/index.js +9 -0
- package/lib/DragModal/DragModal.js +212 -0
- package/lib/DragModal/index.js +7 -0
- package/lib/DragModal/style/index.js +86 -0
- package/lib/EditTable/Body.js +189 -0
- package/lib/EditTable/CellRender.js +12 -0
- package/lib/EditTable/EditTable.js +434 -0
- package/lib/EditTable/FormItem.js +169 -0
- package/lib/EditTable/Group.js +204 -0
- package/lib/EditTable/Header.js +63 -0
- package/lib/EditTable/HeaderRender.js +12 -0
- package/lib/EditTable/components/ContextMenu/Menu.js +86 -0
- package/lib/EditTable/components/ContextMenu/index.js +96 -0
- package/lib/EditTable/components/Search/Search.js +163 -0
- package/lib/EditTable/components/Search/Sort.js +119 -0
- package/lib/EditTable/components/Search/index.js +2 -0
- package/lib/EditTable/consts.js +13 -0
- package/lib/EditTable/context.js +88 -0
- package/lib/EditTable/hooks/index.js +19 -0
- package/lib/EditTable/hooks/useGroup.js +48 -0
- package/lib/EditTable/hooks/useResizeObserver.js +27 -0
- package/lib/EditTable/hooks/useValidate.js +112 -0
- package/lib/EditTable/index.js +25 -0
- package/lib/EditTable/props.js +60 -0
- package/lib/EditTable/style/body.js +63 -0
- package/lib/EditTable/style/form.js +33 -0
- package/lib/EditTable/style/group.js +33 -0
- package/lib/EditTable/style/header.js +72 -0
- package/lib/EditTable/style/index.js +52 -0
- package/lib/EditTable/style/menu.js +27 -0
- package/lib/EditTable/style/table.js +46 -0
- package/lib/EditTable/utils.js +110 -0
- package/lib/Ellipsis/Ellipsis.js +148 -0
- package/lib/Ellipsis/index.js +7 -0
- package/lib/Ellipsis/style/index.js +26 -0
- package/lib/Empty/Empty.js +63 -0
- package/lib/Empty/image.js +3 -0
- package/lib/Empty/index.js +7 -0
- package/lib/FullPage/FullPage.js +19 -0
- package/lib/FullPage/index.js +7 -0
- package/lib/Icon/Icon.js +49 -0
- package/lib/Icon/index.js +7 -0
- package/lib/LocaleProvider/LocaleProvider.js +31 -0
- package/lib/LocaleProvider/index.js +7 -0
- package/lib/LocaleReciver/index.js +24 -0
- package/lib/Markdown/Markdown.js +118 -0
- package/lib/Markdown/index.js +7 -0
- package/lib/PermissionButton/PermissionButton.js +118 -0
- package/lib/PermissionButton/confirm.js +94 -0
- package/lib/PermissionButton/index.js +9 -0
- package/lib/PermissionButton/shared.js +1 -0
- package/lib/ProLayout/Basic/BasicLayout.js +422 -0
- package/lib/ProLayout/Basic/BasicLayoutStyle.js +51 -0
- package/lib/ProLayout/Basic/Header.js +111 -0
- package/lib/ProLayout/Basic/HeaderStyle.js +10 -0
- package/lib/ProLayout/PageContainer/index.js +354 -0
- package/lib/ProLayout/PageContainer/style.js +85 -0
- package/lib/ProLayout/RouteContext.js +28 -0
- package/lib/ProLayout/SiderMenu/BaseMenu.js +241 -0
- package/lib/ProLayout/SiderMenu/SiderMenu.js +274 -0
- package/lib/ProLayout/SiderMenu/index.js +2 -0
- package/lib/ProLayout/SiderMenu/style.js +204 -0
- package/lib/ProLayout/TopHeader/index.js +170 -0
- package/lib/ProLayout/TopHeader/style.js +154 -0
- package/lib/ProLayout/defaultSettings.js +113 -0
- package/lib/ProLayout/index.js +10 -0
- package/lib/ProLayout/style/index.js +14 -0
- package/lib/ProLayout/util.js +58 -0
- package/lib/ProTable/Alert.js +40 -0
- package/lib/ProTable/Content.js +97 -0
- package/lib/ProTable/Header.js +33 -0
- package/lib/ProTable/Pagination.js +55 -0
- package/lib/ProTable/ProTable.js +279 -0
- package/lib/ProTable/hooks/index.js +2 -0
- package/lib/ProTable/hooks/useTableInject.js +6 -0
- package/lib/ProTable/hooks/useTableSelection.js +115 -0
- package/lib/ProTable/index.js +8 -0
- package/lib/ProTable/setting.js +138 -0
- package/lib/ProTable/style/index.js +113 -0
- package/lib/RadioButton/RadioButton.js +53 -0
- package/lib/RadioButton/index.js +8 -0
- package/lib/RadioButton/style/index.js +25 -0
- package/lib/Scrollbar/Bar.js +76 -0
- package/lib/Scrollbar/Scrollbar.js +161 -0
- package/lib/Scrollbar/Thumb.js +150 -0
- package/lib/Scrollbar/constants.js +1 -0
- package/lib/Scrollbar/index.js +7 -0
- package/lib/Scrollbar/scrollbarProps.js +100 -0
- package/lib/Scrollbar/style/index.js +85 -0
- package/lib/Scrollbar/thumbProps.js +10 -0
- package/lib/Scrollbar/util.js +39 -0
- package/lib/Search/Item.js +239 -0
- package/lib/Search/Search.js +90 -0
- package/lib/Search/hooks/index.js +117 -0
- package/lib/Search/hooks/useRouteQuery.js +86 -0
- package/lib/Search/hooks/useSearchItems.js +50 -0
- package/lib/Search/hooks/useTermOptions.js +29 -0
- package/lib/Search/index.js +10 -0
- package/lib/Search/setting.js +245 -0
- package/lib/Search/style/index.js +5 -0
- package/lib/Search/style/item.js +40 -0
- package/lib/Search/style/search.js +177 -0
- package/lib/Search/util.js +270 -0
- package/lib/Skeleton/Skeleton.js +27 -0
- package/lib/Skeleton/components/DashBoardCard.js +27 -0
- package/lib/Skeleton/components/DashBoardChart.js +27 -0
- package/lib/Skeleton/components/Detail.js +27 -0
- package/lib/Skeleton/components/Drawer.js +27 -0
- package/lib/Skeleton/components/Item.js +54 -0
- package/lib/Skeleton/components/List.js +27 -0
- package/lib/Skeleton/components/ListCard.js +28 -0
- package/lib/Skeleton/components/ListCardItem.js +20 -0
- package/lib/Skeleton/components/ListTable.js +27 -0
- package/lib/Skeleton/components/Page.js +26 -0
- package/lib/Skeleton/components/Search.js +16 -0
- package/lib/Skeleton/components/Tree.js +27 -0
- package/lib/Skeleton/index.js +28 -0
- package/lib/Skeleton/style/index.js +195 -0
- package/lib/TimeFormat/TimeFormat.js +36 -0
- package/lib/TimeFormat/index.js +7 -0
- package/lib/Title/Title.js +26 -0
- package/lib/Title/index.js +7 -0
- package/lib/Title/style/index.js +34 -0
- package/lib/ValueItem/ValueItem.js +113 -0
- package/lib/ValueItem/index.js +7 -0
- package/lib/ValueItem/util.js +17 -0
- package/lib/VirtualTable/VirtualTable.js +271 -0
- package/lib/VirtualTable/data.js +60 -0
- package/lib/VirtualTable/index.js +7 -0
- package/lib/VirtualTable/style/index.js +34 -0
- package/lib/components.js +21 -0
- package/lib/index.js +17 -0
- package/lib/locale/en-US.js +120 -0
- package/lib/locale/zh-CN.js +120 -0
- package/lib/style/styleRegister.js +19 -0
- package/lib/style/variable.js +4 -0
- package/lib/style.js +1 -0
- package/lib/utils/constants.js +10 -0
- package/package.json +164 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { computed, inject, unref, } from 'vue'
|
|
2
|
+
import zh from '../locale/zh-CN'
|
|
3
|
+
|
|
4
|
+
export function useLocaleReceiver(
|
|
5
|
+
componentName,
|
|
6
|
+
defaultLocale,
|
|
7
|
+
propsLocale
|
|
8
|
+
) {
|
|
9
|
+
const localeData = inject('componentLocaleData', {})
|
|
10
|
+
|
|
11
|
+
const componentLocale = computed(() => {
|
|
12
|
+
const { antLocale = zh } = localeData
|
|
13
|
+
const locale = unref(defaultLocale) || (componentName ? [componentName] : ['global'])
|
|
14
|
+
const localeFromContext = componentName && antLocale ? antLocale[componentName] : {}
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
...(typeof locale === 'function' ? locale() : locale),
|
|
18
|
+
...(localeFromContext || {}),
|
|
19
|
+
...(unref(propsLocale) || {})
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
return [componentLocale]
|
|
24
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
|
|
2
|
+
import { defineComponent, onMounted, onUpdated, ref } from 'vue'
|
|
3
|
+
import MarkdownIt from 'markdown-it'
|
|
4
|
+
import MarkdownItAbbr from 'markdown-it-abbr'
|
|
5
|
+
import MarkdownItAnchor from 'markdown-it-anchor'
|
|
6
|
+
import MarkdownItDeflist from 'markdown-it-deflist'
|
|
7
|
+
import MarkdownItFootnote from 'markdown-it-footnote'
|
|
8
|
+
import MarkdownItHighlightjs from 'markdown-it-highlightjs'
|
|
9
|
+
import MarkdownItIns from 'markdown-it-ins'
|
|
10
|
+
import MarkdownItMark from 'markdown-it-mark'
|
|
11
|
+
import MarkdownItSub from 'markdown-it-sub'
|
|
12
|
+
import MarkdownItSup from 'markdown-it-sup'
|
|
13
|
+
import MarkdownItTaskLists from 'markdown-it-task-lists'
|
|
14
|
+
import MarkdownItTOC from 'markdown-it-toc-done-right'
|
|
15
|
+
|
|
16
|
+
const props = {
|
|
17
|
+
anchor: {
|
|
18
|
+
type: Object,
|
|
19
|
+
default: () => ({})
|
|
20
|
+
},
|
|
21
|
+
breaks: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: false
|
|
24
|
+
},
|
|
25
|
+
emoji: {
|
|
26
|
+
type: Object,
|
|
27
|
+
default: () => ({})
|
|
28
|
+
},
|
|
29
|
+
highlight: {
|
|
30
|
+
type: Object,
|
|
31
|
+
default: () => ({})
|
|
32
|
+
},
|
|
33
|
+
html: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false
|
|
36
|
+
},
|
|
37
|
+
langPrefix: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: 'language-'
|
|
40
|
+
},
|
|
41
|
+
linkify: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: false
|
|
44
|
+
},
|
|
45
|
+
plugins: {
|
|
46
|
+
type: Array,
|
|
47
|
+
default: () => []
|
|
48
|
+
},
|
|
49
|
+
quotes: {
|
|
50
|
+
type: String,
|
|
51
|
+
default: ''
|
|
52
|
+
},
|
|
53
|
+
source: {
|
|
54
|
+
type: String,
|
|
55
|
+
default: ''
|
|
56
|
+
},
|
|
57
|
+
tasklists: {
|
|
58
|
+
type: Object,
|
|
59
|
+
default: () => ({})
|
|
60
|
+
},
|
|
61
|
+
toc: {
|
|
62
|
+
type: Object,
|
|
63
|
+
default: () => ({})
|
|
64
|
+
},
|
|
65
|
+
typographer: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: false
|
|
68
|
+
},
|
|
69
|
+
xhtmlOut: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
default: false
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default defineComponent({
|
|
76
|
+
name: 'JMarkdown',
|
|
77
|
+
props: props ,
|
|
78
|
+
setup(props) {
|
|
79
|
+
const md = ref()
|
|
80
|
+
|
|
81
|
+
const renderMarkdown = () => {
|
|
82
|
+
const markdown = new MarkdownIt()
|
|
83
|
+
.use(MarkdownItAbbr)
|
|
84
|
+
.use(MarkdownItAnchor, props.anchor)
|
|
85
|
+
.use(MarkdownItDeflist)
|
|
86
|
+
.use(MarkdownItFootnote)
|
|
87
|
+
.use(MarkdownItHighlightjs, props.highlight)
|
|
88
|
+
.use(MarkdownItIns)
|
|
89
|
+
.use(MarkdownItMark)
|
|
90
|
+
.use(MarkdownItSub)
|
|
91
|
+
.use(MarkdownItSup)
|
|
92
|
+
.use(MarkdownItTaskLists, props.tasklists)
|
|
93
|
+
.use(MarkdownItTOC, props.toc)
|
|
94
|
+
.set({
|
|
95
|
+
breaks: props.breaks,
|
|
96
|
+
html: props.html,
|
|
97
|
+
langPrefix: props.langPrefix,
|
|
98
|
+
linkify: props.linkify,
|
|
99
|
+
quotes: props.quotes,
|
|
100
|
+
typographer: props.typographer,
|
|
101
|
+
xhtmlOut: props.xhtmlOut
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
props.plugins.forEach(({ plugin, options = {} }) => {
|
|
105
|
+
markdown.use(plugin, options)
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
md.value = markdown.render(props.source)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
onMounted(() => renderMarkdown())
|
|
112
|
+
onUpdated(() => renderMarkdown())
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
md
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
})
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
import { defineComponent, computed, inject, getCurrentInstance, toRefs } from 'vue'
|
|
3
|
+
import { Button, Tooltip, Modal } from 'ant-design-vue'
|
|
4
|
+
import { omit } from 'lodash-es'
|
|
5
|
+
import { buttonProps } from 'ant-design-vue/es/button/button'
|
|
6
|
+
import { usePermission } from '@meethive/hooks'
|
|
7
|
+
import confirm from './confirm'
|
|
8
|
+
import { PermissionButtonConfig } from '../utils/constants'
|
|
9
|
+
import { useLocaleReceiver } from '../LocaleReciver'
|
|
10
|
+
|
|
11
|
+
const definedProps = {
|
|
12
|
+
tooltip: {
|
|
13
|
+
type: Object
|
|
14
|
+
},
|
|
15
|
+
popConfirm: {
|
|
16
|
+
type: Object
|
|
17
|
+
},
|
|
18
|
+
hasPermission: {
|
|
19
|
+
type: [String, Array, Boolean],
|
|
20
|
+
default: undefined
|
|
21
|
+
},
|
|
22
|
+
style: {
|
|
23
|
+
type: Object
|
|
24
|
+
},
|
|
25
|
+
noPermissionTitle: {
|
|
26
|
+
type: String
|
|
27
|
+
},
|
|
28
|
+
popConfirmBefore: {
|
|
29
|
+
type: Function
|
|
30
|
+
},
|
|
31
|
+
...omit(buttonProps(), 'icon')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default defineComponent({
|
|
35
|
+
name: 'JPermissionButton',
|
|
36
|
+
components: { Button, Tooltip },
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
slots: ['button', 'icon'],
|
|
39
|
+
props: definedProps,
|
|
40
|
+
setup(props) {
|
|
41
|
+
const instance = getCurrentInstance()
|
|
42
|
+
const propsRef = toRefs(props)
|
|
43
|
+
const { hasPerm } = usePermission(propsRef.hasPermission)
|
|
44
|
+
const [contextLocale] = useLocaleReceiver('PermissionButton')
|
|
45
|
+
|
|
46
|
+
const context = inject(PermissionButtonConfig, {
|
|
47
|
+
components: undefined
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
const permission = computed(() => {
|
|
51
|
+
if (props.hasPermission === true || props.hasPermission === undefined) {
|
|
52
|
+
return true
|
|
53
|
+
}
|
|
54
|
+
return hasPerm.value
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
const isPermission = computed(() => {
|
|
58
|
+
if ('hasPermission' in props && permission.value) {
|
|
59
|
+
return 'disabled' in props ? !!props.disabled : false
|
|
60
|
+
}
|
|
61
|
+
return true
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
const hasTooltip = computed(() => !!props.tooltip) // 是否包含文字提示
|
|
65
|
+
|
|
66
|
+
// 排除不传递给 Button 的属性 (与 ES 原版 _excluded 一致)
|
|
67
|
+
const computedButtonProps = computed(() => {
|
|
68
|
+
const { popConfirm, tooltip, hasPermission, noPermissionTitle, ...rest } = props
|
|
69
|
+
return {
|
|
70
|
+
...rest,
|
|
71
|
+
onClick: popConfirm ? handleClick : rest.onClick
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
// tooltip 属性 (与 ES 原版 _extends 一致)
|
|
76
|
+
const tooltipProps = computed(() => {
|
|
77
|
+
if (!props.tooltip) return {}
|
|
78
|
+
return Object.assign(props.tooltip, {
|
|
79
|
+
disabled: isPermission.value
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
// popConfirm 点击处理
|
|
84
|
+
const handleClick = async () => {
|
|
85
|
+
const _popConfirm = (await _optionalChain([props, 'access', _ => _.popConfirmBefore, 'optionalCall', _2 => _2()])) || props.popConfirm
|
|
86
|
+
if (context.components) {
|
|
87
|
+
confirm(
|
|
88
|
+
{
|
|
89
|
+
..._popConfirm,
|
|
90
|
+
danger: props.danger
|
|
91
|
+
},
|
|
92
|
+
context.components
|
|
93
|
+
)
|
|
94
|
+
} else {
|
|
95
|
+
Modal.confirm({
|
|
96
|
+
title: _popConfirm.title,
|
|
97
|
+
content: _popConfirm.content,
|
|
98
|
+
onOk: () => {
|
|
99
|
+
return _optionalChain([_popConfirm, 'access', _3 => _3.onConfirm, 'optionalCall', _4 => _4()])
|
|
100
|
+
},
|
|
101
|
+
onCancel: () => {
|
|
102
|
+
_optionalChain([_popConfirm, 'access', _5 => _5.onCancel, 'optionalCall', _6 => _6()])
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
permission,
|
|
110
|
+
isPermission,
|
|
111
|
+
hasTooltip,
|
|
112
|
+
computedButtonProps,
|
|
113
|
+
tooltipProps,
|
|
114
|
+
contextLocale,
|
|
115
|
+
handleClick
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
})
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { createVNode, render as vueRender, h, } from 'vue'
|
|
2
|
+
import { destroyFns } from './shared'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const confirm = (config, components) => {
|
|
18
|
+
const container = document.createDocumentFragment()
|
|
19
|
+
let confirmDialogInstance = null
|
|
20
|
+
let currentConfig = {
|
|
21
|
+
...config,
|
|
22
|
+
visible: true
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function destroy(...args) {
|
|
26
|
+
if (confirmDialogInstance) {
|
|
27
|
+
// destroy
|
|
28
|
+
vueRender(null, container)
|
|
29
|
+
confirmDialogInstance.component.update()
|
|
30
|
+
confirmDialogInstance = null
|
|
31
|
+
}
|
|
32
|
+
const triggerCancel = args.some((param) => param && param.triggerCancel)
|
|
33
|
+
if (config.onCancel && triggerCancel) {
|
|
34
|
+
config.onCancel(...args)
|
|
35
|
+
}
|
|
36
|
+
for (let i = 0; i < destroyFns.length; i++) {
|
|
37
|
+
const fn = destroyFns[i]
|
|
38
|
+
if (fn === close) {
|
|
39
|
+
destroyFns.splice(i, 1)
|
|
40
|
+
break
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function close( ...args) {
|
|
46
|
+
currentConfig = {
|
|
47
|
+
...currentConfig,
|
|
48
|
+
visible: false,
|
|
49
|
+
afterClose: () => {
|
|
50
|
+
if (typeof config.afterClose === 'function') {
|
|
51
|
+
config.afterClose()
|
|
52
|
+
}
|
|
53
|
+
destroy.apply(this, args)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
update(currentConfig)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function update(configUpdate) {
|
|
60
|
+
if (typeof configUpdate === 'function') {
|
|
61
|
+
currentConfig = configUpdate(currentConfig)
|
|
62
|
+
} else {
|
|
63
|
+
currentConfig = {
|
|
64
|
+
...currentConfig,
|
|
65
|
+
...configUpdate
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (confirmDialogInstance) {
|
|
69
|
+
Object.assign(confirmDialogInstance.component.props, currentConfig)
|
|
70
|
+
confirmDialogInstance.component.update()
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const Wrapper = (p) => {
|
|
75
|
+
return h(components, { ...p })
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function render(props) {
|
|
79
|
+
const vm = createVNode(Wrapper, { ...props })
|
|
80
|
+
vm.appContext = config.parentContext || config.appContext || vm.appContext
|
|
81
|
+
vueRender(vm, container)
|
|
82
|
+
return vm
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
confirmDialogInstance = render(currentConfig)
|
|
86
|
+
destroyFns.push(close)
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
destroy: close,
|
|
90
|
+
update
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export default confirm
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const destroyFns = []
|