@widergy/energy-ui 3.164.0 → 3.165.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 +10 -5
- package/dist/components/UTAlert/README.md +100 -0
- package/dist/components/UTAlert/stories/UTAlert.stories.js +239 -0
- package/dist/components/UTAlert/stories/storiesConstants.js +107 -0
- package/dist/components/UTBanner/index.js +11 -5
- package/dist/components/UTBanner/stories/UTBanner.stories.js +8 -0
- package/dist/components/UTBaseInputField/UTBaseInputField.stories.js +393 -0
- package/dist/components/UTSnackbar/README.md +105 -0
- package/dist/components/UTSnackbar/constants.js +128 -0
- package/dist/components/UTSnackbar/index.js +136 -0
- package/dist/components/UTSnackbar/stories/UTSnackbar.stories.js +316 -0
- package/dist/components/UTSnackbar/stories/storiesConstants.js +168 -0
- package/dist/components/UTSnackbar/styles.module.scss +82 -0
- package/dist/components/UTSnackbar/theme.js +57 -0
- package/dist/components/UTSnackbar/types.js +20 -0
- package/dist/components/UTTextArea/UTTextArea.stories.js +342 -0
- package/dist/components/UTTextInput/UTTextInput.stories.js +439 -0
- package/dist/constants/testIds.js +9 -0
- package/dist/esm/components/UTAlert/README.md +100 -0
- package/dist/esm/components/UTAlert/stories/UTAlert.stories.js +231 -0
- package/dist/esm/components/UTAlert/stories/storiesConstants.js +101 -0
- package/dist/esm/components/UTBanner/index.js +11 -5
- package/dist/esm/components/UTBanner/stories/UTBanner.stories.js +8 -0
- package/dist/esm/components/UTBaseInputField/UTBaseInputField.stories.js +385 -0
- package/dist/esm/components/UTSnackbar/README.md +105 -0
- package/dist/esm/components/UTSnackbar/constants.js +122 -0
- package/dist/esm/components/UTSnackbar/index.js +129 -0
- package/dist/esm/components/UTSnackbar/stories/UTSnackbar.stories.js +308 -0
- package/dist/esm/components/UTSnackbar/stories/storiesConstants.js +162 -0
- package/dist/esm/components/UTSnackbar/styles.module.scss +82 -0
- package/dist/esm/components/UTSnackbar/theme.js +50 -0
- package/dist/esm/components/UTSnackbar/types.js +14 -0
- package/dist/esm/components/UTTextArea/UTTextArea.stories.js +334 -0
- package/dist/esm/components/UTTextInput/UTTextInput.stories.js +431 -0
- package/dist/esm/constants/testIds.js +9 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/utils/hooks/useCSSVariables/constants.js +9 -0
- package/dist/index.js +7 -0
- package/dist/utils/hooks/useCSSVariables/constants.js +9 -0
- package/package.json +1 -1
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { bool, func, number, oneOf, string } from 'prop-types';
|
|
4
|
+
import Slide from '@material-ui/core/Slide';
|
|
5
|
+
import Snackbar from '@material-ui/core/Snackbar';
|
|
6
|
+
import UTButton from '../UTButton';
|
|
7
|
+
import UTIcon from '../UTIcon';
|
|
8
|
+
import UTLabel from '../UTLabel';
|
|
9
|
+
import WithTheme from '../WithTheme';
|
|
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';
|
|
12
|
+
import { retrieveMuiTheme } from './theme';
|
|
13
|
+
import { buttonType } from './types';
|
|
14
|
+
import styles from './styles.module.scss';
|
|
15
|
+
const UTSnackbar = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
button,
|
|
18
|
+
colorTheme = DEFAULT_PROPS.colorTheme,
|
|
19
|
+
dataTestId,
|
|
20
|
+
description,
|
|
21
|
+
icon,
|
|
22
|
+
message,
|
|
23
|
+
onClose,
|
|
24
|
+
open = DEFAULT_PROPS.open,
|
|
25
|
+
secondaryButton,
|
|
26
|
+
timeDuration,
|
|
27
|
+
topRight = DEFAULT_PROPS.topRight,
|
|
28
|
+
variant = DEFAULT_PROPS.variant,
|
|
29
|
+
withoutIcon
|
|
30
|
+
} = _ref;
|
|
31
|
+
const handleClose = (_, reason) => {
|
|
32
|
+
if (reason === 'clickaway') return;
|
|
33
|
+
onClose === null || onClose === void 0 || onClose();
|
|
34
|
+
};
|
|
35
|
+
const variantKey = "".concat(colorTheme, "-").concat(variant);
|
|
36
|
+
const variantClassKey = VARIANT_CLASS_MAP[variantKey];
|
|
37
|
+
const variantClass = styles[variantClassKey] || '';
|
|
38
|
+
const labelColorConfig = LABEL_COLOR_MAP[variantClassKey] || LABEL_COLOR_MAP.successDark;
|
|
39
|
+
const actionButtonConfig = ACTION_BUTTON_CONFIG_MAP[variantClassKey];
|
|
40
|
+
const iconName = withoutIcon ? null : icon || ICON_NAME_MAP[colorTheme];
|
|
41
|
+
const anchor = {
|
|
42
|
+
horizontal: topRight ? 'right' : 'left',
|
|
43
|
+
vertical: topRight ? 'top' : 'bottom'
|
|
44
|
+
};
|
|
45
|
+
const transition = {
|
|
46
|
+
direction: topRight ? 'left' : 'up'
|
|
47
|
+
};
|
|
48
|
+
const testIds = {
|
|
49
|
+
close: dataTestId ? "".concat(dataTestId, ".close") : undefined,
|
|
50
|
+
description: dataTestId ? "".concat(dataTestId, ".").concat(ID_CONSTANTS.DESCRIPTION, ".").concat(ID_CONSTANTS.LABEL) : undefined,
|
|
51
|
+
icon: dataTestId ? "".concat(dataTestId, ".").concat(ID_CONSTANTS.ICON) : undefined,
|
|
52
|
+
label: dataTestId ? "".concat(dataTestId, ".").concat(ID_CONSTANTS.LABEL) : undefined,
|
|
53
|
+
primaryButton: dataTestId ? "".concat(dataTestId, ".button.").concat(ID_CONSTANTS.SECONDARY_ACTION) : undefined,
|
|
54
|
+
secondaryButton: dataTestId ? "".concat(dataTestId, ".secondaryButton.").concat(ID_CONSTANTS.TERTIARY_ACTION) : undefined
|
|
55
|
+
};
|
|
56
|
+
return /*#__PURE__*/React.createElement(Snackbar, {
|
|
57
|
+
action: [!!secondaryButton && /*#__PURE__*/React.createElement(UTButton, _extends({
|
|
58
|
+
key: "secondary",
|
|
59
|
+
colorTheme: actionButtonConfig.colorTheme
|
|
60
|
+
}, secondaryButton, {
|
|
61
|
+
dataTestId: testIds.secondaryButton
|
|
62
|
+
}), secondaryButton.title), !!button && /*#__PURE__*/React.createElement(UTButton, _extends({
|
|
63
|
+
key: "primary",
|
|
64
|
+
colorTheme: actionButtonConfig.colorTheme
|
|
65
|
+
}, button, {
|
|
66
|
+
dataTestId: testIds.primaryButton
|
|
67
|
+
}), button.title), /*#__PURE__*/React.createElement(UTButton, {
|
|
68
|
+
key: "close",
|
|
69
|
+
colorTheme: actionButtonConfig.closeColorTheme || actionButtonConfig.colorTheme,
|
|
70
|
+
dataTestId: testIds.close,
|
|
71
|
+
Icon: "IconX",
|
|
72
|
+
onClick: handleClose,
|
|
73
|
+
variant: actionButtonConfig.variant
|
|
74
|
+
})],
|
|
75
|
+
anchorOrigin: anchor,
|
|
76
|
+
autoHideDuration: timeDuration,
|
|
77
|
+
ContentProps: {
|
|
78
|
+
className: "".concat(styles.snackbarContent, " ").concat(variantClass),
|
|
79
|
+
classes: {
|
|
80
|
+
action: styles.action,
|
|
81
|
+
message: styles.message
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
message: /*#__PURE__*/React.createElement("div", {
|
|
85
|
+
className: styles.messageContent
|
|
86
|
+
}, iconName && /*#__PURE__*/React.createElement(UTIcon, {
|
|
87
|
+
className: styles.icon,
|
|
88
|
+
colorTheme: labelColorConfig.colorTheme,
|
|
89
|
+
dataTestId: testIds.icon,
|
|
90
|
+
name: iconName,
|
|
91
|
+
shade: labelColorConfig.shade,
|
|
92
|
+
size: 20
|
|
93
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
94
|
+
className: styles.textContent
|
|
95
|
+
}, /*#__PURE__*/React.createElement(UTLabel, {
|
|
96
|
+
colorTheme: labelColorConfig.colorTheme,
|
|
97
|
+
dataTestId: testIds.label,
|
|
98
|
+
shade: labelColorConfig.shade,
|
|
99
|
+
variant: "body",
|
|
100
|
+
weight: "medium",
|
|
101
|
+
withMarkdown: true
|
|
102
|
+
}, message), description && /*#__PURE__*/React.createElement(UTLabel, {
|
|
103
|
+
colorTheme: labelColorConfig.colorTheme,
|
|
104
|
+
dataTestId: testIds.description,
|
|
105
|
+
shade: labelColorConfig.shade,
|
|
106
|
+
variant: "small"
|
|
107
|
+
}, description))),
|
|
108
|
+
onClose: handleClose,
|
|
109
|
+
open: open,
|
|
110
|
+
TransitionComponent: Slide,
|
|
111
|
+
TransitionProps: transition
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
UTSnackbar.propTypes = {
|
|
115
|
+
button: buttonType,
|
|
116
|
+
colorTheme: oneOf(Object.values(COLOR_THEMES)),
|
|
117
|
+
dataTestId: string,
|
|
118
|
+
description: string,
|
|
119
|
+
icon: string,
|
|
120
|
+
message: string,
|
|
121
|
+
onClose: func,
|
|
122
|
+
open: bool,
|
|
123
|
+
secondaryButton: buttonType,
|
|
124
|
+
timeDuration: number,
|
|
125
|
+
topRight: bool,
|
|
126
|
+
variant: oneOf(Object.values(VARIANTS)),
|
|
127
|
+
withoutIcon: bool
|
|
128
|
+
};
|
|
129
|
+
export default WithTheme(undefined, retrieveMuiTheme)(UTSnackbar);
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import UTButton from '../../UTButton';
|
|
4
|
+
import UTSnackbar from '..';
|
|
5
|
+
import { COLOR_THEMES, DEFAULT_PROPS, VARIANTS } from '../constants';
|
|
6
|
+
import { ARG_TYPES } from './storiesConstants';
|
|
7
|
+
const SEMANTIC_COLOR_THEMES = [COLOR_THEMES.success, COLOR_THEMES.error, COLOR_THEMES.warning, COLOR_THEMES.info];
|
|
8
|
+
const AllTypesDemo = () => {
|
|
9
|
+
const [snackState, setSnackState] = useState({
|
|
10
|
+
open: false
|
|
11
|
+
});
|
|
12
|
+
const show = function (colorTheme) {
|
|
13
|
+
let variant = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : VARIANTS.dark;
|
|
14
|
+
return setSnackState({
|
|
15
|
+
colorTheme,
|
|
16
|
+
message: "Alerta de tipo: ".concat(colorTheme),
|
|
17
|
+
open: true,
|
|
18
|
+
variant
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const handleClose = () => setSnackState(prev => ({
|
|
22
|
+
...prev,
|
|
23
|
+
open: false
|
|
24
|
+
}));
|
|
25
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
26
|
+
style: {
|
|
27
|
+
display: 'flex',
|
|
28
|
+
flexDirection: 'column',
|
|
29
|
+
gap: '8px',
|
|
30
|
+
maxWidth: '400px'
|
|
31
|
+
}
|
|
32
|
+
}, /*#__PURE__*/React.createElement("p", {
|
|
33
|
+
style: {
|
|
34
|
+
fontSize: '12px',
|
|
35
|
+
fontWeight: 600,
|
|
36
|
+
margin: '0 0 4px'
|
|
37
|
+
}
|
|
38
|
+
}, "Dark"), /*#__PURE__*/React.createElement("div", {
|
|
39
|
+
style: {
|
|
40
|
+
display: 'flex',
|
|
41
|
+
gap: '8px',
|
|
42
|
+
flexWrap: 'wrap'
|
|
43
|
+
}
|
|
44
|
+
}, SEMANTIC_COLOR_THEMES.map(colorTheme => /*#__PURE__*/React.createElement(UTButton, {
|
|
45
|
+
key: colorTheme,
|
|
46
|
+
onClick: () => show(colorTheme),
|
|
47
|
+
size: "small",
|
|
48
|
+
variant: "outlined"
|
|
49
|
+
}, colorTheme)), /*#__PURE__*/React.createElement(UTButton, {
|
|
50
|
+
onClick: () => show(COLOR_THEMES.white),
|
|
51
|
+
size: "small",
|
|
52
|
+
variant: "outlined"
|
|
53
|
+
}, "white")), /*#__PURE__*/React.createElement("p", {
|
|
54
|
+
style: {
|
|
55
|
+
fontSize: '12px',
|
|
56
|
+
fontWeight: 600,
|
|
57
|
+
margin: '8px 0 4px'
|
|
58
|
+
}
|
|
59
|
+
}, "Light"), /*#__PURE__*/React.createElement("div", {
|
|
60
|
+
style: {
|
|
61
|
+
display: 'flex',
|
|
62
|
+
gap: '8px',
|
|
63
|
+
flexWrap: 'wrap'
|
|
64
|
+
}
|
|
65
|
+
}, SEMANTIC_COLOR_THEMES.map(colorTheme => /*#__PURE__*/React.createElement(UTButton, {
|
|
66
|
+
key: colorTheme,
|
|
67
|
+
onClick: () => show(colorTheme, VARIANTS.light),
|
|
68
|
+
size: "small",
|
|
69
|
+
variant: "outlined"
|
|
70
|
+
}, colorTheme, " light")), /*#__PURE__*/React.createElement(UTButton, {
|
|
71
|
+
onClick: () => show(COLOR_THEMES.white, VARIANTS.light),
|
|
72
|
+
size: "small",
|
|
73
|
+
variant: "outlined"
|
|
74
|
+
}, "white light")), /*#__PURE__*/React.createElement(UTSnackbar, _extends({}, snackState, {
|
|
75
|
+
onClose: handleClose
|
|
76
|
+
})));
|
|
77
|
+
};
|
|
78
|
+
export default {
|
|
79
|
+
args: {
|
|
80
|
+
message: 'Operación realizada exitosamente.',
|
|
81
|
+
open: true,
|
|
82
|
+
colorTheme: DEFAULT_PROPS.colorTheme,
|
|
83
|
+
variant: DEFAULT_PROPS.variant,
|
|
84
|
+
topRight: DEFAULT_PROPS.topRight,
|
|
85
|
+
withoutIcon: false,
|
|
86
|
+
icon: undefined,
|
|
87
|
+
timeDuration: undefined,
|
|
88
|
+
button: undefined,
|
|
89
|
+
secondaryButton: undefined,
|
|
90
|
+
description: undefined
|
|
91
|
+
},
|
|
92
|
+
argTypes: ARG_TYPES,
|
|
93
|
+
component: UTSnackbar,
|
|
94
|
+
parameters: {
|
|
95
|
+
controls: {
|
|
96
|
+
exclude: ['dataTestId', 'onClose']
|
|
97
|
+
},
|
|
98
|
+
docs: {
|
|
99
|
+
description: {
|
|
100
|
+
component: 'Componente de notificación tipo Snackbar. Soporta cinco `colorTheme`: los cuatro semánticos (`success`, `error`, `warning`, `info`) y `white` para notificaciones neutras. La prop `variant` controla si el fondo es oscuro o claro.'
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
title: 'Energy-UI/UTSnackbar'
|
|
105
|
+
};
|
|
106
|
+
export const Playground = {
|
|
107
|
+
name: 'Playground'
|
|
108
|
+
};
|
|
109
|
+
export const AllVariants = {
|
|
110
|
+
name: 'Todas las Variantes',
|
|
111
|
+
parameters: {
|
|
112
|
+
docs: {
|
|
113
|
+
description: {
|
|
114
|
+
story: 'Hacé clic en cada botón para ver la variante correspondiente.'
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
render: () => /*#__PURE__*/React.createElement(AllTypesDemo, null)
|
|
119
|
+
};
|
|
120
|
+
export const SemanticDark = {
|
|
121
|
+
args: {
|
|
122
|
+
message: 'El archivo fue guardado correctamente.',
|
|
123
|
+
open: true,
|
|
124
|
+
colorTheme: COLOR_THEMES.success,
|
|
125
|
+
variant: VARIANTS.dark
|
|
126
|
+
},
|
|
127
|
+
name: 'Semántico / Dark',
|
|
128
|
+
parameters: {
|
|
129
|
+
docs: {
|
|
130
|
+
description: {
|
|
131
|
+
story: 'Fondo con el color semántico saturado y texto blanco. Cambiá `colorTheme` en el panel de controls para ver los cuatro tipos semánticos.'
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
export const SemanticLight = {
|
|
137
|
+
args: {
|
|
138
|
+
message: 'El archivo fue guardado correctamente.',
|
|
139
|
+
open: true,
|
|
140
|
+
colorTheme: COLOR_THEMES.success,
|
|
141
|
+
variant: VARIANTS.light
|
|
142
|
+
},
|
|
143
|
+
name: 'Semántico / Light',
|
|
144
|
+
parameters: {
|
|
145
|
+
docs: {
|
|
146
|
+
description: {
|
|
147
|
+
story: 'Fondo claro con texto oscuro accesible. Cambiá `colorTheme` para ver los cuatro tipos semánticos.'
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
export const WhiteVariants = {
|
|
153
|
+
args: {
|
|
154
|
+
message: 'Notificación sin semántica asociada.',
|
|
155
|
+
open: true,
|
|
156
|
+
colorTheme: COLOR_THEMES.white,
|
|
157
|
+
variant: VARIANTS.light
|
|
158
|
+
},
|
|
159
|
+
name: 'White',
|
|
160
|
+
parameters: {
|
|
161
|
+
docs: {
|
|
162
|
+
description: {
|
|
163
|
+
story: 'Variante neutra sin semántica de color. Con `variant="light"` el fondo es blanco; con `variant="dark"` el fondo es oscuro.'
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
export const ConAccionPrimaria = {
|
|
169
|
+
args: {
|
|
170
|
+
button: {
|
|
171
|
+
title: 'Deshacer'
|
|
172
|
+
},
|
|
173
|
+
message: 'Se eliminaron 3 elementos.',
|
|
174
|
+
open: true,
|
|
175
|
+
colorTheme: COLOR_THEMES.error,
|
|
176
|
+
variant: VARIANTS.dark
|
|
177
|
+
},
|
|
178
|
+
name: 'Con Acción Primaria',
|
|
179
|
+
parameters: {
|
|
180
|
+
docs: {
|
|
181
|
+
description: {
|
|
182
|
+
story: 'La prop `button` agrega un botón de texto a la derecha del mensaje. Pasar `onClick` dentro del objeto para manejar el evento.'
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
export const ConAcciones = {
|
|
188
|
+
args: {
|
|
189
|
+
button: {
|
|
190
|
+
title: 'Confirmar'
|
|
191
|
+
},
|
|
192
|
+
secondaryButton: {
|
|
193
|
+
title: 'Cancelar'
|
|
194
|
+
},
|
|
195
|
+
message: 'Se eliminaron 3 elementos.',
|
|
196
|
+
open: true,
|
|
197
|
+
colorTheme: COLOR_THEMES.error,
|
|
198
|
+
variant: VARIANTS.dark
|
|
199
|
+
},
|
|
200
|
+
name: 'Con Acciones Primaria y Secundaria',
|
|
201
|
+
parameters: {
|
|
202
|
+
docs: {
|
|
203
|
+
description: {
|
|
204
|
+
story: 'Con `button` y `secondaryButton` se muestran dos botones de acción. Cualquier prop de `UTButton` puede pasarse dentro del objeto para personalizar su comportamiento.'
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
export const ConDescripcion = {
|
|
210
|
+
args: {
|
|
211
|
+
message: 'El archivo fue guardado correctamente.',
|
|
212
|
+
description: 'Los cambios se aplicarán en la próxima sesión.',
|
|
213
|
+
open: true,
|
|
214
|
+
colorTheme: COLOR_THEMES.success,
|
|
215
|
+
variant: VARIANTS.light
|
|
216
|
+
},
|
|
217
|
+
name: 'Con Descripción',
|
|
218
|
+
parameters: {
|
|
219
|
+
docs: {
|
|
220
|
+
description: {
|
|
221
|
+
story: 'La prop `description` agrega un texto secundario debajo del mensaje principal con tipografía `small`.'
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
export const ConMarkdown = {
|
|
227
|
+
args: {
|
|
228
|
+
message: 'El archivo **reporte_enero.pdf** fue generado *exitosamente*.',
|
|
229
|
+
open: true,
|
|
230
|
+
colorTheme: COLOR_THEMES.success,
|
|
231
|
+
variant: VARIANTS.light
|
|
232
|
+
},
|
|
233
|
+
name: 'Con Markdown',
|
|
234
|
+
parameters: {
|
|
235
|
+
docs: {
|
|
236
|
+
description: {
|
|
237
|
+
story: 'El campo `message` soporta sintaxis markdown a través de `UTLabel`.'
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
export const TopRight = {
|
|
243
|
+
args: {
|
|
244
|
+
message: 'Esta notificación aparece en la esquina superior derecha.',
|
|
245
|
+
open: true,
|
|
246
|
+
colorTheme: COLOR_THEMES.info,
|
|
247
|
+
variant: VARIANTS.dark,
|
|
248
|
+
topRight: true
|
|
249
|
+
},
|
|
250
|
+
name: 'Posición Superior Derecha',
|
|
251
|
+
parameters: {
|
|
252
|
+
docs: {
|
|
253
|
+
description: {
|
|
254
|
+
story: 'Con `topRight: true` el snackbar aparece en la esquina superior derecha con slide desde la derecha.'
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
export const SinIcono = {
|
|
260
|
+
args: {
|
|
261
|
+
message: 'Notificación sin ícono.',
|
|
262
|
+
open: true,
|
|
263
|
+
colorTheme: COLOR_THEMES.warning,
|
|
264
|
+
variant: VARIANTS.dark,
|
|
265
|
+
withoutIcon: true
|
|
266
|
+
},
|
|
267
|
+
name: 'Sin Ícono',
|
|
268
|
+
parameters: {
|
|
269
|
+
docs: {
|
|
270
|
+
description: {
|
|
271
|
+
story: 'Con `withoutIcon: true` se oculta el ícono.'
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
export const Test = {
|
|
277
|
+
name: 'Test',
|
|
278
|
+
parameters: {
|
|
279
|
+
docs: {
|
|
280
|
+
description: {
|
|
281
|
+
story: 'Story para el Storybook Test Runner. Renderiza variantes simultáneas para verificar el correcto renderizado.'
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
render: () => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(UTSnackbar, {
|
|
286
|
+
colorTheme: COLOR_THEMES.success,
|
|
287
|
+
message: "success dark",
|
|
288
|
+
open: true
|
|
289
|
+
}), /*#__PURE__*/React.createElement(UTSnackbar, {
|
|
290
|
+
colorTheme: COLOR_THEMES.error,
|
|
291
|
+
message: "error light",
|
|
292
|
+
open: true,
|
|
293
|
+
variant: VARIANTS.light
|
|
294
|
+
}), /*#__PURE__*/React.createElement(UTSnackbar, {
|
|
295
|
+
colorTheme: COLOR_THEMES.white,
|
|
296
|
+
message: "white dark",
|
|
297
|
+
open: true,
|
|
298
|
+
variant: VARIANTS.dark
|
|
299
|
+
}), /*#__PURE__*/React.createElement(UTSnackbar, {
|
|
300
|
+
button: {
|
|
301
|
+
title: 'Acción'
|
|
302
|
+
},
|
|
303
|
+
colorTheme: COLOR_THEMES.info,
|
|
304
|
+
description: "Texto secundario de descripci\xF3n",
|
|
305
|
+
message: "Con descripci\xF3n",
|
|
306
|
+
open: true
|
|
307
|
+
}))
|
|
308
|
+
};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { joinArgTypes } from 'stories/utils';
|
|
2
|
+
import { COLOR_THEMES, VARIANTS } from '../constants';
|
|
3
|
+
export const ARG_TYPES = {
|
|
4
|
+
button: {
|
|
5
|
+
control: 'object',
|
|
6
|
+
description: 'Configuración del botón de acción primaria. Se hace spread en UTButton — incluir `title` como label y `onClick` como callback.',
|
|
7
|
+
table: {
|
|
8
|
+
defaultValue: {
|
|
9
|
+
summary: 'undefined'
|
|
10
|
+
},
|
|
11
|
+
type: {
|
|
12
|
+
summary: 'shape'
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
colorTheme: {
|
|
17
|
+
control: 'select',
|
|
18
|
+
description: 'Tipo de color de la notificación. `success`, `error`, `warning` e `info` usan colores semánticos con ícono asociado. `white` usa colores neutros sin semántica.',
|
|
19
|
+
options: Object.values(COLOR_THEMES),
|
|
20
|
+
table: {
|
|
21
|
+
defaultValue: {
|
|
22
|
+
summary: COLOR_THEMES.success
|
|
23
|
+
},
|
|
24
|
+
type: {
|
|
25
|
+
summary: joinArgTypes(Object.values(COLOR_THEMES))
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
icon: {
|
|
30
|
+
control: 'text',
|
|
31
|
+
description: 'Nombre del ícono Tabler para sobreescribir el ícono por defecto (ej: `IconStar`). Si no se indica, se usa el ícono correspondiente al `colorTheme`.',
|
|
32
|
+
table: {
|
|
33
|
+
defaultValue: {
|
|
34
|
+
summary: 'undefined'
|
|
35
|
+
},
|
|
36
|
+
type: {
|
|
37
|
+
summary: 'string'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
description: {
|
|
42
|
+
control: 'text',
|
|
43
|
+
description: 'Texto secundario debajo del mensaje principal.',
|
|
44
|
+
table: {
|
|
45
|
+
defaultValue: {
|
|
46
|
+
summary: 'undefined'
|
|
47
|
+
},
|
|
48
|
+
type: {
|
|
49
|
+
summary: 'string'
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
dataTestId: {
|
|
54
|
+
control: false,
|
|
55
|
+
description: 'Identificador de test raíz. Los sub-elementos derivan su testId automáticamente: `.icon`, `.label`, `.description.label`, `.close`, `.button.secondaryAction`, `.secondaryButton.tertiaryAction`.',
|
|
56
|
+
table: {
|
|
57
|
+
defaultValue: {
|
|
58
|
+
summary: 'undefined'
|
|
59
|
+
},
|
|
60
|
+
type: {
|
|
61
|
+
summary: 'string'
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
message: {
|
|
66
|
+
control: 'text',
|
|
67
|
+
description: 'Mensaje principal a mostrar. Soporta markdown.',
|
|
68
|
+
table: {
|
|
69
|
+
defaultValue: {
|
|
70
|
+
summary: 'undefined'
|
|
71
|
+
},
|
|
72
|
+
type: {
|
|
73
|
+
summary: 'string'
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
onClose: {
|
|
78
|
+
control: false,
|
|
79
|
+
description: 'Callback ejecutado al cerrar el snackbar.',
|
|
80
|
+
table: {
|
|
81
|
+
defaultValue: {
|
|
82
|
+
summary: 'undefined'
|
|
83
|
+
},
|
|
84
|
+
type: {
|
|
85
|
+
summary: 'function'
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
open: {
|
|
90
|
+
control: 'boolean',
|
|
91
|
+
description: 'Controla si el snackbar está visible.',
|
|
92
|
+
table: {
|
|
93
|
+
defaultValue: {
|
|
94
|
+
summary: 'false'
|
|
95
|
+
},
|
|
96
|
+
type: {
|
|
97
|
+
summary: 'boolean'
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
secondaryButton: {
|
|
102
|
+
control: 'object',
|
|
103
|
+
description: 'Configuración del botón de acción secundaria. Se hace spread en UTButton — incluir `title` como label y `onClick` como callback.',
|
|
104
|
+
table: {
|
|
105
|
+
defaultValue: {
|
|
106
|
+
summary: 'undefined'
|
|
107
|
+
},
|
|
108
|
+
type: {
|
|
109
|
+
summary: 'shape'
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
timeDuration: {
|
|
114
|
+
control: 'number',
|
|
115
|
+
description: 'Duración en milisegundos antes del cierre automático.',
|
|
116
|
+
table: {
|
|
117
|
+
defaultValue: {
|
|
118
|
+
summary: 'undefined'
|
|
119
|
+
},
|
|
120
|
+
type: {
|
|
121
|
+
summary: 'number'
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
topRight: {
|
|
126
|
+
control: 'boolean',
|
|
127
|
+
description: 'Si es `true`, el snackbar aparece en la esquina superior derecha. Si es `false`, en la inferior izquierda.',
|
|
128
|
+
table: {
|
|
129
|
+
defaultValue: {
|
|
130
|
+
summary: 'false'
|
|
131
|
+
},
|
|
132
|
+
type: {
|
|
133
|
+
summary: 'boolean'
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
variant: {
|
|
138
|
+
control: 'inline-radio',
|
|
139
|
+
description: '`dark` usa el color del `colorTheme` como fondo con texto blanco; `light` usa una versión clara con texto oscuro accesible.',
|
|
140
|
+
options: Object.values(VARIANTS),
|
|
141
|
+
table: {
|
|
142
|
+
defaultValue: {
|
|
143
|
+
summary: VARIANTS.dark
|
|
144
|
+
},
|
|
145
|
+
type: {
|
|
146
|
+
summary: joinArgTypes(Object.values(VARIANTS))
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
withoutIcon: {
|
|
151
|
+
control: 'boolean',
|
|
152
|
+
description: 'Si es `true`, oculta el ícono.',
|
|
153
|
+
table: {
|
|
154
|
+
defaultValue: {
|
|
155
|
+
summary: 'undefined'
|
|
156
|
+
},
|
|
157
|
+
type: {
|
|
158
|
+
summary: 'boolean'
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
.snackbarContent {
|
|
2
|
+
flex-wrap: nowrap;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.message {
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
min-width: 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.messageContent {
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: flex-start;
|
|
14
|
+
gap: var(--UT-snackbar-gap-icon, 8px);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.icon {
|
|
18
|
+
flex-shrink: 0;
|
|
19
|
+
margin-top: var(--UT-snackbar-icon-offset, 2px);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.textContent {
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
gap: var(--UT-snackbar-gap-description, 4px);
|
|
26
|
+
min-width: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.action {
|
|
30
|
+
flex-shrink: 0;
|
|
31
|
+
gap: var(--UT-snackbar-gap-actions, 4px);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.successDark {
|
|
35
|
+
background-color: var(--semanticSuccess04);
|
|
36
|
+
color: var(--light01);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.errorDark {
|
|
40
|
+
background-color: var(--actionError04);
|
|
41
|
+
color: var(--light01);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.warningDark {
|
|
45
|
+
background-color: var(--semanticWarning04);
|
|
46
|
+
color: var(--light01);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.infoDark {
|
|
50
|
+
background-color: var(--semanticInformation04);
|
|
51
|
+
color: var(--light01);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.successLight {
|
|
55
|
+
background-color: var(--semanticSuccess01);
|
|
56
|
+
color: var(--semanticSuccess05);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.errorLight {
|
|
60
|
+
background-color: var(--actionError01);
|
|
61
|
+
color: var(--actionError05);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.warningLight {
|
|
65
|
+
background-color: var(--semanticWarning01);
|
|
66
|
+
color: var(--semanticWarning05);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.infoLight {
|
|
70
|
+
background-color: var(--semanticInformation01);
|
|
71
|
+
color: var(--semanticInformation05);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.whiteLight {
|
|
75
|
+
background-color: var(--light01);
|
|
76
|
+
color: var(--dark05);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.whiteDark {
|
|
80
|
+
background-color: var(--dark04);
|
|
81
|
+
color: var(--light01);
|
|
82
|
+
}
|