@pisell/materials 2.2.35 → 2.2.37

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