@formality-ui/core 0.3.0 → 0.4.0
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/dist/index.cjs +17 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +152 -22
- package/dist/index.d.ts +152 -22
- package/dist/index.js +17 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1226,6 +1226,9 @@ function mergeConfigs(provider, form, field) {
|
|
|
1226
1226
|
}
|
|
1227
1227
|
|
|
1228
1228
|
// src/config/defaults.ts
|
|
1229
|
+
function resolveFieldOverType(fieldVal, typeVal) {
|
|
1230
|
+
return fieldVal !== void 0 ? fieldVal : typeVal;
|
|
1231
|
+
}
|
|
1229
1232
|
function resolveInitialValue(fieldName, fieldConfig, inputConfig, record, defaultValues) {
|
|
1230
1233
|
if (defaultValues && fieldName in defaultValues) {
|
|
1231
1234
|
return defaultValues[fieldName];
|
|
@@ -1234,8 +1237,12 @@ function resolveInitialValue(fieldName, fieldConfig, inputConfig, record, defaul
|
|
|
1234
1237
|
if (record && recordKey in record) {
|
|
1235
1238
|
return record[recordKey];
|
|
1236
1239
|
}
|
|
1237
|
-
|
|
1238
|
-
|
|
1240
|
+
const resolvedDefault = resolveFieldOverType(
|
|
1241
|
+
fieldConfig?.defaultValue,
|
|
1242
|
+
inputConfig?.defaultValue
|
|
1243
|
+
);
|
|
1244
|
+
if (resolvedDefault !== void 0) {
|
|
1245
|
+
return resolvedDefault;
|
|
1239
1246
|
}
|
|
1240
1247
|
return void 0;
|
|
1241
1248
|
}
|
|
@@ -1346,7 +1353,7 @@ function humanizeLabel(fieldName) {
|
|
|
1346
1353
|
const words = fieldName.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").split(" ");
|
|
1347
1354
|
return words.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
|
|
1348
1355
|
}
|
|
1349
|
-
function resolveLabel(fieldName, fieldConfig, evaluatedSelectProps, componentProps) {
|
|
1356
|
+
function resolveLabel(fieldName, fieldConfig, evaluatedSelectProps, componentProps, providerSelectProps, formSelectProps) {
|
|
1350
1357
|
if (componentProps?.label !== void 0) {
|
|
1351
1358
|
return String(componentProps.label);
|
|
1352
1359
|
}
|
|
@@ -1362,6 +1369,12 @@ function resolveLabel(fieldName, fieldConfig, evaluatedSelectProps, componentPro
|
|
|
1362
1369
|
if (fieldConfig?.title !== void 0) {
|
|
1363
1370
|
return fieldConfig.title;
|
|
1364
1371
|
}
|
|
1372
|
+
if (formSelectProps?.label !== void 0) {
|
|
1373
|
+
return String(formSelectProps.label);
|
|
1374
|
+
}
|
|
1375
|
+
if (providerSelectProps?.label !== void 0) {
|
|
1376
|
+
return String(providerSelectProps.label);
|
|
1377
|
+
}
|
|
1365
1378
|
return humanizeLabel(fieldName);
|
|
1366
1379
|
}
|
|
1367
1380
|
function resolveFormTitle(formTitle, evaluatedSelectTitle) {
|
|
@@ -1441,6 +1454,7 @@ exports.pattern = pattern;
|
|
|
1441
1454
|
exports.required = required;
|
|
1442
1455
|
exports.resolveAllInitialValues = resolveAllInitialValues;
|
|
1443
1456
|
exports.resolveErrorMessage = resolveErrorMessage;
|
|
1457
|
+
exports.resolveFieldOverType = resolveFieldOverType;
|
|
1444
1458
|
exports.resolveFieldType = resolveFieldType;
|
|
1445
1459
|
exports.resolveFormTitle = resolveFormTitle;
|
|
1446
1460
|
exports.resolveInitialValue = resolveInitialValue;
|