@purr-react-styled-components/components.text-field 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_types.d.ts +0 -4
- package/dist/index.cjs +1 -1
- package/dist/index.js +60 -69
- package/package.json +8 -10
package/dist/_types.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { ChangeEvent, FocusEventHandler, HTMLAttributes, InputHTMLAttributes } from 'react';
|
|
2
2
|
import { FieldError } from 'react-hook-form';
|
|
3
3
|
import { IExtendable } from '@purr-core/utils.definitions';
|
|
4
|
-
import { IHelperTextProps } from '@purr-react-styled-components/components.helper-text';
|
|
5
|
-
import { ILabelProps } from '@purr-react-styled-components/components.label';
|
|
6
4
|
import { IPostAdornmentProps } from '@purr-react-styled-components/components.post-adornment';
|
|
7
5
|
import { IPreAdornmentProps } from '@purr-react-styled-components/components.pre-adornment';
|
|
8
6
|
|
|
@@ -16,10 +14,8 @@ export interface ITextFieldProps {
|
|
|
16
14
|
clear?: () => void;
|
|
17
15
|
htmlAttributes?: HTMLAttributes<HTMLDivElement> & IExtendable;
|
|
18
16
|
inputHtmlAttributes?: InputHTMLAttributes<HTMLInputElement> & IExtendable;
|
|
19
|
-
labelProps?: ILabelProps;
|
|
20
17
|
preAdornmentProps?: IPreAdornmentProps;
|
|
21
18
|
postAdornmentProps?: IPostAdornmentProps;
|
|
22
|
-
helperTextProps?: IHelperTextProps;
|
|
23
19
|
className?: string;
|
|
24
20
|
fullWidth?: boolean;
|
|
25
21
|
disabled?: boolean;
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var T=Object.create;var y=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var k=(e,t,i,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of O(t))!V.call(e,a)&&a!==i&&y(e,a,{get:()=>t[a],enumerable:!(l=L(t,a))||l.enumerable});return e};var b=(e,t,i)=>(i=e!=null?T(R(e)):{},k(t||!e||!e.__esModule?y(i,"default",{value:e,enumerable:!0}):i,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),$=require("clsx"),c=require("react"),B=require("@purr-core/hooks.focus-with-callback"),M=require("@purr-core/hooks.sync-state-with-props"),h=require("styled-components"),W=require("@purr-react-styled-components/utils.helpers"),D=e=>{let t=0,i=0;const l=(e==null?void 0:e.$variant)==="standard"?0:14;return e!=null&&e.$hasPreAdornment?t=32+l:t=l,e!=null&&e.$hasPostAdornment?i=32+l:i=l,h.css(["padding:0px ","px 0px ","px;"],i,t)},o={Container:h.div.withConfig({displayName:"_style__Container",componentId:"sc-8htvm-0"})(["transition:all 200ms ease-in-out;position:relative;width:",";height:56px;border-radius:4px;",";"],({$fullWidth:e})=>e?"100%":"210px",W.getVariantStyle),Input:h.input.withConfig({displayName:"_style__Input",componentId:"sc-8htvm-1"})(["box-sizing:border-box;transition:all 200ms ease-in-out;width:100%;margin-top:",";height:",";line-height:",";background-color:transparent;color:#ffffff;border-radius:4px;border:none;font-size:16px;",";&:focus-visible{outline:none;}&:disabled{color:#ffffff80;}"],({$hasLabel:e})=>e?"12px":"0px",({$hasLabel:e})=>e?"44px":"56px",({$hasLabel:e})=>e?"44px":"56px",D)},E=c.lazy(()=>import("@purr-react-styled-components/components.post-adornment").then(e=>({default:e.PostAdornment}))),G=c.lazy(()=>import("@purr-react-styled-components/components.pre-adornment").then(e=>({default:e.PreAdornment}))),S=c.forwardRef(({value:e="",variant:t="standard",onChange:i,onFocus:l,onBlur:a,clear:r,htmlAttributes:v,inputHtmlAttributes:j,preAdornmentProps:n,postAdornmentProps:u,className:q="",fullWidth:g=!1,disabled:s=!1,required:f=!1,error:_=null,isStandalone:w=!1},F)=>{const{currentValue:C,setCurrentValue:I}=M(e,w),{captureOnFocus:N,captureOnBlur:m}=B({onFocus:l,onBlur:a}),z=x=>{i==null||i(x.target.value,x),I(x.target.value)};return d.jsxs(o.Container,{...v,$fullWidth:g,$variant:t,$disabled:s,className:$("text-field",g&&"text-field--full-width",f&&"text-field--required",s&&"text-field--disabled",_&&"text-field--error",`text-field--variant-${t}`,q),children:[d.jsx(c.Suspense,{children:!!(n!=null&&n.children)&&d.jsx(G,{...n,hasLabel:!0,variant:t})}),d.jsx(o.Input,{...j,$variant:t,$hasPreAdornment:!!(n!=null&&n.children),$hasPostAdornment:!!r||!!(u!=null&&u.children),$hasLabel:!0,ref:F,value:C,disabled:s,required:f,onChange:z,onFocus:N,onBlur:m,className:$("text-field-input",`text-field-input--variant-${t}`,s&&"text-field-input--disabled",f&&"text-field-input--required")}),d.jsx(c.Suspense,{children:!!(u!=null&&u.children)&&d.jsx(E,{...u,clear:r,variant:t})})]})});S.displayName="TextField";exports.TextField=S;
|
package/dist/index.js
CHANGED
|
@@ -1,81 +1,72 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { lazy as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { getVariantStyle as
|
|
8
|
-
const
|
|
9
|
-
let
|
|
10
|
-
const
|
|
11
|
-
return
|
|
12
|
-
},
|
|
13
|
-
Container:
|
|
1
|
+
import { jsxs as L, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import s from "clsx";
|
|
3
|
+
import { lazy as g, forwardRef as V, Suspense as r } from "react";
|
|
4
|
+
import j from "@purr-core/hooks.focus-with-callback";
|
|
5
|
+
import k from "@purr-core/hooks.sync-state-with-props";
|
|
6
|
+
import m, { css as B } from "styled-components";
|
|
7
|
+
import { getVariantStyle as O } from "@purr-react-styled-components/utils.helpers";
|
|
8
|
+
const R = (t) => {
|
|
9
|
+
let e = 0, i = 0;
|
|
10
|
+
const f = (t == null ? void 0 : t.$variant) === "standard" ? 0 : 14;
|
|
11
|
+
return t != null && t.$hasPreAdornment ? e = 32 + f : e = f, t != null && t.$hasPostAdornment ? i = 32 + f : i = f, B(["padding:0px ", "px 0px ", "px;"], i, e);
|
|
12
|
+
}, o = {
|
|
13
|
+
Container: m.div.withConfig({
|
|
14
14
|
displayName: "_style__Container",
|
|
15
15
|
componentId: "sc-8htvm-0"
|
|
16
16
|
})(["transition:all 200ms ease-in-out;position:relative;width:", ";height:56px;border-radius:4px;", ";"], ({
|
|
17
|
-
$fullWidth:
|
|
18
|
-
}) =>
|
|
19
|
-
Input:
|
|
17
|
+
$fullWidth: t
|
|
18
|
+
}) => t ? "100%" : "210px", O),
|
|
19
|
+
Input: m.input.withConfig({
|
|
20
20
|
displayName: "_style__Input",
|
|
21
21
|
componentId: "sc-8htvm-1"
|
|
22
22
|
})(["box-sizing:border-box;transition:all 200ms ease-in-out;width:100%;margin-top:", ";height:", ";line-height:", ";background-color:transparent;color:#ffffff;border-radius:4px;border:none;font-size:16px;", ";&:focus-visible{outline:none;}&:disabled{color:#ffffff80;}"], ({
|
|
23
|
-
$hasLabel:
|
|
24
|
-
}) =>
|
|
25
|
-
$hasLabel:
|
|
26
|
-
}) =>
|
|
27
|
-
$hasLabel:
|
|
28
|
-
}) =>
|
|
29
|
-
},
|
|
30
|
-
default:
|
|
31
|
-
}))),
|
|
32
|
-
default:
|
|
33
|
-
}))),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
fullWidth: s = !1,
|
|
52
|
-
disabled: h = !1,
|
|
53
|
-
required: x = !1,
|
|
54
|
-
error: u = null,
|
|
55
|
-
isStandalone: z = !1
|
|
56
|
-
}, V) => {
|
|
23
|
+
$hasLabel: t
|
|
24
|
+
}) => t ? "12px" : "0px", ({
|
|
25
|
+
$hasLabel: t
|
|
26
|
+
}) => t ? "44px" : "56px", ({
|
|
27
|
+
$hasLabel: t
|
|
28
|
+
}) => t ? "44px" : "56px", R)
|
|
29
|
+
}, T = g(() => import("@purr-react-styled-components/components.post-adornment").then((t) => ({
|
|
30
|
+
default: t.PostAdornment
|
|
31
|
+
}))), W = g(() => import("@purr-react-styled-components/components.pre-adornment").then((t) => ({
|
|
32
|
+
default: t.PreAdornment
|
|
33
|
+
}))), M = V(({
|
|
34
|
+
value: t = "",
|
|
35
|
+
variant: e = "standard",
|
|
36
|
+
onChange: i,
|
|
37
|
+
onFocus: f,
|
|
38
|
+
onBlur: y,
|
|
39
|
+
clear: x,
|
|
40
|
+
htmlAttributes: b,
|
|
41
|
+
inputHtmlAttributes: $,
|
|
42
|
+
preAdornmentProps: l,
|
|
43
|
+
postAdornmentProps: a,
|
|
44
|
+
className: v = "",
|
|
45
|
+
fullWidth: h = !1,
|
|
46
|
+
disabled: d = !1,
|
|
47
|
+
required: u = !1,
|
|
48
|
+
error: S = null,
|
|
49
|
+
isStandalone: w = !1
|
|
50
|
+
}, _) => {
|
|
57
51
|
const {
|
|
58
|
-
currentValue:
|
|
59
|
-
setCurrentValue:
|
|
60
|
-
} =
|
|
61
|
-
captureOnFocus:
|
|
62
|
-
captureOnBlur:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
n == null || n(y.target.value, y), j(y.target.value);
|
|
52
|
+
currentValue: C,
|
|
53
|
+
setCurrentValue: F
|
|
54
|
+
} = k(t, w), {
|
|
55
|
+
captureOnFocus: I,
|
|
56
|
+
captureOnBlur: N
|
|
57
|
+
} = j({
|
|
58
|
+
onFocus: f,
|
|
59
|
+
onBlur: y
|
|
60
|
+
}), z = (c) => {
|
|
61
|
+
i == null || i(c.target.value, c), F(c.target.value);
|
|
69
62
|
};
|
|
70
|
-
return /* @__PURE__ */
|
|
71
|
-
/* @__PURE__ */
|
|
72
|
-
/* @__PURE__ */
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
/* @__PURE__ */ f(g, { children: !!(c != null && c.children) && /* @__PURE__ */ f(U, { ...c, clear: $, variant: t }) }),
|
|
75
|
-
/* @__PURE__ */ f(g, { children: (d == null ? void 0 : d.children) && /* @__PURE__ */ f(K, { ...d, isError: !!u, variant: t, children: (u == null ? void 0 : u.message) ?? (d == null ? void 0 : d.children) ?? "" }) })
|
|
63
|
+
return /* @__PURE__ */ L(o.Container, { ...b, $fullWidth: h, $variant: e, $disabled: d, className: s("text-field", h && "text-field--full-width", u && "text-field--required", d && "text-field--disabled", S && "text-field--error", `text-field--variant-${e}`, v), children: [
|
|
64
|
+
/* @__PURE__ */ n(r, { children: !!(l != null && l.children) && /* @__PURE__ */ n(W, { ...l, hasLabel: !0, variant: e }) }),
|
|
65
|
+
/* @__PURE__ */ n(o.Input, { ...$, $variant: e, $hasPreAdornment: !!(l != null && l.children), $hasPostAdornment: !!x || !!(a != null && a.children), $hasLabel: !0, ref: _, value: C, disabled: d, required: u, onChange: z, onFocus: I, onBlur: N, className: s("text-field-input", `text-field-input--variant-${e}`, d && "text-field-input--disabled", u && "text-field-input--required") }),
|
|
66
|
+
/* @__PURE__ */ n(r, { children: !!(a != null && a.children) && /* @__PURE__ */ n(T, { ...a, clear: x, variant: e }) })
|
|
76
67
|
] });
|
|
77
68
|
});
|
|
78
|
-
|
|
69
|
+
M.displayName = "TextField";
|
|
79
70
|
export {
|
|
80
|
-
|
|
71
|
+
M as TextField
|
|
81
72
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@purr-react-styled-components/components.text-field",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -25,17 +25,15 @@
|
|
|
25
25
|
"react": "*",
|
|
26
26
|
"styled-components": "*",
|
|
27
27
|
"clsx": "*",
|
|
28
|
-
"@purr-react-styled-components/components.
|
|
29
|
-
"@purr-react-styled-components/components.
|
|
30
|
-
"@purr-
|
|
31
|
-
"@purr-react-styled-components/
|
|
32
|
-
"@purr-core/
|
|
33
|
-
"@purr-
|
|
34
|
-
"@purr-core/hooks.focus-with-callback": "0.0.6",
|
|
35
|
-
"@purr-core/hooks.sync-state-with-props": "0.0.6"
|
|
28
|
+
"@purr-react-styled-components/components.post-adornment": "0.0.7",
|
|
29
|
+
"@purr-react-styled-components/components.pre-adornment": "0.0.7",
|
|
30
|
+
"@purr-core/utils.definitions": "0.0.10",
|
|
31
|
+
"@purr-react-styled-components/utils.helpers": "0.0.6",
|
|
32
|
+
"@purr-core/hooks.focus-with-callback": "0.0.7",
|
|
33
|
+
"@purr-core/hooks.sync-state-with-props": "0.0.7"
|
|
36
34
|
},
|
|
37
35
|
"devDependencies": {
|
|
38
|
-
"@purr-react-styled-components/components.icon": "0.0.
|
|
36
|
+
"@purr-react-styled-components/components.icon": "0.0.7"
|
|
39
37
|
},
|
|
40
38
|
"author": "@DinhThienPhuc",
|
|
41
39
|
"license": "ISC",
|