@widergy/energy-ui 1.131.1 → 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,10 @@
|
|
|
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
|
+
|
|
1
8
|
## [1.131.1](https://github.com/widergy/energy-ui/compare/v1.131.0...v1.131.1) (2022-09-26)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -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
|
-
|
|
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
|
-
|
|
67
|
-
|
|
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
|
|
83
|
-
var optionValue =
|
|
84
|
-
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
|
-
|
|
88
|
-
currentOption =
|
|
89
|
-
switchedOption =
|
|
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
|
-
|
|
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
|
|
123
|
+
}, textOn), /*#__PURE__*/_react.default.createElement("div", {
|
|
117
124
|
className: classes.uncheckedText
|
|
118
|
-
}, textOff
|
|
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'),
|