forked from IDuxFE/idux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DatePanel.tsx
60 lines (53 loc) 路 1.8 KB
/
DatePanel.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* @license
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE
*/
import { computed, defineComponent, provide } from 'vue'
import { useDateConfig, useGlobalConfig } from '@idux/components/config'
import { useThemeToken } from '@idux/components/theme'
import { useActiveDate } from './composables/useActiveDate'
import { useActiveType } from './composables/useActiveType'
import { useMaxIndex } from './composables/useMaxIndex'
import PanelBody from './panel-body/PanelBody'
import PanelHeader from './panel-header/PanelHeader'
import { datePanelToken } from './token'
import { datePanelProps } from './types'
export default defineComponent({
name: '傻DatePanel',
props: datePanelProps,
setup(props, { slots }) {
const common = useGlobalConfig('common')
const { globalHashId } = useThemeToken()
const locale = useGlobalConfig('locale')
const mergedPrefixCls = computed(() => `${common.prefixCls}-date-panel`)
const dateConfig = useDateConfig()
const { activeType, setActiveType } = useActiveType(props)
const { activeDate, setActiveDate, startActiveDate } = useActiveDate(props, dateConfig, activeType)
const { maxRowIndex, maxCellIndex } = useMaxIndex(activeType)
provide(datePanelToken, {
props,
slots,
locale,
mergedPrefixCls,
dateConfig,
activeType,
setActiveType,
activeDate,
setActiveDate,
startActiveDate,
maxRowIndex,
maxCellIndex,
})
return () => {
const prefixCls = mergedPrefixCls.value
return (
<div class={`${prefixCls} ${prefixCls}-${activeType.value} ${globalHashId.value}`}>
<PanelHeader />
<PanelBody />
</div>
)
}
},
})