ods-component-lib 1.18.126 → 1.18.128

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.
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { FormProps, ButtonProps } from 'antd';
3
+ export interface IFormItemRuleProps {
4
+ required?: boolean;
5
+ message?: string;
6
+ }
7
+ export interface IFormItemProps {
8
+ label?: string;
9
+ name?: string;
10
+ formItemType: string;
11
+ rules?: IFormItemRuleProps[];
12
+ }
13
+ export interface IFormProps extends FormProps {
14
+ formItems: IFormItemProps[];
15
+ formButtons: ButtonProps[];
16
+ }
17
+ declare function OdsBasicForm(props: IFormProps): React.JSX.Element;
18
+ export default OdsBasicForm;
package/dist/index.js CHANGED
@@ -34997,16 +34997,17 @@ var OdsServerSideDatagrid = function OdsServerSideDatagrid(props) {
34997
34997
  var _useState = React.useState(50),
34998
34998
  currentPageSize = _useState[0],
34999
34999
  setCurrentPageSize = _useState[1];
35000
- var _useState2 = React.useState(false),
35001
- contentReady = _useState2[0],
35002
- setContentReady = _useState2[1];
35003
- var _useState3 = React.useState(0),
35004
- currentPage = _useState3[0],
35005
- setCurrentPage = _useState3[1];
35000
+ var _useState2 = React.useState(0),
35001
+ currentPage = _useState2[0],
35002
+ setCurrentPage = _useState2[1];
35003
+ var _useState3 = React.useState(false),
35004
+ filterApplied = _useState3[0],
35005
+ setFilterApplied = _useState3[1];
35006
+ var totalUnfilteredCount = React.useRef(0);
35007
+ var totalFilteredCount = React.useRef(0);
35006
35008
  var _useState4 = React.useState(false),
35007
- filterApplied = _useState4[0],
35008
- setFilterApplied = _useState4[1];
35009
- var filteredRowCount = React.useRef(0);
35009
+ updateTrigger = _useState4[0],
35010
+ setUpdateTrigger = _useState4[1];
35010
35011
  var lastPageIndexRef = React.useRef(null);
35011
35012
  var _useState5 = React.useState({}),
35012
35013
  filterOptions = _useState5[0],
@@ -35018,63 +35019,23 @@ var OdsServerSideDatagrid = function OdsServerSideDatagrid(props) {
35018
35019
  gridStyle = _useStyles.styles;
35019
35020
  var renderTotal = React.useCallback(function () {
35020
35021
  var _props$customSummary, _props$customSummary2, _props$customSummary3, _props$customSummary4;
35021
- var totalLoaded = rowCount.current;
35022
+ var totalLoaded = filterApplied ? totalFilteredCount.current : totalUnfilteredCount.current;
35022
35023
  var loadedPage = currentPage + 1;
35023
35024
  var totalRecords = props.totalRecordCount;
35024
35025
  var totalPageCount = Math.ceil(totalRecords / currentPageSize);
35025
- if (totalLoaded === 0) {
35026
+ if (totalLoaded === 0 || totalLoaded === -1) {
35026
35027
  return "";
35027
35028
  }
35028
35029
  var displayText = filterApplied ? totalLoaded + " " + ((_props$customSummary = props.customSummary) === null || _props$customSummary === void 0 ? void 0 : _props$customSummary.summaryFilteredDataLabel) + " - " : totalLoaded + " " + ((_props$customSummary2 = props.customSummary) === null || _props$customSummary2 === void 0 ? void 0 : _props$customSummary2.summaryLoadedDataLabel) + " - ";
35029
35030
  var result = "" + displayText + totalRecords + " " + ((_props$customSummary3 = props.customSummary) === null || _props$customSummary3 === void 0 ? void 0 : _props$customSummary3.summaryTotalDataLabel);
35030
35031
  result += " - " + ((_props$customSummary4 = props.customSummary) === null || _props$customSummary4 === void 0 ? void 0 : _props$customSummary4.summaryTotalPageCountLabel) + " " + loadedPage + " / " + totalPageCount;
35031
35032
  return result;
35032
- }, [props.totalRecordCount, currentPageSize, props.customSummary, currentPage, filteredRowCount.current, filterApplied]);
35033
- React.useEffect(function () {
35034
- var loadFilterData = function loadFilterData() {
35035
- try {
35036
- var newFilterOptions = {};
35037
- var _loop = function _loop() {
35038
- var col = _step.value;
35039
- try {
35040
- if (headerFilterData.length > 0) {
35041
- var newData = headerFilterData.filter(function (item) {
35042
- return item[col.dataField] != null && item[col.dataField] !== "";
35043
- }).map(function (item) {
35044
- return item[col.dataField].toString();
35045
- });
35046
- var values = newData.map(function (group) {
35047
- return {
35048
- text: group,
35049
- value: group
35050
- };
35051
- });
35052
- newFilterOptions[col.dataField] = values;
35053
- }
35054
- } catch (error) {
35055
- console.error('Error loading data for header filter:', error);
35056
- }
35057
- };
35058
- for (var _iterator = _createForOfIteratorHelperLoose(props.columns), _step; !(_step = _iterator()).done;) {
35059
- _loop();
35060
- }
35061
- setFilterOptions(newFilterOptions);
35062
- return Promise.resolve();
35063
- } catch (e) {
35064
- return Promise.reject(e);
35065
- }
35066
- };
35067
- loadFilterData();
35068
- }, [headerFilterData]);
35069
- React.useEffect(function () {
35070
- setHeaderFilterData([]);
35071
- }, []);
35033
+ }, [currentPage, currentPageSize, filterApplied, props.customSummary, props.totalRecordCount]);
35072
35034
  var handleContentReady = React.useCallback(function (e) {
35073
35035
  var _dataGridInstance$get;
35074
35036
  var dataGridInstance = e.component;
35075
35037
  var currentPageIndex = dataGridInstance.pageIndex();
35076
35038
  var currentTotalCount = dataGridInstance.totalCount();
35077
- var currentPageSizeValue = dataGridInstance.pageSize();
35078
35039
  var newData = dataGridInstance === null || dataGridInstance === void 0 ? void 0 : (_dataGridInstance$get = dataGridInstance.getDataSource()) === null || _dataGridInstance$get === void 0 ? void 0 : _dataGridInstance$get.items();
35079
35040
  if (lastPageIndexRef.current !== currentPageIndex && newData && newData.length > 0) {
35080
35041
  setHeaderFilterData(function (prevData) {
@@ -35103,24 +35064,94 @@ var OdsServerSideDatagrid = function OdsServerSideDatagrid(props) {
35103
35064
  });
35104
35065
  return [].concat(prevData, newItems);
35105
35066
  });
35067
+ setCurrentPage(currentPageIndex);
35068
+ setCurrentPageSize(dataGridInstance.pageSize());
35069
+ rowCount.current = currentTotalCount;
35070
+ if (filterApplied) {
35071
+ totalFilteredCount.current = currentTotalCount;
35072
+ } else {
35073
+ totalUnfilteredCount.current = currentTotalCount;
35074
+ }
35075
+ if (!filterApplied && totalFilteredCount.current === 0) {
35076
+ totalFilteredCount.current = totalUnfilteredCount.current;
35077
+ }
35078
+ setUpdateTrigger(function (prev) {
35079
+ return !prev;
35080
+ });
35106
35081
  lastPageIndexRef.current = currentPageIndex;
35107
- if (!contentReady) setContentReady(true);
35108
35082
  }
35109
- setCurrentPage(currentPageIndex);
35110
- setCurrentPageSize(currentPageSizeValue);
35111
- rowCount.current = currentTotalCount > -1 ? currentTotalCount : rowCount.current;
35112
- }, []);
35083
+ }, [props.columns, filterApplied]);
35113
35084
  var handleOptionChanged = React.useCallback(function (e) {
35085
+ var dataGrid = props.dataGridRef.current.instance;
35086
+ var updateFilterStatus = function updateFilterStatus(value) {
35087
+ var active = value !== "" && value !== null && value !== undefined && !(Array.isArray(value) && value.length === 0);
35088
+ setFilterApplied(active);
35089
+ return active;
35090
+ };
35114
35091
  if (e.fullName.includes("sortOrder")) {
35115
- props.dataGridRef.current.instance.getScrollable().scrollTo(0);
35092
+ dataGrid.getScrollable().scrollTo(0);
35116
35093
  }
35094
+ var filterActive = false;
35117
35095
  if (e.name === "filterValue") {
35118
- setFilterApplied(!!(e.value && e.value.length > 0));
35096
+ filterActive = updateFilterStatus(e.value);
35119
35097
  } else if (e.name === "columns" && e.fullName.includes("filterValue")) {
35120
- setFilterApplied(!!e.value);
35121
- } else if (e.name === "filterPanel" && e.fullName === "filterPanel.filterEnabled") {
35098
+ filterActive = updateFilterStatus(e.value);
35099
+ } else if (e.name === "filterPanel" && e.fullName.includes("filterPanel.filterEnabled")) {
35122
35100
  setFilterApplied(e.value);
35101
+ filterActive = e.value;
35102
+ } else if (e.fullName.includes("searchPanel.text")) {
35103
+ filterActive = updateFilterStatus(e.value);
35104
+ }
35105
+ if (filterActive) {
35106
+ setTimeout(function () {
35107
+ dataGrid.refresh().done(function () {
35108
+ totalFilteredCount.current = dataGrid.totalCount();
35109
+ setUpdateTrigger(function (prev) {
35110
+ return !prev;
35111
+ });
35112
+ });
35113
+ }, 0);
35123
35114
  }
35115
+ }, [props.dataGridRef]);
35116
+ React.useEffect(function () {}, [updateTrigger]);
35117
+ React.useEffect(function () {
35118
+ var loadFilterData = function loadFilterData() {
35119
+ try {
35120
+ var newFilterOptions = {};
35121
+ var _loop = function _loop() {
35122
+ var col = _step.value;
35123
+ try {
35124
+ if (headerFilterData.length > 0) {
35125
+ var newData = headerFilterData.filter(function (item) {
35126
+ return item[col.dataField] != null && item[col.dataField] !== "";
35127
+ }).map(function (item) {
35128
+ return item[col.dataField].toString();
35129
+ });
35130
+ var values = newData.map(function (group) {
35131
+ return {
35132
+ text: group,
35133
+ value: group
35134
+ };
35135
+ });
35136
+ newFilterOptions[col.dataField] = values;
35137
+ }
35138
+ } catch (error) {
35139
+ console.error('Error loading data for header filter:', error);
35140
+ }
35141
+ };
35142
+ for (var _iterator = _createForOfIteratorHelperLoose(props.columns), _step; !(_step = _iterator()).done;) {
35143
+ _loop();
35144
+ }
35145
+ setFilterOptions(newFilterOptions);
35146
+ return Promise.resolve();
35147
+ } catch (e) {
35148
+ return Promise.reject(e);
35149
+ }
35150
+ };
35151
+ loadFilterData();
35152
+ }, [headerFilterData, props.columns]);
35153
+ React.useEffect(function () {
35154
+ setHeaderFilterData([]);
35124
35155
  }, []);
35125
35156
  var actionButtons = React.useMemo(function () {
35126
35157
  if (props.actionButtonGroup) {