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