@flowerforce/flower-react 3.4.2-beta.0 → 3.5.1-beta.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 3.5.0 (2024-10-08)
2
+
3
+
4
+ ### 🚀 Features
5
+
6
+ - added "hasFocus" in useFlower and "focused" on FlowerField ([#66](https://github.com/flowerforce/flower/pull/66))
7
+
8
+
9
+ ### 🧱 Updated Dependencies
10
+
11
+ - Updated flower-core to 3.3.0
12
+
1
13
  ## 3.4.1 (2024-10-02)
2
14
 
3
15
 
package/dist/index.cjs.js CHANGED
@@ -410,11 +410,11 @@ function isIntrinsicElement$1(x) {
410
410
  //TODO make types for wrapper function props
411
411
  function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDebounce = 0, asyncValidate, asyncInitialError, asyncWaitingError, destroyValue, onBlur, onFocus, hidden, onUpdate, defaultValue, ...props }) {
412
412
  const dispatch = useDispatch();
413
- const [customAsyncErrors, setCustomAsyncErrors] = React.useState(asyncValidate && [asyncInitialError]);
413
+ const [customAsyncErrors, setCustomAsyncErrors] = React.useState(!hidden && asyncValidate && [asyncInitialError]);
414
414
  const [isValidating, setIsValidating] = React.useState(undefined);
415
415
  const { flowNameFromPath = flowName, path } = React.useMemo(() => flowerCore.CoreUtils.getPath(id), [id]);
416
416
  const value = useSelector(getDataFromState(flowNameFromPath, path));
417
- const errors = useSelector(makeSelectFieldError(flowName, id, validate), flowerCore.CoreUtils.allEqual);
417
+ const errors = useSelector(makeSelectFieldError(flowName, id, hidden ? [] : validate), flowerCore.CoreUtils.allEqual);
418
418
  const dirty = useSelector(makeSelectNodeFieldDirty(flowName, currentNode, id));
419
419
  const touched = useSelector(makeSelectNodeFieldTouched(flowName, currentNode, id));
420
420
  const focused = useSelector(makeSelectNodeFieldFocused(flowName, currentNode, id));
@@ -480,6 +480,8 @@ function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDeboun
480
480
  onFocus && onFocus(e);
481
481
  }, [onFocus, setFocus]);
482
482
  React.useEffect(() => {
483
+ if (hidden)
484
+ return;
483
485
  if (asyncValidate) {
484
486
  if (refValue.current === value)
485
487
  return;
@@ -493,7 +495,7 @@ function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDeboun
493
495
  setTouched(true);
494
496
  debouncedValidation(value);
495
497
  }
496
- }, [asyncValidate, asyncInitialError, value, debouncedValidation, setTouched]);
498
+ }, [asyncValidate, asyncInitialError, value, debouncedValidation, setTouched, hidden]);
497
499
  React.useEffect(() => {
498
500
  if (onUpdate) {
499
501
  onUpdate(value);
package/dist/index.esm.js CHANGED
@@ -408,11 +408,11 @@ function isIntrinsicElement$1(x) {
408
408
  //TODO make types for wrapper function props
409
409
  function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDebounce = 0, asyncValidate, asyncInitialError, asyncWaitingError, destroyValue, onBlur, onFocus, hidden, onUpdate, defaultValue, ...props }) {
410
410
  const dispatch = useDispatch();
411
- const [customAsyncErrors, setCustomAsyncErrors] = useState(asyncValidate && [asyncInitialError]);
411
+ const [customAsyncErrors, setCustomAsyncErrors] = useState(!hidden && asyncValidate && [asyncInitialError]);
412
412
  const [isValidating, setIsValidating] = useState(undefined);
413
413
  const { flowNameFromPath = flowName, path } = useMemo(() => CoreUtils.getPath(id), [id]);
414
414
  const value = useSelector(getDataFromState(flowNameFromPath, path));
415
- const errors = useSelector(makeSelectFieldError(flowName, id, validate), CoreUtils.allEqual);
415
+ const errors = useSelector(makeSelectFieldError(flowName, id, hidden ? [] : validate), CoreUtils.allEqual);
416
416
  const dirty = useSelector(makeSelectNodeFieldDirty(flowName, currentNode, id));
417
417
  const touched = useSelector(makeSelectNodeFieldTouched(flowName, currentNode, id));
418
418
  const focused = useSelector(makeSelectNodeFieldFocused(flowName, currentNode, id));
@@ -478,6 +478,8 @@ function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDeboun
478
478
  onFocus && onFocus(e);
479
479
  }, [onFocus, setFocus]);
480
480
  useEffect(() => {
481
+ if (hidden)
482
+ return;
481
483
  if (asyncValidate) {
482
484
  if (refValue.current === value)
483
485
  return;
@@ -491,7 +493,7 @@ function Wrapper$1({ Component, id, flowName, currentNode, validate, asyncDeboun
491
493
  setTouched(true);
492
494
  debouncedValidation(value);
493
495
  }
494
- }, [asyncValidate, asyncInitialError, value, debouncedValidation, setTouched]);
496
+ }, [asyncValidate, asyncInitialError, value, debouncedValidation, setTouched, hidden]);
495
497
  useEffect(() => {
496
498
  if (onUpdate) {
497
499
  onUpdate(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowerforce/flower-react",
3
- "version": "3.4.2-beta.0",
3
+ "version": "3.5.1-beta.0",
4
4
  "description": "FlowerJS components, hooks and utils for React.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,7 +34,7 @@
34
34
  "typescript": "^5.4.5"
35
35
  },
36
36
  "dependencies": {
37
- "@flowerforce/flower-core": "3.2.4-beta.0",
37
+ "@flowerforce/flower-core": "3.3.1-beta.0",
38
38
  "@reduxjs/toolkit": "^2.2.4",
39
39
  "lodash": "^4.17.21",
40
40
  "react-redux": "^9.1.2",