@pisell/private-materials 6.7.1 → 6.7.3

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 (76) 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 +7 -7
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +2 -2
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +2 -2
  11. package/es/index.d.ts +1 -0
  12. package/es/index.js +2 -1
  13. package/es/plus/webPosLogin/WebPosLogin.d.ts +11 -0
  14. package/es/plus/webPosLogin/WebPosLogin.js +551 -0
  15. package/es/plus/webPosLogin/WebPosLoginCpt.d.ts +9 -0
  16. package/es/plus/webPosLogin/WebPosLoginCpt.js +170 -0
  17. package/es/plus/webPosLogin/WebPosLoginCpt.less +170 -0
  18. package/es/plus/webPosLogin/components/BrandPanel/index.d.ts +9 -0
  19. package/es/plus/webPosLogin/components/BrandPanel/index.js +52 -0
  20. package/es/plus/webPosLogin/components/BrandPanel/index.less +58 -0
  21. package/es/plus/webPosLogin/components/LoginPanel/index.d.ts +21 -0
  22. package/es/plus/webPosLogin/components/LoginPanel/index.js +73 -0
  23. package/es/plus/webPosLogin/components/LoginPanel/index.less +43 -0
  24. package/es/plus/webPosLogin/components/SelectDevice/index.d.ts +28 -0
  25. package/es/plus/webPosLogin/components/SelectDevice/index.js +258 -0
  26. package/es/plus/webPosLogin/components/SelectDevice/index.less +167 -0
  27. package/es/plus/webPosLogin/components/SelectStore/index.d.ts +24 -0
  28. package/es/plus/webPosLogin/components/SelectStore/index.js +198 -0
  29. package/es/plus/webPosLogin/components/SelectStore/index.less +157 -0
  30. package/es/plus/webPosLogin/components/UserFooter/index.d.ts +28 -0
  31. package/es/plus/webPosLogin/components/UserFooter/index.js +110 -0
  32. package/es/plus/webPosLogin/components/UserFooter/index.less +70 -0
  33. package/es/plus/webPosLogin/index.d.ts +12 -0
  34. package/es/plus/webPosLogin/index.js +15 -0
  35. package/es/plus/webPosLogin/locales.d.ts +49 -0
  36. package/es/plus/webPosLogin/locales.js +57 -0
  37. package/es/plus/webPosLogin/service.d.ts +44 -0
  38. package/es/plus/webPosLogin/service.js +198 -0
  39. package/es/plus/webPosLogin/types.d.ts +286 -0
  40. package/es/plus/webPosLogin/types.js +1 -0
  41. package/es/pro/Login2.0/Login2.js +9 -3
  42. package/es/pro/Login2.0/index.less +0 -12
  43. package/lib/index.d.ts +1 -0
  44. package/lib/index.js +3 -0
  45. package/lib/plus/webPosLogin/WebPosLogin.d.ts +11 -0
  46. package/lib/plus/webPosLogin/WebPosLogin.js +331 -0
  47. package/lib/plus/webPosLogin/WebPosLoginCpt.d.ts +9 -0
  48. package/lib/plus/webPosLogin/WebPosLoginCpt.js +170 -0
  49. package/lib/plus/webPosLogin/WebPosLoginCpt.less +170 -0
  50. package/lib/plus/webPosLogin/components/BrandPanel/index.d.ts +9 -0
  51. package/lib/plus/webPosLogin/components/BrandPanel/index.js +63 -0
  52. package/lib/plus/webPosLogin/components/BrandPanel/index.less +58 -0
  53. package/lib/plus/webPosLogin/components/LoginPanel/index.d.ts +21 -0
  54. package/lib/plus/webPosLogin/components/LoginPanel/index.js +98 -0
  55. package/lib/plus/webPosLogin/components/LoginPanel/index.less +43 -0
  56. package/lib/plus/webPosLogin/components/SelectDevice/index.d.ts +28 -0
  57. package/lib/plus/webPosLogin/components/SelectDevice/index.js +158 -0
  58. package/lib/plus/webPosLogin/components/SelectDevice/index.less +167 -0
  59. package/lib/plus/webPosLogin/components/SelectStore/index.d.ts +24 -0
  60. package/lib/plus/webPosLogin/components/SelectStore/index.js +123 -0
  61. package/lib/plus/webPosLogin/components/SelectStore/index.less +157 -0
  62. package/lib/plus/webPosLogin/components/UserFooter/index.d.ts +28 -0
  63. package/lib/plus/webPosLogin/components/UserFooter/index.js +91 -0
  64. package/lib/plus/webPosLogin/components/UserFooter/index.less +70 -0
  65. package/lib/plus/webPosLogin/index.d.ts +12 -0
  66. package/lib/plus/webPosLogin/index.js +56 -0
  67. package/lib/plus/webPosLogin/locales.d.ts +49 -0
  68. package/lib/plus/webPosLogin/locales.js +77 -0
  69. package/lib/plus/webPosLogin/service.d.ts +44 -0
  70. package/lib/plus/webPosLogin/service.js +94 -0
  71. package/lib/plus/webPosLogin/types.d.ts +286 -0
  72. package/lib/plus/webPosLogin/types.js +17 -0
  73. package/lib/pro/Login2.0/Login2.js +19 -9
  74. package/lib/pro/Login2.0/index.less +0 -12
  75. package/lowcode/web-pos-login/meta.ts +71 -0
  76. package/package.json +4 -4
@@ -0,0 +1,258 @@
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(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; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import React, { memo, useState, useMemo, useCallback } from 'react';
8
+ import { Spin } from 'antd';
9
+ import { SearchOutlined } from '@ant-design/icons';
10
+ import { PisellInput, PisellEmpty, PisellModal } from '@pisell/materials';
11
+ import { locales } from '@pisell/utils';
12
+ import "./index.less";
13
+
14
+ /**
15
+ * SelectDevice 组件 Props
16
+ */
17
+
18
+ /** 默认设备图标 */
19
+ var DeviceIcon = function DeviceIcon() {
20
+ return /*#__PURE__*/React.createElement("svg", {
21
+ width: "24",
22
+ height: "24",
23
+ viewBox: "0 0 24 24",
24
+ fill: "none",
25
+ xmlns: "http://www.w3.org/2000/svg"
26
+ }, /*#__PURE__*/React.createElement("rect", {
27
+ x: "4",
28
+ y: "3",
29
+ width: "16",
30
+ height: "18",
31
+ rx: "2",
32
+ stroke: "currentColor",
33
+ strokeWidth: "2"
34
+ }), /*#__PURE__*/React.createElement("line", {
35
+ x1: "4",
36
+ y1: "7",
37
+ x2: "20",
38
+ y2: "7",
39
+ stroke: "currentColor",
40
+ strokeWidth: "2"
41
+ }), /*#__PURE__*/React.createElement("line", {
42
+ x1: "4",
43
+ y1: "17",
44
+ x2: "20",
45
+ y2: "17",
46
+ stroke: "currentColor",
47
+ strokeWidth: "2"
48
+ }), /*#__PURE__*/React.createElement("circle", {
49
+ cx: "12",
50
+ cy: "19.5",
51
+ r: "0.5",
52
+ fill: "currentColor"
53
+ }));
54
+ };
55
+
56
+ /**
57
+ * 模糊搜索匹配
58
+ * @param device 设备数据
59
+ * @param keyword 搜索关键词
60
+ */
61
+ var matchDevice = function matchDevice(device, keyword) {
62
+ if (!keyword.trim()) return true;
63
+ var lowerKeyword = keyword.toLowerCase();
64
+
65
+ // 搜索设备名称和描述
66
+ var searchFields = [device === null || device === void 0 ? void 0 : device.name, device === null || device === void 0 ? void 0 : device.description, device === null || device === void 0 ? void 0 : device.number].filter(Boolean);
67
+ return searchFields.some(function (field) {
68
+ return field === null || field === void 0 ? void 0 : field.toLowerCase().includes(lowerKeyword);
69
+ });
70
+ };
71
+
72
+ /**
73
+ * 获取确认弹窗文本
74
+ * @param device 设备数据
75
+ * @param locale 语言
76
+ */
77
+ var getConfirmText = function getConfirmText(device, locale) {
78
+ var _device$client;
79
+ var deviceName = (device === null || device === void 0 ? void 0 : device.name) || '';
80
+ var clientName = (device === null || device === void 0 || (_device$client = device.client) === null || _device$client === void 0 ? void 0 : _device$client.name) || '';
81
+ var langText = {
82
+ en: "The device \"".concat(deviceName, "\" is currently in use by \"").concat(clientName, "\". Are you sure you want to take it over?"),
83
+ 'zh-CN': "\u8BBE\u5907\"".concat(deviceName, "\"\u6B63\u5728\u88AB\"").concat(clientName, "\"\u4F7F\u7528\uFF0C\u60A8\u786E\u5B9A\u8981\u63A5\u7BA1\u6B64\u8BBE\u5907\u5417\uFF1F"),
84
+ 'zh-HK': "\u8A2D\u5099\"".concat(deviceName, "\"\u6B63\u5728\u88AB\"").concat(clientName, "\"\u4F7F\u7528\uFF0C\u60A8\u78BA\u5B9A\u8981\u63A5\u7BA1\u6B64\u8A2D\u5099\u55CE\uFF1F")
85
+ };
86
+ return langText[locale];
87
+ };
88
+
89
+ /**
90
+ * SelectDevice 设备选择组件
91
+ * @description 展示设备列表,支持搜索过滤和选择,已被使用的设备需确认后选择
92
+ */
93
+ var SelectDevice = /*#__PURE__*/memo(function (props) {
94
+ var _props$deviceList = props.deviceList,
95
+ deviceList = _props$deviceList === void 0 ? [] : _props$deviceList,
96
+ _props$locale = props.locale,
97
+ locale = _props$locale === void 0 ? 'en' : _props$locale,
98
+ _props$loading = props.loading,
99
+ loading = _props$loading === void 0 ? false : _props$loading,
100
+ lastUsedDeviceId = props.lastUsedDeviceId,
101
+ onSelect = props.onSelect,
102
+ confirmOkText = props.confirmOkText,
103
+ confirmCancelText = props.confirmCancelText;
104
+
105
+ /** 搜索关键词 */
106
+ var _useState = useState(''),
107
+ _useState2 = _slicedToArray(_useState, 2),
108
+ searchKeyword = _useState2[0],
109
+ setSearchKeyword = _useState2[1];
110
+
111
+ /** 当前选中的设备ID(用于显示点击loading) */
112
+ var _useState3 = useState(null),
113
+ _useState4 = _slicedToArray(_useState3, 2),
114
+ selectingId = _useState4[0],
115
+ setSelectingId = _useState4[1];
116
+
117
+ /** 确认弹窗状态 */
118
+ var _useState5 = useState(false),
119
+ _useState6 = _slicedToArray(_useState5, 2),
120
+ confirmVisible = _useState6[0],
121
+ setConfirmVisible = _useState6[1];
122
+
123
+ /** 待确认的设备 */
124
+ var _useState7 = useState(null),
125
+ _useState8 = _slicedToArray(_useState7, 2),
126
+ pendingDevice = _useState8[0],
127
+ setPendingDevice = _useState8[1];
128
+
129
+ /**
130
+ * 过滤后的设备列表
131
+ */
132
+ var filteredDeviceList = useMemo(function () {
133
+ if (!searchKeyword.trim()) return deviceList;
134
+ return deviceList.filter(function (device) {
135
+ return matchDevice(device, searchKeyword);
136
+ });
137
+ }, [deviceList, searchKeyword]);
138
+
139
+ /**
140
+ * 处理搜索输入
141
+ */
142
+ var handleSearchChange = useCallback(function (e) {
143
+ setSearchKeyword(e.target.value);
144
+ }, []);
145
+
146
+ /**
147
+ * 处理设备选择
148
+ */
149
+ var handleSelectDevice = useCallback(function (device) {
150
+ if (selectingId) return; // 正在选择中,防止重复点击
151
+
152
+ // 如果设备已被使用(client 不为空),需要弹窗确认
153
+ if (device.client) {
154
+ setPendingDevice(device);
155
+ setConfirmVisible(true);
156
+ return;
157
+ }
158
+
159
+ // 直接选择
160
+ setSelectingId(device.id);
161
+ onSelect === null || onSelect === void 0 || onSelect(device);
162
+ }, [selectingId, onSelect]);
163
+
164
+ /**
165
+ * 确认接管设备
166
+ */
167
+ var handleConfirmSelect = useCallback(function () {
168
+ if (!pendingDevice) return;
169
+ setConfirmVisible(false);
170
+ setSelectingId(pendingDevice.id);
171
+ onSelect === null || onSelect === void 0 || onSelect(pendingDevice);
172
+ setPendingDevice(null);
173
+ }, [pendingDevice, onSelect]);
174
+
175
+ /**
176
+ * 取消确认
177
+ */
178
+ var handleCancelConfirm = useCallback(function () {
179
+ setConfirmVisible(false);
180
+ setPendingDevice(null);
181
+ }, []);
182
+
183
+ /**
184
+ * 获取按钮文本
185
+ */
186
+ var okText = confirmOkText || (locale === 'zh-CN' ? '确认' : locale === 'zh-HK' ? '確認' : 'Confirm');
187
+ var cancelText = confirmCancelText || (locale === 'zh-CN' ? '取消' : locale === 'zh-HK' ? '取消' : 'Cancel');
188
+
189
+ /**
190
+ * 渲染设备列表项
191
+ */
192
+ var renderDeviceItem = function renderDeviceItem(device) {
193
+ var isLastUsed = lastUsedDeviceId === device.id;
194
+ var isSelecting = selectingId === device.id;
195
+ return /*#__PURE__*/React.createElement("div", {
196
+ key: device.id,
197
+ className: "select-device__item ".concat(isSelecting ? 'select-device__item--selecting' : ''),
198
+ onClick: function onClick() {
199
+ return handleSelectDevice(device);
200
+ }
201
+ }, /*#__PURE__*/React.createElement("div", {
202
+ className: "select-device__item-icon"
203
+ }, /*#__PURE__*/React.createElement(DeviceIcon, null)), /*#__PURE__*/React.createElement("div", {
204
+ className: "select-device__item-content"
205
+ }, /*#__PURE__*/React.createElement("span", {
206
+ className: "select-device__item-name"
207
+ }, device.name), device.description && /*#__PURE__*/React.createElement("span", {
208
+ className: "select-device__item-desc"
209
+ }, device.description)), /*#__PURE__*/React.createElement("div", {
210
+ className: "select-device__item-extra"
211
+ }, isSelecting ? /*#__PURE__*/React.createElement(Spin, {
212
+ size: "small"
213
+ }) : isLastUsed ? /*#__PURE__*/React.createElement("span", {
214
+ className: "select-device__item-tag"
215
+ }, locales.getText('webpos-login-last-used')) : null));
216
+ };
217
+ return /*#__PURE__*/React.createElement("div", {
218
+ className: "select-device"
219
+ }, /*#__PURE__*/React.createElement("div", {
220
+ className: "select-device__search"
221
+ }, /*#__PURE__*/React.createElement(PisellInput, {
222
+ placeholder: locales.getText('webpos-login-search'),
223
+ prefix: /*#__PURE__*/React.createElement(SearchOutlined, {
224
+ style: {
225
+ color: '#999'
226
+ }
227
+ }),
228
+ value: searchKeyword,
229
+ onChange: handleSearchChange,
230
+ allowClear: true,
231
+ size: "large"
232
+ })), /*#__PURE__*/React.createElement("div", {
233
+ className: "select-device__list"
234
+ }, loading ? /*#__PURE__*/React.createElement("div", {
235
+ className: "select-device__loading"
236
+ }, /*#__PURE__*/React.createElement(Spin, {
237
+ size: "large"
238
+ })) : filteredDeviceList.length === 0 ? /*#__PURE__*/React.createElement("div", {
239
+ className: "select-device__empty"
240
+ }, /*#__PURE__*/React.createElement(PisellEmpty, {
241
+ description: locales.getText('webpos-login-select-device-empty')
242
+ })) : filteredDeviceList.map(renderDeviceItem)), /*#__PURE__*/React.createElement(PisellModal.Information, {
243
+ title: "",
244
+ describe: pendingDevice ? getConfirmText(pendingDevice, locale) : '',
245
+ open: confirmVisible,
246
+ okText: okText,
247
+ cancelText: cancelText,
248
+ okVisible: true,
249
+ cancelVisible: true,
250
+ closable: true,
251
+ footerDivider: true,
252
+ destroyOnClose: true,
253
+ onOk: handleConfirmSelect,
254
+ onCancel: handleCancelConfirm
255
+ }));
256
+ });
257
+ SelectDevice.displayName = 'SelectDevice';
258
+ export default SelectDevice;
@@ -0,0 +1,167 @@
1
+ /**
2
+ * SelectDevice 设备选择组件样式
3
+ */
4
+ .select-device {
5
+ display: flex;
6
+ flex-direction: column;
7
+ height: 100%;
8
+ overflow: hidden;
9
+
10
+ /* 搜索框区域 */
11
+ &__search {
12
+ flex-shrink: 0;
13
+ padding: 0 0 16px 0;
14
+
15
+ .ant-input-affix-wrapper {
16
+ border-radius: 8px;
17
+ border: 1px solid #e5e5e5;
18
+ background: #fff;
19
+ height: 48px;
20
+
21
+ &:hover,
22
+ &:focus,
23
+ &.ant-input-affix-wrapper-focused {
24
+ border-color: #F04A28;
25
+ box-shadow: 0 0 0 2px rgba(240, 74, 40, 0.1);
26
+ }
27
+
28
+ .ant-input {
29
+ font-size: 15px;
30
+ }
31
+ }
32
+ }
33
+
34
+ /* 设备列表区域 */
35
+ &__list {
36
+ flex: 1;
37
+ overflow-y: auto;
38
+ overflow-x: hidden;
39
+ padding-right: 4px;
40
+
41
+ /* 自定义滚动条 */
42
+ &::-webkit-scrollbar {
43
+ width: 6px;
44
+ }
45
+
46
+ &::-webkit-scrollbar-track {
47
+ background: transparent;
48
+ }
49
+
50
+ &::-webkit-scrollbar-thumb {
51
+ background: #ddd;
52
+ border-radius: 3px;
53
+
54
+ &:hover {
55
+ background: #ccc;
56
+ }
57
+ }
58
+ }
59
+
60
+ /* 加载状态 */
61
+ &__loading {
62
+ display: flex;
63
+ align-items: center;
64
+ justify-content: center;
65
+ height: 200px;
66
+ }
67
+
68
+ /* 空状态 */
69
+ &__empty {
70
+ display: flex;
71
+ align-items: center;
72
+ justify-content: center;
73
+ height: 200px;
74
+ }
75
+
76
+ /* 设备列表项 */
77
+ &__item {
78
+ display: flex;
79
+ align-items: center;
80
+ gap: 16px;
81
+ padding: 16px;
82
+ margin-bottom: 8px;
83
+ background: #fff;
84
+ border: 1px solid #eee;
85
+ border-radius: 12px;
86
+ cursor: pointer;
87
+ transition: all 0.2s ease;
88
+
89
+ &:hover {
90
+ border-color: #F04A28;
91
+ box-shadow: 0 2px 8px rgba(240, 74, 40, 0.1);
92
+ }
93
+
94
+ &:active {
95
+ transform: scale(0.99);
96
+ }
97
+
98
+ /* 选中状态 */
99
+ &--selecting {
100
+ opacity: 0.7;
101
+ pointer-events: none;
102
+ }
103
+
104
+ /* 设备图标 */
105
+ &-icon {
106
+ flex-shrink: 0;
107
+ display: flex;
108
+ align-items: center;
109
+ justify-content: center;
110
+ width: 48px;
111
+ height: 48px;
112
+ border-radius: 8px;
113
+ background: #f5f5f5;
114
+ color: #666;
115
+ }
116
+
117
+ /* 设备内容 */
118
+ &-content {
119
+ flex: 1;
120
+ min-width: 0;
121
+ display: flex;
122
+ flex-direction: column;
123
+ gap: 4px;
124
+ }
125
+
126
+ /* 设备名称 */
127
+ &-name {
128
+ display: block;
129
+ font-size: 15px;
130
+ font-weight: 500;
131
+ color: #1a1a1a;
132
+ white-space: nowrap;
133
+ overflow: hidden;
134
+ text-overflow: ellipsis;
135
+ }
136
+
137
+ /* 设备描述 */
138
+ &-desc {
139
+ display: block;
140
+ font-size: 13px;
141
+ color: #999;
142
+ white-space: nowrap;
143
+ overflow: hidden;
144
+ text-overflow: ellipsis;
145
+ }
146
+
147
+ /* 额外信息区域 */
148
+ &-extra {
149
+ flex-shrink: 0;
150
+ display: flex;
151
+ align-items: center;
152
+ }
153
+
154
+ /* Last used 标签 */
155
+ &-tag {
156
+ display: inline-flex;
157
+ align-items: center;
158
+ padding: 4px 12px;
159
+ font-size: 12px;
160
+ font-weight: 500;
161
+ color: #fff;
162
+ background: #F04A28;
163
+ border-radius: 4px;
164
+ white-space: nowrap;
165
+ }
166
+ }
167
+ }
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { StoreItem, LocaleType } from '../../types';
3
+ import './index.less';
4
+ /**
5
+ * SelectStore 组件 Props
6
+ */
7
+ export interface SelectStoreProps {
8
+ /** 店铺列表 */
9
+ storeList?: StoreItem[];
10
+ /** 语言 */
11
+ locale?: LocaleType;
12
+ /** 加载状态(列表加载) */
13
+ loading?: boolean;
14
+ /** 上次使用的店铺ID */
15
+ lastUsedStoreId?: number;
16
+ /** 选择店铺回调 */
17
+ onSelect?: (store: StoreItem) => void;
18
+ }
19
+ /**
20
+ * SelectStore 店铺选择组件
21
+ * @description 展示店铺列表,支持搜索过滤和选择
22
+ */
23
+ declare const SelectStore: React.FC<SelectStoreProps>;
24
+ export default SelectStore;
@@ -0,0 +1,198 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
+ 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."); }
7
+ 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); }
8
+ 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; }
9
+ 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; } }
10
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
+ import React, { memo, useState, useMemo, useCallback } from 'react';
12
+ import { Spin } from 'antd';
13
+ import { SearchOutlined } from '@ant-design/icons';
14
+ import { PisellInput, PisellEmpty, Image } from '@pisell/materials';
15
+ import { locales } from '@pisell/utils';
16
+ import "./index.less";
17
+
18
+ /**
19
+ * SelectStore 组件 Props
20
+ */
21
+
22
+ /** 默认店铺图标 */
23
+ var DEFAULT_STORE_ICON = 'https://pisell2-dev.s3.cn-north-1.amazonaws.com.cn/static/default-store-icon.png';
24
+
25
+ /**
26
+ * 获取店铺显示名称
27
+ * @param store 店铺数据
28
+ * @param locale 语言
29
+ */
30
+ var getStoreName = function getStoreName(store) {
31
+ var _store$tenant;
32
+ var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en';
33
+ var name = store === null || store === void 0 || (_store$tenant = store.tenant) === null || _store$tenant === void 0 ? void 0 : _store$tenant.name;
34
+ if (!name) return '';
35
+
36
+ // 优先使用对应语言的名称,否则使用 original
37
+ return name[locale] || name.original || '';
38
+ };
39
+
40
+ /**
41
+ * 模糊搜索匹配
42
+ * @param store 店铺数据
43
+ * @param keyword 搜索关键词
44
+ * @param locale 语言
45
+ */
46
+ var matchStore = function matchStore(store, keyword, locale) {
47
+ var _store$tenant2;
48
+ if (!keyword.trim()) return true;
49
+ var lowerKeyword = keyword.toLowerCase();
50
+ var name = store === null || store === void 0 || (_store$tenant2 = store.tenant) === null || _store$tenant2 === void 0 ? void 0 : _store$tenant2.name;
51
+
52
+ // 搜索所有语言的名称
53
+ var searchFields = [name === null || name === void 0 ? void 0 : name.en, name === null || name === void 0 ? void 0 : name['zh-CN'], name === null || name === void 0 ? void 0 : name['zh-HK'], name === null || name === void 0 ? void 0 : name.original, store === null || store === void 0 ? void 0 : store.nickname].filter(Boolean);
54
+ return searchFields.some(function (field) {
55
+ return field === null || field === void 0 ? void 0 : field.toLowerCase().includes(lowerKeyword);
56
+ });
57
+ };
58
+
59
+ /**
60
+ * SelectStore 店铺选择组件
61
+ * @description 展示店铺列表,支持搜索过滤和选择
62
+ */
63
+ var SelectStore = /*#__PURE__*/memo(function (props) {
64
+ var _props$storeList = props.storeList,
65
+ storeList = _props$storeList === void 0 ? [] : _props$storeList,
66
+ _props$locale = props.locale,
67
+ locale = _props$locale === void 0 ? 'en' : _props$locale,
68
+ _props$loading = props.loading,
69
+ loading = _props$loading === void 0 ? false : _props$loading,
70
+ lastUsedStoreId = props.lastUsedStoreId,
71
+ onSelect = props.onSelect;
72
+
73
+ /** 搜索关键词 */
74
+ var _useState = useState(''),
75
+ _useState2 = _slicedToArray(_useState, 2),
76
+ searchKeyword = _useState2[0],
77
+ setSearchKeyword = _useState2[1];
78
+
79
+ /** 当前选中的店铺ID(用于显示点击loading) */
80
+ var _useState3 = useState(null),
81
+ _useState4 = _slicedToArray(_useState3, 2),
82
+ selectingId = _useState4[0],
83
+ setSelectingId = _useState4[1];
84
+
85
+ /**
86
+ * 过滤后的店铺列表
87
+ */
88
+ var filteredStoreList = useMemo(function () {
89
+ if (!searchKeyword.trim()) return storeList;
90
+ return storeList.filter(function (store) {
91
+ return matchStore(store, searchKeyword, locale);
92
+ });
93
+ }, [storeList, searchKeyword, locale]);
94
+
95
+ /**
96
+ * 处理搜索输入
97
+ */
98
+ var handleSearchChange = useCallback(function (e) {
99
+ setSearchKeyword(e.target.value);
100
+ }, []);
101
+
102
+ /**
103
+ * 处理店铺选择
104
+ */
105
+ var handleSelectStore = useCallback( /*#__PURE__*/function () {
106
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(store) {
107
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
108
+ while (1) switch (_context.prev = _context.next) {
109
+ case 0:
110
+ if (!selectingId) {
111
+ _context.next = 2;
112
+ break;
113
+ }
114
+ return _context.abrupt("return");
115
+ case 2:
116
+ // 正在选择中,防止重复点击
117
+
118
+ setSelectingId(store.id);
119
+ _context.next = 5;
120
+ return onSelect === null || onSelect === void 0 ? void 0 : onSelect(store);
121
+ case 5:
122
+ setSelectingId(null);
123
+ case 6:
124
+ case "end":
125
+ return _context.stop();
126
+ }
127
+ }, _callee);
128
+ }));
129
+ return function (_x) {
130
+ return _ref.apply(this, arguments);
131
+ };
132
+ }(), [selectingId, onSelect]);
133
+
134
+ /**
135
+ * 渲染店铺列表项
136
+ */
137
+ var renderStoreItem = function renderStoreItem(store) {
138
+ var _store$tenant3;
139
+ var isLastUsed = lastUsedStoreId === store.id;
140
+ var isSelecting = selectingId === store.id;
141
+ var storeName = getStoreName(store, locale);
142
+ var storeIcon = (store === null || store === void 0 || (_store$tenant3 = store.tenant) === null || _store$tenant3 === void 0 ? void 0 : _store$tenant3.logo) || DEFAULT_STORE_ICON;
143
+ return /*#__PURE__*/React.createElement("div", {
144
+ key: store.id,
145
+ className: "select-store__item ".concat(isSelecting ? 'select-store__item--selecting' : ''),
146
+ onClick: function onClick() {
147
+ return handleSelectStore(store);
148
+ }
149
+ }, /*#__PURE__*/React.createElement("div", {
150
+ className: "select-store__item-icon"
151
+ }, /*#__PURE__*/React.createElement(Image, {
152
+ width: 48,
153
+ height: 48,
154
+ src: storeIcon,
155
+ alt: storeName,
156
+ fallbackType: "image",
157
+ preview: false
158
+ })), /*#__PURE__*/React.createElement("div", {
159
+ className: "select-store__item-content"
160
+ }, /*#__PURE__*/React.createElement("span", {
161
+ className: "select-store__item-name"
162
+ }, storeName)), /*#__PURE__*/React.createElement("div", {
163
+ className: "select-store__item-extra"
164
+ }, isSelecting ? /*#__PURE__*/React.createElement(Spin, {
165
+ size: "small"
166
+ }) : isLastUsed ? /*#__PURE__*/React.createElement("span", {
167
+ className: "select-store__item-tag"
168
+ }, locales.getText('webpos-login-last-used')) : null));
169
+ };
170
+ return /*#__PURE__*/React.createElement("div", {
171
+ className: "select-store"
172
+ }, /*#__PURE__*/React.createElement("div", {
173
+ className: "select-store__search"
174
+ }, /*#__PURE__*/React.createElement(PisellInput, {
175
+ placeholder: locales.getText('webpos-login-search'),
176
+ prefix: /*#__PURE__*/React.createElement(SearchOutlined, {
177
+ style: {
178
+ color: '#999'
179
+ }
180
+ }),
181
+ value: searchKeyword,
182
+ onChange: handleSearchChange,
183
+ allowClear: true,
184
+ size: "large"
185
+ })), /*#__PURE__*/React.createElement("div", {
186
+ className: "select-store__list"
187
+ }, loading ? /*#__PURE__*/React.createElement("div", {
188
+ className: "select-store__loading"
189
+ }, /*#__PURE__*/React.createElement(Spin, {
190
+ size: "large"
191
+ })) : filteredStoreList.length === 0 ? /*#__PURE__*/React.createElement("div", {
192
+ className: "select-store__empty"
193
+ }, /*#__PURE__*/React.createElement(PisellEmpty, {
194
+ description: locales.getText('webpos-login-select-store-empty')
195
+ })) : filteredStoreList.map(renderStoreItem)));
196
+ });
197
+ SelectStore.displayName = 'SelectStore';
198
+ export default SelectStore;