@uiw-admin/components
Version:
115 lines • 3.38 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
var _excluded = ["table", "columns", "operateButtons", "searchBtns", "onBeforeSearch", "paginationProps", "formCol", "tableHeadHidden", "tableBackgroundColor"];
import React, { useMemo } from 'react';
import { Button, Card } from 'uiw';
import Skeleton from '../Skeleton';
import Table from './BaseTable';
import BaseForm from './BaseForm';
import { StoreCtx } from './hooks';
import { QueryClientProvider, queryClient } from '@kkt/request';
import './index.css';
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
export * from './types';
var ProTabel = props => {
var {
table,
columns,
operateButtons = [],
searchBtns,
onBeforeSearch,
paginationProps,
formCol,
tableHeadHidden,
tableBackgroundColor
} = props,
tableProps = _objectWithoutPropertiesLoose(props, _excluded);
var {
key,
onReset,
onRefersh,
updateStore,
formatData,
query,
searchValues,
loading,
onSearch,
selection,
pageIndex,
form,
updateForm,
setPageIndex,
mutate,
requestOptions
} = table;
var store = useMemo(() => ({
data: [],
onReset,
onRefersh,
key,
updateStore,
formatData,
query,
searchValues,
onSearch,
selection,
pageIndex,
form,
updateForm,
setPageIndex,
mutate,
requestOptions
}), [JSON.stringify(table)]);
return /*#__PURE__*/_jsx(StoreCtx.Provider, {
value: _extends({}, store),
children: /*#__PURE__*/_jsxs(Skeleton, {
loading: loading,
children: [searchBtns && searchBtns.length > 0 && /*#__PURE__*/_jsx(Card, {
noHover: true,
style: {
marginBottom: 14
},
bodyStyle: {
padding: '8px 14px'
},
children: /*#__PURE__*/_jsx(BaseForm, {
columns: columns,
searchBtns: searchBtns,
onBeforeSearch: onBeforeSearch,
formCol: formCol
})
}), /*#__PURE__*/_jsxs(Card, {
noHover: true,
children: [operateButtons && operateButtons.length > 0 && /*#__PURE__*/_jsx("div", {
style: {
background: '#fff',
paddingBottom: 14
},
children: operateButtons.map((btn, idx) => btn != null && btn.render ? /*#__PURE__*/_jsx(React.Fragment, {
children: btn.render
}, idx.toString()) : /*#__PURE__*/_jsx(Button, _extends({}, btn, {
children: btn.label
}), idx.toString()))
}), /*#__PURE__*/_jsx("div", {
className: ['uiw-admin-protable', tableHeadHidden ? 'is-need-table-header' : '', tableBackgroundColor ? 'table-parent-uiw-admin' : ''].filter(it => it).join(' '),
style: {
backgroundColor: tableBackgroundColor
},
children: /*#__PURE__*/_jsx(Table, _extends({
columns: columns
}, tableProps, {
paginationProps: paginationProps
}))
})]
})]
})
});
};
var Tables = props => {
return /*#__PURE__*/_jsx(QueryClientProvider, {
client: queryClient,
children: /*#__PURE__*/_jsx(ProTabel, _extends({}, props))
});
};
export default Tables;