@configura/web-ui 2.1.0-alpha.1 → 2.1.0-alpha.3

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.
Files changed (115) hide show
  1. package/.eslintrc.json +5 -5
  2. package/.postcssrc.json +8 -8
  3. package/LICENSE +201 -201
  4. package/README.md +1 -1
  5. package/dist/components/CanvasWrapper.d.ts +9 -9
  6. package/dist/components/CanvasWrapper.js +8 -8
  7. package/dist/components/CfgPriceView.d.ts +6 -6
  8. package/dist/components/CfgPriceView.js +13 -13
  9. package/dist/components/ConfigurationActionsButtonRow.d.ts +14 -14
  10. package/dist/components/ConfigurationActionsButtonRow.js +16 -16
  11. package/dist/components/Configurator.d.ts +12 -12
  12. package/dist/components/Configurator.js +15 -15
  13. package/dist/components/ConfiguratorWrapper.d.ts +8 -8
  14. package/dist/components/ConfiguratorWrapper.js +5 -5
  15. package/dist/components/CurrencyPrice.d.ts +9 -9
  16. package/dist/components/CurrencyPrice.js +7 -7
  17. package/dist/components/ErrorContext.d.ts +2 -2
  18. package/dist/components/ErrorContext.js +2 -2
  19. package/dist/components/ExpandableHeadingRow.d.ts +15 -15
  20. package/dist/components/ExpandableHeadingRow.js +23 -23
  21. package/dist/components/Loading.d.ts +13 -13
  22. package/dist/components/Loading.js +20 -20
  23. package/dist/components/ProductInformation.d.ts +13 -13
  24. package/dist/components/ProductInformation.js +14 -14
  25. package/dist/components/ResetButton.d.ts +8 -8
  26. package/dist/components/ResetButton.js +7 -7
  27. package/dist/components/ShareView.d.ts +3 -3
  28. package/dist/components/ShareView.js +21 -21
  29. package/dist/components/TaskListView.d.ts +8 -8
  30. package/dist/components/TaskListView.js +69 -69
  31. package/dist/components/TaskStartView.d.ts +12 -12
  32. package/dist/components/TaskStartView.js +29 -29
  33. package/dist/components/icons/Checkmark.d.ts +6 -6
  34. package/dist/components/icons/Checkmark.js +12 -12
  35. package/dist/components/icons/Chevron.d.ts +7 -7
  36. package/dist/components/icons/Chevron.js +18 -18
  37. package/dist/components/icons/CircleXmarkIcon.d.ts +3 -3
  38. package/dist/components/icons/CircleXmarkIcon.js +8 -8
  39. package/dist/components/icons/DownloadIcon.d.ts +3 -3
  40. package/dist/components/icons/DownloadIcon.js +8 -8
  41. package/dist/components/icons/ErrorIcon.d.ts +3 -3
  42. package/dist/components/icons/ErrorIcon.js +8 -8
  43. package/dist/components/productConfiguration/CfgAdditionalProductView.d.ts +3 -3
  44. package/dist/components/productConfiguration/CfgAdditionalProductView.js +46 -46
  45. package/dist/components/productConfiguration/CfgCheckboxView.d.ts +4 -4
  46. package/dist/components/productConfiguration/CfgCheckboxView.js +7 -7
  47. package/dist/components/productConfiguration/CfgCheckboxesView.d.ts +4 -4
  48. package/dist/components/productConfiguration/CfgCheckboxesView.js +20 -20
  49. package/dist/components/productConfiguration/CfgConfigurationCommonView.d.ts +7 -7
  50. package/dist/components/productConfiguration/CfgConfigurationCommonView.js +8 -8
  51. package/dist/components/productConfiguration/CfgDropdownOptionView.d.ts +4 -4
  52. package/dist/components/productConfiguration/CfgDropdownOptionView.js +23 -23
  53. package/dist/components/productConfiguration/CfgDropdownView.d.ts +4 -4
  54. package/dist/components/productConfiguration/CfgDropdownView.js +23 -23
  55. package/dist/components/productConfiguration/CfgFeatureView.d.ts +72 -72
  56. package/dist/components/productConfiguration/CfgFeatureView.js +77 -76
  57. package/dist/components/productConfiguration/CfgGroupView.d.ts +4 -4
  58. package/dist/components/productConfiguration/CfgGroupView.js +7 -7
  59. package/dist/components/productConfiguration/CfgMiscFile.d.ts +4 -4
  60. package/dist/components/productConfiguration/CfgMiscFile.js +9 -9
  61. package/dist/components/productConfiguration/CfgMiscFiles.d.ts +4 -4
  62. package/dist/components/productConfiguration/CfgMiscFiles.js +5 -5
  63. package/dist/components/productConfiguration/CfgNote.d.ts +4 -4
  64. package/dist/components/productConfiguration/CfgNote.js +15 -15
  65. package/dist/components/productConfiguration/CfgNotes.d.ts +4 -4
  66. package/dist/components/productConfiguration/CfgNotes.js +5 -5
  67. package/dist/components/productConfiguration/CfgOptionCommonView.d.ts +6 -6
  68. package/dist/components/productConfiguration/CfgOptionCommonView.js +53 -50
  69. package/dist/components/productConfiguration/CfgOptionNumericView.d.ts +29 -29
  70. package/dist/components/productConfiguration/CfgOptionNumericView.js +132 -132
  71. package/dist/components/productConfiguration/CfgOptionPriceView.d.ts +9 -9
  72. package/dist/components/productConfiguration/CfgOptionPriceView.js +31 -31
  73. package/dist/components/productConfiguration/CfgProductConfigurationView.d.ts +24 -22
  74. package/dist/components/productConfiguration/CfgProductConfigurationView.js +50 -50
  75. package/dist/css/web-ui.css.map +1 -1
  76. package/dist/index.d.ts +29 -29
  77. package/dist/index.js +29 -29
  78. package/dist/scss/_button.scss +52 -52
  79. package/dist/scss/_configurator.scss +132 -132
  80. package/dist/scss/_expandable.scss +38 -38
  81. package/dist/scss/_feature-item.scss +146 -146
  82. package/dist/scss/_forms.scss +44 -44
  83. package/dist/scss/_hr.scss +16 -16
  84. package/dist/scss/_loading.scss +98 -98
  85. package/dist/scss/_misc-file-and-note.scss +44 -44
  86. package/dist/scss/_mixins.scss +56 -56
  87. package/dist/scss/_option-tree.scss +29 -29
  88. package/dist/scss/_product-information.scss +53 -53
  89. package/dist/scss/_range-view.scss +39 -39
  90. package/dist/scss/_slider.scss +70 -70
  91. package/dist/scss/_tasks.scss +72 -72
  92. package/dist/scss/_themed.scss +156 -156
  93. package/dist/scss/_utilities.scss +21 -21
  94. package/dist/scss/_variables.scss +6 -6
  95. package/dist/scss/icons/_checkmark.scss +46 -46
  96. package/dist/scss/icons/_chevron.scss +62 -62
  97. package/dist/scss/icons/_circle-xmark-icon.scss +24 -24
  98. package/dist/scss/icons/_download-icon.scss +24 -24
  99. package/dist/scss/icons/_error-icon.scss +24 -24
  100. package/dist/scss/web-ui.scss +11 -11
  101. package/dist/useCatParams.d.ts +17 -17
  102. package/dist/useCatParams.js +29 -29
  103. package/dist/useObservable.d.ts +4 -4
  104. package/dist/useObservable.js +18 -18
  105. package/dist/useRerender.d.ts +1 -1
  106. package/dist/useRerender.js +5 -5
  107. package/dist/useResize.d.ts +6 -6
  108. package/dist/useResize.js +47 -47
  109. package/dist/useSelected.d.ts +2 -2
  110. package/dist/useSelected.js +13 -13
  111. package/dist/useUniqueId.d.ts +1 -1
  112. package/dist/useUniqueId.js +3 -3
  113. package/dist/utilities.d.ts +5 -5
  114. package/dist/utilities.js +1 -1
  115. package/package.json +3 -3
@@ -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
@@ -1,31 +1,31 @@
1
- import React from "react";
2
- import { CurrencyPrice } from "../CurrencyPrice.js";
3
- import { UpchargeDisplayMode } from "./CfgProductConfigurationView.js";
4
- export const CfgOptionPriceView = (props) => {
5
- const { option, upchargeDisplayMode } = props;
6
- const { currency, fractionDigits, lang } = option.parentProduct;
7
- if (currency === "") {
8
- return null;
9
- }
10
- switch (upchargeDisplayMode) {
11
- case UpchargeDisplayMode.None:
12
- return null;
13
- case UpchargeDisplayMode.Price: {
14
- const { upcharge } = option;
15
- if (upcharge === 0) {
16
- return null;
17
- }
18
- return (React.createElement("div", { className: "cfgFeatureItemOption__price" },
19
- React.createElement(CurrencyPrice, { currency: currency, language: lang, price: upcharge, fractionDigits: fractionDigits })));
20
- }
21
- default: {
22
- const { priceChangeAtSelectChange } = option;
23
- if (priceChangeAtSelectChange === 0) {
24
- return null;
25
- }
26
- return (React.createElement("div", { className: "cfgFeatureItemOption__price" },
27
- priceChangeAtSelectChange < 0 ? "-" : "+",
28
- React.createElement(CurrencyPrice, { currency: currency, language: lang, price: Math.abs(priceChangeAtSelectChange), fractionDigits: fractionDigits })));
29
- }
30
- }
31
- };
1
+ import React from "react";
2
+ import { CurrencyPrice } from "../CurrencyPrice.js";
3
+ import { UpchargeDisplayMode } from "./CfgProductConfigurationView.js";
4
+ export const CfgOptionPriceView = (props) => {
5
+ const { option, upchargeDisplayMode } = props;
6
+ const { currency, fractionDigits, lang } = option.parentProduct;
7
+ if (currency === "") {
8
+ return null;
9
+ }
10
+ switch (upchargeDisplayMode) {
11
+ case UpchargeDisplayMode.None:
12
+ return null;
13
+ case UpchargeDisplayMode.Price: {
14
+ const { upcharge } = option;
15
+ if (upcharge === 0) {
16
+ return null;
17
+ }
18
+ return (React.createElement("div", { className: "cfgFeatureItemOption__price" },
19
+ React.createElement(CurrencyPrice, { currency: currency, language: lang, price: upcharge, fractionDigits: fractionDigits })));
20
+ }
21
+ default: {
22
+ const { priceChangeAtSelectChange } = option;
23
+ if (priceChangeAtSelectChange === 0) {
24
+ return null;
25
+ }
26
+ return (React.createElement("div", { className: "cfgFeatureItemOption__price" },
27
+ priceChangeAtSelectChange < 0 ? "-" : "+",
28
+ React.createElement(CurrencyPrice, { currency: currency, language: lang, price: Math.abs(priceChangeAtSelectChange), fractionDigits: fractionDigits })));
29
+ }
30
+ }
31
+ };
@@ -1,23 +1,25 @@
1
- import { CfgProduct, CfgProductConfiguration } from "@configura/web-api";
2
- import React from "react";
3
- import { CssProps } from "../../utilities.js";
4
- import { CfgProductConfigurationComponent } from "./CfgFeatureView.js";
5
- export declare enum UpchargeDisplayMode {
6
- SelectionImpact = 0,
7
- None = 1,
8
- Price = 2
9
- }
10
- /**
11
- * @param upchargeDisplayMode How upcharge on Options is displayed
12
- * @param startOpen Setting this to true will make all selected options be expanded from start. This is bad for performance when viewing large products.
13
- */
14
- export declare type PassthroughProps = {
15
- upchargeDisplayMode?: UpchargeDisplayMode;
16
- startOpen?: boolean;
17
- };
18
- export declare type CfgProductConfigurationViewProps = PassthroughProps & Partial<CfgProductConfigurationComponent> & CssProps & {
19
- productOrConfiguration: CfgProductConfiguration | CfgProduct;
20
- permanentlyExpandedAdditionalProductLevels?: number;
21
- };
22
- export declare const CfgProductConfigurationView: React.FC<CfgProductConfigurationViewProps>;
1
+ import { CfgProduct, CfgProductConfiguration } from "@configura/web-api";
2
+ import React from "react";
3
+ import { CssProps } from "../../utilities.js";
4
+ import { CfgProductConfigurationComponent } from "./CfgFeatureView.js";
5
+ export declare enum UpchargeDisplayMode {
6
+ SelectionImpact = 0,
7
+ None = 1,
8
+ Price = 2
9
+ }
10
+ /**
11
+ * @param upchargeDisplayMode How upcharge on Options is displayed
12
+ * @param startOpen Setting this to true will make all selected options be expanded from start. This is bad for performance when viewing large products.
13
+ * @param hideDisabledOptions Setting this to true will make all disabled options hidden.
14
+ */
15
+ export declare type PassthroughProps = {
16
+ upchargeDisplayMode?: UpchargeDisplayMode;
17
+ startOpen?: boolean;
18
+ hideDisabledOptions?: boolean;
19
+ };
20
+ export declare type CfgProductConfigurationViewProps = PassthroughProps & Partial<CfgProductConfigurationComponent> & CssProps & {
21
+ productOrConfiguration: CfgProductConfiguration | CfgProduct;
22
+ permanentlyExpandedAdditionalProductLevels?: number;
23
+ };
24
+ export declare const CfgProductConfigurationView: React.FC<CfgProductConfigurationViewProps>;
23
25
  //# sourceMappingURL=CfgProductConfigurationView.d.ts.map
@@ -1,50 +1,50 @@
1
- import { CfgProduct, CfgProductConfiguration } from "@configura/web-api";
2
- import React, { useEffect } from "react";
3
- import { useRerender } from "../../useRerender.js";
4
- import { CfgConfigurationCommonView } from "./CfgConfigurationCommonView.js";
5
- import { CfgFeatureViewMemo, forwardProps, useCompleteWithDefaultProductConfigurationComponents, } from "./CfgFeatureView.js";
6
- export var UpchargeDisplayMode;
7
- (function (UpchargeDisplayMode) {
8
- UpchargeDisplayMode[UpchargeDisplayMode["SelectionImpact"] = 0] = "SelectionImpact";
9
- UpchargeDisplayMode[UpchargeDisplayMode["None"] = 1] = "None";
10
- UpchargeDisplayMode[UpchargeDisplayMode["Price"] = 2] = "Price";
11
- })(UpchargeDisplayMode || (UpchargeDisplayMode = {}));
12
- export const CfgProductConfigurationView = React.memo((props) => {
13
- const completedProps = Object.assign(Object.assign({}, props), useCompleteWithDefaultProductConfigurationComponents(props));
14
- const { productOrConfiguration, permanentlyExpandedAdditionalProductLevels, additionalProductComponent: AdditionalProductComponent, } = completedProps;
15
- const configuration = productOrConfiguration instanceof CfgProduct
16
- ? productOrConfiguration.configuration
17
- : productOrConfiguration;
18
- const configurationVisible = productOrConfiguration instanceof CfgProductConfiguration ||
19
- productOrConfiguration.visible;
20
- const features = configuration.features.reduce((agg, feature) => {
21
- // It is possible in Cat Creator to double add a Feature. This fills no known
22
- // purpose and React can not handle this, so we filter out the duplicates.
23
- const code = feature.code;
24
- if (agg.every((f) => f.code !== code)) {
25
- agg.push(feature);
26
- }
27
- return agg;
28
- }, []);
29
- const additionalProducts = productOrConfiguration instanceof CfgProduct
30
- ? productOrConfiguration.additionalProducts
31
- : undefined;
32
- // const AdditionalProductComponent = additionalProductComponent || CfgAdditionalProductView;
33
- // Re-rendering is driven from the very top of the tree. However, when selecting an option
34
- // the change is not bubbled all the way to the top (and then down again) until after
35
- // validation has been done. This keeps the 3D-view from re-rendering until after validation
36
- // has been done. But it also makes the state of this GUI not update until after validate,
37
- // which does not look good. So we add this extra hook to make this rerender early.
38
- const rerender = useRerender();
39
- useEffect(() => {
40
- configuration.listenForChange(rerender);
41
- return () => {
42
- configuration.stopListenForChange(rerender);
43
- };
44
- }, [configuration, rerender]);
45
- return (React.createElement(React.Fragment, null,
46
- configurationVisible && (React.createElement(React.Fragment, null,
47
- React.createElement(CfgConfigurationCommonView, Object.assign({}, forwardProps(completedProps), { notes: configuration.parentProduct.notes, miscFiles: configuration.parentProduct.miscFiles })),
48
- React.createElement("ul", { className: `cfgOptionTree cfgOptionTree--topLevel ${props.className || ""}`, style: props.style }, features.map((f) => (React.createElement(CfgFeatureViewMemo, Object.assign({ feature: f, key: f.key }, forwardProps(completedProps)))))))),
49
- additionalProducts !== undefined && (React.createElement("ul", { className: `cfgOptionTree cfgOptionTree--topLevel` }, additionalProducts.map((additionalProduct) => (React.createElement(AdditionalProductComponent, Object.assign({ key: additionalProduct.key }, forwardProps(completedProps), { product: additionalProduct, permanentlyExpandedLevels: permanentlyExpandedAdditionalProductLevels !== null && permanentlyExpandedAdditionalProductLevels !== void 0 ? permanentlyExpandedAdditionalProductLevels : 0 }))))))));
50
- });
1
+ import { CfgProduct, CfgProductConfiguration } from "@configura/web-api";
2
+ import React, { useEffect } from "react";
3
+ import { useRerender } from "../../useRerender.js";
4
+ import { CfgConfigurationCommonView } from "./CfgConfigurationCommonView.js";
5
+ import { CfgFeatureViewMemo, forwardProps, useCompleteWithDefaultProductConfigurationComponents, } from "./CfgFeatureView.js";
6
+ export var UpchargeDisplayMode;
7
+ (function (UpchargeDisplayMode) {
8
+ UpchargeDisplayMode[UpchargeDisplayMode["SelectionImpact"] = 0] = "SelectionImpact";
9
+ UpchargeDisplayMode[UpchargeDisplayMode["None"] = 1] = "None";
10
+ UpchargeDisplayMode[UpchargeDisplayMode["Price"] = 2] = "Price";
11
+ })(UpchargeDisplayMode || (UpchargeDisplayMode = {}));
12
+ export const CfgProductConfigurationView = React.memo((props) => {
13
+ const completedProps = Object.assign(Object.assign({}, props), useCompleteWithDefaultProductConfigurationComponents(props));
14
+ const { productOrConfiguration, permanentlyExpandedAdditionalProductLevels, additionalProductComponent: AdditionalProductComponent, } = completedProps;
15
+ const configuration = productOrConfiguration instanceof CfgProduct
16
+ ? productOrConfiguration.configuration
17
+ : productOrConfiguration;
18
+ const configurationVisible = productOrConfiguration instanceof CfgProductConfiguration ||
19
+ productOrConfiguration.visible;
20
+ const features = configuration.features.reduce((agg, feature) => {
21
+ // It is possible in Cat Creator to double add a Feature. This fills no known
22
+ // purpose and React can not handle this, so we filter out the duplicates.
23
+ const code = feature.code;
24
+ if (agg.every((f) => f.code !== code)) {
25
+ agg.push(feature);
26
+ }
27
+ return agg;
28
+ }, []);
29
+ const additionalProducts = productOrConfiguration instanceof CfgProduct
30
+ ? productOrConfiguration.additionalProducts
31
+ : undefined;
32
+ // const AdditionalProductComponent = additionalProductComponent || CfgAdditionalProductView;
33
+ // Re-rendering is driven from the very top of the tree. However, when selecting an option
34
+ // the change is not bubbled all the way to the top (and then down again) until after
35
+ // validation has been done. This keeps the 3D-view from re-rendering until after validation
36
+ // has been done. But it also makes the state of this GUI not update until after validate,
37
+ // which does not look good. So we add this extra hook to make this rerender early.
38
+ const rerender = useRerender();
39
+ useEffect(() => {
40
+ configuration.listenForChange(rerender);
41
+ return () => {
42
+ configuration.stopListenForChange(rerender);
43
+ };
44
+ }, [configuration, rerender]);
45
+ return (React.createElement(React.Fragment, null,
46
+ configurationVisible && (React.createElement(React.Fragment, null,
47
+ React.createElement(CfgConfigurationCommonView, Object.assign({}, forwardProps(completedProps), { notes: configuration.parentProduct.notes, miscFiles: configuration.parentProduct.miscFiles })),
48
+ React.createElement("ul", { className: `cfgOptionTree cfgOptionTree--topLevel ${props.className || ""}`, style: props.style }, features.map((f) => (React.createElement(CfgFeatureViewMemo, Object.assign({ feature: f, key: f.key }, forwardProps(completedProps)))))))),
49
+ additionalProducts !== undefined && (React.createElement("ul", { className: `cfgOptionTree cfgOptionTree--topLevel` }, additionalProducts.map((additionalProduct) => (React.createElement(AdditionalProductComponent, Object.assign({ key: additionalProduct.key }, forwardProps(completedProps), { product: additionalProduct, permanentlyExpandedLevels: permanentlyExpandedAdditionalProductLevels !== null && permanentlyExpandedAdditionalProductLevels !== void 0 ? permanentlyExpandedAdditionalProductLevels : 0 }))))))));
50
+ });