@pisell/private-materials 3.4.4 → 3.4.6

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 (65) 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 +3 -3
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +7 -7
  11. package/es/components/appointmentBooking/components/Cart/Item/index.js +1 -0
  12. package/es/components/appointmentBooking/components/Cart/Item/index.less +3 -3
  13. package/es/components/appointmentBooking/components/Cart/utils.js +8 -13
  14. package/es/components/appointmentBooking/components/Content/index.js +105 -19
  15. package/es/components/appointmentBooking/components/Content/index.less +1 -1
  16. package/es/components/appointmentBooking/components/Resource/index.js +1 -0
  17. package/es/components/appointmentBooking/components/Services/index.js +7 -2
  18. package/es/components/appointmentBooking/components/TimeSlicing/index.js +7 -3
  19. package/es/components/appointmentBooking/components/Voucher/index.js +10 -10
  20. package/es/components/appointmentBooking/hooks.js +28 -30
  21. package/es/components/appointmentBooking/index.js +14 -0
  22. package/es/components/appointmentBooking/index.less +1 -1
  23. package/es/components/booking/hooks/useIsBooking4Shop.d.ts +1 -1
  24. package/es/components/booking/hooks/useIsBooking4Shop.js +4 -3
  25. package/es/components/booking/info/addServiceVariant/index.js +2 -2
  26. package/es/components/booking/info/index.js +4 -4
  27. package/es/components/booking/info/utils.d.ts +1 -1
  28. package/es/components/booking/info/utils.js +4 -2
  29. package/es/components/booking/info2/service/addService/utils.js +38 -9
  30. package/es/components/booking/info2/service/addTimeModal/index.js +2 -2
  31. package/es/components/eventBooking/index.js +14 -0
  32. package/es/components/eventBooking/index.less +1 -1
  33. package/es/components/productSelect/components/TabProduct/index.js +103 -39
  34. package/es/components/productSelect/components/TabProduct/tabs/index.less +1 -0
  35. package/es/components/productSelect/index.d.ts +2 -0
  36. package/es/components/ticketBooking/components/addServiceVariant/addService.js +4 -4
  37. package/es/components/walletList/index.js +4 -4
  38. package/lib/components/appointmentBooking/components/Cart/Item/index.js +1 -0
  39. package/lib/components/appointmentBooking/components/Cart/Item/index.less +3 -3
  40. package/lib/components/appointmentBooking/components/Cart/utils.js +0 -10
  41. package/lib/components/appointmentBooking/components/Content/index.js +49 -7
  42. package/lib/components/appointmentBooking/components/Content/index.less +1 -1
  43. package/lib/components/appointmentBooking/components/Resource/index.js +1 -0
  44. package/lib/components/appointmentBooking/components/Services/index.js +6 -1
  45. package/lib/components/appointmentBooking/components/TimeSlicing/index.js +7 -3
  46. package/lib/components/appointmentBooking/components/Voucher/index.js +0 -11
  47. package/lib/components/appointmentBooking/hooks.js +5 -16
  48. package/lib/components/appointmentBooking/index.js +11 -0
  49. package/lib/components/appointmentBooking/index.less +1 -1
  50. package/lib/components/booking/hooks/useIsBooking4Shop.d.ts +1 -1
  51. package/lib/components/booking/hooks/useIsBooking4Shop.js +6 -4
  52. package/lib/components/booking/info/addServiceVariant/index.js +3 -2
  53. package/lib/components/booking/info/index.js +4 -3
  54. package/lib/components/booking/info/utils.d.ts +1 -1
  55. package/lib/components/booking/info/utils.js +2 -2
  56. package/lib/components/booking/info2/service/addService/utils.js +31 -10
  57. package/lib/components/booking/info2/service/addTimeModal/index.js +3 -2
  58. package/lib/components/eventBooking/index.js +11 -0
  59. package/lib/components/eventBooking/index.less +1 -1
  60. package/lib/components/productSelect/components/TabProduct/index.js +74 -37
  61. package/lib/components/productSelect/components/TabProduct/tabs/index.less +1 -0
  62. package/lib/components/productSelect/index.d.ts +2 -0
  63. package/lib/components/ticketBooking/components/addServiceVariant/addService.js +7 -6
  64. package/lib/components/walletList/index.js +3 -3
  65. package/package.json +3 -3
@@ -39,7 +39,15 @@ var import_ahooks = require("ahooks");
39
39
  var import_utils = require("@pisell/utils");
40
40
  var import_tabs = __toESM(require("./tabs"));
41
41
  var import_productGroup = __toESM(require("../productGroup"));
42
- var io = null;
42
+ var getOffsetTopRelativeToScrollContainer = (targetElement, scrollContainer) => {
43
+ if (!targetElement || !scrollContainer) return 0;
44
+ if (targetElement === scrollContainer) {
45
+ return 0;
46
+ }
47
+ const targetRect = targetElement.getBoundingClientRect();
48
+ const containerRect = scrollContainer.getBoundingClientRect();
49
+ return targetRect.top - containerRect.top + scrollContainer.scrollTop;
50
+ };
43
51
  var TabProduct = (props) => {
44
52
  const {
45
53
  showTab = true,
@@ -48,6 +56,7 @@ var TabProduct = (props) => {
48
56
  onChange,
49
57
  amountSymbol = "$",
50
58
  scrollDom,
59
+ offsetDom,
51
60
  value: currentProductId,
52
61
  loading,
53
62
  emptyDescription,
@@ -55,6 +64,8 @@ var TabProduct = (props) => {
55
64
  } = props;
56
65
  const tabsRef = (0, import_react.useRef)();
57
66
  const [currentGroupId, setCurrentGroupId] = (0, import_react.useState)(1);
67
+ const tabLocatingRef = (0, import_react.useRef)(false);
68
+ const ioRef = (0, import_react.useRef)(null);
58
69
  (0, import_react.useEffect)(() => {
59
70
  if (list == null ? void 0 : list.length) {
60
71
  setCurrentGroupId(list[0].id);
@@ -62,6 +73,9 @@ var TabProduct = (props) => {
62
73
  handleObserver();
63
74
  });
64
75
  }
76
+ return () => {
77
+ handleUnobserver();
78
+ };
65
79
  }, [list]);
66
80
  const debouncedScroll = (0, import_ahooks.useDebounceFn)(
67
81
  (id) => {
@@ -75,18 +89,23 @@ var TabProduct = (props) => {
75
89
  const _marginTop = 270;
76
90
  const _marginBottom = window.innerHeight - 70 - 200 - 70;
77
91
  const _rootMargin = `${_marginTop * -1}px 0px ${_marginBottom * -1}px 0px`;
78
- io = new IntersectionObserver(
92
+ ioRef.current = new IntersectionObserver(
79
93
  (entries) => {
80
- var _a, _b;
94
+ var _a;
81
95
  const enteringEntries = entries.filter((entry) => entry.isIntersecting);
82
96
  if (enteringEntries.length > 0) {
83
97
  const topMostEntry = enteringEntries.reduce((top, current) => {
84
98
  return current.boundingClientRect.top < top.boundingClientRect.top ? current : top;
85
99
  });
86
- const [name, id] = (_b = (_a = topMostEntry == null ? void 0 : topMostEntry.target) == null ? void 0 : _a.id) == null ? void 0 : _b.split("-");
87
- const newGroupId = Number(id);
88
- setCurrentGroupId(newGroupId);
89
- debouncedScroll.run(id);
100
+ const targetId = (_a = topMostEntry == null ? void 0 : topMostEntry.target) == null ? void 0 : _a.id;
101
+ if (targetId) {
102
+ const [name, id] = targetId.split("-");
103
+ const newGroupId = Number(id);
104
+ if (!tabLocatingRef.current && !isNaN(newGroupId)) {
105
+ setCurrentGroupId(newGroupId);
106
+ debouncedScroll.run(id);
107
+ }
108
+ }
90
109
  }
91
110
  },
92
111
  {
@@ -94,24 +113,28 @@ var TabProduct = (props) => {
94
113
  rootMargin: _rootMargin
95
114
  }
96
115
  );
97
- if (list == null ? void 0 : list.length) {
116
+ if ((list == null ? void 0 : list.length) && ioRef.current) {
98
117
  for (const item of list) {
99
118
  const _item = document.querySelector(`#list-${item.id}`);
100
119
  if (_item) {
101
- io.observe(_item);
120
+ ioRef.current.observe(_item);
102
121
  }
103
122
  }
104
123
  }
105
124
  });
106
125
  const handleUnobserver = (0, import_ahooks.useMemoizedFn)(() => {
107
- if ((list == null ? void 0 : list.length) && io) {
126
+ if ((list == null ? void 0 : list.length) && ioRef.current) {
108
127
  for (const item of list) {
109
128
  const _item = document.querySelector(`#list-${item.id}`);
110
129
  if (_item) {
111
- io.unobserve(_item);
130
+ ioRef.current.unobserve(_item);
112
131
  }
113
132
  }
114
133
  }
134
+ if (ioRef.current) {
135
+ ioRef.current.disconnect();
136
+ ioRef.current = null;
137
+ }
115
138
  });
116
139
  const renderContent = () => {
117
140
  if (loading) {
@@ -126,7 +149,7 @@ var TabProduct = (props) => {
126
149
  );
127
150
  }
128
151
  return list.map((item, i) => {
129
- return /* @__PURE__ */ import_react.default.createElement("div", { id: `list-${item.id}`, key: i }, /* @__PURE__ */ import_react.default.createElement(
152
+ return /* @__PURE__ */ import_react.default.createElement("div", { id: `list-${item.id}`, key: `list-${item.id}` }, /* @__PURE__ */ import_react.default.createElement(
130
153
  import_productGroup.default,
131
154
  {
132
155
  onSelectProduct: onChange,
@@ -148,7 +171,7 @@ var TabProduct = (props) => {
148
171
  }
149
172
  ), /* @__PURE__ */ import_react.default.createElement("div", { className: "booking-pisell-tabs-content" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Skeleton.Button, { active: true, size: "large", shape: "round" })));
150
173
  }, []);
151
- return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, showTab ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-product-select-tabs-wrapper" }, loading ? tabSkeleton : /* @__PURE__ */ import_react.default.createElement(
174
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, showTab && list && list.length > 1 ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-product-select-tabs-wrapper" }, loading ? tabSkeleton : /* @__PURE__ */ import_react.default.createElement(
152
175
  import_tabs.default,
153
176
  {
154
177
  ref: tabsRef,
@@ -157,33 +180,47 @@ var TabProduct = (props) => {
157
180
  tab: currentGroupId,
158
181
  onChange: (e) => {
159
182
  var _a;
160
- let comWrapper = document.querySelector(
161
- ".pisell-product-select-wrapper"
162
- );
163
- let categoryDom = document.querySelector(
164
- ".pisell-product-select-tabs-wrapper"
165
- );
166
- let wrapperOffsetTop = comWrapper.offsetTop;
167
- let top = 0;
168
- if (categoryDom) {
169
- top = categoryDom.offsetHeight;
170
- }
171
- const dom = document == null ? void 0 : document.querySelector("#list-" + e);
172
- const main = document == null ? void 0 : document.querySelector(scrollDom);
173
- if (dom && main) {
174
- if (e === ((_a = list[0]) == null ? void 0 : _a.id)) {
175
- main.scrollTop = 0;
176
- } else {
177
- main.scrollTop = dom.offsetTop - top - wrapperOffsetTop;
183
+ try {
184
+ const productSelectWrapper = document.querySelector(
185
+ ".pisell-product-select-wrapper"
186
+ );
187
+ const tabsWrapper = document.querySelector(
188
+ ".pisell-product-select-tabs-wrapper"
189
+ );
190
+ let tabsHeight = 0;
191
+ if (tabsWrapper) {
192
+ tabsHeight = tabsWrapper.offsetHeight;
193
+ }
194
+ const targetListElement = document == null ? void 0 : document.querySelector("#list-" + e);
195
+ const scrollContainer = scrollDom ? document == null ? void 0 : document.querySelector(scrollDom) : null;
196
+ const offsetElement = offsetDom ? document == null ? void 0 : document.querySelector(offsetDom) : null;
197
+ const extraOffset = offsetElement ? offsetElement.clientHeight : 0;
198
+ handleUnobserver();
199
+ tabLocatingRef.current = true;
200
+ if (targetListElement && scrollContainer) {
201
+ if (e === ((_a = list[0]) == null ? void 0 : _a.id)) {
202
+ if (productSelectWrapper) {
203
+ const wrapperOffsetTop = getOffsetTopRelativeToScrollContainer(productSelectWrapper, scrollContainer);
204
+ scrollContainer.scrollTop = wrapperOffsetTop - extraOffset;
205
+ }
206
+ } else {
207
+ const listOffsetTop = getOffsetTopRelativeToScrollContainer(targetListElement, scrollContainer);
208
+ scrollContainer.scrollTop = listOffsetTop - tabsHeight - extraOffset;
209
+ }
178
210
  }
211
+ setCurrentGroupId(e);
212
+ debouncedScroll.run(e);
213
+ setTimeout(() => {
214
+ tabLocatingRef.current = false;
215
+ handleObserver();
216
+ }, 500);
217
+ } catch (error) {
218
+ console.error("Tab onChange error:", error);
219
+ tabLocatingRef.current = false;
220
+ setCurrentGroupId(e);
179
221
  }
180
- handleUnobserver();
181
- setCurrentGroupId(e);
182
- setTimeout(() => {
183
- handleObserver();
184
- }, 1e3);
185
222
  }
186
223
  }
187
- )) : null, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-product-select-product-list" }, renderContent()));
224
+ )) : /* @__PURE__ */ import_react.default.createElement("p", null, /* @__PURE__ */ import_react.default.createElement("br", null)), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-product-select-product-list" }, renderContent()));
188
225
  };
189
226
  var TabProduct_default = TabProduct;
@@ -107,6 +107,7 @@
107
107
  text-overflow: ellipsis;
108
108
  overflow: hidden;
109
109
  white-space: nowrap;
110
+ user-select: none;
110
111
  }
111
112
 
112
113
  &:hover {
@@ -14,6 +14,8 @@ interface ProductSelectProps {
14
14
  value?: number;
15
15
  loading?: boolean;
16
16
  scrollDom?: string;
17
+ /** 某些设置了固定头部的情况 */
18
+ offsetDom?: string;
17
19
  style?: React.CSSProperties;
18
20
  emptyDescription?: string;
19
21
  token?: Partial<ProductSelectToken>;
@@ -48,7 +48,7 @@ var import_utils6 = require("../../utils");
48
48
  var import_notAvailable = __toESM(require("../notAvailable"));
49
49
  var import_dayjs = __toESM(require("dayjs"));
50
50
  var AddSerivce = (props) => {
51
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
51
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
52
52
  const { onEdit, state, dispatch, renderMode = "current" } = props;
53
53
  const [loading, setLoading] = (0, import_react.useState)(true);
54
54
  const context = (0, import_useEngineContext.default)();
@@ -64,7 +64,8 @@ var AddSerivce = (props) => {
64
64
  });
65
65
  const isBooking4 = (0, import_utils5.isBooking4Shop)(
66
66
  (_g = (_f = (_e = (_d = (_c = context.appHelper.utils.store) == null ? void 0 : _c.getState) == null ? void 0 : _d.call(_c)) == null ? void 0 : _e.global) == null ? void 0 : _f.globalConfig) == null ? void 0 : _g.id,
67
- state == null ? void 0 : state.renderType
67
+ state == null ? void 0 : state.renderType,
68
+ (_h = context.appHelper.utils) == null ? void 0 : _h.businessUtils
68
69
  );
69
70
  const [currentProduct, setCurrentProduct] = (0, import_react.useState)(null);
70
71
  const stateRef = (0, import_react.useRef)(state);
@@ -72,11 +73,11 @@ var AddSerivce = (props) => {
72
73
  const menuList = (0, import_react.useMemo)(() => {
73
74
  var _a2, _b2, _c2;
74
75
  return ((_c2 = (_b2 = (_a2 = state == null ? void 0 : state.bookingConfig) == null ? void 0 : _a2.config) == null ? void 0 : _b2.menu_list_tab) == null ? void 0 : _c2.menu_list) || [];
75
- }, [(_h = state == null ? void 0 : state.bookingConfig) == null ? void 0 : _h.config]);
76
+ }, [(_i = state == null ? void 0 : state.bookingConfig) == null ? void 0 : _i.config]);
76
77
  const customerId = (0, import_react.useMemo)(() => {
77
78
  var _a2, _b2;
78
79
  return ((_b2 = (_a2 = state.client) == null ? void 0 : _a2.value) == null ? void 0 : _b2.id) || void 0;
79
- }, [(_j = (_i = state.client) == null ? void 0 : _i.value) == null ? void 0 : _j.id]);
80
+ }, [(_k = (_j = state.client) == null ? void 0 : _j.value) == null ? void 0 : _k.id]);
80
81
  const setDefaultService = async (list) => {
81
82
  if (state.renderType !== "eventBooking") {
82
83
  return;
@@ -371,7 +372,7 @@ var AddSerivce = (props) => {
371
372
  }
372
373
  }
373
374
  return _list;
374
- }, [(_k = state.service) == null ? void 0 : _k.services, state == null ? void 0 : state.activeCartId]);
375
+ }, [(_l = state.service) == null ? void 0 : _l.services, state == null ? void 0 : state.activeCartId]);
375
376
  const currentDate = (0, import_react.useMemo)(() => {
376
377
  return state.date.value.format("YYYY-MM-DD");
377
378
  }, [state.date.value]);
@@ -414,7 +415,7 @@ var AddSerivce = (props) => {
414
415
  }
415
416
  return null;
416
417
  }, [
417
- (_m = (_l = state.service) == null ? void 0 : _l.cacheItem) == null ? void 0 : _m.autoClose,
418
+ (_n = (_m = state.service) == null ? void 0 : _m.cacheItem) == null ? void 0 : _n.autoClose,
418
419
  state.service.addModal,
419
420
  import_utils.locales,
420
421
  renderList,
@@ -117,17 +117,17 @@ var DEFAULT_BALANCE = {
117
117
  discount_card_count: 0
118
118
  };
119
119
  var WalletList = (0, import_model.Provider)((props) => {
120
- var _a, _b, _c, _d, _e, _f;
120
+ var _a, _b, _c, _d, _e, _f, _g;
121
121
  const { globalState = {} } = props;
122
122
  const { state, dispatch } = (0, import_react.useContext)(import_model.Context);
123
123
  const context = (0, import_useEngineContext.default)();
124
124
  const { constants, utils } = context.appHelper || {};
125
125
  const dvaStore = (_b = (_a = utils == null ? void 0 : utils.getStore) == null ? void 0 : _a.call(utils)) == null ? void 0 : _b.getState();
126
- import_utils.locales.init(import_locales.default, ((_c = dvaStore == null ? void 0 : dvaStore.core) == null ? void 0 : _c.translateLocale) || "en");
126
+ import_utils.locales.init(import_locales.default, ((_d = (_c = context == null ? void 0 : context.engine) == null ? void 0 : _c.props) == null ? void 0 : _d.locale) || "en");
127
127
  const isMountedRef = (0, import_react.useRef)(true);
128
128
  const carouselRef = (0, import_react.useRef)(null);
129
129
  const { store } = utils;
130
- const symbol = ((_f = (_e = (_d = store == null ? void 0 : store.getState) == null ? void 0 : _d.call(store)) == null ? void 0 : _e.global) == null ? void 0 : _f.symbol) || "$";
130
+ const symbol = ((_g = (_f = (_e = store == null ? void 0 : store.getState) == null ? void 0 : _e.call(store)) == null ? void 0 : _f.global) == null ? void 0 : _g.symbol) || "$";
131
131
  const prevButtonRef = (0, import_react.useRef)(null);
132
132
  const nextButtonRef = (0, import_react.useRef)(null);
133
133
  const [currentIndex, setCurrentIndex] = (0, import_react.useState)(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "3.4.4",
3
+ "version": "3.4.6",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -60,9 +60,9 @@
60
60
  "rc-virtual-list": "^3.11.3",
61
61
  "decimal.js": "^10.4.3",
62
62
  "@pisell/utils": "3.0.0",
63
+ "@pisell/materials": "3.3.47",
63
64
  "@pisell/icon": "0.0.11",
64
- "@pisell/date-picker": "3.0.2",
65
- "@pisell/materials": "3.3.40"
65
+ "@pisell/date-picker": "3.0.2"
66
66
  },
67
67
  "peerDependencies": {
68
68
  "react": "^18.0.0",