@carbon/react 1.41.0-rc.0 → 1.41.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.
@@ -45,7 +45,6 @@ ModalBody.propTypes = {
45
45
  /**
46
46
  * Required props for the accessibility label of the header
47
47
  */
48
- // @ts-expect-error: Built-in prop-types > TS logic doesn't jive well with custom validators
49
48
  ['aria-label']: requiredIfGivenPropIsTruthy('hasScrollingContent', PropTypes.string),
50
49
  /**
51
50
  * Specify the content to be placed in the ModalBody
@@ -6,13 +6,14 @@
6
6
  */
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React__default, { useContext, useState, useRef, useCallback, useLayoutEffect } from 'react';
9
+ import React__default, { useContext, useState, useRef, useCallback } from 'react';
10
10
  import PropTypes from 'prop-types';
11
11
  import cx from 'classnames';
12
12
  import debounce from 'lodash.debounce';
13
13
  import { usePrefix } from '../../internal/usePrefix.js';
14
14
  import { TableContext } from './TableContext.js';
15
15
  import { useWindowEvent } from '../../internal/useEvent.js';
16
+ import useIsomorphicEffect from '../../internal/useIsomorphicEffect.js';
16
17
 
17
18
  const isElementWrappingContent = (element, context) => {
18
19
  if (element.children.length > 0) {
@@ -111,7 +112,7 @@ const Table = _ref => {
111
112
  }, []);
112
113
  const debouncedSetTabIndex = debounce(setTabIndex, 100);
113
114
  useWindowEvent('resize', debouncedSetTabIndex);
114
- useLayoutEffect(() => {
115
+ useIsomorphicEffect(() => {
115
116
  setTabIndex();
116
117
  }, [setTabIndex]);
117
118
 
@@ -121,7 +122,7 @@ const Table = _ref => {
121
122
  setTableAlignment();
122
123
  });
123
124
  }
124
- useLayoutEffect(() => {
125
+ useIsomorphicEffect(() => {
125
126
  setTableAlignment();
126
127
  }, [setTableAlignment, size]);
127
128
  const table = /*#__PURE__*/React__default.createElement("div", {
@@ -98,7 +98,7 @@ declare const TableExpandHeader: {
98
98
  * Specify whether this row is expanded or not. This helps coordinate data
99
99
  * attributes so that `TableExpandRow` and `TableExpandedRow` work together
100
100
  */
101
- isExpanded: Function;
101
+ isExpanded: any;
102
102
  /**
103
103
  * Hook for when a listener initiates a request to expand the given row
104
104
  */
@@ -10,7 +10,7 @@ import { ReactAttr } from '../../types/common';
10
10
  type ExcludedAttributes = 'value' | 'onChange' | 'locale' | 'children';
11
11
  export type ReactNodeLike = ReactElementLike | ReactNodeArray | string | number | boolean | null | undefined;
12
12
  export type func = (...args: any[]) => any;
13
- interface DatePickerInputProps extends Omit<ReactAttr<HTMLDivElement>, ExcludedAttributes> {
13
+ interface DatePickerInputProps extends Omit<ReactAttr<HTMLInputElement>, ExcludedAttributes> {
14
14
  /**
15
15
  * The type of the date picker:
16
16
  *
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ import { ReactAttr } from '../../types/common';
9
+ export declare const ModalSizes: readonly ["xs", "sm", "md", "lg"];
10
+ export type ModalSize = (typeof ModalSizes)[number];
11
+ export interface ModalSecondaryButton {
12
+ buttonText?: string;
13
+ onClick?: React.MouseEventHandler<HTMLButtonElement>;
14
+ }
15
+ export interface ModalProps extends ReactAttr<HTMLDivElement> {
16
+ /**
17
+ * Specify whether the Modal is displaying an alert, error or warning
18
+ * Should go hand in hand with the danger prop.
19
+ */
20
+ alert?: boolean;
21
+ /**
22
+ * Required props for the accessibility label of the header
23
+ */
24
+ 'aria-label'?: string;
25
+ /**
26
+ * Provide the contents of your Modal
27
+ */
28
+ children?: React.ReactNode;
29
+ /**
30
+ * Specify an optional className to be applied to the modal root node
31
+ */
32
+ className?: string;
33
+ /**
34
+ * Specify an label for the close button of the modal; defaults to close
35
+ */
36
+ closeButtonLabel?: string;
37
+ /**
38
+ * Specify whether the Modal is for dangerous actions
39
+ */
40
+ danger?: boolean;
41
+ /**
42
+ * Specify whether the modal contains scrolling content
43
+ */
44
+ hasScrollingContent?: boolean;
45
+ /**
46
+ * Specify the DOM element ID of the top-level node.
47
+ */
48
+ id?: string;
49
+ /**
50
+ * Specify whether or not the Modal content should have any inner padding.
51
+ */
52
+ isFullWidth?: boolean;
53
+ /**
54
+ * Provide a ref to return focus to once the modal is closed.
55
+ */
56
+ launcherButtonRef?: any;
57
+ /**
58
+ * Specify a label to be read by screen readers on the modal root node
59
+ */
60
+ modalAriaLabel?: string;
61
+ /**
62
+ * Specify the content of the modal header title.
63
+ */
64
+ modalHeading?: React.ReactNode;
65
+ /**
66
+ * Specify the content of the modal header label.
67
+ */
68
+ modalLabel?: React.ReactNode;
69
+ /**
70
+ * Specify a handler for keypresses.
71
+ * @deprecated this property is unused
72
+ */
73
+ onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
74
+ /**
75
+ * Specify a handler for closing modal.
76
+ * The handler should care of closing modal, e.g. changing `open` prop.
77
+ */
78
+ onRequestClose?: React.ReactEventHandler<HTMLElement>;
79
+ /**
80
+ * Specify a handler for "submitting" modal.
81
+ * The handler should care of closing modal, e.g. changing `open` prop, if necessary.
82
+ */
83
+ onRequestSubmit?: React.ReactEventHandler<HTMLElement>;
84
+ /**
85
+ * Specify a handler for the secondary button.
86
+ * Useful if separate handler from `onRequestClose` is desirable
87
+ */
88
+ onSecondarySubmit?: React.ReactEventHandler<HTMLElement>;
89
+ /**
90
+ * Specify whether the Modal is currently open
91
+ */
92
+ open?: boolean;
93
+ /**
94
+ * Specify whether the modal should be button-less
95
+ */
96
+ passiveModal?: boolean;
97
+ /**
98
+ * Prevent closing on click outside of modal
99
+ */
100
+ preventCloseOnClickOutside?: boolean;
101
+ /**
102
+ * Specify whether the Button should be disabled, or not
103
+ */
104
+ primaryButtonDisabled?: boolean;
105
+ /**
106
+ * Specify the text for the primary button
107
+ */
108
+ primaryButtonText?: React.ReactNode;
109
+ /**
110
+ * Specify the text for the secondary button
111
+ */
112
+ secondaryButtonText?: React.ReactNode;
113
+ /**
114
+ * Specify an array of config objects for secondary buttons
115
+ */
116
+ secondaryButtons?: ModalSecondaryButton[];
117
+ /**
118
+ * Specify a CSS selector that matches the DOM element that should
119
+ * be focused when the Modal opens
120
+ */
121
+ selectorPrimaryFocus?: string;
122
+ /**
123
+ * Specify CSS selectors that match DOM elements working as floating menus.
124
+ * Focusing on those elements won't trigger "focus-wrap" behavior
125
+ */
126
+ selectorsFloatingMenus?: string[];
127
+ /**
128
+ * Specify if Enter key should be used as "submit" action
129
+ */
130
+ shouldSubmitOnEnter?: boolean;
131
+ /**
132
+ * Specify the size variant.
133
+ */
134
+ size?: ModalSize;
135
+ }
136
+ declare const Modal: React.ForwardRefExoticComponent<ModalProps & React.RefAttributes<HTMLDivElement>>;
137
+ export default Modal;
@@ -25,6 +25,7 @@ import { match } from '../../internal/keyboard/match.js';
25
25
  import { Escape, Enter } from '../../internal/keyboard/keys.js';
26
26
 
27
27
  const getInstanceId = setupGetInstanceId();
28
+ const ModalSizes = ['xs', 'sm', 'md', 'lg'];
28
29
  const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
29
30
  let {
30
31
  'aria-label': ariaLabelProp,
@@ -56,11 +57,11 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
56
57
  ...rest
57
58
  } = _ref;
58
59
  const prefix = usePrefix();
59
- const button = useRef();
60
+ const button = useRef(null);
60
61
  const secondaryButton = useRef();
61
- const innerModal = useRef();
62
- const startTrap = useRef();
63
- const endTrap = useRef();
62
+ const innerModal = useRef(null);
63
+ const startTrap = useRef(null);
64
+ const endTrap = useRef(null);
64
65
  const modalInstanceId = `modal-${getInstanceId()}`;
65
66
  const modalLabelId = `${prefix}--modal-header__label--${modalInstanceId}`;
66
67
  const modalHeadingId = `${prefix}--modal-header__heading--${modalInstanceId}`;
@@ -80,7 +81,8 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
80
81
  }
81
82
  }
82
83
  function handleMousedown(evt) {
83
- if (innerModal.current && !innerModal.current.contains(evt.target) && !elementOrParentIsFloatingMenu(evt.target, selectorsFloatingMenus) && !preventCloseOnClickOutside) {
84
+ const target = evt.target;
85
+ if (innerModal.current && !innerModal.current.contains(target) && !elementOrParentIsFloatingMenu(target, selectorsFloatingMenus) && !preventCloseOnClickOutside) {
84
86
  onRequestClose(evt);
85
87
  }
86
88
  }
@@ -113,9 +115,8 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
113
115
  const modalClasses = cx(`${prefix}--modal`, {
114
116
  [`${prefix}--modal-tall`]: !passiveModal,
115
117
  'is-visible': open,
116
- [`${prefix}--modal--danger`]: danger,
117
- [className]: className
118
- });
118
+ [`${prefix}--modal--danger`]: danger
119
+ }, className);
119
120
  const containerClasses = cx(`${prefix}--modal-container`, {
120
121
  [`${prefix}--modal-container--${size}`]: size,
121
122
  [`${prefix}--modal-container--full-width`]: isFullWidth
@@ -126,7 +127,12 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
126
127
  const footerClasses = cx(`${prefix}--modal-footer`, {
127
128
  [`${prefix}--modal-footer--three-button`]: Array.isArray(secondaryButtons) && secondaryButtons.length === 2
128
129
  });
129
- const ariaLabel = modalLabel || ariaLabelProp || modalAriaLabel || modalHeading;
130
+ const asStringOrUndefined = node => {
131
+ return typeof node === 'string' ? node : undefined;
132
+ };
133
+ const modalLabelStr = asStringOrUndefined(modalLabel);
134
+ const modalHeadingStr = asStringOrUndefined(modalHeading);
135
+ const ariaLabel = modalLabelStr || ariaLabelProp || modalAriaLabel || modalHeadingStr;
130
136
  const getAriaLabelledBy = modalLabel ? modalLabelId : modalHeadingId;
131
137
  const hasScrollingContentProps = hasScrollingContent ? {
132
138
  tabIndex: 0,
@@ -148,7 +154,7 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
148
154
  };
149
155
  }, [prefix]);
150
156
  useEffect(() => {
151
- toggleClass(document.body, `${prefix}--body--with-modal-open`, open);
157
+ toggleClass(document.body, `${prefix}--body--with-modal-open`, open ?? false);
152
158
  }, [open, prefix]);
153
159
  useEffect(() => {
154
160
  if (!open && launcherButtonRef) {
@@ -168,7 +174,7 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
168
174
  };
169
175
  const focusButton = focusContainerElement => {
170
176
  const target = initialFocus(focusContainerElement);
171
- if (target) {
177
+ if (target !== null) {
172
178
  target.focus();
173
179
  }
174
180
  };
@@ -196,7 +202,7 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
196
202
  className: containerClasses,
197
203
  "aria-label": ariaLabel,
198
204
  "aria-modal": "true",
199
- tabIndex: "-1"
205
+ tabIndex: -1
200
206
  }), /*#__PURE__*/React__default.createElement("div", {
201
207
  className: `${prefix}--modal-header`
202
208
  }, passiveModal && modalButton, modalLabel && /*#__PURE__*/React__default.createElement(Text, {
@@ -243,12 +249,12 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
243
249
  ref: ref
244
250
  }), /*#__PURE__*/React__default.createElement("span", {
245
251
  ref: startTrap,
246
- tabIndex: "0",
252
+ tabIndex: 0,
247
253
  role: "link",
248
254
  className: `${prefix}--visually-hidden`
249
255
  }, "Focus sentinel"), modalBody, /*#__PURE__*/React__default.createElement("span", {
250
256
  ref: endTrap,
251
- tabIndex: "0",
257
+ tabIndex: 0,
252
258
  role: "link",
253
259
  className: `${prefix}--visually-hidden`
254
260
  }, "Focus sentinel"));
@@ -383,7 +389,7 @@ Modal.propTypes = {
383
389
  * Specify CSS selectors that match DOM elements working as floating menus.
384
390
  * Focusing on those elements won't trigger "focus-wrap" behavior
385
391
  */
386
- selectorsFloatingMenus: PropTypes.arrayOf(PropTypes.string),
392
+ selectorsFloatingMenus: PropTypes.arrayOf(PropTypes.string.isRequired),
387
393
  /**
388
394
  * Specify if Enter key should be used as "submit" action
389
395
  */
@@ -391,8 +397,7 @@ Modal.propTypes = {
391
397
  /**
392
398
  * Specify the size variant.
393
399
  */
394
- size: PropTypes.oneOf(['xs', 'sm', 'md', 'lg'])
400
+ size: PropTypes.oneOf(ModalSizes)
395
401
  };
396
- var Modal$1 = Modal;
397
402
 
398
- export { Modal$1 as default };
403
+ export { ModalSizes, Modal as default };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import Modal from './Modal';
8
+ export default Modal;
9
+ export { Modal };
@@ -82,7 +82,6 @@ const ClickableTile = /*#__PURE__*/React__default.forwardRef(function ClickableT
82
82
  evt?.persist?.();
83
83
  if (matches(evt, [Enter, Space])) {
84
84
  setIsSelected(!isSelected);
85
- onKeyDown(evt);
86
85
  }
87
86
  onKeyDown(evt);
88
87
  }
@@ -102,6 +101,7 @@ const ClickableTile = /*#__PURE__*/React__default.forwardRef(function ClickableT
102
101
  return /*#__PURE__*/React__default.createElement(Link, _extends({
103
102
  className: classes,
104
103
  href: href,
104
+ tabIndex: !href && !disabled ? 0 : undefined,
105
105
  onClick: !disabled ? handleOnClick : undefined,
106
106
  onKeyDown: handleOnKeyDown,
107
107
  ref: ref,
@@ -37,6 +37,7 @@ export declare namespace ToggletipLabel {
37
37
  interface ToggletipProps<E extends ElementType> {
38
38
  align?: PopoverAlignment | undefined;
39
39
  as?: E | undefined;
40
+ autoAlign?: boolean | undefined;
40
41
  className?: string | undefined;
41
42
  children?: ReactNode;
42
43
  defaultOpen?: boolean | undefined;
@@ -46,7 +47,7 @@ interface ToggletipProps<E extends ElementType> {
46
47
  * is responsible for coordinating between interactions with the button and the
47
48
  * visibility of the content
48
49
  */
49
- export declare function Toggletip<E extends ElementType = 'span'>({ align, as, className: customClassName, children, defaultOpen, }: ToggletipProps<E>): JSX.Element;
50
+ export declare function Toggletip<E extends ElementType = 'span'>({ align, as, autoAlign, className: customClassName, children, defaultOpen, }: ToggletipProps<E>): JSX.Element;
50
51
  export declare namespace Toggletip {
51
52
  var propTypes: {
52
53
  /**
@@ -58,6 +59,10 @@ export declare namespace Toggletip {
58
59
  * component.
59
60
  */
60
61
  as: PropTypes.Requireable<PropTypes.ReactComponentLike>;
62
+ /**
63
+ * Will auto-align the popover on first render if it is not visible. This prop is currently experimental and is subject to future changes.
64
+ */
65
+ autoAlign: PropTypes.Requireable<boolean>;
61
66
  /**
62
67
  * Custom children to be rendered as the content of the label
63
68
  */
@@ -63,6 +63,7 @@ function Toggletip(_ref2) {
63
63
  let {
64
64
  align,
65
65
  as,
66
+ autoAlign,
66
67
  className: customClassName,
67
68
  children,
68
69
  defaultOpen = false
@@ -137,7 +138,8 @@ function Toggletip(_ref2) {
137
138
  open: open,
138
139
  onKeyDown: onKeyDown,
139
140
  onBlur: handleBlur,
140
- ref: ref
141
+ ref: ref,
142
+ autoAlign: autoAlign
141
143
  }, children));
142
144
  }
143
145
  Toggletip.propTypes = {
@@ -150,6 +152,10 @@ Toggletip.propTypes = {
150
152
  * component.
151
153
  */
152
154
  as: PropTypes.elementType,
155
+ /**
156
+ * Will auto-align the popover on first render if it is not visible. This prop is currently experimental and is subject to future changes.
157
+ */
158
+ autoAlign: PropTypes.bool,
153
159
  /**
154
160
  * Custom children to be rendered as the content of the label
155
161
  */
package/es/index.js CHANGED
@@ -58,6 +58,7 @@ export { default as Link } from './components/Link/Link.js';
58
58
  export { default as ListItem } from './components/ListItem/ListItem.js';
59
59
  export { default as Loading } from './components/Loading/Loading.js';
60
60
  export { MenuButton } from './components/MenuButton/index.js';
61
+ export { default as Modal } from './components/Modal/Modal.js';
61
62
  export { ActionableNotification, InlineNotification, NotificationActionButton, NotificationButton, ToastNotification } from './components/Notification/Notification.js';
62
63
  export { default as NumberInputSkeleton } from './components/NumberInput/NumberInput.Skeleton.js';
63
64
  export { NumberInput } from './components/NumberInput/NumberInput.js';
@@ -205,7 +206,6 @@ export { ErrorBoundaryContext } from './components/ErrorBoundary/ErrorBoundaryCo
205
206
  export { default as FilterableMultiSelect } from './components/MultiSelect/FilterableMultiSelect.js';
206
207
  export { Menu } from './components/Menu/Menu.js';
207
208
  export { MenuItem, MenuItemDivider, MenuItemGroup, MenuItemRadioGroup, MenuItemSelectable } from './components/Menu/MenuItem.js';
208
- export { default as Modal } from './components/Modal/Modal.js';
209
209
  export { default as MultiSelect } from './components/MultiSelect/MultiSelect.js';
210
210
  export { default as Pagination } from './components/Pagination/Pagination.js';
211
211
  export { default as PaginationNav } from './components/PaginationNav/PaginationNav.js';
@@ -24,11 +24,11 @@ function elementOrParentIsFloatingMenu(node) {
24
24
  /**
25
25
  * Ensures the focus is kept in the given `modalNode`, implementing "focus-wrap" behavior.
26
26
  * @param {object} options The options.
27
- * @param {HTMLElement|null} options.bodyNode
28
- * @param {HTMLElement|null} options.startTrapNode The DOM node of the focus sentinel the is placed earlier next to `modalNode`.
29
- * @param {HTMLElement|null} options.endTrapNode The DOM node of the focus sentinel the is placed next to `modalNode`.
30
- * @param {HTMLElement} options.currentActiveNode The DOM node that has focus.
31
- * @param {HTMLElement} options.oldActiveNode The DOM node that previously had focus.
27
+ * @param {Node|null} options.bodyNode
28
+ * @param {Node|null} options.startTrapNode The DOM node of the focus sentinel the is placed earlier next to `modalNode`.
29
+ * @param {Node|null} options.endTrapNode The DOM node of the focus sentinel the is placed next to `modalNode`.
30
+ * @param {Node} options.currentActiveNode The DOM node that has focus.
31
+ * @param {Node} options.oldActiveNode The DOM node that previously had focus.
32
32
  * @param {string[]} [options.selectorsFloatingMenus] The CSS selectors that matches floating menus.
33
33
  */
34
34
  function wrapFocus(_ref) {
@@ -8,8 +8,8 @@
8
8
  /**
9
9
  * @param {string} name The name of the prop that must exist to validate
10
10
  * the current prop.
11
- * @param {Function} propType The original prop type checker.
12
- * @returns {Function} The new prop type checker for the current prop that
11
+ * @param {React.Validator} propType The original prop type checker.
12
+ * @returns {React.Validator} The new prop type checker for the current prop that
13
13
  * becomes required if the prop corresponding to the provided prop name exists.
14
14
  */
15
15
  function requiredIfGivenPropIsTruthy(name, propType) {
@@ -55,7 +55,6 @@ ModalBody.propTypes = {
55
55
  /**
56
56
  * Required props for the accessibility label of the header
57
57
  */
58
- // @ts-expect-error: Built-in prop-types > TS logic doesn't jive well with custom validators
59
58
  ['aria-label']: requiredIfGivenPropIsTruthy["default"]('hasScrollingContent', PropTypes__default["default"].string),
60
59
  /**
61
60
  * Specify the content to be placed in the ModalBody
@@ -17,6 +17,7 @@ var debounce = require('lodash.debounce');
17
17
  var usePrefix = require('../../internal/usePrefix.js');
18
18
  var TableContext = require('./TableContext.js');
19
19
  var useEvent = require('../../internal/useEvent.js');
20
+ var useIsomorphicEffect = require('../../internal/useIsomorphicEffect.js');
20
21
 
21
22
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
23
 
@@ -122,7 +123,7 @@ const Table = _ref => {
122
123
  }, []);
123
124
  const debouncedSetTabIndex = debounce__default["default"](setTabIndex, 100);
124
125
  useEvent.useWindowEvent('resize', debouncedSetTabIndex);
125
- React.useLayoutEffect(() => {
126
+ useIsomorphicEffect["default"](() => {
126
127
  setTabIndex();
127
128
  }, [setTabIndex]);
128
129
 
@@ -132,7 +133,7 @@ const Table = _ref => {
132
133
  setTableAlignment();
133
134
  });
134
135
  }
135
- React.useLayoutEffect(() => {
136
+ useIsomorphicEffect["default"](() => {
136
137
  setTableAlignment();
137
138
  }, [setTableAlignment, size]);
138
139
  const table = /*#__PURE__*/React__default["default"].createElement("div", {
@@ -98,7 +98,7 @@ declare const TableExpandHeader: {
98
98
  * Specify whether this row is expanded or not. This helps coordinate data
99
99
  * attributes so that `TableExpandRow` and `TableExpandedRow` work together
100
100
  */
101
- isExpanded: Function;
101
+ isExpanded: any;
102
102
  /**
103
103
  * Hook for when a listener initiates a request to expand the given row
104
104
  */
@@ -10,7 +10,7 @@ import { ReactAttr } from '../../types/common';
10
10
  type ExcludedAttributes = 'value' | 'onChange' | 'locale' | 'children';
11
11
  export type ReactNodeLike = ReactElementLike | ReactNodeArray | string | number | boolean | null | undefined;
12
12
  export type func = (...args: any[]) => any;
13
- interface DatePickerInputProps extends Omit<ReactAttr<HTMLDivElement>, ExcludedAttributes> {
13
+ interface DatePickerInputProps extends Omit<ReactAttr<HTMLInputElement>, ExcludedAttributes> {
14
14
  /**
15
15
  * The type of the date picker:
16
16
  *
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ import { ReactAttr } from '../../types/common';
9
+ export declare const ModalSizes: readonly ["xs", "sm", "md", "lg"];
10
+ export type ModalSize = (typeof ModalSizes)[number];
11
+ export interface ModalSecondaryButton {
12
+ buttonText?: string;
13
+ onClick?: React.MouseEventHandler<HTMLButtonElement>;
14
+ }
15
+ export interface ModalProps extends ReactAttr<HTMLDivElement> {
16
+ /**
17
+ * Specify whether the Modal is displaying an alert, error or warning
18
+ * Should go hand in hand with the danger prop.
19
+ */
20
+ alert?: boolean;
21
+ /**
22
+ * Required props for the accessibility label of the header
23
+ */
24
+ 'aria-label'?: string;
25
+ /**
26
+ * Provide the contents of your Modal
27
+ */
28
+ children?: React.ReactNode;
29
+ /**
30
+ * Specify an optional className to be applied to the modal root node
31
+ */
32
+ className?: string;
33
+ /**
34
+ * Specify an label for the close button of the modal; defaults to close
35
+ */
36
+ closeButtonLabel?: string;
37
+ /**
38
+ * Specify whether the Modal is for dangerous actions
39
+ */
40
+ danger?: boolean;
41
+ /**
42
+ * Specify whether the modal contains scrolling content
43
+ */
44
+ hasScrollingContent?: boolean;
45
+ /**
46
+ * Specify the DOM element ID of the top-level node.
47
+ */
48
+ id?: string;
49
+ /**
50
+ * Specify whether or not the Modal content should have any inner padding.
51
+ */
52
+ isFullWidth?: boolean;
53
+ /**
54
+ * Provide a ref to return focus to once the modal is closed.
55
+ */
56
+ launcherButtonRef?: any;
57
+ /**
58
+ * Specify a label to be read by screen readers on the modal root node
59
+ */
60
+ modalAriaLabel?: string;
61
+ /**
62
+ * Specify the content of the modal header title.
63
+ */
64
+ modalHeading?: React.ReactNode;
65
+ /**
66
+ * Specify the content of the modal header label.
67
+ */
68
+ modalLabel?: React.ReactNode;
69
+ /**
70
+ * Specify a handler for keypresses.
71
+ * @deprecated this property is unused
72
+ */
73
+ onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
74
+ /**
75
+ * Specify a handler for closing modal.
76
+ * The handler should care of closing modal, e.g. changing `open` prop.
77
+ */
78
+ onRequestClose?: React.ReactEventHandler<HTMLElement>;
79
+ /**
80
+ * Specify a handler for "submitting" modal.
81
+ * The handler should care of closing modal, e.g. changing `open` prop, if necessary.
82
+ */
83
+ onRequestSubmit?: React.ReactEventHandler<HTMLElement>;
84
+ /**
85
+ * Specify a handler for the secondary button.
86
+ * Useful if separate handler from `onRequestClose` is desirable
87
+ */
88
+ onSecondarySubmit?: React.ReactEventHandler<HTMLElement>;
89
+ /**
90
+ * Specify whether the Modal is currently open
91
+ */
92
+ open?: boolean;
93
+ /**
94
+ * Specify whether the modal should be button-less
95
+ */
96
+ passiveModal?: boolean;
97
+ /**
98
+ * Prevent closing on click outside of modal
99
+ */
100
+ preventCloseOnClickOutside?: boolean;
101
+ /**
102
+ * Specify whether the Button should be disabled, or not
103
+ */
104
+ primaryButtonDisabled?: boolean;
105
+ /**
106
+ * Specify the text for the primary button
107
+ */
108
+ primaryButtonText?: React.ReactNode;
109
+ /**
110
+ * Specify the text for the secondary button
111
+ */
112
+ secondaryButtonText?: React.ReactNode;
113
+ /**
114
+ * Specify an array of config objects for secondary buttons
115
+ */
116
+ secondaryButtons?: ModalSecondaryButton[];
117
+ /**
118
+ * Specify a CSS selector that matches the DOM element that should
119
+ * be focused when the Modal opens
120
+ */
121
+ selectorPrimaryFocus?: string;
122
+ /**
123
+ * Specify CSS selectors that match DOM elements working as floating menus.
124
+ * Focusing on those elements won't trigger "focus-wrap" behavior
125
+ */
126
+ selectorsFloatingMenus?: string[];
127
+ /**
128
+ * Specify if Enter key should be used as "submit" action
129
+ */
130
+ shouldSubmitOnEnter?: boolean;
131
+ /**
132
+ * Specify the size variant.
133
+ */
134
+ size?: ModalSize;
135
+ }
136
+ declare const Modal: React.ForwardRefExoticComponent<ModalProps & React.RefAttributes<HTMLDivElement>>;
137
+ export default Modal;