inline-input.tsx 708 B

12345678910111213141516171819202122
  1. import type { ComponentProps } from "solid-js"
  2. import { splitProps } from "solid-js"
  3. export type InlineInputProps = ComponentProps<"input"> & {
  4. width?: string
  5. }
  6. export function InlineInput(props: InlineInputProps) {
  7. const [local, others] = splitProps(props, ["class", "width", "style"])
  8. const style = () => {
  9. if (!local.style) return { width: local.width }
  10. if (typeof local.style === "string") {
  11. if (!local.width) return local.style
  12. return `${local.style};width:${local.width}`
  13. }
  14. if (!local.width) return local.style
  15. return { ...local.style, width: local.width }
  16. }
  17. return <input data-component="inline-input" class={local.class} style={style()} {...others} />
  18. }