@lingxiteam/ebe-utils 0.0.10 → 0.0.12

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 (93) hide show
  1. package/README.md +6 -0
  2. package/es/index.d.ts +11 -6
  3. package/es/index.js +63 -52
  4. package/es/node/babel/getAllImportFiles.d.ts +1 -1
  5. package/es/node/babel/getAllImportFiles.js +4 -4
  6. package/es/node/move.d.ts +1 -0
  7. package/es/node/move.js +21 -13
  8. package/lib/h5public/src/components/factory/package.json +4 -0
  9. package/lib/h5public/src/components/factory/src/BlockSelect/index.tsx +9 -1
  10. package/lib/h5public/src/components/factory/src/DynamicDataContainer/index.tsx +24 -5
  11. package/lib/h5public/src/components/factory/src/DynamicList/MySwipe/index.tsx +1 -1
  12. package/lib/h5public/src/hooks/usePageForm.ts +108 -4
  13. package/lib/h5public/src/utils/LcdpSpin/index.tsx +15 -3
  14. package/lib/h5public/src/utils/formUtils.ts +336 -0
  15. package/lib/node/babel/getAllImportFiles.d.ts +1 -1
  16. package/lib/node/babel/getAllImportFiles.js +3 -3
  17. package/lib/node/move.d.ts +1 -0
  18. package/lib/node/move.js +19 -8
  19. package/lib/pcpublic/src/components/common/PreviewFile/index.less +200 -0
  20. package/lib/pcpublic/src/components/common/PreviewFile/index.tsx +787 -0
  21. package/lib/pcpublic/src/components/common/PreviewFile/utils.ts +90 -0
  22. package/lib/pcpublic/src/components/pcfactory/package.json +4 -0
  23. package/lib/pcpublic/src/components/pcfactory/src/Audio/index.tsx +6 -6
  24. package/lib/pcpublic/src/components/pcfactory/src/Cascader/index.tsx +15 -0
  25. package/lib/pcpublic/src/components/pcfactory/src/Checkbox/index.tsx +2 -2
  26. package/lib/pcpublic/src/components/pcfactory/src/DynamicDataContainer/index.tsx +301 -0
  27. package/lib/pcpublic/src/components/pcfactory/src/DynamicDataContainer/useDynamicDataContainer.ts +27 -0
  28. package/lib/pcpublic/src/components/pcfactory/src/Form/Form.tsx +1 -0
  29. package/lib/pcpublic/src/components/pcfactory/src/GridView/GridView.tsx +1 -1
  30. package/lib/pcpublic/src/components/pcfactory/src/Img/assets/placeholder.png +0 -0
  31. package/lib/pcpublic/src/components/pcfactory/src/Input/index.tsx +1 -1
  32. package/lib/pcpublic/src/components/pcfactory/src/LoopList/index.tsx +1 -1
  33. package/lib/pcpublic/src/components/pcfactory/src/ModalSelect/index.tsx +1 -1
  34. package/lib/pcpublic/src/components/pcfactory/src/PictureVerifyCode/assets/placeholder.png +0 -0
  35. package/lib/pcpublic/src/components/pcfactory/src/PictureVerifyCode/index.tsx +6 -6
  36. package/lib/pcpublic/src/components/pcfactory/src/QuillEditor/index.tsx +11 -0
  37. package/lib/pcpublic/src/components/pcfactory/src/RemoteComponent/components/ReactRender.tsx +5 -1
  38. package/lib/pcpublic/src/components/pcfactory/src/RemoteComponent/constant.ts +36 -0
  39. package/lib/pcpublic/src/components/pcfactory/src/RemoteComponent/index.tsx +28 -16
  40. package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/RichTextEditor.tsx +12 -5
  41. package/lib/pcpublic/src/components/pcfactory/src/Select/index.tsx +65 -39
  42. package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/default.png +0 -0
  43. package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/js.png +0 -0
  44. package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/pdf.png +0 -0
  45. package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/ppt.png +0 -0
  46. package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/txt.png +0 -0
  47. package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/word.png +0 -0
  48. package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/xls.png +0 -0
  49. package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/zip.png +0 -0
  50. package/lib/pcpublic/src/components/pcfactory/src/StdUpload/index.tsx +11 -1
  51. package/lib/pcpublic/src/components/pcfactory/src/SuperSelect/ComSelect.tsx +1 -2
  52. package/lib/pcpublic/src/components/pcfactory/src/Table/TableSummaryRow/index.tsx +8 -1
  53. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useCMDActions.ts +4 -4
  54. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useColumns.tsx +91 -34
  55. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSelection.ts +22 -11
  56. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSummaryCol.ts +51 -8
  57. package/lib/pcpublic/src/components/pcfactory/src/Table/index.tsx +28 -6
  58. package/lib/pcpublic/src/components/pcfactory/src/Table/types/bodyCell.d.ts +22 -0
  59. package/lib/pcpublic/src/components/pcfactory/src/Table/types/contentStyle.d.ts +41 -0
  60. package/lib/pcpublic/src/components/pcfactory/src/Table/types/event.d.ts +129 -0
  61. package/lib/pcpublic/src/components/pcfactory/src/Table/types/headerCell.d.ts +37 -0
  62. package/lib/pcpublic/src/components/pcfactory/src/Table/types/prop.d.ts +301 -0
  63. package/lib/pcpublic/src/components/pcfactory/src/Table/utils/index.ts +83 -31
  64. package/lib/pcpublic/src/components/pcfactory/src/Table/utils/indexedDBHelper.ts +119 -0
  65. package/lib/pcpublic/src/components/pcfactory/src/Transfer/index.tsx +8 -3
  66. package/lib/pcpublic/src/components/pcfactory/src/Tree/index.tsx +4 -1
  67. package/lib/pcpublic/src/components/pcfactory/src/TreeSelect/index.tsx +12 -1
  68. package/lib/pcpublic/src/components/pcfactory/src/TreeTable/index.tsx +28 -3
  69. package/lib/pcpublic/src/components/pcfactory/src/VerificationCode/assets/placeholder.png +0 -0
  70. package/lib/pcpublic/src/components/pcfactory/src/VerificationCode/index.tsx +6 -6
  71. package/lib/pcpublic/src/components/pcfactory/src/VideoPlayer/index.tsx +12 -12
  72. package/lib/pcpublic/src/components/pcfactory/src/View/index.tsx +18 -4
  73. package/lib/pcpublic/src/components/pcfactory/src/index.component.ts +3 -0
  74. package/lib/pcpublic/src/components/pcfactory/src/styles/common.less +6 -1
  75. package/lib/pcpublic/src/components/pcfactory/src/styles/components/Form.less +4 -0
  76. package/lib/pcpublic/src/components/pcfactory/src/styles/components/Input.less +3 -0
  77. package/lib/pcpublic/src/components/pcfactory/src/styles/components/InputNumber.less +1 -1
  78. package/lib/pcpublic/src/components/pcfactory/src/styles/components/ModalSelect.less +3 -0
  79. package/lib/pcpublic/src/components/pcfactory/src/styles/components/Table.less +5 -0
  80. package/lib/pcpublic/src/components/pcfactory/src/utils/DummyFormContext.ts +2 -2
  81. package/lib/pcpublic/src/components/pcfactory/src/utils/Empty/empty.tsx +29 -28
  82. package/lib/pcpublic/src/components/pcfactory/src/utils/Empty/index.tsx +36 -0
  83. package/lib/pcpublic/src/components/pcfactory/src/utils/Spin/index.tsx +29 -0
  84. package/lib/pcpublic/src/components/pcfactory/src/utils/common.ts +18 -2
  85. package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/FormContext.tsx +10 -0
  86. package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/FormFields.tsx +10 -5
  87. package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/common.ts +46 -0
  88. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useCompState.tsx +44 -0
  89. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useLocale.ts +1 -0
  90. package/lib/pcpublic/src/utils/formUtils.ts +458 -0
  91. package/lib/public/src/components/WaterMark/index.tsx +1 -1
  92. package/lib/public/src/services/api/index.ts +7 -0
  93. package/package.json +2 -2
@@ -2,8 +2,20 @@ import { DotLoading, type DotLoadingProps } from 'antd-mobile-5';
2
2
  import React from 'react';
3
3
  import './index.less';
4
4
 
5
- const LcdpSpin: React.FC<DotLoadingProps> = (props) => (
6
- <DotLoading {...props} className="lcdp-dynamicPage-spinning-mask" />
7
- );
5
+ interface LcdpSpinProps extends DotLoadingProps {
6
+ spinning: boolean;
7
+ }
8
+
9
+ const LcdpSpin: React.FC<LcdpSpinProps> = (props) => {
10
+ const { spinning = true, ...restProps } = props;
11
+
12
+ if (!spinning) {
13
+ return null;
14
+ }
15
+
16
+ return (
17
+ <DotLoading {...restProps} className="lcdp-dynamicPage-spinning-mask" />
18
+ );
19
+ };
8
20
 
9
21
  export default LcdpSpin;
@@ -0,0 +1,336 @@
1
+ import { RefsManager } from '@/utils/Context/context';
2
+
3
+ type RefsType = Record<string, any>;
4
+
5
+ export const formSubmit = async (form: RefsType, isFormList?: boolean) =>
6
+ new Promise((resolve, reject) => {
7
+ form.submit(resolve, reject, isFormList);
8
+ });
9
+
10
+ export const formCodeSubmit = async (form: Record<string, any>) =>
11
+ new Promise(form.submitByCode);
12
+
13
+ export const getFieldsValueByCode = (form: Record<string, any>) =>
14
+ new Promise(form.getFieldsValueByCode);
15
+
16
+ /**
17
+ * 通过组件id获取所有的组件
18
+ * @param options
19
+ * @returns
20
+ */
21
+ export const getComponentsByCompId = (options: {
22
+ compId: string;
23
+ refs: RefsType;
24
+ }) => {
25
+ const { refs, compId } = options;
26
+ return Object.keys(refs)
27
+ .filter((uid) => refs[uid]?.compId === compId)
28
+ .map((uid) => refs[uid]);
29
+ };
30
+
31
+ /**
32
+ * 通过业务组件id获取表单列表
33
+ * @param engineRelation
34
+ * @param routerId
35
+ * @param uid
36
+ * @returns
37
+ */
38
+ export const getFormsByBoframerId = (options: {
39
+ renderRefs: RefsManager;
40
+ compId: string;
41
+ refs: RefsType;
42
+ }) => {
43
+ const { renderRefs, compId, refs } = options;
44
+ const boframerUids = Object.keys(refs).filter(
45
+ (id) => refs[id].compId === compId,
46
+ );
47
+
48
+ // 如果没找到组件,就返回null
49
+ if (!boframerUids.length) {
50
+ return [];
51
+ }
52
+
53
+ const forms: RefsType[] = [];
54
+ const getAllForms = (refs: RefsType | null) => {
55
+ Object.keys(refs || {}).forEach((uid) => {
56
+ // const engineRef = engineRelation.getEngineRefsByUid(uid, routerId);
57
+ const renderId = uid;
58
+ if (renderId) {
59
+ const engineRefs = renderRefs.getComRefs(renderId);
60
+ if (engineRefs) {
61
+ Object.keys(engineRefs).forEach((compUid) => {
62
+ const r = engineRefs[compUid];
63
+ getAllForms(r);
64
+ if (r.compName === 'Form' && !r.isFormList) {
65
+ forms.push(r);
66
+ }
67
+ });
68
+ }
69
+ }
70
+ });
71
+ };
72
+
73
+ getAllForms(
74
+ boframerUids.reduce((pre, uid) => {
75
+ pre[uid] = refs[uid];
76
+ return pre;
77
+ }, {} as RefsType),
78
+ );
79
+
80
+ return forms;
81
+ };
82
+
83
+ /**
84
+ * 通过内部组件内的表单列表获取表单值
85
+ * @param forms
86
+ * @param getFieldsValue
87
+ * FIXME: 若需要兼容表单切套在循环列表的情况,可以修改本方法
88
+ */
89
+ export const getBoframerValueByForms = async (forms: RefsType[] = []) => {
90
+ const errorValues: Record<string, any> = {};
91
+
92
+ try {
93
+ const values = await Promise.all(forms.map((form) => formSubmit(form)));
94
+ return values.reduce((pre, item) => Object.assign(pre as any, item), {});
95
+ } catch (error) {
96
+ const { errorFields, values } = (error || {}) as any;
97
+ if (Array.isArray(errorFields)) {
98
+ return {
99
+ errorFields: [...(errorValues.errorFields || []), ...errorFields],
100
+ values: {
101
+ ...(errorValues.values || {}),
102
+ ...(values || {}),
103
+ },
104
+ };
105
+ }
106
+ }
107
+ };
108
+
109
+ /**
110
+ * 通过表单列表获取表单值
111
+ * @param forms
112
+ * @param getFieldsValue
113
+ * FIXME: 若需要兼容表单切套在循环列表的情况,可以修改本方法
114
+ */
115
+ export const getFormsValueByForms = async (forms: RefsType[] = []) => {
116
+ const errorValues: Record<string, any> = {};
117
+
118
+ try {
119
+ const values = await Promise.all(forms.map((form) => formSubmit(form)));
120
+ return values.reduce((pre, item) => Object.assign(pre as any, item), {});
121
+ } catch (error) {
122
+ const { errorFields, values } = (error || {}) as any;
123
+ if (Array.isArray(errorFields)) {
124
+ return {
125
+ errorFields: [...(errorValues.errorFields || []), ...errorFields],
126
+ values: {
127
+ ...(errorValues.values || {}),
128
+ ...(values || {}),
129
+ },
130
+ };
131
+ }
132
+ }
133
+ };
134
+
135
+ /**
136
+ * 通过业务组件id获取表单值,
137
+ * 注:所有表单的值不走formCode逻辑。 若同一个业务组件中多个表单则将所有表单放到一起
138
+ * @param options
139
+ * @returns
140
+ */
141
+ export const getFormValueByBOFramerId = async (options: {
142
+ refs: RefsType;
143
+ renderRefs: RefsManager;
144
+ compId: string;
145
+ }) => {
146
+ const forms = getFormsByBoframerId(options);
147
+ return getBoframerValueByForms(forms);
148
+ };
149
+
150
+ /**
151
+ * 通过表单id 获取表单值
152
+ * @param options
153
+ * @returns
154
+ */
155
+ export const getFormValueByFormId = async (options: {
156
+ refs: RefsType;
157
+ compId: string;
158
+ }) => {
159
+ const { compId, refs } = options;
160
+ const formUids = Object.keys(refs).filter((id) => refs[id].compId === compId);
161
+
162
+ // 如果没找到组件,就返回null
163
+ if (!formUids.length) {
164
+ return [];
165
+ }
166
+
167
+ return getFormsValueByForms(formUids.map((uid) => refs[uid]));
168
+ };
169
+
170
+ /**
171
+ * 通过组件名 获取所有表单
172
+ * @param options
173
+ * @returns
174
+ */
175
+ export const getFormsByCompName = (
176
+ options: {
177
+ refs: RefsType;
178
+ renderRefs: RefsManager;
179
+ },
180
+ forms: any[] = [],
181
+ ) => {
182
+ const { refs, renderRefs } = options;
183
+
184
+ Object.keys(refs).forEach((uid) => {
185
+ const item = refs[uid];
186
+ if (!item) return;
187
+ if (item.compName === 'DForm') {
188
+ forms.push(item);
189
+ }
190
+ if (['Pageview', 'BOFramer'].includes(item.compName)) {
191
+ getFormsByCompName(renderRefs.getComRefs(uid));
192
+ }
193
+ });
194
+
195
+ return forms;
196
+ };
197
+
198
+ /**
199
+ * 校验并获取表单值
200
+ */
201
+ export const validateFields = async (
202
+ options: {
203
+ refs: RefsType;
204
+ renderRefs: RefsManager;
205
+ },
206
+ getFormValue: (form: Record<string, any>) => Promise<any>,
207
+ ) => {
208
+ const forms = getFormsByCompName(options);
209
+ const actions: any = forms.map(getFormValue);
210
+ const formValues: any = {};
211
+ const values = await Promise.all(actions);
212
+ values.forEach((val = {}) => {
213
+ Object.keys(val || {}).forEach((key) => {
214
+ const isIncludesKey = Object.keys(formValues).includes(key);
215
+ if (isIncludesKey) {
216
+ Object.assign(formValues[key], { ...(val[key] || {}) });
217
+ } else {
218
+ Object.assign(formValues, { [key]: val[key] });
219
+ }
220
+ });
221
+ });
222
+ return values;
223
+ };
224
+
225
+ // // eslint-disable-next-line max-len
226
+ // export const formSubmit = async (form: { submit: (arg0: (value: unknown) => void, arg1: (reason?: any) => void, arg2: any) => void; }, isFormList?: boolean) =>
227
+ // new Promise((resolve, reject) => {
228
+ // form.submit(resolve, reject, isFormList);
229
+ // });
230
+
231
+ // const collectFomrms = (engineRelation: EngineRelationMethods, forms: any[], routerId: string, refs: any) => {
232
+ // Object.keys(refs)?.forEach((key) => {
233
+ // const comRef = refs[key];
234
+ // if (
235
+ // comRef?.compName === 'DForm' &&
236
+ // typeof comRef.submit === 'function' &&
237
+ // !comRef?.isFormList
238
+ // ) {
239
+ // forms.push(comRef);
240
+ // } else if (comRef?.compName === 'Pageview' || comRef?.compName === 'BOFramer') {
241
+ // const subRefs = engineRelation.getEngineRefsByUid(key, routerId)?.refs;
242
+ // if (subRefs) {
243
+ // collectFomrms(engineRelation, forms, routerId, subRefs);
244
+ // }
245
+ // }
246
+ // });
247
+ // };
248
+ // export const getBOFramerForms = (engineRelation: EngineRelationMethods, routerId: string, uid: string) => {
249
+ // const boframerRef = engineRelation.getEngineRefsByUid(uid, routerId)?.refs;
250
+ // const forms: any[] = [];
251
+ // collectFomrms(engineRelation, forms, routerId, boframerRef);
252
+ // return forms;
253
+ // };
254
+
255
+ // // eslint-disable-next-line max-len
256
+ // export const boFramersubmit = async (onSuccess: (arg0: {}) => void, onFail: (arg0: {}) => void, engineRelation: EngineRelationMethods, routerId: string, uid: string) => {
257
+ // const forms = getBOFramerForms(engineRelation, routerId, uid);
258
+ // const formValues = {};
259
+ // const errorValues: Record<string, any> = {};
260
+ // // eslint-disable-next-line no-plusplus
261
+ // for (let index = 0; index < forms.length; index++) {
262
+ // const inForm = forms[index];
263
+ // try {
264
+ // const values = await formSubmit(inForm);
265
+ // Object.assign(formValues, values);
266
+ // } catch (error) {
267
+ // const { errorFields, values } = (error || {}) as any;
268
+ // if (Array.isArray(errorFields)) {
269
+ // errorValues.errorFields = [
270
+ // ...(errorValues.errorFields || []),
271
+ // ...errorFields,
272
+ // ];
273
+ // errorValues.values = {
274
+ // ...(errorValues.values || {}),
275
+ // ...(values || {}),
276
+ // };
277
+ // }
278
+ // }
279
+ // }
280
+ // if (Object.keys(errorValues).length > 0) {
281
+ // onFail(errorValues);
282
+ // return;
283
+ // }
284
+ // onSuccess(formValues);
285
+ // };
286
+
287
+ // export const boFramerResetFields = (engineRelation: EngineRelationMethods, routerId: string, uid: string) => {
288
+ // const forms = getBOFramerForms(engineRelation, routerId, uid);
289
+ // forms.forEach(form => {
290
+ // form?.resetFields();
291
+ // });
292
+ // };
293
+
294
+ // export const boFramerSetFieldsValue = (engineRelation: EngineRelationMethods, routerId: string, uid: string, v: any) =>
295
+ // getBOFramerForms(engineRelation, routerId, uid)?.forEach(form => {
296
+ // form?.setFieldsValue(v);
297
+ // });
298
+
299
+ // // eslint-disable-next-line max-len
300
+ // export const boFramerGetFieldsValue = async (onSuccess: (arg0: {}) => void, onFail: (arg0: {}) => void, engineRelation: EngineRelationMethods, routerId: string, uid: string,) => {
301
+ // const forms = getBOFramerForms(engineRelation, routerId, uid);
302
+ // const formValues = {};
303
+ // const errorValues: Record<string, any> = {};
304
+ // // eslint-disable-next-line no-plusplus
305
+ // for (let index = 0; index < forms.length; index++) {
306
+ // const inForm = forms[index];
307
+ // let errs: any = {};
308
+ // try {
309
+ // const values = await inForm.getFieldsValue();
310
+ // Object.assign(formValues, values);
311
+ // } catch (error) {
312
+ // errs = error;
313
+ // } finally {
314
+ // const { errorFields, values } = errs;
315
+ // if (Array.isArray(errorFields)) {
316
+ // errorValues.errorFields = [
317
+ // ...(errorValues.errorFields || []),
318
+ // ...errorFields,
319
+ // ];
320
+ // errorValues.values = {
321
+ // ...(errorValues.values || {}),
322
+ // ...(values || {}),
323
+ // };
324
+ // }
325
+ // }
326
+ // }
327
+ // if (Object.keys(errorValues).length > 0) {
328
+ // onFail(errorValues);
329
+ // return;
330
+ // }
331
+ // onSuccess(formValues);
332
+ // };
333
+
334
+ // export const boFramerSetDisabled = (engineRelation: EngineRelationMethods, routerId: string, uid: string, v: any) => {
335
+ // return getBOFramerForms(engineRelation, routerId, uid).forEach(form => form?.setDisabled(v));
336
+ // };
@@ -1 +1 @@
1
- export declare const getAllImportFiles: (target: string, allImportFiles?: any) => any;
1
+ export declare const getAllImportFiles: (cwd: string, target: string, allImportFiles?: any) => any;
@@ -37,7 +37,7 @@ var import_fs = require("fs");
37
37
  var import_path = require("path");
38
38
  var import_getRealPath = require("./getRealPath");
39
39
  var import_parse = require("./parse");
40
- var getAllImportFiles = (target, allImportFiles = {}) => {
40
+ var getAllImportFiles = (cwd, target, allImportFiles = {}) => {
41
41
  var _a;
42
42
  if (!(0, import_fs.existsSync)(target)) {
43
43
  return allImportFiles;
@@ -53,12 +53,12 @@ var getAllImportFiles = (target, allImportFiles = {}) => {
53
53
  if (isAlias || isRelative) {
54
54
  let nextPath = (0, import_path.resolve)((0, import_path.dirname)(target), importName);
55
55
  if (isAlias) {
56
- nextPath = importName.replace("@/", `${process.cwd()}/src/`);
56
+ nextPath = importName.replace("@/", `${cwd}/src/`);
57
57
  }
58
58
  let nextTarget = (0, import_getRealPath.getRealPath)(nextPath);
59
59
  if (!allImportFiles[nextTarget]) {
60
60
  allImportFiles[nextTarget] = true;
61
- getAllImportFiles(nextTarget, allImportFiles);
61
+ getAllImportFiles(cwd, nextTarget, allImportFiles);
62
62
  }
63
63
  }
64
64
  };
@@ -1,5 +1,6 @@
1
1
  export interface MoveConfig {
2
2
  target: string;
3
3
  outDir: string;
4
+ cwd?: string;
4
5
  }
5
6
  export declare function move(moveConfig: MoveConfig): Promise<any>;
package/lib/node/move.js CHANGED
@@ -25,25 +25,24 @@ module.exports = __toCommonJS(move_exports);
25
25
  var import_fs_extra = require("fs-extra");
26
26
  var import_path = require("path");
27
27
  var import_getAllImportFiles = require("./babel/getAllImportFiles");
28
- var copyFileSyncAlias = (from, to) => {
28
+ var copyFileSyncAlias = (cwd, from, to) => {
29
29
  var _a;
30
30
  let context = (0, import_fs_extra.readFileSync)(from, "utf-8");
31
31
  const importList = ((_a = context.match(/from '@\/([^']+)'/g)) == null ? void 0 : _a.map((match) => match.slice(8, -1))) || [];
32
32
  importList.forEach((source) => {
33
- const absolute = (0, import_path.join)(process.cwd(), "src", source);
33
+ const absolute = (0, import_path.join)(cwd, "src", source);
34
34
  const filePath = (0, import_path.relative)((0, import_path.dirname)(from), absolute);
35
35
  context = context.replace(`@/${source}`, filePath);
36
36
  });
37
37
  (0, import_fs_extra.writeFileSync)(to, context, "utf-8");
38
38
  };
39
39
  async function move(moveConfig) {
40
- const { target, outDir } = moveConfig;
41
- const cwd = process.cwd();
40
+ const { target, outDir, cwd = process.cwd() } = moveConfig;
42
41
  const resolvedTarget = (0, import_path.isAbsolute)(target) ? target : (0, import_path.join)(cwd, target);
43
42
  if (!(0, import_fs_extra.existsSync)(resolvedTarget)) {
44
- throw new Error(`指定的文件不存在: ${resolvedTarget}`);
43
+ throw new Error(`指定的入口文件不存在: ${resolvedTarget}`);
45
44
  }
46
- const allImportFiles = (0, import_getAllImportFiles.getAllImportFiles)(resolvedTarget);
45
+ const allImportFiles = (0, import_getAllImportFiles.getAllImportFiles)(cwd, resolvedTarget);
47
46
  allImportFiles[resolvedTarget] = true;
48
47
  const keys = Object.keys(allImportFiles);
49
48
  let count = keys.length;
@@ -54,11 +53,23 @@ async function move(moveConfig) {
54
53
  return;
55
54
  }
56
55
  const filePath = (0, import_path.relative)(cwd, file);
57
- const absTarget = (0, import_path.join)(cwd, outDir, filePath);
56
+ const absTarget = (0, import_path.isAbsolute)(outDir) ? (0, import_path.join)(outDir, filePath) : (0, import_path.join)(cwd, outDir, filePath);
58
57
  (0, import_fs_extra.mkdirpSync)((0, import_path.dirname)(absTarget));
59
- copyFileSyncAlias(file, absTarget);
58
+ copyFileSyncAlias(cwd, file, absTarget);
60
59
  });
61
60
  console.log(`[COPY] 共拷贝文件数 ${count}`);
61
+ const pkg = (0, import_path.join)(cwd, "package.json");
62
+ if ((0, import_fs_extra.existsSync)(pkg)) {
63
+ let context = (0, import_fs_extra.readJSONSync)(pkg, "utf-8");
64
+ (0, import_fs_extra.writeJSONSync)(
65
+ (0, import_path.join)(outDir, "package.json"),
66
+ {
67
+ name: context.name,
68
+ version: context.version
69
+ },
70
+ "utf-8"
71
+ );
72
+ }
62
73
  }
63
74
  // Annotate the CommonJS export names for ESM import in node:
64
75
  0 && (module.exports = {
@@ -0,0 +1,200 @@
1
+ @import (reference) '../../../styles/index.less';
2
+
3
+ @prefixCls: lcdp-previewFile;
4
+
5
+ .@{prefixCls}-wrapPic {
6
+ display: flex;
7
+ align-items: center;
8
+ /*垂直居中*/
9
+ justify-content: center;
10
+ /*水平居中*/
11
+ height: auto !important;
12
+ }
13
+
14
+ .@{prefixCls}-wrap {
15
+ display: flex;
16
+ flex: 1;
17
+ align-items: center;
18
+ flex-direction: column;
19
+ justify-content: center;
20
+ width: 100%;
21
+ height: 100%;
22
+ overflow: auto;
23
+
24
+ .content {
25
+ width: fit-content;
26
+ display: flex;
27
+ justify-content: center;
28
+ }
29
+
30
+ .txt {
31
+ max-width: 70vw;
32
+ max-height: 70vh;
33
+
34
+ .code {
35
+ height: 100%;
36
+ padding: 10px;
37
+ overflow-y: auto;
38
+ background-color: #fff;
39
+ border: 1px solid rgba(0, 0, 0, 0.15);
40
+ }
41
+ }
42
+
43
+ .ppt {
44
+ text-align: center;
45
+ align-items: center;
46
+
47
+ img {
48
+ height: fit-content;
49
+ }
50
+ }
51
+
52
+ .error {
53
+ text-align: center;
54
+ color: #fff;
55
+
56
+ .error-title {
57
+ font-size: 24px;
58
+ font-weight: bold;
59
+ margin-bottom: 16px;
60
+ }
61
+
62
+ .error-tip {
63
+ font-size: 16px;
64
+ }
65
+ }
66
+
67
+ .iframe {
68
+ height: 80vh;
69
+ width: 50vw;
70
+ border: medium none;
71
+ background-color: white;
72
+ }
73
+
74
+ .preview_content {
75
+ width: 100%;
76
+ height: 100%;
77
+ padding: 30px 0;
78
+ display: flex;
79
+ justify-content: center;
80
+ }
81
+
82
+ .pdf-container {
83
+ display: flex;
84
+ flex-direction: column;
85
+ align-items: center;
86
+ padding: 30px 0;
87
+ overflow: hidden;
88
+
89
+ .pdf-loading {
90
+ width: 50px;
91
+ height: 50px;
92
+ }
93
+
94
+ .react-pdf__Document {
95
+ max-width: 100%;
96
+ height: 100%;
97
+ margin: 0 auto;
98
+ overflow: auto;
99
+ }
100
+
101
+ .react-pdf__Page__textContent {
102
+ display: none;
103
+ }
104
+
105
+ .react-pdf__Page__annotations {
106
+ display: none;
107
+ }
108
+
109
+ .pdf-content {
110
+ display: flex;
111
+ flex: 1;
112
+ flex-direction: column;
113
+ align-items: center;
114
+ justify-content: center;
115
+ }
116
+ }
117
+
118
+ .@{prefixCls}-group {
119
+ display: flex;
120
+ align-items: center;
121
+ padding: 13px 0;
122
+
123
+ &:empty {
124
+ display: none;
125
+ }
126
+
127
+ &:last-child {
128
+ padding-right: 32px;
129
+ }
130
+
131
+ &:first-child {
132
+ padding-left: 32px;
133
+ }
134
+
135
+ &:not(:last-child) {
136
+ &::after {
137
+ content: '';
138
+ display: flex;
139
+ width: 1px;
140
+ height: 14px;
141
+ margin: 0 16px;
142
+ background-color: #fff;
143
+ }
144
+ }
145
+ }
146
+ }
147
+
148
+ .@{prefixCls} {
149
+ &-zip-select {
150
+ color: white;
151
+ width: 256px;
152
+ overflow: hidden;
153
+ display: flex;
154
+ align-items: center;
155
+ cursor: pointer;
156
+ }
157
+
158
+ &-zip-select-label {
159
+ flex: 1;
160
+ overflow: hidden;
161
+ overflow: hidden;
162
+ text-overflow: ellipsis;
163
+ white-space: nowrap;
164
+ }
165
+
166
+ &-dropdown {
167
+ margin-bottom: 12px;
168
+ border-radius: @border-radius-base;
169
+ max-width: 65vw;
170
+ overflow: auto;
171
+
172
+ .@{ant-prefix}-cascader-menu-item-content {
173
+ display: inline-block;
174
+ flex: 1;
175
+ overflow: hidden;
176
+ max-width: 128px;
177
+ white-space: nowrap;
178
+ text-overflow: ellipsis;
179
+ }
180
+
181
+ .@{ant-prefix}-cascader-menu {
182
+ padding: 4px;
183
+
184
+ &-item {
185
+ border-radius: @border-radius-base;
186
+ }
187
+ }
188
+
189
+ .@{ant-prefix}-cascader-menus
190
+ .@{ant-prefix}-cascader-menu-item-active:not(
191
+ .@{ant-prefix}-cascader-menus .@{ant-prefix}-cascader-menu-item-disabled
192
+ ) {
193
+ background-color: fade(@primary-color, 8%);
194
+ }
195
+ }
196
+
197
+ &-error-tips {
198
+ font-size: @font-size-md;
199
+ }
200
+ }