@nutui/nutui-react 1.4.13 → 1.4.14-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.
@@ -9,7 +9,7 @@ var __publicField = (obj, key, value) => {
9
9
  return value;
10
10
  };
11
11
  /*!
12
- * @nutui/nutui-react v1.4.13 Wed Mar 29 2023 15:59:34 GMT+0800 (China Standard Time)
12
+ * @nutui/nutui-react v1.4.14-beta.0 Thu Apr 06 2023 15:51:39 GMT+0800 (China Standard Time)
13
13
  * (c) 2023 @jdf2e.
14
14
  * Released under the MIT License.
15
15
  */
@@ -10204,7 +10204,7 @@ Please add \`${key}Action\` when creating your handler.`);
10204
10204
  * @return {String}
10205
10205
  */
10206
10206
  getWhatDay(year, month, day) {
10207
- const date2 = /* @__PURE__ */ new Date(`${year}/${month}/${day}`);
10207
+ const date2 = new Date(`${year}/${month}/${day}`);
10208
10208
  const index = date2.getDay();
10209
10209
  const dayNames = [
10210
10210
  "星期日",
@@ -10222,7 +10222,7 @@ Please add \`${key}Action\` when creating your handler.`);
10222
10222
  * @return {Number}
10223
10223
  */
10224
10224
  getMonthPreDay(year, month) {
10225
- const date2 = /* @__PURE__ */ new Date(`${year}/${month}/01`);
10225
+ const date2 = new Date(`${year}/${month}/01`);
10226
10226
  let day = date2.getDay();
10227
10227
  if (day == 0) {
10228
10228
  day = 7;
@@ -10279,7 +10279,7 @@ Please add \`${key}Action\` when creating your handler.`);
10279
10279
  */
10280
10280
  getDay(i) {
10281
10281
  i = i || 0;
10282
- let date2 = /* @__PURE__ */ new Date();
10282
+ let date2 = new Date();
10283
10283
  const diff = i * (1e3 * 60 * 60 * 24);
10284
10284
  date2 = new Date(date2.getTime() + diff);
10285
10285
  return this.date2Str(date2);
@@ -10469,7 +10469,7 @@ Please add \`${key}Action\` when creating your handler.`);
10469
10469
  };
10470
10470
  const isCurrDay = (month, day) => {
10471
10471
  const date2 = `${month.curData[0]}-${month.curData[1]}-${day}`;
10472
- return Utils.isEqual(date2, Utils.date2Str(/* @__PURE__ */ new Date()));
10472
+ return Utils.isEqual(date2, Utils.date2Str(new Date()));
10473
10473
  };
10474
10474
  const confirm2 = () => {
10475
10475
  const { type: type22 } = props;
@@ -10805,8 +10805,8 @@ Please add \`${key}Action\` when creating your handler.`);
10805
10805
  }
10806
10806
  });
10807
10807
  } else {
10808
- const currentYear2 = (/* @__PURE__ */ new Date()).getFullYear();
10809
- const currentMonth = (/* @__PURE__ */ new Date()).getMonth() + 1;
10808
+ const currentYear2 = new Date().getFullYear();
10809
+ const currentMonth = new Date().getMonth() + 1;
10810
10810
  const currentYearMonthIndex = state.monthsData.findIndex((item) => {
10811
10811
  return +item.curData[0] === currentYear2 && +item.curData[1] === currentMonth;
10812
10812
  });
@@ -11906,7 +11906,6 @@ Please add \`${key}Action\` when creating your handler.`);
11906
11906
  const rotation = 20;
11907
11907
  const moving = React.useRef(false);
11908
11908
  let timer;
11909
- React.useRef(null);
11910
11909
  const rollerRef = React.useRef(null);
11911
11910
  const pickerSlotRef = React.useRef(null);
11912
11911
  const [startTime, setStartTime] = React.useState(0);
@@ -12313,7 +12312,7 @@ Please add \`${key}Action\` when creating your handler.`);
12313
12312
  };
12314
12313
  const Picker = React.forwardRef(InternalPicker);
12315
12314
  const Picker$1 = Picker;
12316
- const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
12315
+ const currentYear = new Date().getFullYear();
12317
12316
  const defaultProps$X = {
12318
12317
  modelValue: null,
12319
12318
  visible: false,
@@ -14189,7 +14188,7 @@ Please add \`${key}Action\` when creating your handler.`);
14189
14188
  if (maxlength && val.length > Number(maxlength)) {
14190
14189
  val = val.slice(0, Number(maxlength));
14191
14190
  }
14192
- updateValue(getModelValue(), "onBlur");
14191
+ updateValue(val, "onBlur");
14193
14192
  onBlur && onBlur(val, event);
14194
14193
  };
14195
14194
  const handleClickInput = (event) => {
@@ -14400,6 +14399,7 @@ Please add \`${key}Action\` when creating your handler.`);
14400
14399
  isAsync,
14401
14400
  className,
14402
14401
  style,
14402
+ formatter,
14403
14403
  add,
14404
14404
  reduce,
14405
14405
  change,
@@ -14420,9 +14420,15 @@ Please add \`${key}Action\` when creating your handler.`);
14420
14420
  ...props
14421
14421
  };
14422
14422
  const [inputValue, setInputValue] = React.useState(modelValue);
14423
+ const inputRef = React.useRef("");
14423
14424
  React.useEffect(() => {
14424
- setInputValue(modelValue);
14425
- }, [modelValue]);
14425
+ if (formatter) {
14426
+ inputRef.current = formatter(modelValue);
14427
+ setInputValue(formatter(modelValue));
14428
+ } else {
14429
+ setInputValue(modelValue);
14430
+ }
14431
+ }, [modelValue, formatter]);
14426
14432
  const b2 = cn("inputnumber");
14427
14433
  const classes = classNames(
14428
14434
  {
@@ -14436,12 +14442,20 @@ Please add \`${key}Action\` when creating your handler.`);
14436
14442
  ...style
14437
14443
  };
14438
14444
  const addAllow = (value = inputValue) => {
14445
+ if (formatter) {
14446
+ const numValue = String(value).replace(/[^0-9|\.]/gi, "");
14447
+ return Number(numValue) < Number(max) && !disabled;
14448
+ }
14439
14449
  if (value || typeof value === "number") {
14440
14450
  return value < Number(max) && !disabled;
14441
14451
  }
14442
14452
  return false;
14443
14453
  };
14444
14454
  const reduceAllow = (value = inputValue) => {
14455
+ if (formatter) {
14456
+ const numValue = String(value).replace(/[^0-9|\.]/gi, "");
14457
+ return Number(numValue) > Number(min) && !disabled;
14458
+ }
14445
14459
  if (value || typeof value === "number") {
14446
14460
  return value > Number(min) && !disabled;
14447
14461
  }
@@ -14462,11 +14476,11 @@ Please add \`${key}Action\` when creating your handler.`);
14462
14476
  change && change(outputValue, e);
14463
14477
  if (!isAsync) {
14464
14478
  if (Number(outputValue) < Number(min)) {
14465
- setInputValue(Number(min));
14479
+ formatter ? setInputValue(formatter(Number(min))) : setInputValue(Number(min));
14466
14480
  } else if (Number(outputValue) > Number(max)) {
14467
- setInputValue(Number(max));
14481
+ formatter ? setInputValue(formatter(Number(max))) : setInputValue(Number(max));
14468
14482
  } else {
14469
- setInputValue(outputValue);
14483
+ formatter ? setInputValue(formatter(outputValue)) : setInputValue(outputValue);
14470
14484
  }
14471
14485
  }
14472
14486
  };
@@ -14474,8 +14488,15 @@ Please add \`${key}Action\` when creating your handler.`);
14474
14488
  onReduce && onReduce(e);
14475
14489
  reduce && reduce(e);
14476
14490
  if (reduceAllow()) {
14477
- const outputValue = Number(inputValue) - Number(step);
14478
- emitChange(outputValue, e);
14491
+ if (formatter) {
14492
+ const numValue = String(inputValue).replace(/[^0-9|\.]/gi, "");
14493
+ const outputValue = Number(numValue) - Number(step);
14494
+ inputRef.current = formatter(outputValue);
14495
+ emitChange(outputValue, e);
14496
+ } else {
14497
+ const outputValue = Number(inputValue) - Number(step);
14498
+ emitChange(outputValue, e);
14499
+ }
14479
14500
  } else {
14480
14501
  onOverlimit && onOverlimit(e);
14481
14502
  overlimit && overlimit(e);
@@ -14485,8 +14506,15 @@ Please add \`${key}Action\` when creating your handler.`);
14485
14506
  onAdd && onAdd(e);
14486
14507
  add && add(e);
14487
14508
  if (addAllow()) {
14488
- const outputValue = Number(inputValue) + Number(step);
14489
- emitChange(outputValue, e);
14509
+ if (formatter) {
14510
+ const numValue = String(inputValue).replace(/[^0-9|\.]/gi, "");
14511
+ const outputValue = Number(numValue) + Number(step);
14512
+ inputRef.current = formatter(outputValue);
14513
+ emitChange(outputValue, e);
14514
+ } else {
14515
+ const outputValue = Number(inputValue) + Number(step);
14516
+ emitChange(outputValue, e);
14517
+ }
14490
14518
  } else {
14491
14519
  onOverlimit && onOverlimit(e);
14492
14520
  overlimit && overlimit(e);
@@ -14504,6 +14532,41 @@ Please add \`${key}Action\` when creating your handler.`);
14504
14532
  }
14505
14533
  }
14506
14534
  };
14535
+ const changeFormatValue = (e) => {
14536
+ const input = e.target.value;
14537
+ const numReg = new RegExp("^[0-9]*$");
14538
+ const numValue = input.replace(/[^0-9|\.]/gi, "");
14539
+ if (formatter) {
14540
+ if (!numReg.test(input[0]) && numValue) {
14541
+ setInputValue(formatter(numValue));
14542
+ } else if (!numReg.test(input[0]) && !numValue) {
14543
+ setInputValue(input);
14544
+ } else if (numReg.test(input[0])) {
14545
+ console.log("inputRef.current", inputRef.current);
14546
+ console.log("formatter(numValue)", formatter(numValue));
14547
+ if (formatter(numValue) === inputRef.current) {
14548
+ setInputValue(numValue);
14549
+ } else {
14550
+ setInputValue(formatter(numValue));
14551
+ inputRef.current = formatter(numValue);
14552
+ }
14553
+ }
14554
+ }
14555
+ };
14556
+ const burFormatValue = (e) => {
14557
+ const input = e.target.value;
14558
+ const numReg = new RegExp("^[0-9]*$");
14559
+ const numValue = input.replace(/[^0-9|\.]/gi, "");
14560
+ if (formatter) {
14561
+ if (formatter(numValue) === input) {
14562
+ emitChange(numValue, e);
14563
+ return;
14564
+ }
14565
+ if (!numReg.test(input) || !input) {
14566
+ setInputValue(formatter(""));
14567
+ }
14568
+ }
14569
+ };
14507
14570
  const focusValue = (e) => {
14508
14571
  if (disabled)
14509
14572
  return;
@@ -14538,7 +14601,21 @@ Please add \`${key}Action\` when creating your handler.`);
14538
14601
  name: "minus",
14539
14602
  onClick: reduceNumber
14540
14603
  }
14541
- )), /* @__PURE__ */ React.createElement(
14604
+ )), /* @__PURE__ */ React.createElement(React.Fragment, null, formatter ? /* @__PURE__ */ React.createElement(
14605
+ "input",
14606
+ {
14607
+ type: "text",
14608
+ min,
14609
+ max,
14610
+ style: { width: pxCheck(inputWidth) },
14611
+ disabled,
14612
+ readOnly: readonly,
14613
+ value: inputValue,
14614
+ onInput: changeFormatValue,
14615
+ onBlur: burFormatValue,
14616
+ onFocus: focusValue
14617
+ }
14618
+ ) : /* @__PURE__ */ React.createElement(
14542
14619
  "input",
14543
14620
  {
14544
14621
  type: "number",
@@ -14552,7 +14629,7 @@ Please add \`${key}Action\` when creating your handler.`);
14552
14629
  onBlur: burValue,
14553
14630
  onFocus: focusValue
14554
14631
  }
14555
- ), /* @__PURE__ */ React.createElement("div", { className: "nut-input-add" }, /* @__PURE__ */ React.createElement(
14632
+ )), /* @__PURE__ */ React.createElement("div", { className: "nut-input-add" }, /* @__PURE__ */ React.createElement(
14556
14633
  Icon,
14557
14634
  {
14558
14635
  classPrefix: iconClassPrefix,
@@ -16517,7 +16594,7 @@ Please add \`${key}Action\` when creating your handler.`);
16517
16594
  constructor() {
16518
16595
  __publicField(this, "status", "ready");
16519
16596
  __publicField(this, "message", "准备中..");
16520
- __publicField(this, "uid", (/* @__PURE__ */ new Date()).getTime().toString());
16597
+ __publicField(this, "uid", new Date().getTime().toString());
16521
16598
  __publicField(this, "name");
16522
16599
  __publicField(this, "url");
16523
16600
  __publicField(this, "type");
@@ -17080,7 +17157,7 @@ Please add \`${key}Action\` when creating your handler.`);
17080
17157
  };
17081
17158
  const scrollAnimation = () => {
17082
17159
  let cid = requestAniFrame2()(function fn() {
17083
- const t = duration - Math.max(0, startTime - +/* @__PURE__ */ new Date() + duration / 2);
17160
+ const t = duration - Math.max(0, startTime - +new Date() + duration / 2);
17084
17161
  const y = t * -scrollTop / duration + scrollTop;
17085
17162
  scroll(y);
17086
17163
  cid = requestAniFrame2()(fn);
@@ -17109,7 +17186,7 @@ Please add \`${key}Action\` when creating your handler.`);
17109
17186
  }
17110
17187
  const goTop = (e) => {
17111
17188
  onClick && onClick(e);
17112
- const otime = +/* @__PURE__ */ new Date();
17189
+ const otime = +new Date();
17113
17190
  startTime = otime;
17114
17191
  isAnimation && duration > 0 ? scrollAnimation() : scroll();
17115
17192
  };
@@ -17824,7 +17901,7 @@ Please add \`${key}Action\` when creating your handler.`);
17824
17901
  __publicField(Notification, "newInstance");
17825
17902
  Notification.newInstance = (properties, callback) => {
17826
17903
  const element = document.createElement("div");
17827
- const id = properties.id ? properties.id : `${(/* @__PURE__ */ new Date()).getTime()}`;
17904
+ const id = properties.id ? properties.id : `${new Date().getTime()}`;
17828
17905
  element.id = id;
17829
17906
  properties.id = id;
17830
17907
  document.body.appendChild(element);
@@ -20300,7 +20377,7 @@ Please add \`${key}Action\` when creating your handler.`);
20300
20377
  const touches = event.touches;
20301
20378
  const events = touches[0];
20302
20379
  const events2 = touches[1];
20303
- const curTouchTime = (/* @__PURE__ */ new Date()).getTime();
20380
+ const curTouchTime = new Date().getTime();
20304
20381
  if (curTouchTime - lastTouchEndTime < 300) {
20305
20382
  const store12 = store;
20306
20383
  if (store12.scale > 1) {
@@ -20354,7 +20431,7 @@ Please add \`${key}Action\` when creating your handler.`);
20354
20431
  }
20355
20432
  };
20356
20433
  const onTouchEnd = () => {
20357
- setLastTouchEndTime((/* @__PURE__ */ new Date()).getTime());
20434
+ setLastTouchEndTime(new Date().getTime());
20358
20435
  const store1 = store;
20359
20436
  store1.moveable = false;
20360
20437
  if (store1.scale < 1.1 && store1.scale > 1 || store1.scale < 1) {
@@ -88,45 +88,45 @@
88
88
  align-items: center;
89
89
  justify-content: space-between;
90
90
  padding: $picker-bar-button-padding;
91
+ }
91
92
 
92
- .nut-picker__cancel-btn {
93
- color: $picker-cancel-color;
94
- font-size: $picker-bar-cancel-font-size;
95
- }
93
+ .nut-picker__cancel-btn {
94
+ color: $picker-cancel-color;
95
+ font-size: $picker-bar-cancel-font-size;
96
+ }
96
97
 
97
- .nut-picker__confirm-btn {
98
- color: $picker-ok-color;
99
- font-size: $picker-bar-ok-font-size;
100
- }
98
+ .nut-picker__confirm-btn {
99
+ color: $picker-ok-color;
100
+ font-size: $picker-bar-ok-font-size;
101
+ }
101
102
 
102
- .nut-picker__title {
103
- flex: 1;
104
- overflow: hidden;
105
- text-overflow: ellipsis;
106
- white-space: nowrap;
107
- text-align: center;
108
- color: $picker-bar-title-color;
109
- font-size: $picker-bar-title-font-size;
110
- font-weight: $picker-bar-title-font-weight;
111
- }
103
+ .nut-picker__title {
104
+ flex: 1;
105
+ overflow: hidden;
106
+ text-overflow: ellipsis;
107
+ white-space: nowrap;
108
+ text-align: center;
109
+ color: $picker-bar-title-color;
110
+ font-size: $picker-bar-title-font-size;
111
+ font-weight: $picker-bar-title-font-weight;
112
112
  }
113
113
 
114
114
  .nut-picker__panel {
115
115
  display: flex;
116
116
  position: relative;
117
+ }
117
118
 
118
- .nut-picker-indicator {
119
- position: absolute;
120
- top: 108px;
121
- height: $picker-item-height;
122
- width: 100%;
123
- border: $picker-item-active-line-border;
124
- border-left: 0;
125
- border-right: 0;
126
- color: $picker-item-text-color;
127
- font-size: $picker-item-text-font-size;
128
- z-index: 3;
129
- }
119
+ .nut-picker-indicator {
120
+ position: absolute;
121
+ top: 108px;
122
+ height: $picker-item-height;
123
+ width: 100%;
124
+ border: $picker-item-active-line-border;
125
+ border-left: 0;
126
+ border-right: 0;
127
+ color: $picker-item-text-color;
128
+ font-size: $picker-item-text-font-size;
129
+ z-index: 3;
130
130
  }
131
131
 
132
132
  .nut-picker-list {
@@ -135,83 +135,89 @@
135
135
  height: $picker-list-height;
136
136
  overflow: hidden;
137
137
  text-align: center;
138
+ }
138
139
 
139
- .nut-picker-list-panel {
140
- transform-style: preserve-3d;
141
- }
140
+ .nut-picker-list-panel {
141
+ transform-style: preserve-3d;
142
+ }
142
143
 
143
- .nut-picker-mask {
144
- position: absolute;
145
- top: 0;
146
- left: 0;
147
- right: 0;
148
- bottom: 0;
149
- background-image: $picker-mask-bg-img;
150
- background-position: top, bottom;
151
- background-size: 100% 108px;
152
- background-repeat: no-repeat;
153
- z-index: 3;
154
- }
144
+ .nut-picker-mask {
145
+ position: absolute;
146
+ top: 0;
147
+ left: 0;
148
+ right: 0;
149
+ bottom: 0;
150
+ background-image: $picker-mask-bg-img;
151
+ background-position: top, bottom;
152
+ background-size: 100% 108px;
153
+ background-repeat: no-repeat;
154
+ z-index: 3;
155
+ }
155
156
 
156
- .nut-picker-content,
157
- .nut-picker-roller {
158
- position: absolute;
159
- top: 108px;
160
- width: 100%;
161
- height: $picker-item-height;
162
- }
157
+ .picker-view-panel {
158
+ height: $picker-list-height;
159
+ flex-grow: 1;
160
+ }
163
161
 
164
- .nut-picker-content {
165
- background: #fff;
166
- z-index: 2;
167
- overflow: hidden;
168
- }
162
+ .nut-picker-content,
163
+ .nut-picker-roller {
164
+ position: absolute;
165
+ top: 108px;
166
+ width: 100%;
167
+ height: $picker-item-height;
168
+ }
169
169
 
170
- .nut-picker-item,
171
- .nut-picker-roller-item {
172
- white-space: nowrap;
173
- overflow: hidden;
174
- text-overflow: ellipsis;
175
- height: $picker-item-height;
176
- line-height: $picker-item-height;
177
- color: $picker-item-text-color;
178
- font-size: $picker-item-text-font-size;
179
- text-align: center;
180
- }
170
+ .nut-picker-content {
171
+ background: #fff;
172
+ z-index: 2;
173
+ overflow: hidden;
174
+ }
181
175
 
182
- .nut-picker-item {
183
- font-size: 16px;
184
- background: #fff;
185
- }
176
+ .nut-picker-item,
177
+ .nut-picker-roller-item {
178
+ white-space: nowrap;
179
+ overflow: hidden;
180
+ text-overflow: ellipsis;
181
+ height: $picker-item-height;
182
+ line-height: $picker-item-height;
183
+ color: $picker-item-text-color;
184
+ font-size: $picker-item-text-font-size;
185
+ text-align: center;
186
+ }
186
187
 
187
- .nut-picker-roller {
188
- z-index: 1;
189
- transform-style: preserve-3d;
188
+ .nut-picker-item {
189
+ font-size: 16px;
190
+ background: #fff;
191
+ }
190
192
 
191
- .nut-picker-roller-item {
192
- backface-visibility: hidden;
193
- -moz-backface-visibility: hidden;
194
- -webkit-backface-visibility: hidden;
195
- position: absolute;
196
- top: 0;
197
- width: 100%;
198
- color: $gray1;
199
- }
193
+ .nut-picker-roller {
194
+ z-index: 1;
195
+ transform-style: preserve-3d;
196
+ }
200
197
 
201
- .nut-picker-roller-item-title {
202
- display: block;
203
- width: 100%;
204
- height: 36px;
205
- line-height: 36px;
206
- color: $gray1;
207
- font-size: $picker-bar-title-font-size;
208
- }
198
+ .nut-picker-roller-item {
199
+ backface-visibility: hidden;
200
+ -moz-backface-visibility: hidden;
201
+ -webkit-backface-visibility: hidden;
202
+ position: absolute;
203
+ top: 0;
204
+ width: 100%;
205
+ color: $gray1;
206
+ }
209
207
 
210
- .nut-picker-roller-item-hidden {
211
- visibility: hidden;
212
- opacity: 0;
213
- }
214
- }
208
+ .nut-picker-roller-item-title {
209
+ display: block;
210
+ width: 100%;
211
+ height: 36px;
212
+ line-height: 36px;
213
+ text-align: center;
214
+ color: $gray1;
215
+ font-size: $picker-bar-title-font-size;
216
+ }
217
+
218
+ .nut-picker-roller-item-hidden {
219
+ visibility: hidden;
220
+ opacity: 0;
215
221
  }
216
222
 
217
223
  .nut-picker-placeholder {
@@ -0,0 +1,65 @@
1
+ .nut-swiper {
2
+ width: 100%;
3
+ height: 100%;
4
+ overflow: hidden;
5
+ }
6
+
7
+ .nut-swiper__container {
8
+ width: 100%;
9
+ height: 100%;
10
+ overflow: visible;
11
+ }
12
+
13
+ .nut-swiper__track {
14
+ width: 100%;
15
+ height: 100%;
16
+ position: relative;
17
+ display: flex;
18
+ }
19
+
20
+ .nut-swiper__track > div {
21
+ flex-shrink: 0;
22
+ width: 100%;
23
+ height: 100%;
24
+ }
25
+
26
+ .nut-swiper__track-vertical {
27
+ flex-direction: column;
28
+ }
29
+
30
+ .nut-swiper__pagination {
31
+ display: flex;
32
+ position: absolute;
33
+ left: 50%;
34
+ bottom: $swiper-pagination-bottom;
35
+ transform: translateX(-50%);
36
+ i {
37
+ width: $swiper-pagination-item-width;
38
+ height: $swiper-pagination-item-height;
39
+ margin-right: $swiper-pagination-item-margin-right;
40
+ border-radius: $swiper-pagination-item-border-radius;
41
+ &:last-child {
42
+ margin-right: 0;
43
+ }
44
+ }
45
+ }
46
+
47
+ .nut-swiper__pagination-vertical {
48
+ top: 50%;
49
+ left: 12px;
50
+ bottom: auto;
51
+ flex-direction: column;
52
+ -webkit-box-orient: vertical;
53
+ -webkit-box-direction: normal;
54
+ transform: translateY(-50%);
55
+ i {
56
+ margin-bottom: 5px;
57
+ width: 6px;
58
+ height: 6px;
59
+ border-radius: 50%;
60
+ &.active {
61
+ height: 18px;
62
+ border-radius: 5px;
63
+ }
64
+ }
65
+ }