@performant-software/semantic-components 1.0.4-beta.2 → 1.0.4-beta.3

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": "1.0.4-beta.2",
3
+ "version": "1.0.4-beta.3",
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": "^1.0.4-beta.2",
15
+ "@performant-software/shared-components": "^1.0.4-beta.3",
16
16
  "@react-google-maps/api": "^2.8.1",
17
17
  "axios": "^0.26.1",
18
18
  "citeproc": "^2.4.62",
@@ -256,22 +256,27 @@ const FileUploadModal: ComponentType<any> = (props: Props) => {
256
256
  const onValidate = useCallback(() => new Promise((resolve, reject) => {
257
257
  let error = false;
258
258
 
259
- setItems((prevItems) => _.map(prevItems, (item) => {
260
- const valid = validateItem(item);
259
+ // Validate each item
260
+ const newItems = _.map(items, (item) => {
261
+ const newItem = validateItem(item);
261
262
 
262
- if (!_.isEmpty(item.errors)) {
263
+ if (!_.isEmpty(newItem.errors)) {
263
264
  error = true;
264
265
  }
265
266
 
266
- return valid;
267
- }));
267
+ return newItem;
268
+ });
269
+
270
+ // Set the new items on the state
271
+ setItems(newItems);
268
272
 
273
+ // Reject or resolve the promise
269
274
  if (error) {
270
275
  reject();
271
276
  } else {
272
277
  resolve();
273
278
  }
274
- }), []);
279
+ }), [items]);
275
280
 
276
281
  /**
277
282
  * Updates the passed item with the passed props.
@@ -256,22 +256,27 @@ const FileUploadModal: ComponentType<any> = (props: Props) => {
256
256
  const onValidate = useCallback(() => new Promise((resolve, reject) => {
257
257
  let error = false;
258
258
 
259
- setItems((prevItems) => _.map(prevItems, (item) => {
260
- const valid = validateItem(item);
259
+ // Validate each item
260
+ const newItems = _.map(items, (item) => {
261
+ const newItem = validateItem(item);
261
262
 
262
- if (!_.isEmpty(item.errors)) {
263
+ if (!_.isEmpty(newItem.errors)) {
263
264
  error = true;
264
265
  }
265
266
 
266
- return valid;
267
- }));
267
+ return newItem;
268
+ });
269
+
270
+ // Set the new items on the state
271
+ setItems(newItems);
268
272
 
273
+ // Reject or resolve the promise
269
274
  if (error) {
270
275
  reject();
271
276
  } else {
272
277
  resolve();
273
278
  }
274
- }), []);
279
+ }), [items]);
275
280
 
276
281
  /**
277
282
  * Updates the passed item with the passed props.