@king-design/intact 3.5.1 → 3.6.0-beta.0
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/components/breadcrumb/demos/separator.md +4 -4
- package/components/breadcrumb/index.vdt +1 -1
- package/components/breadcrumb/styles.ts +3 -2
- package/components/button/index.md +1 -0
- package/components/datepicker/basepicker.ts +60 -13
- package/components/datepicker/calendar.ts +5 -1
- package/components/datepicker/calendar.vdt +20 -6
- package/components/datepicker/dayjs.ts +22 -2
- package/components/datepicker/demos/multiple.md +0 -5
- package/components/datepicker/demos/nowrap.md +35 -0
- package/components/datepicker/demos/yearMonth.md +8 -2
- package/components/datepicker/helpers.ts +5 -5
- package/components/datepicker/index.md +3 -2
- package/components/datepicker/index.spec.ts +107 -90
- package/components/datepicker/index.ts +23 -5
- package/components/datepicker/index.vdt +34 -35
- package/components/datepicker/styles.ts +102 -3
- package/components/datepicker/useDisabled.ts +3 -3
- package/components/datepicker/useFormats.ts +2 -0
- package/components/datepicker/useMergeRange.ts +54 -0
- package/components/datepicker/usePosition.ts +169 -0
- package/components/datepicker/useQuarters.ts +47 -0
- package/components/datepicker/useShowDate.ts +42 -11
- package/components/datepicker/useValue.ts +35 -4
- package/components/datepicker/useWeeks.ts +58 -0
- package/components/dialog/useFixBody.ts +7 -64
- package/components/ellipsis/styles.ts +4 -0
- package/components/form/styles.ts +1 -0
- package/components/scrollSelect/index.spec.ts +3 -3
- package/components/scrollSelect/useMouseEvents.ts +23 -10
- package/components/select/base.vdt +2 -1
- package/components/select/demos/creatable.md +13 -0
- package/components/select/index.md +1 -0
- package/components/select/index.spec.ts +180 -0
- package/components/select/option.ts +9 -1
- package/components/select/select.ts +2 -0
- package/components/select/useFilterable.ts +1 -1
- package/components/select/useInput.ts +4 -2
- package/components/select/useSearchable.ts +2 -2
- package/components/table/table.vdt +3 -3
- package/components/timepicker/demos/step.md +1 -1
- package/components/timepicker/panelPicker.vdt +5 -1
- package/components/timepicker/styles.ts +0 -1
- package/components/tour/demos/basic.md +73 -0
- package/components/tour/demos/beforeChange.md +109 -0
- package/components/tour/demos/closable.md +70 -0
- package/components/tour/demos/custom.md +98 -0
- package/components/tour/demos/customText.md +94 -0
- package/components/tour/demos/declarative.md +72 -0
- package/components/tour/demos/events.md +101 -0
- package/components/tour/demos/maskClosable.md +76 -0
- package/components/tour/demos/notarget.md +59 -0
- package/components/tour/index.md +48 -0
- package/components/tour/index.spec.ts +259 -0
- package/components/tour/index.ts +2 -0
- package/components/tour/step.ts +55 -0
- package/components/tour/step.vdt +75 -0
- package/components/tour/styles.ts +283 -0
- package/components/tour/tour.ts +107 -0
- package/components/tour/tour.vdt +83 -0
- package/components/tour/useArrow.ts +46 -0
- package/components/tour/useFixBody.ts +22 -0
- package/components/tour/useHighlight.ts +36 -0
- package/components/tour/useMaskClosable.ts +26 -0
- package/components/tour/useNavigation.ts +46 -0
- package/components/tour/usePosition.ts +91 -0
- package/components/tour/useSteps.ts +80 -0
- package/components/tree/useChecked.ts +6 -4
- package/components/treeSelect/index.spec.ts +13 -1
- package/components/virtualList/useVirtualRows.ts +1 -1
- package/es/components/breadcrumb/index.vdt.js +2 -1
- package/es/components/breadcrumb/styles.js +5 -3
- package/es/components/datepicker/basepicker.d.ts +4 -2
- package/es/components/datepicker/basepicker.js +46 -13
- package/es/components/datepicker/calendar.d.ts +34 -6
- package/es/components/datepicker/calendar.js +4 -0
- package/es/components/datepicker/calendar.vdt.js +21 -5
- package/es/components/datepicker/dayjs.d.ts +13 -2
- package/es/components/datepicker/dayjs.js +6 -0
- package/es/components/datepicker/helpers.d.ts +5 -5
- package/es/components/datepicker/index.d.ts +17 -2
- package/es/components/datepicker/index.js +23 -5
- package/es/components/datepicker/index.spec.js +356 -355
- package/es/components/datepicker/index.vdt.js +25 -29
- package/es/components/datepicker/styles.d.ts +17 -0
- package/es/components/datepicker/styles.js +29 -2
- package/es/components/datepicker/useDisabled.d.ts +2 -2
- package/es/components/datepicker/useDisabled.js +1 -1
- package/es/components/datepicker/useFormats.js +3 -1
- package/es/components/datepicker/useMergeRange.d.ts +5 -0
- package/es/components/datepicker/useMergeRange.js +50 -0
- package/es/components/datepicker/usePosition.d.ts +10 -0
- package/es/components/datepicker/usePosition.js +166 -0
- package/es/components/datepicker/useQuarters.d.ts +15 -0
- package/es/components/datepicker/useQuarters.js +36 -0
- package/es/components/datepicker/useShowDate.d.ts +1 -1
- package/es/components/datepicker/useShowDate.js +42 -9
- package/es/components/datepicker/useStatus.d.ts +1 -1
- package/es/components/datepicker/useValue.d.ts +1 -0
- package/es/components/datepicker/useValue.js +26 -2
- package/es/components/datepicker/useWeeks.d.ts +19 -0
- package/es/components/datepicker/useWeeks.js +48 -0
- package/es/components/dialog/useFixBody.js +6 -58
- package/es/components/ellipsis/styles.js +1 -1
- package/es/components/form/styles.js +1 -1
- package/es/components/scrollSelect/index.spec.js +4 -6
- package/es/components/scrollSelect/useMouseEvents.js +21 -9
- package/es/components/select/base.vdt.js +4 -2
- package/es/components/select/index.spec.js +269 -42
- package/es/components/select/option.d.ts +1 -0
- package/es/components/select/option.js +9 -2
- package/es/components/select/select.d.ts +1 -0
- package/es/components/select/select.js +2 -1
- package/es/components/select/useFilterable.js +2 -1
- package/es/components/select/useInput.js +5 -2
- package/es/components/select/useSearchable.js +1 -0
- package/es/components/table/table.vdt.js +4 -2
- package/es/components/timepicker/panelPicker.d.ts +2 -1
- package/es/components/timepicker/panelPicker.vdt.js +12 -4
- package/es/components/timepicker/selectPicker.d.ts +1 -1
- package/es/components/timepicker/styles.js +1 -1
- package/es/components/timepicker/useDisabled.d.ts +1 -1
- package/es/components/timepicker/useValue.d.ts +1 -0
- package/es/components/tour/index.d.ts +2 -0
- package/es/components/tour/index.js +2 -0
- package/es/components/tour/index.spec.d.ts +1 -0
- package/es/components/tour/index.spec.js +356 -0
- package/es/components/tour/step.d.ts +23 -0
- package/es/components/tour/step.js +46 -0
- package/es/components/tour/step.vdt.js +74 -0
- package/es/components/tour/styles.d.ts +7 -0
- package/es/components/tour/styles.js +84 -0
- package/es/components/tour/tour.d.ts +73 -0
- package/es/components/tour/tour.js +70 -0
- package/es/components/tour/tour.vdt.js +66 -0
- package/es/components/tour/useArrow.d.ts +4 -0
- package/es/components/tour/useArrow.js +40 -0
- package/es/components/tour/useFixBody.d.ts +4 -0
- package/es/components/tour/useFixBody.js +17 -0
- package/es/components/tour/useHighlight.d.ts +4 -0
- package/es/components/tour/useHighlight.js +31 -0
- package/es/components/tour/useMaskClosable.d.ts +1 -0
- package/es/components/tour/useMaskClosable.js +25 -0
- package/es/components/tour/useNavigation.d.ts +5 -0
- package/es/components/tour/useNavigation.js +103 -0
- package/es/components/tour/usePosition.d.ts +6 -0
- package/es/components/tour/usePosition.js +93 -0
- package/es/components/tour/useSteps.d.ts +6 -0
- package/es/components/tour/useSteps.js +68 -0
- package/es/components/tree/useChecked.js +6 -4
- package/es/components/treeSelect/index.spec.js +20 -5
- package/es/components/virtualList/useVirtualRows.js +1 -1
- package/es/hooks/useDocumentClick.js +3 -3
- package/es/hooks/useFixBody.d.ts +11 -0
- package/es/hooks/useFixBody.js +72 -0
- package/es/index.d.ts +3 -2
- package/es/index.js +3 -2
- package/es/site/data/components/breadcrumb/demos/separator/react.js +7 -5
- package/es/site/data/components/datepicker/demos/multiple/index.d.ts +0 -1
- package/es/site/data/components/datepicker/demos/multiple/index.js +1 -2
- package/es/site/data/components/datepicker/demos/multiple/react.d.ts +0 -1
- package/es/site/data/components/datepicker/demos/multiple/react.js +2 -13
- package/es/site/data/components/datepicker/demos/nowrap/index.d.ts +10 -0
- package/es/site/data/components/datepicker/demos/nowrap/index.js +19 -0
- package/es/site/data/components/datepicker/demos/nowrap/react.d.ts +10 -0
- package/es/site/data/components/datepicker/demos/nowrap/react.js +49 -0
- package/es/site/data/components/datepicker/demos/yearMonth/index.d.ts +2 -0
- package/es/site/data/components/datepicker/demos/yearMonth/index.js +3 -1
- package/es/site/data/components/datepicker/demos/yearMonth/react.d.ts +2 -0
- package/es/site/data/components/datepicker/demos/yearMonth/react.js +21 -1
- package/es/site/data/components/select/demos/creatable/index.d.ts +1 -0
- package/es/site/data/components/select/demos/creatable/index.js +2 -1
- package/es/site/data/components/select/demos/creatable/react.d.ts +1 -0
- package/es/site/data/components/select/demos/creatable/react.js +31 -2
- package/es/site/data/components/select/demos/searchable/index.js +1 -1
- package/es/site/data/components/select/demos/searchable/react.js +1 -1
- package/es/site/data/components/tour/demos/basic/index.d.ts +17 -0
- package/es/site/data/components/tour/demos/basic/index.js +46 -0
- package/es/site/data/components/tour/demos/basic/react.d.ts +16 -0
- package/es/site/data/components/tour/demos/basic/react.js +82 -0
- package/es/site/data/components/tour/demos/beforeChange/index.d.ts +20 -0
- package/es/site/data/components/tour/demos/beforeChange/index.js +69 -0
- package/es/site/data/components/tour/demos/beforeChange/react.d.ts +19 -0
- package/es/site/data/components/tour/demos/beforeChange/react.js +129 -0
- package/es/site/data/components/tour/demos/closable/index.d.ts +18 -0
- package/es/site/data/components/tour/demos/closable/index.js +42 -0
- package/es/site/data/components/tour/demos/closable/react.d.ts +17 -0
- package/es/site/data/components/tour/demos/closable/react.js +85 -0
- package/es/site/data/components/tour/demos/custom/index.d.ts +11 -0
- package/es/site/data/components/tour/demos/custom/index.js +35 -0
- package/es/site/data/components/tour/demos/custom/react.d.ts +11 -0
- package/es/site/data/components/tour/demos/custom/react.js +108 -0
- package/es/site/data/components/tour/demos/customButtons/index.d.ts +33 -0
- package/es/site/data/components/tour/demos/customButtons/index.js +55 -0
- package/es/site/data/components/tour/demos/customButtons/react.d.ts +33 -0
- package/es/site/data/components/tour/demos/customButtons/react.js +99 -0
- package/es/site/data/components/tour/demos/customText/index.d.ts +20 -0
- package/es/site/data/components/tour/demos/customText/index.js +54 -0
- package/es/site/data/components/tour/demos/customText/react.d.ts +19 -0
- package/es/site/data/components/tour/demos/customText/react.js +95 -0
- package/es/site/data/components/tour/demos/declarative/index.d.ts +11 -0
- package/es/site/data/components/tour/demos/declarative/index.js +36 -0
- package/es/site/data/components/tour/demos/declarative/react.d.ts +10 -0
- package/es/site/data/components/tour/demos/declarative/react.js +80 -0
- package/es/site/data/components/tour/demos/events/index.d.ts +18 -0
- package/es/site/data/components/tour/demos/events/index.js +58 -0
- package/es/site/data/components/tour/demos/events/react.d.ts +18 -0
- package/es/site/data/components/tour/demos/events/react.js +101 -0
- package/es/site/data/components/tour/demos/maskClosable/index.d.ts +18 -0
- package/es/site/data/components/tour/demos/maskClosable/index.js +47 -0
- package/es/site/data/components/tour/demos/maskClosable/react.d.ts +17 -0
- package/es/site/data/components/tour/demos/maskClosable/react.js +95 -0
- package/es/site/data/components/tour/demos/notarget/index.d.ts +11 -0
- package/es/site/data/components/tour/demos/notarget/index.js +35 -0
- package/es/site/data/components/tour/demos/notarget/react.d.ts +10 -0
- package/es/site/data/components/tour/demos/notarget/react.js +61 -0
- package/es/site/data/components/tour/index.d.ts +57 -0
- package/es/site/data/components/tour/index.js +32 -0
- package/es/site/src/pages/resource/index.js +1 -1
- package/es/styles/fonts/iconfont.js +2 -1
- package/es/styles/global.js +2 -1
- package/hooks/useDocumentClick.ts +3 -3
- package/hooks/useFixBody.ts +87 -0
- package/index.ts +3 -2
- package/package.json +1 -1
- package/styles/fonts/iconfont.ts +2 -1
- package/styles/global.ts +2 -1
|
@@ -10,16 +10,16 @@ import {Breadcrumb, BreadcrumbItem, Icon} from 'kpc';
|
|
|
10
10
|
|
|
11
11
|
<Breadcrumb>
|
|
12
12
|
<b:separator>
|
|
13
|
-
<Icon class="ion-ios-arrow-thin-right separator"
|
|
13
|
+
<Icon class="ion-ios-arrow-thin-right separator" />
|
|
14
14
|
</b:separator>
|
|
15
15
|
<BreadcrumbItem to="/">
|
|
16
|
-
<Icon class="ion-home" /> item 1
|
|
16
|
+
<Icon class="ion-home" size="small"/> item 1
|
|
17
17
|
</BreadcrumbItem>
|
|
18
18
|
<BreadcrumbItem to="/components/breadcrumb/">
|
|
19
|
-
<Icon class="ion-earth"
|
|
19
|
+
<Icon class="ion-earth" size="small"/> item 2
|
|
20
20
|
</BreadcrumbItem>
|
|
21
21
|
<BreadcrumbItem>
|
|
22
|
-
<Icon class="ion-planet" /> item 3
|
|
22
|
+
<Icon class="ion-planet" size="small"/> item 3
|
|
23
23
|
</BreadcrumbItem>
|
|
24
24
|
</Breadcrumb>
|
|
25
25
|
```
|
|
@@ -15,7 +15,7 @@ const classNameObj = {
|
|
|
15
15
|
const separatorVNode = (
|
|
16
16
|
<span class={`${k}-breadcrumb-separator`}>
|
|
17
17
|
<template v-if={!$blocks.separator && !separator}>
|
|
18
|
-
<Icon class="k-icon-right" />
|
|
18
|
+
<Icon class="k-icon-right" size="small"/>
|
|
19
19
|
</template>
|
|
20
20
|
<b:separator v-else>{separator}</b:separator>
|
|
21
21
|
</span>
|
|
@@ -5,12 +5,12 @@ import '../../styles/global';
|
|
|
5
5
|
import { cache } from '../utils';
|
|
6
6
|
|
|
7
7
|
const defaults = {
|
|
8
|
-
fontSize: '
|
|
8
|
+
fontSize: '12px',
|
|
9
9
|
get color() { return theme.color.lightBlack },
|
|
10
10
|
get hoverColor() {return theme.color.primary },
|
|
11
11
|
gap: '6px',
|
|
12
12
|
activeFontWeight: 'normal',
|
|
13
|
-
activeColor
|
|
13
|
+
get activeColor() { return theme.color.title },
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
let breadcrumb: typeof defaults;
|
|
@@ -22,6 +22,7 @@ setDefault(() => {
|
|
|
22
22
|
export const makeStyles = cache(function makeStyles(k: string) {
|
|
23
23
|
return css`
|
|
24
24
|
font-size: ${breadcrumb.fontSize};
|
|
25
|
+
line-height: 12px;
|
|
25
26
|
display: flex;
|
|
26
27
|
align-items: center;
|
|
27
28
|
.${k}-breadcrumb-item {
|
|
@@ -35,6 +35,7 @@ sidebar: doc
|
|
|
35
35
|
| fluid | 是否宽度100% | `boolean` | `false` |
|
|
36
36
|
| seperate | 是否展示间隔,此属性为错别字,将会在下个版本被删除,请使用正确的属性 `separate`,若两个属性同时使用,则会优先使用`separate`属性 | `boolean` | `false` |
|
|
37
37
|
| separate | 是否展示间隔 | `boolean` | `false` |
|
|
38
|
+
| btnWidth | 指定按钮组每个按钮的固定宽度,默认根据内容撑开 | `number` | `string` | `undefined` |
|
|
38
39
|
|
|
39
40
|
# 方法
|
|
40
41
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import {useInstance, Component, TypeDefs} from 'intact';
|
|
5
5
|
import {useState, watchState, State} from '../../hooks/useState';
|
|
6
|
-
import dayjs, {Dayjs, OpUnitType} from './dayjs';
|
|
6
|
+
import dayjs, {Dayjs, OpUnitType, QUnitType} from './dayjs';
|
|
7
7
|
import {findValueIndex} from './helpers';
|
|
8
8
|
import type {useFormats} from './useFormats';
|
|
9
9
|
import type {useDisabled} from './useDisabled';
|
|
@@ -44,7 +44,8 @@ export interface BasePickerProps<
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export interface BasePickerEvents extends BaseSelectEvents {
|
|
47
|
-
selecting: [StateValueRange]
|
|
47
|
+
selecting: [StateValueRange],
|
|
48
|
+
togglePosition: []
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
export interface BasePickerBlocks<
|
|
@@ -74,6 +75,7 @@ const defaults = (): Partial<BasePickerProps<any>> => ({
|
|
|
74
75
|
const events: Events<BasePickerEvents> = {
|
|
75
76
|
...BaseSelect.events,
|
|
76
77
|
selecting: true,
|
|
78
|
+
togglePosition: true,
|
|
77
79
|
};
|
|
78
80
|
|
|
79
81
|
export abstract class BasePicker<
|
|
@@ -100,8 +102,8 @@ export abstract class BasePicker<
|
|
|
100
102
|
multiple ? '' : !range ?
|
|
101
103
|
value ? getShowString(value as Dayjs) : '' :
|
|
102
104
|
value ? [
|
|
103
|
-
getShowString((value as DayjsValueRange)[0]),
|
|
104
|
-
getShowString((value as DayjsValueRange)[1]),
|
|
105
|
+
(value as DayjsValueRange)[0] ? getShowString((value as DayjsValueRange)[0]) : '',
|
|
106
|
+
(value as DayjsValueRange)[1] ? getShowString((value as DayjsValueRange)[1]) : '',
|
|
105
107
|
].join(' ~ ') : ''
|
|
106
108
|
);
|
|
107
109
|
}
|
|
@@ -124,7 +126,7 @@ export function useValue(
|
|
|
124
126
|
panel: ReturnType<typeof usePanel>,
|
|
125
127
|
shouldUpdateValue: (v: StateValueItem) => boolean,
|
|
126
128
|
updateValueOnInput: (v: DayjsValueItem) => void,
|
|
127
|
-
getEqualType: () => OpUnitType,
|
|
129
|
+
getEqualType: () => OpUnitType | QUnitType,
|
|
128
130
|
updateStateValue: (v: DayjsValue, value: State<StateValue>) => void,
|
|
129
131
|
) {
|
|
130
132
|
// Normalize the value to multipe values, no matter it's multipe or not
|
|
@@ -133,11 +135,23 @@ export function useValue(
|
|
|
133
135
|
let dayjsValue: DayjsValue = [];
|
|
134
136
|
|
|
135
137
|
instance.watch('value', (newValue, oldValue) => {
|
|
138
|
+
|
|
136
139
|
if (isEqualArray(newValue, oldValue)) return;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
+
|
|
141
|
+
// 检查是否与当前 dayjsValue 对应的字符串相同,避免循环
|
|
142
|
+
const currentValueStr = convertToValueString(dayjsValue);
|
|
143
|
+
if (newValue === currentValueStr) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// 只执行一次转换和更新逻辑
|
|
148
|
+
const _value = convertToDayjs(newValue);
|
|
149
|
+
|
|
150
|
+
dayjsValue = _value;
|
|
151
|
+
updateStateValue(_value, value);
|
|
140
152
|
instance.resetKeywords(instance.input.keywords);
|
|
153
|
+
|
|
154
|
+
|
|
141
155
|
});
|
|
142
156
|
|
|
143
157
|
watchState(instance.input.keywords, v => {
|
|
@@ -157,6 +171,8 @@ export function useValue(
|
|
|
157
171
|
}
|
|
158
172
|
if (endDate.isAfter(startDate)) {
|
|
159
173
|
updateValueOnInput([startDate, endDate]);
|
|
174
|
+
} else {
|
|
175
|
+
updateValueOnInput([endDate, startDate]);
|
|
160
176
|
}
|
|
161
177
|
}
|
|
162
178
|
} else {
|
|
@@ -212,7 +228,6 @@ export function useValue(
|
|
|
212
228
|
}
|
|
213
229
|
|
|
214
230
|
function setSingleDate(v: StateValueItem, fromInput: boolean) {
|
|
215
|
-
const {range} = instance.get();
|
|
216
231
|
value.set([v]);
|
|
217
232
|
if (fromInput || shouldUpdateValue(v)) {
|
|
218
233
|
updateValue();
|
|
@@ -267,15 +282,40 @@ export function useValue(
|
|
|
267
282
|
|
|
268
283
|
function updateValue() {
|
|
269
284
|
const _value = value.value as DayjsValue;
|
|
270
|
-
|
|
285
|
+
|
|
286
|
+
const valueStr = convertToValueString(_value);
|
|
287
|
+
|
|
288
|
+
// 检查是否需要更新,避免循环调用
|
|
289
|
+
if (instance.get('value') === valueStr) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// 在设置 value 之前先更新 dayjsValue
|
|
294
|
+
dayjsValue = _value;
|
|
271
295
|
instance.set('value', valueStr);
|
|
296
|
+
|
|
272
297
|
instance.resetKeywords(instance.input.keywords);
|
|
298
|
+
|
|
273
299
|
}
|
|
274
300
|
|
|
275
301
|
function onConfirm() {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
302
|
+
const lastValue = last(instance.value.value.value);
|
|
303
|
+
const {multiple, range} = instance.get();
|
|
304
|
+
if (!multiple) {
|
|
305
|
+
|
|
306
|
+
if (range) {
|
|
307
|
+
// 范围选择:需要开始和结束时间都选择完才关闭
|
|
308
|
+
if((lastValue as [Dayjs, Dayjs?]).length === 2) {
|
|
309
|
+
instance.hide();
|
|
310
|
+
}
|
|
311
|
+
instance.trigger('togglePosition');
|
|
312
|
+
} else {
|
|
313
|
+
// 单选:选择完时间就关闭
|
|
314
|
+
if (lastValue) {
|
|
315
|
+
instance.hide();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
279
319
|
} else {
|
|
280
320
|
unique();
|
|
281
321
|
panel.reset();
|
|
@@ -283,6 +323,12 @@ export function useValue(
|
|
|
283
323
|
updateValue();
|
|
284
324
|
}
|
|
285
325
|
|
|
326
|
+
function setMoment() {
|
|
327
|
+
const now = dayjs();
|
|
328
|
+
setValue(now, true);
|
|
329
|
+
instance.hide();
|
|
330
|
+
}
|
|
331
|
+
|
|
286
332
|
function unique() {
|
|
287
333
|
const _value = value.value;
|
|
288
334
|
const map: Record<string, true> = {};
|
|
@@ -345,5 +391,6 @@ export function useValue(
|
|
|
345
391
|
setValue,
|
|
346
392
|
convertToDayjs,
|
|
347
393
|
getDayjsValue,
|
|
394
|
+
setMoment,
|
|
348
395
|
};
|
|
349
396
|
}
|
|
@@ -10,6 +10,8 @@ import {useShowDate} from './useShowDate';
|
|
|
10
10
|
import {bind} from '../utils';
|
|
11
11
|
import {useYears} from './useYears';
|
|
12
12
|
import {useMonths} from './useMonths';
|
|
13
|
+
import {useWeeks} from './useWeeks';
|
|
14
|
+
import {useQuarters} from './useQuarters';
|
|
13
15
|
import {StateValue} from './basepicker';
|
|
14
16
|
import {useStatus} from './useStatus';
|
|
15
17
|
import {PanelFlags} from './usePanel';
|
|
@@ -17,7 +19,7 @@ import { useConfigContext } from '../config';
|
|
|
17
19
|
|
|
18
20
|
export interface DatepickerCalendarProps {
|
|
19
21
|
value: StateValue
|
|
20
|
-
type?: 'date' | 'year' | 'month'
|
|
22
|
+
type?: 'date' | 'year' | 'month' | 'week' | 'quarter'
|
|
21
23
|
flag: PanelFlags
|
|
22
24
|
}
|
|
23
25
|
|
|
@@ -40,6 +42,8 @@ export class DatepickerCalendar extends Component<DatepickerCalendarProps, Datep
|
|
|
40
42
|
public days = useDays(this.showDate.date, this.status, this.datepicker.focusDate.focusDate);
|
|
41
43
|
public years = useYears(this.showDate.date, this.status, this.datepicker.focusDate.focusDate);
|
|
42
44
|
public months = useMonths(this.showDate.date, this.status, this.datepicker.focusDate.focusDate);
|
|
45
|
+
public weeks = useWeeks(this.showDate.date, this.status, this.datepicker.focusDate.focusDate);
|
|
46
|
+
public quarters = useQuarters(this.showDate.date, this.status, this.datepicker.focusDate.focusDate);
|
|
43
47
|
private config = useConfigContext();
|
|
44
48
|
|
|
45
49
|
@bind
|
|
@@ -7,7 +7,12 @@ import {getNowDate} from './helpers';
|
|
|
7
7
|
|
|
8
8
|
const type = this.type.value;
|
|
9
9
|
const isYear = type === 'year';
|
|
10
|
+
const isWeek = type === 'week';
|
|
11
|
+
const isQuarter = type === 'quarter';
|
|
10
12
|
const isYearOrMonth = isYear || type === 'month';
|
|
13
|
+
const isDateOrDateTime = type === 'date' || type === 'datetime'
|
|
14
|
+
// isDateOrDateTime & isWeek合并
|
|
15
|
+
const showDateWeeks = isDateOrDateTime || isWeek
|
|
11
16
|
const { k } = this.config;
|
|
12
17
|
const classNameObj = {
|
|
13
18
|
[`${k}-datepicker-calendar`]: true,
|
|
@@ -59,7 +64,7 @@ const {
|
|
|
59
64
|
<Button icon type="none" size="small" class={`${k}-prev`}
|
|
60
65
|
tagName="div"
|
|
61
66
|
ev-click={prevMonth}
|
|
62
|
-
v-if={
|
|
67
|
+
v-if={showDateWeeks}
|
|
63
68
|
>
|
|
64
69
|
<Icon class={`${k}-icon-left`} size="small" />
|
|
65
70
|
</Button>
|
|
@@ -79,7 +84,7 @@ const {
|
|
|
79
84
|
<Button icon type="none" size="small" class={`${k}-next`}
|
|
80
85
|
tagName="div"
|
|
81
86
|
ev-click={nextMonth}
|
|
82
|
-
v-if={
|
|
87
|
+
v-if={showDateWeeks}
|
|
83
88
|
>
|
|
84
89
|
<Icon class={`${k}-icon-right`} size="small" />
|
|
85
90
|
</Button>
|
|
@@ -92,20 +97,29 @@ const {
|
|
|
92
97
|
</Button>
|
|
93
98
|
</div>
|
|
94
99
|
</div>
|
|
95
|
-
<template v-if={
|
|
100
|
+
<template v-if={showDateWeeks}>
|
|
96
101
|
<div class={`${k}-weekdays`}>
|
|
97
102
|
<div class={`${k}-weekday`}
|
|
98
103
|
v-for={[_$('日'), _$('一'), _$('二'), _$('三'), _$('四'), _$('五'), _$('六')]}
|
|
99
104
|
>{$value}</div>
|
|
100
105
|
</div>
|
|
101
|
-
<div class={`${k}-
|
|
106
|
+
<div v-if={isWeek} class={`${k}-weeks`} ev-mouseleave={resetFocusDate}>
|
|
107
|
+
<div v-for={this.weeks.getWeeks(now)} class="week-row">
|
|
108
|
+
<div class={`${k}-week-number`} ev-click={e => {onClickDay($value.days[0].value)}}
|
|
109
|
+
ev-mouseenter={() => focusDate.set($value.days[0].value)}>{$value.week}</div>
|
|
110
|
+
{getItems($value.days, onClickDay)}
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
<div v-else class={`${k}-days`} ev-mouseleave={resetFocusDate}>
|
|
102
114
|
{getItems(getDays(now), onClickDay)}
|
|
103
115
|
</div>
|
|
104
116
|
</template>
|
|
105
117
|
<div v-else class={`${k}-years`} ev-mouseleave={resetFocusDate}>
|
|
106
118
|
{isYear ?
|
|
107
|
-
getItems(this.years.getYears(now), this.years.onClick) :
|
|
108
|
-
|
|
119
|
+
getItems(this.years.getYears(now), this.years.onClick) :
|
|
120
|
+
isQuarter ?
|
|
121
|
+
getItems(this.quarters.getQuarters(now), this.quarters.onClick) :
|
|
122
|
+
getItems(this.months.getMonths(now), this.months.onClick)
|
|
109
123
|
}
|
|
110
124
|
</div>
|
|
111
125
|
</div>
|
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
import dayjs, {Dayjs, OpUnitType} from 'dayjs';
|
|
1
|
+
import dayjs, {Dayjs, OpUnitType as DayjsOpUnitType, QUnitType as DayjsQUnitType} from 'dayjs';
|
|
2
|
+
import weekOfYear from 'dayjs/plugin/weekOfYear'
|
|
3
|
+
import quarterOfYear from 'dayjs/plugin/quarterOfYear';
|
|
2
4
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
5
|
+
import advancedFormat from 'dayjs/plugin/advancedFormat';
|
|
3
6
|
|
|
4
7
|
dayjs.extend(customParseFormat);
|
|
8
|
+
dayjs.extend(weekOfYear);
|
|
9
|
+
dayjs.extend(quarterOfYear);
|
|
10
|
+
dayjs.extend(advancedFormat);
|
|
11
|
+
|
|
12
|
+
// 重新声明类型以避免私有名称错误
|
|
13
|
+
export type OpUnitType = DayjsOpUnitType;
|
|
14
|
+
export type QUnitType = DayjsQUnitType;
|
|
15
|
+
|
|
16
|
+
declare module 'dayjs' {
|
|
17
|
+
interface Dayjs {
|
|
18
|
+
isSame(date?: dayjs.ConfigType, unit?: DayjsOpUnitType | DayjsQUnitType): boolean;
|
|
19
|
+
isBefore(date?: dayjs.ConfigType, unit?: DayjsOpUnitType | DayjsQUnitType): boolean;
|
|
20
|
+
isAfter(date?: dayjs.ConfigType, unit?: DayjsOpUnitType | DayjsQUnitType): boolean;
|
|
21
|
+
add(value: number, unit?: DayjsOpUnitType | DayjsQUnitType): dayjs.Dayjs;
|
|
22
|
+
subtract(value: number, unit?: DayjsOpUnitType | DayjsQUnitType): dayjs.Dayjs;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
5
25
|
|
|
6
26
|
export default dayjs;
|
|
7
|
-
export type {Dayjs
|
|
27
|
+
export type {Dayjs};
|
|
@@ -24,9 +24,6 @@ import {Datepicker} from 'kpc';
|
|
|
24
24
|
<Datepicker multiple range v-model="dateRange" />
|
|
25
25
|
You selected: {JSON.stringify(this.get('dateRange'))}
|
|
26
26
|
<br /><br />
|
|
27
|
-
<Datepicker multiple range v-model="datetimeRange" type="datetime" />
|
|
28
|
-
You selected: {JSON.stringify(this.get('datetimeRange'))}
|
|
29
|
-
<br /><br />
|
|
30
27
|
</div>
|
|
31
28
|
```
|
|
32
29
|
|
|
@@ -37,7 +34,6 @@ interface Props {
|
|
|
37
34
|
year?: string[]
|
|
38
35
|
month?: string[]
|
|
39
36
|
dateRange?: [string, string][]
|
|
40
|
-
datetimeRange?: [string, string][]
|
|
41
37
|
}
|
|
42
38
|
|
|
43
39
|
export default class extends Component<Props> {
|
|
@@ -49,7 +45,6 @@ export default class extends Component<Props> {
|
|
|
49
45
|
year: [],
|
|
50
46
|
month: [],
|
|
51
47
|
dateRange: [],
|
|
52
|
-
datetimeRange: [],
|
|
53
48
|
} as Props;
|
|
54
49
|
}
|
|
55
50
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 单行显示
|
|
3
|
+
order: 7
|
|
4
|
+
---
|
|
5
|
+
`nowrap`属性可以控制是否换行显示,`isMerge`属性可以控制不换行显示时是否交叉自动合并
|
|
6
|
+
|
|
7
|
+
```vdt
|
|
8
|
+
import {Datepicker} from 'kpc';
|
|
9
|
+
|
|
10
|
+
<div>
|
|
11
|
+
<Datepicker multiple nowrap range v-model="dateRange" />
|
|
12
|
+
You selected: {JSON.stringify(this.get('dateRange'))}
|
|
13
|
+
<br /><br />
|
|
14
|
+
<Datepicker multiple nowrap isMerge range v-model="mergeDateRange" />
|
|
15
|
+
You selected: {JSON.stringify(this.get('mergeDateRange'))}
|
|
16
|
+
<br /><br />
|
|
17
|
+
</div>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
interface Props {
|
|
22
|
+
dateRange?: [string, string][]
|
|
23
|
+
mergeDateRange?: [string, string][]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default class extends Component<Props> {
|
|
27
|
+
static template = template;
|
|
28
|
+
static defaults() {
|
|
29
|
+
return {
|
|
30
|
+
dateRange: [],
|
|
31
|
+
mergeDateRange: [],
|
|
32
|
+
} as Props;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
-
title:
|
|
2
|
+
title: 选择年、月、周、季度
|
|
3
3
|
order: 5.1
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
将`type`属性指定为`year`或`month
|
|
6
|
+
将`type`属性指定为`year`或`month``或`week``或`quarter`可以只选择“年”或“月””或“周””或“季度”
|
|
7
7
|
|
|
8
8
|
```vdt
|
|
9
9
|
import {Datepicker} from 'kpc';
|
|
@@ -11,6 +11,8 @@ import {Datepicker} from 'kpc';
|
|
|
11
11
|
<div>
|
|
12
12
|
<Datepicker type="year" v-model="year" />
|
|
13
13
|
<Datepicker type="month" v-model="month" clearable />
|
|
14
|
+
<Datepicker type="week" v-model="week" clearable />
|
|
15
|
+
<Datepicker type="quarter" v-model="quarter" clearable />
|
|
14
16
|
</div>
|
|
15
17
|
```
|
|
16
18
|
|
|
@@ -23,6 +25,8 @@ import {Datepicker} from 'kpc';
|
|
|
23
25
|
interface Props {
|
|
24
26
|
year?: string | null
|
|
25
27
|
month?: string | null
|
|
28
|
+
week?: string | null
|
|
29
|
+
quarter?: string | null
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
export default class extends Component<Props> {
|
|
@@ -31,6 +35,8 @@ export default class extends Component<Props> {
|
|
|
31
35
|
return {
|
|
32
36
|
year: null,
|
|
33
37
|
month: null,
|
|
38
|
+
week: null,
|
|
39
|
+
quarter: null,
|
|
34
40
|
} as Props;
|
|
35
41
|
}
|
|
36
42
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import dayjs, {Dayjs, OpUnitType} from 'dayjs';
|
|
1
|
+
import dayjs, {Dayjs, OpUnitType, QUnitType} from 'dayjs';
|
|
2
2
|
import {strPad, range} from '../utils';
|
|
3
3
|
import {_$} from '../../i18n';
|
|
4
4
|
import {StateValueItem} from './basepicker';
|
|
@@ -28,7 +28,7 @@ export function endTime(date: Date) {
|
|
|
28
28
|
export function isEqual(
|
|
29
29
|
a: Dayjs | undefined | null,
|
|
30
30
|
b: Dayjs | undefined | null,
|
|
31
|
-
type: OpUnitType = 'date'
|
|
31
|
+
type: OpUnitType | QUnitType = 'date'
|
|
32
32
|
) {
|
|
33
33
|
if (a && b) {
|
|
34
34
|
return a.isSame(b, type);
|
|
@@ -39,7 +39,7 @@ export function isEqual(
|
|
|
39
39
|
export function isLT(
|
|
40
40
|
a: Dayjs | undefined | null,
|
|
41
41
|
b: Dayjs | undefined | null,
|
|
42
|
-
type: OpUnitType = 'date'
|
|
42
|
+
type: OpUnitType | QUnitType = 'date'
|
|
43
43
|
) {
|
|
44
44
|
if (a && b) {
|
|
45
45
|
return a.isBefore(b, type);
|
|
@@ -51,7 +51,7 @@ export function isLT(
|
|
|
51
51
|
export function isGT(
|
|
52
52
|
a: Dayjs | undefined | null,
|
|
53
53
|
b: Dayjs | undefined | null,
|
|
54
|
-
type: OpUnitType = 'date'
|
|
54
|
+
type: OpUnitType | QUnitType = 'date'
|
|
55
55
|
) {
|
|
56
56
|
return isLT(b, a, type);
|
|
57
57
|
}
|
|
@@ -70,7 +70,7 @@ export function createDate(date: string) {
|
|
|
70
70
|
return new Date(date);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
export function findValueIndex(values: StateValueItem[], value: StateValueItem, type: OpUnitType) {
|
|
73
|
+
export function findValueIndex(values: StateValueItem[], value: StateValueItem, type: OpUnitType | QUnitType) {
|
|
74
74
|
return values.findIndex(item => {
|
|
75
75
|
if (Array.isArray(item)) {
|
|
76
76
|
// is multipe range values
|
|
@@ -28,13 +28,14 @@ sidebar: doc
|
|
|
28
28
|
| max | 最大可选日期 | `Value` | `undefind` |
|
|
29
29
|
| min | 最小可选日期 | `Value` | `undefind` |
|
|
30
30
|
| disabledDate | 该属性值是一个函数,用于定义那些日期被禁止选择,函数参数为日期字符串,返回`true`则表示禁用该日期 | `(v: Dayjs) => boolean` | `undefined` |
|
|
31
|
-
| type | 组件类型:`"date"` 只选择日期;`"datetime"` 选择日期和时间;`"year"` 选择年份;`"month"` 选择月份
|
|
31
|
+
| type | 组件类型:`"date"` 只选择日期;`"datetime"` 选择日期和时间;`"year"` 选择年份;`"month"` 选择月份 `"quarter"` 选择季度;`"week` 选择周;| | `"datetime"` | `"year"` | `"month"` | `"quarter"` | `"week"` | `"date"` |
|
|
32
32
|
| shortcuts | 指定快捷方式 | `Shortcut[]` | `undefined` |
|
|
33
33
|
| show | 是否展示菜单项 | `boolean` | `false` |
|
|
34
34
|
| position | 菜单弹出的位置,默认与触发器左侧对齐向下偏移`8px`的地方 | `Position` | `"left"` | `"bottom"` | `"right"` | `"top"` | `{my: 'left top+8', 'left bottom'}` |
|
|
35
35
|
| flat | 是否展示扁平样式 | `boolean` | `false` |
|
|
36
36
|
| draggable | 多选值是否支持拖动排序 | `boolean` | `false` |
|
|
37
|
-
|
|
37
|
+
| nowrap | 日期多选时, 是否换行显示 | `boolean` | `false` |
|
|
38
|
+
| isMerge | 日期范围多选时,在nowrap状态下是否交叉自动合并 | `boolean` | `false` |
|
|
38
39
|
```ts
|
|
39
40
|
import {Dayjs} from 'dayjs';
|
|
40
41
|
import {VNode} from 'intact';
|