@nutui/nutui-react-taro 1.5.4 → 1.5.5-beta.0

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.
@@ -8,7 +8,7 @@ var __publicField = (obj, key, value) => {
8
8
  return value;
9
9
  };
10
10
  /*!
11
- * @nutui/nutui-react-taro v1.5.4 Wed May 10 2023 17:37:13 GMT+0800 (中国标准时间)
11
+ * @nutui/nutui-react-taro v1.5.5-beta.0 Wed May 17 2023 16:18:17 GMT+0800 (China Standard Time)
12
12
  * (c) 2023 @jdf2e.
13
13
  * Released under the MIT License.
14
14
  */
@@ -31,10 +31,15 @@ var __publicField = (obj, key, value) => {
31
31
  }
32
32
  const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
33
33
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
34
- function getDefaultExportFromCjs(x) {
35
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
36
- }
37
- var classname = { exports: {} };
34
+ var classnameExports = {};
35
+ var classname = {
36
+ get exports() {
37
+ return classnameExports;
38
+ },
39
+ set exports(v) {
40
+ classnameExports = v;
41
+ }
42
+ };
38
43
  var classname_production_min = {};
39
44
  var hasRequiredClassname_production_min;
40
45
  function requireClassname_production_min() {
@@ -42,37 +47,37 @@ var __publicField = (obj, key, value) => {
42
47
  return classname_production_min;
43
48
  hasRequiredClassname_production_min = 1;
44
49
  function r(r2) {
45
- function t2(t3, i, a, o) {
46
- var f = i ? e + t3 + r2.e + i : e + t3, v = f;
50
+ function e2(e3, i, a, o) {
51
+ var f = i ? t + e3 + r2.e + i : t + e3, v = f;
47
52
  if (a) {
48
- var s = " " + v + r2.m;
49
- for (var u in a)
50
- if (a.hasOwnProperty(u)) {
51
- var p = a[u];
52
- true === p ? v += s + u : p && (v += s + u + n + p);
53
+ var u = " " + v + r2.m;
54
+ for (var s in a)
55
+ if (a.hasOwnProperty(s)) {
56
+ var p = a[s];
57
+ true === p ? v += u + s : p && (v += u + s + n + p);
53
58
  }
54
59
  }
55
60
  if (void 0 !== o)
56
- for (var y = 0, c = (o = Array.isArray(o) ? o : [o]).length; y < c; y++) {
57
- var l = o[y];
58
- if (l && "string" == typeof l.valueOf())
59
- for (var g = l.valueOf().split(" "), d = 0; d < g.length; d++) {
61
+ for (var c = 0, l = o.length; c < l; c++) {
62
+ var y = o[c];
63
+ if (y && "string" == typeof y.valueOf())
64
+ for (var g = y.valueOf().split(" "), d = 0; d < g.length; d++) {
60
65
  var h = g[d];
61
66
  h !== f && (v += " " + h);
62
67
  }
63
68
  }
64
69
  return v;
65
70
  }
66
- var e = r2.n || "", n = r2.v || r2.m;
67
- return function(r3, e2) {
71
+ var t = r2.n || "", n = r2.v || r2.m;
72
+ return function(r3, t2) {
68
73
  return function(n2, i, a) {
69
- 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);
74
+ return "string" == typeof n2 ? Array.isArray(i) ? e2(r3, n2, void 0, i) : e2(r3, n2, i, a) : e2(r3, t2, n2, i);
70
75
  };
71
76
  };
72
77
  }
73
78
  Object.defineProperty(classname_production_min, "__esModule", { value: true });
74
- var t = r({ e: "-", m: "_" });
75
- classname_production_min.cn = t, classname_production_min.withNaming = r;
79
+ var e = r({ e: "-", m: "_" });
80
+ classname_production_min.cn = e, classname_production_min.withNaming = r;
76
81
  return classname_production_min;
77
82
  }
78
83
  var classname_development = {};
@@ -102,7 +107,6 @@ var __publicField = (obj, key, value) => {
102
107
  }
103
108
  }
104
109
  if (mix !== void 0) {
105
- mix = Array.isArray(mix) ? mix : [mix];
106
110
  for (var i = 0, len = mix.length; i < len; i++) {
107
111
  var value = mix[i];
108
112
  if (!value || typeof value.valueOf() !== "string")
@@ -121,7 +125,7 @@ var __publicField = (obj, key, value) => {
121
125
  return function cnGenerator(b2, e) {
122
126
  return function(elemOrMods, elemModsOrBlockMix, elemMix) {
123
127
  if (typeof elemOrMods === "string") {
124
- if (typeof elemModsOrBlockMix === "string" || Array.isArray(elemModsOrBlockMix)) {
128
+ if (Array.isArray(elemModsOrBlockMix)) {
125
129
  return stringify(b2, elemOrMods, void 0, elemModsOrBlockMix);
126
130
  }
127
131
  return stringify(b2, elemOrMods, elemModsOrBlockMix, elemMix);
@@ -138,12 +142,13 @@ var __publicField = (obj, key, value) => {
138
142
  classname_development.withNaming = withNaming;
139
143
  return classname_development;
140
144
  }
141
- if (process.env.NODE_ENV === "production") {
142
- classname.exports = requireClassname_production_min();
143
- } else {
144
- classname.exports = requireClassname_development();
145
- }
146
- var classnameExports = classname.exports;
145
+ (function(module2) {
146
+ if (process.env.NODE_ENV === "production") {
147
+ module2.exports = requireClassname_production_min();
148
+ } else {
149
+ module2.exports = requireClassname_development();
150
+ }
151
+ })(classname);
147
152
  const cn = classnameExports.withNaming({ n: "nut-", e: "__", m: "--", v: "-" });
148
153
  const defaultProps$1v = {
149
154
  name: "",
@@ -759,7 +764,6 @@ var __publicField = (obj, key, value) => {
759
764
  return string.match(pattern) || [];
760
765
  }
761
766
  var lodash_kebabcase = kebabCase;
762
- const kebabCase$1 = /* @__PURE__ */ getDefaultExportFromCjs(lodash_kebabcase);
763
767
  const zhCN = {
764
768
  save: "保存",
765
769
  confirm: "确认",
@@ -907,7 +911,7 @@ var __publicField = (obj, key, value) => {
907
911
  function convertThemeVarsToCSSVars(themeVars) {
908
912
  const cssVars = {};
909
913
  Object.keys(themeVars).forEach((key) => {
910
- cssVars[`--${kebabCase$1(key)}`] = themeVars[key];
914
+ cssVars[`--${lodash_kebabcase(key)}`] = themeVars[key];
911
915
  });
912
916
  return cssVars;
913
917
  }
@@ -1024,7 +1028,15 @@ var __publicField = (obj, key, value) => {
1024
1028
  };
1025
1029
  Image$1.defaultProps = defaultProps$1q;
1026
1030
  Image$1.displayName = "NutImage";
1027
- var classnames = { exports: {} };
1031
+ var classnamesExports = {};
1032
+ var classnames = {
1033
+ get exports() {
1034
+ return classnamesExports;
1035
+ },
1036
+ set exports(v) {
1037
+ classnamesExports = v;
1038
+ }
1039
+ };
1028
1040
  /*!
1029
1041
  Copyright (c) 2018 Jed Watson.
1030
1042
  Licensed under the MIT License (MIT), see
@@ -1071,8 +1083,7 @@ var __publicField = (obj, key, value) => {
1071
1083
  }
1072
1084
  })();
1073
1085
  })(classnames);
1074
- var classnamesExports = classnames.exports;
1075
- const classNames = /* @__PURE__ */ getDefaultExportFromCjs(classnamesExports);
1086
+ const classNames = classnamesExports;
1076
1087
  const defaultOverlayProps = {
1077
1088
  zIndex: 2e3,
1078
1089
  duration: 0.3,
@@ -1198,8 +1209,24 @@ var __publicField = (obj, key, value) => {
1198
1209
  subClass.prototype.constructor = subClass;
1199
1210
  _setPrototypeOf(subClass, superClass);
1200
1211
  }
1201
- var propTypes = { exports: {} };
1202
- var reactIs = { exports: {} };
1212
+ var propTypesExports = {};
1213
+ var propTypes = {
1214
+ get exports() {
1215
+ return propTypesExports;
1216
+ },
1217
+ set exports(v) {
1218
+ propTypesExports = v;
1219
+ }
1220
+ };
1221
+ var reactIsExports = {};
1222
+ var reactIs = {
1223
+ get exports() {
1224
+ return reactIsExports;
1225
+ },
1226
+ set exports(v) {
1227
+ reactIsExports = v;
1228
+ }
1229
+ };
1203
1230
  var reactIs_production_min = {};
1204
1231
  /** @license React v16.13.1
1205
1232
  * react-is.production.min.js
@@ -1470,14 +1497,16 @@ var __publicField = (obj, key, value) => {
1470
1497
  var hasRequiredReactIs;
1471
1498
  function requireReactIs() {
1472
1499
  if (hasRequiredReactIs)
1473
- return reactIs.exports;
1500
+ return reactIsExports;
1474
1501
  hasRequiredReactIs = 1;
1475
- if (process.env.NODE_ENV === "production") {
1476
- reactIs.exports = requireReactIs_production_min();
1477
- } else {
1478
- reactIs.exports = requireReactIs_development();
1479
- }
1480
- return reactIs.exports;
1502
+ (function(module2) {
1503
+ if (process.env.NODE_ENV === "production") {
1504
+ module2.exports = requireReactIs_production_min();
1505
+ } else {
1506
+ module2.exports = requireReactIs_development();
1507
+ }
1508
+ })(reactIs);
1509
+ return reactIsExports;
1481
1510
  }
1482
1511
  /*
1483
1512
  object-assign
@@ -2144,8 +2173,6 @@ var __publicField = (obj, key, value) => {
2144
2173
  } else {
2145
2174
  propTypes.exports = requireFactoryWithThrowingShims()();
2146
2175
  }
2147
- var propTypesExports = propTypes.exports;
2148
- const PropTypes = /* @__PURE__ */ getDefaultExportFromCjs(propTypesExports);
2149
2176
  function hasClass(element, className) {
2150
2177
  if (element.classList)
2151
2178
  return !!className && element.classList.contains(className);
@@ -2175,22 +2202,22 @@ var __publicField = (obj, key, value) => {
2175
2202
  const config$1 = {
2176
2203
  disabled: false
2177
2204
  };
2178
- var timeoutsShape = process.env.NODE_ENV !== "production" ? PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
2179
- enter: PropTypes.number,
2180
- exit: PropTypes.number,
2181
- appear: PropTypes.number
2205
+ var timeoutsShape = process.env.NODE_ENV !== "production" ? propTypesExports.oneOfType([propTypesExports.number, propTypesExports.shape({
2206
+ enter: propTypesExports.number,
2207
+ exit: propTypesExports.number,
2208
+ appear: propTypesExports.number
2182
2209
  }).isRequired]) : null;
2183
- var classNamesShape = process.env.NODE_ENV !== "production" ? PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
2184
- enter: PropTypes.string,
2185
- exit: PropTypes.string,
2186
- active: PropTypes.string
2187
- }), PropTypes.shape({
2188
- enter: PropTypes.string,
2189
- enterDone: PropTypes.string,
2190
- enterActive: PropTypes.string,
2191
- exit: PropTypes.string,
2192
- exitDone: PropTypes.string,
2193
- exitActive: PropTypes.string
2210
+ var classNamesShape = process.env.NODE_ENV !== "production" ? propTypesExports.oneOfType([propTypesExports.string, propTypesExports.shape({
2211
+ enter: propTypesExports.string,
2212
+ exit: propTypesExports.string,
2213
+ active: propTypesExports.string
2214
+ }), propTypesExports.shape({
2215
+ enter: propTypesExports.string,
2216
+ enterDone: propTypesExports.string,
2217
+ enterActive: propTypesExports.string,
2218
+ exit: propTypesExports.string,
2219
+ exitDone: propTypesExports.string,
2220
+ exitActive: propTypesExports.string
2194
2221
  })]) : null;
2195
2222
  const TransitionGroupContext = React.createContext(null);
2196
2223
  var forceReflow = function forceReflow2(node) {
@@ -2440,10 +2467,10 @@ var __publicField = (obj, key, value) => {
2440
2467
  * (see
2441
2468
  * [test/CSSTransition-test.js](https://github.com/reactjs/react-transition-group/blob/13435f897b3ab71f6e19d724f145596f5910581c/test/CSSTransition-test.js#L362-L437)).
2442
2469
  */
2443
- nodeRef: PropTypes.shape({
2444
- current: typeof Element === "undefined" ? PropTypes.any : function(propValue, key, componentName, location, propFullName, secret) {
2470
+ nodeRef: propTypesExports.shape({
2471
+ current: typeof Element === "undefined" ? propTypesExports.any : function(propValue, key, componentName, location, propFullName, secret) {
2445
2472
  var value = propValue[key];
2446
- return PropTypes.instanceOf(value && "ownerDocument" in value ? value.ownerDocument.defaultView.Element : Element)(propValue, key, componentName, location, propFullName, secret);
2473
+ return propTypesExports.instanceOf(value && "ownerDocument" in value ? value.ownerDocument.defaultView.Element : Element)(propValue, key, componentName, location, propFullName, secret);
2447
2474
  }
2448
2475
  }),
2449
2476
  /**
@@ -2460,23 +2487,23 @@ var __publicField = (obj, key, value) => {
2460
2487
  * </Transition>
2461
2488
  * ```
2462
2489
  */
2463
- children: PropTypes.oneOfType([PropTypes.func.isRequired, PropTypes.element.isRequired]).isRequired,
2490
+ children: propTypesExports.oneOfType([propTypesExports.func.isRequired, propTypesExports.element.isRequired]).isRequired,
2464
2491
  /**
2465
2492
  * Show the component; triggers the enter or exit states
2466
2493
  */
2467
- in: PropTypes.bool,
2494
+ in: propTypesExports.bool,
2468
2495
  /**
2469
2496
  * By default the child component is mounted immediately along with
2470
2497
  * the parent `Transition` component. If you want to "lazy mount" the component on the
2471
2498
  * first `in={true}` you can set `mountOnEnter`. After the first enter transition the component will stay
2472
2499
  * mounted, even on "exited", unless you also specify `unmountOnExit`.
2473
2500
  */
2474
- mountOnEnter: PropTypes.bool,
2501
+ mountOnEnter: propTypesExports.bool,
2475
2502
  /**
2476
2503
  * By default the child component stays mounted after it reaches the `'exited'` state.
2477
2504
  * Set `unmountOnExit` if you'd prefer to unmount the component after it finishes exiting.
2478
2505
  */
2479
- unmountOnExit: PropTypes.bool,
2506
+ unmountOnExit: propTypesExports.bool,
2480
2507
  /**
2481
2508
  * By default the child component does not perform the enter transition when
2482
2509
  * it first mounts, regardless of the value of `in`. If you want this
@@ -2488,15 +2515,15 @@ var __publicField = (obj, key, value) => {
2488
2515
  * > additional `.appear-*` classes, that way you can choose to style it
2489
2516
  * > differently.
2490
2517
  */
2491
- appear: PropTypes.bool,
2518
+ appear: propTypesExports.bool,
2492
2519
  /**
2493
2520
  * Enable or disable enter transitions.
2494
2521
  */
2495
- enter: PropTypes.bool,
2522
+ enter: propTypesExports.bool,
2496
2523
  /**
2497
2524
  * Enable or disable exit transitions.
2498
2525
  */
2499
- exit: PropTypes.bool,
2526
+ exit: propTypesExports.bool,
2500
2527
  /**
2501
2528
  * The duration of the transition, in milliseconds.
2502
2529
  * Required unless `addEndListener` is provided.
@@ -2546,7 +2573,7 @@ var __publicField = (obj, key, value) => {
2546
2573
  * }}
2547
2574
  * ```
2548
2575
  */
2549
- addEndListener: PropTypes.func,
2576
+ addEndListener: propTypesExports.func,
2550
2577
  /**
2551
2578
  * Callback fired before the "entering" status is applied. An extra parameter
2552
2579
  * `isAppearing` is supplied to indicate if the enter stage is occurring on the initial mount
@@ -2555,7 +2582,7 @@ var __publicField = (obj, key, value) => {
2555
2582
  *
2556
2583
  * @type Function(node: HtmlElement, isAppearing: bool) -> void
2557
2584
  */
2558
- onEnter: PropTypes.func,
2585
+ onEnter: propTypesExports.func,
2559
2586
  /**
2560
2587
  * Callback fired after the "entering" status is applied. An extra parameter
2561
2588
  * `isAppearing` is supplied to indicate if the enter stage is occurring on the initial mount
@@ -2564,7 +2591,7 @@ var __publicField = (obj, key, value) => {
2564
2591
  *
2565
2592
  * @type Function(node: HtmlElement, isAppearing: bool)
2566
2593
  */
2567
- onEntering: PropTypes.func,
2594
+ onEntering: propTypesExports.func,
2568
2595
  /**
2569
2596
  * Callback fired after the "entered" status is applied. An extra parameter
2570
2597
  * `isAppearing` is supplied to indicate if the enter stage is occurring on the initial mount
@@ -2573,7 +2600,7 @@ var __publicField = (obj, key, value) => {
2573
2600
  *
2574
2601
  * @type Function(node: HtmlElement, isAppearing: bool) -> void
2575
2602
  */
2576
- onEntered: PropTypes.func,
2603
+ onEntered: propTypesExports.func,
2577
2604
  /**
2578
2605
  * Callback fired before the "exiting" status is applied.
2579
2606
  *
@@ -2581,7 +2608,7 @@ var __publicField = (obj, key, value) => {
2581
2608
  *
2582
2609
  * @type Function(node: HtmlElement) -> void
2583
2610
  */
2584
- onExit: PropTypes.func,
2611
+ onExit: propTypesExports.func,
2585
2612
  /**
2586
2613
  * Callback fired after the "exiting" status is applied.
2587
2614
  *
@@ -2589,7 +2616,7 @@ var __publicField = (obj, key, value) => {
2589
2616
  *
2590
2617
  * @type Function(node: HtmlElement) -> void
2591
2618
  */
2592
- onExiting: PropTypes.func,
2619
+ onExiting: propTypesExports.func,
2593
2620
  /**
2594
2621
  * Callback fired after the "exited" status is applied.
2595
2622
  *
@@ -2597,7 +2624,7 @@ var __publicField = (obj, key, value) => {
2597
2624
  *
2598
2625
  * @type Function(node: HtmlElement) -> void
2599
2626
  */
2600
- onExited: PropTypes.func
2627
+ onExited: propTypesExports.func
2601
2628
  } : {};
2602
2629
  function noop$2() {
2603
2630
  }
@@ -2836,7 +2863,7 @@ var __publicField = (obj, key, value) => {
2836
2863
  *
2837
2864
  * @type Function(node: HtmlElement, isAppearing: bool)
2838
2865
  */
2839
- onEnter: PropTypes.func,
2866
+ onEnter: propTypesExports.func,
2840
2867
  /**
2841
2868
  * A `<Transition>` callback fired immediately after the 'enter-active' or
2842
2869
  * 'appear-active' class is applied.
@@ -2845,7 +2872,7 @@ var __publicField = (obj, key, value) => {
2845
2872
  *
2846
2873
  * @type Function(node: HtmlElement, isAppearing: bool)
2847
2874
  */
2848
- onEntering: PropTypes.func,
2875
+ onEntering: propTypesExports.func,
2849
2876
  /**
2850
2877
  * A `<Transition>` callback fired immediately after the 'enter' or
2851
2878
  * 'appear' classes are **removed** and the `done` class is added to the DOM node.
@@ -2854,7 +2881,7 @@ var __publicField = (obj, key, value) => {
2854
2881
  *
2855
2882
  * @type Function(node: HtmlElement, isAppearing: bool)
2856
2883
  */
2857
- onEntered: PropTypes.func,
2884
+ onEntered: propTypesExports.func,
2858
2885
  /**
2859
2886
  * A `<Transition>` callback fired immediately after the 'exit' class is
2860
2887
  * applied.
@@ -2863,7 +2890,7 @@ var __publicField = (obj, key, value) => {
2863
2890
  *
2864
2891
  * @type Function(node: HtmlElement)
2865
2892
  */
2866
- onExit: PropTypes.func,
2893
+ onExit: propTypesExports.func,
2867
2894
  /**
2868
2895
  * A `<Transition>` callback fired immediately after the 'exit-active' is applied.
2869
2896
  *
@@ -2871,7 +2898,7 @@ var __publicField = (obj, key, value) => {
2871
2898
  *
2872
2899
  * @type Function(node: HtmlElement)
2873
2900
  */
2874
- onExiting: PropTypes.func,
2901
+ onExiting: propTypesExports.func,
2875
2902
  /**
2876
2903
  * A `<Transition>` callback fired immediately after the 'exit' classes
2877
2904
  * are **removed** and the `exit-done` class is added to the DOM node.
@@ -2880,7 +2907,7 @@ var __publicField = (obj, key, value) => {
2880
2907
  *
2881
2908
  * @type Function(node: HtmlElement)
2882
2909
  */
2883
- onExited: PropTypes.func
2910
+ onExited: propTypesExports.func
2884
2911
  }) : {};
2885
2912
  const CSSTransition$1 = CSSTransition;
2886
2913
  const defaultProps$1p = {
@@ -7889,314 +7916,320 @@ var __publicField = (obj, key, value) => {
7889
7916
  slotButton: null,
7890
7917
  slotInput: null
7891
7918
  };
7892
- const Input = React.forwardRef((props, ref) => {
7893
- const { locale } = useConfig$1();
7894
- const {
7895
- children,
7896
- type,
7897
- name,
7898
- defaultValue,
7899
- placeholder,
7900
- label,
7901
- labelClass,
7902
- labelWidth,
7903
- labelAlign,
7904
- colon,
7905
- inputAlign,
7906
- center,
7907
- required,
7908
- disabled,
7909
- readonly,
7910
- error,
7911
- maxlength,
7912
- leftIcon,
7913
- leftIconSize,
7914
- rightIcon,
7915
- rightIconSize,
7916
- clearable,
7917
- clearIcon,
7918
- clearSize,
7919
- border,
7920
- formatTrigger,
7921
- rules,
7922
- errorMessage,
7923
- errorMessageAlign,
7924
- showWordLimit,
7925
- autofocus,
7926
- style,
7927
- className,
7928
- rows,
7929
- slotButton,
7930
- slotInput,
7931
- onChange,
7932
- onBlur,
7933
- onFocus,
7934
- onClear,
7935
- formatter,
7936
- keypress,
7937
- onClickInput,
7938
- onClickLeftIcon,
7939
- onClickRightIcon,
7940
- onClick,
7941
- iconClassPrefix,
7942
- iconFontClassName,
7943
- ...rest
7944
- } = {
7945
- ...defaultProps$X,
7946
- ...props
7947
- };
7948
- const inputPlaceholder = placeholder || locale.placeholder;
7949
- const [inputValue, SetInputValue] = React.useState("");
7950
- const [active, SetActive] = React.useState(false);
7951
- const [classes, setClasses] = React.useState("");
7952
- const getModelValue = () => String(inputValue ?? "");
7953
- const inputRef = React.useRef(null);
7954
- React.useEffect(() => {
7955
- setClasses(inputClass);
7956
- SetInputValue(defaultValue);
7957
- }, [defaultValue]);
7958
- React.useEffect(() => {
7959
- if (inputValue) {
7960
- updateValue(getModelValue());
7961
- resetValidation();
7962
- }
7963
- }, [inputValue]);
7964
- React.useImperativeHandle(ref, () => {
7965
- return inputRef.current;
7966
- });
7967
- const inputClass = React.useCallback(() => {
7968
- const prefixCls = "nut-input";
7969
- return [
7970
- prefixCls,
7971
- `${center ? "center" : ""}`,
7972
- `${disabled ? `${prefixCls}-disabled` : ""}`,
7973
- `${required ? `${prefixCls}-required` : ""}`,
7974
- `${error ? `${prefixCls}-error` : ""}`,
7975
- `${border ? `${prefixCls}-border` : ""}`,
7976
- `${slotButton || rightIcon ? `${prefixCls}-right-mark` : ""}`
7977
- ].filter(Boolean).join(" ");
7978
- }, [disabled, required, error, border, slotButton, rightIcon, center]);
7979
- React.useEffect(() => {
7980
- setClasses(inputClass);
7981
- }, [disabled, required, error, border, slotButton, rightIcon, center]);
7982
- const updateValue = (value, trigger = "onChange") => {
7983
- var _a;
7984
- let val = value;
7985
- if (type === "tel") {
7986
- val = formatNumber(val, false, false);
7987
- }
7988
- if (["number", "digit"].includes(type)) {
7989
- val = formatNumber(val, true, true);
7990
- }
7991
- if (type === "tel" && !formatter) {
7992
- 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}$/;
7993
- const regNumber = /[^-0-9]/g;
7994
- val = !regTel.test(val) && val.length > 11 ? val.substring(0, 11) : val.replace(regNumber, "");
7995
- }
7996
- if (formatter && trigger === formatTrigger) {
7997
- val = formatter(val);
7998
- }
7999
- if (((_a = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _a.value) !== val) {
8000
- inputRef.current.value = val;
8001
- }
8002
- SetInputValue(val);
8003
- };
8004
- const handleFocus = (event) => {
8005
- const val = event.target.value;
8006
- SetActive(true);
8007
- onFocus && onFocus(val, event);
8008
- };
8009
- const handleInput = (event) => {
8010
- let val = event.target.value;
8011
- if (maxlength && val.length > Number(maxlength)) {
8012
- val = val.slice(0, Number(maxlength));
8013
- }
8014
- updateValue(val, "onChange");
8015
- onChange && onChange(val, event);
8016
- };
8017
- const handleBlur = (event) => {
8018
- setTimeout(() => {
8019
- SetActive(false);
8020
- }, 200);
8021
- let val = event.target.value;
8022
- if (maxlength && val.length > Number(maxlength)) {
8023
- val = val.slice(0, Number(maxlength));
8024
- }
8025
- updateValue(val, "onBlur");
8026
- onBlur && onBlur(val, event);
8027
- };
8028
- const handleClickInput = (event) => {
8029
- onClickInput && onClickInput(event);
8030
- };
8031
- const handleClickLeftIcon = (event) => {
8032
- onClickLeftIcon && onClickLeftIcon(event);
8033
- };
8034
- const handleClickRightIcon = (event) => {
8035
- onClickRightIcon && onClickRightIcon(event);
8036
- };
8037
- const resetValidation = () => {
8038
- };
8039
- const inputType = (type2) => {
8040
- if (type2 === "tel") {
8041
- return "text";
8042
- }
8043
- return type2;
8044
- };
8045
- const handleClear = (event) => {
8046
- updateValue("");
8047
- onClear && onClear("", event);
8048
- };
8049
- return /* @__PURE__ */ React.createElement(
8050
- "div",
8051
- {
8052
- className: `${classes} ${className || ""}`,
7919
+ const Input = React.forwardRef(
7920
+ (props, ref) => {
7921
+ const { locale } = useConfig$1();
7922
+ const {
7923
+ children,
7924
+ type,
7925
+ name,
7926
+ defaultValue,
7927
+ placeholder,
7928
+ label,
7929
+ labelClass,
7930
+ labelWidth,
7931
+ labelAlign,
7932
+ colon,
7933
+ inputAlign,
7934
+ center,
7935
+ required,
7936
+ disabled,
7937
+ readonly,
7938
+ error,
7939
+ maxlength,
7940
+ leftIcon,
7941
+ leftIconSize,
7942
+ rightIcon,
7943
+ rightIconSize,
7944
+ clearable,
7945
+ clearIcon,
7946
+ clearSize,
7947
+ border,
7948
+ formatTrigger,
7949
+ rules,
7950
+ errorMessage,
7951
+ errorMessageAlign,
7952
+ showWordLimit,
7953
+ autofocus,
8053
7954
  style,
8054
- onClick: (e) => {
8055
- onClick && onClick(e);
7955
+ className,
7956
+ rows,
7957
+ slotButton,
7958
+ slotInput,
7959
+ onChange,
7960
+ onBlur,
7961
+ onFocus,
7962
+ onClear,
7963
+ formatter,
7964
+ keypress,
7965
+ onClickInput,
7966
+ onClickLeftIcon,
7967
+ onClickRightIcon,
7968
+ onClick,
7969
+ iconClassPrefix,
7970
+ iconFontClassName,
7971
+ ...rest
7972
+ } = {
7973
+ ...defaultProps$X,
7974
+ ...props
7975
+ };
7976
+ const inputPlaceholder = placeholder || locale.placeholder;
7977
+ const [inputValue, SetInputValue] = React.useState("");
7978
+ const [active, SetActive] = React.useState(false);
7979
+ const [classes, setClasses] = React.useState("");
7980
+ const getModelValue = () => String(inputValue ?? "");
7981
+ const inputRef = React.useRef(null);
7982
+ React.useEffect(() => {
7983
+ setClasses(inputClass);
7984
+ SetInputValue(defaultValue);
7985
+ }, [defaultValue]);
7986
+ React.useEffect(() => {
7987
+ if (inputValue) {
7988
+ updateValue(getModelValue());
7989
+ resetValidation();
8056
7990
  }
8057
- },
8058
- slotInput ? /* @__PURE__ */ React.createElement(React.Fragment, null, label ? /* @__PURE__ */ React.createElement(
8059
- "div",
8060
- {
8061
- className: `nut-input-label ${labelClass}`,
8062
- style: { width: `${labelWidth}px`, textAlign: labelAlign }
8063
- },
8064
- /* @__PURE__ */ React.createElement("div", { className: "label-string" }, label, colon ? ":" : "")
8065
- ) : null, /* @__PURE__ */ React.createElement("div", { className: "nut-input-value" }, /* @__PURE__ */ React.createElement(
8066
- "div",
8067
- {
8068
- className: "nut-input-inner",
8069
- onClick: (e) => {
8070
- handleClickInput(e);
8071
- }
8072
- },
8073
- slotInput
8074
- ))) : /* @__PURE__ */ React.createElement(React.Fragment, null, leftIcon && leftIcon.length > 0 ? /* @__PURE__ */ React.createElement(
7991
+ }, [inputValue]);
7992
+ React.useImperativeHandle(ref, () => {
7993
+ return inputRef.current;
7994
+ });
7995
+ const inputClass = React.useCallback(() => {
7996
+ const prefixCls = "nut-input";
7997
+ return [
7998
+ prefixCls,
7999
+ `${center ? "center" : ""}`,
8000
+ `${disabled ? `${prefixCls}-disabled` : ""}`,
8001
+ `${required ? `${prefixCls}-required` : ""}`,
8002
+ `${error ? `${prefixCls}-error` : ""}`,
8003
+ `${border ? `${prefixCls}-border` : ""}`,
8004
+ `${slotButton || rightIcon ? `${prefixCls}-right-mark` : ""}`
8005
+ ].filter(Boolean).join(" ");
8006
+ }, [disabled, required, error, border, slotButton, rightIcon, center]);
8007
+ React.useEffect(() => {
8008
+ setClasses(inputClass);
8009
+ }, [disabled, required, error, border, slotButton, rightIcon, center]);
8010
+ const updateValue = (value, trigger = "onChange") => {
8011
+ var _a;
8012
+ let val = value;
8013
+ if (type === "tel") {
8014
+ val = formatNumber(val, false, false);
8015
+ }
8016
+ if (["number", "digit"].includes(type)) {
8017
+ val = formatNumber(val, true, true);
8018
+ }
8019
+ if (type === "tel" && !formatter) {
8020
+ 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}$/;
8021
+ const regNumber = /[^-0-9]/g;
8022
+ val = !regTel.test(val) && val.length > 11 ? val.substring(0, 11) : val.replace(regNumber, "");
8023
+ }
8024
+ if (formatter && trigger === formatTrigger) {
8025
+ val = formatter(val);
8026
+ }
8027
+ if (((_a = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _a.value) !== val) {
8028
+ inputRef.current.value = val;
8029
+ }
8030
+ SetInputValue(val);
8031
+ };
8032
+ const handleFocus = (event) => {
8033
+ const val = event.target.value;
8034
+ SetActive(true);
8035
+ onFocus && onFocus(val, event);
8036
+ };
8037
+ const handleInput = (event) => {
8038
+ let val = event.target.value;
8039
+ if (maxlength && val.length > Number(maxlength)) {
8040
+ val = val.slice(0, Number(maxlength));
8041
+ }
8042
+ updateValue(val, "onChange");
8043
+ onChange && onChange(val, event);
8044
+ };
8045
+ const handleBlur = (event) => {
8046
+ SetActive(false);
8047
+ let val = event.target.value;
8048
+ if (maxlength && val.length > Number(maxlength)) {
8049
+ val = val.slice(0, Number(maxlength));
8050
+ }
8051
+ updateValue(val, "onBlur");
8052
+ onBlur && onBlur(val, event);
8053
+ };
8054
+ const handleClickInput = (event) => {
8055
+ onClickInput && onClickInput(event);
8056
+ };
8057
+ const handleClickLeftIcon = (event) => {
8058
+ onClickLeftIcon && onClickLeftIcon(event);
8059
+ };
8060
+ const handleClickRightIcon = (event) => {
8061
+ onClickRightIcon && onClickRightIcon(event);
8062
+ };
8063
+ const resetValidation = () => {
8064
+ };
8065
+ const inputType = (type2) => {
8066
+ if (type2 === "tel") {
8067
+ return "text";
8068
+ }
8069
+ return type2;
8070
+ };
8071
+ const handleClear = (event) => {
8072
+ setTimeout(() => {
8073
+ updateValue("");
8074
+ onClear && onClear("", event);
8075
+ }, 50);
8076
+ };
8077
+ return /* @__PURE__ */ React.createElement(
8075
8078
  "div",
8076
8079
  {
8077
- className: "nut-input-left-icon",
8080
+ className: `${classes} ${className || ""}`,
8081
+ style,
8078
8082
  onClick: (e) => {
8079
- handleClickLeftIcon(e);
8083
+ onClick && onClick(e);
8080
8084
  }
8081
8085
  },
8082
- /* @__PURE__ */ React.createElement(
8083
- Icon$1,
8086
+ slotInput ? /* @__PURE__ */ React.createElement(React.Fragment, null, label ? /* @__PURE__ */ React.createElement(
8087
+ "div",
8084
8088
  {
8085
- classPrefix: iconClassPrefix,
8086
- fontClassName: iconFontClassName,
8087
- name: leftIcon,
8088
- size: leftIconSize
8089
- }
8090
- )
8091
- ) : null, label ? /* @__PURE__ */ React.createElement(
8092
- "div",
8093
- {
8094
- className: `nut-input-label ${labelClass}`,
8095
- style: { width: `${labelWidth}px`, textAlign: labelAlign }
8096
- },
8097
- /* @__PURE__ */ React.createElement("div", { className: "label-string" }, label, colon ? ":" : "")
8098
- ) : null, /* @__PURE__ */ React.createElement("div", { className: "nut-input-value" }, /* @__PURE__ */ React.createElement("div", { className: "nut-input-main-con" }, /* @__PURE__ */ React.createElement(
8099
- "div",
8100
- {
8101
- className: "nut-input-inner",
8102
- onClick: (e) => {
8103
- handleClickInput(e);
8104
- }
8105
- },
8106
- type === "textarea" ? /* @__PURE__ */ React.createElement(
8107
- "textarea",
8089
+ className: `nut-input-label ${labelClass}`,
8090
+ style: { width: `${labelWidth}px`, textAlign: labelAlign }
8091
+ },
8092
+ /* @__PURE__ */ React.createElement("div", { className: "label-string" }, label, colon ? ":" : "")
8093
+ ) : null, /* @__PURE__ */ React.createElement("div", { className: "nut-input-value" }, /* @__PURE__ */ React.createElement(
8094
+ "div",
8108
8095
  {
8109
- name,
8110
- className: "input-text",
8111
- ref: inputRef,
8112
- style: {
8113
- textAlign: inputAlign,
8114
- height: `${Number(rows) * 24}px`
8115
- },
8116
- maxLength: maxlength,
8117
- placeholder: inputPlaceholder,
8118
- disabled,
8119
- readOnly: readonly,
8120
- value: inputValue,
8121
- autoFocus: autofocus,
8122
- onBlur: (e) => {
8123
- handleBlur(e);
8124
- },
8125
- onFocus: (e) => {
8126
- handleFocus(e);
8127
- },
8128
- onInput: (e) => {
8129
- handleInput(e);
8096
+ className: "nut-input-inner",
8097
+ onClick: (e) => {
8098
+ handleClickInput(e);
8130
8099
  }
8131
- }
8132
- ) : /* @__PURE__ */ React.createElement(
8133
- "input",
8100
+ },
8101
+ slotInput
8102
+ ))) : /* @__PURE__ */ React.createElement(React.Fragment, null, leftIcon && leftIcon.length > 0 ? /* @__PURE__ */ React.createElement(
8103
+ "div",
8134
8104
  {
8135
- ...rest,
8136
- name,
8137
- className: "input-text",
8138
- ref: inputRef,
8139
- style: { textAlign: inputAlign },
8140
- type: inputType(type),
8141
- maxLength: maxlength,
8142
- placeholder: inputPlaceholder,
8143
- disabled,
8144
- readOnly: readonly,
8145
- value: inputValue,
8146
- autoFocus: autofocus,
8147
- onBlur: (e) => {
8148
- handleBlur(e);
8149
- },
8150
- onFocus: (e) => {
8151
- handleFocus(e);
8152
- },
8153
- onInput: (e) => {
8154
- handleInput(e);
8105
+ className: "nut-input-left-icon",
8106
+ onClick: (e) => {
8107
+ handleClickLeftIcon(e);
8155
8108
  }
8156
- }
8157
- ),
8158
- clearable && !readonly && active && inputValue.length > 0 ? /* @__PURE__ */ React.createElement(
8159
- Icon$1,
8109
+ },
8110
+ /* @__PURE__ */ React.createElement(
8111
+ Icon$1,
8112
+ {
8113
+ classPrefix: iconClassPrefix,
8114
+ fontClassName: iconFontClassName,
8115
+ name: leftIcon,
8116
+ size: leftIconSize
8117
+ }
8118
+ )
8119
+ ) : null, label ? /* @__PURE__ */ React.createElement(
8120
+ "div",
8160
8121
  {
8161
- classPrefix: iconClassPrefix,
8162
- fontClassName: iconFontClassName,
8163
- className: "nut-input-clear",
8164
- name: clearIcon,
8165
- size: clearSize,
8122
+ className: `nut-input-label ${labelClass}`,
8123
+ style: { width: `${labelWidth}px`, textAlign: labelAlign }
8124
+ },
8125
+ /* @__PURE__ */ React.createElement("div", { className: "label-string" }, label, colon ? ":" : "")
8126
+ ) : null, /* @__PURE__ */ React.createElement("div", { className: "nut-input-value" }, /* @__PURE__ */ React.createElement("div", { className: "nut-input-main-con" }, /* @__PURE__ */ React.createElement(
8127
+ "div",
8128
+ {
8129
+ className: "nut-input-inner",
8166
8130
  onClick: (e) => {
8167
- handleClear(e);
8131
+ handleClickInput(e);
8168
8132
  }
8169
- }
8170
- ) : null
8171
- ), rightIcon && rightIcon.length > 0 ? /* @__PURE__ */ React.createElement(
8172
- "div",
8173
- {
8174
- className: "nut-input-right-icon",
8175
- onClick: (e) => {
8176
- handleClickRightIcon(e);
8177
- }
8178
- },
8179
- /* @__PURE__ */ React.createElement(
8180
- Icon$1,
8133
+ },
8134
+ type === "textarea" ? /* @__PURE__ */ React.createElement(
8135
+ "textarea",
8136
+ {
8137
+ name,
8138
+ className: "input-text",
8139
+ ref: inputRef,
8140
+ style: {
8141
+ textAlign: inputAlign,
8142
+ height: `${Number(rows) * 24}px`
8143
+ },
8144
+ maxLength: maxlength,
8145
+ placeholder: inputPlaceholder,
8146
+ disabled,
8147
+ readOnly: readonly,
8148
+ value: inputValue,
8149
+ autoFocus: autofocus,
8150
+ onBlur: (e) => {
8151
+ handleBlur(e);
8152
+ },
8153
+ onFocus: (e) => {
8154
+ handleFocus(e);
8155
+ },
8156
+ onInput: (e) => {
8157
+ handleInput(e);
8158
+ }
8159
+ }
8160
+ ) : /* @__PURE__ */ React.createElement(
8161
+ "input",
8162
+ {
8163
+ ...rest,
8164
+ name,
8165
+ className: "input-text",
8166
+ ref: inputRef,
8167
+ style: { textAlign: inputAlign },
8168
+ type: inputType(type),
8169
+ maxLength: maxlength,
8170
+ placeholder: inputPlaceholder,
8171
+ disabled,
8172
+ readOnly: readonly,
8173
+ value: inputValue,
8174
+ autoFocus: autofocus,
8175
+ onBlur: (e) => {
8176
+ handleBlur(e);
8177
+ },
8178
+ onFocus: (e) => {
8179
+ handleFocus(e);
8180
+ },
8181
+ onInput: (e) => {
8182
+ handleInput(e);
8183
+ }
8184
+ }
8185
+ ),
8186
+ /* @__PURE__ */ React.createElement(
8187
+ Icon$1,
8188
+ {
8189
+ style: {
8190
+ display: clearable && !readonly && active && inputValue.length > 0 ? "inline-flex" : "none",
8191
+ alignItems: "center"
8192
+ },
8193
+ classPrefix: iconClassPrefix,
8194
+ fontClassName: iconFontClassName,
8195
+ className: "nut-input-clear",
8196
+ name: clearIcon,
8197
+ size: clearSize,
8198
+ onClick: (e) => {
8199
+ handleClear(e);
8200
+ }
8201
+ }
8202
+ )
8203
+ ), rightIcon && rightIcon.length > 0 ? /* @__PURE__ */ React.createElement(
8204
+ "div",
8181
8205
  {
8182
- classPrefix: iconClassPrefix,
8183
- fontClassName: iconFontClassName,
8184
- name: rightIcon,
8185
- size: rightIconSize
8186
- }
8187
- )
8188
- ) : null, slotButton ? /* @__PURE__ */ React.createElement("div", { className: "nut-input-button" }, slotButton) : null, showWordLimit && maxlength ? /* @__PURE__ */ React.createElement("div", { className: "nut-input-word-limit" }, /* @__PURE__ */ React.createElement("span", { className: "nut-input-word-num" }, inputValue ? inputValue.length : 0), "/", maxlength) : null), errorMessage ? /* @__PURE__ */ React.createElement(
8189
- "div",
8190
- {
8191
- className: "nut-input-error-message",
8192
- style: {
8193
- textAlign: errorMessageAlign
8194
- }
8195
- },
8196
- errorMessage
8197
- ) : /* @__PURE__ */ React.createElement("div", null)))
8198
- );
8199
- });
8206
+ className: "nut-input-right-icon",
8207
+ onClick: (e) => {
8208
+ handleClickRightIcon(e);
8209
+ }
8210
+ },
8211
+ /* @__PURE__ */ React.createElement(
8212
+ Icon$1,
8213
+ {
8214
+ classPrefix: iconClassPrefix,
8215
+ fontClassName: iconFontClassName,
8216
+ name: rightIcon,
8217
+ size: rightIconSize
8218
+ }
8219
+ )
8220
+ ) : null, slotButton ? /* @__PURE__ */ React.createElement("div", { className: "nut-input-button" }, slotButton) : null, showWordLimit && maxlength ? /* @__PURE__ */ React.createElement("div", { className: "nut-input-word-limit" }, /* @__PURE__ */ React.createElement("span", { className: "nut-input-word-num" }, inputValue ? inputValue.length : 0), "/", maxlength) : null), errorMessage ? /* @__PURE__ */ React.createElement(
8221
+ "div",
8222
+ {
8223
+ className: "nut-input-error-message",
8224
+ style: {
8225
+ textAlign: errorMessageAlign
8226
+ }
8227
+ },
8228
+ errorMessage
8229
+ ) : /* @__PURE__ */ React.createElement("div", null)))
8230
+ );
8231
+ }
8232
+ );
8200
8233
  Input.defaultProps = defaultProps$X;
8201
8234
  Input.displayName = "NutInput";
8202
8235
  const defaultProps$W = {