easy-forms-core 1.0.10 → 1.1.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/easy-form.js +120 -37
- package/dist/easy-form.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +120 -37
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/dist/easy-form.js
CHANGED
|
@@ -910,7 +910,7 @@ function getLinesStyles(_colors) {
|
|
|
910
910
|
function getShadcnStyles(_colors) {
|
|
911
911
|
return `
|
|
912
912
|
.easy-form-label {
|
|
913
|
-
color:
|
|
913
|
+
color: var(--easy-form-label-color);
|
|
914
914
|
font-size: 0.875rem;
|
|
915
915
|
font-weight: 600;
|
|
916
916
|
margin-bottom: 0.75rem;
|
|
@@ -920,21 +920,22 @@ function getShadcnStyles(_colors) {
|
|
|
920
920
|
border: 1.5px solid #e4e4e7;
|
|
921
921
|
border-radius: 8px;
|
|
922
922
|
padding: 0.75rem 1rem;
|
|
923
|
-
background: linear-gradient(to bottom,
|
|
923
|
+
background: linear-gradient(to bottom, var(--easy-form-background), #fafafa);
|
|
924
|
+
color: var(--easy-form-text);
|
|
924
925
|
font-size: 0.875rem;
|
|
925
926
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
926
927
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), inset 0 1px 1px rgba(255, 255, 255, 0.8);
|
|
927
928
|
}
|
|
928
929
|
input:not([type="checkbox"]):not([type="radio"]):hover, textarea:hover, select:hover {
|
|
929
930
|
border-color: #d4d4d8;
|
|
930
|
-
background: linear-gradient(to bottom,
|
|
931
|
+
background: linear-gradient(to bottom, var(--easy-form-background), #f5f5f5);
|
|
931
932
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08), inset 0 1px 1px rgba(255, 255, 255, 0.9);
|
|
932
933
|
transform: translateY(-1px);
|
|
933
934
|
}
|
|
934
935
|
input:not([type="checkbox"]):not([type="radio"]):focus, textarea:focus, select:focus {
|
|
935
936
|
outline: none;
|
|
936
937
|
border-color: var(--easy-form-primary);
|
|
937
|
-
background:
|
|
938
|
+
background: var(--easy-form-background);
|
|
938
939
|
box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.12), 0 4px 12px rgba(0, 123, 255, 0.15);
|
|
939
940
|
transform: translateY(-2px);
|
|
940
941
|
}
|
|
@@ -958,14 +959,14 @@ function getShadcnStyles(_colors) {
|
|
|
958
959
|
.easy-form-group {
|
|
959
960
|
border: 1.5px solid #e4e4e7;
|
|
960
961
|
border-radius: 12px;
|
|
961
|
-
background: linear-gradient(to bottom,
|
|
962
|
+
background: linear-gradient(to bottom, var(--easy-form-background), #fafafa);
|
|
962
963
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
|
963
964
|
padding: 1.5rem;
|
|
964
965
|
}
|
|
965
966
|
.easy-form-wizard-step {
|
|
966
967
|
border: 1.5px solid #e4e4e7;
|
|
967
968
|
border-radius: 8px;
|
|
968
|
-
background: linear-gradient(to bottom,
|
|
969
|
+
background: linear-gradient(to bottom, var(--easy-form-background), #fafafa);
|
|
969
970
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
970
971
|
}
|
|
971
972
|
.easy-form-wizard-step:hover {
|
|
@@ -983,7 +984,7 @@ function getShadcnStyles(_colors) {
|
|
|
983
984
|
.easy-form-array-item {
|
|
984
985
|
border: 1.5px solid #e4e4e7;
|
|
985
986
|
border-radius: 8px;
|
|
986
|
-
background: linear-gradient(to bottom,
|
|
987
|
+
background: linear-gradient(to bottom, var(--easy-form-background), #fafafa);
|
|
987
988
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
|
|
988
989
|
}
|
|
989
990
|
`;
|
|
@@ -991,7 +992,7 @@ function getShadcnStyles(_colors) {
|
|
|
991
992
|
function getChakraStyles(_colors) {
|
|
992
993
|
return `
|
|
993
994
|
.easy-form-label {
|
|
994
|
-
color:
|
|
995
|
+
color: var(--easy-form-label-color);
|
|
995
996
|
font-size: 0.875rem;
|
|
996
997
|
font-weight: 600;
|
|
997
998
|
margin-bottom: 0.5rem;
|
|
@@ -1003,7 +1004,8 @@ function getChakraStyles(_colors) {
|
|
|
1003
1004
|
border: 2px solid #cbd5e0;
|
|
1004
1005
|
border-radius: 6px;
|
|
1005
1006
|
padding: 0.625rem 0.875rem;
|
|
1006
|
-
background:
|
|
1007
|
+
background: var(--easy-form-background);
|
|
1008
|
+
color: var(--easy-form-text);
|
|
1007
1009
|
font-size: 0.875rem;
|
|
1008
1010
|
transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
|
1009
1011
|
font-weight: 500;
|
|
@@ -1018,7 +1020,7 @@ function getChakraStyles(_colors) {
|
|
|
1018
1020
|
outline: none;
|
|
1019
1021
|
border-color: var(--easy-form-primary);
|
|
1020
1022
|
border-width: 2px;
|
|
1021
|
-
background:
|
|
1023
|
+
background: var(--easy-form-background);
|
|
1022
1024
|
box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2), 0 4px 12px rgba(0, 123, 255, 0.15);
|
|
1023
1025
|
transform: scale(1.02);
|
|
1024
1026
|
}
|
|
@@ -1054,13 +1056,13 @@ function getChakraStyles(_colors) {
|
|
|
1054
1056
|
.easy-form-group {
|
|
1055
1057
|
border: 2px solid #e2e8f0;
|
|
1056
1058
|
border-radius: 8px;
|
|
1057
|
-
background:
|
|
1059
|
+
background: var(--easy-form-background);
|
|
1058
1060
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
1059
1061
|
}
|
|
1060
1062
|
.easy-form-wizard-step {
|
|
1061
1063
|
border: 2px solid #e2e8f0;
|
|
1062
1064
|
border-radius: 6px;
|
|
1063
|
-
background:
|
|
1065
|
+
background: var(--easy-form-background);
|
|
1064
1066
|
transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
|
1065
1067
|
}
|
|
1066
1068
|
.easy-form-wizard-step:hover {
|
|
@@ -1077,7 +1079,7 @@ function getChakraStyles(_colors) {
|
|
|
1077
1079
|
.easy-form-array-item {
|
|
1078
1080
|
border: 2px solid #e2e8f0;
|
|
1079
1081
|
border-radius: 6px;
|
|
1080
|
-
background:
|
|
1082
|
+
background: var(--easy-form-background);
|
|
1081
1083
|
transition: all 0.25s ease;
|
|
1082
1084
|
}
|
|
1083
1085
|
.easy-form-array-item:hover {
|
|
@@ -1089,7 +1091,7 @@ function getChakraStyles(_colors) {
|
|
|
1089
1091
|
function getMantineStyles(_colors) {
|
|
1090
1092
|
return `
|
|
1091
1093
|
.easy-form-label {
|
|
1092
|
-
color:
|
|
1094
|
+
color: var(--easy-form-label-color);
|
|
1093
1095
|
font-size: 0.875rem;
|
|
1094
1096
|
font-weight: 600;
|
|
1095
1097
|
margin-bottom: 0.625rem;
|
|
@@ -1098,21 +1100,22 @@ function getMantineStyles(_colors) {
|
|
|
1098
1100
|
border: 1px solid #dee2e6;
|
|
1099
1101
|
border-radius: 12px;
|
|
1100
1102
|
padding: 0.875rem 1.25rem;
|
|
1101
|
-
background:
|
|
1103
|
+
background: var(--easy-form-background);
|
|
1104
|
+
color: var(--easy-form-text);
|
|
1102
1105
|
font-size: 0.875rem;
|
|
1103
1106
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
1104
1107
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.8);
|
|
1105
1108
|
}
|
|
1106
1109
|
input:not([type="checkbox"]):not([type="radio"]):hover, textarea:hover, select:hover {
|
|
1107
1110
|
border-color: #adb5bd;
|
|
1108
|
-
background: linear-gradient(to bottom,
|
|
1111
|
+
background: linear-gradient(to bottom, var(--easy-form-background), #f8f9fa);
|
|
1109
1112
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);
|
|
1110
1113
|
transform: translateY(-2px);
|
|
1111
1114
|
}
|
|
1112
1115
|
input:not([type="checkbox"]):not([type="radio"]):focus, textarea:focus, select:focus {
|
|
1113
1116
|
outline: none;
|
|
1114
1117
|
border-color: var(--easy-form-primary);
|
|
1115
|
-
background:
|
|
1118
|
+
background: var(--easy-form-background);
|
|
1116
1119
|
box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15), 0 6px 16px rgba(0, 123, 255, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.9);
|
|
1117
1120
|
transform: translateY(-3px);
|
|
1118
1121
|
}
|
|
@@ -1134,14 +1137,14 @@ function getMantineStyles(_colors) {
|
|
|
1134
1137
|
.easy-form-group {
|
|
1135
1138
|
border: 1px solid #dee2e6;
|
|
1136
1139
|
border-radius: 16px;
|
|
1137
|
-
background:
|
|
1140
|
+
background: var(--easy-form-background);
|
|
1138
1141
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.8);
|
|
1139
1142
|
padding: 1.5rem;
|
|
1140
1143
|
}
|
|
1141
1144
|
.easy-form-wizard-step {
|
|
1142
1145
|
border: 1px solid #dee2e6;
|
|
1143
1146
|
border-radius: 12px;
|
|
1144
|
-
background:
|
|
1147
|
+
background: var(--easy-form-background);
|
|
1145
1148
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
1146
1149
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
|
|
1147
1150
|
}
|
|
@@ -1160,7 +1163,7 @@ function getMantineStyles(_colors) {
|
|
|
1160
1163
|
.easy-form-array-item {
|
|
1161
1164
|
border: 1px solid #dee2e6;
|
|
1162
1165
|
border-radius: 12px;
|
|
1163
|
-
background:
|
|
1166
|
+
background: var(--easy-form-background);
|
|
1164
1167
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.8);
|
|
1165
1168
|
}
|
|
1166
1169
|
`;
|
|
@@ -1168,7 +1171,7 @@ function getMantineStyles(_colors) {
|
|
|
1168
1171
|
function getGlassStyles(_colors) {
|
|
1169
1172
|
return `
|
|
1170
1173
|
.easy-form-label {
|
|
1171
|
-
color:
|
|
1174
|
+
color: var(--easy-form-label-color);
|
|
1172
1175
|
font-size: 0.875rem;
|
|
1173
1176
|
font-weight: 600;
|
|
1174
1177
|
margin-bottom: 0.75rem;
|
|
@@ -1182,7 +1185,7 @@ function getGlassStyles(_colors) {
|
|
|
1182
1185
|
backdrop-filter: blur(20px) saturate(180%);
|
|
1183
1186
|
-webkit-backdrop-filter: blur(20px) saturate(180%);
|
|
1184
1187
|
font-size: 0.875rem;
|
|
1185
|
-
color:
|
|
1188
|
+
color: var(--easy-form-text);
|
|
1186
1189
|
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
|
1187
1190
|
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
|
|
1188
1191
|
}
|
|
@@ -1209,7 +1212,7 @@ function getGlassStyles(_colors) {
|
|
|
1209
1212
|
backdrop-filter: blur(20px) saturate(180%);
|
|
1210
1213
|
-webkit-backdrop-filter: blur(20px) saturate(180%);
|
|
1211
1214
|
border: 2px solid rgba(255, 255, 255, 0.4);
|
|
1212
|
-
color:
|
|
1215
|
+
color: var(--easy-form-text);
|
|
1213
1216
|
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 0 20px rgba(255, 255, 255, 0.1);
|
|
1214
1217
|
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
|
1215
1218
|
}
|
|
@@ -1238,7 +1241,7 @@ function getGlassStyles(_colors) {
|
|
|
1238
1241
|
backdrop-filter: blur(20px) saturate(180%);
|
|
1239
1242
|
-webkit-backdrop-filter: blur(20px) saturate(180%);
|
|
1240
1243
|
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
|
1241
|
-
color:
|
|
1244
|
+
color: var(--easy-form-text);
|
|
1242
1245
|
}
|
|
1243
1246
|
.easy-form-wizard-step:hover {
|
|
1244
1247
|
background: rgba(255, 255, 255, 0.25);
|
|
@@ -1266,7 +1269,7 @@ function getGlassStyles(_colors) {
|
|
|
1266
1269
|
function getBorderedStyles(_colors) {
|
|
1267
1270
|
return `
|
|
1268
1271
|
.easy-form-label {
|
|
1269
|
-
color:
|
|
1272
|
+
color: var(--easy-form-label-color);
|
|
1270
1273
|
font-size: 0.875rem;
|
|
1271
1274
|
font-weight: 700;
|
|
1272
1275
|
margin-bottom: 0.75rem;
|
|
@@ -1277,7 +1280,8 @@ function getBorderedStyles(_colors) {
|
|
|
1277
1280
|
border: 3px solid #1a1a1a;
|
|
1278
1281
|
border-radius: 0;
|
|
1279
1282
|
padding: 0.875rem 1.25rem;
|
|
1280
|
-
background:
|
|
1283
|
+
background: var(--easy-form-background);
|
|
1284
|
+
color: var(--easy-form-text);
|
|
1281
1285
|
font-size: 0.875rem;
|
|
1282
1286
|
font-weight: 600;
|
|
1283
1287
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
@@ -1318,14 +1322,14 @@ function getBorderedStyles(_colors) {
|
|
|
1318
1322
|
.easy-form-group {
|
|
1319
1323
|
border: 4px solid #1a1a1a;
|
|
1320
1324
|
border-radius: 0;
|
|
1321
|
-
background:
|
|
1325
|
+
background: var(--easy-form-background);
|
|
1322
1326
|
box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.1);
|
|
1323
1327
|
padding: 2rem;
|
|
1324
1328
|
}
|
|
1325
1329
|
.easy-form-wizard-step {
|
|
1326
1330
|
border: 3px solid #1a1a1a;
|
|
1327
1331
|
border-radius: 0;
|
|
1328
|
-
background:
|
|
1332
|
+
background: var(--easy-form-background);
|
|
1329
1333
|
font-weight: 600;
|
|
1330
1334
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
1331
1335
|
box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.1);
|
|
@@ -1345,7 +1349,7 @@ function getBorderedStyles(_colors) {
|
|
|
1345
1349
|
.easy-form-array-item {
|
|
1346
1350
|
border: 3px solid #1a1a1a;
|
|
1347
1351
|
border-radius: 0;
|
|
1348
|
-
background:
|
|
1352
|
+
background: var(--easy-form-background);
|
|
1349
1353
|
box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.1);
|
|
1350
1354
|
}
|
|
1351
1355
|
`;
|
|
@@ -1353,7 +1357,7 @@ function getBorderedStyles(_colors) {
|
|
|
1353
1357
|
function getMinimalStyles(_colors) {
|
|
1354
1358
|
return `
|
|
1355
1359
|
.easy-form-label {
|
|
1356
|
-
color:
|
|
1360
|
+
color: var(--easy-form-label-color);
|
|
1357
1361
|
font-size: 0.75rem;
|
|
1358
1362
|
font-weight: 500;
|
|
1359
1363
|
margin-bottom: 0.5rem;
|
|
@@ -1366,6 +1370,7 @@ function getMinimalStyles(_colors) {
|
|
|
1366
1370
|
border-radius: 0;
|
|
1367
1371
|
padding: 0.625rem 0;
|
|
1368
1372
|
background: transparent;
|
|
1373
|
+
color: var(--easy-form-text);
|
|
1369
1374
|
font-size: 0.9375rem;
|
|
1370
1375
|
font-weight: 300;
|
|
1371
1376
|
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
|
@@ -2014,6 +2019,26 @@ var StateManager = class {
|
|
|
2014
2019
|
}
|
|
2015
2020
|
return allFields;
|
|
2016
2021
|
}
|
|
2022
|
+
/**
|
|
2023
|
+
* Encuentra el path completo de un campo dentro de grupos
|
|
2024
|
+
*/
|
|
2025
|
+
findFieldPath(fieldName, fields, parentPath = "") {
|
|
2026
|
+
for (const field of fields) {
|
|
2027
|
+
const currentPath = parentPath ? `${parentPath}.${field.name}` : field.name;
|
|
2028
|
+
if (field.name === fieldName) {
|
|
2029
|
+
return currentPath;
|
|
2030
|
+
}
|
|
2031
|
+
if (field.type === "group" && "fields" in field) {
|
|
2032
|
+
const found = this.findFieldPath(fieldName, field.fields, currentPath);
|
|
2033
|
+
if (found) return found;
|
|
2034
|
+
}
|
|
2035
|
+
if (field.type === "row" && "fields" in field) {
|
|
2036
|
+
const found = this.findFieldPath(fieldName, field.fields, currentPath);
|
|
2037
|
+
if (found) return found;
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
return null;
|
|
2041
|
+
}
|
|
2017
2042
|
/**
|
|
2018
2043
|
* Construye el mapa de dependencias para optimizar re-evaluaciones
|
|
2019
2044
|
*/
|
|
@@ -2196,6 +2221,7 @@ var StateManager = class {
|
|
|
2196
2221
|
*/
|
|
2197
2222
|
setValueWithoutValidation(fieldName, value) {
|
|
2198
2223
|
setNestedValue(this.state.values, fieldName, value);
|
|
2224
|
+
this.invalidateDependencyCache(fieldName);
|
|
2199
2225
|
}
|
|
2200
2226
|
/**
|
|
2201
2227
|
* Valida un campo específico
|
|
@@ -2228,6 +2254,13 @@ var StateManager = class {
|
|
|
2228
2254
|
*/
|
|
2229
2255
|
getActiveValidations(field) {
|
|
2230
2256
|
let validations = [...field.validations || []];
|
|
2257
|
+
const isRequired = this.getFieldRequired(field.name);
|
|
2258
|
+
const hasRequiredValidation = validations.some((v) => v.type === "required");
|
|
2259
|
+
if (isRequired && !hasRequiredValidation) {
|
|
2260
|
+
validations = [{ type: "required" }, ...validations];
|
|
2261
|
+
} else if (!isRequired && hasRequiredValidation) {
|
|
2262
|
+
validations = validations.filter((v) => v.type !== "required");
|
|
2263
|
+
}
|
|
2231
2264
|
if (field.conditionalValidations) {
|
|
2232
2265
|
for (const conditional of field.conditionalValidations) {
|
|
2233
2266
|
const conditionMet = this.conditionEngine.evaluateConditions(
|
|
@@ -2360,13 +2393,41 @@ var StateManager = class {
|
|
|
2360
2393
|
if (!this.schema) return true;
|
|
2361
2394
|
const topLevelFields = this.schema.isWizard ? this.schema.steps.flatMap((step) => step.fields) : this.schema.fields || [];
|
|
2362
2395
|
const allFields = this.extractAllFields(topLevelFields);
|
|
2363
|
-
|
|
2396
|
+
let field = allFields.find((f) => {
|
|
2397
|
+
const fullPath = this.findFieldPath(f.name, topLevelFields);
|
|
2398
|
+
return fullPath === fieldName || f.name === fieldName;
|
|
2399
|
+
});
|
|
2400
|
+
if (!field) {
|
|
2401
|
+
field = allFields.find((f) => f.name === fieldName);
|
|
2402
|
+
}
|
|
2364
2403
|
if (!field || !field.dependencies) {
|
|
2365
2404
|
return !field?.hidden;
|
|
2366
2405
|
}
|
|
2406
|
+
const fieldFullPath = this.findFieldPath(field.name, topLevelFields) || field.name;
|
|
2407
|
+
const groupPath = fieldFullPath.includes(".") ? fieldFullPath.split(".").slice(0, -1).join(".") : "";
|
|
2408
|
+
let valuesContext = { ...this.state.values };
|
|
2409
|
+
if (groupPath && field.dependencies) {
|
|
2410
|
+
const groupValues = getNestedValue(this.state.values, groupPath);
|
|
2411
|
+
if (groupValues && typeof groupValues === "object") {
|
|
2412
|
+
const createRelativeContext = (obj, prefix = "") => {
|
|
2413
|
+
const result2 = {};
|
|
2414
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
2415
|
+
const relativeKey = prefix ? `${prefix}.${key}` : key;
|
|
2416
|
+
if (value && typeof value === "object" && !Array.isArray(value) && value !== null) {
|
|
2417
|
+
Object.assign(result2, createRelativeContext(value, relativeKey));
|
|
2418
|
+
} else {
|
|
2419
|
+
result2[relativeKey] = value;
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
return result2;
|
|
2423
|
+
};
|
|
2424
|
+
const relativeContext = createRelativeContext(groupValues);
|
|
2425
|
+
valuesContext = { ...this.state.values, ...relativeContext };
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2367
2428
|
const result = this.conditionEngine.evaluateDependencies(
|
|
2368
2429
|
field.dependencies,
|
|
2369
|
-
|
|
2430
|
+
valuesContext
|
|
2370
2431
|
);
|
|
2371
2432
|
this.dependencyCache.set(fieldName, result);
|
|
2372
2433
|
return result.visible && !field.hidden;
|
|
@@ -2441,7 +2502,15 @@ var BaseInput = class {
|
|
|
2441
2502
|
*/
|
|
2442
2503
|
createFieldContainer(input) {
|
|
2443
2504
|
const container = document.createElement("div");
|
|
2444
|
-
|
|
2505
|
+
const inputClasses = Array.from(input.classList);
|
|
2506
|
+
const componentContainerClasses = inputClasses.filter(
|
|
2507
|
+
(cls) => cls.startsWith("easy-form-") && cls !== "easy-form-field" && (cls.includes("-container") || cls.includes("-wrapper"))
|
|
2508
|
+
);
|
|
2509
|
+
if (componentContainerClasses.length > 0) {
|
|
2510
|
+
container.className = `easy-form-field ${componentContainerClasses.join(" ")}`;
|
|
2511
|
+
} else {
|
|
2512
|
+
container.className = "easy-form-field";
|
|
2513
|
+
}
|
|
2445
2514
|
if (this.field.label) {
|
|
2446
2515
|
const label = document.createElement("label");
|
|
2447
2516
|
label.className = "easy-form-label";
|
|
@@ -2688,7 +2757,18 @@ var MaskEngine = class {
|
|
|
2688
2757
|
return value;
|
|
2689
2758
|
}
|
|
2690
2759
|
const customMask = this.getCustomMask(mask);
|
|
2691
|
-
const
|
|
2760
|
+
const editableTokens = tokens.filter((t) => t.editable);
|
|
2761
|
+
const acceptedTypes = new Set(editableTokens.map((t) => t.type));
|
|
2762
|
+
let unformatted = "";
|
|
2763
|
+
for (const char of value) {
|
|
2764
|
+
if (acceptedTypes.has("any")) {
|
|
2765
|
+
unformatted += char;
|
|
2766
|
+
} else if (acceptedTypes.has("digit") && /\d/.test(char)) {
|
|
2767
|
+
unformatted += char;
|
|
2768
|
+
} else if (acceptedTypes.has("letter") && /[a-zA-Z]/.test(char)) {
|
|
2769
|
+
unformatted += char;
|
|
2770
|
+
}
|
|
2771
|
+
}
|
|
2692
2772
|
let formatted = formatValue(unformatted, tokens);
|
|
2693
2773
|
if (customMask.transform) {
|
|
2694
2774
|
formatted = customMask.transform(formatted);
|
|
@@ -2823,7 +2903,9 @@ var TextInput = class extends BaseInput {
|
|
|
2823
2903
|
}
|
|
2824
2904
|
input.value = displayValue;
|
|
2825
2905
|
this.applyCommonProps(input);
|
|
2826
|
-
if (this.
|
|
2906
|
+
if (this.field.placeholder) {
|
|
2907
|
+
input.placeholder = this.field.placeholder;
|
|
2908
|
+
} else if (this.maskEngine && this.field.mask) {
|
|
2827
2909
|
const maskPlaceholder = this.maskEngine.getMaskPlaceholder(this.field.mask);
|
|
2828
2910
|
if (maskPlaceholder) {
|
|
2829
2911
|
input.placeholder = maskPlaceholder;
|
|
@@ -2935,7 +3017,6 @@ var NumberInput = class extends BaseInput {
|
|
|
2935
3017
|
input.type = "number";
|
|
2936
3018
|
input.value = this.value ?? "";
|
|
2937
3019
|
}
|
|
2938
|
-
input.placeholder = this.field.placeholder || "";
|
|
2939
3020
|
const numberField = this.field;
|
|
2940
3021
|
if (!this.maskEngine && input.type === "number") {
|
|
2941
3022
|
if (numberField.min !== void 0) {
|
|
@@ -2949,7 +3030,9 @@ var NumberInput = class extends BaseInput {
|
|
|
2949
3030
|
}
|
|
2950
3031
|
}
|
|
2951
3032
|
this.applyCommonProps(input);
|
|
2952
|
-
if (this.
|
|
3033
|
+
if (this.field.placeholder) {
|
|
3034
|
+
input.placeholder = this.field.placeholder;
|
|
3035
|
+
} else if (this.maskEngine && this.field.mask) {
|
|
2953
3036
|
const maskPlaceholder = this.maskEngine.getMaskPlaceholder(this.field.mask);
|
|
2954
3037
|
if (maskPlaceholder) {
|
|
2955
3038
|
input.placeholder = maskPlaceholder;
|