@snack-uikit/segmented-control 0.6.23-preview-02d918ac.0 → 0.6.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 0.6.23 (2026-07-03)
|
|
7
|
+
|
|
8
|
+
### Only dependencies have been changed
|
|
9
|
+
* [@snack-uikit/truncate-string@0.7.14]($PUBLIC_PROJECT_URL/blob/master/packages/truncate-string/CHANGELOG.md)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
6
15
|
## 0.6.22 (2026-06-24)
|
|
7
16
|
|
|
8
17
|
### Only dependencies have been changed
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
3
5
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
4
6
|
var t = {};
|
|
5
7
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
@@ -30,30 +32,35 @@ const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
|
30
32
|
* SegmentedControl
|
|
31
33
|
*/
|
|
32
34
|
function SegmentedControl(_a) {
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
var defaultValue = _a.defaultValue,
|
|
36
|
+
_a$size = _a.size,
|
|
37
|
+
size = _a$size === void 0 ? 'm' : _a$size,
|
|
38
|
+
className = _a.className,
|
|
39
|
+
onChange = _a.onChange,
|
|
40
|
+
items = _a.items,
|
|
41
|
+
value = _a.value,
|
|
42
|
+
outline = _a.outline,
|
|
43
|
+
_a$width = _a.width,
|
|
44
|
+
width = _a$width === void 0 ? constants_1.WIDTH.Auto : _a$width,
|
|
45
|
+
name = _a.name,
|
|
44
46
|
other = __rest(_a, ["defaultValue", "size", "className", "onChange", "items", "value", "outline", "width", "name"]);
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
const _ref = (0, uncontrollable_1.useUncontrolledProp)(value, defaultValue, onChange),
|
|
48
|
+
_ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
49
|
+
selected = _ref2[0],
|
|
50
|
+
setSelected = _ref2[1];
|
|
51
|
+
const _ref3 = (0, hooks_1.useFocusControl)({
|
|
52
|
+
selected,
|
|
53
|
+
items
|
|
54
|
+
}),
|
|
55
|
+
focusableSegmentValue = _ref3.focusableSegmentValue,
|
|
56
|
+
onGetFocusable = _ref3.onGetFocusable,
|
|
57
|
+
onKeyDown = _ref3.onKeyDown;
|
|
54
58
|
const containerRef = (0, react_1.useRef)(null);
|
|
55
59
|
const selectedElementRef = (0, react_1.useRef)();
|
|
56
|
-
const
|
|
60
|
+
const _ref4 = (0, react_1.useState)(),
|
|
61
|
+
_ref5 = (0, _slicedToArray2.default)(_ref4, 2),
|
|
62
|
+
selectionPosition = _ref5[0],
|
|
63
|
+
setSelectionPosition = _ref5[1];
|
|
57
64
|
const updateSelectionPosition = (0, react_1.useCallback)(function () {
|
|
58
65
|
let element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : selectedElementRef.current;
|
|
59
66
|
if (!element) {
|
|
@@ -17,20 +17,18 @@ const truncate_string_1 = require("@snack-uikit/truncate-string");
|
|
|
17
17
|
const utils_1 = require("../../utils");
|
|
18
18
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
19
19
|
function Segment(_ref) {
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
renderWrapSegment
|
|
33
|
-
} = _ref;
|
|
20
|
+
let size = _ref.size,
|
|
21
|
+
label = _ref.label,
|
|
22
|
+
value = _ref.value,
|
|
23
|
+
selected = _ref.selected,
|
|
24
|
+
onClick = _ref.onClick,
|
|
25
|
+
disabled = _ref.disabled,
|
|
26
|
+
icon = _ref.icon,
|
|
27
|
+
counter = _ref.counter,
|
|
28
|
+
focusable = _ref.focusable,
|
|
29
|
+
onGetFocusable = _ref.onGetFocusable,
|
|
30
|
+
onSelectionUpdated = _ref.onSelectionUpdated,
|
|
31
|
+
renderWrapSegment = _ref.renderWrapSegment;
|
|
34
32
|
const buttonRef = (0, react_1.useRef)(null);
|
|
35
33
|
(0, react_1.useEffect)(() => {
|
|
36
34
|
if (focusable) {
|
|
@@ -44,7 +42,7 @@ function Segment(_ref) {
|
|
|
44
42
|
}, [selected, buttonRef, onSelectionUpdated]);
|
|
45
43
|
const segment = (0, jsx_runtime_1.jsxs)("button", {
|
|
46
44
|
ref: buttonRef,
|
|
47
|
-
"data-test-id":
|
|
45
|
+
"data-test-id": "section-".concat(value),
|
|
48
46
|
"data-active": selected || undefined,
|
|
49
47
|
"data-disabled": disabled || undefined,
|
|
50
48
|
"data-layout": (0, utils_1.getLayout)(icon, label, size),
|
package/dist/cjs/hooks.js
CHANGED
|
@@ -1,34 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.useFocusControl = useFocusControl;
|
|
7
9
|
const react_1 = require("react");
|
|
8
10
|
function useFocusControl(_ref) {
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
res.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
11
|
+
let selected = _ref.selected,
|
|
12
|
+
items = _ref.items;
|
|
13
|
+
const _ref2 = (0, react_1.useState)(selected),
|
|
14
|
+
_ref3 = (0, _slicedToArray2.default)(_ref2, 2),
|
|
15
|
+
focusableSegmentValue = _ref3[0],
|
|
16
|
+
setFocusableSegmentValue = _ref3[1];
|
|
17
|
+
const _ref4 = (0, react_1.useState)(false),
|
|
18
|
+
_ref5 = (0, _slicedToArray2.default)(_ref4, 2),
|
|
19
|
+
_ = _ref5[0],
|
|
20
|
+
setNeedSetFocus = _ref5[1];
|
|
21
|
+
const _ref6 = (0, react_1.useMemo)(() => items.reduce((res, item) => {
|
|
22
|
+
if (res._isNextSearching && !res.next) {
|
|
23
|
+
res.next = item.disabled ? res.next : item.value;
|
|
24
|
+
}
|
|
25
|
+
if (focusableSegmentValue === item.value) {
|
|
26
|
+
res._isNextSearching = true;
|
|
27
|
+
}
|
|
28
|
+
if (!res._isNextSearching) {
|
|
29
|
+
res.prev = item.disabled ? res.prev : item.value;
|
|
30
|
+
}
|
|
31
|
+
return res;
|
|
32
|
+
}, {
|
|
33
|
+
_isNextSearching: false
|
|
34
|
+
}), [focusableSegmentValue, items]),
|
|
35
|
+
prev = _ref6.prev,
|
|
36
|
+
next = _ref6.next;
|
|
32
37
|
const onKeyDown = (0, react_1.useCallback)(e => {
|
|
33
38
|
switch (e.key) {
|
|
34
39
|
case 'ArrowLeft':
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Segmented Control",
|
|
7
|
-
"version": "0.6.23
|
|
7
|
+
"version": "0.6.23",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"scripts": {},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@snack-uikit/counter": "0.8.12",
|
|
40
|
-
"@snack-uikit/truncate-string": "0.7.14
|
|
40
|
+
"@snack-uikit/truncate-string": "0.7.14",
|
|
41
41
|
"@snack-uikit/utils": "4.0.2",
|
|
42
42
|
"classnames": "2.5.1",
|
|
43
43
|
"uncontrollable": "8.0.4"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "864821fceaa6bbb61080166d14f1682fa16e3f85"
|
|
46
46
|
}
|