@widergy/energy-ui 3.159.0 → 3.160.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 +19 -6
- package/dist/components/UTButton/README.md +17 -8
- package/dist/components/UTButton/index.js +26 -6
- package/dist/components/UTButton/stories/UTButton.stories.js +4 -1
- package/dist/components/UTButton/stories/UTButtonAdornments.stories.js +16 -11
- package/dist/components/UTButton/stories/storiesConstants.js +32 -10
- package/dist/components/UTButton/utils.js +52 -7
- package/dist/components/UTPanel/versions/V1/components/AdditionalContentModule/index.js +7 -2
- package/dist/components/UTPanel/versions/V1/components/AdditionalContentModule/styles.module.scss +2 -1
- package/dist/components/UTTable/UTTable.stories.js +34 -1
- package/dist/components/UTTable/components/TableHeader/versions/V1/ActionsMobile.js +85 -0
- package/dist/components/UTTable/components/TableHeader/versions/V1/index.js +14 -23
- package/dist/components/UTTable/components/TableHeader/versions/V1/utils.js +6 -3
- package/dist/components/UTTable/index.js +3 -0
- package/dist/esm/components/UTButton/README.md +17 -8
- package/dist/esm/components/UTButton/index.js +28 -8
- package/dist/esm/components/UTButton/stories/UTButton.stories.js +4 -1
- package/dist/esm/components/UTButton/stories/UTButtonAdornments.stories.js +15 -10
- package/dist/esm/components/UTButton/stories/storiesConstants.js +33 -11
- package/dist/esm/components/UTButton/utils.js +53 -8
- package/dist/esm/components/UTPanel/versions/V1/components/AdditionalContentModule/index.js +7 -2
- package/dist/esm/components/UTPanel/versions/V1/components/AdditionalContentModule/styles.module.scss +2 -1
- package/dist/esm/components/UTTable/UTTable.stories.js +33 -0
- package/dist/esm/components/UTTable/components/TableHeader/versions/V1/ActionsMobile.js +78 -0
- package/dist/esm/components/UTTable/components/TableHeader/versions/V1/index.js +15 -24
- package/dist/esm/components/UTTable/components/TableHeader/versions/V1/utils.js +6 -3
- package/dist/esm/components/UTTable/index.js +3 -0
- package/package.json +1 -1
|
@@ -17,13 +17,16 @@ const getMenuItems = (actions, closeMenu) => actions.map(action => {
|
|
|
17
17
|
const {
|
|
18
18
|
Icon,
|
|
19
19
|
iconProps,
|
|
20
|
+
LeftIcon,
|
|
20
21
|
onClick
|
|
21
22
|
} = action;
|
|
23
|
+
// Icon is deprecated in favor of LeftIcon
|
|
24
|
+
const resolvedIcon = LeftIcon !== null && LeftIcon !== void 0 ? LeftIcon : Icon;
|
|
22
25
|
return {
|
|
23
26
|
...action,
|
|
24
|
-
Icon:
|
|
25
|
-
name:
|
|
26
|
-
}, iconProps)) :
|
|
27
|
+
Icon: resolvedIcon ? typeof resolvedIcon === 'string' ? () => /*#__PURE__*/_react.default.createElement(_UTIcon.default, _extends({
|
|
28
|
+
name: resolvedIcon
|
|
29
|
+
}, iconProps)) : resolvedIcon : undefined,
|
|
27
30
|
label: action.children,
|
|
28
31
|
onClick: () => {
|
|
29
32
|
onClick();
|
|
@@ -377,8 +377,11 @@ UTTable.propTypes = {
|
|
|
377
377
|
hideTextOnResponsive: _propTypes.bool,
|
|
378
378
|
Icon: (0, _propTypes.oneOfType)([_propTypes.elementType, _propTypes.string]),
|
|
379
379
|
iconPlacement: _propTypes.string,
|
|
380
|
+
isPrimary: _propTypes.bool,
|
|
381
|
+
LeftIcon: (0, _propTypes.oneOfType)([_propTypes.elementType, _propTypes.string]),
|
|
380
382
|
loading: _propTypes.bool,
|
|
381
383
|
onClick: _propTypes.func,
|
|
384
|
+
RightIcon: (0, _propTypes.oneOfType)([_propTypes.elementType, _propTypes.string]),
|
|
382
385
|
size: _propTypes.string,
|
|
383
386
|
type: _propTypes.string,
|
|
384
387
|
variant: _propTypes.string
|
|
@@ -17,12 +17,16 @@ All these variants are defined in the component theme.
|
|
|
17
17
|
|
|
18
18
|
### Color Themes
|
|
19
19
|
|
|
20
|
-
The color themes are defined by the component consumer and will vary accordingly.They define a set of variables (colors and opacities) that then combined with the variant will change how the
|
|
21
|
-
The components supports an infinite amount of color themes but
|
|
20
|
+
The color themes are defined by the component consumer and will vary accordingly. They define a set of variables (colors and opacities) that then combined with the variant will change how the button looks.
|
|
21
|
+
The components supports an infinite amount of color themes but requires the consumer to pass at least a `primary` one that works as a default.
|
|
22
22
|
|
|
23
|
-
###
|
|
23
|
+
### Icons
|
|
24
24
|
|
|
25
|
-
The button can include
|
|
25
|
+
The button can include up to two icons (left and right), each of which can be either a Tabler Icons name or a custom SVG React component.
|
|
26
|
+
|
|
27
|
+
- **`LeftIcon`:** rendered at the start of the button content.
|
|
28
|
+
- **`RightIcon`:** rendered at the end of the button content.
|
|
29
|
+
- Additional props for each icon can be passed via `leftIconProps` and `rightIconProps`.
|
|
26
30
|
|
|
27
31
|
### Props
|
|
28
32
|
|
|
@@ -34,9 +38,14 @@ The button can include an icon, which can be either from the Tabler Icons librar
|
|
|
34
38
|
| onClick | func | | Callback fired when the user clicks the component. |
|
|
35
39
|
| loading | bool | false | If `true` a spinner is shown over the component. |
|
|
36
40
|
| disabled | bool | false | If `true` the button is unclickable. |
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
+
| LeftIcon | node \| string | | Icon rendered at the start of the button. |
|
|
42
|
+
| leftIconProps | object | | Additional props to apply to the left icon. |
|
|
43
|
+
| RightIcon | node \| string | | Icon rendered at the end of the button. |
|
|
44
|
+
| rightIconProps | object | | Additional props to apply to the right icon. |
|
|
45
|
+
| hideTextOnResponsive | bool | false | If `true` and an icon is present, the button text is hidden on mobile. |
|
|
46
|
+
| count | number | | Number to display in a badge inside the button. |
|
|
47
|
+
| type | string | | HTML type attribute. |
|
|
41
48
|
| classNames | object | | Overrides the default button theme. |
|
|
42
49
|
| children | node | | The component contents. |
|
|
50
|
+
| Icon | node \| string | | **Deprecated.** Use `LeftIcon` or `RightIcon` instead. |
|
|
51
|
+
| iconPlacement | 'left' \| 'right' | 'left' | **Deprecated.** Use `LeftIcon` or `RightIcon` instead. |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
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
2
|
import React, { useMemo } from 'react';
|
|
3
|
-
import { bool, func, elementType, objectOf, string, number } from 'prop-types';
|
|
3
|
+
import { bool, func, elementType, object, objectOf, string, number } from 'prop-types';
|
|
4
4
|
import Button from '@material-ui/core/Button';
|
|
5
5
|
import CircularProgress from '@material-ui/core/CircularProgress';
|
|
6
6
|
import { capitalize } from '../../utils/componentUtils';
|
|
@@ -9,7 +9,7 @@ import UTBadge from '../UTBadge';
|
|
|
9
9
|
import UTLabel from '../UTLabel';
|
|
10
10
|
import WithTheme from '../WithTheme';
|
|
11
11
|
import { getCounterColorTheme, getIconProps, getLabelProps } from './utils';
|
|
12
|
-
import {
|
|
12
|
+
import { DEFAULT_PROPS } from './constants';
|
|
13
13
|
import { retrieveStyle } from './theme';
|
|
14
14
|
import styles from './styles.module.scss';
|
|
15
15
|
const UTButton = _ref => {
|
|
@@ -24,8 +24,12 @@ const UTButton = _ref => {
|
|
|
24
24
|
hideTextOnResponsive,
|
|
25
25
|
Icon,
|
|
26
26
|
iconPlacement,
|
|
27
|
+
LeftIcon,
|
|
28
|
+
leftIconProps,
|
|
27
29
|
loading,
|
|
28
30
|
onClick,
|
|
31
|
+
RightIcon,
|
|
32
|
+
rightIconProps,
|
|
29
33
|
size,
|
|
30
34
|
type,
|
|
31
35
|
variant
|
|
@@ -39,27 +43,33 @@ const UTButton = _ref => {
|
|
|
39
43
|
...materialButtonClasses
|
|
40
44
|
} = classes;
|
|
41
45
|
const {
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
LeftIconComponent,
|
|
47
|
+
leftIconProps: leftIconBaseProps,
|
|
48
|
+
RightIconComponent,
|
|
49
|
+
rightIconProps: rightIconBaseProps
|
|
44
50
|
} = useMemo(() => getIconProps({
|
|
45
51
|
className: icon,
|
|
46
52
|
colorTheme,
|
|
47
53
|
hasContent: !!children,
|
|
48
54
|
hideTextOnResponsive,
|
|
49
55
|
Icon,
|
|
56
|
+
iconPlacement,
|
|
57
|
+
LeftIcon,
|
|
58
|
+
RightIcon,
|
|
50
59
|
size,
|
|
51
60
|
variant
|
|
52
|
-
}), [colorTheme, children, hideTextOnResponsive, icon, Icon, size, variant]);
|
|
53
|
-
const
|
|
61
|
+
}), [colorTheme, children, hideTextOnResponsive, icon, Icon, iconPlacement, LeftIcon, RightIcon, size, variant]);
|
|
62
|
+
const LeftIconToShow = LeftIconComponent && /*#__PURE__*/React.createElement(LeftIconComponent, _extends({}, leftIconBaseProps, leftIconProps));
|
|
63
|
+
const RightIconToShow = RightIconComponent && /*#__PURE__*/React.createElement(RightIconComponent, _extends({}, rightIconBaseProps, rightIconProps));
|
|
54
64
|
const counterColorTheme = getCounterColorTheme(colorTheme, variant);
|
|
55
65
|
const labelProps = getLabelProps(colorTheme, variant, size);
|
|
56
66
|
const RenderedChildren = /*#__PURE__*/React.createElement("div", {
|
|
57
67
|
className: "".concat(childrenContainer, " ").concat(styles["".concat(size, "ChildrenContainer")])
|
|
58
68
|
}, count && /*#__PURE__*/React.createElement(UTBadge, {
|
|
59
69
|
colorTheme: counterColorTheme
|
|
60
|
-
}, count),
|
|
70
|
+
}, count), LeftIconToShow, children !== null && children !== undefined && children !== false && /*#__PURE__*/React.createElement(UTLabel, _extends({}, labelProps, {
|
|
61
71
|
className: "".concat(styles.textContainer, " ").concat(textClassName)
|
|
62
|
-
}), children),
|
|
72
|
+
}), children), RightIconToShow);
|
|
63
73
|
return /*#__PURE__*/React.createElement(Button, {
|
|
64
74
|
classes: materialButtonClasses,
|
|
65
75
|
className: "\n ".concat(styles["padding".concat(capitalize(size))], "\n ").concat(hideTextOnResponsive && styles.hideTextOnResponsive, "\n ").concat(!hideTextOnResponsive && !children && styles.noChildren, "\n "),
|
|
@@ -81,10 +91,20 @@ UTButton.propTypes = {
|
|
|
81
91
|
dataTestId: string,
|
|
82
92
|
disabled: bool,
|
|
83
93
|
hideTextOnResponsive: bool,
|
|
94
|
+
/**
|
|
95
|
+
* @deprecated Use LeftIcon or RightIcon instead.
|
|
96
|
+
*/
|
|
84
97
|
Icon: elementType,
|
|
98
|
+
/**
|
|
99
|
+
* @deprecated Use LeftIcon or RightIcon instead.
|
|
100
|
+
*/
|
|
85
101
|
iconPlacement: string,
|
|
102
|
+
LeftIcon: elementType,
|
|
103
|
+
leftIconProps: object,
|
|
86
104
|
loading: bool,
|
|
87
105
|
onClick: func,
|
|
106
|
+
RightIcon: elementType,
|
|
107
|
+
rightIconProps: object,
|
|
88
108
|
size: string,
|
|
89
109
|
type: string,
|
|
90
110
|
variant: string
|
|
@@ -7,8 +7,11 @@ export default {
|
|
|
7
7
|
children: undefined,
|
|
8
8
|
classNames: undefined,
|
|
9
9
|
count: undefined,
|
|
10
|
-
|
|
10
|
+
LeftIcon: undefined,
|
|
11
|
+
leftIconProps: undefined,
|
|
11
12
|
onClick: undefined,
|
|
13
|
+
RightIcon: undefined,
|
|
14
|
+
rightIconProps: undefined,
|
|
12
15
|
...COMMON_ARGS
|
|
13
16
|
},
|
|
14
17
|
argTypes: {
|
|
@@ -13,29 +13,34 @@ export default {
|
|
|
13
13
|
...COMMON_PARAMETERS
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
|
-
export const
|
|
16
|
+
export const LeftIconOnly = {
|
|
17
17
|
args: {
|
|
18
|
-
children: 'Icon
|
|
19
|
-
|
|
20
|
-
iconPlacement: 'left'
|
|
18
|
+
children: 'Left Icon',
|
|
19
|
+
LeftIcon: 'IconArrowLeft'
|
|
21
20
|
}
|
|
22
21
|
};
|
|
23
|
-
export const
|
|
22
|
+
export const RightIconOnly = {
|
|
24
23
|
args: {
|
|
25
|
-
children: 'Icon
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
children: 'Right Icon',
|
|
25
|
+
RightIcon: 'IconArrowRight'
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
export const BothIcons = {
|
|
29
|
+
args: {
|
|
30
|
+
children: 'Descargas',
|
|
31
|
+
LeftIcon: 'IconDownload',
|
|
32
|
+
RightIcon: 'IconChevronDown'
|
|
28
33
|
}
|
|
29
34
|
};
|
|
30
35
|
export const IconOnly = {
|
|
31
36
|
args: {
|
|
32
|
-
|
|
37
|
+
LeftIcon: 'IconSearch'
|
|
33
38
|
}
|
|
34
39
|
};
|
|
35
40
|
export const CountAndIcon = {
|
|
36
41
|
args: {
|
|
37
42
|
count: 7,
|
|
38
|
-
|
|
43
|
+
LeftIcon: 'IconBell'
|
|
39
44
|
}
|
|
40
45
|
};
|
|
41
46
|
export const CountOnly = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { joinArgTypes } from 'stories/utils';
|
|
2
|
-
import { VARIANTS_NAMES, SIZES,
|
|
2
|
+
import { VARIANTS_NAMES, SIZES, DEFAULT_PROPS, COLORS_MAPPER } from '../constants';
|
|
3
3
|
|
|
4
4
|
// Common argTypes used across multiple stories files
|
|
5
5
|
export const COMMON_ARG_TYPES = {
|
|
@@ -90,7 +90,7 @@ export const COMMON_ARG_TYPES = {
|
|
|
90
90
|
},
|
|
91
91
|
hideTextOnResponsive: {
|
|
92
92
|
control: 'boolean',
|
|
93
|
-
description: 'Si es `true` y
|
|
93
|
+
description: 'Si es `true` y hay ícono, el contenido del botón no se muestra en dispositivos móviles.',
|
|
94
94
|
table: {
|
|
95
95
|
defaultValue: {
|
|
96
96
|
summary: DEFAULT_PROPS.hideTextOnResponsive
|
|
@@ -100,9 +100,9 @@ export const COMMON_ARG_TYPES = {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
},
|
|
103
|
-
|
|
103
|
+
LeftIcon: {
|
|
104
104
|
control: 'text',
|
|
105
|
-
description: '
|
|
105
|
+
description: 'Ícono a mostrar al inicio del botón. Puede ser un nombre de icono de Tabler o un componente personalizado.',
|
|
106
106
|
table: {
|
|
107
107
|
defaultValue: {
|
|
108
108
|
summary: 'undefined'
|
|
@@ -112,16 +112,15 @@ export const COMMON_ARG_TYPES = {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
},
|
|
115
|
-
|
|
116
|
-
control:
|
|
117
|
-
description: '
|
|
118
|
-
options: Object.values(ICON_PLACEMENTS),
|
|
115
|
+
leftIconProps: {
|
|
116
|
+
control: false,
|
|
117
|
+
description: 'Props adicionales a aplicar al ícono izquierdo.',
|
|
119
118
|
table: {
|
|
120
119
|
defaultValue: {
|
|
121
|
-
summary:
|
|
120
|
+
summary: 'undefined'
|
|
122
121
|
},
|
|
123
122
|
type: {
|
|
124
|
-
summary:
|
|
123
|
+
summary: 'object'
|
|
125
124
|
}
|
|
126
125
|
}
|
|
127
126
|
},
|
|
@@ -149,6 +148,30 @@ export const COMMON_ARG_TYPES = {
|
|
|
149
148
|
}
|
|
150
149
|
}
|
|
151
150
|
},
|
|
151
|
+
RightIcon: {
|
|
152
|
+
control: 'text',
|
|
153
|
+
description: 'Ícono a mostrar al final del botón. Puede ser un nombre de icono de Tabler o un componente personalizado.',
|
|
154
|
+
table: {
|
|
155
|
+
defaultValue: {
|
|
156
|
+
summary: 'undefined'
|
|
157
|
+
},
|
|
158
|
+
type: {
|
|
159
|
+
summary: joinArgTypes(['string', 'ReactComponent'])
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
rightIconProps: {
|
|
164
|
+
control: false,
|
|
165
|
+
description: 'Props adicionales a aplicar al ícono derecho.',
|
|
166
|
+
table: {
|
|
167
|
+
defaultValue: {
|
|
168
|
+
summary: 'undefined'
|
|
169
|
+
},
|
|
170
|
+
type: {
|
|
171
|
+
summary: 'object'
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
},
|
|
152
175
|
size: {
|
|
153
176
|
control: 'inline-radio',
|
|
154
177
|
description: 'Tamaño del botón.',
|
|
@@ -195,7 +218,6 @@ export const COMMON_ARGS = {
|
|
|
195
218
|
dataTestId: 'customButtonId',
|
|
196
219
|
disabled: DEFAULT_PROPS.disabled,
|
|
197
220
|
hideTextOnResponsive: DEFAULT_PROPS.hideTextOnResponsive,
|
|
198
|
-
iconPlacement: DEFAULT_PROPS.iconPlacement,
|
|
199
221
|
loading: DEFAULT_PROPS.loading,
|
|
200
222
|
size: DEFAULT_PROPS.size,
|
|
201
223
|
type: 'button',
|
|
@@ -1,27 +1,72 @@
|
|
|
1
1
|
import { COLOR_THEMES } from '../../constants/Palette';
|
|
2
2
|
import { capitalize, isUTIcon } from '../../utils/componentUtils';
|
|
3
3
|
import UTIcon from '../UTIcon';
|
|
4
|
-
import { COLORS_MAPPER, SIZES, VARIANTS_NAMES } from './constants';
|
|
4
|
+
import { COLORS_MAPPER, ICON_PLACEMENTS, SIZES, VARIANTS_NAMES } from './constants';
|
|
5
5
|
import styles from './styles.module.scss';
|
|
6
6
|
const getButtonElementColorTheme = (buttonColorTheme, buttonVariant) => buttonVariant === VARIANTS_NAMES.filled ? buttonColorTheme === COLORS_MAPPER.negative ? COLOR_THEMES.neutral : COLOR_THEMES.negative : COLORS_MAPPER[buttonColorTheme];
|
|
7
|
-
|
|
7
|
+
const buildSingleIconProps = _ref => {
|
|
8
8
|
let {
|
|
9
9
|
className,
|
|
10
|
-
colorTheme
|
|
10
|
+
colorTheme,
|
|
11
11
|
hasContent,
|
|
12
12
|
hideTextOnResponsive,
|
|
13
13
|
Icon,
|
|
14
14
|
size,
|
|
15
|
-
variant
|
|
15
|
+
variant
|
|
16
16
|
} = _ref;
|
|
17
|
-
|
|
17
|
+
if (!Icon) return null;
|
|
18
|
+
return {
|
|
18
19
|
IconComponent: isUTIcon(Icon) ? UTIcon : Icon,
|
|
19
|
-
className: "\n
|
|
20
|
+
className: "\n ".concat(styles.baseIcon, "\n ").concat(className, "\n ").concat(hasContent ? styles.icon : styles["iconOnly".concat(capitalize(size))], "\n ").concat(hideTextOnResponsive ? styles["adaptableIcon".concat(capitalize(size))] : '', "\n "),
|
|
20
21
|
...(isUTIcon(Icon) ? {
|
|
21
|
-
colorTheme: getButtonElementColorTheme(
|
|
22
|
+
colorTheme: getButtonElementColorTheme(colorTheme, variant),
|
|
22
23
|
name: Icon
|
|
23
24
|
} : {})
|
|
24
|
-
}
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export const getIconProps = _ref2 => {
|
|
28
|
+
let {
|
|
29
|
+
className,
|
|
30
|
+
colorTheme,
|
|
31
|
+
hasContent,
|
|
32
|
+
hideTextOnResponsive,
|
|
33
|
+
Icon,
|
|
34
|
+
iconPlacement,
|
|
35
|
+
LeftIcon,
|
|
36
|
+
RightIcon,
|
|
37
|
+
size,
|
|
38
|
+
variant
|
|
39
|
+
} = _ref2;
|
|
40
|
+
const resolvedLeftIcon = LeftIcon || (iconPlacement !== ICON_PLACEMENTS.right ? Icon : undefined);
|
|
41
|
+
const resolvedRightIcon = RightIcon || (iconPlacement === ICON_PLACEMENTS.right ? Icon : undefined);
|
|
42
|
+
const commonParams = {
|
|
43
|
+
className,
|
|
44
|
+
colorTheme,
|
|
45
|
+
hasContent,
|
|
46
|
+
hideTextOnResponsive,
|
|
47
|
+
size,
|
|
48
|
+
variant
|
|
49
|
+
};
|
|
50
|
+
const {
|
|
51
|
+
IconComponent: LeftIconComponent,
|
|
52
|
+
...leftIconProps
|
|
53
|
+
} = buildSingleIconProps({
|
|
54
|
+
...commonParams,
|
|
55
|
+
Icon: resolvedLeftIcon
|
|
56
|
+
}) || {};
|
|
57
|
+
const {
|
|
58
|
+
IconComponent: RightIconComponent,
|
|
59
|
+
...rightIconProps
|
|
60
|
+
} = buildSingleIconProps({
|
|
61
|
+
...commonParams,
|
|
62
|
+
Icon: resolvedRightIcon
|
|
63
|
+
}) || {};
|
|
64
|
+
return {
|
|
65
|
+
LeftIconComponent: LeftIconComponent || null,
|
|
66
|
+
leftIconProps,
|
|
67
|
+
RightIconComponent: RightIconComponent || null,
|
|
68
|
+
rightIconProps
|
|
69
|
+
};
|
|
25
70
|
};
|
|
26
71
|
export const getLabelProps = (buttonColorTheme, buttonVariant, buttonSize) => ({
|
|
27
72
|
colorTheme: getButtonElementColorTheme(buttonColorTheme, buttonVariant),
|
|
@@ -26,10 +26,15 @@ const AdditionalContentModule = _ref => {
|
|
|
26
26
|
const defaultTooltipContainer = tooltipContainer || (() => document.body);
|
|
27
27
|
return /*#__PURE__*/React.createElement("div", {
|
|
28
28
|
className: styles.additionalContentWrapper
|
|
29
|
-
}, activeContent && /*#__PURE__*/React.createElement(
|
|
29
|
+
}, activeContent && /*#__PURE__*/React.createElement(PerfectScrollbar, {
|
|
30
|
+
options: {
|
|
31
|
+
suppressScrollX: true
|
|
32
|
+
},
|
|
33
|
+
className: styles.sidebarScroll
|
|
34
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
30
35
|
className: styles.bodyComponent,
|
|
31
36
|
"data-testid": panel.additionalContent.body
|
|
32
|
-
}, ActiveBodyComponent && /*#__PURE__*/React.createElement(ActiveBodyComponent, null)), /*#__PURE__*/React.createElement("div", {
|
|
37
|
+
}, ActiveBodyComponent && /*#__PURE__*/React.createElement(ActiveBodyComponent, null))), /*#__PURE__*/React.createElement("div", {
|
|
33
38
|
className: "".concat(styles.sidebar, " ").concat(!activeContent ? styles.sidebarCollapsed : ''),
|
|
34
39
|
"data-testid": panel.additionalContent.sidebar
|
|
35
40
|
}, /*#__PURE__*/React.createElement(PerfectScrollbar, {
|
|
@@ -23,9 +23,10 @@ $sidebar-width: 56px;
|
|
|
23
23
|
display: flex;
|
|
24
24
|
flex-direction: column;
|
|
25
25
|
flex-shrink: 0;
|
|
26
|
+
height: 100%;
|
|
26
27
|
min-width: $body-component-width;
|
|
27
28
|
opacity: 1;
|
|
28
|
-
overflow:
|
|
29
|
+
overflow-y: auto;
|
|
29
30
|
padding: 24px 24px 16px 24px;
|
|
30
31
|
width: $body-component-width;
|
|
31
32
|
}
|
|
@@ -928,6 +928,39 @@ export const TableHeaderV1WithActions = {
|
|
|
928
928
|
},
|
|
929
929
|
name: 'Header V1 - Con Acciones'
|
|
930
930
|
};
|
|
931
|
+
export const TableHeaderV1WithPrimaryActions = {
|
|
932
|
+
args: {
|
|
933
|
+
data: mockData.slice(0, 10),
|
|
934
|
+
columns: basicColumns,
|
|
935
|
+
headerVersion: 'V1',
|
|
936
|
+
withActionHeader: true,
|
|
937
|
+
tableTitle: 'Tabla con Acciones Primarias V1',
|
|
938
|
+
description: 'Header V1 con isPrimary: las acciones primarias siempre son visibles (solo ícono en mobile), las secundarias colapsan en el dots menu.',
|
|
939
|
+
actionsConfig: [{
|
|
940
|
+
isPrimary: true,
|
|
941
|
+
LeftIcon: 'IconPlus',
|
|
942
|
+
onClick: () => alert('Nuevo trámite'),
|
|
943
|
+
variant: 'filled',
|
|
944
|
+
colorTheme: 'primary',
|
|
945
|
+
size: 'small',
|
|
946
|
+
children: 'Nuevo trámite'
|
|
947
|
+
}, {
|
|
948
|
+
LeftIcon: 'IconDownload',
|
|
949
|
+
RightIcon: 'IconChevronDown',
|
|
950
|
+
onClick: () => alert('Descargas'),
|
|
951
|
+
variant: 'outlined',
|
|
952
|
+
size: 'small',
|
|
953
|
+
children: 'Descargas'
|
|
954
|
+
}, {
|
|
955
|
+
Icon: 'IconFilter',
|
|
956
|
+
onClick: () => alert('Filtrar'),
|
|
957
|
+
variant: 'outlined',
|
|
958
|
+
size: 'small',
|
|
959
|
+
children: 'Filtros'
|
|
960
|
+
}]
|
|
961
|
+
},
|
|
962
|
+
name: 'Header V1 - Con Acciones Primarias'
|
|
963
|
+
};
|
|
931
964
|
export const TableHeaderV1WithSelection = {
|
|
932
965
|
args: {
|
|
933
966
|
data: mockData.slice(0, 10),
|
|
@@ -0,0 +1,78 @@
|
|
|
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 isEmpty from 'lodash/isEmpty';
|
|
3
|
+
import partition from 'lodash/partition';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { arrayOf, bool, func, object, objectOf, shape, string } from 'prop-types';
|
|
6
|
+
import UTButton from '../../../../../UTButton';
|
|
7
|
+
import UTMenu from '../../../../../UTMenu';
|
|
8
|
+
import UTTooltip from '../../../../../UTTooltip';
|
|
9
|
+
import styles from './styles.module.scss';
|
|
10
|
+
import { getMenuItems } from './utils';
|
|
11
|
+
const ActionsMobile = _ref => {
|
|
12
|
+
var _classes$wrapperHeade;
|
|
13
|
+
let {
|
|
14
|
+
actions,
|
|
15
|
+
anchor,
|
|
16
|
+
classes,
|
|
17
|
+
closeMenu,
|
|
18
|
+
menuButtonRef,
|
|
19
|
+
openMenu,
|
|
20
|
+
tableHeaderDataTestId
|
|
21
|
+
} = _ref;
|
|
22
|
+
const [primaryActions, secondaryActions] = partition(actions, _ref2 => {
|
|
23
|
+
let {
|
|
24
|
+
isPrimary
|
|
25
|
+
} = _ref2;
|
|
26
|
+
return isPrimary;
|
|
27
|
+
});
|
|
28
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, !isEmpty(secondaryActions) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
29
|
+
ref: menuButtonRef
|
|
30
|
+
}, /*#__PURE__*/React.createElement(UTButton, {
|
|
31
|
+
dataTestId: tableHeaderDataTestId ? "".concat(tableHeaderDataTestId, ".dotMenuButton") : '',
|
|
32
|
+
Icon: "IconDots",
|
|
33
|
+
onClick: openMenu,
|
|
34
|
+
variant: "text"
|
|
35
|
+
})), /*#__PURE__*/React.createElement(UTMenu, {
|
|
36
|
+
anchor: anchor,
|
|
37
|
+
classNames: {
|
|
38
|
+
menuItemContainer: "".concat(styles.wrapperHeaderMenuItem, " ").concat((_classes$wrapperHeade = classes.wrapperHeaderMenuItem) !== null && _classes$wrapperHeade !== void 0 ? _classes$wrapperHeade : '')
|
|
39
|
+
},
|
|
40
|
+
dataTestId: tableHeaderDataTestId ? "".concat(tableHeaderDataTestId, ".dotMenu") : '',
|
|
41
|
+
iconBefore: true,
|
|
42
|
+
items: getMenuItems(secondaryActions, closeMenu),
|
|
43
|
+
onClose: closeMenu,
|
|
44
|
+
onOpen: openMenu,
|
|
45
|
+
popperProps: {
|
|
46
|
+
disablePortal: true
|
|
47
|
+
}
|
|
48
|
+
})), primaryActions.map(actionConfig => actionConfig.tooltip ? /*#__PURE__*/React.createElement(UTTooltip, _extends({
|
|
49
|
+
key: actionConfig.dataTestId || String(actionConfig.children),
|
|
50
|
+
className: actionConfig.tooltipClassName,
|
|
51
|
+
content: actionConfig.tooltip,
|
|
52
|
+
tippyProps: {
|
|
53
|
+
arrow: false,
|
|
54
|
+
placement: 'top'
|
|
55
|
+
}
|
|
56
|
+
}, actionConfig.tooltipProps), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(UTButton, _extends({
|
|
57
|
+
hideTextOnResponsive: true
|
|
58
|
+
}, actionConfig)))) : /*#__PURE__*/React.createElement(UTButton, _extends({
|
|
59
|
+
key: actionConfig.dataTestId || String(actionConfig.children),
|
|
60
|
+
dataTestId: actionConfig.dataTestId,
|
|
61
|
+
hideTextOnResponsive: true
|
|
62
|
+
}, actionConfig))));
|
|
63
|
+
};
|
|
64
|
+
ActionsMobile.propTypes = {
|
|
65
|
+
actions: arrayOf(shape({
|
|
66
|
+
children: string,
|
|
67
|
+
dataTestId: string,
|
|
68
|
+
isPrimary: bool,
|
|
69
|
+
tooltip: string
|
|
70
|
+
})),
|
|
71
|
+
anchor: object,
|
|
72
|
+
classes: objectOf(string),
|
|
73
|
+
closeMenu: func,
|
|
74
|
+
menuButtonRef: object,
|
|
75
|
+
openMenu: func,
|
|
76
|
+
tableHeaderDataTestId: string
|
|
77
|
+
};
|
|
78
|
+
export default ActionsMobile;
|
|
@@ -4,14 +4,14 @@ import React, { Fragment, useEffect, useState } from 'react';
|
|
|
4
4
|
import { arrayOf, bool, elementType, func, number, objectOf, oneOfType, shape, string } from 'prop-types';
|
|
5
5
|
import UTButton from '../../../../../UTButton';
|
|
6
6
|
import UTLabel from '../../../../../UTLabel';
|
|
7
|
-
import UTMenu from '../../../../../UTMenu';
|
|
8
7
|
import UTTooltip from '../../../../../UTTooltip';
|
|
9
8
|
import useScrollBasedMenu from '../../../../../../utils/hooks/use-scroll-based-menu';
|
|
10
9
|
import { classesType } from '../../../../types';
|
|
10
|
+
import ActionsMobile from './ActionsMobile';
|
|
11
11
|
import styles from './styles.module.scss';
|
|
12
|
-
import {
|
|
12
|
+
import { reloadWindow } from './utils';
|
|
13
13
|
const TableHeader = _ref => {
|
|
14
|
-
var _classes$wrapperHeade, _classes$textElements, _classes$titleAndDesc, _classes$selectedLabe, _classes$refreshAndAc
|
|
14
|
+
var _classes$wrapperHeade, _classes$textElements, _classes$titleAndDesc, _classes$selectedLabe, _classes$refreshAndAc;
|
|
15
15
|
let {
|
|
16
16
|
actions,
|
|
17
17
|
automaticRefreshDelay,
|
|
@@ -82,7 +82,7 @@ const TableHeader = _ref => {
|
|
|
82
82
|
weight: "medium"
|
|
83
83
|
}, selectedLabel)), /*#__PURE__*/React.createElement("article", {
|
|
84
84
|
className: "".concat(styles.refreshAndActions, " ").concat((_classes$refreshAndAc = classes.refreshAndActions) !== null && _classes$refreshAndAc !== void 0 ? _classes$refreshAndAc : '')
|
|
85
|
-
}, withRefresh && /*#__PURE__*/React.createElement(Fragment, null, !isMobile && (loading ? /*#__PURE__*/React.createElement(UTLabel, {
|
|
85
|
+
}, withRefresh && /*#__PURE__*/React.createElement(React.Fragment, null, !isMobile && (loading ? /*#__PURE__*/React.createElement(UTLabel, {
|
|
86
86
|
colorTheme: "gray",
|
|
87
87
|
dataTestId: tableHeaderDataTestId ? "".concat(tableHeaderDataTestId, ".ongoingRefreshLabel") : '',
|
|
88
88
|
variant: "small",
|
|
@@ -115,27 +115,15 @@ const TableHeader = _ref => {
|
|
|
115
115
|
onClick: handleRefresh,
|
|
116
116
|
size: "small",
|
|
117
117
|
variant: "text"
|
|
118
|
-
})))), Array.isArray(actions) && !isEmpty(actions) && !isDesktop ? /*#__PURE__*/React.createElement(
|
|
119
|
-
|
|
120
|
-
}, /*#__PURE__*/React.createElement(UTButton, {
|
|
121
|
-
dataTestId: tableHeaderDataTestId ? "".concat(tableHeaderDataTestId, ".dotMenuButton") : '',
|
|
122
|
-
Icon: "IconDots",
|
|
123
|
-
onClick: openMenu,
|
|
124
|
-
variant: "text"
|
|
125
|
-
})), /*#__PURE__*/React.createElement(UTMenu, {
|
|
118
|
+
})))), Array.isArray(actions) && !isEmpty(actions) && !isDesktop ? /*#__PURE__*/React.createElement(ActionsMobile, {
|
|
119
|
+
actions: actions,
|
|
126
120
|
anchor: anchor,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
onClose: closeMenu,
|
|
134
|
-
onOpen: openMenu,
|
|
135
|
-
popperProps: {
|
|
136
|
-
disablePortal: true
|
|
137
|
-
}
|
|
138
|
-
})) : Array.isArray(actions) && actions.map((actionConfig, index) => actionConfig.tooltip ? /*#__PURE__*/React.createElement(UTTooltip, _extends({
|
|
121
|
+
classes: classes,
|
|
122
|
+
closeMenu: closeMenu,
|
|
123
|
+
menuButtonRef: menuButtonRef,
|
|
124
|
+
openMenu: openMenu,
|
|
125
|
+
tableHeaderDataTestId: tableHeaderDataTestId
|
|
126
|
+
}) : Array.isArray(actions) && actions.map((actionConfig, index) => actionConfig.tooltip ? /*#__PURE__*/React.createElement(UTTooltip, _extends({
|
|
139
127
|
className: actionConfig.tooltipClassName,
|
|
140
128
|
content: actionConfig.tooltip,
|
|
141
129
|
dataTestId: tableHeaderDataTestId ? "".concat(tableHeaderDataTestId, ".").concat(index) : '',
|
|
@@ -158,8 +146,11 @@ TableHeader.propTypes = {
|
|
|
158
146
|
hideTextOnResponsive: bool,
|
|
159
147
|
Icon: oneOfType([elementType, string]),
|
|
160
148
|
iconPlacement: string,
|
|
149
|
+
isPrimary: bool,
|
|
150
|
+
LeftIcon: oneOfType([elementType, string]),
|
|
161
151
|
loading: bool,
|
|
162
152
|
onClick: func,
|
|
153
|
+
RightIcon: oneOfType([elementType, string]),
|
|
163
154
|
size: string,
|
|
164
155
|
type: string,
|
|
165
156
|
variant: string
|
|
@@ -9,13 +9,16 @@ export const getMenuItems = (actions, closeMenu) => actions.map(action => {
|
|
|
9
9
|
const {
|
|
10
10
|
Icon,
|
|
11
11
|
iconProps,
|
|
12
|
+
LeftIcon,
|
|
12
13
|
onClick
|
|
13
14
|
} = action;
|
|
15
|
+
// Icon is deprecated in favor of LeftIcon
|
|
16
|
+
const resolvedIcon = LeftIcon !== null && LeftIcon !== void 0 ? LeftIcon : Icon;
|
|
14
17
|
return {
|
|
15
18
|
...action,
|
|
16
|
-
Icon:
|
|
17
|
-
name:
|
|
18
|
-
}, iconProps)) :
|
|
19
|
+
Icon: resolvedIcon ? typeof resolvedIcon === 'string' ? () => /*#__PURE__*/React.createElement(UTIcon, _extends({
|
|
20
|
+
name: resolvedIcon
|
|
21
|
+
}, iconProps)) : resolvedIcon : undefined,
|
|
19
22
|
label: action.children,
|
|
20
23
|
onClick: () => {
|
|
21
24
|
onClick();
|
|
@@ -369,8 +369,11 @@ UTTable.propTypes = {
|
|
|
369
369
|
hideTextOnResponsive: bool,
|
|
370
370
|
Icon: oneOfType([elementType, string]),
|
|
371
371
|
iconPlacement: string,
|
|
372
|
+
isPrimary: bool,
|
|
373
|
+
LeftIcon: oneOfType([elementType, string]),
|
|
372
374
|
loading: bool,
|
|
373
375
|
onClick: func,
|
|
376
|
+
RightIcon: oneOfType([elementType, string]),
|
|
374
377
|
size: string,
|
|
375
378
|
type: string,
|
|
376
379
|
variant: string
|