decap-cms-widget-file 3.4.0 → 3.5.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.
@@ -1,18 +1,18 @@
1
1
  import _styled from "@emotion/styled/base";
2
2
  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)."; }
3
- import React from 'react';
4
3
  import PropTypes from 'prop-types';
5
4
  import { List } from 'immutable';
6
5
  import { WidgetPreviewContainer } from 'decap-cms-ui-default';
7
- import { jsx as ___EmotionJSX } from "@emotion/react";
6
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
8
7
  const FileLink = /*#__PURE__*/_styled(({
9
8
  href,
10
9
  path
11
- }) => ___EmotionJSX("a", {
10
+ }) => _jsx("a", {
12
11
  href: href,
13
12
  rel: "noopener noreferrer",
14
- target: "_blank"
15
- }, path), {
13
+ target: "_blank",
14
+ children: path
15
+ }), {
16
16
  target: "ecp3s3o0",
17
17
  label: "FileLink"
18
18
  })(process.env.NODE_ENV === "production" ? {
@@ -20,7 +20,7 @@ const FileLink = /*#__PURE__*/_styled(({
20
20
  styles: "display:block"
21
21
  } : {
22
22
  name: "4zleql",
23
- styles: "display:block/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9GaWxlUHJldmlldy5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFVRSIsImZpbGUiOiIuLi8uLi9zcmMvRmlsZVByZXZpZXcuanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgUmVhY3QgZnJvbSAncmVhY3QnO1xuaW1wb3J0IFByb3BUeXBlcyBmcm9tICdwcm9wLXR5cGVzJztcbmltcG9ydCBzdHlsZWQgZnJvbSAnQGVtb3Rpb24vc3R5bGVkJztcbmltcG9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ICByZXR1cm4gKFxuICAgIDxXaWRnZXRQcmV2aWV3Q29udGFpbmVyPlxuICAgICAge3Byb3BzLnZhbHVlID8gPEZpbGVDb250ZW50IHsuLi5wcm9wc30gLz4gOiBudWxsfVxuICAgIDwvV2lkZ2V0UHJldmlld0NvbnRhaW5lcj5cbiAgKTtcbn1cblxuRmlsZVByZXZpZXcucHJvcFR5cGVzID0ge1xuICBnZXRBc3NldDogUHJvcFR5cGVzLmZ1bmMuaXNSZXF1aXJlZCxcbiAgdmFsdWU6IFByb3BUeXBlcy5ub2RlLFxufTtcblxuZXhwb3J0IGRlZmF1bHQgRmlsZVByZXZpZXc7XG4iXX0= */",
23
+ styles: "display:block/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9GaWxlUHJldmlldy5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFTRSIsImZpbGUiOiIuLi8uLi9zcmMvRmlsZVByZXZpZXcuanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgUHJvcFR5cGVzIGZyb20gJ3Byb3AtdHlwZXMnO1xuaW1wb3J0IHN0eWxlZCBmcm9tICdAZW1vdGlvbi9zdHlsZWQnO1xuaW1wb3J0IHsgTGlzdCB9IGZyb20gJ2ltbXV0YWJsZSc7XG5pbXBvcnQgeyBXaWRnZXRQcmV2aWV3Q29udGFpbmVyIH0gZnJvbSAnZGVjYXAtY21zLXVpLWRlZmF1bHQnO1xuXG5jb25zdCBGaWxlTGluayA9IHN0eWxlZCgoeyBocmVmLCBwYXRoIH0pID0+IChcbiAgPGEgaHJlZj17aHJlZn0gcmVsPVwibm9vcGVuZXIgbm9yZWZlcnJlclwiIHRhcmdldD1cIl9ibGFua1wiPlxuICAgIHtwYXRofVxuICA8L2E+XG4pKWBcbiAgZGlzcGxheTogYmxvY2s7XG5gO1xuXG5mdW5jdGlvbiBGaWxlTGlua0xpc3QoeyB2YWx1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IFIED_CSS_ERROR__
25
25
  });
26
26
  function FileLinkList({
@@ -28,11 +28,12 @@ function FileLinkList({
28
28
  getAsset,
29
29
  field
30
30
  }) {
31
- return ___EmotionJSX("div", null, values.map(value => ___EmotionJSX(FileLink, {
32
- key: value,
33
- path: value,
34
- href: getAsset(value, field)
35
- })));
31
+ return _jsx("div", {
32
+ children: values.map(value => _jsx(FileLink, {
33
+ path: value,
34
+ href: getAsset(value, field)
35
+ }, value))
36
+ });
36
37
  }
37
38
  function FileContent(props) {
38
39
  const {
@@ -41,20 +42,23 @@ function FileContent(props) {
41
42
  field
42
43
  } = props;
43
44
  if (Array.isArray(value) || List.isList(value)) {
44
- return ___EmotionJSX(FileLinkList, {
45
+ return _jsx(FileLinkList, {
45
46
  values: value,
46
47
  getAsset: getAsset,
47
48
  field: field
48
49
  });
49
50
  }
50
- return ___EmotionJSX(FileLink, {
51
- key: value,
51
+ return _jsx(FileLink, {
52
52
  path: value,
53
53
  href: getAsset(value, field)
54
- });
54
+ }, value);
55
55
  }
56
56
  function FilePreview(props) {
57
- return ___EmotionJSX(WidgetPreviewContainer, null, props.value ? ___EmotionJSX(FileContent, props) : null);
57
+ return _jsx(WidgetPreviewContainer, {
58
+ children: props.value ? _jsx(FileContent, {
59
+ ...props
60
+ }) : null
61
+ });
58
62
  }
59
63
  FilePreview.propTypes = {
60
64
  getAsset: PropTypes.func.isRequired,
@@ -1,5 +1,4 @@
1
1
  import _styled from "@emotion/styled/base";
2
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
2
  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)."; }
4
3
  import React, { useEffect, useState } from 'react';
5
4
  import PropTypes from 'prop-types';
@@ -15,7 +14,7 @@ import { DndContext, MouseSensor, TouchSensor, closestCenter, useSensor, useSens
15
14
  import { SortableContext, useSortable } from '@dnd-kit/sortable';
16
15
  import { CSS } from '@dnd-kit/utilities';
17
16
  import { restrictToParentElement } from '@dnd-kit/modifiers';
18
- import { jsx as ___EmotionJSX } from "@emotion/react";
17
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
19
18
  const MAX_DISPLAY_LENGTH = 50;
20
19
  const ImageWrapper = /*#__PURE__*/_styled("div", {
21
20
  target: "e1hax4ql7",
@@ -57,7 +56,7 @@ function Image({
57
56
  setAsset(null);
58
57
  }
59
58
  }, [value, field, getAsset]);
60
- return asset ? ___EmotionJSX(StyledImage, {
59
+ return asset ? _jsx(StyledImage, {
61
60
  role: "presentation",
62
61
  src: asset
63
62
  }) : null;
@@ -66,15 +65,17 @@ function SortableImageButtons({
66
65
  onRemove,
67
66
  onReplace
68
67
  }) {
69
- return ___EmotionJSX(SortableImageButtonsWrapper, null, ___EmotionJSX(IconButton, {
70
- size: "small",
71
- type: "media",
72
- onClick: onReplace
73
- }), ___EmotionJSX(IconButton, {
74
- size: "small",
75
- type: "close",
76
- onClick: onRemove
77
- }));
68
+ return _jsxs(SortableImageButtonsWrapper, {
69
+ children: [_jsx(IconButton, {
70
+ size: "small",
71
+ type: "media",
72
+ onClick: onReplace
73
+ }), _jsx(IconButton, {
74
+ size: "small",
75
+ type: "close",
76
+ onClick: onRemove
77
+ })]
78
+ });
78
79
  }
79
80
  function SortableImage(props) {
80
81
  const {
@@ -97,20 +98,24 @@ function SortableImage(props) {
97
98
  onRemove,
98
99
  onReplace
99
100
  } = props;
100
- return ___EmotionJSX("div", _extends({
101
+ return _jsxs("div", {
101
102
  ref: setNodeRef,
102
- style: style
103
- }, attributes, listeners), ___EmotionJSX(ImageWrapper, {
104
- sortable: true
105
- }, ___EmotionJSX(Image, {
106
- value: itemValue,
107
- field: field,
108
- getAsset: getAsset
109
- })), ___EmotionJSX(SortableImageButtons, {
110
- item: itemValue,
111
- onRemove: onRemove,
112
- onReplace: onReplace
113
- }));
103
+ style: style,
104
+ ...attributes,
105
+ ...listeners,
106
+ children: [_jsx(ImageWrapper, {
107
+ sortable: true,
108
+ children: _jsx(Image, {
109
+ value: itemValue,
110
+ field: field,
111
+ getAsset: getAsset
112
+ })
113
+ }), _jsx(SortableImageButtons, {
114
+ item: itemValue,
115
+ onRemove: onRemove,
116
+ onReplace: onReplace
117
+ })]
118
+ });
114
119
  }
115
120
  var _ref = process.env.NODE_ENV === "production" ? {
116
121
  name: "a42x49-SortableMultiImageWrapper",
@@ -145,26 +150,28 @@ function SortableMultiImageWrapper({
145
150
  newIndex: items.findIndex(item => item.id === over.id)
146
151
  });
147
152
  }
148
- return ___EmotionJSX("div", {
153
+ return _jsx("div", {
149
154
  // eslint-disable-next-line react/no-unknown-property
150
- css: _ref
151
- }, ___EmotionJSX(DndContext, {
152
- modifiers: [restrictToParentElement],
153
- collisionDetection: closestCenter,
154
- sensors: sensors,
155
- onDragEnd: handleSortEnd
156
- }, ___EmotionJSX(SortableContext, {
157
- items: items
158
- }, items.map((item, index) => ___EmotionJSX(SortableImage, {
159
- key: item.id,
160
- id: item.id,
161
- index: index,
162
- itemValue: item.value,
163
- getAsset: getAsset,
164
- field: field,
165
- onRemove: onRemoveOne(index),
166
- onReplace: onReplaceOne(index)
167
- })))));
155
+ css: _ref,
156
+ children: _jsx(DndContext, {
157
+ modifiers: [restrictToParentElement],
158
+ collisionDetection: closestCenter,
159
+ sensors: sensors,
160
+ onDragEnd: handleSortEnd,
161
+ children: _jsx(SortableContext, {
162
+ items: items,
163
+ children: items.map((item, index) => _jsx(SortableImage, {
164
+ id: item.id,
165
+ index: index,
166
+ itemValue: item.value,
167
+ getAsset: getAsset,
168
+ field: field,
169
+ onRemove: onRemoveOne(index),
170
+ onReplace: onReplaceOne(index)
171
+ }, item.id))
172
+ })
173
+ })
174
+ });
168
175
  }
169
176
  const FileLink = /*#__PURE__*/_styled("a", {
170
177
  target: "e1hax4ql4",
@@ -394,22 +401,29 @@ export default function withFileControl({
394
401
  return value;
395
402
  }
396
403
  const text = `${value.slice(0, size / 2)}\u2026${value.slice(-(size / 2) + 1)}`;
397
- return ___EmotionJSX(FileLink, {
404
+ return _jsx(FileLink, {
398
405
  href: value,
399
406
  rel: "noopener",
400
- target: "_blank"
401
- }, text);
407
+ target: "_blank",
408
+ children: text
409
+ });
402
410
  };
403
411
  renderFileLinks = () => {
404
412
  const {
405
413
  value
406
414
  } = this.props;
407
415
  if (isMultiple(value)) {
408
- return ___EmotionJSX(FileLinks, null, ___EmotionJSX(FileLinkList, null, value.map(val => ___EmotionJSX("li", {
409
- key: val
410
- }, this.renderFileLink(val)))));
416
+ return _jsx(FileLinks, {
417
+ children: _jsx(FileLinkList, {
418
+ children: value.map(val => _jsx("li", {
419
+ children: this.renderFileLink(val)
420
+ }, val))
421
+ })
422
+ });
411
423
  }
412
- return ___EmotionJSX(FileLinks, null, this.renderFileLink(value));
424
+ return _jsx(FileLinks, {
425
+ children: this.renderFileLink(value)
426
+ });
413
427
  };
414
428
  renderImages = () => {
415
429
  const {
@@ -419,7 +433,7 @@ export default function withFileControl({
419
433
  } = this.props;
420
434
  const items = valueListToSortableArray(value);
421
435
  if (isMultiple(value)) {
422
- return ___EmotionJSX(SortableMultiImageWrapper, {
436
+ return _jsx(SortableMultiImageWrapper, {
423
437
  items: items,
424
438
  onSortEnd: this.onSortEnd,
425
439
  onRemoveOne: this.onRemoveOne,
@@ -431,11 +445,13 @@ export default function withFileControl({
431
445
  lockToContainerEdges: true
432
446
  });
433
447
  }
434
- return ___EmotionJSX(ImageWrapper, null, ___EmotionJSX(Image, {
435
- value: value,
436
- field: field,
437
- getAsset: getAsset
438
- }));
448
+ return _jsx(ImageWrapper, {
449
+ children: _jsx(Image, {
450
+ value: value,
451
+ field: field,
452
+ getAsset: getAsset
453
+ })
454
+ });
439
455
  };
440
456
  renderSelection = subject => {
441
457
  const {
@@ -443,24 +459,35 @@ export default function withFileControl({
443
459
  field
444
460
  } = this.props;
445
461
  const allowsMultiple = this.allowsMultiple();
446
- return ___EmotionJSX("div", null, forImage ? this.renderImages() : null, ___EmotionJSX("div", null, forImage ? null : this.renderFileLinks(), ___EmotionJSX(FileWidgetButton, {
447
- onClick: this.handleChange
448
- }, t(`editor.editorWidgets.${subject}.${this.allowsMultiple() ? 'addMore' : 'chooseDifferent'}`)), field.get('choose_url', true) && !this.allowsMultiple() ? ___EmotionJSX(FileWidgetButton, {
449
- onClick: this.handleUrl(subject)
450
- }, t(`editor.editorWidgets.${subject}.replaceUrl`)) : null, ___EmotionJSX(FileWidgetButtonRemove, {
451
- onClick: this.handleRemove
452
- }, t(`editor.editorWidgets.${subject}.remove${allowsMultiple ? 'All' : ''}`))));
462
+ return _jsxs("div", {
463
+ children: [forImage ? this.renderImages() : null, _jsxs("div", {
464
+ children: [forImage ? null : this.renderFileLinks(), _jsx(FileWidgetButton, {
465
+ onClick: this.handleChange,
466
+ children: t(`editor.editorWidgets.${subject}.${this.allowsMultiple() ? 'addMore' : 'chooseDifferent'}`)
467
+ }), field.get('choose_url', true) && !this.allowsMultiple() ? _jsx(FileWidgetButton, {
468
+ onClick: this.handleUrl(subject),
469
+ children: t(`editor.editorWidgets.${subject}.replaceUrl`)
470
+ }) : null, _jsx(FileWidgetButtonRemove, {
471
+ onClick: this.handleRemove,
472
+ children: t(`editor.editorWidgets.${subject}.remove${allowsMultiple ? 'All' : ''}`)
473
+ })]
474
+ })]
475
+ });
453
476
  };
454
477
  renderNoSelection = subject => {
455
478
  const {
456
479
  t,
457
480
  field
458
481
  } = this.props;
459
- return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(FileWidgetButton, {
460
- onClick: this.handleChange
461
- }, t(`editor.editorWidgets.${subject}.choose${this.allowsMultiple() ? 'Multiple' : ''}`)), field.get('choose_url', true) ? ___EmotionJSX(FileWidgetButton, {
462
- onClick: this.handleUrl(subject)
463
- }, t(`editor.editorWidgets.${subject}.chooseUrl`)) : null);
482
+ return _jsxs(_Fragment, {
483
+ children: [_jsx(FileWidgetButton, {
484
+ onClick: this.handleChange,
485
+ children: t(`editor.editorWidgets.${subject}.choose${this.allowsMultiple() ? 'Multiple' : ''}`)
486
+ }), field.get('choose_url', true) ? _jsx(FileWidgetButton, {
487
+ onClick: this.handleUrl(subject),
488
+ children: t(`editor.editorWidgets.${subject}.chooseUrl`)
489
+ }) : null]
490
+ });
464
491
  };
465
492
  render() {
466
493
  const {
@@ -468,9 +495,12 @@ export default function withFileControl({
468
495
  classNameWrapper
469
496
  } = this.props;
470
497
  const subject = forImage ? 'image' : 'file';
471
- return ___EmotionJSX("div", {
472
- className: classNameWrapper
473
- }, ___EmotionJSX("span", null, value ? this.renderSelection(subject) : this.renderNoSelection(subject)));
498
+ return _jsx("div", {
499
+ className: classNameWrapper,
500
+ children: _jsx("span", {
501
+ children: value ? this.renderSelection(subject) : this.renderNoSelection(subject)
502
+ })
503
+ });
474
504
  }
475
505
  };
476
506
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "decap-cms-widget-file",
3
3
  "description": "Widget for uploading files in Decap CMS.",
4
- "version": "3.4.0",
4
+ "version": "3.5.0",
5
5
  "homepage": "https://www.decapcms.org/docs/widgets/#file",
6
6
  "repository": "https://github.com/decaporg/decap-cms/tree/main/packages/decap-cms-widget-file",
7
7
  "bugs": "https://github.com/decaporg/decap-cms/issues",
@@ -38,5 +38,5 @@
38
38
  "react": "^19.1.0",
39
39
  "react-immutable-proptypes": "^2.1.0"
40
40
  },
41
- "gitHead": "567a80101f4846853701ad7d8abdc29b5e4fab56"
41
+ "gitHead": "ffe5ab7e61f4e7cb374a413bf9fe55f088d20ba2"
42
42
  }
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import PropTypes from 'prop-types';
3
2
  import styled from '@emotion/styled';
4
3
  import { List } from 'immutable';