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.
- package/lib/components/Radios.d.ts +21 -21
- package/lib/components/Select.d.ts +239 -238
- package/lib/components/Select.js +6 -2
- package/lib/components/Select.js.map +2 -2
- package/lib/components/Tree.d.ts +352 -84
- package/lib/components/Tree.js +71 -12
- package/lib/components/Tree.js.map +2 -2
- package/lib/components/icons.js +3 -0
- package/lib/components/icons.js.map +2 -2
- package/lib/helper.css.map +1 -1
- package/lib/index.js +1 -1
- package/lib/locale/de-DE.js +2 -0
- package/lib/locale/de-DE.js.map +2 -2
- package/lib/locale/en-US.js +2 -0
- package/lib/locale/en-US.js.map +2 -2
- package/lib/locale/zh-CN.js +2 -0
- package/lib/locale/zh-CN.js.map +2 -2
- package/lib/renderers/Form/DiffEditor.d.ts +108 -90
- package/lib/renderers/Form/Editor.d.ts +108 -90
- package/lib/renderers/Form/InputImage.d.ts +1 -1
- package/lib/renderers/Form/InputImage.js +6 -5
- package/lib/renderers/Form/InputImage.js.map +2 -2
- package/lib/renderers/Form/InputTree.d.ts +14 -0
- package/lib/renderers/Form/InputTree.js +5 -3
- package/lib/renderers/Form/InputTree.js.map +2 -2
- package/lib/renderers/Form/NestedSelect.d.ts +6 -1
- package/lib/renderers/Form/NestedSelect.js +7 -3
- package/lib/renderers/Form/NestedSelect.js.map +2 -2
- package/lib/renderers/Form/Options.d.ts +1 -0
- package/lib/renderers/Form/Options.js +21 -3
- package/lib/renderers/Form/Options.js.map +2 -2
- package/lib/renderers/Form/TreeSelect.d.ts +19 -1
- package/lib/renderers/Form/TreeSelect.js +10 -4
- package/lib/renderers/Form/TreeSelect.js.map +2 -2
- package/lib/renderers/Table/index.js +24 -16
- package/lib/renderers/Table/index.js.map +2 -2
- package/lib/store/app.js +4 -7
- package/lib/store/app.js.map +2 -2
- package/lib/store/combo.d.ts +120 -100
- package/lib/store/form.d.ts +48 -40
- package/lib/store/formItem.d.ts +2 -1
- package/lib/store/formItem.js +83 -6
- package/lib/store/formItem.js.map +2 -2
- package/lib/store/table.d.ts +96 -80
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +8 -2
- package/lib/themes/cxd.css +8 -2
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default.css +8 -2
- package/lib/themes/default.css.map +1 -1
- package/lib/utils/helper.d.ts +15 -0
- package/lib/utils/helper.js +58 -4
- package/lib/utils/helper.js.map +2 -2
- package/lib/utils/markdown.js +3 -0
- package/lib/utils/markdown.js.map +2 -2
- package/package.json +5 -4
- package/schema.json +49 -21
- package/scss/_functions.scss +3 -1
- package/scss/components/_images.scss +4 -2
- package/scss/components/form/_form.scss +3 -2
- package/scss/components/form/_group.scss +4 -2
- package/scss/layout/_grid.scss +12 -10
- package/scss/themes/_cxd-variables.scss +8 -2
- package/sdk/charts.js +13 -13
- package/sdk/color-picker.js +67 -67
- package/sdk/cropperjs.js +2 -2
- package/sdk/cxd-ie11.css +8 -8
- package/sdk/cxd.css +8 -2
- package/sdk/exceljs.js +1 -1
- package/sdk/helper.css.map +1 -0
- package/sdk/markdown.js +70 -68
- package/sdk/papaparse.js +1 -1
- package/sdk/renderers/Form/CityDB.js +1 -1
- package/sdk/rest.js +19 -19
- package/sdk/rich-text.js +68 -68
- package/sdk/sdk-ie11.css +8 -8
- package/sdk/sdk.css +8 -2
- package/sdk/sdk.js +1132 -1130
- package/sdk/thirds/hls.js/hls.js +1 -1
- package/sdk/thirds/mpegts.js/mpegts.js +2 -2
- package/sdk/tinymce.js +59 -59
- package/src/components/Select.tsx +30 -5
- package/src/components/Tree.tsx +115 -20
- package/src/components/icons.tsx +4 -0
- package/src/locale/de-DE.ts +2 -0
- package/src/locale/en-US.ts +2 -0
- package/src/locale/zh-CN.ts +2 -0
- package/src/renderers/Form/InputImage.tsx +12 -6
- package/src/renderers/Form/InputTree.tsx +30 -2
- package/src/renderers/Form/NestedSelect.tsx +15 -3
- package/src/renderers/Form/Options.tsx +46 -4
- package/src/renderers/Form/TreeSelect.tsx +36 -3
- package/src/renderers/Table/index.tsx +48 -44
- package/src/store/app.ts +4 -7
- package/src/store/formItem.ts +107 -3
- package/src/utils/helper.ts +68 -7
- 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
|
}
|
package/src/store/formItem.ts
CHANGED
@@ -150,17 +150,21 @@ export const FormItemStore = StoreNode.named('FormItemStore')
|
|
150
150
|
return getLastOptionValue();
|
151
151
|
},
|
152
152
|
|
153
|
-
getSelectedOptions: (
|
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 =
|
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,
|
package/src/utils/helper.ts
CHANGED
@@ -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
|
-
?
|
275
|
-
|
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
|
+
}
|
package/src/utils/markdown.ts
CHANGED
@@ -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
|
}
|