@astral/ui 4.67.0 → 4.68.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.
@@ -1,15 +1,3 @@
1
- import type { TabProps as MuiTabProps } from '@mui/material/Tab';
2
1
  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
+ 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;
@@ -1 +1,2 @@
1
1
  export * from './Tab';
2
+ export type { TabProps } from './types';
@@ -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 {};
@@ -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
- return (_jsx(Container, { children: _jsxs(Wrapper, { children: [_jsx(StyledTabs, { ...tabsProps }), _jsx(Divider, {})] }) }));
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,4 @@
1
+ /// <reference types="react" />
2
+ export declare const useScrollToActiveTab: () => {
3
+ containerRef: import("react").RefObject<HTMLDivElement | null>;
4
+ };
@@ -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,15 +1,3 @@
1
- import type { TabProps as MuiTabProps } from '@mui/material/Tab';
2
1
  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
+ 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;
@@ -1 +1,2 @@
1
1
  export * from './Tab';
2
+ export type { TabProps } from './types';
@@ -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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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
- 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 }), (0, jsx_runtime_1.jsx)(styles_1.Divider, {})] }) }));
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,4 @@
1
+ /// <reference types="react" />
2
+ export declare const useScrollToActiveTab: () => {
3
+ containerRef: import("react").RefObject<HTMLDivElement | null>;
4
+ };
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astral/ui",
3
- "version": "4.67.0",
3
+ "version": "4.68.0",
4
4
  "browser": "./index.js",
5
5
  "main": "./node/index.js",
6
6
  "dependencies": {