@teambit/react.ui.error-fallback 0.0.0-cdb41241f2f4c8e0e98f402a679bbd5fc6b6244b

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.
@@ -0,0 +1,9 @@
1
+ import type { ReactNode } from 'react';
2
+ import React from 'react';
3
+ import type { FallbackProps } from 'react-error-boundary';
4
+ export type ErrorFallbackProps = FallbackProps & {
5
+ className?: string;
6
+ children?: ReactNode;
7
+ cta?: string;
8
+ };
9
+ export declare function ErrorFallback({ resetErrorBoundary, className, children, cta, }: ErrorFallbackProps): React.JSX.Element;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-misused-promises */
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.ErrorFallback = ErrorFallback;
17
+ const react_1 = __importDefault(require("react"));
18
+ const classnames_1 = __importDefault(require("classnames"));
19
+ const design_ui_icon_button_1 = require("@teambit/design.ui.icon-button");
20
+ const base_ui_styles_flex_center_1 = require("@teambit/base-ui.styles.flex-center");
21
+ const error_fallback_module_scss_1 = __importDefault(require("./error-fallback.module.scss"));
22
+ function ErrorFallback({
23
+ /* error, */
24
+ resetErrorBoundary, className, children = 'Failed to render', cta = 'try again', }) {
25
+ const handleClick = () => __awaiter(this, void 0, void 0, function* () {
26
+ yield new Promise((resolve) => setTimeout(resolve, 480));
27
+ resetErrorBoundary();
28
+ });
29
+ return (react_1.default.createElement("div", { className: (0, classnames_1.default)(error_fallback_module_scss_1.default.errorFallback, base_ui_styles_flex_center_1.flexCenter, className) },
30
+ react_1.default.createElement("div", { className: error_fallback_module_scss_1.default.icon }),
31
+ react_1.default.createElement("div", { className: error_fallback_module_scss_1.default.message }, children),
32
+ react_1.default.createElement(design_ui_icon_button_1.IconButton, { onClick: handleClick, className: error_fallback_module_scss_1.default.retryButton }, cta)));
33
+ }
34
+ //# sourceMappingURL=error-fallback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-fallback.js","sourceRoot":"","sources":["../error-fallback.tsx"],"names":[],"mappings":";AAAA,2DAA2D;;;;;;;;;;;;;;AAY3D,sCAqBC;AA9BD,kDAA0B;AAC1B,4DAAoC;AAEpC,0EAA4D;AAC5D,oFAAiE;AAEjE,8FAAkD;AAGlD,SAAgB,aAAa,CAAC;AAC5B,YAAY;AACZ,kBAAkB,EAClB,SAAS,EACT,QAAQ,GAAG,kBAAkB,EAC7B,GAAG,GAAG,WAAW,GACE;IACnB,MAAM,WAAW,GAAG,GAAS,EAAE;QAC7B,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;QACzD,kBAAkB,EAAE,CAAC;IACvB,CAAC,CAAA,CAAC;IAEF,OAAO,CACL,uCAAK,SAAS,EAAE,IAAA,oBAAU,EAAC,oCAAM,CAAC,aAAa,EAAE,uCAAU,EAAE,SAAS,CAAC;QACrE,uCAAK,SAAS,EAAE,oCAAM,CAAC,IAAI,GAAI;QAC/B,uCAAK,SAAS,EAAE,oCAAM,CAAC,OAAO,IAAG,QAAQ,CAAO;QAChD,8BAAC,kCAAU,IAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,oCAAM,CAAC,WAAW,IAC5D,GAAG,CACO,CACT,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,42 @@
1
+ .icon {
2
+ // fail-safe inline image (with the color #e62e5c, $r5 0)
3
+ background-image: url("data:image/svg+xml,%3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='512' height='512' viewBox='0 0 512 512'%3E%3Ctitle%3E%3C/title%3E%3Cpath fill='%23e62e5c' d='M256 512c141.385 0 256-114.615 256-256s-114.615-256-256-256c-141.385 0-256 114.615-256 256s114.615 256 256 256zM376.262 171.498l-86.038 84.5 86.038 84.511c10.451 10.275 10.183 25.962 0 35.968-10.077 9.891-25.68 10.17-36.038 0l-84.222-82.743-84.235 82.743c-10.345 10.17-25.949 9.891-36.026 0-10.182-10.007-10.461-25.693 0-35.968l86.038-84.511-86.038-84.501c-10.461-10.286-10.182-25.971 0-35.978 10.077-9.891 25.681-10.159 36.026 0l84.235 82.743 84.222-82.743c10.358-10.159 25.962-9.891 36.038 0 10.183 10.007 10.451 25.692 0 35.978z'%3E%3C/path%3E%3C/svg%3E%0A");
4
+
5
+ height: 24px;
6
+ width: 24px;
7
+ background-color: white;
8
+ background-size: contain;
9
+ margin-bottom: 16px;
10
+ border-radius: 100%;
11
+ }
12
+
13
+ .message {
14
+ color: var(--bit-error-color, #e62e5c);
15
+ margin-bottom: 8px;
16
+ }
17
+
18
+ .errorFallback {
19
+ animation: enter 300ms ease-in forwards;
20
+
21
+ height: 100%;
22
+ padding: 8px;
23
+ border: 4px solid var(--bit-error-light, #f086a0);
24
+ border-radius: 4px;
25
+ box-sizing: border-box;
26
+
27
+ color: var(--bit-error-color, #e62e5c);
28
+ font-family: sans-serif;
29
+
30
+ > * {
31
+ flex: none; // prevent squashing in low res
32
+ }
33
+ }
34
+
35
+ @keyframes enter {
36
+ 0% {
37
+ opacity: 0.1;
38
+ }
39
+ 100% {
40
+ opacity: 1;
41
+ }
42
+ }
@@ -0,0 +1,2 @@
1
+ export { ErrorFallback } from './error-fallback';
2
+ export type { ErrorFallbackProps } from './error-fallback';
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorFallback = void 0;
4
+ var error_fallback_1 = require("./error-fallback");
5
+ Object.defineProperty(exports, "ErrorFallback", { enumerable: true, get: function () { return error_fallback_1.ErrorFallback; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAAxC,+GAAA,aAAa,OAAA"}
@@ -0,0 +1,7 @@
1
+ ;
2
+ ;
3
+
4
+ export const compositions = [];
5
+ export const overview = [];
6
+
7
+ export const compositions_metadata = {"compositions":[]};
@@ -0,0 +1,42 @@
1
+ .icon {
2
+ // fail-safe inline image (with the color #e62e5c, $r5 0)
3
+ background-image: url("data:image/svg+xml,%3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='512' height='512' viewBox='0 0 512 512'%3E%3Ctitle%3E%3C/title%3E%3Cpath fill='%23e62e5c' d='M256 512c141.385 0 256-114.615 256-256s-114.615-256-256-256c-141.385 0-256 114.615-256 256s114.615 256 256 256zM376.262 171.498l-86.038 84.5 86.038 84.511c10.451 10.275 10.183 25.962 0 35.968-10.077 9.891-25.68 10.17-36.038 0l-84.222-82.743-84.235 82.743c-10.345 10.17-25.949 9.891-36.026 0-10.182-10.007-10.461-25.693 0-35.968l86.038-84.511-86.038-84.501c-10.461-10.286-10.182-25.971 0-35.978 10.077-9.891 25.681-10.159 36.026 0l84.235 82.743 84.222-82.743c10.358-10.159 25.962-9.891 36.038 0 10.183 10.007 10.451 25.692 0 35.978z'%3E%3C/path%3E%3C/svg%3E%0A");
4
+
5
+ height: 24px;
6
+ width: 24px;
7
+ background-color: white;
8
+ background-size: contain;
9
+ margin-bottom: 16px;
10
+ border-radius: 100%;
11
+ }
12
+
13
+ .message {
14
+ color: var(--bit-error-color, #e62e5c);
15
+ margin-bottom: 8px;
16
+ }
17
+
18
+ .errorFallback {
19
+ animation: enter 300ms ease-in forwards;
20
+
21
+ height: 100%;
22
+ padding: 8px;
23
+ border: 4px solid var(--bit-error-light, #f086a0);
24
+ border-radius: 4px;
25
+ box-sizing: border-box;
26
+
27
+ color: var(--bit-error-color, #e62e5c);
28
+ font-family: sans-serif;
29
+
30
+ > * {
31
+ flex: none; // prevent squashing in low res
32
+ }
33
+ }
34
+
35
+ @keyframes enter {
36
+ 0% {
37
+ opacity: 0.1;
38
+ }
39
+ 100% {
40
+ opacity: 1;
41
+ }
42
+ }
@@ -0,0 +1,34 @@
1
+ /* eslint-disable @typescript-eslint/no-misused-promises */
2
+
3
+ import type { ReactNode } from 'react';
4
+ import React from 'react';
5
+ import classnames from 'classnames';
6
+ import type { FallbackProps } from 'react-error-boundary';
7
+ import { IconButton } from '@teambit/design.ui.icon-button';
8
+ import { flexCenter } from '@teambit/base-ui.styles.flex-center';
9
+
10
+ import styles from './error-fallback.module.scss';
11
+
12
+ export type ErrorFallbackProps = FallbackProps & { className?: string; children?: ReactNode; cta?: string };
13
+ export function ErrorFallback({
14
+ /* error, */
15
+ resetErrorBoundary,
16
+ className,
17
+ children = 'Failed to render',
18
+ cta = 'try again',
19
+ }: ErrorFallbackProps) {
20
+ const handleClick = async () => {
21
+ await new Promise((resolve) => setTimeout(resolve, 480));
22
+ resetErrorBoundary();
23
+ };
24
+
25
+ return (
26
+ <div className={classnames(styles.errorFallback, flexCenter, className)}>
27
+ <div className={styles.icon} />
28
+ <div className={styles.message}>{children}</div>
29
+ <IconButton onClick={handleClick} className={styles.retryButton}>
30
+ {cta}
31
+ </IconButton>
32
+ </div>
33
+ );
34
+ }
package/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { ErrorFallback } from './error-fallback';
2
+ export type { ErrorFallbackProps } from './error-fallback';
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@teambit/react.ui.error-fallback",
3
+ "version": "0.0.0-cdb41241f2f4c8e0e98f402a679bbd5fc6b6244b",
4
+ "homepage": "https://bit.cloud/teambit/react/ui/error-fallback",
5
+ "main": "dist/index.js",
6
+ "componentId": {
7
+ "scope": "teambit.react",
8
+ "name": "ui/error-fallback",
9
+ "version": "cdb41241f2f4c8e0e98f402a679bbd5fc6b6244b"
10
+ },
11
+ "dependencies": {
12
+ "classnames": "2.2.6",
13
+ "react-error-boundary": "^3.0.0",
14
+ "core-js": "^3.0.0",
15
+ "@teambit/base-ui.styles.flex-center": "1.0.0",
16
+ "@teambit/design.ui.icon-button": "1.0.16"
17
+ },
18
+ "devDependencies": {
19
+ "@types/classnames": "2.2.11",
20
+ "@types/react": "^17.0.8",
21
+ "@types/mocha": "9.1.0",
22
+ "@types/node": "12.20.4",
23
+ "@types/react-dom": "^17.0.5",
24
+ "@types/jest": "^26.0.0",
25
+ "@babel/runtime": "7.20.0",
26
+ "@types/testing-library__jest-dom": "5.9.5"
27
+ },
28
+ "peerDependencies": {
29
+ "react": "^16.8.0 || ^17.0.0",
30
+ "react-dom": "^16.8.0 || ^17.0.0"
31
+ },
32
+ "license": "Apache-2.0",
33
+ "optionalDependencies": {},
34
+ "peerDependenciesMeta": {},
35
+ "private": false,
36
+ "engines": {
37
+ "node": ">=12.22.0"
38
+ },
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "https://github.com/teambit/bit"
42
+ },
43
+ "keywords": [
44
+ "bit",
45
+ "components",
46
+ "collaboration",
47
+ "web",
48
+ "react",
49
+ "react-components",
50
+ "angular",
51
+ "angular-components"
52
+ ]
53
+ }
@@ -0,0 +1,29 @@
1
+ declare module '*.png' {
2
+ const value: any;
3
+ export = value;
4
+ }
5
+ declare module '*.svg' {
6
+ import type { FunctionComponent, SVGProps } from 'react';
7
+
8
+ export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
9
+ const src: string;
10
+ export default src;
11
+ }
12
+
13
+ // @TODO Gilad
14
+ declare module '*.jpg' {
15
+ const value: any;
16
+ export = value;
17
+ }
18
+ declare module '*.jpeg' {
19
+ const value: any;
20
+ export = value;
21
+ }
22
+ declare module '*.gif' {
23
+ const value: any;
24
+ export = value;
25
+ }
26
+ declare module '*.bmp' {
27
+ const value: any;
28
+ export = value;
29
+ }
@@ -0,0 +1,42 @@
1
+ declare module '*.module.css' {
2
+ const classes: { readonly [key: string]: string };
3
+ export default classes;
4
+ }
5
+ declare module '*.module.scss' {
6
+ const classes: { readonly [key: string]: string };
7
+ export default classes;
8
+ }
9
+ declare module '*.module.sass' {
10
+ const classes: { readonly [key: string]: string };
11
+ export default classes;
12
+ }
13
+
14
+ declare module '*.module.less' {
15
+ const classes: { readonly [key: string]: string };
16
+ export default classes;
17
+ }
18
+
19
+ declare module '*.less' {
20
+ const classes: { readonly [key: string]: string };
21
+ export default classes;
22
+ }
23
+
24
+ declare module '*.css' {
25
+ const classes: { readonly [key: string]: string };
26
+ export default classes;
27
+ }
28
+
29
+ declare module '*.sass' {
30
+ const classes: { readonly [key: string]: string };
31
+ export default classes;
32
+ }
33
+
34
+ declare module '*.scss' {
35
+ const classes: { readonly [key: string]: string };
36
+ export default classes;
37
+ }
38
+
39
+ declare module '*.mdx' {
40
+ const component: any;
41
+ export default component;
42
+ }