@snack-uikit/segmented-control 0.4.20-preview-2b94e286.0 → 0.4.20-preview-845a4e8b.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/README.md +0 -1
- package/dist/cjs/components/SegmentedControl.d.ts +1 -5
- package/dist/cjs/components/SegmentedControl.js +3 -8
- package/dist/esm/components/SegmentedControl.d.ts +1 -5
- package/dist/esm/components/SegmentedControl.js +2 -2
- package/package.json +4 -4
- package/src/components/SegmentedControl.tsx +0 -6
package/README.md
CHANGED
|
@@ -22,7 +22,6 @@ SegmentedControl
|
|
|
22
22
|
| size | enum Size: `"s"`, `"m"`, `"l"` | m | Размер компонента. |
|
|
23
23
|
| outline | `boolean` | - | Обводка |
|
|
24
24
|
| width | enum Width: `"auto"`, `"full"` | auto | Управление шириной компонента. |
|
|
25
|
-
| name | `string` | - | Имя поля |
|
|
26
25
|
|
|
27
26
|
|
|
28
27
|
[//]: DOCUMENTATION_SECTION_END
|
|
@@ -33,12 +33,8 @@ export type SegmentedControlProps<Value extends IdType = IdType> = WithSupportPr
|
|
|
33
33
|
* Управление шириной компонента.
|
|
34
34
|
*/
|
|
35
35
|
width?: Width;
|
|
36
|
-
/**
|
|
37
|
-
* Имя поля
|
|
38
|
-
*/
|
|
39
|
-
name?: string;
|
|
40
36
|
}>;
|
|
41
37
|
/**
|
|
42
38
|
* SegmentedControl
|
|
43
39
|
*/
|
|
44
|
-
export declare function SegmentedControl<Value extends IdType>({ defaultValue, size, className, onChange, items, value, outline, width,
|
|
40
|
+
export declare function SegmentedControl<Value extends IdType>({ defaultValue, size, className, onChange, items, value, outline, width, ...other }: SegmentedControlProps<Value>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -38,10 +38,9 @@ function SegmentedControl(_a) {
|
|
|
38
38
|
items,
|
|
39
39
|
value,
|
|
40
40
|
outline,
|
|
41
|
-
width = constants_1.WIDTH.Auto
|
|
42
|
-
name
|
|
41
|
+
width = constants_1.WIDTH.Auto
|
|
43
42
|
} = _a,
|
|
44
|
-
other = __rest(_a, ["defaultValue", "size", "className", "onChange", "items", "value", "outline", "width"
|
|
43
|
+
other = __rest(_a, ["defaultValue", "size", "className", "onChange", "items", "value", "outline", "width"]);
|
|
45
44
|
const [selected, setSelected] = (0, uncontrollable_1.useUncontrolledProp)(value, defaultValue, onChange);
|
|
46
45
|
const {
|
|
47
46
|
focusableSegmentValue,
|
|
@@ -107,11 +106,7 @@ function SegmentedControl(_a) {
|
|
|
107
106
|
"data-outline": outline || undefined,
|
|
108
107
|
"data-width": width
|
|
109
108
|
}, (0, utils_1.extractDataTestProps)(other), (0, utils_1.extractSupportProps)(other), {
|
|
110
|
-
children: [
|
|
111
|
-
type: 'hidden',
|
|
112
|
-
value: selected,
|
|
113
|
-
name: name
|
|
114
|
-
}), (0, jsx_runtime_1.jsx)("div", {
|
|
109
|
+
children: [(0, jsx_runtime_1.jsx)("div", {
|
|
115
110
|
"data-size": size,
|
|
116
111
|
style: selectionPosition,
|
|
117
112
|
className: styles_module_scss_1.default.selection,
|
|
@@ -33,12 +33,8 @@ export type SegmentedControlProps<Value extends IdType = IdType> = WithSupportPr
|
|
|
33
33
|
* Управление шириной компонента.
|
|
34
34
|
*/
|
|
35
35
|
width?: Width;
|
|
36
|
-
/**
|
|
37
|
-
* Имя поля
|
|
38
|
-
*/
|
|
39
|
-
name?: string;
|
|
40
36
|
}>;
|
|
41
37
|
/**
|
|
42
38
|
* SegmentedControl
|
|
43
39
|
*/
|
|
44
|
-
export declare function SegmentedControl<Value extends IdType>({ defaultValue, size, className, onChange, items, value, outline, width,
|
|
40
|
+
export declare function SegmentedControl<Value extends IdType>({ defaultValue, size, className, onChange, items, value, outline, width, ...other }: SegmentedControlProps<Value>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -22,7 +22,7 @@ import styles from './styles.module.css';
|
|
|
22
22
|
* SegmentedControl
|
|
23
23
|
*/
|
|
24
24
|
export function SegmentedControl(_a) {
|
|
25
|
-
var { defaultValue, size = 'm', className, onChange, items, value, outline, width = WIDTH.Auto
|
|
25
|
+
var { defaultValue, size = 'm', className, onChange, items, value, outline, width = WIDTH.Auto } = _a, other = __rest(_a, ["defaultValue", "size", "className", "onChange", "items", "value", "outline", "width"]);
|
|
26
26
|
const [selected, setSelected] = useUncontrolledProp(value, defaultValue, onChange);
|
|
27
27
|
const { focusableSegmentValue, onGetFocusable, onKeyDown } = useFocusControl({ selected, items });
|
|
28
28
|
const containerRef = useRef(null);
|
|
@@ -60,5 +60,5 @@ export function SegmentedControl(_a) {
|
|
|
60
60
|
const itemsJSX = useMemo(() => items.map(props => (_jsx("div", { className: styles.segmentHolder, "data-width": width, children: _jsx(Segment, Object.assign({}, props, { size: size, onGetFocusable: onGetFocusable, selected: selected === props.value, onClick: () => setSelected(props.value), focusable: focusableSegmentValue === props.value, onSelectionUpdated: updateSelectionPosition })) }, props.value))), [items, width, size, onGetFocusable, selected, focusableSegmentValue, updateSelectionPosition, setSelected]);
|
|
61
61
|
return (
|
|
62
62
|
// eslint-disable-next-line jsx-a11y/interactive-supports-focus
|
|
63
|
-
_jsxs("div", Object.assign({ ref: containerRef, "data-size": size, onKeyDown: onKeyDown, className: cn(styles.container, className), role: 'radiogroup', "data-outline": outline || undefined, "data-width": width }, extractDataTestProps(other), extractSupportProps(other), { children: [
|
|
63
|
+
_jsxs("div", Object.assign({ ref: containerRef, "data-size": size, onKeyDown: onKeyDown, className: cn(styles.container, className), role: 'radiogroup', "data-outline": outline || undefined, "data-width": width }, extractDataTestProps(other), extractSupportProps(other), { children: [_jsx("div", { "data-size": size, style: selectionPosition, className: styles.selection, "aria-hidden": true }), itemsJSX] })));
|
|
64
64
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Segmented Control",
|
|
7
|
-
"version": "0.4.20-preview-
|
|
7
|
+
"version": "0.4.20-preview-845a4e8b.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"license": "Apache-2.0",
|
|
37
37
|
"scripts": {},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@snack-uikit/truncate-string": "0.6.
|
|
40
|
-
"@snack-uikit/utils": "3.8.
|
|
39
|
+
"@snack-uikit/truncate-string": "0.6.19-preview-845a4e8b.0",
|
|
40
|
+
"@snack-uikit/utils": "3.8.2-preview-845a4e8b.0",
|
|
41
41
|
"classnames": "2.5.1",
|
|
42
42
|
"uncontrollable": "8.0.4"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "84992c2beb4db1a6bddcb3209c0ffbd26df23185"
|
|
45
45
|
}
|
|
@@ -43,10 +43,6 @@ export type SegmentedControlProps<Value extends IdType = IdType> = WithSupportPr
|
|
|
43
43
|
* Управление шириной компонента.
|
|
44
44
|
*/
|
|
45
45
|
width?: Width;
|
|
46
|
-
/**
|
|
47
|
-
* Имя поля
|
|
48
|
-
*/
|
|
49
|
-
name?: string;
|
|
50
46
|
}>;
|
|
51
47
|
|
|
52
48
|
/**
|
|
@@ -61,7 +57,6 @@ export function SegmentedControl<Value extends IdType>({
|
|
|
61
57
|
value,
|
|
62
58
|
outline,
|
|
63
59
|
width = WIDTH.Auto,
|
|
64
|
-
name,
|
|
65
60
|
...other
|
|
66
61
|
}: SegmentedControlProps<Value>) {
|
|
67
62
|
const [selected, setSelected] = useUncontrolledProp(value, defaultValue, onChange);
|
|
@@ -134,7 +129,6 @@ export function SegmentedControl<Value extends IdType>({
|
|
|
134
129
|
{...extractDataTestProps(other)}
|
|
135
130
|
{...extractSupportProps(other)}
|
|
136
131
|
>
|
|
137
|
-
{name && <input type='hidden' value={selected} name={name} />}
|
|
138
132
|
<div data-size={size} style={selectionPosition} className={styles.selection} aria-hidden={true} />
|
|
139
133
|
{itemsJSX}
|
|
140
134
|
</div>
|