UNPKG

@lanaco/lnc-react-ui

Version:

React component library

134 lines (133 loc) 2.95 kB
import { jsx as u, Fragment as V } from "react/jsx-runtime"; import { forwardRef as v, useState as O, useEffect as T, useCallback as z } from "react"; import { n as S } from "./emotion-styled.browser.esm-CjCaF13H.js"; import { P as a } from "./index-S5Cd7WrG.js"; import { d as k } from "./index-CkWvbrVT.js"; import { c as w, b as o, a as R, h as j, e as F, d as N } from "./utils-DtRLzzTZ.js"; import { u as P } from "./emotion-element-f0de968e.browser.esm-CkCiQliQ.js"; const U = ({ theme: e, size: d }) => { var l = N(e, d); return ` min-height: ${l}; max-height: ${l}; `; }, W = S.input` ${(e) => U(e)} ${(e) => w(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) => o( e.theme, "Input", e.color, "enabled", "background" )}; border: 1px solid ${(e) => o( e.theme, "Input", e.color, e.disabled === !0 ? "disabled" : "enabled", "border" )}; border-radius: ${(e) => R(e.theme, "regular")}; color: ${(e) => o(e.theme, "Input", e.color, "enabled", "text")}; &:disabled { ${(e) => j(e.theme)}; cursor: default; } &:focus:enabled { border: none; ${(e) => e.readOnly !== !0 ? F(e.theme) : ""}; color: ${(e) => o(e.theme, "Input", "primary", "enabled", "text")}; border: 1px solid ${(e) => o( e.theme, "Input", "primary", e.disabled === !0 ? "disabled" : "enabled", "border" )}; } `, B = v((e, d) => { const { // id, disabled: l, readOnly: m, defaultValue: b, value: r, debounceTime: c = 0, // tabIndex, //---------------- onChange: n, //---------------- className: g = "", style: h = {}, size: p = "small", color: f = "primary", ...y } = e, C = P(), [$, i] = O(r || b || ""); T(() => { r != null && i(r); }, [r]); const x = z( k((t, s) => I(t, s), c), [n] ), I = (t, s) => { n && (n == null || n(t, s)); }; return /* @__PURE__ */ u(V, { children: /* @__PURE__ */ u( W, { type: "time", ref: d, onChange: (t) => { i(t.target.value), x(t, t.target.value); }, disabled: l, readOnly: m, theme: C, color: f, size: p, className: g, style: h, value: $, ...y } ) }); }); B.propTypes = { id: a.string, defaultValue: a.string, value: a.string, disabled: a.bool, readOnly: a.bool, debounceTime: a.number, tabIndex: a.number, //---------------- onChange: a.func, //---------------- className: a.string, style: a.object, size: a.oneOf(["small", "medium", "large"]), color: a.oneOf([ "primary", "secondary", "success", "danger", "warning", "information", "neutral", "gray" ]) }; export { B as default };