@schematichq/schematic-components 0.3.3 → 0.3.5
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 +249 -313
- package/dist/schematic-components.d.ts +5 -0
- package/dist/schematic-components.esm.js +216 -293
- package/package.json +1 -1
|
@@ -1230,16 +1230,18 @@ __export(src_exports, {
|
|
|
1230
1230
|
Viewport: () => Viewport,
|
|
1231
1231
|
defaultSettings: () => defaultSettings,
|
|
1232
1232
|
defaultTheme: () => defaultTheme,
|
|
1233
|
-
useEmbed: () => useEmbed
|
|
1233
|
+
useEmbed: () => useEmbed,
|
|
1234
|
+
useIsLightBackground: () => useIsLightBackground,
|
|
1235
|
+
useWrapChildren: () => useWrapChildren
|
|
1234
1236
|
});
|
|
1235
1237
|
module.exports = __toCommonJS(src_exports);
|
|
1236
1238
|
|
|
1237
1239
|
// src/components/elements/plan-manager/PaymentForm.tsx
|
|
1238
|
-
var
|
|
1240
|
+
var import_react8 = require("react");
|
|
1239
1241
|
var import_react_stripe_js = require("@stripe/react-stripe-js");
|
|
1240
1242
|
var import_react_stripe_js2 = require("@stripe/react-stripe-js");
|
|
1241
1243
|
|
|
1242
|
-
// src/hooks/
|
|
1244
|
+
// src/hooks/useEmbed.ts
|
|
1243
1245
|
var import_react3 = require("react");
|
|
1244
1246
|
|
|
1245
1247
|
// src/context/embed.tsx
|
|
@@ -8707,7 +8709,7 @@ var EmbedProvider = ({
|
|
|
8707
8709
|
(0, import_react2.useEffect)(() => {
|
|
8708
8710
|
if (accessToken) {
|
|
8709
8711
|
const { headers = {} } = apiConfig ?? {};
|
|
8710
|
-
headers["X-Schematic-Components-Version"] = "0.3.
|
|
8712
|
+
headers["X-Schematic-Components-Version"] = "0.3.5";
|
|
8711
8713
|
headers["X-Schematic-Session-ID"] = sessionIdRef.current;
|
|
8712
8714
|
const config = new Configuration({
|
|
8713
8715
|
...apiConfig,
|
|
@@ -8757,9 +8759,12 @@ var EmbedProvider = ({
|
|
|
8757
8759
|
);
|
|
8758
8760
|
};
|
|
8759
8761
|
|
|
8760
|
-
// src/hooks/
|
|
8762
|
+
// src/hooks/useEmbed.ts
|
|
8761
8763
|
var useEmbed = () => (0, import_react3.useContext)(EmbedContext);
|
|
8762
8764
|
|
|
8765
|
+
// src/hooks/useIsLightBackground.ts
|
|
8766
|
+
var import_react4 = require("react");
|
|
8767
|
+
|
|
8763
8768
|
// src/utils/color.ts
|
|
8764
8769
|
function hexToHSL(color) {
|
|
8765
8770
|
let r2 = 0;
|
|
@@ -8930,6 +8935,43 @@ attr.rem = function propAsRem(key, value) {
|
|
|
8930
8935
|
`;
|
|
8931
8936
|
};
|
|
8932
8937
|
|
|
8938
|
+
// src/hooks/useIsLightBackground.ts
|
|
8939
|
+
function useIsLightBackground() {
|
|
8940
|
+
const theme = nt();
|
|
8941
|
+
const isLightBackground = (0, import_react4.useMemo)(() => {
|
|
8942
|
+
return hexToHSL(theme.card.background).l > 50;
|
|
8943
|
+
}, [theme.card.background]);
|
|
8944
|
+
return isLightBackground;
|
|
8945
|
+
}
|
|
8946
|
+
|
|
8947
|
+
// src/hooks/useWrapChildren.ts
|
|
8948
|
+
var import_react5 = require("react");
|
|
8949
|
+
function useWrapChildren(elements) {
|
|
8950
|
+
const [shouldWrap, setShouldWrap] = (0, import_react5.useState)(
|
|
8951
|
+
new Array(elements.length).fill(false)
|
|
8952
|
+
);
|
|
8953
|
+
(0, import_react5.useLayoutEffect)(() => {
|
|
8954
|
+
const rowShouldWrap = (parent) => [...parent.children].some(
|
|
8955
|
+
(el) => el instanceof HTMLElement && el.previousElementSibling instanceof HTMLElement && el.offsetLeft <= el.previousElementSibling.offsetLeft
|
|
8956
|
+
);
|
|
8957
|
+
elements.forEach((el, idx) => {
|
|
8958
|
+
new ResizeObserver((entries) => {
|
|
8959
|
+
setShouldWrap((prev2) => {
|
|
8960
|
+
const next2 = [...prev2];
|
|
8961
|
+
next2[idx] = entries.some((entry) => rowShouldWrap(entry.target));
|
|
8962
|
+
return next2;
|
|
8963
|
+
});
|
|
8964
|
+
}).observe(el);
|
|
8965
|
+
setShouldWrap((prev2) => {
|
|
8966
|
+
const next2 = [...prev2];
|
|
8967
|
+
next2[idx] = rowShouldWrap(el);
|
|
8968
|
+
return next2;
|
|
8969
|
+
});
|
|
8970
|
+
});
|
|
8971
|
+
}, [elements]);
|
|
8972
|
+
return shouldWrap.some((wrap) => wrap === true);
|
|
8973
|
+
}
|
|
8974
|
+
|
|
8933
8975
|
// src/components/ui/box/styles.ts
|
|
8934
8976
|
var Box = dt.div((props) => {
|
|
8935
8977
|
const initialStyles = [];
|
|
@@ -9201,20 +9243,20 @@ var IconRound = ({
|
|
|
9201
9243
|
};
|
|
9202
9244
|
|
|
9203
9245
|
// src/components/ui/modal/Modal.tsx
|
|
9204
|
-
var
|
|
9246
|
+
var import_react6 = require("react");
|
|
9205
9247
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
9206
9248
|
var Modal = ({ children, size = "auto", onClose }) => {
|
|
9207
9249
|
const theme = nt();
|
|
9208
9250
|
const { setLayout } = useEmbed();
|
|
9209
|
-
const ref = (0,
|
|
9210
|
-
const isLightBackground = (0,
|
|
9251
|
+
const ref = (0, import_react6.useRef)(null);
|
|
9252
|
+
const isLightBackground = (0, import_react6.useMemo)(() => {
|
|
9211
9253
|
return hexToHSL(theme.card.background).l > 50;
|
|
9212
9254
|
}, [theme.card.background]);
|
|
9213
|
-
const handleClose = (0,
|
|
9255
|
+
const handleClose = (0, import_react6.useCallback)(() => {
|
|
9214
9256
|
setLayout("portal");
|
|
9215
9257
|
onClose?.();
|
|
9216
9258
|
}, [setLayout, onClose]);
|
|
9217
|
-
(0,
|
|
9259
|
+
(0, import_react6.useEffect)(() => {
|
|
9218
9260
|
ref.current?.focus();
|
|
9219
9261
|
}, []);
|
|
9220
9262
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
@@ -9274,7 +9316,7 @@ var Modal = ({ children, size = "auto", onClose }) => {
|
|
|
9274
9316
|
};
|
|
9275
9317
|
|
|
9276
9318
|
// src/components/ui/modal/ModalHeader.tsx
|
|
9277
|
-
var
|
|
9319
|
+
var import_react7 = require("react");
|
|
9278
9320
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
9279
9321
|
var ModalHeader = ({
|
|
9280
9322
|
children,
|
|
@@ -9283,10 +9325,10 @@ var ModalHeader = ({
|
|
|
9283
9325
|
}) => {
|
|
9284
9326
|
const theme = nt();
|
|
9285
9327
|
const { setLayout } = useEmbed();
|
|
9286
|
-
const isLightBackground = (0,
|
|
9328
|
+
const isLightBackground = (0, import_react7.useMemo)(() => {
|
|
9287
9329
|
return hexToHSL(theme.card.background).l > 50;
|
|
9288
9330
|
}, [theme.card.background]);
|
|
9289
|
-
const handleClose = (0,
|
|
9331
|
+
const handleClose = (0, import_react7.useCallback)(() => {
|
|
9290
9332
|
setLayout("portal");
|
|
9291
9333
|
onClose?.();
|
|
9292
9334
|
}, [setLayout, onClose]);
|
|
@@ -9524,9 +9566,9 @@ var PaymentForm = ({ onConfirm }) => {
|
|
|
9524
9566
|
const stripe = (0, import_react_stripe_js2.useStripe)();
|
|
9525
9567
|
const elements = (0, import_react_stripe_js2.useElements)();
|
|
9526
9568
|
const { api } = useEmbed();
|
|
9527
|
-
const [message, setMessage] = (0,
|
|
9528
|
-
const [isLoading, setIsLoading] = (0,
|
|
9529
|
-
const [isConfirmed, setIsConfirmed] = (0,
|
|
9569
|
+
const [message, setMessage] = (0, import_react8.useState)(null);
|
|
9570
|
+
const [isLoading, setIsLoading] = (0, import_react8.useState)(false);
|
|
9571
|
+
const [isConfirmed, setIsConfirmed] = (0, import_react8.useState)(false);
|
|
9530
9572
|
const handleSubmit = async (event) => {
|
|
9531
9573
|
event.preventDefault();
|
|
9532
9574
|
if (!api || !stripe || !elements) {
|
|
@@ -9587,20 +9629,21 @@ var PaymentForm = ({ onConfirm }) => {
|
|
|
9587
9629
|
};
|
|
9588
9630
|
|
|
9589
9631
|
// src/components/elements/plan-manager/PlanManager.tsx
|
|
9590
|
-
var
|
|
9632
|
+
var import_react16 = require("react");
|
|
9591
9633
|
var import_react_dom2 = require("react-dom");
|
|
9592
9634
|
|
|
9593
9635
|
// src/components/layout/root/Root.tsx
|
|
9594
|
-
var
|
|
9636
|
+
var import_react9 = require("react");
|
|
9595
9637
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
9596
|
-
var Root = (0,
|
|
9638
|
+
var Root = (0, import_react9.forwardRef)(
|
|
9597
9639
|
({ data, settings, ...props }, ref) => {
|
|
9598
9640
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { ref, ...props });
|
|
9599
9641
|
}
|
|
9600
9642
|
);
|
|
9643
|
+
Root.displayName = "Root";
|
|
9601
9644
|
|
|
9602
9645
|
// src/components/layout/viewport/Viewport.tsx
|
|
9603
|
-
var
|
|
9646
|
+
var import_react11 = require("react");
|
|
9604
9647
|
|
|
9605
9648
|
// src/components/layout/viewport/styles.ts
|
|
9606
9649
|
var StyledViewport = dt.div`
|
|
@@ -9613,7 +9656,7 @@ var StyledViewport = dt.div`
|
|
|
9613
9656
|
`;
|
|
9614
9657
|
|
|
9615
9658
|
// src/components/layout/RenderLayout.tsx
|
|
9616
|
-
var
|
|
9659
|
+
var import_react10 = require("react");
|
|
9617
9660
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
9618
9661
|
var Disabled = () => {
|
|
9619
9662
|
const theme = nt();
|
|
@@ -9655,14 +9698,14 @@ var Disabled = () => {
|
|
|
9655
9698
|
var Success = () => {
|
|
9656
9699
|
const theme = nt();
|
|
9657
9700
|
const { hydrate, data, api, setLayout, isPending } = useEmbed();
|
|
9658
|
-
const [isOpen, setIsOpen] = (0,
|
|
9659
|
-
(0,
|
|
9701
|
+
const [isOpen, setIsOpen] = (0, import_react10.useState)(true);
|
|
9702
|
+
(0, import_react10.useEffect)(() => {
|
|
9660
9703
|
if (api && data.component?.id) {
|
|
9661
9704
|
hydrate();
|
|
9662
9705
|
setTimeout(() => setIsOpen(false), 2e3);
|
|
9663
9706
|
}
|
|
9664
9707
|
}, [api, data.component?.id, hydrate]);
|
|
9665
|
-
(0,
|
|
9708
|
+
(0, import_react10.useEffect)(() => {
|
|
9666
9709
|
if (!isPending && !isOpen) {
|
|
9667
9710
|
setLayout("portal");
|
|
9668
9711
|
}
|
|
@@ -9724,7 +9767,7 @@ var RenderLayout = ({ children }) => {
|
|
|
9724
9767
|
|
|
9725
9768
|
// src/components/layout/viewport/Viewport.tsx
|
|
9726
9769
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
9727
|
-
var Viewport = (0,
|
|
9770
|
+
var Viewport = (0, import_react11.forwardRef)(
|
|
9728
9771
|
({ children, ...props }, ref) => {
|
|
9729
9772
|
const theme = nt();
|
|
9730
9773
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
@@ -9738,12 +9781,13 @@ var Viewport = (0, import_react9.forwardRef)(
|
|
|
9738
9781
|
);
|
|
9739
9782
|
}
|
|
9740
9783
|
);
|
|
9784
|
+
Viewport.displayName = "Viewport";
|
|
9741
9785
|
|
|
9742
9786
|
// src/components/layout/column/Column.tsx
|
|
9743
|
-
var
|
|
9787
|
+
var import_react13 = require("react");
|
|
9744
9788
|
|
|
9745
9789
|
// src/components/layout/card/Card.tsx
|
|
9746
|
-
var
|
|
9790
|
+
var import_react12 = require("react");
|
|
9747
9791
|
|
|
9748
9792
|
// src/components/layout/card/styles.ts
|
|
9749
9793
|
var Element = dt(Box)``;
|
|
@@ -9795,7 +9839,7 @@ var StyledCard = dt.div(
|
|
|
9795
9839
|
|
|
9796
9840
|
// src/components/layout/card/Card.tsx
|
|
9797
9841
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
9798
|
-
var Card = (0,
|
|
9842
|
+
var Card = (0, import_react12.forwardRef)(
|
|
9799
9843
|
({ children, className }, ref) => {
|
|
9800
9844
|
const theme = nt();
|
|
9801
9845
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
@@ -9812,6 +9856,7 @@ var Card = (0, import_react10.forwardRef)(
|
|
|
9812
9856
|
);
|
|
9813
9857
|
}
|
|
9814
9858
|
);
|
|
9859
|
+
Card.displayName = "Card";
|
|
9815
9860
|
|
|
9816
9861
|
// src/components/layout/column/styles.ts
|
|
9817
9862
|
var StyledColumn = dt.div`
|
|
@@ -9822,14 +9867,15 @@ var StyledColumn = dt.div`
|
|
|
9822
9867
|
|
|
9823
9868
|
// src/components/layout/column/Column.tsx
|
|
9824
9869
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
9825
|
-
var Column = (0,
|
|
9870
|
+
var Column = (0, import_react13.forwardRef)(
|
|
9826
9871
|
({ children, basis, ...props }, ref) => {
|
|
9827
9872
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(StyledColumn, { ref, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Card, { children }) });
|
|
9828
9873
|
}
|
|
9829
9874
|
);
|
|
9875
|
+
Column.displayName = "Column";
|
|
9830
9876
|
|
|
9831
9877
|
// src/components/elements/plan-manager/CheckoutDialog.tsx
|
|
9832
|
-
var
|
|
9878
|
+
var import_react15 = require("react");
|
|
9833
9879
|
var import_pluralize = __toESM(require_pluralize());
|
|
9834
9880
|
|
|
9835
9881
|
// node_modules/@stripe/stripe-js/dist/index.mjs
|
|
@@ -9864,7 +9910,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
|
|
|
9864
9910
|
}
|
|
9865
9911
|
stripe._registerWrapper({
|
|
9866
9912
|
name: "stripe-js",
|
|
9867
|
-
version: "4.
|
|
9913
|
+
version: "4.7.0",
|
|
9868
9914
|
startTime
|
|
9869
9915
|
});
|
|
9870
9916
|
};
|
|
@@ -9970,7 +10016,7 @@ var loadStripe = function loadStripe2() {
|
|
|
9970
10016
|
var import_react_stripe_js4 = require("@stripe/react-stripe-js");
|
|
9971
10017
|
|
|
9972
10018
|
// src/components/elements/payment-method/PaymentMethod.tsx
|
|
9973
|
-
var
|
|
10019
|
+
var import_react14 = require("react");
|
|
9974
10020
|
var import_react_dom = require("react-dom");
|
|
9975
10021
|
var import_react_stripe_js3 = require("@stripe/react-stripe-js");
|
|
9976
10022
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
@@ -9994,7 +10040,7 @@ var PaymentMethodElement = ({
|
|
|
9994
10040
|
...props
|
|
9995
10041
|
}) => {
|
|
9996
10042
|
const theme = nt();
|
|
9997
|
-
const isLightBackground = (0,
|
|
10043
|
+
const isLightBackground = (0, import_react14.useMemo)(() => {
|
|
9998
10044
|
return hexToHSL(theme.card.background).l > 50;
|
|
9999
10045
|
}, [theme.card.background]);
|
|
10000
10046
|
const sizeFactor = size === "lg" ? 2 : size === "md" ? 1 : 0.5;
|
|
@@ -10047,21 +10093,21 @@ var PaymentMethodElement = ({
|
|
|
10047
10093
|
)
|
|
10048
10094
|
] });
|
|
10049
10095
|
};
|
|
10050
|
-
var PaymentMethod = (0,
|
|
10096
|
+
var PaymentMethod = (0, import_react14.forwardRef)(({ children, className, portal, ...rest }, ref) => {
|
|
10051
10097
|
const props = resolveDesignProps(rest);
|
|
10052
10098
|
const theme = nt();
|
|
10053
10099
|
const { api, data, layout, setLayout } = useEmbed();
|
|
10054
|
-
const [isLoading, setIsLoading] = (0,
|
|
10055
|
-
const [error, setError] = (0,
|
|
10056
|
-
const [showPaymentForm, setShowPaymentForm] = (0,
|
|
10100
|
+
const [isLoading, setIsLoading] = (0, import_react14.useState)(false);
|
|
10101
|
+
const [error, setError] = (0, import_react14.useState)();
|
|
10102
|
+
const [showPaymentForm, setShowPaymentForm] = (0, import_react14.useState)(
|
|
10057
10103
|
() => typeof data.subscription?.paymentMethod === "undefined"
|
|
10058
10104
|
);
|
|
10059
|
-
const [stripe, setStripe] = (0,
|
|
10060
|
-
const [setupIntent, setSetupIntent] = (0,
|
|
10061
|
-
const isLightBackground = (0,
|
|
10105
|
+
const [stripe, setStripe] = (0, import_react14.useState)(null);
|
|
10106
|
+
const [setupIntent, setSetupIntent] = (0, import_react14.useState)();
|
|
10107
|
+
const isLightBackground = (0, import_react14.useMemo)(() => {
|
|
10062
10108
|
return hexToHSL(theme.card.background).l > 50;
|
|
10063
10109
|
}, [theme.card.background]);
|
|
10064
|
-
const paymentMethod = (0,
|
|
10110
|
+
const paymentMethod = (0, import_react14.useMemo)(() => {
|
|
10065
10111
|
const { paymentMethodType, cardLast4, cardExpMonth, cardExpYear } = data.subscription?.paymentMethod || {};
|
|
10066
10112
|
let monthsToExpiration;
|
|
10067
10113
|
if (typeof cardExpYear === "number" && typeof cardExpMonth === "number") {
|
|
@@ -10081,7 +10127,7 @@ var PaymentMethod = (0, import_react12.forwardRef)(({ children, className, porta
|
|
|
10081
10127
|
monthsToExpiration
|
|
10082
10128
|
};
|
|
10083
10129
|
}, [data.subscription?.paymentMethod]);
|
|
10084
|
-
const createSetupIntent = (0,
|
|
10130
|
+
const createSetupIntent = (0, import_react14.useCallback)(async () => {
|
|
10085
10131
|
if (!api || !data.component?.id) {
|
|
10086
10132
|
return;
|
|
10087
10133
|
}
|
|
@@ -10098,7 +10144,7 @@ var PaymentMethod = (0, import_react12.forwardRef)(({ children, className, porta
|
|
|
10098
10144
|
setIsLoading(false);
|
|
10099
10145
|
}
|
|
10100
10146
|
}, [api, data.component?.id]);
|
|
10101
|
-
const updatePaymentMethod = (0,
|
|
10147
|
+
const updatePaymentMethod = (0, import_react14.useCallback)(
|
|
10102
10148
|
async (id) => {
|
|
10103
10149
|
if (!api || !id) {
|
|
10104
10150
|
return;
|
|
@@ -10119,17 +10165,17 @@ var PaymentMethod = (0, import_react12.forwardRef)(({ children, className, porta
|
|
|
10119
10165
|
},
|
|
10120
10166
|
[api, setLayout]
|
|
10121
10167
|
);
|
|
10122
|
-
(0,
|
|
10168
|
+
(0, import_react14.useEffect)(() => {
|
|
10123
10169
|
if (!stripe && setupIntent?.publishableKey) {
|
|
10124
10170
|
setStripe(loadStripe(setupIntent.publishableKey));
|
|
10125
10171
|
}
|
|
10126
10172
|
}, [stripe, setupIntent?.publishableKey]);
|
|
10127
|
-
(0,
|
|
10128
|
-
document.body.style.overflow = "hidden";
|
|
10173
|
+
(0, import_react14.useEffect)(() => {
|
|
10174
|
+
document.body.style.overflow = layout === "payment" ? "hidden" : "";
|
|
10129
10175
|
return () => {
|
|
10130
10176
|
document.body.style.overflow = "";
|
|
10131
10177
|
};
|
|
10132
|
-
}, []);
|
|
10178
|
+
}, [layout]);
|
|
10133
10179
|
if (!paymentMethod.paymentMethodType) {
|
|
10134
10180
|
return null;
|
|
10135
10181
|
}
|
|
@@ -10241,6 +10287,7 @@ var PaymentMethod = (0, import_react12.forwardRef)(({ children, className, porta
|
|
|
10241
10287
|
)
|
|
10242
10288
|
] });
|
|
10243
10289
|
});
|
|
10290
|
+
PaymentMethod.displayName = "PaymentMethod";
|
|
10244
10291
|
|
|
10245
10292
|
// src/components/ui/tooltip/styles.ts
|
|
10246
10293
|
var TooltipWrapper = dt.div`
|
|
@@ -10298,6 +10345,7 @@ var FeatureName = ({
|
|
|
10298
10345
|
let period;
|
|
10299
10346
|
if (entitlement.metricPeriod) {
|
|
10300
10347
|
period = {
|
|
10348
|
+
billing: "billing period",
|
|
10301
10349
|
current_day: "day",
|
|
10302
10350
|
current_month: "month",
|
|
10303
10351
|
current_year: "year"
|
|
@@ -10331,23 +10379,23 @@ var FeatureName = ({
|
|
|
10331
10379
|
var CheckoutDialog = () => {
|
|
10332
10380
|
const theme = nt();
|
|
10333
10381
|
const { api, data, setLayout } = useEmbed();
|
|
10334
|
-
const [checkoutStage, setCheckoutStage] = (0,
|
|
10382
|
+
const [checkoutStage, setCheckoutStage] = (0, import_react15.useState)(
|
|
10335
10383
|
"plan"
|
|
10336
10384
|
);
|
|
10337
|
-
const [planPeriod, setPlanPeriod] = (0,
|
|
10385
|
+
const [planPeriod, setPlanPeriod] = (0, import_react15.useState)(
|
|
10338
10386
|
() => data.company?.plan?.planPeriod || "month"
|
|
10339
10387
|
);
|
|
10340
|
-
const [selectedPlan, setSelectedPlan] = (0,
|
|
10341
|
-
const [charges, setCharges] = (0,
|
|
10342
|
-
const [paymentMethodId, setPaymentMethodId] = (0,
|
|
10343
|
-
const [isLoading, setIsLoading] = (0,
|
|
10344
|
-
const [error, setError] = (0,
|
|
10345
|
-
const [showPaymentForm, setShowPaymentForm] = (0,
|
|
10388
|
+
const [selectedPlan, setSelectedPlan] = (0, import_react15.useState)();
|
|
10389
|
+
const [charges, setCharges] = (0, import_react15.useState)();
|
|
10390
|
+
const [paymentMethodId, setPaymentMethodId] = (0, import_react15.useState)();
|
|
10391
|
+
const [isLoading, setIsLoading] = (0, import_react15.useState)(false);
|
|
10392
|
+
const [error, setError] = (0, import_react15.useState)();
|
|
10393
|
+
const [showPaymentForm, setShowPaymentForm] = (0, import_react15.useState)(
|
|
10346
10394
|
() => typeof data.subscription?.paymentMethod === "undefined"
|
|
10347
10395
|
);
|
|
10348
|
-
const [stripe, setStripe] = (0,
|
|
10349
|
-
const [setupIntent, setSetupIntent] = (0,
|
|
10350
|
-
const { paymentMethod, currentPlan, availablePlans, planPeriodOptions } = (0,
|
|
10396
|
+
const [stripe, setStripe] = (0, import_react15.useState)(null);
|
|
10397
|
+
const [setupIntent, setSetupIntent] = (0, import_react15.useState)();
|
|
10398
|
+
const { paymentMethod, currentPlan, availablePlans, planPeriodOptions } = (0, import_react15.useMemo)(() => {
|
|
10351
10399
|
const showMonthlyPriceOption = data.activePlans.some(
|
|
10352
10400
|
(plan) => typeof plan.yearlyPrice !== "undefined"
|
|
10353
10401
|
);
|
|
@@ -10368,7 +10416,7 @@ var CheckoutDialog = () => {
|
|
|
10368
10416
|
planPeriodOptions: planPeriodOptions2
|
|
10369
10417
|
};
|
|
10370
10418
|
}, [data.subscription?.paymentMethod, data.company, data.activePlans]);
|
|
10371
|
-
const savingsPercentage = (0,
|
|
10419
|
+
const savingsPercentage = (0, import_react15.useMemo)(() => {
|
|
10372
10420
|
if (selectedPlan) {
|
|
10373
10421
|
const monthly = (selectedPlan?.monthlyPrice?.price || 0) * 12;
|
|
10374
10422
|
const yearly = selectedPlan?.yearlyPrice?.price || 0;
|
|
@@ -10376,7 +10424,7 @@ var CheckoutDialog = () => {
|
|
|
10376
10424
|
}
|
|
10377
10425
|
return 0;
|
|
10378
10426
|
}, [selectedPlan]);
|
|
10379
|
-
const subscriptionPrice = (0,
|
|
10427
|
+
const subscriptionPrice = (0, import_react15.useMemo)(() => {
|
|
10380
10428
|
if (!selectedPlan || !selectedPlan.monthlyPrice || !selectedPlan.yearlyPrice) {
|
|
10381
10429
|
return;
|
|
10382
10430
|
}
|
|
@@ -10384,10 +10432,10 @@ var CheckoutDialog = () => {
|
|
|
10384
10432
|
(planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price
|
|
10385
10433
|
);
|
|
10386
10434
|
}, [selectedPlan, planPeriod]);
|
|
10387
|
-
const isLightBackground = (0,
|
|
10435
|
+
const isLightBackground = (0, import_react15.useMemo)(() => {
|
|
10388
10436
|
return hexToHSL(theme.card.background).l > 50;
|
|
10389
10437
|
}, [theme.card.background]);
|
|
10390
|
-
const selectPlan = (0,
|
|
10438
|
+
const selectPlan = (0, import_react15.useCallback)(
|
|
10391
10439
|
async (plan, newPeriod) => {
|
|
10392
10440
|
setSelectedPlan(plan);
|
|
10393
10441
|
setCharges(void 0);
|
|
@@ -10415,7 +10463,7 @@ var CheckoutDialog = () => {
|
|
|
10415
10463
|
},
|
|
10416
10464
|
[api, planPeriod]
|
|
10417
10465
|
);
|
|
10418
|
-
const changePlanPeriod = (0,
|
|
10466
|
+
const changePlanPeriod = (0, import_react15.useCallback)(
|
|
10419
10467
|
(period) => {
|
|
10420
10468
|
setPlanPeriod(period);
|
|
10421
10469
|
if (selectedPlan) {
|
|
@@ -10424,7 +10472,7 @@ var CheckoutDialog = () => {
|
|
|
10424
10472
|
},
|
|
10425
10473
|
[selectedPlan, selectPlan]
|
|
10426
10474
|
);
|
|
10427
|
-
const checkout = (0,
|
|
10475
|
+
const checkout = (0, import_react15.useCallback)(async () => {
|
|
10428
10476
|
const priceId = (planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.id;
|
|
10429
10477
|
if (!api || !selectedPlan || !priceId) {
|
|
10430
10478
|
return;
|
|
@@ -10447,12 +10495,12 @@ var CheckoutDialog = () => {
|
|
|
10447
10495
|
setIsLoading(false);
|
|
10448
10496
|
}
|
|
10449
10497
|
}, [api, paymentMethodId, planPeriod, selectedPlan, setLayout]);
|
|
10450
|
-
(0,
|
|
10498
|
+
(0, import_react15.useEffect)(() => {
|
|
10451
10499
|
if (!stripe && setupIntent?.publishableKey) {
|
|
10452
10500
|
setStripe(loadStripe(setupIntent.publishableKey));
|
|
10453
10501
|
}
|
|
10454
10502
|
}, [stripe, setupIntent?.publishableKey]);
|
|
10455
|
-
(0,
|
|
10503
|
+
(0, import_react15.useEffect)(() => {
|
|
10456
10504
|
document.body.style.overflow = "hidden";
|
|
10457
10505
|
return () => {
|
|
10458
10506
|
document.body.style.overflow = "";
|
|
@@ -11301,11 +11349,11 @@ var resolveDesignProps2 = (props) => {
|
|
|
11301
11349
|
}
|
|
11302
11350
|
};
|
|
11303
11351
|
};
|
|
11304
|
-
var PlanManager = (0,
|
|
11352
|
+
var PlanManager = (0, import_react16.forwardRef)(({ children, className, portal, ...rest }, ref) => {
|
|
11305
11353
|
const props = resolveDesignProps2(rest);
|
|
11306
11354
|
const theme = nt();
|
|
11307
11355
|
const { data, layout, setLayout } = useEmbed();
|
|
11308
|
-
const { currentPlan, canChangePlan } = (0,
|
|
11356
|
+
const { currentPlan, canChangePlan } = (0, import_react16.useMemo)(() => {
|
|
11309
11357
|
return {
|
|
11310
11358
|
currentPlan: data.company?.plan,
|
|
11311
11359
|
canChangePlan: data.activePlans.length > 0
|
|
@@ -11386,9 +11434,10 @@ var PlanManager = (0, import_react14.forwardRef)(({ children, className, portal,
|
|
|
11386
11434
|
}
|
|
11387
11435
|
);
|
|
11388
11436
|
});
|
|
11437
|
+
PlanManager.displayName = "PlanManager";
|
|
11389
11438
|
|
|
11390
11439
|
// src/components/elements/included-features/IncludedFeatures.tsx
|
|
11391
|
-
var
|
|
11440
|
+
var import_react17 = require("react");
|
|
11392
11441
|
var import_pluralize2 = __toESM(require_pluralize());
|
|
11393
11442
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
11394
11443
|
function resolveDesignProps3(props) {
|
|
@@ -11413,69 +11462,13 @@ function resolveDesignProps3(props) {
|
|
|
11413
11462
|
}
|
|
11414
11463
|
};
|
|
11415
11464
|
}
|
|
11416
|
-
var IncludedFeatures = (0,
|
|
11465
|
+
var IncludedFeatures = (0, import_react17.forwardRef)(({ className, ...rest }, ref) => {
|
|
11417
11466
|
const props = resolveDesignProps3(rest);
|
|
11418
11467
|
const theme = nt();
|
|
11419
11468
|
const { data } = useEmbed();
|
|
11420
|
-
const elements = (0,
|
|
11421
|
-
const
|
|
11422
|
-
|
|
11423
|
-
({
|
|
11424
|
-
access,
|
|
11425
|
-
allocation,
|
|
11426
|
-
allocationType,
|
|
11427
|
-
feature,
|
|
11428
|
-
period,
|
|
11429
|
-
usage = 0,
|
|
11430
|
-
...props2
|
|
11431
|
-
}) => {
|
|
11432
|
-
return {
|
|
11433
|
-
access,
|
|
11434
|
-
allocation,
|
|
11435
|
-
allocationType,
|
|
11436
|
-
feature,
|
|
11437
|
-
period,
|
|
11438
|
-
/**
|
|
11439
|
-
* @TODO: resolve feature price
|
|
11440
|
-
*/
|
|
11441
|
-
price: void 0,
|
|
11442
|
-
usage,
|
|
11443
|
-
...props2
|
|
11444
|
-
};
|
|
11445
|
-
}
|
|
11446
|
-
);
|
|
11447
|
-
}, [data.featureUsage]);
|
|
11448
|
-
const isLightBackground = (0, import_react15.useMemo)(() => {
|
|
11449
|
-
return hexToHSL(theme.card.background).l > 50;
|
|
11450
|
-
}, [theme.card.background]);
|
|
11451
|
-
(0, import_react15.useLayoutEffect)(() => {
|
|
11452
|
-
const assignRows = (parent) => {
|
|
11453
|
-
let isWrapped = true;
|
|
11454
|
-
[...parent.children].forEach((el) => {
|
|
11455
|
-
if (!(el instanceof HTMLElement)) {
|
|
11456
|
-
return;
|
|
11457
|
-
}
|
|
11458
|
-
if (!el.previousElementSibling || el.offsetLeft <= el.previousElementSibling.offsetLeft) {
|
|
11459
|
-
isWrapped = !isWrapped;
|
|
11460
|
-
}
|
|
11461
|
-
if (isWrapped) {
|
|
11462
|
-
el.style.textAlign = "left";
|
|
11463
|
-
} else if (el.previousElementSibling) {
|
|
11464
|
-
el.style.textAlign = "right";
|
|
11465
|
-
}
|
|
11466
|
-
});
|
|
11467
|
-
};
|
|
11468
|
-
elements.current.forEach((el) => {
|
|
11469
|
-
if (!el) return;
|
|
11470
|
-
const observer = new ResizeObserver((entries) => {
|
|
11471
|
-
entries.forEach((entry) => {
|
|
11472
|
-
assignRows(entry.target);
|
|
11473
|
-
});
|
|
11474
|
-
});
|
|
11475
|
-
observer.observe(el);
|
|
11476
|
-
assignRows(el);
|
|
11477
|
-
});
|
|
11478
|
-
}, [elements.current.length]);
|
|
11469
|
+
const elements = (0, import_react17.useRef)([]);
|
|
11470
|
+
const shouldWrapChildren = useWrapChildren(elements.current);
|
|
11471
|
+
const isLightBackground = useIsLightBackground();
|
|
11479
11472
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
11480
11473
|
Element,
|
|
11481
11474
|
{
|
|
@@ -11495,17 +11488,14 @@ var IncludedFeatures = (0, import_react15.forwardRef)(({ className, ...rest }, r
|
|
|
11495
11488
|
children: props.header.text
|
|
11496
11489
|
}
|
|
11497
11490
|
) }),
|
|
11498
|
-
features.reduce(
|
|
11499
|
-
(acc, { allocation,
|
|
11500
|
-
if (!allocationType) {
|
|
11501
|
-
return acc;
|
|
11502
|
-
}
|
|
11491
|
+
(data.featureUsage?.features || []).reduce(
|
|
11492
|
+
(acc, { allocation, feature, usage }, index) => {
|
|
11503
11493
|
return [
|
|
11504
11494
|
...acc,
|
|
11505
11495
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
11506
11496
|
Flex,
|
|
11507
11497
|
{
|
|
11508
|
-
ref: (el) => elements.current.push(el),
|
|
11498
|
+
ref: (el) => el && elements.current.push(el),
|
|
11509
11499
|
$flexWrap: "wrap",
|
|
11510
11500
|
$justifyContent: "space-between",
|
|
11511
11501
|
$alignItems: "center",
|
|
@@ -11534,12 +11524,12 @@ var IncludedFeatures = (0, import_react15.forwardRef)(({ className, ...rest }, r
|
|
|
11534
11524
|
}
|
|
11535
11525
|
) })
|
|
11536
11526
|
] }),
|
|
11537
|
-
(
|
|
11527
|
+
(feature?.featureType === "event" || feature?.featureType === "trait") && feature?.name && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
11538
11528
|
Box,
|
|
11539
11529
|
{
|
|
11540
11530
|
$flexBasis: "min-content",
|
|
11541
11531
|
$flexGrow: "1",
|
|
11542
|
-
$textAlign: "right",
|
|
11532
|
+
$textAlign: shouldWrapChildren ? "left" : "right",
|
|
11543
11533
|
children: [
|
|
11544
11534
|
props.entitlement.isVisible && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
11545
11535
|
Text,
|
|
@@ -11578,9 +11568,10 @@ var IncludedFeatures = (0, import_react15.forwardRef)(({ className, ...rest }, r
|
|
|
11578
11568
|
}
|
|
11579
11569
|
);
|
|
11580
11570
|
});
|
|
11571
|
+
IncludedFeatures.displayName = "IncludedFeatures";
|
|
11581
11572
|
|
|
11582
11573
|
// src/components/elements/metered-features/MeteredFeatures.tsx
|
|
11583
|
-
var
|
|
11574
|
+
var import_react18 = require("react");
|
|
11584
11575
|
var import_pluralize3 = __toESM(require_pluralize());
|
|
11585
11576
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
11586
11577
|
function resolveDesignProps4(props) {
|
|
@@ -11603,186 +11594,129 @@ function resolveDesignProps4(props) {
|
|
|
11603
11594
|
usage: {
|
|
11604
11595
|
isVisible: props.usage?.isVisible ?? true,
|
|
11605
11596
|
fontStyle: props.usage?.fontStyle ?? "heading5"
|
|
11606
|
-
}
|
|
11597
|
+
},
|
|
11598
|
+
visibleFeatures: props.visibleFeatures ?? []
|
|
11607
11599
|
};
|
|
11608
11600
|
}
|
|
11609
|
-
var MeteredFeatures = (0,
|
|
11601
|
+
var MeteredFeatures = (0, import_react18.forwardRef)(({ className, ...rest }, ref) => {
|
|
11610
11602
|
const props = resolveDesignProps4(rest);
|
|
11603
|
+
const elements = (0, import_react18.useRef)([]);
|
|
11604
|
+
const shouldWrapChildren = useWrapChildren(elements.current);
|
|
11611
11605
|
const theme = nt();
|
|
11612
11606
|
const { data } = useEmbed();
|
|
11613
|
-
const
|
|
11614
|
-
const features = (
|
|
11615
|
-
return (
|
|
11616
|
-
|
|
11617
|
-
|
|
11618
|
-
|
|
11619
|
-
|
|
11620
|
-
|
|
11621
|
-
|
|
11622
|
-
|
|
11623
|
-
|
|
11624
|
-
|
|
11625
|
-
|
|
11626
|
-
|
|
11627
|
-
|
|
11628
|
-
|
|
11629
|
-
|
|
11630
|
-
|
|
11631
|
-
/**
|
|
11632
|
-
* @TODO: resolve feature price
|
|
11633
|
-
*/
|
|
11634
|
-
price: void 0,
|
|
11635
|
-
usage,
|
|
11636
|
-
...props2
|
|
11637
|
-
};
|
|
11638
|
-
}
|
|
11639
|
-
);
|
|
11640
|
-
}, [data.featureUsage]);
|
|
11641
|
-
const isLightBackground = (0, import_react16.useMemo)(() => {
|
|
11642
|
-
return hexToHSL(theme.card.background).l > 50;
|
|
11643
|
-
}, [theme.card.background]);
|
|
11644
|
-
(0, import_react16.useLayoutEffect)(() => {
|
|
11645
|
-
const assignRows = (parent) => {
|
|
11646
|
-
let isWrapped = true;
|
|
11647
|
-
[...parent.children].forEach((el) => {
|
|
11648
|
-
if (!(el instanceof HTMLElement)) {
|
|
11649
|
-
return;
|
|
11650
|
-
}
|
|
11651
|
-
if (!el.previousElementSibling || el.offsetLeft <= el.previousElementSibling.offsetLeft) {
|
|
11652
|
-
isWrapped = !isWrapped;
|
|
11653
|
-
}
|
|
11654
|
-
if (isWrapped) {
|
|
11655
|
-
el.style.textAlign = "left";
|
|
11656
|
-
} else if (el.previousElementSibling) {
|
|
11657
|
-
el.style.textAlign = "right";
|
|
11607
|
+
const isLightBackground = useIsLightBackground();
|
|
11608
|
+
const features = (data.featureUsage?.features || []).filter(({ feature }) => {
|
|
11609
|
+
return (feature?.featureType === "event" || feature?.featureType === "trait") && feature?.id && props.visibleFeatures?.includes(feature.id);
|
|
11610
|
+
});
|
|
11611
|
+
if (features.length === 0) {
|
|
11612
|
+
return null;
|
|
11613
|
+
}
|
|
11614
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Flex, { ref, className, $flexDirection: "column", children: features.map(({ allocation, feature, usage }, index) => {
|
|
11615
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(Element, { as: Flex, $gap: "1.5rem", children: [
|
|
11616
|
+
props.icon.isVisible && feature?.icon && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
11617
|
+
IconRound,
|
|
11618
|
+
{
|
|
11619
|
+
name: feature.icon,
|
|
11620
|
+
size: "sm",
|
|
11621
|
+
colors: [
|
|
11622
|
+
theme.primary,
|
|
11623
|
+
isLightBackground ? "hsla(0, 0%, 0%, 0.0625)" : "hsla(0, 0%, 100%, 0.25)"
|
|
11624
|
+
]
|
|
11658
11625
|
}
|
|
11659
|
-
|
|
11660
|
-
|
|
11661
|
-
|
|
11662
|
-
|
|
11663
|
-
|
|
11664
|
-
|
|
11665
|
-
|
|
11666
|
-
|
|
11667
|
-
|
|
11668
|
-
|
|
11669
|
-
|
|
11670
|
-
|
|
11671
|
-
|
|
11672
|
-
|
|
11673
|
-
|
|
11674
|
-
|
|
11675
|
-
|
|
11676
|
-
|
|
11677
|
-
|
|
11678
|
-
|
|
11679
|
-
|
|
11680
|
-
|
|
11681
|
-
|
|
11682
|
-
|
|
11683
|
-
|
|
11684
|
-
|
|
11685
|
-
|
|
11686
|
-
|
|
11687
|
-
|
|
11688
|
-
|
|
11689
|
-
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
|
|
11694
|
-
|
|
11695
|
-
|
|
11696
|
-
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
|
|
11700
|
-
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
11626
|
+
),
|
|
11627
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(Flex, { $flexDirection: "column", $gap: "2rem", $flexGrow: "1", children: [
|
|
11628
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
11629
|
+
Flex,
|
|
11630
|
+
{
|
|
11631
|
+
ref: (el) => el && elements.current.push(el),
|
|
11632
|
+
$flexWrap: "wrap",
|
|
11633
|
+
$gap: "1rem",
|
|
11634
|
+
children: [
|
|
11635
|
+
feature?.name && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(Flex, { $flexDirection: "column", $gap: "0.5rem", $flexGrow: "1", children: [
|
|
11636
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
11637
|
+
Text,
|
|
11638
|
+
{
|
|
11639
|
+
as: Box,
|
|
11640
|
+
$font: theme.typography[props.header.fontStyle].fontFamily,
|
|
11641
|
+
$size: theme.typography[props.header.fontStyle].fontSize,
|
|
11642
|
+
$weight: theme.typography[props.header.fontStyle].fontWeight,
|
|
11643
|
+
$color: theme.typography[props.header.fontStyle].color,
|
|
11644
|
+
children: feature.name
|
|
11645
|
+
}
|
|
11646
|
+
),
|
|
11647
|
+
props.description.isVisible && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
11648
|
+
Text,
|
|
11649
|
+
{
|
|
11650
|
+
as: Box,
|
|
11651
|
+
$font: theme.typography[props.description.fontStyle].fontFamily,
|
|
11652
|
+
$size: theme.typography[props.description.fontStyle].fontSize,
|
|
11653
|
+
$weight: theme.typography[props.description.fontStyle].fontWeight,
|
|
11654
|
+
$color: theme.typography[props.description.fontStyle].color,
|
|
11655
|
+
children: feature.description
|
|
11656
|
+
}
|
|
11657
|
+
)
|
|
11658
|
+
] }),
|
|
11659
|
+
(feature?.featureType === "event" || feature?.featureType === "trait") && feature?.name && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
11660
|
+
Box,
|
|
11661
|
+
{
|
|
11662
|
+
$flexBasis: "min-content",
|
|
11663
|
+
$flexGrow: "1",
|
|
11664
|
+
$textAlign: shouldWrapChildren ? "left" : "right",
|
|
11665
|
+
children: [
|
|
11666
|
+
props.usage.isVisible && typeof usage === "number" && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
11701
11667
|
Text,
|
|
11702
11668
|
{
|
|
11703
11669
|
as: Box,
|
|
11704
|
-
$font: theme.typography[props.
|
|
11705
|
-
$size: theme.typography[props.
|
|
11706
|
-
$weight: theme.typography[props.
|
|
11707
|
-
$
|
|
11708
|
-
|
|
11670
|
+
$font: theme.typography[props.usage.fontStyle].fontFamily,
|
|
11671
|
+
$size: theme.typography[props.usage.fontStyle].fontSize,
|
|
11672
|
+
$weight: theme.typography[props.usage.fontStyle].fontWeight,
|
|
11673
|
+
$lineHeight: 1.25,
|
|
11674
|
+
$color: theme.typography[props.usage.fontStyle].color,
|
|
11675
|
+
children: [
|
|
11676
|
+
formatNumber(usage),
|
|
11677
|
+
" ",
|
|
11678
|
+
(0, import_pluralize3.default)(feature.name, usage)
|
|
11679
|
+
]
|
|
11709
11680
|
}
|
|
11710
11681
|
),
|
|
11711
|
-
props.
|
|
11682
|
+
props.allocation.isVisible && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Box, { $whiteSpace: "nowrap", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
11712
11683
|
Text,
|
|
11713
11684
|
{
|
|
11714
|
-
|
|
11715
|
-
$
|
|
11716
|
-
$
|
|
11717
|
-
$
|
|
11718
|
-
$
|
|
11719
|
-
children: feature.description
|
|
11685
|
+
$font: theme.typography[props.allocation.fontStyle].fontFamily,
|
|
11686
|
+
$size: theme.typography[props.allocation.fontStyle].fontSize,
|
|
11687
|
+
$weight: theme.typography[props.allocation.fontStyle].fontWeight,
|
|
11688
|
+
$color: theme.typography[props.allocation.fontStyle].color,
|
|
11689
|
+
children: typeof allocation === "number" ? `Limit of ${formatNumber(allocation)}` : "No limit"
|
|
11720
11690
|
}
|
|
11721
|
-
)
|
|
11722
|
-
]
|
|
11723
|
-
|
|
11724
|
-
|
|
11725
|
-
|
|
11726
|
-
|
|
11727
|
-
|
|
11728
|
-
|
|
11729
|
-
|
|
11730
|
-
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
|
|
11742
|
-
|
|
11743
|
-
|
|
11744
|
-
|
|
11745
|
-
),
|
|
11746
|
-
props.allocation.isVisible && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Box, { $whiteSpace: "nowrap", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
11747
|
-
Text,
|
|
11748
|
-
{
|
|
11749
|
-
$font: theme.typography[props.allocation.fontStyle].fontFamily,
|
|
11750
|
-
$size: theme.typography[props.allocation.fontStyle].fontSize,
|
|
11751
|
-
$weight: theme.typography[props.allocation.fontStyle].fontWeight,
|
|
11752
|
-
$color: theme.typography[props.allocation.fontStyle].color,
|
|
11753
|
-
children: typeof allocation === "number" ? `Limit of ${formatNumber(allocation)}` : "No limit"
|
|
11754
|
-
}
|
|
11755
|
-
) })
|
|
11756
|
-
]
|
|
11757
|
-
}
|
|
11758
|
-
)
|
|
11759
|
-
]
|
|
11760
|
-
}
|
|
11761
|
-
),
|
|
11762
|
-
props.isVisible && typeof usage === "number" && typeof allocation === "number" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
11763
|
-
ProgressBar,
|
|
11764
|
-
{
|
|
11765
|
-
progress: usage / allocation * 100,
|
|
11766
|
-
value: usage,
|
|
11767
|
-
total: allocation,
|
|
11768
|
-
color: [
|
|
11769
|
-
"blue",
|
|
11770
|
-
"blue",
|
|
11771
|
-
"yellow",
|
|
11772
|
-
"red"
|
|
11773
|
-
][Math.floor(usage / allocation * 4)]
|
|
11774
|
-
}
|
|
11775
|
-
) })
|
|
11776
|
-
] })
|
|
11777
|
-
] }, index)
|
|
11778
|
-
];
|
|
11779
|
-
},
|
|
11780
|
-
[]
|
|
11781
|
-
) });
|
|
11691
|
+
) })
|
|
11692
|
+
]
|
|
11693
|
+
}
|
|
11694
|
+
)
|
|
11695
|
+
]
|
|
11696
|
+
}
|
|
11697
|
+
),
|
|
11698
|
+
props.isVisible && typeof usage === "number" && typeof allocation === "number" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
11699
|
+
ProgressBar,
|
|
11700
|
+
{
|
|
11701
|
+
progress: usage / allocation * 100,
|
|
11702
|
+
value: usage,
|
|
11703
|
+
total: allocation,
|
|
11704
|
+
color: [
|
|
11705
|
+
"blue",
|
|
11706
|
+
"blue",
|
|
11707
|
+
"yellow",
|
|
11708
|
+
"red"
|
|
11709
|
+
][Math.floor(usage / allocation * 4)]
|
|
11710
|
+
}
|
|
11711
|
+
) })
|
|
11712
|
+
] })
|
|
11713
|
+
] }, index);
|
|
11714
|
+
}) });
|
|
11782
11715
|
});
|
|
11716
|
+
MeteredFeatures.displayName = "MeteredFeatures";
|
|
11783
11717
|
|
|
11784
11718
|
// src/components/elements/upcoming-bill/UpcomingBill.tsx
|
|
11785
|
-
var
|
|
11719
|
+
var import_react19 = require("react");
|
|
11786
11720
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
11787
11721
|
function resolveDesignProps5(props) {
|
|
11788
11722
|
return {
|
|
@@ -11802,11 +11736,11 @@ function resolveDesignProps5(props) {
|
|
|
11802
11736
|
}
|
|
11803
11737
|
};
|
|
11804
11738
|
}
|
|
11805
|
-
var UpcomingBill = (0,
|
|
11739
|
+
var UpcomingBill = (0, import_react19.forwardRef)(({ className, ...rest }, ref) => {
|
|
11806
11740
|
const props = resolveDesignProps5(rest);
|
|
11807
11741
|
const theme = nt();
|
|
11808
11742
|
const { data } = useEmbed();
|
|
11809
|
-
const { upcomingInvoice } = (0,
|
|
11743
|
+
const { upcomingInvoice } = (0, import_react19.useMemo)(() => {
|
|
11810
11744
|
return {
|
|
11811
11745
|
upcomingInvoice: {
|
|
11812
11746
|
...data.upcomingInvoice?.amountDue && {
|
|
@@ -11872,9 +11806,10 @@ var UpcomingBill = (0, import_react17.forwardRef)(({ className, ...rest }, ref)
|
|
|
11872
11806
|
] })
|
|
11873
11807
|
] });
|
|
11874
11808
|
});
|
|
11809
|
+
UpcomingBill.displayName = "UpcomingBill";
|
|
11875
11810
|
|
|
11876
11811
|
// src/components/elements/invoices/Invoices.tsx
|
|
11877
|
-
var
|
|
11812
|
+
var import_react20 = require("react");
|
|
11878
11813
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
11879
11814
|
function resolveDesignProps6(props) {
|
|
11880
11815
|
return {
|
|
@@ -11906,12 +11841,12 @@ function formatInvoices(invoices) {
|
|
|
11906
11841
|
amount: formatCurrency(amountDue)
|
|
11907
11842
|
}));
|
|
11908
11843
|
}
|
|
11909
|
-
var Invoices = (0,
|
|
11844
|
+
var Invoices = (0, import_react20.forwardRef)(({ className, ...rest }, ref) => {
|
|
11910
11845
|
const props = resolveDesignProps6(rest);
|
|
11911
11846
|
const theme = nt();
|
|
11912
11847
|
const { api } = useEmbed();
|
|
11913
|
-
const [invoices, setInvoices] = (0,
|
|
11914
|
-
(0,
|
|
11848
|
+
const [invoices, setInvoices] = (0, import_react20.useState)(() => formatInvoices(rest.data));
|
|
11849
|
+
(0, import_react20.useEffect)(() => {
|
|
11915
11850
|
api?.listInvoices().then(({ data }) => {
|
|
11916
11851
|
setInvoices(formatInvoices(data));
|
|
11917
11852
|
});
|
|
@@ -11969,12 +11904,13 @@ var Invoices = (0, import_react18.forwardRef)(({ className, ...rest }, ref) => {
|
|
|
11969
11904
|
] })
|
|
11970
11905
|
] }) });
|
|
11971
11906
|
});
|
|
11907
|
+
Invoices.displayName = "Invoices";
|
|
11972
11908
|
|
|
11973
11909
|
// src/components/embed/ComponentTree.tsx
|
|
11974
|
-
var
|
|
11910
|
+
var import_react22 = require("react");
|
|
11975
11911
|
|
|
11976
11912
|
// src/components/embed/renderer.ts
|
|
11977
|
-
var
|
|
11913
|
+
var import_react21 = require("react");
|
|
11978
11914
|
var components = {
|
|
11979
11915
|
Root,
|
|
11980
11916
|
Viewport,
|
|
@@ -12004,7 +11940,7 @@ function createRenderer(options) {
|
|
|
12004
11940
|
const { className, ...rest } = props;
|
|
12005
11941
|
const resolvedProps = component === "div" ? rest : props;
|
|
12006
11942
|
const resolvedChildren = children.map(renderNode);
|
|
12007
|
-
return (0,
|
|
11943
|
+
return (0, import_react21.createElement)(
|
|
12008
11944
|
component,
|
|
12009
11945
|
{
|
|
12010
11946
|
key: index,
|
|
@@ -12074,15 +12010,15 @@ var Error2 = ({ message }) => {
|
|
|
12074
12010
|
};
|
|
12075
12011
|
var ComponentTree = () => {
|
|
12076
12012
|
const { error, nodes } = useEmbed();
|
|
12077
|
-
const [children, setChildren] = (0,
|
|
12078
|
-
(0,
|
|
12013
|
+
const [children, setChildren] = (0, import_react22.useState)(/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Loading, {}));
|
|
12014
|
+
(0, import_react22.useEffect)(() => {
|
|
12079
12015
|
const renderer = createRenderer();
|
|
12080
12016
|
setChildren(nodes.map(renderer));
|
|
12081
12017
|
}, [nodes]);
|
|
12082
12018
|
if (error) {
|
|
12083
12019
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Error2, { message: error.message });
|
|
12084
12020
|
}
|
|
12085
|
-
if (
|
|
12021
|
+
if (import_react22.Children.count(children) === 0) {
|
|
12086
12022
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Loading, {});
|
|
12087
12023
|
}
|
|
12088
12024
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children });
|