carbon-react 110.6.1 → 110.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/esm/__internal__/checkable-input/checkable-input.component.js +1 -0
  2. package/esm/__internal__/input/input.component.js +1 -0
  3. package/esm/components/accordion/accordion-group/accordion-group.component.js +1 -0
  4. package/esm/components/alert/alert.component.d.ts +1 -1
  5. package/esm/components/alert/alert.component.js +9 -4
  6. package/esm/components/alert/index.d.ts +1 -1
  7. package/esm/components/dialog/dialog.component.d.ts +59 -0
  8. package/esm/components/dialog/dialog.component.js +52 -84
  9. package/esm/components/dialog/dialog.config.d.ts +5 -0
  10. package/esm/components/dialog/dialog.style.d.ts +25 -0
  11. package/esm/components/dialog/index.d.ts +2 -1
  12. package/esm/components/dialog/index.js +1 -1
  13. package/esm/components/dismissible-box/dismissible-box.component.js +40 -0
  14. package/esm/components/form/__internal__/form-summary.component.js +16 -9
  15. package/esm/components/form/__internal__/form-summary.d.ts +2 -0
  16. package/esm/components/form/__internal__/form-summary.style.js +11 -2
  17. package/esm/components/form/form.component.js +23 -4
  18. package/esm/components/form/form.config.d.ts +1 -0
  19. package/esm/components/form/form.d.ts +2 -0
  20. package/esm/components/form/form.style.d.ts +6 -0
  21. package/esm/components/form/form.style.js +17 -3
  22. package/esm/components/global-header/global-header.component.js +16 -0
  23. package/esm/components/grid/grid-container/grid-container.component.js +25 -0
  24. package/esm/components/grid/grid-item/grid-item.component.js +13 -0
  25. package/esm/components/image/image.component.js +30 -0
  26. package/esm/components/modal/modal.component.d.ts +2 -0
  27. package/esm/components/modal/modal.component.js +1 -0
  28. package/esm/components/multi-action-button/multi-action-button.component.js +1 -0
  29. package/esm/components/navigation-bar/navigation-bar.component.js +16 -0
  30. package/esm/components/search/search.style.d.ts +4 -0
  31. package/esm/components/split-button/split-button.component.js +1 -0
  32. package/esm/components/textarea/textarea.style.d.ts +3 -0
  33. package/esm/components/textbox/textbox.component.js +1 -0
  34. package/lib/__internal__/checkable-input/checkable-input.component.js +1 -0
  35. package/lib/__internal__/input/input.component.js +1 -0
  36. package/lib/components/accordion/accordion-group/accordion-group.component.js +1 -0
  37. package/lib/components/alert/alert.component.d.ts +1 -1
  38. package/lib/components/alert/alert.component.js +9 -4
  39. package/lib/components/alert/index.d.ts +1 -1
  40. package/lib/components/dialog/dialog.component.d.ts +59 -0
  41. package/lib/components/dialog/dialog.component.js +53 -85
  42. package/lib/components/dialog/dialog.config.d.ts +5 -0
  43. package/lib/components/dialog/dialog.style.d.ts +25 -0
  44. package/lib/components/dialog/index.d.ts +2 -1
  45. package/lib/components/dialog/index.js +2 -2
  46. package/lib/components/dismissible-box/dismissible-box.component.js +40 -0
  47. package/lib/components/form/__internal__/form-summary.component.js +16 -9
  48. package/lib/components/form/__internal__/form-summary.d.ts +2 -0
  49. package/lib/components/form/__internal__/form-summary.style.js +11 -2
  50. package/lib/components/form/form.component.js +22 -3
  51. package/lib/components/form/form.config.d.ts +1 -0
  52. package/lib/components/form/form.d.ts +2 -0
  53. package/lib/components/form/form.style.d.ts +6 -0
  54. package/lib/components/form/form.style.js +19 -4
  55. package/lib/components/global-header/global-header.component.js +16 -0
  56. package/lib/components/grid/grid-container/grid-container.component.js +25 -0
  57. package/lib/components/grid/grid-item/grid-item.component.js +13 -0
  58. package/lib/components/image/image.component.js +30 -0
  59. package/lib/components/modal/modal.component.d.ts +2 -0
  60. package/lib/components/modal/modal.component.js +1 -0
  61. package/lib/components/multi-action-button/multi-action-button.component.js +1 -0
  62. package/lib/components/navigation-bar/navigation-bar.component.js +16 -0
  63. package/lib/components/search/search.style.d.ts +4 -0
  64. package/lib/components/split-button/split-button.component.js +1 -0
  65. package/lib/components/textarea/textarea.style.d.ts +3 -0
  66. package/lib/components/textbox/textbox.component.js +1 -0
  67. package/package.json +4 -9
  68. package/esm/components/dialog/dialog.d.ts +0 -68
  69. package/lib/components/dialog/dialog.d.ts +0 -68
@@ -400,6 +400,7 @@ CheckableInput.propTypes = {
400
400
  "role": PropTypes.oneOfType([PropTypes.oneOf(["alert", "alertdialog", "application", "article", "banner", "button", "cell", "checkbox", "columnheader", "combobox", "complementary", "contentinfo", "definition", "dialog", "directory", "document", "feed", "figure", "form", "grid", "gridcell", "group", "heading", "img", "link", "list", "listbox", "listitem", "log", "main", "marquee", "math", "menu", "menubar", "menuitem", "menuitemcheckbox", "menuitemradio", "navigation", "none", "note", "option", "presentation", "progressbar", "radio", "radiogroup", "region", "row", "rowgroup", "rowheader", "scrollbar", "search", "searchbox", "separator", "slider", "spinbutton", "status", "switch", "tab", "table", "tablist", "tabpanel", "term", "textbox", "timer", "toolbar", "tooltip", "tree", "treegrid", "treeitem"]), PropTypes.shape({
401
401
  "__@iterator": PropTypes.func.isRequired,
402
402
  "anchor": PropTypes.func.isRequired,
403
+ "at": PropTypes.func.isRequired,
403
404
  "big": PropTypes.func.isRequired,
404
405
  "blink": PropTypes.func.isRequired,
405
406
  "bold": PropTypes.func.isRequired,
@@ -434,6 +434,7 @@ Input.propTypes = {
434
434
  "role": PropTypes.oneOfType([PropTypes.oneOf(["alert", "alertdialog", "application", "article", "banner", "button", "cell", "checkbox", "columnheader", "combobox", "complementary", "contentinfo", "definition", "dialog", "directory", "document", "feed", "figure", "form", "grid", "gridcell", "group", "heading", "img", "link", "list", "listbox", "listitem", "log", "main", "marquee", "math", "menu", "menubar", "menuitem", "menuitemcheckbox", "menuitemradio", "navigation", "none", "note", "option", "presentation", "progressbar", "radio", "radiogroup", "region", "row", "rowgroup", "rowheader", "scrollbar", "search", "searchbox", "separator", "slider", "spinbutton", "status", "switch", "tab", "table", "tablist", "tabpanel", "term", "textbox", "timer", "toolbar", "tooltip", "tree", "treegrid", "treeitem"]), PropTypes.shape({
435
435
  "__@iterator": PropTypes.func.isRequired,
436
436
  "anchor": PropTypes.func.isRequired,
437
+ "at": PropTypes.func.isRequired,
437
438
  "big": PropTypes.func.isRequired,
438
439
  "blink": PropTypes.func.isRequired,
439
440
  "bold": PropTypes.func.isRequired,
@@ -71,6 +71,7 @@ AccordionGroup.propTypes = {
71
71
  "children": PropTypes.oneOfType([PropTypes.element, PropTypes.shape({
72
72
  "__@iterator": PropTypes.func.isRequired,
73
73
  "__@unscopables": PropTypes.func.isRequired,
74
+ "at": PropTypes.func.isRequired,
74
75
  "concat": PropTypes.func.isRequired,
75
76
  "copyWithin": PropTypes.func.isRequired,
76
77
  "entries": PropTypes.func.isRequired,
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
- import { DialogProps } from "../dialog/dialog";
2
+ import { DialogProps } from "../dialog";
3
3
  export declare const Alert: ({ children, size, ...rest }: DialogProps) => JSX.Element;
4
4
  export default Alert;
@@ -19,34 +19,39 @@ Alert.propTypes = {
19
19
  "aria-label": PropTypes.string,
20
20
  "aria-labelledby": PropTypes.string,
21
21
  "ariaRole": PropTypes.string,
22
+ "bespokeFocusTrap": PropTypes.func,
22
23
  "children": PropTypes.node,
24
+ "className": PropTypes.string,
23
25
  "contentPadding": PropTypes.shape({
24
26
  "p": PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]),
25
27
  "px": PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]),
26
28
  "py": PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8])
27
29
  }),
30
+ "data-component": PropTypes.string,
31
+ "data-element": PropTypes.string,
32
+ "data-role": PropTypes.string,
28
33
  "disableAutoFocus": PropTypes.bool,
29
34
  "disableClose": PropTypes.bool,
30
35
  "disableEscKey": PropTypes.bool,
31
36
  "disableFocusTrap": PropTypes.bool,
32
37
  "enableBackgroundUI": PropTypes.bool,
33
38
  "focusableContainers": PropTypes.arrayOf(PropTypes.shape({
34
- "current": function (props, propName) {
39
+ "current": PropTypes.oneOfType([PropTypes.oneOf([null]), function (props, propName) {
35
40
  if (props[propName] == null) {
36
41
  return new Error("Prop '" + propName + "' is required but wasn't specified");
37
42
  } else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
38
43
  return new Error("Expected prop '" + propName + "' to be of type Element");
39
44
  }
40
- }
45
+ }]).isRequired
41
46
  })),
42
47
  "focusFirstElement": PropTypes.shape({
43
- "current": function (props, propName) {
48
+ "current": PropTypes.oneOfType([PropTypes.oneOf([null]), function (props, propName) {
44
49
  if (props[propName] == null) {
45
50
  return new Error("Prop '" + propName + "' is required but wasn't specified");
46
51
  } else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
47
52
  return new Error("Expected prop '" + propName + "' to be of type Element");
48
53
  }
49
- }
54
+ }]).isRequired
50
55
  }),
51
56
  "height": PropTypes.string,
52
57
  "help": PropTypes.string,
@@ -1,2 +1,2 @@
1
1
  export { default } from "./alert.component";
2
- export type { DialogProps as AlertProps } from "../dialog/dialog";
2
+ export type { DialogProps as AlertProps } from "../dialog";
@@ -0,0 +1,59 @@
1
+ import React from "react";
2
+ import { ModalProps } from "../modal";
3
+ import { TagProps } from "../../__internal__/utils/helpers/tags/tags";
4
+ declare type PaddingValues = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
5
+ export interface ContentPaddingInterface {
6
+ p?: PaddingValues;
7
+ py?: PaddingValues;
8
+ px?: PaddingValues;
9
+ }
10
+ declare type DialogSizes = "auto" | "extra-small" | "small" | "medium-small" | "medium" | "medium-large" | "large" | "extra-large";
11
+ export interface DialogProps extends ModalProps, TagProps {
12
+ /** Custom class name */
13
+ className?: string;
14
+ /** Prop to specify the aria-describedby property of the Dialog component */
15
+ "aria-describedby"?: string;
16
+ /**
17
+ * Prop to specify the aria-label of the Dialog component.
18
+ * To be used only when the title prop is not defined, and the component is not labelled by any internal element.
19
+ */
20
+ "aria-label"?: string;
21
+ /**
22
+ * Prop to specify the aria-labelledby property of the Dialog component
23
+ * To be used when the title prop is a custom React Node,
24
+ * or the component is labelled by an internal element other than the title.
25
+ */
26
+ "aria-labelledby"?: string;
27
+ disableAutoFocus?: boolean;
28
+ disableFocusTrap?: boolean;
29
+ /**
30
+ * Function to replace focus trap
31
+ * @ignore
32
+ * @private
33
+ */
34
+ bespokeFocusTrap?: (ev: KeyboardEvent, firstElement?: HTMLElement, lastElement?: HTMLElement) => void;
35
+ /** Optional reference to an element meant to be focused on open */
36
+ focusFirstElement?: React.MutableRefObject<HTMLElement | null>;
37
+ /** Allows developers to specify a specific height for the dialog. */
38
+ height?: string;
39
+ /** Adds Help tooltip to Header */
40
+ help?: string;
41
+ /** A custom close event handler */
42
+ onCancel?: (ev: React.KeyboardEvent<HTMLElement> | React.MouseEvent<HTMLButtonElement>) => void;
43
+ /** Determines if the close icon is shown */
44
+ showCloseIcon?: boolean;
45
+ /** Size of dialog, default size is 750px */
46
+ size?: DialogSizes;
47
+ /** Subtitle displayed at top of dialog */
48
+ subtitle?: string;
49
+ /** Title displayed at top of dialog */
50
+ title?: React.ReactNode;
51
+ /** The ARIA role to be applied to the Dialog container */
52
+ role?: string;
53
+ /** Padding to be set on the Dialog content */
54
+ contentPadding?: ContentPaddingInterface;
55
+ /** an optional array of refs to containers whose content should also be reachable by tabbing from the dialog */
56
+ focusableContainers?: React.MutableRefObject<HTMLElement | null>[];
57
+ }
58
+ export declare const Dialog: ({ className, children, open, height, size, title, disableEscKey, subtitle, disableAutoFocus, focusFirstElement, onCancel, showCloseIcon, bespokeFocusTrap, disableClose, help, role, contentPadding, focusableContainers, ...rest }: DialogProps) => JSX.Element;
59
+ export default Dialog;
@@ -18,14 +18,14 @@ const Dialog = ({
18
18
  children,
19
19
  open,
20
20
  height,
21
- size,
21
+ size = "medium",
22
22
  title,
23
23
  disableEscKey,
24
24
  subtitle,
25
- disableAutoFocus,
25
+ disableAutoFocus = false,
26
26
  focusFirstElement,
27
27
  onCancel,
28
- showCloseIcon,
28
+ showCloseIcon = true,
29
29
  bespokeFocusTrap,
30
30
  disableClose,
31
31
  help,
@@ -46,6 +46,11 @@ const Dialog = ({
46
46
  current: subtitleId
47
47
  } = useRef(createGuid());
48
48
  const centerDialog = useCallback(() => {
49
+ /* istanbul ignore if */
50
+ if (!dialogRef.current) {
51
+ return;
52
+ }
53
+
49
54
  const {
50
55
  width: dialogWidth,
51
56
  height: dialogHeight
@@ -174,91 +179,54 @@ const Dialog = ({
174
179
  };
175
180
 
176
181
  Dialog.propTypes = {
177
- /** Prop to specify the aria-describedby property of the Dialog component */
178
182
  "aria-describedby": PropTypes.string,
179
-
180
- /**
181
- * Prop to specify the aria-label of the Dialog component.
182
- * To be used only when the title prop is not defined, and the component is not labelled by any internal element.
183
- */
184
183
  "aria-label": PropTypes.string,
185
-
186
- /**
187
- * Prop to specify the aria-labelledby property of the Dialog component
188
- * To be used when the title prop is a custom React Node,
189
- * or the component is labelled by an internal element other than the title.
190
- */
191
184
  "aria-labelledby": PropTypes.string,
192
-
193
- /** Dialog content */
194
- children: PropTypes.node,
195
-
196
- /** Custom class name */
197
- className: PropTypes.string,
198
-
199
- /** Controls the open state of the component */
200
- open: PropTypes.bool.isRequired,
201
-
202
- /** A custom close event handler */
203
- onCancel: PropTypes.func,
204
-
205
- /** Determines if the Esc Key closes the Dialog */
206
- disableEscKey: PropTypes.bool,
207
-
208
- /** Determines if the Dialog can be closed */
209
- disableClose: PropTypes.bool,
210
-
211
- /** Allows developers to specify a specific height for the dialog. */
212
- height: PropTypes.string,
213
-
214
- /** Adds Help tooltip to Header */
215
- help: PropTypes.string,
216
-
217
- /** Title displayed at top of dialog */
218
- title: PropTypes.node,
219
-
220
- /** Subtitle displayed at top of dialog */
221
- subtitle: PropTypes.string,
222
-
223
- /** Size of dialog, default size is 750px */
224
- size: PropTypes.oneOf(["auto", "extra-small", "small", "medium-small", "medium", "medium-large", "large", "extra-large"]),
225
-
226
- /** Determines if the close icon is shown */
227
- showCloseIcon: PropTypes.bool,
228
-
229
- /** Optional reference to an element meant to be focused on open */
230
- focusFirstElement: PropTypes.shape({
231
- current: PropTypes.any
185
+ "ariaRole": PropTypes.string,
186
+ "bespokeFocusTrap": PropTypes.func,
187
+ "children": PropTypes.node,
188
+ "className": PropTypes.string,
189
+ "contentPadding": PropTypes.shape({
190
+ "p": PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]),
191
+ "px": PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]),
192
+ "py": PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8])
232
193
  }),
233
-
234
- /** Disables auto focus functionality on child elements */
235
- disableAutoFocus: PropTypes.bool,
236
-
237
- /**
238
- * Function to replace focus trap
239
- * @ignore
240
- * @private
241
- */
242
- bespokeFocusTrap: PropTypes.func,
243
-
244
- /** The ARIA role to be applied to the Dialog container */
245
- role: PropTypes.string,
246
-
247
- /** Padding to be set on the Dialog content */
248
- contentPadding: PropTypes.shape({
249
- p: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]),
250
- px: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]),
251
- py: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8])
194
+ "data-component": PropTypes.string,
195
+ "data-element": PropTypes.string,
196
+ "data-role": PropTypes.string,
197
+ "disableAutoFocus": PropTypes.bool,
198
+ "disableClose": PropTypes.bool,
199
+ "disableEscKey": PropTypes.bool,
200
+ "disableFocusTrap": PropTypes.bool,
201
+ "enableBackgroundUI": PropTypes.bool,
202
+ "focusableContainers": PropTypes.arrayOf(PropTypes.shape({
203
+ "current": PropTypes.oneOfType([PropTypes.oneOf([null]), function (props, propName) {
204
+ if (props[propName] == null) {
205
+ return new Error("Prop '" + propName + "' is required but wasn't specified");
206
+ } else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
207
+ return new Error("Expected prop '" + propName + "' to be of type Element");
208
+ }
209
+ }]).isRequired
210
+ })),
211
+ "focusFirstElement": PropTypes.shape({
212
+ "current": PropTypes.oneOfType([PropTypes.oneOf([null]), function (props, propName) {
213
+ if (props[propName] == null) {
214
+ return new Error("Prop '" + propName + "' is required but wasn't specified");
215
+ } else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
216
+ return new Error("Expected prop '" + propName + "' to be of type Element");
217
+ }
218
+ }]).isRequired
252
219
  }),
253
-
254
- /** an optional array of refs to containers whose content should also be reachable by tabbing from the dialog */
255
- focusableContainers: PropTypes.arrayOf(PropTypes.shape({
256
- current: PropTypes.any
257
- }))
258
- };
259
- Dialog.defaultProps = {
260
- size: "medium",
261
- showCloseIcon: true,
262
- disableAutoFocus: false
220
+ "height": PropTypes.string,
221
+ "help": PropTypes.string,
222
+ "onCancel": PropTypes.func,
223
+ "open": PropTypes.bool.isRequired,
224
+ "role": PropTypes.string,
225
+ "showCloseIcon": PropTypes.bool,
226
+ "size": PropTypes.oneOf(["auto", "extra-large", "extra-small", "large", "medium-large", "medium-small", "medium", "small"]),
227
+ "subtitle": PropTypes.string,
228
+ "timeout": PropTypes.number,
229
+ "title": PropTypes.node
263
230
  };
231
+ export { Dialog };
264
232
  export default Dialog;
@@ -0,0 +1,5 @@
1
+ export declare const DIALOG_SIZES: string[];
2
+ export declare const TOP_MARGIN = 20;
3
+ export declare const CONTENT_TOP_PADDING = 24;
4
+ export declare const HORIZONTAL_PADDING = 32;
5
+ export declare const CONTENT_BOTTOM_PADDING = 30;
@@ -0,0 +1,25 @@
1
+ import { ContentPaddingInterface } from "./dialog.component";
2
+ declare const dialogSizes: {
3
+ auto: string;
4
+ "extra-small": string;
5
+ small: string;
6
+ "medium-small": string;
7
+ medium: string;
8
+ "medium-large": string;
9
+ large: string;
10
+ "extra-large": string;
11
+ };
12
+ declare type DialogStyleProps = {
13
+ topMargin: number;
14
+ size?: keyof typeof dialogSizes;
15
+ dialogHeight?: string;
16
+ };
17
+ declare const DialogStyle: import("styled-components").StyledComponent<"div", any, DialogStyleProps & ContentPaddingInterface, never>;
18
+ declare type DialogTitleStyleProps = {
19
+ showCloseIcon?: boolean;
20
+ hasSubtitle?: boolean;
21
+ };
22
+ declare const DialogTitleStyle: import("styled-components").StyledComponent<"div", any, DialogTitleStyleProps, never>;
23
+ declare const DialogContentStyle: import("styled-components").StyledComponent<"div", any, ContentPaddingInterface, never>;
24
+ declare const DialogInnerContentStyle: import("styled-components").StyledComponent<"div", any, ContentPaddingInterface, never>;
25
+ export { DialogStyle, DialogTitleStyle, DialogContentStyle, DialogInnerContentStyle, };
@@ -1 +1,2 @@
1
- export { default } from "./dialog";
1
+ export { default } from "./dialog.component";
2
+ export type { DialogProps } from "./dialog.component";
@@ -1 +1 @@
1
- export { default } from "./dialog.component.js";
1
+ export { default } from "./dialog.component";