@purr-react-tailwindcss/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/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var v=Object.create;var w=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var G=(i,t,l,h)=>{if(t&&typeof t=="object"||typeof t=="function")for(let d of M(t))!D.call(i,d)&&d!==l&&w(i,d,{get:()=>t[d],enumerable:!(h=I(t,d))||h.enumerable});return i};var g=(i,t,l)=>(l=i!=null?v(_(i)):{},G(t||!i||!i.__esModule?w(l,"default",{value:i,enumerable:!0}):l,i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),z=require("clsx"),a=require("react"),J=require("@purr-core/hooks.focus-with-callback"),K=require("@purr-core/hooks.sync-state-with-props"),L=require("@purr-react-tailwindcss/utils.helpers"),Q=a.lazy(()=>import("@purr-react-tailwindcss/components.helper-text").then(i=>({default:i.HelperText}))),U=a.lazy(()=>import("@purr-react-tailwindcss/components.label").then(i=>({default:i.Label}))),X=a.lazy(()=>import("@purr-react-tailwindcss/components.post-adornment").then(i=>({default:i.PostAdornment}))),Y=a.lazy(()=>import("@purr-react-tailwindcss/components.pre-adornment").then(i=>({default:i.PreAdornment}))),C=a.forwardRef(({value:i="",variant:t="standard",onChange:l,onFocus:h,onBlur:d,clear:S,htmlAttributes:N,inputHtmlAttributes:O,labelProps:e,preAdornmentProps:u,postAdornmentProps:n,helperTextProps:f,fullWidth:V=!1,disabled:s=!1,required:j=!1,error:x=null,isStandalone:B=!1},E)=>{const{currentValue:F,setCurrentValue:H}=K(i,B),{captureOnFocus:R,captureOnBlur:W,isFocused:q}=J({onFocus:h,onBlur:d}),$=!!(q||u!=null&&u.children||F),k=y=>{l==null||l(y.target.value,y),H(y.target.value)};return c.jsxs("div",{className:z("relative h-14 rounded transition-all duration-200 ease-in-out",L.getVariantClasses(t,s),"text-field",V&&"text-field--full-width",j&&"text-field--required",s&&"text-field--disabled",x&&"text-field--error",`text-field--variant-${t}`),...N,children:[c.jsx(a.Suspense,{children:!!(e!=null&&e.children)&&c.jsx(U,{...e,variant:t,disabled:s,required:j,isLabelCollapsed:$,isFocused:q,isError:!!x})}),c.jsx(a.Suspense,{children:!!(u!=null&&u.children)&&c.jsx(Y,{...u,hasLabel:!!(e!=null&&e.children),variant:t})}),c.jsx("input",{ref:E,value:F,disabled:s,required:j,onChange:k,onFocus:R,onBlur:W,className:z(L.getInputPaddingClasses(!!(u!=null&&u.children),!!S||!!(n!=null&&n.children),t),"box-border w-full rounded border-none bg-transparent text-base text-white outline-none transition-all duration-200 ease-in-out",e!=null&&e.children?"mt-3 h-11 leading-[2.75rem]":"mt-0 h-14 leading-[3.5rem]","text-field-input",`text-field-input--variant-${t}`,s&&"text-field-input--disabled",j&&"text-field-input--required"),...O}),c.jsx(a.Suspense,{children:!!(n!=null&&n.children)&&c.jsx(X,{...n,clear:S,variant:t})}),c.jsx(a.Suspense,{children:(f==null?void 0:f.children)&&c.jsx(Q,{...f,isError:!!x,variant:t,children:(x==null?void 0:x.message)??(f==null?void 0:f.children)??""})})]})});C.displayName="TextField";exports.TextField=C;
1
+ 'use strict';var p=require('clsx'),e=require('react'),V=require('@purr-core/hooks.focus-with-callback'),B=require('@purr-core/hooks.sync-state-with-props'),utils_helpers=require('@purr-react-tailwindcss/utils.helpers');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var p__default=/*#__PURE__*/_interopDefault(p);var e__default=/*#__PURE__*/_interopDefault(e);var V__default=/*#__PURE__*/_interopDefault(V);var B__default=/*#__PURE__*/_interopDefault(B);var W=e.lazy(()=>import('@purr-react-tailwindcss/components.helper-text').then(t=>({default:t.HelperText}))),$=e.lazy(()=>import('@purr-react-tailwindcss/components.label').then(t=>({default:t.Label}))),k=e.lazy(()=>import('@purr-react-tailwindcss/components.post-adornment').then(t=>({default:t.PostAdornment}))),q=e.lazy(()=>import('@purr-react-tailwindcss/components.pre-adornment').then(t=>({default:t.PreAdornment}))),z=e.forwardRef(({value:t="",variant:n="standard",onChange:g,onFocus:C,onBlur:F,clear:h,htmlAttributes:b,inputHtmlAttributes:v,labelProps:i,preAdornmentProps:r,postAdornmentProps:o,helperTextProps:f,fullWidth:L=false,disabled:l=false,required:s=false,error:d=null,isStandalone:S=false},T)=>{let{currentValue:c,setCurrentValue:E}=B__default.default(t,S),{captureOnFocus:H,captureOnBlur:I,isFocused:x}=V__default.default({onFocus:C,onBlur:F}),w=!!(x||r?.children||c),y=m=>{g?.(m.target.value,m),E(m.target.value);};return e__default.default.createElement("div",{className:p__default.default("relative h-14 rounded transition-all duration-200 ease-in-out",utils_helpers.getVariantClasses(n,l),"text-field",L&&"text-field--full-width",s&&"text-field--required",l&&"text-field--disabled",d&&"text-field--error",`text-field--variant-${n}`),...b},e__default.default.createElement(e.Suspense,null,!!i?.children&&e__default.default.createElement($,{...i,variant:n,disabled:l,required:s,isLabelCollapsed:w,isFocused:x,isError:!!d})),e__default.default.createElement(e.Suspense,null,!!r?.children&&e__default.default.createElement(q,{...r,hasLabel:!!i?.children,variant:n})),e__default.default.createElement("input",{ref:T,value:c,disabled:l,required:s,onChange:y,onFocus:H,onBlur:I,className:p__default.default(utils_helpers.getInputPaddingClasses(!!r?.children,!!h||!!o?.children,n),"box-border w-full rounded border-none bg-transparent text-base text-white outline-none transition-all duration-200 ease-in-out",i?.children?"mt-3 h-11 leading-[2.75rem]":"mt-0 h-14 leading-[3.5rem]","text-field-input",`text-field-input--variant-${n}`,l&&"text-field-input--disabled",s&&"text-field-input--required"),...v}),e__default.default.createElement(e.Suspense,null,!!o?.children&&e__default.default.createElement(k,{...o,clear:h,variant:n})),e__default.default.createElement(e.Suspense,null,f?.children&&e__default.default.createElement(W,{...f,isError:!!d,variant:n},d?.message??f?.children??"")))});z.displayName="TextField";exports.TextField=z;
@@ -1,4 +1,4 @@
1
- import { ChangeEvent, FocusEventHandler, HTMLAttributes, InputHTMLAttributes } from 'react';
1
+ import React, { ChangeEvent, FocusEventHandler, HTMLAttributes, InputHTMLAttributes } from 'react';
2
2
  import { FieldError } from 'react-hook-form';
3
3
  import { IExtendable } from '@purr-core/utils.definitions';
4
4
  import { IHelperTextProps } from '@purr-react-tailwindcss/components.helper-text';
@@ -6,8 +6,8 @@ import { ILabelProps } from '@purr-react-tailwindcss/components.label';
6
6
  import { IPostAdornmentProps } from '@purr-react-tailwindcss/components.post-adornment';
7
7
  import { IPreAdornmentProps } from '@purr-react-tailwindcss/components.pre-adornment';
8
8
 
9
- export type TTextFieldVariant = "standard" | "outlined" | "filled";
10
- export interface ITextFieldProps {
9
+ type TTextFieldVariant = "standard" | "outlined" | "filled";
10
+ interface ITextFieldProps {
11
11
  value?: string;
12
12
  variant?: TTextFieldVariant;
13
13
  onChange?: (value: string, e: ChangeEvent<HTMLInputElement>) => void;
@@ -26,3 +26,7 @@ export interface ITextFieldProps {
26
26
  error?: FieldError;
27
27
  isStandalone?: boolean;
28
28
  }
29
+
30
+ declare const TextField: React.ForwardRefExoticComponent<ITextFieldProps & React.RefAttributes<HTMLInputElement>>;
31
+
32
+ export { type ITextFieldProps, type TTextFieldVariant, TextField };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,32 @@
1
- export * from './_components';
2
- export * from './_types';
1
+ import React, { ChangeEvent, FocusEventHandler, HTMLAttributes, InputHTMLAttributes } from 'react';
2
+ import { FieldError } from 'react-hook-form';
3
+ import { IExtendable } from '@purr-core/utils.definitions';
4
+ import { IHelperTextProps } from '@purr-react-tailwindcss/components.helper-text';
5
+ import { ILabelProps } from '@purr-react-tailwindcss/components.label';
6
+ import { IPostAdornmentProps } from '@purr-react-tailwindcss/components.post-adornment';
7
+ import { IPreAdornmentProps } from '@purr-react-tailwindcss/components.pre-adornment';
8
+
9
+ type TTextFieldVariant = "standard" | "outlined" | "filled";
10
+ interface ITextFieldProps {
11
+ value?: string;
12
+ variant?: TTextFieldVariant;
13
+ onChange?: (value: string, e: ChangeEvent<HTMLInputElement>) => void;
14
+ onFocus?: FocusEventHandler<HTMLInputElement>;
15
+ onBlur?: FocusEventHandler<HTMLInputElement>;
16
+ clear?: () => void;
17
+ htmlAttributes?: HTMLAttributes<HTMLDivElement> & IExtendable;
18
+ inputHtmlAttributes?: InputHTMLAttributes<HTMLInputElement> & IExtendable;
19
+ labelProps?: ILabelProps;
20
+ preAdornmentProps?: IPreAdornmentProps;
21
+ postAdornmentProps?: IPostAdornmentProps;
22
+ helperTextProps?: IHelperTextProps;
23
+ fullWidth?: boolean;
24
+ disabled?: boolean;
25
+ required?: boolean;
26
+ error?: FieldError;
27
+ isStandalone?: boolean;
28
+ }
29
+
30
+ declare const TextField: React.ForwardRefExoticComponent<ITextFieldProps & React.RefAttributes<HTMLInputElement>>;
31
+
32
+ export { type ITextFieldProps, type TTextFieldVariant, TextField };
package/dist/index.js CHANGED
@@ -1,137 +1 @@
1
- import { jsxs as z, jsx as c } from "react/jsx-runtime";
2
- import y from "clsx";
3
- import { lazy as x, forwardRef as I, Suspense as n } from "react";
4
- import R from "@purr-core/hooks.focus-with-callback";
5
- import v from "@purr-core/hooks.sync-state-with-props";
6
- import { getVariantClasses as D, getInputPaddingClasses as G } from "@purr-react-tailwindcss/utils.helpers";
7
- const J = x(
8
- () => import("@purr-react-tailwindcss/components.helper-text").then((u) => ({
9
- default: u.HelperText
10
- }))
11
- ), K = x(
12
- () => import("@purr-react-tailwindcss/components.label").then((u) => ({
13
- default: u.Label
14
- }))
15
- ), M = x(
16
- () => import("@purr-react-tailwindcss/components.post-adornment").then(
17
- (u) => ({
18
- default: u.PostAdornment
19
- })
20
- )
21
- ), Q = x(
22
- () => import("@purr-react-tailwindcss/components.pre-adornment").then((u) => ({
23
- default: u.PreAdornment
24
- }))
25
- ), U = I(
26
- ({
27
- value: u = "",
28
- variant: l = "standard",
29
- onChange: g,
30
- onFocus: C,
31
- onBlur: N,
32
- clear: w,
33
- htmlAttributes: S,
34
- inputHtmlAttributes: V,
35
- labelProps: i,
36
- preAdornmentProps: t,
37
- postAdornmentProps: f,
38
- helperTextProps: a,
39
- fullWidth: j = !1,
40
- disabled: e = !1,
41
- required: h = !1,
42
- error: d = null,
43
- isStandalone: B = !1
44
- }, E) => {
45
- const { currentValue: L, setCurrentValue: H } = v(u, B), { captureOnFocus: O, captureOnBlur: W, isFocused: m } = R({
46
- onFocus: C,
47
- onBlur: N
48
- }), $ = !!(m || t != null && t.children || L), k = (F) => {
49
- g == null || g(F.target.value, F), H(F.target.value);
50
- };
51
- return /* @__PURE__ */ z(
52
- "div",
53
- {
54
- className: y(
55
- "relative h-14 rounded transition-all duration-200 ease-in-out",
56
- D(l, e),
57
- "text-field",
58
- j && "text-field--full-width",
59
- h && "text-field--required",
60
- e && "text-field--disabled",
61
- d && "text-field--error",
62
- `text-field--variant-${l}`
63
- ),
64
- ...S,
65
- children: [
66
- /* @__PURE__ */ c(n, { children: !!(i != null && i.children) && /* @__PURE__ */ c(
67
- K,
68
- {
69
- ...i,
70
- variant: l,
71
- disabled: e,
72
- required: h,
73
- isLabelCollapsed: $,
74
- isFocused: m,
75
- isError: !!d
76
- }
77
- ) }),
78
- /* @__PURE__ */ c(n, { children: !!(t != null && t.children) && /* @__PURE__ */ c(
79
- Q,
80
- {
81
- ...t,
82
- hasLabel: !!(i != null && i.children),
83
- variant: l
84
- }
85
- ) }),
86
- /* @__PURE__ */ c(
87
- "input",
88
- {
89
- ref: E,
90
- value: L,
91
- disabled: e,
92
- required: h,
93
- onChange: k,
94
- onFocus: O,
95
- onBlur: W,
96
- className: y(
97
- G(
98
- !!(t != null && t.children),
99
- !!w || !!(f != null && f.children),
100
- l
101
- ),
102
- "box-border w-full rounded border-none bg-transparent text-base text-white outline-none transition-all duration-200 ease-in-out",
103
- i != null && i.children ? "mt-3 h-11 leading-[2.75rem]" : "mt-0 h-14 leading-[3.5rem]",
104
- "text-field-input",
105
- `text-field-input--variant-${l}`,
106
- e && "text-field-input--disabled",
107
- h && "text-field-input--required"
108
- ),
109
- ...V
110
- }
111
- ),
112
- /* @__PURE__ */ c(n, { children: !!(f != null && f.children) && /* @__PURE__ */ c(
113
- M,
114
- {
115
- ...f,
116
- clear: w,
117
- variant: l
118
- }
119
- ) }),
120
- /* @__PURE__ */ c(n, { children: (a == null ? void 0 : a.children) && /* @__PURE__ */ c(
121
- J,
122
- {
123
- ...a,
124
- isError: !!d,
125
- variant: l,
126
- children: (d == null ? void 0 : d.message) ?? (a == null ? void 0 : a.children) ?? ""
127
- }
128
- ) })
129
- ]
130
- }
131
- );
132
- }
133
- );
134
- U.displayName = "TextField";
135
- export {
136
- U as TextField
137
- };
1
+ import p from'clsx';import e,{lazy,forwardRef,Suspense}from'react';import V from'@purr-core/hooks.focus-with-callback';import B from'@purr-core/hooks.sync-state-with-props';import {getVariantClasses,getInputPaddingClasses}from'@purr-react-tailwindcss/utils.helpers';var W=lazy(()=>import('@purr-react-tailwindcss/components.helper-text').then(t=>({default:t.HelperText}))),$=lazy(()=>import('@purr-react-tailwindcss/components.label').then(t=>({default:t.Label}))),k=lazy(()=>import('@purr-react-tailwindcss/components.post-adornment').then(t=>({default:t.PostAdornment}))),q=lazy(()=>import('@purr-react-tailwindcss/components.pre-adornment').then(t=>({default:t.PreAdornment}))),z=forwardRef(({value:t="",variant:n="standard",onChange:g,onFocus:C,onBlur:F,clear:h,htmlAttributes:b,inputHtmlAttributes:v,labelProps:i,preAdornmentProps:r,postAdornmentProps:o,helperTextProps:f,fullWidth:L=false,disabled:l=false,required:s=false,error:d=null,isStandalone:S=false},T)=>{let{currentValue:c,setCurrentValue:E}=B(t,S),{captureOnFocus:H,captureOnBlur:I,isFocused:x}=V({onFocus:C,onBlur:F}),w=!!(x||r?.children||c),y=m=>{g?.(m.target.value,m),E(m.target.value);};return e.createElement("div",{className:p("relative h-14 rounded transition-all duration-200 ease-in-out",getVariantClasses(n,l),"text-field",L&&"text-field--full-width",s&&"text-field--required",l&&"text-field--disabled",d&&"text-field--error",`text-field--variant-${n}`),...b},e.createElement(Suspense,null,!!i?.children&&e.createElement($,{...i,variant:n,disabled:l,required:s,isLabelCollapsed:w,isFocused:x,isError:!!d})),e.createElement(Suspense,null,!!r?.children&&e.createElement(q,{...r,hasLabel:!!i?.children,variant:n})),e.createElement("input",{ref:T,value:c,disabled:l,required:s,onChange:y,onFocus:H,onBlur:I,className:p(getInputPaddingClasses(!!r?.children,!!h||!!o?.children,n),"box-border w-full rounded border-none bg-transparent text-base text-white outline-none transition-all duration-200 ease-in-out",i?.children?"mt-3 h-11 leading-[2.75rem]":"mt-0 h-14 leading-[3.5rem]","text-field-input",`text-field-input--variant-${n}`,l&&"text-field-input--disabled",s&&"text-field-input--required"),...v}),e.createElement(Suspense,null,!!o?.children&&e.createElement(k,{...o,clear:h,variant:n})),e.createElement(Suspense,null,f?.children&&e.createElement(W,{...f,isError:!!d,variant:n},d?.message??f?.children??"")))});z.displayName="TextField";export{z as TextField};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purr-react-tailwindcss/components.text-field",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -24,17 +24,17 @@
24
24
  "typescript": "*",
25
25
  "react": "*",
26
26
  "clsx": "*",
27
- "@purr-core/utils.definitions": "0.0.10",
28
- "@purr-react-tailwindcss/components.helper-text": "0.0.6",
29
- "@purr-react-tailwindcss/components.label": "0.0.6",
30
- "@purr-react-tailwindcss/components.post-adornment": "0.0.6",
31
- "@purr-react-tailwindcss/components.pre-adornment": "0.0.6",
32
- "@purr-core/hooks.focus-with-callback": "0.0.7",
33
- "@purr-core/hooks.sync-state-with-props": "0.0.7",
34
- "@purr-react-tailwindcss/utils.helpers": "0.0.4"
27
+ "@purr-core/utils.definitions": "0.0.12",
28
+ "@purr-react-tailwindcss/components.helper-text": "0.0.8",
29
+ "@purr-react-tailwindcss/components.label": "0.0.8",
30
+ "@purr-react-tailwindcss/components.post-adornment": "0.0.8",
31
+ "@purr-react-tailwindcss/components.pre-adornment": "0.0.8",
32
+ "@purr-core/hooks.focus-with-callback": "0.0.9",
33
+ "@purr-core/hooks.sync-state-with-props": "0.0.9",
34
+ "@purr-react-tailwindcss/utils.helpers": "0.0.6"
35
35
  },
36
36
  "devDependencies": {
37
- "@purr-react-tailwindcss/components.icon": "0.0.6"
37
+ "@purr-react-tailwindcss/components.icon": "0.0.8"
38
38
  },
39
39
  "author": "@DinhThienPhuc",
40
40
  "license": "ISC",
@@ -43,6 +43,8 @@
43
43
  "scripts": {
44
44
  "dev": "vite build --watch",
45
45
  "build": "tsc && vite build",
46
+ "build:vite": "tsc && vite build",
47
+ "build:tsup": "tsup",
46
48
  "lint": "eslint . --ext ts,tsx --max-warnings 0"
47
49
  }
48
50
  }
@@ -1,4 +0,0 @@
1
- import { default as React } from 'react';
2
- import { ITextFieldProps } from './_types';
3
-
4
- export declare const TextField: React.ForwardRefExoticComponent<ITextFieldProps & React.RefAttributes<HTMLInputElement>>;