contentoh-components-library 21.6.61 → 21.6.62

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 (88) hide show
  1. package/.claude/settings.local.json +7 -0
  2. package/dist/ai/prompts/attribute.prompt.js +28 -0
  3. package/dist/ai/prompts/description.prompt.js +33 -0
  4. package/dist/ai/schemas/attribute.schema.js +35 -0
  5. package/dist/ai/schemas/description.schema.js +27 -0
  6. package/dist/components/pages/CreatorsProductEdition/CreatorsProductEditionView.js +11 -5
  7. package/dist/components/pages/CreatorsProductEdition/hooks/useCreatorsProductEdition.js +58 -31
  8. package/dist/components/pages/CreatorsProductEdition/mocks/api.fixtures.js +5 -1
  9. package/dist/components/pages/CreatorsProductEdition/mocks/mockApi.js +3 -40
  10. package/dist/components/pages/CreatorsProductEdition/sections/ImagesSection.js +18 -3
  11. package/dist/components/pages/CreatorsProductEdition/sections/StatusChip.js +4 -13
  12. package/dist/components/pages/CreatorsProductEdition/sections/TabsBar.js +10 -0
  13. package/dist/components/pages/CreatorsProductEdition/stories/CreatorsProductEdition.stories.js +10 -2
  14. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +2 -15
  15. package/dist/components/pages/RetailerProductEdition/index.js +40 -57
  16. package/dist/components/pages/RetailerProductEdition/utils.js +2 -6
  17. package/dist/index.js +0 -13
  18. package/package.json +1 -1
  19. package/src/components/pages/CreatorsProductEdition/CreatorsProductEditionView.jsx +22 -3
  20. package/src/components/pages/CreatorsProductEdition/hooks/useCreatorsProductEdition.js +36 -1
  21. package/src/components/pages/CreatorsProductEdition/mocks/api.fixtures.js +15 -3
  22. package/src/components/pages/CreatorsProductEdition/mocks/mockApi.js +8 -18
  23. package/src/components/pages/CreatorsProductEdition/sections/ImagesSection.jsx +24 -2
  24. package/src/components/pages/CreatorsProductEdition/sections/StatusChip.jsx +4 -8
  25. package/src/components/pages/CreatorsProductEdition/sections/TabsBar.jsx +9 -0
  26. package/src/components/pages/CreatorsProductEdition/stories/CreatorsProductEdition.stories.js +6 -0
  27. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +0 -12
  28. package/src/components/pages/RetailerProductEdition/index.js +3 -28
  29. package/src/components/pages/RetailerProductEdition/utils.js +0 -5
  30. package/src/index.js +0 -1
  31. package/dist/components/organisms/ServicesNavigation/ServiceToolbar.js +0 -210
  32. package/dist/components/organisms/ServicesNavigation/ServicesNavigation.stories.js +0 -138
  33. package/dist/components/organisms/ServicesNavigation/ServicesRail.js +0 -705
  34. package/dist/components/organisms/ServicesNavigation/catalog.js +0 -505
  35. package/dist/components/organisms/ServicesNavigation/index.js +0 -337
  36. package/dist/components/organisms/ServicesNavigation/model.js +0 -167
  37. package/dist/components/organisms/ServicesNavigation/ui.js +0 -371
  38. package/dist/components/organisms/ServicesNavigation/views.js +0 -1237
  39. package/dist/components/organisms/ServicesWorkspace/AssigneePicker.js +0 -459
  40. package/dist/components/organisms/ServicesWorkspace/ServicesWorkspace.stories.js +0 -119
  41. package/dist/components/organisms/ServicesWorkspace/demo.js +0 -137
  42. package/dist/components/organisms/ServicesWorkspace/index.js +0 -813
  43. package/dist/components/organisms/ServicesWorkspace/servicesModel.js +0 -351
  44. package/dist/components/organisms/ServicesWorkspace/tooltipStyles.js +0 -37
  45. package/dist/components/pages/CreatorsProductEdition/mocks/productServices.fixtures.js +0 -387
  46. package/dist/components/pages/ProductEdition/ProductEdition.stories.js +0 -148
  47. package/dist/components/pages/ProductEdition/ProductEditionView.js +0 -1355
  48. package/dist/components/pages/ProductEdition/ServiceHeader.js +0 -142
  49. package/dist/components/pages/ProductEdition/api.js +0 -256
  50. package/dist/components/pages/ProductEdition/index.js +0 -37
  51. package/dist/components/pages/ProductEdition/permissions.js +0 -200
  52. package/dist/components/pages/ProductEdition/permissions.test.js +0 -320
  53. package/dist/components/pages/ProductEdition/sections/CatalogServicePanel.js +0 -237
  54. package/dist/components/pages/ProductEdition/sections/EditionTopBar.js +0 -174
  55. package/dist/components/pages/ProductEdition/sections/ImagePanel.js +0 -440
  56. package/dist/components/pages/ProductEdition/sections/ServiceTeam.js +0 -275
  57. package/dist/components/pages/ProductEdition/sections/ServiceTools.js +0 -186
  58. package/dist/components/pages/ProductEdition/services.js +0 -233
  59. package/dist/components/pages/ProductEdition/services.test.js +0 -195
  60. package/src/components/organisms/ServicesNavigation/ServiceToolbar.jsx +0 -143
  61. package/src/components/organisms/ServicesNavigation/ServicesNavigation.stories.js +0 -101
  62. package/src/components/organisms/ServicesNavigation/ServicesRail.jsx +0 -591
  63. package/src/components/organisms/ServicesNavigation/catalog.js +0 -180
  64. package/src/components/organisms/ServicesNavigation/index.jsx +0 -232
  65. package/src/components/organisms/ServicesNavigation/model.js +0 -85
  66. package/src/components/organisms/ServicesNavigation/ui.jsx +0 -229
  67. package/src/components/organisms/ServicesNavigation/views.jsx +0 -705
  68. package/src/components/organisms/ServicesWorkspace/AssigneePicker.js +0 -348
  69. package/src/components/organisms/ServicesWorkspace/ServicesWorkspace.stories.js +0 -61
  70. package/src/components/organisms/ServicesWorkspace/demo.js +0 -58
  71. package/src/components/organisms/ServicesWorkspace/index.js +0 -556
  72. package/src/components/organisms/ServicesWorkspace/servicesModel.js +0 -203
  73. package/src/components/organisms/ServicesWorkspace/tooltipStyles.js +0 -27
  74. package/src/components/pages/CreatorsProductEdition/mocks/productServices.fixtures.js +0 -175
  75. package/src/components/pages/ProductEdition/ProductEdition.stories.js +0 -106
  76. package/src/components/pages/ProductEdition/ProductEditionView.jsx +0 -1142
  77. package/src/components/pages/ProductEdition/ServiceHeader.jsx +0 -104
  78. package/src/components/pages/ProductEdition/api.js +0 -84
  79. package/src/components/pages/ProductEdition/index.js +0 -21
  80. package/src/components/pages/ProductEdition/permissions.js +0 -128
  81. package/src/components/pages/ProductEdition/permissions.test.js +0 -249
  82. package/src/components/pages/ProductEdition/sections/CatalogServicePanel.jsx +0 -123
  83. package/src/components/pages/ProductEdition/sections/EditionTopBar.jsx +0 -134
  84. package/src/components/pages/ProductEdition/sections/ImagePanel.jsx +0 -342
  85. package/src/components/pages/ProductEdition/sections/ServiceTeam.jsx +0 -184
  86. package/src/components/pages/ProductEdition/sections/ServiceTools.jsx +0 -134
  87. package/src/components/pages/ProductEdition/services.js +0 -187
  88. package/src/components/pages/ProductEdition/services.test.js +0 -88
@@ -1,174 +0,0 @@
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.EditionTopBar = void 0;
9
-
10
- var _react = require("react");
11
-
12
- var _material = require("@mui/material");
13
-
14
- var _Close = _interopRequireDefault(require("@mui/icons-material/Close"));
15
-
16
- var _Chat = require("../../../organisms/Chat");
17
-
18
- var _IconoAB = _interopRequireDefault(require("../../../../assets/images/generalButton/Icono AB.svg"));
19
-
20
- var _tokens = require("../../CreatorsProductEdition/sections/tokens");
21
-
22
- var _jsxRuntime = require("react/jsx-runtime");
23
-
24
- /*
25
- Barra superior de la edición. Reemplaza a `molecules/HeaderTop` con lo mismo
26
- (título, chat, comparar versión auditable y cerrar), pero:
27
- - el título es más chico y la barra tiene aire y una línea abajo, para que
28
- no quede encimado sobre la imagen y el nombre del producto;
29
- - el botón de cerrar queda dentro del margen y con borde, para que siempre
30
- se vea (antes iba pegado al borde derecho).
31
-
32
- Reporta su alto con `setHeaderTop`, como HeaderTop: la pantalla lo resta para
33
- calcular el alto de las columnas. Incluye el margen de abajo.
34
- */
35
- var GAP_BELOW = 12;
36
- var buttonSx = {
37
- width: 32,
38
- height: 32,
39
- border: "1px solid ".concat(_tokens.COLORS.s3),
40
- bgcolor: _tokens.COLORS.white,
41
- "&:hover": {
42
- bgcolor: _tokens.COLORS.s2,
43
- borderColor: _tokens.COLORS.s4
44
- }
45
- };
46
-
47
- var EditionTopBar = function EditionTopBar(_ref) {
48
- var setHeaderTop = _ref.setHeaderTop,
49
- withChat = _ref.withChat,
50
- chatType = _ref.chatType,
51
- productSelected = _ref.productSelected,
52
- token = _ref.token,
53
- auditableVersion = _ref.auditableVersion,
54
- setCompare = _ref.setCompare,
55
- isAuditor = _ref.isAuditor,
56
- activeRetailer = _ref.activeRetailer,
57
- _ref$onClose = _ref.onClose,
58
- onClose = _ref$onClose === void 0 ? function () {
59
- window.location.href = "/products";
60
- } : _ref$onClose;
61
- var ref = (0, _react.useRef)(null);
62
- (0, _react.useEffect)(function () {
63
- if (ref.current && setHeaderTop) setHeaderTop(ref.current.offsetHeight + GAP_BELOW); // eslint-disable-next-line react-hooks/exhaustive-deps
64
- }, []); // Mismo chat que HeaderTop, según `chatType`.
65
-
66
- var chat = (0, _react.useMemo)(function () {
67
- if (!withChat || !chatType || !productSelected || !token) return null;
68
-
69
- if (chatType === "product_status") {
70
- var _productSelected$arti;
71
-
72
- if (!(activeRetailer !== null && activeRetailer !== void 0 && activeRetailer.id)) return null;
73
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chat.Chat, {
74
- chatType: "product_status",
75
- chatContainerType: "popUp",
76
- chatData: {
77
- id: (productSelected === null || productSelected === void 0 ? void 0 : (_productSelected$arti = productSelected.article) === null || _productSelected$arti === void 0 ? void 0 : _productSelected$arti.id_article) || (productSelected === null || productSelected === void 0 ? void 0 : productSelected.id_article),
78
- version: productSelected === null || productSelected === void 0 ? void 0 : productSelected.version,
79
- retailerId: activeRetailer.id,
80
- status: productSelected === null || productSelected === void 0 ? void 0 : productSelected.status,
81
- userToken: token
82
- },
83
- size: 18,
84
- activeRetailer: activeRetailer
85
- });
86
- }
87
-
88
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chat.Chat, {
89
- chatType: "merchant_product",
90
- chatContainerType: "popUp",
91
- chatData: {
92
- userToken: token,
93
- id: productSelected.id_article,
94
- version: productSelected.version
95
- },
96
- size: 18,
97
- activeRetailer: activeRetailer
98
- }); // eslint-disable-next-line react-hooks/exhaustive-deps
99
- }, [withChat, chatType, productSelected === null || productSelected === void 0 ? void 0 : productSelected.id_article, productSelected === null || productSelected === void 0 ? void 0 : productSelected.version, token, activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id]);
100
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
101
- ref: ref,
102
- component: "header",
103
- sx: {
104
- display: "flex",
105
- alignItems: "center",
106
- gap: 1.5,
107
- px: {
108
- xs: 1.5,
109
- sm: 2
110
- },
111
- py: 1,
112
- mb: "".concat(GAP_BELOW, "px"),
113
- borderBottom: "1px solid ".concat(_tokens.COLORS.s2),
114
- minWidth: 0
115
- },
116
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
117
- component: "h1",
118
- sx: {
119
- flex: 1,
120
- minWidth: 0,
121
- fontFamily: _tokens.FONTS.Raleway_600,
122
- fontSize: 16,
123
- lineHeight: "24px",
124
- color: _tokens.COLORS.s5,
125
- overflow: "hidden",
126
- textOverflow: "ellipsis",
127
- whiteSpace: "nowrap"
128
- },
129
- children: "Edici\xF3n de producto"
130
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Stack, {
131
- direction: "row",
132
- alignItems: "center",
133
- spacing: 1,
134
- sx: {
135
- flexShrink: 0
136
- },
137
- children: [chat, isAuditor && auditableVersion && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
138
- title: "Comparar con la versi\xF3n auditable",
139
- arrow: true,
140
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
141
- "aria-label": "Comparar con la versi\xF3n auditable",
142
- onClick: function onClick() {
143
- return setCompare(function (value) {
144
- return !value;
145
- });
146
- },
147
- sx: buttonSx,
148
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
149
- src: _IconoAB.default,
150
- alt: "",
151
- width: 16,
152
- height: 16
153
- })
154
- })
155
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
156
- title: "Cerrar",
157
- arrow: true,
158
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
159
- "aria-label": "Cerrar la edici\xF3n",
160
- onClick: onClose,
161
- sx: buttonSx,
162
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Close.default, {
163
- sx: {
164
- fontSize: 18,
165
- color: _tokens.COLORS.s5
166
- }
167
- })
168
- })
169
- })]
170
- })]
171
- });
172
- };
173
-
174
- exports.EditionTopBar = EditionTopBar;
@@ -1,440 +0,0 @@
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("../../CreatorsProductEdition/sections/ProductMedia");
29
-
30
- var _StatusChip = require("../../CreatorsProductEdition/sections/StatusChip");
31
-
32
- var _tokens = require("../../CreatorsProductEdition/sections/tokens");
33
-
34
- var _ServiceTools = require("./ServiceTools");
35
-
36
- var _jsxRuntime = require("react/jsx-runtime");
37
-
38
- var _excluded = ["imagesArray", "activeImage", "currentIndex", "setActiveImage", "setShowModal"];
39
-
40
- /*
41
- Panel de imagen de ProductEdition: la imagen activa, las miniaturas y los
42
- datos de la imagen.
43
-
44
- Copia del de CreatorsProductEdition con el diseño de la propuesta de
45
- navegación por servicios: la imagen en una tarjeta con fondo claro y bordes
46
- redondeados, miniaturas cuadradas con borde rosa en la activa, y la cabecera
47
- de los datos sin el botón de ayuda (estatus + versión + guardar).
48
-
49
- Reemplaza a `organisms/ImagePreviewer` (EditionActiveImage + ImageSelector) y a
50
- `organisms/ImageDataTable` (TableHeader + filas), con los mismos props, hecho
51
- con MUI y Swiper. Se estira al ancho de su columna en vez de medir 340px fijos:
52
- en desktop ocupa el panel izquierdo y en tablet/celular va arriba del contenido.
53
- */
54
- // --- Vista previa ----------------------------------------------------------
55
- var Preview = function Preview(_ref) {
56
- var _imagesArray$values;
57
-
58
- var imagesArray = _ref.imagesArray,
59
- activeImage = _ref.activeImage,
60
- setActiveImage = _ref.setActiveImage,
61
- setShowModal = _ref.setShowModal,
62
- currentIndex = _ref.currentIndex;
63
- var images = (_imagesArray$values = imagesArray === null || imagesArray === void 0 ? void 0 : imagesArray.values) !== null && _imagesArray$values !== void 0 ? _imagesArray$values : [];
64
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
65
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
66
- sx: {
67
- position: "relative",
68
- width: "100%",
69
- // Misma proporción que el visor original (340 x 295).
70
- aspectRatio: "340 / 295",
71
- p: 1.5,
72
- boxSizing: "border-box",
73
- borderRadius: "10px",
74
- border: "1px solid ".concat(_tokens.COLORS.s2),
75
- background: "linear-gradient(135deg, ".concat(_tokens.COLORS.white, ", ").concat(_tokens.COLORS.s1, ")"),
76
- overflow: "hidden"
77
- },
78
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ProductMedia.ProductMedia, {
79
- src: activeImage === null || activeImage === void 0 ? void 0 : activeImage.src,
80
- ext: activeImage === null || activeImage === void 0 ? void 0 : activeImage.ext,
81
- alt: activeImage === null || activeImage === void 0 ? void 0 : activeImage.name
82
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
83
- title: "Ver en grande",
84
- arrow: true,
85
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
86
- "aria-label": "Ver en grande",
87
- onClick: function onClick() {
88
- return setShowModal(true);
89
- },
90
- sx: {
91
- position: "absolute",
92
- right: 8,
93
- bottom: 8,
94
- width: 32,
95
- height: 32,
96
- p: 0,
97
- bgcolor: _tokens.COLORS.white,
98
- border: "1px solid ".concat(_tokens.COLORS.s2),
99
- backgroundImage: "url(".concat(_openModal.default, ")"),
100
- backgroundRepeat: "no-repeat",
101
- backgroundPosition: "center",
102
- backgroundSize: 16,
103
- "&:hover": {
104
- bgcolor: _tokens.COLORS.s2
105
- }
106
- }
107
- })
108
- })]
109
- }), images.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
110
- sx: {
111
- mt: 1.25
112
- },
113
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Swiper, {
114
- modules: [_swiper.FreeMode, _swiper.Mousewheel, _swiper.Keyboard],
115
- slidesPerView: "auto",
116
- spaceBetween: 8,
117
- freeMode: true,
118
- mousewheel: {
119
- forceToAxis: true
120
- },
121
- keyboard: {
122
- enabled: true
123
- },
124
- style: {
125
- width: "100%"
126
- },
127
- children: images.map(function (image, index) {
128
- var selected = index === currentIndex;
129
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.SwiperSlide, {
130
- style: {
131
- width: 64
132
- },
133
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ButtonBase, {
134
- "aria-label": "Ver imagen ".concat(index + 1),
135
- "aria-pressed": selected,
136
- onClick: function onClick() {
137
- return setActiveImage(index);
138
- },
139
- sx: {
140
- width: 64,
141
- height: 64,
142
- p: "4px",
143
- boxSizing: "border-box",
144
- borderRadius: "8px",
145
- overflow: "hidden",
146
- border: "".concat(selected ? 2 : 1, "px solid ").concat(selected ? _tokens.COLORS.magenta_s2 : _tokens.COLORS.s2),
147
- bgcolor: _tokens.COLORS.white,
148
- "&:hover": {
149
- borderColor: selected ? _tokens.COLORS.magenta_s2 : _tokens.COLORS.s3
150
- }
151
- },
152
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ProductMedia.ProductMedia, {
153
- src: image.src,
154
- ext: image.ext,
155
- alt: image.altText,
156
- thumbnail: true
157
- })
158
- })
159
- }, "".concat(index, "-").concat(image === null || image === void 0 ? void 0 : image.name));
160
- })
161
- })
162
- })]
163
- });
164
- }; // --- Datos de la imagen ----------------------------------------------------
165
-
166
-
167
- var labelSx = {
168
- fontFamily: _tokens.FONTS.AvenirNext,
169
- fontSize: 11,
170
- lineHeight: "18px",
171
- color: _tokens.COLORS.s4
172
- };
173
-
174
- var DataRow = function DataRow(_ref2) {
175
- var label = _ref2.label,
176
- children = _ref2.children;
177
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.TableRow, {
178
- sx: {
179
- "& td, & th": {
180
- border: 0,
181
- py: "2px",
182
- px: 0
183
- }
184
- },
185
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TableCell, {
186
- component: "th",
187
- scope: "row",
188
- sx: labelSx,
189
- children: label
190
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TableCell, {
191
- align: "right",
192
- sx: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, labelSx), {}, {
193
- pl: 1
194
- }),
195
- children: children
196
- })]
197
- });
198
- };
199
-
200
- var GrayValue = function GrayValue(_ref3) {
201
- var children = _ref3.children;
202
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
203
- component: "span",
204
- sx: {
205
- display: "inline-block",
206
- maxWidth: "100%",
207
- px: "3px",
208
- py: "1px",
209
- borderRadius: "3px",
210
- bgcolor: _tokens.COLORS.s2,
211
- color: _tokens.COLORS.s5,
212
- fontFamily: _tokens.FONTS.AvenirNext,
213
- fontSize: 11,
214
- lineHeight: "19px",
215
- overflowWrap: "anywhere"
216
- },
217
- children: children
218
- });
219
- };
220
- /**
221
- * Valor que se edita con un clic, como `atoms/LabelToInput`: se muestra como
222
- * etiqueta y al hacer clic se vuelve campo de texto; al salir, vuelve a ser
223
- * etiqueta. Cada cambio se avisa con el mismo payload que el original.
224
- */
225
-
226
-
227
- var EditableValue = function EditableValue(_ref4) {
228
- var defaultValue = _ref4.defaultValue,
229
- _onChange = _ref4.onChange;
230
-
231
- var _useState = (0, _react.useState)(false),
232
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
233
- editing = _useState2[0],
234
- setEditing = _useState2[1];
235
-
236
- var _useState3 = (0, _react.useState)(defaultValue === "" ? "-" : defaultValue),
237
- _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
238
- value = _useState4[0],
239
- setValue = _useState4[1];
240
-
241
- var inputRef = (0, _react.useRef)(null);
242
- (0, _react.useEffect)(function () {
243
- return setValue(defaultValue === "" ? "-" : defaultValue);
244
- }, [defaultValue]);
245
- (0, _react.useEffect)(function () {
246
- var _inputRef$current;
247
-
248
- if (editing) (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
249
- }, [editing]);
250
-
251
- if (!editing) {
252
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ButtonBase, {
253
- onClick: function onClick() {
254
- return setEditing(true);
255
- },
256
- "aria-label": "Editar valor",
257
- sx: {
258
- borderRadius: "3px",
259
- justifyContent: "flex-end",
260
- maxWidth: "100%"
261
- },
262
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(GrayValue, {
263
- children: value !== null && value !== void 0 ? value : "-"
264
- })
265
- });
266
- }
267
-
268
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.InputBase, {
269
- inputRef: inputRef,
270
- value: value !== null && value !== void 0 ? value : "",
271
- onChange: function onChange(e) {
272
- setValue(e.target.value);
273
-
274
- _onChange(e);
275
- },
276
- onBlur: function onBlur() {
277
- return setEditing(false);
278
- },
279
- onKeyDown: function onKeyDown(e) {
280
- return e.key === "Enter" && setEditing(false);
281
- },
282
- sx: {
283
- width: 120,
284
- maxWidth: "100%",
285
- fontFamily: _tokens.FONTS.AvenirNext,
286
- fontSize: 12,
287
- border: "1px solid ".concat(_tokens.COLORS.s3),
288
- borderRadius: "3px",
289
- px: 0.5
290
- }
291
- });
292
- };
293
-
294
- var ImageData = function ImageData(_ref5) {
295
- var _lists$inputs, _lists$inputs$find, _lists$imageShotType, _lists$imageShotType$, _lists$attrForImgs, _lists$attrForImgs$ge;
296
-
297
- var activeImage = _ref5.activeImage,
298
- lists = _ref5.lists,
299
- retailerSelected = _ref5.retailerSelected,
300
- setImages = _ref5.setImages,
301
- imagesStatus = _ref5.imagesStatus,
302
- onClickSave = _ref5.onClickSave,
303
- showSaveButton = _ref5.showSaveButton,
304
- version = _ref5.version,
305
- setShowVersionSelector = _ref5.setShowVersionSelector,
306
- shotThd = _ref5.shotThd;
307
- 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) {
308
- return f.id === +(activeImage === null || activeImage === void 0 ? void 0 : activeImage.image_id);
309
- })) === null || _lists$inputs$find === void 0 ? void 0 : _lists$inputs$find.name) || "-";
310
- 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) {
311
- return f.id === +(activeImage === null || activeImage === void 0 ? void 0 : activeImage.image_shot_type);
312
- })) === null || _lists$imageShotType$ === void 0 ? void 0 : _lists$imageShotType$.type_shot) || "-";
313
- var size = activeImage !== null && activeImage !== void 0 && activeImage.width && activeImage.height ? "".concat(activeImage.width, "x").concat(activeImage.height, "px") : "-";
314
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Paper, {
315
- variant: "outlined",
316
- sx: {
317
- mt: {
318
- xs: 2,
319
- sm: 0,
320
- md: 2
321
- },
322
- p: 1.5,
323
- borderColor: _tokens.COLORS.s2,
324
- borderRadius: "10px",
325
- minWidth: 0
326
- },
327
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Stack, {
328
- direction: "row",
329
- alignItems: "center",
330
- flexWrap: "wrap",
331
- gap: 1,
332
- sx: {
333
- pb: "5px",
334
- borderBottom: "1px solid ".concat(_tokens.COLORS.s2)
335
- },
336
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
337
- title: (activeImage === null || activeImage === void 0 ? void 0 : activeImage.name) || "-",
338
- sx: {
339
- fontFamily: _tokens.FONTS.Raleway,
340
- fontSize: 14,
341
- lineHeight: "23px",
342
- color: _tokens.COLORS.s5,
343
- flex: "1 1 90px",
344
- minWidth: 0,
345
- overflow: "hidden",
346
- textOverflow: "ellipsis",
347
- whiteSpace: "nowrap"
348
- },
349
- children: (activeImage === null || activeImage === void 0 ? void 0 : activeImage.name) || "-"
350
- }), imagesStatus && imagesStatus !== "-" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_StatusChip.StatusChip, {
351
- status: imagesStatus,
352
- oval: true
353
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ServiceTools.ServiceTools, {
354
- onClickSave: onClickSave,
355
- showSaveButton: showSaveButton,
356
- version: version,
357
- setShowVersionSelector: setShowVersionSelector
358
- })]
359
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Table, {
360
- size: "small",
361
- sx: {
362
- mt: "4px",
363
- tableLayout: "fixed"
364
- },
365
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.TableBody, {
366
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(DataRow, {
367
- label: "Tipo de toma",
368
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(GrayValue, {
369
- children: shotName
370
- })
371
- }), shotThd && /*#__PURE__*/(0, _jsxRuntime.jsx)(DataRow, {
372
- label: "Tipo de imagen THD",
373
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(GrayValue, {
374
- children: thdShot
375
- })
376
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(DataRow, {
377
- label: "Formato",
378
- children: (activeImage === null || activeImage === void 0 ? void 0 : activeImage.ext) || "-"
379
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(DataRow, {
380
- label: "Tama\xF1o de imagen",
381
- children: size
382
- }), 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) {
383
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(DataRow, {
384
- label: (attr === null || attr === void 0 ? void 0 : attr.name) || "-",
385
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(EditableValue, {
386
- defaultValue: attr === null || attr === void 0 ? void 0 : attr.value,
387
- onChange: function onChange(e) {
388
- return setImages({
389
- action: "changeAttrValue",
390
- value: e.target.value || "-",
391
- id: attr.id
392
- });
393
- }
394
- })
395
- }, "row-".concat(index, "-").concat(attr === null || attr === void 0 ? void 0 : attr.name));
396
- }))]
397
- })
398
- })]
399
- });
400
- }; // --- Panel completo --------------------------------------------------------
401
-
402
-
403
- var ImagePanel = function ImagePanel(_ref6) {
404
- var imagesArray = _ref6.imagesArray,
405
- activeImage = _ref6.activeImage,
406
- currentIndex = _ref6.currentIndex,
407
- setActiveImage = _ref6.setActiveImage,
408
- setShowModal = _ref6.setShowModal,
409
- dataProps = (0, _objectWithoutProperties2.default)(_ref6, _excluded);
410
- return (
411
- /*#__PURE__*/
412
- // En tablet la imagen y sus datos van lado a lado: apilados, la imagen
413
- // ocuparía todo el ancho y empujaría el contenido muy abajo.
414
- (0, _jsxRuntime.jsxs)(_material.Box, {
415
- sx: {
416
- width: "100%",
417
- minWidth: 0,
418
- display: "grid",
419
- gridTemplateColumns: {
420
- xs: "minmax(0, 1fr)",
421
- sm: "repeat(2, minmax(0, 1fr))",
422
- md: "minmax(0, 1fr)"
423
- },
424
- columnGap: 2,
425
- alignItems: "start"
426
- },
427
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Preview, {
428
- imagesArray: imagesArray,
429
- activeImage: activeImage,
430
- currentIndex: currentIndex,
431
- setActiveImage: setActiveImage,
432
- setShowModal: setShowModal
433
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(ImageData, (0, _objectSpread2.default)({
434
- activeImage: activeImage
435
- }, dataProps))]
436
- })
437
- );
438
- };
439
-
440
- exports.ImagePanel = ImagePanel;