@ultraviolet/plus 3.0.0-beta.14 → 3.0.0-beta.16
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/ContentCard/styles.css.js +0 -1
- package/dist/components/EstimateCost/Components/components.css.js +1 -0
- package/dist/components/InfoTable/components/Cell.js +2 -2
- package/dist/components/InfoTable/styles.css.d.ts +1 -0
- package/dist/components/InfoTable/styles.css.js +2 -0
- package/dist/components/OfferList/OfferList.d.ts +1 -0
- package/dist/components/OfferList/components/Row.d.ts +1 -0
- package/dist/components/OfferList/components/Row.js +1 -1
- package/dist/components/Plans/styles.css.js +1 -0
- package/dist/components/SteppedListCard/Step.d.ts +6 -1
- package/dist/components/SteppedListCard/Step.js +2 -1
- package/dist/components/SteppedListCard/SteppedListCard.d.ts +5 -2
- package/dist/components/SteppedListCard/SteppedListCard.js +10 -6
- package/dist/components/SteppedListCard/SteppedListContent.d.ts +1 -1
- package/dist/components/SteppedListCard/helper.d.ts +1 -1
- package/dist/components/SteppedListCard/helper.js +2 -1
- package/dist/components/SteppedListCard/styles.css.d.ts +1 -0
- package/dist/components/SteppedListCard/styles.css.js +2 -0
- package/dist/plus.css +1 -1
- package/package.json +8 -12
- package/dist/components/CodeEditor/CodeEditor.cjs +0 -50
- package/dist/components/CodeEditor/styles.css.cjs +0 -9
- package/dist/components/ContentCard/Skeleton.cjs +0 -23
- package/dist/components/ContentCard/index.cjs +0 -62
- package/dist/components/ContentCard/styles.css.cjs +0 -28
- package/dist/components/ContentCardGroup/Card.cjs +0 -30
- package/dist/components/ContentCardGroup/SkeletonCard.cjs +0 -15
- package/dist/components/ContentCardGroup/index.cjs +0 -18
- package/dist/components/ContentCardGroup/styles.css.cjs +0 -17
- package/dist/components/Conversation/index.cjs +0 -42
- package/dist/components/Conversation/styles.css.cjs +0 -17
- package/dist/components/CustomerSatisfaction/assets/1-5.svg.cjs +0 -3
- package/dist/components/CustomerSatisfaction/assets/1-5NB.svg.cjs +0 -3
- package/dist/components/CustomerSatisfaction/assets/2-5.svg.cjs +0 -3
- package/dist/components/CustomerSatisfaction/assets/2-5NB.svg.cjs +0 -3
- package/dist/components/CustomerSatisfaction/assets/3-5.svg.cjs +0 -3
- package/dist/components/CustomerSatisfaction/assets/3-5NB.svg.cjs +0 -3
- package/dist/components/CustomerSatisfaction/assets/4-5.svg.cjs +0 -3
- package/dist/components/CustomerSatisfaction/assets/4-5NB.svg.cjs +0 -3
- package/dist/components/CustomerSatisfaction/assets/5-5.svg.cjs +0 -3
- package/dist/components/CustomerSatisfaction/assets/5-5NB.svg.cjs +0 -3
- package/dist/components/CustomerSatisfaction/index.cjs +0 -66
- package/dist/components/CustomerSatisfaction/styles.css.cjs +0 -6
- package/dist/components/EstimateCost/Components/CustomUnitInput.cjs +0 -34
- package/dist/components/EstimateCost/Components/Item.cjs +0 -221
- package/dist/components/EstimateCost/Components/LineThrough.cjs +0 -11
- package/dist/components/EstimateCost/Components/NumberInput.cjs +0 -31
- package/dist/components/EstimateCost/Components/Region.cjs +0 -34
- package/dist/components/EstimateCost/Components/Regular.cjs +0 -23
- package/dist/components/EstimateCost/Components/Strong.cjs +0 -16
- package/dist/components/EstimateCost/Components/Unit.cjs +0 -36
- package/dist/components/EstimateCost/Components/Zone.cjs +0 -33
- package/dist/components/EstimateCost/Components/components.css.cjs +0 -123
- package/dist/components/EstimateCost/EstimateCost.cjs +0 -86
- package/dist/components/EstimateCost/EstimateCostContent.cjs +0 -206
- package/dist/components/EstimateCost/EstimateCostProvider.cjs +0 -37
- package/dist/components/EstimateCost/OverlayComponent.cjs +0 -85
- package/dist/components/EstimateCost/OverlayContext.cjs +0 -15
- package/dist/components/EstimateCost/constants.cjs +0 -28
- package/dist/components/EstimateCost/helper.cjs +0 -16
- package/dist/components/EstimateCost/locales/en.cjs +0 -23
- package/dist/components/EstimateCost/styles.css.cjs +0 -50
- package/dist/components/FAQ/index.cjs +0 -49
- package/dist/components/FAQ/styles.css.cjs +0 -5
- package/dist/components/InfoTable/InfoTable.cjs +0 -20
- package/dist/components/InfoTable/components/Cell.cjs +0 -16
- package/dist/components/InfoTable/components/Row.cjs +0 -25
- package/dist/components/InfoTable/context.cjs +0 -5
- package/dist/components/InfoTable/styles.css.cjs +0 -15
- package/dist/components/Navigation/Footer.cjs +0 -56
- package/dist/components/Navigation/Header.cjs +0 -18
- package/dist/components/Navigation/Navigation.cjs +0 -18
- package/dist/components/Navigation/NavigationContent.cjs +0 -112
- package/dist/components/Navigation/NavigationProvider.cjs +0 -129
- package/dist/components/Navigation/components/Group.cjs +0 -37
- package/dist/components/Navigation/components/Item.cjs +0 -277
- package/dist/components/Navigation/components/ItemProvider.cjs +0 -14
- package/dist/components/Navigation/components/PinnedItems.cjs +0 -80
- package/dist/components/Navigation/components/Separator.cjs +0 -8
- package/dist/components/Navigation/components/items.css.cjs +0 -47
- package/dist/components/Navigation/components/styles.css.cjs +0 -17
- package/dist/components/Navigation/constants.cjs +0 -10
- package/dist/components/Navigation/locales/en.cjs +0 -11
- package/dist/components/Navigation/styles.css.cjs +0 -23
- package/dist/components/Navigation/variables.css.cjs +0 -4
- package/dist/components/OfferList/OfferList.cjs +0 -45
- package/dist/components/OfferList/OfferListProvider.cjs +0 -38
- package/dist/components/OfferList/components/Banner.cjs +0 -21
- package/dist/components/OfferList/components/Cell.cjs +0 -20
- package/dist/components/OfferList/components/Row.cjs +0 -113
- package/dist/components/OfferList/styles.css.cjs +0 -38
- package/dist/components/OrderSummary/NonScrollableContent.cjs +0 -56
- package/dist/components/OrderSummary/Provider.cjs +0 -18
- package/dist/components/OrderSummary/ScrollableContent.cjs +0 -73
- package/dist/components/OrderSummary/constants.cjs +0 -12
- package/dist/components/OrderSummary/helpers.cjs +0 -91
- package/dist/components/OrderSummary/index.cjs +0 -102
- package/dist/components/OrderSummary/locales/en.cjs +0 -11
- package/dist/components/OrderSummary/styles.css.cjs +0 -19
- package/dist/components/Plans/FeatureHint.cjs +0 -24
- package/dist/components/Plans/PlanHeader.cjs +0 -42
- package/dist/components/Plans/index.cjs +0 -102
- package/dist/components/Plans/locales/en.cjs +0 -7
- package/dist/components/Plans/styles.css.cjs +0 -26
- package/dist/components/SteppedListCard/Step.cjs +0 -20
- package/dist/components/SteppedListCard/SteppedListCard.cjs +0 -54
- package/dist/components/SteppedListCard/SteppedListContent.cjs +0 -51
- package/dist/components/SteppedListCard/helper.cjs +0 -38
- package/dist/components/SteppedListCard/styles.css.cjs +0 -17
- package/dist/index.cjs +0 -33
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
;/* empty css */
|
|
4
|
-
;/* empty css */
|
|
5
|
-
const createRuntimeFn = require("@vanilla-extract/recipes/createRuntimeFn");
|
|
6
|
-
var navigationStickyFooter = createRuntimeFn.createRuntimeFn({ defaultClassName: "uv_plus_19x50fv0", variantClassNames: { overflow: { false: "uv_plus_19x50fv1" } }, defaultVariants: { overflow: false }, compoundVariants: [] });
|
|
7
|
-
var navigationHeader = "uv_plus_19x50fv2";
|
|
8
|
-
var navigationLogoContainer = "uv_plus_19x50fv3";
|
|
9
|
-
var navigation = "uv_plus_19x50fv4";
|
|
10
|
-
var navigationContainer = createRuntimeFn.createRuntimeFn({ defaultClassName: "uv_plus_19x50fv5", variantClassNames: { expanded: { false: "uv_plus_19x50fv6" }, animation: { collapse: "uv_plus_19x50fv7", expand: "uv_plus_19x50fv8", false: "uv_plus_19x50fv9" } }, defaultVariants: {}, compoundVariants: [[{ expanded: true, animation: false }, "uv_plus_19x50fva"]] });
|
|
11
|
-
var navigationContentContainer = "uv_plus_19x50fvb";
|
|
12
|
-
var navigationContentContainerCollapsed = "uv_plus_19x50fvc";
|
|
13
|
-
var navigationContent = "uv_plus_19x50fvd";
|
|
14
|
-
var navigationSlider = "uv_plus_19x50fve";
|
|
15
|
-
exports.navigation = navigation;
|
|
16
|
-
exports.navigationContainer = navigationContainer;
|
|
17
|
-
exports.navigationContent = navigationContent;
|
|
18
|
-
exports.navigationContentContainer = navigationContentContainer;
|
|
19
|
-
exports.navigationContentContainerCollapsed = navigationContentContainerCollapsed;
|
|
20
|
-
exports.navigationHeader = navigationHeader;
|
|
21
|
-
exports.navigationLogoContainer = navigationLogoContainer;
|
|
22
|
-
exports.navigationSlider = navigationSlider;
|
|
23
|
-
exports.navigationStickyFooter = navigationStickyFooter;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const ui = require("@ultraviolet/ui");
|
|
6
|
-
const react = require("react");
|
|
7
|
-
const Cell = require("./components/Cell.cjs");
|
|
8
|
-
const Row = require("./components/Row.cjs");
|
|
9
|
-
const OfferListProvider = require("./OfferListProvider.cjs");
|
|
10
|
-
const styles_css = require("./styles.css.cjs");
|
|
11
|
-
const OfferList = ({
|
|
12
|
-
expandable,
|
|
13
|
-
type = "radio",
|
|
14
|
-
columns,
|
|
15
|
-
children,
|
|
16
|
-
loading,
|
|
17
|
-
autoCollapse,
|
|
18
|
-
selected,
|
|
19
|
-
onChangeSelect,
|
|
20
|
-
className,
|
|
21
|
-
style,
|
|
22
|
-
"data-testid": dataTestId
|
|
23
|
-
}) => {
|
|
24
|
-
const [radioSelectedRow, setRadioSelectedRow] = react.useState(typeof selected === "string" ? selected : void 0);
|
|
25
|
-
const [checkboxSelectedRows, setCheckboxSelectedRows] = react.useState(Array.isArray(selected) ? selected : []);
|
|
26
|
-
const computedColumns = [{
|
|
27
|
-
label: ""
|
|
28
|
-
}, expandable ? {
|
|
29
|
-
label: ""
|
|
30
|
-
} : null, ...columns].filter((element) => !!element);
|
|
31
|
-
react.useEffect(() => {
|
|
32
|
-
if (selected) {
|
|
33
|
-
if (typeof selected === "string" && type === "radio") {
|
|
34
|
-
setRadioSelectedRow(selected);
|
|
35
|
-
}
|
|
36
|
-
if (Array.isArray(selected) && type === "checkbox") {
|
|
37
|
-
setCheckboxSelectedRows(selected);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}, [type, selected]);
|
|
41
|
-
return /* @__PURE__ */ jsxRuntime.jsx(OfferListProvider.OfferListProvider, { autoCollapse, checkboxSelectedRows, expandable, loading, onChangeSelect, radioSelectedRow, selectable: type, setCheckboxSelectedRows, setRadioSelectedRow, children: /* @__PURE__ */ jsxRuntime.jsx(ui.List, { autoCollapse, className: `${className ? `${className} ` : ""}${styles_css.offerList}`, columns: computedColumns, "data-testid": dataTestId, expandable: false, selectable: false, style, children }) });
|
|
42
|
-
};
|
|
43
|
-
OfferList.Row = Row.Row;
|
|
44
|
-
OfferList.Cell = Cell.Cell;
|
|
45
|
-
exports.OfferList = OfferList;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
4
|
-
const react = require("react");
|
|
5
|
-
const OfferListContext = react.createContext(void 0);
|
|
6
|
-
const OfferListProvider = ({
|
|
7
|
-
selectable,
|
|
8
|
-
children,
|
|
9
|
-
expandable,
|
|
10
|
-
disabled,
|
|
11
|
-
loading,
|
|
12
|
-
onChangeSelect,
|
|
13
|
-
autoCollapse,
|
|
14
|
-
radioSelectedRow,
|
|
15
|
-
setRadioSelectedRow,
|
|
16
|
-
checkboxSelectedRows,
|
|
17
|
-
setCheckboxSelectedRows
|
|
18
|
-
}) => /* @__PURE__ */ jsxRuntime.jsx(OfferListContext.Provider, { value: {
|
|
19
|
-
autoCollapse,
|
|
20
|
-
checkboxSelectedRows,
|
|
21
|
-
disabled,
|
|
22
|
-
expandable,
|
|
23
|
-
loading,
|
|
24
|
-
onChangeSelect,
|
|
25
|
-
radioSelectedRow,
|
|
26
|
-
selectable,
|
|
27
|
-
setCheckboxSelectedRows,
|
|
28
|
-
setRadioSelectedRow
|
|
29
|
-
}, children });
|
|
30
|
-
const useOfferListContext = () => {
|
|
31
|
-
const context = react.useContext(OfferListContext);
|
|
32
|
-
if (!context) {
|
|
33
|
-
throw new Error("useOfferListContext should be used inside a OfferList component");
|
|
34
|
-
}
|
|
35
|
-
return context;
|
|
36
|
-
};
|
|
37
|
-
exports.OfferListProvider = OfferListProvider;
|
|
38
|
-
exports.useOfferListContext = useOfferListContext;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const ui = require("@ultraviolet/ui");
|
|
6
|
-
const styles_css = require("../styles.css.cjs");
|
|
7
|
-
const Banner = ({
|
|
8
|
-
children,
|
|
9
|
-
sentiment = "neutral",
|
|
10
|
-
disabled,
|
|
11
|
-
colSpan = 1e3,
|
|
12
|
-
type = "div",
|
|
13
|
-
shouldHavePrimaryBorder
|
|
14
|
-
}) => type === "div" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { "aria-disabled": disabled, className: styles_css.offerListBannerStack({
|
|
15
|
-
sentiment
|
|
16
|
-
}), children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "p", disabled, sentiment, variant: "caption", children }) }) : /* @__PURE__ */ jsxRuntime.jsx("tr", { className: styles_css.offerListBanner, children: /* @__PURE__ */ jsxRuntime.jsx(ui.List.Cell, { "aria-disabled": disabled, className: styles_css.offerListBannerCell, colSpan, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "p", className: styles_css.offerListBannerText({
|
|
17
|
-
disabled,
|
|
18
|
-
primaryBorder: shouldHavePrimaryBorder,
|
|
19
|
-
sentiment
|
|
20
|
-
}), disabled, variant: "caption", children }) }) });
|
|
21
|
-
exports.Banner = Banner;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const ui = require("@ultraviolet/ui");
|
|
6
|
-
const OfferListProvider = require("../OfferListProvider.cjs");
|
|
7
|
-
const styles_css = require("../styles.css.cjs");
|
|
8
|
-
const Cell = ({
|
|
9
|
-
children,
|
|
10
|
-
className,
|
|
11
|
-
"data-testid": dataTestId,
|
|
12
|
-
colSpan,
|
|
13
|
-
style
|
|
14
|
-
}) => {
|
|
15
|
-
const {
|
|
16
|
-
loading
|
|
17
|
-
} = OfferListProvider.useOfferListContext();
|
|
18
|
-
return loading ? /* @__PURE__ */ jsxRuntime.jsx(ui.List.Cell, { className: styles_css.offerListLoadingCell, style, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { "data-state": loading, variant: "line" }) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.List.Cell, { className: `${className ? `${className} ` : ""}${styles_css.offerListCell}`, colSpan, "data-testid": dataTestId, style, children });
|
|
19
|
-
};
|
|
20
|
-
exports.Cell = Cell;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const icons = require("@ultraviolet/icons");
|
|
6
|
-
const themes = require("@ultraviolet/themes");
|
|
7
|
-
const ui = require("@ultraviolet/ui");
|
|
8
|
-
const dynamic = require("@vanilla-extract/dynamic");
|
|
9
|
-
const react = require("react");
|
|
10
|
-
const OfferListProvider = require("../OfferListProvider.cjs");
|
|
11
|
-
const styles_css = require("../styles.css.cjs");
|
|
12
|
-
const Banner = require("./Banner.cjs");
|
|
13
|
-
const Row = ({
|
|
14
|
-
children,
|
|
15
|
-
disabled,
|
|
16
|
-
id,
|
|
17
|
-
banner,
|
|
18
|
-
expandablePadding,
|
|
19
|
-
offerName,
|
|
20
|
-
expandable: expandableContent,
|
|
21
|
-
selectDisabled,
|
|
22
|
-
highlightAnimation,
|
|
23
|
-
expanded,
|
|
24
|
-
className,
|
|
25
|
-
"data-dragging": dataDragging,
|
|
26
|
-
"data-testid": dataTestId,
|
|
27
|
-
style,
|
|
28
|
-
badge
|
|
29
|
-
}) => {
|
|
30
|
-
const {
|
|
31
|
-
selectable,
|
|
32
|
-
radioSelectedRow,
|
|
33
|
-
setRadioSelectedRow,
|
|
34
|
-
checkboxSelectedRows,
|
|
35
|
-
setCheckboxSelectedRows,
|
|
36
|
-
expandable,
|
|
37
|
-
loading,
|
|
38
|
-
onChangeSelect,
|
|
39
|
-
autoCollapse
|
|
40
|
-
} = OfferListProvider.useOfferListContext();
|
|
41
|
-
const {
|
|
42
|
-
expandedRowIds,
|
|
43
|
-
collapseRow,
|
|
44
|
-
expandRow
|
|
45
|
-
} = ui.List.useListContext();
|
|
46
|
-
const [isHovered, setHovered] = react.useState(false);
|
|
47
|
-
const childrenNumber = react.Children.count(children) + (selectable ? 1 : 0) + (expandable ? 1 : 0);
|
|
48
|
-
const toggleRowExpand = react.useCallback(() => {
|
|
49
|
-
if (!loading) {
|
|
50
|
-
if (expandedRowIds[id]) {
|
|
51
|
-
collapseRow(id);
|
|
52
|
-
} else {
|
|
53
|
-
expandRow(id);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}, [collapseRow, expandRow, expandedRowIds, id, loading]);
|
|
57
|
-
const computedExpandableContent = react.useMemo(() => {
|
|
58
|
-
if (expandable && !loading && expandedRowIds[id] && banner) {
|
|
59
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
60
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_css.offerListRowExpandable, style: dynamic.assignInlineVars({
|
|
61
|
-
[styles_css.expandablePadding]: themes.theme.space[expandablePadding ?? 2]
|
|
62
|
-
}), children: expandableContent }),
|
|
63
|
-
/* @__PURE__ */ jsxRuntime.jsx(Banner.Banner, { disabled, sentiment: banner.sentiment, children: banner.text })
|
|
64
|
-
] });
|
|
65
|
-
}
|
|
66
|
-
if (expandable && !loading) {
|
|
67
|
-
return expandableContent;
|
|
68
|
-
}
|
|
69
|
-
return void 0;
|
|
70
|
-
}, [expandable, loading, expandedRowIds, banner, expandablePadding, id, expandableContent, disabled]);
|
|
71
|
-
const isRowSelected = react.useMemo(() => {
|
|
72
|
-
if (selectable === "radio") {
|
|
73
|
-
return radioSelectedRow === offerName;
|
|
74
|
-
}
|
|
75
|
-
return checkboxSelectedRows.includes(offerName);
|
|
76
|
-
}, [offerName, checkboxSelectedRows, radioSelectedRow, selectable]);
|
|
77
|
-
const isSelected = selectable === "radio" ? radioSelectedRow === offerName : checkboxSelectedRows.includes(offerName);
|
|
78
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
79
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.List.Row, { className: `${className ? `${className} ` : ""}${banner ? styles_css.offerListRowBanner : ""}${isSelected ? `${" "}${styles_css.offerListRowSelected}` : ""} ${expandable ? styles_css.offerListRowSelectedExpandable : styles_css.offerListRowSelectedNotExpandable}`, "data-dragging": dataDragging, "data-testid": dataTestId, disabled, expandable: computedExpandableContent, expandablePadding: banner ? "0" : void 0, expanded: expanded ?? expandedRowIds[id], highlightAnimation, id, onMouseEnter: () => setHovered(true), onMouseLeave: () => setHovered(false), style, children: [
|
|
80
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.List.Cell, { className: styles_css.offerListNoPaddingCell, children: [
|
|
81
|
-
badge ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_css.offerListBadgeContainer, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { className: styles_css.offerListBadge, disabled, sentiment: badge.sentiment, size: "small", children: badge.text }) }) : null,
|
|
82
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_css.offerListRowSelectableContainer, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { text: typeof selectDisabled === "string" ? selectDisabled : void 0, children: selectable === "radio" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Radio, { checked: isRowSelected, disabled: disabled || loading || !!selectDisabled, id, name: `radio-offer-list-${id}`, onChange: () => {
|
|
83
|
-
setRadioSelectedRow(offerName);
|
|
84
|
-
onChangeSelect?.(offerName);
|
|
85
|
-
if (expandedRowIds[id]) {
|
|
86
|
-
expandRow(id);
|
|
87
|
-
} else if (!autoCollapse) {
|
|
88
|
-
collapseRow(id);
|
|
89
|
-
}
|
|
90
|
-
}, value: id }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Checkbox, { "aria-label": "select", checked: isRowSelected, disabled: disabled || loading || !!selectDisabled, id, name: `checkbox-offer-list-${id}`, onChange: () => {
|
|
91
|
-
if (isRowSelected) {
|
|
92
|
-
const newSelectedList = checkboxSelectedRows.filter((element) => element !== offerName);
|
|
93
|
-
setCheckboxSelectedRows(newSelectedList);
|
|
94
|
-
onChangeSelect?.(newSelectedList);
|
|
95
|
-
} else {
|
|
96
|
-
const newSelectedList = [...checkboxSelectedRows, offerName];
|
|
97
|
-
setCheckboxSelectedRows(newSelectedList);
|
|
98
|
-
onChangeSelect?.(newSelectedList);
|
|
99
|
-
}
|
|
100
|
-
if (expandedRowIds[id]) {
|
|
101
|
-
expandRow(id);
|
|
102
|
-
} else if (!autoCollapse) {
|
|
103
|
-
collapseRow(id);
|
|
104
|
-
}
|
|
105
|
-
}, value: id }) }) })
|
|
106
|
-
] }),
|
|
107
|
-
expandable ? /* @__PURE__ */ jsxRuntime.jsx(ui.List.Cell, { className: styles_css.offerListNoPaddingCell, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { "aria-label": "expand", "data-testid": "list-expand-button", disabled: disabled || !expandable || loading, onClick: toggleRowExpand, sentiment: "neutral", size: "small", variant: "ghost", children: expandedRowIds[id] ? /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowUpIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowDownIcon, {}) }) }) : null,
|
|
108
|
-
children
|
|
109
|
-
] }),
|
|
110
|
-
banner && !expandedRowIds[id] ? /* @__PURE__ */ jsxRuntime.jsx(Banner.Banner, { colSpan: childrenNumber, disabled, sentiment: banner.sentiment, shouldHavePrimaryBorder: isHovered || isRowSelected, type: "cell", children: banner.text }) : null
|
|
111
|
-
] });
|
|
112
|
-
};
|
|
113
|
-
exports.Row = Row;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
;/* empty css */
|
|
4
|
-
const createRuntimeFn = require("@vanilla-extract/recipes/createRuntimeFn");
|
|
5
|
-
var expandablePadding = "var(--uv_plus_1wcpahp0)";
|
|
6
|
-
var offerList = "uv_plus_1wcpahp1";
|
|
7
|
-
var offerListBanner = "uv_plus_1wcpahp2";
|
|
8
|
-
var offerListBannerText = createRuntimeFn.createRuntimeFn({ defaultClassName: "uv_plus_1wcpahp3", variantClassNames: { primaryBorder: { false: "uv_plus_1wcpahp4" }, sentiment: { primary: "uv_plus_1wcpahp5", secondary: "uv_plus_1wcpahp6", neutral: "uv_plus_1wcpahp7", success: "uv_plus_1wcpahp8", danger: "uv_plus_1wcpahp9", warning: "uv_plus_1wcpahpa", info: "uv_plus_1wcpahpb" }, disabled: { true: "uv_plus_1wcpahpc" } }, defaultVariants: { primaryBorder: false, sentiment: "neutral", disabled: false }, compoundVariants: [[{ sentiment: "primary", disabled: false }, "uv_plus_1wcpahpd"], [{ sentiment: "secondary", disabled: false }, "uv_plus_1wcpahpe"], [{ sentiment: "neutral", disabled: false }, "uv_plus_1wcpahpf"], [{ sentiment: "success", disabled: false }, "uv_plus_1wcpahpg"], [{ sentiment: "danger", disabled: false }, "uv_plus_1wcpahph"], [{ sentiment: "warning", disabled: false }, "uv_plus_1wcpahpi"], [{ sentiment: "info", disabled: false }, "uv_plus_1wcpahpj"], [{ sentiment: "primary", disabled: true }, "uv_plus_1wcpahpk"], [{ sentiment: "secondary", disabled: true }, "uv_plus_1wcpahpl"], [{ sentiment: "neutral", disabled: true }, "uv_plus_1wcpahpm"], [{ sentiment: "success", disabled: true }, "uv_plus_1wcpahpn"], [{ sentiment: "danger", disabled: true }, "uv_plus_1wcpahpo"], [{ sentiment: "warning", disabled: true }, "uv_plus_1wcpahpp"], [{ sentiment: "info", disabled: true }, "uv_plus_1wcpahpq"], [{ primaryBorder: true, disabled: false }, "uv_plus_1wcpahpr"], [{ primaryBorder: true, disabled: true }, "uv_plus_1wcpahps"]] });
|
|
9
|
-
var offerListBannerCell = "uv_plus_1wcpahpt";
|
|
10
|
-
var offerListBannerStack = createRuntimeFn.createRuntimeFn({ defaultClassName: "uv_plus_1wcpahpu", variantClassNames: { sentiment: { primary: "uv_plus_1wcpahpv", secondary: "uv_plus_1wcpahpw", neutral: "uv_plus_1wcpahpx", success: "uv_plus_1wcpahpy", danger: "uv_plus_1wcpahpz", warning: "uv_plus_1wcpahp10", info: "uv_plus_1wcpahp11" } }, defaultVariants: { sentiment: "neutral" }, compoundVariants: [] });
|
|
11
|
-
var offerListBadge = "uv_plus_1wcpahp12";
|
|
12
|
-
var offerListBadgeContainer = "uv_plus_1wcpahp13";
|
|
13
|
-
var offerListNoPaddingCell = "uv_plus_1wcpahp14";
|
|
14
|
-
var offerListRowSelected = "uv_plus_1wcpahp15";
|
|
15
|
-
var offerListRowSelectedNotExpandable = "uv_plus_1wcpahp16";
|
|
16
|
-
var offerListRowSelectedExpandable = "uv_plus_1wcpahp17";
|
|
17
|
-
var offerListRowBanner = "uv_plus_1wcpahp18";
|
|
18
|
-
var offerListRowSelectableContainer = "uv_plus_1wcpahp19";
|
|
19
|
-
var offerListRowExpandable = "uv_plus_1wcpahp1a";
|
|
20
|
-
var offerListCell = "uv_plus_1wcpahp1b";
|
|
21
|
-
var offerListLoadingCell = "uv_plus_1wcpahp1c";
|
|
22
|
-
exports.expandablePadding = expandablePadding;
|
|
23
|
-
exports.offerList = offerList;
|
|
24
|
-
exports.offerListBadge = offerListBadge;
|
|
25
|
-
exports.offerListBadgeContainer = offerListBadgeContainer;
|
|
26
|
-
exports.offerListBanner = offerListBanner;
|
|
27
|
-
exports.offerListBannerCell = offerListBannerCell;
|
|
28
|
-
exports.offerListBannerStack = offerListBannerStack;
|
|
29
|
-
exports.offerListBannerText = offerListBannerText;
|
|
30
|
-
exports.offerListCell = offerListCell;
|
|
31
|
-
exports.offerListLoadingCell = offerListLoadingCell;
|
|
32
|
-
exports.offerListNoPaddingCell = offerListNoPaddingCell;
|
|
33
|
-
exports.offerListRowBanner = offerListRowBanner;
|
|
34
|
-
exports.offerListRowExpandable = offerListRowExpandable;
|
|
35
|
-
exports.offerListRowSelectableContainer = offerListRowSelectableContainer;
|
|
36
|
-
exports.offerListRowSelected = offerListRowSelected;
|
|
37
|
-
exports.offerListRowSelectedExpandable = offerListRowSelectedExpandable;
|
|
38
|
-
exports.offerListRowSelectedNotExpandable = offerListRowSelectedNotExpandable;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
4
|
-
const ui = require("@ultraviolet/ui");
|
|
5
|
-
const react = require("react");
|
|
6
|
-
const helpers = require("./helpers.cjs");
|
|
7
|
-
const Provider = require("./Provider.cjs");
|
|
8
|
-
const styles_css = require("./styles.css.cjs");
|
|
9
|
-
const NonScrollableContent = ({
|
|
10
|
-
totalPrice,
|
|
11
|
-
footer,
|
|
12
|
-
children,
|
|
13
|
-
totalPriceInfo,
|
|
14
|
-
hideDetails,
|
|
15
|
-
unit,
|
|
16
|
-
totalPriceDescription,
|
|
17
|
-
additionalInfo
|
|
18
|
-
}) => {
|
|
19
|
-
const {
|
|
20
|
-
locales
|
|
21
|
-
} = react.useContext(Provider.OrderSummaryContext);
|
|
22
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { className: styles_css.orderSummaryNonScrollableContainer, gap: 3, children: [
|
|
23
|
-
children,
|
|
24
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { alignItems: "center", direction: "row", justifyContent: "space-between", children: [
|
|
25
|
-
totalPriceInfo ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { children: [
|
|
26
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { alignItems: "center", direction: "row", gap: 1, children: [
|
|
27
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { as: "span", prominence: "strong", sentiment: "neutral", variant: "bodyStrong", children: [
|
|
28
|
-
locales["order.summary.total"],
|
|
29
|
-
":"
|
|
30
|
-
] }),
|
|
31
|
-
totalPriceDescription
|
|
32
|
-
] }),
|
|
33
|
-
totalPriceInfo
|
|
34
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { alignItems: "center", direction: "row", gap: 1, children: [
|
|
35
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { as: "span", prominence: "strong", sentiment: "neutral", variant: "bodyStrong", children: [
|
|
36
|
-
locales["order.summary.total"],
|
|
37
|
-
additionalInfo ? ` ${additionalInfo}` : null,
|
|
38
|
-
":"
|
|
39
|
-
] }),
|
|
40
|
-
totalPriceDescription
|
|
41
|
-
] }),
|
|
42
|
-
totalPrice.totalPrice === totalPrice.totalPriceWithDiscount ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { as: "span", "data-testid": "total-price", prominence: "strong", sentiment: "neutral", variant: "headingSmallStrong", children: [
|
|
43
|
-
/* @__PURE__ */ jsxRuntime.jsx(helpers.DisplayPrice, { beforeOrAfter: "after", price: totalPrice }),
|
|
44
|
-
hideDetails ? `/${unit}` : null
|
|
45
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { alignItems: "center", direction: "row", gap: 1, children: [
|
|
46
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "span", prominence: "weak", sentiment: "neutral", strikeThrough: true, variant: "bodySmallStrong", children: /* @__PURE__ */ jsxRuntime.jsx(helpers.DisplayPrice, { beforeOrAfter: "before", price: totalPrice }) }),
|
|
47
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { as: "span", "data-testid": "total-price", prominence: "strong", sentiment: "neutral", variant: "headingSmallStrong", children: [
|
|
48
|
-
/* @__PURE__ */ jsxRuntime.jsx(helpers.DisplayPrice, { beforeOrAfter: "after", price: totalPrice }),
|
|
49
|
-
hideDetails ? `/${unit}` : null
|
|
50
|
-
] })
|
|
51
|
-
] })
|
|
52
|
-
] }),
|
|
53
|
-
footer
|
|
54
|
-
] });
|
|
55
|
-
};
|
|
56
|
-
exports.NonScrollableContent = NonScrollableContent;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const react = require("react");
|
|
4
|
-
const en = require("./locales/en.cjs");
|
|
5
|
-
const OrderSummaryContext = react.createContext({
|
|
6
|
-
categoriesPrice: {},
|
|
7
|
-
currency: "EUR",
|
|
8
|
-
hideTimeUnit: false,
|
|
9
|
-
items: [{
|
|
10
|
-
category: "",
|
|
11
|
-
subCategories: []
|
|
12
|
-
}],
|
|
13
|
-
localeFormat: "en-US",
|
|
14
|
-
locales: en,
|
|
15
|
-
timePeriodAmount: 1,
|
|
16
|
-
timePeriodUnit: "hours"
|
|
17
|
-
});
|
|
18
|
-
exports.OrderSummaryContext = OrderSummaryContext;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
4
|
-
const ui = require("@ultraviolet/ui");
|
|
5
|
-
const react = require("react");
|
|
6
|
-
const helpers = require("./helpers.cjs");
|
|
7
|
-
const Provider = require("./Provider.cjs");
|
|
8
|
-
const styles_css = require("./styles.css.cjs");
|
|
9
|
-
const CategoryName = ({
|
|
10
|
-
category
|
|
11
|
-
}) => {
|
|
12
|
-
const {
|
|
13
|
-
categoriesPrice
|
|
14
|
-
} = react.useContext(Provider.OrderSummaryContext);
|
|
15
|
-
const categoryPrice = categoriesPrice[category.category] ?? {
|
|
16
|
-
maxPrice: 0,
|
|
17
|
-
maxPriceWithDiscount: 0,
|
|
18
|
-
timeUnit: "hours",
|
|
19
|
-
totalPrice: 0,
|
|
20
|
-
totalPriceWithDiscount: 0
|
|
21
|
-
};
|
|
22
|
-
return category.category ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { alignItems: "center", direction: "row", justifyContent: "space-between", children: [
|
|
23
|
-
category.additionalInfo ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { alignItems: "center", direction: "row", gap: 1, children: [
|
|
24
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "span", prominence: "strong", sentiment: "neutral", variant: "bodyStrong", children: category.category }),
|
|
25
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "span", italic: true, sentiment: "primary", variant: "bodySmall", children: category.additionalInfo })
|
|
26
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "span", prominence: "strong", sentiment: "neutral", variant: "bodyStrong", children: category.category }),
|
|
27
|
-
category.customContent,
|
|
28
|
-
category.numberInput ? /* @__PURE__ */ jsxRuntime.jsx(ui.NumberInput, { className: styles_css.orderSummaryNumberInput, controls: category.numberInputControls, onChange: category.onChangeInput, size: "small", unit: category.numberInputUnit, value: category.numberInputValue }) : null,
|
|
29
|
-
!category.customContent && !category.numberInput && categoryPrice.totalPrice === categoryPrice.totalPriceWithDiscount ? /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "span", prominence: "strong", sentiment: "neutral", variant: "bodyStrong", children: /* @__PURE__ */ jsxRuntime.jsx(helpers.DisplayPrice, { beforeOrAfter: "after", price: categoryPrice }) }) : null,
|
|
30
|
-
!category.customContent && !category.numberInput && categoryPrice.totalPrice !== categoryPrice.totalPriceWithDiscount ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { alignItems: "center", direction: "row", gap: 1, children: [
|
|
31
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "span", prominence: "weak", sentiment: "neutral", strikeThrough: true, variant: "bodySmallStrong", children: /* @__PURE__ */ jsxRuntime.jsx(helpers.DisplayPrice, { beforeOrAfter: "before", price: categoryPrice }) }),
|
|
32
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "span", prominence: "strong", sentiment: "neutral", variant: "bodyStrong", children: /* @__PURE__ */ jsxRuntime.jsx(helpers.DisplayPrice, { beforeOrAfter: "after", price: categoryPrice }) })
|
|
33
|
-
] }) : null
|
|
34
|
-
] }) : null;
|
|
35
|
-
};
|
|
36
|
-
const SubCategory = ({
|
|
37
|
-
subCategory
|
|
38
|
-
}) => {
|
|
39
|
-
const {
|
|
40
|
-
currency,
|
|
41
|
-
localeFormat,
|
|
42
|
-
hideTimeUnit,
|
|
43
|
-
timePeriodAmount,
|
|
44
|
-
timePeriodUnit,
|
|
45
|
-
fractionDigits
|
|
46
|
-
} = react.useContext(Provider.OrderSummaryContext);
|
|
47
|
-
const subCategoryPrice = helpers.calculateSubCategoryPrice(subCategory, hideTimeUnit, timePeriodAmount, timePeriodUnit);
|
|
48
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { direction: "column", gap: 1, children: [
|
|
49
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { alignItems: "center", direction: "row", justifyContent: "space-between", children: [
|
|
50
|
-
subCategory.additionalInfo ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { alignItems: "center", direction: "row", gap: 1, children: [
|
|
51
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "span", prominence: "strong", sentiment: "neutral", variant: "bodyStrong", children: subCategory.title }),
|
|
52
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "span", italic: true, sentiment: "primary", variant: "bodySmall", children: subCategory.additionalInfo })
|
|
53
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "span", prominence: "strong", sentiment: "neutral", variant: "bodySmallStrong", children: subCategory.title }),
|
|
54
|
-
subCategory.customContent ? /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "span", prominence: "strong", sentiment: "neutral", variant: "bodySmallStrong", children: subCategory.customContent }) : null,
|
|
55
|
-
subCategory.numberInput ? /* @__PURE__ */ jsxRuntime.jsx(ui.NumberInput, { className: styles_css.orderSummaryNumberInput, controls: subCategory.numberInputControls, onChange: subCategory.onChangeInput, size: "small", unit: subCategory.numberInputUnit, value: subCategory.numberInputValue }) : null,
|
|
56
|
-
subCategory.price !== void 0 && !subCategory.hidePrice ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { as: "span", prominence: "strong", sentiment: "neutral", variant: "bodySmallStrong", children: [
|
|
57
|
-
subCategoryPrice[0] === subCategoryPrice[1] || subCategory.priceUnit ? helpers.formatNumber(subCategory.priceUnit ? subCategory.price : subCategoryPrice[0], localeFormat, currency, fractionDigits) : `${helpers.formatNumber(subCategoryPrice[0], localeFormat, currency, fractionDigits)} - ${helpers.formatNumber(subCategoryPrice[1], localeFormat, currency, fractionDigits)}`,
|
|
58
|
-
subCategory.priceUnit ? ` /${subCategory.priceUnit}` : ""
|
|
59
|
-
] }) : null
|
|
60
|
-
] }),
|
|
61
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { className: styles_css.orderSummaryDetails, direction: "column", gap: 0.5, children: subCategory.details?.map((detail) => detail ? /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "span", sentiment: "neutral", variant: "bodySmall", children: detail }, detail) : null) })
|
|
62
|
-
] });
|
|
63
|
-
};
|
|
64
|
-
const ScrollableContent = () => {
|
|
65
|
-
const {
|
|
66
|
-
items
|
|
67
|
-
} = react.useContext(Provider.OrderSummaryContext);
|
|
68
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { className: styles_css.orderSummaryScrollableContainer, gap: 3, children: items.map((category) => Object.keys(category).length > 0 && category.category ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { className: styles_css.orderSummaryCategory, gap: 1.5, children: [
|
|
69
|
-
/* @__PURE__ */ jsxRuntime.jsx(CategoryName, { category }),
|
|
70
|
-
category.subCategories && Object.keys(category.subCategories).length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { gap: 1, children: category.subCategories.map((subCategory, index) => /* @__PURE__ */ jsxRuntime.jsx(SubCategory, { subCategory }, subCategory.title ?? `${index}`)) }) : null
|
|
71
|
-
] }, category.category) : null) });
|
|
72
|
-
};
|
|
73
|
-
exports.ScrollableContent = ScrollableContent;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const Units = ["seconds", "minutes", "hours", "days", "months"];
|
|
4
|
-
const multiplier = {
|
|
5
|
-
days: 24,
|
|
6
|
-
hours: 1,
|
|
7
|
-
minutes: 1 / 60,
|
|
8
|
-
months: 730,
|
|
9
|
-
seconds: 1 / 60 / 60
|
|
10
|
-
};
|
|
11
|
-
exports.Units = Units;
|
|
12
|
-
exports.multiplier = multiplier;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const react = require("react");
|
|
4
|
-
const constants = require("./constants.cjs");
|
|
5
|
-
const Provider = require("./Provider.cjs");
|
|
6
|
-
const formatNumber = (number, locale, currency, fractionDigits = 10) => {
|
|
7
|
-
const numberFormat = new Intl.NumberFormat(locale, {
|
|
8
|
-
currency,
|
|
9
|
-
maximumFractionDigits: fractionDigits,
|
|
10
|
-
style: "currency"
|
|
11
|
-
});
|
|
12
|
-
return numberFormat.format(number);
|
|
13
|
-
};
|
|
14
|
-
const calculatePrice = ({
|
|
15
|
-
price,
|
|
16
|
-
amount,
|
|
17
|
-
amountFree = 0,
|
|
18
|
-
timeUnit,
|
|
19
|
-
timeAmount,
|
|
20
|
-
discount = 0,
|
|
21
|
-
fixedPrice = false
|
|
22
|
-
}) => {
|
|
23
|
-
const nonNanTimeAmount = Number.isNaN(timeAmount) ? 1 : timeAmount;
|
|
24
|
-
const valueBeforeDiscount = price * (fixedPrice ? 1 : nonNanTimeAmount * constants.multiplier[`${timeUnit}`]) * Math.max(amount - amountFree, 0);
|
|
25
|
-
const finalValue = valueBeforeDiscount * (1 - (discount <= 1 ? discount : 0)) - (discount > 1 ? Math.abs(discount) : 0);
|
|
26
|
-
return finalValue;
|
|
27
|
-
};
|
|
28
|
-
const calculateSubCategoryPrice = (subCategory, hideTimeUnit, timePeriodAmount, timePeriodUnit) => {
|
|
29
|
-
if (Array.isArray(subCategory.amount)) {
|
|
30
|
-
const minPrice = calculatePrice({
|
|
31
|
-
amount: subCategory.amount?.[0] ?? 1,
|
|
32
|
-
amountFree: subCategory.amountFree,
|
|
33
|
-
discount: subCategory.discount,
|
|
34
|
-
fixedPrice: subCategory.fixedPrice,
|
|
35
|
-
price: subCategory.price ?? 0,
|
|
36
|
-
timeAmount: hideTimeUnit ? 1 : timePeriodAmount,
|
|
37
|
-
timeUnit: hideTimeUnit ? "hours" : timePeriodUnit
|
|
38
|
-
}) || 0;
|
|
39
|
-
const maxPrice = calculatePrice({
|
|
40
|
-
amount: subCategory.amount?.[1] ?? 1,
|
|
41
|
-
amountFree: subCategory.amountFree,
|
|
42
|
-
discount: subCategory.discount,
|
|
43
|
-
fixedPrice: subCategory.fixedPrice,
|
|
44
|
-
price: subCategory.price ?? 0,
|
|
45
|
-
timeAmount: hideTimeUnit ? 1 : timePeriodAmount,
|
|
46
|
-
timeUnit: hideTimeUnit ? "hours" : timePeriodUnit
|
|
47
|
-
}) || 0;
|
|
48
|
-
return [minPrice, maxPrice];
|
|
49
|
-
}
|
|
50
|
-
const price = calculatePrice({
|
|
51
|
-
amount: subCategory.amount ?? 1,
|
|
52
|
-
amountFree: subCategory.amountFree,
|
|
53
|
-
discount: subCategory.discount,
|
|
54
|
-
fixedPrice: subCategory.fixedPrice,
|
|
55
|
-
price: subCategory.price ?? 0,
|
|
56
|
-
timeAmount: hideTimeUnit ? 1 : timePeriodAmount,
|
|
57
|
-
timeUnit: hideTimeUnit ? "hours" : timePeriodUnit
|
|
58
|
-
}) || 0;
|
|
59
|
-
return [price, price];
|
|
60
|
-
};
|
|
61
|
-
const calculateCategoryPrice = (category, hideTimeUnit, timePeriodAmount, timePeriodUnit) => {
|
|
62
|
-
const categoryPrice = category.subCategories?.reduce((acc, subCategory) => {
|
|
63
|
-
const computedPrices = calculateSubCategoryPrice(subCategory, hideTimeUnit, timePeriodAmount, timePeriodUnit);
|
|
64
|
-
return [acc[0] + computedPrices[0], acc[1] + computedPrices[1]];
|
|
65
|
-
}, [0, 0]) || [0, 0];
|
|
66
|
-
const discountedPriceMin = category.discount && category.discount <= 1 ? categoryPrice[0] * category.discount : categoryPrice[0] - (category.discount ?? 0);
|
|
67
|
-
const discountedPriceMax = category.discount && category.discount <= 1 ? categoryPrice[1] * category.discount : categoryPrice[1] - (category.discount ?? 0);
|
|
68
|
-
const discountedPrice = category.allowNegative ? [discountedPriceMin, discountedPriceMax] : [Math.max(discountedPriceMin, 0), Math.max(discountedPriceMax, 0)];
|
|
69
|
-
categoryPrice.map((price) => Math.max(category.discount && category.discount <= 1 ? price * category.discount : price - (category.discount ?? 0), 0));
|
|
70
|
-
return {
|
|
71
|
-
categoryPrice,
|
|
72
|
-
discountedPrice
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
const DisplayPrice = ({
|
|
76
|
-
price,
|
|
77
|
-
beforeOrAfter
|
|
78
|
-
}) => {
|
|
79
|
-
const {
|
|
80
|
-
localeFormat,
|
|
81
|
-
currency,
|
|
82
|
-
fractionDigits
|
|
83
|
-
} = react.useContext(Provider.OrderSummaryContext);
|
|
84
|
-
const withDiscount = beforeOrAfter === "after" ? "WithDiscount" : "";
|
|
85
|
-
return price.totalPrice === price.maxPrice ? formatNumber(price[`totalPrice${withDiscount}`], localeFormat, currency, fractionDigits ?? 2) : `${formatNumber(price[`totalPrice${withDiscount}`], localeFormat, currency, fractionDigits ?? 2)} - ${formatNumber(price[`maxPrice${withDiscount}`], localeFormat, currency, fractionDigits ?? 2)}`;
|
|
86
|
-
};
|
|
87
|
-
exports.DisplayPrice = DisplayPrice;
|
|
88
|
-
exports.calculateCategoryPrice = calculateCategoryPrice;
|
|
89
|
-
exports.calculatePrice = calculatePrice;
|
|
90
|
-
exports.calculateSubCategoryPrice = calculateSubCategoryPrice;
|
|
91
|
-
exports.formatNumber = formatNumber;
|