@payfit/unity-components 2.14.2 → 2.15.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.
|
@@ -1,32 +1,47 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as p, jsxs as R } from "react/jsx-runtime";
|
|
2
2
|
import i, { forwardRef as z, useRef as V, useMemo as H, useImperativeHandle as k, useCallback as D } from "react";
|
|
3
|
-
import { uyTv as
|
|
4
|
-
import { useVirtualizer as
|
|
5
|
-
import { useResizeObserver as
|
|
6
|
-
import { TableContextProvider as
|
|
7
|
-
const P =
|
|
3
|
+
import { uyTv as S, uyMerge as E } from "@payfit/unity-themes";
|
|
4
|
+
import { useVirtualizer as M } from "@tanstack/react-virtual";
|
|
5
|
+
import { useResizeObserver as K } from "usehooks-ts";
|
|
6
|
+
import { TableContextProvider as U, useTableContext as $ } from "./Table.context.js";
|
|
7
|
+
const P = S({
|
|
8
8
|
base: [
|
|
9
9
|
"uy:w-full uy:border uy:border-solid uy:border-border-neutral uy:rounded-100",
|
|
10
10
|
"uy:relative uy:flex uy:flex-col uy:overflow-hidden",
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
style: {
|
|
21
|
-
"--uy-table-min-rows": `calc(var(--uy-spacing-600) * ${y})`,
|
|
22
|
-
"--uy-table-max-rows": `calc(var(--uy-spacing-600) * ${d})`
|
|
23
|
-
},
|
|
24
|
-
children: o
|
|
11
|
+
// always force minimum 10 rows of height
|
|
12
|
+
"uy:min-h-(--uy-table-min-rows)"
|
|
13
|
+
],
|
|
14
|
+
variants: {
|
|
15
|
+
height: {
|
|
16
|
+
// allow table to fill available height of container
|
|
17
|
+
fillSpace: ["uy:h-full"],
|
|
18
|
+
// fixed maximum height, defined by number of rows
|
|
19
|
+
fixed: ["uy:max-h-(--uy-table-max-rows)"]
|
|
25
20
|
}
|
|
26
|
-
|
|
21
|
+
},
|
|
22
|
+
defaultVariants: {
|
|
23
|
+
height: "fixed"
|
|
24
|
+
}
|
|
25
|
+
}), j = z(
|
|
26
|
+
({ minRows: f = 10, maxRows: s, children: o }, l) => {
|
|
27
|
+
const b = P({ height: s !== void 0 ? "fixed" : "fillSpace" });
|
|
28
|
+
return /* @__PURE__ */ p(
|
|
29
|
+
"div",
|
|
30
|
+
{
|
|
31
|
+
ref: l,
|
|
32
|
+
className: b,
|
|
33
|
+
"data-unity-slot": "table-root",
|
|
34
|
+
style: {
|
|
35
|
+
"--uy-table-min-rows": `calc(var(--uy-spacing-600) * ${f})`,
|
|
36
|
+
"--uy-table-max-rows": `calc(var(--uy-spacing-600) * ${s})`
|
|
37
|
+
},
|
|
38
|
+
children: o
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
}
|
|
27
42
|
);
|
|
28
43
|
j.displayName = "TableRoot";
|
|
29
|
-
const A =
|
|
44
|
+
const A = S({
|
|
30
45
|
slots: {
|
|
31
46
|
wrapper: [
|
|
32
47
|
"uy:flex-1 uy:bg-surface-neutral",
|
|
@@ -64,36 +79,36 @@ const A = N({
|
|
|
64
79
|
horizontalScroll: !0,
|
|
65
80
|
layout: "auto"
|
|
66
81
|
}
|
|
67
|
-
}), _ = z((
|
|
82
|
+
}), _ = z((f, s) => {
|
|
68
83
|
const {
|
|
69
84
|
children: o,
|
|
70
85
|
label: l,
|
|
71
|
-
description:
|
|
72
|
-
isHorizontalScrollEnabled:
|
|
73
|
-
enableVirtualization:
|
|
74
|
-
estimatedRowHeight:
|
|
75
|
-
overscan:
|
|
86
|
+
description: u,
|
|
87
|
+
isHorizontalScrollEnabled: b = !0,
|
|
88
|
+
enableVirtualization: c = !1,
|
|
89
|
+
estimatedRowHeight: v = 40,
|
|
90
|
+
overscan: w = 5,
|
|
76
91
|
layout: x = "auto",
|
|
77
92
|
...T
|
|
78
|
-
} =
|
|
93
|
+
} = f, h = V(null), { rowCount: m, columnCount: g } = H(() => {
|
|
79
94
|
let t = 0, r = 0;
|
|
80
95
|
return i.Children.forEach(o, (e) => {
|
|
81
96
|
if (!i.isValidElement(e)) return;
|
|
82
|
-
const
|
|
97
|
+
const y = i.Children.toArray(
|
|
83
98
|
e.props.children
|
|
84
|
-
).filter((
|
|
85
|
-
r +=
|
|
86
|
-
if (!i.isValidElement(
|
|
99
|
+
).filter((d) => i.isValidElement(d));
|
|
100
|
+
r += y.length, y.forEach((d) => {
|
|
101
|
+
if (!i.isValidElement(d)) return;
|
|
87
102
|
const n = i.Children.toArray(
|
|
88
|
-
|
|
103
|
+
d.props.children
|
|
89
104
|
).filter((C) => i.isValidElement(C));
|
|
90
105
|
t = Math.max(t, n.length);
|
|
91
106
|
});
|
|
92
107
|
}), { rowCount: r, columnCount: t };
|
|
93
108
|
}, [o]);
|
|
94
|
-
k(
|
|
109
|
+
k(s, () => ({
|
|
95
110
|
scrollToTop: () => {
|
|
96
|
-
const t =
|
|
111
|
+
const t = h.current, r = t?.closest(
|
|
97
112
|
'[data-unity-slot="table-root"]'
|
|
98
113
|
);
|
|
99
114
|
let e;
|
|
@@ -106,28 +121,28 @@ const A = N({
|
|
|
106
121
|
}
|
|
107
122
|
}
|
|
108
123
|
}));
|
|
109
|
-
const a =
|
|
110
|
-
count:
|
|
111
|
-
getScrollElement: () =>
|
|
112
|
-
estimateSize: () =>
|
|
113
|
-
overscan:
|
|
124
|
+
const a = M({
|
|
125
|
+
count: c ? m : 0,
|
|
126
|
+
getScrollElement: () => h.current,
|
|
127
|
+
estimateSize: () => v,
|
|
128
|
+
overscan: w
|
|
114
129
|
});
|
|
115
|
-
return /* @__PURE__ */
|
|
116
|
-
|
|
130
|
+
return /* @__PURE__ */ p(
|
|
131
|
+
U,
|
|
117
132
|
{
|
|
118
133
|
rowCount: m,
|
|
119
|
-
columnCount:
|
|
134
|
+
columnCount: g,
|
|
120
135
|
virtualizer: a,
|
|
121
|
-
enableVirtualization:
|
|
122
|
-
children: /* @__PURE__ */
|
|
123
|
-
|
|
136
|
+
enableVirtualization: c,
|
|
137
|
+
children: /* @__PURE__ */ p(
|
|
138
|
+
N,
|
|
124
139
|
{
|
|
125
|
-
scrollContainerRef:
|
|
140
|
+
scrollContainerRef: h,
|
|
126
141
|
rowCount: m,
|
|
127
|
-
columnCount:
|
|
142
|
+
columnCount: g,
|
|
128
143
|
label: l,
|
|
129
|
-
description:
|
|
130
|
-
isHorizontalScrollEnabled:
|
|
144
|
+
description: u,
|
|
145
|
+
isHorizontalScrollEnabled: b,
|
|
131
146
|
layout: x,
|
|
132
147
|
...T,
|
|
133
148
|
children: o
|
|
@@ -137,43 +152,43 @@ const A = N({
|
|
|
137
152
|
);
|
|
138
153
|
});
|
|
139
154
|
_.displayName = "Table";
|
|
140
|
-
const
|
|
155
|
+
const N = (f) => {
|
|
141
156
|
const {
|
|
142
|
-
children:
|
|
157
|
+
children: s,
|
|
143
158
|
label: o,
|
|
144
159
|
description: l,
|
|
145
|
-
scrollContainerRef:
|
|
146
|
-
layout:
|
|
147
|
-
rowCount:
|
|
148
|
-
columnCount:
|
|
149
|
-
onKeyDown:
|
|
160
|
+
scrollContainerRef: u,
|
|
161
|
+
layout: b,
|
|
162
|
+
rowCount: c,
|
|
163
|
+
columnCount: v,
|
|
164
|
+
onKeyDown: w,
|
|
150
165
|
isHorizontalScrollEnabled: x = !0,
|
|
151
166
|
...T
|
|
152
|
-
} =
|
|
167
|
+
} = f, { wrapper: h, table: m } = A({
|
|
153
168
|
horizontalScroll: x,
|
|
154
|
-
layout:
|
|
155
|
-
}), { keyboardNavigation:
|
|
156
|
-
ref:
|
|
169
|
+
layout: b
|
|
170
|
+
}), { keyboardNavigation: g } = $(), { tableRef: a, handleTableKeyDown: t } = g, { height: r = 0 } = K({
|
|
171
|
+
ref: u,
|
|
157
172
|
box: "border-box"
|
|
158
173
|
}), e = D(
|
|
159
174
|
(n) => {
|
|
160
|
-
n.key !== "Tab" && (t(n),
|
|
175
|
+
n.key !== "Tab" && (t(n), w?.(n));
|
|
161
176
|
},
|
|
162
|
-
[t,
|
|
163
|
-
),
|
|
177
|
+
[t, w]
|
|
178
|
+
), y = u.current?.closest(
|
|
164
179
|
'[data-unity-slot="table-root"]'
|
|
165
|
-
),
|
|
166
|
-
if (!
|
|
167
|
-
const n =
|
|
180
|
+
), d = H(() => {
|
|
181
|
+
if (!y || c === 0) return !1;
|
|
182
|
+
const n = y.clientHeight;
|
|
168
183
|
return (a.current?.clientHeight ?? 0) / n < 0.9;
|
|
169
|
-
}, [
|
|
184
|
+
}, [y, c, a, r]);
|
|
170
185
|
return /* @__PURE__ */ R(
|
|
171
186
|
"div",
|
|
172
187
|
{
|
|
173
|
-
className: E(
|
|
174
|
-
ref:
|
|
188
|
+
className: E(h()),
|
|
189
|
+
ref: u,
|
|
175
190
|
style: {
|
|
176
|
-
"--uy-table-has-remaining-space":
|
|
191
|
+
"--uy-table-has-remaining-space": d ? "1" : "0"
|
|
177
192
|
},
|
|
178
193
|
children: [
|
|
179
194
|
/* @__PURE__ */ R(
|
|
@@ -182,15 +197,15 @@ const S = (y) => {
|
|
|
182
197
|
ref: a,
|
|
183
198
|
className: E(m()),
|
|
184
199
|
role: "grid",
|
|
185
|
-
"aria-rowcount":
|
|
186
|
-
"aria-colcount":
|
|
200
|
+
"aria-rowcount": c,
|
|
201
|
+
"aria-colcount": v,
|
|
187
202
|
"aria-label": o,
|
|
188
203
|
"aria-describedby": l ? `table-desc-${a.current?.id}` : void 0,
|
|
189
204
|
onKeyDown: e,
|
|
190
205
|
...T,
|
|
191
206
|
children: [
|
|
192
|
-
|
|
193
|
-
l && /* @__PURE__ */
|
|
207
|
+
s,
|
|
208
|
+
l && /* @__PURE__ */ p(
|
|
194
209
|
"caption",
|
|
195
210
|
{
|
|
196
211
|
id: `table-desc-${a.current?.id}`,
|
|
@@ -201,12 +216,12 @@ const S = (y) => {
|
|
|
201
216
|
]
|
|
202
217
|
}
|
|
203
218
|
),
|
|
204
|
-
/* @__PURE__ */
|
|
219
|
+
/* @__PURE__ */ p("div", { className: "uy:sr-only", "aria-live": "polite", children: "Table navigation: Use arrow keys to move between cells. Tab key exits the table. Home and End keys navigate to the first and last cell in a row. Page Up and Page Down move between rows." })
|
|
205
220
|
]
|
|
206
221
|
}
|
|
207
222
|
);
|
|
208
223
|
};
|
|
209
|
-
|
|
224
|
+
N.displayName = "TableContent";
|
|
210
225
|
export {
|
|
211
226
|
_ as Table,
|
|
212
227
|
j as TableRoot
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payfit/unity-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.15.0",
|
|
4
4
|
"module": "./dist/esm/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@hookform/devtools": "4.4.0",
|
|
43
43
|
"@hookform/resolvers": "5.2.1",
|
|
44
44
|
"@internationalized/date": "3.12.0",
|
|
45
|
-
"@payfit/unity-illustrations": "2.
|
|
45
|
+
"@payfit/unity-illustrations": "2.15.0",
|
|
46
46
|
"@radix-ui/react-avatar": "1.1.11",
|
|
47
47
|
"@radix-ui/react-slot": "1.2.4",
|
|
48
48
|
"@react-aria/interactions": "3.27.1",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
76
|
"@hookform/devtools": "^4",
|
|
77
|
-
"@payfit/unity-icons": "2.
|
|
78
|
-
"@payfit/unity-themes": "2.
|
|
77
|
+
"@payfit/unity-icons": "2.15.0",
|
|
78
|
+
"@payfit/unity-themes": "2.15.0",
|
|
79
79
|
"@storybook/react-vite": "^10.2.2",
|
|
80
80
|
"@tanstack/react-query": "^5",
|
|
81
81
|
"@tanstack/react-router": "^1.131",
|
|
@@ -95,9 +95,9 @@
|
|
|
95
95
|
"@payfit/hr-apps-tsconfigs": "0.0.0-use.local",
|
|
96
96
|
"@payfit/storybook-addon-console-errors": "0.0.0-use.local",
|
|
97
97
|
"@payfit/storybook-config": "0.0.0-use.local",
|
|
98
|
-
"@payfit/unity-icons": "2.
|
|
99
|
-
"@payfit/unity-illustrations": "2.
|
|
100
|
-
"@payfit/unity-themes": "2.
|
|
98
|
+
"@payfit/unity-icons": "2.15.0",
|
|
99
|
+
"@payfit/unity-illustrations": "2.15.0",
|
|
100
|
+
"@payfit/unity-themes": "2.15.0",
|
|
101
101
|
"@payfit/vite-configs": "0.0.0-use.local",
|
|
102
102
|
"@storybook/addon-a11y": "10.2.15",
|
|
103
103
|
"@storybook/addon-designs": "11.1.1",
|