@coveord/plasma-mantine 56.9.0 → 56.10.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/.turbo/turbo-build.log +4 -4
- package/.turbo/turbo-test.log +113 -107
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/components/InfoToken/InfoToken.d.ts +62 -2
- package/dist/cjs/components/InfoToken/InfoToken.d.ts.map +1 -1
- package/dist/cjs/components/InfoToken/InfoToken.js +5 -0
- package/dist/cjs/components/InfoToken/InfoToken.js.map +1 -1
- package/dist/cjs/components/StatusToken/StatusToken.d.ts +31 -0
- package/dist/cjs/components/StatusToken/StatusToken.d.ts.map +1 -0
- package/dist/cjs/components/StatusToken/StatusToken.js +128 -0
- package/dist/cjs/components/StatusToken/StatusToken.js.map +1 -0
- package/dist/cjs/components/StatusToken/StatusToken.module.css +42 -0
- package/dist/cjs/components/StatusToken/icons/circle.svg +3 -0
- package/dist/cjs/components/StatusToken/icons/info.svg +5 -0
- package/dist/cjs/components/StatusToken/icons/ring.svg +3 -0
- package/dist/cjs/components/StatusToken/icons/square.svg +3 -0
- package/dist/cjs/components/StatusToken/icons/triangle.svg +3 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/svg-raw/index.d.js +3 -0
- package/dist/cjs/types/svg-raw/index.d.js.map +1 -0
- package/dist/esm/components/InfoToken/InfoToken.d.ts +62 -2
- package/dist/esm/components/InfoToken/InfoToken.d.ts.map +1 -1
- package/dist/esm/components/InfoToken/InfoToken.js +5 -0
- package/dist/esm/components/InfoToken/InfoToken.js.map +1 -1
- package/dist/esm/components/StatusToken/StatusToken.d.ts +31 -0
- package/dist/esm/components/StatusToken/StatusToken.d.ts.map +1 -0
- package/dist/esm/components/StatusToken/StatusToken.js +103 -0
- package/dist/esm/components/StatusToken/StatusToken.js.map +1 -0
- package/dist/esm/components/StatusToken/StatusToken.module.css +42 -0
- package/dist/esm/components/StatusToken/icons/circle.svg +3 -0
- package/dist/esm/components/StatusToken/icons/info.svg +5 -0
- package/dist/esm/components/StatusToken/icons/ring.svg +3 -0
- package/dist/esm/components/StatusToken/icons/square.svg +3 -0
- package/dist/esm/components/StatusToken/icons/triangle.svg +3 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/svg-raw/index.d.js +2 -0
- package/dist/esm/types/svg-raw/index.d.js.map +1 -0
- package/package.json +1 -1
- package/src/components/InfoToken/InfoToken.tsx +39 -36
- package/src/components/StatusToken/StatusToken.module.css +42 -0
- package/src/components/StatusToken/StatusToken.tsx +152 -0
- package/src/components/StatusToken/__tests__/StatusToken.component.spec.tsx +28 -0
- package/src/components/StatusToken/icons/circle.svg +3 -0
- package/src/components/StatusToken/icons/info.svg +5 -0
- package/src/components/StatusToken/icons/ring.svg +3 -0
- package/src/components/StatusToken/icons/square.svg +3 -0
- package/src/components/StatusToken/icons/triangle.svg +3 -0
- package/src/index.ts +3 -0
- package/src/types/svg-raw/index.d.ts +4 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Box,
|
|
3
|
+
BoxProps,
|
|
4
|
+
createVarsResolver,
|
|
5
|
+
Factory,
|
|
6
|
+
getSize,
|
|
7
|
+
MantineSize,
|
|
8
|
+
MantineTheme,
|
|
9
|
+
polymorphicFactory,
|
|
10
|
+
StylesApiProps,
|
|
11
|
+
useProps,
|
|
12
|
+
useStyles,
|
|
13
|
+
} from '@mantine/core';
|
|
14
|
+
|
|
15
|
+
import Circle from './icons/circle.svg?raw';
|
|
16
|
+
import Ring from './icons/ring.svg?raw';
|
|
17
|
+
import Square from './icons/square.svg?raw';
|
|
18
|
+
import Triangle from './icons/triangle.svg?raw';
|
|
19
|
+
import Info from './icons/info.svg?raw';
|
|
20
|
+
import classes from './StatusToken.module.css';
|
|
21
|
+
|
|
22
|
+
export type StatusTokenFactory = Factory<{
|
|
23
|
+
props: StatusTokenProps;
|
|
24
|
+
defaultRef: HTMLDivElement;
|
|
25
|
+
defaultComponent: 'div';
|
|
26
|
+
stylesNames: StatusTokenComponentStylesNames;
|
|
27
|
+
vars: StatusTokenCssVariables;
|
|
28
|
+
variant: StatusTokenVariant;
|
|
29
|
+
}>;
|
|
30
|
+
export type StatusTokenComponentStylesNames = 'root';
|
|
31
|
+
export type StatusTokenVariant = 'info' | 'success' | 'caution' | 'error' | 'disabled' | 'waiting' | 'edited' | 'new';
|
|
32
|
+
export type StatusTokenSize = Extract<MantineSize, 'sm' | 'lg'>;
|
|
33
|
+
export type StatusTokenCssVariables = {
|
|
34
|
+
root: '--status-token-color' | '--status-token-size';
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export interface StatusTokenProps extends BoxProps, StylesApiProps<StatusTokenFactory> {
|
|
38
|
+
/**
|
|
39
|
+
* The size of the token.
|
|
40
|
+
*
|
|
41
|
+
* @default 'lg'
|
|
42
|
+
*/
|
|
43
|
+
size?: StatusTokenSize;
|
|
44
|
+
/**
|
|
45
|
+
* The variant of the token.
|
|
46
|
+
*
|
|
47
|
+
* @default 'info'
|
|
48
|
+
*/
|
|
49
|
+
variant?: StatusTokenVariant;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const defaultProps: Partial<StatusTokenProps> = {size: 'lg', variant: 'info'};
|
|
53
|
+
|
|
54
|
+
const resolveThemeColorFromVariant = (variant: StatusTokenVariant, theme: MantineTheme): string => {
|
|
55
|
+
switch (variant) {
|
|
56
|
+
case 'success':
|
|
57
|
+
return theme.colors.green[4];
|
|
58
|
+
case 'caution':
|
|
59
|
+
return theme.colors.yellow[4];
|
|
60
|
+
case 'error':
|
|
61
|
+
return theme.colors.red[5];
|
|
62
|
+
case 'disabled':
|
|
63
|
+
case 'waiting':
|
|
64
|
+
return theme.colors.gray[5];
|
|
65
|
+
case 'edited':
|
|
66
|
+
case 'new':
|
|
67
|
+
return 'var(--mantine-primary-color-filled)';
|
|
68
|
+
case 'info':
|
|
69
|
+
return theme.colors.gray[3];
|
|
70
|
+
default:
|
|
71
|
+
return theme.colors.navy[5];
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const resolveSize = (size: StatusTokenSize): number => (size === 'sm' ? 8 : 12);
|
|
75
|
+
|
|
76
|
+
const resolveIconSrcFromVariant = (variant: StatusTokenVariant): string => {
|
|
77
|
+
switch (variant) {
|
|
78
|
+
case 'caution':
|
|
79
|
+
return Triangle;
|
|
80
|
+
case 'error':
|
|
81
|
+
return Square;
|
|
82
|
+
case 'disabled':
|
|
83
|
+
return Ring;
|
|
84
|
+
case 'info':
|
|
85
|
+
return Info;
|
|
86
|
+
case 'success':
|
|
87
|
+
case 'waiting':
|
|
88
|
+
case 'edited':
|
|
89
|
+
case 'new':
|
|
90
|
+
default:
|
|
91
|
+
return Circle;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const varsResolver = createVarsResolver<StatusTokenFactory>((theme, {variant, size}) => {
|
|
96
|
+
const color = resolveThemeColorFromVariant(variant, theme);
|
|
97
|
+
return {
|
|
98
|
+
root: {
|
|
99
|
+
'--status-token-color': color,
|
|
100
|
+
'--status-token-size': getSize(resolveSize(size), 'status-token-size'),
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const statusTokenLabels: Record<StatusTokenVariant, string> = {
|
|
106
|
+
info: 'Info',
|
|
107
|
+
success: 'Success',
|
|
108
|
+
caution: 'Caution',
|
|
109
|
+
error: 'Error',
|
|
110
|
+
disabled: 'Disabled',
|
|
111
|
+
waiting: 'Waiting',
|
|
112
|
+
edited: 'Edited',
|
|
113
|
+
new: 'New',
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const StatusToken: ReturnType<typeof polymorphicFactory<StatusTokenFactory>> =
|
|
117
|
+
polymorphicFactory<StatusTokenFactory>((props, ref) => {
|
|
118
|
+
const {variant, vars, size, className, style, unstyled, styles, classNames, ...others} = useProps(
|
|
119
|
+
'StatusToken',
|
|
120
|
+
defaultProps,
|
|
121
|
+
props,
|
|
122
|
+
);
|
|
123
|
+
const getStyles = useStyles<StatusTokenFactory>({
|
|
124
|
+
name: 'StatusToken',
|
|
125
|
+
classes,
|
|
126
|
+
className,
|
|
127
|
+
props,
|
|
128
|
+
style,
|
|
129
|
+
styles,
|
|
130
|
+
unstyled,
|
|
131
|
+
vars,
|
|
132
|
+
varsResolver,
|
|
133
|
+
});
|
|
134
|
+
return (
|
|
135
|
+
<Box
|
|
136
|
+
ref={ref}
|
|
137
|
+
variant={variant}
|
|
138
|
+
role="img"
|
|
139
|
+
aria-label={statusTokenLabels[variant]}
|
|
140
|
+
{...getStyles('root', {
|
|
141
|
+
className,
|
|
142
|
+
style,
|
|
143
|
+
styles,
|
|
144
|
+
classNames,
|
|
145
|
+
})}
|
|
146
|
+
dangerouslySetInnerHTML={{__html: resolveIconSrcFromVariant(variant)}}
|
|
147
|
+
{...others}
|
|
148
|
+
/>
|
|
149
|
+
);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
StatusToken.displayName = 'StatusToken';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {render, screen} from '@test-utils';
|
|
2
|
+
import {StatusToken, type StatusTokenVariant} from '../StatusToken.js';
|
|
3
|
+
|
|
4
|
+
describe('StatusToken', () => {
|
|
5
|
+
it('renders with default props', () => {
|
|
6
|
+
render(<StatusToken data-testid="status-token" />);
|
|
7
|
+
expect(screen.getByTestId('status-token')).toHaveAttribute('data-variant', 'info');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('renders with custom size and variant', () => {
|
|
11
|
+
render(<StatusToken size="sm" data-testid="status-token" variant="success" />);
|
|
12
|
+
expect(screen.getByTestId('status-token')).toHaveAttribute('data-variant', 'success');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it.each<{variant: StatusTokenVariant; expected: string}>([
|
|
16
|
+
{variant: 'info', expected: 'Info'},
|
|
17
|
+
{variant: 'success', expected: 'Success'},
|
|
18
|
+
{variant: 'caution', expected: 'Caution'},
|
|
19
|
+
{variant: 'error', expected: 'Error'},
|
|
20
|
+
{variant: 'disabled', expected: 'Disabled'},
|
|
21
|
+
{variant: 'waiting', expected: 'Waiting'},
|
|
22
|
+
{variant: 'edited', expected: 'Edited'},
|
|
23
|
+
{variant: 'new', expected: 'New'},
|
|
24
|
+
])('is accessible for the $variant variant', ({variant, expected}) => {
|
|
25
|
+
render(<StatusToken variant={variant} />);
|
|
26
|
+
expect(screen.getByRole('img', {name: expected})).toBeVisible();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="12" height="13" viewBox="0 0 12 13" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path
|
|
3
|
+
d="M6 0.125C9.3138 0.125 12 2.81014 12 6.12263C12.0012 7.69729 11.3829 9.20927 10.2785 10.3321C9.17415 11.455 7.67229 12.0987 6.09721 12.1242C4.52214 12.1497 3.0002 11.555 1.86 10.4685C0.719794 9.38199 0.0527931 7.89082 0.00300007 6.31695L0 6.12263L0.00239997 5.95469C0.0912 2.72017 2.742 0.125 6 0.125ZM6 5.52286H5.4L5.3298 5.52706C5.18397 5.5444 5.04957 5.6146 4.95205 5.72436C4.85453 5.83413 4.80067 5.97583 4.80067 6.12263C4.80067 6.26943 4.85453 6.41113 4.95205 6.52089C5.04957 6.63065 5.18397 6.70085 5.3298 6.71819L5.4 6.72239V8.52168L5.4042 8.59185C5.41999 8.72573 5.48045 8.85038 5.57581 8.9457C5.67117 9.04103 5.79587 9.10145 5.9298 9.11724L6 9.12144H6.6L6.6702 9.11724C6.80413 9.10145 6.92883 9.04103 7.02419 8.9457C7.11955 8.85038 7.18 8.72573 7.1958 8.59185L7.2 8.52168L7.1958 8.45151C7.18146 8.32914 7.12976 8.21416 7.04774 8.1222C6.96573 8.03023 6.85737 7.96575 6.7374 7.93751L6.6702 7.92551L6.6 7.92192V6.12263L6.5958 6.05246C6.58 5.91858 6.51955 5.79392 6.42419 5.6986C6.32883 5.60328 6.20413 5.54285 6.0702 5.52706L6 5.52286ZM6.006 3.72358L5.9298 3.72777C5.78397 3.74511 5.64957 3.81531 5.55205 3.92508C5.45453 4.03484 5.40067 4.17654 5.40067 4.32334C5.40067 4.47014 5.45453 4.61184 5.55205 4.7216C5.64957 4.83136 5.78397 4.90156 5.9298 4.9189L6 4.9231L6.0762 4.9189C6.22203 4.90156 6.35643 4.83136 6.45395 4.7216C6.55147 4.61184 6.60533 4.47014 6.60533 4.32334C6.60533 4.17654 6.55147 4.03484 6.45395 3.92508C6.35643 3.81531 6.22203 3.74511 6.0762 3.72777L6.006 3.72358Z"
|
|
4
|
+
fill="currentColor" />
|
|
5
|
+
</svg>
|
package/src/index.ts
CHANGED
|
@@ -86,6 +86,9 @@ export {
|
|
|
86
86
|
// Info Token
|
|
87
87
|
export * from './components/InfoToken/InfoToken.js';
|
|
88
88
|
|
|
89
|
+
// Status Token
|
|
90
|
+
export * from './components/StatusToken/StatusToken.js';
|
|
91
|
+
|
|
89
92
|
// Inline Confirm
|
|
90
93
|
export * from './components/InlineConfirm/InlineConfirm.js';
|
|
91
94
|
export * from './components/InlineConfirm/InlineConfirmContext.js';
|