@nutui/nutui 3.1.6 → 3.1.7

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 (92) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/nutui.d.ts +7 -1
  3. package/dist/nutui.es.js +1097 -517
  4. package/dist/nutui.umd.js +1158 -571
  5. package/dist/packages/_es/ActionSheet.js +158 -0
  6. package/dist/packages/_es/Address.js +525 -0
  7. package/dist/packages/_es/Avatar.js +87 -0
  8. package/dist/packages/_es/BackTop.js +159 -0
  9. package/dist/packages/_es/Badge.js +90 -0
  10. package/dist/packages/_es/Barrage.js +118 -0
  11. package/dist/packages/_es/Button.js +124 -0
  12. package/dist/packages/_es/Calendar.js +700 -0
  13. package/dist/packages/_es/Cell.js +95 -0
  14. package/dist/packages/_es/CellGroup.js +42 -0
  15. package/dist/packages/_es/Checkbox.js +109 -0
  16. package/dist/packages/_es/CheckboxGroup.js +62 -0
  17. package/dist/packages/_es/CircleProgress.js +109 -0
  18. package/dist/packages/_es/Col.js +53 -0
  19. package/dist/packages/_es/Collapse.js +89 -0
  20. package/dist/packages/_es/CollapseItem.js +257 -0
  21. package/dist/packages/_es/CountDown.js +224 -0
  22. package/dist/packages/_es/CountUp.js +547 -0
  23. package/dist/packages/_es/DatePicker.js +282 -0
  24. package/dist/packages/_es/Dialog.js +313 -0
  25. package/dist/packages/_es/Divider.js +49 -0
  26. package/dist/packages/_es/Drag.js +198 -0
  27. package/dist/packages/_es/Elevator.js +207 -0
  28. package/dist/packages/_es/FixedNav.js +127 -0
  29. package/dist/packages/_es/Icon.js +44 -0
  30. package/dist/packages/_es/ImagePreview.js +109 -0
  31. package/dist/packages/_es/InfiniteLoading.js +265 -0
  32. package/dist/packages/_es/Input.js +183 -0
  33. package/dist/packages/_es/InputNumber.js +172 -0
  34. package/dist/packages/_es/Layout.js +10 -0
  35. package/dist/packages/_es/MenuItem.js +180 -0
  36. package/dist/packages/_es/Navbar.js +160 -0
  37. package/dist/packages/_es/NoticeBar.js +389 -0
  38. package/dist/packages/_es/Notify.js +233 -0
  39. package/dist/packages/_es/NumberKeyboard.js +248 -0
  40. package/dist/packages/_es/OverLay.js +118 -0
  41. package/dist/packages/_es/Pagination.js +163 -0
  42. package/dist/packages/_es/Picker.js +485 -0
  43. package/dist/packages/_es/Popover.js +157 -0
  44. package/dist/packages/_es/Popup.js +268 -0
  45. package/dist/packages/_es/Price.js +104 -0
  46. package/dist/packages/_es/Progress.js +131 -0
  47. package/dist/packages/_es/Radio.js +72 -0
  48. package/dist/packages/_es/RadioGroup.js +37 -0
  49. package/dist/packages/_es/Range.js +350 -0
  50. package/dist/packages/_es/Rate.js +129 -0
  51. package/dist/packages/_es/Row.js +61 -0
  52. package/dist/packages/_es/ShortPassword.js +221 -0
  53. package/dist/packages/_es/Signature.js +167 -0
  54. package/dist/packages/_es/Step.js +116 -0
  55. package/dist/packages/_es/Steps.js +52 -0
  56. package/dist/packages/_es/Swipe.js +193 -0
  57. package/dist/packages/_es/Swiper.js +429 -0
  58. package/dist/packages/_es/SwiperItem.js +60 -0
  59. package/dist/packages/_es/Switch.js +90 -0
  60. package/dist/packages/_es/Tab.js +179 -0
  61. package/dist/packages/_es/TabPane.js +42 -0
  62. package/dist/packages/_es/TabPanel.js +30 -0
  63. package/dist/packages/_es/Tabbar.js +73 -0
  64. package/dist/packages/_es/TabbarItem.js +142 -0
  65. package/dist/packages/_es/Tag.js +98 -0
  66. package/dist/packages/_es/TextArea.js +127 -0
  67. package/dist/packages/_es/Toast.js +317 -0
  68. package/dist/packages/_es/Uploader.js +400 -0
  69. package/dist/packages/_es/Video.js +405 -0
  70. package/dist/packages/_es/component.js +26 -0
  71. package/dist/packages/_es/index.js +64 -0
  72. package/dist/packages/_es/index2.js +13 -0
  73. package/dist/packages/_es/plugin-vue_export-helper.js +12 -0
  74. package/dist/packages/_es/pxCheck.js +9 -0
  75. package/dist/packages/_es/raf.js +19 -0
  76. package/dist/packages/avatar/index.scss +0 -1
  77. package/dist/packages/badge/index.scss +35 -0
  78. package/dist/packages/calendar/index.scss +13 -0
  79. package/dist/packages/imagepreview/index.scss +48 -0
  80. package/dist/packages/input/index.scss +14 -7
  81. package/dist/packages/pagination/index.scss +51 -0
  82. package/dist/packages/popover/index.scss +159 -0
  83. package/dist/packages/shortpassword/index.scss +19 -7
  84. package/dist/packages/tabpane/index.scss +1 -0
  85. package/dist/packages/tabs/index.scss +1 -0
  86. package/dist/packages/tag/index.scss +47 -0
  87. package/dist/packages/uploader/index.scss +0 -1
  88. package/dist/style.css +1 -1
  89. package/dist/style.es.js +2 -1
  90. package/dist/styles/themes/default.scss +35 -28
  91. package/dist/styles/variables.scss +55 -32
  92. package/package.json +7 -7
@@ -0,0 +1,265 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ /*!
21
+ * @nutui/nutui v3.1.7 Thu Sep 30 2021 20:17:02 GMT+0800 (中国标准时间)
22
+ * (c) 2021 @jdf2e.
23
+ * Released under the MIT License.
24
+ */
25
+ import { reactive, computed, onMounted, onUnmounted, ref, onActivated, onDeactivated, toRefs, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, createVNode, toDisplayString, renderSlot, createCommentVNode } from "vue";
26
+ import { c as createComponent } from "./component.js";
27
+ import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
28
+ const { componentName, create } = createComponent("infiniteloading");
29
+ const _sfc_main = create({
30
+ props: {
31
+ hasMore: {
32
+ type: Boolean,
33
+ default: true
34
+ },
35
+ threshold: {
36
+ type: Number,
37
+ default: 200
38
+ },
39
+ pullIcon: {
40
+ type: String,
41
+ default: "https://img10.360buyimg.com/imagetools/jfs/t1/169863/6/4565/6306/60125948E7e92774e/40b3a0cf42852bcb.png"
42
+ },
43
+ pullTxt: {
44
+ type: String,
45
+ default: "\u677E\u5F00\u5237\u65B0"
46
+ },
47
+ loadIcon: {
48
+ type: String,
49
+ default: "https://img10.360buyimg.com/imagetools/jfs/t1/169863/6/4565/6306/60125948E7e92774e/40b3a0cf42852bcb.png"
50
+ },
51
+ loadTxt: {
52
+ type: String,
53
+ default: "\u52A0\u8F7D\u4E2D\xB7\xB7\xB7"
54
+ },
55
+ loadMoreTxt: {
56
+ type: String,
57
+ default: "\u54CE\u5440\uFF0C\u8FD9\u91CC\u662F\u5E95\u90E8\u4E86\u5566"
58
+ },
59
+ useWindow: {
60
+ type: Boolean,
61
+ default: true
62
+ },
63
+ containerId: {
64
+ type: String,
65
+ default: ""
66
+ },
67
+ useCapture: {
68
+ type: Boolean,
69
+ default: false
70
+ },
71
+ isOpenRefresh: {
72
+ type: Boolean,
73
+ default: false
74
+ }
75
+ },
76
+ emits: ["scroll-change", "load-more", "refresh"],
77
+ setup(props, { emit, slots }) {
78
+ const state = reactive({
79
+ scrollEl: window,
80
+ scroller: null,
81
+ refreshTop: null,
82
+ beforeScrollTop: 0,
83
+ isTouching: false,
84
+ isInfiniting: false,
85
+ refreshMaxH: 0,
86
+ y: 0,
87
+ x: 0,
88
+ distance: 0
89
+ });
90
+ const classes = computed(() => {
91
+ const prefixCls = componentName;
92
+ return {
93
+ [prefixCls]: true
94
+ };
95
+ });
96
+ const getStyle = computed(() => {
97
+ return {
98
+ height: state.distance < 0 ? `0px` : `${state.distance}px`,
99
+ transition: state.isTouching ? `height 0s cubic-bezier(0.25,0.1,0.25,1)` : `height 0.2s cubic-bezier(0.25,0.1,0.25,1)`
100
+ };
101
+ });
102
+ const getParentElement = (el) => {
103
+ return !!props.containerId ? document.querySelector(`#${props.containerId}`) : el && el.parentNode;
104
+ };
105
+ const requestAniFrame = () => {
106
+ return window.requestAnimationFrame || window.webkitRequestAnimationFrame || function(callback) {
107
+ window.setTimeout(callback, 1e3 / 60);
108
+ };
109
+ };
110
+ const getWindowScrollTop = () => {
111
+ return window.pageYOffset !== void 0 ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
112
+ };
113
+ const calculateTopPosition = (el) => {
114
+ return !el ? 0 : el.offsetTop + calculateTopPosition(el.offsetParent);
115
+ };
116
+ const isScrollAtBottom = () => {
117
+ let offsetDistance = 0;
118
+ let resScrollTop = 0;
119
+ let direction = "down";
120
+ const windowScrollTop = getWindowScrollTop();
121
+ if (props.useWindow) {
122
+ if (state.scroller) {
123
+ offsetDistance = calculateTopPosition(state.scroller) + state.scroller.offsetHeight - windowScrollTop - window.innerHeight;
124
+ }
125
+ resScrollTop = windowScrollTop;
126
+ } else {
127
+ const { scrollHeight, clientHeight, scrollTop } = state.scrollEl;
128
+ offsetDistance = scrollHeight - clientHeight - scrollTop;
129
+ resScrollTop = scrollTop;
130
+ }
131
+ if (state.beforeScrollTop > resScrollTop) {
132
+ direction = "up";
133
+ } else {
134
+ direction = "down";
135
+ }
136
+ state.beforeScrollTop = resScrollTop;
137
+ emit("scroll-change", resScrollTop);
138
+ return offsetDistance <= props.threshold && direction == "down";
139
+ };
140
+ const infiniteDone = () => {
141
+ state.isInfiniting = false;
142
+ };
143
+ const handleScroll = () => {
144
+ requestAniFrame()(() => {
145
+ if (!isScrollAtBottom() || !props.hasMore || state.isInfiniting) {
146
+ return false;
147
+ } else {
148
+ state.isInfiniting = true;
149
+ emit("load-more", infiniteDone);
150
+ }
151
+ });
152
+ };
153
+ const scrollListener = () => {
154
+ state.scrollEl.addEventListener("scroll", handleScroll, props.useCapture);
155
+ };
156
+ const refreshDone = () => {
157
+ state.distance = 0;
158
+ state.isTouching = false;
159
+ };
160
+ const touchStart = (event) => {
161
+ if (state.beforeScrollTop == 0 && !state.isTouching && props.isOpenRefresh) {
162
+ state.y = event.touches[0].pageY;
163
+ state.isTouching = true;
164
+ const childHeight = state.refreshTop.firstElementChild.offsetHeight;
165
+ state.refreshMaxH = Math.floor(childHeight * 1 + 10);
166
+ }
167
+ };
168
+ const touchMove = (event) => {
169
+ state.distance = event.touches[0].pageY - state.y;
170
+ if (state.distance > 0 && state.isTouching) {
171
+ event.preventDefault();
172
+ if (state.distance >= state.refreshMaxH)
173
+ state.distance = state.refreshMaxH;
174
+ } else {
175
+ state.distance = 0;
176
+ state.isTouching = false;
177
+ }
178
+ };
179
+ const touchEnd = () => {
180
+ if (state.distance < state.refreshMaxH) {
181
+ state.distance = 0;
182
+ } else {
183
+ emit("refresh", refreshDone);
184
+ }
185
+ };
186
+ onMounted(() => {
187
+ const parentElement = getParentElement(state.scroller);
188
+ state.scrollEl = props.useWindow ? window : parentElement;
189
+ scrollListener();
190
+ });
191
+ onUnmounted(() => {
192
+ state.scrollEl.removeEventListener("scroll", handleScroll, props.useCapture);
193
+ });
194
+ const isKeepAlive = ref(false);
195
+ onActivated(() => {
196
+ if (isKeepAlive.value) {
197
+ isKeepAlive.value = false;
198
+ scrollListener();
199
+ }
200
+ });
201
+ onDeactivated(() => {
202
+ isKeepAlive.value = true;
203
+ state.scrollEl.removeEventListener("scroll", handleScroll, props.useCapture);
204
+ });
205
+ return __spreadProps(__spreadValues({
206
+ classes
207
+ }, toRefs(state)), {
208
+ touchStart,
209
+ touchMove,
210
+ touchEnd,
211
+ getStyle
212
+ });
213
+ }
214
+ });
215
+ const _hoisted_1 = { class: "top-box" };
216
+ const _hoisted_2 = { class: "top-text" };
217
+ const _hoisted_3 = { class: "nut-infinite-container" };
218
+ const _hoisted_4 = { class: "nut-infinite-bottom" };
219
+ const _hoisted_5 = {
220
+ key: 0,
221
+ class: "bottom-box"
222
+ };
223
+ const _hoisted_6 = { class: "bottom-text" };
224
+ const _hoisted_7 = {
225
+ key: 1,
226
+ class: "tips"
227
+ };
228
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
229
+ const _component_nut_icon = resolveComponent("nut-icon");
230
+ return openBlock(), createElementBlock("view", {
231
+ class: normalizeClass(_ctx.classes),
232
+ ref: "scroller",
233
+ onTouchstart: _cache[0] || (_cache[0] = (...args) => _ctx.touchStart && _ctx.touchStart(...args)),
234
+ onTouchmove: _cache[1] || (_cache[1] = (...args) => _ctx.touchMove && _ctx.touchMove(...args)),
235
+ onTouchend: _cache[2] || (_cache[2] = (...args) => _ctx.touchEnd && _ctx.touchEnd(...args))
236
+ }, [
237
+ createElementVNode("view", {
238
+ class: "nut-infinite-top",
239
+ ref: "refreshTop",
240
+ style: normalizeStyle(_ctx.getStyle)
241
+ }, [
242
+ createElementVNode("view", _hoisted_1, [
243
+ createVNode(_component_nut_icon, {
244
+ class: "top-img",
245
+ name: _ctx.pullIcon
246
+ }, null, 8, ["name"]),
247
+ createElementVNode("view", _hoisted_2, toDisplayString(_ctx.pullTxt), 1)
248
+ ])
249
+ ], 4),
250
+ createElementVNode("view", _hoisted_3, [
251
+ renderSlot(_ctx.$slots, "default")
252
+ ]),
253
+ createElementVNode("view", _hoisted_4, [
254
+ _ctx.isInfiniting ? (openBlock(), createElementBlock("view", _hoisted_5, [
255
+ createVNode(_component_nut_icon, {
256
+ class: "bottom-img",
257
+ name: _ctx.loadIcon
258
+ }, null, 8, ["name"]),
259
+ createElementVNode("view", _hoisted_6, toDisplayString(_ctx.loadTxt), 1)
260
+ ])) : !_ctx.hasMore ? (openBlock(), createElementBlock("view", _hoisted_7, toDisplayString(_ctx.loadMoreTxt), 1)) : createCommentVNode("", true)
261
+ ])
262
+ ], 34);
263
+ }
264
+ var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
265
+ export { index as default };
@@ -0,0 +1,183 @@
1
+ /*!
2
+ * @nutui/nutui v3.1.7 Thu Sep 30 2021 20:17:02 GMT+0800 (中国标准时间)
3
+ * (c) 2021 @jdf2e.
4
+ * Released under the MIT License.
5
+ */
6
+ import { ref, computed, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, toDisplayString, createCommentVNode, normalizeStyle, withDirectives, createVNode, vShow } from "vue";
7
+ import { c as createComponent } from "./component.js";
8
+ import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
9
+ function trimExtraChar(value, char, regExp) {
10
+ const index2 = value.indexOf(char);
11
+ if (index2 === -1) {
12
+ return value;
13
+ }
14
+ if (char === "-" && index2 !== 0) {
15
+ return value.slice(0, index2);
16
+ }
17
+ return value.slice(0, index2 + 1) + value.slice(index2).replace(regExp, "");
18
+ }
19
+ function formatNumber(value, allowDot = true, allowMinus = true) {
20
+ if (allowDot) {
21
+ value = trimExtraChar(value, ".", /\./g);
22
+ } else {
23
+ value = value.replace(/\./g, "");
24
+ }
25
+ if (allowMinus) {
26
+ value = trimExtraChar(value, "-", /-/g);
27
+ } else {
28
+ value = value.replace(/-/, "");
29
+ }
30
+ const regExp = allowDot ? /[^-0-9.]/g : /[^-0-9]/g;
31
+ return value.replace(regExp, "");
32
+ }
33
+ const { componentName, create } = createComponent("input");
34
+ const _sfc_main = create({
35
+ props: {
36
+ type: {
37
+ type: String,
38
+ default: "text"
39
+ },
40
+ modelValue: {
41
+ type: [String, Number],
42
+ default: ""
43
+ },
44
+ placeholder: {
45
+ type: String,
46
+ default: "\u8BF7\u8F93\u5165\u4FE1\u606F"
47
+ },
48
+ label: {
49
+ type: String,
50
+ default: ""
51
+ },
52
+ requireShow: {
53
+ type: Boolean,
54
+ default: false
55
+ },
56
+ disabled: {
57
+ type: Boolean,
58
+ default: false
59
+ },
60
+ readonly: {
61
+ type: Boolean,
62
+ default: false
63
+ },
64
+ textAlign: {
65
+ type: String,
66
+ default: "left"
67
+ },
68
+ maxLength: {
69
+ type: [String, Number],
70
+ default: ""
71
+ },
72
+ clearable: {
73
+ type: Boolean,
74
+ default: true
75
+ }
76
+ },
77
+ emits: ["change", "update:modelValue", "blur", "focus", "clear"],
78
+ setup(props, { emit }) {
79
+ const active = ref(false);
80
+ const classes = computed(() => {
81
+ const prefixCls = componentName;
82
+ return {
83
+ [prefixCls]: true,
84
+ [`${prefixCls}-disabled`]: props.disabled,
85
+ [`${prefixCls}-require`]: props.requireShow
86
+ };
87
+ });
88
+ const styles = computed(() => {
89
+ return {
90
+ textAlign: props.textAlign
91
+ };
92
+ });
93
+ const valueChange = (event) => {
94
+ const input = event.target;
95
+ let val = input.value;
96
+ if (props.type === "digit") {
97
+ val = formatNumber(val, true);
98
+ }
99
+ if (props.type === "number") {
100
+ val = formatNumber(val, false);
101
+ }
102
+ if (props.maxLength && val.length > Number(props.maxLength)) {
103
+ val = val.slice(0, Number(props.maxLength));
104
+ }
105
+ emit("update:modelValue", val, event);
106
+ emit("change", val, event);
107
+ };
108
+ const valueFocus = (event) => {
109
+ const input = event.target;
110
+ let value = input.value;
111
+ active.value = true;
112
+ emit("focus", value, event);
113
+ };
114
+ const valueBlur = (event) => {
115
+ setTimeout(() => {
116
+ active.value = false;
117
+ }, 0);
118
+ const input = event.target;
119
+ let value = input.value;
120
+ if (props.maxLength && value.length > Number(props.maxLength)) {
121
+ value = value.slice(0, Number(props.maxLength));
122
+ }
123
+ emit("blur", value, event);
124
+ };
125
+ const handleClear = (event) => {
126
+ emit("update:modelValue", "", event);
127
+ emit("change", "", event);
128
+ emit("clear", "");
129
+ };
130
+ return {
131
+ active,
132
+ classes,
133
+ styles,
134
+ valueChange,
135
+ valueFocus,
136
+ valueBlur,
137
+ handleClear
138
+ };
139
+ }
140
+ });
141
+ const _hoisted_1 = { class: "nut-input-label" };
142
+ const _hoisted_2 = {
143
+ key: 0,
144
+ class: "label-string"
145
+ };
146
+ const _hoisted_3 = ["type", "maxlength", "placeholder", "disabled", "readonly", "value"];
147
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
148
+ const _component_nut_icon = resolveComponent("nut-icon");
149
+ return openBlock(), createElementBlock("view", {
150
+ class: normalizeClass(_ctx.classes)
151
+ }, [
152
+ createElementVNode("view", _hoisted_1, [
153
+ _ctx.label ? (openBlock(), createElementBlock("view", _hoisted_2, toDisplayString(_ctx.label), 1)) : createCommentVNode("", true)
154
+ ]),
155
+ createElementVNode("input", {
156
+ class: "input-text",
157
+ style: normalizeStyle(_ctx.styles),
158
+ type: _ctx.type,
159
+ maxlength: _ctx.maxLength,
160
+ placeholder: _ctx.placeholder,
161
+ disabled: _ctx.disabled,
162
+ readonly: _ctx.readonly,
163
+ value: _ctx.modelValue,
164
+ onInput: _cache[0] || (_cache[0] = (...args) => _ctx.valueChange && _ctx.valueChange(...args)),
165
+ onFocus: _cache[1] || (_cache[1] = (...args) => _ctx.valueFocus && _ctx.valueFocus(...args)),
166
+ onBlur: _cache[2] || (_cache[2] = (...args) => _ctx.valueBlur && _ctx.valueBlur(...args))
167
+ }, null, 44, _hoisted_3),
168
+ _ctx.clearable && !_ctx.readonly ? withDirectives((openBlock(), createElementBlock("view", {
169
+ key: 0,
170
+ onClick: _cache[3] || (_cache[3] = (...args) => _ctx.handleClear && _ctx.handleClear(...args)),
171
+ class: "nut-textinput-clear"
172
+ }, [
173
+ createVNode(_component_nut_icon, {
174
+ name: "close-little",
175
+ size: "12px"
176
+ })
177
+ ], 512)), [
178
+ [vShow, _ctx.active && _ctx.modelValue.length > 0]
179
+ ]) : createCommentVNode("", true)
180
+ ], 2);
181
+ }
182
+ var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
183
+ export { index as default };
@@ -0,0 +1,172 @@
1
+ /*!
2
+ * @nutui/nutui v3.1.7 Thu Sep 30 2021 20:17:02 GMT+0800 (中国标准时间)
3
+ * (c) 2021 @jdf2e.
4
+ * Released under the MIT License.
5
+ */
6
+ import { computed, resolveComponent, openBlock, createElementBlock, normalizeClass, normalizeStyle, createVNode, createElementVNode } 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
+ const { componentName, create } = createComponent("inputnumber");
11
+ const _sfc_main = create({
12
+ props: {
13
+ modelValue: {
14
+ type: [Number, String],
15
+ default: 0
16
+ },
17
+ inputWidth: {
18
+ type: [Number, String],
19
+ default: ""
20
+ },
21
+ buttonSize: {
22
+ type: [Number, String],
23
+ default: ""
24
+ },
25
+ min: {
26
+ type: [Number, String],
27
+ default: 1
28
+ },
29
+ max: {
30
+ type: [Number, String],
31
+ default: 9999
32
+ },
33
+ step: {
34
+ type: [Number, String],
35
+ default: 1
36
+ },
37
+ decimalPlaces: {
38
+ type: [Number, String],
39
+ default: 0
40
+ },
41
+ disabled: {
42
+ type: Boolean,
43
+ default: false
44
+ },
45
+ readonly: {
46
+ type: Boolean,
47
+ default: false
48
+ }
49
+ },
50
+ emits: [
51
+ "update:modelValue",
52
+ "change",
53
+ "blur",
54
+ "focus",
55
+ "reduce",
56
+ "add",
57
+ "overlimit"
58
+ ],
59
+ setup(props, { emit }) {
60
+ const classes = computed(() => {
61
+ const prefixCls = componentName;
62
+ return {
63
+ [prefixCls]: true,
64
+ [`${prefixCls}--disabled`]: props.disabled
65
+ };
66
+ });
67
+ const fixedDecimalPlaces = (v) => {
68
+ return Number(v).toFixed(Number(props.decimalPlaces));
69
+ };
70
+ const change = (event) => {
71
+ const input = event.target;
72
+ emit("update:modelValue", input.valueAsNumber, event);
73
+ };
74
+ const emitChange = (value, event) => {
75
+ let output_value = fixedDecimalPlaces(value);
76
+ emit("change", output_value, event);
77
+ emit("update:modelValue", output_value, event);
78
+ };
79
+ const addAllow = (value = Number(props.modelValue)) => {
80
+ return value < Number(props.max) && !props.disabled;
81
+ };
82
+ const reduceAllow = (value = Number(props.modelValue)) => {
83
+ return value > Number(props.min) && !props.disabled;
84
+ };
85
+ const reduce = (event) => {
86
+ emit("reduce", event);
87
+ if (reduceAllow()) {
88
+ let output_value = Number(props.modelValue) - Number(props.step);
89
+ emitChange(output_value, event);
90
+ } else {
91
+ emit("overlimit", event);
92
+ }
93
+ };
94
+ const add = (event) => {
95
+ emit("add", event);
96
+ if (addAllow()) {
97
+ let output_value = Number(props.modelValue) + Number(props.step);
98
+ emitChange(output_value, event);
99
+ } else {
100
+ emit("overlimit", event);
101
+ }
102
+ };
103
+ const focus = (event) => {
104
+ if (props.disabled)
105
+ return;
106
+ if (props.readonly)
107
+ return;
108
+ emit("focus", event);
109
+ };
110
+ const blur = (event) => {
111
+ if (props.disabled)
112
+ return;
113
+ if (props.readonly)
114
+ return;
115
+ const input = event.target;
116
+ let value = input.valueAsNumber;
117
+ if (value < Number(props.min)) {
118
+ value = Number(props.min);
119
+ } else if (value > Number(props.max)) {
120
+ value = Number(props.max);
121
+ }
122
+ emitChange(value, event);
123
+ emit("blur", event);
124
+ };
125
+ return {
126
+ classes,
127
+ change,
128
+ blur,
129
+ focus,
130
+ add,
131
+ addAllow,
132
+ reduce,
133
+ reduceAllow,
134
+ pxCheck
135
+ };
136
+ }
137
+ });
138
+ const _hoisted_1 = ["min", "max", "disabled", "readonly", "value"];
139
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
140
+ const _component_nut_icon = resolveComponent("nut-icon");
141
+ return openBlock(), createElementBlock("view", {
142
+ class: normalizeClass(_ctx.classes),
143
+ style: normalizeStyle({ height: _ctx.pxCheck(_ctx.buttonSize) })
144
+ }, [
145
+ createVNode(_component_nut_icon, {
146
+ name: "minus",
147
+ class: normalizeClass(["nut-inputnumber__icon", { "nut-inputnumber__icon--disabled": !_ctx.reduceAllow() }]),
148
+ size: _ctx.buttonSize,
149
+ onClick: _ctx.reduce
150
+ }, null, 8, ["class", "size", "onClick"]),
151
+ createElementVNode("input", {
152
+ type: "number",
153
+ min: _ctx.min,
154
+ max: _ctx.max,
155
+ style: normalizeStyle({ width: _ctx.pxCheck(_ctx.inputWidth) }),
156
+ disabled: _ctx.disabled,
157
+ readonly: _ctx.readonly,
158
+ value: _ctx.modelValue,
159
+ onInput: _cache[0] || (_cache[0] = (...args) => _ctx.change && _ctx.change(...args)),
160
+ onBlur: _cache[1] || (_cache[1] = (...args) => _ctx.blur && _ctx.blur(...args)),
161
+ onFocus: _cache[2] || (_cache[2] = (...args) => _ctx.focus && _ctx.focus(...args))
162
+ }, null, 44, _hoisted_1),
163
+ createVNode(_component_nut_icon, {
164
+ name: "plus",
165
+ class: normalizeClass(["nut-inputnumber__icon", { "nut-inputnumber__icon--disabled": !_ctx.addAllow() }]),
166
+ size: _ctx.buttonSize,
167
+ onClick: _ctx.add
168
+ }, null, 8, ["class", "size", "onClick"])
169
+ ], 6);
170
+ }
171
+ var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
172
+ export { index as default };
@@ -0,0 +1,10 @@
1
+ /*!
2
+ * @nutui/nutui v3.1.7 Thu Sep 30 2021 20:17:02 GMT+0800 (中国标准时间)
3
+ * (c) 2021 @jdf2e.
4
+ * Released under the MIT License.
5
+ */
6
+ import { c as createComponent } from "./component.js";
7
+ import "vue";
8
+ const { create } = createComponent("layout");
9
+ const _sfc_main = create({});
10
+ export { _sfc_main as default };