@snack-uikit/link 0.8.1 → 0.9.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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # 0.9.0 (2023-12-14)
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+
12
+ * **FF-3729:** replace enum with unions ([910db4a](https://github.com/cloud-ru-tech/snack-uikit/commit/910db4aa8231ccbc58e538e5c5c1f461b1dec275))
13
+
14
+
15
+
16
+
6
17
  ## 0.8.1 (2023-12-06)
7
18
 
8
19
  ### Only dependencies have been changed
package/README.md CHANGED
@@ -14,11 +14,11 @@
14
14
  import { Link } from '@snack-uikit/link';
15
15
 
16
16
  <Link
17
- onSurface={Link.onSurfaces.Accent}
17
+ onSurface='accent'
18
18
  href='https://cloud.ru/'
19
19
  text='Link text'
20
20
  external={true}
21
- onColor={Link.onSurfaces.Primary}
21
+ onColor='primary'
22
22
  />;
23
23
  ```
24
24
 
@@ -32,13 +32,13 @@ import { Link } from '@snack-uikit/link';
32
32
  | text | `string` | - | Текст ссылки |
33
33
  | className | `string` | - | CSS-класс |
34
34
  | href | `string` | # | Ссылка |
35
- | target | `HTMLAttributeAnchorTarget` | Target.Blank | HTML-атрибут target |
35
+ | target | `HTMLAttributeAnchorTarget` | _blank | HTML-атрибут target |
36
36
  | download | `string` | - | HTML-атрибут download |
37
37
  | onClick | `MouseEventHandler<HTMLAnchorElement>` | - | Колбек обработки клика |
38
- | size | enum Size: `"s"`, `"m"`, `"l"` | Size.S | Размер |
38
+ | size | enum Size: `"s"`, `"m"`, `"l"` | s | Размер |
39
39
  | external | `boolean` | - | Ведет ли ссылка на внешний ресурс (добавляет иконку если true) |
40
- | onColor | enum OnColor: `"invert-neutral"`, `"neutral"`, `"primary"`, `"red"`, `"orange"`, `"yellow"`, `"green"`, `"blue"`, `"violet"`, `"pink"` | OnColor.Primary | Стилизует ссылку для размещения на цветном фоне |
41
- | onSurface | enum OnSurface: `"background"`, `"decor"`, `"accent"` | OnSurface.Background | Тип поверхности, на которой размещена ссылка |
40
+ | onColor | enum OnColor: `"invert-neutral"`, `"neutral"`, `"primary"`, `"red"`, `"orange"`, `"yellow"`, `"green"`, `"blue"`, `"violet"`, `"pink"` | primary | Стилизует ссылку для размещения на цветном фоне |
41
+ | onSurface | enum OnSurface: `"background"`, `"decor"`, `"accent"` | background | Тип поверхности, на которой размещена ссылка |
42
42
 
43
43
 
44
44
  [//]: DOCUMENTATION_SECTION_END
@@ -1,6 +1,6 @@
1
1
  import { AnchorHTMLAttributes, MouseEventHandler } from 'react';
2
2
  import { WithSupportProps } from '@snack-uikit/utils';
3
- import { OnColor, OnSurface, Size, Target } from './constants';
3
+ import { OnColor, OnSurface, Size } from './types';
4
4
  export type LinkProps = WithSupportProps<{
5
5
  /** Текст ссылки */
6
6
  text?: string;
@@ -25,9 +25,3 @@ export type LinkProps = WithSupportProps<{
25
25
  }>;
26
26
  /** Компонент ссылка */
27
27
  export declare function Link({ text, className, href, target, download, onClick, onSurface, size, external, onColor, ...rest }: LinkProps): import("react/jsx-runtime").JSX.Element;
28
- export declare namespace Link {
29
- var sizes: typeof Size;
30
- var targets: typeof Target;
31
- var onColors: typeof OnColor;
32
- var onSurfaces: typeof OnSurface;
33
- }
@@ -14,14 +14,10 @@ import cn from 'classnames';
14
14
  import { ArrowLinksSVG } from '@snack-uikit/icons';
15
15
  import { TruncateString } from '@snack-uikit/truncate-string';
16
16
  import { extractSupportProps } from '@snack-uikit/utils';
17
- import { OnColor, OnSurface, Size, Target } from './constants';
17
+ import { ON_COLOR, ON_SURFACE, SIZE } from './constants';
18
18
  import styles from './styles.module.css';
19
19
  /** Компонент ссылка */
20
20
  export function Link(_a) {
21
- var { text = '', className, href = '#', target = Target.Blank, download, onClick, onSurface = OnSurface.Background, size = Size.S, external, onColor = OnColor.Primary } = _a, rest = __rest(_a, ["text", "className", "href", "target", "download", "onClick", "onSurface", "size", "external", "onColor"]);
22
- return (_jsxs("a", Object.assign({ className: cn(styles.link, className), href: href, target: target, download: download, onClick: onClick }, extractSupportProps(rest), { "data-size": size, "data-on-surface": onSurface, "data-color": onColor, rel: target === Target.Blank ? 'noopener noreferrer' : undefined }, { children: [_jsx(TruncateString, { text: text, maxLines: 1 }), external && _jsx(ArrowLinksSVG, { "data-test-id": 'link__external-icon', className: styles.icon })] })));
21
+ var { text = '', className, href = '#', target = '_blank', download, onClick, onSurface = ON_SURFACE.Background, size = SIZE.S, external, onColor = ON_COLOR.Primary } = _a, rest = __rest(_a, ["text", "className", "href", "target", "download", "onClick", "onSurface", "size", "external", "onColor"]);
22
+ return (_jsxs("a", Object.assign({ className: cn(styles.link, className), href: href, target: target, download: download, onClick: onClick }, extractSupportProps(rest), { "data-size": size, "data-on-surface": onSurface, "data-color": onColor, rel: target === '_blank' ? 'noopener noreferrer' : undefined }, { children: [_jsx(TruncateString, { text: text, maxLines: 1 }), external && _jsx(ArrowLinksSVG, { "data-test-id": 'link__external-icon', className: styles.icon })] })));
23
23
  }
24
- Link.sizes = Size;
25
- Link.targets = Target;
26
- Link.onColors = OnColor;
27
- Link.onSurfaces = OnSurface;
@@ -1,28 +1,28 @@
1
- export declare enum OnColor {
2
- InvertNeutral = "invert-neutral",
3
- Neutral = "neutral",
4
- Primary = "primary",
5
- Red = "red",
6
- Orange = "orange",
7
- Yellow = "yellow",
8
- Green = "green",
9
- Blue = "blue",
10
- Violet = "violet",
11
- Pink = "pink"
12
- }
13
- export declare enum Size {
14
- S = "s",
15
- M = "m",
16
- L = "l"
17
- }
18
- export declare enum Target {
19
- Self = "_self",
20
- Blank = "_blank",
21
- Parent = "_parent",
22
- Top = "_top"
23
- }
24
- export declare enum OnSurface {
25
- Background = "background",
26
- Decor = "decor",
27
- Accent = "accent"
28
- }
1
+ export declare const ON_COLOR: {
2
+ readonly InvertNeutral: "invert-neutral";
3
+ readonly Neutral: "neutral";
4
+ readonly Primary: "primary";
5
+ readonly Red: "red";
6
+ readonly Orange: "orange";
7
+ readonly Yellow: "yellow";
8
+ readonly Green: "green";
9
+ readonly Blue: "blue";
10
+ readonly Violet: "violet";
11
+ readonly Pink: "pink";
12
+ };
13
+ export declare const SIZE: {
14
+ readonly S: "s";
15
+ readonly M: "m";
16
+ readonly L: "l";
17
+ };
18
+ export declare const TARGET: {
19
+ readonly Self: "_self";
20
+ readonly Blank: "_blank";
21
+ readonly Parent: "_parent";
22
+ readonly Top: "_top";
23
+ };
24
+ export declare const ON_SURFACE: {
25
+ readonly Background: "background";
26
+ readonly Decor: "decor";
27
+ readonly Accent: "accent";
28
+ };
@@ -1,32 +1,28 @@
1
- export var OnColor;
2
- (function (OnColor) {
3
- OnColor["InvertNeutral"] = "invert-neutral";
4
- OnColor["Neutral"] = "neutral";
5
- OnColor["Primary"] = "primary";
6
- OnColor["Red"] = "red";
7
- OnColor["Orange"] = "orange";
8
- OnColor["Yellow"] = "yellow";
9
- OnColor["Green"] = "green";
10
- OnColor["Blue"] = "blue";
11
- OnColor["Violet"] = "violet";
12
- OnColor["Pink"] = "pink";
13
- })(OnColor || (OnColor = {}));
14
- export var Size;
15
- (function (Size) {
16
- Size["S"] = "s";
17
- Size["M"] = "m";
18
- Size["L"] = "l";
19
- })(Size || (Size = {}));
20
- export var Target;
21
- (function (Target) {
22
- Target["Self"] = "_self";
23
- Target["Blank"] = "_blank";
24
- Target["Parent"] = "_parent";
25
- Target["Top"] = "_top";
26
- })(Target || (Target = {}));
27
- export var OnSurface;
28
- (function (OnSurface) {
29
- OnSurface["Background"] = "background";
30
- OnSurface["Decor"] = "decor";
31
- OnSurface["Accent"] = "accent";
32
- })(OnSurface || (OnSurface = {}));
1
+ export const ON_COLOR = {
2
+ InvertNeutral: 'invert-neutral',
3
+ Neutral: 'neutral',
4
+ Primary: 'primary',
5
+ Red: 'red',
6
+ Orange: 'orange',
7
+ Yellow: 'yellow',
8
+ Green: 'green',
9
+ Blue: 'blue',
10
+ Violet: 'violet',
11
+ Pink: 'pink',
12
+ };
13
+ export const SIZE = {
14
+ S: 's',
15
+ M: 'm',
16
+ L: 'l',
17
+ };
18
+ export const TARGET = {
19
+ Self: '_self',
20
+ Blank: '_blank',
21
+ Parent: '_parent',
22
+ Top: '_top',
23
+ };
24
+ export const ON_SURFACE = {
25
+ Background: 'background',
26
+ Decor: 'decor',
27
+ Accent: 'accent',
28
+ };
@@ -1,2 +1,2 @@
1
1
  export * from './Link';
2
- export { OnColor } from './constants';
2
+ export { ON_COLOR } from './constants';
@@ -1,2 +1,2 @@
1
1
  export * from './Link';
2
- export { OnColor } from './constants';
2
+ export { ON_COLOR } from './constants';
@@ -0,0 +1,5 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+ import { ON_COLOR, ON_SURFACE, SIZE } from './constants';
3
+ export type OnColor = ValueOf<typeof ON_COLOR>;
4
+ export type Size = ValueOf<typeof SIZE>;
5
+ export type OnSurface = ValueOf<typeof ON_SURFACE>;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Link",
7
- "version": "0.8.1",
7
+ "version": "0.9.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -33,9 +33,9 @@
33
33
  "scripts": {},
34
34
  "dependencies": {
35
35
  "@snack-uikit/icons": "0.19.0",
36
- "@snack-uikit/truncate-string": "0.3.1",
37
- "@snack-uikit/utils": "3.1.0",
36
+ "@snack-uikit/truncate-string": "0.4.0",
37
+ "@snack-uikit/utils": "3.2.0",
38
38
  "classnames": "2.3.2"
39
39
  },
40
- "gitHead": "76a159dde7baccf49dc7b11e1fd7abc31424b42f"
40
+ "gitHead": "bd39c5e674f3b91b0e2487782a04b15034cf3d8b"
41
41
  }
@@ -5,8 +5,9 @@ import { ArrowLinksSVG } from '@snack-uikit/icons';
5
5
  import { TruncateString } from '@snack-uikit/truncate-string';
6
6
  import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
7
7
 
8
- import { OnColor, OnSurface, Size, Target } from './constants';
8
+ import { ON_COLOR, ON_SURFACE, SIZE } from './constants';
9
9
  import styles from './styles.module.scss';
10
+ import { OnColor, OnSurface, Size } from './types';
10
11
 
11
12
  export type LinkProps = WithSupportProps<{
12
13
  /** Текст ссылки */
@@ -36,13 +37,13 @@ export function Link({
36
37
  text = '',
37
38
  className,
38
39
  href = '#',
39
- target = Target.Blank,
40
+ target = '_blank',
40
41
  download,
41
42
  onClick,
42
- onSurface = OnSurface.Background,
43
- size = Size.S,
43
+ onSurface = ON_SURFACE.Background,
44
+ size = SIZE.S,
44
45
  external,
45
- onColor = OnColor.Primary,
46
+ onColor = ON_COLOR.Primary,
46
47
  ...rest
47
48
  }: LinkProps) {
48
49
  return (
@@ -56,15 +57,10 @@ export function Link({
56
57
  data-size={size}
57
58
  data-on-surface={onSurface}
58
59
  data-color={onColor}
59
- rel={target === Target.Blank ? 'noopener noreferrer' : undefined}
60
+ rel={target === '_blank' ? 'noopener noreferrer' : undefined}
60
61
  >
61
62
  <TruncateString text={text} maxLines={1} />
62
63
  {external && <ArrowLinksSVG data-test-id='link__external-icon' className={styles.icon} />}
63
64
  </a>
64
65
  );
65
66
  }
66
-
67
- Link.sizes = Size;
68
- Link.targets = Target;
69
- Link.onColors = OnColor;
70
- Link.onSurfaces = OnSurface;
@@ -1,31 +1,31 @@
1
- export enum OnColor {
2
- InvertNeutral = 'invert-neutral',
3
- Neutral = 'neutral',
4
- Primary = 'primary',
5
- Red = 'red',
6
- Orange = 'orange',
7
- Yellow = 'yellow',
8
- Green = 'green',
9
- Blue = 'blue',
10
- Violet = 'violet',
11
- Pink = 'pink',
12
- }
1
+ export const ON_COLOR = {
2
+ InvertNeutral: 'invert-neutral',
3
+ Neutral: 'neutral',
4
+ Primary: 'primary',
5
+ Red: 'red',
6
+ Orange: 'orange',
7
+ Yellow: 'yellow',
8
+ Green: 'green',
9
+ Blue: 'blue',
10
+ Violet: 'violet',
11
+ Pink: 'pink',
12
+ } as const;
13
13
 
14
- export enum Size {
15
- S = 's',
16
- M = 'm',
17
- L = 'l',
18
- }
14
+ export const SIZE = {
15
+ S: 's',
16
+ M: 'm',
17
+ L: 'l',
18
+ } as const;
19
19
 
20
- export enum Target {
21
- Self = '_self',
22
- Blank = '_blank',
23
- Parent = '_parent',
24
- Top = '_top',
25
- }
20
+ export const TARGET = {
21
+ Self: '_self',
22
+ Blank: '_blank',
23
+ Parent: '_parent',
24
+ Top: '_top',
25
+ } as const;
26
26
 
27
- export enum OnSurface {
28
- Background = 'background',
29
- Decor = 'decor',
30
- Accent = 'accent',
31
- }
27
+ export const ON_SURFACE = {
28
+ Background: 'background',
29
+ Decor: 'decor',
30
+ Accent: 'accent',
31
+ } as const;
@@ -1,2 +1,2 @@
1
1
  export * from './Link';
2
- export { OnColor } from './constants';
2
+ export { ON_COLOR } from './constants';
@@ -0,0 +1,9 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+
3
+ import { ON_COLOR, ON_SURFACE, SIZE } from './constants';
4
+
5
+ export type OnColor = ValueOf<typeof ON_COLOR>;
6
+
7
+ export type Size = ValueOf<typeof SIZE>;
8
+
9
+ export type OnSurface = ValueOf<typeof ON_SURFACE>;