@itwin/itwinui-react 3.9.1 → 3.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/cjs/core/Breadcrumbs/Breadcrumbs.js +2 -3
- package/cjs/core/Buttons/Button.js +1 -1
- package/cjs/core/Buttons/IconButton.js +1 -1
- package/cjs/core/Buttons/IdeasButton.js +6 -2
- package/cjs/core/ComboBox/ComboBox.js +1 -1
- package/cjs/core/DropdownMenu/DropdownMenu.js +36 -13
- package/cjs/core/Input/Input.js +1 -1
- package/cjs/core/LabeledSelect/LabeledSelect.d.ts +26 -4
- package/cjs/core/Menu/Menu.js +9 -0
- package/cjs/core/Menu/MenuItem.d.ts +12 -0
- package/cjs/core/Menu/MenuItem.js +114 -66
- package/cjs/core/NotificationMarker/NotificationMarker.d.ts +7 -6
- package/cjs/core/Popover/Popover.d.ts +32 -9
- package/cjs/core/Popover/Popover.js +68 -17
- package/cjs/core/Select/Select.js +2 -3
- package/cjs/core/SideNavigation/SideNavigation.d.ts +1 -0
- package/cjs/core/SideNavigation/SideNavigation.js +20 -21
- package/cjs/core/SideNavigation/SidenavButton.js +5 -1
- package/cjs/core/Table/TablePaginator.js +1 -3
- package/cjs/core/Table/columns/selectionColumn.js +10 -1
- package/cjs/core/Table/hooks/useSubRowSelection.js +1 -1
- package/cjs/core/ThemeProvider/ThemeProvider.js +53 -17
- package/cjs/core/TimePicker/TimePicker.js +12 -12
- package/cjs/core/ToggleSwitch/ToggleSwitch.d.ts +4 -0
- package/cjs/core/ToggleSwitch/ToggleSwitch.js +2 -2
- package/cjs/utils/components/Portal.d.ts +6 -2
- package/cjs/utils/components/Portal.js +11 -14
- package/cjs/utils/providers/ScopeProvider.d.ts +26 -0
- package/cjs/utils/providers/ScopeProvider.js +77 -0
- package/cjs/utils/providers/index.d.ts +1 -0
- package/cjs/utils/providers/index.js +1 -0
- package/esm/core/Breadcrumbs/Breadcrumbs.js +2 -3
- package/esm/core/Buttons/Button.js +1 -1
- package/esm/core/Buttons/IconButton.js +1 -1
- package/esm/core/Buttons/IdeasButton.js +3 -2
- package/esm/core/ComboBox/ComboBox.js +1 -1
- package/esm/core/DropdownMenu/DropdownMenu.js +36 -13
- package/esm/core/Input/Input.js +1 -1
- package/esm/core/LabeledSelect/LabeledSelect.d.ts +26 -4
- package/esm/core/Menu/Menu.js +9 -0
- package/esm/core/Menu/MenuItem.d.ts +12 -0
- package/esm/core/Menu/MenuItem.js +114 -66
- package/esm/core/NotificationMarker/NotificationMarker.d.ts +7 -6
- package/esm/core/Popover/Popover.d.ts +32 -9
- package/esm/core/Popover/Popover.js +71 -20
- package/esm/core/Select/Select.js +2 -3
- package/esm/core/SideNavigation/SideNavigation.d.ts +1 -0
- package/esm/core/SideNavigation/SideNavigation.js +20 -21
- package/esm/core/SideNavigation/SidenavButton.js +5 -1
- package/esm/core/Table/TablePaginator.js +2 -4
- package/esm/core/Table/columns/selectionColumn.js +10 -1
- package/esm/core/Table/hooks/useSubRowSelection.js +1 -1
- package/esm/core/ThemeProvider/ThemeProvider.js +54 -18
- package/esm/core/TimePicker/TimePicker.js +12 -12
- package/esm/core/ToggleSwitch/ToggleSwitch.d.ts +4 -0
- package/esm/core/ToggleSwitch/ToggleSwitch.js +2 -2
- package/esm/utils/components/Portal.d.ts +6 -2
- package/esm/utils/components/Portal.js +9 -8
- package/esm/utils/providers/ScopeProvider.d.ts +26 -0
- package/esm/utils/providers/ScopeProvider.js +48 -0
- package/esm/utils/providers/index.d.ts +1 -0
- package/esm/utils/providers/index.js +1 -0
- package/package.json +2 -1
- package/styles.css +1 -1
|
@@ -0,0 +1,48 @@
|
|
|
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 * as React from 'react';
|
|
6
|
+
import { createStore, useAtomValue, useSetAtom } from 'jotai';
|
|
7
|
+
const ScopeContext = React.createContext({
|
|
8
|
+
store: createStore(),
|
|
9
|
+
parentStore: null,
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* Provider that creates a fresh, isolated jotai store for its children.
|
|
13
|
+
*
|
|
14
|
+
* Should be used with `useScopedAtom` and/or `useScopedSetAtom`.
|
|
15
|
+
*
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
export const ScopeProvider = ({ children }) => {
|
|
19
|
+
const store = React.useMemo(() => createStore(), []);
|
|
20
|
+
const parentStore = React.useContext(ScopeContext).store;
|
|
21
|
+
return (React.createElement(ScopeContext.Provider, { value: React.useMemo(() => ({ store, parentStore }), [store, parentStore]) }, children));
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Wrapper over `useAtom` that uses the store from the nearest `ScopeProvider`.
|
|
25
|
+
*
|
|
26
|
+
* If the atom is not set in the current store, it will recursively look in the parent store(s).
|
|
27
|
+
* This is only useful for initial values. Future updates to the parent will not be reflected.
|
|
28
|
+
*
|
|
29
|
+
* @private
|
|
30
|
+
*/
|
|
31
|
+
export const useScopedAtom = (atom) => {
|
|
32
|
+
const { store, parentStore } = React.useContext(ScopeContext);
|
|
33
|
+
const setAtom = useScopedSetAtom(atom);
|
|
34
|
+
const value = useAtomValue(atom, { store });
|
|
35
|
+
const inheritedValue = useAtomValue(atom, { store: parentStore || store });
|
|
36
|
+
if (value == undefined && inheritedValue != undefined) {
|
|
37
|
+
setAtom(inheritedValue);
|
|
38
|
+
}
|
|
39
|
+
return [value, setAtom];
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Wrapper over `useSetAtom` that uses the store from the nearest `ScopeProvider`.
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
export const useScopedSetAtom = (atom) => {
|
|
46
|
+
const { store } = React.useContext(ScopeContext);
|
|
47
|
+
return useSetAtom(atom, { store });
|
|
48
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/itwinui-react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.1",
|
|
4
4
|
"author": "Bentley Systems",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"@floating-ui/react": "^0.26.10",
|
|
60
60
|
"@itwin/itwinui-illustrations-react": "^2.1.0",
|
|
61
61
|
"classnames": "^2.3.2",
|
|
62
|
+
"jotai": "^2.8.0",
|
|
62
63
|
"react-table": "^7.8.0",
|
|
63
64
|
"react-transition-group": "^4.4.5",
|
|
64
65
|
"tslib": "^2.6.0"
|