@greatapps/common 1.1.515 → 1.1.516
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.
|
@@ -46,7 +46,7 @@ const FormField = forwardRef(
|
|
|
46
46
|
"flex gap-2 px-4 items-center border rounded-lg transition-color",
|
|
47
47
|
containerHeight,
|
|
48
48
|
classnameContainer,
|
|
49
|
-
error ? "border-red-600 hover:border-red-700" : "border-gray-200 hover:border-gray-400 focus-within:border-gray-950"
|
|
49
|
+
error ? "border-red-600 hover:border-red-700" : inputProps.disabled ? "border-transparent" : "border-gray-200 hover:border-gray-400 focus-within:border-gray-950"
|
|
50
50
|
),
|
|
51
51
|
children: [
|
|
52
52
|
FinalLeftIcon && /* @__PURE__ */ jsx(FinalLeftIcon, { size: 20, className: "text-gray-400" }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ui/form/FormField.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, type ComponentPropsWithoutRef } from 'react';\nimport { IconLock, IconEye, IconEyeOff } from '@tabler/icons-react';\nimport type { TablerIcon } from '@tabler/icons-react';\nimport { Input } from './Input';\nimport { cn } from '../../../infra/utils/clsx';\n\ntype FormFieldSize = 'default' | 'large';\n\ninterface FormFieldProps extends Omit<ComponentPropsWithoutRef<'input'>, 'size'> {\n label?: string;\n optional?: boolean;\n required?: boolean;\n leftIcon?: TablerIcon;\n rightIcon?: TablerIcon;\n rightIconColor?: string;\n hintMessage?: string;\n classnameContainer?: string;\n size?: FormFieldSize;\n error?: boolean;\n errorMessage?: string;\n showCharCount?: boolean;\n showPassword?: boolean;\n onTogglePassword?: () => void;\n}\n\nexport const FormField = forwardRef<HTMLInputElement, FormFieldProps>(\n (\n {\n label,\n optional = false,\n required = false,\n leftIcon: LeftIcon,\n rightIcon: RightIcon,\n rightIconColor = 'var(--color-gray-400)',\n hintMessage,\n size = 'default',\n type = 'text',\n error = false,\n errorMessage,\n className,\n classnameContainer,\n showCharCount = false,\n showPassword = false,\n onTogglePassword,\n ...inputProps\n },\n ref\n ) => {\n const isPasswordField = type === 'password';\n const inputType = isPasswordField && showPassword ? 'text' : type;\n const containerHeight = size === 'large' ? 'h-12' : 'h-10';\n\n const FinalLeftIcon = isPasswordField ? IconLock : LeftIcon;\n const FinalRightIcon = isPasswordField ? (!showPassword ? IconEyeOff : IconEye) : RightIcon;\n\n const finalMessage = error && errorMessage ? errorMessage : hintMessage;\n const messageColor = error ? 'text-red-600' : 'text-gray-600';\n\n const currentLength = typeof inputProps.value === 'string' ? inputProps.value.length : 0;\n const shouldShowCharCount = showCharCount && inputProps.maxLength;\n\n return (\n <div className=\"flex flex-col gap-1.5 w-full\">\n <div className=\"flex items-center gap-1 paragraph-xsmall-semibold truncate\">\n {label && <span className=\"text-gray-600\">{label}</span>}\n {optional && <span className=\"text-gray-500\">(Opcional)</span>}\n {required && <span className=\"text-red-600\">*</span>}\n </div>\n\n <div\n className={cn(\n 'flex gap-2 px-4 items-center border rounded-lg transition-color',\n containerHeight,\n classnameContainer,\n error\n ? 'border-red-600 hover:border-red-700'\n : 'border-gray-200 hover:border-gray-400 focus-within:border-gray-950'\n )}\n >\n {FinalLeftIcon && <FinalLeftIcon size={20} className=\"text-gray-400\" />}\n\n <Input\n ref={ref}\n type={inputType}\n className={cn(\n 'paragraph-small-medium w-full h-full text-gray-950',\n error && 'placeholder:text-red-400',\n className\n )}\n {...inputProps}\n />\n\n {FinalRightIcon && (\n <button\n type=\"button\"\n onClick={isPasswordField ? onTogglePassword : undefined}\n className={cn(\n 'flex items-center justify-center',\n isPasswordField && 'cursor-pointer hover:opacity-70 transition-opacity'\n )}\n aria-label={\n isPasswordField ? (showPassword ? 'Ocultar senha' : 'Mostrar senha') : undefined\n }\n >\n <FinalRightIcon\n size={20}\n color={isPasswordField ? 'var(--color-gray-950)' : rightIconColor}\n />\n </button>\n )}\n </div>\n\n {finalMessage && (\n <span className={cn('paragraph-xsmall-medium', messageColor)}>{finalMessage}</span>\n )}\n\n {shouldShowCharCount && (\n <span className=\"paragraph-xsmall-medium text-gray-600\">\n {currentLength}/{inputProps.maxLength}\n </span>\n )}\n </div>\n );\n }\n);\n\nFormField.displayName = 'FormField';\n\nexport default FormField;\n"],"mappings":";AAiEQ,SACY,KADZ;AA/DR,SAAS,kBAAiD;AAC1D,SAAS,UAAU,SAAS,kBAAkB;AAE9C,SAAS,aAAa;AACtB,SAAS,UAAU;AAqBZ,MAAM,YAAY;AAAA,EACvB,CACE;AAAA,IACE;AAAA,IACA,WAAW;AAAA,IACX,WAAW;AAAA,IACX,UAAU;AAAA,IACV,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB;AAAA,IACA,OAAO;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;AACH,UAAM,kBAAkB,SAAS;AACjC,UAAM,YAAY,mBAAmB,eAAe,SAAS;AAC7D,UAAM,kBAAkB,SAAS,UAAU,SAAS;AAEpD,UAAM,gBAAgB,kBAAkB,WAAW;AACnD,UAAM,iBAAiB,kBAAmB,CAAC,eAAe,aAAa,UAAW;AAElF,UAAM,eAAe,SAAS,eAAe,eAAe;AAC5D,UAAM,eAAe,QAAQ,iBAAiB;AAE9C,UAAM,gBAAgB,OAAO,WAAW,UAAU,WAAW,WAAW,MAAM,SAAS;AACvF,UAAM,sBAAsB,iBAAiB,WAAW;AAExD,WACE,qBAAC,SAAI,WAAU,gCACb;AAAA,2BAAC,SAAI,WAAU,8DACZ;AAAA,iBAAS,oBAAC,UAAK,WAAU,iBAAiB,iBAAM;AAAA,QAChD,YAAY,oBAAC,UAAK,WAAU,iBAAgB,wBAAU;AAAA,QACtD,YAAY,oBAAC,UAAK,WAAU,gBAAe,eAAC;AAAA,SAC/C;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACC,WAAW;AAAA,YACT;AAAA,YACA;AAAA,YACA;AAAA,YACA,QACI,wCACA;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/form/FormField.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, type ComponentPropsWithoutRef } from 'react';\nimport { IconLock, IconEye, IconEyeOff } from '@tabler/icons-react';\nimport type { TablerIcon } from '@tabler/icons-react';\nimport { Input } from './Input';\nimport { cn } from '../../../infra/utils/clsx';\n\ntype FormFieldSize = 'default' | 'large';\n\ninterface FormFieldProps extends Omit<ComponentPropsWithoutRef<'input'>, 'size'> {\n label?: string;\n optional?: boolean;\n required?: boolean;\n leftIcon?: TablerIcon;\n rightIcon?: TablerIcon;\n rightIconColor?: string;\n hintMessage?: string;\n classnameContainer?: string;\n size?: FormFieldSize;\n error?: boolean;\n errorMessage?: string;\n showCharCount?: boolean;\n showPassword?: boolean;\n onTogglePassword?: () => void;\n}\n\nexport const FormField = forwardRef<HTMLInputElement, FormFieldProps>(\n (\n {\n label,\n optional = false,\n required = false,\n leftIcon: LeftIcon,\n rightIcon: RightIcon,\n rightIconColor = 'var(--color-gray-400)',\n hintMessage,\n size = 'default',\n type = 'text',\n error = false,\n errorMessage,\n className,\n classnameContainer,\n showCharCount = false,\n showPassword = false,\n onTogglePassword,\n ...inputProps\n },\n ref\n ) => {\n const isPasswordField = type === 'password';\n const inputType = isPasswordField && showPassword ? 'text' : type;\n const containerHeight = size === 'large' ? 'h-12' : 'h-10';\n\n const FinalLeftIcon = isPasswordField ? IconLock : LeftIcon;\n const FinalRightIcon = isPasswordField ? (!showPassword ? IconEyeOff : IconEye) : RightIcon;\n\n const finalMessage = error && errorMessage ? errorMessage : hintMessage;\n const messageColor = error ? 'text-red-600' : 'text-gray-600';\n\n const currentLength = typeof inputProps.value === 'string' ? inputProps.value.length : 0;\n const shouldShowCharCount = showCharCount && inputProps.maxLength;\n\n return (\n <div className=\"flex flex-col gap-1.5 w-full\">\n <div className=\"flex items-center gap-1 paragraph-xsmall-semibold truncate\">\n {label && <span className=\"text-gray-600\">{label}</span>}\n {optional && <span className=\"text-gray-500\">(Opcional)</span>}\n {required && <span className=\"text-red-600\">*</span>}\n </div>\n\n <div\n className={cn(\n 'flex gap-2 px-4 items-center border rounded-lg transition-color',\n containerHeight,\n classnameContainer,\n error\n ? 'border-red-600 hover:border-red-700'\n : inputProps.disabled\n ? 'border-transparent'\n : 'border-gray-200 hover:border-gray-400 focus-within:border-gray-950'\n )}\n >\n {FinalLeftIcon && <FinalLeftIcon size={20} className=\"text-gray-400\" />}\n\n <Input\n ref={ref}\n type={inputType}\n className={cn(\n 'paragraph-small-medium w-full h-full text-gray-950',\n error && 'placeholder:text-red-400',\n className\n )}\n {...inputProps}\n />\n\n {FinalRightIcon && (\n <button\n type=\"button\"\n onClick={isPasswordField ? onTogglePassword : undefined}\n className={cn(\n 'flex items-center justify-center',\n isPasswordField && 'cursor-pointer hover:opacity-70 transition-opacity'\n )}\n aria-label={\n isPasswordField ? (showPassword ? 'Ocultar senha' : 'Mostrar senha') : undefined\n }\n >\n <FinalRightIcon\n size={20}\n color={isPasswordField ? 'var(--color-gray-950)' : rightIconColor}\n />\n </button>\n )}\n </div>\n\n {finalMessage && (\n <span className={cn('paragraph-xsmall-medium', messageColor)}>{finalMessage}</span>\n )}\n\n {shouldShowCharCount && (\n <span className=\"paragraph-xsmall-medium text-gray-600\">\n {currentLength}/{inputProps.maxLength}\n </span>\n )}\n </div>\n );\n }\n);\n\nFormField.displayName = 'FormField';\n\nexport default FormField;\n"],"mappings":";AAiEQ,SACY,KADZ;AA/DR,SAAS,kBAAiD;AAC1D,SAAS,UAAU,SAAS,kBAAkB;AAE9C,SAAS,aAAa;AACtB,SAAS,UAAU;AAqBZ,MAAM,YAAY;AAAA,EACvB,CACE;AAAA,IACE;AAAA,IACA,WAAW;AAAA,IACX,WAAW;AAAA,IACX,UAAU;AAAA,IACV,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB;AAAA,IACA,OAAO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T;AAAA,kBACA,mBAAmB;AAAA,gBACrB;AAAA,gBACA,cACE,kBAAmB,eAAe,kBAAkB,kBAAmB;AAAA,gBAGzE;AAAA,kBAAC;AAAA;AAAA,oBACC,MAAM;AAAA,oBACN,OAAO,kBAAkB,0BAA0B;AAAA;AAAA,gBACrD;AAAA;AAAA,YACF;AAAA;AAAA;AAAA,MAEJ;AAAA,MAEC,gBACC,oBAAC,UAAK,WAAW,GAAG,2BAA2B,YAAY,GAAI,wBAAa;AAAA,MAG7E,uBACC,qBAAC,UAAK,WAAU,yCACb;AAAA;AAAA,QAAc;AAAA,QAAE,WAAW;AAAA,SAC9B;AAAA,OAEJ;AAAA,EAEJ;AACF;AAEA,UAAU,cAAc;AAExB,IAAO,oBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -76,7 +76,9 @@ export const FormField = forwardRef<HTMLInputElement, FormFieldProps>(
|
|
|
76
76
|
classnameContainer,
|
|
77
77
|
error
|
|
78
78
|
? 'border-red-600 hover:border-red-700'
|
|
79
|
-
:
|
|
79
|
+
: inputProps.disabled
|
|
80
|
+
? 'border-transparent'
|
|
81
|
+
: 'border-gray-200 hover:border-gray-400 focus-within:border-gray-950'
|
|
80
82
|
)}
|
|
81
83
|
>
|
|
82
84
|
{FinalLeftIcon && <FinalLeftIcon size={20} className="text-gray-400" />}
|