@cloudbase/framework-plugin-low-code 0.6.31 → 0.6.34

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 (83) hide show
  1. package/lib/builder/config/index.js +2 -5
  2. package/lib/builder/core/copy.d.ts.map +1 -1
  3. package/lib/builder/mp/materials.d.ts.map +1 -1
  4. package/lib/builder/mp/materials.js +21 -5
  5. package/lib/generator/template.d.ts +1 -101
  6. package/lib/generator/template.d.ts.map +1 -1
  7. package/lib/generator/template.js +1 -101
  8. package/package.json +5 -3
  9. package/template/webpack/web.prod.js +66 -85
  10. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/cookie.js +0 -286
  11. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/history.js +0 -133
  12. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/local-storage.js +0 -103
  13. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/location.js +0 -588
  14. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/miniprogram.js +0 -101
  15. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/navigator.js +0 -80
  16. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/performance.js +0 -28
  17. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/screen.js +0 -31
  18. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/session-storage.js +0 -96
  19. package/template/dist/mp/miniprogram_npm/miniprogram-render/bom/xml-http-request.js +0 -290
  20. package/template/dist/mp/miniprogram_npm/miniprogram-render/document.js +0 -396
  21. package/template/dist/mp/miniprogram_npm/miniprogram-render/event/custom-event.js +0 -12
  22. package/template/dist/mp/miniprogram_npm/miniprogram-render/event/event-target.js +0 -389
  23. package/template/dist/mp/miniprogram_npm/miniprogram-render/event/event.js +0 -186
  24. package/template/dist/mp/miniprogram_npm/miniprogram-render/index.js +0 -41
  25. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/attribute.js +0 -226
  26. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/class-list.js +0 -153
  27. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/comment.js +0 -80
  28. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/a.js +0 -165
  29. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/canvas.js +0 -138
  30. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/image.js +0 -177
  31. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/input.js +0 -181
  32. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/not-support.js +0 -60
  33. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/option.js +0 -126
  34. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/select.js +0 -155
  35. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/textarea.js +0 -178
  36. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/video.js +0 -165
  37. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/wx-component.js +0 -84
  38. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element/wx-custom-component.js +0 -64
  39. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/element.js +0 -970
  40. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/node.js +0 -140
  41. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/style-list.js +0 -28
  42. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/style.js +0 -158
  43. package/template/dist/mp/miniprogram_npm/miniprogram-render/node/text-node.js +0 -127
  44. package/template/dist/mp/miniprogram_npm/miniprogram-render/tree/parser.js +0 -269
  45. package/template/dist/mp/miniprogram_npm/miniprogram-render/tree/query-selector.js +0 -420
  46. package/template/dist/mp/miniprogram_npm/miniprogram-render/tree/tree.js +0 -130
  47. package/template/dist/mp/miniprogram_npm/miniprogram-render/util/cache.js +0 -95
  48. package/template/dist/mp/miniprogram_npm/miniprogram-render/util/pool.js +0 -24
  49. package/template/dist/mp/miniprogram_npm/miniprogram-render/util/tool.js +0 -131
  50. package/template/dist/mp/miniprogram_npm/miniprogram-render/window.js +0 -651
  51. package/template/generator/app/common.js +0 -17
  52. package/template/generator/app/global-api.js +0 -163
  53. package/template/generator/app/handlers.js +0 -13
  54. package/template/generator/datasources/config.js.tpl +0 -21
  55. package/template/generator/datasources/dataset-profiles.js.tpl +0 -5
  56. package/template/generator/datasources/datasource-profiles.js.tpl +0 -4
  57. package/template/generator/datasources/index.js.tpl +0 -14
  58. package/template/generator/handlers/NodeRenderer.jsx +0 -471
  59. package/template/generator/handlers/RenderWrapper.jsx +0 -145
  60. package/template/generator/index.jsx +0 -116
  61. package/template/generator/index.less +0 -120
  62. package/template/generator/pages/app.tpl +0 -181
  63. package/template/generator/pages/composite.tpl +0 -267
  64. package/template/generator/router/index.tpl +0 -49
  65. package/template/generator/store/computed.js +0 -11
  66. package/template/generator/store/index.js +0 -5
  67. package/template/generator/utils/ScanCodeComponent.js +0 -345
  68. package/template/generator/utils/actionHandler.js +0 -119
  69. package/template/generator/utils/common.js +0 -225
  70. package/template/generator/utils/computed.js +0 -9
  71. package/template/generator/utils/date.js +0 -324
  72. package/template/generator/utils/error.jsx +0 -14
  73. package/template/generator/utils/eventProxy.js +0 -64
  74. package/template/generator/utils/history.js +0 -35
  75. package/template/generator/utils/hooks.js +0 -10
  76. package/template/generator/utils/index.js +0 -41
  77. package/template/generator/utils/initGlobalVar.js +0 -14
  78. package/template/generator/utils/lifecycle.js +0 -158
  79. package/template/generator/utils/monitor-jssdk.min.js +0 -881
  80. package/template/generator/utils/page.js +0 -10
  81. package/template/generator/utils/scan-code-action.js +0 -27
  82. package/template/generator/utils/style.js +0 -81
  83. package/template/generator/utils/widgets.js +0 -343
@@ -1,119 +0,0 @@
1
- import { resolveDataBinds } from './common';
2
- import lodashSet from 'lodash.set';
3
-
4
- const DEFAULT_MAX_TIMEOUT = 10 * 1000;
5
-
6
- export function getMetaInfoBySourceKey(sourceKey) {
7
- const [materialName, name] = sourceKey.split(':');
8
- return {
9
- materialName,
10
- name,
11
- };
12
- }
13
-
14
- export function emitEvent(trigger, listeners = [], args, scopeContext = {}) {
15
- const targetListeners = listeners.filter((l) => l.trigger === trigger);
16
- targetListeners.forEach(async (listener) => {
17
- // 当前非捕获Event,再判断冒泡行为
18
- if (!args?.event?.detail?.isCapturePhase && listener.noPropagation) {
19
- args?.domEvent?.stopPropagation && args?.domEvent?.stopPropagation();
20
- }
21
-
22
- // 判断捕获的执行,只有执行的捕获与配置的捕获一致时。才会执行。
23
- if (
24
- (listener?.isCapturePhase || false) ===
25
- (args?.customEventData?.detail?.isCapturePhase || false)
26
- ) {
27
- try {
28
- const res = await invokeListener(listener, args, scopeContext);
29
- const eventName = `${listener.key}.success`;
30
- const event = {
31
- detail: {
32
- value: res,
33
- origin: args.event,
34
- isCapturePhase: !!args.event?.isCapturePhase,
35
- },
36
- name: eventName,
37
- };
38
- emitEvent(
39
- eventName,
40
- listeners,
41
- {
42
- ...args,
43
- event,
44
- customEventData: event,
45
- },
46
- scopeContext
47
- );
48
- } catch (e) {
49
- const eventName = `${listener.key}.fail`;
50
- const event = {
51
- detail: {
52
- value: e,
53
- origin: args.event,
54
- isCapturePhase: !!args.event?.isCapturePhase,
55
- },
56
- name: eventName,
57
- };
58
- emitEvent(
59
- eventName,
60
- listeners,
61
- {
62
- ...args,
63
- event,
64
- customEventData: event,
65
- },
66
- scopeContext
67
- );
68
- // 之前 invoke 内部catch 了错误,不会抛错
69
- // throw e
70
- console.error(`Action error: [${listener.trigger}]`, e);
71
- }
72
- }
73
- });
74
- }
75
-
76
- function invokeListener(
77
- { instanceFunction, data = {}, dataBinds = {} },
78
- args,
79
- scopeContext
80
- ) {
81
- // ToDo resolve databinds
82
- const action = instanceFunction;
83
- const resolvedData = {
84
- ...data,
85
- };
86
- const resolvedDataBinds = resolveDataBinds(
87
- dataBinds,
88
- args.forItems,
89
- { event: args.event },
90
- scopeContext,
91
- true
92
- );
93
-
94
- // eslint-disable-next-line no-restricted-syntax
95
- for (const key in resolvedDataBinds) {
96
- if (
97
- resolvedDataBinds[key] &&
98
- resolvedDataBinds[key].__type === 'scopedValue'
99
- ) {
100
- try {
101
- lodashSet(
102
- resolvedData,
103
- key,
104
- resolvedDataBinds[key].getValue(scopeContext)
105
- );
106
- } catch (e) {
107
- lodashSet(resolvedData, key, '');
108
- }
109
- } else {
110
- lodashSet(resolvedData, key, resolvedDataBinds[key]);
111
- }
112
- }
113
- const params = {
114
- data: resolvedData,
115
- ...args,
116
- };
117
-
118
- return action(params);
119
- }
@@ -1,225 +0,0 @@
1
- /**
2
- * All data bindings are generated as functions: (forItems) => any
3
- * @param {*} dataBinds
4
- * @param {*} forItems
5
- */
6
- export function resolveDataBinds(
7
- dataBinds,
8
- forItems,
9
- codeContext,
10
- scopeContext,
11
- throwError
12
- ) {
13
- const resolvedProps = {};
14
- for (const prop in dataBinds) {
15
- let fn = dataBinds[prop];
16
- try {
17
- if (codeContext && codeContext.$WEAPPS_COMP) {
18
- fn = fn.bind(codeContext.$WEAPPS_COMP);
19
- }
20
- resolvedProps[prop] = fn(
21
- forItems,
22
- codeContext && codeContext.event,
23
- scopeContext
24
- );
25
- } catch (e) {
26
- console.error('Error resolving data binding', prop, dataBinds[prop], e);
27
- if (throwError) {
28
- throw e;
29
- }
30
- }
31
- }
32
- return resolvedProps;
33
- }
34
-
35
- /**
36
- * 对函数进行批量绑定
37
- * @param {*} funcObj
38
- * @param {*} context
39
- */
40
- export function bindFuncObj(funcObj = {}, context) {
41
- return Object.keys(funcObj).reduce((obj, fnName) => {
42
- obj[fnName] = funcObj[fnName].bind(context);
43
- return obj;
44
- }, {});
45
- }
46
-
47
- export function kebabCase(str) {
48
- return str.replace(KEBAB_REGEX, function (match) {
49
- return '-' + match.toLowerCase();
50
- });
51
- }
52
-
53
- export function camelcase(str, firstUpperCase = false) {
54
- str = str.replace(/[_-]([a-z])/g, function (l) {
55
- return l[1].toUpperCase();
56
- });
57
-
58
- if (firstUpperCase) str = str.charAt(0).toUpperCase() + str.slice(1);
59
-
60
- return str;
61
- }
62
-
63
- export const isEmptyObj = (obj) => {
64
- if (!isPlainObject(obj)) {
65
- return false;
66
- }
67
- for (const i in obj) {
68
- if (Object.prototype.hasOwnProperty.call(obj, i)) {
69
- return false;
70
- }
71
- }
72
- return true;
73
- };
74
-
75
- export function isPlainObject(src) {
76
- return Object.prototype.toString.call(src) === '[object Object]';
77
- }
78
-
79
- /**
80
- * 用于处理自定义组件props传参结构,对系统变量进行保留
81
- */
82
- export function resolveComponentProps(props, isPlainProps) {
83
- const { staticResourceAttribute } = props;
84
- staticResourceAttribute &&
85
- staticResourceAttribute.map((property) => {
86
- if (props.data && props.data[property]) {
87
- props.data[property] = getStaticResourceAttribute(props.data[property]);
88
- }
89
- });
90
- if (!isPlainProps) {
91
- return {
92
- ...props,
93
- };
94
- }
95
- const { data = {}, events = [], ...restProps } = props;
96
- const customProps = { ...data };
97
- const builtinProps = [
98
- // react 保留字
99
- 'ref',
100
- 'key',
101
- 'dangerouslySetInnerHTML',
102
- 'className',
103
- 'htmlFor',
104
- 'style',
105
- 'contentEditable',
106
- // lowcode 保留字
107
- 'events',
108
- 'children',
109
- '_parentId',
110
- '_visible',
111
- 'classList',
112
- 'widgetType',
113
- 'getWidgetsByType',
114
- 'getDom',
115
- 'domRef',
116
- 'extends',
117
- // 小程序保留字
118
- 'id',
119
- 'class',
120
- 'hidden',
121
- 'slot',
122
- ];
123
- // delete builtin props
124
- builtinProps.map((prop) => delete customProps[prop]);
125
- // 选区events处理
126
- const { _selectableBlockEvents, ...restData } = data;
127
- const { emit: _selectableBlockEmit } = _selectableBlockEvents;
128
- _selectableBlockEvents.events = new Proxy(
129
- _selectableBlockEvents.events.reduce((events, item) => {
130
- const propName = item;
131
- events[propName] = (e) => _selectableBlockEmit(propName, e);
132
- return events;
133
- }, {}),
134
- {
135
- get(obj, prop) {
136
- return prop in obj ? obj[prop] : (e) => _selectableBlockEmit(prop, e);
137
- },
138
- }
139
- );
140
- return {
141
- ...restData,
142
- ...restProps,
143
- _selectableBlockEvents,
144
- events: new Proxy(
145
- events.reduce((events, item) => {
146
- const propName = item;
147
- events[propName] = (e) => restProps.emit(propName, e);
148
- return events;
149
- }, {}),
150
- {
151
- get(obj, prop) {
152
- return prop in obj ? obj[prop] : (e) => restProps.emit(prop, e);
153
- },
154
- }
155
- ),
156
- };
157
- }
158
-
159
- const SCOPE_SLOT_COMPONENT_LIB = ['tea_basis', 'tea_shop', 'crm_basis'];
160
-
161
- const SCOPE_SLOT_MAP = SCOPE_SLOT_COMPONENT_LIB.reduce((map, lib) => {
162
- map[`${lib}:TableMatching`] = {
163
- headerSlot: true,
164
- recordSlot: true,
165
- };
166
-
167
- map[`${lib}:TableExpanded`] = {
168
- headerSlot: true,
169
- recordSlot: true,
170
- };
171
-
172
- map[`${lib}:TabsTable`] = {
173
- headerSlot: true,
174
- recordSlot: true,
175
- };
176
-
177
- map[`${lib}:Table`] = {
178
- headerSlot: true,
179
- recordSlot: true,
180
- };
181
-
182
- return map;
183
- }, {});
184
-
185
- export function isScopeSlot(comp, slot) {
186
- const { 'x-props': xProps } = comp;
187
- const sourceKey = xProps && xProps.sourceKey;
188
- const map = SCOPE_SLOT_MAP[sourceKey];
189
- return map && map[slot];
190
- }
191
-
192
- export function getStaticResourceAttribute(staticUrl) {
193
- if (/^\//.test(staticUrl)) {
194
- const { domain = '' } = window.app || {};
195
- const url = `https://${domain}${staticUrl}`;
196
- return url;
197
- }
198
- return staticUrl;
199
- }
200
- /**
201
- * 检查页面权限
202
- **/
203
- export async function checkAuth(app, appId, pageId) {
204
- app.showNavigationBarLoading();
205
- const checkAuthResult = await app.cloud.callWedaApi({
206
- action: 'DescribeResourcesPermission',
207
- data: {
208
- ResourceType: `<%= isAdminPortal? 'modelApp' : 'app'%>`,
209
- ResourceIdList: [`${appId}-${pageId}`],
210
- },
211
- });
212
- let isLogin = false;
213
- if (Array.isArray(checkAuthResult) && checkAuthResult.length > 0) {
214
- isLogin = checkAuthResult[0]?.IsAccess ?? false;
215
- }
216
- app.hideNavigationBarLoading();
217
-
218
- if (!isLogin) {
219
- app.showToast({
220
- title: '页面无访问权限',
221
- icon: 'error',
222
- });
223
- }
224
- return isLogin;
225
- }
@@ -1,9 +0,0 @@
1
- export function createComputed(funcs, bindContext = null) {
2
- const obj = {}
3
- for (const name in funcs) {
4
- Object.defineProperty(obj, name, {
5
- get: bindContext ? funcs[name].bind(bindContext) : funcs[name],
6
- })
7
- }
8
- return obj
9
- }
@@ -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,14 +0,0 @@
1
- import React from 'react'
2
-
3
- export function createErrorFallback(cmpKey, id) {
4
- return function ComponentErrorFallback(props) {
5
- return (
6
- <div
7
- style={{ color: 'red', display: 'flex', alignItems: 'center' }}
8
- title={`组件${cmpKey} ${id}发生了错误,错误信息:${props.error}`}
9
- >
10
- {cmpKey}组件错误
11
- </div>
12
- )
13
- }
14
- }