@synerise/ds-tag 1.0.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/LICENSE.md +21 -0
- package/README.md +56 -0
- package/dist/Tag.d.ts +4 -0
- package/dist/Tag.js +105 -0
- package/dist/Tag.styles.d.ts +32 -0
- package/dist/Tag.styles.js +131 -0
- package/dist/Tag.types.d.ts +43 -0
- package/dist/Tag.types.js +14 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/modules.d.js +1 -0
- package/package.json +47 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Synerise
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: tag
|
|
3
|
+
title: Tag
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Tag UI Component
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
```
|
|
10
|
+
npm i @synerise/ds-tag
|
|
11
|
+
or
|
|
12
|
+
yarn add @synerise/ds-tag
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
```
|
|
17
|
+
import Tag from '@synerise/ds-tag'
|
|
18
|
+
|
|
19
|
+
<Tag />
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Demo
|
|
24
|
+
|
|
25
|
+
<iframe src="/storybook-static/iframe.html?id=components-tag--default"></iframe>
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
| Property | Description | Type | Default |
|
|
30
|
+
| --------- | ---------------------------------------- | --------------------------------- | ---------------------- |
|
|
31
|
+
| className | tag container class | string | - |
|
|
32
|
+
| color | primary color (background/border) of tag | string | - |
|
|
33
|
+
| disabled | whether tag should be disabled | boolean | - |
|
|
34
|
+
| id | id of tag (necessary if using Tags) | string / number | - |
|
|
35
|
+
| name | title of tag | string | - |
|
|
36
|
+
| onClick | onClick event on tag body | () => void | - |
|
|
37
|
+
| onRemove | callback when tag is removed | (tagKey: string / number) => void | - |
|
|
38
|
+
| removable | show remove button | boolean | - |
|
|
39
|
+
| shape | shape of the tag | TagShape | TagShape.DEFAULT_ROUND |
|
|
40
|
+
| textColor | color of tag name label | string | - |
|
|
41
|
+
| dashed | make border dashed | boolean | - |
|
|
42
|
+
|
|
43
|
+
## TagShape Enum
|
|
44
|
+
|
|
45
|
+
| Property |
|
|
46
|
+
| -------------------------------- |
|
|
47
|
+
| TagShape.SINGLE_CHARACTER_ROUND |
|
|
48
|
+
| TagShape.SINGLE_CHARACTER_SQUARE |
|
|
49
|
+
| TagShape.DEFAULT_ROUND |
|
|
50
|
+
| TagShape.DEFAULT_SQUARE |
|
|
51
|
+
| TagShape.SMALL_ROUND |
|
|
52
|
+
| TagShape.SMALL_SQUARE |
|
|
53
|
+
| TagShape.STATUS_NEUTRAL |
|
|
54
|
+
| TagShape.STATUS_SUCCESS |
|
|
55
|
+
| TagShape.STATUS_ERROR |
|
|
56
|
+
| TagShape.STATUS_WARNING |
|
package/dist/Tag.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TagProps } from './Tag.types';
|
|
3
|
+
declare const Tag: ({ id, name, className, disabled, removable, image, shape, color, textColor, onRemove, onClick, prefixel, suffixel, texts, asPill, dashed, ...htmlAttributes }: TagProps) => React.JSX.Element;
|
|
4
|
+
export default Tag;
|
package/dist/Tag.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
var _excluded = ["id", "name", "className", "disabled", "removable", "image", "shape", "color", "textColor", "onRemove", "onClick", "prefixel", "suffixel", "texts", "asPill", "dashed"];
|
|
2
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
4
|
+
import React, { useState } from 'react';
|
|
5
|
+
import Icon, { CloseS } from '@synerise/ds-icon';
|
|
6
|
+
import { theme } from '@synerise/ds-core';
|
|
7
|
+
import Tooltip from '@synerise/ds-tooltip';
|
|
8
|
+
import { TagShape } from './Tag.types';
|
|
9
|
+
import * as S from './Tag.styles';
|
|
10
|
+
import { getColorText } from './Tag.styles';
|
|
11
|
+
var Tag = function Tag(_ref) {
|
|
12
|
+
var id = _ref.id,
|
|
13
|
+
name = _ref.name,
|
|
14
|
+
className = _ref.className,
|
|
15
|
+
disabled = _ref.disabled,
|
|
16
|
+
removable = _ref.removable,
|
|
17
|
+
image = _ref.image,
|
|
18
|
+
_ref$shape = _ref.shape,
|
|
19
|
+
shape = _ref$shape === void 0 ? TagShape.DEFAULT_ROUND && TagShape.DEFAULT_SQUARE : _ref$shape,
|
|
20
|
+
color = _ref.color,
|
|
21
|
+
textColor = _ref.textColor,
|
|
22
|
+
onRemove = _ref.onRemove,
|
|
23
|
+
onClick = _ref.onClick,
|
|
24
|
+
prefixel = _ref.prefixel,
|
|
25
|
+
suffixel = _ref.suffixel,
|
|
26
|
+
texts = _ref.texts,
|
|
27
|
+
asPill = _ref.asPill,
|
|
28
|
+
dashed = _ref.dashed,
|
|
29
|
+
htmlAttributes = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
30
|
+
var isDefaultType = shape && [TagShape.DEFAULT_ROUND, TagShape.DEFAULT_SQUARE].includes(shape);
|
|
31
|
+
var isDefaultRound = shape === TagShape.DEFAULT_ROUND;
|
|
32
|
+
var isDefaultSquare = shape === TagShape.DEFAULT_SQUARE;
|
|
33
|
+
var isStatusShape = shape && [TagShape.STATUS_ERROR, TagShape.STATUS_NEUTRAL, TagShape.STATUS_SUCCESS, TagShape.STATUS_WARNING].includes(shape);
|
|
34
|
+
var isRemovable = removable && (isDefaultRound || isDefaultSquare);
|
|
35
|
+
var isActionable = !disabled && isRemovable;
|
|
36
|
+
var _useState = useState(false),
|
|
37
|
+
isIconHovered = _useState[0],
|
|
38
|
+
setIsIconHovered = _useState[1];
|
|
39
|
+
var onRemoveCall = function onRemoveCall() {
|
|
40
|
+
return !!onRemove && !!id && onRemove(id);
|
|
41
|
+
};
|
|
42
|
+
var renderPrefixel = function renderPrefixel() {
|
|
43
|
+
if (typeof prefixel === 'string' || typeof prefixel === 'number') {
|
|
44
|
+
return /*#__PURE__*/React.createElement(S.PrefixWrapper, {
|
|
45
|
+
iconHover: isIconHovered
|
|
46
|
+
}, prefixel);
|
|
47
|
+
}
|
|
48
|
+
return /*#__PURE__*/React.createElement(S.DefaultPrefixWrapper, {
|
|
49
|
+
iconHover: isIconHovered
|
|
50
|
+
}, prefixel);
|
|
51
|
+
};
|
|
52
|
+
var renderSuffixel = function renderSuffixel() {
|
|
53
|
+
if (typeof suffixel === 'string' || typeof suffixel === 'number') {
|
|
54
|
+
return /*#__PURE__*/React.createElement(S.SuffixWrapper, null, suffixel);
|
|
55
|
+
}
|
|
56
|
+
return /*#__PURE__*/React.createElement(S.DefaultSuffixWrapper, null, suffixel);
|
|
57
|
+
};
|
|
58
|
+
var handleMouseOver = function handleMouseOver(event) {
|
|
59
|
+
setIsIconHovered(true);
|
|
60
|
+
// eslint-disable-next-line no-unused-expressions
|
|
61
|
+
htmlAttributes.onMouseOver == null || htmlAttributes.onMouseOver(event);
|
|
62
|
+
};
|
|
63
|
+
var handleMouseLeave = function handleMouseLeave(event) {
|
|
64
|
+
setIsIconHovered(false);
|
|
65
|
+
// eslint-disable-next-line no-unused-expressions
|
|
66
|
+
htmlAttributes.onMouseLeave == null || htmlAttributes.onMouseLeave(event);
|
|
67
|
+
};
|
|
68
|
+
return /*#__PURE__*/React.createElement(S.Tag, _extends({
|
|
69
|
+
className: "ds-tag " + (className != null ? className : ''),
|
|
70
|
+
isStatusShape: isStatusShape,
|
|
71
|
+
shape: shape,
|
|
72
|
+
color: color,
|
|
73
|
+
textColor: textColor,
|
|
74
|
+
removable: removable,
|
|
75
|
+
disabled: disabled,
|
|
76
|
+
isActionable: isActionable,
|
|
77
|
+
onClick: onClick,
|
|
78
|
+
"data-testid": typeof id !== 'undefined' ? "tag-" + id : 'tag',
|
|
79
|
+
preffixel: !!prefixel,
|
|
80
|
+
suffixel: !!suffixel,
|
|
81
|
+
hasImage: !!image,
|
|
82
|
+
iconHover: isIconHovered,
|
|
83
|
+
asPill: asPill,
|
|
84
|
+
dashed: dashed
|
|
85
|
+
}, htmlAttributes), /*#__PURE__*/React.createElement(S.Content, {
|
|
86
|
+
iconHover: isIconHovered
|
|
87
|
+
}, image && isDefaultType && /*#__PURE__*/React.createElement("img", {
|
|
88
|
+
src: image,
|
|
89
|
+
alt: ""
|
|
90
|
+
}), !!prefixel && renderPrefixel(), /*#__PURE__*/React.createElement(S.TagName, null, name), !!suffixel && renderSuffixel(), isRemovable && /*#__PURE__*/React.createElement(Tooltip, {
|
|
91
|
+
title: (texts == null ? void 0 : texts.deleteTooltip) || 'Delete',
|
|
92
|
+
visible: isIconHovered
|
|
93
|
+
}, /*#__PURE__*/React.createElement(S.RemoveButton, {
|
|
94
|
+
onClick: onRemoveCall,
|
|
95
|
+
onMouseOver: handleMouseOver,
|
|
96
|
+
onMouseLeave: handleMouseLeave,
|
|
97
|
+
"data-testid": "remove-btn"
|
|
98
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
99
|
+
className: "icon",
|
|
100
|
+
component: /*#__PURE__*/React.createElement(CloseS, null),
|
|
101
|
+
size: 24,
|
|
102
|
+
color: getColorText(theme, color)
|
|
103
|
+
})))));
|
|
104
|
+
};
|
|
105
|
+
export default Tag;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ThemeProps, ThemePropsVars } from '@synerise/ds-core';
|
|
2
|
+
import { TagShape } from './Tag.types';
|
|
3
|
+
export declare const getColorText: (theme: ThemePropsVars, color?: string) => string;
|
|
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
|
+
export declare const Content: import("styled-components").StyledComponent<"div", any, {
|
|
7
|
+
iconHover?: boolean | undefined;
|
|
8
|
+
}, never>;
|
|
9
|
+
export declare const PrefixWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
10
|
+
iconHover?: boolean | undefined;
|
|
11
|
+
}, never>;
|
|
12
|
+
export declare const SuffixWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
13
|
+
export declare const DefaultSuffixWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
14
|
+
export declare const DefaultPrefixWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
15
|
+
iconHover?: boolean | undefined;
|
|
16
|
+
}, never>;
|
|
17
|
+
export declare const Tag: import("styled-components").StyledComponent<"div", any, {
|
|
18
|
+
isStatusShape?: boolean | undefined;
|
|
19
|
+
shape?: TagShape | undefined;
|
|
20
|
+
color?: string | undefined;
|
|
21
|
+
textColor?: string | undefined;
|
|
22
|
+
removable?: boolean | undefined;
|
|
23
|
+
disabled?: boolean | undefined;
|
|
24
|
+
isActionable?: boolean | undefined;
|
|
25
|
+
suffixel?: boolean | undefined;
|
|
26
|
+
preffixel?: boolean | undefined;
|
|
27
|
+
hasImage?: boolean | undefined;
|
|
28
|
+
iconHover?: boolean | undefined;
|
|
29
|
+
asPill?: boolean | undefined;
|
|
30
|
+
dashed?: boolean | undefined;
|
|
31
|
+
} & ThemeProps, never>;
|
|
32
|
+
export declare const DeleteButton: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
import { TagShape } from './Tag.types';
|
|
3
|
+
var defaultStatusStyles = 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
|
+
export var getColorText = function getColorText(theme, color) {
|
|
5
|
+
return color === theme.palette['grey-200'] ? theme.palette['grey-600'] : theme.palette.white;
|
|
6
|
+
};
|
|
7
|
+
var getWidthOnHover = function getWidthOnHover(props) {
|
|
8
|
+
if (props.suffixel && props.preffixel || props.hasImage) {
|
|
9
|
+
return 'calc(100% - 23px)';
|
|
10
|
+
}
|
|
11
|
+
if (props.preffixel) {
|
|
12
|
+
return 'calc(100% - 35px)';
|
|
13
|
+
}
|
|
14
|
+
if (props.suffixel) {
|
|
15
|
+
return 'calc(100% - 4px)';
|
|
16
|
+
}
|
|
17
|
+
return 'calc(100% - 10px)';
|
|
18
|
+
};
|
|
19
|
+
var getFilterColor = function getFilterColor(props) {
|
|
20
|
+
if (props.iconHover && props.color === props.theme.palette['grey-200']) {
|
|
21
|
+
return 'brightness(100%)';
|
|
22
|
+
}
|
|
23
|
+
if (props.color === props.theme.palette['grey-200']) {
|
|
24
|
+
return 'brightness(90%)';
|
|
25
|
+
}
|
|
26
|
+
if (props.iconHover) {
|
|
27
|
+
return 'brightness(100%)';
|
|
28
|
+
}
|
|
29
|
+
return 'brightness(110%)';
|
|
30
|
+
};
|
|
31
|
+
var addonStyles = function addonStyles(props) {
|
|
32
|
+
return "\n border: 1px solid;\n border-radius: 10px;\n height: 50%;\n padding: 0 3px;\n border-color: " + props.theme.palette.white + ";\n font-size: 9px;\n line-height: 10px;\n text-align: center;\n";
|
|
33
|
+
};
|
|
34
|
+
export var TagName = styled.span.withConfig({
|
|
35
|
+
displayName: "Tagstyles__TagName",
|
|
36
|
+
componentId: "sc-1xw3den-0"
|
|
37
|
+
})(["white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"]);
|
|
38
|
+
export var RemoveButton = styled.div.withConfig({
|
|
39
|
+
displayName: "Tagstyles__RemoveButton",
|
|
40
|
+
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);}}"], function (_ref) {
|
|
42
|
+
var color = _ref.color,
|
|
43
|
+
theme = _ref.theme;
|
|
44
|
+
return getColorText(theme, color);
|
|
45
|
+
}, function (props) {
|
|
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) {
|
|
51
|
+
switch (props.shape) {
|
|
52
|
+
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 || '#fff');
|
|
54
|
+
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 || '#fff');
|
|
56
|
+
case TagShape.MEDIUM_ROUND:
|
|
57
|
+
return css(["color:", ";", ""], props.textColor || getColorText(props.theme, props.color), defaultStatusStyles);
|
|
58
|
+
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 ? '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
|
+
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 ? '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
|
+
case TagShape.SINGLE_CHARACTER_ROUND:
|
|
63
|
+
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
|
+
case TagShape.SINGLE_CHARACTER_SQUARE:
|
|
65
|
+
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
|
+
case TagShape.STATUS_NEUTRAL:
|
|
67
|
+
return css(["border:1px solid ", ";color:", ";", ""], props.color || props.theme.palette['grey-500'], props.textColor || props.color || props.theme.palette['grey-500'], defaultStatusStyles);
|
|
68
|
+
case TagShape.STATUS_SUCCESS:
|
|
69
|
+
return css(["border:1px solid ", ";color:", ";", ""], props.theme.palette['green-600'], props.theme.palette['green-600'], defaultStatusStyles);
|
|
70
|
+
case TagShape.STATUS_ERROR:
|
|
71
|
+
return css(["border:1px solid ", ";color:", ";", ""], props.theme.palette['red-600'], props.theme.palette['red-600'], defaultStatusStyles);
|
|
72
|
+
case TagShape.STATUS_WARNING:
|
|
73
|
+
return css(["border:1px solid ", ";color:", ";", ""], props.theme.palette['yellow-600'], props.theme.palette['yellow-600'], defaultStatusStyles);
|
|
74
|
+
default:
|
|
75
|
+
return css([""]);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
export var Content = styled.div.withConfig({
|
|
79
|
+
displayName: "Tagstyles__Content",
|
|
80
|
+
componentId: "sc-1xw3den-2"
|
|
81
|
+
})(["position:relative;display:flex;align-items:center;flex-grow:0;flex-shrink:1;max-width:100%;", ""], function (props) {
|
|
82
|
+
return !!props.iconHover && "\n &&& {\n color:" + props.theme.palette['red-600'] + ";\n }\n";
|
|
83
|
+
});
|
|
84
|
+
export var PrefixWrapper = styled.div.withConfig({
|
|
85
|
+
displayName: "Tagstyles__PrefixWrapper",
|
|
86
|
+
componentId: "sc-1xw3den-3"
|
|
87
|
+
})(["", ";", ""], function (props) {
|
|
88
|
+
return addonStyles(props);
|
|
89
|
+
}, function (props) {
|
|
90
|
+
return !!props.iconHover && ".ant-scroll-number{ \n color: " + props.theme.palette['red-600'] + "!important;\n box-shadow: 0 0 0 1px " + props.theme.palette['red-600'] + "!important;\n }\n .ds-icon svg {\n fill: " + props.theme.palette['red-600'] + ";\n}";
|
|
91
|
+
});
|
|
92
|
+
export var SuffixWrapper = styled.div.withConfig({
|
|
93
|
+
displayName: "Tagstyles__SuffixWrapper",
|
|
94
|
+
componentId: "sc-1xw3den-4"
|
|
95
|
+
})(["", ";"], function (props) {
|
|
96
|
+
return addonStyles(props);
|
|
97
|
+
});
|
|
98
|
+
export var DefaultSuffixWrapper = styled.div.withConfig({
|
|
99
|
+
displayName: "Tagstyles__DefaultSuffixWrapper",
|
|
100
|
+
componentId: "sc-1xw3den-5"
|
|
101
|
+
})([""]);
|
|
102
|
+
export var DefaultPrefixWrapper = styled.div.withConfig({
|
|
103
|
+
displayName: "Tagstyles__DefaultPrefixWrapper",
|
|
104
|
+
componentId: "sc-1xw3den-6"
|
|
105
|
+
})(["", ""], function (props) {
|
|
106
|
+
return !!props.iconHover && ".ant-scroll-number{ \n color: " + props.theme.palette['red-600'] + "!important;\n box-shadow: 0 0 0 1px " + props.theme.palette['red-600'] + "!important;\n }\n.ds-icon svg {\n fill: " + props.theme.palette['red-600'] + ";\n}";
|
|
107
|
+
});
|
|
108
|
+
export var Tag = styled.div.withConfig({
|
|
109
|
+
displayName: "Tagstyles__Tag",
|
|
110
|
+
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;}", ";&:last-of-type{margin-right:0;}", ",", "{margin:", ";}", ",", "{margin:", ";}"], function (props) {
|
|
112
|
+
return !props.asPill && css(["cursor:pointer;&:hover:before{filter:", ";}"], getFilterColor);
|
|
113
|
+
}, function (props) {
|
|
114
|
+
return insertShapeStyles(props);
|
|
115
|
+
}, function (props) {
|
|
116
|
+
return !!props.iconHover && "\n &&&:before{\n background-color:" + props.theme.palette['red-050'] + ";\n }\n";
|
|
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({
|
|
129
|
+
displayName: "Tagstyles__DeleteButton",
|
|
130
|
+
componentId: "sc-1xw3den-8"
|
|
131
|
+
})([""]);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { WithHTMLAttributes } from '@synerise/ds-utils';
|
|
3
|
+
export type TagTexts = {
|
|
4
|
+
addButtonLabel?: ReactNode;
|
|
5
|
+
searchPlaceholder?: string;
|
|
6
|
+
manageLinkLabel?: ReactNode;
|
|
7
|
+
createTagButtonLabel?: ReactNode;
|
|
8
|
+
dropdownNoTags?: ReactNode;
|
|
9
|
+
clearTooltip?: ReactNode;
|
|
10
|
+
deleteTooltip?: ReactNode;
|
|
11
|
+
noResultsLabel?: ReactNode;
|
|
12
|
+
};
|
|
13
|
+
export type TagProps = WithHTMLAttributes<HTMLDivElement, {
|
|
14
|
+
id?: string | number;
|
|
15
|
+
name?: string;
|
|
16
|
+
textColor?: string;
|
|
17
|
+
color?: string;
|
|
18
|
+
image?: string;
|
|
19
|
+
shape?: TagShape;
|
|
20
|
+
removable?: boolean;
|
|
21
|
+
className?: string;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
onClick?: () => void;
|
|
24
|
+
onRemove?: (tag: string | number) => void;
|
|
25
|
+
prefixel?: ReactNode;
|
|
26
|
+
suffixel?: ReactNode;
|
|
27
|
+
texts?: TagTexts;
|
|
28
|
+
asPill?: boolean;
|
|
29
|
+
dashed?: boolean;
|
|
30
|
+
}>;
|
|
31
|
+
export declare enum TagShape {
|
|
32
|
+
SINGLE_CHARACTER_ROUND = "single_character_round",
|
|
33
|
+
SINGLE_CHARACTER_SQUARE = "single_character_square",
|
|
34
|
+
DEFAULT_ROUND = "default_round",
|
|
35
|
+
DEFAULT_SQUARE = "default_square",
|
|
36
|
+
MEDIUM_ROUND = "medium_round",
|
|
37
|
+
SMALL_ROUND = "small_round",
|
|
38
|
+
SMALL_SQUARE = "small_square",
|
|
39
|
+
STATUS_NEUTRAL = "status_custom",
|
|
40
|
+
STATUS_SUCCESS = "status_active",
|
|
41
|
+
STATUS_ERROR = "status_inactive",
|
|
42
|
+
STATUS_WARNING = "status_paused"
|
|
43
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export var TagShape;
|
|
2
|
+
(function (TagShape) {
|
|
3
|
+
TagShape["SINGLE_CHARACTER_ROUND"] = "single_character_round";
|
|
4
|
+
TagShape["SINGLE_CHARACTER_SQUARE"] = "single_character_square";
|
|
5
|
+
TagShape["DEFAULT_ROUND"] = "default_round";
|
|
6
|
+
TagShape["DEFAULT_SQUARE"] = "default_square";
|
|
7
|
+
TagShape["MEDIUM_ROUND"] = "medium_round";
|
|
8
|
+
TagShape["SMALL_ROUND"] = "small_round";
|
|
9
|
+
TagShape["SMALL_SQUARE"] = "small_square";
|
|
10
|
+
TagShape["STATUS_NEUTRAL"] = "status_custom";
|
|
11
|
+
TagShape["STATUS_SUCCESS"] = "status_active";
|
|
12
|
+
TagShape["STATUS_ERROR"] = "status_inactive";
|
|
13
|
+
TagShape["STATUS_WARNING"] = "status_paused";
|
|
14
|
+
})(TagShape || (TagShape = {}));
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/extend-expect';
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@synerise/ds-tag",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Tag UI Component for the Synerise Design System",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"repository": "Synerise/synerise-design",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"/dist",
|
|
10
|
+
"CHANGELOG.md",
|
|
11
|
+
"README.md",
|
|
12
|
+
"package.json",
|
|
13
|
+
"LICENSE.md"
|
|
14
|
+
],
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "npm run build:js && npm run build:css && npm run defs",
|
|
20
|
+
"build:css": "node ../../../scripts/style/less.js",
|
|
21
|
+
"build:js": "babel --delete-dir-on-start --root-mode upward src --out-dir dist --extensions '.js,.ts,.tsx'",
|
|
22
|
+
"build:watch": "npm run build:js -- --watch",
|
|
23
|
+
"defs": "tsc --declaration --outDir dist/ --emitDeclarationOnly",
|
|
24
|
+
"pack:ci": "npm pack --pack-destination ../../storybook/storybook-static/static",
|
|
25
|
+
"prepublish": "npm run build",
|
|
26
|
+
"test": "jest",
|
|
27
|
+
"test:watch": "npm run test -- --watchAll",
|
|
28
|
+
"types": "tsc --noEmit",
|
|
29
|
+
"upgrade:ds": "ncu -f \"@synerise/ds-*\" -u"
|
|
30
|
+
},
|
|
31
|
+
"sideEffects": [
|
|
32
|
+
"dist/style/*",
|
|
33
|
+
"*.less"
|
|
34
|
+
],
|
|
35
|
+
"types": "dist/index.d.ts",
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@synerise/ds-icon": "^1.0.0",
|
|
38
|
+
"@synerise/ds-tooltip": "^1.0.0",
|
|
39
|
+
"@synerise/ds-utils": "^1.0.0"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@synerise/ds-core": "*",
|
|
43
|
+
"react": ">=16.9.0 <= 18.3.1",
|
|
44
|
+
"styled-components": "^5.3.3"
|
|
45
|
+
},
|
|
46
|
+
"gitHead": "405e8d42fe3535bc45bbc996485c3d4e1bef27a6"
|
|
47
|
+
}
|