perf: do not import from @calcom/ui barrel file (#20184)
* Icon and IconName * Button and ButtonGroup * UserAvatar * AvatarGroup * Avatar * WizardLayout * Dialogs * EmptyScreen * showToast and TextField * Editor * Skeleton * Skeleton * TopBanner and showToast * Button again * more * perf: Remove app-store reference from @calcom/ui * more * Fixing types * Icon * Fixed casing * dropdown * more * Select * more * Badge * List * more * Divider * more * fix * fix type check * refactor * fix * fix * fix * fix * fix * fix * fix * fix type check * fix * fix * fix * fix * more * more * more * more * add index file to components/command * fix * fix * fix * fix imports * fix * fix * fix * fix * fix * fix * fix * fix build errors * fix build errors * fix --------- Co-authored-by: Keith Williams <[email protected]>
This commit is contained in:
1 parent
ca19aa00c1
commit
853f9bc436
548 files changed
+1860
-1502
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { vi } from "vitest";
|
||||
|
||||
vi.mock("../unpublished-entity/UnpublishedEntity", () => ({
|
||||
vi.mock("../unpublished-entity", () => ({
|
||||
UnpublishedEntity: () => <div data-testid="unpublished-entity">Mock Unpublished Entity</div>,
|
||||
}));
|
||||
@@ -0,0 +1,35 @@
|
||||
import cx from "@calcom/ui/classNames";
|
||||
|
||||
import { Input } from "../form";
|
||||
import { Icon } from "../icon";
|
||||
|
||||
export type AddressInputProps = {
|
||||
value: string;
|
||||
id?: string;
|
||||
placeholder?: string;
|
||||
required?: boolean;
|
||||
onChange: (val: string) => void;
|
||||
className?: string;
|
||||
};
|
||||
|
||||
function AddressInput({ value, onChange, ...rest }: AddressInputProps) {
|
||||
return (
|
||||
<div className="relative flex items-center">
|
||||
<Icon
|
||||
name="map-pin"
|
||||
className="text-muted absolute left-0.5 ml-3 h-4 w-4 -translate-y-1/2"
|
||||
style={{ top: "44%" }}
|
||||
/>
|
||||
<Input
|
||||
{...rest}
|
||||
value={value}
|
||||
onChange={(e) => {
|
||||
onChange(e.target.value);
|
||||
}}
|
||||
className={cx("pl-10", rest?.className)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default AddressInput;
|
||||
@@ -0,0 +1,8 @@
|
||||
import dynamic from "next/dynamic";
|
||||
|
||||
/** These are like 40kb that not every user needs */
|
||||
const AddressInput = dynamic(
|
||||
() => import("./AddressInput")
|
||||
) as unknown as typeof import("./AddressInput").default;
|
||||
|
||||
export default AddressInput;
|
||||
@@ -0,0 +1,100 @@
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
|
||||
import { Button } from "../button";
|
||||
import { EmailField } from "../form";
|
||||
import { Icon } from "../icon";
|
||||
import { Tooltip } from "../tooltip";
|
||||
|
||||
interface MultiEmailProps {
|
||||
value: string[];
|
||||
readOnly: boolean;
|
||||
label: string;
|
||||
setValue: (value: string[]) => void;
|
||||
placeholder?: string;
|
||||
}
|
||||
|
||||
function MultiEmail({ value, readOnly, label, setValue, placeholder }: MultiEmailProps) {
|
||||
const { t } = useLocale();
|
||||
value = value || [];
|
||||
const inputClassName =
|
||||
"dark:placeholder:text-muted focus:border-emphasis border-subtle block w-full rounded-md border-default text-sm focus:ring-black disabled:bg-emphasis disabled:hover:cursor-not-allowed dark:selection:bg-green-500 disabled:dark:text-subtle";
|
||||
return (
|
||||
<>
|
||||
{value.length ? (
|
||||
<div>
|
||||
<label htmlFor="emails" className="text-default my-2 block text-sm font-medium">
|
||||
{label}
|
||||
</label>
|
||||
<ul>
|
||||
{value.map((field, index) => (
|
||||
<li key={index}>
|
||||
<EmailField
|
||||
disabled={readOnly}
|
||||
value={field}
|
||||
className={inputClassName}
|
||||
onChange={(e) => {
|
||||
const updatedValue = [...value];
|
||||
updatedValue[index] = e.target.value;
|
||||
setValue(updatedValue);
|
||||
}}
|
||||
placeholder={placeholder}
|
||||
label={<></>}
|
||||
required
|
||||
onClickAddon={() => {
|
||||
const updatedValue = [...value];
|
||||
updatedValue.splice(index, 1);
|
||||
setValue(updatedValue);
|
||||
}}
|
||||
addOnSuffix={
|
||||
!readOnly ? (
|
||||
<Tooltip content="Remove email">
|
||||
<button className="m-1" type="button">
|
||||
<Icon name="x" width={12} className="text-default" />
|
||||
</button>
|
||||
</Tooltip>
|
||||
) : null
|
||||
}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{!readOnly && (
|
||||
<Button
|
||||
data-testid="add-another-email"
|
||||
type="button"
|
||||
color="minimal"
|
||||
StartIcon="user-plus"
|
||||
className="my-2.5"
|
||||
onClick={() => {
|
||||
const updatedValue = [...value];
|
||||
updatedValue.push("");
|
||||
setValue(updatedValue);
|
||||
}}>
|
||||
{t("add_another")}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
|
||||
{!value.length && !readOnly && (
|
||||
<Button
|
||||
data-testid="add-emails"
|
||||
color="minimal"
|
||||
variant="button"
|
||||
StartIcon="user-plus"
|
||||
onClick={() => {
|
||||
const updatedValue = [...value];
|
||||
updatedValue.push("");
|
||||
setValue(updatedValue);
|
||||
}}
|
||||
className="mr-auto">
|
||||
{label}
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default MultiEmail;
|
||||
@@ -0,0 +1,6 @@
|
||||
import dynamic from "next/dynamic";
|
||||
|
||||
/** These are like 40kb that not every user needs */
|
||||
const MultiEmail = dynamic(() => import("./MultiEmail")) as unknown as typeof import("./MultiEmail").default;
|
||||
|
||||
export default MultiEmail;
|
||||
@@ -0,0 +1,106 @@
|
||||
import type { GroupBase, InputProps, Props } from "react-select";
|
||||
import ReactSelect, { components } from "react-select";
|
||||
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
|
||||
export type SelectProps<
|
||||
Option,
|
||||
IsMulti extends boolean = false,
|
||||
Group extends GroupBase<Option> = GroupBase<Option>
|
||||
> = Props<Option, IsMulti, Group>;
|
||||
|
||||
export const InputComponent = <Option, IsMulti extends boolean, Group extends GroupBase<Option>>({
|
||||
inputClassName,
|
||||
...props
|
||||
}: InputProps<Option, IsMulti, Group>) => {
|
||||
return (
|
||||
<components.Input
|
||||
// disables our default form focus highlight on the react-select input element
|
||||
inputClassName={classNames("focus:ring-0 focus:ring-offset-0", inputClassName)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
function Select<
|
||||
Option,
|
||||
IsMulti extends boolean = false,
|
||||
Group extends GroupBase<Option> = GroupBase<Option>
|
||||
>({ className, ...props }: SelectProps<Option, IsMulti, Group>) {
|
||||
return (
|
||||
<ReactSelect
|
||||
theme={(theme) => ({
|
||||
...theme,
|
||||
borderRadius: 2,
|
||||
colors: {
|
||||
...theme.colors,
|
||||
primary: "var(--brand-color)",
|
||||
|
||||
primary50: "rgba(209 , 213, 219, var(--tw-bg-opacity))",
|
||||
primary25: "rgba(244, 245, 246, var(--tw-bg-opacity))",
|
||||
},
|
||||
})}
|
||||
styles={{
|
||||
option: (provided, state) => ({
|
||||
...provided,
|
||||
color: state.isSelected ? "var(--brand-text-color)" : "black",
|
||||
":active": {
|
||||
backgroundColor: state.isSelected ? "" : "var(--brand-color)",
|
||||
color: "var(--brand-text-color)",
|
||||
},
|
||||
}),
|
||||
}}
|
||||
components={{
|
||||
...components,
|
||||
IndicatorSeparator: () => null,
|
||||
Input: InputComponent,
|
||||
}}
|
||||
className={className}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default Select;
|
||||
|
||||
export function UnstyledSelect<
|
||||
Option,
|
||||
IsMulti extends boolean = false,
|
||||
Group extends GroupBase<Option> = GroupBase<Option>
|
||||
>({ ...props }: SelectProps<Option, IsMulti, Group>) {
|
||||
return (
|
||||
<ReactSelect
|
||||
{...props}
|
||||
isSearchable={false}
|
||||
theme={(theme) => ({ ...theme, borderRadius: 0, border: "none" })}
|
||||
components={{
|
||||
IndicatorSeparator: () => null,
|
||||
Input: InputComponent,
|
||||
}}
|
||||
styles={{
|
||||
container: (provided) => ({
|
||||
...provided,
|
||||
width: "100%",
|
||||
}),
|
||||
control: (provided) => ({
|
||||
...provided,
|
||||
backgroundColor: " transparent",
|
||||
border: "none",
|
||||
boxShadow: "none",
|
||||
}),
|
||||
option: (provided, state) => ({
|
||||
...provided,
|
||||
color: state.isSelected ? "var(--brand-text-color)" : "black",
|
||||
":active": {
|
||||
backgroundColor: state.isSelected ? "" : "var(--brand-color)",
|
||||
color: "var(--brand-text-color)",
|
||||
},
|
||||
}),
|
||||
indicatorSeparator: () => ({
|
||||
display: "hidden",
|
||||
color: "black",
|
||||
}),
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
import { useId } from "@radix-ui/react-id";
|
||||
import type { ReactElement, ReactNode, Ref } from "react";
|
||||
import React, { forwardRef } from "react";
|
||||
import type { FieldValues, SubmitHandler, UseFormReturn } from "react-hook-form";
|
||||
import { FormProvider, useFormContext } from "react-hook-form";
|
||||
|
||||
import { getErrorFromUnknown } from "@calcom/lib/errors";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
|
||||
import { Alert } from "../alert";
|
||||
import { showToast } from "../toast";
|
||||
|
||||
type InputProps = Omit<JSX.IntrinsicElements["input"], "name"> & { name: string };
|
||||
|
||||
export const Input = forwardRef<HTMLInputElement, InputProps>(function Input(props, ref) {
|
||||
return (
|
||||
<input
|
||||
{...props}
|
||||
ref={ref}
|
||||
className={classNames(
|
||||
"border-default mt-1 block w-full rounded-sm border px-3 py-2 shadow-sm focus:border-neutral-800 focus:outline-none focus:ring-1 focus:ring-neutral-800 sm:text-sm",
|
||||
props.className
|
||||
)}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
export function Label(props: JSX.IntrinsicElements["label"]) {
|
||||
return (
|
||||
<label {...props} className={classNames("text-default block text-sm font-medium", props.className)}>
|
||||
{props.children}
|
||||
</label>
|
||||
);
|
||||
}
|
||||
|
||||
export function InputLeading(props: JSX.IntrinsicElements["div"]) {
|
||||
return (
|
||||
<span className="bg-muted border-default text-subtle inline-flex flex-shrink-0 items-center rounded-l-sm border border-r-0 px-3 sm:text-sm">
|
||||
{props.children}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
type InputFieldProps = {
|
||||
label?: ReactNode;
|
||||
hint?: ReactNode;
|
||||
addOnLeading?: ReactNode;
|
||||
} & React.ComponentProps<typeof Input> & {
|
||||
labelProps?: React.ComponentProps<typeof Label>;
|
||||
};
|
||||
|
||||
const InputField = forwardRef<HTMLInputElement, InputFieldProps>(function InputField(props, ref) {
|
||||
const id = useId();
|
||||
const { t } = useLocale();
|
||||
const methods = useFormContext();
|
||||
const {
|
||||
label = t(props.name),
|
||||
labelProps,
|
||||
placeholder = t(`${props.name}_placeholder`) !== `${props.name}_placeholder`
|
||||
? t(`${props.name}_placeholder`)
|
||||
: "",
|
||||
className,
|
||||
addOnLeading,
|
||||
hint,
|
||||
...passThrough
|
||||
} = props;
|
||||
return (
|
||||
<div>
|
||||
{!!props.name && (
|
||||
<Label htmlFor={id} {...labelProps}>
|
||||
{label}
|
||||
</Label>
|
||||
)}
|
||||
{addOnLeading ? (
|
||||
<div className="mt-1 flex rounded-md shadow-sm">
|
||||
{addOnLeading}
|
||||
<Input
|
||||
id={id}
|
||||
placeholder={placeholder}
|
||||
className={classNames("mt-0", props.addOnLeading && "rounded-l-none", className)}
|
||||
{...passThrough}
|
||||
ref={ref}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<Input id={id} placeholder={placeholder} className={className} {...passThrough} ref={ref} />
|
||||
)}
|
||||
{hint}
|
||||
{methods?.formState?.errors[props.name]?.message && (
|
||||
<Alert
|
||||
className="mt-1"
|
||||
severity="error"
|
||||
message={<>{methods.formState.errors[props.name]?.message}</>}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
export const TextField = forwardRef<HTMLInputElement, InputFieldProps>(function TextField(props, ref) {
|
||||
return <InputField ref={ref} {...props} />;
|
||||
});
|
||||
|
||||
export const PasswordField = forwardRef<HTMLInputElement, InputFieldProps>(function PasswordField(
|
||||
props,
|
||||
ref
|
||||
) {
|
||||
return (
|
||||
<InputField data-testid="password" type="password" placeholder="•••••••••••••" ref={ref} {...props} />
|
||||
);
|
||||
});
|
||||
|
||||
export const EmailInput = forwardRef<HTMLInputElement, InputFieldProps>(function EmailInput(props, ref) {
|
||||
return (
|
||||
<Input
|
||||
ref={ref}
|
||||
type="email"
|
||||
autoCapitalize="none"
|
||||
autoComplete="email"
|
||||
autoCorrect="off"
|
||||
inputMode="email"
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
export const EmailField = forwardRef<HTMLInputElement, InputFieldProps>(function EmailField(props, ref) {
|
||||
return (
|
||||
<InputField
|
||||
ref={ref}
|
||||
type="email"
|
||||
autoCapitalize="none"
|
||||
autoComplete="email"
|
||||
autoCorrect="off"
|
||||
inputMode="email"
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
type TextAreaProps = Omit<JSX.IntrinsicElements["textarea"], "name"> & { name: string };
|
||||
|
||||
export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(function TextAreaInput(props, ref) {
|
||||
return (
|
||||
<textarea
|
||||
ref={ref}
|
||||
{...props}
|
||||
className={classNames(
|
||||
"border-default block w-full rounded-sm shadow-sm focus:border-neutral-900 focus:ring-neutral-900 sm:text-sm",
|
||||
props.className
|
||||
)}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
type TextAreaFieldProps = {
|
||||
label?: ReactNode;
|
||||
} & React.ComponentProps<typeof TextArea> & {
|
||||
labelProps?: React.ComponentProps<typeof Label>;
|
||||
};
|
||||
|
||||
export const TextAreaField = forwardRef<HTMLTextAreaElement, TextAreaFieldProps>(function TextField(
|
||||
props,
|
||||
ref
|
||||
) {
|
||||
const id = useId();
|
||||
const { t } = useLocale();
|
||||
const methods = useFormContext();
|
||||
const {
|
||||
label = t(props.name as string),
|
||||
labelProps,
|
||||
placeholder = t(`${props.name}_placeholder`) !== `${props.name}_placeholder`
|
||||
? t(`${props.name}_placeholder`)
|
||||
: "",
|
||||
...passThrough
|
||||
} = props;
|
||||
return (
|
||||
<div>
|
||||
{!!props.name && (
|
||||
<Label htmlFor={id} {...labelProps}>
|
||||
{label}
|
||||
</Label>
|
||||
)}
|
||||
<TextArea ref={ref} placeholder={placeholder} {...passThrough} />
|
||||
{methods?.formState?.errors[props.name]?.message && (
|
||||
<Alert
|
||||
className="mt-1"
|
||||
severity="error"
|
||||
message={<>{methods.formState.errors[props.name]?.message}</>}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
type FormProps<T extends object> = { form: UseFormReturn<T>; handleSubmit: SubmitHandler<T> } & Omit<
|
||||
JSX.IntrinsicElements["form"],
|
||||
"onSubmit"
|
||||
>;
|
||||
|
||||
const PlainForm = <T extends FieldValues>(props: FormProps<T>, ref: Ref<HTMLFormElement>) => {
|
||||
const { form, handleSubmit, ...passThrough } = props;
|
||||
|
||||
return (
|
||||
<FormProvider {...form}>
|
||||
<form
|
||||
ref={ref}
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
form
|
||||
.handleSubmit(handleSubmit)(event)
|
||||
.catch((err) => {
|
||||
showToast(`${getErrorFromUnknown(err).message}`, "error");
|
||||
});
|
||||
}}
|
||||
{...passThrough}>
|
||||
{
|
||||
/* @see https://react-hook-form.com/advanced-usage/#SmartFormComponent */
|
||||
React.Children.map(props.children, (child) => {
|
||||
return typeof child !== "string" &&
|
||||
typeof child !== "number" &&
|
||||
typeof child !== "boolean" &&
|
||||
child &&
|
||||
"props" in child &&
|
||||
child.props.name
|
||||
? React.createElement(child.type, {
|
||||
...{
|
||||
...child.props,
|
||||
register: form.register,
|
||||
key: child.props.name,
|
||||
},
|
||||
})
|
||||
: child;
|
||||
})
|
||||
}
|
||||
</form>
|
||||
</FormProvider>
|
||||
);
|
||||
};
|
||||
|
||||
export const Form = forwardRef(PlainForm) as <T extends FieldValues>(
|
||||
p: FormProps<T> & { ref?: Ref<HTMLFormElement> }
|
||||
) => ReactElement;
|
||||
|
||||
export function FieldsetLegend(props: JSX.IntrinsicElements["legend"]) {
|
||||
return (
|
||||
<legend {...props} className={classNames("text-default text-sm font-medium", props.className)}>
|
||||
{props.children}
|
||||
</legend>
|
||||
);
|
||||
}
|
||||
|
||||
export function InputGroupBox(props: JSX.IntrinsicElements["div"]) {
|
||||
return (
|
||||
<div
|
||||
{...props}
|
||||
className={classNames("bg-default border-default space-y-2 rounded-sm border p-2", props.className)}>
|
||||
{props.children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export { default as AddressInput } from "./AddressInputLazy";
|
||||
export { default as MultiEmail } from "./MultiEmailLazy";
|
||||
@@ -1 +1,2 @@
|
||||
export { AppListCard } from "./AppListCard";
|
||||
export type { AppListCardProps } from "./AppListCard";
|
||||
@@ -0,0 +1,11 @@
|
||||
export {
|
||||
Command,
|
||||
CommandDialog,
|
||||
CommandInput,
|
||||
CommandList,
|
||||
CommandEmpty,
|
||||
CommandGroup,
|
||||
CommandItem,
|
||||
CommandShortcut,
|
||||
CommandSeparator,
|
||||
} from "./Command";
|
||||
@@ -1,5 +1,5 @@
|
||||
export { Checkbox, MultiSelectCheckbox, CheckboxField } from "./checkbox";
|
||||
export type { Option } from "./checkbox";
|
||||
export type { Option as MultiSelectCheckboxesOptionType } from "./checkbox";
|
||||
export { HintsOrErrors } from "./inputs/HintOrErrors";
|
||||
export {
|
||||
EmailField,
|
||||
@@ -15,7 +15,7 @@ export {
|
||||
} from "./inputs/Input";
|
||||
|
||||
export { InputFieldWithSelect } from "./inputs/InputFieldWithSelect";
|
||||
|
||||
export type { InputFieldProps, InputProps } from "./inputs/types";
|
||||
export { InputField, Input, TextField, inputStyles } from "./inputs/TextField";
|
||||
export { InputError } from "./inputs/InputError";
|
||||
export { Form } from "./inputs/Form";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { forwardRef } from "react";
|
||||
|
||||
import { UnstyledSelect } from "../../../form/Select";
|
||||
import { UnstyledSelect } from "../../address/Select";
|
||||
import { InputField } from "./TextField";
|
||||
import type { InputFieldProps } from "./types";
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { TooltipProvider } from "@radix-ui/react-tooltip";
|
||||
import { render, fireEvent } from "@testing-library/react";
|
||||
import { vi } from "vitest";
|
||||
|
||||
import type { UnstyledSelect } from "../../../form/Select";
|
||||
import type { UnstyledSelect } from "../../address/Select";
|
||||
import { EmailField, TextAreaField, PasswordField, NumberInput, FilterSearchField } from "./Input";
|
||||
import { InputFieldWithSelect } from "./InputFieldWithSelect";
|
||||
import { InputField } from "./TextField";
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { ReactNode } from "react";
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
|
||||
import { Label } from "../inputs/Label";
|
||||
import Switch from "./Switch";
|
||||
import { Switch } from "./Switch";
|
||||
|
||||
type Props = {
|
||||
children?: ReactNode;
|
||||
@@ -26,7 +26,7 @@ type Props = {
|
||||
hideSwitch?: boolean;
|
||||
};
|
||||
|
||||
function SettingsToggle({
|
||||
export function SettingsToggle({
|
||||
checked,
|
||||
onCheckedChange,
|
||||
description,
|
||||
@@ -123,5 +123,3 @@ function SettingsToggle({
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default SettingsToggle;
|
||||
@@ -14,7 +14,7 @@ const Wrapper = ({ children, tooltip }: { tooltip?: string; children: React.Reac
|
||||
}
|
||||
return <Tooltip content={tooltip}>{children}</Tooltip>;
|
||||
};
|
||||
const Switch = (
|
||||
export const Switch = (
|
||||
props: React.ComponentProps<typeof PrimitiveSwitch.Root> & {
|
||||
label?: string | ReactNode;
|
||||
fitToHeight?: boolean;
|
||||
@@ -87,5 +87,3 @@ const Switch = (
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
export default Switch;
|
||||
@@ -1,2 +1,2 @@
|
||||
export { default as SettingsToggle } from "./SettingsToggle";
|
||||
export { default as Switch } from "./Switch";
|
||||
export { SettingsToggle } from "./SettingsToggle";
|
||||
export { Switch } from "./Switch";
|
||||
@@ -1,3 +1,5 @@
|
||||
export { default as Icon } from "./Icon";
|
||||
export type { IconName } from "./icon-names";
|
||||
export { IconSprites } from "./IconSprites";
|
||||
export { Spinner } from "./Spinner";
|
||||
export { SatSymbol } from "./SatSymbol";
|
||||
@@ -0,0 +1,78 @@
|
||||
"use client";
|
||||
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import { noop } from "lodash";
|
||||
import { usePathname } from "next/navigation";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Toaster } from "sonner";
|
||||
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
|
||||
import { Button } from "../../components/button/Button";
|
||||
import { StepCard } from "../../components/card/StepCard";
|
||||
import { Steps } from "../../components/form/step/Steps";
|
||||
import { SkeletonText } from "../../components/skeleton/Skeleton";
|
||||
|
||||
export function WizardLayout({
|
||||
children,
|
||||
maxSteps = 2,
|
||||
currentStep = 0,
|
||||
isOptionalCallback,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
} & { maxSteps?: number; currentStep?: number; isOptionalCallback?: () => void }) {
|
||||
const { t, isLocaleReady } = useLocale();
|
||||
const [meta, setMeta] = useState({ title: "", subtitle: " " });
|
||||
const pathname = usePathname();
|
||||
const { title, subtitle } = meta;
|
||||
|
||||
useEffect(() => {
|
||||
setMeta({
|
||||
title: window.document.title,
|
||||
subtitle: window.document.querySelector('meta[name="description"]')?.getAttribute("content") || "",
|
||||
});
|
||||
}, [pathname]);
|
||||
|
||||
return (
|
||||
<div className="bg-default text-emphasis min-h-screen" data-testid="onboarding">
|
||||
<div>
|
||||
<Toaster position="bottom-right" />
|
||||
</div>
|
||||
<div className="mx-auto px-4 py-24">
|
||||
<div className="relative">
|
||||
<div className="sm:mx-auto sm:w-full sm:max-w-[600px]">
|
||||
<div className="mx-auto sm:max-w-[520px]">
|
||||
<header>
|
||||
{isLocaleReady ? (
|
||||
<>
|
||||
<p className="font-cal mb-3 text-[28px] font-medium leading-7">
|
||||
{title.replace(` | ${APP_NAME}`, "")}
|
||||
</p>
|
||||
<p className="text-subtle font-sans text-sm font-normal">{subtitle} </p>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<SkeletonText className="h-6 w-1/2" />
|
||||
<SkeletonText className="mt-4 h-4 w-3/4" />
|
||||
</>
|
||||
)}
|
||||
</header>
|
||||
<Steps maxSteps={maxSteps} currentStep={currentStep} nextStep={noop} />
|
||||
</div>
|
||||
<StepCard>{children}</StepCard>
|
||||
</div>
|
||||
</div>
|
||||
{isOptionalCallback && (
|
||||
<div className="mt-4 flex justify-center">
|
||||
<Button data-testid="handle-later-button" color="minimal" onClick={isOptionalCallback}>
|
||||
{t("ill_do_this_later")}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export const getLayout = (page: React.ReactElement) => <WizardLayout>{page}</WizardLayout>;
|
||||
@@ -1 +1,2 @@
|
||||
export { ShellSubHeading } from "./ShellSubHeading";
|
||||
export { WizardLayout } from "./WizardLayout";
|
||||
@@ -1,6 +1,6 @@
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
|
||||
export default function Logo({
|
||||
export function Logo({
|
||||
small,
|
||||
icon,
|
||||
inline = true,
|
||||
|
||||
@@ -1 +1 @@
|
||||
export { default as Logo } from "./Logo";
|
||||
export { Logo } from "./Logo";
|
||||
@@ -0,0 +1,67 @@
|
||||
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
||||
import type { ReactNode } from "react";
|
||||
import React from "react";
|
||||
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
|
||||
export const Group = (props: RadioGroupPrimitive.RadioGroupProps & { children: ReactNode }) => (
|
||||
<RadioGroupPrimitive.Root {...props}>{props.children}</RadioGroupPrimitive.Root>
|
||||
);
|
||||
export const Radio = (props: RadioGroupPrimitive.RadioGroupItemProps & { children: ReactNode }) => (
|
||||
<RadioGroupPrimitive.Item
|
||||
{...props}
|
||||
className={classNames(
|
||||
"hover:bg-subtle border-default dark:checked:bg-brand-default dark:hover:bg-subtle dark:checked:hover:bg-brand-default focus:ring-brand-default hover:border-emphasis me-1.5 mt-0.5 h-4 w-4 flex-shrink-0 rounded-full border text-[--cal-brand] transition focus:border-0 focus:ring-1",
|
||||
props.disabled && "opacity-60"
|
||||
)}>
|
||||
{props.children}
|
||||
</RadioGroupPrimitive.Item>
|
||||
);
|
||||
export const Indicator = ({ disabled }: { disabled?: boolean }) => (
|
||||
<RadioGroupPrimitive.Indicator
|
||||
className={classNames(
|
||||
"after:bg-default dark:after:bg-brand-accent relative flex h-full w-full items-center justify-center rounded-full bg-black after:h-[6px] after:w-[6px] after:rounded-full after:content-['']",
|
||||
disabled ? "after:bg-muted" : "bg-brand-default"
|
||||
)}
|
||||
/>
|
||||
);
|
||||
|
||||
export const Label = (props: JSX.IntrinsicElements["label"] & { disabled?: boolean }) => (
|
||||
<label
|
||||
{...props}
|
||||
className={classNames(
|
||||
"text-emphasis ms-2 w-full text-sm font-medium leading-5",
|
||||
props.disabled && "text-subtle"
|
||||
)}
|
||||
/>
|
||||
);
|
||||
|
||||
export const RadioField = ({
|
||||
label,
|
||||
disabled,
|
||||
id,
|
||||
value,
|
||||
className,
|
||||
withPadding,
|
||||
}: {
|
||||
label: string | ReactNode;
|
||||
disabled?: boolean;
|
||||
id: string;
|
||||
value: string;
|
||||
className?: string;
|
||||
withPadding?: boolean;
|
||||
}) => (
|
||||
<div
|
||||
className={classNames(
|
||||
"flex items-start",
|
||||
withPadding && "hover:bg-subtle cursor-pointer rounded-lg p-1.5",
|
||||
className
|
||||
)}>
|
||||
<Radio value={value} disabled={disabled} id={id}>
|
||||
<Indicator disabled={disabled} />
|
||||
</Radio>
|
||||
<Label htmlFor={id} disabled={disabled}>
|
||||
{label}
|
||||
</Label>
|
||||
</div>
|
||||
);
|
||||
@@ -0,0 +1,59 @@
|
||||
import { useId } from "@radix-ui/react-id";
|
||||
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
|
||||
type RadioAreaProps = RadioGroupPrimitive.RadioGroupItemProps & {
|
||||
children: ReactNode;
|
||||
classNames?: { container?: string };
|
||||
};
|
||||
|
||||
const RadioArea = ({ children, className, classNames: innerClassNames, ...props }: RadioAreaProps) => {
|
||||
const radioAreaId = useId();
|
||||
const id = props.id ?? radioAreaId;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classNames(
|
||||
"border-subtle [&:has(input:checked)]:border-emphasis relative flex items-start rounded-[10px] border ",
|
||||
className
|
||||
)}>
|
||||
<RadioGroupPrimitive.Item
|
||||
id={id}
|
||||
{...props}
|
||||
className={classNames(
|
||||
"hover:bg-subtle disabled:hover:bg-default border-default focus:ring-emphasis absolute left-3 top-[0.9rem] mt-0.5 h-4 w-4 flex-shrink-0 rounded-full border transition focus:ring-2 disabled:cursor-not-allowed",
|
||||
props.disabled && "opacity-60"
|
||||
)}>
|
||||
<RadioGroupPrimitive.Indicator
|
||||
className={classNames(
|
||||
"after:bg-default dark:after:bg-inverted relative flex h-full w-full items-center justify-center rounded-full bg-black after:h-[6px] after:w-[6px] after:rounded-full after:content-['']",
|
||||
props.disabled ? "after:bg-muted" : "bg-black"
|
||||
)}
|
||||
/>
|
||||
</RadioGroupPrimitive.Item>
|
||||
<label htmlFor={id} className={classNames("text-default p-4 pl-10 pt-3", innerClassNames?.container)}>
|
||||
{children}
|
||||
</label>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const RadioAreaGroup = ({
|
||||
children,
|
||||
className,
|
||||
onValueChange,
|
||||
...passThroughProps
|
||||
}: RadioGroupPrimitive.RadioGroupProps) => {
|
||||
return (
|
||||
<RadioGroupPrimitive.Root className={className} onValueChange={onValueChange} {...passThroughProps}>
|
||||
{children}
|
||||
</RadioGroupPrimitive.Root>
|
||||
);
|
||||
};
|
||||
|
||||
const Item = RadioArea;
|
||||
const Group = RadioAreaGroup;
|
||||
|
||||
export { RadioArea, RadioAreaGroup, Item, Group };
|
||||
@@ -0,0 +1,8 @@
|
||||
export * as RadioAreaGroup from "./RadioAreaGroup";
|
||||
export {
|
||||
Group as RadioGroup,
|
||||
Indicator as RadioIndicator,
|
||||
Label as RadioLabel,
|
||||
Radio,
|
||||
RadioField,
|
||||
} from "./Radio";
|
||||
@@ -1,4 +1,6 @@
|
||||
export { Table } from "./Table";
|
||||
export { TableActions, DropdownActions } from "./TableActions";
|
||||
export type { ActionType } from "./TableActions";
|
||||
export {
|
||||
Table as TableNew,
|
||||
TableBody,
|
||||
|
||||
Reference in new issue
Block a user