UNPKG

@lanaco/lnc-react-ui

Version:

React component library

123 lines (122 loc) 2.66 kB
import { jsx as s, Fragment as x } from "react/jsx-runtime"; import { forwardRef as V, useState as k, useEffect as v, useCallback as O } from "react"; import { s as z } from "./emotion-styled.browser.esm-DfbrHHed.js"; import { d as S } from "./index-Dt62UGku.js"; import { d as T, c as a, b as R, i as w, f as F, e as U } from "./utils-BUdHa0nB.js"; import { u as W } from "./emotion-element-f0de968e.browser.esm-CkCiQliQ.js"; const j = ({ theme: e, size: r }) => { var d = U(e, r); return ` min-height: ${d}; max-height: ${d}; `; }, B = z.input` ${(e) => j(e)} ${(e) => T(e.theme, "Input", e.size, "enabled")} padding: 0.625rem 0.75rem 0.62rem 0.75rem; line-height: inherit; appearance: none; outline: none; display: inline-block; border-radius: 0.25rem; width: 100%; box-sizing: border-box; background-color: ${(e) => a( e.theme, "Input", e.color, "enabled", "background" )}; border: 1px solid ${(e) => a( e.theme, "Input", e.color, e.disabled === !0 ? "disabled" : "enabled", "border" )}; border-radius: ${(e) => R(e.theme, "regular")}; color: ${(e) => a(e.theme, "Input", e.color, "enabled", "text")}; &:disabled { /* ${(e) => w(e.theme)}; */ ${(e) => `background-color: ${a( e.theme, "Input", e.color, "disabled", "background", "backgroundOpacity" )}; color: ${(r) => a( r.theme, "Input", r.color, "disabled", "text" )};`} cursor: default; } &:focus:enabled { border: none; ${(e) => e.readOnly !== !0 ? F(e.theme) : ""}; color: ${(e) => a(e.theme, "Input", "primary", "enabled", "text")}; border: 1px solid ${(e) => a( e.theme, "Input", "primary", e.disabled === !0 ? "disabled" : "enabled", "border" )}; } `, J = V((e, r) => { const { // id, disabled: d, readOnly: u, defaultValue: m, value: n, debounceTime: b = 0, // tabIndex, //---------------- onChange: o, //---------------- className: c = "", style: h = {}, size: g = "small", color: f = "primary", ...p } = e, $ = W(), [y, i] = k(n || m || ""); v(() => { n != null && i(n); }, [n]); const C = O( S((t, l) => I(t, l), b), [o] ), I = (t, l) => { o && (o == null || o(t, l)); }; return /* @__PURE__ */ s(x, { children: /* @__PURE__ */ s( B, { type: "time", ref: r, onChange: (t) => { i(t.target.value), C(t, t.target.value); }, disabled: d, readOnly: u, theme: $, color: f, size: g, className: c, style: h, value: y, ...p } ) }); }); export { J as default };