@kittycad/react-shared 1.2.0 → 1.2.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/dist/index.esm.js +25 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +24 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import * as b$2 from 'react';
|
|
3
|
-
import b__default, {
|
|
3
|
+
import b__default, { useImperativeHandle, useEffect, createElement as createElement$1, Children, forwardRef, useRef, useState, useCallback, useMemo, createContext, useContext, useLayoutEffect, cloneElement } from 'react';
|
|
4
4
|
|
|
5
5
|
function styleInject(css, ref) {
|
|
6
6
|
if ( ref === void 0 ) ref = {};
|
|
@@ -22358,7 +22358,7 @@ function SignInPageContent({ shouldTrackConversions = false, trackingClasses = (
|
|
|
22358
22358
|
}
|
|
22359
22359
|
|
|
22360
22360
|
const Spinner = (props) => {
|
|
22361
|
-
return (jsxs("svg", { "data-testid": "spinner", viewBox: "0 0 10 10", className:
|
|
22361
|
+
return (jsxs("svg", { "data-testid": "spinner", viewBox: "0 0 10 10", className: "w-8 h-8", ...props, children: [jsx("title", { children: "spinner" }), jsx("circle", { cx: "5", cy: "5", r: "4", stroke: "currentColor", fill: "none", strokeDasharray: "4, 4", className: "animate-spin origin-center" })] }));
|
|
22362
22362
|
};
|
|
22363
22363
|
|
|
22364
22364
|
// TODO: figure out where this should live v. modeling-app, for now this is only a subset
|
|
@@ -22381,8 +22381,8 @@ const TotalDue = (props) => (jsxs("div", { className: `${Number(props.amount) >
|
|
|
22381
22381
|
}, children: [jsx("span", { children: "$" }), jsx("span", { children: props.amount })] })] }));
|
|
22382
22382
|
const ErrorMsg = (props) => {
|
|
22383
22383
|
const [showMessage, setShowMessage] = useState(false);
|
|
22384
|
-
const fadedBg = 'rgba(
|
|
22385
|
-
const fadedFg = 'rgba(255, 255, 255,
|
|
22384
|
+
const fadedBg = 'rgba(0, 0, 0, 0.25)';
|
|
22385
|
+
const fadedFg = 'rgba(255, 255, 255, 0.75)';
|
|
22386
22386
|
const colors = {
|
|
22387
22387
|
color: fadedFg,
|
|
22388
22388
|
stroke: fadedFg,
|
|
@@ -22407,7 +22407,17 @@ const getBalanceString = (amount) => {
|
|
|
22407
22407
|
return `${Math.floor(amount)} min`;
|
|
22408
22408
|
};
|
|
22409
22409
|
const BillingBalance = (props) => {
|
|
22410
|
-
|
|
22410
|
+
const [showSpinner, setShowSpinner] = useState(true);
|
|
22411
|
+
useEffect(() => {
|
|
22412
|
+
const id = setTimeout(() => {
|
|
22413
|
+
setShowSpinner(false);
|
|
22414
|
+
}, 5000);
|
|
22415
|
+
return () => {
|
|
22416
|
+
clearTimeout(id);
|
|
22417
|
+
};
|
|
22418
|
+
}, []);
|
|
22419
|
+
return props.amount === Number.POSITIVE_INFINITY ? (jsx(CustomIcon, { "data-testid": "infinity", name: "infinity", className: "w-5 h-5" })) : showSpinner &&
|
|
22420
|
+
(Number.isNaN(props.amount) || props.amount === undefined) ? (jsx(Spinner, { className: "text-inherit w-4 h-4" })) : (jsx("span", { children: getBalanceString(props.amount) }));
|
|
22411
22421
|
};
|
|
22412
22422
|
const BillingRemaining = (props) => {
|
|
22413
22423
|
const isFlex = props.mode === BillingRemainingMode.ProgressBarStretch;
|
|
@@ -22421,10 +22431,19 @@ const BillingRemaining = (props) => {
|
|
|
22421
22431
|
];
|
|
22422
22432
|
const hasPaymentMethod = props.paymentMethods !== undefined && props.paymentMethods.length > 0;
|
|
22423
22433
|
const totalDue = props.userPaymentBalance?.total_due ?? '0.00';
|
|
22434
|
+
const [showSpinner, setShowSpinner] = useState(true);
|
|
22435
|
+
useEffect(() => {
|
|
22436
|
+
const id = setTimeout(() => {
|
|
22437
|
+
setShowSpinner(false);
|
|
22438
|
+
}, 5000);
|
|
22439
|
+
return () => {
|
|
22440
|
+
clearTimeout(id);
|
|
22441
|
+
};
|
|
22442
|
+
}, []);
|
|
22424
22443
|
return (jsxs("div", { "data-testid": "billing-remaining", className: [isFlex ? 'flex flex-col gap-1' : 'px-2 flex items-stretch']
|
|
22425
22444
|
.concat(cssWrapper)
|
|
22426
22445
|
.join(' '), children: [jsxs("div", { className: "flex flex-row gap-2 items-center justify-center", children: [props.error && jsx(ErrorMsg, { error: props.error }), jsxs("div", { className: `w-full flex flex-col ${isFlex ? '' : 'items-center'}`, children: [!isFlex &&
|
|
22427
|
-
(typeof props.balance === 'number' ? (jsx("div", { className: "font-mono px-1", "data-testid": "billing-balance", children: jsx(BillingBalance, { amount: props.balance }) })) : (jsx(Spinner, { className: "text-inherit w-4 h-4" }))), props.balance !== Number.POSITIVE_INFINITY && (jsx("div", { className: [isFlex ? 'flex-grow' : 'min-w-10 w-full'].join(' '), children: jsx(ProgressBar, { max: props.allowance ?? 1, value: props.balance ?? 0 }) }))] }), !isFlex && (hasPaymentMethod || Number(totalDue.toString()) > 0) && (jsx(TotalDue, { amount: totalDue.toString() }))] }), isFlex && (jsx("div", { className: "flex flex-row gap-1 text-chalkboard-90", children: typeof props.balance === 'number' ? (props.balance !== Number.POSITIVE_INFINITY ? (jsxs(Fragment, { children: [getBalanceString(props.balance), " of Zookeeper reasoning time remaining this month"] })) : null) : (jsxs(Fragment, { children: [jsx(Spinner, { className: "text-inherit w-4 h-4" }), ' ', jsx("span", { children: "Fetching remaining balance..." })] })) }))] }));
|
|
22446
|
+
(typeof props.balance === 'number' ? (jsx("div", { className: "font-mono px-1", "data-testid": "billing-balance", children: jsx(BillingBalance, { amount: props.balance }) })) : (showSpinner && jsx(Spinner, { className: "text-inherit w-4 h-4" }))), props.balance !== Number.POSITIVE_INFINITY && (jsx("div", { className: [isFlex ? 'flex-grow' : 'min-w-10 w-full'].join(' '), children: jsx(ProgressBar, { max: props.allowance ?? 1, value: props.balance ?? 0 }) }))] }), !isFlex && (hasPaymentMethod || Number(totalDue.toString()) > 0) && (jsx(TotalDue, { amount: totalDue.toString() }))] }), isFlex && (jsx("div", { className: "flex flex-row gap-1 text-chalkboard-90", children: typeof props.balance === 'number' ? (props.balance !== Number.POSITIVE_INFINITY ? (jsxs(Fragment, { children: [getBalanceString(props.balance), " of Zookeeper reasoning time remaining this month"] })) : null) : (jsxs(Fragment, { children: [showSpinner && jsx(Spinner, { className: "text-inherit w-4 h-4" }), ' ', jsx("span", { children: "Fetching remaining balance..." })] })) }))] }));
|
|
22428
22447
|
};
|
|
22429
22448
|
|
|
22430
22449
|
const SITE = 'https://zoo.dev';
|