contentoh-components-library 21.6.56 → 21.6.57

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.
Files changed (43) hide show
  1. package/dist/components/atoms/AsignationOption/index.js +1 -0
  2. package/dist/components/atoms/AsignationOption/styles.js +1 -1
  3. package/dist/components/molecules/GalleryAssetElement/styles.js +1 -1
  4. package/dist/components/molecules/RetailerSelector/RetailerSelector.stories.js +23 -2
  5. package/dist/components/molecules/RetailerSelector/index.js +7 -2
  6. package/dist/components/molecules/RetailerSelectorv2/index.js +6 -2
  7. package/dist/components/organisms/DigitalAssetsTray/DigitalAssetsTray.stories.js +73 -9
  8. package/dist/components/organisms/DigitalAssetsTray/index.js +13 -5
  9. package/dist/components/pages/CreatorsProductEdition/CreatorsProductEditionView.js +905 -0
  10. package/dist/components/pages/CreatorsProductEdition/constants.js +19 -0
  11. package/dist/components/pages/CreatorsProductEdition/hooks/useCreatorsProductEdition.js +2967 -0
  12. package/dist/components/pages/CreatorsProductEdition/index.js +33 -0
  13. package/dist/components/pages/CreatorsProductEdition/mocks/api.fixtures.js +537 -0
  14. package/dist/components/pages/CreatorsProductEdition/mocks/mockApi.js +251 -0
  15. package/dist/components/pages/CreatorsProductEdition/sections/CommentBox.js +311 -0
  16. package/dist/components/pages/CreatorsProductEdition/sections/ImagePanel.js +421 -0
  17. package/dist/components/pages/CreatorsProductEdition/sections/ImagesSection.js +473 -0
  18. package/dist/components/pages/CreatorsProductEdition/sections/ProductHeader.js +379 -0
  19. package/dist/components/pages/CreatorsProductEdition/sections/ProductMedia.js +138 -0
  20. package/dist/components/pages/CreatorsProductEdition/sections/RetailerMenu.js +162 -0
  21. package/dist/components/pages/CreatorsProductEdition/sections/ServiceActions.js +542 -0
  22. package/dist/components/pages/CreatorsProductEdition/sections/StatusChip.js +50 -0
  23. package/dist/components/pages/CreatorsProductEdition/sections/TabsBar.js +247 -0
  24. package/dist/components/pages/CreatorsProductEdition/sections/VariantsPanel.js +389 -0
  25. package/dist/components/pages/CreatorsProductEdition/sections/tokens.js +90 -0
  26. package/dist/components/pages/CreatorsProductEdition/stories/CreatorsProductEdition.stories.js +168 -0
  27. package/dist/components/pages/CreatorsProductEdition/stories/CreatorsProductEditionAPI.stories.js +74 -0
  28. package/dist/components/pages/CreatorsProductEdition/styles.js +46 -0
  29. package/dist/global-files/digital-assets/assetTypes.js +49 -12
  30. package/dist/global-files/digital-assets/uploadAssets.js +39 -16
  31. package/dist/global-files/digital-assets/useDigitalAssets.js +38 -25
  32. package/package.json +1 -1
  33. package/src/components/atoms/AsignationOption/index.js +1 -1
  34. package/src/components/atoms/AsignationOption/styles.js +9 -0
  35. package/src/components/molecules/GalleryAssetElement/styles.js +5 -1
  36. package/src/components/molecules/RetailerSelector/RetailerSelector.stories.js +15 -1
  37. package/src/components/molecules/RetailerSelector/index.js +8 -1
  38. package/src/components/molecules/RetailerSelectorv2/index.js +7 -1
  39. package/src/components/organisms/DigitalAssetsTray/DigitalAssetsTray.stories.js +67 -4
  40. package/src/components/organisms/DigitalAssetsTray/index.js +8 -4
  41. package/src/global-files/digital-assets/assetTypes.js +42 -10
  42. package/src/global-files/digital-assets/uploadAssets.js +38 -23
  43. package/src/global-files/digital-assets/useDigitalAssets.js +19 -8
@@ -0,0 +1,421 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ImagePanel = void 0;
9
+
10
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
11
+
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
13
+
14
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
15
+
16
+ var _react = require("react");
17
+
18
+ var _material = require("@mui/material");
19
+
20
+ var _react2 = require("swiper/react");
21
+
22
+ var _swiper = require("swiper");
23
+
24
+ require("swiper/swiper.min.css");
25
+
26
+ var _openModal = _interopRequireDefault(require("../../../../assets/images/generalButton/openModal.svg"));
27
+
28
+ var _ProductMedia = require("./ProductMedia");
29
+
30
+ var _ServiceActions = require("./ServiceActions");
31
+
32
+ var _tokens = require("./tokens");
33
+
34
+ var _jsxRuntime = require("react/jsx-runtime");
35
+
36
+ var _excluded = ["imagesArray", "activeImage", "currentIndex", "setActiveImage", "setShowModal"];
37
+
38
+ /*
39
+ Panel de imagen: la imagen activa, las miniaturas y los datos de la imagen.
40
+
41
+ Reemplaza a `organisms/ImagePreviewer` (EditionActiveImage + ImageSelector) y a
42
+ `organisms/ImageDataTable` (TableHeader + filas), con los mismos props, hecho
43
+ con MUI y Swiper. Se estira al ancho de su columna en vez de medir 340px fijos:
44
+ en desktop ocupa el panel izquierdo y en tablet/celular va arriba del contenido.
45
+ */
46
+ // --- Vista previa ----------------------------------------------------------
47
+ var Preview = function Preview(_ref) {
48
+ var _imagesArray$values;
49
+
50
+ var imagesArray = _ref.imagesArray,
51
+ activeImage = _ref.activeImage,
52
+ setActiveImage = _ref.setActiveImage,
53
+ setShowModal = _ref.setShowModal,
54
+ currentIndex = _ref.currentIndex;
55
+ var images = (_imagesArray$values = imagesArray === null || imagesArray === void 0 ? void 0 : imagesArray.values) !== null && _imagesArray$values !== void 0 ? _imagesArray$values : [];
56
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
57
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
58
+ sx: {
59
+ position: "relative",
60
+ width: "100%",
61
+ // Misma proporción que el visor original (340 x 295).
62
+ aspectRatio: "340 / 295",
63
+ bgcolor: _tokens.COLORS.white
64
+ },
65
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ProductMedia.ProductMedia, {
66
+ src: activeImage === null || activeImage === void 0 ? void 0 : activeImage.src,
67
+ ext: activeImage === null || activeImage === void 0 ? void 0 : activeImage.ext,
68
+ alt: activeImage === null || activeImage === void 0 ? void 0 : activeImage.name
69
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
70
+ title: "Ver en grande",
71
+ arrow: true,
72
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
73
+ "aria-label": "Ver en grande",
74
+ onClick: function onClick() {
75
+ return setShowModal(true);
76
+ },
77
+ sx: {
78
+ position: "absolute",
79
+ right: 4,
80
+ bottom: 4,
81
+ width: 30,
82
+ height: 30,
83
+ p: 0,
84
+ backgroundImage: "url(".concat(_openModal.default, ")"),
85
+ backgroundRepeat: "no-repeat",
86
+ backgroundPosition: "center"
87
+ }
88
+ })
89
+ })]
90
+ }), images.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
91
+ sx: {
92
+ mt: 1
93
+ },
94
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Swiper, {
95
+ modules: [_swiper.FreeMode, _swiper.Mousewheel, _swiper.Keyboard],
96
+ slidesPerView: "auto",
97
+ spaceBetween: 4,
98
+ freeMode: true,
99
+ mousewheel: {
100
+ forceToAxis: true
101
+ },
102
+ keyboard: {
103
+ enabled: true
104
+ },
105
+ style: {
106
+ width: "100%"
107
+ },
108
+ children: images.map(function (image, index) {
109
+ var selected = index === currentIndex;
110
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.SwiperSlide, {
111
+ style: {
112
+ width: 85
113
+ },
114
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ButtonBase, {
115
+ "aria-label": "Ver imagen ".concat(index + 1),
116
+ "aria-pressed": selected,
117
+ onClick: function onClick() {
118
+ return setActiveImage(index);
119
+ },
120
+ sx: {
121
+ width: 85,
122
+ height: 55,
123
+ borderRadius: "3px",
124
+ overflow: "hidden",
125
+ outline: selected ? "2px solid ".concat(_tokens.COLORS.magenta_s2) : "none",
126
+ outlineOffset: -2,
127
+ bgcolor: _tokens.COLORS.white
128
+ },
129
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ProductMedia.ProductMedia, {
130
+ src: image.src,
131
+ ext: image.ext,
132
+ alt: image.altText,
133
+ thumbnail: true
134
+ })
135
+ })
136
+ }, "".concat(index, "-").concat(image === null || image === void 0 ? void 0 : image.name));
137
+ })
138
+ })
139
+ })]
140
+ });
141
+ }; // --- Datos de la imagen ----------------------------------------------------
142
+
143
+
144
+ var labelSx = {
145
+ fontFamily: _tokens.FONTS.AvenirNext,
146
+ fontSize: 11,
147
+ lineHeight: "18px",
148
+ color: _tokens.COLORS.s4
149
+ };
150
+
151
+ var DataRow = function DataRow(_ref2) {
152
+ var label = _ref2.label,
153
+ children = _ref2.children;
154
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.TableRow, {
155
+ sx: {
156
+ "& td, & th": {
157
+ border: 0,
158
+ py: "2px",
159
+ px: 0
160
+ }
161
+ },
162
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TableCell, {
163
+ component: "th",
164
+ scope: "row",
165
+ sx: labelSx,
166
+ children: label
167
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TableCell, {
168
+ align: "right",
169
+ sx: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, labelSx), {}, {
170
+ pl: 1
171
+ }),
172
+ children: children
173
+ })]
174
+ });
175
+ };
176
+
177
+ var GrayValue = function GrayValue(_ref3) {
178
+ var children = _ref3.children;
179
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
180
+ component: "span",
181
+ sx: {
182
+ display: "inline-block",
183
+ maxWidth: "100%",
184
+ px: "3px",
185
+ py: "1px",
186
+ borderRadius: "3px",
187
+ bgcolor: _tokens.COLORS.s2,
188
+ color: _tokens.COLORS.s5,
189
+ fontFamily: _tokens.FONTS.AvenirNext,
190
+ fontSize: 11,
191
+ lineHeight: "19px",
192
+ overflowWrap: "anywhere"
193
+ },
194
+ children: children
195
+ });
196
+ };
197
+ /**
198
+ * Valor que se edita con un clic, como `atoms/LabelToInput`: se muestra como
199
+ * etiqueta y al hacer clic se vuelve campo de texto; al salir, vuelve a ser
200
+ * etiqueta. Cada cambio se avisa con el mismo payload que el original.
201
+ */
202
+
203
+
204
+ var EditableValue = function EditableValue(_ref4) {
205
+ var defaultValue = _ref4.defaultValue,
206
+ _onChange = _ref4.onChange;
207
+
208
+ var _useState = (0, _react.useState)(false),
209
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
210
+ editing = _useState2[0],
211
+ setEditing = _useState2[1];
212
+
213
+ var _useState3 = (0, _react.useState)(defaultValue === "" ? "-" : defaultValue),
214
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
215
+ value = _useState4[0],
216
+ setValue = _useState4[1];
217
+
218
+ var inputRef = (0, _react.useRef)(null);
219
+ (0, _react.useEffect)(function () {
220
+ return setValue(defaultValue === "" ? "-" : defaultValue);
221
+ }, [defaultValue]);
222
+ (0, _react.useEffect)(function () {
223
+ var _inputRef$current;
224
+
225
+ if (editing) (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
226
+ }, [editing]);
227
+
228
+ if (!editing) {
229
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ButtonBase, {
230
+ onClick: function onClick() {
231
+ return setEditing(true);
232
+ },
233
+ "aria-label": "Editar valor",
234
+ sx: {
235
+ borderRadius: "3px",
236
+ justifyContent: "flex-end",
237
+ maxWidth: "100%"
238
+ },
239
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(GrayValue, {
240
+ children: value !== null && value !== void 0 ? value : "-"
241
+ })
242
+ });
243
+ }
244
+
245
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.InputBase, {
246
+ inputRef: inputRef,
247
+ value: value !== null && value !== void 0 ? value : "",
248
+ onChange: function onChange(e) {
249
+ setValue(e.target.value);
250
+
251
+ _onChange(e);
252
+ },
253
+ onBlur: function onBlur() {
254
+ return setEditing(false);
255
+ },
256
+ onKeyDown: function onKeyDown(e) {
257
+ return e.key === "Enter" && setEditing(false);
258
+ },
259
+ sx: {
260
+ width: 120,
261
+ maxWidth: "100%",
262
+ fontFamily: _tokens.FONTS.AvenirNext,
263
+ fontSize: 12,
264
+ border: "1px solid ".concat(_tokens.COLORS.s3),
265
+ borderRadius: "3px",
266
+ px: 0.5
267
+ }
268
+ });
269
+ };
270
+
271
+ var ImageData = function ImageData(_ref5) {
272
+ var _lists$inputs, _lists$inputs$find, _lists$imageShotType, _lists$imageShotType$, _lists$attrForImgs, _lists$attrForImgs$ge;
273
+
274
+ var activeImage = _ref5.activeImage,
275
+ lists = _ref5.lists,
276
+ retailerSelected = _ref5.retailerSelected,
277
+ setImages = _ref5.setImages,
278
+ assignationsImages = _ref5.assignationsImages,
279
+ imagesStatus = _ref5.imagesStatus,
280
+ setAssignation = _ref5.setAssignation,
281
+ isRetailer = _ref5.isRetailer,
282
+ onClickSave = _ref5.onClickSave,
283
+ showSaveButton = _ref5.showSaveButton,
284
+ version = _ref5.version,
285
+ setShowVersionSelector = _ref5.setShowVersionSelector,
286
+ shotThd = _ref5.shotThd;
287
+ var shotName = (lists === null || lists === void 0 ? void 0 : (_lists$inputs = lists.inputs) === null || _lists$inputs === void 0 ? void 0 : (_lists$inputs$find = _lists$inputs.find(function (f) {
288
+ return f.id === +(activeImage === null || activeImage === void 0 ? void 0 : activeImage.image_id);
289
+ })) === null || _lists$inputs$find === void 0 ? void 0 : _lists$inputs$find.name) || "-";
290
+ var thdShot = (lists === null || lists === void 0 ? void 0 : (_lists$imageShotType = lists.imageShotType) === null || _lists$imageShotType === void 0 ? void 0 : (_lists$imageShotType$ = _lists$imageShotType.find(function (f) {
291
+ return f.id === +(activeImage === null || activeImage === void 0 ? void 0 : activeImage.image_shot_type);
292
+ })) === null || _lists$imageShotType$ === void 0 ? void 0 : _lists$imageShotType$.type_shot) || "-";
293
+ var size = activeImage !== null && activeImage !== void 0 && activeImage.width && activeImage.height ? "".concat(activeImage.width, "x").concat(activeImage.height, "px") : "-";
294
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Paper, {
295
+ variant: "outlined",
296
+ sx: {
297
+ mt: {
298
+ xs: 2,
299
+ sm: 0,
300
+ md: 2
301
+ },
302
+ p: "10px",
303
+ borderColor: _tokens.COLORS.s2,
304
+ borderRadius: "3px",
305
+ minWidth: 0
306
+ },
307
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Stack, {
308
+ direction: "row",
309
+ alignItems: "center",
310
+ flexWrap: "wrap",
311
+ gap: 1,
312
+ sx: {
313
+ pb: "5px",
314
+ borderBottom: "1px solid ".concat(_tokens.COLORS.s2)
315
+ },
316
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
317
+ title: (activeImage === null || activeImage === void 0 ? void 0 : activeImage.name) || "-",
318
+ sx: {
319
+ fontFamily: _tokens.FONTS.Raleway,
320
+ fontSize: 14,
321
+ lineHeight: "23px",
322
+ color: _tokens.COLORS.s5,
323
+ flex: "1 1 90px",
324
+ minWidth: 0,
325
+ overflow: "hidden",
326
+ textOverflow: "ellipsis",
327
+ whiteSpace: "nowrap"
328
+ },
329
+ children: (activeImage === null || activeImage === void 0 ? void 0 : activeImage.name) || "-"
330
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ServiceActions.ServiceActions, {
331
+ status: imagesStatus,
332
+ assig: assignationsImages,
333
+ setAssignation: setAssignation,
334
+ isRetailer: isRetailer,
335
+ onClickSave: onClickSave,
336
+ showSaveButton: showSaveButton,
337
+ version: version,
338
+ setShowVersionSelector: setShowVersionSelector
339
+ })]
340
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Table, {
341
+ size: "small",
342
+ sx: {
343
+ mt: "4px",
344
+ tableLayout: "fixed"
345
+ },
346
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.TableBody, {
347
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(DataRow, {
348
+ label: "Tipo de toma",
349
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(GrayValue, {
350
+ children: shotName
351
+ })
352
+ }), shotThd && /*#__PURE__*/(0, _jsxRuntime.jsx)(DataRow, {
353
+ label: "Tipo de imagen THD",
354
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(GrayValue, {
355
+ children: thdShot
356
+ })
357
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(DataRow, {
358
+ label: "Formato",
359
+ children: (activeImage === null || activeImage === void 0 ? void 0 : activeImage.ext) || "-"
360
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(DataRow, {
361
+ label: "Tama\xF1o de imagen",
362
+ children: size
363
+ }), retailerSelected && (lists === null || lists === void 0 ? void 0 : (_lists$attrForImgs = lists.attrForImgs) === null || _lists$attrForImgs === void 0 ? void 0 : (_lists$attrForImgs$ge = _lists$attrForImgs.general) === null || _lists$attrForImgs$ge === void 0 ? void 0 : _lists$attrForImgs$ge.map(function (attr, index) {
364
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(DataRow, {
365
+ label: (attr === null || attr === void 0 ? void 0 : attr.name) || "-",
366
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(EditableValue, {
367
+ defaultValue: attr === null || attr === void 0 ? void 0 : attr.value,
368
+ onChange: function onChange(e) {
369
+ return setImages({
370
+ action: "changeAttrValue",
371
+ value: e.target.value || "-",
372
+ id: attr.id
373
+ });
374
+ }
375
+ })
376
+ }, "row-".concat(index, "-").concat(attr === null || attr === void 0 ? void 0 : attr.name));
377
+ }))]
378
+ })
379
+ })]
380
+ });
381
+ }; // --- Panel completo --------------------------------------------------------
382
+
383
+
384
+ var ImagePanel = function ImagePanel(_ref6) {
385
+ var imagesArray = _ref6.imagesArray,
386
+ activeImage = _ref6.activeImage,
387
+ currentIndex = _ref6.currentIndex,
388
+ setActiveImage = _ref6.setActiveImage,
389
+ setShowModal = _ref6.setShowModal,
390
+ dataProps = (0, _objectWithoutProperties2.default)(_ref6, _excluded);
391
+ return (
392
+ /*#__PURE__*/
393
+ // En tablet la imagen y sus datos van lado a lado: apilados, la imagen
394
+ // ocuparía todo el ancho y empujaría el contenido muy abajo.
395
+ (0, _jsxRuntime.jsxs)(_material.Box, {
396
+ sx: {
397
+ width: "100%",
398
+ minWidth: 0,
399
+ display: "grid",
400
+ gridTemplateColumns: {
401
+ xs: "minmax(0, 1fr)",
402
+ sm: "repeat(2, minmax(0, 1fr))",
403
+ md: "minmax(0, 1fr)"
404
+ },
405
+ columnGap: 2,
406
+ alignItems: "start"
407
+ },
408
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Preview, {
409
+ imagesArray: imagesArray,
410
+ activeImage: activeImage,
411
+ currentIndex: currentIndex,
412
+ setActiveImage: setActiveImage,
413
+ setShowModal: setShowModal
414
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(ImageData, (0, _objectSpread2.default)({
415
+ activeImage: activeImage
416
+ }, dataProps))]
417
+ })
418
+ );
419
+ };
420
+
421
+ exports.ImagePanel = ImagePanel;