@astral/ui 4.67.0 → 4.68.1
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/components/Tabs/Tab/Tab.d.ts +1 -13
- package/components/Tabs/Tab/index.d.ts +1 -0
- package/components/Tabs/Tab/types.d.ts +14 -0
- package/components/Tabs/Tab/types.js +1 -0
- package/components/Tabs/Tabs.js +3 -1
- package/components/Tabs/hooks/index.d.ts +1 -0
- package/components/Tabs/hooks/index.js +1 -0
- package/components/Tabs/hooks/useScrollToActiveTab/index.d.ts +1 -0
- package/components/Tabs/hooks/useScrollToActiveTab/index.js +1 -0
- package/components/Tabs/hooks/useScrollToActiveTab/useScrollToActiveTab.d.ts +4 -0
- package/components/Tabs/hooks/useScrollToActiveTab/useScrollToActiveTab.js +24 -0
- package/components/Tabs/styles.js +14 -0
- package/components/TextField/styles.d.ts +2 -2
- package/components/TextField/styles.js +5 -0
- package/node/components/Tabs/Tab/Tab.d.ts +1 -13
- package/node/components/Tabs/Tab/index.d.ts +1 -0
- package/node/components/Tabs/Tab/types.d.ts +14 -0
- package/node/components/Tabs/Tab/types.js +2 -0
- package/node/components/Tabs/Tabs.js +3 -1
- package/node/components/Tabs/hooks/index.d.ts +1 -0
- package/node/components/Tabs/hooks/index.js +17 -0
- package/node/components/Tabs/hooks/useScrollToActiveTab/index.d.ts +1 -0
- package/node/components/Tabs/hooks/useScrollToActiveTab/index.js +17 -0
- package/node/components/Tabs/hooks/useScrollToActiveTab/useScrollToActiveTab.d.ts +4 -0
- package/node/components/Tabs/hooks/useScrollToActiveTab/useScrollToActiveTab.js +28 -0
- package/node/components/Tabs/styles.js +14 -0
- package/node/components/TextField/styles.d.ts +2 -2
- package/node/components/TextField/styles.js +5 -0
- package/package.json +1 -1
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import type { TabProps as MuiTabProps } from '@mui/material/Tab';
|
|
2
1
|
import { type ElementType } from 'react';
|
|
3
|
-
import { type
|
|
4
|
-
export type TabProps<TComponent extends ElementType, TComponentProps = {}> = WithoutEmotionSpecific<MuiTabProps<TComponent, TComponentProps>> & {
|
|
5
|
-
component?: TComponent;
|
|
6
|
-
/**
|
|
7
|
-
* Число счетчика
|
|
8
|
-
*/
|
|
9
|
-
count?: number;
|
|
10
|
-
/**
|
|
11
|
-
* Максимальное число которое отобразится в счетчике
|
|
12
|
-
*/
|
|
13
|
-
max?: number;
|
|
14
|
-
};
|
|
2
|
+
import { type TabProps } from './types';
|
|
15
3
|
export declare const Tab: <TComponent extends ElementType = "div", TComponentProps = {}>({ label, count, max, ...rest }: TabProps<TComponent, TComponentProps>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TabProps as MuiTabProps } from '@mui/material/Tab';
|
|
2
|
+
import { type ElementType } from 'react';
|
|
3
|
+
import { type WithoutEmotionSpecific } from '../../types/WithoutEmotionSpecific';
|
|
4
|
+
export type TabProps<TComponent extends ElementType, TComponentProps = {}> = WithoutEmotionSpecific<MuiTabProps<TComponent, TComponentProps>> & {
|
|
5
|
+
component?: TComponent;
|
|
6
|
+
/**
|
|
7
|
+
* Число счетчика
|
|
8
|
+
*/
|
|
9
|
+
count?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Максимальное число которое отобразится в счетчике
|
|
12
|
+
*/
|
|
13
|
+
max?: number;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/components/Tabs/Tabs.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useScrollToActiveTab } from './hooks';
|
|
2
3
|
import { Container, Divider, StyledTabs, Wrapper } from './styles';
|
|
3
4
|
export const Tabs = ({ ...tabsProps }) => {
|
|
4
|
-
|
|
5
|
+
const { containerRef } = useScrollToActiveTab();
|
|
6
|
+
return (_jsx(Container, { children: _jsxs(Wrapper, { children: [_jsx(StyledTabs, { ...tabsProps, ref: containerRef }), _jsx(Divider, {})] }) }));
|
|
5
7
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useScrollToActiveTab';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useScrollToActiveTab';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useScrollToActiveTab';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useScrollToActiveTab';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { useViewportType } from '../../../useViewportType';
|
|
3
|
+
export const useScrollToActiveTab = () => {
|
|
4
|
+
const containerRef = useRef(null);
|
|
5
|
+
const { isMobile } = useViewportType();
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
if (!containerRef.current || !isMobile) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const selectedTab = containerRef.current.querySelector('[aria-selected="true"]');
|
|
11
|
+
const runScroll = () => {
|
|
12
|
+
if (selectedTab) {
|
|
13
|
+
selectedTab.scrollIntoView({
|
|
14
|
+
behavior: 'smooth',
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
// TODO: Убрать setTimeout после отказа от MUI в компоненте
|
|
19
|
+
setTimeout(() => {
|
|
20
|
+
runScroll();
|
|
21
|
+
}, 200);
|
|
22
|
+
}, []);
|
|
23
|
+
return { containerRef };
|
|
24
|
+
};
|
|
@@ -4,6 +4,20 @@ export const Container = styled.div `
|
|
|
4
4
|
overflow-x: auto;
|
|
5
5
|
|
|
6
6
|
width: 100%;
|
|
7
|
+
|
|
8
|
+
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
9
|
+
/* Убираем видимую полосу прокрутки в firefox */
|
|
10
|
+
scrollbar-width: none;
|
|
11
|
+
|
|
12
|
+
overflow-x: auto;
|
|
13
|
+
|
|
14
|
+
width: 100%;
|
|
15
|
+
|
|
16
|
+
/* Убираем видимую полосу прокрутки в chrome */
|
|
17
|
+
&::-webkit-scrollbar {
|
|
18
|
+
display: none;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
7
21
|
`;
|
|
8
22
|
export const Divider = styled.div `
|
|
9
23
|
position: relative;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const StyledTextField: import("../styled").StyledComponent<{
|
|
2
|
-
variant?: import("@mui/material
|
|
3
|
-
} & Omit<import("@mui/material
|
|
2
|
+
variant?: import("@mui/material").TextFieldVariants | undefined;
|
|
3
|
+
} & Omit<import("@mui/material").OutlinedTextFieldProps | import("@mui/material").FilledTextFieldProps | import("@mui/material").StandardTextFieldProps, "variant"> & {
|
|
4
4
|
theme?: import("@emotion/react").Theme | undefined;
|
|
5
5
|
}, {}, {}>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formLabelClasses } from '@mui/material';
|
|
1
2
|
import { formHelperTextClasses } from '@mui/material/FormHelperText';
|
|
2
3
|
import TextField from '@mui/material/TextField';
|
|
3
4
|
import { styled } from '../styled';
|
|
@@ -17,5 +18,9 @@ export const StyledTextField = styled(TextField) `
|
|
|
17
18
|
|
|
18
19
|
&.${textFieldClassnames.disabled} {
|
|
19
20
|
pointer-events: none;
|
|
21
|
+
|
|
22
|
+
& .${formLabelClasses.root} {
|
|
23
|
+
pointer-events: none;
|
|
24
|
+
}
|
|
20
25
|
}
|
|
21
26
|
`;
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import type { TabProps as MuiTabProps } from '@mui/material/Tab';
|
|
2
1
|
import { type ElementType } from 'react';
|
|
3
|
-
import { type
|
|
4
|
-
export type TabProps<TComponent extends ElementType, TComponentProps = {}> = WithoutEmotionSpecific<MuiTabProps<TComponent, TComponentProps>> & {
|
|
5
|
-
component?: TComponent;
|
|
6
|
-
/**
|
|
7
|
-
* Число счетчика
|
|
8
|
-
*/
|
|
9
|
-
count?: number;
|
|
10
|
-
/**
|
|
11
|
-
* Максимальное число которое отобразится в счетчике
|
|
12
|
-
*/
|
|
13
|
-
max?: number;
|
|
14
|
-
};
|
|
2
|
+
import { type TabProps } from './types';
|
|
15
3
|
export declare const Tab: <TComponent extends ElementType = "div", TComponentProps = {}>({ label, count, max, ...rest }: TabProps<TComponent, TComponentProps>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TabProps as MuiTabProps } from '@mui/material/Tab';
|
|
2
|
+
import { type ElementType } from 'react';
|
|
3
|
+
import { type WithoutEmotionSpecific } from '../../types/WithoutEmotionSpecific';
|
|
4
|
+
export type TabProps<TComponent extends ElementType, TComponentProps = {}> = WithoutEmotionSpecific<MuiTabProps<TComponent, TComponentProps>> & {
|
|
5
|
+
component?: TComponent;
|
|
6
|
+
/**
|
|
7
|
+
* Число счетчика
|
|
8
|
+
*/
|
|
9
|
+
count?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Максимальное число которое отобразится в счетчике
|
|
12
|
+
*/
|
|
13
|
+
max?: number;
|
|
14
|
+
};
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Tabs = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const hooks_1 = require("./hooks");
|
|
5
6
|
const styles_1 = require("./styles");
|
|
6
7
|
const Tabs = ({ ...tabsProps }) => {
|
|
7
|
-
|
|
8
|
+
const { containerRef } = (0, hooks_1.useScrollToActiveTab)();
|
|
9
|
+
return ((0, jsx_runtime_1.jsx)(styles_1.Container, { children: (0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { children: [(0, jsx_runtime_1.jsx)(styles_1.StyledTabs, { ...tabsProps, ref: containerRef }), (0, jsx_runtime_1.jsx)(styles_1.Divider, {})] }) }));
|
|
8
10
|
};
|
|
9
11
|
exports.Tabs = Tabs;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useScrollToActiveTab';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useScrollToActiveTab"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useScrollToActiveTab';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useScrollToActiveTab"), exports);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useScrollToActiveTab = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useViewportType_1 = require("../../../useViewportType");
|
|
6
|
+
const useScrollToActiveTab = () => {
|
|
7
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
8
|
+
const { isMobile } = (0, useViewportType_1.useViewportType)();
|
|
9
|
+
(0, react_1.useEffect)(() => {
|
|
10
|
+
if (!containerRef.current || !isMobile) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const selectedTab = containerRef.current.querySelector('[aria-selected="true"]');
|
|
14
|
+
const runScroll = () => {
|
|
15
|
+
if (selectedTab) {
|
|
16
|
+
selectedTab.scrollIntoView({
|
|
17
|
+
behavior: 'smooth',
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
// TODO: Убрать setTimeout после отказа от MUI в компоненте
|
|
22
|
+
setTimeout(() => {
|
|
23
|
+
runScroll();
|
|
24
|
+
}, 200);
|
|
25
|
+
}, []);
|
|
26
|
+
return { containerRef };
|
|
27
|
+
};
|
|
28
|
+
exports.useScrollToActiveTab = useScrollToActiveTab;
|
|
@@ -30,6 +30,20 @@ exports.Container = styled_1.styled.div `
|
|
|
30
30
|
overflow-x: auto;
|
|
31
31
|
|
|
32
32
|
width: 100%;
|
|
33
|
+
|
|
34
|
+
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
35
|
+
/* Убираем видимую полосу прокрутки в firefox */
|
|
36
|
+
scrollbar-width: none;
|
|
37
|
+
|
|
38
|
+
overflow-x: auto;
|
|
39
|
+
|
|
40
|
+
width: 100%;
|
|
41
|
+
|
|
42
|
+
/* Убираем видимую полосу прокрутки в chrome */
|
|
43
|
+
&::-webkit-scrollbar {
|
|
44
|
+
display: none;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
33
47
|
`;
|
|
34
48
|
exports.Divider = styled_1.styled.div `
|
|
35
49
|
position: relative;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const StyledTextField: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
|
|
2
|
-
variant?: import("@mui/material
|
|
3
|
-
} & Omit<import("@mui/material
|
|
2
|
+
variant?: import("@mui/material").TextFieldVariants | undefined;
|
|
3
|
+
} & Omit<import("@mui/material").OutlinedTextFieldProps | import("@mui/material").FilledTextFieldProps | import("@mui/material").StandardTextFieldProps, "variant"> & {
|
|
4
4
|
theme?: import("@emotion/react").Theme | undefined;
|
|
5
5
|
}, {}, {}>;
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.StyledTextField = void 0;
|
|
7
|
+
const material_1 = require("@mui/material");
|
|
7
8
|
const FormHelperText_1 = require("@mui/material/FormHelperText");
|
|
8
9
|
const TextField_1 = __importDefault(require("@mui/material/TextField"));
|
|
9
10
|
const styled_1 = require("../styled");
|
|
@@ -23,5 +24,9 @@ exports.StyledTextField = (0, styled_1.styled)(TextField_1.default) `
|
|
|
23
24
|
|
|
24
25
|
&.${constants_1.textFieldClassnames.disabled} {
|
|
25
26
|
pointer-events: none;
|
|
27
|
+
|
|
28
|
+
& .${material_1.formLabelClasses.root} {
|
|
29
|
+
pointer-events: none;
|
|
30
|
+
}
|
|
26
31
|
}
|
|
27
32
|
`;
|