@coveord/plasma-mantine 56.5.0 → 56.8.1
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 +107 -105
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/components/Badge/Badge.d.ts.map +1 -1
- package/dist/cjs/components/Badge/Badge.js +10 -8
- package/dist/cjs/components/Badge/Badge.js.map +1 -1
- package/dist/cjs/components/CodeEditor/languages/xml.d.ts.map +1 -1
- package/dist/cjs/components/CodeEditor/languages/xml.js.map +1 -1
- package/dist/cjs/components/Collection/enhanceWithCollectionProps.d.ts.map +1 -1
- package/dist/cjs/components/Collection/enhanceWithCollectionProps.js.map +1 -1
- package/dist/cjs/components/DateRangePicker/DateRange.module.css +4 -0
- package/dist/cjs/components/DateRangePicker/DateRangePicker.d.ts.map +1 -1
- package/dist/cjs/components/DateRangePicker/DateRangePicker.js +2 -1
- package/dist/cjs/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/cjs/components/RadioCard/RadioCard.d.ts +26 -0
- package/dist/cjs/components/RadioCard/RadioCard.d.ts.map +1 -0
- package/dist/cjs/components/RadioCard/RadioCard.js +82 -0
- package/dist/cjs/components/RadioCard/RadioCard.js.map +1 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/styles/RadioCard.module.css +44 -0
- package/dist/cjs/theme/Plasmantine.d.ts +1 -1
- package/dist/cjs/theme/Plasmantine.d.ts.map +1 -1
- package/dist/cjs/theme/Plasmantine.js +2 -2
- package/dist/cjs/theme/Plasmantine.js.map +1 -1
- package/dist/esm/components/Badge/Badge.d.ts.map +1 -1
- package/dist/esm/components/Badge/Badge.js +11 -7
- package/dist/esm/components/Badge/Badge.js.map +1 -1
- package/dist/esm/components/CodeEditor/languages/xml.d.ts.map +1 -1
- package/dist/esm/components/CodeEditor/languages/xml.js.map +1 -1
- package/dist/esm/components/Collection/enhanceWithCollectionProps.d.ts.map +1 -1
- package/dist/esm/components/Collection/enhanceWithCollectionProps.js.map +1 -1
- package/dist/esm/components/DateRangePicker/DateRange.module.css +4 -0
- package/dist/esm/components/DateRangePicker/DateRangePicker.d.ts.map +1 -1
- package/dist/esm/components/DateRangePicker/DateRangePicker.js +2 -1
- package/dist/esm/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/esm/components/RadioCard/RadioCard.d.ts +26 -0
- package/dist/esm/components/RadioCard/RadioCard.d.ts.map +1 -0
- package/dist/esm/components/RadioCard/RadioCard.js +63 -0
- package/dist/esm/components/RadioCard/RadioCard.js.map +1 -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/styles/RadioCard.module.css +44 -0
- package/dist/esm/theme/Plasmantine.d.ts +1 -1
- package/dist/esm/theme/Plasmantine.d.ts.map +1 -1
- package/dist/esm/theme/Plasmantine.js +2 -2
- package/dist/esm/theme/Plasmantine.js.map +1 -1
- package/package.json +19 -19
- package/src/components/Badge/Badge.tsx +12 -2
- package/src/components/CodeEditor/languages/xml.ts +2 -1
- package/src/components/Collection/enhanceWithCollectionProps.ts +2 -2
- package/src/components/DateRangePicker/DateRange.module.css +4 -0
- package/src/components/DateRangePicker/DateRangePicker.tsx +2 -1
- package/src/components/RadioCard/RadioCard.tsx +73 -0
- package/src/components/RadioCard/__tests__/RadioCard.component.spec.tsx +25 -0
- package/src/index.ts +3 -0
- package/src/styles/RadioCard.module.css +44 -0
- package/src/theme/Plasmantine.tsx +3 -3
|
@@ -60,8 +60,9 @@ export type SemanticBadge = ForwardRefExoticComponent<SemanticBadgeProps & RefAt
|
|
|
60
60
|
const enhanceBadge = (
|
|
61
61
|
ComponentLight: <L = 'div'>(props: PolymorphicComponentProps<L, BadgeProps>) => ReactElement,
|
|
62
62
|
ComponentDark: <L = 'div'>(props: PolymorphicComponentProps<L, BadgeProps>) => ReactElement,
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
displayName: string,
|
|
64
|
+
): SemanticBadge => {
|
|
65
|
+
const EnhancedBadge = forwardRef<HTMLDivElement, SemanticBadgeProps>((props, ref) => {
|
|
65
66
|
const computedColorScheme = useComputedColorScheme('light', {getInitialValueInEffect: true});
|
|
66
67
|
const Component = (props.on || computedColorScheme) === 'dark' ? ComponentDark : ComponentLight;
|
|
67
68
|
return (
|
|
@@ -75,6 +76,9 @@ const enhanceBadge = (
|
|
|
75
76
|
/>
|
|
76
77
|
);
|
|
77
78
|
});
|
|
79
|
+
EnhancedBadge.displayName = displayName;
|
|
80
|
+
return EnhancedBadge;
|
|
81
|
+
};
|
|
78
82
|
|
|
79
83
|
const BadgePrimary = enhanceBadge(
|
|
80
84
|
MantineBadge.withProps({
|
|
@@ -88,6 +92,7 @@ const BadgePrimary = enhanceBadge(
|
|
|
88
92
|
c: 'var(--mantine-primary-color-2)',
|
|
89
93
|
bg: alpha('var(--mantine-primary-color-3)', 0.32),
|
|
90
94
|
}),
|
|
95
|
+
'Badge.Primary',
|
|
91
96
|
);
|
|
92
97
|
const BadgeSecondary = enhanceBadge(
|
|
93
98
|
MantineBadge.withProps({
|
|
@@ -103,6 +108,7 @@ const BadgeSecondary = enhanceBadge(
|
|
|
103
108
|
bd: `1px solid ${alpha('var(--mantine-color-gray-3)', 0.16)}`,
|
|
104
109
|
bg: alpha('var(--mantine-color-gray-3)', 0.16),
|
|
105
110
|
}),
|
|
111
|
+
'Badge.Secondary',
|
|
106
112
|
);
|
|
107
113
|
const BadgeSuccess = enhanceBadge(
|
|
108
114
|
MantineBadge.withProps({
|
|
@@ -118,6 +124,7 @@ const BadgeSuccess = enhanceBadge(
|
|
|
118
124
|
bd: `1px solid ${alpha('var(--mantine-color-green-3)', 0.16)}`,
|
|
119
125
|
bg: alpha('var(--mantine-color-green-3)', 0.16),
|
|
120
126
|
}),
|
|
127
|
+
'Badge.Success',
|
|
121
128
|
);
|
|
122
129
|
const BadgeCritical = enhanceBadge(
|
|
123
130
|
MantineBadge.withProps({
|
|
@@ -133,6 +140,7 @@ const BadgeCritical = enhanceBadge(
|
|
|
133
140
|
bd: `1px solid ${alpha('var(--mantine-color-red-3)', 0.16)}`,
|
|
134
141
|
bg: alpha('var(--mantine-color-red-3)', 0.16),
|
|
135
142
|
}),
|
|
143
|
+
'Badge.Critical',
|
|
136
144
|
);
|
|
137
145
|
const BadgeWarning = enhanceBadge(
|
|
138
146
|
MantineBadge.withProps({
|
|
@@ -148,6 +156,7 @@ const BadgeWarning = enhanceBadge(
|
|
|
148
156
|
bd: `1px solid ${alpha('var(--mantine-color-yellow-3)', 0.16)}`,
|
|
149
157
|
bg: alpha('var(--mantine-color-yellow-3)', 0.16),
|
|
150
158
|
}),
|
|
159
|
+
'Badge.Warning',
|
|
151
160
|
);
|
|
152
161
|
const BadgeDisabled = enhanceBadge(
|
|
153
162
|
MantineBadge.withProps({
|
|
@@ -162,6 +171,7 @@ const BadgeDisabled = enhanceBadge(
|
|
|
162
171
|
c: 'dark.3',
|
|
163
172
|
bg: alpha('var(--mantine-color-gray-3)', 0.16),
|
|
164
173
|
}),
|
|
174
|
+
'Badge.Disabled',
|
|
165
175
|
);
|
|
166
176
|
|
|
167
177
|
export type BadgeOverloadFactory = PolymorphicFactory<{
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {Monaco} from '@monaco-editor/react';
|
|
2
|
+
import type {editor} from 'monaco-editor';
|
|
2
3
|
|
|
3
4
|
const format = (xml: string): string => {
|
|
4
5
|
// https://stackoverflow.com/questions/57039218/doesnt-monaco-editor-support-xml-language-by-default
|
|
@@ -31,7 +32,7 @@ const format = (xml: string): string => {
|
|
|
31
32
|
|
|
32
33
|
const register = (monaco: Monaco): void => {
|
|
33
34
|
monaco.languages.registerDocumentFormattingEditProvider('xml', {
|
|
34
|
-
provideDocumentFormattingEdits: async (model) => [
|
|
35
|
+
provideDocumentFormattingEdits: async (model: editor.ITextModel) => [
|
|
35
36
|
{
|
|
36
37
|
range: model.getFullModelRange(),
|
|
37
38
|
text: format(model.getValue()),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {UseFormInput} from '@mantine/form';
|
|
1
|
+
import {UseFormInput, type FormArrayElement} from '@mantine/form';
|
|
2
2
|
import {CollectionProps} from './Collection.js';
|
|
3
3
|
|
|
4
4
|
export const enhanceWithCollectionProps = <
|
|
@@ -20,7 +20,7 @@ export const enhanceWithCollectionProps = <
|
|
|
20
20
|
payload.form.removeListItem(field, index);
|
|
21
21
|
validateInputOnChange && payload.form.validate();
|
|
22
22
|
},
|
|
23
|
-
onInsertItem: (valueToInsert:
|
|
23
|
+
onInsertItem: (valueToInsert: FormArrayElement<FormValues, (typeof payload)['field']>, index: number) => {
|
|
24
24
|
payload.form.insertListItem(field, valueToInsert, index);
|
|
25
25
|
validateInputOnChange && payload.form.validate();
|
|
26
26
|
},
|
|
@@ -14,6 +14,7 @@ import {DatesRangeValue, DateStringValue} from '@mantine/dates';
|
|
|
14
14
|
import {useUncontrolled} from '@mantine/hooks';
|
|
15
15
|
import dayjs from 'dayjs';
|
|
16
16
|
import {useUrlSyncedState, UseUrlSyncedStateOptions} from '../../hooks/use-url-synced-state';
|
|
17
|
+
import classes from './DateRange.module.css';
|
|
17
18
|
import {DateRangePickerInlineCalendar, DateRangePickerInlineCalendarProps} from './DateRangePickerInlineCalendar';
|
|
18
19
|
|
|
19
20
|
const serialization = (input: Pick<UseUrlSyncedStateOptions<DatesRangeValue<string>>, 'serializer' | 'deserializer'>) =>
|
|
@@ -123,7 +124,7 @@ export const DateRangePicker = factory<DateRangePickerFactory>((props: DateRange
|
|
|
123
124
|
|
|
124
125
|
const getStyles = useStyles<DateRangePickerFactory>({
|
|
125
126
|
name: 'DateRangePicker',
|
|
126
|
-
classes
|
|
127
|
+
classes,
|
|
127
128
|
props,
|
|
128
129
|
className,
|
|
129
130
|
classNames,
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Box,
|
|
3
|
+
Factory,
|
|
4
|
+
Group,
|
|
5
|
+
RadioCardProps as MantineRadioCardProps,
|
|
6
|
+
RadioCardStylesNames as MantineRadioCardStylesNames,
|
|
7
|
+
Radio,
|
|
8
|
+
RadioCardCssVariables,
|
|
9
|
+
StylesApiProps,
|
|
10
|
+
Title,
|
|
11
|
+
factory,
|
|
12
|
+
useProps,
|
|
13
|
+
useStyles,
|
|
14
|
+
} from '@mantine/core';
|
|
15
|
+
import {ReactNode} from 'react';
|
|
16
|
+
import classes from '../../styles/RadioCard.module.css';
|
|
17
|
+
|
|
18
|
+
export type RadioCardStylesNames = MantineRadioCardStylesNames | 'container' | 'indicator' | 'title' | 'description';
|
|
19
|
+
export type RadioCardFactory = Factory<{
|
|
20
|
+
props: RadioCardProps;
|
|
21
|
+
ref: HTMLButtonElement;
|
|
22
|
+
stylesNames: RadioCardStylesNames;
|
|
23
|
+
vars: RadioCardCssVariables;
|
|
24
|
+
}>;
|
|
25
|
+
|
|
26
|
+
export type RadioCardProps = MantineRadioCardProps &
|
|
27
|
+
StylesApiProps<RadioCardFactory> & {
|
|
28
|
+
/**
|
|
29
|
+
* The label of the card. Appears next to the radio indicator.
|
|
30
|
+
*/
|
|
31
|
+
label: ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* The description of the card. Appears under the title.
|
|
34
|
+
*/
|
|
35
|
+
description?: ReactNode;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const defaultProps: Partial<RadioCardProps> = {};
|
|
39
|
+
|
|
40
|
+
export const RadioCard = factory<RadioCardFactory>((_props, ref) => {
|
|
41
|
+
const {classNames, styles, style, className, vars, disabled, label, description, ...others} = useProps(
|
|
42
|
+
'RadioCard',
|
|
43
|
+
defaultProps,
|
|
44
|
+
_props,
|
|
45
|
+
);
|
|
46
|
+
const getStyles = useStyles<RadioCardFactory>({
|
|
47
|
+
name: 'RadioCard',
|
|
48
|
+
classes,
|
|
49
|
+
vars,
|
|
50
|
+
classNames,
|
|
51
|
+
className,
|
|
52
|
+
style,
|
|
53
|
+
props: _props,
|
|
54
|
+
styles,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<Radio.Card
|
|
59
|
+
ref={ref}
|
|
60
|
+
disabled={disabled}
|
|
61
|
+
{...getStyles('card', {className, style, classNames, styles})}
|
|
62
|
+
{...others}
|
|
63
|
+
>
|
|
64
|
+
<Group {...getStyles('container', {classNames, styles})}>
|
|
65
|
+
<Radio.Indicator size="xs" disabled={disabled} {...getStyles('indicator', {classNames, styles})} />
|
|
66
|
+
<Title order={4} {...getStyles('title', {classNames, styles})}>
|
|
67
|
+
{label}
|
|
68
|
+
</Title>
|
|
69
|
+
</Group>
|
|
70
|
+
{description && <Box {...getStyles('description', {classNames, styles})}>{description}</Box>}
|
|
71
|
+
</Radio.Card>
|
|
72
|
+
);
|
|
73
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {render, screen} from '@test-utils';
|
|
2
|
+
import {RadioCard} from '../RadioCard.js';
|
|
3
|
+
|
|
4
|
+
describe('RadioCard', () => {
|
|
5
|
+
it('renders the title and description correctly', () => {
|
|
6
|
+
const title = 'Test Title';
|
|
7
|
+
const description = 'Test Description';
|
|
8
|
+
|
|
9
|
+
render(<RadioCard label={title} description={description} />);
|
|
10
|
+
|
|
11
|
+
expect(screen.getByText(title)).toBeInTheDocument();
|
|
12
|
+
expect(screen.getByText(description)).toBeInTheDocument();
|
|
13
|
+
});
|
|
14
|
+
it('renders the radio indicator correctly', () => {
|
|
15
|
+
render(<RadioCard label="Test Title" />);
|
|
16
|
+
|
|
17
|
+
expect(screen.getByRole('radio')).not.toBeDisabled();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('renders disabled state correctly', () => {
|
|
21
|
+
render(<RadioCard label="Test Title" disabled />);
|
|
22
|
+
|
|
23
|
+
expect(screen.getByRole('radio')).toBeDisabled();
|
|
24
|
+
});
|
|
25
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -106,6 +106,9 @@ export * from './components/Modal/ModalFooter.js';
|
|
|
106
106
|
// Prompt
|
|
107
107
|
export * from './components/Prompt/Prompt.js';
|
|
108
108
|
|
|
109
|
+
// RadioCard - override Mantine RadioCard
|
|
110
|
+
export {RadioCard, type RadioCardProps} from './components/RadioCard/RadioCard.js';
|
|
111
|
+
|
|
109
112
|
// Read Only - override Mantine PasswordInput and Select
|
|
110
113
|
export {PasswordInput} from './components/PasswordInput/PasswordInput.js';
|
|
111
114
|
export {Select} from './components/Select/Select.js';
|
|
@@ -5,7 +5,51 @@
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
.card {
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
align-items: flex-start;
|
|
11
|
+
padding: var(--mantine-spacing-sm);
|
|
12
|
+
border-radius: var(--mantine-radius-lg);
|
|
13
|
+
|
|
14
|
+
&[data-checked] {
|
|
15
|
+
border-color: var(--mantine-primary-color-filled);
|
|
16
|
+
}
|
|
17
|
+
|
|
8
18
|
&[disabled] {
|
|
9
19
|
pointer-events: none;
|
|
20
|
+
|
|
21
|
+
.title {
|
|
22
|
+
color: var(--mantine-color-disabled-color);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.description {
|
|
26
|
+
color: var(--mantine-color-disabled-color);
|
|
27
|
+
}
|
|
10
28
|
}
|
|
11
29
|
}
|
|
30
|
+
|
|
31
|
+
.container {
|
|
32
|
+
flex-wrap: nowrap;
|
|
33
|
+
gap: var(--mantine-spacing-sm);
|
|
34
|
+
align-items: baseline;
|
|
35
|
+
justify-content: flex-start;
|
|
36
|
+
width: 100%;
|
|
37
|
+
margin-bottom: var(--mantine-spacing-xs);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.title {
|
|
41
|
+
flex: 1;
|
|
42
|
+
color: var(--coveo-color-title);
|
|
43
|
+
word-break: break-word;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.description {
|
|
47
|
+
padding-left: var(--mantine-spacing-lg);
|
|
48
|
+
color: var(--mantine-color-dimmed);
|
|
49
|
+
font-weight: 400;
|
|
50
|
+
font-size: var(--mantine-font-size-xs);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.indicator {
|
|
54
|
+
cursor: pointer;
|
|
55
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import '../styles/global.css';
|
|
2
|
+
|
|
1
3
|
import {MantineProvider, MantineProviderProps, mergeThemeOverrides} from '@mantine/core';
|
|
2
4
|
import {FunctionComponent} from 'react';
|
|
3
|
-
|
|
5
|
+
import {mergeCSSVariablesResolvers} from './mergeCSSVariablesResolvers.js';
|
|
4
6
|
import {plasmaCSSVariablesResolver} from './plasmaCSSVariablesResolver.js';
|
|
5
7
|
import {plasmaTheme} from './Theme.js';
|
|
6
|
-
import {mergeCSSVariablesResolvers} from './mergeCSSVariablesResolvers.js';
|
|
7
|
-
import '../styles/global.css';
|
|
8
8
|
|
|
9
9
|
export const Plasmantine: FunctionComponent<MantineProviderProps> = ({
|
|
10
10
|
children,
|