@semcore/pills 16.1.0-prerelease.3 → 16.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/Pills.js CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
4
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
@@ -13,41 +12,26 @@ var _callSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/callSup
13
12
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
14
13
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
14
  var _core = require("@semcore/core");
15
+ var _baseComponents = require("@semcore/base-components");
16
16
  var _addonTextChildren = _interopRequireDefault(require("@semcore/core/lib/utils/addonTextChildren"));
17
17
  var _a11yEnhance = _interopRequireDefault(require("@semcore/core/lib/utils/enhances/a11yEnhance"));
18
- var _logger = _interopRequireDefault(require("@semcore/core/lib/utils/logger"));
19
- var _flexBox = require("@semcore/flex-box");
20
- var _neighborLocation = _interopRequireWildcard(require("@semcore/neighbor-location"));
21
18
  var _react = _interopRequireDefault(require("react"));
22
19
  /*!__reshadow-styles__:"./style/pills.shadow.css"*/
23
- var style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SPills_lodqe_gg_{display:inline-flex;align-items:center;justify-content:center;isolation:isolate;border-radius:var(--intergalactic-control-rounded, 6px)}.___SPills_lodqe_gg_ .___SPill_lodqe_gg_.__selected_lodqe_gg_{background:var(--intergalactic-control-secondary-info, rgba(0, 81, 255, 0.039));border-color:var(--intergalactic-border-info-active, rgba(0, 40, 230, 0.419));z-index:3}@supports (color:color(display-p3 0 0 0%)){.___SPills_lodqe_gg_ .___SPill_lodqe_gg_.__selected_lodqe_gg_{background:var(--intergalactic-control-secondary-info, rgba(0, 81, 255, 0.039))}@media (color-gamut:p3){.___SPills_lodqe_gg_ .___SPill_lodqe_gg_.__selected_lodqe_gg_{background:var(--intergalactic-control-secondary-info, color(display-p3 0.12567 0.31309 0.96324 / 0.039))}}}.___SPills_lodqe_gg_ .___SPill_lodqe_gg_.__selected_lodqe_gg_,.___SPills_lodqe_gg_ .___SPill_lodqe_gg_:focus-visible{z-index:3}.___SPills_lodqe_gg_ .___SPill_lodqe_gg_:active{z-index:2}@media (hover:hover){.___SPills_lodqe_gg_ .___SPill_lodqe_gg_:hover{z-index:2}}.___SPill_lodqe_gg_{display:inline-flex;align-items:center;justify-content:center;line-height:normal;position:relative;touch-action:manipulation;white-space:nowrap;-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, rgb(255, 255, 255));border:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161));border-radius:var(--intergalactic-control-rounded, 6px)}@supports (color:color(display-p3 0 0 0%)){.___SPill_lodqe_gg_{border:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___SPill_lodqe_gg_{border:1px solid var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___SPill_lodqe_gg_::-moz-focus-inner{border:0;padding:0}.___SPill_lodqe_gg_:active{outline:0;text-decoration:none}@media (hover:hover){.___SPill_lodqe_gg_:hover{background:var(--intergalactic-bg-primary-neutral-hover, rgb(248, 249, 248))}}.___SPill_lodqe_gg_.__disabled_lodqe_gg_{cursor:default;pointer-events:none}.___SPill_lodqe_gg_.__disabled_lodqe_gg_>*{opacity:var(--intergalactic-disabled-opacity, 0.4)}.___SText_lodqe_gg_{color:var(--intergalactic-text-primary, rgba(1, 5, 0, 0.899));display:inline-flex}.___SAddon_lodqe_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583));display:inline-flex;align-items:center;justify-content:center}@supports (color:color(display-p3 0 0 0%)){.___SAddon_lodqe_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@media (color-gamut:p3){.___SAddon_lodqe_gg_{color:var(--intergalactic-text-secondary, color(display-p3 0.00228 0.01289 0.00252 / 0.583))}}}.___SPill_lodqe_gg_._size_m_lodqe_gg_{height:var(--intergalactic-form-control-m, 28px);min-width:var(--intergalactic-form-control-m, 28px);font-size:var(--intergalactic-fs-200, 14px)}.___SPill_lodqe_gg_._size_l_lodqe_gg_ .___SText_lodqe_gg_,.___SPill_lodqe_gg_._size_m_lodqe_gg_ .___SText_lodqe_gg_{margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_lodqe_gg_._size_m_lodqe_gg_ .___SAddon_lodqe_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x, 8px)}.___SPill_lodqe_gg_._size_m_lodqe_gg_ .___SAddon_lodqe_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_lodqe_gg_._size_m_lodqe_gg_ .___SAddon_lodqe_gg_:only-child{margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_lodqe_gg_._size_l_lodqe_gg_{height:var(--intergalactic-form-control-l, 40px);min-width:var(--intergalactic-form-control-l, 40px);font-size:var(--intergalactic-fs-300, 16px)}.___SPill_lodqe_gg_._size_l_lodqe_gg_ .___SAddon_lodqe_gg_:only-child,.___SPill_lodqe_gg_._size_l_lodqe_gg_ .___SText_lodqe_gg_:only-child{margin-left:var(--intergalactic-spacing-3x, 12px);margin-right:var(--intergalactic-spacing-3x, 12px)}.___SPill_lodqe_gg_._size_l_lodqe_gg_ .___SAddon_lodqe_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-3x, 12px)}.___SPill_lodqe_gg_._size_l_lodqe_gg_ .___SAddon_lodqe_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-3x, 12px)}.___SPill_lodqe_gg_._neighborLocation_right_lodqe_gg_{border-top-right-radius:0;border-bottom-right-radius:0}.___SPill_lodqe_gg_._neighborLocation_both_lodqe_gg_{border-radius:0;margin-left:-1px}.___SPill_lodqe_gg_._neighborLocation_left_lodqe_gg_{border-top-left-radius:0;border-bottom-left-radius:0;margin-left:-1px}", /*__inner_css_end__*/"lodqe_gg_"),
20
+ var style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SPills_x9pvr_gg_{display:inline-flex;align-items:center;justify-content:center;isolation:isolate;border-radius:var(--intergalactic-control-rounded, 6px)}.___SPills_x9pvr_gg_ .___SPill_x9pvr_gg_.__selected_x9pvr_gg_{background:var(--intergalactic-control-secondary-info, rgba(0, 81, 255, 0.039));border-color:var(--intergalactic-border-info-active, rgb(135, 150, 239));z-index:3}@supports (color:color(display-p3 0 0 0%)){.___SPills_x9pvr_gg_ .___SPill_x9pvr_gg_.__selected_x9pvr_gg_{background:var(--intergalactic-control-secondary-info, rgba(0, 81, 255, 0.039))}@media (color-gamut:p3){.___SPills_x9pvr_gg_ .___SPill_x9pvr_gg_.__selected_x9pvr_gg_{background:var(--intergalactic-control-secondary-info, color(display-p3 0.12567 0.31309 0.96324 / 0.039))}}}.___SPills_x9pvr_gg_ .___SPill_x9pvr_gg_.__selected_x9pvr_gg_,.___SPills_x9pvr_gg_ .___SPill_x9pvr_gg_:focus-visible{z-index:3}.___SPills_x9pvr_gg_ .___SPill_x9pvr_gg_:active{z-index:2}@media (hover:hover){.___SPills_x9pvr_gg_ .___SPill_x9pvr_gg_:hover{z-index:2}}.___SPill_x9pvr_gg_{display:inline-flex;align-items:center;justify-content:center;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;-webkit-text-decoration: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, rgb(255, 255, 255));border:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161));border-radius:var(--intergalactic-control-rounded, 6px)}@supports (color:color(display-p3 0 0 0%)){.___SPill_x9pvr_gg_{border:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___SPill_x9pvr_gg_{border:1px solid var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___SPill_x9pvr_gg_::-moz-focus-inner{border:0;padding:0}.___SPill_x9pvr_gg_:active{outline:0;-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___SPill_x9pvr_gg_:hover{background:var(--intergalactic-bg-primary-neutral-hover, rgb(248, 249, 248))}}.___SPill_x9pvr_gg_.__disabled_x9pvr_gg_{cursor:default;pointer-events:none}.___SPill_x9pvr_gg_.__disabled_x9pvr_gg_>*{opacity:var(--intergalactic-disabled-opacity, 0.4)}.___SText_x9pvr_gg_{color:var(--intergalactic-text-primary, rgba(1, 5, 0, 0.899));display:inline-flex}.___SAddon_x9pvr_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583));display:inline-flex;align-items:center;justify-content:center}@supports (color:color(display-p3 0 0 0%)){.___SAddon_x9pvr_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@media (color-gamut:p3){.___SAddon_x9pvr_gg_{color:var(--intergalactic-text-secondary, color(display-p3 0.00228 0.01289 0.00252 / 0.583))}}}.___SPill_x9pvr_gg_._size_m_x9pvr_gg_{height:var(--intergalactic-form-control-m, 28px);min-width:var(--intergalactic-form-control-m, 28px);font-size:var(--intergalactic-fs-200, 14px)}.___SPill_x9pvr_gg_._size_l_x9pvr_gg_ .___SText_x9pvr_gg_,.___SPill_x9pvr_gg_._size_m_x9pvr_gg_ .___SText_x9pvr_gg_{margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_x9pvr_gg_._size_m_x9pvr_gg_ .___SAddon_x9pvr_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x, 8px)}.___SPill_x9pvr_gg_._size_m_x9pvr_gg_ .___SAddon_x9pvr_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_x9pvr_gg_._size_m_x9pvr_gg_ .___SAddon_x9pvr_gg_:only-child{margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_x9pvr_gg_._size_l_x9pvr_gg_{height:var(--intergalactic-form-control-l, 40px);min-width:var(--intergalactic-form-control-l, 40px);font-size:var(--intergalactic-fs-300, 16px)}.___SPill_x9pvr_gg_._size_l_x9pvr_gg_ .___SAddon_x9pvr_gg_:only-child,.___SPill_x9pvr_gg_._size_l_x9pvr_gg_ .___SText_x9pvr_gg_:only-child{margin-left:var(--intergalactic-spacing-3x, 12px);margin-right:var(--intergalactic-spacing-3x, 12px)}.___SPill_x9pvr_gg_._size_l_x9pvr_gg_ .___SAddon_x9pvr_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-3x, 12px)}.___SPill_x9pvr_gg_._size_l_x9pvr_gg_ .___SAddon_x9pvr_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-3x, 12px)}.___SPill_x9pvr_gg_._neighborLocation_right_x9pvr_gg_{border-top-right-radius:0;border-bottom-right-radius:0}.___SPill_x9pvr_gg_._neighborLocation_both_x9pvr_gg_{border-radius:0;margin-left:-1px}.___SPill_x9pvr_gg_._neighborLocation_left_x9pvr_gg_{border-top-left-radius:0;border-bottom-left-radius:0;margin-left:-1px}", /*__inner_css_end__*/"x9pvr_gg_"),
24
21
  /*__reshadow_css_end__*/
25
22
  {
26
- "__SText": "___SText_lodqe_gg_",
27
- "__SAddon": "___SAddon_lodqe_gg_",
28
- "__SPill": "___SPill_lodqe_gg_",
29
- "_neighborLocation_right": "_neighborLocation_right_lodqe_gg_",
30
- "_neighborLocation_both": "_neighborLocation_both_lodqe_gg_",
31
- "_neighborLocation_left": "_neighborLocation_left_lodqe_gg_",
32
- "__SPills": "___SPills_lodqe_gg_",
33
- "_selected": "__selected_lodqe_gg_",
34
- "_disabled": "__disabled_lodqe_gg_",
35
- "_size_m": "_size_m_lodqe_gg_",
36
- "_size_l": "_size_l_lodqe_gg_"
23
+ "__SText": "___SText_x9pvr_gg_",
24
+ "__SAddon": "___SAddon_x9pvr_gg_",
25
+ "__SPill": "___SPill_x9pvr_gg_",
26
+ "_neighborLocation_right": "_neighborLocation_right_x9pvr_gg_",
27
+ "_neighborLocation_both": "_neighborLocation_both_x9pvr_gg_",
28
+ "_neighborLocation_left": "_neighborLocation_left_x9pvr_gg_",
29
+ "__SPills": "___SPills_x9pvr_gg_",
30
+ "_selected": "__selected_x9pvr_gg_",
31
+ "_disabled": "__disabled_x9pvr_gg_",
32
+ "_size_m": "_size_m_x9pvr_gg_",
33
+ "_size_l": "_size_l_x9pvr_gg_"
37
34
  });
38
- var optionsA11yEnhance = {
39
- onNeighborChange: function onNeighborChange(neighborElement, props) {
40
- if (neighborElement) {
41
- neighborElement.focus();
42
- if (props.behavior === 'auto' || props.behavior === 'radio') {
43
- neighborElement.click();
44
- }
45
- }
46
- },
47
- childSelector: function childSelector(props) {
48
- return props.behavior === 'auto' || props.behavior === 'radio' ? ['role', 'radio'] : ['role', 'tab'];
49
- }
50
- };
51
35
  var RootPills = /*#__PURE__*/function (_Component) {
52
36
  function RootPills() {
53
37
  var _this;
@@ -63,39 +47,23 @@ var RootPills = /*#__PURE__*/function (_Component) {
63
47
  };
64
48
  });
65
49
  (0, _defineProperty2["default"])(_this, "bindHandleKeyDown", function (value) {
66
- return function (event) {
67
- if (event.key === 'Enter' || event.key === ' ') {
68
- event.preventDefault();
69
- _this.handlers.value(value, event);
50
+ return function (e) {
51
+ if (e.key === 'Enter' || e.key === ' ') {
52
+ e.preventDefault();
53
+ _this.handlers.value(value, e);
70
54
  }
71
55
  };
72
56
  });
73
- (0, _defineProperty2["default"])(_this, "changeIndex", function (startIndex, type) {
74
- var selectable = false;
75
- while (!selectable && startIndex >= 0 && startIndex < _this.itemValues.length) {
76
- if (type === 'increment') startIndex++;
77
- if (type === 'decrement') startIndex--;
78
- var element = _this.itemRefs[startIndex];
79
- if ((element === null || element === void 0 ? void 0 : element.disabled) === false) {
80
- selectable = true;
81
- }
82
- }
83
- return startIndex >= 0 && startIndex < _this.itemValues.length ? startIndex : undefined;
84
- });
85
57
  return _this;
86
58
  }
87
59
  (0, _inherits2["default"])(RootPills, _Component);
88
60
  return (0, _createClass2["default"])(RootPills, [{
89
- key: "componentDidMount",
90
- value: function componentDidMount() {
91
- _logger["default"].warn(this.asProps.behavior === 'tabs', 'Use behavior `manual` instead of `tabs`. \n`tabs` is deprecated and will be removed in the next major release.', 'Pills');
92
- _logger["default"].warn(this.asProps.behavior === 'radio', 'Use behavior `auto` (or nothing, it is default value) instead of `radio`. \n`radio` is deprecated and will be removed in the next major release.', 'Pills');
93
- }
94
- }, {
95
61
  key: "uncontrolledProps",
96
62
  value: function uncontrolledProps() {
97
63
  return {
98
- value: null
64
+ value: function value(_value, e) {
65
+ return _value;
66
+ }
99
67
  };
100
68
  }
101
69
  }, {
@@ -124,7 +92,7 @@ var RootPills = /*#__PURE__*/function (_Component) {
124
92
  value: function render() {
125
93
  var _ref = this.asProps,
126
94
  _ref5;
127
- var SPills = _flexBox.Box;
95
+ var SPills = _baseComponents.Box;
128
96
  var _this$asProps2 = this.asProps,
129
97
  Children = _this$asProps2.Children,
130
98
  styles = _this$asProps2.styles,
@@ -133,10 +101,10 @@ var RootPills = /*#__PURE__*/function (_Component) {
133
101
  behavior = _this$asProps2.behavior,
134
102
  value = _this$asProps2.value;
135
103
  return _ref5 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SPills, _ref5.cn("SPills", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
136
- "role": behavior === 'radio' || behavior === 'auto' ? 'radiogroup' : 'tablist',
104
+ "role": behavior === 'auto' ? 'radiogroup' : 'tablist',
137
105
  "aria-disabled": disabled,
138
106
  "use:tabIndex": value !== null ? -1 : 0
139
- }, _ref))), /*#__PURE__*/_react["default"].createElement(_neighborLocation["default"], _ref5.cn("NeighborLocation", {
107
+ }, _ref))), /*#__PURE__*/_react["default"].createElement(_baseComponents.NeighborLocation, _ref5.cn("NeighborLocation", {
140
108
  "controlsLength": controlsLength
141
109
  }), /*#__PURE__*/_react["default"].createElement(Children, _ref5.cn("Children", {}))));
142
110
  }
@@ -152,11 +120,24 @@ var RootPills = /*#__PURE__*/function (_Component) {
152
120
  behavior: behavior !== null && behavior !== void 0 ? behavior : 'auto'
153
121
  };
154
122
  });
155
- (0, _defineProperty2["default"])(RootPills, "enhance", [(0, _a11yEnhance["default"])(optionsA11yEnhance)]);
123
+ (0, _defineProperty2["default"])(RootPills, "enhance", [(0, _a11yEnhance["default"])({
124
+ onNeighborChange: function onNeighborChange(neighborElement, props) {
125
+ if (neighborElement) {
126
+ neighborElement.focus();
127
+ if (props.behavior === 'auto') {
128
+ neighborElement.click();
129
+ }
130
+ }
131
+ },
132
+ childSelector: function childSelector(props) {
133
+ var selector = props.behavior === 'auto' ? ['role', 'radio'] : ['role', 'tab'];
134
+ return selector;
135
+ }
136
+ })]);
156
137
  function Pill(props) {
157
138
  var _ref2 = arguments[0],
158
139
  _ref6;
159
- var SPill = _flexBox.Box;
140
+ var SPill = _baseComponents.Box;
160
141
  var Children = props.Children,
161
142
  styles = props.styles,
162
143
  addonLeft = props.addonLeft,
@@ -165,15 +146,12 @@ function Pill(props) {
165
146
  disabled = props.disabled,
166
147
  index = props.index,
167
148
  behavior = props.behavior;
168
- var neighborLocation = (0, _neighborLocation.useNeighborLocationDetect)(index);
169
- var roleAreaProps = {};
170
- if (behavior === 'radio' || behavior === 'auto') {
171
- roleAreaProps.role = 'radio';
172
- roleAreaProps['aria-checked'] = selected;
173
- } else {
174
- roleAreaProps.role = 'tab';
175
- roleAreaProps['aria-selected'] = selected;
176
- }
149
+ var neighborLocation = (0, _baseComponents.useNeighborLocationDetect)(index);
150
+ var roleAreaProps = {
151
+ 'role': behavior === 'auto' ? 'radio' : 'tab',
152
+ 'aria-checked': behavior === 'auto' ? selected : undefined,
153
+ 'aria-selected': behavior !== 'auto' ? selected : undefined
154
+ };
177
155
  return _ref6 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SPill, _ref6.cn("SPill", (0, _objectSpread2["default"])({}, (0, _core.assignProps)((0, _objectSpread2["default"])({
178
156
  "tag": 'button',
179
157
  "type": 'button',
@@ -189,7 +167,7 @@ function Pill(props) {
189
167
  function Text(props) {
190
168
  var _ref3 = arguments[0],
191
169
  _ref7;
192
- var SText = _flexBox.Box;
170
+ var SText = _baseComponents.Box;
193
171
  return _ref7 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SText, _ref7.cn("SText", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
194
172
  "tag": 'span'
195
173
  }, _ref3))));
@@ -197,19 +175,19 @@ function Text(props) {
197
175
  function Addon(props) {
198
176
  var _ref4 = arguments[0],
199
177
  _ref8;
200
- var SAddon = _flexBox.Box;
178
+ var SAddon = _baseComponents.Box;
201
179
  return _ref8 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SAddon, _ref8.cn("SAddon", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
202
180
  "tag": 'span'
203
181
  }, _ref4))));
204
182
  }
183
+ var wrapPills = exports.wrapPills = function wrapPills(wrapper) {
184
+ return wrapper;
185
+ };
205
186
  var Pills = (0, _core.createComponent)(RootPills, {
206
187
  Item: [Pill, {
207
188
  Text: Text,
208
189
  Addon: Addon
209
190
  }]
210
191
  });
211
- var wrapPills = exports.wrapPills = function wrapPills(wrapper) {
212
- return wrapper;
213
- };
214
192
  var _default = exports["default"] = Pills;
215
193
  //# sourceMappingURL=Pills.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Pills.js","names":["_core","require","_addonTextChildren","_interopRequireDefault","_a11yEnhance","_logger","_flexBox","_neighborLocation","_interopRequireWildcard","_react","style","sstyled","insert","optionsA11yEnhance","onNeighborChange","neighborElement","props","focus","behavior","click","childSelector","RootPills","_Component","_this","_classCallCheck2","_len","arguments","length","args","Array","_key","_callSuper2","concat","_defineProperty2","value","e","handlers","event","key","preventDefault","startIndex","type","selectable","itemValues","element","itemRefs","disabled","undefined","_inherits2","_createClass2","componentDidMount","log","warn","asProps","uncontrolledProps","getItemProps","index","_this$asProps","size","isSelected","selected","tabIndex","onClick","bindHandlerClick","onKeyDown","bindHandleKeyDown","render","_ref","_ref5","SPills","Box","_this$asProps2","Children","styles","controlsLength","createElement","cn","_objectSpread2","assignProps","Component","_ref9","defaultValue","a11yEnhance","Pill","_ref2","arguments[0]","_ref6","SPill","addonLeft","addonRight","neighborLocation","useNeighborLocationDetect","roleAreaProps","role","Pills","Item","Addon","tag","addonTextChildren","Text","_ref3","_ref7","SText","_ref4","_ref8","SAddon","createComponent","wrapPills","exports","wrapper","_default"],"sources":["../../src/Pills.jsx"],"sourcesContent":["import { createComponent, Component, sstyled, Root } from '@semcore/core';\nimport addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';\nimport a11yEnhance from '@semcore/core/lib/utils/enhances/a11yEnhance';\nimport log from '@semcore/core/lib/utils/logger';\nimport { Box } from '@semcore/flex-box';\nimport NeighborLocation, { useNeighborLocationDetect } from '@semcore/neighbor-location';\nimport React from 'react';\n\nimport style from './style/pills.shadow.css';\n\nconst optionsA11yEnhance = {\n onNeighborChange: (neighborElement, props) => {\n if (neighborElement) {\n neighborElement.focus();\n if (props.behavior === 'auto' || props.behavior === 'radio') {\n neighborElement.click();\n }\n }\n },\n childSelector: (props) =>\n props.behavior === 'auto' || props.behavior === 'radio' ? ['role', 'radio'] : ['role', 'tab'],\n};\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 ?? 'auto',\n });\n\n itemValues = [];\n static enhance = [a11yEnhance(optionsA11yEnhance)];\n\n componentDidMount() {\n log.warn(\n this.asProps.behavior === 'tabs',\n 'Use behavior `manual` instead of `tabs`. \\n`tabs` is deprecated and will be removed in the next major release.',\n 'Pills',\n );\n\n log.warn(\n this.asProps.behavior === 'radio',\n 'Use behavior `auto` (or nothing, it is default value) instead of `radio`. \\n`radio` is deprecated and will be removed in the next major release.',\n 'Pills',\n );\n }\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n bindHandlerClick = (value) => (e) => {\n this.handlers.value(value, e);\n };\n\n bindHandleKeyDown = (value) => (event) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n this.handlers.value(value, event);\n }\n };\n\n getItemProps(props, index) {\n const { value, size, disabled, behavior } = this.asProps;\n const isSelected = value === props.value;\n\n this.itemValues[index] = props.value;\n return {\n index: index,\n size,\n disabled,\n selected: isSelected,\n behavior,\n tabIndex: isSelected ? 0 : -1,\n onClick: this.bindHandlerClick(props.value),\n onKeyDown: this.bindHandleKeyDown(props.value),\n };\n }\n\n changeIndex = (startIndex, type) => {\n let selectable = false;\n\n while (!selectable && startIndex >= 0 && startIndex < this.itemValues.length) {\n if (type === 'increment') startIndex++;\n if (type === 'decrement') startIndex--;\n\n const element = this.itemRefs[startIndex];\n\n if (element?.disabled === false) {\n selectable = true;\n }\n }\n\n return startIndex >= 0 && startIndex < this.itemValues.length ? startIndex : undefined;\n };\n\n render() {\n const SPills = Root;\n const { Children, styles, controlsLength, disabled, behavior, value } = this.asProps;\n\n return sstyled(styles)(\n <SPills\n render={Box}\n role={behavior === 'radio' || behavior === 'auto' ? 'radiogroup' : 'tablist'}\n aria-disabled={disabled}\n use:tabIndex={value !== null ? -1 : 0}\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' || behavior === 'auto') {\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 tabIndex={0}\n neighborLocation={neighborLocation}\n aria-disabled={disabled}\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\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 const wrapPills = (wrapper) => wrapper;\n\nexport default Pills;\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,OAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAC,uBAAA,CAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAN,sBAAA,CAAAF,OAAA;AAA0B;AAAA,IAAAS,KAAA,8BAAAV,KAAA,CAAAW,OAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;E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AAAC,OAAA,CAAAD,SAAA,GAAG,SAAZA,SAASA,CAAIE,OAAO;EAAA,OAAKA,OAAO;AAAA;AAAC,IAAAC,QAAA,GAAAF,OAAA,cAE/Bd,KAAK","ignoreList":[]}
1
+ {"version":3,"file":"Pills.js","names":["_core","require","_baseComponents","_addonTextChildren","_interopRequireDefault","_a11yEnhance","_react","style","sstyled","insert","RootPills","_Component","_this","_classCallCheck2","_len","arguments","length","args","Array","_key","_callSuper2","concat","_defineProperty2","value","e","handlers","key","preventDefault","_inherits2","_createClass2","uncontrolledProps","getItemProps","props","index","_this$asProps","asProps","size","disabled","behavior","isSelected","itemValues","selected","tabIndex","onClick","bindHandlerClick","onKeyDown","bindHandleKeyDown","render","_ref","_ref5","SPills","Box","_this$asProps2","Children","styles","controlsLength","createElement","cn","_objectSpread2","assignProps","NeighborLocation","Component","_ref9","defaultValue","a11yEnhance","onNeighborChange","neighborElement","focus","click","childSelector","selector","Pill","_ref2","arguments[0]","_ref6","SPill","addonLeft","addonRight","neighborLocation","useNeighborLocationDetect","roleAreaProps","undefined","Pills","Item","Addon","tag","addonTextChildren","Text","_ref3","_ref7","SText","_ref4","_ref8","SAddon","wrapPills","exports","wrapper","createComponent","_default"],"sources":["../../src/Pills.tsx"],"sourcesContent":["import { NeighborLocation, Box, useNeighborLocationDetect } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport { createComponent, Component, sstyled, Root } from '@semcore/core';\nimport addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';\nimport a11yEnhance from '@semcore/core/lib/utils/enhances/a11yEnhance';\nimport React from 'react';\n\nimport type { NSPills } from './Pills.type';\nimport style from './style/pills.shadow.css';\n\nclass RootPills extends Component<\n Intergalactic.InternalTypings.InferComponentProps<NSPills.Component>,\n typeof RootPills.enhance,\n NSPills.Handlers\n> {\n static displayName = 'Pills';\n static style = style;\n static defaultProps = ({ behavior }: NSPills.Props) => ({\n size: 'm',\n defaultValue: null,\n behavior: behavior ?? 'auto',\n });\n\n itemValues: Array<NSPills.Pill.Props['value']> = [];\n\n static enhance = [a11yEnhance({\n onNeighborChange: (neighborElement, props) => {\n if (neighborElement) {\n neighborElement.focus();\n if (props.behavior === 'auto') {\n neighborElement.click();\n }\n }\n },\n childSelector: (props) => {\n const selector = props.behavior === 'auto' ? ['role', 'radio'] : ['role', 'tab'];\n\n return selector as [string, string];\n },\n })] as const;\n\n uncontrolledProps() {\n return {\n value: (value: NSPills.Pill.Props['value'], e: React.SyntheticEvent) => value,\n };\n }\n\n bindHandlerClick = (value: NSPills.Pill.Props['value']) => (e: React.MouseEvent) => {\n this.handlers.value(value, e);\n };\n\n bindHandleKeyDown = (value: NSPills.Pill.Props['value']) => (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n this.handlers.value(value, e);\n }\n };\n\n getItemProps(props: NSPills.Pill.Props, index: number) {\n const { value, size, disabled, behavior } = this.asProps;\n const isSelected = value === props.value;\n\n this.itemValues[index] = props.value;\n\n return {\n index: index,\n size,\n disabled,\n selected: isSelected,\n behavior,\n tabIndex: isSelected ? 0 : -1,\n onClick: this.bindHandlerClick(props.value),\n onKeyDown: this.bindHandleKeyDown(props.value),\n };\n }\n\n render() {\n const SPills = Root;\n const { Children, styles, controlsLength, disabled, behavior, value } = this.asProps;\n\n return sstyled(styles)(\n <SPills\n render={Box}\n role={behavior === 'auto' ? 'radiogroup' : 'tablist'}\n aria-disabled={disabled}\n use:tabIndex={value !== null ? -1 : 0}\n >\n <NeighborLocation controlsLength={controlsLength}>\n <Children />\n </NeighborLocation>\n </SPills>,\n );\n }\n}\n\nfunction Pill(props: Intergalactic.InternalTypings.InferChildComponentProps<NSPills.Pill.Component, typeof RootPills, 'Item'>) {\n const SPill = Root;\n const { Children, styles, addonLeft, addonRight, selected, disabled, index, behavior } = props;\n const neighborLocation = useNeighborLocationDetect(index);\n\n const roleAreaProps = {\n 'role': behavior === 'auto' ? 'radio' : 'tab',\n 'aria-checked': behavior === 'auto' ? selected : undefined,\n 'aria-selected': behavior !== 'auto' ? selected : undefined,\n };\n\n return sstyled(styles)(\n <SPill\n render={Box}\n tag='button'\n type='button'\n tabIndex={0}\n neighborLocation={neighborLocation}\n aria-disabled={disabled}\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\nfunction Text(props: Intergalactic.InternalTypings.InferComponentProps<NSPills.Pill.Text.Component>) {\n const SText = Root;\n return sstyled(props.styles)(<SText render={Box} tag='span' />);\n}\n\nfunction Addon(props: Intergalactic.InternalTypings.InferComponentProps<NSPills.Pill.Addon.Component>) {\n const SAddon = Root;\n return sstyled(props.styles)(<SAddon render={Box} tag='span' />);\n}\n\nexport const wrapPills = <PropsExtending extends {}>(wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<NSPills.WrapComponent>\n > &\n PropsExtending,\n) => React.ReactNode) => wrapper as NSPills.WrapComponent<PropsExtending>;\n\nconst Pills = createComponent(RootPills, {\n Item: [Pill, { Text, Addon }],\n}) as unknown as NSPills.Component;\n\nexport default Pills;\n"],"mappings":";;;;;;;;;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAFA,IAAAC,eAAA,GAAAD,OAAA;AAGA,IAAAE,kBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,YAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,MAAA,GAAAF,sBAAA,CAAAH,OAAA;AAA0B;AAAA,IAAAM,KAAA,8BAAAP,KAAA,CAAAQ,OAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAAA,IAKpBC,SAAS,0BAAAC,UAAA;EAAA,SAAA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A,OAAO;AAAA,CAAyC;AAEzE,IAAMd,KAAK,GAAG,IAAAe,qBAAe,EAACvF,SAAS,EAAE;EACvCyE,IAAI,EAAE,CAACZ,IAAI,EAAE;IAAEgB,IAAI,EAAJA,IAAI;IAAEH,KAAK,EAALA;EAAM,CAAC;AAC9B,CAAC,CAAiC;AAAC,IAAAc,QAAA,GAAAH,OAAA,cAEpBb,KAAK","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=Pills.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Pills.type.js","names":[],"sources":["../../src/Pills.type.ts"],"sourcesContent":["import type { Box, BoxProps, NeighborItemProps, NeighborLocationProps } from '@semcore/base-components';\nimport type { PropGetterFn, Intergalactic } from '@semcore/core';\nimport type React from 'react';\n\ndeclare namespace NSPills {\n // TODO: It looks like the value isn't accurate. Revise and align it with the component's logic.\n type Value = string | number | boolean | null;\n type Props<T extends NSPills.Value = NSPills.Value> = NeighborLocationProps & BoxProps & {\n /** Pills size */\n size?: 'l' | 'm';\n /** Disabled state */\n disabled?: boolean;\n /** Called when the selection is changed */\n onChange?:\n | ((value: T, e?: React.SyntheticEvent<HTMLSpanElement>) => void)\n | React.Dispatch<React.SetStateAction<T>>;\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 `auto` pressing left and right arrows\n * selects corresponding sibling pill.\n *\n * It's recommended to use `auto` behavior in forms\n * while `manual` behavior for navigation and layout.\n * @default tabs\n */\n behavior?:\n | 'auto'\n | 'manual';\n };\n type Ctx = {\n getItemProps: PropGetterFn;\n };\n type Handlers = {\n value: (value: Props['value'], event: React.SyntheticEvent) => Props['value'];\n };\n namespace Pill {\n type Props = BoxProps & NeighborItemProps & {\n /** Pill value */\n value?: NSPills.Value;\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 namespace Text {\n type Component = typeof Box;\n }\n namespace Addon {\n type Component = typeof Box;\n }\n\n type Component = Intergalactic.Component<'button', Props, [handlers: Handlers]>;\n }\n\n type WrapComponent<PropsExtending = {}> = (<\n V extends Value,\n Tag extends Intergalactic.Tag = 'div',\n >(\n props: Intergalactic.InternalTypings.ComponentProps<\n Tag,\n 'div',\n Props<V>,\n Ctx,\n [handlers: Handlers]\n > &\n PropsExtending,\n ) => Intergalactic.InternalTypings.ComponentRenderingResults) &\n Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', Props>;\n\n type Component = WrapComponent & {\n Item: Pill.Component & {\n Text: Pill.Text.Component;\n Addon: Pill.Addon.Component;\n };\n };\n}\n\n/** @deprecated It will be removed in v18. */\nexport type PillsValue = NSPills.Value;\n/** @deprecated It will be removed in v18. */\nexport type PillsProps<T extends PillsValue = PillsValue> = NSPills.Props<T>;\n/** @deprecated It will be removed in v18. */\nexport type PillProps = NSPills.Pill.Props;\n/** @deprecated It will be removed in v18. */\nexport type PillsContext = NSPills.Ctx;\n/** @deprecated It will be removed in v18. */\nexport type PillsHandlers = NSPills.Handlers;\n\nexport type { NSPills };\n"],"mappings":"","ignoreList":[]}
package/lib/cjs/index.js CHANGED
@@ -4,22 +4,31 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- var _exportNames = {};
7
+ var _exportNames = {
8
+ wrapPills: true
9
+ };
8
10
  Object.defineProperty(exports, "default", {
9
11
  enumerable: true,
10
12
  get: function get() {
11
13
  return _Pills["default"];
12
14
  }
13
15
  });
16
+ Object.defineProperty(exports, "wrapPills", {
17
+ enumerable: true,
18
+ get: function get() {
19
+ return _Pills.wrapPills;
20
+ }
21
+ });
14
22
  var _Pills = _interopRequireWildcard(require("./Pills"));
15
- Object.keys(_Pills).forEach(function (key) {
23
+ var _Pills2 = require("./Pills.type");
24
+ Object.keys(_Pills2).forEach(function (key) {
16
25
  if (key === "default" || key === "__esModule") return;
17
26
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
18
- if (key in exports && exports[key] === _Pills[key]) return;
27
+ if (key in exports && exports[key] === _Pills2[key]) return;
19
28
  Object.defineProperty(exports, key, {
20
29
  enumerable: true,
21
30
  get: function get() {
22
- return _Pills[key];
31
+ return _Pills2[key];
23
32
  }
24
33
  });
25
34
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_Pills","_interopRequireWildcard","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sources":["../../src/index.js"],"sourcesContent":["export { default } from './Pills';\nexport * from './Pills';\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACAC,MAAA,CAAAC,IAAA,CAAAJ,MAAA,EAAAK,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAN,MAAA,CAAAM,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAd,MAAA,CAAAM,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_Pills","_interopRequireWildcard","require","_Pills2","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sources":["../../src/index.ts"],"sourcesContent":["export { default, wrapPills } from './Pills';\nexport * from './Pills.type';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,OAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,OAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAZ,OAAA,CAAAI,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -7,7 +7,7 @@ SPills {
7
7
 
8
8
  SPill[selected] {
9
9
  background: var(--intergalactic-control-secondary-info, oklch(0.527 0.264 262.9 / 0.039));
10
- border-color: var(--intergalactic-border-info-active, oklch(0.443 0.273 264.2 / 0.419));
10
+ border-color: var(--intergalactic-border-info-active, oklch(0.7 0.131 275.2));
11
11
  z-index: 3;
12
12
  }
13
13
  SPill:focus-visible, SPill[selected] {
package/lib/es6/Pills.js CHANGED
@@ -9,42 +9,27 @@ import { assignProps as _assignProps4 } from "@semcore/core";
9
9
  import { assignProps as _assignProps3 } from "@semcore/core";
10
10
  import { assignProps as _assignProps2 } from "@semcore/core";
11
11
  import { assignProps as _assignProps } from "@semcore/core";
12
+ import { NeighborLocation, Box, useNeighborLocationDetect } from '@semcore/base-components';
12
13
  import { createComponent, Component, sstyled, Root } from '@semcore/core';
13
14
  import addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';
14
15
  import a11yEnhance from '@semcore/core/lib/utils/enhances/a11yEnhance';
15
- import log from '@semcore/core/lib/utils/logger';
16
- import { Box } from '@semcore/flex-box';
17
- import NeighborLocation, { useNeighborLocationDetect } from '@semcore/neighbor-location';
18
16
  import React from 'react';
19
17
  /*!__reshadow-styles__:"./style/pills.shadow.css"*/
20
- var style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___SPills_lodqe_gg_{display:inline-flex;align-items:center;justify-content:center;isolation:isolate;border-radius:var(--intergalactic-control-rounded, 6px)}.___SPills_lodqe_gg_ .___SPill_lodqe_gg_.__selected_lodqe_gg_{background:var(--intergalactic-control-secondary-info, rgba(0, 81, 255, 0.039));border-color:var(--intergalactic-border-info-active, rgba(0, 40, 230, 0.419));z-index:3}@supports (color:color(display-p3 0 0 0%)){.___SPills_lodqe_gg_ .___SPill_lodqe_gg_.__selected_lodqe_gg_{background:var(--intergalactic-control-secondary-info, rgba(0, 81, 255, 0.039))}@media (color-gamut:p3){.___SPills_lodqe_gg_ .___SPill_lodqe_gg_.__selected_lodqe_gg_{background:var(--intergalactic-control-secondary-info, color(display-p3 0.12567 0.31309 0.96324 / 0.039))}}}.___SPills_lodqe_gg_ .___SPill_lodqe_gg_.__selected_lodqe_gg_,.___SPills_lodqe_gg_ .___SPill_lodqe_gg_:focus-visible{z-index:3}.___SPills_lodqe_gg_ .___SPill_lodqe_gg_:active{z-index:2}@media (hover:hover){.___SPills_lodqe_gg_ .___SPill_lodqe_gg_:hover{z-index:2}}.___SPill_lodqe_gg_{display:inline-flex;align-items:center;justify-content:center;line-height:normal;position:relative;touch-action:manipulation;white-space:nowrap;-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, rgb(255, 255, 255));border:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161));border-radius:var(--intergalactic-control-rounded, 6px)}@supports (color:color(display-p3 0 0 0%)){.___SPill_lodqe_gg_{border:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___SPill_lodqe_gg_{border:1px solid var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___SPill_lodqe_gg_::-moz-focus-inner{border:0;padding:0}.___SPill_lodqe_gg_:active{outline:0;text-decoration:none}@media (hover:hover){.___SPill_lodqe_gg_:hover{background:var(--intergalactic-bg-primary-neutral-hover, rgb(248, 249, 248))}}.___SPill_lodqe_gg_.__disabled_lodqe_gg_{cursor:default;pointer-events:none}.___SPill_lodqe_gg_.__disabled_lodqe_gg_>*{opacity:var(--intergalactic-disabled-opacity, 0.4)}.___SText_lodqe_gg_{color:var(--intergalactic-text-primary, rgba(1, 5, 0, 0.899));display:inline-flex}.___SAddon_lodqe_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583));display:inline-flex;align-items:center;justify-content:center}@supports (color:color(display-p3 0 0 0%)){.___SAddon_lodqe_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@media (color-gamut:p3){.___SAddon_lodqe_gg_{color:var(--intergalactic-text-secondary, color(display-p3 0.00228 0.01289 0.00252 / 0.583))}}}.___SPill_lodqe_gg_._size_m_lodqe_gg_{height:var(--intergalactic-form-control-m, 28px);min-width:var(--intergalactic-form-control-m, 28px);font-size:var(--intergalactic-fs-200, 14px)}.___SPill_lodqe_gg_._size_l_lodqe_gg_ .___SText_lodqe_gg_,.___SPill_lodqe_gg_._size_m_lodqe_gg_ .___SText_lodqe_gg_{margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_lodqe_gg_._size_m_lodqe_gg_ .___SAddon_lodqe_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x, 8px)}.___SPill_lodqe_gg_._size_m_lodqe_gg_ .___SAddon_lodqe_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_lodqe_gg_._size_m_lodqe_gg_ .___SAddon_lodqe_gg_:only-child{margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_lodqe_gg_._size_l_lodqe_gg_{height:var(--intergalactic-form-control-l, 40px);min-width:var(--intergalactic-form-control-l, 40px);font-size:var(--intergalactic-fs-300, 16px)}.___SPill_lodqe_gg_._size_l_lodqe_gg_ .___SAddon_lodqe_gg_:only-child,.___SPill_lodqe_gg_._size_l_lodqe_gg_ .___SText_lodqe_gg_:only-child{margin-left:var(--intergalactic-spacing-3x, 12px);margin-right:var(--intergalactic-spacing-3x, 12px)}.___SPill_lodqe_gg_._size_l_lodqe_gg_ .___SAddon_lodqe_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-3x, 12px)}.___SPill_lodqe_gg_._size_l_lodqe_gg_ .___SAddon_lodqe_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-3x, 12px)}.___SPill_lodqe_gg_._neighborLocation_right_lodqe_gg_{border-top-right-radius:0;border-bottom-right-radius:0}.___SPill_lodqe_gg_._neighborLocation_both_lodqe_gg_{border-radius:0;margin-left:-1px}.___SPill_lodqe_gg_._neighborLocation_left_lodqe_gg_{border-top-left-radius:0;border-bottom-left-radius:0;margin-left:-1px}", /*__inner_css_end__*/"lodqe_gg_"),
18
+ var style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___SPills_x9pvr_gg_{display:inline-flex;align-items:center;justify-content:center;isolation:isolate;border-radius:var(--intergalactic-control-rounded, 6px)}.___SPills_x9pvr_gg_ .___SPill_x9pvr_gg_.__selected_x9pvr_gg_{background:var(--intergalactic-control-secondary-info, rgba(0, 81, 255, 0.039));border-color:var(--intergalactic-border-info-active, rgb(135, 150, 239));z-index:3}@supports (color:color(display-p3 0 0 0%)){.___SPills_x9pvr_gg_ .___SPill_x9pvr_gg_.__selected_x9pvr_gg_{background:var(--intergalactic-control-secondary-info, rgba(0, 81, 255, 0.039))}@media (color-gamut:p3){.___SPills_x9pvr_gg_ .___SPill_x9pvr_gg_.__selected_x9pvr_gg_{background:var(--intergalactic-control-secondary-info, color(display-p3 0.12567 0.31309 0.96324 / 0.039))}}}.___SPills_x9pvr_gg_ .___SPill_x9pvr_gg_.__selected_x9pvr_gg_,.___SPills_x9pvr_gg_ .___SPill_x9pvr_gg_:focus-visible{z-index:3}.___SPills_x9pvr_gg_ .___SPill_x9pvr_gg_:active{z-index:2}@media (hover:hover){.___SPills_x9pvr_gg_ .___SPill_x9pvr_gg_:hover{z-index:2}}.___SPill_x9pvr_gg_{display:inline-flex;align-items:center;justify-content:center;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;-webkit-text-decoration: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, rgb(255, 255, 255));border:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161));border-radius:var(--intergalactic-control-rounded, 6px)}@supports (color:color(display-p3 0 0 0%)){.___SPill_x9pvr_gg_{border:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___SPill_x9pvr_gg_{border:1px solid var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___SPill_x9pvr_gg_::-moz-focus-inner{border:0;padding:0}.___SPill_x9pvr_gg_:active{outline:0;-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___SPill_x9pvr_gg_:hover{background:var(--intergalactic-bg-primary-neutral-hover, rgb(248, 249, 248))}}.___SPill_x9pvr_gg_.__disabled_x9pvr_gg_{cursor:default;pointer-events:none}.___SPill_x9pvr_gg_.__disabled_x9pvr_gg_>*{opacity:var(--intergalactic-disabled-opacity, 0.4)}.___SText_x9pvr_gg_{color:var(--intergalactic-text-primary, rgba(1, 5, 0, 0.899));display:inline-flex}.___SAddon_x9pvr_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583));display:inline-flex;align-items:center;justify-content:center}@supports (color:color(display-p3 0 0 0%)){.___SAddon_x9pvr_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@media (color-gamut:p3){.___SAddon_x9pvr_gg_{color:var(--intergalactic-text-secondary, color(display-p3 0.00228 0.01289 0.00252 / 0.583))}}}.___SPill_x9pvr_gg_._size_m_x9pvr_gg_{height:var(--intergalactic-form-control-m, 28px);min-width:var(--intergalactic-form-control-m, 28px);font-size:var(--intergalactic-fs-200, 14px)}.___SPill_x9pvr_gg_._size_l_x9pvr_gg_ .___SText_x9pvr_gg_,.___SPill_x9pvr_gg_._size_m_x9pvr_gg_ .___SText_x9pvr_gg_{margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_x9pvr_gg_._size_m_x9pvr_gg_ .___SAddon_x9pvr_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x, 8px)}.___SPill_x9pvr_gg_._size_m_x9pvr_gg_ .___SAddon_x9pvr_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_x9pvr_gg_._size_m_x9pvr_gg_ .___SAddon_x9pvr_gg_:only-child{margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_x9pvr_gg_._size_l_x9pvr_gg_{height:var(--intergalactic-form-control-l, 40px);min-width:var(--intergalactic-form-control-l, 40px);font-size:var(--intergalactic-fs-300, 16px)}.___SPill_x9pvr_gg_._size_l_x9pvr_gg_ .___SAddon_x9pvr_gg_:only-child,.___SPill_x9pvr_gg_._size_l_x9pvr_gg_ .___SText_x9pvr_gg_:only-child{margin-left:var(--intergalactic-spacing-3x, 12px);margin-right:var(--intergalactic-spacing-3x, 12px)}.___SPill_x9pvr_gg_._size_l_x9pvr_gg_ .___SAddon_x9pvr_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-3x, 12px)}.___SPill_x9pvr_gg_._size_l_x9pvr_gg_ .___SAddon_x9pvr_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-3x, 12px)}.___SPill_x9pvr_gg_._neighborLocation_right_x9pvr_gg_{border-top-right-radius:0;border-bottom-right-radius:0}.___SPill_x9pvr_gg_._neighborLocation_both_x9pvr_gg_{border-radius:0;margin-left:-1px}.___SPill_x9pvr_gg_._neighborLocation_left_x9pvr_gg_{border-top-left-radius:0;border-bottom-left-radius:0;margin-left:-1px}", /*__inner_css_end__*/"x9pvr_gg_"),
21
19
  /*__reshadow_css_end__*/
22
20
  {
23
- "__SText": "___SText_lodqe_gg_",
24
- "__SAddon": "___SAddon_lodqe_gg_",
25
- "__SPill": "___SPill_lodqe_gg_",
26
- "_neighborLocation_right": "_neighborLocation_right_lodqe_gg_",
27
- "_neighborLocation_both": "_neighborLocation_both_lodqe_gg_",
28
- "_neighborLocation_left": "_neighborLocation_left_lodqe_gg_",
29
- "__SPills": "___SPills_lodqe_gg_",
30
- "_selected": "__selected_lodqe_gg_",
31
- "_disabled": "__disabled_lodqe_gg_",
32
- "_size_m": "_size_m_lodqe_gg_",
33
- "_size_l": "_size_l_lodqe_gg_"
21
+ "__SText": "___SText_x9pvr_gg_",
22
+ "__SAddon": "___SAddon_x9pvr_gg_",
23
+ "__SPill": "___SPill_x9pvr_gg_",
24
+ "_neighborLocation_right": "_neighborLocation_right_x9pvr_gg_",
25
+ "_neighborLocation_both": "_neighborLocation_both_x9pvr_gg_",
26
+ "_neighborLocation_left": "_neighborLocation_left_x9pvr_gg_",
27
+ "__SPills": "___SPills_x9pvr_gg_",
28
+ "_selected": "__selected_x9pvr_gg_",
29
+ "_disabled": "__disabled_x9pvr_gg_",
30
+ "_size_m": "_size_m_x9pvr_gg_",
31
+ "_size_l": "_size_l_x9pvr_gg_"
34
32
  });
35
- var optionsA11yEnhance = {
36
- onNeighborChange: function onNeighborChange(neighborElement, props) {
37
- if (neighborElement) {
38
- neighborElement.focus();
39
- if (props.behavior === 'auto' || props.behavior === 'radio') {
40
- neighborElement.click();
41
- }
42
- }
43
- },
44
- childSelector: function childSelector(props) {
45
- return props.behavior === 'auto' || props.behavior === 'radio' ? ['role', 'radio'] : ['role', 'tab'];
46
- }
47
- };
48
33
  var RootPills = /*#__PURE__*/function (_Component) {
49
34
  function RootPills() {
50
35
  var _this;
@@ -60,39 +45,23 @@ var RootPills = /*#__PURE__*/function (_Component) {
60
45
  };
61
46
  });
62
47
  _defineProperty(_this, "bindHandleKeyDown", function (value) {
63
- return function (event) {
64
- if (event.key === 'Enter' || event.key === ' ') {
65
- event.preventDefault();
66
- _this.handlers.value(value, event);
48
+ return function (e) {
49
+ if (e.key === 'Enter' || e.key === ' ') {
50
+ e.preventDefault();
51
+ _this.handlers.value(value, e);
67
52
  }
68
53
  };
69
54
  });
70
- _defineProperty(_this, "changeIndex", function (startIndex, type) {
71
- var selectable = false;
72
- while (!selectable && startIndex >= 0 && startIndex < _this.itemValues.length) {
73
- if (type === 'increment') startIndex++;
74
- if (type === 'decrement') startIndex--;
75
- var element = _this.itemRefs[startIndex];
76
- if ((element === null || element === void 0 ? void 0 : element.disabled) === false) {
77
- selectable = true;
78
- }
79
- }
80
- return startIndex >= 0 && startIndex < _this.itemValues.length ? startIndex : undefined;
81
- });
82
55
  return _this;
83
56
  }
84
57
  _inherits(RootPills, _Component);
85
58
  return _createClass(RootPills, [{
86
- key: "componentDidMount",
87
- value: function componentDidMount() {
88
- log.warn(this.asProps.behavior === 'tabs', 'Use behavior `manual` instead of `tabs`. \n`tabs` is deprecated and will be removed in the next major release.', 'Pills');
89
- log.warn(this.asProps.behavior === 'radio', 'Use behavior `auto` (or nothing, it is default value) instead of `radio`. \n`radio` is deprecated and will be removed in the next major release.', 'Pills');
90
- }
91
- }, {
92
59
  key: "uncontrolledProps",
93
60
  value: function uncontrolledProps() {
94
61
  return {
95
- value: null
62
+ value: function value(_value, e) {
63
+ return _value;
64
+ }
96
65
  };
97
66
  }
98
67
  }, {
@@ -130,7 +99,7 @@ var RootPills = /*#__PURE__*/function (_Component) {
130
99
  behavior = _this$asProps2.behavior,
131
100
  value = _this$asProps2.value;
132
101
  return _ref5 = sstyled(styles), /*#__PURE__*/React.createElement(SPills, _ref5.cn("SPills", _objectSpread({}, _assignProps({
133
- "role": behavior === 'radio' || behavior === 'auto' ? 'radiogroup' : 'tablist',
102
+ "role": behavior === 'auto' ? 'radiogroup' : 'tablist',
134
103
  "aria-disabled": disabled,
135
104
  "use:tabIndex": value !== null ? -1 : 0
136
105
  }, _ref))), /*#__PURE__*/React.createElement(NeighborLocation, _ref5.cn("NeighborLocation", {
@@ -149,7 +118,20 @@ _defineProperty(RootPills, "defaultProps", function (_ref9) {
149
118
  behavior: behavior !== null && behavior !== void 0 ? behavior : 'auto'
150
119
  };
151
120
  });
152
- _defineProperty(RootPills, "enhance", [a11yEnhance(optionsA11yEnhance)]);
121
+ _defineProperty(RootPills, "enhance", [a11yEnhance({
122
+ onNeighborChange: function onNeighborChange(neighborElement, props) {
123
+ if (neighborElement) {
124
+ neighborElement.focus();
125
+ if (props.behavior === 'auto') {
126
+ neighborElement.click();
127
+ }
128
+ }
129
+ },
130
+ childSelector: function childSelector(props) {
131
+ var selector = props.behavior === 'auto' ? ['role', 'radio'] : ['role', 'tab'];
132
+ return selector;
133
+ }
134
+ })]);
153
135
  function Pill(props) {
154
136
  var _ref2 = arguments[0],
155
137
  _ref6;
@@ -163,14 +145,11 @@ function Pill(props) {
163
145
  index = props.index,
164
146
  behavior = props.behavior;
165
147
  var neighborLocation = useNeighborLocationDetect(index);
166
- var roleAreaProps = {};
167
- if (behavior === 'radio' || behavior === 'auto') {
168
- roleAreaProps.role = 'radio';
169
- roleAreaProps['aria-checked'] = selected;
170
- } else {
171
- roleAreaProps.role = 'tab';
172
- roleAreaProps['aria-selected'] = selected;
173
- }
148
+ var roleAreaProps = {
149
+ 'role': behavior === 'auto' ? 'radio' : 'tab',
150
+ 'aria-checked': behavior === 'auto' ? selected : undefined,
151
+ 'aria-selected': behavior !== 'auto' ? selected : undefined
152
+ };
174
153
  return _ref6 = sstyled(styles), /*#__PURE__*/React.createElement(SPill, _ref6.cn("SPill", _objectSpread({}, _assignProps2(_objectSpread({
175
154
  "tag": 'button',
176
155
  "type": 'button',
@@ -199,14 +178,14 @@ function Addon(props) {
199
178
  "tag": 'span'
200
179
  }, _ref4))));
201
180
  }
181
+ export var wrapPills = function wrapPills(wrapper) {
182
+ return wrapper;
183
+ };
202
184
  var Pills = createComponent(RootPills, {
203
185
  Item: [Pill, {
204
186
  Text: Text,
205
187
  Addon: Addon
206
188
  }]
207
189
  });
208
- export var wrapPills = function wrapPills(wrapper) {
209
- return wrapper;
210
- };
211
190
  export default Pills;
212
191
  //# sourceMappingURL=Pills.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Pills.js","names":["createComponent","Component","sstyled","Root","addonTextChildren","a11yEnhance","log","Box","NeighborLocation","useNeighborLocationDetect","React","style","_sstyled","insert","optionsA11yEnhance","onNeighborChange","neighborElement","props","focus","behavior","click","childSelector","RootPills","_Component","_this","_classCallCheck","_len","arguments","length","args","Array","_key","_callSuper","concat","_defineProperty","value","e","handlers","event","key","preventDefault","startIndex","type","selectable","itemValues","element","itemRefs","disabled","undefined","_inherits","_createClass","componentDidMount","warn","asProps","uncontrolledProps","getItemProps","index","_this$asProps","size","isSelected","selected","tabIndex","onClick","bindHandlerClick","onKeyDown","bindHandleKeyDown","render","_ref","_ref5","SPills","_this$asProps2","Children","styles","controlsLength","createElement","cn","_objectSpread","_assignProps","_ref9","defaultValue","Pill","_ref2","arguments[0]","_ref6","SPill","addonLeft","addonRight","neighborLocation","roleAreaProps","role","_assignProps2","Pills","Item","Addon","tag","Text","_ref3","_ref7","SText","_assignProps3","_ref4","_ref8","SAddon","_assignProps4","wrapPills","wrapper"],"sources":["../../src/Pills.jsx"],"sourcesContent":["import { createComponent, Component, sstyled, Root } from '@semcore/core';\nimport addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';\nimport a11yEnhance from '@semcore/core/lib/utils/enhances/a11yEnhance';\nimport log from '@semcore/core/lib/utils/logger';\nimport { Box } from '@semcore/flex-box';\nimport NeighborLocation, { useNeighborLocationDetect } from '@semcore/neighbor-location';\nimport React from 'react';\n\nimport style from './style/pills.shadow.css';\n\nconst optionsA11yEnhance = {\n onNeighborChange: (neighborElement, props) => {\n if (neighborElement) {\n neighborElement.focus();\n if (props.behavior === 'auto' || props.behavior === 'radio') {\n neighborElement.click();\n }\n }\n },\n childSelector: (props) =>\n props.behavior === 'auto' || props.behavior === 'radio' ? ['role', 'radio'] : ['role', 'tab'],\n};\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 ?? 'auto',\n });\n\n itemValues = [];\n static enhance = [a11yEnhance(optionsA11yEnhance)];\n\n componentDidMount() {\n log.warn(\n this.asProps.behavior === 'tabs',\n 'Use behavior `manual` instead of `tabs`. \\n`tabs` is deprecated and will be removed in the next major release.',\n 'Pills',\n );\n\n log.warn(\n this.asProps.behavior === 'radio',\n 'Use behavior `auto` (or nothing, it is default value) instead of `radio`. \\n`radio` is deprecated and will be removed in the next major release.',\n 'Pills',\n );\n }\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n bindHandlerClick = (value) => (e) => {\n this.handlers.value(value, e);\n };\n\n bindHandleKeyDown = (value) => (event) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n this.handlers.value(value, event);\n }\n };\n\n getItemProps(props, index) {\n const { value, size, disabled, behavior } = this.asProps;\n const isSelected = value === props.value;\n\n this.itemValues[index] = props.value;\n return {\n index: index,\n size,\n disabled,\n selected: isSelected,\n behavior,\n tabIndex: isSelected ? 0 : -1,\n onClick: this.bindHandlerClick(props.value),\n onKeyDown: this.bindHandleKeyDown(props.value),\n };\n }\n\n changeIndex = (startIndex, type) => {\n let selectable = false;\n\n while (!selectable && startIndex >= 0 && startIndex < this.itemValues.length) {\n if (type === 'increment') startIndex++;\n if (type === 'decrement') startIndex--;\n\n const element = this.itemRefs[startIndex];\n\n if (element?.disabled === false) {\n selectable = true;\n }\n }\n\n return startIndex >= 0 && startIndex < this.itemValues.length ? startIndex : undefined;\n };\n\n render() {\n const SPills = Root;\n const { Children, styles, controlsLength, disabled, behavior, value } = this.asProps;\n\n return sstyled(styles)(\n <SPills\n render={Box}\n role={behavior === 'radio' || behavior === 'auto' ? 'radiogroup' : 'tablist'}\n aria-disabled={disabled}\n use:tabIndex={value !== null ? -1 : 0}\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' || behavior === 'auto') {\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 tabIndex={0}\n neighborLocation={neighborLocation}\n aria-disabled={disabled}\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\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 const wrapPills = (wrapper) => wrapper;\n\nexport default Pills;\n"],"mappings":";;;;;;;;;;;AAAA,SAASA,eAAe,EAAEC,SAAS,EAAEC,OAAO,EAAEC,IAAI,QAAQ,eAAe;AACzE,OAAOC,iBAAiB,MAAM,2CAA2C;AACzE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A,IAAI;IAAEF,KAAK,EAALA;EAAM,CAAC;AAC9B,CAAC,CAAC;AAEF,OAAO,IAAMW,SAAS,GAAG,SAAZA,SAASA,CAAIC,OAAO;EAAA,OAAKA,OAAO;AAAA;AAE7C,eAAed,KAAK","ignoreList":[]}
1
+ {"version":3,"file":"Pills.js","names":["NeighborLocation","Box","useNeighborLocationDetect","createComponent","Component","sstyled","Root","addonTextChildren","a11yEnhance","React","style","_sstyled","insert","RootPills","_Component","_this","_classCallCheck","_len","arguments","length","args","Array","_key","_callSuper","concat","_defineProperty","value","e","handlers","key","preventDefault","_inherits","_createClass","uncontrolledProps","getItemProps","props","index","_this$asProps","asProps","size","disabled","behavior","isSelected","itemValues","selected","tabIndex","onClick","bindHandlerClick","onKeyDown","bindHandleKeyDown","render","_ref","_ref5","SPills","_this$asProps2","Children","styles","controlsLength","createElement","cn","_objectSpread","_assignProps","_ref9","defaultValue","onNeighborChange","neighborElement","focus","click","childSelector","selector","Pill","_ref2","arguments[0]","_ref6","SPill","addonLeft","addonRight","neighborLocation","roleAreaProps","undefined","_assignProps2","Pills","Item","Addon","tag","Text","_ref3","_ref7","SText","_assignProps3","_ref4","_ref8","SAddon","_assignProps4","wrapPills","wrapper"],"sources":["../../src/Pills.tsx"],"sourcesContent":["import { NeighborLocation, Box, useNeighborLocationDetect } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport { createComponent, Component, sstyled, Root } from '@semcore/core';\nimport addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';\nimport a11yEnhance from '@semcore/core/lib/utils/enhances/a11yEnhance';\nimport React from 'react';\n\nimport type { NSPills } from './Pills.type';\nimport style from './style/pills.shadow.css';\n\nclass RootPills extends Component<\n Intergalactic.InternalTypings.InferComponentProps<NSPills.Component>,\n typeof RootPills.enhance,\n NSPills.Handlers\n> {\n static displayName = 'Pills';\n static style = style;\n static defaultProps = ({ behavior }: NSPills.Props) => ({\n size: 'm',\n defaultValue: null,\n behavior: behavior ?? 'auto',\n });\n\n itemValues: Array<NSPills.Pill.Props['value']> = [];\n\n static enhance = [a11yEnhance({\n onNeighborChange: (neighborElement, props) => {\n if (neighborElement) {\n neighborElement.focus();\n if (props.behavior === 'auto') {\n neighborElement.click();\n }\n }\n },\n childSelector: (props) => {\n const selector = props.behavior === 'auto' ? ['role', 'radio'] : ['role', 'tab'];\n\n return selector as [string, string];\n },\n })] as const;\n\n uncontrolledProps() {\n return {\n value: (value: NSPills.Pill.Props['value'], e: React.SyntheticEvent) => value,\n };\n }\n\n bindHandlerClick = (value: NSPills.Pill.Props['value']) => (e: React.MouseEvent) => {\n this.handlers.value(value, e);\n };\n\n bindHandleKeyDown = (value: NSPills.Pill.Props['value']) => (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n this.handlers.value(value, e);\n }\n };\n\n getItemProps(props: NSPills.Pill.Props, index: number) {\n const { value, size, disabled, behavior } = this.asProps;\n const isSelected = value === props.value;\n\n this.itemValues[index] = props.value;\n\n return {\n index: index,\n size,\n disabled,\n selected: isSelected,\n behavior,\n tabIndex: isSelected ? 0 : -1,\n onClick: this.bindHandlerClick(props.value),\n onKeyDown: this.bindHandleKeyDown(props.value),\n };\n }\n\n render() {\n const SPills = Root;\n const { Children, styles, controlsLength, disabled, behavior, value } = this.asProps;\n\n return sstyled(styles)(\n <SPills\n render={Box}\n role={behavior === 'auto' ? 'radiogroup' : 'tablist'}\n aria-disabled={disabled}\n use:tabIndex={value !== null ? -1 : 0}\n >\n <NeighborLocation controlsLength={controlsLength}>\n <Children />\n </NeighborLocation>\n </SPills>,\n );\n }\n}\n\nfunction Pill(props: Intergalactic.InternalTypings.InferChildComponentProps<NSPills.Pill.Component, typeof RootPills, 'Item'>) {\n const SPill = Root;\n const { Children, styles, addonLeft, addonRight, selected, disabled, index, behavior } = props;\n const neighborLocation = useNeighborLocationDetect(index);\n\n const roleAreaProps = {\n 'role': behavior === 'auto' ? 'radio' : 'tab',\n 'aria-checked': behavior === 'auto' ? selected : undefined,\n 'aria-selected': behavior !== 'auto' ? selected : undefined,\n };\n\n return sstyled(styles)(\n <SPill\n render={Box}\n tag='button'\n type='button'\n tabIndex={0}\n neighborLocation={neighborLocation}\n aria-disabled={disabled}\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\nfunction Text(props: Intergalactic.InternalTypings.InferComponentProps<NSPills.Pill.Text.Component>) {\n const SText = Root;\n return sstyled(props.styles)(<SText render={Box} tag='span' />);\n}\n\nfunction Addon(props: Intergalactic.InternalTypings.InferComponentProps<NSPills.Pill.Addon.Component>) {\n const SAddon = Root;\n return sstyled(props.styles)(<SAddon render={Box} tag='span' />);\n}\n\nexport const wrapPills = <PropsExtending extends {}>(wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<NSPills.WrapComponent>\n > &\n PropsExtending,\n) => React.ReactNode) => wrapper as NSPills.WrapComponent<PropsExtending>;\n\nconst Pills = createComponent(RootPills, {\n Item: [Pill, { Text, Addon }],\n}) as unknown as NSPills.Component;\n\nexport default Pills;\n"],"mappings":";;;;;;;;;;;AAAA,SAASA,gBAAgB,EAAEC,GAAG,EAAEC,yBAAyB,QAAQ,0BAA0B;AAE3F,SAASC,eAAe,EAAEC,SAAS,EAAEC,OAAO,EAAEC,IAAI,QAAQ,eAAe;AACzE,OAAOC,iBAAiB,MAAM,2CAA2C;AACzE,OAAOC,WAAW,MAAM,8CAA8C;AACtE,OAAOC,KAAK,MAAM,OAAO;AAAC;AAAA,IAAAC,KAAA,8BAAAC,QAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAAA,IAKpBC,SAAS,0BAAA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AAElC,eAAeF,KAAK","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Pills.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Pills.type.js","names":[],"sources":["../../src/Pills.type.ts"],"sourcesContent":["import type { Box, BoxProps, NeighborItemProps, NeighborLocationProps } from '@semcore/base-components';\nimport type { PropGetterFn, Intergalactic } from '@semcore/core';\nimport type React from 'react';\n\ndeclare namespace NSPills {\n // TODO: It looks like the value isn't accurate. Revise and align it with the component's logic.\n type Value = string | number | boolean | null;\n type Props<T extends NSPills.Value = NSPills.Value> = NeighborLocationProps & BoxProps & {\n /** Pills size */\n size?: 'l' | 'm';\n /** Disabled state */\n disabled?: boolean;\n /** Called when the selection is changed */\n onChange?:\n | ((value: T, e?: React.SyntheticEvent<HTMLSpanElement>) => void)\n | React.Dispatch<React.SetStateAction<T>>;\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 `auto` pressing left and right arrows\n * selects corresponding sibling pill.\n *\n * It's recommended to use `auto` behavior in forms\n * while `manual` behavior for navigation and layout.\n * @default tabs\n */\n behavior?:\n | 'auto'\n | 'manual';\n };\n type Ctx = {\n getItemProps: PropGetterFn;\n };\n type Handlers = {\n value: (value: Props['value'], event: React.SyntheticEvent) => Props['value'];\n };\n namespace Pill {\n type Props = BoxProps & NeighborItemProps & {\n /** Pill value */\n value?: NSPills.Value;\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 namespace Text {\n type Component = typeof Box;\n }\n namespace Addon {\n type Component = typeof Box;\n }\n\n type Component = Intergalactic.Component<'button', Props, [handlers: Handlers]>;\n }\n\n type WrapComponent<PropsExtending = {}> = (<\n V extends Value,\n Tag extends Intergalactic.Tag = 'div',\n >(\n props: Intergalactic.InternalTypings.ComponentProps<\n Tag,\n 'div',\n Props<V>,\n Ctx,\n [handlers: Handlers]\n > &\n PropsExtending,\n ) => Intergalactic.InternalTypings.ComponentRenderingResults) &\n Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', Props>;\n\n type Component = WrapComponent & {\n Item: Pill.Component & {\n Text: Pill.Text.Component;\n Addon: Pill.Addon.Component;\n };\n };\n}\n\n/** @deprecated It will be removed in v18. */\nexport type PillsValue = NSPills.Value;\n/** @deprecated It will be removed in v18. */\nexport type PillsProps<T extends PillsValue = PillsValue> = NSPills.Props<T>;\n/** @deprecated It will be removed in v18. */\nexport type PillProps = NSPills.Pill.Props;\n/** @deprecated It will be removed in v18. */\nexport type PillsContext = NSPills.Ctx;\n/** @deprecated It will be removed in v18. */\nexport type PillsHandlers = NSPills.Handlers;\n\nexport type { NSPills };\n"],"mappings":"","ignoreList":[]}
package/lib/es6/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { default } from './Pills';
2
- export * from './Pills';
1
+ export { default, wrapPills } from './Pills';
2
+ export * from './Pills.type';
3
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["default"],"sources":["../../src/index.js"],"sourcesContent":["export { default } from './Pills';\nexport * from './Pills';\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,SAAS;AACjC,cAAc,SAAS","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["default","wrapPills"],"sources":["../../src/index.ts"],"sourcesContent":["export { default, wrapPills } from './Pills';\nexport * from './Pills.type';\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,SAAS,QAAQ,SAAS;AAC5C,cAAc,cAAc","ignoreList":[]}
@@ -7,7 +7,7 @@ SPills {
7
7
 
8
8
  SPill[selected] {
9
9
  background: var(--intergalactic-control-secondary-info, oklch(0.527 0.264 262.9 / 0.039));
10
- border-color: var(--intergalactic-border-info-active, oklch(0.443 0.273 264.2 / 0.419));
10
+ border-color: var(--intergalactic-border-info-active, oklch(0.7 0.131 275.2));
11
11
  z-index: 3;
12
12
  }
13
13
  SPill:focus-visible, SPill[selected] {
package/lib/esm/Pills.mjs CHANGED
@@ -4,49 +4,34 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
4
4
  import _callSuper from "@babel/runtime/helpers/esm/callSuper";
5
5
  import _inherits from "@babel/runtime/helpers/esm/inherits";
6
6
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
7
- import { createComponent, sstyled, assignProps, Component } from "@semcore/core";
7
+ import { sstyled, assignProps, Component, createComponent } from "@semcore/core";
8
+ import { Box, NeighborLocation, useNeighborLocationDetect } from "@semcore/base-components";
8
9
  import addonTextChildren from "@semcore/core/lib/utils/addonTextChildren";
9
10
  import a11yEnhance from "@semcore/core/lib/utils/enhances/a11yEnhance";
10
- import log from "@semcore/core/lib/utils/logger";
11
- import { Box } from "@semcore/flex-box";
12
- import NeighborLocation, { useNeighborLocationDetect } from "@semcore/neighbor-location";
13
11
  import React from "react";
14
12
  /*!__reshadow-styles__:"./style/pills.shadow.css"*/
15
13
  var style = (
16
14
  /*__reshadow_css_start__*/
17
15
  (sstyled.insert(
18
16
  /*__inner_css_start__*/
19
- ".___SPills_lodqe_gg_{display:inline-flex;align-items:center;justify-content:center;isolation:isolate;border-radius:var(--intergalactic-control-rounded, 6px)}.___SPills_lodqe_gg_ .___SPill_lodqe_gg_.__selected_lodqe_gg_{background:var(--intergalactic-control-secondary-info, rgba(0, 81, 255, 0.039));border-color:var(--intergalactic-border-info-active, rgba(0, 40, 230, 0.419));z-index:3}@supports (color:color(display-p3 0 0 0%)){.___SPills_lodqe_gg_ .___SPill_lodqe_gg_.__selected_lodqe_gg_{background:var(--intergalactic-control-secondary-info, rgba(0, 81, 255, 0.039))}@media (color-gamut:p3){.___SPills_lodqe_gg_ .___SPill_lodqe_gg_.__selected_lodqe_gg_{background:var(--intergalactic-control-secondary-info, color(display-p3 0.12567 0.31309 0.96324 / 0.039))}}}.___SPills_lodqe_gg_ .___SPill_lodqe_gg_.__selected_lodqe_gg_,.___SPills_lodqe_gg_ .___SPill_lodqe_gg_:focus-visible{z-index:3}.___SPills_lodqe_gg_ .___SPill_lodqe_gg_:active{z-index:2}@media (hover:hover){.___SPills_lodqe_gg_ .___SPill_lodqe_gg_:hover{z-index:2}}.___SPill_lodqe_gg_{display:inline-flex;align-items:center;justify-content:center;line-height:normal;position:relative;touch-action:manipulation;white-space:nowrap;-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, rgb(255, 255, 255));border:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161));border-radius:var(--intergalactic-control-rounded, 6px)}@supports (color:color(display-p3 0 0 0%)){.___SPill_lodqe_gg_{border:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___SPill_lodqe_gg_{border:1px solid var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___SPill_lodqe_gg_::-moz-focus-inner{border:0;padding:0}.___SPill_lodqe_gg_:active{outline:0;text-decoration:none}@media (hover:hover){.___SPill_lodqe_gg_:hover{background:var(--intergalactic-bg-primary-neutral-hover, rgb(248, 249, 248))}}.___SPill_lodqe_gg_.__disabled_lodqe_gg_{cursor:default;pointer-events:none}.___SPill_lodqe_gg_.__disabled_lodqe_gg_>*{opacity:var(--intergalactic-disabled-opacity, 0.4)}.___SText_lodqe_gg_{color:var(--intergalactic-text-primary, rgba(1, 5, 0, 0.899));display:inline-flex}.___SAddon_lodqe_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583));display:inline-flex;align-items:center;justify-content:center}@supports (color:color(display-p3 0 0 0%)){.___SAddon_lodqe_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@media (color-gamut:p3){.___SAddon_lodqe_gg_{color:var(--intergalactic-text-secondary, color(display-p3 0.00228 0.01289 0.00252 / 0.583))}}}.___SPill_lodqe_gg_._size_m_lodqe_gg_{height:var(--intergalactic-form-control-m, 28px);min-width:var(--intergalactic-form-control-m, 28px);font-size:var(--intergalactic-fs-200, 14px)}.___SPill_lodqe_gg_._size_l_lodqe_gg_ .___SText_lodqe_gg_,.___SPill_lodqe_gg_._size_m_lodqe_gg_ .___SText_lodqe_gg_{margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_lodqe_gg_._size_m_lodqe_gg_ .___SAddon_lodqe_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x, 8px)}.___SPill_lodqe_gg_._size_m_lodqe_gg_ .___SAddon_lodqe_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_lodqe_gg_._size_m_lodqe_gg_ .___SAddon_lodqe_gg_:only-child{margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_lodqe_gg_._size_l_lodqe_gg_{height:var(--intergalactic-form-control-l, 40px);min-width:var(--intergalactic-form-control-l, 40px);font-size:var(--intergalactic-fs-300, 16px)}.___SPill_lodqe_gg_._size_l_lodqe_gg_ .___SAddon_lodqe_gg_:only-child,.___SPill_lodqe_gg_._size_l_lodqe_gg_ .___SText_lodqe_gg_:only-child{margin-left:var(--intergalactic-spacing-3x, 12px);margin-right:var(--intergalactic-spacing-3x, 12px)}.___SPill_lodqe_gg_._size_l_lodqe_gg_ .___SAddon_lodqe_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-3x, 12px)}.___SPill_lodqe_gg_._size_l_lodqe_gg_ .___SAddon_lodqe_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-3x, 12px)}.___SPill_lodqe_gg_._neighborLocation_right_lodqe_gg_{border-top-right-radius:0;border-bottom-right-radius:0}.___SPill_lodqe_gg_._neighborLocation_both_lodqe_gg_{border-radius:0;margin-left:-1px}.___SPill_lodqe_gg_._neighborLocation_left_lodqe_gg_{border-top-left-radius:0;border-bottom-left-radius:0;margin-left:-1px}",
17
+ ".___SPills_x9pvr_gg_{display:inline-flex;align-items:center;justify-content:center;isolation:isolate;border-radius:var(--intergalactic-control-rounded, 6px)}.___SPills_x9pvr_gg_ .___SPill_x9pvr_gg_.__selected_x9pvr_gg_{background:var(--intergalactic-control-secondary-info, rgba(0, 81, 255, 0.039));border-color:var(--intergalactic-border-info-active, rgb(135, 150, 239));z-index:3}@supports (color:color(display-p3 0 0 0%)){.___SPills_x9pvr_gg_ .___SPill_x9pvr_gg_.__selected_x9pvr_gg_{background:var(--intergalactic-control-secondary-info, rgba(0, 81, 255, 0.039))}@media (color-gamut:p3){.___SPills_x9pvr_gg_ .___SPill_x9pvr_gg_.__selected_x9pvr_gg_{background:var(--intergalactic-control-secondary-info, color(display-p3 0.12567 0.31309 0.96324 / 0.039))}}}.___SPills_x9pvr_gg_ .___SPill_x9pvr_gg_.__selected_x9pvr_gg_,.___SPills_x9pvr_gg_ .___SPill_x9pvr_gg_:focus-visible{z-index:3}.___SPills_x9pvr_gg_ .___SPill_x9pvr_gg_:active{z-index:2}@media (hover:hover){.___SPills_x9pvr_gg_ .___SPill_x9pvr_gg_:hover{z-index:2}}.___SPill_x9pvr_gg_{display:inline-flex;align-items:center;justify-content:center;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;-webkit-text-decoration: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, rgb(255, 255, 255));border:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161));border-radius:var(--intergalactic-control-rounded, 6px)}@supports (color:color(display-p3 0 0 0%)){.___SPill_x9pvr_gg_{border:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___SPill_x9pvr_gg_{border:1px solid var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___SPill_x9pvr_gg_::-moz-focus-inner{border:0;padding:0}.___SPill_x9pvr_gg_:active{outline:0;-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___SPill_x9pvr_gg_:hover{background:var(--intergalactic-bg-primary-neutral-hover, rgb(248, 249, 248))}}.___SPill_x9pvr_gg_.__disabled_x9pvr_gg_{cursor:default;pointer-events:none}.___SPill_x9pvr_gg_.__disabled_x9pvr_gg_>*{opacity:var(--intergalactic-disabled-opacity, 0.4)}.___SText_x9pvr_gg_{color:var(--intergalactic-text-primary, rgba(1, 5, 0, 0.899));display:inline-flex}.___SAddon_x9pvr_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583));display:inline-flex;align-items:center;justify-content:center}@supports (color:color(display-p3 0 0 0%)){.___SAddon_x9pvr_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@media (color-gamut:p3){.___SAddon_x9pvr_gg_{color:var(--intergalactic-text-secondary, color(display-p3 0.00228 0.01289 0.00252 / 0.583))}}}.___SPill_x9pvr_gg_._size_m_x9pvr_gg_{height:var(--intergalactic-form-control-m, 28px);min-width:var(--intergalactic-form-control-m, 28px);font-size:var(--intergalactic-fs-200, 14px)}.___SPill_x9pvr_gg_._size_l_x9pvr_gg_ .___SText_x9pvr_gg_,.___SPill_x9pvr_gg_._size_m_x9pvr_gg_ .___SText_x9pvr_gg_{margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_x9pvr_gg_._size_m_x9pvr_gg_ .___SAddon_x9pvr_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x, 8px)}.___SPill_x9pvr_gg_._size_m_x9pvr_gg_ .___SAddon_x9pvr_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_x9pvr_gg_._size_m_x9pvr_gg_ .___SAddon_x9pvr_gg_:only-child{margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_x9pvr_gg_._size_l_x9pvr_gg_{height:var(--intergalactic-form-control-l, 40px);min-width:var(--intergalactic-form-control-l, 40px);font-size:var(--intergalactic-fs-300, 16px)}.___SPill_x9pvr_gg_._size_l_x9pvr_gg_ .___SAddon_x9pvr_gg_:only-child,.___SPill_x9pvr_gg_._size_l_x9pvr_gg_ .___SText_x9pvr_gg_:only-child{margin-left:var(--intergalactic-spacing-3x, 12px);margin-right:var(--intergalactic-spacing-3x, 12px)}.___SPill_x9pvr_gg_._size_l_x9pvr_gg_ .___SAddon_x9pvr_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-3x, 12px)}.___SPill_x9pvr_gg_._size_l_x9pvr_gg_ .___SAddon_x9pvr_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-3x, 12px)}.___SPill_x9pvr_gg_._neighborLocation_right_x9pvr_gg_{border-top-right-radius:0;border-bottom-right-radius:0}.___SPill_x9pvr_gg_._neighborLocation_both_x9pvr_gg_{border-radius:0;margin-left:-1px}.___SPill_x9pvr_gg_._neighborLocation_left_x9pvr_gg_{border-top-left-radius:0;border-bottom-left-radius:0;margin-left:-1px}",
20
18
  /*__inner_css_end__*/
21
- "lodqe_gg_"
19
+ "x9pvr_gg_"
22
20
  ), /*__reshadow_css_end__*/
23
21
  {
24
- "__SText": "___SText_lodqe_gg_",
25
- "__SAddon": "___SAddon_lodqe_gg_",
26
- "__SPill": "___SPill_lodqe_gg_",
27
- "_neighborLocation_right": "_neighborLocation_right_lodqe_gg_",
28
- "_neighborLocation_both": "_neighborLocation_both_lodqe_gg_",
29
- "_neighborLocation_left": "_neighborLocation_left_lodqe_gg_",
30
- "__SPills": "___SPills_lodqe_gg_",
31
- "_selected": "__selected_lodqe_gg_",
32
- "_disabled": "__disabled_lodqe_gg_",
33
- "_size_m": "_size_m_lodqe_gg_",
34
- "_size_l": "_size_l_lodqe_gg_"
22
+ "__SText": "___SText_x9pvr_gg_",
23
+ "__SAddon": "___SAddon_x9pvr_gg_",
24
+ "__SPill": "___SPill_x9pvr_gg_",
25
+ "_neighborLocation_right": "_neighborLocation_right_x9pvr_gg_",
26
+ "_neighborLocation_both": "_neighborLocation_both_x9pvr_gg_",
27
+ "_neighborLocation_left": "_neighborLocation_left_x9pvr_gg_",
28
+ "__SPills": "___SPills_x9pvr_gg_",
29
+ "_selected": "__selected_x9pvr_gg_",
30
+ "_disabled": "__disabled_x9pvr_gg_",
31
+ "_size_m": "_size_m_x9pvr_gg_",
32
+ "_size_l": "_size_l_x9pvr_gg_"
35
33
  })
36
34
  );
37
- var optionsA11yEnhance = {
38
- onNeighborChange: function onNeighborChange(neighborElement, props) {
39
- if (neighborElement) {
40
- neighborElement.focus();
41
- if (props.behavior === "auto" || props.behavior === "radio") {
42
- neighborElement.click();
43
- }
44
- }
45
- },
46
- childSelector: function childSelector(props) {
47
- return props.behavior === "auto" || props.behavior === "radio" ? ["role", "radio"] : ["role", "tab"];
48
- }
49
- };
50
35
  var RootPills = /* @__PURE__ */ (function(_Component) {
51
36
  function RootPills2() {
52
37
  var _this;
@@ -62,39 +47,23 @@ var RootPills = /* @__PURE__ */ (function(_Component) {
62
47
  };
63
48
  });
64
49
  _defineProperty(_this, "bindHandleKeyDown", function(value) {
65
- return function(event) {
66
- if (event.key === "Enter" || event.key === " ") {
67
- event.preventDefault();
68
- _this.handlers.value(value, event);
50
+ return function(e) {
51
+ if (e.key === "Enter" || e.key === " ") {
52
+ e.preventDefault();
53
+ _this.handlers.value(value, e);
69
54
  }
70
55
  };
71
56
  });
72
- _defineProperty(_this, "changeIndex", function(startIndex, type) {
73
- var selectable = false;
74
- while (!selectable && startIndex >= 0 && startIndex < _this.itemValues.length) {
75
- if (type === "increment") startIndex++;
76
- if (type === "decrement") startIndex--;
77
- var element = _this.itemRefs[startIndex];
78
- if ((element === null || element === void 0 ? void 0 : element.disabled) === false) {
79
- selectable = true;
80
- }
81
- }
82
- return startIndex >= 0 && startIndex < _this.itemValues.length ? startIndex : void 0;
83
- });
84
57
  return _this;
85
58
  }
86
59
  _inherits(RootPills2, _Component);
87
60
  return _createClass(RootPills2, [{
88
- key: "componentDidMount",
89
- value: function componentDidMount() {
90
- log.warn(this.asProps.behavior === "tabs", "Use behavior `manual` instead of `tabs`. \n`tabs` is deprecated and will be removed in the next major release.", "Pills");
91
- log.warn(this.asProps.behavior === "radio", "Use behavior `auto` (or nothing, it is default value) instead of `radio`. \n`radio` is deprecated and will be removed in the next major release.", "Pills");
92
- }
93
- }, {
94
61
  key: "uncontrolledProps",
95
62
  value: function uncontrolledProps() {
96
63
  return {
97
- value: null
64
+ value: function value(_value, e) {
65
+ return _value;
66
+ }
98
67
  };
99
68
  }
100
69
  }, {
@@ -121,7 +90,7 @@ var RootPills = /* @__PURE__ */ (function(_Component) {
121
90
  var SPills = Box;
122
91
  var _this$asProps2 = this.asProps, Children = _this$asProps2.Children, styles = _this$asProps2.styles, controlsLength = _this$asProps2.controlsLength, disabled = _this$asProps2.disabled, behavior = _this$asProps2.behavior, value = _this$asProps2.value;
123
92
  return _ref5 = sstyled(styles), /* @__PURE__ */ React.createElement(SPills, _ref5.cn("SPills", _objectSpread({}, assignProps({
124
- "role": behavior === "radio" || behavior === "auto" ? "radiogroup" : "tablist",
93
+ "role": behavior === "auto" ? "radiogroup" : "tablist",
125
94
  "aria-disabled": disabled,
126
95
  "use:tabIndex": value !== null ? -1 : 0
127
96
  }, _ref))), /* @__PURE__ */ React.createElement(NeighborLocation, _ref5.cn("NeighborLocation", {
@@ -140,20 +109,30 @@ _defineProperty(RootPills, "defaultProps", function(_ref9) {
140
109
  behavior: behavior !== null && behavior !== void 0 ? behavior : "auto"
141
110
  };
142
111
  });
143
- _defineProperty(RootPills, "enhance", [a11yEnhance(optionsA11yEnhance)]);
112
+ _defineProperty(RootPills, "enhance", [a11yEnhance({
113
+ onNeighborChange: function onNeighborChange(neighborElement, props) {
114
+ if (neighborElement) {
115
+ neighborElement.focus();
116
+ if (props.behavior === "auto") {
117
+ neighborElement.click();
118
+ }
119
+ }
120
+ },
121
+ childSelector: function childSelector(props) {
122
+ var selector = props.behavior === "auto" ? ["role", "radio"] : ["role", "tab"];
123
+ return selector;
124
+ }
125
+ })]);
144
126
  function Pill(props) {
145
127
  var _ref2 = arguments[0], _ref6;
146
128
  var SPill = Box;
147
129
  var Children = props.Children, styles = props.styles, addonLeft = props.addonLeft, addonRight = props.addonRight, selected = props.selected, disabled = props.disabled, index = props.index, behavior = props.behavior;
148
130
  var neighborLocation = useNeighborLocationDetect(index);
149
- var roleAreaProps = {};
150
- if (behavior === "radio" || behavior === "auto") {
151
- roleAreaProps.role = "radio";
152
- roleAreaProps["aria-checked"] = selected;
153
- } else {
154
- roleAreaProps.role = "tab";
155
- roleAreaProps["aria-selected"] = selected;
156
- }
131
+ var roleAreaProps = {
132
+ "role": behavior === "auto" ? "radio" : "tab",
133
+ "aria-checked": behavior === "auto" ? selected : void 0,
134
+ "aria-selected": behavior !== "auto" ? selected : void 0
135
+ };
157
136
  return _ref6 = sstyled(styles), /* @__PURE__ */ React.createElement(SPill, _ref6.cn("SPill", _objectSpread({}, assignProps(_objectSpread({
158
137
  "tag": "button",
159
138
  "type": "button",
@@ -180,15 +159,15 @@ function Addon(props) {
180
159
  "tag": "span"
181
160
  }, _ref4))));
182
161
  }
162
+ var wrapPills = function wrapPills2(wrapper) {
163
+ return wrapper;
164
+ };
183
165
  var Pills = createComponent(RootPills, {
184
166
  Item: [Pill, {
185
167
  Text,
186
168
  Addon
187
169
  }]
188
170
  });
189
- var wrapPills = function wrapPills2(wrapper) {
190
- return wrapper;
191
- };
192
171
  export {
193
172
  Pills as default,
194
173
  wrapPills
@@ -0,0 +1 @@
1
+
package/lib/esm/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { default as default2, wrapPills } from "./Pills.mjs";
2
+ import "./Pills.type.mjs";
2
3
  export {
3
4
  default2 as default,
4
5
  wrapPills
@@ -7,7 +7,7 @@ SPills {
7
7
 
8
8
  SPill[selected] {
9
9
  background: var(--intergalactic-control-secondary-info, oklch(0.527 0.264 262.9 / 0.039));
10
- border-color: var(--intergalactic-border-info-active, oklch(0.443 0.273 264.2 / 0.419));
10
+ border-color: var(--intergalactic-border-info-active, oklch(0.7 0.131 275.2));
11
11
  z-index: 3;
12
12
  }
13
13
  SPill:focus-visible, SPill[selected] {
@@ -0,0 +1,6 @@
1
+ import type { Intergalactic } from '@semcore/core';
2
+ import React from 'react';
3
+ import type { NSPills } from './Pills.type';
4
+ export declare const wrapPills: <PropsExtending extends {}>(wrapper: (props: Intergalactic.InternalTypings.UntypeRefAndTag<Intergalactic.InternalTypings.ComponentPropsNesting<NSPills.WrapComponent>> & PropsExtending) => React.ReactNode) => NSPills.WrapComponent<PropsExtending>;
5
+ declare const Pills: NSPills.Component;
6
+ export default Pills;
@@ -0,0 +1,74 @@
1
+ import type { Box, BoxProps, NeighborItemProps, NeighborLocationProps } from '@semcore/base-components';
2
+ import type { PropGetterFn, Intergalactic } from '@semcore/core';
3
+ import type React from 'react';
4
+ declare namespace NSPills {
5
+ type Value = string | number | boolean | null;
6
+ type Props<T extends NSPills.Value = NSPills.Value> = NeighborLocationProps & BoxProps & {
7
+ /** Pills size */
8
+ size?: 'l' | 'm';
9
+ /** Disabled state */
10
+ disabled?: boolean;
11
+ /** Called when the selection is changed */
12
+ onChange?: ((value: T, e?: React.SyntheticEvent<HTMLSpanElement>) => void) | React.Dispatch<React.SetStateAction<T>>;
13
+ /** Value for the selected pill */
14
+ value?: T;
15
+ /** Default value for the selected pill */
16
+ defaultValue?: T;
17
+ /** Sets semantic role for corresponding behavior,
18
+ * when set to `auto` pressing left and right arrows
19
+ * selects corresponding sibling pill.
20
+ *
21
+ * It's recommended to use `auto` behavior in forms
22
+ * while `manual` behavior for navigation and layout.
23
+ * @default tabs
24
+ */
25
+ behavior?: 'auto' | 'manual';
26
+ };
27
+ type Ctx = {
28
+ getItemProps: PropGetterFn;
29
+ };
30
+ type Handlers = {
31
+ value: (value: Props['value'], event: React.SyntheticEvent) => Props['value'];
32
+ };
33
+ namespace Pill {
34
+ type Props = BoxProps & NeighborItemProps & {
35
+ /** Pill value */
36
+ value?: NSPills.Value;
37
+ /** Disabled state */
38
+ disabled?: boolean;
39
+ /** Selected state */
40
+ selected?: boolean;
41
+ /** Left addon text */
42
+ addonLeft?: React.ElementType;
43
+ /** Right addon tag */
44
+ addonRight?: React.ElementType;
45
+ };
46
+ namespace Text {
47
+ type Component = typeof Box;
48
+ }
49
+ namespace Addon {
50
+ type Component = typeof Box;
51
+ }
52
+ type Component = Intergalactic.Component<'button', Props, [handlers: Handlers]>;
53
+ }
54
+ type WrapComponent<PropsExtending = {}> = (<V extends Value, Tag extends Intergalactic.Tag = 'div'>(props: Intergalactic.InternalTypings.ComponentProps<Tag, 'div', Props<V>, Ctx, [
55
+ handlers: Handlers
56
+ ]> & PropsExtending) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', Props>;
57
+ type Component = WrapComponent & {
58
+ Item: Pill.Component & {
59
+ Text: Pill.Text.Component;
60
+ Addon: Pill.Addon.Component;
61
+ };
62
+ };
63
+ }
64
+ /** @deprecated It will be removed in v18. */
65
+ export type PillsValue = NSPills.Value;
66
+ /** @deprecated It will be removed in v18. */
67
+ export type PillsProps<T extends PillsValue = PillsValue> = NSPills.Props<T>;
68
+ /** @deprecated It will be removed in v18. */
69
+ export type PillProps = NSPills.Pill.Props;
70
+ /** @deprecated It will be removed in v18. */
71
+ export type PillsContext = NSPills.Ctx;
72
+ /** @deprecated It will be removed in v18. */
73
+ export type PillsHandlers = NSPills.Handlers;
74
+ export type { NSPills };
@@ -1,111 +1,2 @@
1
- import type { PropGetterFn, UnknownProperties, Intergalactic } from '@semcore/core';
2
- import type { Box, BoxProps } from '@semcore/flex-box';
3
- import type { NeighborItemProps, NeighborLocationProps } from '@semcore/neighbor-location';
4
- import type React from 'react';
5
-
6
- export type PillsValue = string | number | boolean | null;
7
-
8
- /**
9
- * @deprecated
10
- * use `manual`
11
- */
12
- export type DeprecatedBehaviorTabs = 'tabs';
13
- /**
14
- * @deprecated
15
- * use `auto`
16
- */
17
- export type DeprecatedBehaviorRadio = 'radio';
18
-
19
- /** @deprecated */
20
- export interface IPillsProps<T extends PillsValue = PillsValue>
21
- extends PillsProps<T>,
22
- UnknownProperties {}
23
- export type PillsProps<T extends PillsValue = PillsValue> = NeighborLocationProps &
24
- BoxProps & {
25
- /** Pills size */
26
- size?: 'l' | 'm';
27
- /** Disabled state */
28
- disabled?: boolean;
29
- /** Called when the selection is changed */
30
- onChange?:
31
- | ((value: T, e?: React.SyntheticEvent<HTMLSpanElement>) => void)
32
- | React.Dispatch<React.SetStateAction<T>>;
33
- /** Value for the selected pill */
34
- value?: T;
35
- /** Default value for the selected pill */
36
- defaultValue?: T;
37
- /** Sets semantic role for corresponding behavior,
38
- * when set to `auto` pressing left and right arrows
39
- * selects corresponding sibling pill.
40
- *
41
- * It's recommended to use `auto` behavior in forms
42
- * while `manual` behavior for navigation and layout.
43
- * @default tabs
44
- */
45
- behavior?:
46
- DeprecatedBehaviorTabs | DeprecatedBehaviorRadio
47
- | 'auto'
48
- | 'manual';
49
- };
50
-
51
- /** @deprecated */
52
- export interface IPillProps extends PillProps, UnknownProperties {}
53
- export type PillProps = BoxProps &
54
- NeighborItemProps & {
55
- /** Pill value */
56
- value?: PillsValue;
57
- /** Disabled state */
58
- disabled?: boolean;
59
- /** Selected state */
60
- selected?: boolean;
61
- /** Left addon text */
62
- addonLeft?: React.ElementType;
63
- /** Right addon tag */
64
- addonRight?: React.ElementType;
65
- };
66
-
67
- /** @deprecated */
68
- export interface IPillsContext extends PillsContext, UnknownProperties {}
69
- export type PillsContext = {
70
- getItemProps: PropGetterFn;
71
- };
72
-
73
- /** @deprecated */
74
- export interface IPillsHandlers extends PillsHandlers, UnknownProperties {}
75
- export type PillsHandlers = {
76
- value: (value: PillsValue) => void;
77
- };
78
-
79
- type IntergalacticPillsComponent<PropsExtending = {}> = (<
80
- Value extends PillsValue,
81
- Tag extends Intergalactic.Tag = 'div',
82
- >(
83
- props: Intergalactic.InternalTypings.ComponentProps<
84
- Tag,
85
- 'div',
86
- PillsProps<Value>,
87
- PillsContext,
88
- [handlers: PillsHandlers]
89
- > &
90
- PropsExtending,
91
- ) => Intergalactic.InternalTypings.ComponentRenderingResults) &
92
- Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', PillsProps>;
93
-
94
- declare const Pills: IntergalacticPillsComponent & {
95
- Item: Intergalactic.Component<'button', PillProps, [handlers: PillsHandlers]> & {
96
- Text: typeof Box;
97
- Addon: typeof Box;
98
- };
99
- };
100
-
101
- declare const wrapPills: <PropsExtending extends {}>(
102
- wrapper: (
103
- props: Intergalactic.InternalTypings.UntypeRefAndTag<
104
- Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticPillsComponent>
105
- > &
106
- PropsExtending,
107
- ) => React.ReactNode,
108
- ) => IntergalacticPillsComponent<PropsExtending>;
109
- export { wrapPills };
110
-
111
- export default Pills;
1
+ export { default, wrapPills } from './Pills';
2
+ export * from './Pills.type';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semcore/pills",
3
3
  "description": "Semrush Pills Component",
4
- "version": "16.1.0-prerelease.3",
4
+ "version": "16.1.0",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es6/index.js",
7
7
  "typings": "lib/types/index.d.ts",
@@ -14,11 +14,11 @@
14
14
  "types": "./lib/types/index.d.ts"
15
15
  },
16
16
  "dependencies": {
17
- "@semcore/flex-box": "16.1.0-prerelease.3",
18
- "@semcore/neighbor-location": "16.1.0-prerelease.3"
17
+ "@semcore/flex-box": "16.1.0",
18
+ "@semcore/neighbor-location": "16.1.0"
19
19
  },
20
20
  "peerDependencies": {
21
- "@semcore/base-components": "^16.6.0-prerelease.3"
21
+ "@semcore/base-components": "^16.6.0"
22
22
  },
23
23
  "repository": {
24
24
  "type": "git",
@@ -26,10 +26,10 @@
26
26
  "directory": "semcore/pills"
27
27
  },
28
28
  "devDependencies": {
29
- "@semcore/core": "16.6.0-prerelease.3",
29
+ "@semcore/core": "16.6.0",
30
30
  "@semcore/testing-utils": "1.0.0",
31
- "@semcore/icon": "16.8.0-prerelease.3",
32
- "@semcore/badge": "16.1.0-prerelease.3"
31
+ "@semcore/badge": "16.1.0",
32
+ "@semcore/icon": "16.8.0"
33
33
  },
34
34
  "scripts": {
35
35
  "build": "pnpm semcore-builder --source=js && pnpm vite build"
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=index.d.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import type { PropGetterFn, UnknownProperties, Intergalactic } from '@semcore/core';\nimport type { Box, BoxProps } from '@semcore/flex-box';\nimport type { NeighborItemProps, NeighborLocationProps } from '@semcore/neighbor-location';\nimport type React from 'react';\n\nexport type PillsValue = string | number | boolean | null;\n\n/**\n * @deprecated\n * use `manual`\n */\nexport type DeprecatedBehaviorTabs = 'tabs';\n/**\n * @deprecated\n * use `auto`\n */\nexport type DeprecatedBehaviorRadio = 'radio';\n\n/** @deprecated */\nexport interface IPillsProps<T extends PillsValue = PillsValue>\n extends PillsProps<T>,\n UnknownProperties {}\nexport type PillsProps<T extends PillsValue = PillsValue> = NeighborLocationProps &\n BoxProps & {\n /** Pills size */\n size?: 'l' | 'm';\n /** Disabled state */\n disabled?: boolean;\n /** Called when the selection is changed */\n onChange?:\n | ((value: T, e?: React.SyntheticEvent<HTMLSpanElement>) => void)\n | React.Dispatch<React.SetStateAction<T>>;\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 `auto` pressing left and right arrows\n * selects corresponding sibling pill.\n *\n * It's recommended to use `auto` behavior in forms\n * while `manual` behavior for navigation and layout.\n * @default tabs\n */\n behavior?:\n DeprecatedBehaviorTabs | DeprecatedBehaviorRadio\n | 'auto'\n | 'manual';\n };\n\n/** @deprecated */\nexport interface IPillProps extends PillProps, UnknownProperties {}\nexport type PillProps = BoxProps &\n NeighborItemProps & {\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\n/** @deprecated */\nexport interface IPillsContext extends PillsContext, UnknownProperties {}\nexport type PillsContext = {\n getItemProps: PropGetterFn;\n};\n\n/** @deprecated */\nexport interface IPillsHandlers extends PillsHandlers, UnknownProperties {}\nexport type PillsHandlers = {\n value: (value: PillsValue) => void;\n};\n\ntype IntergalacticPillsComponent<PropsExtending = {}> = (<\n Value extends PillsValue,\n Tag extends Intergalactic.Tag = 'div',\n>(\n props: Intergalactic.InternalTypings.ComponentProps<\n Tag,\n 'div',\n PillsProps<Value>,\n PillsContext,\n [handlers: PillsHandlers]\n > &\n PropsExtending,\n) => Intergalactic.InternalTypings.ComponentRenderingResults) &\nIntergalactic.InternalTypings.ComponentAdditive<'div', 'div', PillsProps>;\n\ndeclare const Pills: IntergalacticPillsComponent & {\n Item: Intergalactic.Component<'button', PillProps, [handlers: PillsHandlers]> & {\n Text: typeof Box;\n Addon: typeof Box;\n };\n};\n\ndeclare const wrapPills: <PropsExtending extends {}>(\n wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticPillsComponent>\n > &\n PropsExtending,\n ) => React.ReactNode,\n) => IntergalacticPillsComponent<PropsExtending>;\nexport { wrapPills };\n\nexport default Pills;\n"],"mappings":"","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.d.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import type { PropGetterFn, UnknownProperties, Intergalactic } from '@semcore/core';\nimport type { Box, BoxProps } from '@semcore/flex-box';\nimport type { NeighborItemProps, NeighborLocationProps } from '@semcore/neighbor-location';\nimport type React from 'react';\n\nexport type PillsValue = string | number | boolean | null;\n\n/**\n * @deprecated\n * use `manual`\n */\nexport type DeprecatedBehaviorTabs = 'tabs';\n/**\n * @deprecated\n * use `auto`\n */\nexport type DeprecatedBehaviorRadio = 'radio';\n\n/** @deprecated */\nexport interface IPillsProps<T extends PillsValue = PillsValue>\n extends PillsProps<T>,\n UnknownProperties {}\nexport type PillsProps<T extends PillsValue = PillsValue> = NeighborLocationProps &\n BoxProps & {\n /** Pills size */\n size?: 'l' | 'm';\n /** Disabled state */\n disabled?: boolean;\n /** Called when the selection is changed */\n onChange?:\n | ((value: T, e?: React.SyntheticEvent<HTMLSpanElement>) => void)\n | React.Dispatch<React.SetStateAction<T>>;\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 `auto` pressing left and right arrows\n * selects corresponding sibling pill.\n *\n * It's recommended to use `auto` behavior in forms\n * while `manual` behavior for navigation and layout.\n * @default tabs\n */\n behavior?:\n DeprecatedBehaviorTabs | DeprecatedBehaviorRadio\n | 'auto'\n | 'manual';\n };\n\n/** @deprecated */\nexport interface IPillProps extends PillProps, UnknownProperties {}\nexport type PillProps = BoxProps &\n NeighborItemProps & {\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\n/** @deprecated */\nexport interface IPillsContext extends PillsContext, UnknownProperties {}\nexport type PillsContext = {\n getItemProps: PropGetterFn;\n};\n\n/** @deprecated */\nexport interface IPillsHandlers extends PillsHandlers, UnknownProperties {}\nexport type PillsHandlers = {\n value: (value: PillsValue) => void;\n};\n\ntype IntergalacticPillsComponent<PropsExtending = {}> = (<\n Value extends PillsValue,\n Tag extends Intergalactic.Tag = 'div',\n>(\n props: Intergalactic.InternalTypings.ComponentProps<\n Tag,\n 'div',\n PillsProps<Value>,\n PillsContext,\n [handlers: PillsHandlers]\n > &\n PropsExtending,\n) => Intergalactic.InternalTypings.ComponentRenderingResults) &\nIntergalactic.InternalTypings.ComponentAdditive<'div', 'div', PillsProps>;\n\ndeclare const Pills: IntergalacticPillsComponent & {\n Item: Intergalactic.Component<'button', PillProps, [handlers: PillsHandlers]> & {\n Text: typeof Box;\n Addon: typeof Box;\n };\n};\n\ndeclare const wrapPills: <PropsExtending extends {}>(\n wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticPillsComponent>\n > &\n PropsExtending,\n ) => React.ReactNode,\n) => IntergalacticPillsComponent<PropsExtending>;\nexport { wrapPills };\n\nexport default Pills;\n"],"mappings":"","ignoreList":[]}