@canlooks/can-ui 0.0.74 → 0.0.76

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 (102) hide show
  1. package/dist/cjs/components/calendar/calendar.style.js +124 -124
  2. package/dist/cjs/components/clickAway/clickAway.d.ts +1 -1
  3. package/dist/cjs/components/curd/curdResizable.js +1 -1
  4. package/dist/cjs/components/dateTimePicker/dateTimePicker.d.ts +4 -4
  5. package/dist/cjs/components/dateTimePicker/dateTimePicker.js +14 -190
  6. package/dist/cjs/components/dateTimePicker/dateTimePicker.style.d.ts +2 -12
  7. package/dist/cjs/components/dateTimePicker/dateTimePicker.style.js +20 -17
  8. package/dist/cjs/components/descriptions/descriptions.js +1 -5
  9. package/dist/cjs/components/dialog/dialog.js +1 -1
  10. package/dist/cjs/components/dialog/dialog.style.js +2 -0
  11. package/dist/cjs/components/inputBase/inputBase.js +10 -1
  12. package/dist/cjs/components/popper/popper.js +21 -20
  13. package/dist/cjs/components/status/status.d.ts +6 -6
  14. package/dist/cjs/components/table/table.d.ts +1 -1
  15. package/dist/cjs/components/table/table.js +3 -1
  16. package/dist/cjs/components/table/table.style.js +21 -6
  17. package/dist/cjs/components/table/tableSticky.js +19 -16
  18. package/dist/cjs/components/table/tableSticky.style.js +0 -8
  19. package/dist/cjs/components/theme/themeVariables.js +2 -2
  20. package/dist/cjs/utils/utils.d.ts +5 -3
  21. package/dist/cjs/utils/utils.js +22 -7
  22. package/dist/esm/components/calendar/calendar.style.js +124 -124
  23. package/dist/esm/components/clickAway/clickAway.d.ts +1 -1
  24. package/dist/esm/components/curd/curdResizable.js +1 -1
  25. package/dist/esm/components/dateTimePicker/dateTimePicker.d.ts +4 -4
  26. package/dist/esm/components/dateTimePicker/dateTimePicker.js +15 -191
  27. package/dist/esm/components/dateTimePicker/dateTimePicker.style.d.ts +2 -12
  28. package/dist/esm/components/dateTimePicker/dateTimePicker.style.js +20 -17
  29. package/dist/esm/components/descriptions/descriptions.js +1 -5
  30. package/dist/esm/components/dialog/dialog.js +1 -1
  31. package/dist/esm/components/dialog/dialog.style.js +2 -0
  32. package/dist/esm/components/inputBase/inputBase.js +11 -2
  33. package/dist/esm/components/popper/popper.js +22 -21
  34. package/dist/esm/components/status/status.d.ts +6 -6
  35. package/dist/esm/components/table/table.d.ts +1 -1
  36. package/dist/esm/components/table/table.js +4 -2
  37. package/dist/esm/components/table/table.style.js +21 -6
  38. package/dist/esm/components/table/tableSticky.js +20 -17
  39. package/dist/esm/components/table/tableSticky.style.js +0 -8
  40. package/dist/esm/components/theme/themeVariables.js +2 -2
  41. package/dist/esm/utils/utils.d.ts +5 -3
  42. package/dist/esm/utils/utils.js +21 -6
  43. package/documentation/dist/assets/index-DvrKS6Tv.js +7747 -0
  44. package/documentation/dist/atom-one-dark.min.css +1 -0
  45. package/documentation/dist/components/accordion.md +38 -0
  46. package/documentation/dist/components/actionSheet.md +49 -0
  47. package/documentation/dist/components/alert.md +38 -0
  48. package/documentation/dist/components/anchorList.md +36 -0
  49. package/documentation/dist/components/autocomplete.md +68 -0
  50. package/documentation/dist/components/avatar.md +79 -0
  51. package/documentation/dist/components/badge.md +33 -0
  52. package/documentation/dist/components/bottomNavigation.md +39 -0
  53. package/documentation/dist/components/breadcrumb.md +28 -0
  54. package/documentation/dist/components/bubbleConfirm.md +34 -0
  55. package/documentation/dist/components/button.md +62 -0
  56. package/documentation/dist/components/card.md +30 -0
  57. package/documentation/dist/components/cascade.md +48 -0
  58. package/documentation/dist/components/checkbox.md +36 -0
  59. package/documentation/dist/components/colorPicker.md +27 -0
  60. package/documentation/dist/components/contextMenu.md +27 -0
  61. package/documentation/dist/components/counter.md +29 -0
  62. package/documentation/dist/components/dataGrid.md +112 -0
  63. package/documentation/dist/components/dateTimePicker.md +35 -0
  64. package/documentation/dist/components/dateTimeRangePicker.md +36 -0
  65. package/documentation/dist/components/descriptions.md +35 -0
  66. package/documentation/dist/components/dialog.md +56 -0
  67. package/documentation/dist/components/divider.md +26 -0
  68. package/documentation/dist/components/drawer.md +40 -0
  69. package/documentation/dist/components/flex.md +20 -0
  70. package/documentation/dist/components/form.md +131 -0
  71. package/documentation/dist/components/formDialog.md +36 -0
  72. package/documentation/dist/components/grid.md +34 -0
  73. package/documentation/dist/components/highlight.md +26 -0
  74. package/documentation/dist/components/image.md +90 -0
  75. package/documentation/dist/components/input.md +39 -0
  76. package/documentation/dist/components/loading.md +46 -0
  77. package/documentation/dist/components/menu.md +85 -0
  78. package/documentation/dist/components/pagination.md +38 -0
  79. package/documentation/dist/components/pickerDialog.md +56 -0
  80. package/documentation/dist/components/placeholder.md +30 -0
  81. package/documentation/dist/components/progress.md +43 -0
  82. package/documentation/dist/components/radio.md +37 -0
  83. package/documentation/dist/components/rating.md +35 -0
  84. package/documentation/dist/components/resizable.md +41 -0
  85. package/documentation/dist/components/scrollbar.md +31 -0
  86. package/documentation/dist/components/segmented.md +57 -0
  87. package/documentation/dist/components/select.md +30 -0
  88. package/documentation/dist/components/skeleton.md +26 -0
  89. package/documentation/dist/components/slidableActions.md +53 -0
  90. package/documentation/dist/guide/appComponent.md +30 -0
  91. package/documentation/dist/guide/globalMethods.md +238 -0
  92. package/documentation/dist/guide/icon.md +57 -0
  93. package/documentation/dist/guide/introduction.md +2 -0
  94. package/documentation/dist/guide/overrideProps.md +0 -0
  95. package/documentation/dist/guide/startup.md +23 -0
  96. package/documentation/dist/guide/theme.md +249 -0
  97. package/documentation/dist/index.html +13 -0
  98. package/documentation/dist/logo.png +0 -0
  99. package/extensions/curd.cjs +5 -5
  100. package/extensions/documentViewer.cjs +5 -5
  101. package/extensions/textFormatter.cjs +5 -5
  102. package/package.json +1 -1
@@ -13,128 +13,128 @@ export const classes = defineInnerClasses('calendar', [
13
13
  'yearItem',
14
14
  'foot'
15
15
  ]);
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
- }
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
+ }
140
140
  `);
@@ -60,7 +60,7 @@ export declare function ClickAway({ ref, container, eventType, onClickAway, disa
60
60
  results: number;
61
61
  security: string;
62
62
  unselectable: "off" | "on";
63
- popover: "" | "auto" | "manual" | "hint";
63
+ popover: "" | "auto" | "manual";
64
64
  popoverTargetAction: "toggle" | "hide" | "show";
65
65
  popoverTarget: string;
66
66
  inert: boolean;
@@ -7,5 +7,5 @@ import { Button } from '../button';
7
7
  import { Icon } from '../icon';
8
8
  import { faArrowsUpDown } from '@fortawesome/free-solid-svg-icons/faArrowsUpDown';
9
9
  export const CurdResizable = memo(({ innerSize, setInnerSize }) => {
10
- return (_jsx(Tooltip, { title: "\u8868\u683C\u5C3A\u5BF8", children: _jsx(Bubble, { placement: "bottom", content: _jsxs(_Fragment, { children: [_jsx(MenuItem, { value: "small", label: "\u5C0F", selected: innerSize === 'small', onClick: () => setInnerSize('small') }), _jsx(MenuItem, { value: "medium", label: "\u4E2D", selected: innerSize === 'medium', onClick: () => setInnerSize('medium') }), _jsx(MenuItem, { value: "large", label: "\u5927", selected: innerSize === 'large', onClick: () => setInnerSize('large') })] }), children: _jsx(Button, { shape: "circular", variant: "text", color: "text.secondary", children: _jsx(Icon, { icon: faArrowsUpDown }) }) }) }));
10
+ return (_jsx(Tooltip, { title: "\u8868\u683C\u5C3A\u5BF8", clickToClose: true, children: _jsx(Bubble, { placement: "bottom", trigger: "click", content: _jsxs(_Fragment, { children: [_jsx(MenuItem, { value: "small", label: "\u5C0F", selected: innerSize === 'small', onClick: () => setInnerSize('small') }), _jsx(MenuItem, { value: "medium", label: "\u4E2D", selected: innerSize === 'medium', onClick: () => setInnerSize('medium') }), _jsx(MenuItem, { value: "large", label: "\u5927", selected: innerSize === 'large', onClick: () => setInnerSize('large') })] }), children: _jsx(Button, { shape: "circular", variant: "text", color: "text.secondary", children: _jsx(Icon, { icon: faArrowsUpDown }) }) }) }));
11
11
  });
@@ -1,7 +1,7 @@
1
- import React, { ComponentProps } from 'react';
2
- import { PopperProps } from '../popper';
3
- import { InputBaseProps } from '../inputBase';
1
+ import { ComponentProps } from 'react';
4
2
  import { Dayjs } from 'dayjs';
3
+ import { InputBaseProps } from '../inputBase';
4
+ import { PopperProps } from '../popper';
5
5
  export type DatePickerSharedProps = {
6
6
  min?: Dayjs;
7
7
  max?: Dayjs;
@@ -23,4 +23,4 @@ export interface DateTimePickerProps extends DatePickerSharedProps, Omit<InputBa
23
23
  disabledDates?: (date: Dayjs) => any;
24
24
  }
25
25
  export declare function useDateTimePickerContext(): DatePickerSharedProps;
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>;
26
+ export declare const DateTimePicker: import("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,205 +1,31 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
2
- import { createContext, memo, useContext, useEffect, useMemo, useRef } from 'react';
3
- import { Popper } from '../popper';
4
- import { InputBase } from '../inputBase';
5
- import { useControlled, mergeComponentProps } from '../../utils';
2
+ import { createContext, memo, useContext, useMemo, useRef } from 'react';
6
3
  import { classes, datePickerPopperStyle, style } from './dateTimePicker.style';
7
4
  import dayjs from 'dayjs';
8
- import customParseFormat from 'dayjs/plugin/customParseFormat';
5
+ import { InputBase } from '../inputBase';
6
+ import { mergeComponentProps, useControlled } from '../../utils';
7
+ import { Popper } from '../popper';
9
8
  import { Calendar } from '../calendar';
10
- import { Timer } from './timer';
11
9
  import { Icon } from '../icon';
12
10
  import { faCalendar } from '@fortawesome/free-regular-svg-icons/faCalendar';
13
11
  import { faClock } from '@fortawesome/free-regular-svg-icons/faClock';
14
- dayjs.extend(customParseFormat);
15
- const availableFormatTokens = ['Y', 'M', 'D', 'H', 'm', 's'];
12
+ import { Timer } from './timer';
16
13
  const DateTimePickerContext = createContext({});
17
14
  export function useDateTimePickerContext() {
18
15
  return useContext(DateTimePickerContext);
19
16
  }
20
17
  export const DateTimePicker = memo(({ inputProps, popperProps, min, max, disabledDates, disabledHours, disabledMinutes, disabledSeconds, format = 'YYYY-MM-DD', defaultValue = null, value, onChange, defaultOpen = false, open, onOpenChange, autoClose = !/[Hms]/.test(format), ...props }) => {
21
- const innerInputRef = useRef(null);
22
18
  const focused = useRef(false);
23
19
  const [innerOpen, _setInnerOpen] = useControlled(defaultOpen, open, onOpenChange);
24
20
  const setInnerOpen = (open) => {
25
21
  // 如果仍聚焦在输入框,则不用关闭弹框
26
22
  (open || !focused.current) && _setInnerOpen(open);
27
23
  };
28
- useEffect(() => {
29
- if (!innerOpen.current && !dateValue.current) {
30
- // 弹框关闭时没有选中日期,清空输入框
31
- innerInputRef.current.value = format;
32
- }
33
- }, [innerOpen.current]);
34
24
  const [dateValue, _setDateValue] = useControlled(defaultValue, value, onChange);
35
25
  const setDateValue = (date) => {
36
26
  _setDateValue(date);
37
27
  autoClose && _setInnerOpen(false);
38
28
  };
39
- useEffect(() => {
40
- innerInputRef.current.value = dateValue.current?.format(format) ?? format;
41
- }, [dateValue.current]);
42
- const clearHandler = () => {
43
- setDateValue(null);
44
- selectFn();
45
- };
46
- const ranges = useMemo(() => {
47
- const range = [];
48
- format.length && availableFormatTokens.forEach(token => {
49
- const matched = format.match(new RegExp(`${token}+`));
50
- if (matched && typeof matched.index === 'number') {
51
- range.push({
52
- token,
53
- start: matched.index,
54
- end: matched.index + matched[0].length
55
- });
56
- }
57
- });
58
- return range;
59
- }, [format]);
60
- const currentRange = useRef(null);
61
- const selectFn = () => {
62
- const input = innerInputRef.current;
63
- const { selectionStart } = input;
64
- const range = ranges.find(({ end }) => (selectionStart || 0) <= end) || ranges[ranges.length - 1];
65
- if (range) {
66
- currentRange.current = range;
67
- input.value ||= format;
68
- input.setSelectionRange(range.start, range.end);
69
- }
70
- };
71
- const selectHandler = (e) => {
72
- if (e.nativeEvent.type === 'selectionchange' || !ranges.length) {
73
- // setSelectionRange()方法也会触发该回调,通过nativeEvent.type排除
74
- return;
75
- }
76
- selectFn();
77
- };
78
- const focusHandler = () => {
79
- focused.current = true;
80
- selectFn();
81
- };
82
- const blurHandler = () => {
83
- resetContinue();
84
- focused.current = false;
85
- _setInnerOpen(false);
86
- };
87
- const valueContinueHelper = useRef({ token: '', value: '' });
88
- const resetContinue = () => {
89
- valueContinueHelper.current = { token: '', value: '' };
90
- };
91
- const keydownHandler = (e) => {
92
- if (!currentRange.current) {
93
- return;
94
- }
95
- const { key } = e;
96
- const input = e.target;
97
- const { token, start, end } = currentRange.current;
98
- if (/^\d$/.test(e.key)) {
99
- // 数字键
100
- e.preventDefault();
101
- let continuedValue;
102
- if (valueContinueHelper.current.token === token) {
103
- continuedValue = valueContinueHelper.current.value += key;
104
- }
105
- else {
106
- valueContinueHelper.current = { token, value: key };
107
- continuedValue = key;
108
- }
109
- input.value = `${input.value.slice(0, start)}${continuedValue.padStart(end - start, '0')}${input.value.slice(end)}`;
110
- input.setSelectionRange(start, end);
111
- const d = dayjs(input.value, format);
112
- d.isValid() && _setDateValue(d);
113
- // 当长度达到,或者数值超过,将会跳转下一个range
114
- if (token === 'Y') {
115
- if (continuedValue.length === 4) {
116
- return selectNext(input);
117
- }
118
- }
119
- else if (continuedValue.length === 2) {
120
- return selectNext(input);
121
- }
122
- switch (token) {
123
- case 'M':
124
- if (+key > 1) {
125
- return selectNext(input);
126
- }
127
- break;
128
- case 'D':
129
- if (+key > 3) {
130
- return selectNext(input);
131
- }
132
- break;
133
- default:
134
- // 'H' | 'm' | 's'
135
- if (+key > 5) {
136
- return selectNext(input);
137
- }
138
- }
139
- }
140
- switch (key) {
141
- case 'Backspace':
142
- case 'Delete':
143
- case 'ArrowLeft':
144
- case 'ArrowRight':
145
- case 'ArrowUp':
146
- case 'ArrowDown':
147
- case 'Escape':
148
- e.preventDefault();
149
- resetContinue();
150
- }
151
- switch (key) {
152
- case 'Backspace':
153
- case 'Delete':
154
- input.value = `${input.value.slice(0, start)}${format.slice(start, end)}${input.value.slice(end)}`;
155
- input.setSelectionRange(start, end);
156
- _setDateValue(null);
157
- break;
158
- case 'ArrowLeft':
159
- const prevRange = ranges[ranges.indexOf(currentRange.current) - 1] || ranges[0];
160
- currentRange.current = prevRange;
161
- input.setSelectionRange(prevRange.start, prevRange.end);
162
- break;
163
- case 'ArrowRight':
164
- selectNext(input);
165
- break;
166
- case 'ArrowUp':
167
- case 'ArrowDown':
168
- let valueFragment = +input.value.slice(start, end);
169
- if (isNaN(valueFragment)) {
170
- valueFragment = 0;
171
- }
172
- key === 'ArrowUp' ? valueFragment++ : valueFragment--;
173
- switch (token) {
174
- case 'Y':
175
- break;
176
- case 'M':
177
- valueFragment >= 13 ? valueFragment = 1
178
- : valueFragment <= 0 && (valueFragment = 12);
179
- break;
180
- case 'D':
181
- valueFragment >= 32 ? valueFragment = 1
182
- : valueFragment <= 0 && (valueFragment = 31);
183
- break;
184
- default:
185
- valueFragment >= 60 ? valueFragment = 1
186
- : valueFragment <= 0 && (valueFragment = 59);
187
- }
188
- input.value = `${input.value.slice(0, start)}${valueFragment.toString().padStart(end - start, '0')}${input.value.slice(end)}`;
189
- input.setSelectionRange(start, end);
190
- const d = dayjs(input.value, format);
191
- d.isValid() && _setDateValue(d);
192
- break;
193
- case 'Escape':
194
- _setInnerOpen(false);
195
- }
196
- };
197
- const selectNext = (input) => {
198
- resetContinue();
199
- const nextRange = ranges[ranges.indexOf(currentRange.current) + 1] || ranges[ranges.length - 1];
200
- currentRange.current = nextRange;
201
- input.setSelectionRange(nextRange.start, nextRange.end);
202
- };
203
29
  const contextValue = useMemo(() => ({
204
30
  min, max, disabledHours, disabledMinutes, disabledSeconds
205
31
  }), [
@@ -207,7 +33,8 @@ export const DateTimePicker = memo(({ inputProps, popperProps, min, max, disable
207
33
  ]);
208
34
  const showCalendar = /[YMD]/.test(format);
209
35
  const showTimer = /[Hms]/.test(format);
210
- const _dateVal = dateValue.current || dayjs();
36
+ // 若外部没有值,内部需要“现在”作为默认值
37
+ const innerValue = dateValue.current || dayjs();
211
38
  return (_jsx(Popper, { ...mergeComponentProps({
212
39
  css: datePickerPopperStyle,
213
40
  open: innerOpen.current,
@@ -217,8 +44,8 @@ export const DateTimePicker = memo(({ inputProps, popperProps, min, max, disable
217
44
  content: (_jsxs(_Fragment, { children: [showCalendar &&
218
45
  _jsx(Calendar, { viewLevel: format.includes('D') ? 'date'
219
46
  : format.includes('M') ? 'month'
220
- : 'year', _defaultNull: !dateValue.current, value: _dateVal, onChange: setDateValue, min: min, max: max, disabledDates: disabledDates }), showTimer &&
221
- _jsx(DateTimePickerContext, { value: contextValue, children: _jsx(Timer, { showHours: format.includes('H'), showMinutes: format.includes('m'), showSeconds: format.includes('s'), value: _dateVal, onChange: setDateValue }) })] })),
47
+ : 'year', _defaultNull: !dateValue.current, value: innerValue, onChange: setDateValue, min: min, max: max, disabledDates: disabledDates }), showTimer &&
48
+ _jsx(DateTimePickerContext, { value: contextValue, children: _jsx(Timer, { showHours: format.includes('H'), showMinutes: format.includes('m'), showSeconds: format.includes('s'), value: innerValue, onChange: setDateValue }) })] }))
222
49
  }, popperProps, {
223
50
  onOpenChange: setInnerOpen,
224
51
  onPointerDown: e => e.preventDefault()
@@ -226,15 +53,12 @@ export const DateTimePicker = memo(({ inputProps, popperProps, min, max, disable
226
53
  css: style,
227
54
  className: classes.root,
228
55
  value: dateValue.current,
229
- onClear: clearHandler,
230
- onSelect: selectHandler,
231
- onFocus: focusHandler,
232
- onBlur: blurHandler,
233
- onKeyDown: keydownHandler
234
- }), "data-focused": innerOpen.current, children: inputBaseProps => _jsxs("div", { className: classes.container, children: [_jsx("input", { ...mergeComponentProps(inputBaseProps, inputProps, {
235
- ref: innerInputRef,
236
- className: classes.input
237
- }) }), _jsx("div", { className: classes.dateTimeIcon, children: showTimer && !showCalendar
56
+ onClear() {
57
+ setDateValue(null);
58
+ }
59
+ }), "data-focused": innerOpen.current, children: inputBaseProps => _jsxs("div", { className: classes.container, children: [!dateValue.current
60
+ ? _jsx("div", { className: classes.placeholder, children: props.placeholder ?? '请选择' })
61
+ : _jsx("div", { className: classes.backfill, children: dateValue.current.format(format) }), _jsx("input", { size: 1, ...mergeComponentProps(inputBaseProps, inputProps), "data-hidden": "true" }), _jsx("div", { className: classes.dateTimeIcon, children: showTimer && !showCalendar
238
62
  ? _jsx(Icon, { icon: faClock })
239
63
  : _jsx(Icon, { icon: faCalendar }) })] }) }) }));
240
64
  });
@@ -1,18 +1,8 @@
1
1
  export declare const classes: {
2
- input: string;
3
- calendar: string;
2
+ placeholder: string;
4
3
  container: string;
5
- dateItem: string;
6
- inputGroup: string;
7
- inputUnit: string;
4
+ backfill: string;
8
5
  dateTimeIcon: string;
9
- calendarHead: string;
10
- calendarHeadSide: string;
11
- calendarHeadControl: string;
12
- calendarHeadCenter: string;
13
- calendarHeadButton: string;
14
- calendarBody: string;
15
- calendarDays: string;
16
6
  } & {
17
7
  root: string;
18
8
  };
@@ -1,34 +1,37 @@
1
1
  import { css } from '@emotion/react';
2
2
  import { defineInnerClasses, defineCss } from '../../utils';
3
- import { commonNativeInputStyle } from '../input/input.style';
4
3
  import { classes as calendarClasses } from '../calendar/calendar.style';
5
4
  import { classes as timerClasses } from './timer.style';
6
5
  import { popperStyleCallback } from '../popper/popper.style';
7
6
  export const classes = defineInnerClasses('date-time-picker', [
8
- 'input',
9
7
  'container',
10
- 'inputGroup',
11
- 'inputUnit',
12
8
  'dateTimeIcon',
13
- 'calendar',
14
- 'calendarHead',
15
- 'calendarHeadSide',
16
- 'calendarHeadControl',
17
- 'calendarHeadCenter',
18
- 'calendarHeadButton',
19
- 'calendarBody',
20
- 'calendarDays',
21
- 'dateItem'
9
+ 'placeholder',
10
+ 'backfill'
22
11
  ]);
23
- export const style = defineCss(({ text }) => css `
12
+ export const style = defineCss(({ text, spacing }) => css `
13
+ cursor: pointer;
14
+
24
15
  .${classes.container} {
25
16
  display: flex;
26
17
  align-items: center;
27
18
 
28
- .${classes.input} {
29
- ${commonNativeInputStyle}
19
+ .${classes.placeholder} {
20
+ flex: 1;
21
+ color: ${text.placeholder};
22
+ white-space: nowrap;
23
+ text-overflow: ellipsis;
24
+ overflow: hidden;
30
25
  }
31
-
26
+
27
+ .${classes.backfill} {
28
+ flex: 1;
29
+ min-width: 0;
30
+ display: flex;
31
+ flex-wrap: wrap;
32
+ gap: ${spacing[1]}px;
33
+ }
34
+
32
35
  .${classes.dateTimeIcon} {
33
36
  color: ${text.secondary};
34
37
  }
@@ -19,11 +19,7 @@ export const Descriptions = memo(({ size, labelWidth, colon = ':', labelPlacemen
19
19
  size, labelWidth, colon, labelPlacement, disableMargin, disablePadding, variant
20
20
  ]);
21
21
  const renderGridItems = () => {
22
- return items?.map((itemProps, i) => _createElement(ItemComponent
23
- // 最后一项沾满剩余行空间
24
- , {
25
- // 最后一项沾满剩余行空间
26
- flex: i === items.length - 1 ? 1 : void 0, ...itemProps, key: itemProps.key ?? i })) || props.children;
22
+ return items?.map((itemProps, i) => _createElement(ItemComponent, { ...itemProps, key: itemProps.key ?? i })) || props.children;
27
23
  };
28
24
  const columnCountNum = useResponsiveValue(columnCount, variant === 'grid');
29
25
  const renderTableItems = () => {
@@ -59,12 +59,12 @@ export function Dialog({ icon, title, footer, prefix, suffix, width = 420, minWi
59
59
  useEffect(() => {
60
60
  if (innerOpen.current) {
61
61
  const resizeObserver = new ResizeObserver(onScroll);
62
+ resizeObserver.observe(bodyRef.current);
62
63
  resizeObserver.observe(bodyWrapRef.current);
63
64
  return () => {
64
65
  resizeObserver.disconnect();
65
66
  };
66
67
  }
67
- return;
68
68
  }, [innerOpen.current]);
69
69
  /**
70
70
  * ---------------------------------------------------------------------
@@ -35,6 +35,7 @@ export const style = defineCss(({ background, borderRadius, boxShadow, spacing,
35
35
  }
36
36
 
37
37
  .${classes.content} {
38
+ min-width: 0;
38
39
  flex: 1;
39
40
  display: flex;
40
41
  flex-direction: column;
@@ -90,6 +91,7 @@ export const style = defineCss(({ background, borderRadius, boxShadow, spacing,
90
91
  }
91
92
 
92
93
  .${classes.bodyWrap} {
94
+ min-width: 0;
93
95
  flex: 1;
94
96
  }
95
97