@redsift/popovers 9.2.3 → 9.2.4

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.
Files changed (171) hide show
  1. package/package.json +3 -2
  2. package/coverage/clover.xml +0 -763
  3. package/coverage/coverage-final.json +0 -53
  4. package/coverage/lcov-report/base.css +0 -224
  5. package/coverage/lcov-report/block-navigation.js +0 -87
  6. package/coverage/lcov-report/dialog/Dialog.tsx.html +0 -271
  7. package/coverage/lcov-report/dialog/context.ts.html +0 -97
  8. package/coverage/lcov-report/dialog/index.html +0 -191
  9. package/coverage/lcov-report/dialog/index.ts.html +0 -100
  10. package/coverage/lcov-report/dialog/types.ts.html +0 -241
  11. package/coverage/lcov-report/dialog/useDialog.tsx.html +0 -346
  12. package/coverage/lcov-report/dialog/useDialogContext.tsx.html +0 -121
  13. package/coverage/lcov-report/dialog-content/DialogContent.tsx.html +0 -484
  14. package/coverage/lcov-report/dialog-content/index.html +0 -146
  15. package/coverage/lcov-report/dialog-content/index.ts.html +0 -91
  16. package/coverage/lcov-report/dialog-content/intl/index.html +0 -116
  17. package/coverage/lcov-report/dialog-content/intl/index.ts.html +0 -106
  18. package/coverage/lcov-report/dialog-content/styles.ts.html +0 -256
  19. package/coverage/lcov-report/dialog-content-actions/DialogContentActions.tsx.html +0 -205
  20. package/coverage/lcov-report/dialog-content-actions/index.html +0 -146
  21. package/coverage/lcov-report/dialog-content-actions/index.ts.html +0 -91
  22. package/coverage/lcov-report/dialog-content-actions/styles.ts.html +0 -139
  23. package/coverage/lcov-report/dialog-content-body/DialogContentBody.tsx.html +0 -232
  24. package/coverage/lcov-report/dialog-content-body/index.html +0 -146
  25. package/coverage/lcov-report/dialog-content-body/index.ts.html +0 -91
  26. package/coverage/lcov-report/dialog-content-body/styles.ts.html +0 -259
  27. package/coverage/lcov-report/dialog-content-header/DialogContentHeader.tsx.html +0 -280
  28. package/coverage/lcov-report/dialog-content-header/index.html +0 -146
  29. package/coverage/lcov-report/dialog-content-header/index.ts.html +0 -91
  30. package/coverage/lcov-report/dialog-content-header/styles.ts.html +0 -193
  31. package/coverage/lcov-report/dialog-trigger/DialogTrigger.tsx.html +0 -217
  32. package/coverage/lcov-report/dialog-trigger/index.html +0 -131
  33. package/coverage/lcov-report/dialog-trigger/index.ts.html +0 -91
  34. package/coverage/lcov-report/favicon.png +0 -0
  35. package/coverage/lcov-report/index.html +0 -341
  36. package/coverage/lcov-report/popover/Popover.tsx.html +0 -295
  37. package/coverage/lcov-report/popover/context.ts.html +0 -97
  38. package/coverage/lcov-report/popover/index.html +0 -191
  39. package/coverage/lcov-report/popover/index.ts.html +0 -100
  40. package/coverage/lcov-report/popover/types.ts.html +0 -283
  41. package/coverage/lcov-report/popover/usePopover.tsx.html +0 -415
  42. package/coverage/lcov-report/popover/usePopoverContext.tsx.html +0 -121
  43. package/coverage/lcov-report/popover-content/PopoverContent.tsx.html +0 -229
  44. package/coverage/lcov-report/popover-content/index.html +0 -146
  45. package/coverage/lcov-report/popover-content/index.ts.html +0 -94
  46. package/coverage/lcov-report/popover-content/styles.ts.html +0 -370
  47. package/coverage/lcov-report/popover-trigger/PopoverTrigger.tsx.html +0 -202
  48. package/coverage/lcov-report/popover-trigger/index.html +0 -131
  49. package/coverage/lcov-report/popover-trigger/index.ts.html +0 -91
  50. package/coverage/lcov-report/prettify.css +0 -1
  51. package/coverage/lcov-report/prettify.js +0 -2
  52. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  53. package/coverage/lcov-report/sorter.js +0 -196
  54. package/coverage/lcov-report/toast/Toast.tsx.html +0 -373
  55. package/coverage/lcov-report/toast/index.html +0 -161
  56. package/coverage/lcov-report/toast/index.ts.html +0 -91
  57. package/coverage/lcov-report/toast/intl/index.html +0 -116
  58. package/coverage/lcov-report/toast/intl/index.ts.html +0 -106
  59. package/coverage/lcov-report/toast/styles.ts.html +0 -193
  60. package/coverage/lcov-report/toast/types.ts.html +0 -217
  61. package/coverage/lcov-report/toast-container/ToastContainer.tsx.html +0 -217
  62. package/coverage/lcov-report/toast-container/index.html +0 -161
  63. package/coverage/lcov-report/toast-container/index.ts.html +0 -94
  64. package/coverage/lcov-report/toast-container/styles.ts.html +0 -2284
  65. package/coverage/lcov-report/toast-container/useToast.tsx.html +0 -469
  66. package/coverage/lcov-report/tooltip/Tooltip.tsx.html +0 -250
  67. package/coverage/lcov-report/tooltip/context.ts.html +0 -97
  68. package/coverage/lcov-report/tooltip/index.html +0 -191
  69. package/coverage/lcov-report/tooltip/index.ts.html +0 -100
  70. package/coverage/lcov-report/tooltip/types.ts.html +0 -250
  71. package/coverage/lcov-report/tooltip/useTooltip.tsx.html +0 -358
  72. package/coverage/lcov-report/tooltip/useTooltipContext.tsx.html +0 -121
  73. package/coverage/lcov-report/tooltip-content/TooltipContent.tsx.html +0 -313
  74. package/coverage/lcov-report/tooltip-content/index.html +0 -146
  75. package/coverage/lcov-report/tooltip-content/index.ts.html +0 -91
  76. package/coverage/lcov-report/tooltip-content/styles.ts.html +0 -337
  77. package/coverage/lcov-report/tooltip-trigger/TooltipTrigger.tsx.html +0 -211
  78. package/coverage/lcov-report/tooltip-trigger/index.html +0 -131
  79. package/coverage/lcov-report/tooltip-trigger/index.ts.html +0 -91
  80. package/coverage/lcov.info +0 -1510
  81. package/coverage/storybook/coverage-storybook.json +0 -58724
  82. package/dist/package.json +0 -96
  83. package/index.ts +0 -1
  84. package/jest.config.js +0 -3
  85. package/rollup.config.js +0 -13
  86. package/src/components/dialog/Dialog.stories.tsx +0 -264
  87. package/src/components/dialog/Dialog.test.tsx +0 -116
  88. package/src/components/dialog/Dialog.tsx +0 -62
  89. package/src/components/dialog/context.ts +0 -4
  90. package/src/components/dialog/index.ts +0 -5
  91. package/src/components/dialog/types.ts +0 -52
  92. package/src/components/dialog/useDialog.tsx +0 -87
  93. package/src/components/dialog/useDialogContext.tsx +0 -12
  94. package/src/components/dialog-content/DialogContent.stories.tsx +0 -348
  95. package/src/components/dialog-content/DialogContent.tsx +0 -133
  96. package/src/components/dialog-content/index.ts +0 -2
  97. package/src/components/dialog-content/intl/en-US.json +0 -3
  98. package/src/components/dialog-content/intl/fr-FR.json +0 -3
  99. package/src/components/dialog-content/intl/index.ts +0 -7
  100. package/src/components/dialog-content/styles.ts +0 -57
  101. package/src/components/dialog-content/types.ts +0 -10
  102. package/src/components/dialog-content-actions/DialogContentActions.test.tsx +0 -68
  103. package/src/components/dialog-content-actions/DialogContentActions.tsx +0 -40
  104. package/src/components/dialog-content-actions/index.ts +0 -2
  105. package/src/components/dialog-content-actions/styles.ts +0 -18
  106. package/src/components/dialog-content-actions/types.ts +0 -11
  107. package/src/components/dialog-content-body/DialogContentBody.test.tsx +0 -63
  108. package/src/components/dialog-content-body/DialogContentBody.tsx +0 -49
  109. package/src/components/dialog-content-body/index.ts +0 -2
  110. package/src/components/dialog-content-body/styles.ts +0 -58
  111. package/src/components/dialog-content-body/types.ts +0 -14
  112. package/src/components/dialog-content-header/DialogContentHeader.test.tsx +0 -63
  113. package/src/components/dialog-content-header/DialogContentHeader.tsx +0 -65
  114. package/src/components/dialog-content-header/index.ts +0 -2
  115. package/src/components/dialog-content-header/styles.ts +0 -36
  116. package/src/components/dialog-content-header/types.ts +0 -21
  117. package/src/components/dialog-trigger/DialogTrigger.tsx +0 -44
  118. package/src/components/dialog-trigger/index.ts +0 -2
  119. package/src/components/dialog-trigger/types.ts +0 -9
  120. package/src/components/popover/Popover.stories.tsx +0 -129
  121. package/src/components/popover/Popover.test.tsx +0 -102
  122. package/src/components/popover/Popover.tsx +0 -70
  123. package/src/components/popover/context.ts +0 -4
  124. package/src/components/popover/index.ts +0 -5
  125. package/src/components/popover/types.ts +0 -66
  126. package/src/components/popover/usePopover.tsx +0 -110
  127. package/src/components/popover/usePopoverContext.tsx +0 -12
  128. package/src/components/popover-content/PopoverContent.tsx +0 -48
  129. package/src/components/popover-content/index.ts +0 -3
  130. package/src/components/popover-content/styles.ts +0 -95
  131. package/src/components/popover-content/types.ts +0 -11
  132. package/src/components/popover-trigger/PopoverTrigger.tsx +0 -39
  133. package/src/components/popover-trigger/index.ts +0 -2
  134. package/src/components/popover-trigger/types.ts +0 -9
  135. package/src/components/toast/Toast.stories.tsx +0 -68
  136. package/src/components/toast/Toast.test.tsx +0 -63
  137. package/src/components/toast/Toast.tsx +0 -96
  138. package/src/components/toast/index.ts +0 -2
  139. package/src/components/toast/intl/en-US.json +0 -3
  140. package/src/components/toast/intl/fr-FR.json +0 -3
  141. package/src/components/toast/intl/index.ts +0 -7
  142. package/src/components/toast/styles.ts +0 -36
  143. package/src/components/toast/types.ts +0 -44
  144. package/src/components/toast-container/ToastContainer.stories.tsx +0 -349
  145. package/src/components/toast-container/ToastContainer.tsx +0 -44
  146. package/src/components/toast-container/index.ts +0 -3
  147. package/src/components/toast-container/styles.ts +0 -733
  148. package/src/components/toast-container/types.ts +0 -110
  149. package/src/components/toast-container/useToast.test.tsx +0 -111
  150. package/src/components/toast-container/useToast.tsx +0 -128
  151. package/src/components/tooltip/Tooltip.stories.tsx +0 -196
  152. package/src/components/tooltip/Tooltip.test.tsx +0 -119
  153. package/src/components/tooltip/Tooltip.tsx +0 -55
  154. package/src/components/tooltip/context.ts +0 -4
  155. package/src/components/tooltip/index.ts +0 -5
  156. package/src/components/tooltip/types.ts +0 -55
  157. package/src/components/tooltip/useTooltip.tsx +0 -93
  158. package/src/components/tooltip/useTooltipContext.tsx +0 -12
  159. package/src/components/tooltip-content/TooltipContent.tsx +0 -76
  160. package/src/components/tooltip-content/index.ts +0 -2
  161. package/src/components/tooltip-content/styles.ts +0 -84
  162. package/src/components/tooltip-content/types.ts +0 -14
  163. package/src/components/tooltip-trigger/TooltipTrigger.tsx +0 -42
  164. package/src/components/tooltip-trigger/index.ts +0 -2
  165. package/src/components/tooltip-trigger/types.ts +0 -9
  166. package/src/index.ts +0 -16
  167. package/tsconfig.json +0 -3
  168. /package/{dist/CONTRIBUTING.md → CONTRIBUTING.md} +0 -0
  169. /package/{dist/index.d.ts → index.d.ts} +0 -0
  170. /package/{dist/index.js → index.js} +0 -0
  171. /package/{dist/index.js.map → index.js.map} +0 -0
@@ -1,68 +0,0 @@
1
- import React from 'react';
2
- import { act, render, waitFor } from '@testing-library/react';
3
-
4
- import { DialogContentActions } from '.';
5
- import { Dialog } from '../dialog';
6
-
7
- const DialogActionsWrapper = ({ children }: { children: React.ReactNode }) => {
8
- return (
9
- <Dialog isOpen>
10
- <Dialog.Content>{children}</Dialog.Content>
11
- </Dialog>
12
- );
13
- };
14
-
15
- describe('DialogContentActions', () => {
16
- it('handles default', async () => {
17
- const { getByText } = render(
18
- <DialogContentActions>Actions</DialogContentActions>,
19
- {
20
- wrapper: DialogActionsWrapper,
21
- }
22
- );
23
- await act(async () => {});
24
- await waitFor(() => {
25
- expect(getByText('Actions')).toBeVisible();
26
- });
27
- expect(getByText('Actions')).toBeVisible();
28
- });
29
-
30
- it('supports custom className', async () => {
31
- const { getByText } = render(
32
- <DialogContentActions className="test-class">
33
- Actions
34
- </DialogContentActions>,
35
- { wrapper: DialogActionsWrapper }
36
- );
37
-
38
- await act(async () => {});
39
- await waitFor(() => {
40
- expect(getByText('Actions')).toBeVisible();
41
- });
42
-
43
- const component = getByText('Actions');
44
- expect(component).toHaveAttribute(
45
- 'class',
46
- expect.stringContaining(DialogContentActions.className!)
47
- );
48
- expect(component).toHaveAttribute(
49
- 'class',
50
- expect.stringContaining('test-class')
51
- );
52
- });
53
-
54
- it('supports custom data attributes', async () => {
55
- const { getByText } = render(
56
- <DialogContentActions data-testid="test">Actions</DialogContentActions>,
57
- { wrapper: DialogActionsWrapper }
58
- );
59
-
60
- await act(async () => {});
61
- await waitFor(() => {
62
- expect(getByText('Actions')).toBeVisible();
63
- });
64
-
65
- const component = getByText('Actions');
66
- expect(component).toHaveAttribute('data-testid', 'test');
67
- });
68
- });
@@ -1,40 +0,0 @@
1
- import React, { forwardRef } from 'react';
2
- import classNames from 'classnames';
3
- import { useMergeRefs } from '@floating-ui/react';
4
-
5
- import { Comp } from '@redsift/design-system';
6
- import { StyledDialogContentActions } from './styles';
7
- import { DialogContentActionsProps } from './types';
8
- import { useDialogContext } from '../dialog';
9
-
10
- const COMPONENT_NAME = 'DialogContentActions';
11
- const CLASSNAME = 'redsift-dialog-content-actions';
12
- const DEFAULT_PROPS: Partial<DialogContentActionsProps> = {
13
- flexDirection: 'row',
14
- };
15
-
16
- /**
17
- * The DialogContentActions component.
18
- */
19
- export const DialogContentActions: Comp<
20
- DialogContentActionsProps,
21
- HTMLDivElement
22
- > = forwardRef((props, ref) => {
23
- const { children, className, ...forwardedProps } = props;
24
-
25
- const { actionsRef, initialFocus } = useDialogContext();
26
-
27
- return (
28
- <StyledDialogContentActions
29
- {...forwardedProps}
30
- className={classNames(DialogContentActions.className, className)}
31
- ref={useMergeRefs([ref, actionsRef])}
32
- tabIndex={initialFocus === 'actions' ? -1 : undefined}
33
- >
34
- {children}
35
- </StyledDialogContentActions>
36
- );
37
- });
38
- DialogContentActions.className = CLASSNAME;
39
- DialogContentActions.defaultProps = DEFAULT_PROPS;
40
- DialogContentActions.displayName = COMPONENT_NAME;
@@ -1,2 +0,0 @@
1
- export * from './types';
2
- export * from './DialogContentActions';
@@ -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,2 +0,0 @@
1
- export * from './types';
2
- export * from './DialogContentBody';
@@ -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-body-font-family);
18
- font-size: var(--redsift-typography-body-font-size);
19
- font-weight: var(--redsift-typography-body-font-weight);
20
- line-height: var(--redsift-typography-body-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,65 +0,0 @@
1
- import React, { forwardRef } from 'react';
2
- import classNames from 'classnames';
3
- import { useMergeRefs } from '@floating-ui/react';
4
-
5
- import { Icon, Heading, Comp, useId } 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<DialogContentHeaderProps, HTMLDivElement> = forwardRef((props, ref) => {
18
- const { children, className, header, headingProps, icon, subheader, ...forwardedProps } = props;
19
-
20
- const { setLabelId, setDescriptionId, headerRef, initialFocus } = useDialogContext();
21
- const [labelId] = useId();
22
- const [descriptionId] = useId();
23
-
24
- // Only sets `aria-labelledby` on the Dialog root element
25
- // if this component is mounted inside it.
26
- React.useLayoutEffect(() => {
27
- setLabelId(labelId);
28
- return () => setLabelId(undefined);
29
- }, [labelId, setLabelId]);
30
-
31
- // Only sets `aria-describedby` on the Dialog root element
32
- // if this component is mounted inside it.
33
- React.useLayoutEffect(() => {
34
- setDescriptionId(descriptionId);
35
- return () => setDescriptionId(undefined);
36
- }, [descriptionId, setDescriptionId]);
37
-
38
- return (
39
- <StyledDialogContentHeader
40
- {...forwardedProps}
41
- className={classNames(DialogContentHeader.className, className)}
42
- ref={useMergeRefs([ref, headerRef])}
43
- tabIndex={initialFocus === 'header' ? -1 : undefined}
44
- >
45
- {subheader ? <div className={`${DialogContentHeader.className}__subheader`}>{subheader}</div> : null}
46
- {header ? (
47
- <Heading
48
- as="h2"
49
- color="black"
50
- className={`${DialogContentHeader.className}__header`}
51
- id={labelId}
52
- variant="h2"
53
- {...headingProps}
54
- >
55
- {icon ? <Icon icon={icon} aria-hidden="true" /> : null}
56
- {header}
57
- </Heading>
58
- ) : null}
59
- {children ? <div id={descriptionId}>{children}</div> : null}
60
- </StyledDialogContentHeader>
61
- );
62
- });
63
- DialogContentHeader.className = CLASSNAME;
64
- DialogContentHeader.defaultProps = DEFAULT_PROPS;
65
- DialogContentHeader.displayName = COMPONENT_NAME;
@@ -1,2 +0,0 @@
1
- export * from './types';
2
- export * from './DialogContentHeader';
@@ -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,21 +0,0 @@
1
- import { ComponentProps } from 'react';
2
- import { HeadingProps, IconProps } 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
- * Can be a string or an array of strings containing `d` property of the `path` SVG element.<br />
16
- * Can also be a ReactElement.
17
- */
18
- icon?: IconProps['icon'];
19
- }
20
-
21
- export type StyledDialogContentHeaderProps = DialogContentHeaderProps;
@@ -1,44 +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> = forwardRef((props, ref) => {
16
- const { children } = props;
17
-
18
- const { getReferenceProps, isOpen, handleOpen, refs } = useDialogContext();
19
- const childrenRef = (children as any).ref;
20
- const triggerRef = useMergeRefs([refs.setReference, ref, childrenRef]);
21
-
22
- if (
23
- isComponent('Button')(children) ||
24
- isComponent('IconButton')(children) ||
25
- isComponent('LinkButton')(children) ||
26
- isComponent('Checkbox')(children)
27
- ) {
28
- return React.cloneElement(children as ReactElement, {
29
- ...getReferenceProps({
30
- ref: triggerRef,
31
- ...props,
32
- ...children.props,
33
- children: children.props.children ?? '',
34
- }),
35
- onClick: () => handleOpen(!isOpen),
36
- isActive: isOpen,
37
- });
38
- }
39
-
40
- return <>{children}</>;
41
- });
42
- DialogTrigger.className = CLASSNAME;
43
- DialogTrigger.defaultProps = DEFAULT_PROPS;
44
- DialogTrigger.displayName = COMPONENT_NAME;
@@ -1,2 +0,0 @@
1
- export * from './types';
2
- export * from './DialogTrigger';
@@ -1,9 +0,0 @@
1
- import { ComponentProps } from 'react';
2
- import { StylingProps } from '@redsift/design-system';
3
-
4
- /**
5
- * Component props.
6
- */
7
- export interface DialogTriggerProps
8
- extends Omit<ComponentProps<'button'>, 'onClick'>,
9
- StylingProps {}