@panneau/field-toggle 3.0.308 → 4.0.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/es/index.js +19 -32
- package/package.json +4 -4
package/es/index.js
CHANGED
|
@@ -1,62 +1,49 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
3
|
import Switch from 'rc-switch';
|
|
5
4
|
import React, { useMemo, useCallback } from 'react';
|
|
6
5
|
import 'rc-switch/assets/index.css';
|
|
7
6
|
|
|
8
7
|
var styles = {"container":"panneau-field-toggle-container"};
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
value
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
className: null,
|
|
24
|
-
onChange: null
|
|
25
|
-
};
|
|
26
|
-
var ToggleField = function ToggleField(_ref) {
|
|
27
|
-
var value = _ref.value,
|
|
28
|
-
queryValue = _ref.queryValue,
|
|
29
|
-
name = _ref.name,
|
|
30
|
-
disabled = _ref.disabled,
|
|
31
|
-
className = _ref.className,
|
|
32
|
-
onChange = _ref.onChange;
|
|
9
|
+
function ToggleField(_ref) {
|
|
10
|
+
var _ref$value = _ref.value,
|
|
11
|
+
value = _ref$value === void 0 ? null : _ref$value,
|
|
12
|
+
_ref$queryValue = _ref.queryValue,
|
|
13
|
+
queryValue = _ref$queryValue === void 0 ? null : _ref$queryValue,
|
|
14
|
+
_ref$name = _ref.name,
|
|
15
|
+
name = _ref$name === void 0 ? null : _ref$name,
|
|
16
|
+
_ref$disabled = _ref.disabled,
|
|
17
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
18
|
+
_ref$className = _ref.className,
|
|
19
|
+
className = _ref$className === void 0 ? null : _ref$className,
|
|
20
|
+
_ref$onChange = _ref.onChange,
|
|
21
|
+
onChange = _ref$onChange === void 0 ? null : _ref$onChange;
|
|
33
22
|
var isTrue = useMemo(function () {
|
|
34
23
|
return queryValue !== null ? value === queryValue : value === true || value === 'true' || value === 1 || value === '1';
|
|
35
24
|
}, [value, queryValue]);
|
|
36
25
|
var finalOnChange = useCallback(function (val) {
|
|
37
26
|
if (queryValue !== null) {
|
|
38
27
|
if (val === true) {
|
|
39
|
-
onChange(queryValue);
|
|
28
|
+
onChange === null || onChange === void 0 || onChange(queryValue);
|
|
40
29
|
} else {
|
|
41
|
-
onChange(null);
|
|
30
|
+
onChange === null || onChange === void 0 || onChange(null);
|
|
42
31
|
}
|
|
43
32
|
} else {
|
|
44
|
-
onChange(val);
|
|
33
|
+
onChange === null || onChange === void 0 || onChange(val);
|
|
45
34
|
}
|
|
46
|
-
}, [onChange]);
|
|
35
|
+
}, [onChange, queryValue]);
|
|
47
36
|
return /*#__PURE__*/React.createElement("div", {
|
|
48
37
|
className: classNames([styles.container, _defineProperty({
|
|
49
38
|
disabled: disabled
|
|
50
39
|
}, className, className !== null)])
|
|
51
40
|
}, /*#__PURE__*/React.createElement(Switch, {
|
|
52
|
-
name: name,
|
|
41
|
+
name: name || undefined,
|
|
53
42
|
checked: isTrue,
|
|
54
43
|
onChange: finalOnChange,
|
|
55
44
|
disabled: disabled
|
|
56
45
|
}));
|
|
57
|
-
}
|
|
58
|
-
ToggleField.propTypes = propTypes;
|
|
59
|
-
ToggleField.defaultProps = defaultProps;
|
|
46
|
+
}
|
|
60
47
|
|
|
61
48
|
var definition = {
|
|
62
49
|
id: 'toggle',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/field-toggle",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "A toggle field",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@babel/runtime": "^7.12.5",
|
|
62
|
-
"@panneau/core": "^
|
|
63
|
-
"@panneau/themes": "^
|
|
62
|
+
"@panneau/core": "^4.0.1",
|
|
63
|
+
"@panneau/themes": "^4.0.1",
|
|
64
64
|
"classnames": "^2.5.1",
|
|
65
65
|
"prop-types": "^15.7.2",
|
|
66
66
|
"rc-switch": "^4.1.0"
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"publishConfig": {
|
|
69
69
|
"access": "public"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "dbdf65640625c027ecd56cf2b816b80a5c38cb8d"
|
|
72
72
|
}
|