@hazelcast/ui 4.0.1-canary.5 → 4.0.1-canary.6
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/lib/components/Button.d.ts +1 -0
- package/lib/components/Button.js +2 -1
- package/lib/components/Button.js.map +1 -1
- package/lib/components/Button.module.css +6 -0
- package/lib/components/Checkbox.js +1 -1
- package/lib/components/Checkbox.js.map +1 -1
- package/lib/components/Checkbox.module.css +97 -0
- package/lib/components/Modal.d.ts +19 -2
- package/lib/components/Modal.js +56 -25
- package/lib/components/Modal.js.map +1 -1
- package/lib/components/Modal.module.css +222 -0
- package/lib/old/Checkbox.d.ts +35 -0
- package/lib/old/Checkbox.js +38 -0
- package/lib/old/Checkbox.js.map +1 -0
- package/lib/old/CheckboxFormik.d.ts +10 -0
- package/lib/old/CheckboxFormik.js +17 -0
- package/lib/old/CheckboxFormik.js.map +1 -0
- package/lib/old/Modal.d.ts +26 -0
- package/lib/old/Modal.js +41 -0
- package/lib/old/Modal.js.map +1 -0
- package/lib/old/index.d.ts +6 -0
- package/lib/old/index.js +3 -0
- package/lib/old/index.js.map +1 -1
- package/package.json +1 -1
- /package/lib/{components/Checkbox.module.scss → old/CheckboxLegacy.module.scss} +0 -0
- /package/lib/{components/Modal.module.scss → old/ModalLegacy.module.scss} +0 -0
|
@@ -51,6 +51,7 @@ export type ButtonCommonProps = {
|
|
|
51
51
|
tooltip?: string;
|
|
52
52
|
active?: boolean;
|
|
53
53
|
truncate?: boolean;
|
|
54
|
+
fullWidth?: boolean;
|
|
54
55
|
} & (ButtonDisabledProps | ButtonNotDisabledProps) & Pick<HTMLAttributes<HTMLAnchorElement | HTMLButtonElement>, 'className' | 'onClick' | 'tabIndex' | 'style'>;
|
|
55
56
|
export type ButtonTypeAnchorProps = {
|
|
56
57
|
component: 'a';
|
package/lib/components/Button.js
CHANGED
|
@@ -22,7 +22,7 @@ const sizeClass = {
|
|
|
22
22
|
small: styles.sizeSmall,
|
|
23
23
|
regular: styles.sizeRegular,
|
|
24
24
|
};
|
|
25
|
-
export const Button = forwardRef(({ component: Component = 'button', className, bodyClassName, outline = 'outline', children, disabled, disabledTooltip, disabledTooltipVisible, disabledTooltipPlacement, iconLeft, iconLeftAriaLabel, iconLeftColor, iconLeftClassName, iconRight, iconRightAriaLabel, iconRightColor, iconRightClassName, rel = 'noopener', target, type = 'button', loading, variant = 'contained', color = 'primary', size = 'regular', tooltip, active, truncate = true, ...rest }, ref) => {
|
|
25
|
+
export const Button = forwardRef(({ component: Component = 'button', className, bodyClassName, outline = 'outline', children, disabled, disabledTooltip, disabledTooltipVisible, disabledTooltipPlacement, iconLeft, iconLeftAriaLabel, iconLeftColor, iconLeftClassName, iconRight, iconRightAriaLabel, iconRightColor, iconRightClassName, rel = 'noopener', target, type = 'button', loading, variant = 'contained', color = 'primary', size = 'regular', tooltip, active, truncate = true, fullWidth, ...rest }, ref) => {
|
|
26
26
|
const tooltipId = useUID();
|
|
27
27
|
const iconSize = size === 'small' ? 'small' : 'smallMedium';
|
|
28
28
|
const relFinal = Array.isArray(rel) ? rel.join(' ') : rel;
|
|
@@ -31,6 +31,7 @@ export const Button = forwardRef(({ component: Component = 'button', className,
|
|
|
31
31
|
React.createElement(Component, { "data-test": "button", className: cn(styles.button, variantClass[variant], colorClass[color], sizeClass[size], {
|
|
32
32
|
[styles.active]: active,
|
|
33
33
|
[styles.inset]: outline === 'inset',
|
|
34
|
+
[styles.fullWidth]: fullWidth,
|
|
34
35
|
}, className), "aria-describedby": disabled ? tooltipId : undefined, disabled: disabled !== null && disabled !== void 0 ? disabled : loading, rel: Component === 'a' ? relFinal : undefined, target: Component === 'a' ? target : undefined, type: Component === 'button' ? type : undefined, ref: ref, ...rest },
|
|
35
36
|
React.createElement("span", { className: cn(styles.body, bodyClassName) },
|
|
36
37
|
loading && !loadingAnimationOnRight && React.createElement(Loader, { className: styles.iconLeft, size: iconSize }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAwB,UAAU,EAAgC,MAAM,OAAO,CAAA;AAC7F,OAAO,EAAE,MAAM,YAAY,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAElC,OAAO,EAAE,IAAI,EAAuB,MAAM,QAAQ,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAe,MAAM,WAAW,CAAA;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGjC,OAAO,MAAM,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAwB,UAAU,EAAgC,MAAM,OAAO,CAAA;AAC7F,OAAO,EAAE,MAAM,YAAY,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAElC,OAAO,EAAE,IAAI,EAAuB,MAAM,QAAQ,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAe,MAAM,WAAW,CAAA;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGjC,OAAO,MAAM,MAAM,qBAAqB,CAAA;AAwFxC,MAAM,YAAY,GAAkC;IAClD,SAAS,EAAE,MAAM,CAAC,gBAAgB;IAClC,QAAQ,EAAE,MAAM,CAAC,eAAe;IAChC,KAAK,EAAE,MAAM,CAAC,YAAY;IAC1B,IAAI,EAAE,MAAM,CAAC,WAAW;CACzB,CAAA;AAED,MAAM,UAAU,GAAgC;IAC9C,OAAO,EAAE,MAAM,CAAC,YAAY;IAC5B,SAAS,EAAE,MAAM,CAAC,cAAc;IAChC,OAAO,EAAE,MAAM,CAAC,Y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Q,EAAE,iBAAiB,CAAC,EAC1D,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,aAAa,GACpB,CACH;gBACA,QAAQ,CAAC,CAAC,CAAC,CACV,oBAAC,aAAa,IAAC,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,IAAI,sBAAsB,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,GAAI,CACpH,CAAC,CAAC,CAAC,CACF,QAAQ,CACT;gBACA,uBAAuB,IAAI,oBAAC,MAAM,IAAC,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,GAAI;gBAClF,CAAC,uBAAuB,IAAI,SAAS,IAAI,kBAAkB,IAAI,CAC9D,oBAAC,IAAI,IACH,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,kBAAkB,eACnB,mBAAmB,EAC7B,kBAAkB,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,kBAAkB,CAAC,EAC5D,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,cAAc,GACrB,CACH,CACI,CACG,CACJ,CACX,CAAA;AACH,CAAC,CACF,CAAA;AAED,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAA"}
|
|
@@ -4,7 +4,7 @@ import { useUID } from 'react-uid';
|
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import { Error, errorId } from './Error';
|
|
6
6
|
import { Help, helpTooltipId } from './Help';
|
|
7
|
-
import styles from './Checkbox.module.
|
|
7
|
+
import styles from './Checkbox.module.css';
|
|
8
8
|
import { TruncatedText } from './TruncatedText';
|
|
9
9
|
/**
|
|
10
10
|
* ### Purpose
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../src/components/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAyC,MAAM,EAAc,UAAU,EAAE,MAAM,OAAO,CAAA;AACpG,OAAO,EAAE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E,kBAAkB,CAAC,GAAI,CACvG,CAAC,CAAC,CAAC,CACF,oBAAC,KAAK,iBAAY,GAAG,QAAQ,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE,kBAAkB,CAAC,GAAI,CACvG;YACA,UAAU,IAAI,oBAAC,IAAI,IAAC,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC,UAAU,GAAI,CACrF;QACR,oBAAC,KAAK,IAAC,SAAS,QAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,cAAc,EAAE,OAAO,EAAE,EAAE,GAAI,CAC5E,CACP,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAA"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
.wrapper {
|
|
2
|
+
--checkbox-size: calc(var(--hive-grid) * 4);
|
|
3
|
+
--checkbox-radius: calc(var(--hive-grid) * 1);
|
|
4
|
+
--checkbox-padding: 1px;
|
|
5
|
+
--checkbox-transition-duration: 120ms;
|
|
6
|
+
--checkbox-shadow: 0 1px 2px oklch(0 0 0 / 0.05);
|
|
7
|
+
--checkbox-shadow-checked: 0 1px 1px oklch(0 0 0 / 0.05);
|
|
8
|
+
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: row;
|
|
11
|
+
align-items: center;
|
|
12
|
+
gap: calc(var(--hive-grid) * 2);
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
color: var(--hive-color-text-v4);
|
|
16
|
+
font-family: var(--hive-font-family-text);
|
|
17
|
+
font-size: var(--hive-font-size-body-small);
|
|
18
|
+
font-weight: var(--hive-font-weight-text-regular);
|
|
19
|
+
line-height: var(--hive-line-height-body-small);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.wrapper * {
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.wrapper input {
|
|
27
|
+
position: absolute;
|
|
28
|
+
width: 1px;
|
|
29
|
+
height: 1px;
|
|
30
|
+
padding: 0;
|
|
31
|
+
margin: -1px;
|
|
32
|
+
overflow: hidden;
|
|
33
|
+
clip: rect(0, 0, 0, 0);
|
|
34
|
+
white-space: nowrap;
|
|
35
|
+
border: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.wrapper .checkmark {
|
|
39
|
+
order: -1;
|
|
40
|
+
flex-shrink: 0;
|
|
41
|
+
width: var(--checkbox-size);
|
|
42
|
+
height: var(--checkbox-size);
|
|
43
|
+
padding: var(--checkbox-padding);
|
|
44
|
+
border: var(--hive-border-width) solid var(--hive-color-border-v4);
|
|
45
|
+
border-radius: var(--checkbox-radius);
|
|
46
|
+
background-color: var(--hive-color-neutral-white-v4);
|
|
47
|
+
color: var(--hive-color-neutral-white-v4);
|
|
48
|
+
box-shadow: var(--checkbox-shadow);
|
|
49
|
+
transition:
|
|
50
|
+
background-color var(--checkbox-transition-duration) ease,
|
|
51
|
+
border-color var(--checkbox-transition-duration) ease,
|
|
52
|
+
box-shadow var(--checkbox-transition-duration) ease;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.wrapper > input:checked ~ .checkmark,
|
|
56
|
+
.wrapper.indeterminate > input ~ .checkmark {
|
|
57
|
+
background-color: var(--hive-color-primary-v4);
|
|
58
|
+
border-color: var(--hive-color-primary-v4);
|
|
59
|
+
box-shadow: var(--checkbox-shadow-checked);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.wrapper:hover > input:not(:disabled) ~ .checkmark,
|
|
63
|
+
.wrapper.hover > input:not(:disabled) ~ .checkmark {
|
|
64
|
+
border-color: var(--hive-color-primary-v4);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.wrapper.error > input ~ .checkmark {
|
|
68
|
+
border-color: var(--hive-color-error-v4);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.wrapper > input:focus-visible ~ .checkmark,
|
|
72
|
+
.wrapper.focus > input ~ .checkmark {
|
|
73
|
+
border-color: var(--hive-color-primary-v4);
|
|
74
|
+
box-shadow: 0 0 0 3px oklch(from var(--hive-color-primary-v4) l c h / 0.5);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.wrapper.disabled {
|
|
78
|
+
cursor: not-allowed;
|
|
79
|
+
opacity: 0.5;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.wrapper .name {
|
|
83
|
+
overflow: hidden;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.wrapper .helperText {
|
|
87
|
+
margin-left: calc(var(--hive-grid) * 1);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.errorContainer {
|
|
91
|
+
margin-top: calc(var(--hive-grid) * 0.5);
|
|
92
|
+
margin-left: calc(var(--hive-grid) * 6);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.withError {
|
|
96
|
+
margin-bottom: calc(var(--hive-grid) * 2);
|
|
97
|
+
}
|
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
import { FC, ReactNode } from 'react';
|
|
1
|
+
import { FC, ReactElement, ReactNode, AnchorHTMLAttributes } from 'react';
|
|
2
2
|
import { Props as ReactModalProps } from 'react-modal';
|
|
3
3
|
import { DataTestProp } from '../helpers/types';
|
|
4
4
|
import { ButtonProps, ButtonTypeButtonProps } from './Button';
|
|
5
5
|
import { IconProps } from './Icon';
|
|
6
6
|
export declare const setAppElement: (appElement: string | HTMLElement) => void;
|
|
7
7
|
export type ModalActionProps = ButtonProps<ButtonTypeButtonProps>;
|
|
8
|
+
export type ModalIntent = 'action' | 'confirm' | 'info' | 'danger' | 'success';
|
|
9
|
+
export type ModalHelperLinkProps = {
|
|
10
|
+
label: ReactNode;
|
|
11
|
+
href: string;
|
|
12
|
+
ariaLabel?: string;
|
|
13
|
+
target?: AnchorHTMLAttributes<HTMLAnchorElement>['target'];
|
|
14
|
+
rel?: AnchorHTMLAttributes<HTMLAnchorElement>['rel'];
|
|
15
|
+
};
|
|
8
16
|
export type ModalProps = {
|
|
9
17
|
actions?: ModalActionProps[];
|
|
10
18
|
hideActions?: boolean;
|
|
19
|
+
hideHeader?: boolean;
|
|
20
|
+
hideFooter?: boolean;
|
|
11
21
|
autoFocus?: boolean;
|
|
12
22
|
children?: ReactNode;
|
|
13
23
|
closable?: boolean;
|
|
@@ -18,9 +28,16 @@ export type ModalProps = {
|
|
|
18
28
|
footerClassName?: string;
|
|
19
29
|
overlayClassName?: string;
|
|
20
30
|
className?: string;
|
|
31
|
+
cancelLabel?: string | ReactElement;
|
|
21
32
|
icon?: IconProps['icon'];
|
|
22
33
|
iconAriaLabel?: IconProps['ariaLabel'];
|
|
23
34
|
onClose: ReactModalProps['onRequestClose'];
|
|
24
|
-
title
|
|
35
|
+
title?: string;
|
|
36
|
+
description?: ReactNode;
|
|
37
|
+
eyebrow?: ReactNode;
|
|
38
|
+
intent?: ModalIntent;
|
|
39
|
+
helperLink?: ModalHelperLinkProps;
|
|
40
|
+
header?: ReactNode;
|
|
41
|
+
footer?: ReactNode;
|
|
25
42
|
} & DataTestProp & Exclude<ReactModalProps, 'onRequestClose' | 'shouldFocusAfterRender' | 'shouldReturnFocusAfterClose'>;
|
|
26
43
|
export declare const Modal: FC<ModalProps>;
|
package/lib/components/Modal.js
CHANGED
|
@@ -1,41 +1,72 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import ReactModal from 'react-modal';
|
|
3
3
|
import cn from 'classnames';
|
|
4
|
-
import { X } from 'react-feather';
|
|
4
|
+
import { X, ExternalLink } from 'react-feather';
|
|
5
5
|
import { Button } from './Button';
|
|
6
6
|
import { Icon } from './Icon';
|
|
7
|
-
import
|
|
8
|
-
import styles from './Modal.module.scss';
|
|
7
|
+
import styles from './Modal.module.css';
|
|
9
8
|
// Direct re-exporting is breaking tests in MC
|
|
10
9
|
// TODO: Investigate why
|
|
11
10
|
export const setAppElement = (appElement) => ReactModal.setAppElement(appElement);
|
|
11
|
+
const intentClass = {
|
|
12
|
+
action: undefined,
|
|
13
|
+
confirm: styles.intentConfirm,
|
|
14
|
+
info: styles.intentInfo,
|
|
15
|
+
danger: styles.intentDanger,
|
|
16
|
+
success: styles.intentSuccess,
|
|
17
|
+
};
|
|
18
|
+
const intentActionColor = {
|
|
19
|
+
action: 'primary',
|
|
20
|
+
confirm: 'warning',
|
|
21
|
+
info: 'primary',
|
|
22
|
+
danger: 'danger',
|
|
23
|
+
success: 'primary',
|
|
24
|
+
};
|
|
12
25
|
/*
|
|
13
26
|
* ### Purpose
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* Usually modals are used to drive a complex action. In case there is a simple action (e.g. confirmation), consider using a Dialog.
|
|
27
|
+
* Modal surfaces a focused, secondary user-story on top of the current page. Use it for
|
|
28
|
+
* confirmations, short forms, or any flow that should pause the underlying page.
|
|
17
29
|
*
|
|
18
30
|
* ### General Info
|
|
19
|
-
* -
|
|
20
|
-
*
|
|
21
|
-
* -
|
|
22
|
-
*
|
|
31
|
+
* - Three optional sections — `header`, body (`children`) and `footer` — are independently
|
|
32
|
+
* customizable. Omit a section (or pass `hideHeader` / `hideFooter`) to remove it entirely.
|
|
33
|
+
* - The default header renders structured `title`, `eyebrow`, `description` and `icon` props.
|
|
34
|
+
* Pass a `header` ReactNode to fully replace the header section (the close button is preserved).
|
|
35
|
+
* - The default footer renders `actions` plus an optional `helperLink`. Pass a `footer`
|
|
36
|
+
* ReactNode to fully replace it, or `hideActions` / no `helperLink` to drop pieces.
|
|
37
|
+
* - Underlying page is blocked by an overlay; click overlay or press Esc to close (when `closable`).
|
|
23
38
|
*/
|
|
24
|
-
export const Modal = ({ 'data-test': dataTest = 'modal', actions, hideActions = false, autoFocus = true, children, className, closable = true, showCloseButton = true, bodyClassName, headerClassName, contentClassName, footerClassName, icon, iconAriaLabel, onClose, overlayClassName, title, ...rest }) => {
|
|
39
|
+
export const Modal = ({ 'data-test': dataTest = 'modal', actions, hideActions = false, hideHeader = false, hideFooter = false, autoFocus = true, children, className, closable = true, showCloseButton = true, bodyClassName, headerClassName, contentClassName, footerClassName, icon, iconAriaLabel, onClose, overlayClassName, cancelLabel = 'Cancel', title, description, eyebrow, intent = 'action', helperLink, header, footer, ...rest }) => {
|
|
40
|
+
var _a, _b;
|
|
25
41
|
const shouldAutoFocusCancelButton = useMemo(() => autoFocus && !(actions === null || actions === void 0 ? void 0 : actions.some((action) => action === null || action === void 0 ? void 0 : action.autoFocus)), [autoFocus, actions]);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
const hasIcon = !!(icon && iconAriaLabel);
|
|
43
|
+
const hasBody = children !== undefined && children !== null && children !== false;
|
|
44
|
+
const hasStructuredHeader = !!(title || eyebrow || description || hasIcon);
|
|
45
|
+
const hasCustomHeader = header !== undefined && header !== null && header !== false;
|
|
46
|
+
const renderHeader = !hideHeader && (hasCustomHeader || hasStructuredHeader);
|
|
47
|
+
const hasCustomFooter = footer !== undefined && footer !== null && footer !== false;
|
|
48
|
+
const hasStructuredFooter = !hideActions || !!helperLink;
|
|
49
|
+
const renderFooter = !hideFooter && (hasCustomFooter || hasStructuredFooter);
|
|
50
|
+
const renderClose = closable && showCloseButton;
|
|
51
|
+
return (React.createElement(ReactModal, { portalClassName: styles.portal, className: cn(styles.modal, intent !== 'action' && intentClass[intent], className), contentLabel: title, onRequestClose: onClose, overlayClassName: cn(styles.overlay, overlayClassName), shouldCloseOnEsc: closable, shouldCloseOnOverlayClick: closable, shouldFocusAfterRender: false, shouldReturnFocusAfterClose: true, ...rest },
|
|
52
|
+
renderClose && (React.createElement("button", { type: "button", "data-test": `${dataTest}-button-close`, className: styles.close, "aria-label": "Close icon", onClick: (e) => onClose === null || onClose === void 0 ? void 0 : onClose(e) },
|
|
53
|
+
React.createElement(X, { size: 16, "aria-hidden": true }))),
|
|
54
|
+
renderHeader &&
|
|
55
|
+
(hasCustomHeader ? (React.createElement("div", { "data-test": "modal-header", className: headerClassName }, header)) : (React.createElement("div", { "data-test": "modal-header", className: cn(styles.header, headerClassName) },
|
|
56
|
+
React.createElement("div", { className: styles.headerRow },
|
|
57
|
+
hasIcon && (React.createElement("div", { className: styles.iconBox },
|
|
58
|
+
React.createElement(Icon, { "data-test": "modal-header-icon", icon: icon, ariaLabel: iconAriaLabel }))),
|
|
59
|
+
React.createElement("div", { className: styles.headerText },
|
|
60
|
+
eyebrow && (React.createElement("p", { "data-test": "modal-header-eyebrow", className: styles.eyebrow }, eyebrow)),
|
|
61
|
+
title && (React.createElement("h3", { "data-test": "modal-header-title", className: styles.title }, title)),
|
|
62
|
+
description && (React.createElement("p", { "data-test": "modal-header-description", className: styles.description }, description))))))),
|
|
63
|
+
hasBody && (React.createElement("div", { "data-test": "modal-content", className: cn(styles.body, bodyClassName, contentClassName) }, children)),
|
|
64
|
+
renderFooter && (React.createElement("div", { "data-test": "modal-footer", className: cn(styles.footer, footerClassName) }, hasCustomFooter ? (footer) : (React.createElement(React.Fragment, null,
|
|
65
|
+
helperLink && (React.createElement("a", { "data-test": "modal-helper-link", className: styles.helperLink, href: helperLink.href, target: (_a = helperLink.target) !== null && _a !== void 0 ? _a : '_blank', rel: (_b = helperLink.rel) !== null && _b !== void 0 ? _b : 'noopener noreferrer', "aria-label": helperLink.ariaLabel },
|
|
66
|
+
helperLink.label,
|
|
67
|
+
React.createElement(ExternalLink, { size: 12, "aria-hidden": true }))),
|
|
68
|
+
!hideActions && (React.createElement("div", { className: styles.footerActions },
|
|
69
|
+
React.createElement(Button, { autoFocus: shouldAutoFocusCancelButton, "data-test": "modal-button-cancel", variant: "ghost", color: "secondary", size: "small", onClick: (e) => onClose === null || onClose === void 0 ? void 0 : onClose(e) }, cancelLabel), actions === null || actions === void 0 ? void 0 :
|
|
70
|
+
actions.map(({ children: actionChildren, size = 'small', color, ...actionPropsRest }, key) => (React.createElement(Button, { key: key, "data-test": "modal-button-action", size: size, color: color !== null && color !== void 0 ? color : intentActionColor[intent], ...actionPropsRest }, actionChildren)))))))))));
|
|
40
71
|
};
|
|
41
72
|
//# sourceMappingURL=Modal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/components/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/components/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAA+B,OAAO,EAAwB,MAAM,OAAO,CAAA;AACzF,OAAO,UAAwC,MAAM,aAAa,CAAA;AAClE,OAAO,EAAE,MAAM,YAAY,CAAA;AAC3B,OAAO,EAAE,CAAC,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAG/C,OAAO,EAAE,MAAM,EAAsC,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,IAAI,EAAa,MAAM,QAAQ,CAAA;AAExC,OAAO,MAAM,MAAM,oBAAoB,CAAA;AAEvC,8CAA8C;AAC9C,wBAAwB;AACxB,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,UAAgC,EAAE,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,UAAU,CAAC,CAAA;AA2CvG,MAAM,WAAW,GAA4C;IAC3D,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,MAAM,CAAC,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAC,UAAU;IACvB,MAAM,EAAE,MAAM,CAAC,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC,aAAa;CAC9B,CAAA;AAED,MAAM,iBAAiB,GAAmD;IACxE,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,SAAS;IACf,MAAM,EA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EAAE,wBAAgB,CACpC,CACL;YACA,CAAC,WAAW,IAAI,CACf,6BAAK,SAAS,EAAE,MAAM,CAAC,aAAa;gBAClC,oBAAC,MAAM,IACL,SAAS,EAAE,2BAA2B,eAC5B,qBAAqB,EAC/B,OAAO,EAAC,OAAO,EACf,KAAK,EAAC,WAAW,EACjB,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAG,CAAC,CAAC,IAE3B,WAAW,CACL,EACR,OAAO,aAAP,OAAO;gBAAP,OAAO,CAAE,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,IAAI,GAAG,OAAO,EAAE,KAAK,EAAE,GAAG,eAAe,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAC9F,oBAAC,MAAM,IACL,GAAG,EAAE,GAAG,eACE,qBAAqB,EAC/B,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,iBAAiB,CAAC,MAAM,CAAC,KACrC,eAAe,IAElB,cAAc,CACR,CACV,CAAC,CACE,CACP,CACA,CACJ,CACG,CACP,CACU,CACd,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
.portal {
|
|
2
|
+
position: fixed;
|
|
3
|
+
inset: 0;
|
|
4
|
+
width: 100%;
|
|
5
|
+
height: 100%;
|
|
6
|
+
z-index: 1000;
|
|
7
|
+
pointer-events: none;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.portal * {
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.overlay {
|
|
15
|
+
width: 100%;
|
|
16
|
+
height: 100%;
|
|
17
|
+
background-color: oklch(0 0 0 / 0.5);
|
|
18
|
+
pointer-events: all;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.modal {
|
|
22
|
+
position: absolute;
|
|
23
|
+
left: 50%;
|
|
24
|
+
top: 50%;
|
|
25
|
+
transform: translate(-50%, -50%);
|
|
26
|
+
width: var(--hive-modal-width);
|
|
27
|
+
min-width: var(--hive-modal-min-width);
|
|
28
|
+
max-width: var(--hive-modal-max-width);
|
|
29
|
+
max-height: var(--hive-modal-max-height);
|
|
30
|
+
background-color: var(--hive-color-neutral-lighter-v4);
|
|
31
|
+
border: var(--hive-border-width) solid var(--hive-color-border-v4);
|
|
32
|
+
border-radius: var(--hive-border-radius);
|
|
33
|
+
box-shadow:
|
|
34
|
+
0 10px 15px -3px oklch(0 0 0 / 0.1),
|
|
35
|
+
0 4px 6px -4px oklch(0 0 0 / 0.1);
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
overflow: hidden;
|
|
39
|
+
z-index: 1000;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.modal:focus,
|
|
43
|
+
.modal.focus {
|
|
44
|
+
outline: transparent solid var(--hive-outline-width);
|
|
45
|
+
box-shadow:
|
|
46
|
+
0 10px 15px -3px oklch(0 0 0 / 0.1),
|
|
47
|
+
0 4px 6px -4px oklch(0 0 0 / 0.1),
|
|
48
|
+
0 0 0 3px oklch(from var(--hive-color-primary-v4) l c h / 0.5);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.header {
|
|
52
|
+
position: relative;
|
|
53
|
+
padding: calc(var(--hive-grid) * 4) calc(var(--hive-grid) * 6);
|
|
54
|
+
border-bottom: var(--hive-border-width) solid var(--hive-color-border-v4);
|
|
55
|
+
background-color: color-mix(in oklab, var(--hive-color-primary-v4) 20%, var(--hive-color-neutral-lighter-v4));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.modal.intentConfirm .header {
|
|
59
|
+
background-color: color-mix(in oklab, var(--hive-color-warning-v4) 20%, var(--hive-color-neutral-lighter-v4));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.modal.intentInfo .header {
|
|
63
|
+
background-color: color-mix(in oklab, var(--hive-color-info-v4) 20%, var(--hive-color-neutral-lighter-v4));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.modal.intentDanger .header {
|
|
67
|
+
background-color: color-mix(in oklab, var(--hive-color-error-v4) 20%, var(--hive-color-neutral-lighter-v4));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.modal.intentSuccess .header {
|
|
71
|
+
background-color: color-mix(in oklab, var(--hive-color-success-v4) 20%, var(--hive-color-neutral-lighter-v4));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.headerRow {
|
|
75
|
+
display: flex;
|
|
76
|
+
flex-direction: row;
|
|
77
|
+
align-items: flex-start;
|
|
78
|
+
gap: calc(var(--hive-grid) * 3);
|
|
79
|
+
padding-right: calc(var(--hive-grid) * 8);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.iconBox {
|
|
83
|
+
flex-shrink: 0;
|
|
84
|
+
width: calc(var(--hive-grid) * 10);
|
|
85
|
+
height: calc(var(--hive-grid) * 10);
|
|
86
|
+
display: flex;
|
|
87
|
+
align-items: center;
|
|
88
|
+
justify-content: center;
|
|
89
|
+
background-color: var(--hive-color-neutral-white-v4);
|
|
90
|
+
border: var(--hive-border-width) solid var(--hive-color-border-v4);
|
|
91
|
+
border-radius: var(--hive-border-radius);
|
|
92
|
+
color: var(--hive-color-primary-v4);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.modal.intentConfirm .iconBox {
|
|
96
|
+
color: var(--hive-color-warning-v4);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.modal.intentInfo .iconBox {
|
|
100
|
+
color: var(--hive-color-info-v4);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.modal.intentDanger .iconBox {
|
|
104
|
+
color: var(--hive-color-error-v4);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.modal.intentSuccess .iconBox {
|
|
108
|
+
color: var(--hive-color-success-v4);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.headerText {
|
|
112
|
+
flex: 1;
|
|
113
|
+
min-width: 0;
|
|
114
|
+
display: flex;
|
|
115
|
+
flex-direction: column;
|
|
116
|
+
gap: calc(var(--hive-grid) * 1);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.eyebrow {
|
|
120
|
+
font-family: var(--hive-font-family-text);
|
|
121
|
+
font-size: var(--hive-font-size-body-tiny);
|
|
122
|
+
line-height: var(--hive-line-height-body-tiny);
|
|
123
|
+
font-weight: var(--hive-font-weight-text-regular);
|
|
124
|
+
color: var(--hive-color-text-secondary-v4);
|
|
125
|
+
text-transform: uppercase;
|
|
126
|
+
margin: 0;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.title {
|
|
130
|
+
font-family: var(--hive-font-family-text);
|
|
131
|
+
font-size: var(--hive-font-size-h3);
|
|
132
|
+
line-height: var(--hive-line-height-h3);
|
|
133
|
+
font-weight: var(--hive-font-weight-text-bold);
|
|
134
|
+
color: var(--hive-color-text-v4);
|
|
135
|
+
margin: 0;
|
|
136
|
+
word-break: break-word;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.description {
|
|
140
|
+
font-family: var(--hive-font-family-text);
|
|
141
|
+
font-size: var(--hive-font-size-body-smaller);
|
|
142
|
+
line-height: var(--hive-line-height-body-smaller);
|
|
143
|
+
color: var(--hive-color-text-secondary-v4);
|
|
144
|
+
margin: 0;
|
|
145
|
+
margin-top: calc(var(--hive-grid) * 2);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.close {
|
|
149
|
+
position: absolute;
|
|
150
|
+
top: calc(var(--hive-grid) * 4);
|
|
151
|
+
right: calc(var(--hive-grid) * 4);
|
|
152
|
+
opacity: 0.7;
|
|
153
|
+
background: none;
|
|
154
|
+
border: 0;
|
|
155
|
+
padding: 0;
|
|
156
|
+
cursor: pointer;
|
|
157
|
+
display: inline-flex;
|
|
158
|
+
align-items: center;
|
|
159
|
+
justify-content: center;
|
|
160
|
+
width: calc(var(--hive-grid) * 4);
|
|
161
|
+
height: calc(var(--hive-grid) * 4);
|
|
162
|
+
color: var(--hive-color-text-v4);
|
|
163
|
+
border-radius: var(--hive-border-radius);
|
|
164
|
+
z-index: 1;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.close:hover,
|
|
168
|
+
.close:focus-visible {
|
|
169
|
+
opacity: 1;
|
|
170
|
+
outline: none;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.close:focus-visible {
|
|
174
|
+
box-shadow: 0 0 0 3px oklch(from var(--hive-color-primary-v4) l c h / 0.5);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.body {
|
|
178
|
+
padding: calc(var(--hive-grid) * 5) calc(var(--hive-grid) * 6);
|
|
179
|
+
overflow: auto;
|
|
180
|
+
flex: 1;
|
|
181
|
+
color: var(--hive-color-text-v4);
|
|
182
|
+
font-family: var(--hive-font-family-text);
|
|
183
|
+
font-size: var(--hive-font-size-body-small);
|
|
184
|
+
line-height: var(--hive-line-height-body-small);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.footer {
|
|
188
|
+
display: flex;
|
|
189
|
+
flex-direction: row;
|
|
190
|
+
align-items: center;
|
|
191
|
+
justify-content: space-between;
|
|
192
|
+
gap: calc(var(--hive-grid) * 3);
|
|
193
|
+
padding: calc(var(--hive-grid) * 3) calc(var(--hive-grid) * 6);
|
|
194
|
+
background-color: var(--hive-color-surface-hover-v4);
|
|
195
|
+
border-top: var(--hive-border-width) solid var(--hive-color-border-v4);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.footerActions {
|
|
199
|
+
display: flex;
|
|
200
|
+
flex-direction: row;
|
|
201
|
+
align-items: center;
|
|
202
|
+
gap: calc(var(--hive-grid) * 2);
|
|
203
|
+
margin-left: auto;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.helperLink {
|
|
207
|
+
display: inline-flex;
|
|
208
|
+
align-items: center;
|
|
209
|
+
gap: calc(var(--hive-grid) * 1);
|
|
210
|
+
font-family: var(--hive-font-family-text);
|
|
211
|
+
font-size: var(--hive-font-size-body-smaller);
|
|
212
|
+
line-height: var(--hive-line-height-body-smaller);
|
|
213
|
+
color: var(--hive-color-text-secondary-v4);
|
|
214
|
+
text-decoration: none;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.helperLink:hover,
|
|
218
|
+
.helperLink:focus-visible {
|
|
219
|
+
text-decoration: underline;
|
|
220
|
+
color: var(--hive-color-text-v4);
|
|
221
|
+
outline: none;
|
|
222
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { ChangeEvent, FocusEvent, ReactElement, MouseEvent } from 'react';
|
|
2
|
+
import { HelpProps } from '../components/Help';
|
|
3
|
+
import { DataTestProp } from '../helpers/types';
|
|
4
|
+
type CheckboxCoreProps = {
|
|
5
|
+
name: string;
|
|
6
|
+
value?: string;
|
|
7
|
+
onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
|
|
8
|
+
onChange: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
9
|
+
onClick?: (e: MouseEvent<HTMLInputElement>) => void;
|
|
10
|
+
error?: string;
|
|
11
|
+
checked?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type CheckboxExtraProps = {
|
|
14
|
+
label?: ReactElement | string;
|
|
15
|
+
helperText?: HelpProps['helperText'];
|
|
16
|
+
indeterminate?: boolean;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
className?: string;
|
|
20
|
+
classNameLabel?: string;
|
|
21
|
+
'aria-label'?: string;
|
|
22
|
+
classNameCheckmark?: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* ### Purpose
|
|
26
|
+
* Forms require input from users. If you need information that can be represented as boolean, use input with type 'checkbox'.
|
|
27
|
+
* Checkbox fields accept boolean types of data. And help and error guidance to ensure they know what to enter.
|
|
28
|
+
*
|
|
29
|
+
*
|
|
30
|
+
* ### General Info
|
|
31
|
+
* - It's important to realise that we don't set checkbox value, but state (on/off). That is the main difference from other input types.
|
|
32
|
+
* - They can have a special indeterminate state, that represents a '3rd' value, usually used in tree structures, etc.
|
|
33
|
+
*/
|
|
34
|
+
export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxCoreProps & CheckboxExtraProps & DataTestProp & React.RefAttributes<HTMLDivElement>>;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { useRef, forwardRef } from 'react';
|
|
2
|
+
import { Check, Minus } from 'react-feather';
|
|
3
|
+
import { useUID } from 'react-uid';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { Error, errorId } from '../components/Error';
|
|
6
|
+
import { Help, helpTooltipId } from '../components/Help';
|
|
7
|
+
import styles from './CheckboxLegacy.module.scss';
|
|
8
|
+
import { TruncatedText } from '../components/TruncatedText';
|
|
9
|
+
/**
|
|
10
|
+
* ### Purpose
|
|
11
|
+
* Forms require input from users. If you need information that can be represented as boolean, use input with type 'checkbox'.
|
|
12
|
+
* Checkbox fields accept boolean types of data. And help and error guidance to ensure they know what to enter.
|
|
13
|
+
*
|
|
14
|
+
*
|
|
15
|
+
* ### General Info
|
|
16
|
+
* - It's important to realise that we don't set checkbox value, but state (on/off). That is the main difference from other input types.
|
|
17
|
+
* - They can have a special indeterminate state, that represents a '3rd' value, usually used in tree structures, etc.
|
|
18
|
+
*/
|
|
19
|
+
export const Checkbox = forwardRef((props, ref) => {
|
|
20
|
+
const { checked, name, onChange, onBlur, className, classNameLabel, classNameCheckmark, value, indeterminate = false, label, helperText, error, disabled = false, required, 'data-test': dataTest = 'checkbox', 'aria-label': ariaLabel, onClick, } = props;
|
|
21
|
+
const inputRef = useRef(null);
|
|
22
|
+
const id = useUID();
|
|
23
|
+
return (React.createElement("div", { ref: ref, className: classNames(className, { [styles.withError]: 'error' in props }), "data-test": dataTest },
|
|
24
|
+
React.createElement("label", { className: classNames(styles.wrapper, {
|
|
25
|
+
[styles.error]: !!error,
|
|
26
|
+
[styles.checked]: checked,
|
|
27
|
+
[styles.disabled]: disabled,
|
|
28
|
+
[styles.indeterminate]: indeterminate,
|
|
29
|
+
}, classNameLabel), htmlFor: id },
|
|
30
|
+
label !== undefined && (React.createElement("div", { className: styles.name, "data-test": "input-checkbox-label" },
|
|
31
|
+
React.createElement(TruncatedText, { text: label }))),
|
|
32
|
+
React.createElement("input", { type: "checkbox", ref: inputRef, id: id, name: name, "aria-label": ariaLabel, checked: !!checked, onChange: onChange, onBlur: onBlur, onClick: onClick, value: value, disabled: disabled, "aria-invalid": !!error, "aria-required": required, "aria-describedby": helperText && helpTooltipId(id), "aria-errormessage": error && errorId(id) }),
|
|
33
|
+
indeterminate ? (React.createElement(Minus, { "data-test": `${dataTest}-minus`, className: classNames(styles.checkmark, classNameCheckmark) })) : (React.createElement(Check, { "data-test": `${dataTest}-check`, className: classNames(styles.checkmark, classNameCheckmark) })),
|
|
34
|
+
helperText && React.createElement(Help, { parentId: id, helperText: helperText, className: styles.helperText })),
|
|
35
|
+
React.createElement(Error, { truncated: true, error: error, className: styles.errorContainer, inputId: id })));
|
|
36
|
+
});
|
|
37
|
+
Checkbox.displayName = 'Checkbox';
|
|
38
|
+
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../src/old/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAyC,MAAM,EAAc,UAAU,EAAE,MAAM,OAAO,CAAA;AACpG,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,UAAU,MAAM,YAAY,CAAA;AAEnC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,IAAI,EAAa,aAAa,EA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KAAK,GAAI,CAC1B,CACP;YACD,+BACE,IAAI,EAAC,UAAU,EACf,GAAG,EAAE,QAAQ,EACb,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,IAAI,gBACE,SAAS,EACrB,OAAO,EAAE,CAAC,CAAC,OAAO,EAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,kBACJ,CAAC,CAAC,KAAK,mBACN,QAAQ,sBACL,UAAU,IAAI,aAAa,CAAC,EAAE,CAAC,uBAC9B,KAAK,IAAI,OAAO,CAAC,EAAE,CAAC,GACvC;YACD,aAAa,CAAC,CAAC,CAAC,CACf,oBAAC,KAAK,iBAAY,GAAG,QAAQ,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE,kBAAkB,CAAC,GAAI,CACvG,CAAC,CAAC,CAAC,CACF,oBAAC,KAAK,iBAAY,GAAG,QAAQ,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE,kBAAkB,CAAC,GAAI,CACvG;YACA,UAAU,IAAI,oBAAC,IAAI,IAAC,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC,UAAU,GAAI,CACrF;QACR,oBAAC,KAAK,IAAC,SAAS,QAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,cAAc,EAAE,OAAO,EAAE,EAAE,GAAI,CAC5E,CACP,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { CheckboxExtraProps } from './Checkbox';
|
|
3
|
+
import { FieldValidatorGeneric } from '../utils/formik';
|
|
4
|
+
import { ExtractKeysOfValueType } from '../utils/types';
|
|
5
|
+
export type CheckboxFieldFormikProps<V extends object> = CheckboxExtraProps & {
|
|
6
|
+
name: ExtractKeysOfValueType<V, boolean>;
|
|
7
|
+
validate?: FieldValidatorGeneric<boolean>;
|
|
8
|
+
onChange?: (value: boolean) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare const CheckboxFormik: <V extends object>({ name, validate, onChange, ...props }: CheckboxFieldFormikProps<V>) => ReactElement;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useField } from 'formik';
|
|
3
|
+
import { Checkbox } from './Checkbox';
|
|
4
|
+
import { getFieldError } from '../utils/formik';
|
|
5
|
+
export const CheckboxFormik = ({ name, validate, onChange, ...props }) => {
|
|
6
|
+
const [{ onBlur, onChange: onFormikChange, value }, meta] = useField({
|
|
7
|
+
name,
|
|
8
|
+
validate,
|
|
9
|
+
});
|
|
10
|
+
return (React.createElement(Checkbox, { ...props, name: name, checked: value, onChange: useCallback((e) => {
|
|
11
|
+
if (onChange) {
|
|
12
|
+
onChange(e.target.checked);
|
|
13
|
+
}
|
|
14
|
+
onFormikChange(e);
|
|
15
|
+
}, [onFormikChange, onChange]), onBlur: onBlur, error: getFieldError(meta) }));
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=CheckboxFormik.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckboxFormik.js","sourceRoot":"","sources":["../../src/old/CheckboxFormik.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAgB,WAAW,EAAE,MAAM,OAAO,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAEjC,OAAO,EAAE,QAAQ,EAAsB,MAAM,YAAY,CAAA;AACzD,OAAO,EAAyB,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAStE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAmB,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,EAA+B,EAAgB,EAAE;IACpI,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,GAAG,QAAQ,CAAU;QAC5E,IAAI;QACJ,QAAQ;KACT,CAAC,CAAA;IAEF,OAAO,CACL,oBAAC,QAAQ,OACH,KAAK,EACT,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,KAAK,EACd,QAAQ,EAAE,WAAW,CACnB,CAAC,CAAC,EAAE,EAAE;YACJ,IAAI,QAAQ,EAAE,CAAC;gBACb,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;YAC5B,CAAC;YAED,cAAc,CAAC,CAAC,CAAC,CAAA;QACnB,CAAC,EACD,CAAC,cAAc,EAAE,QAAQ,CAAC,CAC3B,EACD,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,GAC1B,CACH,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { Props as ReactModalProps } from 'react-modal';
|
|
3
|
+
import { DataTestProp } from '../helpers/types';
|
|
4
|
+
import { ButtonProps, ButtonTypeButtonProps } from './Button';
|
|
5
|
+
import { IconProps } from '../components/Icon';
|
|
6
|
+
export declare const setAppElement: (appElement: string | HTMLElement) => void;
|
|
7
|
+
export type ModalActionProps = ButtonProps<ButtonTypeButtonProps>;
|
|
8
|
+
export type ModalProps = {
|
|
9
|
+
actions?: ModalActionProps[];
|
|
10
|
+
hideActions?: boolean;
|
|
11
|
+
autoFocus?: boolean;
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
closable?: boolean;
|
|
14
|
+
showCloseButton?: boolean;
|
|
15
|
+
bodyClassName?: string;
|
|
16
|
+
headerClassName?: string;
|
|
17
|
+
contentClassName?: string;
|
|
18
|
+
footerClassName?: string;
|
|
19
|
+
overlayClassName?: string;
|
|
20
|
+
className?: string;
|
|
21
|
+
icon?: IconProps['icon'];
|
|
22
|
+
iconAriaLabel?: IconProps['ariaLabel'];
|
|
23
|
+
onClose: ReactModalProps['onRequestClose'];
|
|
24
|
+
title: string;
|
|
25
|
+
} & DataTestProp & Exclude<ReactModalProps, 'onRequestClose' | 'shouldFocusAfterRender' | 'shouldReturnFocusAfterClose'>;
|
|
26
|
+
export declare const Modal: FC<ModalProps>;
|
package/lib/old/Modal.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import ReactModal from 'react-modal';
|
|
3
|
+
import cn from 'classnames';
|
|
4
|
+
import { X } from 'react-feather';
|
|
5
|
+
import { Button } from './Button';
|
|
6
|
+
import { Icon } from '../components/Icon';
|
|
7
|
+
import { IconButton } from './IconButton';
|
|
8
|
+
import styles from './ModalLegacy.module.scss';
|
|
9
|
+
// Direct re-exporting is breaking tests in MC
|
|
10
|
+
// TODO: Investigate why
|
|
11
|
+
export const setAppElement = (appElement) => ReactModal.setAppElement(appElement);
|
|
12
|
+
/*
|
|
13
|
+
* ### Purpose
|
|
14
|
+
* Occasionally there's a user-story that's not a part of the main user flow. Such action can be contained in a Modal.
|
|
15
|
+
* Modals can contain components like forms, menus, tables etc.
|
|
16
|
+
* Usually modals are used to drive a complex action. In case there is a simple action (e.g. confirmation), consider using a Dialog.
|
|
17
|
+
*
|
|
18
|
+
* ### General Info
|
|
19
|
+
* - Modal always contains a title, icon "X" in the header, content and active buttons in the footer.
|
|
20
|
+
* - No interactions on the underlying page can be performed while a Modal.
|
|
21
|
+
* - Content beneath the modal is covered by a "blanket".
|
|
22
|
+
* - To close the Modal, use "Cancel" button in the footer, "X" button in the header, press "Esc" key or click anywhere on the "blanket".
|
|
23
|
+
*/
|
|
24
|
+
export const Modal = ({ 'data-test': dataTest = 'modal', actions, hideActions = false, autoFocus = true, children, className, closable = true, showCloseButton = true, bodyClassName, headerClassName, contentClassName, footerClassName, icon, iconAriaLabel, onClose, overlayClassName, title, ...rest }) => {
|
|
25
|
+
const shouldAutoFocusCancelButton = useMemo(() => autoFocus && !(actions === null || actions === void 0 ? void 0 : actions.some((action) => action === null || action === void 0 ? void 0 : action.autoFocus)), [autoFocus, actions]);
|
|
26
|
+
return (React.createElement(ReactModal, { portalClassName: styles.portal, className: cn(styles.modal, className), contentLabel: title, onRequestClose: onClose, overlayClassName: cn(styles.overlay, overlayClassName), shouldCloseOnEsc: closable, shouldCloseOnOverlayClick: closable, shouldFocusAfterRender: false, shouldReturnFocusAfterClose: true, ...rest },
|
|
27
|
+
React.createElement("div", { className: styles.outline }),
|
|
28
|
+
React.createElement("div", { className: cn(styles.body, bodyClassName) },
|
|
29
|
+
React.createElement("div", { "data-test": "modal-header", className: cn(styles.header, headerClassName) },
|
|
30
|
+
icon && iconAriaLabel && React.createElement(Icon, { "data-test": "modal-header-icon", className: styles.icon, icon: icon, ariaLabel: iconAriaLabel }),
|
|
31
|
+
React.createElement("h3", { "data-test": "modal-header-title", className: styles.title }, title),
|
|
32
|
+
closable && showCloseButton && (
|
|
33
|
+
// Note: Mostly a Dialog use-case. We want it to be closable, but we don't want to show an X button in the corner.
|
|
34
|
+
React.createElement("div", { className: styles.close },
|
|
35
|
+
React.createElement(IconButton, { "data-test": `${dataTest}-button-close`, kind: "transparent", ariaLabel: "Close icon", icon: X, onClick: onClose })))),
|
|
36
|
+
React.createElement("div", { "data-test": "modal-content", className: cn(styles.content, contentClassName) }, children),
|
|
37
|
+
!hideActions && (React.createElement("div", { "data-test": "modal-footer", className: cn(styles.footer, footerClassName) }, actions === null || actions === void 0 ? void 0 :
|
|
38
|
+
actions.map(({ children, ...actionPropsRest }, key) => (React.createElement(Button, { key: key, "data-test": "modal-button-action", ...actionPropsRest }, children))),
|
|
39
|
+
React.createElement(Button, { autoFocus: shouldAutoFocusCancelButton, "data-test": "modal-button-cancel", variant: "outlined", color: "secondary", onClick: onClose }, "Cancel"))))));
|
|
40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YACL,CAAC,WAAW,IAAI,CACf,0CAAe,cAAc,EAAC,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,IACxE,OAAO,aAAP,OAAO;gBAAP,OAAO,CAAE,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,GAAG,eAAe,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CACvD,oBAAC,MAAM,IAAC,GAAG,EAAE,GAAG,eAAY,qBAAqB,KAAK,eAAe,IAClE,QAAQ,CACF,CACV,CAAC;gBACF,oBAAC,MAAM,IACL,SAAS,EAAE,2BAA2B,eAC5B,qBAAqB,EAC/B,OAAO,EAAC,UAAU,EAClB,KAAK,EAAC,WAAW,EACjB,OAAO,EAAE,OAAO,aAGT,CACL,CACP,CACG,CACK,CACd,CAAA;AACH,CAAC,CAAA"}
|
package/lib/old/index.d.ts
CHANGED
|
@@ -7,9 +7,15 @@ export { Button } from './Button';
|
|
|
7
7
|
export type { ButtonProps, ButtonVariant, ButtonColor, ButtonOutlineType, ButtonAccessibleIconLeftProps, ButtonAccessibleIconRightProps, ButtonDisabledProps, ButtonCommonProps, ButtonTypeAnchorProps, ButtonTypeButtonProps, ButtonTypeProps, } from './Button';
|
|
8
8
|
export { IconButton } from './IconButton';
|
|
9
9
|
export type { IconButtonProps, IconButtonKind, IconButtonDisabledProps, IconButtonNotDisabledProps } from './IconButton';
|
|
10
|
+
export { Checkbox } from './Checkbox';
|
|
11
|
+
export type { CheckboxExtraProps } from './Checkbox';
|
|
12
|
+
export { CheckboxFormik } from './CheckboxFormik';
|
|
13
|
+
export type { CheckboxFieldFormikProps } from './CheckboxFormik';
|
|
10
14
|
export { TextField } from './TextField';
|
|
11
15
|
export type { TextFieldProps, TextFieldExtraProps, TextFieldSize, TextFieldVariant, TextFieldTypes } from './TextField';
|
|
12
16
|
export { TextFieldFormik } from './TextFieldFormik';
|
|
13
17
|
export type { TextFieldFormikProps } from './TextFieldFormik';
|
|
14
18
|
export { TabContext, TabContextProvider, TabContextProviderControlled, useTabContext, TabList, Tab, TabPanel } from './Tabs';
|
|
15
19
|
export type { TabContextValue, TabContextProviderProps, TabContextProviderControlledProps, TabListProps, TabProps, TabCommonProps, AnchorTabProps, ButtonTabProps, TabPanelProps, } from './Tabs';
|
|
20
|
+
export { Modal, setAppElement } from './Modal';
|
|
21
|
+
export type { ModalProps, ModalActionProps } from './Modal';
|
package/lib/old/index.js
CHANGED
|
@@ -5,7 +5,10 @@ export { Toggle } from './Toggle';
|
|
|
5
5
|
export { ToggleFormik } from './ToggleFormik';
|
|
6
6
|
export { Button } from './Button';
|
|
7
7
|
export { IconButton } from './IconButton';
|
|
8
|
+
export { Checkbox } from './Checkbox';
|
|
9
|
+
export { CheckboxFormik } from './CheckboxFormik';
|
|
8
10
|
export { TextField } from './TextField';
|
|
9
11
|
export { TextFieldFormik } from './TextFieldFormik';
|
|
10
12
|
export { TabContext, TabContextProvider, TabContextProviderControlled, useTabContext, TabList, Tab, TabPanel } from './Tabs';
|
|
13
|
+
export { Modal, setAppElement } from './Modal';
|
|
11
14
|
//# sourceMappingURL=index.js.map
|
package/lib/old/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/old/index.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yDAAyD;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAcjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/old/index.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yDAAyD;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAcjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAY5H,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA"}
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|