@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,58 +1,440 @@
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 { ref as e, reactive as t, computed as l, watch as n, onMounted as a, resolveComponent as r, openBlock as o, createElementBlock as u, normalizeClass as i, createVNode as c, createCommentVNode as s, normalizeStyle as d, createElementVNode as g, toDisplayString as p, withDirectives as f, createBlock as m, vShow as y, renderSlot as h, createTextVNode as b } from "vue";
7
- import { c as v } from "./component.js";
8
- import { _ as x } from "./plugin-vue_export-helper.js";
6
+ import { ref, reactive, computed, watch, onMounted, resolveComponent, openBlock, createElementBlock, normalizeClass, Fragment, normalizeStyle, createElementVNode, toDisplayString, createCommentVNode, renderSlot, createVNode, withDirectives, createBlock, vShow, createTextVNode } from "vue";
7
+ import { c as createComponent } from "./component.js";
8
+ import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
9
9
  import "../locale/lang";
10
- function k(e2, t2, l2) {
11
- const n2 = e2.indexOf(t2);
12
- return n2 === -1 ? e2 : t2 === "-" && n2 !== 0 ? e2.slice(0, n2) : e2.slice(0, n2 + 1) + e2.slice(n2).replace(l2, "");
10
+ function trimExtraChar(value, char, regExp) {
11
+ const index2 = value.indexOf(char);
12
+ if (index2 === -1) {
13
+ return value;
14
+ }
15
+ if (char === "-" && index2 !== 0) {
16
+ return value.slice(0, index2);
17
+ }
18
+ return value.slice(0, index2 + 1) + value.slice(index2).replace(regExp, "");
13
19
  }
14
- function I(e2, t2 = true, l2 = true) {
15
- e2 = t2 ? k(e2, ".", /\./g) : e2.split(".")[0];
16
- const n2 = t2 ? /[^-0-9.]/g : /[^-0-9]/g;
17
- return (e2 = l2 ? k(e2, "-", /-/g) : e2.replace(/-/, "")).replace(n2, "");
20
+ function formatNumber(value, allowDot = true, allowMinus = true) {
21
+ if (allowDot) {
22
+ value = trimExtraChar(value, ".", /\./g);
23
+ } else {
24
+ value = value.split(".")[0];
25
+ }
26
+ if (allowMinus) {
27
+ value = trimExtraChar(value, "-", /-/g);
28
+ } else {
29
+ value = value.replace(/-/, "");
30
+ }
31
+ const regExp = allowDot ? /[^-0-9.]/g : /[^-0-9]/g;
32
+ return value.replace(regExp, "");
18
33
  }
19
- const { componentName: S, create: B, translate: C } = v("input"), w = B({ props: { ref: { type: String, default: "" }, type: { type: String, default: "text" }, modelValue: { type: [String, Number], default: "" }, placeholder: { type: String, default: "" }, label: { type: String, default: "" }, labelClass: { type: String, default: "" }, labelWidth: { type: [String, Number], default: "80" }, labelAlign: { type: String, default: "left" }, colon: { type: Boolean, default: false }, inputAlign: { type: String, default: "left" }, center: { type: Boolean, default: false }, required: { type: Boolean, default: false }, disabled: { type: Boolean, default: false }, readonly: { type: Boolean, default: false }, error: { type: Boolean, default: false }, maxLength: { type: [String, Number], default: "" }, leftIcon: { type: String, default: "" }, leftIconSize: { type: [String, Number], default: "" }, rightIcon: { type: String, default: "" }, rightIconSize: { type: [String, Number], default: "" }, clearable: { type: Boolean, default: false }, clearIcon: { type: String, default: "mask-close" }, clearSize: { type: [String, Number], default: "14" }, border: { type: Boolean, default: true }, formatTrigger: { type: String, default: "onChange" }, formatter: { type: Function, default: null }, rules: { type: Array, default: [] }, errorMessage: { type: String, default: "" }, errorMessageAlign: { type: String, default: "" }, rows: { type: [String, Number], default: null }, showWordLimit: { type: Boolean, default: false }, autofocus: { type: Boolean, default: false } }, emits: ["update:modelValue", "change", "blur", "focus", "clear", "keypress", "click-input", "click-left-icon", "click-right-icon"], setup(r2, { emit: o2, slots: u2 }) {
20
- const i2 = e(false), c2 = e(), s2 = e(), d2 = () => {
21
- var _a;
22
- return String((_a = r2.modelValue) != null ? _a : "");
23
- }, g2 = t({ focused: false, validateFailed: false, validateMessage: "" }), p2 = l(() => {
24
- const e2 = S;
25
- return { [e2]: true, center: r2.center, [`${e2}-disabled`]: r2.disabled, [`${e2}-required`]: r2.required, [`${e2}-error`]: r2.error, [`${e2}-border`]: r2.border };
26
- }), f2 = l(() => ({ textAlign: r2.inputAlign })), m2 = l(() => ({ textAlign: r2.inputAlign, height: 24 * Number(r2.rows) + "px" }));
27
- l(() => s2.value && u2.input ? s2.value() : r2.modelValue);
28
- const y2 = (e2, t2 = "onChange") => {
29
- var _a;
30
- r2.type === "digit" && (e2 = I(e2, false, false)), r2.type === "number" && (e2 = I(e2, true, true)), r2.formatter && t2 === r2.formatTrigger && (e2 = r2.formatter(e2)), ((_a = c2 == null ? void 0 : c2.value) == null ? void 0 : _a.value) !== e2 && (c2.value.value = e2), e2 !== r2.modelValue && (o2("update:modelValue", e2), o2("change", e2));
31
- };
32
- return n(() => r2.modelValue, () => {
33
- y2(d2()), g2.validateFailed && (g2.validateFailed = false, g2.validateMessage = "");
34
- }), a(() => {
35
- y2(d2(), r2.formatTrigger);
36
- }), { inputRef: c2, active: i2, classes: p2, styles: f2, stylesTextarea: m2, inputType: (e2) => e2 === "number" ? "text" : e2 === "digit" ? "tel" : e2, onInput: (e2) => {
37
- let t2 = e2.target.value;
38
- r2.maxLength && t2.length > Number(r2.maxLength) && (t2 = t2.slice(0, Number(r2.maxLength))), y2(t2);
39
- }, onFocus: (e2) => {
40
- let t2 = e2.target.value;
41
- i2.value = true, o2("focus", t2, e2);
42
- }, onBlur: (e2) => {
43
- setTimeout(() => {
44
- i2.value = false;
45
- }, 200);
46
- let t2 = e2.target.value;
47
- r2.maxLength && t2.length > Number(r2.maxLength) && (t2 = t2.slice(0, Number(r2.maxLength))), y2(d2(), "onBlur"), o2("blur", t2, e2);
48
- }, clear: (e2) => {
49
- o2("update:modelValue", "", e2), o2("change", "", e2), o2("clear", "", e2);
50
- }, onClickInput: (e2) => {
51
- o2("click-input", e2);
52
- }, onClickLeftIcon: (e2) => o2("click-left-icon", e2), onClickRightIcon: (e2) => o2("click-right-icon", e2), translate: C };
53
- } }), L = { class: "label-string" }, T = { class: "nut-input-value" }, N = ["maxlength", "placeholder", "disabled", "readonly", "value", "formatTrigger", "autofocus"], V = ["type", "maxlength", "placeholder", "disabled", "readonly", "value", "formatTrigger", "autofocus"], z = { key: 0, class: "nut-input-word-limit" }, A = { class: "nut-input-word-num" };
54
- var F = x(w, [["render", function(e2, t2, l2, n2, a2, v2) {
55
- const x2 = r("nut-icon");
56
- return o(), u("view", { class: i(e2.classes) }, [e2.leftIcon && e2.leftIcon.length > 0 ? (o(), u("view", { key: 0, class: "nut-input-left-icon", onClick: t2[0] || (t2[0] = (...t3) => e2.onClickLeftIcon && e2.onClickLeftIcon(...t3)) }, [c(x2, { name: e2.leftIcon, size: e2.leftIconSize }, null, 8, ["name", "size"])])) : s("", true), e2.label ? (o(), u("view", { key: 1, class: i(["nut-input-label", e2.labelClass]), style: d({ width: `${e2.labelWidth}px`, textAlign: e2.labelAlign }) }, [g("view", L, p(e2.label) + " " + p(e2.colon ? ":" : ""), 1)], 6)) : s("", true), g("view", T, [g("view", { class: "nut-input-inner", onClick: t2[8] || (t2[8] = (...t3) => e2.onClickInput && e2.onClickInput(...t3)) }, [e2.type == "textarea" ? (o(), u("textarea", { key: 0, class: "input-text", ref: "inputRef", style: d(e2.stylesTextarea), maxlength: e2.maxLength, placeholder: e2.placeholder || e2.translate("placeholder"), disabled: e2.disabled, readonly: e2.readonly, value: e2.modelValue, formatTrigger: e2.formatTrigger, autofocus: e2.autofocus, onInput: t2[1] || (t2[1] = (...t3) => e2.onInput && e2.onInput(...t3)), onFocus: t2[2] || (t2[2] = (...t3) => e2.onFocus && e2.onFocus(...t3)), onBlur: t2[3] || (t2[3] = (...t3) => e2.onBlur && e2.onBlur(...t3)) }, null, 44, N)) : (o(), u("input", { key: 1, class: "input-text", ref: "inputRef", style: d(e2.styles), type: e2.inputType(e2.type), maxlength: e2.maxLength, placeholder: e2.placeholder || e2.translate("placeholder"), disabled: e2.disabled, readonly: e2.readonly, value: e2.modelValue, formatTrigger: e2.formatTrigger, autofocus: e2.autofocus, onInput: t2[4] || (t2[4] = (...t3) => e2.onInput && e2.onInput(...t3)), onFocus: t2[5] || (t2[5] = (...t3) => e2.onFocus && e2.onFocus(...t3)), onBlur: t2[6] || (t2[6] = (...t3) => e2.onBlur && e2.onBlur(...t3)) }, null, 44, V)), e2.clearable && !e2.readonly ? f((o(), m(x2, { key: 2, class: "nut-input-clear", name: e2.clearIcon, size: e2.clearSize, onClick: e2.clear }, null, 8, ["name", "size", "onClick"])), [[y, e2.active && e2.modelValue.length > 0]]) : s("", true), e2.rightIcon && e2.rightIcon.length > 0 ? (o(), u("view", { key: 3, class: "nut-input-right-icon", onClick: t2[7] || (t2[7] = (...t3) => e2.onClickRightIcon && e2.onClickRightIcon(...t3)) }, [c(x2, { name: e2.rightIcon, size: e2.rightIconSize }, null, 8, ["name", "size"])])) : s("", true), e2.$slots.button ? h(e2.$slots, "button", { key: 4, class: "nut-input-button" }) : s("", true)]), e2.showWordLimit && e2.maxLength ? (o(), u("view", z, [g("span", A, p(e2.modelValue ? e2.modelValue.length : 0), 1), b("/" + p(e2.maxLength), 1)])) : s("", true), e2.errorMessage ? (o(), u("view", { key: 1, class: "nut-input-error-message", style: d({ textAlign: e2.errorMessageAlign }) }, p(e2.errorMessage), 5)) : s("", true)])], 2);
57
- }]]);
58
- export { F as default };
34
+ const { componentName, create, translate } = createComponent("input");
35
+ const _sfc_main = create({
36
+ props: {
37
+ ref: {
38
+ type: String,
39
+ default: ""
40
+ },
41
+ type: {
42
+ type: String,
43
+ default: "text"
44
+ },
45
+ modelValue: {
46
+ type: [String, Number],
47
+ default: ""
48
+ },
49
+ placeholder: {
50
+ type: String,
51
+ default: ""
52
+ },
53
+ label: {
54
+ type: String,
55
+ default: ""
56
+ },
57
+ labelClass: {
58
+ type: String,
59
+ default: ""
60
+ },
61
+ labelWidth: {
62
+ type: [String, Number],
63
+ default: "80"
64
+ },
65
+ labelAlign: {
66
+ type: String,
67
+ default: "left"
68
+ },
69
+ colon: {
70
+ type: Boolean,
71
+ default: false
72
+ },
73
+ inputAlign: {
74
+ type: String,
75
+ default: "left"
76
+ },
77
+ center: {
78
+ type: Boolean,
79
+ default: false
80
+ },
81
+ required: {
82
+ type: Boolean,
83
+ default: false
84
+ },
85
+ disabled: {
86
+ type: Boolean,
87
+ default: false
88
+ },
89
+ readonly: {
90
+ type: Boolean,
91
+ default: false
92
+ },
93
+ error: {
94
+ type: Boolean,
95
+ default: false
96
+ },
97
+ maxLength: {
98
+ type: [String, Number],
99
+ default: "9999"
100
+ },
101
+ leftIcon: {
102
+ type: String,
103
+ default: ""
104
+ },
105
+ leftIconSize: {
106
+ type: [String, Number],
107
+ default: ""
108
+ },
109
+ rightIcon: {
110
+ type: String,
111
+ default: ""
112
+ },
113
+ rightIconSize: {
114
+ type: [String, Number],
115
+ default: ""
116
+ },
117
+ clearable: {
118
+ type: Boolean,
119
+ default: false
120
+ },
121
+ clearIcon: {
122
+ type: String,
123
+ default: "mask-close"
124
+ },
125
+ clearSize: {
126
+ type: [String, Number],
127
+ default: "14"
128
+ },
129
+ border: {
130
+ type: Boolean,
131
+ default: true
132
+ },
133
+ formatTrigger: {
134
+ type: String,
135
+ default: "onChange"
136
+ },
137
+ formatter: {
138
+ type: Function,
139
+ default: null
140
+ },
141
+ rules: {
142
+ type: Array,
143
+ default: []
144
+ },
145
+ errorMessage: {
146
+ type: String,
147
+ default: ""
148
+ },
149
+ errorMessageAlign: {
150
+ type: String,
151
+ default: ""
152
+ },
153
+ rows: {
154
+ type: [String, Number],
155
+ default: null
156
+ },
157
+ showWordLimit: {
158
+ type: Boolean,
159
+ default: false
160
+ },
161
+ autofocus: {
162
+ type: Boolean,
163
+ default: false
164
+ }
165
+ },
166
+ emits: [
167
+ "update:modelValue",
168
+ "change",
169
+ "blur",
170
+ "focus",
171
+ "clear",
172
+ "keypress",
173
+ "click-input",
174
+ "click-left-icon",
175
+ "click-right-icon"
176
+ ],
177
+ setup(props, { emit, slots }) {
178
+ const active = ref(false);
179
+ const inputRef = ref();
180
+ ref();
181
+ const getModelValue = () => {
182
+ var _a;
183
+ return String((_a = props.modelValue) != null ? _a : "");
184
+ };
185
+ const state = reactive({
186
+ focused: false,
187
+ validateFailed: false,
188
+ validateMessage: ""
189
+ });
190
+ const classes = computed(() => {
191
+ const prefixCls = componentName;
192
+ return {
193
+ [prefixCls]: true,
194
+ center: props.center,
195
+ [`${prefixCls}-disabled`]: props.disabled,
196
+ [`${prefixCls}-required`]: props.required,
197
+ [`${prefixCls}-error`]: props.error,
198
+ [`${prefixCls}-border`]: props.border
199
+ };
200
+ });
201
+ const styles = computed(() => {
202
+ return {
203
+ textAlign: props.inputAlign
204
+ };
205
+ });
206
+ const stylesTextarea = computed(() => {
207
+ return {
208
+ textAlign: props.inputAlign,
209
+ height: Number(props.rows) * 24 + "px"
210
+ };
211
+ });
212
+ const inputType = (type) => {
213
+ if (type === "number") {
214
+ return "text";
215
+ } else if (type === "digit") {
216
+ return "tel";
217
+ } else {
218
+ return type;
219
+ }
220
+ };
221
+ const onInput = (event) => {
222
+ const input = event.target;
223
+ let value = input.value;
224
+ if (props.maxLength && value.length > Number(props.maxLength)) {
225
+ value = value.slice(0, Number(props.maxLength));
226
+ }
227
+ updateValue(value);
228
+ };
229
+ const updateValue = (value, trigger = "onChange") => {
230
+ var _a;
231
+ if (props.type === "digit") {
232
+ value = formatNumber(value, false, false);
233
+ }
234
+ if (props.type === "number") {
235
+ value = formatNumber(value, true, true);
236
+ }
237
+ if (props.formatter && trigger === props.formatTrigger) {
238
+ value = props.formatter(value);
239
+ }
240
+ if (((_a = inputRef == null ? void 0 : inputRef.value) == null ? void 0 : _a.value) !== value) {
241
+ inputRef.value.value = value;
242
+ }
243
+ if (value !== props.modelValue) {
244
+ emit("update:modelValue", value);
245
+ emit("change", value);
246
+ }
247
+ };
248
+ const onFocus = (event) => {
249
+ const input = event.target;
250
+ let value = input.value;
251
+ active.value = true;
252
+ emit("focus", value, event);
253
+ };
254
+ const onBlur = (event) => {
255
+ setTimeout(() => {
256
+ active.value = false;
257
+ }, 200);
258
+ const input = event.target;
259
+ let value = input.value;
260
+ if (props.maxLength && value.length > Number(props.maxLength)) {
261
+ value = value.slice(0, Number(props.maxLength));
262
+ }
263
+ updateValue(getModelValue(), "onBlur");
264
+ emit("blur", value, event);
265
+ };
266
+ const clear = (event) => {
267
+ emit("update:modelValue", "", event);
268
+ emit("change", "", event);
269
+ emit("clear", "", event);
270
+ };
271
+ const resetValidation = () => {
272
+ if (state.validateFailed) {
273
+ state.validateFailed = false;
274
+ state.validateMessage = "";
275
+ }
276
+ };
277
+ const onClickInput = (event) => {
278
+ emit("click-input", event);
279
+ };
280
+ const onClickLeftIcon = (event) => emit("click-left-icon", event);
281
+ const onClickRightIcon = (event) => emit("click-right-icon", event);
282
+ watch(() => props.modelValue, () => {
283
+ updateValue(getModelValue());
284
+ resetValidation();
285
+ });
286
+ onMounted(() => {
287
+ updateValue(getModelValue(), props.formatTrigger);
288
+ });
289
+ return {
290
+ inputRef,
291
+ active,
292
+ classes,
293
+ styles,
294
+ stylesTextarea,
295
+ inputType,
296
+ onInput,
297
+ onFocus,
298
+ onBlur,
299
+ clear,
300
+ onClickInput,
301
+ onClickLeftIcon,
302
+ onClickRightIcon,
303
+ translate
304
+ };
305
+ }
306
+ });
307
+ const _hoisted_1 = { class: "label-string" };
308
+ const _hoisted_2 = { class: "nut-input-value" };
309
+ const _hoisted_3 = { class: "label-string" };
310
+ const _hoisted_4 = { class: "nut-input-value" };
311
+ const _hoisted_5 = ["maxlength", "placeholder", "disabled", "readonly", "value", "formatTrigger", "autofocus"];
312
+ const _hoisted_6 = ["type", "maxlength", "placeholder", "disabled", "readonly", "value", "formatTrigger", "autofocus"];
313
+ const _hoisted_7 = {
314
+ key: 0,
315
+ class: "nut-input-word-limit"
316
+ };
317
+ const _hoisted_8 = { class: "nut-input-word-num" };
318
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
319
+ const _component_nut_icon = resolveComponent("nut-icon");
320
+ return openBlock(), createElementBlock("view", {
321
+ class: normalizeClass(_ctx.classes)
322
+ }, [
323
+ _ctx.$slots.input ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
324
+ _ctx.label ? (openBlock(), createElementBlock("view", {
325
+ key: 0,
326
+ class: normalizeClass(["nut-input-label", _ctx.labelClass]),
327
+ style: normalizeStyle({
328
+ width: `${_ctx.labelWidth}px`,
329
+ textAlign: _ctx.labelAlign
330
+ })
331
+ }, [
332
+ createElementVNode("view", _hoisted_1, toDisplayString(_ctx.label) + " " + toDisplayString(_ctx.colon ? ":" : ""), 1)
333
+ ], 6)) : createCommentVNode("", true),
334
+ createElementVNode("view", _hoisted_2, [
335
+ createElementVNode("view", {
336
+ class: "nut-input-inner",
337
+ onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClickInput && _ctx.onClickInput(...args))
338
+ }, [
339
+ renderSlot(_ctx.$slots, "input")
340
+ ])
341
+ ])
342
+ ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
343
+ _ctx.leftIcon && _ctx.leftIcon.length > 0 ? (openBlock(), createElementBlock("view", {
344
+ key: 0,
345
+ class: "nut-input-left-icon",
346
+ onClick: _cache[1] || (_cache[1] = (...args) => _ctx.onClickLeftIcon && _ctx.onClickLeftIcon(...args))
347
+ }, [
348
+ createVNode(_component_nut_icon, {
349
+ name: _ctx.leftIcon,
350
+ size: _ctx.leftIconSize
351
+ }, null, 8, ["name", "size"])
352
+ ])) : createCommentVNode("", true),
353
+ _ctx.label ? (openBlock(), createElementBlock("view", {
354
+ key: 1,
355
+ class: normalizeClass(["nut-input-label", _ctx.labelClass]),
356
+ style: normalizeStyle({
357
+ width: `${_ctx.labelWidth}px`,
358
+ textAlign: _ctx.labelAlign
359
+ })
360
+ }, [
361
+ createElementVNode("view", _hoisted_3, toDisplayString(_ctx.label) + " " + toDisplayString(_ctx.colon ? ":" : ""), 1)
362
+ ], 6)) : createCommentVNode("", true),
363
+ createElementVNode("view", _hoisted_4, [
364
+ createElementVNode("view", {
365
+ class: "nut-input-inner",
366
+ onClick: _cache[9] || (_cache[9] = (...args) => _ctx.onClickInput && _ctx.onClickInput(...args))
367
+ }, [
368
+ _ctx.type == "textarea" ? (openBlock(), createElementBlock("textarea", {
369
+ key: 0,
370
+ class: "input-text",
371
+ ref: "inputRef",
372
+ style: normalizeStyle(_ctx.stylesTextarea),
373
+ maxlength: _ctx.maxLength,
374
+ placeholder: _ctx.placeholder || _ctx.translate("placeholder"),
375
+ disabled: _ctx.disabled,
376
+ readonly: _ctx.readonly,
377
+ value: _ctx.modelValue,
378
+ formatTrigger: _ctx.formatTrigger,
379
+ autofocus: _ctx.autofocus,
380
+ onInput: _cache[2] || (_cache[2] = (...args) => _ctx.onInput && _ctx.onInput(...args)),
381
+ onFocus: _cache[3] || (_cache[3] = (...args) => _ctx.onFocus && _ctx.onFocus(...args)),
382
+ onBlur: _cache[4] || (_cache[4] = (...args) => _ctx.onBlur && _ctx.onBlur(...args))
383
+ }, null, 44, _hoisted_5)) : (openBlock(), createElementBlock("input", {
384
+ key: 1,
385
+ class: "input-text",
386
+ ref: "inputRef",
387
+ style: normalizeStyle(_ctx.styles),
388
+ type: _ctx.inputType(_ctx.type),
389
+ maxlength: _ctx.maxLength,
390
+ placeholder: _ctx.placeholder || _ctx.translate("placeholder"),
391
+ disabled: _ctx.disabled,
392
+ readonly: _ctx.readonly,
393
+ value: _ctx.modelValue,
394
+ formatTrigger: _ctx.formatTrigger,
395
+ autofocus: _ctx.autofocus,
396
+ onInput: _cache[5] || (_cache[5] = (...args) => _ctx.onInput && _ctx.onInput(...args)),
397
+ onFocus: _cache[6] || (_cache[6] = (...args) => _ctx.onFocus && _ctx.onFocus(...args)),
398
+ onBlur: _cache[7] || (_cache[7] = (...args) => _ctx.onBlur && _ctx.onBlur(...args))
399
+ }, null, 44, _hoisted_6)),
400
+ _ctx.clearable && !_ctx.readonly ? withDirectives((openBlock(), createBlock(_component_nut_icon, {
401
+ key: 2,
402
+ class: "nut-input-clear",
403
+ name: _ctx.clearIcon,
404
+ size: _ctx.clearSize,
405
+ onClick: _ctx.clear
406
+ }, null, 8, ["name", "size", "onClick"])), [
407
+ [vShow, _ctx.active && _ctx.modelValue.length > 0]
408
+ ]) : createCommentVNode("", true),
409
+ _ctx.rightIcon && _ctx.rightIcon.length > 0 ? (openBlock(), createElementBlock("view", {
410
+ key: 3,
411
+ class: "nut-input-right-icon",
412
+ onClick: _cache[8] || (_cache[8] = (...args) => _ctx.onClickRightIcon && _ctx.onClickRightIcon(...args))
413
+ }, [
414
+ createVNode(_component_nut_icon, {
415
+ name: _ctx.rightIcon,
416
+ size: _ctx.rightIconSize
417
+ }, null, 8, ["name", "size"])
418
+ ])) : createCommentVNode("", true),
419
+ _ctx.$slots.button ? renderSlot(_ctx.$slots, "button", {
420
+ key: 4,
421
+ class: "nut-input-button"
422
+ }) : createCommentVNode("", true)
423
+ ]),
424
+ _ctx.showWordLimit && _ctx.maxLength ? (openBlock(), createElementBlock("view", _hoisted_7, [
425
+ createElementVNode("span", _hoisted_8, toDisplayString(_ctx.modelValue ? _ctx.modelValue.length : 0), 1),
426
+ createTextVNode("/" + toDisplayString(_ctx.maxLength), 1)
427
+ ])) : createCommentVNode("", true),
428
+ _ctx.errorMessage ? (openBlock(), createElementBlock("view", {
429
+ key: 1,
430
+ class: "nut-input-error-message",
431
+ style: normalizeStyle({
432
+ textAlign: _ctx.errorMessageAlign
433
+ })
434
+ }, toDisplayString(_ctx.errorMessage), 5)) : createCommentVNode("", true)
435
+ ])
436
+ ], 64))
437
+ ], 2);
438
+ }
439
+ var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
440
+ export { index as default };