@itwin/itwinui-react 1.34.1 → 1.36.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.
- package/CHANGELOG.md +35 -0
- package/cjs/core/ButtonGroup/ButtonGroup.js +1 -0
- package/cjs/core/Carousel/Carousel.d.ts +68 -0
- package/cjs/core/Carousel/Carousel.js +130 -0
- package/cjs/core/Carousel/CarouselContext.d.ts +37 -0
- package/cjs/core/Carousel/CarouselContext.js +12 -0
- package/cjs/core/Carousel/CarouselDot.d.ts +13 -0
- package/cjs/core/Carousel/CarouselDot.js +46 -0
- package/cjs/core/Carousel/CarouselDotsList.d.ts +32 -0
- package/cjs/core/Carousel/CarouselDotsList.js +132 -0
- package/cjs/core/Carousel/CarouselNavigation.d.ts +15 -0
- package/cjs/core/Carousel/CarouselNavigation.js +88 -0
- package/cjs/core/Carousel/CarouselSlide.d.ts +14 -0
- package/cjs/core/Carousel/CarouselSlide.js +63 -0
- package/cjs/core/Carousel/CarouselSlider.d.ts +5 -0
- package/cjs/core/Carousel/CarouselSlider.js +94 -0
- package/cjs/core/Carousel/index.d.ts +4 -0
- package/cjs/core/Carousel/index.js +10 -0
- package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
- package/cjs/core/DatePicker/DatePicker.d.ts +5 -0
- package/cjs/core/DatePicker/DatePicker.js +38 -13
- package/cjs/core/Menu/Menu.js +8 -3
- package/cjs/core/Modal/Modal.d.ts +5 -0
- package/cjs/core/Modal/Modal.js +11 -9
- package/cjs/core/Modal/ModalContent.d.ts +14 -0
- package/cjs/core/Modal/ModalContent.js +46 -0
- package/cjs/core/Modal/index.d.ts +2 -0
- package/cjs/core/Modal/index.js +3 -1
- package/cjs/core/Table/Table.d.ts +1 -0
- package/cjs/core/Table/Table.js +34 -20
- package/cjs/core/Table/TableCell.js +3 -3
- package/cjs/core/Table/TableRowMemoized.js +12 -7
- package/cjs/core/Table/actionHandlers/index.d.ts +2 -1
- package/cjs/core/Table/actionHandlers/index.js +5 -1
- package/cjs/core/Table/cells/DefaultCell.d.ts +1 -1
- package/cjs/core/Table/cells/DefaultCell.js +5 -2
- package/cjs/core/Table/columns/actionColumn.d.ts +35 -0
- package/cjs/core/Table/columns/actionColumn.js +91 -0
- package/cjs/core/Table/columns/expanderColumn.d.ts +47 -0
- package/cjs/core/Table/columns/expanderColumn.js +81 -0
- package/cjs/core/Table/columns/index.d.ts +3 -0
- package/cjs/core/Table/columns/index.js +15 -0
- package/cjs/core/Table/columns/selectionColumn.d.ts +35 -0
- package/cjs/core/Table/columns/selectionColumn.js +67 -0
- package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.js +18 -2
- package/cjs/core/Table/hooks/index.d.ts +2 -2
- package/cjs/core/Table/hooks/index.js +1 -3
- package/cjs/core/Table/hooks/useExpanderCell.d.ts +0 -1
- package/cjs/core/Table/hooks/useExpanderCell.js +25 -39
- package/cjs/core/Table/hooks/useResizeColumns.js +8 -2
- package/cjs/core/Table/hooks/useSelectionCell.d.ts +0 -1
- package/cjs/core/Table/hooks/useSelectionCell.js +6 -52
- package/cjs/core/Table/index.d.ts +1 -0
- package/cjs/core/Table/index.js +5 -1
- package/cjs/core/Table/utils.js +1 -1
- package/cjs/core/Toast/Toast.js +1 -1
- package/cjs/core/Typography/Anchor/Anchor.d.ts +1 -0
- package/cjs/core/Typography/Anchor/Anchor.js +1 -0
- package/cjs/core/index.d.ts +5 -3
- package/cjs/core/index.js +9 -2
- package/cjs/core/utils/components/Popover.js +13 -1
- package/cjs/core/utils/hooks/index.d.ts +1 -0
- package/cjs/core/utils/hooks/index.js +1 -0
- package/cjs/core/utils/hooks/useMediaQuery.d.ts +2 -0
- package/cjs/core/utils/hooks/useMediaQuery.js +46 -0
- package/cjs/core/utils/hooks/useTheme.d.ts +5 -0
- package/cjs/core/utils/hooks/useTheme.js +20 -14
- package/cjs/types/react-table-config.d.ts +18 -0
- package/esm/core/ButtonGroup/ButtonGroup.js +1 -0
- package/esm/core/Carousel/Carousel.d.ts +68 -0
- package/esm/core/Carousel/Carousel.js +124 -0
- package/esm/core/Carousel/CarouselContext.d.ts +37 -0
- package/esm/core/Carousel/CarouselContext.js +6 -0
- package/esm/core/Carousel/CarouselDot.d.ts +13 -0
- package/esm/core/Carousel/CarouselDot.js +40 -0
- package/esm/core/Carousel/CarouselDotsList.d.ts +32 -0
- package/esm/core/Carousel/CarouselDotsList.js +126 -0
- package/esm/core/Carousel/CarouselNavigation.d.ts +15 -0
- package/esm/core/Carousel/CarouselNavigation.js +82 -0
- package/esm/core/Carousel/CarouselSlide.d.ts +14 -0
- package/esm/core/Carousel/CarouselSlide.js +57 -0
- package/esm/core/Carousel/CarouselSlider.d.ts +5 -0
- package/esm/core/Carousel/CarouselSlider.js +88 -0
- package/esm/core/Carousel/index.d.ts +4 -0
- package/esm/core/Carousel/index.js +6 -0
- package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
- package/esm/core/DatePicker/DatePicker.d.ts +5 -0
- package/esm/core/DatePicker/DatePicker.js +38 -13
- package/esm/core/Menu/Menu.js +8 -3
- package/esm/core/Modal/Modal.d.ts +5 -0
- package/esm/core/Modal/Modal.js +11 -9
- package/esm/core/Modal/ModalContent.d.ts +14 -0
- package/esm/core/Modal/ModalContent.js +39 -0
- package/esm/core/Modal/index.d.ts +2 -0
- package/esm/core/Modal/index.js +1 -0
- package/esm/core/Table/Table.d.ts +1 -0
- package/esm/core/Table/Table.js +30 -16
- package/esm/core/Table/TableCell.js +2 -2
- package/esm/core/Table/TableRowMemoized.js +12 -7
- package/esm/core/Table/actionHandlers/index.d.ts +2 -1
- package/esm/core/Table/actionHandlers/index.js +2 -1
- package/esm/core/Table/cells/DefaultCell.d.ts +1 -1
- package/esm/core/Table/cells/DefaultCell.js +5 -2
- package/esm/core/Table/columns/actionColumn.d.ts +35 -0
- package/esm/core/Table/columns/actionColumn.js +84 -0
- package/esm/core/Table/columns/expanderColumn.d.ts +47 -0
- package/esm/core/Table/columns/expanderColumn.js +74 -0
- package/esm/core/Table/columns/index.d.ts +3 -0
- package/esm/core/Table/columns/index.js +7 -0
- package/esm/core/Table/columns/selectionColumn.d.ts +35 -0
- package/esm/core/Table/columns/selectionColumn.js +60 -0
- package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.js +18 -2
- package/esm/core/Table/hooks/index.d.ts +2 -2
- package/esm/core/Table/hooks/index.js +2 -2
- package/esm/core/Table/hooks/useExpanderCell.d.ts +0 -1
- package/esm/core/Table/hooks/useExpanderCell.js +24 -35
- package/esm/core/Table/hooks/useResizeColumns.js +8 -2
- package/esm/core/Table/hooks/useSelectionCell.d.ts +0 -1
- package/esm/core/Table/hooks/useSelectionCell.js +5 -48
- package/esm/core/Table/index.d.ts +1 -0
- package/esm/core/Table/index.js +1 -0
- package/esm/core/Table/utils.js +1 -1
- package/esm/core/Toast/Toast.js +1 -1
- package/esm/core/Typography/Anchor/Anchor.d.ts +1 -0
- package/esm/core/Typography/Anchor/Anchor.js +1 -0
- package/esm/core/index.d.ts +5 -3
- package/esm/core/index.js +3 -2
- package/esm/core/utils/components/Popover.js +13 -1
- package/esm/core/utils/hooks/index.d.ts +1 -0
- package/esm/core/utils/hooks/index.js +1 -0
- package/esm/core/utils/hooks/useMediaQuery.d.ts +2 -0
- package/esm/core/utils/hooks/useMediaQuery.js +39 -0
- package/esm/core/utils/hooks/useTheme.d.ts +5 -0
- package/esm/core/utils/hooks/useTheme.js +20 -14
- package/esm/types/react-table-config.d.ts +18 -0
- package/package.json +3 -2
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
/*---------------------------------------------------------------------------------------------
|
|
24
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
25
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
26
|
+
*--------------------------------------------------------------------------------------------*/
|
|
27
|
+
import React from 'react';
|
|
28
|
+
import cx from 'classnames';
|
|
29
|
+
import { CarouselContext } from './CarouselContext';
|
|
30
|
+
import { IconButton } from '../Buttons';
|
|
31
|
+
import { CarouselDotsList } from './CarouselDotsList';
|
|
32
|
+
import SvgChevronLeft from '@itwin/itwinui-icons-react/cjs/icons/ChevronLeft';
|
|
33
|
+
import SvgChevronRight from '@itwin/itwinui-icons-react/cjs/icons/ChevronRight';
|
|
34
|
+
/** Button for switching to previous slide */
|
|
35
|
+
var PreviousButton = React.forwardRef(function (props, ref) {
|
|
36
|
+
var context = React.useContext(CarouselContext);
|
|
37
|
+
if (!context) {
|
|
38
|
+
throw new Error('CarouselNavigation should be used inside Carousel');
|
|
39
|
+
}
|
|
40
|
+
var slideCount = context.slideCount, setCurrentIndex = context.setCurrentIndex, keysPressed = context.keysPressed, scrollInstantly = context.scrollInstantly;
|
|
41
|
+
return (React.createElement(IconButton, __assign({ styleType: 'borderless', size: 'small', tabIndex: -1, "data-pressed": keysPressed['ArrowLeft'] || undefined, ref: ref }, props, { onClick: function (e) {
|
|
42
|
+
var _a;
|
|
43
|
+
if (e.detail > 3) {
|
|
44
|
+
scrollInstantly.current = true;
|
|
45
|
+
}
|
|
46
|
+
setCurrentIndex(function (old) { return (slideCount + old - 1) % slideCount; });
|
|
47
|
+
(_a = props === null || props === void 0 ? void 0 : props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
48
|
+
} }),
|
|
49
|
+
React.createElement(SvgChevronLeft, null)));
|
|
50
|
+
});
|
|
51
|
+
/** Button for switching to next slide */
|
|
52
|
+
var NextButton = React.forwardRef(function (props, ref) {
|
|
53
|
+
var context = React.useContext(CarouselContext);
|
|
54
|
+
if (!context) {
|
|
55
|
+
throw new Error('CarouselNavigation should be used inside Carousel');
|
|
56
|
+
}
|
|
57
|
+
var slideCount = context.slideCount, setCurrentIndex = context.setCurrentIndex, keysPressed = context.keysPressed, scrollInstantly = context.scrollInstantly;
|
|
58
|
+
return (React.createElement(IconButton, __assign({ styleType: 'borderless', size: 'small', tabIndex: -1, "data-pressed": keysPressed['ArrowRight'] || undefined, ref: ref }, props, { onClick: function (e) {
|
|
59
|
+
var _a;
|
|
60
|
+
if (e.detail > 3) {
|
|
61
|
+
scrollInstantly.current = true;
|
|
62
|
+
}
|
|
63
|
+
setCurrentIndex(function (old) { return (slideCount + old + 1) % slideCount; });
|
|
64
|
+
(_a = props === null || props === void 0 ? void 0 : props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
65
|
+
} }),
|
|
66
|
+
React.createElement(SvgChevronRight, null)));
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* The `CarouselNavigation` component by default consists of the `PreviousButton` and `NextButton`
|
|
70
|
+
* shown on the left and right, and the `CarouselDotsList` component shown in the middle.
|
|
71
|
+
*
|
|
72
|
+
* `children` can be specified to override what is shown in this navigation section.
|
|
73
|
+
*/
|
|
74
|
+
export var CarouselNavigation = Object.assign(React.forwardRef(function (props, ref) {
|
|
75
|
+
var className = props.className, children = props.children, rest = __rest(props, ["className", "children"]);
|
|
76
|
+
return (React.createElement("nav", __assign({ className: cx('iui-carousel-navigation', className), ref: ref }, rest), children !== null && children !== void 0 ? children : (React.createElement(React.Fragment, null,
|
|
77
|
+
React.createElement("div", { className: 'iui-carousel-navigation-left' },
|
|
78
|
+
React.createElement(PreviousButton, null)),
|
|
79
|
+
React.createElement(CarouselDotsList, null),
|
|
80
|
+
React.createElement("div", { className: 'iui-carousel-navigation-right' },
|
|
81
|
+
React.createElement(NextButton, null))))));
|
|
82
|
+
}), { PreviousButton: PreviousButton, NextButton: NextButton });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* `CarouselSlide` is used for the actual slide content. The content can be specified through `children`.
|
|
4
|
+
*
|
|
5
|
+
* It is recommended that the slide content bring its own dimensions (esp. height) and that
|
|
6
|
+
* the dimensions should be the same for all slides.
|
|
7
|
+
*/
|
|
8
|
+
export declare const CarouselSlide: React.ForwardRefExoticComponent<{
|
|
9
|
+
/**
|
|
10
|
+
* Index of the current slide.
|
|
11
|
+
* Does not need to be manually specified because it will be set in parent (`CarouselSlider`).
|
|
12
|
+
*/
|
|
13
|
+
index?: number | undefined;
|
|
14
|
+
} & Pick<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "key" | keyof React.LiHTMLAttributes<HTMLLIElement>> & React.RefAttributes<HTMLLIElement>>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
/*---------------------------------------------------------------------------------------------
|
|
24
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
25
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
26
|
+
*--------------------------------------------------------------------------------------------*/
|
|
27
|
+
import React from 'react';
|
|
28
|
+
import cx from 'classnames';
|
|
29
|
+
import { useIntersection, useMergedRefs } from '../utils';
|
|
30
|
+
import { CarouselContext } from './CarouselContext';
|
|
31
|
+
/**
|
|
32
|
+
* `CarouselSlide` is used for the actual slide content. The content can be specified through `children`.
|
|
33
|
+
*
|
|
34
|
+
* It is recommended that the slide content bring its own dimensions (esp. height) and that
|
|
35
|
+
* the dimensions should be the same for all slides.
|
|
36
|
+
*/
|
|
37
|
+
export var CarouselSlide = React.forwardRef(function (props, ref) {
|
|
38
|
+
var index = props.index, className = props.className, children = props.children, rest = __rest(props, ["index", "className", "children"]);
|
|
39
|
+
var context = React.useContext(CarouselContext);
|
|
40
|
+
if (!context || index == null) {
|
|
41
|
+
throw new Error('CarouselSlide must be used within Carousel');
|
|
42
|
+
}
|
|
43
|
+
var currentIndex = context.currentIndex, isManuallyUpdating = context.isManuallyUpdating, setCurrentIndex = context.setCurrentIndex;
|
|
44
|
+
var updateActiveIndexOnScroll = React.useCallback(function () {
|
|
45
|
+
// only update index if scroll was triggered by browser
|
|
46
|
+
if (!isManuallyUpdating.current && currentIndex !== index) {
|
|
47
|
+
setCurrentIndex(index);
|
|
48
|
+
}
|
|
49
|
+
// when manual scroll completes, reset the state of `isManuallyUpdating` so that it's ready for future actions
|
|
50
|
+
if (currentIndex === index) {
|
|
51
|
+
isManuallyUpdating.current = false;
|
|
52
|
+
}
|
|
53
|
+
}, [currentIndex, index, isManuallyUpdating, setCurrentIndex]);
|
|
54
|
+
var intersectionRef = useIntersection(updateActiveIndexOnScroll, { threshold: 0.5 }, false);
|
|
55
|
+
var refs = useMergedRefs(intersectionRef, ref);
|
|
56
|
+
return (React.createElement("li", __assign({ className: cx('iui-carousel-slider-item', className), role: 'tabpanel', "aria-roledescription": 'slide', ref: refs }, rest), children));
|
|
57
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* `CarouselSlider` is the scrollable list that should consist of `CarouselSlide` components.
|
|
4
|
+
*/
|
|
5
|
+
export declare const CarouselSlider: React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.OlHTMLAttributes<HTMLOListElement>, HTMLOListElement>, "key" | keyof React.OlHTMLAttributes<HTMLOListElement>> & React.RefAttributes<HTMLOListElement>>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
/*---------------------------------------------------------------------------------------------
|
|
24
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
25
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
26
|
+
*--------------------------------------------------------------------------------------------*/
|
|
27
|
+
import React from 'react';
|
|
28
|
+
import cx from 'classnames';
|
|
29
|
+
import { CarouselContext } from './CarouselContext';
|
|
30
|
+
import { getWindow, useMergedRefs, useResizeObserver } from '../utils';
|
|
31
|
+
/**
|
|
32
|
+
* `CarouselSlider` is the scrollable list that should consist of `CarouselSlide` components.
|
|
33
|
+
*/
|
|
34
|
+
export var CarouselSlider = React.forwardRef(function (props, ref) {
|
|
35
|
+
var children = props.children, className = props.className, rest = __rest(props, ["children", "className"]);
|
|
36
|
+
var context = React.useContext(CarouselContext);
|
|
37
|
+
if (!context) {
|
|
38
|
+
throw new Error('CarouselSlider must be used within Carousel');
|
|
39
|
+
}
|
|
40
|
+
var currentIndex = context.currentIndex, setSlideCount = context.setSlideCount, idPrefix = context.idPrefix, isManuallyUpdating = context.isManuallyUpdating, scrollInstantly = context.scrollInstantly;
|
|
41
|
+
var items = React.useMemo(function () {
|
|
42
|
+
var _a;
|
|
43
|
+
return (_a = React.Children.map(children, function (child, index) {
|
|
44
|
+
return React.isValidElement(child)
|
|
45
|
+
? React.cloneElement(child, {
|
|
46
|
+
id: idPrefix + "--slide-" + index,
|
|
47
|
+
index: index,
|
|
48
|
+
})
|
|
49
|
+
: child;
|
|
50
|
+
})) !== null && _a !== void 0 ? _a : [];
|
|
51
|
+
}, [children, idPrefix]);
|
|
52
|
+
React.useLayoutEffect(function () {
|
|
53
|
+
setSlideCount(items.length);
|
|
54
|
+
}, [items.length, setSlideCount]);
|
|
55
|
+
var _a = React.useState(), width = _a[0], setWidth = _a[1];
|
|
56
|
+
var resizeRef = useResizeObserver(function (_a) {
|
|
57
|
+
var width = _a.width;
|
|
58
|
+
return setWidth(width);
|
|
59
|
+
})[0];
|
|
60
|
+
var sliderRef = React.useRef(null);
|
|
61
|
+
var refs = useMergedRefs(sliderRef, resizeRef, ref);
|
|
62
|
+
var justMounted = React.useRef(true);
|
|
63
|
+
var previousWidth = React.useRef();
|
|
64
|
+
React.useLayoutEffect(function () {
|
|
65
|
+
var _a, _b, _c;
|
|
66
|
+
var slideToShow = (_a = sliderRef.current) === null || _a === void 0 ? void 0 : _a.children.item(currentIndex);
|
|
67
|
+
if (!sliderRef.current ||
|
|
68
|
+
!slideToShow ||
|
|
69
|
+
(!isManuallyUpdating.current && previousWidth.current === width)) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
// instant scroll on first mount
|
|
73
|
+
if (justMounted.current) {
|
|
74
|
+
scrollInstantly.current = true;
|
|
75
|
+
justMounted.current = false;
|
|
76
|
+
}
|
|
77
|
+
var motionOk = (_c = (_b = getWindow()) === null || _b === void 0 ? void 0 : _b.matchMedia('(prefers-reduced-motion: no-preference)')) === null || _c === void 0 ? void 0 : _c.matches;
|
|
78
|
+
sliderRef.current.scrollTo({
|
|
79
|
+
left: slideToShow.offsetLeft - sliderRef.current.offsetLeft,
|
|
80
|
+
behavior: (scrollInstantly.current || !motionOk
|
|
81
|
+
? 'instant'
|
|
82
|
+
: 'smooth'), // scrollTo accepts 'instant' but ScrollBehavior type is wrong
|
|
83
|
+
});
|
|
84
|
+
scrollInstantly.current = false;
|
|
85
|
+
previousWidth.current = width;
|
|
86
|
+
}, [currentIndex, isManuallyUpdating, scrollInstantly, width]);
|
|
87
|
+
return (React.createElement("ol", __assign({ "aria-live": 'polite', className: cx('iui-carousel-slider', className), ref: refs }, rest), items));
|
|
88
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
export { Carousel } from './Carousel';
|
|
6
|
+
export default './Carousel';
|
|
@@ -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" | "role" | "children" | "className" | "accessKey" | "draggable" | "hidden" | "lang" | "translate" | "prefix" | "contentEditable" | "inputMode" | "tabIndex" | "onFocus" | "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" | "
|
|
20
|
+
export declare const ColorSwatch: React.ForwardRefExoticComponent<Pick<ColorSwatchProps, "dir" | "slot" | "style" | "title" | "id" | "aria-disabled" | "role" | "children" | "className" | "onClick" | "accessKey" | "draggable" | "hidden" | "lang" | "translate" | "prefix" | "contentEditable" | "inputMode" | "tabIndex" | "onFocus" | "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" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "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;
|
|
@@ -36,6 +36,11 @@ export declare type DatePickerProps = {
|
|
|
36
36
|
* @default false
|
|
37
37
|
*/
|
|
38
38
|
showTime?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Show additional buttons to select year.
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
showYearSelection?: boolean;
|
|
39
44
|
} & Omit<TimePickerProps, 'date' | 'onChange' | 'setFocusHour'>;
|
|
40
45
|
/**
|
|
41
46
|
* Date picker component
|
|
@@ -26,6 +26,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
26
26
|
*--------------------------------------------------------------------------------------------*/
|
|
27
27
|
import SvgChevronLeft from '@itwin/itwinui-icons-react/cjs/icons/ChevronLeft';
|
|
28
28
|
import SvgChevronRight from '@itwin/itwinui-icons-react/cjs/icons/ChevronRight';
|
|
29
|
+
import SvgChevronLeftDouble from '@itwin/itwinui-icons-react/cjs/icons/ChevronLeftDouble';
|
|
30
|
+
import SvgChevronRightDouble from '@itwin/itwinui-icons-react/cjs/icons/ChevronRightDouble';
|
|
29
31
|
import cx from 'classnames';
|
|
30
32
|
import React from 'react';
|
|
31
33
|
import { useTheme } from '../utils';
|
|
@@ -120,15 +122,15 @@ export var generateLocalizedStrings = function (locale) {
|
|
|
120
122
|
*/
|
|
121
123
|
export var DatePicker = function (props) {
|
|
122
124
|
var _a, _b, _c;
|
|
123
|
-
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, rest = __rest(props, ["date", "onChange", "localizedNames", "className", "style", "setFocus", "showTime", "use12Hours", "precision", "hourStep", "minuteStep", "secondStep"]);
|
|
125
|
+
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"]);
|
|
124
126
|
useTheme();
|
|
125
127
|
var monthNames = (_a = localizedNames === null || localizedNames === void 0 ? void 0 : localizedNames.months) !== null && _a !== void 0 ? _a : defaultMonths;
|
|
126
128
|
var shortDays = (_b = localizedNames === null || localizedNames === void 0 ? void 0 : localizedNames.shortDays) !== null && _b !== void 0 ? _b : defaultShortDays;
|
|
127
129
|
var longDays = (_c = localizedNames === null || localizedNames === void 0 ? void 0 : localizedNames.days) !== null && _c !== void 0 ? _c : defaultLongDays;
|
|
128
|
-
var
|
|
129
|
-
var
|
|
130
|
-
var
|
|
131
|
-
var
|
|
130
|
+
var _h = React.useState(date), selectedDay = _h[0], setSelectedDay = _h[1];
|
|
131
|
+
var _j = React.useState(selectedDay !== null && selectedDay !== void 0 ? selectedDay : new Date()), focusedDay = _j[0], setFocusedDay = _j[1];
|
|
132
|
+
var _k = React.useState(selectedDay ? selectedDay.getMonth() : new Date().getMonth()), displayedMonthIndex = _k[0], setDisplayedMonthIndex = _k[1];
|
|
133
|
+
var _l = React.useState(selectedDay ? selectedDay.getFullYear() : new Date().getFullYear()), displayedYear = _l[0], setDisplayedYear = _l[1];
|
|
132
134
|
// Used to focus days only when days are changed
|
|
133
135
|
// e.g. without this, when changing months day would be focused
|
|
134
136
|
var needFocus = React.useRef(setFocus);
|
|
@@ -174,6 +176,16 @@ export var DatePicker = function (props) {
|
|
|
174
176
|
var newDate = new Date(newYear, newMonth, currentDate.getDate(), currentDate.getHours(), currentDate.getMinutes(), currentDate.getSeconds());
|
|
175
177
|
return newDate;
|
|
176
178
|
};
|
|
179
|
+
var handleMoveToPreviousYear = function () {
|
|
180
|
+
var newYear = displayedYear - 1;
|
|
181
|
+
setMonthAndYear(displayedMonthIndex, newYear);
|
|
182
|
+
setFocusedDay(getNewFocusedDate(newYear, displayedMonthIndex));
|
|
183
|
+
};
|
|
184
|
+
var handleMoveToNextYear = function () {
|
|
185
|
+
var newYear = displayedYear + 1;
|
|
186
|
+
setMonthAndYear(displayedMonthIndex, newYear);
|
|
187
|
+
setFocusedDay(getNewFocusedDate(newYear, displayedMonthIndex));
|
|
188
|
+
};
|
|
177
189
|
var handleMoveToPreviousMonth = function () {
|
|
178
190
|
var newMonth = displayedMonthIndex !== 0 ? displayedMonthIndex - 1 : 11;
|
|
179
191
|
var newYear = displayedMonthIndex !== 0 ? displayedYear : displayedYear - 1;
|
|
@@ -246,26 +258,39 @@ export var DatePicker = function (props) {
|
|
|
246
258
|
break;
|
|
247
259
|
}
|
|
248
260
|
};
|
|
261
|
+
var getDayClass = function (day) {
|
|
262
|
+
if (day.getMonth() !== displayedMonthIndex) {
|
|
263
|
+
return 'iui-calendar-day-outside-month';
|
|
264
|
+
}
|
|
265
|
+
var dayClass = 'iui-calendar-day';
|
|
266
|
+
if (isSameDay(day, selectedDay)) {
|
|
267
|
+
dayClass += '-selected';
|
|
268
|
+
}
|
|
269
|
+
if (isSameDay(day, new Date())) {
|
|
270
|
+
dayClass += '-today';
|
|
271
|
+
}
|
|
272
|
+
return dayClass;
|
|
273
|
+
};
|
|
249
274
|
return (React.createElement("div", __assign({ className: cx('iui-date-picker', className), style: style }, rest),
|
|
250
275
|
React.createElement("div", null,
|
|
251
276
|
React.createElement("div", { className: 'iui-calendar-month-year' },
|
|
252
|
-
React.createElement(IconButton, { styleType: 'borderless', onClick:
|
|
277
|
+
showYearSelection && (React.createElement(IconButton, { styleType: 'borderless', onClick: handleMoveToPreviousYear, "aria-label": 'Previous year', size: 'small' },
|
|
278
|
+
React.createElement(SvgChevronLeftDouble, null))),
|
|
279
|
+
React.createElement(IconButton, { styleType: 'borderless', onClick: handleMoveToPreviousMonth, "aria-label": 'Previous month', size: 'small' },
|
|
253
280
|
React.createElement(SvgChevronLeft, null)),
|
|
254
281
|
React.createElement("span", { "aria-live": 'polite' },
|
|
255
282
|
React.createElement("span", { className: 'iui-calendar-month', title: monthNames[displayedMonthIndex] }, monthNames[displayedMonthIndex]),
|
|
256
283
|
"\u00A0",
|
|
257
284
|
displayedYear),
|
|
258
|
-
React.createElement(IconButton, { styleType: 'borderless', onClick: handleMoveToNextMonth, "aria-label": 'Next month' },
|
|
259
|
-
React.createElement(SvgChevronRight, null))
|
|
285
|
+
React.createElement(IconButton, { styleType: 'borderless', onClick: handleMoveToNextMonth, "aria-label": 'Next month', size: 'small' },
|
|
286
|
+
React.createElement(SvgChevronRight, null)),
|
|
287
|
+
showYearSelection && (React.createElement(IconButton, { styleType: 'borderless', onClick: handleMoveToNextYear, "aria-label": 'Next year', size: 'small' },
|
|
288
|
+
React.createElement(SvgChevronRightDouble, null)))),
|
|
260
289
|
React.createElement("div", { className: 'iui-calendar-weekdays' }, shortDays.map(function (day, index) { return (React.createElement("div", { key: day, title: longDays[index] }, day)); })),
|
|
261
290
|
React.createElement("div", { onKeyDown: handleCalendarKeyDown, role: 'listbox' }, weeks.map(function (weekDays, weekIndex) {
|
|
262
291
|
return (React.createElement("div", { key: "week-" + displayedMonthIndex + "-" + weekIndex, className: 'iui-calendar-week' }, weekDays.map(function (weekDay, dayIndex) {
|
|
263
292
|
var dateValue = weekDay.getDate();
|
|
264
|
-
return (React.createElement("div", { key: "day-" + displayedMonthIndex + "-" + dayIndex, className:
|
|
265
|
-
'iui-outside-month': weekDay.getMonth() !== displayedMonthIndex,
|
|
266
|
-
'iui-today': isSameDay(weekDay, new Date()),
|
|
267
|
-
'iui-selected': isSameDay(weekDay, selectedDay),
|
|
268
|
-
}), onClick: function () { return onDayClick(weekDay); }, role: 'option', tabIndex: isSameDay(weekDay, focusedDay) ? 0 : -1, ref: function (element) {
|
|
293
|
+
return (React.createElement("div", { key: "day-" + displayedMonthIndex + "-" + dayIndex, className: getDayClass(weekDay), onClick: function () { return onDayClick(weekDay); }, role: 'option', tabIndex: isSameDay(weekDay, focusedDay) ? 0 : -1, ref: function (element) {
|
|
269
294
|
return isSameDay(weekDay, focusedDay) &&
|
|
270
295
|
needFocus.current &&
|
|
271
296
|
(element === null || element === void 0 ? void 0 : element.focus());
|
package/esm/core/Menu/Menu.js
CHANGED
|
@@ -40,9 +40,14 @@ export var Menu = React.forwardRef(function (props, ref) {
|
|
|
40
40
|
React.useEffect(function () {
|
|
41
41
|
setFocusedIndex(null);
|
|
42
42
|
}, [children]);
|
|
43
|
+
var getFocusableNodes = React.useCallback(function () {
|
|
44
|
+
var focusableItems = getFocusableElements(menuRef.current);
|
|
45
|
+
// Filter out focusable elements that are inside each menu item, e.g. checkbox, anchor
|
|
46
|
+
return focusableItems.filter(function (i) { return !focusableItems.some(function (p) { return p.contains(i.parentElement); }); });
|
|
47
|
+
}, []);
|
|
43
48
|
React.useEffect(function () {
|
|
44
49
|
var _a;
|
|
45
|
-
var items =
|
|
50
|
+
var items = getFocusableNodes();
|
|
46
51
|
if (focusedIndex != null) {
|
|
47
52
|
(_a = items === null || items === void 0 ? void 0 : items[focusedIndex]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
48
53
|
return;
|
|
@@ -51,9 +56,9 @@ export var Menu = React.forwardRef(function (props, ref) {
|
|
|
51
56
|
if (setFocus) {
|
|
52
57
|
setFocusedIndex(selectedIndex > -1 ? selectedIndex : 0);
|
|
53
58
|
}
|
|
54
|
-
}, [setFocus, focusedIndex]);
|
|
59
|
+
}, [setFocus, focusedIndex, getFocusableNodes]);
|
|
55
60
|
var onKeyDown = function (event) {
|
|
56
|
-
var items =
|
|
61
|
+
var items = getFocusableNodes();
|
|
57
62
|
if (!(items === null || items === void 0 ? void 0 : items.length)) {
|
|
58
63
|
return;
|
|
59
64
|
}
|
package/esm/core/Modal/Modal.js
CHANGED
|
@@ -31,6 +31,7 @@ import SvgClose from '@itwin/itwinui-icons-react/cjs/icons/Close';
|
|
|
31
31
|
import { useTheme, getContainer, getDocument, FocusTrap, } from '../utils';
|
|
32
32
|
import '@itwin/itwinui-css/css/modal.css';
|
|
33
33
|
import { IconButton } from '../Buttons/IconButton';
|
|
34
|
+
import { CSSTransition } from 'react-transition-group';
|
|
34
35
|
/**
|
|
35
36
|
* Modal component which can wrap any content.
|
|
36
37
|
* @example
|
|
@@ -53,7 +54,7 @@ import { IconButton } from '../Buttons/IconButton';
|
|
|
53
54
|
* </Modal>
|
|
54
55
|
*/
|
|
55
56
|
export var Modal = function (props) {
|
|
56
|
-
var _a = props.isOpen, isOpen = _a === void 0 ? false : _a, _b = props.isDismissible, isDismissible = _b === void 0 ? true : _b, _c = props.closeOnEsc, closeOnEsc = _c === void 0 ? true : _c, _d = props.closeOnExternalClick, closeOnExternalClick = _d === void 0 ? true : _d, onClose = props.onClose, title = props.title, onKeyDown = props.onKeyDown, id = props.id, className = props.className, style = props.style, children = props.children, _e = props.modalRootId, modalRootId =
|
|
57
|
+
var _a = props.isOpen, isOpen = _a === void 0 ? false : _a, _b = props.isDismissible, isDismissible = _b === void 0 ? true : _b, _c = props.closeOnEsc, closeOnEsc = _c === void 0 ? true : _c, _d = props.closeOnExternalClick, closeOnExternalClick = _d === void 0 ? true : _d, onClose = props.onClose, title = props.title, onKeyDown = props.onKeyDown, id = props.id, className = props.className, style = props.style, children = props.children, _e = props.styleType, styleType = _e === void 0 ? 'default' : _e, _f = props.modalRootId, modalRootId = _f === void 0 ? 'iui-react-portal-container' : _f, _g = props.ownerDocument, ownerDocument = _g === void 0 ? getDocument() : _g, rest = __rest(props, ["isOpen", "isDismissible", "closeOnEsc", "closeOnExternalClick", "onClose", "title", "onKeyDown", "id", "className", "style", "children", "styleType", "modalRootId", "ownerDocument"]);
|
|
57
58
|
useTheme();
|
|
58
59
|
var container = getContainer(modalRootId, ownerDocument);
|
|
59
60
|
var overlayRef = React.useRef(null);
|
|
@@ -111,13 +112,14 @@ export var Modal = function (props) {
|
|
|
111
112
|
onClose(event);
|
|
112
113
|
}
|
|
113
114
|
};
|
|
114
|
-
return !!container ? (ReactDOM.createPortal(
|
|
115
|
-
React.createElement(
|
|
116
|
-
React.createElement("div", { className: 'iui-modal-
|
|
117
|
-
React.createElement("div", { className: 'iui-
|
|
118
|
-
React.createElement("div", { className: 'iui-title' },
|
|
119
|
-
|
|
120
|
-
React.createElement(
|
|
121
|
-
|
|
115
|
+
return !!container ? (ReactDOM.createPortal(React.createElement(CSSTransition, { in: isOpen, classNames: 'iui-modal-animation', timeout: { exit: 600 }, unmountOnExit: true },
|
|
116
|
+
React.createElement(FocusTrap, null,
|
|
117
|
+
React.createElement("div", __assign({ className: cx('iui-modal', { 'iui-modal-full-page': styleType === 'fullPage' }, { 'iui-modal-visible': isOpen }, className), tabIndex: -1, onKeyDown: handleKeyDown, ref: overlayRef, onMouseDown: handleMouseDown }, rest),
|
|
118
|
+
React.createElement("div", { className: 'iui-modal-dialog', id: id, style: style, role: 'dialog', "aria-modal": 'true' },
|
|
119
|
+
React.createElement("div", { className: 'iui-title-bar' },
|
|
120
|
+
React.createElement("div", { className: 'iui-title' }, title),
|
|
121
|
+
isDismissible && (React.createElement(IconButton, { size: 'small', styleType: 'borderless', onClick: onClose, "aria-label": 'Close' },
|
|
122
|
+
React.createElement(SvgClose, null)))),
|
|
123
|
+
children)))), container)) : (React.createElement(React.Fragment, null));
|
|
122
124
|
};
|
|
123
125
|
export default Modal;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CommonProps } from '../utils';
|
|
3
|
+
import '@itwin/itwinui-css/css/modal.css';
|
|
4
|
+
export declare type ModalContentProps = {
|
|
5
|
+
/**
|
|
6
|
+
* Main content in the `Modal`.
|
|
7
|
+
*/
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
} & Omit<CommonProps, 'title'>;
|
|
10
|
+
/**
|
|
11
|
+
* Container for content in `Modal`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const ModalContent: (props: ModalContentProps) => JSX.Element;
|
|
14
|
+
export default ModalContent;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
/*---------------------------------------------------------------------------------------------
|
|
24
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
25
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
26
|
+
*--------------------------------------------------------------------------------------------*/
|
|
27
|
+
import React from 'react';
|
|
28
|
+
import cx from 'classnames';
|
|
29
|
+
import { useTheme } from '../utils';
|
|
30
|
+
import '@itwin/itwinui-css/css/modal.css';
|
|
31
|
+
/**
|
|
32
|
+
* Container for content in `Modal`.
|
|
33
|
+
*/
|
|
34
|
+
export var ModalContent = function (props) {
|
|
35
|
+
var children = props.children, className = props.className, rest = __rest(props, ["children", "className"]);
|
|
36
|
+
useTheme();
|
|
37
|
+
return (React.createElement("div", __assign({ className: cx('iui-modal-content', className) }, rest), children));
|
|
38
|
+
};
|
|
39
|
+
export default ModalContent;
|
|
@@ -2,5 +2,7 @@ export { Modal } from './Modal';
|
|
|
2
2
|
export type { ModalProps } from './Modal';
|
|
3
3
|
export { ModalButtonBar } from './ModalButtonBar';
|
|
4
4
|
export type { ModalButtonBarProps } from './ModalButtonBar';
|
|
5
|
+
export { ModalContent } from './ModalContent';
|
|
6
|
+
export type { ModalContentProps } from './ModalContent';
|
|
5
7
|
declare const _default: "./Modal";
|
|
6
8
|
export default _default;
|
package/esm/core/Modal/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { CellProps, TableOptions, Row, TableState } from 'react-table';
|
|
|
3
3
|
import { CommonProps } from '../utils';
|
|
4
4
|
import '@itwin/itwinui-css/css/table.css';
|
|
5
5
|
import { TableFilterValue } from './filters';
|
|
6
|
+
export declare const tableResizeStartAction = "tableResizeStart";
|
|
6
7
|
export declare type TablePaginatorRendererProps = {
|
|
7
8
|
/**
|
|
8
9
|
* The zero-based index of the current page.
|