@pingux/astro 2.84.0-alpha.3 → 2.84.0-alpha.5
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 +3 -1
- package/lib/cjs/components/ListBox/ListBox.styles.js +6 -3
- package/lib/cjs/components/SwitchField/SwitchField.d.ts +4 -0
- package/lib/cjs/components/SwitchField/SwitchField.js +12 -32
- package/lib/cjs/components/SwitchField/SwitchField.stories.d.ts +11 -0
- package/lib/cjs/components/SwitchField/SwitchField.stories.js +4 -2
- package/lib/cjs/components/SwitchField/SwitchField.test.d.ts +1 -0
- package/lib/cjs/components/SwitchField/index.d.ts +1 -0
- package/lib/cjs/components/SwitchField/switchFieldAttributes.d.ts +94 -0
- package/lib/cjs/components/SwitchField/switchFieldAttributes.js +2 -30
- package/lib/cjs/styles/themes/next-gen/next-gen.d.ts +3 -0
- package/lib/cjs/styles/themes/next-gen/variants/variants.d.ts +3 -0
- package/lib/cjs/styles/themes/next-gen/variants/variants.js +4 -1
- package/lib/cjs/types/index.d.ts +1 -0
- package/lib/cjs/types/index.js +19 -8
- package/lib/cjs/types/switchField.d.ts +29 -0
- package/lib/cjs/types/switchField.js +6 -0
- package/lib/components/CheckboxField/CheckboxField.stories.js +3 -1
- package/lib/components/ListBox/ListBox.styles.js +6 -3
- package/lib/components/SwitchField/SwitchField.js +14 -34
- package/lib/components/SwitchField/SwitchField.stories.js +4 -2
- package/lib/components/SwitchField/switchFieldAttributes.js +1 -28
- package/lib/styles/themes/next-gen/variants/variants.js +4 -1
- package/lib/types/index.js +1 -0
- package/lib/types/switchField.js +1 -0
- package/package.json +1 -1
@@ -200,7 +200,9 @@ 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:
|
203
|
+
onChange: function onChange() {
|
204
|
+
return setIsReadOnly(!isReadOnly);
|
205
|
+
},
|
204
206
|
value: "my-switch"
|
205
207
|
}), (0, _react2.jsx)("br", null), (0, _react2.jsx)(_index.Box, {
|
206
208
|
isRow: true,
|
@@ -27,13 +27,16 @@ listBox.option = _objectSpread(_objectSpread({}, _Text.text.base), {}, {
|
|
27
27
|
outline: 'none',
|
28
28
|
wordBreak: 'break-word',
|
29
29
|
cursor: 'pointer',
|
30
|
-
'&.is-selected': _objectSpread(_objectSpread({}, _Text.text.inputValue), {}, {
|
31
|
-
pl: 0
|
32
|
-
}),
|
33
30
|
'&.is-focused': {
|
34
31
|
color: 'white',
|
35
32
|
bg: 'active'
|
36
33
|
},
|
34
|
+
'&.is-selected': _objectSpread(_objectSpread({}, _Text.text.inputValue), {}, {
|
35
|
+
pl: 0,
|
36
|
+
'&.is-focused': {
|
37
|
+
color: 'white'
|
38
|
+
}
|
39
|
+
}),
|
37
40
|
'&.is-condensed': {
|
38
41
|
'&.is-selected': {
|
39
42
|
pl: 'md',
|
@@ -27,47 +27,25 @@ 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
|
31
|
-
var _switchFieldAttributes = require("./switchFieldAttributes");
|
30
|
+
var _statuses = _interopRequireDefault(require("../../utils/devUtils/constants/statuses"));
|
32
31
|
var _react2 = require("@emotion/react");
|
33
|
-
var _excluded = ["label", "helperText", "isDefaultSelected", "
|
34
|
-
/* eslint-disable no-unused-vars */
|
32
|
+
var _excluded = ["label", "helperText", "isDefaultSelected", "isDisabled", "status", "controlProps"];
|
35
33
|
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); }
|
36
34
|
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; }
|
37
35
|
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; }
|
38
36
|
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; }
|
39
37
|
var displayName = 'SwitchField';
|
40
38
|
var SwitchField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
39
|
+
var _inputProps$checked;
|
41
40
|
var label = props.label,
|
42
41
|
helperText = props.helperText,
|
43
42
|
isDefaultSelected = props.isDefaultSelected,
|
44
|
-
|
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,
|
43
|
+
isDisabled = props.isDisabled,
|
62
44
|
status = props.status,
|
63
45
|
controlProps = props.controlProps,
|
64
46
|
others = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
65
|
-
var switchRef = (0, _react.useRef)();
|
66
47
|
(0, _hooks.usePropWarning)(props, 'disabled', 'isDisabled');
|
67
|
-
|
68
|
-
(0, _react.useImperativeHandle)(ref, function () {
|
69
|
-
return switchRef.current;
|
70
|
-
});
|
48
|
+
var switchRef = (0, _hooks.useLocalOrForwardRef)(ref);
|
71
49
|
var state = (0, _reactStately.useToggleState)(_objectSpread({
|
72
50
|
defaultSelected: isDefaultSelected
|
73
51
|
}, props));
|
@@ -79,11 +57,11 @@ var SwitchField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
79
57
|
var _useSwitch = (0, _reactAria.useSwitch)(_objectSpread(_objectSpread({
|
80
58
|
children: label
|
81
59
|
}, whitelistedProps), {}, {
|
82
|
-
'aria-label': 'switch-field'
|
60
|
+
'aria-label': others['aria-label'] || 'switch-field'
|
83
61
|
}), state, switchRef),
|
84
62
|
inputProps = _useSwitch.inputProps;
|
85
63
|
var statusClasses = {
|
86
|
-
isSelected: inputProps.checked
|
64
|
+
isSelected: (_inputProps$checked = inputProps.checked) !== null && _inputProps$checked !== void 0 ? _inputProps$checked : false
|
87
65
|
};
|
88
66
|
var _useField = (0, _hooks.useField)(_objectSpread(_objectSpread(_objectSpread({
|
89
67
|
statusClasses: statusClasses
|
@@ -103,12 +81,14 @@ var SwitchField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
103
81
|
}, fieldLabelProps), (0, _react2.jsx)(_.Box, fieldControlWrapperProps, (0, _react2.jsx)(_.Switch, (0, _extends2["default"])({
|
104
82
|
ref: switchRef,
|
105
83
|
inputProps: fieldControlInputProps
|
106
|
-
}, unhandledAriaProps, (0, _omit["default"])(others, 'data-pendo-id')))), label), helperText && (0, _react2.jsx)(_.FieldHelperText, {
|
84
|
+
}, unhandledAriaProps, (0, _omit["default"])(others, 'data-pendo-id', 'aria-label')))), label), helperText && (0, _react2.jsx)(_.FieldHelperText, {
|
107
85
|
status: status
|
108
86
|
}, helperText));
|
109
87
|
});
|
110
|
-
SwitchField.
|
111
|
-
|
88
|
+
SwitchField.defaultProps = {
|
89
|
+
status: _statuses["default"].DEFAULT,
|
90
|
+
isDisabled: false
|
91
|
+
};
|
112
92
|
SwitchField.displayName = displayName;
|
113
93
|
var _default = SwitchField;
|
114
94
|
exports["default"] = _default;
|
@@ -0,0 +1,11 @@
|
|
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>;
|
@@ -60,7 +60,9 @@ var Controlled = function Controlled() {
|
|
60
60
|
return (0, _react2.jsx)(_index.SwitchField, {
|
61
61
|
isSelected: isSelected,
|
62
62
|
label: "Controlled",
|
63
|
-
onChange:
|
63
|
+
onChange: function onChange() {
|
64
|
+
return setIsSelected(!isSelected);
|
65
|
+
},
|
64
66
|
value: "my-switch"
|
65
67
|
});
|
66
68
|
};
|
@@ -97,7 +99,7 @@ var Required = function Required() {
|
|
97
99
|
};
|
98
100
|
exports.Required = Required;
|
99
101
|
var WithTooltip = function WithTooltip() {
|
100
|
-
var tooltipTrigger = (0, _react.useRef)();
|
102
|
+
var tooltipTrigger = (0, _react.useRef)(null);
|
101
103
|
return (0, _react2.jsx)(_index.TooltipTrigger, {
|
102
104
|
crossOffset: 15,
|
103
105
|
offset: 20,
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './SwitchField';
|
@@ -0,0 +1,94 @@
|
|
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
|
+
};
|
@@ -12,16 +12,11 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
12
12
|
_Object$defineProperty(exports, "__esModule", {
|
13
13
|
value: true
|
14
14
|
});
|
15
|
-
exports.
|
15
|
+
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"));
|
20
18
|
var _statuses = _interopRequireDefault(require("../../utils/devUtils/constants/statuses"));
|
21
|
-
var _ariaAttributes = require("../../utils/docUtils/ariaAttributes");
|
22
19
|
var _docArgTypes = require("../../utils/docUtils/docArgTypes");
|
23
|
-
var _fieldAttributes = require("../../utils/docUtils/fieldAttributes");
|
24
|
-
var _statusProp = require("../../utils/docUtils/statusProp");
|
25
20
|
var _context;
|
26
21
|
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; }
|
27
22
|
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; }
|
@@ -168,27 +163,4 @@ var switchFieldArgs = {
|
|
168
163
|
value: 'my-switch',
|
169
164
|
status: _statuses["default"].DEFAULT
|
170
165
|
};
|
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;
|
166
|
+
exports.switchFieldArgs = switchFieldArgs;
|
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, _context54;
|
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,8 +513,19 @@ _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
|
+
});
|
516
527
|
var _tab = require("./tab");
|
517
|
-
_forEachInstanceProperty(
|
528
|
+
_forEachInstanceProperty(_context48 = _Object$keys(_tab)).call(_context48, function (key) {
|
518
529
|
if (key === "default" || key === "__esModule") return;
|
519
530
|
if (key in exports && exports[key] === _tab[key]) return;
|
520
531
|
_Object$defineProperty(exports, key, {
|
@@ -525,7 +536,7 @@ _forEachInstanceProperty(_context47 = _Object$keys(_tab)).call(_context47, funct
|
|
525
536
|
});
|
526
537
|
});
|
527
538
|
var _table = require("./table");
|
528
|
-
_forEachInstanceProperty(
|
539
|
+
_forEachInstanceProperty(_context49 = _Object$keys(_table)).call(_context49, function (key) {
|
529
540
|
if (key === "default" || key === "__esModule") return;
|
530
541
|
if (key in exports && exports[key] === _table[key]) return;
|
531
542
|
_Object$defineProperty(exports, key, {
|
@@ -536,7 +547,7 @@ _forEachInstanceProperty(_context48 = _Object$keys(_table)).call(_context48, fun
|
|
536
547
|
});
|
537
548
|
});
|
538
549
|
var _tabs = require("./tabs");
|
539
|
-
_forEachInstanceProperty(
|
550
|
+
_forEachInstanceProperty(_context50 = _Object$keys(_tabs)).call(_context50, function (key) {
|
540
551
|
if (key === "default" || key === "__esModule") return;
|
541
552
|
if (key in exports && exports[key] === _tabs[key]) return;
|
542
553
|
_Object$defineProperty(exports, key, {
|
@@ -547,7 +558,7 @@ _forEachInstanceProperty(_context49 = _Object$keys(_tabs)).call(_context49, func
|
|
547
558
|
});
|
548
559
|
});
|
549
560
|
var _text = require("./text");
|
550
|
-
_forEachInstanceProperty(
|
561
|
+
_forEachInstanceProperty(_context51 = _Object$keys(_text)).call(_context51, function (key) {
|
551
562
|
if (key === "default" || key === "__esModule") return;
|
552
563
|
if (key in exports && exports[key] === _text[key]) return;
|
553
564
|
_Object$defineProperty(exports, key, {
|
@@ -558,7 +569,7 @@ _forEachInstanceProperty(_context50 = _Object$keys(_text)).call(_context50, func
|
|
558
569
|
});
|
559
570
|
});
|
560
571
|
var _textField = require("./textField");
|
561
|
-
_forEachInstanceProperty(
|
572
|
+
_forEachInstanceProperty(_context52 = _Object$keys(_textField)).call(_context52, function (key) {
|
562
573
|
if (key === "default" || key === "__esModule") return;
|
563
574
|
if (key in exports && exports[key] === _textField[key]) return;
|
564
575
|
_Object$defineProperty(exports, key, {
|
@@ -569,7 +580,7 @@ _forEachInstanceProperty(_context51 = _Object$keys(_textField)).call(_context51,
|
|
569
580
|
});
|
570
581
|
});
|
571
582
|
var _timefield = require("./timefield");
|
572
|
-
_forEachInstanceProperty(
|
583
|
+
_forEachInstanceProperty(_context53 = _Object$keys(_timefield)).call(_context53, function (key) {
|
573
584
|
if (key === "default" || key === "__esModule") return;
|
574
585
|
if (key in exports && exports[key] === _timefield[key]) return;
|
575
586
|
_Object$defineProperty(exports, key, {
|
@@ -580,7 +591,7 @@ _forEachInstanceProperty(_context52 = _Object$keys(_timefield)).call(_context52,
|
|
580
591
|
});
|
581
592
|
});
|
582
593
|
var _tooltipTrigger = require("./tooltipTrigger");
|
583
|
-
_forEachInstanceProperty(
|
594
|
+
_forEachInstanceProperty(_context54 = _Object$keys(_tooltipTrigger)).call(_context54, function (key) {
|
584
595
|
if (key === "default" || key === "__esModule") return;
|
585
596
|
if (key in exports && exports[key] === _tooltipTrigger[key]) return;
|
586
597
|
_Object$defineProperty(exports, key, {
|
@@ -0,0 +1,29 @@
|
|
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
|
+
}
|
@@ -183,7 +183,9 @@ 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:
|
186
|
+
onChange: function onChange() {
|
187
|
+
return setIsReadOnly(!isReadOnly);
|
188
|
+
},
|
187
189
|
value: "my-switch"
|
188
190
|
}), ___EmotionJSX("br", null), ___EmotionJSX(Box, {
|
189
191
|
isRow: true,
|
@@ -20,13 +20,16 @@ listBox.option = _objectSpread(_objectSpread({}, text.base), {}, {
|
|
20
20
|
outline: 'none',
|
21
21
|
wordBreak: 'break-word',
|
22
22
|
cursor: 'pointer',
|
23
|
-
'&.is-selected': _objectSpread(_objectSpread({}, text.inputValue), {}, {
|
24
|
-
pl: 0
|
25
|
-
}),
|
26
23
|
'&.is-focused': {
|
27
24
|
color: 'white',
|
28
25
|
bg: 'active'
|
29
26
|
},
|
27
|
+
'&.is-selected': _objectSpread(_objectSpread({}, text.inputValue), {}, {
|
28
|
+
pl: 0,
|
29
|
+
'&.is-focused': {
|
30
|
+
color: 'white'
|
31
|
+
}
|
32
|
+
}),
|
30
33
|
'&.is-condensed': {
|
31
34
|
'&.is-selected': {
|
32
35
|
pl: 'md',
|
@@ -8,54 +8,32 @@ 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", "
|
11
|
+
var _excluded = ["label", "helperText", "isDefaultSelected", "isDisabled", "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
|
-
|
16
|
-
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
|
15
|
+
import React, { forwardRef } from 'react';
|
17
16
|
import { useSwitch } from 'react-aria';
|
18
17
|
import { useToggleState } from 'react-stately';
|
19
18
|
import { usePress } from '@react-aria/interactions';
|
20
19
|
import omit from 'lodash/omit';
|
21
20
|
import { Box, FieldHelperText, Label, Switch } from '../..';
|
22
|
-
import { useField, usePropWarning } from '../../hooks';
|
21
|
+
import { useField, useLocalOrForwardRef, usePropWarning } from '../../hooks';
|
23
22
|
import { getPendoID } from '../../utils/devUtils/constants/pendoID';
|
24
|
-
import
|
25
|
-
import { switchFieldPropTypes } from './switchFieldAttributes';
|
23
|
+
import statuses from '../../utils/devUtils/constants/statuses';
|
26
24
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
27
25
|
var displayName = 'SwitchField';
|
28
26
|
var SwitchField = /*#__PURE__*/forwardRef(function (props, ref) {
|
27
|
+
var _inputProps$checked;
|
29
28
|
var label = props.label,
|
30
29
|
helperText = props.helperText,
|
31
30
|
isDefaultSelected = props.isDefaultSelected,
|
32
|
-
|
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,
|
31
|
+
isDisabled = props.isDisabled,
|
50
32
|
status = props.status,
|
51
33
|
controlProps = props.controlProps,
|
52
34
|
others = _objectWithoutProperties(props, _excluded);
|
53
|
-
var switchRef = useRef();
|
54
35
|
usePropWarning(props, 'disabled', 'isDisabled');
|
55
|
-
|
56
|
-
useImperativeHandle(ref, function () {
|
57
|
-
return switchRef.current;
|
58
|
-
});
|
36
|
+
var switchRef = useLocalOrForwardRef(ref);
|
59
37
|
var state = useToggleState(_objectSpread({
|
60
38
|
defaultSelected: isDefaultSelected
|
61
39
|
}, props));
|
@@ -67,11 +45,11 @@ var SwitchField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
67
45
|
var _useSwitch = useSwitch(_objectSpread(_objectSpread({
|
68
46
|
children: label
|
69
47
|
}, whitelistedProps), {}, {
|
70
|
-
'aria-label': 'switch-field'
|
48
|
+
'aria-label': others['aria-label'] || 'switch-field'
|
71
49
|
}), state, switchRef),
|
72
50
|
inputProps = _useSwitch.inputProps;
|
73
51
|
var statusClasses = {
|
74
|
-
isSelected: inputProps.checked
|
52
|
+
isSelected: (_inputProps$checked = inputProps.checked) !== null && _inputProps$checked !== void 0 ? _inputProps$checked : false
|
75
53
|
};
|
76
54
|
var _useField = useField(_objectSpread(_objectSpread(_objectSpread({
|
77
55
|
statusClasses: statusClasses
|
@@ -91,11 +69,13 @@ var SwitchField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
91
69
|
}, fieldLabelProps), ___EmotionJSX(Box, fieldControlWrapperProps, ___EmotionJSX(Switch, _extends({
|
92
70
|
ref: switchRef,
|
93
71
|
inputProps: fieldControlInputProps
|
94
|
-
}, unhandledAriaProps, omit(others, 'data-pendo-id')))), label), helperText && ___EmotionJSX(FieldHelperText, {
|
72
|
+
}, unhandledAriaProps, omit(others, 'data-pendo-id', 'aria-label')))), label), helperText && ___EmotionJSX(FieldHelperText, {
|
95
73
|
status: status
|
96
74
|
}, helperText));
|
97
75
|
});
|
98
|
-
SwitchField.
|
99
|
-
|
76
|
+
SwitchField.defaultProps = {
|
77
|
+
status: statuses.DEFAULT,
|
78
|
+
isDisabled: false
|
79
|
+
};
|
100
80
|
SwitchField.displayName = displayName;
|
101
81
|
export default SwitchField;
|
@@ -47,7 +47,9 @@ export var Controlled = function Controlled() {
|
|
47
47
|
return ___EmotionJSX(SwitchField, {
|
48
48
|
isSelected: isSelected,
|
49
49
|
label: "Controlled",
|
50
|
-
onChange:
|
50
|
+
onChange: function onChange() {
|
51
|
+
return setIsSelected(!isSelected);
|
52
|
+
},
|
51
53
|
value: "my-switch"
|
52
54
|
});
|
53
55
|
};
|
@@ -79,7 +81,7 @@ export var Required = function Required() {
|
|
79
81
|
});
|
80
82
|
};
|
81
83
|
export var WithTooltip = function WithTooltip() {
|
82
|
-
var tooltipTrigger = useRef();
|
84
|
+
var tooltipTrigger = useRef(null);
|
83
85
|
return ___EmotionJSX(TooltipTrigger, {
|
84
86
|
crossOffset: 15,
|
85
87
|
offset: 20,
|
@@ -11,13 +11,8 @@ 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';
|
16
14
|
import statuses from '../../utils/devUtils/constants/statuses';
|
17
|
-
import { ariaAttributesBasePropTypes } from '../../utils/docUtils/ariaAttributes';
|
18
15
|
import { booleanArg, docArgTypes, funcArg } from '../../utils/docUtils/docArgTypes';
|
19
|
-
import { inputFieldAttributesBasePropTypes } from '../../utils/docUtils/fieldAttributes';
|
20
|
-
import { statusPropTypes } from '../../utils/docUtils/statusProp';
|
21
16
|
var descriptions = {
|
22
17
|
className: 'A list of class names to apply to the input element.',
|
23
18
|
hasAutoFocus: 'Whether the element should receive focus on render.',
|
@@ -159,26 +154,4 @@ export var switchFieldArgs = {
|
|
159
154
|
label: 'Example Label',
|
160
155
|
value: 'my-switch',
|
161
156
|
status: statuses.DEFAULT
|
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);
|
157
|
+
};
|
package/lib/types/index.js
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|