@performant-software/semantic-components 0.5.7 → 0.5.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@performant-software/semantic-components",
3
- "version": "0.5.7",
3
+ "version": "0.5.8",
4
4
  "description": "A package of shared components based on the Semantic UI Framework.",
5
5
  "license": "MIT",
6
6
  "main": "./build/index.js",
@@ -12,7 +12,7 @@
12
12
  "build": "webpack --mode production && flow-copy-source -v src types"
13
13
  },
14
14
  "dependencies": {
15
- "@performant-software/shared-components": "^0.5.7",
15
+ "@performant-software/shared-components": "^0.5.8",
16
16
  "@react-google-maps/api": "^2.8.1",
17
17
  "axios": "^0.26.1",
18
18
  "i18next": "^19.4.4",
@@ -32,7 +32,7 @@
32
32
  "react-dom": ">= 16.13.1 < 18.0.0"
33
33
  },
34
34
  "devDependencies": {
35
- "@performant-software/webpack-config": "^0.5.7",
35
+ "@performant-software/webpack-config": "^0.5.8",
36
36
  "flow-copy-source": "^2.0.9",
37
37
  "less": "^4.1.2",
38
38
  "less-loader": "^11.0.0",
@@ -1,6 +1,6 @@
1
1
  // @flow
2
2
 
3
- import { Browser } from '@performant-software/shared-components';
3
+ import { Browser, Object as ObjectUtils } from '@performant-software/shared-components';
4
4
  import React, { Component, createRef, type Element } from 'react';
5
5
  import {
6
6
  Checkbox,
@@ -122,6 +122,17 @@ class DataTable extends Component<Props, State> {
122
122
  }
123
123
  }
124
124
 
125
+ /**
126
+ * Reinitialize the column refs if the columns change.
127
+ *
128
+ * @param prevProps
129
+ */
130
+ componentDidUpdate(prevProps: Props) {
131
+ if (!ObjectUtils.isEqual(prevProps.columns, this.props.columns)) {
132
+ this.initializeColumnRefs();
133
+ }
134
+ }
135
+
125
136
  /**
126
137
  * Removes the mousemove and mouseup event listeners.
127
138
  */
@@ -1,5 +1,6 @@
1
1
  // @flow
2
2
 
3
+ import { Object as ObjectUtils } from '@performant-software/shared-components';
3
4
  import React, { Component, type ComponentType, type Element } from 'react';
4
5
  import { Checkbox, Dropdown, Icon } from 'semantic-ui-react';
5
6
  import _ from 'underscore';
@@ -49,7 +50,7 @@ const useColumnSelector = (WrappedComponent: ComponentType<any>) => (
49
50
  * @param prevProps
50
51
  */
51
52
  componentDidUpdate(prevProps: Props): * {
52
- if (prevProps.columns !== this.props.columns) {
53
+ if (!ObjectUtils.isEqual(prevProps.columns, this.props.columns)) {
53
54
  this.setState({ columns: this.props.columns });
54
55
  }
55
56
  }
@@ -1,5 +1,6 @@
1
1
  // @flow
2
2
 
3
+ import { Hooks, Object as ObjectUtils } from '@performant-software/shared-components';
3
4
  import React, { useEffect } from 'react';
4
5
  import _ from 'underscore';
5
6
  import DataTable from './DataTable';
@@ -20,6 +21,8 @@ type Props = {
20
21
  };
21
22
 
22
23
  const ListTable = (props: Props) => {
24
+ const prevColumns = Hooks.usePrevious(props.columns);
25
+
23
26
  /**
24
27
  * Sorts the list by the selected column, and/or reverse the direction.
25
28
  *
@@ -51,18 +54,24 @@ const ListTable = (props: Props) => {
51
54
  * sortable column.
52
55
  */
53
56
  useEffect(() => {
54
- const { page, defaultSort, defaultSortDirection = SORT_ASCENDING } = props;
55
-
56
- if (defaultSort) {
57
- props.onSort(defaultSort, defaultSortDirection, page);
58
- } else {
59
- const sortableColumn = _.findWhere(props.columns, { sortable: true });
57
+ if (!ObjectUtils.isEqual(props.columns, prevColumns)) {
58
+ const {
59
+ page,
60
+ defaultSort,
61
+ defaultSortDirection = SORT_ASCENDING
62
+ } = props;
60
63
 
61
- if (sortableColumn) {
62
- onColumnClick(sortableColumn);
64
+ if (defaultSort) {
65
+ props.onSort(defaultSort, defaultSortDirection, page);
63
66
  } else {
64
- // If no columns are sortable, load the data as is
65
- props.onInit();
67
+ const sortableColumn = _.findWhere(props.columns, { sortable: true });
68
+
69
+ if (sortableColumn) {
70
+ onColumnClick(sortableColumn);
71
+ } else {
72
+ // If no columns are sortable, load the data as is
73
+ props.onInit();
74
+ }
66
75
  }
67
76
  }
68
77
  }, [props.columns]);
@@ -1,6 +1,6 @@
1
1
  // @flow
2
2
 
3
- import { Browser } from '@performant-software/shared-components';
3
+ import { Browser, Object as ObjectUtils } from '@performant-software/shared-components';
4
4
  import React, { Component, createRef, type Element } from 'react';
5
5
  import {
6
6
  Checkbox,
@@ -122,6 +122,17 @@ class DataTable extends Component<Props, State> {
122
122
  }
123
123
  }
124
124
 
125
+ /**
126
+ * Reinitialize the column refs if the columns change.
127
+ *
128
+ * @param prevProps
129
+ */
130
+ componentDidUpdate(prevProps: Props) {
131
+ if (!ObjectUtils.isEqual(prevProps.columns, this.props.columns)) {
132
+ this.initializeColumnRefs();
133
+ }
134
+ }
135
+
125
136
  /**
126
137
  * Removes the mousemove and mouseup event listeners.
127
138
  */
@@ -1,5 +1,6 @@
1
1
  // @flow
2
2
 
3
+ import { Object as ObjectUtils } from '@performant-software/shared-components';
3
4
  import React, { Component, type ComponentType, type Element } from 'react';
4
5
  import { Checkbox, Dropdown, Icon } from 'semantic-ui-react';
5
6
  import _ from 'underscore';
@@ -49,7 +50,7 @@ const useColumnSelector = (WrappedComponent: ComponentType<any>) => (
49
50
  * @param prevProps
50
51
  */
51
52
  componentDidUpdate(prevProps: Props): * {
52
- if (prevProps.columns !== this.props.columns) {
53
+ if (!ObjectUtils.isEqual(prevProps.columns, this.props.columns)) {
53
54
  this.setState({ columns: this.props.columns });
54
55
  }
55
56
  }
@@ -1,5 +1,6 @@
1
1
  // @flow
2
2
 
3
+ import { Hooks, Object as ObjectUtils } from '@performant-software/shared-components';
3
4
  import React, { useEffect } from 'react';
4
5
  import _ from 'underscore';
5
6
  import DataTable from './DataTable';
@@ -20,6 +21,8 @@ type Props = {
20
21
  };
21
22
 
22
23
  const ListTable = (props: Props) => {
24
+ const prevColumns = Hooks.usePrevious(props.columns);
25
+
23
26
  /**
24
27
  * Sorts the list by the selected column, and/or reverse the direction.
25
28
  *
@@ -51,18 +54,24 @@ const ListTable = (props: Props) => {
51
54
  * sortable column.
52
55
  */
53
56
  useEffect(() => {
54
- const { page, defaultSort, defaultSortDirection = SORT_ASCENDING } = props;
55
-
56
- if (defaultSort) {
57
- props.onSort(defaultSort, defaultSortDirection, page);
58
- } else {
59
- const sortableColumn = _.findWhere(props.columns, { sortable: true });
57
+ if (!ObjectUtils.isEqual(props.columns, prevColumns)) {
58
+ const {
59
+ page,
60
+ defaultSort,
61
+ defaultSortDirection = SORT_ASCENDING
62
+ } = props;
60
63
 
61
- if (sortableColumn) {
62
- onColumnClick(sortableColumn);
64
+ if (defaultSort) {
65
+ props.onSort(defaultSort, defaultSortDirection, page);
63
66
  } else {
64
- // If no columns are sortable, load the data as is
65
- props.onInit();
67
+ const sortableColumn = _.findWhere(props.columns, { sortable: true });
68
+
69
+ if (sortableColumn) {
70
+ onColumnClick(sortableColumn);
71
+ } else {
72
+ // If no columns are sortable, load the data as is
73
+ props.onInit();
74
+ }
66
75
  }
67
76
  }
68
77
  }, [props.columns]);