var _excluded = ["dataSource", "columns", "dispatch", "style", "filter", "sort", "buttons", "actionButtons", "title", "summary", "onValuesChange", "columnSetting", "dataSourceGroup", "view", "gallery", "setTableSetting", "onDataSourceChange"];
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import React, { useMemo } from 'react';
import { Form } from 'antd';
import GridViewTable from "../Table";
import Gallery from "../Gallery";
import { stringify } from "../Table/utils";
import { useDebounce, useMemoizedFn } from 'ahooks';
var View = function View(props) {
  var dataSource = props.dataSource,
    columns = props.columns,
    dispatch = props.dispatch,
    style = props.style,
    filter = props.filter,
    sort = props.sort,
    buttons = props.buttons,
    actionButtons = props.actionButtons,
    title = props.title,
    summary = props.summary,
    onValuesChange = props.onValuesChange,
    columnSetting = props.columnSetting,
    dataSourceGroup = props.dataSourceGroup,
    view = props.view,
    gallery = props.gallery,
    setTableSetting = props.setTableSetting,
    onDataSourceChange = props.onDataSourceChange,
    other = _objectWithoutProperties(props, _excluded);
  var form = Form.useFormInstance();
  var viewMode = Form.useWatch('view_mode', {
    form: form,
    preserve: true
  });
  var debouncedFilter = useDebounce(filter, {
    wait: 200
  });
  var memoOnDataSourceChange = useMemoizedFn(function (v) {
    return onDataSourceChange === null || onDataSourceChange === void 0 ? void 0 : onDataSourceChange(v);
  });
  var memoContent = useMemo(function () {
    return /*#__PURE__*/React.createElement(React.Fragment, null, viewMode === 'grid' && /*#__PURE__*/React.createElement(GridViewTable, {
      tableProps: other,
      filter: filter,
      setTableSetting: setTableSetting,
      onDataSourceChange: memoOnDataSourceChange
    }), viewMode === 'gallery' && /*#__PURE__*/React.createElement(Gallery, {
      loading: other === null || other === void 0 ? void 0 : other.loading,
      gallery: gallery,
      pagination: other.pagination,
      filter: filter,
      rowKey: other.rowKey,
      onDataSourceChange: memoOnDataSourceChange
    }));
  }, [viewMode, stringify(other), debouncedFilter, memoOnDataSourceChange, gallery]);
  return memoContent;
};
export default View;