@redsift/popovers 8.0.1 → 8.0.3
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/index.js.map → index.js.map} +1 -1
- package/package.json +3 -2
- package/coverage/clover.xml +0 -738
- package/coverage/coverage-final.json +0 -53
- package/coverage/lcov-report/Tooltip.tsx.html +0 -235
- package/coverage/lcov-report/TooltipContent.tsx.html +0 -235
- package/coverage/lcov-report/TooltipTrigger.tsx.html +0 -241
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/context.ts.html +0 -97
- package/coverage/lcov-report/dialog/Dialog.tsx.html +0 -271
- package/coverage/lcov-report/dialog/context.ts.html +0 -97
- package/coverage/lcov-report/dialog/index.html +0 -191
- package/coverage/lcov-report/dialog/index.ts.html +0 -100
- package/coverage/lcov-report/dialog/types.ts.html +0 -253
- package/coverage/lcov-report/dialog/useDialog.tsx.html +0 -346
- package/coverage/lcov-report/dialog/useDialogContext.tsx.html +0 -121
- package/coverage/lcov-report/dialog-content/DialogContent.tsx.html +0 -487
- package/coverage/lcov-report/dialog-content/index.html +0 -146
- package/coverage/lcov-report/dialog-content/index.ts.html +0 -91
- package/coverage/lcov-report/dialog-content/intl/index.html +0 -116
- package/coverage/lcov-report/dialog-content/intl/index.ts.html +0 -106
- package/coverage/lcov-report/dialog-content/styles.ts.html +0 -301
- package/coverage/lcov-report/dialog-content-actions/DialogContentActions.tsx.html +0 -205
- package/coverage/lcov-report/dialog-content-actions/index.html +0 -146
- package/coverage/lcov-report/dialog-content-actions/index.ts.html +0 -91
- package/coverage/lcov-report/dialog-content-actions/styles.ts.html +0 -139
- package/coverage/lcov-report/dialog-content-body/DialogContentBody.tsx.html +0 -232
- package/coverage/lcov-report/dialog-content-body/index.html +0 -146
- package/coverage/lcov-report/dialog-content-body/index.ts.html +0 -91
- package/coverage/lcov-report/dialog-content-body/styles.ts.html +0 -259
- package/coverage/lcov-report/dialog-content-header/DialogContentHeader.tsx.html +0 -328
- package/coverage/lcov-report/dialog-content-header/index.html +0 -146
- package/coverage/lcov-report/dialog-content-header/index.ts.html +0 -91
- package/coverage/lcov-report/dialog-content-header/styles.ts.html +0 -193
- package/coverage/lcov-report/dialog-trigger/DialogTrigger.tsx.html +0 -214
- package/coverage/lcov-report/dialog-trigger/index.html +0 -131
- package/coverage/lcov-report/dialog-trigger/index.ts.html +0 -91
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -341
- package/coverage/lcov-report/index.ts.html +0 -97
- package/coverage/lcov-report/popover/Popover.tsx.html +0 -244
- package/coverage/lcov-report/popover/context.ts.html +0 -97
- package/coverage/lcov-report/popover/index.html +0 -191
- package/coverage/lcov-report/popover/index.ts.html +0 -100
- package/coverage/lcov-report/popover/types.ts.html +0 -244
- package/coverage/lcov-report/popover/usePopover.tsx.html +0 -295
- package/coverage/lcov-report/popover/usePopoverContext.tsx.html +0 -121
- package/coverage/lcov-report/popover-content/PopoverContent.tsx.html +0 -268
- package/coverage/lcov-report/popover-content/index.html +0 -146
- package/coverage/lcov-report/popover-content/index.ts.html +0 -91
- package/coverage/lcov-report/popover-content/styles.ts.html +0 -166
- package/coverage/lcov-report/popover-trigger/PopoverTrigger.tsx.html +0 -214
- package/coverage/lcov-report/popover-trigger/index.html +0 -131
- package/coverage/lcov-report/popover-trigger/index.ts.html +0 -91
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/styles.ts.html +0 -391
- package/coverage/lcov-report/toast/Toast.tsx.html +0 -451
- package/coverage/lcov-report/toast/index.html +0 -161
- package/coverage/lcov-report/toast/index.ts.html +0 -91
- package/coverage/lcov-report/toast/intl/index.html +0 -116
- package/coverage/lcov-report/toast/intl/index.ts.html +0 -106
- package/coverage/lcov-report/toast/styles.ts.html +0 -214
- package/coverage/lcov-report/toast/types.ts.html +0 -217
- package/coverage/lcov-report/toast-container/ToastContainer.tsx.html +0 -217
- package/coverage/lcov-report/toast-container/index.html +0 -161
- package/coverage/lcov-report/toast-container/index.ts.html +0 -94
- package/coverage/lcov-report/toast-container/styles.ts.html +0 -2323
- package/coverage/lcov-report/toast-container/useToast.tsx.html +0 -469
- package/coverage/lcov-report/toast-provider/ToastProvider.tsx.html +0 -256
- package/coverage/lcov-report/toast-provider/context.ts.html +0 -106
- package/coverage/lcov-report/toast-provider/index.html +0 -161
- package/coverage/lcov-report/toast-provider/index.ts.html +0 -97
- package/coverage/lcov-report/toast-provider/useToast.tsx.html +0 -109
- package/coverage/lcov-report/tooltip/Tooltip.tsx.html +0 -250
- package/coverage/lcov-report/tooltip/context.ts.html +0 -97
- package/coverage/lcov-report/tooltip/index.html +0 -191
- package/coverage/lcov-report/tooltip/index.ts.html +0 -100
- package/coverage/lcov-report/tooltip/types.ts.html +0 -250
- package/coverage/lcov-report/tooltip/useTooltip.tsx.html +0 -352
- package/coverage/lcov-report/tooltip/useTooltipContext.tsx.html +0 -121
- package/coverage/lcov-report/tooltip-content/TooltipContent.tsx.html +0 -313
- package/coverage/lcov-report/tooltip-content/index.html +0 -146
- package/coverage/lcov-report/tooltip-content/index.ts.html +0 -91
- package/coverage/lcov-report/tooltip-content/styles.ts.html +0 -337
- package/coverage/lcov-report/tooltip-trigger/TooltipTrigger.tsx.html +0 -211
- package/coverage/lcov-report/tooltip-trigger/index.html +0 -131
- package/coverage/lcov-report/tooltip-trigger/index.ts.html +0 -91
- package/coverage/lcov-report/types.ts.html +0 -226
- package/coverage/lcov-report/useTooltip.tsx.html +0 -277
- package/coverage/lcov-report/useTooltipContext.tsx.html +0 -121
- package/coverage/lcov-report/useTooltipOpen.tsx.html +0 -559
- package/coverage/lcov.info +0 -1330
- package/dist/package.json +0 -96
- package/index.ts +0 -1
- package/jest.config.js +0 -3
- package/rollup.config.js +0 -13
- package/src/components/dialog/Dialog.stories.tsx +0 -201
- package/src/components/dialog/Dialog.test.tsx +0 -116
- package/src/components/dialog/Dialog.tsx +0 -62
- package/src/components/dialog/context.ts +0 -4
- package/src/components/dialog/index.ts +0 -5
- package/src/components/dialog/types.ts +0 -56
- package/src/components/dialog/useDialog.tsx +0 -87
- package/src/components/dialog/useDialogContext.tsx +0 -12
- package/src/components/dialog-content/DialogContent.stories.tsx +0 -337
- package/src/components/dialog-content/DialogContent.tsx +0 -134
- package/src/components/dialog-content/index.ts +0 -2
- package/src/components/dialog-content/intl/en-US.json +0 -3
- package/src/components/dialog-content/intl/fr-FR.json +0 -3
- package/src/components/dialog-content/intl/index.ts +0 -7
- package/src/components/dialog-content/styles.ts +0 -72
- package/src/components/dialog-content/types.ts +0 -11
- package/src/components/dialog-content-actions/DialogContentActions.test.tsx +0 -68
- package/src/components/dialog-content-actions/DialogContentActions.tsx +0 -40
- package/src/components/dialog-content-actions/index.ts +0 -2
- package/src/components/dialog-content-actions/styles.ts +0 -18
- package/src/components/dialog-content-actions/types.ts +0 -11
- package/src/components/dialog-content-body/DialogContentBody.test.tsx +0 -63
- package/src/components/dialog-content-body/DialogContentBody.tsx +0 -49
- package/src/components/dialog-content-body/index.ts +0 -2
- package/src/components/dialog-content-body/styles.ts +0 -58
- package/src/components/dialog-content-body/types.ts +0 -14
- package/src/components/dialog-content-header/DialogContentHeader.test.tsx +0 -63
- package/src/components/dialog-content-header/DialogContentHeader.tsx +0 -81
- package/src/components/dialog-content-header/index.ts +0 -2
- package/src/components/dialog-content-header/styles.ts +0 -36
- package/src/components/dialog-content-header/types.ts +0 -23
- package/src/components/dialog-trigger/DialogTrigger.tsx +0 -43
- package/src/components/dialog-trigger/index.ts +0 -2
- package/src/components/dialog-trigger/types.ts +0 -9
- package/src/components/popover/Popover.stories.tsx +0 -158
- package/src/components/popover/Popover.test.tsx +0 -102
- package/src/components/popover/Popover.tsx +0 -53
- package/src/components/popover/context.ts +0 -4
- package/src/components/popover/index.ts +0 -5
- package/src/components/popover/types.ts +0 -53
- package/src/components/popover/usePopover.tsx +0 -70
- package/src/components/popover/usePopoverContext.tsx +0 -12
- package/src/components/popover-content/PopoverContent.tsx +0 -61
- package/src/components/popover-content/index.ts +0 -2
- package/src/components/popover-content/styles.ts +0 -27
- package/src/components/popover-content/types.ts +0 -11
- package/src/components/popover-trigger/PopoverTrigger.tsx +0 -43
- package/src/components/popover-trigger/index.ts +0 -2
- package/src/components/popover-trigger/types.ts +0 -9
- package/src/components/toast/Toast.stories.tsx +0 -75
- package/src/components/toast/Toast.test.tsx +0 -63
- package/src/components/toast/Toast.tsx +0 -122
- package/src/components/toast/index.ts +0 -2
- package/src/components/toast/intl/en-US.json +0 -3
- package/src/components/toast/intl/fr-FR.json +0 -3
- package/src/components/toast/intl/index.ts +0 -7
- package/src/components/toast/styles.ts +0 -43
- package/src/components/toast/types.ts +0 -44
- package/src/components/toast-container/ToastContainer.stories.tsx +0 -349
- package/src/components/toast-container/ToastContainer.tsx +0 -44
- package/src/components/toast-container/index.ts +0 -3
- package/src/components/toast-container/styles.ts +0 -746
- package/src/components/toast-container/types.ts +0 -110
- package/src/components/toast-container/useToast.test.tsx +0 -111
- package/src/components/toast-container/useToast.tsx +0 -128
- package/src/components/tooltip/Tooltip.stories.tsx +0 -200
- package/src/components/tooltip/Tooltip.test.tsx +0 -119
- package/src/components/tooltip/Tooltip.tsx +0 -55
- package/src/components/tooltip/context.ts +0 -4
- package/src/components/tooltip/index.ts +0 -5
- package/src/components/tooltip/types.ts +0 -55
- package/src/components/tooltip/useTooltip.tsx +0 -89
- package/src/components/tooltip/useTooltipContext.tsx +0 -12
- package/src/components/tooltip-content/TooltipContent.tsx +0 -76
- package/src/components/tooltip-content/index.ts +0 -2
- package/src/components/tooltip-content/styles.ts +0 -84
- package/src/components/tooltip-content/types.ts +0 -14
- package/src/components/tooltip-trigger/TooltipTrigger.tsx +0 -42
- package/src/components/tooltip-trigger/index.ts +0 -2
- package/src/components/tooltip-trigger/types.ts +0 -9
- package/src/index.ts +0 -14
- package/tsconfig.json +0 -3
- package/{dist/CONTRIBUTING.md → CONTRIBUTING.md} +0 -0
- package/{dist/index.d.ts → index.d.ts} +0 -0
- package/{dist/index.js → index.js} +2 -2
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
import { baseContainer } from '@redsift/design-system';
|
|
3
|
-
import { StyledDialogContentActionsProps } from './types';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Component style.
|
|
7
|
-
*/
|
|
8
|
-
export const StyledDialogContentActions = styled.div<StyledDialogContentActionsProps>`
|
|
9
|
-
display: flex;
|
|
10
|
-
${baseContainer}
|
|
11
|
-
|
|
12
|
-
margin-top: 8px;
|
|
13
|
-
margin-bottom: 8px;
|
|
14
|
-
|
|
15
|
-
&:focus-visible {
|
|
16
|
-
outline: none;
|
|
17
|
-
}
|
|
18
|
-
`;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ComponentProps } from 'react';
|
|
2
|
-
import { ContainerProps } from '@redsift/design-system';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Component props.
|
|
6
|
-
*/
|
|
7
|
-
export interface DialogContentActionsProps
|
|
8
|
-
extends ComponentProps<'div'>,
|
|
9
|
-
ContainerProps {}
|
|
10
|
-
|
|
11
|
-
export type StyledDialogContentActionsProps = DialogContentActionsProps;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { act, render, waitFor } from '@testing-library/react';
|
|
3
|
-
|
|
4
|
-
import { DialogContentBody } from '.';
|
|
5
|
-
import { Dialog } from '../dialog';
|
|
6
|
-
|
|
7
|
-
const DialogBodyWrapper = ({ children }: { children: React.ReactNode }) => {
|
|
8
|
-
return (
|
|
9
|
-
<Dialog isOpen>
|
|
10
|
-
<Dialog.Content>{children}</Dialog.Content>
|
|
11
|
-
</Dialog>
|
|
12
|
-
);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
describe('DialogContentBody', () => {
|
|
16
|
-
it('handles default', async () => {
|
|
17
|
-
const { getByText } = render(<DialogContentBody>Body</DialogContentBody>, {
|
|
18
|
-
wrapper: DialogBodyWrapper,
|
|
19
|
-
});
|
|
20
|
-
await act(async () => {});
|
|
21
|
-
await waitFor(() => {
|
|
22
|
-
expect(getByText('Body')).toBeVisible();
|
|
23
|
-
});
|
|
24
|
-
expect(getByText('Body')).toBeVisible();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('supports custom className', async () => {
|
|
28
|
-
const { getByText } = render(
|
|
29
|
-
<DialogContentBody className="test-class">Body</DialogContentBody>,
|
|
30
|
-
{ wrapper: DialogBodyWrapper }
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
await act(async () => {});
|
|
34
|
-
await waitFor(() => {
|
|
35
|
-
expect(getByText('Body')).toBeVisible();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const component = getByText('Body');
|
|
39
|
-
expect(component).toHaveAttribute(
|
|
40
|
-
'class',
|
|
41
|
-
expect.stringContaining(DialogContentBody.className!)
|
|
42
|
-
);
|
|
43
|
-
expect(component).toHaveAttribute(
|
|
44
|
-
'class',
|
|
45
|
-
expect.stringContaining('test-class')
|
|
46
|
-
);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('supports custom data attributes', async () => {
|
|
50
|
-
const { getByText } = render(
|
|
51
|
-
<DialogContentBody data-testid="test">Body</DialogContentBody>,
|
|
52
|
-
{ wrapper: DialogBodyWrapper }
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
await act(async () => {});
|
|
56
|
-
await waitFor(() => {
|
|
57
|
-
expect(getByText('Body')).toBeVisible();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
const component = getByText('Body');
|
|
61
|
-
expect(component).toHaveAttribute('data-testid', 'test');
|
|
62
|
-
});
|
|
63
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import { useMergeRefs } from '@floating-ui/react';
|
|
4
|
-
|
|
5
|
-
import { Comp, useBoundingClientRect } from '@redsift/design-system';
|
|
6
|
-
import { StyledDialogContentBody } from './styles';
|
|
7
|
-
import { DialogContentBodyProps } from './types';
|
|
8
|
-
import { useDialogContext } from '../dialog';
|
|
9
|
-
|
|
10
|
-
const COMPONENT_NAME = 'DialogContentBody';
|
|
11
|
-
const CLASSNAME = 'redsift-dialog-content-body';
|
|
12
|
-
const DEFAULT_PROPS: Partial<DialogContentBodyProps> = {};
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The DialogContentBody component.
|
|
16
|
-
*/
|
|
17
|
-
export const DialogContentBody: Comp<DialogContentBodyProps, HTMLDivElement> =
|
|
18
|
-
forwardRef((props, ref) => {
|
|
19
|
-
const { children, className, ...forwardedProps } = props;
|
|
20
|
-
|
|
21
|
-
const { actionsRef, bodyRef, hasCloseButton, headerRef, initialFocus } =
|
|
22
|
-
useDialogContext();
|
|
23
|
-
|
|
24
|
-
const { height: headerHeight = 0 } = useBoundingClientRect(
|
|
25
|
-
headerRef as any,
|
|
26
|
-
[children, headerRef]
|
|
27
|
-
);
|
|
28
|
-
const { height: actionsHeight = 0 } = useBoundingClientRect(
|
|
29
|
-
actionsRef as any,
|
|
30
|
-
[children, actionsRef]
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
/* istanbul ignore next */
|
|
34
|
-
return (
|
|
35
|
-
<StyledDialogContentBody
|
|
36
|
-
{...forwardedProps}
|
|
37
|
-
className={classNames(DialogContentBody.className, className)}
|
|
38
|
-
ref={useMergeRefs([ref, bodyRef])}
|
|
39
|
-
tabIndex={initialFocus === 'body' ? -1 : undefined}
|
|
40
|
-
$marginTop={Math.max(headerHeight, hasCloseButton ? 40 : 0) + 80}
|
|
41
|
-
$marginBottom={(actionsHeight === 0 ? 0 : actionsHeight + 16) + 80}
|
|
42
|
-
>
|
|
43
|
-
{children}
|
|
44
|
-
</StyledDialogContentBody>
|
|
45
|
-
);
|
|
46
|
-
});
|
|
47
|
-
DialogContentBody.className = CLASSNAME;
|
|
48
|
-
DialogContentBody.defaultProps = DEFAULT_PROPS;
|
|
49
|
-
DialogContentBody.displayName = COMPONENT_NAME;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import styled, { css } from 'styled-components';
|
|
2
|
-
import { baseContainer } from '@redsift/design-system';
|
|
3
|
-
import { StyledDialogContentBodyProps } from './types';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Component style.
|
|
7
|
-
*/
|
|
8
|
-
export const StyledDialogContentBody = styled.div<StyledDialogContentBodyProps>`
|
|
9
|
-
${baseContainer}
|
|
10
|
-
|
|
11
|
-
overflow-y: auto;
|
|
12
|
-
${({ $marginTop, $marginBottom }) => css`
|
|
13
|
-
max-height: calc(100vh - ${$marginTop + $marginBottom}px);
|
|
14
|
-
`}
|
|
15
|
-
|
|
16
|
-
color: var(--redsift-color-neutral-darkgrey);
|
|
17
|
-
font-family: var(--redsift-typography-body2-font-family);
|
|
18
|
-
font-size: var(--redsift-typography-body2-font-size);
|
|
19
|
-
font-weight: var(--redsift-typography-body2-font-weight);
|
|
20
|
-
line-height: var(--redsift-typography-body2-line-height);
|
|
21
|
-
padding: 0 24px;
|
|
22
|
-
margin: 16px -24px;
|
|
23
|
-
|
|
24
|
-
&:focus-visible {
|
|
25
|
-
outline: none;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
scrollbar-color: var(--redsift-color-neutral-midgrey) transparent;
|
|
29
|
-
scrollbar-width: thin;
|
|
30
|
-
|
|
31
|
-
&::-webkit-scrollbar {
|
|
32
|
-
block-size: 9px;
|
|
33
|
-
inline-size: 9px;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
&::-webkit-scrollbar-thumb {
|
|
37
|
-
background-clip: padding-box;
|
|
38
|
-
background-color: var(--redsift-color-neutral-midgrey);
|
|
39
|
-
border-radius: 0px;
|
|
40
|
-
border-left: 2px solid transparent;
|
|
41
|
-
border-right: 2px solid transparent;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
&::-webkit-scrollbar-track {
|
|
45
|
-
background-color: transparent;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
&::-webkit-scrollbar-thumb:horizontal,
|
|
49
|
-
&::-webkit-scrollbar-thumb:vertical {
|
|
50
|
-
&:hover {
|
|
51
|
-
background-color: var(--redsift-color-neutral-darkgrey);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
&::-webkit-scrollbar-corner {
|
|
56
|
-
visibility: hidden;
|
|
57
|
-
}
|
|
58
|
-
`;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ComponentProps } from 'react';
|
|
2
|
-
import { ContainerProps } from '@redsift/design-system';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Component props.
|
|
6
|
-
*/
|
|
7
|
-
export interface DialogContentBodyProps
|
|
8
|
-
extends ComponentProps<'div'>,
|
|
9
|
-
ContainerProps {}
|
|
10
|
-
|
|
11
|
-
export type StyledDialogContentBodyProps = DialogContentBodyProps & {
|
|
12
|
-
$marginTop: number;
|
|
13
|
-
$marginBottom: number;
|
|
14
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { act, render, waitFor } from '@testing-library/react';
|
|
3
|
-
|
|
4
|
-
import { DialogContentHeader } from '.';
|
|
5
|
-
import { Dialog } from '../dialog';
|
|
6
|
-
|
|
7
|
-
const DialogHeaderWrapper = ({ children }: { children: React.ReactNode }) => {
|
|
8
|
-
return (
|
|
9
|
-
<Dialog isOpen>
|
|
10
|
-
<Dialog.Content>{children}</Dialog.Content>
|
|
11
|
-
</Dialog>
|
|
12
|
-
);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
describe('DialogContentHeader', () => {
|
|
16
|
-
it('handles default', async () => {
|
|
17
|
-
const { getByText } = render(<DialogContentHeader header="Header" />, {
|
|
18
|
-
wrapper: DialogHeaderWrapper,
|
|
19
|
-
});
|
|
20
|
-
await act(async () => {});
|
|
21
|
-
await waitFor(() => {
|
|
22
|
-
expect(getByText('Header')).toBeVisible();
|
|
23
|
-
});
|
|
24
|
-
expect(getByText('Header')).toBeVisible();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('supports custom className', async () => {
|
|
28
|
-
const { getByText } = render(
|
|
29
|
-
<DialogContentHeader className="test-class" header="Header" />,
|
|
30
|
-
{ wrapper: DialogHeaderWrapper }
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
await act(async () => {});
|
|
34
|
-
await waitFor(() => {
|
|
35
|
-
expect(getByText('Header')).toBeVisible();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const component = getByText('Header').parentElement;
|
|
39
|
-
expect(component).toHaveAttribute(
|
|
40
|
-
'class',
|
|
41
|
-
expect.stringContaining(DialogContentHeader.className!)
|
|
42
|
-
);
|
|
43
|
-
expect(component).toHaveAttribute(
|
|
44
|
-
'class',
|
|
45
|
-
expect.stringContaining('test-class')
|
|
46
|
-
);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('supports custom data attributes', async () => {
|
|
50
|
-
const { getByText } = render(
|
|
51
|
-
<DialogContentHeader data-testid="test" header="Header" />,
|
|
52
|
-
{ wrapper: DialogHeaderWrapper }
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
await act(async () => {});
|
|
56
|
-
await waitFor(() => {
|
|
57
|
-
expect(getByText('Header')).toBeVisible();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
const component = getByText('Header').parentElement;
|
|
61
|
-
expect(component).toHaveAttribute('data-testid', 'test');
|
|
62
|
-
});
|
|
63
|
-
});
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, useId } from 'react';
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import { useMergeRefs } from '@floating-ui/react';
|
|
4
|
-
|
|
5
|
-
import { Icon, Heading, Comp } from '@redsift/design-system';
|
|
6
|
-
import { StyledDialogContentHeader } from './styles';
|
|
7
|
-
import { DialogContentHeaderProps } from './types';
|
|
8
|
-
import { useDialogContext } from '../dialog';
|
|
9
|
-
|
|
10
|
-
const COMPONENT_NAME = 'DialogContentHeader';
|
|
11
|
-
const CLASSNAME = 'redsift-dialog-content-header';
|
|
12
|
-
const DEFAULT_PROPS: Partial<DialogContentHeaderProps> = {};
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The DialogContentHeader component.
|
|
16
|
-
*/
|
|
17
|
-
export const DialogContentHeader: Comp<
|
|
18
|
-
DialogContentHeaderProps,
|
|
19
|
-
HTMLDivElement
|
|
20
|
-
> = forwardRef((props, ref) => {
|
|
21
|
-
const {
|
|
22
|
-
children,
|
|
23
|
-
className,
|
|
24
|
-
header,
|
|
25
|
-
headingProps,
|
|
26
|
-
icon,
|
|
27
|
-
subheader,
|
|
28
|
-
...forwardedProps
|
|
29
|
-
} = props;
|
|
30
|
-
|
|
31
|
-
const { setLabelId, setDescriptionId, headerRef, initialFocus } =
|
|
32
|
-
useDialogContext();
|
|
33
|
-
const labelId = useId();
|
|
34
|
-
const descriptionId = useId();
|
|
35
|
-
|
|
36
|
-
// Only sets `aria-labelledby` on the Dialog root element
|
|
37
|
-
// if this component is mounted inside it.
|
|
38
|
-
React.useLayoutEffect(() => {
|
|
39
|
-
setLabelId(labelId);
|
|
40
|
-
return () => setLabelId(undefined);
|
|
41
|
-
}, [labelId, setLabelId]);
|
|
42
|
-
|
|
43
|
-
// Only sets `aria-describedby` on the Dialog root element
|
|
44
|
-
// if this component is mounted inside it.
|
|
45
|
-
React.useLayoutEffect(() => {
|
|
46
|
-
setDescriptionId(descriptionId);
|
|
47
|
-
return () => setDescriptionId(undefined);
|
|
48
|
-
}, [descriptionId, setDescriptionId]);
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<StyledDialogContentHeader
|
|
52
|
-
{...forwardedProps}
|
|
53
|
-
className={classNames(DialogContentHeader.className, className)}
|
|
54
|
-
ref={useMergeRefs([ref, headerRef])}
|
|
55
|
-
tabIndex={initialFocus === 'header' ? -1 : undefined}
|
|
56
|
-
>
|
|
57
|
-
{subheader ? (
|
|
58
|
-
<div className={`${DialogContentHeader.className}__subheader`}>
|
|
59
|
-
{subheader}
|
|
60
|
-
</div>
|
|
61
|
-
) : null}
|
|
62
|
-
{header ? (
|
|
63
|
-
<Heading
|
|
64
|
-
as="h2"
|
|
65
|
-
color="black"
|
|
66
|
-
className={`${DialogContentHeader.className}__header`}
|
|
67
|
-
id={labelId}
|
|
68
|
-
variant="h2"
|
|
69
|
-
{...headingProps}
|
|
70
|
-
>
|
|
71
|
-
{icon ? <Icon icon={icon} aria-hidden="true" /> : null}
|
|
72
|
-
{header}
|
|
73
|
-
</Heading>
|
|
74
|
-
) : null}
|
|
75
|
-
{children ? <div id={descriptionId}>{children}</div> : null}
|
|
76
|
-
</StyledDialogContentHeader>
|
|
77
|
-
);
|
|
78
|
-
});
|
|
79
|
-
DialogContentHeader.className = CLASSNAME;
|
|
80
|
-
DialogContentHeader.defaultProps = DEFAULT_PROPS;
|
|
81
|
-
DialogContentHeader.displayName = COMPONENT_NAME;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
import { StyledDialogContentHeaderProps } from './types';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Component style.
|
|
6
|
-
*/
|
|
7
|
-
export const StyledDialogContentHeader = styled.div<StyledDialogContentHeaderProps>`
|
|
8
|
-
color: var(--redsift-color-neutral-black);
|
|
9
|
-
|
|
10
|
-
&:focus-visible {
|
|
11
|
-
outline: none;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.redsift-dialog-content-header__header {
|
|
15
|
-
align-items: center;
|
|
16
|
-
display: flex;
|
|
17
|
-
gap: 8px;
|
|
18
|
-
padding: 10px 0px;
|
|
19
|
-
margin: 0px;
|
|
20
|
-
|
|
21
|
-
.redsift-icon {
|
|
22
|
-
color: var(--redsift-color-neutral-black);
|
|
23
|
-
padding-right: 8px;
|
|
24
|
-
font-size: 30px;
|
|
25
|
-
line-height: 30px;
|
|
26
|
-
height: 30px;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.redsift-dialog-content-header__subheader {
|
|
31
|
-
font-family: var(--redsift-typography-body-font-family);
|
|
32
|
-
font-size: var(--redsift-typography-body-font-size);
|
|
33
|
-
font-weight: var(--redsift-typography-body-font-weight);
|
|
34
|
-
line-height: var(--redsift-typography-body-line-height);
|
|
35
|
-
}
|
|
36
|
-
`;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ComponentProps } from 'react';
|
|
2
|
-
import { HeadingProps } from '@redsift/design-system';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Component props.
|
|
6
|
-
*/
|
|
7
|
-
export interface DialogContentHeaderProps extends ComponentProps<'div'> {
|
|
8
|
-
/** Header. */
|
|
9
|
-
header?: string;
|
|
10
|
-
/** Heading props allowing to override the component rendered by the heading without changing its style. */
|
|
11
|
-
headingProps?: Pick<HeadingProps, 'as' | 'noWrap'>;
|
|
12
|
-
/** Subheader */
|
|
13
|
-
subheader?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Icon path data (`d` property of the `path` SVG element).<br />
|
|
16
|
-
* See <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths">https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths</a>.<br />
|
|
17
|
-
* Recommended path data come from mdi/js.<br />
|
|
18
|
-
* See <a href="https://www.npmjs.com/package/@mdi/js">https://www.npmjs.com/package/@mdi/js</a>.
|
|
19
|
-
*/
|
|
20
|
-
icon?: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type StyledDialogContentHeaderProps = DialogContentHeaderProps;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, ReactElement } from 'react';
|
|
2
|
-
import { useMergeRefs } from '@floating-ui/react';
|
|
3
|
-
|
|
4
|
-
import { Comp, isComponent } from '@redsift/design-system';
|
|
5
|
-
import { useDialogContext } from '../dialog';
|
|
6
|
-
import { DialogTriggerProps } from './types';
|
|
7
|
-
|
|
8
|
-
const COMPONENT_NAME = 'DialogTrigger';
|
|
9
|
-
const CLASSNAME = 'redsift-dialog-trigger';
|
|
10
|
-
const DEFAULT_PROPS: Partial<DialogTriggerProps> = {};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The DialogTrigger component.
|
|
14
|
-
*/
|
|
15
|
-
export const DialogTrigger: Comp<DialogTriggerProps, HTMLButtonElement> =
|
|
16
|
-
forwardRef((props, ref) => {
|
|
17
|
-
const { children } = props;
|
|
18
|
-
|
|
19
|
-
const { getReferenceProps, isOpen, handleOpen, refs } = useDialogContext();
|
|
20
|
-
const childrenRef = (children as any).ref;
|
|
21
|
-
const triggerRef = useMergeRefs([refs.setReference, ref, childrenRef]);
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
isComponent('Button')(children) ||
|
|
25
|
-
isComponent('IconButton')(children) ||
|
|
26
|
-
isComponent('LinkButton')(children)
|
|
27
|
-
) {
|
|
28
|
-
return React.cloneElement(children, {
|
|
29
|
-
...getReferenceProps({
|
|
30
|
-
ref: triggerRef,
|
|
31
|
-
...props,
|
|
32
|
-
...(children as ReactElement).props,
|
|
33
|
-
}),
|
|
34
|
-
onClick: () => handleOpen(!isOpen),
|
|
35
|
-
isActive: isOpen,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return <>{children}</>;
|
|
40
|
-
});
|
|
41
|
-
DialogTrigger.className = CLASSNAME;
|
|
42
|
-
DialogTrigger.defaultProps = DEFAULT_PROPS;
|
|
43
|
-
DialogTrigger.displayName = COMPONENT_NAME;
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { Flexbox, Button, Text } from '@redsift/design-system';
|
|
3
|
-
import { Popover, PopoverPlacement } from '.';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'Popovers/Popover',
|
|
7
|
-
component: Popover,
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const Uncontrolled = () => (
|
|
11
|
-
<Popover>
|
|
12
|
-
<Popover.Trigger>
|
|
13
|
-
<Button variant="secondary">Button</Button>
|
|
14
|
-
</Popover.Trigger>
|
|
15
|
-
<Popover.Content>
|
|
16
|
-
<Text margin="16px">
|
|
17
|
-
Cupcake ipsum dolor sit amet blueie jujubes topping sesame snaps.
|
|
18
|
-
Liquorice marzipan jelly-o carrot cake icing croissant carrot cake. Tart
|
|
19
|
-
soufflé sweet roll halvah croissant wafer cotton candy. Candy halvah
|
|
20
|
-
marzipan bear claw donut.
|
|
21
|
-
</Text>
|
|
22
|
-
</Popover.Content>
|
|
23
|
-
</Popover>
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
export const Controlled = () => {
|
|
27
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
28
|
-
return (
|
|
29
|
-
<>
|
|
30
|
-
<Button variant="secondary" onClick={() => setIsOpen(!isOpen)}>
|
|
31
|
-
External trigger
|
|
32
|
-
</Button>
|
|
33
|
-
<Popover isOpen={isOpen} onOpen={setIsOpen}>
|
|
34
|
-
<Popover.Trigger>
|
|
35
|
-
<Button variant="secondary">Trigger</Button>
|
|
36
|
-
</Popover.Trigger>
|
|
37
|
-
<Popover.Content>
|
|
38
|
-
<Text margin="16px">
|
|
39
|
-
Cupcake ipsum dolor sit amet blueie jujubes topping sesame snaps.
|
|
40
|
-
Liquorice marzipan jelly-o carrot cake icing croissant carrot cake.
|
|
41
|
-
Tart soufflé sweet roll halvah croissant wafer cotton candy. Candy
|
|
42
|
-
halvah marzipan bear claw donut.
|
|
43
|
-
</Text>
|
|
44
|
-
</Popover.Content>
|
|
45
|
-
</Popover>
|
|
46
|
-
</>
|
|
47
|
-
);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export const AllPlacements = () => (
|
|
51
|
-
<Flexbox
|
|
52
|
-
flexDirection="column"
|
|
53
|
-
flexWrap="wrap"
|
|
54
|
-
gap="32px"
|
|
55
|
-
padding="64px"
|
|
56
|
-
style={{ backgroundColor: '#EFEFEF' }}
|
|
57
|
-
>
|
|
58
|
-
{['top', 'left', 'right', 'bottom'].map((side) => {
|
|
59
|
-
return (
|
|
60
|
-
<Flexbox
|
|
61
|
-
key={side}
|
|
62
|
-
flexDirection="row"
|
|
63
|
-
flexWrap="wrap"
|
|
64
|
-
justifyContent="space-evenly"
|
|
65
|
-
alignItems="center"
|
|
66
|
-
>
|
|
67
|
-
{['start', '', 'end'].map((alignment) => {
|
|
68
|
-
return (
|
|
69
|
-
<div
|
|
70
|
-
key={`${side}${alignment ? '-' : ''}${alignment}`}
|
|
71
|
-
style={{ margin: '1em' }}
|
|
72
|
-
>
|
|
73
|
-
<Popover
|
|
74
|
-
isOpen
|
|
75
|
-
placement={
|
|
76
|
-
`${side}${
|
|
77
|
-
alignment ? '-' : ''
|
|
78
|
-
}${alignment}` as PopoverPlacement
|
|
79
|
-
}
|
|
80
|
-
>
|
|
81
|
-
<Popover.Trigger>
|
|
82
|
-
<Button variant="secondary">Button</Button>
|
|
83
|
-
</Popover.Trigger>
|
|
84
|
-
<Popover.Content>
|
|
85
|
-
<Text margin="16px">{`Popover [${side}${
|
|
86
|
-
alignment ? '-' : ''
|
|
87
|
-
}${alignment}]`}</Text>
|
|
88
|
-
</Popover.Content>
|
|
89
|
-
</Popover>
|
|
90
|
-
</div>
|
|
91
|
-
);
|
|
92
|
-
})}
|
|
93
|
-
</Flexbox>
|
|
94
|
-
);
|
|
95
|
-
})}
|
|
96
|
-
</Flexbox>
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
export const TriggerIsNotAButton = () => (
|
|
100
|
-
<Popover>
|
|
101
|
-
<Popover.Trigger>
|
|
102
|
-
This text has a popover but this will never be displayed because the
|
|
103
|
-
trigger is not a button.
|
|
104
|
-
</Popover.Trigger>
|
|
105
|
-
<Popover.Content>
|
|
106
|
-
<Text margin="16px">
|
|
107
|
-
Cupcake ipsum dolor sit amet blueie jujubes topping sesame snaps.
|
|
108
|
-
Liquorice marzipan jelly-o carrot cake icing croissant carrot cake. Tart
|
|
109
|
-
soufflé sweet roll halvah croissant wafer cotton candy. Candy halvah
|
|
110
|
-
marzipan bear claw donut.
|
|
111
|
-
</Text>
|
|
112
|
-
</Popover.Content>
|
|
113
|
-
</Popover>
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
export const EmptyPopover = () => (
|
|
117
|
-
<Flexbox
|
|
118
|
-
flexDirection="row"
|
|
119
|
-
flexWrap="wrap"
|
|
120
|
-
justifyContent="center"
|
|
121
|
-
alignItems="center"
|
|
122
|
-
padding="32px"
|
|
123
|
-
style={{ backgroundColor: '#EFEFEF' }}
|
|
124
|
-
>
|
|
125
|
-
<Popover>
|
|
126
|
-
<Popover.Trigger>
|
|
127
|
-
<Button variant="secondary">Button</Button>
|
|
128
|
-
</Popover.Trigger>
|
|
129
|
-
</Popover>
|
|
130
|
-
</Flexbox>
|
|
131
|
-
);
|
|
132
|
-
|
|
133
|
-
export const PopoverOnDisabledButton = () => (
|
|
134
|
-
<Flexbox
|
|
135
|
-
flexDirection="row"
|
|
136
|
-
flexWrap="wrap"
|
|
137
|
-
justifyContent="center"
|
|
138
|
-
alignItems="center"
|
|
139
|
-
padding="32px"
|
|
140
|
-
style={{ backgroundColor: '#EFEFEF' }}
|
|
141
|
-
>
|
|
142
|
-
<Popover>
|
|
143
|
-
<Popover.Trigger>
|
|
144
|
-
<Button variant="secondary" isDisabled>
|
|
145
|
-
Disabled
|
|
146
|
-
</Button>
|
|
147
|
-
</Popover.Trigger>
|
|
148
|
-
<Popover.Content>
|
|
149
|
-
<Text margin="16px">
|
|
150
|
-
Cupcake ipsum dolor sit amet blueie jujubes topping sesame snaps.
|
|
151
|
-
Liquorice marzipan jelly-o carrot cake icing croissant carrot cake.
|
|
152
|
-
Tart soufflé sweet roll halvah croissant wafer cotton candy. Candy
|
|
153
|
-
halvah marzipan bear claw donut.
|
|
154
|
-
</Text>
|
|
155
|
-
</Popover.Content>
|
|
156
|
-
</Popover>
|
|
157
|
-
</Flexbox>
|
|
158
|
-
);
|