@nutui/nutui 3.1.22-beta.5 → 3.1.23-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/CHANGELOG.md +48 -0
- package/README.md +3 -4
- package/dist/nutui.es.js +20412 -4214
- package/dist/nutui.umd.js +20518 -4216
- package/dist/packages/_es/ActionSheet.js +149 -17
- package/dist/packages/_es/Address.js +535 -110
- package/dist/packages/_es/AddressList.js +615 -113
- package/dist/packages/_es/Animate.js +59 -17
- package/dist/packages/_es/Audio.js +257 -53
- package/dist/packages/_es/AudioOperate.js +100 -13
- package/dist/packages/_es/Avatar.js +162 -38
- package/dist/packages/_es/AvatarGroup.js +73 -14
- package/dist/packages/_es/BackTop.js +156 -43
- package/dist/packages/_es/Badge.js +86 -14
- package/dist/packages/_es/Barrage.js +120 -41
- package/dist/packages/_es/Button.js +128 -23
- package/dist/packages/_es/Calendar.js +246 -30
- package/dist/packages/_es/CalendarItem.js +1 -1
- package/dist/packages/_es/Card.js +107 -10
- package/dist/packages/_es/Cascader.js +496 -147
- package/dist/packages/_es/Category.js +58 -15
- package/dist/packages/_es/CategoryPane.js +111 -11
- package/dist/packages/_es/Cell.js +108 -21
- package/dist/packages/_es/CellGroup.js +44 -9
- package/dist/packages/_es/Checkbox.js +134 -29
- package/dist/packages/_es/CheckboxGroup.js +79 -29
- package/dist/packages/_es/CircleProgress.js +150 -28
- package/dist/packages/_es/Col.js +56 -14
- package/dist/packages/_es/Collapse.js +109 -32
- package/dist/packages/_es/CollapseItem.js +253 -59
- package/dist/packages/_es/Comment.js +434 -64
- package/dist/packages/_es/ConfigProvider.js +20 -8
- package/dist/packages/_es/CountDown.js +238 -56
- package/dist/packages/_es/CountUp.js +539 -140
- package/dist/packages/_es/DatePicker.js +315 -98
- package/dist/packages/_es/Dialog.js +289 -60
- package/dist/packages/_es/Divider.js +65 -13
- package/dist/packages/_es/Drag.js +197 -56
- package/dist/packages/_es/Ecard.js +159 -24
- package/dist/packages/_es/Elevator.js +255 -58
- package/dist/packages/_es/Ellipsis.js +200 -58
- package/dist/packages/_es/Empty.js +71 -12
- package/dist/packages/_es/FixedNav.js +122 -15
- package/dist/packages/_es/Form.js +151 -64
- package/dist/packages/_es/FormItem.js +114 -15
- package/dist/packages/_es/Grid.js +6 -5
- package/dist/packages/_es/GridItem.js +144 -33
- package/dist/packages/_es/Icon.js +40 -15
- package/dist/packages/_es/Image.js +137 -26
- package/dist/packages/_es/ImagePreview.js +547 -76
- package/dist/packages/_es/Indicator.js +62 -15
- package/dist/packages/_es/InfiniteLoading.js +249 -57
- package/dist/packages/_es/Input.js +433 -51
- package/dist/packages/_es/InputNumber.js +160 -41
- package/dist/packages/_es/Layout.js +5 -4
- package/dist/packages/_es/List.js +106 -18
- package/dist/packages/_es/Menu.js +168 -44
- package/dist/packages/_es/MenuItem.js +173 -37
- package/dist/packages/_es/Navbar.js +192 -30
- package/dist/packages/_es/NoticeBar.js +380 -74
- package/dist/packages/_es/Notify.js +227 -72
- package/dist/packages/_es/NumberKeyboard.js +272 -41
- package/dist/packages/_es/OldPicker.js +457 -130
- package/dist/packages/_es/OverLay.js +98 -24
- package/dist/packages/_es/Pagination.js +157 -39
- package/dist/packages/_es/Picker.js +454 -129
- package/dist/packages/_es/Popover.js +957 -318
- package/dist/packages/_es/Popup.js +299 -55
- package/dist/packages/_es/Price.js +118 -16
- package/dist/packages/_es/Progress.js +146 -14
- package/dist/packages/_es/PullRefresh.js +339 -84
- package/dist/packages/_es/Radio.js +90 -22
- package/dist/packages/_es/RadioGroup.js +37 -8
- package/dist/packages/_es/Range.js +408 -83
- package/dist/packages/_es/Rate.js +192 -36
- package/dist/packages/_es/Row.js +64 -22
- package/dist/packages/_es/SearchBar.js +238 -37
- package/dist/packages/_es/ShortPassword.js +225 -35
- package/dist/packages/_es/SideNavBar.js +81 -24
- package/dist/packages/_es/SideNavBarItem.js +46 -11
- package/dist/packages/_es/Signature.js +160 -41
- package/dist/packages/_es/Skeleton.js +136 -20
- package/dist/packages/_es/Sku.js +491 -84
- package/dist/packages/_es/Step.js +115 -20
- package/dist/packages/_es/Steps.js +53 -18
- package/dist/packages/_es/Sticky.js +138 -53
- package/dist/packages/_es/SubSideNavBar.js +82 -17
- package/dist/packages/_es/Swipe.js +178 -41
- package/dist/packages/_es/Swiper.js +433 -121
- package/dist/packages/_es/SwiperItem.js +53 -22
- package/dist/packages/_es/Switch.js +116 -21
- package/dist/packages/_es/TabPane.js +39 -12
- package/dist/packages/_es/Tabbar.js +72 -17
- package/dist/packages/_es/TabbarItem.js +151 -29
- package/dist/packages/_es/Table.js +178 -18
- package/dist/packages/_es/Tabs.js +202 -43
- package/dist/packages/_es/Tag.js +97 -20
- package/dist/packages/_es/TextArea.js +160 -42
- package/dist/packages/_es/TimeDetail.js +79 -18
- package/dist/packages/_es/TimePannel.js +48 -14
- package/dist/packages/_es/TimeSelect.js +112 -15
- package/dist/packages/_es/Toast.js +310 -71
- package/dist/packages/_es/Uploader.js +455 -104
- package/dist/packages/_es/Video.js +332 -74
- package/dist/packages/_es/common.js +128 -38
- package/dist/packages/_es/component.js +76 -35
- package/dist/packages/_es/index.js +6 -5
- package/dist/packages/_es/index2.js +30 -9
- package/dist/packages/_es/index3.js +8 -6
- package/dist/packages/_es/index4.js +64 -13
- package/dist/packages/_es/index5.js +780 -164
- package/dist/packages/_es/plugin-vue_export-helper.js +8 -7
- package/dist/packages/_es/pxCheck.js +5 -3
- package/dist/packages/_es/raf.js +15 -8
- package/dist/packages/imagepreview/index.scss +6 -1
- package/dist/packages/locale/lang/baseLang.js +3 -3
- package/dist/packages/locale/lang/en-US.js +105 -5
- package/dist/packages/locale/lang/id-ID.js +105 -5
- package/dist/packages/locale/lang/index.js +38 -16
- package/dist/packages/locale/lang/zh-CN.js +105 -5
- package/dist/packages/locale/lang/zh-TW.js +105 -5
- package/dist/packages/picker/index.scss +13 -0
- package/dist/smartips/attributes.json +8 -0
- package/dist/smartips/tags.json +3 -1
- package/dist/smartips/web-types.json +19 -1
- package/dist/style.css +1 -1
- package/dist/style.es.js +1 -1
- package/dist/styles/themes/default.scss +49 -49
- package/dist/styles/themes/jdb.scss +49 -49
- package/dist/styles/themes/jdt.scss +49 -49
- package/dist/styles/variables-jdb.scss +4 -1
- package/dist/styles/variables-jdt.scss +4 -1
- package/dist/styles/variables.scss +1 -1
- package/dist/types/__VUE/actionsheet/index.vue.d.ts +3 -3
- package/dist/types/__VUE/address/index.vue.d.ts +4 -4
- package/dist/types/__VUE/calendar/index.vue.d.ts +1 -1
- package/dist/types/__VUE/cascader/index.vue.d.ts +3 -3
- package/dist/types/__VUE/cell/index.vue.d.ts +2 -2
- package/dist/types/__VUE/checkbox/index.vue.d.ts +2 -2
- package/dist/types/__VUE/collapse/index.vue.d.ts +2 -2
- package/dist/types/__VUE/datepicker/index.vue.d.ts +2 -2
- package/dist/types/__VUE/dialog/index.vue.d.ts +2 -2
- package/dist/types/__VUE/ecard/index.vue.d.ts +2 -2
- package/dist/types/__VUE/fixednav/index.vue.d.ts +2 -2
- package/dist/types/__VUE/grid/index.vue.d.ts +3 -3
- package/dist/types/__VUE/imagepreview/imagePreviewItem.vue.d.ts +95 -0
- package/dist/types/__VUE/imagepreview/index.vue.d.ts +23 -25
- package/dist/types/__VUE/infiniteloading/index.vue.d.ts +6 -6
- package/dist/types/__VUE/input/index.vue.d.ts +2 -2
- package/dist/types/__VUE/menu/index.vue.d.ts +4 -4
- package/dist/types/__VUE/menuitem/index.vue.d.ts +1 -1
- package/dist/types/__VUE/numberkeyboard/index.vue.d.ts +2 -2
- package/dist/types/__VUE/oldpicker/index.vue.d.ts +3 -3
- package/dist/types/__VUE/picker/index.vue.d.ts +3 -3
- package/dist/types/__VUE/popover/index.vue.d.ts +6 -6
- package/dist/types/__VUE/popup/index.vue.d.ts +4 -4
- package/dist/types/__VUE/range/index.vue.d.ts +1 -1
- package/dist/types/__VUE/rate/index.vue.d.ts +2 -2
- package/dist/types/__VUE/searchbar/index.vue.d.ts +2 -2
- package/dist/types/__VUE/shortpassword/index.vue.d.ts +1 -1
- package/dist/types/__VUE/sku/index.vue.d.ts +3 -3
- package/dist/types/__VUE/swipe/index.vue.d.ts +2 -2
- package/dist/types/__VUE/switch/index.vue.d.ts +2 -2
- package/dist/types/__VUE/tabbar/index.vue.d.ts +2 -2
- package/dist/types/__VUE/textarea/index.vue.d.ts +2 -2
- package/dist/types/__VUE/toast/index.vue.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -2
|
@@ -1,39 +1,150 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.1.
|
|
2
|
+
* @nutui/nutui v3.1.23-beta.1 Mon Jun 27 2022 21:39:05 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import { inject
|
|
7
|
-
import { u as
|
|
8
|
-
import { c as
|
|
9
|
-
import { p as
|
|
10
|
-
import { G as
|
|
11
|
-
import { _ as
|
|
6
|
+
import { inject, getCurrentInstance, onUnmounted, computed, ref, resolveComponent, openBlock, createElementBlock, normalizeClass, normalizeStyle, createElementVNode, renderSlot, Fragment, createBlock, toDisplayString } from "vue";
|
|
7
|
+
import { u as useRouter } from "./index.js";
|
|
8
|
+
import { c as createComponent } from "./component.js";
|
|
9
|
+
import { p as pxCheck } from "./pxCheck.js";
|
|
10
|
+
import { G as GRID_KEY } from "./common.js";
|
|
11
|
+
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
12
12
|
import "../locale/lang";
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
function useInject(key) {
|
|
14
|
+
const parent = inject(key, null);
|
|
15
|
+
if (parent) {
|
|
16
|
+
const instance = getCurrentInstance();
|
|
17
|
+
const { add, remove, internalChildren } = parent;
|
|
18
|
+
add(instance);
|
|
19
|
+
onUnmounted(() => remove(instance));
|
|
20
|
+
const index2 = computed(() => internalChildren.indexOf(instance));
|
|
21
|
+
return {
|
|
22
|
+
parent,
|
|
23
|
+
index: index2
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
parent: null,
|
|
28
|
+
index: ref(-1)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const { create, componentName } = createComponent("grid-item");
|
|
32
|
+
const _sfc_main = create({
|
|
33
|
+
props: {
|
|
34
|
+
text: {
|
|
35
|
+
type: String
|
|
36
|
+
},
|
|
37
|
+
icon: {
|
|
38
|
+
type: String
|
|
39
|
+
},
|
|
40
|
+
iconSize: {
|
|
41
|
+
type: [Number, String]
|
|
42
|
+
},
|
|
43
|
+
iconColor: {
|
|
44
|
+
type: String
|
|
45
|
+
},
|
|
46
|
+
to: {
|
|
47
|
+
type: [String, Object]
|
|
48
|
+
},
|
|
49
|
+
url: {
|
|
50
|
+
type: String,
|
|
51
|
+
default: ""
|
|
52
|
+
},
|
|
53
|
+
replace: {
|
|
54
|
+
type: Boolean,
|
|
55
|
+
default: false
|
|
19
56
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
57
|
+
},
|
|
58
|
+
emits: ["click"],
|
|
59
|
+
setup(props, { emit }) {
|
|
60
|
+
const Parent = useInject(GRID_KEY);
|
|
61
|
+
if (!Parent.parent)
|
|
62
|
+
return;
|
|
63
|
+
const index2 = Parent.index;
|
|
64
|
+
const parent = Parent.parent.props;
|
|
65
|
+
const rootClass = computed(() => {
|
|
66
|
+
const prefixCls = componentName;
|
|
67
|
+
return {
|
|
68
|
+
[prefixCls]: true
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
const rootStyle = computed(() => {
|
|
72
|
+
const style = {
|
|
73
|
+
flexBasis: `${100 / +parent.columnNum}%`
|
|
74
|
+
};
|
|
75
|
+
if (parent.square) {
|
|
76
|
+
style.paddingTop = `${100 / +parent.columnNum}%`;
|
|
77
|
+
} else if (parent.gutter) {
|
|
78
|
+
style.paddingRight = pxCheck(parent.gutter);
|
|
79
|
+
if (index2.value >= parent.columnNum) {
|
|
80
|
+
style.marginTop = pxCheck(parent.gutter);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return style;
|
|
84
|
+
});
|
|
85
|
+
const contentClass = computed(() => {
|
|
86
|
+
const prefixCls = `${componentName}__content`;
|
|
87
|
+
return {
|
|
88
|
+
[`${prefixCls}`]: true,
|
|
89
|
+
[`${prefixCls}--border`]: parent.border,
|
|
90
|
+
[`${prefixCls}--surround`]: parent.border && parent.gutter,
|
|
91
|
+
[`${prefixCls}--center`]: parent.center,
|
|
92
|
+
[`${prefixCls}--square`]: parent.square,
|
|
93
|
+
[`${prefixCls}--reverse`]: parent.reverse,
|
|
94
|
+
[`${prefixCls}--${parent.direction}`]: !!parent.direction,
|
|
95
|
+
[`${prefixCls}--clickable`]: parent.clickable || props.to || props.url
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
const iconProps = computed(() => {
|
|
99
|
+
return {
|
|
100
|
+
name: props.icon,
|
|
101
|
+
size: props.iconSize || parent.iconSize,
|
|
102
|
+
color: props.iconColor || parent.iconColor
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
const router = useRouter();
|
|
106
|
+
const handleClick = (event) => {
|
|
107
|
+
emit("click", event);
|
|
108
|
+
if (props.to && router) {
|
|
109
|
+
router[props.replace ? "replace" : "push"](props.to);
|
|
110
|
+
} else if (props.url) {
|
|
111
|
+
props.replace ? location.replace(props.url) : location.href = props.url;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
return {
|
|
115
|
+
rootClass,
|
|
116
|
+
rootStyle,
|
|
117
|
+
contentClass,
|
|
118
|
+
iconProps,
|
|
119
|
+
handleClick
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
const _hoisted_1 = {
|
|
124
|
+
key: 3,
|
|
125
|
+
class: "nut-grid-item__text"
|
|
126
|
+
};
|
|
127
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
128
|
+
const _component_nut_icon = resolveComponent("nut-icon");
|
|
129
|
+
return openBlock(), createElementBlock("view", {
|
|
130
|
+
class: normalizeClass(_ctx.rootClass),
|
|
131
|
+
style: normalizeStyle(_ctx.rootStyle),
|
|
132
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClick && _ctx.handleClick(...args))
|
|
133
|
+
}, [
|
|
134
|
+
createElementVNode("view", {
|
|
135
|
+
class: normalizeClass(_ctx.contentClass)
|
|
136
|
+
}, [
|
|
137
|
+
_ctx.$slots.default ? renderSlot(_ctx.$slots, "default", { key: 0 }) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
138
|
+
_ctx.$slots.icon ? renderSlot(_ctx.$slots, "icon", { key: 0 }) : (openBlock(), createBlock(_component_nut_icon, {
|
|
139
|
+
key: 1,
|
|
140
|
+
name: _ctx.iconProps.name,
|
|
141
|
+
size: _ctx.iconProps.size,
|
|
142
|
+
color: _ctx.iconProps.color
|
|
143
|
+
}, null, 8, ["name", "size", "color"])),
|
|
144
|
+
_ctx.$slots.text ? renderSlot(_ctx.$slots, "text", { key: 2 }) : (openBlock(), createElementBlock("view", _hoisted_1, toDisplayString(_ctx.text), 1))
|
|
145
|
+
], 64))
|
|
146
|
+
], 2)
|
|
147
|
+
], 6);
|
|
148
|
+
}
|
|
149
|
+
var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
150
|
+
export { index as default };
|
|
@@ -1,20 +1,45 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.1.
|
|
2
|
+
* @nutui/nutui v3.1.23-beta.1 Mon Jun 27 2022 21:39:05 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import { h
|
|
7
|
-
import { c as
|
|
8
|
-
import { p as
|
|
6
|
+
import { h } from "vue";
|
|
7
|
+
import { c as createComponent } from "./component.js";
|
|
8
|
+
import { p as pxCheck } from "./pxCheck.js";
|
|
9
9
|
import "../locale/lang";
|
|
10
|
-
const { componentName
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
10
|
+
const { componentName, create } = createComponent("icon");
|
|
11
|
+
const _sfc_main = create({
|
|
12
|
+
props: {
|
|
13
|
+
name: { type: String, default: "" },
|
|
14
|
+
size: { type: [String, Number], default: "" },
|
|
15
|
+
classPrefix: { type: String, default: "nut-icon" },
|
|
16
|
+
fontClassName: { type: String, default: "nutui-iconfont" },
|
|
17
|
+
color: { type: String, default: "" },
|
|
18
|
+
tag: { type: String, default: "i" }
|
|
19
|
+
},
|
|
20
|
+
emits: ["click"],
|
|
21
|
+
setup(props, { emit, slots }) {
|
|
22
|
+
const handleClick = (event) => {
|
|
23
|
+
emit("click", event);
|
|
24
|
+
};
|
|
25
|
+
const isImage = () => {
|
|
26
|
+
return props.name ? props.name.indexOf("/") !== -1 : false;
|
|
27
|
+
};
|
|
28
|
+
return () => {
|
|
29
|
+
var _a;
|
|
30
|
+
const _isImage = isImage();
|
|
31
|
+
return h(_isImage ? "img" : props.tag, {
|
|
32
|
+
class: _isImage ? `${componentName}__img` : `${props.fontClassName} ${componentName} ${props.classPrefix}-${props.name}`,
|
|
33
|
+
style: {
|
|
34
|
+
color: props.color,
|
|
35
|
+
fontSize: pxCheck(props.size),
|
|
36
|
+
width: pxCheck(props.size),
|
|
37
|
+
height: pxCheck(props.size)
|
|
38
|
+
},
|
|
39
|
+
onClick: handleClick,
|
|
40
|
+
src: _isImage ? props.name : ""
|
|
41
|
+
}, (_a = slots.default) == null ? void 0 : _a.call(slots));
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
export { _sfc_main as default };
|
|
@@ -1,31 +1,142 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.1.
|
|
2
|
+
* @nutui/nutui v3.1.23-beta.1 Mon Jun 27 2022 21:39:05 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import { reactive
|
|
7
|
-
import { c as
|
|
8
|
-
import { p as
|
|
9
|
-
import { _ as
|
|
6
|
+
import { reactive, useSlots, computed, watch, toRefs, resolveComponent, openBlock, createElementBlock, normalizeClass, normalizeStyle, createElementVNode, createBlock, createCommentVNode, renderSlot } from "vue";
|
|
7
|
+
import { c as createComponent } from "./component.js";
|
|
8
|
+
import { p as pxCheck } from "./pxCheck.js";
|
|
9
|
+
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
10
10
|
import "../locale/lang";
|
|
11
|
-
const { componentName
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
11
|
+
const { componentName, create } = createComponent("image");
|
|
12
|
+
const _sfc_main = create({
|
|
13
|
+
props: {
|
|
14
|
+
src: String,
|
|
15
|
+
fit: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: "fill"
|
|
18
|
+
},
|
|
19
|
+
position: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: "center"
|
|
22
|
+
},
|
|
23
|
+
alt: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: ""
|
|
26
|
+
},
|
|
27
|
+
width: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: "center"
|
|
30
|
+
},
|
|
31
|
+
height: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: ""
|
|
34
|
+
},
|
|
35
|
+
round: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
default: false
|
|
38
|
+
},
|
|
39
|
+
radius: [String, Number],
|
|
40
|
+
showError: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: true
|
|
43
|
+
},
|
|
44
|
+
showLoading: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: true
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
emits: ["click", "load", "error"],
|
|
50
|
+
setup(props, { emit }) {
|
|
51
|
+
const state = reactive({
|
|
52
|
+
loading: true,
|
|
53
|
+
isError: false,
|
|
54
|
+
slotLoding: useSlots().loading,
|
|
55
|
+
slotError: useSlots().error
|
|
56
|
+
});
|
|
57
|
+
const classes = computed(() => {
|
|
58
|
+
const prefixCls = componentName;
|
|
59
|
+
return {
|
|
60
|
+
[prefixCls]: true,
|
|
61
|
+
[`${prefixCls}-round`]: props.round
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
const stylebox = computed(() => {
|
|
65
|
+
let style = {};
|
|
66
|
+
if (props.width)
|
|
67
|
+
style.width = pxCheck(props.width);
|
|
68
|
+
if (props.height)
|
|
69
|
+
style.height = pxCheck(props.height);
|
|
70
|
+
if (props.radius !== void 0 && props.radius !== null) {
|
|
71
|
+
style.overflow = "hidden";
|
|
72
|
+
style.borderRadius = pxCheck(props.radius);
|
|
73
|
+
}
|
|
74
|
+
return style;
|
|
75
|
+
});
|
|
76
|
+
const styles = computed(() => {
|
|
77
|
+
let styless = {
|
|
78
|
+
objectFit: props.fit,
|
|
79
|
+
objectPosition: props.position
|
|
80
|
+
};
|
|
81
|
+
return styless;
|
|
82
|
+
});
|
|
83
|
+
watch(() => props.src, (val) => {
|
|
84
|
+
state.isError = false, state.loading = true;
|
|
85
|
+
});
|
|
86
|
+
const load = () => {
|
|
87
|
+
state.loading = false;
|
|
88
|
+
emit("load");
|
|
89
|
+
};
|
|
90
|
+
const error = () => {
|
|
91
|
+
state.isError = true;
|
|
92
|
+
state.loading = false;
|
|
93
|
+
emit("error");
|
|
94
|
+
};
|
|
95
|
+
const imageClick = (event) => {
|
|
96
|
+
emit("click", event);
|
|
97
|
+
};
|
|
98
|
+
return { ...toRefs(state), imageClick, classes, styles, stylebox, error, load };
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
const _hoisted_1 = ["src", "alt"];
|
|
102
|
+
const _hoisted_2 = {
|
|
103
|
+
key: 0,
|
|
104
|
+
class: "nut-img-loading"
|
|
105
|
+
};
|
|
106
|
+
const _hoisted_3 = {
|
|
107
|
+
key: 1,
|
|
108
|
+
class: "nut-img-error"
|
|
109
|
+
};
|
|
110
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
111
|
+
const _component_nut_icon = resolveComponent("nut-icon");
|
|
112
|
+
return openBlock(), createElementBlock("view", {
|
|
113
|
+
class: normalizeClass(_ctx.classes),
|
|
114
|
+
style: normalizeStyle(_ctx.stylebox),
|
|
115
|
+
onClick: _cache[2] || (_cache[2] = (...args) => _ctx.imageClick && _ctx.imageClick(...args))
|
|
116
|
+
}, [
|
|
117
|
+
createElementVNode("img", {
|
|
118
|
+
class: "nut-img",
|
|
119
|
+
src: _ctx.src,
|
|
120
|
+
alt: _ctx.alt,
|
|
121
|
+
onLoad: _cache[0] || (_cache[0] = (...args) => _ctx.load && _ctx.load(...args)),
|
|
122
|
+
onError: _cache[1] || (_cache[1] = (...args) => _ctx.error && _ctx.error(...args)),
|
|
123
|
+
style: normalizeStyle(_ctx.styles)
|
|
124
|
+
}, null, 44, _hoisted_1),
|
|
125
|
+
_ctx.loading ? (openBlock(), createElementBlock("view", _hoisted_2, [
|
|
126
|
+
!_ctx.slotLoding ? (openBlock(), createBlock(_component_nut_icon, {
|
|
127
|
+
key: 0,
|
|
128
|
+
name: "image"
|
|
129
|
+
})) : createCommentVNode("", true),
|
|
130
|
+
renderSlot(_ctx.$slots, "loading")
|
|
131
|
+
])) : createCommentVNode("", true),
|
|
132
|
+
_ctx.isError && !_ctx.loading ? (openBlock(), createElementBlock("view", _hoisted_3, [
|
|
133
|
+
!_ctx.slotError ? (openBlock(), createBlock(_component_nut_icon, {
|
|
134
|
+
key: 0,
|
|
135
|
+
name: "image-error"
|
|
136
|
+
})) : createCommentVNode("", true),
|
|
137
|
+
renderSlot(_ctx.$slots, "error")
|
|
138
|
+
])) : createCommentVNode("", true)
|
|
139
|
+
], 6);
|
|
140
|
+
}
|
|
141
|
+
var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
142
|
+
export { index as default };
|