@pisell/private-materials 3.0.185 → 3.0.187

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 (80) 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 +1 -1
  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 +11 -11
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +11 -11
  11. package/es/components/index.d.ts +2 -1
  12. package/es/components/index.js +2 -1
  13. package/es/components/pay/toC/PaymentMethods/MWCreditCard/tds2.js +10 -4
  14. package/es/components/pisellSelectCustomerModal/CustomerCard/index.d.ts +12 -0
  15. package/es/components/pisellSelectCustomerModal/CustomerCard/index.js +71 -0
  16. package/es/components/pisellSelectCustomerModal/CustomerCard/index.less +83 -0
  17. package/es/components/pisellSelectCustomerModal/RightPanel/Add/BirthdayField/index.d.ts +3 -0
  18. package/es/components/pisellSelectCustomerModal/RightPanel/Add/BirthdayField/index.js +277 -0
  19. package/es/components/pisellSelectCustomerModal/RightPanel/Add/GenderField/index.d.ts +3 -0
  20. package/es/components/pisellSelectCustomerModal/RightPanel/Add/GenderField/index.js +17 -0
  21. package/es/components/pisellSelectCustomerModal/RightPanel/Add/PhoneField/index.d.ts +3 -0
  22. package/es/components/pisellSelectCustomerModal/RightPanel/Add/PhoneField/index.js +57 -0
  23. package/es/components/pisellSelectCustomerModal/RightPanel/Add/PhoneField/serve.d.ts +2 -0
  24. package/es/components/pisellSelectCustomerModal/RightPanel/Add/PhoneField/serve.js +166 -0
  25. package/es/components/pisellSelectCustomerModal/RightPanel/Add/index.d.ts +8 -0
  26. package/es/components/pisellSelectCustomerModal/RightPanel/Add/index.js +191 -0
  27. package/es/components/pisellSelectCustomerModal/RightPanel/Add/index.less +35 -0
  28. package/es/components/pisellSelectCustomerModal/RightPanel/List/index.d.ts +13 -0
  29. package/es/components/pisellSelectCustomerModal/RightPanel/List/index.js +78 -0
  30. package/es/components/pisellSelectCustomerModal/RightPanel/List/index.less +49 -0
  31. package/es/components/pisellSelectCustomerModal/RightPanel/index.d.ts +15 -0
  32. package/es/components/pisellSelectCustomerModal/RightPanel/index.js +151 -0
  33. package/es/components/pisellSelectCustomerModal/RightPanel/index.less +50 -0
  34. package/es/components/pisellSelectCustomerModal/RightPanel/mock.d.ts +47 -0
  35. package/es/components/pisellSelectCustomerModal/RightPanel/mock.js +115 -0
  36. package/es/components/pisellSelectCustomerModal/RightPanel/serve.d.ts +3 -0
  37. package/es/components/pisellSelectCustomerModal/RightPanel/serve.js +56 -0
  38. package/es/components/pisellSelectCustomerModal/index.d.ts +16 -0
  39. package/es/components/pisellSelectCustomerModal/index.js +227 -0
  40. package/es/components/pisellSelectCustomerModal/index.less +22 -0
  41. package/es/components/pisellSelectCustomerModal/locales.d.ts +81 -0
  42. package/es/components/pisellSelectCustomerModal/locales.js +80 -0
  43. package/es/index.d.ts +1 -0
  44. package/es/index.js +2 -1
  45. package/lib/components/index.d.ts +2 -1
  46. package/lib/components/index.js +3 -0
  47. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/tds2.js +3 -0
  48. package/lib/components/pisellSelectCustomerModal/CustomerCard/index.d.ts +12 -0
  49. package/lib/components/pisellSelectCustomerModal/CustomerCard/index.js +99 -0
  50. package/lib/components/pisellSelectCustomerModal/CustomerCard/index.less +83 -0
  51. package/lib/components/pisellSelectCustomerModal/RightPanel/Add/BirthdayField/index.d.ts +3 -0
  52. package/lib/components/pisellSelectCustomerModal/RightPanel/Add/BirthdayField/index.js +256 -0
  53. package/lib/components/pisellSelectCustomerModal/RightPanel/Add/GenderField/index.d.ts +3 -0
  54. package/lib/components/pisellSelectCustomerModal/RightPanel/Add/GenderField/index.js +51 -0
  55. package/lib/components/pisellSelectCustomerModal/RightPanel/Add/PhoneField/index.d.ts +3 -0
  56. package/lib/components/pisellSelectCustomerModal/RightPanel/Add/PhoneField/index.js +81 -0
  57. package/lib/components/pisellSelectCustomerModal/RightPanel/Add/PhoneField/serve.d.ts +2 -0
  58. package/lib/components/pisellSelectCustomerModal/RightPanel/Add/PhoneField/serve.js +193 -0
  59. package/lib/components/pisellSelectCustomerModal/RightPanel/Add/index.d.ts +8 -0
  60. package/lib/components/pisellSelectCustomerModal/RightPanel/Add/index.js +200 -0
  61. package/lib/components/pisellSelectCustomerModal/RightPanel/Add/index.less +35 -0
  62. package/lib/components/pisellSelectCustomerModal/RightPanel/List/index.d.ts +13 -0
  63. package/lib/components/pisellSelectCustomerModal/RightPanel/List/index.js +94 -0
  64. package/lib/components/pisellSelectCustomerModal/RightPanel/List/index.less +49 -0
  65. package/lib/components/pisellSelectCustomerModal/RightPanel/index.d.ts +15 -0
  66. package/lib/components/pisellSelectCustomerModal/RightPanel/index.js +152 -0
  67. package/lib/components/pisellSelectCustomerModal/RightPanel/index.less +50 -0
  68. package/lib/components/pisellSelectCustomerModal/RightPanel/mock.d.ts +47 -0
  69. package/lib/components/pisellSelectCustomerModal/RightPanel/mock.js +150 -0
  70. package/lib/components/pisellSelectCustomerModal/RightPanel/serve.d.ts +3 -0
  71. package/lib/components/pisellSelectCustomerModal/RightPanel/serve.js +39 -0
  72. package/lib/components/pisellSelectCustomerModal/index.d.ts +16 -0
  73. package/lib/components/pisellSelectCustomerModal/index.js +237 -0
  74. package/lib/components/pisellSelectCustomerModal/index.less +22 -0
  75. package/lib/components/pisellSelectCustomerModal/locales.d.ts +81 -0
  76. package/lib/components/pisellSelectCustomerModal/locales.js +104 -0
  77. package/lib/index.d.ts +1 -0
  78. package/lib/index.js +3 -0
  79. package/lowcode/pisell-select-customer-modal/meta.ts +80 -0
  80. package/package.json +3 -3
@@ -9,4 +9,5 @@ import ProductExtension from './productExtension';
9
9
  import RuleSetting from './ruleSetting';
10
10
  import TaxSelect from './taxSelect';
11
11
  import ToCPay from './pay/toC';
12
- export { Login, BookingInfo, Booking, BookingNotes, BookingAddons, BookingForms, Schedules, ProductExtension, RuleSetting, TaxSelect, ToCPay };
12
+ import PisellSelectCustomerModal from './pisellSelectCustomerModal';
13
+ export { Login, BookingInfo, Booking, BookingNotes, BookingAddons, BookingForms, Schedules, ProductExtension, RuleSetting, TaxSelect, ToCPay, PisellSelectCustomerModal };
@@ -9,4 +9,5 @@ import ProductExtension from "./productExtension";
9
9
  import RuleSetting from "./ruleSetting";
10
10
  import TaxSelect from "./taxSelect";
11
11
  import ToCPay from "./pay/toC";
12
- export { Login, BookingInfo, Booking, BookingNotes, BookingAddons, BookingForms, Schedules, ProductExtension, RuleSetting, TaxSelect, ToCPay };
12
+ import PisellSelectCustomerModal from "./pisellSelectCustomerModal";
13
+ export { Login, BookingInfo, Booking, BookingNotes, BookingAddons, BookingForms, Schedules, ProductExtension, RuleSetting, TaxSelect, ToCPay, PisellSelectCustomerModal };
@@ -186,9 +186,15 @@ export var checkEnrollment = /*#__PURE__*/function () {
186
186
  _yield$request$getReq = _context2.sent;
187
187
  data = _yield$request$getReq.data;
188
188
  setPayNumber(orderId, data === null || data === void 0 ? void 0 : data.pay_number);
189
+ if (data !== null && data !== void 0 && data.pay_info) {
190
+ _context2.next = 8;
191
+ break;
192
+ }
193
+ return _context2.abrupt("return", null);
194
+ case 8:
189
195
  return _context2.abrupt("return", data);
190
- case 9:
191
- _context2.prev = 9;
196
+ case 11:
197
+ _context2.prev = 11;
192
198
  _context2.t0 = _context2["catch"](0);
193
199
  // 记录卡失败的原因
194
200
  log({
@@ -208,11 +214,11 @@ export var checkEnrollment = /*#__PURE__*/function () {
208
214
  });
209
215
  console.log('error', _context2.t0);
210
216
  return _context2.abrupt("return", 0);
211
- case 17:
217
+ case 19:
212
218
  case "end":
213
219
  return _context2.stop();
214
220
  }
215
- }, _callee2, null, [[0, 9]]);
221
+ }, _callee2, null, [[0, 11]]);
216
222
  }));
217
223
  return function checkEnrollment(_x3, _x4, _x5) {
218
224
  return _ref3.apply(this, arguments);
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ export interface CustomerCardProps {
4
+ className?: string;
5
+ onClickItem: (value?: any) => void;
6
+ customer?: any;
7
+ showIcon?: boolean;
8
+ onRemove?: (value?: any) => void;
9
+ customIcon?: React.ReactNode;
10
+ }
11
+ declare const CustomerCard: ({ onClickItem, customer, showIcon, customIcon, onRemove, className, }: CustomerCardProps) => React.JSX.Element;
12
+ export default CustomerCard;
@@ -0,0 +1,71 @@
1
+ import React, { useMemo } from 'react';
2
+ import { Avatar } from 'antd';
3
+ import PlusCircle from '@pisell/icon/es/PlusCircle';
4
+ import XCircle from '@pisell/icon/es/XCircle';
5
+ import { image, locales } from '@pisell/utils';
6
+ import "./index.less";
7
+ import classNames from 'classnames';
8
+ var CustomerCard = function CustomerCard(_ref) {
9
+ var onClickItem = _ref.onClickItem,
10
+ customer = _ref.customer,
11
+ _ref$showIcon = _ref.showIcon,
12
+ showIcon = _ref$showIcon === void 0 ? true : _ref$showIcon,
13
+ customIcon = _ref.customIcon,
14
+ onRemove = _ref.onRemove,
15
+ className = _ref.className;
16
+ var username = useMemo(function () {
17
+ if (!customer) {
18
+ return 'Walk-in';
19
+ }
20
+ var firstLastName = customer.first_name || customer.last_name ? "".concat(customer.first_name, " ").concat(customer.last_name) : '';
21
+ return customer.name || (customer.display_name || '').trim() || (customer.nickname || '').trim() || firstLastName.trim() || '';
22
+ }, [customer]);
23
+ var getAvatarName = useMemo(function () {
24
+ if (!username) return '';
25
+ var parts = username.trim().split(/\s+/); // 按空格分割并去掉多余空格
26
+
27
+ if (parts.length === 1) {
28
+ return parts[0].charAt(0); // 如果只有一个部分,返回第一个字符
29
+ }
30
+
31
+ // 如果有多个部分,返回前两个部分的首字符
32
+ return parts[0].charAt(0) + parts[1].charAt(0);
33
+ }, [username]);
34
+ return /*#__PURE__*/React.createElement("div", {
35
+ className: classNames('pisell-lowcode__customer_card', className),
36
+ onClick: function onClick() {
37
+ onClickItem(customer);
38
+ }
39
+ }, /*#__PURE__*/React.createElement(Avatar, {
40
+ className: "pisell-lowcode__customer_card-avatar",
41
+ src: customer !== null && customer !== void 0 && customer.cover ? image.ali(customer === null || customer === void 0 ? void 0 : customer.cover, 100) : undefined
42
+ // icon={<User01 className="pisell-lowcode__customer_card-avatar-icon" />}
43
+ }, getAvatarName), /*#__PURE__*/React.createElement("div", {
44
+ className: "pisell-lowcode__customer_card-info"
45
+ }, /*#__PURE__*/React.createElement("div", {
46
+ className: "pisell-lowcode__customer_card-info-left"
47
+ }, /*#__PURE__*/React.createElement("div", {
48
+ className: "pisell-lowcode__customer_card-info-name"
49
+ }, username), !customer ? /*#__PURE__*/React.createElement("div", {
50
+ className: "pisell-lowcode__customer_card-info-desc"
51
+ }, locales.getText('pisell2.text.leave-empty-for-walk-in')) : /*#__PURE__*/React.createElement(React.Fragment, null, customer !== null && customer !== void 0 && customer.email ? /*#__PURE__*/React.createElement("div", {
52
+ className: "pisell-lowcode__customer_card-info-email"
53
+ }, customer === null || customer === void 0 ? void 0 : customer.email) : null, customer !== null && customer !== void 0 && customer.phone ? /*#__PURE__*/React.createElement("div", {
54
+ className: "pisell-lowcode__customer_card-info-phone"
55
+ }, customer === null || customer === void 0 ? void 0 : customer.phone) : null)), showIcon ? /*#__PURE__*/React.createElement("div", {
56
+ className: "pisell-lowcode__customer_card-info-right",
57
+ onClick: function onClick(e) {
58
+ if (!customer) {
59
+ return;
60
+ }
61
+ e.preventDefault();
62
+ e.stopPropagation();
63
+ onRemove === null || onRemove === void 0 ? void 0 : onRemove();
64
+ }
65
+ }, customIcon ? customIcon : customer ? /*#__PURE__*/React.createElement(XCircle, {
66
+ className: "pisell-lowcode__customer_card-add-icon"
67
+ }) : /*#__PURE__*/React.createElement(PlusCircle, {
68
+ className: "pisell-lowcode__customer_card-add-icon"
69
+ })) : null));
70
+ };
71
+ export default CustomerCard;
@@ -0,0 +1,83 @@
1
+ .pisell-lowcode__customer_card {
2
+ display: flex;
3
+ width: 100%;
4
+ padding: 20px 8px;
5
+ align-items: center;
6
+ gap: 16px;
7
+ border-radius: 8px;
8
+ border: 1px solid #D5D7DA;
9
+ background: var(--base-white, #FFF);
10
+ cursor: pointer;
11
+ position: relative;
12
+ margin-bottom: 0;
13
+
14
+ .pisell-lowcode__customer_card-avatar {
15
+ display: flex;
16
+ width: 48px;
17
+ height: 48px;
18
+ padding: 16px;
19
+ justify-content: center;
20
+ align-items: center;
21
+ border-radius: 200px;
22
+ background: var(--Badge-Blue_Container, #D1E3FF);
23
+ font-weight: 600;
24
+ color: #0B5FDB;
25
+ }
26
+
27
+ .pisell-lowcode__customer_card-avatar-icon {
28
+ font-size: 24px;
29
+ color: #0B5FDB;
30
+ }
31
+
32
+
33
+ .pisell-lowcode__customer_card-info {
34
+ flex: 1;
35
+ display: flex;
36
+ align-items: center;
37
+
38
+ .pisell-lowcode__customer_card-info-left {
39
+ flex: 1;
40
+ width: 0;
41
+
42
+ .pisell-lowcode__customer_card-info-name {
43
+ color: var(--gray-900, #101828);
44
+
45
+
46
+ font-size: 16px;
47
+ font-style: normal;
48
+ font-weight: 600;
49
+ line-height: 24px;
50
+ }
51
+
52
+ .pisell-lowcode__customer_card-info-desc {
53
+ color: var(--gray-400, #98A2B3);
54
+
55
+ font-size: 14px;
56
+ font-style: normal;
57
+ font-weight: 400;
58
+ }
59
+
60
+ .pisell-lowcode__customer_card-info-email,
61
+ .pisell-lowcode__customer_card-info-phone {
62
+ color: var(--gray-400, #98A2B3);
63
+
64
+ font-size: 14px;
65
+ font-style: normal;
66
+ font-weight: 400;
67
+ }
68
+ }
69
+
70
+ .pisell-lowcode__customer_card-info-right {
71
+ width: 40px;
72
+ height: 40px;
73
+ display: flex;
74
+ align-items: center;
75
+ justify-content: center;
76
+
77
+ .pisell-lowcode__customer_card-add-icon {
78
+ font-size: 28px;
79
+ color: #475467;
80
+ }
81
+ }
82
+ }
83
+ }
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const DateSectionCom: ({ value, onChange, showTime, className, style, useSpace, format, itemStyle, }: any) => React.JSX.Element;
3
+ export default DateSectionCom;
@@ -0,0 +1,277 @@
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
+ 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(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; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
+ import React, { useEffect, useLayoutEffect, useMemo, useCallback, useState, useRef } from 'react';
14
+ import { Select, Space } from 'antd';
15
+ import debounce from 'lodash/debounce';
16
+ import dayjs from 'dayjs';
17
+ import { getUniqueId, locales } from '@pisell/utils';
18
+ var Option = Select.Option;
19
+ var getSelectInput = function getSelectInput(id) {
20
+ var input = document.getElementById(id);
21
+ if (input) {
22
+ return input;
23
+ }
24
+ };
25
+ var setSelectInputType = function setSelectInputType(_ref) {
26
+ var input = _ref.input,
27
+ type = _ref.type;
28
+ if (input) {
29
+ input.type = type;
30
+ }
31
+ };
32
+ var DateSectionCom = function DateSectionCom(_ref2) {
33
+ var value = _ref2.value,
34
+ onChange = _ref2.onChange,
35
+ showTime = _ref2.showTime,
36
+ _ref2$className = _ref2.className,
37
+ className = _ref2$className === void 0 ? '' : _ref2$className,
38
+ _ref2$style = _ref2.style,
39
+ style = _ref2$style === void 0 ? {} : _ref2$style,
40
+ _ref2$useSpace = _ref2.useSpace,
41
+ useSpace = _ref2$useSpace === void 0 ? true : _ref2$useSpace,
42
+ format = _ref2.format,
43
+ _ref2$itemStyle = _ref2.itemStyle,
44
+ itemStyle = _ref2$itemStyle === void 0 ? {
45
+ width: 100
46
+ } : _ref2$itemStyle;
47
+ var currentYear = dayjs().year();
48
+ var locale = locales.locale;
49
+ var dayRef = useRef(null);
50
+ var monthRef = useRef(null);
51
+ var yearRef = useRef(null);
52
+ var _useState = useState({
53
+ year: value ? dayjs(value).year() : null,
54
+ month: value ? dayjs(value).month() + 1 : null,
55
+ day: value ? dayjs(value).date() : null
56
+ }),
57
+ _useState2 = _slicedToArray(_useState, 2),
58
+ date = _useState2[0],
59
+ setDate = _useState2[1];
60
+ var _useState3 = useState([]),
61
+ _useState4 = _slicedToArray(_useState3, 2),
62
+ dayOptions = _useState4[0],
63
+ setDayOptions = _useState4[1];
64
+ var _useState5 = useState([]),
65
+ _useState6 = _slicedToArray(_useState5, 2),
66
+ monthOptions = _useState6[0],
67
+ setMonthOptions = _useState6[1];
68
+ var _useState7 = useState([]),
69
+ _useState8 = _slicedToArray(_useState7, 2),
70
+ yearOptions = _useState8[0],
71
+ setYearOptions = _useState8[1];
72
+ var localeMap = {
73
+ year: locales.getText('pisell2.text.date-year-text'),
74
+ month: locales.getText('pisell2.text.date-month-text'),
75
+ day: locales.getText('pisell2.text.date-day-text')
76
+ };
77
+ useEffect(function () {
78
+ setDate({
79
+ year: value ? dayjs(value).year() : null,
80
+ month: value ? dayjs(value).month() + 1 : null,
81
+ day: value ? dayjs(value).date() : null
82
+ });
83
+ }, [value]);
84
+ useEffect(function () {
85
+ setMonthOptions(renderOptions('month', 1, 12));
86
+ setYearOptions(renderOptions('year', currentYear - 100, currentYear + 50));
87
+ }, []);
88
+ useEffect(function () {
89
+ setDayOptions(renderOptions('day', 1, date.month ? getDaysInMonth(date.year || currentYear, date.month) : 31));
90
+ }, [date.month, date.year]);
91
+
92
+ /**
93
+ * @title: 下拉框变化
94
+ * @description:
95
+ * @param {any} field
96
+ * @param {any} value
97
+ * @return {*}
98
+ * @Author: chensheng.gu
99
+ * @Date: 2024-03-22 17:49
100
+ */
101
+ var handleDateChange = function handleDateChange(field, value) {
102
+ if (!value) {
103
+ return;
104
+ }
105
+ var newDate = _defineProperty({
106
+ year: date.year,
107
+ month: date.month,
108
+ day: date.day
109
+ }, field, value);
110
+ var foucsList = {
111
+ day: monthRef,
112
+ month: yearRef
113
+ };
114
+
115
+ // 如果是月份需要判断下日期
116
+ if (field === 'month' || field === 'year') {
117
+ var _newDate2, _newDate3, _newDate4;
118
+ var daysInMonth = getDaysInMonth(((_newDate2 = newDate) === null || _newDate2 === void 0 ? void 0 : _newDate2.year) || currentYear, (_newDate3 = newDate) === null || _newDate3 === void 0 ? void 0 : _newDate3.month);
119
+ var newDay = ((_newDate4 = newDate) === null || _newDate4 === void 0 ? void 0 : _newDate4.day) > daysInMonth ? daysInMonth : newDate.day;
120
+ newDate = _objectSpread(_objectSpread({}, newDate), {}, {
121
+ day: newDay
122
+ });
123
+ }
124
+ setDate(newDate);
125
+ if (foucsList[field]) {
126
+ foucsList[field].current.focus();
127
+ } else {
128
+ yearRef.current.blur();
129
+ }
130
+ var _format = format || 'YYYY-MM-DD';
131
+ if (newDate.year && newDate.month && newDate.day) {
132
+ var _date = "".concat(newDate.year, "-").concat(newDate.month.toString().padStart(2, '0'), "-").concat(newDate.day.toString().padStart(2, '0'));
133
+ onChange(dayjs(_date).format(_format));
134
+ }
135
+ };
136
+
137
+ /**
138
+ * @title: 获取日期
139
+ * @description:
140
+ * @param {any} year
141
+ * @param {any} month
142
+ * @return {*}
143
+ * @Author: chensheng.gu
144
+ * @Date: 2024-03-22 17:49
145
+ */
146
+ var getDaysInMonth = function getDaysInMonth(year, month) {
147
+ return dayjs("".concat(year, "-").concat(month), 'YYYY-MM').daysInMonth();
148
+ };
149
+
150
+ /**
151
+ * @title: 渲染下拉框列表
152
+ * @description:
153
+ * @param {any} field
154
+ * @param {any} start
155
+ * @param {any} end
156
+ * @return {*}
157
+ * @Author: chensheng.gu
158
+ * @Date: 2024-03-22 17:50
159
+ */
160
+ var renderOptions = function renderOptions(field, start, end) {
161
+ var options = [];
162
+ var _text = locale !== 'en-US' && locale !== 'en' ? localeMap[field] : '';
163
+ for (var i = start; i <= end; i++) {
164
+ options.push({
165
+ label: "".concat(i).concat(_text),
166
+ value: i
167
+ });
168
+ }
169
+ return options;
170
+ };
171
+ var selectId = useMemo(function () {
172
+ return {
173
+ dayId: getUniqueId('day'),
174
+ monthId: getUniqueId('month'),
175
+ yearId: getUniqueId('year')
176
+ };
177
+ }, []);
178
+ useLayoutEffect(function () {
179
+ setSelectInputType({
180
+ input: getSelectInput(selectId.dayId),
181
+ type: 'number'
182
+ });
183
+ setSelectInputType({
184
+ input: getSelectInput(selectId.monthId),
185
+ type: 'number'
186
+ });
187
+ setSelectInputType({
188
+ input: getSelectInput(selectId.yearId),
189
+ type: 'number'
190
+ });
191
+ }, [selectId]);
192
+ var handleDateSearch = useCallback(debounce(function (field, value) {
193
+ var dateOption = {
194
+ day: dayOptions,
195
+ month: monthOptions,
196
+ year: yearOptions
197
+ };
198
+ var _value = Number(value);
199
+ var index = dateOption[field].findIndex(function (item) {
200
+ return item.value === _value;
201
+ });
202
+ if (index !== -1) {
203
+ handleDateChange(field, _value);
204
+ } else {
205
+ handleDateChange(field, null);
206
+ }
207
+ }, 300), [dayOptions, monthOptions, yearOptions, date]);
208
+ var content = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Select, {
209
+ id: selectId.dayId,
210
+ value: date.day,
211
+ placeholder: locales.getText('pisell2.text.date-day-text'),
212
+ onChange: function onChange(value) {
213
+ return handleDateChange('day', value);
214
+ },
215
+ style: itemStyle,
216
+ showSearch: true,
217
+ onSearch: function onSearch(value) {
218
+ handleDateSearch('day', value);
219
+ },
220
+ ref: dayRef,
221
+ size: "large"
222
+ }, dayOptions.map(function (item) {
223
+ return /*#__PURE__*/React.createElement(Option, {
224
+ key: item.value,
225
+ value: item.value
226
+ }, item.label);
227
+ })), /*#__PURE__*/React.createElement(Select, {
228
+ id: selectId.monthId,
229
+ value: date.month,
230
+ placeholder: locales.getText('pisell2.text.date-month-text'),
231
+ onChange: function onChange(value) {
232
+ return handleDateChange('month', value);
233
+ },
234
+ style: itemStyle,
235
+ showSearch: true,
236
+ onSearch: function onSearch(value) {
237
+ handleDateSearch('month', value);
238
+ },
239
+ ref: monthRef,
240
+ size: "large"
241
+ }, monthOptions.map(function (item) {
242
+ return /*#__PURE__*/React.createElement(Option, {
243
+ key: item.value,
244
+ value: item.value
245
+ }, item.label);
246
+ })), /*#__PURE__*/React.createElement(Select, {
247
+ id: selectId.yearId,
248
+ value: date.year,
249
+ placeholder: locales.getText('pisell2.text.date-year-text'),
250
+ onChange: function onChange(value) {
251
+ return handleDateChange('year', value);
252
+ },
253
+ style: itemStyle,
254
+ showSearch: true,
255
+ onSearch: function onSearch(value) {
256
+ handleDateSearch('year', value);
257
+ },
258
+ ref: yearRef,
259
+ size: "large"
260
+ }, yearOptions.map(function (item) {
261
+ return /*#__PURE__*/React.createElement(Option, {
262
+ key: item.value,
263
+ value: item.value
264
+ }, item.label);
265
+ })));
266
+ if (useSpace) {
267
+ return /*#__PURE__*/React.createElement(Space, {
268
+ className: className || '',
269
+ style: style || {}
270
+ }, content);
271
+ }
272
+ return /*#__PURE__*/React.createElement("div", {
273
+ className: className || '',
274
+ style: style || {}
275
+ }, content);
276
+ };
277
+ export default DateSectionCom;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const GenderField: (props: any) => React.JSX.Element;
3
+ export default GenderField;
@@ -0,0 +1,17 @@
1
+ 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); }
2
+ import React from 'react';
3
+ import { Select } from 'antd';
4
+ import { locales } from '@pisell/utils';
5
+ var GenderField = function GenderField(props) {
6
+ return /*#__PURE__*/React.createElement(Select, _extends({
7
+ size: "large",
8
+ options: [{
9
+ label: locales.getText('pisell2.text.gender.male'),
10
+ value: '1'
11
+ }, {
12
+ label: locales.getText('pisell2.text.gender.female'),
13
+ value: '2'
14
+ }]
15
+ }, props));
16
+ };
17
+ export default GenderField;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const PhoneField: ({ value, onChange }: any) => React.JSX.Element;
3
+ export default PhoneField;
@@ -0,0 +1,57 @@
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, { useEffect } from 'react';
8
+ import { Select, Space, Input } from 'antd';
9
+ import { useRequest } from 'ahooks';
10
+ import { getCountries } from "./serve";
11
+ var defaultValue = {
12
+ code: '+61',
13
+ phone: ''
14
+ };
15
+ var PhoneField = function PhoneField(_ref) {
16
+ var value = _ref.value,
17
+ onChange = _ref.onChange;
18
+ var codes = useRequest(getCountries, {
19
+ manual: true
20
+ });
21
+ console.log('codes', codes.data);
22
+ useEffect(function () {
23
+ codes.run();
24
+ }, []);
25
+ var _onChange = function _onChange(key, val) {
26
+ onChange(_objectSpread(_objectSpread(_objectSpread({}, defaultValue), value), {}, _defineProperty({}, key, val)));
27
+ };
28
+ return /*#__PURE__*/React.createElement(Space.Compact, {
29
+ style: {
30
+ width: '100%'
31
+ }
32
+ }, /*#__PURE__*/React.createElement(Select, {
33
+ options: codes.data || [],
34
+ onChange: function onChange(val) {
35
+ _onChange('code', val);
36
+ },
37
+ size: "large",
38
+ style: {
39
+ flex: '0 0 100px'
40
+ },
41
+ loading: codes.loading,
42
+ optionLabelProp: "value",
43
+ value: value === null || value === void 0 ? void 0 : value.code,
44
+ dropdownMatchSelectWidth: false
45
+ }), /*#__PURE__*/React.createElement(Input, {
46
+ type: "number",
47
+ value: value === null || value === void 0 ? void 0 : value.phone,
48
+ size: "large",
49
+ style: {
50
+ flex: 1
51
+ },
52
+ onChange: function onChange(e) {
53
+ _onChange('phone', e.target.value);
54
+ }
55
+ }));
56
+ };
57
+ export default PhoneField;
@@ -0,0 +1,2 @@
1
+ export declare const defaultCodes: any;
2
+ export declare const getCountries: (params?: any) => Promise<any>;