@para-ui/core 4.0.33 → 4.0.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 (150) hide show
  1. package/Anchor/anchorMenu/index.d.ts +16 -0
  2. package/Anchor/index.d.ts +4 -0
  3. package/Anchor/index.js +394 -0
  4. package/Anchor/lang/en_US.d.ts +4 -0
  5. package/Anchor/lang/index.d.ts +9 -0
  6. package/Anchor/lang/zh_CN.d.ts +4 -0
  7. package/Anchor/type.d.ts +42 -0
  8. package/Argv/batchEdit/index.d.ts +18 -0
  9. package/Argv/dataGenerator/config.d.ts +16 -0
  10. package/Argv/dataGenerator/index.d.ts +24 -0
  11. package/Argv/index.d.ts +36 -0
  12. package/Argv/index.js +738 -0
  13. package/Argv/lang/en_US.d.ts +15 -0
  14. package/Argv/lang/index.d.ts +31 -0
  15. package/Argv/lang/zh_CN.d.ts +15 -0
  16. package/AutoBox/index.js +1 -1
  17. package/AutoButton/index.js +1 -1
  18. package/AutoTips/index.js +1 -1
  19. package/Breadcrumbs/index.js +1 -1
  20. package/Button/index.d.ts +2 -2
  21. package/Button/index.js +4 -4
  22. package/ButtonGroup/index.d.ts +4 -0
  23. package/ButtonGroup/index.js +53 -37
  24. package/Card/index.js +3 -3
  25. package/Carousel/index.js +1 -1
  26. package/Cascader/index.js +6 -7
  27. package/Checkbox/index.js +1 -1
  28. package/CheckboxGroup/index.js +1 -1
  29. package/ComboSelect/index.js +7 -8
  30. package/CopyText/index.js +1 -1
  31. package/CycleSelector/index.js +2 -5
  32. package/DatePicker/index.js +2 -5
  33. package/Descriptions/index.js +1 -1
  34. package/Desktop/index.js +1 -1
  35. package/DragVerify/index.js +1 -1
  36. package/Drawer/index.js +1 -1
  37. package/DynamicMultiBox/index.js +7 -8
  38. package/Form/index.js +7 -8
  39. package/FormItem/index.js +7 -8
  40. package/FunctionModal/index.js +3 -3
  41. package/Help/index.js +1 -1
  42. package/Image/index.js +3 -4
  43. package/InputCode/index.js +1 -1
  44. package/InputLang/index.js +1 -1
  45. package/InputNumber/index.js +1 -1
  46. package/Label/index.js +1 -1
  47. package/Menu/index.js +1 -1
  48. package/Modal/index.js +1 -1
  49. package/MultiBox/index.js +1 -1
  50. package/OperateBtn/index.js +1 -1
  51. package/PageHeader/index.js +1 -1
  52. package/Pagination/index.js +1 -1
  53. package/PopConfirm/index.js +1 -1
  54. package/PopMenu/index.js +1 -1
  55. package/Popover/index.js +1 -1
  56. package/Progress/index.js +1 -1
  57. package/Querying/index.js +4 -4
  58. package/QuickReply/index.js +2 -2
  59. package/README.md +24 -0
  60. package/Radio/index.js +1 -1
  61. package/RadioGroup/index.js +1 -1
  62. package/RangeInput/index.js +1 -1
  63. package/Search/index.js +1 -1
  64. package/Select/index.js +1 -1
  65. package/SelectInput/index.js +1 -1
  66. package/Selector/index.js +276 -322
  67. package/Selector/interface.d.ts +2 -1
  68. package/SelectorPicker/index.js +5 -5
  69. package/SingleBox/index.js +3 -3
  70. package/Slider/index.js +1 -1
  71. package/SortBox/index.js +1 -1
  72. package/Stepper/index.js +2 -2
  73. package/Switch/index.js +3 -3
  74. package/Table/index.js +424 -489
  75. package/Tabs/index.js +3 -3
  76. package/Tag/index.js +54 -83
  77. package/TextEditor/index.js +1 -1
  78. package/TextField/index.js +1 -1
  79. package/TimePicker/index.js +2 -5
  80. package/Timeline/index.js +21 -15
  81. package/Title/index.js +1 -1
  82. package/ToggleButton/ToggleButtonGroup.d.ts +4 -2
  83. package/ToggleButton/index.d.ts +4 -3
  84. package/ToggleButton/index.js +28 -13
  85. package/Tooltip/index.js +1 -1
  86. package/Transfer/index.js +1 -1
  87. package/Tree/index.js +6 -7
  88. package/Upload/index.js +83 -28
  89. package/Upload/interface.d.ts +4 -0
  90. package/Upload/util.d.ts +32 -0
  91. package/Utils/index.d.ts +7 -0
  92. package/Utils/index.js +10 -1
  93. package/Utils/type.d.ts +1 -0
  94. package/_verture/{Portal-edd94cac.js → Portal-42560ff0.js} +1 -2
  95. package/_verture/{defineProperty-6f62bb2a.js → defineProperty-f0e15205.js} +10 -2
  96. package/_verture/{index-8752ccab.js → index-086e9a6d.js} +4 -5
  97. package/_verture/{index-567b5779.js → index-5f0bfdcf.js} +3 -4
  98. package/_verture/{index-94e24006.js → index-8ac46bd9.js} +1 -1
  99. package/_verture/{modalContext-10f0c5aa.js → modalContext-205db1f4.js} +1 -1
  100. package/_verture/{tslib.es6-55ed4bd2.js → tslib.es6-f43aa41d.js} +1 -1
  101. package/index.d.ts +4 -0
  102. package/index.js +26 -22
  103. package/locale/en-US.d.ts +17 -0
  104. package/locale/index.d.ts +34 -0
  105. package/locale/index.js +34 -0
  106. package/locale/zh-CN.d.ts +17 -0
  107. package/package.json +8 -5
  108. package/umd/Anchor.js +43 -0
  109. package/umd/Argv.js +43 -0
  110. package/umd/AutoButton.js +1 -1
  111. package/umd/Button.js +1 -1
  112. package/umd/ButtonGroup.js +5 -5
  113. package/umd/ComboSelect.js +2 -2
  114. package/umd/CopyText.js +3 -3
  115. package/umd/CycleSelector.js +3 -3
  116. package/umd/DatePicker.js +1 -1
  117. package/umd/Descriptions.js +1 -1
  118. package/umd/Desktop.js +3 -3
  119. package/umd/Drawer.js +1 -1
  120. package/umd/DynamicMultiBox.js +3 -3
  121. package/umd/Form.js +2 -2
  122. package/umd/FormItem.js +3 -3
  123. package/umd/FunctionModal.js +1 -1
  124. package/umd/InputCode.js +3 -3
  125. package/umd/InputLang.js +3 -3
  126. package/umd/Message.js +15 -16
  127. package/umd/Modal.js +1 -1
  128. package/umd/MultiBox.js +3 -3
  129. package/umd/OperateBtn.js +1 -1
  130. package/umd/PageHeader.js +1 -1
  131. package/umd/Pagination.js +3 -3
  132. package/umd/PopConfirm.js +1 -1
  133. package/umd/QuickReply.js +3 -3
  134. package/umd/Search.js +3 -3
  135. package/umd/Selector.js +4 -4
  136. package/umd/SelectorPicker.js +6 -6
  137. package/umd/SingleBox.js +3 -3
  138. package/umd/Table.js +2 -2
  139. package/umd/Tabs.js +1 -1
  140. package/umd/TextField.js +2 -2
  141. package/umd/TimePicker.js +1 -1
  142. package/umd/ToggleButton.js +6 -6
  143. package/umd/Transfer.js +2 -2
  144. package/umd/Upload.js +2 -2
  145. package/umd/Utils.js +1 -1
  146. package/umd/locale.js +1 -1
  147. package/_verture/typeof-adeedc13.js +0 -11
  148. /package/_verture/{index-c8cb6751.js → index-0f5ee6f7.js} +0 -0
  149. /package/_verture/{index-e229330e.js → index-4c5d6cd7.js} +0 -0
  150. /package/_verture/{typeof-4646b22c.js → typeof-6ec38efd.js} +0 -0
package/Argv/index.js ADDED
@@ -0,0 +1,738 @@
1
+ import { _ as __awaiter } from '../_verture/tslib.es6-f43aa41d.js';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { useState, useEffect, useRef, useMemo } from 'react';
4
+ import clsx from 'clsx';
5
+ import { $ as $prefixCls } from '../_verture/constant-5317fc89.js';
6
+ import { u as useFormatMessage } from '../_verture/useFormatMessage-1fc7c957.js';
7
+ import { UUID, debounce } from '@paraview/lib';
8
+ import { Button } from '../Button/index.js';
9
+ import { TextField } from '../TextField/index.js';
10
+ import { Modal } from '../Modal/index.js';
11
+ import { Message } from '../Message/index.js';
12
+ import { s as styleInject } from '../_verture/style-inject.es-300983ab.js';
13
+ import Select from '../Select/index.js';
14
+ import ExpandPart from '@para-ui/icons/ExpandPart';
15
+ import { InputNumber } from '../InputNumber/index.js';
16
+ import Label from '../Label/index.js';
17
+ import Delete from '@para-ui/icons/Delete';
18
+ import PlusCircleF from '@para-ui/icons/PlusCircleF';
19
+ import { isObject } from '../Utils/index.js';
20
+ import '../_verture/index-ca413216.js';
21
+ import '@para-ui/icons/LoadingF';
22
+ import '../Tooltip/index.js';
23
+ import 'rc-tooltip';
24
+ import 'rc-tooltip/lib/placements';
25
+ import '@para-ui/icons/Forbid';
26
+ import '@para-ui/icons/Down';
27
+ import '../_verture/index-bde7aabe.js';
28
+ import 'rc-dropdown';
29
+ import '../_verture/usePopupContainer-635f66f4.js';
30
+ import 'dayjs';
31
+ import '../AutoTips/index.js';
32
+ import '@para-ui/icons/PreviewClose';
33
+ import '@para-ui/icons/PreviewOpen';
34
+ import '@para-ui/icons/CloseCircleF';
35
+ import '../Loading/index.js';
36
+ import '../HelperText/index.js';
37
+ import '../_verture/useGlobalProps-4ae1a007.js';
38
+ import 'rc-dialog';
39
+ import '@para-ui/icons/Close';
40
+ import 'react-dom';
41
+ import '@para-ui/icons/CheckCircleF';
42
+ import '@para-ui/icons/WarningCircleF';
43
+ import '../Empty/index.js';
44
+ import '@para-ui/icons/Check';
45
+ import '@para-ui/icons/Search';
46
+ import '../Popover/index.js';
47
+ import 'rc-input-number';
48
+ import '@para-ui/icons/Up';
49
+ import '../Help/index.js';
50
+ import '@para-ui/icons/Help';
51
+
52
+ var en = {
53
+ environmentVariable: 'Environment Variable',
54
+ pleaseEnterKey: 'Please enter key',
55
+ pleaseEnterValue: 'Please enter value',
56
+ add: 'Add',
57
+ batchEdit: 'Batch Edit',
58
+ ok: 'OK',
59
+ formatErrorJson: 'Format error, please enter valid JSON',
60
+ formatErrorArrayJson: 'Format error, please enter a valid JSON array',
61
+ pleaseEnter: 'Please enter',
62
+ pleaseSelect: 'Please select',
63
+ formatError: 'Format error',
64
+ required: 'Required, cannot be empty'
65
+ };
66
+
67
+ var zh = {
68
+ environmentVariable: '环境变量',
69
+ pleaseEnterKey: '请输入key',
70
+ pleaseEnterValue: '请输入value',
71
+ add: '新增',
72
+ batchEdit: '批量编辑',
73
+ ok: '确定',
74
+ formatErrorJson: '格式有误,请输入正确的JSON',
75
+ formatErrorArrayJson: '格式有误,请输入正确的JSON数组',
76
+ pleaseEnter: '请输入',
77
+ pleaseSelect: '请选择',
78
+ formatError: '格式错误',
79
+ required: '必填项,不能为空'
80
+ };
81
+
82
+ var localeJson = {
83
+ zh,
84
+ en
85
+ };
86
+
87
+ var css_248z$2 = "@charset \"UTF-8\";\n/**\n* @author linhd\n* @date 2023/4/11 14:16\n* @description 最新色卡\n*/";
88
+ styleInject(css_248z$2);
89
+
90
+ const BatchEdit = props => {
91
+ const intl = useFormatMessage('Argv', localeJson);
92
+ const {
93
+ className,
94
+ sourceData,
95
+ onFinish,
96
+ dataToJson,
97
+ jsonToData
98
+ } = props;
99
+ const [state, setState] = useState({
100
+ open: false,
101
+ json: ''
102
+ });
103
+ const onHandleClick = () => {
104
+ let jsonStr = '';
105
+ if (!Array.isArray(sourceData)) {
106
+ jsonStr = '';
107
+ } else {
108
+ try {
109
+ if (dataToJson) {
110
+ jsonStr = dataToJson(sourceData);
111
+ } else {
112
+ jsonStr = JSON.stringify(sourceData, null, 4);
113
+ }
114
+ } catch (error) {
115
+ console.error(error);
116
+ }
117
+ }
118
+ setState(Object.assign(Object.assign({}, state), {
119
+ json: jsonStr,
120
+ open: !state.open
121
+ }));
122
+ };
123
+ const onCancel = () => {
124
+ setState(Object.assign(Object.assign({}, state), {
125
+ open: false
126
+ }));
127
+ };
128
+ const onOk = value => {
129
+ let jsonData = [];
130
+ try {
131
+ if (jsonToData) {
132
+ jsonData = jsonToData(value);
133
+ } else {
134
+ jsonData = JSON.parse(value);
135
+ }
136
+ } catch (error) {
137
+ Message.error(intl('formatErrorJson'), 5000);
138
+ return false;
139
+ }
140
+ setState(Object.assign(Object.assign({}, state), {
141
+ open: false
142
+ }));
143
+ onFinish && onFinish(jsonData);
144
+ };
145
+ return jsxs("div", Object.assign({
146
+ className: "argv-batch-edit-content ".concat(className)
147
+ }, {
148
+ children: [jsx(Button, Object.assign({
149
+ variant: "outlined",
150
+ size: "small",
151
+ className: "btn-edit",
152
+ onClick: onHandleClick
153
+ }, {
154
+ children: intl('batchEdit')
155
+ })), jsx(EditModal, {
156
+ open: state.open,
157
+ onCancel: onCancel,
158
+ onOk: onOk,
159
+ json: state.json,
160
+ checkData: props.checkData
161
+ })]
162
+ }));
163
+ };
164
+ const EditModal = props => {
165
+ const {
166
+ open,
167
+ disabled,
168
+ onCancel,
169
+ onOk,
170
+ json,
171
+ checkData
172
+ } = props;
173
+ const intl = useFormatMessage('Argv', localeJson);
174
+ const [value, setValue] = useState('');
175
+ useEffect(() => {
176
+ setValue(json || '');
177
+ }, [json]);
178
+ // 校验value是否是json格式
179
+ const check = () => {
180
+ try {
181
+ const jsonValue = JSON.parse(value);
182
+ if (!Array.isArray(jsonValue)) {
183
+ Message.error(intl('formatErrorArrayJson'));
184
+ return false;
185
+ }
186
+ if (checkData && !checkData(jsonValue)) {
187
+ return false;
188
+ }
189
+ return true;
190
+ } catch (error) {
191
+ Message.error(intl('formatErrorJson'));
192
+ return false;
193
+ }
194
+ };
195
+ const onSubmit = () => {
196
+ if (!check()) return;
197
+ try {
198
+ onOk(value);
199
+ } catch (error) {
200
+ console.error(error);
201
+ }
202
+ };
203
+ return jsx(Modal, Object.assign({
204
+ className: "".concat($prefixCls, "-form"),
205
+ open: open,
206
+ title: intl('batchEdit'),
207
+ onCancel: onCancel,
208
+ onOk: onSubmit,
209
+ maskClosable: true,
210
+ showCancel: false,
211
+ okText: intl('ok')
212
+ }, {
213
+ children: jsx(TextField, {
214
+ label: 'API JSON',
215
+ placeholder: "\u8BF7\u8F93\u5165",
216
+ disabled: disabled,
217
+ multiline: true,
218
+ rows: 12,
219
+ value: value || '',
220
+ onChange: e => setValue(e.target.value)
221
+ })
222
+ }));
223
+ };
224
+
225
+ var dataTypeSelectList = [{
226
+ label: 'string',
227
+ value: 'string'
228
+ }, {
229
+ label: 'number',
230
+ value: 'number'
231
+ }, {
232
+ label: 'boolean',
233
+ value: 'boolean'
234
+ }, {
235
+ label: 'object',
236
+ value: 'object'
237
+ }];
238
+ var defaultInputValueMapping = {
239
+ string: '',
240
+ number: 0,
241
+ boolean: true,
242
+ object: '{}'
243
+ };
244
+ var booleanSelectList = [{
245
+ label: 'true',
246
+ value: true
247
+ }, {
248
+ label: 'false',
249
+ value: false
250
+ }];
251
+
252
+ var css_248z$1 = ".argv-data-generator .data-generator-content {\n width: 100%;\n display: flex;\n}\n.argv-data-generator .data-generator-content .datatype-select {\n width: 120px;\n flex-shrink: 0;\n margin-right: 8px;\n}\n.argv-data-generator .data-input .text-field-content-within-input {\n min-height: 30px;\n}\n.argv-data-generator .data-input .text-field-content-within-input .text-field-label-placeholder {\n padding-top: 9px !important;\n height: unset !important;\n}\n.argv-data-generator .data-input textarea {\n min-height: 30px;\n padding: 6px 10px !important;\n}";
253
+ styleInject(css_248z$1);
254
+
255
+ const DataGenerator = props => {
256
+ const {
257
+ defaultValue,
258
+ value,
259
+ disabled,
260
+ onChange,
261
+ error,
262
+ helperText,
263
+ placeholderTextField
264
+ } = props;
265
+ const intl = useFormatMessage('Argv', localeJson);
266
+ const [valueCom, setValueCom] = useState({
267
+ dataType: 'string',
268
+ data: ''
269
+ });
270
+ const [editorShow, setEditorShow] = useState(false);
271
+ const [code, setCode] = useState('');
272
+ const constData = useRef({
273
+ dataMapping: Object.assign({}, defaultInputValueMapping),
274
+ uuid: UUID()
275
+ });
276
+ useEffect(() => {
277
+ if (defaultValue !== undefined) setValueCom(defaultValue);
278
+ }, []);
279
+ useEffect(() => {
280
+ if (value !== undefined) setValueCom(value);
281
+ }, [value]);
282
+ const onSelectChange = value => {
283
+ var _a;
284
+ if (value !== valueCom.dataType) {
285
+ const dataMapping = constData.current.dataMapping;
286
+ const defaultInputValue = (_a = dataMapping[value]) !== null && _a !== void 0 ? _a : '';
287
+ const val = Object.assign(Object.assign({}, valueCom), {
288
+ dataType: value,
289
+ data: defaultInputValue
290
+ });
291
+ setValueCom(val);
292
+ onChange && onChange(val);
293
+ }
294
+ };
295
+ const onChangeValue = value => {
296
+ const val = Object.assign(Object.assign({}, valueCom), {
297
+ data: value
298
+ });
299
+ setValueCom(val);
300
+ onChange && onChange(val);
301
+ const dataType = valueCom.dataType;
302
+ const dataMapping = constData.current.dataMapping;
303
+ dataMapping[dataType] = value;
304
+ };
305
+ const inputMemo = useMemo(() => {
306
+ const {
307
+ dataType,
308
+ data
309
+ } = valueCom;
310
+ if (dataType === 'number') {
311
+ const val = Number(data);
312
+ return jsx(InputNumber, {
313
+ placeholder: placeholderTextField,
314
+ disabled: disabled,
315
+ className: "data-input",
316
+ value: val,
317
+ onChange: onChangeValue,
318
+ error: error,
319
+ helperText: helperText
320
+ });
321
+ }
322
+ if (dataType === 'boolean') {
323
+ return jsx(Select, {
324
+ disabled: disabled,
325
+ className: "data-input",
326
+ list: booleanSelectList,
327
+ value: data,
328
+ onChange: onChangeValue,
329
+ error: error,
330
+ helperText: helperText
331
+ });
332
+ }
333
+ return jsx(TextField, {
334
+ placeholder: placeholderTextField,
335
+ className: "data-input",
336
+ multiline: true,
337
+ value: data,
338
+ rightIcon: jsx(ExpandPart, {}),
339
+ onClickIcon: () => {
340
+ setEditorShow(true);
341
+ setCode(data);
342
+ },
343
+ onChange: e => onChangeValue(e.target.value),
344
+ rows: 1,
345
+ resize: false,
346
+ error: error,
347
+ helperText: helperText
348
+ });
349
+ }, [valueCom, onChangeValue, error, helperText]);
350
+ const onOk = () => {
351
+ if (valueCom.dataType === 'string') {
352
+ onChangeValue(code);
353
+ setEditorShow(false);
354
+ }
355
+ if (valueCom.dataType === 'object') {
356
+ try {
357
+ const val = JSON.parse(code);
358
+ onChangeValue(code);
359
+ setEditorShow(false);
360
+ } catch (error) {
361
+ Message.warn(intl('formatErrorJson'));
362
+ }
363
+ }
364
+ };
365
+ return jsxs("div", Object.assign({
366
+ className: "argv-data-generator"
367
+ }, {
368
+ children: [jsxs("div", Object.assign({
369
+ className: "data-generator-content"
370
+ }, {
371
+ children: [jsx(Select, {
372
+ disabled: disabled,
373
+ className: "datatype-select",
374
+ list: dataTypeSelectList,
375
+ value: valueCom === null || valueCom === void 0 ? void 0 : valueCom.dataType,
376
+ onChange: onSelectChange
377
+ }), inputMemo]
378
+ })), jsx(Modal, Object.assign({
379
+ open: editorShow,
380
+ hideHeader: true,
381
+ size: "auto",
382
+ onCancel: () => setEditorShow(false),
383
+ onOk: onOk
384
+ }, {
385
+ children: jsx("div", Object.assign({
386
+ style: {
387
+ width: '600px',
388
+ height: 'auto',
389
+ paddingTop: '20px'
390
+ }
391
+ }, {
392
+ children: jsx(TextField, {
393
+ disabled: disabled,
394
+ multiline: true,
395
+ rows: 12,
396
+ value: code || '',
397
+ onChange: e => setCode(e.target.value)
398
+ })
399
+ }))
400
+ }))]
401
+ }));
402
+ };
403
+ // 校验数据是否正确
404
+ const checkGeneratorData = data => {
405
+ const {
406
+ dataType,
407
+ data: value
408
+ } = data;
409
+ switch (dataType) {
410
+ case 'number':
411
+ return !isNaN(Number(value));
412
+ case 'boolean':
413
+ return true;
414
+ case 'string':
415
+ return true;
416
+ case 'object':
417
+ try {
418
+ JSON.parse(value);
419
+ return true;
420
+ } catch (error) {
421
+ return false;
422
+ }
423
+ default:
424
+ return false;
425
+ }
426
+ };
427
+ // 将生成器数据格式化为数据
428
+ const formatGeneratorToData = data => {
429
+ if (!data) return '';
430
+ const {
431
+ dataType,
432
+ data: value
433
+ } = data;
434
+ switch (dataType) {
435
+ case 'number':
436
+ return Number(value);
437
+ case 'boolean':
438
+ return !!value;
439
+ case 'string':
440
+ return value;
441
+ case 'object':
442
+ try {
443
+ const val = JSON.parse(value);
444
+ return val;
445
+ } catch (error) {
446
+ return {};
447
+ }
448
+ default:
449
+ return value;
450
+ }
451
+ };
452
+ // 将数据格式化为生成器数据
453
+ const formatDataToGenerator = data => {
454
+ if (typeof data === 'number') {
455
+ return {
456
+ dataType: 'number',
457
+ data: data
458
+ };
459
+ }
460
+ if (typeof data === 'boolean') {
461
+ return {
462
+ dataType: 'boolean',
463
+ data: data
464
+ };
465
+ }
466
+ if (typeof data === 'string') {
467
+ return {
468
+ dataType: 'string',
469
+ data: data
470
+ };
471
+ }
472
+ if (typeof data === 'object') {
473
+ return {
474
+ dataType: 'object',
475
+ data: JSON.stringify(data)
476
+ };
477
+ }
478
+ return {
479
+ dataType: 'string',
480
+ data: ''
481
+ };
482
+ };
483
+
484
+ var css_248z = "@charset \"UTF-8\";\n/**\n* @author linhd\n* @date 2023/4/11 14:16\n* @description 最新色卡\n*/\n.paraui-v4-argv {\n position: relative;\n}\n.paraui-v4-argv .btn-batch-edit {\n position: absolute;\n right: 0;\n top: -8px;\n display: flex;\n justify-content: flex-end;\n align-items: center;\n}\n.paraui-v4-argv .argv-item {\n display: flex;\n justify-content: flex-start;\n align-items: flex-start;\n}\n.paraui-v4-argv .argv-item .argv-key {\n width: 200px;\n}\n.paraui-v4-argv .argv-item .argv-value {\n flex: 1;\n}\n.paraui-v4-argv .argv-item .middle-icon {\n display: flex;\n justify-content: center;\n align-items: center;\n height: 30px;\n margin: 0 12px;\n line-height: 1;\n color: rgb(92, 101, 115);\n}\n.paraui-v4-argv .paraui-v4-helper-text {\n min-height: 10px;\n}\n.paraui-v4-argv .argv-btn-add {\n height: 32px;\n line-height: 32px;\n text-align: center;\n border: 1px dashed;\n border-color: rgb(212, 218, 227);\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n cursor: pointer;\n background-color: rgb(247, 248, 250);\n color: rgb(46, 101, 230);\n font-size: 14px;\n}\n.paraui-v4-argv .argv-btn-add > svg {\n font-size: 16px;\n color: rgb(46, 101, 230);\n margin-right: 8px;\n}\n.paraui-v4-argv .argv-btn-add:hover {\n border-color: rgb(87, 131, 235);\n background-color: rgb(240, 245, 255);\n}\n.paraui-v4-argv .argv-btn-add.disabled {\n cursor: not-allowed;\n background-color: rgb(247, 248, 250);\n color: rgb(161, 168, 179);\n}\n.paraui-v4-argv .argv-btn-add.disabled > svg {\n color: rgb(161, 168, 179);\n}\n.paraui-v4-argv .argv-btn-add.disabled:hover {\n border-color: rgb(212, 218, 227);\n background-color: rgb(247, 248, 250);\n}\n.paraui-v4-argv .argv-btn-del {\n flex-shrink: 0;\n cursor: pointer;\n width: 32px;\n height: 32px;\n margin-left: 12px;\n border-radius: 4px;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n.paraui-v4-argv .argv-btn-del:hover {\n background-color: rgb(247, 248, 250);\n}\n.paraui-v4-argv .argv-btn-del:hover svg {\n color: rgb(46, 101, 230);\n}\n.paraui-v4-argv .argv-btn-del svg {\n font-size: 24px;\n color: rgb(92, 101, 115);\n}\n.paraui-v4-argv .argv-btn-del.disabled {\n cursor: not-allowed;\n}\n.paraui-v4-argv .argv-btn-del.disabled:hover {\n background-color: transparent;\n}\n.paraui-v4-argv .argv-btn-del.disabled:hover svg {\n color: rgb(92, 101, 115);\n}\n.paraui-v4-argv .argv-btn-del.disabled svg {\n color: rgb(92, 101, 115);\n}";
485
+ styleInject(css_248z);
486
+
487
+ const Argv = props => {
488
+ const {
489
+ style,
490
+ className,
491
+ defaultValue,
492
+ disabled,
493
+ label,
494
+ labelProps,
495
+ errors,
496
+ onChange,
497
+ list,
498
+ onListChange
499
+ } = props;
500
+ const intl = useFormatMessage('Argv', localeJson);
501
+ const [data, setData] = useState([]);
502
+ /** 默认值 */
503
+ const defaultListItem = {
504
+ key: '',
505
+ data: {
506
+ dataType: 'string',
507
+ data: ''
508
+ }
509
+ };
510
+ useEffect(() => {
511
+ // 判断data是否为对象
512
+ if (!defaultValue || !isObject(defaultValue)) {
513
+ setData([]);
514
+ return;
515
+ }
516
+ setData(formatObjectToData(defaultValue));
517
+ }, [defaultValue]);
518
+ useEffect(() => {
519
+ if (list !== undefined) setData(list);
520
+ }, [list]);
521
+ /**
522
+ * @desc 搜索 - 防抖
523
+ */
524
+ const onChangeThrottle = useMemo(() => debounce(val => __awaiter(void 0, void 0, void 0, function* () {
525
+ const obj = formatDataToObject(val);
526
+ onChange && onChange(obj);
527
+ }), 200), []);
528
+ const onDataChange = val => {
529
+ setData(val);
530
+ onListChange && onListChange(val);
531
+ onChangeThrottle(val);
532
+ };
533
+ /**
534
+ * @desc 新增
535
+ */
536
+ const add = () => {
537
+ if (disabled) return;
538
+ data.push(Object.assign({}, defaultListItem));
539
+ // if (value === undefined) setData([...data]);
540
+ onDataChange([...data]);
541
+ };
542
+ /**
543
+ * @desc 删除
544
+ */
545
+ const del = index => {
546
+ if (disabled) return;
547
+ data.splice(index, 1);
548
+ // if (value === undefined) setData([...data]);
549
+ onDataChange([...data]);
550
+ // const errorArr = [...errors];
551
+ // errorArr.splice(index, 1);
552
+ // onErrors && onErrors(errorArr);
553
+ };
554
+ /**
555
+ * @desc 值回调
556
+ */
557
+ const onValueChange = (val, index, key) => {
558
+ if (!data[index]) data[index] = Object.assign({}, defaultListItem);
559
+ data[index] = Object.assign(Object.assign({}, data[index]), {
560
+ [key]: val
561
+ });
562
+ // if (value === undefined) setData([...data]);
563
+ onDataChange([...data]);
564
+ };
565
+ /**
566
+ * @desc 组件头部
567
+ */
568
+ const headerMemo = useMemo(() => {
569
+ return jsx("div", Object.assign({
570
+ className: "argv-label"
571
+ }, {
572
+ children: jsx(Label, Object.assign({
573
+ label: label || intl('environmentVariable')
574
+ }, labelProps))
575
+ }));
576
+ }, [label, labelProps]);
577
+ const listMemo = useMemo(() => {
578
+ const arr = data.map((item, index) => {
579
+ var _a;
580
+ const errItem = (_a = errors === null || errors === void 0 ? void 0 : errors[index]) !== null && _a !== void 0 ? _a : {};
581
+ const errKey = (errItem === null || errItem === void 0 ? void 0 : errItem.key) || '';
582
+ const errValue = (errItem === null || errItem === void 0 ? void 0 : errItem.value) || '';
583
+ return jsx("div", {
584
+ children: jsxs("div", Object.assign({
585
+ className: "argv-item"
586
+ }, {
587
+ children: [jsx("div", Object.assign({
588
+ className: "argv-key"
589
+ }, {
590
+ children: jsx(TextField, {
591
+ value: (item === null || item === void 0 ? void 0 : item.key) || '',
592
+ placeholder: intl('pleaseEnterKey'),
593
+ onChange: e => onValueChange(e.target.value, index, 'key'),
594
+ disabled: disabled,
595
+ error: !!errKey,
596
+ helperText: errKey
597
+ })
598
+ })), jsx("div", Object.assign({
599
+ className: "middle-icon"
600
+ }, {
601
+ children: ":"
602
+ })), jsx("div", Object.assign({
603
+ className: "argv-value"
604
+ }, {
605
+ children: jsx(DataGenerator, {
606
+ value: item === null || item === void 0 ? void 0 : item.data,
607
+ onChange: value => onValueChange(value, index, 'data'),
608
+ disabled: disabled,
609
+ error: !!errValue,
610
+ helperText: errValue,
611
+ placeholderTextField: intl('pleaseEnterValue')
612
+ })
613
+ })), jsx("div", Object.assign({
614
+ className: "argv-btn-del ".concat(disabled ? 'disabled' : '')
615
+ }, {
616
+ children: jsx(Delete, {
617
+ onClick: () => del(index)
618
+ })
619
+ }))]
620
+ }), index)
621
+ }, index);
622
+ });
623
+ return arr;
624
+ }, [data, onValueChange, del]);
625
+ const dataToJson = () => {
626
+ if (!Array.isArray(data)) return '';
627
+ const arr = data.map(item => {
628
+ const value = formatGeneratorToData(item.data);
629
+ return {
630
+ key: item.key || '',
631
+ value: value
632
+ };
633
+ });
634
+ try {
635
+ return JSON.stringify(arr, null, 4);
636
+ } catch (error) {
637
+ return '';
638
+ }
639
+ };
640
+ const jsonToData = value => {
641
+ let jsonData = [];
642
+ try {
643
+ jsonData = JSON.parse(value);
644
+ } catch (error) {
645
+ return [];
646
+ }
647
+ if (!Array.isArray(jsonData)) return [];
648
+ const arr = jsonData.map(item => {
649
+ const value = formatDataToGenerator(item === null || item === void 0 ? void 0 : item.value);
650
+ return {
651
+ key: item.key,
652
+ data: value
653
+ };
654
+ });
655
+ return arr;
656
+ };
657
+ return jsxs("div", Object.assign({
658
+ className: clsx("".concat($prefixCls, "-argv"), className, {}),
659
+ style: style
660
+ }, {
661
+ children: [jsx("div", Object.assign({
662
+ className: "btn-batch-edit"
663
+ }, {
664
+ children: jsx(BatchEdit, {
665
+ sourceData: data,
666
+ dataToJson: dataToJson,
667
+ jsonToData: jsonToData,
668
+ onFinish: val => {
669
+ // if (value === undefined) setData([...val] as IArgvItem[]);
670
+ console.log(val, 'BatchEdit===>');
671
+ onDataChange([...val]);
672
+ }
673
+ })
674
+ })), headerMemo, jsx("div", Object.assign({
675
+ className: "argv-list"
676
+ }, {
677
+ children: listMemo
678
+ })), jsxs("div", Object.assign({
679
+ className: "argv-btn-add ".concat(disabled ? 'disabled' : ''),
680
+ onClick: add
681
+ }, {
682
+ children: [jsx(PlusCircleF, {}), jsx("span", {
683
+ children: intl('add')
684
+ })]
685
+ }))]
686
+ }));
687
+ };
688
+ const formatObjectToData = data => {
689
+ // 判断data是否为对象
690
+ if (!isObject(data)) return [];
691
+ // 格式化数据
692
+ const argvKeys = Object.keys(data);
693
+ const arr = [];
694
+ argvKeys.forEach(key => {
695
+ const value = formatDataToGenerator(data === null || data === void 0 ? void 0 : data[key]);
696
+ arr.push({
697
+ key: key,
698
+ data: value
699
+ });
700
+ });
701
+ return arr;
702
+ };
703
+ const formatDataToObject = data => {
704
+ const obj = {};
705
+ data.forEach(item => {
706
+ if (item.key) {
707
+ const value = formatGeneratorToData(item.data);
708
+ obj[item.key] = value;
709
+ }
710
+ });
711
+ return obj;
712
+ };
713
+ // 校验每一项数据格式是否正确
714
+ const checkArgvData = (data, intl) => {
715
+ const arr = [];
716
+ let isErr = false;
717
+ data.forEach((item, index) => {
718
+ const {
719
+ key,
720
+ data
721
+ } = item;
722
+ const isKeyErr = !key;
723
+ const isValueErr = !checkGeneratorData(data);
724
+ if (isKeyErr || isValueErr) {
725
+ isErr = true;
726
+ arr[index] = {
727
+ key: isKeyErr ? intl('required') : '',
728
+ value: isValueErr ? intl('formatError') : ''
729
+ };
730
+ }
731
+ });
732
+ return {
733
+ error: isErr,
734
+ detail: arr
735
+ };
736
+ };
737
+
738
+ export { checkArgvData, Argv as default, formatDataToObject, formatObjectToData };