@pisell/materials 6.11.97 → 6.11.98

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 (42) 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 +6 -6
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +7 -7
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +7 -7
  11. package/es/components/buttonGroupPreview/index.js +2 -1
  12. package/es/components/pisellFind/index.d.ts +34 -12
  13. package/es/components/pisellFind/index.js +114 -18
  14. package/es/components/pisellRecordBoard/layouts/GridLayout/Grid.js +4 -2
  15. package/es/components/productCard/cartSkuCard/components/resources/index.less +4 -0
  16. package/es/components/productCard/lineItem/BookingLineItem.d.ts +2 -1
  17. package/es/components/productCard/lineItem/BookingLineItem.js +15 -6
  18. package/es/components/productCard/lineItem/components/Holders/index.d.ts +10 -0
  19. package/es/components/productCard/lineItem/components/Holders/index.js +74 -0
  20. package/es/components/productCard/lineItem/components/Holders/index.less +39 -0
  21. package/es/components/productCard/lineItem/index.d.ts +10 -8
  22. package/es/components/productCard/lineItem/index.js +61 -13
  23. package/es/components/productCard/lineItem/index.less +3 -3
  24. package/es/components/productCard/lineItem/types.d.ts +4 -0
  25. package/es/components/productCard/types.d.ts +1 -0
  26. package/lib/components/buttonGroupPreview/index.js +2 -1
  27. package/lib/components/pisellFind/index.d.ts +34 -12
  28. package/lib/components/pisellFind/index.js +80 -5
  29. package/lib/components/pisellRecordBoard/layouts/GridLayout/Grid.js +1 -1
  30. package/lib/components/productCard/cartSkuCard/components/resources/index.less +4 -0
  31. package/lib/components/productCard/lineItem/BookingLineItem.d.ts +2 -1
  32. package/lib/components/productCard/lineItem/BookingLineItem.js +14 -2
  33. package/lib/components/productCard/lineItem/components/Holders/index.d.ts +10 -0
  34. package/lib/components/productCard/lineItem/components/Holders/index.js +83 -0
  35. package/lib/components/productCard/lineItem/components/Holders/index.less +39 -0
  36. package/lib/components/productCard/lineItem/index.d.ts +10 -8
  37. package/lib/components/productCard/lineItem/index.js +51 -10
  38. package/lib/components/productCard/lineItem/index.less +3 -3
  39. package/lib/components/productCard/lineItem/types.d.ts +4 -0
  40. package/lib/components/productCard/types.d.ts +1 -0
  41. package/lowcode/pisell-find/meta.ts +19 -0
  42. package/package.json +3 -3
@@ -66,13 +66,14 @@ var ButtonGroupPreview = /*#__PURE__*/forwardRef(function (props, ref) {
66
66
  var btnProps = _objectSpread(_objectSpread({}, buttonProps), props.updateButtonProps);
67
67
  var children = btnProps.children,
68
68
  dropdownButtonProps = _objectWithoutProperties(btnProps, _excluded);
69
+ var moreButtonChildren = children !== null && children !== void 0 ? children : dropdownButtonProps.icon ? null : /*#__PURE__*/React.createElement(MoreOutlined, null);
69
70
  return isMore ? /*#__PURE__*/React.createElement(Dropdown, {
70
71
  menu: {
71
72
  items: menuData
72
73
  }
73
74
  }, /*#__PURE__*/React.createElement(Button, _extends({
74
75
  key: id
75
- }, dropdownButtonProps), children !== null && children !== void 0 ? children : /*#__PURE__*/React.createElement(MoreOutlined, null))) : /*#__PURE__*/React.createElement(Button, _extends({
76
+ }, dropdownButtonProps), moreButtonChildren)) : /*#__PURE__*/React.createElement(Button, _extends({
76
77
  key: id
77
78
  }, btnProps));
78
79
  }));
@@ -1,10 +1,37 @@
1
1
  import React from 'react';
2
2
  import type { PisellLookupProps, PisellLookupRef } from '../pisellLookup';
3
+ /**
4
+ * 原生扫码事件名,对齐宿主端约定。
5
+ */
6
+ export declare const SCAN_RESULT_EVENT = "nativeScanResult";
7
+ /**
8
+ * 扫码枪回传数据(对齐宿主 ScanResultPayload)
9
+ * - code: 条码标识(如条码格式 / 业务字段)
10
+ * - data: 扫描得到的字符串值(写入输入框的内容)
11
+ */
12
+ export interface PisellFindScannerData {
13
+ code: string;
14
+ data: string;
15
+ }
3
16
  /**
4
17
  * PisellFind Props
5
- * 继承 PisellLookup 的所有 Props
18
+ * 继承 PisellLookup 的所有 Props,并扩展扫码枪监听相关字段。
6
19
  */
7
- export declare type PisellFindProps = PisellLookupProps;
20
+ export interface PisellFindProps extends PisellLookupProps {
21
+ /**
22
+ * 是否开启扫码枪监听
23
+ * 通过宿主 `app.pubsub.subscribe('nativeScanResult', ...)` 订阅;
24
+ * 切换 false 时会 unsubscribe,停止接收事件。
25
+ * @default false
26
+ */
27
+ enableScanner?: boolean;
28
+ /**
29
+ * 扫码枪回调
30
+ * 监听到扫码枪事件时触发,参数为原始 payload 对象(含 `data` 字段)。
31
+ * 注意:仅在 enableScanner 为 true 时才会触发。
32
+ */
33
+ onScannerData?: (data: PisellFindScannerData) => void;
34
+ }
8
35
  /**
9
36
  * PisellFind Ref
10
37
  * 继承 PisellLookup 的所有 Ref 方法
@@ -19,22 +46,17 @@ export declare type PisellFindRef = PisellLookupRef;
19
46
  * - 默认不显示确认按钮(输入即搜索)
20
47
  * - 默认开启搜索历史
21
48
  * - 默认不展示结果区(结果在页面其他位置展示)
49
+ * - 通过 `enableScanner` 接入扫码枪:使用宿主 `app.pubsub.subscribe(SCAN_RESULT_EVENT, ...)`,
50
+ * 每次扫码直接覆盖输入框内容并触发 onSearch / onScannerData;切回 false 时自动 unsubscribe。
22
51
  *
23
52
  * @example
24
53
  * ```tsx
25
- * // 基础用法
26
- * <PisellFind
27
- * onSearch={(keyword) => {
28
- * const filtered = data.filter(item => item.name.includes(keyword));
29
- * setFilteredData(filtered);
30
- * }}
31
- * />
32
- *
33
- * // 切换为 Input 模式
34
54
  * <PisellFind
35
55
  * triggerType="input"
56
+ * enableScanner={isActive}
57
+ * onScannerData={(payload) => console.log('scan:', payload.data)}
36
58
  * onSearch={(keyword) => filterData(keyword)}
37
59
  * />
38
60
  * ```
39
61
  */
40
- export declare const PisellFind: React.ForwardRefExoticComponent<PisellLookupProps & React.RefAttributes<PisellLookupRef>>;
62
+ export declare const PisellFind: React.ForwardRefExoticComponent<PisellFindProps & React.RefAttributes<PisellLookupRef>>;
@@ -1,15 +1,27 @@
1
- var _excluded = ["triggerType", "buttonText", "placeholder", "showConfirmButton", "showHistory", "historyKey"];
1
+ var _excluded = ["triggerType", "buttonText", "placeholder", "showConfirmButton", "showHistory", "historyKey", "enableScanner", "onScannerData", "onSearch"];
2
2
  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); }
3
3
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
4
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5
- import React, { forwardRef } from 'react';
5
+ import React, { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
6
6
  import { locales as utilsLocales } from '@pisell/utils';
7
7
  import { PisellLookup } from "../pisellLookup";
8
+ import useEngineContext from "../../hooks/useEngineContext";
8
9
  import { getText } from "../../locales";
9
10
 
11
+ /**
12
+ * 原生扫码事件名,对齐宿主端约定。
13
+ */
14
+ export var SCAN_RESULT_EVENT = 'nativeScanResult';
15
+
16
+ /**
17
+ * 扫码枪回传数据(对齐宿主 ScanResultPayload)
18
+ * - code: 条码标识(如条码格式 / 业务字段)
19
+ * - data: 扫描得到的字符串值(写入输入框的内容)
20
+ */
21
+
10
22
  /**
11
23
  * PisellFind Props
12
- * 继承 PisellLookup 的所有 Props
24
+ * 继承 PisellLookup 的所有 Props,并扩展扫码枪监听相关字段。
13
25
  */
14
26
 
15
27
  /**
@@ -20,31 +32,27 @@ import { getText } from "../../locales";
20
32
  /**
21
33
  * PisellFind 组件
22
34
  * 基于 PisellLookup 的组件内查找优化版本
23
- *
35
+ *
24
36
  * 核心特点:
25
37
  * - 默认使用 button 触发器
26
38
  * - 默认不显示确认按钮(输入即搜索)
27
39
  * - 默认开启搜索历史
28
40
  * - 默认不展示结果区(结果在页面其他位置展示)
29
- *
41
+ * - 通过 `enableScanner` 接入扫码枪:使用宿主 `app.pubsub.subscribe(SCAN_RESULT_EVENT, ...)`,
42
+ * 每次扫码直接覆盖输入框内容并触发 onSearch / onScannerData;切回 false 时自动 unsubscribe。
43
+ *
30
44
  * @example
31
45
  * ```tsx
32
- * // 基础用法
33
- * <PisellFind
34
- * onSearch={(keyword) => {
35
- * const filtered = data.filter(item => item.name.includes(keyword));
36
- * setFilteredData(filtered);
37
- * }}
38
- * />
39
- *
40
- * // 切换为 Input 模式
41
46
  * <PisellFind
42
47
  * triggerType="input"
48
+ * enableScanner={isActive}
49
+ * onScannerData={(payload) => console.log('scan:', payload.data)}
43
50
  * onSearch={(keyword) => filterData(keyword)}
44
51
  * />
45
52
  * ```
46
53
  */
47
54
  export var PisellFind = /*#__PURE__*/forwardRef(function (props, ref) {
55
+ var _engineContext$appHel;
48
56
  var _props$triggerType = props.triggerType,
49
57
  triggerType = _props$triggerType === void 0 ? 'button' : _props$triggerType,
50
58
  _props$buttonText = props.buttonText,
@@ -65,17 +73,105 @@ export var PisellFind = /*#__PURE__*/forwardRef(function (props, ref) {
65
73
  showHistory = _props$showHistory === void 0 ? true : _props$showHistory,
66
74
  _props$historyKey = props.historyKey,
67
75
  historyKey = _props$historyKey === void 0 ? 'pisell_find_history' : _props$historyKey,
76
+ _props$enableScanner = props.enableScanner,
77
+ enableScanner = _props$enableScanner === void 0 ? false : _props$enableScanner,
78
+ onScannerData = props.onScannerData,
79
+ onSearch = props.onSearch,
68
80
  restProps = _objectWithoutProperties(props, _excluded);
81
+ var lookupRef = useRef(null);
82
+
83
+ /** 透传给监听回调的最新引用,避免回调闭包 stale */
84
+ var onScannerDataRef = useRef(onScannerData);
85
+ var onSearchRef = useRef(onSearch);
86
+ useEffect(function () {
87
+ onScannerDataRef.current = onScannerData;
88
+ }, [onScannerData]);
89
+ useEffect(function () {
90
+ onSearchRef.current = onSearch;
91
+ }, [onSearch]);
92
+ useImperativeHandle(ref, function () {
93
+ return {
94
+ open: function open() {
95
+ var _lookupRef$current;
96
+ return (_lookupRef$current = lookupRef.current) === null || _lookupRef$current === void 0 ? void 0 : _lookupRef$current.open();
97
+ },
98
+ close: function close() {
99
+ var _lookupRef$current2;
100
+ return (_lookupRef$current2 = lookupRef.current) === null || _lookupRef$current2 === void 0 ? void 0 : _lookupRef$current2.close();
101
+ },
102
+ getKeyword: function getKeyword() {
103
+ var _lookupRef$current$ge, _lookupRef$current3;
104
+ return (_lookupRef$current$ge = (_lookupRef$current3 = lookupRef.current) === null || _lookupRef$current3 === void 0 ? void 0 : _lookupRef$current3.getKeyword()) !== null && _lookupRef$current$ge !== void 0 ? _lookupRef$current$ge : '';
105
+ },
106
+ setKeyword: function setKeyword(v) {
107
+ var _lookupRef$current4;
108
+ return (_lookupRef$current4 = lookupRef.current) === null || _lookupRef$current4 === void 0 ? void 0 : _lookupRef$current4.setKeyword(v);
109
+ }
110
+ };
111
+ }, []);
112
+
113
+ /** 通过 useEngineContext 拿到宿主 app(含 pubsub.subscribe / unsubscribe) */
114
+ var engineContext = useEngineContext();
115
+ /**
116
+ * 用 ref 稳定 getApp 引用:低代码环境下 engineContext 每次渲染可能返回新引用,
117
+ * 若把 getApp 直接放进 effect 依赖会导致频繁 unsubscribe/subscribe(甚至漏掉扫码事件)。
118
+ * effect 依赖只保留 enableScanner,运行时通过 ref 拿最新的 getApp。
119
+ */
120
+ var getAppRef = useRef(undefined);
121
+ getAppRef.current = typeof (engineContext === null || engineContext === void 0 || (_engineContext$appHel = engineContext.appHelper) === null || _engineContext$appHel === void 0 || (_engineContext$appHel = _engineContext$appHel.utils) === null || _engineContext$appHel === void 0 ? void 0 : _engineContext$appHel.getApp) === 'function' ? engineContext.appHelper.utils.getApp : undefined;
122
+ useEffect(function () {
123
+ if (!enableScanner) return undefined;
124
+ var getApp = getAppRef.current;
125
+ if (typeof getApp !== 'function') return undefined;
126
+ var app = getApp();
127
+ var pubsub = app === null || app === void 0 ? void 0 : app.pubsub;
128
+ if (!pubsub || typeof pubsub.subscribe !== 'function') {
129
+ return undefined;
130
+ }
131
+
132
+ /**
133
+ * 监听回调:每次扫码直接覆盖输入框。
134
+ * ScanResultPayload: { code, data },取 code 作为输入框值与搜索关键词。
135
+ * setKeyword 在受控模式下会触发外部 onChange;onSearch 需要显式触发以驱动后续搜索流程
136
+ * (受控模式下宿主一般只通过 onSearch 拿到新关键词,不会在 onChange 里再触发一次 onSearch,
137
+ * 因此这里不会产生重复请求。如需自定义合流,可绑定 onScannerData 自行处理)。
138
+ *
139
+ * 非法 payload(无 code 或 code 为空串)直接忽略,避免把输入框/搜索条件意外清空。
140
+ */
141
+ var onScan = function onScan(payload) {
142
+ var _lookupRef$current5, _onSearchRef$current, _onScannerDataRef$cur;
143
+ var data = payload === null || payload === void 0 ? void 0 : payload.data;
144
+ if (typeof data !== 'string' || data.length === 0) {
145
+ return;
146
+ }
147
+ (_lookupRef$current5 = lookupRef.current) === null || _lookupRef$current5 === void 0 || _lookupRef$current5.setKeyword(data);
148
+ (_onSearchRef$current = onSearchRef.current) === null || _onSearchRef$current === void 0 || _onSearchRef$current.call(onSearchRef, data);
149
+ (_onScannerDataRef$cur = onScannerDataRef.current) === null || _onScannerDataRef$cur === void 0 || _onScannerDataRef$cur.call(onScannerDataRef, payload);
150
+ };
151
+ try {
152
+ pubsub.subscribe(SCAN_RESULT_EVENT, onScan);
153
+ } catch (e) {
154
+ console.warn('[PisellFind] subscribe scanner failed:', e);
155
+ return undefined;
156
+ }
157
+ return function () {
158
+ try {
159
+ var _pubsub$unsubscribe;
160
+ (_pubsub$unsubscribe = pubsub.unsubscribe) === null || _pubsub$unsubscribe === void 0 || _pubsub$unsubscribe.call(pubsub, SCAN_RESULT_EVENT, onScan);
161
+ } catch (e) {
162
+ console.warn('[PisellFind] unsubscribe scanner failed:', e);
163
+ }
164
+ };
165
+ }, [enableScanner]);
69
166
  return /*#__PURE__*/React.createElement(PisellLookup, _extends({
70
- ref: ref,
167
+ ref: lookupRef,
71
168
  triggerType: triggerType,
72
169
  buttonText: buttonText,
73
170
  placeholder: placeholder,
74
171
  showConfirmButton: showConfirmButton,
75
172
  showHistory: showHistory,
76
- historyKey: historyKey
173
+ historyKey: historyKey,
174
+ onSearch: onSearch
77
175
  }, restProps));
78
176
  });
79
-
80
- // 显示名称
81
177
  PisellFind.displayName = 'PisellFind';
@@ -217,8 +217,10 @@ var RecordBoardGridView = function RecordBoardGridView(props) {
217
217
  }) : rawScrollX;
218
218
  if (scroll !== null && scroll !== void 0 && scroll.autoCalc && typeof ctx.scrollAreaHeight === 'number') {
219
219
  var wrapHeight = ctx.scrollAreaHeight;
220
- // 40:表头等固定占高;uniformSummaryHeight:同值列总结区动态高度,无总结时为 0, 24是 uniformSummary padding
221
- var reservedHeight = 40 + uniformSummaryHeight + 24;
220
+ // 40:表头固定高;uniformSummaryHeight:同值列总结区高度(ResizeObserver 量出,仅 content-box,不含 padding/border);
221
+ // 25:仅在确实展示 uniformSummary 时补回 padding 12*2 + 1px border-bottom(见 Grid.less .pisell-record-board-uniform-summary)。
222
+ // 无总结时不应再多扣,否则 Table 不能撑满 scroll-body,会在 Table 与底部分页之间留白。
223
+ var reservedHeight = 40 + (uniformSummaryHeight > 0 ? uniformSummaryHeight + 25 : 0);
222
224
  return {
223
225
  x: scrollX !== null && scrollX !== void 0 ? scrollX : sumColumnWidths,
224
226
  y: Math.max(wrapHeight - reservedHeight, 100),
@@ -15,6 +15,10 @@
15
15
  overflow: hidden;
16
16
  text-overflow: ellipsis;
17
17
  margin: 0;
18
+
19
+ .resource-icon {
20
+ margin-right: 2px;
21
+ }
18
22
  }
19
23
 
20
24
  &--title {
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { ProductCardTypes } from '../types';
3
- import type { LineItemStatusOption, LineItemType } from './types';
3
+ import type { LineItemHolderOption, LineItemStatusOption, LineItemType } from './types';
4
4
  interface BookingLineItemProps extends Omit<ProductCardTypes, 'dataSource'> {
5
5
  dataSource: any;
6
6
  type: LineItemType;
@@ -12,6 +12,7 @@ interface BookingLineItemProps extends Omit<ProductCardTypes, 'dataSource'> {
12
12
  statusLoading?: boolean;
13
13
  statusDisabled?: boolean;
14
14
  isShowRelatedProduct?: boolean;
15
+ holderOptions?: LineItemHolderOption[];
15
16
  onBookingStatusChange?: (status: string, item: any) => void;
16
17
  }
17
18
  declare const BookingLineItem: (props: BookingLineItemProps) => React.JSX.Element | null;
@@ -1,4 +1,4 @@
1
- var _excluded = ["dataSource", "type", "cartSkuType", "relatedProductDataSource", "rightActions", "escapeDom", "isShowImage", "isShowDelete", "isShowNote", "isShowAmountFooter", "disabledClick", "disabledEdit", "statusOptions", "statusLoading", "statusDisabled", "isShowRelatedProduct", "onBookingStatusChange", "onAction", "onDelete", "onNote", "onCard", "onPromotion", "onGift"];
1
+ var _excluded = ["dataSource", "type", "cartSkuType", "relatedProductDataSource", "rightActions", "escapeDom", "isShowImage", "isFormSubject", "isShowDelete", "isShowNote", "isShowAmountFooter", "disabledClick", "disabledEdit", "statusOptions", "statusLoading", "statusDisabled", "isShowRelatedProduct", "holderOptions", "onBookingStatusChange", "onAction", "onDelete", "onNote", "onCard", "onPromotion", "onGift"];
2
2
  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); }
3
3
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
4
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -24,6 +24,7 @@ import { SwipeAction } from "../cartSkuCard/components/swipeAction";
24
24
  import Action from "../components/Action";
25
25
  import TimeRange from "./components/TimeRange";
26
26
  import Resources from "./components/Resources";
27
+ import Holders from "./components/Holders";
27
28
  import Iconfont from "../../iconfont";
28
29
  import useEngineContext from "../../../hooks/useEngineContext";
29
30
  var PREFIX = 'pisell-line-item';
@@ -64,7 +65,7 @@ var getResourceName = function getResourceName(booking, translationOriginal) {
64
65
  }).filter(Boolean).join(', ');
65
66
  };
66
67
  var BookingLineItem = function BookingLineItem(props) {
67
- var _context$appHelper$ut, _context$appHelper$ut2, _context$appHelper$ut3, _context$appHelper$ut4, _dataSource$promotion;
68
+ var _context$appHelper$ut, _context$appHelper$ut2, _context$appHelper$ut3, _context$appHelper$ut4, _ref, _ref2, _dataSource$promotion;
68
69
  var dataSource = props.dataSource,
69
70
  type = props.type,
70
71
  cartSkuType = props.cartSkuType,
@@ -73,6 +74,7 @@ var BookingLineItem = function BookingLineItem(props) {
73
74
  rightActions = _props$rightActions === void 0 ? [] : _props$rightActions,
74
75
  escapeDom = props.escapeDom,
75
76
  isShowImage = props.isShowImage,
77
+ isFormSubject = props.isFormSubject,
76
78
  isShowDelete = props.isShowDelete,
77
79
  isShowNote = props.isShowNote,
78
80
  isShowAmountFooter = props.isShowAmountFooter,
@@ -86,6 +88,7 @@ var BookingLineItem = function BookingLineItem(props) {
86
88
  statusDisabled = _props$statusDisabled === void 0 ? false : _props$statusDisabled,
87
89
  _props$isShowRelatedP = props.isShowRelatedProduct,
88
90
  isShowRelatedProduct = _props$isShowRelatedP === void 0 ? true : _props$isShowRelatedP,
91
+ holderOptions = props.holderOptions,
89
92
  onBookingStatusChange = props.onBookingStatusChange,
90
93
  _onAction = props.onAction,
91
94
  onDelete = props.onDelete,
@@ -131,7 +134,9 @@ var BookingLineItem = function BookingLineItem(props) {
131
134
  }
132
135
  };
133
136
  var bookingRightActions = isShowDelete ? [deleteAction].concat(_toConsumableArray(rightActions)) : rightActions;
134
- var bookingTitle = String((dataSource === null || dataSource === void 0 ? void 0 : dataSource.booking_id) || '-');
137
+ var resolvedHolderOptions = (_ref = (_ref2 = holderOptions !== null && holderOptions !== void 0 ? holderOptions : dataSource === null || dataSource === void 0 ? void 0 : dataSource.holderOptions) !== null && _ref2 !== void 0 ? _ref2 : dataSource === null || dataSource === void 0 ? void 0 : dataSource.holders) !== null && _ref !== void 0 ? _ref : [];
138
+ var resolvedIsFormSubject = isFormSubject !== null && isFormSubject !== void 0 ? isFormSubject : dataSource === null || dataSource === void 0 ? void 0 : dataSource.isFormSubject;
139
+ var bookingTitle = String((dataSource === null || dataSource === void 0 ? void 0 : dataSource.booking_id) || '');
135
140
  var bookingTime = formatBookingTime(dataSource, locale);
136
141
  var resourceName = getResourceName(dataSource, translationOriginal) || '-';
137
142
  var renderStatusButton = function renderStatusButton() {
@@ -184,8 +189,8 @@ var BookingLineItem = function BookingLineItem(props) {
184
189
  }, canChangeStatus ? /*#__PURE__*/React.createElement(Dropdown, {
185
190
  menu: {
186
191
  items: statusMenuItems,
187
- onClick: function onClick(_ref) {
188
- var key = _ref.key;
192
+ onClick: function onClick(_ref3) {
193
+ var key = _ref3.key;
189
194
  return onBookingStatusChange === null || onBookingStatusChange === void 0 ? void 0 : onBookingStatusChange(String(key), dataSource);
190
195
  }
191
196
  },
@@ -206,7 +211,11 @@ var BookingLineItem = function BookingLineItem(props) {
206
211
  dataSource: dataSource
207
212
  }), /*#__PURE__*/React.createElement(TimeRange, {
208
213
  dataSource: dataSource
209
- })), isShowRelatedProduct && relatedProductDataSource ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Divider, {
214
+ }), resolvedIsFormSubject ? /*#__PURE__*/React.createElement(Holders, {
215
+ dataSource: dataSource,
216
+ holderOptions: resolvedHolderOptions,
217
+ isFormSubject: resolvedIsFormSubject
218
+ }) : null), isShowRelatedProduct && relatedProductDataSource ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Divider, {
210
219
  style: {
211
220
  margin: 0
212
221
  }
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import type { LineItemHolderOption } from '../../types';
3
+ import './index.less';
4
+ interface LineItemHoldersProps {
5
+ dataSource?: any;
6
+ holderOptions?: LineItemHolderOption[];
7
+ isFormSubject?: boolean;
8
+ }
9
+ declare const LineItemHolders: (props: LineItemHoldersProps) => React.JSX.Element | null;
10
+ export default LineItemHolders;
@@ -0,0 +1,74 @@
1
+ import React, { useMemo } from 'react';
2
+ import { locales } from '@pisell/utils';
3
+ import Iconfont from "../../../../iconfont";
4
+ import "./index.less";
5
+ var PREFIX = 'pisell-line-item';
6
+ var holderIconMap = {
7
+ form: 'pisell2-file-05',
8
+ minors: 'pisell2-user-check-01',
9
+ waiver: 'pisell2-file-lock-03'
10
+ };
11
+ var isEmptyHolderId = function isEmptyHolderId(value) {
12
+ if (Array.isArray(value)) return value.length === 0;
13
+ return value === undefined || value === null || value === '';
14
+ };
15
+ var normalizeHolderIds = function normalizeHolderIds(value) {
16
+ if (isEmptyHolderId(value)) return [];
17
+ return Array.isArray(value) ? value : [value];
18
+ };
19
+ var pickHolderId = function pickHolderId(dataSource) {
20
+ var _ref, _ref2, _dataSource$holder_id, _dataSource$metadata, _dataSource$_extend, _dataSource$_extend2;
21
+ return (_ref = (_ref2 = (_dataSource$holder_id = dataSource === null || dataSource === void 0 ? void 0 : dataSource.holder_id) !== null && _dataSource$holder_id !== void 0 ? _dataSource$holder_id : dataSource === null || dataSource === void 0 || (_dataSource$metadata = dataSource.metadata) === null || _dataSource$metadata === void 0 ? void 0 : _dataSource$metadata.holder_id) !== null && _ref2 !== void 0 ? _ref2 : dataSource === null || dataSource === void 0 || (_dataSource$_extend = dataSource._extend) === null || _dataSource$_extend === void 0 || (_dataSource$_extend = _dataSource$_extend.product) === null || _dataSource$_extend === void 0 || (_dataSource$_extend = _dataSource$_extend.metadata) === null || _dataSource$_extend === void 0 ? void 0 : _dataSource$_extend.holder_id) !== null && _ref !== void 0 ? _ref : dataSource === null || dataSource === void 0 || (_dataSource$_extend2 = dataSource._extend) === null || _dataSource$_extend2 === void 0 || (_dataSource$_extend2 = _dataSource$_extend2.product) === null || _dataSource$_extend2 === void 0 || (_dataSource$_extend2 = _dataSource$_extend2._extend) === null || _dataSource$_extend2 === void 0 ? void 0 : _dataSource$_extend2.holder_id;
22
+ };
23
+ var pickHolderMaxCount = function pickHolderMaxCount(dataSource, holderIds) {
24
+ var _ref3, _ref4, _ref5, _ref6, _ref7, _dataSource$holderMax, _dataSource$_extend3, _dataSource$_extend4, _dataSource$_extend5;
25
+ var count = ((_ref3 = (_ref4 = (_ref5 = (_ref6 = (_ref7 = (_dataSource$holderMax = dataSource === null || dataSource === void 0 ? void 0 : dataSource.holderMaxCount) !== null && _dataSource$holderMax !== void 0 ? _dataSource$holderMax : dataSource === null || dataSource === void 0 ? void 0 : dataSource.holder_max_count) !== null && _ref7 !== void 0 ? _ref7 : dataSource === null || dataSource === void 0 ? void 0 : dataSource.number) !== null && _ref6 !== void 0 ? _ref6 : dataSource === null || dataSource === void 0 || (_dataSource$_extend3 = dataSource._extend) === null || _dataSource$_extend3 === void 0 || (_dataSource$_extend3 = _dataSource$_extend3.product) === null || _dataSource$_extend3 === void 0 ? void 0 : _dataSource$_extend3.num) !== null && _ref5 !== void 0 ? _ref5 : dataSource === null || dataSource === void 0 || (_dataSource$_extend4 = dataSource._extend) === null || _dataSource$_extend4 === void 0 || (_dataSource$_extend4 = _dataSource$_extend4.product) === null || _dataSource$_extend4 === void 0 ? void 0 : _dataSource$_extend4.product_quantity) !== null && _ref4 !== void 0 ? _ref4 : dataSource === null || dataSource === void 0 || (_dataSource$_extend5 = dataSource._extend) === null || _dataSource$_extend5 === void 0 || (_dataSource$_extend5 = _dataSource$_extend5.product) === null || _dataSource$_extend5 === void 0 || (_dataSource$_extend5 = _dataSource$_extend5._extend) === null || _dataSource$_extend5 === void 0 ? void 0 : _dataSource$_extend5.quantity) !== null && _ref3 !== void 0 ? _ref3 : holderIds.length) || 1;
26
+ return Number(count) || 1;
27
+ };
28
+ var LineItemHolders = function LineItemHolders(props) {
29
+ var _props$dataSource = props.dataSource,
30
+ dataSource = _props$dataSource === void 0 ? {} : _props$dataSource,
31
+ _props$holderOptions = props.holderOptions,
32
+ holderOptions = _props$holderOptions === void 0 ? [] : _props$holderOptions,
33
+ isFormSubject = props.isFormSubject;
34
+ var holderIds = useMemo(function () {
35
+ return normalizeHolderIds(pickHolderId(dataSource));
36
+ }, [dataSource]);
37
+ var holderMaxCount = pickHolderMaxCount(dataSource, holderIds);
38
+ var showUnassigned = Boolean(isFormSubject || (dataSource === null || dataSource === void 0 ? void 0 : dataSource.isFormSubject));
39
+ var holderType = (dataSource === null || dataSource === void 0 ? void 0 : dataSource.holderType) || (dataSource === null || dataSource === void 0 ? void 0 : dataSource.holder_type) || 'minors';
40
+ var holderIcon = holderIconMap[holderType] || holderIconMap.minors;
41
+ if (!holderIds.length) {
42
+ if (!showUnassigned) return null;
43
+ return /*#__PURE__*/React.createElement("div", {
44
+ className: "".concat(PREFIX, "__holders")
45
+ }, /*#__PURE__*/React.createElement("div", {
46
+ className: "holder-item unassigned"
47
+ }, holderMaxCount > 1 ? /*#__PURE__*/React.createElement("span", null, holderMaxCount, "/", holderMaxCount, ' ') : null, /*#__PURE__*/React.createElement("span", {
48
+ className: "holder-label"
49
+ }, locales.getText('pisell2.cart.sku-card.unassigned'))));
50
+ }
51
+ var renderHolder = function renderHolder(id, index) {
52
+ var _holder$label;
53
+ var holder = holderOptions.find(function (item) {
54
+ return String(item.id) === String(id);
55
+ });
56
+ var label = (_holder$label = holder === null || holder === void 0 ? void 0 : holder.label) !== null && _holder$label !== void 0 ? _holder$label : String(id);
57
+ return /*#__PURE__*/React.createElement("div", {
58
+ className: "holder-item",
59
+ key: "".concat(id, "-").concat(index)
60
+ }, /*#__PURE__*/React.createElement("span", {
61
+ className: "holder-icon"
62
+ }, /*#__PURE__*/React.createElement(Iconfont, {
63
+ type: holderIcon
64
+ })), /*#__PURE__*/React.createElement("span", {
65
+ className: "holder-label"
66
+ }, label));
67
+ };
68
+ return /*#__PURE__*/React.createElement("div", {
69
+ className: "".concat(PREFIX, "__holders")
70
+ }, holderIds.map(function (id, index) {
71
+ return renderHolder(id, index);
72
+ }));
73
+ };
74
+ export default LineItemHolders;
@@ -0,0 +1,39 @@
1
+ .pisell-line-item__holders {
2
+ user-select: none;
3
+ display: flex;
4
+ gap: 16px;
5
+ overflow: hidden;
6
+
7
+ .holder-item {
8
+ min-width: 30px;
9
+ display: flex;
10
+ align-items: center;
11
+ overflow: hidden;
12
+ white-space: nowrap;
13
+
14
+ .holder-icon {
15
+ margin-right: 2px;
16
+ color: #7f56da;
17
+ font-size: 16px;
18
+ }
19
+
20
+ .holder-label {
21
+ display: inline-block;
22
+ overflow: hidden;
23
+ color: #667085;
24
+ font-size: 14px;
25
+ font-weight: 500;
26
+ line-height: 20px;
27
+ text-overflow: ellipsis;
28
+ white-space: nowrap;
29
+ }
30
+ }
31
+
32
+ .unassigned {
33
+ color: red;
34
+
35
+ .holder-label {
36
+ color: red;
37
+ }
38
+ }
39
+ }
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import type { ProductCardTypes } from '../types';
3
- import type { itemType, LineItemStatusOption, LineItemType } from './types';
3
+ import type { itemType, LineItemHolderOption, LineItemStatusOption, LineItemType } from './types';
4
4
  import './index.less';
5
5
  export declare const PREFIX = "pisell-line-item";
6
- export type { itemType, LineItemStatusOption, LineItemType } from './types';
6
+ export type { itemType, LineItemHolderOption, LineItemStatusOption, LineItemType, } from './types';
7
7
  declare type LocalizedText = string | Record<string, unknown> | null | undefined;
8
8
  export interface LineItemProps extends Omit<ProductCardTypes, 'dataSource'> {
9
9
  dataSource: any;
@@ -15,6 +15,7 @@ export interface LineItemProps extends Omit<ProductCardTypes, 'dataSource'> {
15
15
  statusLoading?: boolean;
16
16
  statusDisabled?: boolean;
17
17
  isShowRelatedProduct?: boolean;
18
+ holderOptions?: LineItemHolderOption[];
18
19
  onBookingStatusChange?: (status: string, item: any) => void;
19
20
  }
20
21
  export declare const convertProductToLineItemProduct: (product: any, translationOriginal: (text: LocalizedText) => string, symbol: string) => {
@@ -29,10 +30,10 @@ export declare const convertProductToLineItemProduct: (product: any, translation
29
30
  image: any;
30
31
  num: any;
31
32
  quantity: any;
32
- price: any;
33
- total: any;
34
- origin_total: any;
35
- original_total: any;
33
+ price: number;
34
+ total: number;
35
+ origin_total: number;
36
+ original_total: number;
36
37
  source_product_price: any;
37
38
  selling_price: any;
38
39
  payment_price: any;
@@ -45,6 +46,7 @@ export declare const convertProductToLineItemProduct: (product: any, translation
45
46
  product_option_string: string;
46
47
  discount_list: any;
47
48
  promotions: any;
49
+ discount_reason: any;
48
50
  isGift: boolean;
49
51
  giftData: any;
50
52
  _origin: any;
@@ -57,8 +59,8 @@ export declare const convertProductToLineItemProduct: (product: any, translation
57
59
  quantity: any;
58
60
  };
59
61
  note: any;
60
- total: any;
61
- origin_total: any;
62
+ total: number;
63
+ origin_total: number;
62
64
  payment_price: any;
63
65
  };
64
66
  };