lisichatbot 1.8.7 → 1.8.8

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +59 -28
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisichatbot",
3
- "version": "1.8.7",
3
+ "version": "1.8.8",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
package/src/index.js CHANGED
@@ -1075,13 +1075,16 @@ function renderMinMaxInputs(field, customConfig, existingData) {
1075
1075
  if (minInput) {
1076
1076
  minInput.setAttribute('data-field', field);
1077
1077
  minInput.setAttribute('data-input-type', 'min');
1078
- minInput.type = 'number';
1079
- minInput.min = customConfig.min !== undefined ? customConfig.min : 0;
1080
- minInput.max = customConfig.max !== undefined ? customConfig.max : 100;
1081
- minInput.value = showMinMax && existingData[0] !== undefined ? existingData[0] : '';
1078
+ minInput.type = 'text'; // Changed from 'number' to 'text' for locale formatting
1079
+ minInput.setAttribute('inputmode', 'numeric'); // Show numeric keyboard on mobile
1080
+ minInput.setAttribute('data-min', customConfig.min !== undefined ? customConfig.min : 0);
1081
+ minInput.setAttribute('data-max', customConfig.max !== undefined ? customConfig.max : 100);
1082
1082
 
1083
- if (showMinMax) {
1084
- console.log(` ✅ Pre-filled min: ${existingData[0]}`);
1083
+ if (showMinMax && existingData[0] !== undefined) {
1084
+ const numValue = Number(existingData[0]);
1085
+ minInput.value = numValue.toLocaleString();
1086
+ minInput.setAttribute('data-raw-value', existingData[0]);
1087
+ console.log(` ✅ Pre-filled min: ${existingData[0]} (display: ${numValue.toLocaleString()})`);
1085
1088
  }
1086
1089
  }
1087
1090
 
@@ -1096,13 +1099,16 @@ function renderMinMaxInputs(field, customConfig, existingData) {
1096
1099
  if (maxInput) {
1097
1100
  maxInput.setAttribute('data-field', field);
1098
1101
  maxInput.setAttribute('data-input-type', 'max');
1099
- maxInput.type = 'number';
1100
- maxInput.min = customConfig.min !== undefined ? customConfig.min : 0;
1101
- maxInput.max = customConfig.max !== undefined ? customConfig.max : 100;
1102
- maxInput.value = showMinMax && existingData[1] !== undefined ? existingData[1] : '';
1102
+ maxInput.type = 'text'; // Changed from 'number' to 'text' for locale formatting
1103
+ maxInput.setAttribute('inputmode', 'numeric'); // Show numeric keyboard on mobile
1104
+ maxInput.setAttribute('data-min', customConfig.min !== undefined ? customConfig.min : 0);
1105
+ maxInput.setAttribute('data-max', customConfig.max !== undefined ? customConfig.max : 100);
1103
1106
 
1104
- if (showMinMax) {
1105
- console.log(` ✅ Pre-filled max: ${existingData[1]}`);
1107
+ if (showMinMax && existingData[1] !== undefined) {
1108
+ const numValue = Number(existingData[1]);
1109
+ maxInput.value = numValue.toLocaleString();
1110
+ maxInput.setAttribute('data-raw-value', existingData[1]);
1111
+ console.log(` ✅ Pre-filled max: ${existingData[1]} (display: ${numValue.toLocaleString()})`);
1106
1112
  }
1107
1113
  }
1108
1114
 
@@ -1137,8 +1143,8 @@ function renderMinMaxInputs(field, customConfig, existingData) {
1137
1143
 
1138
1144
  if (minInput && maxInput) {
1139
1145
  const updateVisualFeedback = () => {
1140
- const minFilled = minInput.value.trim() !== '';
1141
- const maxFilled = maxInput.value.trim() !== '';
1146
+ const minFilled = (minInput.getAttribute('data-raw-value') || minInput.value.trim()) !== '';
1147
+ const maxFilled = (maxInput.getAttribute('data-raw-value') || maxInput.value.trim()) !== '';
1142
1148
  const anyFilled = minFilled || maxFilled;
1143
1149
 
1144
1150
  const minTick = minClone.querySelector('[data-chat-input-element="tick-icon"]');
@@ -1163,20 +1169,40 @@ function renderMinMaxInputs(field, customConfig, existingData) {
1163
1169
  console.log(' ✅ Applied visual feedback for pre-filled values');
1164
1170
  }
1165
1171
 
1166
- minInput.onfocus = () => {
1172
+ minInput.onchange = () => {
1167
1173
  selectCustomOption(field);
1168
- updateVisualFeedback();
1169
- };
1170
- minInput.oninput = () => {
1174
+ // Remove non-numeric characters except minus sign at start
1175
+ let value = minInput.value.replace(/[^\d-]/g, '');
1176
+ if (value.indexOf('-') > 0) {
1177
+ value = value.replace(/-/g, '');
1178
+ }
1179
+ minInput.setAttribute('data-raw-value', value);
1180
+
1181
+ // Format with locale string if valid number
1182
+ if (value && value !== '' && !isNaN(value)) {
1183
+ const numValue = Number(value);
1184
+ minInput.value = numValue.toLocaleString();
1185
+ }
1186
+
1171
1187
  updateVisualFeedback();
1172
1188
  validateMinMax(field, customConfig);
1173
1189
  };
1174
1190
 
1175
- maxInput.onfocus = () => {
1191
+ maxInput.onchange = () => {
1176
1192
  selectCustomOption(field);
1177
- updateVisualFeedback();
1178
- };
1179
- maxInput.oninput = () => {
1193
+ // Remove non-numeric characters except minus sign at start
1194
+ let value = maxInput.value.replace(/[^\d-]/g, '');
1195
+ if (value.indexOf('-') > 0) {
1196
+ value = value.replace(/-/g, '');
1197
+ }
1198
+ maxInput.setAttribute('data-raw-value', value);
1199
+
1200
+ // Format with locale string if valid number
1201
+ if (value && value !== '' && !isNaN(value)) {
1202
+ const numValue = Number(value);
1203
+ maxInput.value = numValue.toLocaleString();
1204
+ }
1205
+
1180
1206
  updateVisualFeedback();
1181
1207
  validateMinMax(field, customConfig);
1182
1208
  };
@@ -1328,10 +1354,12 @@ function handleCustomSelectClick(element, field, customConfig) {
1328
1354
 
1329
1355
  if (minInput) {
1330
1356
  minInput.value = '';
1357
+ minInput.removeAttribute('data-raw-value');
1331
1358
  console.log(' 🧹 Cleared min input');
1332
1359
  }
1333
1360
  if (maxInput) {
1334
1361
  maxInput.value = '';
1362
+ maxInput.removeAttribute('data-raw-value');
1335
1363
  console.log(' 🧹 Cleared max input');
1336
1364
  }
1337
1365
 
@@ -1401,17 +1429,20 @@ function validateMinMax(field, customConfig) {
1401
1429
  return { valid: false, error: null };
1402
1430
  }
1403
1431
 
1404
- const minValue = parseFloat(minInput.value);
1405
- const maxValue = parseFloat(maxInput.value);
1406
- const minFilled = minInput.value.trim() !== '';
1407
- const maxFilled = maxInput.value.trim() !== '';
1432
+ // Use data-raw-value for validation instead of formatted display value
1433
+ const minRawValue = minInput.getAttribute('data-raw-value') || '';
1434
+ const maxRawValue = maxInput.getAttribute('data-raw-value') || '';
1435
+ const minValue = parseFloat(minRawValue);
1436
+ const maxValue = parseFloat(maxRawValue);
1437
+ const minFilled = minRawValue.trim() !== '';
1438
+ const maxFilled = maxRawValue.trim() !== '';
1408
1439
 
1409
1440
  const minConstraint = customConfig.min !== undefined ? customConfig.min : 0;
1410
1441
  const maxConstraint = customConfig.max !== undefined ? customConfig.max : 100;
1411
1442
 
1412
1443
  console.log(`📊 Input values:
1413
- Min input value: "${minInput.value}" (filled: ${minFilled}, parsed: ${minValue})
1414
- Max input value: "${maxInput.value}" (filled: ${maxFilled}, parsed: ${maxValue})`);
1444
+ Min raw value: "${minRawValue}" (filled: ${minFilled}, parsed: ${minValue})
1445
+ Max raw value: "${maxRawValue}" (filled: ${maxFilled}, parsed: ${maxValue})`);
1415
1446
 
1416
1447
  console.log(`📏 Constraints:
1417
1448
  Min constraint: >= ${minConstraint}