@cloudbase/framework-plugin-low-code 0.7.10-beta.2 → 0.7.11-beta.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.
@@ -1,324 +0,0 @@
1
- // 日期转换
2
- class CustomDate {
3
- constructor() {
4
- this.i18n = {
5
- dayNames: [
6
- 'Sun',
7
- 'Mon',
8
- 'Tue',
9
- 'Wed',
10
- 'Thu',
11
- 'Fri',
12
- 'Sat',
13
- 'Sunday',
14
- 'Monday',
15
- 'Tuesday',
16
- 'Wednesday',
17
- 'Thursday',
18
- 'Friday',
19
- 'Saturday',
20
- ],
21
- monthNames: [
22
- 'Jan',
23
- 'Feb',
24
- 'Mar',
25
- 'Apr',
26
- 'May',
27
- 'Jun',
28
- 'Jul',
29
- 'Aug',
30
- 'Sep',
31
- 'Oct',
32
- 'Nov',
33
- 'Dec',
34
- 'January',
35
- 'February',
36
- 'March',
37
- 'April',
38
- 'May',
39
- 'June',
40
- 'July',
41
- 'August',
42
- 'September',
43
- 'October',
44
- 'November',
45
- 'December',
46
- ],
47
- timeNames: ['a', 'p', 'am', 'pm', 'A', 'P', 'AM', 'PM'],
48
- };
49
- this.masks = {
50
- default: 'ddd mmm dd yyyy HH:MM:ss',
51
- shortDate: 'm/d/yy',
52
- paddedShortDate: 'mm/dd/yyyy',
53
- mediumDate: 'mmm d, yyyy',
54
- longDate: 'mmmm d, yyyy',
55
- fullDate: 'dddd, mmmm d, yyyy',
56
- shortTime: 'h:MM TT',
57
- mediumTime: 'h:MM:ss TT',
58
- longTime: 'h:MM:ss TT Z',
59
- isoDate: 'yyyy-mm-dd',
60
- isoTime: 'HH:MM:ss',
61
- isoDateTime: "yyyy-mm-dd'T'HH:MM:sso",
62
- isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'",
63
- expiresHeaderFormat: 'ddd, dd mmm yyyy HH:MM:ss Z',
64
- };
65
- this.token = /d{1,4}|D{3,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|W{1,2}|[LlopSZN]|"[^"]*"|'[^']*'/g;
66
- this.timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g;
67
- this.timezoneClip = /[^-+\dA-Z]/g;
68
- }
69
-
70
- /*
71
- *
72
- | Name | Mask | Example |
73
- | ----------------- | ------------------------------ | ------------------------ |
74
- | `default` | `ddd mmm dd yyyy HH:MM:ss` | Sat Jun 09 2007 17:46:21 |
75
- | `shortDate` | `m/d/yy` | 6/9/07 |
76
- | `paddedShortDate` | `mm/dd/yyyy` | 06/09/2007 |
77
- | `mediumDate` | `mmm d, yyyy` | Jun 9, 2007 |
78
- | `longDate` | `mmmm d, yyyy` | June 9, 2007 |
79
- | `fullDate` | `dddd, mmmm d, yyyy` | Saturday, June 9, 2007 |
80
- | `shortTime` | `h:MM TT` | 5:46 PM |
81
- | `mediumTime` | `h:MM:ss TT` | 5:46:21 PM |
82
- | `longTime` | `h:MM:ss TT Z` | 5:46:21 PM EST |
83
- | `isoDate` | `yyyy-mm-dd` | 2007-06-09 |
84
- | `isoTime` | `HH:MM:ss` | 17:46:21 |
85
- | `isoDateTime` | `yyyy-mm-dd'T'HH:MM:sso` | 2007-06-09T17:46:21+0700 |
86
- | `isoUtcDateTime` | `UTC:yyyy-mm-dd'T'HH:MM:ss'Z'` | 2007-06-09T22:46:21Z |
87
- *
88
- */
89
- format(date, mask, utc, gmt) {
90
- let newMask = mask;
91
- let newDate = date;
92
- let newUtc = utc;
93
- let newGmt = gmt;
94
- if (
95
- arguments.length === 1 &&
96
- this._kindOf(newDate) === 'string' &&
97
- !/\d/.test(newDate)
98
- ) {
99
- newDate = undefined;
100
- }
101
- newDate = newDate || newDate === 0 ? newDate : new Date();
102
- if (!(newDate instanceof Date)) newDate = new Date(newDate);
103
- if (isNaN(newDate)) throw TypeError('Invalid date');
104
- newMask = String(this.masks[newMask] || newMask || this.masks['default']);
105
- const maskSlice = newMask.slice(0, 4);
106
- if (maskSlice === 'UTC:' || maskSlice === 'GMT:') {
107
- newMask = newMask.slice(4);
108
- newUtc = true;
109
- if (maskSlice === 'GMT:') newGmt = true;
110
- }
111
- const _ = newUtc ? 'getUTC' : 'get';
112
- const _d = newDate[`${_}Date`]();
113
- const D = newDate[`${_}Day`]();
114
- const _m = newDate[`${_}Month`]();
115
- const y = newDate[`${_}FullYear`]();
116
- const _H = newDate[`${_}Hours`]();
117
- const _M = newDate[`${_}Minutes`]();
118
- const _s = newDate[`${_}Seconds`]();
119
- const _L = newDate[`${_}Milliseconds`]();
120
- const _o = newUtc ? 0 : newDate.getTimezoneOffset();
121
- const _W = this._getWeek(newDate);
122
- const _N = this._getDayOfWeek(newDate);
123
- // eslint-disable-next-line @typescript-eslint/no-this-alias
124
- const self = this;
125
- // @ts-ignore
126
- // @ts-ignore
127
- const flags = {
128
- d: () => _d,
129
- dd: () => self._pad(_d),
130
- ddd: () => self.i18n.dayNames[D],
131
- DDD: () =>
132
- self._getDayName({
133
- y,
134
- m: _m,
135
- d: _d,
136
- _,
137
- dayName: self.i18n.dayNames[D],
138
- short: true,
139
- }),
140
- dddd: () => self.i18n.dayNames[D + 7],
141
- DDDD: () =>
142
- self._getDayName({
143
- y: y,
144
- m: _m,
145
- d: _d,
146
- _: _,
147
- dayName: self.i18n.dayNames[D + 7],
148
- }),
149
- m: () => _m + 1,
150
- mm: () => self._pad(_m + 1),
151
- mmm: () => self.i18n.monthNames[_m],
152
- mmmm: () => self.i18n.monthNames[_m + 12],
153
- yy: () => String(y).slice(2),
154
- yyyy: () => self._pad(y, 4),
155
- h: () => _H % 12 || 12,
156
- hh: () => self._pad(_H % 12 || 12),
157
- H: () => _H,
158
- HH: () => self._pad(_H),
159
- M: () => _M,
160
- MM: () => self._pad(_M),
161
- s: () => _s,
162
- ss: () => self._pad(_s),
163
- l: () => self._pad(_L, 3),
164
- L: () => self._pad(Math.floor(_L / 10)),
165
- t: () => (_H < 12 ? self.i18n.timeNames[0] : self.i18n.timeNames[1]),
166
- tt: () => (_H < 12 ? self.i18n.timeNames[2] : self.i18n.timeNames[3]),
167
- T: () => (_H < 12 ? self.i18n.timeNames[4] : self.i18n.timeNames[5]),
168
- TT: () => (_H < 12 ? self.i18n.timeNames[6] : self.i18n.timeNames[7]),
169
- // eslint-disable-next-line no-nested-ternary
170
- Z: () =>
171
- newGmt
172
- ? 'GMT'
173
- : newUtc
174
- ? 'UTC'
175
- : (String(newDate).match(self.timezone) || [''])
176
- .pop()
177
- .replace(self.timezoneClip, '')
178
- .replace(/GMT\+0000/g, 'UTC'),
179
- o: () =>
180
- (_o > 0 ? '-' : '+') +
181
- self._pad(Math.floor(Math.abs(_o) / 60) * 100 + (Math.abs(_o) % 60), 4),
182
- p: () =>
183
- `${
184
- (_o > 0 ? '-' : '+') + self._pad(Math.floor(Math.abs(_o) / 60), 2)
185
- }:${self._pad(Math.floor(Math.abs(_o) % 60), 2)}`,
186
- // @ts-ignore
187
- S: () =>
188
- ['th', 'st', 'nd', 'rd'][
189
- _d % 10 > 3 ? 0 : (((_d % 100) - (_d % 10) != 10) * _d) % 10
190
- ],
191
- W: () => _W,
192
- WW: () => self._pad(_W),
193
- N: () => _N,
194
- };
195
- return mask.replace(this.token, (match) => {
196
- if (match in flags) {
197
- return flags[match]();
198
- }
199
- return match.slice(1, match.length - 1);
200
- });
201
- }
202
-
203
- _pad(val, len) {
204
- let newVal = String(val);
205
- const newLen = len || 2;
206
- while (newVal.length < newLen) {
207
- newVal = `0${newVal}`;
208
- }
209
- return newVal;
210
- }
211
-
212
- _getDayName(_ref) {
213
- const { y, m, d, _, dayName } = _ref;
214
- const _ref$short = _ref['short'];
215
- const _short = _ref$short === void 0 ? false : _ref$short;
216
- const today = new Date();
217
- const yesterday = new Date();
218
- yesterday.setDate(yesterday[`${_}Date`]() - 1);
219
- const tomorrow = new Date();
220
- tomorrow.setDate(tomorrow[`${_}Date`]() + 1);
221
- const today_d = function today_d() {
222
- return today[`${_}Date`]();
223
- };
224
- const today_m = function today_m() {
225
- return today[`${_}Month`]();
226
- };
227
- const today_y = function today_y() {
228
- return today[`${_}FullYear`]();
229
- };
230
- const yesterday_d = function yesterday_d() {
231
- return yesterday[`${_}Date`]();
232
- };
233
- const yesterday_m = function yesterday_m() {
234
- return yesterday[`${_}Month`]();
235
- };
236
- const yesterday_y = function yesterday_y() {
237
- return yesterday[`${_}FullYear`]();
238
- };
239
- const tomorrow_d = function tomorrow_d() {
240
- return tomorrow[`${_}Date`]();
241
- };
242
- const tomorrow_m = function tomorrow_m() {
243
- return tomorrow[`${_}Month`]();
244
- };
245
- const tomorrow_y = function tomorrow_y() {
246
- return tomorrow[`${_}FullYear`]();
247
- };
248
- if (today_y() === y && today_m() === m && today_d() === d) {
249
- return _short ? 'Tdy' : 'Today';
250
- }
251
- if (yesterday_y() === y && yesterday_m() === m && yesterday_d() === d) {
252
- return _short ? 'Ysd' : 'Yesterday';
253
- }
254
- if (tomorrow_y() === y && tomorrow_m() === m && tomorrow_d() === d) {
255
- return _short ? 'Tmw' : 'Tomorrow';
256
- }
257
- return dayName;
258
- }
259
-
260
- _getWeek(date) {
261
- const targetThursday = new Date(
262
- date.getFullYear(),
263
- date.getMonth(),
264
- date.getDate()
265
- );
266
- targetThursday.setDate(
267
- targetThursday.getDate() - ((targetThursday.getDay() + 6) % 7) + 3
268
- );
269
- const firstThursday = new Date(targetThursday.getFullYear(), 0, 4);
270
- firstThursday.setDate(
271
- firstThursday.getDate() - ((firstThursday.getDay() + 6) % 7) + 3
272
- );
273
- const ds =
274
- targetThursday.getTimezoneOffset() - firstThursday.getTimezoneOffset();
275
- targetThursday.setHours(targetThursday.getHours() - ds);
276
- const weekDiff = (targetThursday - firstThursday) / (864e5 * 7);
277
- return 1 + Math.floor(weekDiff);
278
- }
279
-
280
- _getDayOfWeek(date) {
281
- let dow = date.getDay();
282
- if (dow === 0) {
283
- dow = 7;
284
- }
285
- return dow;
286
- }
287
-
288
- _kindOf(val) {
289
- if (val === null) {
290
- return 'null';
291
- }
292
- if (val === undefined) {
293
- return 'undefined';
294
- }
295
- if (this._typeof(val) !== 'object') {
296
- return this._typeof(val);
297
- }
298
- if (Array.isArray(val)) {
299
- return 'array';
300
- }
301
- return {}.toString.call(val).slice(8, -1).toLowerCase();
302
- }
303
-
304
- _typeof(obj) {
305
- if (typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol') {
306
- this._typeof = function _typeof(obj) {
307
- return typeof obj;
308
- };
309
- } else {
310
- this._typeof = function _typeof(obj) {
311
- return obj &&
312
- typeof Symbol === 'function' &&
313
- obj.constructor === Symbol &&
314
- obj !== Symbol.prototype
315
- ? 'symbol'
316
- : typeof obj;
317
- };
318
- }
319
- return this._typeof(obj);
320
- }
321
- }
322
-
323
- const dataInstance = new CustomDate();
324
- export const formatDate = new CustomDate().format.bind(dataInstance);
@@ -1,27 +0,0 @@
1
- import React from "react";
2
- import { Suspense } from "react";
3
- import ReactDOM from 'react-dom';
4
-
5
- const ScanCode = React.lazy(() => import('./ScanCodeComponent'));
6
- const WEAPP_SCAN_CODE_ELEMENT_ID = 'weapp-scan-code-modal-root';
7
- export function scanCodeApi(opts) {
8
- const options = {
9
- onlyFromCamera: false,
10
- scanType: ['barCode', 'qrCode'],
11
- success: () => {},
12
- fail: () => {},
13
- complete: () => {},
14
- enableDefaultBehavior: true,
15
- ...opts,
16
- };
17
- if (typeof options.scanType === 'string') {
18
- options.scanType = [options.scanType];
19
- }
20
- let root = document.getElementById(WEAPP_SCAN_CODE_ELEMENT_ID);
21
- if (!root) {
22
- root = document.createElement('div');
23
- root.id = WEAPP_SCAN_CODE_ELEMENT_ID;
24
- }
25
- document.body.appendChild(root);
26
- ReactDOM.render(<Suspense fallback={<></>}><ScanCode root={root} options={options} /></Suspense>, root);
27
- }