odaptos_design_system 2.0.0 → 2.0.2
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/dist/Atoms/Tag/Tag.d.ts +2 -1
- package/dist/Atoms/Typography/Text.d.ts +2 -1
- package/dist/odaptos_design_system.cjs.development.js +28 -6
- package/dist/odaptos_design_system.cjs.development.js.map +1 -1
- package/dist/odaptos_design_system.cjs.production.min.js +1 -1
- package/dist/odaptos_design_system.cjs.production.min.js.map +1 -1
- package/dist/odaptos_design_system.esm.js +28 -6
- package/dist/odaptos_design_system.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/Atoms/Tag/Tag.modules.scss +5 -0
- package/src/Atoms/Tag/Tag.tsx +47 -23
- package/src/Atoms/Typography/Text.tsx +3 -0
- package/src/Organisms/MultiSelect/MultiSelect.tsx +2 -1
- package/src/Organisms/MultiSelect/MultiSelectWithCategories.tsx +1 -0
package/package.json
CHANGED
package/src/Atoms/Tag/Tag.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React, { HTMLAttributes } from 'react';
|
|
1
|
+
import React, { HTMLAttributes, useEffect, useState } from 'react';
|
|
2
2
|
import styles from './Tag.modules.scss';
|
|
3
|
-
import { Text } from '../..';
|
|
3
|
+
import { Text, Tooltip } from '../..';
|
|
4
4
|
import { colord, extend } from 'colord';
|
|
5
5
|
import mixPlugin from 'colord/plugins/mix';
|
|
6
6
|
import { getReadableTextColor } from '../../utils/getReadableTextColor';
|
|
@@ -23,6 +23,7 @@ interface TagProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
23
23
|
amountNumber?: number | undefined;
|
|
24
24
|
customColor?: string;
|
|
25
25
|
className?: string;
|
|
26
|
+
canBeRemoved?: boolean;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
/** Figma link : https://www.figma.com/file/fjnhhbL12HvKccPmJchVnr/Atomic-Library?type=design&node-id=1359-33355&mode=dev */
|
|
@@ -35,6 +36,7 @@ export const Tag = ({
|
|
|
35
36
|
amountNumber,
|
|
36
37
|
customColor,
|
|
37
38
|
className,
|
|
39
|
+
canBeRemoved = false,
|
|
38
40
|
...props
|
|
39
41
|
}: TagProps) => {
|
|
40
42
|
const tagCustomColor = customColor ? colord(customColor) : undefined;
|
|
@@ -80,31 +82,53 @@ export const Tag = ({
|
|
|
80
82
|
else return 'sm';
|
|
81
83
|
};
|
|
82
84
|
|
|
85
|
+
const [isEllipsisActive, setIsEllipsisActive] = useState(false);
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
const checkEllipsis = () => {
|
|
89
|
+
const element = document.querySelector('#tag_text') as HTMLElement;
|
|
90
|
+
if (element) {
|
|
91
|
+
setIsEllipsisActive(element.scrollWidth > element.clientWidth);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
checkEllipsis();
|
|
96
|
+
window.addEventListener('resize', checkEllipsis);
|
|
97
|
+
return () => window.removeEventListener('resize', checkEllipsis);
|
|
98
|
+
}, []);
|
|
99
|
+
|
|
83
100
|
return (
|
|
84
|
-
<
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
className
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
{(amountNumber || amountNumber === 0) && (
|
|
101
|
+
<Tooltip tooltipDescription={text} arrow isTooltipActive={isEllipsisActive}>
|
|
102
|
+
<div
|
|
103
|
+
{...props}
|
|
104
|
+
style={{ backgroundColor: customColor }}
|
|
105
|
+
className={`${styles.tag} ${getTagStatus()} ${getTagSize()} ${
|
|
106
|
+
className ?? ''
|
|
107
|
+
} ${canBeRemoved && styles.canBeRemoved}`}
|
|
108
|
+
>
|
|
109
|
+
{iconLeft &&
|
|
110
|
+
React.cloneElement(iconLeft, {
|
|
111
|
+
style: { fill: getTextColor(), stroke: getTextColor() },
|
|
112
|
+
})}
|
|
97
113
|
<Text
|
|
98
|
-
|
|
99
|
-
weight="bold"
|
|
114
|
+
id="tag_text"
|
|
100
115
|
size={getTextSize()}
|
|
116
|
+
text={text}
|
|
101
117
|
color={getTextColor()}
|
|
102
118
|
/>
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
119
|
+
{(amountNumber || amountNumber === 0) && (
|
|
120
|
+
<Text
|
|
121
|
+
text={`${amountNumber}`}
|
|
122
|
+
weight="bold"
|
|
123
|
+
size={getTextSize()}
|
|
124
|
+
color={getTextColor()}
|
|
125
|
+
/>
|
|
126
|
+
)}
|
|
127
|
+
{iconRight &&
|
|
128
|
+
React.cloneElement(iconRight, {
|
|
129
|
+
style: { fill: getTextColor(), stroke: getTextColor() },
|
|
130
|
+
})}
|
|
131
|
+
</div>
|
|
132
|
+
</Tooltip>
|
|
109
133
|
);
|
|
110
134
|
};
|
|
@@ -11,6 +11,7 @@ interface TextProps extends HTMLAttributes<HTMLParagraphElement> {
|
|
|
11
11
|
textDecoration?: 'underline' | 'line-through';
|
|
12
12
|
className?: string;
|
|
13
13
|
required?: boolean;
|
|
14
|
+
id?: string;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
/** This text should be use to display basic text
|
|
@@ -25,6 +26,7 @@ export const Text = ({
|
|
|
25
26
|
textDecoration,
|
|
26
27
|
className,
|
|
27
28
|
required,
|
|
29
|
+
id,
|
|
28
30
|
...props
|
|
29
31
|
}: TextProps) => {
|
|
30
32
|
const getTextSize = (): string => {
|
|
@@ -53,6 +55,7 @@ export const Text = ({
|
|
|
53
55
|
return (
|
|
54
56
|
<p
|
|
55
57
|
{...props}
|
|
58
|
+
id={id}
|
|
56
59
|
style={{ color: color }}
|
|
57
60
|
className={`${styles.text} ${
|
|
58
61
|
italic ? styles.text_italic : ''
|
|
@@ -234,10 +234,11 @@ export const MultiSelect = ({
|
|
|
234
234
|
size="sm"
|
|
235
235
|
status="info"
|
|
236
236
|
key={`chipt-option-${index}`}
|
|
237
|
+
canBeRemoved
|
|
237
238
|
iconRight={
|
|
238
239
|
<RemoveCircledIcon
|
|
239
240
|
fill={colors.blue_700}
|
|
240
|
-
style={{ cursor: 'pointer' }}
|
|
241
|
+
style={{ cursor: 'pointer !important' }}
|
|
241
242
|
onClick={() => deleteOption(option)}
|
|
242
243
|
/>
|
|
243
244
|
}
|