contentoh-components-library 21.6.55 → 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.
- package/.claude/launch.json +14 -0
- package/.env.test +1 -0
- package/dist/ai/prompts/attribute.prompt.js +28 -0
- package/dist/ai/prompts/description.prompt.js +33 -0
- package/dist/ai/schemas/attribute.schema.js +35 -0
- package/dist/ai/schemas/description.schema.js +27 -0
- package/dist/components/atoms/AsignationOption/index.js +1 -0
- package/dist/components/atoms/AsignationOption/styles.js +1 -1
- package/dist/components/atoms/AssetPreview/AssetPreview.stories.js +118 -0
- package/dist/components/atoms/AssetPreview/index.js +150 -0
- package/dist/components/atoms/AssetPreview/styles.js +28 -0
- package/dist/components/atoms/IconFile/index.js +85 -2
- package/dist/components/atoms/IconFile/styles.js +1 -1
- package/dist/components/atoms/ProductImage/ProductImage.stories.js +70 -2
- package/dist/components/atoms/ProductImage/index.js +100 -27
- package/dist/components/atoms/ProductImage/styles.js +3 -1
- package/dist/components/molecules/EditionActiveImage/index.js +4 -2
- package/dist/components/molecules/GalleryAssetElement/GalleryAssetElement.stories.js +147 -0
- package/dist/components/molecules/GalleryAssetElement/index.js +178 -0
- package/dist/components/molecules/GalleryAssetElement/styles.js +26 -0
- package/dist/components/molecules/GalleryElement/index.js +13 -4
- package/dist/components/molecules/GalleryHeader/index.js +96 -24
- package/dist/components/molecules/GalleryHeader/styles.js +4 -1
- package/dist/components/molecules/GalleryTrayTabs/GalleryTrayTabs.stories.js +56 -0
- package/dist/components/molecules/GalleryTrayTabs/index.js +60 -0
- package/dist/components/molecules/GalleryTrayTabs/styles.js +20 -0
- package/dist/components/molecules/ImageSelector/index.js +1 -0
- package/dist/components/molecules/RetailerSelector/RetailerSelector.stories.js +23 -2
- package/dist/components/molecules/RetailerSelector/index.js +7 -2
- package/dist/components/molecules/RetailerSelectorv2/index.js +6 -2
- package/dist/components/organisms/DigitalAssetsTray/DigitalAssetsTray.stories.js +235 -0
- package/dist/components/organisms/DigitalAssetsTray/index.js +219 -0
- package/dist/components/organisms/DigitalAssetsTray/styles.js +22 -0
- package/dist/components/organisms/ImagePreviewer/index.js +1 -0
- package/dist/components/organisms/ProductImageModal/index.js +3 -2
- package/dist/components/pages/CreatorsProductEdition/CreatorsProductEditionView.js +905 -0
- package/dist/components/pages/CreatorsProductEdition/constants.js +19 -0
- package/dist/components/pages/CreatorsProductEdition/hooks/useCreatorsProductEdition.js +2967 -0
- package/dist/components/pages/CreatorsProductEdition/index.js +33 -0
- package/dist/components/pages/CreatorsProductEdition/mocks/api.fixtures.js +537 -0
- package/dist/components/pages/CreatorsProductEdition/mocks/mockApi.js +251 -0
- package/dist/components/pages/CreatorsProductEdition/sections/CommentBox.js +311 -0
- package/dist/components/pages/CreatorsProductEdition/sections/ImagePanel.js +421 -0
- package/dist/components/pages/CreatorsProductEdition/sections/ImagesSection.js +473 -0
- package/dist/components/pages/CreatorsProductEdition/sections/ProductHeader.js +379 -0
- package/dist/components/pages/CreatorsProductEdition/sections/ProductMedia.js +138 -0
- package/dist/components/pages/CreatorsProductEdition/sections/RetailerMenu.js +162 -0
- package/dist/components/pages/CreatorsProductEdition/sections/ServiceActions.js +542 -0
- package/dist/components/pages/CreatorsProductEdition/sections/StatusChip.js +50 -0
- package/dist/components/pages/CreatorsProductEdition/sections/TabsBar.js +247 -0
- package/dist/components/pages/CreatorsProductEdition/sections/VariantsPanel.js +389 -0
- package/dist/components/pages/CreatorsProductEdition/sections/tokens.js +90 -0
- package/dist/components/pages/CreatorsProductEdition/stories/CreatorsProductEdition.stories.js +168 -0
- package/dist/components/pages/CreatorsProductEdition/stories/CreatorsProductEditionAPI.stories.js +74 -0
- package/dist/components/pages/CreatorsProductEdition/styles.js +46 -0
- package/dist/components/pages/RetailerProductEdition/context/provider-product-edition.context.js +330 -15
- package/dist/components/pages/RetailerProductEdition/context/provider-product-edition.reducer.js +12 -2
- package/dist/components/pages/RetailerProductEdition/index.js +606 -425
- package/dist/components/pages/RetailerProductEdition/stories/ImageEditor.stories.js +1 -0
- package/dist/global-files/data.js +16 -3
- package/dist/global-files/digital-assets/assetTypes.js +517 -0
- package/dist/global-files/digital-assets/assets.actions.js +64 -0
- package/dist/global-files/digital-assets/assets.adapter.js +304 -0
- package/dist/global-files/digital-assets/assets.mock.js +136 -0
- package/dist/global-files/digital-assets/assets.reducer.js +220 -0
- package/dist/global-files/digital-assets/uploadAssets.js +202 -0
- package/dist/global-files/digital-assets/useDigitalAssets.js +535 -0
- package/dist/index.js +142 -90
- package/docs/activos-digitales.md +273 -0
- package/package.json +1 -1
- package/src/components/atoms/AsignationOption/index.js +1 -1
- package/src/components/atoms/AsignationOption/styles.js +9 -0
- package/src/components/atoms/AssetPreview/AssetPreview.stories.js +78 -0
- package/src/components/atoms/AssetPreview/index.js +119 -0
- package/src/components/atoms/AssetPreview/styles.js +190 -0
- package/src/components/atoms/IconFile/index.js +28 -1
- package/src/components/atoms/IconFile/styles.js +8 -0
- package/src/components/atoms/ProductImage/ProductImage.stories.js +38 -0
- package/src/components/atoms/ProductImage/index.js +95 -20
- package/src/components/atoms/ProductImage/styles.js +92 -7
- package/src/components/molecules/EditionActiveImage/index.js +2 -2
- package/src/components/molecules/GalleryAssetElement/GalleryAssetElement.stories.js +102 -0
- package/src/components/molecules/GalleryAssetElement/index.js +162 -0
- package/src/components/molecules/GalleryAssetElement/styles.js +163 -0
- package/src/components/molecules/GalleryElement/index.js +9 -0
- package/src/components/molecules/GalleryHeader/index.js +65 -13
- package/src/components/molecules/GalleryHeader/styles.js +2 -1
- package/src/components/molecules/GalleryTrayTabs/GalleryTrayTabs.stories.js +32 -0
- package/src/components/molecules/GalleryTrayTabs/index.js +41 -0
- package/src/components/molecules/GalleryTrayTabs/styles.js +52 -0
- package/src/components/molecules/ImageSelector/index.js +1 -0
- package/src/components/molecules/RetailerSelector/RetailerSelector.stories.js +15 -1
- package/src/components/molecules/RetailerSelector/index.js +8 -1
- package/src/components/molecules/RetailerSelectorv2/index.js +7 -1
- package/src/components/organisms/DigitalAssetsTray/DigitalAssetsTray.stories.js +164 -0
- package/src/components/organisms/DigitalAssetsTray/index.js +193 -0
- package/src/components/organisms/DigitalAssetsTray/styles.js +183 -0
- package/src/components/organisms/ImagePreviewer/index.js +1 -0
- package/src/components/organisms/ProductImageModal/index.js +1 -0
- package/src/components/pages/RetailerProductEdition/context/provider-product-edition.context.jsx +201 -0
- package/src/components/pages/RetailerProductEdition/context/provider-product-edition.reducer.js +12 -0
- package/src/components/pages/RetailerProductEdition/index.js +356 -139
- package/src/components/pages/RetailerProductEdition/stories/ImageEditor.stories.js +1 -0
- package/src/global-files/data.js +17 -2
- package/src/global-files/digital-assets/assetTypes.js +451 -0
- package/src/global-files/digital-assets/assets.actions.js +50 -0
- package/src/global-files/digital-assets/assets.adapter.js +229 -0
- package/src/global-files/digital-assets/assets.mock.js +122 -0
- package/src/global-files/digital-assets/assets.reducer.js +197 -0
- package/src/global-files/digital-assets/uploadAssets.js +124 -0
- package/src/global-files/digital-assets/useDigitalAssets.js +340 -0
- package/src/index.js +4 -0
|
@@ -0,0 +1,247 @@
|
|
|
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.TabsBar = void 0;
|
|
9
|
+
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
11
|
+
|
|
12
|
+
var _react = require("react");
|
|
13
|
+
|
|
14
|
+
var _material = require("@mui/material");
|
|
15
|
+
|
|
16
|
+
var _ServiceActions = require("./ServiceActions");
|
|
17
|
+
|
|
18
|
+
var _tokens = require("./tokens");
|
|
19
|
+
|
|
20
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
Barra de pestañas (Descripción / Ficha técnica / Imágenes) y sus acciones:
|
|
24
|
+
ayuda, versión, estatus, guardar, borrar/descargar/cambiar vista de imágenes y
|
|
25
|
+
asignaciones.
|
|
26
|
+
|
|
27
|
+
Reemplaza a `organisms/FullTabsMenu` (TabsMenu + StatusAsignationInfo) con
|
|
28
|
+
los mismos props y el mismo comportamiento, hecho con MUI:
|
|
29
|
+
- las pestañas se desplazan de lado si no caben;
|
|
30
|
+
- si no caben junto a las pestañas, las acciones bajan a su propia fila
|
|
31
|
+
(las acciones son `ServiceActions`, compartido con el panel de imagen);
|
|
32
|
+
- cambiar de pestaña con cambios sin guardar pide confirmación.
|
|
33
|
+
*/
|
|
34
|
+
var tabSx = {
|
|
35
|
+
fontFamily: _tokens.FONTS.Raleway_500,
|
|
36
|
+
textTransform: "none",
|
|
37
|
+
fontSize: {
|
|
38
|
+
xs: 13,
|
|
39
|
+
sm: 14
|
|
40
|
+
},
|
|
41
|
+
lineHeight: "21px",
|
|
42
|
+
whiteSpace: "nowrap",
|
|
43
|
+
color: _tokens.COLORS.s5,
|
|
44
|
+
minWidth: {
|
|
45
|
+
xs: 0,
|
|
46
|
+
sm: 149
|
|
47
|
+
},
|
|
48
|
+
minHeight: 36,
|
|
49
|
+
px: {
|
|
50
|
+
xs: 0.5,
|
|
51
|
+
sm: 0
|
|
52
|
+
},
|
|
53
|
+
pb: "5px",
|
|
54
|
+
alignItems: "flex-start",
|
|
55
|
+
borderBottom: "2px solid ".concat(_tokens.COLORS.s3),
|
|
56
|
+
transition: "font-size 0.1s",
|
|
57
|
+
"&.Mui-selected": {
|
|
58
|
+
color: _tokens.COLORS.s5,
|
|
59
|
+
fontSize: {
|
|
60
|
+
xs: 14,
|
|
61
|
+
sm: 18
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
var TabsBar = function TabsBar(_ref) {
|
|
67
|
+
var _tabs$find;
|
|
68
|
+
|
|
69
|
+
var _ref$tabsSections = _ref.tabsSections,
|
|
70
|
+
tabsSections = _ref$tabsSections === void 0 ? {} : _ref$tabsSections,
|
|
71
|
+
_ref$status = _ref.status,
|
|
72
|
+
status = _ref$status === void 0 ? "" : _ref$status,
|
|
73
|
+
activeTab = _ref.activeTab,
|
|
74
|
+
setActiveTab = _ref.setActiveTab,
|
|
75
|
+
imageLayout = _ref.imageLayout,
|
|
76
|
+
setImageLayout = _ref.setImageLayout,
|
|
77
|
+
assig = _ref.assig,
|
|
78
|
+
setAssignation = _ref.setAssignation,
|
|
79
|
+
isRetailer = _ref.isRetailer,
|
|
80
|
+
downloadImages = _ref.downloadImages,
|
|
81
|
+
askToDeleteImages = _ref.askToDeleteImages,
|
|
82
|
+
onClickSave = _ref.onClickSave,
|
|
83
|
+
showSaveButton = _ref.showSaveButton,
|
|
84
|
+
canAssign = _ref.canAssign,
|
|
85
|
+
version = _ref.version,
|
|
86
|
+
setShowVersionSelector = _ref.setShowVersionSelector,
|
|
87
|
+
images = _ref.images,
|
|
88
|
+
_ref$updatedDescripti = _ref.updatedDescriptions,
|
|
89
|
+
updatedDescriptions = _ref$updatedDescripti === void 0 ? [] : _ref$updatedDescripti,
|
|
90
|
+
_ref$updatedDatasheet = _ref.updatedDatasheets,
|
|
91
|
+
updatedDatasheets = _ref$updatedDatasheet === void 0 ? [] : _ref$updatedDatasheet,
|
|
92
|
+
_ref$updatedImages = _ref.updatedImages,
|
|
93
|
+
updatedImages = _ref$updatedImages === void 0 ? [] : _ref$updatedImages,
|
|
94
|
+
setUpdatedDescriptions = _ref.setUpdatedDescriptions,
|
|
95
|
+
setUpdatedDatasheets = _ref.setUpdatedDatasheets,
|
|
96
|
+
setImages = _ref.setImages;
|
|
97
|
+
var tabs = Object.keys(tabsSections);
|
|
98
|
+
var initialTab = (_tabs$find = tabs.find(function (key) {
|
|
99
|
+
return tabsSections[key];
|
|
100
|
+
})) !== null && _tabs$find !== void 0 ? _tabs$find : tabs[0];
|
|
101
|
+
var currentTab = tabs.includes(activeTab) ? activeTab : initialTab;
|
|
102
|
+
var isImagesTab = currentTab === "Imágenes"; // En celular las pestañas se reparten a lo ancho: con tres caben todas y no
|
|
103
|
+
// queda ninguna escondida detrás de la flecha de desplazamiento.
|
|
104
|
+
|
|
105
|
+
var isPhone = (0, _material.useMediaQuery)("(max-width:599.95px)"); // --- Cambio de pestaña con cambios sin guardar ---------------------------
|
|
106
|
+
|
|
107
|
+
var _useState = (0, _react.useState)(null),
|
|
108
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
109
|
+
pendingTab = _useState2[0],
|
|
110
|
+
setPendingTab = _useState2[1];
|
|
111
|
+
|
|
112
|
+
var hasUnsavedChanges = function hasUnsavedChanges() {
|
|
113
|
+
var _images$values, _images$values$filter;
|
|
114
|
+
|
|
115
|
+
return updatedDescriptions.length > 0 || updatedDatasheets.length > 0 || updatedImages.length > 0 || (images === null || images === void 0 ? void 0 : (_images$values = images.values) === null || _images$values === void 0 ? void 0 : (_images$values$filter = _images$values.filter(function (f) {
|
|
116
|
+
return !f.id;
|
|
117
|
+
})) === null || _images$values$filter === void 0 ? void 0 : _images$values$filter.length) > 0;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
var requestTab = function requestTab(tab) {
|
|
121
|
+
if (tab === currentTab) return;
|
|
122
|
+
if (hasUnsavedChanges()) setPendingTab(tab);else setActiveTab(tab);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
var confirmTabChange = function confirmTabChange() {
|
|
126
|
+
// Igual que TabsMenu: al aceptar se descartan los cambios pendientes.
|
|
127
|
+
setActiveTab(pendingTab);
|
|
128
|
+
setUpdatedDescriptions && setUpdatedDescriptions([]);
|
|
129
|
+
setUpdatedDatasheets && setUpdatedDatasheets([]);
|
|
130
|
+
setImages && setImages({});
|
|
131
|
+
setPendingTab(null);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
135
|
+
sx: {
|
|
136
|
+
mb: "14px",
|
|
137
|
+
minWidth: 0
|
|
138
|
+
},
|
|
139
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
140
|
+
direction: "row",
|
|
141
|
+
flexWrap: "wrap",
|
|
142
|
+
alignItems: "flex-end",
|
|
143
|
+
justifyContent: "space-between",
|
|
144
|
+
columnGap: 2,
|
|
145
|
+
rowGap: 1,
|
|
146
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tabs, {
|
|
147
|
+
value: currentTab !== null && currentTab !== void 0 ? currentTab : false,
|
|
148
|
+
onChange: function onChange(_, tab) {
|
|
149
|
+
return requestTab(tab);
|
|
150
|
+
},
|
|
151
|
+
variant: isPhone && tabs.length <= 3 ? "fullWidth" : "scrollable",
|
|
152
|
+
scrollButtons: "auto",
|
|
153
|
+
allowScrollButtonsMobile: true,
|
|
154
|
+
TabIndicatorProps: {
|
|
155
|
+
sx: {
|
|
156
|
+
bgcolor: _tokens.COLORS.magenta_s2,
|
|
157
|
+
height: 2
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
sx: {
|
|
161
|
+
flex: "1 1 auto",
|
|
162
|
+
maxWidth: "100%",
|
|
163
|
+
minHeight: 36,
|
|
164
|
+
minWidth: 0,
|
|
165
|
+
"& .MuiTabs-flexContainer": {
|
|
166
|
+
gap: "10px"
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
children: tabs.map(function (tab) {
|
|
170
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tab, {
|
|
171
|
+
value: tab,
|
|
172
|
+
label: tab,
|
|
173
|
+
disableRipple: true,
|
|
174
|
+
sx: tabSx
|
|
175
|
+
}, tab);
|
|
176
|
+
})
|
|
177
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ServiceActions.ServiceActions, {
|
|
178
|
+
status: status,
|
|
179
|
+
imagesSection: isImagesTab,
|
|
180
|
+
imageLayout: imageLayout,
|
|
181
|
+
setImageLayout: setImageLayout,
|
|
182
|
+
assig: assig,
|
|
183
|
+
setAssignation: setAssignation,
|
|
184
|
+
isRetailer: isRetailer,
|
|
185
|
+
downloadImages: downloadImages,
|
|
186
|
+
askToDeleteImages: askToDeleteImages,
|
|
187
|
+
onClickSave: onClickSave,
|
|
188
|
+
showSaveButton: showSaveButton,
|
|
189
|
+
canAssign: canAssign,
|
|
190
|
+
version: version,
|
|
191
|
+
setShowVersionSelector: setShowVersionSelector,
|
|
192
|
+
resetKey: currentTab
|
|
193
|
+
})]
|
|
194
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Dialog, {
|
|
195
|
+
open: Boolean(pendingTab),
|
|
196
|
+
onClose: function onClose() {
|
|
197
|
+
return setPendingTab(null);
|
|
198
|
+
},
|
|
199
|
+
maxWidth: "xs",
|
|
200
|
+
fullWidth: true,
|
|
201
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.DialogTitle, {
|
|
202
|
+
sx: {
|
|
203
|
+
fontFamily: _tokens.FONTS.Raleway_600,
|
|
204
|
+
color: _tokens.COLORS.s5
|
|
205
|
+
},
|
|
206
|
+
children: "Cambios sin Guardar"
|
|
207
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.DialogContent, {
|
|
208
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.DialogContentText, {
|
|
209
|
+
sx: {
|
|
210
|
+
fontFamily: _tokens.FONTS.AvenirNext
|
|
211
|
+
},
|
|
212
|
+
children: "Est\xE1s cambiando de vista y aun no guardas cambios \xBFEst\xE1s seguro?"
|
|
213
|
+
})
|
|
214
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.DialogActions, {
|
|
215
|
+
sx: {
|
|
216
|
+
px: 3,
|
|
217
|
+
pb: 2
|
|
218
|
+
},
|
|
219
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
|
|
220
|
+
onClick: function onClick() {
|
|
221
|
+
return setPendingTab(null);
|
|
222
|
+
},
|
|
223
|
+
sx: {
|
|
224
|
+
color: _tokens.COLORS.s5,
|
|
225
|
+
textTransform: "none"
|
|
226
|
+
},
|
|
227
|
+
children: "Cancelar"
|
|
228
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
|
|
229
|
+
variant: "contained",
|
|
230
|
+
disableElevation: true,
|
|
231
|
+
onClick: confirmTabChange,
|
|
232
|
+
sx: {
|
|
233
|
+
textTransform: "none",
|
|
234
|
+
borderRadius: "20px",
|
|
235
|
+
bgcolor: _tokens.COLORS.magenta_s2,
|
|
236
|
+
"&:hover": {
|
|
237
|
+
bgcolor: _tokens.COLORS.secondary_magenta
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
children: "Aceptar"
|
|
241
|
+
})]
|
|
242
|
+
})]
|
|
243
|
+
})]
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
exports.TabsBar = TabsBar;
|
|
@@ -0,0 +1,389 @@
|
|
|
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.VariantsPanel = void 0;
|
|
9
|
+
|
|
10
|
+
var _material = require("@mui/material");
|
|
11
|
+
|
|
12
|
+
var _ArrowDropDown = _interopRequireDefault(require("@mui/icons-material/ArrowDropDown"));
|
|
13
|
+
|
|
14
|
+
var _ArrowDropUp = _interopRequireDefault(require("@mui/icons-material/ArrowDropUp"));
|
|
15
|
+
|
|
16
|
+
var _tokens = require("./tokens");
|
|
17
|
+
|
|
18
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
Variantes del producto: padre/hijo (ligar, ver la familia, desvincular) y
|
|
22
|
+
agrupación de variantes (agrupar, ver el grupo, salir del grupo).
|
|
23
|
+
|
|
24
|
+
Reemplaza el marcado de la vista original (clases variants-actions,
|
|
25
|
+
variants-family, family-row...) con MUI, con el mismo comportamiento. Los dos
|
|
26
|
+
mecanismos siguen separados a propósito: padre/hijo es herencia; el grupo es
|
|
27
|
+
solo un código compartido, y juntarlos haría creer que agrupar hereda algo.
|
|
28
|
+
*/
|
|
29
|
+
// Rosa ContentOh, el mismo del modal de ligar productos.
|
|
30
|
+
var PINK = "#E13AA8";
|
|
31
|
+
|
|
32
|
+
var OutlineButton = function OutlineButton(_ref) {
|
|
33
|
+
var children = _ref.children,
|
|
34
|
+
onClick = _ref.onClick;
|
|
35
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
|
|
36
|
+
variant: "outlined",
|
|
37
|
+
size: "small",
|
|
38
|
+
onClick: onClick,
|
|
39
|
+
sx: {
|
|
40
|
+
borderColor: PINK,
|
|
41
|
+
color: PINK,
|
|
42
|
+
borderRadius: "6px",
|
|
43
|
+
px: "12px",
|
|
44
|
+
py: "5px",
|
|
45
|
+
minHeight: 0,
|
|
46
|
+
lineHeight: 1.3,
|
|
47
|
+
textTransform: "none",
|
|
48
|
+
fontFamily: _tokens.FONTS.Raleway_600,
|
|
49
|
+
fontSize: 11,
|
|
50
|
+
"&:hover": {
|
|
51
|
+
borderColor: PINK,
|
|
52
|
+
bgcolor: "rgba(".concat(_tokens.COLORS.rgb_color_pink, ", 0.06)")
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
children: children
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
var ToggleLink = function ToggleLink(_ref2) {
|
|
60
|
+
var open = _ref2.open,
|
|
61
|
+
onClick = _ref2.onClick,
|
|
62
|
+
children = _ref2.children;
|
|
63
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Link, {
|
|
64
|
+
component: "button",
|
|
65
|
+
type: "button",
|
|
66
|
+
"aria-expanded": open,
|
|
67
|
+
onClick: onClick,
|
|
68
|
+
sx: {
|
|
69
|
+
display: "inline-flex",
|
|
70
|
+
alignItems: "center",
|
|
71
|
+
fontFamily: _tokens.FONTS.Raleway_500,
|
|
72
|
+
fontSize: 11,
|
|
73
|
+
color: _tokens.COLORS.gray,
|
|
74
|
+
textDecorationColor: "currentColor"
|
|
75
|
+
},
|
|
76
|
+
children: [children, open ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ArrowDropUp.default, {
|
|
77
|
+
fontSize: "small"
|
|
78
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ArrowDropDown.default, {
|
|
79
|
+
fontSize: "small"
|
|
80
|
+
})]
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
var SmallLink = function SmallLink(_ref3) {
|
|
85
|
+
var onClick = _ref3.onClick,
|
|
86
|
+
title = _ref3.title,
|
|
87
|
+
children = _ref3.children;
|
|
88
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Link, {
|
|
89
|
+
component: "button",
|
|
90
|
+
type: "button",
|
|
91
|
+
title: title,
|
|
92
|
+
onClick: onClick,
|
|
93
|
+
sx: {
|
|
94
|
+
flexShrink: 0,
|
|
95
|
+
px: "6px",
|
|
96
|
+
py: "4px",
|
|
97
|
+
fontFamily: _tokens.FONTS.Raleway_500,
|
|
98
|
+
fontSize: 10,
|
|
99
|
+
color: _tokens.COLORS.gray,
|
|
100
|
+
whiteSpace: "nowrap",
|
|
101
|
+
textDecorationColor: "currentColor",
|
|
102
|
+
"&:hover": {
|
|
103
|
+
color: PINK
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
children: children
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
/** Fila de la familia: el botón navega; "Desvincular" queda FUERA de él. */
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
var FamilyRow = function FamilyRow(_ref4) {
|
|
113
|
+
var role = _ref4.role,
|
|
114
|
+
name = _ref4.name,
|
|
115
|
+
upc = _ref4.upc,
|
|
116
|
+
disabled = _ref4.disabled,
|
|
117
|
+
current = _ref4.current,
|
|
118
|
+
onOpen = _ref4.onOpen,
|
|
119
|
+
action = _ref4.action;
|
|
120
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
121
|
+
direction: "row",
|
|
122
|
+
alignItems: "center",
|
|
123
|
+
gap: "4px",
|
|
124
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.ButtonBase, {
|
|
125
|
+
disabled: disabled,
|
|
126
|
+
onClick: onOpen,
|
|
127
|
+
sx: {
|
|
128
|
+
flex: 1,
|
|
129
|
+
minWidth: 0,
|
|
130
|
+
display: "flex",
|
|
131
|
+
flexWrap: {
|
|
132
|
+
xs: "wrap",
|
|
133
|
+
sm: "nowrap"
|
|
134
|
+
},
|
|
135
|
+
alignItems: "baseline",
|
|
136
|
+
justifyContent: "flex-start",
|
|
137
|
+
columnGap: 1,
|
|
138
|
+
rowGap: "2px",
|
|
139
|
+
px: 1,
|
|
140
|
+
py: "6px",
|
|
141
|
+
borderRadius: "4px",
|
|
142
|
+
textAlign: "left",
|
|
143
|
+
fontFamily: _tokens.FONTS.Raleway_500,
|
|
144
|
+
fontSize: 12,
|
|
145
|
+
color: _tokens.COLORS.deep_gray,
|
|
146
|
+
"&:hover:not(:disabled)": {
|
|
147
|
+
bgcolor: _tokens.COLORS.s2
|
|
148
|
+
},
|
|
149
|
+
"&.Mui-disabled": {
|
|
150
|
+
opacity: 0.7
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
154
|
+
component: "span",
|
|
155
|
+
sx: {
|
|
156
|
+
minWidth: 96,
|
|
157
|
+
fontSize: 10,
|
|
158
|
+
color: current ? _tokens.COLORS.gray : PINK
|
|
159
|
+
},
|
|
160
|
+
children: role
|
|
161
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
162
|
+
component: "span",
|
|
163
|
+
sx: {
|
|
164
|
+
flex: 1,
|
|
165
|
+
minWidth: 0,
|
|
166
|
+
overflow: "hidden",
|
|
167
|
+
textOverflow: "ellipsis",
|
|
168
|
+
whiteSpace: "nowrap"
|
|
169
|
+
},
|
|
170
|
+
children: name
|
|
171
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
172
|
+
component: "span",
|
|
173
|
+
sx: {
|
|
174
|
+
fontSize: 11,
|
|
175
|
+
color: _tokens.COLORS.gray
|
|
176
|
+
},
|
|
177
|
+
children: upc
|
|
178
|
+
})]
|
|
179
|
+
}), action]
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
var Note = function Note(_ref5) {
|
|
184
|
+
var children = _ref5.children;
|
|
185
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
186
|
+
sx: {
|
|
187
|
+
m: 0,
|
|
188
|
+
fontFamily: _tokens.FONTS.Raleway_500,
|
|
189
|
+
fontSize: 11,
|
|
190
|
+
color: _tokens.COLORS.gray
|
|
191
|
+
},
|
|
192
|
+
children: children
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
var FamilyBox = function FamilyBox(_ref6) {
|
|
197
|
+
var open = _ref6.open,
|
|
198
|
+
children = _ref6.children;
|
|
199
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Collapse, {
|
|
200
|
+
in: open,
|
|
201
|
+
unmountOnExit: true,
|
|
202
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Paper, {
|
|
203
|
+
variant: "outlined",
|
|
204
|
+
sx: {
|
|
205
|
+
display: "flex",
|
|
206
|
+
flexDirection: "column",
|
|
207
|
+
gap: "4px",
|
|
208
|
+
mb: "10px",
|
|
209
|
+
p: 1,
|
|
210
|
+
borderColor: _tokens.COLORS.s2,
|
|
211
|
+
borderRadius: "6px"
|
|
212
|
+
},
|
|
213
|
+
children: children
|
|
214
|
+
})
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
var VariantsPanel = function VariantsPanel(_ref7) {
|
|
219
|
+
var _variantGroup$members, _family$variants, _family$variants2;
|
|
220
|
+
|
|
221
|
+
var product = _ref7.product,
|
|
222
|
+
esHijoDeOtro = _ref7.esHijoDeOtro,
|
|
223
|
+
hijosDelProducto = _ref7.hijosDelProducto,
|
|
224
|
+
family = _ref7.family,
|
|
225
|
+
showFamily = _ref7.showFamily,
|
|
226
|
+
setShowFamily = _ref7.setShowFamily,
|
|
227
|
+
loadFamily = _ref7.loadFamily,
|
|
228
|
+
loadingVariant = _ref7.loadingVariant,
|
|
229
|
+
avisoFamilia = _ref7.avisoFamilia,
|
|
230
|
+
openFamilyMember = _ref7.openFamilyMember,
|
|
231
|
+
setPorDesvincular = _ref7.setPorDesvincular,
|
|
232
|
+
setShowLinkVariants = _ref7.setShowLinkVariants,
|
|
233
|
+
puedeAgruparse = _ref7.puedeAgruparse,
|
|
234
|
+
variantGroup = _ref7.variantGroup,
|
|
235
|
+
showGroup = _ref7.showGroup,
|
|
236
|
+
setShowGroup = _ref7.setShowGroup,
|
|
237
|
+
setShowGroupModal = _ref7.setShowGroupModal,
|
|
238
|
+
handleOnLeaveGroup = _ref7.handleOnLeaveGroup;
|
|
239
|
+
|
|
240
|
+
var toggleFamily = function toggleFamily() {
|
|
241
|
+
setShowFamily(function (abierto) {
|
|
242
|
+
return !abierto;
|
|
243
|
+
});
|
|
244
|
+
loadFamily();
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
var opening = function opening(articleId, label) {
|
|
248
|
+
return loadingVariant === articleId ? "Abriendo…" : label;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
var otherMembers = ((_variantGroup$members = variantGroup === null || variantGroup === void 0 ? void 0 : variantGroup.members) !== null && _variantGroup$members !== void 0 ? _variantGroup$members : []).filter(function (miembro) {
|
|
252
|
+
return !miembro.isCurrent;
|
|
253
|
+
});
|
|
254
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
255
|
+
sx: {
|
|
256
|
+
minWidth: 0
|
|
257
|
+
},
|
|
258
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
259
|
+
direction: "row",
|
|
260
|
+
flexWrap: "wrap",
|
|
261
|
+
alignItems: "center",
|
|
262
|
+
gap: "10px",
|
|
263
|
+
sx: {
|
|
264
|
+
mb: 1
|
|
265
|
+
},
|
|
266
|
+
children: [!esHijoDeOtro && /*#__PURE__*/(0, _jsxRuntime.jsx)(OutlineButton, {
|
|
267
|
+
onClick: function onClick() {
|
|
268
|
+
return setShowLinkVariants(true);
|
|
269
|
+
},
|
|
270
|
+
children: "Ligar productos"
|
|
271
|
+
}), !esHijoDeOtro && hijosDelProducto > 0 && /*#__PURE__*/(0, _jsxRuntime.jsxs)(ToggleLink, {
|
|
272
|
+
open: showFamily,
|
|
273
|
+
onClick: toggleFamily,
|
|
274
|
+
children: [hijosDelProducto, " hijo", hijosDelProducto === 1 ? "" : "s"]
|
|
275
|
+
}), esHijoDeOtro && /*#__PURE__*/(0, _jsxRuntime.jsx)(ToggleLink, {
|
|
276
|
+
open: showFamily,
|
|
277
|
+
onClick: toggleFamily,
|
|
278
|
+
children: "Hijo de otro producto"
|
|
279
|
+
})]
|
|
280
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(FamilyBox, {
|
|
281
|
+
open: showFamily,
|
|
282
|
+
children: [!family && /*#__PURE__*/(0, _jsxRuntime.jsx)(Note, {
|
|
283
|
+
children: "Cargando familia\u2026"
|
|
284
|
+
}), (family === null || family === void 0 ? void 0 : family.error) && /*#__PURE__*/(0, _jsxRuntime.jsx)(Note, {
|
|
285
|
+
children: "No se pudo cargar la familia de este producto."
|
|
286
|
+
}), (family === null || family === void 0 ? void 0 : family.parent) && /*#__PURE__*/(0, _jsxRuntime.jsx)(FamilyRow, {
|
|
287
|
+
role: opening(family.parent.articleId, "Producto padre"),
|
|
288
|
+
name: family.parent.name,
|
|
289
|
+
upc: family.parent.upc,
|
|
290
|
+
disabled: loadingVariant !== null,
|
|
291
|
+
onOpen: function onOpen() {
|
|
292
|
+
return openFamilyMember(family.parent.articleId);
|
|
293
|
+
},
|
|
294
|
+
action: /*#__PURE__*/(0, _jsxRuntime.jsx)(SmallLink, {
|
|
295
|
+
title: "Dejar de ser hijo de este producto",
|
|
296
|
+
onClick: function onClick() {
|
|
297
|
+
return setPorDesvincular({
|
|
298
|
+
mode: "self",
|
|
299
|
+
childArticleId: product === null || product === void 0 ? void 0 : product.id_article,
|
|
300
|
+
childName: product === null || product === void 0 ? void 0 : product.name,
|
|
301
|
+
childUpc: product === null || product === void 0 ? void 0 : product.upc,
|
|
302
|
+
parentName: family.parent.name,
|
|
303
|
+
parentUpc: family.parent.upc
|
|
304
|
+
});
|
|
305
|
+
},
|
|
306
|
+
children: "Desvincular"
|
|
307
|
+
})
|
|
308
|
+
}), family === null || family === void 0 ? void 0 : (_family$variants = family.variants) === null || _family$variants === void 0 ? void 0 : _family$variants.map(function (variant) {
|
|
309
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(FamilyRow, {
|
|
310
|
+
role: opening(variant.articleId, variant.isCurrent ? "Estás aquí" : "Hijo"),
|
|
311
|
+
name: variant.name,
|
|
312
|
+
upc: variant.upc,
|
|
313
|
+
current: variant.isCurrent,
|
|
314
|
+
disabled: variant.isCurrent || loadingVariant !== null,
|
|
315
|
+
onOpen: function onOpen() {
|
|
316
|
+
return openFamilyMember(variant.articleId);
|
|
317
|
+
},
|
|
318
|
+
action: // Solo cuando esta ficha ES el padre: si hay `parent`, lo que se
|
|
319
|
+
// lista son hermanos.
|
|
320
|
+
!family.parent && !variant.isCurrent ? /*#__PURE__*/(0, _jsxRuntime.jsx)(SmallLink, {
|
|
321
|
+
title: "Desvincular este hijo",
|
|
322
|
+
onClick: function onClick() {
|
|
323
|
+
return setPorDesvincular({
|
|
324
|
+
mode: "child",
|
|
325
|
+
childArticleId: variant.articleId,
|
|
326
|
+
childName: variant.name,
|
|
327
|
+
childUpc: variant.upc,
|
|
328
|
+
parentName: product === null || product === void 0 ? void 0 : product.name,
|
|
329
|
+
parentUpc: product === null || product === void 0 ? void 0 : product.upc
|
|
330
|
+
});
|
|
331
|
+
},
|
|
332
|
+
children: "Desvincular"
|
|
333
|
+
}) : null
|
|
334
|
+
}, variant.articleId);
|
|
335
|
+
}), family && !family.error && !((_family$variants2 = family.variants) !== null && _family$variants2 !== void 0 && _family$variants2.length) && /*#__PURE__*/(0, _jsxRuntime.jsx)(Note, {
|
|
336
|
+
children: "Este producto no tiene hijos."
|
|
337
|
+
}), avisoFamilia && /*#__PURE__*/(0, _jsxRuntime.jsx)(Note, {
|
|
338
|
+
children: avisoFamilia
|
|
339
|
+
})]
|
|
340
|
+
}), puedeAgruparse && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
341
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
342
|
+
direction: "row",
|
|
343
|
+
flexWrap: "wrap",
|
|
344
|
+
alignItems: "center",
|
|
345
|
+
gap: "10px",
|
|
346
|
+
sx: {
|
|
347
|
+
mb: 1
|
|
348
|
+
},
|
|
349
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(OutlineButton, {
|
|
350
|
+
onClick: function onClick() {
|
|
351
|
+
return setShowGroupModal(true);
|
|
352
|
+
},
|
|
353
|
+
children: variantGroup !== null && variantGroup !== void 0 && variantGroup.group ? "Cambiar de grupo" : "Agrupar variantes"
|
|
354
|
+
}), (variantGroup === null || variantGroup === void 0 ? void 0 : variantGroup.group) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(ToggleLink, {
|
|
355
|
+
open: showGroup,
|
|
356
|
+
onClick: function onClick() {
|
|
357
|
+
return setShowGroup(function (abierto) {
|
|
358
|
+
return !abierto;
|
|
359
|
+
});
|
|
360
|
+
},
|
|
361
|
+
children: ["Variante ", variantGroup.group]
|
|
362
|
+
})]
|
|
363
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(FamilyBox, {
|
|
364
|
+
open: showGroup && Boolean(variantGroup === null || variantGroup === void 0 ? void 0 : variantGroup.group),
|
|
365
|
+
children: [otherMembers.map(function (miembro) {
|
|
366
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(FamilyRow, {
|
|
367
|
+
role: opening(miembro.articleId, "Variante"),
|
|
368
|
+
name: miembro.name,
|
|
369
|
+
upc: miembro.upc,
|
|
370
|
+
disabled: loadingVariant !== null,
|
|
371
|
+
onOpen: function onOpen() {
|
|
372
|
+
return openFamilyMember(miembro.articleId);
|
|
373
|
+
}
|
|
374
|
+
}, miembro.articleId);
|
|
375
|
+
}), otherMembers.length === 0 && /*#__PURE__*/(0, _jsxRuntime.jsxs)(Note, {
|
|
376
|
+
children: ["Este producto es el \xFAnico en el grupo ", variantGroup === null || variantGroup === void 0 ? void 0 : variantGroup.group, "."]
|
|
377
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
378
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(SmallLink, {
|
|
379
|
+
title: "Quitar este producto del grupo",
|
|
380
|
+
onClick: handleOnLeaveGroup,
|
|
381
|
+
children: "Quitar del grupo"
|
|
382
|
+
})
|
|
383
|
+
})]
|
|
384
|
+
})]
|
|
385
|
+
})]
|
|
386
|
+
});
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
exports.VariantsPanel = VariantsPanel;
|