@citygross/components 0.16.6 → 0.16.8

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.
@@ -12,5 +12,9 @@ export declare type TRadioListItemProps = styles.TBaseRadioItemInputWrapper & {
12
12
  wrapMobile?: boolean;
13
13
  children?: JSX.Element;
14
14
  additionalInfo?: JSX.Element;
15
+ tabIndex?: number;
16
+ onFocus?: React.FocusEventHandler<HTMLDivElement>;
17
+ onBlur?: React.FocusEventHandler<HTMLDivElement>;
18
+ onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
15
19
  };
16
- export declare function RadioListItem({ onClick, selected, flexGrow, isDisabled, transparent, noPadding, label, value, wrapMobile, additionalInfo, children }: TRadioListItemProps): React.JSX.Element;
20
+ export declare function RadioListItem({ onClick, selected, flexGrow, isDisabled, transparent, noPadding, label, value, wrapMobile, additionalInfo, children, tabIndex, onFocus, onBlur, onKeyDown }: TRadioListItemProps): React.JSX.Element;
@@ -4,19 +4,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
6
  var RadioListItem_styles = require('./RadioListItem.styles.js');
7
+ var utils = require('@citygross/utils');
7
8
 
8
9
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
10
 
10
11
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
11
12
 
12
13
  function RadioListItem(_a) {
13
- var onClick = _a.onClick, selected = _a.selected, _b = _a.flexGrow, flexGrow = _b === void 0 ? 1 : _b, isDisabled = _a.isDisabled, transparent = _a.transparent, noPadding = _a.noPadding, label = _a.label, value = _a.value, wrapMobile = _a.wrapMobile, additionalInfo = _a.additionalInfo, children = _a.children;
14
- return (React__default["default"].createElement(RadioListItem_styles.BaseRadioListItemContainer, { tabIndex: isDisabled ? -1 : 0, role: "radio", "aria-checked": selected, "aria-disabled": isDisabled, "aria-live": "polite", transparent: transparent, isDisabled: isDisabled, noPadding: noPadding, selected: selected, onClick: isDisabled ? function () { } : function () { return onClick(value); }, onKeyDown: function (event) {
15
- if ((event.key === 'Enter' || event.key === ' ') && !isDisabled) {
16
- event.preventDefault();
17
- onClick(value);
18
- }
19
- } },
14
+ var onClick = _a.onClick, selected = _a.selected, _b = _a.flexGrow, flexGrow = _b === void 0 ? 1 : _b, isDisabled = _a.isDisabled, transparent = _a.transparent, noPadding = _a.noPadding, label = _a.label, value = _a.value, wrapMobile = _a.wrapMobile, additionalInfo = _a.additionalInfo, children = _a.children, tabIndex = _a.tabIndex, onFocus = _a.onFocus, onBlur = _a.onBlur, onKeyDown = _a.onKeyDown;
15
+ var defaultTabIndex = isDisabled ? -1 : selected ? 0 : -1;
16
+ return (React__default["default"].createElement(RadioListItem_styles.BaseRadioListItemContainer, { tabIndex: tabIndex !== null && tabIndex !== void 0 ? tabIndex : defaultTabIndex, role: "radio", "aria-checked": selected, "aria-disabled": isDisabled, "aria-live": "polite", transparent: transparent, isDisabled: isDisabled, noPadding: noPadding, selected: selected, onClick: isDisabled ? function () { } : function () { return onClick(value); }, onFocus: onFocus, onBlur: onBlur, onKeyDown: function (event) { return utils.selectKeyboardEventHandler({ event: event, isDisabled: isDisabled, onClick: onClick, value: value, onKeyDown: onKeyDown }); } },
20
17
  React__default["default"].createElement(RadioListItem_styles.RadioFlex, { wrapMobile: wrapMobile },
21
18
  React__default["default"].createElement(RadioListItem_styles.BaseRadioItemLeftWrapper, { isDisabled: isDisabled, flexGrow: flexGrow },
22
19
  React__default["default"].createElement(RadioListItem_styles.LabelContentWrapper, null,
@@ -1 +1 @@
1
- {"version":3,"file":"RadioListItem.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"RadioListItem.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -519,6 +519,17 @@ var focusTrap = function (_a) {
519
519
  };
520
520
  };
521
521
 
522
+ var selectKeyboardEventHandler = function (_a) {
523
+ var event = _a.event, isDisabled = _a.isDisabled, onClick = _a.onClick, value = _a.value, onKeyDown = _a.onKeyDown;
524
+ if ((event.key === 'Enter' || event.key === ' ') && !isDisabled) {
525
+ event.preventDefault();
526
+ onClick(value);
527
+ }
528
+ if (onKeyDown) {
529
+ onKeyDown(event);
530
+ }
531
+ };
532
+
522
533
  var toggleInert = function (_a) {
523
534
  var elements = _a.elements, isInert = _a.isInert;
524
535
  var snapshots = elements
@@ -18968,6 +18979,7 @@ index.__exports.makeCateringPortionsString = makeCateringPortionsString;
18968
18979
  index.__exports.moment = moment;
18969
18980
  index.__exports.nameRegex = nameRegex;
18970
18981
  index.__exports.phoneRegex = phoneRegex;
18982
+ index.__exports.selectKeyboardEventHandler = selectKeyboardEventHandler;
18971
18983
  index.__exports.toggleInert = toggleInert;
18972
18984
  index.__exports.useDetectDevice = useDetectDevice;
18973
18985
  index.__exports.useFixedModalScroll = useFixedModalScroll;