@pisell/materials 2.2.28 → 2.2.30

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.
Files changed (100) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +2 -2
  6. package/build/lowcode/preview.js +8 -8
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +13 -13
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +19 -19
  11. package/es/components/pisellAdjustPrice/PisellAdjustPriceInputNumber.d.ts +10 -0
  12. package/es/components/pisellAdjustPrice/PisellAdjustPriceInputNumber.js +62 -0
  13. package/es/components/pisellAdjustPrice/index.d.ts +10 -0
  14. package/es/components/pisellAdjustPrice/index.js +148 -0
  15. package/es/components/pisellAdjustPrice/index.less +30 -0
  16. package/es/components/pisellFloatingPanel/index.d.ts +17 -0
  17. package/es/components/pisellFloatingPanel/index.js +89 -0
  18. package/es/components/pisellFloatingPanel/index.less +30 -0
  19. package/es/components/pisellStatisticList/index.d.ts +18 -0
  20. package/es/components/pisellStatisticList/index.js +67 -0
  21. package/es/components/pisellStatisticList/index.less +47 -0
  22. package/es/components/segmented/index.d.ts +1 -0
  23. package/es/components/segmented/index.js +1 -0
  24. package/es/components/segmented/index.less +3 -0
  25. package/es/components/virtual-keyboard/Amount/index.d.ts +22 -0
  26. package/es/components/virtual-keyboard/Amount/index.js +65 -0
  27. package/es/components/virtual-keyboard/BaseNumberKeyboard/Presets.d.ts +12 -0
  28. package/es/components/virtual-keyboard/BaseNumberKeyboard/Presets.js +22 -0
  29. package/es/components/virtual-keyboard/BaseNumberKeyboard/Presets.less +18 -0
  30. package/es/components/virtual-keyboard/BaseNumberKeyboard/index.d.ts +19 -0
  31. package/es/components/virtual-keyboard/BaseNumberKeyboard/index.js +213 -0
  32. package/es/components/virtual-keyboard/BaseNumberKeyboard/index.less +9 -0
  33. package/es/components/virtual-keyboard/Keyboard/index.d.ts +8 -6
  34. package/es/components/virtual-keyboard/Keyboard/index.js +59 -15
  35. package/es/components/virtual-keyboard/Keyboard/index.less +35 -24
  36. package/es/components/virtual-keyboard/Number/index.d.ts +14 -0
  37. package/es/components/virtual-keyboard/Number/index.js +35 -0
  38. package/es/components/virtual-keyboard/VirtualInput/index.d.ts +9 -0
  39. package/es/components/virtual-keyboard/VirtualInput/index.js +41 -0
  40. package/es/components/virtual-keyboard/VirtualInput/index.less +46 -0
  41. package/es/components/virtual-keyboard/VirtualKeyInput/index.d.ts +6 -3
  42. package/es/components/virtual-keyboard/VirtualKeyInput/index.js +27 -20
  43. package/es/index.d.ts +6 -0
  44. package/es/index.js +7 -1
  45. package/es/locales/en-US.d.ts +6 -0
  46. package/es/locales/en-US.js +8 -1
  47. package/es/locales/zh-CN.d.ts +6 -0
  48. package/es/locales/zh-CN.js +8 -1
  49. package/es/locales/zh-TW.d.ts +6 -0
  50. package/es/locales/zh-TW.js +8 -1
  51. package/lib/components/pisellAdjustPrice/PisellAdjustPriceInputNumber.d.ts +10 -0
  52. package/lib/components/pisellAdjustPrice/PisellAdjustPriceInputNumber.js +84 -0
  53. package/lib/components/pisellAdjustPrice/index.d.ts +10 -0
  54. package/lib/components/pisellAdjustPrice/index.js +156 -0
  55. package/lib/components/pisellAdjustPrice/index.less +30 -0
  56. package/lib/components/pisellFloatingPanel/index.d.ts +17 -0
  57. package/lib/components/pisellFloatingPanel/index.js +113 -0
  58. package/lib/components/pisellFloatingPanel/index.less +30 -0
  59. package/lib/components/pisellStatisticList/index.d.ts +18 -0
  60. package/lib/components/pisellStatisticList/index.js +109 -0
  61. package/lib/components/pisellStatisticList/index.less +47 -0
  62. package/lib/components/segmented/index.d.ts +1 -0
  63. package/lib/components/segmented/index.js +1 -0
  64. package/lib/components/segmented/index.less +3 -0
  65. package/lib/components/virtual-keyboard/Amount/index.d.ts +22 -0
  66. package/lib/components/virtual-keyboard/Amount/index.js +96 -0
  67. package/lib/components/virtual-keyboard/BaseNumberKeyboard/Presets.d.ts +12 -0
  68. package/lib/components/virtual-keyboard/BaseNumberKeyboard/Presets.js +46 -0
  69. package/lib/components/virtual-keyboard/BaseNumberKeyboard/Presets.less +18 -0
  70. package/lib/components/virtual-keyboard/BaseNumberKeyboard/index.d.ts +19 -0
  71. package/lib/components/virtual-keyboard/BaseNumberKeyboard/index.js +245 -0
  72. package/lib/components/virtual-keyboard/BaseNumberKeyboard/index.less +9 -0
  73. package/lib/components/virtual-keyboard/Keyboard/index.d.ts +8 -6
  74. package/lib/components/virtual-keyboard/Keyboard/index.js +51 -4
  75. package/lib/components/virtual-keyboard/Keyboard/index.less +35 -24
  76. package/lib/components/virtual-keyboard/Number/index.d.ts +14 -0
  77. package/lib/components/virtual-keyboard/Number/index.js +65 -0
  78. package/lib/components/virtual-keyboard/VirtualInput/index.d.ts +9 -0
  79. package/lib/components/virtual-keyboard/VirtualInput/index.js +63 -0
  80. package/lib/components/virtual-keyboard/VirtualInput/index.less +46 -0
  81. package/lib/components/virtual-keyboard/VirtualKeyInput/index.d.ts +6 -3
  82. package/lib/components/virtual-keyboard/VirtualKeyInput/index.js +20 -11
  83. package/lib/index.d.ts +6 -0
  84. package/lib/index.js +18 -0
  85. package/lib/locales/en-US.d.ts +6 -0
  86. package/lib/locales/en-US.js +8 -1
  87. package/lib/locales/zh-CN.d.ts +6 -0
  88. package/lib/locales/zh-CN.js +8 -1
  89. package/lib/locales/zh-TW.d.ts +6 -0
  90. package/lib/locales/zh-TW.js +8 -1
  91. package/lowcode/input/meta.ts +25 -0
  92. package/lowcode/pisell-adjust-price/meta.ts +58 -0
  93. package/lowcode/pisell-adjust-price/snippets.ts +10 -0
  94. package/lowcode/pisell-adjust-price-input-number/meta.ts +245 -0
  95. package/lowcode/pisell-floating-panel/meta.ts +232 -0
  96. package/lowcode/pisell-modal.information/meta.ts +5 -0
  97. package/lowcode/pisell-number-keyboard/meta.ts +98 -0
  98. package/lowcode/pisell-price-keyboard/meta.ts +174 -0
  99. package/lowcode/pisell-statistic-list/meta.ts +264 -0
  100. package/package.json +3 -3
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import "./Presets.less";
3
+ export declare type PresetsItem = {
4
+ label: string;
5
+ value: number | string;
6
+ };
7
+ export interface PresetsProps {
8
+ presets?: PresetsItem[];
9
+ onChange: (val: string) => void;
10
+ }
11
+ declare const Presets: (props: PresetsProps) => React.JSX.Element | null;
12
+ export default Presets;
@@ -0,0 +1,22 @@
1
+ import React, { useMemo } from 'react';
2
+ import "./Presets.less";
3
+ var Presets = function Presets(props) {
4
+ var presets = props.presets,
5
+ onChange = props.onChange;
6
+ return useMemo(function () {
7
+ if (!(presets !== null && presets !== void 0 && presets.length)) {
8
+ return null;
9
+ }
10
+ return /*#__PURE__*/React.createElement("div", {
11
+ className: "pisell-virtual-keyboard-preset"
12
+ }, presets.map(function (item) {
13
+ return /*#__PURE__*/React.createElement("div", {
14
+ onClick: function onClick() {
15
+ return onChange("".concat(item.value));
16
+ },
17
+ className: "pisell-virtual-keyboard-preset-item"
18
+ }, item.label);
19
+ }));
20
+ }, [presets]);
21
+ };
22
+ export default Presets;
@@ -0,0 +1,18 @@
1
+ .pisell-virtual-keyboard-preset {
2
+ display: flex;
3
+ gap: 7px;
4
+ flex-wrap: wrap;
5
+ margin-bottom: 8px;
6
+ .pisell-virtual-keyboard-preset-item {
7
+ display: flex;
8
+ flex: 1;
9
+ padding: 12px 20px;
10
+ align-items: center;
11
+ justify-content: center;
12
+ height: 48px;
13
+ border-radius: 8px;
14
+ border: 1px solid var(--Gray-300, #D0D5DD);
15
+ box-shadow: 0px 1px 2px 0px rgba(16, 24, 40, 0.05);
16
+ background: var(--Primary-25, #FCFAFF);
17
+ }
18
+ }
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { PresetsProps } from "./Presets";
3
+ import './index.less';
4
+ export interface BaseNumberKeyboardProps {
5
+ placeholder?: string;
6
+ format?: (val: string) => React.ReactNode;
7
+ defaultValue?: string | number;
8
+ doneText?: string;
9
+ resetText?: string;
10
+ onChange?: (val: string) => void;
11
+ onEnter?: (val: string) => void;
12
+ value?: string | number;
13
+ max?: number;
14
+ min?: number;
15
+ presets?: PresetsProps['presets'];
16
+ defaultSelect?: boolean;
17
+ }
18
+ declare const BaseNumberKeyboard: (props: BaseNumberKeyboardProps) => React.JSX.Element;
19
+ export default BaseNumberKeyboard;
@@ -0,0 +1,213 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ 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."); }
3
+ 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); }
4
+ 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; }
5
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import React, { useEffect, useMemo, useState } from 'react';
8
+ import Delete from '@pisell/icon/es/Delete';
9
+ import { useControllableValue, useMemoizedFn } from 'ahooks';
10
+ import { isNumber, isUndefined } from '@pisell/utils';
11
+ import Presets from "./Presets";
12
+ import Keyboard from "../Keyboard";
13
+ import VirtualKeyInput from "../VirtualKeyInput";
14
+ import VirtualInput from "../VirtualInput";
15
+ import "./index.less";
16
+ var items = [{
17
+ value: 1,
18
+ label: '1',
19
+ disabled: false,
20
+ type: 'text'
21
+ }, {
22
+ value: 2,
23
+ label: '2',
24
+ disabled: false,
25
+ type: 'text'
26
+ }, {
27
+ value: 3,
28
+ label: '3',
29
+ disabled: false,
30
+ type: 'text'
31
+ }, {
32
+ value: 4,
33
+ label: '4',
34
+ disabled: false,
35
+ type: 'text'
36
+ }, {
37
+ value: 5,
38
+ label: '5',
39
+ disabled: false,
40
+ type: 'text'
41
+ }, {
42
+ value: 6,
43
+ label: '6',
44
+ disabled: false,
45
+ type: 'text'
46
+ }, {
47
+ value: 7,
48
+ label: '7',
49
+ disabled: false,
50
+ type: 'text'
51
+ }, {
52
+ value: 8,
53
+ label: '8',
54
+ disabled: false,
55
+ type: 'text'
56
+ }, {
57
+ value: 9,
58
+ label: '9',
59
+ disabled: false,
60
+ type: 'text'
61
+ }, {
62
+ value: '0',
63
+ label: '0',
64
+ disabled: false,
65
+ type: 'text'
66
+ }, {
67
+ value: '00',
68
+ label: '00',
69
+ disabled: false,
70
+ type: 'text'
71
+ }, {
72
+ value: '.',
73
+ label: '.',
74
+ disabled: false,
75
+ type: 'text'
76
+ }];
77
+ var BaseNumberKeyboard = function BaseNumberKeyboard(props) {
78
+ var onChange = props.onChange,
79
+ placeholder = props.placeholder,
80
+ format = props.format,
81
+ _props$defaultValue = props.defaultValue,
82
+ defaultValue = _props$defaultValue === void 0 ? '' : _props$defaultValue,
83
+ doneText = props.doneText,
84
+ resetText = props.resetText,
85
+ max = props.max,
86
+ min = props.min,
87
+ onEnter = props.onEnter,
88
+ presets = props.presets,
89
+ defaultSelect = props.defaultSelect;
90
+ var _useControllableValue = useControllableValue(props, {
91
+ defaultValue: defaultValue
92
+ }),
93
+ _useControllableValue2 = _slicedToArray(_useControllableValue, 2),
94
+ value = _useControllableValue2[0],
95
+ setValue = _useControllableValue2[1];
96
+ var _useState = useState(defaultSelect !== null && defaultSelect !== void 0 ? defaultSelect : false),
97
+ _useState2 = _slicedToArray(_useState, 2),
98
+ select = _useState2[0],
99
+ setSelect = _useState2[1];
100
+ useEffect(function () {
101
+ document.body.id = 'body';
102
+ }, []);
103
+ var rightItems = useMemo(function () {
104
+ return [{
105
+ value: 'delete',
106
+ label: /*#__PURE__*/React.createElement(Delete, {
107
+ className: "virtual-keyboard-input-delete-icon"
108
+ }),
109
+ disabled: false,
110
+ type: 'text'
111
+ }, {
112
+ value: 'reset',
113
+ label: resetText || 'Reset',
114
+ disabled: false,
115
+ type: 'text',
116
+ style: {
117
+ fontSize: '18px',
118
+ color: '#D92D20'
119
+ }
120
+ }, {
121
+ value: 'done',
122
+ label: doneText || 'Done',
123
+ disabled: false,
124
+ type: 'primary',
125
+ size: 2,
126
+ style: {
127
+ fontSize: '18px',
128
+ background: 'var(--Green-light-600, #4CA30D)',
129
+ color: '#fff'
130
+ }
131
+ }];
132
+ }, [doneText, resetText]);
133
+ var checkValue = function checkValue(val) {
134
+ // 超过最大值时使用最大值
135
+ if (isNumber(max) && Number(val) > max) {
136
+ var newValue = Math.min(Number(val), Number(max));
137
+ setValue("".concat(newValue));
138
+ return {
139
+ message: ''
140
+ };
141
+ }
142
+ // 小于最小值时使用最小值
143
+ if (isNumber(min) && Number(val) < min) {
144
+ var _newValue = Math.max(Number(val), Number(min));
145
+ setValue("".concat(_newValue));
146
+ return {
147
+ message: ''
148
+ };
149
+ }
150
+ };
151
+ var handleChangeValue = function handleChangeValue(val) {
152
+ var detail = checkValue(val);
153
+ if (detail) return;
154
+ setValue(val);
155
+ };
156
+ var actions = {
157
+ '.': function _(val) {
158
+ // 如果已经有小数点了,则不处理
159
+ if (value.includes('.')) return;
160
+ actions.default(val);
161
+ },
162
+ delete: function _delete() {
163
+ // 选中时删除全部 否则删除最后一位
164
+ handleChangeValue(select ? '' : "".concat(value || "").slice(0, -1));
165
+ },
166
+ reset: function reset() {
167
+ // 重置到默认值
168
+ handleChangeValue("".concat(defaultValue || "") || '');
169
+ },
170
+ done: function done() {
171
+ onEnter === null || onEnter === void 0 ? void 0 : onEnter(value);
172
+ },
173
+ ok: function ok() {
174
+ onEnter === null || onEnter === void 0 ? void 0 : onEnter(value);
175
+ },
176
+ default: function _default(val) {
177
+ // 选中时输入覆盖原有数据
178
+ handleChangeValue(select ? "".concat(val) : "".concat(value).concat(val));
179
+ }
180
+ };
181
+ var handleKeyboardChange = useMemoizedFn(function (val) {
182
+ return (actions[val] || actions.default)(val);
183
+ });
184
+ return /*#__PURE__*/React.createElement("div", {
185
+ className: "pisell-virtual-keyboard-base"
186
+ }, /*#__PURE__*/React.createElement(VirtualKeyInput, {
187
+ value: value,
188
+ onChange: function onChange(e) {
189
+ return handleChangeValue(e.target.value);
190
+ },
191
+ renderInput: function renderInput(props) {
192
+ if (isUndefined(props.value) || props.value === '') {
193
+ return /*#__PURE__*/React.createElement(VirtualInput, {
194
+ autoFocus: true,
195
+ placeholder: placeholder,
196
+ value: props.value
197
+ });
198
+ }
199
+ return (format === null || format === void 0 ? void 0 : format(props.value)) || props.value;
200
+ },
201
+ showDelete: false,
202
+ onValueSelect: setSelect,
203
+ defaultSelect: defaultSelect
204
+ }), /*#__PURE__*/React.createElement(Presets, {
205
+ presets: presets,
206
+ onChange: handleChangeValue
207
+ }), /*#__PURE__*/React.createElement(Keyboard, {
208
+ items: items,
209
+ rightItems: rightItems,
210
+ onChange: handleKeyboardChange
211
+ }));
212
+ };
213
+ export default BaseNumberKeyboard;
@@ -0,0 +1,9 @@
1
+ .pisell-virtual-keyboard-base {
2
+ width: 340px;
3
+ .virtual-keyboard-input-wrap {
4
+ box-shadow: 0px 1px 3px 0px rgba(16, 24, 40, 0.10), 0px 1px 2px 0px rgba(16, 24, 40, 0.06);
5
+ }
6
+ .virtual-keyboard-wrap .virtual-keyboard-content .virtual-keyboard-item {
7
+ box-shadow: 0px 1px 3px 0px rgba(16, 24, 40, 0.10), 0px 1px 2px 0px rgba(16, 24, 40, 0.06);
8
+ }
9
+ }
@@ -1,18 +1,20 @@
1
- import React from "react";
2
- import "./index.less";
1
+ import React from 'react';
2
+ import './index.less';
3
3
  export declare type ItemValue = string | number;
4
4
  export interface Item {
5
5
  value: ItemValue;
6
- label: string;
6
+ label: React.ReactNode;
7
7
  disabled: boolean;
8
- type: "text" | "primary";
8
+ type: 'text' | 'primary';
9
9
  style?: React.CSSProperties;
10
+ size?: number;
10
11
  }
11
12
  export interface KeyboardProps {
12
13
  className?: string;
13
14
  style?: React.CSSProperties;
14
15
  onChange?: (value?: ItemValue) => void;
15
16
  items?: Item[];
17
+ rightItems?: Item[];
16
18
  }
17
- declare const Keyboard: (props: KeyboardProps) => React.JSX.Element;
18
- export default Keyboard;
19
+ declare const _default: React.MemoExoticComponent<(props: KeyboardProps) => React.JSX.Element>;
20
+ export default _default;
@@ -1,20 +1,30 @@
1
- import React from "react";
2
- import { Button } from "antd";
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ import React, { useRef } from 'react';
8
+ import { Button } from 'antd';
3
9
  import "./index.less";
4
- import classNames from "classnames";
5
- import { useEventListener } from "ahooks";
6
- var list = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "ok"];
10
+ import classNames from 'classnames';
11
+ import { useEventListener, useMemoizedFn, useSize } from 'ahooks';
12
+ var list = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'ok'];
13
+ var defaultArr = [];
7
14
  var Keyboard = function Keyboard(props) {
8
15
  var _props$items = props.items,
9
- items = _props$items === void 0 ? [] : _props$items,
16
+ items = _props$items === void 0 ? defaultArr : _props$items,
10
17
  className = props.className,
11
18
  style = props.style,
12
- onChange = props.onChange;
13
- useEventListener("keydown", function (ev) {
14
- console.log("ev", ev);
19
+ onChange = props.onChange,
20
+ rightItems = props.rightItems;
21
+ var contentRef = useRef(null);
22
+ var size = useSize(contentRef);
23
+ useEventListener('keydown', function (ev) {
24
+ console.log('ev', ev);
15
25
  var key = ev.key;
16
- if (key === "Enter") {
17
- key = "ok";
26
+ if (key === 'Enter') {
27
+ key = 'ok';
18
28
  }
19
29
  if (list.includes(key)) {
20
30
  // let dom = document.querySelector(`#virtual-keyboard-${ev.key}`);
@@ -25,9 +35,17 @@ var Keyboard = function Keyboard(props) {
25
35
  onChange === null || onChange === void 0 ? void 0 : onChange(key);
26
36
  }
27
37
  });
38
+ var getHeight = useMemoizedFn(function () {
39
+ var itemSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
40
+ // 默认高度为25% 的容器宽度 * size大小 + 间距
41
+ return ((size === null || size === void 0 ? void 0 : size.width) || 0) / 4 * itemSize + (itemSize - 1) * 7;
42
+ });
28
43
  return /*#__PURE__*/React.createElement("div", {
29
- className: classNames("virtual-keyboard-wrap", className),
44
+ className: classNames('virtual-keyboard-wrap', className),
30
45
  style: style
46
+ }, /*#__PURE__*/React.createElement("div", {
47
+ className: classNames('virtual-keyboard-content'),
48
+ ref: contentRef
31
49
  }, items.map(function (item) {
32
50
  var _item$style;
33
51
  return /*#__PURE__*/React.createElement("div", {
@@ -39,13 +57,39 @@ var Keyboard = function Keyboard(props) {
39
57
  type: item.type,
40
58
  className: "virtual-keyboard-item-button",
41
59
  style: {
42
- color: item.type === "primary" ? "#fff" : ((_item$style = item.style) === null || _item$style === void 0 ? void 0 : _item$style.color) || undefined
60
+ color: item.type === 'primary' ? '#fff' : ((_item$style = item.style) === null || _item$style === void 0 ? void 0 : _item$style.color) || undefined
61
+ },
62
+ disabled: item.disabled,
63
+ onClick: function onClick(e) {
64
+ onChange === null || onChange === void 0 ? void 0 : onChange(item.value);
65
+ }
66
+ }, item.label));
67
+ })), rightItems && /*#__PURE__*/React.createElement("div", {
68
+ className: classNames('virtual-keyboard-content', 'virtual-keyboard-right'),
69
+ style: {
70
+ flex: "0 0 calc((100% - 21px) / 4 * 1)"
71
+ }
72
+ }, rightItems === null || rightItems === void 0 ? void 0 : rightItems.map(function (item) {
73
+ var _item$style2, _item$style3;
74
+ return /*#__PURE__*/React.createElement("div", {
75
+ className: "virtual-keyboard-item",
76
+ style: _objectSpread(_objectSpread({}, item.style || {}), {}, {
77
+ height: getHeight(item.size)
78
+ })
79
+ }, /*#__PURE__*/React.createElement(Button, {
80
+ id: "virtual-keyboard-".concat(item.value),
81
+ key: item.value,
82
+ type: item.type,
83
+ className: "virtual-keyboard-item-button",
84
+ style: {
85
+ fontSize: ((_item$style2 = item.style) === null || _item$style2 === void 0 ? void 0 : _item$style2.fontSize) || 25,
86
+ color: item.type === 'primary' ? '#fff' : ((_item$style3 = item.style) === null || _item$style3 === void 0 ? void 0 : _item$style3.color) || undefined
43
87
  },
44
88
  disabled: item.disabled,
45
89
  onClick: function onClick(e) {
46
90
  onChange === null || onChange === void 0 ? void 0 : onChange(item.value);
47
91
  }
48
92
  }, item.label));
49
- }));
93
+ })));
50
94
  };
51
- export default Keyboard;
95
+ export default /*#__PURE__*/React.memo(Keyboard);
@@ -1,32 +1,43 @@
1
1
  .virtual-keyboard-wrap {
2
- width: 100%;
3
2
  display: flex;
4
- flex-wrap: wrap;
5
- align-items: center;
6
- justify-content: flex-end;
7
3
  gap: 7px;
4
+ .virtual-keyboard-content {
5
+ width: 100%;
6
+ display: flex;
7
+ flex-wrap: wrap;
8
+ align-items: center;
9
+ justify-content: flex-end;
10
+ gap: 7px;
8
11
 
9
- .virtual-keyboard-item {
10
- border-radius: 5px;
11
- background: var(--Base-White, #FFF);
12
- box-shadow: 0px 1px 0px 0px #898A8D;
13
- overflow: hidden;
14
- width: calc((100% - 14px) / 3 * 1);
15
- padding-top: 25%;
16
- position: relative;
12
+ .virtual-keyboard-item {
13
+ border-radius: 5px;
14
+ background: var(--Base-White, #fff);
15
+ box-shadow: 0px 1px 0px 0px #898a8d;
16
+ overflow: hidden;
17
+ width: calc((100% - 14px) / 3 * 1);
18
+ padding-top: 25%;
19
+ position: relative;
17
20
 
18
- .virtual-keyboard-item-button {
19
- position: absolute;
20
- left: 0;
21
- top: 0;
21
+ .virtual-keyboard-item-button {
22
+ position: absolute;
23
+ left: 0;
24
+ top: 0;
25
+ width: 100%;
26
+ height: 100%;
27
+ border-radius: 5px;
28
+ color: var(--Base-Black, #000);
29
+ font-size: 25px;
30
+ font-style: normal;
31
+ font-weight: 400;
32
+ box-shadow: none;
33
+ }
34
+ }
35
+ }
36
+ .virtual-keyboard-right {
37
+ flex-direction: column;
38
+ justify-content: start;
39
+ .virtual-keyboard-item{
22
40
  width: 100%;
23
- height: 100%;
24
- border-radius: 5px;
25
- color: var(--Base-Black, #000);
26
- font-size: 25px;
27
- font-style: normal;
28
- font-weight: 400;
29
- box-shadow: none;
30
41
  }
31
42
  }
32
- }
43
+ }
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ export interface NumberProps {
3
+ max?: number;
4
+ min?: number;
5
+ doneText?: string;
6
+ resetText: string;
7
+ defaultValue?: string | number;
8
+ placeholder?: string;
9
+ value?: string | number;
10
+ onChange?: (val: string | number) => void;
11
+ onEnter?: (val: string | number) => void;
12
+ }
13
+ declare const Number: (props: NumberProps) => React.JSX.Element;
14
+ export default Number;
@@ -0,0 +1,35 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ 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."); }
3
+ 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); }
4
+ 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; }
5
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import React from 'react';
8
+ import { useControllableValue } from 'ahooks';
9
+ import BaseNumberKeyboard from "../BaseNumberKeyboard";
10
+ var Number = function Number(props) {
11
+ var min = props.min,
12
+ max = props.max,
13
+ doneText = props.doneText,
14
+ resetText = props.resetText,
15
+ defaultValue = props.defaultValue,
16
+ placeholder = props.placeholder,
17
+ onEnter = props.onEnter;
18
+ var _useControllableValue = useControllableValue(props, {
19
+ defaultValue: defaultValue || ""
20
+ }),
21
+ _useControllableValue2 = _slicedToArray(_useControllableValue, 2),
22
+ value = _useControllableValue2[0],
23
+ setValue = _useControllableValue2[1];
24
+ return /*#__PURE__*/React.createElement(BaseNumberKeyboard, {
25
+ max: max,
26
+ min: min,
27
+ value: value,
28
+ onChange: setValue,
29
+ placeholder: placeholder,
30
+ doneText: doneText,
31
+ resetText: resetText,
32
+ onEnter: onEnter
33
+ });
34
+ };
35
+ export default Number;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ export interface VirtualInputProps extends React.HTMLAttributes<HTMLDivElement> {
4
+ value?: string;
5
+ autoFocus?: boolean;
6
+ placeholder?: string;
7
+ }
8
+ declare const VirtualInput: (props: VirtualInputProps) => React.JSX.Element;
9
+ export default VirtualInput;
@@ -0,0 +1,41 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ 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."); }
3
+ 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); }
4
+ 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; }
5
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import React, { useState } from 'react';
8
+ import classNames from 'classnames';
9
+ import { isUndefined } from "@pisell/utils";
10
+ import "./index.less";
11
+ var VirtualInput = function VirtualInput(props) {
12
+ var value = props.value,
13
+ autoFocus = props.autoFocus,
14
+ _props$placeholder = props.placeholder,
15
+ placeholder = _props$placeholder === void 0 ? '' : _props$placeholder;
16
+ var _useState = useState(autoFocus),
17
+ _useState2 = _slicedToArray(_useState, 2),
18
+ isFocus = _useState2[0],
19
+ setIsFocus = _useState2[1];
20
+ var onFocus = function onFocus() {
21
+ setIsFocus(true);
22
+ };
23
+ var onBlur = function onBlur() {
24
+ setIsFocus(false);
25
+ };
26
+ return /*#__PURE__*/React.createElement("div", {
27
+ onFocus: onFocus,
28
+ onBlur: onBlur,
29
+ tabIndex: 0,
30
+ className: classNames('pisell-virtual-input-value', {
31
+ 'pisell-virtual-input-value-focus': isFocus
32
+ })
33
+ }, value, (isUndefined(value) || value === '') && /*#__PURE__*/React.createElement("div", {
34
+ className: "pisell-virtual-input-placeholder"
35
+ }, placeholder), /*#__PURE__*/React.createElement("div", {
36
+ className: "pisell-virtual-input-caret-container"
37
+ }, isFocus && /*#__PURE__*/React.createElement("div", {
38
+ className: "pisell-virtual-input-caret"
39
+ })));
40
+ };
41
+ export default VirtualInput;
@@ -0,0 +1,46 @@
1
+ .pisell-virtual-input-value {
2
+ width: 100%;
3
+ min-width: 80px;
4
+ height: 100%;
5
+ display: flex;
6
+ align-items: center;
7
+ .pisell-virtual-input-caret-container {
8
+ height: 100%;
9
+ display: flex;
10
+ align-items: center;
11
+ .pisell-virtual-input-caret {
12
+ height: 40px;
13
+ width: 4px;
14
+ position: relative;
15
+ background: var(--Blue-600, #1570EF);
16
+ }
17
+ }
18
+ .pisell-virtual-input-placeholder {
19
+ color: var(--Gray-300, #D0D5DD);
20
+ }
21
+ }
22
+
23
+ .pisell-virtual-input-value-focus {
24
+ .pisell-virtual-input-caret {
25
+ display: block;
26
+ animation-name: pisell-caret-blink;
27
+ animation-duration: 1s;
28
+ animation-timing-function: linear;
29
+ animation-iteration-count: infinite;
30
+ }
31
+ }
32
+
33
+ @keyframes pisell-caret-blink {
34
+ from {
35
+ opacity: 1;
36
+ }
37
+ 60% {
38
+ opacity: 1;
39
+ }
40
+ 80% {
41
+ opacity: 0;
42
+ }
43
+ to {
44
+ opacity: 0;
45
+ }
46
+ }
@@ -1,9 +1,12 @@
1
- import React from "react";
2
- import { InputProps } from "antd";
3
- import "./index.less";
1
+ import React from 'react';
2
+ import { InputProps } from 'antd';
3
+ import './index.less';
4
4
  export interface VirtualKeyInputProps extends InputProps {
5
5
  previewValue?: string;
6
6
  renderInput?: (props: any) => any;
7
+ showDelete?: boolean;
8
+ onValueSelect?: (selected: boolean) => void;
9
+ defaultSelect?: boolean;
7
10
  }
8
11
  declare const VirtualKeyInput: (props: VirtualKeyInputProps) => React.JSX.Element;
9
12
  export default VirtualKeyInput;