UNPKG

alinea

Version:

[![npm](https://img.shields.io/npm/v/alinea.svg)](https://npmjs.org/package/alinea) [![install size](https://packagephobia.com/badge?p=alinea)](https://packagephobia.com/result?p=alinea)

57 lines (53 loc) 1.78 kB
import "../../chunks/chunk-U5RRZUYZ.js"; // src/input/code/CodeField.browser.tsx import { Field } from "alinea/core"; import { useField } from "alinea/dashboard/editor/UseField"; import { InputLabel } from "alinea/dashboard/view/InputLabel"; import { HStack, fromModule } from "alinea/ui"; import { IcRoundCode } from "alinea/ui/icons/IcRoundCode"; import { TextareaAutosize } from "alinea/ui/util/TextareaAutosize"; import { useState } from "react"; import { code as createCode } from "./CodeField.js"; // src/input/code/CodeInput.module.scss var CodeInput_module_default = { "root-input": "alinea-CodeInput-input", "rootInput": "alinea-CodeInput-input" }; // src/input/code/CodeField.browser.tsx export * from "./CodeField.js"; import { jsx } from "react/jsx-runtime"; var code = Field.provideView(CodeInput, createCode); var styles = fromModule(CodeInput_module_default); function CodeInput({ field }) { const { value, mutator, label, options } = useField(field); const [focus, setFocus] = useState(false); const placeholder = options.inline ? String(label) : ""; const empty = value === ""; return /* @__PURE__ */ jsx( InputLabel, { asLabel: true, ...options, focused: focus, icon: IcRoundCode, empty, children: /* @__PURE__ */ jsx(HStack, { center: true, gap: 8, children: /* @__PURE__ */ jsx( TextareaAutosize, { className: styles.root.input(), type: "text", value: value || "", onChange: (e) => mutator(e.currentTarget.value), onFocus: () => setFocus(true), onBlur: () => setFocus(false), placeholder, spellCheck: "false", disabled: options.readOnly } ) }) } ); } export { code };