@pisell/pisellos 3.0.5 → 3.0.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 (146) hide show
  1. package/dist/modules/Account/index.d.ts +2 -6
  2. package/dist/modules/Account/index.js +21 -103
  3. package/dist/modules/Account/types.d.ts +12 -1
  4. package/dist/modules/AccountList/index.d.ts +20 -1
  5. package/dist/modules/AccountList/index.js +243 -75
  6. package/dist/modules/AccountList/types.d.ts +33 -1
  7. package/dist/modules/AccountList/types.js +8 -0
  8. package/dist/modules/AccountList/utils.d.ts +9 -0
  9. package/dist/modules/AccountList/utils.js +25 -0
  10. package/dist/modules/BaseModule.d.ts +2 -2
  11. package/dist/modules/BaseModule.js +1 -1
  12. package/dist/modules/Cart/index.d.ts +8 -5
  13. package/dist/modules/Cart/index.js +101 -25
  14. package/dist/modules/Cart/types.d.ts +82 -5
  15. package/dist/modules/Cart/types.js +22 -0
  16. package/dist/modules/Cart/utils.d.ts +106 -13
  17. package/dist/modules/Cart/utils.js +289 -76
  18. package/dist/modules/Date/index.d.ts +6 -6
  19. package/dist/modules/Date/index.js +41 -58
  20. package/dist/modules/Date/types.d.ts +22 -6
  21. package/dist/modules/Date/utils.d.ts +4 -3
  22. package/dist/modules/Date/utils.js +81 -30
  23. package/dist/modules/Discount/index.d.ts +4 -4
  24. package/dist/modules/Discount/index.js +11 -11
  25. package/dist/modules/Order/index.d.ts +11 -5
  26. package/dist/modules/Order/index.js +47 -18
  27. package/dist/modules/Order/types.d.ts +10 -3
  28. package/dist/modules/Order/utils.d.ts +10 -0
  29. package/dist/modules/Order/utils.js +15 -0
  30. package/dist/modules/Product/index.d.ts +14 -1
  31. package/dist/modules/Product/index.js +35 -0
  32. package/dist/modules/Product/types.d.ts +27 -3
  33. package/dist/modules/ProductList/index.js +11 -5
  34. package/dist/modules/Resource/types.d.ts +1 -0
  35. package/dist/modules/Resource/utils.js +1 -1
  36. package/dist/modules/Rules/index.d.ts +3 -3
  37. package/dist/modules/Rules/index.js +121 -53
  38. package/dist/modules/Rules/types.d.ts +5 -1
  39. package/dist/modules/Schedule/index.d.ts +18 -0
  40. package/dist/modules/Schedule/index.js +111 -0
  41. package/dist/modules/Schedule/type.d.ts +157 -0
  42. package/dist/modules/Schedule/type.js +1 -0
  43. package/dist/modules/Schedule/types.d.ts +182 -0
  44. package/dist/modules/Schedule/types.js +1 -0
  45. package/dist/modules/Schedule/utils.d.ts +67 -0
  46. package/dist/modules/Schedule/utils.js +729 -0
  47. package/dist/modules/Step/index.d.ts +14 -3
  48. package/dist/modules/Step/index.js +54 -2
  49. package/dist/modules/Summary/index.d.ts +12 -5
  50. package/dist/modules/Summary/index.js +33 -7
  51. package/dist/modules/Summary/types.d.ts +23 -2
  52. package/dist/modules/Summary/utils.d.ts +14 -4
  53. package/dist/modules/Summary/utils.js +46 -4
  54. package/dist/modules/index.d.ts +10 -0
  55. package/dist/modules/index.js +11 -1
  56. package/dist/plugins/index.d.ts +3 -3
  57. package/dist/plugins/request.d.ts +3 -3
  58. package/dist/plugins/request.js +30 -30
  59. package/dist/plugins/shopStore.d.ts +1 -1
  60. package/dist/solution/BookingByStep/index.d.ts +97 -24
  61. package/dist/solution/BookingByStep/index.js +1024 -322
  62. package/dist/solution/BookingByStep/types.d.ts +3 -10
  63. package/dist/solution/BookingByStep/types.js +11 -15
  64. package/dist/solution/BookingByStep/utils/products.d.ts +1 -1
  65. package/dist/solution/BookingByStep/utils/products.js +3 -0
  66. package/dist/solution/BookingByStep/utils/resources.d.ts +60 -6
  67. package/dist/solution/BookingByStep/utils/resources.js +293 -52
  68. package/dist/solution/ShopDiscount/index.d.ts +4 -4
  69. package/dist/solution/ShopDiscount/index.js +16 -16
  70. package/dist/solution/ShopDiscount/types.d.ts +2 -2
  71. package/dist/solution/ShopDiscount/utils.js +1 -1
  72. package/lib/core/index.js +7 -2
  73. package/lib/modules/Account/index.d.ts +2 -6
  74. package/lib/modules/Account/index.js +15 -30
  75. package/lib/modules/Account/types.d.ts +12 -1
  76. package/lib/modules/AccountList/index.d.ts +20 -1
  77. package/lib/modules/AccountList/index.js +122 -13
  78. package/lib/modules/AccountList/types.d.ts +33 -1
  79. package/lib/modules/AccountList/utils.d.ts +9 -0
  80. package/lib/modules/AccountList/utils.js +39 -0
  81. package/lib/modules/BaseModule.d.ts +2 -2
  82. package/lib/modules/BaseModule.js +14 -3
  83. package/lib/modules/Cart/index.d.ts +8 -5
  84. package/lib/modules/Cart/index.js +81 -8
  85. package/lib/modules/Cart/types.d.ts +82 -5
  86. package/lib/modules/Cart/types.js +20 -2
  87. package/lib/modules/Cart/utils.d.ts +106 -13
  88. package/lib/modules/Cart/utils.js +188 -45
  89. package/lib/modules/Date/index.d.ts +6 -6
  90. package/lib/modules/Date/index.js +13 -28
  91. package/lib/modules/Date/types.d.ts +22 -6
  92. package/lib/modules/Date/utils.d.ts +4 -3
  93. package/lib/modules/Date/utils.js +47 -13
  94. package/lib/modules/Discount/index.d.ts +4 -4
  95. package/lib/modules/Discount/index.js +9 -2
  96. package/lib/modules/Guests/index.js +4 -1
  97. package/lib/modules/Order/index.d.ts +11 -5
  98. package/lib/modules/Order/index.js +24 -3
  99. package/lib/modules/Order/types.d.ts +10 -3
  100. package/lib/modules/Order/utils.d.ts +10 -0
  101. package/lib/modules/Order/utils.js +45 -0
  102. package/lib/modules/Payment/index.js +1 -6
  103. package/lib/modules/Product/index.d.ts +14 -1
  104. package/lib/modules/Product/index.js +19 -0
  105. package/lib/modules/Product/types.d.ts +27 -3
  106. package/lib/modules/ProductList/index.js +21 -7
  107. package/lib/modules/Resource/index.js +4 -1
  108. package/lib/modules/Resource/types.d.ts +1 -0
  109. package/lib/modules/Resource/utils.js +7 -4
  110. package/lib/modules/Rules/index.d.ts +3 -3
  111. package/lib/modules/Rules/index.js +118 -43
  112. package/lib/modules/Rules/types.d.ts +5 -1
  113. package/lib/modules/Schedule/index.d.ts +18 -0
  114. package/lib/modules/Schedule/index.js +81 -0
  115. package/lib/modules/Schedule/type.d.ts +157 -0
  116. package/lib/modules/Schedule/type.js +17 -0
  117. package/lib/modules/Schedule/types.d.ts +182 -0
  118. package/lib/modules/Schedule/types.js +17 -0
  119. package/lib/modules/Schedule/utils.d.ts +67 -0
  120. package/lib/modules/Schedule/utils.js +600 -0
  121. package/lib/modules/Step/index.d.ts +14 -3
  122. package/lib/modules/Step/index.js +38 -1
  123. package/lib/modules/Summary/index.d.ts +12 -5
  124. package/lib/modules/Summary/index.js +15 -1
  125. package/lib/modules/Summary/types.d.ts +23 -2
  126. package/lib/modules/Summary/utils.d.ts +14 -4
  127. package/lib/modules/Summary/utils.js +30 -1
  128. package/lib/modules/index.d.ts +10 -0
  129. package/lib/modules/index.js +21 -1
  130. package/lib/plugins/index.d.ts +3 -3
  131. package/lib/plugins/request.d.ts +3 -3
  132. package/lib/plugins/request.js +48 -11
  133. package/lib/plugins/shopStore.d.ts +1 -1
  134. package/lib/solution/BookingByStep/index.d.ts +97 -24
  135. package/lib/solution/BookingByStep/index.js +693 -145
  136. package/lib/solution/BookingByStep/types.d.ts +3 -10
  137. package/lib/solution/BookingByStep/types.js +37 -14
  138. package/lib/solution/BookingByStep/utils/products.d.ts +1 -1
  139. package/lib/solution/BookingByStep/utils/products.js +3 -0
  140. package/lib/solution/BookingByStep/utils/resources.d.ts +60 -6
  141. package/lib/solution/BookingByStep/utils/resources.js +286 -54
  142. package/lib/solution/BuyTickets/index.js +34 -20
  143. package/lib/solution/ShopDiscount/index.d.ts +4 -4
  144. package/lib/solution/ShopDiscount/index.js +10 -2
  145. package/lib/solution/ShopDiscount/types.d.ts +2 -2
  146. package/package.json +4 -2
@@ -0,0 +1,600 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/modules/Schedule/utils.ts
30
+ var utils_exports = {};
31
+ __export(utils_exports, {
32
+ calcCalendarDataByDesignation: () => calcCalendarDataByDesignation,
33
+ calcCalendarDataBySchedule: () => calcCalendarDataBySchedule,
34
+ calcCalendarDataByScheduleResult: () => calcCalendarDataByScheduleResult,
35
+ calcCalendarDataBySchedules: () => calcCalendarDataBySchedules,
36
+ calcCalendarDataByStandard: () => calcCalendarDataByStandard,
37
+ calcCalendarDataByTimeSlots: () => calcCalendarDataByTimeSlots,
38
+ calcMinTimeMaxTimeBySchedules: () => calcMinTimeMaxTimeBySchedules,
39
+ calcScheduleDateRange: () => calcScheduleDateRange,
40
+ formatScheduleData: () => formatScheduleData,
41
+ formatScheduleResult: () => formatScheduleResult,
42
+ getAllSortedDateRanges: () => getAllSortedDateRanges,
43
+ getDaysByStartEnd: () => getDaysByStartEnd,
44
+ isAllDay: () => isAllDay
45
+ });
46
+ module.exports = __toCommonJS(utils_exports);
47
+ var import_dayjs = __toESM(require("dayjs"));
48
+ var calcCalendarDataBySchedule = (values, others, type) => {
49
+ if (type === "time-slots") {
50
+ return calcCalendarDataByTimeSlots(values, others);
51
+ }
52
+ if (type === "designation") {
53
+ return calcCalendarDataByDesignation(values, others);
54
+ }
55
+ return calcCalendarDataByStandard(values, others);
56
+ };
57
+ var getDaysByStartEnd = (startDate, endDate) => {
58
+ let start = (0, import_dayjs.default)(startDate);
59
+ const end = (0, import_dayjs.default)(endDate);
60
+ const daysArray = [];
61
+ while (start.isBefore(end, "day") || start.isSame(end, "day")) {
62
+ daysArray.push(start.format("YYYY-MM-DD"));
63
+ start = start.add(1, "day");
64
+ }
65
+ return daysArray;
66
+ };
67
+ var mergeDateTime = (date, time) => {
68
+ const dateStr = `${(0, import_dayjs.default)(date).format("YYYY-MM-DD")}${time ? (0, import_dayjs.default)(time).format(" HH:MM") : ""}`;
69
+ return (0, import_dayjs.default)(dateStr);
70
+ };
71
+ var getDataRange = ({
72
+ start,
73
+ end,
74
+ type,
75
+ time_slot
76
+ }) => {
77
+ if (type === "time-slots") {
78
+ let dateRange = [];
79
+ const dateStr = getDaysByStartEnd(start, end);
80
+ dateStr.forEach((str) => {
81
+ time_slot == null ? void 0 : time_slot.forEach((time) => {
82
+ dateRange.push({
83
+ start: `${str} ${time.start_time}`,
84
+ end: `${str} ${time.end_time}`
85
+ });
86
+ });
87
+ });
88
+ return dateRange;
89
+ }
90
+ return [
91
+ {
92
+ start: start.format("YYYY-MM-DD HH:mm:ss"),
93
+ end: end.format("YYYY-MM-DD HH:mm:ss")
94
+ }
95
+ ];
96
+ };
97
+ var getDaysByRepeatDay = (params, isGetRange) => {
98
+ const { start, end, deadline, frequency, type, time_slot, excludedDays } = params;
99
+ const scheduleDiff = end.diff(start, "second");
100
+ const excludedDaysMap = new Map(excludedDays.map((day) => [day, true]));
101
+ let startTmp = getMaxStart(start);
102
+ const daysArr = [];
103
+ while (startTmp.isBefore(deadline, "day") || startTmp.isSame(deadline, "day")) {
104
+ const e = startTmp.add(scheduleDiff, "second");
105
+ if (isGetRange) {
106
+ if (excludedDaysMap.has(startTmp.format("YYYY-MM-DD"))) {
107
+ startTmp = startTmp.add(frequency, "day");
108
+ continue;
109
+ }
110
+ const arr = getDataRange({
111
+ start: startTmp,
112
+ end: e,
113
+ type,
114
+ time_slot
115
+ });
116
+ daysArr.push(...arr);
117
+ } else {
118
+ daysArr.push(...getDaysByStartEnd(startTmp, e));
119
+ }
120
+ startTmp = startTmp.add(frequency, "day");
121
+ }
122
+ return Array.from(new Set(daysArr));
123
+ };
124
+ var getDaysByRepeatWeek = (params, isGetRange) => {
125
+ const {
126
+ start,
127
+ end,
128
+ deadline,
129
+ frequency,
130
+ frequency_date,
131
+ type,
132
+ time_slot,
133
+ excludedDays
134
+ } = params;
135
+ const scheduleDiff = end.diff(start, "second");
136
+ const excludedDaysMap = new Map(excludedDays.map((day) => [day, true]));
137
+ let startTmp = getMaxStart(start);
138
+ const daysArr = [];
139
+ while (startTmp.isBefore(deadline, "day") || startTmp.isSame(deadline, "day")) {
140
+ for (let i = 0; i < frequency_date.length; i++) {
141
+ const item = frequency_date[i];
142
+ const _start = startTmp.day(item);
143
+ const _end = _start.add(scheduleDiff, "second");
144
+ if (isGetRange) {
145
+ if (excludedDaysMap.has(_start.format("YYYY-MM-DD"))) {
146
+ startTmp = startTmp.day(1).add(frequency, "week");
147
+ continue;
148
+ }
149
+ const arr = getDataRange({
150
+ start: _start,
151
+ end: _end,
152
+ type,
153
+ time_slot
154
+ });
155
+ daysArr.push(...arr);
156
+ } else {
157
+ daysArr.push(...getDaysByStartEnd(_start, _end));
158
+ }
159
+ }
160
+ startTmp = startTmp.day(1).add(frequency, "week");
161
+ }
162
+ return Array.from(new Set(daysArr));
163
+ };
164
+ var formatDayColor = ({
165
+ days,
166
+ color,
167
+ excludedDays
168
+ }) => {
169
+ const excludedDaysSet = new Set(excludedDays);
170
+ return days.map((item) => ({
171
+ date: item,
172
+ color: [color],
173
+ isExcluded: excludedDaysSet.has(item)
174
+ }));
175
+ };
176
+ var getDaysByStartEndArr = (arr = []) => {
177
+ const daysArr = [];
178
+ arr.forEach((item) => {
179
+ if (item && item.start && item.end) {
180
+ daysArr.push(...getDaysByStartEnd(item.start, item.end));
181
+ }
182
+ });
183
+ return Array.from(new Set(daysArr));
184
+ };
185
+ var processDateRange = ({
186
+ repeat_type,
187
+ start,
188
+ end,
189
+ color,
190
+ endRadio,
191
+ end_date,
192
+ excluded_date,
193
+ included_date,
194
+ frequency,
195
+ excludedStatus,
196
+ includeStatus,
197
+ frequency_date,
198
+ type,
199
+ time_slot
200
+ }, isGetRange) => {
201
+ let days = [];
202
+ const excludedDays = getDaysByStartEndArr(excluded_date);
203
+ const includedDays = getDaysByStartEndArr(included_date);
204
+ if (repeat_type === "0") {
205
+ if (isGetRange) {
206
+ if (type === "time-slots") {
207
+ days = (time_slot == null ? void 0 : time_slot.map((item) => ({
208
+ start: start.format(`YYYY-MM-DD ${item.start_time}`),
209
+ end: end.format(`YYYY-MM-DD ${item.end_time}`)
210
+ }))) || [];
211
+ } else {
212
+ days = [
213
+ {
214
+ start: start.format("YYYY-MM-DD HH:mm:ss"),
215
+ end: end.format("YYYY-MM-DD HH:mm:ss")
216
+ }
217
+ ];
218
+ }
219
+ } else {
220
+ days = getDaysByStartEnd(start, end);
221
+ }
222
+ } else {
223
+ let endDate = (0, import_dayjs.default)(end_date);
224
+ if (endRadio === 1) {
225
+ endDate = isGetRange ? (0, import_dayjs.default)().add(12, "month") : (0, import_dayjs.default)().add(18, "month");
226
+ }
227
+ if (repeat_type === "1") {
228
+ days = getDaysByRepeatDay(
229
+ {
230
+ start,
231
+ end,
232
+ deadline: endDate,
233
+ frequency,
234
+ type,
235
+ time_slot,
236
+ excludedDays
237
+ },
238
+ isGetRange
239
+ );
240
+ } else if (repeat_type === "2") {
241
+ days = getDaysByRepeatWeek(
242
+ {
243
+ start,
244
+ end,
245
+ deadline: endDate,
246
+ frequency,
247
+ frequency_date,
248
+ type,
249
+ time_slot,
250
+ excludedDays
251
+ },
252
+ isGetRange
253
+ );
254
+ }
255
+ }
256
+ if (isGetRange) {
257
+ if (includedDays.length) {
258
+ for (let i = 0; i < includedDays.length; i++) {
259
+ const includedDay = includedDays[i];
260
+ days.push(
261
+ ...getDataRange({
262
+ start: (0, import_dayjs.default)(includedDay),
263
+ end: (0, import_dayjs.default)(includedDay),
264
+ type,
265
+ time_slot
266
+ })
267
+ );
268
+ }
269
+ }
270
+ return days;
271
+ }
272
+ if (includeStatus) {
273
+ days = days.concat(includedDays);
274
+ }
275
+ return formatDayColor({
276
+ days,
277
+ color,
278
+ excludedDays: excludedStatus ? excludedDays : []
279
+ });
280
+ };
281
+ var calcCalendarDataByStandard = (values, others, isGetRange) => {
282
+ const {
283
+ color,
284
+ excluded_date,
285
+ included_date,
286
+ end_date,
287
+ designation,
288
+ repeat_type,
289
+ frequency = 1,
290
+ frequency_date = [],
291
+ time_slot,
292
+ start_time,
293
+ end_time
294
+ } = values;
295
+ const { endRadio, isAllDay: isAllDay2, includeStatus, excludedStatus } = others;
296
+ if (Array.isArray(designation)) {
297
+ return [];
298
+ }
299
+ const start = designation ? mergeDateTime(
300
+ designation.start_date,
301
+ isAllDay2 ? designation.start_time : ""
302
+ ) : (0, import_dayjs.default)(start_time);
303
+ const end = designation ? mergeDateTime(designation.end_date, isAllDay2 ? designation.end_time : "") : (0, import_dayjs.default)(end_time);
304
+ return processDateRange(
305
+ {
306
+ repeat_type,
307
+ start,
308
+ end,
309
+ color,
310
+ endRadio,
311
+ end_date,
312
+ excluded_date,
313
+ excludedStatus,
314
+ frequency,
315
+ frequency_date,
316
+ included_date,
317
+ includeStatus,
318
+ time_slot,
319
+ type: "standard"
320
+ },
321
+ isGetRange
322
+ );
323
+ };
324
+ var getMaxStart = (start_time) => {
325
+ const valueStart = (0, import_dayjs.default)(start_time);
326
+ const currentYearStart = (0, import_dayjs.default)().startOf("year").set("hour", valueStart.get("hour")).set("minute", valueStart.get("minutes")).set("second", valueStart.get("second"));
327
+ const start = valueStart.isBefore(currentYearStart) ? currentYearStart : valueStart;
328
+ return start;
329
+ };
330
+ var calcCalendarDataByTimeSlots = (values, others, isGetRange) => {
331
+ const {
332
+ color,
333
+ excluded_date,
334
+ included_date,
335
+ end_date,
336
+ repeat_type,
337
+ frequency = 1,
338
+ frequency_date = [],
339
+ start_time,
340
+ time_slot
341
+ } = values;
342
+ const { endRadio, excludedStatus, includeStatus } = others;
343
+ if (!start_time)
344
+ return [];
345
+ const start = (0, import_dayjs.default)(start_time);
346
+ const end = (0, import_dayjs.default)(start_time);
347
+ return processDateRange(
348
+ {
349
+ repeat_type,
350
+ start,
351
+ end,
352
+ color,
353
+ endRadio,
354
+ end_date,
355
+ excluded_date,
356
+ excludedStatus,
357
+ frequency,
358
+ frequency_date,
359
+ included_date,
360
+ includeStatus,
361
+ time_slot,
362
+ type: "time-slots"
363
+ },
364
+ isGetRange
365
+ );
366
+ };
367
+ var calcCalendarDataByDesignation = (values, others, isGetRange) => {
368
+ const { designation, color } = values;
369
+ const days = [];
370
+ if (Array.isArray(designation)) {
371
+ designation.forEach((item) => {
372
+ const start = mergeDateTime(item.start_date, item.start_time);
373
+ const end = mergeDateTime(item.end_date, item.end_time);
374
+ if (isGetRange) {
375
+ days.push({
376
+ start: `${item.start_date} ${item.start_time}`,
377
+ end: `${item.end_date} ${item.end_time}`
378
+ });
379
+ } else {
380
+ days.push(...getDaysByStartEnd(start, end));
381
+ }
382
+ });
383
+ }
384
+ if (isGetRange) {
385
+ return days;
386
+ }
387
+ return formatDayColor({
388
+ days,
389
+ color,
390
+ excludedDays: []
391
+ });
392
+ };
393
+ var isAllDay = (value) => {
394
+ return (0, import_dayjs.default)(value.start_time).format("HH:mm:ss") === "00:00:00" && (0, import_dayjs.default)(value.end_time).format("HH:mm:ss") === "23:59:59";
395
+ };
396
+ var repeatTypeMap = {
397
+ none: "0",
398
+ daily: "1",
399
+ weekly: "2"
400
+ };
401
+ var endTypeMap = {
402
+ never: 1,
403
+ date: 2
404
+ };
405
+ var calcCalendarDataByScheduleResult = (schedule) => {
406
+ const { scheduleFormData, scheduleFormOtherValue } = formatScheduleResult(schedule);
407
+ return calcCalendarDataBySchedule(
408
+ scheduleFormData,
409
+ scheduleFormOtherValue,
410
+ schedule.type
411
+ );
412
+ };
413
+ var formatScheduleResult = (schedule) => {
414
+ const {
415
+ color,
416
+ name,
417
+ repeat_type,
418
+ designation,
419
+ repeat_rule,
420
+ start_time,
421
+ end_time,
422
+ is_all,
423
+ type,
424
+ time_slot
425
+ } = schedule;
426
+ const { frequency, end, frequency_date, included_date, excluded_date } = repeat_rule || {};
427
+ return {
428
+ scheduleFormData: {
429
+ color,
430
+ name,
431
+ repeat_type: repeatTypeMap[repeat_type],
432
+ designation,
433
+ frequency,
434
+ frequency_date,
435
+ end_time,
436
+ start_time,
437
+ excluded_date,
438
+ included_date,
439
+ time_slot,
440
+ end_date: end == null ? void 0 : end.end_date
441
+ },
442
+ scheduleFormOtherValue: {
443
+ endRadio: endTypeMap[(end == null ? void 0 : end.type) || "never"],
444
+ isAllDay: !!is_all,
445
+ type,
446
+ excludedStatus: !!(excluded_date == null ? void 0 : excluded_date.length),
447
+ includeStatus: !!(included_date == null ? void 0 : included_date.length)
448
+ }
449
+ };
450
+ };
451
+ var calcScheduleDateRange = (schedule) => {
452
+ const { scheduleFormData, scheduleFormOtherValue } = formatScheduleResult(schedule);
453
+ if (schedule.type === "time-slots") {
454
+ return calcCalendarDataByTimeSlots(
455
+ scheduleFormData,
456
+ scheduleFormOtherValue,
457
+ true
458
+ );
459
+ }
460
+ if (schedule.type === "designation") {
461
+ return calcCalendarDataByDesignation(
462
+ scheduleFormData,
463
+ scheduleFormOtherValue,
464
+ true
465
+ );
466
+ }
467
+ return calcCalendarDataByStandard(
468
+ scheduleFormData,
469
+ scheduleFormOtherValue,
470
+ true
471
+ );
472
+ };
473
+ var calcCalendarDataBySchedules = (schedules) => {
474
+ const allSchedules = [];
475
+ schedules.forEach((item) => {
476
+ allSchedules.push(...calcCalendarDataByScheduleResult(item));
477
+ });
478
+ const dateMap = allSchedules.reduce((pre, cur) => {
479
+ var _a, _b;
480
+ return {
481
+ ...pre,
482
+ [cur.date]: {
483
+ ...cur,
484
+ color: [...((_a = pre[cur.date]) == null ? void 0 : _a.color) || [], ...cur.color],
485
+ isExcluded: ((_b = pre[cur.date]) == null ? void 0 : _b.isExcluded) || cur.isExcluded
486
+ }
487
+ };
488
+ }, {});
489
+ return Object.values(dateMap);
490
+ };
491
+ var calcMinTimeMaxTimeBySchedules = (schedules, scheduleAllMap, selectDate) => {
492
+ return schedules.reduce((pre, cur) => {
493
+ var _a;
494
+ let dateRange = ((_a = scheduleAllMap == null ? void 0 : scheduleAllMap[cur.id]) == null ? void 0 : _a.dateRange) || calcScheduleDateRange(cur);
495
+ let dateRangeFormat = [];
496
+ if (selectDate) {
497
+ const dateRangeTmp = [];
498
+ const dateRangeFormatTmp = [];
499
+ for (let i = 0; i < dateRange.length; i++) {
500
+ const range = dateRange[i];
501
+ const start = (0, import_dayjs.default)(range.start);
502
+ const end = (0, import_dayjs.default)(range.end);
503
+ const isSameStart = range.start.includes(selectDate);
504
+ const isSameEnd = range.end.includes(selectDate);
505
+ if (isSameStart || isSameEnd) {
506
+ dateRangeTmp.push(range);
507
+ if (isSameStart && !isSameEnd) {
508
+ dateRangeFormatTmp.push({
509
+ start: range.start,
510
+ end: end.format("YYYY-MM-DD 23:59:59")
511
+ });
512
+ } else if (!isSameStart && isSameEnd) {
513
+ dateRangeFormatTmp.push({
514
+ start: start.format("YYYY-MM-DD 00:00:00"),
515
+ end: range.end
516
+ });
517
+ } else {
518
+ dateRangeFormatTmp.push(range);
519
+ }
520
+ }
521
+ }
522
+ dateRange = dateRangeTmp;
523
+ dateRangeFormat = dateRangeFormatTmp;
524
+ }
525
+ let minTime = null;
526
+ let maxTime = null;
527
+ if (dateRange.length) {
528
+ minTime = (0, import_dayjs.default)(dateRange[0].start);
529
+ maxTime = (0, import_dayjs.default)(dateRange[dateRange.length - 1].end);
530
+ }
531
+ return {
532
+ ...pre,
533
+ [cur.id]: {
534
+ minTime,
535
+ maxTime,
536
+ minTimeStr: (minTime == null ? void 0 : minTime.format("YYYY-MM-DD HH:mm:ss")) || null,
537
+ maxTimeStr: (maxTime == null ? void 0 : maxTime.format("YYYY-MM-DD HH:mm:ss")) || null,
538
+ dateRange,
539
+ dateRangeFormat
540
+ }
541
+ };
542
+ }, {});
543
+ };
544
+ var formatScheduleData = (relation, table_type, item_type, isExcluded) => {
545
+ const _relation = relation || [];
546
+ if (table_type && item_type && isExcluded) {
547
+ return _relation.find(
548
+ (item) => (item == null ? void 0 : item.relation_table_type) === table_type && (item == null ? void 0 : item.item_type) !== item_type
549
+ );
550
+ }
551
+ if (table_type && item_type) {
552
+ return _relation.find(
553
+ (item) => (item == null ? void 0 : item.relation_table_type) === table_type && (item == null ? void 0 : item.item_type) === item_type
554
+ );
555
+ }
556
+ if (table_type) {
557
+ return _relation.some(
558
+ (item) => (item == null ? void 0 : item.relation_table_type) === table_type
559
+ );
560
+ }
561
+ if (item_type) {
562
+ return _relation.find((item) => (item == null ? void 0 : item.item_type) === item_type);
563
+ }
564
+ };
565
+ function getAllSortedDateRanges(schedules) {
566
+ const allDateRanges = [];
567
+ Object.values(schedules).forEach((schedule) => {
568
+ if (schedule.dateRange && Array.isArray(schedule.dateRange)) {
569
+ allDateRanges.push(...schedule.dateRange);
570
+ }
571
+ });
572
+ if (allDateRanges.length === 0) {
573
+ console.log("No dateRanges found in schedules:", schedules);
574
+ return [];
575
+ }
576
+ return allDateRanges.sort((a, b) => {
577
+ const startTimeCompare = (0, import_dayjs.default)(a.start).valueOf() - (0, import_dayjs.default)(b.start).valueOf();
578
+ if (startTimeCompare !== 0)
579
+ return startTimeCompare;
580
+ const durationA = (0, import_dayjs.default)(a.end).valueOf() - (0, import_dayjs.default)(a.start).valueOf();
581
+ const durationB = (0, import_dayjs.default)(b.end).valueOf() - (0, import_dayjs.default)(b.start).valueOf();
582
+ return durationA - durationB;
583
+ });
584
+ }
585
+ // Annotate the CommonJS export names for ESM import in node:
586
+ 0 && (module.exports = {
587
+ calcCalendarDataByDesignation,
588
+ calcCalendarDataBySchedule,
589
+ calcCalendarDataByScheduleResult,
590
+ calcCalendarDataBySchedules,
591
+ calcCalendarDataByStandard,
592
+ calcCalendarDataByTimeSlots,
593
+ calcMinTimeMaxTimeBySchedules,
594
+ calcScheduleDateRange,
595
+ formatScheduleData,
596
+ formatScheduleResult,
597
+ getAllSortedDateRanges,
598
+ getDaysByStartEnd,
599
+ isAllDay
600
+ });
@@ -1,6 +1,6 @@
1
- import { Module, PisellCore, ModuleOptions } from "../../types";
2
- import { BaseModule } from "../BaseModule";
3
- import { IStep, IStepModuleAPI } from "./tyeps";
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { IStep, IStepModuleAPI } from './tyeps';
4
4
  export declare class StepModule extends BaseModule implements Module, IStepModuleAPI {
5
5
  protected defaultName: string;
6
6
  protected defaultVersion: string;
@@ -19,5 +19,16 @@ export declare class StepModule extends BaseModule implements Module, IStepModul
19
19
  prevStep(): void;
20
20
  nextStep(): void;
21
21
  gotoStep(stepIndex: number): void;
22
+ /**
23
+ * 添加步骤
24
+ * @param step 步骤
25
+ * @param key 步骤的 key,如果存在则插入到该步骤之后,否则插入到当前步骤之后
26
+ */
27
+ addStep(step: IStep, key?: string): void;
28
+ /**
29
+ * 删除步骤
30
+ * @param key 步骤的 key
31
+ */
32
+ removeStep(key: string): void;
22
33
  storeChange(): void;
23
34
  }
@@ -83,9 +83,46 @@ var StepModule = class extends import_BaseModule.BaseModule {
83
83
  gotoStep(stepIndex) {
84
84
  this.setCurrentStep(stepIndex);
85
85
  }
86
+ /**
87
+ * 添加步骤
88
+ * @param step 步骤
89
+ * @param key 步骤的 key,如果存在则插入到该步骤之后,否则插入到当前步骤之后
90
+ */
91
+ addStep(step, key) {
92
+ let stepList = this.store.stepList;
93
+ const index = stepList.findIndex((n) => n.key === step.key);
94
+ if (index !== -1) {
95
+ console.log("[StepModule] 步骤已存在,添加失败");
96
+ return;
97
+ }
98
+ if (key) {
99
+ const index2 = this.store.stepList.findIndex((n) => n.key === key);
100
+ if (index2 !== -1) {
101
+ stepList.splice(index2 + 1, 0, step);
102
+ } else {
103
+ stepList = [...stepList, step];
104
+ }
105
+ } else {
106
+ stepList.splice(this.store.currentStepIndex + 1, 0, step);
107
+ }
108
+ this.store.stepList = [...stepList];
109
+ }
110
+ /**
111
+ * 删除步骤
112
+ * @param key 步骤的 key
113
+ */
114
+ removeStep(key) {
115
+ const newStepList = this.store.stepList.filter((n) => n.key !== key);
116
+ this.store.stepList = [...newStepList];
117
+ }
86
118
  storeChange() {
87
119
  if (this.openCache) {
88
- this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["currentStepIndex", "currentStep", "stepList"] });
120
+ this.checkSaveCache({
121
+ cacheId: this.cacheId,
122
+ fatherModule: this.fatherModule,
123
+ store: this.store,
124
+ cacheKey: ["currentStepIndex", "currentStep", "stepList"]
125
+ });
89
126
  }
90
127
  }
91
128
  };
@@ -1,17 +1,24 @@
1
- import { Module, PisellCore, ModuleOptions } from "../../types";
2
- import { BaseModule } from "../BaseModule";
3
- import { CartItem } from "../Cart/types";
4
- import { ISummaryState, ISummaryModuleAPI } from "./types";
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { CartItem } from '../Cart/types';
4
+ import { ISummaryState, ISummaryModuleAPI } from './types';
5
5
  export declare class SummaryModule extends BaseModule implements Module, ISummaryModuleAPI {
6
6
  protected defaultName: string;
7
7
  protected defaultVersion: string;
8
8
  private shopStore;
9
9
  private store;
10
+ private request;
10
11
  private cacheId;
11
12
  private openCache;
12
13
  private fatherModule;
13
14
  constructor(name?: string, version?: string);
14
15
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
15
- getSummary(cartItems: CartItem[]): Promise<ISummaryState["summary"]>;
16
+ getSummary(cartItems: CartItem[]): Promise<ISummaryState['summary']>;
17
+ /**
18
+ * 获取协议
19
+ * @param protocolId 协议ID
20
+ * @returns 协议
21
+ */
22
+ getProtocol(protocolId: string): Promise<any>;
16
23
  storeChange(): void;
17
24
  }