amis 1.4.2-beta.6 → 1.5.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/lib/Schema.d.ts +11 -3
- package/lib/Schema.js.map +1 -1
- package/lib/components/Alert2.d.ts +26 -21
- package/lib/components/Alert2.js +11 -4
- package/lib/components/Alert2.js.map +2 -2
- package/lib/components/AnchorNav.d.ts +22 -21
- package/lib/components/AnchorNav.js +7 -3
- package/lib/components/AnchorNav.js.map +2 -2
- package/lib/components/ArrayInput.d.ts +84 -84
- package/lib/components/AssociatedSelection.d.ts +930 -0
- package/lib/components/AssociatedSelection.js +89 -0
- package/lib/components/AssociatedSelection.js.map +13 -0
- package/lib/components/Badge.js +2 -2
- package/lib/components/Badge.js.map +2 -2
- package/lib/components/Button.js +1 -1
- package/lib/components/Button.js.map +2 -2
- package/lib/components/{ChainedCheckboxes.d.ts → ChainedSelection.d.ts} +267 -98
- package/lib/components/{ChainedCheckboxes.js → ChainedSelection.js} +30 -24
- package/lib/components/ChainedSelection.js.map +13 -0
- package/lib/components/Checkbox.d.ts +20 -20
- package/lib/components/Collapse.d.ts +51 -23
- package/lib/components/Collapse.js +70 -11
- package/lib/components/Collapse.js.map +2 -2
- package/lib/components/CollapseGroup.d.ts +88 -0
- package/lib/components/CollapseGroup.js +81 -0
- package/lib/components/CollapseGroup.js.map +13 -0
- package/lib/components/ColorPicker.d.ts +89 -85
- package/lib/components/ColorPicker.js +17 -4
- package/lib/components/ColorPicker.js.map +2 -2
- package/lib/components/DatePicker.d.ts +84 -84
- package/lib/components/DateRangePicker.d.ts +84 -84
- package/lib/components/Drawer.js +2 -2
- package/lib/components/Drawer.js.map +2 -2
- package/lib/components/Editor.d.ts +84 -84
- package/lib/components/GridNav.d.ts +52 -0
- package/lib/components/GridNav.js +123 -0
- package/lib/components/GridNav.js.map +13 -0
- package/lib/components/GroupedSelection.d.ts +907 -0
- package/lib/components/GroupedSelection.js +48 -0
- package/lib/components/GroupedSelection.js.map +13 -0
- package/lib/components/InputBox.d.ts +22 -21
- package/lib/components/InputBox.js +10 -2
- package/lib/components/InputBox.js.map +2 -2
- package/lib/components/Link.d.ts +29 -36
- package/lib/components/Link.js +14 -15
- package/lib/components/Link.js.map +2 -2
- package/lib/components/ListGroup.d.ts +21 -21
- package/lib/components/ModalManager.js +1 -1
- package/lib/components/ModalManager.js.map +2 -2
- package/lib/components/MonthRangePicker.d.ts +84 -84
- package/lib/components/NumberInput.d.ts +20 -20
- package/lib/components/Overlay.js +5 -0
- package/lib/components/Overlay.js.map +2 -2
- package/lib/components/PickerColumn.d.ts +514 -0
- package/lib/components/PickerColumn.js +279 -0
- package/lib/components/PickerColumn.js.map +13 -0
- package/lib/components/PickerContainer.d.ts +513 -0
- package/lib/components/PickerContainer.js +96 -0
- package/lib/components/PickerContainer.js.map +13 -0
- package/lib/components/PopOver.d.ts +1 -0
- package/lib/components/PopOver.js +12 -1
- package/lib/components/PopOver.js.map +2 -2
- package/lib/components/Progress.d.ts +85 -0
- package/lib/components/Progress.js +81 -0
- package/lib/components/Progress.js.map +13 -0
- package/lib/components/Radios.d.ts +22 -21
- package/lib/components/Radios.js +1 -0
- package/lib/components/Radios.js.map +2 -2
- package/lib/components/Rating.d.ts +21 -21
- package/lib/components/ResultBox.d.ts +84 -84
- package/lib/components/ResultBox.js +10 -2
- package/lib/components/ResultBox.js.map +2 -2
- package/lib/components/SearchBox.d.ts +84 -84
- package/lib/components/Select.d.ts +245 -237
- package/lib/components/Select.js +25 -4
- package/lib/components/Select.js.map +2 -2
- package/lib/components/{Checkboxes.d.ts → Selection.d.ts} +273 -98
- package/lib/components/Selection.js +134 -0
- package/lib/components/Selection.js.map +13 -0
- package/lib/components/{TableCheckboxes.d.ts → TableSelection.d.ts} +266 -96
- package/lib/components/{TableCheckboxes.js → TableSelection.js} +30 -30
- package/lib/components/TableSelection.js.map +13 -0
- package/lib/components/Tabs.d.ts +20 -20
- package/lib/components/TabsTransfer.d.ts +84 -84
- package/lib/components/TabsTransfer.js +9 -9
- package/lib/components/TabsTransfer.js.map +2 -2
- package/lib/components/TabsTransferPicker.d.ts +489 -0
- package/lib/components/TabsTransferPicker.js +60 -0
- package/lib/components/TabsTransferPicker.js.map +13 -0
- package/lib/components/Toast.d.ts +90 -87
- package/lib/components/Toast.js +15 -5
- package/lib/components/Toast.js.map +2 -2
- package/lib/components/Transfer.d.ts +908 -274
- package/lib/components/Transfer.js +31 -24
- package/lib/components/Transfer.js.map +2 -2
- package/lib/components/TransferDropDown.d.ts +488 -0
- package/lib/components/TransferDropDown.js +59 -0
- package/lib/components/TransferDropDown.js.map +13 -0
- package/lib/components/TransferPicker.d.ts +493 -0
- package/lib/components/TransferPicker.js +60 -0
- package/lib/components/TransferPicker.js.map +13 -0
- package/lib/components/Tree.d.ts +115 -84
- package/lib/components/Tree.js +183 -30
- package/lib/components/Tree.js.map +2 -2
- package/lib/components/{TreeCheckboxes.d.ts → TreeSelection.d.ts} +269 -99
- package/lib/components/{TreeCheckboxes.js → TreeSelection.js} +36 -32
- package/lib/components/TreeSelection.js.map +13 -0
- package/lib/components/condition-builder/Field.js +4 -2
- package/lib/components/condition-builder/Field.js.map +2 -2
- package/lib/components/condition-builder/Func.js +2 -2
- package/lib/components/condition-builder/Func.js.map +2 -2
- 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.js +3 -3
- package/lib/components/condition-builder/Item.js.map +2 -2
- package/lib/components/icons.js +10 -0
- package/lib/components/icons.js.map +2 -2
- package/lib/components/index.d.ts +8 -8
- package/lib/components/index.js +16 -16
- package/lib/components/index.js.map +2 -2
- package/lib/envOverwrite.d.ts +1 -1
- package/lib/envOverwrite.js +24 -9
- package/lib/envOverwrite.js.map +2 -2
- package/lib/factory.d.ts +15 -1
- package/lib/factory.js +35 -6
- package/lib/factory.js.map +2 -2
- package/lib/helper.css.map +1 -1
- package/lib/hooks/index.d.ts +5 -0
- package/lib/hooks/index.js +14 -0
- package/lib/hooks/index.js.map +13 -0
- package/lib/hooks/use-set-state.d.ts +2 -0
- package/lib/hooks/use-set-state.js +15 -0
- package/lib/hooks/use-set-state.js.map +13 -0
- package/lib/hooks/use-touch.d.ts +16 -0
- package/lib/hooks/use-touch.js +73 -0
- package/lib/hooks/use-touch.js.map +13 -0
- package/lib/hooks/use-update-effect.d.ts +3 -0
- package/lib/hooks/use-update-effect.js +17 -0
- package/lib/hooks/use-update-effect.js.map +13 -0
- package/lib/icons/alert-danger.js +7 -0
- package/lib/icons/alert-info.js +7 -0
- package/lib/icons/alert-success.js +7 -0
- package/lib/icons/alert-warning.js +7 -0
- package/lib/icons/download.js +7 -0
- package/lib/icons/drag-bar.js +10 -3
- package/lib/index.d.ts +5 -0
- package/lib/index.js +6 -1
- package/lib/index.js.map +2 -2
- package/lib/locale/de-DE.js +2 -0
- package/lib/locale/de-DE.js.map +2 -2
- package/lib/locale/en-US.js +3 -0
- package/lib/locale/en-US.js.map +2 -2
- package/lib/locale/zh-CN.js +5 -2
- package/lib/locale/zh-CN.js.map +2 -2
- package/lib/renderers/Action.d.ts +10 -5
- package/lib/renderers/Action.js +23 -5
- package/lib/renderers/Action.js.map +2 -2
- package/lib/renderers/Alert.d.ts +21 -1
- package/lib/renderers/Alert.js.map +2 -2
- package/lib/renderers/AnchorNav.d.ts +1 -0
- package/lib/renderers/AnchorNav.js +2 -2
- package/lib/renderers/AnchorNav.js.map +2 -2
- package/lib/renderers/Avatar.js +3 -3
- package/lib/renderers/Avatar.js.map +2 -2
- package/lib/renderers/Breadcrumb.js +1 -1
- package/lib/renderers/Breadcrumb.js.map +2 -2
- package/lib/renderers/CRUD.d.ts +5 -0
- package/lib/renderers/CRUD.js +25 -4
- package/lib/renderers/CRUD.js.map +2 -2
- package/lib/renderers/Card.d.ts +5 -0
- package/lib/renderers/Card.js +34 -23
- package/lib/renderers/Card.js.map +2 -2
- package/lib/renderers/Collapse.d.ts +25 -20
- package/lib/renderers/Collapse.js +10 -72
- package/lib/renderers/Collapse.js.map +2 -2
- package/lib/renderers/CollapseGroup.d.ts +42 -0
- package/lib/renderers/CollapseGroup.js +33 -0
- package/lib/renderers/CollapseGroup.js.map +13 -0
- package/lib/renderers/Form/ConditionBuilder.js +2 -2
- package/lib/renderers/Form/ConditionBuilder.js.map +2 -2
- package/lib/renderers/Form/DiffEditor.d.ts +4 -3
- package/lib/renderers/Form/Editor.d.ts +3 -2
- package/lib/renderers/Form/InputCity.d.ts +84 -84
- package/lib/renderers/Form/InputCity.js +7 -6
- package/lib/renderers/Form/InputCity.js.map +2 -2
- package/lib/renderers/Form/InputColor.d.ts +86 -85
- package/lib/renderers/Form/InputColor.js +1 -1
- package/lib/renderers/Form/InputColor.js.map +2 -2
- package/lib/renderers/Form/InputFile.d.ts +6 -0
- package/lib/renderers/Form/InputFile.js +28 -8
- package/lib/renderers/Form/InputFile.js.map +2 -2
- package/lib/renderers/Form/InputImage.js +11 -4
- package/lib/renderers/Form/InputImage.js.map +2 -2
- package/lib/renderers/Form/Item.d.ts +1 -1
- package/lib/renderers/Form/Item.js +2 -1
- package/lib/renderers/Form/Item.js.map +2 -2
- package/lib/renderers/Form/Options.js +25 -4
- package/lib/renderers/Form/Options.js.map +2 -2
- package/lib/renderers/Form/Select.d.ts +42 -4
- package/lib/renderers/Form/Select.js +37 -3
- package/lib/renderers/Form/Select.js.map +2 -2
- package/lib/renderers/Form/TabsTransferPicker.d.ts +48 -0
- package/lib/renderers/Form/TabsTransferPicker.js +29 -0
- package/lib/renderers/Form/TabsTransferPicker.js.map +13 -0
- package/lib/renderers/Form/Transfer.js +18 -3
- package/lib/renderers/Form/Transfer.js.map +2 -2
- package/lib/renderers/Form/TransferPicker.d.ts +52 -0
- package/lib/renderers/Form/TransferPicker.js +43 -0
- package/lib/renderers/Form/TransferPicker.js.map +13 -0
- package/lib/renderers/Form/TreeSelect.js +2 -2
- package/lib/renderers/Form/TreeSelect.js.map +2 -2
- package/lib/renderers/Form/index.d.ts +5 -0
- package/lib/renderers/Form/index.js +5 -3
- package/lib/renderers/Form/index.js.map +2 -2
- package/lib/renderers/Form/wrapControl.js +13 -1
- package/lib/renderers/Form/wrapControl.js.map +2 -2
- package/lib/renderers/GridNav.d.ts +99 -0
- package/lib/renderers/GridNav.js +82 -0
- package/lib/renderers/GridNav.js.map +13 -0
- package/lib/renderers/IFrame.js +1 -3
- package/lib/renderers/IFrame.js.map +2 -2
- package/lib/renderers/Image.js +7 -5
- package/lib/renderers/Image.js.map +2 -2
- package/lib/renderers/Json.d.ts +4 -0
- package/lib/renderers/Json.js +4 -13
- package/lib/renderers/Json.js.map +2 -2
- package/lib/renderers/Link.d.ts +4 -2
- package/lib/renderers/Link.js +15 -8
- package/lib/renderers/Link.js.map +2 -2
- package/lib/renderers/List.js +1 -1
- package/lib/renderers/List.js.map +2 -2
- package/lib/renderers/Nav.d.ts +21 -21
- package/lib/renderers/Nav.js +37 -19
- package/lib/renderers/Nav.js.map +2 -2
- package/lib/renderers/Page.d.ts +18 -0
- package/lib/renderers/Page.js +53 -9
- package/lib/renderers/Page.js.map +2 -2
- package/lib/renderers/Portlet.d.ts +125 -0
- package/lib/renderers/Portlet.js +156 -0
- package/lib/renderers/Portlet.js.map +13 -0
- package/lib/renderers/Progress.d.ts +23 -3
- package/lib/renderers/Progress.js +15 -19
- package/lib/renderers/Progress.js.map +2 -2
- package/lib/renderers/Property.js +1 -1
- package/lib/renderers/Property.js.map +2 -2
- package/lib/renderers/Table/ColumnToggler.js +1 -1
- package/lib/renderers/Table/ColumnToggler.js.map +2 -2
- package/lib/renderers/Table/TableContent.d.ts +4 -1
- package/lib/renderers/Table/TableContent.js +21 -1
- package/lib/renderers/Table/TableContent.js.map +2 -2
- package/lib/renderers/Table/index.d.ts +5 -1
- package/lib/renderers/Table/index.js +65 -30
- package/lib/renderers/Table/index.js.map +2 -2
- package/lib/renderers/Tabs.js +9 -1
- package/lib/renderers/Tabs.js.map +2 -2
- package/lib/renderers/WebComponent.js +1 -1
- package/lib/renderers/WebComponent.js.map +2 -2
- package/lib/store/combo.d.ts +2 -2
- package/lib/store/form.d.ts +1 -1
- package/lib/store/form.js +3 -5
- package/lib/store/form.js.map +2 -2
- package/lib/store/formItem.js +44 -4
- package/lib/store/formItem.js.map +2 -2
- package/lib/store/table.d.ts +3 -2
- package/lib/store/table.js +35 -12
- package/lib/store/table.js.map +2 -2
- package/lib/themes/ang-ie11.css +934 -222
- package/lib/themes/ang.css +934 -222
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +934 -222
- package/lib/themes/antd.css +934 -222
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +970 -260
- package/lib/themes/cxd.css +970 -260
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +934 -222
- package/lib/themes/dark.css +934 -222
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default.css +970 -260
- package/lib/themes/default.css.map +1 -1
- package/lib/types.d.ts +38 -1
- package/lib/types.js +0 -5
- package/lib/types.js.map +2 -2
- package/lib/utils/api.d.ts +3 -2
- package/lib/utils/api.js +90 -17
- package/lib/utils/api.js.map +2 -2
- package/lib/utils/dom.d.ts +4 -0
- package/lib/utils/dom.js +11 -1
- package/lib/utils/dom.js.map +2 -2
- package/lib/utils/helper.d.ts +12 -23
- package/lib/utils/helper.js +62 -166
- package/lib/utils/helper.js.map +2 -2
- package/lib/utils/tpl-builtin.d.ts +2 -20
- package/lib/utils/tpl-builtin.js +25 -743
- package/lib/utils/tpl-builtin.js.map +2 -2
- package/lib/utils/tpl.js +24 -0
- package/lib/utils/tpl.js.map +2 -2
- package/package.json +5 -2
- package/schema.json +3966 -1263
- package/scss/_mixins.scss +1 -3
- package/scss/_properties.scss +42 -13
- package/scss/base/_common.scss +3 -0
- package/scss/base/_normalize.scss +2 -0
- package/scss/components/_alert.scss +28 -5
- package/scss/components/_anchor-nav.scss +89 -29
- package/scss/components/_button.scss +12 -0
- package/scss/components/_card.scss +9 -15
- package/scss/components/_collapse-group.scss +15 -0
- package/scss/components/_collapse.scss +48 -23
- package/scss/components/_grid-nav.scss +128 -0
- package/scss/components/_images.scss +1 -0
- package/scss/components/_input-box.scss +1 -0
- package/scss/components/_nav.scss +2 -7
- package/scss/components/_page.scss +35 -2
- package/scss/components/_picker-columns.scss +124 -0
- package/scss/components/_popover.scss +13 -0
- package/scss/components/_portlet.scss +51 -0
- package/scss/components/_progress.scss +141 -33
- package/scss/components/_result-box.scss +1 -0
- package/scss/components/_spinner.scss +5 -4
- package/scss/components/_status.scss +1 -1
- package/scss/components/_table.scss +32 -0
- package/scss/components/_toast.scss +41 -11
- package/scss/components/form/_checks.scss +0 -351
- package/scss/components/form/_color.scss +32 -3
- package/scss/components/form/_combo.scss +4 -0
- package/scss/components/form/_fieldset.scss +6 -1
- package/scss/components/form/_file.scss +11 -0
- package/scss/components/form/_form.scss +48 -0
- package/scss/components/form/_selection.scss +354 -0
- package/scss/components/form/_transfer.scss +76 -18
- package/scss/components/form/_tree.scss +42 -0
- package/scss/themes/_common.scss +6 -0
- package/scss/themes/_cxd-variables.scss +13 -6
- package/scss/themes/cxd.scss +19 -20
- package/sdk/ang-ie11.css +1065 -246
- package/sdk/ang.css +1069 -230
- package/sdk/antd-ie11.css +1068 -249
- package/sdk/antd.css +1069 -230
- package/sdk/charts.js +17 -17
- package/sdk/color-picker.js +65 -69
- package/sdk/cropperjs.js +3 -3
- package/sdk/cxd-ie11.css +1081 -268
- package/sdk/cxd.css +1116 -279
- package/sdk/dark-ie11.css +1069 -250
- package/sdk/dark.css +1069 -230
- package/sdk/exceljs.js +1 -1
- package/sdk/helper.css.map +1 -1
- package/sdk/iconfont.svg +2513 -0
- package/sdk/iconfont.ttf +0 -0
- package/sdk/iconfont.woff +0 -0
- package/sdk/locale/de-DE.js +2 -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 +20 -28
- package/sdk/rich-text.js +62 -62
- package/sdk/sdk-ie11.css +1081 -268
- package/sdk/sdk.css +1116 -279
- package/sdk/sdk.js +1371 -1189
- package/sdk/thirds/hls.js/hls.js +18 -18
- package/sdk/thirds/mpegts.js/mpegts.js +2 -2
- package/sdk/tinymce.js +57 -57
- package/src/Schema.ts +19 -1
- package/src/components/Alert2.tsx +32 -4
- package/src/components/AnchorNav.tsx +15 -4
- package/src/components/{AssociatedCheckboxes.tsx → AssociatedSelection.tsx} +43 -37
- package/src/components/Badge.tsx +3 -3
- package/src/components/Button.tsx +1 -0
- package/src/components/{ChainedCheckboxes.tsx → ChainedSelection.tsx} +57 -40
- package/src/components/Collapse.tsx +139 -20
- package/src/components/CollapseGroup.tsx +130 -0
- package/src/components/ColorPicker.tsx +32 -10
- package/src/components/Drawer.tsx +8 -6
- package/src/components/GridNav.tsx +233 -0
- package/src/components/{ListCheckboxes.tsx → GroupedSelection.tsx} +26 -21
- package/src/components/InputBox.tsx +10 -9
- package/src/components/Link.tsx +28 -37
- package/src/components/ModalManager.ts +1 -1
- package/src/components/Overlay.tsx +6 -0
- package/src/components/PickerColumn.tsx +429 -0
- package/src/components/PickerContainer.tsx +128 -0
- package/src/components/PopOver.tsx +15 -1
- package/src/components/Progress.tsx +140 -0
- package/src/components/Radios.tsx +3 -8
- package/src/components/ResultBox.tsx +9 -9
- package/src/components/Select.tsx +57 -5
- package/src/components/{Checkboxes.tsx → Selection.tsx} +75 -21
- package/src/components/{TableCheckboxes.tsx → TableSelection.tsx} +46 -25
- package/src/components/TabsTransfer.tsx +13 -7
- package/src/components/TabsTransferPicker.tsx +85 -0
- package/src/components/Toast.tsx +48 -21
- package/src/components/Transfer.tsx +71 -50
- package/src/components/TransferDropDown.tsx +120 -0
- package/src/components/TransferPicker.tsx +91 -0
- package/src/components/Tree.tsx +194 -8
- package/src/components/{TreeCheckboxes.tsx → TreeSelection.tsx} +33 -26
- package/src/components/condition-builder/Field.tsx +7 -5
- package/src/components/condition-builder/Func.tsx +3 -3
- package/src/components/condition-builder/InputSwitch.tsx +3 -3
- package/src/components/condition-builder/Item.tsx +5 -12
- package/src/components/icons.tsx +10 -0
- package/src/components/index.tsx +13 -13
- package/src/envOverwrite.ts +20 -8
- package/src/factory.tsx +70 -9
- package/src/hooks/index.ts +5 -0
- package/src/hooks/use-set-state.ts +19 -0
- package/src/hooks/use-touch.ts +100 -0
- package/src/hooks/use-update-effect.ts +16 -0
- package/src/icons/alert-danger.svg +1 -0
- package/src/icons/alert-info.svg +1 -0
- package/src/icons/alert-success.svg +1 -0
- package/src/icons/alert-warning.svg +1 -0
- package/src/icons/download.svg +4 -0
- package/src/icons/drag-bar.svg +12 -6
- package/src/index.tsx +5 -0
- package/src/locale/de-DE.ts +2 -0
- package/src/locale/en-US.ts +3 -0
- package/src/locale/zh-CN.ts +5 -2
- package/src/renderers/Action.tsx +58 -3
- package/src/renderers/Alert.tsx +31 -1
- package/src/renderers/AnchorNav.tsx +4 -0
- package/src/renderers/Avatar.tsx +8 -4
- package/src/renderers/Breadcrumb.tsx +5 -1
- package/src/renderers/CRUD.tsx +29 -3
- package/src/renderers/Card.tsx +76 -36
- package/src/renderers/Collapse.tsx +70 -115
- package/src/renderers/CollapseGroup.tsx +80 -0
- package/src/renderers/Form/ConditionBuilder.tsx +2 -2
- package/src/renderers/Form/InputCity.tsx +4 -8
- package/src/renderers/Form/InputColor.tsx +4 -2
- package/src/renderers/Form/InputFile.tsx +65 -24
- package/src/renderers/Form/InputImage.tsx +11 -3
- package/src/renderers/Form/Item.tsx +3 -2
- package/src/renderers/Form/Options.tsx +29 -3
- package/src/renderers/Form/Select.tsx +162 -21
- package/src/renderers/Form/TabsTransferPicker.tsx +123 -0
- package/src/renderers/Form/Transfer.tsx +19 -4
- package/src/renderers/Form/TransferPicker.tsx +145 -0
- package/src/renderers/Form/TreeSelect.tsx +25 -0
- package/src/renderers/Form/index.tsx +15 -2
- package/src/renderers/Form/wrapControl.tsx +26 -1
- package/src/renderers/GridNav.tsx +204 -0
- package/src/renderers/IFrame.tsx +2 -4
- package/src/renderers/Image.tsx +19 -15
- package/src/renderers/Json.tsx +9 -9
- package/src/renderers/Link.tsx +29 -16
- package/src/renderers/List.tsx +1 -1
- package/src/renderers/Nav.tsx +105 -56
- package/src/renderers/Page.tsx +62 -1
- package/src/renderers/Portlet.tsx +423 -0
- package/src/renderers/Progress.tsx +56 -38
- package/src/renderers/Property.tsx +6 -4
- package/src/renderers/Table/ColumnToggler.tsx +1 -1
- package/src/renderers/Table/TableContent.tsx +40 -2
- package/src/renderers/Table/index.tsx +88 -43
- package/src/renderers/Tabs.tsx +9 -1
- package/src/renderers/WebComponent.tsx +2 -2
- package/src/store/form.ts +3 -9
- package/src/store/formItem.ts +94 -2
- package/src/store/table.ts +55 -14
- package/src/types.ts +58 -1
- package/src/utils/api.ts +120 -26
- package/src/utils/dom.tsx +12 -0
- package/src/utils/helper.ts +55 -185
- package/src/utils/tpl-builtin.ts +40 -866
- package/src/utils/tpl.ts +33 -0
- package/tsconfig-for-declaration.json +1 -1
- package/dump.rdb +0 -0
- package/lib/components/AssociatedCheckboxes.d.ts +0 -762
- package/lib/components/AssociatedCheckboxes.js +0 -90
- package/lib/components/AssociatedCheckboxes.js.map +0 -13
- package/lib/components/ChainedCheckboxes.js.map +0 -13
- package/lib/components/Checkboxes.js +0 -101
- package/lib/components/Checkboxes.js.map +0 -13
- package/lib/components/ListCheckboxes.d.ts +0 -739
- package/lib/components/ListCheckboxes.js +0 -48
- package/lib/components/ListCheckboxes.js.map +0 -13
- package/lib/components/ListRadios.d.ts +0 -763
- package/lib/components/ListRadios.js +0 -86
- package/lib/components/ListRadios.js.map +0 -13
- package/lib/components/TableCheckboxes.js.map +0 -13
- package/lib/components/TreeCheckboxes.js.map +0 -13
- package/lib/components/TreeRadios.d.ts +0 -838
- package/lib/components/TreeRadios.js +0 -116
- package/lib/components/TreeRadios.js.map +0 -13
- package/src/components/ListRadios.tsx +0 -159
- package/src/components/TreeRadios.tsx +0 -202
package/lib/utils/tpl-builtin.js
CHANGED
@@ -1,753 +1,30 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.register = exports.dataMapping = exports.resolveMapping = exports.tokenize = exports.resolveVariableAndFilter = exports.isPureVariable = exports.resolveVariable = exports.pickValues = exports.
|
3
|
+
exports.register = exports.dataMapping = exports.resolveMapping = exports.stripNumber = exports.tokenize = exports.resolveVariableAndFilter = exports.isPureVariable = exports.resolveVariable = exports.pickValues = exports.registerFilter = exports.getFilters = exports.parseDuration = exports.relativeValueRe = exports.filterDate = exports.formatDuration = exports.escapeHtml = exports.prettyBytes = void 0;
|
4
4
|
var tslib_1 = require("tslib");
|
5
|
-
var moment_1 = (0, tslib_1.__importDefault)(require("moment"));
|
6
5
|
var isPlainObject_1 = (0, tslib_1.__importDefault)(require("lodash/isPlainObject"));
|
7
|
-
var groupBy_1 = (0, tslib_1.__importDefault)(require("lodash/groupBy"));
|
8
6
|
var helper_1 = require("./helper");
|
9
|
-
var
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
var exponent = Math.min(Math.floor(Math.log(num) / Math.log(1000)), UNITS.length - 1);
|
25
|
-
var numStr = Number((num / Math.pow(1000, exponent)).toPrecision(3));
|
26
|
-
var unit = UNITS[exponent];
|
27
|
-
return (neg ? '-' : '') + numStr + ' ' + unit;
|
28
|
-
};
|
29
|
-
exports.prettyBytes = prettyBytes;
|
30
|
-
var entityMap = {
|
31
|
-
'&': '&',
|
32
|
-
'<': '<',
|
33
|
-
'>': '>',
|
34
|
-
'"': '"',
|
35
|
-
"'": ''',
|
36
|
-
'/': '/'
|
37
|
-
};
|
38
|
-
var escapeHtml = function (str) {
|
39
|
-
return String(str).replace(/[&<>"'\/]/g, function (s) {
|
40
|
-
return entityMap[s];
|
41
|
-
});
|
42
|
-
};
|
43
|
-
exports.escapeHtml = escapeHtml;
|
44
|
-
function formatDuration(value) {
|
45
|
-
var unit = ['秒', '分', '时', '天', '月', '季', '年'];
|
46
|
-
var steps = [1, 60, 3600, 86400, 2592000, 7776000, 31104000];
|
47
|
-
var len = steps.length;
|
48
|
-
var parts = [];
|
49
|
-
while (len--) {
|
50
|
-
if (steps[len] && value >= steps[len]) {
|
51
|
-
parts.push(Math.floor(value / steps[len]) + unit[len]);
|
52
|
-
value %= steps[len];
|
53
|
-
}
|
54
|
-
else if (len === 0 && value) {
|
55
|
-
parts.push((value.toFixed ? value.toFixed(2) : '0') + unit[0]);
|
56
|
-
}
|
57
|
-
}
|
58
|
-
return parts.join('');
|
59
|
-
}
|
60
|
-
exports.formatDuration = formatDuration;
|
61
|
-
function makeSorter(key, method, order) {
|
62
|
-
return function (a, b) {
|
63
|
-
if (!a || !b) {
|
64
|
-
return 0;
|
65
|
-
}
|
66
|
-
var va = (0, exports.resolveVariable)(key, a);
|
67
|
-
var vb = (0, exports.resolveVariable)(key, b);
|
68
|
-
var result = 0;
|
69
|
-
if (method === 'numerical') {
|
70
|
-
result = (parseFloat(va) || 0) - (parseFloat(vb) || 0);
|
71
|
-
}
|
72
|
-
else {
|
73
|
-
result = String(va).localeCompare(String(vb));
|
74
|
-
}
|
75
|
-
return result * (order === 'desc' ? -1 : 1);
|
76
|
-
};
|
77
|
-
}
|
78
|
-
var timeUnitMap = {
|
79
|
-
year: 'Y',
|
80
|
-
month: 'M',
|
81
|
-
week: 'w',
|
82
|
-
weekday: 'W',
|
83
|
-
day: 'd',
|
84
|
-
hour: 'h',
|
85
|
-
minute: 'm',
|
86
|
-
min: 'm',
|
87
|
-
second: 's',
|
88
|
-
millisecond: 'ms'
|
89
|
-
};
|
90
|
-
exports.relativeValueRe = /^(.+)?(\+|-)(\d+)(minute|min|hour|day|week|month|year|weekday|second|millisecond)s?$/i;
|
91
|
-
var filterDate = function (value, data, format, utc) {
|
92
|
-
if (data === void 0) { data = {}; }
|
93
|
-
if (format === void 0) { format = 'X'; }
|
94
|
-
if (utc === void 0) { utc = false; }
|
95
|
-
var m, mm = utc ? moment_1.default.utc : moment_1.default;
|
96
|
-
if (typeof value === 'string') {
|
97
|
-
value = value.trim();
|
98
|
-
}
|
99
|
-
value = (0, exports.tokenize)(value, data);
|
100
|
-
if (value && typeof value === 'string' && (m = exports.relativeValueRe.exec(value))) {
|
101
|
-
var date = new Date();
|
102
|
-
var step = parseInt(m[3], 10);
|
103
|
-
var from = m[1]
|
104
|
-
? (0, exports.filterDate)(m[1], data, format, utc)
|
105
|
-
: mm(/(minute|min|hour|second)s?/.test(m[4])
|
106
|
-
? [
|
107
|
-
date.getFullYear(),
|
108
|
-
date.getMonth(),
|
109
|
-
date.getDate(),
|
110
|
-
date.getHours(),
|
111
|
-
date.getMinutes(),
|
112
|
-
date.getSeconds()
|
113
|
-
]
|
114
|
-
: [date.getFullYear(), date.getMonth(), date.getDate()]);
|
115
|
-
return m[2] === '-'
|
116
|
-
? from.subtract(step, timeUnitMap[m[4]])
|
117
|
-
: from.add(step, timeUnitMap[m[4]]);
|
118
|
-
// return from[m[2] === '-' ? 'subtract' : 'add'](step, mapping[m[4]] || m[4]);
|
119
|
-
}
|
120
|
-
else if (value === 'now') {
|
121
|
-
return mm();
|
122
|
-
}
|
123
|
-
else if (value === 'today') {
|
124
|
-
var date = new Date();
|
125
|
-
return mm([date.getFullYear(), date.getMonth(), date.getDate()]);
|
126
|
-
}
|
127
|
-
else {
|
128
|
-
return mm(value, format);
|
129
|
-
}
|
130
|
-
};
|
131
|
-
exports.filterDate = filterDate;
|
132
|
-
function parseDuration(str) {
|
133
|
-
var matches = /^((?:\-|\+)?(?:\d*\.)?\d+)(minute|min|hour|day|week|month|quarter|year|weekday|second|millisecond)s?$/.exec(str);
|
134
|
-
if (matches) {
|
135
|
-
var duration = moment_1.default.duration(parseFloat(matches[1]), matches[2]);
|
136
|
-
if (moment_1.default.isDuration(duration)) {
|
137
|
-
return duration;
|
138
|
-
}
|
139
|
-
}
|
140
|
-
return;
|
141
|
-
}
|
142
|
-
exports.parseDuration = parseDuration;
|
143
|
-
// 主要用于解决 0.1+0.2 结果的精度问题导致太长
|
144
|
-
function stripNumber(number) {
|
145
|
-
if (typeof number === 'number') {
|
146
|
-
return parseFloat(number.toPrecision(12));
|
147
|
-
}
|
148
|
-
else {
|
149
|
-
return number;
|
150
|
-
}
|
151
|
-
}
|
152
|
-
exports.stripNumber = stripNumber;
|
153
|
-
exports.filters = {
|
154
|
-
map: function (input, fn) {
|
155
|
-
var arg = [];
|
156
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
157
|
-
arg[_i - 2] = arguments[_i];
|
158
|
-
}
|
159
|
-
return Array.isArray(input) && exports.filters[fn]
|
160
|
-
? input.map(function (item) { return exports.filters[fn].apply(exports.filters, (0, tslib_1.__spreadArray)([item], arg, false)); })
|
161
|
-
: input;
|
162
|
-
},
|
163
|
-
html: function (input) { return (0, exports.escapeHtml)(input); },
|
164
|
-
json: function (input, tabSize) {
|
165
|
-
if (tabSize === void 0) { tabSize = 2; }
|
166
|
-
return tabSize
|
167
|
-
? JSON.stringify(input, null, parseInt(tabSize, 10))
|
168
|
-
: JSON.stringify(input);
|
169
|
-
},
|
170
|
-
toJson: function (input) {
|
171
|
-
var ret;
|
172
|
-
try {
|
173
|
-
ret = JSON.parse(input);
|
174
|
-
}
|
175
|
-
catch (e) {
|
176
|
-
ret = null;
|
177
|
-
}
|
178
|
-
return ret;
|
179
|
-
},
|
180
|
-
toInt: function (input) { return (typeof input === 'string' ? parseInt(input, 10) : input); },
|
181
|
-
toFloat: function (input) { return (typeof input === 'string' ? parseFloat(input) : input); },
|
182
|
-
raw: function (input) { return input; },
|
183
|
-
now: function () { return new Date(); },
|
184
|
-
toDate: function (input, inputFormat) {
|
185
|
-
if (inputFormat === void 0) { inputFormat = ''; }
|
186
|
-
var data = (0, moment_1.default)(input, inputFormat);
|
187
|
-
data.add();
|
188
|
-
return data.isValid() ? data.toDate() : undefined;
|
189
|
-
},
|
190
|
-
fromNow: function (input, inputFormat) {
|
191
|
-
if (inputFormat === void 0) { inputFormat = ''; }
|
192
|
-
return (0, moment_1.default)(input, inputFormat).fromNow();
|
193
|
-
},
|
194
|
-
dateModify: function (input, modifier, amount, unit) {
|
195
|
-
if (modifier === void 0) { modifier = 'add'; }
|
196
|
-
if (amount === void 0) { amount = 0; }
|
197
|
-
if (unit === void 0) { unit = 'days'; }
|
198
|
-
if (!(input instanceof Date)) {
|
199
|
-
input = new Date();
|
200
|
-
}
|
201
|
-
if (modifier === 'endOf' || modifier === 'startOf') {
|
202
|
-
return (0, moment_1.default)(input)[modifier === 'endOf' ? 'endOf' : 'startOf'](amount || 'day')
|
203
|
-
.toDate();
|
204
|
-
}
|
205
|
-
return (0, moment_1.default)(input)[modifier === 'add' ? 'add' : 'subtract'](parseInt(amount, 10) || 0, unit)
|
206
|
-
.toDate();
|
207
|
-
},
|
208
|
-
date: function (input, format, inputFormat) {
|
209
|
-
if (format === void 0) { format = 'LLL'; }
|
210
|
-
if (inputFormat === void 0) { inputFormat = 'X'; }
|
211
|
-
return (0, moment_1.default)(input, inputFormat).format(format);
|
212
|
-
},
|
213
|
-
number: function (input) {
|
214
|
-
var parts = String(input).split('.');
|
215
|
-
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
216
|
-
return parts.join('.');
|
217
|
-
},
|
218
|
-
trim: function (input) { return (typeof input === 'string' ? input.trim() : input); },
|
219
|
-
percent: function (input, decimals) {
|
220
|
-
if (decimals === void 0) { decimals = 0; }
|
221
|
-
input = parseFloat(input) || 0;
|
222
|
-
decimals = parseInt(decimals, 10) || 0;
|
223
|
-
var whole = input * 100;
|
224
|
-
var multiplier = Math.pow(10, decimals);
|
225
|
-
return ((Math.round(whole * multiplier) / multiplier).toFixed(decimals) + '%');
|
226
|
-
},
|
227
|
-
duration: function (input) { return (input ? formatDuration(input) : input); },
|
228
|
-
bytes: function (input) { return (input ? (0, exports.prettyBytes)(parseFloat(input)) : input); },
|
229
|
-
round: function (input, decimals) {
|
230
|
-
var _a;
|
231
|
-
if (decimals === void 0) { decimals = 2; }
|
232
|
-
if (isNaN(input)) {
|
233
|
-
return 0;
|
234
|
-
}
|
235
|
-
decimals = (_a = parseInt(decimals, 10)) !== null && _a !== void 0 ? _a : 2;
|
236
|
-
var multiplier = Math.pow(10, decimals);
|
237
|
-
return (Math.round(input * multiplier) / multiplier).toFixed(decimals);
|
238
|
-
},
|
239
|
-
truncate: function (input, length, end) {
|
240
|
-
if (typeof input !== 'string') {
|
241
|
-
return input;
|
242
|
-
}
|
243
|
-
end = end || '...';
|
244
|
-
if (length == null) {
|
245
|
-
return input;
|
246
|
-
}
|
247
|
-
length = parseInt(length, 10) || 200;
|
248
|
-
return input.substring(0, length) + (input.length > length ? end : '');
|
249
|
-
},
|
250
|
-
url_encode: function (input) { return encodeURIComponent(input); },
|
251
|
-
url_decode: function (input) { return decodeURIComponent(input); },
|
252
|
-
default: function (input, defaultValue, strict) {
|
253
|
-
var _a;
|
254
|
-
if (strict === void 0) { strict = false; }
|
255
|
-
return (_a = (strict ? input : input ? input : undefined)) !== null && _a !== void 0 ? _a : (function () {
|
256
|
-
try {
|
257
|
-
if (defaultValue === 'undefined') {
|
258
|
-
return undefined;
|
259
|
-
}
|
260
|
-
return JSON.parse(defaultValue);
|
261
|
-
}
|
262
|
-
catch (e) {
|
263
|
-
return defaultValue;
|
264
|
-
}
|
265
|
-
})();
|
266
|
-
},
|
267
|
-
join: function (input, glue) { return (input && input.join ? input.join(glue) : input); },
|
268
|
-
split: function (input, delimiter) {
|
269
|
-
if (delimiter === void 0) { delimiter = ','; }
|
270
|
-
return typeof input === 'string' ? input.split(delimiter) : input;
|
271
|
-
},
|
272
|
-
sortBy: function (input, key, method, order) {
|
273
|
-
if (method === void 0) { method = 'alpha'; }
|
274
|
-
return Array.isArray(input) ? input.sort(makeSorter(key, method, order)) : input;
|
275
|
-
},
|
276
|
-
objectToArray: function (input, label, value) {
|
277
|
-
if (label === void 0) { label = 'label'; }
|
278
|
-
if (value === void 0) { value = 'value'; }
|
279
|
-
return (0, transform_1.default)(input, function (result, v, k) {
|
280
|
-
var _a;
|
281
|
-
(result || (result = [])).push((_a = {},
|
282
|
-
_a[label] = v,
|
283
|
-
_a[value] = k,
|
284
|
-
_a));
|
285
|
-
}, []);
|
286
|
-
},
|
287
|
-
unique: function (input, key) {
|
288
|
-
return Array.isArray(input) ? (key ? (0, uniqBy_1.default)(input, key) : (0, uniq_1.default)(input)) : input;
|
289
|
-
},
|
290
|
-
topAndOther: function (input, len, labelField, restLabel) {
|
291
|
-
if (len === void 0) { len = 10; }
|
292
|
-
if (labelField === void 0) { labelField = 'name'; }
|
293
|
-
if (restLabel === void 0) { restLabel = '其他'; }
|
294
|
-
if (Array.isArray(input) && len) {
|
295
|
-
var grouped_1 = (0, groupBy_1.default)(input, function (item) {
|
296
|
-
var index = input.indexOf(item) + 1;
|
297
|
-
return index >= len ? len : index;
|
298
|
-
});
|
299
|
-
return Object.keys(grouped_1).map(function (key, index) {
|
300
|
-
var group = grouped_1[key];
|
301
|
-
var obj = group.reduce(function (obj, item) {
|
302
|
-
Object.keys(item).forEach(function (key) {
|
303
|
-
if (!obj.hasOwnProperty(key) || key === 'labelField') {
|
304
|
-
obj[key] = item[key];
|
305
|
-
}
|
306
|
-
else if (typeof item[key] === 'number' &&
|
307
|
-
typeof obj[key] === 'number') {
|
308
|
-
obj[key] += item[key];
|
309
|
-
}
|
310
|
-
else if (typeof item[key] === 'string' &&
|
311
|
-
/^(?:\-|\.)\d/.test(item[key]) &&
|
312
|
-
typeof obj[key] === 'number') {
|
313
|
-
obj[key] += parseFloat(item[key]) || 0;
|
314
|
-
}
|
315
|
-
else if (typeof item[key] === 'string' &&
|
316
|
-
typeof obj[key] === 'string') {
|
317
|
-
obj[key] += ", " + item[key];
|
318
|
-
}
|
319
|
-
else {
|
320
|
-
obj[key] = item[key];
|
321
|
-
}
|
322
|
-
});
|
323
|
-
return obj;
|
324
|
-
}, {});
|
325
|
-
if (index === len - 1) {
|
326
|
-
obj[labelField] = restLabel || '其他';
|
327
|
-
}
|
328
|
-
return obj;
|
329
|
-
});
|
330
|
-
}
|
331
|
-
return input;
|
332
|
-
},
|
333
|
-
first: function (input) { return input && input[0]; },
|
334
|
-
nth: function (input, nth) {
|
335
|
-
if (nth === void 0) { nth = 0; }
|
336
|
-
return input && input[nth];
|
337
|
-
},
|
338
|
-
last: function (input) { return input && (input.length ? input[input.length - 1] : null); },
|
339
|
-
minus: function (input, step) {
|
340
|
-
if (step === void 0) { step = 1; }
|
341
|
-
return stripNumber((Number(input) || 0) - Number(getStrOrVariable(step, this)));
|
342
|
-
},
|
343
|
-
plus: function (input, step) {
|
344
|
-
if (step === void 0) { step = 1; }
|
345
|
-
return stripNumber((Number(input) || 0) + Number(getStrOrVariable(step, this)));
|
346
|
-
},
|
347
|
-
times: function (input, step) {
|
348
|
-
if (step === void 0) { step = 1; }
|
349
|
-
return stripNumber((Number(input) || 0) * Number(getStrOrVariable(step, this)));
|
350
|
-
},
|
351
|
-
division: function (input, step) {
|
352
|
-
if (step === void 0) { step = 1; }
|
353
|
-
return stripNumber((Number(input) || 0) / Number(getStrOrVariable(step, this)));
|
354
|
-
},
|
355
|
-
count: function (input) {
|
356
|
-
return Array.isArray(input) || typeof input === 'string' ? input.length : 0;
|
357
|
-
},
|
358
|
-
sum: function (input, field) {
|
359
|
-
if (!Array.isArray(input)) {
|
360
|
-
return input;
|
361
|
-
}
|
362
|
-
var restult = input.reduce(function (sum, item) {
|
363
|
-
return sum + (parseFloat(field ? pickValues(field, item) : item) || 0);
|
364
|
-
}, 0);
|
365
|
-
return stripNumber(restult);
|
366
|
-
},
|
367
|
-
abs: function (input) { return (typeof input === 'number' ? Math.abs(input) : input); },
|
368
|
-
pick: function (input, path) {
|
369
|
-
if (path === void 0) { path = '&'; }
|
370
|
-
return Array.isArray(input) && !/^\d+$/.test(path)
|
371
|
-
? input.map(function (item, index) {
|
372
|
-
return pickValues(path, (0, helper_1.createObject)({ index: index }, item));
|
373
|
-
})
|
374
|
-
: pickValues(path, input);
|
375
|
-
},
|
376
|
-
pick_if_exist: function (input, path) {
|
377
|
-
if (path === void 0) { path = '&'; }
|
378
|
-
return Array.isArray(input)
|
379
|
-
? input.map(function (item) { return (0, exports.resolveVariable)(path, item) || item; })
|
380
|
-
: (0, exports.resolveVariable)(path, input) || input;
|
381
|
-
},
|
382
|
-
str2date: function (input, inputFormat, outputFormat) {
|
383
|
-
if (inputFormat === void 0) { inputFormat = 'X'; }
|
384
|
-
if (outputFormat === void 0) { outputFormat = 'X'; }
|
385
|
-
return input
|
386
|
-
? (0, exports.filterDate)(input, this, inputFormat).format(outputFormat)
|
387
|
-
: '';
|
388
|
-
},
|
389
|
-
asArray: function (input) { return (Array.isArray(input) ? input : input ? [input] : input); },
|
390
|
-
concat: function (input) {
|
391
|
-
var _this = this;
|
392
|
-
var args = [];
|
393
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
394
|
-
args[_i - 1] = arguments[_i];
|
395
|
-
}
|
396
|
-
return Array.isArray(input)
|
397
|
-
? input.concat.apply(input, args.map(function (arg) { return getStrOrVariable(arg, _this); })) : input;
|
398
|
-
},
|
399
|
-
filter: function (input, keys, expOrDirective, arg1) {
|
400
|
-
if (!Array.isArray(input) || !keys || !expOrDirective) {
|
401
|
-
return input;
|
402
|
-
}
|
403
|
-
var directive = expOrDirective;
|
404
|
-
var fn = function () { return true; };
|
405
|
-
if (directive === 'isTrue') {
|
406
|
-
fn = function (value) { return !!value; };
|
407
|
-
}
|
408
|
-
else if (directive === 'isFalse') {
|
409
|
-
fn = function (value) { return !value; };
|
410
|
-
}
|
411
|
-
else if (directive === 'isExists') {
|
412
|
-
fn = function (value) { return typeof value !== 'undefined'; };
|
413
|
-
}
|
414
|
-
else if (directive === 'equals' || directive === 'equal') {
|
415
|
-
arg1 = arg1 ? getStrOrVariable(arg1, this) : '';
|
416
|
-
fn = function (value) { return arg1 == value; };
|
417
|
-
}
|
418
|
-
else if (directive === 'isIn') {
|
419
|
-
var list_1 = arg1 ? getStrOrVariable(arg1, this) : [];
|
420
|
-
list_1 = str2array(list_1);
|
421
|
-
list_1 = Array.isArray(list_1) ? list_1 : list_1 ? [list_1] : [];
|
422
|
-
fn = function (value) { return (list_1.length ? !!~list_1.indexOf(value) : true); };
|
423
|
-
}
|
424
|
-
else if (directive === 'notIn') {
|
425
|
-
var list_2 = arg1 ? getStrOrVariable(arg1, this) : [];
|
426
|
-
list_2 = str2array(list_2);
|
427
|
-
list_2 = Array.isArray(list_2) ? list_2 : list_2 ? [list_2] : [];
|
428
|
-
fn = function (value) { return !~list_2.indexOf(value); };
|
429
|
-
}
|
430
|
-
else {
|
431
|
-
if (directive !== 'match') {
|
432
|
-
directive = 'match';
|
433
|
-
arg1 = expOrDirective;
|
434
|
-
}
|
435
|
-
arg1 = arg1 ? getStrOrVariable(arg1, this) : '';
|
436
|
-
// 比对的值是空时直接返回。
|
437
|
-
if (!arg1) {
|
438
|
-
return input;
|
439
|
-
}
|
440
|
-
var reg_1 = (0, helper_1.string2regExp)("" + arg1, false);
|
441
|
-
fn = function (value) { return reg_1.test(String(value)); };
|
442
|
-
}
|
443
|
-
// 判断keys是否为*
|
444
|
-
var isAsterisk = /\s*\*\s*/.test(keys);
|
445
|
-
keys = keys.split(/\s*,\s*/);
|
446
|
-
return input.filter(function (item) {
|
447
|
-
// 当keys为*时从item中获取key
|
448
|
-
return (isAsterisk ? Object.keys(item) : keys).some(function (key) {
|
449
|
-
return fn((0, exports.resolveVariable)(key, item), key, item);
|
450
|
-
});
|
451
|
-
});
|
452
|
-
},
|
453
|
-
base64Encode: function (str) {
|
454
|
-
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function toSolidBytes(match, p1) {
|
455
|
-
return String.fromCharCode(('0x' + p1));
|
456
|
-
}));
|
457
|
-
},
|
458
|
-
base64Decode: function (str) {
|
459
|
-
return decodeURIComponent(atob(str)
|
460
|
-
.split('')
|
461
|
-
.map(function (c) {
|
462
|
-
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
463
|
-
})
|
464
|
-
.join(''));
|
465
|
-
},
|
466
|
-
lowerCase: function (input) {
|
467
|
-
return input && typeof input === 'string' ? input.toLowerCase() : input;
|
468
|
-
},
|
469
|
-
upperCase: function (input) {
|
470
|
-
return input && typeof input === 'string' ? input.toUpperCase() : input;
|
471
|
-
},
|
472
|
-
isTrue: function (input, trueValue, falseValue) {
|
473
|
-
return getConditionValue(input, !!input, trueValue, falseValue, this);
|
474
|
-
},
|
475
|
-
isFalse: function (input, trueValue, falseValue) {
|
476
|
-
return getConditionValue(input, !input, trueValue, falseValue, this);
|
477
|
-
},
|
478
|
-
isMatch: function (input, matchArg, trueValue, falseValue) {
|
479
|
-
matchArg = getStrOrVariable(matchArg, this);
|
480
|
-
return getConditionValue(input, matchArg && (0, helper_1.string2regExp)("" + matchArg, false).test(String(input)), trueValue, falseValue, this);
|
481
|
-
},
|
482
|
-
notMatch: function (input, matchArg, trueValue, falseValue) {
|
483
|
-
matchArg = getStrOrVariable(matchArg, this);
|
484
|
-
return getConditionValue(input, matchArg && !(0, helper_1.string2regExp)("" + matchArg, false).test(String(input)), trueValue, falseValue, this);
|
485
|
-
},
|
486
|
-
isEquals: function (input, equalsValue, trueValue, falseValue) {
|
487
|
-
equalsValue = /^\d+$/.test(equalsValue)
|
488
|
-
? parseInt(equalsValue, 10)
|
489
|
-
: getStrOrVariable(equalsValue, this);
|
490
|
-
return getConditionValue(input, input === equalsValue, trueValue, falseValue, this);
|
491
|
-
},
|
492
|
-
notEquals: function (input, equalsValue, trueValue, falseValue) {
|
493
|
-
equalsValue = /^\d+$/.test(equalsValue)
|
494
|
-
? parseInt(equalsValue, 10)
|
495
|
-
: getStrOrVariable(equalsValue, this);
|
496
|
-
return getConditionValue(input, input !== equalsValue, trueValue, falseValue, this);
|
497
|
-
}
|
498
|
-
};
|
499
|
-
/**
|
500
|
-
* 如果当前传入字符为:'xxx'或者"xxx",则返回字符xxx
|
501
|
-
* 否则去数据域中,获取变量xxx
|
502
|
-
*
|
503
|
-
* @param value 传入字符
|
504
|
-
* @param data 数据域
|
505
|
-
*/
|
506
|
-
function getStrOrVariable(value, data) {
|
507
|
-
return /^('|")(.*)\1$/.test(value)
|
508
|
-
? RegExp.$2
|
509
|
-
: /^-?\d+$/.test(value)
|
510
|
-
? parseInt(value, 10)
|
511
|
-
: /^(-?\d+)\.\d+?$/.test(value)
|
512
|
-
? parseFloat(value)
|
513
|
-
: /^\[.*\]$/.test(value)
|
514
|
-
? value
|
515
|
-
.substring(1, value.length - 1)
|
516
|
-
.split(/\s*,\s*/)
|
517
|
-
.filter(function (item) { return item; })
|
518
|
-
: /,/.test(value)
|
519
|
-
? value.split(/\s*,\s*/).filter(function (item) { return item; })
|
520
|
-
: (0, exports.resolveVariable)(value, data);
|
521
|
-
}
|
522
|
-
function str2array(list) {
|
523
|
-
if (list && typeof list === 'string') {
|
524
|
-
if (/^\[.*\]$/.test(list)) {
|
525
|
-
return list
|
526
|
-
.substring(1, list.length - 1)
|
527
|
-
.split(/\s*,\s*/)
|
528
|
-
.filter(function (item) { return item; });
|
529
|
-
}
|
530
|
-
else {
|
531
|
-
return list.split(/\s*,\s*/).filter(function (item) { return item; });
|
532
|
-
}
|
533
|
-
}
|
534
|
-
return list;
|
535
|
-
}
|
536
|
-
function getConditionValue(input, isTrue, trueValue, falseValue, data) {
|
537
|
-
return isTrue || (!isTrue && falseValue)
|
538
|
-
? getStrOrVariable(isTrue ? trueValue : falseValue, data)
|
539
|
-
: input;
|
540
|
-
}
|
541
|
-
function registerFilter(name, fn) {
|
542
|
-
exports.filters[name] = fn;
|
543
|
-
}
|
544
|
-
exports.registerFilter = registerFilter;
|
545
|
-
function getFilters() {
|
546
|
-
return exports.filters;
|
547
|
-
}
|
548
|
-
exports.getFilters = getFilters;
|
549
|
-
function pickValues(names, data) {
|
550
|
-
var _a;
|
551
|
-
var arr;
|
552
|
-
if (!names || ((arr = names.split(',')) && arr.length < 2)) {
|
553
|
-
var idx = names.indexOf('~');
|
554
|
-
if (~idx) {
|
555
|
-
var key = names.substring(0, idx);
|
556
|
-
var target = names.substring(idx + 1);
|
557
|
-
return _a = {},
|
558
|
-
_a[key] = (0, exports.resolveVariable)(target, data),
|
559
|
-
_a;
|
560
|
-
}
|
561
|
-
return (0, exports.resolveVariable)(names, data);
|
562
|
-
}
|
563
|
-
var ret = {};
|
564
|
-
arr.forEach(function (name) {
|
565
|
-
var idx = name.indexOf('~');
|
566
|
-
var target = name;
|
567
|
-
if (~idx) {
|
568
|
-
target = name.substring(idx + 1);
|
569
|
-
name = name.substring(0, idx);
|
570
|
-
}
|
571
|
-
(0, helper_1.setVariable)(ret, name, (0, exports.resolveVariable)(target, data));
|
572
|
-
});
|
573
|
-
return ret;
|
574
|
-
}
|
575
|
-
exports.pickValues = pickValues;
|
576
|
-
function objectGet(data, path) {
|
577
|
-
if (typeof data[path] !== 'undefined') {
|
578
|
-
return data[path];
|
579
|
-
}
|
580
|
-
var parts = (0, helper_1.keyToPath)(path.replace(/^{|}$/g, ''));
|
581
|
-
return parts.reduce(function (data, path) {
|
582
|
-
if (((0, helper_1.isObject)(data) || Array.isArray(data)) && path in data) {
|
583
|
-
return data[path];
|
584
|
-
}
|
585
|
-
return undefined;
|
586
|
-
}, data);
|
587
|
-
}
|
588
|
-
function parseJson(str, defaultValue) {
|
589
|
-
try {
|
590
|
-
return JSON.parse(str);
|
591
|
-
}
|
592
|
-
catch (e) {
|
593
|
-
return defaultValue;
|
594
|
-
}
|
595
|
-
}
|
596
|
-
function getCookie(name) {
|
597
|
-
var value = "; " + document.cookie;
|
598
|
-
var parts = value.split("; " + name + "=");
|
599
|
-
if (parts.length === 2) {
|
600
|
-
return parts.pop().split(';').shift();
|
601
|
-
}
|
602
|
-
return undefined;
|
603
|
-
}
|
604
|
-
var resolveVariable = function (path, data) {
|
605
|
-
if (data === void 0) { data = {}; }
|
606
|
-
if (!path || !data || typeof path !== 'string') {
|
607
|
-
return undefined;
|
608
|
-
}
|
609
|
-
var _a = path.split(':'), ns = _a[0], varname = _a[1];
|
610
|
-
if (!varname && ns) {
|
611
|
-
varname = ns;
|
612
|
-
ns = '';
|
613
|
-
}
|
614
|
-
if (ns === 'window') {
|
615
|
-
data = window;
|
616
|
-
}
|
617
|
-
else if (ns === 'ls' || ns === 'ss') {
|
618
|
-
var parts = (0, helper_1.keyToPath)(varname.replace(/^{|}$/g, ''));
|
619
|
-
var key = parts.shift();
|
620
|
-
var raw = ns === 'ss' ? sessionStorage.getItem(key) : localStorage.getItem(key);
|
621
|
-
if (typeof raw === 'string') {
|
622
|
-
var data_1 = parseJson(raw, raw);
|
623
|
-
if ((0, helper_1.isObject)(data_1) && parts.length) {
|
624
|
-
return objectGet(data_1, parts.join('.'));
|
625
|
-
}
|
626
|
-
return data_1;
|
627
|
-
}
|
628
|
-
return undefined;
|
629
|
-
}
|
630
|
-
else if (ns === 'cookie') {
|
631
|
-
var key = varname.replace(/^{|}$/g, '').trim();
|
632
|
-
return getCookie(key);
|
633
|
-
}
|
634
|
-
if (varname === '$$') {
|
635
|
-
return data;
|
636
|
-
}
|
637
|
-
else if (varname[0] === '$') {
|
638
|
-
varname = path.substring(1);
|
639
|
-
}
|
640
|
-
else if (varname === '&') {
|
641
|
-
return data;
|
642
|
-
}
|
643
|
-
return objectGet(data, varname);
|
644
|
-
};
|
645
|
-
exports.resolveVariable = resolveVariable;
|
646
|
-
function isPureVariable(path) {
|
647
|
-
return typeof path === 'string'
|
648
|
-
? /^\$(?:((?:\w+\:)?[a-z0-9_.][a-z0-9_.\[\]]*)|{[^}{]+})$/i.test(path)
|
649
|
-
: false;
|
650
|
-
}
|
651
|
-
exports.isPureVariable = isPureVariable;
|
652
|
-
var resolveVariableAndFilter = function (path, data, defaultFilter, fallbackValue) {
|
653
|
-
if (data === void 0) { data = {}; }
|
654
|
-
if (defaultFilter === void 0) { defaultFilter = '| html'; }
|
655
|
-
if (fallbackValue === void 0) { fallbackValue = function (value) { return value; }; }
|
656
|
-
if (!path) {
|
657
|
-
return undefined;
|
658
|
-
}
|
659
|
-
var m = /^(\\)?\$(?:((?:\w+\:)?[a-z0-9_.][a-z0-9_.\[\]]*)|{([\s\S]+)})$/i.exec(path);
|
660
|
-
if (!m) {
|
661
|
-
return undefined;
|
662
|
-
}
|
663
|
-
var _ = m[0], escape = m[1], key = m[2], key2 = m[3];
|
664
|
-
// 如果是转义如: `\$abc` => `$abc`
|
665
|
-
if (escape) {
|
666
|
-
return _.substring(1);
|
667
|
-
}
|
668
|
-
var finalKey = key || key2;
|
669
|
-
// 先只支持一层吧
|
670
|
-
finalKey = finalKey.replace(/(\\|\\\$)?\$(?:([a-zA-Z0-9_.][a-zA-Z0-9_.\[\]]*)|{([^}{]+)})/g, function (_, escape) {
|
671
|
-
return escape
|
672
|
-
? _.substring(1)
|
673
|
-
: (0, exports.resolveVariableAndFilter)(_, data, defaultFilter);
|
674
|
-
});
|
675
|
-
// 默认 html 转义
|
676
|
-
if (!~finalKey.indexOf('|')) {
|
677
|
-
finalKey += defaultFilter;
|
678
|
-
}
|
679
|
-
var paths = finalKey.split(/\s*\|\s*/g);
|
680
|
-
var originalKey = finalKey;
|
681
|
-
finalKey = paths.shift();
|
682
|
-
var ret = (0, exports.resolveVariable)(finalKey, data);
|
683
|
-
var prevConInputChanged = false; // 前一个类三元过滤器生效,则跳过后续类三元过滤器
|
684
|
-
return ret == null &&
|
685
|
-
!~originalKey.indexOf('default') &&
|
686
|
-
!~originalKey.indexOf('now')
|
687
|
-
? fallbackValue(ret)
|
688
|
-
: paths.reduce(function (input, filter) {
|
689
|
-
var _a, _b;
|
690
|
-
var params = filter
|
691
|
-
.replace(/([^\\])\\([\:\\])/g, function (_, affix, content) {
|
692
|
-
return affix + "__" + (content === ':' ? 'colon' : 'slash') + "__";
|
693
|
-
})
|
694
|
-
.split(':')
|
695
|
-
.map(function (item) {
|
696
|
-
return item.replace(/__(slash|colon)__/g, function (_, type) {
|
697
|
-
return type === 'colon' ? ':' : '\\';
|
698
|
-
});
|
699
|
-
});
|
700
|
-
var key = params.shift();
|
701
|
-
if (~[
|
702
|
-
'isTrue',
|
703
|
-
'isFalse',
|
704
|
-
'isMatch',
|
705
|
-
'isEquals',
|
706
|
-
'notMatch',
|
707
|
-
'notEquals'
|
708
|
-
].indexOf(key)) {
|
709
|
-
if (prevConInputChanged) {
|
710
|
-
return input;
|
711
|
-
}
|
712
|
-
else {
|
713
|
-
var result = (_a = exports.filters[key]).call.apply(_a, (0, tslib_1.__spreadArray)([data, input], params, false));
|
714
|
-
prevConInputChanged = result !== input;
|
715
|
-
return result;
|
716
|
-
}
|
717
|
-
}
|
718
|
-
else {
|
719
|
-
// 后面再遇到非类三元filter就重置了吧,不影响再后面的其他三元filter
|
720
|
-
prevConInputChanged = false;
|
721
|
-
}
|
722
|
-
return (_b = (exports.filters[key] || exports.filters.raw)).call.apply(_b, (0, tslib_1.__spreadArray)([data, input], params, false));
|
723
|
-
}, ret);
|
724
|
-
};
|
725
|
-
exports.resolveVariableAndFilter = resolveVariableAndFilter;
|
726
|
-
var tokenize = function (str, data, defaultFilter) {
|
727
|
-
if (defaultFilter === void 0) { defaultFilter = '| html'; }
|
728
|
-
if (!str || typeof str !== 'string') {
|
729
|
-
return str;
|
730
|
-
}
|
731
|
-
return str.replace(/(\\)?\$(?:((?:\w+\:)?[a-z0-9_\.][a-z0-9_\.\[\]]*|&|\$)|{([^}{]+?)})/gi, function (_, escape, key1, key2, index, source) {
|
732
|
-
var _a;
|
733
|
-
if (!escape && key1 === '$') {
|
734
|
-
var prefix = source[index - 1];
|
735
|
-
return prefix === '='
|
736
|
-
? encodeURIComponent(JSON.stringify(data))
|
737
|
-
: (0, helper_1.qsstringify)(data);
|
738
|
-
}
|
739
|
-
return escape
|
740
|
-
? _.substring(1)
|
741
|
-
: (_a = (0, exports.resolveVariableAndFilter)(_, data, defaultFilter)) !== null && _a !== void 0 ? _a : '';
|
742
|
-
});
|
743
|
-
};
|
744
|
-
exports.tokenize = tokenize;
|
7
|
+
var amis_formula_1 = require("amis-formula");
|
8
|
+
Object.defineProperty(exports, "prettyBytes", { enumerable: true, get: function () { return amis_formula_1.prettyBytes; } });
|
9
|
+
Object.defineProperty(exports, "escapeHtml", { enumerable: true, get: function () { return amis_formula_1.escapeHtml; } });
|
10
|
+
Object.defineProperty(exports, "formatDuration", { enumerable: true, get: function () { return amis_formula_1.formatDuration; } });
|
11
|
+
Object.defineProperty(exports, "filterDate", { enumerable: true, get: function () { return amis_formula_1.filterDate; } });
|
12
|
+
Object.defineProperty(exports, "relativeValueRe", { enumerable: true, get: function () { return amis_formula_1.relativeValueRe; } });
|
13
|
+
Object.defineProperty(exports, "parseDuration", { enumerable: true, get: function () { return amis_formula_1.parseDuration; } });
|
14
|
+
Object.defineProperty(exports, "getFilters", { enumerable: true, get: function () { return amis_formula_1.getFilters; } });
|
15
|
+
Object.defineProperty(exports, "registerFilter", { enumerable: true, get: function () { return amis_formula_1.registerFilter; } });
|
16
|
+
Object.defineProperty(exports, "pickValues", { enumerable: true, get: function () { return amis_formula_1.pickValues; } });
|
17
|
+
Object.defineProperty(exports, "resolveVariable", { enumerable: true, get: function () { return amis_formula_1.resolveVariable; } });
|
18
|
+
Object.defineProperty(exports, "isPureVariable", { enumerable: true, get: function () { return amis_formula_1.isPureVariable; } });
|
19
|
+
Object.defineProperty(exports, "resolveVariableAndFilter", { enumerable: true, get: function () { return amis_formula_1.resolveVariableAndFilter; } });
|
20
|
+
Object.defineProperty(exports, "tokenize", { enumerable: true, get: function () { return amis_formula_1.tokenize; } });
|
21
|
+
Object.defineProperty(exports, "stripNumber", { enumerable: true, get: function () { return amis_formula_1.stripNumber; } });
|
745
22
|
function resolveMapping(value, data, defaultFilter) {
|
746
23
|
if (defaultFilter === void 0) { defaultFilter = '| raw'; }
|
747
|
-
return typeof value === 'string' && isPureVariable(value)
|
748
|
-
? (0,
|
24
|
+
return typeof value === 'string' && (0, amis_formula_1.isPureVariable)(value)
|
25
|
+
? (0, amis_formula_1.resolveVariableAndFilter)(value, data, defaultFilter, function () { return ''; })
|
749
26
|
: typeof value === 'string' && ~value.indexOf('$')
|
750
|
-
? (0,
|
27
|
+
? (0, amis_formula_1.tokenize)(value, data, defaultFilter)
|
751
28
|
: value;
|
752
29
|
}
|
753
30
|
exports.resolveMapping = resolveMapping;
|
@@ -892,7 +169,12 @@ function register() {
|
|
892
169
|
},
|
893
170
|
compile: function (str, data, defaultFilter) {
|
894
171
|
if (defaultFilter === void 0) { defaultFilter = '| html'; }
|
895
|
-
|
172
|
+
try {
|
173
|
+
return (0, amis_formula_1.tokenize)(str, data, defaultFilter);
|
174
|
+
}
|
175
|
+
catch (e) {
|
176
|
+
return "error: " + e.message;
|
177
|
+
}
|
896
178
|
}
|
897
179
|
};
|
898
180
|
}
|