@rescui/tag 0.1.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.txt +202 -0
- package/README.md +3 -0
- package/lib/index.css +537 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +5 -0
- package/lib/parts/base-tag.d.ts +34 -0
- package/lib/parts/base-tag.js +72 -0
- package/lib/parts/base-tag.module.pcss.js +13 -0
- package/lib/parts/presets.d.ts +9 -0
- package/lib/parts/presets.js +36 -0
- package/lib/parts/removable-tag.d.ts +14 -0
- package/lib/parts/removable-tag.js +77 -0
- package/lib/parts/removable-tag.module.pcss.js +15 -0
- package/lib/parts/sticky-tag.d.ts +46 -0
- package/lib/parts/sticky-tag.js +116 -0
- package/lib/parts/sticky-tag.module.pcss.js +18 -0
- package/lib/parts/tag.module.pcss.js +7 -0
- package/lib/tag.d.ts +35 -0
- package/lib/tag.js +54 -0
- package/package.json +36 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RS_COLOR_WHITE, RS_COLOR_PRIMARY_LIGHT_THEME, RS_COLOR_BLACK, RS_COLOR_BLACK_T10, RS_COLOR_PRIMARY_DARK_THEME, RS_COLOR_WHITE_T10 } from '@rescui/colors';
|
|
2
|
+
var presets = {
|
|
3
|
+
classicLight: {
|
|
4
|
+
color: RS_COLOR_WHITE,
|
|
5
|
+
backgroundColor: "var(--rs-color-primary-light-theme, ".concat(RS_COLOR_PRIMARY_LIGHT_THEME, ")")
|
|
6
|
+
},
|
|
7
|
+
rockLight: {
|
|
8
|
+
color: RS_COLOR_WHITE,
|
|
9
|
+
backgroundColor: RS_COLOR_BLACK
|
|
10
|
+
},
|
|
11
|
+
filledLight: {
|
|
12
|
+
color: RS_COLOR_BLACK,
|
|
13
|
+
backgroundColor: RS_COLOR_BLACK_T10
|
|
14
|
+
},
|
|
15
|
+
outlineLight: {
|
|
16
|
+
color: RS_COLOR_BLACK,
|
|
17
|
+
borderColor: RS_COLOR_BLACK
|
|
18
|
+
},
|
|
19
|
+
classicDark: {
|
|
20
|
+
color: RS_COLOR_WHITE,
|
|
21
|
+
backgroundColor: "var(--rs-color-primary-dark-theme, ".concat(RS_COLOR_PRIMARY_DARK_THEME, ")")
|
|
22
|
+
},
|
|
23
|
+
rockDark: {
|
|
24
|
+
color: RS_COLOR_BLACK,
|
|
25
|
+
backgroundColor: RS_COLOR_WHITE
|
|
26
|
+
},
|
|
27
|
+
filledDark: {
|
|
28
|
+
color: RS_COLOR_WHITE,
|
|
29
|
+
backgroundColor: RS_COLOR_WHITE_T10
|
|
30
|
+
},
|
|
31
|
+
outlineDark: {
|
|
32
|
+
color: RS_COLOR_WHITE,
|
|
33
|
+
borderColor: RS_COLOR_WHITE
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export { presets };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Theme } from '@rescui/ui-contexts';
|
|
3
|
+
export declare type RemovableTagSize = 'xs' | 's' | 'm' | 'l';
|
|
4
|
+
export declare type RemovableTagProps = {
|
|
5
|
+
className?: string;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
size?: RemovableTagSize;
|
|
9
|
+
theme?: Theme;
|
|
10
|
+
/** Additional left icon */
|
|
11
|
+
icon?: React.ReactNode;
|
|
12
|
+
onRemoveClick: () => void;
|
|
13
|
+
};
|
|
14
|
+
export declare const RemovableTag: React.ForwardRefExoticComponent<RemovableTagProps & React.RefAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import "core-js/modules/web.dom-collections.for-each.js";
|
|
2
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
3
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
4
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
5
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
|
6
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
7
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
8
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
|
9
|
+
var _excluded = ["className", "disabled", "size", "theme", "children", "icon", "onRemoveClick"];
|
|
10
|
+
|
|
11
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) { symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
12
|
+
|
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { Object.defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
14
|
+
|
|
15
|
+
import React, { cloneElement } from 'react';
|
|
16
|
+
import PropTypes from 'prop-types';
|
|
17
|
+
import cn from 'classnames';
|
|
18
|
+
import { useTheme } from '@rescui/ui-contexts';
|
|
19
|
+
import { CloseIcon } from '@rescui/icons';
|
|
20
|
+
import styles from './removable-tag.module.pcss.js';
|
|
21
|
+
|
|
22
|
+
function getIconSize(size) {
|
|
23
|
+
return size === 'xs' ? 's' : size;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var SIZE_STYLES = {
|
|
27
|
+
xs: styles.sizeXs,
|
|
28
|
+
s: styles.sizeS,
|
|
29
|
+
m: styles.sizeM,
|
|
30
|
+
l: styles.sizeL
|
|
31
|
+
};
|
|
32
|
+
var THEME_STYLES = {
|
|
33
|
+
light: styles.themeLight,
|
|
34
|
+
dark: styles.themeDark
|
|
35
|
+
};
|
|
36
|
+
var RemovableTag = /*#__PURE__*/React.forwardRef(function Tag(_ref, ref) {
|
|
37
|
+
var className = _ref.className,
|
|
38
|
+
disabled = _ref.disabled,
|
|
39
|
+
_ref$size = _ref.size,
|
|
40
|
+
size = _ref$size === void 0 ? 'xs' : _ref$size,
|
|
41
|
+
themeFromProps = _ref.theme,
|
|
42
|
+
children = _ref.children,
|
|
43
|
+
icon = _ref.icon,
|
|
44
|
+
_ref$onRemoveClick = _ref.onRemoveClick,
|
|
45
|
+
onRemoveClick = _ref$onRemoveClick === void 0 ? function () {} : _ref$onRemoveClick,
|
|
46
|
+
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
47
|
+
|
|
48
|
+
var theme = useTheme(themeFromProps);
|
|
49
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
50
|
+
className: cn(styles.wrapper, SIZE_STYLES[size], THEME_STYLES[theme], disabled && styles.disabled, className),
|
|
51
|
+
"data-test": 'removable-tag-wrapper',
|
|
52
|
+
ref: ref
|
|
53
|
+
}, /*#__PURE__*/React.isValidElement(icon) && /*#__PURE__*/cloneElement(icon, {
|
|
54
|
+
className: cn(icon.props.className, styles.icon)
|
|
55
|
+
}), /*#__PURE__*/React.createElement("span", _objectSpread(_objectSpread({}, restProps), {}, {
|
|
56
|
+
className: styles.main,
|
|
57
|
+
"data-test": "removable-tag"
|
|
58
|
+
}), children), /*#__PURE__*/React.createElement("button", {
|
|
59
|
+
type: "button",
|
|
60
|
+
"data-test": "removable-tag-remove-icon",
|
|
61
|
+
className: styles.close,
|
|
62
|
+
onClick: function onClick(e) {
|
|
63
|
+
e.stopPropagation();
|
|
64
|
+
onRemoveClick();
|
|
65
|
+
}
|
|
66
|
+
}, /*#__PURE__*/React.createElement(CloseIcon, {
|
|
67
|
+
size: getIconSize(size)
|
|
68
|
+
})));
|
|
69
|
+
});
|
|
70
|
+
RemovableTag.propTypes = {
|
|
71
|
+
disabled: PropTypes.bool,
|
|
72
|
+
size: PropTypes.oneOf(['xs', 's', 'm', 'l']),
|
|
73
|
+
theme: PropTypes.oneOf(['dark', 'light']),
|
|
74
|
+
icon: PropTypes.node,
|
|
75
|
+
onRemoveClick: PropTypes.func.isRequired
|
|
76
|
+
};
|
|
77
|
+
export { RemovableTag };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var styles = {
|
|
2
|
+
"wrapper": "_wrapper_vd286z_41",
|
|
3
|
+
"sizeXs": "_sizeXs_vd286z_53",
|
|
4
|
+
"sizeS": "_sizeS_vd286z_54",
|
|
5
|
+
"rs-reset-letter-spacing": "_rs-reset-letter-spacing_vd286z_1",
|
|
6
|
+
"sizeM": "_sizeM_vd286z_58",
|
|
7
|
+
"sizeL": "_sizeL_vd286z_62",
|
|
8
|
+
"themeLight": "_themeLight_vd286z_66",
|
|
9
|
+
"disabled": "_disabled_vd286z_66",
|
|
10
|
+
"themeDark": "_themeDark_vd286z_70",
|
|
11
|
+
"main": "_main_vd286z_111",
|
|
12
|
+
"close": "_close_vd286z_142",
|
|
13
|
+
"icon": "_icon_vd286z_242"
|
|
14
|
+
};
|
|
15
|
+
export default styles;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BaseTagIconPosition, BaseTagSize } from './base-tag';
|
|
3
|
+
export declare type StickyTagSize = BaseTagSize;
|
|
4
|
+
export declare type StickyTagIconPosition = BaseTagIconPosition;
|
|
5
|
+
export declare type StickyTagPlacement = 'top-start' | 'top-end' | 'left-end' | 'left-start';
|
|
6
|
+
export declare type StickyTagAlign = 'top' | 'middle';
|
|
7
|
+
export declare type StickyTagOffset = 16 | 24 | 32;
|
|
8
|
+
export declare type StickyTagProps = {
|
|
9
|
+
/** Additional class-name */
|
|
10
|
+
className?: string;
|
|
11
|
+
/** The content of the attached Tag */
|
|
12
|
+
content: React.ReactNode;
|
|
13
|
+
/** Target element */
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
/** badge size */
|
|
16
|
+
size?: StickyTagSize;
|
|
17
|
+
/** Should the content be uppercase */
|
|
18
|
+
isUppercase?: boolean;
|
|
19
|
+
/** Tag placement */
|
|
20
|
+
placement?: StickyTagPlacement;
|
|
21
|
+
/** Tag align relative to the target border */
|
|
22
|
+
align?: StickyTagAlign;
|
|
23
|
+
/** Offset from the edge */
|
|
24
|
+
offset?: StickyTagOffset;
|
|
25
|
+
/** Text color */
|
|
26
|
+
color: string;
|
|
27
|
+
/**
|
|
28
|
+
* Background color.
|
|
29
|
+
* @default transparent
|
|
30
|
+
* */
|
|
31
|
+
backgroundColor?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Border color.
|
|
34
|
+
* @default transparent
|
|
35
|
+
* */
|
|
36
|
+
borderColor?: string;
|
|
37
|
+
} & ({
|
|
38
|
+
/** Additional icon */
|
|
39
|
+
icon: React.ReactNode;
|
|
40
|
+
/** Additional icon position */
|
|
41
|
+
iconPosition?: StickyTagIconPosition;
|
|
42
|
+
} | {
|
|
43
|
+
icon?: never;
|
|
44
|
+
iconPosition?: never;
|
|
45
|
+
});
|
|
46
|
+
export declare const StickyTag: React.ForwardRefExoticComponent<StickyTagProps & React.RefAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
|
3
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
|
4
|
+
var _excluded = ["className", "content", "children", "size", "placement", "align", "offset"];
|
|
5
|
+
|
|
6
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) { symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
+
|
|
8
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { Object.defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
9
|
+
|
|
10
|
+
import "core-js/modules/es.regexp.exec.js";
|
|
11
|
+
import "core-js/modules/es.string.split.js";
|
|
12
|
+
import "core-js/modules/web.dom-collections.for-each.js";
|
|
13
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
14
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
15
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
16
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
17
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
18
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
|
19
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
20
|
+
import React from 'react';
|
|
21
|
+
import cn from 'classnames';
|
|
22
|
+
import PropTypes from 'prop-types';
|
|
23
|
+
import { BaseTag } from './base-tag.js';
|
|
24
|
+
import styles from './sticky-tag.module.pcss.js';
|
|
25
|
+
var DEFAULT_OFFSET = 24;
|
|
26
|
+
|
|
27
|
+
var parsePlacement = function parsePlacement(placement) {
|
|
28
|
+
var _context, _context2, _context3;
|
|
29
|
+
|
|
30
|
+
var _placement$split$slic = _sliceInstanceProperty(_context = placement.split('-')).call(_context, 0, 2),
|
|
31
|
+
_placement$split$slic2 = _slicedToArray(_placement$split$slic, 2),
|
|
32
|
+
side = _placement$split$slic2[0],
|
|
33
|
+
_placement$split$slic3 = _placement$split$slic2[1],
|
|
34
|
+
justify = _placement$split$slic3 === void 0 ? 'center' : _placement$split$slic3;
|
|
35
|
+
|
|
36
|
+
if (!_includesInstanceProperty(_context2 = ['top', 'right', 'bottom', 'left']).call(_context2, side)) {
|
|
37
|
+
side = 'top';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!_includesInstanceProperty(_context3 = ['start', 'center', 'end']).call(_context3, justify)) {
|
|
41
|
+
justify = 'end';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
side: side,
|
|
46
|
+
justify: justify
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
var SIDE_STYLES = {
|
|
51
|
+
top: styles.top,
|
|
52
|
+
left: styles.left
|
|
53
|
+
};
|
|
54
|
+
var JUSTIFY_STYLES = {
|
|
55
|
+
start: styles.start,
|
|
56
|
+
end: styles.end
|
|
57
|
+
};
|
|
58
|
+
var ALIGN_STYLES = {
|
|
59
|
+
top: styles.alignTop,
|
|
60
|
+
middle: styles.alignMiddle
|
|
61
|
+
};
|
|
62
|
+
var SIZE_STYLES = {
|
|
63
|
+
xs: styles.sizeXs,
|
|
64
|
+
s: styles.sizeS,
|
|
65
|
+
m: styles.sizeM,
|
|
66
|
+
l: styles.sizeL
|
|
67
|
+
};
|
|
68
|
+
var OFFSET_STYLES = {
|
|
69
|
+
16: styles.offset16,
|
|
70
|
+
24: styles.offset24,
|
|
71
|
+
32: styles.offset32
|
|
72
|
+
};
|
|
73
|
+
var StickyTag = /*#__PURE__*/React.forwardRef(function StickyTag(_ref, ref) {
|
|
74
|
+
var className = _ref.className,
|
|
75
|
+
content = _ref.content,
|
|
76
|
+
children = _ref.children,
|
|
77
|
+
_ref$size = _ref.size,
|
|
78
|
+
size = _ref$size === void 0 ? 'xs' : _ref$size,
|
|
79
|
+
_ref$placement = _ref.placement,
|
|
80
|
+
placement = _ref$placement === void 0 ? 'top-end' : _ref$placement,
|
|
81
|
+
_ref$align = _ref.align,
|
|
82
|
+
align = _ref$align === void 0 ? 'top' : _ref$align,
|
|
83
|
+
_ref$offset = _ref.offset,
|
|
84
|
+
offset = _ref$offset === void 0 ? DEFAULT_OFFSET : _ref$offset,
|
|
85
|
+
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
86
|
+
|
|
87
|
+
var _parsePlacement = parsePlacement(placement),
|
|
88
|
+
side = _parsePlacement.side,
|
|
89
|
+
justify = _parsePlacement.justify;
|
|
90
|
+
|
|
91
|
+
var offsetCn = offset in OFFSET_STYLES ? OFFSET_STYLES[offset] : OFFSET_STYLES[DEFAULT_OFFSET];
|
|
92
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
93
|
+
className: cn(styles.wrapper)
|
|
94
|
+
}, /*#__PURE__*/React.createElement(BaseTag, _objectSpread(_objectSpread({
|
|
95
|
+
size: size,
|
|
96
|
+
className: cn(styles.tag, className, SIZE_STYLES[size], JUSTIFY_STYLES[justify], SIDE_STYLES[side], ALIGN_STYLES[align], offsetCn),
|
|
97
|
+
"data-test": 'sticky-tag'
|
|
98
|
+
}, restProps), {}, {
|
|
99
|
+
ref: ref
|
|
100
|
+
}), content), children);
|
|
101
|
+
});
|
|
102
|
+
StickyTag.propTypes = {
|
|
103
|
+
className: PropTypes.string,
|
|
104
|
+
content: PropTypes.node,
|
|
105
|
+
children: PropTypes.node,
|
|
106
|
+
icon: PropTypes.node,
|
|
107
|
+
iconPosition: PropTypes.oneOf(['left', 'right']),
|
|
108
|
+
isUppercase: PropTypes.bool,
|
|
109
|
+
placement: PropTypes.oneOf(['top-start', 'top-end', 'left-start', 'left-end']),
|
|
110
|
+
align: PropTypes.oneOf(['top', 'middle']),
|
|
111
|
+
size: PropTypes.oneOf(['l', 'm', 's', 'xs']),
|
|
112
|
+
color: PropTypes.string.isRequired,
|
|
113
|
+
backgroundColor: PropTypes.string,
|
|
114
|
+
borderColor: PropTypes.string
|
|
115
|
+
};
|
|
116
|
+
export { StickyTag };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var styles = {
|
|
2
|
+
"wrapper": "_wrapper_17tnjix_10",
|
|
3
|
+
"tag": "_tag_17tnjix_14",
|
|
4
|
+
"alignTop": "_alignTop_17tnjix_20",
|
|
5
|
+
"sizeXs": "_sizeXs_17tnjix_21",
|
|
6
|
+
"sizeS": "_sizeS_17tnjix_24",
|
|
7
|
+
"sizeM": "_sizeM_17tnjix_27",
|
|
8
|
+
"sizeL": "_sizeL_17tnjix_30",
|
|
9
|
+
"alignMiddle": "_alignMiddle_17tnjix_35",
|
|
10
|
+
"top": "_top_17tnjix_52",
|
|
11
|
+
"start": "_start_17tnjix_52",
|
|
12
|
+
"offset16": "_offset16_17tnjix_53",
|
|
13
|
+
"offset24": "_offset24_17tnjix_56",
|
|
14
|
+
"offset32": "_offset32_17tnjix_59",
|
|
15
|
+
"end": "_end_17tnjix_64",
|
|
16
|
+
"left": "_left_17tnjix_86"
|
|
17
|
+
};
|
|
18
|
+
export default styles;
|
package/lib/tag.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BaseTagSize, BaseTagIconPosition } from './parts/base-tag';
|
|
3
|
+
export declare type TagSize = BaseTagSize;
|
|
4
|
+
export declare type TagIconPosition = BaseTagIconPosition;
|
|
5
|
+
export declare type TagProps = {
|
|
6
|
+
/** Additional class-name */
|
|
7
|
+
className?: string;
|
|
8
|
+
/** Child element */
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
/** badge size */
|
|
11
|
+
size?: TagSize;
|
|
12
|
+
/** Should the content be uppercase */
|
|
13
|
+
isUppercase?: boolean;
|
|
14
|
+
/** Text color */
|
|
15
|
+
color: string;
|
|
16
|
+
/**
|
|
17
|
+
* Background color.
|
|
18
|
+
* @default transparent
|
|
19
|
+
* */
|
|
20
|
+
backgroundColor?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Border color.
|
|
23
|
+
* @default transparent
|
|
24
|
+
* */
|
|
25
|
+
borderColor?: string;
|
|
26
|
+
} & ({
|
|
27
|
+
/** Additional icon */
|
|
28
|
+
icon: React.ReactNode;
|
|
29
|
+
/** Additional icon position */
|
|
30
|
+
iconPosition?: TagIconPosition;
|
|
31
|
+
} | {
|
|
32
|
+
icon?: never;
|
|
33
|
+
iconPosition?: never;
|
|
34
|
+
});
|
|
35
|
+
export declare const Tag: React.ForwardRefExoticComponent<TagProps & React.RefAttributes<HTMLSpanElement>>;
|
package/lib/tag.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import "core-js/modules/web.dom-collections.for-each.js";
|
|
2
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
3
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
4
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
5
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
|
6
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
7
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
8
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
|
9
|
+
var _excluded = ["className", "children", "size"];
|
|
10
|
+
|
|
11
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) { symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
12
|
+
|
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { Object.defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
14
|
+
|
|
15
|
+
import React from 'react';
|
|
16
|
+
import cn from 'classnames';
|
|
17
|
+
import PropTypes from 'prop-types';
|
|
18
|
+
import { BaseTag } from './parts/base-tag.js';
|
|
19
|
+
import styles from './parts/tag.module.pcss.js';
|
|
20
|
+
var SIZE_STYLES = {
|
|
21
|
+
xs: styles.sizeXs,
|
|
22
|
+
s: styles.sizeS,
|
|
23
|
+
m: styles.sizeM,
|
|
24
|
+
l: styles.sizeL
|
|
25
|
+
};
|
|
26
|
+
var Tag = /*#__PURE__*/React.forwardRef( // eslint-disable-next-line complexity
|
|
27
|
+
function (_ref, ref) {
|
|
28
|
+
var className = _ref.className,
|
|
29
|
+
children = _ref.children,
|
|
30
|
+
_ref$size = _ref.size,
|
|
31
|
+
size = _ref$size === void 0 ? 'xs' : _ref$size,
|
|
32
|
+
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
33
|
+
|
|
34
|
+
return /*#__PURE__*/React.createElement(BaseTag, _objectSpread(_objectSpread({
|
|
35
|
+
"data-test": 'tag'
|
|
36
|
+
}, restProps), {}, {
|
|
37
|
+
size: size,
|
|
38
|
+
ref: ref,
|
|
39
|
+
className: cn(SIZE_STYLES[size], className)
|
|
40
|
+
}), children);
|
|
41
|
+
});
|
|
42
|
+
Tag.displayName = 'Tag';
|
|
43
|
+
Tag.propTypes = {
|
|
44
|
+
className: PropTypes.string,
|
|
45
|
+
children: PropTypes.node,
|
|
46
|
+
icon: PropTypes.node,
|
|
47
|
+
iconPosition: PropTypes.oneOf(['left', 'right']),
|
|
48
|
+
isUppercase: PropTypes.bool,
|
|
49
|
+
size: PropTypes.oneOf(['l', 'm', 's', 'xs']),
|
|
50
|
+
color: PropTypes.string.isRequired,
|
|
51
|
+
backgroundColor: PropTypes.string,
|
|
52
|
+
borderColor: PropTypes.string
|
|
53
|
+
};
|
|
54
|
+
export { Tag };
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rescui/tag",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "JetBrains",
|
|
7
|
+
"main": "lib/index.js",
|
|
8
|
+
"src:main": "src/index.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"lib",
|
|
11
|
+
"LICENSE.txt"
|
|
12
|
+
],
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@babel/runtime-corejs3": "^7.14.0",
|
|
18
|
+
"@rescui/colors": "^0.0.6",
|
|
19
|
+
"@rescui/icons": "^0.5.1",
|
|
20
|
+
"classnames": "^2.3.1",
|
|
21
|
+
"core-js": "^3.9.1"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@rescui/ui-contexts": "<1.0.0",
|
|
25
|
+
"prop-types": "^15.7.2",
|
|
26
|
+
"react": ">=16.8.0 <18"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@rescui/scripts": "^0.1.4",
|
|
30
|
+
"@rescui/typography": "^0.5.0"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "rescui-scripts build"
|
|
34
|
+
},
|
|
35
|
+
"gitHead": "0303dab2dea78cc6ba3a4970148de62fca11a225"
|
|
36
|
+
}
|