@widergy/energy-ui 3.164.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 +15 -4
- 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 +134 -0
- package/dist/components/UTSnackbar/index.js +134 -0
- package/dist/components/UTSnackbar/stories/UTSnackbar.stories.js +350 -0
- package/dist/components/UTSnackbar/stories/storiesConstants.js +169 -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/UTSnackbar/utils.js +53 -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 +128 -0
- package/dist/esm/components/UTSnackbar/index.js +127 -0
- package/dist/esm/components/UTSnackbar/stories/UTSnackbar.stories.js +342 -0
- package/dist/esm/components/UTSnackbar/stories/storiesConstants.js +163 -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/UTSnackbar/utils.js +46 -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,231 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import UTButton from '../../UTButton';
|
|
3
|
+
import UTAlert from '..';
|
|
4
|
+
import { ALERT_TYPES, ARG_TYPES } from './storiesConstants';
|
|
5
|
+
const composeContent = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
message,
|
|
8
|
+
open,
|
|
9
|
+
timeDuration,
|
|
10
|
+
topRight,
|
|
11
|
+
type
|
|
12
|
+
} = _ref;
|
|
13
|
+
return {
|
|
14
|
+
message,
|
|
15
|
+
open,
|
|
16
|
+
timeDuration,
|
|
17
|
+
topRight,
|
|
18
|
+
type
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
const AllTypesDemo = () => {
|
|
22
|
+
const [alertState, setAlertState] = useState({
|
|
23
|
+
open: false
|
|
24
|
+
});
|
|
25
|
+
const showAlert = type => setAlertState({
|
|
26
|
+
message: "Alerta de tipo: ".concat(type),
|
|
27
|
+
open: true,
|
|
28
|
+
type
|
|
29
|
+
});
|
|
30
|
+
const handleClose = () => setAlertState(prev => ({
|
|
31
|
+
...prev,
|
|
32
|
+
open: false
|
|
33
|
+
}));
|
|
34
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
35
|
+
style: {
|
|
36
|
+
display: 'flex',
|
|
37
|
+
gap: '8px'
|
|
38
|
+
}
|
|
39
|
+
}, ALERT_TYPES.map(type => /*#__PURE__*/React.createElement(UTButton, {
|
|
40
|
+
key: type,
|
|
41
|
+
onClick: () => showAlert(type),
|
|
42
|
+
variant: "outlined"
|
|
43
|
+
}, type)), /*#__PURE__*/React.createElement(UTAlert, {
|
|
44
|
+
content: {
|
|
45
|
+
...alertState,
|
|
46
|
+
onClose: handleClose
|
|
47
|
+
}
|
|
48
|
+
}));
|
|
49
|
+
};
|
|
50
|
+
export default {
|
|
51
|
+
args: {
|
|
52
|
+
message: 'Este es un mensaje de alerta de ejemplo.',
|
|
53
|
+
open: true,
|
|
54
|
+
timeDuration: undefined,
|
|
55
|
+
topRight: false,
|
|
56
|
+
type: 'success',
|
|
57
|
+
withoutIcon: false
|
|
58
|
+
},
|
|
59
|
+
argTypes: ARG_TYPES,
|
|
60
|
+
component: UTAlert,
|
|
61
|
+
parameters: {
|
|
62
|
+
controls: {
|
|
63
|
+
exclude: ['classes', 'closeDataTestId', 'labelDataTestId']
|
|
64
|
+
},
|
|
65
|
+
docs: {
|
|
66
|
+
description: {
|
|
67
|
+
component: 'Componente de alerta tipo Snackbar para mostrar notificaciones al usuario. Soporta cuatro tipos (success, error, info, warning), markdown en el mensaje y posicionamiento configurable. Se usa habitualmente junto al `AlertHandler` singleton para disparar alertas desde cualquier lugar de la aplicación.'
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
title: 'Energy-UI/UTAlert'
|
|
72
|
+
};
|
|
73
|
+
export const Playground = {
|
|
74
|
+
name: 'Playground',
|
|
75
|
+
render: _ref2 => {
|
|
76
|
+
let {
|
|
77
|
+
message,
|
|
78
|
+
open,
|
|
79
|
+
timeDuration,
|
|
80
|
+
topRight,
|
|
81
|
+
type,
|
|
82
|
+
withoutIcon
|
|
83
|
+
} = _ref2;
|
|
84
|
+
return /*#__PURE__*/React.createElement(UTAlert, {
|
|
85
|
+
content: composeContent({
|
|
86
|
+
message,
|
|
87
|
+
open,
|
|
88
|
+
timeDuration,
|
|
89
|
+
topRight,
|
|
90
|
+
type
|
|
91
|
+
}),
|
|
92
|
+
withoutIcon: withoutIcon
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
export const AllTypes = {
|
|
97
|
+
name: 'Todos los Tipos',
|
|
98
|
+
parameters: {
|
|
99
|
+
docs: {
|
|
100
|
+
description: {
|
|
101
|
+
story: 'Hacé clic en cada botón para ver el tipo de alerta correspondiente.'
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
render: () => /*#__PURE__*/React.createElement(AllTypesDemo, null)
|
|
106
|
+
};
|
|
107
|
+
export const TopRight = {
|
|
108
|
+
args: {
|
|
109
|
+
message: 'Esta alerta aparece en la esquina superior derecha.',
|
|
110
|
+
open: true,
|
|
111
|
+
topRight: true,
|
|
112
|
+
type: 'info'
|
|
113
|
+
},
|
|
114
|
+
name: 'Posición Superior Derecha',
|
|
115
|
+
parameters: {
|
|
116
|
+
docs: {
|
|
117
|
+
description: {
|
|
118
|
+
story: 'Con `topRight: true` en el objeto `content`, la alerta aparece en la esquina superior derecha con animación de slide desde la derecha.'
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
render: _ref3 => {
|
|
123
|
+
let {
|
|
124
|
+
message,
|
|
125
|
+
open,
|
|
126
|
+
timeDuration,
|
|
127
|
+
topRight,
|
|
128
|
+
type,
|
|
129
|
+
withoutIcon
|
|
130
|
+
} = _ref3;
|
|
131
|
+
return /*#__PURE__*/React.createElement(UTAlert, {
|
|
132
|
+
content: composeContent({
|
|
133
|
+
message,
|
|
134
|
+
open,
|
|
135
|
+
timeDuration,
|
|
136
|
+
topRight,
|
|
137
|
+
type
|
|
138
|
+
}),
|
|
139
|
+
withoutIcon: withoutIcon
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
export const SinIcono = {
|
|
144
|
+
args: {
|
|
145
|
+
message: 'Alerta sin ícono de tipo.',
|
|
146
|
+
open: true,
|
|
147
|
+
type: 'warning',
|
|
148
|
+
withoutIcon: true
|
|
149
|
+
},
|
|
150
|
+
name: 'Sin Ícono',
|
|
151
|
+
parameters: {
|
|
152
|
+
docs: {
|
|
153
|
+
description: {
|
|
154
|
+
story: 'Con `withoutIcon: true` se oculta el ícono del tipo de alerta.'
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
render: _ref4 => {
|
|
159
|
+
let {
|
|
160
|
+
message,
|
|
161
|
+
open,
|
|
162
|
+
timeDuration,
|
|
163
|
+
topRight,
|
|
164
|
+
type,
|
|
165
|
+
withoutIcon
|
|
166
|
+
} = _ref4;
|
|
167
|
+
return /*#__PURE__*/React.createElement(UTAlert, {
|
|
168
|
+
content: composeContent({
|
|
169
|
+
message,
|
|
170
|
+
open,
|
|
171
|
+
timeDuration,
|
|
172
|
+
topRight,
|
|
173
|
+
type
|
|
174
|
+
}),
|
|
175
|
+
withoutIcon: withoutIcon
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
export const ConMarkdown = {
|
|
180
|
+
args: {
|
|
181
|
+
message: 'Operación completada. El archivo **reporte_enero.pdf** fue generado *exitosamente*.',
|
|
182
|
+
open: true,
|
|
183
|
+
type: 'success'
|
|
184
|
+
},
|
|
185
|
+
name: 'Con Markdown',
|
|
186
|
+
parameters: {
|
|
187
|
+
docs: {
|
|
188
|
+
description: {
|
|
189
|
+
story: 'El campo `message` soporta sintaxis markdown. El texto se renderiza a través de `UTLabel` con `withMarkdown`.'
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
render: _ref5 => {
|
|
194
|
+
let {
|
|
195
|
+
message,
|
|
196
|
+
open,
|
|
197
|
+
timeDuration,
|
|
198
|
+
topRight,
|
|
199
|
+
type,
|
|
200
|
+
withoutIcon
|
|
201
|
+
} = _ref5;
|
|
202
|
+
return /*#__PURE__*/React.createElement(UTAlert, {
|
|
203
|
+
content: composeContent({
|
|
204
|
+
message,
|
|
205
|
+
open,
|
|
206
|
+
timeDuration,
|
|
207
|
+
topRight,
|
|
208
|
+
type
|
|
209
|
+
}),
|
|
210
|
+
withoutIcon: withoutIcon
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
export const Test = {
|
|
215
|
+
name: 'Test',
|
|
216
|
+
parameters: {
|
|
217
|
+
docs: {
|
|
218
|
+
description: {
|
|
219
|
+
story: 'Story para el Test Runner. Renderiza los cuatro tipos de alerta simultáneamente.'
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
render: () => /*#__PURE__*/React.createElement(React.Fragment, null, ALERT_TYPES.map(type => /*#__PURE__*/React.createElement(UTAlert, {
|
|
224
|
+
key: type,
|
|
225
|
+
content: {
|
|
226
|
+
message: "Alerta ".concat(type),
|
|
227
|
+
open: true,
|
|
228
|
+
type
|
|
229
|
+
}
|
|
230
|
+
})))
|
|
231
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { joinArgTypes } from 'stories/utils';
|
|
2
|
+
export const ALERT_TYPES = ['error', 'info', 'success', 'warning'];
|
|
3
|
+
export const ARG_TYPES = {
|
|
4
|
+
closeDataTestId: {
|
|
5
|
+
control: false,
|
|
6
|
+
description: 'Identificador de test para el botón de cierre.',
|
|
7
|
+
table: {
|
|
8
|
+
defaultValue: {
|
|
9
|
+
summary: 'undefined'
|
|
10
|
+
},
|
|
11
|
+
type: {
|
|
12
|
+
summary: 'string'
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
labelDataTestId: {
|
|
17
|
+
control: false,
|
|
18
|
+
description: 'Identificador de test para el label del mensaje.',
|
|
19
|
+
table: {
|
|
20
|
+
defaultValue: {
|
|
21
|
+
summary: 'undefined'
|
|
22
|
+
},
|
|
23
|
+
type: {
|
|
24
|
+
summary: 'string'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
message: {
|
|
29
|
+
control: 'text',
|
|
30
|
+
description: 'Mensaje a mostrar en la alerta. Pertenece al objeto `content`. Soporta markdown.',
|
|
31
|
+
table: {
|
|
32
|
+
defaultValue: {
|
|
33
|
+
summary: 'undefined'
|
|
34
|
+
},
|
|
35
|
+
type: {
|
|
36
|
+
summary: 'string'
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
open: {
|
|
41
|
+
control: 'boolean',
|
|
42
|
+
description: 'Controla si la alerta está visible. Pertenece al objeto `content`.',
|
|
43
|
+
table: {
|
|
44
|
+
defaultValue: {
|
|
45
|
+
summary: 'false'
|
|
46
|
+
},
|
|
47
|
+
type: {
|
|
48
|
+
summary: 'boolean'
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
timeDuration: {
|
|
53
|
+
control: 'number',
|
|
54
|
+
description: 'Duración en milisegundos antes del cierre automático. Pertenece al objeto `content`.',
|
|
55
|
+
table: {
|
|
56
|
+
defaultValue: {
|
|
57
|
+
summary: 'undefined'
|
|
58
|
+
},
|
|
59
|
+
type: {
|
|
60
|
+
summary: 'number'
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
topRight: {
|
|
65
|
+
control: 'boolean',
|
|
66
|
+
description: 'Si es `true`, la alerta aparece en la esquina superior derecha. Si es `false`, en la inferior izquierda. Pertenece al objeto `content`.',
|
|
67
|
+
table: {
|
|
68
|
+
defaultValue: {
|
|
69
|
+
summary: 'false'
|
|
70
|
+
},
|
|
71
|
+
type: {
|
|
72
|
+
summary: 'boolean'
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
type: {
|
|
77
|
+
control: 'select',
|
|
78
|
+
description: 'Tipo de alerta. Determina el ícono y el color. Pertenece al objeto `content`.',
|
|
79
|
+
options: ALERT_TYPES,
|
|
80
|
+
table: {
|
|
81
|
+
defaultValue: {
|
|
82
|
+
summary: 'undefined'
|
|
83
|
+
},
|
|
84
|
+
type: {
|
|
85
|
+
summary: joinArgTypes(ALERT_TYPES)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
withoutIcon: {
|
|
90
|
+
control: 'boolean',
|
|
91
|
+
description: 'Si es `true`, oculta el ícono del tipo de alerta.',
|
|
92
|
+
table: {
|
|
93
|
+
defaultValue: {
|
|
94
|
+
summary: 'undefined'
|
|
95
|
+
},
|
|
96
|
+
type: {
|
|
97
|
+
summary: 'boolean'
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
@@ -20,6 +20,7 @@ const UTBanner = _ref => {
|
|
|
20
20
|
colorTheme = DEFAULT_PROPS.colorTheme,
|
|
21
21
|
dataTestId,
|
|
22
22
|
description,
|
|
23
|
+
descriptionProps,
|
|
23
24
|
helpText,
|
|
24
25
|
Icon,
|
|
25
26
|
iconPlacement = DEFAULT_PROPS.iconPlacement,
|
|
@@ -28,6 +29,7 @@ const UTBanner = _ref => {
|
|
|
28
29
|
secondaryButton,
|
|
29
30
|
size = DEFAULT_PROPS.size,
|
|
30
31
|
title,
|
|
32
|
+
titleProps,
|
|
31
33
|
variant = DEFAULT_PROPS.variant
|
|
32
34
|
} = _ref;
|
|
33
35
|
const isVerticalButton = buttonPlacement === PLACEMENTS.VERTICAL;
|
|
@@ -79,16 +81,18 @@ const UTBanner = _ref => {
|
|
|
79
81
|
dataTestId: dataTestId ? "".concat(dataTestId, ".category.").concat(ID_CONSTANTS.LABEL) : undefined,
|
|
80
82
|
variant: "xsmall",
|
|
81
83
|
weight: "medium"
|
|
82
|
-
}, category), !!title && /*#__PURE__*/React.createElement(UTLabel, {
|
|
84
|
+
}, category), !!title && /*#__PURE__*/React.createElement(UTLabel, _extends({
|
|
83
85
|
colorTheme: labelColorTheme,
|
|
84
|
-
dataTestId: dataTestId ? "".concat(dataTestId, ".").concat(ID_CONSTANTS.TITLE, ".").concat(ID_CONSTANTS.LABEL) : undefined,
|
|
85
86
|
variant: titleVariant,
|
|
86
87
|
weight: "medium"
|
|
87
|
-
},
|
|
88
|
+
}, titleProps, {
|
|
89
|
+
dataTestId: dataTestId ? "".concat(dataTestId, ".").concat(ID_CONSTANTS.TITLE, ".").concat(ID_CONSTANTS.LABEL) : undefined
|
|
90
|
+
}), title), !!description && /*#__PURE__*/React.createElement(UTLabel, _extends({
|
|
88
91
|
colorTheme: labelColorTheme,
|
|
89
|
-
dataTestId: dataTestId ? "".concat(dataTestId, ".").concat(ID_CONSTANTS.DESCRIPTION, ".").concat(ID_CONSTANTS.LABEL) : undefined,
|
|
90
92
|
variant: descriptionVariant
|
|
91
|
-
},
|
|
93
|
+
}, descriptionProps, {
|
|
94
|
+
dataTestId: dataTestId ? "".concat(dataTestId, ".").concat(ID_CONSTANTS.DESCRIPTION, ".").concat(ID_CONSTANTS.LABEL) : undefined
|
|
95
|
+
}), description), !!helpText && /*#__PURE__*/React.createElement(UTLabel, {
|
|
92
96
|
colorTheme: secondaryLabelColorTheme,
|
|
93
97
|
dataTestId: dataTestId ? "".concat(dataTestId, ".").concat(ID_CONSTANTS.HELP_TEXT, ".").concat(ID_CONSTANTS.LABEL) : undefined,
|
|
94
98
|
variant: "small"
|
|
@@ -120,6 +124,7 @@ UTBanner.propTypes = {
|
|
|
120
124
|
colorTheme: oneOf(Object.values(COLOR_THEMES)),
|
|
121
125
|
dataTestId: string,
|
|
122
126
|
description: string,
|
|
127
|
+
descriptionProps: object,
|
|
123
128
|
helpText: string,
|
|
124
129
|
Icon: oneOfType([elementType, string]),
|
|
125
130
|
iconPlacement: oneOf(Object.values(PLACEMENTS)),
|
|
@@ -128,6 +133,7 @@ UTBanner.propTypes = {
|
|
|
128
133
|
secondaryButton: buttonType,
|
|
129
134
|
size: oneOf(Object.values(SIZES)),
|
|
130
135
|
title: string,
|
|
136
|
+
titleProps: object,
|
|
131
137
|
variant: oneOf(Object.values(VARIANTS))
|
|
132
138
|
};
|
|
133
139
|
export default UTBanner;
|
|
@@ -40,6 +40,10 @@ export default {
|
|
|
40
40
|
control: 'text',
|
|
41
41
|
description: 'Optional body text shown below the title (small).'
|
|
42
42
|
},
|
|
43
|
+
descriptionProps: {
|
|
44
|
+
control: 'object',
|
|
45
|
+
description: 'Extra props spread into the UTLabel that renders the description.'
|
|
46
|
+
},
|
|
43
47
|
helpText: {
|
|
44
48
|
control: 'text',
|
|
45
49
|
description: 'Optional secondary text shown below the description (small, gray).'
|
|
@@ -74,6 +78,10 @@ export default {
|
|
|
74
78
|
control: 'text',
|
|
75
79
|
description: 'Main text of the banner.'
|
|
76
80
|
},
|
|
81
|
+
titleProps: {
|
|
82
|
+
control: 'object',
|
|
83
|
+
description: 'Extra props spread into the UTLabel that renders the title.'
|
|
84
|
+
},
|
|
77
85
|
variant: {
|
|
78
86
|
control: {
|
|
79
87
|
type: 'select'
|