@itwin/itwinui-react 2.3.1-dev.0 → 2.4.0-dev.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.
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ButtonProps } from '../Button';
3
+ import { DropdownMenuProps } from '../../DropdownMenu';
3
4
  import '@itwin/itwinui-css/css/button.css';
4
5
  export declare type DropdownButtonProps = {
5
6
  /**
@@ -14,6 +15,10 @@ export declare type DropdownButtonProps = {
14
15
  * @default 'default'
15
16
  */
16
17
  styleType?: 'default' | 'borderless';
18
+ /**
19
+ * Props for the `DropdownMenu` which extends `PopoverProps`.
20
+ */
21
+ dropdownMenuProps?: Omit<DropdownMenuProps, 'menuItems' | 'children'>;
17
22
  } & Omit<ButtonProps, 'onClick' | 'styleType' | 'endIcon'>;
18
23
  /**
19
24
  * Button that opens a DropdownMenu.
@@ -37,5 +42,9 @@ export declare const DropdownButton: React.ForwardRefExoticComponent<{
37
42
  * @default 'default'
38
43
  */
39
44
  styleType?: "default" | "borderless" | undefined;
45
+ /**
46
+ * Props for the `DropdownMenu` which extends `PopoverProps`.
47
+ */
48
+ dropdownMenuProps?: Omit<DropdownMenuProps, "children" | "menuItems"> | undefined;
40
49
  } & Omit<ButtonProps<"button">, "onClick" | "styleType" | "endIcon"> & React.RefAttributes<HTMLButtonElement>>;
41
50
  export default DropdownButton;
@@ -24,7 +24,7 @@ require("@itwin/itwinui-css/css/button.css");
24
24
  * <DropdownButton menuItems={menuItems}>Default</DropdownButton>
25
25
  */
26
26
  exports.DropdownButton = react_1.default.forwardRef((props, ref) => {
27
- const { menuItems, className, size, styleType, children, ...rest } = props;
27
+ const { menuItems, className, size, styleType, children, dropdownMenuProps, ...rest } = props;
28
28
  (0, utils_1.useTheme)();
29
29
  const [isMenuOpen, setIsMenuOpen] = react_1.default.useState(false);
30
30
  const [menuWidth, setMenuWidth] = react_1.default.useState(0);
@@ -35,7 +35,15 @@ exports.DropdownButton = react_1.default.forwardRef((props, ref) => {
35
35
  setMenuWidth(buttonRef.current.offsetWidth);
36
36
  }
37
37
  }, [children, size, styleType]);
38
- return (react_1.default.createElement(DropdownMenu_1.DropdownMenu, { menuItems: menuItems, style: { minWidth: menuWidth }, onShow: () => setIsMenuOpen(true), onHide: () => setIsMenuOpen(false) },
38
+ return (react_1.default.createElement(DropdownMenu_1.DropdownMenu, { menuItems: menuItems, ...dropdownMenuProps, onShow: (i) => {
39
+ var _a;
40
+ setIsMenuOpen(true);
41
+ (_a = dropdownMenuProps === null || dropdownMenuProps === void 0 ? void 0 : dropdownMenuProps.onShow) === null || _a === void 0 ? void 0 : _a.call(dropdownMenuProps, i);
42
+ }, onHide: (i) => {
43
+ var _a;
44
+ setIsMenuOpen(false);
45
+ (_a = dropdownMenuProps === null || dropdownMenuProps === void 0 ? void 0 : dropdownMenuProps.onHide) === null || _a === void 0 ? void 0 : _a.call(dropdownMenuProps, i);
46
+ }, style: { minWidth: menuWidth, ...dropdownMenuProps === null || dropdownMenuProps === void 0 ? void 0 : dropdownMenuProps.style } },
39
47
  react_1.default.createElement(Button_1.Button, { className: (0, classnames_1.default)('iui-button-dropdown', className), size: size, styleType: styleType, endIcon: isMenuOpen ? (react_1.default.createElement(utils_1.SvgCaretUpSmall, { "aria-hidden": true })) : (react_1.default.createElement(utils_1.SvgCaretDownSmall, { "aria-hidden": true })), ref: refs, "aria-label": 'Dropdown', ...rest }, children)));
40
48
  });
41
49
  exports.default = exports.DropdownButton;
@@ -15,7 +15,7 @@ export declare type DropdownMenuProps = {
15
15
  * Child element to wrap dropdown with.
16
16
  */
17
17
  children: React.ReactNode;
18
- } & PopoverProps & Omit<CommonProps, 'title'>;
18
+ } & Omit<PopoverProps, 'content'> & Omit<CommonProps, 'title'>;
19
19
  /**
20
20
  * Dropdown menu component.
21
21
  * Uses the {@link Popover} component, which is a wrapper around [tippy.js](https://atomiks.github.io/tippyjs).
@@ -27,22 +27,22 @@ export default class Toaster {
27
27
  * Set global Toaster settings for toasts order and placement.
28
28
  * Settings will be applied to new toasts on the page.
29
29
  */
30
- setSettings(newSettings: ToasterSettings): Promise<void>;
30
+ setSettings(newSettings: ToasterSettings): void;
31
31
  positive(content: React.ReactNode, options?: ToastOptions): {
32
- close: () => Promise<void>;
32
+ close: () => void;
33
33
  };
34
34
  informational(content: React.ReactNode, options?: ToastOptions): {
35
- close: () => Promise<void>;
35
+ close: () => void;
36
36
  };
37
37
  negative(content: React.ReactNode, options?: ToastOptions): {
38
- close: () => Promise<void>;
38
+ close: () => void;
39
39
  };
40
40
  warning(content: React.ReactNode, options?: ToastOptions): {
41
- close: () => Promise<void>;
41
+ close: () => void;
42
42
  };
43
43
  private createToast;
44
44
  private removeToast;
45
45
  private updateView;
46
46
  private closeToast;
47
- closeAll(): Promise<void>;
47
+ closeAll(): void;
48
48
  }
@@ -83,14 +83,14 @@ class Toaster {
83
83
  * Set global Toaster settings for toasts order and placement.
84
84
  * Settings will be applied to new toasts on the page.
85
85
  */
86
- async setSettings(newSettings) {
86
+ setSettings(newSettings) {
87
87
  var _a, _b, _c;
88
88
  (_a = newSettings.placement) !== null && _a !== void 0 ? _a : (newSettings.placement = this.settings.placement);
89
89
  (_b = newSettings.order) !== null && _b !== void 0 ? _b : (newSettings.order = ((_c = newSettings.placement) === null || _c === void 0 ? void 0 : _c.startsWith('bottom'))
90
90
  ? 'ascending'
91
91
  : 'descending');
92
92
  this.settings = newSettings;
93
- await this.asyncInit().then(() => {
93
+ this.asyncInit().then(() => {
94
94
  var _a, _b;
95
95
  (_a = this.toastsRef.current) === null || _a === void 0 ? void 0 : _a.setPlacement((_b = this.settings.placement) !== null && _b !== void 0 ? _b : 'top');
96
96
  });
@@ -126,37 +126,36 @@ class Toaster {
126
126
  },
127
127
  ...(this.settings.order === 'descending' ? this.toasts : []),
128
128
  ];
129
- // cannot `await` this, for backwards compat with the return value
130
129
  this.updateView();
131
130
  return { close: () => this.closeToast(currentId) };
132
131
  }
133
- async removeToast(id) {
132
+ removeToast(id) {
134
133
  this.toasts = this.toasts.filter((toast) => toast.id !== id);
135
134
  this.updateView();
136
135
  }
137
- async updateView() {
138
- await this.asyncInit().then(() => {
136
+ updateView() {
137
+ this.asyncInit().then(() => {
139
138
  var _a;
140
139
  (_a = this.toastsRef.current) === null || _a === void 0 ? void 0 : _a.setToasts(this.toasts);
141
140
  });
142
141
  }
143
- async closeToast(toastId) {
142
+ closeToast(toastId) {
144
143
  this.toasts = this.toasts.map((toast) => {
145
144
  return {
146
145
  ...toast,
147
146
  isVisible: toast.id !== toastId,
148
147
  };
149
148
  });
150
- await this.updateView();
149
+ this.updateView();
151
150
  }
152
- async closeAll() {
151
+ closeAll() {
153
152
  this.toasts = this.toasts.map((toast) => {
154
153
  return {
155
154
  ...toast,
156
155
  isVisible: false,
157
156
  };
158
157
  });
159
- await this.updateView();
158
+ this.updateView();
160
159
  }
161
160
  }
162
161
  exports.default = Toaster;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ButtonProps } from '../Button';
3
+ import { DropdownMenuProps } from '../../DropdownMenu';
3
4
  import '@itwin/itwinui-css/css/button.css';
4
5
  export declare type DropdownButtonProps = {
5
6
  /**
@@ -14,6 +15,10 @@ export declare type DropdownButtonProps = {
14
15
  * @default 'default'
15
16
  */
16
17
  styleType?: 'default' | 'borderless';
18
+ /**
19
+ * Props for the `DropdownMenu` which extends `PopoverProps`.
20
+ */
21
+ dropdownMenuProps?: Omit<DropdownMenuProps, 'menuItems' | 'children'>;
17
22
  } & Omit<ButtonProps, 'onClick' | 'styleType' | 'endIcon'>;
18
23
  /**
19
24
  * Button that opens a DropdownMenu.
@@ -37,5 +42,9 @@ export declare const DropdownButton: React.ForwardRefExoticComponent<{
37
42
  * @default 'default'
38
43
  */
39
44
  styleType?: "default" | "borderless" | undefined;
45
+ /**
46
+ * Props for the `DropdownMenu` which extends `PopoverProps`.
47
+ */
48
+ dropdownMenuProps?: Omit<DropdownMenuProps, "children" | "menuItems"> | undefined;
40
49
  } & Omit<ButtonProps<"button">, "onClick" | "styleType" | "endIcon"> & React.RefAttributes<HTMLButtonElement>>;
41
50
  export default DropdownButton;
@@ -18,7 +18,7 @@ import '@itwin/itwinui-css/css/button.css';
18
18
  * <DropdownButton menuItems={menuItems}>Default</DropdownButton>
19
19
  */
20
20
  export const DropdownButton = React.forwardRef((props, ref) => {
21
- const { menuItems, className, size, styleType, children, ...rest } = props;
21
+ const { menuItems, className, size, styleType, children, dropdownMenuProps, ...rest } = props;
22
22
  useTheme();
23
23
  const [isMenuOpen, setIsMenuOpen] = React.useState(false);
24
24
  const [menuWidth, setMenuWidth] = React.useState(0);
@@ -29,7 +29,15 @@ export const DropdownButton = React.forwardRef((props, ref) => {
29
29
  setMenuWidth(buttonRef.current.offsetWidth);
30
30
  }
31
31
  }, [children, size, styleType]);
32
- return (React.createElement(DropdownMenu, { menuItems: menuItems, style: { minWidth: menuWidth }, onShow: () => setIsMenuOpen(true), onHide: () => setIsMenuOpen(false) },
32
+ return (React.createElement(DropdownMenu, { menuItems: menuItems, ...dropdownMenuProps, onShow: (i) => {
33
+ var _a;
34
+ setIsMenuOpen(true);
35
+ (_a = dropdownMenuProps === null || dropdownMenuProps === void 0 ? void 0 : dropdownMenuProps.onShow) === null || _a === void 0 ? void 0 : _a.call(dropdownMenuProps, i);
36
+ }, onHide: (i) => {
37
+ var _a;
38
+ setIsMenuOpen(false);
39
+ (_a = dropdownMenuProps === null || dropdownMenuProps === void 0 ? void 0 : dropdownMenuProps.onHide) === null || _a === void 0 ? void 0 : _a.call(dropdownMenuProps, i);
40
+ }, style: { minWidth: menuWidth, ...dropdownMenuProps === null || dropdownMenuProps === void 0 ? void 0 : dropdownMenuProps.style } },
33
41
  React.createElement(Button, { className: cx('iui-button-dropdown', className), size: size, styleType: styleType, endIcon: isMenuOpen ? (React.createElement(SvgCaretUpSmall, { "aria-hidden": true })) : (React.createElement(SvgCaretDownSmall, { "aria-hidden": true })), ref: refs, "aria-label": 'Dropdown', ...rest }, children)));
34
42
  });
35
43
  export default DropdownButton;
@@ -15,7 +15,7 @@ export declare type DropdownMenuProps = {
15
15
  * Child element to wrap dropdown with.
16
16
  */
17
17
  children: React.ReactNode;
18
- } & PopoverProps & Omit<CommonProps, 'title'>;
18
+ } & Omit<PopoverProps, 'content'> & Omit<CommonProps, 'title'>;
19
19
  /**
20
20
  * Dropdown menu component.
21
21
  * Uses the {@link Popover} component, which is a wrapper around [tippy.js](https://atomiks.github.io/tippyjs).
@@ -27,22 +27,22 @@ export default class Toaster {
27
27
  * Set global Toaster settings for toasts order and placement.
28
28
  * Settings will be applied to new toasts on the page.
29
29
  */
30
- setSettings(newSettings: ToasterSettings): Promise<void>;
30
+ setSettings(newSettings: ToasterSettings): void;
31
31
  positive(content: React.ReactNode, options?: ToastOptions): {
32
- close: () => Promise<void>;
32
+ close: () => void;
33
33
  };
34
34
  informational(content: React.ReactNode, options?: ToastOptions): {
35
- close: () => Promise<void>;
35
+ close: () => void;
36
36
  };
37
37
  negative(content: React.ReactNode, options?: ToastOptions): {
38
- close: () => Promise<void>;
38
+ close: () => void;
39
39
  };
40
40
  warning(content: React.ReactNode, options?: ToastOptions): {
41
- close: () => Promise<void>;
41
+ close: () => void;
42
42
  };
43
43
  private createToast;
44
44
  private removeToast;
45
45
  private updateView;
46
46
  private closeToast;
47
- closeAll(): Promise<void>;
47
+ closeAll(): void;
48
48
  }
@@ -55,14 +55,14 @@ export default class Toaster {
55
55
  * Set global Toaster settings for toasts order and placement.
56
56
  * Settings will be applied to new toasts on the page.
57
57
  */
58
- async setSettings(newSettings) {
58
+ setSettings(newSettings) {
59
59
  var _a, _b, _c;
60
60
  (_a = newSettings.placement) !== null && _a !== void 0 ? _a : (newSettings.placement = this.settings.placement);
61
61
  (_b = newSettings.order) !== null && _b !== void 0 ? _b : (newSettings.order = ((_c = newSettings.placement) === null || _c === void 0 ? void 0 : _c.startsWith('bottom'))
62
62
  ? 'ascending'
63
63
  : 'descending');
64
64
  this.settings = newSettings;
65
- await this.asyncInit().then(() => {
65
+ this.asyncInit().then(() => {
66
66
  var _a, _b;
67
67
  (_a = this.toastsRef.current) === null || _a === void 0 ? void 0 : _a.setPlacement((_b = this.settings.placement) !== null && _b !== void 0 ? _b : 'top');
68
68
  });
@@ -98,36 +98,35 @@ export default class Toaster {
98
98
  },
99
99
  ...(this.settings.order === 'descending' ? this.toasts : []),
100
100
  ];
101
- // cannot `await` this, for backwards compat with the return value
102
101
  this.updateView();
103
102
  return { close: () => this.closeToast(currentId) };
104
103
  }
105
- async removeToast(id) {
104
+ removeToast(id) {
106
105
  this.toasts = this.toasts.filter((toast) => toast.id !== id);
107
106
  this.updateView();
108
107
  }
109
- async updateView() {
110
- await this.asyncInit().then(() => {
108
+ updateView() {
109
+ this.asyncInit().then(() => {
111
110
  var _a;
112
111
  (_a = this.toastsRef.current) === null || _a === void 0 ? void 0 : _a.setToasts(this.toasts);
113
112
  });
114
113
  }
115
- async closeToast(toastId) {
114
+ closeToast(toastId) {
116
115
  this.toasts = this.toasts.map((toast) => {
117
116
  return {
118
117
  ...toast,
119
118
  isVisible: toast.id !== toastId,
120
119
  };
121
120
  });
122
- await this.updateView();
121
+ this.updateView();
123
122
  }
124
- async closeAll() {
123
+ closeAll() {
125
124
  this.toasts = this.toasts.map((toast) => {
126
125
  return {
127
126
  ...toast,
128
127
  isVisible: false,
129
128
  };
130
129
  });
131
- await this.updateView();
130
+ this.updateView();
132
131
  }
133
132
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/itwinui-react",
3
- "version": "2.3.1-dev.0",
3
+ "version": "2.4.0-dev.0",
4
4
  "author": "Bentley Systems",
5
5
  "license": "MIT",
6
6
  "main": "cjs/index.js",
@@ -62,9 +62,9 @@
62
62
  "dev:types": "concurrently \"tsc -p tsconfig.cjs.json --emitDeclarationOnly --watch --preserveWatchOutput\" \"tsc -p tsconfig.esm.json --emitDeclarationOnly --watch --preserveWatchOutput\""
63
63
  },
64
64
  "dependencies": {
65
- "@itwin/itwinui-css": "^1.4.0",
65
+ "@itwin/itwinui-css": "1.5.0-dev.0",
66
66
  "@itwin/itwinui-illustrations-react": "^2.0.0",
67
- "@itwin/itwinui-variables": "^1.0.0",
67
+ "@itwin/itwinui-variables": "2.0.0-dev.0",
68
68
  "@tippyjs/react": "^4.2.6",
69
69
  "@types/react-table": "^7.0.18",
70
70
  "classnames": "^2.2.6",