diff --git a/src/app/components/generator/McdocRenderer.tsx b/src/app/components/generator/McdocRenderer.tsx index 32543c98..3f8ae36e 100644 --- a/src/app/components/generator/McdocRenderer.tsx +++ b/src/app/components/generator/McdocRenderer.tsx @@ -13,6 +13,7 @@ import config from '../../Config.js' import { useLocale } from '../../contexts/Locale.jsx' import { useFocus } from '../../hooks/useFocus.js' import { generateColor, hexId, randomInt, randomSeed } from '../../Utils.js' +import { Btn } from '../Btn.jsx' import { ItemDisplay } from '../ItemDisplay.jsx' import { Octicon } from '../Octicon.jsx' import { formatIdentifier, getCategory, getDefault, getItemType, isFixedList, isInlineTuple, isListOrArray, isNumericType, isSelectRegistry, quickEqualTypes, simplifyType } from './McdocHelpers.js' @@ -683,37 +684,11 @@ function ListBody({ type: outerType, node, makeEdit, ctx }: Props (node?.children?.length ?? 0) - const onRemoveItem = useCallback((index: number) => { - makeEdit(() => { - node.children.splice(index, 1) - return node - }) - }, [makeEdit, node]) - - const onMoveUp = useCallback((index: number) => { - if (node.children.length <= 1 || index <= 0) { - return - } - makeEdit(() => { - const moved = node.children.splice(index, 1) - node.children.splice(index - 1, 0, ...moved) - return node - }) - }, [makeEdit]) - - const onMoveDown = useCallback((index: number) => { - if (node.children.length <= 1 || index >= node.children.length - 1) { - return - } - makeEdit(() => { - const moved = node.children.splice(index, 1) - node.children.splice(index + 1, 0, ...moved) - return node - }) - }, [makeEdit]) - const onAddBottom = useCallback(() => { if (canAdd) { makeEdit((range) => { @@ -754,52 +729,8 @@ function ListBody({ type: outerType, node, makeEdit, ctx }: Props maxShown) { return <> } - const child = item.value - const itemType = getItemType(type) - const childType = simplifyType(itemType, ctx) - const canToggle = JsonObjectNode.is(child) - const toggled = isToggled(index.toString()) - const isCollapsed = canToggle && (toggled === false || (toggled === undefined && node.children.length > 20)) - const makeItemEdit: MakeEdit = (edit) => { - makeEdit(() => { - const newChild = edit(child?.range ?? item.range) - node.children[index] = { - type: 'item', - range: item.range, - value: newChild, - } - return node - }) - } - const canMoveUp = node.children.length > 1 && index > 0 - const canMoveDown = node.children.length > 1 && index < (node.children.length - 1) - return
-
- - {canToggle && (isCollapsed - ? - : - )} - - {(canMoveUp || canMoveDown) &&
- - -
} - - {!isCollapsed && } -
- {!isCollapsed && (childType.kind === 'struct' - ?
- -
- : )} -
+ const key = index.toString() + return })} {node.children.length > 0 &&
+ : + )} + + {(canMoveUp || canMoveDown) &&
+ + +
} + {active &&
+ +
} + + {!isCollapsed && } +
+ {!isCollapsed && (type.kind === 'struct' + ?
+ +
+ : )} + +} + function TupleHead({ type, optional, node, makeEdit, ctx }: Props) { const { locale } = useLocale() diff --git a/src/styles/nodes.css b/src/styles/nodes.css index 42735a9f..1682db14 100644 --- a/src/styles/nodes.css +++ b/src/styles/nodes.css @@ -294,6 +294,7 @@ button.move:disabled { left: 0; top: 100%; width: min-content; + height: unset; margin-top: 4px; margin-left: 4px; z-index: 1;