The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add Combobox support to Filter.List options
Steven Teyce9b0b540d70
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-table.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-table.tsxindex c8d853dab3..93301e6a6d 100644--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-table.tsx+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-table.tsx@@ -199,6 +199,7 @@ export function PayoutTable() {<Filter.Listfilters={filters}activeFilters={activeFilters}+ onSelect={onSelect}onRemove={onRemove}onRemoveAll={onRemoveAll}/>diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-composite-chart.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-composite-chart.tsxindex d47c690694..78de9361cb 100644--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-composite-chart.tsx+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-composite-chart.tsx@@ -388,6 +388,7 @@ function EarningsTableControls() {<Filter.Listfilters={filters}activeFilters={activeFilters}+ onSelect={onSelect}onRemove={onRemove}onRemoveAll={onRemoveAll}/>diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/page-client.tsxindex 574e001f62..e2b3ea9978 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/page-client.tsx@@ -129,6 +129,7 @@ export function ProgramAnalyticsPageClient() {<Filter.Listfilters={filters}activeFilters={activeFiltersWithStreaming}+ onSelect={onSelect}onRemove={onRemove}onRemoveAll={onRemoveAll}/>diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsxindex fbeff7e842..1b7dc88cc0 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx@@ -373,6 +373,7 @@ export function BountySubmissionsTable() {},]}activeFilters={activeFilters}+ onSelect={onSelect}onRemove={onRemove}onRemoveAll={onRemoveAll}/>diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/commission-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/commission-table.tsxindex 210d93dfe4..bb484c58d4 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/commission-table.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/commission-table.tsx@@ -291,6 +291,7 @@ const CommissionTableInner = memo(},]}activeFilters={activeFilters}+ onSelect={onSelect}onRemove={onRemove}onRemoveAll={onRemoveAll}/>diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/group-additional-links.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/group-additional-links.tsxindex 094e0b2218..d26b72d902 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/group-additional-links.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/group-additional-links.tsx@@ -273,13 +273,12 @@ function LinkFormat({// Delete link formatconst deleteLinkFormat = async () => {- const updatedAdditionalLinks = additionalLinks.filter(- (existingLink) =>- existingLink.domain !== link.domain && existingLink.path !== link.path,- );-// Update the parent form state instead of calling API directly- onUpdateAdditionalLinks(updatedAdditionalLinks);+ onUpdateAdditionalLinks(+ additionalLinks.filter(+ (existingLink) => existingLink.domain !== link.domain,+ ),+ );setOpenPopover(false);};diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/network/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/network/page-client.tsxindex dd9ba03873..285fd053f8 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/network/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/network/page-client.tsx@@ -229,6 +229,7 @@ export function ProgramPartnerNetworkPageClient() {<Filter.Listfilters={filters}activeFilters={activeFilters}+ onSelect={onSelect}onRemove={onRemove}onRemoveAll={onRemoveAll}/>diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partners-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partners-table.tsxindex b4df471ba5..98c966a9c1 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partners-table.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partners-table.tsx@@ -405,6 +405,7 @@ export function PartnersTable() {<Filter.Listfilters={filters}activeFilters={activeFilters}+ onSelect={onSelect}onRemove={onRemove}onRemoveAll={onRemoveAll}/>diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/use-partner-filters.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/use-partner-filters.tsxindex e2759d00d0..5aadcbe0d3 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/use-partner-filters.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/use-partner-filters.tsx@@ -101,8 +101,8 @@ export function usePartnerFilters(extraSearchParams: Record<string, string>) {getOptionIcon: (value) => (<imgalt={value}- src={`https://flag.vercel.app/m/${value}.svg`}- className="h-2.5 w-4"+ src={`https://hatscripts.github.io/circle-flags/flags/${value.toLowerCase()}.svg`}+ className="size-4 shrink-0"/>),getOptionLabel: (value) => COUNTRIES[value],diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-table.tsxindex bf03d088e6..4a29c5358d 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-table.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-table.tsx@@ -266,6 +266,7 @@ const PayoutTableInner = memo(<Filter.Listfilters={filters}activeFilters={activeFilters}+ onSelect={onSelect}onRemove={onRemove}onRemoveAll={onRemoveAll}/>diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/links/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/links/page-client.tsxindex 18b157c557..35406ec4db 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/links/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/links/page-client.tsx@@ -263,6 +263,7 @@ function WorkspaceLinks() {<Filter.Listfilters={filters}activeFilters={activeFilters}+ onSelect={onSelect}onRemove={onRemove}onRemoveAll={onRemoveAll}/>diff --git a/apps/web/ui/analytics/toggle.tsx b/apps/web/ui/analytics/toggle.tsxindex a8e2ca50eb..74d79a0ea2 100644--- a/apps/web/ui/analytics/toggle.tsx+++ b/apps/web/ui/analytics/toggle.tsx@@ -290,6 +290,7 @@ export default function Toggle({<Filter.Listfilters={filters}activeFilters={activeFiltersWithStreaming}+ onSelect={onSelect}onRemove={onRemove}onRemoveAll={onRemoveAll}/>diff --git a/apps/web/ui/analytics/use-analytics-filters.tsx b/apps/web/ui/analytics/use-analytics-filters.tsxindex 228dd7dc62..4016f64078 100644--- a/apps/web/ui/analytics/use-analytics-filters.tsx+++ b/apps/web/ui/analytics/use-analytics-filters.tsx@@ -646,7 +646,7 @@ export function useAnalyticsFilters({<imgalt={value}src={`https://hatscripts.github.io/circle-flags/flags/${value.toLowerCase()}.svg`}- className="h-2.5 w-4"+ className="size-4 shrink-0"/>),getOptionLabel: (value) => COUNTRIES[value],diff --git a/apps/web/ui/analytics/utils.ts b/apps/web/ui/analytics/utils.tsindex 90b3d62233..328702673b 100644--- a/apps/web/ui/analytics/utils.ts+++ b/apps/web/ui/analytics/utils.ts@@ -1,3 +1,4 @@+import { SINGULAR_ANALYTICS_ENDPOINTS } from "@/lib/analytics/constants";import { AnalyticsGroupByOptions } from "@/lib/analytics/types";import { editQueryString } from "@/lib/analytics/utils";import { fetcher } from "@dub/utils";@@ -47,11 +48,25 @@ export function useAnalyticsFilterOption(const { data, isLoading } = useSWR<Record<string, any>[]>(enabled- ? `${baseApiPath}?${editQueryString(queryString, {- ...(typeof groupByOrParams === "string"- ? { groupBy: groupByOrParams }- : groupByOrParams),- })}`+ ? `${baseApiPath}?${editQueryString(+ queryString,+ {+ ...(typeof groupByOrParams === "string"+ ? {+ groupBy: groupByOrParams,+ }+ : groupByOrParams),+ },+ // when there is a groupBy, we need to remove the filter for that groupBy param+ groupByOrParams &&+ SINGULAR_ANALYTICS_ENDPOINTS[+ groupByOrParams as AnalyticsGroupByOptions+ ]+ ? SINGULAR_ANALYTICS_ENDPOINTS[+ groupByOrParams as AnalyticsGroupByOptions+ ]+ : undefined,+ )}`: null,fetcher,{diff --git a/apps/web/ui/customers/customer-table/customer-table.tsx b/apps/web/ui/customers/customer-table/customer-table.tsxindex 9fc9869a55..bfb517445c 100644--- a/apps/web/ui/customers/customer-table/customer-table.tsx+++ b/apps/web/ui/customers/customer-table/customer-table.tsx@@ -293,6 +293,7 @@ export function CustomerTable() {<Filter.Listfilters={filters}activeFilters={activeFilters}+ onSelect={onSelect}onRemove={onRemove}onRemoveAll={onRemoveAll}/>diff --git a/packages/ui/src/combobox/index.tsx b/packages/ui/src/combobox/index.tsxindex 9510f32ea2..a493ab07b3 100644--- a/packages/ui/src/combobox/index.tsx+++ b/packages/ui/src/combobox/index.tsx@@ -404,7 +404,7 @@ function Option({)}</div>)}- <div className="flex min-w-0 grow items-center gap-1">+ <div className="flex min-w-0 grow items-center gap-2">{option.icon && (<span className="shrink-0 text-neutral-600">{isReactNode(option.icon) ? (diff --git a/packages/ui/src/filter/filter-list.tsx b/packages/ui/src/filter/filter-list.tsxindex cafeacc38d..f70246cf1b 100644--- a/packages/ui/src/filter/filter-list.tsx+++ b/packages/ui/src/filter/filter-list.tsx@@ -4,6 +4,7 @@ import { AnimatePresence, motion } from "motion/react";import Link from "next/link";import { ReactNode, isValidElement } from "react";import { AnimatedSizeContainer } from "../animated-size-container";+import { Combobox, ComboboxOption } from "../combobox";import { useKeyboardShortcut } from "../hooks";import { Filter, FilterOption } from "./types";@@ -15,6 +16,7 @@ type FilterListProps = {}[];onRemove: (key: string, value: FilterOption["value"]) => void;onRemoveAll: () => void;+ onSelect?: (key: string, value: FilterOption["value"]) => void;className?: string;};@@ -23,6 +25,7 @@ export function FilterList({activeFilters,onRemove,onRemoveAll,+ onSelect,className,}: FilterListProps) {useKeyboardShortcut("Escape", onRemoveAll, { priority: 1 });@@ -89,6 +92,38 @@ export function FilterList({filter.getOptionPermalink?.(value) ??null;+ const OptionDisplay = ({+ className,+ }: {+ className?: string;+ }) => (+ <div+ className={cn(+ "flex items-center gap-2.5 px-3 py-2",+ className,+ )}+ >+ <span className="shrink-0 text-neutral-600">+ {isReactNode(OptionIcon) ? (+ OptionIcon+ ) : (+ <OptionIcon className="h-4 w-4" />+ )}+ </span>+ {optionPermalink ? (+ <Link+ href={optionPermalink}+ target="_blank"+ className="cursor-alias decoration-dotted underline-offset-2 hover:underline"+ >+ {truncate(optionLabel, 30)}+ </Link>+ ) : (+ truncate(optionLabel, 30)+ )}+ </div>+ );+return (<motion.divkey={`${key}-${value}`}@@ -112,30 +147,78 @@ export function FilterList({<div className="px-3 py-2 text-neutral-500">is</div>{/* Option */}- <div className="flex items-center gap-2.5 px-3 py-2">- {filter.options ? (- <>- <span className="shrink-0 text-neutral-600">- {isReactNode(OptionIcon) ? (- OptionIcon- ) : (- <OptionIcon className="h-4 w-4" />- )}- </span>- {optionPermalink ? (- <Link- href={optionPermalink}- target="_blank"- className="cursor-alias decoration-dotted underline-offset-2 hover:underline"- >- {truncate(optionLabel, 30)}- </Link>- ) : (- truncate(optionLabel, 30)- )}- </>+ <div className="flex items-center">+ {!filter.options ? (+ <div className="flex items-center gap-2.5 px-3 py-2">+ <div className="h-5 w-12 animate-pulse rounded-md bg-neutral-200" />+ </div>+ ) : onSelect ? (+ <Combobox+ selected={+ filter.options.find((opt) =>+ typeof opt.value === "string" &&+ typeof value === "string"+ ? opt.value.toLowerCase() ===+ value.toLowerCase()+ : opt.value === value,+ ) ?? null+ }+ setSelected={(newOption: ComboboxOption | null) => {+ if (newOption && newOption.value !== value) {+ // Remove the current value and add the new one+ onRemove(key, value);+ onSelect(key, newOption.value);+ }+ }}+ options={+ filter.options?.map((opt): ComboboxOption => {+ console.log({ opt });+ const optionIcon =+ opt.icon ??+ filter.getOptionIcon?.(opt.value, {+ key: filter.key,+ option: opt,+ }) ??+ filter.icon;++ return {+ label:+ opt.label ??+ filter.getOptionLabel?.(opt.value, {+ key: filter.key,+ option: opt,+ }) ??+ opt.value,+ value: opt.value,+ icon: optionIcon,+ };+ }) ?? []+ }+ optionRight={(option) => {+ if (option.value === value) {+ return;+ }+ const filterOption = filter.options?.find((opt) =>+ typeof opt.value === "string" &&+ typeof option.value === "string"+ ? opt.value.toLowerCase() ===+ option.value.toLowerCase()+ : opt.value === option.value,+ );+ return filterOption ? (+ <span className="ml-2 text-neutral-500">+ {filterOption.right}+ </span>+ ) : null;+ }}+ placeholder={truncate(optionLabel, 30)}+ caret={false}+ trigger={OptionDisplay({+ className: "cursor-pointer hover:bg-neutral-50",+ })}+ />) : (- <div className="h-5 w-12 animate-pulse rounded-md bg-neutral-200" />+ OptionDisplay({}))}</div>