skillgrid 0.0.42 → 0.0.43

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,6 +1,7 @@
1
- import { ButtonProps, BackButtonProps } from './Button.type';
1
+ import { ButtonProps, BackButtonProps, LinkButtonProps } from './Button.type';
2
2
  export declare const Button: import('react').ForwardRefExoticComponent<(ButtonProps & {
3
3
  style?: React.CSSProperties;
4
4
  }) & import('react').RefAttributes<HTMLButtonElement | HTMLAnchorElement>> & {
5
5
  Back: import('react').ForwardRefExoticComponent<BackButtonProps & import('react').RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
6
+ Link: import('react').ForwardRefExoticComponent<LinkButtonProps & import('react').RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
6
7
  };
@@ -1,5 +1,13 @@
1
1
  export type LinkSize = 'l' | 'm' | 's';
2
2
  export type ButtonSize = 'l' | 'm' | 's' | 'xs';
3
+ /**
4
+ * Button style types - all available styles including gray
5
+ */
6
+ export type ButtonStyle = 'neutral' | 'accent' | 'positive' | 'negative' | 'contrast' | 'gray' | 'warning' | 'dreamy' | 'special' | 'lovely' | 'vivid' | 'blue';
7
+ /**
8
+ * Button style types without gray variant
9
+ */
10
+ export type ButtonStyleWithoutGray = Exclude<ButtonStyle, 'gray'>;
3
11
  /**
4
12
  * Base properties common to all button and link variants
5
13
  */
@@ -85,51 +93,24 @@ type ButtonBaseProps = BaseProps & {
85
93
  */
86
94
  iconLeft?: React.ReactNode;
87
95
  };
88
- /**
89
- * Base properties common to all link variants
90
- */
91
- type LinkBaseProps = BaseProps & LinkStyleProps & {
92
- /**
93
- * Display variant
94
- */
95
- displayAs: 'link';
96
- /**
97
- * Underline setting (only for displayAs='link')
98
- * @default false
99
- */
100
- showUnderline?: boolean;
101
- /**
102
- * Button icon (right side, only for links)
103
- */
104
- iconRight?: React.ReactNode;
105
- postfix?: never;
106
- subcaption?: never;
107
- loading?: never;
108
- stretched?: never;
109
- };
110
96
  type CommonProps = (Omit<ButtonBaseProps, 'mode'> & {
111
97
  /**
112
- * Button style type
98
+ * Button style type (gray is not available for this variant)
113
99
  * @default 'neutral'
114
100
  */
115
- buttonStyle?: 'neutral' | 'accent' | 'positive' | 'negative' | 'contrast' | 'gray';
101
+ buttonStyle?: ButtonStyleWithoutGray;
116
102
  /**
117
- * Button variant - primary mode supports all buttonStyle options including gray
103
+ * Button variant - supports both primary and secondary modes
118
104
  * @default 'primary'
119
105
  */
120
- mode?: 'primary';
106
+ mode?: 'primary' | 'secondary';
121
107
  /**
122
108
  * Button size
123
109
  * @default 'm'
124
110
  */
125
111
  size?: ButtonSize;
126
112
  /**
127
- * Display variant
128
- * @default 'button'
129
- */
130
- displayAs?: 'button';
131
- /**
132
- * Button postfix (only for displayAs='button')
113
+ * Button postfix
133
114
  */
134
115
  postfix?: React.ReactNode;
135
116
  /**
@@ -156,27 +137,24 @@ type CommonProps = (Omit<ButtonBaseProps, 'mode'> & {
156
137
  paddings?: never;
157
138
  } & ButtonSizeAndSubcaption) | (Omit<ButtonBaseProps, 'mode'> & {
158
139
  /**
159
- * Button style type (gray is not available for secondary/tertiary)
140
+ * Button style type - supports union types including 'gray'
141
+ * When 'gray' is used, mode must be 'primary' only
160
142
  * @default 'neutral'
161
143
  */
162
- buttonStyle?: 'neutral' | 'accent' | 'positive' | 'negative' | 'contrast';
144
+ buttonStyle?: ButtonStyle;
163
145
  /**
164
- * Button variant
146
+ * Button variant - when buttonStyle includes 'gray', only 'primary' is allowed
147
+ * For other buttonStyle values, both 'primary' and 'secondary' are allowed
165
148
  * @default 'primary'
166
149
  */
167
- mode?: 'secondary';
150
+ mode?: 'primary' | 'secondary';
168
151
  /**
169
152
  * Button size
170
153
  * @default 'm'
171
154
  */
172
155
  size?: ButtonSize;
173
156
  /**
174
- * Display variant
175
- * @default 'button'
176
- */
177
- displayAs?: 'button';
178
- /**
179
- * Button postfix (only for displayAs='button')
157
+ * Button postfix
180
158
  */
181
159
  postfix?: React.ReactNode;
182
160
  /**
@@ -206,7 +184,7 @@ type CommonProps = (Omit<ButtonBaseProps, 'mode'> & {
206
184
  * Button style type (gray is not available for secondary/tertiary)
207
185
  * @default 'neutral'
208
186
  */
209
- buttonStyle?: 'neutral' | 'accent' | 'positive' | 'negative' | 'contrast';
187
+ buttonStyle?: ButtonStyleWithoutGray;
210
188
  /**
211
189
  * Button variant
212
190
  * @default 'primary'
@@ -218,12 +196,7 @@ type CommonProps = (Omit<ButtonBaseProps, 'mode'> & {
218
196
  */
219
197
  size?: ButtonSize;
220
198
  /**
221
- * Display variant
222
- * @default 'button'
223
- */
224
- displayAs?: 'button';
225
- /**
226
- * Button postfix (only for displayAs='button')
199
+ * Button postfix
227
200
  */
228
201
  postfix?: React.ReactNode;
229
202
  /**
@@ -252,7 +225,7 @@ type CommonProps = (Omit<ButtonBaseProps, 'mode'> & {
252
225
  paddings?: boolean;
253
226
  iconRight?: never;
254
227
  showUnderline?: never;
255
- } & ButtonSizeAndSubcaption) | (LinkBaseProps & LinkIconVariant);
228
+ } & ButtonSizeAndSubcaption);
256
229
  /**
257
230
  * Props when rendered as a native HTMLButtonElement (default behaviour).
258
231
  */
@@ -272,28 +245,17 @@ export type ButtonAsAnchorProps = CommonProps & React.AnchorHTMLAttributes<HTMLA
272
245
  };
273
246
  /**
274
247
  * Discriminated union tying `href` and `onClick` types to the `as` prop.
248
+ * Properties unavailable for regular Button (iconRight, showUnderline) are excluded from autocomplete.
275
249
  */
276
- export type ButtonProps = ButtonAsNativeButtonProps | ButtonAsAnchorProps;
250
+ export type ButtonProps = Omit<ButtonAsNativeButtonProps, 'iconRight' | 'showUnderline'> | Omit<ButtonAsAnchorProps, 'iconRight' | 'showUnderline'>;
277
251
  /**
278
252
  * Runtime type guard that checks if the provided props correspond to an anchor variant of the Button.
279
253
  */
280
- export declare const isAsLink: (props: ButtonProps) => props is ButtonAsAnchorProps;
254
+ export declare const isAsLink: (props: ButtonProps) => props is Omit<ButtonAsAnchorProps, "iconRight" | "showUnderline">;
281
255
  /**
282
256
  * Runtime type guard that checks if the provided props correspond to a native button variant.
283
257
  */
284
- export declare const isAsButton: (props: ButtonProps) => props is ButtonAsNativeButtonProps;
285
- /**
286
- * Runtime type guard that checks if the component should be displayed as a button.
287
- */
288
- export declare const isDisplayAsButton: (props: ButtonProps) => props is Extract<ButtonProps, {
289
- displayAs?: "button";
290
- }>;
291
- /**
292
- * Runtime type guard that checks if the component should be displayed as a link.
293
- */
294
- export declare const isDisplayAsLink: (props: ButtonProps) => props is Extract<ButtonProps, {
295
- displayAs: "link";
296
- }>;
258
+ export declare const isAsButton: (props: ButtonProps) => props is Omit<ButtonAsNativeButtonProps, "iconRight" | "showUnderline">;
297
259
  /**
298
260
  * Enforces that subcaption can be provided only when size is 'l'.
299
261
  * - If subcaption is present → size must be 'l'
@@ -306,8 +268,38 @@ type ButtonSizeAndSubcaption = {
306
268
  subcaption: React.ReactNode;
307
269
  size: 'l';
308
270
  };
271
+ /**
272
+ * Props for Button.Link component - specialized variant for link display.
273
+ * Properties unavailable for Button.Link (loading, stretched, postfix, subcaption, paddings) are excluded from autocomplete.
274
+ */
275
+ export type LinkButtonProps = Omit<BaseProps & LinkStyleProps & LinkIconVariant & {
276
+ /**
277
+ * Underline setting
278
+ * @default false
279
+ */
280
+ showUnderline?: boolean;
281
+ /**
282
+ * Render as native button element
283
+ */
284
+ as?: 'button';
285
+ } & React.ButtonHTMLAttributes<HTMLButtonElement>, 'loading' | 'stretched' | 'postfix' | 'subcaption' | 'paddings'> | Omit<BaseProps & LinkStyleProps & LinkIconVariant & {
286
+ /**
287
+ * Underline setting
288
+ * @default false
289
+ */
290
+ showUnderline?: boolean;
291
+ /**
292
+ * Render as anchor element
293
+ */
294
+ as: 'a';
295
+ /**
296
+ * External link default. If target/rel are not provided, sets target="_blank"
297
+ * and adds rel="noopener noreferrer". Explicit target/rel take precedence.
298
+ */
299
+ isExternal?: boolean;
300
+ } & React.AnchorHTMLAttributes<HTMLAnchorElement>, 'loading' | 'stretched' | 'postfix' | 'subcaption' | 'paddings'>;
309
301
  /**
310
302
  * Props for Button.Back component - based on ButtonProps with restricted design props
311
303
  */
312
- export type BackButtonProps = Omit<ButtonAsNativeButtonProps, 'mode' | 'buttonStyle' | 'size' | 'displayAs' | 'loading' | 'stretched' | 'postfix' | 'subcaption' | 'iconRight' | 'showUnderline'> | Omit<ButtonAsAnchorProps, 'mode' | 'buttonStyle' | 'size' | 'displayAs' | 'loading' | 'stretched' | 'postfix' | 'subcaption' | 'iconRight' | 'showUnderline'>;
304
+ export type BackButtonProps = Omit<ButtonAsNativeButtonProps, 'mode' | 'buttonStyle' | 'size' | 'loading' | 'stretched' | 'postfix' | 'subcaption' | 'iconRight' | 'showUnderline'> | Omit<ButtonAsAnchorProps, 'mode' | 'buttonStyle' | 'size' | 'loading' | 'stretched' | 'postfix' | 'subcaption' | 'iconRight' | 'showUnderline'>;
313
305
  export {};
@@ -1,2 +1,2 @@
1
1
  export { Button } from './Button';
2
- export type { ButtonProps } from './Button.type';
2
+ export type { ButtonProps, BackButtonProps, LinkButtonProps } from './Button.type';
@@ -0,0 +1,11 @@
1
+ import { HTMLAttributeAnchorTarget } from 'react';
2
+ type GetSafeRelParams = {
3
+ rel?: string;
4
+ target?: HTMLAttributeAnchorTarget;
5
+ };
6
+ /**
7
+ * Гарантирует, что ссылки, открывающиеся в новой вкладке, содержат rel-атрибуты,
8
+ * блокирующие доступ к объекту `window.opener`.
9
+ */
10
+ export declare const getSafeRel: ({ rel, target }: GetSafeRelParams) => string | undefined;
11
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import { default as React } from 'react';
2
+ import { IconProps } from './Icon.type';
3
+ /**
4
+ * Компонент Icon для отображения SVG иконок из assets
5
+ * Поддерживает только React элементы (SVG), не поддерживает emoji и строки
6
+ */
7
+ type IconComponent = {
8
+ <E extends React.ElementType = 'button'>(props: IconProps<E>): React.ReactElement | null;
9
+ displayName?: string;
10
+ };
11
+ export declare const Icon: IconComponent;
12
+ export {};
@@ -0,0 +1,156 @@
1
+ export type IconModeBase = 'primary' | 'secondary';
2
+ export type IconMode = IconModeBase | 'tertiary';
3
+ export type IconStyleNonNeutral = 'accent' | 'positive' | 'negative' | 'warning' | 'special' | 'dreamy' | 'lovely' | 'vivid' | 'constant' | 'inverse' | 'custom' | 'none';
4
+ export type IconStyle = 'neutral' | IconStyleNonNeutral;
5
+ export type BorderStyle = 'neutral' | 'phantom' | 'overlay' | 'accent' | 'positive' | 'negative' | 'warning' | 'special' | 'dreamy' | 'lovely' | 'vivid';
6
+ export type BackgroundStyle = 'primary' | 'secondary' | 'tertiary' | 'transparent' | 'overlay' | 'constant' | 'inverse' | 'constant-secondary' | 'inverse-secondary' | 'positive' | 'warning' | 'negative' | 'accent' | 'positive-secondary' | 'warning-secondary' | 'negative-secondary' | 'accent-secondary' | 'special' | 'dreamy' | 'lovely' | 'vivid' | 'special-secondary' | 'dreamy-secondary' | 'lovely-secondary' | 'vivid-secondary';
7
+ export type IconSize = number;
8
+ export type ShadowMode = false | 'permanent' | 'increases-when-pressed';
9
+ export type BadgeSize = 'extra-small' | 'small';
10
+ export type BadgeSizeNumeric = 8 | 16 | 20;
11
+ export interface BadgeConfig {
12
+ show: boolean;
13
+ size?: BadgeSize;
14
+ value?: number | string;
15
+ }
16
+ type AsProp<E extends React.ElementType> = {
17
+ /**
18
+ * Элемент для рендера
19
+ * @default 'button'
20
+ */
21
+ as?: E;
22
+ };
23
+ type PropsToOmit<E extends React.ElementType, P> = keyof (AsProp<E> & P);
24
+ type PolymorphicComponentProps<E extends React.ElementType, Props = object> = Props & AsProp<E> & Omit<React.ComponentPropsWithoutRef<E>, PropsToOmit<E, Props>>;
25
+ type PolymorphicRef<E extends React.ElementType> = React.ComponentPropsWithRef<E>['ref'];
26
+ export type PolymorphicComponentPropsWithRef<E extends React.ElementType, Props = object> = PolymorphicComponentProps<E, Props> & {
27
+ ref?: PolymorphicRef<E>;
28
+ };
29
+ interface BaseIconProps {
30
+ /**
31
+ * Иконка (только React элементы - SVG)
32
+ * Используйте Icon.Category.Name компоненты для доступа к иконкам из assets
33
+ */
34
+ icon?: React.ReactElement;
35
+ /**
36
+ * Размер иконки в пикселях
37
+ * @default 24
38
+ */
39
+ iconSize?: IconSize;
40
+ /**
41
+ * Кастомный цвет для режима 'custom'
42
+ */
43
+ customColor?: string;
44
+ /**
45
+ * Стиль иконки при hover
46
+ * Позволяет задать любой цвет из набора для состояния hover
47
+ */
48
+ hoverStyle?: IconStyle;
49
+ /**
50
+ * Кастомный цвет для hover при hoverStyle='custom'
51
+ */
52
+ hoverCustomColor?: string;
53
+ /**
54
+ * Стиль иконки при pressed
55
+ * Позволяет задать любой цвет из набора для состояния pressed
56
+ */
57
+ pressedStyle?: IconStyle;
58
+ /**
59
+ * Кастомный цвет для pressed при pressedStyle='custom'
60
+ */
61
+ pressedCustomColor?: string;
62
+ /**
63
+ * Внутренние отступы
64
+ * @default false
65
+ */
66
+ padding?: false | number;
67
+ /**
68
+ * Фон иконки
69
+ * @default false
70
+ */
71
+ background?: false | BackgroundStyle;
72
+ /**
73
+ * Тень
74
+ * @default false
75
+ */
76
+ shadow?: ShadowMode;
77
+ /**
78
+ * Показывать рамку
79
+ * @default false
80
+ */
81
+ showBorder?: boolean;
82
+ /**
83
+ * Стиль рамки
84
+ * @default 'neutral'
85
+ */
86
+ borderStyle?: BorderStyle;
87
+ /**
88
+ * Радиус скругления углов
89
+ */
90
+ borderRadius?: number | '50%';
91
+ /**
92
+ * Конфигурация бейджа
93
+ */
94
+ badge?: BadgeConfig;
95
+ /**
96
+ * Состояние checked (для переключаемых иконок)
97
+ * @default false
98
+ */
99
+ checked?: false | React.ReactNode;
100
+ /**
101
+ * Состояние disabled
102
+ * @default false
103
+ */
104
+ disabled?: boolean;
105
+ /**
106
+ * Состояние loading
107
+ * @default false
108
+ */
109
+ loading?: boolean;
110
+ /**
111
+ * Дополнительный CSS класс
112
+ */
113
+ className?: string;
114
+ /**
115
+ * Inline стили
116
+ */
117
+ styles?: React.CSSProperties;
118
+ /**
119
+ * Test ID для тестирования
120
+ */
121
+ 'data-testid'?: string;
122
+ /**
123
+ * ARIA label для доступности
124
+ */
125
+ 'aria-label'?: string;
126
+ /**
127
+ * ARIA описание
128
+ */
129
+ 'aria-describedby'?: string;
130
+ }
131
+ interface NeutralIconProps extends BaseIconProps {
132
+ /**
133
+ * Стиль иконки
134
+ * @default 'neutral'
135
+ */
136
+ style?: 'neutral';
137
+ /**
138
+ * Режим отображения иконки (для neutral доступны primary, secondary и tertiary)
139
+ * @default 'primary'
140
+ */
141
+ mode?: IconMode;
142
+ }
143
+ interface NonNeutralIconProps extends BaseIconProps {
144
+ /**
145
+ * Стиль иконки
146
+ */
147
+ style?: IconStyleNonNeutral;
148
+ /**
149
+ * Режим отображения иконки (только primary и secondary)
150
+ * @default 'primary'
151
+ */
152
+ mode?: IconModeBase;
153
+ }
154
+ type BaseIconPropsUnion = NeutralIconProps | NonNeutralIconProps;
155
+ export type IconProps<E extends React.ElementType = 'div'> = PolymorphicComponentPropsWithRef<E, BaseIconPropsUnion>;
156
+ export {};