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,4 +1,5 @@
import { useState, useEffect } from 'react'
import { create } from 'react-modal-promise'
import { toolTips, useStore } from '../../useStore'
import { BinaryPart, Value, VariableDeclarator } from '../../lang/wasm'
import {
@ -12,12 +13,12 @@ import {
getTransformInfos,
ConstraintType,
} from '../../lang/std/sketchcombos'
import { GetInfoModal, createInfoModal } from '../SetHorVertDistanceModal'
import { GetInfoModal } from '../SetHorVertDistanceModal'
import { createLiteral, createVariableDeclaration } from '../../lang/modifyAst'
import { removeDoubleNegatives } from '../AvailableVarsHelpers'
import { updateCursors } from '../../lang/util'
const getModalInfo = createInfoModal(GetInfoModal)
const getModalInfo = create(GetInfoModal as any)
type ButtonType =
| 'setHorzDistance'
@ -118,46 +119,38 @@ export const SetHorzVertDistance = ({
transformInfos,
programMemory,
})
if (!isAlign) {
const {
segName,
value,
valueNode,
variableName,
newVariableInsertIndex,
sign,
} = await getModalInfo({
const {
segName,
value,
valueNode,
variableName,
newVariableInsertIndex,
sign,
}: {
segName: string
value: number
valueNode: Value
variableName?: string
newVariableInsertIndex: number
sign: number
} = await (!isAlign &&
getModalInfo({
segName: tagInfo?.tag,
isSegNameEditable: !tagInfo?.isTagExisting,
value: valueUsedInTransform,
initialVariableName:
constraint === 'setHorzDistance' ? 'xDis' : 'yDis',
} as any))
if (segName === tagInfo?.tag && value === valueUsedInTransform) {
updateAst(modifiedAst, true, {
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
})
if (
segName === tagInfo?.tag &&
value ===
(valueUsedInTransform === undefined
? ''
: String(Math.abs(valueUsedInTransform)))
) {
updateAst(modifiedAst, true, {
callBack: updateCursors(
setCursor,
selectionRanges,
pathToNodeMap
),
})
}
const finalValue = removeDoubleNegatives(
valueNode as BinaryPart,
sign,
variableName
)
const { modifiedAst: _modifiedAst, pathToNodeMap: _pathToNodeMap } =
} else {
let finalValue = isAlign
? createLiteral(0)
: removeDoubleNegatives(valueNode as BinaryPart, sign, variableName)
// transform again but forcing certain values
const { modifiedAst: _modifiedAst, pathToNodeMap } =
transformSecondarySketchLinesTagFirst({
ast,
selectionRanges,
@ -166,7 +159,6 @@ export const SetHorzVertDistance = ({
forceSegName: segName,
forceValueUsedInTransform: finalValue,
})
if (variableName) {
const newBody = [..._modifiedAst.body]
newBody.splice(
@ -176,24 +168,8 @@ export const SetHorzVertDistance = ({
)
_modifiedAst.body = newBody
}
updateAst(_modifiedAst, true, {
callBack: updateCursors(setCursor, selectionRanges, _pathToNodeMap),
})
} else {
const finalValue = createLiteral(0)
const { modifiedAst: _modifiedAst, pathToNodeMap: _pathToNodeMap } =
transformSecondarySketchLinesTagFirst({
ast,
selectionRanges,
transformInfos,
programMemory,
forceValueUsedInTransform: finalValue,
})
updateAst(_modifiedAst, true, {
callBack: updateCursors(setCursor, selectionRanges, _pathToNodeMap),
callBack: updateCursors(setCursor, selectionRanges, pathToNodeMap),
})
}
}}