@coveord/plasma-mantine 57.1.0 → 58.0.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 +106 -102
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/components/ActionIcon/ActionIcon.d.ts +3 -3
- package/dist/cjs/components/Alert/Alert.d.ts +3 -3
- package/dist/cjs/components/Alert/Alert.js +4 -12
- package/dist/cjs/components/Alert/Alert.js.map +1 -1
- package/dist/cjs/components/AppShell/AppShell.d.ts +8 -1
- package/dist/cjs/components/AppShell/AppShell.d.ts.map +1 -1
- package/dist/cjs/components/AppShell/AppShell.js +27 -1
- package/dist/cjs/components/AppShell/AppShell.js.map +1 -1
- package/dist/cjs/components/AppShell/AppShell.module.css +4 -0
- package/dist/cjs/components/Badge/Badge.d.ts +3 -3
- package/dist/cjs/components/BrowserPreview/BrowserPreview.d.ts +1 -1
- package/dist/cjs/components/BrowserPreview/BrowserPreview.d.ts.map +1 -1
- package/dist/cjs/components/BrowserPreview/BrowserPreview.js +1 -2
- package/dist/cjs/components/BrowserPreview/BrowserPreview.js.map +1 -1
- package/dist/cjs/components/Button/Button.d.ts +3 -3
- package/dist/cjs/components/ChildForm/ChildForm.d.ts +5 -4
- package/dist/cjs/components/ChildForm/ChildForm.d.ts.map +1 -1
- package/dist/cjs/components/ChildForm/ChildForm.js +4 -2
- package/dist/cjs/components/ChildForm/ChildForm.js.map +1 -1
- package/dist/cjs/components/Collection/Collection.d.ts +6 -6
- package/dist/cjs/components/Collection/CollectionAddButton.d.ts +1 -1
- package/dist/cjs/components/Collection/CollectionAddButton.d.ts.map +1 -1
- package/dist/cjs/components/Collection/CollectionContext.d.ts +1 -1
- package/dist/cjs/components/Collection/CollectionContext.d.ts.map +1 -1
- package/dist/cjs/components/Collection/layouts/CollectionLayouts.d.ts +5 -5
- package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayout.d.ts +3 -3
- package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.d.ts +1 -1
- package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.d.ts.map +1 -1
- package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.d.ts +1 -1
- package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.d.ts.map +1 -1
- package/dist/cjs/components/Collection/layouts/shared/itemRenderer.d.ts +3 -3
- package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayout.d.ts +2 -2
- package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayoutBody.d.ts +1 -1
- package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayoutBody.d.ts.map +1 -1
- package/dist/cjs/components/DateRangePicker/DateRangePickerInlineCalendar.d.ts +1 -1
- package/dist/cjs/components/DateRangePicker/DateRangePickerInlineCalendar.d.ts.map +1 -1
- package/dist/cjs/components/DateRangePicker/DateRangePickerPopoverCalendar.d.ts +1 -1
- package/dist/cjs/components/DateRangePicker/DateRangePickerPopoverCalendar.d.ts.map +1 -1
- package/dist/cjs/components/DateTimeRangePicker/DateTimeRangePicker.d.ts +1 -1
- package/dist/cjs/components/DateTimeRangePicker/DateTimeRangePicker.d.ts.map +1 -1
- package/dist/cjs/components/EllipsisText/EllipsisText.d.ts +3 -3
- package/dist/cjs/components/Header/Header.context.d.ts +1 -1
- package/dist/cjs/components/Header/Header.context.d.ts.map +1 -1
- package/dist/cjs/components/Header/Header.module.css +0 -5
- package/dist/cjs/components/Header/HeaderBreadcrumbs/HeaderBreadcrumbAnchor.d.ts +3 -3
- package/dist/cjs/components/Header/HeaderBreadcrumbs/HeaderBreadcrumbText.d.ts +3 -3
- package/dist/cjs/components/Header/HeaderDocAnchor/HeaderDocAnchor.js +2 -4
- package/dist/cjs/components/Header/HeaderDocAnchor/HeaderDocAnchor.js.map +1 -1
- package/dist/cjs/components/InfoToken/InfoToken.d.ts +26 -82
- package/dist/cjs/components/InfoToken/InfoToken.d.ts.map +1 -1
- package/dist/cjs/components/InfoToken/InfoToken.js +62 -55
- package/dist/cjs/components/InfoToken/InfoToken.js.map +1 -1
- package/dist/cjs/components/InfoToken/InfoToken.module.css +11 -3
- package/dist/cjs/components/InlineConfirm/InlineConfirmTarget.d.ts +3 -3
- package/dist/cjs/components/Input/Input.d.ts +14 -1
- package/dist/cjs/components/Input/Input.d.ts.map +1 -1
- package/dist/cjs/components/Input/Input.js +17 -5
- package/dist/cjs/components/Input/Input.js.map +1 -1
- package/dist/cjs/components/Input/InputLabelInfo.d.ts +17 -0
- package/dist/cjs/components/Input/InputLabelInfo.d.ts.map +1 -0
- package/dist/cjs/components/Input/InputLabelInfo.js +58 -0
- package/dist/cjs/components/Input/InputLabelInfo.js.map +1 -0
- package/dist/cjs/components/Input/InputLabelInfo.module.css +5 -0
- package/dist/cjs/components/Menu/Menu.d.ts +1 -1
- package/dist/cjs/components/Modal/Modal.js +1 -1
- package/dist/cjs/components/Modal/Modal.js.map +1 -1
- package/dist/cjs/components/Modal/ModalFooter.js +2 -0
- package/dist/cjs/components/Modal/ModalFooter.js.map +1 -1
- package/dist/cjs/components/Modal/ModalFooter.module.css +2 -2
- package/dist/cjs/components/Prompt/Prompt.context.d.ts +1 -1
- package/dist/cjs/components/Prompt/Prompt.context.d.ts.map +1 -1
- package/dist/cjs/components/Prompt/Prompt.d.ts +33 -33
- package/dist/cjs/components/Prompt/Prompt.d.ts.map +1 -1
- package/dist/cjs/components/Prompt/Prompt.js +38 -18
- package/dist/cjs/components/Prompt/Prompt.js.map +1 -1
- package/dist/cjs/components/Prompt/Prompt.module.css +0 -17
- package/dist/cjs/components/Prompt/PromptCancelButton.d.ts.map +1 -1
- package/dist/cjs/components/Prompt/PromptCancelButton.js +1 -0
- package/dist/cjs/components/Prompt/PromptCancelButton.js.map +1 -1
- package/dist/cjs/components/Prompt/PromptConfirmButton.d.ts.map +1 -1
- package/dist/cjs/components/Prompt/PromptConfirmButton.js +2 -1
- package/dist/cjs/components/Prompt/PromptConfirmButton.js.map +1 -1
- package/dist/cjs/components/StickyFooter/StickyFooter.js +1 -1
- package/dist/cjs/components/StickyFooter/StickyFooter.js.map +1 -1
- package/dist/cjs/components/Table/Table.d.ts +4 -4
- package/dist/cjs/components/Table/layouts/TableLayoutControl.d.ts +1 -1
- package/dist/cjs/components/Table/layouts/TableLayoutControl.d.ts.map +1 -1
- package/dist/cjs/components/Table/layouts/row-layout/RowLayoutBody.d.ts +1 -1
- package/dist/cjs/components/Table/layouts/row-layout/RowLayoutContext.d.ts +1 -1
- package/dist/cjs/components/Table/layouts/row-layout/RowLayoutContext.d.ts.map +1 -1
- package/dist/cjs/components/Table/layouts/row-layout/RowLayoutHeader.d.ts +1 -1
- package/dist/cjs/components/Table/table-actions/TableActionItem.d.ts +3 -3
- package/dist/cjs/components/Table/table-actions/TableActionsList.d.ts +2 -2
- package/dist/cjs/components/Table/table-header/Th.d.ts +1 -1
- package/dist/cjs/index.d.ts +3 -3
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +7 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/styles/AppShell.module.css +4 -0
- package/dist/cjs/styles/Breadcrumbs.module.css +0 -4
- package/dist/cjs/styles/Checkbox.module.css +0 -1
- package/dist/cjs/styles/InputWrapper.module.css +0 -4
- package/dist/cjs/styles/NavLink.module.css +0 -2
- package/dist/cjs/styles/Radio.module.css +0 -1
- package/dist/cjs/styles/RadioCard.module.css +0 -1
- package/dist/cjs/styles/Select.module.css +0 -2
- package/dist/cjs/styles/Tabs.module.css +2 -2
- package/dist/cjs/theme/Theme.d.ts.map +1 -1
- package/dist/cjs/theme/Theme.js +15 -4
- package/dist/cjs/theme/Theme.js.map +1 -1
- package/dist/cjs/theme/plasmaCSSVariablesResolver.d.ts.map +1 -1
- package/dist/cjs/theme/plasmaCSSVariablesResolver.js +3 -6
- package/dist/cjs/theme/plasmaCSSVariablesResolver.js.map +1 -1
- package/dist/esm/components/ActionIcon/ActionIcon.d.ts +3 -3
- package/dist/esm/components/Alert/Alert.d.ts +3 -3
- package/dist/esm/components/Alert/Alert.js +4 -12
- package/dist/esm/components/Alert/Alert.js.map +1 -1
- package/dist/esm/components/AppShell/AppShell.d.ts +8 -1
- package/dist/esm/components/AppShell/AppShell.d.ts.map +1 -1
- package/dist/esm/components/AppShell/AppShell.js +15 -3
- package/dist/esm/components/AppShell/AppShell.js.map +1 -1
- package/dist/esm/components/AppShell/AppShell.module.css +4 -0
- package/dist/esm/components/Badge/Badge.d.ts +3 -3
- package/dist/esm/components/BrowserPreview/BrowserPreview.js +1 -2
- package/dist/esm/components/BrowserPreview/BrowserPreview.js.map +1 -1
- package/dist/esm/components/Button/Button.d.ts +3 -3
- package/dist/esm/components/ChildForm/ChildForm.d.ts +5 -4
- package/dist/esm/components/ChildForm/ChildForm.d.ts.map +1 -1
- package/dist/esm/components/ChildForm/ChildForm.js +4 -2
- package/dist/esm/components/ChildForm/ChildForm.js.map +1 -1
- package/dist/esm/components/EllipsisText/EllipsisText.d.ts +3 -3
- package/dist/esm/components/Header/Header.module.css +0 -5
- package/dist/esm/components/Header/HeaderBreadcrumbs/HeaderBreadcrumbAnchor.d.ts +3 -3
- package/dist/esm/components/Header/HeaderBreadcrumbs/HeaderBreadcrumbText.d.ts +3 -3
- package/dist/esm/components/Header/HeaderDocAnchor/HeaderDocAnchor.js +2 -4
- package/dist/esm/components/Header/HeaderDocAnchor/HeaderDocAnchor.js.map +1 -1
- package/dist/esm/components/InfoToken/InfoToken.d.ts +26 -82
- package/dist/esm/components/InfoToken/InfoToken.d.ts.map +1 -1
- package/dist/esm/components/InfoToken/InfoToken.js +61 -57
- package/dist/esm/components/InfoToken/InfoToken.js.map +1 -1
- package/dist/esm/components/InfoToken/InfoToken.module.css +11 -3
- package/dist/esm/components/InlineConfirm/InlineConfirmTarget.d.ts +3 -3
- package/dist/esm/components/Input/Input.d.ts +14 -1
- package/dist/esm/components/Input/Input.d.ts.map +1 -1
- package/dist/esm/components/Input/Input.js +7 -2
- package/dist/esm/components/Input/Input.js.map +1 -1
- package/dist/esm/components/Input/InputLabelInfo.d.ts +17 -0
- package/dist/esm/components/Input/InputLabelInfo.d.ts.map +1 -0
- package/dist/esm/components/Input/InputLabelInfo.js +35 -0
- package/dist/esm/components/Input/InputLabelInfo.js.map +1 -0
- package/dist/esm/components/Input/InputLabelInfo.module.css +5 -0
- package/dist/esm/components/Modal/Modal.js +1 -1
- package/dist/esm/components/Modal/Modal.js.map +1 -1
- package/dist/esm/components/Modal/ModalFooter.js +2 -0
- package/dist/esm/components/Modal/ModalFooter.js.map +1 -1
- package/dist/esm/components/Modal/ModalFooter.module.css +2 -2
- package/dist/esm/components/Prompt/Prompt.d.ts +33 -33
- package/dist/esm/components/Prompt/Prompt.d.ts.map +1 -1
- package/dist/esm/components/Prompt/Prompt.js +38 -19
- package/dist/esm/components/Prompt/Prompt.js.map +1 -1
- package/dist/esm/components/Prompt/Prompt.module.css +0 -17
- package/dist/esm/components/Prompt/PromptCancelButton.d.ts.map +1 -1
- package/dist/esm/components/Prompt/PromptCancelButton.js +1 -0
- package/dist/esm/components/Prompt/PromptCancelButton.js.map +1 -1
- package/dist/esm/components/Prompt/PromptConfirmButton.d.ts.map +1 -1
- package/dist/esm/components/Prompt/PromptConfirmButton.js +2 -1
- package/dist/esm/components/Prompt/PromptConfirmButton.js.map +1 -1
- package/dist/esm/components/StickyFooter/StickyFooter.js +1 -1
- package/dist/esm/components/StickyFooter/StickyFooter.js.map +1 -1
- package/dist/esm/components/Table/Table.d.ts +3 -3
- package/dist/esm/components/Table/table-actions/TableActionItem.d.ts +3 -3
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/styles/AppShell.module.css +4 -0
- package/dist/esm/styles/Breadcrumbs.module.css +0 -4
- package/dist/esm/styles/Checkbox.module.css +0 -1
- package/dist/esm/styles/InputWrapper.module.css +0 -4
- package/dist/esm/styles/NavLink.module.css +0 -2
- package/dist/esm/styles/Radio.module.css +0 -1
- package/dist/esm/styles/RadioCard.module.css +0 -1
- package/dist/esm/styles/Select.module.css +0 -2
- package/dist/esm/styles/Tabs.module.css +2 -2
- package/dist/esm/theme/Theme.d.ts.map +1 -1
- package/dist/esm/theme/Theme.js +15 -4
- package/dist/esm/theme/Theme.js.map +1 -1
- package/dist/esm/theme/plasmaCSSVariablesResolver.d.ts.map +1 -1
- package/dist/esm/theme/plasmaCSSVariablesResolver.js +3 -6
- package/dist/esm/theme/plasmaCSSVariablesResolver.js.map +1 -1
- package/package.json +23 -23
- package/src/components/Alert/Alert.tsx +4 -4
- package/src/components/AppShell/AppShell.module.css +4 -0
- package/src/components/AppShell/AppShell.tsx +27 -0
- package/src/components/BrowserPreview/BrowserPreview.tsx +1 -1
- package/src/components/ChildForm/ChildForm.tsx +10 -3
- package/src/components/ChildForm/__tests__/ChildForm.spec.tsx +29 -4
- package/src/components/Header/Header.module.css +0 -5
- package/src/components/Header/HeaderDocAnchor/HeaderDocAnchor.tsx +2 -2
- package/src/components/InfoToken/InfoToken.module.css +11 -3
- package/src/components/InfoToken/InfoToken.tsx +83 -67
- package/src/components/Input/Input.ts +24 -2
- package/src/components/Input/InputLabelInfo.module.css +5 -0
- package/src/components/Input/InputLabelInfo.tsx +43 -0
- package/src/components/Input/__tests__/Input.spec.tsx +33 -0
- package/src/components/Modal/Modal.tsx +1 -1
- package/src/components/Modal/ModalFooter.module.css +2 -2
- package/src/components/Modal/ModalFooter.tsx +3 -1
- package/src/components/Prompt/Prompt.module.css +0 -17
- package/src/components/Prompt/Prompt.tsx +48 -34
- package/src/components/Prompt/PromptCancelButton.tsx +3 -1
- package/src/components/Prompt/PromptConfirmButton.tsx +4 -2
- package/src/components/Prompt/__tests__/Prompt.spec.tsx +18 -16
- package/src/components/StickyFooter/StickyFooter.tsx +1 -1
- package/src/components/Switch/__tests__/Switch.spec.tsx +27 -0
- package/src/index.ts +12 -4
- package/src/styles/AppShell.module.css +4 -0
- package/src/styles/Breadcrumbs.module.css +0 -4
- package/src/styles/Checkbox.module.css +0 -1
- package/src/styles/InputWrapper.module.css +0 -4
- package/src/styles/NavLink.module.css +0 -2
- package/src/styles/Radio.module.css +0 -1
- package/src/styles/RadioCard.module.css +0 -1
- package/src/styles/Select.module.css +0 -2
- package/src/styles/Tabs.module.css +2 -2
- package/src/theme/Theme.tsx +10 -2
- package/src/theme/__tests__/plasmaCSSVariablesResolver.spec.ts +3 -6
- package/src/theme/plasmaCSSVariablesResolver.ts +3 -6
- package/dist/cjs/components/Prompt/icons/CriticalIcon.d.ts +0 -3
- package/dist/cjs/components/Prompt/icons/CriticalIcon.d.ts.map +0 -1
- package/dist/cjs/components/Prompt/icons/CriticalIcon.js +0 -29
- package/dist/cjs/components/Prompt/icons/CriticalIcon.js.map +0 -1
- package/dist/cjs/components/Prompt/icons/InfoIcon.d.ts +0 -3
- package/dist/cjs/components/Prompt/icons/InfoIcon.d.ts.map +0 -1
- package/dist/cjs/components/Prompt/icons/InfoIcon.js +0 -29
- package/dist/cjs/components/Prompt/icons/InfoIcon.js.map +0 -1
- package/dist/cjs/components/Prompt/icons/SuccessIcon.d.ts +0 -3
- package/dist/cjs/components/Prompt/icons/SuccessIcon.d.ts.map +0 -1
- package/dist/cjs/components/Prompt/icons/SuccessIcon.js +0 -29
- package/dist/cjs/components/Prompt/icons/SuccessIcon.js.map +0 -1
- package/dist/cjs/components/Prompt/icons/WarningIcon.d.ts +0 -3
- package/dist/cjs/components/Prompt/icons/WarningIcon.d.ts.map +0 -1
- package/dist/cjs/components/Prompt/icons/WarningIcon.js +0 -29
- package/dist/cjs/components/Prompt/icons/WarningIcon.js.map +0 -1
- package/dist/esm/components/Prompt/icons/CriticalIcon.d.ts +0 -3
- package/dist/esm/components/Prompt/icons/CriticalIcon.d.ts.map +0 -1
- package/dist/esm/components/Prompt/icons/CriticalIcon.js +0 -17
- package/dist/esm/components/Prompt/icons/CriticalIcon.js.map +0 -1
- package/dist/esm/components/Prompt/icons/InfoIcon.d.ts +0 -3
- package/dist/esm/components/Prompt/icons/InfoIcon.d.ts.map +0 -1
- package/dist/esm/components/Prompt/icons/InfoIcon.js +0 -17
- package/dist/esm/components/Prompt/icons/InfoIcon.js.map +0 -1
- package/dist/esm/components/Prompt/icons/SuccessIcon.d.ts +0 -3
- package/dist/esm/components/Prompt/icons/SuccessIcon.d.ts.map +0 -1
- package/dist/esm/components/Prompt/icons/SuccessIcon.js +0 -17
- package/dist/esm/components/Prompt/icons/SuccessIcon.js.map +0 -1
- package/dist/esm/components/Prompt/icons/WarningIcon.d.ts +0 -3
- package/dist/esm/components/Prompt/icons/WarningIcon.d.ts.map +0 -1
- package/dist/esm/components/Prompt/icons/WarningIcon.js +0 -17
- package/dist/esm/components/Prompt/icons/WarningIcon.js.map +0 -1
- package/src/components/AppShell/AppShell.ts +0 -11
- package/src/components/Prompt/icons/CriticalIcon.tsx +0 -18
- package/src/components/Prompt/icons/InfoIcon.tsx +0 -18
- package/src/components/Prompt/icons/SuccessIcon.tsx +0 -17
- package/src/components/Prompt/icons/WarningIcon.tsx +0 -18
|
@@ -3,12 +3,37 @@ import {render, screen} from '../../../__tests__/Utils.js';
|
|
|
3
3
|
import {ChildForm} from '../ChildForm.js';
|
|
4
4
|
|
|
5
5
|
describe('ChildForm', () => {
|
|
6
|
-
it('renders the provided title and description',
|
|
6
|
+
it('renders the provided title and description', () => {
|
|
7
7
|
render(<ChildForm in={true} title="This is a title" description="This is a description" />);
|
|
8
8
|
|
|
9
|
-
expect(screen.getByText(/this is a title/i)).
|
|
10
|
-
expect(screen.getByText(/this is a description/i)).
|
|
9
|
+
expect(screen.getByText(/this is a title/i)).toBeVisible();
|
|
10
|
+
expect(screen.getByText(/this is a description/i)).toBeVisible();
|
|
11
11
|
});
|
|
12
|
+
|
|
13
|
+
it('renders a rich description node', () => {
|
|
14
|
+
render(
|
|
15
|
+
<ChildForm
|
|
16
|
+
in={true}
|
|
17
|
+
title="This is a title"
|
|
18
|
+
description={
|
|
19
|
+
<div>
|
|
20
|
+
<span>Rich description</span>
|
|
21
|
+
<a href="https://example.com">Learn more</a>
|
|
22
|
+
</div>
|
|
23
|
+
}
|
|
24
|
+
/>,
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
expect(screen.getByText('Rich description')).toBeVisible();
|
|
28
|
+
expect(screen.getByRole('link', {name: 'Learn more'})).toBeVisible();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('renders a numeric description', () => {
|
|
32
|
+
render(<ChildForm in={true} description={0} />);
|
|
33
|
+
|
|
34
|
+
expect(screen.getByText('0')).toBeInTheDocument();
|
|
35
|
+
});
|
|
36
|
+
|
|
12
37
|
it('renders the content', () => {
|
|
13
38
|
render(
|
|
14
39
|
<ChildForm in={true}>
|
|
@@ -16,7 +41,7 @@ describe('ChildForm', () => {
|
|
|
16
41
|
</ChildForm>,
|
|
17
42
|
);
|
|
18
43
|
|
|
19
|
-
expect(screen.getByRole('textbox', {name: /text input/i})).
|
|
44
|
+
expect(screen.getByRole('textbox', {name: /text input/i})).toBeVisible();
|
|
20
45
|
});
|
|
21
46
|
it('hides the container', () => {
|
|
22
47
|
render(
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
useProps,
|
|
10
10
|
} from '@mantine/core';
|
|
11
11
|
import {ReactNode} from 'react';
|
|
12
|
-
import {useHeaderContext} from '../Header.context.js';
|
|
13
12
|
import {InfoToken} from '../../InfoToken/InfoToken.js';
|
|
13
|
+
import {useHeaderContext} from '../Header.context.js';
|
|
14
14
|
|
|
15
15
|
export type HeaderDocAnchorStyleNames = 'docAnchorTooltip' | 'docAnchor';
|
|
16
16
|
|
|
@@ -43,7 +43,7 @@ export type HeaderDocAnchorFactory = Factory<{
|
|
|
43
43
|
|
|
44
44
|
const defaultProps: Partial<HeaderDocAnchorProps> = {
|
|
45
45
|
position: 'right',
|
|
46
|
-
children: <InfoToken
|
|
46
|
+
children: <InfoToken.Question />,
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
export const HeaderDocAnchor = factory<HeaderDocAnchorFactory>((_props, ref) => {
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
.root {
|
|
2
|
-
--info-token-color: var(--mantine-color-primary);
|
|
3
|
-
|
|
4
2
|
display: inline-flex;
|
|
5
3
|
flex-shrink: 0;
|
|
6
4
|
align-items: center;
|
|
7
|
-
color: var(--
|
|
5
|
+
color: var(--it-color);
|
|
6
|
+
|
|
7
|
+
&[data-variant='light'] {
|
|
8
|
+
background-color: var(--it-bg);
|
|
9
|
+
border-radius: var(--mantine-spacing-xxs);
|
|
10
|
+
padding: var(--mantine-spacing-xs);
|
|
11
|
+
|
|
12
|
+
&[data-size='xs'] {
|
|
13
|
+
padding: var(--mantine-spacing-xxs);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
8
16
|
}
|
|
@@ -1,83 +1,106 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
IconAlertSquare,
|
|
3
|
+
IconAlertTriangle,
|
|
4
|
+
IconBulb,
|
|
5
|
+
IconCheck,
|
|
5
6
|
IconHelpCircle,
|
|
6
7
|
IconInfoCircle,
|
|
7
|
-
IconInfoCircleFilled,
|
|
8
8
|
TablerIcon,
|
|
9
9
|
} from '@coveord/plasma-react-icons';
|
|
10
10
|
import {
|
|
11
11
|
Box,
|
|
12
12
|
BoxProps,
|
|
13
|
+
createPolymorphicComponent,
|
|
13
14
|
createVarsResolver,
|
|
14
15
|
Factory,
|
|
15
|
-
|
|
16
|
+
PolymorphicComponentProps,
|
|
16
17
|
polymorphicFactory,
|
|
17
18
|
StylesApiProps,
|
|
18
19
|
useProps,
|
|
19
20
|
useStyles,
|
|
20
21
|
} from '@mantine/core';
|
|
22
|
+
import {forwardRef, FunctionComponent, ReactElement} from 'react';
|
|
21
23
|
import classes from './InfoToken.module.css';
|
|
22
24
|
|
|
23
25
|
export type InfoTokenFactory = Factory<{
|
|
24
|
-
props:
|
|
26
|
+
props: InfoTokenInternalProps;
|
|
25
27
|
defaultRef: HTMLDivElement;
|
|
26
28
|
defaultComponent: 'div';
|
|
27
29
|
stylesNames: InfoTokenComponentStylesNames;
|
|
28
30
|
vars: InfoTokenCssVariables;
|
|
29
31
|
variant: InfoTokenVariant;
|
|
30
|
-
staticComponents: {
|
|
31
|
-
Information: typeof TokenInformation;
|
|
32
|
-
InformationOutline: typeof TokenInformationOutline;
|
|
33
|
-
Advice: typeof TokenAdvice;
|
|
34
|
-
Warning: typeof TokenWarning;
|
|
35
|
-
Error: typeof TokenError;
|
|
36
|
-
Question: typeof TokenQuestion;
|
|
37
|
-
};
|
|
38
32
|
}>;
|
|
39
33
|
export type InfoTokenComponentStylesNames = 'root';
|
|
40
|
-
export type
|
|
34
|
+
export type InfoTokenType = 'information' | 'advice' | 'warning' | 'error' | 'question' | 'success';
|
|
35
|
+
export type InfoTokenVariant = 'outline' | 'light';
|
|
36
|
+
export type InfoTokenSizes = 'xs' | 'sm' | 'md' | 'lg';
|
|
41
37
|
export type InfoTokenCssVariables = {
|
|
42
|
-
root: '--
|
|
38
|
+
root: '--it-color' | '--it-bg';
|
|
43
39
|
};
|
|
44
40
|
|
|
45
|
-
|
|
41
|
+
interface InfoTokenInternalProps extends BoxProps, StylesApiProps<InfoTokenFactory> {
|
|
46
42
|
/**
|
|
47
43
|
* The variant of the token.
|
|
48
44
|
*
|
|
49
|
-
* @default '
|
|
45
|
+
* @default 'outline'
|
|
50
46
|
*/
|
|
51
47
|
variant?: InfoTokenVariant;
|
|
48
|
+
/**
|
|
49
|
+
* The semantic type of the token
|
|
50
|
+
*
|
|
51
|
+
* @default 'information'
|
|
52
|
+
*/
|
|
53
|
+
type?: InfoTokenType;
|
|
52
54
|
/**
|
|
53
55
|
* The size of the info token.
|
|
54
56
|
*
|
|
55
|
-
* @default '
|
|
57
|
+
* @default 'xs'
|
|
56
58
|
*/
|
|
57
|
-
size?:
|
|
59
|
+
size?: InfoTokenSizes;
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
|
|
62
|
+
export type InfoTokenProps = Omit<InfoTokenInternalProps, 'type'>;
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
type InfoTokenCompoundComponent = (<C = 'div'>(props: PolymorphicComponentProps<C, InfoTokenProps>) => ReactElement) &
|
|
65
|
+
Omit<FunctionComponent<PolymorphicComponentProps<any, InfoTokenProps>>, never>;
|
|
66
|
+
|
|
67
|
+
const defaultProps: Partial<InfoTokenInternalProps> = {variant: 'outline', type: 'information', size: 'xs'};
|
|
68
|
+
|
|
69
|
+
const colorResolver = (type: InfoTokenType): string => {
|
|
70
|
+
switch (type) {
|
|
64
71
|
case 'error':
|
|
65
72
|
return 'var(--mantine-color-error)';
|
|
66
73
|
case 'advice':
|
|
67
74
|
case 'question':
|
|
68
75
|
return 'var(--coveo-color-text-primary)';
|
|
69
76
|
case 'warning':
|
|
70
|
-
return 'var(--mantine-color-
|
|
77
|
+
return 'var(--mantine-color-yellow-text)';
|
|
78
|
+
case 'success':
|
|
79
|
+
return 'var(--mantine-color-green-text)';
|
|
71
80
|
case 'information':
|
|
72
81
|
default:
|
|
73
|
-
return 'var(--mantine-color-gray-
|
|
82
|
+
return 'var(--mantine-color-gray-text)';
|
|
74
83
|
}
|
|
75
84
|
};
|
|
76
85
|
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
86
|
+
const bgColorResolver = (type: InfoTokenType): string => {
|
|
87
|
+
switch (type) {
|
|
88
|
+
case 'error':
|
|
89
|
+
return 'var(--mantine-color-red-light)';
|
|
90
|
+
case 'advice':
|
|
91
|
+
case 'question':
|
|
92
|
+
return 'var(--mantine-primary-color-light)';
|
|
93
|
+
case 'warning':
|
|
94
|
+
return 'var(--mantine-color-yellow-light)';
|
|
95
|
+
case 'success':
|
|
96
|
+
return 'var(--mantine-color-green-light)';
|
|
97
|
+
case 'information':
|
|
98
|
+
default:
|
|
99
|
+
return 'var(--mantine-color-gray-light)';
|
|
80
100
|
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const sizeResolver = (size: InfoTokenSizes): number => {
|
|
81
104
|
switch (size) {
|
|
82
105
|
case 'sm':
|
|
83
106
|
return 20;
|
|
@@ -85,44 +108,43 @@ const sizeResolver = (size: MantineSize): number => {
|
|
|
85
108
|
return 24;
|
|
86
109
|
case 'lg':
|
|
87
110
|
return 32;
|
|
88
|
-
case 'xl':
|
|
89
|
-
return 40;
|
|
90
111
|
case 'xs':
|
|
91
112
|
default:
|
|
92
113
|
return 16;
|
|
93
114
|
}
|
|
94
115
|
};
|
|
95
116
|
|
|
96
|
-
const iconResolver = (
|
|
97
|
-
switch (
|
|
117
|
+
const iconResolver = (type: InfoTokenType): TablerIcon => {
|
|
118
|
+
switch (type) {
|
|
98
119
|
case 'error':
|
|
99
|
-
return
|
|
100
|
-
case 'information':
|
|
101
|
-
return IconInfoCircleFilled;
|
|
102
|
-
case 'information-outline':
|
|
103
|
-
return IconInfoCircle;
|
|
120
|
+
return IconAlertSquare;
|
|
104
121
|
case 'question':
|
|
105
122
|
return IconHelpCircle;
|
|
106
123
|
case 'warning':
|
|
107
|
-
return
|
|
124
|
+
return IconAlertTriangle;
|
|
108
125
|
case 'advice':
|
|
126
|
+
return IconBulb;
|
|
127
|
+
case 'success':
|
|
128
|
+
return IconCheck;
|
|
109
129
|
default:
|
|
110
|
-
return
|
|
130
|
+
return IconInfoCircle;
|
|
111
131
|
}
|
|
112
132
|
};
|
|
113
133
|
|
|
114
|
-
const varsResolver = createVarsResolver<InfoTokenFactory>((_theme, {
|
|
115
|
-
const color = colorResolver(
|
|
134
|
+
const varsResolver = createVarsResolver<InfoTokenFactory>((_theme, {type}) => {
|
|
135
|
+
const color = colorResolver(type);
|
|
136
|
+
const bgColor = bgColorResolver(type);
|
|
116
137
|
return {
|
|
117
138
|
root: {
|
|
118
|
-
'--
|
|
139
|
+
'--it-color': color,
|
|
140
|
+
'--it-bg': bgColor,
|
|
119
141
|
},
|
|
120
142
|
};
|
|
121
143
|
});
|
|
122
144
|
|
|
123
|
-
|
|
145
|
+
const _InfoToken = polymorphicFactory<InfoTokenFactory>((_props, ref) => {
|
|
124
146
|
const props = useProps('InfoToken', defaultProps, _props);
|
|
125
|
-
const {variant, vars, className, style, unstyled, styles, classNames, size, ...others} = props;
|
|
147
|
+
const {variant, type, vars, className, style, unstyled, styles, classNames, size, ...others} = props;
|
|
126
148
|
const getStyles = useStyles<InfoTokenFactory>({
|
|
127
149
|
name: 'InfoToken',
|
|
128
150
|
classes,
|
|
@@ -134,13 +156,13 @@ export const InfoToken = polymorphicFactory<InfoTokenFactory>((_props, ref) => {
|
|
|
134
156
|
vars,
|
|
135
157
|
varsResolver,
|
|
136
158
|
});
|
|
137
|
-
const IconComponent = iconResolver(
|
|
159
|
+
const IconComponent = iconResolver(type);
|
|
138
160
|
return (
|
|
139
161
|
<Box
|
|
140
162
|
ref={ref}
|
|
141
163
|
variant={variant}
|
|
142
164
|
role="img"
|
|
143
|
-
aria-label={
|
|
165
|
+
aria-label={type}
|
|
144
166
|
size={size}
|
|
145
167
|
{...getStyles('root', {
|
|
146
168
|
className,
|
|
@@ -155,25 +177,19 @@ export const InfoToken = polymorphicFactory<InfoTokenFactory>((_props, ref) => {
|
|
|
155
177
|
);
|
|
156
178
|
});
|
|
157
179
|
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
const TokenAdvice = InfoToken.withProps({variant: 'advice'});
|
|
166
|
-
(TokenAdvice as typeof InfoToken).displayName = 'InfoToken.Advice';
|
|
167
|
-
const TokenWarning = InfoToken.withProps({variant: 'warning'});
|
|
168
|
-
(TokenWarning as typeof InfoToken).displayName = 'InfoToken.Warning';
|
|
169
|
-
const TokenError = InfoToken.withProps({variant: 'error'});
|
|
170
|
-
(TokenError as typeof InfoToken).displayName = 'InfoToken.Error';
|
|
171
|
-
const TokenQuestion = InfoToken.withProps({variant: 'question'});
|
|
172
|
-
(TokenQuestion as typeof InfoToken).displayName = 'InfoToken.Question';
|
|
180
|
+
const createInfoTokenCompound = (type: InfoTokenType, displayName: string): InfoTokenCompoundComponent => {
|
|
181
|
+
const Component: InfoTokenCompoundComponent = createPolymorphicComponent<'div', InfoTokenProps>(
|
|
182
|
+
forwardRef<any, InfoTokenProps>((props, ref) => <_InfoToken ref={ref} {...props} type={type} />),
|
|
183
|
+
);
|
|
184
|
+
Component.displayName = displayName;
|
|
185
|
+
return Component;
|
|
186
|
+
};
|
|
173
187
|
|
|
174
|
-
InfoToken
|
|
175
|
-
InfoToken.
|
|
176
|
-
InfoToken.Advice
|
|
177
|
-
InfoToken.Warning
|
|
178
|
-
InfoToken.Error
|
|
179
|
-
InfoToken.Question
|
|
188
|
+
export const InfoToken = {
|
|
189
|
+
Information: createInfoTokenCompound('information', 'InfoToken.Information'),
|
|
190
|
+
Advice: createInfoTokenCompound('advice', 'InfoToken.Advice'),
|
|
191
|
+
Warning: createInfoTokenCompound('warning', 'InfoToken.Warning'),
|
|
192
|
+
Error: createInfoTokenCompound('error', 'InfoToken.Error'),
|
|
193
|
+
Question: createInfoTokenCompound('question', 'InfoToken.Question'),
|
|
194
|
+
Success: createInfoTokenCompound('success', 'InfoToken.Success'),
|
|
195
|
+
} as const;
|
|
@@ -1,5 +1,27 @@
|
|
|
1
|
-
import {Input} from '@mantine/core';
|
|
1
|
+
import {Input as MantineInput, type InputFactory as MantineInputFactory, type InputProps} from '@mantine/core';
|
|
2
|
+
import {
|
|
3
|
+
InputLabelInfo,
|
|
4
|
+
type InputLabelInfoFactory,
|
|
5
|
+
type InputLabelInfoProps,
|
|
6
|
+
type InputLabelInfoStylesNames,
|
|
7
|
+
} from './InputLabelInfo.js';
|
|
8
|
+
|
|
9
|
+
type PlasmaInputFactory = Omit<MantineInputFactory, 'staticComponents'> & {
|
|
10
|
+
staticComponents: MantineInputFactory['staticComponents'] & {
|
|
11
|
+
LabelInfo: typeof InputLabelInfo;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const Input = MantineInput as typeof MantineInput & {
|
|
16
|
+
LabelInfo: typeof InputLabelInfo;
|
|
17
|
+
};
|
|
2
18
|
|
|
3
19
|
Input.displayName = 'Input';
|
|
20
|
+
Input.LabelInfo = InputLabelInfo;
|
|
21
|
+
|
|
22
|
+
InputLabelInfo.displayName = 'Input.LabelInfo';
|
|
4
23
|
|
|
5
|
-
export {Input
|
|
24
|
+
export {Input};
|
|
25
|
+
export type InputFactory = PlasmaInputFactory;
|
|
26
|
+
export type {InputProps, InputLabelInfoFactory, InputLabelInfoProps, InputLabelInfoStylesNames};
|
|
27
|
+
export {InputLabelInfo};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {factory, StylesApiProps, Tooltip, useProps, useStyles, type Factory, type TooltipProps} from '@mantine/core';
|
|
2
|
+
import {type ReactNode} from 'react';
|
|
3
|
+
import {InfoToken} from '../InfoToken/InfoToken.js';
|
|
4
|
+
import classes from './InputLabelInfo.module.css';
|
|
5
|
+
|
|
6
|
+
export type InputLabelInfoStylesNames = 'labelInfo';
|
|
7
|
+
|
|
8
|
+
export interface InputLabelInfoProps
|
|
9
|
+
extends
|
|
10
|
+
Omit<TooltipProps, 'label' | 'classNames' | 'attributes' | 'styles' | 'vars'>,
|
|
11
|
+
StylesApiProps<InputLabelInfoFactory> {
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type InputLabelInfoFactory = Factory<{
|
|
16
|
+
props: InputLabelInfoProps;
|
|
17
|
+
ref: HTMLSpanElement;
|
|
18
|
+
stylesNames: InputLabelInfoStylesNames;
|
|
19
|
+
}>;
|
|
20
|
+
|
|
21
|
+
const defaultProps = {} satisfies Partial<InputLabelInfoProps>;
|
|
22
|
+
|
|
23
|
+
export const InputLabelInfo = factory<InputLabelInfoFactory>((_props, ref) => {
|
|
24
|
+
const props = useProps('InputLabelInfo', defaultProps, _props);
|
|
25
|
+
const {classNames, className, style, styles, unstyled, vars, children, attributes, ...others} = props;
|
|
26
|
+
const getStyles = useStyles<InputLabelInfoFactory>({
|
|
27
|
+
name: 'InputLabelInfo',
|
|
28
|
+
props,
|
|
29
|
+
style,
|
|
30
|
+
styles,
|
|
31
|
+
unstyled,
|
|
32
|
+
attributes,
|
|
33
|
+
className,
|
|
34
|
+
classes,
|
|
35
|
+
classNames,
|
|
36
|
+
vars,
|
|
37
|
+
});
|
|
38
|
+
return (
|
|
39
|
+
<Tooltip label={children} {...others}>
|
|
40
|
+
<InfoToken.Information component="span" {...getStyles('labelInfo', {className, style})} ref={ref} />
|
|
41
|
+
</Tooltip>
|
|
42
|
+
);
|
|
43
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {render, screen, userEvent} from '@test-utils';
|
|
2
|
+
|
|
3
|
+
import {Input, InputLabelInfo} from '../Input.js';
|
|
4
|
+
|
|
5
|
+
describe('Input', () => {
|
|
6
|
+
it('exposes InputLabelInfo as a compound component', () => {
|
|
7
|
+
expect(Input.LabelInfo).toBe(InputLabelInfo);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('renders LabelInfo inside the label prop and shows its tooltip content on hover', async () => {
|
|
11
|
+
const user = userEvent.setup();
|
|
12
|
+
render(
|
|
13
|
+
<Input.Wrapper
|
|
14
|
+
label={
|
|
15
|
+
<>
|
|
16
|
+
<span>Field label</span>
|
|
17
|
+
<Input.LabelInfo>Helpful tooltip</Input.LabelInfo>
|
|
18
|
+
</>
|
|
19
|
+
}
|
|
20
|
+
>
|
|
21
|
+
<Input />
|
|
22
|
+
</Input.Wrapper>,
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
expect(screen.getByText('Field label')).toBeVisible();
|
|
26
|
+
const infoToken = screen.getByRole('img', {name: 'information'});
|
|
27
|
+
expect(infoToken).toBeVisible();
|
|
28
|
+
|
|
29
|
+
await user.hover(infoToken);
|
|
30
|
+
|
|
31
|
+
expect(await screen.findByRole('tooltip')).toHaveTextContent('Helpful tooltip');
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -40,7 +40,7 @@ const PlasmaModal = factory<PlasmaModalFactory>(({title, description, help, ...o
|
|
|
40
40
|
return <MantineModal ref={ref} title={header} {...otherProps} />;
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
PlasmaModal.displayName = '
|
|
43
|
+
PlasmaModal.displayName = 'Modal';
|
|
44
44
|
PlasmaModal.Root = MantineModal.Root;
|
|
45
45
|
PlasmaModal.Body = MantineModal.Body;
|
|
46
46
|
PlasmaModal.Overlay = MantineModal.Overlay;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
:global(.mantine-Modal-body) {
|
|
2
2
|
.root {
|
|
3
3
|
margin: calc(-1 * var(--mb-padding));
|
|
4
|
-
margin-top:
|
|
4
|
+
margin-top: var(--mb-padding);
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
.root {
|
|
9
|
-
padding: var(--mb-padding, var(--mantine-spacing-
|
|
9
|
+
padding: var(--mb-padding, var(--mantine-spacing-md, 24px));
|
|
10
10
|
}
|
|
@@ -31,5 +31,7 @@ export const ModalFooter = factory<ModalFooterFactory>((props, ref) => {
|
|
|
31
31
|
// if ref === 'function', this is a callback ref. Haven't found any solution for adjusting the height in this case
|
|
32
32
|
}, [ref, props.h]);
|
|
33
33
|
|
|
34
|
-
return <StickyFooter className={classes.root} ref={footerRef} {...props} />;
|
|
34
|
+
return <StickyFooter borderTop className={classes.root} ref={footerRef} {...props} />;
|
|
35
35
|
});
|
|
36
|
+
|
|
37
|
+
ModalFooter.displayName = 'Modal.Footer';
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
.root {
|
|
2
|
-
--prompt-icon-size: 32px;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.body {
|
|
6
|
-
padding-left: calc(var(--prompt-icon-size) + var(--mantine-spacing-sm) + var(--mb-padding));
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.icon {
|
|
10
|
-
width: var(--prompt-icon-size);
|
|
11
|
-
height: var(--prompt-icon-size);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
1
|
.header {
|
|
15
2
|
gap: var(--mantine-spacing-sm);
|
|
16
3
|
}
|
|
17
|
-
|
|
18
|
-
.inner {
|
|
19
|
-
color: var(--mantine-color-dimmed);
|
|
20
|
-
}
|
|
@@ -9,18 +9,15 @@ import {
|
|
|
9
9
|
useProps,
|
|
10
10
|
useStyles,
|
|
11
11
|
} from '@mantine/core';
|
|
12
|
-
import {Children, ComponentType, ReactElement, ReactNode} from 'react';
|
|
12
|
+
import {Children, ComponentProps, ComponentType, forwardRef, FunctionComponent, ReactElement, ReactNode} from 'react';
|
|
13
|
+
import {InfoToken} from '../InfoToken/InfoToken.js';
|
|
13
14
|
import {Modal} from '../Modal/Modal.js';
|
|
14
15
|
import {PromptContextProvider} from './Prompt.context.js';
|
|
15
16
|
import classes from './Prompt.module.css';
|
|
16
17
|
import {PromptCancelButton, PromptCancelButtonStylesNamesVariant} from './PromptCancelButton.js';
|
|
17
18
|
import {PromptConfirmButton, PromptConfirmButtonStylesNamesVariant} from './PromptConfirmButton.js';
|
|
18
|
-
import CriticalIcon from './icons/CriticalIcon.js';
|
|
19
|
-
import InfoIcon from './icons/InfoIcon.js';
|
|
20
|
-
import SuccessIcon from './icons/SuccessIcon.js';
|
|
21
|
-
import WarningIcon from './icons/WarningIcon.js';
|
|
22
19
|
|
|
23
|
-
export type PromptVariant = 'success' | 'warning' | 'critical' | '
|
|
20
|
+
export type PromptVariant = 'success' | 'warning' | 'critical' | 'information';
|
|
24
21
|
export type PromptVars = {root: '--prompt-icon-size'};
|
|
25
22
|
export type PromptStylesNames =
|
|
26
23
|
| Exclude<ModalStylesNames, 'title'>
|
|
@@ -28,45 +25,39 @@ export type PromptStylesNames =
|
|
|
28
25
|
| PromptCancelButtonStylesNamesVariant
|
|
29
26
|
| PromptConfirmButtonStylesNamesVariant;
|
|
30
27
|
|
|
28
|
+
type PromptStylesApiProps = Omit<StylesApiProps<PromptFactory>, 'variant'>;
|
|
29
|
+
|
|
31
30
|
export interface PromptProps
|
|
32
|
-
extends
|
|
33
|
-
Omit<ModalRootProps, 'classNames' | 'styles' | 'vars' | 'attributes'> {
|
|
34
|
-
/**
|
|
35
|
-
* Controls prompt appearance
|
|
36
|
-
*
|
|
37
|
-
* @default "info"
|
|
38
|
-
*/
|
|
39
|
-
variant?: PromptVariant;
|
|
31
|
+
extends PromptStylesApiProps, Omit<ModalRootProps, 'classNames' | 'styles' | 'vars' | 'attributes' | 'variant'> {
|
|
40
32
|
children: ReactNode;
|
|
41
33
|
title: ReactNode;
|
|
42
34
|
}
|
|
43
35
|
|
|
36
|
+
interface PromptInternalProps extends PromptProps {
|
|
37
|
+
variant?: PromptVariant;
|
|
38
|
+
}
|
|
39
|
+
|
|
44
40
|
export type PromptFactory = Factory<{
|
|
45
|
-
props:
|
|
41
|
+
props: PromptInternalProps;
|
|
46
42
|
ref: HTMLDivElement;
|
|
47
43
|
vars: PromptVars;
|
|
48
44
|
variant: PromptVariant;
|
|
49
45
|
stylesNames: PromptStylesNames;
|
|
50
|
-
staticComponents: {
|
|
51
|
-
CancelButton: typeof PromptCancelButton;
|
|
52
|
-
ConfirmButton: typeof PromptConfirmButton;
|
|
53
|
-
Footer: typeof PromptFooter;
|
|
54
|
-
};
|
|
55
46
|
}>;
|
|
56
47
|
|
|
57
|
-
const PromptVariantIconsMapping: Record<PromptVariant,
|
|
58
|
-
success:
|
|
59
|
-
warning:
|
|
60
|
-
critical:
|
|
61
|
-
|
|
48
|
+
const PromptVariantIconsMapping: Record<PromptVariant, typeof InfoToken.Information> = {
|
|
49
|
+
success: InfoToken.Success,
|
|
50
|
+
warning: InfoToken.Warning,
|
|
51
|
+
critical: InfoToken.Error,
|
|
52
|
+
information: InfoToken.Information,
|
|
62
53
|
};
|
|
63
54
|
|
|
64
|
-
const defaultProps: Partial<
|
|
65
|
-
variant: '
|
|
55
|
+
const defaultProps: Partial<PromptInternalProps> = {
|
|
56
|
+
variant: 'information',
|
|
66
57
|
centered: true,
|
|
67
58
|
};
|
|
68
59
|
|
|
69
|
-
|
|
60
|
+
const _Prompt = factory<PromptFactory>((_props, ref) => {
|
|
70
61
|
const props = useProps('Prompt', defaultProps, _props);
|
|
71
62
|
const {
|
|
72
63
|
variant,
|
|
@@ -98,7 +89,7 @@ export const Prompt = factory<PromptFactory>((_props, ref) => {
|
|
|
98
89
|
const otherChildren: ReactElement[] = [];
|
|
99
90
|
|
|
100
91
|
Children.forEach(children, (child: ReactElement) => {
|
|
101
|
-
(child.type ===
|
|
92
|
+
(child.type === PromptFooter ? footers : otherChildren).push(child);
|
|
102
93
|
});
|
|
103
94
|
|
|
104
95
|
const IconComponent = PromptVariantIconsMapping[variant];
|
|
@@ -109,7 +100,12 @@ export const Prompt = factory<PromptFactory>((_props, ref) => {
|
|
|
109
100
|
<Modal.Overlay {...getStyles('overlay', stylesApiProps)} />
|
|
110
101
|
<Modal.Content {...getStyles('content', stylesApiProps)}>
|
|
111
102
|
<Modal.Header {...getStyles('header', stylesApiProps)}>
|
|
112
|
-
<IconComponent
|
|
103
|
+
<IconComponent
|
|
104
|
+
{...getStyles('icon', stylesApiProps)}
|
|
105
|
+
variant="light"
|
|
106
|
+
size="sm"
|
|
107
|
+
aria-label={variant}
|
|
108
|
+
/>
|
|
113
109
|
<Modal.Title>
|
|
114
110
|
<Title order={3} component="div">
|
|
115
111
|
{title}
|
|
@@ -126,9 +122,27 @@ export const Prompt = factory<PromptFactory>((_props, ref) => {
|
|
|
126
122
|
</PromptContextProvider>
|
|
127
123
|
);
|
|
128
124
|
});
|
|
125
|
+
_Prompt.displayName = 'Prompt';
|
|
126
|
+
|
|
127
|
+
type PromptCompoundComponent = ((props: PromptProps) => ReactElement) & Omit<FunctionComponent<PromptProps>, never>;
|
|
129
128
|
|
|
130
|
-
const PromptFooter = Modal.Footer
|
|
129
|
+
const PromptFooter: ComponentType<ComponentProps<typeof Modal.Footer>> = (props) => <Modal.Footer {...props} />;
|
|
130
|
+
PromptFooter.displayName = 'Prompt.Footer';
|
|
131
|
+
|
|
132
|
+
const createPromptCompound = (variant: PromptVariant, displayName: string): PromptCompoundComponent => {
|
|
133
|
+
const Component = forwardRef<HTMLDivElement, PromptProps>((props, ref) => (
|
|
134
|
+
<_Prompt ref={ref} {...props} variant={variant} />
|
|
135
|
+
));
|
|
136
|
+
Component.displayName = displayName;
|
|
137
|
+
return Component as PromptCompoundComponent;
|
|
138
|
+
};
|
|
131
139
|
|
|
132
|
-
Prompt
|
|
133
|
-
Prompt.
|
|
134
|
-
Prompt.
|
|
140
|
+
export const Prompt = {
|
|
141
|
+
Information: createPromptCompound('information', 'Prompt.Information'),
|
|
142
|
+
Success: createPromptCompound('success', 'Prompt.Success'),
|
|
143
|
+
Warning: createPromptCompound('warning', 'Prompt.Warning'),
|
|
144
|
+
Critical: createPromptCompound('critical', 'Prompt.Critical'),
|
|
145
|
+
CancelButton: PromptCancelButton,
|
|
146
|
+
ConfirmButton: PromptConfirmButton,
|
|
147
|
+
Footer: PromptFooter,
|
|
148
|
+
} as const;
|