@crispy-seed/data-table 0.3.1 → 0.5.0
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.cjs +1442 -720
- package/dist/index.d.ts +119 -2
- package/dist/index.js +1442 -721
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
3
|
|
|
3
4
|
declare interface DataTableVariant {
|
|
4
5
|
/**
|
|
@@ -66,6 +67,50 @@ interface ToolbarFilter {
|
|
|
66
67
|
*/
|
|
67
68
|
type DataTableCalcOp = "count" | "countFilled" | "sum" | "average" | "min" | "max";
|
|
68
69
|
|
|
70
|
+
/** Everything a saved view actually captures -- deliberately the same five controlled
|
|
71
|
+
* props `useDataTableColumns` + the toolbar sort/filter hooks already expose, so
|
|
72
|
+
* "restore this view" is just handing each field back to its own `on*Change` setter,
|
|
73
|
+
* not a bespoke apply-state routine this file would have to keep in sync with them by
|
|
74
|
+
* hand. Every field is optional: a consumer capturing only PART of the table's state
|
|
75
|
+
* (e.g. column layout but not filters) still produces a valid view. */
|
|
76
|
+
interface DataTableViewState {
|
|
77
|
+
columnOrder?: string[];
|
|
78
|
+
hiddenColumnKeys?: string[];
|
|
79
|
+
columnWidths?: Record<string, number>;
|
|
80
|
+
pinnedColumnKeys?: string[];
|
|
81
|
+
toolbarSorts?: ToolbarSort[];
|
|
82
|
+
toolbarFilters?: ToolbarFilter[];
|
|
83
|
+
}
|
|
84
|
+
/** One named, saved view. */
|
|
85
|
+
interface DataTableView {
|
|
86
|
+
id: string;
|
|
87
|
+
name: string;
|
|
88
|
+
state: DataTableViewState;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
interface UseDataTableViewsProps {
|
|
92
|
+
/** 제어할 저장된 view 목록입니다. */
|
|
93
|
+
views?: DataTableView[];
|
|
94
|
+
/** 비제어 방식으로 사용할 때의 초기 view 목록입니다. */
|
|
95
|
+
defaultViews?: DataTableView[];
|
|
96
|
+
/** view 목록이 바뀔 때(생성/이름변경/삭제) 호출됩니다. */
|
|
97
|
+
onViewsChange?: (views: DataTableView[]) => void;
|
|
98
|
+
/** 제어할, 현재 활성화된 view의 id입니다 (`null`은 "저장된 view 없음"). */
|
|
99
|
+
activeViewId?: string | null;
|
|
100
|
+
/** 비제어 방식으로 사용할 때의 초기 활성 view id입니다. */
|
|
101
|
+
defaultActiveViewId?: string | null;
|
|
102
|
+
/** 활성 view가 바뀔 때 호출됩니다. */
|
|
103
|
+
onActiveViewIdChange?: (id: string | null) => void;
|
|
104
|
+
/**
|
|
105
|
+
* 기본 localStorage 저장소의 key입니다. 이 hook이 `views`를 실제로 소유할 때만
|
|
106
|
+
* (즉 `views`가 제어되지 않을 때만) 마운트 시 한 번 읽고, 바뀔 때마다 다시
|
|
107
|
+
*씁니다 -- `views`를 직접 제어하는 소비자(예: 나중에 서버에 저장하는 tether)는
|
|
108
|
+
* 자기 자신의 저장소를 이미 갖고 있으므로 이 hook이 localStorage에 그림자
|
|
109
|
+
* 복사본을 만들 이유가 없습니다. 생략하면 영속화 없이 메모리에만 남습니다.
|
|
110
|
+
*/
|
|
111
|
+
storageKey?: string;
|
|
112
|
+
}
|
|
113
|
+
|
|
69
114
|
type DataTableCellType = "text" | "entity" | "url" | "email" | "tags" | "status" | "number" | "currency" | "date" | "datetime" | "rating" | "checkbox";
|
|
70
115
|
|
|
71
116
|
/** A `select`/`reference`/`actor` editor's own choice list -- `value`/`label` are
|
|
@@ -180,6 +225,29 @@ interface DataTableColumn<TRow> {
|
|
|
180
225
|
/** `editor: "reference"`/`"actor"`의 선택지입니다 (`avatar`가 있으면 아바타로,
|
|
181
226
|
* 없으면 기본 사람 아이콘으로 표시). */
|
|
182
227
|
refOptions?: DataTableEditOption[];
|
|
228
|
+
/**
|
|
229
|
+
* `editor: "select"` 목록 위에 검색창(Attio/crisp 스타일 search-on-top, crisp의
|
|
230
|
+
* `Select`가 가진 `searchable`과 동일한 발상 -- `select-search.tsx`)을 표시할지
|
|
231
|
+
* 여부입니다. 생략하면 `options`가 `SELECT_EDITOR_SEARCH_THRESHOLD`개를 넘을 때만
|
|
232
|
+
* 자동으로 켜집니다 -- 선택지가 몇 개 안 되는 열에 검색창을 얹는 건 잡음이라는
|
|
233
|
+
* crisp 자신의 `searchable`도 opt-in인 것과 같은 이유입니다. `false`로 명시하면
|
|
234
|
+
* 선택지가 많아도 검색창을 켜지 않습니다. `editor: "reference"`/`"actor"`는 이
|
|
235
|
+
* 플래그와 무관하게 항상 검색이 켜집니다 (아래 `refSearchPlaceholder` 참고) --
|
|
236
|
+
* 사람/레코드 참조는 선택지 수와 상관없이 검색이 본질이기 때문입니다.
|
|
237
|
+
*/
|
|
238
|
+
editorSearchable?: boolean;
|
|
239
|
+
/** `editorSearchable`(자동/명시)일 때 검색창의 placeholder입니다. @default "Search…" */
|
|
240
|
+
editorSearchPlaceholder?: string;
|
|
241
|
+
/** `editorSearchable`이고 검색 결과가 없을 때 표시할 문구입니다. @default "No results" */
|
|
242
|
+
editorEmptyLabel?: string;
|
|
243
|
+
/** `editor: "reference"`/`"actor"` 검색창의 placeholder입니다. 생략하면 `"actor"`는
|
|
244
|
+
* "Search people…", 그 외에는 "Search…"를 씁니다 (crisp의 `DataReferenceEditor`가
|
|
245
|
+
* 쓰는 `refSearchPlaceholder`와 같은 이름, 같은 기본값). */
|
|
246
|
+
refSearchPlaceholder?: string;
|
|
247
|
+
/** `editor: "reference"`/`"actor"` 검색 결과가 없을 때 표시할 문구입니다. 생략하면
|
|
248
|
+
* `"actor"`는 "No users", 그 외에는 "No results"를 씁니다 (crisp의 동일 필드와
|
|
249
|
+
* 같은 기본값 -- checklist G-039). */
|
|
250
|
+
refEmptyLabel?: string;
|
|
183
251
|
/**
|
|
184
252
|
* 편집기가 읽는 raw 값입니다 (`value`와 다름 -- `value`는 정렬/검색/필터/내보내기가
|
|
185
253
|
* 공유하는, 표시용으로 가공됐을 수 있는 접근자인 반면 `editValue`는 편집기 위젯이
|
|
@@ -307,6 +375,14 @@ interface DataTableProps<TRow extends {
|
|
|
307
375
|
defaultColumnLabels?: Record<string, string>;
|
|
308
376
|
/** 열 이름이 바뀔 때 호출됩니다. */
|
|
309
377
|
onColumnLabelsChange?: (labels: Record<string, string>) => void;
|
|
378
|
+
/** 제어할, 왼쪽에 고정(pin)된 열의 key 목록입니다 (Attio의 컬럼 메뉴 "Pin column").
|
|
379
|
+
* 선택 열과 `actions: true` 열은 이미 자기만의 고정 메커니즘(`stickyFirst`/
|
|
380
|
+
* 자동 `stickyLast`)을 갖고 있으므로 이 목록에 넣지 않아도 됩니다. */
|
|
381
|
+
pinnedColumnKeys?: string[];
|
|
382
|
+
/** 비제어 방식으로 사용할 때의 초기 고정 열 목록입니다. */
|
|
383
|
+
defaultPinnedColumnKeys?: string[];
|
|
384
|
+
/** 고정 열 목록이 바뀔 때(핀/언핀) 호출됩니다. */
|
|
385
|
+
onPinnedColumnKeysChange?: (pinned: string[]) => void;
|
|
310
386
|
/** 순서/숨김/이름 중 무엇이든 바뀌어 "실제로 보여줄 열 목록"이 달라질 때마다,
|
|
311
387
|
* 그 결과(순서·숨김·이름이 반영된 `columns`)를 통째로 받는 편의 콜백입니다 --
|
|
312
388
|
* 위 세 쌍의 콜백을 각각 다루는 대신 한 곳에서 "지금 보이는 열 구성"을 저장하고
|
|
@@ -388,5 +464,46 @@ declare const DataTable: <TRow extends {
|
|
|
388
464
|
ref?: react.ForwardedRef<HTMLDivElement>;
|
|
389
465
|
}) => react.ReactElement;
|
|
390
466
|
|
|
391
|
-
|
|
392
|
-
|
|
467
|
+
interface DataTableViewsControlProps extends UseDataTableViewsProps {
|
|
468
|
+
/** The trigger's label when no view is active. @default "Views" */
|
|
469
|
+
label?: string;
|
|
470
|
+
/** Renders an extra leading row in the popover that clears the active view (back to
|
|
471
|
+
* `label`'s own unfiltered state) -- omit (the default) when a consumer has no
|
|
472
|
+
* meaningful "no view" state to switch back to. */
|
|
473
|
+
showClearRow?: boolean;
|
|
474
|
+
/** The clear row's own label, when `showClearRow` is on. @default "label" */
|
|
475
|
+
clearLabel?: react.ReactNode;
|
|
476
|
+
/**
|
|
477
|
+
* Reads the table's CURRENT column order/visibility/widths/pins + toolbar sort/
|
|
478
|
+
* filter conditions -- called when the user picks "Save as new view" or "Update
|
|
479
|
+
* view". Build this from the same controlled state you pass to `<DataTable
|
|
480
|
+
* columnOrder=... toolbarSorts=... />` (or, uncontrolled, from `onColumnsChange`/
|
|
481
|
+
* `onToolbarSortsChange`/... mirrored into your own state).
|
|
482
|
+
*/
|
|
483
|
+
captureState: () => DataTableViewState;
|
|
484
|
+
/** Applies a selected view's saved state back onto the table -- typically each of
|
|
485
|
+
* your own `setColumnOrder`/`setHiddenColumnKeys`/`setColumnWidths`/
|
|
486
|
+
* `setPinnedColumnKeys`/`setToolbarSorts`/`setToolbarFilters` setters, one per
|
|
487
|
+
* field present on `state` (every field is optional -- a view that only captured
|
|
488
|
+
* column layout should leave sort/filter alone). */
|
|
489
|
+
applyState: (state: DataTableViewState) => void;
|
|
490
|
+
newViewLabel?: string;
|
|
491
|
+
updateViewLabel?: string;
|
|
492
|
+
renameLabel?: string;
|
|
493
|
+
deleteLabel?: string;
|
|
494
|
+
/** aria-label for the rename text input, given the view's own name. */
|
|
495
|
+
renameInputLabel?: (name: string) => string;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* A compact saved-views switcher -- current view name (or `label`) as the trigger,
|
|
499
|
+
* a popover listing every saved view (click to switch, inline Rename/Delete), a
|
|
500
|
+
* trailing "Save as new view", and (once a view is active) "Update view" to overwrite
|
|
501
|
+
* the loaded view with the table's current state.
|
|
502
|
+
*/
|
|
503
|
+
declare function DataTableViewsControl({ label, showClearRow, clearLabel, captureState, applyState, newViewLabel, updateViewLabel, renameLabel, deleteLabel, renameInputLabel, ...viewsProps }: DataTableViewsControlProps): react_jsx_runtime.JSX.Element;
|
|
504
|
+
declare namespace DataTableViewsControl {
|
|
505
|
+
var displayName: string;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
export { DataTable, DataTableViewsControl };
|
|
509
|
+
export type { DataTableColumn, DataTableColumnKind, DataTableProps, DataTableView, DataTableViewState, DataTableViewsControlProps, ToolbarFilter, ToolbarFilterOp, ToolbarSort, ToolbarSortDirection };
|