eddev 0.1.47 → 0.1.48-b1
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/fields/ImageWell.d.ts +8 -0
- package/fields/ImageWell.js +64 -0
- package/fields/installFieldTypes.js +3 -0
- package/package.json +1 -1
- package/yarn-error.log +0 -8200
|
@@ -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
|
+
});
|
|
@@ -28,14 +28,17 @@ var jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
28
28
|
var fields_1 = __importDefault(require("@manifest/fields"));
|
|
29
29
|
var ReactDOM = __importStar(require("react-dom"));
|
|
30
30
|
var react_1 = require("react");
|
|
31
|
+
console.log("Field types available");
|
|
31
32
|
function installFieldTypes() {
|
|
32
33
|
// @ts-ignore
|
|
33
34
|
var acf = window.acf;
|
|
35
|
+
console.log("Installing field types", fields_1.default);
|
|
34
36
|
var _loop_1 = function (name_1) {
|
|
35
37
|
var type = fields_1.default[name_1];
|
|
36
38
|
var Component = type.render;
|
|
37
39
|
var init = function (_a) {
|
|
38
40
|
var $el = _a.$el, cid = _a.cid, data = _a.data;
|
|
41
|
+
console.log("Initializing field", $el, data);
|
|
39
42
|
var input = $el.find("input[type='hidden']");
|
|
40
43
|
var container = document.createElement("div");
|
|
41
44
|
$el.append(container);
|