framework7 7.0.9 → 8.0.0-beta.1
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/components/accordion/accordion.js +2 -16
- package/components/accordion/accordion.less +0 -3
- package/components/actions/actions-class.js +13 -58
- package/components/actions/actions-ios.less +42 -0
- package/components/actions/actions-md.less +12 -0
- package/components/actions/actions-rtl.css +1 -1
- package/components/actions/actions-vars.less +17 -42
- package/components/actions/actions.css +1 -1
- package/components/actions/actions.d.ts +2 -2
- package/components/actions/actions.js +0 -4
- package/components/actions/actions.lazy.js +1 -1
- package/components/actions/actions.less +5 -35
- package/components/app/app-class.d.ts +14 -12
- package/components/app/app-class.js +93 -75
- package/components/app/app-ios.less +0 -2
- package/components/app/app-md.less +0 -2
- package/components/app/app-vars.less +13 -96
- package/components/app/app.less +1 -4
- package/components/app/load-module.js +17 -36
- package/components/area-chart/area-chart-class.js +8 -64
- package/components/area-chart/area-chart.js +0 -3
- package/components/area-chart/area-chart.less +0 -3
- package/components/autocomplete/autocomplete-class.js +30 -175
- package/components/autocomplete/autocomplete-ios.less +0 -8
- package/components/autocomplete/autocomplete-rtl.css +1 -1
- package/components/autocomplete/autocomplete-vars.less +8 -22
- package/components/autocomplete/autocomplete.css +1 -1
- package/components/autocomplete/autocomplete.d.ts +1 -3
- package/components/autocomplete/autocomplete.js +1 -6
- package/components/autocomplete/autocomplete.lazy.js +1 -1
- package/components/autocomplete/autocomplete.less +6 -18
- package/components/badge/badge-vars.less +3 -6
- package/components/badge/badge.less +1 -3
- package/components/block/block-vars.less +25 -52
- package/components/block/block.less +37 -12
- package/components/breadcrumbs/breadcrumbs-rtl.css +1 -1
- package/components/breadcrumbs/breadcrumbs-vars.less +31 -15
- package/components/breadcrumbs/breadcrumbs.css +1 -1
- package/components/breadcrumbs/breadcrumbs.js +0 -2
- package/components/breadcrumbs/breadcrumbs.less +4 -10
- package/components/button/button-vars.less +42 -43
- package/components/button/button.less +24 -26
- package/components/calendar/calendar-class.js +81 -401
- package/components/calendar/calendar-rtl.css +1 -1
- package/components/calendar/calendar-vars.less +32 -46
- package/components/calendar/calendar.css +1 -1
- package/components/calendar/calendar.js +6 -4
- package/components/calendar/calendar.lazy.js +1 -1
- package/components/calendar/calendar.less +10 -21
- package/components/card/card-rtl.css +1 -1
- package/components/card/card-vars.less +41 -44
- package/components/card/card.css +1 -1
- package/components/card/card.js +0 -108
- package/components/card/card.less +18 -24
- package/components/checkbox/checkbox-rtl.css +1 -1
- package/components/checkbox/checkbox-vars.less +0 -8
- package/components/checkbox/checkbox.css +1 -1
- package/components/checkbox/checkbox.less +10 -3
- package/components/chip/chip-ios.less +3 -0
- package/components/chip/chip-md.less +4 -3
- package/components/chip/chip-rtl.css +1 -1
- package/components/chip/chip-vars.less +17 -20
- package/components/chip/chip.css +1 -1
- package/components/chip/chip.less +16 -21
- package/components/color-picker/color-picker-class.js +27 -158
- package/components/color-picker/color-picker-rtl.css +1 -1
- package/components/color-picker/color-picker.css +1 -1
- package/components/color-picker/color-picker.js +0 -4
- package/components/color-picker/color-picker.lazy.js +1 -1
- package/components/color-picker/color-picker.less +18 -8
- package/components/color-picker/modules/alpha-slider.js +0 -12
- package/components/color-picker/modules/brightness-slider.js +0 -8
- package/components/color-picker/modules/current-color.js +0 -2
- package/components/color-picker/modules/hex.js +0 -12
- package/components/color-picker/modules/hs-spectrum.js +0 -20
- package/components/color-picker/modules/hsb-sliders.js +0 -18
- package/components/color-picker/modules/hue-slider.js +0 -7
- package/components/color-picker/modules/initial-current-colors.js +0 -7
- package/components/color-picker/modules/palette.js +2 -10
- package/components/color-picker/modules/rgb-bars.js +0 -17
- package/components/color-picker/modules/rgb-sliders.js +0 -17
- package/components/color-picker/modules/sb-spectrum.js +0 -20
- package/components/color-picker/modules/wheel.js +0 -28
- package/components/contacts-list/contacts-list-md.less +4 -3
- package/components/contacts-list/contacts-list-rtl.css +1 -1
- package/components/contacts-list/contacts-list-vars.less +3 -15
- package/components/contacts-list/contacts-list.css +1 -1
- package/components/contacts-list/contacts-list.less +0 -3
- package/components/data-table/data-table-class.js +10 -32
- package/components/data-table/data-table-rtl.css +1 -1
- package/components/data-table/data-table-vars.less +6 -39
- package/components/data-table/data-table.css +1 -1
- package/components/data-table/data-table.js +0 -8
- package/components/data-table/data-table.less +0 -3
- package/components/dialog/dialog-class.js +7 -41
- package/components/dialog/dialog-ios.less +0 -3
- package/components/dialog/dialog-md.less +9 -9
- package/components/dialog/dialog-rtl.css +1 -1
- package/components/dialog/dialog-vars.less +25 -70
- package/components/dialog/dialog.css +1 -1
- package/components/dialog/dialog.d.ts +2 -2
- package/components/dialog/dialog.js +12 -48
- package/components/dialog/dialog.lazy.js +1 -1
- package/components/dialog/dialog.less +8 -4
- package/components/fab/fab-rtl.css +1 -1
- package/components/fab/fab-vars.less +20 -14
- package/components/fab/fab.css +1 -1
- package/components/fab/fab.js +0 -21
- package/components/fab/fab.less +50 -53
- package/components/form/form.d.ts +4 -4
- package/components/form/form.js +58 -94
- package/components/form/form.lazy.js +1 -1
- package/components/form/form.less +0 -3
- package/components/gauge/gauge-class.js +4 -20
- package/components/gauge/gauge.js +0 -9
- package/components/gauge/gauge.less +0 -3
- package/components/grid/grid-rtl.css +1 -1
- package/components/grid/grid-vars.less +0 -7
- package/components/grid/grid.css +1 -1
- package/components/grid/grid.d.ts +2 -8
- package/components/grid/grid.js +1 -225
- package/components/grid/grid.lazy.js +1 -1
- package/components/grid/grid.less +54 -184
- package/components/icon/icon.less +0 -3
- package/components/infinite-scroll/infinite-scroll-rtl.css +1 -1
- package/components/infinite-scroll/infinite-scroll.css +1 -1
- package/components/infinite-scroll/infinite-scroll.js +0 -16
- package/components/infinite-scroll/infinite-scroll.less +0 -3
- package/components/input/input-ios.less +49 -41
- package/components/input/input-md.less +87 -19
- package/components/input/input-rtl.css +1 -1
- package/components/input/input-vars.less +26 -60
- package/components/input/input.css +1 -1
- package/components/input/input.js +8 -67
- package/components/input/input.less +67 -153
- package/components/link/link-vars.less +0 -5
- package/components/link/link.less +3 -3
- package/components/list/list-md.less +0 -7
- package/components/list/list-vars.less +59 -108
- package/components/list/list.less +122 -90
- package/components/list-index/list-index-class.js +12 -69
- package/components/list-index/list-index-rtl.css +1 -1
- package/components/list-index/list-index-vars.less +0 -7
- package/components/list-index/list-index.css +1 -1
- package/components/list-index/list-index.d.ts +1 -3
- package/components/list-index/list-index.js +0 -8
- package/components/list-index/list-index.lazy.js +1 -1
- package/components/list-index/list-index.less +4 -7
- package/components/login-screen/login-screen-class.js +4 -9
- package/components/login-screen/login-screen-rtl.css +1 -1
- package/components/login-screen/login-screen-vars.less +13 -12
- package/components/login-screen/login-screen.css +1 -1
- package/components/login-screen/login-screen.js +0 -4
- package/components/login-screen/login-screen.less +2 -8
- package/components/messagebar/messagebar-class.js +18 -79
- package/components/messagebar/messagebar-ios.less +36 -0
- package/components/messagebar/messagebar-md.less +96 -16
- package/components/messagebar/messagebar-rtl.css +1 -1
- package/components/messagebar/messagebar-vars.less +27 -50
- package/components/messagebar/messagebar.css +1 -1
- package/components/messagebar/messagebar.js +0 -8
- package/components/messagebar/messagebar.less +11 -42
- package/components/messages/messages-class.js +17 -110
- package/components/messages/messages-ios.less +9 -0
- package/components/messages/messages-md.less +63 -28
- package/components/messages/messages-rtl.css +1 -1
- package/components/messages/messages-vars.less +43 -50
- package/components/messages/messages.css +1 -1
- package/components/messages/messages.js +0 -8
- package/components/messages/messages.lazy.js +1 -1
- package/components/messages/messages.less +0 -11
- package/components/modal/custom-modal-class.js +4 -14
- package/components/modal/modal-class.js +19 -55
- package/components/modal/modal.js +0 -3
- package/components/navbar/navbar-ios.less +3 -39
- package/components/navbar/navbar-md.less +12 -0
- package/components/navbar/navbar-vars.less +20 -49
- package/components/navbar/navbar.d.ts +0 -2
- package/components/navbar/navbar.js +37 -166
- package/components/navbar/navbar.less +4 -26
- package/components/notification/notification-class.js +4 -39
- package/components/notification/notification-md.less +18 -8
- package/components/notification/notification-rtl.css +1 -1
- package/components/notification/notification-vars.less +15 -54
- package/components/notification/notification.css +1 -1
- package/components/notification/notification.js +0 -2
- package/components/notification/notification.lazy.js +1 -1
- package/components/notification/notification.less +0 -3
- package/components/page/page-md.less +40 -10
- package/components/page/page-transitions/circle.less +15 -9
- package/components/page/page-transitions/fade.less +17 -11
- package/components/page/page-transitions/flip.less +9 -4
- package/components/page/page-vars.less +3 -19
- package/components/page/page.less +2 -10
- package/components/panel/panel-class.js +23 -127
- package/components/panel/panel-md.less +9 -0
- package/components/panel/panel-rtl.css +1 -1
- package/components/panel/panel-vars.less +7 -21
- package/components/panel/panel.css +1 -1
- package/components/panel/panel.d.ts +2 -2
- package/components/panel/panel.js +0 -34
- package/components/panel/panel.lazy.js +1 -1
- package/components/panel/panel.less +56 -48
- package/components/panel/resizable-panel.js +2 -32
- package/components/panel/swipe-panel.js +16 -71
- package/components/photo-browser/photo-browser-class.js +41 -171
- package/components/photo-browser/photo-browser-rtl.css +1 -1
- package/components/photo-browser/photo-browser-vars.less +0 -3
- package/components/photo-browser/photo-browser.css +1 -1
- package/components/photo-browser/photo-browser.d.ts +2 -4
- package/components/photo-browser/photo-browser.js +1 -6
- package/components/photo-browser/photo-browser.lazy.js +1 -1
- package/components/photo-browser/photo-browser.less +0 -4
- package/components/picker/picker-class.js +26 -133
- package/components/picker/picker-column.js +11 -31
- package/components/picker/picker-ios.less +10 -0
- package/components/picker/picker-md.less +6 -0
- package/components/picker/picker-rtl.css +1 -1
- package/components/picker/picker-vars.less +9 -25
- package/components/picker/picker.css +1 -1
- package/components/picker/picker.js +0 -4
- package/components/picker/picker.lazy.js +1 -1
- package/components/picker/picker.less +0 -11
- package/components/pie-chart/pie-chart-class.js +8 -31
- package/components/pie-chart/pie-chart.js +0 -3
- package/components/pie-chart/pie-chart.less +0 -3
- package/components/popover/popover-class.js +72 -126
- package/components/popover/popover-ios.less +0 -50
- package/components/popover/popover-rtl.css +1 -1
- package/components/popover/popover-vars.less +6 -23
- package/components/popover/popover.css +1 -1
- package/components/popover/popover.d.ts +2 -0
- package/components/popover/popover.js +1 -12
- package/components/popover/popover.lazy.js +1 -1
- package/components/popover/popover.less +62 -5
- package/components/popup/popup-class.js +12 -78
- package/components/popup/popup-rtl.css +1 -1
- package/components/popup/popup-vars.less +7 -9
- package/components/popup/popup.css +1 -1
- package/components/popup/popup.js +0 -4
- package/components/popup/popup.lazy.js +1 -1
- package/components/popup/popup.less +4 -4
- package/components/preloader/preloader-ios.less +3 -1
- package/components/preloader/preloader-md.less +5 -1
- package/components/preloader/preloader-rtl.css +1 -1
- package/components/preloader/preloader-vars.less +0 -6
- package/components/preloader/preloader.css +1 -1
- package/components/preloader/preloader.js +8 -25
- package/components/preloader/preloader.lazy.js +1 -1
- package/components/preloader/preloader.less +6 -3
- package/components/progressbar/progressbar-rtl.css +1 -1
- package/components/progressbar/progressbar-vars.less +2 -12
- package/components/progressbar/progressbar.css +1 -1
- package/components/progressbar/progressbar.js +2 -31
- package/components/progressbar/progressbar.less +0 -3
- package/components/pull-to-refresh/pull-to-refresh-class.js +15 -107
- package/components/pull-to-refresh/pull-to-refresh-md.less +2 -1
- package/components/pull-to-refresh/pull-to-refresh-rtl.css +1 -1
- package/components/pull-to-refresh/pull-to-refresh-vars.less +0 -4
- package/components/pull-to-refresh/pull-to-refresh.css +1 -1
- package/components/pull-to-refresh/pull-to-refresh.js +0 -8
- package/components/pull-to-refresh/pull-to-refresh.lazy.js +1 -1
- package/components/pull-to-refresh/pull-to-refresh.less +0 -3
- package/components/radio/radio-rtl.css +1 -1
- package/components/radio/radio-vars.less +0 -7
- package/components/radio/radio.css +1 -1
- package/components/radio/radio.less +12 -5
- package/components/range/range-class.js +27 -112
- package/components/range/range-rtl.css +1 -1
- package/components/range/range-vars.less +10 -32
- package/components/range/range.css +1 -1
- package/components/range/range.js +0 -12
- package/components/range/range.less +0 -3
- package/components/searchbar/remove-diacritics.js +0 -4
- package/components/searchbar/searchbar-class.js +17 -138
- package/components/searchbar/searchbar-md.less +41 -16
- package/components/searchbar/searchbar-rtl.css +1 -1
- package/components/searchbar/searchbar-vars.less +25 -76
- package/components/searchbar/searchbar.css +1 -1
- package/components/searchbar/searchbar.d.ts +2 -2
- package/components/searchbar/searchbar.js +0 -15
- package/components/searchbar/searchbar.lazy.js +1 -1
- package/components/searchbar/searchbar.less +14 -28
- package/components/sheet/sheet-class.js +15 -110
- package/components/sheet/sheet-rtl.css +1 -1
- package/components/sheet/sheet-vars.less +17 -6
- package/components/sheet/sheet.css +1 -1
- package/components/sheet/sheet.js +0 -9
- package/components/sheet/sheet.lazy.js +1 -1
- package/components/sheet/sheet.less +10 -3
- package/components/skeleton/skeleton.less +1 -4
- package/components/smart-select/smart-select-class.js +36 -173
- package/components/smart-select/smart-select.d.ts +1 -3
- package/components/smart-select/smart-select.js +1 -14
- package/components/smart-select/smart-select.lazy.js +1 -1
- package/components/smart-select/smart-select.less +0 -3
- package/components/sortable/sortable-rtl.css +1 -1
- package/components/sortable/sortable-vars.less +8 -8
- package/components/sortable/sortable.css +1 -1
- package/components/sortable/sortable.js +0 -44
- package/components/sortable/sortable.less +0 -3
- package/components/statusbar/statusbar.js +0 -36
- package/components/statusbar/statusbar.less +0 -3
- package/components/stepper/stepper-class.js +10 -83
- package/components/stepper/stepper-rtl.css +1 -1
- package/components/stepper/stepper-vars.less +12 -24
- package/components/stepper/stepper.css +1 -1
- package/components/stepper/stepper.js +0 -12
- package/components/stepper/stepper.less +12 -23
- package/components/subnavbar/subnavbar-vars.less +3 -18
- package/components/subnavbar/subnavbar.js +0 -3
- package/components/subnavbar/subnavbar.less +1 -11
- package/components/swipeout/swipeout-rtl.css +1 -1
- package/components/swipeout/swipeout-vars.less +7 -6
- package/components/swipeout/swipeout.css +1 -1
- package/components/swipeout/swipeout.js +2 -99
- package/components/swipeout/swipeout.less +2 -7
- package/components/swiper/swiper-rtl.css +1 -1
- package/components/swiper/swiper.css +1 -1
- package/components/swiper/swiper.js +9 -30
- package/components/swiper/swiper.lazy.js +1 -1
- package/components/swiper/swiper.less +1 -16
- package/components/tabs/tabs-rtl.css +1 -1
- package/components/tabs/tabs.css +1 -1
- package/components/tabs/tabs.js +23 -60
- package/components/tabs/tabs.lazy.js +1 -1
- package/components/tabs/tabs.less +1 -3
- package/components/text-editor/text-editor-class.js +16 -102
- package/components/text-editor/text-editor-rtl.css +1 -1
- package/components/text-editor/text-editor-vars.less +12 -16
- package/components/text-editor/text-editor.css +1 -1
- package/components/text-editor/text-editor.js +0 -8
- package/components/text-editor/text-editor.lazy.js +1 -1
- package/components/text-editor/text-editor.less +0 -6
- package/components/timeline/timeline-rtl.css +1 -1
- package/components/timeline/timeline-vars.less +13 -47
- package/components/timeline/timeline.css +1 -1
- package/components/timeline/timeline.less +2 -9
- package/components/toast/toast-class.js +2 -16
- package/components/toast/toast-rtl.css +1 -1
- package/components/toast/toast-vars.less +5 -9
- package/components/toast/toast.css +1 -1
- package/components/toast/toast.js +0 -3
- package/components/toast/toast.less +0 -3
- package/components/toggle/toggle-class.js +6 -30
- package/components/toggle/toggle-ios.less +5 -1
- package/components/toggle/toggle-md.less +27 -11
- package/components/toggle/toggle-rtl.css +1 -1
- package/components/toggle/toggle-vars.less +19 -21
- package/components/toggle/toggle.css +1 -1
- package/components/toggle/toggle.js +0 -8
- package/components/toggle/toggle.less +0 -4
- package/components/toolbar/toolbar-ios.less +2 -2
- package/components/toolbar/toolbar-md.less +28 -4
- package/components/toolbar/toolbar-vars.less +17 -52
- package/components/toolbar/toolbar.js +5 -43
- package/components/toolbar/toolbar.less +27 -45
- package/components/tooltip/tooltip-class.js +10 -64
- package/components/tooltip/tooltip-rtl.css +1 -1
- package/components/tooltip/tooltip-vars.less +12 -3
- package/components/tooltip/tooltip.css +1 -1
- package/components/tooltip/tooltip.js +0 -15
- package/components/tooltip/tooltip.less +0 -3
- package/components/touch-ripple/touch-ripple-class.js +0 -13
- package/components/touch-ripple/touch-ripple.js +0 -4
- package/components/touch-ripple/touch-ripple.less +1 -5
- package/components/treeview/treeview-rtl.css +1 -1
- package/components/treeview/treeview-vars.less +0 -3
- package/components/treeview/treeview.css +1 -1
- package/components/treeview/treeview.js +2 -11
- package/components/treeview/treeview.lazy.js +1 -1
- package/components/treeview/treeview.less +0 -3
- package/components/typography/typography-rtl.css +1 -1
- package/components/typography/typography.css +1 -1
- package/components/typography/typography.less +25 -3
- package/components/view/resizable-view.js +2 -24
- package/components/view/view-class.js +28 -53
- package/components/view/view.d.ts +0 -14
- package/components/view/view.js +8 -32
- package/components/view/view.less +1 -4
- package/components/virtual-list/virtual-list-class.js +58 -146
- package/components/virtual-list/virtual-list.d.ts +1 -1
- package/components/virtual-list/virtual-list.js +0 -2
- package/components/virtual-list/virtual-list.lazy.js +1 -1
- package/components/virtual-list/virtual-list.less +0 -3
- package/framework7-bundle-rtl.css +3593 -5977
- package/framework7-bundle-rtl.min.css +3 -3
- package/framework7-bundle.css +3591 -5978
- package/framework7-bundle.esm.js +4 -10
- package/framework7-bundle.js +6063 -12044
- package/framework7-bundle.js.map +1 -1
- package/framework7-bundle.less +2 -27
- package/framework7-bundle.min.css +3 -3
- package/framework7-bundle.min.js +3 -3
- package/framework7-bundle.min.js.map +1 -1
- package/framework7-lite-bundle.esm.js +4 -10
- package/framework7-lite.esm.js +4 -6
- package/framework7-lite.js +31 -0
- package/framework7-rtl.css +803 -1591
- package/framework7-rtl.min.css +3 -3
- package/framework7-types.d.ts +1 -32
- package/framework7.css +803 -1594
- package/framework7.d.ts +1 -32
- package/framework7.esm.js +4 -6
- package/framework7.js +1770 -3407
- package/framework7.js.map +1 -1
- package/framework7.less +2 -23
- package/framework7.min.css +3 -3
- package/framework7.min.js +3 -3
- package/framework7.min.js.map +1 -1
- package/less/mixins.less +7 -88
- package/less/plugin.js +15 -0
- package/modules/clicks/clicks.js +10 -22
- package/modules/component/$h.js +0 -3
- package/modules/component/$jsx.js +0 -5
- package/modules/component/component-class.js +13 -66
- package/modules/component/component.d.ts +1 -2
- package/modules/component/component.js +0 -8
- package/modules/component/eventslisteners.js +12 -20
- package/modules/component/parse-component.js +18 -20
- package/modules/component/snabbdom/h.js +3 -12
- package/modules/component/snabbdom/helpers/attachto.js +9 -14
- package/modules/component/snabbdom/htmldomapi.js +0 -16
- package/modules/component/snabbdom/modules/attributes.js +7 -11
- package/modules/component/snabbdom/modules/class.js +4 -8
- package/modules/component/snabbdom/modules/dataset.js +3 -7
- package/modules/component/snabbdom/modules/eventlisteners.js +16 -22
- package/modules/component/snabbdom/modules/hero.js +4 -44
- package/modules/component/snabbdom/modules/props.js +5 -9
- package/modules/component/snabbdom/modules/style.js +13 -30
- package/modules/component/snabbdom/snabbdom.bundle.js +0 -6
- package/modules/component/snabbdom/snabbdom.js +13 -72
- package/modules/component/snabbdom/thunk.js +3 -11
- package/modules/component/snabbdom/tovnode.js +1 -6
- package/modules/component/vdom.js +4 -62
- package/modules/demo-module.js +0 -8
- package/modules/device/device.js +6 -11
- package/modules/history/history.js +0 -1
- package/modules/resize/resize.js +8 -11
- package/modules/router/async-component.js +0 -3
- package/modules/router/back.js +86 -275
- package/modules/router/clear-previous-history.js +5 -18
- package/modules/router/component-loader.js +4 -25
- package/modules/router/modal.js +16 -43
- package/modules/router/navigate.js +80 -249
- package/modules/router/process-route-queue.js +0 -12
- package/modules/router/redirect.js +0 -8
- package/modules/router/router-class.js +92 -315
- package/modules/router/router.d.ts +3 -5
- package/modules/router/router.js +0 -3
- package/modules/router/swipe-back.js +35 -139
- package/modules/router/tab.js +14 -43
- package/modules/service-worker/service-worker.js +0 -11
- package/modules/store/create-store.js +10 -29
- package/modules/touch/touch.d.ts +2 -4
- package/modules/touch/touch.js +13 -108
- package/package.json +4 -18
- package/shared/$jsx.js +0 -6
- package/shared/class.js +18 -43
- package/shared/constructor-methods.js +0 -11
- package/shared/events-class.js +0 -17
- package/shared/get-device.js +18 -34
- package/shared/get-support.js +2 -8
- package/shared/history.js +2 -30
- package/shared/material-color-utils.js +728 -0
- package/shared/material-colors.js +75 -0
- package/shared/modal-methods.js +0 -18
- package/shared/utils.d.ts +0 -4
- package/shared/utils.js +191 -71
- package/components/accordion/accordion-aurora.less +0 -2
- package/components/actions/actions-aurora.less +0 -9
- package/components/app/app-aurora.less +0 -10
- package/components/appbar/appbar-aurora.less +0 -2
- package/components/appbar/appbar-ios.less +0 -2
- package/components/appbar/appbar-md.less +0 -2
- package/components/appbar/appbar-rtl.css +0 -1
- package/components/appbar/appbar-vars.less +0 -28
- package/components/appbar/appbar.css +0 -1
- package/components/appbar/appbar.d.ts +0 -14
- package/components/appbar/appbar.js +0 -3
- package/components/appbar/appbar.lazy.js +0 -1
- package/components/appbar/appbar.less +0 -106
- package/components/area-chart/area-chart-aurora.less +0 -2
- package/components/autocomplete/autocomplete-aurora.less +0 -17
- package/components/badge/badge-aurora.less +0 -2
- package/components/block/block-aurora.less +0 -2
- package/components/breadcrumbs/breadcrumbs-aurora.less +0 -2
- package/components/button/button-aurora.less +0 -25
- package/components/calendar/calendar-aurora.less +0 -2
- package/components/card/card-aurora.less +0 -2
- package/components/checkbox/checkbox-aurora.less +0 -39
- package/components/chip/chip-aurora.less +0 -14
- package/components/color-picker/color-picker-aurora.less +0 -2
- package/components/contacts-list/contacts-list-aurora.less +0 -2
- package/components/data-table/data-table-aurora.less +0 -64
- package/components/dialog/dialog-aurora.less +0 -112
- package/components/elevation/elevation-aurora.less +0 -2
- package/components/elevation/elevation-ios.less +0 -2
- package/components/elevation/elevation-md.less +0 -2
- package/components/elevation/elevation-rtl.css +0 -1
- package/components/elevation/elevation-vars.less +0 -51
- package/components/elevation/elevation.css +0 -1
- package/components/elevation/elevation.d.ts +0 -14
- package/components/elevation/elevation.js +0 -3
- package/components/elevation/elevation.lazy.js +0 -1
- package/components/elevation/elevation.less +0 -54
- package/components/fab/fab-aurora.less +0 -2
- package/components/form/form-aurora.less +0 -0
- package/components/gauge/gauge-aurora.less +0 -2
- package/components/grid/grid-aurora.less +0 -2
- package/components/icon/icon-aurora.less +0 -49
- package/components/infinite-scroll/infinite-scroll-aurora.less +0 -6
- package/components/input/input-aurora.less +0 -120
- package/components/lazy/lazy-aurora.less +0 -2
- package/components/lazy/lazy-ios.less +0 -2
- package/components/lazy/lazy-md.less +0 -2
- package/components/lazy/lazy-rtl.css +0 -1
- package/components/lazy/lazy.css +0 -1
- package/components/lazy/lazy.d.ts +0 -57
- package/components/lazy/lazy.js +0 -283
- package/components/lazy/lazy.lazy.js +0 -1
- package/components/lazy/lazy.less +0 -23
- package/components/link/link-aurora.less +0 -15
- package/components/list/list-aurora.less +0 -25
- package/components/list-index/list-index-aurora.less +0 -21
- package/components/login-screen/login-screen-aurora.less +0 -2
- package/components/menu/menu-aurora.less +0 -8
- package/components/menu/menu-ios.less +0 -2
- package/components/menu/menu-md.less +0 -2
- package/components/menu/menu-rtl.css +0 -1
- package/components/menu/menu-vars.less +0 -27
- package/components/menu/menu.css +0 -1
- package/components/menu/menu.d.ts +0 -32
- package/components/menu/menu.js +0 -87
- package/components/menu/menu.lazy.js +0 -1
- package/components/menu/menu.less +0 -232
- package/components/messagebar/messagebar-aurora.less +0 -53
- package/components/messages/messages-aurora.less +0 -137
- package/components/navbar/navbar-aurora.less +0 -70
- package/components/notification/notification-aurora.less +0 -59
- package/components/page/page-aurora.less +0 -49
- package/components/panel/panel-aurora.less +0 -2
- package/components/photo-browser/photo-browser-aurora.less +0 -2
- package/components/picker/picker-aurora.less +0 -2
- package/components/pie-chart/pie-chart-aurora.less +0 -2
- package/components/popover/popover-aurora.less +0 -56
- package/components/popup/popup-aurora.less +0 -2
- package/components/preloader/preloader-aurora.less +0 -53
- package/components/progressbar/progressbar-aurora.less +0 -72
- package/components/pull-to-refresh/pull-to-refresh-aurora.less +0 -122
- package/components/radio/radio-aurora.less +0 -86
- package/components/range/range-aurora.less +0 -9
- package/components/searchbar/searchbar-aurora.less +0 -86
- package/components/sheet/sheet-aurora.less +0 -2
- package/components/skeleton/skeleton-aurora.less +0 -2
- package/components/smart-select/smart-select-aurora.less +0 -2
- package/components/sortable/sortable-aurora.less +0 -7
- package/components/statusbar/statusbar-aurora.less +0 -2
- package/components/stepper/stepper-aurora.less +0 -32
- package/components/subnavbar/subnavbar-aurora.less +0 -51
- package/components/swipeout/swipeout-aurora.less +0 -2
- package/components/swiper/swiper-aurora.less +0 -2
- package/components/tabs/tabs-aurora.less +0 -2
- package/components/text-editor/text-editor-aurora.less +0 -9
- package/components/timeline/timeline-aurora.less +0 -7
- package/components/toast/toast-aurora.less +0 -64
- package/components/toggle/toggle-aurora.less +0 -26
- package/components/toolbar/toolbar-aurora.less +0 -43
- package/components/tooltip/tooltip-aurora.less +0 -2
- package/components/touch-ripple/touch-ripple-aurora.less +0 -2
- package/components/treeview/treeview-aurora.less +0 -31
- package/components/typography/typography-aurora.less +0 -2
- package/components/view/view-aurora.less +0 -2
- package/components/virtual-list/virtual-list-aurora.less +0 -2
- package/modules/request/request.d.ts +0 -15
- package/modules/request/request.js +0 -11
- package/postinstall.js +0 -3
- package/shared/request.d.ts +0 -115
- package/shared/request.js +0 -512
package/shared/request.js
DELETED
|
@@ -1,512 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-classes-per-file */
|
|
2
|
-
import { getWindow, getDocument } from 'ssr-window';
|
|
3
|
-
import { extend, serializeObject } from './utils.js';
|
|
4
|
-
const globals = {};
|
|
5
|
-
let jsonpRequests = 0;
|
|
6
|
-
|
|
7
|
-
class RequestResponse {
|
|
8
|
-
constructor(obj) {
|
|
9
|
-
Object.assign(this, obj);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
class RequestError extends Error {
|
|
15
|
-
constructor(obj) {
|
|
16
|
-
super();
|
|
17
|
-
Object.assign(this, obj);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const request = requestOptions => new Promise((resolve, reject) => {
|
|
23
|
-
const window = getWindow();
|
|
24
|
-
const document = getDocument();
|
|
25
|
-
const globalsNoCallbacks = extend({}, globals);
|
|
26
|
-
'beforeCreate beforeOpen beforeSend error complete success statusCode'.split(' ').forEach(callbackName => {
|
|
27
|
-
delete globalsNoCallbacks[callbackName];
|
|
28
|
-
});
|
|
29
|
-
const defaults = extend({
|
|
30
|
-
url: window.location.toString(),
|
|
31
|
-
method: 'GET',
|
|
32
|
-
data: false,
|
|
33
|
-
async: true,
|
|
34
|
-
cache: true,
|
|
35
|
-
user: '',
|
|
36
|
-
password: '',
|
|
37
|
-
headers: {},
|
|
38
|
-
xhrFields: {},
|
|
39
|
-
statusCode: {},
|
|
40
|
-
processData: true,
|
|
41
|
-
dataType: 'text',
|
|
42
|
-
contentType: 'application/x-www-form-urlencoded',
|
|
43
|
-
timeout: 0
|
|
44
|
-
}, globalsNoCallbacks);
|
|
45
|
-
let proceedRequest;
|
|
46
|
-
const options = extend({}, defaults, requestOptions);
|
|
47
|
-
|
|
48
|
-
if (requestOptions.abortController) {
|
|
49
|
-
options.abortController = requestOptions.abortController;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (options.abortController && options.abortController.canceled) {
|
|
53
|
-
reject(new RequestError({
|
|
54
|
-
options,
|
|
55
|
-
status: 'canceled',
|
|
56
|
-
message: 'canceled'
|
|
57
|
-
}));
|
|
58
|
-
return;
|
|
59
|
-
} // Function to run XHR callbacks and events
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
function fireCallback(callbackName) {
|
|
63
|
-
/*
|
|
64
|
-
Callbacks:
|
|
65
|
-
beforeCreate (options),
|
|
66
|
-
beforeOpen (xhr, options),
|
|
67
|
-
beforeSend (xhr, options),
|
|
68
|
-
error (xhr, status, message),
|
|
69
|
-
complete (xhr, status),
|
|
70
|
-
success (response, status, xhr),
|
|
71
|
-
statusCode ()
|
|
72
|
-
*/
|
|
73
|
-
let globalCallbackValue;
|
|
74
|
-
let optionCallbackValue;
|
|
75
|
-
|
|
76
|
-
for (var _len = arguments.length, data = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
77
|
-
data[_key - 1] = arguments[_key];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (globals[callbackName]) {
|
|
81
|
-
globalCallbackValue = globals[callbackName](...data);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (options[callbackName]) {
|
|
85
|
-
optionCallbackValue = options[callbackName](...data);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (typeof globalCallbackValue !== 'boolean') globalCallbackValue = true;
|
|
89
|
-
if (typeof optionCallbackValue !== 'boolean') optionCallbackValue = true;
|
|
90
|
-
|
|
91
|
-
if (options.abortController && options.abortController.canceled && (callbackName === 'beforeCreate' || callbackName === 'beforeOpen' || callbackName === 'beforeSend')) {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return globalCallbackValue && optionCallbackValue;
|
|
96
|
-
} // Before create callback
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
proceedRequest = fireCallback('beforeCreate', options);
|
|
100
|
-
|
|
101
|
-
if (proceedRequest === false) {
|
|
102
|
-
reject(new RequestError({
|
|
103
|
-
options,
|
|
104
|
-
status: 'canceled',
|
|
105
|
-
message: 'canceled'
|
|
106
|
-
}));
|
|
107
|
-
return;
|
|
108
|
-
} // For jQuery guys
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (options.type) options.method = options.type; // Parameters Prefix
|
|
112
|
-
|
|
113
|
-
let paramsPrefix = options.url.indexOf('?') >= 0 ? '&' : '?'; // UC method
|
|
114
|
-
|
|
115
|
-
const method = options.method.toUpperCase(); // Data to modify GET URL
|
|
116
|
-
|
|
117
|
-
if ((method === 'GET' || method === 'HEAD' || method === 'OPTIONS' || method === 'DELETE') && options.data) {
|
|
118
|
-
let stringData;
|
|
119
|
-
|
|
120
|
-
if (typeof options.data === 'string') {
|
|
121
|
-
// Should be key=value string
|
|
122
|
-
if (options.data.indexOf('?') >= 0) stringData = options.data.split('?')[1];else stringData = options.data;
|
|
123
|
-
} else {
|
|
124
|
-
// Should be key=value object
|
|
125
|
-
stringData = serializeObject(options.data);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (stringData.length) {
|
|
129
|
-
options.url += paramsPrefix + stringData;
|
|
130
|
-
if (paramsPrefix === '?') paramsPrefix = '&';
|
|
131
|
-
}
|
|
132
|
-
} // JSONP
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (options.dataType === 'json' && options.url.indexOf('callback=') >= 0) {
|
|
136
|
-
const callbackName = `f7jsonp_${Date.now() + (jsonpRequests += 1)}`;
|
|
137
|
-
let abortTimeout;
|
|
138
|
-
const callbackSplit = options.url.split('callback=');
|
|
139
|
-
let requestUrl = `${callbackSplit[0]}callback=${callbackName}`;
|
|
140
|
-
|
|
141
|
-
if (callbackSplit[1].indexOf('&') >= 0) {
|
|
142
|
-
const addVars = callbackSplit[1].split('&').filter(el => el.indexOf('=') > 0).join('&');
|
|
143
|
-
if (addVars.length > 0) requestUrl += `&${addVars}`;
|
|
144
|
-
} // Create script
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
let script = document.createElement('script');
|
|
148
|
-
script.type = 'text/javascript';
|
|
149
|
-
|
|
150
|
-
script.onerror = function onerror() {
|
|
151
|
-
clearTimeout(abortTimeout);
|
|
152
|
-
fireCallback('error', null, 'scripterror', 'scripterror');
|
|
153
|
-
reject(new RequestError({
|
|
154
|
-
options,
|
|
155
|
-
status: 'scripterror',
|
|
156
|
-
message: 'scripterror'
|
|
157
|
-
}));
|
|
158
|
-
fireCallback('complete', null, 'scripterror');
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
script.src = requestUrl; // Handler
|
|
162
|
-
|
|
163
|
-
window[callbackName] = function jsonpCallback(data) {
|
|
164
|
-
clearTimeout(abortTimeout);
|
|
165
|
-
fireCallback('success', data);
|
|
166
|
-
script.parentNode.removeChild(script);
|
|
167
|
-
script = null;
|
|
168
|
-
delete window[callbackName];
|
|
169
|
-
resolve(new RequestResponse({
|
|
170
|
-
options,
|
|
171
|
-
data
|
|
172
|
-
}));
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
document.querySelector('head').appendChild(script);
|
|
176
|
-
|
|
177
|
-
if (options.timeout > 0) {
|
|
178
|
-
abortTimeout = setTimeout(() => {
|
|
179
|
-
script.parentNode.removeChild(script);
|
|
180
|
-
script = null;
|
|
181
|
-
fireCallback('error', null, 'timeout', 'timeout');
|
|
182
|
-
reject(new RequestError({
|
|
183
|
-
options,
|
|
184
|
-
status: 'timeout',
|
|
185
|
-
message: 'timeout'
|
|
186
|
-
}));
|
|
187
|
-
}, options.timeout);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
return;
|
|
191
|
-
} // Cache for GET/HEAD requests
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (method === 'GET' || method === 'HEAD' || method === 'OPTIONS' || method === 'DELETE') {
|
|
195
|
-
if (options.cache === false) {
|
|
196
|
-
options.url += `${paramsPrefix}_nocache${Date.now()}`;
|
|
197
|
-
}
|
|
198
|
-
} // Create XHR
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const xhr = new XMLHttpRequest();
|
|
202
|
-
|
|
203
|
-
if (options.abortController) {
|
|
204
|
-
let aborted = false;
|
|
205
|
-
|
|
206
|
-
options.abortController.onAbort = () => {
|
|
207
|
-
if (aborted) return;
|
|
208
|
-
aborted = true;
|
|
209
|
-
xhr.abort();
|
|
210
|
-
reject(new RequestError({
|
|
211
|
-
options,
|
|
212
|
-
xhr,
|
|
213
|
-
status: 'canceled',
|
|
214
|
-
message: 'canceled'
|
|
215
|
-
}));
|
|
216
|
-
};
|
|
217
|
-
} // Save Request URL
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
xhr.requestUrl = options.url;
|
|
221
|
-
xhr.requestParameters = options; // Before open callback
|
|
222
|
-
|
|
223
|
-
proceedRequest = fireCallback('beforeOpen', xhr, options);
|
|
224
|
-
|
|
225
|
-
if (proceedRequest === false) {
|
|
226
|
-
reject(new RequestError({
|
|
227
|
-
options,
|
|
228
|
-
xhr,
|
|
229
|
-
status: 'canceled',
|
|
230
|
-
message: 'canceled'
|
|
231
|
-
}));
|
|
232
|
-
return;
|
|
233
|
-
} // Open XHR
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
xhr.open(method, options.url, options.async, options.user, options.password); // Create POST Data
|
|
237
|
-
|
|
238
|
-
let postData = null;
|
|
239
|
-
|
|
240
|
-
if ((method === 'POST' || method === 'PUT' || method === 'PATCH') && options.data) {
|
|
241
|
-
if (options.processData) {
|
|
242
|
-
const postDataInstances = [ArrayBuffer, Blob, Document, FormData]; // Post Data
|
|
243
|
-
|
|
244
|
-
if (postDataInstances.indexOf(options.data.constructor) >= 0) {
|
|
245
|
-
postData = options.data;
|
|
246
|
-
} else {
|
|
247
|
-
// POST Headers
|
|
248
|
-
const boundary = `---------------------------${Date.now().toString(16)}`;
|
|
249
|
-
|
|
250
|
-
if (options.contentType === 'multipart/form-data') {
|
|
251
|
-
xhr.setRequestHeader('Content-Type', `multipart/form-data; boundary=${boundary}`);
|
|
252
|
-
} else {
|
|
253
|
-
xhr.setRequestHeader('Content-Type', options.contentType);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
postData = '';
|
|
257
|
-
let data = serializeObject(options.data);
|
|
258
|
-
|
|
259
|
-
if (options.contentType === 'multipart/form-data') {
|
|
260
|
-
data = data.split('&');
|
|
261
|
-
const newData = [];
|
|
262
|
-
|
|
263
|
-
for (let i = 0; i < data.length; i += 1) {
|
|
264
|
-
newData.push(`Content-Disposition: form-data; name="${data[i].split('=')[0]}"\r\n\r\n${data[i].split('=')[1]}\r\n`);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
postData = `--${boundary}\r\n${newData.join(`--${boundary}\r\n`)}--${boundary}--\r\n`;
|
|
268
|
-
} else if (options.contentType === 'application/json') {
|
|
269
|
-
postData = JSON.stringify(options.data);
|
|
270
|
-
} else {
|
|
271
|
-
postData = data;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
} else {
|
|
275
|
-
postData = options.data;
|
|
276
|
-
xhr.setRequestHeader('Content-Type', options.contentType);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
if (options.dataType === 'json' && (!options.headers || !options.headers.Accept)) {
|
|
281
|
-
xhr.setRequestHeader('Accept', 'application/json');
|
|
282
|
-
} // Additional headers
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
if (options.headers) {
|
|
286
|
-
Object.keys(options.headers).forEach(headerName => {
|
|
287
|
-
if (typeof options.headers[headerName] === 'undefined') return;
|
|
288
|
-
xhr.setRequestHeader(headerName, options.headers[headerName]);
|
|
289
|
-
});
|
|
290
|
-
} // Check for crossDomain
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
if (typeof options.crossDomain === 'undefined') {
|
|
294
|
-
options.crossDomain = // eslint-disable-next-line
|
|
295
|
-
/^([\w-]+:)?\/\/([^\/]+)/.test(options.url) && RegExp.$2 !== window.location.host;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
if (!options.crossDomain) {
|
|
299
|
-
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
if (options.xhrFields) {
|
|
303
|
-
extend(xhr, options.xhrFields);
|
|
304
|
-
} // Handle XHR
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
xhr.onload = function onload() {
|
|
308
|
-
if (xhr.status >= 200 && xhr.status < 300 || xhr.status === 0) {
|
|
309
|
-
let responseData;
|
|
310
|
-
|
|
311
|
-
if (options.dataType === 'json') {
|
|
312
|
-
let parseError;
|
|
313
|
-
|
|
314
|
-
try {
|
|
315
|
-
responseData = JSON.parse(xhr.responseText);
|
|
316
|
-
} catch (err) {
|
|
317
|
-
parseError = true;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
if (!parseError) {
|
|
321
|
-
fireCallback('success', responseData, xhr.status, xhr);
|
|
322
|
-
resolve(new RequestResponse({
|
|
323
|
-
options,
|
|
324
|
-
data: responseData,
|
|
325
|
-
status: xhr.status,
|
|
326
|
-
xhr
|
|
327
|
-
}));
|
|
328
|
-
} else {
|
|
329
|
-
fireCallback('error', xhr, 'parseerror', 'parseerror');
|
|
330
|
-
reject(new RequestError({
|
|
331
|
-
options,
|
|
332
|
-
xhr,
|
|
333
|
-
status: 'parseerror',
|
|
334
|
-
message: 'parseerror'
|
|
335
|
-
}));
|
|
336
|
-
}
|
|
337
|
-
} else {
|
|
338
|
-
responseData = xhr.responseType === 'text' || xhr.responseType === '' ? xhr.responseText : xhr.response;
|
|
339
|
-
fireCallback('success', responseData, xhr.status, xhr);
|
|
340
|
-
resolve(new RequestResponse({
|
|
341
|
-
options,
|
|
342
|
-
data: responseData,
|
|
343
|
-
status: xhr.status,
|
|
344
|
-
xhr
|
|
345
|
-
}));
|
|
346
|
-
}
|
|
347
|
-
} else {
|
|
348
|
-
fireCallback('error', xhr, xhr.status, xhr.statusText);
|
|
349
|
-
reject(new RequestError({
|
|
350
|
-
options,
|
|
351
|
-
xhr,
|
|
352
|
-
status: xhr.status,
|
|
353
|
-
message: xhr.statusText
|
|
354
|
-
}));
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
if (options.statusCode) {
|
|
358
|
-
if (globals.statusCode && globals.statusCode[xhr.status]) globals.statusCode[xhr.status](xhr);
|
|
359
|
-
if (options.statusCode[xhr.status]) options.statusCode[xhr.status](xhr);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
fireCallback('complete', xhr, xhr.status);
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
xhr.onerror = function onerror() {
|
|
366
|
-
fireCallback('error', xhr, xhr.status, xhr.status);
|
|
367
|
-
reject(new RequestError({
|
|
368
|
-
options,
|
|
369
|
-
xhr,
|
|
370
|
-
status: xhr.status,
|
|
371
|
-
message: xhr.statusText
|
|
372
|
-
}));
|
|
373
|
-
fireCallback('complete', xhr, 'error');
|
|
374
|
-
}; // Timeout
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
if (options.timeout > 0) {
|
|
378
|
-
xhr.timeout = options.timeout;
|
|
379
|
-
|
|
380
|
-
xhr.ontimeout = () => {
|
|
381
|
-
fireCallback('error', xhr, 'timeout', 'timeout');
|
|
382
|
-
reject(new RequestError({
|
|
383
|
-
options,
|
|
384
|
-
xhr,
|
|
385
|
-
status: 'timeout',
|
|
386
|
-
message: 'timeout'
|
|
387
|
-
}));
|
|
388
|
-
fireCallback('complete', xhr, 'timeout');
|
|
389
|
-
};
|
|
390
|
-
} // Ajax start callback
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
proceedRequest = fireCallback('beforeSend', xhr, options);
|
|
394
|
-
|
|
395
|
-
if (proceedRequest === false) {
|
|
396
|
-
reject(new RequestError({
|
|
397
|
-
options,
|
|
398
|
-
xhr,
|
|
399
|
-
status: 'canceled',
|
|
400
|
-
message: 'canceled'
|
|
401
|
-
}));
|
|
402
|
-
return;
|
|
403
|
-
} // Send XHR
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
xhr.send(postData);
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
function requestShortcut(method) {
|
|
410
|
-
let [url, data, success, error, dataType] = [];
|
|
411
|
-
|
|
412
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
413
|
-
args[_key2 - 1] = arguments[_key2];
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
if (typeof args[1] === 'function') {
|
|
417
|
-
[url, success, error, dataType] = args;
|
|
418
|
-
} else {
|
|
419
|
-
[url, data, success, error, dataType] = args;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
[success, error].forEach(callback => {
|
|
423
|
-
if (typeof callback === 'string') {
|
|
424
|
-
dataType = callback;
|
|
425
|
-
if (callback === success) success = undefined;else error = undefined;
|
|
426
|
-
}
|
|
427
|
-
});
|
|
428
|
-
dataType = dataType || (method === 'json' || method === 'postJSON' ? 'json' : undefined);
|
|
429
|
-
const requestOptions = {
|
|
430
|
-
url,
|
|
431
|
-
method: method === 'post' || method === 'postJSON' ? 'POST' : 'GET',
|
|
432
|
-
data,
|
|
433
|
-
success,
|
|
434
|
-
error,
|
|
435
|
-
dataType
|
|
436
|
-
};
|
|
437
|
-
|
|
438
|
-
if (method === 'postJSON') {
|
|
439
|
-
extend(requestOptions, {
|
|
440
|
-
contentType: 'application/json',
|
|
441
|
-
processData: false,
|
|
442
|
-
crossDomain: true,
|
|
443
|
-
data: typeof data === 'string' ? data : JSON.stringify(data)
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
return request(requestOptions);
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
Object.assign(request, {
|
|
451
|
-
get: function () {
|
|
452
|
-
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
453
|
-
args[_key3] = arguments[_key3];
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
return requestShortcut('get', ...args);
|
|
457
|
-
},
|
|
458
|
-
post: function () {
|
|
459
|
-
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
460
|
-
args[_key4] = arguments[_key4];
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
return requestShortcut('post', ...args);
|
|
464
|
-
},
|
|
465
|
-
json: function () {
|
|
466
|
-
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
467
|
-
args[_key5] = arguments[_key5];
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
return requestShortcut('json', ...args);
|
|
471
|
-
},
|
|
472
|
-
getJSON: function () {
|
|
473
|
-
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
474
|
-
args[_key6] = arguments[_key6];
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
return requestShortcut('json', ...args);
|
|
478
|
-
},
|
|
479
|
-
postJSON: function () {
|
|
480
|
-
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
481
|
-
args[_key7] = arguments[_key7];
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
return requestShortcut('postJSON', ...args);
|
|
485
|
-
}
|
|
486
|
-
});
|
|
487
|
-
|
|
488
|
-
request.abortController = () => {
|
|
489
|
-
const contoller = {
|
|
490
|
-
canceled: false,
|
|
491
|
-
onAbort: null,
|
|
492
|
-
|
|
493
|
-
abort() {
|
|
494
|
-
contoller.canceled = true;
|
|
495
|
-
if (contoller.onAbort) contoller.onAbort();
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
};
|
|
499
|
-
return contoller;
|
|
500
|
-
};
|
|
501
|
-
|
|
502
|
-
request.setup = function setup(options) {
|
|
503
|
-
if (options.type && !options.method) {
|
|
504
|
-
extend(options, {
|
|
505
|
-
method: options.type
|
|
506
|
-
});
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
extend(globals, options);
|
|
510
|
-
};
|
|
511
|
-
|
|
512
|
-
export default request;
|