@canlooks/can-ui 0.0.45 → 0.0.47

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 (101) hide show
  1. package/dist/cjs/components/button/button.js +2 -2
  2. package/dist/cjs/components/button/button.style.js +2 -0
  3. package/dist/cjs/components/calendar/calendar.d.ts +32 -0
  4. package/dist/cjs/components/calendar/calendar.js +51 -0
  5. package/dist/cjs/components/calendar/calendar.style.d.ts +15 -0
  6. package/dist/cjs/components/{dateTimePicker → calendar}/calendar.style.js +131 -91
  7. package/dist/cjs/components/calendar/index.d.ts +1 -0
  8. package/dist/cjs/components/calendar/index.js +4 -0
  9. package/dist/cjs/components/calendar/panelDates.d.ts +2 -0
  10. package/dist/cjs/components/{dateTimePicker/calendarDates.js → calendar/panelDates.js} +11 -19
  11. package/dist/cjs/components/calendar/panelMonth.d.ts +2 -0
  12. package/dist/cjs/components/calendar/panelMonth.js +29 -0
  13. package/dist/cjs/components/calendar/panelYear.d.ts +2 -0
  14. package/dist/cjs/components/calendar/panelYear.js +36 -0
  15. package/dist/cjs/components/checkboxBase/checkboxBase.js +2 -2
  16. package/dist/cjs/components/colorPicker/colorPicker.js +2 -2
  17. package/dist/cjs/components/colorPicker/colorPicker.style.js +1 -1
  18. package/dist/cjs/components/dateTimePicker/dateTimePicker.d.ts +1 -1
  19. package/dist/cjs/components/dateTimePicker/dateTimePicker.js +10 -13
  20. package/dist/cjs/components/dateTimePicker/dateTimePicker.style.d.ts +4 -4
  21. package/dist/cjs/components/dateTimePicker/dateTimePicker.style.js +1 -1
  22. package/dist/cjs/components/dateTimePicker/index.d.ts +1 -1
  23. package/dist/cjs/components/dateTimePicker/index.js +1 -1
  24. package/dist/cjs/components/dateTimeRangePicker/dateTimeRangePicker.d.ts +1 -0
  25. package/dist/cjs/components/icon/icon.d.ts +6 -0
  26. package/dist/cjs/components/icon/icon.js +9 -0
  27. package/dist/cjs/components/icon/index.d.ts +1 -0
  28. package/dist/cjs/components/icon/index.js +4 -0
  29. package/dist/cjs/components/menuItem/menuItem.style.js +8 -3
  30. package/dist/cjs/components/pinchable/pinchable.style.js +1 -1
  31. package/dist/cjs/components/popper/popper.js +1 -1
  32. package/dist/cjs/components/slider/slider.d.ts +0 -1
  33. package/dist/cjs/components/tooltip/tooltip.style.js +1 -0
  34. package/dist/cjs/components/touchRipple/touchRipple.js +0 -4
  35. package/dist/cjs/components/waterfall/waterfall.style.js +1 -1
  36. package/dist/cjs/components/waterfall/waterfallItem.js +1 -1
  37. package/dist/cjs/extensions/documentViewer/documentViewer.js +1 -1
  38. package/dist/cjs/index.d.ts +2 -1
  39. package/dist/cjs/index.js +2 -3
  40. package/dist/cjs/utils/style.d.ts +2 -2
  41. package/dist/cjs/utils/style.js +3 -3
  42. package/dist/esm/components/button/button.js +3 -3
  43. package/dist/esm/components/button/button.style.js +2 -0
  44. package/dist/esm/components/calendar/calendar.d.ts +32 -0
  45. package/dist/esm/components/calendar/calendar.js +46 -0
  46. package/dist/esm/components/calendar/calendar.style.d.ts +15 -0
  47. package/dist/esm/components/{dateTimePicker → calendar}/calendar.style.js +131 -91
  48. package/dist/esm/components/calendar/index.d.ts +1 -0
  49. package/dist/esm/components/calendar/index.js +1 -0
  50. package/dist/esm/components/calendar/panelDates.d.ts +2 -0
  51. package/dist/esm/components/{dateTimePicker/calendarDates.js → calendar/panelDates.js} +11 -19
  52. package/dist/esm/components/calendar/panelMonth.d.ts +2 -0
  53. package/dist/esm/components/calendar/panelMonth.js +26 -0
  54. package/dist/esm/components/calendar/panelYear.d.ts +2 -0
  55. package/dist/esm/components/calendar/panelYear.js +33 -0
  56. package/dist/esm/components/checkboxBase/checkboxBase.js +3 -3
  57. package/dist/esm/components/colorPicker/colorPicker.js +3 -3
  58. package/dist/esm/components/colorPicker/colorPicker.style.js +1 -1
  59. package/dist/esm/components/dateTimePicker/dateTimePicker.d.ts +1 -1
  60. package/dist/esm/components/dateTimePicker/dateTimePicker.js +11 -14
  61. package/dist/esm/components/dateTimePicker/dateTimePicker.style.d.ts +4 -4
  62. package/dist/esm/components/dateTimePicker/dateTimePicker.style.js +1 -1
  63. package/dist/esm/components/dateTimePicker/index.d.ts +1 -1
  64. package/dist/esm/components/dateTimePicker/index.js +1 -1
  65. package/dist/esm/components/dateTimeRangePicker/dateTimeRangePicker.d.ts +1 -0
  66. package/dist/esm/components/icon/icon.d.ts +6 -0
  67. package/dist/esm/components/icon/icon.js +6 -0
  68. package/dist/esm/components/icon/index.d.ts +1 -0
  69. package/dist/esm/components/icon/index.js +1 -0
  70. package/dist/esm/components/menuItem/menuItem.style.js +8 -3
  71. package/dist/esm/components/pinchable/pinchable.style.js +2 -2
  72. package/dist/esm/components/popper/popper.js +1 -1
  73. package/dist/esm/components/slider/slider.d.ts +0 -1
  74. package/dist/esm/components/tooltip/tooltip.style.js +1 -0
  75. package/dist/esm/components/touchRipple/touchRipple.js +0 -4
  76. package/dist/esm/components/waterfall/waterfall.style.js +2 -2
  77. package/dist/esm/components/waterfall/waterfallItem.js +1 -1
  78. package/dist/esm/extensions/documentViewer/documentViewer.js +1 -1
  79. package/dist/esm/index.d.ts +2 -1
  80. package/dist/esm/index.js +2 -1
  81. package/dist/esm/utils/style.d.ts +2 -2
  82. package/dist/esm/utils/style.js +2 -2
  83. package/documentation/dist/assets/{index-Dqm5gD_7.js → index-DpTyMkMP.js} +1707 -1660
  84. package/documentation/dist/index.html +1 -1
  85. package/package.json +1 -1
  86. package/dist/cjs/components/dateTimePicker/calendar.d.ts +0 -18
  87. package/dist/cjs/components/dateTimePicker/calendar.js +0 -29
  88. package/dist/cjs/components/dateTimePicker/calendar.style.d.ts +0 -15
  89. package/dist/cjs/components/dateTimePicker/calendarDates.d.ts +0 -2
  90. package/dist/cjs/components/dateTimePicker/calendarMonths.d.ts +0 -2
  91. package/dist/cjs/components/dateTimePicker/calendarMonths.js +0 -22
  92. package/dist/cjs/components/dateTimePicker/calendarYears.d.ts +0 -2
  93. package/dist/cjs/components/dateTimePicker/calendarYears.js +0 -29
  94. package/dist/esm/components/dateTimePicker/calendar.d.ts +0 -18
  95. package/dist/esm/components/dateTimePicker/calendar.js +0 -25
  96. package/dist/esm/components/dateTimePicker/calendar.style.d.ts +0 -15
  97. package/dist/esm/components/dateTimePicker/calendarDates.d.ts +0 -2
  98. package/dist/esm/components/dateTimePicker/calendarMonths.d.ts +0 -2
  99. package/dist/esm/components/dateTimePicker/calendarMonths.js +0 -19
  100. package/dist/esm/components/dateTimePicker/calendarYears.d.ts +0 -2
  101. package/dist/esm/components/dateTimePicker/calendarYears.js +0 -26
@@ -2,99 +2,139 @@ import { css } from '@emotion/react';
2
2
  import { defineInnerClasses, defineCss } from '../../utils';
3
3
  import { menuListPadding } from '../menuItem/menuItem.style';
4
4
  export const classes = defineInnerClasses('calendar', [
5
- 'calendarHead',
6
- 'calendarHeadSide',
7
- 'calendarHeadControl',
8
- 'calendarHeadCenter',
9
- 'calendarHeadButton',
10
- 'calendarBody',
5
+ 'head',
6
+ 'headSide',
7
+ 'headControl',
8
+ 'headCenter',
9
+ 'headButton',
10
+ 'body',
11
11
  'dateItem',
12
12
  'monthItem',
13
13
  'yearItem',
14
- 'calendarFoot'
14
+ 'foot'
15
15
  ]);
16
- export const style = defineCss(({ divider, text, spacing }) => css `
17
- .${classes.calendarHead} {
18
- height: 40px;
19
- display: flex;
20
- align-items: center;
21
- justify-content: space-between;
22
- border-bottom: 1px solid ${divider};
23
- padding: 0 ${menuListPadding}px;
24
- position: relative;
25
-
26
- .${classes.calendarHeadSide} {
27
- z-index: 1;
28
- }
29
-
30
- .${classes.calendarHeadControl} {
31
- color: ${text.placeholder};
32
- }
33
-
34
- .${classes.calendarHeadCenter} {
35
- display: flex;
36
- align-items: center;
37
- justify-content: center;
38
- position: absolute;
39
- inset: 0;
40
-
41
- .${classes.calendarHeadButton} {
42
- font-weight: bold;
43
- color: ${text.primary};
44
- }
45
- }
46
- }
47
-
48
- .${classes.calendarBody} {
49
- padding: ${spacing[3]}px ${spacing[4]}px;
50
- display: grid;
51
- place-items: center;
52
-
53
- &[data-view-type=dates] {
54
- font-size: ${13 / 14}em;
55
- grid-template-columns: repeat(7, 36px);
56
- grid-template-rows: repeat(7, 36px);
57
-
58
- .${classes.dateItem} {
59
- width: 24px;
60
- height: 24px;
61
-
62
- &:not([data-variant=filled]) {
63
- color: ${text.primary};
64
- border-color: ${text.disabled};
65
-
66
- &[data-other-month=true] {
67
- color: ${text.placeholder};
68
- }
69
- }
70
-
71
- &:disabled {
72
- width: 100%;
73
- border-radius: 0;
74
- }
75
- }
76
- }
77
-
78
- &[data-view-type=months] {
79
- grid-template-columns: repeat(3, 84px);
80
- grid-template-rows: repeat(4, 63px);
81
-
82
- .${classes.monthItem},
83
- .${classes.yearItem} {
84
- width: 72px;
85
-
86
- &:not([data-variant=filled]) {
87
- color: ${text.primary};
88
- }
89
- }
90
- }
91
- }
92
-
93
- .${classes.calendarFoot} {
94
- height: 41px;
95
- display: flex;
96
- align-items: center;
97
- justify-content: center;
98
- border-top: 1px solid ${divider};
99
- }
16
+ export const style = defineCss(({ divider, text, spacing }) => css `
17
+ .${classes.head} {
18
+ height: 40px;
19
+ display: flex;
20
+ align-items: center;
21
+ justify-content: space-between;
22
+ border-bottom: 1px solid ${divider};
23
+ padding: 0 ${menuListPadding}px;
24
+ position: relative;
25
+
26
+ .${classes.headSide} {
27
+ z-index: 1;
28
+ }
29
+
30
+ .${classes.headControl} {
31
+ color: ${text.placeholder};
32
+ }
33
+
34
+ .${classes.headCenter} {
35
+ display: flex;
36
+ align-items: center;
37
+ justify-content: center;
38
+ position: absolute;
39
+ inset: 0;
40
+
41
+ .${classes.headButton} {
42
+ font-weight: bold;
43
+ color: ${text.primary};
44
+ }
45
+ }
46
+ }
47
+
48
+ .${classes.body} {
49
+ padding: ${spacing[3]}px ${spacing[4]}px;
50
+ display: grid;
51
+ place-items: center;
52
+
53
+ &[data-view-type=date] {
54
+ font-size: ${13 / 14}em;
55
+ grid-template-columns: repeat(7, 36px);
56
+ grid-template-rows: repeat(7, 36px);
57
+
58
+ .${classes.dateItem} {
59
+ width: 24px;
60
+ height: 24px;
61
+
62
+ &:not([data-variant=filled]) {
63
+ color: ${text.primary};
64
+ border-color: ${text.disabled};
65
+
66
+ &[data-other-month=true] {
67
+ color: ${text.placeholder};
68
+ }
69
+ }
70
+
71
+ &:disabled {
72
+ width: 100%;
73
+ border-radius: 0;
74
+ }
75
+ }
76
+ }
77
+
78
+ &[data-view-type=month], &[data-view-type=year] {
79
+ grid-template-columns: repeat(3, 84px);
80
+ grid-template-rows: repeat(4, 63px);
81
+
82
+ .${classes.monthItem},
83
+ .${classes.yearItem} {
84
+ width: 72px;
85
+ padding-inline: 0;
86
+
87
+ &:not([data-variant=filled]) {
88
+ color: ${text.primary};
89
+ }
90
+ }
91
+ }
92
+ }
93
+
94
+ &[data-size=small] {
95
+ .${classes.body} {
96
+ &[data-view-type=date] {
97
+ grid-template-columns: repeat(7, 30px);
98
+ grid-template-rows: repeat(7, 30px);
99
+ }
100
+
101
+ &[data-view-type=month], &[data-view-type=year] {
102
+ grid-template-columns: repeat(3, 70px);
103
+ grid-template-rows: repeat(4, 52.5px);
104
+
105
+ .${classes.monthItem},
106
+ .${classes.yearItem} {
107
+ width: 60px;
108
+ }
109
+ }
110
+ }
111
+ }
112
+
113
+ &[data-size=large] {
114
+ .${classes.body} {
115
+ &[data-view-type=date] {
116
+ font-size: 1em;
117
+ grid-template-columns: repeat(7, 42px);
118
+ grid-template-rows: repeat(7, 42px);
119
+
120
+ .${classes.dateItem} {
121
+ width: 32px;
122
+ height: 32px;
123
+ }
124
+ }
125
+
126
+ &[data-view-type=month], &[data-view-type=year] {
127
+ grid-template-columns: repeat(3, 98px);
128
+ grid-template-rows: repeat(4, 73.5px);
129
+ }
130
+ }
131
+ }
132
+
133
+ .${classes.foot} {
134
+ height: 41px;
135
+ display: flex;
136
+ align-items: center;
137
+ justify-content: center;
138
+ border-top: 1px solid ${divider};
139
+ }
100
140
  `);
@@ -0,0 +1 @@
1
+ export * from './calendar';
@@ -0,0 +1 @@
1
+ export * from './calendar';
@@ -0,0 +1,2 @@
1
+ import { PanelProps } from './calendar';
2
+ export declare const PanelDates: import("react").MemoExoticComponent<({ value, setValue, innerD, setInnerD, setViewType, min, max, disabledDates, showToday, _defaultNull }: PanelProps) => import("@emotion/react/jsx-runtime").JSX.Element>;
@@ -1,16 +1,14 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
2
2
  import { memo } from 'react';
3
- import { classes } from './calendar.style';
4
3
  import { Button } from '../button';
5
- import { Tooltip } from '../tooltip';
6
4
  import dayjs from 'dayjs';
7
- import { style } from './calendar.style';
8
- import { useDateTimePickerContext } from './dateTimePicker';
9
- import { Icon } from '../..';
5
+ import { Tooltip } from '../tooltip';
6
+ import { Icon } from '../icon';
10
7
  import { faAnglesLeft } from '@fortawesome/free-solid-svg-icons/faAnglesLeft';
11
8
  import { faAngleLeft } from '@fortawesome/free-solid-svg-icons/faAngleLeft';
12
9
  import { faAngleRight } from '@fortawesome/free-solid-svg-icons/faAngleRight';
13
10
  import { faAnglesRight } from '@fortawesome/free-solid-svg-icons/faAnglesRight';
11
+ import { classes } from './calendar.style';
14
12
  const days = ['一', '二', '三', '四', '五', '六', '日'];
15
13
  const renderedDaysList = (() => {
16
14
  const ret = [];
@@ -24,7 +22,7 @@ const commonButtonProps = {
24
22
  size: 'small',
25
23
  color: 'text'
26
24
  };
27
- export const CalendarDates = memo(({ defaultNull, value, onChange, innerD, setInnerD, setViewType }) => {
25
+ export const PanelDates = memo(({ value, setValue, innerD, setInnerD, setViewType, min, max, disabledDates, showToday, _defaultNull }) => {
28
26
  const today = dayjs();
29
27
  const prevMonth = () => {
30
28
  setInnerD(d => d.subtract(1, 'month'));
@@ -38,8 +36,7 @@ export const CalendarDates = memo(({ defaultNull, value, onChange, innerD, setIn
38
36
  const nextYear = () => {
39
37
  setInnerD(d => d.add(1, 'year'));
40
38
  };
41
- const renderHeadControl = (icon, title, onClick) => (_jsx(Tooltip, { title: title, children: _jsx(Button, { ...commonButtonProps, className: classes.calendarHeadControl, onClick: onClick, children: icon }) }));
42
- const { min, max, disabledDates } = useDateTimePickerContext();
39
+ const renderHeadControl = (icon, title, onClick) => (_jsx(Tooltip, { title: title, children: _jsx(Button, { ...commonButtonProps, className: classes.headControl, onClick: onClick, children: icon }) }));
43
40
  const isDisabled = (d) => {
44
41
  if (disabledDates && !disabledDates(d)) {
45
42
  return true;
@@ -47,10 +44,7 @@ export const CalendarDates = memo(({ defaultNull, value, onChange, innerD, setIn
47
44
  if (min && min.isAfter(d)) {
48
45
  return true;
49
46
  }
50
- if (max && max.isBefore(d)) {
51
- return true;
52
- }
53
- return false;
47
+ return max && max.isBefore(d);
54
48
  };
55
49
  const renderDates = () => {
56
50
  let startD = innerD.date(0);
@@ -62,17 +56,15 @@ export const CalendarDates = memo(({ defaultNull, value, onChange, innerD, setIn
62
56
  : offset < 0 ? startD.subtract(-offset, 'days')
63
57
  : startD;
64
58
  const isToday = _d.isSame(today, 'day');
65
- const selected = _d.isSame(value, 'day');
59
+ const selected = !_defaultNull && _d.isSame(value, 'day');
66
60
  const isCurrentMonth = _d.isSame(innerD, 'month');
67
61
  const disabled = isDisabled(_d);
68
62
  ret.push(_jsx(Button, { className: classes.dateItem, size: "small", variant: disabled || selected ? 'filled'
69
63
  : isToday ? 'outlined'
70
- : 'text', disabled: disabled, color: selected ? 'primary' : 'text', "data-other-month": !isCurrentMonth, onClick: () => {
71
- // 默认为空时,任何日期都可选中
72
- (!selected || defaultNull) && onChange(_d);
73
- }, children: _d.date() }, i));
64
+ : 'text', disabled: disabled, color: selected ? 'primary' : 'text', "data-other-month": !isCurrentMonth, onClick: () => !selected && setValue(_d), children: _d.date() }, i));
74
65
  }
75
66
  return ret;
76
67
  };
77
- return (_jsxs("div", { css: style, className: classes.root, children: [_jsxs("div", { className: classes.calendarHead, children: [_jsxs("div", { className: classes.calendarHeadSide, children: [renderHeadControl(_jsx(Icon, { icon: faAnglesLeft }), '上一年', prevYear), renderHeadControl(_jsx(Icon, { icon: faAngleLeft }), '上一月', prevMonth)] }), _jsxs("div", { className: classes.calendarHeadSide, children: [renderHeadControl(_jsx(Icon, { icon: faAngleRight }), '下一月', nextMonth), renderHeadControl(_jsx(Icon, { icon: faAnglesRight }), '下一年', nextYear)] }), _jsxs("div", { className: classes.calendarHeadCenter, children: [_jsxs(Button, { ...commonButtonProps, className: classes.calendarHeadButton, onClick: () => setViewType('years'), children: [innerD.year(), "\u5E74"] }), _jsxs(Button, { ...commonButtonProps, className: classes.calendarHeadButton, onClick: () => setViewType('months'), children: [(innerD.month() + 1).toString().padStart(2, '0'), "\u6708"] })] })] }), _jsxs("div", { className: classes.calendarBody, "data-view-type": "dates", children: [renderedDaysList, renderDates()] }), _jsx("div", { className: classes.calendarFoot, children: _jsx(Button, { variant: "text", onClick: () => onChange(dayjs()), children: "\u56DE\u4ECA\u5929" }) })] }));
68
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { className: classes.head, children: [_jsxs("div", { className: classes.headSide, children: [renderHeadControl(_jsx(Icon, { icon: faAnglesLeft }), '上一年', prevYear), renderHeadControl(_jsx(Icon, { icon: faAngleLeft }), '上一月', prevMonth)] }), _jsxs("div", { className: classes.headSide, children: [renderHeadControl(_jsx(Icon, { icon: faAngleRight }), '下一月', nextMonth), renderHeadControl(_jsx(Icon, { icon: faAnglesRight }), '下一年', nextYear)] }), _jsxs("div", { className: classes.headCenter, children: [_jsxs(Button, { ...commonButtonProps, className: classes.headButton, onClick: () => setViewType('year'), children: [innerD.year(), "\u5E74"] }), _jsxs(Button, { ...commonButtonProps, className: classes.headButton, onClick: () => setViewType('month'), children: [(innerD.month() + 1).toString().padStart(2, '0'), "\u6708"] })] })] }), _jsxs("div", { className: classes.body, "data-view-type": "date", children: [renderedDaysList, renderDates()] }), showToday &&
69
+ _jsx("div", { className: classes.foot, children: _jsx(Button, { variant: "text", onClick: () => setValue(dayjs()), children: "\u56DE\u4ECA\u5929" }) })] }));
78
70
  });
@@ -0,0 +1,2 @@
1
+ import { PanelProps } from './calendar';
2
+ export declare const PanelMonth: import("react").MemoExoticComponent<({ innerD, setInnerD, onSelected, min, max }: PanelProps) => import("@emotion/react/jsx-runtime").JSX.Element>;
@@ -0,0 +1,26 @@
1
+ import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
2
+ import { memo } from 'react';
3
+ import { classes } from './calendar.style';
4
+ import { Button } from '../button';
5
+ export const PanelMonth = memo(({ innerD, setInnerD, onSelected, min, max }) => {
6
+ const currentMonth = innerD.month();
7
+ const clickHandler = (d, i) => {
8
+ currentMonth !== i && setInnerD(d);
9
+ onSelected(d);
10
+ };
11
+ const isDisabled = (d) => {
12
+ if (min && min.isAfter(d)) {
13
+ return true;
14
+ }
15
+ return max && max.isBefore(d);
16
+ };
17
+ const renderButtons = () => {
18
+ const ret = [];
19
+ for (let i = 0; i < 12; i++) {
20
+ const d = innerD.month(i);
21
+ ret.push(_jsxs(Button, { className: classes.monthItem, variant: currentMonth === i ? 'filled' : 'text', size: "large", color: currentMonth === i ? 'primary' : 'text', disabled: isDisabled(d), onClick: () => clickHandler(d, i), children: [i + 1, "\u6708"] }, i));
22
+ }
23
+ return ret;
24
+ };
25
+ return (_jsxs(_Fragment, { children: [_jsx("div", { className: classes.head, children: _jsx("div", { className: classes.headCenter, children: "\u6708\u4EFD" }) }), _jsx("div", { className: classes.body, "data-view-type": "month", children: renderButtons() })] }));
26
+ });
@@ -0,0 +1,2 @@
1
+ import { PanelProps } from './calendar';
2
+ export declare const PanelYear: import("react").MemoExoticComponent<({ innerD, setInnerD, onSelected, min, max }: PanelProps) => import("@emotion/react/jsx-runtime").JSX.Element>;
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
2
+ import { memo, useState } from 'react';
3
+ import { classes } from './calendar.style';
4
+ import { Button } from '../button';
5
+ import { Tooltip } from '../tooltip';
6
+ import { Icon } from '../..';
7
+ import { faAngleLeft } from '@fortawesome/free-solid-svg-icons/faAngleLeft';
8
+ import { faAngleRight } from '@fortawesome/free-solid-svg-icons/faAngleRight';
9
+ export const PanelYear = memo(({ innerD, setInnerD, onSelected, min, max }) => {
10
+ const currentYear = innerD.year();
11
+ const clickHandler = (d, yearNum) => {
12
+ currentYear !== yearNum && setInnerD(d);
13
+ onSelected(d);
14
+ };
15
+ const [page, setPage] = useState(() => Math.floor(currentYear / 12));
16
+ const renderHeadControl = (icon, title, onClick) => (_jsx(Tooltip, { title: title, children: _jsx(Button, { className: classes.headControl, variant: "text", size: "small", color: "text", onClick: onClick, children: icon }) }));
17
+ const isDisabled = (d) => {
18
+ if (min && min.isAfter(d)) {
19
+ return true;
20
+ }
21
+ return max && max.isBefore(d);
22
+ };
23
+ const renderButtons = () => {
24
+ const ret = [];
25
+ for (let i = 0; i < 12; i++) {
26
+ const yearNum = page * 12 + i + 1;
27
+ const d = innerD.year(yearNum);
28
+ ret.push(_jsx(Button, { className: classes.monthItem, variant: currentYear === yearNum ? 'filled' : 'text', size: "large", color: currentYear === yearNum ? 'primary' : 'text', disabled: isDisabled(d), onClick: () => clickHandler(d, yearNum), children: yearNum }, i));
29
+ }
30
+ return ret;
31
+ };
32
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { className: classes.head, children: [_jsx("div", { className: classes.headSide, children: renderHeadControl(_jsx(Icon, { icon: faAngleLeft }), '上一页', () => setPage(p => p - 1)) }), _jsx("div", { className: classes.headSide, children: renderHeadControl(_jsx(Icon, { icon: faAngleRight }), '下一页', () => setPage(p => p + 1)) }), _jsx("div", { className: classes.headCenter, children: "\u5E74\u4EFD" })] }), _jsx("div", { className: classes.body, "data-view-type": "year", children: renderButtons() })] }));
33
+ });
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
2
  import { memo, useRef } from 'react';
3
- import { clsx, cloneRef, useControlled, useTouchRipple } from '../../utils';
3
+ import { clsx, cloneRef, useControlled, useTouchSpread } from '../../utils';
4
4
  import { classes, useStyle } from './checkboxBase.style';
5
5
  import { useCheckboxBaseGroupContext } from '../checkboxBaseGroup';
6
6
  import { Icon } from '../..';
@@ -16,12 +16,12 @@ export const CheckboxBase = memo(({ inputProps, _type, size, color, label, value
16
16
  const checkboxRef = useRef(null);
17
17
  const innerInputRef = useRef(null);
18
18
  const [innerChecked, setInnerChecked] = useControlled(defaultChecked, checked);
19
- const showRipple = useTouchRipple(color);
19
+ const showSpread = useTouchSpread(color);
20
20
  const clickHandler = (e) => {
21
21
  if (disabled || readOnly) {
22
22
  return;
23
23
  }
24
- showRipple(checkboxRef.current);
24
+ showSpread(checkboxRef.current);
25
25
  const newChecked = innerInputRef.current.checked = !innerChecked.current;
26
26
  e.target = e.currentTarget = innerInputRef.current;
27
27
  props.onClick?.(e);
@@ -3,7 +3,7 @@ import { memo, useMemo } from 'react';
3
3
  import { Popper } from '../popper';
4
4
  import { InputBase } from '../inputBase';
5
5
  import { classes, colorPickerPopperStyle, style } from './colorPicker.style';
6
- import { clsx, cloneRef, colorTransfer, useControlled, useTouchRipple } from '../../utils';
6
+ import { clsx, cloneRef, colorTransfer, useControlled, useTouchSpread } from '../../utils';
7
7
  import { useTheme } from '../theme';
8
8
  import { Palette } from '../palette';
9
9
  import Color from 'color';
@@ -23,10 +23,10 @@ function BlockItem({ color, onClick, selected }) {
23
23
  hex: color.hex(),
24
24
  alpha: color.alpha()
25
25
  }), [color]);
26
- const showRipple = useTouchRipple(light ? 'text.disabled' : colorObject.hex);
26
+ const showSpread = useTouchSpread(light ? 'text.disabled' : colorObject.hex);
27
27
  return (_jsx("div", { className: classes.block, "data-selected": selected, "data-light": light, onClick: e => {
28
28
  onClick?.();
29
- showRipple(e.currentTarget);
29
+ showSpread(e.currentTarget);
30
30
  }, children: _jsx("div", { className: classes.blockColor, style: {
31
31
  backgroundColor: colorObject.hex,
32
32
  opacity: colorObject.alpha
@@ -49,7 +49,7 @@ export const style = defineCss(({ spacing, borderRadius, divider, background })
49
49
  &:after {
50
50
  content: '';
51
51
  position: absolute;
52
- inset: 3px;
52
+ inset: 4px;
53
53
  border-radius: inherit;
54
54
  border: 2px solid #ffffff;
55
55
  }
@@ -5,7 +5,6 @@ import { Dayjs } from 'dayjs';
5
5
  export type DatePickerSharedProps = {
6
6
  min?: Dayjs;
7
7
  max?: Dayjs;
8
- disabledDates?: (date: Dayjs) => any;
9
8
  disabledHours?: (date: Dayjs, hours: number) => any;
10
9
  disabledMinutes?: (date: Dayjs, minutes: number) => any;
11
10
  disabledSeconds?: (date: Dayjs, seconds: number) => any;
@@ -21,6 +20,7 @@ export interface DateTimePickerProps extends DatePickerSharedProps, Omit<InputBa
21
20
  defaultValue?: Dayjs | null;
22
21
  value?: Dayjs | null;
23
22
  onChange?(value: Dayjs | null): void;
23
+ disabledDates?: (date: Dayjs) => any;
24
24
  }
25
25
  export declare function useDateTimePickerContext(): DatePickerSharedProps;
26
26
  export declare const DateTimePicker: React.MemoExoticComponent<({ inputProps, popperProps, min, max, disabledDates, disabledHours, disabledMinutes, disabledSeconds, format, defaultValue, value, onChange, defaultOpen, open, onOpenChange, autoClose, ...props }: DateTimePickerProps) => import("@emotion/react/jsx-runtime").JSX.Element>;
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
2
2
  import { createContext, memo, useContext, useEffect, useMemo, useRef } from 'react';
3
3
  import { Popper } from '../popper';
4
4
  import { InputBase } from '../inputBase';
@@ -6,7 +6,7 @@ import { clsx, cloneRef, useControlled } from '../../utils';
6
6
  import { classes, datePickerPopperStyle, style } from './dateTimePicker.style';
7
7
  import dayjs from 'dayjs';
8
8
  import customParseFormat from 'dayjs/plugin/customParseFormat';
9
- import { Calendar } from './calendar';
9
+ import { Calendar } from '../calendar';
10
10
  import { Timer } from './timer';
11
11
  import { Icon } from '../..';
12
12
  import { faCalendar } from '@fortawesome/free-regular-svg-icons/faCalendar';
@@ -76,11 +76,11 @@ export const DateTimePicker = memo(({ inputProps, popperProps, min, max, disable
76
76
  }
77
77
  selectFn();
78
78
  };
79
- const focusHandler = (e) => {
79
+ const focusHandler = () => {
80
80
  focused.current = true;
81
81
  selectFn();
82
82
  };
83
- const blurHandler = (e) => {
83
+ const blurHandler = () => {
84
84
  resetContinue();
85
85
  focused.current = false;
86
86
  _setInnerOpen(false);
@@ -202,21 +202,18 @@ export const DateTimePicker = memo(({ inputProps, popperProps, min, max, disable
202
202
  input.setSelectionRange(nextRange.start, nextRange.end);
203
203
  };
204
204
  const contextValue = useMemo(() => ({
205
- min, max, disabledDates,
206
- disabledHours, disabledMinutes, disabledSeconds
205
+ min, max, disabledHours, disabledMinutes, disabledSeconds
207
206
  }), [
208
- min, max, disabledDates,
209
- disabledHours, disabledMinutes, disabledSeconds
207
+ min, max, disabledHours, disabledMinutes, disabledSeconds
210
208
  ]);
211
209
  const showCalendar = /[YMD]/.test(format);
212
210
  const showTimer = /[Hms]/.test(format);
213
211
  const _dateVal = dateValue.current || dayjs();
214
- return (_jsx(Popper, { css: datePickerPopperStyle, open: innerOpen.current, placement: "bottomLeft", trigger: ['click', 'enter'], disabled: props.disabled || props.readOnly, content: _jsxs(DateTimePickerContext, { value: contextValue, children: [showCalendar &&
215
- _jsx(Calendar, { type: format.includes('D') ? 'dates'
216
- : format.includes('M') ? 'months'
217
- : format.includes('Y') ? 'years'
218
- : 'dates', defaultNull: !dateValue.current, value: _dateVal, onChange: setDateValue }), showTimer &&
219
- _jsx(Timer, { showHours: format.includes('H'), showMinutes: format.includes('m'), showSeconds: format.includes('s'), value: _dateVal, onChange: setDateValue })] }), ...popperProps, onOpenChange: setInnerOpen, onPointerDown: e => {
212
+ return (_jsx(Popper, { css: datePickerPopperStyle, open: innerOpen.current, placement: "bottomLeft", trigger: ['click', 'enter'], disabled: props.disabled || props.readOnly, content: _jsxs(_Fragment, { children: [showCalendar &&
213
+ _jsx(Calendar, { viewLevel: format.includes('D') ? 'date'
214
+ : format.includes('M') ? 'month'
215
+ : 'year', _defaultNull: !dateValue.current, value: _dateVal, onChange: setDateValue, min: min, max: max, disabledDates: disabledDates }), showTimer &&
216
+ _jsx(DateTimePickerContext, { value: contextValue, children: _jsx(Timer, { showHours: format.includes('H'), showMinutes: format.includes('m'), showSeconds: format.includes('s'), value: _dateVal, onChange: setDateValue }) })] }), ...popperProps, onOpenChange: setInnerOpen, onPointerDown: e => {
220
217
  popperProps?.onPointerDown?.(e);
221
218
  e.preventDefault();
222
219
  }, children: _jsx(InputBase, { ...props, css: style, className: clsx(classes.root, props.className), "data-focused": innerOpen.current, value: dateValue.current, onClear: clearHandler, onSelect: selectHandler, onFocus: focusHandler, onBlur: blurHandler, onKeyDown: keydownHandler, children: ({ ref, value, onChange, ...rest }) => _jsxs("div", { className: classes.container, children: [_jsx("input", { ...rest, ...inputProps, ref: cloneRef(ref, inputProps?.ref, innerInputRef), className: clsx(classes.input, inputProps?.className) }), _jsx("div", { className: classes.dateTimeIcon, children: showTimer && !showCalendar
@@ -2,16 +2,16 @@ export declare const classes: {
2
2
  input: string;
3
3
  container: string;
4
4
  calendar: string;
5
+ dateItem: string;
6
+ inputGroup: string;
7
+ inputUnit: string;
8
+ dateTimeIcon: string;
5
9
  calendarHead: string;
6
10
  calendarHeadSide: string;
7
11
  calendarHeadControl: string;
8
12
  calendarHeadCenter: string;
9
13
  calendarHeadButton: string;
10
14
  calendarBody: string;
11
- dateItem: string;
12
- inputGroup: string;
13
- inputUnit: string;
14
- dateTimeIcon: string;
15
15
  calendarDays: string;
16
16
  } & {
17
17
  root: string;
@@ -1,7 +1,7 @@
1
1
  import { css } from '@emotion/react';
2
2
  import { defineInnerClasses, defineCss } from '../../utils';
3
3
  import { commonNativeInputStyle } from '../input/input.style';
4
- import { classes as calendarClasses } from './calendar.style';
4
+ import { classes as calendarClasses } from '../calendar/calendar.style';
5
5
  import { classes as timerClasses } from './timer.style';
6
6
  import { popperStyleCallback } from '../popper/popper.style';
7
7
  export const classes = defineInnerClasses('date-time-picker', [
@@ -1,3 +1,3 @@
1
- export * from './calendar';
1
+ export * from '../calendar/calendar';
2
2
  export * from './dateTimePicker';
3
3
  export * from './timer';
@@ -1,3 +1,3 @@
1
- export * from './calendar';
1
+ export * from '../calendar/calendar';
2
2
  export * from './dateTimePicker';
3
3
  export * from './timer';
@@ -15,6 +15,7 @@ export interface DateTimeRangePickerProps extends DatePickerSharedProps, Omit<Di
15
15
  onOpenPickerChange?(openPicker?: 'start' | 'end' | 'closed'): void;
16
16
  autoClose?: boolean;
17
17
  separator?: ReactNode;
18
+ disabledDates?: (date: Dayjs) => any;
18
19
  variant?: 'outlined' | 'underlined' | 'plain';
19
20
  size?: Size;
20
21
  color?: ColorPropsValue;
@@ -0,0 +1,6 @@
1
+ import { FontAwesomeIconProps } from '@fortawesome/react-fontawesome';
2
+ import { ColorPropsValue } from '../../types';
3
+ export interface IconProps extends Omit<FontAwesomeIconProps, 'color'> {
4
+ color?: ColorPropsValue;
5
+ }
6
+ export declare function Icon({ color, ...props }: IconProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
3
+ import { useColor } from '../../utils';
4
+ export function Icon({ color, ...props }) {
5
+ return _jsx(FontAwesomeIcon, { ...props, color: useColor(color) });
6
+ }
@@ -0,0 +1 @@
1
+ export * from './icon';
@@ -0,0 +1 @@
1
+ export * from './icon';
@@ -23,6 +23,7 @@ export function useStyle({ color }) {
23
23
  const c = Color(colorValue);
24
24
  const selectedBg = c.alpha(.1).string();
25
25
  const selectedAndFocused = c.alpha(.15).string();
26
+ const selectedActive = c.alpha(.08).string();
26
27
  const focusedBg = gray(mode === 'light' ? .05 : .23);
27
28
  const disabledOrActive = gray(mode === 'light' ? .1 : .17);
28
29
  return css `
@@ -33,6 +34,7 @@ export function useStyle({ color }) {
33
34
  cursor: pointer;
34
35
  color: ${text.primary};
35
36
  padding: ${paddingHorizontal.medium}px 12px;
37
+ position: relative;
36
38
  -webkit-tap-highlight-color: transparent;
37
39
 
38
40
  &[data-size=small] {
@@ -47,8 +49,7 @@ export function useStyle({ color }) {
47
49
 
48
50
  transition: background-color .25s ${easing.easeOut};
49
51
 
50
- &:hover,
51
- &[data-focused=true] {
52
+ &:hover, &[data-focused=true] {
52
53
  background-color: ${focusedBg};
53
54
  }
54
55
 
@@ -64,7 +65,7 @@ export function useStyle({ color }) {
64
65
  &[data-selected=true] {
65
66
  background-color: ${selectedBg};
66
67
 
67
- &[data-focused=true] {
68
+ &:hover, &[data-focused=true] {
68
69
  background-color: ${selectedAndFocused};
69
70
  }
70
71
 
@@ -72,6 +73,10 @@ export function useStyle({ color }) {
72
73
  font-weight: bold;
73
74
  color: ${colorValue};
74
75
  }
76
+
77
+ &:active {
78
+ background-color: ${selectedActive};
79
+ }
75
80
  }
76
81
 
77
82
  &[data-disabled=true] {