@widergy/energy-ui 1.131.0 → 1.131.2

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,17 @@
1
+ ## [1.131.2](https://github.com/widergy/energy-ui/compare/v1.131.1...v1.131.2) (2022-09-30)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * added outside text ([#312](https://github.com/widergy/energy-ui/issues/312)) ([09fd1bd](https://github.com/widergy/energy-ui/commit/09fd1bdb263d1f45df29694ae28d3d96f577ce64))
7
+
8
+ ## [1.131.1](https://github.com/widergy/energy-ui/compare/v1.131.0...v1.131.1) (2022-09-26)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * adding tooltip to UTChecklist Checkbox render ([#311](https://github.com/widergy/energy-ui/issues/311)) ([7a52d03](https://github.com/widergy/energy-ui/commit/7a52d03cc3ff4a734aa9f538601a5377413e3acb))
14
+
1
15
  # [1.131.0](https://github.com/widergy/energy-ui/compare/v1.130.3...v1.131.0) (2022-09-15)
2
16
 
3
17
 
@@ -56,31 +56,32 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
56
56
  var UTCheckList = function UTCheckList(_ref) {
57
57
  var _field$configuration;
58
58
 
59
- var valueKey = _ref.valueKey,
60
- labelKey = _ref.labelKey,
61
- input = _ref.input,
62
- additionalInfo = _ref.additionalInfo,
63
- list = _ref.list,
64
- className = _ref.className,
65
- shouldShowErrors = _ref.shouldShowErrors,
66
- meta = _ref.meta,
67
- disabled = _ref.disabled,
59
+ var additionalInfo = _ref.additionalInfo,
60
+ allChecked = _ref.allChecked,
61
+ CustomCheckedIcon = _ref.CustomCheckedIcon,
62
+ CustomUncheckedIcon = _ref.CustomUncheckedIcon,
68
63
  CustomRowLabel = _ref.customRowLabel,
69
64
  CustomSelectAllRowLabel = _ref.customSelectAllRowLabel,
70
65
  _ref$classes = _ref.classes,
71
66
  themeClasses = _ref$classes === void 0 ? {} : _ref$classes,
67
+ className = _ref.className,
72
68
  classNames = _ref.classNames,
69
+ disabled = _ref.disabled,
70
+ disabledItemTooltip = _ref.disabledItemTooltip,
71
+ field = _ref.field,
72
+ getSelectAllNewValues = _ref.getSelectAllNewValues,
73
73
  header = _ref.header,
74
74
  headerLabel = _ref.headerLabel,
75
- withCheckRow = _ref.withCheckRow,
75
+ input = _ref.input,
76
+ labelKey = _ref.labelKey,
77
+ list = _ref.list,
78
+ meta = _ref.meta,
79
+ shouldShowErrors = _ref.shouldShowErrors,
80
+ titleProps = _ref.titleProps,
76
81
  useCustomIcons = _ref.useCustomIcons,
77
- allChecked = _ref.allChecked,
78
- getSelectAllNewValues = _ref.getSelectAllNewValues,
79
- CustomCheckedIcon = _ref.CustomCheckedIcon,
80
- CustomUncheckedIcon = _ref.CustomUncheckedIcon,
81
- field = _ref.field,
82
- withUpperTitle = _ref.withUpperTitle,
83
- titleProps = _ref.titleProps;
82
+ valueKey = _ref.valueKey,
83
+ withCheckRow = _ref.withCheckRow,
84
+ withUpperTitle = _ref.withUpperTitle;
84
85
  var shouldShowUpperTitle = (field === null || field === void 0 ? void 0 : (_field$configuration = field.configuration) === null || _field$configuration === void 0 ? void 0 : _field$configuration.ignore_title) && withUpperTitle;
85
86
 
86
87
  var handleChange = function handleChange(id) {
@@ -168,7 +169,8 @@ var UTCheckList = function UTCheckList(_ref) {
168
169
  },
169
170
  useCustomIcons: useCustomIcons,
170
171
  CustomCheckedIcon: CustomCheckedIcon,
171
- CustomUncheckedIcon: CustomUncheckedIcon
172
+ CustomUncheckedIcon: CustomUncheckedIcon,
173
+ tooltipContent: item.disabled && disabledItemTooltip && disabledItemTooltip(item, list)
172
174
  }));
173
175
  })), additionalInfo && additionalInfo.footer && /*#__PURE__*/_react.default.createElement(_FormHelperText.default, null, additionalInfo.footer), shouldShowErrors && /*#__PURE__*/_react.default.createElement(_FormHelperText.default, {
174
176
  error: true
@@ -192,6 +194,7 @@ UTCheckList.propTypes = {
192
194
  customSelectAllRowLabel: _propTypes.element,
193
195
  CustomUncheckedIcon: _propTypes.element,
194
196
  disabled: _propTypes.bool,
197
+ disabledItemTooltip: _propTypes.func,
195
198
  field: _formTypes.fieldType,
196
199
  getSelectAllNewValues: _propTypes.func,
197
200
  header: (0, _propTypes.shape)({
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.tippyProps = void 0;
7
+ var tippyProps = {
8
+ appendTo: function appendTo() {
9
+ return document.body;
10
+ },
11
+ interactive: false,
12
+ maxWidth: 'none'
13
+ };
14
+ exports.tippyProps = tippyProps;
@@ -19,6 +19,8 @@ var _form = require("@widergy/web-utils/lib/form");
19
19
 
20
20
  var _energyHooks = require("@widergy/energy-hooks");
21
21
 
22
+ var _UTTooltip = _interopRequireDefault(require("../UTTooltip"));
23
+
22
24
  var _formTypes = require("../../types/formTypes");
23
25
 
24
26
  var _UTLabel = _interopRequireDefault(require("../UTLabel"));
@@ -29,6 +31,10 @@ var _classesUtils = require("../../utils/classesUtils");
29
31
 
30
32
  var _theme = require("./theme");
31
33
 
34
+ var _constants = require("./constants");
35
+
36
+ var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
37
+
32
38
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
39
 
34
40
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -83,6 +89,7 @@ var UTCheckbox = function UTCheckbox(_ref) {
83
89
  disableRipple = _ref.disableRipple,
84
90
  label = _ref.label,
85
91
  input = _ref.input,
92
+ tooltipContent = _ref.tooltipContent,
86
93
  onChange = _ref.onChange;
87
94
 
88
95
  var _useMutableState = (0, _energyHooks.useMutableState)(value),
@@ -101,7 +108,11 @@ var UTCheckbox = function UTCheckbox(_ref) {
101
108
  var classes = (0, _classesUtils.mergeClasses)(themeClasses, classNames);
102
109
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_FormControlLabel.default, {
103
110
  disabled: disabled,
104
- control: /*#__PURE__*/_react.default.createElement(_Checkbox.default, {
111
+ control: /*#__PURE__*/_react.default.createElement(_UTTooltip.default, {
112
+ content: tooltipContent,
113
+ stringContentClassName: _stylesModule.default.disableSelectionTooltip,
114
+ tippyProps: _constants.tippyProps
115
+ }, /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement(_Checkbox.default, {
105
116
  classes: {
106
117
  colorPrimary: classes.checkboxColorPrimary,
107
118
  colorSecondary: classes.checkboxColorSecondary
@@ -116,8 +127,9 @@ var UTCheckbox = function UTCheckbox(_ref) {
116
127
  onChange: handleChange,
117
128
  value: (input === null || input === void 0 ? void 0 : input.value) || value,
118
129
  color: color,
119
- disableRipple: disableRipple
120
- }),
130
+ disableRipple: disableRipple,
131
+ disabled: disabled
132
+ }))),
121
133
  label: CustomRowLabel ? /*#__PURE__*/_react.default.createElement(CustomRowLabel, {
122
134
  item: item
123
135
  }) : /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
@@ -152,7 +164,8 @@ UTCheckbox.propTypes = {
152
164
  meta: _formTypes.metaPropTypes,
153
165
  showError: _propTypes.bool,
154
166
  input: _formTypes.inputPropTypes,
155
- disableRipple: _propTypes.bool
167
+ disableRipple: _propTypes.bool,
168
+ tooltipContent: _propTypes.element
156
169
  };
157
170
 
158
171
  var _default = (0, _WithTheme.default)(_theme.retrieveStyle, _theme.retrieveMuiTheme)(UTCheckbox);
@@ -0,0 +1,3 @@
1
+ .disableSelectionTooltip {
2
+ text-align: center;
3
+ }
@@ -58,35 +58,38 @@ var UTSwitch = function UTSwitch(_ref) {
58
58
  themeClasses = _ref$classes === void 0 ? {} : _ref$classes,
59
59
  classNames = _ref.classNames,
60
60
  disabled = _ref.disabled,
61
- field = _ref.field,
62
- input = _ref.input,
61
+ _ref$field = _ref.field,
62
+ field = _ref$field === void 0 ? {} : _ref$field,
63
+ _ref$input = _ref.input,
64
+ input = _ref$input === void 0 ? {} : _ref$input,
63
65
  _ref$meta = _ref.meta,
64
66
  meta = _ref$meta === void 0 ? {} : _ref$meta,
65
- showErrors = _ref.showErrors,
66
- textOff = _ref.textOff,
67
- textOn = _ref.textOn,
68
- withText = _ref.withText;
69
-
70
- var _ref2 = input || {},
71
- value = _ref2.value,
72
- onChange_ = _ref2.onChange;
73
-
67
+ showErrors = _ref.showErrors;
68
+ var value = input.value,
69
+ onChange_ = input.onChange;
74
70
  var key = field.key,
75
- fieldOptions = field.field_options;
71
+ fieldOptions = field.field_options,
72
+ _field$configuration = field.configuration,
73
+ configuration = _field$configuration === void 0 ? {} : _field$configuration;
74
+ var textOff_ = configuration.textOff,
75
+ textOn_ = configuration.textOn,
76
+ _configuration$inside = configuration.insideText,
77
+ insideText = _configuration$inside === void 0 ? true : _configuration$inside,
78
+ withText = configuration.withText;
76
79
  var switchId = key || _constants.DEFAULT_SWITCH_ID;
77
80
  var classes = (0, _react.useMemo)(function () {
78
81
  return (0, _classesUtils.mergeClasses)(themeClasses, classNames);
79
82
  }, [classNames]);
80
83
  var useFieldOptions = fieldOptions && !(0, _array.isEmpty)(fieldOptions);
81
84
 
82
- var _ref3 = useFieldOptions ? _toConsumableArray(fieldOptions).sort(function (_, _ref5) {
83
- var optionValue = _ref5.value,
84
- name = _ref5.name;
85
+ var _ref2 = useFieldOptions ? _toConsumableArray(fieldOptions).sort(function (_, _ref4) {
86
+ var optionValue = _ref4.value,
87
+ name = _ref4.name;
85
88
  return [optionValue, name === _constants.TRUE].includes(value) ? 1 : -1;
86
89
  }) : [],
87
- _ref4 = _slicedToArray(_ref3, 2),
88
- currentOption = _ref4[0],
89
- switchedOption = _ref4[1];
90
+ _ref3 = _slicedToArray(_ref2, 2),
91
+ currentOption = _ref3[0],
92
+ switchedOption = _ref3[1];
90
93
 
91
94
  var onChange = useFieldOptions ? function () {
92
95
  return onChange_(switchedOption.value);
@@ -94,7 +97,11 @@ var UTSwitch = function UTSwitch(_ref) {
94
97
  (0, _react.useEffect)(function () {
95
98
  if (useFieldOptions && value === false) onChange_(currentOption.value);
96
99
  }, [value]);
97
- return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("label", {
100
+ var textOn = textOn_ || _constants.STATES.ON;
101
+ var textOff = textOff_ || _constants.STATES.OFF;
102
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
103
+ className: classes.outerContainer
104
+ }, withText && !insideText && textOff, /*#__PURE__*/_react.default.createElement("label", {
98
105
  htmlFor: switchId,
99
106
  className: "".concat(classes.container, " ").concat(disabled && classes.disabled)
100
107
  }, /*#__PURE__*/_react.default.createElement("input", {
@@ -109,17 +116,17 @@ var UTSwitch = function UTSwitch(_ref) {
109
116
  className: "".concat(classes.sliderContainer, " ").concat(disabled && classes.disabled)
110
117
  }, /*#__PURE__*/_react.default.createElement("span", {
111
118
  className: "".concat(classes.sliderBack, " ").concat(disabled && classes.disabled)
112
- }), withText && /*#__PURE__*/_react.default.createElement("div", {
119
+ }), withText && insideText && /*#__PURE__*/_react.default.createElement("div", {
113
120
  className: classes.textContainer
114
121
  }, /*#__PURE__*/_react.default.createElement("div", {
115
122
  className: classes.checkedText
116
- }, textOn || _constants.STATES.ON), /*#__PURE__*/_react.default.createElement("div", {
123
+ }, textOn), /*#__PURE__*/_react.default.createElement("div", {
117
124
  className: classes.uncheckedText
118
- }, textOff || _constants.STATES.OFF)), /*#__PURE__*/_react.default.createElement("span", {
125
+ }, textOff)), /*#__PURE__*/_react.default.createElement("span", {
119
126
  className: "".concat(classes.sliderHover, " ").concat(disabled && classes.disabled)
120
127
  }), /*#__PURE__*/_react.default.createElement("span", {
121
128
  className: "".concat(classes.slider, " ").concat(disabled && classes.disabled)
122
- }))), showErrors && meta && (0, _form.shouldShowErrors)(meta) && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
129
+ }))), withText && !insideText && textOn), showErrors && meta && (0, _form.shouldShowErrors)(meta) && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
123
130
  error: true
124
131
  }, meta === null || meta === void 0 ? void 0 : meta.error));
125
132
  };
@@ -131,10 +138,7 @@ UTSwitch.propTypes = {
131
138
  field: _formTypes.fieldType,
132
139
  input: _formTypes.inputPropTypes.isRequired,
133
140
  meta: _formTypes.metaPropTypes,
134
- showErrors: _propTypes.bool,
135
- textOff: _propTypes.string,
136
- textOn: _propTypes.string,
137
- withText: _propTypes.bool
141
+ showErrors: _propTypes.bool
138
142
  };
139
143
 
140
144
  var _default = (0, _WithTheme.default)(_theme.retrieveStyle)(UTSwitch);
@@ -13,6 +13,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
13
13
 
14
14
  var retrieveStyle = function retrieveStyle(theme) {
15
15
  return {
16
+ outerContainer: {
17
+ alignItems: (0, _seamlessImmutable.getIn)(theme, ['UTSwitch', 'outerContainer', 'alignItems'], 'center'),
18
+ color: (0, _seamlessImmutable.getIn)(theme, ['UTSwitch', 'outerContainer', 'color']),
19
+ columnGap: (0, _seamlessImmutable.getIn)(theme, ['UTSwitch', 'outerContainer', 'columnGap']),
20
+ display: (0, _seamlessImmutable.getIn)(theme, ['UTSwitch', 'outerContainer', 'display'], 'flex')
21
+ },
16
22
  container: {
17
23
  boxSizing: (0, _seamlessImmutable.getIn)(theme, ['UTSwitch', 'container', 'boxSizing'], 'border-box'),
18
24
  cursor: (0, _seamlessImmutable.getIn)(theme, ['UTSwitch', 'container', 'cursor'], 'pointer'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widergy/energy-ui",
3
- "version": "1.131.0",
3
+ "version": "1.131.2",
4
4
  "description": "Widergy Web Components",
5
5
  "author": "widergy",
6
6
  "license": "MIT",