@itwin/itwinui-react 1.45.0 → 1.46.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 (88) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/cjs/core/Breadcrumbs/Breadcrumbs.d.ts +116 -0
  3. package/cjs/core/Breadcrumbs/Breadcrumbs.js +2 -3
  4. package/cjs/core/ButtonGroup/ButtonGroup.js +1 -1
  5. package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
  6. package/cjs/core/DatePicker/DatePicker.d.ts +24 -4
  7. package/cjs/core/DatePicker/DatePicker.js +116 -19
  8. package/cjs/core/Dialog/Dialog.d.ts +5 -5
  9. package/cjs/core/Dialog/Dialog.js +38 -6
  10. package/cjs/core/Dialog/DialogBackdrop.d.ts +2 -2
  11. package/cjs/core/Dialog/DialogBackdrop.js +2 -2
  12. package/cjs/core/Dialog/DialogContext.d.ts +31 -0
  13. package/cjs/core/Dialog/DialogDragContext.d.ts +8 -0
  14. package/cjs/core/Dialog/DialogDragContext.js +28 -0
  15. package/cjs/core/Dialog/DialogMain.d.ts +2 -2
  16. package/cjs/core/Dialog/DialogMain.js +46 -6
  17. package/cjs/core/Dialog/DialogTitleBar.d.ts +2 -2
  18. package/cjs/core/Dialog/DialogTitleBar.js +12 -2
  19. package/cjs/core/Modal/Modal.js +1 -1
  20. package/cjs/core/Table/Table.d.ts +6 -0
  21. package/cjs/core/Table/Table.js +51 -6
  22. package/cjs/core/Table/actionHandlers/index.d.ts +1 -1
  23. package/cjs/core/Table/actionHandlers/index.js +2 -1
  24. package/cjs/core/Table/actionHandlers/resizeHandler.d.ts +2 -0
  25. package/cjs/core/Table/actionHandlers/selectHandler.d.ts +5 -0
  26. package/cjs/core/Table/actionHandlers/selectHandler.js +35 -2
  27. package/cjs/core/index.d.ts +3 -1
  28. package/cjs/core/index.js +6 -3
  29. package/cjs/core/utils/components/Resizer.d.ts +31 -0
  30. package/cjs/core/utils/components/Resizer.js +206 -0
  31. package/cjs/core/utils/components/VirtualScroll.js +26 -24
  32. package/cjs/core/utils/components/index.d.ts +1 -0
  33. package/cjs/core/utils/components/index.js +1 -0
  34. package/cjs/core/utils/functions/index.d.ts +1 -0
  35. package/cjs/core/utils/functions/index.js +1 -0
  36. package/cjs/core/utils/functions/styles.d.ts +6 -0
  37. package/cjs/core/utils/functions/styles.js +21 -0
  38. package/cjs/core/utils/hooks/useContainerWidth.d.ts +1 -1
  39. package/cjs/core/utils/hooks/useDragAndDrop.d.ts +14 -0
  40. package/cjs/core/utils/hooks/useDragAndDrop.js +110 -0
  41. package/cjs/core/utils/hooks/useEventListener.d.ts +1 -1
  42. package/cjs/core/utils/hooks/useOverflow.d.ts +1 -1
  43. package/cjs/core/utils/hooks/useResizeObserver.d.ts +1 -1
  44. package/cjs/types/react-table-config.d.ts +2 -1
  45. package/esm/core/Breadcrumbs/Breadcrumbs.d.ts +116 -0
  46. package/esm/core/Breadcrumbs/Breadcrumbs.js +2 -3
  47. package/esm/core/ButtonGroup/ButtonGroup.js +1 -1
  48. package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
  49. package/esm/core/DatePicker/DatePicker.d.ts +24 -4
  50. package/esm/core/DatePicker/DatePicker.js +116 -19
  51. package/esm/core/Dialog/Dialog.d.ts +5 -5
  52. package/esm/core/Dialog/Dialog.js +37 -5
  53. package/esm/core/Dialog/DialogBackdrop.d.ts +2 -2
  54. package/esm/core/Dialog/DialogBackdrop.js +2 -2
  55. package/esm/core/Dialog/DialogContext.d.ts +31 -0
  56. package/esm/core/Dialog/DialogDragContext.d.ts +8 -0
  57. package/esm/core/Dialog/DialogDragContext.js +21 -0
  58. package/esm/core/Dialog/DialogMain.d.ts +2 -2
  59. package/esm/core/Dialog/DialogMain.js +47 -7
  60. package/esm/core/Dialog/DialogTitleBar.d.ts +2 -2
  61. package/esm/core/Dialog/DialogTitleBar.js +12 -2
  62. package/esm/core/Modal/Modal.js +1 -1
  63. package/esm/core/Table/Table.d.ts +6 -0
  64. package/esm/core/Table/Table.js +53 -8
  65. package/esm/core/Table/actionHandlers/index.d.ts +1 -1
  66. package/esm/core/Table/actionHandlers/index.js +1 -1
  67. package/esm/core/Table/actionHandlers/resizeHandler.d.ts +2 -0
  68. package/esm/core/Table/actionHandlers/selectHandler.d.ts +5 -0
  69. package/esm/core/Table/actionHandlers/selectHandler.js +33 -1
  70. package/esm/core/index.d.ts +3 -1
  71. package/esm/core/index.js +2 -1
  72. package/esm/core/utils/components/Resizer.d.ts +31 -0
  73. package/esm/core/utils/components/Resizer.js +199 -0
  74. package/esm/core/utils/components/VirtualScroll.js +26 -24
  75. package/esm/core/utils/components/index.d.ts +1 -0
  76. package/esm/core/utils/components/index.js +1 -0
  77. package/esm/core/utils/functions/index.d.ts +1 -0
  78. package/esm/core/utils/functions/index.js +1 -0
  79. package/esm/core/utils/functions/styles.d.ts +6 -0
  80. package/esm/core/utils/functions/styles.js +17 -0
  81. package/esm/core/utils/hooks/useContainerWidth.d.ts +1 -1
  82. package/esm/core/utils/hooks/useDragAndDrop.d.ts +14 -0
  83. package/esm/core/utils/hooks/useDragAndDrop.js +103 -0
  84. package/esm/core/utils/hooks/useEventListener.d.ts +1 -1
  85. package/esm/core/utils/hooks/useOverflow.d.ts +1 -1
  86. package/esm/core/utils/hooks/useResizeObserver.d.ts +1 -1
  87. package/esm/types/react-table-config.d.ts +2 -1
  88. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.46.0](https://www.github.com/iTwin/iTwinUI-react/compare/v1.45.0...v1.46.0) (2022-09-20)
4
+
5
+ ### What's new
6
+
7
+ * **Dialog:** Added new `Dialog` compound component that was previously used by `Modal` internally.
8
+ - Supports dragging through `isDraggable` and `relativeTo` props ([#771](https://www.github.com/iTwin/iTwinUI-react/issues/771)) ([6e19020](https://www.github.com/iTwin/iTwinUI-react/commit/6e1902011c323485cdf74b64c4778de6309c0820))
9
+ - Supports resizing through `isResizable` prop ([#823](https://www.github.com/iTwin/iTwinUI-react/issues/823)) ([635de22](https://www.github.com/iTwin/iTwinUI-react/commit/635de226416196b23babe07c455e7571611a993f))
10
+ * **Breadcrumbs:** Add `overflowButton` property ([#814](https://www.github.com/iTwin/iTwinUI-react/issues/814)) ([5a53003](https://www.github.com/iTwin/iTwinUI-react/commit/5a53003ea7c68854f412713edf49ec489505b134))
11
+ * **DatePicker:** Date range support ([#737](https://www.github.com/iTwin/iTwinUI-react/issues/737)) ([33a815a](https://www.github.com/iTwin/iTwinUI-react/commit/33a815a2588251ff48f0f1852ec1b07957970069))
12
+ * **Table:** Enable `useGlobalFilter` ([#810](https://www.github.com/iTwin/iTwinUI-react/issues/810)) ([b5133cc](https://www.github.com/iTwin/iTwinUI-react/commit/b5133cccb624380b1e4734bf3fe75858c046cf7e))
13
+ * **Table:** Now supports shift click to select multiple rows ([#774](https://www.github.com/iTwin/iTwinUI-react/issues/774)) ([e868dc2](https://www.github.com/iTwin/iTwinUI-react/commit/e868dc285975ccf19635ff24edba017fea55d376))
14
+
15
+ ### Fixes
16
+
17
+ * **ButtonGroup:** Handle overflow when available space is smaller than one element ([#827](https://www.github.com/iTwin/iTwinUI-react/issues/827)) ([f3691d3](https://www.github.com/iTwin/iTwinUI-react/commit/f3691d34306bad9203d85c5708650b524926fb79))
18
+ * **Modal:** Fixed body overflow handling when there is a dialog inside another dialog ([#776](https://www.github.com/iTwin/iTwinUI-react/issues/776)) ([68feac4](https://www.github.com/iTwin/iTwinUI-react/commit/68feac425d335d11d5b0fd306bd35e5815910d17))
19
+ * **Dialog:** Only focus dialog when `setFocus` is `true` ([#809](https://www.github.com/iTwin/iTwinUI-react/issues/809)) ([ddd7a9c](https://www.github.com/iTwin/iTwinUI-react/commit/ddd7a9cbceabaf5699b03b8d9d19b2676b53372f))
20
+ * **Table:** Exposing `BaseFilter` in `index.ts` ([#826](https://www.github.com/iTwin/iTwinUI-react/issues/826)) ([9cddd2c](https://www.github.com/iTwin/iTwinUI-react/commit/9cddd2c8e347e849916637c2c8a60ba24c342a75))
21
+ * **VirtualScroll:** Show all children upon toggling display/visibility ([#811](https://www.github.com/iTwin/iTwinUI-react/issues/811)) ([77810a6](https://www.github.com/iTwin/iTwinUI-react/commit/77810a67745411e235abe31578f3eb265d81a9eb))
22
+
3
23
  ## [1.45.0](https://www.github.com/iTwin/iTwinUI-react/compare/v1.44.0...v1.45.0) (2022-08-25)
4
24
 
5
25
  ### What's new
@@ -16,6 +16,64 @@ export declare type BreadcrumbsProps = {
16
16
  * Defaults to the `SvgChevronRight` icon.
17
17
  */
18
18
  separator?: React.ReactNode;
19
+ /**
20
+ * If specified, this prop will be used to show a custom button when overflow happens,
21
+ * i.e. when there is not enough space to fit all the breadcrumbs.
22
+ *
23
+ * Expects a function that takes the number of items that are visible
24
+ * and returns the `ReactNode` to render.
25
+ *
26
+ * @example <caption>Uses the overflow button to redirect to the previous breadcrumb</caption>
27
+ * <Breadcrumbs
28
+ * overflowButton={(visibleCount: number) => {
29
+ * const previousBreadcrumb = visibleCount > 1 ? items.length - visibleCount : items.length - 2;
30
+ * return (
31
+ * <Tooltip content={`Item ${previousBreadcrumb}`} placement='bottom'>
32
+ * <IconButton
33
+ * onClick={() => {
34
+ * // click on "previousBreadcrumb"
35
+ * }}
36
+ * >
37
+ * <SvgMoreSmall />
38
+ * </IconButton>
39
+ * </Tooltip>
40
+ * );
41
+ * }}
42
+ * >
43
+ * {items}
44
+ * </Breadcrumbs>
45
+ *
46
+ * @example <caption>Uses the overflow button to add a dropdown that contains hidden breadcrumbs</caption>
47
+ * <Breadcrumbs
48
+ * overflowButton={(visibleCount) => (
49
+ * <DropdownMenu
50
+ * menuItems={(close) =>
51
+ * Array(items.length - visibleCount)
52
+ * .fill(null)
53
+ * .map((_, _index) => {
54
+ * const index = visibleCount > 1 ? _index + 1 : _index;
55
+ * const onClick = () => {
56
+ * // click on "index" breadcrumb
57
+ * close();
58
+ * };
59
+ * return (
60
+ * <MenuItem key={index} onClick={onClick}>
61
+ * Item {index}
62
+ * </MenuItem>
63
+ * );
64
+ * })
65
+ * }
66
+ * >
67
+ * <IconButton>
68
+ * <SvgMoreSmall />
69
+ * </IconButton>
70
+ * </DropdownMenu>
71
+ * )}
72
+ * >
73
+ * {items}
74
+ * </Breadcrumbs>
75
+ */
76
+ overflowButton?: (visibleCount: number) => React.ReactNode;
19
77
  } & Omit<CommonProps, 'title'>;
20
78
  /**
21
79
  * A breadcrumb trail is used as a navigational aid to help users keep track
@@ -54,5 +112,63 @@ export declare const Breadcrumbs: React.ForwardRefExoticComponent<{
54
112
  * Defaults to the `SvgChevronRight` icon.
55
113
  */
56
114
  separator?: React.ReactNode;
115
+ /**
116
+ * If specified, this prop will be used to show a custom button when overflow happens,
117
+ * i.e. when there is not enough space to fit all the breadcrumbs.
118
+ *
119
+ * Expects a function that takes the number of items that are visible
120
+ * and returns the `ReactNode` to render.
121
+ *
122
+ * @example <caption>Uses the overflow button to redirect to the previous breadcrumb</caption>
123
+ * <Breadcrumbs
124
+ * overflowButton={(visibleCount: number) => {
125
+ * const previousBreadcrumb = visibleCount > 1 ? items.length - visibleCount : items.length - 2;
126
+ * return (
127
+ * <Tooltip content={`Item ${previousBreadcrumb}`} placement='bottom'>
128
+ * <IconButton
129
+ * onClick={() => {
130
+ * // click on "previousBreadcrumb"
131
+ * }}
132
+ * >
133
+ * <SvgMoreSmall />
134
+ * </IconButton>
135
+ * </Tooltip>
136
+ * );
137
+ * }}
138
+ * >
139
+ * {items}
140
+ * </Breadcrumbs>
141
+ *
142
+ * @example <caption>Uses the overflow button to add a dropdown that contains hidden breadcrumbs</caption>
143
+ * <Breadcrumbs
144
+ * overflowButton={(visibleCount) => (
145
+ * <DropdownMenu
146
+ * menuItems={(close) =>
147
+ * Array(items.length - visibleCount)
148
+ * .fill(null)
149
+ * .map((_, _index) => {
150
+ * const index = visibleCount > 1 ? _index + 1 : _index;
151
+ * const onClick = () => {
152
+ * // click on "index" breadcrumb
153
+ * close();
154
+ * };
155
+ * return (
156
+ * <MenuItem key={index} onClick={onClick}>
157
+ * Item {index}
158
+ * </MenuItem>
159
+ * );
160
+ * })
161
+ * }
162
+ * >
163
+ * <IconButton>
164
+ * <SvgMoreSmall />
165
+ * </IconButton>
166
+ * </DropdownMenu>
167
+ * )}
168
+ * >
169
+ * {items}
170
+ * </Breadcrumbs>
171
+ */
172
+ overflowButton?: ((visibleCount: number) => React.ReactNode) | undefined;
57
173
  } & Omit<CommonProps, "title"> & React.RefAttributes<HTMLElement>>;
58
174
  export default Breadcrumbs;
@@ -58,7 +58,7 @@ require("@itwin/itwinui-css/css/breadcrumbs.css");
58
58
  * </Breadcrumbs>
59
59
  */
60
60
  exports.Breadcrumbs = react_1.default.forwardRef(function (props, ref) {
61
- var items = props.children, _a = props.currentIndex, currentIndex = _a === void 0 ? items.length - 1 : _a, separator = props.separator, className = props.className, rest = __rest(props, ["children", "currentIndex", "separator", "className"]);
61
+ var items = props.children, _a = props.currentIndex, currentIndex = _a === void 0 ? items.length - 1 : _a, separator = props.separator, overflowButton = props.overflowButton, className = props.className, rest = __rest(props, ["children", "currentIndex", "separator", "overflowButton", "className"]);
62
62
  (0, utils_1.useTheme)();
63
63
  var _b = (0, utils_1.useOverflow)(items), overflowRef = _b[0], visibleCount = _b[1];
64
64
  var refs = (0, utils_1.useMergedRefs)(overflowRef, ref);
@@ -68,8 +68,7 @@ exports.Breadcrumbs = react_1.default.forwardRef(function (props, ref) {
68
68
  react_1.default.createElement(ListItem, { item: items[0], isActive: currentIndex === 0 }),
69
69
  react_1.default.createElement(Separator, { separator: separator }))),
70
70
  items.length - visibleCount > 0 && (react_1.default.createElement(react_1.default.Fragment, null,
71
- react_1.default.createElement("li", { className: 'iui-breadcrumbs-item iui-breadcrumbs-item-overrides' },
72
- react_1.default.createElement("span", { className: 'iui-breadcrumbs-text' }, "\u2026")),
71
+ react_1.default.createElement("li", { className: 'iui-breadcrumbs-item iui-breadcrumbs-item-overrides' }, overflowButton ? (overflowButton(visibleCount)) : (react_1.default.createElement("span", { className: 'iui-breadcrumbs-text' }, "\u2026"))),
73
72
  react_1.default.createElement(Separator, { separator: separator }))),
74
73
  items
75
74
  .slice(visibleCount > 1
@@ -78,7 +78,7 @@ exports.ButtonGroup = react_1.default.forwardRef(function (props, ref) {
78
78
  overflowButton &&
79
79
  overflowPlacement === 'start' && (react_1.default.createElement("div", null, overflowButton(visibleCount))),
80
80
  visibleCount < items.length
81
- ? items.slice(0, visibleCount - 1)
81
+ ? items.slice(0, Math.max(0, visibleCount - 1))
82
82
  : items,
83
83
  visibleCount < items.length &&
84
84
  overflowButton &&
@@ -17,5 +17,5 @@ export declare type ColorSwatchProps = {
17
17
  * <ColorSwatch color='#23450b' onClick={onClick}/>
18
18
  * <ColorSwatch color={{ r: 255, g: 255, b: 0 }} onClick={onClick}/>
19
19
  */
20
- export declare const ColorSwatch: React.ForwardRefExoticComponent<Pick<ColorSwatchProps, "dir" | "slot" | "style" | "title" | "id" | "aria-disabled" | "children" | "role" | "className" | "onClick" | "accessKey" | "draggable" | "hidden" | "lang" | "translate" | "prefix" | "contentEditable" | "inputMode" | "tabIndex" | "onFocus" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "color" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "contextMenu" | "placeholder" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "is" | "isActive"> & React.RefAttributes<HTMLDivElement>>;
20
+ export declare const ColorSwatch: React.ForwardRefExoticComponent<Pick<ColorSwatchProps, "dir" | "slot" | "style" | "title" | "id" | "aria-disabled" | "children" | "role" | "className" | "onClick" | "accessKey" | "onPointerDown" | "draggable" | "hidden" | "lang" | "translate" | "prefix" | "contentEditable" | "inputMode" | "tabIndex" | "onFocus" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "color" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "contextMenu" | "placeholder" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "is" | "isActive"> & React.RefAttributes<HTMLDivElement>>;
21
21
  export default ColorSwatch;
@@ -10,15 +10,35 @@ export declare const generateLocalizedStrings: (locale?: string) => {
10
10
  shortDays: string[];
11
11
  days: string[];
12
12
  };
13
- export declare type DatePickerProps = {
13
+ export declare type DateRangePickerProps = {
14
14
  /**
15
- * Selected date.
15
+ * Enable date range support.
16
+ * @default false
16
17
  */
17
- date?: Date;
18
+ enableRangeSelect?: false;
19
+ /**
20
+ * Selected start date
21
+ */
22
+ startDate?: undefined;
23
+ /**
24
+ * Selected end date
25
+ */
26
+ endDate?: undefined;
18
27
  /**
19
28
  * Callback when date is changed.
20
29
  */
21
30
  onChange?: (date: Date) => void;
31
+ } | {
32
+ enableRangeSelect: true;
33
+ startDate: Date;
34
+ endDate: Date;
35
+ onChange?: (startDate: Date, endDate: Date) => void;
36
+ };
37
+ export declare type DatePickerProps = {
38
+ /**
39
+ * Selected date.
40
+ */
41
+ date?: Date;
22
42
  /**
23
43
  * Pass localized week days (start from sunday) and months.
24
44
  * Use helper function `generateLocalizedStrings` to generate strings using `Intl.DateTimeFormat`.
@@ -41,7 +61,7 @@ export declare type DatePickerProps = {
41
61
  * @default false
42
62
  */
43
63
  showYearSelection?: boolean;
44
- } & Omit<TimePickerProps, 'date' | 'onChange' | 'setFocusHour'>;
64
+ } & DateRangePickerProps & Omit<TimePickerProps, 'date' | 'onChange' | 'setFocusHour'>;
45
65
  /**
46
66
  * Date picker component
47
67
  * @example
@@ -47,6 +47,33 @@ var isSameDay = function (a, b) {
47
47
  a.getMonth() === b.getMonth() &&
48
48
  a.getDate() === b.getDate());
49
49
  };
50
+ var isInDateRange = function (date, startDate, endDate) {
51
+ if (!date || !startDate || !endDate) {
52
+ return false;
53
+ }
54
+ var minDate = new Date(startDate);
55
+ var maxDate = new Date(endDate);
56
+ var testDate = new Date(date);
57
+ testDate && testDate.setHours(0, 0, 0, 0);
58
+ minDate && minDate.setHours(0, 0, 0, 0);
59
+ maxDate && maxDate.setHours(0, 0, 0, 0);
60
+ return testDate > minDate && testDate < maxDate;
61
+ };
62
+ // compares to see if one date is earlier than another
63
+ var isBefore = function (beforeDate, afterDate) {
64
+ if (!beforeDate || !afterDate) {
65
+ return false;
66
+ }
67
+ var firstDate = new Date(beforeDate);
68
+ var secondDate = new Date(afterDate);
69
+ firstDate && firstDate.setHours(0, 0, 0, 0);
70
+ secondDate && secondDate.setHours(0, 0, 0, 0);
71
+ return firstDate < secondDate;
72
+ };
73
+ // Type guard for multiple did not work
74
+ var isSingleOnChange = function (onChange, enableRangeSelect) {
75
+ return !enableRangeSelect;
76
+ };
50
77
  var defaultMonths = [
51
78
  'January',
52
79
  'February',
@@ -128,16 +155,20 @@ exports.generateLocalizedStrings = generateLocalizedStrings;
128
155
  * <DatePicker date={new Date()} onChange={(e) => console.log('New date value: ' + e)} />
129
156
  */
130
157
  var DatePicker = function (props) {
131
- var _a, _b, _c;
132
- var date = props.date, onChange = props.onChange, localizedNames = props.localizedNames, className = props.className, style = props.style, _d = props.setFocus, setFocus = _d === void 0 ? false : _d, _e = props.showTime, showTime = _e === void 0 ? false : _e, _f = props.use12Hours, use12Hours = _f === void 0 ? false : _f, precision = props.precision, hourStep = props.hourStep, minuteStep = props.minuteStep, secondStep = props.secondStep, _g = props.showYearSelection, showYearSelection = _g === void 0 ? false : _g, rest = __rest(props, ["date", "onChange", "localizedNames", "className", "style", "setFocus", "showTime", "use12Hours", "precision", "hourStep", "minuteStep", "secondStep", "showYearSelection"]);
158
+ var _a, _b, _c, _d, _e, _f, _g, _h;
159
+ var date = props.date, onChange = props.onChange, localizedNames = props.localizedNames, className = props.className, style = props.style, _j = props.setFocus, setFocus = _j === void 0 ? false : _j, _k = props.showTime, showTime = _k === void 0 ? false : _k, _l = props.use12Hours, use12Hours = _l === void 0 ? false : _l, precision = props.precision, hourStep = props.hourStep, minuteStep = props.minuteStep, secondStep = props.secondStep, _m = props.showYearSelection, showYearSelection = _m === void 0 ? false : _m, _o = props.enableRangeSelect, enableRangeSelect = _o === void 0 ? false : _o, startDate = props.startDate, endDate = props.endDate, rest = __rest(props, ["date", "onChange", "localizedNames", "className", "style", "setFocus", "showTime", "use12Hours", "precision", "hourStep", "minuteStep", "secondStep", "showYearSelection", "enableRangeSelect", "startDate", "endDate"]);
133
160
  (0, utils_1.useTheme)();
134
161
  var monthNames = (_a = localizedNames === null || localizedNames === void 0 ? void 0 : localizedNames.months) !== null && _a !== void 0 ? _a : defaultMonths;
135
162
  var shortDays = (_b = localizedNames === null || localizedNames === void 0 ? void 0 : localizedNames.shortDays) !== null && _b !== void 0 ? _b : defaultShortDays;
136
163
  var longDays = (_c = localizedNames === null || localizedNames === void 0 ? void 0 : localizedNames.days) !== null && _c !== void 0 ? _c : defaultLongDays;
137
- var _h = react_1.default.useState(date), selectedDay = _h[0], setSelectedDay = _h[1];
138
- var _j = react_1.default.useState(selectedDay !== null && selectedDay !== void 0 ? selectedDay : new Date()), focusedDay = _j[0], setFocusedDay = _j[1];
139
- var _k = react_1.default.useState(selectedDay ? selectedDay.getMonth() : new Date().getMonth()), displayedMonthIndex = _k[0], setDisplayedMonthIndex = _k[1];
140
- var _l = react_1.default.useState(selectedDay ? selectedDay.getFullYear() : new Date().getFullYear()), displayedYear = _l[0], setDisplayedYear = _l[1];
164
+ var _p = react_1.default.useState(date), selectedDay = _p[0], setSelectedDay = _p[1];
165
+ var _q = react_1.default.useState(startDate), selectedStartDay = _q[0], setSelectedStartDay = _q[1];
166
+ var _r = react_1.default.useState(endDate), selectedEndDay = _r[0], setSelectedEndDay = _r[1];
167
+ var _s = react_1.default.useState((_d = selectedStartDay !== null && selectedStartDay !== void 0 ? selectedStartDay : selectedDay) !== null && _d !== void 0 ? _d : new Date()), focusedDay = _s[0], setFocusedDay = _s[1];
168
+ var _t = react_1.default.useState((_f = (_e = selectedStartDay === null || selectedStartDay === void 0 ? void 0 : selectedStartDay.getMonth()) !== null && _e !== void 0 ? _e : selectedDay === null || selectedDay === void 0 ? void 0 : selectedDay.getMonth()) !== null && _f !== void 0 ? _f : new Date().getMonth()), displayedMonthIndex = _t[0], setDisplayedMonthIndex = _t[1];
169
+ var _u = react_1.default.useState((_h = (_g = selectedStartDay === null || selectedStartDay === void 0 ? void 0 : selectedStartDay.getFullYear()) !== null && _g !== void 0 ? _g : selectedDay === null || selectedDay === void 0 ? void 0 : selectedDay.getFullYear()) !== null && _h !== void 0 ? _h : new Date().getFullYear()), displayedYear = _u[0], setDisplayedYear = _u[1];
170
+ // boolean that toggles between the user picking the start date and end date for date range
171
+ var _v = react_1.default.useState(true), isSelectingStartDate = _v[0], setIsSelectingStartDate = _v[1];
141
172
  // Used to focus days only when days are changed
142
173
  // e.g. without this, when changing months day would be focused
143
174
  var needFocus = react_1.default.useRef(setFocus);
@@ -151,11 +182,16 @@ var DatePicker = function (props) {
151
182
  setDisplayedYear(newYear);
152
183
  }, []);
153
184
  react_1.default.useEffect(function () {
185
+ var _a, _b, _c, _d;
154
186
  var currentDate = new Date();
155
187
  setSelectedDay(date);
156
- setFocusedDay(date !== null && date !== void 0 ? date : currentDate);
157
- setMonthAndYear(date ? date.getMonth() : currentDate.getMonth(), date ? date.getFullYear() : currentDate.getFullYear());
158
- }, [date, setMonthAndYear]);
188
+ setSelectedStartDay(startDate);
189
+ setSelectedEndDay(endDate);
190
+ if (!enableRangeSelect) {
191
+ setFocusedDay(date !== null && date !== void 0 ? date : currentDate);
192
+ }
193
+ setMonthAndYear((_b = (_a = startDate === null || startDate === void 0 ? void 0 : startDate.getMonth()) !== null && _a !== void 0 ? _a : date === null || date === void 0 ? void 0 : date.getMonth()) !== null && _b !== void 0 ? _b : currentDate.getMonth(), (_d = (_c = startDate === null || startDate === void 0 ? void 0 : startDate.getFullYear()) !== null && _c !== void 0 ? _c : date === null || date === void 0 ? void 0 : date.getFullYear()) !== null && _d !== void 0 ? _d : currentDate.getFullYear());
194
+ }, [date, setMonthAndYear, startDate, endDate, enableRangeSelect]);
159
195
  var days = react_1.default.useMemo(function () {
160
196
  var offsetToFirst = new Date(displayedYear, displayedMonthIndex, 1).getDay();
161
197
  // if its sunday, show one week before
@@ -179,7 +215,8 @@ var DatePicker = function (props) {
179
215
  return weeksInMonth;
180
216
  }, [days]);
181
217
  var getNewFocusedDate = function (newYear, newMonth) {
182
- var currentDate = selectedDay !== null && selectedDay !== void 0 ? selectedDay : new Date();
218
+ var _a;
219
+ var currentDate = (_a = selectedStartDay !== null && selectedStartDay !== void 0 ? selectedStartDay : selectedDay) !== null && _a !== void 0 ? _a : new Date();
183
220
  var newDate = new Date(newYear, newMonth, currentDate.getDate(), currentDate.getHours(), currentDate.getMinutes(), currentDate.getSeconds());
184
221
  return newDate;
185
222
  };
@@ -206,14 +243,55 @@ var DatePicker = function (props) {
206
243
  setFocusedDay(getNewFocusedDate(newYear, newMonth));
207
244
  };
208
245
  var onDayClick = function (day) {
209
- if (day.getMonth() !== (selectedDay === null || selectedDay === void 0 ? void 0 : selectedDay.getMonth())) {
210
- setMonthAndYear(day.getMonth(), day.getFullYear());
246
+ // single date selection
247
+ if (!enableRangeSelect) {
248
+ if (day.getMonth() !== (selectedDay === null || selectedDay === void 0 ? void 0 : selectedDay.getMonth())) {
249
+ setMonthAndYear(day.getMonth(), day.getFullYear());
250
+ }
251
+ var currentDate = selectedDay !== null && selectedDay !== void 0 ? selectedDay : new Date();
252
+ var newDate = new Date(day.getFullYear(), day.getMonth(), day.getDate(), currentDate.getHours(), currentDate.getMinutes(), currentDate.getSeconds());
253
+ setSelectedDay(newDate);
254
+ setFocusedDay(newDate);
255
+ isSingleOnChange(onChange, enableRangeSelect) && (onChange === null || onChange === void 0 ? void 0 : onChange(newDate));
256
+ }
257
+ // start date selection (date range only)
258
+ else if (isSelectingStartDate) {
259
+ if (day.getMonth() !== (selectedStartDay === null || selectedStartDay === void 0 ? void 0 : selectedStartDay.getMonth())) {
260
+ setMonthAndYear(day.getMonth(), day.getFullYear());
261
+ }
262
+ var currentStartDate = selectedStartDay !== null && selectedStartDay !== void 0 ? selectedStartDay : new Date();
263
+ var newStartDate = new Date(day.getFullYear(), day.getMonth(), day.getDate(), currentStartDate.getHours(), currentStartDate.getMinutes(), currentStartDate.getSeconds());
264
+ setSelectedStartDay(newStartDate);
265
+ setFocusedDay(newStartDate);
266
+ // if the start date is after the end date or the end date is undefined, reset the end date
267
+ if (!isBefore(newStartDate, selectedEndDay)) {
268
+ setSelectedEndDay(newStartDate);
269
+ onChange === null || onChange === void 0 ? void 0 : onChange(newStartDate, newStartDate);
270
+ }
271
+ else {
272
+ selectedEndDay && (onChange === null || onChange === void 0 ? void 0 : onChange(newStartDate, selectedEndDay));
273
+ }
274
+ setIsSelectingStartDate(false);
275
+ }
276
+ // end date selection (date range only)
277
+ else {
278
+ if (day.getMonth() !== (selectedEndDay === null || selectedEndDay === void 0 ? void 0 : selectedEndDay.getMonth())) {
279
+ setMonthAndYear(day.getMonth(), day.getFullYear());
280
+ }
281
+ var currentEndDate = selectedEndDay !== null && selectedEndDay !== void 0 ? selectedEndDay : new Date();
282
+ var newEndDate = new Date(day.getFullYear(), day.getMonth(), day.getDate(), currentEndDate.getHours(), currentEndDate.getMinutes(), currentEndDate.getSeconds());
283
+ setFocusedDay(newEndDate);
284
+ // if the end date is before the start date, move back the start date and still have user select end date
285
+ if (!isBefore(newEndDate, selectedStartDay)) {
286
+ setSelectedEndDay(newEndDate);
287
+ selectedStartDay && (onChange === null || onChange === void 0 ? void 0 : onChange(selectedStartDay, newEndDate));
288
+ setIsSelectingStartDate(true);
289
+ }
290
+ else {
291
+ setSelectedStartDay(newEndDate);
292
+ selectedEndDay && (onChange === null || onChange === void 0 ? void 0 : onChange(newEndDate, selectedEndDay));
293
+ }
211
294
  }
212
- var currentDate = selectedDay !== null && selectedDay !== void 0 ? selectedDay : new Date();
213
- var newDate = new Date(day.getFullYear(), day.getMonth(), day.getDate(), currentDate.getHours(), currentDate.getMinutes(), currentDate.getSeconds());
214
- setSelectedDay(newDate);
215
- setFocusedDay(newDate);
216
- onChange === null || onChange === void 0 ? void 0 : onChange(newDate);
217
295
  };
218
296
  var handleCalendarKeyDown = function (event) {
219
297
  if (!focusedDay) {
@@ -270,9 +348,23 @@ var DatePicker = function (props) {
270
348
  return 'iui-calendar-day-outside-month';
271
349
  }
272
350
  var dayClass = 'iui-calendar-day';
273
- if (isSameDay(day, selectedDay)) {
351
+ var isSelectedDay = isSameDay(day, selectedDay) ||
352
+ (isSameDay(day, selectedStartDay) && isSameDay(day, selectedEndDay));
353
+ if (isSelectedDay) {
274
354
  dayClass += '-selected';
275
355
  }
356
+ else if (isSameDay(day, selectedStartDay)) {
357
+ dayClass += '-range-start';
358
+ }
359
+ else if (isSameDay(day, selectedEndDay)) {
360
+ dayClass += '-range-end';
361
+ }
362
+ // adds range class to dates between start and end date
363
+ if (selectedStartDay &&
364
+ selectedEndDay &&
365
+ isInDateRange(day, selectedStartDay, selectedEndDay)) {
366
+ dayClass += '-range';
367
+ }
276
368
  if (isSameDay(day, new Date())) {
277
369
  dayClass += '-today';
278
370
  }
@@ -304,7 +396,12 @@ var DatePicker = function (props) {
304
396
  } }, dateValue));
305
397
  })));
306
398
  }))),
307
- showTime && (react_1.default.createElement(TimePicker_1.TimePicker, { date: selectedDay, use12Hours: use12Hours, precision: precision, hourStep: hourStep, minuteStep: minuteStep, secondStep: secondStep, onChange: function (date) { return onChange === null || onChange === void 0 ? void 0 : onChange(date); } }))));
399
+ showTime && (react_1.default.createElement(TimePicker_1.TimePicker, { date: selectedStartDay !== null && selectedStartDay !== void 0 ? selectedStartDay : selectedDay, use12Hours: use12Hours, precision: precision, hourStep: hourStep, minuteStep: minuteStep, secondStep: secondStep, onChange: function (date) {
400
+ var _a, _b, _c, _d, _e, _f;
401
+ return isSingleOnChange(onChange, enableRangeSelect)
402
+ ? onChange === null || onChange === void 0 ? void 0 : onChange(date)
403
+ : onChange === null || onChange === void 0 ? void 0 : onChange(new Date((_a = selectedStartDay === null || selectedStartDay === void 0 ? void 0 : selectedStartDay.getFullYear()) !== null && _a !== void 0 ? _a : date.getFullYear(), (_b = selectedStartDay === null || selectedStartDay === void 0 ? void 0 : selectedStartDay.getMonth()) !== null && _b !== void 0 ? _b : date.getMonth(), (_c = selectedStartDay === null || selectedStartDay === void 0 ? void 0 : selectedStartDay.getDate()) !== null && _c !== void 0 ? _c : date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds()), new Date((_d = selectedEndDay === null || selectedEndDay === void 0 ? void 0 : selectedEndDay.getFullYear()) !== null && _d !== void 0 ? _d : date.getFullYear(), (_e = selectedEndDay === null || selectedEndDay === void 0 ? void 0 : selectedEndDay.getMonth()) !== null && _e !== void 0 ? _e : date.getMonth(), (_f = selectedEndDay === null || selectedEndDay === void 0 ? void 0 : selectedEndDay.getDate()) !== null && _f !== void 0 ? _f : date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds()));
404
+ } }))));
308
405
  };
309
406
  exports.DatePicker = DatePicker;
310
407
  exports.default = exports.DatePicker;
@@ -6,7 +6,7 @@ export declare type DialogProps = {
6
6
  * Dialog content.
7
7
  */
8
8
  children: React.ReactNode;
9
- } & DialogContextProps;
9
+ } & Omit<DialogContextProps, 'dialogRootRef'> & React.ComponentPropsWithRef<'div'>;
10
10
  /**
11
11
  * Dialog component.
12
12
  * @example
@@ -29,10 +29,10 @@ export declare type DialogProps = {
29
29
  * </Dialog.Main>
30
30
  * </Dialog>
31
31
  */
32
- export declare const Dialog: ((props: DialogProps) => JSX.Element) & {
33
- Backdrop: React.ForwardRefExoticComponent<Pick<import("./DialogBackdrop").DialogBackdropProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "isVisible" | "isDismissible" | "closeOnExternalClick"> & React.RefAttributes<HTMLDivElement>>;
34
- Main: React.ForwardRefExoticComponent<Pick<import("./DialogMain").DialogMainProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "styleType" | "isOpen" | "isDismissible" | "closeOnEsc" | "trapFocus" | "preventDocumentScroll"> & React.RefAttributes<HTMLDivElement>>;
35
- TitleBar: React.ForwardRefExoticComponent<Pick<import("./DialogTitleBar").DialogTitleBarProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "isDismissible" | "titleText"> & React.RefAttributes<HTMLDivElement>> & {
32
+ export declare const Dialog: React.ForwardRefExoticComponent<Pick<DialogProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "setFocus" | "isOpen" | "isDismissible" | "isDraggable" | "closeOnExternalClick" | "closeOnEsc" | "trapFocus" | "preventDocumentScroll" | "isResizable" | "relativeTo"> & React.RefAttributes<HTMLDivElement>> & {
33
+ Backdrop: React.ForwardRefExoticComponent<Pick<import("./DialogBackdrop").DialogBackdropProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "isVisible" | "isDismissible" | "closeOnExternalClick" | "relativeTo"> & React.RefAttributes<HTMLDivElement>>;
34
+ Main: React.ForwardRefExoticComponent<Pick<import("./DialogMain").DialogMainProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "styleType" | "setFocus" | "isOpen" | "isDismissible" | "isDraggable" | "closeOnEsc" | "trapFocus" | "preventDocumentScroll" | "isResizable" | "relativeTo"> & React.RefAttributes<HTMLDivElement>>;
35
+ TitleBar: React.ForwardRefExoticComponent<Pick<import("./DialogTitleBar").DialogTitleBarProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "isDismissible" | "isDraggable" | "titleText"> & React.RefAttributes<HTMLDivElement>> & {
36
36
  Title: React.ForwardRefExoticComponent<Pick<import("./DialogTitleBarTitle").DialogTitleBarTitleProps, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>>;
37
37
  };
38
38
  Content: React.ForwardRefExoticComponent<Pick<import("./DialogContent").DialogContentProps, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>>;
@@ -1,4 +1,26 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
2
24
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
25
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
26
  };
@@ -9,13 +31,15 @@ exports.Dialog = void 0;
9
31
  * See LICENSE.md in the project root for license terms and full copyright notice.
10
32
  *--------------------------------------------------------------------------------------------*/
11
33
  var react_1 = __importDefault(require("react"));
34
+ var classnames_1 = __importDefault(require("classnames"));
12
35
  require("@itwin/itwinui-css/css/dialog.css");
13
36
  var DialogTitleBar_1 = require("./DialogTitleBar");
14
37
  var DialogContent_1 = require("./DialogContent");
15
38
  var DialogBackdrop_1 = require("./DialogBackdrop");
16
39
  var DialogContext_1 = require("./DialogContext");
17
40
  var DialogButtonBar_1 = require("./DialogButtonBar");
18
- var DialogMain_1 = __importDefault(require("./DialogMain"));
41
+ var DialogMain_1 = require("./DialogMain");
42
+ var utils_1 = require("../utils");
19
43
  /**
20
44
  * Dialog component.
21
45
  * @example
@@ -38,8 +62,10 @@ var DialogMain_1 = __importDefault(require("./DialogMain"));
38
62
  * </Dialog.Main>
39
63
  * </Dialog>
40
64
  */
41
- exports.Dialog = Object.assign(function (props) {
42
- var children = props.children, _a = props.trapFocus, trapFocus = _a === void 0 ? false : _a, _b = props.preventDocumentScroll, preventDocumentScroll = _b === void 0 ? false : _b, _c = props.isOpen, isOpen = _c === void 0 ? false : _c, _d = props.isDismissible, isDismissible = _d === void 0 ? true : _d, _e = props.closeOnEsc, closeOnEsc = _e === void 0 ? true : _e, _f = props.closeOnExternalClick, closeOnExternalClick = _f === void 0 ? false : _f, onClose = props.onClose;
65
+ exports.Dialog = Object.assign(react_1.default.forwardRef(function (props, ref) {
66
+ var children = props.children, _a = props.trapFocus, trapFocus = _a === void 0 ? false : _a, _b = props.setFocus, setFocus = _b === void 0 ? false : _b, _c = props.preventDocumentScroll, preventDocumentScroll = _c === void 0 ? false : _c, _d = props.isOpen, isOpen = _d === void 0 ? false : _d, _e = props.isDismissible, isDismissible = _e === void 0 ? true : _e, _f = props.closeOnEsc, closeOnEsc = _f === void 0 ? true : _f, _g = props.closeOnExternalClick, closeOnExternalClick = _g === void 0 ? false : _g, onClose = props.onClose, _h = props.isDraggable, isDraggable = _h === void 0 ? false : _h, _j = props.isResizable, isResizable = _j === void 0 ? false : _j, _k = props.relativeTo, relativeTo = _k === void 0 ? 'viewport' : _k, className = props.className, style = props.style, rest = __rest(props, ["children", "trapFocus", "setFocus", "preventDocumentScroll", "isOpen", "isDismissible", "closeOnEsc", "closeOnExternalClick", "onClose", "isDraggable", "isResizable", "relativeTo", "className", "style"]);
67
+ var dialogRootRef = react_1.default.useRef(null);
68
+ var refs = (0, utils_1.useMergedRefs)(ref, dialogRootRef);
43
69
  return (react_1.default.createElement(DialogContext_1.DialogContext.Provider, { value: {
44
70
  isOpen: isOpen,
45
71
  onClose: onClose,
@@ -48,10 +74,16 @@ exports.Dialog = Object.assign(function (props) {
48
74
  isDismissible: isDismissible,
49
75
  preventDocumentScroll: preventDocumentScroll,
50
76
  trapFocus: trapFocus,
51
- } }, children));
52
- }, {
77
+ setFocus: setFocus,
78
+ isDraggable: isDraggable,
79
+ isResizable: isResizable,
80
+ relativeTo: relativeTo,
81
+ dialogRootRef: dialogRootRef,
82
+ } },
83
+ react_1.default.createElement("div", __assign({ className: (0, classnames_1.default)('iui-dialog-wrapper', className), ref: refs, style: __assign({ position: relativeTo === 'container' ? 'absolute' : 'fixed' }, style) }, rest), children)));
84
+ }), {
53
85
  Backdrop: DialogBackdrop_1.DialogBackdrop,
54
- Main: DialogMain_1.default,
86
+ Main: DialogMain_1.DialogMain,
55
87
  TitleBar: DialogTitleBar_1.DialogTitleBar,
56
88
  Content: DialogContent_1.DialogContent,
57
89
  ButtonBar: DialogButtonBar_1.DialogButtonBar,
@@ -1,12 +1,12 @@
1
1
  import React from 'react';
2
2
  import { BackdropProps } from '../Backdrop';
3
3
  import { DialogContextProps } from './DialogContext';
4
- export declare type DialogBackdropProps = BackdropProps & Pick<DialogContextProps, 'onClose' | 'isDismissible' | 'closeOnExternalClick'>;
4
+ export declare type DialogBackdropProps = BackdropProps & Pick<DialogContextProps, 'onClose' | 'isDismissible' | 'closeOnExternalClick' | 'relativeTo'>;
5
5
  /**
6
6
  * Backdrop component for dialog. Recommended to be used with `Dialog`
7
7
  * then its visibility is being controlled by dialog's `isOpen` prop.
8
8
  * @example
9
9
  * <Dialog.Backdrop />
10
10
  */
11
- export declare const DialogBackdrop: React.ForwardRefExoticComponent<Pick<DialogBackdropProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "isVisible" | "isDismissible" | "closeOnExternalClick"> & React.RefAttributes<HTMLDivElement>>;
11
+ export declare const DialogBackdrop: React.ForwardRefExoticComponent<Pick<DialogBackdropProps, "onClose" | "key" | keyof React.HTMLAttributes<HTMLDivElement> | "isVisible" | "isDismissible" | "closeOnExternalClick" | "relativeTo"> & React.RefAttributes<HTMLDivElement>>;
12
12
  export default DialogBackdrop;
@@ -42,7 +42,7 @@ var DialogContext_1 = require("./DialogContext");
42
42
  */
43
43
  exports.DialogBackdrop = react_1.default.forwardRef(function (props, ref) {
44
44
  var dialogContext = (0, DialogContext_1.useDialogContext)();
45
- var _a = props.isVisible, isVisible = _a === void 0 ? dialogContext.isOpen : _a, _b = props.isDismissible, isDismissible = _b === void 0 ? dialogContext.isDismissible : _b, _c = props.onClose, onClose = _c === void 0 ? dialogContext.onClose : _c, _d = props.closeOnExternalClick, closeOnExternalClick = _d === void 0 ? dialogContext.closeOnExternalClick : _d, onMouseDown = props.onMouseDown, rest = __rest(props, ["isVisible", "isDismissible", "onClose", "closeOnExternalClick", "onMouseDown"]);
45
+ var _a = props.isVisible, isVisible = _a === void 0 ? dialogContext.isOpen : _a, _b = props.isDismissible, isDismissible = _b === void 0 ? dialogContext.isDismissible : _b, _c = props.onClose, onClose = _c === void 0 ? dialogContext.onClose : _c, _d = props.closeOnExternalClick, closeOnExternalClick = _d === void 0 ? dialogContext.closeOnExternalClick : _d, _e = props.relativeTo, relativeTo = _e === void 0 ? dialogContext.relativeTo : _e, onMouseDown = props.onMouseDown, style = props.style, rest = __rest(props, ["isVisible", "isDismissible", "onClose", "closeOnExternalClick", "relativeTo", "onMouseDown", "style"]);
46
46
  var backdropRef = react_1.default.useRef(null);
47
47
  var refs = (0, utils_1.useMergedRefs)(backdropRef, ref);
48
48
  var handleMouseDown = function (event) {
@@ -56,6 +56,6 @@ exports.DialogBackdrop = react_1.default.forwardRef(function (props, ref) {
56
56
  }
57
57
  onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
58
58
  };
59
- return (react_1.default.createElement(Backdrop_1.Backdrop, __assign({ isVisible: isVisible, ref: refs, onMouseDown: handleMouseDown }, rest)));
59
+ return (react_1.default.createElement(Backdrop_1.Backdrop, __assign({ isVisible: isVisible, ref: refs, onMouseDown: handleMouseDown, style: __assign({ pointerEvents: 'auto', position: relativeTo === 'container' ? 'absolute' : 'fixed' }, style) }, rest)));
60
60
  });
61
61
  exports.default = exports.DialogBackdrop;