@ultraviolet/plus 3.0.0-beta.16 → 3.0.0-beta.18
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/components/CodeEditor/CodeEditor.d.ts +1 -1
- package/dist/components/CodeEditor/CodeEditor.js +41 -11
- package/dist/components/ContentCard/Skeleton.d.ts +1 -1
- package/dist/components/ContentCard/Skeleton.js +13 -8
- package/dist/components/ContentCard/index.js +131 -51
- package/dist/components/ContentCardGroup/Card.js +63 -22
- package/dist/components/ContentCardGroup/SkeletonCard.d.ts +1 -1
- package/dist/components/ContentCardGroup/SkeletonCard.js +1 -1
- package/dist/components/ContentCardGroup/index.js +11 -6
- package/dist/components/ContentCardGroup/styles.css.js +1 -0
- package/dist/components/Conversation/index.d.ts +9 -9
- package/dist/components/Conversation/index.js +23 -6
- package/dist/components/CustomerSatisfaction/index.d.ts +1 -1
- package/dist/components/CustomerSatisfaction/index.js +68 -39
- package/dist/components/EstimateCost/Components/CustomUnitInput.d.ts +1 -1
- package/dist/components/EstimateCost/Components/CustomUnitInput.js +47 -27
- package/dist/components/EstimateCost/Components/Item.d.ts +1 -1
- package/dist/components/EstimateCost/Components/Item.js +303 -203
- package/dist/components/EstimateCost/Components/LineThrough.d.ts +1 -1
- package/dist/components/EstimateCost/Components/LineThrough.js +8 -2
- package/dist/components/EstimateCost/Components/NumberInput.d.ts +1 -1
- package/dist/components/EstimateCost/Components/NumberInput.js +17 -9
- package/dist/components/EstimateCost/Components/Region.d.ts +1 -1
- package/dist/components/EstimateCost/Components/Region.js +43 -25
- package/dist/components/EstimateCost/Components/Regular.d.ts +1 -1
- package/dist/components/EstimateCost/Components/Regular.js +20 -16
- package/dist/components/EstimateCost/Components/Strong.d.ts +1 -1
- package/dist/components/EstimateCost/Components/Strong.js +11 -10
- package/dist/components/EstimateCost/Components/Unit.d.ts +1 -1
- package/dist/components/EstimateCost/Components/Unit.js +20 -13
- package/dist/components/EstimateCost/Components/Zone.d.ts +1 -1
- package/dist/components/EstimateCost/Components/Zone.js +41 -24
- package/dist/components/EstimateCost/EstimateCost.d.ts +11 -11
- package/dist/components/EstimateCost/EstimateCost.js +61 -10
- package/dist/components/EstimateCost/EstimateCostContent.d.ts +1 -1
- package/dist/components/EstimateCost/EstimateCostContent.js +264 -120
- package/dist/components/EstimateCost/EstimateCostProvider.d.ts +1 -1
- package/dist/components/EstimateCost/EstimateCostProvider.js +24 -21
- package/dist/components/EstimateCost/OverlayComponent.d.ts +1 -1
- package/dist/components/EstimateCost/OverlayComponent.js +53 -41
- package/dist/components/EstimateCost/OverlayContext.d.ts +1 -1
- package/dist/components/EstimateCost/OverlayContext.js +2 -4
- package/dist/components/FAQ/index.d.ts +1 -1
- package/dist/components/FAQ/index.js +1 -1
- package/dist/components/InfoTable/InfoTable.d.ts +3 -3
- package/dist/components/InfoTable/InfoTable.js +10 -4
- package/dist/components/InfoTable/components/Cell.d.ts +1 -1
- package/dist/components/InfoTable/components/Cell.js +24 -4
- package/dist/components/InfoTable/components/Row.d.ts +1 -1
- package/dist/components/InfoTable/components/Row.js +16 -10
- package/dist/components/InfoTable/styles.css.d.ts +0 -1
- package/dist/components/InfoTable/styles.css.js +0 -2
- package/dist/components/Navigation/Footer.d.ts +1 -1
- package/dist/components/Navigation/Footer.js +34 -19
- package/dist/components/Navigation/Header.d.ts +1 -1
- package/dist/components/Navigation/Header.js +12 -9
- package/dist/components/Navigation/Navigation.d.ts +5 -5
- package/dist/components/Navigation/Navigation.js +2 -5
- package/dist/components/Navigation/NavigationContent.d.ts +1 -1
- package/dist/components/Navigation/NavigationContent.js +56 -18
- package/dist/components/Navigation/NavigationProvider.d.ts +1 -1
- package/dist/components/Navigation/NavigationProvider.js +108 -70
- package/dist/components/Navigation/components/Group.d.ts +1 -1
- package/dist/components/Navigation/components/Group.js +20 -19
- package/dist/components/Navigation/components/Item.d.ts +1 -1
- package/dist/components/Navigation/components/Item.js +551 -254
- package/dist/components/Navigation/components/ItemProvider.d.ts +1 -1
- package/dist/components/Navigation/components/ItemProvider.js +2 -4
- package/dist/components/Navigation/components/PinnedItems.d.ts +1 -1
- package/dist/components/Navigation/components/PinnedItems.js +91 -37
- package/dist/components/Navigation/components/Separator.d.ts +1 -1
- package/dist/components/Navigation/components/Separator.js +1 -1
- package/dist/components/Navigation/styles.css.js +0 -1
- package/dist/components/Navigation/variables.css.js +1 -0
- package/dist/components/OfferList/OfferList.d.ts +3 -3
- package/dist/components/OfferList/OfferList.js +41 -9
- package/dist/components/OfferList/OfferListProvider.d.ts +1 -1
- package/dist/components/OfferList/OfferListProvider.js +25 -15
- package/dist/components/OfferList/components/Banner.d.ts +1 -1
- package/dist/components/OfferList/components/Banner.js +30 -8
- package/dist/components/OfferList/components/Cell.d.ts +1 -1
- package/dist/components/OfferList/components/Cell.js +12 -5
- package/dist/components/OfferList/components/Row.d.ts +1 -1
- package/dist/components/OfferList/components/Row.js +135 -42
- package/dist/components/OrderSummary/NonScrollableContent.d.ts +1 -1
- package/dist/components/OrderSummary/NonScrollableContent.js +68 -22
- package/dist/components/OrderSummary/Provider.js +1 -4
- package/dist/components/OrderSummary/ScrollableContent.d.ts +1 -1
- package/dist/components/OrderSummary/ScrollableContent.js +174 -33
- package/dist/components/OrderSummary/constants.js +7 -1
- package/dist/components/OrderSummary/helpers.js +36 -18
- package/dist/components/OrderSummary/index.d.ts +1 -1
- package/dist/components/OrderSummary/index.js +135 -48
- package/dist/components/Plans/FeatureHint.d.ts +1 -1
- package/dist/components/Plans/FeatureHint.js +26 -8
- package/dist/components/Plans/PlanHeader.d.ts +1 -1
- package/dist/components/Plans/PlanHeader.js +79 -25
- package/dist/components/Plans/index.d.ts +1 -1
- package/dist/components/Plans/index.js +142 -53
- package/dist/components/Plans/styles.css.js +0 -1
- package/dist/components/SteppedListCard/Step.d.ts +1 -1
- package/dist/components/SteppedListCard/Step.js +42 -2
- package/dist/components/SteppedListCard/SteppedListCard.d.ts +2 -2
- package/dist/components/SteppedListCard/SteppedListCard.js +66 -19
- package/dist/components/SteppedListCard/SteppedListContent.d.ts +1 -1
- package/dist/components/SteppedListCard/SteppedListContent.js +13 -11
- package/dist/components/SteppedListCard/helper.js +3 -1
- package/dist/plus.css +1 -1
- package/package.json +6 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs, jsx, Fragment } from "
|
|
2
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { CalculatorIcon } from "@ultraviolet/icons";
|
|
4
4
|
import { Stack, Alert, Badge, Text } from "@ultraviolet/ui";
|
|
5
5
|
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
@@ -16,16 +16,27 @@ import { OverlayComponent } from "./OverlayComponent.js";
|
|
|
16
16
|
import { OverlayContextProvider } from "./OverlayContext.js";
|
|
17
17
|
import { estimateCostTable, estimateCostPriceColumn, estimateCostPriceCellContent, estimateCostPriceCell, estimateCostTimeCell, estimateCostEmptyTable, estimateCostEmptyCell, estimateCostCell, estimateCostTotalPriceCell, estimateCostBadgeBeta, estimateCostText, paddingLeftCell, estimatecostFeesText, estimateCostFeesTable, estimateCostTitle, estimateCostCalculatorIcon } from "./styles.css.js";
|
|
18
18
|
const DEFAULT_UNIT_LIST = ["hours", "days", "months"];
|
|
19
|
-
const DescriptionComponent = memo(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
const DescriptionComponent = memo(
|
|
20
|
+
({
|
|
21
|
+
description,
|
|
22
|
+
locales
|
|
23
|
+
}) => description === void 0 || typeof description === "string" ? /* @__PURE__ */ jsx(Text, { as: "span", variant: "body", children: description || locales["estimate.cost.description"] }) : description
|
|
24
|
+
);
|
|
25
|
+
const TitleComponent = memo(
|
|
26
|
+
({
|
|
27
|
+
locales
|
|
28
|
+
}) => /* @__PURE__ */ jsxs("h3", { className: estimateCostTitle, children: [
|
|
29
|
+
/* @__PURE__ */ jsx(
|
|
30
|
+
CalculatorIcon,
|
|
31
|
+
{
|
|
32
|
+
className: estimateCostCalculatorIcon,
|
|
33
|
+
sentiment: "primary",
|
|
34
|
+
size: "medium"
|
|
35
|
+
}
|
|
36
|
+
),
|
|
37
|
+
locales?.["estimate.cost.label"]
|
|
38
|
+
] })
|
|
39
|
+
);
|
|
29
40
|
const EstimateCostContent = ({
|
|
30
41
|
description,
|
|
31
42
|
alert,
|
|
@@ -55,9 +66,7 @@ const EstimateCostContent = ({
|
|
|
55
66
|
onTotalPriceChange,
|
|
56
67
|
style
|
|
57
68
|
}) => {
|
|
58
|
-
const {
|
|
59
|
-
formatNumber
|
|
60
|
-
} = useEstimateCost();
|
|
69
|
+
const { formatNumber } = useEstimateCost();
|
|
61
70
|
const [ref, inView] = useInView();
|
|
62
71
|
const [products, setProducts] = useState([]);
|
|
63
72
|
const [totalPrice, setTotalPrice] = useState({
|
|
@@ -73,130 +82,265 @@ const EstimateCostContent = ({
|
|
|
73
82
|
value: 1
|
|
74
83
|
});
|
|
75
84
|
const [isLongFractionDigits, setIsLongFractionDigits] = useState(false);
|
|
76
|
-
const providerValue = useMemo(() => ({
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
85
|
+
const providerValue = useMemo(() => ({ isOverlay: false }), []);
|
|
86
|
+
const totalValue = useMemo(
|
|
87
|
+
() => formatNumber(totalPrice.total < 0 ? 0 : totalPrice.total, {
|
|
88
|
+
maximumFractionDigits: isLongFractionDigits ? maximumFractionDigitsLong[iteration.unit] : maximumFractionDigits[iteration.unit]
|
|
89
|
+
}),
|
|
90
|
+
[formatNumber, isLongFractionDigits, iteration.unit, totalPrice.total]
|
|
91
|
+
);
|
|
92
|
+
const totalMaxValue = useMemo(
|
|
93
|
+
() => formatNumber(totalPrice.maxTotal < 0 ? 0 : totalPrice.maxTotal, {
|
|
94
|
+
maximumFractionDigits: isLongFractionDigits ? maximumFractionDigitsLong[iteration.unit] : maximumFractionDigits[iteration.unit]
|
|
95
|
+
}),
|
|
96
|
+
[formatNumber, isLongFractionDigits, iteration.unit, totalPrice.maxTotal]
|
|
97
|
+
);
|
|
98
|
+
const productsCallback = useMemo(
|
|
99
|
+
() => ({
|
|
100
|
+
add: (newProduct) => {
|
|
101
|
+
setProducts((total) => {
|
|
102
|
+
if (total.find((product) => product.id === newProduct.id)) {
|
|
103
|
+
return total.map(
|
|
104
|
+
(product) => product.id === newProduct.id ? newProduct : product
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
return [...total, newProduct];
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
remove: ({ id }) => {
|
|
111
|
+
setProducts((total) => total.filter((product) => product.id !== id));
|
|
112
|
+
}
|
|
113
|
+
}),
|
|
114
|
+
[setProducts]
|
|
115
|
+
);
|
|
100
116
|
useEffect(() => {
|
|
101
117
|
const isMaxAmountInProducts = products.find((product) => product.maxAmount);
|
|
102
|
-
setIsLongFractionDigits(
|
|
118
|
+
setIsLongFractionDigits(
|
|
119
|
+
!!products.find((product) => product.longFractionDigits)
|
|
120
|
+
);
|
|
103
121
|
setTotalPrice({
|
|
104
|
-
hourly: products.reduce(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
hourly: products.reduce(
|
|
123
|
+
(acc, product) => acc + (product.noIteration ? 0 : (product.price - product.price * product.discount) * Math.max(product.amount - product.amountFree, 0)),
|
|
124
|
+
0
|
|
125
|
+
),
|
|
126
|
+
maxHourly: isMaxAmountInProducts ? products.reduce(
|
|
127
|
+
(acc, product) => acc && product.noIteration ? 0 : (product.price - product.price * product.discount) * Math.max(product.maxAmount - product.amountFree, 0),
|
|
128
|
+
0
|
|
129
|
+
) : 0,
|
|
130
|
+
maxOverlayHourly: isMaxAmountInProducts ? products.reduce(
|
|
131
|
+
(acc, product) => acc + (product.noIteration ? 0 : (product.price - product.price * product.discount) * Math.max(product.maxAmount - product.amountFree, 0)),
|
|
132
|
+
0
|
|
133
|
+
) : 0,
|
|
134
|
+
maxTotal: isMaxAmountInProducts ? products.reduce(
|
|
135
|
+
(acc, product) => acc + calculatePrice({
|
|
136
|
+
amount: product.maxAmount || product.amount,
|
|
137
|
+
// Not all products have maxAmount, so we need to check both
|
|
138
|
+
amountFree: product.amountFree,
|
|
139
|
+
discount: product.discount,
|
|
140
|
+
price: product.price,
|
|
141
|
+
timeAmount: product.noIteration ? 1 : iteration.value,
|
|
142
|
+
timeUnit: product.noIteration ? "hours" : iteration.unit
|
|
143
|
+
}),
|
|
144
|
+
0
|
|
145
|
+
) : 0,
|
|
146
|
+
overlayHourly: products.reduce(
|
|
147
|
+
(acc, product) => acc + (product.noIteration ? 0 : (product.price - product.price * product.discount) * Math.max(product.amount - product.amountFree, 0)),
|
|
148
|
+
0
|
|
149
|
+
),
|
|
150
|
+
total: !hideTotal ? products.reduce(
|
|
151
|
+
(acc, product) => acc + calculatePrice({
|
|
152
|
+
amount: product.amount,
|
|
153
|
+
amountFree: product.amountFree,
|
|
154
|
+
discount: product.discount,
|
|
155
|
+
price: product.price,
|
|
156
|
+
timeAmount: product.noIteration ? 1 : iteration.value,
|
|
157
|
+
timeUnit: product.noIteration ? "hours" : iteration.unit
|
|
158
|
+
}),
|
|
159
|
+
0
|
|
160
|
+
) : 0
|
|
125
161
|
});
|
|
126
162
|
onTotalPriceChange?.({
|
|
127
163
|
total: totalPrice.total,
|
|
128
164
|
totalMax: totalPrice.maxTotal > 0 ? totalPrice.maxTotal : void 0
|
|
129
165
|
});
|
|
130
|
-
}, [
|
|
166
|
+
}, [
|
|
167
|
+
hideTotal,
|
|
168
|
+
products,
|
|
169
|
+
iteration,
|
|
170
|
+
setTotalPrice,
|
|
171
|
+
onTotalPriceChange,
|
|
172
|
+
totalPrice.total,
|
|
173
|
+
totalPrice.maxTotal,
|
|
174
|
+
totalValue,
|
|
175
|
+
totalMaxValue
|
|
176
|
+
]);
|
|
131
177
|
useEffect(() => {
|
|
132
178
|
if (hideTimeUnit && (iteration.value > 1 || iteration.unit !== (defaultTimeUnit ?? "hours"))) {
|
|
133
|
-
setIteration({
|
|
134
|
-
unit: defaultTimeUnit ?? "hours",
|
|
135
|
-
value: 1
|
|
136
|
-
});
|
|
179
|
+
setIteration({ unit: defaultTimeUnit ?? "hours", value: 1 });
|
|
137
180
|
}
|
|
138
181
|
}, [hideTimeUnit, iteration, defaultTimeUnit]);
|
|
139
182
|
return /* @__PURE__ */ jsxs(Stack, { gap: 2, style, children: [
|
|
140
|
-
!hideOverlay ? /* @__PURE__ */ jsx(
|
|
183
|
+
!hideOverlay ? /* @__PURE__ */ jsx(
|
|
184
|
+
OverlayComponent,
|
|
185
|
+
{
|
|
186
|
+
disableOverlayLeft,
|
|
187
|
+
disableOverlayRight,
|
|
188
|
+
discount,
|
|
189
|
+
inView,
|
|
190
|
+
isBeta,
|
|
191
|
+
OverlayLeft,
|
|
192
|
+
OverlayRight,
|
|
193
|
+
overlayMargin,
|
|
194
|
+
totalPrice,
|
|
195
|
+
unit: overlayUnit ?? "hours",
|
|
196
|
+
children
|
|
197
|
+
}
|
|
198
|
+
) : null,
|
|
141
199
|
description === false ? null : /* @__PURE__ */ jsx(DescriptionComponent, { description, locales }),
|
|
142
200
|
alert ? /* @__PURE__ */ jsx(Alert, { sentiment: alertVariant, title: alertTitle, children: alert }) : null,
|
|
143
201
|
/* @__PURE__ */ jsx(OverlayContextProvider, { value: providerValue, children: /* @__PURE__ */ jsxs("div", { children: [
|
|
144
|
-
children ? /* @__PURE__ */ jsxs(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
/* @__PURE__ */ jsx(
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
202
|
+
children ? /* @__PURE__ */ jsxs(
|
|
203
|
+
"table",
|
|
204
|
+
{
|
|
205
|
+
cellPadding: "0",
|
|
206
|
+
cellSpacing: "0",
|
|
207
|
+
className: estimateCostTable[hideTotal ? "noTotal" : "total"],
|
|
208
|
+
"data-testid": "summary",
|
|
209
|
+
ref,
|
|
210
|
+
children: [
|
|
211
|
+
/* @__PURE__ */ jsxs("colgroup", { children: [
|
|
212
|
+
/* @__PURE__ */ jsx("col", {}),
|
|
213
|
+
/* @__PURE__ */ jsx("col", { className: estimateCostPriceColumn })
|
|
214
|
+
] }),
|
|
215
|
+
!hideTimeUnit ? /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
216
|
+
/* @__PURE__ */ jsx("th", { children: /* @__PURE__ */ jsx(TitleComponent, { locales }) }),
|
|
217
|
+
/* @__PURE__ */ jsx(
|
|
218
|
+
"th",
|
|
219
|
+
{
|
|
220
|
+
className: `${estimateCostPriceCellContent} ${estimateCostPriceCell}`,
|
|
221
|
+
children: /* @__PURE__ */ jsx("div", { className: estimateCostTimeCell, children: /* @__PURE__ */ jsx(
|
|
222
|
+
CustomUnitInput,
|
|
223
|
+
{
|
|
224
|
+
defaultTimeUnit,
|
|
225
|
+
iteration,
|
|
226
|
+
setIteration,
|
|
227
|
+
timeUnits
|
|
228
|
+
}
|
|
229
|
+
) })
|
|
230
|
+
}
|
|
231
|
+
)
|
|
232
|
+
] }) }) : null,
|
|
233
|
+
/* @__PURE__ */ jsx("tbody", { children: Children.map(
|
|
234
|
+
children,
|
|
235
|
+
(child, index) => isValidElement(child) ? cloneElement(child, {
|
|
236
|
+
discount: discount && !child.props.discount ? discount : child.props.discount,
|
|
237
|
+
isLastElement: index === Children.count(children) - 1,
|
|
238
|
+
iteration,
|
|
239
|
+
productsCallback
|
|
240
|
+
}) : child
|
|
241
|
+
) })
|
|
242
|
+
]
|
|
243
|
+
}
|
|
244
|
+
) : null,
|
|
245
|
+
!hideTotal ? /* @__PURE__ */ jsxs(
|
|
246
|
+
"table",
|
|
247
|
+
{
|
|
248
|
+
cellPadding: "0",
|
|
249
|
+
cellSpacing: "0",
|
|
250
|
+
className: estimateCostEmptyTable,
|
|
251
|
+
children: [
|
|
252
|
+
/* @__PURE__ */ jsxs("colgroup", { children: [
|
|
253
|
+
/* @__PURE__ */ jsx("col", {}),
|
|
254
|
+
/* @__PURE__ */ jsx("col", { className: estimateCostPriceColumn })
|
|
255
|
+
] }),
|
|
256
|
+
/* @__PURE__ */ jsx("tbody", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
257
|
+
/* @__PURE__ */ jsx("td", { "aria-label": "control", className: estimateCostEmptyCell }),
|
|
258
|
+
/* @__PURE__ */ jsxs(
|
|
259
|
+
"td",
|
|
260
|
+
{
|
|
261
|
+
className: `${estimateCostCell({ hasBorder: false, primary: false })} ${estimateCostTotalPriceCell}`,
|
|
262
|
+
style: assignInlineVars({
|
|
263
|
+
[paddingLeftCell]: `16px`
|
|
264
|
+
}),
|
|
265
|
+
children: [
|
|
266
|
+
isBeta ? /* @__PURE__ */ jsx(
|
|
267
|
+
Badge,
|
|
268
|
+
{
|
|
269
|
+
className: estimateCostBadgeBeta[locales[`estimate.cost.beta.${discount > 0 ? "discount" : "free"}`].length > 25 ? "long" : "short"],
|
|
270
|
+
prominence: "strong",
|
|
271
|
+
sentiment: "warning",
|
|
272
|
+
children: `${discount > 0 ? discount * 100 : ""}
|
|
273
|
+
${locales[`estimate.cost.beta.${discount > 0 ? "discount" : "free"}`]}`
|
|
274
|
+
}
|
|
275
|
+
) : null,
|
|
276
|
+
/* @__PURE__ */ jsx(
|
|
277
|
+
Text,
|
|
278
|
+
{
|
|
279
|
+
as: "h3",
|
|
280
|
+
className: estimateCostText[isBeta ? "beta" : "notBeta"],
|
|
281
|
+
sentiment: "primary",
|
|
282
|
+
variant: "heading",
|
|
283
|
+
children: /* @__PURE__ */ jsxs(
|
|
284
|
+
LineThrough,
|
|
285
|
+
{
|
|
286
|
+
isActive: isBeta && (discount === 0 || discount >= 1),
|
|
287
|
+
children: [
|
|
288
|
+
totalValue,
|
|
289
|
+
totalPrice.maxTotal > 0 ? ` - ${totalMaxValue}` : null
|
|
290
|
+
]
|
|
291
|
+
}
|
|
292
|
+
)
|
|
293
|
+
}
|
|
294
|
+
),
|
|
295
|
+
hideHourlyPriceOnTotal && totalPrice.hourly > 0 && totalPrice.hourly !== totalPrice.total && totalPrice.total > 0 ? /* @__PURE__ */ jsx(Text, { as: "p", placement: "right", variant: "body", children: /* @__PURE__ */ jsxs(
|
|
296
|
+
LineThrough,
|
|
297
|
+
{
|
|
298
|
+
isActive: isBeta && (discount === 0 || discount >= 1),
|
|
299
|
+
children: [
|
|
300
|
+
formatNumber(totalPrice.hourly, {
|
|
301
|
+
maximumFractionDigits: isLongFractionDigits ? maximumFractionDigitsLong.hours : maximumFractionDigits.hours
|
|
302
|
+
}),
|
|
303
|
+
totalPrice.maxHourly > 0 ? ` - ${formatNumber(totalPrice.maxHourly, {
|
|
304
|
+
maximumFractionDigits: isLongFractionDigits ? maximumFractionDigitsLong.hours : maximumFractionDigits.hours
|
|
305
|
+
})}` : null,
|
|
306
|
+
"/",
|
|
307
|
+
locales[`estimate.cost.units.hours.label`].toLowerCase()
|
|
308
|
+
]
|
|
309
|
+
}
|
|
310
|
+
) }) : null
|
|
311
|
+
]
|
|
312
|
+
}
|
|
313
|
+
)
|
|
314
|
+
] }) })
|
|
315
|
+
]
|
|
316
|
+
}
|
|
317
|
+
) : null,
|
|
192
318
|
commitmentFees !== void 0 || monthlyFees !== void 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
193
|
-
/* @__PURE__ */ jsx(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
319
|
+
/* @__PURE__ */ jsx(
|
|
320
|
+
Text,
|
|
321
|
+
{
|
|
322
|
+
as: "h3",
|
|
323
|
+
className: estimatecostFeesText,
|
|
324
|
+
variant: "headingSmall",
|
|
325
|
+
children: locales[`estimate.cost.fees.${commitmentFees ? "oneTime" : "monthly"}.title`]
|
|
326
|
+
}
|
|
327
|
+
),
|
|
328
|
+
/* @__PURE__ */ jsx("table", { className: estimateCostFeesTable, children: /* @__PURE__ */ jsx("tbody", { children: /* @__PURE__ */ jsx(
|
|
329
|
+
Item,
|
|
330
|
+
{
|
|
331
|
+
isLastElement: true,
|
|
332
|
+
label: commitmentFees ? locales["estimate.cost.fees.commitment"] : monthlyFeesLabel,
|
|
333
|
+
noIteration: true,
|
|
334
|
+
price: commitmentFees || monthlyFees,
|
|
335
|
+
productsCallback: {
|
|
336
|
+
add: () => {
|
|
337
|
+
},
|
|
338
|
+
remove: () => {
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
children: commitmentFees ? commitmentFeesContent : monthlyFeesContent
|
|
198
342
|
}
|
|
199
|
-
|
|
343
|
+
) }) })
|
|
200
344
|
] }) : null
|
|
201
345
|
] }) })
|
|
202
346
|
] });
|
|
@@ -21,5 +21,5 @@ type FormatNumberOption = {
|
|
|
21
21
|
minimumSignificantDigits?: number;
|
|
22
22
|
maximumSignificantDigits?: number;
|
|
23
23
|
};
|
|
24
|
-
export declare const EstimateCostProvider: ({ children, locales, currency, numberLocales, }: EstimateCostProviderProps) => import("
|
|
24
|
+
export declare const EstimateCostProvider: ({ children, locales, currency, numberLocales, }: EstimateCostProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
25
|
export {};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx } from "
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useMemo, useCallback, createContext, useContext } from "react";
|
|
4
4
|
import EstimateCostLocales from "./locales/en.js";
|
|
5
|
-
const EstimateCostContext = createContext({
|
|
6
|
-
formatNumber: () => "",
|
|
7
|
-
locales: EstimateCostLocales
|
|
8
|
-
});
|
|
5
|
+
const EstimateCostContext = createContext({ formatNumber: () => "", locales: EstimateCostLocales });
|
|
9
6
|
const useEstimateCost = () => useContext(EstimateCostContext);
|
|
10
7
|
const EstimateCostProvider = ({
|
|
11
8
|
children,
|
|
@@ -13,22 +10,28 @@ const EstimateCostProvider = ({
|
|
|
13
10
|
currency,
|
|
14
11
|
numberLocales
|
|
15
12
|
}) => {
|
|
16
|
-
const newLocales = useMemo(
|
|
17
|
-
...EstimateCostLocales,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const formatNumber = useCallback(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
const newLocales = useMemo(
|
|
14
|
+
() => locales ? { ...EstimateCostLocales, ...locales } : EstimateCostLocales,
|
|
15
|
+
[locales]
|
|
16
|
+
);
|
|
17
|
+
const formatNumber = useCallback(
|
|
18
|
+
(number, options) => {
|
|
19
|
+
const numberFormat = new Intl.NumberFormat(numberLocales, {
|
|
20
|
+
currency,
|
|
21
|
+
style: "currency",
|
|
22
|
+
...options
|
|
23
|
+
});
|
|
24
|
+
return numberFormat.format(number);
|
|
25
|
+
},
|
|
26
|
+
[currency, numberLocales]
|
|
27
|
+
);
|
|
28
|
+
const value = useMemo(
|
|
29
|
+
() => ({
|
|
30
|
+
formatNumber,
|
|
31
|
+
locales: newLocales
|
|
32
|
+
}),
|
|
33
|
+
[formatNumber, newLocales]
|
|
34
|
+
);
|
|
32
35
|
return /* @__PURE__ */ jsx(EstimateCostContext.Provider, { value, children });
|
|
33
36
|
};
|
|
34
37
|
export {
|
|
@@ -22,5 +22,5 @@ type OverlayComponentProps = {
|
|
|
22
22
|
};
|
|
23
23
|
overlayMargin?: string;
|
|
24
24
|
};
|
|
25
|
-
export declare const OverlayComponent: ({ children, inView, discount, OverlayRight, disableOverlayRight, OverlayLeft, disableOverlayLeft, totalPrice, unit, isBeta, overlayMargin, }: OverlayComponentProps) => import("
|
|
25
|
+
export declare const OverlayComponent: ({ children, inView, discount, OverlayRight, disableOverlayRight, OverlayLeft, disableOverlayLeft, totalPrice, unit, isBeta, overlayMargin, }: OverlayComponentProps) => import("react/jsx-runtime").JSX.Element;
|
|
26
26
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx, jsxs } from "
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { CalculatorIcon } from "@ultraviolet/icons";
|
|
4
4
|
import { Stack, Badge } from "@ultraviolet/ui";
|
|
5
5
|
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
@@ -24,13 +24,8 @@ const OverlayComponent = ({
|
|
|
24
24
|
isBeta = false,
|
|
25
25
|
overlayMargin
|
|
26
26
|
}) => {
|
|
27
|
-
const {
|
|
28
|
-
|
|
29
|
-
formatNumber
|
|
30
|
-
} = useEstimateCost();
|
|
31
|
-
const value = useMemo(() => ({
|
|
32
|
-
isOverlay: true
|
|
33
|
-
}), []);
|
|
27
|
+
const { locales, formatNumber } = useEstimateCost();
|
|
28
|
+
const value = useMemo(() => ({ isOverlay: true }), []);
|
|
34
29
|
const totalOverlayPrice = {
|
|
35
30
|
days: totalPrice.maxOverlayHourly * multiplier.days,
|
|
36
31
|
hours: totalPrice.maxOverlayHourly,
|
|
@@ -45,40 +40,57 @@ const OverlayComponent = ({
|
|
|
45
40
|
months: totalPrice.overlayHourly * multiplier.months,
|
|
46
41
|
seconds: totalPrice.overlayHourly * multiplier.seconds
|
|
47
42
|
}[unit];
|
|
48
|
-
return /* @__PURE__ */ jsx(OverlayContextProvider, { value, children: /* @__PURE__ */ jsx(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
43
|
+
return /* @__PURE__ */ jsx(OverlayContextProvider, { value, children: /* @__PURE__ */ jsx(
|
|
44
|
+
"div",
|
|
45
|
+
{
|
|
46
|
+
className: estimateCostOverlayContainer({ inView }),
|
|
47
|
+
"data-testid": "summary-overlay",
|
|
48
|
+
style: assignInlineVars({
|
|
49
|
+
[overlayMarginVar]: overlayMargin ?? "0"
|
|
50
|
+
}),
|
|
51
|
+
children: /* @__PURE__ */ jsxs("ul", { className: estimateCostList, children: [
|
|
52
|
+
OverlayLeft ? /* @__PURE__ */ jsx("li", { className: estimateCostSideItem, children: /* @__PURE__ */ jsx(OverlayLeft, { disabled: disableOverlayLeft, children: locales["estimate.cost.submit.label"] }) }) : null,
|
|
53
|
+
Children.map(
|
|
54
|
+
children,
|
|
55
|
+
(child, index) => isValidElement(child) ? cloneElement(child, {
|
|
56
|
+
isFirstElement: index === 0,
|
|
57
|
+
isLastElement: index === Children.count(children) - 1
|
|
58
|
+
}) : null
|
|
59
|
+
),
|
|
60
|
+
/* @__PURE__ */ jsxs("li", { className: estimateCostOverlayRow(), children: [
|
|
61
|
+
/* @__PURE__ */ jsxs(Stack, { alignItems: "center", direction: "row", gap: 1, children: [
|
|
62
|
+
/* @__PURE__ */ jsx(CalculatorIcon, { sentiment: "primary", size: "medium" }),
|
|
63
|
+
locales["estimate.cost.label"]
|
|
64
|
+
] }),
|
|
65
|
+
/* @__PURE__ */ jsxs("div", { className: estimateCostResourceName(), children: [
|
|
66
|
+
/* @__PURE__ */ jsx(Strong, { variant: "big", children: /* @__PURE__ */ jsxs(LineThrough, { isActive: isBeta && discount === 0, children: [
|
|
67
|
+
formatNumber(overlayPrice, {
|
|
68
|
+
maximumFractionDigits: maximumFractionDigits[unit]
|
|
69
|
+
}),
|
|
70
|
+
totalOverlayPrice > 0 ? ` - ${formatNumber(totalOverlayPrice, {
|
|
71
|
+
maximumFractionDigits: maximumFractionDigits[unit]
|
|
72
|
+
})}` : null,
|
|
73
|
+
"/",
|
|
74
|
+
locales[`estimate.cost.units.${unit}.label`]
|
|
75
|
+
] }) }),
|
|
76
|
+
isBeta ? /* @__PURE__ */ jsxs(
|
|
77
|
+
Badge,
|
|
78
|
+
{
|
|
79
|
+
className: estimateCostBadge,
|
|
80
|
+
prominence: "strong",
|
|
81
|
+
sentiment: "warning",
|
|
82
|
+
children: [
|
|
83
|
+
discount > 0 ? discount * 100 : "",
|
|
84
|
+
locales[`estimate.cost.beta.${discount > 0 ? "discount" : "free"}`]
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
) : null
|
|
88
|
+
] })
|
|
89
|
+
] }),
|
|
90
|
+
OverlayRight ? /* @__PURE__ */ jsx("li", { className: estimateCostSideItem, children: /* @__PURE__ */ jsx(OverlayRight, { disabled: disableOverlayRight, children: locales["estimate.cost.submit.label"] }) }) : null
|
|
78
91
|
] })
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
] }) }) });
|
|
92
|
+
}
|
|
93
|
+
) });
|
|
82
94
|
};
|
|
83
95
|
export {
|
|
84
96
|
OverlayComponent
|
|
@@ -8,5 +8,5 @@ type OverlayContextProviderProps = {
|
|
|
8
8
|
isOverlay: boolean;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
-
export declare const OverlayContextProvider: ({ children, value, }: OverlayContextProviderProps) => import("
|
|
11
|
+
export declare const OverlayContextProvider: ({ children, value, }: OverlayContextProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
export {};
|