@semcore/pills 4.4.24 → 4.6.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/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
+ ## [4.6.0] - 2023-05-24
6
+
7
+ ### Added
8
+
9
+ - Added `behavior` prop for better accessability in forms. Props takes value `tabs` and `radio`, `tabs` is a default value and correspond to the old component behavior.
10
+
11
+ ## [4.5.0] - 2023-05-22
12
+
13
+ ### Changed
14
+
15
+ - Updated token for `selected` Pill.
16
+
5
17
  ## [4.4.24] - 2023-05-11
6
18
 
7
19
  ### Changed
package/lib/cjs/Pills.js CHANGED
@@ -20,19 +20,19 @@ var _neighborLocation = _interopRequireWildcard(require("@semcore/neighbor-locat
20
20
  var _keyboardFocusEnhance = _interopRequireDefault(require("@semcore/utils/lib/enhances/keyboardFocusEnhance"));
21
21
  var _addonTextChildren = _interopRequireDefault(require("@semcore/utils/lib/addonTextChildren"));
22
22
  /*__reshadow-styles__:"./style/pills.shadow.css"*/
23
- var style = ( /*__reshadow_css_start__*/_core.sstyled.insert( /*__inner_css_start__*/".___SPill_myxr9_gg_,.___SPills_myxr9_gg_{display:inline-flex;align-items:center;justify-content:center}.___SPills_myxr9_gg_{isolation:isolate}.___SPill_myxr9_gg_{line-height:normal;position:relative;touch-action:manipulation;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;user-select:none;box-sizing:border-box;padding:0;margin:0;box-shadow:none;text-decoration:none;-webkit-tap-highlight-color:transparent;overflow:visible;outline:0;text-align:center;vertical-align:middle;font-family:inherit;cursor:pointer;background:var(--intergalactic-bg-primary-neutral, #ffffff);border:1px solid var(--intergalactic-border-primary, #c4c7cf);border-radius:var(--intergalactic-control-rounded, 6px)}.___SPill_myxr9_gg_::-moz-focus-inner{border:0;padding:0}.___SPill_myxr9_gg_:active,.___SPill_myxr9_gg_:focus{outline:0;text-decoration:none}@media (hover:hover){.___SPill_myxr9_gg_:hover{outline:0;text-decoration:none;background:var(--intergalactic-bg-primary-neutral-hover, #f4f5f9)}}.___SPill_myxr9_gg_.__selected_myxr9_gg_{background:var(--intergalactic-control-secondary-info-hover, rgba(0, 143, 248, 0.2));border-color:var(--intergalactic-border-info-active, #006dca);z-index:1}.___SPill_myxr9_gg_.__disabled_myxr9_gg_{cursor:default;pointer-events:none}.___SPill_myxr9_gg_.__disabled_myxr9_gg_>*{opacity:var(--intergalactic-disabled-opacity, 0.3)}.___SPill_myxr9_gg_.__keyboardFocused_myxr9_gg_{box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.3))}.___SText_myxr9_gg_{color:var(--intergalactic-text-primary, #191b23);display:inline-flex}.___SAddon_myxr9_gg_{color:var(--intergalactic-text-secondary, #6c6e79);display:inline-flex;align-items:center;justify-content:center}.___SPill_myxr9_gg_._size_m_myxr9_gg_{height:var(--intergalactic-form-control-m, 28px);min-width:var(--intergalactic-form-control-m, 28px);font-size:var(--intergalactic-fs-200, 14px)}.___SPill_myxr9_gg_._size_l_myxr9_gg_ .___SText_myxr9_gg_,.___SPill_myxr9_gg_._size_m_myxr9_gg_ .___SText_myxr9_gg_{margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_myxr9_gg_._size_m_myxr9_gg_ .___SAddon_myxr9_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x, 8px)}.___SPill_myxr9_gg_._size_m_myxr9_gg_ .___SAddon_myxr9_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_myxr9_gg_._size_m_myxr9_gg_ .___SAddon_myxr9_gg_:only-child{margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_myxr9_gg_._size_l_myxr9_gg_{height:var(--intergalactic-form-control-l, 40px);min-width:var(--intergalactic-form-control-l, 40px);font-size:var(--intergalactic-fs-300, 16px)}.___SPill_myxr9_gg_._size_l_myxr9_gg_ .___SAddon_myxr9_gg_:only-child,.___SPill_myxr9_gg_._size_l_myxr9_gg_ .___SText_myxr9_gg_:only-child{margin-left:var(--intergalactic-spacing-3x, 12px);margin-right:var(--intergalactic-spacing-3x, 12px)}.___SPill_myxr9_gg_._size_l_myxr9_gg_ .___SAddon_myxr9_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-3x, 12px)}.___SPill_myxr9_gg_._size_l_myxr9_gg_ .___SAddon_myxr9_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-3x, 12px)}.___SPill_myxr9_gg_._neighborLocation_right_myxr9_gg_{border-top-right-radius:0;border-bottom-right-radius:0}.___SPill_myxr9_gg_._neighborLocation_both_myxr9_gg_{border-radius:0;margin-left:-1px}.___SPill_myxr9_gg_._neighborLocation_left_myxr9_gg_{border-top-left-radius:0;border-bottom-left-radius:0;margin-left:-1px}" /*__inner_css_end__*/, "myxr9_gg_") /*__reshadow_css_end__*/, {
24
- "__SPills": "___SPills_myxr9_gg_",
25
- "__SPill": "___SPill_myxr9_gg_",
26
- "_selected": "__selected_myxr9_gg_",
27
- "_disabled": "__disabled_myxr9_gg_",
28
- "_keyboardFocused": "__keyboardFocused_myxr9_gg_",
29
- "__SText": "___SText_myxr9_gg_",
30
- "__SAddon": "___SAddon_myxr9_gg_",
31
- "_size_m": "_size_m_myxr9_gg_",
32
- "_size_l": "_size_l_myxr9_gg_",
33
- "_neighborLocation_right": "_neighborLocation_right_myxr9_gg_",
34
- "_neighborLocation_both": "_neighborLocation_both_myxr9_gg_",
35
- "_neighborLocation_left": "_neighborLocation_left_myxr9_gg_"
23
+ var style = ( /*__reshadow_css_start__*/_core.sstyled.insert( /*__inner_css_start__*/".___SPill_17bl9_gg_,.___SPills_17bl9_gg_{display:inline-flex;align-items:center;justify-content:center;outline:0}.___SPills_17bl9_gg_{isolation:isolate}.___SPill_17bl9_gg_{line-height:normal;position:relative;touch-action:manipulation;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;user-select:none;box-sizing:border-box;padding:0;margin:0;box-shadow:none;text-decoration:none;-webkit-tap-highlight-color:transparent;overflow:visible;text-align:center;vertical-align:middle;font-family:inherit;cursor:pointer;background:var(--intergalactic-bg-primary-neutral, #ffffff);border:1px solid var(--intergalactic-border-primary, #c4c7cf);border-radius:var(--intergalactic-control-rounded, 6px)}.___SPill_17bl9_gg_::-moz-focus-inner{border:0;padding:0}.___SPill_17bl9_gg_:active,.___SPill_17bl9_gg_:focus{outline:0;text-decoration:none}@media (hover:hover){.___SPill_17bl9_gg_:hover{outline:0;text-decoration:none;background:var(--intergalactic-bg-primary-neutral-hover, #f4f5f9)}}.___SPill_17bl9_gg_.__selected_17bl9_gg_{background:var(--intergalactic-control-secondary-info, rgba(0, 143, 248, 0.1));border-color:var(--intergalactic-border-info-active, #006dca);z-index:1}.___SPill_17bl9_gg_.__disabled_17bl9_gg_{cursor:default;pointer-events:none}.___SPill_17bl9_gg_.__disabled_17bl9_gg_>*{opacity:var(--intergalactic-disabled-opacity, 0.3)}.___SPill_17bl9_gg_.__keyboardFocused_17bl9_gg_,.___SPills_17bl9_gg_.__keyboardFocused_17bl9_gg_{box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.5))}.___SText_17bl9_gg_{color:var(--intergalactic-text-primary, #191b23);display:inline-flex}.___SAddon_17bl9_gg_{color:var(--intergalactic-text-secondary, #6c6e79);display:inline-flex;align-items:center;justify-content:center}.___SPill_17bl9_gg_._size_m_17bl9_gg_{height:var(--intergalactic-form-control-m, 28px);min-width:var(--intergalactic-form-control-m, 28px);font-size:var(--intergalactic-fs-200, 14px)}.___SPill_17bl9_gg_._size_l_17bl9_gg_ .___SText_17bl9_gg_,.___SPill_17bl9_gg_._size_m_17bl9_gg_ .___SText_17bl9_gg_{margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_17bl9_gg_._size_m_17bl9_gg_ .___SAddon_17bl9_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x, 8px)}.___SPill_17bl9_gg_._size_m_17bl9_gg_ .___SAddon_17bl9_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_17bl9_gg_._size_m_17bl9_gg_ .___SAddon_17bl9_gg_:only-child{margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_17bl9_gg_._size_l_17bl9_gg_{height:var(--intergalactic-form-control-l, 40px);min-width:var(--intergalactic-form-control-l, 40px);font-size:var(--intergalactic-fs-300, 16px)}.___SPill_17bl9_gg_._size_l_17bl9_gg_ .___SAddon_17bl9_gg_:only-child,.___SPill_17bl9_gg_._size_l_17bl9_gg_ .___SText_17bl9_gg_:only-child{margin-left:var(--intergalactic-spacing-3x, 12px);margin-right:var(--intergalactic-spacing-3x, 12px)}.___SPill_17bl9_gg_._size_l_17bl9_gg_ .___SAddon_17bl9_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-3x, 12px)}.___SPill_17bl9_gg_._size_l_17bl9_gg_ .___SAddon_17bl9_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-3x, 12px)}.___SPill_17bl9_gg_._neighborLocation_right_17bl9_gg_{border-top-right-radius:0;border-bottom-right-radius:0}.___SPill_17bl9_gg_._neighborLocation_both_17bl9_gg_{border-radius:0;margin-left:-1px}.___SPill_17bl9_gg_._neighborLocation_left_17bl9_gg_{border-top-left-radius:0;border-bottom-left-radius:0;margin-left:-1px}" /*__inner_css_end__*/, "17bl9_gg_") /*__reshadow_css_end__*/, {
24
+ "__SPills": "___SPills_17bl9_gg_",
25
+ "__SPill": "___SPill_17bl9_gg_",
26
+ "_selected": "__selected_17bl9_gg_",
27
+ "_disabled": "__disabled_17bl9_gg_",
28
+ "_keyboardFocused": "__keyboardFocused_17bl9_gg_",
29
+ "__SText": "___SText_17bl9_gg_",
30
+ "__SAddon": "___SAddon_17bl9_gg_",
31
+ "_size_m": "_size_m_17bl9_gg_",
32
+ "_size_l": "_size_l_17bl9_gg_",
33
+ "_neighborLocation_right": "_neighborLocation_right_17bl9_gg_",
34
+ "_neighborLocation_both": "_neighborLocation_both_17bl9_gg_",
35
+ "_neighborLocation_left": "_neighborLocation_left_17bl9_gg_"
36
36
  });
37
37
  var RootPills = /*#__PURE__*/function (_Component) {
38
38
  (0, _inherits2["default"])(RootPills, _Component);
@@ -45,21 +45,33 @@ var RootPills = /*#__PURE__*/function (_Component) {
45
45
  }
46
46
  _this = _super.call.apply(_super, [this].concat(args));
47
47
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "itemRefs", []);
48
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "itemValues", []);
48
49
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "bindHandlerClick", function (value) {
49
50
  return function (e) {
50
51
  _this.handlers.value(value, e);
51
52
  };
52
53
  });
53
54
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleKeyDown", function (event) {
54
- var _this$itemRefs$focuse;
55
- if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') return;
56
- var focusedIndex = _this.itemRefs.findIndex(function (item) {
57
- return item === document.activeElement;
58
- });
59
- if (focusedIndex === -1) return;
60
- if (event.key === 'ArrowLeft') focusedIndex--;
61
- if (event.key === 'ArrowRight') focusedIndex++;
62
- (_this$itemRefs$focuse = _this.itemRefs[focusedIndex]) === null || _this$itemRefs$focuse === void 0 ? void 0 : _this$itemRefs$focuse.focus();
55
+ if (event.code !== 'ArrowLeft' && event.code !== 'ArrowRight') return;
56
+ if (_this.asProps.behavior === 'radio') {
57
+ var selectedIndex = _this.itemValues.findIndex(function (value) {
58
+ return value === _this.asProps.value;
59
+ });
60
+ if (selectedIndex === -1) return;
61
+ if (event.code === 'ArrowLeft') selectedIndex--;
62
+ if (event.code === 'ArrowRight') selectedIndex++;
63
+ if (selectedIndex < 0 || selectedIndex >= _this.itemValues.length) return;
64
+ _this.handlers.value(_this.itemValues[selectedIndex], event);
65
+ } else {
66
+ var _this$itemRefs$focuse;
67
+ var focusedIndex = _this.itemRefs.findIndex(function (item) {
68
+ return item === document.activeElement;
69
+ });
70
+ if (focusedIndex === -1) return;
71
+ if (event.code === 'ArrowLeft') focusedIndex--;
72
+ if (event.code === 'ArrowRight') focusedIndex++;
73
+ (_this$itemRefs$focuse = _this.itemRefs[focusedIndex]) === null || _this$itemRefs$focuse === void 0 ? void 0 : _this$itemRefs$focuse.focus();
74
+ }
63
75
  });
64
76
  return _this;
65
77
  }
@@ -77,7 +89,9 @@ var RootPills = /*#__PURE__*/function (_Component) {
77
89
  var _this$asProps = this.asProps,
78
90
  value = _this$asProps.value,
79
91
  size = _this$asProps.size,
80
- disabled = _this$asProps.disabled;
92
+ disabled = _this$asProps.disabled,
93
+ behavior = _this$asProps.behavior;
94
+ this.itemValues[index] = props.value;
81
95
  return {
82
96
  ref: function ref(node) {
83
97
  return _this2.itemRefs[index] = node;
@@ -86,6 +100,8 @@ var RootPills = /*#__PURE__*/function (_Component) {
86
100
  size: size,
87
101
  disabled: disabled,
88
102
  selected: value === props.value,
103
+ behavior: behavior,
104
+ tabIndex: behavior === 'tabs' ? 0 : -1,
89
105
  onClick: this.bindHandlerClick(props.value)
90
106
  };
91
107
  }
@@ -99,9 +115,10 @@ var RootPills = /*#__PURE__*/function (_Component) {
99
115
  Children = _this$asProps2.Children,
100
116
  styles = _this$asProps2.styles,
101
117
  controlsLength = _this$asProps2.controlsLength,
102
- disabled = _this$asProps2.disabled;
118
+ disabled = _this$asProps2.disabled,
119
+ behavior = _this$asProps2.behavior;
103
120
  return _ref5 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SPills, _ref5.cn("SPills", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
104
- "role": "radiogroup",
121
+ "role": behavior === 'radio' ? 'radiogroup' : 'tablist',
105
122
  "aria-disabled": disabled,
106
123
  "onKeyDown": this.handleKeyDown
107
124
  }, _ref))), /*#__PURE__*/_react["default"].createElement(_neighborLocation["default"], _ref5.cn("NeighborLocation", {
@@ -113,10 +130,16 @@ var RootPills = /*#__PURE__*/function (_Component) {
113
130
  }(_core.Component);
114
131
  (0, _defineProperty2["default"])(RootPills, "displayName", 'Pills');
115
132
  (0, _defineProperty2["default"])(RootPills, "style", style);
116
- (0, _defineProperty2["default"])(RootPills, "defaultProps", {
117
- size: 'm',
118
- defaultValue: null
133
+ (0, _defineProperty2["default"])(RootPills, "defaultProps", function (_ref9) {
134
+ var behavior = _ref9.behavior;
135
+ return {
136
+ size: 'm',
137
+ defaultValue: null,
138
+ behavior: behavior !== null && behavior !== void 0 ? behavior : 'tabs',
139
+ tabIndex: behavior === 'tabs' ? -1 : 0
140
+ };
119
141
  });
142
+ (0, _defineProperty2["default"])(RootPills, "enhance", [(0, _keyboardFocusEnhance["default"])()]);
120
143
  function Pill(props) {
121
144
  var _ref2 = arguments[0],
122
145
  _ref6;
@@ -127,16 +150,24 @@ function Pill(props) {
127
150
  addonRight = props.addonRight,
128
151
  selected = props.selected,
129
152
  disabled = props.disabled,
130
- index = props.index;
153
+ index = props.index,
154
+ behavior = props.behavior;
131
155
  var neighborLocation = (0, _neighborLocation.useNeighborLocationDetect)(index);
132
- return _ref6 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SPill, _ref6.cn("SPill", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
133
- "tag": "button",
134
- "type": "button",
135
- "role": "radio",
156
+ var roleAreaProps = {};
157
+ if (behavior === 'radio') {
158
+ roleAreaProps.role = 'radio';
159
+ roleAreaProps['aria-checked'] = selected;
160
+ } else {
161
+ roleAreaProps.role = 'tab';
162
+ roleAreaProps['aria-selected'] = selected;
163
+ }
164
+ return _ref6 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SPill, _ref6.cn("SPill", (0, _objectSpread2["default"])({}, (0, _core.assignProps)((0, _objectSpread2["default"])({
165
+ "tag": 'button',
166
+ "type": 'button',
136
167
  "neighborLocation": neighborLocation,
137
- "aria-checked": selected,
138
- "aria-disabled": disabled
139
- }, _ref2))), addonLeft ? /*#__PURE__*/_react["default"].createElement(Pills.Item.Addon, {
168
+ "aria-disabled": disabled,
169
+ "aria-posinset": index + 1
170
+ }, roleAreaProps), _ref2))), addonLeft ? /*#__PURE__*/_react["default"].createElement(Pills.Item.Addon, {
140
171
  tag: addonLeft
141
172
  }) : null, (0, _addonTextChildren["default"])(Children, Pills.Item.Text, Pills.Item.Addon), addonRight ? /*#__PURE__*/_react["default"].createElement(Pills.Item.Addon, {
142
173
  tag: addonRight
@@ -148,7 +179,7 @@ function Text(props) {
148
179
  _ref7;
149
180
  var SText = _flexBox.Box;
150
181
  return _ref7 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SText, _ref7.cn("SText", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
151
- "tag": "span"
182
+ "tag": 'span'
152
183
  }, _ref3))));
153
184
  }
154
185
  function Addon(props) {
@@ -156,7 +187,7 @@ function Addon(props) {
156
187
  _ref8;
157
188
  var SAddon = _flexBox.Box;
158
189
  return _ref8 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref8.cn("SAddon", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
159
- "tag": "span"
190
+ "tag": 'span'
160
191
  }, _ref4))));
161
192
  }
162
193
  var Pills = (0, _core["default"])(RootPills, {
@@ -1 +1 @@
1
- {"version":3,"file":"Pills.js","names":["_core","_interopRequireWildcard","require","_react","_interopRequireDefault","_flexBox","_neighborLocation","_keyboardFocusEnhance","_addonTextChildren","style","sstyled","insert","RootPills","_Component","_inherits2","_super","_createSuper2","_this","_classCallCheck2","_len","arguments","length","args","Array","_key","call","apply","concat","_defineProperty2","_assertThisInitialized2","value","e","handlers","event","_this$itemRefs$focuse","key","focusedIndex","itemRefs","findIndex","item","document","activeElement","focus","_createClass2","uncontrolledProps","getItemProps","props","index","_this2","_this$asProps","asProps","size","disabled","ref","node","selected","onClick","bindHandlerClick","render","_ref","_ref5","SPills","Box","_this$asProps2","Children","styles","controlsLength","createElement","cn","_objectSpread2","assignProps","handleKeyDown","Component","defaultValue","Pill","_ref2","arguments[0]","_ref6","SPill","addonLeft","addonRight","neighborLocation","useNeighborLocationDetect","Pills","Item","Addon","tag","addonTextChildren","Text","enhance","keyboardFocusEnhance","_ref3","_ref7","SText","_ref4","_ref8","SAddon","createComponent","_default","exports"],"sources":["../../src/Pills.jsx"],"sourcesContent":["import React from 'react';\nimport createComponent, { Component, sstyled, Root } from '@semcore/core';\nimport { Box } from '@semcore/flex-box';\nimport NeighborLocation, { useNeighborLocationDetect } from '@semcore/neighbor-location';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport addonTextChildren from '@semcore/utils/lib/addonTextChildren';\n\nimport style from './style/pills.shadow.css';\n\nclass RootPills extends Component {\n static displayName = 'Pills';\n static style = style;\n static defaultProps = {\n size: 'm',\n defaultValue: null,\n };\n itemRefs = [];\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n bindHandlerClick = (value) => (e) => {\n this.handlers.value(value, e);\n };\n\n getItemProps(props, index) {\n const { value, size, disabled } = this.asProps;\n return {\n ref: (node) => (this.itemRefs[index] = node),\n index: index,\n size,\n disabled,\n selected: value === props.value,\n onClick: this.bindHandlerClick(props.value),\n };\n }\n\n handleKeyDown = (event) => {\n if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') return;\n\n let focusedIndex = this.itemRefs.findIndex((item) => item === document.activeElement);\n if (focusedIndex === -1) return;\n\n if (event.key === 'ArrowLeft') focusedIndex--;\n if (event.key === 'ArrowRight') focusedIndex++;\n\n this.itemRefs[focusedIndex]?.focus();\n };\n\n render() {\n const SPills = Root;\n const { Children, styles, controlsLength, disabled } = this.asProps;\n\n return sstyled(styles)(\n <SPills\n render={Box}\n role=\"radiogroup\"\n aria-disabled={disabled}\n onKeyDown={this.handleKeyDown}\n >\n <NeighborLocation controlsLength={controlsLength}>\n <Children />\n </NeighborLocation>\n </SPills>,\n );\n }\n}\n\nfunction Pill(props) {\n const SPill = Root;\n const { Children, styles, addonLeft, addonRight, selected, disabled, index } = props;\n const neighborLocation = useNeighborLocationDetect(index);\n return sstyled(styles)(\n <SPill\n render={Box}\n tag=\"button\"\n type=\"button\"\n role=\"radio\"\n neighborLocation={neighborLocation}\n aria-checked={selected}\n aria-disabled={disabled}\n >\n {addonLeft ? <Pills.Item.Addon tag={addonLeft} /> : null}\n {addonTextChildren(Children, Pills.Item.Text, Pills.Item.Addon)}\n {addonRight ? <Pills.Item.Addon tag={addonRight} /> : null}\n </SPill>,\n );\n}\n\nPill.enhance = [keyboardFocusEnhance()];\n\nfunction Text(props) {\n const SText = Root;\n return sstyled(props.styles)(<SText render={Box} tag=\"span\" />);\n}\n\nfunction Addon(props) {\n const SAddon = Root;\n return sstyled(props.styles)(<SAddon render={Box} tag=\"span\" />);\n}\n\nconst Pills = createComponent(RootPills, {\n Item: [Pill, { Text, Addon }],\n});\n\nexport default Pills;\n"],"mappings":";;;;;;;;;;;;;;;AACA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AADA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAL,uBAAA,CAAAC,OAAA;AACA,IAAAK,qBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,kBAAA,GAAAJ,sBAAA,CAAAF,OAAA;AAAqE;AAAA,IAAAO,KAAA,+BAAAT,KAAA,CAAAU,OAAA,CAAAC,MAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;E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iClC,YAAG;EAAhD,OAAAiC,KAAA,GAAO,IAAArF,aAAO,EAACoC,KAAK,CAACmB,MAAM,CAAC,eAAC9D,MAAA,YAAAgE,aAAA,CAAC6B,MAAM,EAAAD,KAAA,CAAA3B,EAAA,eAAAC,cAAA,qBAAArE,KAAA,CAAAsE,WAAA;IAAA,OAAkB;EAAM,GAAAwB,KAAA,IAAG;AACjE;AAEA,IAAMX,KAAK,GAAG,IAAAc,gBAAe,EAACrF,SAAS,EAAE;EACvCwE,IAAI,EAAE,CAACV,IAAI,EAAE;IAAEc,IAAI,EAAJA,IAAI;IAAEH,KAAK,EAALA;EAAM,CAAC;AAC9B,CAAC,CAAC;AAAC,IAAAa,QAAA,GAEYf,KAAK;AAAAgB,OAAA,cAAAD,QAAA"}
1
+ {"version":3,"file":"Pills.js","names":["_core","_interopRequireWildcard","require","_react","_interopRequireDefault","_flexBox","_neighborLocation","_keyboardFocusEnhance","_addonTextChildren","style","sstyled","insert","RootPills","_Component","_inherits2","_super","_createSuper2","_this","_classCallCheck2","_len","arguments","length","args","Array","_key","call","apply","concat","_defineProperty2","_assertThisInitialized2","value","e","handlers","event","code","asProps","behavior","selectedIndex","itemValues","findIndex","_this$itemRefs$focuse","focusedIndex","itemRefs","item","document","activeElement","focus","_createClass2","key","uncontrolledProps","getItemProps","props","index","_this2","_this$asProps","size","disabled","ref","node","selected","tabIndex","onClick","bindHandlerClick","render","_ref","_ref5","SPills","Box","_this$asProps2","Children","styles","controlsLength","createElement","cn","_objectSpread2","assignProps","handleKeyDown","Component","_ref9","defaultValue","keyboardFocusEnhance","Pill","_ref2","arguments[0]","_ref6","SPill","addonLeft","addonRight","neighborLocation","useNeighborLocationDetect","roleAreaProps","role","Pills","Item","Addon","tag","addonTextChildren","Text","enhance","_ref3","_ref7","SText","_ref4","_ref8","SAddon","createComponent","_default","exports"],"sources":["../../src/Pills.jsx"],"sourcesContent":["import React from 'react';\nimport createComponent, { Component, sstyled, Root } from '@semcore/core';\nimport { Box } from '@semcore/flex-box';\nimport NeighborLocation, { useNeighborLocationDetect } from '@semcore/neighbor-location';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport addonTextChildren from '@semcore/utils/lib/addonTextChildren';\n\nimport style from './style/pills.shadow.css';\n\nclass RootPills extends Component {\n static displayName = 'Pills';\n static style = style;\n static defaultProps = ({ behavior }) => ({\n size: 'm',\n defaultValue: null,\n behavior: behavior ?? 'tabs',\n tabIndex: behavior === 'tabs' ? -1 : 0,\n });\n itemRefs = [];\n itemValues = [];\n static enhance = [keyboardFocusEnhance()];\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n bindHandlerClick = (value) => (e) => {\n this.handlers.value(value, e);\n };\n\n getItemProps(props, index) {\n const { value, size, disabled, behavior } = this.asProps;\n this.itemValues[index] = props.value;\n return {\n ref: (node) => (this.itemRefs[index] = node),\n index: index,\n size,\n disabled,\n selected: value === props.value,\n behavior,\n tabIndex: behavior === 'tabs' ? 0 : -1,\n onClick: this.bindHandlerClick(props.value),\n };\n }\n\n handleKeyDown = (event) => {\n if (event.code !== 'ArrowLeft' && event.code !== 'ArrowRight') return;\n if (this.asProps.behavior === 'radio') {\n\n let selectedIndex = this.itemValues.findIndex((value) => value === this.asProps.value);\n if (selectedIndex === -1) return;\n\n if (event.code === 'ArrowLeft') selectedIndex--;\n if (event.code === 'ArrowRight') selectedIndex++;\n if (selectedIndex < 0 || selectedIndex >= this.itemValues.length) return;\n\n this.handlers.value(this.itemValues[selectedIndex], event);\n } else {\n let focusedIndex = this.itemRefs.findIndex((item) => item === document.activeElement);\n if (focusedIndex === -1) return;\n\n if (event.code === 'ArrowLeft') focusedIndex--;\n if (event.code === 'ArrowRight') focusedIndex++;\n\n this.itemRefs[focusedIndex]?.focus();\n }\n };\n\n render() {\n const SPills = Root;\n const { Children, styles, controlsLength, disabled, behavior } = this.asProps;\n\n return sstyled(styles)(\n <SPills\n render={Box}\n role={behavior === 'radio' ? 'radiogroup' : 'tablist'}\n aria-disabled={disabled}\n onKeyDown={this.handleKeyDown}\n >\n <NeighborLocation controlsLength={controlsLength}>\n <Children />\n </NeighborLocation>\n </SPills>,\n );\n }\n}\n\nfunction Pill(props) {\n const SPill = Root;\n const { Children, styles, addonLeft, addonRight, selected, disabled, index, behavior } = props;\n const neighborLocation = useNeighborLocationDetect(index);\n const roleAreaProps = {};\n if (behavior === 'radio') {\n roleAreaProps.role = 'radio';\n roleAreaProps['aria-checked'] = selected;\n } else {\n roleAreaProps.role = 'tab';\n roleAreaProps['aria-selected'] = selected;\n }\n return sstyled(styles)(\n <SPill\n render={Box}\n tag='button'\n type='button'\n neighborLocation={neighborLocation}\n aria-disabled={disabled}\n aria-posinset={index + 1}\n {...roleAreaProps}\n >\n {addonLeft ? <Pills.Item.Addon tag={addonLeft} /> : null}\n {addonTextChildren(Children, Pills.Item.Text, Pills.Item.Addon)}\n {addonRight ? <Pills.Item.Addon tag={addonRight} /> : null}\n </SPill>,\n );\n}\n\nPill.enhance = [keyboardFocusEnhance()];\n\nfunction Text(props) {\n const SText = Root;\n return sstyled(props.styles)(<SText render={Box} tag='span' />);\n}\n\nfunction Addon(props) {\n const SAddon = Root;\n return sstyled(props.styles)(<SAddon render={Box} tag='span' />);\n}\n\nconst Pills = createComponent(RootPills, {\n Item: [Pill, { Text, Addon }],\n});\n\nexport default Pills;\n"],"mappings":";;;;;;;;;;;;;;;AACA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AADA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAL,uBAAA,CAAAC,OAAA;AACA,IAAAK,qBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,kBAAA,GAAAJ,sBAAA,CAAAF,OAAA;AAAqE;AAAA,IAAAO,KAAA,+BAAAT,KAAA,CAAAU,OAAA,CAAAC,MAAA;EAAA;EAAA;EAAA;EAAA;EAAA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A,CAAC9C,KAAK,EAAE;EAAA,IAAAgD,KAAA,GAAAhB,YAAA;IAAAiB,KAAA;EACnB,IAAMC,KAAK,GACiClC,YAAG;EAA/C,OAAAiC,KAAA,GAAO,IAAA1F,aAAO,EAACyC,KAAK,CAACmB,MAAM,CAAC,eAACnE,MAAA,YAAAqE,aAAA,CAAC6B,KAAK,EAAAD,KAAA,CAAA3B,EAAA,cAAAC,cAAA,qBAAA1E,KAAA,CAAA2E,WAAA;IAAA,OAAkB;EAAM,GAAAwB,KAAA,IAAG;AAChE;AAEA,SAASL,KAAKA,CAAC3C,KAAK,EAAE;EAAA,IAAAmD,KAAA,GAAAnB,YAAA;IAAAoB,KAAA;EACpB,IAAMC,MAAM,GACiCrC,YAAG;EAAhD,OAAAoC,KAAA,GAAO,IAAA7F,aAAO,EAACyC,KAAK,CAACmB,MAAM,CAAC,eAACnE,MAAA,YAAAqE,aAAA,CAACgC,MAAM,EAAAD,KAAA,CAAA9B,EAAA,eAAAC,cAAA,qBAAA1E,KAAA,CAAA2E,WAAA;IAAA,OAAkB;EAAM,GAAA2B,KAAA,IAAG;AACjE;AAEA,IAAMV,KAAK,GAAG,IAAAa,gBAAe,EAAC7F,SAAS,EAAE;EACvCiF,IAAI,EAAE,CAACZ,IAAI,EAAE;IAAEgB,IAAI,EAAJA,IAAI;IAAEH,KAAK,EAALA;EAAM,CAAC;AAC9B,CAAC,CAAC;AAAC,IAAAY,QAAA,GAEYd,KAAK;AAAAe,OAAA,cAAAD,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import React from 'react';\nimport { CProps, PropGetterFn, ReturnEl } from '@semcore/core';\nimport { Box, IBoxProps } from '@semcore/flex-box';\nimport { INeighborItemProps, INeighborLocationProps } from '@semcore/neighbor-location';\nimport { IKeyboardFocusProps } from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\n\nexport type PillsValue = string | number | boolean | null;\n\nexport interface IPillsProps<T extends PillsValue = PillsValue> extends INeighborLocationProps {\n /** Pills size */\n size?: 'l' | 'm';\n /** Disabled state */\n disabled?: boolean;\n /** Called when the selection is changed */\n onChange?: (value: T, e?: React.SyntheticEvent<HTMLSpanElement>) => void;\n /** Value for the selected pill */\n value?: T;\n /** Default value for the selected pill */\n defaultValue?: T;\n}\n\nexport interface IPillProps extends IBoxProps, INeighborItemProps, IKeyboardFocusProps {\n /** Pill value */\n value?: PillsValue;\n /** Disabled state */\n disabled?: boolean;\n /** Selected state */\n selected?: boolean;\n /** Left addon text */\n addonLeft?: React.ElementType;\n /** Right addon tag */\n addonRight?: React.ElementType;\n}\n\nexport interface IPillsContext {\n getItemProps: PropGetterFn;\n}\n\nexport interface IPillsHandlers {\n value: (value: PillsValue) => void;\n}\n\ndeclare const Pills: (<T, V extends PillsValue = PillsValue>(\n props: CProps<IPillsProps<V> & T, IPillsContext, IPillsHandlers>,\n) => ReturnEl) & {\n Item: (<T>(props: CProps<IPillProps & T, {}, IPillsHandlers>) => ReturnEl) & {\n Text: typeof Box;\n Addon: typeof Box;\n };\n};\n\nexport default Pills;\n"],"mappings":""}
1
+ {"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import React from 'react';\nimport { CProps, PropGetterFn, ReturnEl } from '@semcore/core';\nimport { Box, IBoxProps } from '@semcore/flex-box';\nimport { INeighborItemProps, INeighborLocationProps } from '@semcore/neighbor-location';\nimport { IKeyboardFocusProps } from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\n\nexport type PillsValue = string | number | boolean | null;\n\nexport interface IPillsProps<T extends PillsValue = PillsValue> extends INeighborLocationProps {\n /** Pills size */\n size?: 'l' | 'm';\n /** Disabled state */\n disabled?: boolean;\n /** Called when the selection is changed */\n onChange?: (value: T, e?: React.SyntheticEvent<HTMLSpanElement>) => void;\n /** Value for the selected pill */\n value?: T;\n /** Default value for the selected pill */\n defaultValue?: T;\n /** Sets semantic role for corresponding behavior,\n * when set to `radio` pressing left and right arrows\n * selects corresponding sibling pill.\n *\n * It's recommended to use `radio` behavior in forms\n * while `tabs` behavior for navigation and layout.\n * @default tabs\n */\n behavior?: 'tabs' | 'radio';\n}\n\nexport interface IPillProps extends IBoxProps, INeighborItemProps, IKeyboardFocusProps {\n /** Pill value */\n value?: PillsValue;\n /** Disabled state */\n disabled?: boolean;\n /** Selected state */\n selected?: boolean;\n /** Left addon text */\n addonLeft?: React.ElementType;\n /** Right addon tag */\n addonRight?: React.ElementType;\n}\n\nexport interface IPillsContext {\n getItemProps: PropGetterFn;\n}\n\nexport interface IPillsHandlers {\n value: (value: PillsValue) => void;\n}\n\ndeclare const Pills: (<T, V extends PillsValue = PillsValue>(\n props: CProps<IPillsProps<V> & T, IPillsContext, IPillsHandlers>,\n) => ReturnEl) & {\n Item: (<T>(props: CProps<IPillProps & T, {}, IPillsHandlers>) => ReturnEl) & {\n Text: typeof Box;\n Addon: typeof Box;\n };\n};\n\nexport default Pills;\n"],"mappings":""}
@@ -3,6 +3,7 @@ SPills {
3
3
  align-items: center;
4
4
  justify-content: center;
5
5
  isolation: isolate;
6
+ outline: none;
6
7
  }
7
8
 
8
9
  SPill {
@@ -49,7 +50,7 @@ SPill {
49
50
  }
50
51
 
51
52
  SPill[selected] {
52
- background: var(--intergalactic-control-secondary-info-hover, rgba(0, 143, 248, 0.2));
53
+ background: var(--intergalactic-control-secondary-info, rgba(0, 143, 248, 0.1));
53
54
  border-color: var(--intergalactic-border-info-active, #006dca);
54
55
  z-index: 1;
55
56
  }
@@ -63,8 +64,9 @@ SPill[disabled] {
63
64
  }
64
65
  }
65
66
 
67
+ SPills[keyboardFocused],
66
68
  SPill[keyboardFocused] {
67
- box-shadow: var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.3));
69
+ box-shadow: var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.5));
68
70
  }
69
71
 
70
72
  SText {
package/lib/es6/Pills.js CHANGED
@@ -17,19 +17,19 @@ import NeighborLocation, { useNeighborLocationDetect } from '@semcore/neighbor-l
17
17
  import keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';
18
18
  import addonTextChildren from '@semcore/utils/lib/addonTextChildren';
19
19
  /*__reshadow-styles__:"./style/pills.shadow.css"*/
20
- var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".___SPill_myxr9_gg_,.___SPills_myxr9_gg_{display:inline-flex;align-items:center;justify-content:center}.___SPills_myxr9_gg_{isolation:isolate}.___SPill_myxr9_gg_{line-height:normal;position:relative;touch-action:manipulation;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;user-select:none;box-sizing:border-box;padding:0;margin:0;box-shadow:none;text-decoration:none;-webkit-tap-highlight-color:transparent;overflow:visible;outline:0;text-align:center;vertical-align:middle;font-family:inherit;cursor:pointer;background:var(--intergalactic-bg-primary-neutral, #ffffff);border:1px solid var(--intergalactic-border-primary, #c4c7cf);border-radius:var(--intergalactic-control-rounded, 6px)}.___SPill_myxr9_gg_::-moz-focus-inner{border:0;padding:0}.___SPill_myxr9_gg_:active,.___SPill_myxr9_gg_:focus{outline:0;text-decoration:none}@media (hover:hover){.___SPill_myxr9_gg_:hover{outline:0;text-decoration:none;background:var(--intergalactic-bg-primary-neutral-hover, #f4f5f9)}}.___SPill_myxr9_gg_.__selected_myxr9_gg_{background:var(--intergalactic-control-secondary-info-hover, rgba(0, 143, 248, 0.2));border-color:var(--intergalactic-border-info-active, #006dca);z-index:1}.___SPill_myxr9_gg_.__disabled_myxr9_gg_{cursor:default;pointer-events:none}.___SPill_myxr9_gg_.__disabled_myxr9_gg_>*{opacity:var(--intergalactic-disabled-opacity, 0.3)}.___SPill_myxr9_gg_.__keyboardFocused_myxr9_gg_{box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.3))}.___SText_myxr9_gg_{color:var(--intergalactic-text-primary, #191b23);display:inline-flex}.___SAddon_myxr9_gg_{color:var(--intergalactic-text-secondary, #6c6e79);display:inline-flex;align-items:center;justify-content:center}.___SPill_myxr9_gg_._size_m_myxr9_gg_{height:var(--intergalactic-form-control-m, 28px);min-width:var(--intergalactic-form-control-m, 28px);font-size:var(--intergalactic-fs-200, 14px)}.___SPill_myxr9_gg_._size_l_myxr9_gg_ .___SText_myxr9_gg_,.___SPill_myxr9_gg_._size_m_myxr9_gg_ .___SText_myxr9_gg_{margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_myxr9_gg_._size_m_myxr9_gg_ .___SAddon_myxr9_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x, 8px)}.___SPill_myxr9_gg_._size_m_myxr9_gg_ .___SAddon_myxr9_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_myxr9_gg_._size_m_myxr9_gg_ .___SAddon_myxr9_gg_:only-child{margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_myxr9_gg_._size_l_myxr9_gg_{height:var(--intergalactic-form-control-l, 40px);min-width:var(--intergalactic-form-control-l, 40px);font-size:var(--intergalactic-fs-300, 16px)}.___SPill_myxr9_gg_._size_l_myxr9_gg_ .___SAddon_myxr9_gg_:only-child,.___SPill_myxr9_gg_._size_l_myxr9_gg_ .___SText_myxr9_gg_:only-child{margin-left:var(--intergalactic-spacing-3x, 12px);margin-right:var(--intergalactic-spacing-3x, 12px)}.___SPill_myxr9_gg_._size_l_myxr9_gg_ .___SAddon_myxr9_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-3x, 12px)}.___SPill_myxr9_gg_._size_l_myxr9_gg_ .___SAddon_myxr9_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-3x, 12px)}.___SPill_myxr9_gg_._neighborLocation_right_myxr9_gg_{border-top-right-radius:0;border-bottom-right-radius:0}.___SPill_myxr9_gg_._neighborLocation_both_myxr9_gg_{border-radius:0;margin-left:-1px}.___SPill_myxr9_gg_._neighborLocation_left_myxr9_gg_{border-top-left-radius:0;border-bottom-left-radius:0;margin-left:-1px}" /*__inner_css_end__*/, "myxr9_gg_") /*__reshadow_css_end__*/, {
21
- "__SPills": "___SPills_myxr9_gg_",
22
- "__SPill": "___SPill_myxr9_gg_",
23
- "_selected": "__selected_myxr9_gg_",
24
- "_disabled": "__disabled_myxr9_gg_",
25
- "_keyboardFocused": "__keyboardFocused_myxr9_gg_",
26
- "__SText": "___SText_myxr9_gg_",
27
- "__SAddon": "___SAddon_myxr9_gg_",
28
- "_size_m": "_size_m_myxr9_gg_",
29
- "_size_l": "_size_l_myxr9_gg_",
30
- "_neighborLocation_right": "_neighborLocation_right_myxr9_gg_",
31
- "_neighborLocation_both": "_neighborLocation_both_myxr9_gg_",
32
- "_neighborLocation_left": "_neighborLocation_left_myxr9_gg_"
20
+ var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".___SPill_17bl9_gg_,.___SPills_17bl9_gg_{display:inline-flex;align-items:center;justify-content:center;outline:0}.___SPills_17bl9_gg_{isolation:isolate}.___SPill_17bl9_gg_{line-height:normal;position:relative;touch-action:manipulation;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;user-select:none;box-sizing:border-box;padding:0;margin:0;box-shadow:none;text-decoration:none;-webkit-tap-highlight-color:transparent;overflow:visible;text-align:center;vertical-align:middle;font-family:inherit;cursor:pointer;background:var(--intergalactic-bg-primary-neutral, #ffffff);border:1px solid var(--intergalactic-border-primary, #c4c7cf);border-radius:var(--intergalactic-control-rounded, 6px)}.___SPill_17bl9_gg_::-moz-focus-inner{border:0;padding:0}.___SPill_17bl9_gg_:active,.___SPill_17bl9_gg_:focus{outline:0;text-decoration:none}@media (hover:hover){.___SPill_17bl9_gg_:hover{outline:0;text-decoration:none;background:var(--intergalactic-bg-primary-neutral-hover, #f4f5f9)}}.___SPill_17bl9_gg_.__selected_17bl9_gg_{background:var(--intergalactic-control-secondary-info, rgba(0, 143, 248, 0.1));border-color:var(--intergalactic-border-info-active, #006dca);z-index:1}.___SPill_17bl9_gg_.__disabled_17bl9_gg_{cursor:default;pointer-events:none}.___SPill_17bl9_gg_.__disabled_17bl9_gg_>*{opacity:var(--intergalactic-disabled-opacity, 0.3)}.___SPill_17bl9_gg_.__keyboardFocused_17bl9_gg_,.___SPills_17bl9_gg_.__keyboardFocused_17bl9_gg_{box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.5))}.___SText_17bl9_gg_{color:var(--intergalactic-text-primary, #191b23);display:inline-flex}.___SAddon_17bl9_gg_{color:var(--intergalactic-text-secondary, #6c6e79);display:inline-flex;align-items:center;justify-content:center}.___SPill_17bl9_gg_._size_m_17bl9_gg_{height:var(--intergalactic-form-control-m, 28px);min-width:var(--intergalactic-form-control-m, 28px);font-size:var(--intergalactic-fs-200, 14px)}.___SPill_17bl9_gg_._size_l_17bl9_gg_ .___SText_17bl9_gg_,.___SPill_17bl9_gg_._size_m_17bl9_gg_ .___SText_17bl9_gg_{margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_17bl9_gg_._size_m_17bl9_gg_ .___SAddon_17bl9_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x, 8px)}.___SPill_17bl9_gg_._size_m_17bl9_gg_ .___SAddon_17bl9_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_17bl9_gg_._size_m_17bl9_gg_ .___SAddon_17bl9_gg_:only-child{margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_17bl9_gg_._size_l_17bl9_gg_{height:var(--intergalactic-form-control-l, 40px);min-width:var(--intergalactic-form-control-l, 40px);font-size:var(--intergalactic-fs-300, 16px)}.___SPill_17bl9_gg_._size_l_17bl9_gg_ .___SAddon_17bl9_gg_:only-child,.___SPill_17bl9_gg_._size_l_17bl9_gg_ .___SText_17bl9_gg_:only-child{margin-left:var(--intergalactic-spacing-3x, 12px);margin-right:var(--intergalactic-spacing-3x, 12px)}.___SPill_17bl9_gg_._size_l_17bl9_gg_ .___SAddon_17bl9_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-3x, 12px)}.___SPill_17bl9_gg_._size_l_17bl9_gg_ .___SAddon_17bl9_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-3x, 12px)}.___SPill_17bl9_gg_._neighborLocation_right_17bl9_gg_{border-top-right-radius:0;border-bottom-right-radius:0}.___SPill_17bl9_gg_._neighborLocation_both_17bl9_gg_{border-radius:0;margin-left:-1px}.___SPill_17bl9_gg_._neighborLocation_left_17bl9_gg_{border-top-left-radius:0;border-bottom-left-radius:0;margin-left:-1px}" /*__inner_css_end__*/, "17bl9_gg_") /*__reshadow_css_end__*/, {
21
+ "__SPills": "___SPills_17bl9_gg_",
22
+ "__SPill": "___SPill_17bl9_gg_",
23
+ "_selected": "__selected_17bl9_gg_",
24
+ "_disabled": "__disabled_17bl9_gg_",
25
+ "_keyboardFocused": "__keyboardFocused_17bl9_gg_",
26
+ "__SText": "___SText_17bl9_gg_",
27
+ "__SAddon": "___SAddon_17bl9_gg_",
28
+ "_size_m": "_size_m_17bl9_gg_",
29
+ "_size_l": "_size_l_17bl9_gg_",
30
+ "_neighborLocation_right": "_neighborLocation_right_17bl9_gg_",
31
+ "_neighborLocation_both": "_neighborLocation_both_17bl9_gg_",
32
+ "_neighborLocation_left": "_neighborLocation_left_17bl9_gg_"
33
33
  });
34
34
  var RootPills = /*#__PURE__*/function (_Component) {
35
35
  _inherits(RootPills, _Component);
@@ -42,21 +42,33 @@ var RootPills = /*#__PURE__*/function (_Component) {
42
42
  }
43
43
  _this = _super.call.apply(_super, [this].concat(args));
44
44
  _defineProperty(_assertThisInitialized(_this), "itemRefs", []);
45
+ _defineProperty(_assertThisInitialized(_this), "itemValues", []);
45
46
  _defineProperty(_assertThisInitialized(_this), "bindHandlerClick", function (value) {
46
47
  return function (e) {
47
48
  _this.handlers.value(value, e);
48
49
  };
49
50
  });
50
51
  _defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (event) {
51
- var _this$itemRefs$focuse;
52
- if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') return;
53
- var focusedIndex = _this.itemRefs.findIndex(function (item) {
54
- return item === document.activeElement;
55
- });
56
- if (focusedIndex === -1) return;
57
- if (event.key === 'ArrowLeft') focusedIndex--;
58
- if (event.key === 'ArrowRight') focusedIndex++;
59
- (_this$itemRefs$focuse = _this.itemRefs[focusedIndex]) === null || _this$itemRefs$focuse === void 0 ? void 0 : _this$itemRefs$focuse.focus();
52
+ if (event.code !== 'ArrowLeft' && event.code !== 'ArrowRight') return;
53
+ if (_this.asProps.behavior === 'radio') {
54
+ var selectedIndex = _this.itemValues.findIndex(function (value) {
55
+ return value === _this.asProps.value;
56
+ });
57
+ if (selectedIndex === -1) return;
58
+ if (event.code === 'ArrowLeft') selectedIndex--;
59
+ if (event.code === 'ArrowRight') selectedIndex++;
60
+ if (selectedIndex < 0 || selectedIndex >= _this.itemValues.length) return;
61
+ _this.handlers.value(_this.itemValues[selectedIndex], event);
62
+ } else {
63
+ var _this$itemRefs$focuse;
64
+ var focusedIndex = _this.itemRefs.findIndex(function (item) {
65
+ return item === document.activeElement;
66
+ });
67
+ if (focusedIndex === -1) return;
68
+ if (event.code === 'ArrowLeft') focusedIndex--;
69
+ if (event.code === 'ArrowRight') focusedIndex++;
70
+ (_this$itemRefs$focuse = _this.itemRefs[focusedIndex]) === null || _this$itemRefs$focuse === void 0 ? void 0 : _this$itemRefs$focuse.focus();
71
+ }
60
72
  });
61
73
  return _this;
62
74
  }
@@ -74,7 +86,9 @@ var RootPills = /*#__PURE__*/function (_Component) {
74
86
  var _this$asProps = this.asProps,
75
87
  value = _this$asProps.value,
76
88
  size = _this$asProps.size,
77
- disabled = _this$asProps.disabled;
89
+ disabled = _this$asProps.disabled,
90
+ behavior = _this$asProps.behavior;
91
+ this.itemValues[index] = props.value;
78
92
  return {
79
93
  ref: function ref(node) {
80
94
  return _this2.itemRefs[index] = node;
@@ -83,6 +97,8 @@ var RootPills = /*#__PURE__*/function (_Component) {
83
97
  size: size,
84
98
  disabled: disabled,
85
99
  selected: value === props.value,
100
+ behavior: behavior,
101
+ tabIndex: behavior === 'tabs' ? 0 : -1,
86
102
  onClick: this.bindHandlerClick(props.value)
87
103
  };
88
104
  }
@@ -96,9 +112,10 @@ var RootPills = /*#__PURE__*/function (_Component) {
96
112
  Children = _this$asProps2.Children,
97
113
  styles = _this$asProps2.styles,
98
114
  controlsLength = _this$asProps2.controlsLength,
99
- disabled = _this$asProps2.disabled;
115
+ disabled = _this$asProps2.disabled,
116
+ behavior = _this$asProps2.behavior;
100
117
  return _ref5 = sstyled(styles), /*#__PURE__*/React.createElement(SPills, _ref5.cn("SPills", _objectSpread({}, _assignProps({
101
- "role": "radiogroup",
118
+ "role": behavior === 'radio' ? 'radiogroup' : 'tablist',
102
119
  "aria-disabled": disabled,
103
120
  "onKeyDown": this.handleKeyDown
104
121
  }, _ref))), /*#__PURE__*/React.createElement(NeighborLocation, _ref5.cn("NeighborLocation", {
@@ -110,10 +127,16 @@ var RootPills = /*#__PURE__*/function (_Component) {
110
127
  }(Component);
111
128
  _defineProperty(RootPills, "displayName", 'Pills');
112
129
  _defineProperty(RootPills, "style", style);
113
- _defineProperty(RootPills, "defaultProps", {
114
- size: 'm',
115
- defaultValue: null
130
+ _defineProperty(RootPills, "defaultProps", function (_ref9) {
131
+ var behavior = _ref9.behavior;
132
+ return {
133
+ size: 'm',
134
+ defaultValue: null,
135
+ behavior: behavior !== null && behavior !== void 0 ? behavior : 'tabs',
136
+ tabIndex: behavior === 'tabs' ? -1 : 0
137
+ };
116
138
  });
139
+ _defineProperty(RootPills, "enhance", [keyboardFocusEnhance()]);
117
140
  function Pill(props) {
118
141
  var _ref2 = arguments[0],
119
142
  _ref6;
@@ -124,16 +147,24 @@ function Pill(props) {
124
147
  addonRight = props.addonRight,
125
148
  selected = props.selected,
126
149
  disabled = props.disabled,
127
- index = props.index;
150
+ index = props.index,
151
+ behavior = props.behavior;
128
152
  var neighborLocation = useNeighborLocationDetect(index);
129
- return _ref6 = sstyled(styles), /*#__PURE__*/React.createElement(SPill, _ref6.cn("SPill", _objectSpread({}, _assignProps2({
130
- "tag": "button",
131
- "type": "button",
132
- "role": "radio",
153
+ var roleAreaProps = {};
154
+ if (behavior === 'radio') {
155
+ roleAreaProps.role = 'radio';
156
+ roleAreaProps['aria-checked'] = selected;
157
+ } else {
158
+ roleAreaProps.role = 'tab';
159
+ roleAreaProps['aria-selected'] = selected;
160
+ }
161
+ return _ref6 = sstyled(styles), /*#__PURE__*/React.createElement(SPill, _ref6.cn("SPill", _objectSpread({}, _assignProps2(_objectSpread({
162
+ "tag": 'button',
163
+ "type": 'button',
133
164
  "neighborLocation": neighborLocation,
134
- "aria-checked": selected,
135
- "aria-disabled": disabled
136
- }, _ref2))), addonLeft ? /*#__PURE__*/React.createElement(Pills.Item.Addon, {
165
+ "aria-disabled": disabled,
166
+ "aria-posinset": index + 1
167
+ }, roleAreaProps), _ref2))), addonLeft ? /*#__PURE__*/React.createElement(Pills.Item.Addon, {
137
168
  tag: addonLeft
138
169
  }) : null, addonTextChildren(Children, Pills.Item.Text, Pills.Item.Addon), addonRight ? /*#__PURE__*/React.createElement(Pills.Item.Addon, {
139
170
  tag: addonRight
@@ -145,7 +176,7 @@ function Text(props) {
145
176
  _ref7;
146
177
  var SText = Box;
147
178
  return _ref7 = sstyled(props.styles), /*#__PURE__*/React.createElement(SText, _ref7.cn("SText", _objectSpread({}, _assignProps3({
148
- "tag": "span"
179
+ "tag": 'span'
149
180
  }, _ref3))));
150
181
  }
151
182
  function Addon(props) {
@@ -153,7 +184,7 @@ function Addon(props) {
153
184
  _ref8;
154
185
  var SAddon = Box;
155
186
  return _ref8 = sstyled(props.styles), /*#__PURE__*/React.createElement(SAddon, _ref8.cn("SAddon", _objectSpread({}, _assignProps4({
156
- "tag": "span"
187
+ "tag": 'span'
157
188
  }, _ref4))));
158
189
  }
159
190
  var Pills = createComponent(RootPills, {
@@ -1 +1 @@
1
- {"version":3,"file":"Pills.js","names":["React","createComponent","Component","sstyled","Root","Box","NeighborLocation","useNeighborLocationDetect","keyboardFocusEnhance","addonTextChildren","style","_sstyled","insert","RootPills","_Component","_inherits","_super","_createSuper","_this","_classCallCheck","_len","arguments","length","args","Array","_key","call","apply","concat","_defineProperty","_assertThisInitialized","value","e","handlers","event","_this$itemRefs$focuse","key","focusedIndex","itemRefs","findIndex","item","document","activeElement","focus","_createClass","uncontrolledProps","getItemProps","props","index","_this2","_this$asProps","asProps","size","disabled","ref","node","selected","onClick","bindHandlerClick","render","_ref","_ref5","SPills","_this$asProps2","Children","styles","controlsLength","createElement","cn","_objectSpread","_assignProps","handleKeyDown","defaultValue","Pill","_ref2","arguments[0]","_ref6","SPill","addonLeft","addonRight","neighborLocation","_assignProps2","Pills","Item","Addon","tag","Text","enhance","_ref3","_ref7","SText","_assignProps3","_ref4","_ref8","SAddon","_assignProps4"],"sources":["../../src/Pills.jsx"],"sourcesContent":["import React from 'react';\nimport createComponent, { Component, sstyled, Root } from '@semcore/core';\nimport { Box } from '@semcore/flex-box';\nimport NeighborLocation, { useNeighborLocationDetect } from '@semcore/neighbor-location';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport addonTextChildren from '@semcore/utils/lib/addonTextChildren';\n\nimport style from './style/pills.shadow.css';\n\nclass RootPills extends Component {\n static displayName = 'Pills';\n static style = style;\n static defaultProps = {\n size: 'm',\n defaultValue: null,\n };\n itemRefs = [];\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n bindHandlerClick = (value) => (e) => {\n this.handlers.value(value, e);\n };\n\n getItemProps(props, index) {\n const { value, size, disabled } = this.asProps;\n return {\n ref: (node) => (this.itemRefs[index] = node),\n index: index,\n size,\n disabled,\n selected: value === props.value,\n onClick: this.bindHandlerClick(props.value),\n };\n }\n\n handleKeyDown = (event) => {\n if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') return;\n\n let focusedIndex = this.itemRefs.findIndex((item) => item === document.activeElement);\n if (focusedIndex === -1) return;\n\n if (event.key === 'ArrowLeft') focusedIndex--;\n if (event.key === 'ArrowRight') focusedIndex++;\n\n this.itemRefs[focusedIndex]?.focus();\n };\n\n render() {\n const SPills = Root;\n const { Children, styles, controlsLength, disabled } = this.asProps;\n\n return sstyled(styles)(\n <SPills\n render={Box}\n role=\"radiogroup\"\n aria-disabled={disabled}\n onKeyDown={this.handleKeyDown}\n >\n <NeighborLocation controlsLength={controlsLength}>\n <Children />\n </NeighborLocation>\n </SPills>,\n );\n }\n}\n\nfunction Pill(props) {\n const SPill = Root;\n const { Children, styles, addonLeft, addonRight, selected, disabled, index } = props;\n const neighborLocation = useNeighborLocationDetect(index);\n return sstyled(styles)(\n <SPill\n render={Box}\n tag=\"button\"\n type=\"button\"\n role=\"radio\"\n neighborLocation={neighborLocation}\n aria-checked={selected}\n aria-disabled={disabled}\n >\n {addonLeft ? <Pills.Item.Addon tag={addonLeft} /> : null}\n {addonTextChildren(Children, Pills.Item.Text, Pills.Item.Addon)}\n {addonRight ? <Pills.Item.Addon tag={addonRight} /> : null}\n </SPill>,\n );\n}\n\nPill.enhance = [keyboardFocusEnhance()];\n\nfunction Text(props) {\n const SText = Root;\n return sstyled(props.styles)(<SText render={Box} tag=\"span\" />);\n}\n\nfunction Addon(props) {\n const SAddon = Root;\n return sstyled(props.styles)(<SAddon render={Box} tag=\"span\" />);\n}\n\nconst Pills = createComponent(RootPills, {\n Item: [Pill, { Text, Addon }],\n});\n\nexport default Pills;\n"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,eAAe,IAAIC,SAAS,EAAEC,OAAO,EAAEC,IAAI,QAAQ,eAAe;AACzE,SAASC,GAAG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,SAASJ,KAAKA,CAACrC,KAAK,EAAE;EAAA,IAAA6C,KAAA,GAAAjB,YAAA;IAAAkB,KAAA;EACpB,IAAMC,MAAM,GACiCzF,GAAG;EAAhD,OAAAwF,KAAA,GAAO1F,OAAO,CAAC4C,KAAK,CAACkB,MAAM,CAAC,eAACjE,KAAA,CAAAmE,aAAA,CAAC2B,MAAM,EAAAD,KAAA,CAAAzB,EAAA,WAAAC,aAAA,KAAA0B,aAAA;IAAA,OAAkB;EAAM,GAAAH,KAAA,IAAG;AACjE;AAEA,IAAMV,KAAK,GAAGjF,eAAe,CAACY,SAAS,EAAE;EACvCsE,IAAI,EAAE,CAACV,IAAI,EAAE;IAAEa,IAAI,EAAJA,IAAI;IAAEF,KAAK,EAALA;EAAM,CAAC;AAC9B,CAAC,CAAC;AAEF,eAAeF,KAAK"}
1
+ {"version":3,"file":"Pills.js","names":["React","createComponent","Component","sstyled","Root","Box","NeighborLocation","useNeighborLocationDetect","keyboardFocusEnhance","addonTextChildren","style","_sstyled","insert","RootPills","_Component","_inherits","_super","_createSuper","_this","_classCallCheck","_len","arguments","length","args","Array","_key","call","apply","concat","_defineProperty","_assertThisInitialized","value","e","handlers","event","code","asProps","behavior","selectedIndex","itemValues","findIndex","_this$itemRefs$focuse","focusedIndex","itemRefs","item","document","activeElement","focus","_createClass","key","uncontrolledProps","getItemProps","props","index","_this2","_this$asProps","size","disabled","ref","node","selected","tabIndex","onClick","bindHandlerClick","render","_ref","_ref5","SPills","_this$asProps2","Children","styles","controlsLength","createElement","cn","_objectSpread","_assignProps","handleKeyDown","_ref9","defaultValue","Pill","_ref2","arguments[0]","_ref6","SPill","addonLeft","addonRight","neighborLocation","roleAreaProps","role","_assignProps2","Pills","Item","Addon","tag","Text","enhance","_ref3","_ref7","SText","_assignProps3","_ref4","_ref8","SAddon","_assignProps4"],"sources":["../../src/Pills.jsx"],"sourcesContent":["import React from 'react';\nimport createComponent, { Component, sstyled, Root } from '@semcore/core';\nimport { Box } from '@semcore/flex-box';\nimport NeighborLocation, { useNeighborLocationDetect } from '@semcore/neighbor-location';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport addonTextChildren from '@semcore/utils/lib/addonTextChildren';\n\nimport style from './style/pills.shadow.css';\n\nclass RootPills extends Component {\n static displayName = 'Pills';\n static style = style;\n static defaultProps = ({ behavior }) => ({\n size: 'm',\n defaultValue: null,\n behavior: behavior ?? 'tabs',\n tabIndex: behavior === 'tabs' ? -1 : 0,\n });\n itemRefs = [];\n itemValues = [];\n static enhance = [keyboardFocusEnhance()];\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n bindHandlerClick = (value) => (e) => {\n this.handlers.value(value, e);\n };\n\n getItemProps(props, index) {\n const { value, size, disabled, behavior } = this.asProps;\n this.itemValues[index] = props.value;\n return {\n ref: (node) => (this.itemRefs[index] = node),\n index: index,\n size,\n disabled,\n selected: value === props.value,\n behavior,\n tabIndex: behavior === 'tabs' ? 0 : -1,\n onClick: this.bindHandlerClick(props.value),\n };\n }\n\n handleKeyDown = (event) => {\n if (event.code !== 'ArrowLeft' && event.code !== 'ArrowRight') return;\n if (this.asProps.behavior === 'radio') {\n\n let selectedIndex = this.itemValues.findIndex((value) => value === this.asProps.value);\n if (selectedIndex === -1) return;\n\n if (event.code === 'ArrowLeft') selectedIndex--;\n if (event.code === 'ArrowRight') selectedIndex++;\n if (selectedIndex < 0 || selectedIndex >= this.itemValues.length) return;\n\n this.handlers.value(this.itemValues[selectedIndex], event);\n } else {\n let focusedIndex = this.itemRefs.findIndex((item) => item === document.activeElement);\n if (focusedIndex === -1) return;\n\n if (event.code === 'ArrowLeft') focusedIndex--;\n if (event.code === 'ArrowRight') focusedIndex++;\n\n this.itemRefs[focusedIndex]?.focus();\n }\n };\n\n render() {\n const SPills = Root;\n const { Children, styles, controlsLength, disabled, behavior } = this.asProps;\n\n return sstyled(styles)(\n <SPills\n render={Box}\n role={behavior === 'radio' ? 'radiogroup' : 'tablist'}\n aria-disabled={disabled}\n onKeyDown={this.handleKeyDown}\n >\n <NeighborLocation controlsLength={controlsLength}>\n <Children />\n </NeighborLocation>\n </SPills>,\n );\n }\n}\n\nfunction Pill(props) {\n const SPill = Root;\n const { Children, styles, addonLeft, addonRight, selected, disabled, index, behavior } = props;\n const neighborLocation = useNeighborLocationDetect(index);\n const roleAreaProps = {};\n if (behavior === 'radio') {\n roleAreaProps.role = 'radio';\n roleAreaProps['aria-checked'] = selected;\n } else {\n roleAreaProps.role = 'tab';\n roleAreaProps['aria-selected'] = selected;\n }\n return sstyled(styles)(\n <SPill\n render={Box}\n tag='button'\n type='button'\n neighborLocation={neighborLocation}\n aria-disabled={disabled}\n aria-posinset={index + 1}\n {...roleAreaProps}\n >\n {addonLeft ? <Pills.Item.Addon tag={addonLeft} /> : null}\n {addonTextChildren(Children, Pills.Item.Text, Pills.Item.Addon)}\n {addonRight ? <Pills.Item.Addon tag={addonRight} /> : null}\n </SPill>,\n );\n}\n\nPill.enhance = [keyboardFocusEnhance()];\n\nfunction Text(props) {\n const SText = Root;\n return sstyled(props.styles)(<SText render={Box} tag='span' />);\n}\n\nfunction Addon(props) {\n const SAddon = Root;\n return sstyled(props.styles)(<SAddon render={Box} tag='span' />);\n}\n\nconst Pills = createComponent(RootPills, {\n Item: [Pill, { Text, Addon }],\n});\n\nexport default Pills;\n"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,eAAe,IAAIC,SAAS,EAAEC,OAAO,EAAEC,IAAI,QAAQ,eAAe;AACzE,SAASC,GAAG,QAAQ,mBAAmB;AACvC,OAAOC,gBAAgB,IAAIC,yBAAyB,QAAQ,4BAA4B;AACxF,OAAOC,oBAAoB,MAAM,kDAAkD;AACnF,OAAOC,iBAAiB,MAAM,sCAAsC;AAAC;AAAA,IAAAC,KAAA,+BAAAC,QAAA,CAAAC,MAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EA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AwE,aAAA,CAAC0B,KAAK,EAAAD,KAAA,CAAAxB,EAAA,UAAAC,aAAA,KAAAyB,aAAA;IAAA,OAAkB;EAAM,GAAAH,KAAA,IAAG;AAChE;AAEA,SAASJ,KAAKA,CAACxC,KAAK,EAAE;EAAA,IAAAgD,KAAA,GAAAnB,YAAA;IAAAoB,KAAA;EACpB,IAAMC,MAAM,GACiCjG,GAAG;EAAhD,OAAAgG,KAAA,GAAOlG,OAAO,CAACiD,KAAK,CAACkB,MAAM,CAAC,eAACtE,KAAA,CAAAwE,aAAA,CAAC8B,MAAM,EAAAD,KAAA,CAAA5B,EAAA,WAAAC,aAAA,KAAA6B,aAAA;IAAA,OAAkB;EAAM,GAAAH,KAAA,IAAG;AACjE;AAEA,IAAMV,KAAK,GAAGzF,eAAe,CAACY,SAAS,EAAE;EACvC8E,IAAI,EAAE,CAACZ,IAAI,EAAE;IAAEe,IAAI,EAAJA,IAAI;IAAEF,KAAK,EAALA;EAAM,CAAC;AAC9B,CAAC,CAAC;AAEF,eAAeF,KAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import React from 'react';\nimport { CProps, PropGetterFn, ReturnEl } from '@semcore/core';\nimport { Box, IBoxProps } from '@semcore/flex-box';\nimport { INeighborItemProps, INeighborLocationProps } from '@semcore/neighbor-location';\nimport { IKeyboardFocusProps } from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\n\nexport type PillsValue = string | number | boolean | null;\n\nexport interface IPillsProps<T extends PillsValue = PillsValue> extends INeighborLocationProps {\n /** Pills size */\n size?: 'l' | 'm';\n /** Disabled state */\n disabled?: boolean;\n /** Called when the selection is changed */\n onChange?: (value: T, e?: React.SyntheticEvent<HTMLSpanElement>) => void;\n /** Value for the selected pill */\n value?: T;\n /** Default value for the selected pill */\n defaultValue?: T;\n}\n\nexport interface IPillProps extends IBoxProps, INeighborItemProps, IKeyboardFocusProps {\n /** Pill value */\n value?: PillsValue;\n /** Disabled state */\n disabled?: boolean;\n /** Selected state */\n selected?: boolean;\n /** Left addon text */\n addonLeft?: React.ElementType;\n /** Right addon tag */\n addonRight?: React.ElementType;\n}\n\nexport interface IPillsContext {\n getItemProps: PropGetterFn;\n}\n\nexport interface IPillsHandlers {\n value: (value: PillsValue) => void;\n}\n\ndeclare const Pills: (<T, V extends PillsValue = PillsValue>(\n props: CProps<IPillsProps<V> & T, IPillsContext, IPillsHandlers>,\n) => ReturnEl) & {\n Item: (<T>(props: CProps<IPillProps & T, {}, IPillsHandlers>) => ReturnEl) & {\n Text: typeof Box;\n Addon: typeof Box;\n };\n};\n\nexport default Pills;\n"],"mappings":""}
1
+ {"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import React from 'react';\nimport { CProps, PropGetterFn, ReturnEl } from '@semcore/core';\nimport { Box, IBoxProps } from '@semcore/flex-box';\nimport { INeighborItemProps, INeighborLocationProps } from '@semcore/neighbor-location';\nimport { IKeyboardFocusProps } from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\n\nexport type PillsValue = string | number | boolean | null;\n\nexport interface IPillsProps<T extends PillsValue = PillsValue> extends INeighborLocationProps {\n /** Pills size */\n size?: 'l' | 'm';\n /** Disabled state */\n disabled?: boolean;\n /** Called when the selection is changed */\n onChange?: (value: T, e?: React.SyntheticEvent<HTMLSpanElement>) => void;\n /** Value for the selected pill */\n value?: T;\n /** Default value for the selected pill */\n defaultValue?: T;\n /** Sets semantic role for corresponding behavior,\n * when set to `radio` pressing left and right arrows\n * selects corresponding sibling pill.\n *\n * It's recommended to use `radio` behavior in forms\n * while `tabs` behavior for navigation and layout.\n * @default tabs\n */\n behavior?: 'tabs' | 'radio';\n}\n\nexport interface IPillProps extends IBoxProps, INeighborItemProps, IKeyboardFocusProps {\n /** Pill value */\n value?: PillsValue;\n /** Disabled state */\n disabled?: boolean;\n /** Selected state */\n selected?: boolean;\n /** Left addon text */\n addonLeft?: React.ElementType;\n /** Right addon tag */\n addonRight?: React.ElementType;\n}\n\nexport interface IPillsContext {\n getItemProps: PropGetterFn;\n}\n\nexport interface IPillsHandlers {\n value: (value: PillsValue) => void;\n}\n\ndeclare const Pills: (<T, V extends PillsValue = PillsValue>(\n props: CProps<IPillsProps<V> & T, IPillsContext, IPillsHandlers>,\n) => ReturnEl) & {\n Item: (<T>(props: CProps<IPillProps & T, {}, IPillsHandlers>) => ReturnEl) & {\n Text: typeof Box;\n Addon: typeof Box;\n };\n};\n\nexport default Pills;\n"],"mappings":""}
@@ -3,6 +3,7 @@ SPills {
3
3
  align-items: center;
4
4
  justify-content: center;
5
5
  isolation: isolate;
6
+ outline: none;
6
7
  }
7
8
 
8
9
  SPill {
@@ -49,7 +50,7 @@ SPill {
49
50
  }
50
51
 
51
52
  SPill[selected] {
52
- background: var(--intergalactic-control-secondary-info-hover, rgba(0, 143, 248, 0.2));
53
+ background: var(--intergalactic-control-secondary-info, rgba(0, 143, 248, 0.1));
53
54
  border-color: var(--intergalactic-border-info-active, #006dca);
54
55
  z-index: 1;
55
56
  }
@@ -63,8 +64,9 @@ SPill[disabled] {
63
64
  }
64
65
  }
65
66
 
67
+ SPills[keyboardFocused],
66
68
  SPill[keyboardFocused] {
67
- box-shadow: var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.3));
69
+ box-shadow: var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.5));
68
70
  }
69
71
 
70
72
  SText {
@@ -17,6 +17,15 @@ export interface IPillsProps<T extends PillsValue = PillsValue> extends INeighbo
17
17
  value?: T;
18
18
  /** Default value for the selected pill */
19
19
  defaultValue?: T;
20
+ /** Sets semantic role for corresponding behavior,
21
+ * when set to `radio` pressing left and right arrows
22
+ * selects corresponding sibling pill.
23
+ *
24
+ * It's recommended to use `radio` behavior in forms
25
+ * while `tabs` behavior for navigation and layout.
26
+ * @default tabs
27
+ */
28
+ behavior?: 'tabs' | 'radio';
20
29
  }
21
30
 
22
31
  export interface IPillProps extends IBoxProps, INeighborItemProps, IKeyboardFocusProps {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semcore/pills",
3
3
  "description": "Semrush Pills Component",
4
- "version": "4.4.24",
4
+ "version": "4.6.0",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es6/index.js",
7
7
  "typings": "lib/types/index.d.ts",