@trackunit/react-components 0.1.43 → 0.1.45
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/index.js +14 -21
- package/package.json +3 -3
- package/src/components/Badge/Badge.d.ts +2 -1
package/index.js
CHANGED
|
@@ -488,7 +488,7 @@ const IconContainer$1 = tw.div `
|
|
|
488
488
|
* @returns {JSX.Element} Badge component
|
|
489
489
|
*/
|
|
490
490
|
const Badge = (_a) => {
|
|
491
|
-
var { color = "
|
|
491
|
+
var { color = "primary", subtle = false, className, count, max, hideZero = false, dataTestId } = _a; __rest(_a, ["color", "subtle", "className", "count", "max", "hideZero", "dataTestId"]);
|
|
492
492
|
if (hideZero && count === 0) {
|
|
493
493
|
return null;
|
|
494
494
|
}
|
|
@@ -498,20 +498,7 @@ const Badge = (_a) => {
|
|
|
498
498
|
const getBadgeModifierClass = () => ({ $color, $subtle }) => {
|
|
499
499
|
const colorClasses = {
|
|
500
500
|
primary: $subtle ? tws `tu-badge--primary-subtle` : tws `tu-badge--primary`,
|
|
501
|
-
secondary: $subtle ? tws `tu-badge--secondary-subtle` : tws `tu-badge--secondary`,
|
|
502
|
-
accent: $subtle ? tws `tu-badge--accent-subtle` : tws `tu-badge--accent`,
|
|
503
|
-
success: $subtle ? tws `tu-badge--success-subtle` : tws `tu-badge--success`,
|
|
504
501
|
danger: $subtle ? tws `tu-badge--danger-subtle` : tws `tu-badge--danger`,
|
|
505
|
-
warning: $subtle ? tws `tu-badge--warning-subtle` : tws `tu-badge--warning`,
|
|
506
|
-
info: $subtle ? tws `tu-badge--info-subtle` : tws `tu-badge--info`,
|
|
507
|
-
neutral: $subtle ? tws `tu-badge--neutral-subtle` : tws `tu-badge--neutral`,
|
|
508
|
-
good: $subtle ? tws `tu-badge--good-subtle` : tws `tu-badge--good`,
|
|
509
|
-
low: $subtle ? tws `tu-badge--low-subtle` : tws `tu-badge--low`,
|
|
510
|
-
critical: $subtle ? tws `tu-badge--critical-subtle` : tws `tu-badge--critical`,
|
|
511
|
-
working: $subtle ? tws `tu-badge--working-subtle` : tws `tu-badge--working`,
|
|
512
|
-
idle: $subtle ? tws `tu-badge--idle-subtle` : tws `tu-badge--idle`,
|
|
513
|
-
stopped: $subtle ? tws `tu-badge--stopped-subtle` : tws `tu-badge--stopped`,
|
|
514
|
-
unknown: $subtle ? tws `tu-badge--unknown-subtle` : tws `tu-badge--unknown`,
|
|
515
502
|
};
|
|
516
503
|
return colorClasses[$color];
|
|
517
504
|
};
|
|
@@ -1142,8 +1129,8 @@ const HelpAddon = tw.span `
|
|
|
1142
1129
|
*/
|
|
1143
1130
|
const DateField = forwardRef((_a, ref) => {
|
|
1144
1131
|
var { label, tip, helpText, errorMessage, helpAddon, isInvalid, className, defaultValue, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "errorMessage", "helpAddon", "isInvalid", "className", "defaultValue", "dataTestId"]);
|
|
1145
|
-
const renderAsInvalid = isInvalid
|
|
1146
|
-
return (jsx(FormGroup, Object.assign({ label: label, tip: tip, isInvalid: renderAsInvalid, helpText: errorMessage || helpText, helpAddon: helpAddon, disabled: rest.disabled, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsx(DateInput, Object.assign({ ref: ref, defaultValue: defaultValue, isInvalid: renderAsInvalid }, rest, { className: className, dataTestId: dataTestId })) })));
|
|
1132
|
+
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
1133
|
+
return (jsx(FormGroup, Object.assign({ label: label, tip: tip, isInvalid: renderAsInvalid, helpText: (renderAsInvalid && errorMessage) || helpText, helpAddon: helpAddon, disabled: rest.disabled, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsx(DateInput, Object.assign({ ref: ref, defaultValue: defaultValue, isInvalid: renderAsInvalid }, rest, { className: className, dataTestId: dataTestId })) })));
|
|
1147
1134
|
});
|
|
1148
1135
|
|
|
1149
1136
|
const localeLookup = {
|
|
@@ -1353,6 +1340,12 @@ const Container$4 = tw.div `
|
|
|
1353
1340
|
return tws `tu-indicator--moving`;
|
|
1354
1341
|
case "unknown":
|
|
1355
1342
|
return tws `tu-indicator--unknown`;
|
|
1343
|
+
case "unused":
|
|
1344
|
+
return tws `tu-indicator--unused`;
|
|
1345
|
+
case "utilized":
|
|
1346
|
+
return tws `tu-indicator--utilized`;
|
|
1347
|
+
case "heavily_utilized":
|
|
1348
|
+
return tws `tu-indicator--heavily-utilized`;
|
|
1356
1349
|
case "on_rent":
|
|
1357
1350
|
return tws `tu-indicator--on-rent`;
|
|
1358
1351
|
case "available":
|
|
@@ -1374,7 +1367,7 @@ const Container$4 = tw.div `
|
|
|
1374
1367
|
`;
|
|
1375
1368
|
const IconBackground = tw.div `
|
|
1376
1369
|
tu-indicator__icon-background
|
|
1377
|
-
|
|
1370
|
+
|
|
1378
1371
|
${({ $withBackground }) => {
|
|
1379
1372
|
return $withBackground ? "" : "tu-indicator__icon-background--none";
|
|
1380
1373
|
}}
|
|
@@ -1589,8 +1582,8 @@ const NumberInput = forwardRef((props, ref) => (jsx(BaseInput, Object.assign({ r
|
|
|
1589
1582
|
*/
|
|
1590
1583
|
const NumberField = forwardRef((_a, ref) => {
|
|
1591
1584
|
var { label, tip, helpText, errorMessage, helpAddon, isInvalid, maxLength, className, value, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "errorMessage", "helpAddon", "isInvalid", "maxLength", "className", "value", "dataTestId"]);
|
|
1592
|
-
const renderAsInvalid = isInvalid
|
|
1593
|
-
return (jsx(FormGroup, Object.assign({ label: label, tip: tip, isInvalid: renderAsInvalid, helpText: errorMessage || helpText, helpAddon: helpAddon, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsx(NumberInput, Object.assign({ ref: ref, maxLength: maxLength, value: value, isInvalid: renderAsInvalid }, rest, { className: className, dataTestId: dataTestId })) })));
|
|
1585
|
+
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
1586
|
+
return (jsx(FormGroup, Object.assign({ label: label, tip: tip, isInvalid: renderAsInvalid, helpText: (renderAsInvalid && errorMessage) || helpText, helpAddon: helpAddon, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsx(NumberInput, Object.assign({ ref: ref, maxLength: maxLength, value: value, isInvalid: renderAsInvalid }, rest, { className: className, dataTestId: dataTestId })) })));
|
|
1594
1587
|
});
|
|
1595
1588
|
|
|
1596
1589
|
/**
|
|
@@ -2638,14 +2631,14 @@ const TextAreaField = React.forwardRef((_a, ref) => {
|
|
|
2638
2631
|
const TextField = React.forwardRef((_a, ref) => {
|
|
2639
2632
|
var { label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "helpAddon", "errorMessage", "isInvalid", "maxLength", "onChange", "className", "value", "dataTestId"]);
|
|
2640
2633
|
const [valueLength, setValueLength] = React.useState(value ? `${value}`.length : 0);
|
|
2641
|
-
const renderAsInvalid = isInvalid
|
|
2634
|
+
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
2642
2635
|
const handleChange = React.useCallback((event) => {
|
|
2643
2636
|
setValueLength(event.target.value.length);
|
|
2644
2637
|
if (onChange) {
|
|
2645
2638
|
onChange(event);
|
|
2646
2639
|
}
|
|
2647
2640
|
}, [onChange]);
|
|
2648
|
-
return (jsx(FormGroup, Object.assign({ label: label, tip: tip, isInvalid: renderAsInvalid, helpText: errorMessage || helpText, helpAddon: helpAddon ||
|
|
2641
|
+
return (jsx(FormGroup, Object.assign({ label: label, tip: tip, isInvalid: renderAsInvalid, helpText: (renderAsInvalid && errorMessage) || helpText, helpAddon: helpAddon ||
|
|
2649
2642
|
(maxLength !== null && maxLength !== undefined && (jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength }))), dataTestId: dataTestId && `${dataTestId}-FormGroup`, disabled: rest.readOnly }, { children: jsx(TextInput, Object.assign({ ref: ref, maxLength: maxLength, value: value, isInvalid: renderAsInvalid }, rest, { className: className, onChange: handleChange, dataTestId: dataTestId })) })));
|
|
2650
2643
|
});
|
|
2651
2644
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.45",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@trackunit/css-core": "0.0.
|
|
7
|
+
"@trackunit/css-core": "0.0.68",
|
|
8
8
|
"@trackunit/tailwind-styled-components": "0.0.52",
|
|
9
9
|
"react": "18.2.0",
|
|
10
|
-
"@trackunit/ui-design-tokens": "0.0.
|
|
10
|
+
"@trackunit/ui-design-tokens": "0.0.55",
|
|
11
11
|
"@trackunit/react-core-contexts-test": "0.1.24",
|
|
12
12
|
"echarts": "5.4.0",
|
|
13
13
|
"echarts-for-react": "3.0.2",
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ThemeColors } from "@trackunit/ui-design-tokens";
|
|
3
3
|
import { CommonProps } from "../../common/CommonProps";
|
|
4
|
+
type BadgeColors = Extract<ThemeColors, "primary" | "danger">;
|
|
4
5
|
interface BaseBadgeProps extends CommonProps {
|
|
5
6
|
/**
|
|
6
7
|
* The color of the badge.
|
|
7
8
|
*/
|
|
8
|
-
color?:
|
|
9
|
+
color?: BadgeColors;
|
|
9
10
|
/**
|
|
10
11
|
* Specifies whether the badge is subtle or not.
|
|
11
12
|
* Subtle badges have a light background color wither a darker text color.
|