lisichatbot 2.0.4 → 2.0.5
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/package.json +1 -1
- package/src/index.js +58 -8
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -36,6 +36,7 @@ let config = {
|
|
|
36
36
|
enableAnimations: true,
|
|
37
37
|
showCancelButton: false, // ✅ NEW: Control cancel button visibility
|
|
38
38
|
nextButtonText: null, // ✅ NEW: Global next button text (null = use original)
|
|
39
|
+
localeString: null, // ✅ NEW: Locale for number formatting (e.g., 'nb-NO', 'en-US')
|
|
39
40
|
customRangeErrors: {
|
|
40
41
|
minRequired: 'Minimum value is required',
|
|
41
42
|
maxRequired: 'Maximum value is required',
|
|
@@ -1614,9 +1615,21 @@ function validateMinMax(field, customConfig, showErrors = false) {
|
|
|
1614
1615
|
|
|
1615
1616
|
let displayName = `${minValue}-${maxValue}`;
|
|
1616
1617
|
if (valueType === 'arrayRange') {
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1618
|
+
// ✅ NEW: Check if both values are 0
|
|
1619
|
+
if (minValue === 0 && maxValue === 0) {
|
|
1620
|
+
const formattedZero = config.localeString
|
|
1621
|
+
? (0).toLocaleString(config.localeString)
|
|
1622
|
+
: (0).toLocaleString();
|
|
1623
|
+
displayName = formattedZero;
|
|
1624
|
+
} else {
|
|
1625
|
+
const formattedMin = config.localeString
|
|
1626
|
+
? minValue.toLocaleString(config.localeString)
|
|
1627
|
+
: minValue.toLocaleString();
|
|
1628
|
+
const formattedMax = config.localeString
|
|
1629
|
+
? maxValue.toLocaleString(config.localeString)
|
|
1630
|
+
: maxValue.toLocaleString();
|
|
1631
|
+
displayName = `${formattedMin} - ${formattedMax}`;
|
|
1632
|
+
}
|
|
1620
1633
|
}
|
|
1621
1634
|
|
|
1622
1635
|
if (prefix) displayName = `${prefix} ${displayName}`;
|
|
@@ -2163,9 +2176,22 @@ async function handleNext() {
|
|
|
2163
2176
|
|
|
2164
2177
|
if (valueType === 'arrayRange' && Array.isArray(chatState.currentSelection.value)) {
|
|
2165
2178
|
const [min, max] = chatState.currentSelection.value;
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2179
|
+
|
|
2180
|
+
// ✅ NEW: Check if both values are 0
|
|
2181
|
+
if (min === 0 && max === 0) {
|
|
2182
|
+
const formattedZero = config.localeString
|
|
2183
|
+
? (0).toLocaleString(config.localeString)
|
|
2184
|
+
: (0).toLocaleString();
|
|
2185
|
+
displayName = formattedZero;
|
|
2186
|
+
} else {
|
|
2187
|
+
const formattedMin = config.localeString
|
|
2188
|
+
? min.toLocaleString(config.localeString)
|
|
2189
|
+
: min.toLocaleString();
|
|
2190
|
+
const formattedMax = config.localeString
|
|
2191
|
+
? max.toLocaleString(config.localeString)
|
|
2192
|
+
: max.toLocaleString();
|
|
2193
|
+
displayName = `${formattedMin} - ${formattedMax}`;
|
|
2194
|
+
}
|
|
2169
2195
|
}
|
|
2170
2196
|
|
|
2171
2197
|
if (prefix) displayName = `${prefix} ${displayName}`;
|
|
@@ -3216,10 +3242,33 @@ async function showNextStep() {
|
|
|
3216
3242
|
setTimeout(() => {
|
|
3217
3243
|
// ✅ NEW: Add user message if there's a currentSelection (pre-filled value)
|
|
3218
3244
|
if (chatState.currentSelection && chatState.currentSelection.name) {
|
|
3219
|
-
const
|
|
3220
|
-
const
|
|
3245
|
+
const inputConfig = nextStep.input || {};
|
|
3246
|
+
const valueType = inputConfig.selectedInputValueType;
|
|
3247
|
+
const prefix = inputConfig.selectedInputPrefix || '';
|
|
3248
|
+
const suffix = inputConfig.selectedInputSuffix || '';
|
|
3221
3249
|
let displayName = chatState.currentSelection.name;
|
|
3222
3250
|
|
|
3251
|
+
// ✅ NEW: Format arrayRange values with locale
|
|
3252
|
+
if (valueType === 'arrayRange' && Array.isArray(chatState.currentSelection.value)) {
|
|
3253
|
+
const [min, max] = chatState.currentSelection.value;
|
|
3254
|
+
|
|
3255
|
+
// ✅ Check if both values are 0
|
|
3256
|
+
if (min === 0 && max === 0) {
|
|
3257
|
+
const formattedZero = config.localeString
|
|
3258
|
+
? (0).toLocaleString(config.localeString)
|
|
3259
|
+
: (0).toLocaleString();
|
|
3260
|
+
displayName = formattedZero;
|
|
3261
|
+
} else {
|
|
3262
|
+
const formattedMin = config.localeString
|
|
3263
|
+
? min.toLocaleString(config.localeString)
|
|
3264
|
+
: min.toLocaleString();
|
|
3265
|
+
const formattedMax = config.localeString
|
|
3266
|
+
? max.toLocaleString(config.localeString)
|
|
3267
|
+
: max.toLocaleString();
|
|
3268
|
+
displayName = `${formattedMin} - ${formattedMax}`;
|
|
3269
|
+
}
|
|
3270
|
+
}
|
|
3271
|
+
|
|
3223
3272
|
if (prefix) displayName = `${prefix} ${displayName}`;
|
|
3224
3273
|
if (suffix) displayName = `${displayName} ${suffix}`;
|
|
3225
3274
|
|
|
@@ -3407,6 +3456,7 @@ function init(flowName, flowConfig, options = {}) {
|
|
|
3407
3456
|
autoAdvanceDelay: config.autoAdvanceDelay,
|
|
3408
3457
|
showCancelButton: config.showCancelButton,
|
|
3409
3458
|
nextButtonText: config.nextButtonText || 'not set',
|
|
3459
|
+
localeString: config.localeString || 'default',
|
|
3410
3460
|
customRangeErrors: config.customRangeErrors
|
|
3411
3461
|
});
|
|
3412
3462
|
|