amis 1.2.4-beta.10 → 1.2.4-beta.11

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 (99) hide show
  1. package/lib/components/Radios.d.ts +21 -21
  2. package/lib/components/Select.d.ts +239 -238
  3. package/lib/components/Select.js +6 -2
  4. package/lib/components/Select.js.map +2 -2
  5. package/lib/components/Tree.d.ts +352 -84
  6. package/lib/components/Tree.js +71 -12
  7. package/lib/components/Tree.js.map +2 -2
  8. package/lib/components/icons.js +3 -0
  9. package/lib/components/icons.js.map +2 -2
  10. package/lib/helper.css.map +1 -1
  11. package/lib/index.js +1 -1
  12. package/lib/locale/de-DE.js +2 -0
  13. package/lib/locale/de-DE.js.map +2 -2
  14. package/lib/locale/en-US.js +2 -0
  15. package/lib/locale/en-US.js.map +2 -2
  16. package/lib/locale/zh-CN.js +2 -0
  17. package/lib/locale/zh-CN.js.map +2 -2
  18. package/lib/renderers/Form/DiffEditor.d.ts +108 -90
  19. package/lib/renderers/Form/Editor.d.ts +108 -90
  20. package/lib/renderers/Form/InputImage.d.ts +1 -1
  21. package/lib/renderers/Form/InputImage.js +6 -5
  22. package/lib/renderers/Form/InputImage.js.map +2 -2
  23. package/lib/renderers/Form/InputTree.d.ts +14 -0
  24. package/lib/renderers/Form/InputTree.js +5 -3
  25. package/lib/renderers/Form/InputTree.js.map +2 -2
  26. package/lib/renderers/Form/NestedSelect.d.ts +6 -1
  27. package/lib/renderers/Form/NestedSelect.js +7 -3
  28. package/lib/renderers/Form/NestedSelect.js.map +2 -2
  29. package/lib/renderers/Form/Options.d.ts +1 -0
  30. package/lib/renderers/Form/Options.js +21 -3
  31. package/lib/renderers/Form/Options.js.map +2 -2
  32. package/lib/renderers/Form/TreeSelect.d.ts +19 -1
  33. package/lib/renderers/Form/TreeSelect.js +10 -4
  34. package/lib/renderers/Form/TreeSelect.js.map +2 -2
  35. package/lib/renderers/Table/index.js +24 -16
  36. package/lib/renderers/Table/index.js.map +2 -2
  37. package/lib/store/app.js +4 -7
  38. package/lib/store/app.js.map +2 -2
  39. package/lib/store/combo.d.ts +120 -100
  40. package/lib/store/form.d.ts +48 -40
  41. package/lib/store/formItem.d.ts +2 -1
  42. package/lib/store/formItem.js +83 -6
  43. package/lib/store/formItem.js.map +2 -2
  44. package/lib/store/table.d.ts +96 -80
  45. package/lib/themes/ang.css.map +1 -1
  46. package/lib/themes/antd.css.map +1 -1
  47. package/lib/themes/cxd-ie11.css +8 -2
  48. package/lib/themes/cxd.css +8 -2
  49. package/lib/themes/cxd.css.map +1 -1
  50. package/lib/themes/dark.css.map +1 -1
  51. package/lib/themes/default.css +8 -2
  52. package/lib/themes/default.css.map +1 -1
  53. package/lib/utils/helper.d.ts +15 -0
  54. package/lib/utils/helper.js +58 -4
  55. package/lib/utils/helper.js.map +2 -2
  56. package/lib/utils/markdown.js +3 -0
  57. package/lib/utils/markdown.js.map +2 -2
  58. package/package.json +5 -4
  59. package/schema.json +49 -21
  60. package/scss/_functions.scss +3 -1
  61. package/scss/components/_images.scss +4 -2
  62. package/scss/components/form/_form.scss +3 -2
  63. package/scss/components/form/_group.scss +4 -2
  64. package/scss/layout/_grid.scss +12 -10
  65. package/scss/themes/_cxd-variables.scss +8 -2
  66. package/sdk/charts.js +13 -13
  67. package/sdk/color-picker.js +67 -67
  68. package/sdk/cropperjs.js +2 -2
  69. package/sdk/cxd-ie11.css +8 -8
  70. package/sdk/cxd.css +8 -2
  71. package/sdk/exceljs.js +1 -1
  72. package/sdk/helper.css.map +1 -0
  73. package/sdk/markdown.js +70 -68
  74. package/sdk/papaparse.js +1 -1
  75. package/sdk/renderers/Form/CityDB.js +1 -1
  76. package/sdk/rest.js +19 -19
  77. package/sdk/rich-text.js +68 -68
  78. package/sdk/sdk-ie11.css +8 -8
  79. package/sdk/sdk.css +8 -2
  80. package/sdk/sdk.js +1132 -1130
  81. package/sdk/thirds/hls.js/hls.js +1 -1
  82. package/sdk/thirds/mpegts.js/mpegts.js +2 -2
  83. package/sdk/tinymce.js +59 -59
  84. package/src/components/Select.tsx +30 -5
  85. package/src/components/Tree.tsx +115 -20
  86. package/src/components/icons.tsx +4 -0
  87. package/src/locale/de-DE.ts +2 -0
  88. package/src/locale/en-US.ts +2 -0
  89. package/src/locale/zh-CN.ts +2 -0
  90. package/src/renderers/Form/InputImage.tsx +12 -6
  91. package/src/renderers/Form/InputTree.tsx +30 -2
  92. package/src/renderers/Form/NestedSelect.tsx +15 -3
  93. package/src/renderers/Form/Options.tsx +46 -4
  94. package/src/renderers/Form/TreeSelect.tsx +36 -3
  95. package/src/renderers/Table/index.tsx +48 -44
  96. package/src/store/app.ts +4 -7
  97. package/src/store/formItem.ts +107 -3
  98. package/src/utils/helper.ts +68 -7
  99. package/src/utils/markdown.ts +4 -0
package/src/store/app.ts CHANGED
@@ -45,12 +45,8 @@ export const AppStore = ServiceStore.named('AppStore')
45
45
 
46
46
  return [
47
47
  {
48
- label: '导航',
49
- children: [
50
- {
51
- label: '暂无页面'
52
- }
53
- ]
48
+ label: self.__('App.navigation'),
49
+ children: []
54
50
  }
55
51
  ];
56
52
  },
@@ -148,9 +144,10 @@ export const AppStore = ServiceStore.named('AppStore')
148
144
  ...item,
149
145
  path: ''
150
146
  });
147
+ self.__;
151
148
  if (bcn[0].path !== '/') {
152
149
  bcn.unshift({
153
- label: '首页',
150
+ label: self.__('App.home'),
154
151
  path: '/'
155
152
  });
156
153
  }
@@ -150,17 +150,21 @@ export const FormItemStore = StoreNode.named('FormItemStore')
150
150
  return getLastOptionValue();
151
151
  },
152
152
 
153
- getSelectedOptions: (value: any = self.tmpValue) => {
153
+ getSelectedOptions: (
154
+ value: any = self.tmpValue,
155
+ nodeValueArray?: any[] | undefined
156
+ ) => {
154
157
  if (typeof value === 'undefined') {
155
158
  return [];
156
159
  }
157
160
 
158
- const valueArray = Array.isArray(value)
161
+ const valueArray = nodeValueArray
162
+ ? nodeValueArray
163
+ : Array.isArray(value)
159
164
  ? value
160
165
  : typeof value === 'string'
161
166
  ? value.split(self.delimiter || ',')
162
167
  : [value];
163
-
164
168
  const selected = valueArray.map(item =>
165
169
  item && item.hasOwnProperty(self.valueField || 'value')
166
170
  ? item[self.valueField || 'value']
@@ -681,6 +685,105 @@ export const FormItemStore = StoreNode.named('FormItemStore')
681
685
  return json;
682
686
  });
683
687
 
688
+ /**
689
+ * 根据当前节点路径展开树形组件父节点
690
+ */
691
+ const expandTreeOptions: (
692
+ nodePathArr: any[],
693
+ api: Api,
694
+ data?: object,
695
+ config?: fetchOptions
696
+ ) => Promise<Payload | null | void> = flow(function* getInitData(
697
+ nodePathArr: any[],
698
+ api: string,
699
+ data: object,
700
+ config?: fetchOptions
701
+ ) {
702
+ // 多选模式下需要记录遍历过的Node,避免发送相同的请求
703
+ const traversedNode = new Map();
704
+
705
+ for (let nodePath of nodePathArr) {
706
+ // 根节点已经展开了,不需要加载
707
+ if (nodePath.length <= 1) {
708
+ continue;
709
+ }
710
+
711
+ // 叶节点不需要展开
712
+ for (let level = 0; level < nodePath.length - 1; level++) {
713
+ let tree = self.options.concat();
714
+ let nodeValue = nodePath[level];
715
+
716
+ if (traversedNode.has(nodeValue)) {
717
+ continue;
718
+ }
719
+ // 节点value认为是唯一的
720
+ let node = findTree(tree, (item, key, treeLevel: number) => {
721
+ return (
722
+ treeLevel === level + 1 &&
723
+ optionValueCompare(nodeValue, self.valueField || 'value')(item)
724
+ );
725
+ });
726
+
727
+ // 只处理懒加载节点
728
+ if (!node || !node.defer) {
729
+ continue;
730
+ }
731
+ const indexes = findTreeIndex(
732
+ tree,
733
+ item => item === node
734
+ ) as number[];
735
+
736
+ setOptions(
737
+ spliceTree(tree, indexes, 1, {
738
+ ...node,
739
+ loading: true
740
+ }),
741
+ undefined,
742
+ node
743
+ );
744
+
745
+ let json = yield fetchOptions(
746
+ api,
747
+ node,
748
+ {...config, silent: true},
749
+ false
750
+ );
751
+
752
+ if (!json) {
753
+ setOptions(
754
+ spliceTree(tree, indexes, 1, {
755
+ ...node,
756
+ loading: false,
757
+ error: true
758
+ }),
759
+ undefined,
760
+ node
761
+ );
762
+ }
763
+
764
+ traversedNode.set(nodeValue, true);
765
+
766
+ let childrenOptions: Array<IOption> =
767
+ json.data?.options ||
768
+ json.data.items ||
769
+ json.data.rows ||
770
+ json.data ||
771
+ [];
772
+
773
+ setOptions(
774
+ spliceTree(tree, indexes, 1, {
775
+ ...node,
776
+ loading: false,
777
+ loaded: true,
778
+ children: childrenOptions
779
+ }),
780
+ undefined,
781
+ node
782
+ );
783
+ }
784
+ }
785
+ });
786
+
684
787
  // @issue 强依赖form,需要改造暂且放过。
685
788
  function syncOptions(originOptions?: Array<any>, data?: Object) {
686
789
  if (!self.options.length && typeof self.value === 'undefined') {
@@ -896,6 +999,7 @@ export const FormItemStore = StoreNode.named('FormItemStore')
896
999
  setOptions,
897
1000
  loadOptions,
898
1001
  deferLoadOptions,
1002
+ expandTreeOptions,
899
1003
  syncOptions,
900
1004
  setLoading,
901
1005
  setSubStore,
@@ -2,6 +2,7 @@ import isPlainObject from 'lodash/isPlainObject';
2
2
  import isEqual from 'lodash/isEqual';
3
3
  import isNaN from 'lodash/isNaN';
4
4
  import uniq from 'lodash/uniq';
5
+ import last from 'lodash/last';
5
6
  import {Schema, PlainObject, FunctionPropertyNames} from '../types';
6
7
  import {evalExpression} from './tpl';
7
8
  import qs from 'qs';
@@ -270,10 +271,9 @@ export function anyChanged(
270
271
  to: {[propName: string]: any},
271
272
  strictMode: boolean = true
272
273
  ): boolean {
273
- return (typeof attrs === 'string'
274
- ? attrs.split(/\s*,\s*/)
275
- : attrs
276
- ).some(key => (strictMode ? from[key] !== to[key] : from[key] != to[key]));
274
+ return (typeof attrs === 'string' ? attrs.split(/\s*,\s*/) : attrs).some(
275
+ key => (strictMode ? from[key] !== to[key] : from[key] != to[key])
276
+ );
277
277
  }
278
278
 
279
279
  export function rmUndefined(obj: PlainObject) {
@@ -558,9 +558,7 @@ export function makeHorizontalDeeper(
558
558
 
559
559
  export function promisify<T extends Function>(
560
560
  fn: T
561
- ): (
562
- ...args: Array<any>
563
- ) => Promise<any> & {
561
+ ): (...args: Array<any>) => Promise<any> & {
564
562
  raw: T;
565
563
  } {
566
564
  let promisified = function () {
@@ -1621,3 +1619,66 @@ export function detectPropValueChanged<
1621
1619
  export function removeHTMLTag(str: string) {
1622
1620
  return str.replace(/<\/?[^>]+(>|$)/g, '');
1623
1621
  }
1622
+
1623
+ /**
1624
+ * 将路径格式的value转换成普通格式的value值
1625
+ *
1626
+ * @example
1627
+ *
1628
+ * 'a/b/c' => 'c';
1629
+ * {label: 'A/B/C', value: 'a/b/c'} => {label: 'C', value: 'c'};
1630
+ * 'a/b/c,a/d' => 'c,d';
1631
+ * ['a/b/c', 'a/d'] => ['c', 'd'];
1632
+ * [{label: 'A/B/C', value: 'a/b/c'},{label: 'A/D', value: 'a/d'}] => [{label: 'C', value: 'c'},{label: 'D', value: 'd'}]
1633
+ */
1634
+ export function normalizeNodePath(
1635
+ value: any,
1636
+ enableNodePath: boolean,
1637
+ labelField: string = 'label',
1638
+ valueField: string = 'value',
1639
+ pathSeparator: string = '/',
1640
+ delimiter: string = ','
1641
+ ) {
1642
+ const nodeValueArray: any[] = [];
1643
+ const nodePathArray: any[] = [];
1644
+ const getLastNodeFromPath = (path: any) =>
1645
+ last(path ? path.toString().split(pathSeparator) : []);
1646
+
1647
+ if (typeof value === 'undefined' || !enableNodePath) {
1648
+ return {nodeValueArray, nodePathArray};
1649
+ }
1650
+
1651
+ // 尾节点为当前options中value值
1652
+ if (Array.isArray(value)) {
1653
+ value.forEach(nodePath => {
1654
+ if (nodePath && nodePath.hasOwnProperty(valueField)) {
1655
+ nodeValueArray.push({
1656
+ ...nodePath,
1657
+ [labelField]: getLastNodeFromPath(nodePath[labelField]),
1658
+ [valueField]: getLastNodeFromPath(nodePath[valueField])
1659
+ });
1660
+ nodePathArray.push(nodePath[valueField]);
1661
+ } else {
1662
+ nodeValueArray.push(getLastNodeFromPath(nodePath));
1663
+ nodePathArray.push(nodePath);
1664
+ }
1665
+ });
1666
+ } else if (typeof value === 'string') {
1667
+ value
1668
+ .toString()
1669
+ .split(delimiter)
1670
+ .forEach(path => {
1671
+ nodeValueArray.push(getLastNodeFromPath(path));
1672
+ nodePathArray.push(path);
1673
+ });
1674
+ } else {
1675
+ nodeValueArray.push({
1676
+ ...value,
1677
+ [labelField]: getLastNodeFromPath(value[labelField]),
1678
+ [valueField || 'value']: getLastNodeFromPath(value[valueField])
1679
+ });
1680
+ nodePathArray.push(value[valueField]);
1681
+ }
1682
+
1683
+ return {nodeValueArray, nodePathArray};
1684
+ }
@@ -3,11 +3,15 @@
3
3
  */
4
4
 
5
5
  import markdownIt from 'markdown-it';
6
+ // @ts-ignore
7
+ import {html5Media} from 'markdown-it-html5-media';
6
8
 
7
9
  const markdown = markdownIt({
8
10
  linkify: true
9
11
  });
10
12
 
13
+ markdown.use(html5Media);
14
+
11
15
  export default function (content: string) {
12
16
  return markdown.render(content);
13
17
  }