@cloudbase/weda-ui 3.22.5 → 3.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/configs/components/wd-table.d.ts +1 -0
- package/dist/configs/components/wd-table.js +14 -1
- package/dist/configs/index.d.ts +2 -0
- package/dist/style/index.css +27 -0
- package/dist/style/index.scss +1 -1
- package/dist/style/weda-ui.min.css +2 -2
- package/dist/web/components/form/select/index.js +14 -25
- package/dist/web/components/form-input-hooks/index.d.ts +0 -1
- package/dist/web/components/form-input-hooks/index.js +6 -13
- package/dist/web/components/wd-form/contexts/form-field-context.d.ts +6 -2
- package/dist/web/components/wd-form/contexts/form-field-context.js +18 -2
- package/dist/web/components/wd-form/contexts/form-field-obj-context.d.ts +2 -2
- package/dist/web/components/wd-form/contexts/form-field-obj-context.js +2 -2
- package/dist/web/components/wd-form/hoc/form-container-decorator.d.ts +11 -0
- package/dist/web/components/wd-form/hoc/form-container-decorator.js +61 -0
- package/dist/web/components/wd-form/index.d.ts +4 -49
- package/dist/web/components/wd-form/index.js +53 -70
- package/dist/web/components/wd-form-obj/base-form-obj.d.ts +5 -1
- package/dist/web/components/wd-form-obj/base-form-obj.js +19 -38
- package/dist/web/components/wd-input/wd-input.d.ts +2 -0
- package/dist/web/components/wd-input/wd-input.js +70 -18
- package/dist/web/components/wd-table/components/FieldRender/index.d.ts +9 -1
- package/dist/web/components/wd-table/components/FieldRender/index.js +33 -4
- package/dist/web/components/wd-table/components/FilterFieldsPanel/Fields.d.ts +3 -1
- package/dist/web/components/wd-table/components/FilterFieldsPanel/Fields.js +7 -3
- package/dist/web/components/wd-table/components/FilterFieldsPanel/FilterFieldItem.js +4 -1
- package/dist/web/components/wd-table/components/FilterFieldsPanel/filterFieldsGenerate.d.ts +6 -15
- package/dist/web/components/wd-table/components/FilterFieldsPanel/filterFieldsGenerate.js +47 -16
- package/dist/web/components/wd-table/components/FilterFieldsPanel/index.js +15 -5
- package/dist/web/components/wd-table/utils/index.d.ts +5 -2
- package/dist/web/components/wd-table/utils/index.js +12 -1
- package/dist/web/components/wd-table/wd-table.d.ts +5 -19
- package/dist/web/components/wd-table/wd-table.js +22 -2
- package/dist/web/utils/hooks/useFormLegacy.js +5 -12
- package/package.json +1 -1
|
@@ -10,29 +10,15 @@ export declare const GlobalButton: React.NamedExoticComponent<{
|
|
|
10
10
|
classPrefix: string;
|
|
11
11
|
slots: any;
|
|
12
12
|
}>;
|
|
13
|
-
export declare const WdTable: React.ForwardRefExoticComponent<
|
|
13
|
+
export declare const WdTable: React.ForwardRefExoticComponent<Pick<{
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
initialValues?: any;
|
|
16
|
+
}, string | number> & React.RefAttributes<unknown>>;
|
|
14
17
|
export interface WdTableProps extends CommonPropsType, DataType {
|
|
15
18
|
isMock?: boolean;
|
|
16
19
|
multipleSelect: boolean;
|
|
17
20
|
mockEmpty?: boolean;
|
|
18
21
|
row__bottom__slot?: React.ReactNode;
|
|
19
22
|
__innerSlot?: React.ReactNode;
|
|
23
|
+
initialValues?: [];
|
|
20
24
|
}
|
|
21
|
-
type TCompRef = {
|
|
22
|
-
import: () => void;
|
|
23
|
-
exportOptionalMode: () => void;
|
|
24
|
-
export: () => void;
|
|
25
|
-
deleteSelected: () => void;
|
|
26
|
-
refresh: () => void;
|
|
27
|
-
refreshKeepPage: () => void;
|
|
28
|
-
deleteOne: (params: {
|
|
29
|
-
id: string;
|
|
30
|
-
}) => void;
|
|
31
|
-
openOperationDialog: () => void;
|
|
32
|
-
records?: any[];
|
|
33
|
-
total: number;
|
|
34
|
-
pageNo: number;
|
|
35
|
-
pageSize: number;
|
|
36
|
-
selectedRecords: any[];
|
|
37
|
-
};
|
|
38
|
-
export {};
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
/* eslint-disable max-lines */
|
|
3
3
|
import { useRef, useEffect, useState, useMemo, forwardRef, memo } from 'react';
|
|
4
4
|
import { ConfigProvider } from 'tea-component';
|
|
5
|
+
import { useDeepCompareEffect } from '@react-hookz/web';
|
|
5
6
|
import { Table, ExportFileModal, ImportFileModal, InOrOutRecordModal, deleteRecord, importHandleByApi, exportHandleByApi, exportHandle, FilterFieldsPanel, ToolBar, } from './components';
|
|
6
7
|
import classNames from '../../utils/classnames';
|
|
7
8
|
import { useConfig } from '../../utils/config-context';
|
|
@@ -16,6 +17,10 @@ import { useAuthFields } from './hooks/useAuthFields';
|
|
|
16
17
|
import { useTableData } from './hooks/useTableData';
|
|
17
18
|
import { useViewFields } from './hooks/useViewFields';
|
|
18
19
|
import { useQueryParams } from './hooks/useQueryParams';
|
|
20
|
+
// eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
|
|
21
|
+
import { withFormContainer } from '../wd-form/hoc/form-container-decorator';
|
|
22
|
+
import { useFormField } from '../wd-form/contexts/form-field-context';
|
|
23
|
+
import { useFormFieldObj } from '../wd-form/contexts/form-field-obj-context';
|
|
19
24
|
import { WdCompError } from '../../utils/error';
|
|
20
25
|
import { getSlots, getFilterFields, getSelectedView, getSortColumns, mapTableDataWithView, checkSupport, DataSourceType, getRecordKey, getCurrentPageData, } from './utils';
|
|
21
26
|
import { Mock } from './mock';
|
|
@@ -33,8 +38,9 @@ export const TableOption = function TableOption({ slots, ...props }) {
|
|
|
33
38
|
export const GlobalButton = memo(function GlobalButtonDom({ classPrefix, slots }) {
|
|
34
39
|
return _jsx("div", { className: `${classPrefix}-global-btn`, children: slotRender(slots) });
|
|
35
40
|
});
|
|
41
|
+
export const WdTable = withFormContainer(
|
|
36
42
|
// eslint-disable-next-line complexity
|
|
37
|
-
|
|
43
|
+
forwardRef(function TableComp(tableProps, ref) {
|
|
38
44
|
const { className, style, dataSourceType = 'data-model', bindConnectMetadata = {
|
|
39
45
|
datasource: { id: '', name: '', title: '' },
|
|
40
46
|
}, // APImock数据
|
|
@@ -75,6 +81,9 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
|
|
|
75
81
|
sorter, // 排序规则
|
|
76
82
|
__innerSlot, enableRelationTag = true, // 关联关系字段是否开启关联标签
|
|
77
83
|
enableBottomTipSlot = false, row__bottom__slot, ...props } = tableProps;
|
|
84
|
+
const formField = useFormField();
|
|
85
|
+
const { formFieldsValue = [], setFieldValue, setFormFieldsValue } = formField || {};
|
|
86
|
+
const formFieldObjsContext = useFormFieldObj();
|
|
78
87
|
const wList = convertWhere(props, supportManyRelated); // 查询参数
|
|
79
88
|
const { classPrefix } = useConfig();
|
|
80
89
|
const platform = usePlatform();
|
|
@@ -355,6 +364,15 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
|
|
|
355
364
|
return tableData;
|
|
356
365
|
};
|
|
357
366
|
const tableRecords = mapTableData();
|
|
367
|
+
useDeepCompareEffect(() => {
|
|
368
|
+
const value = [...tableRecords];
|
|
369
|
+
if (setFieldValue && (formFieldObjsContext === null || formFieldObjsContext === void 0 ? void 0 : formFieldObjsContext.namePath)) {
|
|
370
|
+
setFieldValue({ namePath: formFieldObjsContext === null || formFieldObjsContext === void 0 ? void 0 : formFieldObjsContext.namePath, value });
|
|
371
|
+
}
|
|
372
|
+
else if (setFormFieldsValue) {
|
|
373
|
+
setFormFieldsValue(value);
|
|
374
|
+
}
|
|
375
|
+
}, [formFieldObjsContext === null || formFieldObjsContext === void 0 ? void 0 : formFieldObjsContext.namePath, tableRecords]);
|
|
358
376
|
// 总数
|
|
359
377
|
let total = isExpression ? tableRecords === null || tableRecords === void 0 ? void 0 : tableRecords.length : tableTotal;
|
|
360
378
|
if (enableTotal && isExpression && !isNaN(parseInt(`${_total}`))) {
|
|
@@ -573,6 +591,7 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
|
|
|
573
591
|
filter: supportManyRelated ? query.filter : query === null || query === void 0 ? void 0 : query.where,
|
|
574
592
|
dataSourceVersion: supportManyRelated ? 'v2' : 'v1',
|
|
575
593
|
filterConfig,
|
|
594
|
+
value: formFieldsValue,
|
|
576
595
|
}),
|
|
577
596
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
578
597
|
[
|
|
@@ -599,6 +618,7 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
|
|
|
599
618
|
query === null || query === void 0 ? void 0 : query.filter,
|
|
600
619
|
supportManyRelated,
|
|
601
620
|
filterConfig,
|
|
621
|
+
formFieldsValue,
|
|
602
622
|
], ref);
|
|
603
623
|
// 表格更改上下文数据
|
|
604
624
|
// 移动端和自定义APIs场景不支持导入功能,监听变化存到表格上下文中
|
|
@@ -745,4 +765,4 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
|
|
|
745
765
|
setIsMobileOptionVisible(false);
|
|
746
766
|
},
|
|
747
767
|
} }) }))] }) }) }));
|
|
748
|
-
});
|
|
768
|
+
}));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMemo, useRef, useState, useCallback } from 'react';
|
|
2
2
|
import { convertLegacyProps, convertLegacyEnum } from '../tool';
|
|
3
|
-
import { WD_INPUT_SIZE, WD_INPUT_LAYOUT, WD_INPUT_LABEL_ALIGN, WD_DATE_FORMAT
|
|
3
|
+
import { WD_INPUT_SIZE, WD_INPUT_LAYOUT, WD_INPUT_LABEL_ALIGN, WD_DATE_FORMAT } from '../../../enum';
|
|
4
4
|
import isEqual from '../isObjectEqual';
|
|
5
5
|
import lodashGet from 'lodash.get';
|
|
6
6
|
import { usePlatform, textToString } from '../platform';
|
|
@@ -138,7 +138,7 @@ export const convertPx = (val, unit = 'px') => {
|
|
|
138
138
|
/** 日期时间组件相关方法 start */
|
|
139
139
|
// 兼容 format
|
|
140
140
|
export const useDateFormat = (props) => {
|
|
141
|
-
const { mode = X_RUNTIME_DEFAULT.mode, dateFormat = X_RUNTIME_DEFAULT.dateFormat
|
|
141
|
+
const { mode = X_RUNTIME_DEFAULT.mode, dateFormat = X_RUNTIME_DEFAULT.dateFormat } = props || {};
|
|
142
142
|
const format = useMemo(() => {
|
|
143
143
|
const formatValue = WD_DATE_FORMAT.find((item) => item.value === dateFormat);
|
|
144
144
|
switch (mode) {
|
|
@@ -353,10 +353,7 @@ export const convertTimeValue = (value) => {
|
|
|
353
353
|
const match = value.match(/(\d{2}):(\d{2}):?(\d{2})?/);
|
|
354
354
|
if (match) {
|
|
355
355
|
const [yes, hour = 0, minute = 0, second = 0] = match;
|
|
356
|
-
if (yes &&
|
|
357
|
-
Number(hour) < 24 &&
|
|
358
|
-
Number(minute) < 60 &&
|
|
359
|
-
Number(second) < 60) {
|
|
356
|
+
if (yes && Number(hour) < 24 && Number(minute) < 60 && Number(second) < 60) {
|
|
360
357
|
time = moment.duration(`${hour}:${minute}:${second}`).asMilliseconds();
|
|
361
358
|
}
|
|
362
359
|
}
|
|
@@ -397,9 +394,7 @@ export const useHandleClear = (props) => {
|
|
|
397
394
|
const onMouseEnter = useCallback(() => setHover(true), []);
|
|
398
395
|
const onMouseLeave = useCallback(() => setHover(false), []);
|
|
399
396
|
const onClear = useCallback(() => onChange === null || onChange === void 0 ? void 0 : onChange(null), [onChange]);
|
|
400
|
-
const truth = !isNil(value) &&
|
|
401
|
-
value !== '' &&
|
|
402
|
-
(!Array.isArray(value) || value.length !== 0);
|
|
397
|
+
const truth = !isNil(value) && value !== '' && (!Array.isArray(value) || value.length !== 0);
|
|
403
398
|
const hasClearIcon = clearable && !disabled && !readOnly && truth && (hover || isH5);
|
|
404
399
|
return { onMouseEnter, onMouseLeave, onClear, hasClearIcon };
|
|
405
400
|
};
|
|
@@ -413,9 +408,7 @@ export const convertAcceptTypes = (_acceptTypes = X_RUNTIME_DEFAULT._acceptTypes
|
|
|
413
408
|
else if (Array.isArray(_acceptTypes)) {
|
|
414
409
|
types = _acceptTypes;
|
|
415
410
|
}
|
|
416
|
-
return types
|
|
417
|
-
.filter((d) => !!d)
|
|
418
|
-
.map((d) => (/(\*)|(\/)|(^\..+)/.test(d) ? d : `.${d}`));
|
|
411
|
+
return types.filter((d) => !!d).map((d) => (/(\*)|(\/)|(^\..+)/.test(d) ? d : `.${d}`));
|
|
419
412
|
};
|
|
420
413
|
// 区分不同端的前后缀图标,比如下拉选择
|
|
421
414
|
export const useFixedIcon = (props) => {
|