@nutui/nutui-react-taro 1.5.4 → 1.5.5

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.
@@ -5,7 +5,7 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  /*!
8
- * @nutui/nutui-react-taro v1.5.4 Wed May 10 2023 17:37:13 GMT+0800 (中国标准时间)
8
+ * @nutui/nutui-react-taro v1.5.5 Wed May 17 2023 16:28:35 GMT+0800 (China Standard Time)
9
9
  * (c) 2023 @jdf2e.
10
10
  * Released under the MIT License.
11
11
  */
@@ -15,10 +15,15 @@ import Taro, { redirectTo, navigateTo, getEnv, usePageScroll, getSystemInfoSync,
15
15
  import { View, ScrollView, PickerView, PickerViewColumn, Image as Image$2 } from "@tarojs/components";
16
16
  import ReactDOM, { createPortal, unstable_batchedUpdates } from "react-dom";
17
17
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
18
- function getDefaultExportFromCjs(x) {
19
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
20
- }
21
- var classname = { exports: {} };
18
+ var classnameExports = {};
19
+ var classname = {
20
+ get exports() {
21
+ return classnameExports;
22
+ },
23
+ set exports(v) {
24
+ classnameExports = v;
25
+ }
26
+ };
22
27
  var classname_production_min = {};
23
28
  var hasRequiredClassname_production_min;
24
29
  function requireClassname_production_min() {
@@ -26,37 +31,37 @@ function requireClassname_production_min() {
26
31
  return classname_production_min;
27
32
  hasRequiredClassname_production_min = 1;
28
33
  function r(r2) {
29
- function t2(t3, i, a, o) {
30
- var f = i ? e + t3 + r2.e + i : e + t3, v = f;
34
+ function e2(e3, i, a, o) {
35
+ var f = i ? t + e3 + r2.e + i : t + e3, v = f;
31
36
  if (a) {
32
- var s = " " + v + r2.m;
33
- for (var u in a)
34
- if (a.hasOwnProperty(u)) {
35
- var p = a[u];
36
- true === p ? v += s + u : p && (v += s + u + n + p);
37
+ var u = " " + v + r2.m;
38
+ for (var s in a)
39
+ if (a.hasOwnProperty(s)) {
40
+ var p = a[s];
41
+ true === p ? v += u + s : p && (v += u + s + n + p);
37
42
  }
38
43
  }
39
44
  if (void 0 !== o)
40
- for (var y = 0, c = (o = Array.isArray(o) ? o : [o]).length; y < c; y++) {
41
- var l = o[y];
42
- if (l && "string" == typeof l.valueOf())
43
- for (var g = l.valueOf().split(" "), d = 0; d < g.length; d++) {
45
+ for (var c = 0, l = o.length; c < l; c++) {
46
+ var y = o[c];
47
+ if (y && "string" == typeof y.valueOf())
48
+ for (var g = y.valueOf().split(" "), d = 0; d < g.length; d++) {
44
49
  var h = g[d];
45
50
  h !== f && (v += " " + h);
46
51
  }
47
52
  }
48
53
  return v;
49
54
  }
50
- var e = r2.n || "", n = r2.v || r2.m;
51
- return function(r3, e2) {
55
+ var t = r2.n || "", n = r2.v || r2.m;
56
+ return function(r3, t2) {
52
57
  return function(n2, i, a) {
53
- return "string" == typeof n2 ? "string" == typeof i || Array.isArray(i) ? t2(r3, n2, void 0, i) : t2(r3, n2, i, a) : t2(r3, e2, n2, i);
58
+ return "string" == typeof n2 ? Array.isArray(i) ? e2(r3, n2, void 0, i) : e2(r3, n2, i, a) : e2(r3, t2, n2, i);
54
59
  };
55
60
  };
56
61
  }
57
62
  Object.defineProperty(classname_production_min, "__esModule", { value: true });
58
- var t = r({ e: "-", m: "_" });
59
- classname_production_min.cn = t, classname_production_min.withNaming = r;
63
+ var e = r({ e: "-", m: "_" });
64
+ classname_production_min.cn = e, classname_production_min.withNaming = r;
60
65
  return classname_production_min;
61
66
  }
62
67
  var classname_development = {};
@@ -86,7 +91,6 @@ function requireClassname_development() {
86
91
  }
87
92
  }
88
93
  if (mix !== void 0) {
89
- mix = Array.isArray(mix) ? mix : [mix];
90
94
  for (var i = 0, len = mix.length; i < len; i++) {
91
95
  var value = mix[i];
92
96
  if (!value || typeof value.valueOf() !== "string")
@@ -105,7 +109,7 @@ function requireClassname_development() {
105
109
  return function cnGenerator(b2, e) {
106
110
  return function(elemOrMods, elemModsOrBlockMix, elemMix) {
107
111
  if (typeof elemOrMods === "string") {
108
- if (typeof elemModsOrBlockMix === "string" || Array.isArray(elemModsOrBlockMix)) {
112
+ if (Array.isArray(elemModsOrBlockMix)) {
109
113
  return stringify(b2, elemOrMods, void 0, elemModsOrBlockMix);
110
114
  }
111
115
  return stringify(b2, elemOrMods, elemModsOrBlockMix, elemMix);
@@ -122,12 +126,13 @@ function requireClassname_development() {
122
126
  classname_development.withNaming = withNaming;
123
127
  return classname_development;
124
128
  }
125
- if (process.env.NODE_ENV === "production") {
126
- classname.exports = requireClassname_production_min();
127
- } else {
128
- classname.exports = requireClassname_development();
129
- }
130
- var classnameExports = classname.exports;
129
+ (function(module) {
130
+ if (process.env.NODE_ENV === "production") {
131
+ module.exports = requireClassname_production_min();
132
+ } else {
133
+ module.exports = requireClassname_development();
134
+ }
135
+ })(classname);
131
136
  const cn = classnameExports.withNaming({ n: "nut-", e: "__", m: "--", v: "-" });
132
137
  const defaultProps$1v = {
133
138
  name: "",
@@ -743,7 +748,6 @@ function words(string, pattern, guard) {
743
748
  return string.match(pattern) || [];
744
749
  }
745
750
  var lodash_kebabcase = kebabCase;
746
- const kebabCase$1 = /* @__PURE__ */ getDefaultExportFromCjs(lodash_kebabcase);
747
751
  const zhCN = {
748
752
  save: "保存",
749
753
  confirm: "确认",
@@ -891,7 +895,7 @@ const useConfig$1 = () => {
891
895
  function convertThemeVarsToCSSVars(themeVars) {
892
896
  const cssVars = {};
893
897
  Object.keys(themeVars).forEach((key) => {
894
- cssVars[`--${kebabCase$1(key)}`] = themeVars[key];
898
+ cssVars[`--${lodash_kebabcase(key)}`] = themeVars[key];
895
899
  });
896
900
  return cssVars;
897
901
  }
@@ -1008,7 +1012,15 @@ const Image$1 = (props) => {
1008
1012
  };
1009
1013
  Image$1.defaultProps = defaultProps$1q;
1010
1014
  Image$1.displayName = "NutImage";
1011
- var classnames = { exports: {} };
1015
+ var classnamesExports = {};
1016
+ var classnames = {
1017
+ get exports() {
1018
+ return classnamesExports;
1019
+ },
1020
+ set exports(v) {
1021
+ classnamesExports = v;
1022
+ }
1023
+ };
1012
1024
  /*!
1013
1025
  Copyright (c) 2018 Jed Watson.
1014
1026
  Licensed under the MIT License (MIT), see
@@ -1055,8 +1067,7 @@ var classnames = { exports: {} };
1055
1067
  }
1056
1068
  })();
1057
1069
  })(classnames);
1058
- var classnamesExports = classnames.exports;
1059
- const classNames = /* @__PURE__ */ getDefaultExportFromCjs(classnamesExports);
1070
+ const classNames = classnamesExports;
1060
1071
  const defaultOverlayProps = {
1061
1072
  zIndex: 2e3,
1062
1073
  duration: 0.3,
@@ -1182,8 +1193,24 @@ function _inheritsLoose(subClass, superClass) {
1182
1193
  subClass.prototype.constructor = subClass;
1183
1194
  _setPrototypeOf(subClass, superClass);
1184
1195
  }
1185
- var propTypes = { exports: {} };
1186
- var reactIs = { exports: {} };
1196
+ var propTypesExports = {};
1197
+ var propTypes = {
1198
+ get exports() {
1199
+ return propTypesExports;
1200
+ },
1201
+ set exports(v) {
1202
+ propTypesExports = v;
1203
+ }
1204
+ };
1205
+ var reactIsExports = {};
1206
+ var reactIs = {
1207
+ get exports() {
1208
+ return reactIsExports;
1209
+ },
1210
+ set exports(v) {
1211
+ reactIsExports = v;
1212
+ }
1213
+ };
1187
1214
  var reactIs_production_min = {};
1188
1215
  /** @license React v16.13.1
1189
1216
  * react-is.production.min.js
@@ -1454,14 +1481,16 @@ function requireReactIs_development() {
1454
1481
  var hasRequiredReactIs;
1455
1482
  function requireReactIs() {
1456
1483
  if (hasRequiredReactIs)
1457
- return reactIs.exports;
1484
+ return reactIsExports;
1458
1485
  hasRequiredReactIs = 1;
1459
- if (process.env.NODE_ENV === "production") {
1460
- reactIs.exports = requireReactIs_production_min();
1461
- } else {
1462
- reactIs.exports = requireReactIs_development();
1463
- }
1464
- return reactIs.exports;
1486
+ (function(module) {
1487
+ if (process.env.NODE_ENV === "production") {
1488
+ module.exports = requireReactIs_production_min();
1489
+ } else {
1490
+ module.exports = requireReactIs_development();
1491
+ }
1492
+ })(reactIs);
1493
+ return reactIsExports;
1465
1494
  }
1466
1495
  /*
1467
1496
  object-assign
@@ -2128,8 +2157,6 @@ if (process.env.NODE_ENV !== "production") {
2128
2157
  } else {
2129
2158
  propTypes.exports = requireFactoryWithThrowingShims()();
2130
2159
  }
2131
- var propTypesExports = propTypes.exports;
2132
- const PropTypes = /* @__PURE__ */ getDefaultExportFromCjs(propTypesExports);
2133
2160
  function hasClass(element, className) {
2134
2161
  if (element.classList)
2135
2162
  return !!className && element.classList.contains(className);
@@ -2159,22 +2186,22 @@ function removeClass$1(element, className) {
2159
2186
  const config$1 = {
2160
2187
  disabled: false
2161
2188
  };
2162
- var timeoutsShape = process.env.NODE_ENV !== "production" ? PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
2163
- enter: PropTypes.number,
2164
- exit: PropTypes.number,
2165
- appear: PropTypes.number
2189
+ var timeoutsShape = process.env.NODE_ENV !== "production" ? propTypesExports.oneOfType([propTypesExports.number, propTypesExports.shape({
2190
+ enter: propTypesExports.number,
2191
+ exit: propTypesExports.number,
2192
+ appear: propTypesExports.number
2166
2193
  }).isRequired]) : null;
2167
- var classNamesShape = process.env.NODE_ENV !== "production" ? PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
2168
- enter: PropTypes.string,
2169
- exit: PropTypes.string,
2170
- active: PropTypes.string
2171
- }), PropTypes.shape({
2172
- enter: PropTypes.string,
2173
- enterDone: PropTypes.string,
2174
- enterActive: PropTypes.string,
2175
- exit: PropTypes.string,
2176
- exitDone: PropTypes.string,
2177
- exitActive: PropTypes.string
2194
+ var classNamesShape = process.env.NODE_ENV !== "production" ? propTypesExports.oneOfType([propTypesExports.string, propTypesExports.shape({
2195
+ enter: propTypesExports.string,
2196
+ exit: propTypesExports.string,
2197
+ active: propTypesExports.string
2198
+ }), propTypesExports.shape({
2199
+ enter: propTypesExports.string,
2200
+ enterDone: propTypesExports.string,
2201
+ enterActive: propTypesExports.string,
2202
+ exit: propTypesExports.string,
2203
+ exitDone: propTypesExports.string,
2204
+ exitActive: propTypesExports.string
2178
2205
  })]) : null;
2179
2206
  const TransitionGroupContext = React__default.createContext(null);
2180
2207
  var forceReflow = function forceReflow2(node) {
@@ -2424,10 +2451,10 @@ Transition.propTypes = process.env.NODE_ENV !== "production" ? {
2424
2451
  * (see
2425
2452
  * [test/CSSTransition-test.js](https://github.com/reactjs/react-transition-group/blob/13435f897b3ab71f6e19d724f145596f5910581c/test/CSSTransition-test.js#L362-L437)).
2426
2453
  */
2427
- nodeRef: PropTypes.shape({
2428
- current: typeof Element === "undefined" ? PropTypes.any : function(propValue, key, componentName, location, propFullName, secret) {
2454
+ nodeRef: propTypesExports.shape({
2455
+ current: typeof Element === "undefined" ? propTypesExports.any : function(propValue, key, componentName, location, propFullName, secret) {
2429
2456
  var value = propValue[key];
2430
- return PropTypes.instanceOf(value && "ownerDocument" in value ? value.ownerDocument.defaultView.Element : Element)(propValue, key, componentName, location, propFullName, secret);
2457
+ return propTypesExports.instanceOf(value && "ownerDocument" in value ? value.ownerDocument.defaultView.Element : Element)(propValue, key, componentName, location, propFullName, secret);
2431
2458
  }
2432
2459
  }),
2433
2460
  /**
@@ -2444,23 +2471,23 @@ Transition.propTypes = process.env.NODE_ENV !== "production" ? {
2444
2471
  * </Transition>
2445
2472
  * ```
2446
2473
  */
2447
- children: PropTypes.oneOfType([PropTypes.func.isRequired, PropTypes.element.isRequired]).isRequired,
2474
+ children: propTypesExports.oneOfType([propTypesExports.func.isRequired, propTypesExports.element.isRequired]).isRequired,
2448
2475
  /**
2449
2476
  * Show the component; triggers the enter or exit states
2450
2477
  */
2451
- in: PropTypes.bool,
2478
+ in: propTypesExports.bool,
2452
2479
  /**
2453
2480
  * By default the child component is mounted immediately along with
2454
2481
  * the parent `Transition` component. If you want to "lazy mount" the component on the
2455
2482
  * first `in={true}` you can set `mountOnEnter`. After the first enter transition the component will stay
2456
2483
  * mounted, even on "exited", unless you also specify `unmountOnExit`.
2457
2484
  */
2458
- mountOnEnter: PropTypes.bool,
2485
+ mountOnEnter: propTypesExports.bool,
2459
2486
  /**
2460
2487
  * By default the child component stays mounted after it reaches the `'exited'` state.
2461
2488
  * Set `unmountOnExit` if you'd prefer to unmount the component after it finishes exiting.
2462
2489
  */
2463
- unmountOnExit: PropTypes.bool,
2490
+ unmountOnExit: propTypesExports.bool,
2464
2491
  /**
2465
2492
  * By default the child component does not perform the enter transition when
2466
2493
  * it first mounts, regardless of the value of `in`. If you want this
@@ -2472,15 +2499,15 @@ Transition.propTypes = process.env.NODE_ENV !== "production" ? {
2472
2499
  * > additional `.appear-*` classes, that way you can choose to style it
2473
2500
  * > differently.
2474
2501
  */
2475
- appear: PropTypes.bool,
2502
+ appear: propTypesExports.bool,
2476
2503
  /**
2477
2504
  * Enable or disable enter transitions.
2478
2505
  */
2479
- enter: PropTypes.bool,
2506
+ enter: propTypesExports.bool,
2480
2507
  /**
2481
2508
  * Enable or disable exit transitions.
2482
2509
  */
2483
- exit: PropTypes.bool,
2510
+ exit: propTypesExports.bool,
2484
2511
  /**
2485
2512
  * The duration of the transition, in milliseconds.
2486
2513
  * Required unless `addEndListener` is provided.
@@ -2530,7 +2557,7 @@ Transition.propTypes = process.env.NODE_ENV !== "production" ? {
2530
2557
  * }}
2531
2558
  * ```
2532
2559
  */
2533
- addEndListener: PropTypes.func,
2560
+ addEndListener: propTypesExports.func,
2534
2561
  /**
2535
2562
  * Callback fired before the "entering" status is applied. An extra parameter
2536
2563
  * `isAppearing` is supplied to indicate if the enter stage is occurring on the initial mount
@@ -2539,7 +2566,7 @@ Transition.propTypes = process.env.NODE_ENV !== "production" ? {
2539
2566
  *
2540
2567
  * @type Function(node: HtmlElement, isAppearing: bool) -> void
2541
2568
  */
2542
- onEnter: PropTypes.func,
2569
+ onEnter: propTypesExports.func,
2543
2570
  /**
2544
2571
  * Callback fired after the "entering" status is applied. An extra parameter
2545
2572
  * `isAppearing` is supplied to indicate if the enter stage is occurring on the initial mount
@@ -2548,7 +2575,7 @@ Transition.propTypes = process.env.NODE_ENV !== "production" ? {
2548
2575
  *
2549
2576
  * @type Function(node: HtmlElement, isAppearing: bool)
2550
2577
  */
2551
- onEntering: PropTypes.func,
2578
+ onEntering: propTypesExports.func,
2552
2579
  /**
2553
2580
  * Callback fired after the "entered" status is applied. An extra parameter
2554
2581
  * `isAppearing` is supplied to indicate if the enter stage is occurring on the initial mount
@@ -2557,7 +2584,7 @@ Transition.propTypes = process.env.NODE_ENV !== "production" ? {
2557
2584
  *
2558
2585
  * @type Function(node: HtmlElement, isAppearing: bool) -> void
2559
2586
  */
2560
- onEntered: PropTypes.func,
2587
+ onEntered: propTypesExports.func,
2561
2588
  /**
2562
2589
  * Callback fired before the "exiting" status is applied.
2563
2590
  *
@@ -2565,7 +2592,7 @@ Transition.propTypes = process.env.NODE_ENV !== "production" ? {
2565
2592
  *
2566
2593
  * @type Function(node: HtmlElement) -> void
2567
2594
  */
2568
- onExit: PropTypes.func,
2595
+ onExit: propTypesExports.func,
2569
2596
  /**
2570
2597
  * Callback fired after the "exiting" status is applied.
2571
2598
  *
@@ -2573,7 +2600,7 @@ Transition.propTypes = process.env.NODE_ENV !== "production" ? {
2573
2600
  *
2574
2601
  * @type Function(node: HtmlElement) -> void
2575
2602
  */
2576
- onExiting: PropTypes.func,
2603
+ onExiting: propTypesExports.func,
2577
2604
  /**
2578
2605
  * Callback fired after the "exited" status is applied.
2579
2606
  *
@@ -2581,7 +2608,7 @@ Transition.propTypes = process.env.NODE_ENV !== "production" ? {
2581
2608
  *
2582
2609
  * @type Function(node: HtmlElement) -> void
2583
2610
  */
2584
- onExited: PropTypes.func
2611
+ onExited: propTypesExports.func
2585
2612
  } : {};
2586
2613
  function noop$2() {
2587
2614
  }
@@ -2820,7 +2847,7 @@ CSSTransition.propTypes = process.env.NODE_ENV !== "production" ? _extends$3({},
2820
2847
  *
2821
2848
  * @type Function(node: HtmlElement, isAppearing: bool)
2822
2849
  */
2823
- onEnter: PropTypes.func,
2850
+ onEnter: propTypesExports.func,
2824
2851
  /**
2825
2852
  * A `<Transition>` callback fired immediately after the 'enter-active' or
2826
2853
  * 'appear-active' class is applied.
@@ -2829,7 +2856,7 @@ CSSTransition.propTypes = process.env.NODE_ENV !== "production" ? _extends$3({},
2829
2856
  *
2830
2857
  * @type Function(node: HtmlElement, isAppearing: bool)
2831
2858
  */
2832
- onEntering: PropTypes.func,
2859
+ onEntering: propTypesExports.func,
2833
2860
  /**
2834
2861
  * A `<Transition>` callback fired immediately after the 'enter' or
2835
2862
  * 'appear' classes are **removed** and the `done` class is added to the DOM node.
@@ -2838,7 +2865,7 @@ CSSTransition.propTypes = process.env.NODE_ENV !== "production" ? _extends$3({},
2838
2865
  *
2839
2866
  * @type Function(node: HtmlElement, isAppearing: bool)
2840
2867
  */
2841
- onEntered: PropTypes.func,
2868
+ onEntered: propTypesExports.func,
2842
2869
  /**
2843
2870
  * A `<Transition>` callback fired immediately after the 'exit' class is
2844
2871
  * applied.
@@ -2847,7 +2874,7 @@ CSSTransition.propTypes = process.env.NODE_ENV !== "production" ? _extends$3({},
2847
2874
  *
2848
2875
  * @type Function(node: HtmlElement)
2849
2876
  */
2850
- onExit: PropTypes.func,
2877
+ onExit: propTypesExports.func,
2851
2878
  /**
2852
2879
  * A `<Transition>` callback fired immediately after the 'exit-active' is applied.
2853
2880
  *
@@ -2855,7 +2882,7 @@ CSSTransition.propTypes = process.env.NODE_ENV !== "production" ? _extends$3({},
2855
2882
  *
2856
2883
  * @type Function(node: HtmlElement)
2857
2884
  */
2858
- onExiting: PropTypes.func,
2885
+ onExiting: propTypesExports.func,
2859
2886
  /**
2860
2887
  * A `<Transition>` callback fired immediately after the 'exit' classes
2861
2888
  * are **removed** and the `exit-done` class is added to the DOM node.
@@ -2864,7 +2891,7 @@ CSSTransition.propTypes = process.env.NODE_ENV !== "production" ? _extends$3({},
2864
2891
  *
2865
2892
  * @type Function(node: HtmlElement)
2866
2893
  */
2867
- onExited: PropTypes.func
2894
+ onExited: propTypesExports.func
2868
2895
  }) : {};
2869
2896
  const CSSTransition$1 = CSSTransition;
2870
2897
  const defaultProps$1p = {
@@ -7873,314 +7900,320 @@ const defaultProps$X = {
7873
7900
  slotButton: null,
7874
7901
  slotInput: null
7875
7902
  };
7876
- const Input = forwardRef((props, ref) => {
7877
- const { locale } = useConfig$1();
7878
- const {
7879
- children,
7880
- type,
7881
- name,
7882
- defaultValue,
7883
- placeholder,
7884
- label,
7885
- labelClass,
7886
- labelWidth,
7887
- labelAlign,
7888
- colon,
7889
- inputAlign,
7890
- center,
7891
- required,
7892
- disabled,
7893
- readonly,
7894
- error,
7895
- maxlength,
7896
- leftIcon,
7897
- leftIconSize,
7898
- rightIcon,
7899
- rightIconSize,
7900
- clearable,
7901
- clearIcon,
7902
- clearSize,
7903
- border,
7904
- formatTrigger,
7905
- rules,
7906
- errorMessage,
7907
- errorMessageAlign,
7908
- showWordLimit,
7909
- autofocus,
7910
- style,
7911
- className,
7912
- rows,
7913
- slotButton,
7914
- slotInput,
7915
- onChange,
7916
- onBlur,
7917
- onFocus,
7918
- onClear,
7919
- formatter,
7920
- keypress,
7921
- onClickInput,
7922
- onClickLeftIcon,
7923
- onClickRightIcon,
7924
- onClick,
7925
- iconClassPrefix,
7926
- iconFontClassName,
7927
- ...rest
7928
- } = {
7929
- ...defaultProps$X,
7930
- ...props
7931
- };
7932
- const inputPlaceholder = placeholder || locale.placeholder;
7933
- const [inputValue, SetInputValue] = useState("");
7934
- const [active, SetActive] = useState(false);
7935
- const [classes, setClasses] = useState("");
7936
- const getModelValue = () => String(inputValue ?? "");
7937
- const inputRef = useRef(null);
7938
- useEffect(() => {
7939
- setClasses(inputClass);
7940
- SetInputValue(defaultValue);
7941
- }, [defaultValue]);
7942
- useEffect(() => {
7943
- if (inputValue) {
7944
- updateValue(getModelValue());
7945
- resetValidation();
7946
- }
7947
- }, [inputValue]);
7948
- useImperativeHandle(ref, () => {
7949
- return inputRef.current;
7950
- });
7951
- const inputClass = useCallback(() => {
7952
- const prefixCls = "nut-input";
7953
- return [
7954
- prefixCls,
7955
- `${center ? "center" : ""}`,
7956
- `${disabled ? `${prefixCls}-disabled` : ""}`,
7957
- `${required ? `${prefixCls}-required` : ""}`,
7958
- `${error ? `${prefixCls}-error` : ""}`,
7959
- `${border ? `${prefixCls}-border` : ""}`,
7960
- `${slotButton || rightIcon ? `${prefixCls}-right-mark` : ""}`
7961
- ].filter(Boolean).join(" ");
7962
- }, [disabled, required, error, border, slotButton, rightIcon, center]);
7963
- useEffect(() => {
7964
- setClasses(inputClass);
7965
- }, [disabled, required, error, border, slotButton, rightIcon, center]);
7966
- const updateValue = (value, trigger = "onChange") => {
7967
- var _a;
7968
- let val = value;
7969
- if (type === "tel") {
7970
- val = formatNumber(val, false, false);
7971
- }
7972
- if (["number", "digit"].includes(type)) {
7973
- val = formatNumber(val, true, true);
7974
- }
7975
- if (type === "tel" && !formatter) {
7976
- const regTel = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
7977
- const regNumber = /[^-0-9]/g;
7978
- val = !regTel.test(val) && val.length > 11 ? val.substring(0, 11) : val.replace(regNumber, "");
7979
- }
7980
- if (formatter && trigger === formatTrigger) {
7981
- val = formatter(val);
7982
- }
7983
- if (((_a = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _a.value) !== val) {
7984
- inputRef.current.value = val;
7985
- }
7986
- SetInputValue(val);
7987
- };
7988
- const handleFocus = (event) => {
7989
- const val = event.target.value;
7990
- SetActive(true);
7991
- onFocus && onFocus(val, event);
7992
- };
7993
- const handleInput = (event) => {
7994
- let val = event.target.value;
7995
- if (maxlength && val.length > Number(maxlength)) {
7996
- val = val.slice(0, Number(maxlength));
7997
- }
7998
- updateValue(val, "onChange");
7999
- onChange && onChange(val, event);
8000
- };
8001
- const handleBlur = (event) => {
8002
- setTimeout(() => {
8003
- SetActive(false);
8004
- }, 200);
8005
- let val = event.target.value;
8006
- if (maxlength && val.length > Number(maxlength)) {
8007
- val = val.slice(0, Number(maxlength));
8008
- }
8009
- updateValue(val, "onBlur");
8010
- onBlur && onBlur(val, event);
8011
- };
8012
- const handleClickInput = (event) => {
8013
- onClickInput && onClickInput(event);
8014
- };
8015
- const handleClickLeftIcon = (event) => {
8016
- onClickLeftIcon && onClickLeftIcon(event);
8017
- };
8018
- const handleClickRightIcon = (event) => {
8019
- onClickRightIcon && onClickRightIcon(event);
8020
- };
8021
- const resetValidation = () => {
8022
- };
8023
- const inputType = (type2) => {
8024
- if (type2 === "tel") {
8025
- return "text";
8026
- }
8027
- return type2;
8028
- };
8029
- const handleClear = (event) => {
8030
- updateValue("");
8031
- onClear && onClear("", event);
8032
- };
8033
- return /* @__PURE__ */ React__default.createElement(
8034
- "div",
8035
- {
8036
- className: `${classes} ${className || ""}`,
7903
+ const Input = forwardRef(
7904
+ (props, ref) => {
7905
+ const { locale } = useConfig$1();
7906
+ const {
7907
+ children,
7908
+ type,
7909
+ name,
7910
+ defaultValue,
7911
+ placeholder,
7912
+ label,
7913
+ labelClass,
7914
+ labelWidth,
7915
+ labelAlign,
7916
+ colon,
7917
+ inputAlign,
7918
+ center,
7919
+ required,
7920
+ disabled,
7921
+ readonly,
7922
+ error,
7923
+ maxlength,
7924
+ leftIcon,
7925
+ leftIconSize,
7926
+ rightIcon,
7927
+ rightIconSize,
7928
+ clearable,
7929
+ clearIcon,
7930
+ clearSize,
7931
+ border,
7932
+ formatTrigger,
7933
+ rules,
7934
+ errorMessage,
7935
+ errorMessageAlign,
7936
+ showWordLimit,
7937
+ autofocus,
8037
7938
  style,
8038
- onClick: (e) => {
8039
- onClick && onClick(e);
7939
+ className,
7940
+ rows,
7941
+ slotButton,
7942
+ slotInput,
7943
+ onChange,
7944
+ onBlur,
7945
+ onFocus,
7946
+ onClear,
7947
+ formatter,
7948
+ keypress,
7949
+ onClickInput,
7950
+ onClickLeftIcon,
7951
+ onClickRightIcon,
7952
+ onClick,
7953
+ iconClassPrefix,
7954
+ iconFontClassName,
7955
+ ...rest
7956
+ } = {
7957
+ ...defaultProps$X,
7958
+ ...props
7959
+ };
7960
+ const inputPlaceholder = placeholder || locale.placeholder;
7961
+ const [inputValue, SetInputValue] = useState("");
7962
+ const [active, SetActive] = useState(false);
7963
+ const [classes, setClasses] = useState("");
7964
+ const getModelValue = () => String(inputValue ?? "");
7965
+ const inputRef = useRef(null);
7966
+ useEffect(() => {
7967
+ setClasses(inputClass);
7968
+ SetInputValue(defaultValue);
7969
+ }, [defaultValue]);
7970
+ useEffect(() => {
7971
+ if (inputValue) {
7972
+ updateValue(getModelValue());
7973
+ resetValidation();
8040
7974
  }
8041
- },
8042
- slotInput ? /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, label ? /* @__PURE__ */ React__default.createElement(
8043
- "div",
8044
- {
8045
- className: `nut-input-label ${labelClass}`,
8046
- style: { width: `${labelWidth}px`, textAlign: labelAlign }
8047
- },
8048
- /* @__PURE__ */ React__default.createElement("div", { className: "label-string" }, label, colon ? ":" : "")
8049
- ) : null, /* @__PURE__ */ React__default.createElement("div", { className: "nut-input-value" }, /* @__PURE__ */ React__default.createElement(
8050
- "div",
8051
- {
8052
- className: "nut-input-inner",
8053
- onClick: (e) => {
8054
- handleClickInput(e);
8055
- }
8056
- },
8057
- slotInput
8058
- ))) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, leftIcon && leftIcon.length > 0 ? /* @__PURE__ */ React__default.createElement(
7975
+ }, [inputValue]);
7976
+ useImperativeHandle(ref, () => {
7977
+ return inputRef.current;
7978
+ });
7979
+ const inputClass = useCallback(() => {
7980
+ const prefixCls = "nut-input";
7981
+ return [
7982
+ prefixCls,
7983
+ `${center ? "center" : ""}`,
7984
+ `${disabled ? `${prefixCls}-disabled` : ""}`,
7985
+ `${required ? `${prefixCls}-required` : ""}`,
7986
+ `${error ? `${prefixCls}-error` : ""}`,
7987
+ `${border ? `${prefixCls}-border` : ""}`,
7988
+ `${slotButton || rightIcon ? `${prefixCls}-right-mark` : ""}`
7989
+ ].filter(Boolean).join(" ");
7990
+ }, [disabled, required, error, border, slotButton, rightIcon, center]);
7991
+ useEffect(() => {
7992
+ setClasses(inputClass);
7993
+ }, [disabled, required, error, border, slotButton, rightIcon, center]);
7994
+ const updateValue = (value, trigger = "onChange") => {
7995
+ var _a;
7996
+ let val = value;
7997
+ if (type === "tel") {
7998
+ val = formatNumber(val, false, false);
7999
+ }
8000
+ if (["number", "digit"].includes(type)) {
8001
+ val = formatNumber(val, true, true);
8002
+ }
8003
+ if (type === "tel" && !formatter) {
8004
+ const regTel = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
8005
+ const regNumber = /[^-0-9]/g;
8006
+ val = !regTel.test(val) && val.length > 11 ? val.substring(0, 11) : val.replace(regNumber, "");
8007
+ }
8008
+ if (formatter && trigger === formatTrigger) {
8009
+ val = formatter(val);
8010
+ }
8011
+ if (((_a = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _a.value) !== val) {
8012
+ inputRef.current.value = val;
8013
+ }
8014
+ SetInputValue(val);
8015
+ };
8016
+ const handleFocus = (event) => {
8017
+ const val = event.target.value;
8018
+ SetActive(true);
8019
+ onFocus && onFocus(val, event);
8020
+ };
8021
+ const handleInput = (event) => {
8022
+ let val = event.target.value;
8023
+ if (maxlength && val.length > Number(maxlength)) {
8024
+ val = val.slice(0, Number(maxlength));
8025
+ }
8026
+ updateValue(val, "onChange");
8027
+ onChange && onChange(val, event);
8028
+ };
8029
+ const handleBlur = (event) => {
8030
+ SetActive(false);
8031
+ let val = event.target.value;
8032
+ if (maxlength && val.length > Number(maxlength)) {
8033
+ val = val.slice(0, Number(maxlength));
8034
+ }
8035
+ updateValue(val, "onBlur");
8036
+ onBlur && onBlur(val, event);
8037
+ };
8038
+ const handleClickInput = (event) => {
8039
+ onClickInput && onClickInput(event);
8040
+ };
8041
+ const handleClickLeftIcon = (event) => {
8042
+ onClickLeftIcon && onClickLeftIcon(event);
8043
+ };
8044
+ const handleClickRightIcon = (event) => {
8045
+ onClickRightIcon && onClickRightIcon(event);
8046
+ };
8047
+ const resetValidation = () => {
8048
+ };
8049
+ const inputType = (type2) => {
8050
+ if (type2 === "tel") {
8051
+ return "text";
8052
+ }
8053
+ return type2;
8054
+ };
8055
+ const handleClear = (event) => {
8056
+ setTimeout(() => {
8057
+ updateValue("");
8058
+ onClear && onClear("", event);
8059
+ }, 50);
8060
+ };
8061
+ return /* @__PURE__ */ React__default.createElement(
8059
8062
  "div",
8060
8063
  {
8061
- className: "nut-input-left-icon",
8064
+ className: `${classes} ${className || ""}`,
8065
+ style,
8062
8066
  onClick: (e) => {
8063
- handleClickLeftIcon(e);
8067
+ onClick && onClick(e);
8064
8068
  }
8065
8069
  },
8066
- /* @__PURE__ */ React__default.createElement(
8067
- Icon$1,
8070
+ slotInput ? /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, label ? /* @__PURE__ */ React__default.createElement(
8071
+ "div",
8068
8072
  {
8069
- classPrefix: iconClassPrefix,
8070
- fontClassName: iconFontClassName,
8071
- name: leftIcon,
8072
- size: leftIconSize
8073
- }
8074
- )
8075
- ) : null, label ? /* @__PURE__ */ React__default.createElement(
8076
- "div",
8077
- {
8078
- className: `nut-input-label ${labelClass}`,
8079
- style: { width: `${labelWidth}px`, textAlign: labelAlign }
8080
- },
8081
- /* @__PURE__ */ React__default.createElement("div", { className: "label-string" }, label, colon ? ":" : "")
8082
- ) : null, /* @__PURE__ */ React__default.createElement("div", { className: "nut-input-value" }, /* @__PURE__ */ React__default.createElement("div", { className: "nut-input-main-con" }, /* @__PURE__ */ React__default.createElement(
8083
- "div",
8084
- {
8085
- className: "nut-input-inner",
8086
- onClick: (e) => {
8087
- handleClickInput(e);
8088
- }
8089
- },
8090
- type === "textarea" ? /* @__PURE__ */ React__default.createElement(
8091
- "textarea",
8073
+ className: `nut-input-label ${labelClass}`,
8074
+ style: { width: `${labelWidth}px`, textAlign: labelAlign }
8075
+ },
8076
+ /* @__PURE__ */ React__default.createElement("div", { className: "label-string" }, label, colon ? ":" : "")
8077
+ ) : null, /* @__PURE__ */ React__default.createElement("div", { className: "nut-input-value" }, /* @__PURE__ */ React__default.createElement(
8078
+ "div",
8092
8079
  {
8093
- name,
8094
- className: "input-text",
8095
- ref: inputRef,
8096
- style: {
8097
- textAlign: inputAlign,
8098
- height: `${Number(rows) * 24}px`
8099
- },
8100
- maxLength: maxlength,
8101
- placeholder: inputPlaceholder,
8102
- disabled,
8103
- readOnly: readonly,
8104
- value: inputValue,
8105
- autoFocus: autofocus,
8106
- onBlur: (e) => {
8107
- handleBlur(e);
8108
- },
8109
- onFocus: (e) => {
8110
- handleFocus(e);
8111
- },
8112
- onInput: (e) => {
8113
- handleInput(e);
8080
+ className: "nut-input-inner",
8081
+ onClick: (e) => {
8082
+ handleClickInput(e);
8114
8083
  }
8115
- }
8116
- ) : /* @__PURE__ */ React__default.createElement(
8117
- "input",
8084
+ },
8085
+ slotInput
8086
+ ))) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, leftIcon && leftIcon.length > 0 ? /* @__PURE__ */ React__default.createElement(
8087
+ "div",
8118
8088
  {
8119
- ...rest,
8120
- name,
8121
- className: "input-text",
8122
- ref: inputRef,
8123
- style: { textAlign: inputAlign },
8124
- type: inputType(type),
8125
- maxLength: maxlength,
8126
- placeholder: inputPlaceholder,
8127
- disabled,
8128
- readOnly: readonly,
8129
- value: inputValue,
8130
- autoFocus: autofocus,
8131
- onBlur: (e) => {
8132
- handleBlur(e);
8133
- },
8134
- onFocus: (e) => {
8135
- handleFocus(e);
8136
- },
8137
- onInput: (e) => {
8138
- handleInput(e);
8089
+ className: "nut-input-left-icon",
8090
+ onClick: (e) => {
8091
+ handleClickLeftIcon(e);
8139
8092
  }
8140
- }
8141
- ),
8142
- clearable && !readonly && active && inputValue.length > 0 ? /* @__PURE__ */ React__default.createElement(
8143
- Icon$1,
8093
+ },
8094
+ /* @__PURE__ */ React__default.createElement(
8095
+ Icon$1,
8096
+ {
8097
+ classPrefix: iconClassPrefix,
8098
+ fontClassName: iconFontClassName,
8099
+ name: leftIcon,
8100
+ size: leftIconSize
8101
+ }
8102
+ )
8103
+ ) : null, label ? /* @__PURE__ */ React__default.createElement(
8104
+ "div",
8144
8105
  {
8145
- classPrefix: iconClassPrefix,
8146
- fontClassName: iconFontClassName,
8147
- className: "nut-input-clear",
8148
- name: clearIcon,
8149
- size: clearSize,
8106
+ className: `nut-input-label ${labelClass}`,
8107
+ style: { width: `${labelWidth}px`, textAlign: labelAlign }
8108
+ },
8109
+ /* @__PURE__ */ React__default.createElement("div", { className: "label-string" }, label, colon ? ":" : "")
8110
+ ) : null, /* @__PURE__ */ React__default.createElement("div", { className: "nut-input-value" }, /* @__PURE__ */ React__default.createElement("div", { className: "nut-input-main-con" }, /* @__PURE__ */ React__default.createElement(
8111
+ "div",
8112
+ {
8113
+ className: "nut-input-inner",
8150
8114
  onClick: (e) => {
8151
- handleClear(e);
8115
+ handleClickInput(e);
8152
8116
  }
8153
- }
8154
- ) : null
8155
- ), rightIcon && rightIcon.length > 0 ? /* @__PURE__ */ React__default.createElement(
8156
- "div",
8157
- {
8158
- className: "nut-input-right-icon",
8159
- onClick: (e) => {
8160
- handleClickRightIcon(e);
8161
- }
8162
- },
8163
- /* @__PURE__ */ React__default.createElement(
8164
- Icon$1,
8117
+ },
8118
+ type === "textarea" ? /* @__PURE__ */ React__default.createElement(
8119
+ "textarea",
8120
+ {
8121
+ name,
8122
+ className: "input-text",
8123
+ ref: inputRef,
8124
+ style: {
8125
+ textAlign: inputAlign,
8126
+ height: `${Number(rows) * 24}px`
8127
+ },
8128
+ maxLength: maxlength,
8129
+ placeholder: inputPlaceholder,
8130
+ disabled,
8131
+ readOnly: readonly,
8132
+ value: inputValue,
8133
+ autoFocus: autofocus,
8134
+ onBlur: (e) => {
8135
+ handleBlur(e);
8136
+ },
8137
+ onFocus: (e) => {
8138
+ handleFocus(e);
8139
+ },
8140
+ onInput: (e) => {
8141
+ handleInput(e);
8142
+ }
8143
+ }
8144
+ ) : /* @__PURE__ */ React__default.createElement(
8145
+ "input",
8146
+ {
8147
+ ...rest,
8148
+ name,
8149
+ className: "input-text",
8150
+ ref: inputRef,
8151
+ style: { textAlign: inputAlign },
8152
+ type: inputType(type),
8153
+ maxLength: maxlength,
8154
+ placeholder: inputPlaceholder,
8155
+ disabled,
8156
+ readOnly: readonly,
8157
+ value: inputValue,
8158
+ autoFocus: autofocus,
8159
+ onBlur: (e) => {
8160
+ handleBlur(e);
8161
+ },
8162
+ onFocus: (e) => {
8163
+ handleFocus(e);
8164
+ },
8165
+ onInput: (e) => {
8166
+ handleInput(e);
8167
+ }
8168
+ }
8169
+ ),
8170
+ /* @__PURE__ */ React__default.createElement(
8171
+ Icon$1,
8172
+ {
8173
+ style: {
8174
+ display: clearable && !readonly && active && inputValue.length > 0 ? "inline-flex" : "none",
8175
+ alignItems: "center"
8176
+ },
8177
+ classPrefix: iconClassPrefix,
8178
+ fontClassName: iconFontClassName,
8179
+ className: "nut-input-clear",
8180
+ name: clearIcon,
8181
+ size: clearSize,
8182
+ onClick: (e) => {
8183
+ handleClear(e);
8184
+ }
8185
+ }
8186
+ )
8187
+ ), rightIcon && rightIcon.length > 0 ? /* @__PURE__ */ React__default.createElement(
8188
+ "div",
8165
8189
  {
8166
- classPrefix: iconClassPrefix,
8167
- fontClassName: iconFontClassName,
8168
- name: rightIcon,
8169
- size: rightIconSize
8170
- }
8171
- )
8172
- ) : null, slotButton ? /* @__PURE__ */ React__default.createElement("div", { className: "nut-input-button" }, slotButton) : null, showWordLimit && maxlength ? /* @__PURE__ */ React__default.createElement("div", { className: "nut-input-word-limit" }, /* @__PURE__ */ React__default.createElement("span", { className: "nut-input-word-num" }, inputValue ? inputValue.length : 0), "/", maxlength) : null), errorMessage ? /* @__PURE__ */ React__default.createElement(
8173
- "div",
8174
- {
8175
- className: "nut-input-error-message",
8176
- style: {
8177
- textAlign: errorMessageAlign
8178
- }
8179
- },
8180
- errorMessage
8181
- ) : /* @__PURE__ */ React__default.createElement("div", null)))
8182
- );
8183
- });
8190
+ className: "nut-input-right-icon",
8191
+ onClick: (e) => {
8192
+ handleClickRightIcon(e);
8193
+ }
8194
+ },
8195
+ /* @__PURE__ */ React__default.createElement(
8196
+ Icon$1,
8197
+ {
8198
+ classPrefix: iconClassPrefix,
8199
+ fontClassName: iconFontClassName,
8200
+ name: rightIcon,
8201
+ size: rightIconSize
8202
+ }
8203
+ )
8204
+ ) : null, slotButton ? /* @__PURE__ */ React__default.createElement("div", { className: "nut-input-button" }, slotButton) : null, showWordLimit && maxlength ? /* @__PURE__ */ React__default.createElement("div", { className: "nut-input-word-limit" }, /* @__PURE__ */ React__default.createElement("span", { className: "nut-input-word-num" }, inputValue ? inputValue.length : 0), "/", maxlength) : null), errorMessage ? /* @__PURE__ */ React__default.createElement(
8205
+ "div",
8206
+ {
8207
+ className: "nut-input-error-message",
8208
+ style: {
8209
+ textAlign: errorMessageAlign
8210
+ }
8211
+ },
8212
+ errorMessage
8213
+ ) : /* @__PURE__ */ React__default.createElement("div", null)))
8214
+ );
8215
+ }
8216
+ );
8184
8217
  Input.defaultProps = defaultProps$X;
8185
8218
  Input.displayName = "NutInput";
8186
8219
  const defaultProps$W = {