@crispy-seed/data-table 0.1.3 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -27,19 +27,33 @@ interface DataTableSortState {
27
27
  dir: DataTableSortDirection;
28
28
  }
29
29
 
30
- type DataTableFilterMode = "is" | "isnot";
31
- interface DataTableColumnFilter {
32
- mode: DataTableFilterMode;
33
- /**
34
- * Checked values. One checked value reads as "is X"/"is not X"; several read as
35
- * Attio's "is any of X, Y"/"is not any of X, Y" -- the exact same predicate, just
36
- * more values in the set (crisp's own `applyFilters`, `tabletoolbar.tsx`, treats
37
- * `isanyof` as membership-in-`values` too). An empty array means the picker is open
38
- * with nothing checked yet, not "match nothing" -- see `isFilterActive` below.
39
- */
40
- values: string[];
30
+ type ToolbarSortDirection = "asc" | "desc";
31
+ /** One toolbar Sort condition -- crisp's `TableToolbar` model (`tabletoolbar.tsx`'s
32
+ * `ToolbarSort`), reproduced verbatim: a column key + direction, nothing else. */
33
+ interface ToolbarSort {
34
+ key: string;
35
+ dir: ToolbarSortDirection;
36
+ }
37
+
38
+ /** crisp's own `ToolbarFilterOp` (`tabletoolbar.tsx`), reproduced verbatim so the
39
+ * operator vocabulary and its per-kind gating (styled layer's `opsForKind`) match the
40
+ * Attio-measured reference exactly rather than drifting to a locally-invented set. */
41
+ type ToolbarFilterOp = "contains" | "doesnotcontain" | "startswith" | "endswith" | "is" | "isnot" | "isanyof" | "empty" | "notempty"
42
+ /** Number columns only. */
43
+ | "lessthan" | "greaterthan"
44
+ /** Date columns only. */
45
+ | "before" | "after";
46
+ /** One toolbar Filter condition chip -- crisp's `ToolbarFilter`. `op` is unset right
47
+ * after the field is (re)chosen: Attio's own chip shows "Select condition" until an
48
+ * operator is actually picked, rather than defaulting silently to one. */
49
+ interface ToolbarFilter {
50
+ id: string;
51
+ key: string;
52
+ op?: ToolbarFilterOp;
53
+ value: string;
54
+ /** Checked values for `"isanyof"` -- ignored by every other op. */
55
+ values?: string[];
41
56
  }
42
- type DataTableFilterState = Record<string, DataTableColumnFilter>;
43
57
 
44
58
  /**
45
59
  * The six aggregations DATATABLE-ATTIO-SPEC.md's ColumnCalc footer offers (crisp's own
@@ -64,6 +78,11 @@ interface DataTableEditOption {
64
78
  avatar?: string;
65
79
  }
66
80
 
81
+ /** Gates which operators (and which value editor) a column's filter condition offers --
82
+ * DATATABLE-ATTIO-SPEC.md's `kind`. Defaults to `"text"` when a column doesn't set one
83
+ * (`DataTableColumn.kind`). */
84
+ type DataTableColumnKind = "text" | "number" | "date" | "select";
85
+
67
86
  interface DataTableColumn<TRow> {
68
87
  /**
69
88
  * `data`의 각 행에서 이 열의 값을 찾는 key입니다. `render`가 없으면 `type`에 맞는
@@ -98,10 +117,30 @@ interface DataTableColumn<TRow> {
98
117
  * (GRC의 `Column<T>` 계약과 동일) -- 명시적으로 표시한 열만 검색됩니다. */
99
118
  searchable?: boolean;
100
119
  /**
101
- * 이 열의 값 목록입니다. 지정하면 헤더에 "is / is not / is any of" 체크박스
102
- * 필터 피커가 붙습니다 -- 자유 텍스트 열은 생략합니다(필터 UI 없음).
120
+ * 이 열의 값 목록입니다 (Attio/crisp 툴바 모델, DATATABLE-ATTIO-SPEC.md). 지정하면
121
+ * 툴바 Filter의 이 열 조건에 "is any of" 연산자(체크박스 피커)가 추가됩니다 -- 자유
122
+ * 텍스트 열은 생략합니다.
103
123
  */
104
124
  filterValues?: string[];
125
+ /**
126
+ * 툴바 Filter 조건이 이 열에 제공할 연산자 집합(과 값 편집기)을 결정합니다
127
+ * (DATATABLE-ATTIO-SPEC.md의 `kind`). 생략하면 `"text"`입니다: contains/does not
128
+ * contain/starts with/ends with/is/is not/empty/not empty. `"number"`는 is/is not/
129
+ * less than/greater than/empty/not empty(스피너 입력)로, `"date"`는 is/is not/
130
+ * before/after/empty/not empty(달력 입력)로 바뀝니다. `"select"`는 닫힌 어휘 열의
131
+ * 텍스트 검색 연산자가 무의미하므로 is/is not/empty/not empty만 남습니다 --
132
+ * `filterValues`와 짝지으면 "is any of"도 함께 제공됩니다(다른 kind와 동일).
133
+ */
134
+ kind?: DataTableColumnKind;
135
+ /**
136
+ * 이 열이 행 액션(⋯ 메뉴 등) 열임을 표시합니다. Attio는 행 액션 열을 가로 스크롤 중에도
137
+ * 절대 스크롤되어 사라지지 않도록 오른쪽 끝에 고정합니다 -- 이 플래그가 있는 열은 테이블
138
+ * 전체의 `stickyLast`를 켜지 않아도 자동으로 그 고정 + 왼쪽 스크롤 그림자
139
+ * (`stickyProps`/`stickyLast`가 이미 구현한 것과 동일한 메커니즘, `data-sticky-edge-end`
140
+ * / `data-scrolled-end`)를 받습니다. 열 목록의 마지막 열이어야 합니다 -- `stickyLast`
141
+ * 자체가 이미 "마지막으로 보이는 열"만 고정하는 규칙이기 때문입니다.
142
+ */
143
+ actions?: boolean;
105
144
  /**
106
145
  * 이 열의 초기 너비(px)입니다. 생략하면 다른 미지정 열들과 폭을 균등하게 나눠
107
146
  * 갖는(flex: 1) 기존 동작을 유지합니다 -- 드래그로 리사이즈하거나 `columnWidths`로
@@ -201,12 +240,26 @@ interface DataTableProps<TRow extends {
201
240
  searchPlaceholder?: string;
202
241
  /** 검색창의 접근성 이름입니다. */
203
242
  searchLabel?: string;
204
- /** 제어할 열별 필터 상태입니다. */
205
- filters?: DataTableFilterState;
206
- /** 비제어 방식으로 사용할 때의 초기 필터 상태입니다. */
207
- defaultFilters?: DataTableFilterState;
208
- /** 필터 상태가 바뀔 때 호출됩니다. */
209
- onFiltersChange?: (filters: DataTableFilterState) => void;
243
+ /**
244
+ * 제어할 툴바 Sort 조건 목록입니다 (DATATABLE-ATTIO-SPEC.md의 Attio/crisp
245
+ * `TableToolbar` 모델 -- 순서가 우선순위입니다, sorts[0]이 이기고 이후 조건은
246
+ * 동점만 깹니다). 하나라도 있으면 헤더 클릭 정렬(`sort`/`onSortChange`, 위)보다
247
+ * 우선합니다 -- 헤더 클릭은 툴바에 정렬 조건이 없을 때만 쓰는 보조 수단입니다.
248
+ */
249
+ toolbarSorts?: ToolbarSort[];
250
+ /** 비제어 방식으로 사용할 때의 초기 툴바 정렬 조건 목록입니다. */
251
+ defaultToolbarSorts?: ToolbarSort[];
252
+ /** 툴바 정렬 조건 목록이 바뀔 때 호출됩니다. */
253
+ onToolbarSortsChange?: (sorts: ToolbarSort[]) => void;
254
+ /**
255
+ * 제어할 툴바 Filter 조건(칩) 목록입니다 (DATATABLE-ATTIO-SPEC.md의 Attio/crisp
256
+ * `TableToolbar` 모델) -- 이전의 열별 헤더 "is/is not" 피커를 대체합니다.
257
+ */
258
+ toolbarFilters?: ToolbarFilter[];
259
+ /** 비제어 방식으로 사용할 때의 초기 툴바 필터 조건 목록입니다. */
260
+ defaultToolbarFilters?: ToolbarFilter[];
261
+ /** 툴바 필터 조건 목록이 바뀔 때 호출됩니다. */
262
+ onToolbarFiltersChange?: (filters: ToolbarFilter[]) => void;
210
263
  /** 툴바에 행 개수를 표시할지 여부입니다. @default true */
211
264
  showCount?: boolean;
212
265
  /**
@@ -327,4 +380,4 @@ declare const DataTable: <TRow extends {
327
380
  }) => react.ReactElement;
328
381
 
329
382
  export { DataTable };
330
- export type { DataTableColumn, DataTableProps };
383
+ export type { DataTableColumn, DataTableColumnKind, DataTableProps, ToolbarFilter, ToolbarFilterOp, ToolbarSort, ToolbarSortDirection };