@widergy/energy-ui 3.165.0 → 3.165.1
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 +9 -3
- 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/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/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
## [3.165.1](https://github.com/widergy/energy-ui/compare/v3.165.0...v3.165.1) (2026-06-12)
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
###
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* added prop position to snackbar ([#818](https://github.com/widergy/energy-ui/issues/818)) ([676e43c](https://github.com/widergy/energy-ui/commit/676e43c4d625578b074506867879b0b8bdbe75ea))
|
|
7
|
+
|
|
8
|
+
# [3.165.0](https://github.com/widergy/energy-ui/compare/v3.164.0...v3.165.0) (2026-06-10)
|
|
9
|
+
|
|
10
|
+
### Novedades y Mejoras
|
|
5
11
|
|
|
6
|
-
*
|
|
12
|
+
* 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
13
|
|
|
8
14
|
# [3.164.0](https://github.com/widergy/energy-ui/compare/v3.163.0...v3.164.0) (2026-06-09)
|
|
9
15
|
|
|
@@ -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;
|
|
@@ -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];
|