@crystaldesign/forms 25.12.0-beta.9 → 25.12.0-rc.1
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/esm/index.js
CHANGED
|
@@ -313,11 +313,11 @@ function FormComponent(_ref) {
|
|
|
313
313
|
}
|
|
314
314
|
};
|
|
315
315
|
var translateError = function translateError(error) {
|
|
316
|
-
var _error$message;
|
|
316
|
+
var _getFieldNameFromSche, _error$message;
|
|
317
317
|
switch (error.keyword) {
|
|
318
318
|
case 'required':
|
|
319
319
|
return t('basket.checkout.form.requiredField', {
|
|
320
|
-
data: error.params.missingProperty
|
|
320
|
+
data: "'" + ((_getFieldNameFromSche = getFieldNameFromSchema(translatedSchema, error.params.missingProperty)) !== null && _getFieldNameFromSche !== void 0 ? _getFieldNameFromSche : error.params.missingProperty) + "'"
|
|
321
321
|
});
|
|
322
322
|
case 'minLength':
|
|
323
323
|
return t('basket.checkout.form.minLength', {
|
|
@@ -337,6 +337,42 @@ function FormComponent(_ref) {
|
|
|
337
337
|
return (_error$message = error.message) !== null && _error$message !== void 0 ? _error$message : t('basket.checkout.form.invalidvalue');
|
|
338
338
|
}
|
|
339
339
|
};
|
|
340
|
+
var getFieldNameFromSchema = function getFieldNameFromSchema(schema, path) {
|
|
341
|
+
var _schema$properties;
|
|
342
|
+
// First try to find the field at the top level
|
|
343
|
+
var topLevelField = (_schema$properties = schema.properties) === null || _schema$properties === void 0 ? void 0 : _schema$properties[path];
|
|
344
|
+
if (topLevelField) {
|
|
345
|
+
var _topLevelField$title;
|
|
346
|
+
return (_topLevelField$title = topLevelField.title) !== null && _topLevelField$title !== void 0 ? _topLevelField$title : path;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// If not found at top level, search recursively in nested objects
|
|
350
|
+
var _findFieldInNestedObjects = function findFieldInNestedObjects(currentSchema, fieldName) {
|
|
351
|
+
if (!currentSchema.properties) {
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
for (var _i = 0, _Object$entries = Object.entries(currentSchema.properties); _i < _Object$entries.length; _i++) {
|
|
355
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
356
|
+
key = _Object$entries$_i[0],
|
|
357
|
+
property = _Object$entries$_i[1];
|
|
358
|
+
if (key === fieldName) {
|
|
359
|
+
var _property$title;
|
|
360
|
+
return (_property$title = property.title) !== null && _property$title !== void 0 ? _property$title : fieldName;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// If this property is an object, search recursively
|
|
364
|
+
if (property.type === 'object' && property.properties) {
|
|
365
|
+
var found = _findFieldInNestedObjects(property, fieldName);
|
|
366
|
+
if (found) {
|
|
367
|
+
return found;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return null;
|
|
372
|
+
};
|
|
373
|
+
var nestedResult = _findFieldInNestedObjects(schema, path);
|
|
374
|
+
return nestedResult !== null && nestedResult !== void 0 ? nestedResult : path;
|
|
375
|
+
};
|
|
340
376
|
if (renderer == 'vanilla') {
|
|
341
377
|
var _ref2 = other,
|
|
342
378
|
_ref2$styleDef = _ref2.styleDef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../../src/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAG5D,OAAO,EAAwE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC9H,OAAO,EAAE,aAAa,EAAE,8BAA8B,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAQ7F,UAAU,aAAc,SAAQ,SAAS;IACvC,QAAQ,CAAC,EAAE,UAAU,CAAC;CACvB;AAED,UAAU,YAAa,SAAQ,SAAS;IACtC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;CACvB;AAED,UAAU,SAAS;IACjB;;;OAGG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AAC;IAClD;;;;OAIG;IACH,QAAQ,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,QAAQ,CAAC,GAAG,IAAI,CAAC;IAC/D;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,MAAM,KAAK,GAAG,aAAa,GAAG,YAAY,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,QAAoB,EACpB,cAAmB,EACnB,QAAQ,EACR,aAAa,EACb,GAAG,KAAK,EACT,EAAE,KAAK,4BAmHP"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crystaldesign/forms",
|
|
3
|
-
"version": "25.12.0-
|
|
3
|
+
"version": "25.12.0-rc.1",
|
|
4
4
|
"license": "COMMERCIAL",
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@testing-library/jest-dom": "^6.5.0",
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
},
|
|
26
26
|
"module": "build/esm/index.js",
|
|
27
27
|
"types": "./build/types/forms/src/index.d.ts",
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "3261d80f42868a4a6c1be5f61340a564c5b2735a"
|
|
29
29
|
}
|