@pisell/pisellos 0.0.37 → 2.0.1

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 (47) hide show
  1. package/dist/modules/Cart/types.d.ts +0 -4
  2. package/dist/modules/Cart/utils.d.ts +0 -1
  3. package/dist/modules/Cart/utils.js +12 -23
  4. package/dist/modules/Product/index.d.ts +0 -10
  5. package/dist/modules/Product/index.js +0 -13
  6. package/dist/modules/Product/types.d.ts +0 -4
  7. package/dist/modules/Resource/types.d.ts +0 -1
  8. package/dist/modules/index.d.ts +0 -9
  9. package/dist/modules/index.js +1 -10
  10. package/dist/solution/BookingByStep/index.d.ts +5 -14
  11. package/dist/solution/BookingByStep/index.js +163 -284
  12. package/dist/solution/BookingByStep/types.d.ts +10 -2
  13. package/dist/solution/BookingByStep/types.js +7 -1
  14. package/dist/solution/BookingByStep/utils/resources.d.ts +4 -45
  15. package/dist/solution/BookingByStep/utils/resources.js +32 -153
  16. package/lib/modules/Cart/types.d.ts +0 -4
  17. package/lib/modules/Cart/utils.d.ts +0 -1
  18. package/lib/modules/Cart/utils.js +12 -24
  19. package/lib/modules/Product/index.d.ts +0 -10
  20. package/lib/modules/Product/index.js +0 -3
  21. package/lib/modules/Product/types.d.ts +0 -4
  22. package/lib/modules/Resource/types.d.ts +0 -1
  23. package/lib/modules/index.d.ts +0 -9
  24. package/lib/modules/index.js +1 -19
  25. package/lib/solution/BookingByStep/index.d.ts +5 -14
  26. package/lib/solution/BookingByStep/index.js +35 -84
  27. package/lib/solution/BookingByStep/types.d.ts +10 -2
  28. package/lib/solution/BookingByStep/types.js +12 -6
  29. package/lib/solution/BookingByStep/utils/resources.d.ts +4 -45
  30. package/lib/solution/BookingByStep/utils/resources.js +24 -101
  31. package/package.json +2 -2
  32. package/dist/modules/Schedule/index.d.ts +0 -10
  33. package/dist/modules/Schedule/index.js +0 -56
  34. package/dist/modules/Schedule/type.d.ts +0 -157
  35. package/dist/modules/Schedule/type.js +0 -1
  36. package/dist/modules/Schedule/types.d.ts +0 -177
  37. package/dist/modules/Schedule/types.js +0 -1
  38. package/dist/modules/Schedule/utils.d.ts +0 -61
  39. package/dist/modules/Schedule/utils.js +0 -700
  40. package/lib/modules/Schedule/index.d.ts +0 -10
  41. package/lib/modules/Schedule/index.js +0 -41
  42. package/lib/modules/Schedule/type.d.ts +0 -157
  43. package/lib/modules/Schedule/type.js +0 -17
  44. package/lib/modules/Schedule/types.d.ts +0 -177
  45. package/lib/modules/Schedule/types.js +0 -17
  46. package/lib/modules/Schedule/utils.d.ts +0 -61
  47. package/lib/modules/Schedule/utils.js +0 -572
@@ -1,572 +0,0 @@
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
- getDaysByStartEnd: () => getDaysByStartEnd,
43
- isAllDay: () => isAllDay
44
- });
45
- module.exports = __toCommonJS(utils_exports);
46
- var import_dayjs = __toESM(require("dayjs"));
47
- var calcCalendarDataBySchedule = (values, others, type) => {
48
- if (type === "time-slots") {
49
- return calcCalendarDataByTimeSlots(values, others);
50
- }
51
- if (type === "designation") {
52
- return calcCalendarDataByDesignation(values, others);
53
- }
54
- return calcCalendarDataByStandard(values, others);
55
- };
56
- var getDaysByStartEnd = (startDate, endDate) => {
57
- let start = (0, import_dayjs.default)(startDate);
58
- const end = (0, import_dayjs.default)(endDate);
59
- const daysArray = [];
60
- while (start.isBefore(end, "day") || start.isSame(end, "day")) {
61
- daysArray.push(start.format("YYYY-MM-DD"));
62
- start = start.add(1, "day");
63
- }
64
- return daysArray;
65
- };
66
- var mergeDateTime = (date, time) => {
67
- const dateStr = `${(0, import_dayjs.default)(date).format("YYYY-MM-DD")}${time ? (0, import_dayjs.default)(time).format(" HH:MM") : ""}`;
68
- return (0, import_dayjs.default)(dateStr);
69
- };
70
- var getDataRange = ({
71
- start,
72
- end,
73
- type,
74
- time_slot
75
- }) => {
76
- if (type === "time-slots") {
77
- let dateRange = [];
78
- const dateStr = getDaysByStartEnd(start, end);
79
- dateStr.forEach((str) => {
80
- time_slot == null ? void 0 : time_slot.forEach((time) => {
81
- dateRange.push({
82
- start: `${str} ${time.start_time}`,
83
- end: `${str} ${time.end_time}`
84
- });
85
- });
86
- });
87
- return dateRange;
88
- }
89
- return [
90
- {
91
- start: start.format("YYYY-MM-DD HH:mm:ss"),
92
- end: end.format("YYYY-MM-DD HH:mm:ss")
93
- }
94
- ];
95
- };
96
- var getDaysByRepeatDay = (params, isGetRange) => {
97
- const { start, end, deadline, frequency, type, time_slot, excludedDays } = params;
98
- const scheduleDiff = end.diff(start, "second");
99
- const excludedDaysMap = new Map(excludedDays.map((day) => [day, true]));
100
- let startTmp = getMaxStart(start);
101
- const daysArr = [];
102
- while (startTmp.isBefore(deadline, "day") || startTmp.isSame(deadline, "day")) {
103
- const e = startTmp.add(scheduleDiff, "second");
104
- if (isGetRange) {
105
- if (excludedDaysMap.has(startTmp.format("YYYY-MM-DD"))) {
106
- startTmp = startTmp.add(frequency, "day");
107
- continue;
108
- }
109
- const arr = getDataRange({
110
- start: startTmp,
111
- end: e,
112
- type,
113
- time_slot
114
- });
115
- daysArr.push(...arr);
116
- } else {
117
- daysArr.push(...getDaysByStartEnd(startTmp, e));
118
- }
119
- startTmp = startTmp.add(frequency, "day");
120
- }
121
- return Array.from(new Set(daysArr));
122
- };
123
- var getDaysByRepeatWeek = (params, isGetRange) => {
124
- const {
125
- start,
126
- end,
127
- deadline,
128
- frequency,
129
- frequency_date,
130
- type,
131
- time_slot,
132
- excludedDays
133
- } = params;
134
- const scheduleDiff = end.diff(start, "second");
135
- const excludedDaysMap = new Map(excludedDays.map((day) => [day, true]));
136
- let startTmp = getMaxStart(start);
137
- const daysArr = [];
138
- while (startTmp.isBefore(deadline, "day") || startTmp.isSame(deadline, "day")) {
139
- for (let i = 0; i < frequency_date.length; i++) {
140
- const item = frequency_date[i];
141
- const _start = startTmp.day(item);
142
- const _end = _start.add(scheduleDiff, "second");
143
- if (isGetRange) {
144
- if (excludedDaysMap.has(_start.format("YYYY-MM-DD"))) {
145
- startTmp = startTmp.day(1).add(frequency, "week");
146
- continue;
147
- }
148
- const arr = getDataRange({
149
- start: _start,
150
- end: _end,
151
- type,
152
- time_slot
153
- });
154
- daysArr.push(...arr);
155
- } else {
156
- daysArr.push(...getDaysByStartEnd(_start, _end));
157
- }
158
- }
159
- startTmp = startTmp.day(1).add(frequency, "week");
160
- }
161
- return Array.from(new Set(daysArr));
162
- };
163
- var formatDayColor = ({
164
- days,
165
- color,
166
- excludedDays
167
- }) => {
168
- const excludedDaysSet = new Set(excludedDays);
169
- return days.map((item) => ({
170
- date: item,
171
- color: [color],
172
- isExcluded: excludedDaysSet.has(item)
173
- }));
174
- };
175
- var getDaysByStartEndArr = (arr = []) => {
176
- const daysArr = [];
177
- arr.forEach((item) => {
178
- if (item && item.start && item.end) {
179
- daysArr.push(...getDaysByStartEnd(item.start, item.end));
180
- }
181
- });
182
- return Array.from(new Set(daysArr));
183
- };
184
- var processDateRange = ({
185
- repeat_type,
186
- start,
187
- end,
188
- color,
189
- endRadio,
190
- end_date,
191
- excluded_date,
192
- included_date,
193
- frequency,
194
- excludedStatus,
195
- includeStatus,
196
- frequency_date,
197
- type,
198
- time_slot
199
- }, isGetRange) => {
200
- let days = [];
201
- const excludedDays = getDaysByStartEndArr(excluded_date);
202
- const includedDays = getDaysByStartEndArr(included_date);
203
- if (repeat_type === "0") {
204
- if (isGetRange) {
205
- if (type === "time-slots") {
206
- days = (time_slot == null ? void 0 : time_slot.map((item) => ({
207
- start: start.format(`YYYY-MM-DD ${item.start_time}`),
208
- end: end.format(`YYYY-MM-DD ${item.end_time}`)
209
- }))) || [];
210
- } else {
211
- days = [
212
- {
213
- start: start.format("YYYY-MM-DD HH:mm:ss"),
214
- end: end.format("YYYY-MM-DD HH:mm:ss")
215
- }
216
- ];
217
- }
218
- } else {
219
- days = getDaysByStartEnd(start, end);
220
- }
221
- } else {
222
- let endDate = (0, import_dayjs.default)(end_date);
223
- if (endRadio === 1) {
224
- endDate = isGetRange ? (0, import_dayjs.default)().add(12, "month") : (0, import_dayjs.default)().add(18, "month");
225
- }
226
- if (repeat_type === "1") {
227
- days = getDaysByRepeatDay(
228
- {
229
- start,
230
- end,
231
- deadline: endDate,
232
- frequency,
233
- type,
234
- time_slot,
235
- excludedDays
236
- },
237
- isGetRange
238
- );
239
- } else if (repeat_type === "2") {
240
- days = getDaysByRepeatWeek(
241
- {
242
- start,
243
- end,
244
- deadline: endDate,
245
- frequency,
246
- frequency_date,
247
- type,
248
- time_slot,
249
- excludedDays
250
- },
251
- isGetRange
252
- );
253
- }
254
- }
255
- if (isGetRange) {
256
- if (includedDays.length) {
257
- for (let i = 0; i < includedDays.length; i++) {
258
- const includedDay = includedDays[i];
259
- days.push(
260
- ...getDataRange({
261
- start: (0, import_dayjs.default)(includedDay),
262
- end: (0, import_dayjs.default)(includedDay),
263
- type,
264
- time_slot
265
- })
266
- );
267
- }
268
- }
269
- return days;
270
- }
271
- if (includeStatus) {
272
- days = days.concat(includedDays);
273
- }
274
- return formatDayColor({
275
- days,
276
- color,
277
- excludedDays: excludedStatus ? excludedDays : []
278
- });
279
- };
280
- var calcCalendarDataByStandard = (values, others, isGetRange) => {
281
- const {
282
- color,
283
- excluded_date,
284
- included_date,
285
- end_date,
286
- designation,
287
- repeat_type,
288
- frequency = 1,
289
- frequency_date = [],
290
- time_slot,
291
- start_time,
292
- end_time
293
- } = values;
294
- const { endRadio, isAllDay: isAllDay2, includeStatus, excludedStatus } = others;
295
- if (Array.isArray(designation)) {
296
- return [];
297
- }
298
- const start = designation ? mergeDateTime(
299
- designation.start_date,
300
- isAllDay2 ? designation.start_time : ""
301
- ) : (0, import_dayjs.default)(start_time);
302
- const end = designation ? mergeDateTime(designation.end_date, isAllDay2 ? designation.end_time : "") : (0, import_dayjs.default)(end_time);
303
- return processDateRange(
304
- {
305
- repeat_type,
306
- start,
307
- end,
308
- color,
309
- endRadio,
310
- end_date,
311
- excluded_date,
312
- excludedStatus,
313
- frequency,
314
- frequency_date,
315
- included_date,
316
- includeStatus,
317
- time_slot,
318
- type: "standard"
319
- },
320
- isGetRange
321
- );
322
- };
323
- var getMaxStart = (start_time) => {
324
- const valueStart = (0, import_dayjs.default)(start_time);
325
- const currentYearStart = (0, import_dayjs.default)().startOf("year").set("hour", valueStart.get("hour")).set("minute", valueStart.get("minutes")).set("second", valueStart.get("second"));
326
- const start = valueStart.isBefore(currentYearStart) ? currentYearStart : valueStart;
327
- return start;
328
- };
329
- var calcCalendarDataByTimeSlots = (values, others, isGetRange) => {
330
- const {
331
- color,
332
- excluded_date,
333
- included_date,
334
- end_date,
335
- repeat_type,
336
- frequency = 1,
337
- frequency_date = [],
338
- start_time,
339
- time_slot
340
- } = values;
341
- const { endRadio, excludedStatus, includeStatus } = others;
342
- if (!start_time)
343
- return [];
344
- const start = (0, import_dayjs.default)(start_time);
345
- const end = (0, import_dayjs.default)(start_time);
346
- return processDateRange(
347
- {
348
- repeat_type,
349
- start,
350
- end,
351
- color,
352
- endRadio,
353
- end_date,
354
- excluded_date,
355
- excludedStatus,
356
- frequency,
357
- frequency_date,
358
- included_date,
359
- includeStatus,
360
- time_slot,
361
- type: "time-slots"
362
- },
363
- isGetRange
364
- );
365
- };
366
- var calcCalendarDataByDesignation = (values, others, isGetRange) => {
367
- const { designation, color } = values;
368
- const days = [];
369
- if (Array.isArray(designation)) {
370
- designation.forEach((item) => {
371
- const start = mergeDateTime(item.start_date, item.start_time);
372
- const end = mergeDateTime(item.end_date, item.end_time);
373
- if (isGetRange) {
374
- days.push({
375
- start: `${item.start_date} ${item.start_time}`,
376
- end: `${item.end_date} ${item.end_time}`
377
- });
378
- } else {
379
- days.push(...getDaysByStartEnd(start, end));
380
- }
381
- });
382
- }
383
- if (isGetRange) {
384
- return days;
385
- }
386
- return formatDayColor({
387
- days,
388
- color,
389
- excludedDays: []
390
- });
391
- };
392
- var isAllDay = (value) => {
393
- 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";
394
- };
395
- var repeatTypeMap = {
396
- none: "0",
397
- daily: "1",
398
- weekly: "2"
399
- };
400
- var endTypeMap = {
401
- never: 1,
402
- date: 2
403
- };
404
- var calcCalendarDataByScheduleResult = (schedule) => {
405
- const { scheduleFormData, scheduleFormOtherValue } = formatScheduleResult(schedule);
406
- return calcCalendarDataBySchedule(
407
- scheduleFormData,
408
- scheduleFormOtherValue,
409
- schedule.type
410
- );
411
- };
412
- var formatScheduleResult = (schedule) => {
413
- const {
414
- color,
415
- name,
416
- repeat_type,
417
- designation,
418
- repeat_rule,
419
- start_time,
420
- end_time,
421
- is_all,
422
- type,
423
- time_slot
424
- } = schedule;
425
- const { frequency, end, frequency_date, included_date, excluded_date } = repeat_rule || {};
426
- return {
427
- scheduleFormData: {
428
- color,
429
- name,
430
- repeat_type: repeatTypeMap[repeat_type],
431
- designation,
432
- frequency,
433
- frequency_date,
434
- end_time,
435
- start_time,
436
- excluded_date,
437
- included_date,
438
- time_slot,
439
- end_date: end == null ? void 0 : end.end_date
440
- },
441
- scheduleFormOtherValue: {
442
- endRadio: endTypeMap[(end == null ? void 0 : end.type) || "never"],
443
- isAllDay: !!is_all,
444
- type,
445
- excludedStatus: !!(excluded_date == null ? void 0 : excluded_date.length),
446
- includeStatus: !!(included_date == null ? void 0 : included_date.length)
447
- }
448
- };
449
- };
450
- var calcScheduleDateRange = (schedule) => {
451
- const { scheduleFormData, scheduleFormOtherValue } = formatScheduleResult(schedule);
452
- if (schedule.type === "time-slots") {
453
- return calcCalendarDataByTimeSlots(
454
- scheduleFormData,
455
- scheduleFormOtherValue,
456
- true
457
- );
458
- }
459
- if (schedule.type === "designation") {
460
- return calcCalendarDataByDesignation(
461
- scheduleFormData,
462
- scheduleFormOtherValue,
463
- true
464
- );
465
- }
466
- return calcCalendarDataByStandard(
467
- scheduleFormData,
468
- scheduleFormOtherValue,
469
- true
470
- );
471
- };
472
- var calcCalendarDataBySchedules = (schedules) => {
473
- const allSchedules = [];
474
- schedules.forEach((item) => {
475
- allSchedules.push(...calcCalendarDataByScheduleResult(item));
476
- });
477
- const dateMap = allSchedules.reduce((pre, cur) => {
478
- var _a, _b;
479
- return {
480
- ...pre,
481
- [cur.date]: {
482
- ...cur,
483
- color: [...((_a = pre[cur.date]) == null ? void 0 : _a.color) || [], ...cur.color],
484
- isExcluded: ((_b = pre[cur.date]) == null ? void 0 : _b.isExcluded) || cur.isExcluded
485
- }
486
- };
487
- }, {});
488
- return Object.values(dateMap);
489
- };
490
- var calcMinTimeMaxTimeBySchedules = (schedules, scheduleAllMap, selectDate) => {
491
- return schedules.reduce((pre, cur) => {
492
- var _a;
493
- let dateRange = ((_a = scheduleAllMap[cur.id]) == null ? void 0 : _a.dateRange) || calcScheduleDateRange(cur);
494
- let dateRangeFormat = [];
495
- if (selectDate) {
496
- const dateRangeTmp = [];
497
- const dateRangeFormatTmp = [];
498
- for (let i = 0; i < dateRange.length; i++) {
499
- const range = dateRange[i];
500
- const start = (0, import_dayjs.default)(range.start);
501
- const end = (0, import_dayjs.default)(range.end);
502
- const isSameStart = range.start.includes(selectDate);
503
- const isSameEnd = range.end.includes(selectDate);
504
- if (isSameStart || isSameEnd) {
505
- dateRangeTmp.push(range);
506
- if (isSameStart && !isSameEnd) {
507
- dateRangeFormatTmp.push({
508
- start: range.start,
509
- end: end.format("YYYY-MM-DD 23:59:59")
510
- });
511
- } else if (!isSameStart && isSameEnd) {
512
- dateRangeFormatTmp.push({
513
- start: start.format("YYYY-MM-DD 00:00:00"),
514
- end: range.end
515
- });
516
- } else {
517
- dateRangeFormatTmp.push(range);
518
- }
519
- }
520
- }
521
- dateRange = dateRangeTmp;
522
- dateRangeFormat = dateRangeFormatTmp;
523
- }
524
- let minTime = null;
525
- let maxTime = null;
526
- if (dateRange.length) {
527
- minTime = (0, import_dayjs.default)(dateRange[0].start);
528
- maxTime = (0, import_dayjs.default)(dateRange[dateRange.length - 1].end);
529
- }
530
- return {
531
- ...pre,
532
- [cur.id]: {
533
- minTime,
534
- maxTime,
535
- minTimeStr: (minTime == null ? void 0 : minTime.format("YYYY-MM-DD HH:mm:ss")) || null,
536
- maxTimeStr: (maxTime == null ? void 0 : maxTime.format("YYYY-MM-DD HH:mm:ss")) || null,
537
- dateRange,
538
- dateRangeFormat
539
- }
540
- };
541
- }, {});
542
- };
543
- var formatScheduleData = (relation, table_type, item_type, isExcluded) => {
544
- const _relation = relation || [];
545
- if (table_type && item_type && isExcluded) {
546
- return _relation.find((item) => (item == null ? void 0 : item.relation_table_type) === table_type && (item == null ? void 0 : item.item_type) !== item_type);
547
- }
548
- if (table_type && item_type) {
549
- return _relation.find((item) => (item == null ? void 0 : item.relation_table_type) === table_type && (item == null ? void 0 : item.item_type) === item_type);
550
- }
551
- if (table_type) {
552
- return _relation.some((item) => (item == null ? void 0 : item.relation_table_type) === table_type);
553
- }
554
- if (item_type) {
555
- return _relation.find((item) => (item == null ? void 0 : item.item_type) === item_type);
556
- }
557
- };
558
- // Annotate the CommonJS export names for ESM import in node:
559
- 0 && (module.exports = {
560
- calcCalendarDataByDesignation,
561
- calcCalendarDataBySchedule,
562
- calcCalendarDataByScheduleResult,
563
- calcCalendarDataBySchedules,
564
- calcCalendarDataByStandard,
565
- calcCalendarDataByTimeSlots,
566
- calcMinTimeMaxTimeBySchedules,
567
- calcScheduleDateRange,
568
- formatScheduleData,
569
- formatScheduleResult,
570
- getDaysByStartEnd,
571
- isAllDay
572
- });