@izumisy-tailor/tailor-data-viewer 0.3.2 → 0.3.3

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.
Files changed (2) hide show
  1. package/README.md +25 -25
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -6,7 +6,7 @@ A low-level React component library for building data table interfaces with Tail
6
6
 
7
7
  - **Separation of Concerns**: Data fetching, query parameter management, and UI are fully decoupled
8
8
  - **`useCollectionVariables` Hook**: Manages filter, sort, and pagination state; outputs Tailor Platform-compatible GraphQL variables
9
- - **`CollectionVariablesProvider`**: Shares query parameters via React Context across sibling components
9
+ - **`CollectionControlProvider`**: Shares collection control state via React Context across sibling components
10
10
  - **`Table.*` Compound Components**: Static, unstyled table primitives (`<table>`, `<thead>`, `<tbody>`, `<tr>`, `<th>`, `<td>`)
11
11
  - **`DataTable.*` Compound Components**: Data-bound table with sort indicators, cell renderers, and `useDataTable` integration
12
12
  - **`useDataTable` Hook**: Integrates data, column visibility, row operations (optimistic updates), and props generators
@@ -95,7 +95,7 @@ const columns = [
95
95
 
96
96
  // 2. Build a page
97
97
  function OrdersPage() {
98
- const { variables } = useCollectionVariables({ params: { pageSize: 20 } });
98
+ const { variables, control } = useCollectionVariables({ params: { pageSize: 20 } });
99
99
  const [result] = useQuery({
100
100
  query: GET_ORDERS,
101
101
  variables: {
@@ -109,7 +109,7 @@ function OrdersPage() {
109
109
  columns,
110
110
  data: result.data?.orders,
111
111
  loading: result.fetching,
112
- collection,
112
+ control,
113
113
  });
114
114
 
115
115
  return (
@@ -131,7 +131,7 @@ function OrdersPage() {
131
131
  Manages filter, sort, and pagination state. Returns `variables` containing `query`, `order`, and `pagination` sub-properties in Tailor Platform-compatible format.
132
132
 
133
133
  ```tsx
134
- const { variables, ...collection } = useCollectionVariables({
134
+ const { variables, control } = useCollectionVariables({
135
135
  params: {
136
136
  pageSize: 20,
137
137
  initialSort: [{ field: "createdAt", direction: "Desc" }],
@@ -149,36 +149,36 @@ const [result] = useQuery({
149
149
  });
150
150
 
151
151
  // Filter operations
152
- collection.addFilter("status", "eq", "ACTIVE");
153
- collection.setFilters([{ field: "status", operator: "eq", value: "ACTIVE" }]);
154
- collection.removeFilter("status");
155
- collection.clearFilters();
152
+ control.addFilter("status", "eq", "ACTIVE");
153
+ control.setFilters([{ field: "status", operator: "eq", value: "ACTIVE" }]);
154
+ control.removeFilter("status");
155
+ control.clearFilters();
156
156
 
157
157
  // Sort operations
158
- collection.setSort("createdAt", "Desc");
159
- collection.setSort("name", "Asc", true); // append for multi-sort
160
- collection.clearSort();
158
+ control.setSort("createdAt", "Desc");
159
+ control.setSort("name", "Asc", true); // append for multi-sort
160
+ control.clearSort();
161
161
 
162
162
  // Pagination
163
- collection.nextPage(endCursor);
164
- collection.prevPage(startCursor);
165
- collection.resetPage();
163
+ control.nextPage(endCursor);
164
+ control.prevPage(startCursor);
165
+ control.resetPage();
166
166
 
167
167
  // Page info tracking
168
- collection.setPageInfo(pageInfo);
169
- collection.hasPrevPage; // boolean
170
- collection.hasNextPage; // boolean
168
+ control.setPageInfo(pageInfo);
169
+ control.hasPrevPage; // boolean
170
+ control.hasNextPage; // boolean
171
171
  ```
172
172
 
173
- ### `DataTable.Provider` / `useDataTableContext()` / `useCollectionVariablesContext()`
173
+ ### `DataTable.Provider` / `useDataTableContext()` / `useCollectionControl()`
174
174
 
175
- `DataTable.Provider` wraps the table UI and provides both data table and collection context. All utility components (`Pagination`, `ColumnSelector`, `CsvButton`, `SearchFilterForm`) read from this context — no prop spreading needed.
175
+ `DataTable.Provider` wraps the table UI and provides both data table and collection control context. All utility components (`Pagination`, `ColumnSelector`, `CsvButton`, `SearchFilterForm`) read from this context — no prop spreading needed.
176
176
 
177
- When `collection` is passed to `useDataTable`, `DataTable.Provider` automatically wraps a `CollectionVariablesProvider` so child components can use `useCollectionVariablesContext()`.
177
+ When `control` is passed to `useDataTable`, `DataTable.Provider` automatically wraps a `CollectionControlProvider` so child components can use `useCollectionControl()`.
178
178
 
179
179
  ```tsx
180
180
  <DataTable.Provider value={table}>
181
- <StatusFilter /> {/* useCollectionVariablesContext() inside */}
181
+ <StatusFilter /> {/* useCollectionControl() inside */}
182
182
  <DataTable.Root>
183
183
  <DataTable.Headers />
184
184
  <DataTable.Body />
@@ -187,13 +187,13 @@ When `collection` is passed to `useDataTable`, `DataTable.Provider` automaticall
187
187
  </DataTable.Provider>
188
188
  ```
189
189
 
190
- For cases where you need `CollectionVariablesProvider` without `DataTable.Provider` (e.g., non-table UIs), you can use it standalone:
190
+ For cases where you need `CollectionControlProvider` without `DataTable.Provider` (e.g., non-table UIs), you can use it standalone:
191
191
 
192
192
  ```tsx
193
- <CollectionVariablesProvider value={collection}>
193
+ <CollectionControlProvider value={control}>
194
194
  <StatusFilter />
195
195
  <CustomKanbanBoard />
196
- </CollectionVariablesProvider>
196
+ </CollectionControlProvider>
197
197
  ```
198
198
 
199
199
  ### Column Definition Helper
@@ -275,7 +275,7 @@ const table = useDataTable<Order>({
275
275
  data: result.data?.orders, // CollectionResult<Order>
276
276
  loading: result.fetching,
277
277
  error: result.error,
278
- collection,
278
+ control,
279
279
  onClickRow: (row) => navigate(`/orders/${row.id}`),
280
280
  rowActions: [
281
281
  { id: "delete", label: "Delete", variant: "destructive", onClick: (row) => handleDelete(row.id) },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@izumisy-tailor/tailor-data-viewer",
3
3
  "private": false,
4
- "version": "0.3.2",
4
+ "version": "0.3.3",
5
5
  "type": "module",
6
6
  "description": "Flexible data viewer component for Tailor Platform",
7
7
  "files": [