@valbuild/react 0.43.0 → 0.44.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.
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./ValProvider-1bf1d7e4.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./ValProvider-1bf1d7e4.cjs.dev.js");
7
+ }
@@ -662,25 +662,31 @@ function ValProvider(_ref) {
662
662
  _useState2 = slicedToArray._slicedToArray(_useState, 2),
663
663
  isClient = _useState2[0],
664
664
  setIsClient = _useState2[1];
665
- var _useState3 = React.useState(false),
665
+ var _useState3 = React.useState(),
666
666
  _useState4 = slicedToArray._slicedToArray(_useState3, 2),
667
667
  enabled = _useState4[0],
668
668
  setEnabled = _useState4[1];
669
669
  React.useEffect(function () {
670
670
  setIsClient(true);
671
671
  try {
672
- var _document$cookie;
672
+ var _document$cookie, _document$cookie2;
673
673
  var valEnabled = (_document$cookie = document.cookie) === null || _document$cookie === void 0 ? void 0 : _document$cookie.includes("".concat(core.Internal.VAL_ENABLE_COOKIE_NAME, "=true"));
674
- setEnabled(valEnabled);
674
+ if (valEnabled) {
675
+ setEnabled(true);
676
+ }
677
+ var valDisabled = (_document$cookie2 = document.cookie) === null || _document$cookie2 === void 0 ? void 0 : _document$cookie2.includes("".concat(core.Internal.VAL_ENABLE_COOKIE_NAME, "=false"));
678
+ if (valDisabled) {
679
+ setEnabled(false);
680
+ }
681
+ // If we are in development and Val is not enabled or disabled, enable Val
682
+ if ( "production" === "development" && !valEnabled && !valDisabled) ;
675
683
  } catch (e) {
676
684
  console.warn("Could not read Val enabled state", e);
677
685
  }
678
686
  }, []);
679
- if (isClient && !enabled && "production" === "development") {
687
+ if (isClient && !enabled) {
680
688
  if (!api) {
681
689
  console.warn("Val does not seem to be configured properly! Please check that you have wrapper your root layout (or _app) with the ValProvider.");
682
- } else {
683
- console.log("Val is disabled. Enable it by going here ".concat(window.origin).concat(api.host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href), ". NOTE: this message appears because NODE_ENV is set to development."));
684
690
  }
685
691
  }
686
692
  if (!isClient || !enabled || !store || !api || !ValContext) {
@@ -636,25 +636,37 @@ function ValProvider(_ref) {
636
636
  _useState2 = _slicedToArray(_useState, 2),
637
637
  isClient = _useState2[0],
638
638
  setIsClient = _useState2[1];
639
- var _useState3 = useState(false),
639
+ var _useState3 = useState(),
640
640
  _useState4 = _slicedToArray(_useState3, 2),
641
641
  enabled = _useState4[0],
642
642
  setEnabled = _useState4[1];
643
643
  useEffect(function () {
644
644
  setIsClient(true);
645
645
  try {
646
- var _document$cookie;
646
+ var _document$cookie, _document$cookie2;
647
647
  var valEnabled = (_document$cookie = document.cookie) === null || _document$cookie === void 0 ? void 0 : _document$cookie.includes("".concat(Internal.VAL_ENABLE_COOKIE_NAME, "=true"));
648
- setEnabled(valEnabled);
648
+ if (valEnabled) {
649
+ setEnabled(true);
650
+ }
651
+ var valDisabled = (_document$cookie2 = document.cookie) === null || _document$cookie2 === void 0 ? void 0 : _document$cookie2.includes("".concat(Internal.VAL_ENABLE_COOKIE_NAME, "=false"));
652
+ if (valDisabled) {
653
+ setEnabled(false);
654
+ }
655
+ // If we are in development and Val is not enabled or disabled, enable Val
656
+ if (process.env.NODE_ENV === "development" && !valEnabled && !valDisabled) {
657
+ window.location.href = "".concat(window.origin).concat(host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href));
658
+ }
649
659
  } catch (e) {
650
660
  console.warn("Could not read Val enabled state", e);
651
661
  }
652
662
  }, []);
653
- if (isClient && !enabled && process.env.NODE_ENV === "development") {
663
+ if (isClient && !enabled) {
654
664
  if (!api) {
655
665
  console.warn("Val does not seem to be configured properly! Please check that you have wrapper your root layout (or _app) with the ValProvider.");
656
666
  } else {
657
- console.log("Val is disabled. Enable it by going here ".concat(window.origin).concat(api.host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href), ". NOTE: this message appears because NODE_ENV is set to development."));
667
+ if (process.env.NODE_ENV === "development") {
668
+ console.log("Val is disabled. Enable it by going here: ".concat(window.origin).concat(api.host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href), ". NOTE: this message appears because NODE_ENV is set to development."));
669
+ }
658
670
  }
659
671
  }
660
672
  if (!isClient || !enabled || !store || !api || !ValContext) {
@@ -662,25 +662,37 @@ function ValProvider(_ref) {
662
662
  _useState2 = slicedToArray._slicedToArray(_useState, 2),
663
663
  isClient = _useState2[0],
664
664
  setIsClient = _useState2[1];
665
- var _useState3 = React.useState(false),
665
+ var _useState3 = React.useState(),
666
666
  _useState4 = slicedToArray._slicedToArray(_useState3, 2),
667
667
  enabled = _useState4[0],
668
668
  setEnabled = _useState4[1];
669
669
  React.useEffect(function () {
670
670
  setIsClient(true);
671
671
  try {
672
- var _document$cookie;
672
+ var _document$cookie, _document$cookie2;
673
673
  var valEnabled = (_document$cookie = document.cookie) === null || _document$cookie === void 0 ? void 0 : _document$cookie.includes("".concat(core.Internal.VAL_ENABLE_COOKIE_NAME, "=true"));
674
- setEnabled(valEnabled);
674
+ if (valEnabled) {
675
+ setEnabled(true);
676
+ }
677
+ var valDisabled = (_document$cookie2 = document.cookie) === null || _document$cookie2 === void 0 ? void 0 : _document$cookie2.includes("".concat(core.Internal.VAL_ENABLE_COOKIE_NAME, "=false"));
678
+ if (valDisabled) {
679
+ setEnabled(false);
680
+ }
681
+ // If we are in development and Val is not enabled or disabled, enable Val
682
+ if (process.env.NODE_ENV === "development" && !valEnabled && !valDisabled) {
683
+ window.location.href = "".concat(window.origin).concat(host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href));
684
+ }
675
685
  } catch (e) {
676
686
  console.warn("Could not read Val enabled state", e);
677
687
  }
678
688
  }, []);
679
- if (isClient && !enabled && process.env.NODE_ENV === "development") {
689
+ if (isClient && !enabled) {
680
690
  if (!api) {
681
691
  console.warn("Val does not seem to be configured properly! Please check that you have wrapper your root layout (or _app) with the ValProvider.");
682
692
  } else {
683
- console.log("Val is disabled. Enable it by going here ".concat(window.origin).concat(api.host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href), ". NOTE: this message appears because NODE_ENV is set to development."));
693
+ if (process.env.NODE_ENV === "development") {
694
+ console.log("Val is disabled. Enable it by going here: ".concat(window.origin).concat(api.host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href), ". NOTE: this message appears because NODE_ENV is set to development."));
695
+ }
684
696
  }
685
697
  }
686
698
  if (!isClient || !enabled || !store || !api || !ValContext) {
@@ -636,25 +636,37 @@ function ValProvider(_ref) {
636
636
  _useState2 = _slicedToArray(_useState, 2),
637
637
  isClient = _useState2[0],
638
638
  setIsClient = _useState2[1];
639
- var _useState3 = useState(false),
639
+ var _useState3 = useState(),
640
640
  _useState4 = _slicedToArray(_useState3, 2),
641
641
  enabled = _useState4[0],
642
642
  setEnabled = _useState4[1];
643
643
  useEffect(function () {
644
644
  setIsClient(true);
645
645
  try {
646
- var _document$cookie;
646
+ var _document$cookie, _document$cookie2;
647
647
  var valEnabled = (_document$cookie = document.cookie) === null || _document$cookie === void 0 ? void 0 : _document$cookie.includes("".concat(Internal.VAL_ENABLE_COOKIE_NAME, "=true"));
648
- setEnabled(valEnabled);
648
+ if (valEnabled) {
649
+ setEnabled(true);
650
+ }
651
+ var valDisabled = (_document$cookie2 = document.cookie) === null || _document$cookie2 === void 0 ? void 0 : _document$cookie2.includes("".concat(Internal.VAL_ENABLE_COOKIE_NAME, "=false"));
652
+ if (valDisabled) {
653
+ setEnabled(false);
654
+ }
655
+ // If we are in development and Val is not enabled or disabled, enable Val
656
+ if (process.env.NODE_ENV === "development" && !valEnabled && !valDisabled) {
657
+ window.location.href = "".concat(window.origin).concat(host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href));
658
+ }
649
659
  } catch (e) {
650
660
  console.warn("Could not read Val enabled state", e);
651
661
  }
652
662
  }, []);
653
- if (isClient && !enabled && process.env.NODE_ENV === "development") {
663
+ if (isClient && !enabled) {
654
664
  if (!api) {
655
665
  console.warn("Val does not seem to be configured properly! Please check that you have wrapper your root layout (or _app) with the ValProvider.");
656
666
  } else {
657
- console.log("Val is disabled. Enable it by going here ".concat(window.origin).concat(api.host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href), ". NOTE: this message appears because NODE_ENV is set to development."));
667
+ if (process.env.NODE_ENV === "development") {
668
+ console.log("Val is disabled. Enable it by going here: ".concat(window.origin).concat(api.host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href), ". NOTE: this message appears because NODE_ENV is set to development."));
669
+ }
658
670
  }
659
671
  }
660
672
  if (!isClient || !enabled || !store || !api || !ValContext) {
@@ -631,25 +631,37 @@ function ValProvider(_ref) {
631
631
  _useState2 = _slicedToArray(_useState, 2),
632
632
  isClient = _useState2[0],
633
633
  setIsClient = _useState2[1];
634
- var _useState3 = useState(false),
634
+ var _useState3 = useState(),
635
635
  _useState4 = _slicedToArray(_useState3, 2),
636
636
  enabled = _useState4[0],
637
637
  setEnabled = _useState4[1];
638
638
  useEffect(function () {
639
639
  setIsClient(true);
640
640
  try {
641
- var _document$cookie;
641
+ var _document$cookie, _document$cookie2;
642
642
  var valEnabled = (_document$cookie = document.cookie) === null || _document$cookie === void 0 ? void 0 : _document$cookie.includes("".concat(Internal.VAL_ENABLE_COOKIE_NAME, "=true"));
643
- setEnabled(valEnabled);
643
+ if (valEnabled) {
644
+ setEnabled(true);
645
+ }
646
+ var valDisabled = (_document$cookie2 = document.cookie) === null || _document$cookie2 === void 0 ? void 0 : _document$cookie2.includes("".concat(Internal.VAL_ENABLE_COOKIE_NAME, "=false"));
647
+ if (valDisabled) {
648
+ setEnabled(false);
649
+ }
650
+ // If we are in development and Val is not enabled or disabled, enable Val
651
+ if (process.env.NODE_ENV === "development" && !valEnabled && !valDisabled) {
652
+ window.location.href = "".concat(window.origin).concat(host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href));
653
+ }
644
654
  } catch (e) {
645
655
  console.warn("Could not read Val enabled state", e);
646
656
  }
647
657
  }, []);
648
- if (isClient && !enabled && process.env.NODE_ENV === "development") {
658
+ if (isClient && !enabled) {
649
659
  if (!api) {
650
660
  console.warn("Val does not seem to be configured properly! Please check that you have wrapper your root layout (or _app) with the ValProvider.");
651
661
  } else {
652
- console.log("Val is disabled. Enable it by going here ".concat(window.origin).concat(api.host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href), ". NOTE: this message appears because NODE_ENV is set to development."));
662
+ if (process.env.NODE_ENV === "development") {
663
+ console.log("Val is disabled. Enable it by going here: ".concat(window.origin).concat(api.host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href), ". NOTE: this message appears because NODE_ENV is set to development."));
664
+ }
653
665
  }
654
666
  }
655
667
  if (!isClient || !enabled || !store || !api || !ValContext) {
@@ -8,7 +8,7 @@ var slicedToArray = require('./slicedToArray-a2a426c7.cjs.prod.js');
8
8
  var React = require('react');
9
9
  var reactDom = require('react-dom');
10
10
  var ReactJSXRuntime = require('react/jsx-runtime');
11
- var ValProvider = require('./ValProvider-8d8e3678.cjs.prod.js');
11
+ var ValProvider = require('./ValProvider-1bf1d7e4.cjs.prod.js');
12
12
 
13
13
  function ShadowContent(_ref) {
14
14
  var root = _ref.root,
@@ -4,7 +4,7 @@ import { _ as _slicedToArray } from './slicedToArray-d4c4a4ed.worker.esm.js';
4
4
  import { useRef, useState, useLayoutEffect } from 'react';
5
5
  import { createPortal } from 'react-dom';
6
6
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
7
- import { useValApi, useValStore } from './ValProvider-e21d3e7d.worker.esm.js';
7
+ import { useValApi, useValStore } from './ValProvider-a29fe950.worker.esm.js';
8
8
 
9
9
  function ShadowContent(_ref) {
10
10
  var root = _ref.root,
@@ -4,7 +4,7 @@ import { _ as _slicedToArray } from './slicedToArray-85f6bb43.browser.esm.js';
4
4
  import { useRef, useState, useLayoutEffect } from 'react';
5
5
  import { createPortal } from 'react-dom';
6
6
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
7
- import { useValApi, useValStore } from './ValProvider-9a2431d9.browser.esm.js';
7
+ import { useValApi, useValStore } from './ValProvider-36edbac3.browser.esm.js';
8
8
 
9
9
  function ShadowContent(_ref) {
10
10
  var root = _ref.root,
@@ -4,7 +4,7 @@ import { _ as _slicedToArray } from './slicedToArray-331bebbb.esm.js';
4
4
  import { useRef, useState, useLayoutEffect } from 'react';
5
5
  import { createPortal } from 'react-dom';
6
6
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
7
- import { useValApi, useValStore } from './ValProvider-52a0ce49.esm.js';
7
+ import { useValApi, useValStore } from './ValProvider-87475f3a.esm.js';
8
8
 
9
9
  function ShadowContent(_ref) {
10
10
  var root = _ref.root,
@@ -8,7 +8,7 @@ var slicedToArray = require('./slicedToArray-a9d0d9cd.cjs.dev.js');
8
8
  var React = require('react');
9
9
  var reactDom = require('react-dom');
10
10
  var ReactJSXRuntime = require('react/jsx-runtime');
11
- var ValProvider = require('./ValProvider-387a3070.cjs.dev.js');
11
+ var ValProvider = require('./ValProvider-3f3f21ba.cjs.dev.js');
12
12
 
13
13
  function ShadowContent(_ref) {
14
14
  var root = _ref.root,
@@ -1,4 +1,4 @@
1
- export { ValProvider, useValApi, useValStore } from '../../dist/ValProvider-9a2431d9.browser.esm.js';
1
+ export { ValProvider, useValApi, useValStore } from '../../dist/ValProvider-36edbac3.browser.esm.js';
2
2
  import React from 'react';
3
3
  import { jsx } from 'react/jsx-runtime';
4
4
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var ValProvider = require('../../dist/ValProvider-387a3070.cjs.dev.js');
5
+ var ValProvider = require('../../dist/ValProvider-3f3f21ba.cjs.dev.js');
6
6
  var React = require('react');
7
7
  var ReactJSXRuntime = require('react/jsx-runtime');
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var ValProvider = require('../../dist/ValProvider-8d8e3678.cjs.prod.js');
5
+ var ValProvider = require('../../dist/ValProvider-1bf1d7e4.cjs.prod.js');
6
6
  var React = require('react');
7
7
  var ReactJSXRuntime = require('react/jsx-runtime');
8
8
 
@@ -1,4 +1,4 @@
1
- export { ValProvider, useValApi, useValStore } from '../../dist/ValProvider-52a0ce49.esm.js';
1
+ export { ValProvider, useValApi, useValStore } from '../../dist/ValProvider-87475f3a.esm.js';
2
2
  import React from 'react';
3
3
  import { jsx } from 'react/jsx-runtime';
4
4
 
@@ -1,4 +1,4 @@
1
- export { ValProvider, useValApi, useValStore } from '../../dist/ValProvider-e21d3e7d.worker.esm.js';
1
+ export { ValProvider, useValApi, useValStore } from '../../dist/ValProvider-a29fe950.worker.esm.js';
2
2
  import React from 'react';
3
3
  import { jsx } from 'react/jsx-runtime';
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/react",
3
- "version": "0.43.0",
3
+ "version": "0.44.0",
4
4
  "private": false,
5
5
  "description": "Val - React internal helpers",
6
6
  "sideEffects": false,
@@ -9,9 +9,9 @@
9
9
  "test": "jest"
10
10
  },
11
11
  "dependencies": {
12
- "@valbuild/core": "~0.43.0",
13
- "@valbuild/shared": "~0.43.0",
14
- "@valbuild/ui": "~0.43.0",
12
+ "@valbuild/core": "~0.44.0",
13
+ "@valbuild/shared": "~0.44.0",
14
+ "@valbuild/ui": "~0.44.0",
15
15
  "@vercel/stega": "^0.1.0",
16
16
  "base64-arraybuffer": "^1.0.2",
17
17
  "style-to-object": "^0.4.1"
@@ -28,7 +28,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
28
28
  if (valPath) {
29
29
  valSources.push(valPath);
30
30
  props[key] = isIntrinsicElement(type) ? vercelStegaSplit(value).cleaned : value;
31
- props["data-val-attr-".concat(key)] = valPath;
31
+ props["data-val-attr-".concat(key.toLowerCase())] = valPath;
32
32
  }
33
33
  }
34
34
  }
@@ -38,7 +38,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
38
38
  if (valPath) {
39
39
  valSources.push(valPath);
40
40
  props[key] = isIntrinsicElement(type) ? stega.vercelStegaSplit(value).cleaned : value;
41
- props["data-val-attr-".concat(key)] = valPath;
41
+ props["data-val-attr-".concat(key.toLowerCase())] = valPath;
42
42
  }
43
43
  }
44
44
  }
@@ -38,7 +38,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
38
38
  if (valPath) {
39
39
  valSources.push(valPath);
40
40
  props[key] = isIntrinsicElement(type) ? stega.vercelStegaSplit(value).cleaned : value;
41
- props["data-val-attr-".concat(key)] = valPath;
41
+ props["data-val-attr-".concat(key.toLowerCase())] = valPath;
42
42
  }
43
43
  }
44
44
  }
@@ -28,7 +28,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
28
28
  if (valPath) {
29
29
  valSources.push(valPath);
30
30
  props[key] = isIntrinsicElement(type) ? vercelStegaSplit(value).cleaned : value;
31
- props["data-val-attr-".concat(key)] = valPath;
31
+ props["data-val-attr-".concat(key.toLowerCase())] = valPath;
32
32
  }
33
33
  }
34
34
  }
@@ -28,7 +28,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
28
28
  if (valPath) {
29
29
  valSources.push(valPath);
30
30
  props[key] = isIntrinsicElement(type) ? vercelStegaSplit(value).cleaned : value;
31
- props["data-val-attr-".concat(key)] = valPath;
31
+ props["data-val-attr-".concat(key.toLowerCase())] = valPath;
32
32
  }
33
33
  }
34
34
  }
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./ValProvider-8d8e3678.cjs.prod.js");
5
- } else {
6
- module.exports = require("./ValProvider-8d8e3678.cjs.dev.js");
7
- }