feat: add more transform trigger point
All checks were successful
/ deploy_site (push) Successful in 3m46s

This commit is contained in:
Minhyeok Park 2024-11-12 11:14:53 +09:00
parent 735284416a
commit c56390050d
Signed by: pmh_only
SSH Key Fingerprint: SHA256:g/OyGvi2pcd8ub9mqge/ohmDP0fZX/xOPWPIcM+9XpI

View File

@ -32,6 +32,14 @@ export const TransformGridItem: FC<TransformGridItemProp> = ({ transform }) => {
value: '' value: ''
}) })
const triggerTransform = async () =>
await transform
.fn(value, options)
.then((result) => {
setResult(result)
return result
})
useEffect(() => { useEffect(() => {
setAlreadyClosed(closed) setAlreadyClosed(closed)
}, []) }, [])
@ -40,9 +48,7 @@ export const TransformGridItem: FC<TransformGridItemProp> = ({ transform }) => {
if (closed) if (closed)
return return
transform triggerTransform()
.fn(value, options)
.then(setResult.bind(this))
}, [value, options, closed]) }, [value, options, closed])
useEffect(() => { useEffect(() => {
@ -54,6 +60,7 @@ export const TransformGridItem: FC<TransformGridItemProp> = ({ transform }) => {
if (previewDisabled) { if (previewDisabled) {
setClosed(alreadyClosed) setClosed(alreadyClosed)
triggerTransform()
setPreviewDisabled(false) setPreviewDisabled(false)
} }
}, [value]) }, [value])
@ -107,17 +114,23 @@ export const TransformGridItem: FC<TransformGridItemProp> = ({ transform }) => {
setOptions(new Map(options)) setOptions(new Map(options))
} }
const onForwardButtonPressed = () => { const onForwardButtonPressed = async () => {
const result =
await triggerTransform()
if (result.error) if (result.error)
return return
setValue(result.value) setValue(result.value)
} }
const onLabelClicked = () => { const onLabelClicked = async () => {
if (previewDisabled) if (previewDisabled)
return return
if (closed)
triggerTransform()
setClosed(!closed) setClosed(!closed)
setAlreadyClosed(!closed) setAlreadyClosed(!closed)
} }