Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1ab4b9d

Browse files
authored
chore: Fix circular dependency in tanstack-table.d.ts (#25411)
* chore: Fix circular dependency in tanstack-table.d.ts* fix: Re-export TextFilterOperator* Unable to export non-type values from @calcom/types* Refactor data-table types in a way that ensures type-safety as before* Add FilterPopover and further fixups* Fix further type errors missed earlier* More hidden type errors* Type error in useFilterValue
1 parentf3d0475 commit1ab4b9d

File tree

17 files changed

+140
-110
lines changed

17 files changed

+140
-110
lines changed

‎apps/web/modules/insights/insights-view.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
ColumnFilterType,
1111
typeFilterableColumn,
1212
}from"@calcom/features/data-table";
13+
importtype{FilterType}from"@calcom/types/data-table";
1314
import{useDataTable}from"@calcom/features/data-table/hooks/useDataTable";
1415
import{useSegments}from"@calcom/features/data-table/hooks/useSegments";
1516
import{
@@ -53,13 +54,13 @@ export default function InsightsPage({ timeZone }: { timeZone: string }) {
5354
);
5455
}
5556

56-
constcreatedAtColumn:Extract<FilterableColumn,{type:ColumnFilterType.DATE_RANGE}>={
57+
constcreatedAtColumn:Extract<FilterableColumn,{type:Extract<FilterType,"dr">}>={
5758
id:"createdAt",
5859
title:"createdAt",
5960
type:ColumnFilterType.DATE_RANGE,
6061
};
6162

62-
conststartTimeColumn:Extract<FilterableColumn,{type:ColumnFilterType.DATE_RANGE}>={
63+
conststartTimeColumn:Extract<FilterableColumn,{type:Extract<FilterType,"dr">}>={
6364
id:"startTime",
6465
title:"startTime",
6566
type:ColumnFilterType.DATE_RANGE,

‎packages/features/data-table/components/filters/BaseSelectFilterOptions.tsx‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,26 @@ import { Icon } from "@calcom/ui/components/icon";
1818

1919
import{useDataTable,useFilterValue}from"../../hooks";
2020
importtype{
21-
ColumnFilterType,
2221
FacetedValue,
2322
FilterableColumnas_FilterableColumn,
2423
FilterValueSchema,
2524
}from"../../lib/types";
25+
importtype{FilterType}from"@calcom/types/data-table";
2626

2727
typeFilterableColumn=Extract<
2828
_FilterableColumn,
29-
{type:ColumnFilterType.MULTI_SELECT|ColumnFilterType.SINGLE_SELECT}
29+
{type:Extract<FilterType,"ms"|"ss">}
3030
>;
3131

32-
typeFilterableSelectColumn<TextendsColumnFilterType.MULTI_SELECT|ColumnFilterType.SINGLE_SELECT>=
32+
typeFilterableSelectColumn<TextendsExtract<FilterType,"ms"|"ss">>=
3333
Extract<FilterableColumn,{type:T}>;
3434

35-
typeFilterValue<TextendsColumnFilterType.MULTI_SELECT|ColumnFilterType.SINGLE_SELECT>=ReturnType<
35+
typeFilterValue<TextendsExtract<FilterType,"ms"|"ss">>=ReturnType<
3636
typeofuseFilterValue<T,FilterValueSchema<T>>
3737
>;
3838

3939
exporttypeBaseSelectFilterOptionsProps<
40-
TextendsColumnFilterType.MULTI_SELECT|ColumnFilterType.SINGLE_SELECT
40+
TextendsExtract<FilterType,"ms"|"ss">
4141
>={
4242
column:FilterableSelectColumn<T>;
4343
filterValueSchema:FilterValueSchema<T>;
@@ -88,7 +88,7 @@ function getSectionedOptions(options: FacetedValue[]) {
8888
}
8989

9090
exportfunctionBaseSelectFilterOptions<
91-
TextendsColumnFilterType.MULTI_SELECT|ColumnFilterType.SINGLE_SELECT
91+
TextendsExtract<FilterType,"ms"|"ss">
9292
>({
9393
column,
9494
filterValueSchema,

‎packages/features/data-table/components/filters/DateRangeFilter.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ import {
3333
import{preserveLocalTime}from"../../lib/preserveLocalTime";
3434
importtype{FilterableColumn,DateRangeFilterOptions}from"../../lib/types";
3535
import{ZDateRangeFilterValue,ColumnFilterType}from"../../lib/types";
36+
importtype{FilterType}from"@calcom/types/data-table";
3637
import{useFilterPopoverOpen}from"./useFilterPopoverOpen";
3738

3839
typeDateRangeFilterProps={
39-
column:Extract<FilterableColumn,{type:ColumnFilterType.DATE_RANGE}>;
40+
column:Extract<FilterableColumn,{type:Extract<FilterType,"dr">}>;
4041
options?:DateRangeFilterOptions;
4142
showColumnName?:boolean;
4243
showClearButton?:boolean;

‎packages/features/data-table/components/filters/FilterPopover.tsx‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
// eslint-disable-next-line no-restricted-imports
1+
22
importstartCasefrom"lodash/startCase";
33

4+
importtype{FilterType}from"@calcom/types/data-table";
45
import{Badge}from"@calcom/ui/components/badge";
56
import{Button}from"@calcom/ui/components/button";
67
importtype{IconName}from"@calcom/ui/components/icon";
@@ -18,7 +19,7 @@ import { FilterOptions } from "./FilterOptions";
1819
import{useFilterPopoverOpen}from"./useFilterPopoverOpen";
1920
import{numberFilterOperatorOptions,useTextFilterOperatorOptions}from"./utils";
2021

21-
constFILTER_ICONS:Record<ColumnFilterType,IconName>={
22+
constFILTER_ICONS:Record<FilterType,IconName>={
2223
[ColumnFilterType.TEXT]:"file-text",
2324
[ColumnFilterType.NUMBER]:"binary",
2425
[ColumnFilterType.MULTI_SELECT]:"layers",
@@ -84,11 +85,11 @@ function AppliedSelectFilterValue({ column, filterValue }: SelectedLabelsProps)
8485
letmoreCount=0;
8586

8687
if(isSingleSelectFilterValue(filterValue)){
87-
constoptions=(columnasExtract<FilterableColumn,{type:ColumnFilterType.SINGLE_SELECT}>).options;
88+
constoptions=(columnasFilterableColumn&{type:"ss"}).options;
8889
text=options.find((opt)=>opt.value===filterValue.data)?.label;
8990
moreCount=0;
9091
}elseif(isMultiSelectFilterValue(filterValue)){
91-
constoptions=(columnasExtract<FilterableColumn,{type:ColumnFilterType.MULTI_SELECT}>).options;
92+
constoptions=(columnasFilterableColumn&{type:"ms"}).options;
9293
text=options.find((opt)=>opt.value===filterValue.data[0])?.label;
9394
moreCount=filterValue.data.length-1;
9495
}

‎packages/features/data-table/components/filters/MultiSelectFilterOptions.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33
import{useDataTable}from"../../hooks";
44
importtype{FilterableColumn}from"../../lib/types";
55
import{ZMultiSelectFilterValue,ColumnFilterType}from"../../lib/types";
6+
importtype{FilterType}from"@calcom/types/data-table";
67
import{BaseSelectFilterOptions}from"./BaseSelectFilterOptions";
78

89
exporttypeMultiSelectFilterOptionsProps={
9-
column:Extract<FilterableColumn,{type:ColumnFilterType.MULTI_SELECT}>;
10+
column:Extract<FilterableColumn,{type:Extract<FilterType,"ms">}>;
1011
};
1112

1213
exportfunctionMultiSelectFilterOptions({ column}:MultiSelectFilterOptionsProps){
1314
const{ updateFilter}=useDataTable();
1415

1516
return(
16-
<BaseSelectFilterOptions<ColumnFilterType.MULTI_SELECT>
17+
<BaseSelectFilterOptions<Extract<FilterType,"ms">>
1718
column={column}
1819
filterValueSchema={ZMultiSelectFilterValue}
1920
testIdPrefix="select-filter-options"

‎packages/features/data-table/components/filters/NumberFilterOptions.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ import { Form, Select, NumberInput } from "@calcom/ui/components/form";
99
import{useFilterValue,useDataTable}from"../../hooks";
1010
importtype{FilterableColumn}from"../../lib/types";
1111
import{ZNumberFilterValue,ColumnFilterType}from"../../lib/types";
12+
importtype{FilterType}from"@calcom/types/data-table";
1213
import{numberFilterOperatorOptions}from"./utils";
1314

1415
exporttypeNumberFilterOptionsProps={
15-
column:Extract<FilterableColumn,{type:ColumnFilterType.NUMBER}>;
16+
column:Extract<FilterableColumn,{type:Extract<FilterType,"n">}>;
1617
};
1718

1819
exportfunctionNumberFilterOptions({ column}:NumberFilterOptionsProps){

‎packages/features/data-table/components/filters/SingleSelectFilterOptions.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
"use client";
22

3+
importtype{FilterType}from"@calcom/types/data-table";
4+
35
import{useDataTable}from"../../hooks";
46
importtype{FilterableColumn}from"../../lib/types";
57
import{ZSingleSelectFilterValue,ColumnFilterType}from"../../lib/types";
68
import{BaseSelectFilterOptions}from"./BaseSelectFilterOptions";
79

810
exporttypeSingleSelectFilterOptionsProps={
9-
column:Extract<FilterableColumn,{type:ColumnFilterType.SINGLE_SELECT}>;
11+
column:Extract<FilterableColumn,{type:Extract<FilterType,"ss">}>;
1012
};
1113

1214
exportfunctionSingleSelectFilterOptions({ column}:SingleSelectFilterOptionsProps){
1315
const{ updateFilter}=useDataTable();
1416

1517
return(
16-
<BaseSelectFilterOptions<ColumnFilterType.SINGLE_SELECT>
18+
<BaseSelectFilterOptions<Extract<FilterType,"ss">>
1719
column={column}
1820
filterValueSchema={ZSingleSelectFilterValue}
1921
testIdPrefix="select-filter-options"

‎packages/features/data-table/components/filters/TextFilterOptions.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ import { Form, Select, Input } from "@calcom/ui/components/form";
99
import{useFilterValue,useDataTable}from"../../hooks";
1010
importtype{FilterableColumn}from"../../lib/types";
1111
import{ZTextFilterValue,ColumnFilterType}from"../../lib/types";
12+
importtype{FilterType}from"@calcom/types/data-table";
1213
import{useTextFilterOperatorOptions}from"./utils";
1314

1415
exporttypeTextFilterOptionsProps={
15-
column:Extract<FilterableColumn,{type:ColumnFilterType.TEXT}>;
16+
column:Extract<FilterableColumn,{type:Extract<FilterType,"t">}>;
1617
};
1718

1819
exportfunctionTextFilterOptions({ column}:TextFilterOptionsProps){

‎packages/features/data-table/hooks/useFilterValue.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import{useMemo}from"react";
22
importtype{z}from"zod";
33

4-
importtype{FilterValueSchema,ColumnFilterType,ZFilterValue}from"../lib/types";
4+
importtype{FilterValueSchema,ZFilterValue}from"../lib/types";
5+
importtype{FilterType}from"@calcom/types/data-table";
56
import{useDataTable}from"./useDataTable";
67

78
exportfunctionuseFilterValue<
8-
TextendsColumnFilterType,
9+
TextendsFilterType,
910
TSchemaextendsFilterValueSchema<T>|typeofZFilterValue
1011
>(columnId:string,schema:TSchema){
1112
const{ activeFilters}=useDataTable();

‎packages/features/data-table/lib/types.ts‎

Lines changed: 30 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
importtype{SortingState,ColumnSort}from"@tanstack/react-table";
22
import{z}from"zod";
33

4-
importtype{IconName}from"@calcom/ui/components/icon";
4+
importtype{TextFilterOperator,FilterType}from"@calcom/types/data-table";
5+
exporttype{ColumnFilterMeta,FilterableColumn}from"@calcom/types/data-table";
6+
7+
constColumnFilterType={
8+
SINGLE_SELECT:"ss",
9+
MULTI_SELECT:"ms",
10+
TEXT:"t",
11+
NUMBER:"n",
12+
DATE_RANGE:"dr",
13+
}asconstsatisfiesRecord<string,FilterType>;
14+
15+
typeColumnFilterTypeValues=typeofColumnFilterType;
516

617
exporttype{SortingState}from"@tanstack/react-table";
718

819
exportconstSYSTEM_SEGMENT_PREFIX="system_";
920

10-
exportenumColumnFilterType{
11-
SINGLE_SELECT="ss",
12-
MULTI_SELECT="ms",
13-
TEXT="t",
14-
NUMBER="n",
15-
DATE_RANGE="dr",
16-
}
21+
export{ColumnFilterType,TextFilterOperator};
1722

1823
exportconsttextFilterOperators=[
1924
"equals",
@@ -26,12 +31,10 @@ export const textFilterOperators = [
2631
"isNotEmpty",
2732
]asconst;
2833

29-
exporttypeTextFilterOperator=(typeoftextFilterOperators)[number];
30-
3134
exportconstZTextFilterOperator=z.enum(textFilterOperators);
3235

3336
exporttypeSingleSelectFilterValue={
34-
type:ColumnFilterType.SINGLE_SELECT;
37+
type:ColumnFilterTypeValues["SINGLE_SELECT"];
3538
data:string|number;
3639
};
3740

@@ -41,7 +44,7 @@ export const ZSingleSelectFilterValue = z.object({
4144
})satisfiesz.ZodType<SingleSelectFilterValue>;
4245

4346
exporttypeMultiSelectFilterValue={
44-
type:ColumnFilterType.MULTI_SELECT;
47+
type:ColumnFilterTypeValues["MULTI_SELECT"];
4548
data:Array<string|number>;
4649
};
4750

@@ -51,7 +54,7 @@ export const ZMultiSelectFilterValue = z.object({
5154
})satisfiesz.ZodType<MultiSelectFilterValue>;
5255

5356
exporttypeTextFilterValue={
54-
type:ColumnFilterType.TEXT;
57+
type:ColumnFilterTypeValues["TEXT"];
5558
data:{
5659
operator:TextFilterOperator;
5760
operand:string;
@@ -73,7 +76,7 @@ export type NumberFilterOperator = (typeof numberFilterOperators)[number];
7376
exportconstZNumberFilterOperator=z.enum(numberFilterOperators);
7477

7578
exporttypeNumberFilterValue={
76-
type:ColumnFilterType.NUMBER;
79+
type:ColumnFilterTypeValues["NUMBER"];
7780
data:{
7881
operator:NumberFilterOperator;
7982
operand:number;
@@ -89,7 +92,7 @@ export const ZNumberFilterValue = z.object({
8992
})satisfiesz.ZodType<NumberFilterValue>;
9093

9194
exporttypeDateRangeFilterValue={
92-
type:ColumnFilterType.DATE_RANGE;
95+
type:ColumnFilterTypeValues["DATE_RANGE"];
9396
data:{
9497
startDate:string|null;
9598
endDate:string|null;
@@ -124,48 +127,6 @@ export type TextFilterOptions = {
124127
placeholder?:string;
125128
};
126129

127-
exporttypeColumnFilterMeta=
128-
|{
129-
type:ColumnFilterType.DATE_RANGE;
130-
icon?:IconName;
131-
dateRangeOptions?:DateRangeFilterOptions;
132-
}
133-
|{
134-
type:ColumnFilterType.TEXT;
135-
icon?:IconName;
136-
textOptions?:TextFilterOptions;
137-
}
138-
|{
139-
type?:Exclude<ColumnFilterType,ColumnFilterType.DATE_RANGE|ColumnFilterType.TEXT>;
140-
icon?:IconName;
141-
};
142-
143-
exporttypeFilterableColumn={
144-
id:string;
145-
title:string;
146-
icon?:IconName;
147-
}&(
148-
|{
149-
type:ColumnFilterType.SINGLE_SELECT;
150-
options:FacetedValue[];
151-
}
152-
|{
153-
type:ColumnFilterType.MULTI_SELECT;
154-
options:FacetedValue[];
155-
}
156-
|{
157-
type:ColumnFilterType.TEXT;
158-
textOptions?:TextFilterOptions;
159-
}
160-
|{
161-
type:ColumnFilterType.NUMBER;
162-
}
163-
|{
164-
type:ColumnFilterType.DATE_RANGE;
165-
dateRangeOptions?:DateRangeFilterOptions;
166-
}
167-
);
168-
169130
exporttypeColumnFilter={
170131
id:string;
171132
value:FilterValue;
@@ -176,32 +137,32 @@ export const ZColumnFilter = z.object({
176137
value:ZFilterValue,
177138
})satisfiesz.ZodType<ColumnFilter>;
178139

179-
exporttypeFilterValueSchema<TextendsColumnFilterType>=TextendsColumnFilterType.SINGLE_SELECT
140+
exporttypeFilterValueSchema<TextendsFilterType>=TextendsColumnFilterTypeValues["SINGLE_SELECT"]
180141
?typeofZSingleSelectFilterValue
181-
:TextendsColumnFilterType.MULTI_SELECT
142+
:TextendsColumnFilterTypeValues["MULTI_SELECT"]
182143
?typeofZMultiSelectFilterValue
183-
:TextendsColumnFilterType.TEXT
144+
:TextendsColumnFilterTypeValues["TEXT"]
184145
?typeofZTextFilterValue
185-
:TextendsColumnFilterType.NUMBER
146+
:TextendsColumnFilterTypeValues["NUMBER"]
186147
?typeofZNumberFilterValue
187-
:TextendsColumnFilterType.DATE_RANGE
148+
:TextendsColumnFilterTypeValues["DATE_RANGE"]
188149
?typeofZDateRangeFilterValue
189150
:never;
190151

191-
exporttypeFilterValue<TextendsColumnFilterType=ColumnFilterType>=
192-
TextendsColumnFilterType.SINGLE_SELECT
152+
exporttypeFilterValue<TextendsFilterType=FilterType>=
153+
TextendsColumnFilterTypeValues["SINGLE_SELECT"]
193154
?SingleSelectFilterValue
194-
:TextendsColumnFilterType.MULTI_SELECT
155+
:TextendsColumnFilterTypeValues["MULTI_SELECT"]
195156
?MultiSelectFilterValue
196-
:TextendsColumnFilterType.TEXT
157+
:TextendsColumnFilterTypeValues["TEXT"]
197158
?TextFilterValue
198-
:TextendsColumnFilterType.NUMBER
159+
:TextendsColumnFilterTypeValues["NUMBER"]
199160
?NumberFilterValue
200-
:TextendsColumnFilterType.DATE_RANGE
161+
:TextendsColumnFilterTypeValues["DATE_RANGE"]
201162
?DateRangeFilterValue
202163
:never;
203164

204-
exporttypeTypedColumnFilter<TextendsColumnFilterType>={
165+
exporttypeTypedColumnFilter<TextendsFilterType>={
205166
id:string;
206167
value:FilterValue<T>;
207168
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp