@configura/web-ui 2.0.0-alpha.9 → 2.1.0-alpha.0
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/.eslintrc.json +5 -0
- package/dist/components/ExpandableHeadingRow.js +9 -7
- package/dist/components/ResetButton.d.ts +9 -0
- package/dist/components/ResetButton.js +7 -0
- package/dist/components/ShareView.d.ts +4 -0
- package/dist/components/ShareView.js +21 -0
- package/dist/components/productConfiguration/CfgAdditionalProductView.js +7 -3
- package/dist/components/productConfiguration/CfgCheckboxView.d.ts +2 -5
- package/dist/components/productConfiguration/CfgCheckboxView.js +4 -26
- package/dist/components/productConfiguration/CfgCheckboxesView.d.ts +2 -5
- package/dist/components/productConfiguration/CfgCheckboxesView.js +4 -2
- package/dist/components/productConfiguration/CfgConfigurationCommonView.d.ts +8 -0
- package/dist/components/productConfiguration/CfgConfigurationCommonView.js +8 -0
- package/dist/components/productConfiguration/CfgDropdownOptionView.d.ts +2 -5
- package/dist/components/productConfiguration/CfgDropdownOptionView.js +16 -37
- package/dist/components/productConfiguration/CfgDropdownView.d.ts +2 -5
- package/dist/components/productConfiguration/CfgDropdownView.js +8 -5
- package/dist/components/productConfiguration/CfgFeatureView.d.ts +47 -6
- package/dist/components/productConfiguration/CfgFeatureView.js +20 -4
- package/dist/components/productConfiguration/CfgMiscFile.d.ts +5 -0
- package/dist/components/productConfiguration/CfgMiscFile.js +9 -0
- package/dist/components/productConfiguration/CfgMiscFiles.d.ts +5 -0
- package/dist/components/productConfiguration/CfgMiscFiles.js +5 -0
- package/dist/components/productConfiguration/CfgNote.d.ts +5 -0
- package/dist/components/productConfiguration/CfgNote.js +15 -0
- package/dist/components/productConfiguration/CfgNotes.d.ts +5 -0
- package/dist/components/productConfiguration/CfgNotes.js +5 -0
- package/dist/components/productConfiguration/CfgOptionCommonView.d.ts +7 -0
- package/dist/components/productConfiguration/CfgOptionCommonView.js +48 -0
- package/dist/components/productConfiguration/CfgOptionPriceView.js +6 -4
- package/dist/components/productConfiguration/CfgProductConfigurationView.js +4 -1
- package/dist/css/web-ui.css +1 -1
- package/dist/css/web-ui.css.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/scss/_configurator.scss +47 -3
- package/dist/scss/_expandable.scss +1 -0
- package/dist/scss/_feature-item.scss +5 -0
- package/dist/scss/_forms.scss +2 -0
- package/dist/scss/_misc-file-and-note.scss +44 -0
- package/dist/scss/_product-information.scss +4 -0
- package/dist/scss/_themed.scss +8 -1
- package/dist/useCatParams.d.ts +5 -5
- package/dist/useUniqueId.js +1 -5
- package/package.json +3 -3
- package/dist/components/productConfiguration/CfgOptionFeaturesView.d.ts +0 -4
- package/dist/components/productConfiguration/CfgOptionFeaturesView.js +0 -13
package/.eslintrc.json
ADDED
|
@@ -9,13 +9,15 @@ export var ExpandableHeadingRowSymbol;
|
|
|
9
9
|
export const ExpandableHeadingRow = (props) => {
|
|
10
10
|
const { heading, open: active, onClick, children } = props;
|
|
11
11
|
const symbol = props.symbol === undefined ? ExpandableHeadingRowSymbol.Chevron : props.symbol;
|
|
12
|
+
const inner = (React.createElement(React.Fragment, null,
|
|
13
|
+
children,
|
|
14
|
+
React.createElement("div", { className: "cfgExpandableHeadingRow__title" },
|
|
15
|
+
React.createElement("div", { className: "cfgTextOverflow" }, heading))));
|
|
12
16
|
if (props.expandable === false) {
|
|
13
|
-
return
|
|
14
|
-
children,
|
|
15
|
-
React.createElement("div", { className: "cfgExpandableHeadingRow__title cfgTextOverflow" }, heading)));
|
|
17
|
+
return React.createElement("div", { className: "cfgExpandableHeadingRow" }, inner);
|
|
16
18
|
}
|
|
17
|
-
return (React.createElement(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
return (React.createElement(React.Fragment, null,
|
|
20
|
+
React.createElement("button", { className: `cfgExpandableHeadingRow cfgExpandableHeadingRow--expandable ${props.className || ""}`, style: props.style, onClick: onClick },
|
|
21
|
+
inner,
|
|
22
|
+
React.createElement("div", { className: "cfgExpandableHeadingRow__icon" }, symbol === ExpandableHeadingRowSymbol.Chevron ? (React.createElement(Chevron, { active: active })) : (React.createElement(CheckmarkWithBorder, { active: active }))))));
|
|
21
23
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export const ResetButton = (props) => {
|
|
3
|
+
var _a;
|
|
4
|
+
const { callback, tooltip } = props;
|
|
5
|
+
return (React.createElement("div", { className: `cfgReset ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}`, style: props.style },
|
|
6
|
+
React.createElement("button", { title: tooltip, className: "cfgInput", onClick: callback }, "Reset")));
|
|
7
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CfgHistoryManager } from "@configura/web-api";
|
|
2
|
+
import React, { useState } from "react";
|
|
3
|
+
const shareLabel = "Share";
|
|
4
|
+
export const ShareView = (props) => {
|
|
5
|
+
var _a;
|
|
6
|
+
const [value, setValue] = useState(shareLabel);
|
|
7
|
+
// No need for a useMemo, this will always be the same instance
|
|
8
|
+
const historyManager = CfgHistoryManager.instance;
|
|
9
|
+
return (React.createElement("div", { className: `cfgShare ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}`, style: props.style },
|
|
10
|
+
React.createElement("input", { title: "Click to copy a share-link to the clipboard", className: "cfgInput", readOnly: true, value: value, onBlur: () => setValue(shareLabel), onFocus: (event) => {
|
|
11
|
+
const url = historyManager.getUrl();
|
|
12
|
+
setValue(url);
|
|
13
|
+
event.target.value = url;
|
|
14
|
+
event.target.select();
|
|
15
|
+
navigator.clipboard.writeText(url).catch((err) => {
|
|
16
|
+
// In Firefox we get "Error DOMException: Clipboard write was blocked due to lack of user activation." when we
|
|
17
|
+
// tab between windows, because the focus event triggers but is not user initiated. We just swallow any error.
|
|
18
|
+
console.error("Error", err);
|
|
19
|
+
});
|
|
20
|
+
} })));
|
|
21
|
+
};
|
|
@@ -4,6 +4,7 @@ import { ExpandableHeadingRow, ExpandableHeadingRowSymbol } from "../ExpandableH
|
|
|
4
4
|
import { forwardProps, } from "./CfgFeatureView.js";
|
|
5
5
|
import { CfgProductConfigurationView } from "./CfgProductConfigurationView.js";
|
|
6
6
|
export const CfgAdditionalProductView = React.memo((props) => {
|
|
7
|
+
var _a;
|
|
7
8
|
const { product, permanentlyExpandedLevels, startOpen } = props;
|
|
8
9
|
const { partNumber, optional, selected, configuration, additionalProducts, preview, description, visible: configurationVisible, } = product;
|
|
9
10
|
const setError = useContext(ErrorContext);
|
|
@@ -14,8 +15,11 @@ export const CfgAdditionalProductView = React.memo((props) => {
|
|
|
14
15
|
return (React.createElement(AdditionalProductsView, Object.assign({}, forwardProps(props), { additionalProducts: additionalProducts, permanentlyExpandedLevels: permanentlyExpandedLevels })));
|
|
15
16
|
}
|
|
16
17
|
const openOrSelected = optional ? selected : open;
|
|
17
|
-
const hasChildren = configuration.features.length !== 0 ||
|
|
18
|
-
|
|
18
|
+
const hasChildren = configuration.features.length !== 0 ||
|
|
19
|
+
additionalProducts.length !== 0 ||
|
|
20
|
+
product.notes.length !== 0 ||
|
|
21
|
+
product.miscFiles.length !== 0;
|
|
22
|
+
return (React.createElement("li", { className: `cfgFeatureItem cfgAdditionalProduct ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}`, style: props.style },
|
|
19
23
|
React.createElement(ExpandableHeadingRow, { heading: description || partNumber, expandable: optional || (hasChildren && permanentlyExpandedLevels <= 0), open: openOrSelected, onClick: () => {
|
|
20
24
|
if (optional) {
|
|
21
25
|
product.setSelected(!selected).catch((e) => {
|
|
@@ -38,5 +42,5 @@ export const CfgAdditionalProductView = React.memo((props) => {
|
|
|
38
42
|
});
|
|
39
43
|
const AdditionalProductsView = (props) => {
|
|
40
44
|
const { additionalProducts, permanentlyExpandedLevels, additionalProductComponent: AdditionalProductComponent, } = props;
|
|
41
|
-
return (React.createElement(React.Fragment, null, additionalProducts.map((additionalProduct) => (React.createElement(AdditionalProductComponent, Object.assign({
|
|
45
|
+
return (React.createElement(React.Fragment, null, additionalProducts.map((additionalProduct) => (React.createElement(AdditionalProductComponent, Object.assign({}, forwardProps(props), { key: additionalProduct.key, product: additionalProduct, permanentlyExpandedLevels: permanentlyExpandedLevels - 1 }))))));
|
|
42
46
|
};
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { CssProps } from "../../utilities.js";
|
|
3
2
|
import { CfgOptionViewProps } from "./CfgFeatureView.js";
|
|
4
|
-
export declare const CfgCheckboxView: React.FC<CfgOptionViewProps
|
|
5
|
-
export declare const CfgCheckboxViewMemo: React.NamedExoticComponent<
|
|
6
|
-
option: import("@configura/web-api").CfgOption;
|
|
7
|
-
} & CssProps>;
|
|
3
|
+
export declare const CfgCheckboxView: React.FC<CfgOptionViewProps>;
|
|
4
|
+
export declare const CfgCheckboxViewMemo: React.NamedExoticComponent<CfgOptionViewProps>;
|
|
8
5
|
//# sourceMappingURL=CfgCheckboxView.d.ts.map
|
|
@@ -1,29 +1,7 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
3
|
-
import { ErrorContext } from "../ErrorContext.js";
|
|
4
|
-
import { Checkmark } from "../icons/Checkmark.js";
|
|
5
|
-
import { forwardProps } from "./CfgFeatureView.js";
|
|
6
|
-
import { CfgOptionFeaturesView } from "./CfgOptionFeaturesView.js";
|
|
7
|
-
import { CfgOptionPriceView } from "./CfgOptionPriceView.js";
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CfgOptionCommonView } from "./CfgOptionCommonView.js";
|
|
8
3
|
export const CfgCheckboxView = (props) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const { thumbnail, description, selected, code, selectedChangeInProgress } = option;
|
|
12
|
-
const uniqueId = useUuid();
|
|
13
|
-
return (React.createElement("li", { className: props.className, style: props.style },
|
|
14
|
-
React.createElement("label", { className: "cfgFeatureItemOptional", htmlFor: uniqueId },
|
|
15
|
-
React.createElement("input", { checked: selected, className: "cfgFeatureItem__hiddenInput", id: uniqueId, name: uniqueId, onChange: () => {
|
|
16
|
-
option.setSelected(!selected).catch((e) => {
|
|
17
|
-
setError(e);
|
|
18
|
-
throw e;
|
|
19
|
-
});
|
|
20
|
-
}, type: "checkbox" }),
|
|
21
|
-
React.createElement("div", { className: "cfgFeatureItem__checkbox" }, selected === !selectedChangeInProgress && React.createElement(Checkmark, null)),
|
|
22
|
-
thumbnail && (React.createElement("img", { alt: `Thumbnail for ${description}`, className: "cfgThumbnailImage cfgMl1", src: thumbnail })),
|
|
23
|
-
React.createElement("div", { className: "cfgFeatureItemOptional__titleWrapper" },
|
|
24
|
-
React.createElement("div", { className: "cfgFeatureItemOptional__title" },
|
|
25
|
-
description || code,
|
|
26
|
-
React.createElement(CfgOptionPriceView, { option: option, upchargeDisplayMode: upchargeDisplayMode })))),
|
|
27
|
-
React.createElement(CfgOptionFeaturesView, Object.assign({ option: option }, forwardProps(props)))));
|
|
4
|
+
var _a;
|
|
5
|
+
return (React.createElement(CfgOptionCommonView, Object.assign({}, props, { className: `cfgFeatureItem ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}` })));
|
|
28
6
|
};
|
|
29
7
|
export const CfgCheckboxViewMemo = React.memo(CfgCheckboxView);
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { CssProps } from "../../utilities.js";
|
|
3
2
|
import { CfgFeatureViewProps } from "./CfgFeatureView.js";
|
|
4
|
-
export declare const CfgCheckboxesView: React.FC<CfgFeatureViewProps
|
|
5
|
-
export declare const CfgCheckboxesViewMemo: React.NamedExoticComponent<
|
|
6
|
-
feature: import("@configura/web-api").CfgFeature;
|
|
7
|
-
} & CssProps>;
|
|
3
|
+
export declare const CfgCheckboxesView: React.FC<CfgFeatureViewProps>;
|
|
4
|
+
export declare const CfgCheckboxesViewMemo: React.NamedExoticComponent<CfgFeatureViewProps>;
|
|
8
5
|
//# sourceMappingURL=CfgCheckboxesView.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SelectionType } from "@configura/web-api";
|
|
2
2
|
import React from "react";
|
|
3
|
+
import { CfgConfigurationCommonView } from "./CfgConfigurationCommonView.js";
|
|
3
4
|
import { forwardProps } from "./CfgFeatureView.js";
|
|
4
5
|
export const CfgCheckboxesView = (props) => {
|
|
5
6
|
var _a;
|
|
@@ -7,12 +8,13 @@ export const CfgCheckboxesView = (props) => {
|
|
|
7
8
|
if (feature.selectionType !== SelectionType.SelectMany) {
|
|
8
9
|
throw Error(`Unsupported selection type expected: ${SelectionType.SelectMany}, got: ${feature.selectionType}`);
|
|
9
10
|
}
|
|
10
|
-
const { options, description } = feature;
|
|
11
|
+
const { options, description, code, notes } = feature;
|
|
11
12
|
if (options.length === 0) {
|
|
12
13
|
return null;
|
|
13
14
|
}
|
|
14
15
|
return (React.createElement("li", { className: `cfgFeatureItem cfgFeatureItem--optional ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}`, style: props.style },
|
|
15
|
-
React.createElement("h3", { className: "cfgFeatureItemOptional__header" }, description),
|
|
16
|
+
React.createElement("h3", { className: "cfgFeatureItemOptional__header" }, description || code),
|
|
17
|
+
React.createElement(CfgConfigurationCommonView, Object.assign({}, forwardProps(props), { notes: notes })),
|
|
16
18
|
React.createElement("ul", { className: "cfgOptionTree" }, options.map((option) => (React.createElement(OptionComponent, Object.assign({ option: option, key: option.key }, forwardProps(props))))))));
|
|
17
19
|
};
|
|
18
20
|
export const CfgCheckboxesViewMemo = React.memo(CfgCheckboxesView);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DtoMiscFile, DtoNote } from "@configura/web-api";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { CfgProductConfigurationComponentAndPassthroughProps } from "./CfgFeatureView.js";
|
|
4
|
+
export declare const CfgConfigurationCommonView: React.FC<CfgProductConfigurationComponentAndPassthroughProps & {
|
|
5
|
+
notes?: DtoNote[];
|
|
6
|
+
miscFiles?: DtoMiscFile[];
|
|
7
|
+
}>;
|
|
8
|
+
//# sourceMappingURL=CfgConfigurationCommonView.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { forwardProps, } from "./CfgFeatureView.js";
|
|
3
|
+
export const CfgConfigurationCommonView = (props) => {
|
|
4
|
+
const { notesComponent: NotesComponent, miscFilesComponent: MiscFilesComponent, notes, miscFiles, } = props;
|
|
5
|
+
return (React.createElement(React.Fragment, null,
|
|
6
|
+
notes && notes.length !== 0 && (React.createElement(NotesComponent, Object.assign({}, forwardProps(props), { notes: notes }))),
|
|
7
|
+
miscFiles && miscFiles.length !== 0 && (React.createElement(MiscFilesComponent, Object.assign({}, forwardProps(props), { miscFiles: miscFiles })))));
|
|
8
|
+
};
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { CssProps } from "../../utilities.js";
|
|
3
2
|
import { CfgOptionViewProps } from "./CfgFeatureView.js";
|
|
4
|
-
export declare const CfgDropdownOptionView: React.FC<CfgOptionViewProps
|
|
5
|
-
export declare const CfgDropdownOptionViewMemo: React.NamedExoticComponent<
|
|
6
|
-
option: import("@configura/web-api").CfgOption;
|
|
7
|
-
} & CssProps>;
|
|
3
|
+
export declare const CfgDropdownOptionView: React.FC<CfgOptionViewProps>;
|
|
4
|
+
export declare const CfgDropdownOptionViewMemo: React.NamedExoticComponent<CfgOptionViewProps>;
|
|
8
5
|
//# sourceMappingURL=CfgDropdownOptionView.d.ts.map
|
|
@@ -1,44 +1,23 @@
|
|
|
1
1
|
import React, { useContext } from "react";
|
|
2
|
-
import { useUuid } from "../../useUniqueId.js";
|
|
3
2
|
import { ErrorContext } from "../ErrorContext.js";
|
|
4
|
-
import {
|
|
5
|
-
import { forwardProps } from "./CfgFeatureView.js";
|
|
6
|
-
import { CfgOptionFeaturesView } from "./CfgOptionFeaturesView.js";
|
|
7
|
-
import { CfgOptionNumericView } from "./CfgOptionNumericView.js";
|
|
8
|
-
import { CfgOptionPriceView } from "./CfgOptionPriceView.js";
|
|
3
|
+
import { CfgOptionCommonView } from "./CfgOptionCommonView.js";
|
|
9
4
|
export const CfgDropdownOptionView = (props) => {
|
|
10
5
|
var _a;
|
|
11
|
-
const { option
|
|
12
|
-
const {
|
|
6
|
+
const { option } = props;
|
|
7
|
+
const { selected } = option;
|
|
13
8
|
const setError = useContext(ErrorContext);
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// a change.
|
|
28
|
-
if (selected) {
|
|
29
|
-
option.setSelected(true).catch((e) => {
|
|
30
|
-
setError(e);
|
|
31
|
-
throw e;
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}, type: "radio", value: code }),
|
|
35
|
-
React.createElement("div", { className: "cfgFeatureItem__radio" }, selected === !selectedChangeInProgress && React.createElement(Checkmark, null)),
|
|
36
|
-
thumbnail && (React.createElement("img", { alt: `Thumbnail for ${description}`, className: "cfgThumbnailImage cfgMl1", src: thumbnail })),
|
|
37
|
-
React.createElement("div", { className: "cfgFeatureItemOption__titleWrapper" },
|
|
38
|
-
React.createElement("div", { className: "cfgFeatureItemOption__title" },
|
|
39
|
-
description || code,
|
|
40
|
-
React.createElement(CfgOptionPriceView, { option: option, upchargeDisplayMode: upchargeDisplayMode })))),
|
|
41
|
-
selected && React.createElement(CfgOptionNumericView, { option: option }),
|
|
42
|
-
React.createElement(CfgOptionFeaturesView, Object.assign({ option: option }, forwardProps(props)))));
|
|
9
|
+
const onClick = () => {
|
|
10
|
+
// As a convenience for when wanting to re-select something already
|
|
11
|
+
// selected to use the propagation side effects we have added this
|
|
12
|
+
// which will trigger a setSelected even though this is strictly not
|
|
13
|
+
// a change.
|
|
14
|
+
if (selected) {
|
|
15
|
+
option.setSelected(true).catch((e) => {
|
|
16
|
+
setError(e);
|
|
17
|
+
throw e;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
return (React.createElement(CfgOptionCommonView, Object.assign({}, props, { className: `cfgFeatureItem cfgMb1 ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}`, labelClassName: selected ? "cfgFeatureItemOption--checked" : "", onClick: onClick })));
|
|
43
22
|
};
|
|
44
23
|
export const CfgDropdownOptionViewMemo = React.memo(CfgDropdownOptionView);
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { CssProps } from "../../utilities.js";
|
|
3
2
|
import { CfgFeatureViewProps } from "./CfgFeatureView.js";
|
|
4
|
-
export declare const CfgDropdownView: React.FC<CfgFeatureViewProps
|
|
5
|
-
export declare const CfgDropdownViewMemo: React.NamedExoticComponent<
|
|
6
|
-
feature: import("@configura/web-api").CfgFeature;
|
|
7
|
-
} & CssProps>;
|
|
3
|
+
export declare const CfgDropdownView: React.FC<CfgFeatureViewProps>;
|
|
4
|
+
export declare const CfgDropdownViewMemo: React.NamedExoticComponent<CfgFeatureViewProps>;
|
|
8
5
|
//# sourceMappingURL=CfgDropdownView.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SelectionType } from "@configura/web-api";
|
|
2
2
|
import React, { useState } from "react";
|
|
3
3
|
import { ExpandableHeadingRow } from "../ExpandableHeadingRow.js";
|
|
4
|
+
import { CfgConfigurationCommonView } from "./CfgConfigurationCommonView.js";
|
|
4
5
|
import { forwardProps } from "./CfgFeatureView.js";
|
|
5
6
|
export const CfgDropdownView = (props) => {
|
|
6
7
|
var _a;
|
|
@@ -8,13 +9,15 @@ export const CfgDropdownView = (props) => {
|
|
|
8
9
|
if (feature.selectionType !== SelectionType.SelectOne) {
|
|
9
10
|
throw Error(`Unsupported selection type expected: ${SelectionType.SelectOne}, got: ${feature.selectionType}`);
|
|
10
11
|
}
|
|
11
|
-
const { description, preview, options } = feature;
|
|
12
|
+
const { description, preview, options, code, notes } = feature;
|
|
12
13
|
const [open, setOpen] = useState(startOpen === true);
|
|
13
14
|
return (React.createElement("li", { className: `cfgFeatureItem ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}`, style: props.style },
|
|
14
|
-
React.createElement(ExpandableHeadingRow, { heading: description, open: open, onClick: () => setOpen((prev) => !prev) }, preview && (React.createElement("div", { className: "cfgThumbnailPlaceholder" },
|
|
15
|
+
React.createElement(ExpandableHeadingRow, { heading: description || code, open: open, onClick: () => setOpen((prev) => !prev) }, preview && (React.createElement("div", { className: "cfgThumbnailPlaceholder" },
|
|
15
16
|
React.createElement("img", { alt: `Preview for ${description}`, className: "cfgThumbnailImage", src: preview })))),
|
|
16
|
-
React.createElement("div", { className: "cfgFeatureItem__subTree" },
|
|
17
|
-
open && (React.createElement(
|
|
18
|
-
|
|
17
|
+
(options || notes.length !== 0) && (React.createElement("div", { className: "cfgFeatureItem__subTree" },
|
|
18
|
+
open && (React.createElement(React.Fragment, null,
|
|
19
|
+
React.createElement(CfgConfigurationCommonView, Object.assign({}, forwardProps(props), { notes: notes })),
|
|
20
|
+
React.createElement("ul", { className: `cfgOptionTree cfgOptionTree--subLevel ${preview ? "cfgOptionTree--compThumb" : ""}` }, options.map((option) => (React.createElement(OptionComponent, Object.assign({}, forwardProps(props), { key: option.key, option: option }))))))),
|
|
21
|
+
React.createElement("hr", { className: "cfgFeatureItem__hr cfgHr" })))));
|
|
19
22
|
};
|
|
20
23
|
export const CfgDropdownViewMemo = React.memo(CfgDropdownView);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CfgFeature, CfgOption, CfgProduct } from "@configura/web-api";
|
|
1
|
+
import { CfgFeature, CfgOption, CfgProduct, DtoMiscFile, DtoNote } from "@configura/web-api";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { CssProps } from "../../utilities.js";
|
|
4
4
|
import { PassthroughProps } from "./CfgProductConfigurationView.js";
|
|
@@ -12,6 +12,24 @@ export declare type CfgAdditionalProductViewProps = CfgProductConfigurationCompo
|
|
|
12
12
|
product: CfgProduct;
|
|
13
13
|
permanentlyExpandedLevels: number;
|
|
14
14
|
};
|
|
15
|
+
export declare type CfgNoteViewProps = CssProps & {
|
|
16
|
+
note: DtoNote;
|
|
17
|
+
};
|
|
18
|
+
declare type CfgNoteComponent = {
|
|
19
|
+
noteComponent: React.ComponentType<CfgNoteViewProps>;
|
|
20
|
+
};
|
|
21
|
+
export declare type CfgNotesViewProps = CssProps & CfgNoteComponent & {
|
|
22
|
+
notes: DtoNote[];
|
|
23
|
+
};
|
|
24
|
+
export declare type CfgMiscFileViewProps = CssProps & {
|
|
25
|
+
miscFile: DtoMiscFile;
|
|
26
|
+
};
|
|
27
|
+
declare type CfgMiscFileComponent = {
|
|
28
|
+
miscFileComponent: React.ComponentType<CfgMiscFileViewProps>;
|
|
29
|
+
};
|
|
30
|
+
export declare type CfgMiscFilesViewProps = CssProps & CfgMiscFileComponent & {
|
|
31
|
+
miscFiles: DtoMiscFile[];
|
|
32
|
+
};
|
|
15
33
|
export declare type CfgProductConfigurationComponent = {
|
|
16
34
|
additionalProductComponent: React.ComponentType<CfgAdditionalProductViewProps>;
|
|
17
35
|
featureFlattenComponent: React.ComponentType<CfgFeatureViewProps>;
|
|
@@ -20,13 +38,36 @@ export declare type CfgProductConfigurationComponent = {
|
|
|
20
38
|
optionSelectManyComponent: React.ComponentType<CfgOptionViewProps>;
|
|
21
39
|
featureSelectOneComponent: React.ComponentType<CfgFeatureViewProps>;
|
|
22
40
|
optionSelectOneComponent: React.ComponentType<CfgOptionViewProps>;
|
|
23
|
-
|
|
24
|
-
|
|
41
|
+
notesComponent: React.ComponentType<CfgNotesViewProps>;
|
|
42
|
+
miscFilesComponent: React.ComponentType<CfgMiscFilesViewProps>;
|
|
43
|
+
} & CfgMiscFileComponent & CfgNoteComponent;
|
|
44
|
+
export declare const completeWithDefaultProductConfigurationComponents: <T>(incomplete: T & Partial<CfgProductConfigurationComponent>) => T & {
|
|
45
|
+
additionalProductComponent: React.ComponentType<CfgAdditionalProductViewProps>;
|
|
46
|
+
featureFlattenComponent: React.ComponentType<CfgFeatureViewProps>;
|
|
47
|
+
featureGroupComponent: React.ComponentType<CfgFeatureViewProps>;
|
|
48
|
+
featureSelectManyComponent: React.ComponentType<CfgFeatureViewProps>;
|
|
49
|
+
optionSelectManyComponent: React.ComponentType<CfgOptionViewProps>;
|
|
50
|
+
featureSelectOneComponent: React.ComponentType<CfgFeatureViewProps>;
|
|
51
|
+
optionSelectOneComponent: React.ComponentType<CfgOptionViewProps>;
|
|
52
|
+
notesComponent: React.ComponentType<CfgNotesViewProps>;
|
|
53
|
+
miscFilesComponent: React.ComponentType<CfgMiscFilesViewProps>;
|
|
54
|
+
} & CfgMiscFileComponent & CfgNoteComponent;
|
|
25
55
|
export declare const useCompleteWithDefaultProductConfigurationComponents: (incomplete: Partial<CfgProductConfigurationComponent>) => CfgProductConfigurationComponent;
|
|
26
|
-
export declare type CfgProductConfigurationComponentAndPassthroughProps = PassthroughProps & CfgProductConfigurationComponent;
|
|
56
|
+
export declare type CfgProductConfigurationComponentAndPassthroughProps = PassthroughProps & CssProps & CfgProductConfigurationComponent;
|
|
27
57
|
export declare const forwardProps: (props: CfgProductConfigurationComponentAndPassthroughProps) => CfgProductConfigurationComponentAndPassthroughProps;
|
|
28
58
|
export declare const CfgFeatureView: React.FC<CfgFeatureViewProps & CssProps>;
|
|
29
|
-
export declare const CfgFeatureViewMemo: React.NamedExoticComponent<PassthroughProps &
|
|
59
|
+
export declare const CfgFeatureViewMemo: React.NamedExoticComponent<PassthroughProps & CssProps & {
|
|
60
|
+
additionalProductComponent: React.ComponentType<CfgAdditionalProductViewProps>;
|
|
61
|
+
featureFlattenComponent: React.ComponentType<CfgFeatureViewProps>;
|
|
62
|
+
featureGroupComponent: React.ComponentType<CfgFeatureViewProps>;
|
|
63
|
+
featureSelectManyComponent: React.ComponentType<CfgFeatureViewProps>;
|
|
64
|
+
optionSelectManyComponent: React.ComponentType<CfgOptionViewProps>;
|
|
65
|
+
featureSelectOneComponent: React.ComponentType<CfgFeatureViewProps>;
|
|
66
|
+
optionSelectOneComponent: React.ComponentType<CfgOptionViewProps>;
|
|
67
|
+
notesComponent: React.ComponentType<CfgNotesViewProps>;
|
|
68
|
+
miscFilesComponent: React.ComponentType<CfgMiscFilesViewProps>;
|
|
69
|
+
} & CfgMiscFileComponent & CfgNoteComponent & {
|
|
30
70
|
feature: CfgFeature;
|
|
31
|
-
}
|
|
71
|
+
}>;
|
|
72
|
+
export {};
|
|
32
73
|
//# sourceMappingURL=CfgFeatureView.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SelectionType } from "@configura/web-api";
|
|
1
|
+
import { SelectionType, } from "@configura/web-api";
|
|
2
2
|
import React, { useMemo } from "react";
|
|
3
3
|
import { CfgAdditionalProductView } from "./CfgAdditionalProductView.js";
|
|
4
4
|
import { CfgCheckboxesViewMemo } from "./CfgCheckboxesView.js";
|
|
@@ -6,12 +6,16 @@ import { CfgCheckboxViewMemo } from "./CfgCheckboxView.js";
|
|
|
6
6
|
import { CfgDropdownOptionViewMemo } from "./CfgDropdownOptionView.js";
|
|
7
7
|
import { CfgDropdownViewMemo } from "./CfgDropdownView.js";
|
|
8
8
|
import { CfgGroupViewMemo } from "./CfgGroupView.js";
|
|
9
|
+
import { CfgMiscFile } from "./CfgMiscFile.js";
|
|
10
|
+
import { CfgMiscFiles } from "./CfgMiscFiles.js";
|
|
11
|
+
import { CfgNote } from "./CfgNote.js";
|
|
12
|
+
import { CfgNotes } from "./CfgNotes.js";
|
|
9
13
|
export const completeWithDefaultProductConfigurationComponents = (incomplete) => {
|
|
10
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
11
|
-
return (Object.assign(Object.assign({}, incomplete), { additionalProductComponent: (_a = incomplete.additionalProductComponent) !== null && _a !== void 0 ? _a : CfgAdditionalProductView, featureFlattenComponent: (_b = incomplete.featureFlattenComponent) !== null && _b !== void 0 ? _b : CfgGroupViewMemo, featureGroupComponent: (_c = incomplete.featureGroupComponent) !== null && _c !== void 0 ? _c : CfgGroupViewMemo, featureSelectManyComponent: (_d = incomplete.featureSelectManyComponent) !== null && _d !== void 0 ? _d : CfgCheckboxesViewMemo, optionSelectManyComponent: (_e = incomplete.optionSelectManyComponent) !== null && _e !== void 0 ? _e : CfgCheckboxViewMemo, featureSelectOneComponent: (_f = incomplete.featureSelectOneComponent) !== null && _f !== void 0 ? _f : CfgDropdownViewMemo, optionSelectOneComponent: (_g = incomplete.optionSelectOneComponent) !== null && _g !== void 0 ? _g : CfgDropdownOptionViewMemo }));
|
|
14
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
15
|
+
return (Object.assign(Object.assign({}, incomplete), { additionalProductComponent: (_a = incomplete.additionalProductComponent) !== null && _a !== void 0 ? _a : CfgAdditionalProductView, featureFlattenComponent: (_b = incomplete.featureFlattenComponent) !== null && _b !== void 0 ? _b : CfgGroupViewMemo, featureGroupComponent: (_c = incomplete.featureGroupComponent) !== null && _c !== void 0 ? _c : CfgGroupViewMemo, featureSelectManyComponent: (_d = incomplete.featureSelectManyComponent) !== null && _d !== void 0 ? _d : CfgCheckboxesViewMemo, optionSelectManyComponent: (_e = incomplete.optionSelectManyComponent) !== null && _e !== void 0 ? _e : CfgCheckboxViewMemo, featureSelectOneComponent: (_f = incomplete.featureSelectOneComponent) !== null && _f !== void 0 ? _f : CfgDropdownViewMemo, optionSelectOneComponent: (_g = incomplete.optionSelectOneComponent) !== null && _g !== void 0 ? _g : CfgDropdownOptionViewMemo, noteComponent: (_h = incomplete.noteComponent) !== null && _h !== void 0 ? _h : CfgNote, notesComponent: (_j = incomplete.notesComponent) !== null && _j !== void 0 ? _j : CfgNotes, miscFileComponent: (_k = incomplete.miscFileComponent) !== null && _k !== void 0 ? _k : CfgMiscFile, miscFilesComponent: (_l = incomplete.miscFilesComponent) !== null && _l !== void 0 ? _l : CfgMiscFiles }));
|
|
12
16
|
};
|
|
13
17
|
export const useCompleteWithDefaultProductConfigurationComponents = (incomplete) => {
|
|
14
|
-
const { additionalProductComponent, featureFlattenComponent, featureGroupComponent, featureSelectManyComponent, featureSelectOneComponent, optionSelectManyComponent, optionSelectOneComponent, } = incomplete;
|
|
18
|
+
const { additionalProductComponent, featureFlattenComponent, featureGroupComponent, featureSelectManyComponent, featureSelectOneComponent, optionSelectManyComponent, optionSelectOneComponent, noteComponent, notesComponent, miscFileComponent, miscFilesComponent, } = incomplete;
|
|
15
19
|
return useMemo(() => completeWithDefaultProductConfigurationComponents({
|
|
16
20
|
additionalProductComponent,
|
|
17
21
|
featureFlattenComponent,
|
|
@@ -20,6 +24,10 @@ export const useCompleteWithDefaultProductConfigurationComponents = (incomplete)
|
|
|
20
24
|
featureSelectOneComponent,
|
|
21
25
|
optionSelectManyComponent,
|
|
22
26
|
optionSelectOneComponent,
|
|
27
|
+
noteComponent,
|
|
28
|
+
notesComponent,
|
|
29
|
+
miscFileComponent,
|
|
30
|
+
miscFilesComponent,
|
|
23
31
|
}), [
|
|
24
32
|
additionalProductComponent,
|
|
25
33
|
featureFlattenComponent,
|
|
@@ -28,6 +36,10 @@ export const useCompleteWithDefaultProductConfigurationComponents = (incomplete)
|
|
|
28
36
|
featureSelectOneComponent,
|
|
29
37
|
optionSelectManyComponent,
|
|
30
38
|
optionSelectOneComponent,
|
|
39
|
+
noteComponent,
|
|
40
|
+
notesComponent,
|
|
41
|
+
miscFileComponent,
|
|
42
|
+
miscFilesComponent,
|
|
31
43
|
]);
|
|
32
44
|
};
|
|
33
45
|
export const forwardProps = (props) => ({
|
|
@@ -40,6 +52,10 @@ export const forwardProps = (props) => ({
|
|
|
40
52
|
optionSelectManyComponent: props.optionSelectManyComponent,
|
|
41
53
|
featureSelectOneComponent: props.featureSelectOneComponent,
|
|
42
54
|
optionSelectOneComponent: props.optionSelectOneComponent,
|
|
55
|
+
noteComponent: props.noteComponent,
|
|
56
|
+
notesComponent: props.notesComponent,
|
|
57
|
+
miscFileComponent: props.miscFileComponent,
|
|
58
|
+
miscFilesComponent: props.miscFilesComponent,
|
|
43
59
|
});
|
|
44
60
|
export const CfgFeatureView = (props) => {
|
|
45
61
|
const { feature, featureFlattenComponent: FlattenComponent, featureGroupComponent: GroupComponent, featureSelectManyComponent: SelectManyComponent, featureSelectOneComponent: SelectOneComponent, } = props;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export const CfgMiscFile = (props) => {
|
|
3
|
+
const { url, preview } = props.miscFile;
|
|
4
|
+
const split = url.lastIndexOf("/");
|
|
5
|
+
const name = split ? decodeURI(url.substring(split + 1)) : url;
|
|
6
|
+
return (React.createElement("li", { className: `cfgMiscFiles__item ${props.className || ""}`, style: props.style },
|
|
7
|
+
preview !== undefined && (React.createElement("img", { className: "cfgMiscFiles__thumbnail cfgThumbnailImage", src: preview, alt: "Preview for file URL." })),
|
|
8
|
+
React.createElement("a", { href: url, className: "cfgMiscFiles__link cfgTextOverflow", target: "_blank", rel: "noopener noreferrer" }, name)));
|
|
9
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export const CfgMiscFiles = (props) => {
|
|
3
|
+
const { miscFileComponent: MiscFileComponent } = props;
|
|
4
|
+
return (React.createElement("ul", { className: `cfgMiscFiles ${props.className || ""}`, style: props.style }, props.miscFiles.map((f) => (React.createElement(MiscFileComponent, { key: f.key + f.url + f.preview, miscFile: f })))));
|
|
5
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { ExpandableHeadingRow } from "../ExpandableHeadingRow.js";
|
|
3
|
+
export const CfgNote = (props) => {
|
|
4
|
+
const { code, body, key, title } = props.note;
|
|
5
|
+
const [open, setOpen] = useState(false);
|
|
6
|
+
const hasNoTitle = !title;
|
|
7
|
+
const hasNoBody = !body;
|
|
8
|
+
if (hasNoBody && hasNoTitle) {
|
|
9
|
+
console.info(`Note has neither title nor body and will not be visible. (${code})`);
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return (React.createElement("li", { className: "cfgNotes__item" },
|
|
13
|
+
React.createElement(ExpandableHeadingRow, { heading: title || key || code, open: open, onClick: () => setOpen((prev) => !prev), expandable: !hasNoBody, className: "cfgNotes__title" }),
|
|
14
|
+
open && React.createElement("div", { className: "cfgNotes__body" }, body)));
|
|
15
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export const CfgNotes = (props) => {
|
|
3
|
+
const { noteComponent: NoteComponent } = props;
|
|
4
|
+
return (React.createElement("ul", { className: "cfgNotes", style: props.style }, props.notes.map((n) => (React.createElement(NoteComponent, { note: n, key: n.code })))));
|
|
5
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CfgOptionViewProps } from "./CfgFeatureView.js";
|
|
3
|
+
export declare const CfgOptionCommonView: React.FC<CfgOptionViewProps & {
|
|
4
|
+
labelClassName?: string;
|
|
5
|
+
onClick?: () => void;
|
|
6
|
+
}>;
|
|
7
|
+
//# sourceMappingURL=CfgOptionCommonView.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SelectionType } from "@configura/web-api";
|
|
2
|
+
import React, { useContext } from "react";
|
|
3
|
+
import { useUuid } from "../../useUniqueId.js";
|
|
4
|
+
import { ErrorContext } from "../ErrorContext.js";
|
|
5
|
+
import { Checkmark } from "../icons/Checkmark.js";
|
|
6
|
+
import { CfgConfigurationCommonView } from "./CfgConfigurationCommonView.js";
|
|
7
|
+
import { CfgFeatureView, forwardProps } from "./CfgFeatureView.js";
|
|
8
|
+
import { CfgOptionNumericView } from "./CfgOptionNumericView.js";
|
|
9
|
+
import { CfgOptionPriceView } from "./CfgOptionPriceView.js";
|
|
10
|
+
export const CfgOptionCommonView = (props) => {
|
|
11
|
+
const { option, upchargeDisplayMode, onClick, labelClassName } = props;
|
|
12
|
+
const { features, thumbnail, description, selected, code, selectedChangeInProgress, miscFiles, notes, } = option;
|
|
13
|
+
const setError = useContext(ErrorContext);
|
|
14
|
+
const uniqueId = useUuid();
|
|
15
|
+
const selectionType = option.parent.selectionType;
|
|
16
|
+
let inputType;
|
|
17
|
+
let typeClassNameFragment;
|
|
18
|
+
switch (selectionType) {
|
|
19
|
+
case SelectionType.SelectMany:
|
|
20
|
+
inputType = "checkbox";
|
|
21
|
+
typeClassNameFragment = "Optional";
|
|
22
|
+
break;
|
|
23
|
+
case SelectionType.SelectOne:
|
|
24
|
+
inputType = "radio";
|
|
25
|
+
typeClassNameFragment = "Option";
|
|
26
|
+
break;
|
|
27
|
+
default:
|
|
28
|
+
throw new Error(`Unsupported selectionType ${selectionType}`);
|
|
29
|
+
}
|
|
30
|
+
return (React.createElement("li", { className: props.className, style: props.style },
|
|
31
|
+
React.createElement("label", { className: `cfgFeatureItem${typeClassNameFragment} ${labelClassName !== null && labelClassName !== void 0 ? labelClassName : ""}`, htmlFor: uniqueId },
|
|
32
|
+
React.createElement("input", { checked: selected, className: "cfgFeatureItem__hiddenInput", id: uniqueId, name: uniqueId, onChange: () => {
|
|
33
|
+
option.setSelected(!selected).catch((e) => {
|
|
34
|
+
setError(e);
|
|
35
|
+
throw e;
|
|
36
|
+
});
|
|
37
|
+
}, onClick: onClick, type: inputType }),
|
|
38
|
+
React.createElement("div", { className: `cfgFeatureItem__${inputType}` }, selected === !selectedChangeInProgress && React.createElement(Checkmark, null)),
|
|
39
|
+
thumbnail && (React.createElement("img", { alt: `Thumbnail for ${description}`, className: "cfgThumbnailImage cfgMl1", src: thumbnail })),
|
|
40
|
+
React.createElement("div", { className: `cfgFeatureItem${typeClassNameFragment}__titleWrapper` },
|
|
41
|
+
React.createElement("div", { className: `cfgFeatureItem${typeClassNameFragment}__title` },
|
|
42
|
+
description || code,
|
|
43
|
+
React.createElement(CfgOptionPriceView, { option: option, upchargeDisplayMode: upchargeDisplayMode })))),
|
|
44
|
+
selected && (React.createElement(React.Fragment, null,
|
|
45
|
+
React.createElement(CfgOptionNumericView, { option: option }),
|
|
46
|
+
React.createElement(CfgConfigurationCommonView, Object.assign({}, forwardProps(props), { notes: notes, miscFiles: miscFiles })),
|
|
47
|
+
features.length !== 0 && (React.createElement("ul", { className: "cfgOptionTree cfgOptionTree--subLevel cfgOptionTree--indent" }, features.map((f) => (React.createElement(CfgFeatureView, Object.assign({}, forwardProps(props), { feature: f, key: f.key }))))))))));
|
|
48
|
+
};
|