Revert "Improve Prop Typings for Modals. Remove instances of any. (… (#813)

Revert "Improve Prop Typings for Modals. Remove instances of `any`. (#792)"

This reverts commit 629f326f4c.
This commit is contained in:
Kurt Hutten
2023-10-10 06:43:25 +11:00
committed by GitHub
parent 629f326f4c
commit 9822576077
9 changed files with 130 additions and 210 deletions

View File

@ -1,6 +1,5 @@
import { Dialog, Transition } from '@headlessui/react'
import { Fragment, useState } from 'react'
import { type InstanceProps, create } from 'react-modal-promise'
import { Value } from '../lang/wasm'
import {
AvailableVars,
@ -10,30 +9,6 @@ import {
CreateNewVariable,
} from './AvailableVarsHelpers'
type ModalResolve = {
value: string
segName: string
valueNode: Value
variableName?: string
newVariableInsertIndex: number
sign: number
}
type ModalReject = boolean
type GetInfoModalProps = InstanceProps<ModalResolve, ModalReject> & {
segName: string
isSegNameEditable: boolean
value?: number
initialVariableName: string
}
export const createInfoModal = create<
GetInfoModalProps,
ModalResolve,
ModalReject
>
export const GetInfoModal = ({
isOpen,
onResolve,
@ -42,12 +17,25 @@ export const GetInfoModal = ({
isSegNameEditable,
value: initialValue,
initialVariableName,
}: GetInfoModalProps) => {
}: {
isOpen: boolean
onResolve: (a: {
value: string
segName: string
valueNode: Value
variableName?: string
newVariableInsertIndex: number
sign: number
}) => void
onReject: (a: any) => void
segName: string
isSegNameEditable: boolean
value: number
initialVariableName: string
}) => {
const [sign, setSign] = useState(Math.sign(Number(initialValue)))
const [segName, setSegName] = useState(initialSegName)
const [value, setValue] = useState(
initialValue === undefined ? '' : String(Math.abs(initialValue))
)
const [value, setValue] = useState(String(Math.abs(initialValue)))
const [shouldCreateVariable, setShouldCreateVariable] = useState(false)
const {