@pisell/private-materials 6.6.60 → 6.6.62
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.
- package/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +2 -2
- package/build/lowcode/preview.js +8 -8
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +10 -10
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +10 -10
- package/es/components/booking/components/footer/amount.js +3 -4
- package/es/components/booking/components/footer/utils.js +82 -85
- package/es/components/booking/components/voucher/index.js +1 -1
- package/es/components/booking/dashboard/index.d.ts +5 -0
- package/es/components/booking/dashboard/index.js +9 -6
- package/es/components/booking/info/service2/Group/utils.js +30 -1
- package/es/components/booking/info2/service/editService/index.js +6 -49
- package/es/components/booking/info2/service/editService/utils.d.ts +0 -1
- package/es/components/booking/info2/service/editService/utils.js +0 -16
- package/es/components/booking/payments/index.js +1 -1
- package/es/components/checkout/hooks/useWalletPass.d.ts +1 -1
- package/es/components/checkout/hooks/useWalletPass.js +23 -15
- package/es/components/index.d.ts +2 -1
- package/es/components/index.js +2 -1
- package/es/components/pisellCashCounting/PisellCashCounting.d.ts +5 -0
- package/es/components/pisellCashCounting/PisellCashCounting.js +121 -0
- package/es/components/pisellCashCounting/PisellCashCounting.less +263 -0
- package/es/components/pisellCashCounting/components/CashCountingModal/index.d.ts +20 -0
- package/es/components/pisellCashCounting/components/CashCountingModal/index.js +250 -0
- package/es/components/pisellCashCounting/components/CashCountingModal/index.less +279 -0
- package/es/components/pisellCashCounting/hooks.d.ts +21 -0
- package/es/components/pisellCashCounting/hooks.js +193 -0
- package/es/components/pisellCashCounting/index.d.ts +2 -0
- package/es/components/pisellCashCounting/index.js +1 -0
- package/es/components/pisellCashCounting/locales.d.ts +118 -0
- package/es/components/pisellCashCounting/locales.js +117 -0
- package/es/components/pisellCashCounting/types.d.ts +85 -0
- package/es/components/pisellCashCounting/types.js +1 -0
- package/es/components/pisellCashCounting/utils.d.ts +10 -0
- package/es/components/pisellCashCounting/utils.js +40 -0
- package/es/components/ticketBooking/components/addServiceVariant/addService.js +0 -1
- package/es/components/ticketBooking/components/bookingDataPanel/bookingDashboard/index.d.ts +2 -0
- package/es/components/ticketBooking/components/bookingDataPanel/bookingDashboard/index.js +5 -2
- package/es/components/ticketBooking/components/bookingDataPanel/index.d.ts +2 -0
- package/es/components/ticketBooking/components/bookingDataPanel/index.js +5 -2
- package/es/components/ticketBooking/components/bookingDataPanel/pisellFloatingPanel/index.js +2 -1
- package/es/components/ticketBooking/components/ticketBooking/index.js +156 -37
- package/es/components/ticketBooking/index.js +7 -1
- package/es/components/ticketBooking/utils/formatProductMessage.js +47 -2
- package/es/hooks/useResponsive.d.ts +8 -0
- package/es/hooks/useResponsive.js +43 -0
- package/es/hooks/useThemeTokens.d.ts +7 -0
- package/es/hooks/useThemeTokens.js +20 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/es/pro/Login2.0/components/phoneValidation.js +65 -58
- package/es/pro/NumericStepper/index.d.ts +75 -0
- package/es/pro/NumericStepper/index.js +301 -0
- package/es/pro/NumericStepper/index.less +364 -0
- package/es/pro/keyboards/index.d.ts +2 -0
- package/es/pro/keyboards/index.js +1 -0
- package/es/pro/keyboards/locales.d.ts +38 -0
- package/es/pro/keyboards/locales.js +57 -0
- package/es/pro/keyboards/numberKeyboard/index.d.ts +16 -0
- package/es/pro/keyboards/numberKeyboard/index.js +523 -0
- package/es/pro/keyboards/numberKeyboard/index.less +59 -0
- package/es/pro/keyboards/numberKeyboard/types.d.ts +63 -0
- package/es/pro/keyboards/numberKeyboard/types.js +1 -0
- package/es/pro/pisellPriceKeyboardModal/PisellPriceKeyboardModal.js +3 -1
- package/es/pro/pisellPriceKeyboardModal/types.d.ts +2 -0
- package/lib/components/booking/components/footer/amount.js +3 -3
- package/lib/components/booking/components/footer/utils.js +11 -15
- package/lib/components/booking/components/voucher/index.js +1 -1
- package/lib/components/booking/dashboard/index.d.ts +5 -0
- package/lib/components/booking/dashboard/index.js +6 -5
- package/lib/components/booking/info/service2/Group/utils.js +42 -3
- package/lib/components/booking/info2/service/editService/index.js +5 -39
- package/lib/components/booking/info2/service/editService/utils.d.ts +0 -1
- package/lib/components/booking/info2/service/editService/utils.js +0 -16
- package/lib/components/booking/payments/index.js +1 -1
- package/lib/components/checkout/hooks/useWalletPass.d.ts +1 -1
- package/lib/components/checkout/hooks/useWalletPass.js +23 -16
- package/lib/components/index.d.ts +2 -1
- package/lib/components/index.js +3 -0
- package/lib/components/pisellCashCounting/PisellCashCounting.d.ts +5 -0
- package/lib/components/pisellCashCounting/PisellCashCounting.js +168 -0
- package/lib/components/pisellCashCounting/PisellCashCounting.less +263 -0
- package/lib/components/pisellCashCounting/components/CashCountingModal/index.d.ts +20 -0
- package/lib/components/pisellCashCounting/components/CashCountingModal/index.js +171 -0
- package/lib/components/pisellCashCounting/components/CashCountingModal/index.less +279 -0
- package/lib/components/pisellCashCounting/hooks.d.ts +21 -0
- package/lib/components/pisellCashCounting/hooks.js +189 -0
- package/lib/components/pisellCashCounting/index.d.ts +2 -0
- package/lib/components/pisellCashCounting/index.js +35 -0
- package/lib/components/pisellCashCounting/locales.d.ts +118 -0
- package/lib/components/pisellCashCounting/locales.js +141 -0
- package/lib/components/pisellCashCounting/types.d.ts +85 -0
- package/lib/components/pisellCashCounting/types.js +17 -0
- package/lib/components/pisellCashCounting/utils.d.ts +10 -0
- package/lib/components/pisellCashCounting/utils.js +59 -0
- package/lib/components/ticketBooking/components/addServiceVariant/addService.js +0 -1
- package/lib/components/ticketBooking/components/bookingDataPanel/bookingDashboard/index.d.ts +2 -0
- package/lib/components/ticketBooking/components/bookingDataPanel/bookingDashboard/index.js +3 -2
- package/lib/components/ticketBooking/components/bookingDataPanel/index.d.ts +2 -0
- package/lib/components/ticketBooking/components/bookingDataPanel/index.js +10 -3
- package/lib/components/ticketBooking/components/bookingDataPanel/pisellFloatingPanel/index.js +10 -1
- package/lib/components/ticketBooking/components/ticketBooking/index.js +114 -14
- package/lib/components/ticketBooking/index.js +11 -1
- package/lib/components/ticketBooking/utils/formatProductMessage.js +44 -2
- package/lib/hooks/useResponsive.d.ts +8 -0
- package/lib/hooks/useResponsive.js +48 -0
- package/lib/hooks/useThemeTokens.d.ts +7 -0
- package/lib/hooks/useThemeTokens.js +40 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -0
- package/lib/pro/Login2.0/components/phoneValidation.js +4 -2
- package/lib/pro/NumericStepper/index.d.ts +75 -0
- package/lib/pro/NumericStepper/index.js +338 -0
- package/lib/pro/NumericStepper/index.less +364 -0
- package/lib/pro/keyboards/index.d.ts +2 -0
- package/lib/pro/keyboards/index.js +39 -0
- package/lib/pro/keyboards/locales.d.ts +38 -0
- package/lib/pro/keyboards/locales.js +61 -0
- package/lib/pro/keyboards/numberKeyboard/index.d.ts +16 -0
- package/lib/pro/keyboards/numberKeyboard/index.js +400 -0
- package/lib/pro/keyboards/numberKeyboard/index.less +59 -0
- package/lib/pro/keyboards/numberKeyboard/types.d.ts +63 -0
- package/lib/pro/keyboards/numberKeyboard/types.js +17 -0
- package/lib/pro/pisellPriceKeyboardModal/PisellPriceKeyboardModal.js +3 -1
- package/lib/pro/pisellPriceKeyboardModal/types.d.ts +2 -0
- package/lowcode/pisell-cash-counting/meta.ts +167 -0
- package/lowcode/pisell-cash-counting/snippets.ts +13 -0
- package/package.json +4 -4
|
@@ -12,7 +12,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
12
12
|
*/
|
|
13
13
|
export var validatePhoneNumber = /*#__PURE__*/function () {
|
|
14
14
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(value, getText) {
|
|
15
|
-
var phone, countryCode, match;
|
|
15
|
+
var phone, countryCode, match, usCanadaReg, auReg;
|
|
16
16
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17
17
|
while (1) switch (_context.prev = _context.next) {
|
|
18
18
|
case 0:
|
|
@@ -55,7 +55,7 @@ export var validatePhoneNumber = /*#__PURE__*/function () {
|
|
|
55
55
|
throw new Error(getText('pisell-phone-validation-required'));
|
|
56
56
|
case 16:
|
|
57
57
|
_context.t0 = countryCode;
|
|
58
|
-
_context.next = _context.t0 === '86' ? 19 : _context.t0 === '852' ? 22 : _context.t0 === '853' ? 25 : _context.t0 === '886' ? 28 : _context.t0 === '1' ? 31 : _context.t0 === '44' ?
|
|
58
|
+
_context.next = _context.t0 === '86' ? 19 : _context.t0 === '852' ? 22 : _context.t0 === '853' ? 25 : _context.t0 === '886' ? 28 : _context.t0 === '1' ? 31 : _context.t0 === '44' ? 35 : _context.t0 === '61' ? 38 : _context.t0 === '81' ? 42 : _context.t0 === '82' ? 45 : _context.t0 === '65' ? 48 : _context.t0 === '60' ? 51 : _context.t0 === '66' ? 54 : _context.t0 === '84' ? 57 : _context.t0 === '63' ? 60 : _context.t0 === '62' ? 63 : _context.t0 === '91' ? 66 : 69;
|
|
59
59
|
break;
|
|
60
60
|
case 19:
|
|
61
61
|
if (/^1[3-9]\d{9}$/.test(phone)) {
|
|
@@ -64,7 +64,7 @@ export var validatePhoneNumber = /*#__PURE__*/function () {
|
|
|
64
64
|
}
|
|
65
65
|
throw new Error(getText('pisell-phone-validation-china'));
|
|
66
66
|
case 21:
|
|
67
|
-
return _context.abrupt("break",
|
|
67
|
+
return _context.abrupt("break", 72);
|
|
68
68
|
case 22:
|
|
69
69
|
if (/^[5-9]\d{7}$/.test(phone)) {
|
|
70
70
|
_context.next = 24;
|
|
@@ -72,7 +72,7 @@ export var validatePhoneNumber = /*#__PURE__*/function () {
|
|
|
72
72
|
}
|
|
73
73
|
throw new Error(getText('pisell-phone-validation-hongkong'));
|
|
74
74
|
case 24:
|
|
75
|
-
return _context.abrupt("break",
|
|
75
|
+
return _context.abrupt("break", 72);
|
|
76
76
|
case 25:
|
|
77
77
|
if (/^6\d{7}$/.test(phone)) {
|
|
78
78
|
_context.next = 27;
|
|
@@ -80,7 +80,7 @@ export var validatePhoneNumber = /*#__PURE__*/function () {
|
|
|
80
80
|
}
|
|
81
81
|
throw new Error(getText('pisell-phone-validation-macau'));
|
|
82
82
|
case 27:
|
|
83
|
-
return _context.abrupt("break",
|
|
83
|
+
return _context.abrupt("break", 72);
|
|
84
84
|
case 28:
|
|
85
85
|
if (/^9\d{8}$/.test(phone)) {
|
|
86
86
|
_context.next = 30;
|
|
@@ -88,112 +88,119 @@ export var validatePhoneNumber = /*#__PURE__*/function () {
|
|
|
88
88
|
}
|
|
89
89
|
throw new Error(getText('pisell-phone-validation-taiwan'));
|
|
90
90
|
case 30:
|
|
91
|
-
return _context.abrupt("break",
|
|
91
|
+
return _context.abrupt("break", 72);
|
|
92
92
|
case 31:
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
// 美国/加拿大
|
|
94
|
+
// NANP 标准 10 位格式:3位区号[2-9] + 3位局号[2-9] + 4位
|
|
95
|
+
usCanadaReg = /^[2-9]\d{2}[2-9]\d{6}$/;
|
|
96
|
+
if (usCanadaReg.test(phone)) {
|
|
97
|
+
_context.next = 34;
|
|
95
98
|
break;
|
|
96
99
|
}
|
|
97
100
|
throw new Error(getText('pisell-phone-validation-us-canada'));
|
|
98
|
-
case 33:
|
|
99
|
-
return _context.abrupt("break", 70);
|
|
100
101
|
case 34:
|
|
102
|
+
return _context.abrupt("break", 72);
|
|
103
|
+
case 35:
|
|
101
104
|
if (/^7\d{9}$/.test(phone)) {
|
|
102
|
-
_context.next =
|
|
105
|
+
_context.next = 37;
|
|
103
106
|
break;
|
|
104
107
|
}
|
|
105
108
|
throw new Error(getText('pisell-phone-validation-uk'));
|
|
106
|
-
case 36:
|
|
107
|
-
return _context.abrupt("break", 70);
|
|
108
109
|
case 37:
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
return _context.abrupt("break", 72);
|
|
111
|
+
case 38:
|
|
112
|
+
// 澳大利亚
|
|
113
|
+
// const reg = /^(\+?0)?4\d{8}$/;
|
|
114
|
+
// 固话前缀 02/03/07/08, 手机前缀 04/05, 首位 0 可选
|
|
115
|
+
auReg = /^0?[2-578]\d{8}$/;
|
|
116
|
+
if (auReg.test(phone)) {
|
|
117
|
+
_context.next = 41;
|
|
111
118
|
break;
|
|
112
119
|
}
|
|
113
120
|
throw new Error(getText('pisell-phone-validation-australia'));
|
|
114
|
-
case
|
|
115
|
-
return _context.abrupt("break",
|
|
116
|
-
case
|
|
121
|
+
case 41:
|
|
122
|
+
return _context.abrupt("break", 72);
|
|
123
|
+
case 42:
|
|
117
124
|
if (/^[789]0\d{8}$/.test(phone)) {
|
|
118
|
-
_context.next =
|
|
125
|
+
_context.next = 44;
|
|
119
126
|
break;
|
|
120
127
|
}
|
|
121
128
|
throw new Error(getText('pisell-phone-validation-japan'));
|
|
122
|
-
case
|
|
123
|
-
return _context.abrupt("break",
|
|
124
|
-
case
|
|
129
|
+
case 44:
|
|
130
|
+
return _context.abrupt("break", 72);
|
|
131
|
+
case 45:
|
|
125
132
|
if (/^1[0-9]\d{7,8}$/.test(phone)) {
|
|
126
|
-
_context.next =
|
|
133
|
+
_context.next = 47;
|
|
127
134
|
break;
|
|
128
135
|
}
|
|
129
136
|
throw new Error(getText('pisell-phone-validation-korea'));
|
|
130
|
-
case
|
|
131
|
-
return _context.abrupt("break",
|
|
132
|
-
case
|
|
137
|
+
case 47:
|
|
138
|
+
return _context.abrupt("break", 72);
|
|
139
|
+
case 48:
|
|
133
140
|
if (/^[89]\d{7}$/.test(phone)) {
|
|
134
|
-
_context.next =
|
|
141
|
+
_context.next = 50;
|
|
135
142
|
break;
|
|
136
143
|
}
|
|
137
144
|
throw new Error(getText('pisell-phone-validation-singapore'));
|
|
138
|
-
case
|
|
139
|
-
return _context.abrupt("break",
|
|
140
|
-
case
|
|
145
|
+
case 50:
|
|
146
|
+
return _context.abrupt("break", 72);
|
|
147
|
+
case 51:
|
|
141
148
|
if (/^1[0-9]\d{7,8}$/.test(phone)) {
|
|
142
|
-
_context.next =
|
|
149
|
+
_context.next = 53;
|
|
143
150
|
break;
|
|
144
151
|
}
|
|
145
152
|
throw new Error(getText('pisell-phone-validation-malaysia'));
|
|
146
|
-
case
|
|
147
|
-
return _context.abrupt("break",
|
|
148
|
-
case
|
|
153
|
+
case 53:
|
|
154
|
+
return _context.abrupt("break", 72);
|
|
155
|
+
case 54:
|
|
149
156
|
if (/^[689]\d{8}$/.test(phone)) {
|
|
150
|
-
_context.next =
|
|
157
|
+
_context.next = 56;
|
|
151
158
|
break;
|
|
152
159
|
}
|
|
153
160
|
throw new Error(getText('pisell-phone-validation-thailand'));
|
|
154
|
-
case
|
|
155
|
-
return _context.abrupt("break",
|
|
156
|
-
case
|
|
161
|
+
case 56:
|
|
162
|
+
return _context.abrupt("break", 72);
|
|
163
|
+
case 57:
|
|
157
164
|
if (/^[3579]\d{8}$/.test(phone)) {
|
|
158
|
-
_context.next =
|
|
165
|
+
_context.next = 59;
|
|
159
166
|
break;
|
|
160
167
|
}
|
|
161
168
|
throw new Error(getText('pisell-phone-validation-vietnam'));
|
|
162
|
-
case
|
|
163
|
-
return _context.abrupt("break",
|
|
164
|
-
case
|
|
169
|
+
case 59:
|
|
170
|
+
return _context.abrupt("break", 72);
|
|
171
|
+
case 60:
|
|
165
172
|
if (/^9\d{9}$/.test(phone)) {
|
|
166
|
-
_context.next =
|
|
173
|
+
_context.next = 62;
|
|
167
174
|
break;
|
|
168
175
|
}
|
|
169
176
|
throw new Error(getText('pisell-phone-validation-philippines'));
|
|
170
|
-
case
|
|
171
|
-
return _context.abrupt("break",
|
|
172
|
-
case
|
|
177
|
+
case 62:
|
|
178
|
+
return _context.abrupt("break", 72);
|
|
179
|
+
case 63:
|
|
173
180
|
if (/^8\d{8,11}$/.test(phone)) {
|
|
174
|
-
_context.next =
|
|
181
|
+
_context.next = 65;
|
|
175
182
|
break;
|
|
176
183
|
}
|
|
177
184
|
throw new Error(getText('pisell-phone-validation-indonesia'));
|
|
178
|
-
case
|
|
179
|
-
return _context.abrupt("break",
|
|
180
|
-
case
|
|
185
|
+
case 65:
|
|
186
|
+
return _context.abrupt("break", 72);
|
|
187
|
+
case 66:
|
|
181
188
|
if (/^[6-9]\d{9}$/.test(phone)) {
|
|
182
|
-
_context.next =
|
|
189
|
+
_context.next = 68;
|
|
183
190
|
break;
|
|
184
191
|
}
|
|
185
192
|
throw new Error(getText('pisell-phone-validation-india'));
|
|
186
|
-
case
|
|
187
|
-
return _context.abrupt("break",
|
|
188
|
-
case
|
|
193
|
+
case 68:
|
|
194
|
+
return _context.abrupt("break", 72);
|
|
195
|
+
case 69:
|
|
189
196
|
if (/^\d{6,15}$/.test(phone)) {
|
|
190
|
-
_context.next =
|
|
197
|
+
_context.next = 71;
|
|
191
198
|
break;
|
|
192
199
|
}
|
|
193
200
|
throw new Error(getText('pisell-phone-validation-invalid'));
|
|
194
|
-
case
|
|
195
|
-
return _context.abrupt("break",
|
|
196
|
-
case
|
|
201
|
+
case 71:
|
|
202
|
+
return _context.abrupt("break", 72);
|
|
203
|
+
case 72:
|
|
197
204
|
case "end":
|
|
198
205
|
return _context.stop();
|
|
199
206
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import './index.less';
|
|
3
|
+
declare global {
|
|
4
|
+
namespace JSX {
|
|
5
|
+
interface IntrinsicElements {
|
|
6
|
+
[elemName: string]: any;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 样式变体类型
|
|
12
|
+
* - separated: 分离式,按钮独立显示(默认)
|
|
13
|
+
* - capsule: 胶囊式,按钮和数字在一个圆角容器内
|
|
14
|
+
*/
|
|
15
|
+
export declare type NumericStepperVariant = 'separated' | 'capsule';
|
|
16
|
+
export interface NumericStepperProps {
|
|
17
|
+
/** 当前值 */
|
|
18
|
+
value?: number;
|
|
19
|
+
/** 默认值 */
|
|
20
|
+
defaultValue?: number;
|
|
21
|
+
/** 最小值 */
|
|
22
|
+
min?: number;
|
|
23
|
+
/** 最大值 */
|
|
24
|
+
max?: number;
|
|
25
|
+
/** 步长 */
|
|
26
|
+
step?: number;
|
|
27
|
+
/** 是否禁用 */
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/** 值变化回调 */
|
|
30
|
+
onChange?: (value: number) => void;
|
|
31
|
+
/** 自定义类名 */
|
|
32
|
+
className?: string;
|
|
33
|
+
theme?: {
|
|
34
|
+
token?: {
|
|
35
|
+
colorPrimary?: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
/** 自定义样式 */
|
|
39
|
+
styles?: {
|
|
40
|
+
container?: React.CSSProperties;
|
|
41
|
+
};
|
|
42
|
+
/** 值为 0 时是否折叠为仅展示加号(隐藏减号与中间数字) */
|
|
43
|
+
plusOnlyAtZero?: boolean;
|
|
44
|
+
horizontalPadding?: number | string;
|
|
45
|
+
/** 尺寸 */
|
|
46
|
+
size?: 'small' | 'middle' | 'large';
|
|
47
|
+
/** 按钮形状(仅在 variant='separated' 时生效) */
|
|
48
|
+
shape?: 'round' | 'square';
|
|
49
|
+
/** 减号按钮的自定义内容 */
|
|
50
|
+
minusIcon?: React.ReactNode;
|
|
51
|
+
/** 加号按钮的自定义内容 */
|
|
52
|
+
plusIcon?: React.ReactNode;
|
|
53
|
+
/**
|
|
54
|
+
* 样式变体
|
|
55
|
+
* - separated: 分离式,按钮独立显示(默认)
|
|
56
|
+
* - capsule: 胶囊式,按钮和数字在一个圆角容器内
|
|
57
|
+
* @default 'separated'
|
|
58
|
+
*/
|
|
59
|
+
variant?: NumericStepperVariant;
|
|
60
|
+
/**
|
|
61
|
+
* 是否启用输入功能(点击数字弹出键盘)
|
|
62
|
+
* - 开启时:展示区域 cursor 为 pointer,点击弹出键盘
|
|
63
|
+
* - 关闭后:展示区域无边框,点击不会弹出键盘
|
|
64
|
+
* @default true
|
|
65
|
+
*/
|
|
66
|
+
enableInput?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* 展示区域最大宽度(仅胶囊模式生效)
|
|
69
|
+
* - 设置后:展示区域最大宽度受限,超出部分截断
|
|
70
|
+
* - 不设置:展示区域宽度随内容自适应
|
|
71
|
+
*/
|
|
72
|
+
displayMaxWidth?: number | string;
|
|
73
|
+
}
|
|
74
|
+
declare const NumericStepper: React.FC<NumericStepperProps>;
|
|
75
|
+
export default NumericStepper;
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import { useMemo, useState, useCallback, useEffect } from 'react';
|
|
15
|
+
import classNames from 'classnames';
|
|
16
|
+
import { isMobile } from '@pisell/utils';
|
|
17
|
+
import { NumberKeyboard } from "../keyboards";
|
|
18
|
+
import useThemeTokens from "../../hooks/useThemeTokens";
|
|
19
|
+
import "./index.less";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 样式变体类型
|
|
23
|
+
* - separated: 分离式,按钮独立显示(默认)
|
|
24
|
+
* - capsule: 胶囊式,按钮和数字在一个圆角容器内
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
var NumericStepper = function NumericStepper(_ref) {
|
|
28
|
+
var value = _ref.value,
|
|
29
|
+
_ref$defaultValue = _ref.defaultValue,
|
|
30
|
+
defaultValue = _ref$defaultValue === void 0 ? 0 : _ref$defaultValue,
|
|
31
|
+
_ref$min = _ref.min,
|
|
32
|
+
min = _ref$min === void 0 ? 0 : _ref$min,
|
|
33
|
+
_ref$max = _ref.max,
|
|
34
|
+
max = _ref$max === void 0 ? Infinity : _ref$max,
|
|
35
|
+
_ref$step = _ref.step,
|
|
36
|
+
step = _ref$step === void 0 ? 1 : _ref$step,
|
|
37
|
+
_ref$disabled = _ref.disabled,
|
|
38
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
39
|
+
onChange = _ref.onChange,
|
|
40
|
+
className = _ref.className,
|
|
41
|
+
styles = _ref.styles,
|
|
42
|
+
_ref$size = _ref.size,
|
|
43
|
+
size = _ref$size === void 0 ? 'middle' : _ref$size,
|
|
44
|
+
_ref$shape = _ref.shape,
|
|
45
|
+
shape = _ref$shape === void 0 ? 'round' : _ref$shape,
|
|
46
|
+
minusIcon = _ref.minusIcon,
|
|
47
|
+
plusIcon = _ref.plusIcon,
|
|
48
|
+
_ref$horizontalPaddin = _ref.horizontalPadding,
|
|
49
|
+
horizontalPadding = _ref$horizontalPaddin === void 0 ? 0 : _ref$horizontalPaddin,
|
|
50
|
+
_ref$variant = _ref.variant,
|
|
51
|
+
variant = _ref$variant === void 0 ? 'separated' : _ref$variant,
|
|
52
|
+
_ref$enableInput = _ref.enableInput,
|
|
53
|
+
enableInput = _ref$enableInput === void 0 ? true : _ref$enableInput,
|
|
54
|
+
displayMaxWidth = _ref.displayMaxWidth,
|
|
55
|
+
theme = _ref.theme,
|
|
56
|
+
_ref$plusOnlyAtZero = _ref.plusOnlyAtZero,
|
|
57
|
+
plusOnlyAtZero = _ref$plusOnlyAtZero === void 0 ? true : _ref$plusOnlyAtZero;
|
|
58
|
+
var _useState = useState(false),
|
|
59
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
60
|
+
open = _useState2[0],
|
|
61
|
+
setOpen = _useState2[1];
|
|
62
|
+
var _useState3 = useState(value !== undefined ? value : defaultValue),
|
|
63
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
64
|
+
internalValue = _useState4[0],
|
|
65
|
+
setInternalValue = _useState4[1];
|
|
66
|
+
var _isMobile = useMemo(function () {
|
|
67
|
+
return isMobile();
|
|
68
|
+
}, [isMobile]);
|
|
69
|
+
var _useThemeTokens = useThemeTokens(theme),
|
|
70
|
+
colorPrimary = _useThemeTokens.colorPrimary;
|
|
71
|
+
var _useState5 = useState(''),
|
|
72
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
73
|
+
tempValue = _useState6[0],
|
|
74
|
+
setTempValue = _useState6[1];
|
|
75
|
+
var currentValue = value !== undefined ? value : internalValue;
|
|
76
|
+
|
|
77
|
+
// 同步外部value变化
|
|
78
|
+
useEffect(function () {
|
|
79
|
+
if (value !== undefined) {
|
|
80
|
+
setInternalValue(value);
|
|
81
|
+
}
|
|
82
|
+
}, [value]);
|
|
83
|
+
|
|
84
|
+
// 处理值变化
|
|
85
|
+
var handleValueChange = useCallback(function (newValue) {
|
|
86
|
+
// 确保值在有效范围内
|
|
87
|
+
var clampedValue = Math.max(min, Math.min(max, newValue));
|
|
88
|
+
if (value === undefined) {
|
|
89
|
+
setInternalValue(clampedValue);
|
|
90
|
+
}
|
|
91
|
+
onChange === null || onChange === void 0 || onChange(clampedValue);
|
|
92
|
+
}, [min, max, value, onChange]);
|
|
93
|
+
|
|
94
|
+
// 减少数值
|
|
95
|
+
var handleDecrease = useCallback(function () {
|
|
96
|
+
if (disabled) return;
|
|
97
|
+
var newValue = currentValue - step;
|
|
98
|
+
if (newValue >= min) {
|
|
99
|
+
handleValueChange(newValue);
|
|
100
|
+
}
|
|
101
|
+
}, [currentValue, step, min, disabled, handleValueChange]);
|
|
102
|
+
|
|
103
|
+
// 增加数值
|
|
104
|
+
var handleIncrease = useCallback(function () {
|
|
105
|
+
if (disabled) return;
|
|
106
|
+
|
|
107
|
+
// 如果当前值小于 min,直接增加到 min
|
|
108
|
+
if (currentValue < min) {
|
|
109
|
+
handleValueChange(min);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
var newValue = currentValue + step;
|
|
113
|
+
if (newValue <= max) {
|
|
114
|
+
handleValueChange(newValue);
|
|
115
|
+
}
|
|
116
|
+
}, [currentValue, step, min, max, disabled, handleValueChange]);
|
|
117
|
+
var handleChange = function handleChange(e) {
|
|
118
|
+
if (!e) {
|
|
119
|
+
setTempValue(min.toString());
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (e === 'delete') {
|
|
123
|
+
// 删除最后一位数字
|
|
124
|
+
var newTempValue = tempValue.slice(0, -1);
|
|
125
|
+
setTempValue(newTempValue || '0');
|
|
126
|
+
return;
|
|
127
|
+
} else if (e === 'verify') {
|
|
128
|
+
// 确认时提交暂存的值
|
|
129
|
+
var newValue = parseInt(tempValue) || 0;
|
|
130
|
+
var clampedValue = Math.max(min, Math.min(max, newValue));
|
|
131
|
+
onChange === null || onChange === void 0 || onChange(clampedValue);
|
|
132
|
+
setOpen(false); // 手动关闭弹窗
|
|
133
|
+
return;
|
|
134
|
+
} else {
|
|
135
|
+
// 更新暂存值,不直接触发onChange
|
|
136
|
+
setTempValue(e);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// 点击数字的处理
|
|
141
|
+
var handleNumberClick = function handleNumberClick() {
|
|
142
|
+
// 禁用或关闭输入功能时不响应点击
|
|
143
|
+
if (disabled || !enableInput) return;
|
|
144
|
+
// Popover 会自动处理打开,我们只需要设置初始值
|
|
145
|
+
setTempValue(currentValue.toString()); // 设置临时值为当前值
|
|
146
|
+
if (_isMobile) {
|
|
147
|
+
setOpen(true);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// 处理弹窗开关时的值同步
|
|
152
|
+
var handleOpenChange = function handleOpenChange(visible) {
|
|
153
|
+
setOpen(visible);
|
|
154
|
+
if (visible) {
|
|
155
|
+
// 打开时设置临时值为当前值
|
|
156
|
+
setTempValue(currentValue.toString());
|
|
157
|
+
} else {
|
|
158
|
+
// 关闭时检查是否需要提交值
|
|
159
|
+
var tempNumber = parseInt(tempValue) || 0;
|
|
160
|
+
var clampedValue = Math.max(min, Math.min(max, tempNumber));
|
|
161
|
+
if (clampedValue !== value) {
|
|
162
|
+
onChange === null || onChange === void 0 || onChange(clampedValue);
|
|
163
|
+
}
|
|
164
|
+
// 重置临时值为当前值,确保下次打开时显示正确的值
|
|
165
|
+
setTempValue(currentValue.toString());
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// 判断按钮是否应该禁用
|
|
170
|
+
var isDecreaseDisabled = disabled || currentValue <= min;
|
|
171
|
+
var isIncreaseDisabled = disabled || currentValue >= max;
|
|
172
|
+
// 胶囊模式下不应用 isPlusOnly 逻辑,始终显示完整的 减号-数字-加号
|
|
173
|
+
var isPlusOnly = variant === 'capsule' ? false : Boolean(plusOnlyAtZero && (currentValue === 0 || currentValue === undefined));
|
|
174
|
+
var outOfRange = currentValue < min || currentValue > max;
|
|
175
|
+
var stepperClasses = classNames('numeric-stepper', "numeric-stepper-".concat(size), "numeric-stepper-".concat(variant), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "numeric-stepper-".concat(shape), variant === 'separated'), 'numeric-stepper-disabled', disabled), 'numeric-stepper-simple', currentValue === 0 || currentValue === undefined), 'numeric-stepper-out-of-range', outOfRange), 'numeric-stepper-plus-only', isPlusOnly), 'numeric-stepper-input-disabled', !enableInput), className);
|
|
176
|
+
var _minus = !isPlusOnly && /*#__PURE__*/React.createElement("div", {
|
|
177
|
+
className: "numeric-stepper-button-wrapper numeric-stepper-minus-button-wrapper",
|
|
178
|
+
onClick: handleDecrease,
|
|
179
|
+
style: {
|
|
180
|
+
paddingLeft: horizontalPadding
|
|
181
|
+
}
|
|
182
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
183
|
+
type: "button",
|
|
184
|
+
className: classNames('numeric-stepper-button', 'numeric-stepper-minus', {
|
|
185
|
+
'numeric-stepper-button-disabled': isDecreaseDisabled
|
|
186
|
+
}),
|
|
187
|
+
disabled: isDecreaseDisabled
|
|
188
|
+
}, minusIcon || /*#__PURE__*/React.createElement("svg", {
|
|
189
|
+
width: "16",
|
|
190
|
+
height: "16",
|
|
191
|
+
viewBox: "0 0 16 16",
|
|
192
|
+
fill: "none"
|
|
193
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
194
|
+
d: "M3 8h10",
|
|
195
|
+
stroke: "currentColor",
|
|
196
|
+
strokeWidth: "1.5",
|
|
197
|
+
strokeLinecap: "round"
|
|
198
|
+
}))));
|
|
199
|
+
var _display = useMemo(function () {
|
|
200
|
+
if (isPlusOnly) {
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// 展示区域样式(胶囊模式下支持 displayMaxWidth)
|
|
205
|
+
var displayWrapperStyle = variant === 'capsule' && displayMaxWidth ? {
|
|
206
|
+
maxWidth: typeof displayMaxWidth === 'number' ? "".concat(displayMaxWidth, "px") : displayMaxWidth
|
|
207
|
+
} : {};
|
|
208
|
+
|
|
209
|
+
// 纯展示模式(enableInput 为 false)
|
|
210
|
+
var displayElement = /*#__PURE__*/React.createElement("span", {
|
|
211
|
+
className: "numeric-stepper-display-wrapper",
|
|
212
|
+
onClick: handleNumberClick,
|
|
213
|
+
style: displayWrapperStyle
|
|
214
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
215
|
+
className: classNames('numeric-stepper-display')
|
|
216
|
+
}, currentValue));
|
|
217
|
+
|
|
218
|
+
// 关闭输入功能时,只展示数字,不包装键盘
|
|
219
|
+
if (!enableInput) {
|
|
220
|
+
return displayElement;
|
|
221
|
+
}
|
|
222
|
+
if (_isMobile) {
|
|
223
|
+
return displayElement;
|
|
224
|
+
}
|
|
225
|
+
return /*#__PURE__*/React.createElement(NumberKeyboard, {
|
|
226
|
+
max: max,
|
|
227
|
+
min: min,
|
|
228
|
+
originalValue: currentValue.toString(),
|
|
229
|
+
defaultValue: currentValue.toString(),
|
|
230
|
+
onEnter: function onEnter(newValue) {
|
|
231
|
+
handleValueChange === null || handleValueChange === void 0 || handleValueChange(Number(newValue));
|
|
232
|
+
setOpen(false);
|
|
233
|
+
},
|
|
234
|
+
containerProps: {
|
|
235
|
+
className: 'numeric-stepper-keyboard-popover',
|
|
236
|
+
renderType: 'popover',
|
|
237
|
+
open: open,
|
|
238
|
+
onOpenChange: handleOpenChange,
|
|
239
|
+
content: /*#__PURE__*/React.createElement(NumberKeyboard, {
|
|
240
|
+
max: max,
|
|
241
|
+
min: min,
|
|
242
|
+
originalValue: currentValue.toString(),
|
|
243
|
+
defaultValue: currentValue.toString(),
|
|
244
|
+
onEnter: function onEnter(newValue) {
|
|
245
|
+
handleValueChange === null || handleValueChange === void 0 || handleValueChange(Number(newValue));
|
|
246
|
+
setOpen(false);
|
|
247
|
+
}
|
|
248
|
+
})
|
|
249
|
+
}
|
|
250
|
+
}, displayElement);
|
|
251
|
+
}, [_isMobile, open, isPlusOnly, currentValue, handleNumberClick, handleOpenChange, handleChange, max, min, onChange, tempValue, enableInput, variant, displayMaxWidth]);
|
|
252
|
+
var _plus = /*#__PURE__*/React.createElement("div", {
|
|
253
|
+
className: "numeric-stepper-button-wrapper numeric-stepper-plus-button-wrapper",
|
|
254
|
+
onClick: handleIncrease,
|
|
255
|
+
style: {
|
|
256
|
+
paddingLeft: isPlusOnly ? horizontalPadding : 0,
|
|
257
|
+
paddingRight: horizontalPadding
|
|
258
|
+
}
|
|
259
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
260
|
+
type: "button",
|
|
261
|
+
className: classNames('numeric-stepper-button', 'numeric-stepper-plus', {
|
|
262
|
+
'numeric-stepper-button-disabled': isIncreaseDisabled
|
|
263
|
+
}),
|
|
264
|
+
disabled: isIncreaseDisabled
|
|
265
|
+
}, plusIcon || /*#__PURE__*/React.createElement("svg", {
|
|
266
|
+
width: "16",
|
|
267
|
+
height: "16",
|
|
268
|
+
viewBox: "0 0 16 16",
|
|
269
|
+
fill: "none"
|
|
270
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
271
|
+
d: "M8 3v10M3 8h10",
|
|
272
|
+
stroke: "currentColor",
|
|
273
|
+
strokeWidth: "1.5",
|
|
274
|
+
strokeLinecap: "round"
|
|
275
|
+
}))));
|
|
276
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
277
|
+
className: stepperClasses,
|
|
278
|
+
style: _objectSpread(_objectSpread({}, (styles === null || styles === void 0 ? void 0 : styles.container) || {}), {}, _defineProperty({}, '--color-primary', colorPrimary)),
|
|
279
|
+
onClick: function onClick(e) {
|
|
280
|
+
return e.stopPropagation();
|
|
281
|
+
}
|
|
282
|
+
}, _minus, _display, _plus, _isMobile && /*#__PURE__*/React.createElement(NumberKeyboard, {
|
|
283
|
+
containerProps: {
|
|
284
|
+
className: 'numeric-stepper-keyboard-modal',
|
|
285
|
+
renderType: 'modal',
|
|
286
|
+
open: open,
|
|
287
|
+
onCancel: function onCancel() {
|
|
288
|
+
setOpen(false);
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
max: max,
|
|
292
|
+
min: min,
|
|
293
|
+
defaultValue: currentValue.toString(),
|
|
294
|
+
originalValue: currentValue.toString(),
|
|
295
|
+
onEnter: function onEnter(newValue) {
|
|
296
|
+
handleValueChange === null || handleValueChange === void 0 || handleValueChange(Number(newValue));
|
|
297
|
+
setOpen(false);
|
|
298
|
+
}
|
|
299
|
+
}));
|
|
300
|
+
};
|
|
301
|
+
export default NumericStepper;
|