@widergy/energy-ui 3.159.0 → 3.160.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.
Files changed (24) hide show
  1. package/CHANGELOG.md +12 -5
  2. package/dist/components/UTButton/README.md +17 -8
  3. package/dist/components/UTButton/index.js +26 -6
  4. package/dist/components/UTButton/stories/UTButton.stories.js +4 -1
  5. package/dist/components/UTButton/stories/UTButtonAdornments.stories.js +16 -11
  6. package/dist/components/UTButton/stories/storiesConstants.js +32 -10
  7. package/dist/components/UTButton/utils.js +52 -7
  8. package/dist/components/UTTable/UTTable.stories.js +34 -1
  9. package/dist/components/UTTable/components/TableHeader/versions/V1/ActionsMobile.js +85 -0
  10. package/dist/components/UTTable/components/TableHeader/versions/V1/index.js +14 -23
  11. package/dist/components/UTTable/components/TableHeader/versions/V1/utils.js +6 -3
  12. package/dist/components/UTTable/index.js +3 -0
  13. package/dist/esm/components/UTButton/README.md +17 -8
  14. package/dist/esm/components/UTButton/index.js +28 -8
  15. package/dist/esm/components/UTButton/stories/UTButton.stories.js +4 -1
  16. package/dist/esm/components/UTButton/stories/UTButtonAdornments.stories.js +15 -10
  17. package/dist/esm/components/UTButton/stories/storiesConstants.js +33 -11
  18. package/dist/esm/components/UTButton/utils.js +53 -8
  19. package/dist/esm/components/UTTable/UTTable.stories.js +33 -0
  20. package/dist/esm/components/UTTable/components/TableHeader/versions/V1/ActionsMobile.js +78 -0
  21. package/dist/esm/components/UTTable/components/TableHeader/versions/V1/index.js +15 -24
  22. package/dist/esm/components/UTTable/components/TableHeader/versions/V1/utils.js +6 -3
  23. package/dist/esm/components/UTTable/index.js +3 -0
  24. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,16 +1,23 @@
1
- # [3.159.0](https://github.com/widergy/energy-ui/compare/v3.158.1...v3.159.0) (2026-06-01)
1
+ # [3.160.0](https://github.com/widergy/energy-ui/compare/v3.159.0...v3.160.0) (2026-06-02)
2
2
 
3
3
 
4
4
  ### Features
5
5
 
6
- * [AXAG-276] bundle size ([#801](https://github.com/widergy/energy-ui/issues/801)) ([8d9cc0d](https://github.com/widergy/energy-ui/commit/8d9cc0d75f3176ad366a41bdb03c59982537003e))
6
+ * [AXCH-1489] second icon in ut button ([#805](https://github.com/widergy/energy-ui/issues/805)) ([a66bfc8](https://github.com/widergy/energy-ui/commit/a66bfc86748b07e516e5e5b53c2a08dcf3268d74))
7
7
 
8
- ## [3.158.1](https://github.com/widergy/energy-ui/compare/v3.158.0...v3.158.1) (2026-06-01)
8
+ # [3.159.0](https://github.com/widergy/energy-ui/compare/v3.158.1...v3.159.0) (2026-06-01)
9
9
 
10
+ ### Novedades y Mejoras
10
11
 
11
- ### Bug Fixes
12
+ * Se optimizó el tamaño de la aplicación: ahora solo se cargan los recursos necesarios según lo que cada pantalla utiliza, lo que mejora los tiempos de carga y el rendimiento general. [#801](https://github.com/widergy/Energy-UI/pull/801) [AXAG-276](https://widergy.atlassian.net/browse/AXAG-276)
13
+ * Los íconos de banderas se cargan de forma inteligente bajo demanda, evitando descargas innecesarias y reduciendo el consumo de datos. [#801](https://github.com/widergy/Energy-UI/pull/801) [AXAG-276](https://widergy.atlassian.net/browse/AXAG-276)
14
+ * Mejoras internas de la plataforma. [#801](https://github.com/widergy/Energy-UI/pull/801) [AXAG-276](https://widergy.atlassian.net/browse/AXAG-276)
15
+
16
+ ## [3.158.1](https://github.com/widergy/energy-ui/compare/v3.158.0...v3.158.1) (2026-06-01)
17
+
18
+ ### Correcciones
12
19
 
13
- * moved components to deprecated ([#802](https://github.com/widergy/energy-ui/issues/802)) ([b305c18](https://github.com/widergy/energy-ui/commit/b305c185d5066725f09ed5a3b321a1feb12dcd02))
20
+ * Mejoras internas de la plataforma. [#802](https://github.com/widergy/Energy-UI/pull/802) [`650c988`](https://github.com/widergy/Energy-UI/commit/650c988) [OUG-999](https://widergy.atlassian.net/browse/OUG-999)
14
21
 
15
22
  # [3.158.0](https://github.com/widergy/energy-ui/compare/v3.157.1...v3.158.0) (2026-05-19)
16
23
 
@@ -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 buttons looks.
21
- The components supports an infinite amount of color themes but requieres the consumer to pass at least a `primary` one that works as a default.
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
- ### Icon
23
+ ### Icons
24
24
 
25
- The button can include an icon, which can be either from the Tabler Icons library or a custom SVG rendered as a React component. If using an icon from the Tabler Icons library, you should provide the name of the icon. Alternatively, a custom SVG can be passed directly to the component.
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
- | Icon | node \| string | | An Icon component that can be displayed within the button. |
38
- | iconPlacement | 'left' \| 'right' | 'left' | Indicates where the icon is placed in relation with the contents of the button |
39
- | showTextOnResponsive | bool | false | If `true` and Icon is not `null` the contents of the button are not displayed. |
40
- | type | 'string' | | HTML type attribute. |
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. |
@@ -32,8 +32,12 @@ const UTButton = _ref => {
32
32
  hideTextOnResponsive,
33
33
  Icon,
34
34
  iconPlacement,
35
+ LeftIcon,
36
+ leftIconProps,
35
37
  loading,
36
38
  onClick,
39
+ RightIcon,
40
+ rightIconProps,
37
41
  size,
38
42
  type,
39
43
  variant
@@ -47,27 +51,33 @@ const UTButton = _ref => {
47
51
  ...materialButtonClasses
48
52
  } = classes;
49
53
  const {
50
- IconComponent,
51
- ...iconProps
54
+ LeftIconComponent,
55
+ leftIconProps: leftIconBaseProps,
56
+ RightIconComponent,
57
+ rightIconProps: rightIconBaseProps
52
58
  } = (0, _react.useMemo)(() => (0, _utils.getIconProps)({
53
59
  className: icon,
54
60
  colorTheme,
55
61
  hasContent: !!children,
56
62
  hideTextOnResponsive,
57
63
  Icon,
64
+ iconPlacement,
65
+ LeftIcon,
66
+ RightIcon,
58
67
  size,
59
68
  variant
60
- }), [colorTheme, children, hideTextOnResponsive, icon, Icon, size, variant]);
61
- const IconToShow = IconComponent && /*#__PURE__*/_react.default.createElement(IconComponent, iconProps);
69
+ }), [colorTheme, children, hideTextOnResponsive, icon, Icon, iconPlacement, LeftIcon, RightIcon, size, variant]);
70
+ const LeftIconToShow = LeftIconComponent && /*#__PURE__*/_react.default.createElement(LeftIconComponent, _extends({}, leftIconBaseProps, leftIconProps));
71
+ const RightIconToShow = RightIconComponent && /*#__PURE__*/_react.default.createElement(RightIconComponent, _extends({}, rightIconBaseProps, rightIconProps));
62
72
  const counterColorTheme = (0, _utils.getCounterColorTheme)(colorTheme, variant);
63
73
  const labelProps = (0, _utils.getLabelProps)(colorTheme, variant, size);
64
74
  const RenderedChildren = /*#__PURE__*/_react.default.createElement("div", {
65
75
  className: "".concat(childrenContainer, " ").concat(_stylesModule.default["".concat(size, "ChildrenContainer")])
66
76
  }, count && /*#__PURE__*/_react.default.createElement(_UTBadge.default, {
67
77
  colorTheme: counterColorTheme
68
- }, count), iconPlacement === _constants.ICON_PLACEMENTS.left && IconToShow, children !== null && children !== undefined && children !== false && /*#__PURE__*/_react.default.createElement(_UTLabel.default, _extends({}, labelProps, {
78
+ }, count), LeftIconToShow, children !== null && children !== undefined && children !== false && /*#__PURE__*/_react.default.createElement(_UTLabel.default, _extends({}, labelProps, {
69
79
  className: "".concat(_stylesModule.default.textContainer, " ").concat(textClassName)
70
- }), children), iconPlacement !== _constants.ICON_PLACEMENTS.left && IconToShow);
80
+ }), children), RightIconToShow);
71
81
  return /*#__PURE__*/_react.default.createElement(_Button.default, {
72
82
  classes: materialButtonClasses,
73
83
  className: "\n ".concat(_stylesModule.default["padding".concat((0, _componentUtils.capitalize)(size))], "\n ").concat(hideTextOnResponsive && _stylesModule.default.hideTextOnResponsive, "\n ").concat(!hideTextOnResponsive && !children && _stylesModule.default.noChildren, "\n "),
@@ -89,10 +99,20 @@ UTButton.propTypes = {
89
99
  dataTestId: _propTypes.string,
90
100
  disabled: _propTypes.bool,
91
101
  hideTextOnResponsive: _propTypes.bool,
102
+ /**
103
+ * @deprecated Use LeftIcon or RightIcon instead.
104
+ */
92
105
  Icon: _propTypes.elementType,
106
+ /**
107
+ * @deprecated Use LeftIcon or RightIcon instead.
108
+ */
93
109
  iconPlacement: _propTypes.string,
110
+ LeftIcon: _propTypes.elementType,
111
+ leftIconProps: _propTypes.object,
94
112
  loading: _propTypes.bool,
95
113
  onClick: _propTypes.func,
114
+ RightIcon: _propTypes.elementType,
115
+ rightIconProps: _propTypes.object,
96
116
  size: _propTypes.string,
97
117
  type: _propTypes.string,
98
118
  variant: _propTypes.string
@@ -14,8 +14,11 @@ var _default = exports.default = {
14
14
  children: undefined,
15
15
  classNames: undefined,
16
16
  count: undefined,
17
- Icon: undefined,
17
+ LeftIcon: undefined,
18
+ leftIconProps: undefined,
18
19
  onClick: undefined,
20
+ RightIcon: undefined,
21
+ rightIconProps: undefined,
19
22
  ..._storiesConstants.COMMON_ARGS
20
23
  },
21
24
  argTypes: {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.IconPlacementRight = exports.IconPlacementLeft = exports.IconOnly = exports.CountOnly = exports.CountAndIcon = void 0;
6
+ exports.default = exports.RightIconOnly = exports.LeftIconOnly = exports.IconOnly = exports.CountOnly = exports.CountAndIcon = exports.BothIcons = void 0;
7
7
  var _ = _interopRequireDefault(require(".."));
8
8
  var _storiesConstants = require("./storiesConstants");
9
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -20,29 +20,34 @@ var _default = exports.default = {
20
20
  ..._storiesConstants.COMMON_PARAMETERS
21
21
  }
22
22
  };
23
- const IconPlacementLeft = exports.IconPlacementLeft = {
23
+ const LeftIconOnly = exports.LeftIconOnly = {
24
24
  args: {
25
- children: 'Icon Placement Left',
26
- Icon: 'IconArrowLeft',
27
- iconPlacement: 'left'
25
+ children: 'Left Icon',
26
+ LeftIcon: 'IconArrowLeft'
28
27
  }
29
28
  };
30
- const IconPlacementRight = exports.IconPlacementRight = {
29
+ const RightIconOnly = exports.RightIconOnly = {
31
30
  args: {
32
- children: 'Icon Placement Right',
33
- Icon: 'IconArrowRight',
34
- iconPlacement: 'right'
31
+ children: 'Right Icon',
32
+ RightIcon: 'IconArrowRight'
33
+ }
34
+ };
35
+ const BothIcons = exports.BothIcons = {
36
+ args: {
37
+ children: 'Descargas',
38
+ LeftIcon: 'IconDownload',
39
+ RightIcon: 'IconChevronDown'
35
40
  }
36
41
  };
37
42
  const IconOnly = exports.IconOnly = {
38
43
  args: {
39
- Icon: 'IconSearch'
44
+ LeftIcon: 'IconSearch'
40
45
  }
41
46
  };
42
47
  const CountAndIcon = exports.CountAndIcon = {
43
48
  args: {
44
49
  count: 7,
45
- Icon: 'IconBell'
50
+ LeftIcon: 'IconBell'
46
51
  }
47
52
  };
48
53
  const CountOnly = exports.CountOnly = {
@@ -95,7 +95,7 @@ const COMMON_ARG_TYPES = exports.COMMON_ARG_TYPES = {
95
95
  },
96
96
  hideTextOnResponsive: {
97
97
  control: 'boolean',
98
- description: 'Si es `true` y el icono no es `null`, el contenido del botón no se muestra en dispositivos móviles.',
98
+ description: 'Si es `true` y hay ícono, el contenido del botón no se muestra en dispositivos móviles.',
99
99
  table: {
100
100
  defaultValue: {
101
101
  summary: _constants.DEFAULT_PROPS.hideTextOnResponsive
@@ -105,9 +105,9 @@ const COMMON_ARG_TYPES = exports.COMMON_ARG_TYPES = {
105
105
  }
106
106
  }
107
107
  },
108
- Icon: {
108
+ LeftIcon: {
109
109
  control: 'text',
110
- description: 'Icono a mostrar en el botón. Puede ser un nombre de icono de Tabler o un componente personalizado.',
110
+ description: 'Ícono a mostrar al inicio del botón. Puede ser un nombre de icono de Tabler o un componente personalizado.',
111
111
  table: {
112
112
  defaultValue: {
113
113
  summary: 'undefined'
@@ -117,16 +117,15 @@ const COMMON_ARG_TYPES = exports.COMMON_ARG_TYPES = {
117
117
  }
118
118
  }
119
119
  },
120
- iconPlacement: {
121
- control: 'inline-radio',
122
- description: 'Posición del icono en relación al contenido del botón.',
123
- options: Object.values(_constants.ICON_PLACEMENTS),
120
+ leftIconProps: {
121
+ control: false,
122
+ description: 'Props adicionales a aplicar al ícono izquierdo.',
124
123
  table: {
125
124
  defaultValue: {
126
- summary: _constants.DEFAULT_PROPS.iconPlacement
125
+ summary: 'undefined'
127
126
  },
128
127
  type: {
129
- summary: (0, _utils.joinArgTypes)(Object.values(_constants.ICON_PLACEMENTS))
128
+ summary: 'object'
130
129
  }
131
130
  }
132
131
  },
@@ -154,6 +153,30 @@ const COMMON_ARG_TYPES = exports.COMMON_ARG_TYPES = {
154
153
  }
155
154
  }
156
155
  },
156
+ RightIcon: {
157
+ control: 'text',
158
+ description: 'Ícono a mostrar al final del botón. Puede ser un nombre de icono de Tabler o un componente personalizado.',
159
+ table: {
160
+ defaultValue: {
161
+ summary: 'undefined'
162
+ },
163
+ type: {
164
+ summary: (0, _utils.joinArgTypes)(['string', 'ReactComponent'])
165
+ }
166
+ }
167
+ },
168
+ rightIconProps: {
169
+ control: false,
170
+ description: 'Props adicionales a aplicar al ícono derecho.',
171
+ table: {
172
+ defaultValue: {
173
+ summary: 'undefined'
174
+ },
175
+ type: {
176
+ summary: 'object'
177
+ }
178
+ }
179
+ },
157
180
  size: {
158
181
  control: 'inline-radio',
159
182
  description: 'Tamaño del botón.',
@@ -200,7 +223,6 @@ const COMMON_ARGS = exports.COMMON_ARGS = {
200
223
  dataTestId: 'customButtonId',
201
224
  disabled: _constants.DEFAULT_PROPS.disabled,
202
225
  hideTextOnResponsive: _constants.DEFAULT_PROPS.hideTextOnResponsive,
203
- iconPlacement: _constants.DEFAULT_PROPS.iconPlacement,
204
226
  loading: _constants.DEFAULT_PROPS.loading,
205
227
  size: _constants.DEFAULT_PROPS.size,
206
228
  type: 'button',
@@ -11,24 +11,69 @@ var _constants = require("./constants");
11
11
  var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
12
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
13
  const getButtonElementColorTheme = (buttonColorTheme, buttonVariant) => buttonVariant === _constants.VARIANTS_NAMES.filled ? buttonColorTheme === _constants.COLORS_MAPPER.negative ? _Palette.COLOR_THEMES.neutral : _Palette.COLOR_THEMES.negative : _constants.COLORS_MAPPER[buttonColorTheme];
14
- const getIconProps = _ref => {
14
+ const buildSingleIconProps = _ref => {
15
15
  let {
16
16
  className,
17
- colorTheme: buttonColorTheme,
17
+ colorTheme,
18
18
  hasContent,
19
19
  hideTextOnResponsive,
20
20
  Icon,
21
21
  size,
22
- variant: buttonVariant
22
+ variant
23
23
  } = _ref;
24
- return Icon ? {
24
+ if (!Icon) return null;
25
+ return {
25
26
  IconComponent: (0, _componentUtils.isUTIcon)(Icon) ? _UTIcon.default : Icon,
26
- className: "\n ".concat(_stylesModule.default.baseIcon, "\n ").concat(className, "\n ").concat(hasContent ? _stylesModule.default.icon : _stylesModule.default["iconOnly".concat((0, _componentUtils.capitalize)(size))], "\n ").concat(hideTextOnResponsive ? _stylesModule.default["adaptableIcon".concat((0, _componentUtils.capitalize)(size))] : '', "\n "),
27
+ className: "\n ".concat(_stylesModule.default.baseIcon, "\n ").concat(className, "\n ").concat(hasContent ? _stylesModule.default.icon : _stylesModule.default["iconOnly".concat((0, _componentUtils.capitalize)(size))], "\n ").concat(hideTextOnResponsive ? _stylesModule.default["adaptableIcon".concat((0, _componentUtils.capitalize)(size))] : '', "\n "),
27
28
  ...((0, _componentUtils.isUTIcon)(Icon) ? {
28
- colorTheme: getButtonElementColorTheme(buttonColorTheme, buttonVariant),
29
+ colorTheme: getButtonElementColorTheme(colorTheme, variant),
29
30
  name: Icon
30
31
  } : {})
31
- } : {};
32
+ };
33
+ };
34
+ const getIconProps = _ref2 => {
35
+ let {
36
+ className,
37
+ colorTheme,
38
+ hasContent,
39
+ hideTextOnResponsive,
40
+ Icon,
41
+ iconPlacement,
42
+ LeftIcon,
43
+ RightIcon,
44
+ size,
45
+ variant
46
+ } = _ref2;
47
+ const resolvedLeftIcon = LeftIcon || (iconPlacement !== _constants.ICON_PLACEMENTS.right ? Icon : undefined);
48
+ const resolvedRightIcon = RightIcon || (iconPlacement === _constants.ICON_PLACEMENTS.right ? Icon : undefined);
49
+ const commonParams = {
50
+ className,
51
+ colorTheme,
52
+ hasContent,
53
+ hideTextOnResponsive,
54
+ size,
55
+ variant
56
+ };
57
+ const {
58
+ IconComponent: LeftIconComponent,
59
+ ...leftIconProps
60
+ } = buildSingleIconProps({
61
+ ...commonParams,
62
+ Icon: resolvedLeftIcon
63
+ }) || {};
64
+ const {
65
+ IconComponent: RightIconComponent,
66
+ ...rightIconProps
67
+ } = buildSingleIconProps({
68
+ ...commonParams,
69
+ Icon: resolvedRightIcon
70
+ }) || {};
71
+ return {
72
+ LeftIconComponent: LeftIconComponent || null,
73
+ leftIconProps,
74
+ RightIconComponent: RightIconComponent || null,
75
+ rightIconProps
76
+ };
32
77
  };
33
78
  exports.getIconProps = getIconProps;
34
79
  const getLabelProps = (buttonColorTheme, buttonVariant, buttonSize) => ({
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.WithRefresh = exports.WithPagination = exports.WithCustomRenderers = exports.WithActions = exports.TableHeaderV1WithSelection = exports.TableHeaderV1WithRefresh = exports.TableHeaderV1WithAutomaticRefresh = exports.TableHeaderV1WithActions = exports.TableHeaderV1Loading = exports.TableHeaderV1Basic = exports.TableHeaderV0WithReload = exports.TableHeaderV0Basic = exports.StickyHeader = exports.Selectable = exports.Playground = exports.NoPagination = exports.Loading = exports.FitColumnsWidth = exports.ExternalIntegration = exports.ExclusiveSelection = exports.EmptyState = exports.CustomSpacing = exports.CustomNoResults = exports.CompleteExample = exports.ClickableRows = exports.Basic = void 0;
6
+ exports.default = exports.WithRefresh = exports.WithPagination = exports.WithCustomRenderers = exports.WithActions = exports.TableHeaderV1WithSelection = exports.TableHeaderV1WithRefresh = exports.TableHeaderV1WithPrimaryActions = exports.TableHeaderV1WithAutomaticRefresh = exports.TableHeaderV1WithActions = exports.TableHeaderV1Loading = exports.TableHeaderV1Basic = exports.TableHeaderV0WithReload = exports.TableHeaderV0Basic = exports.StickyHeader = exports.Selectable = exports.Playground = exports.NoPagination = exports.Loading = exports.FitColumnsWidth = exports.ExternalIntegration = exports.ExclusiveSelection = exports.EmptyState = exports.CustomSpacing = exports.CustomNoResults = exports.CompleteExample = exports.ClickableRows = exports.Basic = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _utils = require("stories/utils");
9
9
  var _UTLabel = _interopRequireDefault(require("../UTLabel"));
@@ -933,6 +933,39 @@ const TableHeaderV1WithActions = exports.TableHeaderV1WithActions = {
933
933
  },
934
934
  name: 'Header V1 - Con Acciones'
935
935
  };
936
+ const TableHeaderV1WithPrimaryActions = exports.TableHeaderV1WithPrimaryActions = {
937
+ args: {
938
+ data: mockData.slice(0, 10),
939
+ columns: basicColumns,
940
+ headerVersion: 'V1',
941
+ withActionHeader: true,
942
+ tableTitle: 'Tabla con Acciones Primarias V1',
943
+ description: 'Header V1 con isPrimary: las acciones primarias siempre son visibles (solo ícono en mobile), las secundarias colapsan en el dots menu.',
944
+ actionsConfig: [{
945
+ isPrimary: true,
946
+ LeftIcon: 'IconPlus',
947
+ onClick: () => alert('Nuevo trámite'),
948
+ variant: 'filled',
949
+ colorTheme: 'primary',
950
+ size: 'small',
951
+ children: 'Nuevo trámite'
952
+ }, {
953
+ LeftIcon: 'IconDownload',
954
+ RightIcon: 'IconChevronDown',
955
+ onClick: () => alert('Descargas'),
956
+ variant: 'outlined',
957
+ size: 'small',
958
+ children: 'Descargas'
959
+ }, {
960
+ Icon: 'IconFilter',
961
+ onClick: () => alert('Filtrar'),
962
+ variant: 'outlined',
963
+ size: 'small',
964
+ children: 'Filtros'
965
+ }]
966
+ },
967
+ name: 'Header V1 - Con Acciones Primarias'
968
+ };
936
969
  const TableHeaderV1WithSelection = exports.TableHeaderV1WithSelection = {
937
970
  args: {
938
971
  data: mockData.slice(0, 10),
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
8
+ var _partition = _interopRequireDefault(require("lodash/partition"));
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _propTypes = require("prop-types");
11
+ var _UTButton = _interopRequireDefault(require("../../../../../UTButton"));
12
+ var _UTMenu = _interopRequireDefault(require("../../../../../UTMenu"));
13
+ var _UTTooltip = _interopRequireDefault(require("../../../../../UTTooltip"));
14
+ var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
15
+ var _utils = require("./utils");
16
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
+ 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); }
18
+ const ActionsMobile = _ref => {
19
+ var _classes$wrapperHeade;
20
+ let {
21
+ actions,
22
+ anchor,
23
+ classes,
24
+ closeMenu,
25
+ menuButtonRef,
26
+ openMenu,
27
+ tableHeaderDataTestId
28
+ } = _ref;
29
+ const [primaryActions, secondaryActions] = (0, _partition.default)(actions, _ref2 => {
30
+ let {
31
+ isPrimary
32
+ } = _ref2;
33
+ return isPrimary;
34
+ });
35
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !(0, _isEmpty.default)(secondaryActions) && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
36
+ ref: menuButtonRef
37
+ }, /*#__PURE__*/_react.default.createElement(_UTButton.default, {
38
+ dataTestId: tableHeaderDataTestId ? "".concat(tableHeaderDataTestId, ".dotMenuButton") : '',
39
+ Icon: "IconDots",
40
+ onClick: openMenu,
41
+ variant: "text"
42
+ })), /*#__PURE__*/_react.default.createElement(_UTMenu.default, {
43
+ anchor: anchor,
44
+ classNames: {
45
+ menuItemContainer: "".concat(_stylesModule.default.wrapperHeaderMenuItem, " ").concat((_classes$wrapperHeade = classes.wrapperHeaderMenuItem) !== null && _classes$wrapperHeade !== void 0 ? _classes$wrapperHeade : '')
46
+ },
47
+ dataTestId: tableHeaderDataTestId ? "".concat(tableHeaderDataTestId, ".dotMenu") : '',
48
+ iconBefore: true,
49
+ items: (0, _utils.getMenuItems)(secondaryActions, closeMenu),
50
+ onClose: closeMenu,
51
+ onOpen: openMenu,
52
+ popperProps: {
53
+ disablePortal: true
54
+ }
55
+ })), primaryActions.map(actionConfig => actionConfig.tooltip ? /*#__PURE__*/_react.default.createElement(_UTTooltip.default, _extends({
56
+ key: actionConfig.dataTestId || String(actionConfig.children),
57
+ className: actionConfig.tooltipClassName,
58
+ content: actionConfig.tooltip,
59
+ tippyProps: {
60
+ arrow: false,
61
+ placement: 'top'
62
+ }
63
+ }, actionConfig.tooltipProps), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_UTButton.default, _extends({
64
+ hideTextOnResponsive: true
65
+ }, actionConfig)))) : /*#__PURE__*/_react.default.createElement(_UTButton.default, _extends({
66
+ key: actionConfig.dataTestId || String(actionConfig.children),
67
+ dataTestId: actionConfig.dataTestId,
68
+ hideTextOnResponsive: true
69
+ }, actionConfig))));
70
+ };
71
+ ActionsMobile.propTypes = {
72
+ actions: (0, _propTypes.arrayOf)((0, _propTypes.shape)({
73
+ children: _propTypes.string,
74
+ dataTestId: _propTypes.string,
75
+ isPrimary: _propTypes.bool,
76
+ tooltip: _propTypes.string
77
+ })),
78
+ anchor: _propTypes.object,
79
+ classes: (0, _propTypes.objectOf)(_propTypes.string),
80
+ closeMenu: _propTypes.func,
81
+ menuButtonRef: _propTypes.object,
82
+ openMenu: _propTypes.func,
83
+ tableHeaderDataTestId: _propTypes.string
84
+ };
85
+ var _default = exports.default = ActionsMobile;
@@ -9,17 +9,17 @@ var _react = _interopRequireWildcard(require("react"));
9
9
  var _propTypes = require("prop-types");
10
10
  var _UTButton = _interopRequireDefault(require("../../../../../UTButton"));
11
11
  var _UTLabel = _interopRequireDefault(require("../../../../../UTLabel"));
12
- var _UTMenu = _interopRequireDefault(require("../../../../../UTMenu"));
13
12
  var _UTTooltip = _interopRequireDefault(require("../../../../../UTTooltip"));
14
13
  var _useScrollBasedMenu = _interopRequireDefault(require("../../../../../../utils/hooks/use-scroll-based-menu"));
15
14
  var _types = require("../../../../types");
15
+ var _ActionsMobile = _interopRequireDefault(require("./ActionsMobile"));
16
16
  var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
17
17
  var _utils = require("./utils");
18
18
  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); }
19
19
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
20
  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); }
21
21
  const TableHeader = _ref => {
22
- var _classes$wrapperHeade, _classes$textElements, _classes$titleAndDesc, _classes$selectedLabe, _classes$refreshAndAc, _classes$wrapperHeade2;
22
+ var _classes$wrapperHeade, _classes$textElements, _classes$titleAndDesc, _classes$selectedLabe, _classes$refreshAndAc;
23
23
  let {
24
24
  actions,
25
25
  automaticRefreshDelay,
@@ -90,7 +90,7 @@ const TableHeader = _ref => {
90
90
  weight: "medium"
91
91
  }, selectedLabel)), /*#__PURE__*/_react.default.createElement("article", {
92
92
  className: "".concat(_stylesModule.default.refreshAndActions, " ").concat((_classes$refreshAndAc = classes.refreshAndActions) !== null && _classes$refreshAndAc !== void 0 ? _classes$refreshAndAc : '')
93
- }, withRefresh && /*#__PURE__*/_react.default.createElement(_react.Fragment, null, !isMobile && (loading ? /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
93
+ }, withRefresh && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !isMobile && (loading ? /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
94
94
  colorTheme: "gray",
95
95
  dataTestId: tableHeaderDataTestId ? "".concat(tableHeaderDataTestId, ".ongoingRefreshLabel") : '',
96
96
  variant: "small",
@@ -123,27 +123,15 @@ const TableHeader = _ref => {
123
123
  onClick: handleRefresh,
124
124
  size: "small",
125
125
  variant: "text"
126
- })))), Array.isArray(actions) && !(0, _isEmpty.default)(actions) && !isDesktop ? /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
127
- ref: menuButtonRef
128
- }, /*#__PURE__*/_react.default.createElement(_UTButton.default, {
129
- dataTestId: tableHeaderDataTestId ? "".concat(tableHeaderDataTestId, ".dotMenuButton") : '',
130
- Icon: "IconDots",
131
- onClick: openMenu,
132
- variant: "text"
133
- })), /*#__PURE__*/_react.default.createElement(_UTMenu.default, {
126
+ })))), Array.isArray(actions) && !(0, _isEmpty.default)(actions) && !isDesktop ? /*#__PURE__*/_react.default.createElement(_ActionsMobile.default, {
127
+ actions: actions,
134
128
  anchor: anchor,
135
- classNames: {
136
- menuItemContainer: "".concat(_stylesModule.default.wrapperHeaderMenuItem, " ").concat((_classes$wrapperHeade2 = classes.wrapperHeaderMenuItem) !== null && _classes$wrapperHeade2 !== void 0 ? _classes$wrapperHeade2 : '')
137
- },
138
- dataTestId: tableHeaderDataTestId ? "".concat(tableHeaderDataTestId, ".dotMenu") : '',
139
- iconBefore: true,
140
- items: (0, _utils.getMenuItems)(actions, closeMenu),
141
- onClose: closeMenu,
142
- onOpen: openMenu,
143
- popperProps: {
144
- disablePortal: true
145
- }
146
- })) : Array.isArray(actions) && actions.map((actionConfig, index) => actionConfig.tooltip ? /*#__PURE__*/_react.default.createElement(_UTTooltip.default, _extends({
129
+ classes: classes,
130
+ closeMenu: closeMenu,
131
+ menuButtonRef: menuButtonRef,
132
+ openMenu: openMenu,
133
+ tableHeaderDataTestId: tableHeaderDataTestId
134
+ }) : Array.isArray(actions) && actions.map((actionConfig, index) => actionConfig.tooltip ? /*#__PURE__*/_react.default.createElement(_UTTooltip.default, _extends({
147
135
  className: actionConfig.tooltipClassName,
148
136
  content: actionConfig.tooltip,
149
137
  dataTestId: tableHeaderDataTestId ? "".concat(tableHeaderDataTestId, ".").concat(index) : '',
@@ -166,8 +154,11 @@ TableHeader.propTypes = {
166
154
  hideTextOnResponsive: _propTypes.bool,
167
155
  Icon: (0, _propTypes.oneOfType)([_propTypes.elementType, _propTypes.string]),
168
156
  iconPlacement: _propTypes.string,
157
+ isPrimary: _propTypes.bool,
158
+ LeftIcon: (0, _propTypes.oneOfType)([_propTypes.elementType, _propTypes.string]),
169
159
  loading: _propTypes.bool,
170
160
  onClick: _propTypes.func,
161
+ RightIcon: (0, _propTypes.oneOfType)([_propTypes.elementType, _propTypes.string]),
171
162
  size: _propTypes.string,
172
163
  type: _propTypes.string,
173
164
  variant: _propTypes.string
@@ -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: Icon ? typeof Icon === 'string' ? () => /*#__PURE__*/_react.default.createElement(_UTIcon.default, _extends({
25
- name: Icon
26
- }, iconProps)) : Icon : undefined,
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 buttons looks.
21
- The components supports an infinite amount of color themes but requieres the consumer to pass at least a `primary` one that works as a default.
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
- ### Icon
23
+ ### Icons
24
24
 
25
- The button can include an icon, which can be either from the Tabler Icons library or a custom SVG rendered as a React component. If using an icon from the Tabler Icons library, you should provide the name of the icon. Alternatively, a custom SVG can be passed directly to the component.
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
- | Icon | node \| string | | An Icon component that can be displayed within the button. |
38
- | iconPlacement | 'left' \| 'right' | 'left' | Indicates where the icon is placed in relation with the contents of the button |
39
- | showTextOnResponsive | bool | false | If `true` and Icon is not `null` the contents of the button are not displayed. |
40
- | type | 'string' | | HTML type attribute. |
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 { ICON_PLACEMENTS, DEFAULT_PROPS } from './constants';
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
- IconComponent,
43
- ...iconProps
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 IconToShow = IconComponent && /*#__PURE__*/React.createElement(IconComponent, iconProps);
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), iconPlacement === ICON_PLACEMENTS.left && IconToShow, children !== null && children !== undefined && children !== false && /*#__PURE__*/React.createElement(UTLabel, _extends({}, labelProps, {
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), iconPlacement !== ICON_PLACEMENTS.left && IconToShow);
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
- Icon: undefined,
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 IconPlacementLeft = {
16
+ export const LeftIconOnly = {
17
17
  args: {
18
- children: 'Icon Placement Left',
19
- Icon: 'IconArrowLeft',
20
- iconPlacement: 'left'
18
+ children: 'Left Icon',
19
+ LeftIcon: 'IconArrowLeft'
21
20
  }
22
21
  };
23
- export const IconPlacementRight = {
22
+ export const RightIconOnly = {
24
23
  args: {
25
- children: 'Icon Placement Right',
26
- Icon: 'IconArrowRight',
27
- iconPlacement: 'right'
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
- Icon: 'IconSearch'
37
+ LeftIcon: 'IconSearch'
33
38
  }
34
39
  };
35
40
  export const CountAndIcon = {
36
41
  args: {
37
42
  count: 7,
38
- Icon: 'IconBell'
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, ICON_PLACEMENTS, DEFAULT_PROPS, COLORS_MAPPER } from '../constants';
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 el icono no es `null`, el contenido del botón no se muestra en dispositivos móviles.',
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
- Icon: {
103
+ LeftIcon: {
104
104
  control: 'text',
105
- description: 'Icono a mostrar en el botón. Puede ser un nombre de icono de Tabler o un componente personalizado.',
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
- iconPlacement: {
116
- control: 'inline-radio',
117
- description: 'Posición del icono en relación al contenido del botón.',
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: DEFAULT_PROPS.iconPlacement
120
+ summary: 'undefined'
122
121
  },
123
122
  type: {
124
- summary: joinArgTypes(Object.values(ICON_PLACEMENTS))
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
- export const getIconProps = _ref => {
7
+ const buildSingleIconProps = _ref => {
8
8
  let {
9
9
  className,
10
- colorTheme: buttonColorTheme,
10
+ colorTheme,
11
11
  hasContent,
12
12
  hideTextOnResponsive,
13
13
  Icon,
14
14
  size,
15
- variant: buttonVariant
15
+ variant
16
16
  } = _ref;
17
- return Icon ? {
17
+ if (!Icon) return null;
18
+ return {
18
19
  IconComponent: isUTIcon(Icon) ? UTIcon : Icon,
19
- 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
+ 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(buttonColorTheme, buttonVariant),
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),
@@ -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 { getMenuItems, reloadWindow } from './utils';
12
+ import { reloadWindow } from './utils';
13
13
  const TableHeader = _ref => {
14
- var _classes$wrapperHeade, _classes$textElements, _classes$titleAndDesc, _classes$selectedLabe, _classes$refreshAndAc, _classes$wrapperHeade2;
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(Fragment, null, /*#__PURE__*/React.createElement("div", {
119
- ref: menuButtonRef
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
- classNames: {
128
- menuItemContainer: "".concat(styles.wrapperHeaderMenuItem, " ").concat((_classes$wrapperHeade2 = classes.wrapperHeaderMenuItem) !== null && _classes$wrapperHeade2 !== void 0 ? _classes$wrapperHeade2 : '')
129
- },
130
- dataTestId: tableHeaderDataTestId ? "".concat(tableHeaderDataTestId, ".dotMenu") : '',
131
- iconBefore: true,
132
- items: getMenuItems(actions, closeMenu),
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: Icon ? typeof Icon === 'string' ? () => /*#__PURE__*/React.createElement(UTIcon, _extends({
17
- name: Icon
18
- }, iconProps)) : Icon : undefined,
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widergy/energy-ui",
3
- "version": "3.159.0",
3
+ "version": "3.160.0",
4
4
  "description": "Widergy Web Components",
5
5
  "author": "widergy",
6
6
  "license": "MIT",