patiya 2.0.1 → 2.0.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"patiya8.mjs","names":["Input","forwardRef","props","inputClassName","cn","inputSize","variant","invalid","leftIcon","rightIcon","className","Box"],"sources":["../src/components/Input/Input.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport { cn } from '../../utils/cn';\nimport { PatiyaSize } from '../../types/common';\nimport { Box } from '../Layout/Box';\n\nexport interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'> {\n inputSize?: PatiyaSize;\n variant?: 'outline' | 'filled' | 'soft';\n invalid?: boolean;\n leftIcon?: React.ReactNode;\n rightIcon?: React.ReactNode;\n}\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(\n (\n {\n className,\n inputSize = 'md',\n variant = 'outline',\n invalid = false,\n leftIcon,\n rightIcon,\n disabled,\n ...props\n },\n ref\n ) => {\n const sizeClasses: Record<PatiyaSize, string> = {\n xs: 'h-7 text-xs px-2',\n sm: 'h-8 text-sm px-3',\n md: 'h-10 text-base px-4',\n lg: 'h-12 text-lg px-4',\n xl: 'h-14 text-xl px-5',\n };\n\n const variantClasses = {\n outline: 'bg-transparent border border-[var(--patiya-color-border)] focus:border-[var(--patiya-color-primary)] shadow-[var(--patiya-shadow-sm)]',\n filled: 'bg-[var(--patiya-color-muted)] border border-transparent focus:bg-transparent focus:border-[var(--patiya-color-primary)]',\n soft: 'bg-[var(--patiya-color-primary)]/5 border border-transparent focus:bg-transparent focus:border-[var(--patiya-color-primary)]',\n };\n\n const inputClassName = cn(\n 'flex w-full rounded-md transition-all duration-200 outline-none',\n 'text-[var(--patiya-color-foreground)] placeholder:text-(--patiya-color-muted-foreground)',\n 'focus:ring-4 focus:ring-[var(--patiya-color-primary)]/10',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n sizeClasses[inputSize],\n variantClasses[variant],\n invalid && 'border-[var(--patiya-color-destructive)] focus:border-[var(--patiya-color-destructive)] focus:ring-[var(--patiya-color-destructive)]/10',\n leftIcon && 'pl-10',\n rightIcon && 'pr-10',\n !leftIcon && !rightIcon && className // only apply className directly to input if no wrapper\n );\n\n if (leftIcon || rightIcon) {\n return (\n <Box className={cn('relative flex items-center w-full', className)}>\n {leftIcon && (\n <span className=\"absolute left-3 flex items-center justify-center text-(--patiya-color-muted-foreground) pointer-events-none\">\n {leftIcon}\n </span>\n )}\n <input ref={ref} disabled={disabled} className={cn(inputClassName, 'w-full')} {...props} />\n {rightIcon && (\n <span className=\"absolute right-3 flex items-center justify-center text-(--patiya-color-muted-foreground) pointer-events-none\">\n {rightIcon}\n </span>\n )}\n </Box>\n );\n }\n\n return <input ref={ref} disabled={disabled} className={inputClassName} {...props} />;\n }\n);\n\nInput.displayName = 'Input';\n"],"mappings":";;;;;AAaA,IAAaA,IAAQC,GAEjB,EACE,cACA,eAAY,MACZ,aAAU,WACV,aAAU,IACV,aACA,cACA,aACA,GAAGC,KAEL,MACG;CAeH,IAAMC,IAAiBC,EACrB,mEACA,4FACA,4DACA,mDACA;EAlBA,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;CAcJ,EAAYC,IACZ;EAXA,SAAS;EACT,QAAQ;EACR,MAAM;CASN,EAAeC,IACfC,KAAW,2IACXC,KAAY,SACZC,KAAa,SACb,CAACD,KAAY,CAACC,KAAaC,CAC7B;CAoBA,OAlBIF,KAAYC,IAEZ,kBAACE,GAAD;EAAK,WAAWP,EAAG,qCAAqCM,CAAS;EAAjE,UAAA;GACGF,KACC,kBAAC,QAAD;IAAM,WAAU;IACb,UAAAA;GACG,CAAA;GAER,kBAAC,SAAD;IAAY;IAAe;IAAU,WAAWJ,EAAGD,GAAgB,QAAQ;IAAG,GAAID;GAAQ,CAAA;GACzFO,KACC,kBAAC,QAAD;IAAM,WAAU;IACb,UAAAA;GACG,CAAA;EAEL;MAIF,kBAAC,SAAD;EAAY;EAAe;EAAU,WAAWN;EAAgB,GAAID;CAAQ,CAAA;AACrF,CACF;AAEA,EAAM,cAAc"}
1
+ {"version":3,"file":"patiya8.mjs","names":["DefaultEyeIcon","DefaultEyeOffIcon","Input","forwardRef","props","internalInputRef","useRef","ref","showPassword","setShowPassword","useState","internalValue","setInternalValue","defaultValue","isControlled","value","currentVal","hasValue","handleInputChange","onChange","handleClear","syntheticEvent","isPassword","type","computedType","computedRightIcon","rightIcon","showPasswordToggle","prev","eyeOffIcon","eyeIcon","clearable","inputClassName","cn","inputSize","variant","invalid","leftIcon","className","Box"],"sources":["../src/components/Input/Input.tsx"],"sourcesContent":["import React, { forwardRef, useState, useRef, useImperativeHandle } from 'react';\nimport { cn } from '../../utils/cn';\nimport { PatiyaSize } from '../../types/common';\nimport { Box } from '../Layout/Box';\n\nexport type InputProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'> & {\n inputSize?: PatiyaSize;\n variant?: 'outline' | 'filled' | 'soft';\n invalid?: boolean;\n leftIcon?: React.ReactNode;\n rightIcon?: React.ReactNode;\n showPasswordToggle?: boolean;\n eyeIcon?: React.ReactNode;\n eyeOffIcon?: React.ReactNode;\n clearable?: boolean;\n onClear?: () => void;\n};\n\nconst DefaultEyeIcon = () => (\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <path d=\"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z\" />\n <circle cx=\"12\" cy=\"12\" r=\"3\" />\n </svg>\n);\n\nconst DefaultEyeOffIcon = () => (\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <path d=\"M9.88 9.88a3 3 0 1 0 4.24 4.24\" />\n <path d=\"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68\" />\n <path d=\"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61\" />\n <line x1=\"2\" x2=\"22\" y1=\"2\" y2=\"22\" />\n </svg>\n);\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(\n (\n {\n className,\n inputSize = 'md',\n variant = 'outline',\n invalid = false,\n leftIcon,\n rightIcon,\n disabled,\n type = 'text',\n showPasswordToggle = false,\n eyeIcon,\n eyeOffIcon,\n clearable = false,\n onClear,\n value,\n defaultValue,\n onChange,\n ...props\n },\n ref\n ) => {\n const internalInputRef = useRef<HTMLInputElement>(null);\n useImperativeHandle(ref, () => internalInputRef.current as HTMLInputElement);\n\n const [showPassword, setShowPassword] = useState(false);\n const [internalValue, setInternalValue] = useState(defaultValue ?? '');\n\n const isControlled = value !== undefined;\n const currentVal = isControlled ? value : internalValue;\n const hasValue = currentVal !== undefined && currentVal !== null && currentVal !== '';\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (!isControlled) {\n setInternalValue(e.target.value);\n }\n onChange?.(e);\n };\n\n const handleClear = () => {\n if (!isControlled) {\n setInternalValue('');\n }\n if (internalInputRef.current) {\n internalInputRef.current.value = '';\n const syntheticEvent = new Event('input', { bubbles: true });\n internalInputRef.current.dispatchEvent(syntheticEvent);\n internalInputRef.current.focus();\n }\n onClear?.();\n };\n\n const isPassword = type === 'password';\n const computedType = isPassword && showPassword ? 'text' : type;\n\n let computedRightIcon = rightIcon;\n if (!computedRightIcon) {\n if (isPassword && showPasswordToggle) {\n computedRightIcon = (\n <button\n type=\"button\"\n disabled={disabled}\n onClick={() => setShowPassword((prev) => !prev)}\n aria-label={showPassword ? 'Hide password' : 'Show password'}\n className=\"cursor-pointer text-[var(--patiya-color-muted-foreground)] hover:text-[var(--patiya-color-foreground)] transition-colors\"\n >\n {showPassword ? (eyeOffIcon || <DefaultEyeOffIcon />) : (eyeIcon || <DefaultEyeIcon />)}\n </button>\n );\n } else if (clearable && hasValue) {\n computedRightIcon = (\n <button\n type=\"button\"\n disabled={disabled}\n onClick={handleClear}\n aria-label=\"Clear input\"\n className=\"cursor-pointer text-xs px-1 text-[var(--patiya-color-muted-foreground)] hover:text-[var(--patiya-color-foreground)] transition-colors\"\n >\n ✕\n </button>\n );\n }\n }\n\n const sizeClasses: Record<PatiyaSize, string> = {\n xs: 'h-7 text-xs px-2',\n sm: 'h-8 text-sm px-3',\n md: 'h-10 text-base px-4',\n lg: 'h-12 text-lg px-4',\n xl: 'h-14 text-xl px-5',\n };\n\n const variantClasses = {\n outline: 'bg-transparent border border-[var(--patiya-color-border)] focus:border-[var(--patiya-color-primary)] shadow-[var(--patiya-shadow-sm)]',\n filled: 'bg-[var(--patiya-color-muted)] border border-transparent focus:bg-transparent focus:border-[var(--patiya-color-primary)]',\n soft: 'bg-[var(--patiya-color-primary)]/5 border border-transparent focus:bg-transparent focus:border-[var(--patiya-color-primary)]',\n };\n\n const inputClassName = cn(\n 'flex w-full rounded-md transition-all duration-200 outline-none',\n 'text-[var(--patiya-color-foreground)] placeholder:text-(--patiya-color-muted-foreground)',\n 'focus:ring-4 focus:ring-[var(--patiya-color-primary)]/10',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n sizeClasses[inputSize],\n variantClasses[variant],\n invalid && 'border-[var(--patiya-color-destructive)] focus:border-[var(--patiya-color-destructive)] focus:ring-[var(--patiya-color-destructive)]/10',\n leftIcon && 'pl-10',\n computedRightIcon && 'pr-10',\n !leftIcon && !computedRightIcon && className\n );\n\n if (leftIcon || computedRightIcon) {\n return (\n <Box className={cn('relative flex items-center w-full', className)}>\n {leftIcon && (\n <span className=\"absolute left-3 flex items-center justify-center text-(--patiya-color-muted-foreground) pointer-events-none\">\n {leftIcon}\n </span>\n )}\n <input\n ref={internalInputRef}\n type={computedType}\n disabled={disabled}\n value={value}\n defaultValue={defaultValue}\n onChange={handleInputChange}\n className={cn(inputClassName, 'w-full')}\n {...props}\n />\n {computedRightIcon && (\n <span className=\"absolute right-3 flex items-center justify-center text-(--patiya-color-muted-foreground)\">\n {computedRightIcon}\n </span>\n )}\n </Box>\n );\n }\n\n return (\n <input\n ref={internalInputRef}\n type={computedType}\n disabled={disabled}\n value={value}\n defaultValue={defaultValue}\n onChange={handleInputChange}\n className={inputClassName}\n {...props}\n />\n );\n }\n);\n\nInput.displayName = 'Input';\n"],"mappings":";;;;;AAkBA,IAAMA,UACJ,kBAAC,OAAD;CAAK,OAAM;CAA6B,OAAM;CAAK,QAAO;CAAK,SAAQ;CAAY,MAAK;CAAO,QAAO;CAAe,aAAY;CAAI,eAAc;CAAQ,gBAAe;CAA1K,UAAA,CACE,kBAAC,QAAD,EAAM,GAAE,+CAAgD,CAAA,GACxD,kBAAC,UAAD;EAAQ,IAAG;EAAK,IAAG;EAAK,GAAE;CAAK,CAAA,CAC5B;IAGDC,UACJ,kBAAC,OAAD;CAAK,OAAM;CAA6B,OAAM;CAAK,QAAO;CAAK,SAAQ;CAAY,MAAK;CAAO,QAAO;CAAe,aAAY;CAAI,eAAc;CAAQ,gBAAe;CAA1K,UAAA;EACE,kBAAC,QAAD,EAAM,GAAE,iCAAkC,CAAA;EAC1C,kBAAC,QAAD,EAAM,GAAE,+EAAgF,CAAA;EACxF,kBAAC,QAAD,EAAM,GAAE,yEAA0E,CAAA;EAClF,kBAAC,QAAD;GAAM,IAAG;GAAI,IAAG;GAAK,IAAG;GAAI,IAAG;EAAM,CAAA;CAClC;IAGMC,IAAQC,GAEjB,EACE,cACA,eAAY,MACZ,aAAU,WACV,aAAU,IACV,aACA,cACA,aACA,UAAO,QACP,wBAAqB,IACrB,YACA,eACA,eAAY,IACZ,YACA,UACA,iBACA,aACA,GAAGC,KAEL,MACG;CACH,IAAMC,IAAmBC,EAAyB,IAAI;CACtD,EAAoBC,SAAWF,EAAiB,OAA2B;C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