amis 1.9.1-beta.28 → 1.9.1-beta.30

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. package/lib/components/AnchorNav.d.ts +9 -2
  2. package/lib/components/AnchorNav.js +32 -5
  3. package/lib/components/AnchorNav.js.map +2 -2
  4. package/lib/components/DatePicker.d.ts +41 -40
  5. package/lib/components/DatePicker.js +3 -5
  6. package/lib/components/DatePicker.js.map +2 -2
  7. package/lib/components/DateRangePicker.d.ts +45 -42
  8. package/lib/components/DateRangePicker.js +43 -11
  9. package/lib/components/DateRangePicker.js.map +2 -2
  10. package/lib/components/MonthRangePicker.d.ts +41 -40
  11. package/lib/components/MonthRangePicker.js +2 -2
  12. package/lib/components/MonthRangePicker.js.map +2 -2
  13. package/lib/components/SearchBox.d.ts +124 -42
  14. package/lib/components/SearchBox.js +181 -19
  15. package/lib/components/SearchBox.js.map +2 -2
  16. package/lib/components/Tag.d.ts +12 -10
  17. package/lib/components/Tag.js +18 -7
  18. package/lib/components/Tag.js.map +2 -2
  19. package/lib/components/calendar/Calendar.d.ts +1 -0
  20. package/lib/components/calendar/Calendar.js +8 -8
  21. package/lib/components/calendar/Calendar.js.map +2 -2
  22. package/lib/components/calendar/DaysView.d.ts +2 -1
  23. package/lib/components/calendar/DaysView.js +5 -4
  24. package/lib/components/calendar/DaysView.js.map +2 -2
  25. package/lib/index.js +1 -1
  26. package/lib/locale/de-DE.js +1 -0
  27. package/lib/locale/de-DE.js.map +2 -2
  28. package/lib/locale/en-US.js +1 -0
  29. package/lib/locale/en-US.js.map +2 -2
  30. package/lib/locale/zh-CN.js +1 -0
  31. package/lib/locale/zh-CN.js.map +2 -2
  32. package/lib/renderers/CRUD.d.ts +2 -0
  33. package/lib/renderers/CRUD.js +8 -2
  34. package/lib/renderers/CRUD.js.map +2 -2
  35. package/lib/renderers/Card.d.ts +7 -2
  36. package/lib/renderers/Card.js +11 -7
  37. package/lib/renderers/Card.js.map +2 -2
  38. package/lib/renderers/Form/InputColor.d.ts +0 -458
  39. package/lib/renderers/Form/InputColor.js +8 -9
  40. package/lib/renderers/Form/InputColor.js.map +2 -2
  41. package/lib/renderers/Form/InputExcel.d.ts +1 -0
  42. package/lib/renderers/Form/InputExcel.js +5 -0
  43. package/lib/renderers/Form/InputExcel.js.map +2 -2
  44. package/lib/renderers/Form/InputFile.d.ts +2 -2
  45. package/lib/renderers/Form/InputFile.js +6 -5
  46. package/lib/renderers/Form/InputFile.js.map +2 -2
  47. package/lib/renderers/Form/InputTable.js +16 -2
  48. package/lib/renderers/Form/InputTable.js.map +2 -2
  49. package/lib/renderers/Form/InputText.d.ts +8 -0
  50. package/lib/renderers/Form/InputText.js +8 -8
  51. package/lib/renderers/Form/InputText.js.map +2 -2
  52. package/lib/renderers/IFrame.d.ts +4 -0
  53. package/lib/renderers/IFrame.js +2 -2
  54. package/lib/renderers/IFrame.js.map +2 -2
  55. package/lib/renderers/Table/index.js +2 -2
  56. package/lib/renderers/Table/index.js.map +2 -2
  57. package/lib/renderers/Tag.js +2 -2
  58. package/lib/renderers/Tag.js.map +2 -2
  59. package/lib/renderers/Wizard.d.ts +1 -1
  60. package/lib/renderers/Wizard.js +72 -75
  61. package/lib/renderers/Wizard.js.map +2 -2
  62. package/lib/store/formItem.js +2 -1
  63. package/lib/store/formItem.js.map +2 -2
  64. package/lib/themes/ang-ie11.css +134 -21
  65. package/lib/themes/ang.css +138 -21
  66. package/lib/themes/ang.css.map +1 -1
  67. package/lib/themes/antd-ie11.css +134 -21
  68. package/lib/themes/antd.css +138 -21
  69. package/lib/themes/antd.css.map +1 -1
  70. package/lib/themes/cxd-ie11.css +134 -21
  71. package/lib/themes/cxd.css +138 -21
  72. package/lib/themes/cxd.css.map +1 -1
  73. package/lib/themes/dark-ie11.css +134 -21
  74. package/lib/themes/dark.css +138 -21
  75. package/lib/themes/dark.css.map +1 -1
  76. package/lib/themes/default-ie11.css +134 -21
  77. package/lib/themes/default.css +138 -21
  78. package/lib/themes/default.css.map +1 -1
  79. package/lib/utils/dom.js +3 -2
  80. package/lib/utils/dom.js.map +2 -2
  81. package/package.json +3 -3
  82. package/schema.json +35 -14
  83. package/scss/_properties.scss +5 -0
  84. package/scss/components/_anchor-nav.scss +1 -0
  85. package/scss/components/_calendar.scss +32 -14
  86. package/scss/components/_search-box.scss +116 -10
  87. package/scss/components/_tag.scss +12 -3
  88. package/scss/components/form/_date-range.scss +1 -1
  89. package/scss/components/form/_date.scss +28 -24
  90. package/sdk/ang-ie11.css +146 -20
  91. package/sdk/ang.css +150 -20
  92. package/sdk/antd-ie11.css +146 -20
  93. package/sdk/antd.css +150 -20
  94. package/sdk/barcode.js +51 -51
  95. package/sdk/charts.js +14 -14
  96. package/sdk/codemirror.js +7 -7
  97. package/sdk/cropperjs.js +2 -2
  98. package/sdk/cxd-ie11.css +146 -20
  99. package/sdk/cxd.css +150 -20
  100. package/sdk/dark-ie11.css +146 -20
  101. package/sdk/dark.css +150 -20
  102. package/sdk/exceljs.js +1 -1
  103. package/sdk/locale/de-DE.js +1 -0
  104. package/sdk/markdown.js +69 -69
  105. package/sdk/papaparse.js +1 -1
  106. package/sdk/renderers/Form/CityDB.js +1 -1
  107. package/sdk/rest.js +9 -23
  108. package/sdk/rich-text.js +62 -62
  109. package/sdk/sdk-ie11.css +146 -20
  110. package/sdk/sdk.css +150 -20
  111. package/sdk/sdk.js +1480 -1336
  112. package/sdk/thirds/hls.js/hls.js +1 -1
  113. package/sdk/thirds/mpegts.js/mpegts.js +1 -1
  114. package/sdk/tinymce.js +57 -57
  115. package/src/components/AnchorNav.tsx +48 -7
  116. package/src/components/DatePicker.tsx +9 -8
  117. package/src/components/DateRangePicker.tsx +62 -11
  118. package/src/components/MonthRangePicker.tsx +4 -2
  119. package/src/components/SearchBox.tsx +262 -29
  120. package/src/components/Tag.tsx +14 -3
  121. package/src/components/calendar/Calendar.tsx +30 -14
  122. package/src/components/calendar/DaysView.tsx +17 -5
  123. package/src/locale/de-DE.ts +1 -0
  124. package/src/locale/en-US.ts +1 -0
  125. package/src/locale/zh-CN.ts +1 -0
  126. package/src/renderers/CRUD.tsx +10 -0
  127. package/src/renderers/Card.tsx +24 -12
  128. package/src/renderers/Form/InputColor.tsx +14 -19
  129. package/src/renderers/Form/InputExcel.tsx +6 -0
  130. package/src/renderers/Form/InputFile.tsx +19 -18
  131. package/src/renderers/Form/InputTable.tsx +25 -4
  132. package/src/renderers/Form/InputText.tsx +20 -5
  133. package/src/renderers/IFrame.tsx +30 -1
  134. package/src/renderers/Table/index.tsx +2 -1
  135. package/src/renderers/Tag.tsx +2 -0
  136. package/src/renderers/Wizard.tsx +2 -1
  137. package/src/store/formItem.ts +4 -1
  138. package/src/utils/dom.tsx +3 -2
  139. package/sdk/color-picker.js +0 -130
@@ -49,8 +49,13 @@ export interface AnchorNavProps extends ThemeProps {
49
49
  direction?: 'vertical' | 'horizontal'; // 导航方向
50
50
  }
51
51
 
52
+ interface SectionOffset {
53
+ key: string | number;
54
+ offsetTop: number;
55
+ }
56
+
52
57
  export interface AnchorNavState {
53
- offsetArr: PlainObject[]; // 记录每个段落的offsetTop
58
+ offsetArr: SectionOffset[]; // 记录每个段落的offsetTop
54
59
  fromSelect: boolean; // 标识滚动触发来源
55
60
  }
56
61
 
@@ -67,17 +72,53 @@ export class AnchorNav extends React.Component<AnchorNavProps, AnchorNavState> {
67
72
  // 滚动区域DOM
68
73
  contentDom: React.RefObject<HTMLDivElement> = React.createRef();
69
74
 
75
+ // 后代节点观察器
76
+ observer: MutationObserver;
77
+
78
+ // 滚动区域的高度
79
+ contentDomHeight = 0;
80
+
70
81
  componentDidMount() {
71
- // 初始化滚动标识
82
+ // 初始化滚动标识
72
83
  this.setState({fromSelect: false});
73
84
 
74
- // add scroll event
75
85
  const sectionRootDom =
76
86
  this.contentDom && (this.contentDom.current as HTMLElement);
77
- sectionRootDom.addEventListener('scroll', this.scrollToNav);
78
- let offsetArr: Array<object> = [];
87
+
88
+ this.updateSectionOffset(sectionRootDom, false);
89
+ this.observer = new MutationObserver((mutations: MutationRecord[]) => {
90
+ let height = sectionRootDom.scrollHeight;
91
+
92
+ // 监听sectio容器dom高度是否变化,如果变化,则重新计算section的offset
93
+ if (height !== this.contentDomHeight) {
94
+ this.contentDomHeight = height;
95
+ this.updateSectionOffset(sectionRootDom, true);
96
+ }
97
+ });
98
+
99
+ this.observer.observe(sectionRootDom, {
100
+ childList: true,
101
+ attributes: true, // 属性变化也有可能导致高度的变化,例如类名,所以也要监听
102
+ subtree: true
103
+ });
104
+ }
105
+
106
+ componentWillUnmount() {
107
+ if (this.contentDom && this.contentDom.current) {
108
+ this.contentDom.current.removeEventListener('scroll', this.scrollToNav);
109
+ }
110
+ this.observer && this.observer.disconnect();
111
+ }
112
+
113
+ updateSectionOffset(parentNode: HTMLElement, inited: boolean) {
114
+ const offsetArr: Array<SectionOffset> = [];
79
115
  const {children, active} = this.props;
80
116
 
117
+ if (!inited) {
118
+ // add scroll event
119
+ parentNode.addEventListener('scroll', this.scrollToNav);
120
+ }
121
+
81
122
  // 收集段落区域offsetTop
82
123
  children &&
83
124
  React.Children.forEach(
@@ -85,7 +126,7 @@ export class AnchorNav extends React.Component<AnchorNavProps, AnchorNavState> {
85
126
  (section: AnchorNavSectionComponent, index: number) => {
86
127
  offsetArr.push({
87
128
  key: section.props.name,
88
- offsetTop: (sectionRootDom.children[index] as HTMLElement).offsetTop
129
+ offsetTop: (parentNode.children[index] as HTMLElement).offsetTop
89
130
  });
90
131
  }
91
132
  );
@@ -94,7 +135,7 @@ export class AnchorNav extends React.Component<AnchorNavProps, AnchorNavState> {
94
135
  {
95
136
  offsetArr
96
137
  },
97
- () => active && this.scrollToSection(active)
138
+ !inited ? () => active && this.scrollToSection(active) : undefined
98
139
  );
99
140
  }
100
141
 
@@ -276,7 +276,7 @@ export interface DateProps extends LocaleProps, ThemeProps {
276
276
  };
277
277
  };
278
278
  popOverContainer?: any;
279
-
279
+ label?: string | false;
280
280
  borderMode?: 'full' | 'half' | 'none';
281
281
  // 是否为内嵌模式,如果开启就不是 picker 了,直接页面点选。
282
282
  embed?: boolean;
@@ -368,7 +368,6 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
368
368
 
369
369
  componentDidUpdate(prevProps: DateProps) {
370
370
  const props = this.props;
371
-
372
371
  const prevValue = prevProps.value;
373
372
 
374
373
  if (prevValue !== props.value) {
@@ -400,9 +399,7 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
400
399
  }
401
400
 
402
401
  handleBlur(e: React.SyntheticEvent<HTMLDivElement>) {
403
- this.setState({
404
- isFocused: false
405
- });
402
+ this.setState({isFocused: false});
406
403
  const {onBlur} = this.props;
407
404
  onBlur && onBlur(e);
408
405
  }
@@ -657,7 +654,8 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
657
654
  largeMode,
658
655
  scheduleClassNames,
659
656
  onScheduleClick,
660
- mobileCalendarMode
657
+ mobileCalendarMode,
658
+ label
661
659
  } = this.props;
662
660
 
663
661
  const __ = this.props.translate;
@@ -687,7 +685,7 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
687
685
  );
688
686
  const CalendarMobileTitle = (
689
687
  <div className={`${ns}CalendarMobile-title`}>
690
- {__('Calendar.datepicker')}
688
+ {label && typeof label === 'string' ? label : __('Calendar.datepicker')}
691
689
  </div>
692
690
  );
693
691
  const useCalendarMobile =
@@ -788,7 +786,10 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
788
786
  ) : null}
789
787
 
790
788
  <a className={cx(`DatePicker-toggler`)}>
791
- <Icon icon={viewMode === 'time' ? 'clock' : 'date'} className="icon" />
789
+ <Icon
790
+ icon={viewMode === 'time' ? 'clock' : 'date'}
791
+ className="icon"
792
+ />
792
793
  </a>
793
794
 
794
795
  {!(useMobileUI && isMobile()) && isOpened ? (
@@ -55,6 +55,7 @@ export interface DateRangePickerProps extends ThemeProps, LocaleProps {
55
55
  onBlur?: Function;
56
56
  type?: string;
57
57
  onRef?: any;
58
+ label?: string | false;
58
59
  }
59
60
 
60
61
  export interface DateRangePickerState {
@@ -62,6 +63,8 @@ export interface DateRangePickerState {
62
63
  isFocused: boolean;
63
64
  startDate?: moment.Moment;
64
65
  endDate?: moment.Moment;
66
+ oldStartDate?: moment.Moment;
67
+ oldEndDate?: moment.Moment;
65
68
  editState?: 'start' | 'end'; // 编辑开始时间还是结束时间
66
69
  startInputValue?: string;
67
70
  endInputValue?: string;
@@ -534,6 +537,8 @@ export class DateRangePicker extends React.Component<
534
537
  editState: 'start',
535
538
  startDate,
536
539
  endDate,
540
+ oldStartDate: startDate,
541
+ oldEndDate: endDate,
537
542
  startInputValue: startDate?.format(inputFormat),
538
543
  endInputValue: endDate?.format(inputFormat)
539
544
  };
@@ -645,7 +650,17 @@ export class DateRangePicker extends React.Component<
645
650
  });
646
651
  }
647
652
 
648
- close() {
653
+ close(isConfirm: boolean = false) {
654
+ if (!isConfirm) {
655
+ const {oldEndDate, oldStartDate} = this.state;
656
+ const {inputFormat} = this.props;
657
+ this.setState({
658
+ endDate: oldEndDate,
659
+ endInputValue: oldEndDate ? oldEndDate.format(inputFormat) : '',
660
+ startDate: oldStartDate,
661
+ startInputValue: oldStartDate ? oldStartDate.format(inputFormat) : ''
662
+ });
663
+ }
649
664
  this.setState(
650
665
  {
651
666
  isOpened: false,
@@ -693,7 +708,7 @@ export class DateRangePicker extends React.Component<
693
708
  if (this.state.startDate && !this.state.endDate) {
694
709
  this.setState({editState: 'end'});
695
710
  } else {
696
- this.close();
711
+ this.close(true);
697
712
  }
698
713
  }
699
714
 
@@ -723,8 +738,22 @@ export class DateRangePicker extends React.Component<
723
738
  return value;
724
739
  }
725
740
 
726
- handleDateChange(newValue: moment.Moment) {
741
+ handleDateChange(
742
+ newValue: moment.Moment,
743
+ timeRangeContext?: 'start' | 'end'
744
+ ) {
727
745
  let {editState} = this.state;
746
+
747
+ if (timeRangeContext) {
748
+ if (timeRangeContext === 'start') {
749
+ this.handleStartDateChange(newValue);
750
+ } else if (timeRangeContext === 'end') {
751
+ this.handeleEndDateChange(newValue);
752
+ }
753
+
754
+ return;
755
+ }
756
+
728
757
  if (editState === 'start') {
729
758
  this.handleStartDateChange(newValue);
730
759
  } else if (editState === 'end') {
@@ -746,6 +775,7 @@ export class DateRangePicker extends React.Component<
746
775
  );
747
776
  const newState = {
748
777
  startDate: date,
778
+ oldStartDate: startDate,
749
779
  startInputValue: date.format(inputFormat)
750
780
  } as any;
751
781
  // 这些没有时间的选择点第一次后第二次就是选结束时间
@@ -769,14 +799,17 @@ export class DateRangePicker extends React.Component<
769
799
  if (newValue.isBefore(startDate)) {
770
800
  this.setState({
771
801
  startDate: undefined,
802
+ oldStartDate: startDate,
772
803
  startInputValue: ''
773
804
  });
774
805
  }
775
806
 
776
807
  const date = this.filterDate(newValue, endDate, timeFormat, 'end');
808
+
777
809
  this.setState(
778
810
  {
779
811
  endDate: date,
812
+ oldEndDate: endDate,
780
813
  endInputValue: date.format(inputFormat)
781
814
  },
782
815
  () => {
@@ -1147,6 +1180,14 @@ export class DateRangePicker extends React.Component<
1147
1180
  props.className += ' rdtBetween';
1148
1181
  }
1149
1182
 
1183
+ if (startDate && currentDate.isSame(startDate, 'day')) {
1184
+ props.className += ' rdtActive rdtStartDay';
1185
+ }
1186
+
1187
+ if (endDate && currentDate.isSame(endDate, 'day')) {
1188
+ props.className += ' rdtActive rdtEndDay';
1189
+ }
1190
+
1150
1191
  return (
1151
1192
  <td {...props}>
1152
1193
  <span>{currentDate.date()}</span>
@@ -1226,7 +1267,8 @@ export class DateRangePicker extends React.Component<
1226
1267
  locale,
1227
1268
  embed,
1228
1269
  type,
1229
- viewMode = 'days'
1270
+ viewMode = 'days',
1271
+ useMobileUI
1230
1272
  } = this.props;
1231
1273
  const __ = this.props.translate;
1232
1274
 
@@ -1236,7 +1278,7 @@ export class DateRangePicker extends React.Component<
1236
1278
  const isTimeRange = type === 'input-datetime-range' || viewMode === 'time';
1237
1279
 
1238
1280
  return (
1239
- <div className={`${ns}DateRangePicker-wrap`} ref={this.calendarRef}>
1281
+ <div className={cx(`${ns}DateRangePicker-wrap`)} ref={this.calendarRef}>
1240
1282
  {this.renderRanges(ranges)}
1241
1283
  {(!isTimeRange || (editState === 'start' && !embed)) && (
1242
1284
  <Calendar
@@ -1264,7 +1306,8 @@ export class DateRangePicker extends React.Component<
1264
1306
  renderQuarter={this.renderQuarter}
1265
1307
  renderYear={this.renderYear}
1266
1308
  locale={locale}
1267
- timeRangeHeader="开始时间"
1309
+ timeRangeHeader={__('Calendar.startPick')}
1310
+ timeRangeContext="start"
1268
1311
  />
1269
1312
  )}
1270
1313
  {(!isTimeRange || (editState === 'end' && !embed)) && (
@@ -1293,13 +1336,17 @@ export class DateRangePicker extends React.Component<
1293
1336
  renderQuarter={this.renderQuarter}
1294
1337
  renderYear={this.renderYear}
1295
1338
  locale={locale}
1296
- timeRangeHeader="结束时间"
1339
+ timeRangeHeader={__('Calendar.endPick')}
1340
+ timeRangeContext="end"
1297
1341
  />
1298
1342
  )}
1299
1343
 
1300
1344
  {embed ? null : (
1301
1345
  <div key="button" className={`${ns}DateRangePicker-actions`}>
1302
- <a className={cx('Button', 'Button--default')} onClick={this.close}>
1346
+ <a
1347
+ className={cx('Button', 'Button--default')}
1348
+ onClick={() => this.close()}
1349
+ >
1303
1350
  {__('cancel')}
1304
1351
  </a>
1305
1352
  <a
@@ -1348,7 +1395,8 @@ export class DateRangePicker extends React.Component<
1348
1395
  maxDuration,
1349
1396
  dateFormat,
1350
1397
  viewMode = 'days',
1351
- ranges
1398
+ ranges,
1399
+ label
1352
1400
  } = this.props;
1353
1401
  const useCalendarMobile =
1354
1402
  useMobileUI &&
@@ -1400,7 +1448,7 @@ export class DateRangePicker extends React.Component<
1400
1448
 
1401
1449
  const CalendarMobileTitle = (
1402
1450
  <div className={`${ns}CalendarMobile-title`}>
1403
- {__('Calendar.datepicker')}
1451
+ {label && typeof label === 'string' ? label : __('Calendar.datepicker')}
1404
1452
  </div>
1405
1453
  );
1406
1454
 
@@ -1466,7 +1514,10 @@ export class DateRangePicker extends React.Component<
1466
1514
  <PopUp
1467
1515
  isShow={isOpened}
1468
1516
  container={popOverContainer}
1469
- className={cx(`${ns}CalendarMobile-pop`)}
1517
+ className={cx(
1518
+ `${ns}CalendarMobile-pop`,
1519
+ `${ns}CalendarMobile-pop--${viewMode}`
1520
+ )}
1470
1521
  onHide={this.close}
1471
1522
  header={CalendarMobileTitle}
1472
1523
  >
@@ -52,6 +52,7 @@ export interface MonthRangePickerProps extends ThemeProps, LocaleProps {
52
52
  useMobileUI?: boolean;
53
53
  onFocus?: Function;
54
54
  onBlur?: Function;
55
+ label?: string | false;
55
56
  }
56
57
 
57
58
  export interface MonthRangePickerState {
@@ -555,7 +556,8 @@ export class MonthRangePicker extends React.Component<
555
556
  maxDate,
556
557
  minDuration,
557
558
  maxDuration,
558
- ranges
559
+ ranges,
560
+ label
559
561
  } = this.props;
560
562
  const mobileUI = isMobile() && useMobileUI;
561
563
 
@@ -616,7 +618,7 @@ export class MonthRangePicker extends React.Component<
616
618
 
617
619
  const CalendarMobileTitle = (
618
620
  <div className={`${ns}CalendarMobile-title`}>
619
- {__('Calendar.datepicker')}
621
+ {label && typeof label === 'string' ? label : __('Calendar.datepicker')}
620
622
  </div>
621
623
  );
622
624