App Store Search (#5704)
Co-authored-by: Alex van Andel <[email protected]> Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
13 files changed
+312
-58
No files matched your search
@@ -6,7 +6,7 @@ import classNames from "@calcom/lib/classNames";
|
||||
import { getErrorFromUnknown } from "@calcom/lib/errors";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
|
||||
import { Alert, showToast, Skeleton, Tooltip, UnstyledSelect } from "../../..";
|
||||
import { Alert, showToast, Icon, Skeleton, Tooltip, UnstyledSelect } from "../../..";
|
||||
import { HintsOrErrors } from "./HintOrErrors";
|
||||
import { Label } from "./Label";
|
||||
|
||||
@@ -44,9 +44,8 @@ type InputFieldProps = {
|
||||
addOnLeading?: ReactNode;
|
||||
addOnSuffix?: ReactNode;
|
||||
inputIsFullWidth?: boolean;
|
||||
/**@Default paddingX 12px */
|
||||
addOnPadding?: number;
|
||||
addOnFilled?: boolean;
|
||||
addOnClassname?: string;
|
||||
error?: string;
|
||||
labelSrOnly?: boolean;
|
||||
containerClassName?: string;
|
||||
@@ -61,13 +60,15 @@ type AddonProps = {
|
||||
isFilled?: boolean;
|
||||
className?: string;
|
||||
error?: boolean;
|
||||
paddingX?: number;
|
||||
};
|
||||
|
||||
const Addon = ({ isFilled, children, className, error, paddingX = 12 }: AddonProps) => (
|
||||
const Addon = ({ isFilled, children, className, error }: AddonProps) => (
|
||||
<div
|
||||
style={{ padding: `0 ${paddingX}px` }}
|
||||
className={classNames("addon-wrapper h-9 border border-gray-300", isFilled && "bg-gray-100", className)}>
|
||||
className={classNames(
|
||||
"addon-wrapper h-9 border border-gray-300 px-3",
|
||||
isFilled && "bg-gray-100",
|
||||
className
|
||||
)}>
|
||||
<div className={classNames("flex h-full flex-col justify-center text-sm", error && "text-red-900")}>
|
||||
<span className="whitespace-nowrap py-2.5">{children}</span>
|
||||
</div>
|
||||
@@ -88,9 +89,10 @@ export const InputField = forwardRef<HTMLInputElement, InputFieldProps>(function
|
||||
addOnLeading,
|
||||
addOnSuffix,
|
||||
addOnFilled = true,
|
||||
addOnPadding,
|
||||
addOnClassname,
|
||||
inputIsFullWidth,
|
||||
hint,
|
||||
type,
|
||||
hintErrors,
|
||||
labelSrOnly,
|
||||
containerClassName,
|
||||
@@ -99,6 +101,8 @@ export const InputField = forwardRef<HTMLInputElement, InputFieldProps>(function
|
||||
...passThrough
|
||||
} = props;
|
||||
|
||||
const [inputValue, setInputValue] = useState<string>("");
|
||||
|
||||
return (
|
||||
<div className={classNames(containerClassName)}>
|
||||
{!!name && (
|
||||
@@ -114,28 +118,45 @@ export const InputField = forwardRef<HTMLInputElement, InputFieldProps>(function
|
||||
{addOnLeading || addOnSuffix ? (
|
||||
<div className="relative mb-1 flex items-center rounded-md focus-within:outline-none focus-within:ring-2 focus-within:ring-neutral-800 focus-within:ring-offset-1">
|
||||
{addOnLeading && (
|
||||
<Addon isFilled={addOnFilled} className="rounded-l-md border-r-0" paddingX={addOnPadding}>
|
||||
<Addon isFilled={addOnFilled} className={classNames("rounded-l-md border-r-0", addOnClassname)}>
|
||||
{addOnLeading}
|
||||
</Addon>
|
||||
)}
|
||||
<Input
|
||||
id={id}
|
||||
placeholder={placeholder}
|
||||
{...passThrough}
|
||||
{...(type == "search" && {
|
||||
onChange: (e) => {
|
||||
setInputValue(e.target.value);
|
||||
props.onChange && props.onChange(e);
|
||||
},
|
||||
value: inputValue,
|
||||
})}
|
||||
isFullWidth={inputIsFullWidth}
|
||||
className={classNames(
|
||||
className,
|
||||
addOnLeading && "rounded-l-none",
|
||||
addOnSuffix && "rounded-r-none",
|
||||
type === "search" && "pr-8",
|
||||
"!my-0 !ring-0"
|
||||
)}
|
||||
{...passThrough}
|
||||
ref={ref}
|
||||
/>
|
||||
{addOnSuffix && (
|
||||
<Addon isFilled={addOnFilled} className="rounded-r-md border-l-0" paddingX={addOnPadding}>
|
||||
<Addon isFilled={addOnFilled} className={classNames("rounded-r-md border-l-0", addOnClassname)}>
|
||||
{addOnSuffix}
|
||||
</Addon>
|
||||
)}
|
||||
{type === "search" && inputValue?.toString().length > 0 && (
|
||||
<Icon.FiX
|
||||
className="absolute right-2 top-2.5 h-4 w-4 cursor-pointer text-gray-500"
|
||||
onClick={(e) => {
|
||||
setInputValue("");
|
||||
props.onChange && props.onChange(e as unknown as React.ChangeEvent<HTMLInputElement>);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<Input
|
||||
@@ -344,7 +365,7 @@ export const InputFieldWithSelect = forwardRef<
|
||||
ref={ref}
|
||||
{...props}
|
||||
inputIsFullWidth={false}
|
||||
addOnPadding={0}
|
||||
addOnClassname="!px-0"
|
||||
addOnSuffix={<UnstyledSelect {...props.selectProps} />}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user