eddev 0.2.65 → 0.2.67-beta1
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/admin/components/ImageWell.d.ts +2 -3
- package/admin/components/ImageWell.js +39 -51
- package/admin/defineField.d.ts +2 -2
- package/admin/defineWidget.d.ts +1 -1
- package/admin/defineWidget.js +2 -2
- package/admin/index.js +5 -1
- package/admin/installFieldTypes.js +26 -26
- package/admin/runWidgets.js +17 -28
- package/admin/selectMedia.d.ts +2 -2
- package/admin/selectMedia.js +1 -1
- package/blocks/ContentBlocks.d.ts +6 -6
- package/blocks/ContentBlocks.js +58 -66
- package/blocks/ErrorBoundaryEditor.d.ts +1 -1
- package/blocks/ErrorBoundaryEditor.js +16 -45
- package/blocks/ErrorBoundaryFrontend.d.ts +1 -1
- package/blocks/ErrorBoundaryFrontend.js +16 -45
- package/blocks/InspectorControls.d.ts +1 -1
- package/blocks/InspectorControls.js +3 -3
- package/blocks/blockAttributes.d.ts +2 -2
- package/blocks/blockAttributes.js +24 -44
- package/blocks/index.js +5 -1
- package/blocks/inlineEditing.d.ts +7 -7
- package/blocks/inlineEditing.js +36 -55
- package/blocks/installGutenbergHooks.js +48 -68
- package/build/babel/plugin-name-defined-components.js +15 -16
- package/build/build-favicon.js +11 -62
- package/build/clean.js +5 -52
- package/build/create-codegen-worker.js +78 -33
- package/build/create-serverless-dev-worker.js +61 -39
- package/build/create-webpack-worker.js +65 -33
- package/build/file-tree.d.ts +2 -2
- package/build/file-tree.js +12 -12
- package/build/get-webpack-config.js +341 -395
- package/build/graphql-codegen/graphql-codegen-files.js +31 -25
- package/build/graphql-codegen/graphql-codegen-no-duplicates.js +4 -4
- package/build/graphql-codegen/graphql-codegen-queries.js +102 -99
- package/build/manifests/manifest-blocks.d.ts +1 -1
- package/build/manifests/manifest-blocks.js +37 -29
- package/build/manifests/manifest-fields.d.ts +1 -1
- package/build/manifests/manifest-fields.js +23 -21
- package/build/manifests/manifest-views.d.ts +1 -1
- package/build/manifests/manifest-views.js +32 -25
- package/build/manifests/manifest-widgets.d.ts +1 -1
- package/build/manifests/manifest-widgets.js +22 -20
- package/build/manifests/manifest.d.ts +2 -2
- package/build/manifests/manifest.js +30 -90
- package/build/reporter.d.ts +1 -1
- package/build/reporter.js +29 -32
- package/build/serverless/create-next-app.d.ts +1 -1
- package/build/serverless/create-next-app.js +245 -467
- package/build/state/codegen-state.d.ts +4 -4
- package/build/state/compiler-state.d.ts +5 -5
- package/build/state/serverless-state.d.ts +3 -3
- package/build/workers/codegen-worker-script.js +392 -507
- package/build/workers/serverless-worker-dev-script.js +4 -4
- package/build/workers/webpack-worker-script.js +89 -150
- package/cli/build.dev.d.ts +1 -1
- package/cli/build.dev.js +79 -126
- package/cli/build.prod.d.ts +1 -1
- package/cli/build.prod.js +42 -98
- package/cli/cli.js +16 -55
- package/cli/display/components/BundleDisplay.d.ts +1 -2
- package/cli/display/components/BundleDisplay.js +13 -24
- package/cli/display/components/CodegenDisplay.d.ts +1 -2
- package/cli/display/components/CodegenDisplay.js +14 -25
- package/cli/display/components/DevCLIDisplay.d.ts +2 -3
- package/cli/display/components/DevCLIDisplay.js +14 -25
- package/cli/display/components/Fullscreen.js +9 -20
- package/cli/display/components/ServerlessDisplay.d.ts +2 -3
- package/cli/display/components/ServerlessDisplay.js +15 -26
- package/cli/display/components/StatusIcon.d.ts +2 -3
- package/cli/display/components/StatusIcon.js +3 -3
- package/cli/preinstall.js +4 -5
- package/cli/setup.js +25 -73
- package/components/AdminBar.d.ts +1 -2
- package/components/AdminBar.js +37 -3
- package/components/BrowserRouter.d.ts +2 -2
- package/components/BrowserRouter.js +41 -54
- package/components/InlinePage.d.ts +2 -2
- package/components/InlinePage.js +17 -29
- package/components/NextRouter.d.ts +2 -2
- package/components/NextRouter.js +20 -29
- package/components/index.js +5 -1
- package/config/config-schema.d.ts +1 -1
- package/config/config-schema.js +1 -1
- package/config/create-schema-file.js +6 -6
- package/config/get-config.js +10 -13
- package/config/index.js +5 -1
- package/config/parse-config.js +1 -1
- package/config/print-zod-errors.js +3 -3
- package/dev-ui/components/BreakpointColumnHeader.d.ts +2 -3
- package/dev-ui/components/BreakpointColumnHeader.js +7 -18
- package/dev-ui/components/BreakpointIndicator.d.ts +1 -2
- package/dev-ui/components/BreakpointIndicator.js +25 -32
- package/dev-ui/components/DevUI.d.ts +1 -2
- package/dev-ui/components/DevUI.js +13 -13
- package/dev-ui/components/Launcher.d.ts +2 -2
- package/dev-ui/components/Launcher.js +13 -25
- package/dev-ui/components/PanelWrapper.d.ts +2 -2
- package/dev-ui/components/PanelWrapper.js +8 -8
- package/dev-ui/components/ResponsiveLerpControl.d.ts +2 -3
- package/dev-ui/components/ResponsiveLerpControl.js +27 -38
- package/dev-ui/components/ResponsiveScaleEditor.d.ts +4 -5
- package/dev-ui/components/ResponsiveScaleEditor.js +64 -78
- package/dev-ui/components/atoms/Button.js +1 -1
- package/dev-ui/components/atoms/Dropdown.d.ts +3 -3
- package/dev-ui/components/atoms/Dropdown.js +8 -9
- package/dev-ui/components/atoms/NumberField.d.ts +2 -3
- package/dev-ui/components/atoms/NumberField.js +29 -42
- package/dev-ui/components/atoms/Spacer.js +1 -1
- package/dev-ui/components/atoms/Text.js +1 -1
- package/dev-ui/components/atoms/ToggleButton.d.ts +2 -2
- package/dev-ui/components/atoms/ToggleButton.js +5 -16
- package/dev-ui/components/atoms/Tooltip.d.ts +2 -2
- package/dev-ui/components/atoms/Tooltip.js +8 -20
- package/dev-ui/components/panels/AppDataDebugger.d.ts +1 -2
- package/dev-ui/components/panels/AppDataDebugger.js +8 -19
- package/dev-ui/components/panels/ColorEditor.d.ts +1 -2
- package/dev-ui/components/panels/ColorEditor.js +35 -42
- package/dev-ui/components/panels/PageDataDebugger.d.ts +1 -2
- package/dev-ui/components/panels/PageDataDebugger.js +8 -20
- package/dev-ui/components/panels/QueryDebugger.d.ts +1 -2
- package/dev-ui/components/panels/QueryDebugger.js +12 -24
- package/dev-ui/components/panels/SpacingEditor.d.ts +1 -2
- package/dev-ui/components/panels/SpacingEditor.js +34 -48
- package/dev-ui/components/panels/TypographyEditor.d.ts +1 -2
- package/dev-ui/components/panels/TypographyEditor.js +38 -46
- package/dev-ui/hooks/useBreakpoint.d.ts +1 -1
- package/dev-ui/hooks/useBreakpoint.js +13 -13
- package/dev-ui/hooks/usePersistState.js +6 -7
- package/dev-ui/hooks/useStylesheet.js +6 -6
- package/dev-ui/icons.d.ts +15 -16
- package/dev-ui/icons.js +16 -27
- package/dev-ui/index.js +5 -1
- package/dev-ui/loader.d.ts +1 -2
- package/dev-ui/loader.js +13 -9
- package/dev-ui/panels.d.ts +2 -2
- package/dev-ui/panels.js +7 -7
- package/dev-ui/theme.d.ts +96 -70
- package/dev-ui/theme.js +3 -3
- package/dynamic/dynamic-component.d.ts +1 -10
- package/dynamic/dynamic-component.js +1 -1
- package/dynamic/index.js +5 -1
- package/entry/Root.d.ts +2 -3
- package/entry/Root.js +16 -26
- package/entry/entry.admin.dev.js +4 -4
- package/entry/entry.admin.prod.js +4 -4
- package/entry/entry.monolith.dev.js +5 -5
- package/entry/entry.monolith.prod.js +5 -5
- package/gravityforms/gravity-forms.d.ts +2 -2
- package/gravityforms/index.js +5 -1
- package/gravityforms/useGravityForm.d.ts +2 -2
- package/gravityforms/useGravityForm.js +126 -130
- package/hooks/index.js +5 -1
- package/hooks/queryUtils.d.ts +14 -14
- package/hooks/queryUtils.js +101 -192
- package/hooks/useAppData.d.ts +2 -2
- package/hooks/useAppData.js +9 -9
- package/hooks/usePageLoad.js +4 -4
- package/hooks/useQueryDebug.d.ts +1 -1
- package/hooks/useQueryDebug.js +7 -7
- package/hooks/useRPC.d.ts +4 -4
- package/hooks/useRPC.js +3 -3
- package/package.json +7 -7
- package/routing/index.js +5 -1
- package/routing/remoteProps.d.ts +1 -1
- package/routing/remoteProps.js +31 -72
- package/routing/routing.d.ts +15 -15
- package/routing/routing.js +108 -170
- package/routing/updateEditLink.js +1 -1
- package/serverless/define-api.d.ts +1 -1
- package/serverless/define-rpc-router.js +8 -4
- package/serverless/index.js +6 -2
- package/serverless-template/_utils/fetch-wordpress-props.ts +0 -4
- package/serverless-template/_utils/fetch-wp.ts +0 -1
- package/style/createStitches.d.ts +375 -783
- package/style/createStitches.js +164 -142
- package/style/index.js +5 -1
- package/tsconfig.json +1 -1
- package/utils/Observable.d.ts +2 -2
- package/utils/Observable.js +12 -15
- package/utils/getRepoName.js +3 -3
- package/utils/promptIfRepoNameIncorrect.js +18 -64
- package/utils/refreshOverlayInterop.js +1 -1
- package/utils/reportErrorStack.d.ts +1 -1
- package/utils/reportErrorStack.js +1 -1
- package/utils/serverlessAppContext.js +1 -1
- package/utils/updateEnvFile.js +19 -69
- package/utils/useObservable.js +3 -3
- package/views/index.js +5 -1
package/entry/Root.js
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
16
9
|
}) : (function(o, m, k, k2) {
|
|
17
10
|
if (k2 === undefined) k2 = k;
|
|
18
11
|
o[k2] = m[k];
|
|
@@ -30,25 +23,22 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
30
23
|
return result;
|
|
31
24
|
};
|
|
32
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
|
|
26
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
34
27
|
// @ts-ignore
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
const views_1 = __importStar(require("@manifest/views"));
|
|
29
|
+
const react_1 = require("react");
|
|
30
|
+
const routing_1 = require("../routing");
|
|
31
|
+
const loader_1 = require("../dev-ui/loader");
|
|
32
|
+
const next_1 = require("@trpc/next");
|
|
40
33
|
function Root() {
|
|
41
|
-
|
|
42
|
-
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [process.devUI && (0, jsx_runtime_1.jsx)(loader_1.DevUILoader, {}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return ((0, jsx_runtime_1.jsx)(routing_1.Route, __assign({ match: function (route) { var _a; return ((_a = route.data) === null || _a === void 0 ? void 0 : _a.view) === name; } }, { children: (0, jsx_runtime_1.jsx)(Component, __assign({}, (_c = (_b = route.data) === null || _b === void 0 ? void 0 : _b.viewData) === null || _c === void 0 ? void 0 : _c.data), void 0) }), name));
|
|
46
|
-
}) }, void 0) }, void 0)] }, void 0));
|
|
34
|
+
const route = (0, routing_1.useRoute)();
|
|
35
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [process.devUI && (0, jsx_runtime_1.jsx)(loader_1.DevUILoader, {}), (0, jsx_runtime_1.jsx)(views_1.App, { children: (0, jsx_runtime_1.jsx)(routing_1.Switch, { children: Object.entries(views_1.default).map(([name, Component]) => {
|
|
36
|
+
return ((0, jsx_runtime_1.jsx)(routing_1.Route, { match: (route) => route.data?.view === name, children: (0, jsx_runtime_1.jsx)(Component, { ...route.data?.viewData?.data }) }, name));
|
|
37
|
+
}) }) })] }));
|
|
47
38
|
}
|
|
48
39
|
exports.default = process.rpcEnabled
|
|
49
40
|
? (0, next_1.withTRPC)({
|
|
50
|
-
config
|
|
51
|
-
var ctx = _a.ctx;
|
|
41
|
+
config({ ctx }) {
|
|
52
42
|
return {
|
|
53
43
|
url: process.serverlessEndpoint + "api/trpc",
|
|
54
44
|
};
|
package/entry/entry.admin.dev.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
const installGutenbergHooks_1 = require("../blocks/installGutenbergHooks");
|
|
4
4
|
// @ts-ignore
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const _theme_1 = require("@theme");
|
|
6
|
+
const installFieldTypes_1 = require("../admin/installFieldTypes");
|
|
7
|
+
const runWidgets_1 = require("../admin/runWidgets");
|
|
8
8
|
(0, installGutenbergHooks_1.installEDGutenbergHooks)();
|
|
9
9
|
(0, installFieldTypes_1.installFieldTypes)();
|
|
10
10
|
window.onload = runWidgets_1.runWidgets;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
const installGutenbergHooks_1 = require("../blocks/installGutenbergHooks");
|
|
4
4
|
// @ts-ignore
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const _theme_1 = require("@theme");
|
|
6
|
+
const installFieldTypes_1 = require("../admin/installFieldTypes");
|
|
7
|
+
const runWidgets_1 = require("../admin/runWidgets");
|
|
8
8
|
(0, installGutenbergHooks_1.installEDGutenbergHooks)();
|
|
9
9
|
(0, installFieldTypes_1.installFieldTypes)();
|
|
10
10
|
window.onload = runWidgets_1.runWidgets;
|
|
@@ -3,17 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
7
|
/**
|
|
8
8
|
* This entryfile is only ever executed within a browser context.
|
|
9
9
|
* It also assumes that it's being run from a theme directory in WordPress, and
|
|
10
10
|
* that it's not being run in the Admin panel, but the user may be logged in.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const client_1 = __importDefault(require("react-dom/client"));
|
|
13
|
+
const BrowserRouter_1 = require("../components/BrowserRouter");
|
|
14
|
+
const Root_1 = __importDefault(require("./Root"));
|
|
15
15
|
// @ts-ignore
|
|
16
16
|
if (!window.wp)
|
|
17
17
|
window.wp = {};
|
|
18
18
|
// @ts-ignore
|
|
19
|
-
client_1.default.createRoot(document.getElementById("root")).render((0, jsx_runtime_1.jsx)(BrowserRouter_1.BrowserRouter, { children: (0, jsx_runtime_1.jsx)(Root_1.default, {}
|
|
19
|
+
client_1.default.createRoot(document.getElementById("root")).render((0, jsx_runtime_1.jsx)(BrowserRouter_1.BrowserRouter, { children: (0, jsx_runtime_1.jsx)(Root_1.default, {}) }));
|
|
@@ -3,16 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
7
|
/**
|
|
8
8
|
* This entryfile is only ever executed within a browser context.
|
|
9
9
|
* It also assumes that it's being run from a theme directory in WordPress, and
|
|
10
10
|
* that it's not being run in the Admin panel, but the user may be logged in.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const client_1 = __importDefault(require("react-dom/client"));
|
|
13
|
+
const BrowserRouter_1 = require("../components/BrowserRouter");
|
|
14
|
+
const Root_1 = __importDefault(require("./Root"));
|
|
15
15
|
// @ts-ignore
|
|
16
16
|
// if (ReactDOM.createRoot) {
|
|
17
17
|
// @ts-ignore
|
|
18
|
-
client_1.default.createRoot(document.getElementById("root")).render((0, jsx_runtime_1.jsx)(BrowserRouter_1.BrowserRouter, { children: (0, jsx_runtime_1.jsx)(Root_1.default, {}
|
|
18
|
+
client_1.default.createRoot(document.getElementById("root")).render((0, jsx_runtime_1.jsx)(BrowserRouter_1.BrowserRouter, { children: (0, jsx_runtime_1.jsx)(Root_1.default, {}) }));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type GravityFormsField = {
|
|
2
2
|
type: string;
|
|
3
3
|
id: number;
|
|
4
4
|
label: string;
|
|
@@ -6,7 +6,7 @@ export declare type GravityFormsField = {
|
|
|
6
6
|
} & {
|
|
7
7
|
[key: string]: any;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type GravityFormData = {
|
|
10
10
|
id: number;
|
|
11
11
|
fields: GravityFormsField[];
|
|
12
12
|
title: string;
|
package/gravityforms/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { GravityFormsField } from ".";
|
|
2
2
|
import { GravityFormData } from "./gravity-forms";
|
|
3
|
-
|
|
3
|
+
type Options = {
|
|
4
4
|
form: GravityFormData;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
6
|
+
export type GravityFormsFieldState<T = any> = GravityFormsField & {
|
|
7
7
|
value: T | undefined;
|
|
8
8
|
error: string | undefined;
|
|
9
9
|
set(value: T | undefined): void;
|
|
@@ -1,77 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
3
|
exports.useGravityForm = void 0;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var _a, _b, _c;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const react_2 = require("react");
|
|
6
|
+
const react_3 = require("react");
|
|
7
|
+
const reducer = (state, action) => {
|
|
56
8
|
switch (action.type) {
|
|
57
9
|
case "field":
|
|
58
|
-
return
|
|
10
|
+
return {
|
|
11
|
+
...state,
|
|
12
|
+
errors: {
|
|
13
|
+
...state.errors,
|
|
14
|
+
[action.id]: undefined,
|
|
15
|
+
},
|
|
16
|
+
values: {
|
|
17
|
+
...state.values,
|
|
18
|
+
[action.id]: action.value,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
59
21
|
case "submitting":
|
|
60
|
-
return
|
|
22
|
+
return {
|
|
23
|
+
...state,
|
|
24
|
+
errors: {},
|
|
25
|
+
validity: {},
|
|
26
|
+
hasErrors: false,
|
|
27
|
+
submitting: true,
|
|
28
|
+
};
|
|
61
29
|
case "success":
|
|
62
|
-
return
|
|
30
|
+
return {
|
|
31
|
+
...state,
|
|
32
|
+
submitting: false,
|
|
33
|
+
complete: true,
|
|
34
|
+
errors: {},
|
|
35
|
+
validity: {},
|
|
36
|
+
hasErrors: false,
|
|
37
|
+
successMessage: action.message,
|
|
38
|
+
};
|
|
63
39
|
case "mainError":
|
|
64
|
-
return
|
|
40
|
+
return {
|
|
41
|
+
...state,
|
|
42
|
+
submitting: false,
|
|
43
|
+
hasErrors: true,
|
|
44
|
+
mainError: action.message,
|
|
45
|
+
};
|
|
65
46
|
case "errors":
|
|
66
|
-
return
|
|
47
|
+
return {
|
|
48
|
+
...state,
|
|
49
|
+
submitting: false,
|
|
50
|
+
hasErrors: true,
|
|
51
|
+
errors: action.errors,
|
|
52
|
+
};
|
|
67
53
|
case "clearError":
|
|
68
|
-
return
|
|
54
|
+
return {
|
|
55
|
+
...state,
|
|
56
|
+
submitting: false,
|
|
57
|
+
errors: {
|
|
58
|
+
...state.errors,
|
|
59
|
+
[action.id]: undefined,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
69
62
|
default:
|
|
70
|
-
throw new Error(
|
|
63
|
+
throw new Error(`Unknown GravityForms action ${JSON.stringify(action)}`);
|
|
71
64
|
}
|
|
72
65
|
return state;
|
|
73
66
|
};
|
|
74
|
-
|
|
67
|
+
const initializer = (form) => {
|
|
75
68
|
return {
|
|
76
69
|
submitting: false,
|
|
77
70
|
mainError: null,
|
|
@@ -84,18 +77,23 @@ var initializer = function (form) {
|
|
|
84
77
|
};
|
|
85
78
|
};
|
|
86
79
|
function useGravityForm(opts) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
80
|
+
const { form } = opts;
|
|
81
|
+
const [state, dispatch] = (0, react_3.useReducer)(reducer, form, initializer);
|
|
82
|
+
const fields = form.fields.map((field) => ({
|
|
83
|
+
...field,
|
|
84
|
+
value: state.values[field.id],
|
|
85
|
+
error: state.errors[field.id],
|
|
86
|
+
set: (value) => {
|
|
87
|
+
dispatch({ type: "field", id: field.id, value });
|
|
88
|
+
},
|
|
89
|
+
}));
|
|
90
|
+
const [submitter, setSubmitter] = (0, react_2.useState)(null);
|
|
91
|
+
(0, react_1.useEffect)(() => {
|
|
92
|
+
let cancelled = false;
|
|
95
93
|
setSubmitter({
|
|
96
|
-
submit:
|
|
94
|
+
submit: (state) => {
|
|
97
95
|
dispatch({ type: "submitting" });
|
|
98
|
-
submit(form, state).then(
|
|
96
|
+
submit(form, state).then((result) => {
|
|
99
97
|
if (cancelled)
|
|
100
98
|
return;
|
|
101
99
|
if (result.success) {
|
|
@@ -110,27 +108,32 @@ function useGravityForm(opts) {
|
|
|
110
108
|
});
|
|
111
109
|
},
|
|
112
110
|
});
|
|
113
|
-
return
|
|
111
|
+
return () => {
|
|
114
112
|
cancelled = true;
|
|
115
113
|
};
|
|
116
114
|
}, []);
|
|
117
|
-
return
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
115
|
+
return {
|
|
116
|
+
...state,
|
|
117
|
+
fields,
|
|
118
|
+
submit() {
|
|
119
|
+
submitter?.submit(state);
|
|
120
|
+
},
|
|
121
|
+
updateField(id, value) {
|
|
122
|
+
dispatch({ type: "field", id, value });
|
|
123
|
+
},
|
|
124
|
+
};
|
|
122
125
|
}
|
|
123
126
|
exports.useGravityForm = useGravityForm;
|
|
124
127
|
function prepareValuesPayload(form, state, data) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
+
for (const field of form.fields) {
|
|
129
|
+
const value = state.values[field.id];
|
|
130
|
+
let key = "input_" + field.id;
|
|
128
131
|
if (field.type === "consent") {
|
|
129
132
|
key += "_1";
|
|
130
133
|
}
|
|
131
134
|
if (field.type === "checkbox") {
|
|
132
|
-
field.choices.forEach(
|
|
133
|
-
data.append(
|
|
135
|
+
field.choices.forEach((choice, i) => {
|
|
136
|
+
data.append(`${key}.${i + 1}`, value?.includes(choice.value) ? choice.value : "");
|
|
134
137
|
// data[`${key}.${i + 1}`] =
|
|
135
138
|
});
|
|
136
139
|
}
|
|
@@ -144,57 +147,50 @@ function prepareValuesPayload(form, state, data) {
|
|
|
144
147
|
}
|
|
145
148
|
// data[key] = value
|
|
146
149
|
}
|
|
147
|
-
};
|
|
148
|
-
for (var _i = 0, _a = form.fields; _i < _a.length; _i++) {
|
|
149
|
-
var field = _a[_i];
|
|
150
|
-
_loop_1(field);
|
|
151
150
|
}
|
|
152
151
|
// return data
|
|
153
152
|
}
|
|
154
|
-
function submit(form, state) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
headers: {
|
|
168
|
-
// "Content-type": "application/json",
|
|
169
|
-
},
|
|
170
|
-
credentials: "include",
|
|
171
|
-
body: data,
|
|
172
|
-
})];
|
|
173
|
-
case 1:
|
|
174
|
-
result = _a.sent();
|
|
175
|
-
return [4 /*yield*/, result.json()];
|
|
176
|
-
case 2:
|
|
177
|
-
payload = _a.sent();
|
|
178
|
-
if (!payload.is_valid) {
|
|
179
|
-
return [2 /*return*/, __assign(__assign({}, payload), { success: false, errors: payload.validation_messages })];
|
|
180
|
-
}
|
|
181
|
-
else if (payload.is_valid) {
|
|
182
|
-
return [2 /*return*/, __assign(__assign({}, payload), { success: true, successMessage: payload.confirmation_message })];
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
console.error("Not sure what to do with GF response", payload);
|
|
186
|
-
return [2 /*return*/, __assign({}, payload)];
|
|
187
|
-
}
|
|
188
|
-
return [3 /*break*/, 4];
|
|
189
|
-
case 3:
|
|
190
|
-
err_1 = _a.sent();
|
|
191
|
-
console.error(err_1);
|
|
192
|
-
return [2 /*return*/, {
|
|
193
|
-
success: false,
|
|
194
|
-
mainError: "An error occurred while submitting this form. Please contact us directly if the issue persists.",
|
|
195
|
-
}];
|
|
196
|
-
case 4: return [2 /*return*/];
|
|
197
|
-
}
|
|
153
|
+
async function submit(form, state) {
|
|
154
|
+
try {
|
|
155
|
+
let url = process.serverless ? `/api/rest/form-submit` : `/wp-json/ed/v1/gf/submit-with-uploads`;
|
|
156
|
+
const data = new FormData();
|
|
157
|
+
data.append("formID", String(form.id));
|
|
158
|
+
prepareValuesPayload(form, state, data);
|
|
159
|
+
const result = await fetch(url, {
|
|
160
|
+
method: "POST",
|
|
161
|
+
headers: {
|
|
162
|
+
// "Content-type": "application/json",
|
|
163
|
+
},
|
|
164
|
+
credentials: "include",
|
|
165
|
+
body: data,
|
|
198
166
|
});
|
|
199
|
-
|
|
167
|
+
const payload = await result.json();
|
|
168
|
+
if (!payload.is_valid) {
|
|
169
|
+
return {
|
|
170
|
+
...payload,
|
|
171
|
+
success: false,
|
|
172
|
+
errors: payload.validation_messages,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
else if (payload.is_valid) {
|
|
176
|
+
return {
|
|
177
|
+
...payload,
|
|
178
|
+
success: true,
|
|
179
|
+
successMessage: payload.confirmation_message,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
console.error("Not sure what to do with GF response", payload);
|
|
184
|
+
return {
|
|
185
|
+
...payload,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
catch (err) {
|
|
190
|
+
console.error(err);
|
|
191
|
+
return {
|
|
192
|
+
success: false,
|
|
193
|
+
mainError: "An error occurred while submitting this form. Please contact us directly if the issue persists.",
|
|
194
|
+
};
|
|
195
|
+
}
|
|
200
196
|
}
|
package/hooks/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/hooks/queryUtils.d.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
/** Generic Error */
|
|
2
|
-
|
|
2
|
+
type GraphQLError = {
|
|
3
3
|
message: string;
|
|
4
4
|
};
|
|
5
5
|
/** Regular queries */
|
|
6
|
-
|
|
6
|
+
type CreateUseQueryOptions = {
|
|
7
7
|
name: string;
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
type QueryOptions = {
|
|
10
10
|
revalidateIfStale?: boolean;
|
|
11
11
|
revalidateOnFocus?: boolean;
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
type MaybeVars = {
|
|
14
14
|
[key: string]: any;
|
|
15
15
|
} | undefined;
|
|
16
|
-
|
|
16
|
+
type QueryHookReturn<TReturn, TVars> = {
|
|
17
17
|
loading: boolean;
|
|
18
18
|
errors?: GraphQLError[];
|
|
19
19
|
data?: TReturn;
|
|
20
20
|
refresh: (vars?: TVars) => void;
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
type QueryHook<TReturn, TVars> = TVars extends undefined ? (vars?: TVars, opts?: QueryOptions) => QueryHookReturn<TReturn, TVars> : (vars: TVars, opts?: QueryOptions) => QueryHookReturn<TReturn, TVars>;
|
|
23
|
+
type QueryFetcher<TReturn, TVars> = {
|
|
24
24
|
fetch: TVars extends undefined ? (vars?: TVars) => Promise<TReturn> : (vars: TVars) => Promise<TReturn>;
|
|
25
25
|
};
|
|
26
26
|
export declare function createUseQuery<TReturn extends any, TVars extends MaybeVars>(init: CreateUseQueryOptions): QueryHook<TReturn, TVars> & QueryFetcher<TReturn, TVars>;
|
|
27
27
|
/** Infinite queries */
|
|
28
|
-
|
|
28
|
+
type CreateUseInfiniteQueryOptions = {
|
|
29
29
|
name: string;
|
|
30
30
|
defaultLimit: number;
|
|
31
31
|
paths: {
|
|
@@ -35,7 +35,7 @@ declare type CreateUseInfiniteQueryOptions = {
|
|
|
35
35
|
hasNextPagePath: string[];
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
|
-
|
|
38
|
+
type InfiniteQueryHookReturn<TItem, TVars> = {
|
|
39
39
|
loading: boolean;
|
|
40
40
|
loadingMore: boolean;
|
|
41
41
|
errors?: GraphQLError[];
|
|
@@ -45,18 +45,18 @@ declare type InfiniteQueryHookReturn<TItem, TVars> = {
|
|
|
45
45
|
refresh: () => void;
|
|
46
46
|
loadMore: () => void;
|
|
47
47
|
};
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
type InfiniteQueryHasAdditionalVars<TVars> = Exclude<keyof TVars, "limit" | "cursor"> extends never ? false : true;
|
|
49
|
+
type InfiniteQueryHook<TItem, TVars> = InfiniteQueryHasAdditionalVars<TVars> extends false ? (vars?: TVars, opts?: QueryOptions) => InfiniteQueryHookReturn<TItem, TVars> : (vars: TVars, opts?: QueryOptions) => InfiniteQueryHookReturn<TItem, TVars>;
|
|
50
50
|
export declare function createUseInfiniteQuery<TItem, TVars extends MaybeVars>(init: CreateUseInfiniteQueryOptions): InfiniteQueryHook<TItem, TVars>;
|
|
51
|
-
|
|
51
|
+
type MutationHookReturn<TReturn, TVars> = {
|
|
52
52
|
submitting: boolean;
|
|
53
53
|
submitted: boolean;
|
|
54
54
|
errors?: GraphQLError[];
|
|
55
55
|
data?: TReturn;
|
|
56
56
|
submit: (vars: TVars) => void;
|
|
57
57
|
};
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
type MutationHook<TReturn, TVars> = (opts?: QueryOptions) => MutationHookReturn<TReturn, TVars>;
|
|
59
|
+
type MutationFetcher<TReturn, TVars> = {
|
|
60
60
|
mutate: (vars: TVars) => Promise<TReturn>;
|
|
61
61
|
};
|
|
62
62
|
export declare function createUseMutation<TReturn extends any, TVars extends MaybeVars>(init: CreateUseQueryOptions): MutationHook<TReturn, TVars> & MutationFetcher<TReturn, TVars>;
|