@semcore/pills 5.43.4 → 5.44.0-prerelease.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/lib/cjs/Pills.js +63 -93
- package/lib/cjs/Pills.js.map +1 -1
- package/lib/cjs/Pills.type.js +2 -0
- package/lib/cjs/Pills.type.js.map +1 -0
- package/lib/cjs/index.js +14 -5
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/style/pills.shadow.css +20 -26
- package/lib/es6/Pills.js +55 -81
- package/lib/es6/Pills.js.map +1 -1
- package/lib/es6/Pills.type.js +2 -0
- package/lib/es6/Pills.type.js.map +1 -0
- package/lib/es6/index.js +2 -2
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/style/pills.shadow.css +20 -26
- package/lib/esm/Pills.mjs +61 -88
- package/lib/esm/Pills.type.mjs +1 -0
- package/lib/esm/index.mjs +1 -0
- package/lib/esm/style/pills.shadow.css +20 -26
- package/lib/types/Pills.d.ts +6 -0
- package/lib/types/Pills.type.d.ts +74 -0
- package/lib/types/index.d.ts +2 -105
- package/package.json +5 -5
- package/lib/cjs/index.d.js +0 -2
- package/lib/cjs/index.d.js.map +0 -1
- package/lib/es6/index.d.js +0 -2
- package/lib/es6/index.d.js.map +0 -1
package/lib/esm/Pills.mjs
CHANGED
|
@@ -1,105 +1,69 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import
|
|
4
|
+
import _callSuper from "@babel/runtime/helpers/esm/callSuper";
|
|
5
5
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
7
6
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
8
|
-
import { sstyled } from "@semcore/
|
|
9
|
-
import
|
|
7
|
+
import { sstyled, assignProps, Component, createComponent } from "@semcore/core";
|
|
8
|
+
import { Box, NeighborLocation, useNeighborLocationDetect } from "@semcore/base-components";
|
|
9
|
+
import addonTextChildren from "@semcore/core/lib/utils/addonTextChildren";
|
|
10
|
+
import a11yEnhance from "@semcore/core/lib/utils/enhances/a11yEnhance";
|
|
10
11
|
import React from "react";
|
|
11
|
-
import { Box } from "@semcore/flex-box";
|
|
12
|
-
import NeighborLocation, { useNeighborLocationDetect } from "@semcore/neighbor-location";
|
|
13
|
-
import keyboardFocusEnhance from "@semcore/utils/lib/enhances/keyboardFocusEnhance";
|
|
14
|
-
import addonTextChildren from "@semcore/utils/lib/addonTextChildren";
|
|
15
|
-
import a11yEnhance from "@semcore/utils/lib/enhances/a11yEnhance";
|
|
16
|
-
import log from "@semcore/utils/lib/logger";
|
|
17
12
|
/*!__reshadow-styles__:"./style/pills.shadow.css"*/
|
|
18
13
|
var style = (
|
|
19
14
|
/*__reshadow_css_start__*/
|
|
20
15
|
(sstyled.insert(
|
|
21
16
|
/*__inner_css_start__*/
|
|
22
|
-
".
|
|
17
|
+
".___SPills_pfea8_gg_{display:inline-flex;align-items:center;justify-content:center;isolation:isolate;border-radius:var(--intergalactic-control-rounded, 6px)}.___SPills_pfea8_gg_ .___SPill_pfea8_gg_.__selected_pfea8_gg_{background:var(--intergalactic-control-secondary-info, rgba(0, 31, 210, 0.031));border-color:var(--intergalactic-border-info-active, rgba(0, 22, 195, 0.386));z-index:3}@supports (color:color(display-p3 0 0 0%)){.___SPills_pfea8_gg_ .___SPill_pfea8_gg_.__selected_pfea8_gg_{background:var(--intergalactic-control-secondary-info, rgba(0, 31, 210, 0.031));border-color:var(--intergalactic-border-info-active, rgba(0, 22, 195, 0.386))}@media (color-gamut:p3){.___SPills_pfea8_gg_ .___SPill_pfea8_gg_.__selected_pfea8_gg_{background:var(--intergalactic-control-secondary-info, color(display-p3 0.03208 0.12081 0.79186 / 0.031));border-color:var(--intergalactic-border-info-active, color(display-p3 0.01805 0.08334 0.73488 / 0.386))}}}.___SPills_pfea8_gg_ .___SPill_pfea8_gg_.__selected_pfea8_gg_,.___SPills_pfea8_gg_ .___SPill_pfea8_gg_:focus-visible{z-index:3}.___SPills_pfea8_gg_ .___SPill_pfea8_gg_:active{z-index:2}@media (hover:hover){.___SPills_pfea8_gg_ .___SPill_pfea8_gg_:hover{z-index:2}}.___SPill_pfea8_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_pfea8_gg_{border:1px solid var(--intergalactic-border-primary, rgba(0, 12, 8, 0.161))}@media (color-gamut:p3){.___SPill_pfea8_gg_{border:1px solid var(--intergalactic-border-primary, color(display-p3 0.00798 0.04498 0.03219 / 0.161))}}}.___SPill_pfea8_gg_::-moz-focus-inner{border:0;padding:0}.___SPill_pfea8_gg_:active{outline:0;-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___SPill_pfea8_gg_:hover{background:var(--intergalactic-bg-primary-neutral-hover, rgb(248, 249, 248))}}.___SPill_pfea8_gg_.__disabled_pfea8_gg_{cursor:default;pointer-events:none}.___SPill_pfea8_gg_.__disabled_pfea8_gg_>*{opacity:var(--intergalactic-disabled-opacity, 0.4)}.___SText_pfea8_gg_{color:var(--intergalactic-text-primary, rgba(1, 5, 0, 0.899));display:inline-flex}.___SAddon_pfea8_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_pfea8_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@media (color-gamut:p3){.___SAddon_pfea8_gg_{color:var(--intergalactic-text-secondary, color(display-p3 0.00228 0.01289 0.00252 / 0.583))}}}.___SPill_pfea8_gg_._size_m_pfea8_gg_{height:var(--intergalactic-form-control-m, 28px);min-width:var(--intergalactic-form-control-m, 28px);font-size:var(--intergalactic-fs-200, 14px)}.___SPill_pfea8_gg_._size_l_pfea8_gg_ .___SText_pfea8_gg_,.___SPill_pfea8_gg_._size_m_pfea8_gg_ .___SText_pfea8_gg_{margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_pfea8_gg_._size_m_pfea8_gg_ .___SAddon_pfea8_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x, 8px)}.___SPill_pfea8_gg_._size_m_pfea8_gg_ .___SAddon_pfea8_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_pfea8_gg_._size_m_pfea8_gg_ .___SAddon_pfea8_gg_:only-child{margin-left:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SPill_pfea8_gg_._size_l_pfea8_gg_{height:var(--intergalactic-form-control-l, 40px);min-width:var(--intergalactic-form-control-l, 40px);font-size:var(--intergalactic-fs-300, 16px)}.___SPill_pfea8_gg_._size_l_pfea8_gg_ .___SAddon_pfea8_gg_:only-child,.___SPill_pfea8_gg_._size_l_pfea8_gg_ .___SText_pfea8_gg_:only-child{margin-left:var(--intergalactic-spacing-3x, 12px);margin-right:var(--intergalactic-spacing-3x, 12px)}.___SPill_pfea8_gg_._size_l_pfea8_gg_ .___SAddon_pfea8_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-3x, 12px)}.___SPill_pfea8_gg_._size_l_pfea8_gg_ .___SAddon_pfea8_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-3x, 12px)}.___SPill_pfea8_gg_._neighborLocation_right_pfea8_gg_{border-top-right-radius:0;border-bottom-right-radius:0}.___SPill_pfea8_gg_._neighborLocation_both_pfea8_gg_{border-radius:0;margin-left:-1px}.___SPill_pfea8_gg_._neighborLocation_left_pfea8_gg_{border-top-left-radius:0;border-bottom-left-radius:0;margin-left:-1px}",
|
|
23
18
|
/*__inner_css_end__*/
|
|
24
|
-
"
|
|
19
|
+
"pfea8_gg_"
|
|
25
20
|
), /*__reshadow_css_end__*/
|
|
26
21
|
{
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"__SPill": "
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"_size_l": "_size_l_b73wr_gg_"
|
|
22
|
+
"__SText": "___SText_pfea8_gg_",
|
|
23
|
+
"__SAddon": "___SAddon_pfea8_gg_",
|
|
24
|
+
"__SPill": "___SPill_pfea8_gg_",
|
|
25
|
+
"_neighborLocation_right": "_neighborLocation_right_pfea8_gg_",
|
|
26
|
+
"_neighborLocation_both": "_neighborLocation_both_pfea8_gg_",
|
|
27
|
+
"_neighborLocation_left": "_neighborLocation_left_pfea8_gg_",
|
|
28
|
+
"__SPills": "___SPills_pfea8_gg_",
|
|
29
|
+
"_selected": "__selected_pfea8_gg_",
|
|
30
|
+
"_disabled": "__disabled_pfea8_gg_",
|
|
31
|
+
"_size_m": "_size_m_pfea8_gg_",
|
|
32
|
+
"_size_l": "_size_l_pfea8_gg_"
|
|
39
33
|
})
|
|
40
34
|
);
|
|
41
|
-
var
|
|
42
|
-
onNeighborChange: function onNeighborChange(neighborElement, props) {
|
|
43
|
-
if (neighborElement) {
|
|
44
|
-
neighborElement.focus();
|
|
45
|
-
if (props.behavior === "auto" || props.behavior === "radio") {
|
|
46
|
-
neighborElement.click();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
childSelector: function childSelector(props) {
|
|
51
|
-
return props.behavior === "auto" || props.behavior === "radio" ? ["role", "radio"] : ["role", "tab"];
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
var RootPills = /* @__PURE__ */ function(_Component) {
|
|
55
|
-
_inherits(RootPills2, _Component);
|
|
56
|
-
var _super = _createSuper(RootPills2);
|
|
35
|
+
var RootPills = /* @__PURE__ */ (function(_Component) {
|
|
57
36
|
function RootPills2() {
|
|
58
37
|
var _this;
|
|
59
38
|
_classCallCheck(this, RootPills2);
|
|
60
39
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
61
40
|
args[_key] = arguments[_key];
|
|
62
41
|
}
|
|
63
|
-
_this =
|
|
64
|
-
_defineProperty(
|
|
65
|
-
_defineProperty(
|
|
42
|
+
_this = _callSuper(this, RootPills2, [].concat(args));
|
|
43
|
+
_defineProperty(_this, "itemValues", []);
|
|
44
|
+
_defineProperty(_this, "bindHandlerClick", function(value) {
|
|
66
45
|
return function(e) {
|
|
67
46
|
_this.handlers.value(value, e);
|
|
68
47
|
};
|
|
69
48
|
});
|
|
70
|
-
_defineProperty(
|
|
71
|
-
return function(
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
_this.handlers.value(value,
|
|
49
|
+
_defineProperty(_this, "bindHandleKeyDown", function(value) {
|
|
50
|
+
return function(e) {
|
|
51
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
_this.handlers.value(value, e);
|
|
75
54
|
}
|
|
76
55
|
};
|
|
77
56
|
});
|
|
78
|
-
_defineProperty(_assertThisInitialized(_this), "changeIndex", function(startIndex, type) {
|
|
79
|
-
var selectable = false;
|
|
80
|
-
while (!selectable && startIndex >= 0 && startIndex < _this.itemValues.length) {
|
|
81
|
-
if (type === "increment") startIndex++;
|
|
82
|
-
if (type === "decrement") startIndex--;
|
|
83
|
-
var element = _this.itemRefs[startIndex];
|
|
84
|
-
if ((element === null || element === void 0 ? void 0 : element.disabled) === false) {
|
|
85
|
-
selectable = true;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return startIndex >= 0 && startIndex < _this.itemValues.length ? startIndex : void 0;
|
|
89
|
-
});
|
|
90
57
|
return _this;
|
|
91
58
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
value: function componentDidMount() {
|
|
95
|
-
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");
|
|
96
|
-
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");
|
|
97
|
-
}
|
|
98
|
-
}, {
|
|
59
|
+
_inherits(RootPills2, _Component);
|
|
60
|
+
return _createClass(RootPills2, [{
|
|
99
61
|
key: "uncontrolledProps",
|
|
100
62
|
value: function uncontrolledProps() {
|
|
101
63
|
return {
|
|
102
|
-
value:
|
|
64
|
+
value: function value(_value, e) {
|
|
65
|
+
return _value;
|
|
66
|
+
}
|
|
103
67
|
};
|
|
104
68
|
}
|
|
105
69
|
}, {
|
|
@@ -125,8 +89,8 @@ var RootPills = /* @__PURE__ */ function(_Component) {
|
|
|
125
89
|
var _ref = this.asProps, _ref5;
|
|
126
90
|
var SPills = Box;
|
|
127
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;
|
|
128
|
-
return _ref5 = sstyled
|
|
129
|
-
"role": behavior === "
|
|
92
|
+
return _ref5 = sstyled(styles), /* @__PURE__ */ React.createElement(SPills, _ref5.cn("SPills", _objectSpread({}, assignProps({
|
|
93
|
+
"role": behavior === "auto" ? "radiogroup" : "tablist",
|
|
130
94
|
"aria-disabled": disabled,
|
|
131
95
|
"use:tabIndex": value !== null ? -1 : 0
|
|
132
96
|
}, _ref))), /* @__PURE__ */ React.createElement(NeighborLocation, _ref5.cn("NeighborLocation", {
|
|
@@ -134,8 +98,7 @@ var RootPills = /* @__PURE__ */ function(_Component) {
|
|
|
134
98
|
}), /* @__PURE__ */ React.createElement(Children, _ref5.cn("Children", {}))));
|
|
135
99
|
}
|
|
136
100
|
}]);
|
|
137
|
-
|
|
138
|
-
}(Component);
|
|
101
|
+
})(Component);
|
|
139
102
|
_defineProperty(RootPills, "displayName", "Pills");
|
|
140
103
|
_defineProperty(RootPills, "style", style);
|
|
141
104
|
_defineProperty(RootPills, "defaultProps", function(_ref9) {
|
|
@@ -146,23 +109,34 @@ _defineProperty(RootPills, "defaultProps", function(_ref9) {
|
|
|
146
109
|
behavior: behavior !== null && behavior !== void 0 ? behavior : "auto"
|
|
147
110
|
};
|
|
148
111
|
});
|
|
149
|
-
_defineProperty(RootPills, "enhance", [a11yEnhance(
|
|
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
|
+
})]);
|
|
150
126
|
function Pill(props) {
|
|
151
127
|
var _ref2 = arguments[0], _ref6;
|
|
152
128
|
var SPill = Box;
|
|
153
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;
|
|
154
130
|
var neighborLocation = useNeighborLocationDetect(index);
|
|
155
|
-
var roleAreaProps = {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
roleAreaProps["aria-selected"] = selected;
|
|
162
|
-
}
|
|
163
|
-
return _ref6 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SPill, _ref6.cn("SPill", _objectSpread({}, assignProps(_objectSpread({
|
|
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
|
+
};
|
|
136
|
+
return _ref6 = sstyled(styles), /* @__PURE__ */ React.createElement(SPill, _ref6.cn("SPill", _objectSpread({}, assignProps(_objectSpread({
|
|
164
137
|
"tag": "button",
|
|
165
138
|
"type": "button",
|
|
139
|
+
"tabIndex": 0,
|
|
166
140
|
"neighborLocation": neighborLocation,
|
|
167
141
|
"aria-disabled": disabled
|
|
168
142
|
}, roleAreaProps), _ref2))), addonLeft ? /* @__PURE__ */ React.createElement(Pills.Item.Addon, {
|
|
@@ -171,30 +145,29 @@ function Pill(props) {
|
|
|
171
145
|
tag: addonRight
|
|
172
146
|
}) : null);
|
|
173
147
|
}
|
|
174
|
-
Pill.enhance = [keyboardFocusEnhance()];
|
|
175
148
|
function Text(props) {
|
|
176
149
|
var _ref3 = arguments[0], _ref7;
|
|
177
150
|
var SText = Box;
|
|
178
|
-
return _ref7 = sstyled
|
|
151
|
+
return _ref7 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SText, _ref7.cn("SText", _objectSpread({}, assignProps({
|
|
179
152
|
"tag": "span"
|
|
180
153
|
}, _ref3))));
|
|
181
154
|
}
|
|
182
155
|
function Addon(props) {
|
|
183
156
|
var _ref4 = arguments[0], _ref8;
|
|
184
157
|
var SAddon = Box;
|
|
185
|
-
return _ref8 = sstyled
|
|
158
|
+
return _ref8 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SAddon, _ref8.cn("SAddon", _objectSpread({}, assignProps({
|
|
186
159
|
"tag": "span"
|
|
187
160
|
}, _ref4))));
|
|
188
161
|
}
|
|
162
|
+
var wrapPills = function wrapPills2(wrapper) {
|
|
163
|
+
return wrapper;
|
|
164
|
+
};
|
|
189
165
|
var Pills = createComponent(RootPills, {
|
|
190
166
|
Item: [Pill, {
|
|
191
167
|
Text,
|
|
192
168
|
Addon
|
|
193
169
|
}]
|
|
194
170
|
});
|
|
195
|
-
var wrapPills = function wrapPills2(wrapper) {
|
|
196
|
-
return wrapper;
|
|
197
|
-
};
|
|
198
171
|
export {
|
|
199
172
|
Pills as default,
|
|
200
173
|
wrapPills
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/lib/esm/index.mjs
CHANGED
|
@@ -3,12 +3,20 @@ SPills {
|
|
|
3
3
|
align-items: center;
|
|
4
4
|
justify-content: center;
|
|
5
5
|
isolation: isolate;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
border-radius: var(--intergalactic-control-rounded, 6px);
|
|
7
|
+
|
|
8
|
+
SPill[selected] {
|
|
9
|
+
background: var(--intergalactic-control-secondary-info, oklch(0.41 0.258 264.2 / 0.031));
|
|
10
|
+
border-color: var(--intergalactic-border-info-active, oklch(0.382 0.248 264.2 / 0.386));
|
|
11
|
+
z-index: 3;
|
|
12
|
+
}
|
|
13
|
+
SPill:focus-visible, SPill[selected] {
|
|
14
|
+
z-index: 3;
|
|
15
|
+
}
|
|
8
16
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
17
|
+
SPill:hover, SPill:active {
|
|
18
|
+
z-index: 2;
|
|
19
|
+
}
|
|
12
20
|
}
|
|
13
21
|
|
|
14
22
|
SPill {
|
|
@@ -27,13 +35,12 @@ SPill {
|
|
|
27
35
|
text-decoration: none;
|
|
28
36
|
-webkit-tap-highlight-color: transparent;
|
|
29
37
|
overflow: visible;
|
|
30
|
-
outline: 0;
|
|
31
38
|
text-align: center;
|
|
32
39
|
vertical-align: middle;
|
|
33
40
|
font-family: inherit;
|
|
34
41
|
cursor: pointer;
|
|
35
|
-
background: var(--intergalactic-bg-primary-neutral,
|
|
36
|
-
border: 1px solid var(--intergalactic-border-primary,
|
|
42
|
+
background: var(--intergalactic-bg-primary-neutral, oklch(1 0 0));
|
|
43
|
+
border: 1px solid var(--intergalactic-border-primary, oklch(0.137 0.026 175.7 / 0.161));
|
|
37
44
|
border-radius: var(--intergalactic-control-rounded, 6px);
|
|
38
45
|
|
|
39
46
|
&::-moz-focus-inner {
|
|
@@ -41,46 +48,33 @@ SPill {
|
|
|
41
48
|
padding: 0;
|
|
42
49
|
}
|
|
43
50
|
|
|
44
|
-
&:active
|
|
45
|
-
&:hover,
|
|
46
|
-
&:focus {
|
|
51
|
+
&:active {
|
|
47
52
|
outline: 0;
|
|
48
53
|
text-decoration: none;
|
|
49
54
|
}
|
|
50
55
|
|
|
51
56
|
&:hover {
|
|
52
|
-
background: var(--intergalactic-bg-primary-neutral-hover,
|
|
57
|
+
background: var(--intergalactic-bg-primary-neutral-hover, oklch(0.98 0.001 180));
|
|
53
58
|
}
|
|
54
59
|
}
|
|
55
60
|
|
|
56
|
-
SPill[selected] {
|
|
57
|
-
background: var(--intergalactic-control-secondary-info, rgba(0, 143, 248, 0.1));
|
|
58
|
-
border-color: var(--intergalactic-border-info-active, #006dca);
|
|
59
|
-
z-index: 1;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
61
|
SPill[disabled] {
|
|
63
62
|
cursor: default;
|
|
64
63
|
/* Disable link interactions */
|
|
65
64
|
pointer-events: none;
|
|
66
65
|
|
|
67
66
|
&>* {
|
|
68
|
-
opacity: var(--intergalactic-disabled-opacity, 0.
|
|
67
|
+
opacity: var(--intergalactic-disabled-opacity, 0.4);
|
|
69
68
|
}
|
|
70
69
|
}
|
|
71
70
|
|
|
72
|
-
SPill[keyboardFocused] {
|
|
73
|
-
box-shadow: var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.5));
|
|
74
|
-
z-index: 1;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
71
|
SText {
|
|
78
|
-
color: var(--intergalactic-text-primary,
|
|
72
|
+
color: var(--intergalactic-text-primary, oklch(0.1 0.03 137 / 0.899));
|
|
79
73
|
display: inline-flex;
|
|
80
74
|
}
|
|
81
75
|
|
|
82
76
|
SAddon {
|
|
83
|
-
color: var(--intergalactic-text-secondary,
|
|
77
|
+
color: var(--intergalactic-text-secondary, oklch(0.088 0.026 147.7 / 0.583));
|
|
84
78
|
display: inline-flex;
|
|
85
79
|
align-items: center;
|
|
86
80
|
justify-content: center;
|
|
@@ -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 };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,105 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { Box, BoxProps } from '@semcore/flex-box';
|
|
4
|
-
import { NeighborItemProps, NeighborLocationProps } from '@semcore/neighbor-location';
|
|
5
|
-
import { KeyboardFocusProps } from '@semcore/utils/lib/enhances/keyboardFocusEnhance';
|
|
6
|
-
|
|
7
|
-
export type PillsValue = string | number | boolean | null;
|
|
8
|
-
|
|
9
|
-
/** @deprecated */
|
|
10
|
-
export interface IPillsProps<T extends PillsValue = PillsValue>
|
|
11
|
-
extends PillsProps<T>,
|
|
12
|
-
UnknownProperties {}
|
|
13
|
-
export type PillsProps<T extends PillsValue = PillsValue> = NeighborLocationProps &
|
|
14
|
-
KeyboardFocusProps &
|
|
15
|
-
BoxProps & {
|
|
16
|
-
/** Pills size */
|
|
17
|
-
size?: 'l' | 'm';
|
|
18
|
-
/** Disabled state */
|
|
19
|
-
disabled?: boolean;
|
|
20
|
-
/** Called when the selection is changed */
|
|
21
|
-
onChange?:
|
|
22
|
-
| ((value: T, e?: React.SyntheticEvent<HTMLSpanElement>) => void)
|
|
23
|
-
| React.Dispatch<React.SetStateAction<T>>;
|
|
24
|
-
/** Value for the selected pill */
|
|
25
|
-
value?: T;
|
|
26
|
-
/** Default value for the selected pill */
|
|
27
|
-
defaultValue?: T;
|
|
28
|
-
/** Sets semantic role for corresponding behavior,
|
|
29
|
-
* when set to `auto` pressing left and right arrows
|
|
30
|
-
* selects corresponding sibling pill.
|
|
31
|
-
*
|
|
32
|
-
* It's recommended to use `auto` behavior in forms
|
|
33
|
-
* while `manual` behavior for navigation and layout.
|
|
34
|
-
* @default tabs
|
|
35
|
-
*/
|
|
36
|
-
behavior?: /** @deprecated use `manual` */
|
|
37
|
-
| 'tabs'
|
|
38
|
-
/** @deprecated use `auto` */
|
|
39
|
-
| 'radio'
|
|
40
|
-
| 'auto'
|
|
41
|
-
| 'manual';
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/** @deprecated */
|
|
45
|
-
export interface IPillProps extends PillProps, UnknownProperties {}
|
|
46
|
-
export type PillProps = BoxProps &
|
|
47
|
-
NeighborItemProps &
|
|
48
|
-
KeyboardFocusProps & {
|
|
49
|
-
/** Pill value */
|
|
50
|
-
value?: PillsValue;
|
|
51
|
-
/** Disabled state */
|
|
52
|
-
disabled?: boolean;
|
|
53
|
-
/** Selected state */
|
|
54
|
-
selected?: boolean;
|
|
55
|
-
/** Left addon text */
|
|
56
|
-
addonLeft?: React.ElementType;
|
|
57
|
-
/** Right addon tag */
|
|
58
|
-
addonRight?: React.ElementType;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/** @deprecated */
|
|
62
|
-
export interface IPillsContext extends PillsContext, UnknownProperties {}
|
|
63
|
-
export type PillsContext = {
|
|
64
|
-
getItemProps: PropGetterFn;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
/** @deprecated */
|
|
68
|
-
export interface IPillsHandlers extends PillsHandlers, UnknownProperties {}
|
|
69
|
-
export type PillsHandlers = {
|
|
70
|
-
value: (value: PillsValue) => void;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
type IntergalacticPillsComponent<PropsExtending = {}> = (<
|
|
74
|
-
Value extends PillsValue,
|
|
75
|
-
Tag extends Intergalactic.Tag = 'div',
|
|
76
|
-
>(
|
|
77
|
-
props: Intergalactic.InternalTypings.ComponentProps<
|
|
78
|
-
Tag,
|
|
79
|
-
'div',
|
|
80
|
-
PillsProps<Value>,
|
|
81
|
-
PillsContext,
|
|
82
|
-
[handlers: PillsHandlers]
|
|
83
|
-
> &
|
|
84
|
-
PropsExtending,
|
|
85
|
-
) => Intergalactic.InternalTypings.ComponentRenderingResults) &
|
|
86
|
-
Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', PillsProps>;
|
|
87
|
-
|
|
88
|
-
declare const Pills: IntergalacticPillsComponent & {
|
|
89
|
-
Item: Intergalactic.Component<'button', PillProps, [handlers: PillsHandlers]> & {
|
|
90
|
-
Text: typeof Box;
|
|
91
|
-
Addon: typeof Box;
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
declare const wrapPills: <PropsExtending extends {}>(
|
|
96
|
-
wrapper: (
|
|
97
|
-
props: Intergalactic.InternalTypings.UntypeRefAndTag<
|
|
98
|
-
Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticPillsComponent>
|
|
99
|
-
> &
|
|
100
|
-
PropsExtending,
|
|
101
|
-
) => React.ReactNode,
|
|
102
|
-
) => IntergalacticPillsComponent<PropsExtending>;
|
|
103
|
-
export { wrapPills };
|
|
104
|
-
|
|
105
|
-
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": "5.
|
|
4
|
+
"version": "5.44.0-prerelease.0",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"types": "./lib/types/index.d.ts"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@semcore/flex-box": "5.
|
|
18
|
-
"@semcore/neighbor-location": "4.
|
|
19
|
-
"@semcore/utils": "4.
|
|
17
|
+
"@semcore/flex-box": "5.42.0-prerelease.0",
|
|
18
|
+
"@semcore/neighbor-location": "4.41.0-prerelease.0",
|
|
19
|
+
"@semcore/utils": "4.49.0-prerelease.0"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"@semcore/core": "^2.
|
|
22
|
+
"@semcore/core": "^2.40.0-prerelease.0",
|
|
23
23
|
"react": "16.8 - 18",
|
|
24
24
|
"react-dom": "16.8 - 18"
|
|
25
25
|
},
|
package/lib/cjs/index.d.js
DELETED
package/lib/cjs/index.d.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import React from 'react';\nimport { PropGetterFn, UnknownProperties, Intergalactic } from '@semcore/core';\nimport { Box, BoxProps } from '@semcore/flex-box';\nimport { NeighborItemProps, NeighborLocationProps } from '@semcore/neighbor-location';\nimport { KeyboardFocusProps } from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\n\nexport type PillsValue = string | number | boolean | null;\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 KeyboardFocusProps &\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?: /** @deprecated use `manual` */\n | 'tabs'\n /** @deprecated use `auto` */\n | 'radio'\n | 'auto'\n | 'manual';\n };\n\n/** @deprecated */\nexport interface IPillProps extends PillProps, UnknownProperties {}\nexport type PillProps = BoxProps &\n NeighborItemProps &\n KeyboardFocusProps & {\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) &\n Intergalactic.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":""}
|
package/lib/es6/index.d.js
DELETED
package/lib/es6/index.d.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import React from 'react';\nimport { PropGetterFn, UnknownProperties, Intergalactic } from '@semcore/core';\nimport { Box, BoxProps } from '@semcore/flex-box';\nimport { NeighborItemProps, NeighborLocationProps } from '@semcore/neighbor-location';\nimport { KeyboardFocusProps } from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\n\nexport type PillsValue = string | number | boolean | null;\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 KeyboardFocusProps &\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?: /** @deprecated use `manual` */\n | 'tabs'\n /** @deprecated use `auto` */\n | 'radio'\n | 'auto'\n | 'manual';\n };\n\n/** @deprecated */\nexport interface IPillProps extends PillProps, UnknownProperties {}\nexport type PillProps = BoxProps &\n NeighborItemProps &\n KeyboardFocusProps & {\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) &\n Intergalactic.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":""}
|