@widergy/energy-ui 3.87.2 → 3.89.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 +14 -0
- package/dist/components/UTDataCategory/README.md +19 -0
- package/dist/components/UTDataCategory/index.js +92 -0
- package/dist/components/UTDataCategory/styles.module.scss +30 -0
- package/dist/components/UTDataCategory/theme.js +35 -0
- package/dist/components/UTDataElement/README.md +136 -0
- package/dist/components/UTDataElement/components/MainAction/index.js +61 -0
- package/dist/components/UTDataElement/components/MainAction/styles.module.scss +23 -0
- package/dist/components/UTDataElement/constants.js +22 -0
- package/dist/components/UTDataElement/index.js +131 -0
- package/dist/components/UTDataElement/styles.module.scss +65 -0
- package/dist/components/UTDataElement/theme.js +33 -0
- package/dist/components/UTLabel/README.md +1 -1
- package/dist/constants/testIds.js +14 -1
- package/dist/utils/componentUtils.js +3 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [3.89.0](https://github.com/widergy/energy-ui/compare/v3.88.0...v3.89.0) (2025-07-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* [SFPE-404] add UTDataCategory ([#635](https://github.com/widergy/energy-ui/issues/635)) ([52ce4c6](https://github.com/widergy/energy-ui/commit/52ce4c6eeeb4fa29b9236473c1173e18da3248a6))
|
|
7
|
+
|
|
8
|
+
# [3.88.0](https://github.com/widergy/energy-ui/compare/v3.87.2...v3.88.0) (2025-07-15)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* [SFPE-405] UTDataElement ([#633](https://github.com/widergy/energy-ui/issues/633)) ([5c9084b](https://github.com/widergy/energy-ui/commit/5c9084bff7986202a8a0bece3af8021e8cf57aaa))
|
|
14
|
+
|
|
1
15
|
## [3.87.2](https://github.com/widergy/energy-ui/compare/v3.87.1...v3.87.2) (2025-07-15)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# UTDataCategory
|
|
2
|
+
|
|
3
|
+
UTDataCategory component
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
| Name | Type | Default | Description |
|
|
8
|
+
| ------------- | ------ | ------- | ------------------------------------------------------------ |
|
|
9
|
+
| area | bool | `false` | Specifies whether the component has an area. |
|
|
10
|
+
| collapsable | bool | `true` | Specifies if the data list is collapsable |
|
|
11
|
+
| elements | array | | Array of items to be rendered as UTDataElement |
|
|
12
|
+
| classNames | object | | Custom style for the component. |
|
|
13
|
+
| title | string | | Title text displayed in the component. |
|
|
14
|
+
| titleProps | object | | Additional props for customizing the title. |
|
|
15
|
+
| elementsProps | object | {} | Additional props for customizing elements that apply to all. |
|
|
16
|
+
|
|
17
|
+
### colapsable
|
|
18
|
+
|
|
19
|
+
The component is only collapsable if it has a title
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _propTypes = require("prop-types");
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _WithTheme = _interopRequireDefault(require("../WithTheme"));
|
|
10
|
+
var _UTDataElement = _interopRequireDefault(require("../UTDataElement"));
|
|
11
|
+
var _UTLabel = _interopRequireDefault(require("../UTLabel"));
|
|
12
|
+
var _UTButton = _interopRequireDefault(require("../UTButton"));
|
|
13
|
+
var _classesUtils = require("../../utils/classesUtils");
|
|
14
|
+
var _testIds = require("../../constants/testIds");
|
|
15
|
+
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
16
|
+
var _theme = require("./theme");
|
|
17
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
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
|
+
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); }
|
|
20
|
+
const {
|
|
21
|
+
dataCategory
|
|
22
|
+
} = _testIds.TEST_IDS;
|
|
23
|
+
const UTDataCategory = _ref => {
|
|
24
|
+
let {
|
|
25
|
+
area,
|
|
26
|
+
classes: theme,
|
|
27
|
+
classNames,
|
|
28
|
+
collapsable = true,
|
|
29
|
+
dataTestId,
|
|
30
|
+
elements = [],
|
|
31
|
+
elementsProps = {},
|
|
32
|
+
title,
|
|
33
|
+
titleProps
|
|
34
|
+
} = _ref;
|
|
35
|
+
const showTitle = !!title;
|
|
36
|
+
const classes = (0, _react.useMemo)(() => (0, _classesUtils.mergeClasses)(theme, classNames), [classNames, theme]);
|
|
37
|
+
const [isCollapsed, setIsCollapsed] = (0, _react.useState)(showTitle && collapsable);
|
|
38
|
+
const childrenRef = (0, _react.useRef)(null);
|
|
39
|
+
const toggleCollapsed = () => setIsCollapsed(!isCollapsed);
|
|
40
|
+
const containerClasses = "".concat(_stylesModule.default.container, " ").concat(classes.container || '', " ").concat(area ? classes.area : '');
|
|
41
|
+
const collapseButtonClasses = "".concat(_stylesModule.default.collapseButton, " ").concat(isCollapsed ? _stylesModule.default.collapsed : '');
|
|
42
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
43
|
+
className: containerClasses,
|
|
44
|
+
"data-testid": dataTestId ? "".concat(dataTestId, ".").concat(dataCategory.container) : undefined
|
|
45
|
+
}, title && /*#__PURE__*/_react.default.createElement("div", {
|
|
46
|
+
className: _stylesModule.default.title
|
|
47
|
+
}, /*#__PURE__*/_react.default.createElement(_UTLabel.default, _extends({
|
|
48
|
+
colorTheme: "gray",
|
|
49
|
+
weight: "medium"
|
|
50
|
+
}, titleProps), title), collapsable && /*#__PURE__*/_react.default.createElement("div", {
|
|
51
|
+
className: collapseButtonClasses
|
|
52
|
+
}, /*#__PURE__*/_react.default.createElement(_UTButton.default, {
|
|
53
|
+
Icon: "IconChevronUp",
|
|
54
|
+
variant: "text",
|
|
55
|
+
onClick: toggleCollapsed,
|
|
56
|
+
size: "small",
|
|
57
|
+
dataTestId: dataTestId ? "".concat(dataTestId, ".").concat(dataCategory.collapseButton) : undefined
|
|
58
|
+
}))), /*#__PURE__*/_react.default.createElement("div", {
|
|
59
|
+
style: {
|
|
60
|
+
gridTemplateRows: isCollapsed ? '0fr' : '1fr',
|
|
61
|
+
marginTop: isCollapsed || !showTitle ? 0 : 16
|
|
62
|
+
},
|
|
63
|
+
className: _stylesModule.default.children
|
|
64
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
65
|
+
ref: childrenRef,
|
|
66
|
+
className: _stylesModule.default.childrenContent
|
|
67
|
+
}, elements.map((element, index) => {
|
|
68
|
+
const {
|
|
69
|
+
key,
|
|
70
|
+
...dataElementProps
|
|
71
|
+
} = element;
|
|
72
|
+
return /*#__PURE__*/_react.default.createElement(_UTDataElement.default, _extends({
|
|
73
|
+
key: key || index,
|
|
74
|
+
dataTestId: dataTestId ? "".concat(dataTestId, ".dataElement.").concat(index) : "".concat(dataCategory.dataElement, ".").concat(index),
|
|
75
|
+
classNames: classes.element
|
|
76
|
+
}, elementsProps, dataElementProps));
|
|
77
|
+
}))));
|
|
78
|
+
};
|
|
79
|
+
UTDataCategory.propTypes = {
|
|
80
|
+
area: _propTypes.bool,
|
|
81
|
+
areaProps: _propTypes.object,
|
|
82
|
+
collapsable: _propTypes.bool,
|
|
83
|
+
elements: _propTypes.array,
|
|
84
|
+
elementsProps: _propTypes.object,
|
|
85
|
+
style: _propTypes.object,
|
|
86
|
+
title: _propTypes.string,
|
|
87
|
+
titleProps: _propTypes.object,
|
|
88
|
+
classes: (0, _propTypes.objectOf)(_propTypes.string),
|
|
89
|
+
classNames: (0, _propTypes.objectOf)(_propTypes.string),
|
|
90
|
+
dataTestId: _propTypes.string
|
|
91
|
+
};
|
|
92
|
+
var _default = exports.default = (0, _WithTheme.default)(_theme.retrieveStyle)(UTDataCategory);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.title {
|
|
7
|
+
align-items: center;
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: row;
|
|
10
|
+
grid-gap: 8px;
|
|
11
|
+
width: 100%;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.collapseButton {
|
|
15
|
+
transition: transform 0.3s ease-in-out;
|
|
16
|
+
|
|
17
|
+
&.collapsed {
|
|
18
|
+
transform: rotate(180deg);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.children {
|
|
23
|
+
display: grid;
|
|
24
|
+
transition: grid-template-rows 0.3s ease-in-out, margin-top 0.3s ease-in-out;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.childrenContent {
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
min-height: 0;
|
|
30
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.retrieveStyle = exports.backgroundColor = void 0;
|
|
7
|
+
var _Palette = require("../../constants/Palette");
|
|
8
|
+
const backgroundColor = function (theme, area) {
|
|
9
|
+
var _theme$Palette;
|
|
10
|
+
let areaProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
11
|
+
const colorTheme = areaProps.colorTheme || _Palette.COLOR_THEMES.light;
|
|
12
|
+
const actionPaletteColors = ((_theme$Palette = theme.Palette) === null || _theme$Palette === void 0 ? void 0 : _theme$Palette.actions) || theme.Palette;
|
|
13
|
+
const areaColor = actionPaletteColors[colorTheme];
|
|
14
|
+
const shade = areaProps.shade || (_Palette.COLOR_THEMES.light === colorTheme ? '03' : '01');
|
|
15
|
+
return {
|
|
16
|
+
backgroundColor: area ? areaColor[shade] : 'transparent'
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
exports.backgroundColor = backgroundColor;
|
|
20
|
+
const retrieveStyle = _ref => {
|
|
21
|
+
let {
|
|
22
|
+
area,
|
|
23
|
+
theme,
|
|
24
|
+
areaProps
|
|
25
|
+
} = _ref;
|
|
26
|
+
const areaBackgroundColor = backgroundColor(theme, area, areaProps);
|
|
27
|
+
return {
|
|
28
|
+
area: {
|
|
29
|
+
...areaBackgroundColor,
|
|
30
|
+
padding: 16,
|
|
31
|
+
borderRadius: 8
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
exports.retrieveStyle = retrieveStyle;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# UTDataElement
|
|
2
|
+
|
|
3
|
+
A versatile data component that can be customized with various themes, sizes, icons, data elements, and actions. It supports both horizontal and vertical layouts, collapsible content, and different types of actions including buttons and switches.
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
| Name | Type | Default | Description |
|
|
8
|
+
| --------------- | ----------------- | ------------ | ------------------------------------------------------------------ |
|
|
9
|
+
| action | object | | Action configuration for button or switch. See Action Types below. |
|
|
10
|
+
| area | bool | `false` | Specifies whether the component has a background area. |
|
|
11
|
+
| badge | string \| number | | Displays a badge with text or number. |
|
|
12
|
+
| badgeProps | object | `{}` | Additional props for customizing the badge. |
|
|
13
|
+
| children | element | | Collapsible content displayed below the main component. |
|
|
14
|
+
| classes | objectOf(string) | | Theme classes for styling. |
|
|
15
|
+
| classNames | objectOf(string) | | Additional class names for custom styling. |
|
|
16
|
+
| Data | element \| string | | Data content to display (can be a React element or string). |
|
|
17
|
+
| dataProps | object | `{}` | Additional props for configuring the data element. |
|
|
18
|
+
| forceShowBadge | bool | `false` | Forces the badge to be displayed even when empty. |
|
|
19
|
+
| Icon | element \| string | | Icon to display (can be a UTIcon name or custom React element). |
|
|
20
|
+
| iconProps | object | `{}` | Additional props for the icon element. |
|
|
21
|
+
| orientation | string | `horizontal` | Defines the layout orientation. |
|
|
22
|
+
| paddingVertical | string | `medium` | Vertical padding applied to the component. |
|
|
23
|
+
| prefix | string | | Text or symbol displayed before the title. |
|
|
24
|
+
| prefixProps | object | `{}` | Additional props for customizing the prefix. |
|
|
25
|
+
| spacing | string | `medium` | Defines the spacing between elements. |
|
|
26
|
+
| title | string | | Title text displayed in the component. |
|
|
27
|
+
| titleProps | object | `{}` | Additional props for customizing the title. |
|
|
28
|
+
|
|
29
|
+
## Action Types
|
|
30
|
+
|
|
31
|
+
The `action` prop supports two types of actions:
|
|
32
|
+
|
|
33
|
+
### Button Action
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
{
|
|
37
|
+
type: 'button',
|
|
38
|
+
onClick: () => console.log('Button clicked'),
|
|
39
|
+
Icon: 'IconEdit',
|
|
40
|
+
// ... other UTButton props
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Switch Action
|
|
45
|
+
|
|
46
|
+
```javascript
|
|
47
|
+
{
|
|
48
|
+
type: 'switch',
|
|
49
|
+
onChange: (value) => console.log('Switch toggled:', value),
|
|
50
|
+
value: true,
|
|
51
|
+
// ... other UTSwitch props
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Orientation
|
|
56
|
+
|
|
57
|
+
The value of `orientation` must be one of the following:
|
|
58
|
+
|
|
59
|
+
- `horizontal` - Elements are arranged in a row
|
|
60
|
+
- `vertical` - Elements are arranged in a column
|
|
61
|
+
|
|
62
|
+
## Padding & Spacing
|
|
63
|
+
|
|
64
|
+
The values of `paddingVertical` and `spacing` must be one of the following:
|
|
65
|
+
|
|
66
|
+
- `small` - 8px spacing/padding
|
|
67
|
+
- `medium` - 16px spacing/padding
|
|
68
|
+
|
|
69
|
+
## Collapsible Content
|
|
70
|
+
|
|
71
|
+
If the component has any `children`, it will automatically become collapsible with a chevron button to expand/collapse the content.
|
|
72
|
+
|
|
73
|
+
## Examples
|
|
74
|
+
|
|
75
|
+
### Basic Usage
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
<UTDataElement title="User Information" Data="John Doe" Icon="IconUser" />
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### With Action and Badge
|
|
82
|
+
|
|
83
|
+
```javascript
|
|
84
|
+
<UTDataElement
|
|
85
|
+
title="Status"
|
|
86
|
+
Data="Active"
|
|
87
|
+
badge="New"
|
|
88
|
+
action={{
|
|
89
|
+
type: 'button',
|
|
90
|
+
onClick: () => console.log('Edit clicked'),
|
|
91
|
+
Icon: 'IconEdit'
|
|
92
|
+
}}
|
|
93
|
+
/>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### With Switch Action
|
|
97
|
+
|
|
98
|
+
```javascript
|
|
99
|
+
<UTDataElement
|
|
100
|
+
title="Notifications"
|
|
101
|
+
Data="Email notifications enabled"
|
|
102
|
+
action={{
|
|
103
|
+
type: 'switch',
|
|
104
|
+
onChange: value => setNotifications(value),
|
|
105
|
+
value: notificationsEnabled
|
|
106
|
+
}}
|
|
107
|
+
/>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### With Collapsible Content
|
|
111
|
+
|
|
112
|
+
```javascript
|
|
113
|
+
<UTDataElement title="Details" Data="Click to expand" Icon="IconInfo">
|
|
114
|
+
<UTLabel>Additional information here</UTLabel>
|
|
115
|
+
<UTIcon name="IconBeach" colorTheme="success" />
|
|
116
|
+
</UTDataElement>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### With Custom Data Component
|
|
120
|
+
|
|
121
|
+
```javascript
|
|
122
|
+
<UTDataElement
|
|
123
|
+
title="Status"
|
|
124
|
+
Data={
|
|
125
|
+
<UTStatus variant="information" Icon="IconPlanet">
|
|
126
|
+
Online
|
|
127
|
+
</UTStatus>
|
|
128
|
+
}
|
|
129
|
+
/>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### With Area Background
|
|
133
|
+
|
|
134
|
+
```javascript
|
|
135
|
+
<UTDataElement area title="Highlighted Item" Data="Important information" Icon="IconStar" />
|
|
136
|
+
```
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _propTypes = require("prop-types");
|
|
9
|
+
var _testIds = require("../../../../constants/testIds");
|
|
10
|
+
var _UTSwitch = _interopRequireDefault(require("../../../UTSwitch"));
|
|
11
|
+
var _UTButton = _interopRequireDefault(require("../../../UTButton"));
|
|
12
|
+
var _constants = require("../../constants");
|
|
13
|
+
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
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); }
|
|
16
|
+
const {
|
|
17
|
+
dataElement
|
|
18
|
+
} = _testIds.TEST_IDS;
|
|
19
|
+
const MainAction = _ref => {
|
|
20
|
+
let {
|
|
21
|
+
type = _constants.ACTION_TYPE.BUTTON,
|
|
22
|
+
onChange,
|
|
23
|
+
value,
|
|
24
|
+
onClick,
|
|
25
|
+
dataTestId,
|
|
26
|
+
id,
|
|
27
|
+
...props
|
|
28
|
+
} = _ref;
|
|
29
|
+
return type === _constants.ACTION_TYPE.SWITCH && onChange ? /*#__PURE__*/_react.default.createElement("div", {
|
|
30
|
+
className: _stylesModule.default.container
|
|
31
|
+
}, /*#__PURE__*/_react.default.createElement(_UTSwitch.default, _extends({
|
|
32
|
+
dataTestId: dataTestId ? "".concat(dataTestId, ".").concat(dataElement.switchAction) : undefined,
|
|
33
|
+
input: {
|
|
34
|
+
onChange,
|
|
35
|
+
value
|
|
36
|
+
},
|
|
37
|
+
field: {
|
|
38
|
+
key: "".concat(id)
|
|
39
|
+
}
|
|
40
|
+
}, props, {
|
|
41
|
+
classNames: {
|
|
42
|
+
container: _stylesModule.default.switchContainer,
|
|
43
|
+
slider: _stylesModule.default.slider,
|
|
44
|
+
sliderContainer: _stylesModule.default.sliderContainer,
|
|
45
|
+
sliderHover: _stylesModule.default.sliderHover
|
|
46
|
+
}
|
|
47
|
+
}))) : type === _constants.ACTION_TYPE.BUTTON && onClick ? /*#__PURE__*/_react.default.createElement(_UTButton.default, _extends({
|
|
48
|
+
dataTestId: dataTestId ? "".concat(dataTestId, ".").concat(dataElement.buttonAction) : undefined,
|
|
49
|
+
variant: "text",
|
|
50
|
+
onClick: onClick
|
|
51
|
+
}, props)) : null;
|
|
52
|
+
};
|
|
53
|
+
MainAction.propTypes = {
|
|
54
|
+
dataTestId: _propTypes.string,
|
|
55
|
+
id: (0, _propTypes.oneOfType)([_propTypes.string, _propTypes.number]),
|
|
56
|
+
onChange: _propTypes.func,
|
|
57
|
+
onClick: _propTypes.func,
|
|
58
|
+
type: (0, _propTypes.oneOf)(Object.values(_constants.ACTION_TYPE)),
|
|
59
|
+
value: _propTypes.bool
|
|
60
|
+
};
|
|
61
|
+
var _default = exports.default = MainAction;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
display: flex;
|
|
3
|
+
width: 41px;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.switchContainer {
|
|
7
|
+
height: 20px !important;
|
|
8
|
+
width: 40px !important;
|
|
9
|
+
|
|
10
|
+
& input:checked ~ .sliderContainer > {
|
|
11
|
+
.slider {
|
|
12
|
+
transform: translateX(20px) !important;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.slider {
|
|
18
|
+
margin-left: -20px !important;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.sliderHover {
|
|
22
|
+
display: none;
|
|
23
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SPACING = exports.PADDING = exports.ORIENTATION = exports.ACTION_TYPE = void 0;
|
|
7
|
+
const ORIENTATION = exports.ORIENTATION = {
|
|
8
|
+
HORIZONTAL: 'horizontal',
|
|
9
|
+
VERTICAL: 'vertical'
|
|
10
|
+
};
|
|
11
|
+
const PADDING = exports.PADDING = {
|
|
12
|
+
SMALL: 'small',
|
|
13
|
+
MEDIUM: 'medium'
|
|
14
|
+
};
|
|
15
|
+
const SPACING = exports.SPACING = {
|
|
16
|
+
SMALL: 'small',
|
|
17
|
+
MEDIUM: 'medium'
|
|
18
|
+
};
|
|
19
|
+
const ACTION_TYPE = exports.ACTION_TYPE = {
|
|
20
|
+
SWITCH: 'switch',
|
|
21
|
+
BUTTON: 'button'
|
|
22
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _propTypes = require("prop-types");
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
10
|
+
var _isString = _interopRequireDefault(require("lodash/isString"));
|
|
11
|
+
var _isFinite = _interopRequireDefault(require("lodash/isFinite"));
|
|
12
|
+
var _UTBadge = _interopRequireDefault(require("../UTBadge"));
|
|
13
|
+
var _UTLabel = _interopRequireDefault(require("../UTLabel"));
|
|
14
|
+
var _WithTheme = _interopRequireDefault(require("../WithTheme"));
|
|
15
|
+
var _UTIcon = _interopRequireDefault(require("../UTIcon"));
|
|
16
|
+
var _componentUtils = require("../../utils/componentUtils");
|
|
17
|
+
var _classesUtils = require("../../utils/classesUtils");
|
|
18
|
+
var _UTButton = _interopRequireDefault(require("../UTButton"));
|
|
19
|
+
var _testIds = require("../../constants/testIds");
|
|
20
|
+
var _theme = require("./theme");
|
|
21
|
+
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
22
|
+
var _constants = require("./constants");
|
|
23
|
+
var _MainAction = _interopRequireDefault(require("./components/MainAction"));
|
|
24
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
25
|
+
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); }
|
|
26
|
+
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); }
|
|
27
|
+
const {
|
|
28
|
+
dataElement
|
|
29
|
+
} = _testIds.TEST_IDS;
|
|
30
|
+
const UTDataElement = _ref => {
|
|
31
|
+
let {
|
|
32
|
+
action,
|
|
33
|
+
area,
|
|
34
|
+
badge,
|
|
35
|
+
badgeProps = {},
|
|
36
|
+
children,
|
|
37
|
+
classes: theme,
|
|
38
|
+
classNames,
|
|
39
|
+
Data,
|
|
40
|
+
dataProps = {},
|
|
41
|
+
dataTestId,
|
|
42
|
+
forceShowBadge = false,
|
|
43
|
+
Icon,
|
|
44
|
+
iconProps = {},
|
|
45
|
+
orientation = _constants.ORIENTATION.HORIZONTAL,
|
|
46
|
+
paddingVertical = _constants.PADDING.MEDIUM,
|
|
47
|
+
prefix,
|
|
48
|
+
prefixProps = {},
|
|
49
|
+
spacing = _constants.SPACING.MEDIUM,
|
|
50
|
+
title,
|
|
51
|
+
titleProps = {}
|
|
52
|
+
} = _ref;
|
|
53
|
+
const classes = (0, _react.useMemo)(() => (0, _classesUtils.mergeClasses)(theme, classNames), [classNames, theme]);
|
|
54
|
+
const [isCollapsed, setIsCollapsed] = (0, _react.useState)(true);
|
|
55
|
+
const [childrenHeight, setChildrenHeight] = (0, _react.useState)(0);
|
|
56
|
+
const childrenRef = (0, _react.useRef)(null);
|
|
57
|
+
const toggleCollapsed = (0, _react.useCallback)(() => setIsCollapsed(!isCollapsed), [isCollapsed]);
|
|
58
|
+
(0, _react.useEffect)(() => {
|
|
59
|
+
if (childrenRef.current) {
|
|
60
|
+
const rect = childrenRef.current.getBoundingClientRect();
|
|
61
|
+
setChildrenHeight(rect.height);
|
|
62
|
+
}
|
|
63
|
+
}, [children]);
|
|
64
|
+
const IconComponent = (0, _componentUtils.isUTIcon)(Icon) ? _UTIcon.default : Icon;
|
|
65
|
+
const DataComponent = (0, _componentUtils.isUTLabel)(Data) ? /*#__PURE__*/_react.default.createElement(_UTLabel.default, dataProps, Data) : Data;
|
|
66
|
+
const showBadge = forceShowBadge || (0, _isString.default)(badge) && !(0, _isEmpty.default)(badge) || (0, _isFinite.default)(badge);
|
|
67
|
+
const contentClasses = "".concat(_stylesModule.default.content, " ").concat(_stylesModule.default["spacing".concat((0, _componentUtils.capitalize)(spacing))]);
|
|
68
|
+
const infoClasses = "".concat(_stylesModule.default.info, " ").concat(orientation === _constants.ORIENTATION.VERTICAL && _stylesModule.default.vertical);
|
|
69
|
+
const iconCollapseButtonClasses = "".concat(_stylesModule.default.iconCollapseButton, " ").concat(isCollapsed && _stylesModule.default.collapsed);
|
|
70
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
71
|
+
className: "".concat(_stylesModule.default.container, " ").concat(classes.container, " ").concat(area ? classes.area : '', " ").concat(_stylesModule.default["padding".concat((0, _componentUtils.capitalize)(paddingVertical))]),
|
|
72
|
+
"data-testid": dataTestId ? "".concat(dataTestId, ".").concat(dataElement.container) : undefined
|
|
73
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
74
|
+
className: contentClasses
|
|
75
|
+
}, IconComponent && /*#__PURE__*/_react.default.createElement(IconComponent, _extends({
|
|
76
|
+
name: Icon,
|
|
77
|
+
colorTheme: "gray"
|
|
78
|
+
}, iconProps)), /*#__PURE__*/_react.default.createElement("div", {
|
|
79
|
+
className: infoClasses
|
|
80
|
+
}, (prefix || title || showBadge) && /*#__PURE__*/_react.default.createElement("div", {
|
|
81
|
+
className: _stylesModule.default.topInfo
|
|
82
|
+
}, prefix && /*#__PURE__*/_react.default.createElement(_UTLabel.default, _extends({
|
|
83
|
+
colorTheme: "gray"
|
|
84
|
+
}, prefixProps), prefix), title && /*#__PURE__*/_react.default.createElement(_UTLabel.default, _extends({
|
|
85
|
+
colorTheme: "gray"
|
|
86
|
+
}, titleProps), title), showBadge && /*#__PURE__*/_react.default.createElement(_UTBadge.default, _extends({
|
|
87
|
+
colorTheme: "accent",
|
|
88
|
+
className: _stylesModule.default.badge
|
|
89
|
+
}, badgeProps), forceShowBadge ? null : badge)), DataComponent && DataComponent), action && /*#__PURE__*/_react.default.createElement(_MainAction.default, _extends({
|
|
90
|
+
dataTestId: dataTestId
|
|
91
|
+
}, action)), children && /*#__PURE__*/_react.default.createElement(_UTButton.default, {
|
|
92
|
+
classNames: {
|
|
93
|
+
icon: iconCollapseButtonClasses
|
|
94
|
+
},
|
|
95
|
+
Icon: "IconChevronUp",
|
|
96
|
+
onClick: toggleCollapsed,
|
|
97
|
+
size: "small",
|
|
98
|
+
variant: "text",
|
|
99
|
+
dataTestId: dataTestId ? "".concat(dataTestId, ".").concat(dataElement.collapseButton) : undefined
|
|
100
|
+
})), children && /*#__PURE__*/_react.default.createElement("div", {
|
|
101
|
+
style: {
|
|
102
|
+
maxHeight: isCollapsed ? 0 : childrenHeight,
|
|
103
|
+
marginTop: isCollapsed ? 0 : 16
|
|
104
|
+
},
|
|
105
|
+
className: _stylesModule.default.children
|
|
106
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
107
|
+
ref: childrenRef
|
|
108
|
+
}, children)));
|
|
109
|
+
};
|
|
110
|
+
UTDataElement.propTypes = {
|
|
111
|
+
action: _propTypes.object,
|
|
112
|
+
area: _propTypes.bool,
|
|
113
|
+
badge: _propTypes.string,
|
|
114
|
+
badgeProps: _propTypes.object,
|
|
115
|
+
classes: (0, _propTypes.objectOf)(_propTypes.string),
|
|
116
|
+
classNames: (0, _propTypes.objectOf)(_propTypes.string),
|
|
117
|
+
Data: (0, _propTypes.oneOfType)([_propTypes.element, _propTypes.string]),
|
|
118
|
+
dataProps: _propTypes.object,
|
|
119
|
+
dataTestId: _propTypes.string,
|
|
120
|
+
forceShowBadge: _propTypes.bool,
|
|
121
|
+
Icon: (0, _propTypes.oneOfType)([_propTypes.element, _propTypes.string]),
|
|
122
|
+
iconProps: _propTypes.object,
|
|
123
|
+
orientation: _propTypes.string,
|
|
124
|
+
paddingVertical: _propTypes.string,
|
|
125
|
+
prefix: _propTypes.string,
|
|
126
|
+
prefixProps: _propTypes.object,
|
|
127
|
+
spacing: _propTypes.string,
|
|
128
|
+
title: _propTypes.string,
|
|
129
|
+
titleProps: _propTypes.object
|
|
130
|
+
};
|
|
131
|
+
var _default = exports.default = (0, _WithTheme.default)(_theme.retrieveStyle)(UTDataElement);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.paddingSmall {
|
|
7
|
+
padding: 8px 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.paddingMedium {
|
|
11
|
+
padding: 16px 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.content {
|
|
15
|
+
align-items: center;
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: row;
|
|
18
|
+
width: 100%;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.spacingSmall {
|
|
22
|
+
grid-gap: 8px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.spacingMedium {
|
|
26
|
+
grid-gap: 16px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.info {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: row;
|
|
32
|
+
grid-gap: 8px;
|
|
33
|
+
justify-content: space-between;
|
|
34
|
+
flex: 1;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.vertical {
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.topInfo {
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: row;
|
|
44
|
+
align-items: center;
|
|
45
|
+
grid-gap: 8px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.iconCollapseButton {
|
|
49
|
+
transition: transform 0.3s ease-in-out;
|
|
50
|
+
|
|
51
|
+
&.collapsed {
|
|
52
|
+
transform: rotate(180deg);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.children {
|
|
57
|
+
overflow: hidden;
|
|
58
|
+
transition:
|
|
59
|
+
max-height 0.3s ease,
|
|
60
|
+
margin-top 0.3s ease;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.badge {
|
|
64
|
+
width: fit-content !important;
|
|
65
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.retrieveStyle = exports.backgroundColor = void 0;
|
|
7
|
+
var _Palette = require("../../constants/Palette");
|
|
8
|
+
const backgroundColor = (theme, area) => {
|
|
9
|
+
var _theme$Palette;
|
|
10
|
+
const colorTheme = _Palette.COLOR_THEMES.light;
|
|
11
|
+
const actionPaletteColors = ((_theme$Palette = theme.Palette) === null || _theme$Palette === void 0 ? void 0 : _theme$Palette.actions) || theme.Palette;
|
|
12
|
+
const areaColor = actionPaletteColors[colorTheme];
|
|
13
|
+
return {
|
|
14
|
+
backgroundColor: area ? areaColor['03'] : 'transparent'
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
exports.backgroundColor = backgroundColor;
|
|
18
|
+
const retrieveStyle = _ref => {
|
|
19
|
+
let {
|
|
20
|
+
area,
|
|
21
|
+
theme
|
|
22
|
+
} = _ref;
|
|
23
|
+
const areaBackgroundColor = backgroundColor(theme, area);
|
|
24
|
+
return {
|
|
25
|
+
area: {
|
|
26
|
+
...areaBackgroundColor,
|
|
27
|
+
paddingLeft: 16,
|
|
28
|
+
paddingRight: 16,
|
|
29
|
+
borderRadius: 8
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
exports.retrieveStyle = retrieveStyle;
|
|
@@ -7,7 +7,7 @@ Component used for displaying text values and markdown.
|
|
|
7
7
|
|
|
8
8
|
| Name | Type | Default | Description |
|
|
9
9
|
| ------------------- | -------- | ------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
10
|
-
| align | string |
|
|
10
|
+
| align | string | | Alignment of the text content. Accepts values like 'left', 'center', 'right', or 'justify'. |
|
|
11
11
|
| className | string | | Additional classes. |
|
|
12
12
|
| classes | string | | Classes returned by UTLabel's own[theme](./theme.js#L40) `retrieveStyle`. |
|
|
13
13
|
| colorTheme | string | 'primary' | Color theme to style the UTLabel. Has to be defined in the proyect theme.[Example](#colortheme). |
|
|
@@ -17,7 +17,9 @@ const ID_CONSTANTS = exports.ID_CONSTANTS = {
|
|
|
17
17
|
STATUS_MESSAGE: 'statusMessage',
|
|
18
18
|
TABLE: 'table',
|
|
19
19
|
TABLE_ROW: 'tableRow',
|
|
20
|
-
WORKFLOW_CONTAINER: 'workflowContainer'
|
|
20
|
+
WORKFLOW_CONTAINER: 'workflowContainer',
|
|
21
|
+
DATA_CATEGORY: 'dataCategory',
|
|
22
|
+
DATA_ELEMENT: 'dataElement'
|
|
21
23
|
};
|
|
22
24
|
const TEST_IDS = exports.TEST_IDS = {
|
|
23
25
|
barChart: {
|
|
@@ -38,6 +40,17 @@ const TEST_IDS = exports.TEST_IDS = {
|
|
|
38
40
|
expires: "".concat(ID_CONSTANTS.CREDIT_CARD, ".expires"),
|
|
39
41
|
nameField: "".concat(ID_CONSTANTS.CREDIT_CARD, ".nameField")
|
|
40
42
|
},
|
|
43
|
+
dataCategory: {
|
|
44
|
+
container: "".concat(ID_CONSTANTS.DATA_CATEGORY, ".container"),
|
|
45
|
+
collapseButton: "".concat(ID_CONSTANTS.DATA_CATEGORY, ".collapseButton"),
|
|
46
|
+
dataElement: "".concat(ID_CONSTANTS.DATA_CATEGORY, ".dataElement")
|
|
47
|
+
},
|
|
48
|
+
dataElement: {
|
|
49
|
+
container: "".concat(ID_CONSTANTS.DATA_ELEMENT, ".container"),
|
|
50
|
+
collapseButton: "".concat(ID_CONSTANTS.DATA_ELEMENT, ".collapseButton"),
|
|
51
|
+
switchAction: "".concat(ID_CONSTANTS.DATA_ELEMENT, ".actionSwitch"),
|
|
52
|
+
buttonAction: "".concat(ID_CONSTANTS.DATA_ELEMENT, ".actionButton")
|
|
53
|
+
},
|
|
41
54
|
dialog: {
|
|
42
55
|
acceptButton: "".concat(ID_CONSTANTS.DIALOG, ".acceptButton"),
|
|
43
56
|
cancelButton: "".concat(ID_CONSTANTS.DIALOG, ".cancelButton"),
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.valueExists = exports.isUTIcon = exports.getDefaultColorShade = exports.default = exports.capitalize = void 0;
|
|
6
|
+
exports.valueExists = exports.isUTLabel = exports.isUTIcon = exports.getDefaultColorShade = exports.default = exports.capitalize = void 0;
|
|
7
7
|
var _Palette = require("../constants/Palette");
|
|
8
8
|
const A_CHAR_CODE = 65;
|
|
9
9
|
const Z_CHAR_CODE = 90;
|
|
@@ -19,6 +19,8 @@ const getAvatarColors = (userName, colors) => {
|
|
|
19
19
|
const getFirstLetter = userName => (userName === null || userName === void 0 ? void 0 : userName.trim().slice(0, 1).toUpperCase()) || 'A';
|
|
20
20
|
const isUTIcon = icon => typeof icon === 'string';
|
|
21
21
|
exports.isUTIcon = isUTIcon;
|
|
22
|
+
const isUTLabel = label => typeof label === 'string' || typeof label === 'number';
|
|
23
|
+
exports.isUTLabel = isUTLabel;
|
|
22
24
|
const getDefaultColorShade = colorTheme => colorTheme === _Palette.COLOR_THEMES.gray ? _Palette.COLOR_SHADES.shade04 : colorTheme === _Palette.COLOR_THEMES.light ? _Palette.COLOR_SHADES.shade01 : _Palette.COLOR_SHADES.shade05;
|
|
23
25
|
exports.getDefaultColorShade = getDefaultColorShade;
|
|
24
26
|
const valueExists = value => value !== undefined && value !== null;
|