@itwin/itwinui-react 1.37.3 → 1.38.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 +16 -0
- package/cjs/core/Breadcrumbs/Breadcrumbs.js +3 -5
- package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
- package/cjs/core/ComboBox/ComboBox.d.ts +4 -2
- package/cjs/core/ComboBox/ComboBox.js +129 -246
- package/cjs/core/ComboBox/ComboBoxDropdown.d.ts +8 -0
- package/cjs/core/ComboBox/ComboBoxDropdown.js +55 -0
- package/cjs/core/ComboBox/ComboBoxEndIcon.d.ts +5 -0
- package/cjs/core/ComboBox/ComboBoxEndIcon.js +54 -0
- package/cjs/core/ComboBox/ComboBoxInput.d.ts +5 -0
- package/cjs/core/ComboBox/ComboBoxInput.js +134 -0
- package/cjs/core/ComboBox/ComboBoxInputContainer.d.ts +8 -0
- package/cjs/core/ComboBox/ComboBoxInputContainer.js +45 -0
- package/cjs/core/ComboBox/ComboBoxMenu.d.ts +3 -0
- package/cjs/core/ComboBox/ComboBoxMenu.js +45 -0
- package/cjs/core/ComboBox/ComboBoxMenuItem.d.ts +21 -0
- package/cjs/core/ComboBox/ComboBoxMenuItem.js +65 -0
- package/cjs/core/ComboBox/helpers.d.ts +27 -0
- package/cjs/core/ComboBox/helpers.js +50 -0
- package/cjs/core/Modal/Modal.d.ts +1 -1
- package/cjs/core/Modal/Modal.js +6 -6
- package/cjs/core/Modal/ModalButtonBar.d.ts +1 -1
- package/cjs/core/Modal/ModalButtonBar.js +2 -2
- package/cjs/core/Modal/ModalContent.d.ts +1 -1
- package/cjs/core/Modal/ModalContent.js +2 -2
- package/cjs/core/RadioTiles/RadioTile.d.ts +1 -1
- package/cjs/core/RadioTiles/RadioTile.js +7 -9
- package/cjs/core/Table/Table.js +2 -2
- package/cjs/core/Table/filters/FilterToggle.js +3 -2
- package/cjs/core/Toast/ToastWrapper.d.ts +7 -5
- package/cjs/core/Toast/ToastWrapper.js +8 -4
- package/cjs/core/Toast/Toaster.d.ts +3 -0
- package/cjs/core/Toast/Toaster.js +66 -5
- package/cjs/core/utils/components/Popover.d.ts +1 -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/useSafeContext.d.ts +6 -0
- package/cjs/core/utils/hooks/useSafeContext.js +23 -0
- package/esm/core/Breadcrumbs/Breadcrumbs.js +3 -5
- package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
- package/esm/core/ComboBox/ComboBox.d.ts +4 -2
- package/esm/core/ComboBox/ComboBox.js +131 -248
- package/esm/core/ComboBox/ComboBoxDropdown.d.ts +8 -0
- package/esm/core/ComboBox/ComboBoxDropdown.js +49 -0
- package/esm/core/ComboBox/ComboBoxEndIcon.d.ts +5 -0
- package/esm/core/ComboBox/ComboBoxEndIcon.js +48 -0
- package/esm/core/ComboBox/ComboBoxInput.d.ts +5 -0
- package/esm/core/ComboBox/ComboBoxInput.js +128 -0
- package/esm/core/ComboBox/ComboBoxInputContainer.d.ts +8 -0
- package/esm/core/ComboBox/ComboBoxInputContainer.js +38 -0
- package/esm/core/ComboBox/ComboBoxMenu.d.ts +3 -0
- package/esm/core/ComboBox/ComboBoxMenu.js +39 -0
- package/esm/core/ComboBox/ComboBoxMenuItem.d.ts +21 -0
- package/esm/core/ComboBox/ComboBoxMenuItem.js +59 -0
- package/esm/core/ComboBox/helpers.d.ts +27 -0
- package/esm/core/ComboBox/helpers.js +43 -0
- package/esm/core/Modal/Modal.d.ts +1 -1
- package/esm/core/Modal/Modal.js +6 -6
- package/esm/core/Modal/ModalButtonBar.d.ts +1 -1
- package/esm/core/Modal/ModalButtonBar.js +2 -2
- package/esm/core/Modal/ModalContent.d.ts +1 -1
- package/esm/core/Modal/ModalContent.js +2 -2
- package/esm/core/RadioTiles/RadioTile.d.ts +1 -1
- package/esm/core/RadioTiles/RadioTile.js +7 -9
- package/esm/core/Table/Table.js +2 -2
- package/esm/core/Table/filters/FilterToggle.js +3 -2
- package/esm/core/Toast/ToastWrapper.d.ts +7 -5
- package/esm/core/Toast/ToastWrapper.js +8 -3
- package/esm/core/Toast/Toaster.d.ts +3 -0
- package/esm/core/Toast/Toaster.js +66 -5
- package/esm/core/utils/components/Popover.d.ts +1 -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/useSafeContext.d.ts +6 -0
- package/esm/core/utils/hooks/useSafeContext.js +16 -0
- package/package.json +5 -33
|
@@ -9,6 +9,42 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
12
48
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
49
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
50
|
if (ar || !(i in from)) {
|
|
@@ -35,18 +71,21 @@ var Toaster = /** @class */ (function () {
|
|
|
35
71
|
order: 'descending',
|
|
36
72
|
placement: 'top',
|
|
37
73
|
};
|
|
74
|
+
this.toastsRef = React.createRef();
|
|
75
|
+
this.isInitialized = false;
|
|
38
76
|
}
|
|
39
77
|
/**
|
|
40
78
|
* Set global Toaster settings for toasts order and placement.
|
|
41
79
|
* Settings will be applied to new toasts on the page.
|
|
42
80
|
*/
|
|
43
81
|
Toaster.prototype.setSettings = function (newSettings) {
|
|
44
|
-
var _a, _b, _c;
|
|
82
|
+
var _a, _b, _c, _d, _e;
|
|
45
83
|
(_a = newSettings.placement) !== null && _a !== void 0 ? _a : (newSettings.placement = this.settings.placement);
|
|
46
84
|
(_b = newSettings.order) !== null && _b !== void 0 ? _b : (newSettings.order = ((_c = newSettings.placement) === null || _c === void 0 ? void 0 : _c.startsWith('bottom'))
|
|
47
85
|
? 'ascending'
|
|
48
86
|
: 'descending');
|
|
49
87
|
this.settings = newSettings;
|
|
88
|
+
(_d = this.toastsRef.current) === null || _d === void 0 ? void 0 : _d.setPlacement((_e = this.settings.placement) !== null && _e !== void 0 ? _e : 'top');
|
|
50
89
|
};
|
|
51
90
|
Toaster.prototype.positive = function (content, options) {
|
|
52
91
|
return this.createToast(content, 'positive', options);
|
|
@@ -78,12 +117,34 @@ var Toaster = /** @class */ (function () {
|
|
|
78
117
|
this.toasts = this.toasts.filter(function (toast) { return toast.id !== id; });
|
|
79
118
|
this.updateView();
|
|
80
119
|
};
|
|
120
|
+
// Create container on demand.
|
|
121
|
+
// Cannot do it in constructor, because SSG/SSR apps would fail.
|
|
122
|
+
Toaster.prototype.createContainer = function () {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
124
|
+
var container;
|
|
125
|
+
return __generator(this, function (_a) {
|
|
126
|
+
container = getContainer(TOASTS_CONTAINER_ID);
|
|
127
|
+
if (!container) {
|
|
128
|
+
return [2 /*return*/];
|
|
129
|
+
}
|
|
130
|
+
ReactDOM.render(React.createElement(ToastWrapper, { ref: this.toastsRef }), container);
|
|
131
|
+
return [2 /*return*/];
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
};
|
|
81
135
|
Toaster.prototype.updateView = function () {
|
|
82
|
-
var
|
|
83
|
-
|
|
84
|
-
|
|
136
|
+
var _this = this;
|
|
137
|
+
var _a;
|
|
138
|
+
if (!this.isInitialized) {
|
|
139
|
+
this.createContainer().then(function () {
|
|
140
|
+
var _a;
|
|
141
|
+
_this.isInitialized = true;
|
|
142
|
+
(_a = _this.toastsRef.current) === null || _a === void 0 ? void 0 : _a.setToasts(_this.toasts);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
(_a = this.toastsRef.current) === null || _a === void 0 ? void 0 : _a.setToasts(this.toasts);
|
|
85
147
|
}
|
|
86
|
-
ReactDOM.render(React.createElement(ToastWrapper, { toasts: this.toasts, placement: this.settings.placement }), container);
|
|
87
148
|
};
|
|
88
149
|
Toaster.prototype.closeToast = function (toastId) {
|
|
89
150
|
this.toasts = this.toasts.map(function (toast) {
|
|
@@ -43,7 +43,7 @@ export declare const Popover: React.ForwardRefExoticComponent<Pick<{
|
|
|
43
43
|
* @see [tippy.js placement prop](https://atomiks.github.io/tippyjs/v6/all-props/#placement).
|
|
44
44
|
*/
|
|
45
45
|
placement?: import("@popperjs/core").Placement | undefined;
|
|
46
|
-
} & Omit<TippyProps, "placement" | "trigger" | "visible">, "disabled" | "placement" | "trigger" | "visible" | "content" | "render" | "animateFill" | "appendTo" | "aria" | "delay" | "duration" | "followCursor" | "getReferenceClientRect" | "hideOnClick" | "ignoreAttributes" | "inlinePositioning" | "interactive" | "interactiveBorder" | "interactiveDebounce" | "moveTransition" | "offset" | "plugins" | "popperOptions" | "showOnCreate" | "sticky" | "touch" | "triggerTarget" | "onAfterUpdate" | "onBeforeUpdate" | "onCreate" | "onDestroy" | "onHidden" | "onHide" | "onMount" | "onShow" | "onShown" | "onTrigger" | "onUntrigger" | "onClickOutside" | "allowHTML" | "animation" | "arrow" | "inertia" | "maxWidth" | "role" | "theme" | "zIndex" | "
|
|
46
|
+
} & Omit<TippyProps, "placement" | "trigger" | "visible">, "disabled" | "children" | "placement" | "trigger" | "visible" | "content" | "render" | "animateFill" | "appendTo" | "aria" | "delay" | "duration" | "followCursor" | "getReferenceClientRect" | "hideOnClick" | "ignoreAttributes" | "inlinePositioning" | "interactive" | "interactiveBorder" | "interactiveDebounce" | "moveTransition" | "offset" | "plugins" | "popperOptions" | "showOnCreate" | "sticky" | "touch" | "triggerTarget" | "onAfterUpdate" | "onBeforeUpdate" | "onCreate" | "onDestroy" | "onHidden" | "onHide" | "onMount" | "onShow" | "onShown" | "onTrigger" | "onUntrigger" | "onClickOutside" | "allowHTML" | "animation" | "arrow" | "inertia" | "maxWidth" | "role" | "theme" | "zIndex" | "className" | "singleton" | "reference"> & React.RefAttributes<unknown>>;
|
|
47
47
|
/**
|
|
48
48
|
* Plugin to hide Popover when either Esc key is pressed,
|
|
49
49
|
* or when the content inside is not tabbable and Tab key is pressed.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Wrapper hook around `useContext` that throws an error if the context is not provided.
|
|
4
|
+
* @param context Context to use. Must have a `displayName` for useful errors.
|
|
5
|
+
*/
|
|
6
|
+
export declare const useSafeContext: <T>(context: React.Context<T>) => NonNullable<T>;
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
/**
|
|
7
|
+
* Wrapper hook around `useContext` that throws an error if the context is not provided.
|
|
8
|
+
* @param context Context to use. Must have a `displayName` for useful errors.
|
|
9
|
+
*/
|
|
10
|
+
export var useSafeContext = function (context) {
|
|
11
|
+
var value = React.useContext(context);
|
|
12
|
+
if (!value) {
|
|
13
|
+
throw new Error("".concat(context.displayName, " is undefined"));
|
|
14
|
+
}
|
|
15
|
+
return value; // eslint-disable-line @typescript-eslint/no-non-null-assertion -- we already checked for undefined
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/itwinui-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.38.0",
|
|
4
4
|
"author": "Bentley Systems",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "cjs/index.js",
|
|
@@ -38,15 +38,14 @@
|
|
|
38
38
|
"createComponent": "node scripts/createComponent.js",
|
|
39
39
|
"format": "prettier --config .prettierrc **/*.{tsx,ts,js} --ignore-path .gitignore --write",
|
|
40
40
|
"lint": "eslint \"**/*.{js,ts,tsx}\" --max-warnings=0",
|
|
41
|
-
"lint:fix": "yarn lint --fix &&
|
|
42
|
-
"
|
|
43
|
-
"copy-files": "cpx \"../../{README,LICENSE}.md\" .",
|
|
41
|
+
"lint:fix": "yarn lint --fix && node ../configs/copyrightLinter.js --fix \"*/**/*.{js,ts,tsx}\"",
|
|
42
|
+
"copy-files": "cpy \"../../{README,LICENSE}.md\" .",
|
|
44
43
|
"storybook": "start-storybook -p 6006",
|
|
45
44
|
"dev": "yarn storybook",
|
|
46
45
|
"build-storybook": "yarn copy-files && build-storybook"
|
|
47
46
|
},
|
|
48
47
|
"dependencies": {
|
|
49
|
-
"@itwin/itwinui-css": "^0.
|
|
48
|
+
"@itwin/itwinui-css": "^0.58.0",
|
|
50
49
|
"@itwin/itwinui-icons-react": "^1.5.0",
|
|
51
50
|
"@itwin/itwinui-illustrations-react": "^1.0.1",
|
|
52
51
|
"@tippyjs/react": "^4.2.5",
|
|
@@ -84,20 +83,14 @@
|
|
|
84
83
|
"babel-loader": "^8.2.2",
|
|
85
84
|
"concurrently": "^5.3.0",
|
|
86
85
|
"configs": "*",
|
|
87
|
-
"cpx": "^1.5.0",
|
|
88
86
|
"creevey": "^0.8.0-beta.0",
|
|
89
|
-
"fast-glob": "^3.2.5",
|
|
90
|
-
"husky": "^4.0.0",
|
|
91
87
|
"inquirer": "^6.2.2",
|
|
92
88
|
"jest": "^27.0.6",
|
|
93
89
|
"jest-cli": "^27.0.6",
|
|
94
90
|
"jest-junit": "^12.0.0",
|
|
95
|
-
"lint-staged": "^12.1.2",
|
|
96
91
|
"markdown-to-jsx": "6.11.4",
|
|
97
|
-
"mkdirp": "^1.0.4",
|
|
98
92
|
"react": "^17.0.2",
|
|
99
93
|
"react-dom": "^17.0.2",
|
|
100
|
-
"rimraf": "^2.6.2",
|
|
101
94
|
"storybook-dark-mode": "^1.0.9",
|
|
102
95
|
"tippy.js": "^6.3.1",
|
|
103
96
|
"ts-jest": "^27.0.4",
|
|
@@ -110,32 +103,11 @@
|
|
|
110
103
|
"react": "^16.8.6 || ^17.0.0",
|
|
111
104
|
"react-dom": "^16.8.6 || ^17.0.0"
|
|
112
105
|
},
|
|
113
|
-
"resolutions": {
|
|
114
|
-
"braces": "^2.3.1",
|
|
115
|
-
"hosted-git-info": ">=3.0.8",
|
|
116
|
-
"trim": "^0.0.3",
|
|
117
|
-
"browserslist": "^4.16.6",
|
|
118
|
-
"glob-parent": "^5.1.2",
|
|
119
|
-
"css-what": "^5.0.1",
|
|
120
|
-
"immer": "^9.0.6",
|
|
121
|
-
"set-value": "^4.1.0",
|
|
122
|
-
"prismjs": "^1.25.0",
|
|
123
|
-
"nth-check": "^2.0.1",
|
|
124
|
-
"ansi-regex": "^5.0.1",
|
|
125
|
-
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.1",
|
|
126
|
-
"postcss": "8",
|
|
127
|
-
"nanoid": "^3.1.31"
|
|
128
|
-
},
|
|
129
|
-
"husky": {
|
|
130
|
-
"hooks": {
|
|
131
|
-
"pre-commit": "lint-staged"
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
106
|
"lint-staged": {
|
|
135
107
|
"*.{tsx,ts,jsx,js}": [
|
|
136
108
|
"prettier --write",
|
|
137
109
|
"eslint --max-warnings=0 --fix",
|
|
138
|
-
"
|
|
110
|
+
"node ../configs/copyrightLinter.js --fix"
|
|
139
111
|
]
|
|
140
112
|
},
|
|
141
113
|
"prettier": "configs/prettier-config",
|