@snack-uikit/tag 0.11.2 → 0.11.3-preview-64081c67.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.
Files changed (46) hide show
  1. package/README.md +18 -2
  2. package/dist/cjs/components/Tag/Tag.d.ts +5 -20
  3. package/dist/cjs/components/Tag/Tag.js +10 -59
  4. package/dist/cjs/components/TagBase/TagBase.d.ts +8 -0
  5. package/dist/cjs/components/TagBase/TagBase.js +61 -0
  6. package/dist/cjs/components/TagBase/index.d.ts +1 -0
  7. package/dist/cjs/components/TagBase/index.js +25 -0
  8. package/dist/cjs/components/TagLink/TagLink.d.ts +9 -0
  9. package/dist/cjs/components/TagLink/TagLink.js +51 -0
  10. package/dist/cjs/components/TagLink/index.d.ts +1 -0
  11. package/dist/cjs/components/TagLink/index.js +25 -0
  12. package/dist/cjs/components/TagLink/styles.module.css +206 -0
  13. package/dist/cjs/index.d.ts +2 -0
  14. package/dist/cjs/index.js +2 -1
  15. package/dist/cjs/types.d.ts +19 -1
  16. package/dist/esm/components/Tag/Tag.d.ts +5 -20
  17. package/dist/esm/components/Tag/Tag.js +11 -22
  18. package/dist/esm/components/TagBase/TagBase.d.ts +8 -0
  19. package/dist/esm/components/TagBase/TagBase.js +22 -0
  20. package/dist/esm/components/TagBase/index.d.ts +1 -0
  21. package/dist/esm/components/TagBase/index.js +1 -0
  22. package/dist/esm/components/TagLink/TagLink.d.ts +9 -0
  23. package/dist/esm/components/TagLink/TagLink.js +20 -0
  24. package/dist/esm/components/TagLink/index.d.ts +1 -0
  25. package/dist/esm/components/TagLink/index.js +1 -0
  26. package/dist/esm/components/TagLink/styles.module.css +206 -0
  27. package/dist/esm/index.d.ts +2 -0
  28. package/dist/esm/index.js +1 -0
  29. package/dist/esm/types.d.ts +19 -1
  30. package/package.json +2 -2
  31. package/src/components/Tag/Tag.tsx +11 -61
  32. package/src/components/TagBase/TagBase.tsx +55 -0
  33. package/src/components/TagBase/index.ts +1 -0
  34. package/src/components/TagLink/TagLink.tsx +43 -0
  35. package/src/components/TagLink/index.ts +1 -0
  36. package/src/components/TagLink/styles.module.scss +147 -0
  37. package/src/index.ts +2 -0
  38. package/src/types.ts +22 -1
  39. /package/dist/cjs/components/{Tag → TagBase}/constants.d.ts +0 -0
  40. /package/dist/cjs/components/{Tag → TagBase}/constants.js +0 -0
  41. /package/dist/cjs/components/{Tag → TagBase}/styles.module.css +0 -0
  42. /package/dist/esm/components/{Tag → TagBase}/constants.d.ts +0 -0
  43. /package/dist/esm/components/{Tag → TagBase}/constants.js +0 -0
  44. /package/dist/esm/components/{Tag → TagBase}/styles.module.css +0 -0
  45. /package/src/components/{Tag → TagBase}/constants.ts +0 -0
  46. /package/src/components/{Tag → TagBase}/styles.module.scss +0 -0
package/README.md CHANGED
@@ -7,16 +7,32 @@
7
7
 
8
8
  [//]: DOCUMENTATION_SECTION_START
9
9
  [//]: THIS_SECTION_IS_AUTOGENERATED_PLEASE_DONT_EDIT_IT
10
+ ## isTagLinkProps
11
+ ### Props
12
+ | name | type | default value | description |
13
+ |------|------|---------------|-------------|
14
+ | href* | `string` | - | |
15
+ | label* | `string` | - | Текст |
16
+ | onDelete | `MouseEventHandler<HTMLButtonElement>` | - | Коллбэк на удаление |
17
+ | size | enum Size: `"xs"`, `"s"` | - | Размер |
18
+ | appearance | enum Appearance: `"neutral"`, `"primary"`, `"red"`, `"orange"`, `"yellow"`, `"green"`, `"blue"`, `"violet"`, `"pink"` | - | Внешний вид |
19
+ | className | `string` | - | CSS-класс |
20
+ | tabIndex | `number` | - | tabIndex кнопки удаления |
21
+ | onClick | `(e: MouseEvent<HTMLAnchorElement, MouseEvent>) => void` | - | |
22
+ | target | `string` | - | |
10
23
  ## Tag
11
24
  ### Props
12
25
  | name | type | default value | description |
13
26
  |------|------|---------------|-------------|
27
+ | href* | `string` | - | |
14
28
  | label* | `string` | - | Текст |
15
- | size | enum Size: `"xs"`, `"s"` | xs | Размер |
16
- | appearance | enum Appearance: `"neutral"`, `"primary"`, `"red"`, `"orange"`, `"yellow"`, `"green"`, `"blue"`, `"violet"`, `"pink"` | neutral | Внешний вид |
17
29
  | onDelete | `MouseEventHandler<HTMLButtonElement>` | - | Коллбэк на удаление |
30
+ | size | enum Size: `"xs"`, `"s"` | - | Размер |
31
+ | appearance | enum Appearance: `"neutral"`, `"primary"`, `"red"`, `"orange"`, `"yellow"`, `"green"`, `"blue"`, `"violet"`, `"pink"` | - | Внешний вид |
18
32
  | className | `string` | - | CSS-класс |
19
33
  | tabIndex | `number` | - | tabIndex кнопки удаления |
34
+ | onClick | `(e: MouseEvent<HTMLAnchorElement, MouseEvent>) => void` | - | |
35
+ | target | `string` | - | |
20
36
  ## TagRow
21
37
  ### Props
22
38
  | name | type | default value | description |
@@ -1,20 +1,5 @@
1
- import { MouseEventHandler } from 'react';
2
- import { WithSupportProps } from '@snack-uikit/utils';
3
- import { APPEARANCE } from '../../constants';
4
- import { Appearance, Size } from '../../types';
5
- export type TagProps = WithSupportProps<{
6
- /** Текст */
7
- label: string;
8
- /** Размер */
9
- size?: Size;
10
- /** Внешний вид */
11
- appearance?: Appearance;
12
- /** Коллбэк на удаление */
13
- onDelete?: MouseEventHandler<HTMLButtonElement>;
14
- /** CSS-класс */
15
- className?: string;
16
- /** tabIndex кнопки удаления */
17
- tabIndex?: number;
18
- }>;
19
- export declare function Tag({ label, size, appearance, onDelete, className, tabIndex, ...rest }: TagProps): import("react/jsx-runtime").JSX.Element;
20
- export { APPEARANCE };
1
+ import { TagBaseProps } from '../TagBase';
2
+ import { TagLinkProps } from '../TagLink';
3
+ export type TagProps = TagBaseProps | TagLinkProps;
4
+ export declare function isTagLinkProps(props: TagProps): props is TagLinkProps;
5
+ export declare function Tag(props: TagProps): import("react/jsx-runtime").JSX.Element;
@@ -1,68 +1,19 @@
1
1
  "use strict";
2
2
 
3
- var __rest = void 0 && (void 0).__rest || function (s, e) {
4
- var t = {};
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
8
- }
9
- return t;
10
- };
11
- var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
12
- return mod && mod.__esModule ? mod : {
13
- "default": mod
14
- };
15
- };
16
3
  Object.defineProperty(exports, "__esModule", {
17
4
  value: true
18
5
  });
19
- exports.APPEARANCE = void 0;
6
+ exports.isTagLinkProps = isTagLinkProps;
20
7
  exports.Tag = Tag;
21
8
  const jsx_runtime_1 = require("react/jsx-runtime");
22
- const classnames_1 = __importDefault(require("classnames"));
23
- const icons_1 = require("@snack-uikit/icons");
24
- const utils_1 = require("@snack-uikit/utils");
25
- const constants_1 = require("../../constants");
26
- Object.defineProperty(exports, "APPEARANCE", {
27
- enumerable: true,
28
- get: function () {
29
- return constants_1.APPEARANCE;
9
+ const TagBase_1 = require("../TagBase");
10
+ const TagLink_1 = require("../TagLink");
11
+ function isTagLinkProps(props) {
12
+ return 'href' in props && props.href !== undefined;
13
+ }
14
+ function Tag(props) {
15
+ if (isTagLinkProps(props)) {
16
+ return (0, jsx_runtime_1.jsx)(TagLink_1.TagLink, Object.assign({}, props));
30
17
  }
31
- });
32
- const constants_2 = require("./constants");
33
- const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
34
- function Tag(_a) {
35
- var {
36
- label,
37
- size = constants_1.SIZE.Xs,
38
- appearance = constants_1.APPEARANCE.Neutral,
39
- onDelete,
40
- className,
41
- tabIndex
42
- } = _a,
43
- rest = __rest(_a, ["label", "size", "appearance", "onDelete", "className", "tabIndex"]);
44
- return (0, jsx_runtime_1.jsxs)("span", Object.assign({}, (0, utils_1.extractSupportProps)(rest), {
45
- className: (0, classnames_1.default)(styles_module_scss_1.default.tag, className),
46
- "data-size": size,
47
- "data-appearance": appearance,
48
- "data-removable": Boolean(onDelete),
49
- children: [(0, jsx_runtime_1.jsx)("span", {
50
- title: label,
51
- className: styles_module_scss_1.default.label,
52
- children: label
53
- }), onDelete && (0, jsx_runtime_1.jsx)("button", {
54
- type: 'button',
55
- className: styles_module_scss_1.default.tagButton,
56
- onClick: onDelete,
57
- "data-test-id": 'tag-remove-button',
58
- tabIndex: tabIndex,
59
- children: size === constants_1.SIZE.Xs ? (0, jsx_runtime_1.jsx)(icons_1.CrossSVG, {
60
- size: constants_2.ICON_SIZE[size],
61
- className: styles_module_scss_1.default.icon
62
- }) : (0, jsx_runtime_1.jsx)(icons_1.CrossSVG, {
63
- size: constants_2.ICON_SIZE[size],
64
- className: styles_module_scss_1.default.icon
65
- })
66
- })]
67
- }));
18
+ return (0, jsx_runtime_1.jsx)(TagBase_1.TagBase, Object.assign({}, props));
68
19
  }
@@ -0,0 +1,8 @@
1
+ import { MouseEventHandler } from 'react';
2
+ import { WithSupportProps } from '@snack-uikit/utils';
3
+ import { CommonTagProps } from '../../types';
4
+ export type TagBaseProps = WithSupportProps<{
5
+ /** Коллбэк на удаление */
6
+ onDelete?: MouseEventHandler<HTMLButtonElement>;
7
+ }> & CommonTagProps;
8
+ export declare function TagBase({ label, size, appearance, onDelete, className, tabIndex, ...rest }: TagBaseProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ var __rest = void 0 && (void 0).__rest || function (s, e) {
4
+ var t = {};
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
8
+ }
9
+ return t;
10
+ };
11
+ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
12
+ return mod && mod.__esModule ? mod : {
13
+ "default": mod
14
+ };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", {
17
+ value: true
18
+ });
19
+ exports.TagBase = TagBase;
20
+ const jsx_runtime_1 = require("react/jsx-runtime");
21
+ const classnames_1 = __importDefault(require("classnames"));
22
+ const icons_1 = require("@snack-uikit/icons");
23
+ const utils_1 = require("@snack-uikit/utils");
24
+ const constants_1 = require("../../constants");
25
+ const constants_2 = require("./constants");
26
+ const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
27
+ function TagBase(_a) {
28
+ var {
29
+ label,
30
+ size = constants_1.SIZE.Xs,
31
+ appearance = constants_1.APPEARANCE.Neutral,
32
+ onDelete,
33
+ className,
34
+ tabIndex
35
+ } = _a,
36
+ rest = __rest(_a, ["label", "size", "appearance", "onDelete", "className", "tabIndex"]);
37
+ return (0, jsx_runtime_1.jsxs)("span", Object.assign({}, (0, utils_1.extractSupportProps)(rest), {
38
+ className: (0, classnames_1.default)(styles_module_scss_1.default.tag, className),
39
+ "data-size": size,
40
+ "data-appearance": appearance,
41
+ "data-removable": Boolean(onDelete),
42
+ children: [(0, jsx_runtime_1.jsx)("span", {
43
+ title: label,
44
+ className: styles_module_scss_1.default.label,
45
+ children: label
46
+ }), onDelete && (0, jsx_runtime_1.jsx)("button", {
47
+ type: 'button',
48
+ className: styles_module_scss_1.default.tagButton,
49
+ onClick: onDelete,
50
+ "data-test-id": 'tag-remove-button',
51
+ tabIndex: tabIndex,
52
+ children: size === constants_1.SIZE.Xs ? (0, jsx_runtime_1.jsx)(icons_1.CrossSVG, {
53
+ size: constants_2.ICON_SIZE[size],
54
+ className: styles_module_scss_1.default.icon
55
+ }) : (0, jsx_runtime_1.jsx)(icons_1.CrossSVG, {
56
+ size: constants_2.ICON_SIZE[size],
57
+ className: styles_module_scss_1.default.icon
58
+ })
59
+ })]
60
+ }));
61
+ }
@@ -0,0 +1 @@
1
+ export * from './TagBase';
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = {
8
+ enumerable: true,
9
+ get: function () {
10
+ return m[k];
11
+ }
12
+ };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ } : function (o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ });
19
+ var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", {
23
+ value: true
24
+ });
25
+ __exportStar(require("./TagBase"), exports);
@@ -0,0 +1,9 @@
1
+ import { MouseEvent } from 'react';
2
+ import { WithSupportProps } from '@snack-uikit/utils';
3
+ import { CommonTagProps } from '../../types';
4
+ export type TagLinkProps = WithSupportProps<CommonTagProps> & {
5
+ href: string;
6
+ onClick?(e: MouseEvent<HTMLAnchorElement>): void;
7
+ target?: HTMLAnchorElement['target'];
8
+ };
9
+ export declare function TagLink({ label, size, appearance, className, tabIndex, href, onClick, target, ...rest }: TagLinkProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ var __rest = void 0 && (void 0).__rest || function (s, e) {
4
+ var t = {};
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
8
+ }
9
+ return t;
10
+ };
11
+ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
12
+ return mod && mod.__esModule ? mod : {
13
+ "default": mod
14
+ };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", {
17
+ value: true
18
+ });
19
+ exports.TagLink = TagLink;
20
+ const jsx_runtime_1 = require("react/jsx-runtime");
21
+ const classnames_1 = __importDefault(require("classnames"));
22
+ const utils_1 = require("@snack-uikit/utils");
23
+ const constants_1 = require("../../constants");
24
+ const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
25
+ function TagLink(_a) {
26
+ var {
27
+ label,
28
+ size = constants_1.SIZE.Xs,
29
+ appearance = constants_1.APPEARANCE.Neutral,
30
+ className,
31
+ tabIndex,
32
+ href,
33
+ onClick,
34
+ target
35
+ } = _a,
36
+ rest = __rest(_a, ["label", "size", "appearance", "className", "tabIndex", "href", "onClick", "target"]);
37
+ return (0, jsx_runtime_1.jsx)("a", Object.assign({}, (0, utils_1.extractSupportProps)(rest), {
38
+ className: (0, classnames_1.default)(styles_module_scss_1.default.tag, className),
39
+ "data-size": size,
40
+ "data-appearance": appearance,
41
+ tabIndex: tabIndex,
42
+ href: href,
43
+ target: target,
44
+ onClick: onClick,
45
+ children: (0, jsx_runtime_1.jsx)("span", {
46
+ title: label,
47
+ className: styles_module_scss_1.default.label,
48
+ children: label
49
+ })
50
+ }));
51
+ }
@@ -0,0 +1 @@
1
+ export * from './TagLink';
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = {
8
+ enumerable: true,
9
+ get: function () {
10
+ return m[k];
11
+ }
12
+ };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ } : function (o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ });
19
+ var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", {
23
+ value: true
24
+ });
25
+ __exportStar(require("./TagLink"), exports);
@@ -0,0 +1,206 @@
1
+ .tag{
2
+ display:inline-flex;
3
+ align-items:center;
4
+ box-sizing:border-box;
5
+ max-width:100%;
6
+ text-decoration:none;
7
+ }
8
+ .tag:focus-visible{
9
+ outline-width:var(--border-state-focus-s-border-width, 2px);
10
+ outline-style:var(--border-state-focus-s-border-style, solid);
11
+ outline-color:var(--border-state-focus-s-border-color, );
12
+ outline-offset:calc(var(--border-state-focus-s-border-width, 2px) * -1);
13
+ }
14
+ .tag:active{
15
+ outline:none;
16
+ }
17
+ .tag[data-size=xs]{
18
+ padding-left:var(--space-tag-xs-from-label, 8px);
19
+ padding-right:var(--space-tag-xs-from-label, 8px);
20
+ height:var(--size-tag-xs, 24px);
21
+ border-radius:var(--radius-tag-xs, 4px);
22
+ }
23
+ .tag[data-size=xs] .label{
24
+ font-family:var(--sans-label-s-font-family, SB Sans Interface);
25
+ font-weight:var(--sans-label-s-font-weight, Semibold);
26
+ line-height:var(--sans-label-s-line-height, 14px);
27
+ font-size:var(--sans-label-s-font-size, 11px);
28
+ letter-spacing:var(--sans-label-s-letter-spacing, 0px);
29
+ paragraph-spacing:var(--sans-label-s-paragraph-spacing, 6.05px);
30
+ }
31
+ .tag[data-size=s]{
32
+ padding-left:var(--space-tag-s-from-label, 16px);
33
+ padding-right:var(--space-tag-s-from-label, 16px);
34
+ height:var(--size-tag-s, 32px);
35
+ border-radius:var(--radius-tag-s, 8px);
36
+ }
37
+ .tag[data-size=s] .label{
38
+ font-family:var(--sans-label-m-font-family, SB Sans Interface);
39
+ font-weight:var(--sans-label-m-font-weight, Semibold);
40
+ line-height:var(--sans-label-m-line-height, 16px);
41
+ font-size:var(--sans-label-m-font-size, 12px);
42
+ letter-spacing:var(--sans-label-m-letter-spacing, 0px);
43
+ paragraph-spacing:var(--sans-label-m-paragraph-spacing, 6.6px);
44
+ }
45
+ .tag[data-appearance=neutral]{
46
+ background-color:var(--sys-neutral-decor-default, #dde0ea);
47
+ }
48
+ .tag[data-appearance=neutral] .label{
49
+ overflow:hidden;
50
+ color:var(--sys-neutral-text-support, #6d707f);
51
+ text-overflow:ellipsis;
52
+ white-space:nowrap;
53
+ }
54
+ .tag[data-appearance=neutral]:focus, .tag[data-appearance=neutral]:hover, .tag[data-appearance=neutral]:active{
55
+ color:var(--sys-neutral-text-main, #41424e);
56
+ }
57
+ .tag[data-appearance=neutral]:focus, .tag[data-appearance=neutral]:hover{
58
+ background-color:var(--sys-neutral-decor-hovered, #cfd2dc);
59
+ }
60
+ .tag[data-appearance=neutral]:active{
61
+ background-color:var(--sys-neutral-decor-activated, #bec2cf);
62
+ }
63
+ .tag[data-appearance=primary]{
64
+ background-color:var(--sys-primary-decor-default, #ebdefd);
65
+ }
66
+ .tag[data-appearance=primary] .label{
67
+ overflow:hidden;
68
+ color:var(--sys-primary-text-support, #5b4796);
69
+ text-overflow:ellipsis;
70
+ white-space:nowrap;
71
+ }
72
+ .tag[data-appearance=primary]:focus, .tag[data-appearance=primary]:hover, .tag[data-appearance=primary]:active{
73
+ color:var(--sys-primary-text-main, #382a62);
74
+ }
75
+ .tag[data-appearance=primary]:focus, .tag[data-appearance=primary]:hover{
76
+ background-color:var(--sys-primary-decor-hovered, #decdfb);
77
+ }
78
+ .tag[data-appearance=primary]:active{
79
+ background-color:var(--sys-primary-decor-activated, #c5b2f1);
80
+ }
81
+ .tag[data-appearance=red]{
82
+ background-color:var(--sys-red-decor-default, #fdd6cd);
83
+ }
84
+ .tag[data-appearance=red] .label{
85
+ overflow:hidden;
86
+ color:var(--sys-red-text-support, #ae514c);
87
+ text-overflow:ellipsis;
88
+ white-space:nowrap;
89
+ }
90
+ .tag[data-appearance=red]:focus, .tag[data-appearance=red]:hover, .tag[data-appearance=red]:active{
91
+ color:var(--sys-red-text-main, #7a2d2d);
92
+ }
93
+ .tag[data-appearance=red]:focus, .tag[data-appearance=red]:hover{
94
+ background-color:var(--sys-red-decor-hovered, #fac1b3);
95
+ }
96
+ .tag[data-appearance=red]:active{
97
+ background-color:var(--sys-red-decor-activated, #fbab99);
98
+ }
99
+ .tag[data-appearance=orange]{
100
+ background-color:var(--sys-orange-decor-default, #fed8b8);
101
+ }
102
+ .tag[data-appearance=orange] .label{
103
+ overflow:hidden;
104
+ color:var(--sys-orange-text-support, #bb733e);
105
+ text-overflow:ellipsis;
106
+ white-space:nowrap;
107
+ }
108
+ .tag[data-appearance=orange]:focus, .tag[data-appearance=orange]:hover, .tag[data-appearance=orange]:active{
109
+ color:var(--sys-orange-text-main, #884c23);
110
+ }
111
+ .tag[data-appearance=orange]:focus, .tag[data-appearance=orange]:hover{
112
+ background-color:var(--sys-orange-decor-hovered, #f8c699);
113
+ }
114
+ .tag[data-appearance=orange]:active{
115
+ background-color:var(--sys-orange-decor-activated, #f5b27b);
116
+ }
117
+ .tag[data-appearance=yellow]{
118
+ background-color:var(--sys-yellow-decor-default, #f0dfb1);
119
+ }
120
+ .tag[data-appearance=yellow] .label{
121
+ overflow:hidden;
122
+ color:var(--sys-yellow-text-support, #b78c32);
123
+ text-overflow:ellipsis;
124
+ white-space:nowrap;
125
+ }
126
+ .tag[data-appearance=yellow]:focus, .tag[data-appearance=yellow]:hover, .tag[data-appearance=yellow]:active{
127
+ color:var(--sys-yellow-text-main, #815f19);
128
+ }
129
+ .tag[data-appearance=yellow]:focus, .tag[data-appearance=yellow]:hover{
130
+ background-color:var(--sys-yellow-decor-hovered, #ead49a);
131
+ }
132
+ .tag[data-appearance=yellow]:active{
133
+ background-color:var(--sys-yellow-decor-activated, #e6c878);
134
+ }
135
+ .tag[data-appearance=green]{
136
+ background-color:var(--sys-green-decor-default, #d2ead0);
137
+ }
138
+ .tag[data-appearance=green] .label{
139
+ overflow:hidden;
140
+ color:var(--sys-green-text-support, #55915a);
141
+ text-overflow:ellipsis;
142
+ white-space:nowrap;
143
+ }
144
+ .tag[data-appearance=green]:focus, .tag[data-appearance=green]:hover, .tag[data-appearance=green]:active{
145
+ color:var(--sys-green-text-main, #3d6035);
146
+ }
147
+ .tag[data-appearance=green]:focus, .tag[data-appearance=green]:hover{
148
+ background-color:var(--sys-green-decor-hovered, #c0e1ba);
149
+ }
150
+ .tag[data-appearance=green]:active{
151
+ background-color:var(--sys-green-decor-activated, #a8d1a2);
152
+ }
153
+ .tag[data-appearance=blue]{
154
+ background-color:var(--sys-blue-decor-default, #d6e2f4);
155
+ }
156
+ .tag[data-appearance=blue] .label{
157
+ overflow:hidden;
158
+ color:var(--sys-blue-text-support, #4877b0);
159
+ text-overflow:ellipsis;
160
+ white-space:nowrap;
161
+ }
162
+ .tag[data-appearance=blue]:focus, .tag[data-appearance=blue]:hover, .tag[data-appearance=blue]:active{
163
+ color:var(--sys-blue-text-main, #2b537e);
164
+ }
165
+ .tag[data-appearance=blue]:focus, .tag[data-appearance=blue]:hover{
166
+ background-color:var(--sys-blue-decor-hovered, #c5d9f6);
167
+ }
168
+ .tag[data-appearance=blue]:active{
169
+ background-color:var(--sys-blue-decor-activated, #aac4ea);
170
+ }
171
+ .tag[data-appearance=violet]{
172
+ background-color:var(--sys-violet-decor-default, #e6dcf3);
173
+ }
174
+ .tag[data-appearance=violet] .label{
175
+ overflow:hidden;
176
+ color:var(--sys-violet-text-support, #8c639b);
177
+ text-overflow:ellipsis;
178
+ white-space:nowrap;
179
+ }
180
+ .tag[data-appearance=violet]:focus, .tag[data-appearance=violet]:hover, .tag[data-appearance=violet]:active{
181
+ color:var(--sys-violet-text-main, #59446a);
182
+ }
183
+ .tag[data-appearance=violet]:focus, .tag[data-appearance=violet]:hover{
184
+ background-color:var(--sys-violet-decor-hovered, #e1d0f7);
185
+ }
186
+ .tag[data-appearance=violet]:active{
187
+ background-color:var(--sys-violet-decor-activated, #ceb7e7);
188
+ }
189
+ .tag[data-appearance=pink]{
190
+ background-color:var(--sys-pink-decor-default, #f5d9e1);
191
+ }
192
+ .tag[data-appearance=pink] .label{
193
+ overflow:hidden;
194
+ color:var(--sys-pink-text-support, #ae5e80);
195
+ text-overflow:ellipsis;
196
+ white-space:nowrap;
197
+ }
198
+ .tag[data-appearance=pink]:focus, .tag[data-appearance=pink]:hover, .tag[data-appearance=pink]:active{
199
+ color:var(--sys-pink-text-main, #754158);
200
+ }
201
+ .tag[data-appearance=pink]:focus, .tag[data-appearance=pink]:hover{
202
+ background-color:var(--sys-pink-decor-hovered, #f5c9d6);
203
+ }
204
+ .tag[data-appearance=pink]:active{
205
+ background-color:var(--sys-pink-decor-activated, #e8b1c1);
206
+ }
@@ -1 +1,3 @@
1
1
  export * from './components';
2
+ export * from './constants';
3
+ export type { Appearance, Size, TagRowItem } from './types';
package/dist/cjs/index.js CHANGED
@@ -22,4 +22,5 @@ var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
22
22
  Object.defineProperty(exports, "__esModule", {
23
23
  value: true
24
24
  });
25
- __exportStar(require("./components"), exports);
25
+ __exportStar(require("./components"), exports);
26
+ __exportStar(require("./constants"), exports);
@@ -1,12 +1,30 @@
1
+ import { MouseEvent } from 'react';
1
2
  import { ValueOf } from '@snack-uikit/utils';
2
3
  import { APPEARANCE, SIZE } from './constants';
3
4
  export type Appearance = ValueOf<typeof APPEARANCE>;
4
5
  export type Size = ValueOf<typeof SIZE>;
6
+ export type LinkProps = {
7
+ href: string;
8
+ onClick?(e: MouseEvent<HTMLAnchorElement>): void;
9
+ target?: HTMLAnchorElement['target'];
10
+ };
5
11
  export type TagRowItem = {
6
12
  label: string;
7
13
  appearance?: Appearance;
8
- };
14
+ } & Partial<LinkProps>;
9
15
  export type TagRowItemInner = {
10
16
  label: string;
11
17
  appearance: Appearance;
18
+ } & Partial<LinkProps>;
19
+ export type CommonTagProps = {
20
+ /** Текст */
21
+ label: string;
22
+ /** Размер */
23
+ size?: Size;
24
+ /** Внешний вид */
25
+ appearance?: Appearance;
26
+ /** CSS-класс */
27
+ className?: string;
28
+ /** tabIndex кнопки удаления */
29
+ tabIndex?: number;
12
30
  };
@@ -1,20 +1,5 @@
1
- import { MouseEventHandler } from 'react';
2
- import { WithSupportProps } from '@snack-uikit/utils';
3
- import { APPEARANCE } from '../../constants';
4
- import { Appearance, Size } from '../../types';
5
- export type TagProps = WithSupportProps<{
6
- /** Текст */
7
- label: string;
8
- /** Размер */
9
- size?: Size;
10
- /** Внешний вид */
11
- appearance?: Appearance;
12
- /** Коллбэк на удаление */
13
- onDelete?: MouseEventHandler<HTMLButtonElement>;
14
- /** CSS-класс */
15
- className?: string;
16
- /** tabIndex кнопки удаления */
17
- tabIndex?: number;
18
- }>;
19
- export declare function Tag({ label, size, appearance, onDelete, className, tabIndex, ...rest }: TagProps): import("react/jsx-runtime").JSX.Element;
20
- export { APPEARANCE };
1
+ import { TagBaseProps } from '../TagBase';
2
+ import { TagLinkProps } from '../TagLink';
3
+ export type TagProps = TagBaseProps | TagLinkProps;
4
+ export declare function isTagLinkProps(props: TagProps): props is TagLinkProps;
5
+ export declare function Tag(props: TagProps): import("react/jsx-runtime").JSX.Element;
@@ -1,23 +1,12 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import cn from 'classnames';
14
- import { CrossSVG } from '@snack-uikit/icons';
15
- import { extractSupportProps } from '@snack-uikit/utils';
16
- import { APPEARANCE, SIZE } from '../../constants';
17
- import { ICON_SIZE } from './constants';
18
- import styles from './styles.module.css';
19
- export function Tag(_a) {
20
- var { label, size = SIZE.Xs, appearance = APPEARANCE.Neutral, onDelete, className, tabIndex } = _a, rest = __rest(_a, ["label", "size", "appearance", "onDelete", "className", "tabIndex"]);
21
- return (_jsxs("span", Object.assign({}, extractSupportProps(rest), { className: cn(styles.tag, className), "data-size": size, "data-appearance": appearance, "data-removable": Boolean(onDelete), children: [_jsx("span", { title: label, className: styles.label, children: label }), onDelete && (_jsx("button", { type: 'button', className: styles.tagButton, onClick: onDelete, "data-test-id": 'tag-remove-button', tabIndex: tabIndex, children: size === SIZE.Xs ? (_jsx(CrossSVG, { size: ICON_SIZE[size], className: styles.icon })) : (_jsx(CrossSVG, { size: ICON_SIZE[size], className: styles.icon })) }))] })));
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { TagBase } from '../TagBase';
3
+ import { TagLink } from '../TagLink';
4
+ export function isTagLinkProps(props) {
5
+ return 'href' in props && props.href !== undefined;
6
+ }
7
+ export function Tag(props) {
8
+ if (isTagLinkProps(props)) {
9
+ return _jsx(TagLink, Object.assign({}, props));
10
+ }
11
+ return _jsx(TagBase, Object.assign({}, props));
22
12
  }
23
- export { APPEARANCE };
@@ -0,0 +1,8 @@
1
+ import { MouseEventHandler } from 'react';
2
+ import { WithSupportProps } from '@snack-uikit/utils';
3
+ import { CommonTagProps } from '../../types';
4
+ export type TagBaseProps = WithSupportProps<{
5
+ /** Коллбэк на удаление */
6
+ onDelete?: MouseEventHandler<HTMLButtonElement>;
7
+ }> & CommonTagProps;
8
+ export declare function TagBase({ label, size, appearance, onDelete, className, tabIndex, ...rest }: TagBaseProps): import("react/jsx-runtime").JSX.Element;