@valbuild/react 0.59.0 → 0.60.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.
Files changed (45) hide show
  1. package/dist/declarations/src/internal/index.d.ts +0 -1
  2. package/dist/{slicedToArray-11a666de.cjs.dev.js → slicedToArray-129629e4.cjs.dev.js} +11 -0
  3. package/dist/{slicedToArray-c405fbf0.cjs.prod.js → slicedToArray-386a8ae8.cjs.prod.js} +11 -0
  4. package/dist/{slicedToArray-7b69258f.browser.esm.js → slicedToArray-6b2002fa.browser.esm.js} +11 -1
  5. package/dist/{slicedToArray-e7da2c5e.worker.esm.js → slicedToArray-7a63acfd.worker.esm.js} +11 -1
  6. package/dist/{slicedToArray-1dc7d2d6.esm.js → slicedToArray-a79154e9.esm.js} +11 -1
  7. package/internal/dist/valbuild-react-internal.browser.esm.js +0 -1
  8. package/internal/dist/valbuild-react-internal.cjs.dev.js +0 -13
  9. package/internal/dist/valbuild-react-internal.cjs.prod.js +0 -13
  10. package/internal/dist/valbuild-react-internal.esm.js +0 -1
  11. package/internal/dist/valbuild-react-internal.worker.esm.js +0 -1
  12. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.browser.esm.js +1 -2
  13. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.cjs.dev.js +2 -3
  14. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.cjs.prod.js +2 -3
  15. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.esm.js +1 -2
  16. package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.worker.esm.js +1 -2
  17. package/jsx-runtime/dist/valbuild-react-jsx-runtime.browser.esm.js +1 -2
  18. package/jsx-runtime/dist/valbuild-react-jsx-runtime.cjs.dev.js +2 -3
  19. package/jsx-runtime/dist/valbuild-react-jsx-runtime.cjs.prod.js +2 -3
  20. package/jsx-runtime/dist/valbuild-react-jsx-runtime.esm.js +1 -2
  21. package/jsx-runtime/dist/valbuild-react-jsx-runtime.worker.esm.js +1 -2
  22. package/package.json +5 -6
  23. package/stega/dist/valbuild-react-stega.browser.esm.js +1 -2
  24. package/stega/dist/valbuild-react-stega.cjs.dev.js +12 -13
  25. package/stega/dist/valbuild-react-stega.cjs.prod.js +12 -13
  26. package/stega/dist/valbuild-react-stega.esm.js +1 -2
  27. package/stega/dist/valbuild-react-stega.worker.esm.js +1 -2
  28. package/dist/ValProvider-09e313e2.worker.esm.js +0 -87
  29. package/dist/ValProvider-461fa48b.cjs.js +0 -7
  30. package/dist/ValProvider-461fa48b.cjs.prod.js +0 -115
  31. package/dist/ValProvider-a3b1e699.esm.js +0 -92
  32. package/dist/ValProvider-b34afe68.browser.esm.js +0 -92
  33. package/dist/ValProvider-d17e4d13.cjs.dev.js +0 -121
  34. package/dist/ValUI-1922d8db.cjs.dev.js +0 -83
  35. package/dist/ValUI-23e2422b.cjs.js +0 -7
  36. package/dist/ValUI-23e2422b.cjs.prod.js +0 -83
  37. package/dist/ValUI-7d39a3f6.browser.esm.js +0 -79
  38. package/dist/ValUI-84a9cc93.worker.esm.js +0 -79
  39. package/dist/ValUI-8775ef5c.esm.js +0 -79
  40. package/dist/declarations/src/internal/ValProvider.d.ts +0 -17
  41. package/dist/typeof-16428c61.cjs.prod.js +0 -13
  42. package/dist/typeof-9915e135.browser.esm.js +0 -11
  43. package/dist/typeof-a1531d8f.esm.js +0 -11
  44. package/dist/typeof-b568f48f.cjs.dev.js +0 -13
  45. package/dist/typeof-e0c837cc.worker.esm.js +0 -11
@@ -1,87 +0,0 @@
1
- 'use client';
2
- import { _ as _slicedToArray } from './slicedToArray-e7da2c5e.worker.esm.js';
3
- import { useMemo, useState, useEffect, lazy } from 'react';
4
- import { ValApi, Internal } from '@valbuild/core';
5
- import { ValStore } from '@valbuild/shared/internal';
6
- import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
7
- import './unsupportedIterableToArray-50359a05.worker.esm.js';
8
-
9
- var useValStore = function useValStore() {
10
- {
11
- return undefined;
12
- }
13
- };
14
- var useValApi = function useValApi() {
15
- {
16
- return undefined;
17
- }
18
- };
19
- var ValContext = undefined;
20
- var ValUI = /*#__PURE__*/lazy(function () {
21
- return import('./ValUI-84a9cc93.worker.esm.js');
22
- });
23
- function ValProvider(_ref) {
24
- var children = _ref.children,
25
- onSubmit = _ref.onSubmit;
26
- var host = "/api/val";
27
- var api = useMemo(function () {
28
- return new ValApi(host);
29
- }, [host]);
30
- var store = useMemo(function () {
31
- return new ValStore(api);
32
- }, [api]);
33
- var _useState = useState(false),
34
- _useState2 = _slicedToArray(_useState, 2),
35
- isClient = _useState2[0],
36
- setIsClient = _useState2[1];
37
- var _useState3 = useState(),
38
- _useState4 = _slicedToArray(_useState3, 2),
39
- enabled = _useState4[0],
40
- setEnabled = _useState4[1];
41
- useEffect(function () {
42
- setIsClient(true);
43
- try {
44
- var _document$cookie, _document$cookie2;
45
- var valEnabled = (_document$cookie = document.cookie) === null || _document$cookie === void 0 ? void 0 : _document$cookie.includes("".concat(Internal.VAL_ENABLE_COOKIE_NAME, "=true"));
46
- if (valEnabled) {
47
- setEnabled(true);
48
- }
49
- var valDisabled = (_document$cookie2 = document.cookie) === null || _document$cookie2 === void 0 ? void 0 : _document$cookie2.includes("".concat(Internal.VAL_ENABLE_COOKIE_NAME, "=false"));
50
- if (valDisabled) {
51
- setEnabled(false);
52
- }
53
- // If we are in development and Val is not enabled or disabled, enable Val
54
- if (process.env.NODE_ENV === "development" && !valEnabled && !valDisabled) {
55
- window.location.href = "".concat(window.origin).concat(host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href));
56
- }
57
- } catch (e) {
58
- console.warn("Could not read Val enabled state", e);
59
- }
60
- }, []);
61
- if (isClient && !enabled) {
62
- if (!api) {
63
- console.warn("Val does not seem to be configured properly! Please check that you have wrapper your root layout (or _app) with the ValProvider.");
64
- } else {
65
- if (process.env.NODE_ENV === "development") {
66
- 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."));
67
- }
68
- }
69
- }
70
- if (!isClient || !enabled || !store || !api || !ValContext) {
71
- return /*#__PURE__*/jsx(Fragment, {
72
- children: children
73
- });
74
- }
75
- return /*#__PURE__*/jsxs(ValContext.Provider, {
76
- value: {
77
- valApi: api,
78
- valStore: store
79
- },
80
- children: [children, /*#__PURE__*/jsx(ValUI, {
81
- host: host,
82
- onSubmit: onSubmit
83
- })]
84
- });
85
- }
86
-
87
- export { ValContext, ValProvider, useValApi, useValStore };
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./ValProvider-461fa48b.cjs.prod.js");
5
- } else {
6
- module.exports = require("./ValProvider-461fa48b.cjs.dev.js");
7
- }
@@ -1,115 +0,0 @@
1
- 'use client';
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var slicedToArray = require('./slicedToArray-c405fbf0.cjs.prod.js');
7
- var React = require('react');
8
- var core = require('@valbuild/core');
9
- var internal = require('@valbuild/shared/internal');
10
- var ReactJSXRuntime = require('react/jsx-runtime');
11
- require('./unsupportedIterableToArray-42309462.cjs.prod.js');
12
-
13
- function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
14
-
15
- function _interopNamespace(e) {
16
- if (e && e.__esModule) return e;
17
- var n = Object.create(null);
18
- if (e) {
19
- Object.keys(e).forEach(function (k) {
20
- if (k !== 'default') {
21
- var d = Object.getOwnPropertyDescriptor(e, k);
22
- Object.defineProperty(n, k, d.get ? d : {
23
- enumerable: true,
24
- get: function () { return e[k]; }
25
- });
26
- }
27
- });
28
- }
29
- n["default"] = e;
30
- return Object.freeze(n);
31
- }
32
-
33
- var React__default = /*#__PURE__*/_interopDefault(React);
34
-
35
- var useValStore = function useValStore() {
36
- if (!ValContext) {
37
- return undefined;
38
- }
39
- return React.useContext(ValContext).valStore;
40
- };
41
- var useValApi = function useValApi() {
42
- if (!ValContext) {
43
- return undefined;
44
- }
45
- return React.useContext(ValContext).valApi;
46
- };
47
- var ValContext = typeof window !== "undefined" ? /*#__PURE__*/React__default["default"].createContext({
48
- valStore: undefined,
49
- valApi: undefined
50
- }) : undefined;
51
- var ValUI = /*#__PURE__*/React.lazy(function () {
52
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('./ValUI-23e2422b.cjs.prod.js')); });
53
- });
54
- function ValProvider(_ref) {
55
- var children = _ref.children,
56
- onSubmit = _ref.onSubmit;
57
- var host = "/api/val";
58
- var api = React.useMemo(function () {
59
- return new core.ValApi(host);
60
- }, [host]);
61
- var store = React.useMemo(function () {
62
- return new internal.ValStore(api);
63
- }, [api]);
64
- var _useState = React.useState(false),
65
- _useState2 = slicedToArray._slicedToArray(_useState, 2),
66
- isClient = _useState2[0],
67
- setIsClient = _useState2[1];
68
- var _useState3 = React.useState(),
69
- _useState4 = slicedToArray._slicedToArray(_useState3, 2),
70
- enabled = _useState4[0],
71
- setEnabled = _useState4[1];
72
- React.useEffect(function () {
73
- setIsClient(true);
74
- try {
75
- var _document$cookie, _document$cookie2;
76
- var valEnabled = (_document$cookie = document.cookie) === null || _document$cookie === void 0 ? void 0 : _document$cookie.includes("".concat(core.Internal.VAL_ENABLE_COOKIE_NAME, "=true"));
77
- if (valEnabled) {
78
- setEnabled(true);
79
- }
80
- var valDisabled = (_document$cookie2 = document.cookie) === null || _document$cookie2 === void 0 ? void 0 : _document$cookie2.includes("".concat(core.Internal.VAL_ENABLE_COOKIE_NAME, "=false"));
81
- if (valDisabled) {
82
- setEnabled(false);
83
- }
84
- // If we are in development and Val is not enabled or disabled, enable Val
85
- if ( "production" === "development" && !valEnabled && !valDisabled) ;
86
- } catch (e) {
87
- console.warn("Could not read Val enabled state", e);
88
- }
89
- }, []);
90
- if (isClient && !enabled) {
91
- if (!api) {
92
- console.warn("Val does not seem to be configured properly! Please check that you have wrapper your root layout (or _app) with the ValProvider.");
93
- }
94
- }
95
- if (!isClient || !enabled || !store || !api || !ValContext) {
96
- return /*#__PURE__*/ReactJSXRuntime.jsx(ReactJSXRuntime.Fragment, {
97
- children: children
98
- });
99
- }
100
- return /*#__PURE__*/ReactJSXRuntime.jsxs(ValContext.Provider, {
101
- value: {
102
- valApi: api,
103
- valStore: store
104
- },
105
- children: [children, /*#__PURE__*/ReactJSXRuntime.jsx(ValUI, {
106
- host: host,
107
- onSubmit: onSubmit
108
- })]
109
- });
110
- }
111
-
112
- exports.ValContext = ValContext;
113
- exports.ValProvider = ValProvider;
114
- exports.useValApi = useValApi;
115
- exports.useValStore = useValStore;
@@ -1,92 +0,0 @@
1
- 'use client';
2
- import { _ as _slicedToArray } from './slicedToArray-1dc7d2d6.esm.js';
3
- import React, { useContext, useMemo, useState, useEffect, lazy } from 'react';
4
- import { ValApi, Internal } from '@valbuild/core';
5
- import { ValStore } from '@valbuild/shared/internal';
6
- import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
7
- import './unsupportedIterableToArray-7c30dadf.esm.js';
8
-
9
- var useValStore = function useValStore() {
10
- if (!ValContext) {
11
- return undefined;
12
- }
13
- return useContext(ValContext).valStore;
14
- };
15
- var useValApi = function useValApi() {
16
- if (!ValContext) {
17
- return undefined;
18
- }
19
- return useContext(ValContext).valApi;
20
- };
21
- var ValContext = typeof window !== "undefined" ? /*#__PURE__*/React.createContext({
22
- valStore: undefined,
23
- valApi: undefined
24
- }) : undefined;
25
- var ValUI = /*#__PURE__*/lazy(function () {
26
- return import('./ValUI-8775ef5c.esm.js');
27
- });
28
- function ValProvider(_ref) {
29
- var children = _ref.children,
30
- onSubmit = _ref.onSubmit;
31
- var host = "/api/val";
32
- var api = useMemo(function () {
33
- return new ValApi(host);
34
- }, [host]);
35
- var store = useMemo(function () {
36
- return new ValStore(api);
37
- }, [api]);
38
- var _useState = useState(false),
39
- _useState2 = _slicedToArray(_useState, 2),
40
- isClient = _useState2[0],
41
- setIsClient = _useState2[1];
42
- var _useState3 = useState(),
43
- _useState4 = _slicedToArray(_useState3, 2),
44
- enabled = _useState4[0],
45
- setEnabled = _useState4[1];
46
- useEffect(function () {
47
- setIsClient(true);
48
- try {
49
- var _document$cookie, _document$cookie2;
50
- var valEnabled = (_document$cookie = document.cookie) === null || _document$cookie === void 0 ? void 0 : _document$cookie.includes("".concat(Internal.VAL_ENABLE_COOKIE_NAME, "=true"));
51
- if (valEnabled) {
52
- setEnabled(true);
53
- }
54
- var valDisabled = (_document$cookie2 = document.cookie) === null || _document$cookie2 === void 0 ? void 0 : _document$cookie2.includes("".concat(Internal.VAL_ENABLE_COOKIE_NAME, "=false"));
55
- if (valDisabled) {
56
- setEnabled(false);
57
- }
58
- // If we are in development and Val is not enabled or disabled, enable Val
59
- if (process.env.NODE_ENV === "development" && !valEnabled && !valDisabled) {
60
- window.location.href = "".concat(window.origin).concat(host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href));
61
- }
62
- } catch (e) {
63
- console.warn("Could not read Val enabled state", e);
64
- }
65
- }, []);
66
- if (isClient && !enabled) {
67
- if (!api) {
68
- console.warn("Val does not seem to be configured properly! Please check that you have wrapper your root layout (or _app) with the ValProvider.");
69
- } else {
70
- if (process.env.NODE_ENV === "development") {
71
- 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."));
72
- }
73
- }
74
- }
75
- if (!isClient || !enabled || !store || !api || !ValContext) {
76
- return /*#__PURE__*/jsx(Fragment, {
77
- children: children
78
- });
79
- }
80
- return /*#__PURE__*/jsxs(ValContext.Provider, {
81
- value: {
82
- valApi: api,
83
- valStore: store
84
- },
85
- children: [children, /*#__PURE__*/jsx(ValUI, {
86
- host: host,
87
- onSubmit: onSubmit
88
- })]
89
- });
90
- }
91
-
92
- export { ValContext, ValProvider, useValApi, useValStore };
@@ -1,92 +0,0 @@
1
- 'use client';
2
- import { _ as _slicedToArray } from './slicedToArray-7b69258f.browser.esm.js';
3
- import React, { useContext, useMemo, useState, useEffect, lazy } from 'react';
4
- import { ValApi, Internal } from '@valbuild/core';
5
- import { ValStore } from '@valbuild/shared/internal';
6
- import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
7
- import './unsupportedIterableToArray-cce3cb41.browser.esm.js';
8
-
9
- var useValStore = function useValStore() {
10
- if (!ValContext) {
11
- return undefined;
12
- }
13
- return useContext(ValContext).valStore;
14
- };
15
- var useValApi = function useValApi() {
16
- if (!ValContext) {
17
- return undefined;
18
- }
19
- return useContext(ValContext).valApi;
20
- };
21
- var ValContext = /*#__PURE__*/React.createContext({
22
- valStore: undefined,
23
- valApi: undefined
24
- }) ;
25
- var ValUI = /*#__PURE__*/lazy(function () {
26
- return import('./ValUI-7d39a3f6.browser.esm.js');
27
- });
28
- function ValProvider(_ref) {
29
- var children = _ref.children,
30
- onSubmit = _ref.onSubmit;
31
- var host = "/api/val";
32
- var api = useMemo(function () {
33
- return new ValApi(host);
34
- }, [host]);
35
- var store = useMemo(function () {
36
- return new ValStore(api);
37
- }, [api]);
38
- var _useState = useState(false),
39
- _useState2 = _slicedToArray(_useState, 2),
40
- isClient = _useState2[0],
41
- setIsClient = _useState2[1];
42
- var _useState3 = useState(),
43
- _useState4 = _slicedToArray(_useState3, 2),
44
- enabled = _useState4[0],
45
- setEnabled = _useState4[1];
46
- useEffect(function () {
47
- setIsClient(true);
48
- try {
49
- var _document$cookie, _document$cookie2;
50
- var valEnabled = (_document$cookie = document.cookie) === null || _document$cookie === void 0 ? void 0 : _document$cookie.includes("".concat(Internal.VAL_ENABLE_COOKIE_NAME, "=true"));
51
- if (valEnabled) {
52
- setEnabled(true);
53
- }
54
- var valDisabled = (_document$cookie2 = document.cookie) === null || _document$cookie2 === void 0 ? void 0 : _document$cookie2.includes("".concat(Internal.VAL_ENABLE_COOKIE_NAME, "=false"));
55
- if (valDisabled) {
56
- setEnabled(false);
57
- }
58
- // If we are in development and Val is not enabled or disabled, enable Val
59
- if (process.env.NODE_ENV === "development" && !valEnabled && !valDisabled) {
60
- window.location.href = "".concat(window.origin).concat(host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href));
61
- }
62
- } catch (e) {
63
- console.warn("Could not read Val enabled state", e);
64
- }
65
- }, []);
66
- if (isClient && !enabled) {
67
- if (!api) {
68
- console.warn("Val does not seem to be configured properly! Please check that you have wrapper your root layout (or _app) with the ValProvider.");
69
- } else {
70
- if (process.env.NODE_ENV === "development") {
71
- 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."));
72
- }
73
- }
74
- }
75
- if (!isClient || !enabled || !store || !api || !ValContext) {
76
- return /*#__PURE__*/jsx(Fragment, {
77
- children: children
78
- });
79
- }
80
- return /*#__PURE__*/jsxs(ValContext.Provider, {
81
- value: {
82
- valApi: api,
83
- valStore: store
84
- },
85
- children: [children, /*#__PURE__*/jsx(ValUI, {
86
- host: host,
87
- onSubmit: onSubmit
88
- })]
89
- });
90
- }
91
-
92
- export { ValContext, ValProvider, useValApi, useValStore };
@@ -1,121 +0,0 @@
1
- 'use client';
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var slicedToArray = require('./slicedToArray-11a666de.cjs.dev.js');
7
- var React = require('react');
8
- var core = require('@valbuild/core');
9
- var internal = require('@valbuild/shared/internal');
10
- var ReactJSXRuntime = require('react/jsx-runtime');
11
- require('./unsupportedIterableToArray-ac28611a.cjs.dev.js');
12
-
13
- function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
14
-
15
- function _interopNamespace(e) {
16
- if (e && e.__esModule) return e;
17
- var n = Object.create(null);
18
- if (e) {
19
- Object.keys(e).forEach(function (k) {
20
- if (k !== 'default') {
21
- var d = Object.getOwnPropertyDescriptor(e, k);
22
- Object.defineProperty(n, k, d.get ? d : {
23
- enumerable: true,
24
- get: function () { return e[k]; }
25
- });
26
- }
27
- });
28
- }
29
- n["default"] = e;
30
- return Object.freeze(n);
31
- }
32
-
33
- var React__default = /*#__PURE__*/_interopDefault(React);
34
-
35
- var useValStore = function useValStore() {
36
- if (!ValContext) {
37
- return undefined;
38
- }
39
- return React.useContext(ValContext).valStore;
40
- };
41
- var useValApi = function useValApi() {
42
- if (!ValContext) {
43
- return undefined;
44
- }
45
- return React.useContext(ValContext).valApi;
46
- };
47
- var ValContext = typeof window !== "undefined" ? /*#__PURE__*/React__default["default"].createContext({
48
- valStore: undefined,
49
- valApi: undefined
50
- }) : undefined;
51
- var ValUI = /*#__PURE__*/React.lazy(function () {
52
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('./ValUI-1922d8db.cjs.dev.js')); });
53
- });
54
- function ValProvider(_ref) {
55
- var children = _ref.children,
56
- onSubmit = _ref.onSubmit;
57
- var host = "/api/val";
58
- var api = React.useMemo(function () {
59
- return new core.ValApi(host);
60
- }, [host]);
61
- var store = React.useMemo(function () {
62
- return new internal.ValStore(api);
63
- }, [api]);
64
- var _useState = React.useState(false),
65
- _useState2 = slicedToArray._slicedToArray(_useState, 2),
66
- isClient = _useState2[0],
67
- setIsClient = _useState2[1];
68
- var _useState3 = React.useState(),
69
- _useState4 = slicedToArray._slicedToArray(_useState3, 2),
70
- enabled = _useState4[0],
71
- setEnabled = _useState4[1];
72
- React.useEffect(function () {
73
- setIsClient(true);
74
- try {
75
- var _document$cookie, _document$cookie2;
76
- var valEnabled = (_document$cookie = document.cookie) === null || _document$cookie === void 0 ? void 0 : _document$cookie.includes("".concat(core.Internal.VAL_ENABLE_COOKIE_NAME, "=true"));
77
- if (valEnabled) {
78
- setEnabled(true);
79
- }
80
- var valDisabled = (_document$cookie2 = document.cookie) === null || _document$cookie2 === void 0 ? void 0 : _document$cookie2.includes("".concat(core.Internal.VAL_ENABLE_COOKIE_NAME, "=false"));
81
- if (valDisabled) {
82
- setEnabled(false);
83
- }
84
- // If we are in development and Val is not enabled or disabled, enable Val
85
- if (process.env.NODE_ENV === "development" && !valEnabled && !valDisabled) {
86
- window.location.href = "".concat(window.origin).concat(host, "/enable?redirect_to=").concat(encodeURIComponent(window.location.href));
87
- }
88
- } catch (e) {
89
- console.warn("Could not read Val enabled state", e);
90
- }
91
- }, []);
92
- if (isClient && !enabled) {
93
- if (!api) {
94
- console.warn("Val does not seem to be configured properly! Please check that you have wrapper your root layout (or _app) with the ValProvider.");
95
- } else {
96
- if (process.env.NODE_ENV === "development") {
97
- 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."));
98
- }
99
- }
100
- }
101
- if (!isClient || !enabled || !store || !api || !ValContext) {
102
- return /*#__PURE__*/ReactJSXRuntime.jsx(ReactJSXRuntime.Fragment, {
103
- children: children
104
- });
105
- }
106
- return /*#__PURE__*/ReactJSXRuntime.jsxs(ValContext.Provider, {
107
- value: {
108
- valApi: api,
109
- valStore: store
110
- },
111
- children: [children, /*#__PURE__*/ReactJSXRuntime.jsx(ValUI, {
112
- host: host,
113
- onSubmit: onSubmit
114
- })]
115
- });
116
- }
117
-
118
- exports.ValContext = ValContext;
119
- exports.ValProvider = ValProvider;
120
- exports.useValApi = useValApi;
121
- exports.useValStore = useValStore;
@@ -1,83 +0,0 @@
1
- 'use client';
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var ui = require('@valbuild/ui');
7
- var slicedToArray = require('./slicedToArray-11a666de.cjs.dev.js');
8
- var React = require('react');
9
- var reactDom = require('react-dom');
10
- var ReactJSXRuntime = require('react/jsx-runtime');
11
- var ValProvider = require('./ValProvider-d17e4d13.cjs.dev.js');
12
- require('./unsupportedIterableToArray-ac28611a.cjs.dev.js');
13
-
14
- function ShadowContent(_ref) {
15
- var root = _ref.root,
16
- children = _ref.children;
17
- return /*#__PURE__*/reactDom.createPortal(children, root);
18
- }
19
- var ShadowRoot = function ShadowRoot(_ref2) {
20
- var children = _ref2.children,
21
- style = _ref2.style;
22
- var node = React.useRef(null);
23
- var _useState = React.useState(null),
24
- _useState2 = slicedToArray._slicedToArray(_useState, 2),
25
- root = _useState2[0],
26
- setRoot = _useState2[1];
27
- React.useLayoutEffect(function () {
28
- if (node.current) {
29
- if (node.current.shadowRoot) {
30
- setRoot(node.current.shadowRoot);
31
- } else {
32
- var _root = node.current.attachShadow({
33
- mode: "open"
34
- });
35
- setRoot(_root);
36
- }
37
- }
38
- }, []);
39
- return /*#__PURE__*/ReactJSXRuntime.jsx("div", {
40
- ref: node,
41
- style: style,
42
- id: "val-ui",
43
- children: root && /*#__PURE__*/ReactJSXRuntime.jsx(ShadowContent, {
44
- root: root,
45
- children: children
46
- })
47
- });
48
- };
49
-
50
- function ValUI(props) {
51
- var api = ValProvider.useValApi();
52
- var store = ValProvider.useValStore();
53
- if (!api || !store) {
54
- return null;
55
- }
56
- return /*#__PURE__*/ReactJSXRuntime.jsx(ReactJSXRuntime.Fragment, {
57
- children: /*#__PURE__*/ReactJSXRuntime.jsxs(ShadowRoot, {
58
- children: [/*#__PURE__*/ReactJSXRuntime.jsx("link", {
59
- rel: "preconnect",
60
- href: "https://fonts.googleapis.com"
61
- }), /*#__PURE__*/ReactJSXRuntime.jsx("link", {
62
- rel: "preconnect",
63
- href: "https://fonts.gstatic.com",
64
- crossOrigin: "anonymous"
65
- }), /*#__PURE__*/ReactJSXRuntime.jsx("link", {
66
- href: "https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap",
67
- rel: "stylesheet"
68
- }), /*#__PURE__*/ReactJSXRuntime.jsx("link", {
69
- href: "https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;1,100;1,300;1,400;1,500;1,700&family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap",
70
- rel: "stylesheet"
71
- }), /*#__PURE__*/ReactJSXRuntime.jsx("link", {
72
- rel: "stylesheet",
73
- href: "".concat(props.host || "/api/val", "/static").concat(ui.VAL_CSS_PATH)
74
- }), /*#__PURE__*/ReactJSXRuntime.jsx(ui.ValOverlay, {
75
- api: api,
76
- store: store,
77
- onSubmit: props.onSubmit
78
- })]
79
- })
80
- });
81
- }
82
-
83
- exports["default"] = ValUI;
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./ValUI-23e2422b.cjs.prod.js");
5
- } else {
6
- module.exports = require("./ValUI-23e2422b.cjs.dev.js");
7
- }
@@ -1,83 +0,0 @@
1
- 'use client';
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var ui = require('@valbuild/ui');
7
- var slicedToArray = require('./slicedToArray-c405fbf0.cjs.prod.js');
8
- var React = require('react');
9
- var reactDom = require('react-dom');
10
- var ReactJSXRuntime = require('react/jsx-runtime');
11
- var ValProvider = require('./ValProvider-461fa48b.cjs.prod.js');
12
- require('./unsupportedIterableToArray-42309462.cjs.prod.js');
13
-
14
- function ShadowContent(_ref) {
15
- var root = _ref.root,
16
- children = _ref.children;
17
- return /*#__PURE__*/reactDom.createPortal(children, root);
18
- }
19
- var ShadowRoot = function ShadowRoot(_ref2) {
20
- var children = _ref2.children,
21
- style = _ref2.style;
22
- var node = React.useRef(null);
23
- var _useState = React.useState(null),
24
- _useState2 = slicedToArray._slicedToArray(_useState, 2),
25
- root = _useState2[0],
26
- setRoot = _useState2[1];
27
- React.useLayoutEffect(function () {
28
- if (node.current) {
29
- if (node.current.shadowRoot) {
30
- setRoot(node.current.shadowRoot);
31
- } else {
32
- var _root = node.current.attachShadow({
33
- mode: "open"
34
- });
35
- setRoot(_root);
36
- }
37
- }
38
- }, []);
39
- return /*#__PURE__*/ReactJSXRuntime.jsx("div", {
40
- ref: node,
41
- style: style,
42
- id: "val-ui",
43
- children: root && /*#__PURE__*/ReactJSXRuntime.jsx(ShadowContent, {
44
- root: root,
45
- children: children
46
- })
47
- });
48
- };
49
-
50
- function ValUI(props) {
51
- var api = ValProvider.useValApi();
52
- var store = ValProvider.useValStore();
53
- if (!api || !store) {
54
- return null;
55
- }
56
- return /*#__PURE__*/ReactJSXRuntime.jsx(ReactJSXRuntime.Fragment, {
57
- children: /*#__PURE__*/ReactJSXRuntime.jsxs(ShadowRoot, {
58
- children: [/*#__PURE__*/ReactJSXRuntime.jsx("link", {
59
- rel: "preconnect",
60
- href: "https://fonts.googleapis.com"
61
- }), /*#__PURE__*/ReactJSXRuntime.jsx("link", {
62
- rel: "preconnect",
63
- href: "https://fonts.gstatic.com",
64
- crossOrigin: "anonymous"
65
- }), /*#__PURE__*/ReactJSXRuntime.jsx("link", {
66
- href: "https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap",
67
- rel: "stylesheet"
68
- }), /*#__PURE__*/ReactJSXRuntime.jsx("link", {
69
- href: "https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;1,100;1,300;1,400;1,500;1,700&family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap",
70
- rel: "stylesheet"
71
- }), /*#__PURE__*/ReactJSXRuntime.jsx("link", {
72
- rel: "stylesheet",
73
- href: "".concat(props.host || "/api/val", "/static").concat(ui.VAL_CSS_PATH)
74
- }), /*#__PURE__*/ReactJSXRuntime.jsx(ui.ValOverlay, {
75
- api: api,
76
- store: store,
77
- onSubmit: props.onSubmit
78
- })]
79
- })
80
- });
81
- }
82
-
83
- exports["default"] = ValUI;