amis 1.9.1-beta.0 → 1.9.1-beta.1

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 (63) hide show
  1. package/lib/components/Alert2.d.ts +10 -10
  2. package/lib/components/SearchBox.d.ts +40 -40
  3. package/lib/components/calendar/DaysView.js +13 -6
  4. package/lib/components/calendar/DaysView.js.map +2 -2
  5. package/lib/components/calendar/TimeView.js +2 -1
  6. package/lib/components/calendar/TimeView.js.map +2 -2
  7. package/lib/components/formula/Picker.js +4 -4
  8. package/lib/components/formula/Picker.js.map +2 -2
  9. package/lib/helper.css +125 -124
  10. package/lib/helper.css.map +1 -1
  11. package/lib/index.js +1 -1
  12. package/lib/renderers/Log.d.ts +16 -0
  13. package/lib/renderers/Log.js +35 -11
  14. package/lib/renderers/Log.js.map +2 -2
  15. package/lib/themes/ang-ie11.css +15 -3
  16. package/lib/themes/ang.css +15 -3
  17. package/lib/themes/ang.css.map +1 -1
  18. package/lib/themes/antd-ie11.css +15 -3
  19. package/lib/themes/antd.css +15 -3
  20. package/lib/themes/antd.css.map +1 -1
  21. package/lib/themes/cxd-ie11.css +15 -3
  22. package/lib/themes/cxd.css +15 -3
  23. package/lib/themes/cxd.css.map +1 -1
  24. package/lib/themes/dark-ie11.css +15 -3
  25. package/lib/themes/dark.css +15 -3
  26. package/lib/themes/dark.css.map +1 -1
  27. package/lib/themes/default-ie11.css +15 -3
  28. package/lib/themes/default.css +15 -3
  29. package/lib/themes/default.css.map +1 -1
  30. package/package.json +1 -1
  31. package/scss/components/form/_transfer.scss +19 -3
  32. package/scss/helper/background/_background-color.scss +125 -124
  33. package/sdk/ang-ie11.css +19 -3
  34. package/sdk/ang.css +19 -3
  35. package/sdk/antd-ie11.css +19 -3
  36. package/sdk/antd.css +19 -3
  37. package/sdk/barcode.js +51 -51
  38. package/sdk/charts.js +14 -14
  39. package/sdk/codemirror.js +7 -7
  40. package/sdk/color-picker.js +65 -65
  41. package/sdk/cropperjs.js +2 -2
  42. package/sdk/cxd-ie11.css +19 -3
  43. package/sdk/cxd.css +19 -3
  44. package/sdk/dark-ie11.css +19 -3
  45. package/sdk/dark.css +19 -3
  46. package/sdk/exceljs.js +1 -1
  47. package/sdk/helper.css +125 -124
  48. package/sdk/helper.css.map +1 -1
  49. package/sdk/markdown.js +69 -69
  50. package/sdk/papaparse.js +1 -1
  51. package/sdk/renderers/Form/CityDB.js +1 -1
  52. package/sdk/rest.js +16 -16
  53. package/sdk/rich-text.js +62 -62
  54. package/sdk/sdk-ie11.css +19 -3
  55. package/sdk/sdk.css +19 -3
  56. package/sdk/sdk.js +1307 -1305
  57. package/sdk/thirds/hls.js/hls.js +1 -1
  58. package/sdk/thirds/mpegts.js/mpegts.js +1 -1
  59. package/sdk/tinymce.js +57 -57
  60. package/src/components/calendar/DaysView.tsx +68 -37
  61. package/src/components/calendar/TimeView.tsx +1 -1
  62. package/src/components/formula/Picker.tsx +2 -1
  63. package/src/renderers/Log.tsx +71 -12
@@ -31,7 +31,12 @@ interface CustomDaysViewProps extends LocaleProps {
31
31
  setDateTimeState: (state: any) => void;
32
32
  showTime: () => void;
33
33
  setTime: (type: string, amount: number) => void;
34
- scrollToTop: (type: string, amount: number, i: number, lable?: string) => void;
34
+ scrollToTop: (
35
+ type: string,
36
+ amount: number,
37
+ i: number,
38
+ lable?: string
39
+ ) => void;
35
40
  subtractTime: (
36
41
  amount: number,
37
42
  type: string,
@@ -177,21 +182,16 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
177
182
  columns,
178
183
  types,
179
184
  pickerValue: currentDate.toArray(),
180
- uniqueTag: 0,
181
- }
185
+ uniqueTag: 0
186
+ };
182
187
  }
183
188
 
184
189
  componentWillMount() {
185
- this.setState({uniqueTag: (new Date()).valueOf()})
190
+ this.setState({uniqueTag: new Date().valueOf()});
186
191
  }
187
192
 
188
193
  componentDidMount() {
189
- const {
190
- timeFormat,
191
- selectedDate,
192
- viewDate,
193
- isEndDate,
194
- } = this.props;
194
+ const {timeFormat, selectedDate, viewDate, isEndDate} = this.props;
195
195
  const formatMap = {
196
196
  hours: 'HH',
197
197
  minutes: 'mm',
@@ -207,9 +207,14 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
207
207
  ? 'seconds'
208
208
  : '';
209
209
  if (type) {
210
- this.scrollToTop(type, parseInt(date.format(formatMap[type]), 10), i, 'init')
210
+ this.scrollToTop(
211
+ type,
212
+ parseInt(date.format(formatMap[type]), 10),
213
+ i,
214
+ 'init'
215
+ );
211
216
  }
212
- })
217
+ });
213
218
  }
214
219
 
215
220
  updateSelectedDate = (event: React.MouseEvent<any>) => {
@@ -246,17 +251,14 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
246
251
  this.props.updateSelectedDate(event, true);
247
252
  };
248
253
 
249
- showTime = () =>{
250
- const {selectedDate, viewDate, timeFormat} = this.props
254
+ showTime = () => {
255
+ const {selectedDate, viewDate, timeFormat} = this.props;
251
256
  return (
252
- <div
253
- key="stb"
254
- className="rdtShowTime"
255
- >
257
+ <div key="stb" className="rdtShowTime">
256
258
  {(selectedDate || viewDate || moment()).format(timeFormat)}
257
259
  </div>
258
- )
259
- }
260
+ );
261
+ };
260
262
 
261
263
  setTime = (
262
264
  type: 'hours' | 'minutes' | 'seconds' | 'milliseconds',
@@ -279,13 +281,15 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
279
281
  type: 'hours' | 'minutes' | 'seconds' | 'milliseconds',
280
282
  value: number,
281
283
  i: number,
282
- label?: string,
284
+ label?: string
283
285
  ) => {
284
- let elf: any = document.getElementById(`${this.state.uniqueTag}-${i}-input`);
285
- elf.parentNode.scrollTo({
286
+ let elf: any = document.getElementById(
287
+ `${this.state.uniqueTag}-${i}-input`
288
+ );
289
+ elf?.parentNode?.scrollTo({
286
290
  top: value * 28,
287
291
  behavior: label === 'init' ? 'auto' : 'smooth'
288
- })
292
+ });
289
293
  };
290
294
 
291
295
  confirm = () => {
@@ -479,7 +483,7 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
479
483
  const date = selectedDate || (isEndDate ? viewDate.endOf('day') : viewDate);
480
484
  const inputs: Array<React.ReactNode> = [];
481
485
 
482
- inputs.push(this.showTime())
486
+ inputs.push(this.showTime());
483
487
 
484
488
  timeFormat.split(':').forEach((format, i) => {
485
489
  const type = /h/i.test(format)
@@ -525,7 +529,12 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
525
529
  )
526
530
  });
527
531
  return (
528
- <div className={cx('CalendarInputWrapper', 'CalendarInputWrapperMT')}>
532
+ <div
533
+ className={cx(
534
+ 'CalendarInputWrapper',
535
+ 'CalendarInputWrapperMT'
536
+ )}
537
+ >
529
538
  {/* <input
530
539
  type="text"
531
540
  value={date.format(formatMap[type])}
@@ -534,24 +543,30 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
534
543
  max={max}
535
544
  {...inputProps}
536
545
  /> */}
537
- <div
546
+ <div
538
547
  className={cx(
539
548
  'CalendarInput-sugs',
540
- type === 'hours' ? 'CalendarInput-sugsHours' : 'CalendarInput-sugsTimes'
541
- )}
549
+ type === 'hours'
550
+ ? 'CalendarInput-sugsHours'
551
+ : 'CalendarInput-sugsTimes'
552
+ )}
542
553
  id={`${this.state.uniqueTag}-${i}-input`}
543
554
  >
544
555
  {options.map(option => {
545
556
  return (
546
557
  <div
547
558
  key={option.value}
548
- className={cx(
549
- 'CalendarInput-sugsItem',
550
- {'is-highlight': option.value === date.format(formatMap[type])}
551
- )}
559
+ className={cx('CalendarInput-sugsItem', {
560
+ 'is-highlight':
561
+ option.value === date.format(formatMap[type])
562
+ })}
552
563
  onClick={() => {
553
564
  this.setTime(type, parseInt(option.value, 10));
554
- this.scrollToTop(type, parseInt(option.value, 10), i);
565
+ this.scrollToTop(
566
+ type,
567
+ parseInt(option.value, 10),
568
+ i
569
+ );
555
570
  closeMenu();
556
571
  }}
557
572
  >
@@ -649,7 +664,13 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
649
664
  };
650
665
 
651
666
  render() {
652
- const {viewDate: date, useMobileUI, embed, timeFormat, classnames: cx} = this.props;
667
+ const {
668
+ viewDate: date,
669
+ useMobileUI,
670
+ embed,
671
+ timeFormat,
672
+ classnames: cx
673
+ } = this.props;
653
674
  const locale = date.localeData();
654
675
  const __ = this.props.translate;
655
676
  if (isMobile() && useMobileUI && !embed) {
@@ -718,9 +739,19 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
718
739
  return (
719
740
  <>
720
741
  <div className={timeFormat ? 'rdtDays' : ''}>
721
- <table className={timeFormat ? 'rdtDaysPart' : ''}>{tableChildren}</table>
742
+ <table className={timeFormat ? 'rdtDaysPart' : ''}>
743
+ {tableChildren}
744
+ </table>
722
745
  {timeFormat ? (
723
- <div className={timeFormat.toLowerCase().indexOf('s') > 0 ? "rdtTimePartWithS" : "rdtTimePart"}>{this.renderTimes()}</div>
746
+ <div
747
+ className={
748
+ timeFormat.toLowerCase().indexOf('s') > 0
749
+ ? 'rdtTimePartWithS'
750
+ : 'rdtTimePart'
751
+ }
752
+ >
753
+ {this.renderTimes()}
754
+ </div>
724
755
  ) : null}
725
756
  </div>
726
757
  <table>{this.renderFooter()}</table>
@@ -550,7 +550,7 @@ export class CustomTimeView extends React.Component<
550
550
  let elf: any = document.getElementById(
551
551
  `${this.state.uniqueTag}-${i}-input`
552
552
  );
553
- elf.parentNode.scrollTo({
553
+ elf?.parentNode?.scrollTo({
554
554
  top: value * 28,
555
555
  behavior: label === 'init' ? 'auto' : 'smooth'
556
556
  });
@@ -275,6 +275,7 @@ export class FormulaPicker extends React.Component<
275
275
  variables,
276
276
  functions,
277
277
  children,
278
+ variableMode,
278
279
  ...rest
279
280
  } = this.props;
280
281
  const {isOpened, value, editorValue, isError} = this.state;
@@ -377,7 +378,7 @@ export class FormulaPicker extends React.Component<
377
378
  {...rest}
378
379
  variables={this.state.variables ?? variables}
379
380
  functions={this.state.functions ?? functions}
380
- variableMode={this.state.variableMode}
381
+ variableMode={this.state.variableMode ?? variableMode}
381
382
  value={editorValue}
382
383
  onChange={this.handleEditorChange}
383
384
  />
@@ -7,6 +7,7 @@ import {BaseSchema, SchemaTpl} from '../Schema';
7
7
  import Ansi from 'ansi-to-react';
8
8
  import {filter} from '../utils/tpl';
9
9
  import {buildApi, isApiOutdated} from '../utils/api';
10
+ import VirtualList from '../components/virtual-list';
10
11
 
11
12
  /**
12
13
  * 日志展示组件
@@ -42,6 +43,21 @@ export interface LogSchema extends BaseSchema {
42
43
  * 返回内容字符编码
43
44
  */
44
45
  encoding?: string;
46
+
47
+ /**
48
+ * 限制最大日志数量
49
+ */
50
+ maxLength?: number;
51
+
52
+ /**
53
+ * 每行高度
54
+ */
55
+ rowHeight?: number;
56
+
57
+ /**
58
+ * 关闭 ANSI 颜色支持
59
+ */
60
+ disableColor?: boolean;
45
61
  }
46
62
 
47
63
  export interface LogProps
@@ -125,7 +141,7 @@ export class Log extends React.Component<LogProps, LogState> {
125
141
  }
126
142
 
127
143
  async loadLogs() {
128
- const {source, data, env, translate: __, encoding} = this.props;
144
+ const {source, data, env, translate: __, encoding, maxLength} = this.props;
129
145
  // 因为这里返回结果是流式的,和普通 api 请求不一样,如果直接用 fetcher 经过 responseAdaptor 可能会导致出错,所以就直接 fetch 了
130
146
  const api = buildApi(source, data);
131
147
  if (!api.url) {
@@ -162,6 +178,11 @@ export class Log extends React.Component<LogProps, LogState> {
162
178
  lines[0] = lastline + lines[0];
163
179
  // 最后一个要么是空,要么是下一行的数据
164
180
  lastline = lines.pop() || '';
181
+ if (maxLength) {
182
+ if (logs.length + lines.length > maxLength) {
183
+ logs.splice(0, lines.length);
184
+ }
185
+ }
165
186
  logs = logs.concat(lines);
166
187
  this.setState({
167
188
  logs: logs,
@@ -180,6 +201,18 @@ export class Log extends React.Component<LogProps, LogState> {
180
201
  }
181
202
  }
182
203
 
204
+ /**
205
+ * 渲染某一行
206
+ */
207
+ renderLine(index: number, line: string) {
208
+ const {classnames: cx, disableColor} = this.props;
209
+ return (
210
+ <div className={cx('Log-line')} key={index}>
211
+ {disableColor ? line : <Ansi useClasses>{line}</Ansi>}
212
+ </div>
213
+ );
214
+ }
215
+
183
216
  render() {
184
217
  const {
185
218
  source,
@@ -187,6 +220,8 @@ export class Log extends React.Component<LogProps, LogState> {
187
220
  classnames: cx,
188
221
  placeholder,
189
222
  height,
223
+ rowHeight,
224
+ disableColor,
190
225
  translate: __
191
226
  } = this.props;
192
227
 
@@ -195,25 +230,49 @@ export class Log extends React.Component<LogProps, LogState> {
195
230
  if (!source) {
196
231
  loading = __('Log.mustHaveSource');
197
232
  }
233
+ let lines: any;
198
234
 
199
- const lines = this.state.logs.map((line, index) => {
200
- return (
201
- <div className={cx('Log-line')} key={index}>
202
- <Ansi useClasses>{line}</Ansi>
203
- </div>
235
+ const logs = this.state.lastLine
236
+ ? this.state.logs.concat([this.state.lastLine])
237
+ : this.state.logs;
238
+
239
+ // 如果设置 rowHeight 就开启延迟渲染
240
+ const useVirtualRender = rowHeight;
241
+
242
+ if (useVirtualRender) {
243
+ lines = (
244
+ <VirtualList
245
+ height={height as number}
246
+ itemCount={logs.length}
247
+ itemSize={rowHeight}
248
+ renderItem={({index, style}) => (
249
+ <div
250
+ className={cx('Log-line')}
251
+ key={index}
252
+ style={{...style, whiteSpace: 'nowrap'}}
253
+ >
254
+ {disableColor ? (
255
+ logs[index]
256
+ ) : (
257
+ <Ansi useClasses>{logs[index]}</Ansi>
258
+ )}
259
+ </div>
260
+ )}
261
+ />
204
262
  );
205
- });
263
+ } else {
264
+ lines = logs.map((line, index) => {
265
+ return this.renderLine(index, line);
266
+ });
267
+ }
206
268
 
207
269
  return (
208
270
  <div
209
271
  ref={this.logRef}
210
272
  className={cx('Log', className)}
211
- style={{height: height}}
273
+ style={{height: useVirtualRender ? 'auto' : height}}
212
274
  >
213
- {lines.length ? lines : loading}
214
- <div className={cx('Log-line')} key="last">
215
- <code>{this.state.lastLine}</code>
216
- </div>
275
+ {useVirtualRender ? lines : lines.length ? lines : loading}
217
276
  </div>
218
277
  );
219
278
  }