@configura/web-ui 2.0.0-alpha.2 → 2.0.0-alpha.21
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/.postcssrc.json +8 -8
- package/LICENSE +201 -201
- package/README.md +1 -1
- package/dist/components/CanvasWrapper.d.ts +9 -9
- package/dist/components/CanvasWrapper.js +8 -8
- package/dist/components/CfgPriceView.d.ts +6 -6
- package/dist/components/CfgPriceView.js +13 -13
- package/dist/components/ConfigurationActionsButtonRow.d.ts +14 -14
- package/dist/components/ConfigurationActionsButtonRow.js +16 -16
- package/dist/components/Configurator.d.ts +12 -12
- package/dist/components/Configurator.js +15 -15
- package/dist/components/ConfiguratorWrapper.d.ts +8 -8
- package/dist/components/ConfiguratorWrapper.js +5 -5
- package/dist/components/CurrencyPrice.d.ts +9 -9
- package/dist/components/CurrencyPrice.js +7 -7
- package/dist/components/ErrorContext.d.ts +2 -2
- package/dist/components/ErrorContext.js +2 -2
- package/dist/components/ExpandableHeadingRow.d.ts +15 -15
- package/dist/components/ExpandableHeadingRow.js +21 -21
- package/dist/components/Loading.d.ts +13 -13
- package/dist/components/Loading.js +20 -20
- package/dist/components/ProductInformation.d.ts +13 -13
- package/dist/components/ProductInformation.js +14 -14
- 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/TaskListView.d.ts +8 -8
- package/dist/components/TaskListView.js +69 -69
- package/dist/components/TaskStartView.d.ts +12 -12
- package/dist/components/TaskStartView.js +29 -29
- package/dist/components/icons/Checkmark.d.ts +6 -6
- package/dist/components/icons/Checkmark.js +12 -12
- package/dist/components/icons/Chevron.d.ts +7 -7
- package/dist/components/icons/Chevron.js +18 -18
- package/dist/components/icons/CircleXmarkIcon.d.ts +3 -3
- package/dist/components/icons/CircleXmarkIcon.js +8 -8
- package/dist/components/icons/DownloadIcon.d.ts +3 -3
- package/dist/components/icons/DownloadIcon.js +8 -8
- package/dist/components/icons/ErrorIcon.d.ts +3 -3
- package/dist/components/icons/ErrorIcon.js +8 -8
- package/dist/components/productConfiguration/CfgAdditionalProductView.d.ts +3 -3
- package/dist/components/productConfiguration/CfgAdditionalProductView.js +42 -42
- package/dist/components/productConfiguration/CfgCheckboxView.d.ts +7 -9
- package/dist/components/productConfiguration/CfgCheckboxView.js +29 -29
- package/dist/components/productConfiguration/CfgCheckboxesView.d.ts +7 -9
- package/dist/components/productConfiguration/CfgCheckboxesView.js +18 -18
- package/dist/components/productConfiguration/CfgDropdownOptionView.d.ts +7 -9
- package/dist/components/productConfiguration/CfgDropdownOptionView.js +44 -44
- package/dist/components/productConfiguration/CfgDropdownView.d.ts +7 -9
- package/dist/components/productConfiguration/CfgDropdownView.js +20 -20
- package/dist/components/productConfiguration/CfgFeatureView.d.ts +31 -35
- package/dist/components/productConfiguration/CfgFeatureView.js +60 -64
- package/dist/components/productConfiguration/CfgGroupView.d.ts +4 -4
- package/dist/components/productConfiguration/CfgGroupView.js +7 -7
- package/dist/components/productConfiguration/CfgOptionFeaturesView.d.ts +3 -3
- package/dist/components/productConfiguration/CfgOptionFeaturesView.js +13 -13
- package/dist/components/productConfiguration/CfgOptionNumericView.d.ts +29 -29
- package/dist/components/productConfiguration/CfgOptionNumericView.js +132 -132
- package/dist/components/productConfiguration/CfgOptionPriceView.d.ts +9 -9
- package/dist/components/productConfiguration/CfgOptionPriceView.js +31 -29
- package/dist/components/productConfiguration/CfgProductConfigurationView.d.ts +22 -17
- package/dist/components/productConfiguration/CfgProductConfigurationView.js +47 -47
- package/dist/css/web-ui.css +1 -1
- package/dist/css/web-ui.css.map +1 -1
- package/dist/index.d.ts +29 -23
- package/dist/index.js +29 -23
- package/dist/scss/_button.scss +52 -52
- package/dist/scss/_configurator.scss +125 -88
- package/dist/scss/_expandable.scss +37 -37
- package/dist/scss/_feature-item.scss +137 -137
- package/dist/scss/_forms.scss +44 -42
- package/dist/scss/_hr.scss +16 -16
- package/dist/scss/_loading.scss +98 -98
- package/dist/scss/_mixins.scss +56 -56
- package/dist/scss/_option-tree.scss +29 -29
- package/dist/scss/_product-information.scss +53 -49
- package/dist/scss/_range-view.scss +39 -39
- package/dist/scss/_slider.scss +70 -70
- package/dist/scss/_tasks.scss +72 -72
- package/dist/scss/_themed.scss +154 -149
- package/dist/scss/_utilities.scss +21 -21
- package/dist/scss/_variables.scss +6 -6
- package/dist/scss/icons/_checkmark.scss +46 -46
- package/dist/scss/icons/_chevron.scss +62 -62
- package/dist/scss/icons/_circle-xmark-icon.scss +24 -24
- package/dist/scss/icons/_download-icon.scss +24 -24
- package/dist/scss/icons/_error-icon.scss +24 -24
- package/dist/scss/web-ui.scss +11 -11
- package/dist/useCatParams.d.ts +18 -0
- package/dist/useCatParams.js +29 -0
- package/dist/useObservable.d.ts +4 -4
- package/dist/useObservable.js +18 -18
- package/dist/useRerender.d.ts +1 -1
- package/dist/useRerender.js +5 -5
- package/dist/useResize.d.ts +6 -6
- package/dist/useResize.js +47 -47
- package/dist/useSelected.d.ts +2 -2
- package/dist/useSelected.js +13 -13
- package/dist/useUniqueId.d.ts +1 -1
- package/dist/useUniqueId.js +3 -7
- package/dist/utilities.d.ts +5 -5
- package/dist/utilities.js +1 -1
- package/package.json +3 -3
|
@@ -1,36 +1,32 @@
|
|
|
1
|
-
import { CfgFeature, CfgOption, CfgProduct } from "@configura/web-api";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { CssProps } from "../../utilities.js";
|
|
4
|
-
import { PassthroughProps } from "./CfgProductConfigurationView.js";
|
|
5
|
-
export declare type CfgFeatureViewProps = CfgProductConfigurationComponentAndPassthroughProps & {
|
|
6
|
-
feature: CfgFeature;
|
|
7
|
-
};
|
|
8
|
-
export declare type CfgOptionViewProps = CfgProductConfigurationComponentAndPassthroughProps & {
|
|
9
|
-
option: CfgOption;
|
|
10
|
-
};
|
|
11
|
-
export declare type CfgAdditionalProductViewProps = CfgProductConfigurationComponentAndPassthroughProps & {
|
|
12
|
-
product: CfgProduct;
|
|
13
|
-
permanentlyExpandedLevels: number;
|
|
14
|
-
};
|
|
15
|
-
export declare type CfgProductConfigurationComponent = {
|
|
16
|
-
additionalProductComponent: React.ComponentType<CfgAdditionalProductViewProps>;
|
|
17
|
-
featureFlattenComponent: React.ComponentType<CfgFeatureViewProps>;
|
|
18
|
-
featureGroupComponent: React.ComponentType<CfgFeatureViewProps>;
|
|
19
|
-
featureSelectManyComponent: React.ComponentType<CfgFeatureViewProps>;
|
|
20
|
-
optionSelectManyComponent: React.ComponentType<CfgOptionViewProps>;
|
|
21
|
-
featureSelectOneComponent: React.ComponentType<CfgFeatureViewProps>;
|
|
22
|
-
optionSelectOneComponent: React.ComponentType<CfgOptionViewProps>;
|
|
23
|
-
};
|
|
24
|
-
export declare const completeWithDefaultProductConfigurationComponents: <T>(incomplete: T & Partial<CfgProductConfigurationComponent>) => T & CfgProductConfigurationComponent;
|
|
25
|
-
export declare const useCompleteWithDefaultProductConfigurationComponents: (incomplete: Partial<CfgProductConfigurationComponent>) => CfgProductConfigurationComponent;
|
|
26
|
-
export declare type CfgProductConfigurationComponentAndPassthroughProps = PassthroughProps & CfgProductConfigurationComponent
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export declare const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
startOpen?: boolean | undefined;
|
|
33
|
-
} & {
|
|
34
|
-
feature: CfgFeature;
|
|
35
|
-
} & CssProps>;
|
|
1
|
+
import { CfgFeature, CfgOption, CfgProduct } from "@configura/web-api";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { CssProps } from "../../utilities.js";
|
|
4
|
+
import { PassthroughProps } from "./CfgProductConfigurationView.js";
|
|
5
|
+
export declare type CfgFeatureViewProps = CfgProductConfigurationComponentAndPassthroughProps & {
|
|
6
|
+
feature: CfgFeature;
|
|
7
|
+
};
|
|
8
|
+
export declare type CfgOptionViewProps = CfgProductConfigurationComponentAndPassthroughProps & {
|
|
9
|
+
option: CfgOption;
|
|
10
|
+
};
|
|
11
|
+
export declare type CfgAdditionalProductViewProps = CfgProductConfigurationComponentAndPassthroughProps & {
|
|
12
|
+
product: CfgProduct;
|
|
13
|
+
permanentlyExpandedLevels: number;
|
|
14
|
+
};
|
|
15
|
+
export declare type CfgProductConfigurationComponent = {
|
|
16
|
+
additionalProductComponent: React.ComponentType<CfgAdditionalProductViewProps>;
|
|
17
|
+
featureFlattenComponent: React.ComponentType<CfgFeatureViewProps>;
|
|
18
|
+
featureGroupComponent: React.ComponentType<CfgFeatureViewProps>;
|
|
19
|
+
featureSelectManyComponent: React.ComponentType<CfgFeatureViewProps>;
|
|
20
|
+
optionSelectManyComponent: React.ComponentType<CfgOptionViewProps>;
|
|
21
|
+
featureSelectOneComponent: React.ComponentType<CfgFeatureViewProps>;
|
|
22
|
+
optionSelectOneComponent: React.ComponentType<CfgOptionViewProps>;
|
|
23
|
+
};
|
|
24
|
+
export declare const completeWithDefaultProductConfigurationComponents: <T>(incomplete: T & Partial<CfgProductConfigurationComponent>) => T & CfgProductConfigurationComponent;
|
|
25
|
+
export declare const useCompleteWithDefaultProductConfigurationComponents: (incomplete: Partial<CfgProductConfigurationComponent>) => CfgProductConfigurationComponent;
|
|
26
|
+
export declare type CfgProductConfigurationComponentAndPassthroughProps = PassthroughProps & CfgProductConfigurationComponent;
|
|
27
|
+
export declare const forwardProps: (props: CfgProductConfigurationComponentAndPassthroughProps) => CfgProductConfigurationComponentAndPassthroughProps;
|
|
28
|
+
export declare const CfgFeatureView: React.FC<CfgFeatureViewProps & CssProps>;
|
|
29
|
+
export declare const CfgFeatureViewMemo: React.NamedExoticComponent<PassthroughProps & CfgProductConfigurationComponent & {
|
|
30
|
+
feature: CfgFeature;
|
|
31
|
+
} & CssProps>;
|
|
36
32
|
//# sourceMappingURL=CfgFeatureView.d.ts.map
|
|
@@ -1,64 +1,60 @@
|
|
|
1
|
-
import { SelectionType } from "@configura/web-api";
|
|
2
|
-
import React, { useMemo } from "react";
|
|
3
|
-
import { CfgAdditionalProductView } from "./CfgAdditionalProductView.js";
|
|
4
|
-
import { CfgCheckboxesViewMemo } from "./CfgCheckboxesView.js";
|
|
5
|
-
import { CfgCheckboxViewMemo } from "./CfgCheckboxView.js";
|
|
6
|
-
import { CfgDropdownOptionViewMemo } from "./CfgDropdownOptionView.js";
|
|
7
|
-
import { CfgDropdownViewMemo } from "./CfgDropdownView.js";
|
|
8
|
-
import { CfgGroupViewMemo } from "./CfgGroupView.js";
|
|
9
|
-
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 }));
|
|
12
|
-
};
|
|
13
|
-
export const useCompleteWithDefaultProductConfigurationComponents = (incomplete) => {
|
|
14
|
-
const { additionalProductComponent, featureFlattenComponent, featureGroupComponent, featureSelectManyComponent, featureSelectOneComponent, optionSelectManyComponent, optionSelectOneComponent, } = incomplete;
|
|
15
|
-
return useMemo(() => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
case SelectionType.
|
|
55
|
-
return React.createElement(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
throw Error("Unsupported viewType");
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
export const CfgFeatureViewMemo = React.memo(CfgFeatureView);
|
|
1
|
+
import { SelectionType } from "@configura/web-api";
|
|
2
|
+
import React, { useMemo } from "react";
|
|
3
|
+
import { CfgAdditionalProductView } from "./CfgAdditionalProductView.js";
|
|
4
|
+
import { CfgCheckboxesViewMemo } from "./CfgCheckboxesView.js";
|
|
5
|
+
import { CfgCheckboxViewMemo } from "./CfgCheckboxView.js";
|
|
6
|
+
import { CfgDropdownOptionViewMemo } from "./CfgDropdownOptionView.js";
|
|
7
|
+
import { CfgDropdownViewMemo } from "./CfgDropdownView.js";
|
|
8
|
+
import { CfgGroupViewMemo } from "./CfgGroupView.js";
|
|
9
|
+
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 }));
|
|
12
|
+
};
|
|
13
|
+
export const useCompleteWithDefaultProductConfigurationComponents = (incomplete) => {
|
|
14
|
+
const { additionalProductComponent, featureFlattenComponent, featureGroupComponent, featureSelectManyComponent, featureSelectOneComponent, optionSelectManyComponent, optionSelectOneComponent, } = incomplete;
|
|
15
|
+
return useMemo(() => completeWithDefaultProductConfigurationComponents({
|
|
16
|
+
additionalProductComponent,
|
|
17
|
+
featureFlattenComponent,
|
|
18
|
+
featureGroupComponent,
|
|
19
|
+
featureSelectManyComponent,
|
|
20
|
+
featureSelectOneComponent,
|
|
21
|
+
optionSelectManyComponent,
|
|
22
|
+
optionSelectOneComponent,
|
|
23
|
+
}), [
|
|
24
|
+
additionalProductComponent,
|
|
25
|
+
featureFlattenComponent,
|
|
26
|
+
featureGroupComponent,
|
|
27
|
+
featureSelectManyComponent,
|
|
28
|
+
featureSelectOneComponent,
|
|
29
|
+
optionSelectManyComponent,
|
|
30
|
+
optionSelectOneComponent,
|
|
31
|
+
]);
|
|
32
|
+
};
|
|
33
|
+
export const forwardProps = (props) => ({
|
|
34
|
+
upchargeDisplayMode: props.upchargeDisplayMode,
|
|
35
|
+
startOpen: props.startOpen,
|
|
36
|
+
additionalProductComponent: props.additionalProductComponent,
|
|
37
|
+
featureFlattenComponent: props.featureFlattenComponent,
|
|
38
|
+
featureGroupComponent: props.featureGroupComponent,
|
|
39
|
+
featureSelectManyComponent: props.featureSelectManyComponent,
|
|
40
|
+
optionSelectManyComponent: props.optionSelectManyComponent,
|
|
41
|
+
featureSelectOneComponent: props.featureSelectOneComponent,
|
|
42
|
+
optionSelectOneComponent: props.optionSelectOneComponent,
|
|
43
|
+
});
|
|
44
|
+
export const CfgFeatureView = (props) => {
|
|
45
|
+
const { feature, featureFlattenComponent: FlattenComponent, featureGroupComponent: GroupComponent, featureSelectManyComponent: SelectManyComponent, featureSelectOneComponent: SelectOneComponent, } = props;
|
|
46
|
+
if (!feature.visible) {
|
|
47
|
+
return React.createElement(FlattenComponent, Object.assign({}, props));
|
|
48
|
+
}
|
|
49
|
+
switch (feature.selectionType) {
|
|
50
|
+
case SelectionType.Group:
|
|
51
|
+
return React.createElement(GroupComponent, Object.assign({}, props));
|
|
52
|
+
case SelectionType.SelectMany:
|
|
53
|
+
return React.createElement(SelectManyComponent, Object.assign({}, props));
|
|
54
|
+
case SelectionType.SelectOne:
|
|
55
|
+
return React.createElement(SelectOneComponent, Object.assign({}, props));
|
|
56
|
+
default:
|
|
57
|
+
throw Error("Unsupported viewType");
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
export const CfgFeatureViewMemo = React.memo(CfgFeatureView);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { CfgFeatureViewProps } from "./CfgFeatureView.js";
|
|
3
|
-
export declare const CfgGroupView: React.FC<CfgFeatureViewProps>;
|
|
4
|
-
export declare const CfgGroupViewMemo: React.NamedExoticComponent<CfgFeatureViewProps>;
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CfgFeatureViewProps } from "./CfgFeatureView.js";
|
|
3
|
+
export declare const CfgGroupView: React.FC<CfgFeatureViewProps>;
|
|
4
|
+
export declare const CfgGroupViewMemo: React.NamedExoticComponent<CfgFeatureViewProps>;
|
|
5
5
|
//# sourceMappingURL=CfgGroupView.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { CfgFeatureViewMemo, forwardProps } from "./CfgFeatureView.js";
|
|
3
|
-
export const CfgGroupView = (props) => {
|
|
4
|
-
const { feature } = props;
|
|
5
|
-
return (React.createElement(React.Fragment, null, feature.selectedOptions.map((o) => o.features.map((f) => (React.createElement(CfgFeatureViewMemo, Object.assign({ key: f.key, feature: f }, forwardProps(props))))))));
|
|
6
|
-
};
|
|
7
|
-
export const CfgGroupViewMemo = React.memo(CfgGroupView);
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CfgFeatureViewMemo, forwardProps } from "./CfgFeatureView.js";
|
|
3
|
+
export const CfgGroupView = (props) => {
|
|
4
|
+
const { feature } = props;
|
|
5
|
+
return (React.createElement(React.Fragment, null, feature.selectedOptions.map((o) => o.features.map((f) => (React.createElement(CfgFeatureViewMemo, Object.assign({ key: f.key, feature: f }, forwardProps(props))))))));
|
|
6
|
+
};
|
|
7
|
+
export const CfgGroupViewMemo = React.memo(CfgGroupView);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { CfgOptionViewProps } from "./CfgFeatureView.js";
|
|
3
|
-
export declare const CfgOptionFeaturesView: React.FC<CfgOptionViewProps>;
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CfgOptionViewProps } from "./CfgFeatureView.js";
|
|
3
|
+
export declare const CfgOptionFeaturesView: React.FC<CfgOptionViewProps>;
|
|
4
4
|
//# sourceMappingURL=CfgOptionFeaturesView.d.ts.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { CfgFeatureView, forwardProps } from "./CfgFeatureView.js";
|
|
3
|
-
export const CfgOptionFeaturesView = (props) => {
|
|
4
|
-
const { option } = props;
|
|
5
|
-
const { features, selected } = option;
|
|
6
|
-
if (!selected) {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
if (features.length === 0) {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
return (React.createElement("ul", { className: "cfgOptionTree cfgOptionTree--subLevel cfgOptionTree--indent" }, features.map((f) => (React.createElement(CfgFeatureView, Object.assign({ feature: f, key: f.key }, forwardProps(props)))))));
|
|
13
|
-
};
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CfgFeatureView, forwardProps } from "./CfgFeatureView.js";
|
|
3
|
+
export const CfgOptionFeaturesView = (props) => {
|
|
4
|
+
const { option } = props;
|
|
5
|
+
const { features, selected } = option;
|
|
6
|
+
if (!selected) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
if (features.length === 0) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return (React.createElement("ul", { className: "cfgOptionTree cfgOptionTree--subLevel cfgOptionTree--indent" }, features.map((f) => (React.createElement(CfgFeatureView, Object.assign({ feature: f, key: f.key }, forwardProps(props)))))));
|
|
13
|
+
};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { CfgOption, NumericValueDiscrete, NumericValueRangeDefinition } from "@configura/web-api";
|
|
2
|
-
import { LengthUnit } from "@configura/web-utilities";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { CssProps } from "../../utilities.js";
|
|
5
|
-
declare type Props = {
|
|
6
|
-
option: CfgOption;
|
|
7
|
-
} & CssProps;
|
|
8
|
-
export declare const CfgOptionNumericView: React.FC<Props>;
|
|
9
|
-
/**
|
|
10
|
-
* Displays GUI for selecting in one "range". Please note that the range
|
|
11
|
-
* parameter can also be a discrete value.
|
|
12
|
-
*/
|
|
13
|
-
export declare const NumericValueView: React.FC<{
|
|
14
|
-
currentValue: number;
|
|
15
|
-
unit: LengthUnit;
|
|
16
|
-
range: NumericValueRangeDefinition | NumericValueDiscrete;
|
|
17
|
-
updateValue: (val: number, commit: boolean) => void;
|
|
18
|
-
hasNoSiblings: boolean;
|
|
19
|
-
}>;
|
|
20
|
-
export declare const RangeView: React.FC<{
|
|
21
|
-
currentValue: number;
|
|
22
|
-
unit: LengthUnit;
|
|
23
|
-
range: NumericValueRangeDefinition;
|
|
24
|
-
inputValue: number;
|
|
25
|
-
onChange: (val: number, instantUpdate: boolean) => void;
|
|
26
|
-
onCommit: () => void;
|
|
27
|
-
showRangeError: boolean;
|
|
28
|
-
} & CssProps>;
|
|
29
|
-
export {};
|
|
1
|
+
import { CfgOption, NumericValueDiscrete, NumericValueRangeDefinition } from "@configura/web-api";
|
|
2
|
+
import { LengthUnit } from "@configura/web-utilities";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { CssProps } from "../../utilities.js";
|
|
5
|
+
declare type Props = {
|
|
6
|
+
option: CfgOption;
|
|
7
|
+
} & CssProps;
|
|
8
|
+
export declare const CfgOptionNumericView: React.FC<Props>;
|
|
9
|
+
/**
|
|
10
|
+
* Displays GUI for selecting in one "range". Please note that the range
|
|
11
|
+
* parameter can also be a discrete value.
|
|
12
|
+
*/
|
|
13
|
+
export declare const NumericValueView: React.FC<{
|
|
14
|
+
currentValue: number;
|
|
15
|
+
unit: LengthUnit;
|
|
16
|
+
range: NumericValueRangeDefinition | NumericValueDiscrete;
|
|
17
|
+
updateValue: (val: number, commit: boolean) => void;
|
|
18
|
+
hasNoSiblings: boolean;
|
|
19
|
+
}>;
|
|
20
|
+
export declare const RangeView: React.FC<{
|
|
21
|
+
currentValue: number;
|
|
22
|
+
unit: LengthUnit;
|
|
23
|
+
range: NumericValueRangeDefinition;
|
|
24
|
+
inputValue: number;
|
|
25
|
+
onChange: (val: number, instantUpdate: boolean) => void;
|
|
26
|
+
onCommit: () => void;
|
|
27
|
+
showRangeError: boolean;
|
|
28
|
+
} & CssProps>;
|
|
29
|
+
export {};
|
|
30
30
|
//# sourceMappingURL=CfgOptionNumericView.d.ts.map
|
|
@@ -1,132 +1,132 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { NumericValueDiscrete, NumericValueRangeDefinition } from "@configura/web-api";
|
|
11
|
-
import React, { useContext, useEffect, useState } from "react";
|
|
12
|
-
import { useRerender } from "../../useRerender.js";
|
|
13
|
-
import { useUuid } from "../../useUniqueId.js";
|
|
14
|
-
import { ErrorContext } from "../ErrorContext.js";
|
|
15
|
-
import { Checkmark } from "../icons/Checkmark.js";
|
|
16
|
-
import { ErrorIcon } from "../icons/ErrorIcon.js";
|
|
17
|
-
export const CfgOptionNumericView = (props) => {
|
|
18
|
-
const { option } = props;
|
|
19
|
-
const { isUseNumericValue } = option;
|
|
20
|
-
const setError = useContext(ErrorContext);
|
|
21
|
-
// Contrary to most other components this one has its own connection to the
|
|
22
|
-
// option that is backing it. This is for it to be able to "live" update
|
|
23
|
-
// as we drag sliders. The value is not "commited" at immediate drag, and so
|
|
24
|
-
// the full machinery of validations and such is not run until later.
|
|
25
|
-
const rerender = useRerender();
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
option.listenForChange(rerender);
|
|
28
|
-
return () => {
|
|
29
|
-
option.stopListenForChange(rerender);
|
|
30
|
-
};
|
|
31
|
-
}, [option, rerender]);
|
|
32
|
-
if (!isUseNumericValue) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
const { allowedNumericValues, numericValue, unit } = option;
|
|
36
|
-
if (allowedNumericValues === undefined) {
|
|
37
|
-
throw new Error("AllowedNumericValues undefined for numeric option");
|
|
38
|
-
}
|
|
39
|
-
if (numericValue === undefined) {
|
|
40
|
-
throw new Error("Numeric value not set for numeric option");
|
|
41
|
-
}
|
|
42
|
-
const { ranges } = allowedNumericValues;
|
|
43
|
-
const isSingleRange = ranges.length === 1;
|
|
44
|
-
if (isSingleRange && ranges[0] instanceof NumericValueDiscrete) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
return (React.createElement("ul", { className: `cfgOptionTree cfgOptionTree--subLevel cfgOptionTree--indent ${props.className || ""}`, style: props.style }, ranges.map((range) => (React.createElement(NumericValueView, { currentValue: numericValue, unit: unit, range: range, key: range.first, hasNoSiblings: isSingleRange, updateValue: (value, commit) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
-
return yield option.setNumericValue(value, commit).catch((e) => {
|
|
49
|
-
setError(e);
|
|
50
|
-
throw e;
|
|
51
|
-
});
|
|
52
|
-
}) })))));
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Displays GUI for selecting in one "range". Please note that the range
|
|
56
|
-
* parameter can also be a discrete value.
|
|
57
|
-
*/
|
|
58
|
-
export const NumericValueView = (props) => {
|
|
59
|
-
const { range, currentValue, updateValue, hasNoSiblings } = props;
|
|
60
|
-
const { legend, first } = range;
|
|
61
|
-
const selected = range.includesValue(currentValue);
|
|
62
|
-
const optionClasses = selected ? "cfgFeatureItemOption--checked" : "";
|
|
63
|
-
const uniqueId = useUuid();
|
|
64
|
-
const [inputValue, setInputValue] = useState(first);
|
|
65
|
-
const [inputCommited, setInputCommited] = useState(true);
|
|
66
|
-
const [showRangeError, setShowRangeError] = useState(false);
|
|
67
|
-
if (inputCommited && inputValue !== currentValue && range.includesValue(currentValue)) {
|
|
68
|
-
setInputValue(currentValue);
|
|
69
|
-
}
|
|
70
|
-
function isAcceptableValue(value) {
|
|
71
|
-
return !isNaN(value) && range.includesValue(value);
|
|
72
|
-
}
|
|
73
|
-
return (React.createElement("li", { className: `cfgFeatureItem cfgMb1 ${hasNoSiblings ? "" : "cfgMt1"}` },
|
|
74
|
-
!hasNoSiblings && (React.createElement("label", { className: `cfgFeatureItemOption ${optionClasses}`, htmlFor: uniqueId },
|
|
75
|
-
React.createElement("input", { checked: selected, className: "cfgFeatureItem__hiddenInput", id: uniqueId, name: uniqueId, onChange: (event) => {
|
|
76
|
-
if (event.target.checked) {
|
|
77
|
-
updateValue(inputValue, true);
|
|
78
|
-
}
|
|
79
|
-
}, type: "radio", value: first }),
|
|
80
|
-
React.createElement("div", { className: "cfgFeatureItem__radio" }, selected && React.createElement(Checkmark, null)),
|
|
81
|
-
React.createElement("div", { className: "cfgFeatureItemOption__titleWrapper" },
|
|
82
|
-
React.createElement("div", { className: "cfgFeatureItemOption__title" }, legend)))),
|
|
83
|
-
selected && range instanceof NumericValueRangeDefinition && (React.createElement(RangeView, Object.assign({}, props, { className: hasNoSiblings ? undefined : "cfgOptionTree--indent", range: range, onChange: (val, instantUpdate) => {
|
|
84
|
-
setInputValue(val);
|
|
85
|
-
if (!isAcceptableValue(inputValue)) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
if (instantUpdate) {
|
|
89
|
-
updateValue(val, false);
|
|
90
|
-
}
|
|
91
|
-
setShowRangeError(false);
|
|
92
|
-
setInputCommited(false);
|
|
93
|
-
}, onCommit: () => {
|
|
94
|
-
if (inputCommited) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (!isAcceptableValue(inputValue)) {
|
|
98
|
-
setShowRangeError(true);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
updateValue(inputValue, true);
|
|
102
|
-
setShowRangeError(false);
|
|
103
|
-
setInputCommited(true);
|
|
104
|
-
}, inputValue: inputValue, showRangeError: showRangeError })))));
|
|
105
|
-
};
|
|
106
|
-
export const RangeView = (props) => {
|
|
107
|
-
const { currentValue, unit, inputValue, range, onChange, onCommit, showRangeError } = props;
|
|
108
|
-
const { minValue, maxValue, increment, legend } = range;
|
|
109
|
-
const getOnChange = (instant) => (event) => onChange(event.currentTarget.valueAsNumber, instant);
|
|
110
|
-
const inputProps = {
|
|
111
|
-
min: minValue,
|
|
112
|
-
max: maxValue,
|
|
113
|
-
step: increment || Math.pow(10, Math.round(Math.log10(maxValue - minValue)) - 3),
|
|
114
|
-
enterKeyHint: "enter",
|
|
115
|
-
onBlur: onCommit,
|
|
116
|
-
onMouseUp: onCommit,
|
|
117
|
-
onKeyPress: (event) => {
|
|
118
|
-
if (event.key === "Enter") {
|
|
119
|
-
onCommit();
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
return (React.createElement("div", { className: `cfgRangeView cfgMt1 ${props.className || ""}`, style: props.style },
|
|
124
|
-
React.createElement("div", { className: "cfgRangeView__inputs" },
|
|
125
|
-
React.createElement("input", Object.assign({}, inputProps, { type: "number", value: isNaN(inputValue) ? "" : inputValue, onChange: getOnChange(false), className: "cfgInput cfgRangeView__number-input" })),
|
|
126
|
-
React.createElement("span", { className: "cfgRangeView__unit-label" }, unit),
|
|
127
|
-
React.createElement("input", Object.assign({}, inputProps, { type: "range", className: "cfgSlider cfgRangeView__slider-input", value: currentValue, onChange: getOnChange(true) }))),
|
|
128
|
-
showRangeError && (React.createElement("div", { className: "cfgRangeView__error" },
|
|
129
|
-
React.createElement(ErrorIcon, null),
|
|
130
|
-
" Value not allowed, allowed values are ",
|
|
131
|
-
legend))));
|
|
132
|
-
};
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { NumericValueDiscrete, NumericValueRangeDefinition } from "@configura/web-api";
|
|
11
|
+
import React, { useContext, useEffect, useState } from "react";
|
|
12
|
+
import { useRerender } from "../../useRerender.js";
|
|
13
|
+
import { useUuid } from "../../useUniqueId.js";
|
|
14
|
+
import { ErrorContext } from "../ErrorContext.js";
|
|
15
|
+
import { Checkmark } from "../icons/Checkmark.js";
|
|
16
|
+
import { ErrorIcon } from "../icons/ErrorIcon.js";
|
|
17
|
+
export const CfgOptionNumericView = (props) => {
|
|
18
|
+
const { option } = props;
|
|
19
|
+
const { isUseNumericValue } = option;
|
|
20
|
+
const setError = useContext(ErrorContext);
|
|
21
|
+
// Contrary to most other components this one has its own connection to the
|
|
22
|
+
// option that is backing it. This is for it to be able to "live" update
|
|
23
|
+
// as we drag sliders. The value is not "commited" at immediate drag, and so
|
|
24
|
+
// the full machinery of validations and such is not run until later.
|
|
25
|
+
const rerender = useRerender();
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
option.listenForChange(rerender);
|
|
28
|
+
return () => {
|
|
29
|
+
option.stopListenForChange(rerender);
|
|
30
|
+
};
|
|
31
|
+
}, [option, rerender]);
|
|
32
|
+
if (!isUseNumericValue) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const { allowedNumericValues, numericValue, unit } = option;
|
|
36
|
+
if (allowedNumericValues === undefined) {
|
|
37
|
+
throw new Error("AllowedNumericValues undefined for numeric option");
|
|
38
|
+
}
|
|
39
|
+
if (numericValue === undefined) {
|
|
40
|
+
throw new Error("Numeric value not set for numeric option");
|
|
41
|
+
}
|
|
42
|
+
const { ranges } = allowedNumericValues;
|
|
43
|
+
const isSingleRange = ranges.length === 1;
|
|
44
|
+
if (isSingleRange && ranges[0] instanceof NumericValueDiscrete) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return (React.createElement("ul", { className: `cfgOptionTree cfgOptionTree--subLevel cfgOptionTree--indent ${props.className || ""}`, style: props.style }, ranges.map((range) => (React.createElement(NumericValueView, { currentValue: numericValue, unit: unit, range: range, key: range.first, hasNoSiblings: isSingleRange, updateValue: (value, commit) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
+
return yield option.setNumericValue(value, commit).catch((e) => {
|
|
49
|
+
setError(e);
|
|
50
|
+
throw e;
|
|
51
|
+
});
|
|
52
|
+
}) })))));
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Displays GUI for selecting in one "range". Please note that the range
|
|
56
|
+
* parameter can also be a discrete value.
|
|
57
|
+
*/
|
|
58
|
+
export const NumericValueView = (props) => {
|
|
59
|
+
const { range, currentValue, updateValue, hasNoSiblings } = props;
|
|
60
|
+
const { legend, first } = range;
|
|
61
|
+
const selected = range.includesValue(currentValue);
|
|
62
|
+
const optionClasses = selected ? "cfgFeatureItemOption--checked" : "";
|
|
63
|
+
const uniqueId = useUuid();
|
|
64
|
+
const [inputValue, setInputValue] = useState(first);
|
|
65
|
+
const [inputCommited, setInputCommited] = useState(true);
|
|
66
|
+
const [showRangeError, setShowRangeError] = useState(false);
|
|
67
|
+
if (inputCommited && inputValue !== currentValue && range.includesValue(currentValue)) {
|
|
68
|
+
setInputValue(currentValue);
|
|
69
|
+
}
|
|
70
|
+
function isAcceptableValue(value) {
|
|
71
|
+
return !isNaN(value) && range.includesValue(value);
|
|
72
|
+
}
|
|
73
|
+
return (React.createElement("li", { className: `cfgFeatureItem cfgMb1 ${hasNoSiblings ? "" : "cfgMt1"}` },
|
|
74
|
+
!hasNoSiblings && (React.createElement("label", { className: `cfgFeatureItemOption ${optionClasses}`, htmlFor: uniqueId },
|
|
75
|
+
React.createElement("input", { checked: selected, className: "cfgFeatureItem__hiddenInput", id: uniqueId, name: uniqueId, onChange: (event) => {
|
|
76
|
+
if (event.target.checked) {
|
|
77
|
+
updateValue(inputValue, true);
|
|
78
|
+
}
|
|
79
|
+
}, type: "radio", value: first }),
|
|
80
|
+
React.createElement("div", { className: "cfgFeatureItem__radio" }, selected && React.createElement(Checkmark, null)),
|
|
81
|
+
React.createElement("div", { className: "cfgFeatureItemOption__titleWrapper" },
|
|
82
|
+
React.createElement("div", { className: "cfgFeatureItemOption__title" }, legend)))),
|
|
83
|
+
selected && range instanceof NumericValueRangeDefinition && (React.createElement(RangeView, Object.assign({}, props, { className: hasNoSiblings ? undefined : "cfgOptionTree--indent", range: range, onChange: (val, instantUpdate) => {
|
|
84
|
+
setInputValue(val);
|
|
85
|
+
if (!isAcceptableValue(inputValue)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (instantUpdate) {
|
|
89
|
+
updateValue(val, false);
|
|
90
|
+
}
|
|
91
|
+
setShowRangeError(false);
|
|
92
|
+
setInputCommited(false);
|
|
93
|
+
}, onCommit: () => {
|
|
94
|
+
if (inputCommited) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (!isAcceptableValue(inputValue)) {
|
|
98
|
+
setShowRangeError(true);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
updateValue(inputValue, true);
|
|
102
|
+
setShowRangeError(false);
|
|
103
|
+
setInputCommited(true);
|
|
104
|
+
}, inputValue: inputValue, showRangeError: showRangeError })))));
|
|
105
|
+
};
|
|
106
|
+
export const RangeView = (props) => {
|
|
107
|
+
const { currentValue, unit, inputValue, range, onChange, onCommit, showRangeError } = props;
|
|
108
|
+
const { minValue, maxValue, increment, legend } = range;
|
|
109
|
+
const getOnChange = (instant) => (event) => onChange(event.currentTarget.valueAsNumber, instant);
|
|
110
|
+
const inputProps = {
|
|
111
|
+
min: minValue,
|
|
112
|
+
max: maxValue,
|
|
113
|
+
step: increment || Math.pow(10, Math.round(Math.log10(maxValue - minValue)) - 3),
|
|
114
|
+
enterKeyHint: "enter",
|
|
115
|
+
onBlur: onCommit,
|
|
116
|
+
onMouseUp: onCommit,
|
|
117
|
+
onKeyPress: (event) => {
|
|
118
|
+
if (event.key === "Enter") {
|
|
119
|
+
onCommit();
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
return (React.createElement("div", { className: `cfgRangeView cfgMt1 ${props.className || ""}`, style: props.style },
|
|
124
|
+
React.createElement("div", { className: "cfgRangeView__inputs" },
|
|
125
|
+
React.createElement("input", Object.assign({}, inputProps, { type: "number", value: isNaN(inputValue) ? "" : inputValue, onChange: getOnChange(false), className: "cfgInput cfgRangeView__number-input" })),
|
|
126
|
+
React.createElement("span", { className: "cfgRangeView__unit-label" }, unit),
|
|
127
|
+
React.createElement("input", Object.assign({}, inputProps, { type: "range", className: "cfgSlider cfgRangeView__slider-input", value: currentValue, onChange: getOnChange(true) }))),
|
|
128
|
+
showRangeError && (React.createElement("div", { className: "cfgRangeView__error" },
|
|
129
|
+
React.createElement(ErrorIcon, null),
|
|
130
|
+
" Value not allowed, allowed values are ",
|
|
131
|
+
legend))));
|
|
132
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { CfgOption } from "@configura/web-api";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { UpchargeDisplayMode } from "./CfgProductConfigurationView.js";
|
|
4
|
-
declare type Props = {
|
|
5
|
-
option: CfgOption;
|
|
6
|
-
upchargeDisplayMode: UpchargeDisplayMode | undefined;
|
|
7
|
-
};
|
|
8
|
-
export declare const CfgOptionPriceView: React.FC<Props>;
|
|
9
|
-
export {};
|
|
1
|
+
import { CfgOption } from "@configura/web-api";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { UpchargeDisplayMode } from "./CfgProductConfigurationView.js";
|
|
4
|
+
declare type Props = {
|
|
5
|
+
option: CfgOption;
|
|
6
|
+
upchargeDisplayMode: UpchargeDisplayMode | undefined;
|
|
7
|
+
};
|
|
8
|
+
export declare const CfgOptionPriceView: React.FC<Props>;
|
|
9
|
+
export {};
|
|
10
10
|
//# sourceMappingURL=CfgOptionPriceView.d.ts.map
|