@widergy/energy-ui 3.165.0 → 3.166.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -2
- package/dist/components/UTSnackbar/README.md +1 -1
- package/dist/components/UTSnackbar/constants.js +8 -2
- package/dist/components/UTSnackbar/index.js +7 -9
- package/dist/components/UTSnackbar/stories/UTSnackbar.stories.js +39 -5
- package/dist/components/UTSnackbar/stories/storiesConstants.js +6 -5
- package/dist/components/UTSnackbar/utils.js +53 -0
- package/dist/components/UTTable/components/TableFooter/components/PageSizeSelector/index.js +4 -0
- package/dist/components/UTTable/components/TableFooter/index.js +6 -2
- package/dist/components/UTTable/index.js +3 -0
- package/dist/esm/components/UTSnackbar/README.md +1 -1
- package/dist/esm/components/UTSnackbar/constants.js +7 -1
- package/dist/esm/components/UTSnackbar/index.js +8 -10
- package/dist/esm/components/UTSnackbar/stories/UTSnackbar.stories.js +39 -5
- package/dist/esm/components/UTSnackbar/stories/storiesConstants.js +7 -6
- package/dist/esm/components/UTSnackbar/utils.js +46 -0
- package/dist/esm/components/UTTable/components/TableFooter/components/PageSizeSelector/index.js +4 -0
- package/dist/esm/components/UTTable/components/TableFooter/index.js +6 -2
- package/dist/esm/components/UTTable/index.js +3 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
# [3.
|
|
1
|
+
# [3.166.0](https://github.com/widergy/energy-ui/compare/v3.165.1...v3.166.0) (2026-06-12)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Features
|
|
5
5
|
|
|
6
|
-
* [
|
|
6
|
+
* [AUTO-271] Add test ids to case panel detail ([#809](https://github.com/widergy/energy-ui/issues/809)) ([d2413bb](https://github.com/widergy/energy-ui/commit/d2413bb084b1ae70de41800edd347450e836d94e))
|
|
7
|
+
|
|
8
|
+
## [3.165.1](https://github.com/widergy/energy-ui/compare/v3.165.0...v3.165.1) (2026-06-12)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* added prop position to snackbar ([#818](https://github.com/widergy/energy-ui/issues/818)) ([676e43c](https://github.com/widergy/energy-ui/commit/676e43c4d625578b074506867879b0b8bdbe75ea))
|
|
14
|
+
|
|
15
|
+
# [3.165.0](https://github.com/widergy/energy-ui/compare/v3.164.0...v3.165.0) (2026-06-10)
|
|
16
|
+
|
|
17
|
+
### Novedades y Mejoras
|
|
18
|
+
|
|
19
|
+
* Se incorpora un nuevo componente de notificaciones emergentes que permite mostrar mensajes informativos, de éxito, advertencia o error con estilos visuales configurables, soporte de íconos automáticos, acciones interactivas y cierre automático. Reemplaza y supera al componente de alertas anterior, adaptándose al diseño de cada entorno. [#813](https://github.com/widergy/Energy-UI/pull/813) [DIS-1106](https://widergy.atlassian.net/browse/DIS-1106)
|
|
7
20
|
|
|
8
21
|
# [3.164.0](https://github.com/widergy/energy-ui/compare/v3.163.0...v3.164.0) (2026-06-09)
|
|
9
22
|
|
|
@@ -18,7 +18,7 @@ Componente de notificación tipo Snackbar. Soporta cinco `colorTheme`: los cuatr
|
|
|
18
18
|
| `description` | `string` | `undefined` | Texto secundario debajo del mensaje principal. |
|
|
19
19
|
| `icon` | `string` | `undefined` | Nombre de ícono Tabler para sobreescribir el ícono por defecto (ej: `IconStar`). |
|
|
20
20
|
| `withoutIcon` | `boolean` | `undefined` | Oculta el ícono. |
|
|
21
|
-
| `
|
|
21
|
+
| `position` | `'bottomLeft' \| 'bottomRight' \| 'topLeft' \| 'topRight'` | `'bottomLeft'` | Posición del snackbar en la pantalla. Determina también la dirección del slide de entrada. |
|
|
22
22
|
| `timeDuration` | `number` | `undefined` | Duración en ms antes del cierre automático. |
|
|
23
23
|
| `onClose` | `function` | `undefined` | Callback al cerrar el snackbar. |
|
|
24
24
|
| `classes` | `object` | `{}` | Clases CSS personalizadas para sobrescribir estilos del tema. |
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.VARIANT_CLASS_MAP = exports.VARIANTS = exports.LABEL_COLOR_MAP = exports.ICON_NAME_MAP = exports.DEFAULT_PROPS = exports.COLOR_THEMES = exports.ACTION_BUTTON_CONFIG_MAP = void 0;
|
|
6
|
+
exports.VARIANT_CLASS_MAP = exports.VARIANTS = exports.POSITIONS = exports.LABEL_COLOR_MAP = exports.ICON_NAME_MAP = exports.DEFAULT_PROPS = exports.COLOR_THEMES = exports.ACTION_BUTTON_CONFIG_MAP = void 0;
|
|
7
7
|
var _Palette = require("../../constants/Palette");
|
|
8
8
|
const COLOR_THEMES = exports.COLOR_THEMES = {
|
|
9
9
|
error: 'error',
|
|
@@ -16,10 +16,16 @@ const VARIANTS = exports.VARIANTS = {
|
|
|
16
16
|
dark: 'dark',
|
|
17
17
|
light: 'light'
|
|
18
18
|
};
|
|
19
|
+
const POSITIONS = exports.POSITIONS = {
|
|
20
|
+
bottomLeft: 'bottomLeft',
|
|
21
|
+
bottomRight: 'bottomRight',
|
|
22
|
+
topLeft: 'topLeft',
|
|
23
|
+
topRight: 'topRight'
|
|
24
|
+
};
|
|
19
25
|
const DEFAULT_PROPS = exports.DEFAULT_PROPS = {
|
|
20
26
|
colorTheme: COLOR_THEMES.success,
|
|
21
27
|
open: false,
|
|
22
|
-
|
|
28
|
+
position: POSITIONS.bottomLeft,
|
|
23
29
|
variant: VARIANTS.dark
|
|
24
30
|
};
|
|
25
31
|
const VARIANT_CLASS_MAP = exports.VARIANT_CLASS_MAP = {
|
|
@@ -14,6 +14,7 @@ var _UTLabel = _interopRequireDefault(require("../UTLabel"));
|
|
|
14
14
|
var _WithTheme = _interopRequireDefault(require("../WithTheme"));
|
|
15
15
|
var _testIds = require("../../constants/testIds");
|
|
16
16
|
var _constants = require("./constants");
|
|
17
|
+
var _utils = require("./utils");
|
|
17
18
|
var _theme = require("./theme");
|
|
18
19
|
var _types = require("./types");
|
|
19
20
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
@@ -29,9 +30,9 @@ const UTSnackbar = _ref => {
|
|
|
29
30
|
message,
|
|
30
31
|
onClose,
|
|
31
32
|
open = _constants.DEFAULT_PROPS.open,
|
|
33
|
+
position = _constants.DEFAULT_PROPS.position,
|
|
32
34
|
secondaryButton,
|
|
33
35
|
timeDuration,
|
|
34
|
-
topRight = _constants.DEFAULT_PROPS.topRight,
|
|
35
36
|
variant = _constants.DEFAULT_PROPS.variant,
|
|
36
37
|
withoutIcon
|
|
37
38
|
} = _ref;
|
|
@@ -45,13 +46,10 @@ const UTSnackbar = _ref => {
|
|
|
45
46
|
const labelColorConfig = _constants.LABEL_COLOR_MAP[variantClassKey] || _constants.LABEL_COLOR_MAP.successDark;
|
|
46
47
|
const actionButtonConfig = _constants.ACTION_BUTTON_CONFIG_MAP[variantClassKey];
|
|
47
48
|
const iconName = withoutIcon ? null : icon || _constants.ICON_NAME_MAP[colorTheme];
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
};
|
|
52
|
-
const transition = {
|
|
53
|
-
direction: topRight ? 'left' : 'up'
|
|
54
|
-
};
|
|
49
|
+
const {
|
|
50
|
+
anchor,
|
|
51
|
+
transition
|
|
52
|
+
} = (0, _utils.getAnchorAndTransition)(position);
|
|
55
53
|
const testIds = {
|
|
56
54
|
close: dataTestId ? "".concat(dataTestId, ".close") : undefined,
|
|
57
55
|
description: dataTestId ? "".concat(dataTestId, ".").concat(_testIds.ID_CONSTANTS.DESCRIPTION, ".").concat(_testIds.ID_CONSTANTS.LABEL) : undefined,
|
|
@@ -127,9 +125,9 @@ UTSnackbar.propTypes = {
|
|
|
127
125
|
message: _propTypes.string,
|
|
128
126
|
onClose: _propTypes.func,
|
|
129
127
|
open: _propTypes.bool,
|
|
128
|
+
position: (0, _propTypes.oneOf)(Object.values(_constants.POSITIONS)),
|
|
130
129
|
secondaryButton: _types.buttonType,
|
|
131
130
|
timeDuration: _propTypes.number,
|
|
132
|
-
topRight: _propTypes.bool,
|
|
133
131
|
variant: (0, _propTypes.oneOf)(Object.values(_constants.VARIANTS)),
|
|
134
132
|
withoutIcon: _propTypes.bool
|
|
135
133
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.WhiteVariants = exports.TopRight = exports.Test = exports.SinIcono = exports.SemanticLight = exports.SemanticDark = exports.Playground = exports.ConMarkdown = exports.ConDescripcion = exports.ConAcciones = exports.ConAccionPrimaria = exports.AllVariants = void 0;
|
|
6
|
+
exports.default = exports.WhiteVariants = exports.TopRight = exports.TopLeft = exports.Test = exports.SinIcono = exports.SemanticLight = exports.SemanticDark = exports.Playground = exports.ConMarkdown = exports.ConDescripcion = exports.ConAcciones = exports.ConAccionPrimaria = exports.BottomRight = exports.AllVariants = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _UTButton = _interopRequireDefault(require("../../UTButton"));
|
|
9
9
|
var _ = _interopRequireDefault(require(".."));
|
|
@@ -88,8 +88,8 @@ var _default = exports.default = {
|
|
|
88
88
|
message: 'Operación realizada exitosamente.',
|
|
89
89
|
open: true,
|
|
90
90
|
colorTheme: _constants.DEFAULT_PROPS.colorTheme,
|
|
91
|
+
position: _constants.DEFAULT_PROPS.position,
|
|
91
92
|
variant: _constants.DEFAULT_PROPS.variant,
|
|
92
|
-
topRight: _constants.DEFAULT_PROPS.topRight,
|
|
93
93
|
withoutIcon: false,
|
|
94
94
|
icon: undefined,
|
|
95
95
|
timeDuration: undefined,
|
|
@@ -252,14 +252,48 @@ const TopRight = exports.TopRight = {
|
|
|
252
252
|
message: 'Esta notificación aparece en la esquina superior derecha.',
|
|
253
253
|
open: true,
|
|
254
254
|
colorTheme: _constants.COLOR_THEMES.info,
|
|
255
|
-
|
|
256
|
-
|
|
255
|
+
position: _constants.POSITIONS.topRight,
|
|
256
|
+
variant: _constants.VARIANTS.dark
|
|
257
257
|
},
|
|
258
258
|
name: 'Posición Superior Derecha',
|
|
259
259
|
parameters: {
|
|
260
260
|
docs: {
|
|
261
261
|
description: {
|
|
262
|
-
story: 'Con `topRight
|
|
262
|
+
story: 'Con `position="topRight"` el snackbar aparece en la esquina superior derecha con slide desde la derecha.'
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
const BottomRight = exports.BottomRight = {
|
|
268
|
+
args: {
|
|
269
|
+
message: 'Esta notificación aparece en la esquina inferior derecha.',
|
|
270
|
+
open: true,
|
|
271
|
+
colorTheme: _constants.COLOR_THEMES.success,
|
|
272
|
+
position: _constants.POSITIONS.bottomRight,
|
|
273
|
+
variant: _constants.VARIANTS.dark
|
|
274
|
+
},
|
|
275
|
+
name: 'Posición Inferior Derecha',
|
|
276
|
+
parameters: {
|
|
277
|
+
docs: {
|
|
278
|
+
description: {
|
|
279
|
+
story: 'Con `position="bottomRight"` el snackbar aparece en la esquina inferior derecha con slide desde abajo.'
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
const TopLeft = exports.TopLeft = {
|
|
285
|
+
args: {
|
|
286
|
+
message: 'Esta notificación aparece en la esquina superior izquierda.',
|
|
287
|
+
open: true,
|
|
288
|
+
colorTheme: _constants.COLOR_THEMES.warning,
|
|
289
|
+
position: _constants.POSITIONS.topLeft,
|
|
290
|
+
variant: _constants.VARIANTS.dark
|
|
291
|
+
},
|
|
292
|
+
name: 'Posición Superior Izquierda',
|
|
293
|
+
parameters: {
|
|
294
|
+
docs: {
|
|
295
|
+
description: {
|
|
296
|
+
story: 'Con `position="topLeft"` el snackbar aparece en la esquina superior izquierda con slide desde arriba.'
|
|
263
297
|
}
|
|
264
298
|
}
|
|
265
299
|
}
|
|
@@ -128,15 +128,16 @@ const ARG_TYPES = exports.ARG_TYPES = {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
},
|
|
131
|
-
|
|
132
|
-
control: '
|
|
133
|
-
description: '
|
|
131
|
+
position: {
|
|
132
|
+
control: 'select',
|
|
133
|
+
description: 'Posición del snackbar en la pantalla.',
|
|
134
|
+
options: Object.values(_constants.POSITIONS),
|
|
134
135
|
table: {
|
|
135
136
|
defaultValue: {
|
|
136
|
-
summary:
|
|
137
|
+
summary: _constants.POSITIONS.bottomLeft
|
|
137
138
|
},
|
|
138
139
|
type: {
|
|
139
|
-
summary:
|
|
140
|
+
summary: (0, _utils.joinArgTypes)(Object.values(_constants.POSITIONS))
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
143
|
},
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getAnchorAndTransition = void 0;
|
|
7
|
+
var _constants = require("./constants");
|
|
8
|
+
const ANCHOR_TRANSITION_MAP = {
|
|
9
|
+
[_constants.POSITIONS.bottomLeft]: {
|
|
10
|
+
anchor: {
|
|
11
|
+
horizontal: 'left',
|
|
12
|
+
vertical: 'bottom'
|
|
13
|
+
},
|
|
14
|
+
transition: {
|
|
15
|
+
direction: 'up'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
[_constants.POSITIONS.bottomRight]: {
|
|
19
|
+
anchor: {
|
|
20
|
+
horizontal: 'right',
|
|
21
|
+
vertical: 'bottom'
|
|
22
|
+
},
|
|
23
|
+
transition: {
|
|
24
|
+
direction: 'up'
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
[_constants.POSITIONS.topLeft]: {
|
|
28
|
+
anchor: {
|
|
29
|
+
horizontal: 'left',
|
|
30
|
+
vertical: 'top'
|
|
31
|
+
},
|
|
32
|
+
transition: {
|
|
33
|
+
direction: 'down'
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
[_constants.POSITIONS.topRight]: {
|
|
37
|
+
anchor: {
|
|
38
|
+
horizontal: 'right',
|
|
39
|
+
vertical: 'top'
|
|
40
|
+
},
|
|
41
|
+
transition: {
|
|
42
|
+
direction: 'left'
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Devuelve anchorOrigin y TransitionProps para el Snackbar según la posición indicada.
|
|
49
|
+
* @param {string} position - Posición del snackbar (bottomLeft, bottomRight, topLeft, topRight).
|
|
50
|
+
* @returns {{ anchor: { horizontal: string, vertical: string }, transition: { direction: string } }}
|
|
51
|
+
*/
|
|
52
|
+
const getAnchorAndTransition = position => ANCHOR_TRANSITION_MAP[position] || ANCHOR_TRANSITION_MAP[_constants.POSITIONS.bottomLeft];
|
|
53
|
+
exports.getAnchorAndTransition = getAnchorAndTransition;
|
|
@@ -15,6 +15,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
15
15
|
const PageSizeSelector = _ref => {
|
|
16
16
|
let {
|
|
17
17
|
classes,
|
|
18
|
+
dataTestId,
|
|
18
19
|
options,
|
|
19
20
|
rowsPerPage,
|
|
20
21
|
onChangeRowPerPage,
|
|
@@ -27,12 +28,14 @@ const PageSizeSelector = _ref => {
|
|
|
27
28
|
className: _stylesModule.default.selectorContainer
|
|
28
29
|
}, /*#__PURE__*/_react.default.createElement(_UTSelect.default, {
|
|
29
30
|
options: (0, _utils.getPageSizeOptions)(options, totalRows),
|
|
31
|
+
dataTestId: dataTestId,
|
|
30
32
|
labelKey: "label",
|
|
31
33
|
valueKey: "value",
|
|
32
34
|
input: {
|
|
33
35
|
onChange: onChangeRowPerPage,
|
|
34
36
|
value: rowsPerPage
|
|
35
37
|
},
|
|
38
|
+
itemDataTestId: dataTestId ? "".concat(dataTestId, ".option") : undefined,
|
|
36
39
|
disableFirstOption: true,
|
|
37
40
|
variant: "outlined",
|
|
38
41
|
selectProps: {
|
|
@@ -47,6 +50,7 @@ const PageSizeSelector = _ref => {
|
|
|
47
50
|
};
|
|
48
51
|
PageSizeSelector.propTypes = {
|
|
49
52
|
classes: _types.classesType,
|
|
53
|
+
dataTestId: _propTypes.string,
|
|
50
54
|
options: (0, _propTypes.arrayOf)(_propTypes.number),
|
|
51
55
|
rowsPerPage: _propTypes.number,
|
|
52
56
|
onChangeRowPerPage: _propTypes.func,
|
|
@@ -22,19 +22,22 @@ const TableFooter = _ref => {
|
|
|
22
22
|
rowsPerPage,
|
|
23
23
|
rowsPerPageOptions,
|
|
24
24
|
hidePageSelector = false,
|
|
25
|
+
paginatorDataTestId,
|
|
25
26
|
totalRows,
|
|
26
27
|
totalRowsLabel,
|
|
27
28
|
isResponsive
|
|
28
29
|
} = _ref;
|
|
29
30
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
30
|
-
className: _stylesModule.default.tableFooter
|
|
31
|
+
className: _stylesModule.default.tableFooter,
|
|
32
|
+
"data-testid": paginatorDataTestId
|
|
31
33
|
}, !hidePageSelector && /*#__PURE__*/_react.default.createElement(_PageSizeSelector.default, {
|
|
32
34
|
classes: classes,
|
|
33
35
|
options: rowsPerPageOptions,
|
|
34
36
|
rowsPerPage: rowsPerPage,
|
|
35
37
|
onChangeRowPerPage: onChangeRowPerPage,
|
|
36
38
|
totalRows: totalRows,
|
|
37
|
-
label: "".concat(_constants.PREPOSITION, " ").concat(totalRows, " ").concat(totalRowsLabel)
|
|
39
|
+
label: "".concat(_constants.PREPOSITION, " ").concat(totalRows, " ").concat(totalRowsLabel),
|
|
40
|
+
dataTestId: paginatorDataTestId ? "".concat(paginatorDataTestId, ".pageSizeSelector") : undefined
|
|
38
41
|
}), /*#__PURE__*/_react.default.createElement(_Pagination.default, {
|
|
39
42
|
classes: classes,
|
|
40
43
|
currentPage: page,
|
|
@@ -52,6 +55,7 @@ TableFooter.propTypes = {
|
|
|
52
55
|
rowsPerPage: _propTypes.number,
|
|
53
56
|
rowsPerPageOptions: (0, _propTypes.arrayOf)(_propTypes.number),
|
|
54
57
|
hidePageSelector: _propTypes.bool,
|
|
58
|
+
paginatorDataTestId: _propTypes.string,
|
|
55
59
|
totalRows: _propTypes.number,
|
|
56
60
|
totalRowsLabel: _propTypes.string,
|
|
57
61
|
isResponsive: _propTypes.bool
|
|
@@ -78,6 +78,7 @@ const UTTable = _ref => {
|
|
|
78
78
|
mobileBreakpoint = _constants.DEFAULT_MOBILE_BREAKPOINT,
|
|
79
79
|
noResultDataTestId,
|
|
80
80
|
noResultsComponent,
|
|
81
|
+
paginatorDataTestId,
|
|
81
82
|
noResultsLabel = _constants.NO_RESULTS_LABEL,
|
|
82
83
|
onOrderChange,
|
|
83
84
|
onPageChange,
|
|
@@ -360,6 +361,7 @@ const UTTable = _ref => {
|
|
|
360
361
|
onChangeRowPerPage: onChangeRowPerPage,
|
|
361
362
|
hidePageSelector: hidePageSelector,
|
|
362
363
|
page: page,
|
|
364
|
+
paginatorDataTestId: paginatorDataTestId,
|
|
363
365
|
rowsPerPage: rowsPerPage,
|
|
364
366
|
rowsPerPageOptions: rowsPerPageOptions,
|
|
365
367
|
totalRows: totalRows || rows.length,
|
|
@@ -426,6 +428,7 @@ UTTable.propTypes = {
|
|
|
426
428
|
mobileBreakpoint: _propTypes.number,
|
|
427
429
|
noResultDataTestId: _propTypes.string,
|
|
428
430
|
noResultsComponent: _propTypes.node,
|
|
431
|
+
paginatorDataTestId: _propTypes.string,
|
|
429
432
|
noResultsLabel: _propTypes.string,
|
|
430
433
|
onOrderChange: _propTypes.func,
|
|
431
434
|
onPageChange: _propTypes.func,
|
|
@@ -18,7 +18,7 @@ Componente de notificación tipo Snackbar. Soporta cinco `colorTheme`: los cuatr
|
|
|
18
18
|
| `description` | `string` | `undefined` | Texto secundario debajo del mensaje principal. |
|
|
19
19
|
| `icon` | `string` | `undefined` | Nombre de ícono Tabler para sobreescribir el ícono por defecto (ej: `IconStar`). |
|
|
20
20
|
| `withoutIcon` | `boolean` | `undefined` | Oculta el ícono. |
|
|
21
|
-
| `
|
|
21
|
+
| `position` | `'bottomLeft' \| 'bottomRight' \| 'topLeft' \| 'topRight'` | `'bottomLeft'` | Posición del snackbar en la pantalla. Determina también la dirección del slide de entrada. |
|
|
22
22
|
| `timeDuration` | `number` | `undefined` | Duración en ms antes del cierre automático. |
|
|
23
23
|
| `onClose` | `function` | `undefined` | Callback al cerrar el snackbar. |
|
|
24
24
|
| `classes` | `object` | `{}` | Clases CSS personalizadas para sobrescribir estilos del tema. |
|
|
@@ -10,10 +10,16 @@ export const VARIANTS = {
|
|
|
10
10
|
dark: 'dark',
|
|
11
11
|
light: 'light'
|
|
12
12
|
};
|
|
13
|
+
export const POSITIONS = {
|
|
14
|
+
bottomLeft: 'bottomLeft',
|
|
15
|
+
bottomRight: 'bottomRight',
|
|
16
|
+
topLeft: 'topLeft',
|
|
17
|
+
topRight: 'topRight'
|
|
18
|
+
};
|
|
13
19
|
export const DEFAULT_PROPS = {
|
|
14
20
|
colorTheme: COLOR_THEMES.success,
|
|
15
21
|
open: false,
|
|
16
|
-
|
|
22
|
+
position: POSITIONS.bottomLeft,
|
|
17
23
|
variant: VARIANTS.dark
|
|
18
24
|
};
|
|
19
25
|
export const VARIANT_CLASS_MAP = {
|
|
@@ -8,7 +8,8 @@ import UTIcon from '../UTIcon';
|
|
|
8
8
|
import UTLabel from '../UTLabel';
|
|
9
9
|
import WithTheme from '../WithTheme';
|
|
10
10
|
import { ID_CONSTANTS } from '../../constants/testIds';
|
|
11
|
-
import { ACTION_BUTTON_CONFIG_MAP, COLOR_THEMES, DEFAULT_PROPS, ICON_NAME_MAP, LABEL_COLOR_MAP, VARIANT_CLASS_MAP, VARIANTS } from './constants';
|
|
11
|
+
import { ACTION_BUTTON_CONFIG_MAP, COLOR_THEMES, DEFAULT_PROPS, ICON_NAME_MAP, LABEL_COLOR_MAP, POSITIONS, VARIANT_CLASS_MAP, VARIANTS } from './constants';
|
|
12
|
+
import { getAnchorAndTransition } from './utils';
|
|
12
13
|
import { retrieveMuiTheme } from './theme';
|
|
13
14
|
import { buttonType } from './types';
|
|
14
15
|
import styles from './styles.module.scss';
|
|
@@ -22,9 +23,9 @@ const UTSnackbar = _ref => {
|
|
|
22
23
|
message,
|
|
23
24
|
onClose,
|
|
24
25
|
open = DEFAULT_PROPS.open,
|
|
26
|
+
position = DEFAULT_PROPS.position,
|
|
25
27
|
secondaryButton,
|
|
26
28
|
timeDuration,
|
|
27
|
-
topRight = DEFAULT_PROPS.topRight,
|
|
28
29
|
variant = DEFAULT_PROPS.variant,
|
|
29
30
|
withoutIcon
|
|
30
31
|
} = _ref;
|
|
@@ -38,13 +39,10 @@ const UTSnackbar = _ref => {
|
|
|
38
39
|
const labelColorConfig = LABEL_COLOR_MAP[variantClassKey] || LABEL_COLOR_MAP.successDark;
|
|
39
40
|
const actionButtonConfig = ACTION_BUTTON_CONFIG_MAP[variantClassKey];
|
|
40
41
|
const iconName = withoutIcon ? null : icon || ICON_NAME_MAP[colorTheme];
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
-
const transition = {
|
|
46
|
-
direction: topRight ? 'left' : 'up'
|
|
47
|
-
};
|
|
42
|
+
const {
|
|
43
|
+
anchor,
|
|
44
|
+
transition
|
|
45
|
+
} = getAnchorAndTransition(position);
|
|
48
46
|
const testIds = {
|
|
49
47
|
close: dataTestId ? "".concat(dataTestId, ".close") : undefined,
|
|
50
48
|
description: dataTestId ? "".concat(dataTestId, ".").concat(ID_CONSTANTS.DESCRIPTION, ".").concat(ID_CONSTANTS.LABEL) : undefined,
|
|
@@ -120,9 +118,9 @@ UTSnackbar.propTypes = {
|
|
|
120
118
|
message: string,
|
|
121
119
|
onClose: func,
|
|
122
120
|
open: bool,
|
|
121
|
+
position: oneOf(Object.values(POSITIONS)),
|
|
123
122
|
secondaryButton: buttonType,
|
|
124
123
|
timeDuration: number,
|
|
125
|
-
topRight: bool,
|
|
126
124
|
variant: oneOf(Object.values(VARIANTS)),
|
|
127
125
|
withoutIcon: bool
|
|
128
126
|
};
|
|
@@ -2,7 +2,7 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
3
|
import UTButton from '../../UTButton';
|
|
4
4
|
import UTSnackbar from '..';
|
|
5
|
-
import { COLOR_THEMES, DEFAULT_PROPS, VARIANTS } from '../constants';
|
|
5
|
+
import { COLOR_THEMES, DEFAULT_PROPS, POSITIONS, VARIANTS } from '../constants';
|
|
6
6
|
import { ARG_TYPES } from './storiesConstants';
|
|
7
7
|
const SEMANTIC_COLOR_THEMES = [COLOR_THEMES.success, COLOR_THEMES.error, COLOR_THEMES.warning, COLOR_THEMES.info];
|
|
8
8
|
const AllTypesDemo = () => {
|
|
@@ -80,8 +80,8 @@ export default {
|
|
|
80
80
|
message: 'Operación realizada exitosamente.',
|
|
81
81
|
open: true,
|
|
82
82
|
colorTheme: DEFAULT_PROPS.colorTheme,
|
|
83
|
+
position: DEFAULT_PROPS.position,
|
|
83
84
|
variant: DEFAULT_PROPS.variant,
|
|
84
|
-
topRight: DEFAULT_PROPS.topRight,
|
|
85
85
|
withoutIcon: false,
|
|
86
86
|
icon: undefined,
|
|
87
87
|
timeDuration: undefined,
|
|
@@ -244,14 +244,48 @@ export const TopRight = {
|
|
|
244
244
|
message: 'Esta notificación aparece en la esquina superior derecha.',
|
|
245
245
|
open: true,
|
|
246
246
|
colorTheme: COLOR_THEMES.info,
|
|
247
|
-
|
|
248
|
-
|
|
247
|
+
position: POSITIONS.topRight,
|
|
248
|
+
variant: VARIANTS.dark
|
|
249
249
|
},
|
|
250
250
|
name: 'Posición Superior Derecha',
|
|
251
251
|
parameters: {
|
|
252
252
|
docs: {
|
|
253
253
|
description: {
|
|
254
|
-
story: 'Con `topRight
|
|
254
|
+
story: 'Con `position="topRight"` el snackbar aparece en la esquina superior derecha con slide desde la derecha.'
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
export const BottomRight = {
|
|
260
|
+
args: {
|
|
261
|
+
message: 'Esta notificación aparece en la esquina inferior derecha.',
|
|
262
|
+
open: true,
|
|
263
|
+
colorTheme: COLOR_THEMES.success,
|
|
264
|
+
position: POSITIONS.bottomRight,
|
|
265
|
+
variant: VARIANTS.dark
|
|
266
|
+
},
|
|
267
|
+
name: 'Posición Inferior Derecha',
|
|
268
|
+
parameters: {
|
|
269
|
+
docs: {
|
|
270
|
+
description: {
|
|
271
|
+
story: 'Con `position="bottomRight"` el snackbar aparece en la esquina inferior derecha con slide desde abajo.'
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
export const TopLeft = {
|
|
277
|
+
args: {
|
|
278
|
+
message: 'Esta notificación aparece en la esquina superior izquierda.',
|
|
279
|
+
open: true,
|
|
280
|
+
colorTheme: COLOR_THEMES.warning,
|
|
281
|
+
position: POSITIONS.topLeft,
|
|
282
|
+
variant: VARIANTS.dark
|
|
283
|
+
},
|
|
284
|
+
name: 'Posición Superior Izquierda',
|
|
285
|
+
parameters: {
|
|
286
|
+
docs: {
|
|
287
|
+
description: {
|
|
288
|
+
story: 'Con `position="topLeft"` el snackbar aparece en la esquina superior izquierda con slide desde arriba.'
|
|
255
289
|
}
|
|
256
290
|
}
|
|
257
291
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { joinArgTypes } from 'stories/utils';
|
|
2
|
-
import { COLOR_THEMES, VARIANTS } from '../constants';
|
|
2
|
+
import { COLOR_THEMES, POSITIONS, VARIANTS } from '../constants';
|
|
3
3
|
export const ARG_TYPES = {
|
|
4
4
|
button: {
|
|
5
5
|
control: 'object',
|
|
@@ -122,15 +122,16 @@ export const ARG_TYPES = {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
},
|
|
125
|
-
|
|
126
|
-
control: '
|
|
127
|
-
description: '
|
|
125
|
+
position: {
|
|
126
|
+
control: 'select',
|
|
127
|
+
description: 'Posición del snackbar en la pantalla.',
|
|
128
|
+
options: Object.values(POSITIONS),
|
|
128
129
|
table: {
|
|
129
130
|
defaultValue: {
|
|
130
|
-
summary:
|
|
131
|
+
summary: POSITIONS.bottomLeft
|
|
131
132
|
},
|
|
132
133
|
type: {
|
|
133
|
-
summary:
|
|
134
|
+
summary: joinArgTypes(Object.values(POSITIONS))
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
137
|
},
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { POSITIONS } from './constants';
|
|
2
|
+
const ANCHOR_TRANSITION_MAP = {
|
|
3
|
+
[POSITIONS.bottomLeft]: {
|
|
4
|
+
anchor: {
|
|
5
|
+
horizontal: 'left',
|
|
6
|
+
vertical: 'bottom'
|
|
7
|
+
},
|
|
8
|
+
transition: {
|
|
9
|
+
direction: 'up'
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
[POSITIONS.bottomRight]: {
|
|
13
|
+
anchor: {
|
|
14
|
+
horizontal: 'right',
|
|
15
|
+
vertical: 'bottom'
|
|
16
|
+
},
|
|
17
|
+
transition: {
|
|
18
|
+
direction: 'up'
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
[POSITIONS.topLeft]: {
|
|
22
|
+
anchor: {
|
|
23
|
+
horizontal: 'left',
|
|
24
|
+
vertical: 'top'
|
|
25
|
+
},
|
|
26
|
+
transition: {
|
|
27
|
+
direction: 'down'
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
[POSITIONS.topRight]: {
|
|
31
|
+
anchor: {
|
|
32
|
+
horizontal: 'right',
|
|
33
|
+
vertical: 'top'
|
|
34
|
+
},
|
|
35
|
+
transition: {
|
|
36
|
+
direction: 'left'
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Devuelve anchorOrigin y TransitionProps para el Snackbar según la posición indicada.
|
|
43
|
+
* @param {string} position - Posición del snackbar (bottomLeft, bottomRight, topLeft, topRight).
|
|
44
|
+
* @returns {{ anchor: { horizontal: string, vertical: string }, transition: { direction: string } }}
|
|
45
|
+
*/
|
|
46
|
+
export const getAnchorAndTransition = position => ANCHOR_TRANSITION_MAP[position] || ANCHOR_TRANSITION_MAP[POSITIONS.bottomLeft];
|
package/dist/esm/components/UTTable/components/TableFooter/components/PageSizeSelector/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import styles from './styles.module.scss';
|
|
|
8
8
|
const PageSizeSelector = _ref => {
|
|
9
9
|
let {
|
|
10
10
|
classes,
|
|
11
|
+
dataTestId,
|
|
11
12
|
options,
|
|
12
13
|
rowsPerPage,
|
|
13
14
|
onChangeRowPerPage,
|
|
@@ -20,12 +21,14 @@ const PageSizeSelector = _ref => {
|
|
|
20
21
|
className: styles.selectorContainer
|
|
21
22
|
}, /*#__PURE__*/React.createElement(UTSelect, {
|
|
22
23
|
options: getPageSizeOptions(options, totalRows),
|
|
24
|
+
dataTestId: dataTestId,
|
|
23
25
|
labelKey: "label",
|
|
24
26
|
valueKey: "value",
|
|
25
27
|
input: {
|
|
26
28
|
onChange: onChangeRowPerPage,
|
|
27
29
|
value: rowsPerPage
|
|
28
30
|
},
|
|
31
|
+
itemDataTestId: dataTestId ? "".concat(dataTestId, ".option") : undefined,
|
|
29
32
|
disableFirstOption: true,
|
|
30
33
|
variant: "outlined",
|
|
31
34
|
selectProps: {
|
|
@@ -40,6 +43,7 @@ const PageSizeSelector = _ref => {
|
|
|
40
43
|
};
|
|
41
44
|
PageSizeSelector.propTypes = {
|
|
42
45
|
classes: classesType,
|
|
46
|
+
dataTestId: string,
|
|
43
47
|
options: arrayOf(number),
|
|
44
48
|
rowsPerPage: number,
|
|
45
49
|
onChangeRowPerPage: func,
|
|
@@ -14,19 +14,22 @@ const TableFooter = _ref => {
|
|
|
14
14
|
rowsPerPage,
|
|
15
15
|
rowsPerPageOptions,
|
|
16
16
|
hidePageSelector = false,
|
|
17
|
+
paginatorDataTestId,
|
|
17
18
|
totalRows,
|
|
18
19
|
totalRowsLabel,
|
|
19
20
|
isResponsive
|
|
20
21
|
} = _ref;
|
|
21
22
|
return /*#__PURE__*/React.createElement("div", {
|
|
22
|
-
className: styles.tableFooter
|
|
23
|
+
className: styles.tableFooter,
|
|
24
|
+
"data-testid": paginatorDataTestId
|
|
23
25
|
}, !hidePageSelector && /*#__PURE__*/React.createElement(PageSizeSelector, {
|
|
24
26
|
classes: classes,
|
|
25
27
|
options: rowsPerPageOptions,
|
|
26
28
|
rowsPerPage: rowsPerPage,
|
|
27
29
|
onChangeRowPerPage: onChangeRowPerPage,
|
|
28
30
|
totalRows: totalRows,
|
|
29
|
-
label: "".concat(PREPOSITION, " ").concat(totalRows, " ").concat(totalRowsLabel)
|
|
31
|
+
label: "".concat(PREPOSITION, " ").concat(totalRows, " ").concat(totalRowsLabel),
|
|
32
|
+
dataTestId: paginatorDataTestId ? "".concat(paginatorDataTestId, ".pageSizeSelector") : undefined
|
|
30
33
|
}), /*#__PURE__*/React.createElement(Pagination, {
|
|
31
34
|
classes: classes,
|
|
32
35
|
currentPage: page,
|
|
@@ -44,6 +47,7 @@ TableFooter.propTypes = {
|
|
|
44
47
|
rowsPerPage: number,
|
|
45
48
|
rowsPerPageOptions: arrayOf(number),
|
|
46
49
|
hidePageSelector: bool,
|
|
50
|
+
paginatorDataTestId: string,
|
|
47
51
|
totalRows: number,
|
|
48
52
|
totalRowsLabel: string,
|
|
49
53
|
isResponsive: bool
|
|
@@ -70,6 +70,7 @@ const UTTable = _ref => {
|
|
|
70
70
|
mobileBreakpoint = DEFAULT_MOBILE_BREAKPOINT,
|
|
71
71
|
noResultDataTestId,
|
|
72
72
|
noResultsComponent,
|
|
73
|
+
paginatorDataTestId,
|
|
73
74
|
noResultsLabel = NO_RESULTS_LABEL,
|
|
74
75
|
onOrderChange,
|
|
75
76
|
onPageChange,
|
|
@@ -352,6 +353,7 @@ const UTTable = _ref => {
|
|
|
352
353
|
onChangeRowPerPage: onChangeRowPerPage,
|
|
353
354
|
hidePageSelector: hidePageSelector,
|
|
354
355
|
page: page,
|
|
356
|
+
paginatorDataTestId: paginatorDataTestId,
|
|
355
357
|
rowsPerPage: rowsPerPage,
|
|
356
358
|
rowsPerPageOptions: rowsPerPageOptions,
|
|
357
359
|
totalRows: totalRows || rows.length,
|
|
@@ -418,6 +420,7 @@ UTTable.propTypes = {
|
|
|
418
420
|
mobileBreakpoint: number,
|
|
419
421
|
noResultDataTestId: string,
|
|
420
422
|
noResultsComponent: node,
|
|
423
|
+
paginatorDataTestId: string,
|
|
421
424
|
noResultsLabel: string,
|
|
422
425
|
onOrderChange: func,
|
|
423
426
|
onPageChange: func,
|