@widergy/energy-ui 3.172.2 → 3.173.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 +20 -6
- package/dist/components/UTDataCategory/README.md +3 -1
- package/dist/components/UTDataCategory/UTDataCategory.stories.js +405 -0
- package/dist/components/UTDataCategory/components/MainAction/index.js +47 -0
- package/dist/components/UTDataCategory/constants.js +6 -2
- package/dist/components/UTDataCategory/index.js +46 -16
- package/dist/components/UTDataCategory/styles.module.scss +11 -0
- package/dist/components/UTDataElement/README.md +15 -2
- package/dist/components/UTDataElement/UTDataElement.stories.js +29 -1
- package/dist/components/UTDataElement/index.js +96 -49
- package/dist/components/UTDataElement/styles.module.scss +5 -0
- package/dist/components/UTDataElement/theme.js +11 -9
- package/dist/components/UTRadioGroup/UTRadioGroup.stories.js +124 -4
- package/dist/components/UTRadioGroup/versions/V1/components/Radio/index.js +12 -6
- package/dist/components/UTRadioGroup/versions/V1/constants.js +1 -0
- package/dist/components/UTRadioGroup/versions/V1/index.js +23 -7
- package/dist/components/UTRadioGroup/versions/V1/styles.module.scss +5 -0
- package/dist/components/UTRadioGroup/versions/V1/utils.js +40 -0
- package/dist/constants/Palette.js +18 -2
- package/dist/esm/components/UTDataCategory/README.md +3 -1
- package/dist/esm/components/UTDataCategory/UTDataCategory.stories.js +400 -0
- package/dist/esm/components/UTDataCategory/components/MainAction/index.js +40 -0
- package/dist/esm/components/UTDataCategory/constants.js +5 -1
- package/dist/esm/components/UTDataCategory/index.js +48 -18
- package/dist/esm/components/UTDataCategory/styles.module.scss +11 -0
- package/dist/esm/components/UTDataElement/README.md +15 -2
- package/dist/esm/components/UTDataElement/UTDataElement.stories.js +28 -0
- package/dist/esm/components/UTDataElement/index.js +98 -51
- package/dist/esm/components/UTDataElement/styles.module.scss +5 -0
- package/dist/esm/components/UTDataElement/theme.js +12 -10
- package/dist/esm/components/UTRadioGroup/UTRadioGroup.stories.js +123 -3
- package/dist/esm/components/UTRadioGroup/versions/V1/components/Radio/index.js +12 -6
- package/dist/esm/components/UTRadioGroup/versions/V1/constants.js +1 -0
- package/dist/esm/components/UTRadioGroup/versions/V1/index.js +25 -9
- package/dist/esm/components/UTRadioGroup/versions/V1/styles.module.scss +5 -0
- package/dist/esm/components/UTRadioGroup/versions/V1/utils.js +34 -0
- package/dist/esm/constants/Palette.js +17 -1
- package/dist/esm/utils/colorUtils.js +15 -0
- package/dist/esm/utils/hooks/useCSSVariables/constants.js +1 -0
- package/dist/utils/colorUtils.js +16 -1
- package/dist/utils/hooks/useCSSVariables/constants.js +1 -0
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.WithTooltip = exports.WithSwitchAction = exports.WithPrefix = exports.WithNumericBadge = exports.WithIcon = exports.WithExpandableContent = exports.WithButtonAction = exports.WithBadge = exports.VerticalOrientation = exports.SmallSpacing = exports.SmallPadding = exports.Playground = exports.NestedExample = exports.ForcedBadge = exports.Default = exports.CustomDataTestId = exports.ComplexExample = exports.AreaMode = void 0;
|
|
6
|
+
exports.default = exports.WithTooltip = exports.WithSwitchAction = exports.WithPrefix = exports.WithNumericBadge = exports.WithIcon = exports.WithExpandableContent = exports.WithButtonAction = exports.WithBadge = exports.VerticalOrientation = exports.SmallSpacing = exports.SmallPadding = exports.Playground = exports.NestedExample = exports.ForcedBadge = exports.Default = exports.CustomDataTestId = exports.ComplexExample = exports.AreaModeCustomProps = exports.AreaMode = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _utils = require("stories/utils");
|
|
9
9
|
var _UTLabel = _interopRequireDefault(require("../UTLabel"));
|
|
@@ -175,6 +175,18 @@ var _default = exports.default = {
|
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
},
|
|
178
|
+
areaProps: {
|
|
179
|
+
control: false,
|
|
180
|
+
description: "Personaliza el fondo del área. Acepta `colorTheme` (cualquier valor de COLOR_THEMES) y `shade` ('01'–'05'). Solo aplica cuando `area` es `true`.",
|
|
181
|
+
table: {
|
|
182
|
+
defaultValue: {
|
|
183
|
+
summary: '{}'
|
|
184
|
+
},
|
|
185
|
+
type: {
|
|
186
|
+
summary: 'object'
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
},
|
|
178
190
|
action: {
|
|
179
191
|
control: false,
|
|
180
192
|
description: 'Configuración de la acción principal del elemento.',
|
|
@@ -531,6 +543,22 @@ const AreaMode = exports.AreaMode = {
|
|
|
531
543
|
},
|
|
532
544
|
name: 'Modo Área'
|
|
533
545
|
};
|
|
546
|
+
const AreaModeCustomProps = exports.AreaModeCustomProps = {
|
|
547
|
+
args: {
|
|
548
|
+
title: 'Área con Color Personalizado',
|
|
549
|
+
Data: mockDataContent,
|
|
550
|
+
Icon: 'IconPalette',
|
|
551
|
+
area: true,
|
|
552
|
+
areaProps: {
|
|
553
|
+
colorTheme: 'accent',
|
|
554
|
+
shade: '01'
|
|
555
|
+
},
|
|
556
|
+
orientation: _constants.ORIENTATION.HORIZONTAL,
|
|
557
|
+
paddingVertical: _constants.PADDING.MEDIUM,
|
|
558
|
+
spacing: _constants.SPACING.MEDIUM
|
|
559
|
+
},
|
|
560
|
+
name: 'Modo Área — Color Personalizado'
|
|
561
|
+
};
|
|
534
562
|
const SmallPadding = exports.SmallPadding = {
|
|
535
563
|
args: {
|
|
536
564
|
title: 'Padding Pequeño',
|
|
@@ -12,11 +12,11 @@ var _isFinite = _interopRequireDefault(require("lodash/isFinite"));
|
|
|
12
12
|
var _UTTooltip = _interopRequireDefault(require("../UTTooltip"));
|
|
13
13
|
var _UTBadge = _interopRequireDefault(require("../UTBadge"));
|
|
14
14
|
var _UTLabel = _interopRequireDefault(require("../UTLabel"));
|
|
15
|
+
var _UTTouchableWithoutFeedback = _interopRequireDefault(require("../UTTouchableWithoutFeedback"));
|
|
15
16
|
var _WithTheme = _interopRequireDefault(require("../WithTheme"));
|
|
16
17
|
var _UTIcon = _interopRequireDefault(require("../UTIcon"));
|
|
17
18
|
var _componentUtils = require("../../utils/componentUtils");
|
|
18
19
|
var _classesUtils = require("../../utils/classesUtils");
|
|
19
|
-
var _UTButton = _interopRequireDefault(require("../UTButton"));
|
|
20
20
|
var _testIds = require("../../constants/testIds");
|
|
21
21
|
var _theme = require("./theme");
|
|
22
22
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
@@ -40,6 +40,7 @@ const UTDataElement = _ref => {
|
|
|
40
40
|
Data,
|
|
41
41
|
dataProps = {},
|
|
42
42
|
dataTestId,
|
|
43
|
+
expanded = false,
|
|
43
44
|
forceShowBadge = false,
|
|
44
45
|
Icon,
|
|
45
46
|
iconProps = {},
|
|
@@ -53,35 +54,67 @@ const UTDataElement = _ref => {
|
|
|
53
54
|
transitionDuration = _constants.ANIMATION.TRANSITION_DURATION
|
|
54
55
|
} = _ref;
|
|
55
56
|
const classes = (0, _react.useMemo)(() => (0, _classesUtils.mergeMultipleClassNames)(_stylesModule.default, theme, classNames), [classNames, theme]);
|
|
56
|
-
const [isCollapsed, setIsCollapsed] = (0, _react.useState)(
|
|
57
|
+
const [isCollapsed, setIsCollapsed] = (0, _react.useState)(!expanded);
|
|
57
58
|
const [isTransitioning, setIsTransitioning] = (0, _react.useState)(false);
|
|
58
|
-
const [contentHeight, setContentHeight] = (0, _react.useState)('0px');
|
|
59
|
+
const [contentHeight, setContentHeight] = (0, _react.useState)(expanded ? 'none' : '0px');
|
|
59
60
|
const childrenRef = (0, _react.useRef)(null);
|
|
61
|
+
const hasMountedRef = (0, _react.useRef)(false);
|
|
62
|
+
const transitionTimeoutRef = (0, _react.useRef)(null);
|
|
63
|
+
const transitionFrameRef = (0, _react.useRef)(null);
|
|
64
|
+
const clearPendingTransition = (0, _react.useCallback)(() => {
|
|
65
|
+
if (transitionTimeoutRef.current) {
|
|
66
|
+
clearTimeout(transitionTimeoutRef.current);
|
|
67
|
+
transitionTimeoutRef.current = null;
|
|
68
|
+
}
|
|
69
|
+
if (transitionFrameRef.current) {
|
|
70
|
+
cancelAnimationFrame(transitionFrameRef.current);
|
|
71
|
+
transitionFrameRef.current = null;
|
|
72
|
+
}
|
|
73
|
+
}, []);
|
|
74
|
+
const prepareContentTransition = (0, _react.useCallback)(() => {
|
|
75
|
+
if (!childrenRef.current) return false;
|
|
76
|
+
clearPendingTransition();
|
|
77
|
+
setContentHeight("".concat(childrenRef.current.scrollHeight, "px"));
|
|
78
|
+
setIsTransitioning(true);
|
|
79
|
+
return true;
|
|
80
|
+
}, [clearPendingTransition]);
|
|
81
|
+
const openContent = (0, _react.useCallback)(() => {
|
|
82
|
+
if (!prepareContentTransition()) return;
|
|
83
|
+
setIsCollapsed(false);
|
|
84
|
+
transitionTimeoutRef.current = setTimeout(() => {
|
|
85
|
+
setIsTransitioning(false);
|
|
86
|
+
setContentHeight('none');
|
|
87
|
+
}, transitionDuration);
|
|
88
|
+
}, [prepareContentTransition, transitionDuration]);
|
|
89
|
+
const closeContent = (0, _react.useCallback)(() => {
|
|
90
|
+
if (!prepareContentTransition()) return;
|
|
91
|
+
transitionFrameRef.current = requestAnimationFrame(() => {
|
|
92
|
+
setContentHeight('0px');
|
|
93
|
+
setIsCollapsed(true);
|
|
94
|
+
transitionTimeoutRef.current = setTimeout(() => setIsTransitioning(false), transitionDuration);
|
|
95
|
+
});
|
|
96
|
+
}, [prepareContentTransition, transitionDuration]);
|
|
97
|
+
(0, _react.useEffect)(() => clearPendingTransition, []);
|
|
60
98
|
const toggleCollapsed = (0, _react.useCallback)(() => {
|
|
61
|
-
if (isCollapsed)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
setTimeout(() => {
|
|
68
|
-
setIsTransitioning(false);
|
|
69
|
-
setContentHeight('none');
|
|
70
|
-
}, transitionDuration);
|
|
71
|
-
}
|
|
72
|
-
} else if (childrenRef.current) {
|
|
73
|
-
const height = childrenRef.current.scrollHeight;
|
|
74
|
-
setContentHeight("".concat(height, "px"));
|
|
75
|
-
setIsTransitioning(true);
|
|
76
|
-
requestAnimationFrame(() => {
|
|
77
|
-
setContentHeight('0px');
|
|
78
|
-
setIsCollapsed(true);
|
|
79
|
-
setTimeout(() => setIsTransitioning(false), transitionDuration);
|
|
80
|
-
});
|
|
99
|
+
if (isCollapsed) openContent();else closeContent();
|
|
100
|
+
}, [isCollapsed, openContent, closeContent]);
|
|
101
|
+
(0, _react.useEffect)(() => {
|
|
102
|
+
if (!hasMountedRef.current) {
|
|
103
|
+
hasMountedRef.current = true;
|
|
104
|
+
return;
|
|
81
105
|
}
|
|
82
|
-
|
|
106
|
+
if (expanded) openContent();else closeContent();
|
|
107
|
+
}, [expanded, openContent, closeContent]);
|
|
108
|
+
const handleInfoKeyDown = (0, _react.useCallback)(event => {
|
|
109
|
+
if (event.target === event.currentTarget && (event.key === 'Enter' || event.key === ' ')) {
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
toggleCollapsed();
|
|
112
|
+
}
|
|
113
|
+
}, [toggleCollapsed]);
|
|
114
|
+
const stopDataPropagation = (0, _react.useCallback)(event => event.stopPropagation(), []);
|
|
83
115
|
const IconComponent = (0, _componentUtils.isUTIcon)(Icon) ? _UTIcon.default : Icon;
|
|
84
|
-
const
|
|
116
|
+
const isDataLabel = (0, _componentUtils.isUTLabel)(Data);
|
|
117
|
+
const DataComponent = isDataLabel ? /*#__PURE__*/_react.default.createElement(_UTLabel.default, dataProps, Data) : Data;
|
|
85
118
|
const showBadge = forceShowBadge || (0, _isString.default)(badge) && !(0, _isEmpty.default)(badge) || (0, _isFinite.default)(badge);
|
|
86
119
|
const {
|
|
87
120
|
tooltip: titleTooltip
|
|
@@ -92,18 +125,7 @@ const UTDataElement = _ref => {
|
|
|
92
125
|
const infoClasses = "".concat(classes.info, " ").concat(orientation === _constants.ORIENTATION.VERTICAL && classes.vertical);
|
|
93
126
|
const iconCollapseButtonClasses = "".concat(classes.iconCollapseButton, " ").concat(isCollapsed && classes.collapsed);
|
|
94
127
|
const childrenClasses = "".concat(classes.children, " ").concat(isCollapsed ? classes.childrenCollapsed : classes.childrenExpanded, " ").concat(isTransitioning ? classes.childrenTransitioning : classes.childrenStatic);
|
|
95
|
-
|
|
96
|
-
className: "".concat(classes.container, " ").concat(area ? classes.area : '', " ").concat(classes["padding".concat((0, _componentUtils.capitalize)(paddingVertical))]),
|
|
97
|
-
"data-testid": dataTestId ? "".concat(dataTestId, ".").concat(dataElement.container) : undefined
|
|
98
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
99
|
-
className: contentClasses
|
|
100
|
-
}, IconComponent && /*#__PURE__*/_react.default.createElement(IconComponent, _extends({
|
|
101
|
-
name: Icon,
|
|
102
|
-
colorTheme: "gray",
|
|
103
|
-
size: "var(--UT-dataElement-icon-size, 1.5rem)"
|
|
104
|
-
}, iconProps)), /*#__PURE__*/_react.default.createElement("div", {
|
|
105
|
-
className: infoClasses
|
|
106
|
-
}, (prefix || title || showBadge) && /*#__PURE__*/_react.default.createElement("div", {
|
|
128
|
+
const infoContent = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, (prefix || title || showBadge || children) && /*#__PURE__*/_react.default.createElement("div", {
|
|
107
129
|
className: classes.topInfo
|
|
108
130
|
}, prefix && /*#__PURE__*/_react.default.createElement(_UTLabel.default, _extends({
|
|
109
131
|
colorTheme: "gray"
|
|
@@ -112,21 +134,41 @@ const UTDataElement = _ref => {
|
|
|
112
134
|
content: titleTooltip
|
|
113
135
|
} : {}, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_UTLabel.default, _extends({
|
|
114
136
|
colorTheme: "gray"
|
|
115
|
-
}, titleProps), title))),
|
|
137
|
+
}, titleProps), title))), children && /*#__PURE__*/_react.default.createElement(_UTIcon.default, {
|
|
138
|
+
className: iconCollapseButtonClasses,
|
|
139
|
+
colorTheme: "gray",
|
|
140
|
+
name: "IconChevronUp",
|
|
141
|
+
size: "var(--UT-dataElement-chevron-icon-size, 1.25rem)",
|
|
142
|
+
dataTestId: dataTestId ? "".concat(dataTestId, ".").concat(dataElement.collapseButton) : undefined
|
|
143
|
+
}), showBadge && /*#__PURE__*/_react.default.createElement(_UTBadge.default, _extends({
|
|
116
144
|
colorTheme: "accent",
|
|
117
145
|
className: classes.badge
|
|
118
|
-
}, badgeProps), forceShowBadge ? null : badge)), DataComponent &&
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
146
|
+
}, badgeProps), forceShowBadge ? null : badge)), DataComponent && (isDataLabel ? DataComponent :
|
|
147
|
+
/*#__PURE__*/
|
|
148
|
+
// Sin role="button": este div solo corta la propagación del click/keydown hacia el toggle de colapso, no es un control propio.
|
|
149
|
+
_react.default.createElement("div", {
|
|
150
|
+
onClick: stopDataPropagation,
|
|
151
|
+
onKeyDown: stopDataPropagation
|
|
152
|
+
}, DataComponent)));
|
|
153
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
154
|
+
className: "".concat(classes.container, " ").concat(area ? classes.area : '', " ").concat(classes["padding".concat((0, _componentUtils.capitalize)(paddingVertical))]),
|
|
155
|
+
"data-testid": dataTestId ? "".concat(dataTestId, ".").concat(dataElement.container) : undefined
|
|
156
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
157
|
+
className: contentClasses
|
|
158
|
+
}, IconComponent && /*#__PURE__*/_react.default.createElement(IconComponent, _extends({
|
|
159
|
+
name: Icon,
|
|
160
|
+
colorTheme: "gray",
|
|
161
|
+
size: "var(--UT-dataElement-icon-size, 1.5rem)"
|
|
162
|
+
}, iconProps)), children ? /*#__PURE__*/_react.default.createElement(_UTTouchableWithoutFeedback.default, {
|
|
163
|
+
className: "".concat(infoClasses, " ").concat(classes.clickable),
|
|
125
164
|
onClick: toggleCollapsed,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
165
|
+
onKeyDown: handleInfoKeyDown,
|
|
166
|
+
"aria-expanded": !isCollapsed
|
|
167
|
+
}, infoContent) : /*#__PURE__*/_react.default.createElement("div", {
|
|
168
|
+
className: infoClasses
|
|
169
|
+
}, infoContent), action && /*#__PURE__*/_react.default.createElement(_MainAction.default, _extends({
|
|
170
|
+
dataTestId: dataTestId
|
|
171
|
+
}, action))), children && /*#__PURE__*/_react.default.createElement("div", {
|
|
130
172
|
style: {
|
|
131
173
|
maxHeight: contentHeight
|
|
132
174
|
},
|
|
@@ -138,6 +180,10 @@ const UTDataElement = _ref => {
|
|
|
138
180
|
UTDataElement.propTypes = {
|
|
139
181
|
action: _propTypes.object,
|
|
140
182
|
area: _propTypes.bool,
|
|
183
|
+
areaProps: (0, _propTypes.shape)({
|
|
184
|
+
colorTheme: _propTypes.string,
|
|
185
|
+
shade: _propTypes.string
|
|
186
|
+
}),
|
|
141
187
|
badge: _propTypes.string,
|
|
142
188
|
badgeProps: _propTypes.object,
|
|
143
189
|
classes: (0, _propTypes.objectOf)(_propTypes.string),
|
|
@@ -145,6 +191,7 @@ UTDataElement.propTypes = {
|
|
|
145
191
|
Data: (0, _propTypes.oneOfType)([_propTypes.element, _propTypes.string]),
|
|
146
192
|
dataProps: _propTypes.object,
|
|
147
193
|
dataTestId: _propTypes.string,
|
|
194
|
+
expanded: _propTypes.bool,
|
|
148
195
|
forceShowBadge: _propTypes.bool,
|
|
149
196
|
Icon: (0, _propTypes.oneOfType)([_propTypes.element, _propTypes.string]),
|
|
150
197
|
iconProps: _propTypes.object,
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
.info {
|
|
36
|
+
align-items: stretch;
|
|
36
37
|
display: flex;
|
|
37
38
|
flex: 1;
|
|
38
39
|
flex-direction: row;
|
|
@@ -40,6 +41,10 @@
|
|
|
40
41
|
justify-content: space-between;
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
.clickable {
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
}
|
|
47
|
+
|
|
43
48
|
.vertical {
|
|
44
49
|
flex-direction: column;
|
|
45
50
|
grid-gap: var(--UT-dataElement-content-gap-y, 0.5rem);
|
|
@@ -5,23 +5,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.retrieveStyle = exports.backgroundColor = void 0;
|
|
7
7
|
var _Palette = require("../../constants/Palette");
|
|
8
|
-
const backgroundColor = (theme, area)
|
|
9
|
-
var _theme$Palette;
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const areaColor =
|
|
8
|
+
const backgroundColor = function (theme, area) {
|
|
9
|
+
var _theme$Palette, _theme$Palette2;
|
|
10
|
+
let areaProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
11
|
+
const requestedColorTheme = areaProps.colorTheme || _Palette.COLOR_THEMES.light;
|
|
12
|
+
const colorTheme = _Palette.VALID_PALETTE_COLOR_THEMES.has(requestedColorTheme) ? requestedColorTheme : _Palette.COLOR_THEMES.light;
|
|
13
|
+
const areaColor = ((_theme$Palette = theme.Palette) === null || _theme$Palette === void 0 || (_theme$Palette = _theme$Palette.actions) === null || _theme$Palette === void 0 ? void 0 : _theme$Palette[colorTheme]) || ((_theme$Palette2 = theme.Palette) === null || _theme$Palette2 === void 0 ? void 0 : _theme$Palette2[colorTheme]);
|
|
14
|
+
const shade = areaProps.shade || (_Palette.COLOR_THEMES.light === colorTheme ? _Palette.COLOR_SHADES.shade03 : _Palette.COLOR_SHADES.shade01);
|
|
14
15
|
return {
|
|
15
|
-
backgroundColor: area ? areaColor[
|
|
16
|
+
backgroundColor: area ? areaColor === null || areaColor === void 0 ? void 0 : areaColor[shade] : 'transparent'
|
|
16
17
|
};
|
|
17
18
|
};
|
|
18
19
|
exports.backgroundColor = backgroundColor;
|
|
19
20
|
const retrieveStyle = _ref => {
|
|
20
21
|
let {
|
|
21
22
|
area,
|
|
22
|
-
theme
|
|
23
|
+
theme,
|
|
24
|
+
areaProps
|
|
23
25
|
} = _ref;
|
|
24
|
-
const areaBackgroundColor = backgroundColor(theme, area);
|
|
26
|
+
const areaBackgroundColor = backgroundColor(theme, area, areaProps);
|
|
25
27
|
return {
|
|
26
28
|
area: {
|
|
27
29
|
...areaBackgroundColor,
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.V1Categorized = exports.V1CardVariant = exports.V1ButtonVariant = exports.V0WithField = exports.V0WithDividers = exports.V0Disabled = exports.V0Basic = exports.Playground = void 0;
|
|
6
|
+
exports.default = exports.V1WithArea = exports.V1Categorized = exports.V1CardVariant = exports.V1ButtonVariant = exports.V0WithField = exports.V0WithDividers = exports.V0Disabled = exports.V0Basic = exports.Playground = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _previewApi = require("@storybook/preview-api");
|
|
9
9
|
var _utils = require("stories/utils");
|
|
10
|
-
var _constants = require("
|
|
10
|
+
var _constants = require("./versions/V1/constants");
|
|
11
11
|
var _constants2 = require("./versions/V1/components/Radio/constants");
|
|
12
12
|
var _ = _interopRequireDefault(require("."));
|
|
13
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -319,6 +319,102 @@ var _default = exports.default = {
|
|
|
319
319
|
eq: 'V1'
|
|
320
320
|
}
|
|
321
321
|
},
|
|
322
|
+
area: {
|
|
323
|
+
control: 'boolean',
|
|
324
|
+
description: 'Muestra un área de fondo alrededor del grupo de opciones (V1 only).',
|
|
325
|
+
table: {
|
|
326
|
+
defaultValue: {
|
|
327
|
+
summary: 'false'
|
|
328
|
+
},
|
|
329
|
+
type: {
|
|
330
|
+
summary: 'bool'
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
if: {
|
|
334
|
+
arg: 'version',
|
|
335
|
+
eq: 'V1'
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
areaProps: {
|
|
339
|
+
control: 'object',
|
|
340
|
+
description: 'Personalización del área de fondo: `colorTheme`, `shade`, `borderColorTheme`, `borderShade` (V1 only). Sin `colorTheme` no se agrega fondo; sin `borderColorTheme` no se agrega borde.',
|
|
341
|
+
table: {
|
|
342
|
+
defaultValue: {
|
|
343
|
+
summary: 'undefined'
|
|
344
|
+
},
|
|
345
|
+
type: {
|
|
346
|
+
summary: 'object'
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
if: {
|
|
350
|
+
arg: 'version',
|
|
351
|
+
eq: 'V1'
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
iconProps: {
|
|
355
|
+
control: 'object',
|
|
356
|
+
description: 'Props adicionales para el ícono de cada opción (V1 only).',
|
|
357
|
+
table: {
|
|
358
|
+
defaultValue: {
|
|
359
|
+
summary: 'undefined'
|
|
360
|
+
},
|
|
361
|
+
type: {
|
|
362
|
+
summary: 'object'
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
if: {
|
|
366
|
+
arg: 'version',
|
|
367
|
+
eq: 'V1'
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
iconSelectedProps: {
|
|
371
|
+
control: 'object',
|
|
372
|
+
description: 'Props adicionales para el ícono de la opción seleccionada, sobrescriben `iconProps` (V1 only).',
|
|
373
|
+
table: {
|
|
374
|
+
defaultValue: {
|
|
375
|
+
summary: 'undefined'
|
|
376
|
+
},
|
|
377
|
+
type: {
|
|
378
|
+
summary: 'object'
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
if: {
|
|
382
|
+
arg: 'version',
|
|
383
|
+
eq: 'V1'
|
|
384
|
+
}
|
|
385
|
+
},
|
|
386
|
+
nameProps: {
|
|
387
|
+
control: 'object',
|
|
388
|
+
description: 'Props adicionales para el UTLabel del nombre de cada opción (V1 only).',
|
|
389
|
+
table: {
|
|
390
|
+
defaultValue: {
|
|
391
|
+
summary: 'undefined'
|
|
392
|
+
},
|
|
393
|
+
type: {
|
|
394
|
+
summary: 'object'
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
if: {
|
|
398
|
+
arg: 'version',
|
|
399
|
+
eq: 'V1'
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
nameSelectedProps: {
|
|
403
|
+
control: 'object',
|
|
404
|
+
description: 'Props adicionales para el UTLabel del nombre de la opción seleccionada, sobrescriben `nameProps` (V1 only).',
|
|
405
|
+
table: {
|
|
406
|
+
defaultValue: {
|
|
407
|
+
summary: 'undefined'
|
|
408
|
+
},
|
|
409
|
+
type: {
|
|
410
|
+
summary: 'object'
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
if: {
|
|
414
|
+
arg: 'version',
|
|
415
|
+
eq: 'V1'
|
|
416
|
+
}
|
|
417
|
+
},
|
|
322
418
|
dataTestId: {
|
|
323
419
|
control: 'text',
|
|
324
420
|
description: 'ID de prueba para el elemento raíz.',
|
|
@@ -424,8 +520,8 @@ const Playground = exports.Playground = {
|
|
|
424
520
|
options: defaultOptions,
|
|
425
521
|
title: 'Selecciona una opción',
|
|
426
522
|
value: '',
|
|
427
|
-
horizontalSpacing:
|
|
428
|
-
verticalSpacing:
|
|
523
|
+
horizontalSpacing: _constants.SPACING.MEDIUM,
|
|
524
|
+
verticalSpacing: _constants.SPACING.MEDIUM,
|
|
429
525
|
reversed: false,
|
|
430
526
|
required: false,
|
|
431
527
|
disabled: false,
|
|
@@ -481,6 +577,30 @@ const V1ButtonVariant = exports.V1ButtonVariant = {
|
|
|
481
577
|
},
|
|
482
578
|
name: 'V1 - Variante Button'
|
|
483
579
|
};
|
|
580
|
+
const V1WithArea = exports.V1WithArea = {
|
|
581
|
+
render: V1Template,
|
|
582
|
+
args: {
|
|
583
|
+
version: 'V1',
|
|
584
|
+
options: defaultOptions,
|
|
585
|
+
title: 'Opciones con Área de Fondo',
|
|
586
|
+
value: '',
|
|
587
|
+
area: true,
|
|
588
|
+
areaProps: {
|
|
589
|
+
colorTheme: 'light',
|
|
590
|
+
borderColorTheme: 'gray'
|
|
591
|
+
},
|
|
592
|
+
iconProps: {
|
|
593
|
+
colorTheme: 'dark'
|
|
594
|
+
},
|
|
595
|
+
iconSelectedProps: {
|
|
596
|
+
colorTheme: 'accent'
|
|
597
|
+
},
|
|
598
|
+
nameSelectedProps: {
|
|
599
|
+
weight: 'bold'
|
|
600
|
+
}
|
|
601
|
+
},
|
|
602
|
+
name: 'V1 - Con Área de Fondo'
|
|
603
|
+
};
|
|
484
604
|
|
|
485
605
|
// V0 Stories
|
|
486
606
|
const V0Basic = exports.V0Basic = {
|
|
@@ -7,6 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _Radio = _interopRequireDefault(require("@material-ui/core/Radio"));
|
|
9
9
|
var _propTypes = require("prop-types");
|
|
10
|
+
var _UTTouchableWithoutFeedback = _interopRequireDefault(require("../../../../../UTTouchableWithoutFeedback"));
|
|
10
11
|
var _UTIcon = _interopRequireDefault(require("../../../../../UTIcon"));
|
|
11
12
|
var _UTLabel = _interopRequireDefault(require("../../../../../UTLabel"));
|
|
12
13
|
var _WithTheme = _interopRequireDefault(require("../../../../../WithTheme"));
|
|
@@ -21,18 +22,20 @@ const Radio = _ref => {
|
|
|
21
22
|
descriptionProps = {},
|
|
22
23
|
disabled,
|
|
23
24
|
icon,
|
|
25
|
+
iconProps = {},
|
|
26
|
+
iconSelectedProps = {},
|
|
24
27
|
name,
|
|
25
28
|
nameProps = {},
|
|
29
|
+
nameSelectedProps = {},
|
|
26
30
|
onChange,
|
|
27
31
|
prefix,
|
|
28
32
|
selected,
|
|
29
33
|
suffix,
|
|
30
34
|
variant = _constants.RADIO_VARIANTS.DEFAULT
|
|
31
35
|
} = _ref;
|
|
32
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
36
|
+
return /*#__PURE__*/_react.default.createElement(_UTTouchableWithoutFeedback.default, {
|
|
33
37
|
className: classes.root,
|
|
34
|
-
onClick: () => !disabled && onChange()
|
|
35
|
-
role: "button"
|
|
38
|
+
onClick: () => !disabled && onChange()
|
|
36
39
|
}, variant === _constants.RADIO_VARIANTS.DEFAULT && /*#__PURE__*/_react.default.createElement(_Radio.default, {
|
|
37
40
|
checked: selected,
|
|
38
41
|
onChange: onChange,
|
|
@@ -40,11 +43,11 @@ const Radio = _ref => {
|
|
|
40
43
|
disabled: disabled
|
|
41
44
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
42
45
|
className: classes.content
|
|
43
|
-
}, icon && /*#__PURE__*/_react.default.createElement(_UTIcon.default, {
|
|
46
|
+
}, icon && /*#__PURE__*/_react.default.createElement(_UTIcon.default, _extends({
|
|
44
47
|
name: icon,
|
|
45
48
|
colorTheme: selected ? 'accent' : 'dark',
|
|
46
49
|
size: _constants.ICON_SIZES[variant]
|
|
47
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
50
|
+
}, iconProps, selected ? iconSelectedProps : {})), /*#__PURE__*/_react.default.createElement("div", {
|
|
48
51
|
className: classes.contentContainer
|
|
49
52
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
50
53
|
className: classes.content
|
|
@@ -52,7 +55,7 @@ const Radio = _ref => {
|
|
|
52
55
|
colorTheme: "gray"
|
|
53
56
|
}, prefix), name && /*#__PURE__*/_react.default.createElement(_UTLabel.default, _extends({
|
|
54
57
|
colorTheme: selected ? 'accent' : 'dark'
|
|
55
|
-
}, nameProps), name), suffix && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
58
|
+
}, nameProps, selected ? nameSelectedProps : {}), name), suffix && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
56
59
|
colorTheme: "gray",
|
|
57
60
|
variant: "small",
|
|
58
61
|
weight: "medium"
|
|
@@ -70,8 +73,11 @@ Radio.propTypes = {
|
|
|
70
73
|
descriptionProps: _propTypes.object,
|
|
71
74
|
disabled: _propTypes.bool,
|
|
72
75
|
icon: _propTypes.string,
|
|
76
|
+
iconProps: _propTypes.object,
|
|
77
|
+
iconSelectedProps: _propTypes.object,
|
|
73
78
|
name: _propTypes.string,
|
|
74
79
|
nameProps: _propTypes.object,
|
|
80
|
+
nameSelectedProps: _propTypes.object,
|
|
75
81
|
onChange: _propTypes.func,
|
|
76
82
|
prefix: _propTypes.string,
|
|
77
83
|
selected: _propTypes.bool,
|
|
@@ -14,6 +14,7 @@ var _utils = require("../../../UTValidation/utils");
|
|
|
14
14
|
var _UTValidation = _interopRequireDefault(require("../../../UTValidation"));
|
|
15
15
|
var _Radio = _interopRequireDefault(require("./components/Radio"));
|
|
16
16
|
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
17
|
+
var _utils2 = require("./utils");
|
|
17
18
|
var _constants = require("./constants");
|
|
18
19
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
20
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
@@ -21,15 +22,20 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
21
22
|
const UTRadioGroup = _ref => {
|
|
22
23
|
let {
|
|
23
24
|
actions,
|
|
25
|
+
area,
|
|
26
|
+
areaProps,
|
|
24
27
|
classNames = {},
|
|
25
28
|
dataTestId,
|
|
26
29
|
descriptionProps,
|
|
27
30
|
disabled,
|
|
28
31
|
error,
|
|
29
32
|
errorDataTestId,
|
|
30
|
-
horizontalSpacing =
|
|
33
|
+
horizontalSpacing = _constants.SPACING.MEDIUM,
|
|
34
|
+
iconProps,
|
|
35
|
+
iconSelectedProps,
|
|
31
36
|
itemDataTestId,
|
|
32
37
|
nameProps,
|
|
38
|
+
nameSelectedProps,
|
|
33
39
|
onChange = () => {},
|
|
34
40
|
options,
|
|
35
41
|
required,
|
|
@@ -37,7 +43,7 @@ const UTRadioGroup = _ref => {
|
|
|
37
43
|
title,
|
|
38
44
|
value = null,
|
|
39
45
|
variant,
|
|
40
|
-
verticalSpacing =
|
|
46
|
+
verticalSpacing = _constants.SPACING.MEDIUM
|
|
41
47
|
} = _ref;
|
|
42
48
|
const categorizedOptions = (0, _react.useMemo)(() => {
|
|
43
49
|
const optionsGrouped = options.reduce((groupedOptions, option) => {
|
|
@@ -60,11 +66,13 @@ const UTRadioGroup = _ref => {
|
|
|
60
66
|
});
|
|
61
67
|
}, [options]);
|
|
62
68
|
const validationData = (0, _react.useMemo)(() => error && (0, _utils.formatErrorToValidation)(error), [error]);
|
|
69
|
+
const areaStyle = (0, _react.useMemo)(() => (0, _utils2.getAreaStyle)(area, areaProps), [area, areaProps]);
|
|
63
70
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
64
|
-
className: "".concat(_stylesModule.default.container, "
|
|
65
|
-
"data-testid": dataTestId
|
|
71
|
+
className: "".concat(_stylesModule.default.container, " ").concat(classNames.root || ''),
|
|
72
|
+
"data-testid": dataTestId,
|
|
73
|
+
style: areaStyle
|
|
66
74
|
}, title && /*#__PURE__*/_react.default.createElement("div", {
|
|
67
|
-
className: "".concat(_stylesModule.default.headerContainer, " ").concat(classNames.header)
|
|
75
|
+
className: "".concat(_stylesModule.default.headerContainer, " ").concat(classNames.header || '')
|
|
68
76
|
}, title && /*#__PURE__*/_react.default.createElement(_UTFieldLabel.default, {
|
|
69
77
|
actions: actions,
|
|
70
78
|
required: required
|
|
@@ -85,8 +93,11 @@ const UTRadioGroup = _ref => {
|
|
|
85
93
|
dataTestId: itemDataTestId ? "".concat(itemDataTestId, ".category_").concat(catIndex, ".").concat(index) : null,
|
|
86
94
|
descriptionProps: descriptionProps,
|
|
87
95
|
disabled: item.disabled || disabled,
|
|
96
|
+
iconProps: iconProps,
|
|
97
|
+
iconSelectedProps: iconSelectedProps,
|
|
88
98
|
key: item.value,
|
|
89
99
|
nameProps: nameProps,
|
|
100
|
+
nameSelectedProps: nameSelectedProps,
|
|
90
101
|
onChange: () => onChange(item.value),
|
|
91
102
|
reversed: reversed,
|
|
92
103
|
selected: item.value === value,
|
|
@@ -100,15 +111,20 @@ const UTRadioGroup = _ref => {
|
|
|
100
111
|
};
|
|
101
112
|
UTRadioGroup.propTypes = {
|
|
102
113
|
actions: (0, _propTypes.arrayOf)(_buttonTypes.buttonTypes),
|
|
114
|
+
area: _propTypes.bool,
|
|
115
|
+
areaProps: _propTypes.object,
|
|
103
116
|
classNames: (0, _propTypes.objectOf)(_propTypes.string),
|
|
104
117
|
dataTestId: _propTypes.string,
|
|
105
118
|
descriptionProps: _propTypes.object,
|
|
106
119
|
disabled: _propTypes.bool,
|
|
107
120
|
error: _propTypes.string,
|
|
108
121
|
errorDataTestId: _propTypes.string,
|
|
109
|
-
horizontalSpacing: _propTypes.
|
|
122
|
+
horizontalSpacing: (0, _propTypes.oneOf)(Object.values(_constants.SPACING)),
|
|
123
|
+
iconProps: _propTypes.object,
|
|
124
|
+
iconSelectedProps: _propTypes.object,
|
|
110
125
|
itemDataTestId: _propTypes.string,
|
|
111
126
|
nameProps: _propTypes.object,
|
|
127
|
+
nameSelectedProps: _propTypes.object,
|
|
112
128
|
onChange: _propTypes.func,
|
|
113
129
|
options: (0, _propTypes.arrayOf)((0, _propTypes.shape)({
|
|
114
130
|
category: _propTypes.string,
|
|
@@ -123,6 +139,6 @@ UTRadioGroup.propTypes = {
|
|
|
123
139
|
title: _propTypes.string,
|
|
124
140
|
value: _propTypes.string,
|
|
125
141
|
variant: _propTypes.string,
|
|
126
|
-
verticalSpacing: _propTypes.
|
|
142
|
+
verticalSpacing: (0, _propTypes.oneOf)(Object.values(_constants.SPACING))
|
|
127
143
|
};
|
|
128
144
|
var _default = exports.default = UTRadioGroup;
|