@ebertjendustries/cswrapper 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +253 -267
  2. package/dist/index.mjs +253 -267
  3. package/package.json +37 -5
package/dist/index.js CHANGED
@@ -112,28 +112,29 @@ var import_components2 = require("@cloudscape-design/components");
112
112
 
113
113
  // src/types/CSFormProps.ts
114
114
  var FromPropsHelper = class {
115
- static getBasicProps = (props) => {
116
- const localisationObject = props.localiser.localiseField(props.fieldSpec.getLocalisationKey(), props.localisationVariables, props.alternateNs);
117
- const uniqueId = props.fieldSpec.getDataTestId();
118
- return { localisationObject, uniqueId };
119
- };
120
- static usesFormField = (props) => {
121
- const localisation = props.localiser.localiseField(props.fieldSpec.getLocalisationKey(), props.localisationVariables, props.alternateNs);
122
- return props.formField !== void 0 || localisation?.formField !== void 0;
123
- };
124
- static getLocalisedErrorText = (props, value, localiseValidity) => {
125
- if (props.formField?.errorText !== void 0) {
126
- return props.formField?.errorText;
127
- }
128
- const validityLevel = props.fieldSpec.getValueValidityLevel(value);
129
- return localiseValidity(props.fieldSpec, validityLevel);
130
- };
131
- static sanitizeValueToString = (value) => {
132
- if (value === null || value === void 0) {
133
- return "";
134
- }
135
- return value;
136
- };
115
+ };
116
+ FromPropsHelper.getBasicProps = (props) => {
117
+ const localisationObject = props.localiser.localiseField(props.fieldSpec.getLocalisationKey(), props.localisationVariables, props.alternateNs);
118
+ const uniqueId = props.fieldSpec.getDataTestId();
119
+ return { localisationObject, uniqueId };
120
+ };
121
+ FromPropsHelper.usesFormField = (props) => {
122
+ const localisation = props.localiser.localiseField(props.fieldSpec.getLocalisationKey(), props.localisationVariables, props.alternateNs);
123
+ return props.formField !== void 0 || (localisation == null ? void 0 : localisation.formField) !== void 0;
124
+ };
125
+ FromPropsHelper.getLocalisedErrorText = (props, value, localiseValidity) => {
126
+ var _a, _b;
127
+ if (((_a = props.formField) == null ? void 0 : _a.errorText) !== void 0) {
128
+ return (_b = props.formField) == null ? void 0 : _b.errorText;
129
+ }
130
+ const validityLevel = props.fieldSpec.getValueValidityLevel(value);
131
+ return localiseValidity(props.fieldSpec, validityLevel);
132
+ };
133
+ FromPropsHelper.sanitizeValueToString = (value) => {
134
+ if (value === null || value === void 0) {
135
+ return "";
136
+ }
137
+ return value;
137
138
  };
138
139
 
139
140
  // src/components/CSFormField.tsx
@@ -151,34 +152,35 @@ function CSFormField(props) {
151
152
  if (!FromPropsHelper.usesFormField(props)) {
152
153
  return props.children;
153
154
  }
154
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.FormField, { "data-testid": formFieldId, ...localisationObject?.formField, ...props.formField, children: props.children });
155
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.FormField, { "data-testid": formFieldId, ...localisationObject == null ? void 0 : localisationObject.formField, ...props.formField, children: props.children });
155
156
  }
156
157
 
157
158
  // src/components/ChildUtils.tsx
158
159
  var import_jsx_runtime2 = require("react/jsx-runtime");
159
160
  var ChildUtils = class {
160
- static getChildren = (props, localisationObject) => {
161
- const childrenRaw = props.children ?? localisationObject?.children;
162
- const children = props.childrenWrapper ? props.childrenWrapper(childrenRaw) : childrenRaw;
163
- let finalChildren = props.preventOverflow ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
164
- whiteSpace: "nowrap",
165
- overflow: "hidden",
166
- textOverflow: "ellipsis"
167
- }, children }) : children;
168
- let formFieldProps = props.formField ?? localisationObject?.formField;
169
- if (props.inlineLabel && FromPropsHelper.usesFormField(props)) {
170
- finalChildren = /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", flexWrap: "nowrap" }, children: [
171
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
172
- flex: "none",
173
- fontWeight: "bold",
174
- paddingRight: "5px"
175
- }, children: formFieldProps.label + ":" }),
176
- finalChildren
177
- ] });
178
- formFieldProps = { ...formFieldProps, label: void 0 };
179
- }
180
- return { children: finalChildren, formProps: { ...props, formField: formFieldProps } };
181
- };
161
+ };
162
+ ChildUtils.getChildren = (props, localisationObject) => {
163
+ var _a, _b;
164
+ const childrenRaw = (_a = props.children) != null ? _a : localisationObject == null ? void 0 : localisationObject.children;
165
+ const children = props.childrenWrapper ? props.childrenWrapper(childrenRaw) : childrenRaw;
166
+ let finalChildren = props.preventOverflow ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
167
+ whiteSpace: "nowrap",
168
+ overflow: "hidden",
169
+ textOverflow: "ellipsis"
170
+ }, children }) : children;
171
+ let formFieldProps = (_b = props.formField) != null ? _b : localisationObject == null ? void 0 : localisationObject.formField;
172
+ if (props.inlineLabel && FromPropsHelper.usesFormField(props)) {
173
+ finalChildren = /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", flexWrap: "nowrap" }, children: [
174
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
175
+ flex: "none",
176
+ fontWeight: "bold",
177
+ paddingRight: "5px"
178
+ }, children: formFieldProps.label + ":" }),
179
+ finalChildren
180
+ ] });
181
+ formFieldProps = { ...formFieldProps, label: void 0 };
182
+ }
183
+ return { children: finalChildren, formProps: { ...props, formField: formFieldProps } };
182
184
  };
183
185
 
184
186
  // src/components/CSAlert.tsx
@@ -276,6 +278,7 @@ function CSDatePicker(props) {
276
278
  var import_components7 = require("@cloudscape-design/components");
277
279
  var import_jsx_runtime8 = require("react/jsx-runtime");
278
280
  function CSMultiselect(props) {
281
+ var _a, _b;
279
282
  const { localisationObject, uniqueId } = FromPropsHelper.getBasicProps(props);
280
283
  const { formProps } = ChildUtils.getChildren(props, localisationObject);
281
284
  const adaptedOnChange = ({ detail }) => {
@@ -289,13 +292,13 @@ function CSMultiselect(props) {
289
292
  props.onChangeValue(props.fieldSpec.key, detail.selectedOptions.map((sel) => sel.value));
290
293
  }
291
294
  };
292
- const hideTokens = props.hideTokens ?? (props.tokenLimit !== void 0 && props.tokenLimit === 0);
295
+ const hideTokens = (_a = props.hideTokens) != null ? _a : props.tokenLimit !== void 0 && props.tokenLimit === 0;
293
296
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CSFormField, { ...formProps, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
294
297
  import_components7.Multiselect,
295
298
  {
296
299
  "data-testid": uniqueId,
297
300
  controlId: uniqueId,
298
- filteringType: props.filteringType ?? "auto",
301
+ filteringType: (_b = props.filteringType) != null ? _b : "auto",
299
302
  onChange: adaptedOnChange,
300
303
  enableSelectAll: true,
301
304
  ...props,
@@ -308,86 +311,86 @@ function CSMultiselect(props) {
308
311
 
309
312
  // src/types/ObjectWithId.ts
310
313
  var ObjectWithId = class {
311
- id;
312
- static idToString = (objectWithId) => {
313
- return objectWithId.id ? objectWithId.id.toString() : "<N/A>";
314
- };
315
- static toObjectWithId = (array, idExtractor) => {
316
- return array.map((object) => ({
317
- ...object,
318
- id: idExtractor(object)
319
- }));
320
- };
314
+ };
315
+ ObjectWithId.idToString = (objectWithId) => {
316
+ return objectWithId.id ? objectWithId.id.toString() : "<N/A>";
317
+ };
318
+ ObjectWithId.toObjectWithId = (array, idExtractor) => {
319
+ return array.map((object) => ({
320
+ ...object,
321
+ id: idExtractor(object)
322
+ }));
321
323
  };
322
324
 
323
325
  // src/utils/SelectHelper.ts
324
- var SelectHelper = class _SelectHelper {
325
- static singleSelectOptionWithId = (objects, selectedObjectId, toOptionDefinition) => {
326
- return this.singleSelectOption(objects, objects.find((importObject) => ObjectWithId.idToString(importObject) === selectedObjectId?.toString()), toOptionDefinition);
327
- };
328
- static singleSelectOption = (objects, selectedObject, toOptionDefinition) => {
329
- const options = objects.map((object) => ({
330
- value: ObjectWithId.idToString(object),
331
- ...toOptionDefinition(object)
332
- }));
333
- const selectedOption = selectedObject === void 0 ? null : _SelectHelper.getSelectedOptions(options, [selectedObject.id])[0];
334
- return {
335
- options,
336
- selectedOption
337
- };
326
+ var _SelectHelper = class _SelectHelper {
327
+ };
328
+ _SelectHelper.singleSelectOptionWithId = (objects, selectedObjectId, toOptionDefinition) => {
329
+ return _SelectHelper.singleSelectOption(objects, objects.find((importObject) => ObjectWithId.idToString(importObject) === (selectedObjectId == null ? void 0 : selectedObjectId.toString())), toOptionDefinition);
330
+ };
331
+ _SelectHelper.singleSelectOption = (objects, selectedObject, toOptionDefinition) => {
332
+ const options = objects.map((object) => ({
333
+ value: ObjectWithId.idToString(object),
334
+ ...toOptionDefinition(object)
335
+ }));
336
+ const selectedOption = selectedObject === void 0 ? null : _SelectHelper.getSelectedOptions(options, [selectedObject.id])[0];
337
+ return {
338
+ options,
339
+ selectedOption
338
340
  };
339
- static singleSelectEnum = (enumFactory, selectedEnum, localiser, exclude) => {
340
- const options = enumFactory.values.filter((enumInstance) => exclude === void 0 || !exclude.includes(enumInstance)).map((enumInstance) => {
341
- const enumTranslation = localiser.getEnumLocalisation(enumFactory, enumInstance);
342
- return {
343
- value: enumInstance.toString(),
344
- label: enumTranslation.label,
345
- description: enumTranslation.description
346
- };
347
- });
348
- const selectedOption = selectedEnum === void 0 ? null : _SelectHelper.getSelectedEnumOptions(options, [selectedEnum.toString()])[0];
341
+ };
342
+ _SelectHelper.singleSelectEnum = (enumFactory, selectedEnum, localiser, exclude) => {
343
+ const options = enumFactory.values.filter((enumInstance) => exclude === void 0 || !exclude.includes(enumInstance)).map((enumInstance) => {
344
+ const enumTranslation = localiser.getEnumLocalisation(enumFactory, enumInstance);
349
345
  return {
350
- options,
351
- selectedOption
346
+ value: enumInstance.toString(),
347
+ label: enumTranslation.label,
348
+ description: enumTranslation.description
352
349
  };
350
+ });
351
+ const selectedOption = selectedEnum === void 0 ? null : _SelectHelper.getSelectedEnumOptions(options, [selectedEnum.toString()])[0];
352
+ return {
353
+ options,
354
+ selectedOption
353
355
  };
354
- static multiSelectOptions = (objects, selectedObjects, toOptionDefinition) => {
355
- const options = objects.map((object) => ({
356
- value: ObjectWithId.idToString(object),
357
- ...toOptionDefinition(object)
358
- }));
359
- const selectedOptions = _SelectHelper.getSelectedOptions(options, selectedObjects.map((s) => s.id));
360
- return {
361
- options,
362
- selectedOptions
363
- };
356
+ };
357
+ _SelectHelper.multiSelectOptions = (objects, selectedObjects, toOptionDefinition) => {
358
+ const options = objects.map((object) => ({
359
+ value: ObjectWithId.idToString(object),
360
+ ...toOptionDefinition(object)
361
+ }));
362
+ const selectedOptions = _SelectHelper.getSelectedOptions(options, selectedObjects.map((s) => s.id));
363
+ return {
364
+ options,
365
+ selectedOptions
364
366
  };
365
- static multiSelectEnums = (enumFactory, selectedEnums, localiser) => {
366
- const options = enumFactory.values.map((enumInstance) => {
367
- const enumTranslation = localiser.getEnumLocalisation(enumFactory, enumInstance);
368
- return {
369
- value: enumInstance.toString(),
370
- label: enumTranslation.label,
371
- description: enumTranslation.description
372
- };
373
- });
374
- const selectedOptions = _SelectHelper.getSelectedEnumOptions(options, selectedEnums);
367
+ };
368
+ _SelectHelper.multiSelectEnums = (enumFactory, selectedEnums, localiser) => {
369
+ const options = enumFactory.values.map((enumInstance) => {
370
+ const enumTranslation = localiser.getEnumLocalisation(enumFactory, enumInstance);
375
371
  return {
376
- options,
377
- selectedOptions
372
+ value: enumInstance.toString(),
373
+ label: enumTranslation.label,
374
+ description: enumTranslation.description
378
375
  };
376
+ });
377
+ const selectedOptions = _SelectHelper.getSelectedEnumOptions(options, selectedEnums);
378
+ return {
379
+ options,
380
+ selectedOptions
379
381
  };
380
- static getSelectedOptions = (options, selectedIds) => {
381
- const selectedIdsSet = {};
382
- selectedIds.forEach((selId) => selId !== void 0 ? selectedIdsSet[selId] = true : null);
383
- return options.filter((option) => option.value && selectedIdsSet[parseInt(option.value)]);
384
- };
385
- static getSelectedEnumOptions = (options, selectedEnums) => {
386
- const selectedIdsSet = {};
387
- selectedEnums.forEach((selId) => selId !== void 0 ? selectedIdsSet[selId.toString()] = true : null);
388
- return options.filter((option) => option.value && selectedIdsSet[option.value]);
389
- };
390
382
  };
383
+ _SelectHelper.getSelectedOptions = (options, selectedIds) => {
384
+ const selectedIdsSet = {};
385
+ selectedIds.forEach((selId) => selId !== void 0 ? selectedIdsSet[selId] = true : null);
386
+ return options.filter((option) => option.value && selectedIdsSet[parseInt(option.value)]);
387
+ };
388
+ _SelectHelper.getSelectedEnumOptions = (options, selectedEnums) => {
389
+ const selectedIdsSet = {};
390
+ selectedEnums.forEach((selId) => selId !== void 0 ? selectedIdsSet[selId.toString()] = true : null);
391
+ return options.filter((option) => option.value && selectedIdsSet[option.value]);
392
+ };
393
+ var SelectHelper = _SelectHelper;
391
394
 
392
395
  // src/components/CSEnumMultiselect.tsx
393
396
  var import_jsx_runtime9 = require("react/jsx-runtime");
@@ -733,8 +736,6 @@ var ELEMENT_VALIDITY_LEVEL_FACTORY = new EnumFactory("ElementValidityLevel", Obj
733
736
  // src/logging/Log.ts
734
737
  var DISABLE_LOGGING = false;
735
738
  var Log = class _Log {
736
- prefix;
737
- debugLogging;
738
739
  constructor(prefix) {
739
740
  this.prefix = prefix ? "[" + prefix + "] " : "";
740
741
  this.debugLogging = true;
@@ -837,11 +838,6 @@ var ViewElementSpec = class {
837
838
  this.key = key;
838
839
  this.instanceId = instanceId;
839
840
  }
840
- parent;
841
- ns;
842
- dataTestId;
843
- localisationKey;
844
- keyHierarchy;
845
841
  getDataTestId() {
846
842
  if (this.dataTestId === void 0) {
847
843
  const parentDataTestId = this.parent ? this.parent.getDataTestId() : "";
@@ -940,8 +936,6 @@ var ViewSpec = class _ViewSpec extends ViewElementSpec {
940
936
  this.viewValidator = customViewValidator;
941
937
  }
942
938
  }
943
- elements;
944
- viewValidator;
945
939
  static create(key, ns, elementDefinition, instanceId, parent, customViewValidator) {
946
940
  const viewSpec = new _ViewSpec(key, ns, instanceId, customViewValidator);
947
941
  viewSpec.parent = parent;
@@ -1069,62 +1063,63 @@ var import_components21 = require("@cloudscape-design/components");
1069
1063
 
1070
1064
  // src/utils/PriceUtils.ts
1071
1065
  var LOGGER2 = new Log("PriceUtils");
1072
- var PriceUtils = class {
1073
- static getFormattedPrice = (locale, price) => {
1074
- if (isNaN(price.priceInCents)) {
1075
- return "-";
1076
- }
1077
- return new Intl.NumberFormat(locale, {
1078
- style: "currency",
1079
- currency: price.currency.toString()
1080
- }).format(price.priceInCents / 100);
1081
- };
1082
- static sumPrices = (prices, defaultCurrency) => {
1083
- if (prices.length === 0) {
1084
- return { priceInCents: 0, currency: defaultCurrency };
1085
- }
1086
- const currencySet = this.getCurrenciesFromPrices(prices);
1087
- if (currencySet.size > 1) {
1088
- LOGGER2.warn("Different currencies found in price array to be summed - the final price is incorrect!", currencySet);
1089
- }
1090
- const summedPrice = prices.map((pr) => pr.priceInCents).reduce((sum, current) => sum + current);
1091
- return { priceInCents: summedPrice, currency: prices[0].currency };
1092
- };
1093
- static getCurrenciesFromPrices = (prices) => {
1094
- const currencySet = /* @__PURE__ */ new Set();
1095
- prices.forEach((pr) => currencySet.add(pr.currency));
1096
- return currencySet;
1097
- };
1098
- static getPriceValidityLevel = (spec, value) => {
1099
- const centsValidity = spec.elements.inputPrice.getValueValidityLevel(value.priceInCents);
1100
- if (centsValidity !== "VALID" /* VALID */) {
1101
- return centsValidity;
1102
- }
1103
- return spec.elements.selectCurrency.getValueValidityLevel(value.currency);
1104
- };
1105
- static parseFormattedPrice = (locale, formattedPrice, currency) => {
1106
- const thousandSeparator = Intl.NumberFormat(locale).format(11111).replace(/\p{Number}/gu, "");
1107
- const decimalSeparator = Intl.NumberFormat(locale).format(1.1).replace(/\p{Number}/gu, "");
1108
- const sanitizedPrice = formattedPrice.replace(new RegExp("\\" + thousandSeparator, "g"), "").replace(new RegExp("\\" + decimalSeparator), ".").replace(new RegExp("[^0-9.]", "g"), "").trim();
1109
- const parsedPriceCents = Math.round(100 * parseFloat(sanitizedPrice));
1110
- return { priceInCents: parsedPriceCents, currency };
1111
- };
1112
- static parseFormattedPriceWithCurrency = (locale, formattedPrice, currencySymbolMapping) => {
1113
- const thousandSeparator = Intl.NumberFormat(locale).format(11111).replace(/\p{Number}/gu, "");
1114
- const decimalSeparator = Intl.NumberFormat(locale).format(1.1).replace(/\p{Number}/gu, "");
1115
- const sanitizedPrice = formattedPrice.replace(new RegExp("\\" + thousandSeparator, "g"), "").replace(new RegExp("\\" + decimalSeparator), ".").replace(new RegExp("[^0-9.]", "g"), "").trim();
1116
- const parsedPriceCents = Math.round(100 * parseFloat(sanitizedPrice));
1117
- const supportedCurrencies = Object.keys(currencySymbolMapping);
1118
- const currencySymbolsFound = supportedCurrencies.filter((symbol) => formattedPrice.includes(symbol));
1119
- if (currencySymbolsFound.length > 1) {
1120
- throw new Error(`Multiple currency symbols found in formatter price string ${formattedPrice}, here are the supported currencies: ${supportedCurrencies}`);
1121
- }
1122
- return {
1123
- priceInCents: parsedPriceCents,
1124
- currency: currencySymbolMapping[currencySymbolsFound[0]]
1125
- };
1066
+ var _PriceUtils = class _PriceUtils {
1067
+ };
1068
+ _PriceUtils.getFormattedPrice = (locale, price) => {
1069
+ if (isNaN(price.priceInCents)) {
1070
+ return "-";
1071
+ }
1072
+ return new Intl.NumberFormat(locale, {
1073
+ style: "currency",
1074
+ currency: price.currency.toString()
1075
+ }).format(price.priceInCents / 100);
1076
+ };
1077
+ _PriceUtils.sumPrices = (prices, defaultCurrency) => {
1078
+ if (prices.length === 0) {
1079
+ return { priceInCents: 0, currency: defaultCurrency };
1080
+ }
1081
+ const currencySet = _PriceUtils.getCurrenciesFromPrices(prices);
1082
+ if (currencySet.size > 1) {
1083
+ LOGGER2.warn("Different currencies found in price array to be summed - the final price is incorrect!", currencySet);
1084
+ }
1085
+ const summedPrice = prices.map((pr) => pr.priceInCents).reduce((sum, current) => sum + current);
1086
+ return { priceInCents: summedPrice, currency: prices[0].currency };
1087
+ };
1088
+ _PriceUtils.getCurrenciesFromPrices = (prices) => {
1089
+ const currencySet = /* @__PURE__ */ new Set();
1090
+ prices.forEach((pr) => currencySet.add(pr.currency));
1091
+ return currencySet;
1092
+ };
1093
+ _PriceUtils.getPriceValidityLevel = (spec, value) => {
1094
+ const centsValidity = spec.elements.inputPrice.getValueValidityLevel(value.priceInCents);
1095
+ if (centsValidity !== "VALID" /* VALID */) {
1096
+ return centsValidity;
1097
+ }
1098
+ return spec.elements.selectCurrency.getValueValidityLevel(value.currency);
1099
+ };
1100
+ _PriceUtils.parseFormattedPrice = (locale, formattedPrice, currency) => {
1101
+ const thousandSeparator = Intl.NumberFormat(locale).format(11111).replace(/\p{Number}/gu, "");
1102
+ const decimalSeparator = Intl.NumberFormat(locale).format(1.1).replace(/\p{Number}/gu, "");
1103
+ const sanitizedPrice = formattedPrice.replace(new RegExp("\\" + thousandSeparator, "g"), "").replace(new RegExp("\\" + decimalSeparator), ".").replace(new RegExp("[^0-9.]", "g"), "").trim();
1104
+ const parsedPriceCents = Math.round(100 * parseFloat(sanitizedPrice));
1105
+ return { priceInCents: parsedPriceCents, currency };
1106
+ };
1107
+ _PriceUtils.parseFormattedPriceWithCurrency = (locale, formattedPrice, currencySymbolMapping) => {
1108
+ const thousandSeparator = Intl.NumberFormat(locale).format(11111).replace(/\p{Number}/gu, "");
1109
+ const decimalSeparator = Intl.NumberFormat(locale).format(1.1).replace(/\p{Number}/gu, "");
1110
+ const sanitizedPrice = formattedPrice.replace(new RegExp("\\" + thousandSeparator, "g"), "").replace(new RegExp("\\" + decimalSeparator), ".").replace(new RegExp("[^0-9.]", "g"), "").trim();
1111
+ const parsedPriceCents = Math.round(100 * parseFloat(sanitizedPrice));
1112
+ const supportedCurrencies = Object.keys(currencySymbolMapping);
1113
+ const currencySymbolsFound = supportedCurrencies.filter((symbol) => formattedPrice.includes(symbol));
1114
+ if (currencySymbolsFound.length > 1) {
1115
+ throw new Error(`Multiple currency symbols found in formatter price string ${formattedPrice}, here are the supported currencies: ${supportedCurrencies}`);
1116
+ }
1117
+ return {
1118
+ priceInCents: parsedPriceCents,
1119
+ currency: currencySymbolMapping[currencySymbolsFound[0]]
1126
1120
  };
1127
1121
  };
1122
+ var PriceUtils = _PriceUtils;
1128
1123
 
1129
1124
  // src/views/CSVPriceInputView.tsx
1130
1125
  var import_jsx_runtime26 = require("react/jsx-runtime");
@@ -1471,35 +1466,25 @@ var MESSAGE_SEVERITY_FACTORY = new EnumFactory("MessageSeverity", Object.values(
1471
1466
 
1472
1467
  // src/types/messaging/MessageCTO.ts
1473
1468
  var MessageCTO = class {
1474
- static TIMESTAMP_PROPS = new FieldProperties("timestamp", true);
1475
- static DETAIL_MESSAGE_PROPS = new FieldProperties("detailMessage", true);
1476
- static CORRELATION_ID_PROPS = new FieldProperties("correlationId", true);
1477
- static OPERATION_PROPS = new FieldProperties("operation", true);
1478
- code;
1479
- timestamp;
1480
- detailMessage;
1481
- correlationId;
1482
- operation;
1483
1469
  };
1470
+ MessageCTO.TIMESTAMP_PROPS = new FieldProperties("timestamp", true);
1471
+ MessageCTO.DETAIL_MESSAGE_PROPS = new FieldProperties("detailMessage", true);
1472
+ MessageCTO.CORRELATION_ID_PROPS = new FieldProperties("correlationId", true);
1473
+ MessageCTO.OPERATION_PROPS = new FieldProperties("operation", true);
1484
1474
 
1485
1475
  // src/types/messaging/MessageCodeTO.ts
1486
1476
  var MessageCodeTO = class {
1487
- static CONTROLLER_ID_PROPS = new FieldProperties("componentId", true);
1488
- static HTTP_STATUS_CODE_PROPS = new FieldProperties("httpStatusCode", true);
1489
- static LOCAL_CODE_PROPS = new FieldProperties("localCode", true);
1490
- static MESSAGE_SEVERITY_PROPS = new FieldProperties("messageSeverity", true);
1491
- static UNIQUE_CODE_PROPS = new FieldProperties("uniqueCode", true);
1492
- componentId;
1493
- httpStatusCode;
1494
- localCode;
1495
- messageSeverity;
1496
- uniqueCode;
1497
1477
  };
1478
+ MessageCodeTO.CONTROLLER_ID_PROPS = new FieldProperties("componentId", true);
1479
+ MessageCodeTO.HTTP_STATUS_CODE_PROPS = new FieldProperties("httpStatusCode", true);
1480
+ MessageCodeTO.LOCAL_CODE_PROPS = new FieldProperties("localCode", true);
1481
+ MessageCodeTO.MESSAGE_SEVERITY_PROPS = new FieldProperties("messageSeverity", true);
1482
+ MessageCodeTO.UNIQUE_CODE_PROPS = new FieldProperties("uniqueCode", true);
1498
1483
 
1499
1484
  // src/types/messaging/MessageService.ts
1500
1485
  var TECHNICAL_CONTROLLER_ID = "T";
1501
1486
  var NO_HTTP_CODE = 0;
1502
- var MessageService = class _MessageService {
1487
+ var _MessageService = class _MessageService {
1503
1488
  static getResponseTOWithMessagesFromUnknownResponse(json, op, status) {
1504
1489
  const response = json !== void 0 && json !== null && json.hasOwnProperty("messages") ? json : _MessageService.createGenericErrorMessageTO(status, op);
1505
1490
  response.messages.forEach((m) => m.operation = op);
@@ -1516,71 +1501,72 @@ var MessageService = class _MessageService {
1516
1501
  result.messages.forEach((m) => m.operation = op);
1517
1502
  return result;
1518
1503
  }
1519
- static createContentWithSuccessMessage = (operation, message) => {
1520
- return this.createContentWithMessage(this.createMessageTO(
1521
- TECHNICAL_CONTROLLER_ID,
1522
- NO_HTTP_CODE.toString(),
1523
- 0,
1524
- message,
1525
- operation,
1526
- "SUCCESS" /* SUCCESS */
1527
- ));
1528
- };
1529
- static createContentWithoutMessages = (content) => {
1530
- return {
1531
- messages: [],
1532
- content
1533
- };
1534
- };
1535
- static createContentWithInfoMessage = (operation, message) => {
1536
- return this.createContentWithMessage(this.createMessageTO(
1537
- TECHNICAL_CONTROLLER_ID,
1538
- NO_HTTP_CODE.toString(),
1539
- 0,
1540
- message,
1541
- operation,
1542
- "INFO" /* INFO */
1543
- ));
1544
- };
1545
- static createGenericErrorMessageTO = (httpStatusCode, operation) => {
1546
- if (this.isAPIClientCallError(httpStatusCode)) {
1547
- return this.createContentWithMessage(this.createMessageTO(TECHNICAL_CONTROLLER_ID, "998", httpStatusCode, "Generic API call client error", operation));
1548
- } else if (this.isBackendError(httpStatusCode)) {
1549
- return this.createContentWithMessage(this.createMessageTO(TECHNICAL_CONTROLLER_ID, "999", httpStatusCode, "Generic backend error", operation));
1550
- } else {
1551
- throw new Error("Calling this methods with any http status code outside 400-599 is not allowed.");
1552
- }
1553
- };
1554
- static createCriticalErrorFrontendProcessingMessageTO = (operation, message) => {
1555
- return this.createMessageTO(TECHNICAL_CONTROLLER_ID, "997", -1, message, operation);
1556
- };
1557
- static isAPIClientCallError = (httpStatusCode) => {
1558
- return httpStatusCode >= 400 && httpStatusCode <= 499;
1559
- };
1560
- static isBackendError = (httpStatusCode) => {
1561
- return httpStatusCode >= 500 && httpStatusCode <= 599;
1562
- };
1563
1504
  static createContentWithMessage(message) {
1564
1505
  return {
1565
1506
  messages: [message],
1566
1507
  content: void 0
1567
1508
  };
1568
1509
  }
1569
- static createMessageTO = (componentId, localCode, httpStatusCode, detailMessage, operation, severity) => {
1570
- const message = new MessageCTO();
1571
- message.code = new MessageCodeTO();
1572
- message.code.httpStatusCode = httpStatusCode;
1573
- message.code.componentId = componentId;
1574
- message.code.localCode = localCode;
1575
- message.code.uniqueCode = componentId + localCode;
1576
- message.code.messageSeverity = severity ? severity : "ERR" /* ERR */;
1577
- message.operation = operation;
1578
- message.correlationId = "N/A";
1579
- message.timestamp = DateUtils.currentDateTimeAsUTCISO8601String();
1580
- message.detailMessage = detailMessage;
1581
- return message;
1510
+ };
1511
+ _MessageService.createContentWithSuccessMessage = (operation, message) => {
1512
+ return _MessageService.createContentWithMessage(_MessageService.createMessageTO(
1513
+ TECHNICAL_CONTROLLER_ID,
1514
+ NO_HTTP_CODE.toString(),
1515
+ 0,
1516
+ message,
1517
+ operation,
1518
+ "SUCCESS" /* SUCCESS */
1519
+ ));
1520
+ };
1521
+ _MessageService.createContentWithoutMessages = (content) => {
1522
+ return {
1523
+ messages: [],
1524
+ content
1582
1525
  };
1583
1526
  };
1527
+ _MessageService.createContentWithInfoMessage = (operation, message) => {
1528
+ return _MessageService.createContentWithMessage(_MessageService.createMessageTO(
1529
+ TECHNICAL_CONTROLLER_ID,
1530
+ NO_HTTP_CODE.toString(),
1531
+ 0,
1532
+ message,
1533
+ operation,
1534
+ "INFO" /* INFO */
1535
+ ));
1536
+ };
1537
+ _MessageService.createGenericErrorMessageTO = (httpStatusCode, operation) => {
1538
+ if (_MessageService.isAPIClientCallError(httpStatusCode)) {
1539
+ return _MessageService.createContentWithMessage(_MessageService.createMessageTO(TECHNICAL_CONTROLLER_ID, "998", httpStatusCode, "Generic API call client error", operation));
1540
+ } else if (_MessageService.isBackendError(httpStatusCode)) {
1541
+ return _MessageService.createContentWithMessage(_MessageService.createMessageTO(TECHNICAL_CONTROLLER_ID, "999", httpStatusCode, "Generic backend error", operation));
1542
+ } else {
1543
+ throw new Error("Calling this methods with any http status code outside 400-599 is not allowed.");
1544
+ }
1545
+ };
1546
+ _MessageService.createCriticalErrorFrontendProcessingMessageTO = (operation, message) => {
1547
+ return _MessageService.createMessageTO(TECHNICAL_CONTROLLER_ID, "997", -1, message, operation);
1548
+ };
1549
+ _MessageService.isAPIClientCallError = (httpStatusCode) => {
1550
+ return httpStatusCode >= 400 && httpStatusCode <= 499;
1551
+ };
1552
+ _MessageService.isBackendError = (httpStatusCode) => {
1553
+ return httpStatusCode >= 500 && httpStatusCode <= 599;
1554
+ };
1555
+ _MessageService.createMessageTO = (componentId, localCode, httpStatusCode, detailMessage, operation, severity) => {
1556
+ const message = new MessageCTO();
1557
+ message.code = new MessageCodeTO();
1558
+ message.code.httpStatusCode = httpStatusCode;
1559
+ message.code.componentId = componentId;
1560
+ message.code.localCode = localCode;
1561
+ message.code.uniqueCode = componentId + localCode;
1562
+ message.code.messageSeverity = severity ? severity : "ERR" /* ERR */;
1563
+ message.operation = operation;
1564
+ message.correlationId = "N/A";
1565
+ message.timestamp = DateUtils.currentDateTimeAsUTCISO8601String();
1566
+ message.detailMessage = detailMessage;
1567
+ return message;
1568
+ };
1569
+ var MessageService = _MessageService;
1584
1570
 
1585
1571
  // src/utils/QueryParamHelper.ts
1586
1572
  var QUERY_START = "?";
@@ -1633,8 +1619,17 @@ function createRestClient() {
1633
1619
  return new RestClient("");
1634
1620
  }
1635
1621
  var RestClient = class {
1636
- // Base URL. May be empty.
1637
- baseUrl = "";
1622
+ /**
1623
+ * Creates a new REST client.
1624
+ * @param baseUrl base URL, so client can be called with relative URLs.
1625
+ */
1626
+ constructor(baseUrl) {
1627
+ // Base URL. May be empty.
1628
+ this.baseUrl = "";
1629
+ if (baseUrl != null) {
1630
+ this.baseUrl = baseUrl;
1631
+ }
1632
+ }
1638
1633
  prepareFetchConfig(method, payload, header = {}) {
1639
1634
  let headers = {
1640
1635
  Accept: "application/json",
@@ -1656,15 +1651,6 @@ var RestClient = class {
1656
1651
  }
1657
1652
  return config;
1658
1653
  }
1659
- /**
1660
- * Creates a new REST client.
1661
- * @param baseUrl base URL, so client can be called with relative URLs.
1662
- */
1663
- constructor(baseUrl) {
1664
- if (baseUrl != null) {
1665
- this.baseUrl = baseUrl;
1666
- }
1667
- }
1668
1654
  /**
1669
1655
  * Make a GET request on the specified endpoint
1670
1656
  *
@@ -2013,7 +1999,7 @@ var useHotkey = (key, shift, ctrl, alt, callback, node = null) => {
2013
1999
  [alt, ctrl, key, shift]
2014
2000
  );
2015
2001
  (0, import_react5.useEffect)(() => {
2016
- const targetNode = node ?? document;
2002
+ const targetNode = node != null ? node : document;
2017
2003
  targetNode && targetNode.addEventListener("keydown", handleKeyPress);
2018
2004
  return () => targetNode && targetNode.removeEventListener("keydown", handleKeyPress);
2019
2005
  }, [handleKeyPress, node]);