skillgrid 0.0.25 → 0.0.27

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.
Files changed (36) hide show
  1. package/dist/components/Button/Button.d.ts +1 -1
  2. package/dist/components/Button/Button.type.d.ts +121 -43
  3. package/dist/components/Button/assets/ArrowIcon.d.ts +5 -0
  4. package/dist/components/Button/assets/ArrowRightIcon.d.ts +5 -0
  5. package/dist/components/Button/assets/CrossIcon.d.ts +5 -0
  6. package/dist/components/Button/assets/DownloadIcon.d.ts +5 -0
  7. package/dist/components/Button/assets/FollowIcon.d.ts +5 -0
  8. package/dist/components/Button/assets/HeartIcon.d.ts +5 -0
  9. package/dist/components/Button/assets/LocationIcon.d.ts +5 -0
  10. package/dist/components/Button/assets/MapMarkerIcon.d.ts +5 -0
  11. package/dist/components/Button/assets/index.d.ts +9 -0
  12. package/dist/components/Button/assets/types.d.ts +7 -0
  13. package/dist/components/Button/lib/get-safe-props.d.ts +8 -0
  14. package/dist/components/Button/lib/get-safe-props.test.d.ts +1 -0
  15. package/dist/components/Button/lib/get-typography.d.ts +11 -0
  16. package/dist/components/Button/lib/get-typography.test.d.ts +1 -0
  17. package/dist/components/Button/preview/index.d.ts +8 -0
  18. package/dist/components/Radio/Radio.type.d.ts +14 -2
  19. package/dist/components/Radio/RadioGroup/RadioGroup.d.ts +2 -1
  20. package/dist/components/Radio/RadioGroup/RadioGroup.type.d.ts +1 -1
  21. package/dist/components/Radio/index.d.ts +4 -2
  22. package/dist/components/Tabs/ScrollWrapper.d.ts +9 -0
  23. package/dist/components/Tabs/Tabs.d.ts +99 -0
  24. package/dist/components/Tabs/Tabs.type.d.ts +199 -0
  25. package/dist/components/Tabs/index.d.ts +2 -0
  26. package/dist/hooks/index.d.ts +1 -0
  27. package/dist/hooks/useIsMobile.d.ts +1 -0
  28. package/dist/hooks/useViewPortSize.d.ts +4 -0
  29. package/dist/hooks/useWindowEvent.d.ts +3 -0
  30. package/dist/index.cjs.js +13 -11
  31. package/dist/index.css +1 -1
  32. package/dist/index.d.ts +3 -0
  33. package/dist/index.es.js +2089 -1625
  34. package/dist/types/common.d.ts +1 -0
  35. package/dist/types/index.d.ts +1 -0
  36. package/package.json +2 -1
@@ -5,7 +5,7 @@ import { ButtonProps } from './Button.type';
5
5
  * @component
6
6
  * @example
7
7
  * ```tsx
8
- * <Button mode="primary" size="medium" buttonStyle="accent">Click me</Button>
8
+ * <Button mode="primary" size="m" buttonStyle="accent">Click me</Button>
9
9
  * ```
10
10
  */
11
11
  export declare const Button: import('react').ForwardRefExoticComponent<(ButtonProps & {
@@ -1,95 +1,160 @@
1
- export interface ButtonCommonProps {
1
+ export type LinkSizeType = 'l' | 'm' | 's';
2
+ /**
3
+ * Link style variants - buttonStyle and mode combinations
4
+ */
5
+ type LinkStyleProps = {
6
+ /**
7
+ * Button style type
8
+ * @default 'neutral'
9
+ */
10
+ buttonStyle?: 'neutral';
2
11
  /**
3
12
  * Button variant
4
13
  * @default 'primary'
5
14
  */
6
15
  mode?: 'primary' | 'secondary' | 'tertiary';
16
+ } | {
7
17
  /**
8
- * Размер кнопки
9
- * @default 'm'
18
+ * Button style type
19
+ * @default 'accent'
10
20
  */
11
- size?: 'l' | 'm' | 's' | 'xs';
21
+ buttonStyle?: 'accent' | 'positive' | 'negative' | 'contrast' | 'warning';
12
22
  /**
13
- * Button style type
14
- * @default 'neutral'
23
+ * Button variant
24
+ * @default 'primary'
15
25
  */
16
- buttonStyle?: 'neutral' | 'accent' | 'positive' | 'negative' | 'special' | 'contrast';
26
+ mode?: 'primary' | 'secondary';
27
+ };
28
+ /**
29
+ * Link icon variants
30
+ * - With icons: size is required
31
+ * - Without icons: size is optional
32
+ */
33
+ type LinkIconVariant = {
17
34
  /**
18
- * Показывает состояние загрузки
19
- * @default false
35
+ * Icons render only when size is provided.
36
+ * @default 'm'
20
37
  */
21
- loading?: boolean;
38
+ size: LinkSizeType;
39
+ iconLeft?: React.ReactNode;
40
+ iconRight?: React.ReactNode;
41
+ } | {
42
+ /** No icons in this variant */
43
+ size?: LinkSizeType;
44
+ iconLeft?: never;
45
+ iconRight?: never;
46
+ };
47
+ /**
48
+ * Base properties common to all link variants
49
+ */
50
+ type LinkBaseProps = Omit<ButtonBaseProps, 'mode' | 'iconRight'> & LinkStyleProps & {
51
+ /**
52
+ * Display variant
53
+ */
54
+ displayAs: 'link';
22
55
  /**
23
- * Делает кнопку недоступной
56
+ * Underline setting (only for displayAs='link')
24
57
  * @default false
25
58
  */
26
- disabled?: boolean;
59
+ showUnderline?: boolean;
60
+ postfix?: never;
61
+ subcaption?: never;
62
+ loading?: never;
63
+ stretched?: never;
64
+ };
65
+ /**
66
+ * Base properties common to all button variants
67
+ */
68
+ type ButtonBaseProps = {
27
69
  /**
28
- * Show badge
70
+ * Button variant
71
+ * @default 'primary'
29
72
  */
30
- showBadge?: boolean;
73
+ mode?: 'primary' | 'secondary' | 'tertiary';
31
74
  /**
32
- * Badge size
75
+ * Disables the button
76
+ * @default false
33
77
  */
34
- badgeSize?: 'small' | 'extra-small';
78
+ disabled?: boolean;
35
79
  /**
36
- * Badge value
80
+ * Button icon (right side)
37
81
  */
38
- badgeValue?: number | string;
82
+ iconRight?: React.ReactNode;
39
83
  /**
40
- * Show subcaption
84
+ * Additional CSS class
41
85
  */
42
- showSubcaption?: boolean;
86
+ className?: string;
43
87
  /**
44
- * Subcaption text or node
88
+ * Tab index
45
89
  */
46
- subcaption?: string | React.ReactNode;
90
+ tabIndex?: number;
47
91
  /**
48
- * Stretch button to full width
49
- * @default false
92
+ * Children content
50
93
  */
51
- stretched?: boolean;
94
+ children?: React.ReactNode;
52
95
  /**
53
- * Distribute content to both edges
54
- * @default false
96
+ * Test ID for testing
55
97
  */
56
- spaceBetween?: boolean;
98
+ 'data-testid'?: string;
99
+ };
100
+ type CommonProps = (ButtonBaseProps & {
57
101
  /**
58
- * Button icon
102
+ * Button style type
103
+ * @default 'neutral'
59
104
  */
60
- icon?: React.ReactNode;
105
+ buttonStyle?: 'neutral' | 'accent' | 'positive' | 'negative' | 'contrast' | 'special';
61
106
  /**
62
- * Button postfix
107
+ * Button size
108
+ * @default 'm'
63
109
  */
64
- postfix?: string | React.ReactNode;
110
+ size?: 'l' | 'm' | 's' | 'xs';
65
111
  /**
66
- * Additional CSS class
112
+ * Display variant
113
+ * @default 'button'
67
114
  */
68
- className?: string;
115
+ displayAs?: 'button';
69
116
  /**
70
- * Tab index
117
+ * Button postfix (only for displayAs='button')
71
118
  */
72
- tabIndex?: number;
119
+ postfix?: React.ReactNode;
73
120
  /**
74
- * Children content
121
+ * Subcaption text or node (only for displayAs='button')
75
122
  */
76
- children?: React.ReactNode;
123
+ subcaption?: React.ReactNode;
77
124
  /**
78
- * Test ID for testing
125
+ * Shows loading state
126
+ * @default false
79
127
  */
80
- 'data-testid'?: string;
81
- }
128
+ loading?: boolean;
129
+ /**
130
+ * Stretch button to full width, optionally with justify-content control
131
+ * @default false
132
+ * @example
133
+ * stretched={true} // Simple full width
134
+ * stretched={{ justify: 'space-between' }} // Full width with space-between
135
+ */
136
+ stretched?: boolean | {
137
+ justify: React.CSSProperties['justifyContent'];
138
+ };
139
+ iconLeft?: never;
140
+ showUnderline?: never;
141
+ }) | (LinkBaseProps & LinkIconVariant);
82
142
  /**
83
143
  * Props when rendered as a native HTMLButtonElement (default behaviour).
84
144
  */
85
- export type ButtonAsNativeButtonProps = ButtonCommonProps & React.ButtonHTMLAttributes<HTMLButtonElement> & {
145
+ export type ButtonAsNativeButtonProps = CommonProps & React.ButtonHTMLAttributes<HTMLButtonElement> & {
86
146
  as?: 'button';
87
147
  };
88
148
  /**
89
149
  * Props when rendered as an anchor (HTMLAnchorElement).
90
150
  */
91
- export type ButtonAsAnchorProps = Omit<ButtonCommonProps, 'type'> & React.AnchorHTMLAttributes<HTMLAnchorElement> & {
151
+ export type ButtonAsAnchorProps = CommonProps & React.AnchorHTMLAttributes<HTMLAnchorElement> & {
92
152
  as: 'a';
153
+ /**
154
+ * External link default. If target/rel are not provided, sets target="_blank"
155
+ * and adds rel="noopener noreferrer". Explicit target/rel take precedence.
156
+ */
157
+ isExternal?: boolean;
93
158
  };
94
159
  /**
95
160
  * Discriminated union tying `href` and `onClick` types to the `as` prop.
@@ -103,3 +168,16 @@ export declare const isAsLink: (props: ButtonProps) => props is ButtonAsAnchorPr
103
168
  * Runtime type guard that checks if the provided props correspond to a native button variant.
104
169
  */
105
170
  export declare const isAsButton: (props: ButtonProps) => props is ButtonAsNativeButtonProps;
171
+ /**
172
+ * Runtime type guard that checks if the component should be displayed as a button.
173
+ */
174
+ export declare const isDisplayAsButton: (props: ButtonProps) => props is Extract<ButtonProps, {
175
+ displayAs?: "button";
176
+ }>;
177
+ /**
178
+ * Runtime type guard that checks if the component should be displayed as a link.
179
+ */
180
+ export declare const isDisplayAsLink: (props: ButtonProps) => props is Extract<ButtonProps, {
181
+ displayAs: "link";
182
+ }>;
183
+ export {};
@@ -0,0 +1,5 @@
1
+ import { IconProps } from './types';
2
+ /**
3
+ * Arrow icon used in Button examples
4
+ */
5
+ export declare const ArrowIcon: React.FC<IconProps>;
@@ -0,0 +1,5 @@
1
+ import { IconProps } from './types';
2
+ /**
3
+ * Simple arrow right icon used in Button examples
4
+ */
5
+ export declare const ArrowRightIcon: React.FC<IconProps>;
@@ -0,0 +1,5 @@
1
+ import { IconProps } from './types';
2
+ /**
3
+ * Cross/close icon used in Button examples
4
+ */
5
+ export declare const CrossIcon: React.FC<IconProps>;
@@ -0,0 +1,5 @@
1
+ import { IconProps } from './types';
2
+ /**
3
+ * Download icon used in Button examples
4
+ */
5
+ export declare const DownloadIcon: React.FC<IconProps>;
@@ -0,0 +1,5 @@
1
+ import { IconProps } from './types';
2
+ /**
3
+ * Follow/external link icon used in Button examples
4
+ */
5
+ export declare const FollowIcon: React.FC<IconProps>;
@@ -0,0 +1,5 @@
1
+ import { IconProps } from './types';
2
+ /**
3
+ * Heart icon used in Button examples
4
+ */
5
+ export declare const HeartIcon: React.FC<IconProps>;
@@ -0,0 +1,5 @@
1
+ import { IconProps } from './types';
2
+ /**
3
+ * Simple location pin icon used in Button examples
4
+ */
5
+ export declare const LocationIcon: React.FC<IconProps>;
@@ -0,0 +1,5 @@
1
+ import { IconProps } from './types';
2
+ /**
3
+ * Map marker icon used in Button examples
4
+ */
5
+ export declare const MapMarkerIcon: React.FC<IconProps>;
@@ -0,0 +1,9 @@
1
+ export type { IconProps } from './types';
2
+ export { ArrowRightIcon } from './ArrowRightIcon';
3
+ export { LocationIcon } from './LocationIcon';
4
+ export { MapMarkerIcon } from './MapMarkerIcon';
5
+ export { HeartIcon } from './HeartIcon';
6
+ export { ArrowIcon } from './ArrowIcon';
7
+ export { FollowIcon } from './FollowIcon';
8
+ export { DownloadIcon } from './DownloadIcon';
9
+ export { CrossIcon } from './CrossIcon';
@@ -0,0 +1,7 @@
1
+ export interface IconProps {
2
+ width?: number;
3
+ height?: number;
4
+ className?: string;
5
+ color?: string;
6
+ [key: string]: unknown;
7
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Filters out internal Button/Link component props from a props object.
3
+ * This ensures that only valid DOM attributes are forwarded to the underlying HTML element,
4
+ * preventing React warnings about unknown DOM properties.
5
+ * @param {T} props - The props object to filter
6
+ * @returns {Record<string, unknown>} A new object containing only safe props that can be forwarded to DOM elements
7
+ */
8
+ export declare const getSafeProps: <T extends Record<string, unknown>>(props: T) => Record<string, unknown>;
@@ -0,0 +1,11 @@
1
+ import { default as t } from '../../../styles/typography.module.css';
2
+ import { LinkSizeType } from '../Button.type';
3
+ type TypographyType = keyof typeof t;
4
+ /**
5
+ * Maps a Link size variant to its corresponding typography CSS class name.
6
+ * This ensures consistent typography styling across different link sizes.
7
+ * @param {LinkSizeType} size - The size of the link component ('l', 'm', or 's')
8
+ * @returns {TypographyType} The typography class name corresponding to the given size
9
+ */
10
+ declare function getTypography(size: LinkSizeType): TypographyType;
11
+ export { getTypography };
@@ -0,0 +1,8 @@
1
+ import { ReactNode, FC } from 'react';
2
+ export declare const LabelChip: FC<{
3
+ text: string;
4
+ }>;
5
+ export declare const Tile: FC<{
6
+ title: ReactNode;
7
+ children: ReactNode;
8
+ }>;
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react';
1
+ import { CSSProperties, ReactNode } from 'react';
2
2
  export interface Option<T extends string | number> {
3
3
  /**
4
4
  * Значение вариант
@@ -23,6 +23,10 @@ export interface RadioProps<T> {
23
23
  * Уникальное имя для компонента
24
24
  */
25
25
  name: string;
26
+ /**
27
+ * Идентификатор компонента, иначе используется name
28
+ */
29
+ id?: string;
26
30
  /**
27
31
  * Выбрано ли значение
28
32
  * - true - отмеченный
@@ -38,7 +42,7 @@ export interface RadioProps<T> {
38
42
  /**
39
43
  * Вложенный компонент справа
40
44
  */
41
- label?: ReactNode;
45
+ children?: ReactNode;
42
46
  /**
43
47
  * Загрузка (компонент становится неактивным)
44
48
  * @default false
@@ -74,6 +78,14 @@ export interface RadioProps<T> {
74
78
  * Формат отображения
75
79
  */
76
80
  mode?: 'card' | 'default';
81
+ /**
82
+ * Дополнительные CSS стили для контейнера
83
+ */
84
+ containerStyle?: CSSProperties;
85
+ /**
86
+ * Дополнительные CSS стили для radio
87
+ */
88
+ style?: CSSProperties;
77
89
  /**
78
90
  * Обработчик изменения состояния
79
91
  * @param value - Выбранное значение
@@ -1,3 +1,4 @@
1
+ import { ReactElement, RefAttributes } from 'react';
1
2
  import { RadioGroupProps } from './RadioGroup.type';
2
3
  /**
3
4
  * RadioGroup компонент для группировки Radio
@@ -18,4 +19,4 @@ import { RadioGroupProps } from './RadioGroup.type';
18
19
  * />
19
20
  * ```
20
21
  */
21
- export declare const RadioGroup: import('react').ForwardRefExoticComponent<RadioGroupProps<string | number> & import('react').RefAttributes<HTMLInputElement>>;
22
+ export declare const RadioGroup: <T extends string | number>(props: RadioGroupProps<T> & RefAttributes<HTMLInputElement>) => ReactElement | null;
@@ -1,5 +1,5 @@
1
1
  import { Option, RadioProps } from '../Radio.type';
2
- export interface RadioGroupProps<T extends string | number> extends Omit<RadioProps<T>, 'value' | 'label' | 'checked'> {
2
+ export interface RadioGroupProps<T extends string | number> extends Omit<RadioProps<T>, 'value' | 'children' | 'checked'> {
3
3
  /**
4
4
  * Список radio кнопок
5
5
  */
@@ -1,4 +1,6 @@
1
- export { Radio } from './Radio';
1
+ declare const Radio: (<T>(props: import('./Radio.type').RadioProps<T> & import('react').RefAttributes<HTMLInputElement>) => import('react').ReactElement | null) & {
2
+ Group: <T extends string | number>(props: import('.').RadioGroupProps<T> & import('react').RefAttributes<HTMLInputElement>) => import('react').ReactElement | null;
3
+ };
2
4
  export * from './Radio.type';
3
- export { RadioGroup } from './RadioGroup/RadioGroup';
4
5
  export * from './RadioGroup/RadioGroup.type';
6
+ export { Radio };
@@ -0,0 +1,9 @@
1
+ import { FC, ReactNode } from 'react';
2
+ interface ScrollWrapperProps {
3
+ children: ReactNode;
4
+ size: 'sm' | 'md' | 'xs';
5
+ withControls?: boolean;
6
+ className?: string;
7
+ }
8
+ export declare const ScrollWrapper: FC<ScrollWrapperProps>;
9
+ export {};
@@ -0,0 +1,99 @@
1
+ import { default as React, FC } from 'react';
2
+ import { TabsBarProps, TabPanelProps, TabsContentProps, TabsContextType, TabsProviderProps } from './Tabs.type';
3
+ /**
4
+ * useTabs - кастомный хук для доступа к контексту вкладок
5
+ *
6
+ * Должен использоваться внутри TabsProvider для доступа к активной вкладке и функции её изменения
7
+ * Бросает ошибку, если используется вне контекста TabsProvider
8
+ *
9
+ * @returns {TabsContextType} Объект контекста с activeTab и функцией setTab
10
+ * @throws {Error} Если хук используется вне TabsProvider
11
+ *
12
+ * @example
13
+ * const { activeTab, setTab } = useTabs();
14
+ */
15
+ export declare const useTabs: () => TabsContextType;
16
+ /**
17
+ * TabsProvider - провайдер контекста для управления состоянием вкладок.
18
+ *
19
+ * Хранит текущую активную вкладку и предоставляет метод (`setTab`)
20
+ * для её изменения, доступный всем дочерним компонентам через контекст.
21
+ *
22
+ * Поддерживает как контролируемый, так и неконтролируемый режим:
23
+ * - Неконтролируемый: использует `defaultActiveTab`
24
+ * - Контролируемый: использует `activeTab` и колбэк `onChange`
25
+ *
26
+ * @param defaultActiveTab - вкладка, выбранная по умолчанию (неконтролируемый режим)
27
+ * @param activeTab - текущая активная вкладка (контролируемый режим)
28
+ * @param onChange - колбэк, вызываемый при изменении активной вкладки
29
+ * @param children - дочерние компоненты, которые будут иметь доступ к TabsContext
30
+ *
31
+ * @example
32
+ * <Tabs.Provider defaultActiveTab="tab1" onChange={(val) => console.log(val)}>
33
+ * <Tabs.Bar mode="primary" items={tabItems} />
34
+ * <Tabs.Content>
35
+ * <Tabs.Panel tabValue="tab1">Content 1</Tabs.Panel>
36
+ * <Tabs.Panel tabValue="tab2">Content 2</Tabs.Panel>
37
+ * </Tabs.Content>
38
+ * </Tabs.Provider>
39
+ */
40
+ export declare const TabsProvider: FC<TabsProviderProps>;
41
+ /**
42
+ * Bar - компонент для отображения списка вкладок.
43
+ *
44
+ * Компонент связан с контекстом `TabsProvider` и обновляет
45
+ * активную вкладку при клике на элемент.
46
+ *
47
+ * @param mode - визуальный режим вкладки
48
+ * @param items - список вкладок для отображения
49
+ *
50
+ * @example
51
+ * <Tabs.Provider defaultActiveTab="tab1">
52
+ * <Tabs.Bar mode="primary" items={[
53
+ * { value: "tab1", label: "Tab 1" },
54
+ * { value: "tab2", label: "Tab 2", postfix: "🔥" }
55
+ * ]}/>
56
+ * </Tabs.Provider>
57
+ */
58
+ export declare const Bar: FC<TabsBarProps>;
59
+ /** ====================== Секция контента ====================== */
60
+ /**
61
+ * TabPanel - рендерит контент для конкретной вкладки внутри TabsContent.
62
+ * Отображается только панель активной вкладки.
63
+ * @param tabValue - идентификатор панели вкладки
64
+ * @param children - содержимое панели вкладки
65
+ * @param restProps - дополнительные пропсы, передаваемые в контейнерный div
66
+ *
67
+ * @example
68
+ * <TabPanel tabValue="tab1" className="p-4">
69
+ * Контент для Вкладки 1
70
+ * </TabPanel>
71
+ */
72
+ export declare const TabPanel: FC<TabPanelProps>;
73
+ /**
74
+ * TabsContent - компонент для отображения панелей вкладок,
75
+ * связанных с активной вкладкой.
76
+ *
77
+ * Принимает дочерние элементы 'TabPanel' и отображает только тот,
78
+ * который соответствует текущей активной вкладке
79
+ *
80
+ * @param children - один или несколько компонентов 'TabPanel'.
81
+ * @param restProps - дополнительные пропсы, передаваемые в контейнерный div.
82
+ *
83
+ * @example
84
+ * <TabsProvider defaultActiveTab="tab1">
85
+ * <TabsContent className="tab-content">
86
+ * <TabPanel tabValue="tab1">Контент для Вкладки 1</TabPanel>
87
+ * <TabPanel tabValue="tab2">Контент для Вкладки 2</TabPanel>
88
+ * </TabsContent>
89
+ * </TabsProvider>
90
+ */
91
+ export declare const TabsContent: FC<TabsContentProps>;
92
+ /** ====================== Экспорт ====================== */
93
+ export declare const Tabs: {
94
+ Provider: React.FC<TabsProviderProps>;
95
+ Content: React.FC<TabsContentProps>;
96
+ Panel: React.FC<TabPanelProps>;
97
+ Bar: React.FC<TabsBarProps>;
98
+ };
99
+ export default Bar;