@payfit/unity-components 1.2.0 → 2.0.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.
- package/dist/esm/components/action-bar/ActionBar.js +14 -14
- package/dist/esm/components/actionable/Actionable.js +31 -28
- package/dist/esm/components/app-layout/AppLayout.js +17 -17
- package/dist/esm/components/app-menu/parts/AppMenuHeader.d.ts +86 -4
- package/dist/esm/components/app-menu/parts/AppMenuHeader.js +25 -25
- package/dist/esm/components/breadcrumbs/Breadcrumbs.context.js +3 -3
- package/dist/esm/components/breadcrumbs/Breadcrumbs.d.ts +19 -11
- package/dist/esm/components/breadcrumbs/Breadcrumbs.js +29 -18
- package/dist/esm/components/breadcrumbs/parts/Breadcrumb.d.ts +30 -5
- package/dist/esm/components/breadcrumbs/parts/Breadcrumb.js +35 -27
- package/dist/esm/components/breadcrumbs/parts/RawBreadcrumbLink.d.ts +37 -0
- package/dist/esm/components/breadcrumbs/parts/RawBreadcrumbLink.js +36 -0
- package/dist/esm/components/client-side-pagination/ClientSidePagination.d.ts +103 -0
- package/dist/esm/components/client-side-pagination/ClientSidePagination.js +177 -0
- package/dist/esm/components/client-side-pagination/parts/PaginationEllipsis.d.ts +11 -0
- package/dist/esm/components/client-side-pagination/parts/PaginationEllipsis.js +30 -0
- package/dist/esm/components/client-side-pagination/parts/PaginationJumpDialog.d.ts +8 -0
- package/dist/esm/components/{pagination/parts/PaginationLink.d.ts → client-side-pagination/parts/RawPaginationLink.d.ts} +2 -2
- package/dist/esm/components/{pagination/parts/PaginationLink.js → client-side-pagination/parts/RawPaginationLink.js} +2 -2
- package/dist/esm/components/client-side-pagination/utils/pagination-window.d.ts +8 -0
- package/dist/esm/components/client-side-pagination/utils/pagination-window.js +33 -0
- package/dist/esm/components/error-state/ErrorState.d.ts +13 -1
- package/dist/esm/components/error-state/ErrorState.js +133 -92
- package/dist/esm/components/error-state/initConfig.js +1 -1
- package/dist/esm/components/fieldset/Fieldset.d.ts +19 -0
- package/dist/esm/components/fieldset/Fieldset.js +32 -26
- package/dist/esm/components/flex/Flex.js +52 -37
- package/dist/esm/components/form-field/FormField.js +12 -12
- package/dist/esm/components/form-field/parts/{FormContextualLink.d.ts → RawFormContextualLink.d.ts} +2 -2
- package/dist/esm/components/form-field/parts/RawFormContextualLink.js +39 -0
- package/dist/esm/components/funnel-layout/parts/FunnelSidebar.d.ts +2 -2
- package/dist/esm/components/icon/Icon.js +23 -19
- package/dist/esm/components/link/{Link.variants.d.ts → RawLink.d.ts} +92 -0
- package/dist/esm/components/link/{Link.variants.js → RawLink.js} +70 -4
- package/dist/esm/components/menu/parts/{MenuItem.d.ts → RawMenuItem.d.ts} +3 -4
- package/dist/esm/components/menu/parts/{MenuItem.js → RawMenuItem.js} +9 -9
- package/dist/esm/components/nav/parts/NavGroup.d.ts +3 -3
- package/dist/esm/components/nav/parts/NavGroup.js +62 -51
- package/dist/esm/components/nav/parts/{NavItem.d.ts → RawNavItem.d.ts} +102 -5
- package/dist/esm/components/nav/parts/RawNavItem.js +106 -0
- package/dist/esm/components/page/Page.js +1 -1
- package/dist/esm/components/page/parts/PageHeader.d.ts +79 -9
- package/dist/esm/components/page/parts/PageHeader.js +22 -20
- package/dist/esm/components/pagination/Pagination.d.ts +23 -44
- package/dist/esm/components/pagination/Pagination.js +89 -163
- package/dist/esm/components/pagination/PaginationContext.d.ts +11 -0
- package/dist/esm/components/pagination/PaginationContext.js +15 -0
- package/dist/esm/components/pagination/hooks/use-pagination-state.d.ts +63 -0
- package/dist/esm/components/pagination/hooks/use-pagination-state.js +27 -0
- package/dist/esm/components/pagination/hooks/use-pagination-window.d.ts +64 -0
- package/dist/esm/components/pagination/hooks/use-pagination-window.js +15 -0
- package/dist/esm/components/pagination/parts/PaginationContent.d.ts +30 -0
- package/dist/esm/components/pagination/parts/PaginationContent.js +37 -0
- package/dist/esm/components/pagination/parts/PaginationEllipsis.d.ts +23 -4
- package/dist/esm/components/pagination/parts/PaginationEllipsis.js +20 -16
- package/dist/esm/components/pagination/parts/PaginationItem.d.ts +38 -0
- package/dist/esm/components/pagination/parts/PaginationItem.js +22 -0
- package/dist/esm/components/pagination/parts/RawPaginationLink.d.ts +11 -0
- package/dist/esm/components/pagination/parts/RawPaginationLink.js +60 -0
- package/dist/esm/components/pagination/parts/RawPaginationNext.d.ts +22 -0
- package/dist/esm/components/pagination/parts/RawPaginationNext.js +70 -0
- package/dist/esm/components/pagination/parts/RawPaginationPrevious.d.ts +22 -0
- package/dist/esm/components/pagination/parts/RawPaginationPrevious.js +67 -0
- package/dist/esm/components/pagination/utils/pagination-window.js +29 -20
- package/dist/esm/components/select/Select.js +63 -45
- package/dist/esm/components/select/parts/SelectOption.js +9 -9
- package/dist/esm/components/skip-links/SkipLinks.js +1 -1
- package/dist/esm/components/table/Table.d.ts +1 -0
- package/dist/esm/components/table/Table.js +82 -73
- package/dist/esm/components/table/hooks/useTableKeyboardNavigation.js +6 -6
- package/dist/esm/components/table/parts/TableCell.js +29 -26
- package/dist/esm/components/table/parts/TablePagination.d.ts +5 -5
- package/dist/esm/components/table/parts/TablePagination.js +10 -10
- package/dist/esm/components/table/parts/TableRow.js +21 -18
- package/dist/esm/components/tabs/parts/{Tab.d.ts → RawTab.d.ts} +2 -2
- package/dist/esm/components/tabs/parts/{Tab.js → RawTab.js} +6 -6
- package/dist/esm/components/task-menu/TaskMenu.d.ts +4 -4
- package/dist/esm/components/task-menu/parts/{SubTask.d.ts → RawSubTask.d.ts} +7 -7
- package/dist/esm/components/task-menu/parts/{SubTask.js → RawSubTask.js} +19 -19
- package/dist/esm/components/task-menu/parts/{Task.d.ts → RawTask.d.ts} +7 -7
- package/dist/esm/components/task-menu/parts/{Task.js → RawTask.js} +17 -17
- package/dist/esm/components/task-menu/parts/TaskGroup.d.ts +5 -5
- package/dist/esm/components/text/Text.js +30 -27
- package/dist/esm/hooks/use-container-query-level.d.ts +42 -0
- package/dist/esm/hooks/use-container-query-level.js +33 -0
- package/dist/esm/index.d.ts +21 -11
- package/dist/esm/index.js +424 -399
- package/dist/esm/integrations/tanstack-router/components/breadcrumbs/Breadcrumb.d.ts +23 -0
- package/dist/esm/integrations/tanstack-router/components/breadcrumbs/BreadcrumbLink.d.ts +38 -0
- package/dist/esm/integrations/tanstack-router/components/breadcrumbs/BreadcrumbLink.js +7 -0
- package/dist/esm/integrations/tanstack-router/components/breadcrumbs/Breadcrumbs.d.ts +23 -0
- package/dist/esm/integrations/tanstack-router/components/breadcrumbs/use-route-breadcrumb.d.ts +53 -0
- package/dist/esm/integrations/tanstack-router/components/form-contextual-link/FormContextualLink.d.ts +40 -0
- package/dist/esm/integrations/tanstack-router/components/form-contextual-link/FormContextualLink.js +7 -0
- package/dist/esm/integrations/tanstack-router/components/link/Link.d.ts +33 -0
- package/dist/esm/integrations/tanstack-router/components/link/Link.js +7 -0
- package/dist/esm/integrations/tanstack-router/components/menu-item/MenuItem.d.ts +49 -0
- package/dist/esm/integrations/tanstack-router/components/menu-item/MenuItem.js +16 -0
- package/dist/esm/integrations/tanstack-router/components/nav-item/NavItem.d.ts +52 -0
- package/dist/esm/integrations/tanstack-router/components/nav-item/NavItem.js +29 -0
- package/dist/esm/integrations/tanstack-router/components/pagination/PaginationLink.d.ts +54 -0
- package/dist/esm/integrations/tanstack-router/components/pagination/PaginationLink.js +21 -0
- package/dist/esm/integrations/tanstack-router/components/pagination/PaginationNext.d.ts +52 -0
- package/dist/esm/integrations/tanstack-router/components/pagination/PaginationNext.js +22 -0
- package/dist/esm/integrations/tanstack-router/components/pagination/PaginationPrevious.d.ts +51 -0
- package/dist/esm/integrations/tanstack-router/components/pagination/PaginationPrevious.js +22 -0
- package/dist/esm/integrations/tanstack-router/components/tabs/Tabs.d.ts +82 -0
- package/dist/esm/integrations/tanstack-router/components/tabs/Tabs.js +41 -0
- package/dist/esm/integrations/tanstack-router/components/tabs/parts/Tab.d.ts +52 -0
- package/dist/esm/integrations/tanstack-router/components/tabs/parts/Tab.js +15 -0
- package/dist/esm/integrations/tanstack-router/components/tabs/parts/TabList.d.ts +5 -0
- package/dist/esm/integrations/tanstack-router/components/tabs/parts/TabPanel.d.ts +77 -0
- package/dist/esm/integrations/tanstack-router/components/tabs/parts/TabPanel.js +16 -0
- package/dist/esm/integrations/tanstack-router/components/task-menu/SubTask.d.ts +69 -0
- package/dist/esm/integrations/tanstack-router/components/task-menu/SubTask.js +14 -0
- package/dist/esm/integrations/tanstack-router/components/task-menu/Task.d.ts +64 -0
- package/dist/esm/integrations/tanstack-router/components/task-menu/Task.js +14 -0
- package/dist/esm/integrations/tanstack-router/index.d.ts +16 -0
- package/dist/esm/integrations/tanstack-router/utils/decorators.d.ts +23 -0
- package/dist/esm/integrations/tanstack-router.js +34 -0
- package/dist/esm/providers/router/RouterProvider.d.ts +7 -2
- package/dist/esm/providers/router/RouterProvider.js +14 -10
- package/dist/esm/types/DataAttributes.d.ts +1 -1
- package/i18n/en-GB.json +1 -0
- package/i18n/es-ES.json +1 -0
- package/i18n/fr-FR.json +1 -0
- package/package.json +47 -25
- package/dist/esm/components/form-field/parts/FormContextualLink.js +0 -37
- package/dist/esm/components/link/Link.d.ts +0 -93
- package/dist/esm/components/link/Link.js +0 -68
- package/dist/esm/components/nav/parts/NavItem.js +0 -95
- /package/dist/esm/components/{pagination → client-side-pagination}/hooks/use-pagination.d.ts +0 -0
- /package/dist/esm/components/{pagination → client-side-pagination}/hooks/use-pagination.js +0 -0
- /package/dist/esm/components/{pagination → client-side-pagination}/parts/PaginationJumpDialog.js +0 -0
- /package/dist/esm/components/{pagination → client-side-pagination}/parts/PaginationNavButton.d.ts +0 -0
- /package/dist/esm/components/{pagination → client-side-pagination}/parts/PaginationNavButton.js +0 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as m } from "react";
|
|
3
|
+
import { uyTv as g } from "@payfit/unity-themes";
|
|
4
|
+
import { Link as v } from "react-aria-components";
|
|
5
|
+
import { useIntl as b } from "react-intl";
|
|
6
|
+
import { Icon as h } from "../../icon/Icon.js";
|
|
7
|
+
import { Tooltip as w } from "../../tooltip/Tooltip.js";
|
|
8
|
+
import { usePaginationContext as x } from "../PaginationContext.js";
|
|
9
|
+
const P = g({
|
|
10
|
+
base: [
|
|
11
|
+
"uy:min-w-300 uy:h-300 uy:p-25 uy:flex uy:justify-center uy:items-center uy:typography-action uy:rounded-circle uy:transition-colors",
|
|
12
|
+
"uy:text-content-neutral-lowest uy:enabled:bg-transparent uy:cursor-pointer",
|
|
13
|
+
"uy:hover:text-content-neutral-hover uy:hover:bg-surface-neutral-hover",
|
|
14
|
+
"uy:active:text-content-neutral-pressed uy:active:bg-surface-neutral-pressed",
|
|
15
|
+
"uy:data-[pressed]:text-content-neutral-pressed uy:data-[pressed]:bg-surface-neutral-pressed",
|
|
16
|
+
"uy:data-[disabled]:text-content-neutral-disabled uy:data-[disabled]:bg-transparent uy:data-[disabled]:cursor-not-allowed",
|
|
17
|
+
"uy:focus-visible:outline-2 uy:focus-visible:outline-solid uy:focus-visible:outline-utility-focus-ring uy:focus-visible:outline-offset-2"
|
|
18
|
+
]
|
|
19
|
+
}), D = m(({ isDisabled: a, href: n, onPress: i, ...s }, u) => {
|
|
20
|
+
const r = b(), {
|
|
21
|
+
onKeyDown: l,
|
|
22
|
+
currentPage: e,
|
|
23
|
+
onPageChange: c
|
|
24
|
+
} = x(), t = r.formatMessage({
|
|
25
|
+
id: "unity:component:common:previous",
|
|
26
|
+
defaultMessage: "Previous"
|
|
27
|
+
}), y = r.formatMessage(
|
|
28
|
+
{
|
|
29
|
+
id: "unity:component:pagination:nav-button:description",
|
|
30
|
+
defaultMessage: "Go to previous page"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
variant: t
|
|
34
|
+
}
|
|
35
|
+
), d = (f) => {
|
|
36
|
+
l(f);
|
|
37
|
+
}, p = () => {
|
|
38
|
+
!n && e > 1 && c(e - 1, e, -1);
|
|
39
|
+
};
|
|
40
|
+
return /* @__PURE__ */ o(w, { title: t, children: /* @__PURE__ */ o(
|
|
41
|
+
v,
|
|
42
|
+
{
|
|
43
|
+
ref: u,
|
|
44
|
+
href: n,
|
|
45
|
+
className: P(),
|
|
46
|
+
isDisabled: a,
|
|
47
|
+
onPress: i ?? p,
|
|
48
|
+
"aria-label": t,
|
|
49
|
+
"aria-description": y,
|
|
50
|
+
onKeyDown: d,
|
|
51
|
+
...s,
|
|
52
|
+
children: /* @__PURE__ */ o(
|
|
53
|
+
h,
|
|
54
|
+
{
|
|
55
|
+
src: "CaretLeftOutlined",
|
|
56
|
+
size: 20,
|
|
57
|
+
color: "inherit",
|
|
58
|
+
role: "presentation"
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
) });
|
|
63
|
+
});
|
|
64
|
+
D.displayName = "RawPaginationPrevious";
|
|
65
|
+
export {
|
|
66
|
+
D as RawPaginationPrevious
|
|
67
|
+
};
|
|
@@ -1,33 +1,42 @@
|
|
|
1
|
-
function
|
|
2
|
-
return Array.from({ length:
|
|
3
|
-
(
|
|
1
|
+
function y(s, l) {
|
|
2
|
+
return Array.from({ length: l - s + 1 }, (p, t) => t + s).map(
|
|
3
|
+
(p) => ({
|
|
4
4
|
type: "page",
|
|
5
|
-
value:
|
|
5
|
+
value: p
|
|
6
6
|
})
|
|
7
7
|
);
|
|
8
8
|
}
|
|
9
9
|
const n = 5;
|
|
10
|
-
function
|
|
11
|
-
const
|
|
10
|
+
function d(s, l, p) {
|
|
11
|
+
const t = Math.max(
|
|
12
12
|
n,
|
|
13
|
-
|
|
14
|
-
),
|
|
15
|
-
if (
|
|
16
|
-
|
|
13
|
+
p % 2 === 0 ? p + 1 : p
|
|
14
|
+
), h = t - 2;
|
|
15
|
+
if (s === -1) {
|
|
16
|
+
const e = [];
|
|
17
|
+
e.push({ type: "page", value: 1 });
|
|
18
|
+
const o = h - 1, u = Math.floor(o / 2);
|
|
19
|
+
return l <= 3 + u ? (e.push(...y(2, t - 1)), e.push({ type: "ellipsis", value: [t, 1 / 0] })) : (e.push({ type: "ellipsis", value: [2, l - u] }), e.push(...y(l - u + 1, l + u)), e.push({
|
|
20
|
+
type: "ellipsis",
|
|
21
|
+
value: [l + u + 1, 1 / 0]
|
|
22
|
+
})), e;
|
|
23
|
+
}
|
|
24
|
+
if (s <= t)
|
|
25
|
+
return Array.from({ length: s }, (e, o) => ({
|
|
17
26
|
type: "page",
|
|
18
|
-
value:
|
|
27
|
+
value: o + 1
|
|
19
28
|
}));
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
return
|
|
29
|
+
const i = [];
|
|
30
|
+
i.push({ type: "page", value: 1 });
|
|
31
|
+
const v = h - 2, f = Math.floor(v / 2);
|
|
32
|
+
return l <= 3 + f ? (i.push(...y(2, h)), i.push({ type: "ellipsis", value: [h + 1, s - 1] })) : l >= s - (2 + f) ? (i.push({
|
|
24
33
|
type: "ellipsis",
|
|
25
|
-
value: [2,
|
|
26
|
-
}),
|
|
34
|
+
value: [2, s - (h - 1) - 1]
|
|
35
|
+
}), i.push(...y(s - (h - 1), s - 1))) : (i.push({ type: "ellipsis", value: [2, l - f - 1] }), i.push(...y(l - f, l + f)), i.push({
|
|
27
36
|
type: "ellipsis",
|
|
28
|
-
value: [
|
|
29
|
-
})),
|
|
37
|
+
value: [l + f + 1, s - 1]
|
|
38
|
+
})), i.push({ type: "page", value: s }), i;
|
|
30
39
|
}
|
|
31
40
|
export {
|
|
32
|
-
|
|
41
|
+
d as generatePaginationWithWindow
|
|
33
42
|
};
|
|
@@ -1,78 +1,96 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { uyTv as
|
|
4
|
-
import { useFilter as F, Select as
|
|
5
|
-
import { SearchInput as
|
|
6
|
-
import { SelectButton as
|
|
7
|
-
const
|
|
1
|
+
import { jsxs as c, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as j, useState as B } from "react";
|
|
3
|
+
import { uyTv as C } from "@payfit/unity-themes";
|
|
4
|
+
import { useFilter as F, Select as z, Popover as A, Autocomplete as I, Virtualizer as p, ListLayout as d, ListBox as y } from "react-aria-components";
|
|
5
|
+
import { SearchInput as T } from "./parts/SearchInput.js";
|
|
6
|
+
import { SelectButton as U } from "./parts/SelectButton.js";
|
|
7
|
+
const V = C({
|
|
8
8
|
slots: {
|
|
9
9
|
base: "uy:flex uy:flex-col uy:gap-100 uy:w-full",
|
|
10
10
|
popover: "uy:rounded-75 uy:border uy:border-solid uy:border-border-neutral uy:w-[var(--trigger-width)] uy:bg-surface-neutral",
|
|
11
|
-
listbox: "uy:overflow-y-auto uy:max-h-[296px] uy:pt-100 uy:pb-100
|
|
11
|
+
listbox: "uy:overflow-y-auto uy:max-h-[296px] uy:pt-100 uy:pb-100"
|
|
12
12
|
}
|
|
13
|
-
}),
|
|
13
|
+
}), $ = ({
|
|
14
14
|
children: t,
|
|
15
15
|
items: o,
|
|
16
16
|
placeholder: r,
|
|
17
|
-
name:
|
|
17
|
+
name: f,
|
|
18
18
|
isDisabled: l,
|
|
19
19
|
isInvalid: s,
|
|
20
|
-
isReadOnly:
|
|
21
|
-
value:
|
|
22
|
-
defaultValue:
|
|
23
|
-
onChange:
|
|
24
|
-
isSearchable:
|
|
25
|
-
onBlur:
|
|
20
|
+
isReadOnly: n,
|
|
21
|
+
value: i,
|
|
22
|
+
defaultValue: m,
|
|
23
|
+
onChange: a,
|
|
24
|
+
isSearchable: b = !1,
|
|
25
|
+
onBlur: x,
|
|
26
26
|
placement: S,
|
|
27
|
-
...
|
|
28
|
-
},
|
|
29
|
-
const [
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} : {
|
|
33
|
-
return /* @__PURE__ */
|
|
34
|
-
|
|
27
|
+
...h
|
|
28
|
+
}, v) => {
|
|
29
|
+
const [g, w] = B(!1), { contains: N } = F({ sensitivity: "base" }), { base: O, popover: L, listbox: u } = V(), P = i !== void 0 || a !== void 0 ? {
|
|
30
|
+
value: i,
|
|
31
|
+
onChange: a
|
|
32
|
+
} : { defaultValue: m };
|
|
33
|
+
return /* @__PURE__ */ c(
|
|
34
|
+
z,
|
|
35
35
|
{
|
|
36
|
-
onOpenChange:
|
|
37
|
-
...
|
|
38
|
-
ref:
|
|
39
|
-
className:
|
|
40
|
-
name:
|
|
36
|
+
onOpenChange: w,
|
|
37
|
+
...h,
|
|
38
|
+
ref: v,
|
|
39
|
+
className: O(),
|
|
40
|
+
name: f,
|
|
41
41
|
placeholder: l ? void 0 : r,
|
|
42
|
-
isDisabled: l ||
|
|
42
|
+
isDisabled: l || n,
|
|
43
43
|
isInvalid: s,
|
|
44
|
-
onBlur:
|
|
45
|
-
...
|
|
44
|
+
onBlur: x,
|
|
45
|
+
...P,
|
|
46
46
|
children: [
|
|
47
47
|
/* @__PURE__ */ e(
|
|
48
|
-
|
|
48
|
+
U,
|
|
49
49
|
{
|
|
50
50
|
isDisabled: l,
|
|
51
51
|
isInvalid: s,
|
|
52
|
-
isReadOnly:
|
|
53
|
-
isOpen:
|
|
52
|
+
isReadOnly: n,
|
|
53
|
+
isOpen: g
|
|
54
54
|
}
|
|
55
55
|
),
|
|
56
56
|
/* @__PURE__ */ e(
|
|
57
|
-
|
|
57
|
+
A,
|
|
58
58
|
{
|
|
59
59
|
offset: 1,
|
|
60
60
|
containerPadding: 8,
|
|
61
|
-
className:
|
|
61
|
+
className: L(),
|
|
62
62
|
placement: S,
|
|
63
|
-
children:
|
|
64
|
-
/* @__PURE__ */ e(
|
|
65
|
-
/* @__PURE__ */ e(
|
|
66
|
-
|
|
63
|
+
children: b ? /* @__PURE__ */ c(I, { filter: N, children: [
|
|
64
|
+
/* @__PURE__ */ e(T, {}),
|
|
65
|
+
/* @__PURE__ */ e(
|
|
66
|
+
p,
|
|
67
|
+
{
|
|
68
|
+
layout: d,
|
|
69
|
+
layoutOptions: {
|
|
70
|
+
padding: 8
|
|
71
|
+
},
|
|
72
|
+
children: /* @__PURE__ */ e(y, { items: o, className: u(), children: t })
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
] }) : /* @__PURE__ */ e(
|
|
76
|
+
p,
|
|
77
|
+
{
|
|
78
|
+
layout: d,
|
|
79
|
+
layoutOptions: {
|
|
80
|
+
padding: 8
|
|
81
|
+
},
|
|
82
|
+
children: /* @__PURE__ */ e(y, { items: o, className: u(), children: t })
|
|
83
|
+
}
|
|
84
|
+
)
|
|
67
85
|
}
|
|
68
86
|
)
|
|
69
87
|
]
|
|
70
88
|
}
|
|
71
89
|
);
|
|
72
|
-
},
|
|
73
|
-
return
|
|
90
|
+
}, k = j(function(o, r) {
|
|
91
|
+
return $(o, r);
|
|
74
92
|
});
|
|
75
|
-
|
|
93
|
+
k.displayName = "Select";
|
|
76
94
|
export {
|
|
77
|
-
|
|
95
|
+
k as Select
|
|
78
96
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { forwardRef as
|
|
1
|
+
import { jsx as e, jsxs as y, Fragment as i } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as d } from "react";
|
|
3
3
|
import { uyTv as f } from "@payfit/unity-themes";
|
|
4
|
-
import { ListBoxItem as
|
|
5
|
-
import { Icon as
|
|
4
|
+
import { ListBoxItem as p } from "react-aria-components";
|
|
5
|
+
import { Icon as m } from "../../icon/Icon.js";
|
|
6
6
|
import { SelectOptionProvider as b } from "./SelectOption.context.js";
|
|
7
7
|
const x = f({
|
|
8
|
-
base: "uy:flex uy:flex-col uy:typography-body uy:rounded-50 uy:pt-100 uy:pb-100 uy:pl-150 uy:pr-150 uy:outline-none",
|
|
8
|
+
base: "uy:flex uy:flex-col uy:typography-body uy:rounded-50 uy:pt-100 uy:pb-100 uy:pl-150 uy:pr-150 uy:outline-none uy:cursor-pointer",
|
|
9
9
|
variants: {
|
|
10
10
|
isFocusVisible: {
|
|
11
11
|
true: "uy:outline-offset-2 uy:outline-2 uy:outline-solid uy:outline-utility-focus-ring"
|
|
@@ -33,11 +33,11 @@ const x = f({
|
|
|
33
33
|
class: "uy:bg-surface-neutral-enabled uy:text-content-neutral-enabled"
|
|
34
34
|
}
|
|
35
35
|
]
|
|
36
|
-
}), v =
|
|
36
|
+
}), v = d(
|
|
37
37
|
(s, l) => {
|
|
38
38
|
const { children: u, isDisabled: r, textValue: n } = s;
|
|
39
39
|
return /* @__PURE__ */ e(
|
|
40
|
-
|
|
40
|
+
p,
|
|
41
41
|
{
|
|
42
42
|
...s,
|
|
43
43
|
ref: l,
|
|
@@ -50,9 +50,9 @@ const x = f({
|
|
|
50
50
|
isSelected: c,
|
|
51
51
|
isDisabled: r
|
|
52
52
|
}),
|
|
53
|
-
children: ({ isSelected: t }) => /* @__PURE__ */ e(b, { isDisabled: r, children: t ? /* @__PURE__ */
|
|
53
|
+
children: ({ isSelected: t }) => /* @__PURE__ */ e(b, { isDisabled: r, children: t ? /* @__PURE__ */ y("div", { className: "uy:flex uy:justify-between", children: [
|
|
54
54
|
/* @__PURE__ */ e("div", { className: "uy:flex uy:flex-col", children: /* @__PURE__ */ e(i, { children: u }) }),
|
|
55
|
-
/* @__PURE__ */ e(
|
|
55
|
+
/* @__PURE__ */ e(m, { src: "CheckOutlined" })
|
|
56
56
|
] }) : /* @__PURE__ */ e(i, { children: u }) })
|
|
57
57
|
}
|
|
58
58
|
);
|
|
@@ -3,7 +3,7 @@ import { forwardRef as l, useId as p } from "react";
|
|
|
3
3
|
import { uyTv as f } from "@payfit/unity-themes";
|
|
4
4
|
import { Link as m } from "react-aria-components";
|
|
5
5
|
import { FormattedMessage as b } from "react-intl";
|
|
6
|
-
import { link as k } from "../link/
|
|
6
|
+
import { link as k } from "../link/RawLink.js";
|
|
7
7
|
const h = f({
|
|
8
8
|
slots: {
|
|
9
9
|
base: [
|
|
@@ -13,6 +13,7 @@ export interface TableRootProps extends PropsWithChildren {
|
|
|
13
13
|
* @component
|
|
14
14
|
* The `TableRoot` component serves as the container for the table and its pagination controls.
|
|
15
15
|
* It provides styling and layout for the table, including min and max height constraints.
|
|
16
|
+
* The pagination remains fixed while the table content can scroll horizontally if needed.
|
|
16
17
|
* @param {TableRootProps} props - The props for the `TableRoot` component
|
|
17
18
|
* @param {number} [props.minRows=10] - The minimum number of rows to display, affecting the minimum height
|
|
18
19
|
* @param {number} [props.maxRows=50] - The maximum number of rows to display, affecting the maximum height
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
1
|
+
import { jsx as f, jsxs as x } from "react/jsx-runtime";
|
|
2
|
+
import i, { forwardRef as T, useRef as N, useMemo as C, useImperativeHandle as z, useCallback as k } from "react";
|
|
3
3
|
import { uyTv as R } from "@payfit/unity-themes";
|
|
4
4
|
import { useResizeObserver as S } from "usehooks-ts";
|
|
5
5
|
import { TableContextProvider as V, useTableContext as D } from "./Table.context.js";
|
|
@@ -8,23 +8,22 @@ const K = R({
|
|
|
8
8
|
"uy:w-full uy:border uy:border-solid uy:border-border-neutral uy:rounded-100",
|
|
9
9
|
"uy:relative uy:flex uy:flex-col",
|
|
10
10
|
"uy:min-h-[var(--uy-table-min-rows)] uy:max-h-[var(--uy-table-max-rows)]",
|
|
11
|
-
"uy:overflow-y-auto"
|
|
12
|
-
// Handle vertical scrolling
|
|
13
|
-
|
|
14
|
-
// Handle horizontal scrolling too
|
|
11
|
+
"uy:overflow-y-auto"
|
|
12
|
+
// Handle vertical scrolling only
|
|
13
|
+
// Remove horizontal overflow - pagination should not scroll horizontally
|
|
15
14
|
]
|
|
16
|
-
}), U =
|
|
17
|
-
({ minRows:
|
|
15
|
+
}), U = T(
|
|
16
|
+
({ minRows: s = 10, maxRows: u = 50, children: o }, l) => /* @__PURE__ */ f(
|
|
18
17
|
"div",
|
|
19
18
|
{
|
|
20
|
-
ref:
|
|
19
|
+
ref: l,
|
|
21
20
|
className: K(),
|
|
22
21
|
"data-unity-slot": "table-root",
|
|
23
22
|
style: {
|
|
24
|
-
"--uy-table-min-rows": `calc(var(--uy-spacing-600) * ${
|
|
25
|
-
"--uy-table-max-rows": `calc(var(--uy-spacing-600) * ${
|
|
23
|
+
"--uy-table-min-rows": `calc(var(--uy-spacing-600) * ${s})`,
|
|
24
|
+
"--uy-table-max-rows": `calc(var(--uy-spacing-600) * ${u})`
|
|
26
25
|
},
|
|
27
|
-
children:
|
|
26
|
+
children: o
|
|
28
27
|
}
|
|
29
28
|
)
|
|
30
29
|
);
|
|
@@ -33,8 +32,9 @@ const $ = R({
|
|
|
33
32
|
slots: {
|
|
34
33
|
wrapper: [
|
|
35
34
|
"uy:flex-1 uy:bg-surface-neutral",
|
|
36
|
-
"uy:w-full"
|
|
37
|
-
//
|
|
35
|
+
"uy:w-full",
|
|
36
|
+
// Handle horizontal scrolling in the wrapper, independent of pagination
|
|
37
|
+
"uy:overflow-x-auto"
|
|
38
38
|
],
|
|
39
39
|
table: [
|
|
40
40
|
"uy:min-w-full",
|
|
@@ -45,10 +45,12 @@ const $ = R({
|
|
|
45
45
|
variants: {
|
|
46
46
|
horizontalScroll: {
|
|
47
47
|
true: {
|
|
48
|
-
//
|
|
48
|
+
// Enable horizontal scrolling and allow table to exceed container width
|
|
49
49
|
table: "uy:w-max"
|
|
50
50
|
},
|
|
51
51
|
false: {
|
|
52
|
+
// Disable horizontal scrolling
|
|
53
|
+
wrapper: "uy:overflow-x-hidden",
|
|
52
54
|
table: "uy:w-fit"
|
|
53
55
|
}
|
|
54
56
|
}
|
|
@@ -56,85 +58,92 @@ const $ = R({
|
|
|
56
58
|
defaultVariants: {
|
|
57
59
|
horizontalScroll: !0
|
|
58
60
|
}
|
|
59
|
-
}), P =
|
|
61
|
+
}), P = T((s, u) => {
|
|
60
62
|
const {
|
|
61
|
-
children:
|
|
62
|
-
label:
|
|
63
|
+
children: o,
|
|
64
|
+
label: l,
|
|
63
65
|
description: m,
|
|
64
66
|
isHorizontalScrollEnabled: g = !0,
|
|
65
67
|
...c
|
|
66
|
-
} =
|
|
67
|
-
ref:
|
|
68
|
+
} = s, y = N(null), { height: h = 0 } = S({
|
|
69
|
+
ref: y,
|
|
68
70
|
box: "border-box"
|
|
69
|
-
}), { rowCount:
|
|
70
|
-
let
|
|
71
|
-
return
|
|
72
|
-
if (!
|
|
73
|
-
const a =
|
|
74
|
-
|
|
75
|
-
).filter((
|
|
76
|
-
|
|
77
|
-
if (!
|
|
78
|
-
const v =
|
|
79
|
-
|
|
80
|
-
).filter((
|
|
81
|
-
|
|
71
|
+
}), { rowCount: p, columnCount: w } = C(() => {
|
|
72
|
+
let t = 0, r = 0;
|
|
73
|
+
return i.Children.forEach(o, (e) => {
|
|
74
|
+
if (!i.isValidElement(e)) return;
|
|
75
|
+
const a = i.Children.toArray(
|
|
76
|
+
e.props.children
|
|
77
|
+
).filter((n) => i.isValidElement(n));
|
|
78
|
+
r += a.length, a.forEach((n) => {
|
|
79
|
+
if (!i.isValidElement(n)) return;
|
|
80
|
+
const v = i.Children.toArray(
|
|
81
|
+
n.props.children
|
|
82
|
+
).filter((d) => i.isValidElement(d));
|
|
83
|
+
t = Math.max(t, v.length);
|
|
82
84
|
});
|
|
83
|
-
}), { rowCount:
|
|
84
|
-
}, [
|
|
85
|
-
return z(
|
|
85
|
+
}), { rowCount: r, columnCount: t };
|
|
86
|
+
}, [o]);
|
|
87
|
+
return z(u, () => ({
|
|
86
88
|
scrollToTop: () => {
|
|
87
|
-
const
|
|
89
|
+
const t = y.current, r = t?.closest(
|
|
88
90
|
'[data-unity-slot="table-root"]'
|
|
89
91
|
);
|
|
90
|
-
|
|
92
|
+
let e;
|
|
93
|
+
if (r ? e = r : t && (e = t), !!e) {
|
|
94
|
+
if (typeof e.scrollTo == "function") {
|
|
95
|
+
e.scrollTo({ top: 0, behavior: "smooth" });
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
e.scrollTop = 0;
|
|
99
|
+
}
|
|
91
100
|
}
|
|
92
|
-
})), /* @__PURE__ */
|
|
101
|
+
})), /* @__PURE__ */ f(V, { rowCount: p, columnCount: w, children: /* @__PURE__ */ f(
|
|
93
102
|
E,
|
|
94
103
|
{
|
|
95
|
-
scrollContainerRef:
|
|
96
|
-
containerHeight:
|
|
97
|
-
rowCount:
|
|
98
|
-
columnCount:
|
|
99
|
-
label:
|
|
104
|
+
scrollContainerRef: y,
|
|
105
|
+
containerHeight: h,
|
|
106
|
+
rowCount: p,
|
|
107
|
+
columnCount: w,
|
|
108
|
+
label: l,
|
|
100
109
|
description: m,
|
|
101
110
|
isHorizontalScrollEnabled: g,
|
|
102
111
|
...c,
|
|
103
|
-
children:
|
|
112
|
+
children: o
|
|
104
113
|
}
|
|
105
114
|
) });
|
|
106
115
|
});
|
|
107
116
|
P.displayName = "Table";
|
|
108
|
-
const E = (
|
|
117
|
+
const E = (s) => {
|
|
109
118
|
const {
|
|
110
|
-
children:
|
|
111
|
-
label:
|
|
112
|
-
description:
|
|
119
|
+
children: u,
|
|
120
|
+
label: o,
|
|
121
|
+
description: l,
|
|
113
122
|
scrollContainerRef: m,
|
|
114
123
|
containerHeight: g,
|
|
115
124
|
rowCount: c,
|
|
116
|
-
columnCount:
|
|
117
|
-
onKeyDown:
|
|
118
|
-
isHorizontalScrollEnabled:
|
|
119
|
-
...
|
|
120
|
-
} =
|
|
121
|
-
horizontalScroll:
|
|
122
|
-
}), { keyboardNavigation:
|
|
125
|
+
columnCount: y,
|
|
126
|
+
onKeyDown: h,
|
|
127
|
+
isHorizontalScrollEnabled: p = !0,
|
|
128
|
+
...w
|
|
129
|
+
} = s, { wrapper: t, table: r } = $({
|
|
130
|
+
horizontalScroll: p
|
|
131
|
+
}), { keyboardNavigation: e } = D(), { tableRef: a, handleTableKeyDown: n } = e, v = k(
|
|
123
132
|
(b) => {
|
|
124
|
-
b.key !== "Tab" && (
|
|
133
|
+
b.key !== "Tab" && (n(b), h?.(b));
|
|
125
134
|
},
|
|
126
|
-
[
|
|
127
|
-
),
|
|
135
|
+
[n, h]
|
|
136
|
+
), d = m.current?.closest(
|
|
128
137
|
'[data-unity-slot="table-root"]'
|
|
129
|
-
), H =
|
|
130
|
-
if (!
|
|
131
|
-
const b =
|
|
138
|
+
), H = C(() => {
|
|
139
|
+
if (!d || c === 0) return !1;
|
|
140
|
+
const b = d.clientHeight;
|
|
132
141
|
return (a.current?.clientHeight ?? 0) / b < 0.9;
|
|
133
|
-
}, [
|
|
142
|
+
}, [d, c]);
|
|
134
143
|
return /* @__PURE__ */ x(
|
|
135
144
|
"div",
|
|
136
145
|
{
|
|
137
|
-
className:
|
|
146
|
+
className: t(),
|
|
138
147
|
ref: m,
|
|
139
148
|
style: {
|
|
140
149
|
"--uy-table-has-remaining-space": H ? "1" : "0"
|
|
@@ -144,28 +153,28 @@ const E = (i) => {
|
|
|
144
153
|
"table",
|
|
145
154
|
{
|
|
146
155
|
ref: a,
|
|
147
|
-
className:
|
|
156
|
+
className: r(),
|
|
148
157
|
role: "grid",
|
|
149
158
|
"aria-rowcount": c,
|
|
150
|
-
"aria-colcount":
|
|
151
|
-
"aria-label":
|
|
152
|
-
"aria-describedby":
|
|
159
|
+
"aria-colcount": y,
|
|
160
|
+
"aria-label": o,
|
|
161
|
+
"aria-describedby": l ? `table-desc-${a.current?.id}` : void 0,
|
|
153
162
|
onKeyDown: v,
|
|
154
|
-
...
|
|
163
|
+
...w,
|
|
155
164
|
children: [
|
|
156
|
-
|
|
157
|
-
|
|
165
|
+
u,
|
|
166
|
+
l && /* @__PURE__ */ f(
|
|
158
167
|
"caption",
|
|
159
168
|
{
|
|
160
169
|
id: `table-desc-${a.current?.id}`,
|
|
161
170
|
className: "uy:sr-only",
|
|
162
|
-
children:
|
|
171
|
+
children: l
|
|
163
172
|
}
|
|
164
173
|
)
|
|
165
174
|
]
|
|
166
175
|
}
|
|
167
176
|
),
|
|
168
|
-
/* @__PURE__ */
|
|
177
|
+
/* @__PURE__ */ f("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." })
|
|
169
178
|
]
|
|
170
179
|
}
|
|
171
180
|
);
|
|
@@ -126,7 +126,7 @@ function O() {
|
|
|
126
126
|
[l]
|
|
127
127
|
), x = i(
|
|
128
128
|
(e) => {
|
|
129
|
-
if (e.key === "
|
|
129
|
+
if (e.key === "RawTab" || !a.current) return;
|
|
130
130
|
let t = e.currentTarget;
|
|
131
131
|
const s = e.target;
|
|
132
132
|
if (s !== t) {
|
|
@@ -173,19 +173,19 @@ function O() {
|
|
|
173
173
|
break;
|
|
174
174
|
case "PageUp":
|
|
175
175
|
e.preventDefault();
|
|
176
|
-
const f = Math.max(0, r - 5),
|
|
177
|
-
if (!
|
|
178
|
-
const R = Array.from(
|
|
176
|
+
const f = Math.max(0, r - 5), w = n[f];
|
|
177
|
+
if (!w) break;
|
|
178
|
+
const R = Array.from(w.querySelectorAll("td, th")), E = Math.min(u, R.length - 1);
|
|
179
179
|
l(f, E);
|
|
180
180
|
break;
|
|
181
181
|
case "PageDown":
|
|
182
182
|
e.preventDefault();
|
|
183
|
-
const
|
|
183
|
+
const p = Math.min(n.length - 1, r + 5), C = n[p];
|
|
184
184
|
if (!C) break;
|
|
185
185
|
const T = Array.from(
|
|
186
186
|
C.querySelectorAll("td, th")
|
|
187
187
|
), F = Math.min(u, T.length - 1);
|
|
188
|
-
l(
|
|
188
|
+
l(p, F);
|
|
189
189
|
break;
|
|
190
190
|
}
|
|
191
191
|
},
|