@pisell/materials 2.2.39 → 2.2.41

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 (67) 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 +142 -142
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +24 -24
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +14 -14
  11. package/es/components/Pagination/index.d.ts +1 -1
  12. package/es/components/collapse/index.js +27 -4
  13. package/es/components/productCard/components/Action/index.js +1 -1
  14. package/es/components/productCard/components/AmountFooter/index.d.ts +1 -1
  15. package/es/components/productCard/components/AmountFooter/index.js +30 -10
  16. package/es/components/productCard/components/AmountFooter/index.less +11 -0
  17. package/es/components/productCard/components/Header/index.js +22 -14
  18. package/es/components/productCard/components/MultiDay/index.d.ts +4 -0
  19. package/es/components/productCard/components/MultiDay/index.js +79 -0
  20. package/es/components/productCard/components/MultiDay/index.less +34 -0
  21. package/es/components/productCard/components/MultiDay/utils.d.ts +14 -0
  22. package/es/components/productCard/components/MultiDay/utils.js +54 -0
  23. package/es/components/productCard/components/Packages/components/collapsibleList/utils.js +11 -5
  24. package/es/components/productCard/components/Packages/components/options/index.js +2 -2
  25. package/es/components/productCard/components/Packages/index.js +1 -2
  26. package/es/components/productCard/components/Sales/index.js +2 -2
  27. package/es/components/productCard/components/Time/index.js +15 -13
  28. package/es/components/productCard/index.d.ts +1 -1
  29. package/es/components/productCard/index.js +34 -20
  30. package/es/components/productCard/index.less +3 -2
  31. package/es/components/productCard/status.d.ts +24 -1
  32. package/es/components/productCard/status.js +52 -2
  33. package/es/components/productCard/types.d.ts +60 -1
  34. package/es/components/productCard/utils.d.ts +10 -144
  35. package/es/components/productCard/utils.js +36 -673
  36. package/es/components/table/Table/utils.d.ts +1 -1
  37. package/lib/components/Pagination/index.d.ts +1 -1
  38. package/lib/components/collapse/index.js +30 -4
  39. package/lib/components/productCard/components/Action/index.js +1 -1
  40. package/lib/components/productCard/components/AmountFooter/index.d.ts +1 -1
  41. package/lib/components/productCard/components/AmountFooter/index.js +33 -9
  42. package/lib/components/productCard/components/AmountFooter/index.less +11 -0
  43. package/lib/components/productCard/components/Header/index.js +16 -8
  44. package/lib/components/productCard/components/MultiDay/index.d.ts +4 -0
  45. package/lib/components/productCard/components/MultiDay/index.js +72 -0
  46. package/lib/components/productCard/components/MultiDay/index.less +34 -0
  47. package/lib/components/productCard/components/MultiDay/utils.d.ts +14 -0
  48. package/lib/components/productCard/components/MultiDay/utils.js +77 -0
  49. package/lib/components/productCard/components/Packages/components/collapsibleList/utils.js +2 -1
  50. package/lib/components/productCard/components/Packages/components/options/index.js +2 -2
  51. package/lib/components/productCard/components/Packages/index.js +1 -1
  52. package/lib/components/productCard/components/Sales/index.js +1 -2
  53. package/lib/components/productCard/components/Time/index.js +14 -11
  54. package/lib/components/productCard/index.d.ts +1 -1
  55. package/lib/components/productCard/index.js +32 -20
  56. package/lib/components/productCard/index.less +3 -2
  57. package/lib/components/productCard/status.d.ts +24 -1
  58. package/lib/components/productCard/status.js +35 -2
  59. package/lib/components/productCard/types.d.ts +60 -1
  60. package/lib/components/productCard/utils.d.ts +10 -144
  61. package/lib/components/productCard/utils.js +30 -567
  62. package/lib/components/table/Table/utils.d.ts +1 -1
  63. package/package.json +3 -3
  64. package/es/components/table/Actions/component/ExportImport/utils/index.d.ts +0 -9
  65. package/es/components/table/Actions/component/ExportImport/utils/index.js +0 -11
  66. package/lib/components/table/Actions/component/ExportImport/utils/index.d.ts +0 -9
  67. package/lib/components/table/Actions/component/ExportImport/utils/index.js +0 -31
@@ -29,594 +29,57 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  // src/components/productCard/utils.ts
30
30
  var utils_exports = {};
31
31
  __export(utils_exports, {
32
- deleteCacheParams: () => deleteCacheParams,
33
- findNextDuration: () => findNextDuration,
34
- findNextSlice: () => findNextSlice,
35
- flexibleObj: () => flexibleObj,
36
- formatProductListByCategory: () => formatProductListByCategory,
37
- formatResource: () => formatResource,
38
- formatTimes: () => formatTimes,
39
- getCacheParams: () => getCacheParams,
40
- getDiscountTime: () => getDiscountTime,
41
- getDuration: () => getDuration,
42
- getEndDate: () => getEndDate,
43
- getErrorList: () => getErrorList,
44
- getIsEdit: () => getIsEdit,
45
- getLastServer: () => getLastServer,
46
- getNowTime: () => getNowTime,
47
- getProductTotalPrice: () => getProductTotalPrice,
48
- getResourceTimeIsUsable: () => getResourceTimeIsUsable,
49
- getServeStartTime: () => getServeStartTime,
50
- getServerItemExtend: () => getServerItemExtend,
32
+ formatMultiDayDate: () => formatMultiDayDate,
51
33
  getServiceTime: () => getServiceTime,
52
- getServiceTimes: () => getServiceTimes,
53
- getShopOpeningHours: () => getShopOpeningHours,
54
- isNowTime: () => isNowTime,
55
- isWalkIn: () => isWalkIn,
56
- request: () => request,
57
- sliceDayIntoFiveMinutes: () => sliceDayIntoFiveMinutes
34
+ isEn: () => isEn
58
35
  });
59
36
  module.exports = __toCommonJS(utils_exports);
60
37
  var import_dayjs = __toESM(require("dayjs"));
61
38
  var import_utils = require("@pisell/utils");
62
- var import_lodash = require("lodash");
63
39
  var import_zh_cn = require("dayjs/locale/zh-cn");
64
40
  var import_en = require("dayjs/locale/en");
65
41
  var import_zh_tw = require("dayjs/locale/zh-tw");
66
- var Request = class {
67
- constructor() {
68
- this.request = {};
69
- }
70
- setRequest(val) {
71
- this.request = val;
72
- }
73
- getRequest() {
74
- return this.request;
75
- }
76
- };
77
- var request = new Request();
78
- var getDiscountTime = (service_times) => {
79
- if (!service_times) {
80
- return "";
81
- }
82
- if (service_times < 60) {
83
- return `${service_times} ${import_utils.locales.getText("pisell2.text.min")}`;
84
- } else {
85
- let str = "";
86
- const hours = Math.floor(service_times / 60);
87
- const minutes = service_times % 60;
88
- str += `${hours}${import_utils.locales.getText("pisell2.text.h")}`;
89
- if (minutes > 0) {
90
- str += ` ${minutes}${import_utils.locales.getText("pisell2.text.min")}`;
91
- }
92
- return str;
93
- }
94
- };
95
- var sliceDayIntoFiveMinutes = (config, locale) => {
96
- let _locale = locale;
97
- let dayjsLocale = _locale === "en-US" || _locale === "en" ? "en" : "zh-cn";
98
- import_dayjs.default.locale(dayjsLocale);
99
- const startTime = (0, import_dayjs.default)().startOf("day");
100
- const endTime = (0, import_dayjs.default)().endOf("day");
101
- const timeSlice = (config == null ? void 0 : config.value) || 5;
102
- let timeSlices = [];
103
- let durationSlicesBasedOnTime = [];
104
- let currentTime = startTime;
105
- while (currentTime.isBefore(endTime)) {
106
- const timeLabel = currentTime.format("hh:mm A");
107
- const timeValue = currentTime.format("HH:mm");
108
- timeSlices.push({ label: timeLabel, value: timeValue });
109
- const nextTime = currentTime.add(timeSlice, "minute");
110
- const durationValue = nextTime.diff(startTime, "minute");
111
- if (durationValue > 60) {
112
- const durationLabel = getDiscountTime(durationValue);
113
- durationSlicesBasedOnTime.push({
114
- label: durationLabel,
115
- value: durationValue
116
- });
117
- } else {
118
- const durationLabel = `${durationValue} ${import_utils.locales.getText(
119
- "pisell2.text.min"
120
- )}`;
121
- durationSlicesBasedOnTime.push({
122
- label: durationLabel,
123
- value: durationValue
124
- });
125
- }
126
- currentTime = nextTime;
127
- }
128
- return { timeSlices, durationSlicesBasedOnTime };
129
- };
130
- var getNowTime = () => {
131
- return (0, import_dayjs.default)().format("HH:mm");
132
- };
133
- var isNowTime = (time) => {
134
- return time === "now";
42
+ var isEn = (item) => {
43
+ const locale = (item == null ? void 0 : item.locale) || "en-US";
44
+ const _isEn = locale === "en-US" || locale === "en";
45
+ const localeTypes = {
46
+ "en-US": "en",
47
+ "zh-CN": "zh-cn",
48
+ "zh-HK": "zh-tw"
49
+ };
50
+ import_dayjs.default.locale(localeTypes[locale]);
51
+ return _isEn;
135
52
  };
136
- var getServeStartTime = (start_time) => {
137
- if (isNowTime(start_time)) {
138
- return getNowTime();
139
- }
140
- return start_time;
53
+ var formatMultiDayDate = (item) => {
54
+ const _isEn = isEn(item);
55
+ const startDate = (0, import_dayjs.default)(item == null ? void 0 : item.start_date);
56
+ const endDate = (0, import_dayjs.default)(item == null ? void 0 : item.end_date);
57
+ const _format = _isEn ? "ddd, DD/MM/YYYY" : "YYYY-MM-DD,ddd";
58
+ const date = `${startDate.format(_format)} ~ ${endDate.format(_format)}`;
59
+ return date;
141
60
  };
142
61
  var getServiceTime = (item, currentDate) => {
143
- var _a, _b, _c, _d, _e, _f, _g;
144
- if (!currentDate || !((_a = item == null ? void 0 : item._extend) == null ? void 0 : _a.start_time) || !(0, import_dayjs.default)(currentDate).isValid())
62
+ if (!(0, import_dayjs.default)(currentDate).isValid())
145
63
  return "";
146
64
  const locale = (item == null ? void 0 : item.locale) || "en-US";
147
- const isEn = locale === "en-US" || locale === "en";
65
+ const isEn2 = locale === "en-US" || locale === "en";
148
66
  const localeTypes = {
149
67
  "en-US": "en",
150
68
  "zh-CN": "zh-cn",
151
69
  "zh-HK": "zh-tw"
152
70
  };
153
71
  import_dayjs.default.locale(localeTypes[locale]);
154
- console.log(locale, "wh_locale");
155
- const startDate = (0, import_dayjs.default)(
156
- (currentDate == null ? void 0 : currentDate.format("YYYY-MM-DD")) + " " + getServeStartTime((_b = item == null ? void 0 : item._extend) == null ? void 0 : _b.start_time)
157
- );
158
- const startTime = startDate.format("HH:mm");
159
- if (((_c = item == null ? void 0 : item._extend) == null ? void 0 : _c.sub_type) === "days") {
160
- const startDate2 = (0, import_dayjs.default)((_d = item == null ? void 0 : item._extend) == null ? void 0 : _d.start_date);
161
- const endDate = (0, import_dayjs.default)((_e = item == null ? void 0 : item._extend) == null ? void 0 : _e.end_date);
162
- const diffInDays = endDate.diff(startDate2, "day");
163
- const _format = isEn ? "ddd, DD/MM/YYYY" : "YYYY-MM-DD,ddd";
164
- const date = `${startDate2.format(_format)} ~ ${endDate.format(_format)}`;
165
- const duration2 = `${diffInDays} ${import_utils.locales.getText("pisell2.product.card.day")(diffInDays)}`;
166
- return `${date} (${duration2})`;
167
- }
168
- const endTime = startDate.add(flexibleObj.getValue((_f = item == null ? void 0 : item._extend) == null ? void 0 : _f.duration), "minute").format("HH:mm");
169
- const duration = getDiscountTime(flexibleObj.getValue((_g = item == null ? void 0 : item._extend) == null ? void 0 : _g.duration));
170
- return `${startTime} - ${endTime} ( ${duration} )`;
171
- };
172
- var findNextSlice = ({
173
- timeSlices = [],
174
- index = 0,
175
- date = ""
176
- }) => {
177
- const currentTimeValue = date || (0, import_dayjs.default)().format("HH:mm");
178
- for (let i = 0; i < timeSlices.length; i++) {
179
- if (timeSlices[i].value !== "now") {
180
- if (timeSlices[i].value >= currentTimeValue) {
181
- return timeSlices[i].value;
182
- }
183
- }
184
- }
185
- return timeSlices[index].value;
186
- };
187
- var findNextDuration = (current, array, defaultValue) => {
188
- for (let i = 0; i < array.length; i++) {
189
- if (array[i].value == (current == null ? void 0 : current.value)) {
190
- return array[i].value;
191
- }
192
- }
193
- return defaultValue || array[0].value;
194
- };
195
- var formatProductListByCategory = (list, filterItem) => {
196
- let _list = list || [];
197
- if (filterItem) {
198
- _list = _list.filter(filterItem);
199
- }
200
- let categoryObject = {};
201
- for (let i = 0; i < _list.length; i++) {
202
- const productItem = _list[i];
203
- if ((productItem.category || []).length) {
204
- for (let j = 0; j < productItem.category.length; j++) {
205
- let categoryItem = productItem.category[j];
206
- if (!categoryObject[categoryItem.id]) {
207
- categoryObject[categoryItem.id] = {
208
- ...categoryItem,
209
- products: []
210
- };
211
- }
212
- categoryObject[categoryItem.id] = {
213
- ...categoryItem,
214
- products: [...categoryObject[categoryItem.id].products, productItem]
215
- };
216
- }
217
- } else {
218
- if (!categoryObject["other"]) {
219
- categoryObject["other"] = {
220
- id: 0,
221
- title: import_utils.locales.getText("pisell2.text.other"),
222
- name: import_utils.locales.getText("pisell2.text.other"),
223
- cover: "",
224
- products: []
225
- };
226
- }
227
- categoryObject["other"] = {
228
- ...categoryObject["other"],
229
- products: [...categoryObject["other"].products, productItem]
230
- };
231
- }
232
- }
233
- return Object.values(categoryObject).sort((a, b) => b.sort - a.sort);
234
- };
235
- var getResourceTimeIsUsable = (item, cacheItem) => {
236
- const startDate = (0, import_dayjs.default)(
237
- cacheItem._extend.start_date.format("YYYY-MM-DD") + " " + getServeStartTime(cacheItem._extend.start_time)
238
- );
239
- const isFlexible = flexibleObj.isFlexible(cacheItem._extend.duration);
240
- let isMaxLimitRange = false;
241
- let isDateRange = false;
242
- let time = { ...item };
243
- if (time.max_participants_limit == 0) {
244
- isMaxLimitRange = true;
245
- } else {
246
- isMaxLimitRange = "unknown";
247
- }
248
- const timeStartDate = (0, import_dayjs.default)(time.start_date + " " + time.start_time).subtract(
249
- 1,
250
- "second"
251
- );
252
- const timeEndDate = (0, import_dayjs.default)(time.end_date + " " + time.end_time).add(
253
- 1,
254
- "second"
255
- );
256
- let bol;
257
- if (isFlexible) {
258
- bol = startDate.isAfter(timeStartDate) && startDate.isBefore(timeEndDate);
259
- } else {
260
- let endDate = startDate.add(
261
- flexibleObj.getValue(cacheItem._extend.duration),
262
- "minute"
263
- );
264
- bol = startDate.isAfter(timeStartDate) && endDate.isBefore(timeEndDate);
265
- }
266
- if (bol) {
267
- isDateRange = true;
268
- }
269
- const isUsable = isDateRange;
270
- time._extend = {
271
- isMaxLimitRange,
272
- isDateRange,
273
- isUsable
274
- };
275
- return time;
276
- };
277
- var formatTimes = (resourceItem, cacheItem) => {
278
- let usableTimes = [];
279
- let _resourceItem = { ...resourceItem };
280
- _resourceItem.times = _resourceItem.times.map((time) => {
281
- let _time2 = getResourceTimeIsUsable(time, cacheItem);
282
- if (_time2 == null ? void 0 : _time2._extend.isUsable) {
283
- usableTimes.push(_time2);
284
- }
285
- return _time2;
286
- });
287
- let _time = (usableTimes || []).sort((a, b) => {
288
- const aEndDate = (0, import_dayjs.default)(a.end_date + " " + a.end_time).valueOf();
289
- const bEndDate = (0, import_dayjs.default)(b.end_date + " " + b.end_time).valueOf();
290
- return aEndDate - bEndDate;
291
- })[0];
292
- resourceItem._extend = {
293
- ...resourceItem._extend,
294
- usableTime: _time
295
- };
296
- return resourceItem;
297
- };
298
- var formatResourceProducts = (resourceItem, currentItem) => {
299
- var _a;
300
- let usableProduct = false;
301
- let _resourceItem = { ...resourceItem };
302
- const type = _resourceItem.partyroom_package.type;
303
- if (type === "product_all") {
304
- usableProduct = true;
305
- } else {
306
- if (type === "product_collection") {
307
- usableProduct = !!(0, import_lodash.intersectionBy)(
308
- ((_a = _resourceItem.partyroom_package) == null ? void 0 : _a.products.map((item) => ({
309
- ...item,
310
- id: item.product_collection_id
311
- }))) || [],
312
- currentItem.collection || [],
313
- "id"
314
- ).length;
315
- } else {
316
- usableProduct = _resourceItem.partyroom_package.products.some(
317
- (item) => {
318
- if (type === "products") {
319
- if (item.product_id == currentItem.product_id) {
320
- return true;
321
- }
322
- }
323
- }
324
- );
325
- }
326
- }
327
- resourceItem._extend = {
328
- ...resourceItem._extend,
329
- // 是否可用
330
- usableProduct
331
- };
332
- return resourceItem;
333
- };
334
- var getShopOpeningHours = () => {
335
- return localStorage.getItem("shopOpeningHours") || "23:59";
336
- };
337
- var flexibleObj = {
338
- // 创建, 增加前缀
339
- create: (num) => {
340
- return `flexible_${num}`;
341
- },
342
- // 格式化, 去除前缀
343
- getValue: (str) => {
344
- if (typeof str === "string" && flexibleObj.isFlexible(str)) {
345
- return Number(str.replace("flexible_", ""));
346
- }
347
- return str;
348
- },
349
- // 判断当前时长是否为灵活时长
350
- isFlexible: (str) => {
351
- if (typeof str !== "string") {
352
- return false;
353
- }
354
- return str.indexOf("flexible_") > -1;
355
- },
356
- add: (current, duration) => {
357
- if (flexibleObj.isFlexible(current)) {
358
- return flexibleObj.create(
359
- flexibleObj.getValue(current) + duration
360
- );
361
- } else {
362
- return Number(current) + duration;
363
- }
364
- }
365
- };
366
- var getEndDate = (startDate, duration, endDate) => {
367
- if (duration === "flexible") {
368
- let openingDate = (0, import_dayjs.default)(
369
- startDate.format("YYYY-MM-DD") + " " + getShopOpeningHours()
370
- );
371
- if ((0, import_dayjs.default)(startDate).isAfter(openingDate)) {
372
- openingDate = openingDate.add(1, "day");
373
- }
374
- if (!endDate) {
375
- return openingDate;
376
- }
377
- endDate = (0, import_dayjs.default)(endDate);
378
- if (endDate.isAfter(openingDate)) {
379
- return openingDate;
380
- }
381
- return endDate;
382
- }
383
- return startDate.add(duration, "minute");
384
- };
385
- var getServiceTimes = (service) => {
386
- const startDate = (0, import_dayjs.default)(
387
- (0, import_dayjs.default)(service._extend.start_date).format("YYYY-MM-DD ") + getServeStartTime(service._extend.start_time)
388
- );
389
- const endDate = startDate.add(
390
- flexibleObj.getValue(service._extend.duration),
391
- "minute"
392
- );
393
- return {
394
- startDate,
395
- endDate
396
- };
397
- };
398
- var getErrorList = (resource, cacheItem) => {
399
- var _a, _b, _c;
400
- if (!(cacheItem == null ? void 0 : cacheItem.id)) {
401
- return [
402
- {
403
- label: import_utils.locales.getText("pisell2.text.no-product-added"),
404
- type: "products"
405
- }
406
- ];
407
- }
408
- if (!resource || !resource._extend || !cacheItem) {
409
- return [];
410
- }
411
- let list = [];
412
- if (!resource.usable) {
413
- if (!((_a = resource == null ? void 0 : resource._extend) == null ? void 0 : _a.usableProduct)) {
414
- list.push({
415
- label: import_utils.locales.getText("pisell1.text.resource-error-message-1")(
416
- resource.labelText,
417
- cacheItem == null ? void 0 : cacheItem.title
418
- ),
419
- type: "product"
420
- });
421
- }
422
- const { startDate, endDate } = getServiceTimes(cacheItem);
423
- const startText = startDate.format("hh:mm A");
424
- let endText = endDate.format("hh:mm A");
425
- if ((0, import_dayjs.default)(endDate).isAfter(startDate, "day")) {
426
- endText = import_utils.locales.getText("pisell1.text.tomorrow") + endText;
427
- }
428
- if (!((_b = resource._extend) == null ? void 0 : _b.usableTime)) {
429
- list.push({
430
- label: import_utils.locales.getText("pisell1.text.resource-error-message-2")(
431
- resource.labelText,
432
- startText,
433
- endText
434
- ),
435
- type: "time"
436
- });
437
- } else {
438
- if (!((_c = resource._extend) == null ? void 0 : _c.usableTime._extend.isMaxLimitRange)) {
439
- list.push({
440
- label: import_utils.locales.getText("pisell1.text.resource-error-message-3")(
441
- resource.labelText,
442
- startText,
443
- endText
444
- ),
445
- type: "limit"
446
- });
447
- }
448
- }
449
- }
450
- return list;
451
- };
452
- var formatResource = (resourceItem, cacheItem, formatLabel) => {
453
- let _resourceItem = { ...resourceItem };
454
- _resourceItem = formatTimes(_resourceItem, cacheItem);
455
- _resourceItem = formatResourceProducts(_resourceItem, cacheItem);
456
- _resourceItem.labelText = _resourceItem.room_name || _resourceItem.name;
457
- const usable = _resourceItem._extend.usableTime && _resourceItem._extend.usableProduct;
458
- _resourceItem.usable = usable;
459
- if (formatLabel) {
460
- _resourceItem.label = formatLabel(_resourceItem);
461
- }
462
- return _resourceItem;
463
- };
464
- var getLastServer = (list) => {
465
- return list[list.length - 1];
466
- };
467
- var getCacheParams = () => {
468
- const sessionData = sessionStorage.getItem("pisell2.booking.serviceParams");
469
- const data = sessionData ? JSON.parse(sessionData) : null;
470
- return data == null ? void 0 : data.serviceParams;
471
- };
472
- var deleteCacheParams = () => {
473
- sessionStorage.removeItem("pisell2.booking.serviceParams");
474
- };
475
- var getServerItemExtend = (state, cacheItem, timeObj) => {
476
- var _a;
477
- if (!cacheItem.new && cacheItem._extend.endDate) {
478
- return cacheItem._extend;
479
- }
480
- let lastServer = getLastServer(state.service.value);
481
- let _extend = {
482
- duration: findNextDuration(
483
- cacheItem.duration,
484
- timeObj.durationSlicesBasedOnTime,
485
- (_a = cacheItem == null ? void 0 : cacheItem.duration) == null ? void 0 : _a.value
486
- )
487
- };
488
- if (lastServer) {
489
- _extend.resource = lastServer._extend.resource;
490
- let lastServerStartDate = lastServer._extend.startDate;
491
- let lastServerEndDate = lastServer._extend.endDate;
492
- if ((0, import_dayjs.default)(lastServerEndDate).isAfter(lastServerStartDate, "day")) {
493
- _extend.start_time = timeObj.timeSlices[timeObj.timeSlices.length - 1].value;
494
- } else {
495
- _extend.start_time = lastServerEndDate.format("HH:mm");
496
- }
497
- } else {
498
- let findNextSliceProps = {
499
- timeSlices: timeObj.timeSlices,
500
- index: 0,
501
- date: ""
502
- };
503
- const serviceParams = getCacheParams();
504
- if (serviceParams) {
505
- let str = serviceParams.start_date;
506
- if (str) {
507
- findNextSliceProps.date = (0, import_dayjs.default)(str).format("HH:mm");
508
- }
509
- let resourceId = Number(serviceParams.resource_id);
510
- if (resourceId || resourceId === 0) {
511
- _extend.resource = resourceId;
512
- }
513
- }
514
- if (findNextSliceProps.date && findNextSliceProps.date !== "00:00") {
515
- _extend.start_time = findNextSlice(findNextSliceProps);
516
- } else {
517
- if (cacheItem.currentDefaultTime) {
518
- _extend.start_time = cacheItem.currentDefaultTime;
519
- } else {
520
- _extend.start_time = (0, import_dayjs.default)().format("HH:mm");
521
- }
522
- }
523
- }
524
- _extend = {
525
- ..._extend,
526
- ...cacheItem._extend
527
- };
528
- return _extend;
529
- };
530
- var getProductTotalPrice = (item) => {
531
- var _a;
532
- let price = 0;
533
- price += Number(item._extend.price);
534
- let other = (_a = item._extend) == null ? void 0 : _a.other;
535
- if (other == null ? void 0 : other.bundle) {
536
- price = other == null ? void 0 : other.bundle.reduce((accumulator, currentValue) => {
537
- return accumulator + Number(currentValue.price) * Number(currentValue.num);
538
- }, price);
539
- }
540
- price = price;
541
- return price;
542
- };
543
- var getDuration = (duration) => {
544
- if (typeof duration === "number") {
545
- return duration;
546
- }
547
- if (typeof duration === "object") {
548
- if (duration.type === "minutes") {
549
- return duration.value;
550
- }
551
- if (duration.type === "flexible") {
552
- return "flexible";
553
- }
554
- }
555
- return duration;
556
- };
557
- var isWalkIn = (customer_id) => {
558
- if (customer_id === void 0) {
559
- return true;
560
- }
561
- if (typeof customer_id === "string") {
562
- return ["", "0", "1"].includes(customer_id);
563
- }
564
- return [0, 1].includes(customer_id);
565
- };
566
- var getIsEdit = (state) => {
567
- var _a, _b, _c, _d, _e, _f, _g;
568
- if ((_a = state.addons) == null ? void 0 : _a.edit) {
569
- return true;
570
- }
571
- if (!state.bookingId) {
572
- return true;
573
- }
574
- if ((_b = state.client) == null ? void 0 : _b.edit) {
575
- return true;
576
- }
577
- if ((_c = state.date) == null ? void 0 : _c.edit) {
578
- return true;
579
- }
580
- if ((_d = state.pet) == null ? void 0 : _d.edit) {
581
- return true;
582
- }
583
- if ((_e = state.service) == null ? void 0 : _e.edit) {
584
- return true;
585
- }
586
- if ((_f = state.notes) == null ? void 0 : _f.edit) {
587
- return true;
588
- }
589
- if ((_g = state.contacts) == null ? void 0 : _g.edit) {
590
- return true;
591
- }
592
- return false;
72
+ const startDate = (0, import_dayjs.default)(item == null ? void 0 : item.start_date);
73
+ const endDate = (0, import_dayjs.default)(item == null ? void 0 : item.end_date);
74
+ const diffInDays = endDate.diff(startDate, "day");
75
+ const _format = isEn2 ? "ddd, DD/MM/YYYY" : "YYYY-MM-DD,ddd";
76
+ const date = `${startDate.format(_format)} ~ ${endDate.format(_format)}`;
77
+ const duration = `${diffInDays} ${import_utils.locales.getText("pisell2.product.card.day")(diffInDays)}`;
78
+ return `${date} (${duration})`;
593
79
  };
594
80
  // Annotate the CommonJS export names for ESM import in node:
595
81
  0 && (module.exports = {
596
- deleteCacheParams,
597
- findNextDuration,
598
- findNextSlice,
599
- flexibleObj,
600
- formatProductListByCategory,
601
- formatResource,
602
- formatTimes,
603
- getCacheParams,
604
- getDiscountTime,
605
- getDuration,
606
- getEndDate,
607
- getErrorList,
608
- getIsEdit,
609
- getLastServer,
610
- getNowTime,
611
- getProductTotalPrice,
612
- getResourceTimeIsUsable,
613
- getServeStartTime,
614
- getServerItemExtend,
82
+ formatMultiDayDate,
615
83
  getServiceTime,
616
- getServiceTimes,
617
- getShopOpeningHours,
618
- isNowTime,
619
- isWalkIn,
620
- request,
621
- sliceDayIntoFiveMinutes
84
+ isEn
622
85
  });
@@ -155,7 +155,7 @@ export declare const getSettingKeyArrByMode: ({ filter, columnSetting, dataSourc
155
155
  sort?: SortType | undefined;
156
156
  mode: "" | "localStorage" | "remote";
157
157
  currentViewMode: ModeType;
158
- }) => ("view_mode" | "column_setting" | "order_by" | "group_by" | "gallery_setting" | "filter_setting")[];
158
+ }) => ("filter_setting" | "column_setting" | "gallery_setting" | "view_mode" | "group_by" | "order_by")[];
159
159
  export declare const omit: (obj: Record<string, any>, keys: string[]) => Record<string, any>;
160
160
  export declare const stringify: (obj: Record<string, any>) => string;
161
161
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/materials",
3
- "version": "2.2.39",
3
+ "version": "2.2.41",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -63,9 +63,9 @@
63
63
  "react-virtualized-auto-sizer": "^1.0.20",
64
64
  "crypto-js": "^4.2.0",
65
65
  "@zxing/library": "0.21.2",
66
- "@pisell/utils": "2.0.1",
66
+ "@pisell/date-picker": "1.0.101",
67
67
  "@pisell/icon": "0.0.11",
68
- "@pisell/date-picker": "1.0.101"
68
+ "@pisell/utils": "2.0.1"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "react": "^18.0.0",
@@ -1,9 +0,0 @@
1
- /**
2
- * @title: 格式化导出导入接口地址
3
- * @description:
4
- * @param {string} url
5
- * @return {*}
6
- * @Author: WangHan
7
- * @Date: 2024-09-05 11:39
8
- */
9
- export declare const formatApiUrl: (url: string) => string;
@@ -1,11 +0,0 @@
1
- /**
2
- * @title: 格式化导出导入接口地址
3
- * @description:
4
- * @param {string} url
5
- * @return {*}
6
- * @Author: WangHan
7
- * @Date: 2024-09-05 11:39
8
- */
9
- export var formatApiUrl = function formatApiUrl(url) {
10
- return url || '/shop/form/data';
11
- };
@@ -1,9 +0,0 @@
1
- /**
2
- * @title: 格式化导出导入接口地址
3
- * @description:
4
- * @param {string} url
5
- * @return {*}
6
- * @Author: WangHan
7
- * @Date: 2024-09-05 11:39
8
- */
9
- export declare const formatApiUrl: (url: string) => string;