@os-design/upload 1.0.159 → 1.0.161

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.
@@ -4,101 +4,62 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = exports.Overlay = void 0;
7
-
8
7
  var _react = require("@emotion/react");
9
-
10
8
  var _styled = _interopRequireDefault(require("@emotion/styled"));
11
-
12
9
  var _core = require("@os-design/core");
13
-
14
10
  var _icons = require("@os-design/icons");
15
-
16
11
  var _styles = require("@os-design/styles");
17
-
18
12
  var _theming = require("@os-design/theming");
19
-
20
13
  var _utils = require("@os-design/utils");
21
-
22
14
  var _react2 = _interopRequireWildcard(require("react"));
23
-
24
15
  var _reactDropzone = require("react-dropzone");
25
-
26
16
  var _defaultLocale = _interopRequireDefault(require("./utils/defaultLocale"));
27
-
28
17
  var _excluded = ["url", "accept", "locale", "value", "defaultValue", "onChange", "size"];
29
-
30
18
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15;
31
-
32
19
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
33
-
34
20
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
35
-
36
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
37
-
38
22
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
39
-
40
23
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
41
-
42
24
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
43
-
44
25
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
45
-
46
26
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
47
-
48
27
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
49
-
50
28
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
51
-
52
29
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
53
-
54
30
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
55
-
56
31
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
57
-
58
32
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
59
-
60
33
  var overlayHasImageStyles = function overlayHasImageStyles(p) {
61
34
  return p.hasImage && (0, _react.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: hsla(0, 0%, 0%, ", ");\n color: hsl(0, 0%, 100%);\n "])), p.theme.imageUploadOverlayOpacity);
62
35
  };
63
-
64
36
  var overlayHasImageHoverStyles = function overlayHasImageHoverStyles(p) {
65
37
  return p.hasImage && !p.isDragActive && (0, _react.css)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n @media (hover: hover) {\n opacity: 0;\n\n &:hover {\n opacity: 1;\n }\n }\n "])));
66
38
  };
67
-
68
39
  var Overlay = (0, _styled["default"])('div', (0, _utils.omitEmotionProps)('isDragActive', 'hasImage'))(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n ", ";\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n\n text-align: center;\n padding: ", "em;\n\n ", ";\n ", "\n ", ";\n"])), _styles.resetFocusStyles, function (p) {
69
40
  return p.theme.imageUploadOverlayPadding;
70
41
  }, overlayHasImageStyles, overlayHasImageHoverStyles, (0, _styles.transitionStyles)('opacity'));
71
42
  exports.Overlay = Overlay;
72
-
73
43
  var contentIsDragActiveStyles = function contentIsDragActiveStyles(p) {
74
44
  return p.isDragActive && (0, _react.css)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n transform: scale(0.92);\n "])));
75
45
  };
76
-
77
46
  var Content = (0, _styled["default"])('div', (0, _utils.omitEmotionProps)('isDragActive'))(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n ", ";\n ", ";\n"])), contentIsDragActiveStyles, (0, _styles.transitionStyles)('transform'));
78
47
  var PictureIcon = (0, _styled["default"])(_icons.Picture)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n opacity: 0.8;\n font-size: 2.5em;\n"])));
79
-
80
48
  var Title = _styled["default"].div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n opacity: 0.8;\n"])));
81
-
82
49
  var DeleteButtonContainer = _styled["default"].div(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n position: absolute;\n top: 0.5em;\n right: 0.5em;\n"])));
83
-
84
50
  var hoverStyles = function hoverStyles(p) {
85
51
  return (0, _react.css)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n border-color: ", ";\n"])), (0, _theming.clr)(p.theme.imageUploadNoImageHoverColorBorder));
86
52
  };
87
-
88
53
  var notHasImageStyles = function notHasImageStyles(p) {
89
54
  return !p.hasImage && (0, _react.css)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n background-color: ", ";\n border: 2px dashed ", ";\n\n @media (hover: hover) {\n &:hover {\n ", ";\n }\n }\n "])), (0, _theming.clr)(p.theme.imageUploadNoImageColorBg), (0, _theming.clr)(p.theme.imageUploadNoImageColorBorder), hoverStyles(p));
90
55
  };
91
-
92
56
  var focusStyles = function focusStyles(p) {
93
57
  return (0, _react.css)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n &:focus-within {\n & > div {\n opacity: 1;\n }\n ", ";\n }\n"])), hoverStyles(p));
94
58
  };
95
-
96
59
  var isDragActiveStyles = function isDragActiveStyles(p) {
97
60
  return p.isDragActive && (0, _react.css)(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n ", ";\n "])), hoverStyles(p));
98
61
  };
99
-
100
62
  var LocalImage = _styled["default"].img(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n width: 100%;\n vertical-align: top;\n"])));
101
-
102
63
  var RemoteImage = (0, _styled["default"])(_core.Image)(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n vertical-align: top;\n"])));
103
64
  var Container = (0, _styled["default"])('div', (0, _utils.omitEmotionProps)('isDragActive', 'hasImage', 'size'))(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["\n position: relative;\n cursor: pointer;\n overflow: hidden;\n box-sizing: border-box;\n\n max-width: ", "em;\n min-height: ", "em;\n border-radius: ", "em;\n color: ", ";\n\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n"])), function (p) {
104
65
  return p.theme.imageUploadMaxWidth;
@@ -109,56 +70,49 @@ var Container = (0, _styled["default"])('div', (0, _utils.omitEmotionProps)('isD
109
70
  }, function (p) {
110
71
  return (0, _theming.clr)(p.theme.colorText);
111
72
  }, notHasImageStyles, focusStyles, isDragActiveStyles, _styles.sizeStyles, (0, _styles.transitionStyles)('border'));
73
+
112
74
  /**
113
75
  * The component to upload an image.
114
76
  */
115
-
116
77
  var ImageUpload = /*#__PURE__*/(0, _react2.forwardRef)(function (_ref, ref) {
117
78
  var url = _ref.url,
118
- _ref$accept = _ref.accept,
119
- accept = _ref$accept === void 0 ? {
120
- 'image/*': ['.jpeg', '.png', '.webp']
121
- } : _ref$accept,
122
- _ref$locale = _ref.locale,
123
- locale = _ref$locale === void 0 ? _defaultLocale["default"] : _ref$locale,
124
- value = _ref.value,
125
- defaultValue = _ref.defaultValue,
126
- onChange = _ref.onChange,
127
- size = _ref.size,
128
- rest = _objectWithoutProperties(_ref, _excluded);
129
-
79
+ _ref$accept = _ref.accept,
80
+ accept = _ref$accept === void 0 ? {
81
+ 'image/*': ['.jpeg', '.png', '.webp']
82
+ } : _ref$accept,
83
+ _ref$locale = _ref.locale,
84
+ locale = _ref$locale === void 0 ? _defaultLocale["default"] : _ref$locale,
85
+ value = _ref.value,
86
+ defaultValue = _ref.defaultValue,
87
+ onChange = _ref.onChange,
88
+ size = _ref.size,
89
+ rest = _objectWithoutProperties(_ref, _excluded);
130
90
  var touchDevice = (0, _react2.useMemo)(function () {
131
91
  return (0, _utils.isTouchDevice)();
132
92
  }, []);
133
-
134
93
  var _useForwardedState = (0, _utils.useForwardedState)({
135
- value: value,
136
- defaultValue: defaultValue,
137
- onChange: onChange
138
- }),
139
- _useForwardedState2 = _slicedToArray(_useForwardedState, 2),
140
- forwardedValue = _useForwardedState2[0],
141
- setForwardedValue = _useForwardedState2[1];
142
-
94
+ value: value,
95
+ defaultValue: defaultValue,
96
+ onChange: onChange
97
+ }),
98
+ _useForwardedState2 = _slicedToArray(_useForwardedState, 2),
99
+ forwardedValue = _useForwardedState2[0],
100
+ setForwardedValue = _useForwardedState2[1];
143
101
  var _useDropzone = (0, _reactDropzone.useDropzone)({
144
- accept: accept,
145
- multiple: false,
146
- onDrop: function onDrop(_ref2) {
147
- var _ref3 = _slicedToArray(_ref2, 1),
102
+ accept: accept,
103
+ multiple: false,
104
+ onDrop: function onDrop(_ref2) {
105
+ var _ref3 = _slicedToArray(_ref2, 1),
148
106
  file = _ref3[0];
149
-
150
- return setForwardedValue(file);
151
- }
152
- }),
153
- getRootProps = _useDropzone.getRootProps,
154
- getInputProps = _useDropzone.getInputProps,
155
- isDragActive = _useDropzone.isDragActive;
156
-
107
+ return setForwardedValue(file);
108
+ }
109
+ }),
110
+ getRootProps = _useDropzone.getRootProps,
111
+ getInputProps = _useDropzone.getInputProps,
112
+ isDragActive = _useDropzone.isDragActive;
157
113
  var source = (0, _react2.useMemo)(function () {
158
114
  if (forwardedValue === null) return null; // If the user select an image
159
-
160
115
  if (forwardedValue) return URL.createObjectURL(forwardedValue); // If the image already exists
161
-
162
116
  if (url) return url;
163
117
  return null;
164
118
  }, [forwardedValue, url]);
@@ -167,13 +121,11 @@ var ImageUpload = /*#__PURE__*/(0, _react2.forwardRef)(function (_ref, ref) {
167
121
  }, [source]);
168
122
  var renderImage = (0, _react2.useCallback)(function () {
169
123
  if (!source) return null;
170
-
171
124
  if (_typeof(forwardedValue) === 'object' && forwardedValue !== null) {
172
125
  return /*#__PURE__*/_react2["default"].createElement(LocalImage, {
173
126
  src: source
174
127
  });
175
128
  }
176
-
177
129
  return /*#__PURE__*/_react2["default"].createElement(RemoteImage, {
178
130
  url: source
179
131
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["overlayHasImageStyles","p","hasImage","css","theme","imageUploadOverlayOpacity","overlayHasImageHoverStyles","isDragActive","Overlay","styled","omitEmotionProps","resetFocusStyles","imageUploadOverlayPadding","transitionStyles","contentIsDragActiveStyles","Content","PictureIcon","Picture","Title","div","DeleteButtonContainer","hoverStyles","clr","imageUploadNoImageHoverColorBorder","notHasImageStyles","imageUploadNoImageColorBg","imageUploadNoImageColorBorder","focusStyles","isDragActiveStyles","LocalImage","img","RemoteImage","Image","Container","imageUploadMaxWidth","imageUploadMinHeight","borderRadius","colorText","sizeStyles","ImageUpload","forwardRef","ref","url","accept","locale","defaultLocale","value","defaultValue","onChange","size","rest","touchDevice","useMemo","isTouchDevice","useForwardedState","forwardedValue","setForwardedValue","useDropzone","multiple","onDrop","file","getRootProps","getInputProps","source","URL","createObjectURL","renderImage","useCallback","e","preventDefault","onKeyDown","key","touchTitle","dropTitle","buttonGhostColorText","buttonGhostColorBgHover","stopPropagation","displayName"],"sources":["../../../src/ImageUpload/index.tsx"],"sourcesContent":["import { css } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { Button, Image } from '@os-design/core';\nimport { Delete, Picture } from '@os-design/icons';\nimport {\n resetFocusStyles,\n sizeStyles,\n transitionStyles,\n WithSize,\n} from '@os-design/styles';\nimport { clr, ThemeOverrider } from '@os-design/theming';\nimport {\n isTouchDevice,\n omitEmotionProps,\n useForwardedState,\n} from '@os-design/utils';\nimport React, { forwardRef, useCallback, useMemo } from 'react';\nimport { Accept, useDropzone } from 'react-dropzone';\nimport defaultLocale, { ImageUploadLocale } from './utils/defaultLocale';\n\ntype JsxDivProps = Omit<\n JSX.IntrinsicElements['div'],\n 'defaultValue' | 'onChange' | 'ref'\n>;\nexport interface ImageUploadProps extends JsxDivProps, WithSize {\n /**\n * The url of the image.\n * @default undefined\n */\n url?: string;\n /**\n * Allowed image formats.\n * @default undefined\n */\n accept?: Accept;\n /**\n * The locale of the component.\n * @default undefined\n */\n locale?: ImageUploadLocale;\n /**\n * The selected local file, or null if the image is marked as deleted.\n * @default undefined\n */\n value?: File | null;\n /**\n * The default value.\n * @default undefined\n */\n defaultValue?: File | null;\n /**\n * The change event handler.\n * @default undefined\n */\n onChange?: (value: File | null) => void;\n}\n\nconst overlayHasImageStyles = (p) =>\n p.hasImage &&\n css`\n background-color: hsla(0, 0%, 0%, ${p.theme.imageUploadOverlayOpacity});\n color: hsl(0, 0%, 100%);\n `;\n\nconst overlayHasImageHoverStyles = (p) =>\n p.hasImage &&\n !p.isDragActive &&\n css`\n @media (hover: hover) {\n opacity: 0;\n\n &:hover {\n opacity: 1;\n }\n }\n `;\n\ninterface OverlayProps {\n isDragActive: boolean;\n hasImage: boolean;\n}\nexport const Overlay = styled(\n 'div',\n omitEmotionProps('isDragActive', 'hasImage')\n)<OverlayProps>`\n ${resetFocusStyles};\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n\n text-align: center;\n padding: ${(p) => p.theme.imageUploadOverlayPadding}em;\n\n ${overlayHasImageStyles};\n ${overlayHasImageHoverStyles}\n ${transitionStyles('opacity')};\n`;\n\nconst contentIsDragActiveStyles = (p) =>\n p.isDragActive &&\n css`\n transform: scale(0.92);\n `;\n\ntype ContentProps = Pick<OverlayProps, 'isDragActive'>;\nconst Content = styled('div', omitEmotionProps('isDragActive'))<ContentProps>`\n ${contentIsDragActiveStyles};\n ${transitionStyles('transform')};\n`;\n\nconst PictureIcon = styled(Picture)`\n opacity: 0.8;\n font-size: 2.5em;\n`;\n\nconst Title = styled.div`\n opacity: 0.8;\n`;\n\nconst DeleteButtonContainer = styled.div`\n position: absolute;\n top: 0.5em;\n right: 0.5em;\n`;\n\nconst hoverStyles = (p) => css`\n border-color: ${clr(p.theme.imageUploadNoImageHoverColorBorder)};\n`;\n\nconst notHasImageStyles = (p) =>\n !p.hasImage &&\n css`\n background-color: ${clr(p.theme.imageUploadNoImageColorBg)};\n border: 2px dashed ${clr(p.theme.imageUploadNoImageColorBorder)};\n\n @media (hover: hover) {\n &:hover {\n ${hoverStyles(p)};\n }\n }\n `;\n\nconst focusStyles = (p) => css`\n &:focus-within {\n & > div {\n opacity: 1;\n }\n ${hoverStyles(p)};\n }\n`;\n\nconst isDragActiveStyles = (p) =>\n p.isDragActive &&\n css`\n ${hoverStyles(p)};\n `;\n\nconst LocalImage = styled.img`\n width: 100%;\n vertical-align: top;\n`;\n\nconst RemoteImage = styled(Image)`\n vertical-align: top;\n`;\n\ninterface ContainerProps extends WithSize {\n isDragActive: boolean;\n hasImage: boolean;\n}\n\nconst Container = styled(\n 'div',\n omitEmotionProps('isDragActive', 'hasImage', 'size')\n)<ContainerProps>`\n position: relative;\n cursor: pointer;\n overflow: hidden;\n box-sizing: border-box;\n\n max-width: ${(p) => p.theme.imageUploadMaxWidth}em;\n min-height: ${(p) => p.theme.imageUploadMinHeight}em;\n border-radius: ${(p) => p.theme.borderRadius}em;\n color: ${(p) => clr(p.theme.colorText)};\n\n ${notHasImageStyles};\n ${focusStyles};\n ${isDragActiveStyles};\n ${sizeStyles};\n ${transitionStyles('border')};\n`;\n\n/**\n * The component to upload an image.\n */\nconst ImageUpload = forwardRef<HTMLDivElement, ImageUploadProps>(\n (\n {\n url,\n accept = { 'image/*': ['.jpeg', '.png', '.webp'] },\n locale = defaultLocale,\n value,\n defaultValue,\n onChange,\n size,\n ...rest\n },\n ref\n ) => {\n const touchDevice = useMemo(() => isTouchDevice(), []);\n const [forwardedValue, setForwardedValue] = useForwardedState({\n value,\n defaultValue,\n onChange,\n });\n\n const { getRootProps, getInputProps, isDragActive } = useDropzone({\n accept,\n multiple: false,\n onDrop: ([file]) => setForwardedValue(file),\n });\n\n const source = useMemo(() => {\n if (forwardedValue === null) return null; // If the user select an image\n if (forwardedValue) return URL.createObjectURL(forwardedValue); // If the image already exists\n if (url) return url;\n return null;\n }, [forwardedValue, url]);\n\n const hasImage = useMemo(() => !!source, [source]);\n\n const renderImage = useCallback(() => {\n if (!source) return null;\n if (typeof forwardedValue === 'object' && forwardedValue !== null) {\n return <LocalImage src={source} />;\n }\n return <RemoteImage url={source} />;\n }, [forwardedValue, source]);\n\n return (\n <Container\n isDragActive={isDragActive}\n hasImage={hasImage}\n size={size}\n onMouseDown={(e) => e.preventDefault()}\n {...rest}\n ref={ref}\n >\n <input {...getInputProps()} />\n {renderImage()}\n\n <Overlay\n isDragActive={isDragActive}\n hasImage={hasImage}\n {\n ...getRootProps({\n onKeyDown: (e) => {\n if (e.key === 'Backspace') setForwardedValue(null);\n },\n } as any) // eslint-disable-line @typescript-eslint/no-explicit-any\n }\n >\n <Content isDragActive={isDragActive}>\n <PictureIcon />\n <Title>{touchDevice ? locale.touchTitle : locale.dropTitle}</Title>\n </Content>\n\n {hasImage && (\n <ThemeOverrider\n overrides={{\n buttonGhostColorText: [0, 0, 100],\n buttonGhostColorBgHover: [0, 0, 100, 0.1],\n }}\n >\n <DeleteButtonContainer>\n <Button\n type='ghost'\n wide='never'\n onClick={(e) => {\n setForwardedValue(null);\n e.stopPropagation();\n }}\n >\n <Delete />\n </Button>\n </DeleteButtonContainer>\n </ThemeOverrider>\n )}\n </Overlay>\n </Container>\n );\n }\n);\n\nImageUpload.displayName = 'ImageUpload';\n\nexport default ImageUpload;\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AAKA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAMA,qBAAqB,GAAG,SAAxBA,qBAAwB,CAACC,CAAD;EAAA,OAC5BA,CAAC,CAACC,QAAF,QACAC,UADA,uJAEsCF,CAAC,CAACG,KAAF,CAAQC,yBAF9C,CAD4B;AAAA,CAA9B;;AAOA,IAAMC,0BAA0B,GAAG,SAA7BA,0BAA6B,CAACL,CAAD;EAAA,OACjCA,CAAC,CAACC,QAAF,IACA,CAACD,CAAC,CAACM,YADH,QAEAJ,UAFA,oLADiC;AAAA,CAAnC;;AAiBO,IAAMK,OAAO,GAAG,IAAAC,kBAAA,EACrB,KADqB,EAErB,IAAAC,uBAAA,EAAiB,cAAjB,EAAiC,UAAjC,CAFqB,CAAH,wUAIhBC,wBAJgB,EAiBP,UAACV,CAAD;EAAA,OAAOA,CAAC,CAACG,KAAF,CAAQQ,yBAAf;AAAA,CAjBO,EAmBhBZ,qBAnBgB,EAoBhBM,0BApBgB,EAqBhB,IAAAO,wBAAA,EAAiB,SAAjB,CArBgB,CAAb;;;AAwBP,IAAMC,yBAAyB,GAAG,SAA5BA,yBAA4B,CAACb,CAAD;EAAA,OAChCA,CAAC,CAACM,YAAF,QACAJ,UADA,yGADgC;AAAA,CAAlC;;AAOA,IAAMY,OAAO,GAAG,IAAAN,kBAAA,EAA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B,CAAD;MAAA,OAAOA,CAAC,CAACC,cAAF,EAAP;IAAA;EAJf,GAKMnB,IALN;IAME,GAAG,EAAET;EANP,iBAQE,0CAAWqB,aAAa,EAAxB,CARF,EASGI,WAAW,EATd,eAWE,iCAAC,OAAD;IACE,YAAY,EAAE3D,YADhB;IAEE,QAAQ,EAAEL;EAFZ,GAIO2D,YAAY,CAAC;IACdS,SAAS,EAAE,mBAACF,CAAD,EAAO;MAChB,IAAIA,CAAC,CAACG,GAAF,KAAU,WAAd,EAA2Bf,iBAAiB,CAAC,IAAD,CAAjB;IAC5B;EAHa,CAAD,CAJnB,CAQc;EARd,gBAWE,iCAAC,OAAD;IAAS,YAAY,EAAEjD;EAAvB,gBACE,iCAAC,WAAD,OADF,eAEE,iCAAC,KAAD,QAAQ4C,WAAW,GAAGP,MAAM,CAAC4B,UAAV,GAAuB5B,MAAM,CAAC6B,SAAjD,CAFF,CAXF,EAgBGvE,QAAQ,iBACP,iCAAC,uBAAD;IACE,SAAS,EAAE;MACTwE,oBAAoB,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,GAAP,CADb;MAETC,uBAAuB,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,GAAP,EAAY,GAAZ;IAFhB;EADb,gBAME,iCAAC,qBAAD,qBACE,iCAAC,YAAD;IACE,IAAI,EAAC,OADP;IAEE,IAAI,EAAC,OAFP;IAGE,OAAO,EAAE,iBAACP,CAAD,EAAO;MACdZ,iBAAiB,CAAC,IAAD,CAAjB;MACAY,CAAC,CAACQ,eAAF;IACD;EANH,gBAQE,iCAAC,aAAD,OARF,CADF,CANF,CAjBJ,CAXF,CADF;AAoDD,CAhGiB,CAApB;AAmGArC,WAAW,CAACsC,WAAZ,GAA0B,aAA1B;eAEetC,W"}
1
+ {"version":3,"file":"index.js","names":["overlayHasImageStyles","p","hasImage","css","theme","imageUploadOverlayOpacity","overlayHasImageHoverStyles","isDragActive","Overlay","styled","omitEmotionProps","resetFocusStyles","imageUploadOverlayPadding","transitionStyles","contentIsDragActiveStyles","Content","PictureIcon","Picture","Title","div","DeleteButtonContainer","hoverStyles","clr","imageUploadNoImageHoverColorBorder","notHasImageStyles","imageUploadNoImageColorBg","imageUploadNoImageColorBorder","focusStyles","isDragActiveStyles","LocalImage","img","RemoteImage","Image","Container","imageUploadMaxWidth","imageUploadMinHeight","borderRadius","colorText","sizeStyles","ImageUpload","forwardRef","ref","url","accept","locale","defaultLocale","value","defaultValue","onChange","size","rest","touchDevice","useMemo","isTouchDevice","useForwardedState","forwardedValue","setForwardedValue","useDropzone","multiple","onDrop","file","getRootProps","getInputProps","source","URL","createObjectURL","renderImage","useCallback","e","preventDefault","onKeyDown","key","touchTitle","dropTitle","buttonGhostColorText","buttonGhostColorBgHover","stopPropagation","displayName"],"sources":["../../../src/ImageUpload/index.tsx"],"sourcesContent":["import { css } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { Button, Image } from '@os-design/core';\nimport { Delete, Picture } from '@os-design/icons';\nimport {\n resetFocusStyles,\n sizeStyles,\n transitionStyles,\n WithSize,\n} from '@os-design/styles';\nimport { clr, ThemeOverrider } from '@os-design/theming';\nimport {\n isTouchDevice,\n omitEmotionProps,\n useForwardedState,\n} from '@os-design/utils';\nimport React, { forwardRef, useCallback, useMemo } from 'react';\nimport { Accept, useDropzone } from 'react-dropzone';\nimport defaultLocale, { ImageUploadLocale } from './utils/defaultLocale';\n\ntype JsxDivProps = Omit<\n JSX.IntrinsicElements['div'],\n 'defaultValue' | 'onChange' | 'ref'\n>;\nexport interface ImageUploadProps extends JsxDivProps, WithSize {\n /**\n * The url of the image.\n * @default undefined\n */\n url?: string;\n /**\n * Allowed image formats.\n * @default undefined\n */\n accept?: Accept;\n /**\n * The locale of the component.\n * @default undefined\n */\n locale?: ImageUploadLocale;\n /**\n * The selected local file, or null if the image is marked as deleted.\n * @default undefined\n */\n value?: File | null;\n /**\n * The default value.\n * @default undefined\n */\n defaultValue?: File | null;\n /**\n * The change event handler.\n * @default undefined\n */\n onChange?: (value: File | null) => void;\n}\n\nconst overlayHasImageStyles = (p) =>\n p.hasImage &&\n css`\n background-color: hsla(0, 0%, 0%, ${p.theme.imageUploadOverlayOpacity});\n color: hsl(0, 0%, 100%);\n `;\n\nconst overlayHasImageHoverStyles = (p) =>\n p.hasImage &&\n !p.isDragActive &&\n css`\n @media (hover: hover) {\n opacity: 0;\n\n &:hover {\n opacity: 1;\n }\n }\n `;\n\ninterface OverlayProps {\n isDragActive: boolean;\n hasImage: boolean;\n}\nexport const Overlay = styled(\n 'div',\n omitEmotionProps('isDragActive', 'hasImage')\n)<OverlayProps>`\n ${resetFocusStyles};\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n\n text-align: center;\n padding: ${(p) => p.theme.imageUploadOverlayPadding}em;\n\n ${overlayHasImageStyles};\n ${overlayHasImageHoverStyles}\n ${transitionStyles('opacity')};\n`;\n\nconst contentIsDragActiveStyles = (p) =>\n p.isDragActive &&\n css`\n transform: scale(0.92);\n `;\n\ntype ContentProps = Pick<OverlayProps, 'isDragActive'>;\nconst Content = styled('div', omitEmotionProps('isDragActive'))<ContentProps>`\n ${contentIsDragActiveStyles};\n ${transitionStyles('transform')};\n`;\n\nconst PictureIcon = styled(Picture)`\n opacity: 0.8;\n font-size: 2.5em;\n`;\n\nconst Title = styled.div`\n opacity: 0.8;\n`;\n\nconst DeleteButtonContainer = styled.div`\n position: absolute;\n top: 0.5em;\n right: 0.5em;\n`;\n\nconst hoverStyles = (p) => css`\n border-color: ${clr(p.theme.imageUploadNoImageHoverColorBorder)};\n`;\n\nconst notHasImageStyles = (p) =>\n !p.hasImage &&\n css`\n background-color: ${clr(p.theme.imageUploadNoImageColorBg)};\n border: 2px dashed ${clr(p.theme.imageUploadNoImageColorBorder)};\n\n @media (hover: hover) {\n &:hover {\n ${hoverStyles(p)};\n }\n }\n `;\n\nconst focusStyles = (p) => css`\n &:focus-within {\n & > div {\n opacity: 1;\n }\n ${hoverStyles(p)};\n }\n`;\n\nconst isDragActiveStyles = (p) =>\n p.isDragActive &&\n css`\n ${hoverStyles(p)};\n `;\n\nconst LocalImage = styled.img`\n width: 100%;\n vertical-align: top;\n`;\n\nconst RemoteImage = styled(Image)`\n vertical-align: top;\n`;\n\ninterface ContainerProps extends WithSize {\n isDragActive: boolean;\n hasImage: boolean;\n}\n\nconst Container = styled(\n 'div',\n omitEmotionProps('isDragActive', 'hasImage', 'size')\n)<ContainerProps>`\n position: relative;\n cursor: pointer;\n overflow: hidden;\n box-sizing: border-box;\n\n max-width: ${(p) => p.theme.imageUploadMaxWidth}em;\n min-height: ${(p) => p.theme.imageUploadMinHeight}em;\n border-radius: ${(p) => p.theme.borderRadius}em;\n color: ${(p) => clr(p.theme.colorText)};\n\n ${notHasImageStyles};\n ${focusStyles};\n ${isDragActiveStyles};\n ${sizeStyles};\n ${transitionStyles('border')};\n`;\n\n/**\n * The component to upload an image.\n */\nconst ImageUpload = forwardRef<HTMLDivElement, ImageUploadProps>(\n (\n {\n url,\n accept = { 'image/*': ['.jpeg', '.png', '.webp'] },\n locale = defaultLocale,\n value,\n defaultValue,\n onChange,\n size,\n ...rest\n },\n ref\n ) => {\n const touchDevice = useMemo(() => isTouchDevice(), []);\n const [forwardedValue, setForwardedValue] = useForwardedState({\n value,\n defaultValue,\n onChange,\n });\n\n const { getRootProps, getInputProps, isDragActive } = useDropzone({\n accept,\n multiple: false,\n onDrop: ([file]) => setForwardedValue(file),\n });\n\n const source = useMemo(() => {\n if (forwardedValue === null) return null; // If the user select an image\n if (forwardedValue) return URL.createObjectURL(forwardedValue); // If the image already exists\n if (url) return url;\n return null;\n }, [forwardedValue, url]);\n\n const hasImage = useMemo(() => !!source, [source]);\n\n const renderImage = useCallback(() => {\n if (!source) return null;\n if (typeof forwardedValue === 'object' && forwardedValue !== null) {\n return <LocalImage src={source} />;\n }\n return <RemoteImage url={source} />;\n }, [forwardedValue, source]);\n\n return (\n <Container\n isDragActive={isDragActive}\n hasImage={hasImage}\n size={size}\n onMouseDown={(e) => e.preventDefault()}\n {...rest}\n ref={ref}\n >\n <input {...getInputProps()} />\n {renderImage()}\n\n <Overlay\n isDragActive={isDragActive}\n hasImage={hasImage}\n {\n ...getRootProps({\n onKeyDown: (e) => {\n if (e.key === 'Backspace') setForwardedValue(null);\n },\n } as any) // eslint-disable-line @typescript-eslint/no-explicit-any\n }\n >\n <Content isDragActive={isDragActive}>\n <PictureIcon />\n <Title>{touchDevice ? locale.touchTitle : locale.dropTitle}</Title>\n </Content>\n\n {hasImage && (\n <ThemeOverrider\n overrides={{\n buttonGhostColorText: [0, 0, 100],\n buttonGhostColorBgHover: [0, 0, 100, 0.1],\n }}\n >\n <DeleteButtonContainer>\n <Button\n type='ghost'\n wide='never'\n onClick={(e) => {\n setForwardedValue(null);\n e.stopPropagation();\n }}\n >\n <Delete />\n </Button>\n </DeleteButtonContainer>\n </ThemeOverrider>\n )}\n </Overlay>\n </Container>\n );\n }\n);\n\nImageUpload.displayName = 'ImageUpload';\n\nexport default ImageUpload;\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AAMA;AACA;AAKA;AACA;AACA;AAAyE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuCzE,IAAMA,qBAAqB,GAAG,SAAxBA,qBAAqB,CAAIC,CAAC;EAAA,OAC9BA,CAAC,CAACC,QAAQ,QACVC,UAAG,uJACmCF,CAAC,CAACG,KAAK,CAACC,yBAAyB,CAEtE;AAAA;AAEH,IAAMC,0BAA0B,GAAG,SAA7BA,0BAA0B,CAAIL,CAAC;EAAA,OACnCA,CAAC,CAACC,QAAQ,IACV,CAACD,CAAC,CAACM,YAAY,QACfJ,UAAG,oLAQF;AAAA;AAMI,IAAMK,OAAO,GAAG,IAAAC,kBAAM,EAC3B,KAAK,EACL,IAAAC,uBAAgB,EAAC,cAAc,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,eAEzBtC,WAAW;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"defaultLocale.js","names":["defaultLocale","touchTitle","dropTitle"],"sources":["../../../../src/ImageUpload/utils/defaultLocale.ts"],"sourcesContent":["export interface ImageUploadLocale {\n touchTitle: string;\n dropTitle: string;\n}\n\nconst defaultLocale: ImageUploadLocale = {\n touchTitle: 'Click here to choose an image',\n dropTitle: 'Drop an image here or click to choose it',\n};\n\nexport default defaultLocale;\n"],"mappings":";;;;;;AAKA,IAAMA,aAAgC,GAAG;EACvCC,UAAU,EAAE,+BAD2B;EAEvCC,SAAS,EAAE;AAF4B,CAAzC;eAKeF,a"}
1
+ {"version":3,"file":"defaultLocale.js","names":["defaultLocale","touchTitle","dropTitle"],"sources":["../../../../src/ImageUpload/utils/defaultLocale.ts"],"sourcesContent":["export interface ImageUploadLocale {\n touchTitle: string;\n dropTitle: string;\n}\n\nconst defaultLocale: ImageUploadLocale = {\n touchTitle: 'Click here to choose an image',\n dropTitle: 'Drop an image here or click to choose it',\n};\n\nexport default defaultLocale;\n"],"mappings":";;;;;;AAKA,IAAMA,aAAgC,GAAG;EACvCC,UAAU,EAAE,+BAA+B;EAC3CC,SAAS,EAAE;AACb,CAAC;AAAC,eAEaF,aAAa;AAAA"}
@@ -1,44 +1,31 @@
1
1
  "use strict";
2
2
 
3
3
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports["default"] = void 0;
9
-
10
8
  var _styled = _interopRequireDefault(require("@emotion/styled"));
11
-
12
9
  var _react = _interopRequireWildcard(require("react"));
13
-
14
10
  var _styles = require("@os-design/styles");
15
-
16
11
  var _utils = require("@os-design/utils");
17
-
18
12
  var _core = require("@os-design/core");
19
-
20
13
  var _templateObject;
21
-
22
14
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
-
24
15
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
-
26
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
27
-
28
17
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
29
-
30
18
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
31
-
32
19
  var StyledImageUploadSkeleton = (0, _styled["default"])(_core.Skeleton, (0, _utils.omitEmotionProps)('size'))(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n max-width: ", "em;\n height: ", "em;\n ", ";\n"])), function (p) {
33
20
  return p.theme.imageUploadMaxWidth;
34
21
  }, function (p) {
35
22
  return p.theme.imageUploadMinHeight;
36
23
  }, _styles.sizeStyles);
24
+
37
25
  /**
38
26
  * Provides an image upload placeholder while a user waits for
39
27
  * the content to load.
40
28
  */
41
-
42
29
  var ImageUploadSkeleton = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
43
30
  return /*#__PURE__*/_react["default"].createElement(StyledImageUploadSkeleton, _extends({
44
31
  width: "100%"
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["StyledImageUploadSkeleton","styled","Skeleton","omitEmotionProps","p","theme","imageUploadMaxWidth","imageUploadMinHeight","sizeStyles","ImageUploadSkeleton","forwardRef","props","ref","displayName"],"sources":["../../../src/ImageUploadSkeleton/index.tsx"],"sourcesContent":["import styled from '@emotion/styled';\nimport React, { forwardRef } from 'react';\nimport { sizeStyles, WithSize } from '@os-design/styles';\nimport { omitEmotionProps } from '@os-design/utils';\nimport { Skeleton, SkeletonProps } from '@os-design/core';\n\nexport type ImageUploadSkeletonProps = Omit<SkeletonProps, 'width'> & WithSize;\n\nconst StyledImageUploadSkeleton = styled(\n Skeleton,\n omitEmotionProps('size')\n)<WithSize>`\n max-width: ${(p) => p.theme.imageUploadMaxWidth}em;\n height: ${(p) => p.theme.imageUploadMinHeight}em;\n ${sizeStyles};\n`;\n\n/**\n * Provides an image upload placeholder while a user waits for\n * the content to load.\n */\nconst ImageUploadSkeleton = forwardRef<\n HTMLDivElement,\n ImageUploadSkeletonProps\n>((props, ref) => (\n <StyledImageUploadSkeleton width='100%' {...props} ref={ref} />\n));\n\nImageUploadSkeleton.displayName = 'ImageUploadSkeleton';\n\nexport default ImageUploadSkeleton;\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAIA,IAAMA,yBAAyB,GAAG,IAAAC,kBAAA,EAChCC,cADgC,EAEhC,IAAAC,uBAAA,EAAiB,MAAjB,CAFgC,CAAH,0HAIhB,UAACC,CAAD;EAAA,OAAOA,CAAC,CAACC,KAAF,CAAQC,mBAAf;AAAA,CAJgB,EAKnB,UAACF,CAAD;EAAA,OAAOA,CAAC,CAACC,KAAF,CAAQE,oBAAf;AAAA,CALmB,EAM3BC,kBAN2B,CAA/B;AASA;AACA;AACA;AACA;;AACA,IAAMC,mBAAmB,gBAAG,IAAAC,iBAAA,EAG1B,UAACC,KAAD,EAAQC,GAAR;EAAA,oBACA,gCAAC,yBAAD;IAA2B,KAAK,EAAC;EAAjC,GAA4CD,KAA5C;IAAmD,GAAG,EAAEC;EAAxD,GADA;AAAA,CAH0B,CAA5B;AAOAH,mBAAmB,CAACI,WAApB,GAAkC,qBAAlC;eAEeJ,mB"}
1
+ {"version":3,"file":"index.js","names":["StyledImageUploadSkeleton","styled","Skeleton","omitEmotionProps","p","theme","imageUploadMaxWidth","imageUploadMinHeight","sizeStyles","ImageUploadSkeleton","forwardRef","props","ref","displayName"],"sources":["../../../src/ImageUploadSkeleton/index.tsx"],"sourcesContent":["import styled from '@emotion/styled';\nimport React, { forwardRef } from 'react';\nimport { sizeStyles, WithSize } from '@os-design/styles';\nimport { omitEmotionProps } from '@os-design/utils';\nimport { Skeleton, SkeletonProps } from '@os-design/core';\n\nexport type ImageUploadSkeletonProps = Omit<SkeletonProps, 'width'> & WithSize;\n\nconst StyledImageUploadSkeleton = styled(\n Skeleton,\n omitEmotionProps('size')\n)<WithSize>`\n max-width: ${(p) => p.theme.imageUploadMaxWidth}em;\n height: ${(p) => p.theme.imageUploadMinHeight}em;\n ${sizeStyles};\n`;\n\n/**\n * Provides an image upload placeholder while a user waits for\n * the content to load.\n */\nconst ImageUploadSkeleton = forwardRef<\n HTMLDivElement,\n ImageUploadSkeletonProps\n>((props, ref) => (\n <StyledImageUploadSkeleton width='100%' {...props} ref={ref} />\n));\n\nImageUploadSkeleton.displayName = 'ImageUploadSkeleton';\n\nexport default ImageUploadSkeleton;\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AAA0D;AAAA;AAAA;AAAA;AAAA;AAAA;AAI1D,IAAMA,yBAAyB,GAAG,IAAAC,kBAAM,EACtCC,cAAQ,EACR,IAAAC,uBAAgB,EAAC,MAAM,CAAC,CACzB,0HACc,UAACC,CAAC;EAAA,OAAKA,CAAC,CAACC,KAAK,CAACC,mBAAmB;AAAA,GACrC,UAACF,CAAC;EAAA,OAAKA,CAAC,CAACC,KAAK,CAACE,oBAAoB;AAAA,GAC3CC,kBAAU,CACb;;AAED;AACA;AACA;AACA;AACA,IAAMC,mBAAmB,gBAAG,IAAAC,iBAAU,EAGpC,UAACC,KAAK,EAAEC,GAAG;EAAA,oBACX,gCAAC,yBAAyB;IAAC,KAAK,EAAC;EAAM,GAAKD,KAAK;IAAE,GAAG,EAAEC;EAAI,GAAG;AAAA,CAChE,CAAC;AAEFH,mBAAmB,CAACI,WAAW,GAAG,qBAAqB;AAAC,eAEzCJ,mBAAmB;AAAA"}
package/dist/cjs/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -21,9 +20,7 @@ Object.defineProperty(exports, "ImageUploadSkeleton", {
21
20
  return _ImageUploadSkeleton["default"];
22
21
  }
23
22
  });
24
-
25
23
  var _ImageUpload = _interopRequireWildcard(require("./ImageUpload"));
26
-
27
24
  Object.keys(_ImageUpload).forEach(function (key) {
28
25
  if (key === "default" || key === "__esModule") return;
29
26
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -35,9 +32,7 @@ Object.keys(_ImageUpload).forEach(function (key) {
35
32
  }
36
33
  });
37
34
  });
38
-
39
35
  var _ImageUploadSkeleton = _interopRequireWildcard(require("./ImageUploadSkeleton"));
40
-
41
36
  Object.keys(_ImageUploadSkeleton).forEach(function (key) {
42
37
  if (key === "default" || key === "__esModule") return;
43
38
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -49,8 +44,6 @@ Object.keys(_ImageUploadSkeleton).forEach(function (key) {
49
44
  }
50
45
  });
51
46
  });
52
-
53
47
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
54
-
55
48
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
56
49
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export * from './ImageUpload';\nexport { default as ImageUpload } from './ImageUpload';\nexport * from './ImageUploadSkeleton';\nexport { default as ImageUploadSkeleton } from './ImageUploadSkeleton';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export * from './ImageUpload';\nexport { default as ImageUpload } from './ImageUpload';\nexport * from './ImageUploadSkeleton';\nexport { default as ImageUploadSkeleton } from './ImageUploadSkeleton';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAEA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAAsC;AAAA"}
@@ -1,5 +1,4 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
2
  import { css } from '@emotion/react';
4
3
  import styled from '@emotion/styled';
5
4
  import { Button, Image } from '@os-design/core';
@@ -10,12 +9,10 @@ import { isTouchDevice, omitEmotionProps, useForwardedState } from '@os-design/u
10
9
  import React, { forwardRef, useCallback, useMemo } from 'react';
11
10
  import { useDropzone } from 'react-dropzone';
12
11
  import defaultLocale from './utils/defaultLocale';
13
-
14
12
  const overlayHasImageStyles = p => p.hasImage && css`
15
13
  background-color: hsla(0, 0%, 0%, ${p.theme.imageUploadOverlayOpacity});
16
14
  color: hsl(0, 0%, 100%);
17
15
  `;
18
-
19
16
  const overlayHasImageHoverStyles = p => p.hasImage && !p.isDragActive && css`
20
17
  @media (hover: hover) {
21
18
  opacity: 0;
@@ -25,7 +22,6 @@ const overlayHasImageHoverStyles = p => p.hasImage && !p.isDragActive && css`
25
22
  }
26
23
  }
27
24
  `;
28
-
29
25
  export const Overlay = styled('div', omitEmotionProps('isDragActive', 'hasImage'))`
30
26
  ${resetFocusStyles};
31
27
  position: absolute;
@@ -46,11 +42,9 @@ export const Overlay = styled('div', omitEmotionProps('isDragActive', 'hasImage'
46
42
  ${overlayHasImageHoverStyles}
47
43
  ${transitionStyles('opacity')};
48
44
  `;
49
-
50
45
  const contentIsDragActiveStyles = p => p.isDragActive && css`
51
46
  transform: scale(0.92);
52
47
  `;
53
-
54
48
  const Content = styled('div', omitEmotionProps('isDragActive'))`
55
49
  ${contentIsDragActiveStyles};
56
50
  ${transitionStyles('transform')};
@@ -67,11 +61,9 @@ const DeleteButtonContainer = styled.div`
67
61
  top: 0.5em;
68
62
  right: 0.5em;
69
63
  `;
70
-
71
64
  const hoverStyles = p => css`
72
65
  border-color: ${clr(p.theme.imageUploadNoImageHoverColorBorder)};
73
66
  `;
74
-
75
67
  const notHasImageStyles = p => !p.hasImage && css`
76
68
  background-color: ${clr(p.theme.imageUploadNoImageColorBg)};
77
69
  border: 2px dashed ${clr(p.theme.imageUploadNoImageColorBorder)};
@@ -82,7 +74,6 @@ const notHasImageStyles = p => !p.hasImage && css`
82
74
  }
83
75
  }
84
76
  `;
85
-
86
77
  const focusStyles = p => css`
87
78
  &:focus-within {
88
79
  & > div {
@@ -91,11 +82,9 @@ const focusStyles = p => css`
91
82
  ${hoverStyles(p)};
92
83
  }
93
84
  `;
94
-
95
85
  const isDragActiveStyles = p => p.isDragActive && css`
96
86
  ${hoverStyles(p)};
97
87
  `;
98
-
99
88
  const LocalImage = styled.img`
100
89
  width: 100%;
101
90
  vertical-align: top;
@@ -120,10 +109,10 @@ const Container = styled('div', omitEmotionProps('isDragActive', 'hasImage', 'si
120
109
  ${sizeStyles};
121
110
  ${transitionStyles('border')};
122
111
  `;
112
+
123
113
  /**
124
114
  * The component to upload an image.
125
115
  */
126
-
127
116
  const ImageUpload = /*#__PURE__*/forwardRef(({
128
117
  url,
129
118
  accept = {
@@ -153,22 +142,18 @@ const ImageUpload = /*#__PURE__*/forwardRef(({
153
142
  });
154
143
  const source = useMemo(() => {
155
144
  if (forwardedValue === null) return null; // If the user select an image
156
-
157
145
  if (forwardedValue) return URL.createObjectURL(forwardedValue); // If the image already exists
158
-
159
146
  if (url) return url;
160
147
  return null;
161
148
  }, [forwardedValue, url]);
162
149
  const hasImage = useMemo(() => !!source, [source]);
163
150
  const renderImage = useCallback(() => {
164
151
  if (!source) return null;
165
-
166
152
  if (typeof forwardedValue === 'object' && forwardedValue !== null) {
167
153
  return /*#__PURE__*/React.createElement(LocalImage, {
168
154
  src: source
169
155
  });
170
156
  }
171
-
172
157
  return /*#__PURE__*/React.createElement(RemoteImage, {
173
158
  url: source
174
159
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["css","styled","Button","Image","Delete","Picture","resetFocusStyles","sizeStyles","transitionStyles","clr","ThemeOverrider","isTouchDevice","omitEmotionProps","useForwardedState","React","forwardRef","useCallback","useMemo","useDropzone","defaultLocale","overlayHasImageStyles","p","hasImage","theme","imageUploadOverlayOpacity","overlayHasImageHoverStyles","isDragActive","Overlay","imageUploadOverlayPadding","contentIsDragActiveStyles","Content","PictureIcon","Title","div","DeleteButtonContainer","hoverStyles","imageUploadNoImageHoverColorBorder","notHasImageStyles","imageUploadNoImageColorBg","imageUploadNoImageColorBorder","focusStyles","isDragActiveStyles","LocalImage","img","RemoteImage","Container","imageUploadMaxWidth","imageUploadMinHeight","borderRadius","colorText","ImageUpload","url","accept","locale","value","defaultValue","onChange","size","rest","ref","touchDevice","forwardedValue","setForwardedValue","getRootProps","getInputProps","multiple","onDrop","file","source","URL","createObjectURL","renderImage","e","preventDefault","onKeyDown","key","touchTitle","dropTitle","buttonGhostColorText","buttonGhostColorBgHover","stopPropagation","displayName"],"sources":["../../../src/ImageUpload/index.tsx"],"sourcesContent":["import { css } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { Button, Image } from '@os-design/core';\nimport { Delete, Picture } from '@os-design/icons';\nimport {\n resetFocusStyles,\n sizeStyles,\n transitionStyles,\n WithSize,\n} from '@os-design/styles';\nimport { clr, ThemeOverrider } from '@os-design/theming';\nimport {\n isTouchDevice,\n omitEmotionProps,\n useForwardedState,\n} from '@os-design/utils';\nimport React, { forwardRef, useCallback, useMemo } from 'react';\nimport { Accept, useDropzone } from 'react-dropzone';\nimport defaultLocale, { ImageUploadLocale } from './utils/defaultLocale';\n\ntype JsxDivProps = Omit<\n JSX.IntrinsicElements['div'],\n 'defaultValue' | 'onChange' | 'ref'\n>;\nexport interface ImageUploadProps extends JsxDivProps, WithSize {\n /**\n * The url of the image.\n * @default undefined\n */\n url?: string;\n /**\n * Allowed image formats.\n * @default undefined\n */\n accept?: Accept;\n /**\n * The locale of the component.\n * @default undefined\n */\n locale?: ImageUploadLocale;\n /**\n * The selected local file, or null if the image is marked as deleted.\n * @default undefined\n */\n value?: File | null;\n /**\n * The default value.\n * @default undefined\n */\n defaultValue?: File | null;\n /**\n * The change event handler.\n * @default undefined\n */\n onChange?: (value: File | null) => void;\n}\n\nconst overlayHasImageStyles = (p) =>\n p.hasImage &&\n css`\n background-color: hsla(0, 0%, 0%, ${p.theme.imageUploadOverlayOpacity});\n color: hsl(0, 0%, 100%);\n `;\n\nconst overlayHasImageHoverStyles = (p) =>\n p.hasImage &&\n !p.isDragActive &&\n css`\n @media (hover: hover) {\n opacity: 0;\n\n &:hover {\n opacity: 1;\n }\n }\n `;\n\ninterface OverlayProps {\n isDragActive: boolean;\n hasImage: boolean;\n}\nexport const Overlay = styled(\n 'div',\n omitEmotionProps('isDragActive', 'hasImage')\n)<OverlayProps>`\n ${resetFocusStyles};\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n\n text-align: center;\n padding: ${(p) => p.theme.imageUploadOverlayPadding}em;\n\n ${overlayHasImageStyles};\n ${overlayHasImageHoverStyles}\n ${transitionStyles('opacity')};\n`;\n\nconst contentIsDragActiveStyles = (p) =>\n p.isDragActive &&\n css`\n transform: scale(0.92);\n `;\n\ntype ContentProps = Pick<OverlayProps, 'isDragActive'>;\nconst Content = styled('div', omitEmotionProps('isDragActive'))<ContentProps>`\n ${contentIsDragActiveStyles};\n ${transitionStyles('transform')};\n`;\n\nconst PictureIcon = styled(Picture)`\n opacity: 0.8;\n font-size: 2.5em;\n`;\n\nconst Title = styled.div`\n opacity: 0.8;\n`;\n\nconst DeleteButtonContainer = styled.div`\n position: absolute;\n top: 0.5em;\n right: 0.5em;\n`;\n\nconst hoverStyles = (p) => css`\n border-color: ${clr(p.theme.imageUploadNoImageHoverColorBorder)};\n`;\n\nconst notHasImageStyles = (p) =>\n !p.hasImage &&\n css`\n background-color: ${clr(p.theme.imageUploadNoImageColorBg)};\n border: 2px dashed ${clr(p.theme.imageUploadNoImageColorBorder)};\n\n @media (hover: hover) {\n &:hover {\n ${hoverStyles(p)};\n }\n }\n `;\n\nconst focusStyles = (p) => css`\n &:focus-within {\n & > div {\n opacity: 1;\n }\n ${hoverStyles(p)};\n }\n`;\n\nconst isDragActiveStyles = (p) =>\n p.isDragActive &&\n css`\n ${hoverStyles(p)};\n `;\n\nconst LocalImage = styled.img`\n width: 100%;\n vertical-align: top;\n`;\n\nconst RemoteImage = styled(Image)`\n vertical-align: top;\n`;\n\ninterface ContainerProps extends WithSize {\n isDragActive: boolean;\n hasImage: boolean;\n}\n\nconst Container = styled(\n 'div',\n omitEmotionProps('isDragActive', 'hasImage', 'size')\n)<ContainerProps>`\n position: relative;\n cursor: pointer;\n overflow: hidden;\n box-sizing: border-box;\n\n max-width: ${(p) => p.theme.imageUploadMaxWidth}em;\n min-height: ${(p) => p.theme.imageUploadMinHeight}em;\n border-radius: ${(p) => p.theme.borderRadius}em;\n color: ${(p) => clr(p.theme.colorText)};\n\n ${notHasImageStyles};\n ${focusStyles};\n ${isDragActiveStyles};\n ${sizeStyles};\n ${transitionStyles('border')};\n`;\n\n/**\n * The component to upload an image.\n */\nconst ImageUpload = forwardRef<HTMLDivElement, ImageUploadProps>(\n (\n {\n url,\n accept = { 'image/*': ['.jpeg', '.png', '.webp'] },\n locale = defaultLocale,\n value,\n defaultValue,\n onChange,\n size,\n ...rest\n },\n ref\n ) => {\n const touchDevice = useMemo(() => isTouchDevice(), []);\n const [forwardedValue, setForwardedValue] = useForwardedState({\n value,\n defaultValue,\n onChange,\n });\n\n const { getRootProps, getInputProps, isDragActive } = useDropzone({\n accept,\n multiple: false,\n onDrop: ([file]) => setForwardedValue(file),\n });\n\n const source = useMemo(() => {\n if (forwardedValue === null) return null; // If the user select an image\n if (forwardedValue) return URL.createObjectURL(forwardedValue); // If the image already exists\n if (url) return url;\n return null;\n }, [forwardedValue, url]);\n\n const hasImage = useMemo(() => !!source, [source]);\n\n const renderImage = useCallback(() => {\n if (!source) return null;\n if (typeof forwardedValue === 'object' && forwardedValue !== null) {\n return <LocalImage src={source} />;\n }\n return <RemoteImage url={source} />;\n }, [forwardedValue, source]);\n\n return (\n <Container\n isDragActive={isDragActive}\n hasImage={hasImage}\n size={size}\n onMouseDown={(e) => e.preventDefault()}\n {...rest}\n ref={ref}\n >\n <input {...getInputProps()} />\n {renderImage()}\n\n <Overlay\n isDragActive={isDragActive}\n hasImage={hasImage}\n {\n ...getRootProps({\n onKeyDown: (e) => {\n if (e.key === 'Backspace') setForwardedValue(null);\n },\n } as any) // eslint-disable-line @typescript-eslint/no-explicit-any\n }\n >\n <Content isDragActive={isDragActive}>\n <PictureIcon />\n <Title>{touchDevice ? locale.touchTitle : locale.dropTitle}</Title>\n </Content>\n\n {hasImage && (\n <ThemeOverrider\n overrides={{\n buttonGhostColorText: [0, 0, 100],\n buttonGhostColorBgHover: [0, 0, 100, 0.1],\n }}\n >\n <DeleteButtonContainer>\n <Button\n type='ghost'\n wide='never'\n onClick={(e) => {\n setForwardedValue(null);\n e.stopPropagation();\n }}\n >\n <Delete />\n </Button>\n </DeleteButtonContainer>\n </ThemeOverrider>\n )}\n </Overlay>\n </Container>\n );\n }\n);\n\nImageUpload.displayName = 'ImageUpload';\n\nexport default ImageUpload;\n"],"mappings":";;AAAA,SAASA,GAAT,QAAoB,gBAApB;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiB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kC,WAAW,GAAGP,MAAM,CAACuB,UAAV,GAAuBvB,MAAM,CAACwB,SAAjD,CAFF,CAXF,EAgBGvD,QAAQ,iBACP,oBAAC,cAAD;IACE,SAAS,EAAE;MACTwD,oBAAoB,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,GAAP,CADb;MAETC,uBAAuB,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,GAAP,EAAY,GAAZ;IAFhB;EADb,gBAME,oBAAC,qBAAD,qBACE,oBAAC,MAAD;IACE,IAAI,EAAC,OADP;IAEE,IAAI,EAAC,OAFP;IAGE,OAAO,EAAGP,CAAD,IAAO;MACdV,iBAAiB,CAAC,IAAD,CAAjB;MACAU,CAAC,CAACQ,eAAF;IACD;EANH,gBAQE,oBAAC,MAAD,OARF,CADF,CANF,CAjBJ,CAXF,CADF;AAoDD,CAhG2B,CAA9B;AAmGA9B,WAAW,CAAC+B,WAAZ,GAA0B,aAA1B;AAEA,eAAe/B,WAAf"}
1
+ {"version":3,"file":"index.js","names":["css","styled","Button","Image","Delete","Picture","resetFocusStyles","sizeStyles","transitionStyles","clr","ThemeOverrider","isTouchDevice","omitEmotionProps","useForwardedState","React","forwardRef","useCallback","useMemo","useDropzone","defaultLocale","overlayHasImageStyles","p","hasImage","theme","imageUploadOverlayOpacity","overlayHasImageHoverStyles","isDragActive","Overlay","imageUploadOverlayPadding","contentIsDragActiveStyles","Content","PictureIcon","Title","div","DeleteButtonContainer","hoverStyles","imageUploadNoImageHoverColorBorder","notHasImageStyles","imageUploadNoImageColorBg","imageUploadNoImageColorBorder","focusStyles","isDragActiveStyles","LocalImage","img","RemoteImage","Container","imageUploadMaxWidth","imageUploadMinHeight","borderRadius","colorText","ImageUpload","url","accept","locale","value","defaultValue","onChange","size","rest","ref","touchDevice","forwardedValue","setForwardedValue","getRootProps","getInputProps","multiple","onDrop","file","source","URL","createObjectURL","renderImage","e","preventDefault","onKeyDown","key","touchTitle","dropTitle","buttonGhostColorText","buttonGhostColorBgHover","stopPropagation","displayName"],"sources":["../../../src/ImageUpload/index.tsx"],"sourcesContent":["import { css } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { Button, Image } from '@os-design/core';\nimport { Delete, Picture } from '@os-design/icons';\nimport {\n resetFocusStyles,\n sizeStyles,\n transitionStyles,\n WithSize,\n} from '@os-design/styles';\nimport { clr, ThemeOverrider } from '@os-design/theming';\nimport {\n isTouchDevice,\n omitEmotionProps,\n useForwardedState,\n} from '@os-design/utils';\nimport React, { forwardRef, useCallback, useMemo } from 'react';\nimport { Accept, useDropzone } from 'react-dropzone';\nimport defaultLocale, { ImageUploadLocale } from './utils/defaultLocale';\n\ntype JsxDivProps = Omit<\n JSX.IntrinsicElements['div'],\n 'defaultValue' | 'onChange' | 'ref'\n>;\nexport interface ImageUploadProps extends JsxDivProps, WithSize {\n /**\n * The url of the image.\n * @default undefined\n */\n url?: string;\n /**\n * Allowed image formats.\n * @default undefined\n */\n accept?: Accept;\n /**\n * The locale of the component.\n * @default undefined\n */\n locale?: ImageUploadLocale;\n /**\n * The selected local file, or null if the image is marked as deleted.\n * @default undefined\n */\n value?: File | null;\n /**\n * The default value.\n * @default undefined\n */\n defaultValue?: File | null;\n /**\n * The change event handler.\n * @default undefined\n */\n onChange?: (value: File | null) => void;\n}\n\nconst overlayHasImageStyles = (p) =>\n p.hasImage &&\n css`\n background-color: hsla(0, 0%, 0%, ${p.theme.imageUploadOverlayOpacity});\n color: hsl(0, 0%, 100%);\n `;\n\nconst overlayHasImageHoverStyles = (p) =>\n p.hasImage &&\n !p.isDragActive &&\n css`\n @media (hover: hover) {\n opacity: 0;\n\n &:hover {\n opacity: 1;\n }\n }\n `;\n\ninterface OverlayProps {\n isDragActive: boolean;\n hasImage: boolean;\n}\nexport const Overlay = styled(\n 'div',\n omitEmotionProps('isDragActive', 'hasImage')\n)<OverlayProps>`\n ${resetFocusStyles};\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n\n text-align: center;\n padding: ${(p) => p.theme.imageUploadOverlayPadding}em;\n\n ${overlayHasImageStyles};\n ${overlayHasImageHoverStyles}\n ${transitionStyles('opacity')};\n`;\n\nconst contentIsDragActiveStyles = (p) =>\n p.isDragActive &&\n css`\n transform: scale(0.92);\n `;\n\ntype ContentProps = Pick<OverlayProps, 'isDragActive'>;\nconst Content = styled('div', omitEmotionProps('isDragActive'))<ContentProps>`\n ${contentIsDragActiveStyles};\n ${transitionStyles('transform')};\n`;\n\nconst PictureIcon = styled(Picture)`\n opacity: 0.8;\n font-size: 2.5em;\n`;\n\nconst Title = styled.div`\n opacity: 0.8;\n`;\n\nconst DeleteButtonContainer = styled.div`\n position: absolute;\n top: 0.5em;\n right: 0.5em;\n`;\n\nconst hoverStyles = (p) => css`\n border-color: ${clr(p.theme.imageUploadNoImageHoverColorBorder)};\n`;\n\nconst notHasImageStyles = (p) =>\n !p.hasImage &&\n css`\n background-color: ${clr(p.theme.imageUploadNoImageColorBg)};\n border: 2px dashed ${clr(p.theme.imageUploadNoImageColorBorder)};\n\n @media (hover: hover) {\n &:hover {\n ${hoverStyles(p)};\n }\n }\n `;\n\nconst focusStyles = (p) => css`\n &:focus-within {\n & > div {\n opacity: 1;\n }\n ${hoverStyles(p)};\n }\n`;\n\nconst isDragActiveStyles = (p) =>\n p.isDragActive &&\n css`\n ${hoverStyles(p)};\n `;\n\nconst LocalImage = styled.img`\n width: 100%;\n vertical-align: top;\n`;\n\nconst RemoteImage = styled(Image)`\n vertical-align: top;\n`;\n\ninterface ContainerProps extends WithSize {\n isDragActive: boolean;\n hasImage: boolean;\n}\n\nconst Container = styled(\n 'div',\n omitEmotionProps('isDragActive', 'hasImage', 'size')\n)<ContainerProps>`\n position: relative;\n cursor: pointer;\n overflow: hidden;\n box-sizing: border-box;\n\n max-width: ${(p) => p.theme.imageUploadMaxWidth}em;\n min-height: ${(p) => p.theme.imageUploadMinHeight}em;\n border-radius: ${(p) => p.theme.borderRadius}em;\n color: ${(p) => clr(p.theme.colorText)};\n\n ${notHasImageStyles};\n ${focusStyles};\n ${isDragActiveStyles};\n ${sizeStyles};\n ${transitionStyles('border')};\n`;\n\n/**\n * The component to upload an image.\n */\nconst ImageUpload = forwardRef<HTMLDivElement, ImageUploadProps>(\n (\n {\n url,\n accept = { 'image/*': ['.jpeg', '.png', '.webp'] },\n locale = defaultLocale,\n value,\n defaultValue,\n onChange,\n size,\n ...rest\n },\n ref\n ) => {\n const touchDevice = useMemo(() => isTouchDevice(), []);\n const [forwardedValue, setForwardedValue] = useForwardedState({\n value,\n defaultValue,\n onChange,\n });\n\n const { getRootProps, getInputProps, isDragActive } = useDropzone({\n accept,\n multiple: false,\n onDrop: ([file]) => setForwardedValue(file),\n });\n\n const source = useMemo(() => {\n if (forwardedValue === null) return null; // If the user select an image\n if (forwardedValue) return URL.createObjectURL(forwardedValue); // If the image already exists\n if (url) return url;\n return null;\n }, [forwardedValue, url]);\n\n const hasImage = useMemo(() => !!source, [source]);\n\n const renderImage = useCallback(() => {\n if (!source) return null;\n if (typeof forwardedValue === 'object' && forwardedValue !== null) {\n return <LocalImage src={source} />;\n }\n return <RemoteImage url={source} />;\n }, [forwardedValue, source]);\n\n return (\n <Container\n isDragActive={isDragActive}\n hasImage={hasImage}\n size={size}\n onMouseDown={(e) => e.preventDefault()}\n {...rest}\n ref={ref}\n >\n <input {...getInputProps()} />\n {renderImage()}\n\n <Overlay\n isDragActive={isDragActive}\n hasImage={hasImage}\n {\n ...getRootProps({\n onKeyDown: (e) => {\n if (e.key === 'Backspace') setForwardedValue(null);\n },\n } as any) // eslint-disable-line @typescript-eslint/no-explicit-any\n }\n >\n <Content isDragActive={isDragActive}>\n <PictureIcon />\n <Title>{touchDevice ? locale.touchTitle : locale.dropTitle}</Title>\n </Content>\n\n {hasImage && (\n <ThemeOverrider\n overrides={{\n buttonGhostColorText: [0, 0, 100],\n buttonGhostColorBgHover: [0, 0, 100, 0.1],\n }}\n >\n <DeleteButtonContainer>\n <Button\n type='ghost'\n wide='never'\n onClick={(e) => {\n setForwardedValue(null);\n e.stopPropagation();\n }}\n >\n <Delete />\n </Button>\n </DeleteButtonContainer>\n </ThemeOverrider>\n )}\n </Overlay>\n </Container>\n );\n }\n);\n\nImageUpload.displayName = 'ImageUpload';\n\nexport default ImageUpload;\n"],"mappings":";AAAA,SAASA,GAAG,QAAQ,gBAAgB;AACpC,OAAOC,MAAM,MAAM,iBAAiB;AACpC,SAASC,MAAM,EAAEC,KAAK,QAAQ,iBAAiB;AAC/C,SAASC,MAAM,EAAEC,OAAO,QAAQ,kBAAkB;AAClD,SACEC,gBAAgB,EAChBC,UAAU,EACVC,gBAAgB,QAEX,mBAAmB;AAC1B,SAASC,GAAG,EAAEC,cAAc,QAAQ,oBAAoB;AACxD,SACEC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,QACZ,kBAAkB;AACzB,OAAOC,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAC/D,SAAiBC,WAAW,QAAQ,gBAAgB;AACpD,OAAOC,aAAa,MAA6B,uBAAuB;AAuCxE,MAAMC,qBAAqB,GAAIC,CAAC,IAC9BA,CAAC,CAACC,QAAQ,IACVtB,GAAI;AACN,wCAAwCqB,CAAC,CAACE,KAAK,CAACC,yBAA0B;AAC1E;AACA,GAAG;AAEH,MAAMC,0BAA0B,GAAIJ,CAAC,IACnCA,CAAC,CAACC,QAAQ,IACV,CAACD,CAAC,CAACK,YAAY,IACf1B,GAAI;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AAMH,OAAO,MAAM2B,OAAO,GAAG1B,MAAM,CAC3B,KAAK,EACLW,gBAAgB,CAAC,cAAc,EAAE,UAAU,CAAC,CAC9B;AAChB,IAAIN,gBAAiB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAce,CAAC,IAAKA,CAAC,CAACE,KAAK,CAACK,yB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,EAAGF,CAAC,IAAK;MAChB,IAAIA,CAAC,CAACG,GAAG,KAAK,WAAW,EAAEb,iBAAiB,CAAC,IAAI,CAAC;IACpD;EACF,CAAC,CAAQ,CAAC;EAAA,gBAGZ,oBAAC,OAAO;IAAC,YAAY,EAAEpC;EAAa,gBAClC,oBAAC,WAAW,OAAG,eACf,oBAAC,KAAK,QAAEkC,WAAW,GAAGP,MAAM,CAACuB,UAAU,GAAGvB,MAAM,CAACwB,SAAS,CAAS,CAC3D,EAETvD,QAAQ,iBACP,oBAAC,cAAc;IACb,SAAS,EAAE;MACTwD,oBAAoB,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC;MACjCC,uBAAuB,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG;IAC1C;EAAE,gBAEF,oBAAC,qBAAqB,qBACpB,oBAAC,MAAM;IACL,IAAI,EAAC,OAAO;IACZ,IAAI,EAAC,OAAO;IACZ,OAAO,EAAGP,CAAC,IAAK;MACdV,iBAAiB,CAAC,IAAI,CAAC;MACvBU,CAAC,CAACQ,eAAe,EAAE;IACrB;EAAE,gBAEF,oBAAC,MAAM,OAAG,CACH,CACa,CAE3B,CACO,CACA;AAEhB,CAAC,CACF;AAED9B,WAAW,CAAC+B,WAAW,GAAG,aAAa;AAEvC,eAAe/B,WAAW"}
@@ -1 +1 @@
1
- {"version":3,"file":"defaultLocale.js","names":["defaultLocale","touchTitle","dropTitle"],"sources":["../../../../src/ImageUpload/utils/defaultLocale.ts"],"sourcesContent":["export interface ImageUploadLocale {\n touchTitle: string;\n dropTitle: string;\n}\n\nconst defaultLocale: ImageUploadLocale = {\n touchTitle: 'Click here to choose an image',\n dropTitle: 'Drop an image here or click to choose it',\n};\n\nexport default defaultLocale;\n"],"mappings":"AAKA,MAAMA,aAAgC,GAAG;EACvCC,UAAU,EAAE,+BAD2B;EAEvCC,SAAS,EAAE;AAF4B,CAAzC;AAKA,eAAeF,aAAf"}
1
+ {"version":3,"file":"defaultLocale.js","names":["defaultLocale","touchTitle","dropTitle"],"sources":["../../../../src/ImageUpload/utils/defaultLocale.ts"],"sourcesContent":["export interface ImageUploadLocale {\n touchTitle: string;\n dropTitle: string;\n}\n\nconst defaultLocale: ImageUploadLocale = {\n touchTitle: 'Click here to choose an image',\n dropTitle: 'Drop an image here or click to choose it',\n};\n\nexport default defaultLocale;\n"],"mappings":"AAKA,MAAMA,aAAgC,GAAG;EACvCC,UAAU,EAAE,+BAA+B;EAC3CC,SAAS,EAAE;AACb,CAAC;AAED,eAAeF,aAAa"}
@@ -1,5 +1,4 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
2
  import styled from '@emotion/styled';
4
3
  import React, { forwardRef } from 'react';
5
4
  import { sizeStyles } from '@os-design/styles';
@@ -10,11 +9,11 @@ const StyledImageUploadSkeleton = styled(Skeleton, omitEmotionProps('size'))`
10
9
  height: ${p => p.theme.imageUploadMinHeight}em;
11
10
  ${sizeStyles};
12
11
  `;
12
+
13
13
  /**
14
14
  * Provides an image upload placeholder while a user waits for
15
15
  * the content to load.
16
16
  */
17
-
18
17
  const ImageUploadSkeleton = /*#__PURE__*/forwardRef((props, ref) => /*#__PURE__*/React.createElement(StyledImageUploadSkeleton, _extends({
19
18
  width: "100%"
20
19
  }, props, {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["styled","React","forwardRef","sizeStyles","omitEmotionProps","Skeleton","StyledImageUploadSkeleton","p","theme","imageUploadMaxWidth","imageUploadMinHeight","ImageUploadSkeleton","props","ref","displayName"],"sources":["../../../src/ImageUploadSkeleton/index.tsx"],"sourcesContent":["import styled from '@emotion/styled';\nimport React, { forwardRef } from 'react';\nimport { sizeStyles, WithSize } from '@os-design/styles';\nimport { omitEmotionProps } from '@os-design/utils';\nimport { Skeleton, SkeletonProps } from '@os-design/core';\n\nexport type ImageUploadSkeletonProps = Omit<SkeletonProps, 'width'> & WithSize;\n\nconst StyledImageUploadSkeleton = styled(\n Skeleton,\n omitEmotionProps('size')\n)<WithSize>`\n max-width: ${(p) => p.theme.imageUploadMaxWidth}em;\n height: ${(p) => p.theme.imageUploadMinHeight}em;\n ${sizeStyles};\n`;\n\n/**\n * Provides an image upload placeholder while a user waits for\n * the content to load.\n */\nconst ImageUploadSkeleton = forwardRef<\n HTMLDivElement,\n ImageUploadSkeletonProps\n>((props, ref) => (\n <StyledImageUploadSkeleton width='100%' {...props} ref={ref} />\n));\n\nImageUploadSkeleton.displayName = 'ImageUploadSkeleton';\n\nexport default ImageUploadSkeleton;\n"],"mappings":";;AAAA,OAAOA,MAAP,MAAmB,iBAAnB;AACA,OAAOC,KAAP,IAAgBC,UAAhB,QAAkC,OAAlC;AACA,SAASC,UAAT,QAAqC,mBAArC;AACA,SAASC,gBAAT,QAAiC,kBAAjC;AACA,SAASC,QAAT,QAAwC,iBAAxC;AAIA,MAAMC,yBAAyB,GAAGN,MAAM,CACtCK,QADsC,EAEtCD,gBAAgB,CAAC,MAAD,CAFsB,CAG5B;AACZ,eAAgBG,CAAD,IAAOA,CAAC,CAACC,KAAF,CAAQC,mBAAoB;AAClD,YAAaF,CAAD,IAAOA,CAAC,CAACC,KAAF,CAAQE,oBAAqB;AAChD,IAAIP,UAAW;AACf,CAPA;AASA;AACA;AACA;AACA;;AACA,MAAMQ,mBAAmB,gBAAGT,UAAU,CAGpC,CAACU,KAAD,EAAQC,GAAR,kBACA,oBAAC,yBAAD;EAA2B,KAAK,EAAC;AAAjC,GAA4CD,KAA5C;EAAmD,GAAG,EAAEC;AAAxD,GAJoC,CAAtC;AAOAF,mBAAmB,CAACG,WAApB,GAAkC,qBAAlC;AAEA,eAAeH,mBAAf"}
1
+ {"version":3,"file":"index.js","names":["styled","React","forwardRef","sizeStyles","omitEmotionProps","Skeleton","StyledImageUploadSkeleton","p","theme","imageUploadMaxWidth","imageUploadMinHeight","ImageUploadSkeleton","props","ref","displayName"],"sources":["../../../src/ImageUploadSkeleton/index.tsx"],"sourcesContent":["import styled from '@emotion/styled';\nimport React, { forwardRef } from 'react';\nimport { sizeStyles, WithSize } from '@os-design/styles';\nimport { omitEmotionProps } from '@os-design/utils';\nimport { Skeleton, SkeletonProps } from '@os-design/core';\n\nexport type ImageUploadSkeletonProps = Omit<SkeletonProps, 'width'> & WithSize;\n\nconst StyledImageUploadSkeleton = styled(\n Skeleton,\n omitEmotionProps('size')\n)<WithSize>`\n max-width: ${(p) => p.theme.imageUploadMaxWidth}em;\n height: ${(p) => p.theme.imageUploadMinHeight}em;\n ${sizeStyles};\n`;\n\n/**\n * Provides an image upload placeholder while a user waits for\n * the content to load.\n */\nconst ImageUploadSkeleton = forwardRef<\n HTMLDivElement,\n ImageUploadSkeletonProps\n>((props, ref) => (\n <StyledImageUploadSkeleton width='100%' {...props} ref={ref} />\n));\n\nImageUploadSkeleton.displayName = 'ImageUploadSkeleton';\n\nexport default ImageUploadSkeleton;\n"],"mappings":";AAAA,OAAOA,MAAM,MAAM,iBAAiB;AACpC,OAAOC,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,UAAU,QAAkB,mBAAmB;AACxD,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,SAASC,QAAQ,QAAuB,iBAAiB;AAIzD,MAAMC,yBAAyB,GAAGN,MAAM,CACtCK,QAAQ,EACRD,gBAAgB,CAAC,MAAM,CAAC,CACd;AACZ,eAAgBG,CAAC,IAAKA,CAAC,CAACC,KAAK,CAACC,mBAAoB;AAClD,YAAaF,CAAC,IAAKA,CAAC,CAACC,KAAK,CAACE,oBAAqB;AAChD,IAAIP,UAAW;AACf,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMQ,mBAAmB,gBAAGT,UAAU,CAGpC,CAACU,KAAK,EAAEC,GAAG,kBACX,oBAAC,yBAAyB;EAAC,KAAK,EAAC;AAAM,GAAKD,KAAK;EAAE,GAAG,EAAEC;AAAI,GAC7D,CAAC;AAEFF,mBAAmB,CAACG,WAAW,GAAG,qBAAqB;AAEvD,eAAeH,mBAAmB"}
@@ -1 +1 @@
1
- {"version":3,"file":"emotion.d.js","names":[],"sources":["../../src/emotion.d.ts"],"sourcesContent":["import '@emotion/react';\nimport { Theme as BaseTheme } from '@os-design/theming';\n\ndeclare module '@emotion/react' {\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n export interface Theme extends BaseTheme {}\n}\n"],"mappings":"AAAA,OAAO,gBAAP"}
1
+ {"version":3,"file":"emotion.d.js","names":[],"sources":["../../src/emotion.d.ts"],"sourcesContent":["import '@emotion/react';\nimport { Theme as BaseTheme } from '@os-design/theming';\n\ndeclare module '@emotion/react' {\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n export interface Theme extends BaseTheme {}\n}\n"],"mappings":"AAAA,OAAO,gBAAgB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["default","ImageUpload","ImageUploadSkeleton"],"sources":["../../src/index.ts"],"sourcesContent":["export * from './ImageUpload';\nexport { default as ImageUpload } from './ImageUpload';\nexport * from './ImageUploadSkeleton';\nexport { default as ImageUploadSkeleton } from './ImageUploadSkeleton';\n"],"mappings":"AAAA,cAAc,eAAd;AACA,SAASA,OAAO,IAAIC,WAApB,QAAuC,eAAvC;AACA,cAAc,uBAAd;AACA,SAASD,OAAO,IAAIE,mBAApB,QAA+C,uBAA/C"}
1
+ {"version":3,"file":"index.js","names":["default","ImageUpload","ImageUploadSkeleton"],"sources":["../../src/index.ts"],"sourcesContent":["export * from './ImageUpload';\nexport { default as ImageUpload } from './ImageUpload';\nexport * from './ImageUploadSkeleton';\nexport { default as ImageUploadSkeleton } from './ImageUploadSkeleton';\n"],"mappings":"AAAA,cAAc,eAAe;AAC7B,SAASA,OAAO,IAAIC,WAAW,QAAQ,eAAe;AACtD,cAAc,uBAAuB;AACrC,SAASD,OAAO,IAAIE,mBAAmB,QAAQ,uBAAuB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@os-design/upload",
3
- "version": "1.0.159",
3
+ "version": "1.0.161",
4
4
  "license": "UNLICENSED",
5
5
  "repository": "git@gitlab.com:os-team/libs/os-design.git",
6
6
  "main": "dist/cjs/index.js",
@@ -29,7 +29,7 @@
29
29
  "access": "public"
30
30
  },
31
31
  "dependencies": {
32
- "@os-design/core": "^1.0.156",
32
+ "@os-design/core": "^1.0.158",
33
33
  "@os-design/icons": "^1.0.41",
34
34
  "@os-design/styles": "^1.0.39",
35
35
  "@os-design/theming": "^1.0.37",
@@ -46,5 +46,5 @@
46
46
  "react": ">=18",
47
47
  "react-dom": ">=18"
48
48
  },
49
- "gitHead": "5a2a0d8ca15882259f4f84a52faca3e43f79841b"
49
+ "gitHead": "1f7502d2714949d3dabaa8e103a4e315fda8e2f8"
50
50
  }