@tedi-design-system/react 17.1.0-rc.2 → 17.1.0-rc.4
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/_virtual/index.cjs10.js +1 -1
- package/_virtual/index.cjs11.js +1 -1
- package/_virtual/index.cjs12.js +1 -1
- package/_virtual/index.cjs13.js +1 -1
- package/_virtual/index.cjs5.js +1 -1
- package/_virtual/index.cjs6.js +1 -1
- package/_virtual/index.cjs7.js +1 -1
- package/_virtual/index.cjs8.js +1 -1
- package/_virtual/index.cjs9.js +1 -1
- package/_virtual/index.es10.js +1 -1
- package/_virtual/index.es11.js +1 -1
- package/_virtual/index.es12.js +1 -1
- package/_virtual/index.es13.js +4 -2
- package/_virtual/index.es5.js +2 -4
- package/_virtual/index.es6.js +1 -1
- package/_virtual/index.es7.js +1 -1
- package/_virtual/index.es8.js +1 -1
- package/_virtual/index.es9.js +1 -1
- package/bundle-stats.html +1 -1
- package/external/@mui/system/colorManipulator.cjs.js +1 -1
- package/external/@mui/system/colorManipulator.es.js +2 -2
- package/external/@mui/system/createStyled.cjs.js +1 -1
- package/external/@mui/system/createStyled.es.js +6 -6
- package/external/@mui/system/useThemeWithoutDefault.cjs.js +1 -1
- package/external/@mui/system/useThemeWithoutDefault.es.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.es.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.es.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/index.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/index.es.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.development.cjs.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.development.es.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.production.min.es.js +1 -1
- package/external/prop-types/external/react-is/index.cjs.js +1 -1
- package/external/prop-types/external/react-is/index.es.js +1 -1
- package/external/toposort/index.cjs.js +1 -1
- package/external/toposort/index.es.js +1 -1
- package/index.css +1 -1
- package/package.json +1 -1
- package/src/community/components/table/components/pagination/pagination.cjs.js +1 -1
- package/src/community/components/table/components/pagination/pagination.es.js +20 -24
- package/src/tedi/components/misc/empty-state/empty-state.cjs.js +1 -0
- package/src/tedi/components/misc/empty-state/empty-state.d.ts +51 -0
- package/src/tedi/components/misc/empty-state/empty-state.es.js +36 -0
- package/src/tedi/components/misc/empty-state/empty-state.module.scss.cjs.js +1 -0
- package/src/tedi/components/misc/empty-state/empty-state.module.scss.es.js +15 -0
- package/src/tedi/components/misc/empty-state/index.d.ts +1 -0
- package/src/tedi/components/navigation/pagination/index.d.ts +2 -0
- package/src/tedi/components/navigation/pagination/pagination.cjs.js +1 -0
- package/src/tedi/components/navigation/pagination/pagination.d.ts +102 -0
- package/src/tedi/components/navigation/pagination/pagination.es.js +131 -0
- package/src/tedi/components/navigation/pagination/pagination.module.scss.cjs.js +1 -0
- package/src/tedi/components/navigation/pagination/pagination.module.scss.es.js +20 -0
- package/src/tedi/components/navigation/pagination/use-pagination.cjs.js +1 -0
- package/src/tedi/components/navigation/pagination/use-pagination.d.ts +28 -0
- package/src/tedi/components/navigation/pagination/use-pagination.es.js +48 -0
- package/src/tedi/index.d.ts +2 -0
- package/src/tedi/providers/label-provider/labels-map.cjs.js +1 -1
- package/src/tedi/providers/label-provider/labels-map.d.ts +3 -3
- package/src/tedi/providers/label-provider/labels-map.es.js +4 -4
- package/tedi.cjs.js +1 -1
- package/tedi.es.js +120 -114
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react/jsx-runtime"),S=require("../../../../../../external/classnames/index.cjs.js"),h=require("react"),j=require("../../../../../tedi/components/base/typography/text/text.cjs.js"),_=require("../../../form/select/select.cjs.js"),m=require("../../table-context.cjs.js"),l=require("./pagination.module.scss.cjs.js"),y=require("./PaginationNextButton.cjs.js"),z=require("./PaginationPageButton.cjs.js"),C=require("./use-pagination.cjs.js"),L=require("../../../../../tedi/providers/label-provider/use-labels.cjs.js"),N=
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react/jsx-runtime"),S=require("../../../../../../external/classnames/index.cjs.js"),h=require("react"),j=require("../../../../../tedi/components/base/typography/text/text.cjs.js"),_=require("../../../form/select/select.cjs.js"),m=require("../../table-context.cjs.js"),l=require("./pagination.module.scss.cjs.js"),y=require("./PaginationNextButton.cjs.js"),z=require("./PaginationPageButton.cjs.js"),C=require("./use-pagination.cjs.js"),L=require("../../../../../tedi/providers/label-provider/use-labels.cjs.js"),N=i=>{const{getLabel:s}=L.useLabels(),{table:r,id:u}=h.useContext(m.TableContext),c=s("pagination.results",i.totalRows),{setPageSize:g,getState:d,getPageCount:p}=r,{pageIndex:b,pageSize:n}=d().pagination,o=[{value:"5",label:"5"},{value:"10",label:"10"},{value:"20",label:"20"},{value:"50",label:"50"},{value:"100",label:"100"}],f=Math.ceil(i.totalRows/n),{paginationItems:v}=C.default({page:b+1,count:f}),x=o.find(e=>e.value===String(n))??{value:String(n),label:String(n)},q=e=>{const t=parseInt((e==null?void 0:e.value)||"10");g(t)},P=(e,t)=>e.type==="previous"||e.type==="next"?a.jsx(y.default,{type:e.type},t):e.type==="ellipsis"?a.jsx("li",{className:S.default(l.default.pagination__page),children:"..."},t):a.jsx(z.default,{item:e},t);return a.jsxs("div",{className:l.default.pagination__wrapper,children:[a.jsx(j.Text,{color:"secondary",modifiers:"small",children:c}),p()>1&&a.jsx("nav",{role:"navigation","aria-label":s("pagination.title"),className:l.default.pagination,children:a.jsx("ul",{className:l.default.pagination__pages,children:v.map((e,t)=>P(e,t))})}),a.jsx(_.Select,{id:`page-size-${u}`,label:s("pagination.page-size"),hideLabel:!0,isSearchable:!1,isClearable:!1,onChange:e=>q(e),value:x,size:"small",options:o})]})};exports.default=N;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as S, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import _ from "../../../../../../external/classnames/index.es.js";
|
|
3
3
|
import x from "react";
|
|
4
4
|
import { Text as y } from "../../../../../tedi/components/base/typography/text/text.es.js";
|
|
@@ -6,43 +6,39 @@ import { Select as z } from "../../../form/select/select.es.js";
|
|
|
6
6
|
import { TableContext as N } from "../../table-context.es.js";
|
|
7
7
|
import n from "./pagination.module.scss.es.js";
|
|
8
8
|
import C from "./PaginationNextButton.es.js";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { useLabels as
|
|
12
|
-
const D = (
|
|
13
|
-
const { getLabel:
|
|
9
|
+
import L from "./PaginationPageButton.es.js";
|
|
10
|
+
import w from "./use-pagination.es.js";
|
|
11
|
+
import { useLabels as B } from "../../../../../tedi/providers/label-provider/use-labels.es.js";
|
|
12
|
+
const D = (o) => {
|
|
13
|
+
const { getLabel: i } = B(), { table: r, id: g } = x.useContext(N), p = i("pagination.results", o.totalRows), { setPageSize: c, getState: u, getPageCount: m } = r, { pageIndex: f, pageSize: l } = u().pagination, s = [
|
|
14
14
|
{ value: "5", label: "5" },
|
|
15
15
|
{ value: "10", label: "10" },
|
|
16
16
|
{ value: "20", label: "20" },
|
|
17
17
|
{ value: "50", label: "50" },
|
|
18
18
|
{ value: "100", label: "100" }
|
|
19
|
-
],
|
|
20
|
-
page:
|
|
21
|
-
count:
|
|
22
|
-
}),
|
|
19
|
+
], b = Math.ceil(o.totalRows / l), { paginationItems: d } = w({
|
|
20
|
+
page: f + 1,
|
|
21
|
+
count: b
|
|
22
|
+
}), v = s.find((a) => a.value === String(l)) ?? {
|
|
23
23
|
value: String(l),
|
|
24
24
|
label: String(l)
|
|
25
|
-
},
|
|
25
|
+
}, h = (a) => {
|
|
26
26
|
const e = parseInt((a == null ? void 0 : a.value) || "10");
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
return /* @__PURE__ */
|
|
30
|
-
/* @__PURE__ */
|
|
31
|
-
|
|
32
|
-
" ",
|
|
33
|
-
c
|
|
34
|
-
] }),
|
|
35
|
-
f() > 1 && /* @__PURE__ */ t("nav", { role: "navigation", "aria-label": o("pagination.title"), className: n.pagination, children: /* @__PURE__ */ t("ul", { className: n.pagination__pages, children: v.map((a, e) => S(a, e)) }) }),
|
|
27
|
+
c(e);
|
|
28
|
+
}, P = (a, e) => a.type === "previous" || a.type === "next" ? /* @__PURE__ */ t(C, { type: a.type }, e) : a.type === "ellipsis" ? /* @__PURE__ */ t("li", { className: _(n.pagination__page), children: "..." }, e) : /* @__PURE__ */ t(L, { item: a }, e);
|
|
29
|
+
return /* @__PURE__ */ S("div", { className: n.pagination__wrapper, children: [
|
|
30
|
+
/* @__PURE__ */ t(y, { color: "secondary", modifiers: "small", children: p }),
|
|
31
|
+
m() > 1 && /* @__PURE__ */ t("nav", { role: "navigation", "aria-label": i("pagination.title"), className: n.pagination, children: /* @__PURE__ */ t("ul", { className: n.pagination__pages, children: d.map((a, e) => P(a, e)) }) }),
|
|
36
32
|
/* @__PURE__ */ t(
|
|
37
33
|
z,
|
|
38
34
|
{
|
|
39
|
-
id: `page-size-${
|
|
40
|
-
label:
|
|
35
|
+
id: `page-size-${g}`,
|
|
36
|
+
label: i("pagination.page-size"),
|
|
41
37
|
hideLabel: !0,
|
|
42
38
|
isSearchable: !1,
|
|
43
39
|
isClearable: !1,
|
|
44
|
-
onChange: (a) =>
|
|
45
|
-
value:
|
|
40
|
+
onChange: (a) => h(a),
|
|
41
|
+
value: v,
|
|
46
42
|
size: "small",
|
|
47
43
|
options: s
|
|
48
44
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("../../../../../external/classnames/index.cjs.js"),n=require("../../base/icon/icon.cjs.js"),y=require("../../base/typography/heading/heading.cjs.js"),f=require("../../base/typography/text/text.cjs.js"),t=require("./empty-state.module.scss.cjs.js"),l=({type:c="separate",size:o="default",icon:s="spa",heading:a,children:d,actions:r,className:m})=>{const u=p.default(t.default["tedi-empty-state"],t.default[`tedi-empty-state--${c}`],t.default[`tedi-empty-state--${o}`],m),i=s===null?null:typeof s=="string"?e.jsx(n.Icon,{name:s,size:36,color:"brand"}):e.jsx(n.Icon,{size:36,color:"brand",...s});return e.jsxs("div",{"data-name":"tedi-empty-state",className:u,children:[e.jsxs("div",{className:t.default["tedi-empty-state__text"],children:[i&&e.jsx("div",{className:t.default["tedi-empty-state__icon"],children:i}),(a||d)&&e.jsxs("div",{className:t.default["tedi-empty-state__content"],children:[a&&e.jsx(y.Heading,{className:t.default["tedi-empty-state__heading"],element:"h3",modifiers:"h3",color:"brand",children:a}),d&&e.jsx(f.Text,{className:t.default["tedi-empty-state__description"],color:"secondary",modifiers:"center",children:d})]})]}),r&&e.jsx("div",{className:t.default["tedi-empty-state__actions"],children:r})]})};l.displayName="EmptyState";exports.EmptyState=l;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { IconWithoutBackgroundProps } from '../../base/icon/icon';
|
|
3
|
+
export type EmptyStateType = 'separate' | 'attached' | 'inside';
|
|
4
|
+
export type EmptyStateSize = 'default' | 'small';
|
|
5
|
+
export interface EmptyStateProps {
|
|
6
|
+
/**
|
|
7
|
+
* Container variant — matches the Figma "Types" section.
|
|
8
|
+
* - `'separate'` (default) — full border + radius, stands on its own.
|
|
9
|
+
* - `'attached'` — top border omitted so the block sits flush beneath a
|
|
10
|
+
* preceding card or table (same width + same bottom-radius).
|
|
11
|
+
* - `'inside'` — no border, no radius; intended to be placed inside another
|
|
12
|
+
* container such as a `<Card>` or `<Table>`.
|
|
13
|
+
* @default separate
|
|
14
|
+
*/
|
|
15
|
+
type?: EmptyStateType;
|
|
16
|
+
/**
|
|
17
|
+
* Padding scale. `default` = 24px, `small` = 16px.
|
|
18
|
+
* @default default
|
|
19
|
+
*/
|
|
20
|
+
size?: EmptyStateSize;
|
|
21
|
+
/**
|
|
22
|
+
* Icon rendered above the text block. Pass a Material icon name, a full
|
|
23
|
+
* `IconWithoutBackgroundProps` object to configure the underlying `Icon`,
|
|
24
|
+
* or `null` to hide the icon.
|
|
25
|
+
* @default spa
|
|
26
|
+
*/
|
|
27
|
+
icon?: string | IconWithoutBackgroundProps | null;
|
|
28
|
+
/**
|
|
29
|
+
* Optional heading rendered above the description — appears as an H3 in
|
|
30
|
+
* brand-primary text color.
|
|
31
|
+
*/
|
|
32
|
+
heading?: React.ReactNode;
|
|
33
|
+
/**
|
|
34
|
+
* Main body text describing why there is nothing to show.
|
|
35
|
+
*/
|
|
36
|
+
children?: React.ReactNode;
|
|
37
|
+
/**
|
|
38
|
+
* Call-to-action slot. Typically a `<Button>` (or two) or a `<Link>`.
|
|
39
|
+
* Rendered below the text block.
|
|
40
|
+
*/
|
|
41
|
+
actions?: React.ReactNode;
|
|
42
|
+
/**
|
|
43
|
+
* Additional class name on the root element.
|
|
44
|
+
*/
|
|
45
|
+
className?: string;
|
|
46
|
+
}
|
|
47
|
+
export declare const EmptyState: {
|
|
48
|
+
({ type, size, icon, heading, children, actions, className, }: EmptyStateProps): JSX.Element;
|
|
49
|
+
displayName: string;
|
|
50
|
+
};
|
|
51
|
+
export default EmptyState;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as t, jsxs as m } from "react/jsx-runtime";
|
|
2
|
+
import y from "../../../../../external/classnames/index.es.js";
|
|
3
|
+
import { Icon as d } from "../../base/icon/icon.es.js";
|
|
4
|
+
import { Heading as f } from "../../base/typography/heading/heading.es.js";
|
|
5
|
+
import { Text as _ } from "../../base/typography/text/text.es.js";
|
|
6
|
+
import e from "./empty-state.module.scss.es.js";
|
|
7
|
+
const N = ({
|
|
8
|
+
type: n = "separate",
|
|
9
|
+
size: l = "default",
|
|
10
|
+
icon: s = "spa",
|
|
11
|
+
heading: a,
|
|
12
|
+
children: r,
|
|
13
|
+
actions: i,
|
|
14
|
+
className: p
|
|
15
|
+
}) => {
|
|
16
|
+
const c = y(
|
|
17
|
+
e["tedi-empty-state"],
|
|
18
|
+
e[`tedi-empty-state--${n}`],
|
|
19
|
+
e[`tedi-empty-state--${l}`],
|
|
20
|
+
p
|
|
21
|
+
), o = s === null ? null : typeof s == "string" ? /* @__PURE__ */ t(d, { name: s, size: 36, color: "brand" }) : /* @__PURE__ */ t(d, { size: 36, color: "brand", ...s });
|
|
22
|
+
return /* @__PURE__ */ m("div", { "data-name": "tedi-empty-state", className: c, children: [
|
|
23
|
+
/* @__PURE__ */ m("div", { className: e["tedi-empty-state__text"], children: [
|
|
24
|
+
o && /* @__PURE__ */ t("div", { className: e["tedi-empty-state__icon"], children: o }),
|
|
25
|
+
(a || r) && /* @__PURE__ */ m("div", { className: e["tedi-empty-state__content"], children: [
|
|
26
|
+
a && /* @__PURE__ */ t(f, { className: e["tedi-empty-state__heading"], element: "h3", modifiers: "h3", color: "brand", children: a }),
|
|
27
|
+
r && /* @__PURE__ */ t(_, { className: e["tedi-empty-state__description"], color: "secondary", modifiers: "center", children: r })
|
|
28
|
+
] })
|
|
29
|
+
] }),
|
|
30
|
+
i && /* @__PURE__ */ t("div", { className: e["tedi-empty-state__actions"], children: i })
|
|
31
|
+
] });
|
|
32
|
+
};
|
|
33
|
+
N.displayName = "EmptyState";
|
|
34
|
+
export {
|
|
35
|
+
N as EmptyState
|
|
36
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t={"tedi-empty-state":"tedi-empty-state-fa18a0c7","tedi-empty-state--small":"tedi-empty-state--small-cd55192d","tedi-empty-state--attached":"tedi-empty-state--attached-34f9494f","tedi-empty-state--inside":"tedi-empty-state--inside-59a35f4a","tedi-empty-state__text":"tedi-empty-state__text-3356405a","tedi-empty-state__icon":"tedi-empty-state__icon-b7c0b65c","tedi-empty-state__content":"tedi-empty-state__content-8f9e9b61","tedi-empty-state__heading":"tedi-empty-state__heading-a8adf6aa","tedi-empty-state__description":"tedi-empty-state__description-4c540947","tedi-empty-state__actions":"tedi-empty-state__actions-bff9b270"};exports.default=t;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const t = {
|
|
2
|
+
"tedi-empty-state": "tedi-empty-state-fa18a0c7",
|
|
3
|
+
"tedi-empty-state--small": "tedi-empty-state--small-cd55192d",
|
|
4
|
+
"tedi-empty-state--attached": "tedi-empty-state--attached-34f9494f",
|
|
5
|
+
"tedi-empty-state--inside": "tedi-empty-state--inside-59a35f4a",
|
|
6
|
+
"tedi-empty-state__text": "tedi-empty-state__text-3356405a",
|
|
7
|
+
"tedi-empty-state__icon": "tedi-empty-state__icon-b7c0b65c",
|
|
8
|
+
"tedi-empty-state__content": "tedi-empty-state__content-8f9e9b61",
|
|
9
|
+
"tedi-empty-state__heading": "tedi-empty-state__heading-a8adf6aa",
|
|
10
|
+
"tedi-empty-state__description": "tedi-empty-state__description-4c540947",
|
|
11
|
+
"tedi-empty-state__actions": "tedi-empty-state__actions-bff9b270"
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
t as default
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './empty-state';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),g=require("../../../../../external/classnames/index.cjs.js"),s=require("react"),U=require("../../base/icon/icon.cjs.js"),y=require("../../base/typography/text/text.cjs.js"),x=require("../../buttons/button/button.cjs.js"),D=require("../../form/select/select.cjs.js"),a=require("./pagination.module.scss.cjs.js"),E=require("./use-pagination.cjs.js"),F=require("../../../providers/label-provider/use-labels.cjs.js"),N=s.forwardRef((S,j)=>{const{pageCount:u,page:f,defaultPage:z=1,onPageChange:d,totalItems:m,pageSize:b,pageSizeOptions:l,onPageSizeChange:c,boundaryCount:L=1,siblingCount:q=1,labels:h,className:A}=S,{getLabel:i}=F.useLabels(),n=s.useMemo(()=>({ariaLabel:i("pagination.title"),previous:i("pagination.prev-page"),next:i("pagination.next-page"),pageAriaLabel:e=>i("pagination.page",e,!1),currentPageAriaLabel:e=>i("pagination.page",e,!0),results:e=>i("pagination.results",e),pageSize:i("pagination.page-size"),...h}),[i,h]),[C,P]=s.useState(z),_=f??C,w=E.usePagination({page:_,pageCount:u,boundaryCount:L,siblingCount:q}),v=s.useCallback(e=>{e===_||e<1||e>u||(f===void 0&&P(e),d==null||d(e))},[_,d,f,u]),k=s.useId(),p=s.useMemo(()=>Array.isArray(l)?l.map(e=>({value:String(e),label:String(e)})):[],[l]),I=s.useMemo(()=>b===void 0?p[0]??null:p.find(e=>e.value===String(b))??null,[b,p]),M=s.useCallback(e=>{const r=Array.isArray(e)?e[0]:e;r&&"value"in r&&(c==null||c(Number(r.value)))},[c]),O=g.default(a.default["tedi-pagination"],A),R=m!==void 0,T=Array.isArray(l)&&l.length>0;return t.jsxs("div",{ref:j,className:O,"data-name":"tedi-pagination",children:[t.jsx("div",{className:a.default["tedi-pagination__slot-start"],children:R&&t.jsx(y.Text,{className:a.default["tedi-pagination__results"],color:"secondary",modifiers:"small",children:n.results(m)})}),t.jsx("div",{className:a.default["tedi-pagination__slot-center"],children:u>1&&t.jsx("nav",{"aria-label":n.ariaLabel,className:a.default["tedi-pagination__nav"],children:t.jsx("ul",{className:a.default["tedi-pagination__list"],children:w.map((e,r)=>{if(e.type==="ellipsis")return t.jsx("li",{className:g.default(a.default["tedi-pagination__item"],a.default["tedi-pagination__item--ellipsis"]),"aria-hidden":"true",children:"…"},`ellipsis-${r}`);if(e.type==="previous"||e.type==="next"){if(e.disabled)return null;const B=e.type==="previous"?n.previous:n.next,$=e.type==="previous"?"arrow_back":"arrow_forward";return t.jsx("li",{className:a.default["tedi-pagination__item"],children:t.jsx(x.Button,{type:"button",className:g.default(a.default["tedi-pagination__button"],a.default["tedi-pagination__button--nav"]),"aria-label":B,onClick:()=>e.page!==null&&v(e.page),noStyle:!0,children:t.jsx(U.Icon,{name:$,size:18,color:"brand"})})},e.type)}const o=e.page;return t.jsx("li",{className:a.default["tedi-pagination__item"],children:t.jsx(x.Button,{type:"button",className:g.default(a.default["tedi-pagination__button"],{[a.default["tedi-pagination__button--selected"]]:e.selected}),"aria-label":e.selected?n.currentPageAriaLabel(o):n.pageAriaLabel(o),"aria-current":e.selected?"page":void 0,onClick:()=>v(o),noStyle:!0,children:o})},o)})})})}),t.jsx("div",{className:a.default["tedi-pagination__slot-end"],children:T&&t.jsxs("div",{className:a.default["tedi-pagination__page-size"],children:[t.jsx(y.Text,{className:a.default["tedi-pagination__page-size-label"],color:"secondary",modifiers:"small",element:"span",children:n.pageSize}),t.jsx(D.Select,{id:`tedi-pagination-page-size-${k}`,className:a.default["tedi-pagination__select"],label:n.pageSize,hideLabel:!0,size:"small",options:p,value:I,onChange:M,isSearchable:!1,isClearable:!1})]})})]})});N.displayName="Pagination";exports.Pagination=N;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export type PaginationItemType = 'page' | 'previous' | 'next' | 'ellipsis';
|
|
2
|
+
export interface PaginationItem {
|
|
3
|
+
type: PaginationItemType;
|
|
4
|
+
page: number | null;
|
|
5
|
+
selected: boolean;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface PaginationLabels {
|
|
9
|
+
/**
|
|
10
|
+
* Accessible label for the nav wrapper.
|
|
11
|
+
* @default 'Pagination'
|
|
12
|
+
*/
|
|
13
|
+
ariaLabel: string;
|
|
14
|
+
/**
|
|
15
|
+
* Previous button label (icon-only, used as aria-label).
|
|
16
|
+
* @default 'Previous page'
|
|
17
|
+
*/
|
|
18
|
+
previous: string;
|
|
19
|
+
/**
|
|
20
|
+
* Next button label (icon-only, used as aria-label).
|
|
21
|
+
* @default 'Next page'
|
|
22
|
+
*/
|
|
23
|
+
next: string;
|
|
24
|
+
/**
|
|
25
|
+
* Function that builds the aria-label for a numeric page button.
|
|
26
|
+
* @default (page) => `Go to page ${page}`
|
|
27
|
+
*/
|
|
28
|
+
pageAriaLabel: (page: number) => string;
|
|
29
|
+
/**
|
|
30
|
+
* Function that builds the aria-label for the currently active page.
|
|
31
|
+
* @default (page) => `Current page, page ${page}`
|
|
32
|
+
*/
|
|
33
|
+
currentPageAriaLabel: (page: number) => string;
|
|
34
|
+
/**
|
|
35
|
+
* Rendered to the left of the pagination nav when `totalItems` is set.
|
|
36
|
+
* @default (count) => `${count} results`
|
|
37
|
+
*/
|
|
38
|
+
results: (count: number) => string;
|
|
39
|
+
/**
|
|
40
|
+
* Prefix label for the page-size select.
|
|
41
|
+
* @default 'Show per page'
|
|
42
|
+
*/
|
|
43
|
+
pageSize: string;
|
|
44
|
+
}
|
|
45
|
+
export interface PaginationProps {
|
|
46
|
+
/**
|
|
47
|
+
* Total number of pages.
|
|
48
|
+
*/
|
|
49
|
+
pageCount: number;
|
|
50
|
+
/**
|
|
51
|
+
* Controlled current page (1-based). Pair with `onPageChange`.
|
|
52
|
+
*/
|
|
53
|
+
page?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Initial page for uncontrolled mode (1-based).
|
|
56
|
+
* @default 1
|
|
57
|
+
*/
|
|
58
|
+
defaultPage?: number;
|
|
59
|
+
/**
|
|
60
|
+
* Fires whenever the user navigates to a different page.
|
|
61
|
+
*/
|
|
62
|
+
onPageChange?: (page: number) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Total number of items across all pages. Renders a "{count} results" label
|
|
65
|
+
* to the left of the nav when set.
|
|
66
|
+
*/
|
|
67
|
+
totalItems?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Current page size. Shown in the page-size select when
|
|
70
|
+
* `pageSizeOptions` is provided.
|
|
71
|
+
*/
|
|
72
|
+
pageSize?: number;
|
|
73
|
+
/**
|
|
74
|
+
* Options for the page-size select. Omit to hide the select.
|
|
75
|
+
*/
|
|
76
|
+
pageSizeOptions?: number[];
|
|
77
|
+
/**
|
|
78
|
+
* Fires when the user picks a different page size.
|
|
79
|
+
*/
|
|
80
|
+
onPageSizeChange?: (pageSize: number) => void;
|
|
81
|
+
/**
|
|
82
|
+
* Number of pages always shown at the start and end of the range before
|
|
83
|
+
* ellipsis kicks in.
|
|
84
|
+
* @default 1
|
|
85
|
+
*/
|
|
86
|
+
boundaryCount?: number;
|
|
87
|
+
/**
|
|
88
|
+
* Number of sibling pages shown on either side of the current page.
|
|
89
|
+
* @default 1
|
|
90
|
+
*/
|
|
91
|
+
siblingCount?: number;
|
|
92
|
+
/**
|
|
93
|
+
* Override any of the default text labels / aria labels.
|
|
94
|
+
*/
|
|
95
|
+
labels?: Partial<PaginationLabels>;
|
|
96
|
+
/**
|
|
97
|
+
* Additional class name on the root element.
|
|
98
|
+
*/
|
|
99
|
+
className?: string;
|
|
100
|
+
}
|
|
101
|
+
export declare const Pagination: import('react').ForwardRefExoticComponent<PaginationProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
102
|
+
export default Pagination;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { jsxs as v, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import g from "../../../../../external/classnames/index.es.js";
|
|
3
|
+
import { forwardRef as D, useMemo as b, useState as E, useCallback as y, useId as F } from "react";
|
|
4
|
+
import { Icon as G } from "../../base/icon/icon.es.js";
|
|
5
|
+
import { Text as S } from "../../base/typography/text/text.es.js";
|
|
6
|
+
import { Button as z } from "../../buttons/button/button.es.js";
|
|
7
|
+
import { Select as H } from "../../form/select/select.es.js";
|
|
8
|
+
import a from "./pagination.module.scss.es.js";
|
|
9
|
+
import { usePagination as J } from "./use-pagination.es.js";
|
|
10
|
+
import { useLabels as K } from "../../../providers/label-provider/use-labels.es.js";
|
|
11
|
+
const Q = D((A, L) => {
|
|
12
|
+
const {
|
|
13
|
+
pageCount: o,
|
|
14
|
+
page: u,
|
|
15
|
+
defaultPage: C = 1,
|
|
16
|
+
onPageChange: p,
|
|
17
|
+
totalItems: f,
|
|
18
|
+
pageSize: m,
|
|
19
|
+
pageSizeOptions: s,
|
|
20
|
+
onPageSizeChange: c,
|
|
21
|
+
boundaryCount: P = 1,
|
|
22
|
+
siblingCount: w = 1,
|
|
23
|
+
labels: h,
|
|
24
|
+
className: k
|
|
25
|
+
} = A, { getLabel: t } = K(), n = b(
|
|
26
|
+
() => ({
|
|
27
|
+
ariaLabel: t("pagination.title"),
|
|
28
|
+
previous: t("pagination.prev-page"),
|
|
29
|
+
next: t("pagination.next-page"),
|
|
30
|
+
pageAriaLabel: (e) => t("pagination.page", e, !1),
|
|
31
|
+
currentPageAriaLabel: (e) => t("pagination.page", e, !0),
|
|
32
|
+
results: (e) => t("pagination.results", e),
|
|
33
|
+
pageSize: t("pagination.page-size"),
|
|
34
|
+
...h
|
|
35
|
+
}),
|
|
36
|
+
[t, h]
|
|
37
|
+
), [x, I] = E(C), _ = u ?? x, O = J({ page: _, pageCount: o, boundaryCount: P, siblingCount: w }), N = y(
|
|
38
|
+
(e) => {
|
|
39
|
+
e === _ || e < 1 || e > o || (u === void 0 && I(e), p == null || p(e));
|
|
40
|
+
},
|
|
41
|
+
[_, p, u, o]
|
|
42
|
+
), j = F(), d = b(
|
|
43
|
+
() => Array.isArray(s) ? s.map((e) => ({
|
|
44
|
+
value: String(e),
|
|
45
|
+
label: String(e)
|
|
46
|
+
})) : [],
|
|
47
|
+
[s]
|
|
48
|
+
), R = b(() => m === void 0 ? d[0] ?? null : d.find((e) => e.value === String(m)) ?? null, [m, d]), $ = y(
|
|
49
|
+
(e) => {
|
|
50
|
+
const l = Array.isArray(e) ? e[0] : e;
|
|
51
|
+
l && "value" in l && (c == null || c(Number(l.value)));
|
|
52
|
+
},
|
|
53
|
+
[c]
|
|
54
|
+
), B = g(a["tedi-pagination"], k), M = f !== void 0, T = Array.isArray(s) && s.length > 0;
|
|
55
|
+
return /* @__PURE__ */ v("div", { ref: L, className: B, "data-name": "tedi-pagination", children: [
|
|
56
|
+
/* @__PURE__ */ i("div", { className: a["tedi-pagination__slot-start"], children: M && /* @__PURE__ */ i(S, { className: a["tedi-pagination__results"], color: "secondary", modifiers: "small", children: n.results(f) }) }),
|
|
57
|
+
/* @__PURE__ */ i("div", { className: a["tedi-pagination__slot-center"], children: o > 1 && /* @__PURE__ */ i("nav", { "aria-label": n.ariaLabel, className: a["tedi-pagination__nav"], children: /* @__PURE__ */ i("ul", { className: a["tedi-pagination__list"], children: O.map((e, l) => {
|
|
58
|
+
if (e.type === "ellipsis")
|
|
59
|
+
return /* @__PURE__ */ i(
|
|
60
|
+
"li",
|
|
61
|
+
{
|
|
62
|
+
className: g(a["tedi-pagination__item"], a["tedi-pagination__item--ellipsis"]),
|
|
63
|
+
"aria-hidden": "true",
|
|
64
|
+
children: "…"
|
|
65
|
+
},
|
|
66
|
+
`ellipsis-${l}`
|
|
67
|
+
);
|
|
68
|
+
if (e.type === "previous" || e.type === "next") {
|
|
69
|
+
if (e.disabled) return null;
|
|
70
|
+
const U = e.type === "previous" ? n.previous : n.next, q = e.type === "previous" ? "arrow_back" : "arrow_forward";
|
|
71
|
+
return /* @__PURE__ */ i("li", { className: a["tedi-pagination__item"], children: /* @__PURE__ */ i(
|
|
72
|
+
z,
|
|
73
|
+
{
|
|
74
|
+
type: "button",
|
|
75
|
+
className: g(a["tedi-pagination__button"], a["tedi-pagination__button--nav"]),
|
|
76
|
+
"aria-label": U,
|
|
77
|
+
onClick: () => e.page !== null && N(e.page),
|
|
78
|
+
noStyle: !0,
|
|
79
|
+
children: /* @__PURE__ */ i(G, { name: q, size: 18, color: "brand" })
|
|
80
|
+
}
|
|
81
|
+
) }, e.type);
|
|
82
|
+
}
|
|
83
|
+
const r = e.page;
|
|
84
|
+
return /* @__PURE__ */ i("li", { className: a["tedi-pagination__item"], children: /* @__PURE__ */ i(
|
|
85
|
+
z,
|
|
86
|
+
{
|
|
87
|
+
type: "button",
|
|
88
|
+
className: g(a["tedi-pagination__button"], {
|
|
89
|
+
[a["tedi-pagination__button--selected"]]: e.selected
|
|
90
|
+
}),
|
|
91
|
+
"aria-label": e.selected ? n.currentPageAriaLabel(r) : n.pageAriaLabel(r),
|
|
92
|
+
"aria-current": e.selected ? "page" : void 0,
|
|
93
|
+
onClick: () => N(r),
|
|
94
|
+
noStyle: !0,
|
|
95
|
+
children: r
|
|
96
|
+
}
|
|
97
|
+
) }, r);
|
|
98
|
+
}) }) }) }),
|
|
99
|
+
/* @__PURE__ */ i("div", { className: a["tedi-pagination__slot-end"], children: T && /* @__PURE__ */ v("div", { className: a["tedi-pagination__page-size"], children: [
|
|
100
|
+
/* @__PURE__ */ i(
|
|
101
|
+
S,
|
|
102
|
+
{
|
|
103
|
+
className: a["tedi-pagination__page-size-label"],
|
|
104
|
+
color: "secondary",
|
|
105
|
+
modifiers: "small",
|
|
106
|
+
element: "span",
|
|
107
|
+
children: n.pageSize
|
|
108
|
+
}
|
|
109
|
+
),
|
|
110
|
+
/* @__PURE__ */ i(
|
|
111
|
+
H,
|
|
112
|
+
{
|
|
113
|
+
id: `tedi-pagination-page-size-${j}`,
|
|
114
|
+
className: a["tedi-pagination__select"],
|
|
115
|
+
label: n.pageSize,
|
|
116
|
+
hideLabel: !0,
|
|
117
|
+
size: "small",
|
|
118
|
+
options: d,
|
|
119
|
+
value: R,
|
|
120
|
+
onChange: $,
|
|
121
|
+
isSearchable: !1,
|
|
122
|
+
isClearable: !1
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
] }) })
|
|
126
|
+
] });
|
|
127
|
+
});
|
|
128
|
+
Q.displayName = "Pagination";
|
|
129
|
+
export {
|
|
130
|
+
Q as Pagination
|
|
131
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i={"tedi-pagination":"tedi-pagination-96c6fc62","tedi-pagination__slot-start":"tedi-pagination__slot-start-846e7900","tedi-pagination__slot-center":"tedi-pagination__slot-center-e489623b","tedi-pagination__slot-end":"tedi-pagination__slot-end-3f4f5848","tedi-pagination__results":"tedi-pagination__results-29d9108c","tedi-pagination__nav":"tedi-pagination__nav-5f414114","tedi-pagination__list":"tedi-pagination__list-03467ce1","tedi-pagination__item":"tedi-pagination__item-46985c58","tedi-pagination__item--ellipsis":"tedi-pagination__item--ellipsis-85f798f5","tedi-pagination__button":"tedi-pagination__button-d06c27d4","tedi-pagination__button--selected":"tedi-pagination__button--selected-cb151c7f","tedi-pagination__button--nav":"tedi-pagination__button--nav-2f74eea2","tedi-pagination__page-size":"tedi-pagination__page-size-d1fa6f9d","tedi-pagination__page-size-label":"tedi-pagination__page-size-label-3dc2d141","tedi-pagination__select":"tedi-pagination__select-435e167e"};exports.default=i;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const i = {
|
|
2
|
+
"tedi-pagination": "tedi-pagination-96c6fc62",
|
|
3
|
+
"tedi-pagination__slot-start": "tedi-pagination__slot-start-846e7900",
|
|
4
|
+
"tedi-pagination__slot-center": "tedi-pagination__slot-center-e489623b",
|
|
5
|
+
"tedi-pagination__slot-end": "tedi-pagination__slot-end-3f4f5848",
|
|
6
|
+
"tedi-pagination__results": "tedi-pagination__results-29d9108c",
|
|
7
|
+
"tedi-pagination__nav": "tedi-pagination__nav-5f414114",
|
|
8
|
+
"tedi-pagination__list": "tedi-pagination__list-03467ce1",
|
|
9
|
+
"tedi-pagination__item": "tedi-pagination__item-46985c58",
|
|
10
|
+
"tedi-pagination__item--ellipsis": "tedi-pagination__item--ellipsis-85f798f5",
|
|
11
|
+
"tedi-pagination__button": "tedi-pagination__button-d06c27d4",
|
|
12
|
+
"tedi-pagination__button--selected": "tedi-pagination__button--selected-cb151c7f",
|
|
13
|
+
"tedi-pagination__button--nav": "tedi-pagination__button--nav-2f74eea2",
|
|
14
|
+
"tedi-pagination__page-size": "tedi-pagination__page-size-d1fa6f9d",
|
|
15
|
+
"tedi-pagination__page-size-label": "tedi-pagination__page-size-label-3dc2d141",
|
|
16
|
+
"tedi-pagination__select": "tedi-pagination__select-435e167e"
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
i as default
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=(r,e)=>e<r?[]:Array.from({length:e-r+1},(c,n)=>r+n);function m({page:r,pageCount:e,boundaryCount:c=1,siblingCount:n=1}){if(e<=0)return[];const l=Math.max(0,c),t=Math.max(0,n),s=Math.max(1,Math.min(e,r)),f=l*2+t*2+3;let d;if(e<=f)d=i(1,e);else{const a=l+t*2+2,o=l+t+2,h=e-l-t-1;s<=o?d=[...i(1,a),"ellipsis",...i(e-l+1,e)]:s>=h?d=[...i(1,l),"ellipsis",...i(e-a+1,e)]:d=[...i(1,l),"ellipsis",...i(s-t,s+t),"ellipsis",...i(e-l+1,e)]}return[{type:"previous",page:s>1?s-1:null,selected:!1,disabled:s<=1},...d.map(a=>a==="ellipsis"?{type:"ellipsis",page:null,selected:!1,disabled:!0}:{type:"page",page:a,selected:a===s,disabled:!1}),{type:"next",page:s<e?s+1:null,selected:!1,disabled:s>=e}]}exports.usePagination=m;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PaginationItem } from './pagination';
|
|
2
|
+
export interface UsePaginationArgs {
|
|
3
|
+
/** 1-based current page. */
|
|
4
|
+
page: number;
|
|
5
|
+
/** Total page count. */
|
|
6
|
+
pageCount: number;
|
|
7
|
+
/** Pages always shown at the very start and very end. */
|
|
8
|
+
boundaryCount?: number;
|
|
9
|
+
/** Pages shown on either side of the current page. */
|
|
10
|
+
siblingCount?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Computes the ordered list of pagination items (previous, page-buttons,
|
|
14
|
+
* ellipsis, next).
|
|
15
|
+
*
|
|
16
|
+
* The algorithm targets a stable slot count: for any `pageCount` larger than
|
|
17
|
+
* the window size, the returned list always has the same number of page
|
|
18
|
+
* entries (`boundaryCount * 2 + siblingCount * 2 + 3`). As the current page
|
|
19
|
+
* moves toward a boundary, the corresponding ellipsis is swapped for an extra
|
|
20
|
+
* adjacent page number rather than collapsing the list — the visual row does
|
|
21
|
+
* not expand or contract as the user navigates.
|
|
22
|
+
*
|
|
23
|
+
* Edge cases:
|
|
24
|
+
* - `pageCount <= 0` → returns `[]`.
|
|
25
|
+
* - `page` is clamped to `[1, pageCount]` before computation.
|
|
26
|
+
* - `pageCount <= window size` → every page is rendered, no ellipsis.
|
|
27
|
+
*/
|
|
28
|
+
export declare function usePagination({ page, pageCount, boundaryCount, siblingCount, }: UsePaginationArgs): PaginationItem[];
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const i = (d, e) => e < d ? [] : Array.from({ length: e - d + 1 }, (n, c) => d + c);
|
|
2
|
+
function o({
|
|
3
|
+
page: d,
|
|
4
|
+
pageCount: e,
|
|
5
|
+
boundaryCount: n = 1,
|
|
6
|
+
siblingCount: c = 1
|
|
7
|
+
}) {
|
|
8
|
+
if (e <= 0) return [];
|
|
9
|
+
const l = Math.max(0, n), t = Math.max(0, c), s = Math.max(1, Math.min(e, d)), f = l * 2 + t * 2 + 3;
|
|
10
|
+
let r;
|
|
11
|
+
if (e <= f)
|
|
12
|
+
r = i(1, e);
|
|
13
|
+
else {
|
|
14
|
+
const a = l + t * 2 + 2, h = l + t + 2, m = e - l - t - 1;
|
|
15
|
+
s <= h ? r = [...i(1, a), "ellipsis", ...i(e - l + 1, e)] : s >= m ? r = [...i(1, l), "ellipsis", ...i(e - a + 1, e)] : r = [
|
|
16
|
+
...i(1, l),
|
|
17
|
+
"ellipsis",
|
|
18
|
+
...i(s - t, s + t),
|
|
19
|
+
"ellipsis",
|
|
20
|
+
...i(e - l + 1, e)
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
type: "previous",
|
|
26
|
+
page: s > 1 ? s - 1 : null,
|
|
27
|
+
selected: !1,
|
|
28
|
+
disabled: s <= 1
|
|
29
|
+
},
|
|
30
|
+
...r.map(
|
|
31
|
+
(a) => a === "ellipsis" ? { type: "ellipsis", page: null, selected: !1, disabled: !0 } : {
|
|
32
|
+
type: "page",
|
|
33
|
+
page: a,
|
|
34
|
+
selected: a === s,
|
|
35
|
+
disabled: !1
|
|
36
|
+
}
|
|
37
|
+
),
|
|
38
|
+
{
|
|
39
|
+
type: "next",
|
|
40
|
+
page: s < e ? s + 1 : null,
|
|
41
|
+
selected: !1,
|
|
42
|
+
disabled: s >= e
|
|
43
|
+
}
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
o as usePagination
|
|
48
|
+
};
|
package/src/tedi/index.d.ts
CHANGED
|
@@ -21,10 +21,12 @@ export * from './components/buttons/collapse/collapse';
|
|
|
21
21
|
export * from './components/layout/vertical-spacing';
|
|
22
22
|
export * from './components/layout/grid';
|
|
23
23
|
export * from './components/notifications/alert/alert';
|
|
24
|
+
export * from './components/misc/empty-state';
|
|
24
25
|
export * from './components/notifications/toast/toast';
|
|
25
26
|
export * from './components/cards/card';
|
|
26
27
|
export * from './components/navigation/hash-trigger/hash-trigger';
|
|
27
28
|
export * from './components/navigation/link/link';
|
|
29
|
+
export * from './components/navigation/pagination';
|
|
28
30
|
export * from './components/navigation/tabs';
|
|
29
31
|
export * from './components/form/textfield/textfield';
|
|
30
32
|
export * from './components/form/textarea/textarea';
|