amis 1.4.0 → 1.4.1-echarts-5.3.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 (87) hide show
  1. package/lib/components/Badge.d.ts +2 -1
  2. package/lib/components/Badge.js +33 -4
  3. package/lib/components/Badge.js.map +2 -2
  4. package/lib/components/Button.d.ts +24 -22
  5. package/lib/components/Button.js +13 -7
  6. package/lib/components/Button.js.map +2 -2
  7. package/lib/components/RichText.d.ts +6 -1
  8. package/lib/components/RichText.js +243 -8
  9. package/lib/components/RichText.js.map +2 -2
  10. package/lib/components/calendar/DaysView.js +2 -2
  11. package/lib/components/calendar/DaysView.js.map +2 -2
  12. package/lib/components/icons.js +2 -0
  13. package/lib/components/icons.js.map +2 -2
  14. package/lib/helper.css.map +1 -1
  15. package/lib/icons/loading-outline.js +7 -0
  16. package/lib/index.js +1 -1
  17. package/lib/renderers/Action.d.ts +9 -1
  18. package/lib/renderers/Action.js +5 -5
  19. package/lib/renderers/Action.js.map +2 -2
  20. package/lib/renderers/DropDownButton.d.ts +4 -0
  21. package/lib/renderers/DropDownButton.js +5 -3
  22. package/lib/renderers/DropDownButton.js.map +2 -2
  23. package/lib/renderers/Nav.d.ts +52 -22
  24. package/lib/renderers/Nav.js +100 -15
  25. package/lib/renderers/Nav.js.map +2 -2
  26. package/lib/renderers/Page.js +1 -1
  27. package/lib/renderers/Page.js.map +2 -2
  28. package/lib/themes/ang-ie11.css +350 -54
  29. package/lib/themes/ang.css +350 -54
  30. package/lib/themes/ang.css.map +1 -1
  31. package/lib/themes/antd-ie11.css +350 -54
  32. package/lib/themes/antd.css +350 -54
  33. package/lib/themes/antd.css.map +1 -1
  34. package/lib/themes/cxd-ie11.css +458 -174
  35. package/lib/themes/cxd.css +458 -174
  36. package/lib/themes/cxd.css.map +1 -1
  37. package/lib/themes/dark-ie11.css +350 -54
  38. package/lib/themes/dark.css +350 -54
  39. package/lib/themes/dark.css.map +1 -1
  40. package/lib/themes/default.css +458 -174
  41. package/lib/themes/default.css.map +1 -1
  42. package/lib/utils/helper.js.map +2 -2
  43. package/package.json +46 -39
  44. package/schema.json +200 -15
  45. package/scss/_mixins.scss +29 -0
  46. package/scss/_properties.scss +23 -11
  47. package/scss/components/_badge.scss +52 -1
  48. package/scss/components/_button.scss +35 -3
  49. package/scss/components/_image-gallery.scss +1 -1
  50. package/scss/components/_nav.scss +109 -35
  51. package/scss/themes/_cxd-variables.scss +20 -20
  52. package/sdk/ang-ie11.css +449 -56
  53. package/sdk/ang.css +459 -56
  54. package/sdk/antd-ie11.css +439 -48
  55. package/sdk/antd.css +459 -56
  56. package/sdk/charts.js +13 -13
  57. package/sdk/color-picker.js +69 -65
  58. package/sdk/cropperjs.js +2 -2
  59. package/sdk/cxd-ie11.css +908 -517
  60. package/sdk/cxd.css +567 -176
  61. package/sdk/dark-ie11.css +449 -56
  62. package/sdk/dark.css +459 -56
  63. package/sdk/exceljs.js +1 -1
  64. package/sdk/helper.css.map +1 -1
  65. package/sdk/markdown.js +69 -69
  66. package/sdk/papaparse.js +1 -1
  67. package/sdk/renderers/Form/CityDB.js +1 -1
  68. package/sdk/rest.js +22 -28
  69. package/sdk/rich-text.js +62 -64
  70. package/sdk/sdk-ie11.css +908 -517
  71. package/sdk/sdk.css +567 -176
  72. package/sdk/sdk.js +1145 -1141
  73. package/sdk/thirds/hls.js/hls.js +1 -1
  74. package/sdk/thirds/mpegts.js/mpegts.js +1 -1
  75. package/sdk/tinymce.js +57 -57
  76. package/sdk.zip +0 -0
  77. package/src/components/Badge.tsx +78 -22
  78. package/src/components/Button.tsx +23 -7
  79. package/src/components/RichText.tsx +284 -3
  80. package/src/components/calendar/DaysView.tsx +2 -2
  81. package/src/components/icons.tsx +2 -0
  82. package/src/icons/loading-outline.svg +4 -0
  83. package/src/renderers/Action.tsx +66 -13
  84. package/src/renderers/DropDownButton.tsx +13 -4
  85. package/src/renderers/Nav.tsx +165 -36
  86. package/src/renderers/Page.tsx +1 -1
  87. package/src/utils/helper.ts +1 -0
@@ -35,6 +35,10 @@ export interface ButtonSchema extends BaseSchema {
35
35
  * 右侧 icon 上的 css 类名
36
36
  */
37
37
  rightIconClassName?: SchemaClassName;
38
+ /**
39
+ * loading 上的css 类名
40
+ */
41
+ loadingClassName?: SchemaClassName;
38
42
 
39
43
  /**
40
44
  * 按钮文字
@@ -131,6 +135,10 @@ export interface ButtonSchema extends BaseSchema {
131
135
  * 键盘快捷键
132
136
  */
133
137
  hotKey?: string;
138
+ /**
139
+ * 是否显示loading效果
140
+ */
141
+ loadingOn?: string;
134
142
  }
135
143
 
136
144
  export interface AjaxActionSchema extends ButtonSchema {
@@ -416,44 +424,80 @@ export const createSyntheticEvent = <T extends Element, E extends Event>(
416
424
  export interface ActionProps
417
425
  extends Omit<
418
426
  ButtonSchema,
419
- 'className' | 'iconClassName' | 'rightIconClassName'
427
+ 'className' | 'iconClassName' | 'rightIconClassName' | 'loadingClassName'
420
428
  >,
421
429
  ThemeProps,
422
430
  Omit<
423
431
  AjaxActionSchema,
424
- 'type' | 'className' | 'iconClassName' | 'rightIconClassName'
432
+ | 'type'
433
+ | 'className'
434
+ | 'iconClassName'
435
+ | 'rightIconClassName'
436
+ | 'loadingClassName'
425
437
  >,
426
438
  Omit<
427
439
  UrlActionSchema,
428
- 'type' | 'className' | 'iconClassName' | 'rightIconClassName'
440
+ | 'type'
441
+ | 'className'
442
+ | 'iconClassName'
443
+ | 'rightIconClassName'
444
+ | 'loadingClassName'
429
445
  >,
430
446
  Omit<
431
447
  LinkActionSchema,
432
- 'type' | 'className' | 'iconClassName' | 'rightIconClassName'
448
+ | 'type'
449
+ | 'className'
450
+ | 'iconClassName'
451
+ | 'rightIconClassName'
452
+ | 'loadingClassName'
433
453
  >,
434
454
  Omit<
435
455
  DialogActionSchema,
436
- 'type' | 'className' | 'iconClassName' | 'rightIconClassName'
456
+ | 'type'
457
+ | 'className'
458
+ | 'iconClassName'
459
+ | 'rightIconClassName'
460
+ | 'loadingClassName'
437
461
  >,
438
462
  Omit<
439
463
  DrawerActionSchema,
440
- 'type' | 'className' | 'iconClassName' | 'rightIconClassName'
464
+ | 'type'
465
+ | 'className'
466
+ | 'iconClassName'
467
+ | 'rightIconClassName'
468
+ | 'loadingClassName'
441
469
  >,
442
470
  Omit<
443
471
  CopyActionSchema,
444
- 'type' | 'className' | 'iconClassName' | 'rightIconClassName'
472
+ | 'type'
473
+ | 'className'
474
+ | 'iconClassName'
475
+ | 'rightIconClassName'
476
+ | 'loadingClassName'
445
477
  >,
446
478
  Omit<
447
479
  ReloadActionSchema,
448
- 'type' | 'className' | 'iconClassName' | 'rightIconClassName'
480
+ | 'type'
481
+ | 'className'
482
+ | 'iconClassName'
483
+ | 'rightIconClassName'
484
+ | 'loadingClassName'
449
485
  >,
450
486
  Omit<
451
487
  EmailActionSchema,
452
- 'type' | 'className' | 'iconClassName' | 'rightIconClassName'
488
+ | 'type'
489
+ | 'className'
490
+ | 'iconClassName'
491
+ | 'rightIconClassName'
492
+ | 'loadingClassName'
453
493
  >,
454
494
  Omit<
455
495
  OtherActionSchema,
456
- 'type' | 'className' | 'iconClassName' | 'rightIconClassName'
496
+ | 'type'
497
+ | 'className'
498
+ | 'iconClassName'
499
+ | 'rightIconClassName'
500
+ | 'loadingClassName'
457
501
  > {
458
502
  actionType: any;
459
503
  onAction?: (
@@ -619,6 +663,7 @@ export class Action extends React.Component<ActionProps, ActionState> {
619
663
  iconClassName,
620
664
  rightIcon,
621
665
  rightIconClassName,
666
+ loadingClassName,
622
667
  primary,
623
668
  size,
624
669
  level,
@@ -638,7 +683,10 @@ export class Action extends React.Component<ActionProps, ActionState> {
638
683
  isMenuItem,
639
684
  active,
640
685
  activeLevel,
686
+ tooltipTrigger,
641
687
  tooltipContainer,
688
+ tooltipRootClose,
689
+ loading,
642
690
  classnames: cx
643
691
  } = this.props;
644
692
 
@@ -678,6 +726,8 @@ export class Action extends React.Component<ActionProps, ActionState> {
678
726
  ? activeLevel
679
727
  : level || (primary ? 'primary' : undefined)
680
728
  }
729
+ loadingClassName={loadingClassName}
730
+ loading={loading}
681
731
  onClick={this.handleAction}
682
732
  type={type && ~allowedType.indexOf(type) ? type : 'button'}
683
733
  disabled={disabled}
@@ -685,12 +735,14 @@ export class Action extends React.Component<ActionProps, ActionState> {
685
735
  overrideClassName={isMenuItem}
686
736
  tooltip={filterContents(tooltip, data)}
687
737
  disabledTip={filterContents(disabledTip, data)}
688
- placement={tooltipPlacement}
738
+ tooltipPlacement={tooltipPlacement}
689
739
  tooltipContainer={tooltipContainer}
740
+ tooltipTrigger={tooltipTrigger}
741
+ tooltipRootClose={tooltipRootClose}
690
742
  block={block}
691
743
  iconOnly={!!(icon && !label && level !== 'link')}
692
744
  >
693
- {iconElement}
745
+ {!loading ? iconElement : ''}
694
746
  {label ? <span>{filter(String(label), data)}</span> : null}
695
747
  {rightIconElement}
696
748
  </Button>
@@ -736,13 +788,14 @@ export class ActionRenderer extends React.Component<
736
788
  }
737
789
 
738
790
  render() {
739
- const {env, disabled, btnDisabled, ...rest} = this.props;
791
+ const {env, disabled, btnDisabled, loading, ...rest} = this.props;
740
792
 
741
793
  return (
742
794
  <Action
743
795
  {...(rest as any)}
744
796
  disabled={disabled || btnDisabled}
745
797
  onAction={this.handleAction}
798
+ loading={loading}
746
799
  isCurrentUrl={this.isCurrentAction}
747
800
  tooltipContainer={
748
801
  env.getModalContainer ? env.getModalContainer : undefined
@@ -81,6 +81,10 @@ export interface DropdownButtonSchema extends BaseSchema {
81
81
  * 触发条件,默认是 click
82
82
  */
83
83
  trigger?: 'click' | 'hover';
84
+ /**
85
+ * 是否显示下拉按钮
86
+ */
87
+ hideCaret?: boolean;
84
88
  }
85
89
 
86
90
  export interface DropDownButtonProps
@@ -272,7 +276,8 @@ export default class DropDownButton extends React.Component<
272
276
  icon,
273
277
  isActived,
274
278
  trigger,
275
- data
279
+ data,
280
+ hideCaret
276
281
  } = this.props;
277
282
 
278
283
  return (
@@ -325,9 +330,13 @@ export default class DropDownButton extends React.Component<
325
330
  )
326
331
  ) : null}
327
332
  {typeof label === 'string' ? filter(label, data) : label}
328
- <span className={cx('DropDown-caret')}>
329
- <Icon icon="caret" className="icon" />
330
- </span>
333
+ {
334
+ !hideCaret
335
+ ? <span className={cx('DropDown-caret')} >
336
+ <Icon icon="caret" className="icon" />
337
+ </span>
338
+ : null
339
+ }
331
340
  </button>
332
341
  </TooltipWrapper>
333
342
  {this.state.isOpened ? this.renderOuter() : null}
@@ -1,8 +1,10 @@
1
1
  import React from 'react';
2
+ import Sortable from 'sortablejs';
2
3
  import {Renderer, RendererEnv, RendererProps} from '../factory';
3
4
  import getExprProperties from '../utils/filter-schema';
4
5
  import {filter, evalExpression} from '../utils/tpl';
5
6
  import {
7
+ guid,
6
8
  autobind,
7
9
  createObject,
8
10
  findTree,
@@ -22,6 +24,9 @@ import {
22
24
  } from '../components/WithRemoteConfig';
23
25
  import {Payload} from '../types';
24
26
  import Spinner from '../components/Spinner';
27
+ import cloneDeep from 'lodash/cloneDeep';
28
+ import {isEffectiveApi} from '../utils/api';
29
+ import {Badge, BadgeSchema} from '../components/Badge';
25
30
 
26
31
  export type NavItemSchema = {
27
32
  /**
@@ -45,6 +50,11 @@ export type NavItemSchema = {
45
50
  deferApi?: SchemaApi;
46
51
 
47
52
  children?: Array<NavItemSchema>;
53
+
54
+ /**
55
+ * 角标
56
+ */
57
+ badge?: BadgeSchema
48
58
  } & Omit<BaseSchema, 'type'>;
49
59
 
50
60
  /**
@@ -81,6 +91,26 @@ export interface NavSchema extends BaseSchema {
81
91
  * true 为垂直排列,false 为水平排列类似如 tabs。
82
92
  */
83
93
  stacked?: boolean;
94
+
95
+ /**
96
+ * 更多操作菜单列表
97
+ */
98
+ itemActions?: SchemaCollection;
99
+
100
+ /**
101
+ * 可拖拽
102
+ */
103
+ draggable?: boolean;
104
+
105
+ /**
106
+ * 保存排序的 api
107
+ */
108
+ saveOrderApi?: SchemaApi;
109
+
110
+ /**
111
+ * 角标
112
+ */
113
+ badge?: BadgeSchema;
84
114
  }
85
115
 
86
116
  export interface Link {
@@ -97,6 +127,7 @@ export interface Link {
97
127
  loading?: boolean;
98
128
  loaded?: boolean;
99
129
  [propName: string]: any;
130
+ badge?: BadgeSchema
100
131
  }
101
132
  export interface Links extends Array<Link> {}
102
133
 
@@ -113,7 +144,9 @@ export interface NavigationProps
113
144
  togglerClassName?: string;
114
145
  links?: Array<Link>;
115
146
  loading?: boolean;
116
- render: RendererProps['render']
147
+ render: RendererProps['render'];
148
+ env: RendererEnv;
149
+ reload?: any;
117
150
  }
118
151
 
119
152
  export class Navigation extends React.Component<
@@ -123,6 +156,9 @@ export class Navigation extends React.Component<
123
156
  static defaultProps = {
124
157
  indentSize: 24
125
158
  };
159
+ sortable: Sortable[] = [];
160
+ id: string;
161
+ dragRef?: HTMLElement;
126
162
 
127
163
  @autobind
128
164
  handleClick(link: Link) {
@@ -134,15 +170,85 @@ export class Navigation extends React.Component<
134
170
  this.props.onToggle?.(target);
135
171
  }
136
172
 
173
+ @autobind
174
+ dragRefFn(ref: any) {
175
+ const {draggable} = this.props;
176
+ if (ref && draggable) {
177
+ this.id = guid();
178
+ this.initDragging(ref);
179
+ }
180
+ }
181
+
182
+ initDragging(ref: HTMLElement) {
183
+ const ns = this.props.classPrefix;
184
+ this.sortable.push(new Sortable(
185
+ ref,
186
+ {
187
+ group: `nav-${this.id}`,
188
+ animation: 150,
189
+ handle: `.${ns}Nav-itemDrager`,
190
+ ghostClass: `${ns}Nav-item--dragging`,
191
+ onEnd: async (e: any) => {
192
+ // 没有移动
193
+ if (e.newIndex === e.oldIndex) {
194
+ return;
195
+ }
196
+ const id = e.item.getAttribute('data-id');
197
+ const parentNode = e.to
198
+ if (
199
+ e.newIndex < e.oldIndex &&
200
+ e.oldIndex < parentNode.childNodes.length - 1
201
+ ) {
202
+ parentNode.insertBefore(e.item, parentNode.childNodes[e.oldIndex + 1]);
203
+ } else if (e.oldIndex < parentNode.childNodes.length - 1) {
204
+ parentNode.insertBefore(e.item, parentNode.childNodes[e.oldIndex]);
205
+ } else {
206
+ parentNode.appendChild(e.item);
207
+ }
208
+ const links = cloneDeep(this.props.links) as Link[];
209
+ let parent = links;
210
+ someTree(links, (item: Link, key, level, paths: Link[]) => {
211
+ if (item.id === id) {
212
+ const len = paths.length - 1;
213
+ parent = (~len ? paths[len].children : links) as Link[];
214
+ return true;
215
+ }
216
+ return false;
217
+ });
218
+ parent.splice(e.newIndex, 0, parent.splice(e.oldIndex, 1)[0]);
219
+ const {saveOrderApi, env} = this.props;
220
+ if (saveOrderApi && isEffectiveApi(saveOrderApi)) {
221
+ await env.fetcher(saveOrderApi as SchemaApi, {data: links}, {method: 'post'});
222
+ this.props.reload();
223
+ } else {
224
+ console.warn('请配置saveOrderApi');
225
+ }
226
+ }
227
+ }
228
+ ));
229
+ }
230
+
137
231
  renderItem(link: Link, index: number, depth = 1) {
138
232
  if (link.hidden === true || link.visible === false) {
139
233
  return null;
140
234
  }
141
235
  const isActive: boolean = !!link.active;
142
- const {disabled, togglerClassName, classnames: cx, indentSize} = this.props;
236
+ const {
237
+ disabled,
238
+ togglerClassName,
239
+ classnames: cx,
240
+ indentSize,
241
+ render,
242
+ itemActions,
243
+ draggable,
244
+ links,
245
+ badge: defaultBadge
246
+ } = this.props;
143
247
  const hasSub =
144
248
  (link.defer && !link.loaded) || (link.children && link.children.length);
145
-
249
+ const id = guid();
250
+ link.id = id;
251
+ const badge = defaultBadge ? Object.assign(defaultBadge, link.badge) : link.badge;
146
252
  return (
147
253
  <li
148
254
  key={index}
@@ -152,42 +258,62 @@ export class Navigation extends React.Component<
152
258
  'is-unfolded': link.unfolded,
153
259
  'has-sub': hasSub
154
260
  })}
261
+ data-id={id}
155
262
  >
156
- <a
157
- onClick={this.handleClick.bind(this, link)}
158
- style={{paddingLeft: depth * (parseInt(indentSize as any, 10) ?? 24)}}
159
- >
160
- {generateIcon(cx, link.icon, 'Nav-itemIcon')}
263
+ <Badge classnames={cx} badge={badge} data={link}>
264
+ <a
265
+ onClick={this.handleClick.bind(this, link)}
266
+ style={{paddingLeft: depth * (parseInt(indentSize as any, 10) ?? 24)}}
267
+ >
268
+ {!disabled && draggable && links && links.length > 1 ? (
269
+ <div className={cx('Nav-itemDrager')} >
270
+ <a
271
+ key="drag"
272
+ data-position="bottom"
273
+ >
274
+ <Icon icon="drag-bar" className="icon" />
275
+ </a>
276
+ </div>
277
+ ) : null}
278
+ {link.loading ? (
279
+ <Spinner
280
+ size="sm"
281
+ show
282
+ icon="reload"
283
+ spinnerClassName={cx('Nav-spinner')}
284
+ />
285
+ ) : hasSub ? (
286
+ <span
287
+ onClick={() => this.toggleLink(link)}
288
+ className={cx('Nav-itemToggler', togglerClassName)}
289
+ >
290
+ <Icon icon="caret" className="icon" />
291
+ </span>
292
+ ) : null}
293
+ {generateIcon(cx, link.icon, 'Nav-itemIcon')}
294
+ {
295
+ link.label && (typeof link.label === 'string'
296
+ ? link.label
297
+ : render('inline', link.label as SchemaCollection))
298
+ }
299
+ </a>
161
300
  {
162
- link.label && (typeof link.label === 'string'
163
- ? link.label
164
- : this.props.render('inline', link.label as SchemaCollection))
301
+ // 更多操作
302
+ itemActions
303
+ ? <div className={cx('Nav-item-atcions')}>
304
+ {
305
+ render('inline', itemActions, {data: link})
306
+ }
307
+ </div> : null
165
308
  }
166
- </a>
167
-
168
- {link.loading ? (
169
- <Spinner
170
- size="sm"
171
- show
172
- icon="reload"
173
- spinnerClassName={cx('Nav-spinner')}
174
- />
175
- ) : hasSub ? (
176
- <span
177
- onClick={() => this.toggleLink(link)}
178
- className={cx('Nav-itemToggler', togglerClassName)}
179
- >
180
- <Icon icon="caret" className="icon" />
181
- </span>
182
- ) : null}
183
-
184
- {Array.isArray(link.children) && link.children.length ? (
185
- <ul className={cx('Nav-subItems')}>
186
- {link.children.map((link, index) =>
187
- this.renderItem(link, index, depth + 1)
188
- )}
189
- </ul>
190
- ) : null}
309
+ {Array.isArray(link.children) && link.children.length ? (
310
+ <ul className={cx('Nav-subItems')} ref={this.dragRefFn}>
311
+ {link.children.map((link, index) =>
312
+ this.renderItem(link, index, depth + 1)
313
+ )}
314
+ </ul>
315
+ ) : null}
316
+ </Badge>
191
317
  </li>
192
318
  );
193
319
  }
@@ -198,6 +324,7 @@ export class Navigation extends React.Component<
198
324
  return (
199
325
  <ul
200
326
  className={cx('Nav', className, stacked ? 'Nav--stacked' : 'Nav--tabs')}
327
+ ref={this.dragRefFn}
201
328
  >
202
329
  {Array.isArray(links)
203
330
  ? links.map((item, index) => this.renderItem(item, index))
@@ -310,6 +437,7 @@ const ConditionBuilderWithRemoteOptions = withRemoteConfig({
310
437
  data?: any;
311
438
  unfoldedField?: string;
312
439
  foldedField?: string;
440
+ reload?: any;
313
441
  }
314
442
  > {
315
443
  constructor(props: any) {
@@ -442,6 +570,7 @@ export class NavigationRenderer extends React.Component<RendererProps> {
442
570
  return (
443
571
  <ConditionBuilderWithRemoteOptions
444
572
  {...rest}
573
+ reload={this.reload}
445
574
  remoteConfigRef={this.remoteConfigRef}
446
575
  />
447
576
  );
@@ -665,7 +665,7 @@ export default class Page extends React.Component<PageProps> {
665
665
  onAction: this.handleAction,
666
666
  onQuery: initApi ? this.handleQuery : undefined,
667
667
  onChange: this.handleChange,
668
- loading: store.loading
668
+ pageLoading: store.loading
669
669
  };
670
670
 
671
671
  const hasAside = Array.isArray(regions)
@@ -507,6 +507,7 @@ export function isDisabled(
507
507
  );
508
508
  }
509
509
 
510
+
510
511
  export function hasAbility(
511
512
  schema: any,
512
513
  ability: string,