nuxt-ui-tools 1.17.0 → 1.18.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.
Files changed (122) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +1 -0
  3. package/dist/runtime/form/components/page/form-page-navigation.d.vue.ts +5 -3
  4. package/dist/runtime/form/components/page/form-page-navigation.vue +6 -3
  5. package/dist/runtime/form/components/page/form-page-navigation.vue.d.ts +5 -3
  6. package/dist/runtime/form/components/page/form-page-section.vue +6 -5
  7. package/dist/runtime/form/components/page/form-page-sections.d.vue.ts +4 -3
  8. package/dist/runtime/form/components/page/form-page-sections.vue +7 -2
  9. package/dist/runtime/form/components/page/form-page-sections.vue.d.ts +4 -3
  10. package/dist/runtime/form/components/page/form-page.d.vue.ts +2 -0
  11. package/dist/runtime/form/components/page/form-page.vue +10 -2
  12. package/dist/runtime/form/components/page/form-page.vue.d.ts +2 -0
  13. package/dist/runtime/form/components/renderer/form-field-renderer.vue +6 -4
  14. package/dist/runtime/form/components/renderer/form-field-shell.d.vue.ts +4 -4
  15. package/dist/runtime/form/components/renderer/form-field-shell.vue +28 -4
  16. package/dist/runtime/form/components/renderer/form-field-shell.vue.d.ts +4 -4
  17. package/dist/runtime/form/components/root/form.vue +2 -2
  18. package/dist/runtime/form/composables/use-field-control.d.ts +1 -1
  19. package/dist/runtime/form/composables/use-field-control.js +9 -21
  20. package/dist/runtime/form/composables/use-field-options.js +8 -4
  21. package/dist/runtime/form/composables/use-form-page.d.ts +11 -1
  22. package/dist/runtime/form/composables/use-form-page.js +12 -6
  23. package/dist/runtime/form/composables/use-form-runtime.js +1 -1
  24. package/dist/runtime/form/fields/array-primitive/types.d.ts +1 -1
  25. package/dist/runtime/form/fields/checkbox-card/component.vue +54 -28
  26. package/dist/runtime/form/fields/checkbox-card/config.d.ts +1 -0
  27. package/dist/runtime/form/fields/checkbox-card/config.js +1 -1
  28. package/dist/runtime/form/fields/checkbox-card/types.d.ts +3 -3
  29. package/dist/runtime/form/fields/choice-card/choice-card-label.d.vue.ts +7 -0
  30. package/dist/runtime/form/fields/choice-card/choice-card-label.vue +27 -1
  31. package/dist/runtime/form/fields/choice-card/choice-card-label.vue.d.ts +7 -0
  32. package/dist/runtime/form/fields/choice-card/types.d.ts +54 -1
  33. package/dist/runtime/form/fields/choice-card/use-choice-card.d.ts +7 -3
  34. package/dist/runtime/form/fields/choice-card/use-choice-card.js +37 -15
  35. package/dist/runtime/form/fields/choice-card/utils.d.ts +27 -0
  36. package/dist/runtime/form/fields/choice-card/utils.js +17 -0
  37. package/dist/runtime/form/fields/hierarchy/component.vue +3 -2
  38. package/dist/runtime/form/fields/index.d.ts +2 -0
  39. package/dist/runtime/form/fields/radio-card/component.vue +58 -28
  40. package/dist/runtime/form/fields/radio-card/config.d.ts +1 -0
  41. package/dist/runtime/form/fields/radio-card/config.js +1 -1
  42. package/dist/runtime/form/fields/radio-card/types.d.ts +3 -3
  43. package/dist/runtime/form/types/field-base.d.ts +6 -0
  44. package/dist/runtime/form/types/field-kind.d.ts +3 -1
  45. package/dist/runtime/form/types/field.d.ts +1 -0
  46. package/dist/runtime/form/types/page.d.ts +20 -8
  47. package/dist/runtime/form/types/ui.d.ts +24 -4
  48. package/dist/runtime/form/utils/disabled.d.ts +11 -0
  49. package/dist/runtime/form/utils/disabled.js +11 -0
  50. package/dist/runtime/form/utils/field-instance.js +3 -0
  51. package/dist/runtime/form/utils/options.d.ts +22 -1
  52. package/dist/runtime/form/utils/options.js +15 -0
  53. package/dist/runtime/form/utils/page-surface.d.ts +21 -0
  54. package/dist/runtime/form/utils/page-surface.js +27 -0
  55. package/dist/runtime/form/utils/page.d.ts +21 -1
  56. package/dist/runtime/form/utils/page.js +24 -2
  57. package/dist/runtime/i18n/locales/en.js +28 -8
  58. package/dist/runtime/i18n/locales/fr.js +28 -8
  59. package/dist/runtime/i18n/types.d.ts +46 -7
  60. package/dist/runtime/table/components/actions/row-actions.d.vue.ts +2 -0
  61. package/dist/runtime/table/components/actions/row-actions.vue +8 -3
  62. package/dist/runtime/table/components/actions/row-actions.vue.d.ts +2 -0
  63. package/dist/runtime/table/components/data-list/data-list-content.vue +7 -1
  64. package/dist/runtime/table/components/data-list/data-list-default.d.vue.ts +16 -16
  65. package/dist/runtime/table/components/data-list/data-list-default.vue +3 -0
  66. package/dist/runtime/table/components/data-list/data-list-default.vue.d.ts +16 -16
  67. package/dist/runtime/table/components/data-list/data-list-layout-switch.vue +7 -9
  68. package/dist/runtime/table/components/data-list/data-list-root.vue +5 -6
  69. package/dist/runtime/table/components/data-list/data-list-sort-menu.vue +3 -1
  70. package/dist/runtime/table/components/data-list/data-list-table.d.vue.ts +8 -1
  71. package/dist/runtime/table/components/data-list/data-list-table.vue +18 -1
  72. package/dist/runtime/table/components/data-list/data-list-table.vue.d.ts +8 -1
  73. package/dist/runtime/table/components/data-list/data-list-view-toggle.d.vue.ts +25 -0
  74. package/dist/runtime/table/components/data-list/data-list-view-toggle.vue +57 -0
  75. package/dist/runtime/table/components/data-list/data-list-view-toggle.vue.d.ts +25 -0
  76. package/dist/runtime/table/components/data-list/sort-menu-panel.vue +1 -1
  77. package/dist/runtime/table/components/layout/table-footer.d.vue.ts +6 -4
  78. package/dist/runtime/table/components/layout/table-footer.vue +80 -3
  79. package/dist/runtime/table/components/layout/table-footer.vue.d.ts +6 -4
  80. package/dist/runtime/table/components/summary/summary-content.d.ts +13 -0
  81. package/dist/runtime/table/components/summary/summary-content.js +5 -0
  82. package/dist/runtime/table/components/summary/summary-renderer.d.vue.ts +31 -0
  83. package/dist/runtime/table/components/summary/summary-renderer.vue +282 -0
  84. package/dist/runtime/table/components/summary/summary-renderer.vue.d.ts +31 -0
  85. package/dist/runtime/table/components/summary/summary-row.d.vue.ts +19 -0
  86. package/dist/runtime/table/components/summary/summary-row.vue +102 -0
  87. package/dist/runtime/table/components/summary/summary-row.vue.d.ts +19 -0
  88. package/dist/runtime/table/components/table/table-empty-state.vue +39 -9
  89. package/dist/runtime/table/components/table/table-renderer.vue +1 -1
  90. package/dist/runtime/table/components/table/table-row-actions-control.vue +10 -6
  91. package/dist/runtime/table/components/table/table-selection-control.d.vue.ts +5 -1
  92. package/dist/runtime/table/components/table/table-selection-control.vue +17 -4
  93. package/dist/runtime/table/components/table/table-selection-control.vue.d.ts +5 -1
  94. package/dist/runtime/table/components/table/table-tree-control.vue +2 -1
  95. package/dist/runtime/table/components/table/table-tree-header.vue +0 -1
  96. package/dist/runtime/table/composables/use-table-api.d.ts +2 -0
  97. package/dist/runtime/table/composables/use-table-api.js +8 -0
  98. package/dist/runtime/table/composables/use-table-columns.d.ts +2 -0
  99. package/dist/runtime/table/composables/use-table-controls.d.ts +6 -0
  100. package/dist/runtime/table/composables/use-table-controls.js +6 -3
  101. package/dist/runtime/table/composables/use-table-internals.d.ts +33 -0
  102. package/dist/runtime/table/composables/use-table-internals.js +9 -0
  103. package/dist/runtime/table/composables/use-table-row-labels.d.ts +16 -0
  104. package/dist/runtime/table/composables/use-table-row-labels.js +22 -0
  105. package/dist/runtime/table/composables/use-table-row-summary.d.ts +18 -0
  106. package/dist/runtime/table/composables/use-table-row-summary.js +41 -0
  107. package/dist/runtime/table/constants/mobile.d.ts +79 -0
  108. package/dist/runtime/table/constants/mobile.js +17 -0
  109. package/dist/runtime/table/constants/summary.d.ts +67 -0
  110. package/dist/runtime/table/constants/summary.js +31 -0
  111. package/dist/runtime/table/types/data-list.d.ts +58 -8
  112. package/dist/runtime/table/types/layout.d.ts +73 -0
  113. package/dist/runtime/table/types/schema.d.ts +9 -1
  114. package/dist/runtime/table/types/source.d.ts +6 -1
  115. package/dist/runtime/table/types/table-api.d.ts +12 -0
  116. package/dist/runtime/table/utils/columns/defs.js +3 -1
  117. package/dist/runtime/table/utils/columns/render.d.ts +2 -0
  118. package/dist/runtime/table/utils/columns/render.js +2 -2
  119. package/dist/runtime/table/utils/data-list-ui.js +3 -1
  120. package/dist/runtime/table/utils/mobile-defaults.d.ts +7 -0
  121. package/dist/runtime/table/utils/mobile-defaults.js +25 -0
  122. package/package.json +1 -1
@@ -6,6 +6,7 @@ import type { PaginationProps } from '@nuxt/ui/components/Pagination.vue';
6
6
  import type { SelectProps } from '@nuxt/ui/components/Select.vue';
7
7
  import type { ComputedRef } from 'vue';
8
8
  import type { TableInternals } from '../composables/use-table-internals.js';
9
+ import type { TableEmptySchema } from './layout.js';
9
10
  import type { TableLayout } from './utils.js';
10
11
  export interface DataListTable {
11
12
  schema: ComputedRef<{
@@ -211,6 +212,14 @@ export interface DataListLayoutSwitchUi {
211
212
  triggerLeadingIcon?: DataListUiClass;
212
213
  triggerTrailingIcon?: DataListUiClass;
213
214
  }
215
+ /** UI slots rendered by the summary/table toggle. */
216
+ export interface DataListViewToggleUi {
217
+ [slot: string]: DataListUiClass | undefined;
218
+ base?: DataListUiClass;
219
+ label?: DataListUiClass;
220
+ leadingIcon?: DataListUiClass;
221
+ trailingIcon?: DataListUiClass;
222
+ }
214
223
  /** UI slots rendered by the content state boundary. */
215
224
  export interface DataListContentUi {
216
225
  root?: DataListUiClass;
@@ -244,6 +253,35 @@ export interface DataListTableUi {
244
253
  loading?: DataListUiClass;
245
254
  loadingOverlay?: DataListUiClass;
246
255
  emptyOverlay?: DataListUiClass;
256
+ /** The empty state's button: the reset of a filtered list and the first-use `empty.action`. */
257
+ emptyAction?: DataListUiClass;
258
+ /** The row-actions button at the end of each row, in the table and in summary rows. */
259
+ rowAction?: DataListUiClass;
260
+ /** The tap area around a selection checkbox, a row's or the select-all one, in the table and in summary rows. */
261
+ selectControl?: DataListUiClass;
262
+ }
263
+ /** UI slots rendered by summary rows, the compact presentation of the table layout. */
264
+ export interface DataListSummaryUi {
265
+ root?: DataListUiClass;
266
+ viewport?: DataListUiClass;
267
+ /** The select-all strip above the rows, present when the list has selection. */
268
+ header?: DataListUiClass;
269
+ list?: DataListUiClass;
270
+ row?: DataListUiClass;
271
+ /** The checkbox cell of a row and of the select-all strip. */
272
+ select?: DataListUiClass;
273
+ /** The tappable part of a row: everything between the checkbox and the actions. */
274
+ main?: DataListUiClass;
275
+ leading?: DataListUiClass;
276
+ body?: DataListUiClass;
277
+ title?: DataListUiClass;
278
+ /** The line under the title, holding the status and the details. */
279
+ meta?: DataListUiClass;
280
+ status?: DataListUiClass;
281
+ details?: DataListUiClass;
282
+ actions?: DataListUiClass;
283
+ skeleton?: DataListUiClass;
284
+ loadingMore?: DataListUiClass;
247
285
  }
248
286
  /** UI slots rendered by the grid mode and its built-in states. */
249
287
  export interface DataListGridUi {
@@ -356,16 +394,19 @@ export interface DataListLayoutSwitchProps {
356
394
  /** Icons per layout; defaults to list and box icons. */
357
395
  icons?: Partial<Record<TableLayout, string>>;
358
396
  }
359
- /** Component props exposed by the table renderer controls. */
397
+ /** Component props exposed by the summary/table toggle. */
398
+ export interface DataListViewToggleProps {
399
+ button?: DataListButtonProps;
400
+ }
401
+ /** Component props exposed by the table renderer controls, shared by summary rows. */
360
402
  export interface DataListTableProps {
361
403
  checkbox?: DataListCheckboxProps;
362
404
  rowActions?: DataListButtonProps;
363
- /** Empty state copy; `description: false` hides the second line. */
364
- empty?: {
365
- icon?: string;
366
- title?: string;
367
- description?: string | false;
368
- };
405
+ /**
406
+ * Empty state copy and first-use action shared by every list. A list's own `empty` schema
407
+ * field wins, field by field. `description: false` hides the second line.
408
+ */
409
+ empty?: TableEmptySchema;
369
410
  }
370
411
  /** Component props exposed by offset pagination. */
371
412
  export interface DataListPaginationProps {
@@ -432,13 +473,22 @@ export interface DataListUiConfig {
432
473
  columnPanel?: DataListPartConfig<DataListColumnPanelUi, DataListColumnPanelProps>;
433
474
  sortMenu?: DataListPartConfig<DataListSortMenuUi, DataListSortMenuProps>;
434
475
  layoutSwitch?: DataListPartConfig<DataListLayoutSwitchUi, DataListLayoutSwitchProps>;
476
+ viewToggle?: DataListPartConfig<DataListViewToggleUi, DataListViewToggleProps>;
435
477
  content?: DataListPartConfig<DataListContentUi>;
436
478
  table?: DataListTableConfig;
479
+ summary?: DataListPartConfig<DataListSummaryUi>;
437
480
  grid?: DataListGridConfig;
438
481
  pagination?: DataListPartConfig<DataListPaginationUi, DataListPaginationProps>;
439
482
  infiniteLoader?: DataListPartConfig<DataListInfiniteLoaderUi, DataListInfiniteLoaderProps>;
440
483
  selectionActions?: DataListPartConfig<DataListSelectionActionsUi, DataListSelectionActionsProps>;
441
- /** Overrides merged on top of this config while the viewport is below the `md` breakpoint. */
484
+ /**
485
+ * Overrides merged on top of this config while the viewport is below the `md` breakpoint.
486
+ *
487
+ * Below `md` the package also adds a 44px touch target (`min-h-11 min-w-11` and alike) to the
488
+ * controls a thumb reaches, under the classes of each `ui` slot: yours add to them and win only
489
+ * where they conflict. To shrink a control back, state the conflicting utilities, for example
490
+ * `min-h-0 min-w-0`.
491
+ */
442
492
  mobile?: Omit<DataListUiConfig, 'mobile'>;
443
493
  }
444
494
  export interface DataListGridConfig extends DataListPartConfig<DataListGridUi> {
@@ -1,3 +1,5 @@
1
+ import type { ButtonProps } from '@nuxt/ui/components/Button.vue';
2
+ import type { LinkProps } from '@nuxt/ui/components/Link.vue';
1
3
  import type { TableColumnCollection, TableSummaryRequest, TableSummaryScope, TableSummaryValue } from './columns.js';
2
4
  import type { TableTreeSchema } from './tree.js';
3
5
  import type { GenericObject, TableDefaultSort, TableGridSortOption, TableLayout, TableRowRenderParams, RenderableType, TableSortKey, TableTextValue } from './utils.js';
@@ -5,6 +7,27 @@ export interface TablePersistenceOptions {
5
7
  state?: boolean;
6
8
  preferences?: boolean;
7
9
  }
10
+ /**
11
+ * The button of a first-use empty state. Any Nuxt UI button prop applies; `label` may be lazy so
12
+ * it follows the locale.
13
+ */
14
+ export interface TableEmptyAction extends Omit<ButtonProps, 'ui' | 'label'> {
15
+ label: TableTextValue;
16
+ /** Runs on click. Use `to` instead to navigate. */
17
+ onClick?: (event: MouseEvent) => void;
18
+ }
19
+ /**
20
+ * What a list shows when it has no records at all. Anything left out keeps the localized default.
21
+ * A list hidden by filters or a search always offers to reset them instead, never `action`.
22
+ */
23
+ export interface TableEmptySchema {
24
+ icon?: string;
25
+ title?: TableTextValue;
26
+ /** `false` hides the second line. */
27
+ description?: TableTextValue | false;
28
+ /** The first thing to do in an empty list, such as creating the first record. */
29
+ action?: TableEmptyAction;
30
+ }
8
31
  export type TableLayoutControl<TLayout extends TableLayout = TableLayout> = boolean | string | Partial<Record<TLayout, boolean | string>> | (() => boolean | string | Partial<Record<TLayout, boolean | string>>);
9
32
  export interface TableControlsSchema {
10
33
  refresh?: TableLayoutControl;
@@ -13,6 +36,8 @@ export interface TableControlsSchema {
13
36
  filters?: TableLayoutControl;
14
37
  sort?: TableLayoutControl;
15
38
  actions?: TableLayoutControl;
39
+ /** The toggle between summary rows and the full table, offered while `table.summary` is active. */
40
+ summary?: TableLayoutControl;
16
41
  }
17
42
  export interface TableSelectionSchema {
18
43
  mode?: false | true | 'auto';
@@ -59,6 +84,54 @@ export interface TableTableSchema<TRow extends GenericObject = GenericObject, TC
59
84
  defaultSorting?: TableDefaultSort<TSortKey>;
60
85
  selection?: boolean | 'auto';
61
86
  summaries?: TableSummariesSchema<TRow>;
87
+ /**
88
+ * Reads each record as one compact row instead of a line of columns, the way a phone screen
89
+ * needs it. Off until configured; see `TableRowSummarySchema` for when it applies.
90
+ */
91
+ summary?: TableRowSummarySchema<TRow, TContext, TPageContext>;
92
+ }
93
+ /** One value of a summary row's detail line. Empty values are skipped. */
94
+ export type TableRowSummaryValue = string | number | null | undefined | false;
95
+ /**
96
+ * A record as one summary row: an identity, one status, a couple of useful values and the row
97
+ * actions. Every callback receives the params a grid card gets, with `layout: 'table'`.
98
+ *
99
+ * Summary rows replace the column table, so columns, column sorting and the totals row are not
100
+ * shown while they are active. Filters, search, selection, row actions and pagination work as in
101
+ * the table, and a toggle brings the full table back.
102
+ *
103
+ * @example
104
+ * summary: {
105
+ * leading: ({ row }) => h(UAvatar, { text: initials(row.name), size: 'md' }),
106
+ * title: ({ row }) => row.name,
107
+ * status: ({ row }) => h(UBadge, { label: STATUS[row.status], variant: 'subtle' }),
108
+ * details: ({ row }) => [row.kind, row.city],
109
+ * to: ({ row }) => `/accounts/${row.id}`,
110
+ * }
111
+ */
112
+ export interface TableRowSummarySchema<TRow extends GenericObject = GenericObject, TContext extends GenericObject = GenericObject, TPageContext extends GenericObject = GenericObject> {
113
+ /**
114
+ * Where summary rows replace the column table: `true`, `false`, a responsive string, or a
115
+ * getter returning either. The reader can still switch to the table from the toggle.
116
+ * @default 'true md:false' Summary rows below the `md` breakpoint, the table from `md` up.
117
+ * @example 'true lg:false' // summary rows on tablets too
118
+ */
119
+ enabled?: boolean | string | (() => boolean | string);
120
+ /** The record's identity. One line, cut with an ellipsis when it does not fit. */
121
+ title: (params: TableRowRenderParams<TRow, TContext, TPageContext>) => string | number;
122
+ /**
123
+ * A 32px tile before the title: an avatar, an icon, initials. It is clipped to a rounded
124
+ * square, so pass an element that fills it.
125
+ */
126
+ leading?: (params: TableRowRenderParams<TRow, TContext, TPageContext>) => RenderableType;
127
+ /** One status pill, first on the line under the title. */
128
+ status?: (params: TableRowRenderParams<TRow, TContext, TPageContext>) => RenderableType;
129
+ /** The two or so values worth reading without opening the record, joined with " · ". */
130
+ details?: (params: TableRowRenderParams<TRow, TContext, TPageContext>) => TableRowSummaryValue[];
131
+ /** Makes the row a link to the record. Return `undefined` for a row that is not one. */
132
+ to?: (params: TableRowRenderParams<TRow, TContext, TPageContext>) => LinkProps['to'] | undefined;
133
+ /** Runs when the row is tapped. With `to`, it runs before the navigation. */
134
+ onSelect?: (params: TableRowRenderParams<TRow, TContext, TPageContext>) => void;
62
135
  }
63
136
  export interface TableSummariesSchema<TRow extends GenericObject = GenericObject> {
64
137
  /** Rows the aggregates describe; defaults to `filtered`. */
@@ -1,14 +1,22 @@
1
1
  import type { TableBulkAction, TableRowAction, TableToolbarAction } from './actions.js';
2
2
  import type { TableContextDataFromItems, TableContextItem, TablePageContextItem } from './context.js';
3
3
  import type { TableFiltersSchema } from './filters.js';
4
- import type { TableControlsSchema, TableGridSchema, TablePaginationSchema, TablePersistenceOptions, TableSelectionSchema, TableTableSchema } from './layout.js';
4
+ import type { TableControlsSchema, TableEmptySchema, TableGridSchema, TablePaginationSchema, TablePersistenceOptions, TableSelectionSchema, TableTableSchema } from './layout.js';
5
5
  import type { InferTableSourceRow, ExtractTableSourceResult, NormalizeTableSource, TableCursorPageResult, TableSource, TableSourceExecutionResult } from './source.js';
6
6
  import type { TableKnownFieldPath, TableLayout, TableRowKey, TableSortKey, GenericObject } from './utils.js';
7
7
  export interface TableSchema<TRow extends GenericObject = GenericObject, TContextItems extends TableContextItem[] = TableContextItem[], TPageContextItems extends TablePageContextItem<TRow, TableContextDataFromItems<TContextItems>>[] = TablePageContextItem<TRow, TableContextDataFromItems<TContextItems>>[], TFilterKey extends string = TableKnownFieldPath<TRow>, TSortKey extends string = TableSortKey<TRow>> {
8
8
  tableKey: string;
9
9
  rowKey: TableRowKey<TRow>;
10
10
  source: TableSource<TRow, TableContextDataFromItems<TContextItems>, TRow[] | TableSourceExecutionResult<TRow> | TableCursorPageResult<TRow>>;
11
+ /**
12
+ * Names a record for assistive technology, in "Select {label}" and "Actions for {label}".
13
+ * Without it the controls name the row by its position on the page.
14
+ * @example (row) => row.name
15
+ */
16
+ rowLabel?: (row: TRow) => string | number | null | undefined;
11
17
  defaultLayout?: TableLayout;
18
+ /** What the list shows while it has no records at all. See `TableEmptySchema`. */
19
+ empty?: TableEmptySchema;
12
20
  pagination?: TablePaginationSchema;
13
21
  context?: TContextItems;
14
22
  pageContext?: TPageContextItems;
@@ -5,10 +5,15 @@ import type { GenericObject, TableKnownFieldPath, TablePaginationState, TableSor
5
5
  /** Table name of the shared `QueryDefinition`, kept for public type compatibility. */
6
6
  export type TableQueryDefinition<TData = unknown> = QueryDefinition<TData>;
7
7
  /**
8
- * Result of a query definition: what its `queryFn` resolves to, or the data type of TanStack
8
+ * Result of a query definition: what the table actually receives.
9
+ *
10
+ * A `select` wins, because TanStack hands its return value to the consumer in place of the
11
+ * fetched data. Without one it is what the `queryFn` resolves to, or the data type of TanStack
9
12
  * options whose `queryFn` may be a ref or `skipToken` (Tuyau's `queryOptions()`).
10
13
  */
11
14
  export type TableSourceQueryResult<TQuery> = TQuery extends {
15
+ select: (...args: never[]) => infer TSelected;
16
+ } ? Awaited<TSelected> : TQuery extends {
12
17
  queryFn: (...args: never[]) => infer TResult;
13
18
  } ? Awaited<TResult> : TQuery extends UseQueryOptions<infer _TQueryFnData, infer _TError, infer TResult, infer _TQueryData, infer _TQueryKey> ? Awaited<TResult> : never;
14
19
  /** Row of a table query result: an array of rows, or a page (`{ rows }`). */
@@ -103,6 +103,18 @@ export interface TableApi<TSchema = TableSchemaView> {
103
103
  }>;
104
104
  set: (layout: TableLayout) => void;
105
105
  };
106
+ /**
107
+ * Summary rows, the compact presentation of the table layout. With no `table.summary` in the
108
+ * schema, or where it is not enabled, `state.available` is `false` and `set` has no effect.
109
+ */
110
+ summary: {
111
+ state: ComputedRef<{
112
+ active: boolean;
113
+ available: boolean;
114
+ }>;
115
+ /** Shows the summary rows (`true`) or the full table (`false`), and remembers the choice. */
116
+ set: (active: boolean) => void;
117
+ };
106
118
  filters: {
107
119
  state: ComputedRef<TableFilterState>;
108
120
  search: WritableComputedRef<string>;
@@ -48,7 +48,9 @@ export function createColumnDefs(options) {
48
48
  canHide: false,
49
49
  internal: "selection",
50
50
  label: "",
51
- render: ({ row, index }) => selection.cell({ row: { id: options.params.selection.getRowId({ index, row }) } }),
51
+ render: ({ row, index }) => selection.cell({
52
+ row: { id: options.params.selection.getRowId({ index, row }), index, original: row }
53
+ }),
52
54
  renderHeader: () => selection.header(),
53
55
  sortable: false
54
56
  },
@@ -9,6 +9,8 @@ export declare function createSelectionColumn(options: {
9
9
  cell: ({ row }: {
10
10
  row: {
11
11
  id: string;
12
+ original: GenericObject;
13
+ index: number;
12
14
  };
13
15
  }) => import("vue/jsx-runtime").JSX.Element;
14
16
  enableHiding: boolean;
@@ -29,7 +29,8 @@ export function createSelectionColumn(options) {
29
29
  TableSelectionControl,
30
30
  {
31
31
  modelValue: options.params.selection.isRowSelected({ rowId }),
32
- ariaLabel: "Select row",
32
+ row: row.original,
33
+ index: row.index,
33
34
  onToggle: (event) => options.params.selection.toggleRowSelection({
34
35
  rowId,
35
36
  selected: !options.params.selection.isRowSelected({ rowId }),
@@ -46,7 +47,6 @@ export function createSelectionColumn(options) {
46
47
  TableSelectionControl,
47
48
  {
48
49
  modelValue: options.params.selection.allSelected.value ? true : options.params.selection.partiallySelected.value ? "indeterminate" : false,
49
- ariaLabel: "Select all rows",
50
50
  onToggle: () => options.params.selection.toggleAllRows({
51
51
  selected: !options.params.selection.allSelected.value
52
52
  })
@@ -205,7 +205,9 @@ export function mergeDataListUiConfig(appUi, componentUi, density, size) {
205
205
  search: mergeSearchConfig(appUi?.search, componentUi?.search),
206
206
  selectionActions: mergePartConfig(appUi?.selectionActions, componentUi?.selectionActions),
207
207
  sortMenu: mergePartConfig(appUi?.sortMenu, componentUi?.sortMenu),
208
- table: mergeUiConfig(appUi?.table, componentUi?.table)
208
+ summary: mergeUiConfig(appUi?.summary, componentUi?.summary),
209
+ table: mergeUiConfig(appUi?.table, componentUi?.table),
210
+ viewToggle: mergePartConfig(appUi?.viewToggle, componentUi?.viewToggle)
209
211
  };
210
212
  }
211
213
  function mergeUiConfig(appDefaults, componentConfig) {
@@ -0,0 +1,7 @@
1
+ import type { DataListUiConfig } from '../types/index.js';
2
+ /**
3
+ * Adds the package's mobile defaults to a config: a 44px touch target on every control a thumb
4
+ * reaches. Their classes go under the classes each slot already has, so an app's own slot classes
5
+ * are kept and win wherever they conflict.
6
+ */
7
+ export declare function layerDataListMobileDefaults(config: DataListUiConfig): DataListUiConfig;
@@ -0,0 +1,25 @@
1
+ import { isObject, isString } from "../../shared/utils/predicate.js";
2
+ import { DATA_LIST_MOBILE_DEFAULTS } from "../constants/mobile.js";
3
+ import { mergeDataListUiClass } from "./data-list-ui.js";
4
+ function isClassEntry(entry) {
5
+ return isString(entry[1]);
6
+ }
7
+ function readPart(config, name) {
8
+ const part = new Map(Object.entries(config)).get(name);
9
+ return isObject(part) ? part : {};
10
+ }
11
+ function layerPart(config, name, defaults) {
12
+ const own = readPart(config, name);
13
+ const ui = isObject(own.ui) ? own.ui : {};
14
+ const classes = new Map(Object.entries(ui).filter(isClassEntry));
15
+ const added = Object.entries(defaults).filter(isClassEntry).map(
16
+ ([slot, base]) => [slot, mergeDataListUiClass(base, void 0, classes.get(slot))]
17
+ );
18
+ return { ...own, ui: { ...ui, ...Object.fromEntries(added) } };
19
+ }
20
+ export function layerDataListMobileDefaults(config) {
21
+ const layered = Object.entries(DATA_LIST_MOBILE_DEFAULTS).map(
22
+ ([name, defaults]) => [name, layerPart(config, name, defaults.ui)]
23
+ );
24
+ return Object.assign({}, config, Object.fromEntries(layered));
25
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-ui-tools",
3
- "version": "1.17.0",
3
+ "version": "1.18.0",
4
4
  "description": "Nuxt module and runtime toolkit for UI-heavy Nuxt applications",
5
5
  "homepage": "https://github.com/ChronicStone/nuxt-ui-tools#readme",
6
6
  "bugs": "https://github.com/ChronicStone/nuxt-ui-tools/issues",