@taiv/ui 2.1.0 → 2.1.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/components/Data/Cards/StatsCard/StatsCard.d.ts +3 -2
- package/dist/components/Data/Cards/StatsCard/StatsCard.d.ts.map +1 -1
- package/dist/components/Data/Cards/StatsCard/StatsCard.js +13 -6
- package/dist/components/Info/Notifications/Notifications.stories.d.ts.map +1 -1
- package/dist/components/Info/Notifications/Notifications.stories.js +5 -3
- package/dist/components/Info/Notifications/variants.d.ts +12 -0
- package/dist/components/Info/Notifications/variants.d.ts.map +1 -1
- package/dist/components/Info/Notifications/variants.js +12 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CardProps } from '../../../Layout/Card/Card';
|
|
3
3
|
import { primitives } from '../../../../constants/colors';
|
|
4
|
-
import { formats } from '../../../../constants/data';
|
|
4
|
+
import { formats, truncation } from '../../../../constants/data';
|
|
5
5
|
export interface StatsCardProps extends Omit<CardProps, 'children'> {
|
|
6
6
|
value: number;
|
|
7
7
|
title: string;
|
|
@@ -12,6 +12,7 @@ export interface StatsCardProps extends Omit<CardProps, 'children'> {
|
|
|
12
12
|
iconColor?: keyof typeof primitives;
|
|
13
13
|
tooltip?: React.ReactNode;
|
|
14
14
|
increaseDescription?: string;
|
|
15
|
+
truncateAt?: keyof typeof truncation;
|
|
15
16
|
}
|
|
16
|
-
export declare const StatsCard: ({ value, format, isDelta, title, description, increaseDescription, icon: Icon, iconColor, tooltip, ...cardProps }: StatsCardProps) => React.JSX.Element;
|
|
17
|
+
export declare const StatsCard: ({ value, format, isDelta, title, description, increaseDescription, icon: Icon, iconColor, tooltip, truncateAt, ...cardProps }: StatsCardProps) => React.JSX.Element;
|
|
17
18
|
//# sourceMappingURL=StatsCard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatsCard.d.ts","sourceRoot":"","sources":["../../../../../src/components/Data/Cards/StatsCard/StatsCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAQ,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAO5D,OAAO,EAAE,UAAU,EAAoB,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"StatsCard.d.ts","sourceRoot":"","sources":["../../../../../src/components/Data/Cards/StatsCard/StatsCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAQ,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAO5D,OAAO,EAAE,UAAU,EAAoB,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAGjE,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC;IACjE,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,OAAO,OAAO,CAAC;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,OAAO,UAAU,CAAC;IACpC,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,OAAO,UAAU,CAAC;CACtC;AAED,eAAO,MAAM,SAAS,GAAI,+HAA4J,cAAc,sBAmEnM,CAAC"}
|
|
@@ -7,9 +7,9 @@ import { Group } from '../../../Layout/Group/Group';
|
|
|
7
7
|
import { Stack } from '../../../Layout/Stack/Stack';
|
|
8
8
|
import { IconBadge } from '../../../Misc/IconBadge/IconBadge';
|
|
9
9
|
import { success, neutral } from '../../../../constants/colors';
|
|
10
|
-
import { formats } from '../../../../constants/data';
|
|
10
|
+
import { formats, truncation } from '../../../../constants/data';
|
|
11
11
|
import { spacing } from '../../../../constants/spacing';
|
|
12
|
-
export const StatsCard = ({ value, format = 'decimal', isDelta = false, title, description, increaseDescription, icon: Icon, iconColor = 'blue', tooltip, ...cardProps }) => {
|
|
12
|
+
export const StatsCard = ({ value, format = 'decimal', isDelta = false, title, description, increaseDescription, icon: Icon, iconColor = 'blue', tooltip, truncateAt, ...cardProps }) => {
|
|
13
13
|
const getDelta = () => {
|
|
14
14
|
const currentDirection = isDelta ? (value > 0 ? 'positive' : value < 0 ? 'negative' : null) : null;
|
|
15
15
|
return {
|
|
@@ -21,10 +21,17 @@ export const StatsCard = ({ value, format = 'decimal', isDelta = false, title, d
|
|
|
21
21
|
const delta = getDelta();
|
|
22
22
|
const formatValue = () => {
|
|
23
23
|
const config = formats[format];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
let formattedNumber;
|
|
25
|
+
if (truncateAt && value >= truncation[truncateAt].threshold) {
|
|
26
|
+
const truncConfig = truncation[truncateAt];
|
|
27
|
+
formattedNumber = `${(value / truncConfig.threshold).toFixed(1)}${truncConfig.suffix}`;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
formattedNumber = value.toLocaleString('en-US', {
|
|
31
|
+
minimumFractionDigits: config.decimalPlaces,
|
|
32
|
+
maximumFractionDigits: config.decimalPlaces,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
28
35
|
let result = formattedNumber;
|
|
29
36
|
if (delta.direction === 'positive') {
|
|
30
37
|
result = `+${result}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Notifications.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/Info/Notifications/Notifications.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AAMnF,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,oBAAoB,
|
|
1
|
+
{"version":3,"file":"Notifications.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/Info/Notifications/Notifications.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AAMnF,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,oBAAoB,CA0C3C,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAqBnC,eAAO,MAAM,OAAO,EAAE,KAQrB,CAAC;AAkBF,eAAO,MAAM,QAAQ,EAAE,KAEtB,CAAC;AAQF,eAAO,MAAM,YAAY,EAAE,KAE1B,CAAC;AAyCF,eAAO,MAAM,kBAAkB,EAAE,KAEhC,CAAC;AAiDF,eAAO,MAAM,qBAAqB,EAAE,KAEnC,CAAC"}
|
|
@@ -15,10 +15,12 @@ const meta = {
|
|
|
15
15
|
argTypes: {
|
|
16
16
|
variant: {
|
|
17
17
|
control: { type: 'select' },
|
|
18
|
-
options: ['success', 'error', 'warning', 'info', 'copy'],
|
|
18
|
+
options: ['success', 'error', 'warning', 'info', 'copy', 'lock', 'unlock'],
|
|
19
19
|
description: 'Visual style and icon of the notification',
|
|
20
20
|
table: {
|
|
21
|
-
type: {
|
|
21
|
+
type: {
|
|
22
|
+
summary: "'success' | 'error' | 'warning' | 'info' | 'copy' | 'lock' | 'unlock'",
|
|
23
|
+
},
|
|
22
24
|
defaultValue: { summary: "'info'" },
|
|
23
25
|
},
|
|
24
26
|
},
|
|
@@ -66,7 +68,7 @@ export const Default = {
|
|
|
66
68
|
};
|
|
67
69
|
const VariantsDemo = () => {
|
|
68
70
|
const { show } = useNotifications();
|
|
69
|
-
return (_jsxs(Group, { gap: spacing.xs, children: [_jsx(Button, { variant: "success", onClick: () => show({ variant: 'success', message: 'Operation completed successfully!' }), children: "Success" }), _jsx(Button, { variant: "cancel", onClick: () => show({ variant: 'error', message: 'Something went wrong!' }), children: "Error" }), _jsx(Button, { variant: "warning", onClick: () => show({ variant: 'warning', message: 'Please review your input' }), children: "Warning" }), _jsx(Button, { variant: "primary", onClick: () => show({ variant: 'info', message: 'Here is some useful information' }), children: "Info" }), _jsx(Button, { variant: "secondary", onClick: () => show({ variant: 'copy', message: 'Copied to clipboard!' }), children: "Copy" })] }));
|
|
71
|
+
return (_jsxs(Group, { gap: spacing.xs, children: [_jsx(Button, { variant: "success", onClick: () => show({ variant: 'success', message: 'Operation completed successfully!' }), children: "Success" }), _jsx(Button, { variant: "cancel", onClick: () => show({ variant: 'error', message: 'Something went wrong!' }), children: "Error" }), _jsx(Button, { variant: "warning", onClick: () => show({ variant: 'warning', message: 'Please review your input' }), children: "Warning" }), _jsx(Button, { variant: "primary", onClick: () => show({ variant: 'info', message: 'Here is some useful information' }), children: "Info" }), _jsx(Button, { variant: "secondary", onClick: () => show({ variant: 'copy', message: 'Copied to clipboard!' }), children: "Copy" }), _jsx(Button, { variant: "warning", onClick: () => show({ variant: 'lock', message: 'Bar TV 3 is now locked to Demo Mode. It won\'t follow your automations until you unlock it.' }), children: "Lock" }), _jsx(Button, { variant: "success", onClick: () => show({ variant: 'unlock', message: 'Bar TV 3 will now follow your venue\'s default mode and automations.' }), children: "Unlock" })] }));
|
|
70
72
|
};
|
|
71
73
|
export const Variants = {
|
|
72
74
|
render: () => _jsx(VariantsDemo, {}),
|
|
@@ -42,5 +42,17 @@ export declare const componentVariants: {
|
|
|
42
42
|
readonly defaultTitle: "Warning";
|
|
43
43
|
readonly icon: React.JSX.Element;
|
|
44
44
|
};
|
|
45
|
+
readonly lock: {
|
|
46
|
+
readonly autoClose: 4000;
|
|
47
|
+
readonly color: "#FE9A00";
|
|
48
|
+
readonly defaultTitle: "Locked";
|
|
49
|
+
readonly icon: React.JSX.Element;
|
|
50
|
+
};
|
|
51
|
+
readonly unlock: {
|
|
52
|
+
readonly autoClose: 4000;
|
|
53
|
+
readonly color: "#00A84F";
|
|
54
|
+
readonly defaultTitle: "Unlocked";
|
|
55
|
+
readonly icon: React.JSX.Element;
|
|
56
|
+
};
|
|
45
57
|
};
|
|
46
58
|
//# sourceMappingURL=variants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../../src/components/Info/Notifications/variants.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../../src/components/Info/Notifications/variants.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8DpB,CAAC"}
|
|
@@ -44,4 +44,16 @@ export const componentVariants = {
|
|
|
44
44
|
defaultTitle: 'Warning',
|
|
45
45
|
icon: (_jsx("i", { className: 'fas fa-exclamation-triangle', style: { color: warning[100] } })),
|
|
46
46
|
},
|
|
47
|
+
lock: {
|
|
48
|
+
autoClose: 4000,
|
|
49
|
+
color: warning[100],
|
|
50
|
+
defaultTitle: 'Locked',
|
|
51
|
+
icon: _jsx("i", { className: 'fas fa-lock', style: { color: warning[100] } }),
|
|
52
|
+
},
|
|
53
|
+
unlock: {
|
|
54
|
+
autoClose: 4000,
|
|
55
|
+
color: success[300],
|
|
56
|
+
defaultTitle: 'Unlocked',
|
|
57
|
+
icon: _jsx("i", { className: 'fas fa-lock-open', style: { color: success[300] } }),
|
|
58
|
+
},
|
|
47
59
|
};
|
package/package.json
CHANGED