@pingux/astro 2.84.0-alpha.5 → 2.84.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.
- package/lib/cjs/components/CheckboxField/CheckboxField.stories.js +1 -3
- package/lib/cjs/components/SwitchField/SwitchField.js +32 -12
- package/lib/cjs/components/SwitchField/SwitchField.stories.js +2 -4
- package/lib/cjs/components/SwitchField/switchFieldAttributes.js +30 -2
- package/lib/cjs/types/index.d.ts +0 -1
- package/lib/cjs/types/index.js +8 -19
- package/lib/components/CheckboxField/CheckboxField.stories.js +1 -3
- package/lib/components/SwitchField/SwitchField.js +34 -14
- package/lib/components/SwitchField/SwitchField.stories.js +2 -4
- package/lib/components/SwitchField/switchFieldAttributes.js +28 -1
- package/lib/types/index.js +0 -1
- package/package.json +1 -1
- package/lib/cjs/components/SwitchField/SwitchField.d.ts +0 -4
- package/lib/cjs/components/SwitchField/SwitchField.stories.d.ts +0 -11
- package/lib/cjs/components/SwitchField/SwitchField.test.d.ts +0 -1
- package/lib/cjs/components/SwitchField/index.d.ts +0 -1
- package/lib/cjs/components/SwitchField/switchFieldAttributes.d.ts +0 -94
- package/lib/cjs/types/switchField.d.ts +0 -29
- package/lib/cjs/types/switchField.js +0 -6
- package/lib/types/switchField.js +0 -1
@@ -200,9 +200,7 @@ var ExpandableAndToggleableIndeterminate = function ExpandableAndToggleableIndet
|
|
200
200
|
return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_index.SwitchField, {
|
201
201
|
isSelected: isReadOnly,
|
202
202
|
label: "Is Read Only",
|
203
|
-
onChange:
|
204
|
-
return setIsReadOnly(!isReadOnly);
|
205
|
-
},
|
203
|
+
onChange: setIsReadOnly,
|
206
204
|
value: "my-switch"
|
207
205
|
}), (0, _react2.jsx)("br", null), (0, _react2.jsx)(_index.Box, {
|
208
206
|
isRow: true,
|
@@ -27,25 +27,47 @@ var _omit = _interopRequireDefault(require("lodash/omit"));
|
|
27
27
|
var _ = require("../..");
|
28
28
|
var _hooks = require("../../hooks");
|
29
29
|
var _pendoID = require("../../utils/devUtils/constants/pendoID");
|
30
|
-
var
|
30
|
+
var _statusProp = require("../../utils/docUtils/statusProp");
|
31
|
+
var _switchFieldAttributes = require("./switchFieldAttributes");
|
31
32
|
var _react2 = require("@emotion/react");
|
32
|
-
var _excluded = ["label", "helperText", "isDefaultSelected", "isDisabled", "status", "controlProps"];
|
33
|
+
var _excluded = ["label", "helperText", "isDefaultSelected", "isSelected", "onChange", "value", "name", "id", "isDisabled", "isReadOnly", "isRequired", "hasAutoFocus", "onFocus", "onBlur", "onFocusChange", "onKeyDown", "onKeyUp", "status", "controlProps"];
|
34
|
+
/* eslint-disable no-unused-vars */
|
33
35
|
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); }
|
34
36
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
35
37
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys2(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
36
38
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
37
39
|
var displayName = 'SwitchField';
|
38
40
|
var SwitchField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
39
|
-
var _inputProps$checked;
|
40
41
|
var label = props.label,
|
41
42
|
helperText = props.helperText,
|
42
43
|
isDefaultSelected = props.isDefaultSelected,
|
43
|
-
|
44
|
+
isSelected = props.isSelected,
|
45
|
+
onChange = props.onChange,
|
46
|
+
value = props.value,
|
47
|
+
name = props.name,
|
48
|
+
id = props.id,
|
49
|
+
_props$isDisabled = props.isDisabled,
|
50
|
+
isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
|
51
|
+
_props$isReadOnly = props.isReadOnly,
|
52
|
+
isReadOnly = _props$isReadOnly === void 0 ? false : _props$isReadOnly,
|
53
|
+
_props$isRequired = props.isRequired,
|
54
|
+
isRequired = _props$isRequired === void 0 ? false : _props$isRequired,
|
55
|
+
_props$hasAutoFocus = props.hasAutoFocus,
|
56
|
+
hasAutoFocus = _props$hasAutoFocus === void 0 ? false : _props$hasAutoFocus,
|
57
|
+
onFocus = props.onFocus,
|
58
|
+
onBlur = props.onBlur,
|
59
|
+
onFocusChange = props.onFocusChange,
|
60
|
+
onKeyDown = props.onKeyDown,
|
61
|
+
onKeyUp = props.onKeyUp,
|
44
62
|
status = props.status,
|
45
63
|
controlProps = props.controlProps,
|
46
64
|
others = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
65
|
+
var switchRef = (0, _react.useRef)();
|
47
66
|
(0, _hooks.usePropWarning)(props, 'disabled', 'isDisabled');
|
48
|
-
|
67
|
+
/* istanbul ignore next */
|
68
|
+
(0, _react.useImperativeHandle)(ref, function () {
|
69
|
+
return switchRef.current;
|
70
|
+
});
|
49
71
|
var state = (0, _reactStately.useToggleState)(_objectSpread({
|
50
72
|
defaultSelected: isDefaultSelected
|
51
73
|
}, props));
|
@@ -57,11 +79,11 @@ var SwitchField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
57
79
|
var _useSwitch = (0, _reactAria.useSwitch)(_objectSpread(_objectSpread({
|
58
80
|
children: label
|
59
81
|
}, whitelistedProps), {}, {
|
60
|
-
'aria-label':
|
82
|
+
'aria-label': 'switch-field'
|
61
83
|
}), state, switchRef),
|
62
84
|
inputProps = _useSwitch.inputProps;
|
63
85
|
var statusClasses = {
|
64
|
-
isSelected:
|
86
|
+
isSelected: inputProps.checked
|
65
87
|
};
|
66
88
|
var _useField = (0, _hooks.useField)(_objectSpread(_objectSpread(_objectSpread({
|
67
89
|
statusClasses: statusClasses
|
@@ -81,14 +103,12 @@ var SwitchField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
81
103
|
}, fieldLabelProps), (0, _react2.jsx)(_.Box, fieldControlWrapperProps, (0, _react2.jsx)(_.Switch, (0, _extends2["default"])({
|
82
104
|
ref: switchRef,
|
83
105
|
inputProps: fieldControlInputProps
|
84
|
-
}, unhandledAriaProps, (0, _omit["default"])(others, 'data-pendo-id'
|
106
|
+
}, unhandledAriaProps, (0, _omit["default"])(others, 'data-pendo-id')))), label), helperText && (0, _react2.jsx)(_.FieldHelperText, {
|
85
107
|
status: status
|
86
108
|
}, helperText));
|
87
109
|
});
|
88
|
-
SwitchField.
|
89
|
-
|
90
|
-
isDisabled: false
|
91
|
-
};
|
110
|
+
SwitchField.propTypes = _switchFieldAttributes.switchFieldPropTypes;
|
111
|
+
SwitchField.defaultProps = _objectSpread({}, _statusProp.statusDefaultProp);
|
92
112
|
SwitchField.displayName = displayName;
|
93
113
|
var _default = SwitchField;
|
94
114
|
exports["default"] = _default;
|
@@ -60,9 +60,7 @@ var Controlled = function Controlled() {
|
|
60
60
|
return (0, _react2.jsx)(_index.SwitchField, {
|
61
61
|
isSelected: isSelected,
|
62
62
|
label: "Controlled",
|
63
|
-
onChange:
|
64
|
-
return setIsSelected(!isSelected);
|
65
|
-
},
|
63
|
+
onChange: setIsSelected,
|
66
64
|
value: "my-switch"
|
67
65
|
});
|
68
66
|
};
|
@@ -99,7 +97,7 @@ var Required = function Required() {
|
|
99
97
|
};
|
100
98
|
exports.Required = Required;
|
101
99
|
var WithTooltip = function WithTooltip() {
|
102
|
-
var tooltipTrigger = (0, _react.useRef)(
|
100
|
+
var tooltipTrigger = (0, _react.useRef)();
|
103
101
|
return (0, _react2.jsx)(_index.TooltipTrigger, {
|
104
102
|
crossOffset: 15,
|
105
103
|
offset: 20,
|
@@ -12,11 +12,16 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
12
12
|
_Object$defineProperty(exports, "__esModule", {
|
13
13
|
value: true
|
14
14
|
});
|
15
|
-
exports.switchFieldArgs = exports.switchFieldArgTypes = void 0;
|
15
|
+
exports.switchFieldPropTypes = exports.switchFieldArgs = exports.switchFieldArgTypes = void 0;
|
16
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
17
17
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
18
|
+
var _values = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/values"));
|
19
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
18
20
|
var _statuses = _interopRequireDefault(require("../../utils/devUtils/constants/statuses"));
|
21
|
+
var _ariaAttributes = require("../../utils/docUtils/ariaAttributes");
|
19
22
|
var _docArgTypes = require("../../utils/docUtils/docArgTypes");
|
23
|
+
var _fieldAttributes = require("../../utils/docUtils/fieldAttributes");
|
24
|
+
var _statusProp = require("../../utils/docUtils/statusProp");
|
20
25
|
var _context;
|
21
26
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
22
27
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
@@ -163,4 +168,27 @@ var switchFieldArgs = {
|
|
163
168
|
value: 'my-switch',
|
164
169
|
status: _statuses["default"].DEFAULT
|
165
170
|
};
|
166
|
-
exports.switchFieldArgs = switchFieldArgs;
|
171
|
+
exports.switchFieldArgs = switchFieldArgs;
|
172
|
+
var switchFieldPropTypes = _objectSpread(_objectSpread(_objectSpread({
|
173
|
+
className: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].arrayOf(_propTypes["default"].string)]),
|
174
|
+
hasAutoFocus: _propTypes["default"].bool,
|
175
|
+
helperText: _propTypes["default"].node,
|
176
|
+
hintText: _propTypes["default"].string,
|
177
|
+
id: _propTypes["default"].string,
|
178
|
+
isDefaultSelected: _propTypes["default"].bool,
|
179
|
+
isDisabled: _propTypes["default"].bool,
|
180
|
+
isReadOnly: _propTypes["default"].bool,
|
181
|
+
isRequired: _propTypes["default"].bool,
|
182
|
+
isSelected: _propTypes["default"].bool,
|
183
|
+
label: _propTypes["default"].node,
|
184
|
+
name: _propTypes["default"].string,
|
185
|
+
onBlur: _propTypes["default"].func,
|
186
|
+
onChange: _propTypes["default"].func,
|
187
|
+
onFocus: _propTypes["default"].func,
|
188
|
+
onFocusChange: _propTypes["default"].func,
|
189
|
+
onKeyDown: _propTypes["default"].func,
|
190
|
+
onKeyUp: _propTypes["default"].func,
|
191
|
+
status: _propTypes["default"].oneOf((0, _values["default"])(_statuses["default"])),
|
192
|
+
value: _propTypes["default"].string
|
193
|
+
}, _ariaAttributes.ariaAttributesBasePropTypes), _fieldAttributes.inputFieldAttributesBasePropTypes), _statusProp.statusPropTypes);
|
194
|
+
exports.switchFieldPropTypes = switchFieldPropTypes;
|
package/lib/cjs/types/index.d.ts
CHANGED
package/lib/cjs/types/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10, _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18, _context19, _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29, _context30, _context31, _context32, _context33, _context34, _context35, _context36, _context37, _context38, _context39, _context40, _context41, _context42, _context43, _context44, _context45, _context46, _context47, _context48, _context49, _context50, _context51, _context52, _context53
|
3
|
+
var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10, _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18, _context19, _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29, _context30, _context31, _context32, _context33, _context34, _context35, _context36, _context37, _context38, _context39, _context40, _context41, _context42, _context43, _context44, _context45, _context46, _context47, _context48, _context49, _context50, _context51, _context52, _context53;
|
4
4
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
5
5
|
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
|
6
6
|
var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
|
@@ -513,19 +513,8 @@ _forEachInstanceProperty(_context46 = _Object$keys(_shared)).call(_context46, fu
|
|
513
513
|
}
|
514
514
|
});
|
515
515
|
});
|
516
|
-
var _switchField = require("./switchField");
|
517
|
-
_forEachInstanceProperty(_context47 = _Object$keys(_switchField)).call(_context47, function (key) {
|
518
|
-
if (key === "default" || key === "__esModule") return;
|
519
|
-
if (key in exports && exports[key] === _switchField[key]) return;
|
520
|
-
_Object$defineProperty(exports, key, {
|
521
|
-
enumerable: true,
|
522
|
-
get: function get() {
|
523
|
-
return _switchField[key];
|
524
|
-
}
|
525
|
-
});
|
526
|
-
});
|
527
516
|
var _tab = require("./tab");
|
528
|
-
_forEachInstanceProperty(
|
517
|
+
_forEachInstanceProperty(_context47 = _Object$keys(_tab)).call(_context47, function (key) {
|
529
518
|
if (key === "default" || key === "__esModule") return;
|
530
519
|
if (key in exports && exports[key] === _tab[key]) return;
|
531
520
|
_Object$defineProperty(exports, key, {
|
@@ -536,7 +525,7 @@ _forEachInstanceProperty(_context48 = _Object$keys(_tab)).call(_context48, funct
|
|
536
525
|
});
|
537
526
|
});
|
538
527
|
var _table = require("./table");
|
539
|
-
_forEachInstanceProperty(
|
528
|
+
_forEachInstanceProperty(_context48 = _Object$keys(_table)).call(_context48, function (key) {
|
540
529
|
if (key === "default" || key === "__esModule") return;
|
541
530
|
if (key in exports && exports[key] === _table[key]) return;
|
542
531
|
_Object$defineProperty(exports, key, {
|
@@ -547,7 +536,7 @@ _forEachInstanceProperty(_context49 = _Object$keys(_table)).call(_context49, fun
|
|
547
536
|
});
|
548
537
|
});
|
549
538
|
var _tabs = require("./tabs");
|
550
|
-
_forEachInstanceProperty(
|
539
|
+
_forEachInstanceProperty(_context49 = _Object$keys(_tabs)).call(_context49, function (key) {
|
551
540
|
if (key === "default" || key === "__esModule") return;
|
552
541
|
if (key in exports && exports[key] === _tabs[key]) return;
|
553
542
|
_Object$defineProperty(exports, key, {
|
@@ -558,7 +547,7 @@ _forEachInstanceProperty(_context50 = _Object$keys(_tabs)).call(_context50, func
|
|
558
547
|
});
|
559
548
|
});
|
560
549
|
var _text = require("./text");
|
561
|
-
_forEachInstanceProperty(
|
550
|
+
_forEachInstanceProperty(_context50 = _Object$keys(_text)).call(_context50, function (key) {
|
562
551
|
if (key === "default" || key === "__esModule") return;
|
563
552
|
if (key in exports && exports[key] === _text[key]) return;
|
564
553
|
_Object$defineProperty(exports, key, {
|
@@ -569,7 +558,7 @@ _forEachInstanceProperty(_context51 = _Object$keys(_text)).call(_context51, func
|
|
569
558
|
});
|
570
559
|
});
|
571
560
|
var _textField = require("./textField");
|
572
|
-
_forEachInstanceProperty(
|
561
|
+
_forEachInstanceProperty(_context51 = _Object$keys(_textField)).call(_context51, function (key) {
|
573
562
|
if (key === "default" || key === "__esModule") return;
|
574
563
|
if (key in exports && exports[key] === _textField[key]) return;
|
575
564
|
_Object$defineProperty(exports, key, {
|
@@ -580,7 +569,7 @@ _forEachInstanceProperty(_context52 = _Object$keys(_textField)).call(_context52,
|
|
580
569
|
});
|
581
570
|
});
|
582
571
|
var _timefield = require("./timefield");
|
583
|
-
_forEachInstanceProperty(
|
572
|
+
_forEachInstanceProperty(_context52 = _Object$keys(_timefield)).call(_context52, function (key) {
|
584
573
|
if (key === "default" || key === "__esModule") return;
|
585
574
|
if (key in exports && exports[key] === _timefield[key]) return;
|
586
575
|
_Object$defineProperty(exports, key, {
|
@@ -591,7 +580,7 @@ _forEachInstanceProperty(_context53 = _Object$keys(_timefield)).call(_context53,
|
|
591
580
|
});
|
592
581
|
});
|
593
582
|
var _tooltipTrigger = require("./tooltipTrigger");
|
594
|
-
_forEachInstanceProperty(
|
583
|
+
_forEachInstanceProperty(_context53 = _Object$keys(_tooltipTrigger)).call(_context53, function (key) {
|
595
584
|
if (key === "default" || key === "__esModule") return;
|
596
585
|
if (key in exports && exports[key] === _tooltipTrigger[key]) return;
|
597
586
|
_Object$defineProperty(exports, key, {
|
@@ -183,9 +183,7 @@ export var ExpandableAndToggleableIndeterminate = function ExpandableAndToggleab
|
|
183
183
|
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(SwitchField, {
|
184
184
|
isSelected: isReadOnly,
|
185
185
|
label: "Is Read Only",
|
186
|
-
onChange:
|
187
|
-
return setIsReadOnly(!isReadOnly);
|
188
|
-
},
|
186
|
+
onChange: setIsReadOnly,
|
189
187
|
value: "my-switch"
|
190
188
|
}), ___EmotionJSX("br", null), ___EmotionJSX(Box, {
|
191
189
|
isRow: true,
|
@@ -8,32 +8,54 @@ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object
|
|
8
8
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
9
9
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
10
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
11
|
-
var _excluded = ["label", "helperText", "isDefaultSelected", "isDisabled", "status", "controlProps"];
|
11
|
+
var _excluded = ["label", "helperText", "isDefaultSelected", "isSelected", "onChange", "value", "name", "id", "isDisabled", "isReadOnly", "isRequired", "hasAutoFocus", "onFocus", "onBlur", "onFocusChange", "onKeyDown", "onKeyUp", "status", "controlProps"];
|
12
12
|
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
13
13
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
14
14
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
15
|
-
|
15
|
+
/* eslint-disable no-unused-vars */
|
16
|
+
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
|
16
17
|
import { useSwitch } from 'react-aria';
|
17
18
|
import { useToggleState } from 'react-stately';
|
18
19
|
import { usePress } from '@react-aria/interactions';
|
19
20
|
import omit from 'lodash/omit';
|
20
21
|
import { Box, FieldHelperText, Label, Switch } from '../..';
|
21
|
-
import { useField,
|
22
|
+
import { useField, usePropWarning } from '../../hooks';
|
22
23
|
import { getPendoID } from '../../utils/devUtils/constants/pendoID';
|
23
|
-
import
|
24
|
+
import { statusDefaultProp } from '../../utils/docUtils/statusProp';
|
25
|
+
import { switchFieldPropTypes } from './switchFieldAttributes';
|
24
26
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
25
27
|
var displayName = 'SwitchField';
|
26
28
|
var SwitchField = /*#__PURE__*/forwardRef(function (props, ref) {
|
27
|
-
var _inputProps$checked;
|
28
29
|
var label = props.label,
|
29
30
|
helperText = props.helperText,
|
30
31
|
isDefaultSelected = props.isDefaultSelected,
|
31
|
-
|
32
|
+
isSelected = props.isSelected,
|
33
|
+
onChange = props.onChange,
|
34
|
+
value = props.value,
|
35
|
+
name = props.name,
|
36
|
+
id = props.id,
|
37
|
+
_props$isDisabled = props.isDisabled,
|
38
|
+
isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
|
39
|
+
_props$isReadOnly = props.isReadOnly,
|
40
|
+
isReadOnly = _props$isReadOnly === void 0 ? false : _props$isReadOnly,
|
41
|
+
_props$isRequired = props.isRequired,
|
42
|
+
isRequired = _props$isRequired === void 0 ? false : _props$isRequired,
|
43
|
+
_props$hasAutoFocus = props.hasAutoFocus,
|
44
|
+
hasAutoFocus = _props$hasAutoFocus === void 0 ? false : _props$hasAutoFocus,
|
45
|
+
onFocus = props.onFocus,
|
46
|
+
onBlur = props.onBlur,
|
47
|
+
onFocusChange = props.onFocusChange,
|
48
|
+
onKeyDown = props.onKeyDown,
|
49
|
+
onKeyUp = props.onKeyUp,
|
32
50
|
status = props.status,
|
33
51
|
controlProps = props.controlProps,
|
34
52
|
others = _objectWithoutProperties(props, _excluded);
|
53
|
+
var switchRef = useRef();
|
35
54
|
usePropWarning(props, 'disabled', 'isDisabled');
|
36
|
-
|
55
|
+
/* istanbul ignore next */
|
56
|
+
useImperativeHandle(ref, function () {
|
57
|
+
return switchRef.current;
|
58
|
+
});
|
37
59
|
var state = useToggleState(_objectSpread({
|
38
60
|
defaultSelected: isDefaultSelected
|
39
61
|
}, props));
|
@@ -45,11 +67,11 @@ var SwitchField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
45
67
|
var _useSwitch = useSwitch(_objectSpread(_objectSpread({
|
46
68
|
children: label
|
47
69
|
}, whitelistedProps), {}, {
|
48
|
-
'aria-label':
|
70
|
+
'aria-label': 'switch-field'
|
49
71
|
}), state, switchRef),
|
50
72
|
inputProps = _useSwitch.inputProps;
|
51
73
|
var statusClasses = {
|
52
|
-
isSelected:
|
74
|
+
isSelected: inputProps.checked
|
53
75
|
};
|
54
76
|
var _useField = useField(_objectSpread(_objectSpread(_objectSpread({
|
55
77
|
statusClasses: statusClasses
|
@@ -69,13 +91,11 @@ var SwitchField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
69
91
|
}, fieldLabelProps), ___EmotionJSX(Box, fieldControlWrapperProps, ___EmotionJSX(Switch, _extends({
|
70
92
|
ref: switchRef,
|
71
93
|
inputProps: fieldControlInputProps
|
72
|
-
}, unhandledAriaProps, omit(others, 'data-pendo-id'
|
94
|
+
}, unhandledAriaProps, omit(others, 'data-pendo-id')))), label), helperText && ___EmotionJSX(FieldHelperText, {
|
73
95
|
status: status
|
74
96
|
}, helperText));
|
75
97
|
});
|
76
|
-
SwitchField.
|
77
|
-
|
78
|
-
isDisabled: false
|
79
|
-
};
|
98
|
+
SwitchField.propTypes = switchFieldPropTypes;
|
99
|
+
SwitchField.defaultProps = _objectSpread({}, statusDefaultProp);
|
80
100
|
SwitchField.displayName = displayName;
|
81
101
|
export default SwitchField;
|
@@ -47,9 +47,7 @@ export var Controlled = function Controlled() {
|
|
47
47
|
return ___EmotionJSX(SwitchField, {
|
48
48
|
isSelected: isSelected,
|
49
49
|
label: "Controlled",
|
50
|
-
onChange:
|
51
|
-
return setIsSelected(!isSelected);
|
52
|
-
},
|
50
|
+
onChange: setIsSelected,
|
53
51
|
value: "my-switch"
|
54
52
|
});
|
55
53
|
};
|
@@ -81,7 +79,7 @@ export var Required = function Required() {
|
|
81
79
|
});
|
82
80
|
};
|
83
81
|
export var WithTooltip = function WithTooltip() {
|
84
|
-
var tooltipTrigger = useRef(
|
82
|
+
var tooltipTrigger = useRef();
|
85
83
|
return ___EmotionJSX(TooltipTrigger, {
|
86
84
|
crossOffset: 15,
|
87
85
|
offset: 20,
|
@@ -11,8 +11,13 @@ var _context;
|
|
11
11
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
12
12
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
13
13
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
14
|
+
import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
|
15
|
+
import PropTypes from 'prop-types';
|
14
16
|
import statuses from '../../utils/devUtils/constants/statuses';
|
17
|
+
import { ariaAttributesBasePropTypes } from '../../utils/docUtils/ariaAttributes';
|
15
18
|
import { booleanArg, docArgTypes, funcArg } from '../../utils/docUtils/docArgTypes';
|
19
|
+
import { inputFieldAttributesBasePropTypes } from '../../utils/docUtils/fieldAttributes';
|
20
|
+
import { statusPropTypes } from '../../utils/docUtils/statusProp';
|
16
21
|
var descriptions = {
|
17
22
|
className: 'A list of class names to apply to the input element.',
|
18
23
|
hasAutoFocus: 'Whether the element should receive focus on render.',
|
@@ -154,4 +159,26 @@ export var switchFieldArgs = {
|
|
154
159
|
label: 'Example Label',
|
155
160
|
value: 'my-switch',
|
156
161
|
status: statuses.DEFAULT
|
157
|
-
};
|
162
|
+
};
|
163
|
+
export var switchFieldPropTypes = _objectSpread(_objectSpread(_objectSpread({
|
164
|
+
className: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
|
165
|
+
hasAutoFocus: PropTypes.bool,
|
166
|
+
helperText: PropTypes.node,
|
167
|
+
hintText: PropTypes.string,
|
168
|
+
id: PropTypes.string,
|
169
|
+
isDefaultSelected: PropTypes.bool,
|
170
|
+
isDisabled: PropTypes.bool,
|
171
|
+
isReadOnly: PropTypes.bool,
|
172
|
+
isRequired: PropTypes.bool,
|
173
|
+
isSelected: PropTypes.bool,
|
174
|
+
label: PropTypes.node,
|
175
|
+
name: PropTypes.string,
|
176
|
+
onBlur: PropTypes.func,
|
177
|
+
onChange: PropTypes.func,
|
178
|
+
onFocus: PropTypes.func,
|
179
|
+
onFocusChange: PropTypes.func,
|
180
|
+
onKeyDown: PropTypes.func,
|
181
|
+
onKeyUp: PropTypes.func,
|
182
|
+
status: PropTypes.oneOf(_Object$values(statuses)),
|
183
|
+
value: PropTypes.string
|
184
|
+
}, ariaAttributesBasePropTypes), inputFieldAttributesBasePropTypes), statusPropTypes);
|
package/lib/types/index.js
CHANGED
package/package.json
CHANGED
@@ -1,11 +0,0 @@
|
|
1
|
-
import { StoryFn } from '@storybook/react';
|
2
|
-
import { SwitchFieldProps } from '../../types';
|
3
|
-
declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
|
4
|
-
export default _default;
|
5
|
-
export declare const Default: StoryFn<SwitchFieldProps>;
|
6
|
-
export declare const Controlled: StoryFn<SwitchFieldProps>;
|
7
|
-
export declare const DefaultSelected: StoryFn<SwitchFieldProps>;
|
8
|
-
export declare const Disabled: StoryFn<SwitchFieldProps>;
|
9
|
-
export declare const NoVisibleLabel: StoryFn<SwitchFieldProps>;
|
10
|
-
export declare const Required: StoryFn<SwitchFieldProps>;
|
11
|
-
export declare const WithTooltip: StoryFn<SwitchFieldProps>;
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export { default } from './SwitchField';
|
@@ -1,94 +0,0 @@
|
|
1
|
-
export declare const switchFieldArgTypes: {
|
2
|
-
className: {
|
3
|
-
type: {
|
4
|
-
summary: string;
|
5
|
-
};
|
6
|
-
description: string;
|
7
|
-
};
|
8
|
-
hasAutoFocus: any;
|
9
|
-
helperText: {
|
10
|
-
control: {
|
11
|
-
type: any;
|
12
|
-
};
|
13
|
-
type: {
|
14
|
-
summary: any;
|
15
|
-
};
|
16
|
-
description: string;
|
17
|
-
};
|
18
|
-
hintText: {
|
19
|
-
control: {
|
20
|
-
type: any;
|
21
|
-
};
|
22
|
-
type: {
|
23
|
-
summary: any;
|
24
|
-
};
|
25
|
-
description: string;
|
26
|
-
};
|
27
|
-
id: {
|
28
|
-
control: {
|
29
|
-
type: any;
|
30
|
-
};
|
31
|
-
type: {
|
32
|
-
summary: any;
|
33
|
-
};
|
34
|
-
description: string;
|
35
|
-
};
|
36
|
-
isDefaultSelected: any;
|
37
|
-
isDisabled: any;
|
38
|
-
isReadOnly: any;
|
39
|
-
isRequired: any;
|
40
|
-
isSelected: {
|
41
|
-
control: {
|
42
|
-
type: string;
|
43
|
-
};
|
44
|
-
type: {
|
45
|
-
summary: any;
|
46
|
-
};
|
47
|
-
description: string;
|
48
|
-
};
|
49
|
-
label: {
|
50
|
-
control: {
|
51
|
-
type: any;
|
52
|
-
};
|
53
|
-
type: {
|
54
|
-
summary: any;
|
55
|
-
};
|
56
|
-
description: string;
|
57
|
-
};
|
58
|
-
name: {
|
59
|
-
control: {
|
60
|
-
type: any;
|
61
|
-
};
|
62
|
-
type: {
|
63
|
-
summary: any;
|
64
|
-
};
|
65
|
-
description: string;
|
66
|
-
};
|
67
|
-
onBlur: any;
|
68
|
-
onChange: any;
|
69
|
-
onFocus: any;
|
70
|
-
onFocusChange: any;
|
71
|
-
onKeyDown: any;
|
72
|
-
onKeyUp: any;
|
73
|
-
value: {
|
74
|
-
control: {
|
75
|
-
type: any;
|
76
|
-
};
|
77
|
-
type: {
|
78
|
-
summary: any;
|
79
|
-
};
|
80
|
-
description: string;
|
81
|
-
};
|
82
|
-
status: {
|
83
|
-
control: {
|
84
|
-
type: string;
|
85
|
-
options: any;
|
86
|
-
};
|
87
|
-
description: string;
|
88
|
-
};
|
89
|
-
};
|
90
|
-
export declare const switchFieldArgs: {
|
91
|
-
label: string;
|
92
|
-
value: string;
|
93
|
-
status: any;
|
94
|
-
};
|
@@ -1,29 +0,0 @@
|
|
1
|
-
/// <reference types="react" />
|
2
|
-
import { ControlProps } from '../hooks/useField/useField';
|
3
|
-
import { Status } from './item';
|
4
|
-
import { LabelProps } from './label';
|
5
|
-
import { DOMAttributes } from './shared';
|
6
|
-
export interface SwitchFieldProps extends DOMAttributes {
|
7
|
-
className?: string;
|
8
|
-
label?: React.ReactNode;
|
9
|
-
helperText?: string;
|
10
|
-
isDefaultSelected?: boolean;
|
11
|
-
isDisabled?: boolean;
|
12
|
-
status?: Status;
|
13
|
-
controlProps?: ControlProps;
|
14
|
-
isSelected?: boolean;
|
15
|
-
onChange?: () => void;
|
16
|
-
value?: string;
|
17
|
-
isRequired?: boolean;
|
18
|
-
hintText?: string;
|
19
|
-
labelProps?: LabelProps;
|
20
|
-
hasAutoFocus?: boolean;
|
21
|
-
id?: string;
|
22
|
-
isReadOnly?: boolean;
|
23
|
-
name?: string;
|
24
|
-
onBlur?: () => void;
|
25
|
-
onFocus?: () => void;
|
26
|
-
onFocusChange?: () => void;
|
27
|
-
onKeyDown?: () => void;
|
28
|
-
onKeyUp?: () => void;
|
29
|
-
}
|
package/lib/types/switchField.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|