@pisell/materials 6.12.38 → 6.12.40

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.
@@ -44,6 +44,7 @@ const _excluded = [
44
44
  "statusDisabled",
45
45
  "isShowRelatedProduct",
46
46
  "holderOptions",
47
+ "onAssignHolder",
47
48
  "onBookingStatusChange",
48
49
  "onAddTimeProductCard",
49
50
  "onAction",
@@ -65,7 +66,7 @@ const getStatusOption = (status, statusOptions = []) => {
65
66
  };
66
67
  const BookingLineItem = (props) => {
67
68
  var _ref, _ref2, _dataSource$promotion, _dataSource$giftData;
68
- const { dataSource, type, cartSkuType, isShowBookingHeader, relatedProductDataSource, addTimeProductDataSources = [], rightActions = [], rightActionsDisplay = "swipe", escapeDom, isShowImage, isShowQuantityBadge = true, isFormSubject, isShowDelete, isShowInlineDelete = isShowDelete, isShowNote, isShowAmountFooter, disabledClick, disabledEdit, disabledNoteEdit = disabledEdit, statusOptions = [], statusLoading = false, statusDisabled = false, isShowRelatedProduct = true, holderOptions, onBookingStatusChange, onAddTimeProductCard, onAction, onDelete, onNote, onCard, onPromotion, onGift } = props, other = _objectWithoutProperties(props, _excluded);
69
+ const { dataSource, type, cartSkuType, isShowBookingHeader, relatedProductDataSource, addTimeProductDataSources = [], rightActions = [], rightActionsDisplay = "swipe", escapeDom, isShowImage, isShowQuantityBadge = true, isFormSubject, isShowDelete, isShowInlineDelete = isShowDelete, isShowNote, isShowAmountFooter, disabledClick, disabledEdit, disabledNoteEdit = disabledEdit, statusOptions = [], statusLoading = false, statusDisabled = false, isShowRelatedProduct = true, holderOptions, onAssignHolder, onBookingStatusChange, onAddTimeProductCard, onAction, onDelete, onNote, onCard, onPromotion, onGift } = props, other = _objectWithoutProperties(props, _excluded);
69
70
  const shouldRenderRelatedProduct = isShowRelatedProduct && Boolean(relatedProductDataSource);
70
71
  const [isAddTimeProductsExpanded, setIsAddTimeProductsExpanded] = useState(false);
71
72
  const { isShowAction, actionText } = dataSource;
@@ -192,11 +193,12 @@ const BookingLineItem = (props) => {
192
193
  onClick: ({ key }) => onBookingStatusChange === null || onBookingStatusChange === void 0 ? void 0 : onBookingStatusChange(String(key), dataSource)
193
194
  },
194
195
  trigger: ["click"]
195
- }, renderStatusButton()) : renderStatusButton(), renderDeleteButton()))) : null, /* @__PURE__ */ React.createElement("div", { className: classNames(`${PREFIX}__booking-detail`, { [`${PREFIX}__booking-detail--with-delete`]: !isShowBookingHeader && isShowInlineDelete }) }, /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__booking-detail-content` }, /* @__PURE__ */ React.createElement(LineItemResources, { dataSource }), /* @__PURE__ */ React.createElement(LineItemTimeRange, { dataSource }), resolvedIsFormSubject ? /* @__PURE__ */ React.createElement(LineItemHolders, {
196
+ }, renderStatusButton()) : renderStatusButton(), renderDeleteButton()))) : null, /* @__PURE__ */ React.createElement("div", { className: classNames(`${PREFIX}__booking-detail`, { [`${PREFIX}__booking-detail--with-delete`]: !isShowBookingHeader && isShowInlineDelete }) }, /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__booking-detail-content` }, /* @__PURE__ */ React.createElement(LineItemResources, { dataSource }), /* @__PURE__ */ React.createElement(LineItemTimeRange, { dataSource }), /* @__PURE__ */ React.createElement(LineItemHolders, {
196
197
  dataSource,
197
198
  holderOptions: resolvedHolderOptions,
198
- isFormSubject: resolvedIsFormSubject
199
- }) : null), !isShowBookingHeader ? renderDeleteButton(true) : null), shouldRenderRelatedProduct ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Divider, { style: { margin: 0 } }), /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__related-product` }, /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__related-product-card` }, renderProductCard(relatedProductDataSource, dataSource, {
199
+ isFormSubject: resolvedIsFormSubject,
200
+ onAssignHolder
201
+ })), !isShowBookingHeader ? renderDeleteButton(true) : null), shouldRenderRelatedProduct ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Divider, { style: { margin: 0 } }), /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__related-product` }, /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__related-product-card` }, renderProductCard(relatedProductDataSource, dataSource, {
200
202
  showProductPromotion: false,
201
203
  showAmountFooter: !shouldRenderFullWidthAmountFooter,
202
204
  inlineActions: showDeleteInRelatedProduct ? [deleteAction] : []
@@ -27,14 +27,30 @@ const pickHolderMaxCount = (dataSource, holderIds) => {
27
27
  return Number(count) || 1;
28
28
  };
29
29
  const LineItemHolders = (props) => {
30
- const { dataSource = {}, holderOptions = [], isFormSubject } = props;
30
+ const { dataSource = {}, holderOptions = [], isFormSubject, onAssignHolder } = props;
31
31
  const holderIds = useMemo(() => normalizeHolderIds(pickHolderId(dataSource)), [dataSource]);
32
32
  const holderMaxCount = pickHolderMaxCount(dataSource, holderIds);
33
- const showUnassigned = Boolean(isFormSubject || (dataSource === null || dataSource === void 0 ? void 0 : dataSource.isFormSubject));
33
+ const showUnassigned = isFormSubject !== void 0 ? Boolean(isFormSubject) : Boolean(dataSource === null || dataSource === void 0 ? void 0 : dataSource.isFormSubject);
34
34
  const holderIcon = holderIconMap[(dataSource === null || dataSource === void 0 ? void 0 : dataSource.holderType) || (dataSource === null || dataSource === void 0 ? void 0 : dataSource.holder_type) || "minors"] || holderIconMap.minors;
35
35
  if (!holderIds.length) {
36
36
  if (!showUnassigned) return null;
37
- return /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__holders` }, /* @__PURE__ */ React.createElement("div", { className: "holder-item unassigned" }, holderMaxCount > 1 ? /* @__PURE__ */ React.createElement("span", null, holderMaxCount, "/", holderMaxCount, " ") : null, /* @__PURE__ */ React.createElement("span", { className: "holder-label" }, locales.getText("pisell2.cart.sku-card.unassigned"))));
37
+ return /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__holders` }, /* @__PURE__ */ React.createElement("div", {
38
+ className: "holder-item unassigned",
39
+ role: onAssignHolder ? "button" : void 0,
40
+ tabIndex: onAssignHolder ? 0 : void 0,
41
+ onClick: (event) => {
42
+ if (!onAssignHolder) return;
43
+ event.preventDefault();
44
+ event.stopPropagation();
45
+ onAssignHolder();
46
+ },
47
+ onKeyDown: (event) => {
48
+ if (!onAssignHolder || !["Enter", " "].includes(event.key)) return;
49
+ event.preventDefault();
50
+ event.stopPropagation();
51
+ onAssignHolder();
52
+ }
53
+ }, holderMaxCount > 1 ? /* @__PURE__ */ React.createElement("span", null, holderMaxCount, "/", holderMaxCount, " ") : null, /* @__PURE__ */ React.createElement("span", { className: "holder-label" }, locales.getText("pisell2.cart.sku-card.unassigned"))));
38
54
  }
39
55
  const renderHolder = (id, index) => {
40
56
  const holder = holderOptions.find((item) => String(item.id) === String(id));
@@ -36,4 +36,8 @@
36
36
  color: red;
37
37
  }
38
38
  }
39
+
40
+ .unassigned[role='button'] {
41
+ cursor: pointer;
42
+ }
39
43
  }
@@ -47,6 +47,7 @@ const _excluded = [
47
47
  "statusDisabled",
48
48
  "isShowRelatedProduct",
49
49
  "holderOptions",
50
+ "onAssignHolder",
50
51
  "onBookingStatusChange",
51
52
  "onAddTimeProductCard",
52
53
  "onAction",
@@ -68,7 +69,7 @@ const getStatusOption = (status, statusOptions = []) => {
68
69
  };
69
70
  const BookingLineItem = (props) => {
70
71
  var _ref, _ref2, _dataSource$promotion, _dataSource$giftData;
71
- const { dataSource, type, cartSkuType, isShowBookingHeader, relatedProductDataSource, addTimeProductDataSources = [], rightActions = [], rightActionsDisplay = "swipe", escapeDom, isShowImage, isShowQuantityBadge = true, isFormSubject, isShowDelete, isShowInlineDelete = isShowDelete, isShowNote, isShowAmountFooter, disabledClick, disabledEdit, disabledNoteEdit = disabledEdit, statusOptions = [], statusLoading = false, statusDisabled = false, isShowRelatedProduct = true, holderOptions, onBookingStatusChange, onAddTimeProductCard, onAction, onDelete, onNote, onCard, onPromotion, onGift } = props, other = require_objectWithoutProperties._objectWithoutProperties(props, _excluded);
72
+ const { dataSource, type, cartSkuType, isShowBookingHeader, relatedProductDataSource, addTimeProductDataSources = [], rightActions = [], rightActionsDisplay = "swipe", escapeDom, isShowImage, isShowQuantityBadge = true, isFormSubject, isShowDelete, isShowInlineDelete = isShowDelete, isShowNote, isShowAmountFooter, disabledClick, disabledEdit, disabledNoteEdit = disabledEdit, statusOptions = [], statusLoading = false, statusDisabled = false, isShowRelatedProduct = true, holderOptions, onAssignHolder, onBookingStatusChange, onAddTimeProductCard, onAction, onDelete, onNote, onCard, onPromotion, onGift } = props, other = require_objectWithoutProperties._objectWithoutProperties(props, _excluded);
72
73
  const shouldRenderRelatedProduct = isShowRelatedProduct && Boolean(relatedProductDataSource);
73
74
  const [isAddTimeProductsExpanded, setIsAddTimeProductsExpanded] = (0, react.useState)(false);
74
75
  const { isShowAction, actionText } = dataSource;
@@ -195,11 +196,12 @@ const BookingLineItem = (props) => {
195
196
  onClick: ({ key }) => onBookingStatusChange === null || onBookingStatusChange === void 0 ? void 0 : onBookingStatusChange(String(key), dataSource)
196
197
  },
197
198
  trigger: ["click"]
198
- }, renderStatusButton()) : renderStatusButton(), renderDeleteButton()))) : null, /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)(`${PREFIX}__booking-detail`, { [`${PREFIX}__booking-detail--with-delete`]: !isShowBookingHeader && isShowInlineDelete }) }, /* @__PURE__ */ react.default.createElement("div", { className: `${PREFIX}__booking-detail-content` }, /* @__PURE__ */ react.default.createElement(require_index$11.default, { dataSource }), /* @__PURE__ */ react.default.createElement(require_index$10.default, { dataSource }), resolvedIsFormSubject ? /* @__PURE__ */ react.default.createElement(require_index$12.default, {
199
+ }, renderStatusButton()) : renderStatusButton(), renderDeleteButton()))) : null, /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)(`${PREFIX}__booking-detail`, { [`${PREFIX}__booking-detail--with-delete`]: !isShowBookingHeader && isShowInlineDelete }) }, /* @__PURE__ */ react.default.createElement("div", { className: `${PREFIX}__booking-detail-content` }, /* @__PURE__ */ react.default.createElement(require_index$11.default, { dataSource }), /* @__PURE__ */ react.default.createElement(require_index$10.default, { dataSource }), /* @__PURE__ */ react.default.createElement(require_index$12.default, {
199
200
  dataSource,
200
201
  holderOptions: resolvedHolderOptions,
201
- isFormSubject: resolvedIsFormSubject
202
- }) : null), !isShowBookingHeader ? renderDeleteButton(true) : null), shouldRenderRelatedProduct ? /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement(antd.Divider, { style: { margin: 0 } }), /* @__PURE__ */ react.default.createElement("div", { className: `${PREFIX}__related-product` }, /* @__PURE__ */ react.default.createElement("div", { className: `${PREFIX}__related-product-card` }, renderProductCard(relatedProductDataSource, dataSource, {
202
+ isFormSubject: resolvedIsFormSubject,
203
+ onAssignHolder
204
+ })), !isShowBookingHeader ? renderDeleteButton(true) : null), shouldRenderRelatedProduct ? /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement(antd.Divider, { style: { margin: 0 } }), /* @__PURE__ */ react.default.createElement("div", { className: `${PREFIX}__related-product` }, /* @__PURE__ */ react.default.createElement("div", { className: `${PREFIX}__related-product-card` }, renderProductCard(relatedProductDataSource, dataSource, {
203
205
  showProductPromotion: false,
204
206
  showAmountFooter: !shouldRenderFullWidthAmountFooter,
205
207
  inlineActions: showDeleteInRelatedProduct ? [deleteAction] : []
@@ -29,14 +29,30 @@ const pickHolderMaxCount = (dataSource, holderIds) => {
29
29
  return Number(count) || 1;
30
30
  };
31
31
  const LineItemHolders = (props) => {
32
- const { dataSource = {}, holderOptions = [], isFormSubject } = props;
32
+ const { dataSource = {}, holderOptions = [], isFormSubject, onAssignHolder } = props;
33
33
  const holderIds = (0, react.useMemo)(() => normalizeHolderIds(pickHolderId(dataSource)), [dataSource]);
34
34
  const holderMaxCount = pickHolderMaxCount(dataSource, holderIds);
35
- const showUnassigned = Boolean(isFormSubject || (dataSource === null || dataSource === void 0 ? void 0 : dataSource.isFormSubject));
35
+ const showUnassigned = isFormSubject !== void 0 ? Boolean(isFormSubject) : Boolean(dataSource === null || dataSource === void 0 ? void 0 : dataSource.isFormSubject);
36
36
  const holderIcon = holderIconMap[(dataSource === null || dataSource === void 0 ? void 0 : dataSource.holderType) || (dataSource === null || dataSource === void 0 ? void 0 : dataSource.holder_type) || "minors"] || holderIconMap.minors;
37
37
  if (!holderIds.length) {
38
38
  if (!showUnassigned) return null;
39
- return /* @__PURE__ */ react.default.createElement("div", { className: `${PREFIX}__holders` }, /* @__PURE__ */ react.default.createElement("div", { className: "holder-item unassigned" }, holderMaxCount > 1 ? /* @__PURE__ */ react.default.createElement("span", null, holderMaxCount, "/", holderMaxCount, " ") : null, /* @__PURE__ */ react.default.createElement("span", { className: "holder-label" }, _pisell_utils.locales.getText("pisell2.cart.sku-card.unassigned"))));
39
+ return /* @__PURE__ */ react.default.createElement("div", { className: `${PREFIX}__holders` }, /* @__PURE__ */ react.default.createElement("div", {
40
+ className: "holder-item unassigned",
41
+ role: onAssignHolder ? "button" : void 0,
42
+ tabIndex: onAssignHolder ? 0 : void 0,
43
+ onClick: (event) => {
44
+ if (!onAssignHolder) return;
45
+ event.preventDefault();
46
+ event.stopPropagation();
47
+ onAssignHolder();
48
+ },
49
+ onKeyDown: (event) => {
50
+ if (!onAssignHolder || !["Enter", " "].includes(event.key)) return;
51
+ event.preventDefault();
52
+ event.stopPropagation();
53
+ onAssignHolder();
54
+ }
55
+ }, holderMaxCount > 1 ? /* @__PURE__ */ react.default.createElement("span", null, holderMaxCount, "/", holderMaxCount, " ") : null, /* @__PURE__ */ react.default.createElement("span", { className: "holder-label" }, _pisell_utils.locales.getText("pisell2.cart.sku-card.unassigned"))));
40
56
  }
41
57
  const renderHolder = (id, index) => {
42
58
  const holder = holderOptions.find((item) => String(item.id) === String(id));
@@ -36,4 +36,8 @@
36
36
  color: red;
37
37
  }
38
38
  }
39
+
40
+ .unassigned[role='button'] {
41
+ cursor: pointer;
42
+ }
39
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/materials",
3
- "version": "6.12.38",
3
+ "version": "6.12.40",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -95,8 +95,8 @@
95
95
  "swiper": "^8.4.7",
96
96
  "antd-mobile": "^5.38.1",
97
97
  "vod-js-sdk-v6": "^1.4.11",
98
- "@pisell/date-picker": "3.0.10",
99
98
  "@pisell/utils": "3.0.4",
99
+ "@pisell/date-picker": "3.0.10",
100
100
  "@pisell/icon": "0.0.11"
101
101
  },
102
102
  "peerDependencies": {