@widergy/energy-ui 3.22.4 → 3.23.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 (48) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/components/UTActionCard/README.md +2 -2
  3. package/dist/components/UTActionCard/components/AdditionalMessage/index.js +3 -1
  4. package/dist/components/UTActionCard/components/BottomActions/index.js +5 -3
  5. package/dist/components/UTActionCard/components/BottomActions/styles.module.scss +4 -0
  6. package/dist/components/UTActionCard/components/Header/constants.js +14 -1
  7. package/dist/components/UTActionCard/components/Header/index.js +5 -3
  8. package/dist/components/UTActionCard/components/Header/styles.module.scss +6 -8
  9. package/dist/components/UTActionCard/components/HeaderActions/index.js +9 -6
  10. package/dist/components/UTActionCard/components/HeaderActions/utils.js +26 -15
  11. package/dist/components/UTActionCard/index.js +7 -9
  12. package/dist/components/UTFieldLabel/constants.js +7 -0
  13. package/dist/components/UTFieldLabel/index.js +43 -0
  14. package/dist/components/UTFieldLabel/styles.module.scss +5 -0
  15. package/dist/components/UTIcon/styles.module.scss +0 -1
  16. package/dist/components/UTLabel/theme.js +24 -8
  17. package/dist/components/UTTextArea/index.js +11 -87
  18. package/dist/components/UTTextArea/versions/V0/index.js +102 -0
  19. package/dist/components/UTTextArea/{theme.js → versions/V0/theme.js} +1 -1
  20. package/dist/components/UTTextArea/versions/V1/README.md +33 -0
  21. package/dist/components/UTTextArea/versions/V1/index.js +18 -0
  22. package/dist/components/UTTextInput/index.js +15 -200
  23. package/dist/components/UTTextInput/versions/V0/index.js +211 -0
  24. package/dist/components/UTTextInput/{styles.module.scss → versions/V0/styles.module.scss} +1 -1
  25. package/dist/components/UTTextInput/{theme.js → versions/V0/theme.js} +1 -1
  26. package/dist/components/UTTextInput/versions/V1/README.md +85 -0
  27. package/dist/components/UTTextInput/versions/V1/components/ActionAdornment/index.js +31 -0
  28. package/dist/components/UTTextInput/versions/V1/components/IconAdornment/constants.js +8 -0
  29. package/dist/components/UTTextInput/versions/V1/components/IconAdornment/index.js +48 -0
  30. package/dist/components/UTTextInput/versions/V1/components/IconAdornment/utils.js +17 -0
  31. package/dist/components/UTTextInput/versions/V1/components/PrefixAdornment/index.js +24 -0
  32. package/dist/components/UTTextInput/versions/V1/components/SuffixAdornment/index.js +22 -0
  33. package/dist/components/UTTextInput/versions/V1/components/TooltipAdornment/index.js +26 -0
  34. package/dist/components/UTTextInput/versions/V1/index.js +177 -0
  35. package/dist/components/UTTextInput/versions/V1/styles.module.scss +29 -0
  36. package/dist/components/UTTextInput/versions/V1/theme.js +94 -0
  37. package/dist/components/UTValidation/README.md +68 -0
  38. package/dist/components/UTValidation/constants.js +27 -0
  39. package/dist/components/UTValidation/index.js +86 -0
  40. package/dist/components/UTValidation/styles.module.scss +33 -0
  41. package/dist/components/UTValidation/theme.js +25 -0
  42. package/dist/components/UTValidation/utils.js +23 -0
  43. package/dist/index.js +7 -0
  44. package/package.json +1 -1
  45. package/dist/components/UTActionCard/components/HeaderActions/constants.js +0 -7
  46. /package/dist/components/UTTextArea/{constants.js → versions/V0/constants.js} +0 -0
  47. /package/dist/components/UTTextArea/{styles.module.scss → versions/V0/styles.module.scss} +0 -0
  48. /package/dist/components/UTTextInput/{constants.js → versions/V0/constants.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [3.23.0](https://github.com/widergy/energy-ui/compare/v3.22.5...v3.23.0) (2024-10-07)
2
+
3
+
4
+ ### Features
5
+
6
+ * add UTTextInput + UTTextArea + UTValidation + UTFieldLabel ([#500](https://github.com/widergy/energy-ui/issues/500)) ([333f340](https://github.com/widergy/energy-ui/commit/333f340215a2c6b99f4f2978e940bce5a20d0e96))
7
+
8
+ ## [3.22.5](https://github.com/widergy/energy-ui/compare/v3.22.4...v3.22.5) (2024-10-03)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * ut action card minor fixes ([#502](https://github.com/widergy/energy-ui/issues/502)) ([a0b41b5](https://github.com/widergy/energy-ui/commit/a0b41b5b7bc9608892b87af8c6946d37aa56e782))
14
+
1
15
  ## [3.22.4](https://github.com/widergy/energy-ui/compare/v3.22.3...v3.22.4) (2024-10-02)
2
16
 
3
17
 
@@ -14,12 +14,12 @@
14
14
  | `description` | `string` | | Description text to be displayed. |
15
15
  | `descriptionProps` | `shape({ colorTheme: string, variant: string })` | | Props to customize the description's style. |
16
16
  | `headerActions` | `arrayOf(shape({ Icon: oneOfType([elementType, string]), iconProps: string, id: oneOfType([number, string]), label: string, loading: bool, onClick: func }))` | | List of actions available in the header section. |
17
- | `headerActionsProps` | `shape({ alignment: oneOf(['center', 'end', 'start']), buttonGroupProps: shape({ colorTheme: string, shape: string }), maxNumberOfPrimaryActions: number, variant: oneOf(['default', 'buttonGroup']) })` | | Props to configure header actions alignment, button group, etc. |
17
+ | `headerActionsProps` | `shape({ alignment: oneOf(['center', 'end', 'start']), buttonGroupProps: shape({ colorTheme: string, shape: string }), variant: oneOf(['default', 'buttonGroup']) })` | | Props to configure header actions alignment, button group, etc. |
18
18
  | `mainAction` | `func` | | Main action function for the card. |
19
19
  | `size` | `oneOf(['medium', 'small'])` | `'medium'` | Size of the card, either small or medium. |
20
20
  | `status` | `string` | | Status text to be displayed. |
21
21
  | `statusLabel` | `string` | | Status label for additional status info. |
22
22
  | `statusAlignment` | `oneOf(['center', 'end', 'start'])` | | Alignment of the status element. |
23
- | `title` | `string.isRequired` | | The title of the card, required. |
23
+ | `title` | `string` | | The title of the card. |
24
24
  | `titleProps` | `shape({ variant: string, weight: string })` | | Props to configure the title style. |
25
25
  | `withBodyPadding` | `bool` | `false` | Adds padding to the card body if`true`. |
@@ -25,8 +25,10 @@ const AdditionalMessage = _ref => {
25
25
  return /*#__PURE__*/_react.default.createElement("div", {
26
26
  className: "".concat(_stylesModule.default.additionalMessageContainer, " ").concat(_stylesModule.default[size])
27
27
  }, icon && /*#__PURE__*/_react.default.createElement(_UTIcon.default, _extends({
28
+ area: true,
28
29
  colorTheme: "gray",
29
- name: icon
30
+ name: icon,
31
+ size: 16
30
32
  }, iconProps)), /*#__PURE__*/_react.default.createElement(_UTLabel.default, _extends({
31
33
  colorTheme: "gray",
32
34
  variant: "small",
@@ -15,7 +15,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
15
15
  const BottomActions = _ref => {
16
16
  let {
17
17
  actions = [],
18
- bottomActionsVariant
18
+ bottomActionsVariant,
19
+ size
19
20
  } = _ref;
20
21
  const type = actions.length > 2 ? _constants.ACTION_TYPES.REDIRECTION : bottomActionsVariant || _constants.ACTION_TYPES.DEFAULT;
21
22
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -32,7 +33,7 @@ const BottomActions = _ref => {
32
33
  return /*#__PURE__*/_react.default.createElement(_UTButton.default, {
33
34
  classNames: {
34
35
  childrenContainer: "".concat(type === _constants.ACTION_TYPES.REDIRECTION && _stylesModule.default.redirectionChildrenContainer, " "),
35
- root: "".concat(_stylesModule.default.actionButton, " ").concat(type === _constants.ACTION_TYPES.REDIRECTION ? _stylesModule.default.fullWidth : ''),
36
+ root: "".concat(_stylesModule.default.actionButton, " ").concat(type === _constants.ACTION_TYPES.REDIRECTION && _stylesModule.default.fullWidth, " ").concat(size === _constants.SIZES.MEDIUM && _stylesModule.default.mediumPadding),
36
37
  text: "".concat(type === _constants.ACTION_TYPES.REDIRECTION ? _stylesModule.default.redirectionText : _stylesModule.default.defaultText)
37
38
  },
38
39
  colorTheme: colorTheme,
@@ -56,6 +57,7 @@ BottomActions.propTypes = {
56
57
  loading: _propTypes.bool,
57
58
  onClick: _propTypes.func
58
59
  })),
59
- bottomActionsVariant: _propTypes.string
60
+ bottomActionsVariant: _propTypes.string,
61
+ size: _propTypes.string
60
62
  };
61
63
  var _default = exports.default = /*#__PURE__*/(0, _react.memo)(BottomActions);
@@ -38,3 +38,7 @@ $default-border-color: #E7E7E7;
38
38
  .fullWidth {
39
39
  flex: 1 0 100%;
40
40
  }
41
+
42
+ .mediumPadding {
43
+ padding: 16px 24px;
44
+ }
@@ -7,11 +7,24 @@ exports.ADORNMENT_COMPONENT_MAPPER = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _UTAvatar = _interopRequireDefault(require("../../../UTAvatar"));
9
9
  var _UTIcon = _interopRequireDefault(require("../../../UTIcon"));
10
+ var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
10
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
12
  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); }
12
13
  const ADORNMENT_COMPONENT_MAPPER = exports.ADORNMENT_COMPONENT_MAPPER = {
13
14
  icon: _UTIcon.default,
14
- avatar: _UTAvatar.default,
15
+ avatar: _ref => {
16
+ let {
17
+ className,
18
+ ...props
19
+ } = _ref;
20
+ return /*#__PURE__*/_react.default.createElement(_UTAvatar.default, _extends({
21
+ className: "".concat(_stylesModule.default.defaultAvatar, " ").concat(className),
22
+ labelProps: {
23
+ variant: 'title1',
24
+ weight: 'medium'
25
+ }
26
+ }, props));
27
+ },
15
28
  image: props => /*#__PURE__*/_react.default.createElement("img", _extends({
16
29
  alt: ""
17
30
  }, props))
@@ -20,6 +20,7 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
20
20
  const Header = _ref => {
21
21
  let {
22
22
  adornment,
23
+ classNames,
23
24
  description,
24
25
  descriptionProps,
25
26
  headerActions,
@@ -33,10 +34,11 @@ const Header = _ref => {
33
34
  titleProps
34
35
  } = _ref;
35
36
  return /*#__PURE__*/_react.default.createElement("div", {
36
- className: "".concat(_stylesModule.default.header, " ").concat(_stylesModule.default[size])
37
+ className: "".concat(_stylesModule.default.header, " ").concat(_stylesModule.default[size], " ").concat(classNames.header)
37
38
  }, (0, _utils.renderAdornment)(adornment, 'left', size), /*#__PURE__*/_react.default.createElement("div", {
38
- className: "".concat(_stylesModule.default.headerTitles, " ").concat(_stylesModule.default["gap-".concat(size)])
39
+ className: _stylesModule.default.headerTitles
39
40
  }, (0, _utils.renderAdornment)(adornment, 'top', size), /*#__PURE__*/_react.default.createElement(_UTLabel.default, _extends({
41
+ variant: "title3",
40
42
  weight: "medium"
41
43
  }, titleProps), title), description && /*#__PURE__*/_react.default.createElement(_UTLabel.default, _extends({
42
44
  colorTheme: "gray"
@@ -55,6 +57,7 @@ Header.propTypes = {
55
57
  props: _propTypes.object,
56
58
  type: _propTypes.string
57
59
  }),
60
+ classNames: (0, _propTypes.objectOf)(_propTypes.string),
58
61
  description: _propTypes.string,
59
62
  descriptionProps: (0, _propTypes.shape)({
60
63
  colorTheme: _propTypes.string,
@@ -74,7 +77,6 @@ Header.propTypes = {
74
77
  colorTheme: _propTypes.string,
75
78
  shape: _propTypes.string
76
79
  }),
77
- maxNumberOfPrimaryActions: _propTypes.number,
78
80
  variant: (0, _propTypes.oneOf)([_constants.HEADER_ACTIONS_VARIANTS.DEFAULT, _constants.HEADER_ACTIONS_VARIANTS.BUTTON_GROUP])
79
81
  }),
80
82
  setMainActionHoverVisible: _propTypes.string,
@@ -7,6 +7,7 @@
7
7
  .headerTitles {
8
8
  display: flex;
9
9
  flex-direction: column;
10
+ grid-gap: 8px;
10
11
  margin-right: auto;
11
12
  overflow-wrap: anywhere;
12
13
  }
@@ -15,18 +16,10 @@
15
16
  padding: 24px;
16
17
  }
17
18
 
18
- .gap-medium {
19
- grid-gap: 16px;
20
- }
21
-
22
19
  .small {
23
20
  padding: 16px;
24
21
  }
25
22
 
26
- .gap-small {
27
- grid-gap: 8px;
28
- }
29
-
30
23
  .placeSelf-center {
31
24
  place-self: center;
32
25
  }
@@ -38,3 +31,8 @@
38
31
  .placeSelf-end {
39
32
  place-self: flex-end;
40
33
  }
34
+
35
+ .defaultAvatar {
36
+ height: 64px;
37
+ width: 64px;
38
+ }
@@ -12,7 +12,6 @@ var _UTButtonGroup = _interopRequireDefault(require("../../../UTButtonGroup"));
12
12
  var _UTMenu = _interopRequireDefault(require("../../../UTMenu"));
13
13
  var _constants = require("../../constants");
14
14
  var _utils = require("./utils");
15
- var _constants2 = require("./constants");
16
15
  var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
17
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
17
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
@@ -32,7 +31,6 @@ const HeaderActions = _ref => {
32
31
  colorTheme: buttonGroupColorTheme = 'secondary',
33
32
  shape: buttonGroupShape
34
33
  } = (headerActionsProps === null || headerActionsProps === void 0 ? void 0 : headerActionsProps.buttonGroupProps) || {};
35
- const maxNumberOfPrimaryActions = (headerActionsProps === null || headerActionsProps === void 0 ? void 0 : headerActionsProps.maxNumberOfPrimaryActions) || _constants2.DEFAULT_MAX_NUMBER_OF_PRIMARY_ACTIONS;
36
34
  const handleSetMainActionHoverVisible = () => setMainActionHoverVisible(true);
37
35
  const handleSetMainActionHoverHidden = () => setMainActionHoverVisible(false);
38
36
  const openMenu = event => setMenu(event.currentTarget);
@@ -40,8 +38,10 @@ const HeaderActions = _ref => {
40
38
  handleSetMainActionHoverVisible();
41
39
  setMenu();
42
40
  };
43
- const primaryActions = (0, _utils.mapActions)(headerActions, true).slice(0, maxNumberOfPrimaryActions);
44
- const secondaryActions = (0, _utils.mapActions)(headerActions, false, !showButtonGroup ? closeMenu : null);
41
+ const {
42
+ primaryActions,
43
+ secondaryActions
44
+ } = (0, _utils.processActions)(headerActions, !showButtonGroup ? closeMenu : null);
45
45
  return /*#__PURE__*/_react.default.createElement("div", {
46
46
  className: "".concat(_stylesModule.default.headerActionsContainer, " ").concat(_stylesModule.default["placeSelf-".concat(headerActionsProps.alignment)]),
47
47
  onClick: e => e.stopPropagation(),
@@ -72,7 +72,11 @@ const HeaderActions = _ref => {
72
72
  Icon: "IconDots",
73
73
  onClick: e => {
74
74
  e.stopPropagation();
75
- openMenu(e);
75
+ if (menu) {
76
+ setMenu();
77
+ } else {
78
+ openMenu(e);
79
+ }
76
80
  },
77
81
  size: "medium",
78
82
  variant: "text"
@@ -104,7 +108,6 @@ HeaderActions.propTypes = {
104
108
  colorTheme: _propTypes.string,
105
109
  shape: _propTypes.string
106
110
  }),
107
- maxNumberOfPrimaryActions: _propTypes.number,
108
111
  variant: (0, _propTypes.oneOf)([_constants.HEADER_ACTIONS_VARIANTS.DEFAULT, _constants.HEADER_ACTIONS_VARIANTS.BUTTON_GROUP])
109
112
  }),
110
113
  setMainActionHoverVisible: _propTypes.func
@@ -3,18 +3,29 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.mapActions = void 0;
7
- const mapActions = function () {
8
- let actions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
9
- let isPrimary = arguments.length > 1 ? arguments[1] : undefined;
10
- let onClickHandler = arguments.length > 2 ? arguments[2] : undefined;
11
- return actions.filter(action => ((action === null || action === void 0 ? void 0 : action.isPrimary) || false) === isPrimary).map(action => ({
12
- ...action,
13
- onClick: e => {
14
- e === null || e === void 0 || e.stopPropagation();
15
- if (onClickHandler) onClickHandler();
16
- action.onClick();
17
- }
18
- }));
19
- };
20
- exports.mapActions = mapActions;
6
+ exports.processActions = void 0;
7
+ var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ const mapAction = (action, onClickHandler) => ({
10
+ ...action,
11
+ onClick: e => {
12
+ var _action$onClick;
13
+ e === null || e === void 0 || e.stopPropagation();
14
+ if (onClickHandler) onClickHandler();
15
+ action === null || action === void 0 || (_action$onClick = action.onClick) === null || _action$onClick === void 0 || _action$onClick.call(action);
16
+ }
17
+ });
18
+ const processActions = (headerActions, onClickHandler) => headerActions.reduce((final, current) => {
19
+ if (current.isPrimary && (0, _isEmpty.default)(final.primaryActions)) return {
20
+ ...final,
21
+ primaryActions: [current]
22
+ };
23
+ return {
24
+ ...final,
25
+ secondaryActions: [...final.secondaryActions, mapAction(current, onClickHandler)]
26
+ };
27
+ }, {
28
+ primaryActions: [],
29
+ secondaryActions: []
30
+ });
31
+ exports.processActions = processActions;
@@ -17,6 +17,7 @@ var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
17
17
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
18
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
19
19
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
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); }
20
21
  const UTActionCard = _ref => {
21
22
  let {
22
23
  additionalMessage,
@@ -53,6 +54,7 @@ const UTActionCard = _ref => {
53
54
  className: "".concat(_stylesModule.default.headerAndChildrenContainer, " ").concat(classNames.headerAndChildrenContainer)
54
55
  }, /*#__PURE__*/_react.default.createElement(_Header.default, {
55
56
  adornment,
57
+ classNames,
56
58
  description,
57
59
  descriptionProps,
58
60
  headerActions,
@@ -67,15 +69,12 @@ const UTActionCard = _ref => {
67
69
  titleProps
68
70
  }), children && /*#__PURE__*/_react.default.createElement("div", {
69
71
  className: "".concat(withBodyPadding ? _stylesModule.default["bodyPadding-".concat(size)] : _stylesModule.default["withoutBodyPadding-".concat(size)])
70
- }, children))), !(0, _object.objectIsEmpty)(additionalMessage) && /*#__PURE__*/_react.default.createElement(_AdditionalMessage.default, {
71
- icon: additionalMessage.icon,
72
- iconProps: additionalMessage.iconProps,
73
- labelProps: additionalMessage.labelProps,
74
- message: additionalMessage.message,
72
+ }, children))), !(0, _object.objectIsEmpty)(additionalMessage) && /*#__PURE__*/_react.default.createElement(_AdditionalMessage.default, _extends({}, additionalMessage, {
75
73
  size: size
76
- }), !(0, _array.isEmpty)(bottomActions) && /*#__PURE__*/_react.default.createElement(_BottomActions.default, {
74
+ })), !(0, _array.isEmpty)(bottomActions) && /*#__PURE__*/_react.default.createElement(_BottomActions.default, {
77
75
  actions: bottomActions,
78
- bottomActionsVariant: bottomActionsVariant
76
+ bottomActionsVariant: bottomActionsVariant,
77
+ size: size
79
78
  }));
80
79
  };
81
80
  UTActionCard.propTypes = {
@@ -127,7 +126,6 @@ UTActionCard.propTypes = {
127
126
  colorTheme: _propTypes.string,
128
127
  shape: _propTypes.string
129
128
  }),
130
- maxNumberOfPrimaryActions: _propTypes.number,
131
129
  variant: (0, _propTypes.oneOf)([_constants.HEADER_ACTIONS_VARIANTS.DEFAULT, _constants.HEADER_ACTIONS_VARIANTS.BUTTON_GROUP])
132
130
  }),
133
131
  mainAction: _propTypes.func,
@@ -135,7 +133,7 @@ UTActionCard.propTypes = {
135
133
  status: _propTypes.string,
136
134
  statusLabel: _propTypes.string,
137
135
  statusAlignment: (0, _propTypes.oneOf)([_constants.PLACE_SELF_TYPES.CENTER, _constants.PLACE_SELF_TYPES.END, _constants.PLACE_SELF_TYPES.START]),
138
- title: _propTypes.string.isRequired,
136
+ title: _propTypes.string,
139
137
  titleProps: (0, _propTypes.shape)({
140
138
  variant: _propTypes.string,
141
139
  weight: _propTypes.string
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.REQUIRED_LABEL = void 0;
7
+ const REQUIRED_LABEL = exports.REQUIRED_LABEL = '*';
@@ -0,0 +1,43 @@
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 _UTLabel = _interopRequireDefault(require("../UTLabel"));
10
+ var _constants = require("./constants");
11
+ var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ const UTFieldLabel = _ref => {
14
+ let {
15
+ children,
16
+ colorTheme,
17
+ required,
18
+ style,
19
+ variant,
20
+ weight,
21
+ withMarkdown
22
+ } = _ref;
23
+ return /*#__PURE__*/_react.default.createElement("div", {
24
+ className: "".concat(_stylesModule.default.label, " ").concat(style)
25
+ }, /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
26
+ colorTheme: colorTheme,
27
+ variant: variant,
28
+ withMarkdown: withMarkdown
29
+ }, children), required && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
30
+ colorTheme: "error",
31
+ shade: "04",
32
+ variant: variant,
33
+ weight: weight
34
+ }, _constants.REQUIRED_LABEL));
35
+ };
36
+ UTFieldLabel.propTypes = {
37
+ colorTheme: _propTypes.string,
38
+ required: _propTypes.bool,
39
+ variant: _propTypes.string,
40
+ weight: _propTypes.string,
41
+ withMarkdown: _propTypes.bool
42
+ };
43
+ var _default = exports.default = UTFieldLabel;
@@ -0,0 +1,5 @@
1
+ .label {
2
+ display: flex;
3
+ flex-direction: row;
4
+ grid-gap: 4px;
5
+ }
@@ -5,7 +5,6 @@ $padding-xlarge: 12px;
5
5
  $padding-xxlarge: 21px;
6
6
 
7
7
  .withArea {
8
- background-color: transparent;
9
8
  border-radius: 100px;
10
9
  }
11
10
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.retrieveStyle = void 0;
6
+ exports.retrieveStyle = exports.getFontStyles = void 0;
7
7
  var _Palette = require("../../constants/Palette");
8
8
  var _componentUtils = require("../../utils/componentUtils");
9
9
  var _colorsModule = _interopRequireDefault(require("../../scss/variables/colors.module.scss"));
@@ -20,8 +20,23 @@ const linkColor = (theme, colorTheme) => {
20
20
  const color = colorTheme === _Palette.COLOR_THEMES.light ? actionPaletteColors.negative[_Palette.COLOR_SHADES.shade05] : colorTheme === _Palette.COLOR_THEMES.error ? actionPaletteColors.error[_Palette.COLOR_SHADES.shade05] : actionPaletteColors.neutral[_Palette.COLOR_SHADES.shade05];
21
21
  return color;
22
22
  };
23
- const retrieveStyle = _ref => {
24
- var _field$configuration$, _field$configuration, _field$configuration$2, _field$configuration2, _theme$Fonts, _field$configuration$3, _field$configuration3, _field$configuration$4, _field$configuration4, _field$configuration$5, _field$configuration5;
23
+ const getFontStyles = _ref => {
24
+ var _theme$Fonts;
25
+ let {
26
+ theme,
27
+ variant,
28
+ weight
29
+ } = _ref;
30
+ return {
31
+ fontFamily: theme === null || theme === void 0 || (_theme$Fonts = theme.Fonts) === null || _theme$Fonts === void 0 ? void 0 : _theme$Fonts.fontFamily,
32
+ fontSize: _constants.VARIANTS_SIZES[variant] || _constants.VARIANTS_SIZES[_constants.DEFAULT_PROPS.variant],
33
+ fontWeight: _constants.WEIGHTS[weight] || _constants.WEIGHTS[_constants.DEFAULT_PROPS.weight],
34
+ lineHeight: _constants.VARIANTS_LINE_HEIGHT[variant] || _constants.VARIANTS_LINE_HEIGHT[_constants.DEFAULT_PROPS.variant]
35
+ };
36
+ };
37
+ exports.getFontStyles = getFontStyles;
38
+ const retrieveStyle = _ref2 => {
39
+ var _field$configuration$, _field$configuration, _field$configuration$2, _field$configuration2, _field$configuration$3, _field$configuration3, _field$configuration$4, _field$configuration4;
25
40
  let {
26
41
  colorTheme,
27
42
  field,
@@ -29,14 +44,15 @@ const retrieveStyle = _ref => {
29
44
  theme,
30
45
  variant,
31
46
  weight
32
- } = _ref;
47
+ } = _ref2;
33
48
  return {
34
49
  root: {
35
50
  color: variantsColorTheme((_field$configuration$ = field === null || field === void 0 || (_field$configuration = field.configuration) === null || _field$configuration === void 0 ? void 0 : _field$configuration.colorTheme) !== null && _field$configuration$ !== void 0 ? _field$configuration$ : colorTheme, (_field$configuration$2 = field === null || field === void 0 || (_field$configuration2 = field.configuration) === null || _field$configuration2 === void 0 ? void 0 : _field$configuration2.shade) !== null && _field$configuration$2 !== void 0 ? _field$configuration$2 : shade, theme),
36
- fontFamily: theme === null || theme === void 0 || (_theme$Fonts = theme.Fonts) === null || _theme$Fonts === void 0 ? void 0 : _theme$Fonts.fontFamily,
37
- fontSize: _constants.VARIANTS_SIZES[(_field$configuration$3 = field === null || field === void 0 || (_field$configuration3 = field.configuration) === null || _field$configuration3 === void 0 ? void 0 : _field$configuration3.variant) !== null && _field$configuration$3 !== void 0 ? _field$configuration$3 : variant] || _constants.VARIANTS_SIZES[_constants.DEFAULT_PROPS.variant],
38
- fontWeight: _constants.WEIGHTS[(_field$configuration$4 = field === null || field === void 0 || (_field$configuration4 = field.configuration) === null || _field$configuration4 === void 0 ? void 0 : _field$configuration4.weight) !== null && _field$configuration$4 !== void 0 ? _field$configuration$4 : weight] || _constants.WEIGHTS[_constants.DEFAULT_PROPS.weight],
39
- lineHeight: _constants.VARIANTS_LINE_HEIGHT[(_field$configuration$5 = field === null || field === void 0 || (_field$configuration5 = field.configuration) === null || _field$configuration5 === void 0 ? void 0 : _field$configuration5.variant) !== null && _field$configuration$5 !== void 0 ? _field$configuration$5 : variant] || _constants.VARIANTS_LINE_HEIGHT[_constants.DEFAULT_PROPS.variant],
51
+ ...getFontStyles({
52
+ theme,
53
+ variant: (_field$configuration$3 = field === null || field === void 0 || (_field$configuration3 = field.configuration) === null || _field$configuration3 === void 0 ? void 0 : _field$configuration3.variant) !== null && _field$configuration$3 !== void 0 ? _field$configuration$3 : variant,
54
+ weight: (_field$configuration$4 = field === null || field === void 0 || (_field$configuration4 = field.configuration) === null || _field$configuration4 === void 0 ? void 0 : _field$configuration4.weight) !== null && _field$configuration$4 !== void 0 ? _field$configuration$4 : weight
55
+ }),
40
56
  margin: 0,
41
57
  '& > a': {
42
58
  color: linkColor(theme, colorTheme)
@@ -6,97 +6,21 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _propTypes = require("prop-types");
9
- var _normalize = require("@widergy/web-utils/lib/normalize");
10
- var _HelpOutline = _interopRequireDefault(require("@material-ui/icons/HelpOutline"));
11
- var _UTTooltip = _interopRequireDefault(require("../UTTooltip"));
12
- var _WithTheme = _interopRequireDefault(require("../WithTheme"));
13
- var _UTLabel = _interopRequireDefault(require("../UTLabel"));
14
- var _formTypes = require("../../types/formTypes");
15
- var _constants = require("./constants");
16
- var _theme = require("./theme");
17
- var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
9
+ var _V = _interopRequireDefault(require("./versions/V0"));
10
+ var _V2 = _interopRequireDefault(require("./versions/V1"));
18
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
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
12
  const UTTextArea = _ref => {
21
13
  let {
22
- classes,
23
- classNames = {},
24
- disabled,
25
- field,
26
- HelpIcon,
27
- inputProps = {},
28
- onBlur,
29
- onChange,
30
- onFocus,
31
- placeholder,
32
- title = '',
33
- tooltip,
34
- value
14
+ version = 'V0',
15
+ ...props
35
16
  } = _ref;
36
- const {
37
- container,
38
- icon,
39
- textarea,
40
- label,
41
- textAreaContainer
42
- } = classNames;
43
- const {
44
- character_count_limit: characterCountLimit
45
- } = (field === null || field === void 0 ? void 0 : field.configuration) || {};
46
- const handleOnChange = _ref2 => {
47
- let {
48
- target
49
- } = _ref2;
50
- return onChange(characterCountLimit ? (0, _normalize.maxLength)(characterCountLimit)(target.value) : target.value);
51
- };
52
- return /*#__PURE__*/_react.default.createElement("div", {
53
- className: container
54
- }, /*#__PURE__*/_react.default.createElement("div", {
55
- className: _stylesModule.default.titleContainer
56
- }, /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
57
- className: "".concat(label, " ").concat(_stylesModule.default.label),
58
- withMarkdown: true
59
- }, title)), /*#__PURE__*/_react.default.createElement("div", {
60
- className: "".concat(_stylesModule.default.textAreaContainer, " ").concat(textAreaContainer)
61
- }, /*#__PURE__*/_react.default.createElement("div", {
62
- className: _stylesModule.default.componentWrapper
63
- }, /*#__PURE__*/_react.default.createElement("textarea", _extends({}, inputProps, {
64
- className: "".concat(_stylesModule.default.textarea, " ").concat(textarea, " ").concat(classes.textarea),
65
- onChange: handleOnChange,
66
- onBlur: onBlur,
67
- onFocus: onFocus,
68
- value: value,
69
- disabled: disabled,
70
- placeholder: placeholder
71
- })), characterCountLimit && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
72
- className: _stylesModule.default.characterCount,
73
- colorTheme: value.length === characterCountLimit ? 'error' : value.length >= characterCountLimit * _constants.LIMIT_WARNING_FACTOR ? 'warning' : 'dark'
74
- }, "".concat(value.length, "/").concat(characterCountLimit))), tooltip && /*#__PURE__*/_react.default.createElement(_UTTooltip.default, {
75
- content: tooltip,
76
- tippyProps: _constants.tippyProps
77
- }, /*#__PURE__*/_react.default.createElement("div", null, HelpIcon || /*#__PURE__*/_react.default.createElement(_HelpOutline.default, {
78
- className: "".concat(icon, " ").concat(classes.icon)
79
- })))));
17
+ const Component = {
18
+ V0: _V.default,
19
+ V1: _V2.default
20
+ }[version];
21
+ return /*#__PURE__*/_react.default.createElement(Component, props);
80
22
  };
81
23
  UTTextArea.propTypes = {
82
- classes: (0, _propTypes.objectOf)(_propTypes.string),
83
- classNames: (0, _propTypes.shape)({
84
- container: _propTypes.string,
85
- icon: _propTypes.string,
86
- label: _propTypes.string,
87
- textarea: _propTypes.string,
88
- textAreaContainer: _propTypes.string
89
- }),
90
- disabled: _propTypes.bool,
91
- field: _formTypes.fieldType,
92
- HelpIcon: _propTypes.elementType,
93
- inputProps: _formTypes.inputPropTypes,
94
- onBlur: _propTypes.func,
95
- onChange: _propTypes.func,
96
- onFocus: _propTypes.func,
97
- placeholder: _propTypes.string,
98
- title: _propTypes.string,
99
- tooltip: _propTypes.string,
100
- value: _propTypes.string
24
+ version: _propTypes.string
101
25
  };
102
- var _default = exports.default = (0, _WithTheme.default)(_theme.retrieveStyle)(UTTextArea);
26
+ var _default = exports.default = UTTextArea;