karsten-design-system 1.1.39 → 1.1.40
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.js +5 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -623,23 +623,23 @@ function Input({ onChange, placeholder, disabled = false, error, icon, onClickIc
|
|
|
623
623
|
}
|
|
624
624
|
};
|
|
625
625
|
useEffect(() => {
|
|
626
|
-
const formatted = applyMask(props
|
|
626
|
+
const formatted = applyMask(props?.value ?? '', mask);
|
|
627
627
|
setInputValue(formatted);
|
|
628
|
-
}, [props
|
|
628
|
+
}, [props?.value, mask]);
|
|
629
629
|
const handleChange = (e) => {
|
|
630
630
|
const value = applyMask(e.target.value, mask);
|
|
631
631
|
setInputValue(value);
|
|
632
632
|
onChange(value);
|
|
633
633
|
};
|
|
634
|
-
const hasError = (props
|
|
635
|
-
(!!error && !disabled && props
|
|
634
|
+
const hasError = (props?.value && error && !disabled) ||
|
|
635
|
+
(!!error && !disabled && props?.value?.length === 0);
|
|
636
636
|
return (jsxRuntimeExports.jsxs("div", { className: "relative flex flex-col w-100", children: [jsxRuntimeExports.jsxs(IconField, { className: "w-100", children: [jsxRuntimeExports.jsx(InputIcon, { className: clsx(`pi ${icon} px-2 cursor-pointer`, hasError
|
|
637
637
|
? 'text-redError'
|
|
638
638
|
: disabled
|
|
639
639
|
? 'text-stone'
|
|
640
640
|
: variants$4[iconColor]), onClick: onClickIcon }), jsxRuntimeExports.jsx(InputText, { id: inputId, type: "text", placeholder: placeholder, className: clsx('focus:shadow-none text-base w-100 font-roboto border !p-2 rounded-md', hasError
|
|
641
641
|
? 'border-redError placeholder:text-redError'
|
|
642
|
-
: 'border-gray focus:border-primary', disabled && 'border-stoneDark text-disabled', error && 'border-redError text-redError', !error && 'border-gray placeholder:text-gray'), onChange: handleChange, disabled: disabled, invalid: hasError, ...props, value: inputValue })] }), jsxRuntimeExports.jsx(FloatingLabel, { value: props?.value ? props
|
|
642
|
+
: 'border-gray focus:border-primary', disabled && 'border-stoneDark text-disabled', error && 'border-redError text-redError', !error && 'border-gray placeholder:text-gray'), onChange: handleChange, disabled: disabled, invalid: hasError, ...props, value: inputValue })] }), jsxRuntimeExports.jsx(FloatingLabel, { value: props?.value ? props?.value?.toString() : '', label: label || '', disabled: disabled, error: error }), hasError && jsxRuntimeExports.jsx("span", { className: "text-redError text-xs px-2", children: error })] }));
|
|
643
643
|
}
|
|
644
644
|
|
|
645
645
|
function AutoComplete({ items, onChange, error, ...props }) {
|