amis 1.8.0-beta.5 → 1.8.0-beta.9
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/Schema.d.ts +9 -2
- package/lib/Schema.js.map +1 -1
- package/lib/actions/PageAction.d.ts +32 -0
- package/lib/actions/PageAction.js +72 -0
- package/lib/actions/PageAction.js.map +13 -0
- package/lib/actions/index.d.ts +1 -0
- package/lib/actions/index.js +1 -0
- package/lib/actions/index.js.map +2 -2
- package/lib/components/CalendarMobile.d.ts +84 -84
- package/lib/components/Cascader.d.ts +2 -0
- package/lib/components/Cascader.js +28 -12
- package/lib/components/Cascader.js.map +2 -2
- package/lib/components/Checkbox.js +2 -2
- package/lib/components/Checkbox.js.map +2 -2
- package/lib/components/Collapse.d.ts +20 -20
- package/lib/components/DatePicker.d.ts +84 -84
- package/lib/components/DatePicker.js +5 -5
- package/lib/components/DatePicker.js.map +2 -2
- package/lib/components/Drawer.js +1 -1
- package/lib/components/Drawer.js.map +2 -2
- package/lib/components/ListGroup.d.ts +21 -21
- package/lib/components/Modal.js +1 -1
- package/lib/components/Modal.js.map +2 -2
- package/lib/components/Overlay.d.ts +1 -0
- package/lib/components/Overlay.js +4 -3
- package/lib/components/Overlay.js.map +2 -2
- package/lib/components/PullRefresh.d.ts +86 -0
- package/lib/components/PullRefresh.js +135 -0
- package/lib/components/PullRefresh.js.map +13 -0
- package/lib/components/Spinner.d.ts +200 -107
- package/lib/components/Spinner.js +30 -26
- package/lib/components/Spinner.js.map +2 -2
- package/lib/components/Tooltip.d.ts +4 -0
- package/lib/components/Tooltip.js +6 -4
- package/lib/components/Tooltip.js.map +2 -2
- package/lib/components/TooltipWrapper.d.ts +60 -4
- package/lib/components/TooltipWrapper.js +27 -8
- package/lib/components/TooltipWrapper.js.map +2 -2
- package/lib/components/Transfer.d.ts +84 -84
- package/lib/components/TransferDropDown.d.ts +84 -84
- package/lib/components/Tree.d.ts +87 -85
- package/lib/components/Tree.js +13 -5
- package/lib/components/Tree.js.map +2 -2
- package/lib/components/TreeSelection.d.ts +84 -84
- package/lib/components/calendar/TimeView.d.ts +1 -0
- package/lib/components/calendar/TimeView.js +7 -0
- package/lib/components/calendar/TimeView.js.map +2 -2
- package/lib/components/condition-builder/Expression.d.ts +1 -0
- package/lib/components/condition-builder/Expression.js +4 -4
- package/lib/components/condition-builder/Expression.js.map +2 -2
- package/lib/components/condition-builder/Field.d.ts +1 -0
- package/lib/components/condition-builder/Field.js +3 -2
- package/lib/components/condition-builder/Field.js.map +2 -2
- package/lib/components/condition-builder/Group.d.ts +1 -0
- package/lib/components/condition-builder/Group.js +2 -2
- package/lib/components/condition-builder/Group.js.map +2 -2
- package/lib/components/condition-builder/GroupOrItem.d.ts +1 -0
- package/lib/components/condition-builder/GroupOrItem.js +2 -2
- package/lib/components/condition-builder/GroupOrItem.js.map +2 -2
- package/lib/components/condition-builder/InputSwitch.d.ts +2 -1
- package/lib/components/condition-builder/InputSwitch.js +2 -2
- package/lib/components/condition-builder/InputSwitch.js.map +2 -2
- package/lib/components/condition-builder/Item.d.ts +1 -0
- package/lib/components/condition-builder/Item.js +9 -8
- package/lib/components/condition-builder/Item.js.map +2 -2
- package/lib/components/condition-builder/Value.d.ts +1 -0
- package/lib/components/condition-builder/Value.js +5 -5
- package/lib/components/condition-builder/Value.js.map +2 -2
- package/lib/components/condition-builder/index.d.ts +1 -0
- package/lib/components/condition-builder/index.js +2 -2
- package/lib/components/condition-builder/index.js.map +2 -2
- package/lib/components/formula/Editor.d.ts +87 -85
- package/lib/components/formula/Editor.js +10 -6
- package/lib/components/formula/Editor.js.map +2 -2
- package/lib/components/formula/Picker.js +3 -1
- package/lib/components/formula/Picker.js.map +2 -2
- package/lib/index.js +1 -1
- package/lib/locale/de-DE.js +5 -1
- package/lib/locale/de-DE.js.map +2 -2
- package/lib/locale/en-US.js +5 -1
- package/lib/locale/en-US.js.map +2 -2
- package/lib/locale/zh-CN.js +5 -1
- package/lib/locale/zh-CN.js.map +2 -2
- package/lib/renderers/CRUD.js +1 -1
- package/lib/renderers/CRUD.js.map +2 -2
- package/lib/renderers/Form/Combo.d.ts +2 -1
- package/lib/renderers/Form/Combo.js +51 -14
- package/lib/renderers/Form/Combo.js.map +2 -2
- package/lib/renderers/Form/DiffEditor.d.ts +1 -0
- package/lib/renderers/Form/InputCity.d.ts +84 -84
- package/lib/renderers/Form/InputDate.js +10 -3
- package/lib/renderers/Form/InputDate.js.map +2 -2
- package/lib/renderers/Form/InputDateRange.js +12 -3
- package/lib/renderers/Form/InputDateRange.js.map +2 -2
- package/lib/renderers/Form/InputFile.js +13 -5
- package/lib/renderers/Form/InputFile.js.map +2 -2
- package/lib/renderers/Form/InputImage.js +12 -4
- package/lib/renderers/Form/InputImage.js.map +2 -2
- package/lib/renderers/Form/InputMonthRange.js +5 -1
- package/lib/renderers/Form/InputMonthRange.js.map +2 -2
- package/lib/renderers/Form/InputText.js +8 -4
- package/lib/renderers/Form/InputText.js.map +2 -2
- package/lib/renderers/Form/InputTree.d.ts +5 -0
- package/lib/renderers/Form/InputTree.js +51 -2
- package/lib/renderers/Form/InputTree.js.map +2 -2
- package/lib/renderers/Form/Item.d.ts +68 -70
- package/lib/renderers/Form/Item.js.map +2 -2
- package/lib/renderers/Form/NestedSelect.d.ts +4 -0
- package/lib/renderers/Form/NestedSelect.js +14 -5
- package/lib/renderers/Form/NestedSelect.js.map +2 -2
- package/lib/renderers/Form/Options.js +61 -27
- package/lib/renderers/Form/Options.js.map +2 -2
- package/lib/renderers/Form/Select.js +4 -2
- package/lib/renderers/Form/Select.js.map +2 -2
- package/lib/renderers/Form/TreeSelect.d.ts +11 -2
- package/lib/renderers/Form/TreeSelect.js +56 -10
- package/lib/renderers/Form/TreeSelect.js.map +2 -2
- package/lib/renderers/Form/wrapControl.js +3 -3
- package/lib/renderers/Form/wrapControl.js.map +2 -2
- package/lib/renderers/Nav.d.ts +82 -67
- package/lib/renderers/Nav.js +47 -11
- package/lib/renderers/Nav.js.map +2 -2
- package/lib/renderers/Page.d.ts +20 -0
- package/lib/renderers/Page.js +51 -14
- package/lib/renderers/Page.js.map +2 -2
- package/lib/renderers/Service.d.ts +2 -0
- package/lib/renderers/Service.js +52 -20
- package/lib/renderers/Service.js.map +2 -2
- package/lib/renderers/Spinner.d.ts +58 -2
- package/lib/renderers/Spinner.js +8 -1
- package/lib/renderers/Spinner.js.map +2 -2
- package/lib/renderers/Table/ColumnToggler.d.ts +4 -0
- package/lib/renderers/Table/ColumnToggler.js +11 -6
- package/lib/renderers/Table/ColumnToggler.js.map +2 -2
- package/lib/renderers/Table/TableCell.js +27 -1
- package/lib/renderers/Table/TableCell.js.map +2 -2
- package/lib/renderers/Table/index.d.ts +1 -0
- package/lib/renderers/Table/index.js +19 -11
- package/lib/renderers/Table/index.js.map +2 -2
- package/lib/renderers/TooltipWrapper.d.ts +31 -6
- package/lib/renderers/TooltipWrapper.js +18 -8
- package/lib/renderers/TooltipWrapper.js.map +2 -2
- package/lib/renderers/Wizard.js +23 -14
- package/lib/renderers/Wizard.js.map +2 -2
- package/lib/store/crud.js +23 -13
- package/lib/store/crud.js.map +2 -2
- package/lib/themes/ang-ie11.css +313 -100
- package/lib/themes/ang.css +322 -103
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +429 -216
- package/lib/themes/antd.css +323 -104
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +424 -211
- package/lib/themes/cxd.css +324 -105
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +313 -100
- package/lib/themes/dark.css +322 -103
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default-ie11.css +424 -211
- package/lib/themes/default.css +324 -105
- package/lib/themes/default.css.map +1 -1
- package/lib/types.d.ts +3 -1
- package/lib/types.js.map +1 -1
- package/lib/utils/ColorScale.d.ts +19 -0
- package/lib/utils/ColorScale.js +104 -0
- package/lib/utils/ColorScale.js.map +13 -0
- package/lib/utils/api.js +20 -4
- package/lib/utils/api.js.map +2 -2
- package/lib/utils/dom.d.ts +1 -1
- package/lib/utils/dom.js +7 -5
- package/lib/utils/dom.js.map +2 -2
- package/package.json +3 -2
- package/schema.json +29645 -29137
- package/scss/_properties.scss +33 -15
- package/scss/components/_column-toggler.scss +21 -11
- package/scss/components/_formula.scss +1 -1
- package/scss/components/_nav.scss +51 -6
- package/scss/components/_pull-refresh.scss +25 -0
- package/scss/components/_spinner.scss +134 -56
- package/scss/components/_tooltip.scss +4 -9
- package/scss/components/form/_checks.scss +1 -0
- package/scss/components/form/_combo.scss +13 -1
- package/scss/components/form/_date-range.scss +11 -2
- package/scss/components/form/_date.scss +11 -0
- package/scss/components/form/_file.scss +4 -0
- package/scss/components/form/_form.scss +15 -8
- package/scss/components/form/_transfer.scss +3 -2
- package/scss/themes/_antd-variables.scss +1 -1
- package/scss/themes/_common.scss +1 -0
- package/scss/themes/_cxd-variables.scss +2 -2
- package/sdk/ang-ie11.css +286 -80
- package/sdk/ang.css +294 -82
- package/sdk/antd-ie11.css +402 -196
- package/sdk/antd.css +295 -83
- package/sdk/barcode.js +51 -51
- package/sdk/charts.js +14 -14
- package/sdk/codemirror.js +7 -7
- package/sdk/color-picker.js +65 -65
- package/sdk/cropperjs.js +2 -2
- package/sdk/cxd-ie11.css +397 -191
- package/sdk/cxd.css +296 -84
- package/sdk/dark-ie11.css +286 -80
- package/sdk/dark.css +294 -82
- package/sdk/exceljs.js +1 -1
- package/sdk/locale/de-DE.js +5 -1
- package/sdk/markdown.js +69 -69
- package/sdk/papaparse.js +1 -1
- package/sdk/renderers/Form/CityDB.js +1 -1
- package/sdk/rest.js +17 -17
- package/sdk/rich-text.js +62 -62
- package/sdk/sdk-ie11.css +397 -191
- package/sdk/sdk.css +296 -84
- package/sdk/sdk.js +1300 -1260
- 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/Schema.ts +10 -0
- package/src/actions/PageAction.ts +62 -0
- package/src/actions/index.ts +1 -0
- package/src/components/Cascader.tsx +37 -11
- package/src/components/Checkbox.tsx +1 -1
- package/src/components/DatePicker.tsx +7 -5
- package/src/components/Drawer.tsx +1 -0
- package/src/components/Modal.tsx +1 -0
- package/src/components/Overlay.tsx +6 -3
- package/src/components/PullRefresh.tsx +197 -0
- package/src/components/Spinner.tsx +77 -42
- package/src/components/Tooltip.tsx +12 -3
- package/src/components/TooltipWrapper.tsx +120 -33
- package/src/components/Tree.tsx +19 -5
- package/src/components/calendar/TimeView.tsx +12 -0
- package/src/components/condition-builder/Expression.tsx +6 -1
- package/src/components/condition-builder/Field.tsx +5 -1
- package/src/components/condition-builder/Group.tsx +4 -1
- package/src/components/condition-builder/GroupOrItem.tsx +4 -1
- package/src/components/condition-builder/InputSwitch.tsx +4 -1
- package/src/components/condition-builder/Item.tsx +28 -4
- package/src/components/condition-builder/Value.tsx +7 -1
- package/src/components/condition-builder/index.tsx +4 -2
- package/src/components/formula/Editor.tsx +20 -15
- package/src/components/formula/Picker.tsx +9 -5
- package/src/locale/de-DE.ts +5 -1
- package/src/locale/en-US.ts +5 -1
- package/src/locale/zh-CN.ts +5 -1
- package/src/renderers/CRUD.tsx +1 -1
- package/src/renderers/Form/Combo.tsx +102 -46
- package/src/renderers/Form/InputDate.tsx +18 -4
- package/src/renderers/Form/InputDateRange.tsx +19 -2
- package/src/renderers/Form/InputFile.tsx +16 -4
- package/src/renderers/Form/InputImage.tsx +15 -3
- package/src/renderers/Form/InputMonthRange.tsx +7 -1
- package/src/renderers/Form/InputText.tsx +14 -2
- package/src/renderers/Form/InputTree.tsx +40 -2
- package/src/renderers/Form/Item.tsx +6 -0
- package/src/renderers/Form/NestedSelect.tsx +23 -4
- package/src/renderers/Form/Options.tsx +26 -7
- package/src/renderers/Form/Select.tsx +5 -3
- package/src/renderers/Form/TreeSelect.tsx +47 -9
- package/src/renderers/Form/wrapControl.tsx +2 -2
- package/src/renderers/Nav.tsx +230 -32
- package/src/renderers/Page.tsx +89 -33
- package/src/renderers/Service.tsx +62 -27
- package/src/renderers/Spinner.tsx +85 -3
- package/src/renderers/Table/ColumnToggler.tsx +36 -11
- package/src/renderers/Table/TableCell.tsx +39 -1
- package/src/renderers/Table/index.tsx +34 -21
- package/src/renderers/TooltipWrapper.tsx +64 -28
- package/src/renderers/Wizard.tsx +36 -25
- package/src/store/crud.ts +10 -0
- package/src/types.ts +4 -0
- package/src/utils/ColorScale.ts +138 -0
- package/src/utils/api.ts +26 -4
- package/src/utils/dom.tsx +7 -6
package/src/renderers/Wizard.tsx
CHANGED
@@ -253,7 +253,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
253
253
|
}
|
254
254
|
})
|
255
255
|
.then(value => {
|
256
|
-
this.handleInitEvent(store.data)
|
256
|
+
this.handleInitEvent(store.data);
|
257
257
|
|
258
258
|
const state = {
|
259
259
|
currentStep:
|
@@ -340,14 +340,19 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
340
340
|
async dispatchEvent(action: string, value?: object) {
|
341
341
|
const {dispatchEvent, data} = this.props;
|
342
342
|
|
343
|
-
const rendererEvent = await dispatchEvent(
|
343
|
+
const rendererEvent = await dispatchEvent(
|
344
|
+
action,
|
345
|
+
createObject(data, value ? value : {})
|
346
|
+
);
|
344
347
|
|
345
348
|
return rendererEvent?.prevented ?? false;
|
346
349
|
}
|
347
350
|
|
348
351
|
async handleInitEvent(data: any) {
|
349
352
|
const {onInit} = this.props;
|
350
|
-
(await this.dispatchEvent('inited', data)) &&
|
353
|
+
(await this.dispatchEvent('inited', {formData: data})) &&
|
354
|
+
onInit &&
|
355
|
+
onInit(data);
|
351
356
|
}
|
352
357
|
|
353
358
|
@autobind
|
@@ -383,8 +388,13 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
383
388
|
index = Math.max(Math.min(steps.length, index), 1);
|
384
389
|
|
385
390
|
if (index != this.state.currentStep) {
|
386
|
-
if (
|
387
|
-
|
391
|
+
if (
|
392
|
+
await this.dispatchEvent('stepChange', {
|
393
|
+
step: index,
|
394
|
+
formData: this.props.store.data
|
395
|
+
})
|
396
|
+
) {
|
397
|
+
return;
|
388
398
|
}
|
389
399
|
|
390
400
|
this.setState({
|
@@ -537,7 +547,11 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
537
547
|
) {
|
538
548
|
const {onAction, store, env, steps} = this.props;
|
539
549
|
|
540
|
-
if (
|
550
|
+
if (
|
551
|
+
action.actionType === 'next' ||
|
552
|
+
action.type === 'submit' ||
|
553
|
+
action.actionType === 'step-submit'
|
554
|
+
) {
|
541
555
|
this.form.doAction(
|
542
556
|
{
|
543
557
|
...action,
|
@@ -593,11 +607,15 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
593
607
|
} else if (action.actionType === 'goto-step') {
|
594
608
|
const targetStep = (data as any).step;
|
595
609
|
|
596
|
-
if (
|
610
|
+
if (
|
611
|
+
targetStep !== undefined &&
|
612
|
+
targetStep <= steps.length &&
|
613
|
+
targetStep >= 0
|
614
|
+
) {
|
597
615
|
this.gotoStep((data as any).step);
|
598
616
|
}
|
599
617
|
} else if (action.actionType === 'submit') {
|
600
|
-
this.finalSubmit()
|
618
|
+
this.finalSubmit();
|
601
619
|
} else if (onAction) {
|
602
620
|
onAction(e, action, data, throwErrors, delegate || this.context);
|
603
621
|
}
|
@@ -630,14 +648,13 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
630
648
|
async handleChange(values: object) {
|
631
649
|
const {store} = this.props;
|
632
650
|
|
633
|
-
const previous =
|
651
|
+
const previous = store.data;
|
634
652
|
const final = {...previous, ...values};
|
635
653
|
|
636
|
-
if (await this.dispatchEvent('change', final)) {
|
654
|
+
if (await this.dispatchEvent('change', {formData: final})) {
|
637
655
|
return;
|
638
656
|
}
|
639
657
|
|
640
|
-
|
641
658
|
store.updateData(values);
|
642
659
|
}
|
643
660
|
|
@@ -678,14 +695,13 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
678
695
|
onFinished
|
679
696
|
} = this.props;
|
680
697
|
|
681
|
-
if (await this.dispatchEvent('finished', store.data)) {
|
698
|
+
if (await this.dispatchEvent('finished', {formData: store.data})) {
|
682
699
|
return;
|
683
700
|
}
|
684
701
|
|
685
702
|
const step = steps[this.state.currentStep - 1];
|
686
703
|
store.updateData(values);
|
687
704
|
|
688
|
-
|
689
705
|
// 最后一步
|
690
706
|
if (target) {
|
691
707
|
this.submitToTarget(target, store.data);
|
@@ -706,7 +722,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
706
722
|
formStore
|
707
723
|
.saveRemote(action.api || step.api || api!, store.data, {
|
708
724
|
onSuccess: () => {
|
709
|
-
this.dispatchEvent('submitSucc', store.data);
|
725
|
+
this.dispatchEvent('submitSucc', {formData: store.data});
|
710
726
|
|
711
727
|
if (
|
712
728
|
!isEffectiveApi(finnalAsyncApi, store.data) ||
|
@@ -721,7 +737,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
721
737
|
cancel => (this.asyncCancel = cancel)
|
722
738
|
);
|
723
739
|
},
|
724
|
-
onFailed:
|
740
|
+
onFailed: error => this.dispatchEvent('submitFail', {error})
|
725
741
|
})
|
726
742
|
.then(async value => {
|
727
743
|
const feedback = action.feedback;
|
@@ -766,7 +782,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
766
782
|
return value;
|
767
783
|
})
|
768
784
|
.catch(error => {
|
769
|
-
this.dispatchEvent('submitFail', error)
|
785
|
+
this.dispatchEvent('submitFail', {error});
|
770
786
|
store.markSaving(false);
|
771
787
|
console.error(error);
|
772
788
|
});
|
@@ -779,12 +795,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
779
795
|
// 接管里面 form 的提交,不能直接让 form 提交,因为 wizard 自己需要知道进度。
|
780
796
|
@autobind
|
781
797
|
async handleSubmit(values: object, action: Action) {
|
782
|
-
const {
|
783
|
-
store,
|
784
|
-
steps,
|
785
|
-
finishedField
|
786
|
-
} = this.props;
|
787
|
-
|
798
|
+
const {store, steps, finishedField} = this.props;
|
788
799
|
|
789
800
|
if (this.state.currentStep < steps.length) {
|
790
801
|
const step = steps[this.state.currentStep - 1];
|
@@ -801,7 +812,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
801
812
|
store
|
802
813
|
.saveRemote(action.api || step.api!, store.data, {
|
803
814
|
onSuccess: () => {
|
804
|
-
this.dispatchEvent('stepSubmitSucc', store.data);
|
815
|
+
this.dispatchEvent('stepSubmitSucc', {formData: store.data});
|
805
816
|
|
806
817
|
if (
|
807
818
|
!isEffectiveApi(finnalAsyncApi, store.data) ||
|
@@ -817,7 +828,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
817
828
|
);
|
818
829
|
},
|
819
830
|
onFailed: json => {
|
820
|
-
this.dispatchEvent('stepSubmitFail', json);
|
831
|
+
this.dispatchEvent('stepSubmitFail', {error: json});
|
821
832
|
if (json.status === 422 && json.errors && this.form) {
|
822
833
|
this.form.props.store.setFormItemErrors(json.errors);
|
823
834
|
}
|
@@ -843,7 +854,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
|
|
843
854
|
);
|
844
855
|
})
|
845
856
|
.catch(reason => {
|
846
|
-
this.dispatchEvent('stepSubmitFail', reason);
|
857
|
+
this.dispatchEvent('stepSubmitFail', {error: reason});
|
847
858
|
if (reason instanceof SkipOperation) {
|
848
859
|
return;
|
849
860
|
}
|
package/src/store/crud.ts
CHANGED
@@ -272,6 +272,16 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
|
|
272
272
|
items = result.items || result.rows;
|
273
273
|
}
|
274
274
|
|
275
|
+
// 如果不按照 items 格式返回,就拿第一个数组当成 items
|
276
|
+
if (!Array.isArray(items)) {
|
277
|
+
for (const key of Object.keys(result)) {
|
278
|
+
if (result.hasOwnProperty(key) && Array.isArray(result[key])) {
|
279
|
+
items = result[key];
|
280
|
+
break;
|
281
|
+
}
|
282
|
+
}
|
283
|
+
}
|
284
|
+
|
275
285
|
if (!Array.isArray(items)) {
|
276
286
|
throw new Error(self.__('CRUD.invalidArray'));
|
277
287
|
} else {
|
package/src/types.ts
CHANGED
@@ -6,6 +6,8 @@ export interface ApiObject extends SchemaApiObject {
|
|
6
6
|
withCredentials?: boolean;
|
7
7
|
cancelExecutor?: (cancel: Function) => void;
|
8
8
|
};
|
9
|
+
graphql?: string;
|
10
|
+
operationName?: string;
|
9
11
|
body?: PlainObject;
|
10
12
|
query?: PlainObject;
|
11
13
|
adaptor?: (payload: object, response: fetcherResult, api: ApiObject) => any;
|
@@ -104,6 +106,8 @@ export interface Action extends Button {
|
|
104
106
|
| 'clear-and-submit'
|
105
107
|
| 'toast'
|
106
108
|
| 'goto-step'
|
109
|
+
| 'expand'
|
110
|
+
| 'collapse'
|
107
111
|
| 'step-submit';
|
108
112
|
api?: Api;
|
109
113
|
asyncApi?: Api;
|
@@ -0,0 +1,138 @@
|
|
1
|
+
// 代码修改自 https://github.com/dalisc/color-scales-js
|
2
|
+
// 主要是将校验功能改成修正而不是报错,比如 min 和 max 相等的时候自动给 max + 1
|
3
|
+
|
4
|
+
class Color {
|
5
|
+
public r: number;
|
6
|
+
public g: number;
|
7
|
+
public b: number;
|
8
|
+
public a: number;
|
9
|
+
|
10
|
+
constructor(r: number, g: number, b: number, a: number = 1) {
|
11
|
+
this.r = r;
|
12
|
+
this.g = g;
|
13
|
+
this.b = b;
|
14
|
+
this.a = a;
|
15
|
+
}
|
16
|
+
|
17
|
+
toRGBString() {
|
18
|
+
return `rgb(${Math.floor(this.r * this.a)},${Math.floor(
|
19
|
+
this.g * this.a
|
20
|
+
)},${Math.floor(this.b * this.a)})`;
|
21
|
+
}
|
22
|
+
|
23
|
+
toRGBAString() {
|
24
|
+
return `rgba(${this.r},${this.g},${this.b},${this.a})`;
|
25
|
+
}
|
26
|
+
|
27
|
+
toHexString() {
|
28
|
+
return rgbaToHex(this);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
function hexToColor(hex: string, alpha: number) {
|
33
|
+
if (isValid3DigitHexColor(hex)) {
|
34
|
+
hex = convertTo6DigitHexColor(hex);
|
35
|
+
}
|
36
|
+
|
37
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
38
|
+
if (result) {
|
39
|
+
return new Color(
|
40
|
+
parseInt(result[1], 16),
|
41
|
+
parseInt(result[2], 16),
|
42
|
+
parseInt(result[3], 16),
|
43
|
+
alpha
|
44
|
+
);
|
45
|
+
} else {
|
46
|
+
throw new Error(`${hex} is not a valid hex color.`);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
function isValidHexColor(colorString: string) {
|
51
|
+
return (
|
52
|
+
isValid3DigitHexColor(colorString) || isValid6DigitHexColor(colorString)
|
53
|
+
);
|
54
|
+
}
|
55
|
+
|
56
|
+
function isValid3DigitHexColor(colorString: string) {
|
57
|
+
const hexColorRegex = /^#(?:[0-9a-fA-F]{3})$/;
|
58
|
+
return colorString.match(hexColorRegex);
|
59
|
+
}
|
60
|
+
|
61
|
+
function isValid6DigitHexColor(colorString: string) {
|
62
|
+
const hexColorRegex = /^#(?:[0-9a-fA-F]{6})$/;
|
63
|
+
return colorString.match(hexColorRegex);
|
64
|
+
}
|
65
|
+
|
66
|
+
function convertTo6DigitHexColor(threeDigitHex: string) {
|
67
|
+
return threeDigitHex
|
68
|
+
.substring(1)
|
69
|
+
.split('')
|
70
|
+
.map(char => {
|
71
|
+
return char + char;
|
72
|
+
})
|
73
|
+
.join('');
|
74
|
+
}
|
75
|
+
|
76
|
+
function componentToHex(c: number) {
|
77
|
+
const hex = c.toString(16);
|
78
|
+
return hex.length === 1 ? '0' + hex : hex;
|
79
|
+
}
|
80
|
+
|
81
|
+
function rgbaToHex(color: Color) {
|
82
|
+
const r = Math.floor(color.r * color.a);
|
83
|
+
const g = Math.floor(color.g * color.a);
|
84
|
+
const b = Math.floor(color.b * color.a);
|
85
|
+
return `#${componentToHex(r)}${componentToHex(g)}${componentToHex(b)}`;
|
86
|
+
}
|
87
|
+
|
88
|
+
export default class ColorScale {
|
89
|
+
private min: number;
|
90
|
+
private max: number;
|
91
|
+
private alpha: number;
|
92
|
+
private colorStops: Color[];
|
93
|
+
|
94
|
+
constructor(
|
95
|
+
min: number,
|
96
|
+
max: number,
|
97
|
+
colorStops: string[],
|
98
|
+
alpha: number = 1
|
99
|
+
) {
|
100
|
+
this.min = isNaN(min) ? 0 : min;
|
101
|
+
this.max = isNaN(max) ? 0 : max;
|
102
|
+
if (this.min === this.max) {
|
103
|
+
this.max = this.min + 1;
|
104
|
+
}
|
105
|
+
if (this.max < this.min) {
|
106
|
+
[this.max, this.min] = [this.min, this.max];
|
107
|
+
}
|
108
|
+
if (colorStops.length < 2) {
|
109
|
+
colorStops = ['#FFEF9C', '#FF7127'];
|
110
|
+
}
|
111
|
+
this.alpha = alpha;
|
112
|
+
this.colorStops = colorStops.map(colorStop => hexToColor(colorStop, alpha));
|
113
|
+
}
|
114
|
+
|
115
|
+
getColor(value: number) {
|
116
|
+
const numOfColorStops = this.colorStops.length;
|
117
|
+
if (value < this.min) return this.colorStops[0];
|
118
|
+
if (value > this.max) return this.colorStops[numOfColorStops - 1];
|
119
|
+
|
120
|
+
const range = this.max - this.min;
|
121
|
+
let weight = (value - this.min) / range;
|
122
|
+
const colorStopIndex = Math.max(
|
123
|
+
Math.ceil(weight * (numOfColorStops - 1)),
|
124
|
+
1
|
125
|
+
);
|
126
|
+
|
127
|
+
const minColor = this.colorStops[colorStopIndex - 1];
|
128
|
+
const maxColor = this.colorStops[colorStopIndex];
|
129
|
+
|
130
|
+
weight = weight * (numOfColorStops - 1) - (colorStopIndex - 1);
|
131
|
+
|
132
|
+
const r = Math.floor(weight * maxColor.r + (1 - weight) * minColor.r);
|
133
|
+
const g = Math.floor(weight * maxColor.g + (1 - weight) * minColor.g);
|
134
|
+
const b = Math.floor(weight * maxColor.b + (1 - weight) * minColor.b);
|
135
|
+
|
136
|
+
return new Color(r, g, b, this.alpha);
|
137
|
+
}
|
138
|
+
}
|
package/src/utils/api.ts
CHANGED
@@ -125,19 +125,25 @@ export function buildApi(
|
|
125
125
|
undefined,
|
126
126
|
api.convertKeyToPath
|
127
127
|
);
|
128
|
-
} else if (
|
128
|
+
} else if (
|
129
|
+
api.method === 'post' ||
|
130
|
+
api.method === 'put' ||
|
131
|
+
api.method === 'patch'
|
132
|
+
) {
|
129
133
|
api.body = api.data = cloneObject(data);
|
130
134
|
}
|
131
135
|
|
132
136
|
// get 类请求,把 data 附带到 url 上。
|
133
137
|
if (api.method === 'get' || api.method === 'jsonp') {
|
134
|
-
if (
|
138
|
+
if (
|
139
|
+
!api.data &&
|
140
|
+
((!~raw.indexOf('$') && autoAppend) || api.forceAppendDataToQuery)
|
141
|
+
) {
|
135
142
|
api.query = api.data = data;
|
136
143
|
} else if (
|
137
144
|
api.attachDataToQuery === false &&
|
138
145
|
api.data &&
|
139
|
-
!~raw.indexOf('$') &&
|
140
|
-
autoAppend
|
146
|
+
((!~raw.indexOf('$') && autoAppend) || api.forceAppendDataToQuery)
|
141
147
|
) {
|
142
148
|
const idx = api.url.indexOf('?');
|
143
149
|
if (~idx) {
|
@@ -168,6 +174,22 @@ export function buildApi(
|
|
168
174
|
}
|
169
175
|
}
|
170
176
|
|
177
|
+
if (api.graphql) {
|
178
|
+
if (api.method === 'get') {
|
179
|
+
api.query = api.data = {...api.query, query: api.graphql};
|
180
|
+
} else if (
|
181
|
+
api.method === 'post' ||
|
182
|
+
api.method === 'put' ||
|
183
|
+
api.method === 'patch'
|
184
|
+
) {
|
185
|
+
api.body = api.data = {
|
186
|
+
query: api.graphql,
|
187
|
+
operationName: api.operationName,
|
188
|
+
variables: cloneObject(api.data)
|
189
|
+
};
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
171
193
|
return api;
|
172
194
|
}
|
173
195
|
|
package/src/utils/dom.tsx
CHANGED
@@ -82,7 +82,8 @@ export function calculatePosition(
|
|
82
82
|
overlayNode: any,
|
83
83
|
target: HTMLElement,
|
84
84
|
container: any,
|
85
|
-
padding: any = 0
|
85
|
+
padding: any = 0,
|
86
|
+
customOffset: [number, number] = [0, 0]
|
86
87
|
) {
|
87
88
|
const childOffset: any =
|
88
89
|
container.tagName === 'BODY'
|
@@ -215,12 +216,12 @@ export function calculatePosition(
|
|
215
216
|
`calcOverlayPosition(): No such placement of "${placement}" found.`
|
216
217
|
);
|
217
218
|
}
|
218
|
-
|
219
|
+
const [offSetX = 0, offSetY = 0] = customOffset;
|
219
220
|
return {
|
220
|
-
positionLeft: positionLeft / scaleX,
|
221
|
-
positionTop: positionTop / scaleY,
|
222
|
-
arrowOffsetLeft: arrowOffsetLeft / scaleX,
|
223
|
-
arrowOffsetTop: arrowOffsetTop / scaleY,
|
221
|
+
positionLeft: (positionLeft + offSetX) / scaleX,
|
222
|
+
positionTop: (positionTop + offSetY) / scaleY,
|
223
|
+
arrowOffsetLeft: (arrowOffsetLeft + offSetX) / scaleX,
|
224
|
+
arrowOffsetTop: (arrowOffsetTop + offSetY) / scaleY,
|
224
225
|
activePlacement
|
225
226
|
};
|
226
227
|
}
|