Skip to content

Commit

Permalink
add numeric input wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
softmarshmallow committed Feb 28, 2024
1 parent bba24c2 commit 08b74a4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/editor-ui-property/property-input/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { PropertyInput } from "./property-input";
export * from "./property-input";
export type { PropertyInputProps } from "./property-input";
21 changes: 21 additions & 0 deletions packages/editor-ui-property/property-input/property-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,27 @@ export function PropertyInput({
);
}

export function PropertyNumericInput({
onChange,
...props
}: Omit<React.ComponentProps<typeof PropertyInput>, "type" | "onChange"> & {
onChange?: (value: number) => void;
}) {
return (
<PropertyInput
type="number"
{...props}
onChange={(txt) => {
const val = Number(txt);
if (isNaN(val)) {
return;
}
onChange(val);
}}
/>
);
}

const PlainInput = styled.input`
width: 100%;
height: 100%;
Expand Down

0 comments on commit 08b74a4

Please sign in to comment.