@indico-data/design-system 2.46.0 → 2.47.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/lib/components/index.d.ts +1 -0
  2. package/lib/components/modal/Modal.d.ts +2 -0
  3. package/lib/components/modal/Modal.stories.d.ts +7 -0
  4. package/lib/components/modal/__tests__/Modal.test.d.ts +1 -0
  5. package/lib/components/modal/index.d.ts +1 -0
  6. package/lib/components/modal/types.d.ts +16 -0
  7. package/lib/index.css +87 -0
  8. package/lib/index.d.ts +28 -48
  9. package/lib/index.esm.css +87 -0
  10. package/lib/index.esm.js +11223 -11386
  11. package/lib/index.esm.js.map +1 -1
  12. package/lib/index.js +11221 -11385
  13. package/lib/index.js.map +1 -1
  14. package/lib/legacy/components/index.d.ts +0 -1
  15. package/package.json +1 -1
  16. package/src/components/index.ts +1 -0
  17. package/src/components/modal/Modal.mdx +121 -0
  18. package/src/components/modal/Modal.stories.tsx +286 -0
  19. package/src/components/modal/Modal.tsx +63 -0
  20. package/src/components/modal/__tests__/Modal.test.tsx +60 -0
  21. package/src/components/modal/index.ts +1 -0
  22. package/src/components/modal/styles/Modal.scss +100 -0
  23. package/src/components/modal/types.ts +16 -0
  24. package/src/index.ts +2 -8
  25. package/src/legacy/components/index.ts +0 -1
  26. package/src/setup/setupIcons.ts +2 -0
  27. package/src/styles/index.scss +1 -0
  28. package/lib/legacy/components/modals/ConfirmModal/ConfirmModal.d.ts +0 -17
  29. package/lib/legacy/components/modals/ConfirmModal/ConfirmModal.stories.d.ts +0 -44
  30. package/lib/legacy/components/modals/ConfirmModal/ConfirmModal.styles.d.ts +0 -1
  31. package/lib/legacy/components/modals/ConfirmModal/index.d.ts +0 -1
  32. package/lib/legacy/components/modals/ModalBase/ModalBase.d.ts +0 -26
  33. package/lib/legacy/components/modals/ModalBase/ModalBase.stories.d.ts +0 -9
  34. package/lib/legacy/components/modals/ModalBase/ModalBase.styles.d.ts +0 -4
  35. package/lib/legacy/components/modals/ModalBase/index.d.ts +0 -2
  36. package/lib/legacy/components/modals/index.d.ts +0 -2
  37. package/src/legacy/components/modals/ConfirmModal/ConfirmModal.stories.tsx +0 -76
  38. package/src/legacy/components/modals/ConfirmModal/ConfirmModal.styles.ts +0 -27
  39. package/src/legacy/components/modals/ConfirmModal/ConfirmModal.tsx +0 -79
  40. package/src/legacy/components/modals/ConfirmModal/index.ts +0 -1
  41. package/src/legacy/components/modals/ModalBase/ModalBase.stories.tsx +0 -45
  42. package/src/legacy/components/modals/ModalBase/ModalBase.styles.tsx +0 -72
  43. package/src/legacy/components/modals/ModalBase/ModalBase.tsx +0 -79
  44. package/src/legacy/components/modals/ModalBase/index.ts +0 -2
  45. package/src/legacy/components/modals/index.ts +0 -2
@@ -1,3 +1,2 @@
1
1
  export { BarSpinner, CirclePulse, CircleSpinner } from './loading-indicators';
2
- export { ConfirmModal, ModalBase } from './modals';
3
2
  export { Tooltip } from './Tooltip';
@@ -22,6 +22,7 @@ import {
22
22
  faFileDownload,
23
23
  faQuestionCircle,
24
24
  faCopy,
25
+ faXmark,
25
26
  } from '@fortawesome/free-solid-svg-icons';
26
27
  import { indiconDefinitions } from '@/components/icons/indicons';
27
28
 
@@ -52,6 +53,7 @@ registerFontAwesomeIcons(
52
53
  faFileDownload,
53
54
  faQuestionCircle,
54
55
  faCopy,
56
+ faXmark,
55
57
  // backwards compat, don't require registration of custom indicons
56
58
  // might want to consider doing so in the future
57
59
  ...indiconDefinitions,
@@ -22,6 +22,7 @@
22
22
  @import '../components/floatUI/styles/FloatUI.scss';
23
23
  @import '../components/forms/date/datePicker/styles/DatePicker.scss';
24
24
  @import '../components/badge/styles/Badge.scss';
25
+ @import '../components/modal/styles/Modal.scss';
25
26
 
26
27
  @import '../components/pill/styles/Pill.scss';
27
28
  @import 'sheets'; // Port to an sheets component when we build it
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- import { ModalBaseProps } from '../ModalBase';
3
- import type { PermafrostComponent } from '../../../../types';
4
- type Props = PermafrostComponent & Pick<ModalBaseProps, 'open'> & {
5
- describedBy?: string;
6
- clickOutsideHandler(e?: React.SyntheticEvent): void;
7
- confirmText?: string;
8
- message?: string | React.ReactNode;
9
- modalNode?: string;
10
- processing?: boolean;
11
- rejectText?: string;
12
- responseHandler(response: boolean, event: React.SyntheticEvent): void;
13
- title?: string | React.ReactNode;
14
- width?: number;
15
- };
16
- export declare function ConfirmModal(props: Props): import("react/jsx-runtime").JSX.Element;
17
- export {};
@@ -1,44 +0,0 @@
1
- import type { StoryObj } from '@storybook/react';
2
- import { ConfirmModal } from './ConfirmModal';
3
- declare const meta: {
4
- component: typeof ConfirmModal;
5
- title: string;
6
- args: {
7
- title: string;
8
- message: string;
9
- confirmText: string;
10
- rejectText: string;
11
- };
12
- argTypes: {
13
- open: {
14
- control: {
15
- disable: true;
16
- };
17
- };
18
- className: {
19
- control: {
20
- disable: true;
21
- };
22
- };
23
- describedBy: {
24
- control: {
25
- disable: true;
26
- };
27
- };
28
- modalNode: {
29
- control: {
30
- disable: true;
31
- };
32
- };
33
- width: {
34
- control: {
35
- disable: true;
36
- };
37
- };
38
- };
39
- };
40
- export default meta;
41
- type Story = StoryObj<typeof ConfirmModal>;
42
- export declare const Base: Story;
43
- export declare const Open: Story;
44
- export declare const processing: Story;
@@ -1 +0,0 @@
1
- export declare const StyledConfirmModal: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
@@ -1 +0,0 @@
1
- export { ConfirmModal } from './ConfirmModal';
@@ -1,26 +0,0 @@
1
- import React from 'react';
2
- import type { PermafrostComponent } from '../../../../types';
3
- export type ModalBaseProps = PermafrostComponent & {
4
- children: React.ReactNode | React.ReactNode[];
5
- clickToDismiss?(): void;
6
- describedBy?: string;
7
- node?: string;
8
- open: boolean;
9
- preventEscDismiss?: boolean;
10
- preventReturnFocus?: boolean;
11
- maxWidth?: string;
12
- } & ({
13
- labelElement: string;
14
- } | {
15
- labelText: string;
16
- });
17
- /**
18
- * Base modal component, powered by [react-modal](http://reactcommunity.org/react-modal/#usage)
19
- *
20
- * (Also see `ModalAdapter` in the styles file)
21
- *
22
- * Accessible element label must be included either as a string passed to `labelText`, or
23
- * the id of one of the children passed to `labelElement`. If a description is available,
24
- * pass that element’s id to the `describedBy` prop.
25
- */
26
- export declare function ModalBase(props: ModalBaseProps): import("react/jsx-runtime").JSX.Element;
@@ -1,9 +0,0 @@
1
- import type { StoryObj } from '@storybook/react';
2
- import { ModalBase } from './ModalBase';
3
- declare const meta: {
4
- component: typeof ModalBase;
5
- title: string;
6
- };
7
- export default meta;
8
- type Story = StoryObj<typeof ModalBase>;
9
- export declare const Base: Story;
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- declare function ModalAdapter(props: any): React.ReactElement;
3
- export declare const StyledModalBase: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<any, never>> & string & Omit<typeof ModalAdapter, keyof React.Component<any, {}, any>>;
4
- export {};
@@ -1,2 +0,0 @@
1
- export { ModalBase } from './ModalBase';
2
- export type { ModalBaseProps } from './ModalBase';
@@ -1,2 +0,0 @@
1
- export { ConfirmModal } from './ConfirmModal';
2
- export { ModalBase } from './ModalBase';
@@ -1,76 +0,0 @@
1
- import React, { useState } from 'react';
2
- import type { Meta, StoryObj } from '@storybook/react';
3
-
4
- import { ConfirmModal } from './ConfirmModal';
5
-
6
- const meta = {
7
- component: ConfirmModal,
8
- title: 'legacy/Modals/ConfirmModal',
9
- args: {
10
- title: 'Im sorry, Dave. Im afraid I cant do that.',
11
- message: 'This mission is too important for me to allow you to jeopardize it.',
12
- confirmText: 'I dont know what youre talking about, Hal.',
13
- rejectText: 'I dont know what youre talking about, Hal.',
14
- },
15
- argTypes: {
16
- open: { control: { disable: true } },
17
- className: { control: { disable: true } },
18
- describedBy: { control: { disable: true } },
19
- modalNode: { control: { disable: true } },
20
- width: { control: { disable: true } },
21
- },
22
- } satisfies Meta<typeof ConfirmModal>;
23
-
24
- export default meta;
25
- type Story = StoryObj<typeof ConfirmModal>;
26
-
27
- function StoryRender(props: any) {
28
- const [isOpen, setIsOpen] = useState<boolean>(props.open);
29
-
30
- const handleOpen = () => {
31
- setIsOpen(true);
32
- };
33
-
34
- const handleClose = () => {
35
- setIsOpen(false);
36
- };
37
-
38
- return (
39
- <>
40
- <button type="button" onClick={handleOpen}>
41
- Open the pod bay doors, HAL.
42
- </button>
43
-
44
- <ConfirmModal {...props} open={isOpen} responseHandler={handleClose} />
45
- </>
46
- );
47
- }
48
-
49
- export const Base: Story = {
50
- args: {
51
- processing: false,
52
- },
53
- render: (args) => {
54
- return <StoryRender {...args} />;
55
- },
56
- };
57
-
58
- export const Open: Story = {
59
- args: {
60
- open: true,
61
- processing: false,
62
- },
63
- render: (args) => {
64
- return <StoryRender {...args} />;
65
- },
66
- };
67
-
68
- export const processing: Story = {
69
- args: {
70
- open: true,
71
- processing: true,
72
- },
73
- render: (args) => {
74
- return <StoryRender {...args} />;
75
- },
76
- };
@@ -1,27 +0,0 @@
1
- import styled from 'styled-components';
2
-
3
- export const StyledConfirmModal = styled.div`
4
- padding: 20px;
5
-
6
- .title {
7
- margin: 30px 16px;
8
-
9
- text-align: center;
10
- }
11
-
12
- .message {
13
- text-align: center;
14
- padding-bottom: 16px;
15
- }
16
-
17
- .actions {
18
- text-align: center;
19
- padding-bottom: 40px;
20
-
21
- button {
22
- min-width: 300px;
23
- display: block;
24
- margin: 16px auto 0;
25
- }
26
- }
27
- `;
@@ -1,79 +0,0 @@
1
- // TODO: This component's migration was fast-tracked for Insights. Assess for potential refactor and documentation.
2
-
3
- import React from 'react';
4
-
5
- import { v4 as uuid } from 'uuid';
6
-
7
- import { ModalBase } from '@/legacy/components/modals/ModalBase';
8
- import { Button } from '@/components/button';
9
- import { ModalBaseProps } from '../ModalBase';
10
- import type { PermafrostComponent } from '../../../../types';
11
-
12
- import { StyledConfirmModal } from './ConfirmModal.styles';
13
-
14
- type Props = PermafrostComponent &
15
- Pick<ModalBaseProps, 'open'> & {
16
- describedBy?: string;
17
- clickOutsideHandler(e?: React.SyntheticEvent): void;
18
- confirmText?: string;
19
- message?: string | React.ReactNode;
20
- modalNode?: string;
21
- processing?: boolean;
22
- rejectText?: string;
23
- responseHandler(response: boolean, event: React.SyntheticEvent): void;
24
- title?: string | React.ReactNode;
25
- width?: number;
26
- };
27
-
28
- export function ConfirmModal(props: Props) {
29
- const id = uuid();
30
- const {
31
- className,
32
- clickOutsideHandler,
33
- confirmText,
34
- describedBy,
35
- message,
36
- modalNode,
37
- open,
38
- processing,
39
- rejectText,
40
- responseHandler,
41
- title,
42
- width,
43
- } = props;
44
-
45
- return (
46
- <ModalBase
47
- className={className}
48
- clickToDismiss={clickOutsideHandler}
49
- data-cy={props['data-cy']}
50
- describedBy={describedBy}
51
- id={props.id}
52
- labelElement={id}
53
- node={modalNode}
54
- open={open}
55
- >
56
- <StyledConfirmModal style={{ width: width || 555 }}>
57
- {title && (
58
- <div id={id} className="title">
59
- {title || 'Please confirm'}
60
- </div>
61
- )}
62
-
63
- {message && <div className="message">{message}</div>}
64
-
65
- <Button ariaLabel="confirm" onClick={(event) => responseHandler(true, event)}>
66
- {confirmText || 'Yes'}
67
- </Button>
68
-
69
- <Button
70
- variant="outline"
71
- ariaLabel="reject"
72
- onClick={(event) => responseHandler(false, event)}
73
- >
74
- {rejectText || 'No'}
75
- </Button>
76
- </StyledConfirmModal>
77
- </ModalBase>
78
- );
79
- }
@@ -1 +0,0 @@
1
- export { ConfirmModal } from './ConfirmModal';
@@ -1,45 +0,0 @@
1
- import React, { useState } from 'react';
2
- import type { Meta, StoryObj } from '@storybook/react';
3
-
4
- import { ModalBase } from './ModalBase';
5
-
6
- const meta = {
7
- component: ModalBase,
8
- title: 'legacy/Modals/ModalBase',
9
- } satisfies Meta<typeof ModalBase>;
10
-
11
- export default meta;
12
- type Story = StoryObj<typeof ModalBase>;
13
-
14
- function StoryRender(props: any) {
15
- const [isOpen, setIsOpen] = useState<boolean>(props.isOpen);
16
-
17
- const handleOpen = () => {
18
- setIsOpen(true);
19
- };
20
-
21
- const handleClose = () => {
22
- setIsOpen(false);
23
- };
24
-
25
- return (
26
- <>
27
- <button type="button" onClick={handleOpen}>
28
- open modal
29
- </button>
30
-
31
- <ModalBase {...props} open={isOpen} width="300px" clickToDismiss={handleClose}>
32
- There is nothing to this modal at all. It is completely up to you to style its contents.
33
- </ModalBase>
34
- </>
35
- );
36
- }
37
-
38
- export const Base: Story = {
39
- args: {
40
- labelText: 'my modal',
41
- },
42
- render: (args) => {
43
- return <StoryRender {...args} />;
44
- },
45
- };
@@ -1,72 +0,0 @@
1
- import React from 'react';
2
- import ReactModal from 'react-modal';
3
- import styled from 'styled-components';
4
-
5
- // see: https://github.com/reactjs/react-modal/issues/603
6
- function ModalAdapter(props: any): React.ReactElement {
7
- const { className } = props;
8
- const contentClassName = `${className}__content`;
9
- const overlayClassName = `${className}__overlay`;
10
-
11
- return (
12
- <ReactModal
13
- {...props}
14
- portalClassName={className}
15
- className={contentClassName}
16
- overlayClassName={overlayClassName}
17
- closeTimeoutMS={120}
18
- appElement={document.getElementById(props.node || 'root')}
19
- >
20
- <div className="modal-content">{props.children}</div>
21
- </ReactModal>
22
- );
23
- }
24
-
25
- export const StyledModalBase = styled(ModalAdapter)`
26
- .modal-content {
27
- background-color: var(--pf-primary-color-600);
28
- padding: var(--pf-padding-4);
29
- border-radius: var(--pf-rounded-lg);
30
- }
31
-
32
- .${(props) => props.className}__content {
33
- position: absolute;
34
- top: 70px;
35
- left: 50%;
36
- transform: translateX(-50%);
37
-
38
- overflow: visible;
39
- padding: 0;
40
-
41
- border-radius: 4px;
42
- outline: none;
43
-
44
- width: ${(props) => (props.maxWidth ? '100%' : 'auto')};
45
- max-width: ${(props) => props.maxWidth || 'none'};
46
- }
47
-
48
- .${(props) => props.className}__overlay {
49
- z-index: 900;
50
- position: absolute;
51
- top: 0;
52
- left: 0;
53
-
54
- width: 100%;
55
- height: 100%;
56
- }
57
-
58
- .ReactModal__Overlay {
59
- opacity: 0;
60
- background-color: rgba(0, 0, 0, 0.5);
61
- transition: opacity 120ms ease-in-out;
62
- }
63
-
64
- .ReactModal__Overlay--after-open {
65
- opacity: 1;
66
- position: fixed;
67
- }
68
-
69
- .ReactModal__Overlay--before-close {
70
- opacity: 0;
71
- }
72
- `;
@@ -1,79 +0,0 @@
1
- // TODO: This component's migration was fast-tracked for Insights. Assess for potential refactor and documentation.
2
-
3
- import React from 'react';
4
-
5
- import type { PermafrostComponent } from '../../../../types';
6
-
7
- import { StyledModalBase } from './ModalBase.styles';
8
-
9
- export type ModalBaseProps = PermafrostComponent & {
10
- children: React.ReactNode | React.ReactNode[];
11
- clickToDismiss?(): void;
12
- describedBy?: string;
13
- node?: string;
14
- open: boolean;
15
- preventEscDismiss?: boolean;
16
- preventReturnFocus?: boolean;
17
- maxWidth?: string;
18
- } & ({ labelElement: string } | { labelText: string });
19
-
20
- /**
21
- * Base modal component, powered by [react-modal](http://reactcommunity.org/react-modal/#usage)
22
- *
23
- * (Also see `ModalAdapter` in the styles file)
24
- *
25
- * Accessible element label must be included either as a string passed to `labelText`, or
26
- * the id of one of the children passed to `labelElement`. If a description is available,
27
- * pass that element’s id to the `describedBy` prop.
28
- */
29
- export function ModalBase(props: ModalBaseProps) {
30
- const {
31
- children,
32
- className,
33
- clickToDismiss,
34
- describedBy,
35
- id,
36
- node,
37
- open,
38
- preventEscDismiss,
39
- preventReturnFocus,
40
- maxWidth,
41
- } = props;
42
-
43
- const ariaProps = {} as { labelledby?: string; describedby?: string };
44
-
45
- if ('labelElement' in props) {
46
- ariaProps['labelledby'] = props.labelElement;
47
- }
48
-
49
- if (describedBy) {
50
- ariaProps['describedby'] = describedBy;
51
- }
52
-
53
- // Try to render modal within the theme-root, otherwise attach to the root
54
- const parentSelector = () => {
55
- const themeRoot = document.getElementById('theme-root');
56
- const root = document.getElementById('root');
57
- return themeRoot || root || document.body;
58
- };
59
-
60
- return (
61
- <StyledModalBase
62
- ariaHideApp={false}
63
- data-cy={props['data-cy']}
64
- aria={ariaProps}
65
- className={className || 'baseModal'}
66
- contentLabel={'labelText' in props ? props.labelText : null}
67
- id={id}
68
- isOpen={open}
69
- node={node}
70
- onRequestClose={clickToDismiss}
71
- parentSelector={parentSelector}
72
- shouldCloseOnEsc={!preventEscDismiss}
73
- shouldReturnFocusAfterClose={!preventReturnFocus}
74
- maxWidth={maxWidth}
75
- >
76
- {children}
77
- </StyledModalBase>
78
- );
79
- }
@@ -1,2 +0,0 @@
1
- export { ModalBase } from './ModalBase';
2
- export type { ModalBaseProps } from './ModalBase';
@@ -1,2 +0,0 @@
1
- export { ConfirmModal } from './ConfirmModal';
2
- export { ModalBase } from './ModalBase';