naive-ui 2.23.2 → 2.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/es/_internal/icons/Switcher.js +2 -3
- package/es/_internal/selection/src/styles/index.cssr.js +1 -1
- package/es/_internal/selection/styles/_common.js +1 -1
- package/es/auto-complete/src/AutoComplete.d.ts +12 -12
- package/es/auto-complete/src/AutoComplete.js +13 -15
- package/es/back-top/src/BackTop.d.ts +3 -3
- package/es/calendar/src/Calendar.d.ts +5 -1
- package/es/calendar/src/Calendar.js +16 -4
- package/es/calendar/src/interface.d.ts +4 -0
- package/es/carousel/index.d.ts +1 -0
- package/es/carousel/index.js +1 -0
- package/es/carousel/src/Carousel.d.ts +235 -19
- package/es/carousel/src/Carousel.js +683 -229
- package/es/carousel/src/CarouselArrow.d.ts +9 -0
- package/es/carousel/src/CarouselArrow.js +43 -0
- package/es/carousel/src/CarouselDots.d.ts +66 -0
- package/es/carousel/src/CarouselDots.js +118 -0
- package/es/carousel/src/CarouselItem.d.ts +11 -0
- package/es/carousel/src/CarouselItem.js +72 -0
- package/es/carousel/src/interface.d.ts +28 -0
- package/es/carousel/src/interface.js +2 -0
- package/es/carousel/src/styles/index.cssr.js +141 -38
- package/es/carousel/src/utils.d.ts +12 -0
- package/es/carousel/src/utils.js +58 -0
- package/es/carousel/styles/light.d.ts +3 -0
- package/es/carousel/styles/light.js +5 -2
- package/es/cascader/src/Cascader.d.ts +6 -2
- package/es/cascader/src/Cascader.js +2 -1
- package/es/cascader/src/CascaderOption.d.ts +1 -0
- package/es/cascader/src/CascaderOption.js +7 -4
- package/es/cascader/src/interface.d.ts +2 -1
- package/es/checkbox/src/styles/index.cssr.js +1 -1
- package/es/code/src/Code.d.ts +5 -0
- package/es/code/src/Code.js +6 -3
- package/es/code/src/styles/index.cssr.js +2 -2
- package/es/color-picker/src/ColorInputUnit.js +2 -2
- package/es/color-picker/src/ColorPicker.d.ts +13 -5
- package/es/color-picker/src/ColorPicker.js +19 -10
- package/es/color-picker/src/ColorPickerTrigger.d.ts +1 -1
- package/es/color-picker/src/ColorPickerTrigger.js +23 -17
- package/es/color-picker/src/interface.d.ts +2 -0
- package/es/color-picker/src/styles/index.cssr.js +1 -0
- package/es/config-provider/src/ConfigProvider.d.ts +27 -0
- package/es/data-table/src/DataTable.d.ts +10 -55
- package/es/data-table/src/DataTable.js +23 -49
- package/es/data-table/src/interface.d.ts +1 -1
- package/es/data-table/src/styles/index.cssr.js +4 -1
- package/es/data-table/src/utils.js +4 -1
- package/es/date-picker/src/DatePicker.d.ts +26 -22
- package/es/date-picker/src/DatePicker.js +99 -49
- package/es/date-picker/src/interface.d.ts +17 -2
- package/es/date-picker/src/panel/use-calendar.js +2 -2
- package/es/drawer/src/Drawer.d.ts +18 -58
- package/es/drawer/src/Drawer.js +32 -49
- package/es/drawer/src/DrawerBodyWrapper.js +21 -13
- package/es/drawer/src/DrawerContent.js +6 -6
- package/es/dropdown/src/Dropdown.d.ts +5 -0
- package/es/form/src/Feedbacks.js +4 -1
- package/es/form/src/Form.d.ts +7 -7
- package/es/form/src/Form.js +17 -8
- package/es/form/src/FormItem.d.ts +12 -7
- package/es/form/src/FormItem.js +24 -12
- package/es/form/src/FormItemCol.d.ts +8 -4
- package/es/form/src/FormItemGridItem.d.ts +8 -4
- package/es/form/src/FormItemRow.d.ts +7 -3
- package/es/form/src/interface.d.ts +6 -2
- package/es/form/src/styles/form-item.cssr.js +2 -0
- package/es/form/src/utils.d.ts +2 -2
- package/es/form/src/utils.js +29 -18
- package/es/image/src/Image.d.ts +279 -10
- package/es/image/src/Image.js +4 -17
- package/es/image/src/ImageGroup.d.ts +272 -2
- package/es/image/src/ImageGroup.js +5 -8
- package/es/image/src/ImagePreview.d.ts +195 -7
- package/es/image/src/ImagePreview.js +50 -31
- package/es/image/src/interface.d.ts +94 -0
- package/es/image/src/interface.js +2 -1
- package/es/image/src/styles/index.cssr.js +8 -4
- package/es/image/styles/dark.js +8 -1
- package/es/image/styles/light.d.ts +32 -3
- package/es/image/styles/light.js +8 -1
- package/es/input-number/src/utils.js +2 -2
- package/es/locales/common/deDE.js +10 -0
- package/es/locales/common/enUS.d.ts +9 -0
- package/es/locales/common/enUS.js +10 -0
- package/es/locales/common/frFR.js +10 -0
- package/es/locales/common/idID.js +10 -0
- package/es/locales/common/jaJP.js +10 -0
- package/es/locales/common/nbNO.js +10 -0
- package/es/locales/common/ruRU.js +10 -0
- package/es/locales/common/ukUA.js +10 -0
- package/es/locales/common/zhCN.js +9 -0
- package/es/locales/common/zhTW.js +10 -0
- package/es/mention/src/utils.js +0 -1
- package/es/message/index.d.ts +2 -1
- package/es/message/src/Message.d.ts +191 -19
- package/es/message/src/Message.js +13 -11
- package/es/message/src/MessageEnvironment.d.ts +3 -3
- package/es/message/src/MessageProvider.d.ts +5 -10
- package/es/message/src/MessageProvider.js +1 -1
- package/es/message/src/message-props.d.ts +5 -2
- package/es/message/src/types.d.ts +15 -0
- package/es/message/src/types.js +1 -0
- package/es/modal/src/Modal.d.ts +5 -0
- package/es/modal/src/Modal.js +2 -1
- package/es/page-header/index.d.ts +1 -1
- package/es/page-header/src/PageHeader.d.ts +1 -1
- package/es/pagination/index.d.ts +1 -1
- package/es/pagination/src/Pagination.d.ts +8 -4
- package/es/pagination/src/Pagination.js +66 -19
- package/es/pagination/src/interface.d.ts +10 -1
- package/es/pagination/src/utils.d.ts +2 -2
- package/es/pagination/src/utils.js +2 -4
- package/es/popconfirm/src/Popconfirm.d.ts +5 -0
- package/es/popover/src/Popover.d.ts +7 -0
- package/es/popover/src/Popover.js +24 -1
- package/es/popover/src/PopoverBody.d.ts +5 -0
- package/es/popover/src/PopoverBody.js +28 -46
- package/es/popover/src/styles/index.cssr.js +9 -8
- package/es/popselect/src/Popselect.d.ts +62 -73
- package/es/popselect/src/Popselect.js +2 -2
- package/es/progress/src/Circle.d.ts +7 -0
- package/es/progress/src/Circle.js +8 -1
- package/es/progress/src/Line.d.ts +2 -2
- package/es/progress/src/Line.js +4 -1
- package/es/progress/src/Progress.d.ts +6 -2
- package/es/progress/src/Progress.js +2 -2
- package/es/progress/src/styles/index.cssr.js +16 -16
- package/es/radio/src/styles/radio.cssr.js +4 -1
- package/es/result/src/Result.js +9 -10
- package/es/result/src/styles/index.cssr.js +7 -7
- package/es/select/src/Select.d.ts +8 -27
- package/es/select/src/Select.js +16 -24
- package/es/slider/src/Slider.d.ts +2 -4
- package/es/tabs/index.d.ts +1 -0
- package/es/tabs/src/Tabs.d.ts +2 -2
- package/es/tabs/src/Tabs.js +25 -22
- package/es/tabs/src/interface.d.ts +3 -0
- package/es/time-picker/src/TimePicker.d.ts +22 -2
- package/es/time-picker/src/TimePicker.js +59 -29
- package/es/time-picker/src/interface.d.ts +4 -2
- package/es/tooltip/src/Tooltip.d.ts +5 -0
- package/es/tree/src/Tree.d.ts +5 -1
- package/es/tree/src/Tree.js +4 -2
- package/es/tree/src/TreeNodeSwitcher.d.ts +1 -1
- package/es/tree/src/TreeNodeSwitcher.js +25 -14
- package/es/tree/src/interface.d.ts +2 -0
- package/es/tree/src/styles/index.cssr.js +4 -2
- package/es/upload/src/Upload.d.ts +15 -6
- package/es/upload/src/Upload.js +18 -9
- package/es/upload/src/UploadFile.d.ts +5 -5
- package/es/upload/src/UploadFileList.js +2 -2
- package/es/upload/src/interface.d.ts +11 -4
- package/es/version.d.ts +1 -1
- package/es/version.js +1 -1
- package/lib/_internal/icons/Switcher.js +2 -3
- package/lib/_internal/selection/src/styles/index.cssr.js +1 -1
- package/lib/_internal/selection/styles/_common.js +1 -1
- package/lib/auto-complete/src/AutoComplete.d.ts +12 -12
- package/lib/auto-complete/src/AutoComplete.js +14 -16
- package/lib/back-top/src/BackTop.d.ts +3 -3
- package/lib/calendar/src/Calendar.d.ts +5 -1
- package/lib/calendar/src/Calendar.js +15 -3
- package/lib/calendar/src/interface.d.ts +4 -0
- package/lib/carousel/index.d.ts +1 -0
- package/lib/carousel/index.js +3 -1
- package/lib/carousel/src/Carousel.d.ts +235 -19
- package/lib/carousel/src/Carousel.js +681 -227
- package/lib/carousel/src/CarouselArrow.d.ts +9 -0
- package/lib/carousel/src/CarouselArrow.js +45 -0
- package/lib/carousel/src/CarouselDots.d.ts +66 -0
- package/lib/carousel/src/CarouselDots.js +120 -0
- package/lib/carousel/src/CarouselItem.d.ts +11 -0
- package/lib/carousel/src/CarouselItem.js +74 -0
- package/lib/carousel/src/interface.d.ts +28 -0
- package/lib/carousel/src/interface.js +6 -0
- package/lib/carousel/src/styles/index.cssr.js +141 -38
- package/lib/carousel/src/utils.d.ts +12 -0
- package/lib/carousel/src/utils.js +69 -0
- package/lib/carousel/styles/light.d.ts +3 -0
- package/lib/carousel/styles/light.js +5 -2
- package/lib/cascader/src/Cascader.d.ts +6 -2
- package/lib/cascader/src/Cascader.js +2 -1
- package/lib/cascader/src/CascaderOption.d.ts +1 -0
- package/lib/cascader/src/CascaderOption.js +7 -4
- package/lib/cascader/src/interface.d.ts +2 -1
- package/lib/checkbox/src/styles/index.cssr.js +1 -1
- package/lib/code/src/Code.d.ts +5 -0
- package/lib/code/src/Code.js +6 -3
- package/lib/code/src/styles/index.cssr.js +1 -1
- package/lib/color-picker/src/ColorInputUnit.js +1 -1
- package/lib/color-picker/src/ColorPicker.d.ts +13 -5
- package/lib/color-picker/src/ColorPicker.js +19 -10
- package/lib/color-picker/src/ColorPickerTrigger.d.ts +1 -1
- package/lib/color-picker/src/ColorPickerTrigger.js +22 -16
- package/lib/color-picker/src/interface.d.ts +2 -0
- package/lib/color-picker/src/styles/index.cssr.js +1 -0
- package/lib/config-provider/src/ConfigProvider.d.ts +27 -0
- package/lib/data-table/src/DataTable.d.ts +10 -55
- package/lib/data-table/src/DataTable.js +21 -47
- package/lib/data-table/src/interface.d.ts +1 -1
- package/lib/data-table/src/styles/index.cssr.js +4 -1
- package/lib/data-table/src/utils.js +3 -0
- package/lib/date-picker/src/DatePicker.d.ts +26 -22
- package/lib/date-picker/src/DatePicker.js +98 -48
- package/lib/date-picker/src/interface.d.ts +17 -2
- package/lib/date-picker/src/panel/use-calendar.js +2 -2
- package/lib/drawer/src/Drawer.d.ts +18 -58
- package/lib/drawer/src/Drawer.js +30 -47
- package/lib/drawer/src/DrawerBodyWrapper.js +21 -13
- package/lib/drawer/src/DrawerContent.js +6 -6
- package/lib/dropdown/src/Dropdown.d.ts +5 -0
- package/lib/form/src/Feedbacks.js +4 -1
- package/lib/form/src/Form.d.ts +7 -7
- package/lib/form/src/Form.js +16 -7
- package/lib/form/src/FormItem.d.ts +12 -7
- package/lib/form/src/FormItem.js +23 -11
- package/lib/form/src/FormItemCol.d.ts +8 -4
- package/lib/form/src/FormItemGridItem.d.ts +8 -4
- package/lib/form/src/FormItemRow.d.ts +7 -3
- package/lib/form/src/interface.d.ts +6 -2
- package/lib/form/src/styles/form-item.cssr.js +2 -0
- package/lib/form/src/utils.d.ts +2 -2
- package/lib/form/src/utils.js +29 -18
- package/lib/image/src/Image.d.ts +279 -10
- package/lib/image/src/Image.js +4 -17
- package/lib/image/src/ImageGroup.d.ts +272 -2
- package/lib/image/src/ImageGroup.js +4 -7
- package/lib/image/src/ImagePreview.d.ts +195 -7
- package/lib/image/src/ImagePreview.js +49 -30
- package/lib/image/src/interface.d.ts +94 -0
- package/lib/image/src/interface.js +3 -0
- package/lib/image/src/styles/index.cssr.js +8 -4
- package/lib/image/styles/dark.js +8 -1
- package/lib/image/styles/light.d.ts +32 -3
- package/lib/image/styles/light.js +8 -1
- package/lib/input-number/src/utils.js +2 -2
- package/lib/locales/common/deDE.js +10 -0
- package/lib/locales/common/enUS.d.ts +9 -0
- package/lib/locales/common/enUS.js +10 -0
- package/lib/locales/common/frFR.js +10 -0
- package/lib/locales/common/idID.js +10 -0
- package/lib/locales/common/jaJP.js +10 -0
- package/lib/locales/common/nbNO.js +10 -0
- package/lib/locales/common/ruRU.js +10 -0
- package/lib/locales/common/ukUA.js +10 -0
- package/lib/locales/common/zhCN.js +9 -0
- package/lib/locales/common/zhTW.js +10 -0
- package/lib/mention/src/utils.js +0 -1
- package/lib/message/index.d.ts +2 -1
- package/lib/message/src/Message.d.ts +191 -19
- package/lib/message/src/Message.js +13 -11
- package/lib/message/src/MessageEnvironment.d.ts +3 -3
- package/lib/message/src/MessageProvider.d.ts +5 -10
- package/lib/message/src/MessageProvider.js +1 -1
- package/lib/message/src/message-props.d.ts +5 -2
- package/lib/message/src/types.d.ts +15 -0
- package/lib/message/src/types.js +2 -0
- package/lib/modal/src/Modal.d.ts +5 -0
- package/lib/modal/src/Modal.js +2 -1
- package/lib/page-header/index.d.ts +1 -1
- package/lib/page-header/src/PageHeader.d.ts +1 -1
- package/lib/pagination/index.d.ts +1 -1
- package/lib/pagination/src/Pagination.d.ts +8 -4
- package/lib/pagination/src/Pagination.js +65 -18
- package/lib/pagination/src/interface.d.ts +10 -1
- package/lib/pagination/src/utils.d.ts +2 -2
- package/lib/pagination/src/utils.js +2 -4
- package/lib/popconfirm/src/Popconfirm.d.ts +5 -0
- package/lib/popover/src/Popover.d.ts +7 -0
- package/lib/popover/src/Popover.js +23 -0
- package/lib/popover/src/PopoverBody.d.ts +5 -0
- package/lib/popover/src/PopoverBody.js +27 -45
- package/lib/popover/src/styles/index.cssr.js +9 -8
- package/lib/popselect/src/Popselect.d.ts +62 -73
- package/lib/popselect/src/Popselect.js +2 -2
- package/lib/progress/src/Circle.d.ts +7 -0
- package/lib/progress/src/Circle.js +8 -1
- package/lib/progress/src/Line.d.ts +2 -2
- package/lib/progress/src/Line.js +4 -1
- package/lib/progress/src/Progress.d.ts +6 -2
- package/lib/progress/src/Progress.js +2 -2
- package/lib/progress/src/styles/index.cssr.js +16 -16
- package/lib/radio/src/styles/radio.cssr.js +4 -1
- package/lib/result/src/Result.js +8 -9
- package/lib/result/src/styles/index.cssr.js +6 -6
- package/lib/select/src/Select.d.ts +8 -27
- package/lib/select/src/Select.js +14 -22
- package/lib/slider/src/Slider.d.ts +2 -4
- package/lib/tabs/index.d.ts +1 -0
- package/lib/tabs/src/Tabs.d.ts +2 -2
- package/lib/tabs/src/Tabs.js +25 -22
- package/lib/tabs/src/interface.d.ts +3 -0
- package/lib/time-picker/src/TimePicker.d.ts +22 -2
- package/lib/time-picker/src/TimePicker.js +59 -29
- package/lib/time-picker/src/interface.d.ts +4 -2
- package/lib/tooltip/src/Tooltip.d.ts +5 -0
- package/lib/tree/src/Tree.d.ts +5 -1
- package/lib/tree/src/Tree.js +4 -2
- package/lib/tree/src/TreeNodeSwitcher.d.ts +1 -1
- package/lib/tree/src/TreeNodeSwitcher.js +24 -13
- package/lib/tree/src/interface.d.ts +2 -0
- package/lib/tree/src/styles/index.cssr.js +4 -2
- package/lib/upload/src/Upload.d.ts +15 -6
- package/lib/upload/src/Upload.js +18 -9
- package/lib/upload/src/UploadFile.d.ts +5 -5
- package/lib/upload/src/UploadFileList.js +2 -2
- package/lib/upload/src/interface.d.ts +11 -4
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +21 -13
- package/web-types.json +413 -31
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {
|
|
2
|
+
mergedClsPrefix: import("vue").ComputedRef<string>;
|
|
3
|
+
isVertical: () => boolean;
|
|
4
|
+
isPrevDisabled: () => boolean;
|
|
5
|
+
isNextDisabled: () => boolean;
|
|
6
|
+
prev: () => void;
|
|
7
|
+
next: () => void;
|
|
8
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{} & {} & {}>, {}>;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { h, defineComponent, inject, Fragment } from 'vue';
|
|
2
|
+
import { useConfig } from '../../_mixins';
|
|
3
|
+
import { carouselMethodsInjectionKey } from './interface';
|
|
4
|
+
const backwardIcon = (h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16" },
|
|
5
|
+
h("g", { fill: "none" },
|
|
6
|
+
h("path", { d: "M10.26 3.2a.75.75 0 0 1 .04 1.06L6.773 8l3.527 3.74a.75.75 0 1 1-1.1 1.02l-4-4.25a.75.75 0 0 1 0-1.02l4-4.25a.75.75 0 0 1 1.06-.04z", fill: "currentColor" }))));
|
|
7
|
+
const forwardIcon = (h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16" },
|
|
8
|
+
h("g", { fill: "none" },
|
|
9
|
+
h("path", { d: "M5.74 3.2a.75.75 0 0 0-.04 1.06L9.227 8L5.7 11.74a.75.75 0 1 0 1.1 1.02l4-4.25a.75.75 0 0 0 0-1.02l-4-4.25a.75.75 0 0 0-1.06-.04z", fill: "currentColor" }))));
|
|
10
|
+
export default defineComponent({
|
|
11
|
+
name: 'CarouselArrow',
|
|
12
|
+
setup(props) {
|
|
13
|
+
const { mergedClsPrefixRef } = useConfig(props);
|
|
14
|
+
const { isVertical, isPrevDisabled, isNextDisabled, prev, next
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
16
|
+
} = inject(carouselMethodsInjectionKey, null);
|
|
17
|
+
return {
|
|
18
|
+
mergedClsPrefix: mergedClsPrefixRef,
|
|
19
|
+
isVertical,
|
|
20
|
+
isPrevDisabled,
|
|
21
|
+
isNextDisabled,
|
|
22
|
+
prev,
|
|
23
|
+
next
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
render() {
|
|
27
|
+
const { mergedClsPrefix } = this;
|
|
28
|
+
const isVertical = this.isVertical();
|
|
29
|
+
return (h(Fragment, null,
|
|
30
|
+
h("div", { class: [
|
|
31
|
+
`${mergedClsPrefix}-carousel__arrow`,
|
|
32
|
+
`${mergedClsPrefix}-carousel__arrow--${isVertical ? 'bottom' : 'right'}`,
|
|
33
|
+
this.isNextDisabled() &&
|
|
34
|
+
`${mergedClsPrefix}-carousel__arrow--disabled`
|
|
35
|
+
], role: "button", onClick: this.next }, forwardIcon),
|
|
36
|
+
h("div", { class: [
|
|
37
|
+
`${mergedClsPrefix}-carousel__arrow`,
|
|
38
|
+
`${mergedClsPrefix}-carousel__arrow--${isVertical ? 'top' : 'left'}`,
|
|
39
|
+
this.isPrevDisabled() &&
|
|
40
|
+
`${mergedClsPrefix}-carousel__arrow--disabled`
|
|
41
|
+
], role: "button", onClick: this.prev }, backwardIcon)));
|
|
42
|
+
}
|
|
43
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { PropType } from 'vue';
|
|
2
|
+
import type { ExtractPublicPropTypes } from '../../_utils';
|
|
3
|
+
declare const carouselDotsProps: {
|
|
4
|
+
total: {
|
|
5
|
+
type: NumberConstructor;
|
|
6
|
+
default: number;
|
|
7
|
+
};
|
|
8
|
+
currentIndex: {
|
|
9
|
+
type: NumberConstructor;
|
|
10
|
+
default: number;
|
|
11
|
+
};
|
|
12
|
+
dotType: {
|
|
13
|
+
type: PropType<"never" | "dot" | "line">;
|
|
14
|
+
default: string;
|
|
15
|
+
};
|
|
16
|
+
trigger: {
|
|
17
|
+
type: PropType<"click" | "hover">;
|
|
18
|
+
default: string;
|
|
19
|
+
};
|
|
20
|
+
keyboard: BooleanConstructor;
|
|
21
|
+
};
|
|
22
|
+
export declare type CarouselDotsProps = ExtractPublicPropTypes<typeof carouselDotsProps>;
|
|
23
|
+
declare const _default: import("vue").DefineComponent<{
|
|
24
|
+
total: {
|
|
25
|
+
type: NumberConstructor;
|
|
26
|
+
default: number;
|
|
27
|
+
};
|
|
28
|
+
currentIndex: {
|
|
29
|
+
type: NumberConstructor;
|
|
30
|
+
default: number;
|
|
31
|
+
};
|
|
32
|
+
dotType: {
|
|
33
|
+
type: PropType<"never" | "dot" | "line">;
|
|
34
|
+
default: string;
|
|
35
|
+
};
|
|
36
|
+
trigger: {
|
|
37
|
+
type: PropType<"click" | "hover">;
|
|
38
|
+
default: string;
|
|
39
|
+
};
|
|
40
|
+
keyboard: BooleanConstructor;
|
|
41
|
+
}, {
|
|
42
|
+
mergedClsPrefix: import("vue").ComputedRef<string>;
|
|
43
|
+
dotEls: import("vue").Ref<HTMLElement[]>;
|
|
44
|
+
handleKeydown: (e: KeyboardEvent, current: number) => void;
|
|
45
|
+
handleMouseenter: (current: number) => void;
|
|
46
|
+
handleClick: (current: number) => void;
|
|
47
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
|
|
48
|
+
total?: unknown;
|
|
49
|
+
currentIndex?: unknown;
|
|
50
|
+
dotType?: unknown;
|
|
51
|
+
trigger?: unknown;
|
|
52
|
+
keyboard?: unknown;
|
|
53
|
+
} & {
|
|
54
|
+
trigger: "click" | "hover";
|
|
55
|
+
keyboard: boolean;
|
|
56
|
+
total: number;
|
|
57
|
+
currentIndex: number;
|
|
58
|
+
dotType: "never" | "dot" | "line";
|
|
59
|
+
} & {}>, {
|
|
60
|
+
trigger: "click" | "hover";
|
|
61
|
+
keyboard: boolean;
|
|
62
|
+
total: number;
|
|
63
|
+
currentIndex: number;
|
|
64
|
+
dotType: "never" | "dot" | "line";
|
|
65
|
+
}>;
|
|
66
|
+
export default _default;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { h, defineComponent, inject, ref, onBeforeUpdate } from 'vue';
|
|
2
|
+
import { indexMap } from 'seemly';
|
|
3
|
+
import { useConfig } from '../../_mixins';
|
|
4
|
+
import { carouselMethodsInjectionKey } from './interface';
|
|
5
|
+
const carouselDotsProps = {
|
|
6
|
+
total: {
|
|
7
|
+
type: Number,
|
|
8
|
+
default: 0
|
|
9
|
+
},
|
|
10
|
+
currentIndex: {
|
|
11
|
+
type: Number,
|
|
12
|
+
default: 0
|
|
13
|
+
},
|
|
14
|
+
dotType: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: 'dot'
|
|
17
|
+
},
|
|
18
|
+
trigger: {
|
|
19
|
+
type: String,
|
|
20
|
+
default: 'click'
|
|
21
|
+
},
|
|
22
|
+
keyboard: Boolean
|
|
23
|
+
};
|
|
24
|
+
export default defineComponent({
|
|
25
|
+
name: 'CarouselDots',
|
|
26
|
+
props: carouselDotsProps,
|
|
27
|
+
setup(props) {
|
|
28
|
+
const { mergedClsPrefixRef } = useConfig(props);
|
|
29
|
+
const dotElsRef = ref([]);
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
31
|
+
const NCarousel = inject(carouselMethodsInjectionKey, null);
|
|
32
|
+
function handleKeydown(e, current) {
|
|
33
|
+
switch (e.code) {
|
|
34
|
+
case 'Enter':
|
|
35
|
+
case 'NumpadEnter':
|
|
36
|
+
case 'Space':
|
|
37
|
+
NCarousel.to(current);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (props.keyboard) {
|
|
41
|
+
handleKeyboard(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function handleMouseenter(current) {
|
|
45
|
+
if (props.trigger === 'hover') {
|
|
46
|
+
NCarousel.to(current);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function handleClick(current) {
|
|
50
|
+
if (props.trigger === 'click') {
|
|
51
|
+
NCarousel.to(current);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function handleKeyboard(e) {
|
|
55
|
+
var _a;
|
|
56
|
+
const { code: keycode } = e;
|
|
57
|
+
const vertical = NCarousel.isVertical();
|
|
58
|
+
const isVerticalNext = keycode === 'PageUp' || keycode === 'ArrowUp';
|
|
59
|
+
const isVerticalPrev = keycode === 'PageDown' || keycode === 'ArrowDown';
|
|
60
|
+
const isHorizontalNext = keycode === 'PageUp' || keycode === 'ArrowRight';
|
|
61
|
+
const isHorizontalPrev = keycode === 'PageDown' || keycode === 'ArrowLeft';
|
|
62
|
+
if (vertical &&
|
|
63
|
+
((isVerticalNext && NCarousel.isNextDisabled()) ||
|
|
64
|
+
(isVerticalPrev && NCarousel.isPrevDisabled()))) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (!vertical &&
|
|
68
|
+
((isHorizontalNext && NCarousel.isNextDisabled()) ||
|
|
69
|
+
(isHorizontalPrev && NCarousel.isPrevDisabled()))) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const nodeName = (_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.nodeName.toLowerCase();
|
|
76
|
+
if (nodeName === 'input' || nodeName === 'textarea') {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (vertical ? isVerticalNext : isHorizontalNext) {
|
|
80
|
+
e.preventDefault();
|
|
81
|
+
NCarousel.next();
|
|
82
|
+
focusDot(NCarousel.getCurrentIndex());
|
|
83
|
+
}
|
|
84
|
+
else if (vertical ? isVerticalPrev : isHorizontalPrev) {
|
|
85
|
+
e.preventDefault();
|
|
86
|
+
NCarousel.prev();
|
|
87
|
+
focusDot(NCarousel.getCurrentIndex());
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function focusDot(index = props.currentIndex) {
|
|
91
|
+
const { value: dotEls } = dotElsRef;
|
|
92
|
+
if (index >= 0 && index < dotEls.length) {
|
|
93
|
+
dotEls[index].focus();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
onBeforeUpdate(() => (dotElsRef.value.length = 0));
|
|
97
|
+
return {
|
|
98
|
+
mergedClsPrefix: mergedClsPrefixRef,
|
|
99
|
+
dotEls: dotElsRef,
|
|
100
|
+
handleKeydown,
|
|
101
|
+
handleMouseenter,
|
|
102
|
+
handleClick
|
|
103
|
+
};
|
|
104
|
+
},
|
|
105
|
+
render() {
|
|
106
|
+
const { mergedClsPrefix, dotEls } = this;
|
|
107
|
+
return (h("div", { class: [
|
|
108
|
+
`${mergedClsPrefix}-carousel__dots`,
|
|
109
|
+
`${mergedClsPrefix}-carousel__dots--${this.dotType}`
|
|
110
|
+
], role: "tablist" }, indexMap(this.total, (i) => {
|
|
111
|
+
const selected = i === this.currentIndex;
|
|
112
|
+
return (h("div", { "aria-selected": selected, ref: (el) => dotEls.push(el), role: "button", tabindex: "0", class: [
|
|
113
|
+
`${mergedClsPrefix}-carousel__dot`,
|
|
114
|
+
selected && `${mergedClsPrefix}-carousel__dot--active`
|
|
115
|
+
], key: i, onClick: () => this.handleClick(i), onMouseenter: () => this.handleMouseenter(i), onKeydown: (e) => this.handleKeydown(e, i) }));
|
|
116
|
+
})));
|
|
117
|
+
}
|
|
118
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {
|
|
2
|
+
mergedClsPrefix: import("vue").ComputedRef<string>;
|
|
3
|
+
selfElRef: import("vue").Ref<HTMLElement | undefined>;
|
|
4
|
+
isPrev: import("vue").ComputedRef<boolean>;
|
|
5
|
+
isNext: import("vue").ComputedRef<boolean>;
|
|
6
|
+
isActive: import("vue").ComputedRef<boolean>;
|
|
7
|
+
index: import("vue").ComputedRef<number | undefined>;
|
|
8
|
+
style: import("vue").ComputedRef<any>;
|
|
9
|
+
handleClick: (e: MouseEvent) => void;
|
|
10
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{} & {} & {}>, {}>;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { h, defineComponent, renderSlot, inject, computed, ref, onMounted, onBeforeUnmount } from 'vue';
|
|
2
|
+
import { useConfig } from '../../_mixins';
|
|
3
|
+
import { throwError } from '../../_utils';
|
|
4
|
+
import { carouselMethodsInjectionKey } from './interface';
|
|
5
|
+
export default defineComponent({
|
|
6
|
+
name: 'CarouselItem',
|
|
7
|
+
setup(props) {
|
|
8
|
+
const { mergedClsPrefixRef } = useConfig(props);
|
|
9
|
+
const NCarousel = inject(carouselMethodsInjectionKey, null);
|
|
10
|
+
if (!NCarousel) {
|
|
11
|
+
throwError('carousel-item', '`n-carousel-item` must be placed inside `n-carousel`.');
|
|
12
|
+
}
|
|
13
|
+
const selfElRef = ref();
|
|
14
|
+
const isPrevRef = computed(() => {
|
|
15
|
+
const { value: selfEl } = selfElRef;
|
|
16
|
+
return Boolean(selfEl && NCarousel.isPrev(selfEl));
|
|
17
|
+
});
|
|
18
|
+
const isNextRef = computed(() => {
|
|
19
|
+
const { value: selfEl } = selfElRef;
|
|
20
|
+
return Boolean(selfEl && NCarousel.isNext(selfEl));
|
|
21
|
+
});
|
|
22
|
+
const isActiveRef = computed(() => {
|
|
23
|
+
const { value: selfEl } = selfElRef;
|
|
24
|
+
return Boolean(selfEl && NCarousel.isActive(selfEl));
|
|
25
|
+
});
|
|
26
|
+
const styleRef = computed(() => {
|
|
27
|
+
const { value: selfEl } = selfElRef;
|
|
28
|
+
return selfEl && NCarousel.getSlideStyle(selfEl);
|
|
29
|
+
});
|
|
30
|
+
const indexRef = computed(() => {
|
|
31
|
+
const { value: selfEl } = selfElRef;
|
|
32
|
+
return selfEl && NCarousel.getSlideIndex(selfEl);
|
|
33
|
+
});
|
|
34
|
+
function handleClick(e) {
|
|
35
|
+
const { value: index } = indexRef;
|
|
36
|
+
if (index !== undefined) {
|
|
37
|
+
NCarousel === null || NCarousel === void 0 ? void 0 : NCarousel.onCarouselItemClick(index);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
onMounted(() => NCarousel.addSlide(selfElRef.value));
|
|
41
|
+
onBeforeUnmount(() => {
|
|
42
|
+
NCarousel.removeSlide(selfElRef.value);
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
mergedClsPrefix: mergedClsPrefixRef,
|
|
46
|
+
selfElRef,
|
|
47
|
+
isPrev: isPrevRef,
|
|
48
|
+
isNext: isNextRef,
|
|
49
|
+
isActive: isActiveRef,
|
|
50
|
+
index: indexRef,
|
|
51
|
+
style: styleRef,
|
|
52
|
+
handleClick
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
render() {
|
|
56
|
+
const { $slots: slots, mergedClsPrefix, isPrev, isNext, isActive, index, style } = this;
|
|
57
|
+
const className = [
|
|
58
|
+
`${mergedClsPrefix}-carousel__slide`,
|
|
59
|
+
{
|
|
60
|
+
[`${mergedClsPrefix}-carousel__slide--current`]: isActive,
|
|
61
|
+
[`${mergedClsPrefix}-carousel__slide--prev`]: isPrev,
|
|
62
|
+
[`${mergedClsPrefix}-carousel__slide--next`]: isNext
|
|
63
|
+
}
|
|
64
|
+
];
|
|
65
|
+
return (h("div", { ref: 'selfElRef', class: className, role: 'option', tabindex: "-1", "data-index": index, "aria-hidden": !isActive, style: style, onClick: this.handleClick }, renderSlot(slots, 'default', {
|
|
66
|
+
isPrev,
|
|
67
|
+
isNext,
|
|
68
|
+
isActive,
|
|
69
|
+
index
|
|
70
|
+
})));
|
|
71
|
+
}
|
|
72
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { InjectionKey } from 'vue';
|
|
2
|
+
export declare const tuple: <T extends string[]>(...args: T) => T;
|
|
3
|
+
export declare type ElementOf<T> = T extends Array<infer E> ? E : T extends ReadonlyArray<infer F> ? F : never;
|
|
4
|
+
export interface CarouselMethodsInjection {
|
|
5
|
+
to: (index: number) => void;
|
|
6
|
+
prev: () => void;
|
|
7
|
+
next: () => void;
|
|
8
|
+
isVertical: () => boolean;
|
|
9
|
+
isHorizontal: () => boolean;
|
|
10
|
+
isPrev: (slide: number | HTMLElement) => boolean;
|
|
11
|
+
isNext: (slide: number | HTMLElement) => boolean;
|
|
12
|
+
isActive: (slide: number | HTMLElement) => boolean;
|
|
13
|
+
isPrevDisabled: () => boolean;
|
|
14
|
+
isNextDisabled: () => boolean;
|
|
15
|
+
getCurrentIndex: () => number;
|
|
16
|
+
getSlideIndex: (slide: number | HTMLElement) => number;
|
|
17
|
+
getSlideStyle: (slide: HTMLElement) => any;
|
|
18
|
+
addSlide: (slide?: HTMLElement) => void;
|
|
19
|
+
removeSlide: (slide?: HTMLElement) => void;
|
|
20
|
+
onCarouselItemClick: (index: number) => void;
|
|
21
|
+
}
|
|
22
|
+
export declare const carouselMethodsInjectionKey: InjectionKey<CarouselMethodsInjection>;
|
|
23
|
+
export interface CarouselInst {
|
|
24
|
+
getCurrentIndex: () => number;
|
|
25
|
+
to: (index: number) => void;
|
|
26
|
+
prev: () => void;
|
|
27
|
+
next: () => void;
|
|
28
|
+
}
|
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
import { c, cB, cE, cM } from '../../../_utils/cssr'; // vars:
|
|
2
|
-
// --bezier
|
|
3
|
-
// --dot-color
|
|
4
|
-
// --dot-color-
|
|
5
|
-
// --dot-
|
|
6
|
-
// --
|
|
2
|
+
// --n-bezier
|
|
3
|
+
// --n-dot-color
|
|
4
|
+
// --n-dot-color-focus
|
|
5
|
+
// --n-dot-color-active
|
|
6
|
+
// --n-dot-size
|
|
7
|
+
// --n-dot-line-width
|
|
8
|
+
// --n-dot-line-width-active
|
|
9
|
+
// --n-arrow-color
|
|
7
10
|
|
|
8
11
|
export default cB('carousel', `
|
|
9
|
-
overflow: hidden;
|
|
10
12
|
position: relative;
|
|
13
|
+
width: 100%;
|
|
14
|
+
height: 100%;
|
|
15
|
+
overflow: hidden;
|
|
11
16
|
`, [cE('slides', `
|
|
12
|
-
transition: transform .3s var(--n-bezier);
|
|
13
17
|
display: flex;
|
|
14
|
-
|
|
18
|
+
width: 100%;
|
|
19
|
+
height: 100%;
|
|
20
|
+
transition-timing-function: var(--n-bezier);
|
|
21
|
+
transition-property: transform;
|
|
22
|
+
touch-action: pan-y;
|
|
23
|
+
`, [cE('slide', `
|
|
24
|
+
flex-shrink: 0;
|
|
25
|
+
position: relative;
|
|
26
|
+
width: 100%;
|
|
27
|
+
height: 100%;
|
|
28
|
+
outline: none;
|
|
15
29
|
overflow: hidden;
|
|
16
30
|
`, [c('> img', `
|
|
17
31
|
display: block;
|
|
@@ -19,7 +33,7 @@ export default cB('carousel', `
|
|
|
19
33
|
position: absolute;
|
|
20
34
|
display: flex;
|
|
21
35
|
flex-wrap: nowrap;
|
|
22
|
-
|
|
36
|
+
`, [cM('dot', [cE('dot', `
|
|
23
37
|
height: var(--n-dot-size);
|
|
24
38
|
width: var(--n-dot-size);
|
|
25
39
|
background-color: var(--n-dot-color);
|
|
@@ -30,26 +44,41 @@ export default cB('carousel', `
|
|
|
30
44
|
background-color .3s var(--n-bezier);
|
|
31
45
|
outline: none;
|
|
32
46
|
`, [c('&:focus', `
|
|
47
|
+
background-color: var(--n-dot-color-focus);
|
|
48
|
+
`), cM('active', `
|
|
33
49
|
background-color: var(--n-dot-color-active);
|
|
50
|
+
`)])]), cM('line', [cE('dot', `
|
|
51
|
+
border-radius: 9999px;
|
|
52
|
+
width: var(--n-dot-line-width);
|
|
53
|
+
height: 4px;
|
|
54
|
+
background-color: var(--n-dot-color);
|
|
55
|
+
cursor: pointer;
|
|
56
|
+
transition:
|
|
57
|
+
width .3s var(--n-bezier),
|
|
58
|
+
box-shadow .3s var(--n-bezier),
|
|
59
|
+
background-color .3s var(--n-bezier);
|
|
60
|
+
outline: none;
|
|
61
|
+
`, [c('&:focus', `
|
|
62
|
+
background-color: var(--n-dot-color-focus);
|
|
34
63
|
`), cM('active', `
|
|
64
|
+
width: var(--n-dot-line-width-active);
|
|
35
65
|
background-color: var(--n-dot-color-active);
|
|
36
|
-
`),
|
|
37
|
-
margin-right: 0;
|
|
38
|
-
`)]), cE('arrow', `
|
|
66
|
+
`)])])]), cE('arrow', `
|
|
39
67
|
position: absolute;
|
|
40
68
|
transition: transform .3s var(--n-bezier);
|
|
41
69
|
transform: scale(1);
|
|
42
70
|
cursor: pointer;
|
|
43
|
-
height:
|
|
44
|
-
width:
|
|
71
|
+
height: 36px;
|
|
72
|
+
width: 36px;
|
|
45
73
|
display: flex;
|
|
46
74
|
align-items: center;
|
|
47
75
|
justify-content: center;
|
|
48
76
|
color: var(--n-arrow-color);
|
|
77
|
+
user-select: none;
|
|
49
78
|
`, [cM('right', `
|
|
50
79
|
transform: translateY(-50%);
|
|
51
80
|
top: 50%;
|
|
52
|
-
right:
|
|
81
|
+
right: -2px;
|
|
53
82
|
`, [c('&:hover', {
|
|
54
83
|
transform: 'translateY(-50%) scale(1.1)'
|
|
55
84
|
}), c('&:active', {
|
|
@@ -57,14 +86,14 @@ export default cB('carousel', `
|
|
|
57
86
|
})]), cM('left', `
|
|
58
87
|
transform: translateY(-50%);
|
|
59
88
|
top: 50%;
|
|
60
|
-
left:
|
|
89
|
+
left: -2px;
|
|
61
90
|
`, [c('&:hover', {
|
|
62
91
|
transform: 'translateY(-50%) scale(1.1)'
|
|
63
92
|
}), c('&:active', {
|
|
64
93
|
transform: 'translateY(-50%) scale(1)'
|
|
65
94
|
})]), cM('top', `
|
|
66
95
|
transform: translateX(-50%) rotate(90deg);
|
|
67
|
-
top:
|
|
96
|
+
top: -2px;
|
|
68
97
|
left: 50%;
|
|
69
98
|
`, [c('&:hover', {
|
|
70
99
|
transform: 'translateX(-50%) scale(1.1) rotate(90deg)'
|
|
@@ -72,43 +101,117 @@ export default cB('carousel', `
|
|
|
72
101
|
transform: 'translateX(-50%) scale(1) rotate(90deg)'
|
|
73
102
|
})]), cM('bottom', `
|
|
74
103
|
transform: translateX(-50%) rotate(90deg);
|
|
75
|
-
bottom:
|
|
76
|
-
left: 50
|
|
104
|
+
bottom: -2px;
|
|
105
|
+
left: 50%
|
|
77
106
|
`, [c('&:hover', {
|
|
78
107
|
transform: 'translateX(-50%) scale(1.1) rotate(90deg)'
|
|
79
108
|
}), c('&:active', {
|
|
80
109
|
transform: 'translateX(-50%) scale(1) rotate(90deg)'
|
|
81
|
-
})]),
|
|
110
|
+
})]), cM('disabled', `
|
|
111
|
+
opacity: 0.6;
|
|
112
|
+
cursor: auto;
|
|
113
|
+
pointer-events: none;
|
|
114
|
+
`), c('svg', {
|
|
82
115
|
height: '100%',
|
|
83
116
|
width: '100%'
|
|
84
|
-
})]), cM('
|
|
117
|
+
})]), cM('vertical', [cE('slides', `
|
|
85
118
|
flex-direction: column;
|
|
86
|
-
|
|
119
|
+
touch-action: pan-x;
|
|
120
|
+
`), cM('fade', [cE('slide', `
|
|
121
|
+
top: 50%;
|
|
122
|
+
left: unset;
|
|
87
123
|
transform: translateY(-50%);
|
|
124
|
+
`)]), cM('card', [cE('slide', `
|
|
88
125
|
top: 50%;
|
|
89
|
-
left:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
`)
|
|
126
|
+
left: unset;
|
|
127
|
+
transform: translateY(-50%) translateZ(-400px);
|
|
128
|
+
`, [cM('current', `
|
|
129
|
+
transform: translateY(-50%) translateZ(0);
|
|
130
|
+
`), cM('prev', `
|
|
131
|
+
transform: translateY(-100%) translateZ(-200px);
|
|
132
|
+
`), cM('next', `
|
|
133
|
+
transform: translateY(0%) translateZ(-200px);
|
|
134
|
+
`)])])]), cM('usercontrol', [cE('slide', `
|
|
135
|
+
position: absolute;
|
|
136
|
+
top: 50%;
|
|
137
|
+
left: 50%;
|
|
138
|
+
transform: translate(-50%, -50%);
|
|
139
|
+
`)]), cM('left', [cE('dots', `
|
|
140
|
+
transform: translateY(-50%);
|
|
141
|
+
top: 50%;
|
|
142
|
+
left: 12px;
|
|
94
143
|
flex-direction: column;
|
|
95
|
-
|
|
144
|
+
`, [cM('line', [cE('dot', `
|
|
145
|
+
width: 4px;
|
|
146
|
+
height: var(--n-dot-line-width);
|
|
147
|
+
margin: 4px 0;
|
|
148
|
+
transition:
|
|
149
|
+
height .3s var(--n-bezier),
|
|
150
|
+
box-shadow .3s var(--n-bezier),
|
|
151
|
+
background-color .3s var(--n-bezier);
|
|
152
|
+
outline: none;
|
|
153
|
+
`, [cM('active', `
|
|
154
|
+
height: var(--n-dot-line-width-active);
|
|
155
|
+
`)])])]), cE('dot', `
|
|
156
|
+
margin: 4px 0;
|
|
157
|
+
`)]), cM('right', [cE('dots', `
|
|
96
158
|
transform: translateY(-50%);
|
|
97
159
|
top: 50%;
|
|
98
|
-
right:
|
|
160
|
+
right: 12px;
|
|
99
161
|
flex-direction: column;
|
|
100
|
-
|
|
101
|
-
|
|
162
|
+
`, [cM('line', [cE('dot', `
|
|
163
|
+
width: 4px;
|
|
164
|
+
height: var(--n-dot-line-width);
|
|
165
|
+
margin: 4px 0;
|
|
166
|
+
transition:
|
|
167
|
+
height .3s var(--n-bezier),
|
|
168
|
+
box-shadow .3s var(--n-bezier),
|
|
169
|
+
background-color .3s var(--n-bezier);
|
|
170
|
+
outline: none;
|
|
171
|
+
`, [cM('active', `
|
|
172
|
+
height: var(--n-dot-line-width-active);
|
|
173
|
+
`)])])]), cE('dot', `
|
|
174
|
+
margin: 4px 0;
|
|
102
175
|
`)]), cM('top', [cE('dots', `
|
|
103
176
|
transform: translateX(-50%);
|
|
104
|
-
top:
|
|
177
|
+
top: 12px;
|
|
105
178
|
left: 50%;
|
|
106
|
-
|
|
107
|
-
margin
|
|
179
|
+
`, [cM('line', [cE('dot', `
|
|
180
|
+
margin: 0 4px;
|
|
181
|
+
`)])]), cE('dot', `
|
|
182
|
+
margin: 0 4px;
|
|
108
183
|
`)]), cM('bottom', [cE('dots', `
|
|
109
184
|
transform: translateX(-50%);
|
|
110
|
-
bottom:
|
|
185
|
+
bottom: 12px;
|
|
186
|
+
left: 50%;
|
|
187
|
+
`, [cM('line', [cE('dot', `
|
|
188
|
+
margin: 0 4px;
|
|
189
|
+
`)])]), cE('dot', `
|
|
190
|
+
margin: 0 4px;
|
|
191
|
+
`)]), cM('fade', [cE('slide', `
|
|
192
|
+
position: absolute;
|
|
193
|
+
left: 50%;
|
|
194
|
+
opacity: 0;
|
|
195
|
+
transform: translateX(-50%);
|
|
196
|
+
transition-property: opacity;
|
|
197
|
+
`, [cM('current', `
|
|
198
|
+
opacity: 1;
|
|
199
|
+
`)])]), cM('card', [cE('slides', `
|
|
200
|
+
perspective: 1200px;
|
|
201
|
+
`), cE('slide', `
|
|
202
|
+
position: absolute;
|
|
111
203
|
left: 50%;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
204
|
+
opacity: 0;
|
|
205
|
+
transform: translateX(-50%) translateZ(-400px);
|
|
206
|
+
transition-property: opacity, transform;
|
|
207
|
+
`, [cM('current', `
|
|
208
|
+
opacity: 1;
|
|
209
|
+
transform: translateX(-50%) translateZ(0);
|
|
210
|
+
z-index: 1;
|
|
211
|
+
`), cM('prev', `
|
|
212
|
+
opacity: 0.4;
|
|
213
|
+
transform: translateX(-100%) translateZ(-200px);
|
|
214
|
+
`), cM('next', `
|
|
215
|
+
opacity: 0.4;
|
|
216
|
+
transform: translateX(0%) translateZ(-200px);
|
|
217
|
+
`)])])]);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface Size {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
}
|
|
5
|
+
export declare function isTouchEvent(e: MouseEvent | TouchEvent): e is TouchEvent;
|
|
6
|
+
export declare function calculateSize(element: HTMLElement, innerOnly?: boolean): Size;
|
|
7
|
+
export declare function clampValue(value: number, min: number, max: number): number;
|
|
8
|
+
export declare function resolveSpeed(value?: string | number): number;
|
|
9
|
+
export declare function getDisplayIndex(current: number, length: number, duplicatedable?: boolean): number;
|
|
10
|
+
export declare function getRealIndex(current: number, duplicatedable?: boolean): number;
|
|
11
|
+
export declare function getPrevIndex(current: number, length: number, duplicatedable?: boolean): number | null;
|
|
12
|
+
export declare function getNextIndex(current: number, length: number, duplicatedable?: boolean): number | null;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export function isTouchEvent(e) {
|
|
2
|
+
return window.TouchEvent && e instanceof window.TouchEvent;
|
|
3
|
+
}
|
|
4
|
+
export function calculateSize(element, innerOnly) {
|
|
5
|
+
let width = element.clientWidth;
|
|
6
|
+
let height = element.clientHeight;
|
|
7
|
+
if (innerOnly) {
|
|
8
|
+
const style = getComputedStyle(element);
|
|
9
|
+
width =
|
|
10
|
+
width -
|
|
11
|
+
parseFloat(style.getPropertyValue('padding-left')) -
|
|
12
|
+
parseFloat(style.getPropertyValue('padding-right'));
|
|
13
|
+
height =
|
|
14
|
+
height -
|
|
15
|
+
parseFloat(style.getPropertyValue('padding-top')) -
|
|
16
|
+
parseFloat(style.getPropertyValue('padding-bottom'));
|
|
17
|
+
return { width, height };
|
|
18
|
+
}
|
|
19
|
+
return { width, height };
|
|
20
|
+
}
|
|
21
|
+
export function clampValue(value, min, max) {
|
|
22
|
+
return value < min ? min : value > max ? max : value;
|
|
23
|
+
}
|
|
24
|
+
export function resolveSpeed(value) {
|
|
25
|
+
if (value === undefined)
|
|
26
|
+
return 0;
|
|
27
|
+
if (typeof value === 'number')
|
|
28
|
+
return value;
|
|
29
|
+
const timeRE = /^((\d+)?\.?\d+?)(ms|s)?$/;
|
|
30
|
+
const match = value.match(timeRE);
|
|
31
|
+
if (match) {
|
|
32
|
+
const [, number, , unit = 'ms'] = match;
|
|
33
|
+
return Number(number) * (unit === 'ms' ? 1 : 1000);
|
|
34
|
+
}
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
export function getDisplayIndex(current, length, duplicatedable) {
|
|
38
|
+
return !duplicatedable
|
|
39
|
+
? current
|
|
40
|
+
: current === 0
|
|
41
|
+
? length - 3
|
|
42
|
+
: current === length - 1
|
|
43
|
+
? 0
|
|
44
|
+
: current - 1;
|
|
45
|
+
}
|
|
46
|
+
export function getRealIndex(current, duplicatedable) {
|
|
47
|
+
return !duplicatedable ? current : current + 1;
|
|
48
|
+
}
|
|
49
|
+
export function getPrevIndex(current, length, duplicatedable) {
|
|
50
|
+
if (current < 0)
|
|
51
|
+
return null;
|
|
52
|
+
return current === 0 ? (duplicatedable ? length - 1 : null) : current - 1;
|
|
53
|
+
}
|
|
54
|
+
export function getNextIndex(current, length, duplicatedable) {
|
|
55
|
+
if (current > length - 1)
|
|
56
|
+
return null;
|
|
57
|
+
return current === length - 1 ? (duplicatedable ? 0 : null) : current + 1;
|
|
58
|
+
}
|