@itwin/itwinui-react 3.18.3 → 3.19.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 +44 -0
- package/DEV-cjs/core/ComboBox/ComboBoxMenuItem.js +1 -1
- package/DEV-cjs/core/Menu/MenuItem.js +8 -7
- package/DEV-cjs/core/Select/Select.js +18 -10
- package/DEV-cjs/core/SideNavigation/SideNavigation.js +2 -2
- package/DEV-cjs/core/Table/ColumnHeader.js +7 -3
- package/DEV-cjs/core/Table/Table.js +65 -5
- package/DEV-cjs/core/Table/cells/DefaultCell.js +14 -9
- package/DEV-cjs/core/Table/columns/actionColumn.js +1 -0
- package/DEV-cjs/core/Table/columns/expanderColumn.js +25 -20
- package/DEV-cjs/core/Table/columns/selectionColumn.js +14 -8
- package/DEV-cjs/core/Table/hooks/useExpanderCell.js +10 -6
- package/DEV-cjs/core/Tag/Tag.js +8 -2
- package/DEV-cjs/core/ThemeProvider/ThemeProvider.js +46 -46
- package/DEV-cjs/core/ToggleSwitch/ToggleSwitch.js +15 -4
- package/DEV-cjs/styles.js +1 -1
- package/DEV-cjs/utils/components/index.js +1 -1
- package/DEV-cjs/utils/components/lineClamp.js +23 -0
- package/DEV-cjs/utils/functions/react.js +18 -4
- package/DEV-cjs/utils/hooks/useControlledState.js +5 -1
- package/DEV-cjs/utils/providers/FutureFlagsProvider.js +48 -0
- package/DEV-cjs/utils/providers/index.js +1 -0
- package/DEV-esm/core/ComboBox/ComboBoxMenuItem.js +1 -1
- package/DEV-esm/core/Menu/MenuItem.js +8 -7
- package/DEV-esm/core/Select/Select.js +19 -10
- package/DEV-esm/core/SideNavigation/SideNavigation.js +2 -2
- package/DEV-esm/core/Table/ColumnHeader.js +8 -4
- package/DEV-esm/core/Table/Table.js +65 -5
- package/DEV-esm/core/Table/cells/DefaultCell.js +15 -10
- package/DEV-esm/core/Table/columns/actionColumn.js +1 -0
- package/DEV-esm/core/Table/columns/expanderColumn.js +25 -20
- package/DEV-esm/core/Table/columns/selectionColumn.js +14 -8
- package/DEV-esm/core/Table/hooks/useExpanderCell.js +10 -6
- package/DEV-esm/core/Tag/Tag.js +11 -3
- package/DEV-esm/core/ThemeProvider/ThemeProvider.js +48 -42
- package/DEV-esm/core/ToggleSwitch/ToggleSwitch.js +15 -5
- package/DEV-esm/styles.js +1 -1
- package/DEV-esm/utils/components/index.js +1 -1
- package/DEV-esm/utils/components/lineClamp.js +13 -0
- package/DEV-esm/utils/functions/react.js +6 -1
- package/DEV-esm/utils/hooks/useControlledState.js +5 -1
- package/DEV-esm/utils/providers/FutureFlagsProvider.js +28 -0
- package/DEV-esm/utils/providers/index.js +1 -0
- package/cjs/core/Buttons/DropdownButton.d.ts +1 -1
- package/cjs/core/ComboBox/ComboBoxMenuItem.d.ts +5 -16
- package/cjs/core/ComboBox/ComboBoxMenuItem.js +1 -1
- package/cjs/core/DropdownMenu/DropdownMenu.d.ts +1 -1
- package/cjs/core/Menu/MenuItem.d.ts +7 -1
- package/cjs/core/Menu/MenuItem.js +8 -7
- package/cjs/core/Popover/Popover.d.ts +5 -3
- package/cjs/core/Select/Select.js +18 -10
- package/cjs/core/SideNavigation/SideNavigation.js +2 -2
- package/cjs/core/Table/ColumnHeader.js +7 -3
- package/cjs/core/Table/Table.d.ts +2 -2
- package/cjs/core/Table/Table.js +65 -5
- package/cjs/core/Table/cells/DefaultCell.js +14 -9
- package/cjs/core/Table/columns/actionColumn.d.ts +1 -0
- package/cjs/core/Table/columns/actionColumn.js +1 -0
- package/cjs/core/Table/columns/expanderColumn.d.ts +2 -2
- package/cjs/core/Table/columns/expanderColumn.js +25 -20
- package/cjs/core/Table/columns/selectionColumn.d.ts +2 -2
- package/cjs/core/Table/columns/selectionColumn.js +14 -8
- package/cjs/core/Table/hooks/useExpanderCell.js +10 -6
- package/cjs/core/Tabs/Tabs.d.ts +4 -1
- package/cjs/core/Tag/Tag.js +8 -2
- package/cjs/core/ThemeProvider/ThemeContext.d.ts +1 -2
- package/cjs/core/ThemeProvider/ThemeProvider.d.ts +8 -18
- package/cjs/core/ThemeProvider/ThemeProvider.js +46 -46
- package/cjs/core/ToggleSwitch/ToggleSwitch.d.ts +21 -0
- package/cjs/core/ToggleSwitch/ToggleSwitch.js +15 -4
- package/cjs/styles.js +1 -1
- package/cjs/utils/components/index.d.ts +1 -1
- package/cjs/utils/components/index.js +1 -1
- package/cjs/utils/components/lineClamp.d.ts +5 -0
- package/cjs/utils/components/lineClamp.js +23 -0
- package/cjs/utils/functions/react.d.ts +5 -0
- package/cjs/utils/functions/react.js +18 -4
- package/cjs/utils/hooks/useControlledState.d.ts +5 -2
- package/cjs/utils/hooks/useControlledState.js +5 -1
- package/cjs/utils/hooks/useGlobals.d.ts +0 -1
- package/cjs/utils/providers/FutureFlagsProvider.d.ts +37 -0
- package/cjs/utils/providers/FutureFlagsProvider.js +48 -0
- package/cjs/utils/providers/index.d.ts +1 -0
- package/cjs/utils/providers/index.js +1 -0
- package/esm/core/Buttons/DropdownButton.d.ts +1 -1
- package/esm/core/ComboBox/ComboBoxMenuItem.d.ts +5 -16
- package/esm/core/ComboBox/ComboBoxMenuItem.js +1 -1
- package/esm/core/DropdownMenu/DropdownMenu.d.ts +1 -1
- package/esm/core/Menu/MenuItem.d.ts +7 -1
- package/esm/core/Menu/MenuItem.js +8 -7
- package/esm/core/Popover/Popover.d.ts +5 -3
- package/esm/core/Select/Select.js +19 -10
- package/esm/core/SideNavigation/SideNavigation.js +2 -2
- package/esm/core/Table/ColumnHeader.js +8 -4
- package/esm/core/Table/Table.d.ts +2 -2
- package/esm/core/Table/Table.js +65 -5
- package/esm/core/Table/cells/DefaultCell.js +15 -10
- package/esm/core/Table/columns/actionColumn.d.ts +1 -0
- package/esm/core/Table/columns/actionColumn.js +1 -0
- package/esm/core/Table/columns/expanderColumn.d.ts +2 -2
- package/esm/core/Table/columns/expanderColumn.js +25 -20
- package/esm/core/Table/columns/selectionColumn.d.ts +2 -2
- package/esm/core/Table/columns/selectionColumn.js +14 -8
- package/esm/core/Table/hooks/useExpanderCell.js +10 -6
- package/esm/core/Tabs/Tabs.d.ts +4 -1
- package/esm/core/Tag/Tag.js +11 -3
- package/esm/core/ThemeProvider/ThemeContext.d.ts +1 -2
- package/esm/core/ThemeProvider/ThemeProvider.d.ts +8 -18
- package/esm/core/ThemeProvider/ThemeProvider.js +48 -42
- package/esm/core/ToggleSwitch/ToggleSwitch.d.ts +21 -0
- package/esm/core/ToggleSwitch/ToggleSwitch.js +15 -5
- package/esm/styles.js +1 -1
- package/esm/utils/components/index.d.ts +1 -1
- package/esm/utils/components/index.js +1 -1
- package/esm/utils/components/lineClamp.d.ts +5 -0
- package/esm/utils/components/lineClamp.js +13 -0
- package/esm/utils/functions/react.d.ts +5 -0
- package/esm/utils/functions/react.js +6 -1
- package/esm/utils/hooks/useControlledState.d.ts +5 -2
- package/esm/utils/hooks/useControlledState.js +5 -1
- package/esm/utils/hooks/useGlobals.d.ts +0 -1
- package/esm/utils/providers/FutureFlagsProvider.d.ts +37 -0
- package/esm/utils/providers/FutureFlagsProvider.js +28 -0
- package/esm/utils/providers/index.d.ts +1 -0
- package/esm/utils/providers/index.js +1 -0
- package/package.json +11 -5
- package/styles.css +10 -10
- package/DEV-cjs/utils/components/LineClamp.js +0 -50
- package/DEV-esm/utils/components/LineClamp.js +0 -36
- package/cjs/utils/components/LineClamp.d.ts +0 -5
- package/cjs/utils/components/LineClamp.js +0 -50
- package/esm/utils/components/LineClamp.d.ts +0 -5
- package/esm/utils/components/LineClamp.js +0 -36
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* `true` if the current React version is 17 or 18. Else, is `false`.
|
|
4
|
+
* @private
|
|
5
|
+
*/
|
|
6
|
+
export declare const isReact17or18: boolean;
|
|
2
7
|
/**
|
|
3
8
|
* Wrapper over `cloneElement` that automatically checks for `isValidElement`
|
|
4
9
|
* and automatically merges `children.ref` with the ref passed in props.
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { mergeRefs } from '../hooks/useMergedRefs.js';
|
|
3
|
+
let _React = React;
|
|
4
|
+
export const isReact17or18 = (() => {
|
|
5
|
+
let version = _React.version?.split('.')?.[0];
|
|
6
|
+
return ['17', '18'].includes(version);
|
|
7
|
+
})();
|
|
3
8
|
export const cloneElementWithRef = (children, getProps) => {
|
|
4
9
|
if (!children) return null;
|
|
5
10
|
if (!React.isValidElement(children)) return children;
|
|
6
|
-
let childrenRef = children
|
|
11
|
+
let childrenRef = isReact17or18 ? children?.ref : children.props?.ref;
|
|
7
12
|
let props = getProps(children);
|
|
8
13
|
let ref = mergeRefs(
|
|
9
14
|
...[childrenRef, 'ref' in props ? props.ref : null].filter(Boolean),
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
/**
|
|
3
2
|
* Wrapper over `useState` that always gives preference to the
|
|
4
3
|
* controlled state (which often comes from a prop).
|
|
@@ -6,8 +5,12 @@ import * as React from 'react';
|
|
|
6
5
|
* This is helpful when a component needs to support both uncontrolled
|
|
7
6
|
* and controlled states. If controlled value/setter is not passed,
|
|
8
7
|
* then it will work just like a regular `useState`.
|
|
8
|
+
* The only exception is that the set function only accepts the new state. It does not accept a function.
|
|
9
|
+
*
|
|
10
|
+
* **NOTE**: `setControlledState` is called only when the value *changes* (uncontrolled mode) or should *change*
|
|
11
|
+
* (controlled mode).
|
|
9
12
|
*
|
|
10
13
|
* @example
|
|
11
14
|
* const [state, setState] = useControlledState(null, props.value, props.onChange);
|
|
12
15
|
*/
|
|
13
|
-
export declare const useControlledState: <T>(initialValue: T, controlledState: T | undefined, setControlledState?:
|
|
16
|
+
export declare const useControlledState: <T>(initialValue: T, controlledState: T | undefined, setControlledState?: (value: T) => void) => readonly [T, (value: T) => void];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { useLatestRef } from './useLatestRef.js';
|
|
2
3
|
export const useControlledState = (
|
|
3
4
|
initialValue,
|
|
4
5
|
controlledState,
|
|
@@ -9,12 +10,15 @@ export const useControlledState = (
|
|
|
9
10
|
() => (void 0 !== controlledState ? controlledState : uncontrolledState),
|
|
10
11
|
[controlledState, uncontrolledState],
|
|
11
12
|
);
|
|
13
|
+
let oldState = useLatestRef(state);
|
|
12
14
|
let setState = React.useCallback(
|
|
13
15
|
(value) => {
|
|
16
|
+
if (value === oldState.current) return;
|
|
17
|
+
oldState.current = value;
|
|
14
18
|
setUncontrolledState(value);
|
|
15
19
|
setControlledState?.(value);
|
|
16
20
|
},
|
|
17
|
-
[
|
|
21
|
+
[oldState, setControlledState],
|
|
18
22
|
);
|
|
19
23
|
return [state, setState];
|
|
20
24
|
};
|
|
@@ -10,7 +10,6 @@ export declare const useGlobals: () => {
|
|
|
10
10
|
theme?: import("../../index.js").ThemeType;
|
|
11
11
|
themeOptions?: import("../../core/ThemeProvider/ThemeProvider.js").ThemeOptions;
|
|
12
12
|
portalContainer?: HTMLElement | null;
|
|
13
|
-
future?: import("../../core/ThemeProvider/ThemeProvider.js").FutureOptions;
|
|
14
13
|
} | undefined;
|
|
15
14
|
/** Shows console error if ThemeProvider is not used */
|
|
16
15
|
export declare const useThemeProviderWarning: (themeContext: React.ContextType<typeof ThemeContext>) => void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type FutureOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* @alpha
|
|
5
|
+
*
|
|
6
|
+
* If enabled, the theme resembles the future iTwinUI version's theme (including alphas) *whenever possible*.
|
|
7
|
+
*
|
|
8
|
+
* This is useful in making apps looks like future versions of iTwinUI to help with incremental adoption.
|
|
9
|
+
*
|
|
10
|
+
* **NOTE**: Since this is a theme bridge to *future* versions, the theme could have breaking changes.
|
|
11
|
+
*/
|
|
12
|
+
themeBridge?: boolean;
|
|
13
|
+
ToggleSwitch?: {
|
|
14
|
+
/**
|
|
15
|
+
* When `true`, `className` and `style` will be applied on the
|
|
16
|
+
* input element, along with the rest of the DOM props.
|
|
17
|
+
*
|
|
18
|
+
* By default (without this flag), `className` and `style` get
|
|
19
|
+
* applied on the wrapper element, unless `wrapperProps` is also passed.
|
|
20
|
+
*/
|
|
21
|
+
consistentPropsSpread?: boolean;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Hook to access future flags.
|
|
26
|
+
* @private
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```jsx
|
|
30
|
+
* const themeBridge = useFutureFlag('themeBridge');
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function useFutureFlag<K extends keyof FutureOptions>(key: K): FutureOptions[K];
|
|
34
|
+
/** @private */
|
|
35
|
+
export declare const FutureFlagsProvider: ({ children, value, }: React.PropsWithChildren<{
|
|
36
|
+
value: true | FutureOptions;
|
|
37
|
+
}>) => React.JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useSafeContext } from '../hooks/useSafeContext.js';
|
|
3
|
+
let FutureFlagsContext = React.createContext({});
|
|
4
|
+
export function useFutureFlag(key) {
|
|
5
|
+
let context = useSafeContext(FutureFlagsContext);
|
|
6
|
+
return context[key];
|
|
7
|
+
}
|
|
8
|
+
export const FutureFlagsProvider = ({ children, value }) => {
|
|
9
|
+
if (true === value)
|
|
10
|
+
value = {
|
|
11
|
+
themeBridge: true,
|
|
12
|
+
};
|
|
13
|
+
let context = React.useContext(FutureFlagsContext);
|
|
14
|
+
let combinedValue = {
|
|
15
|
+
...context,
|
|
16
|
+
...value,
|
|
17
|
+
};
|
|
18
|
+
return React.createElement(
|
|
19
|
+
FutureFlagsContext.Provider,
|
|
20
|
+
{
|
|
21
|
+
value: React.useMemo(
|
|
22
|
+
() => combinedValue,
|
|
23
|
+
[JSON.stringify(combinedValue)],
|
|
24
|
+
),
|
|
25
|
+
},
|
|
26
|
+
children,
|
|
27
|
+
);
|
|
28
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/itwinui-react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.19.0",
|
|
4
4
|
"author": "Bentley Systems",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -79,10 +79,10 @@
|
|
|
79
79
|
"ux"
|
|
80
80
|
],
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@floating-ui/react": "^0.27.
|
|
82
|
+
"@floating-ui/react": "^0.27.13",
|
|
83
83
|
"@itwin/itwinui-illustrations-react": "^2.1.0",
|
|
84
|
-
"@swc/helpers": "^0.5.
|
|
85
|
-
"@tanstack/react-virtual": "^3.13.
|
|
84
|
+
"@swc/helpers": "^0.5.17",
|
|
85
|
+
"@tanstack/react-virtual": "^3.13.12",
|
|
86
86
|
"classnames": "^2.5.1",
|
|
87
87
|
"react-table": "^7.8.0"
|
|
88
88
|
},
|
|
@@ -108,7 +108,13 @@
|
|
|
108
108
|
},
|
|
109
109
|
"peerDependencies": {
|
|
110
110
|
"react": ">=17.0.0",
|
|
111
|
-
"react-dom": ">=17.0.0"
|
|
111
|
+
"react-dom": ">=17.0.0",
|
|
112
|
+
"@stratakit/foundations": ">=0.2.0"
|
|
113
|
+
},
|
|
114
|
+
"peerDependenciesMeta": {
|
|
115
|
+
"@stratakit/foundations": {
|
|
116
|
+
"optional": true
|
|
117
|
+
}
|
|
112
118
|
},
|
|
113
119
|
"lint-staged": {
|
|
114
120
|
"*.{tsx,ts,jsx,js}": [
|