@king-design/vue 2.1.4 → 2.1.5
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/affix/index.d.ts +2 -2
- package/components/affix/index.js +5 -0
- package/components/affix/index.spec.js +108 -84
- package/components/affix/index.vdt.js +8 -5
- package/components/affix/useStyle.js +19 -8
- package/components/badge/index.js +2 -0
- package/components/badge/index.vdt.js +9 -5
- package/components/badge/styles.js +2 -0
- package/components/breadcrumb/index.js +4 -0
- package/components/breadcrumb/index.spec.js +6 -6
- package/components/breadcrumb/index.vdt.js +14 -5
- package/components/breadcrumb/item.js +8 -0
- package/components/breadcrumb/item.vdt.js +6 -3
- package/components/breadcrumb/styles.js +3 -0
- package/components/button/dynamicButton.d.ts +1 -1
- package/components/button/dynamicButton.js +5 -2
- package/components/button/group.js +10 -2
- package/components/button/group.vdt.js +7 -4
- package/components/button/index.js +27 -3
- package/components/button/index.spec.js +96 -74
- package/components/button/index.vdt.js +29 -19
- package/components/button/styles.d.ts +2 -2
- package/components/button/styles.js +48 -4
- package/components/card/column.js +2 -0
- package/components/card/column.vdt.js +10 -5
- package/components/card/index.js +4 -0
- package/components/card/index.vdt.js +16 -4
- package/components/carousel/index.js +19 -1
- package/components/carousel/index.spec.js +163 -127
- package/components/carousel/index.vdt.js +15 -12
- package/components/carousel/item.js +2 -0
- package/components/carousel/item.vdt.js +7 -4
- package/components/carousel/styles.js +1 -0
- package/components/carousel/useAutoplay.js +4 -0
- package/components/carousel/useItems.js +20 -4
- package/components/carousel/useSlide.js +89 -57
- package/components/cascader/index.d.ts +45 -0
- package/components/cascader/index.js +18 -3
- package/components/cascader/index.spec.js +445 -354
- package/components/cascader/index.vdt.js +31 -14
- package/components/cascader/styles.js +6 -0
- package/components/cascader/useFields.js +4 -1
- package/components/cascader/useFilterable.js +19 -2
- package/components/cascader/useLabel.js +9 -1
- package/components/cascader/useLoad.js +35 -22
- package/components/cascader/useValue.d.ts +2 -2
- package/components/cascader/useValue.js +26 -5
- package/components/checkbox/index.js +27 -5
- package/components/checkbox/index.spec.js +171 -129
- package/components/checkbox/index.vdt.js +16 -12
- package/components/checkbox/styles.js +10 -0
- package/components/code/crossDomain.js +9 -2
- package/components/code/index.js +9 -0
- package/components/code/index.spec.js +55 -46
- package/components/code/index.vdt.js +14 -6
- package/components/code/styles.js +1 -0
- package/components/code/useEditor.js +10 -5
- package/components/collapse/index.d.ts +1 -1
- package/components/collapse/index.js +14 -3
- package/components/collapse/index.spec.js +60 -47
- package/components/collapse/index.vdt.js +12 -4
- package/components/collapse/item.js +10 -0
- package/components/collapse/item.vdt.js +14 -7
- package/components/collapse/styles.js +1 -0
- package/components/colorpicker/drag.js +5 -0
- package/components/colorpicker/index.js +4 -0
- package/components/colorpicker/index.spec.js +259 -211
- package/components/colorpicker/index.vdt.js +11 -8
- package/components/colorpicker/panel.js +5 -0
- package/components/colorpicker/panel.vdt.js +26 -21
- package/components/colorpicker/styles.js +13 -2
- package/components/colorpicker/useDrag.js +26 -22
- package/components/colorpicker/useInput.js +16 -0
- package/components/colorpicker/usePointer.js +18 -15
- package/components/colorpicker/useValue.js +7 -2
- package/components/context.d.ts +2 -2
- package/components/context.js +19 -2
- package/components/datepicker/basepicker.d.ts +8 -8
- package/components/datepicker/basepicker.js +90 -20
- package/components/datepicker/calendar.js +11 -0
- package/components/datepicker/calendar.vdt.js +14 -11
- package/components/datepicker/constants.js +1 -0
- package/components/datepicker/dayjs.js +1 -1
- package/components/datepicker/helpers.js +15 -3
- package/components/datepicker/index.d.ts +63 -0
- package/components/datepicker/index.js +32 -6
- package/components/datepicker/index.spec.js +1448 -1141
- package/components/datepicker/index.vdt.js +34 -20
- package/components/datepicker/shortcuts.d.ts +1 -1
- package/components/datepicker/shortcuts.js +4 -0
- package/components/datepicker/styles.js +8 -0
- package/components/datepicker/time.d.ts +1 -1
- package/components/datepicker/time.js +23 -3
- package/components/datepicker/time.vdt.js +5 -4
- package/components/datepicker/useDays.js +9 -2
- package/components/datepicker/useDisabled.js +23 -6
- package/components/datepicker/useFocusDate.js +2 -0
- package/components/datepicker/useFormats.js +15 -6
- package/components/datepicker/useKeyboards.js +36 -20
- package/components/datepicker/useMonths.js +6 -0
- package/components/datepicker/usePanel.js +10 -0
- package/components/datepicker/useShowDate.js +37 -10
- package/components/datepicker/useStatus.js +15 -3
- package/components/datepicker/useValue.js +35 -22
- package/components/datepicker/useYears.js +15 -4
- package/components/diagram/diagram.js +43 -17
- package/components/diagram/diagram.vdt.js +5 -2
- package/components/diagram/graph.js +6 -6
- package/components/diagram/index.d.ts +1 -1
- package/components/diagram/index.js +7 -7
- package/components/diagram/index.spec.js +495 -369
- package/components/diagram/layouts/circle.js +14 -6
- package/components/diagram/layouts/flow.js +15 -7
- package/components/diagram/layouts/layout.js +28 -6
- package/components/diagram/layouts/organic.js +11 -3
- package/components/diagram/layouts/partition.js +12 -4
- package/components/diagram/layouts/radial.js +18 -6
- package/components/diagram/layouts/stack.js +14 -6
- package/components/diagram/layouts/tree.js +21 -11
- package/components/diagram/mxgraph/handler/mxConnectionHandler.js +22 -15
- package/components/diagram/mxgraph/handler/mxConstraintHandler.js +4 -4
- package/components/diagram/mxgraph/handler/mxEdgeHandler.js +15 -11
- package/components/diagram/mxgraph/handler/mxGraphHandler.js +9 -6
- package/components/diagram/mxgraph/handler/mxRubberband.js +4 -4
- package/components/diagram/mxgraph/handler/mxVertexHandler.js +10 -7
- package/components/diagram/mxgraph/index.js +2 -0
- package/components/diagram/mxgraph/mx.js +3 -3
- package/components/diagram/mxgraph/shape/mxCloud.js +2 -2
- package/components/diagram/mxgraph/shape/mxCylinder.js +9 -4
- package/components/diagram/mxgraph/shape/mxEllipse.js +2 -2
- package/components/diagram/mxgraph/shape/mxHexagon.js +2 -2
- package/components/diagram/mxgraph/shape/mxLine.js +2 -2
- package/components/diagram/mxgraph/shape/mxRectangleShape.js +2 -2
- package/components/diagram/mxgraph/shape/mxRhombus.js +12 -6
- package/components/diagram/mxgraph/shape/mxShape.js +1 -0
- package/components/diagram/mxgraph/shape/mxTriangle.js +2 -2
- package/components/diagram/mxgraph/util/mxConstants.js +2 -2
- package/components/diagram/mxgraph/util/mxGuide.js +7 -5
- package/components/diagram/mxgraph/view/mxCellEditor.js +29 -16
- package/components/diagram/mxgraph/view/mxCellRenderer.js +2 -0
- package/components/diagram/mxgraph/view/mxGraph.js +32 -14
- package/components/diagram/shapes/base.d.ts +1 -1
- package/components/diagram/shapes/base.js +39 -9
- package/components/diagram/shapes/callout.js +23 -10
- package/components/diagram/shapes/circle.js +10 -3
- package/components/diagram/shapes/document.js +16 -5
- package/components/diagram/shapes/ellipse.js +5 -0
- package/components/diagram/shapes/generateShapes.d.ts +1 -1
- package/components/diagram/shapes/generateShapes.js +9 -0
- package/components/diagram/shapes/hexagon.js +26 -9
- package/components/diagram/shapes/image.js +9 -1
- package/components/diagram/shapes/line.d.ts +2 -2
- package/components/diagram/shapes/line.js +48 -13
- package/components/diagram/shapes/parallelogram.js +26 -9
- package/components/diagram/shapes/rectangle.js +9 -1
- package/components/diagram/shapes/shape.js +35 -6
- package/components/diagram/shapes/square.js +11 -3
- package/components/diagram/shapes/text.js +5 -0
- package/components/diagram/styles.js +1 -0
- package/components/dialog/alert.vdt.js +19 -9
- package/components/dialog/base.js +29 -1
- package/components/dialog/base.vdt.js +29 -14
- package/components/dialog/index.js +31 -6
- package/components/dialog/index.spec.js +554 -406
- package/components/dialog/staticMethods.d.ts +1 -1
- package/components/dialog/staticMethods.js +13 -2
- package/components/dialog/styles.js +11 -0
- package/components/dialog/useDraggable.js +6 -0
- package/components/dialog/useEscClosable.js +12 -4
- package/components/dialog/useFixBody.d.ts +1 -1
- package/components/dialog/useFixBody.js +11 -0
- package/components/dialog/usePosition.js +5 -0
- package/components/drawer/index.js +5 -0
- package/components/drawer/index.spec.js +168 -126
- package/components/drawer/index.vdt.js +9 -3
- package/components/drawer/styles.d.ts +2 -2
- package/components/drawer/styles.js +4 -0
- package/components/dropdown/dropdown.d.ts +2 -2
- package/components/dropdown/dropdown.js +89 -33
- package/components/dropdown/index.js +6 -2
- package/components/dropdown/index.spec.js +496 -388
- package/components/dropdown/item.js +25 -4
- package/components/dropdown/item.vdt.js +8 -5
- package/components/dropdown/menu.js +29 -12
- package/components/dropdown/menu.vdt.js +13 -5
- package/components/dropdown/styles.js +9 -0
- package/components/dropdown/useKeyboard.d.ts +2 -2
- package/components/dropdown/useKeyboard.js +30 -8
- package/components/dropdown/usePosition.d.ts +1 -1
- package/components/dropdown/usePosition.js +22 -12
- package/components/dropdown/useTransition.js +8 -0
- package/components/editable/index.d.ts +1 -1
- package/components/editable/index.js +28 -4
- package/components/editable/index.spec.js +189 -152
- package/components/editable/index.vdt.js +11 -8
- package/components/editable/styles.js +1 -0
- package/components/form/form.js +18 -0
- package/components/form/form.vdt.js +7 -4
- package/components/form/index.spec.js +1280 -1057
- package/components/form/item.d.ts +1 -1
- package/components/form/item.js +12 -0
- package/components/form/item.vdt.js +31 -17
- package/components/form/methods.d.ts +5 -5
- package/components/form/methods.js +12 -2
- package/components/form/styles.js +8 -0
- package/components/form/useDirty.js +7 -2
- package/components/form/useError.js +10 -2
- package/components/form/useValidate.d.ts +1 -1
- package/components/form/useValidate.js +24 -8
- package/components/grid/col.d.ts +3 -3
- package/components/grid/col.js +7 -0
- package/components/grid/col.vdt.js +13 -8
- package/components/grid/constants.d.ts +6 -6
- package/components/grid/row.js +5 -0
- package/components/grid/row.vdt.js +8 -5
- package/components/grid/styles.js +7 -0
- package/components/grid/useBreakpoints.js +5 -0
- package/components/grid/useGutter.js +25 -5
- package/components/icon/index.js +10 -0
- package/components/icon/index.vdt.js +13 -7
- package/components/icon/styles.js +1 -0
- package/components/input/index.d.ts +3 -3
- package/components/input/index.js +14 -0
- package/components/input/index.spec.js +239 -185
- package/components/input/index.vdt.js +49 -39
- package/components/input/search.js +20 -0
- package/components/input/search.vdt.js +9 -6
- package/components/input/styles.js +26 -0
- package/components/input/useAutoRows.js +18 -6
- package/components/input/useAutoWidth.js +5 -0
- package/components/input/useFrozen.js +6 -0
- package/components/input/useShowPassword.js +5 -2
- package/components/layout/aside.js +17 -5
- package/components/layout/aside.vdt.js +9 -5
- package/components/layout/body.js +17 -5
- package/components/layout/footer.js +7 -1
- package/components/layout/header.js +21 -7
- package/components/layout/layout.js +24 -9
- package/components/layout/styles.js +13 -2
- package/components/layout/template.vdt.js +4 -2
- package/components/layout/useParse.js +7 -0
- package/components/menu/index.spec.js +242 -189
- package/components/menu/item.js +16 -3
- package/components/menu/item.vdt.js +32 -20
- package/components/menu/menu.js +11 -2
- package/components/menu/menu.vdt.js +12 -6
- package/components/menu/styles.js +18 -0
- package/components/menu/useDropdown.js +9 -4
- package/components/menu/useExpanded.js +14 -0
- package/components/menu/useHighlight.js +36 -26
- package/components/message/index.spec.js +73 -58
- package/components/message/message.js +19 -0
- package/components/message/message.vdt.js +8 -5
- package/components/message/messages.js +12 -0
- package/components/message/messages.vdt.js +1 -0
- package/components/message/styles.js +9 -0
- package/components/pagination/index.d.ts +1 -1
- package/components/pagination/index.js +46 -10
- package/components/pagination/index.spec.js +173 -133
- package/components/pagination/index.vdt.js +34 -14
- package/components/pagination/styles.js +4 -0
- package/components/portal.d.ts +1 -1
- package/components/portal.js +29 -2
- package/components/position.d.ts +12 -12
- package/components/position.js +88 -32
- package/components/progress/index.d.ts +6 -6
- package/components/progress/index.js +12 -0
- package/components/progress/index.spec.js +191 -143
- package/components/progress/index.vdt.js +11 -8
- package/components/progress/styles.js +6 -0
- package/components/progress/useColor.js +7 -2
- package/components/progress/useStatus.d.ts +1 -1
- package/components/progress/useStatus.js +5 -2
- package/components/radio/index.js +18 -3
- package/components/radio/index.spec.js +149 -111
- package/components/radio/index.vdt.js +17 -14
- package/components/radio/styles.js +10 -0
- package/components/rate/index.js +7 -0
- package/components/rate/index.spec.js +79 -64
- package/components/rate/index.vdt.js +21 -8
- package/components/rate/styles.js +3 -0
- package/components/rate/useActiveValue.js +7 -2
- package/components/scrollSelect/index.d.ts +2 -2
- package/components/scrollSelect/index.js +7 -0
- package/components/scrollSelect/index.spec.js +131 -100
- package/components/scrollSelect/index.vdt.js +11 -6
- package/components/scrollSelect/styles.js +7 -0
- package/components/scrollSelect/useList.js +17 -3
- package/components/scrollSelect/useMouseEvents.js +49 -31
- package/components/scrollSelect/useTranslate.js +11 -1
- package/components/select/base.js +35 -5
- package/components/select/base.vdt.js +38 -23
- package/components/select/group.js +5 -0
- package/components/select/group.vdt.js +10 -4
- package/components/select/index.spec.js +452 -361
- package/components/select/menu.js +5 -0
- package/components/select/menu.vdt.js +33 -18
- package/components/select/option.js +16 -2
- package/components/select/option.vdt.js +14 -7
- package/components/select/select.d.ts +33 -0
- package/components/select/select.js +20 -3
- package/components/select/select.vdt.js +17 -9
- package/components/select/styles.js +33 -0
- package/components/select/useBaseLabel.d.ts +1 -1
- package/components/select/useBaseLabel.js +17 -4
- package/components/select/useCard.js +4 -0
- package/components/select/useEqualWidth.js +1 -0
- package/components/select/useFilterable.js +27 -5
- package/components/select/useFocusout.js +8 -0
- package/components/select/useInput.js +10 -6
- package/components/select/useLabel.js +13 -3
- package/components/select/useSearchable.js +10 -0
- package/components/skeleton/item.d.ts +1 -1
- package/components/skeleton/item.js +4 -0
- package/components/skeleton/item.vdt.js +6 -1
- package/components/skeleton/skeleton.js +4 -0
- package/components/skeleton/skeleton.vdt.js +12 -6
- package/components/skeleton/style.d.ts +1 -1
- package/components/skeleton/style.js +1 -0
- package/components/slider/index.d.ts +1 -1
- package/components/slider/index.js +7 -0
- package/components/slider/index.spec.js +585 -467
- package/components/slider/index.vdt.js +45 -32
- package/components/slider/styles.js +14 -0
- package/components/slider/useClick.js +11 -2
- package/components/slider/useDraggable.js +34 -23
- package/components/slider/useKeyboard.js +18 -7
- package/components/slider/useMarks.d.ts +5 -5
- package/components/slider/useMarks.js +13 -5
- package/components/slider/usePoints.d.ts +2 -2
- package/components/slider/usePoints.js +21 -7
- package/components/slider/useStyles.d.ts +1 -1
- package/components/slider/useStyles.js +10 -5
- package/components/slider/useTooltip.js +10 -2
- package/components/slider/useValue.d.ts +1 -1
- package/components/slider/useValue.js +22 -7
- package/components/spin/index.js +4 -0
- package/components/spin/index.vdt.js +11 -4
- package/components/spin/styles.js +2 -0
- package/components/spinner/index.d.ts +4 -4
- package/components/spinner/index.js +24 -9
- package/components/spinner/index.spec.js +460 -359
- package/components/spinner/index.vdt.js +13 -10
- package/components/spinner/styles.js +3 -0
- package/components/spinner/useChange.js +16 -4
- package/components/spinner/useFormatter.js +16 -6
- package/components/spinner/useStep.d.ts +3 -3
- package/components/spinner/useStep.js +20 -2
- package/components/spinner/useValue.js +26 -11
- package/components/split/index.js +7 -0
- package/components/split/index.spec.js +267 -223
- package/components/split/index.vdt.js +17 -8
- package/components/split/style.d.ts +1 -1
- package/components/split/style.js +8 -0
- package/components/split/useDraggable.js +35 -11
- package/components/split/useSize.js +5 -2
- package/components/steps/context.d.ts +2 -2
- package/components/steps/index.js +10 -2
- package/components/steps/index.spec.js +27 -21
- package/components/steps/index.vdt.js +10 -8
- package/components/steps/step.js +2 -0
- package/components/steps/step.vdt.js +12 -8
- package/components/steps/styles.js +27 -0
- package/components/switch/index.js +23 -2
- package/components/switch/index.spec.js +224 -188
- package/components/switch/index.vdt.js +32 -16
- package/components/switch/styles.js +14 -3
- package/components/switch/useDraggable.js +18 -10
- package/components/table/cell.js +6 -0
- package/components/table/cell.vdt.js +21 -14
- package/components/table/column.d.ts +1 -1
- package/components/table/column.js +5 -0
- package/components/table/column.vdt.js +30 -19
- package/components/table/exportTable.js +56 -45
- package/components/table/index.spec.js +984 -780
- package/components/table/row.d.ts +1 -1
- package/components/table/row.js +41 -12
- package/components/table/row.vdt.js +39 -27
- package/components/table/styles.js +11 -0
- package/components/table/table.d.ts +5 -5
- package/components/table/table.js +50 -18
- package/components/table/table.vdt.js +85 -61
- package/components/table/useChecked.d.ts +1 -1
- package/components/table/useChecked.js +61 -20
- package/components/table/useColumns.js +16 -3
- package/components/table/useDisableRow.js +12 -2
- package/components/table/useDraggable.js +12 -4
- package/components/table/useExpandable.js +5 -2
- package/components/table/useFixedColumns.d.ts +1 -1
- package/components/table/useFixedColumns.js +23 -4
- package/components/table/useGroup.d.ts +1 -1
- package/components/table/useGroup.js +24 -7
- package/components/table/useMerge.d.ts +4 -4
- package/components/table/useMerge.js +14 -2
- package/components/table/usePagination.js +18 -4
- package/components/table/useResizable.js +10 -2
- package/components/table/useRestRowStatus.js +6 -2
- package/components/table/useScroll.d.ts +1 -1
- package/components/table/useScroll.js +3 -0
- package/components/table/useSelected.js +5 -2
- package/components/table/useSortable.js +8 -2
- package/components/table/useStickyHeader.js +7 -3
- package/components/table/useStickyScrollbar.js +16 -6
- package/components/table/useTree.js +12 -1
- package/components/table/useWidth.js +30 -14
- package/components/tabs/index.js +51 -29
- package/components/tabs/index.spec.js +74 -56
- package/components/tabs/index.vdt.js +16 -13
- package/components/tabs/styles.js +16 -0
- package/components/tabs/tab.js +10 -0
- package/components/tabs/tab.vdt.js +10 -6
- package/components/tabs/useActiveBar.js +11 -2
- package/components/tabs/useScroll.js +20 -4
- package/components/tag/base.js +8 -0
- package/components/tag/index.js +4 -2
- package/components/tag/index.spec.js +25 -19
- package/components/tag/index.vdt.js +15 -8
- package/components/tag/styles.js +9 -0
- package/components/timeline/item.js +4 -0
- package/components/timeline/item.vdt.js +9 -4
- package/components/timeline/styles.d.ts +2 -2
- package/components/timeline/styles.js +4 -0
- package/components/timeline/timeline.js +2 -0
- package/components/timeline/timeline.vdt.js +5 -2
- package/components/timepicker/index.js +7 -2
- package/components/timepicker/index.spec.js +368 -293
- package/components/timepicker/panelPicker.d.ts +54 -0
- package/components/timepicker/panelPicker.js +11 -2
- package/components/timepicker/panelPicker.vdt.js +24 -14
- package/components/timepicker/selectPicker.js +5 -0
- package/components/timepicker/selectPicker.vdt.js +10 -5
- package/components/timepicker/styles.js +1 -0
- package/components/timepicker/useDisabled.js +4 -2
- package/components/timepicker/useFormats.js +13 -4
- package/components/timepicker/useStep.d.ts +1 -1
- package/components/timepicker/useStep.js +17 -8
- package/components/timepicker/useValue.js +21 -16
- package/components/tip/index.js +2 -0
- package/components/tip/index.vdt.js +17 -5
- package/components/tip/styles.js +3 -0
- package/components/tooltip/content.js +28 -0
- package/components/tooltip/content.vdt.js +25 -15
- package/components/tooltip/index.js +7 -3
- package/components/tooltip/index.spec.js +572 -434
- package/components/tooltip/styles.d.ts +1 -1
- package/components/tooltip/styles.js +10 -2
- package/components/tooltip/tooltip.js +15 -2
- package/components/tooltip/useArrow.js +14 -11
- package/components/transfer/index.d.ts +1 -1
- package/components/transfer/index.js +13 -1
- package/components/transfer/index.spec.js +194 -159
- package/components/transfer/index.vdt.js +34 -16
- package/components/transfer/styles.js +10 -0
- package/components/transfer/useCheck.d.ts +1 -1
- package/components/transfer/useCheck.js +15 -1
- package/components/transfer/useFilter.d.ts +1 -1
- package/components/transfer/useFilter.js +30 -9
- package/components/transfer/useTransfer.js +26 -10
- package/components/tree/index.d.ts +3 -3
- package/components/tree/index.js +22 -4
- package/components/tree/index.spec.js +355 -285
- package/components/tree/index.vdt.js +23 -12
- package/components/tree/styles.js +16 -2
- package/components/tree/useChecked.js +26 -3
- package/components/tree/useDraggable.js +42 -12
- package/components/tree/useExpanded.js +43 -26
- package/components/tree/useFilter.js +10 -3
- package/components/tree/useNodes.d.ts +1 -1
- package/components/tree/useNodes.js +4 -0
- package/components/tree/useSelected.js +38 -21
- package/components/tree/useTransitionEvent.js +5 -3
- package/components/treeSelect/index.d.ts +27 -0
- package/components/treeSelect/index.js +36 -9
- package/components/treeSelect/index.spec.js +160 -123
- package/components/treeSelect/index.vdt.js +20 -14
- package/components/treeSelect/styles.js +1 -0
- package/components/treeSelect/useValue.js +11 -0
- package/components/types.d.ts +3 -3
- package/components/upload/ajaxUploader.d.ts +1 -1
- package/components/upload/ajaxUploader.js +17 -0
- package/components/upload/index.d.ts +4 -4
- package/components/upload/index.js +14 -0
- package/components/upload/index.spec.js +249 -142
- package/components/upload/index.vdt.js +27 -12
- package/components/upload/styles.js +30 -0
- package/components/upload/useAccept.js +10 -2
- package/components/upload/useDrag.js +7 -0
- package/components/upload/useFiles.js +145 -103
- package/components/upload/useShowImage.js +3 -0
- package/components/upload/useUpload.js +69 -47
- package/components/utils.d.ts +3 -3
- package/components/utils.js +47 -12
- package/components/virtual.js +37 -9
- package/components/wave/index.js +31 -5
- package/hooks/useDelayClose.js +6 -2
- package/hooks/useDocumentClick.js +16 -8
- package/hooks/useDraggable.d.ts +1 -1
- package/hooks/useDraggable.js +9 -0
- package/hooks/useKeyboard.d.ts +3 -3
- package/hooks/useKeyboard.js +10 -0
- package/hooks/useMouseOutsidable.js +8 -0
- package/hooks/useReceive.d.ts +1 -1
- package/hooks/useReceive.js +4 -0
- package/hooks/useRecordComponent.js +6 -0
- package/hooks/useRouter.js +18 -7
- package/hooks/useShowHideEvents.js +3 -0
- package/hooks/useState.d.ts +2 -2
- package/hooks/useState.js +6 -2
- package/i18n/en-US.js +1 -0
- package/i18n/index.d.ts +1 -1
- package/i18n/index.js +7 -0
- package/index.d.ts +2 -2
- package/index.js +3 -2
- package/package.json +1 -1
- package/styles/global.js +3 -2
- package/styles/keyframes.js +1 -0
- package/styles/theme.d.ts +1 -1
- package/styles/theme.js +7 -4
- package/styles/utils.d.ts +1 -1
- package/styles/utils.js +17 -3
- package/yarn-error.log +0 -1013
|
@@ -5,9 +5,13 @@ import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-meth
|
|
|
5
5
|
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
6
6
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
8
|
+
|
|
8
9
|
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
+
|
|
9
11
|
function _unsupportedIterableToArray(o, minLen) { var _context15; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context15 = Object.prototype.toString.call(o)).call(_context15, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
-
|
|
12
|
+
|
|
13
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
14
|
+
|
|
11
15
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
|
|
12
16
|
import _Promise from "@babel/runtime-corejs3/core-js/promise";
|
|
13
17
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
@@ -21,30 +25,38 @@ import ManuallyDemo from '~/components/upload/demos/manually';
|
|
|
21
25
|
import { mount, unmount, dispatchEvent, getElement, wait } from '../../test/utils';
|
|
22
26
|
import { Upload } from './';
|
|
23
27
|
import { bind } from '../utils';
|
|
28
|
+
|
|
24
29
|
function getDataTransfer(names, options, type) {
|
|
25
30
|
if (options === void 0) {
|
|
26
31
|
options = {};
|
|
27
32
|
}
|
|
33
|
+
|
|
28
34
|
if (type === void 0) {
|
|
29
35
|
type = '';
|
|
30
36
|
}
|
|
37
|
+
|
|
31
38
|
var data = _mapInstanceProperty(names).call(names, function (item) {
|
|
32
39
|
var file = new File([item], (options.name || item) + "." + (options.type || 'png'), {
|
|
33
40
|
type: type
|
|
34
41
|
});
|
|
35
42
|
return file;
|
|
36
43
|
});
|
|
44
|
+
|
|
37
45
|
var dt = new DataTransfer();
|
|
46
|
+
|
|
38
47
|
for (var _iterator = _createForOfIteratorHelperLoose(data), _step; !(_step = _iterator()).done;) {
|
|
39
48
|
var file = _step.value;
|
|
40
49
|
dt.items.add(file);
|
|
41
50
|
}
|
|
51
|
+
|
|
42
52
|
return dt;
|
|
43
53
|
}
|
|
54
|
+
|
|
44
55
|
var respond = function respond(xhr) {
|
|
45
56
|
xhr.respond(200);
|
|
46
|
-
};
|
|
47
|
-
|
|
57
|
+
}; // we should trigger change event manually in the newest ChromeHeadless
|
|
58
|
+
|
|
59
|
+
|
|
48
60
|
function fixInputChange(input) {
|
|
49
61
|
var files;
|
|
50
62
|
Object.defineProperty(input, 'files', {
|
|
@@ -57,10 +69,12 @@ function fixInputChange(input) {
|
|
|
57
69
|
}
|
|
58
70
|
});
|
|
59
71
|
}
|
|
72
|
+
|
|
60
73
|
describe('Upload', function () {
|
|
61
74
|
beforeEach(function () {
|
|
62
75
|
this.xhr = sinon.useFakeXMLHttpRequest();
|
|
63
76
|
var requests = this.requests = [];
|
|
77
|
+
|
|
64
78
|
this.xhr.onCreate = function (xhr) {
|
|
65
79
|
setTimeout(function () {
|
|
66
80
|
respond(xhr);
|
|
@@ -69,55 +83,68 @@ describe('Upload', function () {
|
|
|
69
83
|
});
|
|
70
84
|
afterEach(function (done) {
|
|
71
85
|
unmount();
|
|
86
|
+
|
|
72
87
|
respond = function respond(xhr) {
|
|
73
88
|
xhr.respond(200);
|
|
74
89
|
};
|
|
90
|
+
|
|
75
91
|
this.xhr.restore();
|
|
76
92
|
setTimeout(done, 500);
|
|
77
93
|
});
|
|
78
94
|
it('basic', function (done) {
|
|
79
95
|
this.timeout(0);
|
|
96
|
+
|
|
80
97
|
var _mount = mount(BasicDemo),
|
|
81
|
-
|
|
82
|
-
|
|
98
|
+
instance = _mount[0],
|
|
99
|
+
element = _mount[1];
|
|
100
|
+
|
|
83
101
|
var upload = instance.$lastInput.children;
|
|
84
102
|
upload.on('success', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
85
103
|
var remove, dialog, _dialog$querySelector, cancel, _dialog$querySelector2, ok;
|
|
104
|
+
|
|
86
105
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
87
|
-
while (1)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
106
|
+
while (1) {
|
|
107
|
+
switch (_context.prev = _context.next) {
|
|
108
|
+
case 0:
|
|
109
|
+
_context.next = 2;
|
|
110
|
+
return wait(500);
|
|
111
|
+
|
|
112
|
+
case 2:
|
|
113
|
+
expect(element.innerHTML).to.matchSnapshot(); // beforeRemove
|
|
114
|
+
|
|
115
|
+
remove = element.querySelector('.k-upload-close');
|
|
116
|
+
remove.click();
|
|
117
|
+
_context.next = 7;
|
|
118
|
+
return wait();
|
|
119
|
+
|
|
120
|
+
case 7:
|
|
121
|
+
dialog = getElement('.k-dialog');
|
|
122
|
+
_dialog$querySelector = dialog.querySelectorAll('.k-dialog-footer .k-btn'), cancel = _dialog$querySelector[1];
|
|
123
|
+
cancel.click();
|
|
124
|
+
_context.next = 12;
|
|
125
|
+
return wait(500);
|
|
126
|
+
|
|
127
|
+
case 12:
|
|
128
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
129
|
+
remove.click();
|
|
130
|
+
_context.next = 16;
|
|
131
|
+
return wait();
|
|
132
|
+
|
|
133
|
+
case 16:
|
|
134
|
+
dialog = getElement('.k-dialog');
|
|
135
|
+
_dialog$querySelector2 = dialog.querySelectorAll('.k-dialog-footer .k-btn'), ok = _dialog$querySelector2[0];
|
|
136
|
+
ok.click();
|
|
137
|
+
_context.next = 21;
|
|
138
|
+
return wait(500);
|
|
139
|
+
|
|
140
|
+
case 21:
|
|
141
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
142
|
+
done();
|
|
143
|
+
|
|
144
|
+
case 23:
|
|
145
|
+
case "end":
|
|
146
|
+
return _context.stop();
|
|
147
|
+
}
|
|
121
148
|
}
|
|
122
149
|
}, _callee);
|
|
123
150
|
})));
|
|
@@ -128,78 +155,92 @@ describe('Upload', function () {
|
|
|
128
155
|
});
|
|
129
156
|
it('drag', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
130
157
|
var _mount2, instance, element, handle, upload, p;
|
|
158
|
+
|
|
131
159
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
132
|
-
while (1)
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
160
|
+
while (1) {
|
|
161
|
+
switch (_context2.prev = _context2.next) {
|
|
162
|
+
case 0:
|
|
163
|
+
this.timeout(0);
|
|
164
|
+
_mount2 = mount(DragDemo), instance = _mount2[0], element = _mount2[1];
|
|
165
|
+
handle = element.querySelector('.k-upload-handle');
|
|
166
|
+
dispatchEvent(handle, 'dragenter');
|
|
167
|
+
_context2.next = 6;
|
|
168
|
+
return wait();
|
|
169
|
+
|
|
170
|
+
case 6:
|
|
171
|
+
expect(element.outerHTML).to.matchSnapshot();
|
|
172
|
+
dispatchEvent(handle, 'dragleave');
|
|
173
|
+
_context2.next = 10;
|
|
174
|
+
return wait();
|
|
175
|
+
|
|
176
|
+
case 10:
|
|
177
|
+
expect(element.outerHTML).to.matchSnapshot();
|
|
178
|
+
upload = instance.$lastInput.children;
|
|
179
|
+
p = new _Promise(function (resolve) {
|
|
180
|
+
upload.on('success', function () {
|
|
181
|
+
setTimeout(function () {
|
|
182
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
183
|
+
resolve();
|
|
184
|
+
}, 1000);
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
dispatchEvent(handle, 'drop', {
|
|
188
|
+
dataTransfer: getDataTransfer(['a'])
|
|
154
189
|
});
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
return _context2.stop();
|
|
190
|
+
_context2.next = 16;
|
|
191
|
+
return wait();
|
|
192
|
+
|
|
193
|
+
case 16:
|
|
194
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
195
|
+
_context2.next = 19;
|
|
196
|
+
return p;
|
|
197
|
+
|
|
198
|
+
case 19:
|
|
199
|
+
case "end":
|
|
200
|
+
return _context2.stop();
|
|
201
|
+
}
|
|
168
202
|
}
|
|
169
203
|
}, _callee2, this);
|
|
170
204
|
})));
|
|
171
205
|
it('gallery', function (done) {
|
|
172
206
|
this.timeout(0);
|
|
207
|
+
|
|
173
208
|
var _mount3 = mount(GalleryDemo),
|
|
174
|
-
|
|
175
|
-
|
|
209
|
+
instance = _mount3[0],
|
|
210
|
+
element = _mount3[1];
|
|
211
|
+
|
|
176
212
|
var input = element.querySelector('input');
|
|
177
213
|
var upload = instance.$lastInput.children;
|
|
178
214
|
upload.on('success', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
179
215
|
var view, dialog;
|
|
180
216
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
181
|
-
while (1)
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
view.click();
|
|
189
|
-
_context3.next = 7;
|
|
190
|
-
return wait();
|
|
191
|
-
case 7:
|
|
192
|
-
dialog = getElement('.k-dialog');
|
|
193
|
-
expect(dialog.innerHTML.replace(/blob:[^"]*/g, '')).to.matchSnapshot();
|
|
194
|
-
upload.on('error', function (err) {
|
|
195
|
-
expect(err.message).to.matchSnapshot();
|
|
217
|
+
while (1) {
|
|
218
|
+
switch (_context3.prev = _context3.next) {
|
|
219
|
+
case 0:
|
|
220
|
+
_context3.next = 2;
|
|
221
|
+
return wait(1000);
|
|
222
|
+
|
|
223
|
+
case 2:
|
|
196
224
|
expect(element.innerHTML.replace(/blob:[^"]*/g, '')).to.matchSnapshot();
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
225
|
+
view = element.querySelector('.k-upload-overlap');
|
|
226
|
+
view.click();
|
|
227
|
+
_context3.next = 7;
|
|
228
|
+
return wait();
|
|
229
|
+
|
|
230
|
+
case 7:
|
|
231
|
+
dialog = getElement('.k-dialog');
|
|
232
|
+
expect(dialog.innerHTML.replace(/blob:[^"]*/g, '')).to.matchSnapshot();
|
|
233
|
+
upload.on('error', function (err) {
|
|
234
|
+
expect(err.message).to.matchSnapshot();
|
|
235
|
+
expect(element.innerHTML.replace(/blob:[^"]*/g, '')).to.matchSnapshot();
|
|
236
|
+
done();
|
|
237
|
+
});
|
|
238
|
+
input.files = getDataTransfer(['b', 'c', 'd']).files;
|
|
239
|
+
|
|
240
|
+
case 11:
|
|
241
|
+
case "end":
|
|
242
|
+
return _context3.stop();
|
|
243
|
+
}
|
|
203
244
|
}
|
|
204
245
|
}, _callee3);
|
|
205
246
|
})));
|
|
@@ -211,22 +252,28 @@ describe('Upload', function () {
|
|
|
211
252
|
});
|
|
212
253
|
it('manually', function (done) {
|
|
213
254
|
this.timeout(0);
|
|
255
|
+
|
|
214
256
|
var _mount4 = mount(ManuallyDemo),
|
|
215
|
-
|
|
216
|
-
|
|
257
|
+
instance = _mount4[0],
|
|
258
|
+
element = _mount4[1];
|
|
259
|
+
|
|
217
260
|
var upload = instance.$lastInput.children;
|
|
218
261
|
upload.on('success', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
219
262
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
220
|
-
while (1)
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
263
|
+
while (1) {
|
|
264
|
+
switch (_context4.prev = _context4.next) {
|
|
265
|
+
case 0:
|
|
266
|
+
_context4.next = 2;
|
|
267
|
+
return wait(500);
|
|
268
|
+
|
|
269
|
+
case 2:
|
|
270
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
271
|
+
done();
|
|
272
|
+
|
|
273
|
+
case 4:
|
|
274
|
+
case "end":
|
|
275
|
+
return _context4.stop();
|
|
276
|
+
}
|
|
230
277
|
}
|
|
231
278
|
}, _callee4);
|
|
232
279
|
})));
|
|
@@ -240,29 +287,40 @@ describe('Upload', function () {
|
|
|
240
287
|
});
|
|
241
288
|
it('should trigger error event when exceed the maxSize', function (done) {
|
|
242
289
|
var _context6;
|
|
290
|
+
|
|
243
291
|
var Demo = /*#__PURE__*/function (_Component) {
|
|
244
292
|
_inheritsLoose(Demo, _Component);
|
|
293
|
+
|
|
245
294
|
function Demo() {
|
|
246
295
|
var _context5;
|
|
296
|
+
|
|
247
297
|
var _this;
|
|
298
|
+
|
|
248
299
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
249
300
|
args[_key] = arguments[_key];
|
|
250
301
|
}
|
|
302
|
+
|
|
251
303
|
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context5 = [this]).call(_context5, args)) || this;
|
|
252
304
|
_this.Upload = Upload;
|
|
253
305
|
return _this;
|
|
254
306
|
}
|
|
307
|
+
|
|
255
308
|
var _proto = Demo.prototype;
|
|
309
|
+
|
|
256
310
|
_proto._onError = function _onError(e) {
|
|
257
311
|
expect(e.message).to.matchSnapshot();
|
|
258
312
|
done();
|
|
259
313
|
};
|
|
314
|
+
|
|
260
315
|
return Demo;
|
|
261
316
|
}(Component);
|
|
317
|
+
|
|
262
318
|
Demo.template = "const {Upload} = this; <Upload maxSize={1} ev-error={this._onError} />";
|
|
319
|
+
|
|
263
320
|
var _mount5 = mount(Demo),
|
|
264
|
-
|
|
265
|
-
|
|
321
|
+
instance = _mount5[0],
|
|
322
|
+
element = _mount5[1];
|
|
323
|
+
|
|
266
324
|
var input = element.querySelector('input');
|
|
267
325
|
fixInputChange(input);
|
|
268
326
|
input.files = getDataTransfer([_repeatInstanceProperty(_context6 = 'a').call(_context6, 1025 * 1)], {
|
|
@@ -271,79 +329,108 @@ describe('Upload', function () {
|
|
|
271
329
|
});
|
|
272
330
|
it('should handle error on uploading correctly', function (done) {
|
|
273
331
|
var _context9;
|
|
332
|
+
|
|
274
333
|
this.timeout(0);
|
|
334
|
+
|
|
275
335
|
var Demo = /*#__PURE__*/function (_Component2) {
|
|
276
336
|
_inheritsLoose(Demo, _Component2);
|
|
337
|
+
|
|
277
338
|
function Demo() {
|
|
278
339
|
var _context7;
|
|
340
|
+
|
|
279
341
|
var _this2;
|
|
342
|
+
|
|
280
343
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
281
344
|
args[_key2] = arguments[_key2];
|
|
282
345
|
}
|
|
346
|
+
|
|
283
347
|
_this2 = _Component2.call.apply(_Component2, _concatInstanceProperty(_context7 = [this]).call(_context7, args)) || this;
|
|
284
348
|
_this2.Upload = Upload;
|
|
285
349
|
return _this2;
|
|
286
350
|
}
|
|
351
|
+
|
|
287
352
|
var _proto2 = Demo.prototype;
|
|
353
|
+
|
|
288
354
|
_proto2._onError = /*#__PURE__*/function () {
|
|
289
355
|
var _onError2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(e) {
|
|
290
356
|
return _regeneratorRuntime.wrap(function _callee5$(_context8) {
|
|
291
|
-
while (1)
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
357
|
+
while (1) {
|
|
358
|
+
switch (_context8.prev = _context8.next) {
|
|
359
|
+
case 0:
|
|
360
|
+
_context8.next = 2;
|
|
361
|
+
return wait(500);
|
|
362
|
+
|
|
363
|
+
case 2:
|
|
364
|
+
// FIXME: the innerHTML has string: `height: 44px;` when we run test in travis-ci
|
|
365
|
+
// expect(element.innerHTML.replace(/height: \d+px;/, '')).to.matchSnapshot();
|
|
366
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
367
|
+
done();
|
|
368
|
+
|
|
369
|
+
case 4:
|
|
370
|
+
case "end":
|
|
371
|
+
return _context8.stop();
|
|
372
|
+
}
|
|
303
373
|
}
|
|
304
374
|
}, _callee5);
|
|
305
375
|
}));
|
|
376
|
+
|
|
306
377
|
function _onError(_x) {
|
|
307
378
|
return _onError2.apply(this, arguments);
|
|
308
379
|
}
|
|
380
|
+
|
|
309
381
|
return _onError;
|
|
310
382
|
}();
|
|
383
|
+
|
|
311
384
|
return Demo;
|
|
312
385
|
}(Component);
|
|
386
|
+
|
|
313
387
|
Demo.template = "\n const {Upload} = this;\n <Upload\n action=\"//localhost\"\n ev-error={this._onError}\n />\n ";
|
|
388
|
+
|
|
314
389
|
var _mount6 = mount(Demo),
|
|
315
|
-
|
|
316
|
-
|
|
390
|
+
instance = _mount6[0],
|
|
391
|
+
element = _mount6[1];
|
|
392
|
+
|
|
317
393
|
var input = element.querySelector('input');
|
|
318
394
|
fixInputChange(input);
|
|
319
395
|
input.files = getDataTransfer([_repeatInstanceProperty(_context9 = 'a').call(_context9, 1024 * 100)], {
|
|
320
396
|
name: 'a'
|
|
321
397
|
}).files;
|
|
398
|
+
|
|
322
399
|
respond = function respond(xhr) {
|
|
323
400
|
return xhr.respond(500);
|
|
324
401
|
};
|
|
325
402
|
});
|
|
326
403
|
it('should abort request when remove file in progress', function (done) {
|
|
327
404
|
var _context11;
|
|
405
|
+
|
|
328
406
|
this.timeout(0);
|
|
407
|
+
|
|
329
408
|
var Demo = /*#__PURE__*/function (_Component3) {
|
|
330
409
|
_inheritsLoose(Demo, _Component3);
|
|
410
|
+
|
|
331
411
|
function Demo() {
|
|
332
412
|
var _context10;
|
|
413
|
+
|
|
333
414
|
var _this3;
|
|
415
|
+
|
|
334
416
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
335
417
|
args[_key3] = arguments[_key3];
|
|
336
418
|
}
|
|
419
|
+
|
|
337
420
|
_this3 = _Component3.call.apply(_Component3, _concatInstanceProperty(_context10 = [this]).call(_context10, args)) || this;
|
|
338
421
|
_this3.Upload = Upload;
|
|
339
422
|
return _this3;
|
|
340
423
|
}
|
|
424
|
+
|
|
341
425
|
return Demo;
|
|
342
426
|
}(Component);
|
|
427
|
+
|
|
343
428
|
Demo.template = "\n const {Upload} = this;\n <Upload\n action=\"//jsonplaceholder.typicode.com/posts/\"\n ref=\"upload\"\n />\n ";
|
|
429
|
+
|
|
344
430
|
var _mount7 = mount(Demo),
|
|
345
|
-
|
|
346
|
-
|
|
431
|
+
instance = _mount7[0],
|
|
432
|
+
element = _mount7[1];
|
|
433
|
+
|
|
347
434
|
var input = element.querySelector('input');
|
|
348
435
|
fixInputChange(input);
|
|
349
436
|
input.files = getDataTransfer([_repeatInstanceProperty(_context11 = 'a').call(_context11, 1024 * 512)], {
|
|
@@ -351,17 +438,21 @@ describe('Upload', function () {
|
|
|
351
438
|
}).files;
|
|
352
439
|
instance.refs.upload.on('progress', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
353
440
|
return _regeneratorRuntime.wrap(function _callee6$(_context12) {
|
|
354
|
-
while (1)
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
441
|
+
while (1) {
|
|
442
|
+
switch (_context12.prev = _context12.next) {
|
|
443
|
+
case 0:
|
|
444
|
+
element.querySelector('.k-upload-close').click();
|
|
445
|
+
_context12.next = 3;
|
|
446
|
+
return wait(500);
|
|
447
|
+
|
|
448
|
+
case 3:
|
|
449
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
450
|
+
done();
|
|
451
|
+
|
|
452
|
+
case 5:
|
|
453
|
+
case "end":
|
|
454
|
+
return _context12.stop();
|
|
455
|
+
}
|
|
365
456
|
}
|
|
366
457
|
}, _callee6);
|
|
367
458
|
})));
|
|
@@ -377,9 +468,11 @@ describe('Upload', function () {
|
|
|
377
468
|
expect(!!i.accept.isValidType('image/png', '')).to.be.true;
|
|
378
469
|
expect(!!i.accept.isValidType('video/avi', '')).to.be.true;
|
|
379
470
|
expect(!!i.accept.isValidType('application/x-tar', 'a.tar')).to.be.true;
|
|
471
|
+
|
|
380
472
|
var _mount8 = mount(BasicDemo),
|
|
381
|
-
|
|
382
|
-
|
|
473
|
+
instance = _mount8[0],
|
|
474
|
+
element = _mount8[1];
|
|
475
|
+
|
|
383
476
|
var upload = instance.$lastInput.children;
|
|
384
477
|
upload.on('error', function (e) {
|
|
385
478
|
expect(e.message).to.matchSnapshot();
|
|
@@ -393,25 +486,34 @@ describe('Upload', function () {
|
|
|
393
486
|
});
|
|
394
487
|
it('should not add file if beforeUpload returns false', function (done) {
|
|
395
488
|
var _context14;
|
|
489
|
+
|
|
396
490
|
var Demo = /*#__PURE__*/function (_Component4) {
|
|
397
491
|
_inheritsLoose(Demo, _Component4);
|
|
492
|
+
|
|
398
493
|
function Demo() {
|
|
399
494
|
var _context13;
|
|
495
|
+
|
|
400
496
|
var _this4;
|
|
497
|
+
|
|
401
498
|
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
402
499
|
args[_key4] = arguments[_key4];
|
|
403
500
|
}
|
|
501
|
+
|
|
404
502
|
_this4 = _Component4.call.apply(_Component4, _concatInstanceProperty(_context13 = [this]).call(_context13, args)) || this;
|
|
405
503
|
_this4.Upload = Upload;
|
|
406
504
|
return _this4;
|
|
407
505
|
}
|
|
506
|
+
|
|
408
507
|
var _proto3 = Demo.prototype;
|
|
508
|
+
|
|
409
509
|
_proto3.beforeUpload = function beforeUpload() {
|
|
410
510
|
var _this5 = this;
|
|
511
|
+
|
|
411
512
|
return new _Promise(function (resolve, reject) {
|
|
412
513
|
setTimeout(function () {
|
|
413
514
|
setTimeout(function () {
|
|
414
515
|
var files = _this5.refs.upload.get('files');
|
|
516
|
+
|
|
415
517
|
expect(files.length).to.eql(0);
|
|
416
518
|
done();
|
|
417
519
|
});
|
|
@@ -419,13 +521,18 @@ describe('Upload', function () {
|
|
|
419
521
|
}, 100);
|
|
420
522
|
});
|
|
421
523
|
};
|
|
524
|
+
|
|
422
525
|
return Demo;
|
|
423
526
|
}(Component);
|
|
527
|
+
|
|
424
528
|
Demo.template = "\n const {Upload} = this;\n <Upload\n action=\"//jsonplaceholder.typicode.com/posts/\"\n ref=\"upload\"\n beforeUpload={this.beforeUpload}\n type=\"gallery\"\n limit={1}\n />\n ";
|
|
529
|
+
|
|
425
530
|
__decorate([bind], Demo.prototype, "beforeUpload", null);
|
|
531
|
+
|
|
426
532
|
var _mount9 = mount(Demo),
|
|
427
|
-
|
|
428
|
-
|
|
533
|
+
instance = _mount9[0],
|
|
534
|
+
element = _mount9[1];
|
|
535
|
+
|
|
429
536
|
var input = element.querySelector('input');
|
|
430
537
|
fixInputChange(input);
|
|
431
538
|
input.files = getDataTransfer([_repeatInstanceProperty(_context14 = 'a').call(_context14, 1024 * 512)], {
|