* feat: Cal.diy — community-driven MIT-licensed fork of Cal.com This squashed commit contains all Cal.diy changes applied on top of calcom/cal.com main: - Rebrand Cal.com to Cal.diy across the entire codebase - Remove Enterprise Edition (EE) features, license checks, and AGPL restrictions - Switch license from AGPL-3.0 to MIT - Remove docs/ directory (migrated to Nextra at cal.diy) - Remove dead code: org tests, EE tips, platform nav, premium username, SAML/SSO, etc. - Clean up .env.example for self-hosted Cal.diy - Update Docker image references to calcom/cal.diy - Update README, CONTRIBUTING.md, and issue templates for Cal.diy community fork - Add PR welcome bot for Cal.diy contributors - Fix API v2 breaking changes oasdiff ignore entries - Replace Blacksmith CI runners with default GitHub Actions 3893 files changed, 20789 insertions(+), 411020 deletions(-) Co-Authored-By: benny@cal.com <sldisek783@gmail.com> * refactor: remove org-specific /organizations/:orgId endpoints from API v2 atoms controllers (#1701) Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix: revert Cal.diy Inc to Cal.com, Inc. in license files, copyright notices, and package metadata (#1702) Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * rip out org related comments in api v2 --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
105 lines
3.1 KiB
TypeScript
105 lines
3.1 KiB
TypeScript
import type { GroupBase, InputProps, OptionProps, ControlProps } from "react-select";
|
|
import { components as reactSelectComponents } from "react-select";
|
|
|
|
import classNames from "@calcom/ui/classNames";
|
|
|
|
import { Badge, CreditsBadge } from "../../badge";
|
|
import { CheckIcon } from "@coss/ui/icons";
|
|
import type { SelectProps } from "./types";
|
|
|
|
export const InputComponent = <
|
|
Option,
|
|
IsMulti extends boolean = false,
|
|
Group extends GroupBase<Option> = GroupBase<Option>
|
|
>({
|
|
inputClassName,
|
|
...props
|
|
}: InputProps<Option, IsMulti, Group>) => {
|
|
return (
|
|
<reactSelectComponents.Input
|
|
// disables our default form focus highlight on the react-select input element
|
|
inputClassName={classNames(
|
|
"focus:ring-0 focus:ring-offset-0 !text-default dark:text-white!",
|
|
inputClassName
|
|
)}
|
|
{...props}
|
|
/>
|
|
);
|
|
};
|
|
|
|
type ExtendedOption = {
|
|
value: string | number;
|
|
label: string;
|
|
needsCredits?: boolean;
|
|
isCalAi?: boolean;
|
|
creditsTeamId?: number;
|
|
isOrganization?: boolean;
|
|
};
|
|
|
|
export const OptionComponent = <
|
|
Option,
|
|
IsMulti extends boolean = false,
|
|
Group extends GroupBase<Option> = GroupBase<Option>
|
|
>({
|
|
...props
|
|
}: OptionProps<Option, IsMulti, Group>) => {
|
|
return (
|
|
// This gets styled in the select classNames prop now - handles overrides with styles vs className here doesn't
|
|
<reactSelectComponents.Option {...props}>
|
|
<div className="flex items-center justify-between">
|
|
<span className="w-full" data-testid={`select-option-${(props as unknown as ExtendedOption).value}`}>
|
|
{(props.data as unknown as ExtendedOption).isCalAi ? (
|
|
<Badge startIcon="sparkles" variant="purple" className="mr-1 hidden md:inline-flex">
|
|
Cal.ai
|
|
</Badge>
|
|
) : (
|
|
<></>
|
|
)}
|
|
{props.label || <> </>}
|
|
</span>
|
|
{(props.data as unknown as ExtendedOption).needsCredits ? (
|
|
<CreditsBadge
|
|
teamId={(props.data as unknown as ExtendedOption).creditsTeamId}
|
|
isOrganization={(props.data as unknown as ExtendedOption).isOrganization}
|
|
/>
|
|
) : (
|
|
<></>
|
|
)}
|
|
{props.isSelected && <CheckIcon className="ml-2 h-4 w-4" />}
|
|
</div>
|
|
</reactSelectComponents.Option>
|
|
);
|
|
};
|
|
|
|
export const ControlComponent = <
|
|
Option,
|
|
IsMulti extends boolean,
|
|
Group extends GroupBase<Option> = GroupBase<Option>
|
|
>(
|
|
controlProps: ControlProps<Option, IsMulti, Group> & {
|
|
selectProps: SelectProps<Option, IsMulti, Group>;
|
|
}
|
|
) => {
|
|
const dataTestId = controlProps.selectProps["data-testid"] ?? "select-control";
|
|
return (
|
|
<span data-testid={dataTestId}>
|
|
<reactSelectComponents.Control {...controlProps} />
|
|
</span>
|
|
);
|
|
};
|
|
|
|
// We need to override this component if we need a icon - we can't simpily override styles
|
|
type IconLeadingProps = {
|
|
icon: React.ReactNode;
|
|
children?: React.ReactNode;
|
|
} & React.ComponentProps<typeof reactSelectComponents.Control>;
|
|
|
|
export const IconLeading = ({ icon, children, ...props }: IconLeadingProps) => {
|
|
return (
|
|
<reactSelectComponents.Control {...props}>
|
|
{icon}
|
|
{children}
|
|
</reactSelectComponents.Control>
|
|
);
|
|
};
|