@midas-ds/table-styles 1.1.9 → 1.2.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## 1.2.1 (2026-01-13)
2
+
3
+ ### 🧱 Updated Dependencies
4
+
5
+ - Updated components to 16.3.2
6
+
7
+ ## 1.2.0 (2026-01-13)
8
+
9
+ ### 🚀 Features
10
+
11
+ - **table-styles:** add pagination component ([#978](https://github.com/migrationsverket/midas/pull/978))
12
+
13
+ ### 🧱 Updated Dependencies
14
+
15
+ - Updated components to 16.3.1
16
+
1
17
  ## 1.1.9 (2026-01-09)
2
18
 
3
19
  ### 🧱 Updated Dependencies
package/README.md CHANGED
@@ -1,6 +1,62 @@
1
- # Table-styles
1
+ # @midas-ds/table-styles
2
2
 
3
- CSS for styling headless libs with `@midas-ds` styles.
3
+ React components and styles for TanStack Table with Midas design system.
4
4
 
5
+ ## Installation
5
6
 
7
+ ```bash
8
+ npm install @midas-ds/table-styles @tanstack/react-table
9
+ ```
6
10
 
11
+ ## Usage
12
+
13
+ ### Import the component and styles
14
+
15
+ ```typescript
16
+ import { Pagination } from '@midas-ds/table-styles'
17
+ import '@midas-ds/table-styles/tanstack-table.css'
18
+ ```
19
+
20
+ ### Basic example with TanStack Table
21
+
22
+ ```typescript
23
+ import { useReactTable, getCoreRowModel, getPaginationRowModel } from '@tanstack/react-table'
24
+ import { Pagination } from '@midas-ds/table-styles'
25
+ import '@midas-ds/table-styles/tanstack-table.css'
26
+
27
+ function MyTable() {
28
+ const table = useReactTable({
29
+ data,
30
+ columns,
31
+ getCoreRowModel: getCoreRowModel(),
32
+ getPaginationRowModel: getPaginationRowModel(),
33
+ })
34
+
35
+ const { pagination: { pageIndex, pageSize } } = table.getState()
36
+
37
+ return (
38
+ <>
39
+ <table className="midas-tanstack-table">
40
+ {/* Your table markup */}
41
+ </table>
42
+
43
+ <Pagination
44
+ getCanNextPage={table.getCanNextPage}
45
+ getCanPreviousPage={table.getCanPreviousPage}
46
+ getPageCount={table.getPageCount}
47
+ getRowCount={table.getRowCount}
48
+ nextPage={table.nextPage}
49
+ pageIndex={pageIndex}
50
+ pageSize={pageSize}
51
+ previousPage={table.previousPage}
52
+ setPageIndex={table.setPageIndex}
53
+ setPageSize={table.setPageSize}
54
+ />
55
+ </>
56
+ )
57
+ }
58
+ ```
59
+
60
+ ## Documentation
61
+
62
+ For complete documentation and examples, visit [Midas Design System](https://designsystem.migrationsverket.se/)
package/index.css ADDED
@@ -0,0 +1 @@
1
+ ._pagination_4gcns_1{align-items:center;background-color:var(--midas-layer-01-base);color:var(--midas-text-primary);container-type:inline-size;display:flex;font-size:var(--midas-typography-font-size-20);height:var(--midas-size-150);justify-content:space-between;line-height:var(--midas-typography-line-height-30)}._pagination_4gcns_1 *{font-size:var(--midas-typography-font-size-20)}._separator_4gcns_17{border-left:1px solid var(--midas-border-color-subtle)}._select_4gcns_21{flex-direction:row;gap:var(--midas-spacing-10)}._select_4gcns_21 label{align-items:center;display:flex;font-weight:var(--midas-typography-weight-regular);margin:0}._select_4gcns_21 button{border:none}._select_4gcns_21 button span{max-width:unset!important}._listBoxItem_4gcns_41{padding:.44rem var(--midas-spacing-50) .44rem var(--midas-spacing-50);font-size:var(--midas-typography-font-size-20);line-height:var(--midas-typography-line-height-20);height:var(--midas-size-120);white-space:nowrap}._listBoxItem_4gcns_41[data-selected] div{max-width:unset!important}._listBoxItem_4gcns_41[data-selected]:before,._listBoxItem_4gcns_41[data-selected]:after{display:none}._pageSize_4gcns_60{padding-left:var(--midas-spacing-50)}._pageSize_4gcns_60 button{padding:0 var(--midas-spacing-50) 0 var(--midas-spacing-30)}._pageSize_4gcns_60 button+span div{left:var(--midas-spacing-30)!important}._result_4gcns_73{align-items:center;display:flex;height:100%;padding:0 var(--midas-spacing-50)}@container (width < 675px){._result_4gcns_73{display:none}}._pageIndexContainer_4gcns_85{align-items:center;display:flex;padding:0 var(--midas-spacing-50) 0 0}._pageIndexContainer_4gcns_85 ._label_4gcns_91{white-space:nowrap}@container (width < 420px){._pageIndexContainer_4gcns_85 ._label_4gcns_91{display:none}}._pageIndex_4gcns_85 button{padding:0 var(--midas-spacing-30) 0 var(--midas-spacing-50)}._buttons_4gcns_108{display:flex;height:100%}
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { Pagination } from './lib/pagination';
2
+ export type { PaginationProps } from './lib/pagination';
package/index.mjs ADDED
@@ -0,0 +1,146 @@
1
+ import { jsxs as o, jsx as t, Fragment as C } from "react/jsx-runtime";
2
+ import { ChevronLeft as z, ChevronRight as B } from "lucide-react";
3
+ import { useLocalizedStringFormatter as w, Select as b, ListBoxItem as f, Text as P, Button as h } from "@midas-ds/components";
4
+ import { FocusScope as F, useFocusManager as L } from "react-aria";
5
+ import './index.css';const R = { nextPage: "Next page", previousPage: "Previous page", rowsPerPage: "Rows per page:", of: "of", page: "page", pages: "pages", row: "row", rows: "rows", selectPage: "Select page" }, V = { nextPage: "Nästa sida", previousPage: "Föregående sida", rowsPerPage: "Rader per sida:", of: "av", page: "sida", pages: "sidor", row: "rad", rows: "rader", selectPage: "Välj sida" }, I = {
6
+ en: R,
7
+ sv: V
8
+ }, y = "_pagination_4gcns_1", j = "_listBoxItem_4gcns_41", k = "_pageSize_4gcns_60 _select_4gcns_21", A = "_result_4gcns_73 _separator_4gcns_17", D = "_pageIndexContainer_4gcns_85 _separator_4gcns_17", M = "_label_4gcns_91", K = "_pageIndex_4gcns_85 _select_4gcns_21", O = "_buttons_4gcns_108", T = "_button_4gcns_108 _separator_4gcns_17", a = {
9
+ pagination: y,
10
+ listBoxItem: j,
11
+ pageSize: k,
12
+ result: A,
13
+ pageIndexContainer: D,
14
+ label: M,
15
+ pageIndex: K,
16
+ buttons: O,
17
+ button: T
18
+ }, q = ({
19
+ getCanNextPage: r,
20
+ getCanPreviousPage: p,
21
+ nextPage: m,
22
+ previousPage: i
23
+ }) => {
24
+ const n = L(), g = w(I), c = (_) => {
25
+ switch (_.key) {
26
+ case "ArrowRight":
27
+ n?.focusNext({ wrap: !0 });
28
+ break;
29
+ case "ArrowLeft":
30
+ n?.focusPrevious({ wrap: !0 });
31
+ break;
32
+ }
33
+ };
34
+ return /* @__PURE__ */ o(C, { children: [
35
+ /* @__PURE__ */ t(
36
+ h,
37
+ {
38
+ "aria-label": g.format("previousPage"),
39
+ className: a.button,
40
+ isDisabled: !p(),
41
+ onKeyDown: c,
42
+ onPress: i,
43
+ variant: "icon",
44
+ children: /* @__PURE__ */ t(z, {})
45
+ }
46
+ ),
47
+ /* @__PURE__ */ t(
48
+ h,
49
+ {
50
+ "aria-label": g.format("nextPage"),
51
+ className: a.button,
52
+ isDisabled: !r(),
53
+ onKeyDown: c,
54
+ onPress: m,
55
+ variant: "icon",
56
+ children: /* @__PURE__ */ t(B, {})
57
+ }
58
+ )
59
+ ] });
60
+ }, Q = (r) => {
61
+ const {
62
+ getPageCount: p,
63
+ getRowCount: m,
64
+ pageIndex: i,
65
+ pageSize: n,
66
+ pageSizeOptions: g = [10, 20, 30, 40, 50],
67
+ setPageIndex: c,
68
+ setPageSize: _
69
+ } = r, s = w(I), u = p(), l = m(), x = (i + 1) * n, S = x - n + 1, N = (e) => {
70
+ c(e !== null ? Number(e) : 0);
71
+ }, v = (e) => {
72
+ const d = e !== null ? Number(e) : n;
73
+ _(d);
74
+ };
75
+ return /* @__PURE__ */ o("div", { className: a.pagination, children: [
76
+ /* @__PURE__ */ t(
77
+ b,
78
+ {
79
+ className: a.pageSize,
80
+ items: g.map((e) => ({
81
+ id: e.toString(),
82
+ name: e
83
+ })),
84
+ label: s.format("rowsPerPage"),
85
+ onChange: v,
86
+ value: n.toString(),
87
+ children: (e) => /* @__PURE__ */ t(
88
+ f,
89
+ {
90
+ className: a.listBoxItem,
91
+ id: e.id,
92
+ textValue: e.id,
93
+ children: e.name
94
+ }
95
+ )
96
+ }
97
+ ),
98
+ /* @__PURE__ */ o(P, { className: a.result, children: [
99
+ S,
100
+ " -",
101
+ " ",
102
+ x > l ? l : x,
103
+ " ",
104
+ s.format("of"),
105
+ " ",
106
+ l.toLocaleString(),
107
+ " ",
108
+ l === 1 ? s.format("row") : s.format("rows")
109
+ ] }),
110
+ /* @__PURE__ */ o("div", { className: a.pageIndexContainer, children: [
111
+ /* @__PURE__ */ t(
112
+ b,
113
+ {
114
+ "aria-label": s.format("selectPage"),
115
+ className: a.pageIndex,
116
+ items: Array.from({ length: u }, (e, d) => ({
117
+ id: d.toString(),
118
+ name: d
119
+ })),
120
+ onChange: N,
121
+ value: i.toString(),
122
+ children: (e) => /* @__PURE__ */ t(
123
+ f,
124
+ {
125
+ className: a.listBoxItem,
126
+ id: e.id,
127
+ textValue: (Number(e.id) + 1).toString(),
128
+ children: e.name + 1
129
+ }
130
+ )
131
+ }
132
+ ),
133
+ /* @__PURE__ */ o(P, { className: a.label, children: [
134
+ s.format("of"),
135
+ " ",
136
+ u,
137
+ " ",
138
+ u === 1 ? s.format("page") : s.format("pages")
139
+ ] })
140
+ ] }),
141
+ /* @__PURE__ */ t("div", { className: a.buttons, children: /* @__PURE__ */ t(F, { children: /* @__PURE__ */ t(q, { ...r }) }) })
142
+ ] });
143
+ };
144
+ export {
145
+ Q as Pagination
146
+ };
@@ -0,0 +1,9 @@
1
+ import { PaginationState, RowData, Table } from '@tanstack/react-table';
2
+ export interface PaginationProps<T extends RowData> extends Pick<Table<T>, 'getCanNextPage' | 'getCanPreviousPage' | 'getPageCount' | 'getRowCount' | 'nextPage' | 'previousPage' | 'setPageIndex' | 'setPageSize'>, PaginationState {
3
+ /**
4
+ * Options for different page sizes
5
+ * @default [10, 20, 30, 40, 50]
6
+ */
7
+ pageSizeOptions?: number[];
8
+ }
9
+ export declare const Pagination: <T extends RowData>(props: PaginationProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from './Pagination';
package/package.json CHANGED
@@ -11,16 +11,30 @@
11
11
  "publishConfig": {
12
12
  "access": "public"
13
13
  },
14
- "description": "Midas table styles",
14
+ "description": "Midas table components and styles for TanStack Table",
15
15
  "homepage": "https://designsystem.migrationsverket.se/",
16
16
  "license": "CC0-1.0",
17
- "version": "1.1.9",
17
+ "version": "1.2.1",
18
+ "main": "./index.mjs",
19
+ "types": "./index.d.ts",
20
+ "files": [
21
+ "./"
22
+ ],
18
23
  "exports": {
24
+ ".": {
25
+ "types": "./index.d.ts",
26
+ "import": "./index.mjs",
27
+ "default": "./index.mjs"
28
+ },
19
29
  "./tanstack-table.css": {
20
30
  "import": "./tanstack-table.css"
21
31
  }
22
32
  },
23
33
  "dependencies": {
24
- "@midas-ds/theme": "3.9.3"
34
+ "@midas-ds/components": "16.3.2",
35
+ "@midas-ds/theme": "3.9.3",
36
+ "lucide-react": "^0.525.0",
37
+ "react-aria-components": "1.14.0",
38
+ "@tanstack/react-table": "^8.21.3"
25
39
  }
26
40
  }