@douyinfe/semi-foundation 2.6.0-beta.0 → 2.7.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 (61) hide show
  1. package/button/constants.ts +2 -2
  2. package/datePicker/_utils/formatter.ts +2 -2
  3. package/datePicker/_utils/getInsetInputFormatToken.ts +42 -0
  4. package/datePicker/_utils/getInsetInputValueFromInsetInputStr.ts +60 -0
  5. package/datePicker/constants.ts +2 -0
  6. package/datePicker/datePicker.scss +136 -3
  7. package/datePicker/foundation.ts +92 -15
  8. package/datePicker/inputFoundation.ts +133 -4
  9. package/datePicker/monthsGridFoundation.ts +4 -0
  10. package/datePicker/rtl.scss +8 -0
  11. package/datePicker/variables.scss +30 -0
  12. package/lib/cjs/button/constants.d.ts +9 -1
  13. package/lib/cjs/datePicker/_utils/formatter.d.ts +2 -2
  14. package/lib/cjs/datePicker/_utils/getInsetInputFormatToken.d.ts +20 -0
  15. package/lib/cjs/datePicker/_utils/getInsetInputFormatToken.js +61 -0
  16. package/lib/cjs/datePicker/_utils/getInsetInputValueFromInsetInputStr.d.ts +31 -0
  17. package/lib/cjs/datePicker/_utils/getInsetInputValueFromInsetInputStr.js +76 -0
  18. package/lib/cjs/datePicker/constants.d.ts +2 -0
  19. package/lib/cjs/datePicker/constants.js +4 -3
  20. package/lib/cjs/datePicker/datePicker.css +104 -2
  21. package/lib/cjs/datePicker/datePicker.scss +136 -3
  22. package/lib/cjs/datePicker/foundation.d.ts +30 -7
  23. package/lib/cjs/datePicker/foundation.js +122 -9
  24. package/lib/cjs/datePicker/inputFoundation.d.ts +73 -3
  25. package/lib/cjs/datePicker/inputFoundation.js +196 -3
  26. package/lib/cjs/datePicker/monthsGridFoundation.d.ts +1 -0
  27. package/lib/cjs/datePicker/monthsGridFoundation.js +4 -2
  28. package/lib/cjs/datePicker/rtl.scss +8 -0
  29. package/lib/cjs/datePicker/variables.scss +30 -0
  30. package/lib/cjs/tag/tag.css +1 -0
  31. package/lib/cjs/tag/tag.scss +1 -0
  32. package/lib/cjs/tooltip/foundation.js +8 -8
  33. package/lib/cjs/treeSelect/foundation.d.ts +3 -2
  34. package/lib/cjs/treeSelect/foundation.js +28 -15
  35. package/lib/es/button/constants.d.ts +9 -1
  36. package/lib/es/datePicker/_utils/formatter.d.ts +2 -2
  37. package/lib/es/datePicker/_utils/getInsetInputFormatToken.d.ts +20 -0
  38. package/lib/es/datePicker/_utils/getInsetInputFormatToken.js +48 -0
  39. package/lib/es/datePicker/_utils/getInsetInputValueFromInsetInputStr.d.ts +31 -0
  40. package/lib/es/datePicker/_utils/getInsetInputValueFromInsetInputStr.js +66 -0
  41. package/lib/es/datePicker/constants.d.ts +2 -0
  42. package/lib/es/datePicker/constants.js +4 -3
  43. package/lib/es/datePicker/datePicker.css +104 -2
  44. package/lib/es/datePicker/datePicker.scss +136 -3
  45. package/lib/es/datePicker/foundation.d.ts +30 -7
  46. package/lib/es/datePicker/foundation.js +120 -9
  47. package/lib/es/datePicker/inputFoundation.d.ts +73 -3
  48. package/lib/es/datePicker/inputFoundation.js +192 -4
  49. package/lib/es/datePicker/monthsGridFoundation.d.ts +1 -0
  50. package/lib/es/datePicker/monthsGridFoundation.js +4 -2
  51. package/lib/es/datePicker/rtl.scss +8 -0
  52. package/lib/es/datePicker/variables.scss +30 -0
  53. package/lib/es/tag/tag.css +1 -0
  54. package/lib/es/tag/tag.scss +1 -0
  55. package/lib/es/tooltip/foundation.js +8 -8
  56. package/lib/es/treeSelect/foundation.d.ts +3 -2
  57. package/lib/es/treeSelect/foundation.js +27 -15
  58. package/package.json +3 -3
  59. package/tag/tag.scss +1 -0
  60. package/tooltip/foundation.ts +8 -8
  61. package/treeSelect/foundation.ts +26 -19
@@ -6,6 +6,7 @@ $module: #{$prefix}-datepicker;
6
6
  .#{$module} {
7
7
  box-sizing: border-box;
8
8
  display: inline-block;
9
+ vertical-align: top;
9
10
 
10
11
  // 双月网格
11
12
 
@@ -45,6 +46,34 @@ $module: #{$prefix}-datepicker;
45
46
  min-height: $height-datepicker_dateType_yamShowing_min;
46
47
  }
47
48
 
49
+ &[x-insetInput=true] {
50
+ .#{$module}-month-grid-left,
51
+ .#{$module}-month-grid-right {
52
+ &[x-open-type=year] {
53
+ min-height: $height-datepicker_month_grid_yearType_insetInput;
54
+ }
55
+ &[x-open-type=time] {
56
+ min-height: $height-datepicker_month_grid_timeType_insetInput;
57
+ }
58
+ }
59
+
60
+ .#{$module}-navigation {
61
+ padding-top: $spacing-datepicker_navigation_insetInput-paddingY;
62
+ padding-bottom: $spacing-datepicker_navigation_insetInput-paddingY;
63
+ }
64
+
65
+ .#{$module}-tpk {
66
+ min-height: $height-datepicker_timeType_insetInput_tpk;
67
+ }
68
+
69
+ &[x-type=dateTime],
70
+ &[x-type=dateTimeRange] {
71
+ .#{$module}-yam {
72
+ height: $height-datepicker_timeType_insetInput_yam;
73
+ }
74
+ }
75
+ }
76
+
48
77
  // 年月选择返回主面板
49
78
  .#{$module}-yearmonth-header {
50
79
  background: $color-datepicker_header-bg-default;
@@ -92,6 +121,7 @@ $module: #{$prefix}-datepicker;
92
121
 
93
122
  @include font-size-regular;
94
123
  min-height: $height-datepicker_timepicker_header_min;
124
+ line-height: $height-datepicker_timepicker_header_min;
95
125
  }
96
126
  }
97
127
 
@@ -581,6 +611,41 @@ $module: #{$prefix}-datepicker;
581
611
  cursor: pointer;
582
612
  }
583
613
 
614
+ &-inset-input {
615
+ &-wrapper {
616
+ display: flex;
617
+ flex-wrap: nowrap;
618
+ justify-content: space-between;
619
+ box-sizing: border-box;
620
+ column-gap: $spacing-datepicker_insetInput_wrapper-margin;
621
+ padding: $spacing-datepicker_insetInput_wrapper-paddingY $spacing-datepicker_insetInput_wrapper-paddingX;
622
+ padding-bottom: $spacing-datepicker_insetInput_wrapper-paddingBottom;
623
+
624
+ width: $width-datepicker_insetInput_date_type_wrapper;
625
+ &[x-type=dateRange],
626
+ &[x-type=dateTimeRange] {
627
+ width: $width-datepicker_insetInput_date_range_type_wrapper;
628
+ }
629
+ &[x-type=month] {
630
+ width: $width-datepicker_insetInput_month_type_wrapper;
631
+ }
632
+
633
+ .#{$prefix}-input-wrapper {
634
+ flex: 1;
635
+ flex-shrink: 0;
636
+ }
637
+ }
638
+
639
+ &-separator {
640
+ flex-grow: 0;
641
+ flex-shrink: 0;
642
+ height: $height-datepicker_insetInput_separator;
643
+ line-height: $height-datepicker_insetInput_separator;
644
+ padding: $spacing-datepicker_insetInput_separator-paddingY $spacing-datepicker_insetInput_separator-paddingX;
645
+ color: $color-datepicker_insetInput_separator;
646
+ }
647
+ }
648
+
584
649
  &-range {
585
650
 
586
651
  &-input {
@@ -862,6 +927,33 @@ $module: #{$prefix}-datepicker;
862
927
  min-height: 6 * $width-datepicker_day_compact;
863
928
  }
864
929
  }
930
+
931
+ &[x-insetInput=true] {
932
+ .#{$module}-month-grid-left,
933
+ .#{$module}-month-grid-right {
934
+ &[x-open-type=year] {
935
+ min-height: $height-datepicker_tpk_compact;
936
+ }
937
+ &[x-open-type=time] {
938
+ min-height: $height-datepicker_tpk_compact;
939
+ }
940
+ }
941
+
942
+ .#{$module}-yam-showing {
943
+ min-height: $height-datepicker_tpk_compact;
944
+ }
945
+
946
+ .#{$module}-tpk {
947
+ min-height: $height-datepicker_insetInput_tpk_compact;
948
+ }
949
+
950
+ &[x-type=dateTime],
951
+ &[x-type=dateTimeRange] {
952
+ .#{$module}-yam {
953
+ height: $height-datepicker_timeType_insetInput_yam_compact;
954
+ }
955
+ }
956
+ }
865
957
  }
866
958
 
867
959
  // 年月选择器
@@ -1039,6 +1131,46 @@ $module: #{$prefix}-datepicker;
1039
1131
  padding-right: $spacing-datepicker_footer_compact-paddintRight;
1040
1132
  padding-bottom: $spacing-datepicker_footer_compact-paddintBottom;
1041
1133
  }
1134
+
1135
+ .#{$module}-inset-input {
1136
+ &-wrapper {
1137
+ column-gap: $spacing-datepicker_insetInput_wrapper_compact-margin;
1138
+ padding: $spacing-datepicker_insetInput_wrapper_compact-paddingY $spacing-datepicker_insetInput_wrapper_compact-paddingX;
1139
+ padding-bottom: $spacing-datepicker_insetInput_wrapper_compact-paddingBottom;
1140
+
1141
+ width: $width-datepicker_insetInput_date_type_wrapper_compact;
1142
+ &[x-type=dateRange],
1143
+ &[x-type=dateTimeRange] {
1144
+ width: $width-datepicker_insetInput_date_range_type_wrapper_compact;
1145
+ padding-top: $spacing-datepicker_insetInput_wrapper_rangeType_compact-paddingTop;
1146
+
1147
+ .#{$prefix}-input-wrapper {
1148
+ margin-top: $spacing-datepicker_insetInput_wrapper_compact-paddingY;
1149
+ }
1150
+ }
1151
+ &[x-type=month] {
1152
+ width: $width-datepicker_insetInput_month_type_wrapper_compact;
1153
+ }
1154
+
1155
+ .#{$prefix}-input-wrapper {
1156
+ height: $height-datepicker_insetInput_wrapper_compact;
1157
+ box-sizing: border-box;
1158
+
1159
+ .#{$prefix}-input {
1160
+ font-size: $fontSize-datepicker_insetInput_compact-fontSize;
1161
+ line-height: $height-datepicker_insetInput_compact;
1162
+ height: $height-datepicker_insetInput_compact;
1163
+ vertical-align: top;
1164
+ }
1165
+ }
1166
+ }
1167
+
1168
+ &-separator {
1169
+ border-left: $width-datepicker-border solid $color-datepicker_border-bg-default;
1170
+ transform: translateX(50%);
1171
+ height: auto;
1172
+ }
1173
+ }
1042
1174
  }
1043
1175
 
1044
1176
  // 向上弹出时固定高度为6周 #1042
@@ -1046,8 +1178,10 @@ $module: #{$prefix}-datepicker;
1046
1178
 
1047
1179
  &-wrapper {
1048
1180
 
1049
- &[x-placement*="top"],
1050
- &[x-placement*="Top"] {
1181
+ &[x-placement^="top"],
1182
+ &[x-placement="leftTop"],
1183
+ &[x-placement="rightTop"],
1184
+ &[x-placement*="BottomOver"] {
1051
1185
  .#{$module} .#{$module}-weeks {
1052
1186
  min-height: 6 * $width-datepicker_day;
1053
1187
  }
@@ -1056,7 +1190,6 @@ $module: #{$prefix}-datepicker;
1056
1190
  min-height: 6 * $width-datepicker_day_compact;
1057
1191
  }
1058
1192
  }
1059
-
1060
1193
  }
1061
1194
  }
1062
1195
 
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import BaseFoundation, { DefaultAdapter } from '../base/foundation';
3
3
  import { strings } from './constants';
4
- import { Type, DateInputFoundationProps } from './inputFoundation';
4
+ import { Type, DateInputFoundationProps, InsetInputValue } from './inputFoundation';
5
5
  import { MonthsGridFoundationProps } from './monthsGridFoundation';
6
6
  import { WeekStartNumber } from './_utils/getMonthTable';
7
7
  import { ArrayElement, Motion } from '../utils/type';
@@ -70,6 +70,7 @@ export interface RenderProps {
70
70
  renderFullDate?: RenderFullDateType;
71
71
  triggerRender?: TriggerRenderType;
72
72
  }
73
+ export declare type RangeType = 'rangeStart' | 'rangeEnd' | false;
73
74
  export interface EventHandlerProps {
74
75
  onCancel?: OnCancelType;
75
76
  onChange?: OnChangeType;
@@ -78,7 +79,7 @@ export interface EventHandlerProps {
78
79
  onConfirm?: OnConfirmType;
79
80
  onBlur?: (e: any) => void;
80
81
  onClear?: (e: any) => void;
81
- onFocus?: (e: any, rangType: 'rangeStart' | 'rangeEnd') => void;
82
+ onFocus?: (e: any, rangType: RangeType) => void;
82
83
  onPresetClick?: OnPresetClickType;
83
84
  }
84
85
  export interface DatePickerFoundationProps extends ElementProps, RenderProps, EventHandlerProps {
@@ -130,6 +131,7 @@ export interface DatePickerFoundationProps extends ElementProps, RenderProps, Ev
130
131
  dateFnsLocale?: any;
131
132
  localeCode?: string;
132
133
  rangeSeparator?: string;
134
+ insetInput?: boolean;
133
135
  }
134
136
  export interface DatePickerFoundationState {
135
137
  panelShow: boolean;
@@ -139,8 +141,10 @@ export interface DatePickerFoundationState {
139
141
  cachedSelectedValue: Date[];
140
142
  prevTimeZone: string | number;
141
143
  motionEnd: boolean;
142
- rangeInputFocus: 'rangeStart' | 'rangeEnd' | boolean;
144
+ rangeInputFocus: RangeType;
143
145
  autofocus: boolean;
146
+ insetInputValue: InsetInputValue;
147
+ triggerDisabled: boolean;
144
148
  }
145
149
  export { Type, DateInputFoundationProps };
146
150
  export interface DatePickerAdapter extends DefaultAdapter<DatePickerFoundationProps, DatePickerFoundationState> {
@@ -165,6 +169,9 @@ export interface DatePickerAdapter extends DefaultAdapter<DatePickerFoundationPr
165
169
  setRangeInputFocus: (rangeInputFocus: DatePickerFoundationState['rangeInputFocus']) => void;
166
170
  couldPanelClosed: () => boolean;
167
171
  isEventTarget: (e: any) => boolean;
172
+ updateInsetInputValue: (insetInputValue: InsetInputValue) => void;
173
+ setInsetInputFocus: () => void;
174
+ setTriggerDisabled: (disabled: boolean) => void;
168
175
  }
169
176
  /**
170
177
  * The datePicker foundation.js is responsible for maintaining the date value and the input box value, as well as the callback of both
@@ -207,6 +214,10 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
207
214
  * clear input value when selected date is not confirmed
208
215
  */
209
216
  needConfirmSideEffectsWhenClosePanel(willUpdateDates: Date[] | null | undefined): void;
217
+ /**
218
+ * clear inset input value when close panel
219
+ */
220
+ clearInsetInputValue(): void;
210
221
  resetCachedSelectedValue(willUpdateDates?: Date[]): void;
211
222
  /**
212
223
  * timing to call closePanel
@@ -233,6 +244,17 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
233
244
  * @param {Event} e
234
245
  */
235
246
  handleInputChange(input: string, e: any): void;
247
+ /**
248
+ * inset input 变化时需要更新以下 state 状态
249
+ * - insetInputValue(总是)
250
+ * - inputValue(可以解析为合法日期时)
251
+ * - value(可以解析为合法日期时)
252
+ */
253
+ handleInsetInputChange(options: {
254
+ insetInputStr: string;
255
+ format: string;
256
+ insetInputValue: InsetInputValue;
257
+ }): void;
236
258
  /**
237
259
  * Input box blur
238
260
  * @param {String} input
@@ -250,7 +272,7 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
250
272
  * @param {String} range 'rangeStart' or 'rangeEnd', use when type is range
251
273
  */
252
274
  handleInputFocus(e: any, range: 'rangeStart' | 'rangeEnd'): void;
253
- handleSetRangeFocus(rangeInputFocus: boolean | 'rangeStart' | 'rangeEnd'): void;
275
+ handleSetRangeFocus(rangeInputFocus: RangeType): void;
254
276
  handleInputClear(e: any): void;
255
277
  /**
256
278
  * 范围选择清除按钮回调
@@ -269,7 +291,7 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
269
291
  * @param {string} input
270
292
  * @returns {Date [] | '}
271
293
  */
272
- parseInput(input?: string): Date[];
294
+ parseInput(input?: string, format?: string): Date[];
273
295
  /**
274
296
  * Parses the input when multiple is true, if valid,
275
297
  * returns a list of time objects, otherwise returns an array
@@ -286,14 +308,14 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
286
308
  * @param {Date[]} dates
287
309
  * @returns {string}
288
310
  */
289
- formatDates(dates?: Date[]): string;
311
+ formatDates(dates?: Date[], customFormat?: string): string;
290
312
  /**
291
313
  * dates[] => string
292
314
  *
293
315
  * @param {Date[]} dates
294
316
  * @returns {string}
295
317
  */
296
- formatMultipleDates(dates?: Date[], separator?: string): string;
318
+ formatMultipleDates(dates?: Date[], separator?: string, customFormat?: string): string;
297
319
  /**
298
320
  * Update date value and the value of the input box
299
321
  * 1. Select Update
@@ -414,4 +436,5 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
414
436
  * @returns
415
437
  */
416
438
  handleTriggerWrapperClick(e: any): void;
439
+ handlePanelVisibleChange(visible: boolean): void;
417
440
  }
@@ -29,6 +29,8 @@ import { compatiableParse } from './_utils/parser';
29
29
  import { getDefaultFormatTokenByType } from './_utils/getDefaultFormatToken';
30
30
  import { strings } from './constants';
31
31
  import { strings as inputStrings } from '../input/constants';
32
+ import getInsetInputFormatToken from './_utils/getInsetInputFormatToken';
33
+ import getInsetInputValueFromInsetInputStr from './_utils/getInsetInputValueFromInsetInputStr';
32
34
  /**
33
35
  * The datePicker foundation.js is responsible for maintaining the date value and the input box value, as well as the callback of both
34
36
  * task 1. Accept the selected date change, update the date value, and update the input box value according to the date = > Notify the change
@@ -260,6 +262,20 @@ export default class DatePickerFoundation extends BaseFoundation {
260
262
  this.resetCachedSelectedValue(willUpdateDates);
261
263
  }
262
264
  }
265
+ /**
266
+ * clear inset input value when close panel
267
+ */
268
+
269
+
270
+ clearInsetInputValue() {
271
+ const {
272
+ insetInput
273
+ } = this._adapter.getProps();
274
+
275
+ if (insetInput) {
276
+ this._adapter.updateInsetInputValue(null);
277
+ }
278
+ }
263
279
 
264
280
  resetCachedSelectedValue(willUpdateDates) {
265
281
  const {
@@ -307,6 +323,7 @@ export default class DatePickerFoundation extends BaseFoundation {
307
323
 
308
324
  this.rangeTypeSideEffectsWhenClosePanel(inputValue, willUpdateDates);
309
325
  this.needConfirmSideEffectsWhenClosePanel(willUpdateDates);
326
+ this.clearInsetInputValue();
310
327
 
311
328
  this._adapter.notifyOpenChange(false);
312
329
 
@@ -352,6 +369,52 @@ export default class DatePickerFoundation extends BaseFoundation {
352
369
  this._adapter.updateInputValue(input);
353
370
  }
354
371
  }
372
+ /**
373
+ * inset input 变化时需要更新以下 state 状态
374
+ * - insetInputValue(总是)
375
+ * - inputValue(可以解析为合法日期时)
376
+ * - value(可以解析为合法日期时)
377
+ */
378
+
379
+
380
+ handleInsetInputChange(options) {
381
+ const {
382
+ insetInputStr,
383
+ format,
384
+ insetInputValue
385
+ } = options;
386
+
387
+ const _isMultiple = this._isMultiple();
388
+
389
+ const result = _isMultiple ? this.parseMultipleInput(insetInputStr, format) : this.parseInput(insetInputStr, format);
390
+ const {
391
+ value: stateValue
392
+ } = this.getStates();
393
+
394
+ if (result && result.length) {
395
+ const changedDates = this._getChangedDates(result);
396
+
397
+ if (!this._someDateDisabled(changedDates)) {
398
+ if (this._adapter.needConfirm()) {
399
+ this._adapter.updateCachedSelectedValue(result);
400
+ }
401
+
402
+ if (!_isEqual(result, stateValue)) {
403
+ if (!this._isControlledComponent()) {
404
+ this._adapter.updateValue(result);
405
+ }
406
+
407
+ this._notifyChange(result);
408
+ }
409
+
410
+ const triggerInput = _isMultiple ? this.formatMultipleDates(result) : this.formatDates(result);
411
+
412
+ this._adapter.updateInputValue(triggerInput);
413
+ }
414
+ }
415
+
416
+ this._adapter.updateInsetInputValue(insetInputValue);
417
+ }
355
418
  /**
356
419
  * Input box blur
357
420
  * @param {String} input
@@ -482,6 +545,7 @@ export default class DatePickerFoundation extends BaseFoundation {
482
545
 
483
546
  parseInput() {
484
547
  let input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
548
+ let format = arguments.length > 1 ? arguments[1] : undefined;
485
549
  let result = []; // console.log(input);
486
550
 
487
551
  const {
@@ -491,7 +555,7 @@ export default class DatePickerFoundation extends BaseFoundation {
491
555
 
492
556
  if (input && input.length) {
493
557
  const type = this.getProp('type');
494
- const formatToken = this.getProp('format') || getDefaultFormatTokenByType(type);
558
+ const formatToken = format || this.getProp('format') || getDefaultFormatTokenByType(type);
495
559
  let parsedResult, formatedInput;
496
560
  const nowDate = new Date();
497
561
 
@@ -585,12 +649,13 @@ export default class DatePickerFoundation extends BaseFoundation {
585
649
 
586
650
  formatDates() {
587
651
  let dates = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
652
+ let customFormat = arguments.length > 1 ? arguments[1] : undefined;
588
653
  let str = '';
589
654
  const rangeSeparator = this.getProp('rangeSeparator');
590
655
 
591
656
  if (_Array$isArray(dates) && dates.length) {
592
657
  const type = this.getProp('type');
593
- const formatToken = this.getProp('format') || getDefaultFormatTokenByType(type);
658
+ const formatToken = customFormat || this.getProp('format') || getDefaultFormatTokenByType(type);
594
659
 
595
660
  switch (type) {
596
661
  case 'date':
@@ -640,6 +705,7 @@ export default class DatePickerFoundation extends BaseFoundation {
640
705
  formatMultipleDates() {
641
706
  let dates = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
642
707
  let separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : strings.DEFAULT_SEPARATOR_MULTIPLE;
708
+ let customFormat = arguments.length > 2 ? arguments[2] : undefined;
643
709
  const strs = [];
644
710
 
645
711
  if (_Array$isArray(dates) && dates.length) {
@@ -649,14 +715,14 @@ export default class DatePickerFoundation extends BaseFoundation {
649
715
  case 'date':
650
716
  case 'dateTime':
651
717
  case 'month':
652
- _forEachInstanceProperty(dates).call(dates, date => strs.push(this.formatDates([date])));
718
+ _forEachInstanceProperty(dates).call(dates, date => strs.push(this.formatDates([date], customFormat)));
653
719
 
654
720
  break;
655
721
 
656
722
  case 'dateRange':
657
723
  case 'dateTimeRange':
658
724
  for (let i = 0; i < dates.length; i += 2) {
659
- strs.push(this.formatDates(_sliceInstanceProperty(dates).call(dates, i, i + 2)));
725
+ strs.push(this.formatDates(_sliceInstanceProperty(dates).call(dates, i, i + 2), customFormat));
660
726
  }
661
727
 
662
728
  break;
@@ -706,7 +772,13 @@ export default class DatePickerFoundation extends BaseFoundation {
706
772
 
707
773
 
708
774
  handleSelectedChange(value, options) {
709
- const type = this.getProp('type');
775
+ const {
776
+ type,
777
+ format,
778
+ rangeSeparator,
779
+ insetInput
780
+ } = this._adapter.getProps();
781
+
710
782
  const {
711
783
  value: stateValue
712
784
  } = this.getStates();
@@ -733,10 +805,24 @@ export default class DatePickerFoundation extends BaseFoundation {
733
805
 
734
806
  const changedDates = this._getChangedDates(dates);
735
807
 
736
- let inputValue;
808
+ let inputValue, insetInputValue;
737
809
 
738
810
  if (!this._someDateDisabled(changedDates)) {
739
811
  inputValue = this._isMultiple() ? this.formatMultipleDates(dates) : this.formatDates(dates);
812
+
813
+ if (insetInput) {
814
+ const insetInputFormatToken = getInsetInputFormatToken({
815
+ format,
816
+ type
817
+ });
818
+ const insetInputStr = this._isMultiple() ? this.formatMultipleDates(dates, undefined, insetInputFormatToken) : this.formatDates(dates, insetInputFormatToken);
819
+ insetInputValue = getInsetInputValueFromInsetInputStr({
820
+ inputValue: insetInputStr,
821
+ type,
822
+ rangeSeparator
823
+ });
824
+ }
825
+
740
826
  const isRangeTypeAndInputIncomplete = this._isRangeType() && !this._isRangeValueComplete(dates);
741
827
  /**
742
828
  * If the input is incomplete when under control, the notifyChange is not triggered because
@@ -751,15 +837,23 @@ export default class DatePickerFoundation extends BaseFoundation {
751
837
  // do not change value when selected value is incomplete
752
838
  this._adapter.updateInputValue(inputValue);
753
839
 
840
+ this._adapter.updateInsetInputValue(insetInputValue);
841
+
754
842
  return;
755
843
  } else {
756
- (!controlled || fromPreset) && this._updateValueAndInput(dates, true, inputValue);
844
+ if (!controlled || fromPreset) {
845
+ this._updateValueAndInput(dates, true, inputValue);
846
+
847
+ this._adapter.updateInsetInputValue(insetInputValue);
848
+ }
757
849
  }
758
850
  }
759
851
 
760
852
  if (!controlled && this._adapter.needConfirm()) {
761
853
  // select date only change inputValue when needConfirm is true
762
- this._adapter.updateInputValue(inputValue); // if inputValue is not complete, don't notifyChange
854
+ this._adapter.updateInputValue(inputValue);
855
+
856
+ this._adapter.updateInsetInputValue(insetInputValue); // if inputValue is not complete, don't notifyChange
763
857
 
764
858
 
765
859
  if (isRangeTypeAndInputIncomplete) {
@@ -803,7 +897,7 @@ export default class DatePickerFoundation extends BaseFoundation {
803
897
  const {
804
898
  cachedSelectedValue,
805
899
  value
806
- } = this.getStates();
900
+ } = this._adapter.getStates();
807
901
 
808
902
  const isRangeValueComplete = this._isRangeValueComplete(cachedSelectedValue);
809
903
 
@@ -1174,4 +1268,21 @@ export default class DatePickerFoundation extends BaseFoundation {
1174
1268
  }
1175
1269
  }
1176
1270
 
1271
+ handlePanelVisibleChange(visible) {
1272
+ if (visible) {
1273
+ this._adapter.setInsetInputFocus();
1274
+ /**
1275
+ * After the panel is closed, the trigger input is disabled
1276
+ * 面板关闭后,trigger input 禁用
1277
+ */
1278
+
1279
+
1280
+ _setTimeout(() => {
1281
+ this._adapter.setTriggerDisabled(true);
1282
+ }, 0);
1283
+ } else {
1284
+ this._adapter.setTriggerDisabled(false);
1285
+ }
1286
+ }
1287
+
1177
1288
  }
@@ -1,8 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import BaseFoundation, { DefaultAdapter } from '../base/foundation';
3
- import { BaseValueType, ValidateStatus, ValueType } from './foundation';
3
+ import { BaseValueType, ValidateStatus } from './foundation';
4
+ import { strings } from './constants';
4
5
  export declare type Type = 'date' | 'dateRange' | 'year' | 'month' | 'dateTime' | 'dateTimeRange';
5
6
  export declare type RangeType = 'rangeStart' | 'rangeEnd';
7
+ export declare type PanelType = 'left' | 'right';
6
8
  export interface DateInputEventHandlerProps {
7
9
  onClick?: (e: any) => void;
8
10
  onChange?: (value: string, e: any) => void;
@@ -12,6 +14,7 @@ export interface DateInputEventHandlerProps {
12
14
  onClear?: (e: any) => void;
13
15
  onRangeInputClear?: (e: any) => void;
14
16
  onRangeEndTabPress?: (e: any) => void;
17
+ onInsetInputChange?: (options: InsetInputChangeProps) => void;
15
18
  }
16
19
  export interface DateInputElementProps {
17
20
  insetLabel?: any;
@@ -19,7 +22,7 @@ export interface DateInputElementProps {
19
22
  }
20
23
  export interface DateInputFoundationProps extends DateInputElementProps, DateInputEventHandlerProps {
21
24
  [x: string]: any;
22
- value?: ValueType;
25
+ value?: BaseValueType[];
23
26
  disabled?: boolean;
24
27
  type?: Type;
25
28
  showClear?: boolean;
@@ -29,11 +32,37 @@ export interface DateInputFoundationProps extends DateInputElementProps, DateInp
29
32
  validateStatus?: ValidateStatus;
30
33
  prefixCls?: string;
31
34
  rangeSeparator?: string;
35
+ panelType?: PanelType;
36
+ insetInput?: boolean;
37
+ insetInputValue?: InsetInputValue;
38
+ density?: typeof strings.DENSITY_SET[number];
39
+ }
40
+ export interface InsetInputValue {
41
+ monthLeft: {
42
+ dateInput: string;
43
+ timeInput: string;
44
+ };
45
+ monthRight: {
46
+ dateInput: string;
47
+ timeInput: string;
48
+ };
49
+ }
50
+ export interface InsetInputChangeFoundationProps {
51
+ value: string;
52
+ insetInputValue: InsetInputValue;
53
+ event: any;
54
+ valuePath: string;
55
+ }
56
+ export interface InsetInputChangeProps {
57
+ insetInputStr: string;
58
+ format: string;
59
+ insetInputValue: InsetInputValue;
32
60
  }
33
61
  export interface DateInputAdapter extends DefaultAdapter {
34
62
  updateIsFocusing: (isFocusing: boolean) => void;
35
63
  notifyClick: DateInputFoundationProps['onClick'];
36
64
  notifyChange: DateInputFoundationProps['onChange'];
65
+ notifyInsetInputChange: DateInputFoundationProps['onInsetInputChange'];
37
66
  notifyEnter: DateInputFoundationProps['onEnterPress'];
38
67
  notifyBlur: DateInputFoundationProps['onBlur'];
39
68
  notifyClear: DateInputFoundationProps['onClear'];
@@ -54,5 +83,46 @@ export default class InputFoundation extends BaseFoundation<DateInputAdapter> {
54
83
  handleRangeInputEnterPress(e: any, rangeInputValue: string): void;
55
84
  handleRangeInputEndKeyPress(e: any): void;
56
85
  handleRangeInputFocus(e: any, rangeType: RangeType): void;
57
- formatShowText(value: BaseValueType[]): string;
86
+ formatShowText(value: BaseValueType[], customFormat?: string): string;
87
+ handleInsetInputChange(options: InsetInputChangeFoundationProps): void;
88
+ /**
89
+ * 只有传入的 format 符合 formatReg 时,才会使用用户传入的 format
90
+ * 否则会使用默认的 format 作为 placeholder
91
+ *
92
+ * The format passed in by the user will be used only if the incoming format conforms to formatReg
93
+ * Otherwise the default format will be used as placeholder
94
+ */
95
+ getInsetInputPlaceholder(): {
96
+ datePlaceholder: any;
97
+ timePlaceholder: any;
98
+ };
99
+ /**
100
+ * 从当前日期值或 inputValue 中解析出 insetInputValue
101
+ *
102
+ * Parse out insetInputValue from current date value or inputValue
103
+ */
104
+ getInsetInputValue({ value, insetInputValue }: {
105
+ value: BaseValueType[];
106
+ insetInputValue: InsetInputValue;
107
+ }): {
108
+ monthLeft: {
109
+ dateInput: string;
110
+ timeInput: string;
111
+ };
112
+ monthRight: {
113
+ dateInput: string;
114
+ timeInput: string;
115
+ };
116
+ };
117
+ concatInsetDateAndTime({ date, time }: {
118
+ date: any;
119
+ time: any;
120
+ }): string;
121
+ concatInsetDateRange({ rangeStart, rangeEnd }: {
122
+ rangeStart: any;
123
+ rangeEnd: any;
124
+ }): string;
125
+ concatInsetInputValue({ insetInputValue }: {
126
+ insetInputValue: InsetInputValue;
127
+ }): string;
58
128
  }