feat: main Added click away logic to commander
This commit is contained in:
parent
a95e6833fb
commit
0a99a50746
@ -3,6 +3,7 @@ import { Center, Box, Flex, Input } from '@chakra-ui/react'
|
|||||||
import { useThingtime } from '../Thingtime/useThingtime'
|
import { useThingtime } from '../Thingtime/useThingtime'
|
||||||
import { Thingtime } from '../Thingtime/Thingtime'
|
import { Thingtime } from '../Thingtime/Thingtime'
|
||||||
import { sanitise } from '~/functions/path'
|
import { sanitise } from '~/functions/path'
|
||||||
|
import ClickAwayListener from 'react-click-away-listener'
|
||||||
|
|
||||||
export const Commander = props => {
|
export const Commander = props => {
|
||||||
const { thingtime, setThingtime, getThingtime, thingtimeRef } = useThingtime()
|
const { thingtime, setThingtime, getThingtime, thingtimeRef } = useThingtime()
|
||||||
@ -175,7 +176,12 @@ export const Commander = props => {
|
|||||||
const fn = `() => { return ${escapedCommandValue} }`
|
const fn = `() => { return ${escapedCommandValue} }`
|
||||||
const evalFn = eval(fn)
|
const evalFn = eval(fn)
|
||||||
const realVal = evalFn()
|
const realVal = evalFn()
|
||||||
|
const prevVal = getThingtime(commandPath)
|
||||||
setThingtime(commandPath, realVal)
|
setThingtime(commandPath, realVal)
|
||||||
|
if (!prevVal) {
|
||||||
|
setContextPath(commandPath)
|
||||||
|
setShowContext(true, 'commandIsAction check')
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log('setThingtime errored in Commander', err)
|
console.log('setThingtime errored in Commander', err)
|
||||||
}
|
}
|
||||||
@ -277,6 +283,7 @@ export const Commander = props => {
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<ClickAwayListener onClickAway={closeCommander}>
|
||||||
<Flex
|
<Flex
|
||||||
id='commander'
|
id='commander'
|
||||||
// display={['flex', showCommander ? 'flex' : 'none']}
|
// display={['flex', showCommander ? 'flex' : 'none']}
|
||||||
@ -395,5 +402,6 @@ export const Commander = props => {
|
|||||||
></Input>
|
></Input>
|
||||||
</Center>
|
</Center>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
</ClickAwayListener>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
"isbot": "latest",
|
"isbot": "latest",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
|
"react-click-away-listener": "^2.2.3",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"uuid": "^9.0.0"
|
"uuid": "^9.0.0"
|
||||||
},
|
},
|
||||||
|
@ -32,6 +32,9 @@ dependencies:
|
|||||||
react:
|
react:
|
||||||
specifier: ^18.2.0
|
specifier: ^18.2.0
|
||||||
version: 18.2.0
|
version: 18.2.0
|
||||||
|
react-click-away-listener:
|
||||||
|
specifier: ^2.2.3
|
||||||
|
version: 2.2.3(react-dom@18.2.0)(react@18.2.0)
|
||||||
react-dom:
|
react-dom:
|
||||||
specifier: ^18.2.0
|
specifier: ^18.2.0
|
||||||
version: 18.2.0(react@18.2.0)
|
version: 18.2.0(react@18.2.0)
|
||||||
@ -7644,6 +7647,16 @@ packages:
|
|||||||
iconv-lite: 0.4.24
|
iconv-lite: 0.4.24
|
||||||
unpipe: 1.0.0
|
unpipe: 1.0.0
|
||||||
|
|
||||||
|
/react-click-away-listener@2.2.3(react-dom@18.2.0)(react@18.2.0):
|
||||||
|
resolution: {integrity: sha512-p63JRQtK9d085+QHUJ2Pje22P/N4tEaXsS2x7tbbptriQqZ9o8xEk7G1JrxwND5YmEVc/VO4fC3+cSBsqqgLUQ==}
|
||||||
|
peerDependencies:
|
||||||
|
react: ^16.8.0 || ^17.0.0 || ^18.0.0
|
||||||
|
react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0
|
||||||
|
dependencies:
|
||||||
|
react: 18.2.0
|
||||||
|
react-dom: 18.2.0(react@18.2.0)
|
||||||
|
dev: false
|
||||||
|
|
||||||
/react-clientside-effect@1.2.6(react@18.2.0):
|
/react-clientside-effect@1.2.6(react@18.2.0):
|
||||||
resolution: {integrity: sha512-XGGGRQAKY+q25Lz9a/4EPqom7WRjz3z9R2k4jhVKA/puQFH/5Nt27vFZYql4m4NVNdUvX8PS3O7r/Zzm7cjUlg==}
|
resolution: {integrity: sha512-XGGGRQAKY+q25Lz9a/4EPqom7WRjz3z9R2k4jhVKA/puQFH/5Nt27vFZYql4m4NVNdUvX8PS3O7r/Zzm7cjUlg==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
|
Loading…
Reference in New Issue
Block a user