@pisell/utils 2.0.1 → 2.0.3
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.
- package/es/constants/index.d.ts +4 -1
- package/es/constants/index.js +6 -1
- package/es/document.js +2 -2
- package/es/escPosPrinter/index.js +2 -2
- package/es/firebase/index.js +34 -13
- package/es/index.js +17 -1
- package/es/jsBridge/index.js +44 -2
- package/es/jsBridge/regDeviceApi.js +6 -10
- package/es/jsBridge/types.js +1 -0
- package/es/locales.js +5 -6
- package/es/log.js +23 -14
- package/es/miniRedux.js +14 -10
- package/es/otherUtils.js +2 -2
- package/es/walletValidity.js +499 -0
- package/lib/constants/index.d.ts +4 -1
- package/lib/constants/index.js +6 -1
- package/lib/escPosPrinter/EscPosPrinter.js +43 -86
- package/lib/escPosPrinter/index.js +2 -2
- package/lib/firebase/index.js +22 -0
- package/lib/image.js +1 -2
- package/lib/index.js +24 -1
- package/lib/jsBridge/index.js +33 -1
- package/lib/jsBridge/regDeviceApi.js +5 -13
- package/lib/jsBridge/types.js +17 -0
- package/lib/locales.js +0 -1
- package/lib/log.js +10 -1
- package/lib/miniRedux.js +5 -7
- package/lib/walletValidity.js +349 -0
- package/package.json +1 -1
- package/es/format.d.ts +0 -28
- package/es/index.d.ts +0 -13
- package/es/jsBridge/index.d.ts +0 -106
- package/es/locales.d.ts +0 -12
- package/es/miniRedux.d.ts +0 -16
- package/lib/format.d.ts +0 -28
- package/lib/index.d.ts +0 -13
- package/lib/jsBridge/index.d.ts +0 -106
- package/lib/locales.d.ts +0 -12
- package/lib/miniRedux.d.ts +0 -16
|
@@ -0,0 +1,349 @@
|
|
|
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/walletValidity.ts
|
|
30
|
+
var walletValidity_exports = {};
|
|
31
|
+
__export(walletValidity_exports, {
|
|
32
|
+
getScheduleSummary: () => getScheduleSummary
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(walletValidity_exports);
|
|
35
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
36
|
+
var CONSTANTS = {
|
|
37
|
+
ALL_DAY_START: "00:00",
|
|
38
|
+
ALL_DAY_END: "23:59",
|
|
39
|
+
DEFAULT_FUTURE_YEARS: 10,
|
|
40
|
+
SECONDS_SUFFIX: ":59"
|
|
41
|
+
};
|
|
42
|
+
var textConfig = {
|
|
43
|
+
"zh-HK": {
|
|
44
|
+
weekdays: ["日", "一", "二", "三", "四", "五", "六"],
|
|
45
|
+
separator: "、",
|
|
46
|
+
timeSeparator: "–",
|
|
47
|
+
rangeSeparator: " 至 ",
|
|
48
|
+
periodSeparator: ";",
|
|
49
|
+
timeSlotSeparator: ",",
|
|
50
|
+
every: "每",
|
|
51
|
+
day: "天",
|
|
52
|
+
week: "周",
|
|
53
|
+
month: "月",
|
|
54
|
+
year: "年",
|
|
55
|
+
available: "可用",
|
|
56
|
+
unlimited: "无限期",
|
|
57
|
+
multipleRules: "多規則,點詳情",
|
|
58
|
+
multipleSlots: ",多時段",
|
|
59
|
+
until: "至",
|
|
60
|
+
daily: "每天",
|
|
61
|
+
days: "天",
|
|
62
|
+
weeks: "周",
|
|
63
|
+
everyPrefix: "每",
|
|
64
|
+
weekPrefix: "周",
|
|
65
|
+
dateFormat: "YYYY-MM-DD",
|
|
66
|
+
dateTimeFormat: "YYYY-MM-DD HH:mm",
|
|
67
|
+
longTermValidFrom: "自",
|
|
68
|
+
noExpiry: "起長期有效",
|
|
69
|
+
on: ""
|
|
70
|
+
},
|
|
71
|
+
"zh-CN": {
|
|
72
|
+
weekdays: ["日", "一", "二", "三", "四", "五", "六"],
|
|
73
|
+
separator: "、",
|
|
74
|
+
timeSeparator: "–",
|
|
75
|
+
rangeSeparator: " 至 ",
|
|
76
|
+
periodSeparator: ";",
|
|
77
|
+
timeSlotSeparator: ",",
|
|
78
|
+
every: "每",
|
|
79
|
+
day: "天",
|
|
80
|
+
week: "周",
|
|
81
|
+
month: "月",
|
|
82
|
+
year: "年",
|
|
83
|
+
available: "可用",
|
|
84
|
+
unlimited: "无限期",
|
|
85
|
+
multipleRules: "多规则,点详情",
|
|
86
|
+
multipleSlots: ",多时段",
|
|
87
|
+
until: "至",
|
|
88
|
+
daily: "每天",
|
|
89
|
+
days: "天",
|
|
90
|
+
weeks: "周",
|
|
91
|
+
everyPrefix: "每",
|
|
92
|
+
weekPrefix: "周",
|
|
93
|
+
dateFormat: "YYYY-MM-DD",
|
|
94
|
+
dateTimeFormat: "YYYY-MM-DD HH:mm",
|
|
95
|
+
longTermValidFrom: "自",
|
|
96
|
+
noExpiry: "起长期有效",
|
|
97
|
+
on: ""
|
|
98
|
+
},
|
|
99
|
+
"en": {
|
|
100
|
+
weekdays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
|
101
|
+
separator: ", ",
|
|
102
|
+
timeSeparator: "–",
|
|
103
|
+
rangeSeparator: " - ",
|
|
104
|
+
periodSeparator: "; ",
|
|
105
|
+
timeSlotSeparator: ", ",
|
|
106
|
+
every: "every ",
|
|
107
|
+
day: "day",
|
|
108
|
+
week: "week",
|
|
109
|
+
month: "month",
|
|
110
|
+
year: "year",
|
|
111
|
+
available: "available",
|
|
112
|
+
unlimited: "unlimited",
|
|
113
|
+
multipleRules: "Multiple rules, see details",
|
|
114
|
+
multipleSlots: ", multiple slots",
|
|
115
|
+
until: "Until ",
|
|
116
|
+
daily: "daily",
|
|
117
|
+
days: "days",
|
|
118
|
+
weeks: "weeks",
|
|
119
|
+
everyPrefix: "every ",
|
|
120
|
+
weekPrefix: "",
|
|
121
|
+
dateFormat: "DD MMM YYYY",
|
|
122
|
+
dateTimeFormat: "DD MMM YYYY h:mm A",
|
|
123
|
+
longTermValidFrom: "from ",
|
|
124
|
+
noExpiry: ", no expiry",
|
|
125
|
+
on: "on "
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
function getWeekdayText(dayNumbers, locale, separator) {
|
|
129
|
+
const config = textConfig[locale];
|
|
130
|
+
return dayNumbers.map((day) => config.weekdays[day]).join(separator || config.separator);
|
|
131
|
+
}
|
|
132
|
+
function getText(locale, key) {
|
|
133
|
+
return textConfig[locale][key];
|
|
134
|
+
}
|
|
135
|
+
function getConfig(locale) {
|
|
136
|
+
return textConfig[locale];
|
|
137
|
+
}
|
|
138
|
+
function getDailyFrequencyText(frequency, locale) {
|
|
139
|
+
if (frequency === 1) {
|
|
140
|
+
return getText(locale, "daily");
|
|
141
|
+
}
|
|
142
|
+
const config = textConfig[locale];
|
|
143
|
+
if (locale === "en") {
|
|
144
|
+
return `${config.everyPrefix}${frequency} ${config.days}`;
|
|
145
|
+
} else {
|
|
146
|
+
return `${config.everyPrefix}${frequency}${config.days}`;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function getWeeklyFrequencyPrefix(frequency, locale) {
|
|
150
|
+
if (frequency === 1) {
|
|
151
|
+
return "";
|
|
152
|
+
}
|
|
153
|
+
const config = textConfig[locale];
|
|
154
|
+
if (locale === "en") {
|
|
155
|
+
return `${config.everyPrefix}${frequency} ${config.weeks}, `;
|
|
156
|
+
} else {
|
|
157
|
+
return `${config.everyPrefix}${frequency}${config.weeks} `;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function formatDateTime(dateTime, isAll = false, locale = "zh-CN") {
|
|
161
|
+
const date = (0, import_dayjs.default)(dateTime);
|
|
162
|
+
const config = getConfig(locale);
|
|
163
|
+
if (isAll) {
|
|
164
|
+
return date.format(config.dateFormat);
|
|
165
|
+
}
|
|
166
|
+
return date.format(config.dateTimeFormat);
|
|
167
|
+
}
|
|
168
|
+
function isAllDaySchedule(startTime, endTime) {
|
|
169
|
+
return startTime === CONSTANTS.ALL_DAY_START && endTime === CONSTANTS.ALL_DAY_END;
|
|
170
|
+
}
|
|
171
|
+
function formatDateRange(startDate, endDate, isStarted, locale, isAllDay = false) {
|
|
172
|
+
const config = getConfig(locale);
|
|
173
|
+
if (isStarted) {
|
|
174
|
+
const endDateStr = formatDateTime(endDate, isAllDay, locale);
|
|
175
|
+
return `${config.until}${endDateStr}`;
|
|
176
|
+
} else {
|
|
177
|
+
const startDateStr = formatDateTime(startDate, isAllDay, locale);
|
|
178
|
+
const endDateStr = formatDateTime(endDate, isAllDay, locale);
|
|
179
|
+
return `${startDateStr}${config.rangeSeparator}${endDateStr}`;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function getScheduleSummary(scheduleList, locale = "zh-CN") {
|
|
183
|
+
try {
|
|
184
|
+
if (!scheduleList || !Array.isArray(scheduleList)) {
|
|
185
|
+
return "";
|
|
186
|
+
}
|
|
187
|
+
if (scheduleList.length > 1) {
|
|
188
|
+
return getText(locale, "multipleRules");
|
|
189
|
+
}
|
|
190
|
+
if (scheduleList.length === 0) {
|
|
191
|
+
return "";
|
|
192
|
+
}
|
|
193
|
+
const schedule = scheduleList[0];
|
|
194
|
+
if (!schedule) {
|
|
195
|
+
return "";
|
|
196
|
+
}
|
|
197
|
+
const now = (0, import_dayjs.default)();
|
|
198
|
+
let startTime = null;
|
|
199
|
+
if (schedule.start_time) {
|
|
200
|
+
startTime = (0, import_dayjs.default)(schedule.start_time);
|
|
201
|
+
} else if (schedule.designation && schedule.designation.length > 0) {
|
|
202
|
+
const firstDesignation = schedule.designation[0];
|
|
203
|
+
if (firstDesignation && firstDesignation.start_date && firstDesignation.start_time) {
|
|
204
|
+
startTime = (0, import_dayjs.default)(`${firstDesignation.start_date} ${firstDesignation.start_time}`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
const isStarted = startTime ? isTimeStarted(now, startTime) : false;
|
|
208
|
+
return generateSummaryText(schedule, isStarted, locale);
|
|
209
|
+
} catch (error) {
|
|
210
|
+
console.warn("Error in getScheduleSummary:", error);
|
|
211
|
+
return "";
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function isTimeStarted(now, startTime) {
|
|
215
|
+
return startTime.isBefore(now);
|
|
216
|
+
}
|
|
217
|
+
function generateSummaryText(schedule, isStarted, locale) {
|
|
218
|
+
if (schedule.type === "designation" && schedule.designation && schedule.designation.length > 1) {
|
|
219
|
+
return getText(locale, "multipleRules");
|
|
220
|
+
}
|
|
221
|
+
if (schedule.type === "time-slots") {
|
|
222
|
+
const endDate = getScheduleEndDate(schedule);
|
|
223
|
+
if (!endDate) return "";
|
|
224
|
+
const endDateStr = formatDateTime(endDate, true, locale);
|
|
225
|
+
const prefix = "";
|
|
226
|
+
const suffix = getText(locale, "multipleSlots");
|
|
227
|
+
return `${prefix}${endDateStr}${suffix}`;
|
|
228
|
+
}
|
|
229
|
+
if (schedule.repeat_type !== "none" && schedule.repeat_rule) {
|
|
230
|
+
return generateRecurringSummary(schedule, isStarted, locale);
|
|
231
|
+
}
|
|
232
|
+
return generateSingleScheduleSummary(schedule, isStarted, locale);
|
|
233
|
+
}
|
|
234
|
+
function generateRecurringSummary(schedule, isStarted, locale) {
|
|
235
|
+
const { repeat_type, repeat_rule } = schedule;
|
|
236
|
+
if (!repeat_rule) return "";
|
|
237
|
+
const { frequency, frequency_date, end } = repeat_rule;
|
|
238
|
+
if (end.type === "never") {
|
|
239
|
+
return generateNeverEndingRecurringSummary(schedule, isStarted, locale, repeat_type, frequency, frequency_date);
|
|
240
|
+
}
|
|
241
|
+
const endDate = getScheduleEndDate(schedule);
|
|
242
|
+
if (!endDate) return "";
|
|
243
|
+
const endDateStr = formatDateTime(endDate, true, locale);
|
|
244
|
+
if (repeat_type === "daily") {
|
|
245
|
+
const frequencyText = getDailyFrequencyText(frequency, locale);
|
|
246
|
+
const dateRange = formatDateRange(schedule.start_time, endDate, isStarted, locale, true);
|
|
247
|
+
return `${dateRange},${frequencyText}`;
|
|
248
|
+
}
|
|
249
|
+
if (repeat_type === "weekly") {
|
|
250
|
+
const weekdaysText = getWeekdayText(frequency_date, locale, "/");
|
|
251
|
+
const frequencyPrefix = getWeeklyFrequencyPrefix(frequency, locale);
|
|
252
|
+
const config = getConfig(locale);
|
|
253
|
+
const dateRange = formatDateRange(schedule.start_time, endDate, isStarted, locale, true);
|
|
254
|
+
return `${dateRange},${frequencyPrefix}${config.weekPrefix}${weekdaysText}`;
|
|
255
|
+
}
|
|
256
|
+
return "";
|
|
257
|
+
}
|
|
258
|
+
function generateNeverEndingRecurringSummary(schedule, isStarted, locale, repeatType, frequency, frequencyDate) {
|
|
259
|
+
const config = getConfig(locale);
|
|
260
|
+
if (repeatType === "daily") {
|
|
261
|
+
if (frequency === 1) {
|
|
262
|
+
if (schedule.start_time) {
|
|
263
|
+
const startDateStr = formatDateTime(schedule.start_time, true, locale);
|
|
264
|
+
return `${config.longTermValidFrom}${startDateStr}${config.noExpiry}`;
|
|
265
|
+
}
|
|
266
|
+
return "";
|
|
267
|
+
} else {
|
|
268
|
+
const frequencyText = getDailyFrequencyText(frequency, locale);
|
|
269
|
+
if (locale === "en") {
|
|
270
|
+
return `${frequencyText}`;
|
|
271
|
+
} else {
|
|
272
|
+
return `${frequencyText}${config.available}`;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (repeatType === "weekly") {
|
|
277
|
+
const weekdaysText = getWeekdayText(frequencyDate, locale, locale === "en" ? " & " : "/");
|
|
278
|
+
if (frequency === 1) {
|
|
279
|
+
if (locale === "en") {
|
|
280
|
+
return `${config.on}${weekdaysText}`;
|
|
281
|
+
} else {
|
|
282
|
+
return `${config.everyPrefix}${config.weekPrefix}${weekdaysText}${config.available}`;
|
|
283
|
+
}
|
|
284
|
+
} else {
|
|
285
|
+
const frequencyPrefix = getWeeklyFrequencyPrefix(frequency, locale);
|
|
286
|
+
if (locale === "en") {
|
|
287
|
+
return `${frequencyPrefix}${config.on}${weekdaysText}`;
|
|
288
|
+
} else {
|
|
289
|
+
return `${frequencyPrefix}${config.weekPrefix}${weekdaysText}`;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return "";
|
|
294
|
+
}
|
|
295
|
+
function generateSingleScheduleSummary(schedule, isStarted, locale) {
|
|
296
|
+
const isAllDay = schedule.is_all === 1;
|
|
297
|
+
if (schedule.type === "designation" && schedule.designation && schedule.designation.length === 1) {
|
|
298
|
+
const designation = schedule.designation[0];
|
|
299
|
+
const startDate = designation.start_date;
|
|
300
|
+
const endDate = designation.end_date;
|
|
301
|
+
const startTime = designation.start_time;
|
|
302
|
+
const endTime = designation.end_time;
|
|
303
|
+
const isDesignationAllDay = isAllDaySchedule(startTime, endTime);
|
|
304
|
+
if (isDesignationAllDay || isAllDay) {
|
|
305
|
+
return formatDateRange(startDate, endDate, isStarted, locale, true);
|
|
306
|
+
} else {
|
|
307
|
+
const startDateTime = `${startDate} ${startTime}${CONSTANTS.SECONDS_SUFFIX}`;
|
|
308
|
+
const endDateTime = `${endDate} ${endTime}${CONSTANTS.SECONDS_SUFFIX}`;
|
|
309
|
+
return formatDateRange(startDateTime, endDateTime, isStarted, locale, false);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (isAllDay) {
|
|
313
|
+
const endDate = getScheduleEndDate(schedule);
|
|
314
|
+
if (!endDate) return "";
|
|
315
|
+
return formatDateRange(schedule.start_time, endDate, isStarted, locale, true);
|
|
316
|
+
} else {
|
|
317
|
+
return formatDateRange(schedule.start_time, schedule.end_time, isStarted, locale, false);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
function getScheduleEndDate(schedule) {
|
|
321
|
+
try {
|
|
322
|
+
if (schedule.repeat_rule) {
|
|
323
|
+
if (schedule.repeat_rule.end.type === "never") {
|
|
324
|
+
const futureDate = (0, import_dayjs.default)().add(CONSTANTS.DEFAULT_FUTURE_YEARS, "year");
|
|
325
|
+
return `${futureDate.format("YYYY-MM-DD")} ${CONSTANTS.ALL_DAY_END}${CONSTANTS.SECONDS_SUFFIX}`;
|
|
326
|
+
} else if (schedule.repeat_rule.end.end_date) {
|
|
327
|
+
return `${schedule.repeat_rule.end.end_date} ${CONSTANTS.ALL_DAY_END}${CONSTANTS.SECONDS_SUFFIX}`;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (schedule.designation && schedule.designation.length > 0) {
|
|
331
|
+
const lastDesignation = schedule.designation[schedule.designation.length - 1];
|
|
332
|
+
return `${lastDesignation.end_date} ${lastDesignation.end_time}${CONSTANTS.SECONDS_SUFFIX}`;
|
|
333
|
+
}
|
|
334
|
+
if (schedule.end_time) {
|
|
335
|
+
return schedule.end_time;
|
|
336
|
+
}
|
|
337
|
+
if (schedule.start_time) {
|
|
338
|
+
return schedule.start_time;
|
|
339
|
+
}
|
|
340
|
+
return null;
|
|
341
|
+
} catch (error) {
|
|
342
|
+
console.warn("Error in getScheduleEndDate:", error);
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
347
|
+
0 && (module.exports = {
|
|
348
|
+
getScheduleSummary
|
|
349
|
+
});
|
package/package.json
CHANGED
package/es/format.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @title: 格式化金额
|
|
3
|
-
* @description:
|
|
4
|
-
* @param {number} amount 原金额
|
|
5
|
-
* @param {number} precision 小数位数
|
|
6
|
-
* @param {string} symbol 货币符号
|
|
7
|
-
* @return {*}
|
|
8
|
-
* @Author: zhiwei.Wang
|
|
9
|
-
* @Date: 2023-11-06 16:51
|
|
10
|
-
*/
|
|
11
|
-
export declare const formatAmount: (amount?: number | string, precision?: number, symbol?: string) => string | number;
|
|
12
|
-
export declare type FormatOptions = {
|
|
13
|
-
/** 小数点后位数 默认是小数点后2位 */
|
|
14
|
-
precision?: number;
|
|
15
|
-
/** 显示货币符号 指的是 ¥$ 等货币符号等显隐,默认是展示 */
|
|
16
|
-
showCurrencySymbol?: boolean;
|
|
17
|
-
/** 千分位 指的是长金额的千分位逗号隔开,比如“123, 245, 315” 这种展现形式,默认是关闭 */
|
|
18
|
-
useThousandsSeparator?: boolean;
|
|
19
|
-
/** 整数位隐藏小数 指的是如果价格为整数,后面的".00" 将被省略以节省页面空间 */
|
|
20
|
-
hideDecimalForWholeNumbers?: boolean;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* 根据配置格式化金额
|
|
24
|
-
* @param amount
|
|
25
|
-
* @param symbol
|
|
26
|
-
* @param options
|
|
27
|
-
*/
|
|
28
|
-
export declare const formatAmountWithOptions: (amount: string | number | undefined, symbol: string | undefined, options: FormatOptions) => string | number;
|
package/es/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export * from "./otherUtils";
|
|
2
|
-
export * from "./typeUtils";
|
|
3
|
-
export * from "./document";
|
|
4
|
-
export * from "./date";
|
|
5
|
-
export * from "./platform";
|
|
6
|
-
export * from "./log";
|
|
7
|
-
export * from "./format";
|
|
8
|
-
export * from "./escPosPrinter";
|
|
9
|
-
export * from './miniRedux';
|
|
10
|
-
export * from "./jsBridge";
|
|
11
|
-
export * from "./image";
|
|
12
|
-
export * from "./locales";
|
|
13
|
-
export * from "./arrayUtils";
|
package/es/jsBridge/index.d.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
declare type LanguageNumber = {
|
|
2
|
-
en: number;
|
|
3
|
-
zh_CN: number;
|
|
4
|
-
zh_HK: number;
|
|
5
|
-
};
|
|
6
|
-
declare type LanguageString = {
|
|
7
|
-
en: string;
|
|
8
|
-
zh_CN: string;
|
|
9
|
-
zh_HK: string;
|
|
10
|
-
} | string;
|
|
11
|
-
/**
|
|
12
|
-
* 打印小票
|
|
13
|
-
*/
|
|
14
|
-
declare type WebPrint0 = {
|
|
15
|
-
/**
|
|
16
|
-
* 打印类型
|
|
17
|
-
* 0: 小票
|
|
18
|
-
* 1:ITS备货单/划菜单
|
|
19
|
-
* 2:手环
|
|
20
|
-
*/
|
|
21
|
-
type: "0";
|
|
22
|
-
data: {
|
|
23
|
-
/** 订单ID */
|
|
24
|
-
order_id: string;
|
|
25
|
-
};
|
|
26
|
-
/** 打印语言对应的数量 */
|
|
27
|
-
language: LanguageNumber;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* 打印ITS备货单/划菜单
|
|
31
|
-
*/
|
|
32
|
-
declare type WebPrint1 = {
|
|
33
|
-
/**
|
|
34
|
-
* 打印类型
|
|
35
|
-
* 0: 小票
|
|
36
|
-
* 1:ITS备货单/划菜单
|
|
37
|
-
* 2:手环
|
|
38
|
-
*/
|
|
39
|
-
type: "1";
|
|
40
|
-
data: {
|
|
41
|
-
/** 0:备货 1:划单 */
|
|
42
|
-
mode: "0" | "1";
|
|
43
|
-
resource: LanguageString;
|
|
44
|
-
/** 订单备注 */
|
|
45
|
-
order_note: string;
|
|
46
|
-
/** 订单时间或商品下单时间 */
|
|
47
|
-
time: string;
|
|
48
|
-
/** 订单编号 */
|
|
49
|
-
order_number?: string;
|
|
50
|
-
/** 商品 */
|
|
51
|
-
products: {
|
|
52
|
-
/** 商品名称 */
|
|
53
|
-
product_title: LanguageString;
|
|
54
|
-
/** 商品规格 */
|
|
55
|
-
product_option_string: LanguageString;
|
|
56
|
-
/** 商品备注 */
|
|
57
|
-
product_note: string;
|
|
58
|
-
/** 商品数量 */
|
|
59
|
-
product_quantity: number;
|
|
60
|
-
/** 加菜标识 待定 */
|
|
61
|
-
is_append?: boolean;
|
|
62
|
-
/** 退菜标识 待定 */
|
|
63
|
-
is_removed?: boolean;
|
|
64
|
-
}[];
|
|
65
|
-
};
|
|
66
|
-
/** 打印语言对应的数量 */
|
|
67
|
-
language: LanguageNumber;
|
|
68
|
-
};
|
|
69
|
-
declare type WebPrint2 = {
|
|
70
|
-
/**
|
|
71
|
-
* 打印类型
|
|
72
|
-
* 0: 小票
|
|
73
|
-
* 1:ITS备货单/划菜单
|
|
74
|
-
* 2:手环
|
|
75
|
-
*/
|
|
76
|
-
type: "2";
|
|
77
|
-
data: {
|
|
78
|
-
/** 0: 普通票 1:成人票 2:免费成人票 */
|
|
79
|
-
type: "0" | "1" | "2";
|
|
80
|
-
/** 发行编码 */
|
|
81
|
-
encoded: string;
|
|
82
|
-
/** 编码 */
|
|
83
|
-
code: string;
|
|
84
|
-
/** 到期时间 */
|
|
85
|
-
expire_date: string;
|
|
86
|
-
areas: {
|
|
87
|
-
/** 区域名字 */
|
|
88
|
-
area_name: string;
|
|
89
|
-
/** 区域代码 */
|
|
90
|
-
area_code: string;
|
|
91
|
-
/** 可用次数 */
|
|
92
|
-
limit_num: number;
|
|
93
|
-
/** 已用次数 */
|
|
94
|
-
used_num: number;
|
|
95
|
-
}[];
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
declare type WebPrintParams = WebPrint0 | WebPrint1 | WebPrint2;
|
|
99
|
-
/**
|
|
100
|
-
* webView页面中调用打印机打印
|
|
101
|
-
* 此api暂时只支持native app平台下ios手机
|
|
102
|
-
* @param params
|
|
103
|
-
* @param callback
|
|
104
|
-
*/
|
|
105
|
-
export declare function webPrint(params: WebPrintParams, callback: (...arg: any) => void): void;
|
|
106
|
-
export {};
|
package/es/locales.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare const locales: {
|
|
2
|
-
init: (_localeMaps: any, _locale: string) => void;
|
|
3
|
-
getText: (id: string) => any;
|
|
4
|
-
locale: string;
|
|
5
|
-
localeMap: any;
|
|
6
|
-
localeMaps: {
|
|
7
|
-
en: {};
|
|
8
|
-
'zh-CN': {};
|
|
9
|
-
'zh-HK': {};
|
|
10
|
-
};
|
|
11
|
-
formatLocale: (_locale: string) => string;
|
|
12
|
-
};
|
package/es/miniRedux.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
interface MiniReduxProps<State, Namespace> {
|
|
2
|
-
namespace?: Namespace;
|
|
3
|
-
state?: State;
|
|
4
|
-
reducers?: any;
|
|
5
|
-
effects?: any;
|
|
6
|
-
}
|
|
7
|
-
export declare const miniRedux: <State extends Record<string, any>, Namespace extends string>({ namespace, state, reducers, effects, }: MiniReduxProps<State, Namespace>) => {
|
|
8
|
-
Context: React.Context<{ [K in Namespace]: State; } & {
|
|
9
|
-
dispatch: (params: {
|
|
10
|
-
type: string;
|
|
11
|
-
payload: any;
|
|
12
|
-
}) => void;
|
|
13
|
-
}>;
|
|
14
|
-
Provider: (ComponentUi: any) => any;
|
|
15
|
-
};
|
|
16
|
-
export {};
|
package/lib/format.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @title: 格式化金额
|
|
3
|
-
* @description:
|
|
4
|
-
* @param {number} amount 原金额
|
|
5
|
-
* @param {number} precision 小数位数
|
|
6
|
-
* @param {string} symbol 货币符号
|
|
7
|
-
* @return {*}
|
|
8
|
-
* @Author: zhiwei.Wang
|
|
9
|
-
* @Date: 2023-11-06 16:51
|
|
10
|
-
*/
|
|
11
|
-
export declare const formatAmount: (amount?: number | string, precision?: number, symbol?: string) => string | number;
|
|
12
|
-
export declare type FormatOptions = {
|
|
13
|
-
/** 小数点后位数 默认是小数点后2位 */
|
|
14
|
-
precision?: number;
|
|
15
|
-
/** 显示货币符号 指的是 ¥$ 等货币符号等显隐,默认是展示 */
|
|
16
|
-
showCurrencySymbol?: boolean;
|
|
17
|
-
/** 千分位 指的是长金额的千分位逗号隔开,比如“123, 245, 315” 这种展现形式,默认是关闭 */
|
|
18
|
-
useThousandsSeparator?: boolean;
|
|
19
|
-
/** 整数位隐藏小数 指的是如果价格为整数,后面的".00" 将被省略以节省页面空间 */
|
|
20
|
-
hideDecimalForWholeNumbers?: boolean;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* 根据配置格式化金额
|
|
24
|
-
* @param amount
|
|
25
|
-
* @param symbol
|
|
26
|
-
* @param options
|
|
27
|
-
*/
|
|
28
|
-
export declare const formatAmountWithOptions: (amount: string | number | undefined, symbol: string | undefined, options: FormatOptions) => string | number;
|
package/lib/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export * from "./otherUtils";
|
|
2
|
-
export * from "./typeUtils";
|
|
3
|
-
export * from "./document";
|
|
4
|
-
export * from "./date";
|
|
5
|
-
export * from "./platform";
|
|
6
|
-
export * from "./log";
|
|
7
|
-
export * from "./format";
|
|
8
|
-
export * from "./escPosPrinter";
|
|
9
|
-
export * from './miniRedux';
|
|
10
|
-
export * from "./jsBridge";
|
|
11
|
-
export * from "./image";
|
|
12
|
-
export * from "./locales";
|
|
13
|
-
export * from "./arrayUtils";
|
package/lib/jsBridge/index.d.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
declare type LanguageNumber = {
|
|
2
|
-
en: number;
|
|
3
|
-
zh_CN: number;
|
|
4
|
-
zh_HK: number;
|
|
5
|
-
};
|
|
6
|
-
declare type LanguageString = {
|
|
7
|
-
en: string;
|
|
8
|
-
zh_CN: string;
|
|
9
|
-
zh_HK: string;
|
|
10
|
-
} | string;
|
|
11
|
-
/**
|
|
12
|
-
* 打印小票
|
|
13
|
-
*/
|
|
14
|
-
declare type WebPrint0 = {
|
|
15
|
-
/**
|
|
16
|
-
* 打印类型
|
|
17
|
-
* 0: 小票
|
|
18
|
-
* 1:ITS备货单/划菜单
|
|
19
|
-
* 2:手环
|
|
20
|
-
*/
|
|
21
|
-
type: "0";
|
|
22
|
-
data: {
|
|
23
|
-
/** 订单ID */
|
|
24
|
-
order_id: string;
|
|
25
|
-
};
|
|
26
|
-
/** 打印语言对应的数量 */
|
|
27
|
-
language: LanguageNumber;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* 打印ITS备货单/划菜单
|
|
31
|
-
*/
|
|
32
|
-
declare type WebPrint1 = {
|
|
33
|
-
/**
|
|
34
|
-
* 打印类型
|
|
35
|
-
* 0: 小票
|
|
36
|
-
* 1:ITS备货单/划菜单
|
|
37
|
-
* 2:手环
|
|
38
|
-
*/
|
|
39
|
-
type: "1";
|
|
40
|
-
data: {
|
|
41
|
-
/** 0:备货 1:划单 */
|
|
42
|
-
mode: "0" | "1";
|
|
43
|
-
resource: LanguageString;
|
|
44
|
-
/** 订单备注 */
|
|
45
|
-
order_note: string;
|
|
46
|
-
/** 订单时间或商品下单时间 */
|
|
47
|
-
time: string;
|
|
48
|
-
/** 订单编号 */
|
|
49
|
-
order_number?: string;
|
|
50
|
-
/** 商品 */
|
|
51
|
-
products: {
|
|
52
|
-
/** 商品名称 */
|
|
53
|
-
product_title: LanguageString;
|
|
54
|
-
/** 商品规格 */
|
|
55
|
-
product_option_string: LanguageString;
|
|
56
|
-
/** 商品备注 */
|
|
57
|
-
product_note: string;
|
|
58
|
-
/** 商品数量 */
|
|
59
|
-
product_quantity: number;
|
|
60
|
-
/** 加菜标识 待定 */
|
|
61
|
-
is_append?: boolean;
|
|
62
|
-
/** 退菜标识 待定 */
|
|
63
|
-
is_removed?: boolean;
|
|
64
|
-
}[];
|
|
65
|
-
};
|
|
66
|
-
/** 打印语言对应的数量 */
|
|
67
|
-
language: LanguageNumber;
|
|
68
|
-
};
|
|
69
|
-
declare type WebPrint2 = {
|
|
70
|
-
/**
|
|
71
|
-
* 打印类型
|
|
72
|
-
* 0: 小票
|
|
73
|
-
* 1:ITS备货单/划菜单
|
|
74
|
-
* 2:手环
|
|
75
|
-
*/
|
|
76
|
-
type: "2";
|
|
77
|
-
data: {
|
|
78
|
-
/** 0: 普通票 1:成人票 2:免费成人票 */
|
|
79
|
-
type: "0" | "1" | "2";
|
|
80
|
-
/** 发行编码 */
|
|
81
|
-
encoded: string;
|
|
82
|
-
/** 编码 */
|
|
83
|
-
code: string;
|
|
84
|
-
/** 到期时间 */
|
|
85
|
-
expire_date: string;
|
|
86
|
-
areas: {
|
|
87
|
-
/** 区域名字 */
|
|
88
|
-
area_name: string;
|
|
89
|
-
/** 区域代码 */
|
|
90
|
-
area_code: string;
|
|
91
|
-
/** 可用次数 */
|
|
92
|
-
limit_num: number;
|
|
93
|
-
/** 已用次数 */
|
|
94
|
-
used_num: number;
|
|
95
|
-
}[];
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
declare type WebPrintParams = WebPrint0 | WebPrint1 | WebPrint2;
|
|
99
|
-
/**
|
|
100
|
-
* webView页面中调用打印机打印
|
|
101
|
-
* 此api暂时只支持native app平台下ios手机
|
|
102
|
-
* @param params
|
|
103
|
-
* @param callback
|
|
104
|
-
*/
|
|
105
|
-
export declare function webPrint(params: WebPrintParams, callback: (...arg: any) => void): void;
|
|
106
|
-
export {};
|