🐛 (condition) Greater and Less should compare list length when possible
This commit is contained in:
@@ -63,24 +63,24 @@ const executeComparison =
|
|||||||
return compare((a, b) => a !== b, inputValue, value)
|
return compare((a, b) => a !== b, inputValue, value)
|
||||||
}
|
}
|
||||||
case ComparisonOperators.GREATER: {
|
case ComparisonOperators.GREATER: {
|
||||||
return compare(
|
if (typeof inputValue === 'string') {
|
||||||
(a, b) =>
|
if (typeof value === 'string')
|
||||||
isDefined(a) && isDefined(b)
|
return parseFloat(inputValue) > parseFloat(value)
|
||||||
? parseFloat(a) > parseFloat(b)
|
return parseFloat(inputValue) > value.length
|
||||||
: false,
|
}
|
||||||
inputValue,
|
if (typeof value === 'string')
|
||||||
value
|
return inputValue.length > parseFloat(value)
|
||||||
)
|
return inputValue.length > value.length
|
||||||
}
|
}
|
||||||
case ComparisonOperators.LESS: {
|
case ComparisonOperators.LESS: {
|
||||||
return compare(
|
if (typeof inputValue === 'string') {
|
||||||
(a, b) =>
|
if (typeof value === 'string')
|
||||||
isDefined(a) && isDefined(b)
|
return parseFloat(inputValue) < parseFloat(value)
|
||||||
? parseFloat(a) < parseFloat(b)
|
return parseFloat(inputValue) < value.length
|
||||||
: false,
|
}
|
||||||
inputValue,
|
if (typeof value === 'string')
|
||||||
value
|
return inputValue.length < parseFloat(value)
|
||||||
)
|
return inputValue.length < value.length
|
||||||
}
|
}
|
||||||
case ComparisonOperators.IS_SET: {
|
case ComparisonOperators.IS_SET: {
|
||||||
return isDefined(inputValue) && inputValue.length > 0
|
return isDefined(inputValue) && inputValue.length > 0
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/js",
|
"name": "@typebot.io/js",
|
||||||
"version": "0.0.37",
|
"version": "0.0.38",
|
||||||
"description": "Javascript library to display typebots on your website",
|
"description": "Javascript library to display typebots on your website",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ export const TextInput = (props: Props) => {
|
|||||||
if (e.key === 'Enter') submit()
|
if (e.key === 'Enter') submit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const submitIfCtrlEnter = (e: KeyboardEvent) => {
|
||||||
|
if (!props.block.options.isLong) return
|
||||||
|
if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) submit()
|
||||||
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (!isMobile() && inputRef) inputRef.focus()
|
if (!isMobile() && inputRef) inputRef.focus()
|
||||||
})
|
})
|
||||||
@@ -46,6 +51,7 @@ export const TextInput = (props: Props) => {
|
|||||||
<Textarea
|
<Textarea
|
||||||
ref={inputRef as HTMLTextAreaElement}
|
ref={inputRef as HTMLTextAreaElement}
|
||||||
onInput={handleInput}
|
onInput={handleInput}
|
||||||
|
onKeyDown={submitIfCtrlEnter}
|
||||||
value={inputValue()}
|
value={inputValue()}
|
||||||
placeholder={
|
placeholder={
|
||||||
props.block.options?.labels?.placeholder ?? 'Type your answer...'
|
props.block.options?.labels?.placeholder ?? 'Type your answer...'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/react",
|
"name": "@typebot.io/react",
|
||||||
"version": "0.0.37",
|
"version": "0.0.38",
|
||||||
"description": "React library to display typebots on your website",
|
"description": "React library to display typebots on your website",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user