@pisell/private-materials 6.8.86 → 6.8.88
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 +1 -1
- package/build/lowcode/preview.js +9 -9
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +9 -9
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +9 -9
- package/es/components/booking/components/customiseItemModal/index.js +4 -7
- package/es/components/booking/deposit/index.d.ts +0 -1
- package/es/components/booking/info/index.d.ts +0 -1
- package/es/components/booking/info/service/addTimeModal/index.d.ts +0 -1
- package/es/components/booking/utils.d.ts +2 -2
- package/es/components/eftposPay/amount.d.ts +1 -1
- package/es/components/eftposPay/app.d.ts +1 -1
- package/es/components/eftposPay/device.d.ts +1 -1
- package/es/components/eftposPay/hooks.d.ts +1 -1
- package/es/components/eftposPay/store/index.d.ts +4 -4
- package/es/components/ticketBooking/components/addServiceVariant/addService.d.ts +0 -1
- package/es/components/ticketBooking/components/addServiceVariant/addService.js +1 -1
- package/es/components/ticketBooking/components/ticketBooking/index.d.ts +0 -1
- package/es/components/ticketBooking/index.d.ts +0 -1
- package/es/components/ticketBooking/utils/index.d.ts +1 -1
- package/es/plus/productSelect/ProductCard/SkuCard/components/Capacity/index.d.ts +1 -1
- package/es/plus/productSelect/ProductCard/SkuCard/components/CardMask/index.d.ts +1 -1
- package/es/plus/productSelect/ProductCard/SkuCard/components/Countdown/index.d.ts +1 -1
- package/es/plus/productSelect/ProductCard/SkuCard/components/Duration/index.d.ts +1 -1
- package/es/plus/productSelect/ProductCard/SkuCard/components/MemberPrice/index.d.ts +1 -1
- package/es/plus/productSelect/ProductCard/SkuCard/components/Resource/index.d.ts +1 -1
- package/es/plus/productSelect/ProductCard/SkuCard/components/Stock/index.d.ts +1 -1
- package/es/plus/productSelect/ProductCard/SkuCard/components/Time/index.d.ts +1 -1
- package/es/plus/saasLogin/utils.d.ts +5 -5
- package/es/plus/skuOptionsSelection/components/OptionsCard/OptionItemCard.d.ts +0 -1
- package/es/plus/skuOptionsSelection/components/OptionsModal/index.d.ts +0 -1
- package/es/plus/skuOptionsSelection/components/VariantCard/index.d.ts +0 -1
- package/es/plus/skuOptionsSelection/utils/transformBundleGroup.js +11 -2
- package/es/plus/skuOptionsSelection/utils/transformOptionGroup.js +10 -0
- package/es/plus/skuOptionsSelection/utils/transformValueToSelectorValue.js +1 -0
- package/es/plus/skuOptionsSelection/utils/transformVariantGroup.js +10 -0
- package/es/plus/walletEditor/components/ImageUpload/index.d.ts +1 -1
- package/es/pro/NumericStepper/index.d.ts +21 -1
- package/es/pro/NumericStepper/index.js +74 -66
- package/es/pro/NumericStepper/index.less +289 -136
- package/es/pro/Selector/demo.d.ts +0 -1
- package/es/pro/Selector/hooks/usePresetProps.js +2 -1
- package/es/pro/keyboards/index.d.ts +2 -0
- package/es/pro/keyboards/index.js +1 -0
- package/es/pro/keyboards/locales.d.ts +24 -0
- package/es/pro/keyboards/locales.js +35 -0
- package/es/pro/keyboards/numberKeyboard/index.d.ts +16 -0
- package/es/pro/keyboards/numberKeyboard/index.js +524 -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/priceKeyboard/components/cashKeyboard/CashKeyboardSimple.js +2 -1
- package/es/pro/priceKeyboard/components/discountKeyboard/index.js +2 -1
- package/es/pro/priceKeyboard/components/paymentKeyboard/index.d.ts +0 -1
- package/es/pro/priceKeyboard/components/paymentKeyboard/index.js +6 -3
- package/es/pro/skuDetailModal/index.js +6 -8
- package/es/pro/skuDetailModal/index.less +4 -4
- package/lib/components/booking/components/customiseItemModal/index.js +4 -5
- package/lib/components/booking/deposit/index.d.ts +0 -1
- package/lib/components/booking/info/index.d.ts +0 -1
- package/lib/components/booking/info/service/addTimeModal/index.d.ts +0 -1
- package/lib/components/booking/utils.d.ts +2 -2
- package/lib/components/eftposPay/amount.d.ts +1 -1
- package/lib/components/eftposPay/app.d.ts +1 -1
- package/lib/components/eftposPay/device.d.ts +1 -1
- package/lib/components/eftposPay/hooks.d.ts +1 -1
- package/lib/components/eftposPay/store/index.d.ts +4 -4
- package/lib/components/ticketBooking/components/addServiceVariant/addService.d.ts +0 -1
- package/lib/components/ticketBooking/components/ticketBooking/index.d.ts +0 -1
- package/lib/components/ticketBooking/index.d.ts +0 -1
- package/lib/components/ticketBooking/utils/index.d.ts +1 -1
- package/lib/plus/productSelect/ProductCard/SkuCard/components/Capacity/index.d.ts +1 -1
- package/lib/plus/productSelect/ProductCard/SkuCard/components/CardMask/index.d.ts +1 -1
- package/lib/plus/productSelect/ProductCard/SkuCard/components/Countdown/index.d.ts +1 -1
- package/lib/plus/productSelect/ProductCard/SkuCard/components/Duration/index.d.ts +1 -1
- package/lib/plus/productSelect/ProductCard/SkuCard/components/MemberPrice/index.d.ts +1 -1
- package/lib/plus/productSelect/ProductCard/SkuCard/components/Resource/index.d.ts +1 -1
- package/lib/plus/productSelect/ProductCard/SkuCard/components/Stock/index.d.ts +1 -1
- package/lib/plus/productSelect/ProductCard/SkuCard/components/Time/index.d.ts +1 -1
- package/lib/plus/saasLogin/utils.d.ts +5 -5
- package/lib/plus/skuOptionsSelection/components/OptionsCard/OptionItemCard.d.ts +0 -1
- package/lib/plus/skuOptionsSelection/components/OptionsModal/index.d.ts +0 -1
- package/lib/plus/skuOptionsSelection/components/VariantCard/index.d.ts +0 -1
- package/lib/plus/skuOptionsSelection/utils/transformBundleGroup.js +10 -0
- package/lib/plus/skuOptionsSelection/utils/transformOptionGroup.js +10 -0
- package/lib/plus/skuOptionsSelection/utils/transformValueToSelectorValue.js +1 -0
- package/lib/plus/skuOptionsSelection/utils/transformVariantGroup.js +10 -0
- package/lib/plus/walletEditor/components/ImageUpload/index.d.ts +1 -1
- package/lib/pro/NumericStepper/index.d.ts +21 -1
- package/lib/pro/NumericStepper/index.js +67 -69
- package/lib/pro/NumericStepper/index.less +289 -136
- package/lib/pro/Selector/demo.d.ts +0 -1
- package/lib/pro/Selector/hooks/usePresetProps.js +2 -1
- package/lib/pro/keyboards/index.d.ts +2 -0
- package/lib/pro/keyboards/index.js +39 -0
- package/lib/pro/keyboards/locales.d.ts +24 -0
- package/lib/pro/keyboards/locales.js +47 -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/priceKeyboard/components/cashKeyboard/CashKeyboardSimple.js +2 -1
- package/lib/pro/priceKeyboard/components/discountKeyboard/index.js +2 -1
- package/lib/pro/priceKeyboard/components/paymentKeyboard/index.d.ts +0 -1
- package/lib/pro/priceKeyboard/components/paymentKeyboard/index.js +6 -3
- package/lib/pro/skuDetailModal/index.js +94 -41
- package/lib/pro/skuDetailModal/index.less +4 -4
- package/package.json +1 -1
- package/es/pro/pisellNumberSelector/example.d.ts +0 -3
- package/es/pro/pisellNumberSelector/example.js +0 -68
- package/lib/pro/pisellNumberSelector/example.d.ts +0 -3
- package/lib/pro/pisellNumberSelector/example.js +0 -93
|
@@ -0,0 +1,524 @@
|
|
|
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
|
+
var _excluded = ["containerProps", "children"],
|
|
3
|
+
_excluded2 = ["renderType", "open", "className"];
|
|
4
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
5
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
6
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
7
|
+
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; }
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
10
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
11
|
+
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); }
|
|
12
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
13
|
+
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."); }
|
|
14
|
+
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); }
|
|
15
|
+
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; }
|
|
16
|
+
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; } }
|
|
17
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
|
+
import React, { useMemo, useCallback, useState, useEffect } from 'react';
|
|
19
|
+
import classNames from 'classnames';
|
|
20
|
+
import { Popover } from 'antd';
|
|
21
|
+
import { useControllableValue } from 'ahooks';
|
|
22
|
+
import { Icon, Keyboard, PisellModal } from '@pisell/materials';
|
|
23
|
+
import { locales } from '@pisell/utils';
|
|
24
|
+
import VirtualInput from "../../../../../materials/src/components/virtualInput";
|
|
25
|
+
import useEngineContext from "../../../hooks/useEngineContext";
|
|
26
|
+
import localeTexts from "../locales";
|
|
27
|
+
import "./index.less";
|
|
28
|
+
|
|
29
|
+
// 生成简单的唯一 ID
|
|
30
|
+
var generateSimpleUUID = function generateSimpleUUID() {
|
|
31
|
+
return Math.random().toString(36).substring(2) + Date.now().toString(36);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* NumberKeyboardBase - 数字输入键盘基础组件
|
|
36
|
+
* 支持整数模式和小数模式
|
|
37
|
+
*/
|
|
38
|
+
var NumberKeyboardBase = function NumberKeyboardBase(props) {
|
|
39
|
+
var _context$engine;
|
|
40
|
+
var _props$mode = props.mode,
|
|
41
|
+
mode = _props$mode === void 0 ? 'integer' : _props$mode,
|
|
42
|
+
_props$originalValue = props.originalValue,
|
|
43
|
+
originalValue = _props$originalValue === void 0 ? '' : _props$originalValue,
|
|
44
|
+
_props$placeholder = props.placeholder,
|
|
45
|
+
placeholder = _props$placeholder === void 0 ? '' : _props$placeholder,
|
|
46
|
+
max = props.max,
|
|
47
|
+
min = props.min,
|
|
48
|
+
maxLength = props.maxLength,
|
|
49
|
+
_props$precision = props.precision,
|
|
50
|
+
precision = _props$precision === void 0 ? 2 : _props$precision,
|
|
51
|
+
_props$disabled = props.disabled,
|
|
52
|
+
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
53
|
+
doneText = props.doneText,
|
|
54
|
+
resetText = props.resetText,
|
|
55
|
+
clearText = props.clearText,
|
|
56
|
+
label = props.label,
|
|
57
|
+
errorText = props.errorText,
|
|
58
|
+
style = props.style,
|
|
59
|
+
className = props.className,
|
|
60
|
+
_props$keydown = props.keydown,
|
|
61
|
+
keydown = _props$keydown === void 0 ? true : _props$keydown,
|
|
62
|
+
inputStyle = props.inputStyle,
|
|
63
|
+
inputWrapperStyle = props.inputWrapperStyle,
|
|
64
|
+
onEnter = props.onEnter,
|
|
65
|
+
onReset = props.onReset;
|
|
66
|
+
var context = useEngineContext();
|
|
67
|
+
locales.init(localeTexts, (context === null || context === void 0 || (_context$engine = context.engine) === null || _context$engine === void 0 || (_context$engine = _context$engine.props) === null || _context$engine === void 0 ? void 0 : _context$engine.locale) || 'en');
|
|
68
|
+
|
|
69
|
+
// 受控/非受控值
|
|
70
|
+
var _useControllableValue = useControllableValue(props, {
|
|
71
|
+
defaultValue: ''
|
|
72
|
+
}),
|
|
73
|
+
_useControllableValue2 = _slicedToArray(_useControllableValue, 2),
|
|
74
|
+
internalValue = _useControllableValue2[0],
|
|
75
|
+
setInternalValue = _useControllableValue2[1];
|
|
76
|
+
var uniqueKeyboardId = useMemo(function () {
|
|
77
|
+
return "number-keyboard-".concat(generateSimpleUUID());
|
|
78
|
+
}, []);
|
|
79
|
+
|
|
80
|
+
// 是否是首次输入(用于选中状态)
|
|
81
|
+
var _useState = useState(!!internalValue),
|
|
82
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
83
|
+
isSelected = _useState2[0],
|
|
84
|
+
setIsSelected = _useState2[1];
|
|
85
|
+
|
|
86
|
+
// 当从外部传入新的 value 时,重新标记为选中状态
|
|
87
|
+
useEffect(function () {
|
|
88
|
+
if (internalValue) {
|
|
89
|
+
setIsSelected(true);
|
|
90
|
+
}
|
|
91
|
+
}, []);
|
|
92
|
+
|
|
93
|
+
// 检查是否超出范围
|
|
94
|
+
var isOutOfRange = useMemo(function () {
|
|
95
|
+
if (!internalValue) return false;
|
|
96
|
+
var numValue = parseFloat(internalValue);
|
|
97
|
+
if (isNaN(numValue)) return false;
|
|
98
|
+
if (max !== undefined && numValue > max) return true;
|
|
99
|
+
if (min !== undefined && numValue < min) return true;
|
|
100
|
+
return false;
|
|
101
|
+
}, [internalValue, max, min]);
|
|
102
|
+
|
|
103
|
+
// 获取错误提示文本
|
|
104
|
+
var errorMessage = useMemo(function () {
|
|
105
|
+
if (!isOutOfRange) return '';
|
|
106
|
+
if (errorText) return errorText;
|
|
107
|
+
var numValue = parseFloat(internalValue);
|
|
108
|
+
if (max !== undefined && numValue > max) {
|
|
109
|
+
return locales.getText('pisell2.keyboard.number-keybard.max')(max);
|
|
110
|
+
}
|
|
111
|
+
if (min !== undefined && numValue < min) {
|
|
112
|
+
return locales.getText('pisell2.keyboard.number-keybard.min')(min);
|
|
113
|
+
}
|
|
114
|
+
return '';
|
|
115
|
+
}, [isOutOfRange, errorText, internalValue, max, min]);
|
|
116
|
+
|
|
117
|
+
// 处理数值变化
|
|
118
|
+
var handleValueChange = useCallback(function (newValue) {
|
|
119
|
+
// 如果当前是选中状态,替换整个值
|
|
120
|
+
if (isSelected && newValue !== '') {
|
|
121
|
+
setIsSelected(false);
|
|
122
|
+
}
|
|
123
|
+
setInternalValue(newValue);
|
|
124
|
+
}, [isSelected, setInternalValue]);
|
|
125
|
+
|
|
126
|
+
// 单个删除
|
|
127
|
+
var handleDelete = useCallback(function () {
|
|
128
|
+
if (isSelected) {
|
|
129
|
+
// 如果是选中状态,删除全部
|
|
130
|
+
handleValueChange('');
|
|
131
|
+
setIsSelected(false);
|
|
132
|
+
} else if (internalValue.length > 0) {
|
|
133
|
+
handleValueChange(internalValue.slice(0, -1));
|
|
134
|
+
}
|
|
135
|
+
}, [internalValue, isSelected, handleValueChange]);
|
|
136
|
+
|
|
137
|
+
// 清空
|
|
138
|
+
var handleClear = useCallback(function () {
|
|
139
|
+
handleValueChange('');
|
|
140
|
+
setIsSelected(false);
|
|
141
|
+
}, [handleValueChange]);
|
|
142
|
+
|
|
143
|
+
// 重置到原始值
|
|
144
|
+
var handleReset = useCallback(function () {
|
|
145
|
+
setInternalValue(String(originalValue));
|
|
146
|
+
setIsSelected(true);
|
|
147
|
+
onReset === null || onReset === void 0 || onReset();
|
|
148
|
+
}, [originalValue, setInternalValue, onReset]);
|
|
149
|
+
|
|
150
|
+
// 确认
|
|
151
|
+
var handleDone = useCallback(function () {
|
|
152
|
+
if (isOutOfRange) return;
|
|
153
|
+
onEnter === null || onEnter === void 0 || onEnter(internalValue);
|
|
154
|
+
}, [internalValue, isOutOfRange, onEnter]);
|
|
155
|
+
|
|
156
|
+
// 处理数字输入
|
|
157
|
+
var handleNumberInput = useCallback(function (num) {
|
|
158
|
+
var newValue;
|
|
159
|
+
if (isSelected) {
|
|
160
|
+
// 选中状态,替换整个值
|
|
161
|
+
newValue = num;
|
|
162
|
+
setIsSelected(false);
|
|
163
|
+
} else {
|
|
164
|
+
newValue = internalValue + num;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// 检查最大长度
|
|
168
|
+
if (maxLength && newValue.replace('.', '').length > maxLength) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// 整数模式不允许小数点
|
|
173
|
+
if (mode === 'integer' && newValue.includes('.')) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// 小数模式检查小数位数
|
|
178
|
+
if (mode === 'decimal' && newValue.includes('.')) {
|
|
179
|
+
var parts = newValue.split('.');
|
|
180
|
+
if (parts[1] && parts[1].length > precision) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// 防止多个小数点
|
|
186
|
+
if (num === '.' && internalValue.includes('.')) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// 防止以多个0开头
|
|
191
|
+
if (newValue.length > 1 && newValue.startsWith('0') && !newValue.startsWith('0.')) {
|
|
192
|
+
newValue = newValue.replace(/^0+/, '') || '0';
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// 处理 "00" 输入
|
|
196
|
+
if (num === '00') {
|
|
197
|
+
if (internalValue === '' || internalValue === '0') {
|
|
198
|
+
newValue = '0';
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
handleValueChange(newValue);
|
|
202
|
+
}, [internalValue, isSelected, maxLength, mode, precision, handleValueChange]);
|
|
203
|
+
|
|
204
|
+
// 键盘按键处理
|
|
205
|
+
var handleKeyboardChange = useCallback(function (key) {
|
|
206
|
+
if (key === undefined) return;
|
|
207
|
+
var keyStr = String(key);
|
|
208
|
+
switch (keyStr) {
|
|
209
|
+
case 'delete':
|
|
210
|
+
case 'backspace':
|
|
211
|
+
handleDelete();
|
|
212
|
+
break;
|
|
213
|
+
case 'clear':
|
|
214
|
+
handleClear();
|
|
215
|
+
break;
|
|
216
|
+
case 'reset':
|
|
217
|
+
handleReset();
|
|
218
|
+
break;
|
|
219
|
+
case 'done':
|
|
220
|
+
case 'ok':
|
|
221
|
+
handleDone();
|
|
222
|
+
break;
|
|
223
|
+
default:
|
|
224
|
+
// 数字或小数点
|
|
225
|
+
if (/^[0-9.]$/.test(keyStr) || keyStr === '00') {
|
|
226
|
+
handleNumberInput(keyStr);
|
|
227
|
+
}
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
}, [handleDelete, handleClear, handleReset, handleDone, handleNumberInput]);
|
|
231
|
+
|
|
232
|
+
// 整数模式键盘配置 (3列布局)
|
|
233
|
+
var integerKeyboardItems = useMemo(function () {
|
|
234
|
+
return [{
|
|
235
|
+
value: 1,
|
|
236
|
+
label: '1',
|
|
237
|
+
disabled: false,
|
|
238
|
+
type: 'text'
|
|
239
|
+
}, {
|
|
240
|
+
value: 2,
|
|
241
|
+
label: '2',
|
|
242
|
+
disabled: false,
|
|
243
|
+
type: 'text'
|
|
244
|
+
}, {
|
|
245
|
+
value: 3,
|
|
246
|
+
label: '3',
|
|
247
|
+
disabled: false,
|
|
248
|
+
type: 'text'
|
|
249
|
+
}, {
|
|
250
|
+
value: 4,
|
|
251
|
+
label: '4',
|
|
252
|
+
disabled: false,
|
|
253
|
+
type: 'text'
|
|
254
|
+
}, {
|
|
255
|
+
value: 5,
|
|
256
|
+
label: '5',
|
|
257
|
+
disabled: false,
|
|
258
|
+
type: 'text'
|
|
259
|
+
}, {
|
|
260
|
+
value: 6,
|
|
261
|
+
label: '6',
|
|
262
|
+
disabled: false,
|
|
263
|
+
type: 'text'
|
|
264
|
+
}, {
|
|
265
|
+
value: 7,
|
|
266
|
+
label: '7',
|
|
267
|
+
disabled: false,
|
|
268
|
+
type: 'text'
|
|
269
|
+
}, {
|
|
270
|
+
value: 8,
|
|
271
|
+
label: '8',
|
|
272
|
+
disabled: false,
|
|
273
|
+
type: 'text'
|
|
274
|
+
}, {
|
|
275
|
+
value: 9,
|
|
276
|
+
label: '9',
|
|
277
|
+
disabled: false,
|
|
278
|
+
type: 'text'
|
|
279
|
+
}, {
|
|
280
|
+
value: 'reset',
|
|
281
|
+
label: resetText || locales.getText('pisell2.keyboard.number-keybard.reset'),
|
|
282
|
+
disabled: false,
|
|
283
|
+
type: 'text',
|
|
284
|
+
style: {
|
|
285
|
+
color: '#F04438',
|
|
286
|
+
fontSize: 18
|
|
287
|
+
}
|
|
288
|
+
}, {
|
|
289
|
+
value: 0,
|
|
290
|
+
label: '0',
|
|
291
|
+
disabled: false,
|
|
292
|
+
type: 'text'
|
|
293
|
+
}, {
|
|
294
|
+
value: 'done',
|
|
295
|
+
label: doneText || locales.getText('pisell2.keyboard.number-keybard.ok'),
|
|
296
|
+
disabled: isOutOfRange,
|
|
297
|
+
type: 'primary',
|
|
298
|
+
style: {
|
|
299
|
+
fontSize: 18
|
|
300
|
+
}
|
|
301
|
+
}];
|
|
302
|
+
}, [resetText, doneText, isOutOfRange]);
|
|
303
|
+
|
|
304
|
+
// 小数模式键盘配置 (4列布局,带右侧按钮)
|
|
305
|
+
var decimalKeyboardItems = useMemo(function () {
|
|
306
|
+
return [{
|
|
307
|
+
value: 1,
|
|
308
|
+
label: '1',
|
|
309
|
+
disabled: false,
|
|
310
|
+
type: 'text'
|
|
311
|
+
}, {
|
|
312
|
+
value: 2,
|
|
313
|
+
label: '2',
|
|
314
|
+
disabled: false,
|
|
315
|
+
type: 'text'
|
|
316
|
+
}, {
|
|
317
|
+
value: 3,
|
|
318
|
+
label: '3',
|
|
319
|
+
disabled: false,
|
|
320
|
+
type: 'text'
|
|
321
|
+
}, {
|
|
322
|
+
value: 4,
|
|
323
|
+
label: '4',
|
|
324
|
+
disabled: false,
|
|
325
|
+
type: 'text'
|
|
326
|
+
}, {
|
|
327
|
+
value: 5,
|
|
328
|
+
label: '5',
|
|
329
|
+
disabled: false,
|
|
330
|
+
type: 'text'
|
|
331
|
+
}, {
|
|
332
|
+
value: 6,
|
|
333
|
+
label: '6',
|
|
334
|
+
disabled: false,
|
|
335
|
+
type: 'text'
|
|
336
|
+
}, {
|
|
337
|
+
value: 7,
|
|
338
|
+
label: '7',
|
|
339
|
+
disabled: false,
|
|
340
|
+
type: 'text'
|
|
341
|
+
}, {
|
|
342
|
+
value: 8,
|
|
343
|
+
label: '8',
|
|
344
|
+
disabled: false,
|
|
345
|
+
type: 'text'
|
|
346
|
+
}, {
|
|
347
|
+
value: 9,
|
|
348
|
+
label: '9',
|
|
349
|
+
disabled: false,
|
|
350
|
+
type: 'text'
|
|
351
|
+
}, {
|
|
352
|
+
value: 0,
|
|
353
|
+
label: '0',
|
|
354
|
+
disabled: false,
|
|
355
|
+
type: 'text'
|
|
356
|
+
}, {
|
|
357
|
+
value: '00',
|
|
358
|
+
label: '00',
|
|
359
|
+
disabled: false,
|
|
360
|
+
type: 'text'
|
|
361
|
+
}, {
|
|
362
|
+
value: '.',
|
|
363
|
+
label: '.',
|
|
364
|
+
disabled: false,
|
|
365
|
+
type: 'text'
|
|
366
|
+
}];
|
|
367
|
+
}, []);
|
|
368
|
+
|
|
369
|
+
// 小数模式右侧按钮
|
|
370
|
+
var decimalRightItems = useMemo(function () {
|
|
371
|
+
return [{
|
|
372
|
+
value: 'clear',
|
|
373
|
+
label: clearText || locales.getText('pisell2.keyboard.number-keybard.clear'),
|
|
374
|
+
disabled: false,
|
|
375
|
+
type: 'text',
|
|
376
|
+
size: 1,
|
|
377
|
+
style: {
|
|
378
|
+
fontSize: 18
|
|
379
|
+
}
|
|
380
|
+
}, {
|
|
381
|
+
value: 'reset',
|
|
382
|
+
label: resetText || locales.getText('pisell2.keyboard.number-keybard.reset'),
|
|
383
|
+
disabled: false,
|
|
384
|
+
type: 'text',
|
|
385
|
+
size: 1,
|
|
386
|
+
style: {
|
|
387
|
+
color: '#F04438',
|
|
388
|
+
fontSize: 18
|
|
389
|
+
}
|
|
390
|
+
}, {
|
|
391
|
+
value: 'done',
|
|
392
|
+
label: doneText || locales.getText('pisell2.keyboard.number-keybard.ok'),
|
|
393
|
+
disabled: isOutOfRange,
|
|
394
|
+
type: 'primary',
|
|
395
|
+
size: 2,
|
|
396
|
+
style: {
|
|
397
|
+
fontSize: 18
|
|
398
|
+
}
|
|
399
|
+
}];
|
|
400
|
+
}, [clearText, resetText, doneText, isOutOfRange]);
|
|
401
|
+
|
|
402
|
+
// 渲染输入框显示值
|
|
403
|
+
var displayValue = useMemo(function () {
|
|
404
|
+
return internalValue || '';
|
|
405
|
+
}, [internalValue]);
|
|
406
|
+
var renderBottomContent = useCallback(function () {
|
|
407
|
+
if (isOutOfRange && errorMessage) {
|
|
408
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
409
|
+
className: "pisell-number-keyboard-error-message"
|
|
410
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
411
|
+
type: "pisell2-alert-circle",
|
|
412
|
+
size: 16
|
|
413
|
+
}), errorMessage);
|
|
414
|
+
}
|
|
415
|
+
return null;
|
|
416
|
+
}, [errorMessage]);
|
|
417
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
418
|
+
className: classNames('pisell-number-keyboard', "pisell-number-keyboard--".concat(mode), {
|
|
419
|
+
'pisell-number-keyboard--disabled': disabled
|
|
420
|
+
}, className),
|
|
421
|
+
style: style
|
|
422
|
+
}, label && /*#__PURE__*/React.createElement("div", {
|
|
423
|
+
className: "pisell-number-keyboard-label"
|
|
424
|
+
}, label), /*#__PURE__*/React.createElement("div", {
|
|
425
|
+
className: classNames('pisell-number-keyboard-input-wrapper')
|
|
426
|
+
}, /*#__PURE__*/React.createElement(VirtualInput, {
|
|
427
|
+
focused: !disabled,
|
|
428
|
+
selected: isSelected && !!internalValue,
|
|
429
|
+
value: displayValue,
|
|
430
|
+
placeholder: placeholder,
|
|
431
|
+
wrapperStyle: _objectSpread({
|
|
432
|
+
flex: 1,
|
|
433
|
+
padding: '19px 16px',
|
|
434
|
+
borderRadius: '8px',
|
|
435
|
+
backgroundColor: 'white',
|
|
436
|
+
boxShadow: '0px 1px 2px rgba(16, 24, 40, 0.06)',
|
|
437
|
+
overflow: 'hidden'
|
|
438
|
+
}, inputWrapperStyle),
|
|
439
|
+
style: _objectSpread({
|
|
440
|
+
fontSize: '48px',
|
|
441
|
+
fontWeight: 'bold',
|
|
442
|
+
border: 'none',
|
|
443
|
+
background: 'transparent',
|
|
444
|
+
width: '100%',
|
|
445
|
+
color: isOutOfRange ? '#D92D20' : undefined
|
|
446
|
+
}, inputStyle),
|
|
447
|
+
preventBlurElements: ["#".concat(uniqueKeyboardId)],
|
|
448
|
+
allowClear: true,
|
|
449
|
+
onClear: handleDelete,
|
|
450
|
+
textAlign: "center"
|
|
451
|
+
}), renderBottomContent()), /*#__PURE__*/React.createElement(Keyboard, {
|
|
452
|
+
id: uniqueKeyboardId,
|
|
453
|
+
className: classNames('pisell-number-keyboard-keys', {
|
|
454
|
+
'pisell-number-keyboard-keys--integer': mode === 'integer',
|
|
455
|
+
'pisell-number-keyboard-keys--decimal': mode === 'decimal'
|
|
456
|
+
}),
|
|
457
|
+
items: mode === 'integer' ? integerKeyboardItems : decimalKeyboardItems,
|
|
458
|
+
rightItems: mode === 'decimal' ? decimalRightItems : undefined,
|
|
459
|
+
keydown: keydown,
|
|
460
|
+
onChange: handleKeyboardChange
|
|
461
|
+
}));
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* NumberKeyboard - 数字输入键盘
|
|
466
|
+
* 支持基础形式展示、popover 形态或 modal 形态
|
|
467
|
+
*/
|
|
468
|
+
var NumberKeyboard = function NumberKeyboard(props) {
|
|
469
|
+
var containerProps = props.containerProps,
|
|
470
|
+
children = props.children,
|
|
471
|
+
keyboardProps = _objectWithoutProperties(props, _excluded);
|
|
472
|
+
|
|
473
|
+
// 无 containerProps,直接渲染基础组件
|
|
474
|
+
if (!containerProps) {
|
|
475
|
+
return /*#__PURE__*/React.createElement(NumberKeyboardBase, keyboardProps);
|
|
476
|
+
}
|
|
477
|
+
var _ref = containerProps || {},
|
|
478
|
+
renderType = _ref.renderType,
|
|
479
|
+
open = _ref.open,
|
|
480
|
+
className = _ref.className,
|
|
481
|
+
restProps = _objectWithoutProperties(_ref, _excluded2);
|
|
482
|
+
|
|
483
|
+
// Popover 模式(受控)
|
|
484
|
+
if (renderType === 'popover') {
|
|
485
|
+
return /*#__PURE__*/React.createElement(Popover, _extends({
|
|
486
|
+
key: "".concat(open),
|
|
487
|
+
open: open,
|
|
488
|
+
trigger: ['click'],
|
|
489
|
+
overlayClassName: classNames('pisell-number-keyboard-popover', className),
|
|
490
|
+
destroyTooltipOnHide: true,
|
|
491
|
+
overlayInnerStyle: {
|
|
492
|
+
padding: 0
|
|
493
|
+
},
|
|
494
|
+
arrow: false
|
|
495
|
+
}, restProps, {
|
|
496
|
+
content: /*#__PURE__*/React.createElement(NumberKeyboardBase, keyboardProps)
|
|
497
|
+
}), children);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// Modal 模式(受控)
|
|
501
|
+
if (renderType === 'modal') {
|
|
502
|
+
return open ? /*#__PURE__*/React.createElement(PisellModal, _extends({
|
|
503
|
+
platform: 'pc',
|
|
504
|
+
open: true,
|
|
505
|
+
width: "unset",
|
|
506
|
+
header: null,
|
|
507
|
+
footer: false,
|
|
508
|
+
mask: false,
|
|
509
|
+
maskClosable: true,
|
|
510
|
+
bodyStyle: {
|
|
511
|
+
padding: '0px',
|
|
512
|
+
backgroundColor: 'transparent'
|
|
513
|
+
},
|
|
514
|
+
closeIcon: null,
|
|
515
|
+
className: classNames('pisell-number-keyboard-modal', className),
|
|
516
|
+
destroyOnHidden: true
|
|
517
|
+
}, restProps), /*#__PURE__*/React.createElement(NumberKeyboardBase, keyboardProps)) : null;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// 默认渲染基础组件
|
|
521
|
+
return /*#__PURE__*/React.createElement(NumberKeyboardBase, keyboardProps);
|
|
522
|
+
};
|
|
523
|
+
export default NumberKeyboard;
|
|
524
|
+
export { NumberKeyboardBase };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
.pisell-number-keyboard-modal {
|
|
2
|
+
.ant-moda-content,
|
|
3
|
+
.pisell-lowcode-modal-content {
|
|
4
|
+
background-color: transparent;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.pisell-number-keyboard-popover {
|
|
9
|
+
.ant-popover-inner,
|
|
10
|
+
.pisell-lowcode-popover-inner {
|
|
11
|
+
background-color: transparent;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.pisell-number-keyboard {
|
|
16
|
+
padding: 10px;
|
|
17
|
+
border-radius: 10px;
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
gap: 8px;
|
|
21
|
+
background-color: rgba(0, 0, 0, 0.7);
|
|
22
|
+
width: 344px;
|
|
23
|
+
|
|
24
|
+
&--disabled {
|
|
25
|
+
pointer-events: none;
|
|
26
|
+
opacity: 0.6;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&-label {
|
|
30
|
+
font-size: 20px;
|
|
31
|
+
font-weight: 600;
|
|
32
|
+
color: #fff;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&-error-message {
|
|
36
|
+
user-select: none;
|
|
37
|
+
font-size: 12px;
|
|
38
|
+
color: #d92d20;
|
|
39
|
+
line-height: 18px;
|
|
40
|
+
padding: 0 4px;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.pisell-number-keyboard-input-wrapper {
|
|
45
|
+
position: relative;
|
|
46
|
+
|
|
47
|
+
.pisell-number-keyboard-error-message {
|
|
48
|
+
position: absolute;
|
|
49
|
+
bottom: 0;
|
|
50
|
+
left: 0;
|
|
51
|
+
right: 0;
|
|
52
|
+
font-size: 12px;
|
|
53
|
+
color: #f04438;
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
justify-content: center;
|
|
57
|
+
gap: 4px;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare type NumberKeyboardMode = 'integer' | 'decimal';
|
|
3
|
+
export interface NumberKeyboardBaseProps {
|
|
4
|
+
/** 模式:整数 or 小数 */
|
|
5
|
+
mode?: NumberKeyboardMode;
|
|
6
|
+
/** 当前值(受控) */
|
|
7
|
+
value?: string;
|
|
8
|
+
/** 默认值(非受控) */
|
|
9
|
+
defaultValue?: string;
|
|
10
|
+
/** 原始值,用于重置 */
|
|
11
|
+
originalValue?: string;
|
|
12
|
+
/** 占位符 */
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
/** 最大值 */
|
|
15
|
+
max?: number;
|
|
16
|
+
/** 最小值 */
|
|
17
|
+
min?: number;
|
|
18
|
+
/** 最大长度 */
|
|
19
|
+
maxLength?: number;
|
|
20
|
+
/** 小数位数,默认 2 */
|
|
21
|
+
precision?: number;
|
|
22
|
+
/** 是否禁用 */
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
/** 确认按钮文本 */
|
|
25
|
+
doneText?: string;
|
|
26
|
+
/** 重置按钮文本 */
|
|
27
|
+
resetText?: string;
|
|
28
|
+
/** 清空按钮文本 */
|
|
29
|
+
clearText?: string;
|
|
30
|
+
/** 标签文本(显示在输入框上方) */
|
|
31
|
+
label?: string;
|
|
32
|
+
/** 超出范围时的提示文本 */
|
|
33
|
+
errorText?: string;
|
|
34
|
+
/** 值变化回调 */
|
|
35
|
+
onChange?: (value: string) => void;
|
|
36
|
+
/** 确认按钮点击回调 */
|
|
37
|
+
onEnter?: (value: string) => void;
|
|
38
|
+
/** 重置按钮点击回调 */
|
|
39
|
+
onReset?: () => void;
|
|
40
|
+
/** 外层样式 */
|
|
41
|
+
style?: React.CSSProperties;
|
|
42
|
+
/** 自定义类名 */
|
|
43
|
+
className?: string;
|
|
44
|
+
/** 键盘是否监听物理键盘 */
|
|
45
|
+
keydown?: boolean;
|
|
46
|
+
/** 输入框样式 */
|
|
47
|
+
inputStyle?: React.CSSProperties;
|
|
48
|
+
/** 输入框包裹样式 */
|
|
49
|
+
inputWrapperStyle?: React.CSSProperties;
|
|
50
|
+
}
|
|
51
|
+
export interface NumberKeyboardProps extends NumberKeyboardBaseProps {
|
|
52
|
+
/** 容器配置,用于控制键盘以 popover 或 modal 形态展示 */
|
|
53
|
+
containerProps?: {
|
|
54
|
+
/** 渲染类型:popover 或 modal */
|
|
55
|
+
renderType: 'modal' | 'popover';
|
|
56
|
+
/** 是否打开(受控模式) */
|
|
57
|
+
open?: boolean;
|
|
58
|
+
/** 其他传递给 Popover 或 Modal 的属性 */
|
|
59
|
+
[key: string]: any;
|
|
60
|
+
};
|
|
61
|
+
/** 子元素,用于 popover 模式的触发器 */
|
|
62
|
+
children?: React.ReactNode;
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -239,7 +239,8 @@ var CashKeyboardBase = function CashKeyboardBase(props) {
|
|
|
239
239
|
background: 'transparent',
|
|
240
240
|
width: '100%'
|
|
241
241
|
},
|
|
242
|
-
preventBlurElements: ["#".concat(uniqueKeyboardId), shortcutsRef]
|
|
242
|
+
preventBlurElements: ["#".concat(uniqueKeyboardId), shortcutsRef],
|
|
243
|
+
selected: isFirstInput && !!internalValue
|
|
243
244
|
}), /*#__PURE__*/React.createElement("div", {
|
|
244
245
|
style: {
|
|
245
246
|
display: 'flex',
|
|
@@ -256,7 +256,8 @@ var DiscountKeyboardBase = function DiscountKeyboardBase(props) {
|
|
|
256
256
|
color: _color
|
|
257
257
|
},
|
|
258
258
|
placeholder: placeholder,
|
|
259
|
-
bottomContent: renderBottomContent()
|
|
259
|
+
bottomContent: renderBottomContent(),
|
|
260
|
+
selected: isFirstInput && updateMode === 'priceOverride' && !!internalValue
|
|
260
261
|
}), /*#__PURE__*/React.createElement("div", {
|
|
261
262
|
style: {
|
|
262
263
|
flex: '1',
|