@schematichq/schematic-components 0.3.11 → 0.3.12
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.
|
@@ -8936,7 +8936,7 @@ var EmbedProvider = ({
|
|
|
8936
8936
|
(0, import_react2.useEffect)(() => {
|
|
8937
8937
|
if (accessToken) {
|
|
8938
8938
|
const { headers = {} } = apiConfig ?? {};
|
|
8939
|
-
headers["X-Schematic-Components-Version"] = "0.3.
|
|
8939
|
+
headers["X-Schematic-Components-Version"] = "0.3.12";
|
|
8940
8940
|
headers["X-Schematic-Session-ID"] = sessionIdRef.current;
|
|
8941
8941
|
const config = new Configuration({
|
|
8942
8942
|
...apiConfig,
|
|
@@ -11207,7 +11207,9 @@ function resolveDesignProps2(props) {
|
|
|
11207
11207
|
};
|
|
11208
11208
|
}
|
|
11209
11209
|
function formatInvoices(invoices) {
|
|
11210
|
-
return (invoices || []).
|
|
11210
|
+
return (invoices || []).filter(
|
|
11211
|
+
({ url, amountDue, amountPaid }) => url && (amountDue === 0 || amountPaid > 0)
|
|
11212
|
+
).sort((a2, b2) => a2.dueDate && b2.dueDate ? +b2.dueDate - +a2.dueDate : 1).map(({ amountDue, dueDate, url }) => ({
|
|
11211
11213
|
...dueDate && { date: toPrettyDate(dueDate) },
|
|
11212
11214
|
amount: formatCurrency(amountDue),
|
|
11213
11215
|
url
|
|
@@ -11218,26 +11220,34 @@ var InvoiceDate = ({ date, fontStyle, url }) => {
|
|
|
11218
11220
|
const dateText = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
11219
11221
|
Text,
|
|
11220
11222
|
{
|
|
11223
|
+
...url && { onClick: () => {
|
|
11224
|
+
} },
|
|
11221
11225
|
$font: theme.typography[fontStyle].fontFamily,
|
|
11222
11226
|
$size: theme.typography[fontStyle].fontSize,
|
|
11223
11227
|
$weight: theme.typography[fontStyle].fontWeight,
|
|
11224
|
-
$color: theme.typography
|
|
11228
|
+
$color: url ? theme.typography.link.color : theme.typography.text.color,
|
|
11225
11229
|
children: date
|
|
11226
11230
|
}
|
|
11227
11231
|
);
|
|
11228
11232
|
if (url) {
|
|
11229
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("a", { href: url, target: "_blank", children: dateText });
|
|
11233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("a", { href: url, target: "_blank", children: dateText });
|
|
11230
11234
|
}
|
|
11231
11235
|
return dateText;
|
|
11232
11236
|
};
|
|
11233
|
-
var Invoices = (0, import_react15.forwardRef)(({ className, ...rest }, ref) => {
|
|
11237
|
+
var Invoices = (0, import_react15.forwardRef)(({ className, data, ...rest }, ref) => {
|
|
11234
11238
|
const props = resolveDesignProps2(rest);
|
|
11235
11239
|
const theme = nt();
|
|
11236
11240
|
const { api } = useEmbed();
|
|
11237
|
-
const [invoices, setInvoices] = (0, import_react15.useState)(() => formatInvoices(
|
|
11241
|
+
const [invoices, setInvoices] = (0, import_react15.useState)(() => formatInvoices(data));
|
|
11242
|
+
const [listSize, setListSize] = (0, import_react15.useState)(props.limit.number);
|
|
11243
|
+
const toggleListSize = () => {
|
|
11244
|
+
setListSize(
|
|
11245
|
+
(prev2) => prev2 !== props.limit.number ? props.limit.number : 12
|
|
11246
|
+
);
|
|
11247
|
+
};
|
|
11238
11248
|
(0, import_react15.useEffect)(() => {
|
|
11239
|
-
api?.listInvoices().then(({ data }) => {
|
|
11240
|
-
setInvoices(formatInvoices(
|
|
11249
|
+
api?.listInvoices().then(({ data: data2 }) => {
|
|
11250
|
+
setInvoices(formatInvoices(data2));
|
|
11241
11251
|
});
|
|
11242
11252
|
}, [api]);
|
|
11243
11253
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Element, { ref, className, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Flex, { $flexDirection: "column", $gap: "1rem", children: [
|
|
@@ -11251,10 +11261,7 @@ var Invoices = (0, import_react15.forwardRef)(({ className, ...rest }, ref) => {
|
|
|
11251
11261
|
children: "Invoices"
|
|
11252
11262
|
}
|
|
11253
11263
|
) }),
|
|
11254
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Flex, { $flexDirection: "column", $gap: "0.5rem", children: invoices.slice(
|
|
11255
|
-
0,
|
|
11256
|
-
props.limit.isVisible && props.limit.number || invoices.length
|
|
11257
|
-
).map(({ date, amount, url }, index) => {
|
|
11264
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Flex, { $flexDirection: "column", $gap: "0.5rem", children: invoices.slice(0, listSize).map(({ date, amount, url }, index) => {
|
|
11258
11265
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Flex, { $justifyContent: "space-between", children: [
|
|
11259
11266
|
props.date.isVisible && date && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
11260
11267
|
InvoiceDate,
|
|
@@ -11277,15 +11284,25 @@ var Invoices = (0, import_react15.forwardRef)(({ className, ...rest }, ref) => {
|
|
|
11277
11284
|
] }, index);
|
|
11278
11285
|
}) }),
|
|
11279
11286
|
props.collapse.isVisible && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Flex, { $alignItems: "center", $gap: "0.5rem", children: [
|
|
11280
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon2, { name: "chevron-down", style: { color: "#D0D0D0" } }),
|
|
11281
11287
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
11288
|
+
Icon2,
|
|
11289
|
+
{
|
|
11290
|
+
name: `chevron-${listSize === props.limit.number ? "down" : "up"}`,
|
|
11291
|
+
style: { color: "#D0D0D0" }
|
|
11292
|
+
}
|
|
11293
|
+
),
|
|
11294
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
11282
11295
|
Text,
|
|
11283
11296
|
{
|
|
11297
|
+
onClick: toggleListSize,
|
|
11284
11298
|
$font: theme.typography[props.collapse.fontStyle].fontFamily,
|
|
11285
11299
|
$size: theme.typography[props.collapse.fontStyle].fontSize,
|
|
11286
11300
|
$weight: theme.typography[props.collapse.fontStyle].fontWeight,
|
|
11287
11301
|
$color: theme.typography[props.collapse.fontStyle].color,
|
|
11288
|
-
children:
|
|
11302
|
+
children: [
|
|
11303
|
+
"See ",
|
|
11304
|
+
listSize === props.limit.number ? "more" : "less"
|
|
11305
|
+
]
|
|
11289
11306
|
}
|
|
11290
11307
|
)
|
|
11291
11308
|
] })
|
|
@@ -11984,7 +12001,7 @@ var UpcomingBill = (0, import_react20.forwardRef)(({ className, ...rest }, ref)
|
|
|
11984
12001
|
const { upcomingInvoice } = (0, import_react20.useMemo)(() => {
|
|
11985
12002
|
return {
|
|
11986
12003
|
upcomingInvoice: {
|
|
11987
|
-
...data.upcomingInvoice?.amountDue && {
|
|
12004
|
+
...typeof data.upcomingInvoice?.amountDue === "number" && {
|
|
11988
12005
|
amountDue: data.upcomingInvoice.amountDue
|
|
11989
12006
|
},
|
|
11990
12007
|
...data.subscription?.interval && {
|
|
@@ -11996,11 +12013,11 @@ var UpcomingBill = (0, import_react20.forwardRef)(({ className, ...rest }, ref)
|
|
|
11996
12013
|
}
|
|
11997
12014
|
};
|
|
11998
12015
|
}, [data.subscription, data.upcomingInvoice]);
|
|
11999
|
-
if (
|
|
12016
|
+
if (typeof upcomingInvoice.amountDue !== "number" || !upcomingInvoice.dueDate) {
|
|
12000
12017
|
return null;
|
|
12001
12018
|
}
|
|
12002
12019
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(Element, { ref, className, children: [
|
|
12003
|
-
props.header.isVisible &&
|
|
12020
|
+
props.header.isVisible && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
12004
12021
|
Flex,
|
|
12005
12022
|
{
|
|
12006
12023
|
$justifyContent: "space-between",
|
|
@@ -12022,7 +12039,7 @@ var UpcomingBill = (0, import_react20.forwardRef)(({ className, ...rest }, ref)
|
|
|
12022
12039
|
)
|
|
12023
12040
|
}
|
|
12024
12041
|
),
|
|
12025
|
-
|
|
12042
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(Flex, { $justifyContent: "space-between", $alignItems: "start", $gap: "1rem", children: [
|
|
12026
12043
|
props.price.isVisible && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Flex, { $alignItems: "end", $flexGrow: "1", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
12027
12044
|
Text,
|
|
12028
12045
|
{
|
|
@@ -12063,7 +12080,8 @@ var components = {
|
|
|
12063
12080
|
IncludedFeatures,
|
|
12064
12081
|
MeteredFeatures,
|
|
12065
12082
|
UpcomingBill,
|
|
12066
|
-
PaymentMethod
|
|
12083
|
+
PaymentMethod,
|
|
12084
|
+
Invoices
|
|
12067
12085
|
};
|
|
12068
12086
|
function createRenderer(options) {
|
|
12069
12087
|
const { useFallback = false } = options || {};
|
|
@@ -2400,7 +2400,7 @@ declare interface InvoiceResponseData {
|
|
|
2400
2400
|
url?: string | null;
|
|
2401
2401
|
}
|
|
2402
2402
|
|
|
2403
|
-
export declare const Invoices: ForwardRefExoticComponent<ElementProps & DesignProps_2 & {
|
|
2403
|
+
export declare const Invoices: ForwardRefExoticComponent<ElementProps & RecursivePartial<DesignProps_2> & {
|
|
2404
2404
|
data?: ListInvoicesResponse["data"];
|
|
2405
2405
|
} & HTMLAttributes<HTMLDivElement> & RefAttributes<HTMLDivElement | null>>;
|
|
2406
2406
|
|
|
@@ -8896,7 +8896,7 @@ var EmbedProvider = ({
|
|
|
8896
8896
|
useEffect(() => {
|
|
8897
8897
|
if (accessToken) {
|
|
8898
8898
|
const { headers = {} } = apiConfig ?? {};
|
|
8899
|
-
headers["X-Schematic-Components-Version"] = "0.3.
|
|
8899
|
+
headers["X-Schematic-Components-Version"] = "0.3.12";
|
|
8900
8900
|
headers["X-Schematic-Session-ID"] = sessionIdRef.current;
|
|
8901
8901
|
const config = new Configuration({
|
|
8902
8902
|
...apiConfig,
|
|
@@ -11167,7 +11167,9 @@ function resolveDesignProps2(props) {
|
|
|
11167
11167
|
};
|
|
11168
11168
|
}
|
|
11169
11169
|
function formatInvoices(invoices) {
|
|
11170
|
-
return (invoices || []).
|
|
11170
|
+
return (invoices || []).filter(
|
|
11171
|
+
({ url, amountDue, amountPaid }) => url && (amountDue === 0 || amountPaid > 0)
|
|
11172
|
+
).sort((a2, b2) => a2.dueDate && b2.dueDate ? +b2.dueDate - +a2.dueDate : 1).map(({ amountDue, dueDate, url }) => ({
|
|
11171
11173
|
...dueDate && { date: toPrettyDate(dueDate) },
|
|
11172
11174
|
amount: formatCurrency(amountDue),
|
|
11173
11175
|
url
|
|
@@ -11178,26 +11180,34 @@ var InvoiceDate = ({ date, fontStyle, url }) => {
|
|
|
11178
11180
|
const dateText = /* @__PURE__ */ jsx16(
|
|
11179
11181
|
Text,
|
|
11180
11182
|
{
|
|
11183
|
+
...url && { onClick: () => {
|
|
11184
|
+
} },
|
|
11181
11185
|
$font: theme.typography[fontStyle].fontFamily,
|
|
11182
11186
|
$size: theme.typography[fontStyle].fontSize,
|
|
11183
11187
|
$weight: theme.typography[fontStyle].fontWeight,
|
|
11184
|
-
$color: theme.typography
|
|
11188
|
+
$color: url ? theme.typography.link.color : theme.typography.text.color,
|
|
11185
11189
|
children: date
|
|
11186
11190
|
}
|
|
11187
11191
|
);
|
|
11188
11192
|
if (url) {
|
|
11189
|
-
/* @__PURE__ */ jsx16("a", { href: url, target: "_blank", children: dateText });
|
|
11193
|
+
return /* @__PURE__ */ jsx16("a", { href: url, target: "_blank", children: dateText });
|
|
11190
11194
|
}
|
|
11191
11195
|
return dateText;
|
|
11192
11196
|
};
|
|
11193
|
-
var Invoices = forwardRef6(({ className, ...rest }, ref) => {
|
|
11197
|
+
var Invoices = forwardRef6(({ className, data, ...rest }, ref) => {
|
|
11194
11198
|
const props = resolveDesignProps2(rest);
|
|
11195
11199
|
const theme = nt();
|
|
11196
11200
|
const { api } = useEmbed();
|
|
11197
|
-
const [invoices, setInvoices] = useState5(() => formatInvoices(
|
|
11201
|
+
const [invoices, setInvoices] = useState5(() => formatInvoices(data));
|
|
11202
|
+
const [listSize, setListSize] = useState5(props.limit.number);
|
|
11203
|
+
const toggleListSize = () => {
|
|
11204
|
+
setListSize(
|
|
11205
|
+
(prev2) => prev2 !== props.limit.number ? props.limit.number : 12
|
|
11206
|
+
);
|
|
11207
|
+
};
|
|
11198
11208
|
useEffect5(() => {
|
|
11199
|
-
api?.listInvoices().then(({ data }) => {
|
|
11200
|
-
setInvoices(formatInvoices(
|
|
11209
|
+
api?.listInvoices().then(({ data: data2 }) => {
|
|
11210
|
+
setInvoices(formatInvoices(data2));
|
|
11201
11211
|
});
|
|
11202
11212
|
}, [api]);
|
|
11203
11213
|
return /* @__PURE__ */ jsx16(Element, { ref, className, children: /* @__PURE__ */ jsxs9(Flex, { $flexDirection: "column", $gap: "1rem", children: [
|
|
@@ -11211,10 +11221,7 @@ var Invoices = forwardRef6(({ className, ...rest }, ref) => {
|
|
|
11211
11221
|
children: "Invoices"
|
|
11212
11222
|
}
|
|
11213
11223
|
) }),
|
|
11214
|
-
/* @__PURE__ */ jsx16(Flex, { $flexDirection: "column", $gap: "0.5rem", children: invoices.slice(
|
|
11215
|
-
0,
|
|
11216
|
-
props.limit.isVisible && props.limit.number || invoices.length
|
|
11217
|
-
).map(({ date, amount, url }, index) => {
|
|
11224
|
+
/* @__PURE__ */ jsx16(Flex, { $flexDirection: "column", $gap: "0.5rem", children: invoices.slice(0, listSize).map(({ date, amount, url }, index) => {
|
|
11218
11225
|
return /* @__PURE__ */ jsxs9(Flex, { $justifyContent: "space-between", children: [
|
|
11219
11226
|
props.date.isVisible && date && /* @__PURE__ */ jsx16(
|
|
11220
11227
|
InvoiceDate,
|
|
@@ -11237,15 +11244,25 @@ var Invoices = forwardRef6(({ className, ...rest }, ref) => {
|
|
|
11237
11244
|
] }, index);
|
|
11238
11245
|
}) }),
|
|
11239
11246
|
props.collapse.isVisible && /* @__PURE__ */ jsxs9(Flex, { $alignItems: "center", $gap: "0.5rem", children: [
|
|
11240
|
-
/* @__PURE__ */ jsx16(Icon2, { name: "chevron-down", style: { color: "#D0D0D0" } }),
|
|
11241
11247
|
/* @__PURE__ */ jsx16(
|
|
11248
|
+
Icon2,
|
|
11249
|
+
{
|
|
11250
|
+
name: `chevron-${listSize === props.limit.number ? "down" : "up"}`,
|
|
11251
|
+
style: { color: "#D0D0D0" }
|
|
11252
|
+
}
|
|
11253
|
+
),
|
|
11254
|
+
/* @__PURE__ */ jsxs9(
|
|
11242
11255
|
Text,
|
|
11243
11256
|
{
|
|
11257
|
+
onClick: toggleListSize,
|
|
11244
11258
|
$font: theme.typography[props.collapse.fontStyle].fontFamily,
|
|
11245
11259
|
$size: theme.typography[props.collapse.fontStyle].fontSize,
|
|
11246
11260
|
$weight: theme.typography[props.collapse.fontStyle].fontWeight,
|
|
11247
11261
|
$color: theme.typography[props.collapse.fontStyle].color,
|
|
11248
|
-
children:
|
|
11262
|
+
children: [
|
|
11263
|
+
"See ",
|
|
11264
|
+
listSize === props.limit.number ? "more" : "less"
|
|
11265
|
+
]
|
|
11249
11266
|
}
|
|
11250
11267
|
)
|
|
11251
11268
|
] })
|
|
@@ -11948,7 +11965,7 @@ var UpcomingBill = forwardRef10(({ className, ...rest }, ref) => {
|
|
|
11948
11965
|
const { upcomingInvoice } = useMemo4(() => {
|
|
11949
11966
|
return {
|
|
11950
11967
|
upcomingInvoice: {
|
|
11951
|
-
...data.upcomingInvoice?.amountDue && {
|
|
11968
|
+
...typeof data.upcomingInvoice?.amountDue === "number" && {
|
|
11952
11969
|
amountDue: data.upcomingInvoice.amountDue
|
|
11953
11970
|
},
|
|
11954
11971
|
...data.subscription?.interval && {
|
|
@@ -11960,11 +11977,11 @@ var UpcomingBill = forwardRef10(({ className, ...rest }, ref) => {
|
|
|
11960
11977
|
}
|
|
11961
11978
|
};
|
|
11962
11979
|
}, [data.subscription, data.upcomingInvoice]);
|
|
11963
|
-
if (
|
|
11980
|
+
if (typeof upcomingInvoice.amountDue !== "number" || !upcomingInvoice.dueDate) {
|
|
11964
11981
|
return null;
|
|
11965
11982
|
}
|
|
11966
11983
|
return /* @__PURE__ */ jsxs14(Element, { ref, className, children: [
|
|
11967
|
-
props.header.isVisible &&
|
|
11984
|
+
props.header.isVisible && /* @__PURE__ */ jsx21(
|
|
11968
11985
|
Flex,
|
|
11969
11986
|
{
|
|
11970
11987
|
$justifyContent: "space-between",
|
|
@@ -11986,7 +12003,7 @@ var UpcomingBill = forwardRef10(({ className, ...rest }, ref) => {
|
|
|
11986
12003
|
)
|
|
11987
12004
|
}
|
|
11988
12005
|
),
|
|
11989
|
-
|
|
12006
|
+
/* @__PURE__ */ jsxs14(Flex, { $justifyContent: "space-between", $alignItems: "start", $gap: "1rem", children: [
|
|
11990
12007
|
props.price.isVisible && /* @__PURE__ */ jsx21(Flex, { $alignItems: "end", $flexGrow: "1", children: /* @__PURE__ */ jsx21(
|
|
11991
12008
|
Text,
|
|
11992
12009
|
{
|
|
@@ -12027,7 +12044,8 @@ var components = {
|
|
|
12027
12044
|
IncludedFeatures,
|
|
12028
12045
|
MeteredFeatures,
|
|
12029
12046
|
UpcomingBill,
|
|
12030
|
-
PaymentMethod
|
|
12047
|
+
PaymentMethod,
|
|
12048
|
+
Invoices
|
|
12031
12049
|
};
|
|
12032
12050
|
function createRenderer(options) {
|
|
12033
12051
|
const { useFallback = false } = options || {};
|