@vendure/dashboard 3.4.3-master-202509250229 → 3.5.0-minor-202509261210

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 (75) hide show
  1. package/dist/plugin/api/api-extensions.js +11 -14
  2. package/dist/plugin/api/metrics.resolver.d.ts +2 -2
  3. package/dist/plugin/api/metrics.resolver.js +2 -2
  4. package/dist/plugin/config/metrics-strategies.d.ts +9 -9
  5. package/dist/plugin/config/metrics-strategies.js +6 -6
  6. package/dist/plugin/constants.d.ts +2 -0
  7. package/dist/plugin/constants.js +3 -1
  8. package/dist/plugin/dashboard.plugin.js +13 -0
  9. package/dist/plugin/service/metrics.service.d.ts +3 -3
  10. package/dist/plugin/service/metrics.service.js +37 -53
  11. package/dist/plugin/types.d.ts +9 -12
  12. package/dist/plugin/types.js +7 -11
  13. package/dist/vite/utils/compiler.js +2 -0
  14. package/dist/vite/vite-plugin-vendure-dashboard.js +2 -2
  15. package/package.json +4 -4
  16. package/src/app/routes/_authenticated/_collections/collections.tsx +7 -2
  17. package/src/app/routes/_authenticated/_collections/collections_.$id.tsx +15 -2
  18. package/src/app/routes/_authenticated/_facets/facets_.$id.tsx +14 -2
  19. package/src/app/routes/_authenticated/_product-variants/product-variants.graphql.ts +10 -0
  20. package/src/app/routes/_authenticated/_products/components/product-option-group-badge.tsx +19 -0
  21. package/src/app/routes/_authenticated/_products/components/product-options-table.tsx +111 -0
  22. package/src/app/routes/_authenticated/_products/product-option-groups.graphql.ts +103 -0
  23. package/src/app/routes/_authenticated/_products/products.graphql.ts +13 -1
  24. package/src/app/routes/_authenticated/_products/products.tsx +27 -3
  25. package/src/app/routes/_authenticated/_products/products_.$id.tsx +26 -9
  26. package/src/app/routes/_authenticated/_products/products_.$productId.option-groups.$id.tsx +181 -0
  27. package/src/app/routes/_authenticated/_products/products_.$productId.option-groups.$productOptionGroupId.options_.$id.tsx +208 -0
  28. package/src/app/routes/_authenticated/_zones/components/zone-countries-sheet.tsx +4 -1
  29. package/src/app/routes/_authenticated/index.tsx +41 -24
  30. package/src/lib/components/data-display/json.tsx +16 -1
  31. package/src/lib/components/data-input/index.ts +3 -0
  32. package/src/lib/components/data-input/slug-input.tsx +296 -0
  33. package/src/lib/components/data-table/add-filter-menu.tsx +13 -6
  34. package/src/lib/components/data-table/data-table-bulk-action-item.tsx +38 -1
  35. package/src/lib/components/data-table/data-table-context.tsx +91 -0
  36. package/src/lib/components/data-table/data-table-filter-badge.tsx +9 -5
  37. package/src/lib/components/data-table/data-table-view-options.tsx +17 -8
  38. package/src/lib/components/data-table/data-table.tsx +146 -94
  39. package/src/lib/components/data-table/global-views-bar.tsx +97 -0
  40. package/src/lib/components/data-table/global-views-sheet.tsx +11 -0
  41. package/src/lib/components/data-table/manage-global-views-button.tsx +26 -0
  42. package/src/lib/components/data-table/my-views-button.tsx +47 -0
  43. package/src/lib/components/data-table/refresh-button.tsx +12 -3
  44. package/src/lib/components/data-table/save-view-button.tsx +45 -0
  45. package/src/lib/components/data-table/save-view-dialog.tsx +113 -0
  46. package/src/lib/components/data-table/use-generated-columns.tsx +3 -1
  47. package/src/lib/components/data-table/user-views-sheet.tsx +11 -0
  48. package/src/lib/components/data-table/views-sheet.tsx +297 -0
  49. package/src/lib/components/date-range-picker.tsx +184 -0
  50. package/src/lib/components/shared/paginated-list-data-table.tsx +59 -32
  51. package/src/lib/components/ui/button.tsx +1 -1
  52. package/src/lib/framework/dashboard-widget/latest-orders-widget/index.tsx +29 -2
  53. package/src/lib/framework/dashboard-widget/metrics-widget/index.tsx +10 -7
  54. package/src/lib/framework/dashboard-widget/metrics-widget/metrics-widget.graphql.ts +9 -3
  55. package/src/lib/framework/dashboard-widget/orders-summary/index.tsx +19 -75
  56. package/src/lib/framework/dashboard-widget/widget-filters-context.tsx +33 -0
  57. package/src/lib/framework/document-introspection/add-custom-fields.spec.ts +319 -9
  58. package/src/lib/framework/document-introspection/add-custom-fields.ts +60 -31
  59. package/src/lib/framework/document-introspection/get-document-structure.spec.ts +1 -159
  60. package/src/lib/framework/document-introspection/include-only-selected-list-fields.spec.ts +1840 -0
  61. package/src/lib/framework/document-introspection/include-only-selected-list-fields.ts +940 -0
  62. package/src/lib/framework/document-introspection/testing-utils.ts +161 -0
  63. package/src/lib/framework/extension-api/display-component-extensions.tsx +2 -0
  64. package/src/lib/framework/extension-api/types/data-table.ts +62 -4
  65. package/src/lib/framework/extension-api/types/navigation.ts +16 -0
  66. package/src/lib/framework/form-engine/utils.ts +34 -0
  67. package/src/lib/framework/page/list-page.tsx +289 -4
  68. package/src/lib/framework/page/use-extended-router.tsx +59 -17
  69. package/src/lib/graphql/api.ts +4 -2
  70. package/src/lib/graphql/graphql-env.d.ts +13 -10
  71. package/src/lib/hooks/use-extended-list-query.ts +5 -0
  72. package/src/lib/hooks/use-saved-views.ts +230 -0
  73. package/src/lib/index.ts +15 -0
  74. package/src/lib/types/saved-views.ts +39 -0
  75. package/src/lib/utils/saved-views-utils.ts +40 -0
@@ -0,0 +1,161 @@
1
+ export function getMockSchemaInfo() {
2
+ return {
3
+ schemaInfo: {
4
+ types: {
5
+ Query: {
6
+ products: ['ProductList', false, false, true],
7
+ product: ['Product', false, false, false],
8
+ collection: ['Collection', false, false, false],
9
+ order: ['Order', false, false, false],
10
+ },
11
+ Mutation: {
12
+ updateProduct: ['Product', false, false, false],
13
+ adjustDraftOrderLine: ['Order', false, false, false],
14
+ },
15
+
16
+ Collection: {
17
+ id: ['ID', false, false, false],
18
+ name: ['String', false, false, false],
19
+ productVariants: ['ProductVariantList', false, false, true],
20
+ },
21
+
22
+ ProductVariantList: {
23
+ items: ['ProductVariant', false, true, false],
24
+ totalItems: ['Int', false, false, false],
25
+ },
26
+
27
+ Product: {
28
+ channels: ['Channel', false, true, false],
29
+ id: ['ID', false, false, false],
30
+ createdAt: ['DateTime', false, false, false],
31
+ updatedAt: ['DateTime', false, false, false],
32
+ languageCode: ['LanguageCode', false, false, false],
33
+ name: ['String', false, false, false],
34
+ slug: ['String', false, false, false],
35
+ description: ['String', false, false, false],
36
+ enabled: ['Boolean', false, false, false],
37
+ featuredAsset: ['Asset', true, false, false],
38
+ assets: ['Asset', false, true, false],
39
+ variants: ['ProductVariant', false, true, false],
40
+ variantList: ['ProductVariantList', false, false, true],
41
+ optionGroups: ['ProductOptionGroup', false, true, false],
42
+ facetValues: ['FacetValue', false, true, false],
43
+ translations: ['ProductTranslation', false, true, false],
44
+ collections: ['Collection', false, true, false],
45
+ reviews: ['ProductReviewList', false, false, true],
46
+ reviewsHistogram: ['ProductReviewHistogramItem', false, true, false],
47
+ customFields: ['ProductCustomFields', true, false, false],
48
+ },
49
+ ProductVariantPrice: {
50
+ currencyCode: ['CurrencyCode', false, false, false],
51
+ price: ['Money', false, false, false],
52
+ customFields: ['JSON', true, false, false],
53
+ },
54
+ ProductVariant: {
55
+ enabled: ['Boolean', false, false, false],
56
+ trackInventory: ['GlobalFlag', false, false, false],
57
+ stockOnHand: ['Int', false, false, false],
58
+ stockAllocated: ['Int', false, false, false],
59
+ outOfStockThreshold: ['Int', false, false, false],
60
+ useGlobalOutOfStockThreshold: ['Boolean', false, false, false],
61
+ prices: ['ProductVariantPrice', false, true, false],
62
+ stockLevels: ['StockLevel', false, true, false],
63
+ stockMovements: ['StockMovementList', false, false, false],
64
+ channels: ['Channel', false, true, false],
65
+ id: ['ID', false, false, false],
66
+ product: ['Product', false, false, false],
67
+ productId: ['ID', false, false, false],
68
+ createdAt: ['DateTime', false, false, false],
69
+ updatedAt: ['DateTime', false, false, false],
70
+ languageCode: ['LanguageCode', false, false, false],
71
+ sku: ['String', false, false, false],
72
+ name: ['String', false, false, false],
73
+ featuredAsset: ['Asset', true, false, false],
74
+ assets: ['Asset', false, true, false],
75
+ price: ['Money', false, false, false],
76
+ currencyCode: ['CurrencyCode', false, false, false],
77
+ priceWithTax: ['Money', false, false, false],
78
+ stockLevel: ['String', false, false, false],
79
+ taxRateApplied: ['TaxRate', false, false, false],
80
+ taxCategory: ['TaxCategory', false, false, false],
81
+ options: ['ProductOption', false, true, false],
82
+ facetValues: ['FacetValue', false, true, false],
83
+ translations: ['ProductVariantTranslation', false, true, false],
84
+ customFields: ['JSON', true, false, false],
85
+ },
86
+ ProductCustomFields: {
87
+ custom1: ['String', false, false, false],
88
+ },
89
+
90
+ Asset: {
91
+ id: ['ID', false, false, false],
92
+ createdAt: ['DateTime', false, false, false],
93
+ updatedAt: ['DateTime', false, false, false],
94
+ name: ['String', false, false, false],
95
+ type: ['AssetType', false, false, false],
96
+ fileSize: ['Int', false, false, false],
97
+ mimeType: ['String', false, false, false],
98
+ width: ['Int', false, false, false],
99
+ height: ['Int', false, false, false],
100
+ source: ['String', false, false, false],
101
+ preview: ['String', false, false, false],
102
+ focalPoint: ['Coordinate', true, false, false],
103
+ tags: ['Tag', false, true, false],
104
+ customFields: ['JSON', true, false, false],
105
+ },
106
+ ProductTranslation: {
107
+ id: ['ID', false, false, false],
108
+ createdAt: ['DateTime', false, false, false],
109
+ updatedAt: ['DateTime', false, false, false],
110
+ languageCode: ['LanguageCode', false, false, false],
111
+ name: ['String', false, false, false],
112
+ slug: ['String', false, false, false],
113
+ description: ['String', false, false, false],
114
+ customFields: ['ProductTranslationCustomFields', true, false, false],
115
+ },
116
+ ProductList: {
117
+ items: ['Product', false, true, false],
118
+ totalItems: ['Int', false, false, false],
119
+ },
120
+
121
+ ProductVariantTranslation: {
122
+ id: ['ID', false, false, false],
123
+ createdAt: ['DateTime', false, false, false],
124
+ updatedAt: ['DateTime', false, false, false],
125
+ languageCode: ['LanguageCode', false, false, false],
126
+ name: ['String', false, false, false],
127
+ },
128
+ Order: {
129
+ id: ['ID', false, false, false],
130
+ lines: ['OrderLine', false, true, false],
131
+ },
132
+ OrderLine: {
133
+ id: ['ID', false, false, false],
134
+ quantity: ['Int', false, false, false],
135
+ },
136
+ },
137
+ inputs: {
138
+ UpdateProductInput: {
139
+ id: ['ID', false, false, false],
140
+ name: ['String', false, false, false],
141
+ },
142
+ AdjustDraftOrderLineInput: {
143
+ orderLineId: ['ID', false, false, false],
144
+ quantity: ['Int', false, false, false],
145
+ },
146
+ },
147
+ scalars: [
148
+ 'ID',
149
+ 'String',
150
+ 'Int',
151
+ 'Boolean',
152
+ 'Float',
153
+ 'JSON',
154
+ 'DateTime',
155
+ 'Upload',
156
+ 'CurrencyCode',
157
+ ],
158
+ enums: {},
159
+ },
160
+ };
161
+ }
@@ -1,5 +1,6 @@
1
1
  import { BooleanDisplayBadge, BooleanDisplayCheckbox } from '@/vdb/components/data-display/boolean.js';
2
2
  import { DateTime } from '@/vdb/components/data-display/date-time.js';
3
+ import { Json } from '@/vdb/components/data-display/json.js';
3
4
  import { Money } from '@/vdb/components/data-display/money.js';
4
5
  import { VendureImage } from '@/vdb/components/shared/vendure-image.js';
5
6
  import { DataDisplayComponent } from '../component-registry/component-registry.js';
@@ -17,6 +18,7 @@ displayComponents.set('vendure:booleanBadge', BooleanDisplayBadge);
17
18
  displayComponents.set('vendure:dateTime', DateTime);
18
19
  displayComponents.set('vendure:asset', AssetDisplay);
19
20
  displayComponents.set('vendure:money', Money);
21
+ displayComponents.set('vendure:json', Json);
20
22
 
21
23
  export function getDisplayComponent(id: string): DataDisplayComponent | undefined {
22
24
  return globalRegistry.get('displayComponents').get(id);
@@ -35,12 +35,70 @@ export type BulkActionComponent<Item extends { id: string } & Record<string, any
35
35
 
36
36
  /**
37
37
  * @description
38
- * **Status: Developer Preview**
39
- *
40
38
  * A bulk action is a component that will be rendered in the bulk actions dropdown.
41
39
  *
42
- * @docsCategory components
43
- * @docsPage DataTable
40
+ * The component receives the following props:
41
+ *
42
+ * - `selection`: The selected row or rows
43
+ * - `table`: A reference to the Tanstack table instance powering the list
44
+ *
45
+ * The `table` object has
46
+ *
47
+ * @example
48
+ * ```tsx
49
+ * import { BulkActionComponent, DataTableBulkActionItem, usePaginatedList } from '\@vendure/dashboard';
50
+ *
51
+ * // This is an example of a bulk action that shows some typical
52
+ * // uses of the provided props
53
+ * export const MyBulkAction: BulkActionComponent<any> = ({ selection, table }) => {
54
+ * const { refetchPaginatedList } = usePaginatedList();
55
+ *
56
+ * const doTheAction = async () => {
57
+ * // Actual logic of the action
58
+ * // goes here...
59
+ *
60
+ * // On success, we refresh the list
61
+ * refetchPaginatedList();
62
+ * // and un-select any selected rows in the table
63
+ * table.resetRowSelection();
64
+ * };
65
+ *
66
+ * return (
67
+ * <DataTableBulkActionItem
68
+ * onClick={doTheAction}
69
+ * label={<Trans>Delete</Trans>}
70
+ * confirmationText={<Trans>Are you sure?</Trans>}
71
+ * icon={Check}
72
+ * className="text-destructive"
73
+ * />
74
+ * );
75
+ * }
76
+ * ```
77
+ *
78
+ * For the common action of deletion, we provide a ready-made helper component:
79
+ *
80
+ * @example
81
+ * ```tsx
82
+ * import { BulkActionComponent, DeleteProductsBulkAction } from '\@vendure/dashboard';
83
+ *
84
+ * // Define the BulkAction component. This one uses
85
+ * // a built-in wrapper for "delete" actions, which includes
86
+ * // a confirmation dialog.
87
+ * export const DeleteProductsBulkAction: BulkActionComponent<any> = ({ selection, table }) => {
88
+ * return (
89
+ * <DeleteBulkAction
90
+ * mutationDocument={deleteProductsDocument}
91
+ * entityName="products"
92
+ * requiredPermissions={['DeleteCatalog', 'DeleteProduct']}
93
+ * selection={selection}
94
+ * table={table}
95
+ * />
96
+ * );
97
+ * };
98
+ * ```
99
+ *
100
+ * @docsCategory list-views
101
+ * @docsPage bulk-actions
44
102
  * @since 3.4.0
45
103
  */
46
104
  export type BulkAction = {
@@ -40,6 +40,22 @@ export interface DashboardRouteDefinition {
40
40
  * [loader function](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#route-loaders)
41
41
  */
42
42
  loader?: RouteOptions['loader'];
43
+
44
+ /**
45
+ * @description
46
+ * Optional search parameter validation function.
47
+ * The value is a Tanstack Router
48
+ * [validateSearch function](https://tanstack.com/router/latest/docs/framework/react/guide/search-params#search-param-validation)
49
+ */
50
+ validateSearch?: RouteOptions['validateSearch'];
51
+
52
+ /**
53
+ * @description
54
+ * Define if the route should be under the authentication context, i.e have the authenticated route
55
+ * as a parent.
56
+ * @default true
57
+ */
58
+ authenticated?: boolean;
43
59
  }
44
60
 
45
61
  /**
@@ -19,6 +19,8 @@ import {
19
19
  StructField,
20
20
  TextCustomFieldConfig,
21
21
  } from '@/vdb/framework/form-engine/form-engine-types.js';
22
+ import { FormEvent } from 'react';
23
+ import { UseFormReturn } from 'react-hook-form';
22
24
 
23
25
  import { FieldInfo } from '../document-introspection/get-document-structure.js';
24
26
 
@@ -320,3 +322,35 @@ export function hasPermissionRequirement(input: ConfigurableFieldDef): boolean {
320
322
  export function isNullableField(input: ConfigurableFieldDef): boolean {
321
323
  return isCustomFieldConfig(input) && Boolean(input.nullable);
322
324
  }
325
+
326
+ /**
327
+ * Handles nested form submission to prevent event bubbling in nested forms.
328
+ * This is useful when you have a form inside a dialog that's within another form.
329
+ *
330
+ * @param form - The react-hook-form instance
331
+ * @param onSubmit - The submit handler function
332
+ * @returns An event handler that prevents propagation and handles the form submission
333
+ *
334
+ * @example
335
+ * ```tsx
336
+ * const form = useForm<FormSchema>({ resolver: zodResolver(formSchema) });
337
+ *
338
+ * return (
339
+ * <form onSubmit={handleNestedFormSubmit(form, (data) => {
340
+ * // Handle form submission
341
+ * })}>
342
+ * ...
343
+ * </form>
344
+ * );
345
+ * ```
346
+ */
347
+ export function handleNestedFormSubmit<TFieldValues extends Record<string, any>>(
348
+ form: UseFormReturn<TFieldValues>,
349
+ onSubmit: (data: TFieldValues) => void | Promise<void>,
350
+ ) {
351
+ return (e: FormEvent<HTMLFormElement>) => {
352
+ e.preventDefault();
353
+ e.stopPropagation();
354
+ void form.handleSubmit(onSubmit)(e);
355
+ };
356
+ }
@@ -17,7 +17,6 @@ import { ColumnFiltersState, SortingState, Table } from '@tanstack/react-table';
17
17
  import { TableOptions } from '@tanstack/table-core';
18
18
 
19
19
  import { BulkAction } from '@/vdb/framework/extension-api/types/index.js';
20
- import { addCustomFields } from '../document-introspection/add-custom-fields.js';
21
20
  import { FullWidthPageBlock, Page, PageActionBar, PageLayout, PageTitle } from '../layout-engine/page-layout.js';
22
21
 
23
22
  /**
@@ -34,9 +33,62 @@ export interface ListPageProps<
34
33
  V extends ListQueryOptionsShape,
35
34
  AC extends AdditionalColumns<T>,
36
35
  > {
36
+ /**
37
+ * @description
38
+ * A unique identifier for the list page. This is important to support
39
+ * customization functionality that relies on page IDs and makes your
40
+ * component extensible.
41
+ */
37
42
  pageId?: string;
43
+ /**
44
+ @description
45
+ * The Tanstack Router `Route` object, which will be defined in the component file.
46
+ */
38
47
  route: AnyRoute | (() => AnyRoute);
48
+ /**
49
+ @description
50
+ * The page title, which will display in the header area.
51
+ */
39
52
  title: string | React.ReactElement;
53
+ /**
54
+ * @description
55
+ * This DocumentNode of the list query, i.e. a query that fetches
56
+ * PaginatedList data with "items" and "totalItems", such as:
57
+ *
58
+ * @example
59
+ * ```tsx
60
+ * export const collectionListDocument = graphql(`
61
+ * query CollectionList($options: CollectionListOptions) {
62
+ * collections(options: $options) {
63
+ * items {
64
+ * id
65
+ * createdAt
66
+ * updatedAt
67
+ * name
68
+ * slug
69
+ * breadcrumbs {
70
+ * id
71
+ * name
72
+ * slug
73
+ * }
74
+ * children {
75
+ * id
76
+ * name
77
+ * }
78
+ * # ... etc
79
+ * }
80
+ * totalItems
81
+ * }
82
+ * }
83
+ * `);
84
+ * // ...
85
+ * <ListPage
86
+ * pageId="collection-list"
87
+ * listQuery={collectionListDocument}
88
+ * // ...
89
+ * />
90
+ * ```
91
+ */
40
92
  listQuery: T;
41
93
  /**
42
94
  * @description
@@ -46,20 +98,255 @@ export interface ListPageProps<
46
98
  * will be added to the action column dropdown already.
47
99
  */
48
100
  deleteMutation?: TypedDocumentNode<any, { id: string }>;
101
+ /**
102
+ * @description
103
+ * This prop can be used to intercept and transform the list query variables before they are
104
+ * sent to the Admin API.
105
+ *
106
+ * This allows you to implement specific logic that differs from the standard filter/sort
107
+ * handling.
108
+ *
109
+ * @example
110
+ * ```tsx
111
+ * <ListPage
112
+ * pageId="collection-list"
113
+ * title="Collections"
114
+ * listQuery={collectionListDocument}
115
+ * transformVariables={input => {
116
+ * const filterTerm = input.options?.filter?.name?.contains;
117
+ * // If there is a filter term set
118
+ * // we want to return all results. Else
119
+ * // we only want top-level Collections
120
+ * const isFiltering = !!filterTerm;
121
+ * return {
122
+ * options: {
123
+ * ...input.options,
124
+ * topLevelOnly: !isFiltering,
125
+ * },
126
+ * };
127
+ * }}
128
+ * />
129
+ * ```
130
+ */
49
131
  transformVariables?: (variables: V) => V;
132
+ /**
133
+ * @description
134
+ * Allows you to customize how the search term is used in the list query options.
135
+ * For instance, when you want the term to filter on specific fields.
136
+ *
137
+ * @example
138
+ * ```tsx
139
+ * <ListPage
140
+ * pageId="administrator-list"
141
+ * title="Administrators"
142
+ * listQuery={administratorListDocument}
143
+ * onSearchTermChange={searchTerm => {
144
+ * return {
145
+ * firstName: { contains: searchTerm },
146
+ * lastName: { contains: searchTerm },
147
+ * emailAddress: { contains: searchTerm },
148
+ * };
149
+ * }}
150
+ * />
151
+ * @param searchTerm
152
+ */
50
153
  onSearchTermChange?: (searchTerm: string) => NonNullable<V['options']>['filter'];
154
+ /**
155
+ * @description
156
+ * Allows you to customize the rendering and other aspects of individual columns.
157
+ *
158
+ * By default, an appropriate component will be chosen to render the column data
159
+ * based on the data type of the field. However, in many cases you want to have
160
+ * more control over how the column data is rendered.
161
+ *
162
+ * @example
163
+ * ```tsx
164
+ * <ListPage
165
+ * pageId="collection-list"
166
+ * listQuery={collectionListDocument}
167
+ * customizeColumns={{
168
+ * // The key "name" matches one of the top-level fields of the
169
+ * // list query type (Collection, in this example)
170
+ * name: {
171
+ * meta: {
172
+ * // The Dashboard optimizes the list query `collectionListDocument` to
173
+ * // only select field that are actually visible in the ListPage table.
174
+ * // However, sometimes you want to render data from other fields, i.e.
175
+ * // this column has a data dependency on the "children" and "breadcrumbs"
176
+ * // fields in order to correctly render the "name" field.
177
+ * // In this case, we can declare those data dependencies which means whenever
178
+ * // the "name" column is visible, it will ensure the "children" and "breadcrumbs"
179
+ * // fields are also selected in the query.
180
+ * dependencies: ['children', 'breadcrumbs'],
181
+ * },
182
+ * header: 'Collection Name',
183
+ * cell: ({ row }) => {
184
+ * const isExpanded = row.getIsExpanded();
185
+ * const hasChildren = !!row.original.children?.length;
186
+ * return (
187
+ * <div
188
+ * style={{ marginLeft: (row.original.breadcrumbs?.length - 2) * 20 + 'px' }}
189
+ * className="flex gap-2 items-center"
190
+ * >
191
+ * <Button
192
+ * size="icon"
193
+ * variant="secondary"
194
+ * onClick={row.getToggleExpandedHandler()}
195
+ * disabled={!hasChildren}
196
+ * className={!hasChildren ? 'opacity-20' : ''}
197
+ * >
198
+ * {isExpanded ? <FolderOpen /> : <Folder />}
199
+ * </Button>
200
+ * <DetailPageButton id={row.original.id} label={row.original.name} />
201
+ * </div>
202
+ * );
203
+ * },
204
+ * },
205
+ * ```
206
+ */
51
207
  customizeColumns?: CustomizeColumnConfig<T>;
208
+ /**
209
+ * @description
210
+ * Allows you to define extra columns that are not related to actual fields returned in
211
+ * the query result.
212
+ *
213
+ * For example, in the Administrator list, we define an additional "name" column composed
214
+ * of the `firstName` and `lastName` fields.
215
+ *
216
+ * @example
217
+ * ```tsx
218
+ * <ListPage
219
+ * pageId="administrator-list"
220
+ * title="Administrators"
221
+ * listQuery={administratorListDocument}
222
+ * additionalColumns={{
223
+ * name: {
224
+ * header: 'Name',
225
+ * cell: ({ row }) => (
226
+ * <DetailPageButton
227
+ * id={row.original.id}
228
+ * label={`${row.original.firstName} ${row.original.lastName}`}
229
+ * />
230
+ * ),
231
+ * },
232
+ * />
233
+ * ```
234
+ */
52
235
  additionalColumns?: AC;
236
+ /**
237
+ * @description
238
+ * Allows you to specify the default order of columns in the table. When not defined, the
239
+ * order of fields in the list query document will be used.
240
+ */
53
241
  defaultColumnOrder?: (keyof ListQueryFields<T> | keyof AC | CustomFieldKeysOfItem<ListQueryFields<T>>)[];
242
+ /**
243
+ * @description
244
+ * Allows you to specify the default sorting applied to the table.
245
+ *
246
+ * @example
247
+ * ```tsx
248
+ * defaultSort={[{ id: 'orderPlacedAt', desc: true }]}
249
+ * ```
250
+ */
54
251
  defaultSort?: SortingState;
252
+ /**
253
+ * @description
254
+ * Allows you to specify the default columns that are visible in the table.
255
+ * If you set them to `true`, then only those will show by default. If you set them to `false`,
256
+ * then _all other_ columns will be visible by default.
257
+ *
258
+ * @example
259
+ * ```tsx
260
+ * <ListPage
261
+ * pageId="country-list"
262
+ * listQuery={countriesListQuery}
263
+ * title="Countries"
264
+ * defaultVisibility={{
265
+ * name: true,
266
+ * code: true,
267
+ * enabled: true,
268
+ * }}
269
+ * />
270
+ * ```
271
+ */
55
272
  defaultVisibility?: Partial<
56
273
  Record<keyof ListQueryFields<T> | keyof AC | CustomFieldKeysOfItem<ListQueryFields<T>>, boolean>
57
274
  >;
58
275
  children?: React.ReactNode;
276
+ /**
277
+ * @description
278
+ * Allows you to define pre-set filters based on an array of possible selections
279
+ *
280
+ * @example
281
+ * ```tsx
282
+ * <ListPage
283
+ * pageId="payment-method-list"
284
+ * listQuery={paymentMethodListQuery}
285
+ * title="Payment Methods"
286
+ * facetedFilters={{
287
+ * enabled: {
288
+ * title: 'Enabled',
289
+ * options: [
290
+ * { label: 'Enabled', value: true },
291
+ * { label: 'Disabled', value: false },
292
+ * ],
293
+ * },
294
+ * }}
295
+ * />
296
+ * ```
297
+ */
59
298
  facetedFilters?: FacetedFilterConfig<T>;
299
+ /**
300
+ * @description
301
+ * Allows you to specify additional "actions" that will be made available in the "actions" column.
302
+ * By default, the actions column includes all bulk actions defined in the `bulkActions` prop.
303
+ */
60
304
  rowActions?: RowAction<ListQueryFields<T>>[];
305
+ /**
306
+ * @description
307
+ * Allows the returned list query data to be transformed in some way. This is an advanced feature
308
+ * that is not often required.
309
+ */
61
310
  transformData?: (data: any[]) => any[];
311
+ /**
312
+ * @description
313
+ * Allows you to directly manipulate the Tanstack Table `TableOptions` object before the
314
+ * table is created. And advanced option that is not often required.
315
+ */
62
316
  setTableOptions?: (table: TableOptions<any>) => TableOptions<any>;
317
+ /**
318
+ * @description
319
+ * Bulk actions are actions that can be applied to one or more table rows, and include things like
320
+ *
321
+ * - Deleting the rows
322
+ * - Assigning the rows to another channel
323
+ * - Bulk editing some aspect of the rows
324
+ *
325
+ * See the {@link BulkAction} docs for an example of how to build the component.
326
+ *
327
+ * @example
328
+ * ```tsx
329
+ * <ListPage
330
+ * pageId="product-list"
331
+ * listQuery={productListDocument}
332
+ * title="Products"
333
+ * bulkActions={[
334
+ * {
335
+ * component: AssignProductsToChannelBulkAction,
336
+ * order: 100,
337
+ * },
338
+ * {
339
+ * component: RemoveProductsFromChannelBulkAction,
340
+ * order: 200,
341
+ * },
342
+ * {
343
+ * component: DeleteProductsBulkAction,
344
+ * order: 300,
345
+ * },
346
+ * ]}
347
+ * />
348
+ * ```
349
+ */
63
350
  bulkActions?: BulkAction[];
64
351
  /**
65
352
  * @description
@@ -242,8 +529,6 @@ export function ListPage<
242
529
  });
243
530
  }
244
531
 
245
- const listQueryWithCustomFields = addCustomFields(listQuery);
246
-
247
532
  return (
248
533
  <Page pageId={pageId}>
249
534
  <PageTitle>{title}</PageTitle>
@@ -251,7 +536,7 @@ export function ListPage<
251
536
  <PageLayout>
252
537
  <FullWidthPageBlock blockId="list-table">
253
538
  <PaginatedListDataTable
254
- listQuery={listQueryWithCustomFields}
539
+ listQuery={listQuery}
255
540
  deleteMutation={deleteMutation}
256
541
  transformVariables={transformVariables}
257
542
  customizeColumns={customizeColumns as any}