vueye-table 2.0.0-alpha.9 → 3.0.0-alpha.2

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 (42) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +146 -65
  3. package/dist/index.d.ts +671 -1
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +490 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/style.css +1 -1
  8. package/package.json +48 -73
  9. package/dist/components/core/VueyeTable/VueyeTable.vue.d.ts +0 -65
  10. package/dist/components/core/VueyeTable/api.d.ts +0 -14
  11. package/dist/components/core/VueyeTable/components/VueyeBody/VueyeBody.vue.d.ts +0 -49
  12. package/dist/components/core/VueyeTable/components/VueyeBody/api.d.ts +0 -7
  13. package/dist/components/core/VueyeTable/components/VueyeBody/index.d.ts +0 -2
  14. package/dist/components/core/VueyeTable/components/VueyeDropdown/api.d.ts +0 -20
  15. package/dist/components/core/VueyeTable/components/VueyeDropdown/index.d.ts +0 -4
  16. package/dist/components/core/VueyeTable/components/VueyeHead/VueyeHead.vue.d.ts +0 -22
  17. package/dist/components/core/VueyeTable/components/VueyeHead/index.d.ts +0 -2
  18. package/dist/components/core/VueyeTable/components/VueyePagination/VueyePagination.vue.d.ts +0 -56
  19. package/dist/components/core/VueyeTable/components/VueyePagination/api.d.ts +0 -12
  20. package/dist/components/core/VueyeTable/components/VueyePagination/index.d.ts +0 -2
  21. package/dist/components/core/VueyeTable/components/index.d.ts +0 -4
  22. package/dist/components/core/VueyeTable/composables/index.d.ts +0 -4
  23. package/dist/components/core/VueyeTable/composables/useHeaderKeys.d.ts +0 -4
  24. package/dist/components/core/VueyeTable/composables/usePagination.d.ts +0 -11
  25. package/dist/components/core/VueyeTable/index.d.ts +0 -5
  26. package/dist/components/core/VueyeTable/types/Column.d.ts +0 -55
  27. package/dist/components/core/VueyeTable/types/Row.d.ts +0 -3
  28. package/dist/components/core/VueyeTable/types/Utils.d.ts +0 -19
  29. package/dist/components/core/VueyeTable/types/index.d.ts +0 -3
  30. package/dist/components/core/VueyeTable/utils/body.d.ts +0 -4
  31. package/dist/components/core/VueyeTable/utils/header.d.ts +0 -7
  32. package/dist/components/core/VueyeTable/utils/humanize.d.ts +0 -1
  33. package/dist/components/core/VueyeTable/utils/index.d.ts +0 -3
  34. package/dist/components/index.d.ts +0 -1
  35. package/dist/composables/dark.d.ts +0 -2
  36. package/dist/composables/index.d.ts +0 -1
  37. package/dist/favicon.ico +0 -0
  38. package/dist/histoire-setup.d.ts +0 -0
  39. package/dist/main.d.ts +0 -1
  40. package/dist/vueye-table.js +0 -429
  41. package/dist/vueye-table.umd.cjs +0 -1
  42. package/dist/white-logo.ico +0 -0
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 radix-vue
3
+ Copyright (c) 2026 Brahim Boussadjra and vueye-table contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,89 +1,170 @@
1
- # Vueye Table
1
+ # vueye-table
2
2
 
3
- Vueye Table is a Vue 3 component for displaying data in a table.
3
+ A Vue framework for data, data tables, and spreadsheets.
4
4
 
5
- ## Installation
5
+ vueye-table began as a single table component. Version 3 is a rewrite around one idea: a table is
6
+ data plus state plus operations, and rendering is a separate concern. A framework-independent
7
+ engine owns searching, filtering, sorting, pagination, selection, column visibility, editing,
8
+ undo, clipboard, and export. Vue layers sit on top of it, and you pick the one that fits:
9
+
10
+ | Layer | Package | Use it when |
11
+ | ------------------- | ----------------------- | ---------------------------------------------------------- |
12
+ | Full UI | `vueye-table` | You want a complete table or spreadsheet in one tag. |
13
+ | Styled components | `@vueye-table/styled` | You want the look, arranged your own way. |
14
+ | Headless components | `@vueye-table/headless` | You want accessible behavior with your own markup and CSS. |
15
+ | Vue composables | `@vueye-table/vue` | You want reactive state and nothing rendered. |
16
+ | Engine | `@vueye-table/core` | You are outside Vue, on a server, or writing a binding. |
17
+ | Nuxt module | `@vueye-table/nuxt` | You use Nuxt 4. |
18
+
19
+ Each layer depends only on the layers beneath it, and `vueye-table` re-exports all of them, so
20
+ one install covers every level.
21
+
22
+ > **Status:** `3.0.0-alpha`. The API is provisional and may change between alpha releases. The
23
+ > 2.x component lives on the [`legacy`](https://github.com/boussadjra/vueye-table/tree/legacy)
24
+ > branch; see [Upgrading from 2.x](./docs/guide/upgrading-from-2.md).
25
+
26
+ ## Install
6
27
 
7
28
  ```bash
8
- npm install vueye-table
29
+ pnpm add vueye-table
30
+ ```
31
+
32
+ Vue 3.5 or newer is a peer dependency.
33
+
34
+ ## Full table
35
+
36
+ ```vue
37
+ <script setup lang="ts">
38
+ import "vueye-table/style.css";
39
+ import { ref } from "vue";
40
+ import { VueyeTable, defineColumns, type RowKey } from "vueye-table";
41
+
42
+ interface User {
43
+ id: number;
44
+ name: { first: string; last: string };
45
+ age: number;
46
+ city: string;
47
+ }
48
+
49
+ const users: User[] = [
50
+ { id: 1, name: { first: "Ada", last: "Lovelace" }, age: 36, city: "London" },
51
+ { id: 2, name: { first: "Alan", last: "Turing" }, age: 41, city: "Wilmslow" },
52
+ ];
53
+
54
+ const columns = defineColumns<User>([
55
+ { id: "name.first", header: "First name" },
56
+ { id: "name.last", header: "Last name" },
57
+ { id: "age", align: "end", format: (age) => `${age} years` },
58
+ { id: "city" },
59
+ ]);
60
+
61
+ const selected = ref<readonly RowKey[]>([]);
62
+ </script>
63
+
64
+ <template>
65
+ <VueyeTable v-model:selected="selected" :data="users" :columns="columns" selectable striped>
66
+ <template #cell.city="{ value }">
67
+ <strong>{{ value }}</strong>
68
+ </template>
69
+ </VueyeTable>
70
+ </template>
71
+ ```
72
+
73
+ Column ids are typed paths into your rows, so `format` above receives a `number`. Without
74
+ `columns`, columns are inferred from the data.
75
+
76
+ Every piece of state has a `v-model`: `page`, `pageSize`, `sorting`, `search`, `filters`,
77
+ `hiddenColumns`, and `selected`. Add `manual` and `row-count` to let a server search, sort, and
78
+ page, with the table presenting whatever page it returns.
79
+
80
+ ## Spreadsheet
81
+
82
+ ```vue
83
+ <VueyeGrid v-model:data="lines" :columns="columns" column-letters />
9
84
  ```
10
85
 
11
- ## Usage
86
+ Cells edit in place. Arrows, Tab, Home, and End move; Shift extends the range; Enter or typing
87
+ starts an edit; Delete clears; and copy, cut, paste, undo, and redo behave like a spreadsheet
88
+ application. Each edit emits a new array; the one you passed in is never mutated. Text is parsed
89
+ by the column's type, and a value that cannot be read is refused and reported through
90
+ `edit-error`.
91
+
92
+ ## Headless
12
93
 
13
94
  ```vue
95
+ <script setup lang="ts">
96
+ import { DataTableRoot, DataTablePagination, DataTableSearch, useDataTable } from "vueye-table";
97
+
98
+ const table = useDataTable({ data: users, columns });
99
+ </script>
100
+
14
101
  <template>
15
- <VueyeTable
16
- :data="data"
17
- :columnHeaders="columnHeaders"
18
- :itemValue="itemValue"
19
- :perPage="perPage"
20
- :currentPage="currentPage"
21
- :perPageOptions="perPageOptions"
22
- :loading="loading"
23
- :selected="selected"
24
- :selectMode="selectMode"
25
- :caption="caption"
26
- :summary="summary"
27
- @update:loading="updateLoading"
28
- @update:selected="updateSelected"
29
- >
30
- <template #headerCellContent.name="props">
31
- {{ props.columnHeader.name }}
32
- </template>
33
- <template #itemCellContent.name="props">
34
- {{ props.item.name }}
35
- </template>
36
- </VueyeTable>
102
+ <DataTableRoot :table="table" as="div">
103
+ <DataTableSearch />
104
+ <article v-for="row in table.rows" :key="row.key">{{ row.getDisplay("name.first") }}</article>
105
+ <DataTablePagination />
106
+ </DataTableRoot>
37
107
  </template>
38
108
  ```
39
109
 
40
- ### VueyeTableProps
110
+ Headless components render semantic, accessible markup (`aria-sort`, `aria-selected`,
111
+ `aria-rowindex`, a polite live status, grid keyboard navigation) with `data-*` state attributes
112
+ and no styles. Every one accepts `as` and exposes its state through slot props.
41
113
 
42
- | Prop Name | Type | Default Value | Description |
43
- | --- | --- | --- | --- |
44
- | data | TData[] | [] | An array of data for the table. |
45
- | columnHeaders | TColumn[] or a function returning an array | [] | An array of column headers for the table. |
46
- | itemValue | string | 'id' | The property name used as a unique identifier for each item. |
47
- | perPage | number | 10 | The number of items displayed per page. |
48
- | currentPage | number | 1 | The current page number. |
49
- | perPageOptions | number[] or a function returning an array | [5, 10, 20, 30] | An array of options for the number of items per page. |
50
- | loading | boolean | false | Indicates whether the table is in a loading state. |
51
- | selected | TData[], Row[], or null | null | An array of selected items or rows. |
52
- | selectMode | 'page' or 'all' | 'all' | The mode for selecting items: 'page' or 'all'. |
53
- | caption | string | '' | The table's caption. |
54
- | summary | string | '' | The table's summary. |
114
+ ## Engine
55
115
 
56
- ### VueyeTableEmits
116
+ ```ts
117
+ import { createTable } from "@vueye-table/core";
57
118
 
58
- | Emit Name | Parameters | Description |
59
- | --------------- | -------------- | ------------------------------------- |
60
- | update:loading | value: boolean | Emits when the loading state changes. |
61
- | update:selected | value: T[] | Emits when the selected items change. |
119
+ const table = createTable({ data: users, columns: [{ id: "age" }, { id: "city" }] });
120
+ table.search("lon");
121
+ table.toggleSort("age");
122
+ table.getSnapshot().rows; // the current page
123
+ table.exportRows(); // CSV of every filtered row
124
+ ```
62
125
 
63
- ### PaginationEmits
126
+ The state is plain serializable data, so it can be saved, restored, sent to a server, or kept in
127
+ the URL.
64
128
 
65
- | Emit Name | Parameters | Description |
66
- | ------------------ | ------------- | ------------------------------------------------ |
67
- | update:currentPage | value: number | Emits when the current page changes. |
68
- | update:perPage | value: number | Emits when the number of items per page changes. |
129
+ ## Nuxt
69
130
 
70
- ### SlotHeader
131
+ ```ts
132
+ export default defineNuxtConfig({
133
+ modules: ["@vueye-table/nuxt"],
134
+ });
135
+ ```
71
136
 
72
- The SlotHeader component defines various slots for customizing the table header.
137
+ The module auto-imports `<VueyeTable>`, `<VueyeGrid>`, `useDataTable`, `useDataGrid`, and
138
+ `defineColumns`, and adds the stylesheet. Set `vueyeTable: { layers: true }` to also register the
139
+ headless and styled components.
73
140
 
74
- - `headerCell.<ColumnKey>`: Slot for customizing the content of a specific column header.
75
- - `headerCellContent.<ColumnKey>`: Slot for customizing the content within a specific column header cell.
76
- - `headers`: Slot for customizing the entire table header, containing all column headers.
77
- - `checkbox`: Slot for customizing the checkbox used for selecting all items.
141
+ ## Theming
78
142
 
79
- ### SlotRow
143
+ The styled layer is driven by CSS custom properties on `.vt-surface`:
144
+
145
+ ```css
146
+ .vt-surface {
147
+ --vt-accent: #0f766e;
148
+ --vt-radius: 4px;
149
+ --vt-font-size: 0.8125rem;
150
+ }
151
+ ```
152
+
153
+ Dark colors follow `prefers-color-scheme`; `theme="dark"` or `theme="light"` forces one.
154
+ Density is `compact`, `comfortable`, or `spacious`.
155
+
156
+ ## Development
157
+
158
+ ```bash
159
+ pnpm install
160
+ pnpm playground # every layer, side by side
161
+ pnpm test # every Vitest project
162
+ pnpm check # format, lint, types, tests with coverage, build, boundaries, packages
163
+ ```
80
164
 
81
- The SlotRow component defines various slots for customizing the table rows.
165
+ Architecture lives in [ARCHITECTURE.md](./ARCHITECTURE.md) and decisions in
166
+ [docs/adr](./docs/adr).
82
167
 
83
- - `itemCell.<ItemKey>`: Slot for customizing the content of a specific item cell within a row.
84
- - `itemCellContent.<ItemKey>`: Slot for customizing the content within a specific item cell.
85
- - `rows`: Slot for customizing the entire table rows, containing all rows.
86
- - `row`: Slot for customizing a specific row.
87
- - `checkbox`: Slot for customizing the checkbox used for selecting a specific row.
168
+ ## License
88
169
 
89
- You can use these Markdown tables to document the props, emits, and slot definitions for the data table and pagination components in your Vue 3 project.
170
+ [MIT](./LICENSE)