@itwin/itwinui-react 1.34.2 → 1.37.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 +43 -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/Header/HeaderButton.js +1 -0
- 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/SkipToContentLink/SkipToContentLink.d.ts +33 -0
- package/cjs/core/SkipToContentLink/SkipToContentLink.js +50 -0
- package/cjs/core/SkipToContentLink/index.d.ts +4 -0
- package/cjs/core/SkipToContentLink/index.js +10 -0
- package/cjs/core/Surface/Surface.d.ts +32 -0
- package/cjs/core/Surface/Surface.js +70 -0
- package/cjs/core/Surface/index.d.ts +4 -0
- package/cjs/core/Surface/index.js +10 -0
- package/cjs/core/Table/Table.d.ts +7 -0
- package/cjs/core/Table/Table.js +51 -27
- 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/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 +1 -2
- package/cjs/core/Table/hooks/useSelectionCell.js +8 -53
- 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/Tag/Tag.js +6 -3
- package/cjs/core/Tile/Tile.d.ts +6 -2
- package/cjs/core/Tile/Tile.js +7 -2
- 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 +9 -3
- package/cjs/core/index.js +13 -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/Header/HeaderButton.js +1 -0
- 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/SkipToContentLink/SkipToContentLink.d.ts +33 -0
- package/esm/core/SkipToContentLink/SkipToContentLink.js +44 -0
- package/esm/core/SkipToContentLink/index.d.ts +4 -0
- package/esm/core/SkipToContentLink/index.js +6 -0
- package/esm/core/Surface/Surface.d.ts +32 -0
- package/esm/core/Surface/Surface.js +64 -0
- package/esm/core/Surface/index.d.ts +4 -0
- package/esm/core/Surface/index.js +6 -0
- package/esm/core/Table/Table.d.ts +7 -0
- package/esm/core/Table/Table.js +47 -23
- 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/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 +1 -2
- package/esm/core/Table/hooks/useSelectionCell.js +7 -49
- 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/Tag/Tag.js +6 -3
- package/esm/core/Tile/Tile.d.ts +6 -2
- package/esm/core/Tile/Tile.js +7 -2
- 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 +9 -3
- package/esm/core/index.js +5 -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,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,63 @@
|
|
|
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
|
+
};
|
|
24
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.CarouselSlide = void 0;
|
|
29
|
+
/*---------------------------------------------------------------------------------------------
|
|
30
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
31
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
32
|
+
*--------------------------------------------------------------------------------------------*/
|
|
33
|
+
var react_1 = __importDefault(require("react"));
|
|
34
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
35
|
+
var utils_1 = require("../utils");
|
|
36
|
+
var CarouselContext_1 = require("./CarouselContext");
|
|
37
|
+
/**
|
|
38
|
+
* `CarouselSlide` is used for the actual slide content. The content can be specified through `children`.
|
|
39
|
+
*
|
|
40
|
+
* It is recommended that the slide content bring its own dimensions (esp. height) and that
|
|
41
|
+
* the dimensions should be the same for all slides.
|
|
42
|
+
*/
|
|
43
|
+
exports.CarouselSlide = react_1.default.forwardRef(function (props, ref) {
|
|
44
|
+
var index = props.index, className = props.className, children = props.children, rest = __rest(props, ["index", "className", "children"]);
|
|
45
|
+
var context = react_1.default.useContext(CarouselContext_1.CarouselContext);
|
|
46
|
+
if (!context || index == null) {
|
|
47
|
+
throw new Error('CarouselSlide must be used within Carousel');
|
|
48
|
+
}
|
|
49
|
+
var currentIndex = context.currentIndex, isManuallyUpdating = context.isManuallyUpdating, setCurrentIndex = context.setCurrentIndex;
|
|
50
|
+
var updateActiveIndexOnScroll = react_1.default.useCallback(function () {
|
|
51
|
+
// only update index if scroll was triggered by browser
|
|
52
|
+
if (!isManuallyUpdating.current && currentIndex !== index) {
|
|
53
|
+
setCurrentIndex(index);
|
|
54
|
+
}
|
|
55
|
+
// when manual scroll completes, reset the state of `isManuallyUpdating` so that it's ready for future actions
|
|
56
|
+
if (currentIndex === index) {
|
|
57
|
+
isManuallyUpdating.current = false;
|
|
58
|
+
}
|
|
59
|
+
}, [currentIndex, index, isManuallyUpdating, setCurrentIndex]);
|
|
60
|
+
var intersectionRef = (0, utils_1.useIntersection)(updateActiveIndexOnScroll, { threshold: 0.5 }, false);
|
|
61
|
+
var refs = (0, utils_1.useMergedRefs)(intersectionRef, ref);
|
|
62
|
+
return (react_1.default.createElement("li", __assign({ className: (0, classnames_1.default)('iui-carousel-slider-item', className), role: 'tabpanel', "aria-roledescription": 'slide', ref: refs }, rest), children));
|
|
63
|
+
});
|
|
@@ -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,94 @@
|
|
|
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
|
+
};
|
|
24
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.CarouselSlider = void 0;
|
|
29
|
+
/*---------------------------------------------------------------------------------------------
|
|
30
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
31
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
32
|
+
*--------------------------------------------------------------------------------------------*/
|
|
33
|
+
var react_1 = __importDefault(require("react"));
|
|
34
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
35
|
+
var CarouselContext_1 = require("./CarouselContext");
|
|
36
|
+
var utils_1 = require("../utils");
|
|
37
|
+
/**
|
|
38
|
+
* `CarouselSlider` is the scrollable list that should consist of `CarouselSlide` components.
|
|
39
|
+
*/
|
|
40
|
+
exports.CarouselSlider = react_1.default.forwardRef(function (props, ref) {
|
|
41
|
+
var children = props.children, className = props.className, rest = __rest(props, ["children", "className"]);
|
|
42
|
+
var context = react_1.default.useContext(CarouselContext_1.CarouselContext);
|
|
43
|
+
if (!context) {
|
|
44
|
+
throw new Error('CarouselSlider must be used within Carousel');
|
|
45
|
+
}
|
|
46
|
+
var currentIndex = context.currentIndex, setSlideCount = context.setSlideCount, idPrefix = context.idPrefix, isManuallyUpdating = context.isManuallyUpdating, scrollInstantly = context.scrollInstantly;
|
|
47
|
+
var items = react_1.default.useMemo(function () {
|
|
48
|
+
var _a;
|
|
49
|
+
return (_a = react_1.default.Children.map(children, function (child, index) {
|
|
50
|
+
return react_1.default.isValidElement(child)
|
|
51
|
+
? react_1.default.cloneElement(child, {
|
|
52
|
+
id: idPrefix + "--slide-" + index,
|
|
53
|
+
index: index,
|
|
54
|
+
})
|
|
55
|
+
: child;
|
|
56
|
+
})) !== null && _a !== void 0 ? _a : [];
|
|
57
|
+
}, [children, idPrefix]);
|
|
58
|
+
react_1.default.useLayoutEffect(function () {
|
|
59
|
+
setSlideCount(items.length);
|
|
60
|
+
}, [items.length, setSlideCount]);
|
|
61
|
+
var _a = react_1.default.useState(), width = _a[0], setWidth = _a[1];
|
|
62
|
+
var resizeRef = (0, utils_1.useResizeObserver)(function (_a) {
|
|
63
|
+
var width = _a.width;
|
|
64
|
+
return setWidth(width);
|
|
65
|
+
})[0];
|
|
66
|
+
var sliderRef = react_1.default.useRef(null);
|
|
67
|
+
var refs = (0, utils_1.useMergedRefs)(sliderRef, resizeRef, ref);
|
|
68
|
+
var justMounted = react_1.default.useRef(true);
|
|
69
|
+
var previousWidth = react_1.default.useRef();
|
|
70
|
+
react_1.default.useLayoutEffect(function () {
|
|
71
|
+
var _a, _b, _c;
|
|
72
|
+
var slideToShow = (_a = sliderRef.current) === null || _a === void 0 ? void 0 : _a.children.item(currentIndex);
|
|
73
|
+
if (!sliderRef.current ||
|
|
74
|
+
!slideToShow ||
|
|
75
|
+
(!isManuallyUpdating.current && previousWidth.current === width)) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
// instant scroll on first mount
|
|
79
|
+
if (justMounted.current) {
|
|
80
|
+
scrollInstantly.current = true;
|
|
81
|
+
justMounted.current = false;
|
|
82
|
+
}
|
|
83
|
+
var motionOk = (_c = (_b = (0, utils_1.getWindow)()) === null || _b === void 0 ? void 0 : _b.matchMedia('(prefers-reduced-motion: no-preference)')) === null || _c === void 0 ? void 0 : _c.matches;
|
|
84
|
+
sliderRef.current.scrollTo({
|
|
85
|
+
left: slideToShow.offsetLeft - sliderRef.current.offsetLeft,
|
|
86
|
+
behavior: (scrollInstantly.current || !motionOk
|
|
87
|
+
? 'instant'
|
|
88
|
+
: 'smooth'), // scrollTo accepts 'instant' but ScrollBehavior type is wrong
|
|
89
|
+
});
|
|
90
|
+
scrollInstantly.current = false;
|
|
91
|
+
previousWidth.current = width;
|
|
92
|
+
}, [currentIndex, isManuallyUpdating, scrollInstantly, width]);
|
|
93
|
+
return (react_1.default.createElement("ol", __assign({ "aria-live": 'polite', className: (0, classnames_1.default)('iui-carousel-slider', className), ref: refs }, rest), items));
|
|
94
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Carousel = void 0;
|
|
4
|
+
/*---------------------------------------------------------------------------------------------
|
|
5
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
+
*--------------------------------------------------------------------------------------------*/
|
|
8
|
+
var Carousel_1 = require("./Carousel");
|
|
9
|
+
Object.defineProperty(exports, "Carousel", { enumerable: true, get: function () { return Carousel_1.Carousel; } });
|
|
10
|
+
exports.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
|
|
@@ -32,6 +32,8 @@ exports.DatePicker = exports.generateLocalizedStrings = void 0;
|
|
|
32
32
|
*--------------------------------------------------------------------------------------------*/
|
|
33
33
|
var ChevronLeft_1 = __importDefault(require("@itwin/itwinui-icons-react/cjs/icons/ChevronLeft"));
|
|
34
34
|
var ChevronRight_1 = __importDefault(require("@itwin/itwinui-icons-react/cjs/icons/ChevronRight"));
|
|
35
|
+
var ChevronLeftDouble_1 = __importDefault(require("@itwin/itwinui-icons-react/cjs/icons/ChevronLeftDouble"));
|
|
36
|
+
var ChevronRightDouble_1 = __importDefault(require("@itwin/itwinui-icons-react/cjs/icons/ChevronRightDouble"));
|
|
35
37
|
var classnames_1 = __importDefault(require("classnames"));
|
|
36
38
|
var react_1 = __importDefault(require("react"));
|
|
37
39
|
var utils_1 = require("../utils");
|
|
@@ -127,15 +129,15 @@ exports.generateLocalizedStrings = generateLocalizedStrings;
|
|
|
127
129
|
*/
|
|
128
130
|
var DatePicker = function (props) {
|
|
129
131
|
var _a, _b, _c;
|
|
130
|
-
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"]);
|
|
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"]);
|
|
131
133
|
(0, utils_1.useTheme)();
|
|
132
134
|
var monthNames = (_a = localizedNames === null || localizedNames === void 0 ? void 0 : localizedNames.months) !== null && _a !== void 0 ? _a : defaultMonths;
|
|
133
135
|
var shortDays = (_b = localizedNames === null || localizedNames === void 0 ? void 0 : localizedNames.shortDays) !== null && _b !== void 0 ? _b : defaultShortDays;
|
|
134
136
|
var longDays = (_c = localizedNames === null || localizedNames === void 0 ? void 0 : localizedNames.days) !== null && _c !== void 0 ? _c : defaultLongDays;
|
|
135
|
-
var
|
|
136
|
-
var
|
|
137
|
-
var
|
|
138
|
-
var
|
|
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];
|
|
139
141
|
// Used to focus days only when days are changed
|
|
140
142
|
// e.g. without this, when changing months day would be focused
|
|
141
143
|
var needFocus = react_1.default.useRef(setFocus);
|
|
@@ -181,6 +183,16 @@ var DatePicker = function (props) {
|
|
|
181
183
|
var newDate = new Date(newYear, newMonth, currentDate.getDate(), currentDate.getHours(), currentDate.getMinutes(), currentDate.getSeconds());
|
|
182
184
|
return newDate;
|
|
183
185
|
};
|
|
186
|
+
var handleMoveToPreviousYear = function () {
|
|
187
|
+
var newYear = displayedYear - 1;
|
|
188
|
+
setMonthAndYear(displayedMonthIndex, newYear);
|
|
189
|
+
setFocusedDay(getNewFocusedDate(newYear, displayedMonthIndex));
|
|
190
|
+
};
|
|
191
|
+
var handleMoveToNextYear = function () {
|
|
192
|
+
var newYear = displayedYear + 1;
|
|
193
|
+
setMonthAndYear(displayedMonthIndex, newYear);
|
|
194
|
+
setFocusedDay(getNewFocusedDate(newYear, displayedMonthIndex));
|
|
195
|
+
};
|
|
184
196
|
var handleMoveToPreviousMonth = function () {
|
|
185
197
|
var newMonth = displayedMonthIndex !== 0 ? displayedMonthIndex - 1 : 11;
|
|
186
198
|
var newYear = displayedMonthIndex !== 0 ? displayedYear : displayedYear - 1;
|
|
@@ -253,26 +265,39 @@ var DatePicker = function (props) {
|
|
|
253
265
|
break;
|
|
254
266
|
}
|
|
255
267
|
};
|
|
268
|
+
var getDayClass = function (day) {
|
|
269
|
+
if (day.getMonth() !== displayedMonthIndex) {
|
|
270
|
+
return 'iui-calendar-day-outside-month';
|
|
271
|
+
}
|
|
272
|
+
var dayClass = 'iui-calendar-day';
|
|
273
|
+
if (isSameDay(day, selectedDay)) {
|
|
274
|
+
dayClass += '-selected';
|
|
275
|
+
}
|
|
276
|
+
if (isSameDay(day, new Date())) {
|
|
277
|
+
dayClass += '-today';
|
|
278
|
+
}
|
|
279
|
+
return dayClass;
|
|
280
|
+
};
|
|
256
281
|
return (react_1.default.createElement("div", __assign({ className: (0, classnames_1.default)('iui-date-picker', className), style: style }, rest),
|
|
257
282
|
react_1.default.createElement("div", null,
|
|
258
283
|
react_1.default.createElement("div", { className: 'iui-calendar-month-year' },
|
|
259
|
-
react_1.default.createElement(IconButton_1.IconButton, { styleType: 'borderless', onClick:
|
|
284
|
+
showYearSelection && (react_1.default.createElement(IconButton_1.IconButton, { styleType: 'borderless', onClick: handleMoveToPreviousYear, "aria-label": 'Previous year', size: 'small' },
|
|
285
|
+
react_1.default.createElement(ChevronLeftDouble_1.default, null))),
|
|
286
|
+
react_1.default.createElement(IconButton_1.IconButton, { styleType: 'borderless', onClick: handleMoveToPreviousMonth, "aria-label": 'Previous month', size: 'small' },
|
|
260
287
|
react_1.default.createElement(ChevronLeft_1.default, null)),
|
|
261
288
|
react_1.default.createElement("span", { "aria-live": 'polite' },
|
|
262
289
|
react_1.default.createElement("span", { className: 'iui-calendar-month', title: monthNames[displayedMonthIndex] }, monthNames[displayedMonthIndex]),
|
|
263
290
|
"\u00A0",
|
|
264
291
|
displayedYear),
|
|
265
|
-
react_1.default.createElement(IconButton_1.IconButton, { styleType: 'borderless', onClick: handleMoveToNextMonth, "aria-label": 'Next month' },
|
|
266
|
-
react_1.default.createElement(ChevronRight_1.default, null))
|
|
292
|
+
react_1.default.createElement(IconButton_1.IconButton, { styleType: 'borderless', onClick: handleMoveToNextMonth, "aria-label": 'Next month', size: 'small' },
|
|
293
|
+
react_1.default.createElement(ChevronRight_1.default, null)),
|
|
294
|
+
showYearSelection && (react_1.default.createElement(IconButton_1.IconButton, { styleType: 'borderless', onClick: handleMoveToNextYear, "aria-label": 'Next year', size: 'small' },
|
|
295
|
+
react_1.default.createElement(ChevronRightDouble_1.default, null)))),
|
|
267
296
|
react_1.default.createElement("div", { className: 'iui-calendar-weekdays' }, shortDays.map(function (day, index) { return (react_1.default.createElement("div", { key: day, title: longDays[index] }, day)); })),
|
|
268
297
|
react_1.default.createElement("div", { onKeyDown: handleCalendarKeyDown, role: 'listbox' }, weeks.map(function (weekDays, weekIndex) {
|
|
269
298
|
return (react_1.default.createElement("div", { key: "week-" + displayedMonthIndex + "-" + weekIndex, className: 'iui-calendar-week' }, weekDays.map(function (weekDay, dayIndex) {
|
|
270
299
|
var dateValue = weekDay.getDate();
|
|
271
|
-
return (react_1.default.createElement("div", { key: "day-" + displayedMonthIndex + "-" + dayIndex, className: (
|
|
272
|
-
'iui-outside-month': weekDay.getMonth() !== displayedMonthIndex,
|
|
273
|
-
'iui-today': isSameDay(weekDay, new Date()),
|
|
274
|
-
'iui-selected': isSameDay(weekDay, selectedDay),
|
|
275
|
-
}), onClick: function () { return onDayClick(weekDay); }, role: 'option', tabIndex: isSameDay(weekDay, focusedDay) ? 0 : -1, ref: function (element) {
|
|
300
|
+
return (react_1.default.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) {
|
|
276
301
|
return isSameDay(weekDay, focusedDay) &&
|
|
277
302
|
needFocus.current &&
|
|
278
303
|
(element === null || element === void 0 ? void 0 : element.focus());
|
|
@@ -61,6 +61,7 @@ exports.HeaderButton = react_1.default.forwardRef(function (props, ref) {
|
|
|
61
61
|
: undefined, styleType: 'borderless', className: (0, classnames_1.default)({
|
|
62
62
|
'iui-header-button': !isSplitButton(props),
|
|
63
63
|
'iui-header-split-button': isSplitButton(props),
|
|
64
|
+
'iui-header-dropdown-button': !isSplitButton(props) && isDropdownButton(props),
|
|
64
65
|
'iui-active': isActive,
|
|
65
66
|
}, className), 'aria-current': isActive ? 'location' : undefined, children: (react_1.default.createElement(react_1.default.Fragment, null,
|
|
66
67
|
react_1.default.createElement("div", null, name),
|
package/cjs/core/Menu/Menu.js
CHANGED
|
@@ -46,9 +46,14 @@ exports.Menu = react_1.default.forwardRef(function (props, ref) {
|
|
|
46
46
|
react_1.default.useEffect(function () {
|
|
47
47
|
setFocusedIndex(null);
|
|
48
48
|
}, [children]);
|
|
49
|
+
var getFocusableNodes = react_1.default.useCallback(function () {
|
|
50
|
+
var focusableItems = (0, utils_1.getFocusableElements)(menuRef.current);
|
|
51
|
+
// Filter out focusable elements that are inside each menu item, e.g. checkbox, anchor
|
|
52
|
+
return focusableItems.filter(function (i) { return !focusableItems.some(function (p) { return p.contains(i.parentElement); }); });
|
|
53
|
+
}, []);
|
|
49
54
|
react_1.default.useEffect(function () {
|
|
50
55
|
var _a;
|
|
51
|
-
var items = (
|
|
56
|
+
var items = getFocusableNodes();
|
|
52
57
|
if (focusedIndex != null) {
|
|
53
58
|
(_a = items === null || items === void 0 ? void 0 : items[focusedIndex]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
54
59
|
return;
|
|
@@ -57,9 +62,9 @@ exports.Menu = react_1.default.forwardRef(function (props, ref) {
|
|
|
57
62
|
if (setFocus) {
|
|
58
63
|
setFocusedIndex(selectedIndex > -1 ? selectedIndex : 0);
|
|
59
64
|
}
|
|
60
|
-
}, [setFocus, focusedIndex]);
|
|
65
|
+
}, [setFocus, focusedIndex, getFocusableNodes]);
|
|
61
66
|
var onKeyDown = function (event) {
|
|
62
|
-
var items = (
|
|
67
|
+
var items = getFocusableNodes();
|
|
63
68
|
if (!(items === null || items === void 0 ? void 0 : items.length)) {
|
|
64
69
|
return;
|
|
65
70
|
}
|
package/cjs/core/Modal/Modal.js
CHANGED
|
@@ -37,6 +37,7 @@ var Close_1 = __importDefault(require("@itwin/itwinui-icons-react/cjs/icons/Clos
|
|
|
37
37
|
var utils_1 = require("../utils");
|
|
38
38
|
require("@itwin/itwinui-css/css/modal.css");
|
|
39
39
|
var IconButton_1 = require("../Buttons/IconButton");
|
|
40
|
+
var react_transition_group_1 = require("react-transition-group");
|
|
40
41
|
/**
|
|
41
42
|
* Modal component which can wrap any content.
|
|
42
43
|
* @example
|
|
@@ -59,7 +60,7 @@ var IconButton_1 = require("../Buttons/IconButton");
|
|
|
59
60
|
* </Modal>
|
|
60
61
|
*/
|
|
61
62
|
var Modal = function (props) {
|
|
62
|
-
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 =
|
|
63
|
+
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 ? (0, utils_1.getDocument)() : _g, rest = __rest(props, ["isOpen", "isDismissible", "closeOnEsc", "closeOnExternalClick", "onClose", "title", "onKeyDown", "id", "className", "style", "children", "styleType", "modalRootId", "ownerDocument"]);
|
|
63
64
|
(0, utils_1.useTheme)();
|
|
64
65
|
var container = (0, utils_1.getContainer)(modalRootId, ownerDocument);
|
|
65
66
|
var overlayRef = react_1.default.useRef(null);
|
|
@@ -117,14 +118,15 @@ var Modal = function (props) {
|
|
|
117
118
|
onClose(event);
|
|
118
119
|
}
|
|
119
120
|
};
|
|
120
|
-
return !!container ? (react_dom_1.default.createPortal(
|
|
121
|
-
react_1.default.createElement(
|
|
122
|
-
react_1.default.createElement("div", { className: 'iui-modal-
|
|
123
|
-
react_1.default.createElement("div", { className: 'iui-
|
|
124
|
-
react_1.default.createElement("div", { className: 'iui-title' },
|
|
125
|
-
|
|
126
|
-
react_1.default.createElement(
|
|
127
|
-
|
|
121
|
+
return !!container ? (react_dom_1.default.createPortal(react_1.default.createElement(react_transition_group_1.CSSTransition, { in: isOpen, classNames: 'iui-modal-animation', timeout: { exit: 600 }, unmountOnExit: true },
|
|
122
|
+
react_1.default.createElement(utils_1.FocusTrap, null,
|
|
123
|
+
react_1.default.createElement("div", __assign({ className: (0, classnames_1.default)('iui-modal', { 'iui-modal-full-page': styleType === 'fullPage' }, { 'iui-modal-visible': isOpen }, className), tabIndex: -1, onKeyDown: handleKeyDown, ref: overlayRef, onMouseDown: handleMouseDown }, rest),
|
|
124
|
+
react_1.default.createElement("div", { className: 'iui-modal-dialog', id: id, style: style, role: 'dialog', "aria-modal": 'true' },
|
|
125
|
+
react_1.default.createElement("div", { className: 'iui-title-bar' },
|
|
126
|
+
react_1.default.createElement("div", { className: 'iui-title' }, title),
|
|
127
|
+
isDismissible && (react_1.default.createElement(IconButton_1.IconButton, { size: 'small', styleType: 'borderless', onClick: onClose, "aria-label": 'Close' },
|
|
128
|
+
react_1.default.createElement(Close_1.default, null)))),
|
|
129
|
+
children)))), container)) : (react_1.default.createElement(react_1.default.Fragment, null));
|
|
128
130
|
};
|
|
129
131
|
exports.Modal = Modal;
|
|
130
132
|
exports.default = exports.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,46 @@
|
|
|
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
|
+
};
|
|
24
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.ModalContent = void 0;
|
|
29
|
+
/*---------------------------------------------------------------------------------------------
|
|
30
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
31
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
32
|
+
*--------------------------------------------------------------------------------------------*/
|
|
33
|
+
var react_1 = __importDefault(require("react"));
|
|
34
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
35
|
+
var utils_1 = require("../utils");
|
|
36
|
+
require("@itwin/itwinui-css/css/modal.css");
|
|
37
|
+
/**
|
|
38
|
+
* Container for content in `Modal`.
|
|
39
|
+
*/
|
|
40
|
+
var ModalContent = function (props) {
|
|
41
|
+
var children = props.children, className = props.className, rest = __rest(props, ["children", "className"]);
|
|
42
|
+
(0, utils_1.useTheme)();
|
|
43
|
+
return (react_1.default.createElement("div", __assign({ className: (0, classnames_1.default)('iui-modal-content', className) }, rest), children));
|
|
44
|
+
};
|
|
45
|
+
exports.ModalContent = ModalContent;
|
|
46
|
+
exports.default = exports.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/cjs/core/Modal/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ModalButtonBar = exports.Modal = void 0;
|
|
3
|
+
exports.ModalContent = exports.ModalButtonBar = exports.Modal = void 0;
|
|
4
4
|
/*---------------------------------------------------------------------------------------------
|
|
5
5
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
6
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -9,4 +9,6 @@ var Modal_1 = require("./Modal");
|
|
|
9
9
|
Object.defineProperty(exports, "Modal", { enumerable: true, get: function () { return Modal_1.Modal; } });
|
|
10
10
|
var ModalButtonBar_1 = require("./ModalButtonBar");
|
|
11
11
|
Object.defineProperty(exports, "ModalButtonBar", { enumerable: true, get: function () { return ModalButtonBar_1.ModalButtonBar; } });
|
|
12
|
+
var ModalContent_1 = require("./ModalContent");
|
|
13
|
+
Object.defineProperty(exports, "ModalContent", { enumerable: true, get: function () { return ModalContent_1.ModalContent; } });
|
|
12
14
|
exports.default = './Modal';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '@itwin/itwinui-css/css/skip-to-content.css';
|
|
3
|
+
export declare type SkipToContentLinkProps = {
|
|
4
|
+
/**
|
|
5
|
+
* The id of the main content that the link directs to. Don't forget the #!
|
|
6
|
+
*/
|
|
7
|
+
href: string;
|
|
8
|
+
/**
|
|
9
|
+
* Localize 'Skip to main content' label.
|
|
10
|
+
* @default 'Skip to main content'
|
|
11
|
+
*/
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
} & Omit<React.ComponentPropsWithoutRef<'a'>, 'href'>;
|
|
14
|
+
/**
|
|
15
|
+
* `SkipToContentLink` is for screen reader and keyboard users and will not be visible unless tabbed to.
|
|
16
|
+
* Provides a shortcut to the main content of the page without navigating through the header, etc.
|
|
17
|
+
* Should be placed just inside the body. Set `href` to the id of your main content component. Don't forget the `#`!
|
|
18
|
+
* @example
|
|
19
|
+
* <body><SkipToContentLink href='#main-content-id' /> ... </body>
|
|
20
|
+
* <body><SkipToContentLink href='#main-content-id'>{localizedLabel}</SkipToContentLink> ... </body>
|
|
21
|
+
*/
|
|
22
|
+
export declare const SkipToContentLink: React.ForwardRefExoticComponent<{
|
|
23
|
+
/**
|
|
24
|
+
* The id of the main content that the link directs to. Don't forget the #!
|
|
25
|
+
*/
|
|
26
|
+
href: string;
|
|
27
|
+
/**
|
|
28
|
+
* Localize 'Skip to main content' label.
|
|
29
|
+
* @default 'Skip to main content'
|
|
30
|
+
*/
|
|
31
|
+
children?: React.ReactNode;
|
|
32
|
+
} & Omit<Pick<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "key" | keyof React.AnchorHTMLAttributes<HTMLAnchorElement>>, "href"> & React.RefAttributes<HTMLAnchorElement>>;
|
|
33
|
+
export default SkipToContentLink;
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
};
|
|
24
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.SkipToContentLink = void 0;
|
|
29
|
+
/*---------------------------------------------------------------------------------------------
|
|
30
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
31
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
32
|
+
*--------------------------------------------------------------------------------------------*/
|
|
33
|
+
var react_1 = __importDefault(require("react"));
|
|
34
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
35
|
+
var utils_1 = require("../utils");
|
|
36
|
+
require("@itwin/itwinui-css/css/skip-to-content.css");
|
|
37
|
+
/**
|
|
38
|
+
* `SkipToContentLink` is for screen reader and keyboard users and will not be visible unless tabbed to.
|
|
39
|
+
* Provides a shortcut to the main content of the page without navigating through the header, etc.
|
|
40
|
+
* Should be placed just inside the body. Set `href` to the id of your main content component. Don't forget the `#`!
|
|
41
|
+
* @example
|
|
42
|
+
* <body><SkipToContentLink href='#main-content-id' /> ... </body>
|
|
43
|
+
* <body><SkipToContentLink href='#main-content-id'>{localizedLabel}</SkipToContentLink> ... </body>
|
|
44
|
+
*/
|
|
45
|
+
exports.SkipToContentLink = react_1.default.forwardRef(function (props, ref) {
|
|
46
|
+
var _a = props.children, children = _a === void 0 ? 'Skip to main content' : _a, className = props.className, rest = __rest(props, ["children", "className"]);
|
|
47
|
+
(0, utils_1.useTheme)();
|
|
48
|
+
return (react_1.default.createElement("a", __assign({ ref: ref, className: (0, classnames_1.default)('iui-skip-to-content-link', className) }, rest), children));
|
|
49
|
+
});
|
|
50
|
+
exports.default = exports.SkipToContentLink;
|