@king-design/vue 3.5.2 → 3.6.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.
Files changed (119) hide show
  1. package/__tests__/__snapshots__/Vue Next Demos.md +111 -47
  2. package/__tests__/components/misc.spec.ts +93 -0
  3. package/components/cascader/index.spec.js +18 -19
  4. package/components/datepicker/basepicker.d.ts +6 -25
  5. package/components/datepicker/basepicker.js +22 -234
  6. package/components/datepicker/calendar.d.ts +36 -6
  7. package/components/datepicker/calendar.js +4 -0
  8. package/components/datepicker/calendar.vdt.js +21 -5
  9. package/components/datepicker/dayjs.d.ts +2 -2
  10. package/components/datepicker/dayjs.js +6 -0
  11. package/components/datepicker/helpers.d.ts +8 -7
  12. package/components/datepicker/helpers.js +2 -3
  13. package/components/datepicker/index.d.ts +26 -19
  14. package/components/datepicker/index.js +21 -13
  15. package/components/datepicker/index.spec.js +1389 -633
  16. package/components/datepicker/index.vdt.js +43 -46
  17. package/components/datepicker/shortcuts.d.ts +1 -1
  18. package/components/datepicker/styles.d.ts +22 -0
  19. package/components/datepicker/styles.js +26 -4
  20. package/components/datepicker/useConfirm.d.ts +6 -0
  21. package/components/datepicker/useConfirm.js +65 -0
  22. package/components/datepicker/useDisabled.d.ts +7 -5
  23. package/components/datepicker/useDisabled.js +22 -27
  24. package/components/datepicker/useFormats.d.ts +2 -2
  25. package/components/datepicker/useFormats.js +9 -3
  26. package/components/datepicker/useHighlight.d.ts +14 -0
  27. package/components/datepicker/useHighlight.js +60 -0
  28. package/components/datepicker/useKeyboards.js +2 -1
  29. package/components/datepicker/useMergeRange.d.ts +5 -0
  30. package/components/datepicker/useMergeRange.js +45 -0
  31. package/components/datepicker/useMonths.js +5 -3
  32. package/components/datepicker/usePanel.d.ts +1 -10
  33. package/components/datepicker/usePanel.js +19 -32
  34. package/components/datepicker/useQuarters.d.ts +15 -0
  35. package/components/datepicker/useQuarters.js +36 -0
  36. package/components/datepicker/useShowDate.js +10 -2
  37. package/components/datepicker/useStatus.d.ts +1 -1
  38. package/components/datepicker/useStatus.js +33 -16
  39. package/components/datepicker/useValue.d.ts +12 -6
  40. package/components/datepicker/useValue.js +49 -45
  41. package/components/datepicker/useValueBase.d.ts +28 -0
  42. package/components/datepicker/useValueBase.js +277 -0
  43. package/components/datepicker/useWeeks.d.ts +19 -0
  44. package/components/datepicker/useWeeks.js +48 -0
  45. package/components/datepicker/useYears.js +6 -3
  46. package/components/dialog/useFixBody.js +6 -58
  47. package/components/dropdown/dropdown.d.ts +1 -0
  48. package/components/dropdown/dropdown.js +7 -4
  49. package/components/ellipsis/styles.js +1 -1
  50. package/components/form/styles.js +1 -1
  51. package/components/input/index.d.ts +2 -0
  52. package/components/input/index.js +6 -0
  53. package/components/input/index.spec.js +45 -0
  54. package/components/input/index.vdt.js +4 -3
  55. package/components/input/useAutoWidth.d.ts +2 -0
  56. package/components/input/useAutoWidth.js +19 -1
  57. package/components/scrollSelect/index.spec.js +4 -6
  58. package/components/scrollSelect/useMouseEvents.js +22 -9
  59. package/components/select/base.d.ts +1 -1
  60. package/components/select/base.js +3 -2
  61. package/components/select/base.vdt.js +5 -2
  62. package/components/select/index.spec.js +329 -82
  63. package/components/select/option.d.ts +1 -0
  64. package/components/select/option.js +10 -2
  65. package/components/select/select.d.ts +1 -0
  66. package/components/select/select.js +4 -2
  67. package/components/select/styles.d.ts +79 -0
  68. package/components/select/styles.js +1 -0
  69. package/components/select/useFilterable.js +2 -1
  70. package/components/select/useInput.d.ts +1 -1
  71. package/components/select/useInput.js +7 -4
  72. package/components/select/useSearchable.js +1 -0
  73. package/components/table/index.spec.js +84 -6
  74. package/components/table/useStickyHeader.js +1 -1
  75. package/components/timepicker/index.spec.js +298 -128
  76. package/components/timepicker/panelPicker.d.ts +23 -17
  77. package/components/timepicker/panelPicker.js +7 -4
  78. package/components/timepicker/panelPicker.vdt.js +8 -4
  79. package/components/timepicker/selectPicker.d.ts +5 -4
  80. package/components/timepicker/useConfirm.d.ts +6 -0
  81. package/components/timepicker/useConfirm.js +19 -0
  82. package/components/timepicker/useDefaultValue.d.ts +4 -0
  83. package/components/timepicker/useDefaultValue.js +27 -0
  84. package/components/timepicker/useDisabled.d.ts +7 -4
  85. package/components/timepicker/useDisabled.js +13 -4
  86. package/components/timepicker/useFormats.d.ts +1 -1
  87. package/components/timepicker/useValue.d.ts +14 -8
  88. package/components/timepicker/useValue.js +14 -15
  89. package/components/tour/index.d.ts +2 -0
  90. package/components/tour/index.js +2 -0
  91. package/components/tour/index.spec.d.ts +1 -0
  92. package/components/tour/index.spec.js +356 -0
  93. package/components/tour/step.d.ts +23 -0
  94. package/components/tour/step.js +46 -0
  95. package/components/tour/step.vdt.js +74 -0
  96. package/components/tour/styles.d.ts +7 -0
  97. package/components/tour/styles.js +84 -0
  98. package/components/tour/tour.d.ts +73 -0
  99. package/components/tour/tour.js +70 -0
  100. package/components/tour/tour.vdt.js +66 -0
  101. package/components/tour/useArrow.d.ts +4 -0
  102. package/components/tour/useArrow.js +40 -0
  103. package/components/tour/useFixBody.d.ts +4 -0
  104. package/components/tour/useFixBody.js +17 -0
  105. package/components/tour/useHighlight.d.ts +4 -0
  106. package/components/tour/useHighlight.js +31 -0
  107. package/components/tour/useMaskClosable.d.ts +1 -0
  108. package/components/tour/useMaskClosable.js +25 -0
  109. package/components/tour/useNavigation.d.ts +5 -0
  110. package/components/tour/useNavigation.js +103 -0
  111. package/components/tour/usePosition.d.ts +6 -0
  112. package/components/tour/usePosition.js +93 -0
  113. package/components/tour/useSteps.d.ts +6 -0
  114. package/components/tour/useSteps.js +68 -0
  115. package/hooks/useFixBody.d.ts +11 -0
  116. package/hooks/useFixBody.js +72 -0
  117. package/index.d.ts +3 -2
  118. package/index.js +3 -2
  119. package/package.json +2 -2
@@ -7,84 +7,81 @@ import { DatepickerTime } from './time';
7
7
  import { Icon } from '../icon';
8
8
  import { Button } from '../button';
9
9
  import { _$ } from '../../i18n';
10
- import { makePanelStyles } from './styles';
11
- import { PanelTypes, PanelFlags } from './usePanel';
10
+ import { makeStyles, makePanelStyles, makeHighlightStyles } from './styles';
11
+ import { PanelFlags } from './usePanel';
12
12
  import { isFunction } from 'intact-shared';
13
13
  import { Tabs, Tab } from '../tabs';
14
+ import { Position } from './useHighlight';
14
15
  export default function ($props, $blocks, $__proto__) {
15
16
  var _classNameObj,
17
+ _classDatePickerObj,
16
18
  _this = this;
17
19
  $blocks || ($blocks = {});
18
20
  $props || ($props = {});
19
21
  var $this = this;
22
+ var k = this.config.k;
20
23
  var _this$get = this.get(),
21
24
  className = _this$get.className,
22
25
  type = _this$get.type,
23
26
  range = _this$get.range,
24
27
  multiple = _this$get.multiple,
25
- shortcuts = _this$get.shortcuts;
28
+ shortcuts = _this$get.shortcuts,
29
+ size = _this$get.size;
26
30
  var _this$value = this.value,
27
31
  value = _this$value.value.value,
28
32
  onChangeDate = _this$value.onChangeDate,
29
- onConfirm = _this$value.onConfirm,
30
33
  onChangeTime = _this$value.onChangeTime,
31
34
  onChangeDateForRange = _this$value.onChangeDateForRange,
32
35
  getTimeValue = _this$value.getTimeValue;
33
- var k = this.config.k;
36
+ var onConfirm = this.confirm.onConfirm;
37
+ var _this$highlight = this.highlight,
38
+ position = _this$highlight.position,
39
+ handleInputClick = _this$highlight.handleInputClick,
40
+ highlightWidth = _this$highlight.highlightWidth,
41
+ highlightLeft = _this$highlight.highlightLeft;
42
+ // 判断是否显示双面板
43
+ var showDualPanels = range && type !== 'datetime';
34
44
  var classNameObj = (_classNameObj = {}, _classNameObj[k + "-datepicker-content"] = true, _classNameObj[className] = className, _classNameObj[makePanelStyles(k)] = true, _classNameObj);
45
+ var classDatePickerObj = (_classDatePickerObj = {}, _classDatePickerObj[k + "-datepicker"] = true, _classDatePickerObj[makeHighlightStyles(k, size, highlightWidth.value, highlightLeft.value)] = range, _classDatePickerObj[makeStyles(k)] = true, _classDatePickerObj);
35
46
  var _this$disabled = this.disabled,
36
47
  isDisabledTime = _this$disabled.isDisabledTime,
37
48
  isDisabledConfirm = _this$disabled.isDisabledConfirm;
38
49
  var _this$panel = this.panel,
39
- startPanel = _this$panel.startPanel,
40
- endPanel = _this$panel.endPanel,
41
- getPanel = _this$panel.getPanel,
42
50
  startRef = _this$panel.startRef,
43
51
  endRef = _this$panel.endRef;
44
52
  var generatePanel = function generatePanel(flag) {
45
- var panel = getPanel(flag);
46
- var timeValue = getTimeValue(flag);
47
- return _$ce(2, 'div', [function () {
48
- if (type === 'datetime') {
49
- var dateString = '0000-00-00';
50
- var timeString = '00:00:00';
51
- if (timeValue) {
52
- var valueString = _this.formats.getShowString(timeValue).split(/\s+/);
53
- dateString = valueString[0];
54
- timeString = valueString[1];
55
- }
56
- return _$cc(Tabs, {
57
- 'type': 'card',
58
- 'value': panel.value,
59
- 'ev-$change:value': panel.set,
60
- 'children': [_$cc(Tab, {
61
- 'value': PanelTypes.Date,
62
- 'children': dateString
63
- }), _$cc(Tab, {
64
- 'value': PanelTypes.Time,
65
- 'disabled': !timeValue,
66
- 'children': timeString
67
- })]
68
- });
69
- }
70
- }(), panel.value === PanelTypes.Date ? _$cc(DatepickerCalendar, {
53
+ return _$ce(2, 'div', [_$cc(DatepickerCalendar, {
71
54
  'value': value,
72
55
  'ev-change': onChangeDate,
73
56
  'type': type === 'datetime' ? 'date' : type,
74
57
  'flag': flag,
75
- 'ref': flag === PanelFlags.Start ? startRef : endRef
76
- }, null, flag === PanelFlags.Start ? startRef : endRef) : _$cc(DatepickerTime, {
77
- 'value': timeValue,
78
- 'ev-$change:value': function ev$changeValue(v) {
79
- return onChangeTime(v, flag);
80
- },
81
- 'format': _this.formats.getValueFormat(),
82
- 'flag': flag,
83
- 'isDisabledTime': isDisabledTime
84
- })], 0, _$cn(k + "-datepicker-calendar-wrapper"));
58
+ 'ref': flag === PanelFlags.Start ? startRef : endRef,
59
+ 'highlightPosition': position.value
60
+ }, null, flag === PanelFlags.Start ? startRef : endRef), type === 'datetime' ? _$ce(2, 'div', function () {
61
+ var timeValue = getTimeValue(flag);
62
+ if (flag === PanelFlags.End && !timeValue) {
63
+ timeValue = getTimeValue(PanelFlags.Start);
64
+ }
65
+ var timeString = '00:00:00';
66
+ if (timeValue) {
67
+ var valueString = _this.formats.getShowString(timeValue).split(/\s+/);
68
+ timeString = valueString[1];
69
+ }
70
+ return [_$ce(2, 'div', timeString, 0, _$cn(k + "-datepicker-time-time")), _$cc(DatepickerTime, {
71
+ 'value': timeValue,
72
+ 'ev-$change:value': function ev$changeValue(v) {
73
+ return onChangeTime(v, flag);
74
+ },
75
+ 'format': _this.formats.getValueFormat(),
76
+ 'flag': flag,
77
+ 'isDisabledTime': isDisabledTime
78
+ })];
79
+ }(), 0, _$cn(k + "-datepicker-time-wrapper")) : undefined], 0, _$cn(k + "-datepicker-calendar-time-wrapper"));
85
80
  };
86
81
  return _$su.call($this, {
87
- 'className': _$cn(k + "-datepicker")
82
+ 'className': _$cn(classDatePickerObj),
83
+ 'onClick': handleInputClick,
84
+ 'alwaysShowOnClick': true
88
85
  }, function ($blocks) {
89
86
  var _$blocks = {},
90
87
  __$blocks = _$ex({}, $blocks);
@@ -98,7 +95,7 @@ export default function ($props, $blocks, $__proto__) {
98
95
  'title': label,
99
96
  'ev-click': linkEvent($value, _this2.setByShortcut)
100
97
  });
101
- }), 0, _$cn(k + "-datepicker-shortcuts")) : undefined, _$ce(2, 'div', [_$ce(2, 'div', [generatePanel(PanelFlags.Start), _$ct('\n '), range ? generatePanel(PanelFlags.End) : null], 0, _$cn(k + "-datepicker-calendars")), type === 'datetime' ? _$ce(2, 'div', _$cc(Button, {
98
+ }), 0, _$cn(k + "-datepicker-shortcuts")) : undefined, _$ce(2, 'div', [_$ce(2, 'div', [generatePanel(!showDualPanels && position.value === Position.End ? PanelFlags.End : PanelFlags.Start), _$ct('\n '), showDualPanels ? generatePanel(PanelFlags.End) : null], 0, _$cn(k + "-datepicker-calendars")), type === 'datetime' ? _$ce(2, 'div', _$cc(Button, {
102
99
  'type': 'primary',
103
100
  'size': 'small',
104
101
  'disabled': isDisabledConfirm(),
@@ -1,5 +1,5 @@
1
1
  import { Children } from 'intact-vue-next';
2
- import { Value } from './basepicker';
2
+ import { Value } from './useValueBase';
3
3
  export type Shortcut = {
4
4
  label: (() => Children) | Children;
5
5
  value: () => Value | [Value, Value];
@@ -1,3 +1,4 @@
1
+ import { Sizes } from '../../styles/utils';
1
2
  import '../../styles/global';
2
3
  declare const defaults: {
3
4
  width: string;
@@ -5,7 +6,9 @@ declare const defaults: {
5
6
  border: string;
6
7
  item: {
7
8
  gutter: string;
9
+ yearGutter: string;
8
10
  height: string;
11
+ rangeGutter: string;
9
12
  readonly hoverBgColor: string;
10
13
  readonly exceedColor: string;
11
14
  readonly todayBorder: string;
@@ -34,6 +37,17 @@ declare const defaults: {
34
37
  footer: {
35
38
  padding: string;
36
39
  };
40
+ week: {
41
+ height: string;
42
+ width: string;
43
+ margin: string;
44
+ padding: string;
45
+ currentWeek: string;
46
+ };
47
+ calendarTime: {
48
+ height: string;
49
+ fontSize: string;
50
+ };
37
51
  shortcuts: {
38
52
  width: string;
39
53
  padding: string;
@@ -46,6 +60,10 @@ declare const defaults: {
46
60
  };
47
61
  declare let datepicker: typeof defaults;
48
62
  export { datepicker };
63
+ export declare const makeStyles: {
64
+ (k: string): string;
65
+ clearCache(): {};
66
+ };
49
67
  export declare const makePanelStyles: {
50
68
  (k: string): string;
51
69
  clearCache(): {};
@@ -58,3 +76,7 @@ export declare const makeTimeStyles: {
58
76
  (k: string): string;
59
77
  clearCache(): {};
60
78
  };
79
+ export declare const makeHighlightStyles: {
80
+ (k: string, size: Sizes, highlightWidth: number, highlightLeft: number): string;
81
+ clearCache(): {};
82
+ };
@@ -1,15 +1,18 @@
1
1
  import { css } from '@emotion/css';
2
2
  import { theme, setDefault } from '../../styles/theme';
3
- import { deepDefaults, palette } from '../../styles/utils';
3
+ import { deepDefaults, getLeft, palette } from '../../styles/utils';
4
4
  import '../../styles/global';
5
5
  import { cache } from '../utils';
6
+ import { select } from '../select/styles';
6
7
  var defaults = {
7
8
  width: "300px",
8
9
  padding: "16px 16px 4px",
9
10
  border: "1px solid #e5e5e5",
10
11
  item: {
11
12
  gutter: "7px",
13
+ yearGutter: '36px',
12
14
  height: "24px",
15
+ rangeGutter: "17px",
13
16
  get hoverBgColor() {
14
17
  return theme.color.bg;
15
18
  },
@@ -52,6 +55,17 @@ var defaults = {
52
55
  footer: {
53
56
  padding: "8px 16px"
54
57
  },
58
+ week: {
59
+ height: "20px",
60
+ width: "40px",
61
+ margin: "0 0 0 10px",
62
+ padding: "0 2px",
63
+ currentWeek: '#eee'
64
+ },
65
+ calendarTime: {
66
+ height: "44px",
67
+ fontSize: "14px"
68
+ },
55
69
  shortcuts: {
56
70
  width: '100px',
57
71
  padding: '12px 0',
@@ -72,14 +86,22 @@ setDefault(function () {
72
86
  makePanelStyles == null || makePanelStyles.clearCache();
73
87
  makeCalendarStyles == null || makeCalendarStyles.clearCache();
74
88
  makeTimeStyles == null || makeTimeStyles.clearCache();
89
+ makeHighlightStyles == null || makeHighlightStyles.clearCache();
75
90
  });
76
91
  export { datepicker };
92
+ export var makeStyles = cache(function (k) {
93
+ return /*#__PURE__*/css("&.", k, "-dropdown-open{.", k, "-input-inner{color:", theme.color.placeholder, ";}}");
94
+ });
77
95
  export var makePanelStyles = cache(function makePanelStyles(k) {
78
- return /*#__PURE__*/css("display:flex;.", k, "-datepicker-shortcuts{width:", datepicker.shortcuts.width, ";padding:", datepicker.shortcuts.padding, ";border-right:", datepicker.border, ";}.", k, "-datepicker-shortcut{height:", datepicker.shortcuts.shortcut.height, ";line-height:", datepicker.shortcuts.shortcut.height, ";padding:", datepicker.shortcuts.shortcut.padding, ";cursor:pointer;&:hover{background:", datepicker.shortcuts.shortcut.hoverBgcolor, ";}}.", k, "-datepicker-calendars{display:flex;}.", k, "-datepicker-calendar-wrapper{&:nth-child(2){border-left:", datepicker.border, ";}.", k, "-tabs{border:none;.", k, "-tabs-wrapper{float:none;}.", k, "-tab{width:50%;}}}.", k, "-datepicker-footer{border-top:", datepicker.border, ";padding:", datepicker.footer.padding, ";text-align:right;}");
96
+ return /*#__PURE__*/css("display:flex;.", k, "-datepicker-shortcuts{width:", datepicker.shortcuts.width, ";padding:", datepicker.shortcuts.padding, ";border-right:", datepicker.border, ";}.", k, "-datepicker-shortcut{height:", datepicker.shortcuts.shortcut.height, ";line-height:", datepicker.shortcuts.shortcut.height, ";padding:", datepicker.shortcuts.shortcut.padding, ";cursor:pointer;&:hover{background:", datepicker.shortcuts.shortcut.hoverBgcolor, ";}}.", k, "-datepicker-calendars{display:flex;}.", k, "-datepicker-calendar-wrapper{&:nth-child(2){border-left:", datepicker.border, ";}.", k, "-tabs{border:none;.", k, "-tabs-wrapper{float:none;}.", k, "-tab{width:50%;}}}.", k, "-datepicker-calendar-time-wrapper{display:flex;.", k, "-datepicker-time-time{height:", datepicker.calendarTime.height, ";line-height:", datepicker.calendarTime.height, ";text-align:center;font-size:", datepicker.calendarTime.fontSize, ";}.", k, "-datepicker-time-wrapper{overflow:hidden;height:320px;}}.", k, "-datepicker-footer{border-top:", datepicker.border, ";padding:", datepicker.footer.padding, ";text-align:right;}");
79
97
  });
80
98
  export var makeCalendarStyles = cache(function makeCalendarStyles(k) {
81
- return /*#__PURE__*/css("padding:", datepicker.padding, ";width:", datepicker.width, ";position:relative;.", k, "-datepicker-month{display:flex;padding:", datepicker.month.padding, ";}.", k, "-prev .", k, "-icon,.", k, "-next .", k, "-icon{margin:0 -5px!important;}.", k, "-month-values{flex:1;font-size:14px;text-align:center;cursor:pointer;overflow:hidden;position:relative;}.", k, "-month-value{margin:0 ", datepicker.month.valueGap, ";line-height:", theme.small.height, ";&:hover{color:", theme.color.primary, ";}},.", k, "-weekdays{display:flex;border-bottom:", datepicker.border, ";padding:", datepicker.weekday.padding, ";}.", k, "-weekday{flex:1;text-align:center;}.", k, "-calendar-item{text-align:center;margin:", datepicker.item.gutter, ";aspect-ratio:1;display:flex;align-items:center;cursor:pointer;position:relative;border-radius:", datepicker.item.borderRadius, ";.", k, "-value{border-radius:", datepicker.item.borderRadius, ";}&.", k, "-hover{background:", datepicker.item.hoverBgColor, ";}&.", k, "-exceed{color:", datepicker.item.exceedColor, ";}&.", k, "-today .", k, "-value{border:", datepicker.item.todayBorder, ";}&.", k, "-active{background:", datepicker.item.active.bgColor, ";color:", datepicker.item.active.color, ";&.", k, "-today .", k, "-value{border-color:", datepicker.item.active.todayBorderColor, ";}}&.", k, "-disabled{color:", datepicker.item.disabled.color, ";cursor:not-allowed;background:", datepicker.item.disabled.hoverBgColor, ";}&.", k, "-in-range:after{content:'';display:block;position:absolute;box-sizing:content-box;background:", datepicker.item.range.bgColor, ";width:100%;height:100%;left:-", datepicker.item.gutter, ";padding:0 ", datepicker.item.gutter, ";z-index:-1;}.", k, "-value{flex:1;display:flex;align-items:center;justify-content:center;height:100%;}}.", k, "-days{display:grid;grid-template-columns:repeat(7, 1fr);}.", k, "-years{display:grid;grid-template-columns:repeat(4, 1fr);}");
99
+ return /*#__PURE__*/css("padding:", datepicker.padding, ";width:", datepicker.width, ";position:relative;.", k, "-datepicker-month{display:flex;padding:", datepicker.month.padding, ";}.", k, "-prev .", k, "-icon,.", k, "-next .", k, "-icon{margin:0 -5px!important;}.", k, "-month-values{flex:1;font-size:14px;text-align:center;cursor:pointer;overflow:hidden;position:relative;}.", k, "-month-value{margin:0 ", datepicker.month.valueGap, ";line-height:", theme.small.height, ";&:hover{color:", theme.color.primary, ";}},.", k, "-weekdays{display:flex;border-bottom:", datepicker.border, ";padding:", datepicker.weekday.padding, ";}.", k, "-weekday{flex:1;text-align:center;}.", k, "-calendar-item{text-align:center;margin:", datepicker.item.gutter, ";aspect-ratio:1;display:flex;align-items:center;cursor:pointer;position:relative;border-radius:", datepicker.item.borderRadius, ";.", k, "-value{border-radius:", datepicker.item.borderRadius, ";}&.", k, "-hover{background:", datepicker.item.hoverBgColor, ";}&.", k, "-exceed{color:", datepicker.item.exceedColor, ";}&.", k, "-today .", k, "-value{border:", datepicker.item.todayBorder, ";}&.", k, "-active{background:", datepicker.item.active.bgColor, ";color:", datepicker.item.active.color, ";&.", k, "-today .", k, "-value{border-color:", datepicker.item.active.todayBorderColor, ";}}&.", k, "-disabled{color:", datepicker.item.disabled.color, ";cursor:not-allowed;background:", datepicker.item.disabled.hoverBgColor, ";}&.", k, "-in-range:after{content:'';display:block;position:absolute;box-sizing:content-box;background:", datepicker.item.range.bgColor, ";width:100%;height:100%;left:-", datepicker.item.gutter, ";padding:0 ", datepicker.item.gutter, ";z-index:-1;}.", k, "-value{flex:1;display:flex;align-items:center;justify-content:center;height:100%;}}.", k, "-days{display:grid;grid-template-columns:repeat(7, 1fr);}.", k, "-years{display:grid;justify-items:center;grid-template-columns:repeat(3, 1fr);gap:0;.", k, "-calendar-item{height:20px;width:40px;&.", k, "-in-range:after{width:calc(100% + 14px);left:calc(-", datepicker.item.yearGutter, " / 2);padding:0 calc(", datepicker.item.yearGutter, " / 2);}}}.", k, "-weeks{display:grid;.week-row{display:flex;align-items:center;width:", datepicker.week.width, ";margin:", datepicker.week.margin, ";.", k, "-week-number{padding:", datepicker.week.padding, ";cursor:pointer;}}.", k, "-calendar-item{height:", datepicker.week.height, ";&.", k, "-today:not(:last-child) .", k, "-value{background:", datepicker.week.currentWeek, ";border:0;&:after{content:'';display:block;position:absolute;box-sizing:content-box;background:", datepicker.week.currentWeek, ";width:100%;height:100%;left:0;padding:0 ", datepicker.item.rangeGutter, ";z-index:-1;}}&.", k, "-today:last-child .", k, "-value{border:0;}}}");
82
100
  });
83
101
  export var makeTimeStyles = cache(function makeTimeStyles(k) {
84
- return /*#__PURE__*/css("display:flex;padding:", datepicker.padding, ";width:", datepicker.width, ";position:relative;.", k, "-scroll-select{flex:1;height:305px;}");
102
+ return /*#__PURE__*/css("display:flex;padding:", datepicker.padding, ";width:", datepicker.width, ";position:relative;.", k, "-scroll-select{flex:1;height:265px;}");
103
+ });
104
+ export var makeHighlightStyles = cache(function makeHighlightStyles(k, size, highlightWidth, highlightLeft) {
105
+ var paddingLeft = getLeft(select[size].padding);
106
+ return /*#__PURE__*/css("&.", k, "-dropdown-open{&:before{content:'';display:block;width:", highlightWidth ? highlightWidth + 'px' : '50%', ";height:1px;position:absolute;background-color:", datepicker.item.active.bgColor, ";left:calc(", paddingLeft, " + ", highlightLeft, "px);bottom:0;transition:left ", theme.transition.middle, ";}}");
85
107
  });
@@ -0,0 +1,6 @@
1
+ import type { useFormats } from './useFormats';
2
+ import { useHighlight } from './useHighlight';
3
+ import { useValue } from './useValue';
4
+ export declare function useConfirm(highlight: ReturnType<typeof useHighlight>, value: ReturnType<typeof useValue>, getValueString: ReturnType<typeof useFormats>['getValueString']): {
5
+ onConfirm: () => void;
6
+ };
@@ -0,0 +1,65 @@
1
+ import { useInstance } from 'intact-vue-next';
2
+ import { last } from '../utils';
3
+ export function useConfirm(highlight, value, getValueString) {
4
+ var instance = useInstance();
5
+ var selectionState = [false, false];
6
+ /**
7
+ * can not use hide event to do it
8
+ * because value will be reset to dayjsValue on hide in useValue
9
+ */
10
+ instance.on('$change:show', function (show) {
11
+ if (!show) {
12
+ reset();
13
+ if (instance.get('range') && hasWholeRangeValue()) {
14
+ // to fix the order
15
+ value.updateValue();
16
+ }
17
+ }
18
+ });
19
+ instance.on('selecting', function () {
20
+ var _instance$get = instance.get(),
21
+ type = _instance$get.type;
22
+ if (type !== 'datetime') {
23
+ onConfirm();
24
+ }
25
+ });
26
+ function reset() {
27
+ selectionState = [false, false];
28
+ }
29
+ function onConfirm() {
30
+ var _instance$get2 = instance.get(),
31
+ multiple = _instance$get2.multiple,
32
+ range = _instance$get2.range;
33
+ if (range) {
34
+ var position = highlight.position.value;
35
+ selectionState[position] = true;
36
+ if (selectionState.every(function (state) {
37
+ return state;
38
+ })) {
39
+ if (!multiple) {
40
+ instance.hide();
41
+ } else {
42
+ // update value directly on multiple mode
43
+ reset();
44
+ value.unique();
45
+ value.updateValue();
46
+ }
47
+ }
48
+ highlight.togglePosition();
49
+ } else {
50
+ if (!multiple) {
51
+ instance.hide();
52
+ } else {
53
+ value.unique();
54
+ }
55
+ value.updateValue();
56
+ }
57
+ }
58
+ function hasWholeRangeValue() {
59
+ var lastValue = last(value.value.value);
60
+ return lastValue && lastValue.length === 2;
61
+ }
62
+ return {
63
+ onConfirm: onConfirm
64
+ };
65
+ }
@@ -1,11 +1,13 @@
1
1
  import { State } from '../../hooks/useState';
2
- import { Dayjs, OpUnitType } from 'dayjs';
2
+ import { Dayjs, OpUnitType, QUnitType } from './dayjs';
3
3
  import type { useFormats } from './useFormats';
4
- import { PanelFlags } from './usePanel';
5
- export declare function useDisabled({ createDateByValueFormat }: ReturnType<typeof useFormats>): {
6
- isDisabled: (value: Dayjs, type?: OpUnitType) => boolean;
7
- isDisabledTime: (value: Dayjs, flag: PanelFlags) => boolean;
4
+ import { StateValueItem } from './useValueBase';
5
+ import { Position } from './useHighlight';
6
+ export declare function useDisabled({ createDateByValueFormat }: ReturnType<typeof useFormats>, getHighlightPosition?: () => State<Position>): {
7
+ isDisabled: (value: Dayjs, type?: OpUnitType | QUnitType) => boolean;
8
+ isDisabledTime: (value: Dayjs) => boolean;
8
9
  isDisabledConfirm: () => boolean;
10
+ isDisabledValue: (value: StateValueItem) => boolean;
9
11
  maxDate: State<Dayjs | null>;
10
12
  minDate: State<Dayjs | null>;
11
13
  };
@@ -2,8 +2,7 @@ import { useInstance } from 'intact-vue-next';
2
2
  import { useState } from '../../hooks/useState';
3
3
  import { isNullOrUndefined } from 'intact-shared';
4
4
  import { isGT, isLT, last } from './helpers';
5
- import { PanelFlags, PanelTypes } from './usePanel';
6
- export function useDisabled(_ref) {
5
+ export function useDisabled(_ref, getHighlightPosition) {
7
6
  var createDateByValueFormat = _ref.createDateByValueFormat;
8
7
  var instance = useInstance();
9
8
  var maxDate = useState(null);
@@ -29,41 +28,36 @@ export function useDisabled(_ref) {
29
28
  disabledDate = _instance$get.disabledDate;
30
29
  return isGT(value, maxDate.value, type) || isLT(value, minDate.value, type) || !!disabledDate && disabledDate(value);
31
30
  }
32
- function isDisabledTime(value, flag) {
33
- if (!isDisabled(value, 'second')) {
34
- if (!instance.get('range')) return false;
35
- // compare the start and the end datetime
36
- var anotherDatetime = instance.value.getTimeValue(flag === PanelFlags.Start ? PanelFlags.End : PanelFlags.Start);
37
- if (!anotherDatetime) return false;
38
- if (flag === PanelFlags.Start) {
39
- return value.isAfter(anotherDatetime, 'second');
40
- } else {
41
- return value.isBefore(anotherDatetime, 'second');
42
- }
43
- }
44
- return true;
31
+ function isDisabledTime(value) {
32
+ return isDisabled(value, 'second');
45
33
  }
46
34
  function isDisabledConfirm() {
47
35
  var lastValue = last(instance.value.value.value);
48
- if (!lastValue) return true;
49
36
  var _instance$get2 = instance.get(),
50
- range = _instance$get2.range;
51
- if (range && lastValue.length < 2) return true;
52
- var _instance$panel = instance.panel,
53
- startPanel = _instance$panel.startPanel,
54
- endPanel = _instance$panel.endPanel;
55
- if (startPanel.value === PanelTypes.Date && endPanel.value === PanelTypes.Date) {
56
- return true;
37
+ range = _instance$get2.range,
38
+ multiple = _instance$get2.multiple;
39
+ if (!lastValue || instance.value.allValuesUpdatedInMultipleMode()) return true;
40
+ if (range && getHighlightPosition) {
41
+ var position = getHighlightPosition();
42
+ // if the position is not selected, it should be disabled
43
+ if (!lastValue[position.value]) {
44
+ return true;
45
+ }
57
46
  }
47
+ return isDisabledValue(lastValue);
48
+ }
49
+ function isDisabledValue(value) {
50
+ var _instance$get3 = instance.get(),
51
+ range = _instance$get3.range;
58
52
  var start;
59
53
  var end;
60
54
  if (range) {
61
- start = lastValue[0];
62
- end = lastValue[1];
55
+ start = value[0];
56
+ end = value[1];
63
57
  } else {
64
- start = lastValue;
58
+ start = value;
65
59
  }
66
- if (isDisabledTime(start, PanelFlags.Start) || end && isDisabledTime(end, PanelFlags.End)) {
60
+ if (isDisabledTime(start) || end && isDisabledTime(end)) {
67
61
  return true;
68
62
  }
69
63
  return false;
@@ -72,6 +66,7 @@ export function useDisabled(_ref) {
72
66
  isDisabled: isDisabled,
73
67
  isDisabledTime: isDisabledTime,
74
68
  isDisabledConfirm: isDisabledConfirm,
69
+ isDisabledValue: isDisabledValue,
75
70
  maxDate: maxDate,
76
71
  minDate: minDate
77
72
  };
@@ -1,5 +1,5 @@
1
- import dayjs, { Dayjs } from './dayjs';
2
- import { Value } from './basepicker';
1
+ import dayjs, { Dayjs } from 'dayjs';
2
+ import type { Value } from './useValueBase';
3
3
  export declare function useFormats(): {
4
4
  getValueFormat: () => string;
5
5
  getShowFormat: () => string;
@@ -1,11 +1,13 @@
1
1
  import { useInstance } from 'intact-vue-next';
2
- import dayjs from './dayjs';
2
+ import dayjs from 'dayjs';
3
3
  import { isString } from 'intact-shared';
4
4
  var FORMATS = {
5
5
  date: 'YYYY-MM-DD',
6
6
  datetime: 'YYYY-MM-DD HH:mm:ss',
7
7
  year: 'YYYY',
8
- month: 'YYYY-MM'
8
+ month: 'YYYY-MM',
9
+ quarter: 'YYYY-[Q]Q',
10
+ week: 'YYYY-w[周]'
9
11
  };
10
12
  export function useFormats() {
11
13
  var instance = useInstance();
@@ -23,8 +25,12 @@ export function useFormats() {
23
25
  type = _instance$get2.type;
24
26
  return showFormat || format || FORMATS[type];
25
27
  }
28
+ /**
29
+ * 根据日期字符串,按照格式创建日期对象
30
+ */
26
31
  function createDateByValueFormat(value) {
27
- return dayjs(value, isString(value) ? getValueFormat() : undefined);
32
+ var format = isString(value) ? getValueFormat() : undefined;
33
+ return dayjs(value, format);
28
34
  }
29
35
  function createDateByShowFormat(value) {
30
36
  return dayjs(value, getShowFormat(), true); // strict parsing
@@ -0,0 +1,14 @@
1
+ import { State } from '../../hooks/useState';
2
+ import { StateValue } from './useValueBase';
3
+ import { Dayjs } from 'dayjs';
4
+ export declare enum Position {
5
+ Start = 0,
6
+ End = 1
7
+ }
8
+ export declare function useHighlight(value: State<StateValue>, getShowString: (value: Dayjs) => string, keywords: State<string>): {
9
+ position: State<Position>;
10
+ handleInputClick: () => void;
11
+ togglePosition: () => void;
12
+ highlightWidth: State<number>;
13
+ highlightLeft: State<number>;
14
+ };
@@ -0,0 +1,60 @@
1
+ import { useInstance, onMounted } from 'intact-vue-next';
2
+ import { useState, watchState } from '../../hooks/useState';
3
+ import dayjs from 'dayjs';
4
+ export var Position;
5
+ (function (Position) {
6
+ Position[Position["Start"] = 0] = "Start";
7
+ Position[Position["End"] = 1] = "End";
8
+ })(Position || (Position = {}));
9
+ var DELIMITER_WIDTH = 14;
10
+ var fakeDate = dayjs();
11
+ export function useHighlight(value, getShowString, keywords) {
12
+ var instance = useInstance();
13
+ var position = useState(Position.Start);
14
+ var highlightWidth = useState(0);
15
+ var highlightLeft = useState(0);
16
+ /**
17
+ * calculate the real width by rendering the showString to fake div
18
+ */
19
+ onMounted(function () {
20
+ var showString = getShowString(fakeDate);
21
+ instance.input.inputRef.value.getStringWidth(showString).then(function (width) {
22
+ highlightWidth.set(width);
23
+ });
24
+ });
25
+ /**
26
+ * change the left of style on position changed
27
+ */
28
+ watchState(position, function (position) {
29
+ highlightLeft.set(position === Position.Start ? 0 : highlightWidth.value + DELIMITER_WIDTH);
30
+ });
31
+ // if value is cleared reset the position to start
32
+ instance.watch('value', function (v) {
33
+ if (!v || Array.isArray(v) && !v.length) {
34
+ position.set(Position.Start);
35
+ }
36
+ });
37
+ function handleInputClick() {
38
+ var _instance$get = instance.get(),
39
+ range = _instance$get.range,
40
+ type = _instance$get.type;
41
+ if (!range) return;
42
+ var cursorPosition = instance.input.inputRef.value.getSelectionStart();
43
+ var showString = getShowString(fakeDate);
44
+ if (!cursorPosition || cursorPosition <= showString.length + 1 /* one whitespace */) {
45
+ position.set(Position.Start);
46
+ } else {
47
+ position.set(Position.End);
48
+ }
49
+ }
50
+ function togglePosition() {
51
+ position.set(position.value === Position.Start ? Position.End : Position.Start);
52
+ }
53
+ return {
54
+ position: position,
55
+ handleInputClick: handleInputClick,
56
+ togglePosition: togglePosition,
57
+ highlightWidth: highlightWidth,
58
+ highlightLeft: highlightLeft
59
+ };
60
+ }
@@ -72,7 +72,8 @@ export function useKeyboards(panelRef, focusDate) {
72
72
  break;
73
73
  }
74
74
  var _focusDate = focusDate.value;
75
- _focusDate = _focusDate.add(offset, type === 'date' ? 'day' : type);
75
+ var unit = type === 'date' ? 'day' : type;
76
+ _focusDate = _focusDate.add(offset, unit);
76
77
  focusDate.set(_focusDate);
77
78
  // change panel show date
78
79
  calendar.showDate.date.set(_focusDate);
@@ -0,0 +1,5 @@
1
+ import { DayjsValue } from './useValueBase';
2
+ import type { useFormats } from './useFormats';
3
+ export declare function useMergeRange(formats: ReturnType<typeof useFormats>): {
4
+ formatMultipleValues: (dayjsValue: DayjsValue, results: string[]) => string[];
5
+ };
@@ -0,0 +1,45 @@
1
+ import _sortInstanceProperty from "@babel/runtime-corejs3/core-js/instance/sort";
2
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
3
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js/instance/filter";
4
+ import { useInstance } from 'intact-vue-next';
5
+ // TODO isMerge
6
+ export function useMergeRange(formats) {
7
+ var instance = useInstance();
8
+ function _mergeRanges(dayjsValue, getShowString) {
9
+ var _context, _context2;
10
+ var ranges = _sortInstanceProperty(_context = _mapInstanceProperty(_context2 = _filterInstanceProperty(dayjsValue).call(dayjsValue, Array.isArray)).call(_context2, function (range) {
11
+ return {
12
+ start: range[0],
13
+ end: range[1]
14
+ };
15
+ })).call(_context, function (a, b) {
16
+ return a.start.valueOf() - b.start.valueOf();
17
+ });
18
+ if (ranges.length === 0) return [];
19
+ // 合并有交集的时间范围
20
+ var mergedRange = ranges.reduce(function (acc, curr) {
21
+ if (!acc) return curr;
22
+ return {
23
+ start: acc.start,
24
+ end: curr.end.valueOf() > acc.end.valueOf() ? curr.end : acc.end
25
+ };
26
+ });
27
+ return [getShowString(mergedRange.start) + " ~ " + getShowString(mergedRange.end)];
28
+ }
29
+ function formatMultipleValues(dayjsValue, results) {
30
+ // const {isMerge, nowrap} = instance.get();
31
+ // if (isMerge && nowrap) {
32
+ // const mergedResults = _mergeRanges(dayjsValue, (v: Dayjs) => v.format(formats.getShowFormat()));
33
+ // if (mergedResults.length > 0) {
34
+ // return [
35
+ // ...mergedResults,
36
+ // ...results.slice(1).map((result, index) => `${result}-${index}`)
37
+ // ];
38
+ // }
39
+ // }
40
+ return results;
41
+ }
42
+ return {
43
+ formatMultipleValues: formatMultipleValues
44
+ };
45
+ }
@@ -26,10 +26,12 @@ export function useMonths(showDate, status, focusDate) {
26
26
  function onClick(date) {
27
27
  showDate.set(date);
28
28
  var datepickerType = instance.datepicker.get('type');
29
- if (datepickerType !== 'month' && datepickerType !== 'year') {
30
- instance.type.set('date');
31
- } else {
29
+ if (datepickerType === 'month' || datepickerType === 'year') {
32
30
  instance.triggerChange(date);
31
+ } else if (datepickerType === 'week') {
32
+ instance.type.set('week');
33
+ } else {
34
+ instance.type.set('date');
33
35
  }
34
36
  }
35
37
  return {