amis 1.3.4 → 1.4.0
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/README.md +2 -1
- package/lib/RootRenderer.js +4 -1
- package/lib/RootRenderer.js.map +2 -2
- package/lib/components/Badge.d.ts +13 -1
- package/lib/components/Badge.js +16 -2
- package/lib/components/Badge.js.map +2 -2
- package/lib/components/Checkbox.d.ts +1 -1
- package/lib/components/Checkbox.js +1 -1
- package/lib/components/Checkbox.js.map +2 -2
- package/lib/components/Drawer.js +1 -1
- package/lib/components/Drawer.js.map +2 -2
- package/lib/components/Modal.js +1 -1
- package/lib/components/Modal.js.map +2 -2
- package/lib/components/RichText.d.ts +0 -3
- package/lib/components/RichText.js +1 -22
- package/lib/components/RichText.js.map +2 -2
- package/lib/components/Select.d.ts +7 -0
- package/lib/components/Select.js.map +2 -2
- package/lib/components/Steps.d.ts +3 -3
- package/lib/components/Steps.js.map +1 -1
- package/lib/components/WithRemoteConfig.d.ts +8 -0
- package/lib/components/WithRemoteConfig.js +28 -2
- package/lib/components/WithRemoteConfig.js.map +2 -2
- package/lib/components/condition-builder/Field.js +0 -1
- package/lib/components/condition-builder/Field.js.map +2 -2
- package/lib/components/condition-builder/Value.js +2 -1
- package/lib/components/condition-builder/Value.js.map +2 -2
- package/lib/components/condition-builder/types.d.ts +5 -0
- package/lib/components/condition-builder/types.js.map +1 -1
- package/lib/env.d.ts +1 -1
- package/lib/env.js.map +1 -1
- package/lib/factory.d.ts +6 -2
- package/lib/factory.js +9 -4
- package/lib/factory.js.map +2 -2
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/lib/index.js.map +2 -2
- package/lib/locale/de-DE.js +1 -0
- package/lib/locale/de-DE.js.map +2 -2
- package/lib/locale/en-US.js +2 -1
- package/lib/locale/en-US.js.map +2 -2
- package/lib/locale/zh-CN.js +2 -1
- package/lib/locale/zh-CN.js.map +2 -2
- package/lib/renderers/Action.d.ts +6 -0
- package/lib/renderers/Action.js +9 -1
- package/lib/renderers/Action.js.map +2 -2
- package/lib/renderers/CRUD.d.ts +2 -2
- package/lib/renderers/CRUD.js +13 -21
- package/lib/renderers/CRUD.js.map +2 -2
- package/lib/renderers/Card.js +11 -11
- package/lib/renderers/Card.js.map +2 -2
- package/lib/renderers/Collapse.d.ts +1 -1
- package/lib/renderers/Collapse.js +5 -1
- package/lib/renderers/Collapse.js.map +2 -2
- package/lib/renderers/Copyable.js +30 -28
- package/lib/renderers/Copyable.js.map +2 -2
- package/lib/renderers/Dialog.d.ts +0 -252
- package/lib/renderers/Dialog.js +3 -2
- package/lib/renderers/Dialog.js.map +2 -2
- package/lib/renderers/Drawer.js +2 -1
- package/lib/renderers/Drawer.js.map +2 -2
- package/lib/renderers/DropDownButton.d.ts +4 -0
- package/lib/renderers/DropDownButton.js +2 -2
- package/lib/renderers/DropDownButton.js.map +2 -2
- package/lib/renderers/Form/ButtonGroupSelect.js +3 -0
- package/lib/renderers/Form/ButtonGroupSelect.js.map +2 -2
- package/lib/renderers/Form/Combo.d.ts +2 -0
- package/lib/renderers/Form/Combo.js +16 -1
- package/lib/renderers/Form/Combo.js.map +2 -2
- package/lib/renderers/Form/DiffEditor.d.ts +0 -2
- package/lib/renderers/Form/Editor.d.ts +0 -2
- package/lib/renderers/Form/Editor.js +1 -1
- package/lib/renderers/Form/Editor.js.map +2 -2
- package/lib/renderers/Form/InputExcel.d.ts +5 -0
- package/lib/renderers/Form/InputExcel.js +24 -3
- package/lib/renderers/Form/InputExcel.js.map +2 -2
- package/lib/renderers/Form/InputImage.d.ts +8 -0
- package/lib/renderers/Form/InputImage.js +2 -1
- package/lib/renderers/Form/InputImage.js.map +2 -2
- package/lib/renderers/Form/InputNumber.d.ts +19 -5
- package/lib/renderers/Form/InputNumber.js +69 -7
- package/lib/renderers/Form/InputNumber.js.map +2 -2
- package/lib/renderers/Form/InputRange.js +7 -2
- package/lib/renderers/Form/InputRange.js.map +2 -2
- package/lib/renderers/Form/InputTable.d.ts +23 -5
- package/lib/renderers/Form/InputTable.js +32 -3
- package/lib/renderers/Form/InputTable.js.map +2 -2
- package/lib/renderers/Form/NestedSelect.js +2 -3
- package/lib/renderers/Form/NestedSelect.js.map +2 -2
- package/lib/renderers/Form/Options.js +3 -1
- package/lib/renderers/Form/Options.js.map +2 -2
- package/lib/renderers/Form/index.js +0 -10
- package/lib/renderers/Form/index.js.map +2 -2
- package/lib/renderers/Form/wrapControl.js +3 -3
- package/lib/renderers/Form/wrapControl.js.map +2 -2
- package/lib/renderers/Json.js +5 -1
- package/lib/renderers/Json.js.map +2 -2
- package/lib/renderers/List.d.ts +5 -0
- package/lib/renderers/List.js +20 -14
- package/lib/renderers/List.js.map +2 -2
- package/lib/renderers/Page.d.ts +6 -0
- package/lib/renderers/Page.js +10 -2
- package/lib/renderers/Page.js.map +2 -2
- package/lib/renderers/Service.d.ts +10 -1
- package/lib/renderers/Service.js +85 -3
- package/lib/renderers/Service.js.map +2 -2
- package/lib/renderers/Steps.d.ts +4 -4
- package/lib/renderers/Steps.js +5 -2
- package/lib/renderers/Steps.js.map +2 -2
- package/lib/renderers/Table/TableBody.d.ts +5 -3
- package/lib/renderers/Table/TableBody.js +17 -11
- package/lib/renderers/Table/TableBody.js.map +2 -2
- package/lib/renderers/Table/TableCell.js +6 -2
- package/lib/renderers/Table/TableCell.js.map +2 -2
- package/lib/renderers/Table/TableContent.d.ts +3 -1
- package/lib/renderers/Table/TableContent.js +6 -2
- package/lib/renderers/Table/TableContent.js.map +2 -2
- package/lib/renderers/Table/TableRow.d.ts +1 -1
- package/lib/renderers/Table/TableRow.js +14 -13
- package/lib/renderers/Table/TableRow.js.map +2 -2
- package/lib/renderers/Table/index.d.ts +28 -3
- package/lib/renderers/Table/index.js +97 -54
- package/lib/renderers/Table/index.js.map +2 -2
- package/lib/schemaExtend.d.ts +1 -0
- package/lib/schemaExtend.js +59 -0
- package/lib/schemaExtend.js.map +13 -0
- package/lib/store/app.d.ts +0 -1
- package/lib/store/combo.d.ts +0 -2
- package/lib/store/crud.d.ts +3 -3
- package/lib/store/crud.js +41 -36
- package/lib/store/crud.js.map +2 -2
- package/lib/store/form.d.ts +0 -1
- package/lib/store/formItem.js +10 -6
- package/lib/store/formItem.js.map +2 -2
- package/lib/store/modal.d.ts +1 -1
- package/lib/store/modal.js +4 -0
- package/lib/store/modal.js.map +2 -2
- package/lib/store/root.d.ts +0 -1
- package/lib/store/service.d.ts +0 -1
- package/lib/store/service.js +0 -13
- package/lib/store/service.js.map +2 -2
- package/lib/store/table.d.ts +1 -2
- package/lib/store/table.js +44 -3
- package/lib/store/table.js.map +2 -2
- package/lib/themes/ang-ie11.css +278 -17
- package/lib/themes/ang.css +278 -17
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +278 -17
- package/lib/themes/antd.css +278 -17
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +278 -17
- package/lib/themes/cxd.css +278 -17
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +278 -17
- package/lib/themes/dark.css +278 -17
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default.css +278 -17
- package/lib/themes/default.css.map +1 -1
- package/lib/utils/api.js +12 -0
- package/lib/utils/api.js.map +2 -2
- package/lib/utils/attachmentAdpator.d.ts +7 -0
- package/lib/utils/attachmentAdpator.js +82 -0
- package/lib/utils/attachmentAdpator.js.map +13 -0
- package/lib/utils/helper.d.ts +2 -0
- package/lib/utils/helper.js +14 -1
- package/lib/utils/helper.js.map +2 -2
- package/lib/utils/resize-sensor.js +6 -0
- package/lib/utils/resize-sensor.js.map +2 -2
- package/lib/utils/tpl-builtin.d.ts +1 -0
- package/lib/utils/tpl-builtin.js +24 -8
- package/lib/utils/tpl-builtin.js.map +2 -2
- package/lib/utils/validations.js +62 -5
- package/lib/utils/validations.js.map +2 -2
- package/package.json +1 -1
- package/schema.json +369 -164
- package/scss/_properties.scss +6 -0
- package/scss/components/_badge.scss +15 -1
- package/scss/components/_list.scss +8 -0
- package/scss/components/_markdown.scss +266 -0
- package/scss/components/_spinner.scss +6 -2
- package/scss/components/_table.scss +4 -0
- package/scss/components/form/_form.scss +3 -17
- package/scss/components/form/_group.scss +4 -0
- package/scss/components/form/_nested-select.scss +4 -0
- package/scss/components/form/_number.scss +12 -1
- package/scss/themes/_common.scss +1 -0
- package/sdk/ang-ie11.css +324 -20
- package/sdk/ang.css +330 -20
- package/sdk/antd-ie11.css +324 -20
- package/sdk/antd.css +330 -20
- package/sdk/charts.js +15 -15
- package/sdk/color-picker.js +65 -69
- package/sdk/cropperjs.js +2 -2
- package/sdk/cxd-ie11.css +324 -20
- package/sdk/cxd.css +330 -20
- package/sdk/dark-ie11.css +324 -20
- package/sdk/dark.css +330 -20
- package/sdk/exceljs.js +1 -1
- package/sdk/locale/de-DE.js +1 -0
- package/sdk/markdown.js +69 -69
- package/sdk/papaparse.js +1 -1
- package/sdk/renderers/Form/CityDB.js +1 -1
- package/sdk/rest.js +27 -23
- package/sdk/rich-text.js +63 -63
- package/sdk/sdk-ie11.css +324 -20
- package/sdk/sdk.css +330 -20
- package/sdk/sdk.js +1146 -1138
- package/sdk/thirds/hls.js/hls.js +1 -1
- package/sdk/thirds/mpegts.js/mpegts.js +1 -1
- package/sdk/tinymce.js +57 -57
- package/src/RootRenderer.tsx +8 -3
- package/src/components/Badge.tsx +41 -6
- package/src/components/Checkbox.tsx +5 -2
- package/src/components/Drawer.tsx +3 -2
- package/src/components/Modal.tsx +3 -2
- package/src/components/RichText.tsx +2 -27
- package/src/components/Select.tsx +1 -0
- package/src/components/Steps.tsx +3 -3
- package/src/components/WithRemoteConfig.tsx +37 -2
- package/src/components/condition-builder/Field.tsx +1 -2
- package/src/components/condition-builder/Value.tsx +3 -0
- package/src/components/condition-builder/types.ts +6 -0
- package/src/env.tsx +1 -1
- package/src/factory.tsx +14 -4
- package/src/index.tsx +2 -0
- package/src/locale/de-DE.ts +1 -0
- package/src/locale/en-US.ts +2 -1
- package/src/locale/zh-CN.ts +2 -1
- package/src/renderers/Action.tsx +19 -1
- package/src/renderers/CRUD.tsx +15 -34
- package/src/renderers/Card.tsx +21 -15
- package/src/renderers/Collapse.tsx +5 -1
- package/src/renderers/Copyable.tsx +46 -44
- package/src/renderers/Dialog.tsx +3 -2
- package/src/renderers/Drawer.tsx +2 -1
- package/src/renderers/DropDownButton.tsx +8 -0
- package/src/renderers/Form/ButtonGroupSelect.tsx +3 -0
- package/src/renderers/Form/Combo.tsx +7 -0
- package/src/renderers/Form/Editor.tsx +19 -20
- package/src/renderers/Form/InputExcel.tsx +28 -3
- package/src/renderers/Form/InputImage.tsx +23 -8
- package/src/renderers/Form/InputNumber.tsx +113 -18
- package/src/renderers/Form/InputRange.tsx +5 -2
- package/src/renderers/Form/InputTable.tsx +88 -9
- package/src/renderers/Form/NestedSelect.tsx +1 -1
- package/src/renderers/Form/Options.tsx +3 -1
- package/src/renderers/Form/index.tsx +0 -15
- package/src/renderers/Form/wrapControl.tsx +2 -2
- package/src/renderers/Json.tsx +10 -1
- package/src/renderers/List.tsx +32 -19
- package/src/renderers/Page.tsx +19 -0
- package/src/renderers/Service.tsx +101 -3
- package/src/renderers/Steps.tsx +12 -9
- package/src/renderers/Table/TableBody.tsx +29 -10
- package/src/renderers/Table/TableCell.tsx +15 -1
- package/src/renderers/Table/TableContent.tsx +7 -1
- package/src/renderers/Table/TableRow.tsx +18 -17
- package/src/renderers/Table/index.tsx +117 -28
- package/src/schemaExtend.ts +66 -0
- package/src/store/crud.ts +34 -38
- package/src/store/formItem.ts +10 -6
- package/src/store/modal.ts +4 -0
- package/src/store/service.ts +0 -19
- package/src/store/table.ts +48 -0
- package/src/utils/api.ts +11 -0
- package/src/utils/attachmentAdpator.ts +90 -0
- package/src/utils/helper.ts +15 -0
- package/src/utils/resize-sensor.ts +7 -0
- package/src/utils/tpl-builtin.ts +36 -17
- package/src/utils/validations.ts +80 -12
package/src/renderers/CRUD.tsx
CHANGED
@@ -1057,7 +1057,10 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
|
1057
1057
|
(!stopAutoRefreshWhen ||
|
1058
1058
|
!(
|
1059
1059
|
(stopAutoRefreshWhenModalIsOpen && store.hasModalOpened) ||
|
1060
|
-
evalExpression(
|
1060
|
+
evalExpression(
|
1061
|
+
stopAutoRefreshWhen,
|
1062
|
+
createObject(store.data, store.query)
|
1063
|
+
)
|
1061
1064
|
)) &&
|
1062
1065
|
(this.timer = setTimeout(
|
1063
1066
|
silentPolling
|
@@ -1497,15 +1500,11 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
|
1497
1500
|
hasBulkActions() {
|
1498
1501
|
const {bulkActions, itemActions, store} = this.props;
|
1499
1502
|
|
1500
|
-
if (
|
1501
|
-
(!bulkActions || !bulkActions.length) &&
|
1502
|
-
(!itemActions || !itemActions.length)
|
1503
|
-
) {
|
1503
|
+
if (!bulkActions || !bulkActions.length) {
|
1504
1504
|
return false;
|
1505
1505
|
}
|
1506
1506
|
|
1507
1507
|
let bulkBtns: Array<ActionSchema> = [];
|
1508
|
-
let itemBtns: Array<ActionSchema> = [];
|
1509
1508
|
const ctx = store.mergedData;
|
1510
1509
|
|
1511
1510
|
if (bulkActions && bulkActions.length) {
|
@@ -1517,21 +1516,7 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
|
1517
1516
|
.filter(item => !item.hidden && item.visible !== false);
|
1518
1517
|
}
|
1519
1518
|
|
1520
|
-
|
1521
|
-
store.data,
|
1522
|
-
store.selectedItems.length ? store.selectedItems[0] : {}
|
1523
|
-
);
|
1524
|
-
|
1525
|
-
if (itemActions && itemActions.length) {
|
1526
|
-
itemBtns = itemActions
|
1527
|
-
.map(item => ({
|
1528
|
-
...item,
|
1529
|
-
...getExprProperties(item as Schema, itemData)
|
1530
|
-
}))
|
1531
|
-
.filter(item => !item.hidden && item.visible !== false);
|
1532
|
-
}
|
1533
|
-
|
1534
|
-
return bulkBtns.length || itemBtns.length;
|
1519
|
+
return bulkBtns.length;
|
1535
1520
|
}
|
1536
1521
|
|
1537
1522
|
renderBulkActions(childProps: any) {
|
@@ -1539,11 +1524,7 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
|
1539
1524
|
|
1540
1525
|
const items = childProps.items;
|
1541
1526
|
|
1542
|
-
if (
|
1543
|
-
!items.length ||
|
1544
|
-
((!bulkActions || !bulkActions.length) &&
|
1545
|
-
(!itemActions || !itemActions.length))
|
1546
|
-
) {
|
1527
|
+
if (!items.length || !bulkActions || !bulkActions.length) {
|
1547
1528
|
return null;
|
1548
1529
|
}
|
1549
1530
|
|
@@ -1595,7 +1576,6 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
|
1595
1576
|
render(
|
1596
1577
|
`bulk-action/${index}`,
|
1597
1578
|
{
|
1598
|
-
size: 'sm',
|
1599
1579
|
...omit(btn, ['visibleOn', 'hiddenOn', 'disabledOn']),
|
1600
1580
|
type: 'button',
|
1601
1581
|
ignoreConfirm: true
|
@@ -1619,7 +1599,6 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
|
1619
1599
|
render(
|
1620
1600
|
`bulk-action/${index}`,
|
1621
1601
|
{
|
1622
|
-
size: 'sm',
|
1623
1602
|
...omit(btn, ['visibleOn', 'hiddenOn', 'disabledOn']),
|
1624
1603
|
type: 'button'
|
1625
1604
|
},
|
@@ -1776,16 +1755,17 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
|
1776
1755
|
);
|
1777
1756
|
}
|
1778
1757
|
|
1779
|
-
renderExportCSV() {
|
1758
|
+
renderExportCSV(toolbar: Schema) {
|
1780
1759
|
const {
|
1781
1760
|
store,
|
1782
1761
|
classPrefix: ns,
|
1783
1762
|
classnames: cx,
|
1784
1763
|
translate: __,
|
1785
|
-
loadDataOnce
|
1786
|
-
api
|
1764
|
+
loadDataOnce
|
1787
1765
|
} = this.props;
|
1788
1766
|
|
1767
|
+
const api = (toolbar as Schema).api;
|
1768
|
+
|
1789
1769
|
return (
|
1790
1770
|
<Button
|
1791
1771
|
classPrefix={ns}
|
@@ -1797,7 +1777,7 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
|
1797
1777
|
}
|
1798
1778
|
size="sm"
|
1799
1779
|
>
|
1800
|
-
{__('CRUD.exportCSV')}
|
1780
|
+
{toolbar.label || __('CRUD.exportCSV')}
|
1801
1781
|
</Button>
|
1802
1782
|
);
|
1803
1783
|
}
|
@@ -1827,7 +1807,7 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
|
1827
1807
|
} else if (type === 'filter-toggler') {
|
1828
1808
|
return this.renderFilterToggler();
|
1829
1809
|
} else if (type === 'export-csv') {
|
1830
|
-
return this.renderExportCSV();
|
1810
|
+
return this.renderExportCSV(toolbar as Schema);
|
1831
1811
|
} else if (Array.isArray(toolbar)) {
|
1832
1812
|
const children: Array<any> = toolbar
|
1833
1813
|
.map((toolbar, index) => ({
|
@@ -2043,7 +2023,8 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
|
2043
2023
|
data: store.filterData,
|
2044
2024
|
onReset: this.handleFilterReset,
|
2045
2025
|
onSubmit: this.handleFilterSubmit,
|
2046
|
-
onInit: this.handleFilterInit
|
2026
|
+
onInit: this.handleFilterInit,
|
2027
|
+
formStore: undefined
|
2047
2028
|
}
|
2048
2029
|
)
|
2049
2030
|
: null}
|
package/src/renderers/Card.tsx
CHANGED
@@ -6,7 +6,13 @@ import {filter, evalExpression} from '../utils/tpl';
|
|
6
6
|
import cx from 'classnames';
|
7
7
|
import Checkbox from '../components/Checkbox';
|
8
8
|
import {IItem} from '../store/list';
|
9
|
-
import {
|
9
|
+
import {
|
10
|
+
padArr,
|
11
|
+
isVisible,
|
12
|
+
isDisabled,
|
13
|
+
noop,
|
14
|
+
isClickOnInput
|
15
|
+
} from '../utils/helper';
|
10
16
|
import {resolveVariable} from '../utils/tpl-builtin';
|
11
17
|
import QuickEdit, {SchemaQuickEdit} from './QuickEdit';
|
12
18
|
import PopOver, {SchemaPopOver} from './PopOver';
|
@@ -209,19 +215,11 @@ export class Card extends React.Component<CardProps> {
|
|
209
215
|
}
|
210
216
|
|
211
217
|
handleClick(e: React.MouseEvent<HTMLDivElement>) {
|
212
|
-
|
213
|
-
const ns = this.props.classPrefix;
|
214
|
-
let formItem;
|
215
|
-
|
216
|
-
if (
|
217
|
-
!e.currentTarget.contains(target) ||
|
218
|
-
~['INPUT', 'TEXTAREA'].indexOf(target.tagName) ||
|
219
|
-
((formItem = target.closest(`button, a, .${ns}Form-item`)) &&
|
220
|
-
e.currentTarget.contains(formItem))
|
221
|
-
) {
|
218
|
+
if (isClickOnInput(e)) {
|
222
219
|
return;
|
223
220
|
}
|
224
|
-
|
221
|
+
|
222
|
+
const {item, href, data, env, blank, itemAction, onAction} = this.props;
|
225
223
|
if (href) {
|
226
224
|
env.jumpTo(filter(href, data), {
|
227
225
|
type: 'button',
|
@@ -231,6 +229,11 @@ export class Card extends React.Component<CardProps> {
|
|
231
229
|
return;
|
232
230
|
}
|
233
231
|
|
232
|
+
if (itemAction) {
|
233
|
+
onAction && onAction(e, itemAction, item?.data || data);
|
234
|
+
return;
|
235
|
+
}
|
236
|
+
|
234
237
|
this.props.onCheck && this.props.onCheck(item);
|
235
238
|
}
|
236
239
|
|
@@ -447,7 +450,8 @@ export class Card extends React.Component<CardProps> {
|
|
447
450
|
classPrefix: ns,
|
448
451
|
imageClassName,
|
449
452
|
avatarTextClassName,
|
450
|
-
href
|
453
|
+
href,
|
454
|
+
itemAction
|
451
455
|
} = this.props;
|
452
456
|
|
453
457
|
let heading = null;
|
@@ -558,10 +562,12 @@ export class Card extends React.Component<CardProps> {
|
|
558
562
|
return (
|
559
563
|
<div
|
560
564
|
onClick={
|
561
|
-
(checkOnItemClick && checkable) || href
|
565
|
+
(checkOnItemClick && checkable) || href || itemAction
|
566
|
+
? this.handleClick
|
567
|
+
: undefined
|
562
568
|
}
|
563
569
|
className={cx('Card', className, {
|
564
|
-
'Card--link': href
|
570
|
+
'Card--link': href || itemAction
|
565
571
|
})}
|
566
572
|
>
|
567
573
|
{this.renderToolbar()}
|
@@ -7,6 +7,7 @@ import {
|
|
7
7
|
SchemaCollection,
|
8
8
|
SchemaTpl
|
9
9
|
} from '../Schema';
|
10
|
+
import {isClickOnInput} from '../utils/helper';
|
10
11
|
|
11
12
|
/**
|
12
13
|
* Collapse 折叠渲染器,格式说明。
|
@@ -134,7 +135,10 @@ export default class Collapse extends React.Component<
|
|
134
135
|
}
|
135
136
|
}
|
136
137
|
|
137
|
-
toggleCollapsed() {
|
138
|
+
toggleCollapsed(e: React.MouseEvent<HTMLElement>) {
|
139
|
+
if (isClickOnInput(e)) {
|
140
|
+
return;
|
141
|
+
}
|
138
142
|
this.props.collapsable !== false &&
|
139
143
|
this.setState({
|
140
144
|
collapsed: !this.state.collapsed
|
@@ -32,54 +32,56 @@ export interface CopyableProps extends RendererProps {
|
|
32
32
|
copyable: SchemaCopyable;
|
33
33
|
}
|
34
34
|
|
35
|
-
export const HocCopyable =
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
35
|
+
export const HocCopyable =
|
36
|
+
() =>
|
37
|
+
(Component: React.ComponentType<any>): any => {
|
38
|
+
class QuickEditComponent extends React.PureComponent<CopyableProps, any> {
|
39
|
+
static ComposedComponent = Component;
|
40
|
+
handleClick(content: string) {
|
41
|
+
const {env, copyFormat} = this.props;
|
42
|
+
env.copy && env.copy(content, {format: copyFormat});
|
43
|
+
}
|
44
|
+
render() {
|
45
|
+
const {
|
46
|
+
copyable,
|
47
|
+
name,
|
48
|
+
className,
|
49
|
+
data,
|
50
|
+
noHoc,
|
51
|
+
classnames: cx,
|
52
|
+
translate: __
|
53
|
+
} = this.props;
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
);
|
59
|
-
if (content) {
|
60
|
-
return (
|
61
|
-
<Component
|
62
|
-
{...this.props}
|
63
|
-
className={cx(`Field--copyable`, className)}
|
64
|
-
>
|
65
|
-
<Component {...this.props} wrapperComponent={''} noHoc />
|
66
|
-
<a
|
67
|
-
key="edit-btn"
|
68
|
-
data-tooltip={__('Copyable.tip')}
|
69
|
-
className={cx('Field-copyBtn')}
|
70
|
-
onClick={this.handleClick.bind(this, content)}
|
71
|
-
>
|
72
|
-
<Icon icon="copy" className="icon" />
|
73
|
-
</a>
|
74
|
-
</Component>
|
55
|
+
if (copyable && !noHoc) {
|
56
|
+
const content = filter(
|
57
|
+
(copyable as SchemaCopyableObject).content ||
|
58
|
+
'${' + name + ' | raw }',
|
59
|
+
data
|
75
60
|
);
|
61
|
+
if (content) {
|
62
|
+
return (
|
63
|
+
<Component
|
64
|
+
{...this.props}
|
65
|
+
className={cx(`Field--copyable`, className)}
|
66
|
+
>
|
67
|
+
<Component {...this.props} wrapperComponent={''} noHoc />
|
68
|
+
<a
|
69
|
+
key="edit-btn"
|
70
|
+
data-tooltip={__('Copyable.tip')}
|
71
|
+
className={cx('Field-copyBtn')}
|
72
|
+
onClick={this.handleClick.bind(this, content)}
|
73
|
+
>
|
74
|
+
<Icon icon="copy" className="icon" />
|
75
|
+
</a>
|
76
|
+
</Component>
|
77
|
+
);
|
78
|
+
}
|
76
79
|
}
|
80
|
+
return <Component {...this.props} />;
|
77
81
|
}
|
78
|
-
return <Component {...this.props} />;
|
79
82
|
}
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
};
|
83
|
+
hoistNonReactStatic(QuickEditComponent, Component);
|
84
|
+
return QuickEditComponent;
|
85
|
+
};
|
84
86
|
|
85
87
|
export default HocCopyable;
|
package/src/renderers/Dialog.tsx
CHANGED
@@ -318,7 +318,7 @@ export default class Dialog extends React.Component<DialogProps> {
|
|
318
318
|
handleExited() {
|
319
319
|
const {lazySchema, store} = this.props;
|
320
320
|
if (isAlive(store)) {
|
321
|
-
store.
|
321
|
+
store.reset();
|
322
322
|
store.setEntered(false);
|
323
323
|
if (typeof lazySchema === 'function') {
|
324
324
|
store.setSchema('');
|
@@ -395,7 +395,8 @@ export default class Dialog extends React.Component<DialogProps> {
|
|
395
395
|
affixOffsetTop: 0,
|
396
396
|
onChange: this.handleFormChange,
|
397
397
|
onInit: this.handleFormInit,
|
398
|
-
onSaved: this.handleFormSaved
|
398
|
+
onSaved: this.handleFormSaved,
|
399
|
+
syncLocation: false // 弹框中的 crud 一般不需要同步地址栏
|
399
400
|
};
|
400
401
|
|
401
402
|
if (!(body as Schema).type) {
|
package/src/renderers/Drawer.tsx
CHANGED
@@ -394,7 +394,8 @@ export default class Drawer extends React.Component<DrawerProps> {
|
|
394
394
|
popOverContainer: this.getPopOverContainer,
|
395
395
|
onChange: this.handleFormChange,
|
396
396
|
onInit: this.handleFormInit,
|
397
|
-
onSaved: this.handleFormSaved
|
397
|
+
onSaved: this.handleFormSaved,
|
398
|
+
syncLocation: false
|
398
399
|
};
|
399
400
|
|
400
401
|
if (schema.type === 'form') {
|
@@ -76,6 +76,11 @@ export interface DropdownButtonSchema extends BaseSchema {
|
|
76
76
|
* 是否只显示图标。
|
77
77
|
*/
|
78
78
|
iconOnly?: boolean;
|
79
|
+
|
80
|
+
/**
|
81
|
+
* 触发条件,默认是 click
|
82
|
+
*/
|
83
|
+
trigger?: 'click' | 'hover';
|
79
84
|
}
|
80
85
|
|
81
86
|
export interface DropDownButtonProps
|
@@ -266,6 +271,7 @@ export default class DropDownButton extends React.Component<
|
|
266
271
|
iconOnly,
|
267
272
|
icon,
|
268
273
|
isActived,
|
274
|
+
trigger,
|
269
275
|
data
|
270
276
|
} = this.props;
|
271
277
|
|
@@ -281,6 +287,8 @@ export default class DropDownButton extends React.Component<
|
|
281
287
|
},
|
282
288
|
className
|
283
289
|
)}
|
290
|
+
onMouseEnter={trigger === 'hover' ? this.open : () => {}}
|
291
|
+
onMouseLeave={trigger === 'hover' ? this.close : () => {}}
|
284
292
|
ref={this.domRef}
|
285
293
|
>
|
286
294
|
<TooltipWrapper
|
@@ -108,6 +108,9 @@ export default class ButtonGroupControl extends React.Component<
|
|
108
108
|
className: cx(option.className, btnClassName),
|
109
109
|
disabled: option.disabled || disabled,
|
110
110
|
onClick: (e: React.UIEvent<any>) => {
|
111
|
+
if (disabled) {
|
112
|
+
return;
|
113
|
+
}
|
111
114
|
this.handleToggle(option);
|
112
115
|
e.preventDefault(); // 禁止 onAction 触发
|
113
116
|
}
|
@@ -1452,3 +1452,10 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
1452
1452
|
extendsData: false
|
1453
1453
|
})
|
1454
1454
|
export class ComboControlRenderer extends ComboControl {}
|
1455
|
+
|
1456
|
+
@FormItem({
|
1457
|
+
type: 'input-kv',
|
1458
|
+
storeType: ComboStore.name,
|
1459
|
+
extendsData: false
|
1460
|
+
})
|
1461
|
+
export class KVControlRenderer extends ComboControl {}
|
@@ -118,7 +118,7 @@ export default class EditorControl extends React.Component<EditorProps, any> {
|
|
118
118
|
static defaultProps: Partial<EditorProps> = {
|
119
119
|
language: 'javascript',
|
120
120
|
editorTheme: 'vs',
|
121
|
-
allowFullscreen:
|
121
|
+
allowFullscreen: true,
|
122
122
|
options: {
|
123
123
|
automaticLayout: true,
|
124
124
|
selectOnLineNumbers: true,
|
@@ -294,26 +294,25 @@ export const availableLanguages = [
|
|
294
294
|
'yaml'
|
295
295
|
];
|
296
296
|
|
297
|
-
export const EditorControls: Array<
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
}
|
313
|
-
}
|
297
|
+
export const EditorControls: Array<typeof EditorControl> =
|
298
|
+
availableLanguages.map((lang: string) => {
|
299
|
+
@FormItem({
|
300
|
+
type: `${lang}-editor`,
|
301
|
+
sizeMutable: false
|
302
|
+
})
|
303
|
+
class EditorControlRenderer extends EditorControl {
|
304
|
+
static lang = lang;
|
305
|
+
static displayName = `${lang[0].toUpperCase()}${lang.substring(
|
306
|
+
1
|
307
|
+
)}EditorControlRenderer`;
|
308
|
+
static defaultProps = {
|
309
|
+
...EditorControl.defaultProps,
|
310
|
+
language: lang
|
311
|
+
};
|
312
|
+
}
|
314
313
|
|
315
|
-
|
316
|
-
});
|
314
|
+
return EditorControlRenderer;
|
315
|
+
});
|
317
316
|
|
318
317
|
@FormItem({
|
319
318
|
type: 'js-editor',
|
@@ -28,6 +28,11 @@ export interface InputExcelControlSchema extends FormBaseControl {
|
|
28
28
|
* 是否包含空内容,主要用于二维数组模式
|
29
29
|
*/
|
30
30
|
includeEmpty: boolean;
|
31
|
+
|
32
|
+
/**
|
33
|
+
* 纯文本模式
|
34
|
+
*/
|
35
|
+
plainText: boolean;
|
31
36
|
}
|
32
37
|
|
33
38
|
export interface ExcelProps
|
@@ -48,12 +53,15 @@ export default class ExcelControl extends React.PureComponent<
|
|
48
53
|
static defaultProps: Partial<ExcelProps> = {
|
49
54
|
allSheets: false,
|
50
55
|
parseMode: 'object',
|
51
|
-
includeEmpty: true
|
56
|
+
includeEmpty: true,
|
57
|
+
plainText: true
|
52
58
|
};
|
53
59
|
state: ExcelControlState = {
|
54
60
|
open: false
|
55
61
|
};
|
56
62
|
|
63
|
+
ExcelJS: any;
|
64
|
+
|
57
65
|
@autobind
|
58
66
|
handleDrop(files: File[]) {
|
59
67
|
const {allSheets, onChange} = this.props;
|
@@ -63,6 +71,7 @@ export default class ExcelControl extends React.PureComponent<
|
|
63
71
|
reader.onload = async () => {
|
64
72
|
if (reader.result) {
|
65
73
|
import('exceljs').then(async (ExcelJS: any) => {
|
74
|
+
this.ExcelJS = ExcelJS;
|
66
75
|
const workbook = new ExcelJS.Workbook();
|
67
76
|
await workbook.xlsx.load(reader.result);
|
68
77
|
if (allSheets) {
|
@@ -88,7 +97,7 @@ export default class ExcelControl extends React.PureComponent<
|
|
88
97
|
*/
|
89
98
|
readWorksheet(worksheet: any) {
|
90
99
|
const result: any[] = [];
|
91
|
-
const {parseMode} = this.props;
|
100
|
+
const {parseMode, plainText} = this.props;
|
92
101
|
|
93
102
|
if (parseMode === 'array') {
|
94
103
|
worksheet.eachRow((row: any, rowNumber: number) => {
|
@@ -107,7 +116,23 @@ export default class ExcelControl extends React.PureComponent<
|
|
107
116
|
const data: any = {};
|
108
117
|
row.eachCell((cell: any, colNumber: any) => {
|
109
118
|
if (firstRowValues[colNumber]) {
|
110
|
-
|
119
|
+
let value = cell.value;
|
120
|
+
if (plainText) {
|
121
|
+
const ExcelValueType = this.ExcelJS.ValueType;
|
122
|
+
if (cell.type === ExcelValueType.Hyperlink) {
|
123
|
+
value = cell.value.hyperlink;
|
124
|
+
} else if (cell.type === ExcelValueType.Formula) {
|
125
|
+
value = cell.value.result;
|
126
|
+
} else if (cell.type === ExcelValueType.RichText) {
|
127
|
+
value = cell.value.richText
|
128
|
+
.map((item: any) => item.text)
|
129
|
+
.join('');
|
130
|
+
} else if (cell.type === ExcelValueType.Error) {
|
131
|
+
value = '';
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
data[firstRowValues[colNumber]] = value;
|
111
136
|
}
|
112
137
|
});
|
113
138
|
result.push(data);
|
@@ -110,6 +110,16 @@ export interface ImageControlSchema extends FormBaseControl {
|
|
110
110
|
scalable?: boolean;
|
111
111
|
};
|
112
112
|
|
113
|
+
/**
|
114
|
+
* 裁剪后的图片类型
|
115
|
+
*/
|
116
|
+
cropFormat?: string;
|
117
|
+
|
118
|
+
/**
|
119
|
+
* 裁剪后的质量
|
120
|
+
*/
|
121
|
+
cropQuality?: number;
|
122
|
+
|
113
123
|
/**
|
114
124
|
* 是否允许二次裁剪。
|
115
125
|
*/
|
@@ -862,14 +872,19 @@ export default class ImageControl extends React.Component<
|
|
862
872
|
}
|
863
873
|
|
864
874
|
handleCrop() {
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
875
|
+
const {cropFormat, cropQuality} = this.props;
|
876
|
+
this.cropper.getCroppedCanvas().toBlob(
|
877
|
+
(file: File) => {
|
878
|
+
this.addFiles([file]);
|
879
|
+
this.setState({
|
880
|
+
cropFile: undefined,
|
881
|
+
locked: false,
|
882
|
+
lockedReason: ''
|
883
|
+
});
|
884
|
+
},
|
885
|
+
cropFormat || 'image/png',
|
886
|
+
cropQuality || 1
|
887
|
+
);
|
873
888
|
}
|
874
889
|
|
875
890
|
cancelCrop() {
|