@synerise/ds-tag 1.4.16 → 1.4.18
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 +8 -0
- package/README.md +9 -2
- package/dist/Tag.d.ts +4 -4
- package/dist/Tag.js +61 -101
- package/dist/Tag.styles.d.ts +10 -10
- package/dist/Tag.styles.js +87 -79
- package/dist/Tag.types.d.ts +3 -3
- package/dist/Tag.types.js +17 -14
- package/dist/hooks/useDefaultTexts.d.ts +1 -1
- package/dist/hooks/useDefaultTexts.js +25 -43
- package/dist/index.js +8 -3
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/package.json +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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
|
+
## [1.4.18](https://github.com/Synerise/synerise-design/compare/@synerise/ds-tag@1.4.17...@synerise/ds-tag@1.4.18) (2026-03-24)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-tag
|
|
9
|
+
|
|
10
|
+
## [1.4.17](https://github.com/Synerise/synerise-design/compare/@synerise/ds-tag@1.4.16...@synerise/ds-tag@1.4.17) (2026-03-20)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @synerise/ds-tag
|
|
13
|
+
|
|
6
14
|
## [1.4.16](https://github.com/Synerise/synerise-design/compare/@synerise/ds-tag@1.4.15...@synerise/ds-tag@1.4.16) (2026-03-09)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @synerise/ds-tag
|
package/README.md
CHANGED
|
@@ -11,6 +11,8 @@ Tag UI Component
|
|
|
11
11
|
npm i @synerise/ds-tag
|
|
12
12
|
or
|
|
13
13
|
yarn add @synerise/ds-tag
|
|
14
|
+
or
|
|
15
|
+
pnpm add @synerise/ds-tag
|
|
14
16
|
```
|
|
15
17
|
|
|
16
18
|
## Usage
|
|
@@ -38,10 +40,15 @@ import Tag from '@synerise/ds-tag'
|
|
|
38
40
|
| onClick | onClick event on tag body | () => void | - |
|
|
39
41
|
| onRemove | callback when tag is removed | (tagKey: string / number) => void | - |
|
|
40
42
|
| removable | show remove button | boolean | - |
|
|
41
|
-
| shape | shape of the tag | TagShape | TagShape.
|
|
43
|
+
| shape | shape of the tag | TagShape | TagShape.DEFAULT_SQUARE |
|
|
42
44
|
| textColor | color of tag name label | string | - |
|
|
45
|
+
| image | src of image shown before content (DEFAULT_ROUND/SQUARE only) | string | - |
|
|
46
|
+
| prefixel | leading slot content | ReactNode | - |
|
|
47
|
+
| suffixel | trailing slot content (hidden on remove hover) | ReactNode | - |
|
|
48
|
+
| texts | i18n overrides for internal labels | Partial<TagTexts> | - |
|
|
49
|
+
| asPill | disable hover brightness effect | boolean | - |
|
|
43
50
|
| dashed | make border dashed | boolean | - |
|
|
44
|
-
| tooltipProps | tooltip to show over entire tag. see ds-tooltip | TooltipProps |
|
|
51
|
+
| tooltipProps | tooltip to show over entire tag. see ds-tooltip | TooltipProps | - |
|
|
45
52
|
|
|
46
53
|
## TagShape Enum
|
|
47
54
|
|
package/dist/Tag.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import { default as React } from 'react';
|
|
2
2
|
import { TagShape } from './Tag.types';
|
|
3
3
|
declare const Tag: React.ForwardRefExoticComponent<{
|
|
4
4
|
id?: string | number;
|
|
@@ -14,9 +14,9 @@ declare const Tag: React.ForwardRefExoticComponent<{
|
|
|
14
14
|
onRemove?: (tag: string | number) => void;
|
|
15
15
|
prefixel?: React.ReactNode;
|
|
16
16
|
suffixel?: React.ReactNode;
|
|
17
|
-
texts?: import(
|
|
17
|
+
texts?: import('./Tag.types').TagTexts;
|
|
18
18
|
asPill?: boolean;
|
|
19
19
|
dashed?: boolean;
|
|
20
|
-
tooltipProps?: import(
|
|
21
|
-
} & Omit<React.HTMLAttributes<HTMLDivElement>, "className" | "id" | "color" | "onClick" | "name" | "textColor" | "image" | "shape" | "removable" | "disabled" | "onRemove" | "prefixel" | "suffixel" | "texts" | "asPill" | "dashed" | "tooltipProps"> & import(
|
|
20
|
+
tooltipProps?: import('@synerise/ds-tooltip').TooltipProps;
|
|
21
|
+
} & Omit<React.HTMLAttributes<HTMLDivElement>, "className" | "id" | "color" | "onClick" | "name" | "textColor" | "image" | "shape" | "removable" | "disabled" | "onRemove" | "prefixel" | "suffixel" | "texts" | "asPill" | "dashed" | "tooltipProps"> & import('@synerise/ds-utils').DataAttributes & React.RefAttributes<HTMLDivElement>>;
|
|
22
22
|
export default Tag;
|
package/dist/Tag.js
CHANGED
|
@@ -1,110 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
setIsIconHovered = _useState[1];
|
|
43
|
-
var onRemoveCall = function onRemoveCall() {
|
|
44
|
-
return !!onRemove && !!id && onRemove(id);
|
|
45
|
-
};
|
|
46
|
-
var renderPrefixel = function renderPrefixel() {
|
|
47
|
-
if (typeof prefixel === 'string' || typeof prefixel === 'number') {
|
|
48
|
-
return /*#__PURE__*/React.createElement(S.PrefixWrapper, {
|
|
49
|
-
iconHover: isIconHovered
|
|
50
|
-
}, prefixel);
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useState } from "react";
|
|
3
|
+
import { useTheme } from "@synerise/ds-core";
|
|
4
|
+
import Icon, { CloseS } from "@synerise/ds-icon";
|
|
5
|
+
import Tooltip from "@synerise/ds-tooltip";
|
|
6
|
+
import { Tag as Tag$1, Content, TagName, RemoveButton, getColorText, PrefixWrapper, DefaultPrefixWrapper, SuffixWrapper, DefaultSuffixWrapper } from "./Tag.styles.js";
|
|
7
|
+
import { TagShape } from "./Tag.types.js";
|
|
8
|
+
import { useDefaultTexts } from "./hooks/useDefaultTexts.js";
|
|
9
|
+
const Tag = forwardRef(({
|
|
10
|
+
id,
|
|
11
|
+
name,
|
|
12
|
+
className,
|
|
13
|
+
disabled,
|
|
14
|
+
removable,
|
|
15
|
+
image,
|
|
16
|
+
shape = TagShape.DEFAULT_ROUND && TagShape.DEFAULT_SQUARE,
|
|
17
|
+
color,
|
|
18
|
+
textColor,
|
|
19
|
+
onRemove,
|
|
20
|
+
onClick,
|
|
21
|
+
prefixel,
|
|
22
|
+
suffixel,
|
|
23
|
+
texts,
|
|
24
|
+
asPill,
|
|
25
|
+
dashed,
|
|
26
|
+
tooltipProps,
|
|
27
|
+
...htmlAttributes
|
|
28
|
+
}, ref) => {
|
|
29
|
+
const theme = useTheme();
|
|
30
|
+
const allTexts = useDefaultTexts(texts);
|
|
31
|
+
const isDefaultType = shape && [TagShape.DEFAULT_ROUND, TagShape.DEFAULT_SQUARE].includes(shape);
|
|
32
|
+
const isDefaultRound = shape === TagShape.DEFAULT_ROUND;
|
|
33
|
+
const isDefaultSquare = shape === TagShape.DEFAULT_SQUARE;
|
|
34
|
+
const isStatusShape = shape && [TagShape.STATUS_ERROR, TagShape.STATUS_NEUTRAL, TagShape.STATUS_SUCCESS, TagShape.STATUS_WARNING].includes(shape);
|
|
35
|
+
const isRemovable = removable && (isDefaultRound || isDefaultSquare);
|
|
36
|
+
const isActionable = !disabled && isRemovable;
|
|
37
|
+
const [isIconHovered, setIsIconHovered] = useState(false);
|
|
38
|
+
const onRemoveCall = () => !!onRemove && !!id && onRemove(id);
|
|
39
|
+
const renderPrefixel = () => {
|
|
40
|
+
if (typeof prefixel === "string" || typeof prefixel === "number") {
|
|
41
|
+
return /* @__PURE__ */ jsx(PrefixWrapper, { iconHover: isIconHovered, children: prefixel });
|
|
51
42
|
}
|
|
52
|
-
return
|
|
53
|
-
iconHover: isIconHovered
|
|
54
|
-
}, prefixel);
|
|
43
|
+
return /* @__PURE__ */ jsx(DefaultPrefixWrapper, { iconHover: isIconHovered, children: prefixel });
|
|
55
44
|
};
|
|
56
|
-
|
|
57
|
-
if (typeof suffixel ===
|
|
58
|
-
return
|
|
45
|
+
const renderSuffixel = () => {
|
|
46
|
+
if (typeof suffixel === "string" || typeof suffixel === "number") {
|
|
47
|
+
return /* @__PURE__ */ jsx(SuffixWrapper, { children: suffixel });
|
|
59
48
|
}
|
|
60
|
-
return
|
|
49
|
+
return /* @__PURE__ */ jsx(DefaultSuffixWrapper, { children: suffixel });
|
|
61
50
|
};
|
|
62
|
-
|
|
51
|
+
const handleMouseOver = (event) => {
|
|
63
52
|
setIsIconHovered(true);
|
|
64
|
-
htmlAttributes.onMouseOver
|
|
53
|
+
htmlAttributes.onMouseOver?.(event);
|
|
65
54
|
};
|
|
66
|
-
|
|
55
|
+
const handleMouseLeave = (event) => {
|
|
67
56
|
setIsIconHovered(false);
|
|
68
|
-
htmlAttributes.onMouseLeave
|
|
57
|
+
htmlAttributes.onMouseLeave?.(event);
|
|
69
58
|
};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
color: color
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
disabled: disabled,
|
|
79
|
-
isActionable: isActionable,
|
|
80
|
-
onClick: onClick,
|
|
81
|
-
"data-testid": typeof id !== 'undefined' ? "tag-" + id : 'tag',
|
|
82
|
-
preffixel: !!prefixel,
|
|
83
|
-
suffixel: !!suffixel,
|
|
84
|
-
hasImage: !!image,
|
|
85
|
-
iconHover: isIconHovered,
|
|
86
|
-
asPill: asPill,
|
|
87
|
-
dashed: dashed
|
|
88
|
-
}, htmlAttributes), /*#__PURE__*/React.createElement(S.Content, {
|
|
89
|
-
iconHover: isIconHovered
|
|
90
|
-
}, image && isDefaultType && /*#__PURE__*/React.createElement("img", {
|
|
91
|
-
src: image,
|
|
92
|
-
alt: ""
|
|
93
|
-
}), !!prefixel && renderPrefixel(), /*#__PURE__*/React.createElement(S.TagName, null, name), !!suffixel && renderSuffixel(), isRemovable && /*#__PURE__*/React.createElement(Tooltip, {
|
|
94
|
-
title: allTexts.deleteTooltip,
|
|
95
|
-
open: isIconHovered,
|
|
96
|
-
zIndex: parseInt(theme.variables['@zindex-tooltip'], 10) + 1
|
|
97
|
-
}, /*#__PURE__*/React.createElement(S.RemoveButton, {
|
|
98
|
-
onClick: onRemoveCall,
|
|
99
|
-
onMouseOver: handleMouseOver,
|
|
100
|
-
onMouseLeave: handleMouseLeave,
|
|
101
|
-
"data-testid": "remove-btn"
|
|
102
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
103
|
-
className: "icon",
|
|
104
|
-
component: /*#__PURE__*/React.createElement(CloseS, null),
|
|
105
|
-
size: 24,
|
|
106
|
-
color: getColorText(theme, color)
|
|
107
|
-
})))));
|
|
108
|
-
return tooltipProps ? /*#__PURE__*/React.createElement(Tooltip, tooltipProps, renderedTag) : renderedTag;
|
|
59
|
+
const renderedTag = /* @__PURE__ */ jsx(Tag$1, { ref, className: `ds-tag ${className ?? ""}`, isStatusShape, shape, color, textColor, removable, disabled, isActionable, onClick, "data-testid": typeof id !== "undefined" ? `tag-${id}` : "tag", preffixel: !!prefixel, suffixel: !!suffixel, hasImage: !!image, iconHover: isIconHovered, asPill, dashed, ...htmlAttributes, children: /* @__PURE__ */ jsxs(Content, { iconHover: isIconHovered, children: [
|
|
60
|
+
image && isDefaultType && /* @__PURE__ */ jsx("img", { src: image, alt: "" }),
|
|
61
|
+
!!prefixel && renderPrefixel(),
|
|
62
|
+
/* @__PURE__ */ jsx(TagName, { children: name }),
|
|
63
|
+
!!suffixel && renderSuffixel(),
|
|
64
|
+
isRemovable && /* @__PURE__ */ jsx(Tooltip, { title: allTexts.deleteTooltip, open: isIconHovered, zIndex: parseInt(theme.variables["@zindex-tooltip"], 10) + 1, children: /* @__PURE__ */ jsx(RemoveButton, { onClick: onRemoveCall, onMouseOver: handleMouseOver, onMouseLeave: handleMouseLeave, "data-testid": "remove-btn", children: /* @__PURE__ */ jsx(Icon, { className: "icon", component: /* @__PURE__ */ jsx(CloseS, {}), size: 24, color: getColorText(theme, color) }) }) })
|
|
65
|
+
] }) });
|
|
66
|
+
return tooltipProps ? /* @__PURE__ */ jsx(Tooltip, { ...tooltipProps, children: renderedTag }) : renderedTag;
|
|
109
67
|
});
|
|
110
|
-
export
|
|
68
|
+
export {
|
|
69
|
+
Tag as default
|
|
70
|
+
};
|
package/dist/Tag.styles.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ThemeProps, ThemePropsVars } from '@synerise/ds-core';
|
|
2
2
|
import { TagShape } from './Tag.types';
|
|
3
3
|
export declare const getColorText: (theme: ThemePropsVars, color?: string) => string;
|
|
4
|
-
export declare const TagName: import(
|
|
5
|
-
export declare const RemoveButton: import(
|
|
4
|
+
export declare const TagName: import('styled-components').StyledComponent<"span", any, {}, never>;
|
|
5
|
+
export declare const RemoveButton: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
6
6
|
type TagProps = {
|
|
7
7
|
isStatusShape?: boolean;
|
|
8
8
|
shape?: TagShape;
|
|
@@ -18,17 +18,17 @@ type TagProps = {
|
|
|
18
18
|
asPill?: boolean;
|
|
19
19
|
dashed?: boolean;
|
|
20
20
|
} & ThemeProps;
|
|
21
|
-
export declare const Content: import(
|
|
21
|
+
export declare const Content: import('styled-components').StyledComponent<"div", any, {
|
|
22
22
|
iconHover?: boolean;
|
|
23
23
|
}, never>;
|
|
24
|
-
export declare const PrefixWrapper: import(
|
|
24
|
+
export declare const PrefixWrapper: import('styled-components').StyledComponent<"div", any, {
|
|
25
25
|
iconHover?: boolean;
|
|
26
26
|
}, never>;
|
|
27
|
-
export declare const SuffixWrapper: import(
|
|
28
|
-
export declare const DefaultSuffixWrapper: import(
|
|
29
|
-
export declare const DefaultPrefixWrapper: import(
|
|
27
|
+
export declare const SuffixWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
28
|
+
export declare const DefaultSuffixWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
29
|
+
export declare const DefaultPrefixWrapper: import('styled-components').StyledComponent<"div", any, {
|
|
30
30
|
iconHover?: boolean;
|
|
31
31
|
}, never>;
|
|
32
|
-
export declare const Tag: import(
|
|
33
|
-
export declare const DeleteButton: import(
|
|
32
|
+
export declare const Tag: import('styled-components').StyledComponent<"div", any, TagProps, never>;
|
|
33
|
+
export declare const DeleteButton: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
34
34
|
export {};
|
package/dist/Tag.styles.js
CHANGED
|
@@ -1,131 +1,139 @@
|
|
|
1
|
-
import styled, { css } from
|
|
2
|
-
import { TagShape } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return color === theme.palette[
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
import { TagShape } from "./Tag.types.js";
|
|
3
|
+
const defaultStatusStyles = /* @__PURE__ */ css(["border-radius:9px;font-size:10px;height:18px;font-weight:500;line-height:18px;text-transform:uppercase;letter-spacing:0.1px;padding:0 8px;line-height:18px;"]);
|
|
4
|
+
const getColorText = (theme, color) => {
|
|
5
|
+
return color === theme.palette["grey-200"] ? theme.palette["grey-600"] : theme.palette.white;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
const getWidthOnHover = (props) => {
|
|
8
8
|
if (props.suffixel && props.preffixel || props.hasImage) {
|
|
9
|
-
return
|
|
9
|
+
return "calc(100% - 23px)";
|
|
10
10
|
}
|
|
11
11
|
if (props.preffixel) {
|
|
12
|
-
return
|
|
12
|
+
return "calc(100% - 35px)";
|
|
13
13
|
}
|
|
14
14
|
if (props.suffixel) {
|
|
15
|
-
return
|
|
15
|
+
return "calc(100% - 4px)";
|
|
16
16
|
}
|
|
17
|
-
return
|
|
17
|
+
return "calc(100% - 10px)";
|
|
18
18
|
};
|
|
19
|
-
|
|
20
|
-
if (props.iconHover && props.color === props.theme.palette[
|
|
21
|
-
return
|
|
19
|
+
const getFilterColor = (props) => {
|
|
20
|
+
if (props.iconHover && props.color === props.theme.palette["grey-200"]) {
|
|
21
|
+
return "brightness(100%)";
|
|
22
22
|
}
|
|
23
|
-
if (props.color === props.theme.palette[
|
|
24
|
-
return
|
|
23
|
+
if (props.color === props.theme.palette["grey-200"]) {
|
|
24
|
+
return "brightness(90%)";
|
|
25
25
|
}
|
|
26
26
|
if (props.iconHover) {
|
|
27
|
-
return
|
|
27
|
+
return "brightness(100%)";
|
|
28
28
|
}
|
|
29
|
-
return
|
|
29
|
+
return "brightness(110%)";
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
const addonStyles = (props) => `
|
|
32
|
+
border: 1px solid;
|
|
33
|
+
border-radius: 10px;
|
|
34
|
+
height: 50%;
|
|
35
|
+
padding: 0 3px;
|
|
36
|
+
border-color: ${props.theme.palette.white};
|
|
37
|
+
font-size: 9px;
|
|
38
|
+
line-height: 10px;
|
|
39
|
+
text-align: center;
|
|
40
|
+
`;
|
|
41
|
+
const TagName = /* @__PURE__ */ styled.span.withConfig({
|
|
35
42
|
displayName: "Tagstyles__TagName",
|
|
36
43
|
componentId: "sc-1xw3den-0"
|
|
37
44
|
})(["white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"]);
|
|
38
|
-
|
|
45
|
+
const RemoveButton = /* @__PURE__ */ styled.div.withConfig({
|
|
39
46
|
displayName: "Tagstyles__RemoveButton",
|
|
40
47
|
componentId: "sc-1xw3den-1"
|
|
41
|
-
})(["color:", ";height:18px;width:18px;border-radius:10px;padding:0;border:none;outline:none;margin:3px 3px 3px 5px;text-align:center;cursor:pointer;position:relative;overflow:hidden;display:none;opacity:0.8;&:before{color:", ";filter:brightness(70%);opacity:0.3;content:'';position:absolute;top:0;left:0;width:100%;height:100%;}&&&:hover{.ds-icon svg{fill:", " !important;}}.icon{&&{transform:translate(1px,-3px);}}"],
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return props.color || props.theme.palette['red-600'];
|
|
47
|
-
}, function (props) {
|
|
48
|
-
return props.theme.palette['red-600'];
|
|
49
|
-
});
|
|
50
|
-
var insertShapeStyles = function insertShapeStyles(props) {
|
|
48
|
+
})(["color:", ";height:18px;width:18px;border-radius:10px;padding:0;border:none;outline:none;margin:3px 3px 3px 5px;text-align:center;cursor:pointer;position:relative;overflow:hidden;display:none;opacity:0.8;&:before{color:", ";filter:brightness(70%);opacity:0.3;content:'';position:absolute;top:0;left:0;width:100%;height:100%;}&&&:hover{.ds-icon svg{fill:", " !important;}}.icon{&&{transform:translate(1px,-3px);}}"], ({
|
|
49
|
+
color,
|
|
50
|
+
theme
|
|
51
|
+
}) => getColorText(theme, color), (props) => props.color || props.theme.palette["red-600"], (props) => props.theme.palette["red-600"]);
|
|
52
|
+
const insertShapeStyles = (props) => {
|
|
51
53
|
switch (props.shape) {
|
|
52
54
|
case TagShape.SMALL_SQUARE:
|
|
53
|
-
return css(["color:", ";border-radius:3px;font-size:10px;height:14px;line-height:14px;text-transform:uppercase;font-weight:500;letter-spacing:0.1px;padding:0 4px;"], props.textColor ||
|
|
55
|
+
return css(["color:", ";border-radius:3px;font-size:10px;height:14px;line-height:14px;text-transform:uppercase;font-weight:500;letter-spacing:0.1px;padding:0 4px;"], props.textColor || "#fff");
|
|
54
56
|
case TagShape.SMALL_ROUND:
|
|
55
|
-
return css(["color:", ";border-radius:8px;font-size:10px;height:14px;line-height:14px;text-transform:uppercase;letter-spacing:0.1px;padding:0 4px;"], props.textColor ||
|
|
57
|
+
return css(["color:", ";border-radius:8px;font-size:10px;height:14px;line-height:14px;text-transform:uppercase;letter-spacing:0.1px;padding:0 4px;"], props.textColor || "#fff");
|
|
56
58
|
case TagShape.MEDIUM_ROUND:
|
|
57
59
|
return css(["color:", ";", ""], props.textColor || getColorText(props.theme, props.color), defaultStatusStyles);
|
|
58
60
|
case TagShape.DEFAULT_ROUND:
|
|
59
|
-
return css(["color:", ";border-radius:12px;font-size:13px;height:24px;line-height:24px;padding:", ";", "{padding:", ";padding-left:", ";padding-right:", ";}", ""], props.textColor || getColorText(props.theme, props.color), props.removable ?
|
|
61
|
+
return css(["color:", ";border-radius:12px;font-size:13px;height:24px;line-height:24px;padding:", ";", "{padding:", ";padding-left:", ";padding-right:", ";}", ""], props.textColor || getColorText(props.theme, props.color), props.removable ? "0" : "0 12px", TagName, props.removable ? "0 12px" : "0", props.removable && props.preffixel && "4px", props.removable && props.suffixel && "4px", props.isActionable && css(["&:hover{padding:", ";", "{display:inline-block;padding:", ";padding-left:", ";padding-right:", ";width:", ";}padding-right:", ";", "{margin-left:0px;margin-right:", ";.icon{position:absolute;left:-3px;top:-3px;}}}"], props.removable && props.suffixel && "0 15px 0 0px", TagName, props.removable ? "0 7px 0 12px" : "0", props.removable && props.preffixel && "4px", props.removable && props.suffixel && "10px", getWidthOnHover(props), !props.suffixel && "5px", RemoveButton, props.suffixel ? "2px" : "-2px"));
|
|
60
62
|
case TagShape.DEFAULT_SQUARE:
|
|
61
|
-
return css(["color:", ";border-radius:3px;font-size:13px;height:24px;line-height:24px;padding:", ";", "{padding:", ";padding-left:", ";padding-right:", ";}", ""], props.textColor || getColorText(props.theme, props.color), props.removable ?
|
|
63
|
+
return css(["color:", ";border-radius:3px;font-size:13px;height:24px;line-height:24px;padding:", ";", "{padding:", ";padding-left:", ";padding-right:", ";}", ""], props.textColor || getColorText(props.theme, props.color), props.removable ? "0" : "0 12px", TagName, props.removable ? "0 12px" : "0", props.removable && props.preffixel && "4px", props.removable && props.suffixel && "4px", props.isActionable && css(["&:hover{padding-right:", ";", "{display:inline-block;padding:", ";padding-left:", ";padding-right:", ";width:", ";}padding-right:", ";", "{margin-left:0px;margin-right:", ";.icon{position:absolute;left:-3px;top:-3px;}}}"], props.removable && props.suffixel && "15px", TagName, props.removable ? "0 7px 0 12px" : "0", props.removable && props.preffixel && "4px", props.removable && props.suffixel && "10px", getWidthOnHover(props), !props.suffixel && "5px", RemoveButton, props.suffixel ? "2px" : "-2px"));
|
|
62
64
|
case TagShape.SINGLE_CHARACTER_ROUND:
|
|
63
65
|
return css(["color:", ";border-radius:12px;font-size:13px;height:24px;width:24px;line-height:24px;justify-content:center;"], props.textColor || getColorText(props.theme, props.color));
|
|
64
66
|
case TagShape.SINGLE_CHARACTER_SQUARE:
|
|
65
67
|
return css(["color:", ";border-radius:3px;font-size:13px;height:24px;width:24px;line-height:24px;justify-content:center;"], props.textColor || getColorText(props.theme, props.color));
|
|
66
68
|
case TagShape.STATUS_NEUTRAL:
|
|
67
|
-
return css(["border:1px solid ", ";color:", ";", ""], props.color || props.theme.palette[
|
|
69
|
+
return css(["border:1px solid ", ";color:", ";", ""], props.color || props.theme.palette["grey-500"], props.textColor || props.color || props.theme.palette["grey-500"], defaultStatusStyles);
|
|
68
70
|
case TagShape.STATUS_SUCCESS:
|
|
69
|
-
return css(["border:1px solid ", ";color:", ";", ""], props.theme.palette[
|
|
71
|
+
return css(["border:1px solid ", ";color:", ";", ""], props.theme.palette["green-600"], props.theme.palette["green-600"], defaultStatusStyles);
|
|
70
72
|
case TagShape.STATUS_ERROR:
|
|
71
|
-
return css(["border:1px solid ", ";color:", ";", ""], props.theme.palette[
|
|
73
|
+
return css(["border:1px solid ", ";color:", ";", ""], props.theme.palette["red-600"], props.theme.palette["red-600"], defaultStatusStyles);
|
|
72
74
|
case TagShape.STATUS_WARNING:
|
|
73
|
-
return css(["border:1px solid ", ";color:", ";", ""], props.theme.palette[
|
|
75
|
+
return css(["border:1px solid ", ";color:", ";", ""], props.theme.palette["yellow-600"], props.theme.palette["yellow-600"], defaultStatusStyles);
|
|
74
76
|
default:
|
|
75
77
|
return css([""]);
|
|
76
78
|
}
|
|
77
79
|
};
|
|
78
|
-
|
|
80
|
+
const Content = /* @__PURE__ */ styled.div.withConfig({
|
|
79
81
|
displayName: "Tagstyles__Content",
|
|
80
82
|
componentId: "sc-1xw3den-2"
|
|
81
|
-
})(["position:relative;display:flex;align-items:center;flex-grow:0;flex-shrink:1;max-width:100%;", ""],
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
83
|
+
})(["position:relative;display:flex;align-items:center;flex-grow:0;flex-shrink:1;max-width:100%;", ""], (props) => !!props.iconHover && `
|
|
84
|
+
&&& {
|
|
85
|
+
color:${props.theme.palette["red-600"]};
|
|
86
|
+
}
|
|
87
|
+
`);
|
|
88
|
+
const PrefixWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
85
89
|
displayName: "Tagstyles__PrefixWrapper",
|
|
86
90
|
componentId: "sc-1xw3den-3"
|
|
87
|
-
})(["", ";", ""],
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
})(["", ";", ""], (props) => addonStyles(props), (props) => !!props.iconHover && `.ant-scroll-number{
|
|
92
|
+
color: ${props.theme.palette["red-600"]}!important;
|
|
93
|
+
box-shadow: 0 0 0 1px ${props.theme.palette["red-600"]}!important;
|
|
94
|
+
}
|
|
95
|
+
.ds-icon svg {
|
|
96
|
+
fill: ${props.theme.palette["red-600"]};
|
|
97
|
+
}`);
|
|
98
|
+
const SuffixWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
93
99
|
displayName: "Tagstyles__SuffixWrapper",
|
|
94
100
|
componentId: "sc-1xw3den-4"
|
|
95
|
-
})(["", ";"],
|
|
96
|
-
|
|
97
|
-
});
|
|
98
|
-
export var DefaultSuffixWrapper = styled.div.withConfig({
|
|
101
|
+
})(["", ";"], (props) => addonStyles(props));
|
|
102
|
+
const DefaultSuffixWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
99
103
|
displayName: "Tagstyles__DefaultSuffixWrapper",
|
|
100
104
|
componentId: "sc-1xw3den-5"
|
|
101
105
|
})([""]);
|
|
102
|
-
|
|
106
|
+
const DefaultPrefixWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
103
107
|
displayName: "Tagstyles__DefaultPrefixWrapper",
|
|
104
108
|
componentId: "sc-1xw3den-6"
|
|
105
|
-
})(["", ""],
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
+
})(["", ""], (props) => !!props.iconHover && `.ant-scroll-number{
|
|
110
|
+
color: ${props.theme.palette["red-600"]}!important;
|
|
111
|
+
box-shadow: 0 0 0 1px ${props.theme.palette["red-600"]}!important;
|
|
112
|
+
}
|
|
113
|
+
.ds-icon svg {
|
|
114
|
+
fill: ${props.theme.palette["red-600"]};
|
|
115
|
+
}`);
|
|
116
|
+
const Tag = /* @__PURE__ */ styled.div.withConfig({
|
|
109
117
|
displayName: "Tagstyles__Tag",
|
|
110
118
|
componentId: "sc-1xw3den-7"
|
|
111
|
-
})(["position:relative;margin:4px;display:inline-flex;font-weight:500;overflow:hidden;cursor:default;", " ", ";", " ", " ", " .icon1{margin:0 -2px 0 1px;}", ";", ",", "{margin:", ";}", ",", "{margin:", ";}"],
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
},
|
|
116
|
-
|
|
117
|
-
}, function (props) {
|
|
118
|
-
return !!props.disabled && css(["opacity:0.4;cursor:not-allowed;"]);
|
|
119
|
-
}, function (props) {
|
|
120
|
-
return !props.isStatusShape && css(["&:before{content:'';position:absolute;top:0;left:0;width:100%;height:100%;background-color:", ";}", ";"], props.color || props.theme.palette['grey-500'], props.isActionable && css(["&:hover:before{filter:", ";}"], getFilterColor));
|
|
121
|
-
}, function (props) {
|
|
122
|
-
return !!props.isActionable && css(["&:hover{", ",", "{display:none;}", "{position:absolute;top:0;right:", ";display:inline-block;}}"], SuffixWrapper, DefaultSuffixWrapper, RemoveButton, props.removable && props.suffixel ? '-15px' : '0');
|
|
123
|
-
}, SuffixWrapper, DefaultSuffixWrapper, function (props) {
|
|
124
|
-
return !props.removable && props.suffixel ? '0px -8px 3px 5px' : '0 4px 3px 1px';
|
|
125
|
-
}, PrefixWrapper, DefaultPrefixWrapper, function (props) {
|
|
126
|
-
return !props.removable && props.preffixel ? '0px 5px 3px -8px' : '0 1px 3px 4px';
|
|
127
|
-
});
|
|
128
|
-
export var DeleteButton = styled.div.withConfig({
|
|
119
|
+
})(["position:relative;margin:4px;display:inline-flex;font-weight:500;overflow:hidden;cursor:default;", " ", ";", " ", " ", " .icon1{margin:0 -2px 0 1px;}", ";", ",", "{margin:", ";}", ",", "{margin:", ";}"], (props) => !props.asPill && css(["cursor:pointer;&:hover:before{filter:", ";}"], getFilterColor), (props) => insertShapeStyles(props), (props) => !!props.iconHover && `
|
|
120
|
+
&&&:before{
|
|
121
|
+
background-color:${props.theme.palette["red-050"]};
|
|
122
|
+
}
|
|
123
|
+
`, (props) => !!props.disabled && css(["opacity:0.4;cursor:not-allowed;"]), (props) => !props.isStatusShape && css(["&:before{content:'';position:absolute;top:0;left:0;width:100%;height:100%;background-color:", ";}", ";"], props.color || props.theme.palette["grey-500"], props.isActionable && css(["&:hover:before{filter:", ";}"], getFilterColor)), (props) => !!props.isActionable && css(["&:hover{", ",", "{display:none;}", "{position:absolute;top:0;right:", ";display:inline-block;}}"], SuffixWrapper, DefaultSuffixWrapper, RemoveButton, props.removable && props.suffixel ? "-15px" : "0"), SuffixWrapper, DefaultSuffixWrapper, (props) => !props.removable && props.suffixel ? "0px -8px 3px 5px" : "0 4px 3px 1px", PrefixWrapper, DefaultPrefixWrapper, (props) => !props.removable && props.preffixel ? "0px 5px 3px -8px" : "0 1px 3px 4px");
|
|
124
|
+
const DeleteButton = /* @__PURE__ */ styled.div.withConfig({
|
|
129
125
|
displayName: "Tagstyles__DeleteButton",
|
|
130
126
|
componentId: "sc-1xw3den-8"
|
|
131
|
-
})([""]);
|
|
127
|
+
})([""]);
|
|
128
|
+
export {
|
|
129
|
+
Content,
|
|
130
|
+
DefaultPrefixWrapper,
|
|
131
|
+
DefaultSuffixWrapper,
|
|
132
|
+
DeleteButton,
|
|
133
|
+
PrefixWrapper,
|
|
134
|
+
RemoveButton,
|
|
135
|
+
SuffixWrapper,
|
|
136
|
+
Tag,
|
|
137
|
+
TagName,
|
|
138
|
+
getColorText
|
|
139
|
+
};
|
package/dist/Tag.types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { TooltipProps } from '@synerise/ds-tooltip';
|
|
3
|
+
import { WithHTMLAttributes } from '@synerise/ds-utils';
|
|
4
4
|
export type TagTexts = {
|
|
5
5
|
addButtonLabel?: ReactNode;
|
|
6
6
|
searchPlaceholder?: string;
|
package/dist/Tag.types.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return
|
|
14
|
-
}({});
|
|
1
|
+
var TagShape = /* @__PURE__ */ ((TagShape2) => {
|
|
2
|
+
TagShape2["SINGLE_CHARACTER_ROUND"] = "single_character_round";
|
|
3
|
+
TagShape2["SINGLE_CHARACTER_SQUARE"] = "single_character_square";
|
|
4
|
+
TagShape2["DEFAULT_ROUND"] = "default_round";
|
|
5
|
+
TagShape2["DEFAULT_SQUARE"] = "default_square";
|
|
6
|
+
TagShape2["MEDIUM_ROUND"] = "medium_round";
|
|
7
|
+
TagShape2["SMALL_ROUND"] = "small_round";
|
|
8
|
+
TagShape2["SMALL_SQUARE"] = "small_square";
|
|
9
|
+
TagShape2["STATUS_NEUTRAL"] = "status_custom";
|
|
10
|
+
TagShape2["STATUS_SUCCESS"] = "status_active";
|
|
11
|
+
TagShape2["STATUS_ERROR"] = "status_inactive";
|
|
12
|
+
TagShape2["STATUS_WARNING"] = "status_paused";
|
|
13
|
+
return TagShape2;
|
|
14
|
+
})(TagShape || {});
|
|
15
|
+
export {
|
|
16
|
+
TagShape
|
|
17
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TagTexts } from '../Tag.types';
|
|
2
2
|
export declare const useDefaultTexts: (texts?: Partial<TagTexts>) => TagTexts;
|
|
@@ -1,44 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
formatMessage
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
id: "DS.TAG.CREATE-TAG-LABEL",
|
|
23
|
-
defaultMessage: "Create tag"
|
|
24
|
-
}),
|
|
25
|
-
dropdownNoTags: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
26
|
-
id: "DS.TAG.NO-TAGS",
|
|
27
|
-
defaultMessage: "No data"
|
|
28
|
-
}),
|
|
29
|
-
clearTooltip: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
30
|
-
id: "DS.TAG.CLEAR-TOOLTIP",
|
|
31
|
-
defaultMessage: "Clear"
|
|
32
|
-
}),
|
|
33
|
-
deleteTooltip: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
34
|
-
id: "DS.TAG.DELETE-TOOLTIP",
|
|
35
|
-
defaultMessage: "Delete"
|
|
36
|
-
}),
|
|
37
|
-
noResultsLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
38
|
-
id: "DS.TAG.NO-SEARCH-RESULTS",
|
|
39
|
-
defaultMessage: "No tags found"
|
|
40
|
-
})
|
|
41
|
-
}, texts || {});
|
|
42
|
-
}, [texts, formatMessage]);
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { useIntl, FormattedMessage } from "react-intl";
|
|
4
|
+
const useDefaultTexts = (texts) => {
|
|
5
|
+
const {
|
|
6
|
+
formatMessage
|
|
7
|
+
} = useIntl();
|
|
8
|
+
const allTexts = useMemo(() => ({
|
|
9
|
+
searchPlaceholder: formatMessage({
|
|
10
|
+
id: "DS.TAG.SEARCH-PLACEHOLDER",
|
|
11
|
+
defaultMessage: "Search"
|
|
12
|
+
}),
|
|
13
|
+
addButtonLabel: /* @__PURE__ */ jsx(FormattedMessage, { id: "DS.TAG.ADD-BUTTON-LABEL", defaultMessage: "Add tag" }),
|
|
14
|
+
manageLinkLabel: /* @__PURE__ */ jsx(FormattedMessage, { id: "DS.TAG.MANAGE-LINK-LABEL", defaultMessage: "Manage tags" }),
|
|
15
|
+
createTagButtonLabel: /* @__PURE__ */ jsx(FormattedMessage, { id: "DS.TAG.CREATE-TAG-LABEL", defaultMessage: "Create tag" }),
|
|
16
|
+
dropdownNoTags: /* @__PURE__ */ jsx(FormattedMessage, { id: "DS.TAG.NO-TAGS", defaultMessage: "No data" }),
|
|
17
|
+
clearTooltip: /* @__PURE__ */ jsx(FormattedMessage, { id: "DS.TAG.CLEAR-TOOLTIP", defaultMessage: "Clear" }),
|
|
18
|
+
deleteTooltip: /* @__PURE__ */ jsx(FormattedMessage, { id: "DS.TAG.DELETE-TOOLTIP", defaultMessage: "Delete" }),
|
|
19
|
+
noResultsLabel: /* @__PURE__ */ jsx(FormattedMessage, { id: "DS.TAG.NO-SEARCH-RESULTS", defaultMessage: "No tags found" }),
|
|
20
|
+
...texts || {}
|
|
21
|
+
}), [texts, formatMessage]);
|
|
43
22
|
return allTexts;
|
|
44
|
-
};
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
useDefaultTexts
|
|
26
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { default as default2 } from "./Tag.js";
|
|
2
|
+
import { TagShape } from "./Tag.types.js";
|
|
3
|
+
import { useDefaultTexts } from "./hooks/useDefaultTexts.js";
|
|
4
|
+
export {
|
|
5
|
+
TagShape,
|
|
6
|
+
default2 as default,
|
|
7
|
+
useDefaultTexts
|
|
8
|
+
};
|
package/dist/modules.d.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "@testing-library/jest-dom/extend-expect";
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-tag",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.18",
|
|
4
4
|
"description": "Tag UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
|
-
"build": "
|
|
19
|
+
"build": "vite build",
|
|
20
20
|
"build:css": "node ../../../scripts/style/less.js",
|
|
21
21
|
"build:js": "babel --delete-dir-on-start --root-mode upward src --out-dir dist --extensions '.js,.ts,.tsx'",
|
|
22
|
-
"build:watch": "
|
|
22
|
+
"build:watch": "vite build --watch",
|
|
23
23
|
"defs": "tsc --declaration --outDir dist/ --emitDeclarationOnly",
|
|
24
24
|
"pack:ci": "pnpm pack --pack-destination ../../storybook/storybook-static/static",
|
|
25
25
|
"prepublish": "pnpm run build",
|
|
@@ -35,14 +35,15 @@
|
|
|
35
35
|
],
|
|
36
36
|
"types": "dist/index.d.ts",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@synerise/ds-icon": "^1.
|
|
39
|
-
"@synerise/ds-tooltip": "^1.4.
|
|
40
|
-
"@synerise/ds-utils": "^1.
|
|
38
|
+
"@synerise/ds-icon": "^1.15.1",
|
|
39
|
+
"@synerise/ds-tooltip": "^1.4.10",
|
|
40
|
+
"@synerise/ds-utils": "^1.7.1",
|
|
41
|
+
"react-intl": "^6.8.7"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|
|
43
44
|
"@synerise/ds-core": "*",
|
|
44
45
|
"react": ">=16.9.0 <= 18.3.1",
|
|
45
46
|
"styled-components": "^5.3.3"
|
|
46
47
|
},
|
|
47
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "e4ecca8944fc9b41c1b9d59c8bcad5e5e2013225"
|
|
48
49
|
}
|