@nulogy/components 6.5.0 → 6.6.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/dist/main.js CHANGED
@@ -16203,7 +16203,7 @@
16203
16203
 
16204
16204
  return /*#__PURE__*/React__default['default'].createElement(WrapperButton$1, Object.assign({
16205
16205
  ref: forwardedRef,
16206
- "aria-label": children,
16206
+ "aria-label": props["aria-label"] ? props["aria-label"] : typeof children === "string" ? children : undefined,
16207
16207
  className: className
16208
16208
  }, props), /*#__PURE__*/React__default['default'].createElement(Manager$2, null, /*#__PURE__*/React__default['default'].createElement(Reference$2, null, function (_ref4) {
16209
16209
  var ref = _ref4.ref;
@@ -24527,7 +24527,7 @@
24527
24527
  }
24528
24528
  };
24529
24529
  });
24530
- var Switch = styled__default['default'].div.withConfig({
24530
+ var Switch$1 = styled__default['default'].div.withConfig({
24531
24531
  displayName: "ToggleButton__Switch",
24532
24532
  componentId: "t7wo9n-1"
24533
24533
  })(function (_ref2) {
@@ -24576,7 +24576,7 @@
24576
24576
  }
24577
24577
  };
24578
24578
 
24579
- return /*#__PURE__*/React__default['default'].createElement(Switch, {
24579
+ return /*#__PURE__*/React__default['default'].createElement(Switch$1, {
24580
24580
  onClick: handleClick
24581
24581
  }, /*#__PURE__*/React__default['default'].createElement(ToggleInput, Object.assign({
24582
24582
  ref: inputRef,
@@ -27494,6 +27494,55 @@
27494
27494
  label: null
27495
27495
  };
27496
27496
 
27497
+ var FocusManager = function FocusManager(_ref) {
27498
+ var children = _ref.children,
27499
+ _ref$refs = _ref.refs,
27500
+ refs = _ref$refs === void 0 ? undefined : _ref$refs;
27501
+
27502
+ var _useState = React.useState(0),
27503
+ focusedIndex = _useState[0],
27504
+ setFocusedIndex = _useState[1];
27505
+
27506
+ var focusPrevious = function focusPrevious() {
27507
+ setFocusedIndex(function (prevFocusedIndex) {
27508
+ return (prevFocusedIndex - 1 + refs.length) % refs.length;
27509
+ });
27510
+ };
27511
+
27512
+ var focusNext = function focusNext() {
27513
+ setFocusedIndex(function (prevFocusedIndex) {
27514
+ return (prevFocusedIndex + 1) % refs.length;
27515
+ });
27516
+ };
27517
+
27518
+ var handleArrowNavigation = function handleArrowNavigation(e) {
27519
+ switch (e.key) {
27520
+ case "ArrowLeft":
27521
+ e.preventDefault();
27522
+ focusPrevious();
27523
+ break;
27524
+
27525
+ case "ArrowRight":
27526
+ e.preventDefault();
27527
+ focusNext();
27528
+ break;
27529
+ }
27530
+ };
27531
+
27532
+ React.useEffect(function () {
27533
+ var updateFocused = function updateFocused() {
27534
+ refs[focusedIndex].focus();
27535
+ };
27536
+
27537
+ updateFocused();
27538
+ }, [focusedIndex, refs]);
27539
+ return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, children({
27540
+ focusedIndex: focusedIndex,
27541
+ setFocusedIndex: setFocusedIndex,
27542
+ handleArrowNavigation: handleArrowNavigation
27543
+ }));
27544
+ };
27545
+
27497
27546
  var TabContainer = styled__default['default'](Box).withConfig({
27498
27547
  displayName: "TabContainer",
27499
27548
  componentId: "sc-1esq49v-0"
@@ -27522,94 +27571,6 @@
27522
27571
  };
27523
27572
  });
27524
27573
 
27525
- var TabFocusManager = /*#__PURE__*/function (_React$Component) {
27526
- _inheritsLoose__default['default'](TabFocusManager, _React$Component);
27527
-
27528
- function TabFocusManager(props) {
27529
- var _this;
27530
-
27531
- _this = _React$Component.call(this, props) || this;
27532
- _this.state = {
27533
- focusedIndex: 0
27534
- };
27535
- _this.handleArrowNavigation = _this.handleArrowNavigation.bind(_assertThisInitialized__default['default'](_this));
27536
- _this.focusNextTab = _this.focusNextTab.bind(_assertThisInitialized__default['default'](_this));
27537
- _this.focusPreviousTab = _this.focusPreviousTab.bind(_assertThisInitialized__default['default'](_this));
27538
- _this.setFocusToTab = _this.setFocusToTab.bind(_assertThisInitialized__default['default'](_this));
27539
- return _this;
27540
- }
27541
-
27542
- var _proto = TabFocusManager.prototype;
27543
-
27544
- _proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
27545
- var focusedIndex = this.state.focusedIndex;
27546
-
27547
- if (prevState.focusedIndex !== focusedIndex) {
27548
- this.updateFocusedTab();
27549
- }
27550
- };
27551
-
27552
- _proto.setFocusToTab = function setFocusToTab(index) {
27553
- this.setState({
27554
- focusedIndex: index
27555
- });
27556
- };
27557
-
27558
- _proto.handleArrowNavigation = function handleArrowNavigation(e) {
27559
- switch (e.key) {
27560
- case "ArrowLeft":
27561
- e.preventDefault();
27562
- this.focusPreviousTab();
27563
- break;
27564
-
27565
- case "ArrowRight":
27566
- e.preventDefault();
27567
- this.focusNextTab();
27568
- break;
27569
- }
27570
- };
27571
-
27572
- _proto.focusNextTab = function focusNextTab() {
27573
- var tabRefs = this.props.tabRefs;
27574
- this.setState(function (prevState) {
27575
- return {
27576
- focusedIndex: (prevState.focusedIndex + 1) % tabRefs.length
27577
- };
27578
- });
27579
- };
27580
-
27581
- _proto.focusPreviousTab = function focusPreviousTab() {
27582
- var tabRefs = this.props.tabRefs;
27583
- this.setState(function (prevState) {
27584
- return {
27585
- focusedIndex: (prevState.focusedIndex - 1 + tabRefs.length) % tabRefs.length
27586
- };
27587
- });
27588
- };
27589
-
27590
- _proto.updateFocusedTab = function updateFocusedTab() {
27591
- var tabRefs = this.props.tabRefs;
27592
- var focusedIndex = this.state.focusedIndex;
27593
- tabRefs[focusedIndex].focus();
27594
- };
27595
-
27596
- _proto.render = function render() {
27597
- var focusedIndex = this.state.focusedIndex;
27598
- var children = this.props.children;
27599
- return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, children({
27600
- focusedIndex: focusedIndex,
27601
- handleArrowNavigation: this.handleArrowNavigation,
27602
- setFocusToTab: this.setFocusToTab
27603
- }));
27604
- };
27605
-
27606
- return TabFocusManager;
27607
- }(React__default['default'].Component);
27608
-
27609
- TabFocusManager.defaultProps = {
27610
- tabRefs: undefined
27611
- };
27612
-
27613
27574
  var TabScrollIndicatorButton = styled__default['default'].button.withConfig({
27614
27575
  displayName: "TabScrollIndicator__TabScrollIndicatorButton",
27615
27576
  componentId: "sc-91z16z-0"
@@ -28008,12 +27969,12 @@
28008
27969
  var spaceProps = getSubset(this.props, propTypes.space);
28009
27970
  return /*#__PURE__*/React__default['default'].createElement(Box, {
28010
27971
  position: "relative"
28011
- }, /*#__PURE__*/React__default['default'].createElement(TabFocusManager, {
28012
- tabRefs: this.tabRefs
27972
+ }, /*#__PURE__*/React__default['default'].createElement(FocusManager, {
27973
+ refs: this.tabRefs
28013
27974
  }, function (_ref2) {
28014
- var handleArrowNavigation = _ref2.handleArrowNavigation,
28015
- setFocusToTab = _ref2.setFocusToTab,
28016
- focusedIndex = _ref2.focusedIndex;
27975
+ var focusedIndex = _ref2.focusedIndex,
27976
+ setFocusedIndex = _ref2.setFocusedIndex,
27977
+ handleArrowNavigation = _ref2.handleArrowNavigation;
28017
27978
  return /*#__PURE__*/React__default['default'].createElement(TabScrollIndicators, {
28018
27979
  tabRefs: _this3.tabRefs,
28019
27980
  tabContainerRef: _this3.tabContainerRef
@@ -28028,7 +27989,7 @@
28028
27989
  }, spaceProps), /*#__PURE__*/React__default['default'].createElement(ResizeDetector, {
28029
27990
  handleWidth: true,
28030
27991
  onResize: handleResize
28031
- }), _this3.getTabs(setFocusToTab, focusedIndex, handleArrowNavigation));
27992
+ }), _this3.getTabs(setFocusedIndex, focusedIndex, handleArrowNavigation));
28032
27993
  });
28033
27994
  }), this.getTabContent());
28034
27995
  };
@@ -28046,6 +28007,109 @@
28046
28007
  onTabClick: undefined
28047
28008
  };
28048
28009
 
28010
+ var Switcher = function Switcher(_a) {
28011
+ var selected = _a.selected,
28012
+ onChange = _a.onChange,
28013
+ rest = __rest(_a, ["selected", "onChange"]);
28014
+
28015
+ var optionRefs = [];
28016
+
28017
+ var isSelected = function isSelected(value, index) {
28018
+ if (!selected) return index === 0;
28019
+ return value === selected;
28020
+ };
28021
+
28022
+ var options = function options(focusedIndex, setFocusedIndex, handleArrowNavigation) {
28023
+ return React__default['default'].Children.map(rest.children, function (child, index) {
28024
+ return /*#__PURE__*/React__default['default'].cloneElement(child, {
28025
+ index: index,
28026
+ tabIndex: index === focusedIndex ? 0 : -1,
28027
+ selected: isSelected(child.props.value, index),
28028
+ "aria-selected": isSelected(child.props.value, index),
28029
+ onKeyDown: handleArrowNavigation,
28030
+ ref: function ref(_ref) {
28031
+ optionRefs[index] = _ref;
28032
+ },
28033
+ onFocus: function onFocus(e) {
28034
+ e.stopPropagation();
28035
+ },
28036
+ onClick: function onClick() {
28037
+ setFocusedIndex(index);
28038
+ if (onChange) onChange(child.props.value);
28039
+ }
28040
+ });
28041
+ });
28042
+ };
28043
+
28044
+ return /*#__PURE__*/React__default['default'].createElement(Box, Object.assign({
28045
+ display: "inline-flex",
28046
+ bg: "whiteGrey",
28047
+ borderRadius: "20px"
28048
+ }, rest), /*#__PURE__*/React__default['default'].createElement(FocusManager, {
28049
+ refs: optionRefs
28050
+ }, function (_ref2) {
28051
+ var focusedIndex = _ref2.focusedIndex,
28052
+ setFocusedIndex = _ref2.setFocusedIndex,
28053
+ handleArrowNavigation = _ref2.handleArrowNavigation;
28054
+ return options(focusedIndex, setFocusedIndex, handleArrowNavigation);
28055
+ }));
28056
+ };
28057
+
28058
+ Switcher.propTypes = {
28059
+ children: PropTypes__default['default'].node,
28060
+ selected: PropTypes__default['default'].string,
28061
+ onChange: PropTypes__default['default'].func
28062
+ };
28063
+
28064
+ var SwitchButton = styled__default['default'].button.withConfig({
28065
+ displayName: "Switch__SwitchButton",
28066
+ componentId: "wsu5uq-0"
28067
+ })(function (_ref) {
28068
+ var selected = _ref.selected,
28069
+ theme = _ref.theme;
28070
+ return Object.assign(Object.assign(Object.assign({
28071
+ height: theme.space.x4,
28072
+ margin: 1,
28073
+ padding: theme.space.half + " " + theme.space.x2,
28074
+ background: selected ? theme.colors.white : "none",
28075
+ color: selected ? theme.colors.darkBlue : theme.colors.darkGrey,
28076
+ cursor: "pointer",
28077
+ border: "none",
28078
+ borderRadius: 20,
28079
+ fontSize: theme.fontSizes.medium,
28080
+ fontWeight: theme.fontWeights.medium,
28081
+ lineHeight: theme.lineHeights.base,
28082
+ textDecoration: "none",
28083
+ whiteSpace: "nowrap"
28084
+ }, selected && {
28085
+ boxShadow: theme.shadows.small
28086
+ }), {
28087
+ "&:focus": {
28088
+ outline: "none",
28089
+ boxShadow: theme.shadows.focus
28090
+ }
28091
+ }), !selected && {
28092
+ "&:hover": {
28093
+ backgroundColor: theme.colors.lightGrey
28094
+ }
28095
+ });
28096
+ });
28097
+ /* eslint-disable-next-line react/display-name */
28098
+
28099
+ var Switch = /*#__PURE__*/React__default['default'].forwardRef(function (_a, ref) {
28100
+ var children = _a.children,
28101
+ rest = __rest(_a, ["children"]);
28102
+
28103
+ return /*#__PURE__*/React__default['default'].createElement(SwitchButton, Object.assign({}, rest, {
28104
+ ref: ref
28105
+ }), children);
28106
+ });
28107
+ Switch.propTypes = {
28108
+ children: PropTypes__default['default'].node,
28109
+ selected: PropTypes__default['default'].bool,
28110
+ value: PropTypes__default['default'].oneOfType([PropTypes__default['default'].string, PropTypes__default['default'].number, PropTypes__default['default'].array])
28111
+ };
28112
+
28049
28113
  var getHoverBackground = function getHoverBackground(currentPage, disabled, theme) {
28050
28114
  if (currentPage) {
28051
28115
  return theme.colors.darkBlue;
@@ -43848,8 +43912,9 @@
43848
43912
  width: "240px",
43849
43913
  height: "24px",
43850
43914
  viewBox: "0 0 100 10",
43851
- preserveAspectRatio: "xMidYMid"
43852
- }, /*#__PURE__*/React__default['default'].createElement("g", {
43915
+ preserveAspectRatio: "xMidYMid",
43916
+ role: "img"
43917
+ }, /*#__PURE__*/React__default['default'].createElement("title", null, "Loading animation"), /*#__PURE__*/React__default['default'].createElement("g", {
43853
43918
  transform: "translate(4 5)"
43854
43919
  }, /*#__PURE__*/React__default['default'].createElement("circle", {
43855
43920
  cx: "0",
@@ -52788,6 +52853,8 @@
52788
52853
  exports.Sidebar = Sidebar;
52789
52854
  exports.SortingTable = SortingTable;
52790
52855
  exports.StatusIndicator = StatusIndicator;
52856
+ exports.Switch = Switch;
52857
+ exports.Switcher = Switcher;
52791
52858
  exports.Tab = Tab;
52792
52859
  exports.Table = Table;
52793
52860
  exports.Tabs = Tabs;
@@ -16177,7 +16177,7 @@ var IconicButton = /*#__PURE__*/React__default.forwardRef(function (_a, forwarde
16177
16177
 
16178
16178
  return /*#__PURE__*/React__default.createElement(WrapperButton$1, Object.assign({
16179
16179
  ref: forwardedRef,
16180
- "aria-label": children,
16180
+ "aria-label": props["aria-label"] ? props["aria-label"] : typeof children === "string" ? children : undefined,
16181
16181
  className: className
16182
16182
  }, props), /*#__PURE__*/React__default.createElement(Manager$2, null, /*#__PURE__*/React__default.createElement(Reference$2, null, function (_ref4) {
16183
16183
  var ref = _ref4.ref;
@@ -24501,7 +24501,7 @@ var Slider = styled.span.withConfig({
24501
24501
  }
24502
24502
  };
24503
24503
  });
24504
- var Switch = styled.div.withConfig({
24504
+ var Switch$1 = styled.div.withConfig({
24505
24505
  displayName: "ToggleButton__Switch",
24506
24506
  componentId: "t7wo9n-1"
24507
24507
  })(function (_ref2) {
@@ -24550,7 +24550,7 @@ var ToggleButton = /*#__PURE__*/React__default.forwardRef(function (props, ref)
24550
24550
  }
24551
24551
  };
24552
24552
 
24553
- return /*#__PURE__*/React__default.createElement(Switch, {
24553
+ return /*#__PURE__*/React__default.createElement(Switch$1, {
24554
24554
  onClick: handleClick
24555
24555
  }, /*#__PURE__*/React__default.createElement(ToggleInput, Object.assign({
24556
24556
  ref: inputRef,
@@ -27468,6 +27468,55 @@ Tab.defaultProps = {
27468
27468
  label: null
27469
27469
  };
27470
27470
 
27471
+ var FocusManager = function FocusManager(_ref) {
27472
+ var children = _ref.children,
27473
+ _ref$refs = _ref.refs,
27474
+ refs = _ref$refs === void 0 ? undefined : _ref$refs;
27475
+
27476
+ var _useState = useState(0),
27477
+ focusedIndex = _useState[0],
27478
+ setFocusedIndex = _useState[1];
27479
+
27480
+ var focusPrevious = function focusPrevious() {
27481
+ setFocusedIndex(function (prevFocusedIndex) {
27482
+ return (prevFocusedIndex - 1 + refs.length) % refs.length;
27483
+ });
27484
+ };
27485
+
27486
+ var focusNext = function focusNext() {
27487
+ setFocusedIndex(function (prevFocusedIndex) {
27488
+ return (prevFocusedIndex + 1) % refs.length;
27489
+ });
27490
+ };
27491
+
27492
+ var handleArrowNavigation = function handleArrowNavigation(e) {
27493
+ switch (e.key) {
27494
+ case "ArrowLeft":
27495
+ e.preventDefault();
27496
+ focusPrevious();
27497
+ break;
27498
+
27499
+ case "ArrowRight":
27500
+ e.preventDefault();
27501
+ focusNext();
27502
+ break;
27503
+ }
27504
+ };
27505
+
27506
+ useEffect(function () {
27507
+ var updateFocused = function updateFocused() {
27508
+ refs[focusedIndex].focus();
27509
+ };
27510
+
27511
+ updateFocused();
27512
+ }, [focusedIndex, refs]);
27513
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, children({
27514
+ focusedIndex: focusedIndex,
27515
+ setFocusedIndex: setFocusedIndex,
27516
+ handleArrowNavigation: handleArrowNavigation
27517
+ }));
27518
+ };
27519
+
27471
27520
  var TabContainer = styled(Box).withConfig({
27472
27521
  displayName: "TabContainer",
27473
27522
  componentId: "sc-1esq49v-0"
@@ -27496,94 +27545,6 @@ var TabContainer = styled(Box).withConfig({
27496
27545
  };
27497
27546
  });
27498
27547
 
27499
- var TabFocusManager = /*#__PURE__*/function (_React$Component) {
27500
- _inheritsLoose$2(TabFocusManager, _React$Component);
27501
-
27502
- function TabFocusManager(props) {
27503
- var _this;
27504
-
27505
- _this = _React$Component.call(this, props) || this;
27506
- _this.state = {
27507
- focusedIndex: 0
27508
- };
27509
- _this.handleArrowNavigation = _this.handleArrowNavigation.bind(_assertThisInitialized$4(_this));
27510
- _this.focusNextTab = _this.focusNextTab.bind(_assertThisInitialized$4(_this));
27511
- _this.focusPreviousTab = _this.focusPreviousTab.bind(_assertThisInitialized$4(_this));
27512
- _this.setFocusToTab = _this.setFocusToTab.bind(_assertThisInitialized$4(_this));
27513
- return _this;
27514
- }
27515
-
27516
- var _proto = TabFocusManager.prototype;
27517
-
27518
- _proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
27519
- var focusedIndex = this.state.focusedIndex;
27520
-
27521
- if (prevState.focusedIndex !== focusedIndex) {
27522
- this.updateFocusedTab();
27523
- }
27524
- };
27525
-
27526
- _proto.setFocusToTab = function setFocusToTab(index) {
27527
- this.setState({
27528
- focusedIndex: index
27529
- });
27530
- };
27531
-
27532
- _proto.handleArrowNavigation = function handleArrowNavigation(e) {
27533
- switch (e.key) {
27534
- case "ArrowLeft":
27535
- e.preventDefault();
27536
- this.focusPreviousTab();
27537
- break;
27538
-
27539
- case "ArrowRight":
27540
- e.preventDefault();
27541
- this.focusNextTab();
27542
- break;
27543
- }
27544
- };
27545
-
27546
- _proto.focusNextTab = function focusNextTab() {
27547
- var tabRefs = this.props.tabRefs;
27548
- this.setState(function (prevState) {
27549
- return {
27550
- focusedIndex: (prevState.focusedIndex + 1) % tabRefs.length
27551
- };
27552
- });
27553
- };
27554
-
27555
- _proto.focusPreviousTab = function focusPreviousTab() {
27556
- var tabRefs = this.props.tabRefs;
27557
- this.setState(function (prevState) {
27558
- return {
27559
- focusedIndex: (prevState.focusedIndex - 1 + tabRefs.length) % tabRefs.length
27560
- };
27561
- });
27562
- };
27563
-
27564
- _proto.updateFocusedTab = function updateFocusedTab() {
27565
- var tabRefs = this.props.tabRefs;
27566
- var focusedIndex = this.state.focusedIndex;
27567
- tabRefs[focusedIndex].focus();
27568
- };
27569
-
27570
- _proto.render = function render() {
27571
- var focusedIndex = this.state.focusedIndex;
27572
- var children = this.props.children;
27573
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, children({
27574
- focusedIndex: focusedIndex,
27575
- handleArrowNavigation: this.handleArrowNavigation,
27576
- setFocusToTab: this.setFocusToTab
27577
- }));
27578
- };
27579
-
27580
- return TabFocusManager;
27581
- }(React__default.Component);
27582
-
27583
- TabFocusManager.defaultProps = {
27584
- tabRefs: undefined
27585
- };
27586
-
27587
27548
  var TabScrollIndicatorButton = styled.button.withConfig({
27588
27549
  displayName: "TabScrollIndicator__TabScrollIndicatorButton",
27589
27550
  componentId: "sc-91z16z-0"
@@ -27982,12 +27943,12 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
27982
27943
  var spaceProps = getSubset(this.props, propTypes.space);
27983
27944
  return /*#__PURE__*/React__default.createElement(Box, {
27984
27945
  position: "relative"
27985
- }, /*#__PURE__*/React__default.createElement(TabFocusManager, {
27986
- tabRefs: this.tabRefs
27946
+ }, /*#__PURE__*/React__default.createElement(FocusManager, {
27947
+ refs: this.tabRefs
27987
27948
  }, function (_ref2) {
27988
- var handleArrowNavigation = _ref2.handleArrowNavigation,
27989
- setFocusToTab = _ref2.setFocusToTab,
27990
- focusedIndex = _ref2.focusedIndex;
27949
+ var focusedIndex = _ref2.focusedIndex,
27950
+ setFocusedIndex = _ref2.setFocusedIndex,
27951
+ handleArrowNavigation = _ref2.handleArrowNavigation;
27991
27952
  return /*#__PURE__*/React__default.createElement(TabScrollIndicators, {
27992
27953
  tabRefs: _this3.tabRefs,
27993
27954
  tabContainerRef: _this3.tabContainerRef
@@ -28002,7 +27963,7 @@ var Tabs = /*#__PURE__*/function (_React$Component) {
28002
27963
  }, spaceProps), /*#__PURE__*/React__default.createElement(ResizeDetector, {
28003
27964
  handleWidth: true,
28004
27965
  onResize: handleResize
28005
- }), _this3.getTabs(setFocusToTab, focusedIndex, handleArrowNavigation));
27966
+ }), _this3.getTabs(setFocusedIndex, focusedIndex, handleArrowNavigation));
28006
27967
  });
28007
27968
  }), this.getTabContent());
28008
27969
  };
@@ -28020,6 +27981,109 @@ Tabs.defaultProps = {
28020
27981
  onTabClick: undefined
28021
27982
  };
28022
27983
 
27984
+ var Switcher = function Switcher(_a) {
27985
+ var selected = _a.selected,
27986
+ onChange = _a.onChange,
27987
+ rest = __rest(_a, ["selected", "onChange"]);
27988
+
27989
+ var optionRefs = [];
27990
+
27991
+ var isSelected = function isSelected(value, index) {
27992
+ if (!selected) return index === 0;
27993
+ return value === selected;
27994
+ };
27995
+
27996
+ var options = function options(focusedIndex, setFocusedIndex, handleArrowNavigation) {
27997
+ return React__default.Children.map(rest.children, function (child, index) {
27998
+ return /*#__PURE__*/React__default.cloneElement(child, {
27999
+ index: index,
28000
+ tabIndex: index === focusedIndex ? 0 : -1,
28001
+ selected: isSelected(child.props.value, index),
28002
+ "aria-selected": isSelected(child.props.value, index),
28003
+ onKeyDown: handleArrowNavigation,
28004
+ ref: function ref(_ref) {
28005
+ optionRefs[index] = _ref;
28006
+ },
28007
+ onFocus: function onFocus(e) {
28008
+ e.stopPropagation();
28009
+ },
28010
+ onClick: function onClick() {
28011
+ setFocusedIndex(index);
28012
+ if (onChange) onChange(child.props.value);
28013
+ }
28014
+ });
28015
+ });
28016
+ };
28017
+
28018
+ return /*#__PURE__*/React__default.createElement(Box, Object.assign({
28019
+ display: "inline-flex",
28020
+ bg: "whiteGrey",
28021
+ borderRadius: "20px"
28022
+ }, rest), /*#__PURE__*/React__default.createElement(FocusManager, {
28023
+ refs: optionRefs
28024
+ }, function (_ref2) {
28025
+ var focusedIndex = _ref2.focusedIndex,
28026
+ setFocusedIndex = _ref2.setFocusedIndex,
28027
+ handleArrowNavigation = _ref2.handleArrowNavigation;
28028
+ return options(focusedIndex, setFocusedIndex, handleArrowNavigation);
28029
+ }));
28030
+ };
28031
+
28032
+ Switcher.propTypes = {
28033
+ children: PropTypes.node,
28034
+ selected: PropTypes.string,
28035
+ onChange: PropTypes.func
28036
+ };
28037
+
28038
+ var SwitchButton = styled.button.withConfig({
28039
+ displayName: "Switch__SwitchButton",
28040
+ componentId: "wsu5uq-0"
28041
+ })(function (_ref) {
28042
+ var selected = _ref.selected,
28043
+ theme = _ref.theme;
28044
+ return Object.assign(Object.assign(Object.assign({
28045
+ height: theme.space.x4,
28046
+ margin: 1,
28047
+ padding: theme.space.half + " " + theme.space.x2,
28048
+ background: selected ? theme.colors.white : "none",
28049
+ color: selected ? theme.colors.darkBlue : theme.colors.darkGrey,
28050
+ cursor: "pointer",
28051
+ border: "none",
28052
+ borderRadius: 20,
28053
+ fontSize: theme.fontSizes.medium,
28054
+ fontWeight: theme.fontWeights.medium,
28055
+ lineHeight: theme.lineHeights.base,
28056
+ textDecoration: "none",
28057
+ whiteSpace: "nowrap"
28058
+ }, selected && {
28059
+ boxShadow: theme.shadows.small
28060
+ }), {
28061
+ "&:focus": {
28062
+ outline: "none",
28063
+ boxShadow: theme.shadows.focus
28064
+ }
28065
+ }), !selected && {
28066
+ "&:hover": {
28067
+ backgroundColor: theme.colors.lightGrey
28068
+ }
28069
+ });
28070
+ });
28071
+ /* eslint-disable-next-line react/display-name */
28072
+
28073
+ var Switch = /*#__PURE__*/React__default.forwardRef(function (_a, ref) {
28074
+ var children = _a.children,
28075
+ rest = __rest(_a, ["children"]);
28076
+
28077
+ return /*#__PURE__*/React__default.createElement(SwitchButton, Object.assign({}, rest, {
28078
+ ref: ref
28079
+ }), children);
28080
+ });
28081
+ Switch.propTypes = {
28082
+ children: PropTypes.node,
28083
+ selected: PropTypes.bool,
28084
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array])
28085
+ };
28086
+
28023
28087
  var getHoverBackground = function getHoverBackground(currentPage, disabled, theme) {
28024
28088
  if (currentPage) {
28025
28089
  return theme.colors.darkBlue;
@@ -43822,8 +43886,9 @@ var LoadingAnimation = function LoadingAnimation(_ref) {
43822
43886
  width: "240px",
43823
43887
  height: "24px",
43824
43888
  viewBox: "0 0 100 10",
43825
- preserveAspectRatio: "xMidYMid"
43826
- }, /*#__PURE__*/React__default.createElement("g", {
43889
+ preserveAspectRatio: "xMidYMid",
43890
+ role: "img"
43891
+ }, /*#__PURE__*/React__default.createElement("title", null, "Loading animation"), /*#__PURE__*/React__default.createElement("g", {
43827
43892
  transform: "translate(4 5)"
43828
43893
  }, /*#__PURE__*/React__default.createElement("circle", {
43829
43894
  cx: "0",
@@ -52694,4 +52759,4 @@ var SortingTable = function SortingTable(_a) {
52694
52759
  }, props));
52695
52760
  };
52696
52761
 
52697
- export { ALL_NDS_LOCALES, Alert, AnimatedBox, ApplicationFrame, AsyncSelect, Box, NavBar as BrandedNavBar, Branding, Breadcrumbs, Button, ButtonGroup, Card, CardSet, Checkbox, CheckboxGroup, ControlIcon, DangerButton, DatePicker, DateRange, Divider, DropdownButton, DropdownItem, DropdownLink, DropdownMenu, Field, FieldLabel, Fieldset, Flex, Form, FormSection, Heading1, Heading2, Heading3, Heading4, HelpText, Icon, IconicButton, InlineIcon, InlineValidation, Input$1 as Input, Link, List, ListItem, LoadingAnimation, Modal, NDSProvider, NavBar$1 as NavBar, Overlay, Page, Pagination, PrimaryButton, QuietButton, Radio, RadioGroup, RangeContainer, RequirementText, ReactSelect as Select, SelectClearIndicator, SelectContainer$1 as SelectContainer, SelectControl, SelectDropdownIndicator, SelectInput, SelectMenu, SelectMultiValue, SelectOption, Sidebar, SortingTable, StatusIndicator, Tab, Table, Tabs, Text, Textarea, TimePicker, TimeRange, Toast, ToggleComponent as Toggle, Tooltip, TruncatedText, Theme as theme, useWindowDimensions };
52762
+ export { ALL_NDS_LOCALES, Alert, AnimatedBox, ApplicationFrame, AsyncSelect, Box, NavBar as BrandedNavBar, Branding, Breadcrumbs, Button, ButtonGroup, Card, CardSet, Checkbox, CheckboxGroup, ControlIcon, DangerButton, DatePicker, DateRange, Divider, DropdownButton, DropdownItem, DropdownLink, DropdownMenu, Field, FieldLabel, Fieldset, Flex, Form, FormSection, Heading1, Heading2, Heading3, Heading4, HelpText, Icon, IconicButton, InlineIcon, InlineValidation, Input$1 as Input, Link, List, ListItem, LoadingAnimation, Modal, NDSProvider, NavBar$1 as NavBar, Overlay, Page, Pagination, PrimaryButton, QuietButton, Radio, RadioGroup, RangeContainer, RequirementText, ReactSelect as Select, SelectClearIndicator, SelectContainer$1 as SelectContainer, SelectControl, SelectDropdownIndicator, SelectInput, SelectMenu, SelectMultiValue, SelectOption, Sidebar, SortingTable, StatusIndicator, Switch, Switcher, Tab, Table, Tabs, Text, Textarea, TimePicker, TimeRange, Toast, ToggleComponent as Toggle, Tooltip, TruncatedText, Theme as theme, useWindowDimensions };
@@ -58,3 +58,9 @@ export declare const WithACustomFontSize: {
58
58
  name: string;
59
59
  };
60
60
  };
61
+ export declare const WithNonTextChildren: {
62
+ (): JSX.Element;
63
+ story: {
64
+ name: string;
65
+ };
66
+ };
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ declare type SwitchProps = {
3
+ selected?: boolean;
4
+ } & React.ComponentPropsWithRef<"button">;
5
+ declare const Switch: React.ForwardRefExoticComponent<Pick<SwitchProps, "form" | "slot" | "style" | "title" | "key" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "type" | "value" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "selected"> & React.RefAttributes<HTMLButtonElement>>;
6
+ export default Switch;
@@ -0,0 +1,23 @@
1
+ /// <reference types="react" />
2
+ declare const _default: {
3
+ title: string;
4
+ };
5
+ export default _default;
6
+ export declare const _Switch: {
7
+ (): JSX.Element;
8
+ story: {
9
+ name: string;
10
+ };
11
+ };
12
+ export declare const SelectedSwitch: {
13
+ (): JSX.Element;
14
+ story: {
15
+ name: string;
16
+ };
17
+ };
18
+ export declare const UnSelectedSwitch: {
19
+ (): JSX.Element;
20
+ story: {
21
+ name: string;
22
+ };
23
+ };
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ declare type SwitchValue = HTMLButtonElement["value"];
3
+ declare type SwitcherProps = {
4
+ children?: any;
5
+ selected?: SwitchValue;
6
+ onChange?: Function;
7
+ };
8
+ declare const Switcher: React.FC<SwitcherProps>;
9
+ export default Switcher;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export declare const WithSelectedValue: () => JSX.Element;
3
+ export declare const WithContent: () => JSX.Element;
4
+ declare const _default: {
5
+ title: string;
6
+ };
7
+ export default _default;
@@ -0,0 +1,2 @@
1
+ export { default as Switcher } from "./Switcher";
2
+ export { default as Switch } from "./Switch";
@@ -1,5 +1,4 @@
1
1
  export { default as Tab } from "./Tab";
2
2
  export { default as Tabs } from "./Tabs";
3
- export { default as TabFocusManager } from "./TabFocusManager";
4
3
  export { default as TabScrollIndicator } from "./TabScrollIndicator";
5
4
  export { default as TabScrollIndicators } from "./TabScrollIndicators";
@@ -26,6 +26,7 @@ export { Tooltip } from "./Tooltip";
26
26
  export { Card, CardSet } from "./Card";
27
27
  export { Modal } from "./Modal";
28
28
  export { Tab, Tabs } from "./Tabs";
29
+ export { Switch, Switcher } from "./Switcher";
29
30
  export { Table } from "./Table";
30
31
  export type { TableProps, TableColumnType, TableRowType, TableCellInfoType, } from "./Table";
31
32
  export { StatusIndicator } from "./StatusIndicator";
@@ -0,0 +1,16 @@
1
+ import React, { ReactNode } from "react";
2
+ declare type Reference = {
3
+ current?: JSX.Element;
4
+ focus?: (...args: any[]) => any;
5
+ };
6
+ declare type ChildrenHandlers = {
7
+ focusedIndex: number;
8
+ handleArrowNavigation: Function;
9
+ setFocusedIndex: Function;
10
+ };
11
+ declare type FocusManagerProps = {
12
+ refs?: Array<Reference>;
13
+ children: (handlers: ChildrenHandlers) => ReactNode;
14
+ };
15
+ declare const FocusManager: React.FC<FocusManagerProps>;
16
+ export default FocusManager;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nulogy/components",
3
- "version": "6.5.0",
3
+ "version": "6.6.2",
4
4
  "description": "Component library for the Nulogy Design System - http://nulogy.design",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -1,27 +0,0 @@
1
- import React from "react";
2
- declare type TabFocusManagerProps = {
3
- tabRefs?: {
4
- current?: JSX.Element;
5
- focus?: (...args: any[]) => any;
6
- }[];
7
- };
8
- declare type TabFocusManagerState = {
9
- focusedIndex: any;
10
- } & ((prevState: any) => {
11
- focusedIndex: number;
12
- }) & ((prevState: any) => {
13
- focusedIndex: number;
14
- }) & {
15
- focusedIndex: number;
16
- };
17
- declare class TabFocusManager extends React.Component<TabFocusManagerProps, TabFocusManagerState> {
18
- constructor(props: any);
19
- componentDidUpdate(prevProps: any, prevState: any): void;
20
- setFocusToTab(index: any): void;
21
- handleArrowNavigation(e: any): void;
22
- focusNextTab(): void;
23
- focusPreviousTab(): void;
24
- updateFocusedTab(): void;
25
- render(): JSX.Element;
26
- }
27
- export default TabFocusManager;