decap-cms-widget-file 2.13.0-beta.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,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _styledBase = _interopRequireDefault(require("@emotion/styled-base"));
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _immutable = require("immutable");
11
+ var _decapCmsUiDefault = require("decap-cms-ui-default");
12
+ var _core = require("@emotion/core");
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
15
+ const FileLink = ( /*#__PURE__*/0, _styledBase.default)(({
16
+ href,
17
+ path
18
+ }) => (0, _core.jsx)("a", {
19
+ href: href,
20
+ rel: "noopener noreferrer",
21
+ target: "_blank"
22
+ }, path), {
23
+ target: "ecp3s3o0",
24
+ label: "FileLink"
25
+ })(process.env.NODE_ENV === "production" ? {
26
+ name: "13o7eu2",
27
+ styles: "display:block;"
28
+ } : {
29
+ name: "13o7eu2",
30
+ styles: "display:block;",
31
+ map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9GaWxlUHJldmlldy5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFVRSIsImZpbGUiOiIuLi8uLi9zcmMvRmlsZVByZXZpZXcuanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgUmVhY3QgZnJvbSAncmVhY3QnO1xuaW1wb3J0IFByb3BUeXBlcyBmcm9tICdwcm9wLXR5cGVzJztcbmltcG9ydCBzd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ufVxuXG5mdW5jdGlvbiBGaWxlUHJldmlldyhwcm9wcykge1xuICByZXR1cm4gKFxuICAgIDxXaWRnZXRQcmV2aWV3Q29udGFpbmVyPlxuICAgICAge3Byb3BzLnZhbHVlID8gPEZpbGVDb250ZW50IHsuLi5wcm9wc30gLz4gOiBudWxsfVxuICAgIDwvV2lkZ2V0UHJldmlld0NvbnRhaW5lcj5cbiAgKTtcbn1cblxuRmlsZVByZXZpZXcucHJvcFR5cGVzID0ge1xuICBnZXRBc3NldDogUHJvcFR5cGVzLmZ1bmMuaXNSZXF1aXJlZCxcbiAgdmFsdWU6IFByb3BUeXBlcy5ub2RlLFxufTtcblxuZXhwb3J0IGRlZmF1bHQgRmlsZVByZXZpZXc7XG4iXX0= */",
32
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
33
+ });
34
+ function FileLinkList({
35
+ values,
36
+ getAsset,
37
+ field
38
+ }) {
39
+ return (0, _core.jsx)("div", null, values.map(value => (0, _core.jsx)(FileLink, {
40
+ key: value,
41
+ path: value,
42
+ href: getAsset(value, field)
43
+ })));
44
+ }
45
+ function FileContent(props) {
46
+ const {
47
+ value,
48
+ getAsset,
49
+ field
50
+ } = props;
51
+ if (Array.isArray(value) || _immutable.List.isList(value)) {
52
+ return (0, _core.jsx)(FileLinkList, {
53
+ values: value,
54
+ getAsset: getAsset,
55
+ field: field
56
+ });
57
+ }
58
+ return (0, _core.jsx)(FileLink, {
59
+ key: value,
60
+ path: value,
61
+ href: getAsset(value, field)
62
+ });
63
+ }
64
+ function FilePreview(props) {
65
+ return (0, _core.jsx)(_decapCmsUiDefault.WidgetPreviewContainer, null, props.value ? (0, _core.jsx)(FileContent, props) : null);
66
+ }
67
+ FilePreview.propTypes = {
68
+ getAsset: _propTypes.default.func.isRequired,
69
+ value: _propTypes.default.node
70
+ };
71
+ var _default = FilePreview;
72
+ exports.default = _default;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.DecapCmsWidgetFile = void 0;
7
+ var _withFileControl = _interopRequireDefault(require("./withFileControl"));
8
+ var _FilePreview = _interopRequireDefault(require("./FilePreview"));
9
+ var _schema = _interopRequireDefault(require("./schema"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
13
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
15
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
16
+ const controlComponent = (0, _withFileControl.default)();
17
+ function Widget(opts = {}) {
18
+ return _objectSpread({
19
+ name: 'file',
20
+ controlComponent,
21
+ previewComponent: _FilePreview.default,
22
+ schema: _schema.default
23
+ }, opts);
24
+ }
25
+ const DecapCmsWidgetFile = {
26
+ Widget,
27
+ controlComponent,
28
+ previewComponent: _FilePreview.default,
29
+ withFileControl: _withFileControl.default
30
+ };
31
+ exports.DecapCmsWidgetFile = DecapCmsWidgetFile;
32
+ var _default = DecapCmsWidgetFile;
33
+ exports.default = _default;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = {
8
+ properties: {
9
+ allow_multiple: {
10
+ type: 'boolean'
11
+ }
12
+ }
13
+ };
14
+ exports.default = _default;