@itwin/itwinui-react 1.34.0 → 1.35.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 +27 -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/ComboBox/ComboBox.js +2 -2
- package/cjs/core/DatePicker/DatePicker.d.ts +5 -0
- package/cjs/core/DatePicker/DatePicker.js +38 -13
- 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.js +8 -7
- package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.js +18 -2
- package/cjs/core/index.d.ts +4 -2
- package/cjs/core/index.js +6 -2
- 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/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/ComboBox/ComboBox.js +2 -2
- package/esm/core/DatePicker/DatePicker.d.ts +5 -0
- package/esm/core/DatePicker/DatePicker.js +38 -13
- 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.js +8 -7
- package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.js +18 -2
- package/esm/core/index.d.ts +4 -2
- package/esm/core/index.js +2 -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/package.json +3 -2
package/esm/core/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export { Badge } from './Badge';
|
|
|
7
7
|
export { Breadcrumbs } from './Breadcrumbs';
|
|
8
8
|
export { Button, DropdownButton, IconButton, IdeasButton, SplitButton, } from './Buttons';
|
|
9
9
|
export { ButtonGroup } from './ButtonGroup';
|
|
10
|
+
export { Carousel } from './Carousel';
|
|
10
11
|
export { Checkbox } from './Checkbox';
|
|
11
12
|
export { ColorPicker, ColorSwatch, ColorBuilder, ColorInputPanel, ColorPalette, } from './ColorPicker';
|
|
12
13
|
export { ComboBox } from './ComboBox';
|
|
@@ -27,7 +28,7 @@ export { InputGroup } from './InputGroup';
|
|
|
27
28
|
export { LabeledSelect } from './LabeledSelect';
|
|
28
29
|
export { LabeledTextarea } from './LabeledTextarea';
|
|
29
30
|
export { Menu, MenuItem, MenuDivider, MenuExtraContent } from './Menu';
|
|
30
|
-
export { Modal, ModalButtonBar } from './Modal';
|
|
31
|
+
export { Modal, ModalButtonBar, ModalContent } from './Modal';
|
|
31
32
|
export { ProgressLinear, ProgressRadial } from './ProgressIndicators';
|
|
32
33
|
export { Radio } from './Radio';
|
|
33
34
|
export { RadioTile, RadioTileGroup } from './RadioTiles';
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
import React from 'react';
|
|
6
|
+
import { getWindow } from '../functions';
|
|
7
|
+
export var useMediaQuery = function (queryString) {
|
|
8
|
+
var _a = React.useState(), matches = _a[0], setMatches = _a[1];
|
|
9
|
+
React.useLayoutEffect(function () {
|
|
10
|
+
var _a, _b, _c;
|
|
11
|
+
var mediaQueryList = (_b = (_a = getWindow()) === null || _a === void 0 ? void 0 : _a.matchMedia) === null || _b === void 0 ? void 0 : _b.call(_a, queryString);
|
|
12
|
+
var handleChange = function (_a) {
|
|
13
|
+
var matches = _a.matches;
|
|
14
|
+
return setMatches(matches);
|
|
15
|
+
};
|
|
16
|
+
if (mediaQueryList != undefined) {
|
|
17
|
+
setMatches(mediaQueryList.matches);
|
|
18
|
+
try {
|
|
19
|
+
mediaQueryList.addEventListener('change', handleChange);
|
|
20
|
+
}
|
|
21
|
+
catch (_d) {
|
|
22
|
+
// Safari 13 fallback
|
|
23
|
+
(_c = mediaQueryList.addListener) === null || _c === void 0 ? void 0 : _c.call(mediaQueryList, handleChange);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return function () {
|
|
27
|
+
var _a;
|
|
28
|
+
try {
|
|
29
|
+
mediaQueryList === null || mediaQueryList === void 0 ? void 0 : mediaQueryList.removeEventListener('change', handleChange);
|
|
30
|
+
}
|
|
31
|
+
catch (_b) {
|
|
32
|
+
// Safari 13 fallback
|
|
33
|
+
(_a = mediaQueryList === null || mediaQueryList === void 0 ? void 0 : mediaQueryList.removeListener) === null || _a === void 0 ? void 0 : _a.call(mediaQueryList, handleChange);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}, [queryString]);
|
|
37
|
+
return !!matches;
|
|
38
|
+
};
|
|
39
|
+
export default useMediaQuery;
|
|
@@ -6,6 +6,11 @@ export declare type ThemeOptions = {
|
|
|
6
6
|
* @default document
|
|
7
7
|
*/
|
|
8
8
|
ownerDocument?: Document;
|
|
9
|
+
/**
|
|
10
|
+
* Whether to apply high-contrast versions of light and dark themes.
|
|
11
|
+
* Will default to user preference if browser supports it.
|
|
12
|
+
*/
|
|
13
|
+
highContrast?: boolean;
|
|
9
14
|
};
|
|
10
15
|
export declare type ThemeType = 'light' | 'dark' | 'os';
|
|
11
16
|
/**
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import '@itwin/itwinui-css/css/global.css';
|
|
7
7
|
import { getDocument, getWindow } from '../functions/dom';
|
|
8
|
+
import { useMediaQuery } from './useMediaQuery';
|
|
8
9
|
/**
|
|
9
10
|
* Hook that applies styling and theme to all components.
|
|
10
11
|
* Defaults to light theme if none provided or set elsewhere.
|
|
@@ -14,6 +15,8 @@ import { getDocument, getWindow } from '../functions/dom';
|
|
|
14
15
|
export var useTheme = function (theme, themeOptions) {
|
|
15
16
|
var _a;
|
|
16
17
|
var ownerDocument = (_a = themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.ownerDocument) !== null && _a !== void 0 ? _a : getDocument();
|
|
18
|
+
var prefersHighContrast = useMediaQuery('(prefers-contrast: more)');
|
|
19
|
+
var highContrast = React.useMemo(function () { var _a; return !!((_a = themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.highContrast) !== null && _a !== void 0 ? _a : prefersHighContrast); }, [prefersHighContrast, themeOptions === null || themeOptions === void 0 ? void 0 : themeOptions.highContrast]);
|
|
17
20
|
React.useLayoutEffect(function () {
|
|
18
21
|
if (!(ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.body.classList.contains('iui-body'))) {
|
|
19
22
|
ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.body.classList.add('iui-body');
|
|
@@ -28,20 +31,20 @@ export var useTheme = function (theme, themeOptions) {
|
|
|
28
31
|
var addOSTheme = function (_a) {
|
|
29
32
|
var isDark = _a.matches;
|
|
30
33
|
if (isDark) {
|
|
31
|
-
|
|
34
|
+
applyTheme('dark', { ownerDocument: ownerDocument, highContrast: highContrast });
|
|
32
35
|
}
|
|
33
36
|
else {
|
|
34
|
-
|
|
37
|
+
applyTheme('light', { ownerDocument: ownerDocument, highContrast: highContrast });
|
|
35
38
|
}
|
|
36
39
|
};
|
|
37
40
|
switch (theme) {
|
|
38
41
|
case 'light':
|
|
39
42
|
(_c = prefersDarkMediaQuery === null || prefersDarkMediaQuery === void 0 ? void 0 : prefersDarkMediaQuery.removeEventListener) === null || _c === void 0 ? void 0 : _c.call(prefersDarkMediaQuery, 'change', addOSTheme);
|
|
40
|
-
|
|
43
|
+
applyTheme('light', { ownerDocument: ownerDocument, highContrast: highContrast });
|
|
41
44
|
break;
|
|
42
45
|
case 'dark':
|
|
43
46
|
(_d = prefersDarkMediaQuery === null || prefersDarkMediaQuery === void 0 ? void 0 : prefersDarkMediaQuery.removeEventListener) === null || _d === void 0 ? void 0 : _d.call(prefersDarkMediaQuery, 'change', addOSTheme);
|
|
44
|
-
|
|
47
|
+
applyTheme('dark', { ownerDocument: ownerDocument, highContrast: highContrast });
|
|
45
48
|
break;
|
|
46
49
|
case 'os':
|
|
47
50
|
if (prefersDarkMediaQuery != undefined) {
|
|
@@ -49,25 +52,28 @@ export var useTheme = function (theme, themeOptions) {
|
|
|
49
52
|
(_e = prefersDarkMediaQuery.addEventListener) === null || _e === void 0 ? void 0 : _e.call(prefersDarkMediaQuery, 'change', addOSTheme);
|
|
50
53
|
}
|
|
51
54
|
else {
|
|
52
|
-
|
|
55
|
+
applyTheme('light', { ownerDocument: ownerDocument, highContrast: highContrast });
|
|
53
56
|
}
|
|
54
57
|
break;
|
|
55
58
|
default:
|
|
56
59
|
if (ownerDocument.documentElement.className.indexOf('iui-theme') === -1) {
|
|
57
|
-
|
|
60
|
+
applyTheme('light', { ownerDocument: ownerDocument, highContrast: highContrast });
|
|
58
61
|
}
|
|
59
62
|
}
|
|
60
63
|
return function () {
|
|
61
64
|
var _a;
|
|
62
65
|
(_a = prefersDarkMediaQuery === null || prefersDarkMediaQuery === void 0 ? void 0 : prefersDarkMediaQuery.removeEventListener) === null || _a === void 0 ? void 0 : _a.call(prefersDarkMediaQuery, 'change', addOSTheme);
|
|
63
66
|
};
|
|
64
|
-
}, [ownerDocument, theme]);
|
|
67
|
+
}, [highContrast, ownerDocument, theme]);
|
|
65
68
|
};
|
|
66
|
-
var
|
|
67
|
-
ownerDocument.
|
|
68
|
-
ownerDocument.documentElement.classList
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
var applyTheme = function (theme, _a) {
|
|
70
|
+
var ownerDocument = _a.ownerDocument, highContrast = _a.highContrast;
|
|
71
|
+
var classList = ownerDocument.documentElement.classList;
|
|
72
|
+
var currentTheme = Array.from(classList).find(function (cls) {
|
|
73
|
+
return cls.startsWith('iui-theme');
|
|
74
|
+
});
|
|
75
|
+
if (currentTheme) {
|
|
76
|
+
classList.remove(currentTheme);
|
|
77
|
+
}
|
|
78
|
+
classList.add("iui-theme-" + theme + (highContrast ? '-hc' : ''));
|
|
73
79
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/itwinui-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.35.0",
|
|
4
4
|
"author": "Bentley Systems",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "cjs/index.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"build-storybook": "build-storybook"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@itwin/itwinui-css": "^0.
|
|
43
|
+
"@itwin/itwinui-css": "^0.53.3",
|
|
44
44
|
"@itwin/itwinui-icons-react": "^1.5.0",
|
|
45
45
|
"@itwin/itwinui-illustrations-react": "^1.0.1",
|
|
46
46
|
"@tippyjs/react": "^4.2.5",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@babel/core": "^7.12.10",
|
|
54
|
+
"@storybook/addon-a11y": "^6.4.19",
|
|
54
55
|
"@storybook/addon-essentials": "~6.4.19",
|
|
55
56
|
"@storybook/addon-storysource": "~6.4.19",
|
|
56
57
|
"@storybook/addons": "~6.4.19",
|