amis 1.5.6-beta.5 → 1.6.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/.husky/pre-commit +1 -1
- package/lib/Schema.d.ts +3 -2
- package/lib/Schema.js.map +1 -1
- package/lib/components/AssociatedSelection.d.ts +84 -84
- package/lib/components/AssociatedSelection.js +2 -2
- package/lib/components/AssociatedSelection.js.map +2 -2
- package/lib/components/Avatar.d.ts +135 -0
- package/lib/components/Avatar.js +120 -0
- package/lib/components/Avatar.js.map +13 -0
- package/lib/components/BaiduMapPicker.js.map +2 -2
- package/lib/components/CalendarMobile.d.ts +547 -0
- package/lib/components/CalendarMobile.js +432 -0
- package/lib/components/CalendarMobile.js.map +13 -0
- package/lib/components/Card.js +1 -1
- package/lib/components/Card.js.map +2 -2
- package/lib/components/Cascader.d.ts +123 -0
- package/lib/components/Cascader.js +487 -0
- package/lib/components/Cascader.js.map +13 -0
- package/lib/components/ChainedSelection.d.ts +84 -84
- package/lib/components/ChainedSelection.js +15 -3
- package/lib/components/ChainedSelection.js.map +2 -2
- package/lib/components/CityArea.d.ts +527 -0
- package/lib/components/CityArea.js +177 -0
- package/lib/components/CityArea.js.map +13 -0
- package/lib/components/Collapse.js +1 -1
- package/lib/components/Collapse.js.map +2 -2
- package/lib/components/ColorPicker.d.ts +84 -84
- package/lib/components/ColorPicker.js +4 -3
- package/lib/components/ColorPicker.js.map +2 -2
- package/lib/components/DatePicker.d.ts +85 -84
- package/lib/components/DatePicker.js +15 -8
- package/lib/components/DatePicker.js.map +2 -2
- package/lib/components/DateRangePicker.d.ts +85 -84
- package/lib/components/DateRangePicker.js +18 -6
- package/lib/components/DateRangePicker.js.map +2 -2
- package/lib/components/GroupedSelection.d.ts +84 -84
- package/lib/components/GroupedSelection.js +14 -2
- package/lib/components/GroupedSelection.js.map +2 -2
- package/lib/components/MonthRangePicker.d.ts +85 -84
- package/lib/components/MonthRangePicker.js +16 -6
- package/lib/components/MonthRangePicker.js.map +2 -2
- package/lib/components/Overlay.d.ts +1 -1
- package/lib/components/Overlay.js.map +1 -1
- package/lib/components/Picker.d.ts +1 -0
- package/lib/components/Picker.js +16 -7
- package/lib/components/Picker.js.map +2 -2
- package/lib/components/PickerColumn.d.ts +1 -0
- package/lib/components/PickerColumn.js +21 -18
- package/lib/components/PickerColumn.js.map +2 -2
- package/lib/components/PickerContainer.d.ts +3 -0
- package/lib/components/PickerContainer.js +12 -5
- package/lib/components/PickerContainer.js.map +2 -2
- package/lib/components/PopOverContainer.d.ts +1 -0
- package/lib/components/PopOverContainer.js +5 -3
- package/lib/components/PopOverContainer.js.map +2 -2
- package/lib/components/PopUp.d.ts +1041 -28
- package/lib/components/PopUp.js +32 -8
- package/lib/components/PopUp.js.map +2 -2
- package/lib/components/Rating.d.ts +203 -73
- package/lib/components/Rating.js +147 -31
- package/lib/components/Rating.js.map +2 -2
- package/lib/components/ResultBox.d.ts +85 -84
- package/lib/components/ResultBox.js +9 -4
- package/lib/components/ResultBox.js.map +2 -2
- package/lib/components/ResultList.d.ts +9 -2
- package/lib/components/ResultList.js +22 -2
- package/lib/components/ResultList.js.map +2 -2
- package/lib/components/Select.d.ts +237 -237
- package/lib/components/Select.js +9 -6
- package/lib/components/Select.js.map +2 -2
- package/lib/components/Selection.d.ts +94 -86
- package/lib/components/Selection.js +11 -2
- package/lib/components/Selection.js.map +2 -2
- package/lib/components/Steps.js.map +2 -2
- package/lib/components/TableSelection.d.ts +85 -85
- package/lib/components/TableSelection.js +1 -9
- package/lib/components/TableSelection.js.map +2 -2
- package/lib/components/Tabs.js +31 -33
- package/lib/components/Tabs.js.map +2 -2
- package/lib/components/TabsTransfer.d.ts +87 -256
- package/lib/components/TabsTransfer.js +52 -9
- package/lib/components/TabsTransfer.js.map +2 -2
- package/lib/components/TabsTransferPicker.d.ts +1 -1
- package/lib/components/TabsTransferPicker.js +20 -18
- package/lib/components/TabsTransferPicker.js.map +2 -2
- package/lib/components/Timeline.d.ts +69 -0
- package/lib/components/Timeline.js +16 -0
- package/lib/components/Timeline.js.map +13 -0
- package/lib/components/TimelineItem.d.ts +516 -0
- package/lib/components/TimelineItem.js +41 -0
- package/lib/components/TimelineItem.js.map +13 -0
- package/lib/components/Transfer.d.ts +100 -98
- package/lib/components/Transfer.js +2 -3
- package/lib/components/Transfer.js.map +2 -2
- package/lib/components/TransferDropDown.d.ts +85 -84
- package/lib/components/TransferDropDown.js +9 -10
- package/lib/components/TransferDropDown.js.map +2 -2
- package/lib/components/TransferPicker.d.ts +1 -0
- package/lib/components/TransferPicker.js +19 -4
- package/lib/components/TransferPicker.js.map +2 -2
- package/lib/components/TreeSelection.d.ts +85 -85
- package/lib/components/TreeSelection.js +7 -1
- package/lib/components/TreeSelection.js.map +2 -2
- package/lib/components/calendar/Calendar.d.ts +19 -0
- package/lib/components/calendar/Calendar.js +71 -1
- package/lib/components/calendar/Calendar.js.map +2 -2
- package/lib/components/calendar/DaysView.d.ts +21 -0
- package/lib/components/calendar/DaysView.js +76 -17
- package/lib/components/calendar/DaysView.js.map +2 -2
- package/lib/components/calendar/MonthsView.d.ts +34 -0
- package/lib/components/calendar/MonthsView.js +68 -3
- package/lib/components/calendar/MonthsView.js.map +2 -2
- package/lib/components/calendar/QuartersView.d.ts +1 -0
- package/lib/components/calendar/QuartersView.js +2 -2
- package/lib/components/calendar/QuartersView.js.map +2 -2
- package/lib/components/calendar/TimeView.d.ts +30 -18
- package/lib/components/calendar/TimeView.js +47 -8
- package/lib/components/calendar/TimeView.js.map +2 -2
- package/lib/components/calendar/YearsView.d.ts +6 -0
- package/lib/components/calendar/YearsView.js +21 -10
- package/lib/components/calendar/YearsView.js.map +2 -2
- package/lib/components/condition-builder/Field.js +1 -4
- package/lib/components/condition-builder/Field.js.map +2 -2
- package/lib/components/condition-builder/Func.js +1 -1
- package/lib/components/condition-builder/Func.js.map +2 -2
- package/lib/components/formula/Editor.d.ts +3 -0
- package/lib/components/formula/Editor.js +3 -2
- package/lib/components/formula/Editor.js.map +2 -2
- package/lib/components/formula/FuncList.js +2 -1
- package/lib/components/formula/FuncList.js.map +2 -2
- package/lib/components/formula/Picker.js +1 -1
- package/lib/components/formula/Picker.js.map +2 -2
- package/lib/components/icons.js +4 -0
- package/lib/components/icons.js.map +2 -2
- package/lib/components/index.d.ts +2 -1
- package/lib/components/index.js +4 -2
- package/lib/components/index.js.map +2 -2
- package/lib/components/virtual-list/SizeAndPositionManager.js.map +2 -2
- package/lib/components/virtual-list/index.js +1 -2
- package/lib/components/virtual-list/index.js.map +2 -2
- package/lib/factory.js +5 -0
- package/lib/factory.js.map +2 -2
- package/lib/icons/star.js +12 -0
- package/lib/icons/tree-down.js +7 -0
- 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 +17 -2
- package/lib/locale/de-DE.js.map +2 -2
- package/lib/locale/en-US.js +17 -2
- package/lib/locale/en-US.js.map +2 -2
- package/lib/locale/zh-CN.js +16 -1
- package/lib/locale/zh-CN.js.map +2 -2
- package/lib/renderers/Avatar.d.ts +35 -26
- package/lib/renderers/Avatar.js +14 -19
- package/lib/renderers/Avatar.js.map +2 -2
- package/lib/renderers/CRUD.js +1 -2
- package/lib/renderers/CRUD.js.map +2 -2
- package/lib/renderers/Card.js +6 -5
- package/lib/renderers/Card.js.map +2 -2
- package/lib/renderers/Custom.js.map +2 -2
- package/lib/renderers/DropDownButton.d.ts +11 -2
- package/lib/renderers/DropDownButton.js +30 -12
- package/lib/renderers/DropDownButton.js.map +2 -2
- package/lib/renderers/Each.js +5 -2
- package/lib/renderers/Each.js.map +2 -2
- package/lib/renderers/Flex.js +1 -5
- package/lib/renderers/Flex.js.map +2 -2
- package/lib/renderers/Form/ChartRadios.js.map +2 -2
- package/lib/renderers/Form/Checkboxes.js.map +2 -2
- package/lib/renderers/Form/CityDB.js +526 -2
- package/lib/renderers/Form/CityDB.js.map +2 -2
- package/lib/renderers/Form/DiffEditor.js +2 -1
- package/lib/renderers/Form/DiffEditor.js.map +2 -2
- package/lib/renderers/Form/InputCity.d.ts +85 -84
- package/lib/renderers/Form/InputCity.js +4 -2
- package/lib/renderers/Form/InputCity.js.map +2 -2
- package/lib/renderers/Form/InputColor.d.ts +84 -84
- package/lib/renderers/Form/InputColor.js +6 -2
- package/lib/renderers/Form/InputColor.js.map +2 -2
- package/lib/renderers/Form/InputDate.js +10 -5
- package/lib/renderers/Form/InputDate.js.map +2 -2
- package/lib/renderers/Form/InputDateRange.js +6 -2
- package/lib/renderers/Form/InputDateRange.js.map +2 -2
- package/lib/renderers/Form/InputFormula.d.ts +4 -1
- package/lib/renderers/Form/InputFormula.js +2 -2
- package/lib/renderers/Form/InputFormula.js.map +2 -2
- package/lib/renderers/Form/InputImage.d.ts +1 -0
- package/lib/renderers/Form/InputImage.js +8 -4
- package/lib/renderers/Form/InputImage.js.map +2 -2
- package/lib/renderers/Form/InputMonthRange.js +1 -1
- package/lib/renderers/Form/InputMonthRange.js.map +2 -2
- package/lib/renderers/Form/InputQuarterRange.js +1 -1
- package/lib/renderers/Form/InputQuarterRange.js.map +2 -2
- package/lib/renderers/Form/InputRating.d.ts +37 -0
- package/lib/renderers/Form/InputRating.js +6 -2
- package/lib/renderers/Form/InputRating.js.map +2 -2
- package/lib/renderers/Form/InputYearRange.js +1 -1
- package/lib/renderers/Form/InputYearRange.js.map +2 -2
- package/lib/renderers/Form/Item.d.ts +10 -14
- package/lib/renderers/Form/Item.js +18 -9
- package/lib/renderers/Form/Item.js.map +2 -2
- package/lib/renderers/Form/NestedSelect.d.ts +1 -0
- package/lib/renderers/Form/NestedSelect.js +8 -4
- package/lib/renderers/Form/NestedSelect.js.map +2 -2
- package/lib/renderers/Form/Select.d.ts +2 -0
- package/lib/renderers/Form/Select.js +7 -4
- package/lib/renderers/Form/Select.js.map +2 -2
- package/lib/renderers/Form/TabsTransfer.d.ts +5 -32
- package/lib/renderers/Form/TabsTransfer.js +20 -1
- package/lib/renderers/Form/TabsTransfer.js.map +2 -2
- package/lib/renderers/Form/TabsTransferPicker.d.ts +5 -35
- package/lib/renderers/Form/TabsTransferPicker.js +21 -2
- package/lib/renderers/Form/TabsTransferPicker.js.map +2 -2
- package/lib/renderers/Form/Transfer.d.ts +15 -4
- package/lib/renderers/Form/Transfer.js +55 -18
- package/lib/renderers/Form/Transfer.js.map +2 -2
- package/lib/renderers/Form/TransferPicker.d.ts +3 -32
- package/lib/renderers/Form/TransferPicker.js +1 -1
- package/lib/renderers/Form/TransferPicker.js.map +2 -2
- package/lib/renderers/Form/TreeSelect.js +4 -4
- package/lib/renderers/Form/TreeSelect.js.map +2 -2
- package/lib/renderers/Form/index.js +2 -1
- package/lib/renderers/Form/index.js.map +2 -2
- package/lib/renderers/IFrame.js +0 -2
- package/lib/renderers/IFrame.js.map +2 -2
- package/lib/renderers/Json.js +7 -0
- package/lib/renderers/Json.js.map +2 -2
- package/lib/renderers/Nav.js +4 -1
- package/lib/renderers/Nav.js.map +2 -2
- package/lib/renderers/Remark.d.ts +4 -0
- package/lib/renderers/Remark.js +39 -7
- package/lib/renderers/Remark.js.map +2 -2
- package/lib/renderers/Steps.js +5 -5
- package/lib/renderers/Steps.js.map +2 -2
- package/lib/renderers/Table/TableRow.js +4 -1
- package/lib/renderers/Table/TableRow.js.map +2 -2
- package/lib/renderers/Table/index.js +4 -1
- package/lib/renderers/Table/index.js.map +2 -2
- package/lib/renderers/Tabs.js +1 -1
- package/lib/renderers/Tabs.js.map +2 -2
- package/lib/renderers/Timeline.d.ts +65 -0
- package/lib/renderers/Timeline.js +54 -0
- package/lib/renderers/Timeline.js.map +13 -0
- package/lib/renderers/Video.js.map +2 -2
- package/lib/schemaExtend.js +23 -9
- package/lib/schemaExtend.js.map +2 -2
- package/lib/store/combo.js.map +2 -2
- package/lib/store/formItem.js +6 -6
- package/lib/store/formItem.js.map +2 -2
- package/lib/store/table.js +1 -1
- package/lib/store/table.js.map +2 -2
- package/lib/themes/ang-ie11.css +1018 -67
- package/lib/themes/ang.css +1018 -67
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +1053 -67
- package/lib/themes/antd.css +1053 -67
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +1058 -78
- package/lib/themes/cxd.css +1058 -78
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +1019 -67
- package/lib/themes/dark.css +1019 -67
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default.css +1058 -78
- package/lib/themes/default.css.map +1 -1
- package/lib/utils/RootClose.js +3 -1
- package/lib/utils/RootClose.js.map +2 -2
- package/lib/utils/helper.d.ts +1 -6
- package/lib/utils/helper.js +6 -17
- package/lib/utils/helper.js.map +2 -2
- package/package.json +12 -6
- package/schema.json +3696 -971
- package/scss/_properties.scss +21 -7
- package/scss/components/_avatar.scss +27 -9
- package/scss/components/_calendar.scss +287 -0
- package/scss/components/_card.scss +1 -1
- package/scss/components/_cascader.scss +102 -0
- package/scss/components/_city-area.scss +27 -0
- package/scss/components/_collapse-group.scss +1 -3
- package/scss/components/_dropdown.scss +39 -9
- package/scss/components/_formula.scss +30 -6
- package/scss/components/_modal.scss +18 -0
- package/scss/components/_panel.scss +45 -0
- package/scss/components/_picker-columns.scss +15 -5
- package/scss/components/_popup.scss +42 -15
- package/scss/components/_result-box.scss +31 -0
- package/scss/components/_timeline.scss +198 -0
- package/scss/components/form/_checks.scss +2 -0
- package/scss/components/form/_color.scss +2 -2
- package/scss/components/form/_date-range.scss +1 -1
- package/scss/components/form/_date.scss +46 -1
- package/scss/components/form/_form.scss +168 -0
- package/scss/components/form/_nested-select.scss +3 -0
- package/scss/components/form/_rating.scss +60 -21
- package/scss/components/form/_result-list.scss +2 -0
- package/scss/components/form/_select.scss +32 -3
- package/scss/components/form/_selection.scss +5 -4
- package/scss/components/form/_transfer.scss +3 -0
- package/scss/components/form/_tree-select.scss +1 -1
- package/scss/themes/_antd-variables.scss +42 -0
- package/scss/themes/_common.scss +3 -0
- package/scss/themes/_cxd-variables.scss +51 -2
- package/scss/themes/_dark-variables.scss +1 -0
- package/scss/themes/cxd.scss +0 -12
- package/sdk/ang-ie11.css +1278 -141
- package/sdk/ang.css +1296 -153
- package/sdk/antd-ie11.css +1278 -141
- package/sdk/antd.css +1331 -153
- 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 +1258 -132
- package/sdk/cxd.css +1338 -168
- package/sdk/dark-ie11.css +1278 -141
- package/sdk/dark.css +1297 -153
- package/sdk/exceljs.js +1 -1
- package/sdk/locale/de-DE.js +17 -2
- package/sdk/markdown.js +69 -69
- package/sdk/papaparse.js +1 -1
- package/sdk/renderers/Form/CityDB.js +1 -1
- package/sdk/rest.js +18 -18
- package/sdk/rich-text.js +62 -62
- package/sdk/sdk-ie11.css +1258 -132
- package/sdk/sdk.css +1338 -168
- package/sdk/sdk.js +1242 -1218
- 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 +3 -0
- package/src/components/AssociatedSelection.tsx +5 -1
- package/src/components/Avatar.tsx +253 -0
- package/src/components/BaiduMapPicker.tsx +19 -14
- package/src/components/CalendarMobile.tsx +563 -0
- package/src/components/Card.tsx +2 -2
- package/src/components/Cascader.tsx +564 -0
- package/src/components/ChainedSelection.tsx +16 -3
- package/src/components/CityArea.tsx +315 -0
- package/src/components/Collapse.tsx +1 -1
- package/src/components/ColorPicker.tsx +41 -40
- package/src/components/DatePicker.tsx +54 -38
- package/src/components/DateRangePicker.tsx +83 -29
- package/src/components/GroupedSelection.tsx +14 -2
- package/src/components/MonthRangePicker.tsx +76 -30
- package/src/components/Overlay.tsx +1 -1
- package/src/components/Picker.tsx +55 -35
- package/src/components/PickerColumn.tsx +43 -36
- package/src/components/PickerContainer.tsx +13 -1
- package/src/components/PopOverContainer.tsx +31 -17
- package/src/components/PopUp.tsx +84 -57
- package/src/components/Rating.tsx +235 -47
- package/src/components/ResultBox.tsx +14 -2
- package/src/components/ResultList.tsx +36 -6
- package/src/components/Select.tsx +20 -23
- package/src/components/Selection.tsx +21 -3
- package/src/components/Steps.tsx +23 -10
- package/src/components/TableSelection.tsx +1 -44
- package/src/components/Tabs.tsx +65 -54
- package/src/components/TabsTransfer.tsx +78 -9
- package/src/components/TabsTransferPicker.tsx +25 -13
- package/src/components/Timeline.tsx +31 -0
- package/src/components/TimelineItem.tsx +107 -0
- package/src/components/Transfer.tsx +11 -8
- package/src/components/TransferDropDown.tsx +20 -12
- package/src/components/TransferPicker.tsx +25 -4
- package/src/components/TreeSelection.tsx +7 -1
- package/src/components/calendar/Calendar.tsx +101 -4
- package/src/components/calendar/DaysView.tsx +165 -33
- package/src/components/calendar/MonthsView.tsx +108 -1
- package/src/components/calendar/QuartersView.tsx +3 -2
- package/src/components/calendar/TimeView.tsx +104 -41
- package/src/components/calendar/YearsView.tsx +34 -17
- package/src/components/condition-builder/Field.tsx +1 -3
- package/src/components/condition-builder/Func.tsx +1 -1
- package/src/components/formula/Editor.tsx +16 -11
- package/src/components/formula/FuncList.tsx +3 -1
- package/src/components/formula/Picker.tsx +2 -1
- package/src/components/icons.tsx +4 -0
- package/src/components/index.tsx +2 -0
- package/src/components/virtual-list/SizeAndPositionManager.ts +6 -3
- package/src/components/virtual-list/index.tsx +4 -6
- package/src/factory.tsx +6 -0
- package/src/icons/star.svg +12 -0
- package/src/icons/tree-down.svg +5 -0
- package/src/index.tsx +1 -0
- package/src/locale/de-DE.ts +17 -2
- package/src/locale/en-US.ts +17 -2
- package/src/locale/zh-CN.ts +16 -1
- package/src/renderers/Avatar.tsx +83 -74
- package/src/renderers/CRUD.tsx +1 -3
- package/src/renderers/Card.tsx +10 -6
- package/src/renderers/Custom.tsx +6 -3
- package/src/renderers/DropDownButton.tsx +69 -35
- package/src/renderers/Each.tsx +4 -4
- package/src/renderers/Flex.tsx +3 -7
- package/src/renderers/Form/ChartRadios.tsx +2 -7
- package/src/renderers/Form/Checkboxes.tsx +1 -1
- package/src/renderers/Form/CityDB.ts +526 -2
- package/src/renderers/Form/DiffEditor.tsx +2 -3
- package/src/renderers/Form/InputCity.tsx +23 -3
- package/src/renderers/Form/InputColor.tsx +21 -2
- package/src/renderers/Form/InputDate.tsx +48 -20
- package/src/renderers/Form/InputDateRange.tsx +9 -2
- package/src/renderers/Form/InputFormula.tsx +9 -4
- package/src/renderers/Form/InputImage.tsx +9 -4
- package/src/renderers/Form/InputMonthRange.tsx +0 -1
- package/src/renderers/Form/InputQuarterRange.tsx +0 -1
- package/src/renderers/Form/InputRating.tsx +66 -3
- package/src/renderers/Form/InputYearRange.tsx +0 -1
- package/src/renderers/Form/Item.tsx +29 -8
- package/src/renderers/Form/NestedSelect.tsx +32 -4
- package/src/renderers/Form/Select.tsx +15 -3
- package/src/renderers/Form/TabsTransfer.tsx +28 -38
- package/src/renderers/Form/TabsTransferPicker.tsx +28 -46
- package/src/renderers/Form/Transfer.tsx +75 -24
- package/src/renderers/Form/TransferPicker.tsx +6 -38
- package/src/renderers/Form/TreeSelect.tsx +18 -16
- package/src/renderers/Form/index.tsx +2 -1
- package/src/renderers/IFrame.tsx +0 -2
- package/src/renderers/Json.tsx +5 -0
- package/src/renderers/Nav.tsx +4 -1
- package/src/renderers/Remark.tsx +68 -18
- package/src/renderers/Steps.tsx +11 -13
- package/src/renderers/Table/TableRow.tsx +3 -1
- package/src/renderers/Table/index.tsx +7 -1
- package/src/renderers/Tabs.tsx +6 -2
- package/src/renderers/Timeline.tsx +141 -0
- package/src/renderers/Video.tsx +4 -20
- package/src/schemaExtend.ts +22 -10
- package/src/store/combo.ts +1 -3
- package/src/store/formItem.ts +2 -2
- package/src/store/table.ts +2 -1
- package/src/utils/RootClose.ts +5 -1
- package/src/utils/helper.ts +6 -16
@@ -9,6 +9,7 @@ var icons_1 = require("./icons");
|
|
9
9
|
var Input_1 = (0, tslib_1.__importDefault)(require("./Input"));
|
10
10
|
var helper_1 = require("../utils/helper");
|
11
11
|
var locale_1 = require("../locale");
|
12
|
+
var isPlainObject = require("lodash/isPlainObject");
|
12
13
|
var ResultBox = /** @class */ (function (_super) {
|
13
14
|
(0, tslib_1.__extends)(ResultBox, _super);
|
14
15
|
function ResultBox() {
|
@@ -62,20 +63,22 @@ var ResultBox = /** @class */ (function (_super) {
|
|
62
63
|
ResultBox.prototype.render = function () {
|
63
64
|
var _a;
|
64
65
|
var _this = this;
|
65
|
-
var _b = this.props, className = _b.className, cx = _b.classnames, classPrefix = _b.classPrefix, clearable = _b.clearable, disabled = _b.disabled, hasError = _b.hasError, result = _b.result, value = _b.value, placeholder = _b.placeholder, children = _b.children, itemRender = _b.itemRender, allowInput = _b.allowInput, inputPlaceholder = _b.inputPlaceholder, onResultChange = _b.onResultChange, onChange = _b.onChange, onResultClick = _b.onResultClick, __ = _b.translate, locale = _b.locale, onKeyPress = _b.onKeyPress, onFocus = _b.onFocus, onBlur = _b.onBlur, borderMode = _b.borderMode, rest = (0, tslib_1.__rest)(_b, ["className", "classnames", "classPrefix", "clearable", "disabled", "hasError", "result", "value", "placeholder", "children", "itemRender", "allowInput", "inputPlaceholder", "onResultChange", "onChange", "onResultClick", "translate", "locale", "onKeyPress", "onFocus", "onBlur", "borderMode"]);
|
66
|
+
var _b = this.props, className = _b.className, cx = _b.classnames, classPrefix = _b.classPrefix, clearable = _b.clearable, disabled = _b.disabled, hasError = _b.hasError, result = _b.result, value = _b.value, placeholder = _b.placeholder, children = _b.children, itemRender = _b.itemRender, allowInput = _b.allowInput, inputPlaceholder = _b.inputPlaceholder, onResultChange = _b.onResultChange, onChange = _b.onChange, onResultClick = _b.onResultClick, __ = _b.translate, locale = _b.locale, onKeyPress = _b.onKeyPress, onFocus = _b.onFocus, onBlur = _b.onBlur, borderMode = _b.borderMode, useMobileUI = _b.useMobileUI, rest = (0, tslib_1.__rest)(_b, ["className", "classnames", "classPrefix", "clearable", "disabled", "hasError", "result", "value", "placeholder", "children", "itemRender", "allowInput", "inputPlaceholder", "onResultChange", "onChange", "onResultClick", "translate", "locale", "onKeyPress", "onFocus", "onBlur", "borderMode", "useMobileUI"]);
|
66
67
|
var isFocused = this.state.isFocused;
|
68
|
+
var mobileUI = useMobileUI && (0, helper_1.isMobile)();
|
67
69
|
return (react_1.default.createElement("div", { className: cx('ResultBox', className, (_a = {
|
68
70
|
'is-focused': isFocused,
|
69
71
|
'is-disabled': disabled,
|
70
72
|
'is-error': hasError,
|
71
|
-
'is-clickable': onResultClick
|
73
|
+
'is-clickable': onResultClick,
|
74
|
+
'is-mobile': mobileUI
|
72
75
|
},
|
73
76
|
_a["ResultBox--border" + (0, helper_1.ucFirst)(borderMode)] = borderMode,
|
74
77
|
_a)), onClick: onResultClick, tabIndex: !allowInput && !disabled && onFocus ? 0 : -1, onKeyPress: allowInput ? undefined : onKeyPress, onFocus: allowInput ? undefined : onFocus, onBlur: allowInput ? undefined : onBlur },
|
75
78
|
Array.isArray(result) && result.length ? (result.map(function (item, index) { return (react_1.default.createElement("div", { className: cx('ResultBox-value'), key: index },
|
76
79
|
react_1.default.createElement("span", { className: cx('ResultBox-valueLabel') }, itemRender(item)),
|
77
80
|
!disabled ? (react_1.default.createElement("a", { "data-index": index, onClick: _this.removeItem },
|
78
|
-
react_1.default.createElement(icons_1.Icon, { icon: "close", className: "icon" }))) : null)); })) : result && !Array.isArray(result) ? (react_1.default.createElement("span", { className: cx('ResultBox-singleValue') }, result)) : allowInput && !disabled ? null : (react_1.default.createElement("span", { className: cx('ResultBox-placeholder') }, __(placeholder || 'placeholder.noData'))),
|
81
|
+
react_1.default.createElement(icons_1.Icon, { icon: "close", className: "icon" }))) : null)); })) : result && !Array.isArray(result) ? (react_1.default.createElement("span", { className: cx('ResultBox-singleValue') }, isPlainObject(result) ? itemRender(result) : result)) : allowInput && !disabled ? null : (react_1.default.createElement("span", { className: cx('ResultBox-placeholder') }, __(placeholder || 'placeholder.noData'))),
|
79
82
|
allowInput && !disabled ? (react_1.default.createElement(Input_1.default, (0, tslib_1.__assign)({}, rest, { onKeyPress: onKeyPress, ref: this.inputRef, value: value || '', onChange: this.handleChange, placeholder: __(Array.isArray(result) && result.length
|
80
83
|
? inputPlaceholder
|
81
84
|
: placeholder), onFocus: this.handleFocus, onBlur: this.handleBlur }))) : null,
|
@@ -83,7 +86,9 @@ var ResultBox = /** @class */ (function (_super) {
|
|
83
86
|
clearable &&
|
84
87
|
!disabled &&
|
85
88
|
(Array.isArray(result) ? result.length : result) ? (react_1.default.createElement("a", { onClick: this.clearValue, className: cx('ResultBox-clear') },
|
86
|
-
react_1.default.createElement(icons_1.Icon, { icon: "close", className: "icon" }))) : null
|
89
|
+
react_1.default.createElement(icons_1.Icon, { icon: "close", className: "icon" }))) : null,
|
90
|
+
!allowInput && mobileUI ? (react_1.default.createElement("span", { className: cx('ResultBox-arrow') },
|
91
|
+
react_1.default.createElement(icons_1.Icon, { icon: "caret", className: "icon" }))) : null));
|
87
92
|
};
|
88
93
|
var _a, _b, _c;
|
89
94
|
ResultBox.defaultProps = {
|
@@ -6,8 +6,8 @@
|
|
6
6
|
"/src/components/ResultBox.tsx"
|
7
7
|
],
|
8
8
|
"names": [],
|
9
|
-
"mappings": ";;;;AAAA,kCAA+C;AAC/C,6DAA0B;AAE1B,iDAA8C;AAC9C,iCAA6B;AAC7B,+DAA4B;AAC5B,
|
9
|
+
"mappings": ";;;;AAAA,kCAA+C;AAC/C,6DAA0B;AAE1B,iDAA8C;AAC9C,iCAA6B;AAC7B,+DAA4B;AAC5B,0CAA4D;AAC5D,oCAAkD;AAClD,oDAAuD;AAgBvD;IAA+B,0CAA+B;IAA9D;QAAA,qEA6KC;QAhKC,WAAK,GAAG;YACN,SAAS,EAAE,KAAK;SACjB,CAAC;QAEF,cAAQ,GAAyB,eAAK,CAAC,SAAS,EAAE,CAAC;;IA4JrD,CAAC;IA1JC,yBAAK,GAAL;;QACE,MAAA,IAAI,CAAC,QAA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AAK;QAChB,WAAW,EAAE,oBAAoB;QACjC,gBAAgB,EAAE,mBAAmB;QACrC,UAAU,EAAE,UAAC,MAAW,IAAK,OAAA,CAC3B,4CAAO,MAAG,MAAM,CAAC,UAAU,IAAI,EAAE,IAAG,MAAM,CAAC,KAAO,CAAQ,CAC3D,EAF4B,CAE5B;KACF,CAAC;IAiBF;QADC,iBAAQ;;0EACK,eAAK,oBAAL,eAAK,CAAC,UAAU;;+CAI7B;IAGD;QADC,iBAAQ;;;;gDAOR;IAGD;QADC,iBAAQ;;;;+CAOR;IAGD;QADC,iBAAQ;;0EACK,eAAK,oBAAL,eAAK,CAAC,UAAU;;+CAS7B;IAGD;QADC,iBAAQ;;0EACO,eAAK,oBAAL,eAAK,CAAC,WAAW;;iDAGhC;IAyGH,gBAAC;CAAA,AA7KD,CAA+B,eAAK,CAAC,SAAS,GA6K7C;AA7KY,8BAAS;AA+KtB,kBAAe,IAAA,iBAAS,EACtB,IAAA,mBAAU,EACR,IAAA,+BAAc,EAAC,SAAS,EAAE;IACxB,KAAK,EAAE,UAAU;IACjB,MAAM,EAAE,gBAAgB;CACzB,CAAC,CACH,CACF,CAAC",
|
10
10
|
"sourcesContent": [
|
11
|
-
"import {ThemeProps, themeable} from '../theme';\nimport React from 'react';\nimport {InputBoxProps} from './InputBox';\nimport {uncontrollable} from 'uncontrollable';\nimport {Icon} from './icons';\nimport Input from './Input';\nimport {autobind, ucFirst} from '../utils/helper';\nimport {LocaleProps, localeable} from '../locale';\n\nexport interface ResultBoxProps\n extends ThemeProps,\n LocaleProps,\n Omit<InputBoxProps, 'result' | 'prefix' | 'onChange' | 'translate'> {\n onChange?: (value: string) => void;\n onResultClick?: (e: React.MouseEvent<HTMLElement>) => void;\n result?: Array<any> | any;\n itemRender: (value: any) => JSX.Element | string;\n onResultChange?: (value: Array<any>) => void;\n allowInput?: boolean;\n inputPlaceholder: string;\n}\n\nexport class ResultBox extends React.Component<ResultBoxProps> {\n static defaultProps: Pick<\n ResultBoxProps,\n 'clearable' | 'placeholder' | 'itemRender' | 'inputPlaceholder'\n > = {\n clearable: false,\n placeholder: 'placeholder.noData',\n inputPlaceholder: 'placeholder.enter',\n itemRender: (option: any) => (\n <span>{`${option.scopeLabel || ''}${option.label}`}</span>\n )\n };\n\n state = {\n isFocused: false\n };\n\n inputRef: React.RefObject<any> = React.createRef();\n\n focus() {\n this.inputRef.current?.focus();\n }\n\n blur() {\n this.inputRef.current?.blur();\n }\n\n @autobind\n clearValue(e: React.MouseEvent<any>) {\n e.preventDefault();\n const onResultChange = this.props.onResultChange;\n onResultChange && onResultChange([]);\n }\n\n @autobind\n handleFocus(e: any) {\n const onFocus = this.props.onFocus;\n onFocus && onFocus(e);\n this.setState({\n isFocused: true\n });\n }\n\n @autobind\n handleBlur(e: any) {\n const onBlur = this.props.onBlur;\n onBlur && onBlur(e);\n this.setState({\n isFocused: false\n });\n }\n\n @autobind\n removeItem(e: React.MouseEvent<HTMLElement>) {\n e.stopPropagation();\n e.preventDefault();\n\n const {result, onResultChange} = this.props;\n const index = parseInt(e.currentTarget.getAttribute('data-index')!, 10);\n const newResult = Array.isArray(result) ? result.concat() : [];\n newResult.splice(index, 1);\n onResultChange && onResultChange(newResult);\n }\n\n @autobind\n handleChange(e: React.ChangeEvent<HTMLInputElement>) {\n const {onChange} = this.props;\n onChange?.(e.currentTarget.value);\n }\n\n render() {\n const {\n className,\n classnames: cx,\n classPrefix,\n clearable,\n disabled,\n hasError,\n result,\n value,\n placeholder,\n children,\n itemRender,\n allowInput,\n inputPlaceholder,\n onResultChange,\n onChange,\n onResultClick,\n translate: __,\n locale,\n onKeyPress,\n onFocus,\n onBlur,\n borderMode,\n ...rest\n } = this.props;\n const isFocused = this.state.isFocused;\n\n return (\n <div\n className={cx('ResultBox', className, {\n 'is-focused': isFocused,\n 'is-disabled': disabled,\n 'is-error': hasError,\n 'is-clickable': onResultClick,\n [`ResultBox--border${ucFirst(borderMode)}`]: borderMode\n })}\n onClick={onResultClick}\n tabIndex={!allowInput && !disabled && onFocus ? 0 : -1}\n onKeyPress={allowInput ? undefined : onKeyPress}\n onFocus={allowInput ? undefined : onFocus}\n onBlur={allowInput ? undefined : onBlur}\n >\n {Array.isArray(result) && result.length ? (\n result.map((item, index) => (\n <div className={cx('ResultBox-value')} key={index}>\n <span className={cx('ResultBox-valueLabel')}>\n {itemRender(item)}\n </span>\n {!disabled ? (\n <a data-index={index} onClick={this.removeItem}>\n <Icon icon=\"close\" className=\"icon\" />\n </a>\n ) : null}\n </div>\n ))\n ) : result && !Array.isArray(result) ? (\n <span className={cx('ResultBox-singleValue')}
|
11
|
+
"import {ThemeProps, themeable} from '../theme';\nimport React from 'react';\nimport {InputBoxProps} from './InputBox';\nimport {uncontrollable} from 'uncontrollable';\nimport {Icon} from './icons';\nimport Input from './Input';\nimport {autobind, isMobile, ucFirst} from '../utils/helper';\nimport {LocaleProps, localeable} from '../locale';\nimport isPlainObject = require('lodash/isPlainObject');\n\nexport interface ResultBoxProps\n extends ThemeProps,\n LocaleProps,\n Omit<InputBoxProps, 'result' | 'prefix' | 'onChange' | 'translate'> {\n onChange?: (value: string) => void;\n onResultClick?: (e: React.MouseEvent<HTMLElement>) => void;\n result?: Array<any> | any;\n itemRender: (value: any) => JSX.Element | string;\n onResultChange?: (value: Array<any>) => void;\n allowInput?: boolean;\n inputPlaceholder: string;\n useMobileUI?: boolean;\n}\n\nexport class ResultBox extends React.Component<ResultBoxProps> {\n static defaultProps: Pick<\n ResultBoxProps,\n 'clearable' | 'placeholder' | 'itemRender' | 'inputPlaceholder'\n > = {\n clearable: false,\n placeholder: 'placeholder.noData',\n inputPlaceholder: 'placeholder.enter',\n itemRender: (option: any) => (\n <span>{`${option.scopeLabel || ''}${option.label}`}</span>\n )\n };\n\n state = {\n isFocused: false\n };\n\n inputRef: React.RefObject<any> = React.createRef();\n\n focus() {\n this.inputRef.current?.focus();\n }\n\n blur() {\n this.inputRef.current?.blur();\n }\n\n @autobind\n clearValue(e: React.MouseEvent<any>) {\n e.preventDefault();\n const onResultChange = this.props.onResultChange;\n onResultChange && onResultChange([]);\n }\n\n @autobind\n handleFocus(e: any) {\n const onFocus = this.props.onFocus;\n onFocus && onFocus(e);\n this.setState({\n isFocused: true\n });\n }\n\n @autobind\n handleBlur(e: any) {\n const onBlur = this.props.onBlur;\n onBlur && onBlur(e);\n this.setState({\n isFocused: false\n });\n }\n\n @autobind\n removeItem(e: React.MouseEvent<HTMLElement>) {\n e.stopPropagation();\n e.preventDefault();\n\n const {result, onResultChange} = this.props;\n const index = parseInt(e.currentTarget.getAttribute('data-index')!, 10);\n const newResult = Array.isArray(result) ? result.concat() : [];\n newResult.splice(index, 1);\n onResultChange && onResultChange(newResult);\n }\n\n @autobind\n handleChange(e: React.ChangeEvent<HTMLInputElement>) {\n const {onChange} = this.props;\n onChange?.(e.currentTarget.value);\n }\n\n render() {\n const {\n className,\n classnames: cx,\n classPrefix,\n clearable,\n disabled,\n hasError,\n result,\n value,\n placeholder,\n children,\n itemRender,\n allowInput,\n inputPlaceholder,\n onResultChange,\n onChange,\n onResultClick,\n translate: __,\n locale,\n onKeyPress,\n onFocus,\n onBlur,\n borderMode,\n useMobileUI,\n ...rest\n } = this.props;\n const isFocused = this.state.isFocused;\n const mobileUI = useMobileUI && isMobile();\n\n return (\n <div\n className={cx('ResultBox', className, {\n 'is-focused': isFocused,\n 'is-disabled': disabled,\n 'is-error': hasError,\n 'is-clickable': onResultClick,\n 'is-mobile': mobileUI,\n [`ResultBox--border${ucFirst(borderMode)}`]: borderMode\n })}\n onClick={onResultClick}\n tabIndex={!allowInput && !disabled && onFocus ? 0 : -1}\n onKeyPress={allowInput ? undefined : onKeyPress}\n onFocus={allowInput ? undefined : onFocus}\n onBlur={allowInput ? undefined : onBlur}\n >\n {Array.isArray(result) && result.length ? (\n result.map((item, index) => (\n <div className={cx('ResultBox-value')} key={index}>\n <span className={cx('ResultBox-valueLabel')}>\n {itemRender(item)}\n </span>\n {!disabled ? (\n <a data-index={index} onClick={this.removeItem}>\n <Icon icon=\"close\" className=\"icon\" />\n </a>\n ) : null}\n </div>\n ))\n ) : result && !Array.isArray(result) ? (\n <span className={cx('ResultBox-singleValue')}>\n {isPlainObject(result) ? itemRender(result) : result}\n </span>\n ) : allowInput && !disabled ? null : (\n <span className={cx('ResultBox-placeholder')}>\n {__(placeholder || 'placeholder.noData')}\n </span>\n )}\n\n {allowInput && !disabled ? (\n <Input\n {...rest}\n onKeyPress={onKeyPress}\n ref={this.inputRef}\n value={value || ''}\n onChange={this.handleChange}\n placeholder={__(\n Array.isArray(result) && result.length\n ? inputPlaceholder\n : placeholder\n )}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n />\n ) : null}\n\n {children}\n\n {clearable &&\n !disabled &&\n (Array.isArray(result) ? result.length : result) ? (\n <a onClick={this.clearValue} className={cx('ResultBox-clear')}>\n <Icon icon=\"close\" className=\"icon\" />\n </a>\n ) : null}\n {!allowInput && mobileUI ? (\n <span className={cx('ResultBox-arrow')}>\n <Icon icon=\"caret\" className=\"icon\" />\n </span>\n ) : null}\n </div>\n );\n }\n}\n\nexport default themeable(\n localeable(\n uncontrollable(ResultBox, {\n value: 'onChange',\n result: 'onResultChange'\n })\n )\n);\n"
|
12
12
|
]
|
13
13
|
}
|
@@ -10,15 +10,21 @@ import { LocaleProps } from '../locale';
|
|
10
10
|
export interface ResultListProps extends ThemeProps, LocaleProps {
|
11
11
|
className?: string;
|
12
12
|
value?: Array<Option>;
|
13
|
-
onChange?: (value: Array<Option
|
13
|
+
onChange?: (value: Array<Option>, optionModified?: boolean) => void;
|
14
14
|
sortable?: boolean;
|
15
15
|
disabled?: boolean;
|
16
16
|
title?: string;
|
17
17
|
placeholder: string;
|
18
|
-
itemRender: (option: Option) => JSX.Element;
|
18
|
+
itemRender: (option: Option, states: ItemRenderStates) => JSX.Element;
|
19
19
|
itemClassName?: string;
|
20
20
|
}
|
21
|
+
export interface ItemRenderStates {
|
22
|
+
index: number;
|
23
|
+
disabled?: boolean;
|
24
|
+
onChange: (value: any, name: string) => void;
|
25
|
+
}
|
21
26
|
export declare class ResultList extends React.Component<ResultListProps> {
|
27
|
+
static itemRender(option: any): JSX.Element;
|
22
28
|
static defaultProps: Pick<ResultListProps, 'placeholder' | 'itemRender'>;
|
23
29
|
id: string;
|
24
30
|
sortable?: Sortable;
|
@@ -28,6 +34,7 @@ export declare class ResultList extends React.Component<ResultListProps> {
|
|
28
34
|
handleRemove(e: React.MouseEvent<HTMLElement>): void;
|
29
35
|
initSortable(): void;
|
30
36
|
desposeSortable(): void;
|
37
|
+
handleValueChange(index: number, value: any, name: string): void;
|
31
38
|
render(): JSX.Element;
|
32
39
|
}
|
33
40
|
declare const _default: {
|
@@ -19,6 +19,9 @@ var ResultList = /** @class */ (function (_super) {
|
|
19
19
|
_this.id = (0, helper_1.guid)();
|
20
20
|
return _this;
|
21
21
|
}
|
22
|
+
ResultList.itemRender = function (option) {
|
23
|
+
return react_1.default.createElement("span", null, "" + (option.scopeLabel || '') + option.label);
|
24
|
+
};
|
22
25
|
ResultList.prototype.componentDidMount = function () {
|
23
26
|
this.props.sortable && this.initSortable();
|
24
27
|
};
|
@@ -89,6 +92,19 @@ var ResultList = /** @class */ (function (_super) {
|
|
89
92
|
(_a = this.sortable) === null || _a === void 0 ? void 0 : _a.destroy();
|
90
93
|
delete this.sortable;
|
91
94
|
};
|
95
|
+
ResultList.prototype.handleValueChange = function (index, value, name) {
|
96
|
+
var _a;
|
97
|
+
if (typeof name !== 'string') {
|
98
|
+
return;
|
99
|
+
}
|
100
|
+
var _b = this.props, list = _b.value, onChange = _b.onChange;
|
101
|
+
var result = Array.isArray(list) ? list.concat() : [];
|
102
|
+
if (!result[index]) {
|
103
|
+
return;
|
104
|
+
}
|
105
|
+
result.splice(index, 1, (0, tslib_1.__assign)((0, tslib_1.__assign)({}, result[index]), (_a = {}, _a[name] = value, _a)));
|
106
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(result, true);
|
107
|
+
};
|
92
108
|
ResultList.prototype.render = function () {
|
93
109
|
var _this = this;
|
94
110
|
var _a = this.props, cx = _a.classnames, className = _a.className, value = _a.value, placeholder = _a.placeholder, itemRender = _a.itemRender, disabled = _a.disabled, title = _a.title, itemClassName = _a.itemClassName, sortable = _a.sortable, __ = _a.translate;
|
@@ -96,14 +112,18 @@ var ResultList = /** @class */ (function (_super) {
|
|
96
112
|
title ? react_1.default.createElement("div", { className: cx('Selections-title') }, title) : null,
|
97
113
|
Array.isArray(value) && value.length ? (react_1.default.createElement("div", { className: cx('Selections-items') }, value.map(function (option, index) { return (react_1.default.createElement("div", { className: cx('Selections-item', itemClassName, option === null || option === void 0 ? void 0 : option.className), key: index },
|
98
114
|
sortable && !disabled && value.length > 1 ? (react_1.default.createElement(icons_1.Icon, { className: cx('Selections-dragbar icon'), icon: "drag-bar" })) : null,
|
99
|
-
react_1.default.createElement("label", null, itemRender(option
|
115
|
+
react_1.default.createElement("label", null, itemRender(option, {
|
116
|
+
index: index,
|
117
|
+
disabled: disabled,
|
118
|
+
onChange: _this.handleValueChange.bind(_this, index)
|
119
|
+
})),
|
100
120
|
!disabled ? (react_1.default.createElement("a", { className: cx('Selections-delBtn'), "data-index": index, onClick: _this.handleRemove },
|
101
121
|
react_1.default.createElement(icons_1.Icon, { icon: "close", className: "icon" }))) : null)); }))) : (react_1.default.createElement("div", { className: cx('Selections-placeholder') }, __(placeholder)))));
|
102
122
|
};
|
103
123
|
var _a;
|
104
124
|
ResultList.defaultProps = {
|
105
125
|
placeholder: 'placeholder.selectData',
|
106
|
-
itemRender:
|
126
|
+
itemRender: ResultList.itemRender
|
107
127
|
};
|
108
128
|
(0, tslib_1.__decorate)([
|
109
129
|
helper_1.autobind,
|
@@ -6,8 +6,8 @@
|
|
6
6
|
"/src/components/ResultList.tsx"
|
7
7
|
],
|
8
8
|
"names": [],
|
9
|
-
"mappings": ";;;;AAAA;;GAEG;AACH,6DAA0B;AAE1B,kCAA+C;AAC/C,iCAA6B;AAC7B,0CAA+C;AA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,CACX,qCACE,SAAS,EAAE,EAAE,CAAC,mBAAmB,CAAC,gBACtB,KAAK,EACjB,OAAO,EAAE,KAAI,CAAC,YAAY;oBAE1B,8BAAC,YAAI,IAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,MAAM,GAAG,CACpC,CACL,CAAC,CAAC,CAAC,IAAI,CACJ,CACP,EAlC6B,CAkC7B,CAAC,CACE,CACP,CAAC,CAAC,CAAC,CACF,uCAAK,SAAS,EAAE,EAAE,CAAC,wBAAwB,CAAC,IAAG,EAAE,CAAC,WAAW,CAAC,CAAO,CACtE,CACG,CACP,CAAC;IACJ,CAAC;;IAvKM,uBAAY,GAAwD;QACzE,WAAW,EAAE,wBAAwB;QACrC,UAAU,EAAE,UAAU,CAAC,UAAU;KAClC,CAAC;IAsBF;QADC,iBAAQ;;0EACO,eAAK,oBAAL,eAAK,CAAC,UAAU;;kDAW/B;IAoIH,iBAAC;CAAA,AA5KD,CAAgC,eAAK,CAAC,SAAS,GA4K9C;AA5KY,gCAAU;AA8KvB,kBAAe,IAAA,iBAAS,EAAC,IAAA,mBAAU,EAAC,UAAU,CAAC,CAAC,CAAC",
|
10
10
|
"sourcesContent": [
|
11
|
-
"/**\n * 用来显示选择结果,垂直显示。支持移出、排序等操作。\n */\nimport React from 'react';\nimport {Option} from './Select';\nimport {ThemeProps, themeable} from '../theme';\nimport {Icon} from './icons';\nimport {autobind, guid} from '../utils/helper';\nimport Sortable from 'sortablejs';\nimport {findDOMNode} from 'react-dom';\nimport {LocaleProps, localeable} from '../locale';\n\nexport interface ResultListProps extends ThemeProps, LocaleProps {\n className?: string;\n value?: Array<Option>;\n onChange?: (value: Array<Option
|
11
|
+
"/**\n * 用来显示选择结果,垂直显示。支持移出、排序等操作。\n */\nimport React from 'react';\nimport {Option} from './Select';\nimport {ThemeProps, themeable} from '../theme';\nimport {Icon} from './icons';\nimport {autobind, guid} from '../utils/helper';\nimport Sortable from 'sortablejs';\nimport {findDOMNode} from 'react-dom';\nimport {LocaleProps, localeable} from '../locale';\n\nexport interface ResultListProps extends ThemeProps, LocaleProps {\n className?: string;\n value?: Array<Option>;\n onChange?: (value: Array<Option>, optionModified?: boolean) => void;\n sortable?: boolean;\n disabled?: boolean;\n title?: string;\n placeholder: string;\n itemRender: (option: Option, states: ItemRenderStates) => JSX.Element;\n itemClassName?: string;\n}\n\nexport interface ItemRenderStates {\n index: number;\n disabled?: boolean;\n onChange: (value: any, name: string) => void;\n}\n\nexport class ResultList extends React.Component<ResultListProps> {\n static itemRender(option: any) {\n return <span>{`${option.scopeLabel || ''}${option.label}`}</span>;\n }\n static defaultProps: Pick<ResultListProps, 'placeholder' | 'itemRender'> = {\n placeholder: 'placeholder.selectData',\n itemRender: ResultList.itemRender\n };\n\n id = guid();\n sortable?: Sortable;\n\n componentDidMount() {\n this.props.sortable && this.initSortable();\n }\n\n componentDidUpdate() {\n if (this.props.sortable) {\n this.sortable || this.initSortable();\n } else {\n this.desposeSortable();\n }\n }\n\n componentWillUnmount() {\n this.desposeSortable();\n }\n\n @autobind\n handleRemove(e: React.MouseEvent<HTMLElement>) {\n const index = parseInt(e.currentTarget.getAttribute('data-index')!, 10);\n const {value, onChange} = this.props;\n\n if (!Array.isArray(value)) {\n return;\n }\n\n const newValue = value.concat();\n newValue.splice(index, 1);\n onChange?.(newValue);\n }\n\n initSortable() {\n const ns = this.props.classPrefix;\n const dom = findDOMNode(this) as HTMLElement;\n const container = dom.querySelector(\n `.${ns}Selections-items`\n ) as HTMLElement;\n\n if (!container) {\n return;\n }\n\n this.sortable = new Sortable(container, {\n group: `selections-${this.id}`,\n animation: 150,\n handle: `.${ns}Selections-dragbar`,\n ghostClass: `${ns}Selections-item--dragging`,\n onEnd: (e: any) => {\n // 没有移动\n if (e.newIndex === e.oldIndex) {\n return;\n }\n\n // 换回来\n const parent = e.to as HTMLElement;\n if (\n e.newIndex < e.oldIndex &&\n e.oldIndex < parent.childNodes.length - 1\n ) {\n parent.insertBefore(e.item, parent.childNodes[e.oldIndex + 1]);\n } else if (e.oldIndex < parent.childNodes.length - 1) {\n parent.insertBefore(e.item, parent.childNodes[e.oldIndex]);\n } else {\n parent.appendChild(e.item);\n }\n\n const value = this.props.value;\n if (!Array.isArray(value)) {\n return;\n }\n const newValue = value.concat();\n newValue.splice(e.newIndex, 0, newValue.splice(e.oldIndex, 1)[0]);\n this.props.onChange?.(newValue);\n }\n });\n }\n\n desposeSortable() {\n this.sortable?.destroy();\n delete this.sortable;\n }\n\n handleValueChange(index: number, value: any, name: string) {\n if (typeof name !== 'string') {\n return;\n }\n const {value: list, onChange} = this.props;\n\n const result = Array.isArray(list) ? list.concat() : [];\n if (!result[index]) {\n return;\n }\n result.splice(index, 1, {\n ...result[index],\n [name]: value\n });\n onChange?.(result, true);\n }\n\n render() {\n const {\n classnames: cx,\n className,\n value,\n placeholder,\n itemRender,\n disabled,\n title,\n itemClassName,\n sortable,\n translate: __\n } = this.props;\n\n return (\n <div className={cx('Selections', className)}>\n {title ? <div className={cx('Selections-title')}>{title}</div> : null}\n\n {Array.isArray(value) && value.length ? (\n <div className={cx('Selections-items')}>\n {value.map((option, index) => (\n <div\n className={cx(\n 'Selections-item',\n itemClassName,\n option?.className\n )}\n key={index}\n >\n {sortable && !disabled && value.length > 1 ? (\n <Icon\n className={cx('Selections-dragbar icon')}\n icon=\"drag-bar\"\n />\n ) : null}\n\n <label>\n {itemRender(option, {\n index,\n disabled,\n onChange: this.handleValueChange.bind(this, index)\n })}\n </label>\n\n {!disabled ? (\n <a\n className={cx('Selections-delBtn')}\n data-index={index}\n onClick={this.handleRemove}\n >\n <Icon icon=\"close\" className=\"icon\" />\n </a>\n ) : null}\n </div>\n ))}\n </div>\n ) : (\n <div className={cx('Selections-placeholder')}>{__(placeholder)}</div>\n )}\n </div>\n );\n }\n}\n\nexport default themeable(localeable(ResultList));\n"
|
12
12
|
]
|
13
13
|
}
|