@schematichq/schematic-components 0.3.2 → 0.3.4
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/schematic-components.cjs.js +169 -219
- package/dist/schematic-components.d.ts +5 -0
- package/dist/schematic-components.esm.js +136 -199
- package/package.json +1 -1
|
@@ -1201,11 +1201,11 @@ var require_pluralize = __commonJS({
|
|
|
1201
1201
|
});
|
|
1202
1202
|
|
|
1203
1203
|
// src/components/elements/plan-manager/PaymentForm.tsx
|
|
1204
|
-
import { useState as
|
|
1204
|
+
import { useState as useState3 } from "react";
|
|
1205
1205
|
import { PaymentElement } from "@stripe/react-stripe-js";
|
|
1206
1206
|
import { useStripe, useElements } from "@stripe/react-stripe-js";
|
|
1207
1207
|
|
|
1208
|
-
// src/hooks/
|
|
1208
|
+
// src/hooks/useEmbed.ts
|
|
1209
1209
|
import { useContext } from "react";
|
|
1210
1210
|
|
|
1211
1211
|
// src/context/embed.tsx
|
|
@@ -8673,7 +8673,7 @@ var EmbedProvider = ({
|
|
|
8673
8673
|
useEffect(() => {
|
|
8674
8674
|
if (accessToken) {
|
|
8675
8675
|
const { headers = {} } = apiConfig ?? {};
|
|
8676
|
-
headers["X-Schematic-Components-Version"] = "0.3.
|
|
8676
|
+
headers["X-Schematic-Components-Version"] = "0.3.4";
|
|
8677
8677
|
headers["X-Schematic-Session-ID"] = sessionIdRef.current;
|
|
8678
8678
|
const config = new Configuration({
|
|
8679
8679
|
...apiConfig,
|
|
@@ -8723,9 +8723,12 @@ var EmbedProvider = ({
|
|
|
8723
8723
|
);
|
|
8724
8724
|
};
|
|
8725
8725
|
|
|
8726
|
-
// src/hooks/
|
|
8726
|
+
// src/hooks/useEmbed.ts
|
|
8727
8727
|
var useEmbed = () => useContext(EmbedContext);
|
|
8728
8728
|
|
|
8729
|
+
// src/hooks/useIsLightBackground.ts
|
|
8730
|
+
import { useMemo } from "react";
|
|
8731
|
+
|
|
8729
8732
|
// src/utils/color.ts
|
|
8730
8733
|
function hexToHSL(color) {
|
|
8731
8734
|
let r2 = 0;
|
|
@@ -8896,6 +8899,43 @@ attr.rem = function propAsRem(key, value) {
|
|
|
8896
8899
|
`;
|
|
8897
8900
|
};
|
|
8898
8901
|
|
|
8902
|
+
// src/hooks/useIsLightBackground.ts
|
|
8903
|
+
function useIsLightBackground() {
|
|
8904
|
+
const theme = nt();
|
|
8905
|
+
const isLightBackground = useMemo(() => {
|
|
8906
|
+
return hexToHSL(theme.card.background).l > 50;
|
|
8907
|
+
}, [theme.card.background]);
|
|
8908
|
+
return isLightBackground;
|
|
8909
|
+
}
|
|
8910
|
+
|
|
8911
|
+
// src/hooks/useWrapChildren.ts
|
|
8912
|
+
import { useLayoutEffect, useState as useState2 } from "react";
|
|
8913
|
+
function useWrapChildren(elements) {
|
|
8914
|
+
const [shouldWrap, setShouldWrap] = useState2(
|
|
8915
|
+
new Array(elements.length).fill(false)
|
|
8916
|
+
);
|
|
8917
|
+
useLayoutEffect(() => {
|
|
8918
|
+
const rowShouldWrap = (parent) => [...parent.children].some(
|
|
8919
|
+
(el) => el instanceof HTMLElement && el.previousElementSibling instanceof HTMLElement && el.offsetLeft <= el.previousElementSibling.offsetLeft
|
|
8920
|
+
);
|
|
8921
|
+
elements.forEach((el, idx) => {
|
|
8922
|
+
new ResizeObserver((entries) => {
|
|
8923
|
+
setShouldWrap((prev2) => {
|
|
8924
|
+
const next2 = [...prev2];
|
|
8925
|
+
next2[idx] = entries.some((entry) => rowShouldWrap(entry.target));
|
|
8926
|
+
return next2;
|
|
8927
|
+
});
|
|
8928
|
+
}).observe(el);
|
|
8929
|
+
setShouldWrap((prev2) => {
|
|
8930
|
+
const next2 = [...prev2];
|
|
8931
|
+
next2[idx] = rowShouldWrap(el);
|
|
8932
|
+
return next2;
|
|
8933
|
+
});
|
|
8934
|
+
});
|
|
8935
|
+
}, [elements]);
|
|
8936
|
+
return shouldWrap.some((wrap) => wrap === true);
|
|
8937
|
+
}
|
|
8938
|
+
|
|
8899
8939
|
// src/components/ui/box/styles.ts
|
|
8900
8940
|
var Box = dt.div((props) => {
|
|
8901
8941
|
const initialStyles = [];
|
|
@@ -9167,13 +9207,13 @@ var IconRound = ({
|
|
|
9167
9207
|
};
|
|
9168
9208
|
|
|
9169
9209
|
// src/components/ui/modal/Modal.tsx
|
|
9170
|
-
import { useCallback as useCallback2, useEffect as useEffect2, useMemo, useRef as useRef2 } from "react";
|
|
9210
|
+
import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2 } from "react";
|
|
9171
9211
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
9172
9212
|
var Modal = ({ children, size = "auto", onClose }) => {
|
|
9173
9213
|
const theme = nt();
|
|
9174
9214
|
const { setLayout } = useEmbed();
|
|
9175
9215
|
const ref = useRef2(null);
|
|
9176
|
-
const isLightBackground =
|
|
9216
|
+
const isLightBackground = useMemo2(() => {
|
|
9177
9217
|
return hexToHSL(theme.card.background).l > 50;
|
|
9178
9218
|
}, [theme.card.background]);
|
|
9179
9219
|
const handleClose = useCallback2(() => {
|
|
@@ -9240,7 +9280,7 @@ var Modal = ({ children, size = "auto", onClose }) => {
|
|
|
9240
9280
|
};
|
|
9241
9281
|
|
|
9242
9282
|
// src/components/ui/modal/ModalHeader.tsx
|
|
9243
|
-
import { useCallback as useCallback3, useMemo as
|
|
9283
|
+
import { useCallback as useCallback3, useMemo as useMemo3 } from "react";
|
|
9244
9284
|
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
9245
9285
|
var ModalHeader = ({
|
|
9246
9286
|
children,
|
|
@@ -9249,7 +9289,7 @@ var ModalHeader = ({
|
|
|
9249
9289
|
}) => {
|
|
9250
9290
|
const theme = nt();
|
|
9251
9291
|
const { setLayout } = useEmbed();
|
|
9252
|
-
const isLightBackground =
|
|
9292
|
+
const isLightBackground = useMemo3(() => {
|
|
9253
9293
|
return hexToHSL(theme.card.background).l > 50;
|
|
9254
9294
|
}, [theme.card.background]);
|
|
9255
9295
|
const handleClose = useCallback3(() => {
|
|
@@ -9490,9 +9530,9 @@ var PaymentForm = ({ onConfirm }) => {
|
|
|
9490
9530
|
const stripe = useStripe();
|
|
9491
9531
|
const elements = useElements();
|
|
9492
9532
|
const { api } = useEmbed();
|
|
9493
|
-
const [message, setMessage] =
|
|
9494
|
-
const [isLoading, setIsLoading] =
|
|
9495
|
-
const [isConfirmed, setIsConfirmed] =
|
|
9533
|
+
const [message, setMessage] = useState3(null);
|
|
9534
|
+
const [isLoading, setIsLoading] = useState3(false);
|
|
9535
|
+
const [isConfirmed, setIsConfirmed] = useState3(false);
|
|
9496
9536
|
const handleSubmit = async (event) => {
|
|
9497
9537
|
event.preventDefault();
|
|
9498
9538
|
if (!api || !stripe || !elements) {
|
|
@@ -9553,7 +9593,7 @@ var PaymentForm = ({ onConfirm }) => {
|
|
|
9553
9593
|
};
|
|
9554
9594
|
|
|
9555
9595
|
// src/components/elements/plan-manager/PlanManager.tsx
|
|
9556
|
-
import { forwardRef as forwardRef6, useMemo as
|
|
9596
|
+
import { forwardRef as forwardRef6, useMemo as useMemo6 } from "react";
|
|
9557
9597
|
import { createPortal as createPortal2 } from "react-dom";
|
|
9558
9598
|
|
|
9559
9599
|
// src/components/layout/root/Root.tsx
|
|
@@ -9564,6 +9604,7 @@ var Root = forwardRef(
|
|
|
9564
9604
|
return /* @__PURE__ */ jsx9("div", { ref, ...props });
|
|
9565
9605
|
}
|
|
9566
9606
|
);
|
|
9607
|
+
Root.displayName = "Root";
|
|
9567
9608
|
|
|
9568
9609
|
// src/components/layout/viewport/Viewport.tsx
|
|
9569
9610
|
import { forwardRef as forwardRef2 } from "react";
|
|
@@ -9579,7 +9620,7 @@ var StyledViewport = dt.div`
|
|
|
9579
9620
|
`;
|
|
9580
9621
|
|
|
9581
9622
|
// src/components/layout/RenderLayout.tsx
|
|
9582
|
-
import { useEffect as useEffect3, useState as
|
|
9623
|
+
import { useEffect as useEffect3, useState as useState4 } from "react";
|
|
9583
9624
|
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
9584
9625
|
var Disabled = () => {
|
|
9585
9626
|
const theme = nt();
|
|
@@ -9621,7 +9662,7 @@ var Disabled = () => {
|
|
|
9621
9662
|
var Success = () => {
|
|
9622
9663
|
const theme = nt();
|
|
9623
9664
|
const { hydrate, data, api, setLayout, isPending } = useEmbed();
|
|
9624
|
-
const [isOpen, setIsOpen] =
|
|
9665
|
+
const [isOpen, setIsOpen] = useState4(true);
|
|
9625
9666
|
useEffect3(() => {
|
|
9626
9667
|
if (api && data.component?.id) {
|
|
9627
9668
|
hydrate();
|
|
@@ -9704,6 +9745,7 @@ var Viewport = forwardRef2(
|
|
|
9704
9745
|
);
|
|
9705
9746
|
}
|
|
9706
9747
|
);
|
|
9748
|
+
Viewport.displayName = "Viewport";
|
|
9707
9749
|
|
|
9708
9750
|
// src/components/layout/column/Column.tsx
|
|
9709
9751
|
import { forwardRef as forwardRef4 } from "react";
|
|
@@ -9778,6 +9820,7 @@ var Card = forwardRef3(
|
|
|
9778
9820
|
);
|
|
9779
9821
|
}
|
|
9780
9822
|
);
|
|
9823
|
+
Card.displayName = "Card";
|
|
9781
9824
|
|
|
9782
9825
|
// src/components/layout/column/styles.ts
|
|
9783
9826
|
var StyledColumn = dt.div`
|
|
@@ -9793,15 +9836,10 @@ var Column = forwardRef4(
|
|
|
9793
9836
|
return /* @__PURE__ */ jsx13(StyledColumn, { ref, ...props, children: /* @__PURE__ */ jsx13(Card, { children }) });
|
|
9794
9837
|
}
|
|
9795
9838
|
);
|
|
9839
|
+
Column.displayName = "Column";
|
|
9796
9840
|
|
|
9797
9841
|
// src/components/elements/plan-manager/CheckoutDialog.tsx
|
|
9798
|
-
import {
|
|
9799
|
-
useCallback as useCallback5,
|
|
9800
|
-
useEffect as useEffect5,
|
|
9801
|
-
useLayoutEffect as useLayoutEffect2,
|
|
9802
|
-
useMemo as useMemo4,
|
|
9803
|
-
useState as useState5
|
|
9804
|
-
} from "react";
|
|
9842
|
+
import { useCallback as useCallback5, useEffect as useEffect5, useMemo as useMemo5, useState as useState6 } from "react";
|
|
9805
9843
|
var import_pluralize = __toESM(require_pluralize());
|
|
9806
9844
|
|
|
9807
9845
|
// node_modules/@stripe/stripe-js/dist/index.mjs
|
|
@@ -9836,7 +9874,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
|
|
|
9836
9874
|
}
|
|
9837
9875
|
stripe._registerWrapper({
|
|
9838
9876
|
name: "stripe-js",
|
|
9839
|
-
version: "4.
|
|
9877
|
+
version: "4.7.0",
|
|
9840
9878
|
startTime
|
|
9841
9879
|
});
|
|
9842
9880
|
};
|
|
@@ -9942,14 +9980,7 @@ var loadStripe = function loadStripe2() {
|
|
|
9942
9980
|
import { Elements as Elements2 } from "@stripe/react-stripe-js";
|
|
9943
9981
|
|
|
9944
9982
|
// src/components/elements/payment-method/PaymentMethod.tsx
|
|
9945
|
-
import {
|
|
9946
|
-
forwardRef as forwardRef5,
|
|
9947
|
-
useCallback as useCallback4,
|
|
9948
|
-
useEffect as useEffect4,
|
|
9949
|
-
useLayoutEffect,
|
|
9950
|
-
useMemo as useMemo3,
|
|
9951
|
-
useState as useState4
|
|
9952
|
-
} from "react";
|
|
9983
|
+
import { forwardRef as forwardRef5, useCallback as useCallback4, useEffect as useEffect4, useMemo as useMemo4, useState as useState5 } from "react";
|
|
9953
9984
|
import { createPortal } from "react-dom";
|
|
9954
9985
|
import { Elements } from "@stripe/react-stripe-js";
|
|
9955
9986
|
import { Fragment, jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
@@ -9973,7 +10004,7 @@ var PaymentMethodElement = ({
|
|
|
9973
10004
|
...props
|
|
9974
10005
|
}) => {
|
|
9975
10006
|
const theme = nt();
|
|
9976
|
-
const isLightBackground =
|
|
10007
|
+
const isLightBackground = useMemo4(() => {
|
|
9977
10008
|
return hexToHSL(theme.card.background).l > 50;
|
|
9978
10009
|
}, [theme.card.background]);
|
|
9979
10010
|
const sizeFactor = size === "lg" ? 2 : size === "md" ? 1 : 0.5;
|
|
@@ -10030,17 +10061,17 @@ var PaymentMethod = forwardRef5(({ children, className, portal, ...rest }, ref)
|
|
|
10030
10061
|
const props = resolveDesignProps(rest);
|
|
10031
10062
|
const theme = nt();
|
|
10032
10063
|
const { api, data, layout, setLayout } = useEmbed();
|
|
10033
|
-
const [isLoading, setIsLoading] =
|
|
10034
|
-
const [error, setError] =
|
|
10035
|
-
const [showPaymentForm, setShowPaymentForm] =
|
|
10064
|
+
const [isLoading, setIsLoading] = useState5(false);
|
|
10065
|
+
const [error, setError] = useState5();
|
|
10066
|
+
const [showPaymentForm, setShowPaymentForm] = useState5(
|
|
10036
10067
|
() => typeof data.subscription?.paymentMethod === "undefined"
|
|
10037
10068
|
);
|
|
10038
|
-
const [stripe, setStripe] =
|
|
10039
|
-
const [setupIntent, setSetupIntent] =
|
|
10040
|
-
const isLightBackground =
|
|
10069
|
+
const [stripe, setStripe] = useState5(null);
|
|
10070
|
+
const [setupIntent, setSetupIntent] = useState5();
|
|
10071
|
+
const isLightBackground = useMemo4(() => {
|
|
10041
10072
|
return hexToHSL(theme.card.background).l > 50;
|
|
10042
10073
|
}, [theme.card.background]);
|
|
10043
|
-
const paymentMethod =
|
|
10074
|
+
const paymentMethod = useMemo4(() => {
|
|
10044
10075
|
const { paymentMethodType, cardLast4, cardExpMonth, cardExpYear } = data.subscription?.paymentMethod || {};
|
|
10045
10076
|
let monthsToExpiration;
|
|
10046
10077
|
if (typeof cardExpYear === "number" && typeof cardExpMonth === "number") {
|
|
@@ -10103,12 +10134,12 @@ var PaymentMethod = forwardRef5(({ children, className, portal, ...rest }, ref)
|
|
|
10103
10134
|
setStripe(loadStripe(setupIntent.publishableKey));
|
|
10104
10135
|
}
|
|
10105
10136
|
}, [stripe, setupIntent?.publishableKey]);
|
|
10106
|
-
|
|
10107
|
-
document.body.style.overflow = "hidden";
|
|
10137
|
+
useEffect4(() => {
|
|
10138
|
+
document.body.style.overflow = layout === "payment" ? "hidden" : "";
|
|
10108
10139
|
return () => {
|
|
10109
10140
|
document.body.style.overflow = "";
|
|
10110
10141
|
};
|
|
10111
|
-
}, []);
|
|
10142
|
+
}, [layout]);
|
|
10112
10143
|
if (!paymentMethod.paymentMethodType) {
|
|
10113
10144
|
return null;
|
|
10114
10145
|
}
|
|
@@ -10220,6 +10251,7 @@ var PaymentMethod = forwardRef5(({ children, className, portal, ...rest }, ref)
|
|
|
10220
10251
|
)
|
|
10221
10252
|
] });
|
|
10222
10253
|
});
|
|
10254
|
+
PaymentMethod.displayName = "PaymentMethod";
|
|
10223
10255
|
|
|
10224
10256
|
// src/components/ui/tooltip/styles.ts
|
|
10225
10257
|
var TooltipWrapper = dt.div`
|
|
@@ -10277,6 +10309,7 @@ var FeatureName = ({
|
|
|
10277
10309
|
let period;
|
|
10278
10310
|
if (entitlement.metricPeriod) {
|
|
10279
10311
|
period = {
|
|
10312
|
+
billing: "billing period",
|
|
10280
10313
|
current_day: "day",
|
|
10281
10314
|
current_month: "month",
|
|
10282
10315
|
current_year: "year"
|
|
@@ -10310,23 +10343,23 @@ var FeatureName = ({
|
|
|
10310
10343
|
var CheckoutDialog = () => {
|
|
10311
10344
|
const theme = nt();
|
|
10312
10345
|
const { api, data, setLayout } = useEmbed();
|
|
10313
|
-
const [checkoutStage, setCheckoutStage] =
|
|
10346
|
+
const [checkoutStage, setCheckoutStage] = useState6(
|
|
10314
10347
|
"plan"
|
|
10315
10348
|
);
|
|
10316
|
-
const [planPeriod, setPlanPeriod] =
|
|
10349
|
+
const [planPeriod, setPlanPeriod] = useState6(
|
|
10317
10350
|
() => data.company?.plan?.planPeriod || "month"
|
|
10318
10351
|
);
|
|
10319
|
-
const [selectedPlan, setSelectedPlan] =
|
|
10320
|
-
const [charges, setCharges] =
|
|
10321
|
-
const [paymentMethodId, setPaymentMethodId] =
|
|
10322
|
-
const [isLoading, setIsLoading] =
|
|
10323
|
-
const [error, setError] =
|
|
10324
|
-
const [showPaymentForm, setShowPaymentForm] =
|
|
10352
|
+
const [selectedPlan, setSelectedPlan] = useState6();
|
|
10353
|
+
const [charges, setCharges] = useState6();
|
|
10354
|
+
const [paymentMethodId, setPaymentMethodId] = useState6();
|
|
10355
|
+
const [isLoading, setIsLoading] = useState6(false);
|
|
10356
|
+
const [error, setError] = useState6();
|
|
10357
|
+
const [showPaymentForm, setShowPaymentForm] = useState6(
|
|
10325
10358
|
() => typeof data.subscription?.paymentMethod === "undefined"
|
|
10326
10359
|
);
|
|
10327
|
-
const [stripe, setStripe] =
|
|
10328
|
-
const [setupIntent, setSetupIntent] =
|
|
10329
|
-
const { paymentMethod, currentPlan, availablePlans, planPeriodOptions } =
|
|
10360
|
+
const [stripe, setStripe] = useState6(null);
|
|
10361
|
+
const [setupIntent, setSetupIntent] = useState6();
|
|
10362
|
+
const { paymentMethod, currentPlan, availablePlans, planPeriodOptions } = useMemo5(() => {
|
|
10330
10363
|
const showMonthlyPriceOption = data.activePlans.some(
|
|
10331
10364
|
(plan) => typeof plan.yearlyPrice !== "undefined"
|
|
10332
10365
|
);
|
|
@@ -10347,7 +10380,7 @@ var CheckoutDialog = () => {
|
|
|
10347
10380
|
planPeriodOptions: planPeriodOptions2
|
|
10348
10381
|
};
|
|
10349
10382
|
}, [data.subscription?.paymentMethod, data.company, data.activePlans]);
|
|
10350
|
-
const savingsPercentage =
|
|
10383
|
+
const savingsPercentage = useMemo5(() => {
|
|
10351
10384
|
if (selectedPlan) {
|
|
10352
10385
|
const monthly = (selectedPlan?.monthlyPrice?.price || 0) * 12;
|
|
10353
10386
|
const yearly = selectedPlan?.yearlyPrice?.price || 0;
|
|
@@ -10355,7 +10388,7 @@ var CheckoutDialog = () => {
|
|
|
10355
10388
|
}
|
|
10356
10389
|
return 0;
|
|
10357
10390
|
}, [selectedPlan]);
|
|
10358
|
-
const subscriptionPrice =
|
|
10391
|
+
const subscriptionPrice = useMemo5(() => {
|
|
10359
10392
|
if (!selectedPlan || !selectedPlan.monthlyPrice || !selectedPlan.yearlyPrice) {
|
|
10360
10393
|
return;
|
|
10361
10394
|
}
|
|
@@ -10363,7 +10396,7 @@ var CheckoutDialog = () => {
|
|
|
10363
10396
|
(planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price
|
|
10364
10397
|
);
|
|
10365
10398
|
}, [selectedPlan, planPeriod]);
|
|
10366
|
-
const isLightBackground =
|
|
10399
|
+
const isLightBackground = useMemo5(() => {
|
|
10367
10400
|
return hexToHSL(theme.card.background).l > 50;
|
|
10368
10401
|
}, [theme.card.background]);
|
|
10369
10402
|
const selectPlan = useCallback5(
|
|
@@ -10431,7 +10464,7 @@ var CheckoutDialog = () => {
|
|
|
10431
10464
|
setStripe(loadStripe(setupIntent.publishableKey));
|
|
10432
10465
|
}
|
|
10433
10466
|
}, [stripe, setupIntent?.publishableKey]);
|
|
10434
|
-
|
|
10467
|
+
useEffect5(() => {
|
|
10435
10468
|
document.body.style.overflow = "hidden";
|
|
10436
10469
|
return () => {
|
|
10437
10470
|
document.body.style.overflow = "";
|
|
@@ -11284,7 +11317,7 @@ var PlanManager = forwardRef6(({ children, className, portal, ...rest }, ref) =>
|
|
|
11284
11317
|
const props = resolveDesignProps2(rest);
|
|
11285
11318
|
const theme = nt();
|
|
11286
11319
|
const { data, layout, setLayout } = useEmbed();
|
|
11287
|
-
const { currentPlan, canChangePlan } =
|
|
11320
|
+
const { currentPlan, canChangePlan } = useMemo6(() => {
|
|
11288
11321
|
return {
|
|
11289
11322
|
currentPlan: data.company?.plan,
|
|
11290
11323
|
canChangePlan: data.activePlans.length > 0
|
|
@@ -11365,9 +11398,10 @@ var PlanManager = forwardRef6(({ children, className, portal, ...rest }, ref) =>
|
|
|
11365
11398
|
}
|
|
11366
11399
|
);
|
|
11367
11400
|
});
|
|
11401
|
+
PlanManager.displayName = "PlanManager";
|
|
11368
11402
|
|
|
11369
11403
|
// src/components/elements/included-features/IncludedFeatures.tsx
|
|
11370
|
-
import { forwardRef as forwardRef7,
|
|
11404
|
+
import { forwardRef as forwardRef7, useRef as useRef3 } from "react";
|
|
11371
11405
|
var import_pluralize2 = __toESM(require_pluralize());
|
|
11372
11406
|
import { Fragment as Fragment3, jsx as jsx18, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
11373
11407
|
function resolveDesignProps3(props) {
|
|
@@ -11397,64 +11431,8 @@ var IncludedFeatures = forwardRef7(({ className, ...rest }, ref) => {
|
|
|
11397
11431
|
const theme = nt();
|
|
11398
11432
|
const { data } = useEmbed();
|
|
11399
11433
|
const elements = useRef3([]);
|
|
11400
|
-
const
|
|
11401
|
-
|
|
11402
|
-
({
|
|
11403
|
-
access,
|
|
11404
|
-
allocation,
|
|
11405
|
-
allocationType,
|
|
11406
|
-
feature,
|
|
11407
|
-
period,
|
|
11408
|
-
usage = 0,
|
|
11409
|
-
...props2
|
|
11410
|
-
}) => {
|
|
11411
|
-
return {
|
|
11412
|
-
access,
|
|
11413
|
-
allocation,
|
|
11414
|
-
allocationType,
|
|
11415
|
-
feature,
|
|
11416
|
-
period,
|
|
11417
|
-
/**
|
|
11418
|
-
* @TODO: resolve feature price
|
|
11419
|
-
*/
|
|
11420
|
-
price: void 0,
|
|
11421
|
-
usage,
|
|
11422
|
-
...props2
|
|
11423
|
-
};
|
|
11424
|
-
}
|
|
11425
|
-
);
|
|
11426
|
-
}, [data.featureUsage]);
|
|
11427
|
-
const isLightBackground = useMemo6(() => {
|
|
11428
|
-
return hexToHSL(theme.card.background).l > 50;
|
|
11429
|
-
}, [theme.card.background]);
|
|
11430
|
-
useLayoutEffect3(() => {
|
|
11431
|
-
const assignRows = (parent) => {
|
|
11432
|
-
let isWrapped = true;
|
|
11433
|
-
[...parent.children].forEach((el) => {
|
|
11434
|
-
if (!(el instanceof HTMLElement)) {
|
|
11435
|
-
return;
|
|
11436
|
-
}
|
|
11437
|
-
if (!el.previousElementSibling || el.offsetLeft <= el.previousElementSibling.offsetLeft) {
|
|
11438
|
-
isWrapped = !isWrapped;
|
|
11439
|
-
}
|
|
11440
|
-
if (isWrapped) {
|
|
11441
|
-
el.style.textAlign = "left";
|
|
11442
|
-
} else if (el.previousElementSibling) {
|
|
11443
|
-
el.style.textAlign = "right";
|
|
11444
|
-
}
|
|
11445
|
-
});
|
|
11446
|
-
};
|
|
11447
|
-
elements.current.forEach((el) => {
|
|
11448
|
-
if (!el) return;
|
|
11449
|
-
const observer = new ResizeObserver((entries) => {
|
|
11450
|
-
entries.forEach((entry) => {
|
|
11451
|
-
assignRows(entry.target);
|
|
11452
|
-
});
|
|
11453
|
-
});
|
|
11454
|
-
observer.observe(el);
|
|
11455
|
-
assignRows(el);
|
|
11456
|
-
});
|
|
11457
|
-
}, [elements.current.length]);
|
|
11434
|
+
const shouldWrapChildren = useWrapChildren(elements.current);
|
|
11435
|
+
const isLightBackground = useIsLightBackground();
|
|
11458
11436
|
return /* @__PURE__ */ jsxs11(
|
|
11459
11437
|
Element,
|
|
11460
11438
|
{
|
|
@@ -11474,17 +11452,14 @@ var IncludedFeatures = forwardRef7(({ className, ...rest }, ref) => {
|
|
|
11474
11452
|
children: props.header.text
|
|
11475
11453
|
}
|
|
11476
11454
|
) }),
|
|
11477
|
-
features.reduce(
|
|
11478
|
-
(acc, { allocation,
|
|
11479
|
-
if (!allocationType) {
|
|
11480
|
-
return acc;
|
|
11481
|
-
}
|
|
11455
|
+
(data.featureUsage?.features || []).reduce(
|
|
11456
|
+
(acc, { allocation, feature, usage }, index) => {
|
|
11482
11457
|
return [
|
|
11483
11458
|
...acc,
|
|
11484
11459
|
/* @__PURE__ */ jsxs11(
|
|
11485
11460
|
Flex,
|
|
11486
11461
|
{
|
|
11487
|
-
ref: (el) => elements.current.push(el),
|
|
11462
|
+
ref: (el) => el && elements.current.push(el),
|
|
11488
11463
|
$flexWrap: "wrap",
|
|
11489
11464
|
$justifyContent: "space-between",
|
|
11490
11465
|
$alignItems: "center",
|
|
@@ -11513,12 +11488,12 @@ var IncludedFeatures = forwardRef7(({ className, ...rest }, ref) => {
|
|
|
11513
11488
|
}
|
|
11514
11489
|
) })
|
|
11515
11490
|
] }),
|
|
11516
|
-
(
|
|
11491
|
+
(feature?.featureType === "event" || feature?.featureType === "trait") && feature?.name && /* @__PURE__ */ jsxs11(
|
|
11517
11492
|
Box,
|
|
11518
11493
|
{
|
|
11519
11494
|
$flexBasis: "min-content",
|
|
11520
11495
|
$flexGrow: "1",
|
|
11521
|
-
$textAlign: "right",
|
|
11496
|
+
$textAlign: shouldWrapChildren ? "left" : "right",
|
|
11522
11497
|
children: [
|
|
11523
11498
|
props.entitlement.isVisible && /* @__PURE__ */ jsx18(Box, { children: /* @__PURE__ */ jsx18(
|
|
11524
11499
|
Text,
|
|
@@ -11557,9 +11532,10 @@ var IncludedFeatures = forwardRef7(({ className, ...rest }, ref) => {
|
|
|
11557
11532
|
}
|
|
11558
11533
|
);
|
|
11559
11534
|
});
|
|
11535
|
+
IncludedFeatures.displayName = "IncludedFeatures";
|
|
11560
11536
|
|
|
11561
11537
|
// src/components/elements/metered-features/MeteredFeatures.tsx
|
|
11562
|
-
import { forwardRef as forwardRef8,
|
|
11538
|
+
import { forwardRef as forwardRef8, useRef as useRef4 } from "react";
|
|
11563
11539
|
var import_pluralize3 = __toESM(require_pluralize());
|
|
11564
11540
|
import { jsx as jsx19, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
11565
11541
|
function resolveDesignProps4(props) {
|
|
@@ -11582,75 +11558,20 @@ function resolveDesignProps4(props) {
|
|
|
11582
11558
|
usage: {
|
|
11583
11559
|
isVisible: props.usage?.isVisible ?? true,
|
|
11584
11560
|
fontStyle: props.usage?.fontStyle ?? "heading5"
|
|
11585
|
-
}
|
|
11561
|
+
},
|
|
11562
|
+
visibleFeatures: props.visibleFeatures ?? []
|
|
11586
11563
|
};
|
|
11587
11564
|
}
|
|
11588
11565
|
var MeteredFeatures = forwardRef8(({ className, ...rest }, ref) => {
|
|
11589
11566
|
const props = resolveDesignProps4(rest);
|
|
11567
|
+
const elements = useRef4([]);
|
|
11568
|
+
const shouldWrapChildren = useWrapChildren(elements.current);
|
|
11590
11569
|
const theme = nt();
|
|
11591
11570
|
const { data } = useEmbed();
|
|
11592
|
-
const
|
|
11593
|
-
|
|
11594
|
-
|
|
11595
|
-
({
|
|
11596
|
-
access,
|
|
11597
|
-
allocation,
|
|
11598
|
-
allocationType,
|
|
11599
|
-
feature,
|
|
11600
|
-
period,
|
|
11601
|
-
usage,
|
|
11602
|
-
...props2
|
|
11603
|
-
}) => {
|
|
11604
|
-
return {
|
|
11605
|
-
access,
|
|
11606
|
-
allocation,
|
|
11607
|
-
allocationType,
|
|
11608
|
-
feature,
|
|
11609
|
-
period,
|
|
11610
|
-
/**
|
|
11611
|
-
* @TODO: resolve feature price
|
|
11612
|
-
*/
|
|
11613
|
-
price: void 0,
|
|
11614
|
-
usage,
|
|
11615
|
-
...props2
|
|
11616
|
-
};
|
|
11617
|
-
}
|
|
11618
|
-
);
|
|
11619
|
-
}, [data.featureUsage]);
|
|
11620
|
-
const isLightBackground = useMemo7(() => {
|
|
11621
|
-
return hexToHSL(theme.card.background).l > 50;
|
|
11622
|
-
}, [theme.card.background]);
|
|
11623
|
-
useLayoutEffect4(() => {
|
|
11624
|
-
const assignRows = (parent) => {
|
|
11625
|
-
let isWrapped = true;
|
|
11626
|
-
[...parent.children].forEach((el) => {
|
|
11627
|
-
if (!(el instanceof HTMLElement)) {
|
|
11628
|
-
return;
|
|
11629
|
-
}
|
|
11630
|
-
if (!el.previousElementSibling || el.offsetLeft <= el.previousElementSibling.offsetLeft) {
|
|
11631
|
-
isWrapped = !isWrapped;
|
|
11632
|
-
}
|
|
11633
|
-
if (isWrapped) {
|
|
11634
|
-
el.style.textAlign = "left";
|
|
11635
|
-
} else if (el.previousElementSibling) {
|
|
11636
|
-
el.style.textAlign = "right";
|
|
11637
|
-
}
|
|
11638
|
-
});
|
|
11639
|
-
};
|
|
11640
|
-
elements.current.forEach((el) => {
|
|
11641
|
-
if (!el) return;
|
|
11642
|
-
const observer = new ResizeObserver((entries) => {
|
|
11643
|
-
entries.forEach((entry) => {
|
|
11644
|
-
assignRows(entry.target);
|
|
11645
|
-
});
|
|
11646
|
-
});
|
|
11647
|
-
observer.observe(el);
|
|
11648
|
-
assignRows(el);
|
|
11649
|
-
});
|
|
11650
|
-
}, [elements.current.length]);
|
|
11651
|
-
return /* @__PURE__ */ jsx19(Flex, { ref, className, $flexDirection: "column", children: features.reduce(
|
|
11652
|
-
(acc, { allocation, allocationType, feature, usage }, index) => {
|
|
11653
|
-
if (allocationType !== "numeric") {
|
|
11571
|
+
const isLightBackground = useIsLightBackground();
|
|
11572
|
+
return /* @__PURE__ */ jsx19(Flex, { ref, className, $flexDirection: "column", children: props.visibleFeatures.length > 0 ? (data.featureUsage?.features || []).reduce(
|
|
11573
|
+
(acc, { allocation, feature, usage }, index) => {
|
|
11574
|
+
if (feature?.id && !props.visibleFeatures?.includes(feature.id) || feature?.featureType !== "event" && feature?.featureType !== "trait") {
|
|
11654
11575
|
return acc;
|
|
11655
11576
|
}
|
|
11656
11577
|
return [
|
|
@@ -11671,7 +11592,7 @@ var MeteredFeatures = forwardRef8(({ className, ...rest }, ref) => {
|
|
|
11671
11592
|
/* @__PURE__ */ jsxs12(
|
|
11672
11593
|
Flex,
|
|
11673
11594
|
{
|
|
11674
|
-
ref: (el) => elements.current.push(el),
|
|
11595
|
+
ref: (el) => el && elements.current.push(el),
|
|
11675
11596
|
$flexWrap: "wrap",
|
|
11676
11597
|
$gap: "1rem",
|
|
11677
11598
|
children: [
|
|
@@ -11699,12 +11620,12 @@ var MeteredFeatures = forwardRef8(({ className, ...rest }, ref) => {
|
|
|
11699
11620
|
}
|
|
11700
11621
|
)
|
|
11701
11622
|
] }),
|
|
11702
|
-
(
|
|
11623
|
+
(feature?.featureType === "event" || feature?.featureType === "trait") && feature?.name && /* @__PURE__ */ jsxs12(
|
|
11703
11624
|
Box,
|
|
11704
11625
|
{
|
|
11705
11626
|
$flexBasis: "min-content",
|
|
11706
11627
|
$flexGrow: "1",
|
|
11707
|
-
$textAlign: "right",
|
|
11628
|
+
$textAlign: shouldWrapChildren ? "left" : "right",
|
|
11708
11629
|
children: [
|
|
11709
11630
|
props.usage.isVisible && typeof usage === "number" && /* @__PURE__ */ jsxs12(
|
|
11710
11631
|
Text,
|
|
@@ -11757,11 +11678,22 @@ var MeteredFeatures = forwardRef8(({ className, ...rest }, ref) => {
|
|
|
11757
11678
|
];
|
|
11758
11679
|
},
|
|
11759
11680
|
[]
|
|
11760
|
-
)
|
|
11681
|
+
) : /* @__PURE__ */ jsx19(Element, { as: Flex, $justifyContent: "center", children: /* @__PURE__ */ jsx19(
|
|
11682
|
+
Text,
|
|
11683
|
+
{
|
|
11684
|
+
$font: theme.typography.heading1.fontFamily,
|
|
11685
|
+
$size: theme.typography.heading1.fontSize,
|
|
11686
|
+
$weight: theme.typography.heading1.fontWeight,
|
|
11687
|
+
$color: theme.typography.heading1.color,
|
|
11688
|
+
$align: "center",
|
|
11689
|
+
children: "No features selected"
|
|
11690
|
+
}
|
|
11691
|
+
) }) });
|
|
11761
11692
|
});
|
|
11693
|
+
MeteredFeatures.displayName = "MeteredFeatures";
|
|
11762
11694
|
|
|
11763
11695
|
// src/components/elements/upcoming-bill/UpcomingBill.tsx
|
|
11764
|
-
import { forwardRef as forwardRef9, useMemo as
|
|
11696
|
+
import { forwardRef as forwardRef9, useMemo as useMemo7 } from "react";
|
|
11765
11697
|
import { jsx as jsx20, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
11766
11698
|
function resolveDesignProps5(props) {
|
|
11767
11699
|
return {
|
|
@@ -11785,7 +11717,7 @@ var UpcomingBill = forwardRef9(({ className, ...rest }, ref) => {
|
|
|
11785
11717
|
const props = resolveDesignProps5(rest);
|
|
11786
11718
|
const theme = nt();
|
|
11787
11719
|
const { data } = useEmbed();
|
|
11788
|
-
const { upcomingInvoice } =
|
|
11720
|
+
const { upcomingInvoice } = useMemo7(() => {
|
|
11789
11721
|
return {
|
|
11790
11722
|
upcomingInvoice: {
|
|
11791
11723
|
...data.upcomingInvoice?.amountDue && {
|
|
@@ -11851,9 +11783,10 @@ var UpcomingBill = forwardRef9(({ className, ...rest }, ref) => {
|
|
|
11851
11783
|
] })
|
|
11852
11784
|
] });
|
|
11853
11785
|
});
|
|
11786
|
+
UpcomingBill.displayName = "UpcomingBill";
|
|
11854
11787
|
|
|
11855
11788
|
// src/components/elements/invoices/Invoices.tsx
|
|
11856
|
-
import { forwardRef as forwardRef10, useEffect as useEffect6, useState as
|
|
11789
|
+
import { forwardRef as forwardRef10, useEffect as useEffect6, useState as useState7 } from "react";
|
|
11857
11790
|
import { jsx as jsx21, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
11858
11791
|
function resolveDesignProps6(props) {
|
|
11859
11792
|
return {
|
|
@@ -11889,7 +11822,7 @@ var Invoices = forwardRef10(({ className, ...rest }, ref) => {
|
|
|
11889
11822
|
const props = resolveDesignProps6(rest);
|
|
11890
11823
|
const theme = nt();
|
|
11891
11824
|
const { api } = useEmbed();
|
|
11892
|
-
const [invoices, setInvoices] =
|
|
11825
|
+
const [invoices, setInvoices] = useState7(() => formatInvoices(rest.data));
|
|
11893
11826
|
useEffect6(() => {
|
|
11894
11827
|
api?.listInvoices().then(({ data }) => {
|
|
11895
11828
|
setInvoices(formatInvoices(data));
|
|
@@ -11948,9 +11881,10 @@ var Invoices = forwardRef10(({ className, ...rest }, ref) => {
|
|
|
11948
11881
|
] })
|
|
11949
11882
|
] }) });
|
|
11950
11883
|
});
|
|
11884
|
+
Invoices.displayName = "Invoices";
|
|
11951
11885
|
|
|
11952
11886
|
// src/components/embed/ComponentTree.tsx
|
|
11953
|
-
import { useEffect as useEffect7, useState as
|
|
11887
|
+
import { useEffect as useEffect7, useState as useState8, Children } from "react";
|
|
11954
11888
|
|
|
11955
11889
|
// src/components/embed/renderer.ts
|
|
11956
11890
|
import { createElement } from "react";
|
|
@@ -11961,6 +11895,7 @@ var components = {
|
|
|
11961
11895
|
Card,
|
|
11962
11896
|
PlanManager,
|
|
11963
11897
|
IncludedFeatures,
|
|
11898
|
+
MeteredFeatures,
|
|
11964
11899
|
UpcomingBill,
|
|
11965
11900
|
PaymentMethod
|
|
11966
11901
|
};
|
|
@@ -12052,7 +11987,7 @@ var Error2 = ({ message }) => {
|
|
|
12052
11987
|
};
|
|
12053
11988
|
var ComponentTree = () => {
|
|
12054
11989
|
const { error, nodes } = useEmbed();
|
|
12055
|
-
const [children, setChildren] =
|
|
11990
|
+
const [children, setChildren] = useState8(/* @__PURE__ */ jsx22(Loading, {}));
|
|
12056
11991
|
useEffect7(() => {
|
|
12057
11992
|
const renderer = createRenderer();
|
|
12058
11993
|
setChildren(nodes.map(renderer));
|
|
@@ -12105,7 +12040,9 @@ export {
|
|
|
12105
12040
|
Viewport,
|
|
12106
12041
|
defaultSettings,
|
|
12107
12042
|
defaultTheme,
|
|
12108
|
-
useEmbed
|
|
12043
|
+
useEmbed,
|
|
12044
|
+
useIsLightBackground,
|
|
12045
|
+
useWrapChildren
|
|
12109
12046
|
};
|
|
12110
12047
|
/*! Bundled license information:
|
|
12111
12048
|
|