@payfit/unity-components 2.12.7 → 2.12.9
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,5 +1,5 @@
|
|
|
1
|
-
import { CalendarDate } from '@internationalized/date';
|
|
2
1
|
import { PlayCtx } from '../../types/testing.js';
|
|
2
|
+
import { CalendarDate } from '@internationalized/date';
|
|
3
3
|
/**
|
|
4
4
|
* Factory to get date picker testing utils
|
|
5
5
|
* @param context the story context
|
|
@@ -9,4 +9,7 @@ export declare const getTestingUtilsDatePicker: (context: PlayCtx) => {
|
|
|
9
9
|
labelText: string;
|
|
10
10
|
calendarDate: CalendarDate;
|
|
11
11
|
}) => Promise<void>;
|
|
12
|
+
getCalendarDateValue: ({ labelText }: {
|
|
13
|
+
labelText: string;
|
|
14
|
+
}) => CalendarDate;
|
|
12
15
|
};
|
|
@@ -1,35 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { CalendarDate as o } from "@internationalized/date";
|
|
2
|
+
import { userEvent as r, within as l } from "storybook/test";
|
|
3
|
+
const c = (i) => {
|
|
4
|
+
const d = (e) => {
|
|
5
|
+
const t = l(i.canvasElement).getAllByLabelText(
|
|
6
|
+
e,
|
|
7
|
+
{
|
|
8
|
+
exact: !1,
|
|
9
|
+
selector: "span"
|
|
10
|
+
}
|
|
11
|
+
);
|
|
12
|
+
if (t.length !== 3)
|
|
13
|
+
throw new Error(`Date field for ${e} not found`);
|
|
14
|
+
return t;
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
fillCalendarDate: async ({
|
|
18
|
+
labelText: e,
|
|
19
|
+
calendarDate: t
|
|
20
|
+
}) => {
|
|
21
|
+
await i.step(`Fill date picker ${e}`, async () => {
|
|
22
|
+
const a = d(e);
|
|
23
|
+
await r.type(
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
25
|
+
a.find((n) => n.getAttribute("data-type") === "day"),
|
|
26
|
+
String(t.day)
|
|
27
|
+
), await r.type(
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
29
|
+
a.find((n) => n.getAttribute("data-type") === "month"),
|
|
30
|
+
String(t.month)
|
|
31
|
+
), await r.type(
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
33
|
+
a.find((n) => n.getAttribute("data-type") === "year"),
|
|
34
|
+
String(t.year)
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
getCalendarDateValue: ({ labelText: e }) => {
|
|
39
|
+
const t = d(e), a = (n) => parseInt(
|
|
40
|
+
t.find((s) => s.getAttribute("data-type") === n)?.textContent ?? ""
|
|
14
41
|
);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
e.find((t) => t.getAttribute("data-type") === "day"),
|
|
20
|
-
String(i.day)
|
|
21
|
-
), await n.type(
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
23
|
-
e.find((t) => t.getAttribute("data-type") === "month"),
|
|
24
|
-
String(i.month)
|
|
25
|
-
), await n.type(
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
27
|
-
e.find((t) => t.getAttribute("data-type") === "year"),
|
|
28
|
-
String(i.year)
|
|
42
|
+
return new o(
|
|
43
|
+
a("year"),
|
|
44
|
+
a("month"),
|
|
45
|
+
a("day")
|
|
29
46
|
);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
};
|
|
33
50
|
export {
|
|
34
|
-
|
|
51
|
+
c as getTestingUtilsDatePicker
|
|
35
52
|
};
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { uyTv as N, uyMerge as
|
|
4
|
-
import { useVirtualizer as
|
|
5
|
-
import { useResizeObserver as
|
|
6
|
-
import { TableContextProvider as
|
|
7
|
-
const
|
|
1
|
+
import { jsx as h, jsxs as R } from "react/jsx-runtime";
|
|
2
|
+
import i, { forwardRef as z, useRef as V, useMemo as H, useImperativeHandle as k, useCallback as D } from "react";
|
|
3
|
+
import { uyTv as N, uyMerge as E } from "@payfit/unity-themes";
|
|
4
|
+
import { useVirtualizer as K } from "@tanstack/react-virtual";
|
|
5
|
+
import { useResizeObserver as U } from "usehooks-ts";
|
|
6
|
+
import { TableContextProvider as $, useTableContext as M } from "./Table.context.js";
|
|
7
|
+
const P = N({
|
|
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
11
|
"uy:min-h-(--uy-table-min-rows) uy:max-h-(--uy-table-max-rows)"
|
|
12
12
|
]
|
|
13
|
-
}),
|
|
14
|
-
({ minRows:
|
|
13
|
+
}), j = z(
|
|
14
|
+
({ minRows: y = 10, maxRows: d = 50, children: o }, l) => /* @__PURE__ */ h(
|
|
15
15
|
"div",
|
|
16
16
|
{
|
|
17
|
-
ref:
|
|
18
|
-
className:
|
|
17
|
+
ref: l,
|
|
18
|
+
className: P(),
|
|
19
19
|
"data-unity-slot": "table-root",
|
|
20
20
|
style: {
|
|
21
|
-
"--uy-table-min-rows": `calc(var(--uy-spacing-600) * ${
|
|
22
|
-
"--uy-table-max-rows": `calc(var(--uy-spacing-600) * ${
|
|
21
|
+
"--uy-table-min-rows": `calc(var(--uy-spacing-600) * ${y})`,
|
|
22
|
+
"--uy-table-max-rows": `calc(var(--uy-spacing-600) * ${d})`
|
|
23
23
|
},
|
|
24
|
-
children:
|
|
24
|
+
children: o
|
|
25
25
|
}
|
|
26
26
|
)
|
|
27
27
|
);
|
|
28
|
-
|
|
29
|
-
const
|
|
28
|
+
j.displayName = "TableRoot";
|
|
29
|
+
const A = N({
|
|
30
30
|
slots: {
|
|
31
31
|
wrapper: [
|
|
32
32
|
"uy:flex-1 uy:bg-surface-neutral",
|
|
@@ -64,43 +64,40 @@ const _ = N({
|
|
|
64
64
|
horizontalScroll: !0,
|
|
65
65
|
layout: "auto"
|
|
66
66
|
}
|
|
67
|
-
}),
|
|
67
|
+
}), _ = z((y, d) => {
|
|
68
68
|
const {
|
|
69
|
-
children:
|
|
70
|
-
label:
|
|
71
|
-
description:
|
|
72
|
-
isHorizontalScrollEnabled:
|
|
73
|
-
enableVirtualization:
|
|
74
|
-
estimatedRowHeight:
|
|
69
|
+
children: o,
|
|
70
|
+
label: l,
|
|
71
|
+
description: b,
|
|
72
|
+
isHorizontalScrollEnabled: v = !0,
|
|
73
|
+
enableVirtualization: s = !1,
|
|
74
|
+
estimatedRowHeight: g = 40,
|
|
75
75
|
overscan: p = 5,
|
|
76
|
-
layout:
|
|
77
|
-
...
|
|
78
|
-
} =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return s.Children.forEach(r, (e) => {
|
|
84
|
-
if (!s.isValidElement(e)) return;
|
|
85
|
-
const a = s.Children.toArray(
|
|
76
|
+
layout: x = "auto",
|
|
77
|
+
...T
|
|
78
|
+
} = y, f = V(null), { rowCount: m, columnCount: w } = H(() => {
|
|
79
|
+
let t = 0, r = 0;
|
|
80
|
+
return i.Children.forEach(o, (e) => {
|
|
81
|
+
if (!i.isValidElement(e)) return;
|
|
82
|
+
const u = i.Children.toArray(
|
|
86
83
|
e.props.children
|
|
87
|
-
).filter((
|
|
88
|
-
|
|
89
|
-
if (!
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
).filter((
|
|
93
|
-
t = Math.max(t,
|
|
84
|
+
).filter((c) => i.isValidElement(c));
|
|
85
|
+
r += u.length, u.forEach((c) => {
|
|
86
|
+
if (!i.isValidElement(c)) return;
|
|
87
|
+
const n = i.Children.toArray(
|
|
88
|
+
c.props.children
|
|
89
|
+
).filter((C) => i.isValidElement(C));
|
|
90
|
+
t = Math.max(t, n.length);
|
|
94
91
|
});
|
|
95
|
-
}), { rowCount:
|
|
96
|
-
}, [
|
|
97
|
-
|
|
92
|
+
}), { rowCount: r, columnCount: t };
|
|
93
|
+
}, [o]);
|
|
94
|
+
k(d, () => ({
|
|
98
95
|
scrollToTop: () => {
|
|
99
|
-
const t =
|
|
96
|
+
const t = f.current, r = t?.closest(
|
|
100
97
|
'[data-unity-slot="table-root"]'
|
|
101
98
|
);
|
|
102
99
|
let e;
|
|
103
|
-
if (
|
|
100
|
+
if (r ? e = r : t && (e = t), !!e) {
|
|
104
101
|
if (typeof e.scrollTo == "function") {
|
|
105
102
|
e.scrollTo({ top: 0, behavior: "smooth" });
|
|
106
103
|
return;
|
|
@@ -109,106 +106,108 @@ const _ = N({
|
|
|
109
106
|
}
|
|
110
107
|
}
|
|
111
108
|
}));
|
|
112
|
-
const
|
|
113
|
-
count:
|
|
114
|
-
getScrollElement: () =>
|
|
115
|
-
estimateSize: () =>
|
|
109
|
+
const a = K({
|
|
110
|
+
count: s ? m : 0,
|
|
111
|
+
getScrollElement: () => f.current,
|
|
112
|
+
estimateSize: () => g,
|
|
116
113
|
overscan: p
|
|
117
114
|
});
|
|
118
|
-
return /* @__PURE__ */
|
|
119
|
-
|
|
115
|
+
return /* @__PURE__ */ h(
|
|
116
|
+
$,
|
|
120
117
|
{
|
|
121
|
-
rowCount:
|
|
122
|
-
columnCount:
|
|
123
|
-
virtualizer:
|
|
124
|
-
enableVirtualization:
|
|
125
|
-
children: /* @__PURE__ */
|
|
118
|
+
rowCount: m,
|
|
119
|
+
columnCount: w,
|
|
120
|
+
virtualizer: a,
|
|
121
|
+
enableVirtualization: s,
|
|
122
|
+
children: /* @__PURE__ */ h(
|
|
126
123
|
S,
|
|
127
124
|
{
|
|
128
|
-
scrollContainerRef:
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
children: r
|
|
125
|
+
scrollContainerRef: f,
|
|
126
|
+
rowCount: m,
|
|
127
|
+
columnCount: w,
|
|
128
|
+
label: l,
|
|
129
|
+
description: b,
|
|
130
|
+
isHorizontalScrollEnabled: v,
|
|
131
|
+
layout: x,
|
|
132
|
+
...T,
|
|
133
|
+
children: o
|
|
138
134
|
}
|
|
139
135
|
)
|
|
140
136
|
}
|
|
141
137
|
);
|
|
142
138
|
});
|
|
143
|
-
|
|
144
|
-
const S = (
|
|
139
|
+
_.displayName = "Table";
|
|
140
|
+
const S = (y) => {
|
|
145
141
|
const {
|
|
146
|
-
children:
|
|
147
|
-
label:
|
|
148
|
-
description:
|
|
149
|
-
scrollContainerRef:
|
|
150
|
-
layout:
|
|
151
|
-
rowCount:
|
|
152
|
-
columnCount:
|
|
142
|
+
children: d,
|
|
143
|
+
label: o,
|
|
144
|
+
description: l,
|
|
145
|
+
scrollContainerRef: b,
|
|
146
|
+
layout: v,
|
|
147
|
+
rowCount: s,
|
|
148
|
+
columnCount: g,
|
|
153
149
|
onKeyDown: p,
|
|
154
|
-
isHorizontalScrollEnabled:
|
|
155
|
-
...
|
|
156
|
-
} =
|
|
157
|
-
horizontalScroll:
|
|
158
|
-
layout:
|
|
159
|
-
}), { keyboardNavigation:
|
|
160
|
-
|
|
161
|
-
|
|
150
|
+
isHorizontalScrollEnabled: x = !0,
|
|
151
|
+
...T
|
|
152
|
+
} = y, { wrapper: f, table: m } = A({
|
|
153
|
+
horizontalScroll: x,
|
|
154
|
+
layout: v
|
|
155
|
+
}), { keyboardNavigation: w } = M(), { tableRef: a, handleTableKeyDown: t } = w, { height: r = 0 } = U({
|
|
156
|
+
ref: b,
|
|
157
|
+
box: "border-box"
|
|
158
|
+
}), e = D(
|
|
159
|
+
(n) => {
|
|
160
|
+
n.key !== "Tab" && (t(n), p?.(n));
|
|
162
161
|
},
|
|
163
|
-
[
|
|
164
|
-
),
|
|
162
|
+
[t, p]
|
|
163
|
+
), u = b.current?.closest(
|
|
165
164
|
'[data-unity-slot="table-root"]'
|
|
166
|
-
),
|
|
167
|
-
if (!
|
|
168
|
-
const
|
|
169
|
-
return (
|
|
170
|
-
}, [
|
|
165
|
+
), c = H(() => {
|
|
166
|
+
if (!u || s === 0) return !1;
|
|
167
|
+
const n = u.clientHeight;
|
|
168
|
+
return (a.current?.clientHeight ?? 0) / n < 0.9;
|
|
169
|
+
}, [u, s, a, r]);
|
|
171
170
|
return /* @__PURE__ */ R(
|
|
172
171
|
"div",
|
|
173
172
|
{
|
|
174
|
-
className:
|
|
175
|
-
ref:
|
|
173
|
+
className: E(f()),
|
|
174
|
+
ref: b,
|
|
176
175
|
style: {
|
|
177
|
-
"--uy-table-has-remaining-space":
|
|
176
|
+
"--uy-table-has-remaining-space": c ? "1" : "0"
|
|
178
177
|
},
|
|
179
178
|
children: [
|
|
180
179
|
/* @__PURE__ */ R(
|
|
181
180
|
"table",
|
|
182
181
|
{
|
|
183
|
-
ref:
|
|
184
|
-
className:
|
|
182
|
+
ref: a,
|
|
183
|
+
className: E(m()),
|
|
185
184
|
role: "grid",
|
|
186
|
-
"aria-rowcount":
|
|
187
|
-
"aria-colcount":
|
|
188
|
-
"aria-label":
|
|
189
|
-
"aria-describedby":
|
|
190
|
-
onKeyDown:
|
|
191
|
-
...
|
|
185
|
+
"aria-rowcount": s,
|
|
186
|
+
"aria-colcount": g,
|
|
187
|
+
"aria-label": o,
|
|
188
|
+
"aria-describedby": l ? `table-desc-${a.current?.id}` : void 0,
|
|
189
|
+
onKeyDown: e,
|
|
190
|
+
...T,
|
|
192
191
|
children: [
|
|
193
|
-
|
|
194
|
-
|
|
192
|
+
d,
|
|
193
|
+
l && /* @__PURE__ */ h(
|
|
195
194
|
"caption",
|
|
196
195
|
{
|
|
197
|
-
id: `table-desc-${
|
|
196
|
+
id: `table-desc-${a.current?.id}`,
|
|
198
197
|
className: "uy:sr-only",
|
|
199
|
-
children:
|
|
198
|
+
children: l
|
|
200
199
|
}
|
|
201
200
|
)
|
|
202
201
|
]
|
|
203
202
|
}
|
|
204
203
|
),
|
|
205
|
-
/* @__PURE__ */
|
|
204
|
+
/* @__PURE__ */ h("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." })
|
|
206
205
|
]
|
|
207
206
|
}
|
|
208
207
|
);
|
|
209
208
|
};
|
|
210
209
|
S.displayName = "TableContent";
|
|
211
210
|
export {
|
|
212
|
-
|
|
213
|
-
|
|
211
|
+
_ as Table,
|
|
212
|
+
j as TableRoot
|
|
214
213
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payfit/unity-components",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.9",
|
|
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.11.0",
|
|
45
|
-
"@payfit/unity-illustrations": "2.12.
|
|
45
|
+
"@payfit/unity-illustrations": "2.12.9",
|
|
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.0",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
76
|
"@hookform/devtools": "^4",
|
|
77
|
-
"@payfit/unity-icons": "2.12.
|
|
78
|
-
"@payfit/unity-themes": "2.12.
|
|
77
|
+
"@payfit/unity-icons": "2.12.9",
|
|
78
|
+
"@payfit/unity-themes": "2.12.9",
|
|
79
79
|
"@storybook/react-vite": "^10.2.2",
|
|
80
80
|
"@tanstack/react-query": "^5",
|
|
81
81
|
"@tanstack/react-router": "^1.131",
|
|
@@ -94,9 +94,9 @@
|
|
|
94
94
|
"@payfit/hr-apps-tsconfigs": "0.0.0-use.local",
|
|
95
95
|
"@payfit/storybook-addon-console-errors": "0.0.0-use.local",
|
|
96
96
|
"@payfit/storybook-config": "0.0.0-use.local",
|
|
97
|
-
"@payfit/unity-icons": "2.12.
|
|
98
|
-
"@payfit/unity-illustrations": "2.12.
|
|
99
|
-
"@payfit/unity-themes": "2.12.
|
|
97
|
+
"@payfit/unity-icons": "2.12.9",
|
|
98
|
+
"@payfit/unity-illustrations": "2.12.9",
|
|
99
|
+
"@payfit/unity-themes": "2.12.9",
|
|
100
100
|
"@payfit/vite-configs": "0.0.0-use.local",
|
|
101
101
|
"@storybook/addon-a11y": "10.2.13",
|
|
102
102
|
"@storybook/addon-docs": "10.2.13",
|