* 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>
108 lines
3.0 KiB
TypeScript
108 lines
3.0 KiB
TypeScript
"use client";
|
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import classNames from "@calcom/ui/classNames";
|
|
import { Button, type ButtonProps } from "@calcom/ui/components/button";
|
|
import { FilterSearchField } from "@calcom/ui/components/form";
|
|
import type { Table } from "@tanstack/react-table";
|
|
import type { ComponentPropsWithoutRef } from "react";
|
|
import { type ChangeEvent, forwardRef, type Ref, useEffect, useState } from "react";
|
|
import { useColumnFilters, useDataTable } from "~/data-table/hooks";
|
|
|
|
interface DataTableToolbarProps extends ComponentPropsWithoutRef<"div"> {
|
|
children: React.ReactNode;
|
|
}
|
|
|
|
const Root = forwardRef<HTMLDivElement, DataTableToolbarProps>(function DataTableToolbar(
|
|
{ children, className },
|
|
ref
|
|
) {
|
|
return (
|
|
<div
|
|
ref={ref}
|
|
className={classNames("grid w-full items-center gap-2 py-4", className)}
|
|
style={{ gridArea: "header" }}>
|
|
{children}
|
|
</div>
|
|
);
|
|
});
|
|
|
|
interface SearchBarProps {
|
|
className?: string;
|
|
}
|
|
|
|
function SearchBarComponent({ className }: SearchBarProps, ref: Ref<HTMLInputElement>) {
|
|
const { searchTerm, setSearchTerm } = useDataTable();
|
|
const { t } = useLocale();
|
|
const [localValue, setLocalValue] = useState(searchTerm);
|
|
|
|
useEffect(() => {
|
|
setLocalValue(searchTerm);
|
|
}, [searchTerm]);
|
|
|
|
const handleSearchChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
const value = event.target.value;
|
|
setLocalValue(value);
|
|
setSearchTerm(value);
|
|
};
|
|
|
|
return (
|
|
<FilterSearchField
|
|
ref={ref}
|
|
className={classNames("max-w-48", className)}
|
|
placeholder={t("search")}
|
|
value={localValue}
|
|
onChange={handleSearchChange}
|
|
/>
|
|
);
|
|
}
|
|
|
|
const SearchBar = forwardRef(SearchBarComponent) as (
|
|
props: SearchBarProps & { ref?: React.Ref<HTMLInputElement> }
|
|
) => ReturnType<typeof SearchBarComponent>;
|
|
|
|
interface ClearFiltersButtonProps<TData> {
|
|
table: Table<TData>;
|
|
}
|
|
|
|
function ClearFiltersButtonComponent<TData>(
|
|
{ table }: ClearFiltersButtonProps<TData>,
|
|
ref: React.Ref<HTMLButtonElement>
|
|
) {
|
|
const { t } = useLocale();
|
|
const columnFilters = useColumnFilters();
|
|
const isFiltered = columnFilters.length > 0;
|
|
if (!isFiltered) return null;
|
|
return (
|
|
<Button
|
|
ref={ref}
|
|
color="minimal"
|
|
EndIcon="x"
|
|
onClick={() => table.resetColumnFilters()}
|
|
className="h-8 px-2 lg:px-3">
|
|
{t("clear")}
|
|
</Button>
|
|
);
|
|
}
|
|
|
|
const ClearFiltersButton = forwardRef(ClearFiltersButtonComponent) as <TData>(
|
|
props: ClearFiltersButtonProps<TData> & { ref?: React.Ref<HTMLButtonElement> }
|
|
) => ReturnType<typeof ClearFiltersButtonComponent>;
|
|
|
|
function CTAComponent(
|
|
{ children, onClick, color = "primary", ...rest }: ButtonProps,
|
|
ref: React.Ref<HTMLButtonElement>
|
|
) {
|
|
return (
|
|
<Button ref={ref} color={color} onClick={onClick} {...rest}>
|
|
{children}
|
|
</Button>
|
|
);
|
|
}
|
|
|
|
const CTA = forwardRef(CTAComponent) as (
|
|
props: ButtonProps & { ref?: React.Ref<HTMLButtonElement> }
|
|
) => ReturnType<typeof CTAComponent>;
|
|
|
|
export const DataTableToolbar = { Root, SearchBar, ClearFiltersButton, CTA };
|