@widergy/energy-ui 3.1.7 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ## [3.2.1](https://github.com/widergy/energy-ui/compare/v3.2.0...v3.2.1) (2024-02-20)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * minor fix ([#415](https://github.com/widergy/energy-ui/issues/415)) ([d26822e](https://github.com/widergy/energy-ui/commit/d26822e70070bbf7543f053fa6e2e808d937dbee))
7
+
8
+ # [3.2.0](https://github.com/widergy/energy-ui/compare/v3.1.7...v3.2.0) (2024-02-14)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * fix pr ([85fe5ba](https://github.com/widergy/energy-ui/commit/85fe5ba1a525fa189b289754f4322b3aa55fe64d))
14
+ * fix pr ([9736b29](https://github.com/widergy/energy-ui/commit/9736b29787905fbbe38a1a46b0efcf1579b790d0))
15
+ * minor fix ([b422f41](https://github.com/widergy/energy-ui/commit/b422f41aa0f46d1330a49aca6ac256a61c07fe01))
16
+
17
+
18
+ ### Features
19
+
20
+ * new componente + lint identation fixes ([005287f](https://github.com/widergy/energy-ui/commit/005287fc033a7ff41606c026cb106e480631e9c7))
21
+
1
22
  ## [3.1.7](https://github.com/widergy/energy-ui/compare/v3.1.6...v3.1.7) (2024-02-07)
2
23
 
3
24
 
@@ -0,0 +1,28 @@
1
+ # UTProductItem
2
+
3
+ ### Description
4
+ Product item component.
5
+
6
+ ### Action
7
+ This action object will wait for a function and a type to apply a determinate style to the action button:
8
+ Available types:
9
+ - `add`
10
+ - `modify`
11
+ - `detail`
12
+ - `modifyDetail`
13
+
14
+ Also, you can pass a CustomIcon if you want to.
15
+
16
+ ### Props
17
+
18
+ | Name | Type | Default |Description |
19
+ |----------------------|-----------------------------------------------------------------------------------------------------------------|-----------|---------------------------------|
20
+ | action | object: {CustomIcon: ReactComponent, type: 'add' \| 'modify' \| 'detail' \| 'modifyDetail', onClick: () => () } | | The action definition. |
21
+ | additionalInfo | string | | The additional info to detail. |
22
+ | amount | | | The current amount. |
23
+ | discount | number | | Current discount. |
24
+ | discountSize | 'small' \| 'medium' | medium | UTLabel component variant. |
25
+ | Image | asset | | Image of the product. |
26
+ | previousAmount | number | | Amount without discount applied.|
27
+ | selectedQuantity | number | | Selected item product quantity. |
28
+ | title | string | | Product name. |
@@ -0,0 +1,3 @@
1
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M8 0C8.55228 0 9 0.447715 9 1V7H15C15.5523 7 16 7.44772 16 8C16 8.55228 15.5523 9 15 9H9V15C9 15.5523 8.55228 16 8 16C7.44772 16 7 15.5523 7 15V9H1C0.447715 9 0 8.55228 0 8C0 7.44772 0.447715 7 1 7H7V1C7 0.447715 7.44772 0 8 0Z" fill="#091E42"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="8" height="14" viewBox="0 0 8 14" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M0.292893 0.292893C0.683417 -0.0976311 1.31658 -0.0976311 1.70711 0.292893L7.70711 6.29289C8.09763 6.68342 8.09763 7.31658 7.70711 7.70711L1.70711 13.7071C1.31658 14.0976 0.683417 14.0976 0.292893 13.7071C-0.0976311 13.3166 -0.0976311 12.6834 0.292893 12.2929L5.58579 7L0.292893 1.70711C-0.0976311 1.31658 -0.0976311 0.683417 0.292893 0.292893Z" fill="white"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M12.0189 6.67867L9.3239 3.98367L11.2719 2.03467L13.9659 4.72867L12.0189 6.67867ZM5.0799 13.6247L2.1029 13.8957L2.3669 10.9397L7.9839 5.32267L10.6799 8.01867L5.0799 13.6247ZM15.4039 3.33767L15.4029 3.33667L12.6649 0.598675C11.9239 -0.140325 10.6509 -0.175325 9.9489 0.529675L0.952896 9.52567C0.626896 9.85067 0.424896 10.2827 0.382896 10.7397L0.00389602 14.9097C-0.022104 15.2047 0.082896 15.4967 0.292896 15.7067C0.481896 15.8957 0.736896 15.9997 0.999896 15.9997C1.0309 15.9997 1.0609 15.9987 1.0909 15.9957L5.2609 15.6167C5.7189 15.5747 6.1499 15.3737 6.4749 15.0487L15.4719 6.05167C16.1999 5.32167 16.1689 4.10367 15.4039 3.33767Z" fill="#091E42"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M12.0189 6.67867L9.3239 3.98367L11.2719 2.03467L13.9659 4.72867L12.0189 6.67867ZM5.0799 13.6247L2.1029 13.8957L2.3669 10.9397L7.9839 5.32267L10.6799 8.01867L5.0799 13.6247ZM15.4039 3.33767L15.4029 3.33667L12.6649 0.598675C11.9239 -0.140325 10.6509 -0.175325 9.9489 0.529675L0.952896 9.52567C0.626896 9.85067 0.424896 10.2827 0.382896 10.7397L0.00389602 14.9097C-0.022104 15.2047 0.082896 15.4967 0.292896 15.7067C0.481896 15.8957 0.736896 15.9997 0.999896 15.9997C1.0309 15.9997 1.0609 15.9987 1.0909 15.9957L5.2609 15.6167C5.7189 15.5747 6.1499 15.3737 6.4749 15.0487L15.4719 6.05167C16.1999 5.32167 16.1689 4.10367 15.4039 3.33767Z" fill="white"/>
3
+ </svg>
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.actionMapper = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ var Add = function Add(props) {
10
+ return /*#__PURE__*/_react.default.createElement("svg", props, /*#__PURE__*/_react.default.createElement("path", {
11
+ fillRule: "evenodd",
12
+ clipRule: "evenodd",
13
+ d: "M8 0a1 1 0 0 1 1 1v6h6a1 1 0 1 1 0 2H9v6a1 1 0 1 1-2 0V9H1a1 1 0 0 1 0-2h6V1a1 1 0 0 1 1-1Z",
14
+ fill: "#091E42"
15
+ }));
16
+ };
17
+ Add.defaultProps = {
18
+ width: "16",
19
+ height: "16",
20
+ viewBox: "0 0 16 16",
21
+ fill: "none",
22
+ xmlns: "http://www.w3.org/2000/svg"
23
+ };
24
+ var Edit = function Edit(props) {
25
+ return /*#__PURE__*/_react.default.createElement("svg", props, /*#__PURE__*/_react.default.createElement("path", {
26
+ fillRule: "evenodd",
27
+ clipRule: "evenodd",
28
+ d: "M12.019 6.679 9.324 3.984l1.948-1.95 2.694 2.695-1.947 1.95Zm-6.94 6.946-2.976.27.264-2.955 5.617-5.617 2.696 2.696-5.6 5.606ZM15.405 3.338l-.001-.001L12.665.599c-.741-.74-2.014-.774-2.716-.07L.953 9.527a1.973 1.973 0 0 0-.57 1.214l-.38 4.17a1.002 1.002 0 0 0 1.088 1.086l4.17-.38a1.974 1.974 0 0 0 1.214-.567l8.997-8.997c.728-.73.697-1.948-.068-2.714Z",
29
+ fill: "#091E42"
30
+ }));
31
+ };
32
+ Edit.defaultProps = {
33
+ width: "16",
34
+ height: "16",
35
+ viewBox: "0 0 16 16",
36
+ fill: "none",
37
+ xmlns: "http://www.w3.org/2000/svg"
38
+ };
39
+ var Detail = function Detail(props) {
40
+ return /*#__PURE__*/_react.default.createElement("svg", props, /*#__PURE__*/_react.default.createElement("path", {
41
+ fillRule: "evenodd",
42
+ clipRule: "evenodd",
43
+ d: "M.293.293a1 1 0 0 1 1.414 0l6 6a1 1 0 0 1 0 1.414l-6 6a1 1 0 0 1-1.414-1.414L5.586 7 .293 1.707a1 1 0 0 1 0-1.414Z",
44
+ fill: "#fff"
45
+ }));
46
+ };
47
+ Detail.defaultProps = {
48
+ width: "8",
49
+ height: "14",
50
+ viewBox: "0 0 8 14",
51
+ fill: "none",
52
+ xmlns: "http://www.w3.org/2000/svg"
53
+ };
54
+ var ModifyDetail = function ModifyDetail(props) {
55
+ return /*#__PURE__*/_react.default.createElement("svg", props, /*#__PURE__*/_react.default.createElement("path", {
56
+ fillRule: "evenodd",
57
+ clipRule: "evenodd",
58
+ d: "M12.019 6.679 9.324 3.984l1.948-1.95 2.694 2.695-1.947 1.95Zm-6.94 6.946-2.976.27.264-2.955 5.617-5.617 2.696 2.696-5.6 5.606ZM15.405 3.338l-.001-.001L12.665.599c-.741-.74-2.014-.774-2.716-.07L.953 9.527a1.973 1.973 0 0 0-.57 1.214l-.38 4.17a1.002 1.002 0 0 0 1.088 1.086l4.17-.38a1.974 1.974 0 0 0 1.214-.567l8.997-8.997c.728-.73.697-1.948-.068-2.714Z",
59
+ fill: "#fff"
60
+ }));
61
+ };
62
+ ModifyDetail.defaultProps = {
63
+ width: "16",
64
+ height: "16",
65
+ viewBox: "0 0 16 16",
66
+ fill: "none",
67
+ xmlns: "http://www.w3.org/2000/svg"
68
+ };
69
+ const ADD = 'add';
70
+ const MODIFY = 'modify';
71
+ const DETAIL = 'detail';
72
+ const MODIFY_DETAIL = 'modifyDetail';
73
+ const actionMapper = exports.actionMapper = {
74
+ [ADD]: {
75
+ colorTheme: 'secondary',
76
+ Icon: Add,
77
+ size: 'small',
78
+ variant: 'semitransparent'
79
+ },
80
+ [MODIFY]: {
81
+ colorTheme: 'secondary',
82
+ Icon: Edit,
83
+ size: 'small',
84
+ variant: 'text'
85
+ },
86
+ [DETAIL]: {
87
+ colorTheme: 'primary',
88
+ Icon: Detail,
89
+ size: 'small'
90
+ },
91
+ [MODIFY_DETAIL]: {
92
+ colorTheme: 'primary',
93
+ Icon: ModifyDetail,
94
+ size: 'small'
95
+ }
96
+ };
@@ -0,0 +1,100 @@
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 _object = require("@widergy/web-utils/lib/object");
10
+ var _WithTheme = _interopRequireDefault(require("../WithTheme"));
11
+ var _UTLabel = _interopRequireDefault(require("../UTLabel"));
12
+ var _UTButton = _interopRequireDefault(require("../UTButton"));
13
+ var _theme = require("./theme");
14
+ var _constants = require("./constants");
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+ const UTProductItem = _ref => {
17
+ let {
18
+ action = {},
19
+ additionalInfo,
20
+ amount,
21
+ classes,
22
+ discount,
23
+ discountSize = 'medium',
24
+ Image,
25
+ previousAmount,
26
+ selectedQuantity,
27
+ title
28
+ } = _ref;
29
+ const {
30
+ CustomIcon,
31
+ onClick,
32
+ type = 'add'
33
+ } = action;
34
+ const {
35
+ colorTheme,
36
+ Icon,
37
+ size,
38
+ variant
39
+ } = _constants.actionMapper[type] || {};
40
+ return /*#__PURE__*/_react.default.createElement("div", {
41
+ className: classes.container
42
+ }, /*#__PURE__*/_react.default.createElement("div", {
43
+ className: classes.leftSection
44
+ }, !!Image && /*#__PURE__*/_react.default.createElement(Image, {
45
+ className: classes.image
46
+ }), /*#__PURE__*/_react.default.createElement("div", {
47
+ className: classes.mainInfo
48
+ }, !!title && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
49
+ weight: "medium",
50
+ variant: "small"
51
+ }, title), !!additionalInfo && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
52
+ variant: "small",
53
+ colorTheme: "gray"
54
+ }, additionalInfo), !!discount && /*#__PURE__*/_react.default.createElement("div", {
55
+ className: classes.amountContainer
56
+ }, /*#__PURE__*/_react.default.createElement("div", {
57
+ className: classes.discountChip
58
+ }, /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
59
+ colorTheme: "light",
60
+ variant: discountSize
61
+ }, "".concat(discount, "% OFF"))), !!previousAmount && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
62
+ colorTheme: "gray",
63
+ className: classes.previousAmount
64
+ }, "$ ".concat(previousAmount))), /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
65
+ weight: "medium",
66
+ variant: "subtitle1"
67
+ }, "$ ".concat(amount)))), /*#__PURE__*/_react.default.createElement("div", {
68
+ className: classes.rightSection
69
+ }, !!selectedQuantity && /*#__PURE__*/_react.default.createElement("div", {
70
+ className: classes.selectedQuantity
71
+ }, /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
72
+ colorTheme: "light",
73
+ weight: "medium"
74
+ }, selectedQuantity)), !(0, _object.objectIsEmpty)(action) && /*#__PURE__*/_react.default.createElement(_UTButton.default, {
75
+ classNames: {
76
+ icon: classes.buttonIcon
77
+ },
78
+ colorTheme: colorTheme,
79
+ onClick: onClick,
80
+ Icon: CustomIcon || Icon,
81
+ size: size,
82
+ variant: variant
83
+ })));
84
+ };
85
+ UTProductItem.propTypes = {
86
+ action: (0, _propTypes.shape)({
87
+ onClick: _propTypes.func,
88
+ type: _propTypes.string
89
+ }),
90
+ additionalInfo: _propTypes.string,
91
+ amount: _propTypes.number,
92
+ classes: (0, _propTypes.objectOf)(_propTypes.string),
93
+ discount: _propTypes.number,
94
+ discountSize: _propTypes.string,
95
+ Image: _propTypes.node,
96
+ previousAmount: _propTypes.number,
97
+ selectedQuantity: _propTypes.number,
98
+ title: _propTypes.string
99
+ };
100
+ var _default = exports.default = (0, _WithTheme.default)(_theme.retrieveStyle)(UTProductItem);
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.retrieveStyle = void 0;
7
+ const retrieveStyle = _ref => {
8
+ let {
9
+ theme
10
+ } = _ref;
11
+ return {
12
+ amountContainer: {
13
+ alignItems: 'center',
14
+ display: 'flex',
15
+ gridGap: '8px'
16
+ },
17
+ buttonIcon: {
18
+ height: '16px',
19
+ width: '16px'
20
+ },
21
+ container: {
22
+ borderBottom: "1px solid ".concat(theme.Palette.light['04']),
23
+ display: 'flex',
24
+ gridGap: '12px',
25
+ justifyContent: 'space-between',
26
+ paddingBottom: '24px'
27
+ },
28
+ discountChip: {
29
+ backgroundColor: theme.Palette.actions.accent['04'],
30
+ borderRadius: '4px',
31
+ padding: '4px 8px'
32
+ },
33
+ image: {
34
+ borderRadius: '12px',
35
+ height: '70px',
36
+ width: '70px'
37
+ },
38
+ leftSection: {
39
+ alignItems: 'center',
40
+ display: 'flex',
41
+ gridGap: '16px'
42
+ },
43
+ mainInfo: {
44
+ display: 'flex',
45
+ flexDirection: 'column',
46
+ gridGap: '4px',
47
+ minWidth: '160px'
48
+ },
49
+ previousAmount: {
50
+ textDecoration: 'line-through'
51
+ },
52
+ rightSection: {
53
+ alignItems: 'center',
54
+ display: 'flex',
55
+ gridGap: '12px'
56
+ },
57
+ selectedQuantity: {
58
+ backgroundColor: theme.Palette.actions.neutral['04'],
59
+ borderRadius: '4px',
60
+ padding: '4px 8px'
61
+ }
62
+ };
63
+ };
64
+ exports.retrieveStyle = retrieveStyle;
@@ -7,6 +7,9 @@ exports.hasVisibleActions = void 0;
7
7
  var _array = require("@widergy/web-utils/lib/array");
8
8
  const hasVisibleActions = (secondaryActions, rowData) => !(0, _array.isEmpty)(secondaryActions) && secondaryActions.some(secondaryAction => {
9
9
  var _secondaryAction$acti;
10
- return secondaryAction === null || secondaryAction === void 0 || (_secondaryAction$acti = secondaryAction.actions) === null || _secondaryAction$acti === void 0 ? void 0 : _secondaryAction$acti.some(action => action.isVisible(rowData));
10
+ return secondaryAction === null || secondaryAction === void 0 || (_secondaryAction$acti = secondaryAction.actions) === null || _secondaryAction$acti === void 0 ? void 0 : _secondaryAction$acti.some(action => {
11
+ var _action$isVisible;
12
+ return (_action$isVisible = action.isVisible) === null || _action$isVisible === void 0 ? void 0 : _action$isVisible.call(action, rowData);
13
+ });
11
14
  });
12
15
  exports.hasVisibleActions = hasVisibleActions;
package/dist/index.js CHANGED
@@ -219,6 +219,12 @@ Object.defineProperty(exports, "UTPieChart", {
219
219
  return _UTPieChart.default;
220
220
  }
221
221
  });
222
+ Object.defineProperty(exports, "UTProductItem", {
223
+ enumerable: true,
224
+ get: function () {
225
+ return _UTProductItem.default;
226
+ }
227
+ });
222
228
  Object.defineProperty(exports, "UTProgressBar", {
223
229
  enumerable: true,
224
230
  get: function () {
@@ -388,6 +394,7 @@ var _UTPanel = _interopRequireDefault(require("./components/UTPanel"));
388
394
  var _UTPasswordField = _interopRequireDefault(require("./components/UTPasswordField"));
389
395
  var _UTPhoneInput = _interopRequireDefault(require("./components/UTPhoneInput"));
390
396
  var _UTPieChart = _interopRequireDefault(require("./components/UTPieChart"));
397
+ var _UTProductItem = _interopRequireDefault(require("./components/UTProductItem"));
391
398
  var _UTProgressBar = _interopRequireDefault(require("./components/UTProgressBar"));
392
399
  var _UTRadioGroup = _interopRequireDefault(require("./components/UTRadioGroup"));
393
400
  var _UTRating = _interopRequireDefault(require("./components/UTRating"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widergy/energy-ui",
3
- "version": "3.1.7",
3
+ "version": "3.2.1",
4
4
  "description": "Widergy Web Components",
5
5
  "author": "widergy",
6
6
  "license": "MIT",