eddev 0.1.47 → 0.1.50
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/build/get-webpack-config.js +1 -1
- package/fields/ImageWell.d.ts +8 -0
- package/fields/ImageWell.js +64 -0
- package/fields/installFieldTypes.js +17 -5
- package/gravityforms/useGravityForm.js +5 -3
- package/package.json +1 -1
- package/yarn-error.log +0 -8200
|
@@ -325,7 +325,7 @@ function getWebpackConfig(opts) {
|
|
|
325
325
|
return [3 /*break*/, 10];
|
|
326
326
|
case 8:
|
|
327
327
|
_b = updateFieldManifest;
|
|
328
|
-
return [4 /*yield*/, (0, file_tree_1.getFileTree)(
|
|
328
|
+
return [4 /*yield*/, (0, file_tree_1.getFileTree)(fieldTypeLookupPattern)];
|
|
329
329
|
case 9:
|
|
330
330
|
_b.apply(void 0, [_d.sent()]);
|
|
331
331
|
_d.label = 10;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImageWell = void 0;
|
|
4
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
var react_1 = require("@stitches/react");
|
|
6
|
+
var react_2 = require("react");
|
|
7
|
+
function ImageWell(props) {
|
|
8
|
+
var _a = (0, react_2.useState)(null), selectedImage = _a[0], setSelectedImage = _a[1];
|
|
9
|
+
var _b = (0, react_2.useState)(false), imageIsLoading = _b[0], setImageIsLoading = _b[1];
|
|
10
|
+
(0, react_2.useEffect)(function () {
|
|
11
|
+
if (props.value) {
|
|
12
|
+
var cancelled = false;
|
|
13
|
+
setImageIsLoading(true);
|
|
14
|
+
fetch("/wp-json/ed/v1/media/" + Number(props.value))
|
|
15
|
+
.then(function (response) { return response.json(); })
|
|
16
|
+
.then(function (image) {
|
|
17
|
+
setImageIsLoading(false);
|
|
18
|
+
setSelectedImage(image);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}, [props.value]);
|
|
22
|
+
return ((0, jsx_runtime_1.jsxs)(Wrapper, { children: [imageIsLoading ? ((0, jsx_runtime_1.jsx)(Loading, { children: (0, jsx_runtime_1.jsx)(Spinner, {}, void 0) }, void 0)) : selectedImage ? ((0, jsx_runtime_1.jsx)(ImageContainer, { children: (0, jsx_runtime_1.jsx)("img", { src: selectedImage.sizes[props.previewSize] || selectedImage.sizes["thumbnail"] }, void 0) }, void 0)) : null, (0, jsx_runtime_1.jsx)(Toolbar, { children: selectedImage || imageIsLoading ? ((0, jsx_runtime_1.jsxs)(react_2.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button, { children: "Remove" }, void 0), (0, jsx_runtime_1.jsx)(Button, { children: "Edit" }, void 0), (0, jsx_runtime_1.jsx)(Button, { children: "View" }, void 0)] }, void 0)) : null }, void 0)] }, void 0));
|
|
23
|
+
}
|
|
24
|
+
exports.ImageWell = ImageWell;
|
|
25
|
+
var Wrapper = (0, react_1.styled)("div", {
|
|
26
|
+
position: "relative",
|
|
27
|
+
display: "block",
|
|
28
|
+
width: "100%",
|
|
29
|
+
border: "1px solid #aaaaaa",
|
|
30
|
+
});
|
|
31
|
+
var ImageContainer = (0, react_1.styled)("div", {
|
|
32
|
+
padding: "4px",
|
|
33
|
+
img: {
|
|
34
|
+
maxWidth: "100%",
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
var spin = (0, react_1.keyframes)({
|
|
38
|
+
from: {
|
|
39
|
+
transform: "rotate(0deg)",
|
|
40
|
+
},
|
|
41
|
+
to: {
|
|
42
|
+
transform: "rotate(360deg)",
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
var Spinner = (0, react_1.styled)("div", {
|
|
46
|
+
display: "block",
|
|
47
|
+
width: "32px",
|
|
48
|
+
height: "32px",
|
|
49
|
+
border: "4px solid transparent",
|
|
50
|
+
borderTop: "currentColor",
|
|
51
|
+
animation: "".concat(spin, " 1s linear infinite"),
|
|
52
|
+
});
|
|
53
|
+
var Loading = (0, react_1.styled)("div", {
|
|
54
|
+
display: "flex",
|
|
55
|
+
justifyContent: "center",
|
|
56
|
+
alignItems: "center",
|
|
57
|
+
padding: "8px",
|
|
58
|
+
});
|
|
59
|
+
var Toolbar = (0, react_1.styled)("div", {
|
|
60
|
+
position: "absolute",
|
|
61
|
+
top: 0,
|
|
62
|
+
right: 0,
|
|
63
|
+
padding: "4px",
|
|
64
|
+
});
|
|
@@ -34,8 +34,9 @@ function installFieldTypes() {
|
|
|
34
34
|
var _loop_1 = function (name_1) {
|
|
35
35
|
var type = fields_1.default[name_1];
|
|
36
36
|
var Component = type.render;
|
|
37
|
-
var init = function (
|
|
38
|
-
|
|
37
|
+
var init = function (field) {
|
|
38
|
+
console.log("Field is", field);
|
|
39
|
+
var $el = field.$el, cid = field.cid, data = field.data;
|
|
39
40
|
var input = $el.find("input[type='hidden']");
|
|
40
41
|
var container = document.createElement("div");
|
|
41
42
|
$el.append(container);
|
|
@@ -52,9 +53,20 @@ exports.installFieldTypes = installFieldTypes;
|
|
|
52
53
|
function FieldWrapper(_a) {
|
|
53
54
|
var input = _a.input, defaultValue = _a.defaultValue, Component = _a.Component, settings = _a.settings;
|
|
54
55
|
var _b = (0, react_1.useState)(function () { var _a; return (_a = (input.value ? JSON.parse(input.value) : null)) !== null && _a !== void 0 ? _a : defaultValue; }), value = _b[0], setValue = _b[1];
|
|
56
|
+
var _c = (0, react_1.useState)(false), valueChanged = _c[0], setValueChanged = _c[1];
|
|
55
57
|
(0, react_1.useEffect)(function () {
|
|
56
58
|
input.value = JSON.stringify(value);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
if (valueChanged) {
|
|
60
|
+
try {
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
window.jQuery(input).change();
|
|
63
|
+
}
|
|
64
|
+
catch (err) { }
|
|
65
|
+
setValueChanged(false);
|
|
66
|
+
}
|
|
67
|
+
}, [value, valueChanged]);
|
|
68
|
+
return ((0, jsx_runtime_1.jsx)(Component, { value: value, onChange: function (value) {
|
|
69
|
+
setValue(value);
|
|
70
|
+
setValueChanged(true);
|
|
71
|
+
}, settings: settings }, void 0));
|
|
60
72
|
}
|
|
@@ -96,7 +96,6 @@ function useGravityForm(opts) {
|
|
|
96
96
|
submit: function (state) {
|
|
97
97
|
dispatch({ type: "submitting" });
|
|
98
98
|
submit(form, state).then(function (result) {
|
|
99
|
-
console.log("RESULT", result);
|
|
100
99
|
if (cancelled)
|
|
101
100
|
return;
|
|
102
101
|
if (result.success) {
|
|
@@ -126,7 +125,11 @@ function prepareValuesPayload(form, state, data) {
|
|
|
126
125
|
for (var _i = 0, _a = form.fields; _i < _a.length; _i++) {
|
|
127
126
|
var field = _a[_i];
|
|
128
127
|
var value = state.values[field.id];
|
|
129
|
-
|
|
128
|
+
var key = "input_" + field.id;
|
|
129
|
+
if (field.type === "consent") {
|
|
130
|
+
key += "_1";
|
|
131
|
+
}
|
|
132
|
+
data[key] = value;
|
|
130
133
|
}
|
|
131
134
|
return data;
|
|
132
135
|
}
|
|
@@ -137,7 +140,6 @@ function submit(form, state) {
|
|
|
137
140
|
switch (_a.label) {
|
|
138
141
|
case 0:
|
|
139
142
|
_a.trys.push([0, 3, , 4]);
|
|
140
|
-
console.log("Submitting", { form: form, state: state });
|
|
141
143
|
url = "/wp-json/ed/v1/gf/submit";
|
|
142
144
|
params = {
|
|
143
145
|
formID: form.id,
|