@crystaldesign/quick-config 26.3.0-beta.3 → 26.3.0-beta.30
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/build/cjs/index.js +2107 -0
- package/build/esm/index.js +2090 -0
- package/build/types/quick-config/src/Components/ConditionEvaluator/index.d.ts +47 -0
- package/build/types/quick-config/src/Components/ConditionEvaluator/index.d.ts.map +1 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/FeatureRenderer/index.d.ts +10 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/FeatureRenderer/index.d.ts.map +1 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/Header/index.d.ts +12 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/Header/index.d.ts.map +1 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/Navigation/index.d.ts +18 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/Navigation/index.d.ts.map +1 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/OptionRenderer/Layouts/ButtonGroupLayout.d.ts +18 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/OptionRenderer/Layouts/ButtonGroupLayout.d.ts.map +1 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/OptionRenderer/Layouts/DropdownLayout.d.ts +16 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/OptionRenderer/Layouts/DropdownLayout.d.ts.map +1 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/OptionRenderer/Layouts/RangeLayout.d.ts +11 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/OptionRenderer/Layouts/RangeLayout.d.ts.map +1 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/OptionRenderer/Layouts/SelectionListLayout.d.ts +18 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/OptionRenderer/Layouts/SelectionListLayout.d.ts.map +1 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/OptionRenderer/index.d.ts +10 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/OptionRenderer/index.d.ts.map +1 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/ProgressBar/index.d.ts +7 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/ProgressBar/index.d.ts.map +1 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/ResultDisplay/components/ContentItem.d.ts +8 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/ResultDisplay/components/ContentItem.d.ts.map +1 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/ResultDisplay/components/ResultItemsRenderer.d.ts +12 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/ResultDisplay/components/ResultItemsRenderer.d.ts.map +1 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/ResultDisplay/components/SpeedometerGroup/Speedometer.d.ts +17 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/ResultDisplay/components/SpeedometerGroup/Speedometer.d.ts.map +1 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/ResultDisplay/components/SpeedometerGroup/index.d.ts +10 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/ResultDisplay/components/SpeedometerGroup/index.d.ts.map +1 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/ResultDisplay/components/TextResult.d.ts +10 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/ResultDisplay/components/TextResult.d.ts.map +1 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/ResultDisplay/index.d.ts +13 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/ResultDisplay/index.d.ts.map +1 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/ResultDisplay/utils/index.d.ts +3 -0
- package/build/types/quick-config/src/Components/QuickConfig/components/ResultDisplay/utils/index.d.ts.map +1 -0
- package/build/types/quick-config/src/Components/QuickConfig/hooks/useOptionRenderer.d.ts +19 -0
- package/build/types/quick-config/src/Components/QuickConfig/hooks/useOptionRenderer.d.ts.map +1 -0
- package/build/types/quick-config/src/Components/QuickConfig/hooks/useQuickConfig.d.ts +30 -0
- package/build/types/quick-config/src/Components/QuickConfig/hooks/useQuickConfig.d.ts.map +1 -0
- package/build/types/quick-config/src/Components/QuickConfig/hooks/useQuickConfigCalculations.d.ts +7 -0
- package/build/types/quick-config/src/Components/QuickConfig/hooks/useQuickConfigCalculations.d.ts.map +1 -0
- package/build/types/quick-config/src/Components/QuickConfig/hooks/useQuickConfigFeatures.d.ts +6 -0
- package/build/types/quick-config/src/Components/QuickConfig/hooks/useQuickConfigFeatures.d.ts.map +1 -0
- package/build/types/quick-config/src/Components/QuickConfig/hooks/useQuickConfigStorage.d.ts +9 -0
- package/build/types/quick-config/src/Components/QuickConfig/hooks/useQuickConfigStorage.d.ts.map +1 -0
- package/build/types/quick-config/src/Components/QuickConfig/index.d.ts +10 -0
- package/build/types/quick-config/src/Components/QuickConfig/index.d.ts.map +1 -0
- package/build/types/quick-config/src/calculators/variantValueCalculator.d.ts +8 -0
- package/build/types/quick-config/src/calculators/variantValueCalculator.d.ts.map +1 -0
- package/build/types/quick-config/src/index.d.ts +8 -0
- package/build/types/quick-config/src/index.d.ts.map +1 -0
- package/build/types/quick-config/src/stories/QuickConfig.stories.d.ts +17 -0
- package/build/types/quick-config/src/stories/QuickConfig.stories.d.ts.map +1 -0
- package/build/types/quick-config/src/types.d.ts +216 -0
- package/build/types/quick-config/src/types.d.ts.map +1 -0
- package/build/types/quick-config/src/utils/index.d.ts +14 -0
- package/build/types/quick-config/src/utils/index.d.ts.map +1 -0
- package/build/umd/124.quick-config.umd.min.js +2 -0
- package/build/umd/124.quick-config.umd.min.js.LICENSE.txt +1 -0
- package/build/umd/145.quick-config.umd.min.js +2 -0
- package/build/umd/145.quick-config.umd.min.js.LICENSE.txt +1 -0
- package/build/umd/338.quick-config.umd.min.js +2 -0
- package/build/umd/338.quick-config.umd.min.js.LICENSE.txt +1 -0
- package/build/umd/433.quick-config.umd.min.js +2 -0
- package/build/umd/433.quick-config.umd.min.js.LICENSE.txt +1 -0
- package/build/umd/610.quick-config.umd.min.js +2 -0
- package/build/umd/610.quick-config.umd.min.js.LICENSE.txt +1 -0
- package/build/umd/662.quick-config.umd.min.js +2 -0
- package/build/umd/662.quick-config.umd.min.js.LICENSE.txt +1 -0
- package/build/umd/721.quick-config.umd.min.js +408 -0
- package/build/umd/721.quick-config.umd.min.js.LICENSE.txt +92 -0
- package/build/umd/74.quick-config.umd.min.js +2 -0
- package/build/umd/74.quick-config.umd.min.js.LICENSE.txt +1 -0
- package/build/umd/871.quick-config.umd.min.js +2 -0
- package/build/umd/871.quick-config.umd.min.js.LICENSE.txt +1 -0
- package/build/umd/944.quick-config.umd.min.js +2 -0
- package/build/umd/944.quick-config.umd.min.js.LICENSE.txt +10 -0
- package/build/umd/quick-config.umd.min.js +102 -0
- package/build/umd/quick-config.umd.min.js.LICENSE.txt +135 -0
- package/build/umd/report.html +38 -0
- package/package.json +3 -3
|
@@ -0,0 +1,2107 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var react = require('react');
|
|
6
|
+
var divaCore = require('@crystaldesign/diva-core');
|
|
7
|
+
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
8
|
+
var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
|
|
9
|
+
var _createClass = require('@babel/runtime/helpers/createClass');
|
|
10
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
11
|
+
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
12
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
13
|
+
var _typeof = require('@babel/runtime/helpers/typeof');
|
|
14
|
+
var classNames = require('classnames');
|
|
15
|
+
|
|
16
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
17
|
+
|
|
18
|
+
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
|
|
19
|
+
var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallCheck);
|
|
20
|
+
var _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);
|
|
21
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
22
|
+
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
23
|
+
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
|
|
24
|
+
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
25
|
+
|
|
26
|
+
(function() {
|
|
27
|
+
const env = {"STAGE":"production"};
|
|
28
|
+
try {
|
|
29
|
+
if (process) {
|
|
30
|
+
process.env = Object.assign({}, process.env);
|
|
31
|
+
Object.assign(process.env, env);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
} catch (e) {} // avoid ReferenceError: process is not defined
|
|
35
|
+
globalThis.process = { env:env };
|
|
36
|
+
})();
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Utility functions for QuickConfig
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Get translated text with fallback
|
|
44
|
+
*/
|
|
45
|
+
function getTranslatedText(translations, language, fallbackCodex) {
|
|
46
|
+
return translations[language] || translations.en || translations.de || fallbackCodex || '';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Validate QuickConfig definition
|
|
51
|
+
*/
|
|
52
|
+
function validateQuickConfig(config) {
|
|
53
|
+
var _config$features;
|
|
54
|
+
var errors = [];
|
|
55
|
+
if (!config.codex) {
|
|
56
|
+
errors.push('QuickConfig must have a codex');
|
|
57
|
+
}
|
|
58
|
+
if (!config.name || Object.keys(config.name).length === 0) {
|
|
59
|
+
errors.push('QuickConfig must have at least one language for name');
|
|
60
|
+
}
|
|
61
|
+
if (!config.features || config.features.length === 0) {
|
|
62
|
+
errors.push('QuickConfig must have at least one feature');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Validate features
|
|
66
|
+
(_config$features = config.features) === null || _config$features === void 0 || _config$features.forEach(function (feature, index) {
|
|
67
|
+
var _feature$options;
|
|
68
|
+
if (!feature.codex) {
|
|
69
|
+
errors.push("Feature at index ".concat(index, " must have a codex"));
|
|
70
|
+
}
|
|
71
|
+
if (!feature.label || Object.keys(feature.label).length === 0) {
|
|
72
|
+
errors.push("Feature ".concat(feature.codex || index, " must have at least one language for label"));
|
|
73
|
+
}
|
|
74
|
+
if (!feature.layout) {
|
|
75
|
+
errors.push("Feature ".concat(feature.codex || index, " must have a layout"));
|
|
76
|
+
}
|
|
77
|
+
if (!feature.options || feature.options.length === 0) {
|
|
78
|
+
errors.push("Feature ".concat(feature.codex || index, " must have at least one option"));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Validate options
|
|
82
|
+
(_feature$options = feature.options) === null || _feature$options === void 0 || _feature$options.forEach(function (option, optIndex) {
|
|
83
|
+
if (!option.codex) {
|
|
84
|
+
errors.push("Option at index ".concat(optIndex, " in feature ").concat(feature.codex || index, " must have a codex"));
|
|
85
|
+
}
|
|
86
|
+
if (!option.type) {
|
|
87
|
+
errors.push("Option ".concat(option.codex || optIndex, " must have a type"));
|
|
88
|
+
}
|
|
89
|
+
if (option.type === 'range' && !option.range) {
|
|
90
|
+
errors.push("Range option ".concat(option.codex || optIndex, " must have range configuration"));
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
return errors;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Evaluates a condition against the current user selections
|
|
99
|
+
*/
|
|
100
|
+
var ConditionEvaluator = /*#__PURE__*/function () {
|
|
101
|
+
function ConditionEvaluator(selections) {
|
|
102
|
+
_classCallCheck__default["default"](this, ConditionEvaluator);
|
|
103
|
+
_defineProperty__default["default"](this, "selections", void 0);
|
|
104
|
+
this.selections = new Map(selections.map(function (s) {
|
|
105
|
+
return [s.featureCodex, s.selectedOptions];
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Main evaluation method
|
|
111
|
+
*/
|
|
112
|
+
return _createClass__default["default"](ConditionEvaluator, [{
|
|
113
|
+
key: "evaluate",
|
|
114
|
+
value: function evaluate(condition) {
|
|
115
|
+
if (this.isAndCondition(condition)) {
|
|
116
|
+
return this.evaluateAnd(condition);
|
|
117
|
+
}
|
|
118
|
+
if (this.isOrCondition(condition)) {
|
|
119
|
+
return this.evaluateOr(condition);
|
|
120
|
+
}
|
|
121
|
+
if (this.isNotCondition(condition)) {
|
|
122
|
+
return this.evaluateNot(condition);
|
|
123
|
+
}
|
|
124
|
+
return this.evaluateSingleCondition(condition);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Type guards
|
|
129
|
+
*/
|
|
130
|
+
}, {
|
|
131
|
+
key: "isAndCondition",
|
|
132
|
+
value: function isAndCondition(condition) {
|
|
133
|
+
return 'and' in condition;
|
|
134
|
+
}
|
|
135
|
+
}, {
|
|
136
|
+
key: "isOrCondition",
|
|
137
|
+
value: function isOrCondition(condition) {
|
|
138
|
+
return 'or' in condition;
|
|
139
|
+
}
|
|
140
|
+
}, {
|
|
141
|
+
key: "isNotCondition",
|
|
142
|
+
value: function isNotCondition(condition) {
|
|
143
|
+
return 'not' in condition;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Evaluate logical operators
|
|
148
|
+
*/
|
|
149
|
+
}, {
|
|
150
|
+
key: "evaluateAnd",
|
|
151
|
+
value: function evaluateAnd(condition) {
|
|
152
|
+
var _this = this;
|
|
153
|
+
return condition.and.every(function (c) {
|
|
154
|
+
return _this.evaluateSingleCondition(c);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}, {
|
|
158
|
+
key: "evaluateOr",
|
|
159
|
+
value: function evaluateOr(condition) {
|
|
160
|
+
var _this2 = this;
|
|
161
|
+
return condition.or.some(function (c) {
|
|
162
|
+
return _this2.evaluateSingleCondition(c);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}, {
|
|
166
|
+
key: "evaluateNot",
|
|
167
|
+
value: function evaluateNot(condition) {
|
|
168
|
+
return !this.evaluate(condition.not);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Evaluate a single condition
|
|
173
|
+
*/
|
|
174
|
+
}, {
|
|
175
|
+
key: "evaluateSingleCondition",
|
|
176
|
+
value: function evaluateSingleCondition(condition) {
|
|
177
|
+
var selectedValues = this.selections.get(condition.featureCodex);
|
|
178
|
+
|
|
179
|
+
// If feature not selected yet, condition is false
|
|
180
|
+
if (!selectedValues || selectedValues.length === 0) {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
switch (condition.operator) {
|
|
184
|
+
case 'eq':
|
|
185
|
+
return selectedValues.some(function (v) {
|
|
186
|
+
return v === condition.value;
|
|
187
|
+
});
|
|
188
|
+
case 'ne':
|
|
189
|
+
return !selectedValues.some(function (v) {
|
|
190
|
+
return v === condition.value;
|
|
191
|
+
});
|
|
192
|
+
case 'in':
|
|
193
|
+
return selectedValues.some(function (v) {
|
|
194
|
+
return condition.value.includes(v);
|
|
195
|
+
});
|
|
196
|
+
case 'nin':
|
|
197
|
+
return !selectedValues.some(function (v) {
|
|
198
|
+
return condition.value.includes(v);
|
|
199
|
+
});
|
|
200
|
+
default:
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Utility method to check if a feature should be visible
|
|
207
|
+
*/
|
|
208
|
+
}], [{
|
|
209
|
+
key: "shouldShowFeature",
|
|
210
|
+
value: function shouldShowFeature(feature, selections) {
|
|
211
|
+
if (!feature.condition) {
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
var evaluator = new ConditionEvaluator(selections);
|
|
215
|
+
return evaluator.evaluate(feature.condition);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Utility method to check if an option should be visible
|
|
220
|
+
*/
|
|
221
|
+
}, {
|
|
222
|
+
key: "shouldShowOption",
|
|
223
|
+
value: function shouldShowOption(option, selections) {
|
|
224
|
+
if (!option.condition) {
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
var evaluator = new ConditionEvaluator(selections);
|
|
228
|
+
return evaluator.evaluate(option.condition);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Utility method to check if an instance should be visible
|
|
233
|
+
*/
|
|
234
|
+
}, {
|
|
235
|
+
key: "shouldShowInstance",
|
|
236
|
+
value: function shouldShowInstance(instance, selections) {
|
|
237
|
+
if (!instance.condition) {
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
var evaluator = new ConditionEvaluator(selections);
|
|
241
|
+
return evaluator.evaluate(instance.condition);
|
|
242
|
+
}
|
|
243
|
+
}]);
|
|
244
|
+
}();
|
|
245
|
+
|
|
246
|
+
var useOptionRenderer = function useOptionRenderer(_ref) {
|
|
247
|
+
var feature = _ref.feature,
|
|
248
|
+
selectedOptions = _ref.selectedOptions,
|
|
249
|
+
onSelect = _ref.onSelect,
|
|
250
|
+
selections = _ref.selections;
|
|
251
|
+
var _useTranslation = divaCore.useTranslation(),
|
|
252
|
+
i18n = _useTranslation.i18n;
|
|
253
|
+
var language = i18n.language;
|
|
254
|
+
// Filter visible options based on conditions
|
|
255
|
+
var visibleOptions = react.useMemo(function () {
|
|
256
|
+
return feature.options.filter(function (option) {
|
|
257
|
+
return ConditionEvaluator.shouldShowOption(option, selections);
|
|
258
|
+
});
|
|
259
|
+
}, [feature.options, selections]);
|
|
260
|
+
var selectOptions = react.useMemo(function () {
|
|
261
|
+
return visibleOptions.filter(function (o) {
|
|
262
|
+
return o.type === 'select';
|
|
263
|
+
});
|
|
264
|
+
}, [visibleOptions]);
|
|
265
|
+
var rangeOption = react.useMemo(function () {
|
|
266
|
+
return visibleOptions.find(function (o) {
|
|
267
|
+
return o.type === 'range';
|
|
268
|
+
});
|
|
269
|
+
}, [visibleOptions]);
|
|
270
|
+
var handleSingleSelect = react.useCallback(function (optionCodex) {
|
|
271
|
+
onSelect([optionCodex]);
|
|
272
|
+
}, [onSelect]);
|
|
273
|
+
var handleMultiSelect = react.useCallback(function (optionCodex) {
|
|
274
|
+
if (selectedOptions.includes(optionCodex)) {
|
|
275
|
+
onSelect(selectedOptions.filter(function (o) {
|
|
276
|
+
return o !== optionCodex;
|
|
277
|
+
}));
|
|
278
|
+
} else {
|
|
279
|
+
onSelect([].concat(_toConsumableArray__default["default"](selectedOptions), [optionCodex]));
|
|
280
|
+
}
|
|
281
|
+
}, [selectedOptions, onSelect]);
|
|
282
|
+
var getOptionLabel = react.useCallback(function (option) {
|
|
283
|
+
return option.label[language] || option.label.en || option.label.de || option.codex;
|
|
284
|
+
}, [language]);
|
|
285
|
+
var getOptionDescription = react.useCallback(function (option) {
|
|
286
|
+
var _option$description, _option$description2, _option$description3;
|
|
287
|
+
return ((_option$description = option.description) === null || _option$description === void 0 ? void 0 : _option$description[language]) || ((_option$description2 = option.description) === null || _option$description2 === void 0 ? void 0 : _option$description2.en) || ((_option$description3 = option.description) === null || _option$description3 === void 0 ? void 0 : _option$description3.de);
|
|
288
|
+
}, [language]);
|
|
289
|
+
var getOptionCaption = react.useCallback(function (option) {
|
|
290
|
+
var _option$caption, _option$caption2, _option$caption3;
|
|
291
|
+
return ((_option$caption = option.caption) === null || _option$caption === void 0 ? void 0 : _option$caption[language]) || ((_option$caption2 = option.caption) === null || _option$caption2 === void 0 ? void 0 : _option$caption2.en) || ((_option$caption3 = option.caption) === null || _option$caption3 === void 0 ? void 0 : _option$caption3.de);
|
|
292
|
+
}, [language]);
|
|
293
|
+
return {
|
|
294
|
+
visibleOptions: visibleOptions,
|
|
295
|
+
selectOptions: selectOptions,
|
|
296
|
+
rangeOption: rangeOption,
|
|
297
|
+
handleSingleSelect: handleSingleSelect,
|
|
298
|
+
handleMultiSelect: handleMultiSelect,
|
|
299
|
+
getOptionLabel: getOptionLabel,
|
|
300
|
+
getOptionDescription: getOptionDescription,
|
|
301
|
+
getOptionCaption: getOptionCaption
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
function styleInject(css, ref) {
|
|
306
|
+
if ( ref === void 0 ) ref = {};
|
|
307
|
+
var insertAt = ref.insertAt;
|
|
308
|
+
|
|
309
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
310
|
+
|
|
311
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
312
|
+
var style = document.createElement('style');
|
|
313
|
+
style.type = 'text/css';
|
|
314
|
+
|
|
315
|
+
if (insertAt === 'top') {
|
|
316
|
+
if (head.firstChild) {
|
|
317
|
+
head.insertBefore(style, head.firstChild);
|
|
318
|
+
} else {
|
|
319
|
+
head.appendChild(style);
|
|
320
|
+
}
|
|
321
|
+
} else {
|
|
322
|
+
head.appendChild(style);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (style.styleSheet) {
|
|
326
|
+
style.styleSheet.cssText = css;
|
|
327
|
+
} else {
|
|
328
|
+
style.appendChild(document.createTextNode(css));
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
var container = "container-nN2kI";
|
|
333
|
+
var subContainer = "subContainer-x97eX";
|
|
334
|
+
var stickyHeader = "stickyHeader-V5orv";
|
|
335
|
+
var featureContainer = "featureContainer-cTJH8";
|
|
336
|
+
var featureLabel = "featureLabel-q4sHn";
|
|
337
|
+
var featureRequired = "featureRequired-tby4F";
|
|
338
|
+
var featureDescription = "featureDescription-k4v-p";
|
|
339
|
+
var optionDescription = "optionDescription-omLcU";
|
|
340
|
+
var progressText = "progressText-LXaM7";
|
|
341
|
+
var configDescription = "configDescription--0UjU";
|
|
342
|
+
var resultDescription = "resultDescription-7jW2U";
|
|
343
|
+
var optionsBox = "optionsBox-TBnRq";
|
|
344
|
+
var optionsGallery = "optionsGallery-72aVW";
|
|
345
|
+
var optionButton = "optionButton-tRXEs";
|
|
346
|
+
var radioOption = "radioOption-sv3m6";
|
|
347
|
+
var checkboxOption = "checkboxOption-UY3nL";
|
|
348
|
+
var optionButtonSelected = "optionButtonSelected-pjY9O";
|
|
349
|
+
var radioOptionSelected = "radioOptionSelected-vm6bN";
|
|
350
|
+
var checkboxOptionSelected = "checkboxOptionSelected-DuZGL";
|
|
351
|
+
var optionLabel = "optionLabel-oz4Zj";
|
|
352
|
+
var optionCaption = "optionCaption-3d-V1";
|
|
353
|
+
var optionContent = "optionContent-DS9Wc";
|
|
354
|
+
var progressBar = "progressBar-RKPZp";
|
|
355
|
+
var progressBarFill = "progressBarFill--Shc9";
|
|
356
|
+
var progressBarInner = "progressBarInner-agBx-";
|
|
357
|
+
var slider = "slider-ev57L";
|
|
358
|
+
var sliderInput = "sliderInput-xAXVM";
|
|
359
|
+
var sliderValue = "sliderValue-vwwNn";
|
|
360
|
+
var dropdown = "dropdown-fst7q";
|
|
361
|
+
var radio = "radio-GesCu";
|
|
362
|
+
var checkbox = "checkbox-xI7lT";
|
|
363
|
+
var toggle = "toggle-fi2uF";
|
|
364
|
+
var toggleButton = "toggleButton-4myWl";
|
|
365
|
+
var toggleButtonSelected = "toggleButtonSelected-4SMtn";
|
|
366
|
+
var resultContainer = "resultContainer-sc6De";
|
|
367
|
+
var resultItem = "resultItem-84scA";
|
|
368
|
+
var resultKey = "resultKey-qD5DS";
|
|
369
|
+
var resultValue = "resultValue-42tes";
|
|
370
|
+
var buttonContainer = "buttonContainer-UZKoO";
|
|
371
|
+
var navLeftGroup = "navLeftGroup-JOQ3N";
|
|
372
|
+
var navRightGroup = "navRightGroup-mWCAz";
|
|
373
|
+
var navButtonPadding = "navButtonPadding-aX9-f";
|
|
374
|
+
var button = "button-CT3BR";
|
|
375
|
+
var buttonPrimary = "buttonPrimary-b3Tur";
|
|
376
|
+
var buttonPrimaryApplied = "buttonPrimaryApplied-90Q5-";
|
|
377
|
+
var headerContainer = "headerContainer-fhFhh";
|
|
378
|
+
var tabWrapper = "tabWrapper-ZqpAa";
|
|
379
|
+
var tabSlider = "tabSlider-d133A";
|
|
380
|
+
var tab = "tab-Cf5O4";
|
|
381
|
+
var tabActive = "tabActive-B4W84";
|
|
382
|
+
var buttonSecondary = "buttonSecondary-Fs2ci";
|
|
383
|
+
var buttonWithArrow = "buttonWithArrow-PQQFS";
|
|
384
|
+
var closeButton = "closeButton-Regwf";
|
|
385
|
+
var resultsGrid = "resultsGrid-s3UTE";
|
|
386
|
+
var speedometer = "speedometer-kKRJQ";
|
|
387
|
+
var speedometerGroup = "speedometerGroup-SS-GT";
|
|
388
|
+
var speedometerGroupTitle = "speedometerGroupTitle-4s2YI";
|
|
389
|
+
var speedometerGroupGrid = "speedometerGroupGrid-SNMAM";
|
|
390
|
+
var speedometerGroupItem = "speedometerGroupItem-a4T-A";
|
|
391
|
+
var speedometerGroupItemTitle = "speedometerGroupItemTitle-N35gZ";
|
|
392
|
+
var contentSection = "contentSection-dJgsX";
|
|
393
|
+
var css_248z = ".container-nN2kI {\n display: flex;\n flex-direction: column;\n flex: 1;\n min-height: 0;\n height: 100%;\n\n max-height: calc(100vh - 40px);\n padding: 12px;\n box-sizing: border-box;\n overflow: auto;\n}\n\n@supports (height: 100dvh) {\n .container-nN2kI {\n max-height: calc(100dvh - 40px);\n }\n}\n\n.subContainer-x97eX {\n flex: 1;\n padding: 12px 0;\n display: flex;\n flex-direction: column;\n gap: 20px;\n}\n\n.mobile .subContainer-x97eX {\n padding: 12px 0;\n gap: 4px;\n}\n\n.stickyHeader-V5orv {\n position: sticky;\n top: -12px;\n z-index: 10;\n background: #fff;\n margin: -12px -12px 0 -12px;\n padding: 12px 12px 0 12px;\n}\n\n.stickyHeaderSticky-5qqWo {\n position: sticky;\n top: -12px;\n z-index: 10;\n background: #fff;\n margin: -12px -12px 0 -12px;\n padding: 12px 12px 0 12px;\n}\n\n.darkmode .stickyHeader-V5orv {\n background: #1a1a1a;\n}\n\n.featureContainer-cTJH8 {\n min-width: 0;\n max-width: 100%;\n}\n\n.featureLabel-q4sHn {\n font-size: 18px;\n font-weight: 600;\n margin-bottom: 10px;\n word-wrap: break-word;\n}\n\n.featureRequired-tby4F {\n color: red;\n}\n\n.featureDescription-k4v-p,\n.optionDescription-omLcU,\n.progressText-LXaM7 {\n color: #666;\n}\n\n.darkmode .featureDescription-k4v-p,\n.darkmode .optionDescription-omLcU,\n.darkmode .progressText-LXaM7 {\n color: #aaa;\n}\n\n.featureDescription-k4v-p {\n font-size: 14px;\n margin-bottom: 15px;\n word-wrap: break-word;\n}\n\n.configDescription--0UjU,\n.resultDescription-7jW2U {\n font-size: 15px;\n color: #666;\n margin: 12px 0 0 0;\n word-wrap: break-word;\n}\n\n.mobile .configDescription--0UjU,\n.mobile .resultDescription-7jW2U {\n font-size: 14px;\n margin: 8px 0 0 0;\n}\n\n.darkmode .configDescription--0UjU,\n.darkmode .resultDescription-7jW2U {\n color: #aaa;\n}\n\n.optionsContainer-oIEc3 {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.optionsBox-TBnRq {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));\n grid-gap: 10px;\n gap: 10px;\n min-width: 0;\n max-width: 100%;\n}\n\n.optionsGallery-72aVW {\n display: grid;\n grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));\n grid-gap: 15px;\n gap: 15px;\n min-width: 0;\n max-width: 100%;\n}\n\n/* Shared selectable option base (optionButton, radioOption, checkboxOption) */\n.optionButton-tRXEs,\n.radioOption-sv3m6,\n.checkboxOption-UY3nL {\n padding: 12px;\n border: 2px solid #ddd;\n border-radius: 8px;\n background: #fff;\n cursor: pointer;\n transition: all 0.2s;\n min-width: 0;\n}\n\n.optionButton-tRXEs {\n padding: 15px;\n text-align: left;\n}\n\n.radioOption-sv3m6,\n.checkboxOption-UY3nL {\n display: flex;\n align-items: center;\n gap: 10px;\n}\n\n.darkmode .optionButton-tRXEs,\n.darkmode .radioOption-sv3m6,\n.darkmode .checkboxOption-UY3nL {\n border-color: #444;\n background: #2a2a2a;\n}\n\n.optionButton-tRXEs:hover,\n.radioOption-sv3m6:hover,\n.checkboxOption-UY3nL:hover {\n border-color: #999;\n background: #f9f9f9;\n}\n\n.darkmode .optionButton-tRXEs:hover,\n.darkmode .radioOption-sv3m6:hover,\n.darkmode .checkboxOption-UY3nL:hover {\n border-color: #666;\n background: #333;\n}\n\n.optionButtonSelected-pjY9O,\n.radioOptionSelected-vm6bN,\n.checkboxOptionSelected-DuZGL {\n border-color: var(--diva-theme-palette-primary-main);\n background: var(--diva-theme-palette-primary-light);\n}\n\n.darkmode .optionButtonSelected-pjY9O,\n.darkmode .radioOptionSelected-vm6bN,\n.darkmode .checkboxOptionSelected-DuZGL {\n border-color: var(--diva-theme-palette-primary-main);\n background: var(--diva-theme-palette-primary-dark);\n}\n\n.optionButtonSelected-pjY9O:hover,\n.radioOptionSelected-vm6bN:hover,\n.checkboxOptionSelected-DuZGL:hover {\n border-color: var(--diva-theme-palette-primary-dark);\n background: var(--diva-theme-palette-primary-light);\n}\n\n.darkmode .optionButtonSelected-pjY9O:hover,\n.darkmode .radioOptionSelected-vm6bN:hover,\n.darkmode .checkboxOptionSelected-DuZGL:hover {\n border-color: var(--diva-theme-palette-primary-main);\n background: var(--diva-theme-palette-primary-dark);\n}\n\n.optionLabel-oz4Zj {\n font-weight: 500;\n display: flex;\n align-items: center;\n justify-self: start;\n gap: 5px;\n flex-direction: column;\n width: 100%;\n min-width: 0;\n word-wrap: break-word;\n}\n\n.optionCaption-3d-V1 {\n font-size: 0.75rem;\n opacity: 0.6;\n font-weight: normal;\n text-align: center;\n}\n\n.optionContent-DS9Wc {\n min-width: 0;\n flex: 1;\n}\n\n.optionDescription-omLcU {\n font-size: 12px;\n min-width: 0;\n word-wrap: break-word;\n}\n\n.progressBar-RKPZp {\n display: flex;\n align-items: center;\n gap: 10px;\n margin-bottom: 20px;\n padding-bottom: 15px;\n border-bottom: 1px solid #ddd;\n}\n\n.darkmode .progressBar-RKPZp {\n border-bottom-color: #444;\n}\n\n.progressBarFill--Shc9 {\n flex: 1;\n height: 6px;\n background: #e0e0e0;\n border-radius: 3px;\n overflow: hidden;\n}\n\n.darkmode .progressBarFill--Shc9 {\n background: #444;\n}\n\n.progressBarInner-agBx- {\n height: 100%;\n background: var(--diva-theme-palette-primary-main);\n transition: width 0.3s ease;\n}\n\n.progressText-LXaM7 {\n font-size: 14px;\n white-space: nowrap;\n}\n\n.backButton-qRYLD {\n padding: 8px 12px;\n border: 1px solid #ddd;\n background: #fff;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n}\n\n.darkmode .backButton-qRYLD {\n border-color: #444;\n background: #2a2a2a;\n color: white;\n}\n\n.backButton-qRYLD:hover {\n background: #f5f5f5;\n}\n\n.darkmode .backButton-qRYLD:hover {\n background: #333;\n}\n\n.slider-ev57L {\n width: 100%;\n margin: 20px 0;\n}\n\n.sliderInput-xAXVM {\n width: 100%;\n height: 6px;\n border-radius: 3px;\n background: #e0e0e0;\n outline: none;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n\n.darkmode .sliderInput-xAXVM {\n background: #444;\n}\n\n.sliderInput-xAXVM::-webkit-slider-thumb,\n.sliderInput-xAXVM::-moz-range-thumb {\n width: 20px;\n height: 20px;\n border-radius: 50%;\n background: var(--diva-theme-palette-primary-main);\n cursor: pointer;\n border: none;\n}\n\n.sliderInput-xAXVM::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n}\n\n.sliderValue-vwwNn {\n text-align: center;\n font-size: 16px;\n font-weight: 600;\n margin-top: 10px;\n}\n\n.dropdown-fst7q {\n width: 100%;\n padding: 12px;\n border: 2px solid #ddd;\n border-radius: 8px;\n font-size: 16px;\n background: #fff;\n cursor: pointer;\n}\n\n.darkmode .dropdown-fst7q {\n border-color: #444;\n background: #2a2a2a;\n color: white;\n}\n\n.radio-GesCu {\n display: flex;\n flex-direction: column;\n gap: 10px;\n min-width: 0;\n max-width: 100%;\n}\n\n.checkbox-xI7lT {\n display: flex;\n flex-direction: column;\n gap: 10px;\n min-width: 0;\n max-width: 100%;\n}\n\n.toggle-fi2uF {\n display: flex;\n flex-wrap: wrap;\n gap: 10px;\n}\n\n.toggleButton-4myWl {\n flex: 1;\n min-width: 120px;\n padding: 15px;\n border: 2px solid #ddd;\n border-radius: 8px;\n background: #fff;\n cursor: pointer;\n transition: all 0.2s;\n text-align: center;\n font-weight: 500;\n}\n\n.darkmode .toggleButton-4myWl {\n border-color: #444;\n background: #2a2a2a;\n color: white;\n}\n\n.toggleButton-4myWl:hover {\n border-color: #999;\n background: #f9f9f9;\n}\n\n.darkmode .toggleButton-4myWl:hover {\n border-color: #666;\n background: #333;\n}\n\n.toggleButtonSelected-4SMtn {\n border-color: var(--diva-theme-palette-primary-main);\n background: var(--diva-theme-palette-primary-main);\n color: var(--diva-theme-palette-primary-contrast-text);\n}\n\n.toggleButtonSelected-4SMtn:hover {\n border-color: var(--diva-theme-palette-primary-dark);\n background: var(--diva-theme-palette-primary-dark);\n color: var(--diva-theme-palette-primary-contrast-text);\n}\n\n.resultContainer-sc6De {\n}\n\n.mobile .resultContainer-sc6De {\n padding: 4px;\n}\n\n.resultItem-84scA {\n display: flex;\n justify-content: space-between;\n padding: 15px;\n margin-bottom: 10px;\n background: #f5f5f5;\n border-radius: 8px;\n}\n\n.darkmode .resultItem-84scA {\n background: #2a2a2a;\n}\n\n.resultKey-qD5DS {\n font-weight: 600;\n}\n\n.resultValue-42tes {\n color: var(--diva-theme-palette-primary-main);\n font-weight: 500;\n}\n\n.buttonContainer-UZKoO {\n display: flex;\n gap: 10px;\n justify-content: flex-end;\n padding: 20px 0;\n border-top: 1px solid #ddd;\n}\n\n.navLeftGroup-JOQ3N {\n display: flex;\n gap: 10px;\n flex: 1;\n}\n\n.navRightGroup-mWCAz {\n display: flex;\n gap: 10px;\n flex-direction: row;\n flex-wrap: wrap;\n justify-content: flex-end;\n flex-grow: 1;\n}\n\n.navButtonPadding-aX9-f {\n padding: 10px 20px;\n}\n\n.darkmode .buttonContainer-UZKoO {\n border-top-color: #444;\n}\n\n.button-CT3BR {\n padding: 10px 20px;\n border: 1px solid #ddd;\n border-radius: 4px;\n background: #fff;\n color: #000;\n cursor: pointer;\n font-size: 14px;\n font-weight: 500;\n transition: all 0.2s;\n}\n\n.darkmode .button-CT3BR {\n border-color: #444;\n background: #2a2a2a;\n color: white;\n}\n\n.button-CT3BR:hover:not(:disabled) {\n background: #f5f5f5;\n border-color: #999;\n}\n\n.darkmode .button-CT3BR:hover:not(:disabled) {\n background: #333;\n border-color: #666;\n}\n\n.button-CT3BR:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.buttonPrimary-b3Tur {\n background: var(--diva-theme-palette-primary-main);\n border-color: var(--diva-theme-palette-primary-main);\n color: var(--diva-theme-palette-primary-contrast-text);\n}\n\n.buttonPrimary-b3Tur:hover:not(:disabled) {\n background: var(--diva-theme-palette-primary-dark);\n border-color: var(--diva-theme-palette-primary-dark);\n}\n\n.buttonPrimaryApplied-90Q5- {\n background: var(--diva-theme-palette-primary-dark);\n border-color: var(--diva-theme-palette-primary-dark);\n}\n\n.buttonCancel-HA74N {\n background: transparent;\n border-color: #ddd;\n color: #666;\n}\n\n.darkmode .buttonCancel-HA74N {\n border-color: #444;\n color: #aaa;\n}\n\n.buttonCancel-HA74N:hover:not(:disabled) {\n background: #f5f5f5;\n border-color: #999;\n color: #333;\n}\n\n.darkmode .buttonCancel-HA74N:hover:not(:disabled) {\n background: #333;\n border-color: #666;\n color: white;\n}\n\n.headerContainer-fhFhh {\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 40px;\n margin-bottom: 4px;\n position: relative;\n}\n\n.darkmode .headerContainer-fhFhh {\n border-bottom-color: #333;\n}\n\n/* Segmented control style tabs */\n.tabWrapper-ZqpAa {\n --tab-count: 2;\n display: flex;\n position: relative;\n flex-grow: 1;\n max-width: min(360px, 80%);\n min-width: 0;\n background: #f0f0f0;\n border-radius: 10px;\n padding: 3px;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);\n}\n\n.darkmode .tabWrapper-ZqpAa {\n background: #333;\n}\n\n.tabSlider-d133A {\n position: absolute;\n top: 3px;\n left: 3px;\n width: calc((100% - 6px) / var(--tab-count));\n height: calc(100% - 6px);\n background: #fff;\n border-radius: 7px;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n transition: transform 0.25s ease;\n pointer-events: none;\n}\n\n.darkmode .tabSlider-d133A {\n background: #404040;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);\n}\n\n.tab-Cf5O4 {\n flex: 1;\n min-width: 0;\n padding: 8px 16px;\n border: none;\n outline: none;\n background: transparent;\n cursor: pointer;\n font-size: 16px;\n font-weight: 500;\n color: #666;\n transition: color 0.25s ease;\n position: relative;\n z-index: 1;\n text-align: center;\n}\n\n.tab-Cf5O4:focus,\n.tab-Cf5O4.focus-visible-kxYL6,\n.tab-Cf5O4:hover,\n.tab-Cf5O4:active {\n outline: none;\n border: none;\n box-shadow: none;\n}\n\n.tab-Cf5O4:focus,\n.tab-Cf5O4:focus-visible,\n.tab-Cf5O4:hover,\n.tab-Cf5O4:active {\n outline: none;\n border: none;\n box-shadow: none;\n}\n\n.darkmode .tab-Cf5O4 {\n color: #999;\n}\n\n.tabActive-B4W84 {\n color: var(--diva-theme-palette-primary-main);\n}\n\n.tab-Cf5O4:hover:not(.tabActive-B4W84) {\n color: #333;\n}\n\n.darkmode .tab-Cf5O4:hover:not(.tabActive-B4W84) {\n color: #ccc;\n}\n\n.instanceNavContainer-0U7gZ {\n display: flex;\n flex-direction: column;\n gap: 12px;\n margin-top: 32px;\n padding: 0;\n background: transparent;\n border-radius: 0;\n border: none;\n}\n\n.darkmode .instanceNavContainer-0U7gZ {\n background: transparent;\n border-color: transparent;\n}\n\n.instanceNavButtons-HMFdy {\n display: flex;\n flex-direction: row;\n gap: 16px;\n flex-wrap: wrap;\n}\n\n.buttonSecondary-Fs2ci {\n background: #fff;\n border: 1px solid var(--diva-theme-palette-primary-main);\n color: var(--diva-theme-palette-primary-main);\n font-size: 14px;\n}\n\n.darkmode .buttonSecondary-Fs2ci {\n background: transparent;\n border-color: var(--diva-theme-palette-primary-main);\n color: var(--diva-theme-palette-primary-main);\n}\n\n.buttonSecondary-Fs2ci:hover:not(:disabled) {\n background: var(--diva-theme-palette-primary-light);\n color: var(--diva-theme-palette-primary-contrast-text);\n}\n\n.darkmode .buttonSecondary-Fs2ci:hover:not(:disabled) {\n background: color-mix(in srgb, var(--diva-theme-palette-primary-main) 10%, transparent);\n color: var(--diva-theme-palette-primary-contrast-text);\n}\n\n.buttonWithArrow-PQQFS {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 12px 24px;\n font-size: 16px;\n border-radius: 8px;\n height: auto;\n text-align: left;\n flex: 1;\n min-width: 250px;\n}\n\n.closeButton-Regwf {\n position: absolute;\n right: -8px;\n top: 50%;\n transform: translateY(-50%);\n background-color: rgba(255,255,255,0.8);\n border-radius: 50%;\n border: none;\n outline: none;\n cursor: pointer;\n padding: 10px;\n display: flex;\n align-items: center;\n justify-content: center;\n color: #949daf;\n transition: color 0.2s;\n}\n\n.closeButton-Regwf:focus,\n.closeButton-Regwf.focus-visible-kxYL6,\n.closeButton-Regwf:hover,\n.closeButton-Regwf:active {\n outline: none;\n border: none;\n box-shadow: none;\n}\n\n.closeButton-Regwf:focus,\n.closeButton-Regwf:focus-visible,\n.closeButton-Regwf:hover,\n.closeButton-Regwf:active {\n outline: none;\n border: none;\n box-shadow: none;\n}\n\n.closeButton-Regwf:hover {\n color: #333;\n}\n\n.darkmode .closeButton-Regwf:hover {\n color: #fff;\n}\n\n/* Mobile Smaller Version */\n.mobile .container-nN2kI {\n padding: 12px;\n}\n\n.mobile .subContainer-x97eX {\n padding: 12px 0;\n}\n\n.mobile .featureLabel-q4sHn {\n font-size: 16px;\n margin-bottom: 8px;\n}\n\n.mobile .featureDescription-k4v-p {\n font-size: 13px;\n margin-bottom: 10px;\n}\n\n.mobile .optionButton-tRXEs {\n padding: 10px;\n}\n\n.mobile .optionLabel-oz4Zj {\n gap: 3px;\n}\n\n.mobile .optionDescription-omLcU {\n font-size: 11px;\n}\n\n.mobile .progressBar-RKPZp {\n gap: 8px;\n margin-bottom: 15px;\n padding-bottom: 10px;\n}\n\n.mobile .progressText-LXaM7 {\n font-size: 12px;\n}\n\n.mobile .backButton-qRYLD {\n padding: 6px 10px;\n font-size: 13px;\n}\n\n.mobile .sliderValue-vwwNn {\n font-size: 14px;\n}\n\n.mobile .dropdown-fst7q {\n padding: 10px;\n font-size: 14px;\n}\n\n.mobile .radioOption-sv3m6,\n.mobile .checkboxOption-UY3nL {\n padding: 10px;\n}\n\n.mobile .toggleButton-4myWl {\n padding: 10px;\n min-width: 90px;\n}\n\n.mobile .resultContainer-sc6De {\n padding: 0px;\n}\n\n.mobile .resultTitle-WVM2- {\n font-size: 20px;\n margin-bottom: 15px;\n}\n\n.mobile .resultItem-84scA {\n padding: 10px;\n}\n\n.mobile .buttonContainer-UZKoO {\n padding: 8px 0;\n margin-top: 6px;\n}\n\n.mobile .button-CT3BR {\n padding: 8px 16px;\n font-size: 13px;\n}\n\n.mobile .tab-Cf5O4 {\n padding: 6px 12px;\n font-size: 14px;\n}\n\n.mobile .instanceNavContainer-0U7gZ {\n padding: 10px;\n}\n\n.resultsGrid-s3UTE {\n display: flex;\n flex-wrap: wrap;\n justify-content: center;\n gap: 30px;\n}\n\n.speedometer-kKRJQ {\n width: 100%;\n max-width: 250px;\n margin: 0 auto;\n aspect-ratio: 240 / 170;\n}\n\n.speedometerGroup-SS-GT {\n width: 100%;\n}\n\n.speedometerGroupTitle-4s2YI {\n text-align: center;\n margin-bottom: 4px;\n margin-top: 4px;\n}\n\n.speedometerGroupGrid-SNMAM {\n display: flex;\n flex-wrap: wrap;\n justify-content: center;\n gap: 16px;\n}\n\n.speedometerGroupItem-a4T-A {\n text-align: center;\n flex: 1 1 40%;\n max-width: 45%;\n}\n\n.speedometerGroupItemTitle-N35gZ {\n margin-bottom: 4px;\n margin-top: 4px;\n}\n\n.speedometerValue-pbLcR {\n color: var(--diva-theme-palette-primary-main);\n stroke: var(--diva-theme-palette-primary-main);\n}\n\n.contentSection-dJgsX {\n padding-top: 8px;\n}\n\n.darkmode .contentSection-dJgsX {\n border-top-color: #333;\n}\n";
|
|
394
|
+
styleInject(css_248z);
|
|
395
|
+
|
|
396
|
+
var RangeLayout = function RangeLayout(_ref) {
|
|
397
|
+
var _range$unit, _range$unit2, _range$unit3;
|
|
398
|
+
var option = _ref.option,
|
|
399
|
+
selectedOptions = _ref.selectedOptions,
|
|
400
|
+
onSelect = _ref.onSelect,
|
|
401
|
+
getOptionCaption = _ref.getOptionCaption;
|
|
402
|
+
var _useTranslation = divaCore.useTranslation(),
|
|
403
|
+
i18n = _useTranslation.i18n;
|
|
404
|
+
var language = i18n.language;
|
|
405
|
+
var range = option.range;
|
|
406
|
+
if (!range) return null;
|
|
407
|
+
var _useState = react.useState(selectedOptions[0] ? Number(selectedOptions[0]) : range.defaultValue || range.min),
|
|
408
|
+
_useState2 = _slicedToArray__default["default"](_useState, 2),
|
|
409
|
+
value = _useState2[0],
|
|
410
|
+
setValue = _useState2[1];
|
|
411
|
+
var caption = getOptionCaption(option);
|
|
412
|
+
var handleChange = function handleChange(e) {
|
|
413
|
+
var newValue = Number(e.target.value);
|
|
414
|
+
setValue(newValue);
|
|
415
|
+
onSelect([String(newValue)]);
|
|
416
|
+
};
|
|
417
|
+
var unit = ((_range$unit = range.unit) === null || _range$unit === void 0 ? void 0 : _range$unit[language]) || ((_range$unit2 = range.unit) === null || _range$unit2 === void 0 ? void 0 : _range$unit2.en) || ((_range$unit3 = range.unit) === null || _range$unit3 === void 0 ? void 0 : _range$unit3.de) || '';
|
|
418
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
419
|
+
className: slider,
|
|
420
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("input", {
|
|
421
|
+
type: "range",
|
|
422
|
+
min: range.min,
|
|
423
|
+
max: range.max,
|
|
424
|
+
step: range.step,
|
|
425
|
+
value: value,
|
|
426
|
+
onChange: handleChange,
|
|
427
|
+
className: sliderInput + ' diva-stop-swipe-detection'
|
|
428
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
429
|
+
className: sliderValue,
|
|
430
|
+
children: [value, " ", unit, caption && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
431
|
+
className: optionCaption,
|
|
432
|
+
dangerouslySetInnerHTML: {
|
|
433
|
+
__html: " ".concat(caption)
|
|
434
|
+
}
|
|
435
|
+
})]
|
|
436
|
+
})]
|
|
437
|
+
});
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
var DropdownLayout = function DropdownLayout(_ref) {
|
|
441
|
+
var options = _ref.options,
|
|
442
|
+
selectedOptions = _ref.selectedOptions,
|
|
443
|
+
onSelect = _ref.onSelect,
|
|
444
|
+
getOptionLabel = _ref.getOptionLabel,
|
|
445
|
+
getOptionCaption = _ref.getOptionCaption,
|
|
446
|
+
layoutConfig = _ref.layoutConfig;
|
|
447
|
+
var _useTranslation = divaCore.useTranslation(),
|
|
448
|
+
t = _useTranslation.t;
|
|
449
|
+
return /*#__PURE__*/jsxRuntime.jsxs("select", {
|
|
450
|
+
className: dropdown,
|
|
451
|
+
value: selectedOptions[0] || '',
|
|
452
|
+
onChange: function onChange(e) {
|
|
453
|
+
return onSelect(e.target.value);
|
|
454
|
+
},
|
|
455
|
+
style: {
|
|
456
|
+
fontSize: layoutConfig === null || layoutConfig === void 0 ? void 0 : layoutConfig.optionLabelFontSize
|
|
457
|
+
},
|
|
458
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("option", {
|
|
459
|
+
value: "",
|
|
460
|
+
children: t('quickconfig.pleaseSelect', {
|
|
461
|
+
defaultValue: 'Bitte wählen'
|
|
462
|
+
})
|
|
463
|
+
}), options.map(function (option) {
|
|
464
|
+
var label = getOptionLabel(option);
|
|
465
|
+
var caption = getOptionCaption(option);
|
|
466
|
+
return /*#__PURE__*/jsxRuntime.jsxs("option", {
|
|
467
|
+
value: option.codex,
|
|
468
|
+
children: [label, caption ? " (".concat(caption, ")") : '']
|
|
469
|
+
}, option.codex);
|
|
470
|
+
})]
|
|
471
|
+
});
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
var SelectionListLayout = function SelectionListLayout(_ref) {
|
|
475
|
+
var options = _ref.options,
|
|
476
|
+
selectedOptions = _ref.selectedOptions,
|
|
477
|
+
onSelect = _ref.onSelect,
|
|
478
|
+
getOptionLabel = _ref.getOptionLabel,
|
|
479
|
+
getOptionDescription = _ref.getOptionDescription,
|
|
480
|
+
getOptionCaption = _ref.getOptionCaption,
|
|
481
|
+
type = _ref.type,
|
|
482
|
+
layoutConfig = _ref.layoutConfig;
|
|
483
|
+
var isRadio = type === 'radio';
|
|
484
|
+
var containerClass = isRadio ? radio : checkbox;
|
|
485
|
+
var itemClass = isRadio ? radioOption : checkboxOption;
|
|
486
|
+
var selectedItemClass = isRadio ? radioOptionSelected : checkboxOptionSelected;
|
|
487
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
488
|
+
className: containerClass,
|
|
489
|
+
children: options.map(function (option) {
|
|
490
|
+
var isSelected = selectedOptions.includes(option.codex);
|
|
491
|
+
var label = getOptionLabel(option);
|
|
492
|
+
var description = getOptionDescription(option);
|
|
493
|
+
var caption = getOptionCaption(option);
|
|
494
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
495
|
+
className: isSelected ? "".concat(itemClass, " ").concat(selectedItemClass) : itemClass,
|
|
496
|
+
onClick: function onClick() {
|
|
497
|
+
return onSelect(option.codex);
|
|
498
|
+
},
|
|
499
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("input", {
|
|
500
|
+
type: isRadio ? 'radio' : 'checkbox',
|
|
501
|
+
checked: isSelected,
|
|
502
|
+
onChange: function onChange() {
|
|
503
|
+
return onSelect(option.codex);
|
|
504
|
+
}
|
|
505
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
506
|
+
className: optionContent,
|
|
507
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
508
|
+
className: optionLabel,
|
|
509
|
+
style: layoutConfig !== null && layoutConfig !== void 0 && layoutConfig.optionLabelFontSize ? {
|
|
510
|
+
fontSize: layoutConfig === null || layoutConfig === void 0 ? void 0 : layoutConfig.optionLabelFontSize
|
|
511
|
+
} : undefined,
|
|
512
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
513
|
+
dangerouslySetInnerHTML: {
|
|
514
|
+
__html: label
|
|
515
|
+
}
|
|
516
|
+
}), caption && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
517
|
+
className: optionCaption,
|
|
518
|
+
dangerouslySetInnerHTML: {
|
|
519
|
+
__html: " ".concat(caption)
|
|
520
|
+
}
|
|
521
|
+
})]
|
|
522
|
+
}), description && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
523
|
+
className: optionDescription,
|
|
524
|
+
dangerouslySetInnerHTML: {
|
|
525
|
+
__html: description
|
|
526
|
+
}
|
|
527
|
+
})]
|
|
528
|
+
})]
|
|
529
|
+
}, option.codex);
|
|
530
|
+
})
|
|
531
|
+
});
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
var ButtonGroupLayout = function ButtonGroupLayout(_ref) {
|
|
535
|
+
var options = _ref.options,
|
|
536
|
+
selectedOptions = _ref.selectedOptions,
|
|
537
|
+
onSelect = _ref.onSelect,
|
|
538
|
+
getOptionLabel = _ref.getOptionLabel,
|
|
539
|
+
getOptionDescription = _ref.getOptionDescription,
|
|
540
|
+
getOptionCaption = _ref.getOptionCaption,
|
|
541
|
+
layout = _ref.layout,
|
|
542
|
+
layoutConfig = _ref.layoutConfig;
|
|
543
|
+
var isToggle = layout === 'toggle' || layout === 'multitoggle';
|
|
544
|
+
var containerClass = isToggle ? toggle : layout === 'gallery' ? optionsGallery : optionsBox;
|
|
545
|
+
var itemClass = isToggle ? toggleButton : optionButton;
|
|
546
|
+
var selectedItemClass = isToggle ? toggleButtonSelected : optionButtonSelected;
|
|
547
|
+
var style = {};
|
|
548
|
+
if (layoutConfig !== null && layoutConfig !== void 0 && layoutConfig.columns && !isToggle) {
|
|
549
|
+
style.gridTemplateColumns = "repeat(".concat(layoutConfig.columns, ", minmax(0, 1fr))");
|
|
550
|
+
}
|
|
551
|
+
if (layoutConfig !== null && layoutConfig !== void 0 && layoutConfig.gap && !isToggle) {
|
|
552
|
+
style.gap = typeof layoutConfig.gap === 'number' ? "".concat(layoutConfig.gap, "px") : layoutConfig.gap;
|
|
553
|
+
}
|
|
554
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
555
|
+
className: containerClass,
|
|
556
|
+
style: style,
|
|
557
|
+
children: options.map(function (option) {
|
|
558
|
+
var isSelected = selectedOptions.includes(option.codex);
|
|
559
|
+
var label = getOptionLabel(option);
|
|
560
|
+
var description = getOptionDescription(option);
|
|
561
|
+
var caption = getOptionCaption(option);
|
|
562
|
+
if (isToggle) {
|
|
563
|
+
return /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
564
|
+
className: isSelected ? "".concat(itemClass, " ").concat(selectedItemClass) : itemClass,
|
|
565
|
+
onClick: function onClick() {
|
|
566
|
+
return onSelect(option.codex);
|
|
567
|
+
},
|
|
568
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
569
|
+
className: optionLabel,
|
|
570
|
+
style: layoutConfig !== null && layoutConfig !== void 0 && layoutConfig.optionLabelFontSize ? {
|
|
571
|
+
fontSize: layoutConfig === null || layoutConfig === void 0 ? void 0 : layoutConfig.optionLabelFontSize
|
|
572
|
+
} : undefined,
|
|
573
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
574
|
+
dangerouslySetInnerHTML: {
|
|
575
|
+
__html: label
|
|
576
|
+
}
|
|
577
|
+
}), caption && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
578
|
+
className: optionCaption,
|
|
579
|
+
dangerouslySetInnerHTML: {
|
|
580
|
+
__html: " ".concat(caption)
|
|
581
|
+
}
|
|
582
|
+
})]
|
|
583
|
+
})
|
|
584
|
+
}, option.codex);
|
|
585
|
+
}
|
|
586
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
587
|
+
className: isSelected ? "".concat(itemClass, " ").concat(selectedItemClass) : itemClass,
|
|
588
|
+
onClick: function onClick() {
|
|
589
|
+
return onSelect(option.codex);
|
|
590
|
+
},
|
|
591
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
592
|
+
className: optionLabel,
|
|
593
|
+
style: layoutConfig !== null && layoutConfig !== void 0 && layoutConfig.optionLabelFontSize ? {
|
|
594
|
+
fontSize: layoutConfig === null || layoutConfig === void 0 ? void 0 : layoutConfig.optionLabelFontSize
|
|
595
|
+
} : undefined,
|
|
596
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
597
|
+
dangerouslySetInnerHTML: {
|
|
598
|
+
__html: label
|
|
599
|
+
}
|
|
600
|
+
}), caption && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
601
|
+
className: optionCaption,
|
|
602
|
+
dangerouslySetInnerHTML: {
|
|
603
|
+
__html: " ".concat(caption)
|
|
604
|
+
}
|
|
605
|
+
})]
|
|
606
|
+
}), description && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
607
|
+
className: optionDescription,
|
|
608
|
+
dangerouslySetInnerHTML: {
|
|
609
|
+
__html: description
|
|
610
|
+
}
|
|
611
|
+
})]
|
|
612
|
+
}, option.codex);
|
|
613
|
+
})
|
|
614
|
+
});
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
var OptionRenderer = function OptionRenderer(_ref) {
|
|
618
|
+
var feature = _ref.feature,
|
|
619
|
+
selectedOptions = _ref.selectedOptions,
|
|
620
|
+
onSelect = _ref.onSelect,
|
|
621
|
+
selections = _ref.selections;
|
|
622
|
+
var _useOptionRenderer = useOptionRenderer({
|
|
623
|
+
feature: feature,
|
|
624
|
+
selectedOptions: selectedOptions,
|
|
625
|
+
onSelect: onSelect,
|
|
626
|
+
selections: selections
|
|
627
|
+
}),
|
|
628
|
+
selectOptions = _useOptionRenderer.selectOptions,
|
|
629
|
+
rangeOption = _useOptionRenderer.rangeOption,
|
|
630
|
+
handleSingleSelect = _useOptionRenderer.handleSingleSelect,
|
|
631
|
+
handleMultiSelect = _useOptionRenderer.handleMultiSelect,
|
|
632
|
+
getOptionLabel = _useOptionRenderer.getOptionLabel,
|
|
633
|
+
getOptionDescription = _useOptionRenderer.getOptionDescription,
|
|
634
|
+
getOptionCaption = _useOptionRenderer.getOptionCaption;
|
|
635
|
+
|
|
636
|
+
// Handle range type (slider)
|
|
637
|
+
if (rangeOption && rangeOption.range) {
|
|
638
|
+
return /*#__PURE__*/jsxRuntime.jsx(RangeLayout, {
|
|
639
|
+
option: rangeOption,
|
|
640
|
+
selectedOptions: selectedOptions,
|
|
641
|
+
onSelect: onSelect,
|
|
642
|
+
getOptionCaption: getOptionCaption
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
var handleSelect = feature.multiSelect ? handleMultiSelect : handleSingleSelect;
|
|
646
|
+
switch (feature.layout) {
|
|
647
|
+
case 'dropdown':
|
|
648
|
+
return /*#__PURE__*/jsxRuntime.jsx(DropdownLayout, {
|
|
649
|
+
options: selectOptions,
|
|
650
|
+
selectedOptions: selectedOptions,
|
|
651
|
+
onSelect: handleSingleSelect,
|
|
652
|
+
getOptionLabel: getOptionLabel,
|
|
653
|
+
getOptionCaption: getOptionCaption,
|
|
654
|
+
layoutConfig: feature.layoutConfig
|
|
655
|
+
});
|
|
656
|
+
case 'radio':
|
|
657
|
+
case 'checkbox':
|
|
658
|
+
return /*#__PURE__*/jsxRuntime.jsx(SelectionListLayout, {
|
|
659
|
+
options: selectOptions,
|
|
660
|
+
selectedOptions: selectedOptions,
|
|
661
|
+
onSelect: handleSelect,
|
|
662
|
+
getOptionLabel: getOptionLabel,
|
|
663
|
+
getOptionDescription: getOptionDescription,
|
|
664
|
+
getOptionCaption: getOptionCaption,
|
|
665
|
+
type: feature.layout,
|
|
666
|
+
layoutConfig: feature.layoutConfig
|
|
667
|
+
});
|
|
668
|
+
case 'toggle':
|
|
669
|
+
case 'multitoggle':
|
|
670
|
+
case 'box':
|
|
671
|
+
case 'gallery':
|
|
672
|
+
default:
|
|
673
|
+
return /*#__PURE__*/jsxRuntime.jsx(ButtonGroupLayout, {
|
|
674
|
+
options: selectOptions,
|
|
675
|
+
selectedOptions: selectedOptions,
|
|
676
|
+
onSelect: handleSelect,
|
|
677
|
+
getOptionLabel: getOptionLabel,
|
|
678
|
+
getOptionDescription: getOptionDescription,
|
|
679
|
+
getOptionCaption: getOptionCaption,
|
|
680
|
+
layout: feature.layout,
|
|
681
|
+
layoutConfig: feature.layoutConfig
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
|
|
686
|
+
var FeatureRenderer = function FeatureRenderer(_ref) {
|
|
687
|
+
var _feature$description, _feature$description2, _feature$description3;
|
|
688
|
+
var feature = _ref.feature,
|
|
689
|
+
selection = _ref.selection,
|
|
690
|
+
_onSelect = _ref.onSelect,
|
|
691
|
+
selections = _ref.selections;
|
|
692
|
+
var _useTranslation = divaCore.useTranslation(),
|
|
693
|
+
i18n = _useTranslation.i18n;
|
|
694
|
+
var language = i18n.language;
|
|
695
|
+
var label = feature.label[language] || feature.label.en || feature.label.de || feature.codex;
|
|
696
|
+
var description = ((_feature$description = feature.description) === null || _feature$description === void 0 ? void 0 : _feature$description[language]) || ((_feature$description2 = feature.description) === null || _feature$description2 === void 0 ? void 0 : _feature$description2.en) || ((_feature$description3 = feature.description) === null || _feature$description3 === void 0 ? void 0 : _feature$description3.de);
|
|
697
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
698
|
+
className: featureContainer,
|
|
699
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
700
|
+
className: featureLabel,
|
|
701
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
702
|
+
dangerouslySetInnerHTML: {
|
|
703
|
+
__html: label
|
|
704
|
+
}
|
|
705
|
+
}), feature.required && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
706
|
+
className: featureRequired,
|
|
707
|
+
children: " *"
|
|
708
|
+
})]
|
|
709
|
+
}), description && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
710
|
+
className: featureDescription,
|
|
711
|
+
dangerouslySetInnerHTML: {
|
|
712
|
+
__html: description
|
|
713
|
+
}
|
|
714
|
+
}), /*#__PURE__*/jsxRuntime.jsx(OptionRenderer, {
|
|
715
|
+
feature: feature,
|
|
716
|
+
selectedOptions: (selection === null || selection === void 0 ? void 0 : selection.selectedOptions) || [],
|
|
717
|
+
onSelect: function onSelect(selectedOptions) {
|
|
718
|
+
return _onSelect(feature.codex, selectedOptions);
|
|
719
|
+
},
|
|
720
|
+
selections: selections
|
|
721
|
+
})]
|
|
722
|
+
});
|
|
723
|
+
};
|
|
724
|
+
|
|
725
|
+
var Speedometer = function Speedometer(_ref) {
|
|
726
|
+
var value = _ref.value,
|
|
727
|
+
_ref$min = _ref.min,
|
|
728
|
+
min = _ref$min === void 0 ? 0 : _ref$min,
|
|
729
|
+
_ref$max = _ref.max,
|
|
730
|
+
max = _ref$max === void 0 ? 100 : _ref$max,
|
|
731
|
+
label = _ref.label,
|
|
732
|
+
_ref$zones = _ref.zones,
|
|
733
|
+
zones = _ref$zones === void 0 ? [] : _ref$zones;
|
|
734
|
+
var _useTranslation = divaCore.useTranslation();
|
|
735
|
+
_useTranslation.t;
|
|
736
|
+
var radius = 80;
|
|
737
|
+
var strokeWidth = 12;
|
|
738
|
+
var centerX = 100;
|
|
739
|
+
var centerY = 110;
|
|
740
|
+
var normalizedValue = Math.min(Math.max(value, min), max);
|
|
741
|
+
var percentage = (normalizedValue - min) / (max - min);
|
|
742
|
+
|
|
743
|
+
// Speedometer arc: Centered at top (0deg), spanning 240 degrees
|
|
744
|
+
// From 240deg (bottom-left) to 480deg (bottom-right)
|
|
745
|
+
var startAngle = 240;
|
|
746
|
+
var endAngle = 480;
|
|
747
|
+
var totalAngle = endAngle - startAngle;
|
|
748
|
+
var currentAngle = startAngle + percentage * totalAngle;
|
|
749
|
+
|
|
750
|
+
// Animation state for the indicator
|
|
751
|
+
var _useState = react.useState(startAngle),
|
|
752
|
+
_useState2 = _slicedToArray__default["default"](_useState, 2),
|
|
753
|
+
animatedAngle = _useState2[0],
|
|
754
|
+
setAnimatedAngle = _useState2[1];
|
|
755
|
+
react.useEffect(function () {
|
|
756
|
+
var timer = setTimeout(function () {
|
|
757
|
+
setAnimatedAngle(currentAngle);
|
|
758
|
+
}, 50);
|
|
759
|
+
return function () {
|
|
760
|
+
return clearTimeout(timer);
|
|
761
|
+
};
|
|
762
|
+
}, [currentAngle]);
|
|
763
|
+
var polarToCartesian = function polarToCartesian(cX, cY, r, angleInDegrees) {
|
|
764
|
+
var angleInRadians = (angleInDegrees - 90) * Math.PI / 180.0;
|
|
765
|
+
return {
|
|
766
|
+
x: cX + r * Math.cos(angleInRadians),
|
|
767
|
+
y: cY + r * Math.sin(angleInRadians)
|
|
768
|
+
};
|
|
769
|
+
};
|
|
770
|
+
var describeArc = function describeArc(x, y, r, startA, endA) {
|
|
771
|
+
var start = polarToCartesian(x, y, r, endA);
|
|
772
|
+
var end = polarToCartesian(x, y, r, startA);
|
|
773
|
+
var largeArcFlag = endA - startA <= 180 ? '0' : '1';
|
|
774
|
+
return ['M', start.x, start.y, 'A', r, r, 0, largeArcFlag, 0, end.x, end.y].join(' ');
|
|
775
|
+
};
|
|
776
|
+
var backgroundPath = describeArc(centerX, centerY, radius, startAngle, endAngle);
|
|
777
|
+
|
|
778
|
+
// Find current zone color
|
|
779
|
+
var currentZone = zones.find(function (z) {
|
|
780
|
+
if (z.value && label && z.value === label) return true;
|
|
781
|
+
return normalizedValue >= z.min && normalizedValue <= z.max;
|
|
782
|
+
});
|
|
783
|
+
var activeColor = (currentZone === null || currentZone === void 0 ? void 0 : currentZone.color) || 'var(--diva-theme-palette-primary-main)';
|
|
784
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
785
|
+
className: speedometer,
|
|
786
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("svg", {
|
|
787
|
+
viewBox: "-20 0 240 170",
|
|
788
|
+
width: "100%",
|
|
789
|
+
height: "100%",
|
|
790
|
+
children: [zones.length > 0 ? zones.map(function (zone, i) {
|
|
791
|
+
var zoneStart = startAngle + (zone.min - min) / (max - min) * totalAngle;
|
|
792
|
+
var zoneEnd = startAngle + (zone.max - min) / (max - min) * totalAngle;
|
|
793
|
+
return /*#__PURE__*/jsxRuntime.jsx("path", {
|
|
794
|
+
d: describeArc(centerX, centerY, radius, zoneStart, zoneEnd),
|
|
795
|
+
fill: "none",
|
|
796
|
+
stroke: zone.color || '#e6e6e6',
|
|
797
|
+
strokeWidth: strokeWidth,
|
|
798
|
+
opacity: 0.3
|
|
799
|
+
}, i);
|
|
800
|
+
}) : /*#__PURE__*/jsxRuntime.jsx("path", {
|
|
801
|
+
d: backgroundPath,
|
|
802
|
+
fill: "none",
|
|
803
|
+
stroke: "#e6e6e6",
|
|
804
|
+
strokeWidth: strokeWidth,
|
|
805
|
+
strokeLinecap: "round"
|
|
806
|
+
}), /*#__PURE__*/jsxRuntime.jsx("g", {
|
|
807
|
+
style: {
|
|
808
|
+
transition: 'transform 2s cubic-bezier(0.4, 0, 0.2, 1)',
|
|
809
|
+
transform: "rotate(".concat(animatedAngle, "deg)"),
|
|
810
|
+
transformOrigin: "".concat(centerX, "px ").concat(centerY, "px")
|
|
811
|
+
},
|
|
812
|
+
children: /*#__PURE__*/jsxRuntime.jsx("path", {
|
|
813
|
+
d: describeArc(centerX, centerY, radius + 5, -2, 2),
|
|
814
|
+
fill: "none",
|
|
815
|
+
stroke: activeColor,
|
|
816
|
+
strokeWidth: strokeWidth + 10,
|
|
817
|
+
strokeLinecap: "round"
|
|
818
|
+
})
|
|
819
|
+
}), zones.map(function (zone, i) {
|
|
820
|
+
var zoneMidAngle = startAngle + ((zone.min - min) / (max - min) + (zone.max - min) / (max - min)) / 2 * totalAngle;
|
|
821
|
+
|
|
822
|
+
// Adjust offset based on string length to avoid collision with the arc/pointer
|
|
823
|
+
var textLength = zone.label.length;
|
|
824
|
+
var labelOffset = 22 + (textLength > 5 ? 6 : 0);
|
|
825
|
+
var labelPos = polarToCartesian(centerX, centerY, radius - labelOffset, zoneMidAngle);
|
|
826
|
+
return /*#__PURE__*/jsxRuntime.jsx("text", {
|
|
827
|
+
x: labelPos.x,
|
|
828
|
+
y: labelPos.y,
|
|
829
|
+
textAnchor: "middle",
|
|
830
|
+
fontSize: textLength > 7 ? '10' : '12',
|
|
831
|
+
fontWeight: "500",
|
|
832
|
+
fill: "#999",
|
|
833
|
+
dominantBaseline: "middle",
|
|
834
|
+
children: zone.label
|
|
835
|
+
}, i);
|
|
836
|
+
}), /*#__PURE__*/jsxRuntime.jsx("text", {
|
|
837
|
+
x: centerX,
|
|
838
|
+
y: centerY - 10,
|
|
839
|
+
textAnchor: "middle",
|
|
840
|
+
fontSize: "22",
|
|
841
|
+
fontWeight: "700",
|
|
842
|
+
fill: activeColor,
|
|
843
|
+
children: (currentZone === null || currentZone === void 0 ? void 0 : currentZone.label) || label || value
|
|
844
|
+
}), /*#__PURE__*/jsxRuntime.jsx("text", {
|
|
845
|
+
x: centerX,
|
|
846
|
+
y: centerY + 34,
|
|
847
|
+
textAnchor: "middle",
|
|
848
|
+
fontSize: "20",
|
|
849
|
+
fontWeight: "600",
|
|
850
|
+
fill: activeColor,
|
|
851
|
+
children: value
|
|
852
|
+
})]
|
|
853
|
+
})
|
|
854
|
+
});
|
|
855
|
+
};
|
|
856
|
+
|
|
857
|
+
function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
858
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty__default["default"](e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
859
|
+
var SpeedometerGroup = function SpeedometerGroup(_ref) {
|
|
860
|
+
var displayConfig = _ref.displayConfig,
|
|
861
|
+
data = _ref.data,
|
|
862
|
+
language = _ref.language;
|
|
863
|
+
var titleText = displayConfig.title ? displayConfig.title[language] || displayConfig.title.en || displayConfig.title.de : '';
|
|
864
|
+
var speedometerConfigs = displayConfig.speedometers;
|
|
865
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
866
|
+
className: speedometerGroup,
|
|
867
|
+
children: [titleText && /*#__PURE__*/jsxRuntime.jsx("h4", {
|
|
868
|
+
className: speedometerGroupTitle,
|
|
869
|
+
dangerouslySetInnerHTML: {
|
|
870
|
+
__html: titleText
|
|
871
|
+
}
|
|
872
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
873
|
+
className: speedometerGroupGrid,
|
|
874
|
+
children: speedometerConfigs.map(function (sConfig, idx) {
|
|
875
|
+
var _sConfig$zones;
|
|
876
|
+
var sValue = sConfig.valueKey ? data[sConfig.valueKey] : null;
|
|
877
|
+
var sLabel = sConfig.labelKey ? data[sConfig.labelKey] : null;
|
|
878
|
+
var sTitle = sConfig.title ? sConfig.title[language] || sConfig.title.en || sConfig.title.de : '';
|
|
879
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
880
|
+
className: speedometerGroupItem,
|
|
881
|
+
children: [sTitle && /*#__PURE__*/jsxRuntime.jsx("h5", {
|
|
882
|
+
className: speedometerGroupItemTitle,
|
|
883
|
+
dangerouslySetInnerHTML: {
|
|
884
|
+
__html: sTitle
|
|
885
|
+
}
|
|
886
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Speedometer, {
|
|
887
|
+
value: _typeof__default["default"](sValue) === 'object' ? sValue.value : sValue,
|
|
888
|
+
label: _typeof__default["default"](sLabel) === 'object' ? sLabel.result : sLabel,
|
|
889
|
+
min: sConfig.min,
|
|
890
|
+
max: sConfig.max,
|
|
891
|
+
zones: (_sConfig$zones = sConfig.zones) === null || _sConfig$zones === void 0 ? void 0 : _sConfig$zones.map(function (z) {
|
|
892
|
+
return _objectSpread$3(_objectSpread$3({}, z), {}, {
|
|
893
|
+
label: z.label[language] || z.label.en || z.label.de
|
|
894
|
+
});
|
|
895
|
+
})
|
|
896
|
+
})]
|
|
897
|
+
}, idx);
|
|
898
|
+
})
|
|
899
|
+
})]
|
|
900
|
+
});
|
|
901
|
+
};
|
|
902
|
+
|
|
903
|
+
var TextResult = function TextResult(_ref) {
|
|
904
|
+
var displayConfig = _ref.displayConfig,
|
|
905
|
+
data = _ref.data,
|
|
906
|
+
language = _ref.language;
|
|
907
|
+
var label = displayConfig.labelKey ? data[displayConfig.labelKey] : null;
|
|
908
|
+
var titleText = displayConfig.title ? displayConfig.title[language] || displayConfig.title.en || displayConfig.title.de : '';
|
|
909
|
+
var resultValueText = _typeof__default["default"](label) === 'object' ? label.result : String(label);
|
|
910
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
911
|
+
className: resultItem,
|
|
912
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
913
|
+
className: resultKey,
|
|
914
|
+
dangerouslySetInnerHTML: {
|
|
915
|
+
__html: titleText
|
|
916
|
+
}
|
|
917
|
+
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
918
|
+
className: resultValue,
|
|
919
|
+
dangerouslySetInnerHTML: {
|
|
920
|
+
__html: resultValueText
|
|
921
|
+
}
|
|
922
|
+
})]
|
|
923
|
+
}, displayConfig.labelKey || 'text');
|
|
924
|
+
};
|
|
925
|
+
|
|
926
|
+
var ResultItemsRenderer = function ResultItemsRenderer(_ref) {
|
|
927
|
+
var data = _ref.data,
|
|
928
|
+
config = _ref.config,
|
|
929
|
+
language = _ref.language;
|
|
930
|
+
var renderGenericResult = function renderGenericResult(displayConfig, data, index) {
|
|
931
|
+
switch (displayConfig.type) {
|
|
932
|
+
case 'speedometer':
|
|
933
|
+
return /*#__PURE__*/jsxRuntime.jsx(SpeedometerGroup, {
|
|
934
|
+
displayConfig: displayConfig,
|
|
935
|
+
data: data,
|
|
936
|
+
language: language
|
|
937
|
+
}, "speedometer-".concat(index));
|
|
938
|
+
case 'text':
|
|
939
|
+
return /*#__PURE__*/jsxRuntime.jsx(TextResult, {
|
|
940
|
+
displayConfig: displayConfig,
|
|
941
|
+
data: data,
|
|
942
|
+
language: language
|
|
943
|
+
}, "text-".concat(index));
|
|
944
|
+
default:
|
|
945
|
+
return null;
|
|
946
|
+
}
|
|
947
|
+
};
|
|
948
|
+
if (config.results && config.results.length > 0) {
|
|
949
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
950
|
+
className: resultsGrid,
|
|
951
|
+
children: config.results.map(function (displayConfig, index) {
|
|
952
|
+
return renderGenericResult(displayConfig, data, index);
|
|
953
|
+
})
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
// Fallback to legacy rendering if no results config provided
|
|
958
|
+
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
959
|
+
children: Object.entries(data).map(function (_ref2) {
|
|
960
|
+
var _ref3 = _slicedToArray__default["default"](_ref2, 2),
|
|
961
|
+
key = _ref3[0],
|
|
962
|
+
value = _ref3[1];
|
|
963
|
+
if (_typeof__default["default"](value) === 'object' && value !== null) {
|
|
964
|
+
if (value.result !== undefined) {
|
|
965
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
966
|
+
className: resultItem,
|
|
967
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
968
|
+
className: resultKey,
|
|
969
|
+
dangerouslySetInnerHTML: {
|
|
970
|
+
__html: key
|
|
971
|
+
}
|
|
972
|
+
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
973
|
+
className: resultValue,
|
|
974
|
+
dangerouslySetInnerHTML: {
|
|
975
|
+
__html: value.result
|
|
976
|
+
}
|
|
977
|
+
})]
|
|
978
|
+
}, key);
|
|
979
|
+
}
|
|
980
|
+
return null;
|
|
981
|
+
}
|
|
982
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
983
|
+
className: resultItem,
|
|
984
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
985
|
+
className: resultKey,
|
|
986
|
+
dangerouslySetInnerHTML: {
|
|
987
|
+
__html: key
|
|
988
|
+
}
|
|
989
|
+
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
990
|
+
className: resultValue,
|
|
991
|
+
dangerouslySetInnerHTML: {
|
|
992
|
+
__html: String(value)
|
|
993
|
+
}
|
|
994
|
+
})]
|
|
995
|
+
}, key);
|
|
996
|
+
})
|
|
997
|
+
});
|
|
998
|
+
};
|
|
999
|
+
|
|
1000
|
+
var ArrowRight = function ArrowRight() {
|
|
1001
|
+
return /*#__PURE__*/jsxRuntime.jsxs("svg", {
|
|
1002
|
+
width: "20",
|
|
1003
|
+
height: "20",
|
|
1004
|
+
viewBox: "0 0 24 24",
|
|
1005
|
+
fill: "none",
|
|
1006
|
+
stroke: "currentColor",
|
|
1007
|
+
strokeWidth: "2",
|
|
1008
|
+
strokeLinecap: "round",
|
|
1009
|
+
strokeLinejoin: "round",
|
|
1010
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("line", {
|
|
1011
|
+
x1: "5",
|
|
1012
|
+
y1: "12",
|
|
1013
|
+
x2: "19",
|
|
1014
|
+
y2: "12"
|
|
1015
|
+
}), /*#__PURE__*/jsxRuntime.jsx("polyline", {
|
|
1016
|
+
points: "12 5 19 12 12 19"
|
|
1017
|
+
})]
|
|
1018
|
+
});
|
|
1019
|
+
};
|
|
1020
|
+
var CopyIcon = function CopyIcon() {
|
|
1021
|
+
return /*#__PURE__*/jsxRuntime.jsxs("svg", {
|
|
1022
|
+
width: "20",
|
|
1023
|
+
height: "20",
|
|
1024
|
+
viewBox: "0 0 24 24",
|
|
1025
|
+
fill: "none",
|
|
1026
|
+
stroke: "currentColor",
|
|
1027
|
+
strokeWidth: "2",
|
|
1028
|
+
strokeLinecap: "round",
|
|
1029
|
+
strokeLinejoin: "round",
|
|
1030
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("rect", {
|
|
1031
|
+
x: "9",
|
|
1032
|
+
y: "9",
|
|
1033
|
+
width: "13",
|
|
1034
|
+
height: "13",
|
|
1035
|
+
rx: "2",
|
|
1036
|
+
ry: "2"
|
|
1037
|
+
}), /*#__PURE__*/jsxRuntime.jsx("path", {
|
|
1038
|
+
d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"
|
|
1039
|
+
})]
|
|
1040
|
+
});
|
|
1041
|
+
};
|
|
1042
|
+
var CheckIcon = function CheckIcon() {
|
|
1043
|
+
return /*#__PURE__*/jsxRuntime.jsx("svg", {
|
|
1044
|
+
width: "20",
|
|
1045
|
+
height: "20",
|
|
1046
|
+
viewBox: "0 0 24 24",
|
|
1047
|
+
fill: "none",
|
|
1048
|
+
stroke: "currentColor",
|
|
1049
|
+
strokeWidth: "2",
|
|
1050
|
+
strokeLinecap: "round",
|
|
1051
|
+
strokeLinejoin: "round",
|
|
1052
|
+
children: /*#__PURE__*/jsxRuntime.jsx("polyline", {
|
|
1053
|
+
points: "20 6 9 17 4 12"
|
|
1054
|
+
})
|
|
1055
|
+
});
|
|
1056
|
+
};
|
|
1057
|
+
var CloseIcon = function CloseIcon() {
|
|
1058
|
+
return /*#__PURE__*/jsxRuntime.jsxs("svg", {
|
|
1059
|
+
width: "20",
|
|
1060
|
+
height: "20",
|
|
1061
|
+
viewBox: "0 0 24 24",
|
|
1062
|
+
fill: "none",
|
|
1063
|
+
stroke: "currentColor",
|
|
1064
|
+
strokeWidth: "2",
|
|
1065
|
+
strokeLinecap: "round",
|
|
1066
|
+
strokeLinejoin: "round",
|
|
1067
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("line", {
|
|
1068
|
+
x1: "18",
|
|
1069
|
+
y1: "6",
|
|
1070
|
+
x2: "6",
|
|
1071
|
+
y2: "18"
|
|
1072
|
+
}), /*#__PURE__*/jsxRuntime.jsx("line", {
|
|
1073
|
+
x1: "6",
|
|
1074
|
+
y1: "6",
|
|
1075
|
+
x2: "18",
|
|
1076
|
+
y2: "18"
|
|
1077
|
+
})]
|
|
1078
|
+
});
|
|
1079
|
+
};
|
|
1080
|
+
var Navigation = function Navigation(_ref) {
|
|
1081
|
+
var onBack = _ref.onBack,
|
|
1082
|
+
onNext = _ref.onNext,
|
|
1083
|
+
onCopy = _ref.onCopy,
|
|
1084
|
+
onRetry = _ref.onRetry,
|
|
1085
|
+
onApply = _ref.onApply,
|
|
1086
|
+
onClose = _ref.onClose,
|
|
1087
|
+
_ref$canProceed = _ref.canProceed,
|
|
1088
|
+
canProceed = _ref$canProceed === void 0 ? true : _ref$canProceed,
|
|
1089
|
+
_ref$showBack = _ref.showBack,
|
|
1090
|
+
showBack = _ref$showBack === void 0 ? false : _ref$showBack,
|
|
1091
|
+
_ref$nextLabel = _ref.nextLabel,
|
|
1092
|
+
nextLabel = _ref$nextLabel === void 0 ? '' : _ref$nextLabel,
|
|
1093
|
+
nextInstance = _ref.nextInstance,
|
|
1094
|
+
currentInstanceId = _ref.currentInstanceId,
|
|
1095
|
+
_ref$language = _ref.language,
|
|
1096
|
+
language = _ref$language === void 0 ? 'de' : _ref$language;
|
|
1097
|
+
var _useTranslation = divaCore.useTranslation(),
|
|
1098
|
+
t = _useTranslation.t;
|
|
1099
|
+
var _useState = react.useState(false),
|
|
1100
|
+
_useState2 = _slicedToArray__default["default"](_useState, 2),
|
|
1101
|
+
appliedFeedback = _useState2[0],
|
|
1102
|
+
setAppliedFeedback = _useState2[1];
|
|
1103
|
+
var _useState3 = react.useState(false),
|
|
1104
|
+
_useState4 = _slicedToArray__default["default"](_useState3, 2),
|
|
1105
|
+
showCloseButton = _useState4[0],
|
|
1106
|
+
setShowCloseButton = _useState4[1];
|
|
1107
|
+
var nextInstanceLabel = nextInstance ? nextInstance.label[language] || nextInstance.label.en || nextInstance.label.de || nextInstance.id : '';
|
|
1108
|
+
var handleApply = function handleApply() {
|
|
1109
|
+
onApply === null || onApply === void 0 || onApply();
|
|
1110
|
+
setAppliedFeedback(true);
|
|
1111
|
+
if (onClose) {
|
|
1112
|
+
setTimeout(function () {
|
|
1113
|
+
return setShowCloseButton(true);
|
|
1114
|
+
}, 1500);
|
|
1115
|
+
} else {
|
|
1116
|
+
setTimeout(function () {
|
|
1117
|
+
setAppliedFeedback(false);
|
|
1118
|
+
}, 2000);
|
|
1119
|
+
}
|
|
1120
|
+
};
|
|
1121
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1122
|
+
className: buttonContainer,
|
|
1123
|
+
children: [showBack && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1124
|
+
className: navLeftGroup,
|
|
1125
|
+
children: /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
1126
|
+
className: button,
|
|
1127
|
+
onClick: onBack,
|
|
1128
|
+
"aria-label": t('quickconfig.back', {
|
|
1129
|
+
defaultValue: 'Zurück'
|
|
1130
|
+
}),
|
|
1131
|
+
children: t('quickconfig.back', {
|
|
1132
|
+
defaultValue: 'Zurück'
|
|
1133
|
+
})
|
|
1134
|
+
}, "back")
|
|
1135
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1136
|
+
className: navRightGroup,
|
|
1137
|
+
children: [onApply && !showCloseButton && /*#__PURE__*/jsxRuntime.jsxs("button", {
|
|
1138
|
+
className: classNames__default["default"](button, buttonPrimary, buttonWithArrow, navButtonPadding, appliedFeedback && buttonPrimaryApplied),
|
|
1139
|
+
onClick: handleApply,
|
|
1140
|
+
disabled: appliedFeedback,
|
|
1141
|
+
children: [appliedFeedback ? t('quickconfig.changesApplied', {
|
|
1142
|
+
defaultValue: 'Änderungen wurden übernommen'
|
|
1143
|
+
}) : t('quickconfig.applyChanges', {
|
|
1144
|
+
defaultValue: 'Änderungen übernehmen'
|
|
1145
|
+
}), appliedFeedback ? /*#__PURE__*/jsxRuntime.jsx(CheckIcon, {}) : /*#__PURE__*/jsxRuntime.jsx(CopyIcon, {})]
|
|
1146
|
+
}, "apply"), onClose && showCloseButton && /*#__PURE__*/jsxRuntime.jsxs("button", {
|
|
1147
|
+
className: classNames__default["default"](button, buttonPrimary, buttonWithArrow, navButtonPadding),
|
|
1148
|
+
onClick: onClose,
|
|
1149
|
+
children: [t('quickconfig.closeNow', {
|
|
1150
|
+
defaultValue: 'Jetzt schließen'
|
|
1151
|
+
}), /*#__PURE__*/jsxRuntime.jsx(CloseIcon, {})]
|
|
1152
|
+
}, "close"), onRetry && /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
1153
|
+
className: classNames__default["default"](button, buttonSecondary, buttonWithArrow, navButtonPadding),
|
|
1154
|
+
onClick: onRetry,
|
|
1155
|
+
children: t('quickconfig.retry', {
|
|
1156
|
+
defaultValue: 'Nochmal zum Anfang'
|
|
1157
|
+
})
|
|
1158
|
+
}, "retry"), nextInstance && onCopy && currentInstanceId && /*#__PURE__*/jsxRuntime.jsxs("button", {
|
|
1159
|
+
className: classNames__default["default"](button, buttonSecondary, buttonWithArrow),
|
|
1160
|
+
onClick: function onClick() {
|
|
1161
|
+
onCopy(currentInstanceId, nextInstance.id);
|
|
1162
|
+
},
|
|
1163
|
+
disabled: !canProceed,
|
|
1164
|
+
children: [t('quickconfig.applyRecommendationsFor', {
|
|
1165
|
+
instance: nextInstanceLabel,
|
|
1166
|
+
defaultValue: "Eingabe f\xFCr ".concat(nextInstanceLabel, " \xFCbernehmen")
|
|
1167
|
+
}), /*#__PURE__*/jsxRuntime.jsx(ArrowRight, {})]
|
|
1168
|
+
}, "applyRecommendations"), onNext && /*#__PURE__*/jsxRuntime.jsxs("button", {
|
|
1169
|
+
className: classNames__default["default"](button, buttonPrimary, buttonWithArrow),
|
|
1170
|
+
onClick: onNext,
|
|
1171
|
+
disabled: !canProceed,
|
|
1172
|
+
children: [nextInstance ? t('quickconfig.nextWith', {
|
|
1173
|
+
instance: nextInstanceLabel,
|
|
1174
|
+
defaultValue: "Weiter mit ".concat(nextInstanceLabel)
|
|
1175
|
+
}) : nextLabel, /*#__PURE__*/jsxRuntime.jsx(ArrowRight, {})]
|
|
1176
|
+
}, "next")]
|
|
1177
|
+
})]
|
|
1178
|
+
});
|
|
1179
|
+
};
|
|
1180
|
+
|
|
1181
|
+
var ContentItem = function ContentItem(_ref) {
|
|
1182
|
+
var id = _ref.id,
|
|
1183
|
+
renderContentItem = _ref.renderContentItem;
|
|
1184
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1185
|
+
className: contentSection,
|
|
1186
|
+
children: renderContentItem ? renderContentItem(id) : null
|
|
1187
|
+
});
|
|
1188
|
+
};
|
|
1189
|
+
|
|
1190
|
+
function _createForOfIteratorHelper$1(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$1(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
1191
|
+
function _unsupportedIterableToArray$1(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$1(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1(r, a) : void 0; } }
|
|
1192
|
+
function _arrayLikeToArray$1(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
1193
|
+
var resolveContentItemId = function resolveContentItemId(displayConfig, data) {
|
|
1194
|
+
// Convert calculation results to UserSelection format for ConditionEvaluator
|
|
1195
|
+
var resultAsSelections = Object.entries(data).filter(function (_ref) {
|
|
1196
|
+
var _ref2 = _slicedToArray__default["default"](_ref, 1),
|
|
1197
|
+
key = _ref2[0];
|
|
1198
|
+
return key !== 'input' && key !== 'instanceResults';
|
|
1199
|
+
}).map(function (_ref3) {
|
|
1200
|
+
var _ref4 = _slicedToArray__default["default"](_ref3, 2),
|
|
1201
|
+
key = _ref4[0],
|
|
1202
|
+
val = _ref4[1];
|
|
1203
|
+
var value = _typeof__default["default"](val) === 'object' && val !== null && 'result' in val ? String(val.result) : String(val);
|
|
1204
|
+
return {
|
|
1205
|
+
featureCodex: key,
|
|
1206
|
+
selectedOptions: [value]
|
|
1207
|
+
};
|
|
1208
|
+
});
|
|
1209
|
+
var evaluator = new ConditionEvaluator(resultAsSelections);
|
|
1210
|
+
|
|
1211
|
+
// 1. Check rules first (complex logic)
|
|
1212
|
+
if (displayConfig.rules) {
|
|
1213
|
+
var _iterator = _createForOfIteratorHelper$1(displayConfig.rules),
|
|
1214
|
+
_step;
|
|
1215
|
+
try {
|
|
1216
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1217
|
+
var rule = _step.value;
|
|
1218
|
+
if (evaluator.evaluate(rule.condition)) {
|
|
1219
|
+
return rule.contentItemId;
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
} catch (err) {
|
|
1223
|
+
_iterator.e(err);
|
|
1224
|
+
} finally {
|
|
1225
|
+
_iterator.f();
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
// 2. Fallback to direct key match or static contentItemId
|
|
1230
|
+
return (displayConfig.contentItemId && data[displayConfig.contentItemId] ? data[displayConfig.contentItemId] : null) || displayConfig.contentItemId || null;
|
|
1231
|
+
};
|
|
1232
|
+
|
|
1233
|
+
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1234
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { _defineProperty__default["default"](e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1235
|
+
var ResultDisplay = function ResultDisplay(_ref) {
|
|
1236
|
+
var activeInstanceId = _ref.activeInstanceId,
|
|
1237
|
+
result = _ref.result,
|
|
1238
|
+
config = _ref.config,
|
|
1239
|
+
onRetry = _ref.onRetry,
|
|
1240
|
+
filteredInstances = _ref.filteredInstances,
|
|
1241
|
+
onEvent = _ref.onEvent,
|
|
1242
|
+
renderContentItem = _ref.renderContentItem;
|
|
1243
|
+
var _useTranslation = divaCore.useTranslation(),
|
|
1244
|
+
i18n = _useTranslation.i18n;
|
|
1245
|
+
var language = i18n.language;
|
|
1246
|
+
var activeInstanceData = react.useMemo(function () {
|
|
1247
|
+
if (activeInstanceId && result.instanceResults && result.instanceResults[activeInstanceId]) return result.instanceResults[activeInstanceId];
|
|
1248
|
+
return result;
|
|
1249
|
+
}, [activeInstanceId, result]);
|
|
1250
|
+
var handleApplyResults = function handleApplyResults() {
|
|
1251
|
+
var combinedMappedResults = {};
|
|
1252
|
+
if (result.instanceResults && filteredInstances && filteredInstances.length > 0) {
|
|
1253
|
+
filteredInstances.forEach(function (instance) {
|
|
1254
|
+
var instanceRes = result.instanceResults[instance.id];
|
|
1255
|
+
if (instanceRes && instance.resultMapping) {
|
|
1256
|
+
Object.entries(instance.resultMapping).forEach(function (_ref2) {
|
|
1257
|
+
var _ref3 = _slicedToArray__default["default"](_ref2, 2),
|
|
1258
|
+
resultKey = _ref3[0],
|
|
1259
|
+
targetKey = _ref3[1];
|
|
1260
|
+
var val = instanceRes[resultKey];
|
|
1261
|
+
if (val && val.result) {
|
|
1262
|
+
if (Array.isArray(targetKey)) {
|
|
1263
|
+
targetKey.forEach(function (key) {
|
|
1264
|
+
combinedMappedResults[key] = val.result;
|
|
1265
|
+
});
|
|
1266
|
+
} else {
|
|
1267
|
+
combinedMappedResults[targetKey] = val.result;
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
});
|
|
1271
|
+
}
|
|
1272
|
+
});
|
|
1273
|
+
} else {
|
|
1274
|
+
var targetInstance = filteredInstances && filteredInstances.length === 1 ? filteredInstances[0] : null;
|
|
1275
|
+
var resSource = result.result || {};
|
|
1276
|
+
if (targetInstance !== null && targetInstance !== void 0 && targetInstance.resultMapping) {
|
|
1277
|
+
Object.entries(targetInstance.resultMapping).forEach(function (_ref4) {
|
|
1278
|
+
var _ref5 = _slicedToArray__default["default"](_ref4, 2),
|
|
1279
|
+
resultKey = _ref5[0],
|
|
1280
|
+
targetKey = _ref5[1];
|
|
1281
|
+
var val = resSource[resultKey];
|
|
1282
|
+
if (val && val.result) {
|
|
1283
|
+
if (Array.isArray(targetKey)) {
|
|
1284
|
+
targetKey.forEach(function (key) {
|
|
1285
|
+
combinedMappedResults[key] = val.result;
|
|
1286
|
+
});
|
|
1287
|
+
} else {
|
|
1288
|
+
combinedMappedResults[targetKey] = val.result;
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
onEvent === null || onEvent === void 0 || onEvent({
|
|
1295
|
+
type: 'applyResults',
|
|
1296
|
+
payload: combinedMappedResults
|
|
1297
|
+
});
|
|
1298
|
+
};
|
|
1299
|
+
var handleClose = onEvent ? function () {
|
|
1300
|
+
return onEvent({
|
|
1301
|
+
type: 'onClose'
|
|
1302
|
+
});
|
|
1303
|
+
} : undefined;
|
|
1304
|
+
var renderResultsInOrder = function renderResultsInOrder() {
|
|
1305
|
+
if (!config.results || config.results.length === 0) {
|
|
1306
|
+
return /*#__PURE__*/jsxRuntime.jsx(ResultItemsRenderer, {
|
|
1307
|
+
data: activeInstanceData,
|
|
1308
|
+
config: config,
|
|
1309
|
+
language: language
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
var elements = [];
|
|
1313
|
+
var currentNonContentGroup = [];
|
|
1314
|
+
var flushNonContentGroup = function flushNonContentGroup() {
|
|
1315
|
+
if (currentNonContentGroup.length === 0) return;
|
|
1316
|
+
var groupResults = _toConsumableArray__default["default"](currentNonContentGroup);
|
|
1317
|
+
var key = "group-".concat(elements.length);
|
|
1318
|
+
elements.push(/*#__PURE__*/jsxRuntime.jsx(ResultItemsRenderer, {
|
|
1319
|
+
data: activeInstanceData,
|
|
1320
|
+
config: _objectSpread$2(_objectSpread$2({}, config), {}, {
|
|
1321
|
+
results: groupResults
|
|
1322
|
+
}),
|
|
1323
|
+
language: language
|
|
1324
|
+
}, key));
|
|
1325
|
+
currentNonContentGroup = [];
|
|
1326
|
+
};
|
|
1327
|
+
config.results.forEach(function (displayConfig, index) {
|
|
1328
|
+
if (displayConfig.type === 'content') {
|
|
1329
|
+
flushNonContentGroup();
|
|
1330
|
+
var contentItemId = resolveContentItemId(displayConfig, activeInstanceData);
|
|
1331
|
+
if (contentItemId) {
|
|
1332
|
+
elements.push(/*#__PURE__*/jsxRuntime.jsx(ContentItem, {
|
|
1333
|
+
id: contentItemId,
|
|
1334
|
+
renderContentItem: renderContentItem
|
|
1335
|
+
}, "content-".concat(index)));
|
|
1336
|
+
}
|
|
1337
|
+
} else {
|
|
1338
|
+
currentNonContentGroup.push(displayConfig);
|
|
1339
|
+
}
|
|
1340
|
+
});
|
|
1341
|
+
flushNonContentGroup();
|
|
1342
|
+
return elements;
|
|
1343
|
+
};
|
|
1344
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1345
|
+
className: resultContainer,
|
|
1346
|
+
children: [renderResultsInOrder(), /*#__PURE__*/jsxRuntime.jsx(Navigation, {
|
|
1347
|
+
onRetry: onRetry,
|
|
1348
|
+
onApply: onEvent ? handleApplyResults : undefined,
|
|
1349
|
+
onClose: handleClose
|
|
1350
|
+
})]
|
|
1351
|
+
});
|
|
1352
|
+
};
|
|
1353
|
+
|
|
1354
|
+
var ProgressBar = function ProgressBar(_ref) {
|
|
1355
|
+
var currentStep = _ref.currentStep,
|
|
1356
|
+
totalSteps = _ref.totalSteps;
|
|
1357
|
+
var progress = currentStep / totalSteps * 100;
|
|
1358
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1359
|
+
className: progressBar,
|
|
1360
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1361
|
+
className: progressBarFill,
|
|
1362
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1363
|
+
className: progressBarInner,
|
|
1364
|
+
style: {
|
|
1365
|
+
width: "".concat(progress, "%")
|
|
1366
|
+
}
|
|
1367
|
+
})
|
|
1368
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1369
|
+
className: progressText,
|
|
1370
|
+
children: [currentStep, " / ", totalSteps]
|
|
1371
|
+
})]
|
|
1372
|
+
});
|
|
1373
|
+
};
|
|
1374
|
+
|
|
1375
|
+
var Header = function Header(_ref) {
|
|
1376
|
+
var _ref$instances = _ref.instances,
|
|
1377
|
+
instances = _ref$instances === void 0 ? [] : _ref$instances,
|
|
1378
|
+
_ref$activeInstanceId = _ref.activeInstanceId,
|
|
1379
|
+
activeInstanceId = _ref$activeInstanceId === void 0 ? '' : _ref$activeInstanceId,
|
|
1380
|
+
onSwitchInstance = _ref.onSwitchInstance,
|
|
1381
|
+
onCancel = _ref.onCancel,
|
|
1382
|
+
_ref$featureGroups = _ref.featureGroups,
|
|
1383
|
+
featureGroups = _ref$featureGroups === void 0 ? [] : _ref$featureGroups,
|
|
1384
|
+
currentFeatureGroupIndex = _ref.currentFeatureGroupIndex;
|
|
1385
|
+
var _useTranslation = divaCore.useTranslation(),
|
|
1386
|
+
t = _useTranslation.t,
|
|
1387
|
+
i18n = _useTranslation.i18n;
|
|
1388
|
+
var language = i18n.language;
|
|
1389
|
+
var activeIndex = instances.findIndex(function (i) {
|
|
1390
|
+
return i.id === activeInstanceId;
|
|
1391
|
+
});
|
|
1392
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1393
|
+
className: stickyHeader,
|
|
1394
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1395
|
+
className: headerContainer,
|
|
1396
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1397
|
+
className: tabWrapper,
|
|
1398
|
+
style: {
|
|
1399
|
+
'--tab-count': instances.length
|
|
1400
|
+
},
|
|
1401
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1402
|
+
className: tabSlider,
|
|
1403
|
+
style: {
|
|
1404
|
+
transform: "translateX(".concat(activeIndex >= 0 ? activeIndex * 100 : 0, "%)")
|
|
1405
|
+
},
|
|
1406
|
+
"aria-hidden": true
|
|
1407
|
+
}), instances.map(function (instance) {
|
|
1408
|
+
return /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
1409
|
+
type: "button",
|
|
1410
|
+
className: classNames__default["default"](tab, _defineProperty__default["default"]({}, tabActive, activeInstanceId === instance.id)),
|
|
1411
|
+
onClick: function onClick() {
|
|
1412
|
+
return onSwitchInstance === null || onSwitchInstance === void 0 ? void 0 : onSwitchInstance(instance.id);
|
|
1413
|
+
},
|
|
1414
|
+
dangerouslySetInnerHTML: {
|
|
1415
|
+
__html: instance.label[language] || instance.label.en || instance.label.de || instance.id
|
|
1416
|
+
}
|
|
1417
|
+
}, instance.id);
|
|
1418
|
+
})]
|
|
1419
|
+
}), onCancel && /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
1420
|
+
className: closeButton,
|
|
1421
|
+
onClick: onCancel,
|
|
1422
|
+
"aria-label": t('quickconfig.close', {
|
|
1423
|
+
defaultValue: 'Schließen'
|
|
1424
|
+
}),
|
|
1425
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("svg", {
|
|
1426
|
+
width: "24",
|
|
1427
|
+
height: "24",
|
|
1428
|
+
viewBox: "0 0 24 24",
|
|
1429
|
+
fill: "none",
|
|
1430
|
+
stroke: "currentColor",
|
|
1431
|
+
strokeWidth: "2",
|
|
1432
|
+
strokeLinecap: "round",
|
|
1433
|
+
strokeLinejoin: "round",
|
|
1434
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("line", {
|
|
1435
|
+
x1: "18",
|
|
1436
|
+
y1: "6",
|
|
1437
|
+
x2: "6",
|
|
1438
|
+
y2: "18"
|
|
1439
|
+
}), /*#__PURE__*/jsxRuntime.jsx("line", {
|
|
1440
|
+
x1: "6",
|
|
1441
|
+
y1: "6",
|
|
1442
|
+
x2: "18",
|
|
1443
|
+
y2: "18"
|
|
1444
|
+
})]
|
|
1445
|
+
})
|
|
1446
|
+
})]
|
|
1447
|
+
}), featureGroups.length > 1 && currentFeatureGroupIndex !== undefined && /*#__PURE__*/jsxRuntime.jsx(ProgressBar, {
|
|
1448
|
+
currentStep: currentFeatureGroupIndex + 1,
|
|
1449
|
+
totalSteps: featureGroups.length
|
|
1450
|
+
})]
|
|
1451
|
+
});
|
|
1452
|
+
};
|
|
1453
|
+
|
|
1454
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
1455
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
1456
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
1457
|
+
function calculateVariantValue(selections, config) {
|
|
1458
|
+
if (!config) {
|
|
1459
|
+
return {};
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
// 1. Prepare variables for rule evaluation
|
|
1463
|
+
var variables = {};
|
|
1464
|
+
|
|
1465
|
+
// Extract values from selections based on config.features
|
|
1466
|
+
var _loop = function _loop() {
|
|
1467
|
+
var _Object$entries$_i = _slicedToArray__default["default"](_Object$entries[_i], 2),
|
|
1468
|
+
featureKey = _Object$entries$_i[0],
|
|
1469
|
+
featureConfig = _Object$entries$_i[1];
|
|
1470
|
+
var selection = selections.find(function (s) {
|
|
1471
|
+
return s.featureCodex === featureConfig.featureCodex;
|
|
1472
|
+
});
|
|
1473
|
+
if (selection && selection.selectedOptions.length > 0) {
|
|
1474
|
+
// Use the first selected option
|
|
1475
|
+
var selectedOptionCodex = selection.selectedOptions[0];
|
|
1476
|
+
var optionConfig = featureConfig.options[selectedOptionCodex];
|
|
1477
|
+
if (optionConfig) {
|
|
1478
|
+
variables[featureKey] = parseFloat(optionConfig.value) || 0;
|
|
1479
|
+
} else {
|
|
1480
|
+
// Handle range strings like "150-160" -> 160
|
|
1481
|
+
if (selectedOptionCodex.includes('-')) {
|
|
1482
|
+
var parts = selectedOptionCodex.split('-');
|
|
1483
|
+
var lastPart = parts[parts.length - 1];
|
|
1484
|
+
variables[featureKey] = parseFloat(lastPart) || 0;
|
|
1485
|
+
} else {
|
|
1486
|
+
variables[featureKey] = parseFloat(selectedOptionCodex) || 0;
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
} else {
|
|
1490
|
+
variables[featureKey] = 0;
|
|
1491
|
+
}
|
|
1492
|
+
};
|
|
1493
|
+
for (var _i = 0, _Object$entries = Object.entries(config.features); _i < _Object$entries.length; _i++) {
|
|
1494
|
+
_loop();
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
// 2. Evaluate results
|
|
1498
|
+
var calculatedResults = {};
|
|
1499
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(config.results); _i2 < _Object$entries2.length; _i2++) {
|
|
1500
|
+
var _Object$entries2$_i = _slicedToArray__default["default"](_Object$entries2[_i2], 2),
|
|
1501
|
+
resultKey = _Object$entries2$_i[0],
|
|
1502
|
+
resultConfig = _Object$entries2$_i[1];
|
|
1503
|
+
var numericValue = evaluateRule(resultConfig.rule, variables);
|
|
1504
|
+
calculatedResults[resultKey] = getResultValue(resultKey, numericValue, resultConfig.valueResultPairs);
|
|
1505
|
+
}
|
|
1506
|
+
return calculatedResults;
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
/**
|
|
1510
|
+
* Helper to evaluate a mathematical rule with given variables
|
|
1511
|
+
*/
|
|
1512
|
+
function evaluateRule(rule, variables) {
|
|
1513
|
+
var expression = rule;
|
|
1514
|
+
|
|
1515
|
+
// Sort keys by length descending to avoid partial replacements
|
|
1516
|
+
var sortedKeys = Object.keys(variables).sort(function (a, b) {
|
|
1517
|
+
return b.length - a.length;
|
|
1518
|
+
});
|
|
1519
|
+
var _iterator = _createForOfIteratorHelper(sortedKeys),
|
|
1520
|
+
_step;
|
|
1521
|
+
try {
|
|
1522
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1523
|
+
var key = _step.value;
|
|
1524
|
+
var value = variables[key];
|
|
1525
|
+
var regex = new RegExp("\\b".concat(key, "\\b"), 'g');
|
|
1526
|
+
expression = expression.replace(regex, value.toString());
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
// Safety check: only allow numbers, operators, parentheses and spaces
|
|
1530
|
+
} catch (err) {
|
|
1531
|
+
_iterator.e(err);
|
|
1532
|
+
} finally {
|
|
1533
|
+
_iterator.f();
|
|
1534
|
+
}
|
|
1535
|
+
var sanitizedExpression = expression.replace(/[0-9.+\-*/() ]/g, '');
|
|
1536
|
+
if (sanitizedExpression.length > 0) {
|
|
1537
|
+
return 0;
|
|
1538
|
+
}
|
|
1539
|
+
try {
|
|
1540
|
+
// eslint-disable-next-line no-new-func
|
|
1541
|
+
return new Function("return ".concat(expression))();
|
|
1542
|
+
} catch (e) {
|
|
1543
|
+
return 0;
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
/**
|
|
1548
|
+
* Helper to map a numeric value to a result string based on ranges
|
|
1549
|
+
*/
|
|
1550
|
+
function getResultValue(resultKey, value, pairs) {
|
|
1551
|
+
console.log('resultKey', resultKey, value, pairs);
|
|
1552
|
+
var _iterator2 = _createForOfIteratorHelper(pairs),
|
|
1553
|
+
_step2;
|
|
1554
|
+
try {
|
|
1555
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1556
|
+
var _step2$value = _slicedToArray__default["default"](_step2.value, 2),
|
|
1557
|
+
range = _step2$value[0],
|
|
1558
|
+
result = _step2$value[1];
|
|
1559
|
+
var parts = range.split('-');
|
|
1560
|
+
var min = parseFloat(parts[0]);
|
|
1561
|
+
var max = parseFloat(parts[1]);
|
|
1562
|
+
if (!isNaN(min) && !isNaN(max)) {
|
|
1563
|
+
if (value >= min && value <= max) {
|
|
1564
|
+
return {
|
|
1565
|
+
result: result,
|
|
1566
|
+
value: value
|
|
1567
|
+
};
|
|
1568
|
+
}
|
|
1569
|
+
} else if (!isNaN(min)) {
|
|
1570
|
+
if (value === min) return {
|
|
1571
|
+
result: result,
|
|
1572
|
+
value: value
|
|
1573
|
+
};
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
// Fallback: use first result if none match
|
|
1578
|
+
} catch (err) {
|
|
1579
|
+
_iterator2.e(err);
|
|
1580
|
+
} finally {
|
|
1581
|
+
_iterator2.f();
|
|
1582
|
+
}
|
|
1583
|
+
return pairs.length > 0 ? {
|
|
1584
|
+
result: pairs[0][1],
|
|
1585
|
+
value: value
|
|
1586
|
+
} : {
|
|
1587
|
+
result: '',
|
|
1588
|
+
value: value
|
|
1589
|
+
};
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1593
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty__default["default"](e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1594
|
+
var useQuickConfigCalculations = function useQuickConfigCalculations(config) {
|
|
1595
|
+
var calculateInstanceResult = react.useCallback(function (currentSelections) {
|
|
1596
|
+
if (!config.calculator) {
|
|
1597
|
+
return {};
|
|
1598
|
+
}
|
|
1599
|
+
if (config.calculator.variantValueConfig) {
|
|
1600
|
+
return calculateVariantValue(currentSelections, config.calculator.variantValueConfig);
|
|
1601
|
+
}
|
|
1602
|
+
return {};
|
|
1603
|
+
}, [config.calculator]);
|
|
1604
|
+
var calculateFullResult = react.useCallback(function (allInstanceSelections) {
|
|
1605
|
+
if (!config.instances || config.instances.length === 0) {
|
|
1606
|
+
var defaultSelections = allInstanceSelections['default'] || [];
|
|
1607
|
+
var res = calculateInstanceResult(defaultSelections);
|
|
1608
|
+
return _objectSpread$1(_objectSpread$1({}, res), {}, {
|
|
1609
|
+
input: {
|
|
1610
|
+
selections: defaultSelections
|
|
1611
|
+
}
|
|
1612
|
+
});
|
|
1613
|
+
}
|
|
1614
|
+
var instanceResults = {};
|
|
1615
|
+
config.instances.forEach(function (instance) {
|
|
1616
|
+
instanceResults[instance.id] = calculateInstanceResult(allInstanceSelections[instance.id] || []);
|
|
1617
|
+
});
|
|
1618
|
+
return {
|
|
1619
|
+
instanceResults: instanceResults,
|
|
1620
|
+
input: {
|
|
1621
|
+
selections: allInstanceSelections[config.instances[0].id] || [],
|
|
1622
|
+
// Backward compatibility
|
|
1623
|
+
instanceSelections: allInstanceSelections
|
|
1624
|
+
}
|
|
1625
|
+
};
|
|
1626
|
+
}, [config.instances, calculateInstanceResult]);
|
|
1627
|
+
return {
|
|
1628
|
+
calculateFullResult: calculateFullResult
|
|
1629
|
+
};
|
|
1630
|
+
};
|
|
1631
|
+
|
|
1632
|
+
var useQuickConfigFeatures = function useQuickConfigFeatures(config, selections, currentFeatureGroupIndex, result) {
|
|
1633
|
+
// Group features by group field
|
|
1634
|
+
var featureGroups = react.useMemo(function () {
|
|
1635
|
+
var groups = [];
|
|
1636
|
+
var groupMap = new Map();
|
|
1637
|
+
config.features.forEach(function (feature) {
|
|
1638
|
+
var groupKey = feature.group;
|
|
1639
|
+
if (!groupMap.has(groupKey)) {
|
|
1640
|
+
groupMap.set(groupKey, []);
|
|
1641
|
+
}
|
|
1642
|
+
groupMap.get(groupKey).push(feature);
|
|
1643
|
+
});
|
|
1644
|
+
|
|
1645
|
+
// Flatten groups in order they appear
|
|
1646
|
+
var seenGroups = new Set();
|
|
1647
|
+
config.features.forEach(function (feature) {
|
|
1648
|
+
var groupKey = feature.group;
|
|
1649
|
+
if (!seenGroups.has(groupKey)) {
|
|
1650
|
+
seenGroups.add(groupKey);
|
|
1651
|
+
groups.push(groupMap.get(groupKey));
|
|
1652
|
+
}
|
|
1653
|
+
});
|
|
1654
|
+
return groups;
|
|
1655
|
+
}, [config.features]);
|
|
1656
|
+
|
|
1657
|
+
// Get visible features in current group
|
|
1658
|
+
var currentFeatures = react.useMemo(function () {
|
|
1659
|
+
if (result) return [];
|
|
1660
|
+
var group = featureGroups[currentFeatureGroupIndex] || [];
|
|
1661
|
+
return group.filter(function (feature) {
|
|
1662
|
+
return ConditionEvaluator.shouldShowFeature(feature, selections);
|
|
1663
|
+
});
|
|
1664
|
+
}, [featureGroups, currentFeatureGroupIndex, selections, result]);
|
|
1665
|
+
return {
|
|
1666
|
+
featureGroups: featureGroups,
|
|
1667
|
+
currentFeatures: currentFeatures
|
|
1668
|
+
};
|
|
1669
|
+
};
|
|
1670
|
+
|
|
1671
|
+
var STORAGE_PREFIX = 'quickconfig.';
|
|
1672
|
+
var TTL_MS = 24 * 60 * 60 * 1000; // 1 day
|
|
1673
|
+
|
|
1674
|
+
function loadFromStorage(storageKey) {
|
|
1675
|
+
try {
|
|
1676
|
+
var raw = localStorage.getItem(storageKey);
|
|
1677
|
+
if (!raw) return null;
|
|
1678
|
+
var parsed = JSON.parse(raw);
|
|
1679
|
+
if (_typeof__default["default"](parsed) !== 'object' || parsed === null) return null;
|
|
1680
|
+
|
|
1681
|
+
// Legacy format: plain selections object (no TTL)
|
|
1682
|
+
if (!('storedAt' in parsed) || !('selections' in parsed)) {
|
|
1683
|
+
var legacy = parsed;
|
|
1684
|
+
return _typeof__default["default"](legacy) === 'object' && legacy !== null && !Array.isArray(legacy) ? legacy : null;
|
|
1685
|
+
}
|
|
1686
|
+
var _ref = parsed,
|
|
1687
|
+
selections = _ref.selections,
|
|
1688
|
+
storedAt = _ref.storedAt;
|
|
1689
|
+
if (typeof storedAt !== 'number' || !selections || _typeof__default["default"](selections) !== 'object' || Array.isArray(selections)) return null;
|
|
1690
|
+
if (Date.now() - storedAt > TTL_MS) {
|
|
1691
|
+
localStorage.removeItem(storageKey);
|
|
1692
|
+
return null;
|
|
1693
|
+
}
|
|
1694
|
+
return selections;
|
|
1695
|
+
} catch (_unused) {
|
|
1696
|
+
return null;
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
function useQuickConfigStorage(configId) {
|
|
1700
|
+
var storageKey = react.useMemo(function () {
|
|
1701
|
+
return configId ? "".concat(STORAGE_PREFIX).concat(configId) : '';
|
|
1702
|
+
}, [configId]);
|
|
1703
|
+
var storedSelections = react.useMemo(function () {
|
|
1704
|
+
return storageKey ? loadFromStorage(storageKey) : null;
|
|
1705
|
+
}, [storageKey]);
|
|
1706
|
+
var persistSelections = react.useCallback(function (selections) {
|
|
1707
|
+
if (!storageKey) return;
|
|
1708
|
+
try {
|
|
1709
|
+
var data = {
|
|
1710
|
+
selections: selections,
|
|
1711
|
+
storedAt: Date.now()
|
|
1712
|
+
};
|
|
1713
|
+
localStorage.setItem(storageKey, JSON.stringify(data));
|
|
1714
|
+
} catch (_unused2) {
|
|
1715
|
+
// Ignore quota exceeded or other storage errors
|
|
1716
|
+
}
|
|
1717
|
+
}, [storageKey]);
|
|
1718
|
+
return {
|
|
1719
|
+
storedSelections: storedSelections,
|
|
1720
|
+
persistSelections: persistSelections
|
|
1721
|
+
};
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1725
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default["default"](e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1726
|
+
var useQuickConfig = function useQuickConfig(_ref) {
|
|
1727
|
+
var config = _ref.config,
|
|
1728
|
+
onEvent = _ref.onEvent,
|
|
1729
|
+
initialContext = _ref.initialContext;
|
|
1730
|
+
var storageKey = config.id || config.codex;
|
|
1731
|
+
var _useQuickConfigStorag = useQuickConfigStorage(storageKey),
|
|
1732
|
+
storedSelections = _useQuickConfigStorag.storedSelections,
|
|
1733
|
+
persistSelections = _useQuickConfigStorag.persistSelections;
|
|
1734
|
+
var filteredInstances = react.useMemo(function () {
|
|
1735
|
+
if (!config.instances) return [];
|
|
1736
|
+
return config.instances.filter(function (instance) {
|
|
1737
|
+
return ConditionEvaluator.shouldShowInstance(instance, initialContext || []);
|
|
1738
|
+
});
|
|
1739
|
+
}, [config.instances, initialContext]);
|
|
1740
|
+
var getInitialSelections = react.useCallback(function () {
|
|
1741
|
+
// Prefer stored selections when reopening (user's previous choices persist across closes)
|
|
1742
|
+
if (storedSelections && Object.keys(storedSelections).length > 0) {
|
|
1743
|
+
return storedSelections;
|
|
1744
|
+
}
|
|
1745
|
+
// Fall back to initialContext when no stored data (e.g. pre-fill from product/basket)
|
|
1746
|
+
if (initialContext !== undefined) {
|
|
1747
|
+
return {
|
|
1748
|
+
"default": initialContext
|
|
1749
|
+
};
|
|
1750
|
+
}
|
|
1751
|
+
return {
|
|
1752
|
+
"default": []
|
|
1753
|
+
};
|
|
1754
|
+
}, [initialContext, storedSelections]);
|
|
1755
|
+
var _useState = react.useState(getInitialSelections),
|
|
1756
|
+
_useState2 = _slicedToArray__default["default"](_useState, 2),
|
|
1757
|
+
instanceSelections = _useState2[0],
|
|
1758
|
+
setInstanceSelections = _useState2[1];
|
|
1759
|
+
var prevStorageKeyRef = react.useRef(storageKey);
|
|
1760
|
+
react.useEffect(function () {
|
|
1761
|
+
if (prevStorageKeyRef.current !== storageKey) {
|
|
1762
|
+
prevStorageKeyRef.current = storageKey;
|
|
1763
|
+
setInstanceSelections(getInitialSelections());
|
|
1764
|
+
}
|
|
1765
|
+
}, [storageKey, getInitialSelections]);
|
|
1766
|
+
react.useEffect(function () {
|
|
1767
|
+
persistSelections(instanceSelections);
|
|
1768
|
+
}, [instanceSelections, persistSelections]);
|
|
1769
|
+
var _useState3 = react.useState(filteredInstances.length > 0 ? filteredInstances[0].id : 'default'),
|
|
1770
|
+
_useState4 = _slicedToArray__default["default"](_useState3, 2),
|
|
1771
|
+
activeInstanceId = _useState4[0],
|
|
1772
|
+
setActiveInstanceId = _useState4[1];
|
|
1773
|
+
var _useState5 = react.useState(0),
|
|
1774
|
+
_useState6 = _slicedToArray__default["default"](_useState5, 2),
|
|
1775
|
+
currentFeatureGroupIndex = _useState6[0],
|
|
1776
|
+
setCurrentFeatureGroupIndex = _useState6[1];
|
|
1777
|
+
var _useState7 = react.useState(null),
|
|
1778
|
+
_useState8 = _slicedToArray__default["default"](_useState7, 2),
|
|
1779
|
+
result = _useState8[0],
|
|
1780
|
+
setResult = _useState8[1];
|
|
1781
|
+
var _useState9 = react.useState(!!config.introText),
|
|
1782
|
+
_useState10 = _slicedToArray__default["default"](_useState9, 2),
|
|
1783
|
+
showIntro = _useState10[0],
|
|
1784
|
+
setShowIntro = _useState10[1];
|
|
1785
|
+
react.useEffect(function () {
|
|
1786
|
+
if (result && filteredInstances.length > 0) {
|
|
1787
|
+
setActiveInstanceId(filteredInstances[0].id);
|
|
1788
|
+
}
|
|
1789
|
+
}, [result, filteredInstances]);
|
|
1790
|
+
var selections = react.useMemo(function () {
|
|
1791
|
+
return instanceSelections[activeInstanceId] || [];
|
|
1792
|
+
}, [instanceSelections, activeInstanceId]);
|
|
1793
|
+
var _useQuickConfigCalcul = useQuickConfigCalculations(config),
|
|
1794
|
+
calculateFullResult = _useQuickConfigCalcul.calculateFullResult;
|
|
1795
|
+
var _useQuickConfigFeatur = useQuickConfigFeatures(config, selections, currentFeatureGroupIndex, result),
|
|
1796
|
+
featureGroups = _useQuickConfigFeatur.featureGroups,
|
|
1797
|
+
currentFeatures = _useQuickConfigFeatur.currentFeatures;
|
|
1798
|
+
var handleFeatureSelect = react.useCallback(function (featureCodex, selectedOptions) {
|
|
1799
|
+
setInstanceSelections(function (prev) {
|
|
1800
|
+
var currentSelections = prev[activeInstanceId] || [];
|
|
1801
|
+
var existing = currentSelections.find(function (s) {
|
|
1802
|
+
return s.featureCodex === featureCodex;
|
|
1803
|
+
});
|
|
1804
|
+
var updatedSelections = existing ? currentSelections.map(function (s) {
|
|
1805
|
+
return s.featureCodex === featureCodex ? _objectSpread(_objectSpread({}, s), {}, {
|
|
1806
|
+
selectedOptions: selectedOptions
|
|
1807
|
+
}) : s;
|
|
1808
|
+
}) : [].concat(_toConsumableArray__default["default"](currentSelections), [{
|
|
1809
|
+
featureCodex: featureCodex,
|
|
1810
|
+
selectedOptions: selectedOptions
|
|
1811
|
+
}]);
|
|
1812
|
+
var updated = _objectSpread(_objectSpread({}, prev), {}, _defineProperty__default["default"]({}, activeInstanceId, updatedSelections));
|
|
1813
|
+
|
|
1814
|
+
// Auto-advance logic
|
|
1815
|
+
var currentFeature = currentFeatures.find(function (f) {
|
|
1816
|
+
return f.codex === featureCodex;
|
|
1817
|
+
});
|
|
1818
|
+
if (currentFeatures.length === 1 && !(currentFeature !== null && currentFeature !== void 0 && currentFeature.multiSelect) && selectedOptions.length > 0) {
|
|
1819
|
+
var isLastGroup = currentFeatureGroupIndex === featureGroups.length - 1;
|
|
1820
|
+
var isLastInstance = filteredInstances.length === 0 || activeInstanceId === filteredInstances[filteredInstances.length - 1].id;
|
|
1821
|
+
if (!isLastGroup || !isLastInstance) {
|
|
1822
|
+
setTimeout(function () {
|
|
1823
|
+
if (currentFeatureGroupIndex < featureGroups.length - 1) {
|
|
1824
|
+
setCurrentFeatureGroupIndex(function (prevIdx) {
|
|
1825
|
+
return prevIdx + 1;
|
|
1826
|
+
});
|
|
1827
|
+
}
|
|
1828
|
+
}, 100);
|
|
1829
|
+
} else if (isLastGroup && isLastInstance) {
|
|
1830
|
+
setTimeout(function () {
|
|
1831
|
+
var fullResult = calculateFullResult(updated);
|
|
1832
|
+
setResult(fullResult);
|
|
1833
|
+
onEvent === null || onEvent === void 0 || onEvent({
|
|
1834
|
+
type: 'complete',
|
|
1835
|
+
payload: fullResult
|
|
1836
|
+
});
|
|
1837
|
+
}, 100);
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
return updated;
|
|
1841
|
+
});
|
|
1842
|
+
}, [activeInstanceId, currentFeatures, currentFeatureGroupIndex, featureGroups.length, filteredInstances, calculateFullResult, onEvent]);
|
|
1843
|
+
var handleNext = react.useCallback(function () {
|
|
1844
|
+
var _filteredInstances$fi;
|
|
1845
|
+
var isLastGroup = currentFeatureGroupIndex === featureGroups.length - 1;
|
|
1846
|
+
var instanceIndex = (_filteredInstances$fi = filteredInstances.findIndex(function (i) {
|
|
1847
|
+
return i.id === activeInstanceId;
|
|
1848
|
+
})) !== null && _filteredInstances$fi !== void 0 ? _filteredInstances$fi : -1;
|
|
1849
|
+
var isLastInstance = filteredInstances.length === 0 || instanceIndex === filteredInstances.length - 1;
|
|
1850
|
+
if (!isLastGroup) {
|
|
1851
|
+
setCurrentFeatureGroupIndex(function (prev) {
|
|
1852
|
+
return prev + 1;
|
|
1853
|
+
});
|
|
1854
|
+
} else if (!isLastInstance) {
|
|
1855
|
+
setActiveInstanceId(filteredInstances[instanceIndex + 1].id);
|
|
1856
|
+
setCurrentFeatureGroupIndex(0);
|
|
1857
|
+
} else {
|
|
1858
|
+
var fullResult = calculateFullResult(instanceSelections);
|
|
1859
|
+
setResult(fullResult);
|
|
1860
|
+
onEvent === null || onEvent === void 0 || onEvent({
|
|
1861
|
+
type: 'complete',
|
|
1862
|
+
payload: fullResult
|
|
1863
|
+
});
|
|
1864
|
+
}
|
|
1865
|
+
}, [currentFeatureGroupIndex, featureGroups.length, filteredInstances, activeInstanceId, instanceSelections, calculateFullResult, onEvent]);
|
|
1866
|
+
var handleBack = react.useCallback(function () {
|
|
1867
|
+
var _filteredInstances$fi2;
|
|
1868
|
+
var instanceIndex = (_filteredInstances$fi2 = filteredInstances.findIndex(function (i) {
|
|
1869
|
+
return i.id === activeInstanceId;
|
|
1870
|
+
})) !== null && _filteredInstances$fi2 !== void 0 ? _filteredInstances$fi2 : -1;
|
|
1871
|
+
if (currentFeatureGroupIndex > 0) {
|
|
1872
|
+
setCurrentFeatureGroupIndex(function (prev) {
|
|
1873
|
+
return prev - 1;
|
|
1874
|
+
});
|
|
1875
|
+
} else if (instanceIndex > 0) {
|
|
1876
|
+
setActiveInstanceId(filteredInstances[instanceIndex - 1].id);
|
|
1877
|
+
setCurrentFeatureGroupIndex(featureGroups.length - 1);
|
|
1878
|
+
} else if (config.introText) {
|
|
1879
|
+
setShowIntro(true);
|
|
1880
|
+
}
|
|
1881
|
+
}, [currentFeatureGroupIndex, filteredInstances, activeInstanceId, featureGroups.length, config.introText]);
|
|
1882
|
+
var handleIntroNext = react.useCallback(function () {
|
|
1883
|
+
return setShowIntro(false);
|
|
1884
|
+
}, []);
|
|
1885
|
+
var handleRetry = react.useCallback(function () {
|
|
1886
|
+
setActiveInstanceId(filteredInstances.length > 0 ? filteredInstances[0].id : 'default');
|
|
1887
|
+
setCurrentFeatureGroupIndex(0);
|
|
1888
|
+
setResult(null);
|
|
1889
|
+
}, [filteredInstances]);
|
|
1890
|
+
var handleSwitchInstance = react.useCallback(function (instanceId) {
|
|
1891
|
+
setActiveInstanceId(instanceId);
|
|
1892
|
+
setCurrentFeatureGroupIndex(0);
|
|
1893
|
+
}, []);
|
|
1894
|
+
var handleCopySelections = react.useCallback(function (fromId, toId) {
|
|
1895
|
+
var selectionsToCopy = instanceSelections[fromId] || [];
|
|
1896
|
+
var updatedSelections = _objectSpread({}, instanceSelections);
|
|
1897
|
+
var fromIndex = filteredInstances.findIndex(function (i) {
|
|
1898
|
+
return i.id === fromId;
|
|
1899
|
+
});
|
|
1900
|
+
if (fromIndex !== -1) {
|
|
1901
|
+
for (var i = fromIndex + 1; i < filteredInstances.length; i++) {
|
|
1902
|
+
updatedSelections[filteredInstances[i].id] = _toConsumableArray__default["default"](selectionsToCopy);
|
|
1903
|
+
}
|
|
1904
|
+
} else {
|
|
1905
|
+
updatedSelections[toId] = _toConsumableArray__default["default"](selectionsToCopy);
|
|
1906
|
+
}
|
|
1907
|
+
setInstanceSelections(updatedSelections);
|
|
1908
|
+
var fullResult = calculateFullResult(updatedSelections);
|
|
1909
|
+
setResult(fullResult);
|
|
1910
|
+
onEvent === null || onEvent === void 0 || onEvent({
|
|
1911
|
+
type: 'complete',
|
|
1912
|
+
payload: fullResult
|
|
1913
|
+
});
|
|
1914
|
+
}, [instanceSelections, filteredInstances, calculateFullResult, onEvent]);
|
|
1915
|
+
var canProceed = react.useMemo(function () {
|
|
1916
|
+
return currentFeatures.every(function (feature) {
|
|
1917
|
+
if (!feature.required) return true;
|
|
1918
|
+
var selection = selections.find(function (s) {
|
|
1919
|
+
return s.featureCodex === feature.codex;
|
|
1920
|
+
});
|
|
1921
|
+
return selection && selection.selectedOptions.length > 0;
|
|
1922
|
+
});
|
|
1923
|
+
}, [currentFeatures, selections]);
|
|
1924
|
+
return {
|
|
1925
|
+
selections: selections,
|
|
1926
|
+
instanceSelections: instanceSelections,
|
|
1927
|
+
activeInstanceId: activeInstanceId,
|
|
1928
|
+
currentFeatureGroupIndex: currentFeatureGroupIndex,
|
|
1929
|
+
result: result,
|
|
1930
|
+
showIntro: showIntro,
|
|
1931
|
+
featureGroups: featureGroups,
|
|
1932
|
+
currentFeatures: currentFeatures,
|
|
1933
|
+
canProceed: canProceed,
|
|
1934
|
+
handleFeatureSelect: handleFeatureSelect,
|
|
1935
|
+
handleNext: handleNext,
|
|
1936
|
+
handleBack: handleBack,
|
|
1937
|
+
handleIntroNext: handleIntroNext,
|
|
1938
|
+
handleRetry: handleRetry,
|
|
1939
|
+
handleSwitchInstance: handleSwitchInstance,
|
|
1940
|
+
handleCopySelections: handleCopySelections,
|
|
1941
|
+
setResult: setResult,
|
|
1942
|
+
filteredInstances: filteredInstances
|
|
1943
|
+
};
|
|
1944
|
+
};
|
|
1945
|
+
|
|
1946
|
+
function getLocalizedText(texts, language) {
|
|
1947
|
+
if (!texts) return '';
|
|
1948
|
+
return texts[language] || texts.en || texts.de || '';
|
|
1949
|
+
}
|
|
1950
|
+
var QuickConfig = function QuickConfig(_ref) {
|
|
1951
|
+
var config = _ref.config,
|
|
1952
|
+
onEvent = _ref.onEvent,
|
|
1953
|
+
initialContext = _ref.initialContext,
|
|
1954
|
+
renderContentItem = _ref.renderContentItem;
|
|
1955
|
+
var _useTranslation = divaCore.useTranslation(),
|
|
1956
|
+
t = _useTranslation.t,
|
|
1957
|
+
i18n = _useTranslation.i18n;
|
|
1958
|
+
var language = i18n.language;
|
|
1959
|
+
var containerRef = react.useRef(null);
|
|
1960
|
+
var handleCancel = onEvent ? function () {
|
|
1961
|
+
return onEvent({
|
|
1962
|
+
type: 'onCancel'
|
|
1963
|
+
});
|
|
1964
|
+
} : undefined;
|
|
1965
|
+
var _useQuickConfig = useQuickConfig({
|
|
1966
|
+
config: config,
|
|
1967
|
+
onEvent: onEvent,
|
|
1968
|
+
initialContext: initialContext
|
|
1969
|
+
}),
|
|
1970
|
+
selections = _useQuickConfig.selections,
|
|
1971
|
+
activeInstanceId = _useQuickConfig.activeInstanceId,
|
|
1972
|
+
currentFeatureGroupIndex = _useQuickConfig.currentFeatureGroupIndex,
|
|
1973
|
+
result = _useQuickConfig.result,
|
|
1974
|
+
showIntro = _useQuickConfig.showIntro,
|
|
1975
|
+
featureGroups = _useQuickConfig.featureGroups,
|
|
1976
|
+
currentFeatures = _useQuickConfig.currentFeatures,
|
|
1977
|
+
canProceed = _useQuickConfig.canProceed,
|
|
1978
|
+
handleFeatureSelect = _useQuickConfig.handleFeatureSelect,
|
|
1979
|
+
handleNext = _useQuickConfig.handleNext,
|
|
1980
|
+
handleBack = _useQuickConfig.handleBack,
|
|
1981
|
+
handleIntroNext = _useQuickConfig.handleIntroNext,
|
|
1982
|
+
handleRetry = _useQuickConfig.handleRetry,
|
|
1983
|
+
handleSwitchInstance = _useQuickConfig.handleSwitchInstance,
|
|
1984
|
+
handleCopySelections = _useQuickConfig.handleCopySelections,
|
|
1985
|
+
filteredInstances = _useQuickConfig.filteredInstances;
|
|
1986
|
+
react.useEffect(function () {
|
|
1987
|
+
var _containerRef$current;
|
|
1988
|
+
(_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 || _containerRef$current.scrollTo({
|
|
1989
|
+
top: 0
|
|
1990
|
+
});
|
|
1991
|
+
}, [currentFeatureGroupIndex, activeInstanceId, showIntro, result]);
|
|
1992
|
+
if (showIntro && config.introText) {
|
|
1993
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1994
|
+
className: container,
|
|
1995
|
+
ref: containerRef,
|
|
1996
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Header, {
|
|
1997
|
+
onCancel: handleCancel,
|
|
1998
|
+
featureGroups: featureGroups,
|
|
1999
|
+
currentFeatureGroupIndex: currentFeatureGroupIndex
|
|
2000
|
+
}), getLocalizedText(config.configDescription, language) && /*#__PURE__*/jsxRuntime.jsx("p", {
|
|
2001
|
+
className: configDescription,
|
|
2002
|
+
dangerouslySetInnerHTML: {
|
|
2003
|
+
__html: getLocalizedText(config.configDescription, language)
|
|
2004
|
+
}
|
|
2005
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2006
|
+
className: subContainer,
|
|
2007
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("h2", {
|
|
2008
|
+
dangerouslySetInnerHTML: {
|
|
2009
|
+
__html: getLocalizedText(config.name, language)
|
|
2010
|
+
}
|
|
2011
|
+
}), /*#__PURE__*/jsxRuntime.jsx("p", {
|
|
2012
|
+
dangerouslySetInnerHTML: {
|
|
2013
|
+
__html: getLocalizedText(config.introText, language)
|
|
2014
|
+
}
|
|
2015
|
+
})]
|
|
2016
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Navigation, {
|
|
2017
|
+
onNext: handleIntroNext,
|
|
2018
|
+
canProceed: true,
|
|
2019
|
+
showBack: false,
|
|
2020
|
+
nextLabel: t('quickconfig.next', {
|
|
2021
|
+
defaultValue: 'Weiter'
|
|
2022
|
+
})
|
|
2023
|
+
})]
|
|
2024
|
+
});
|
|
2025
|
+
}
|
|
2026
|
+
if (result) {
|
|
2027
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2028
|
+
className: container,
|
|
2029
|
+
ref: containerRef,
|
|
2030
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Header, {
|
|
2031
|
+
instances: filteredInstances,
|
|
2032
|
+
activeInstanceId: activeInstanceId,
|
|
2033
|
+
onSwitchInstance: handleSwitchInstance,
|
|
2034
|
+
onCancel: handleCancel,
|
|
2035
|
+
featureGroups: featureGroups,
|
|
2036
|
+
currentFeatureGroupIndex: currentFeatureGroupIndex
|
|
2037
|
+
}), getLocalizedText(config.resultDescription, language) && /*#__PURE__*/jsxRuntime.jsx("p", {
|
|
2038
|
+
className: resultDescription,
|
|
2039
|
+
dangerouslySetInnerHTML: {
|
|
2040
|
+
__html: getLocalizedText(config.resultDescription, language)
|
|
2041
|
+
}
|
|
2042
|
+
}), /*#__PURE__*/jsxRuntime.jsx(ResultDisplay, {
|
|
2043
|
+
activeInstanceId: activeInstanceId,
|
|
2044
|
+
result: result,
|
|
2045
|
+
config: config,
|
|
2046
|
+
onRetry: handleRetry,
|
|
2047
|
+
filteredInstances: filteredInstances,
|
|
2048
|
+
onEvent: onEvent,
|
|
2049
|
+
renderContentItem: renderContentItem
|
|
2050
|
+
})]
|
|
2051
|
+
});
|
|
2052
|
+
}
|
|
2053
|
+
var currentInstanceIndex = filteredInstances.findIndex(function (i) {
|
|
2054
|
+
return i.id === activeInstanceId;
|
|
2055
|
+
});
|
|
2056
|
+
var hasNextInstance = filteredInstances.length > 1 && currentInstanceIndex < filteredInstances.length - 1;
|
|
2057
|
+
var isLastStep = currentFeatureGroupIndex >= featureGroups.length - 1 && !hasNextInstance;
|
|
2058
|
+
var nextLabel = isLastStep ? t('quickconfig.calculate', {
|
|
2059
|
+
defaultValue: 'Berechnen'
|
|
2060
|
+
}) : t('quickconfig.next', {
|
|
2061
|
+
defaultValue: 'Weiter'
|
|
2062
|
+
});
|
|
2063
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2064
|
+
className: container,
|
|
2065
|
+
ref: containerRef,
|
|
2066
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Header, {
|
|
2067
|
+
instances: filteredInstances,
|
|
2068
|
+
activeInstanceId: activeInstanceId,
|
|
2069
|
+
onSwitchInstance: handleSwitchInstance,
|
|
2070
|
+
onCancel: handleCancel,
|
|
2071
|
+
featureGroups: featureGroups,
|
|
2072
|
+
currentFeatureGroupIndex: currentFeatureGroupIndex
|
|
2073
|
+
}), getLocalizedText(config.configDescription, language) && /*#__PURE__*/jsxRuntime.jsx("p", {
|
|
2074
|
+
className: configDescription,
|
|
2075
|
+
dangerouslySetInnerHTML: {
|
|
2076
|
+
__html: getLocalizedText(config.configDescription, language)
|
|
2077
|
+
}
|
|
2078
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2079
|
+
className: subContainer,
|
|
2080
|
+
children: currentFeatures.map(function (feature) {
|
|
2081
|
+
return /*#__PURE__*/jsxRuntime.jsx(FeatureRenderer, {
|
|
2082
|
+
feature: feature,
|
|
2083
|
+
selection: selections.find(function (s) {
|
|
2084
|
+
return s.featureCodex === feature.codex;
|
|
2085
|
+
}),
|
|
2086
|
+
onSelect: handleFeatureSelect,
|
|
2087
|
+
selections: selections
|
|
2088
|
+
}, feature.codex);
|
|
2089
|
+
})
|
|
2090
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Navigation, {
|
|
2091
|
+
onBack: handleBack,
|
|
2092
|
+
onNext: handleNext,
|
|
2093
|
+
onCopy: handleCopySelections,
|
|
2094
|
+
canProceed: canProceed,
|
|
2095
|
+
showBack: currentFeatureGroupIndex > 0,
|
|
2096
|
+
nextLabel: nextLabel,
|
|
2097
|
+
currentInstanceId: activeInstanceId,
|
|
2098
|
+
language: language,
|
|
2099
|
+
nextInstance: hasNextInstance ? filteredInstances[currentInstanceIndex + 1] : undefined
|
|
2100
|
+
}, currentFeatureGroupIndex)]
|
|
2101
|
+
});
|
|
2102
|
+
};
|
|
2103
|
+
|
|
2104
|
+
exports.ConditionEvaluator = ConditionEvaluator;
|
|
2105
|
+
exports.QuickConfig = QuickConfig;
|
|
2106
|
+
exports.getTranslatedText = getTranslatedText;
|
|
2107
|
+
exports.validateQuickConfig = validateQuickConfig;
|