@tedi-design-system/react 19.1.0-rc.1 → 19.1.0-rc.3
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/DESIGN.md +308 -0
- package/README.md +28 -0
- package/bundle-stats.html +1 -1
- package/component.manifest.json +1191 -0
- package/index.css +1 -1
- package/package.json +1 -1
- package/src/community/components/layout/sidenav/sidenav.cjs.js +1 -1
- package/src/community/components/layout/sidenav/sidenav.es.js +38 -40
- package/src/tedi/components/content/collapse/collapse.cjs.js +1 -1
- package/src/tedi/components/content/collapse/collapse.d.ts +9 -0
- package/src/tedi/components/content/collapse/collapse.es.js +44 -35
- package/src/tedi/components/filter/filter/filter.cjs.js +1 -1
- package/src/tedi/components/filter/filter/filter.d.ts +5 -0
- package/src/tedi/components/filter/filter/filter.es.js +154 -144
- package/src/tedi/components/filter/filter/filter.module.scss.cjs.js +1 -1
- package/src/tedi/components/filter/filter/filter.module.scss.es.js +2 -1
- package/src/tedi/components/layout/sidenav/components/sidenav-item/sidenav-item.cjs.js +1 -1
- package/src/tedi/components/layout/sidenav/components/sidenav-item/sidenav-item.es.js +82 -85
- package/src/tedi/components/layout/sidenav/sidenav.cjs.js +1 -1
- package/src/tedi/components/layout/sidenav/sidenav.es.js +16 -16
- package/src/tedi/components/layout/top-nav/components/top-nav-item/top-nav-item.cjs.js +1 -1
- package/src/tedi/components/layout/top-nav/components/top-nav-item/top-nav-item.es.js +6 -7
- package/src/tedi/components/layout/top-nav/components/top-nav-separator/top-nav-separator.cjs.js +1 -1
- package/src/tedi/components/layout/top-nav/components/top-nav-separator/top-nav-separator.es.js +2 -2
- package/src/tedi/components/layout/top-nav/top-nav.cjs.js +1 -1
- package/src/tedi/components/layout/top-nav/top-nav.es.js +9 -8
- package/src/tedi/components/overlays/dropdown/dropdown.cjs.js +1 -1
- package/src/tedi/components/overlays/dropdown/dropdown.d.ts +8 -0
- package/src/tedi/components/overlays/dropdown/dropdown.es.js +82 -74
- package/src/tedi/components/overlays/dropdown/dropdown.module.scss.cjs.js +1 -1
- package/src/tedi/components/overlays/dropdown/dropdown.module.scss.es.js +1 -0
- package/src/tedi/helpers/hooks/use-safe-id.cjs.js +1 -0
- package/src/tedi/helpers/hooks/use-safe-id.d.ts +16 -0
- package/src/tedi/helpers/hooks/use-safe-id.es.js +5 -0
- package/src/tedi/helpers/index.d.ts +1 -0
- package/tedi.cjs.js +1 -1
- package/tedi.es.js +10 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tedi-design-system/react",
|
|
3
|
-
"version": "19.1.0-rc.
|
|
3
|
+
"version": "19.1.0-rc.3",
|
|
4
4
|
"description": "TEDI Design System React component library — accessible, reusable UI components. Docs & live examples: https://storybook.tedi.ee/react/rc/",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),d=require("react"),S=require("../../../../../external/@floating-ui/react/dist/floating-ui.react.cjs.js"),h=require("../../../../../external/classnames/index.cjs.js"),T=require("../../../../tedi/components/base/icon/icon.cjs.js"),L=require("../../../../tedi/components/content/collapse/collapse.cjs.js"),P=require("../../../../tedi/components/misc/print/print.cjs.js"),q=require("../../../helpers/hooks/use-layout.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),d=require("react"),S=require("../../../../../external/@floating-ui/react/dist/floating-ui.react.cjs.js"),h=require("../../../../../external/classnames/index.cjs.js"),T=require("../../../../tedi/components/base/icon/icon.cjs.js"),L=require("../../../../tedi/components/content/collapse/collapse.cjs.js"),P=require("../../../../tedi/components/misc/print/print.cjs.js"),q=require("../../../helpers/hooks/use-layout.cjs.js"),A=require("../../anchor/anchor.cjs.js"),C=require("../layout-context.cjs.js"),a=require("./sidenav.module.scss.cjs.js"),B=require("./utility.cjs.js"),F=n=>requestAnimationFrame(n),I=n=>{const{navItems:l,ariaLabel:r,linkAs:i,breakToBottomContent:c,breakToHeader:x,showDividers:u=!0,hideSubItemIcons:m=!1,className:v,..._}=n,p=q.default(["mobile","tablet"]),{menuOpen:g,context:y,getFloatingProps:f,floating:N,headerType:e,y:s}=d.useContext(C.LayoutContext),{hasSidenav:o}=B.useSidenavRendered(e,n);if(!o)return null;const b=h.default(a.default.sidenav,v,{[a.default["sidenav--has-dividers"]]:u,[a.default["sidenav--hide-subitem-icons"]]:m}),j=t.jsx(P.Print,{visibility:"hide",children:t.jsx("nav",{"data-name":"sidenav",..._,className:b,"aria-label":r,children:t.jsx("ul",{className:a.default.sidenav__list,children:l.map((E,M)=>d.createElement(k,{as:i,...E,key:M}))})})});return p?g?t.jsx(S.FloatingOverlay,{lockScroll:!0,className:a.default.sidenav__overlay,children:t.jsx(S.FloatingFocusManager,{context:y,order:["reference","content"],children:t.jsx("div",{...f({style:{paddingTop:s??0},className:a.default.sidenav,"aria-label":r}),ref:N,children:j})})}):null:j},k=n=>{const{icon:l,children:r,isActive:i,onClick:c,subItems:x,as:u,...m}=n,{toggleMenu:v,onHeaderSidenavToggle:_}=d.useContext(C.LayoutContext),p=q.default(["mobile","tablet"]),g=h.default(a.default.sidenav__item,{[a.default["sidenav__item--current"]]:i}),y=d.useId(),f=e=>{const o={className:h.default(a.default.sidenav__icon)},b=typeof e=="string"?{...o,name:e,color:"inherit"}:{...o,...e,className:h.default(o.className,e==null?void 0:e.className),background:void 0};return t.jsx(T.Icon,{...b})},N=e=>{c==null||c(e),e.stopPropagation(),typeof _=="function"||(p?F(()=>v()):v())};return t.jsx("li",{"data-name":"sidenav-item",className:g,children:x?t.jsx(L.Collapse,{id:y,hideCollapseText:!0,contentAsRegion:!1,open:i,title:t.jsxs("span",{...(({_href:e,...s})=>s)(m),className:a.default.sidenav__link,"aria-current":i?"page":void 0,children:[l&&f(l),t.jsx("span",{className:a.default.sidenav__title,children:r})]}),children:t.jsx("ul",{className:a.default.sidenav__list,children:x.map((e,s)=>d.createElement(k,{as:u,...e,key:s}))})}):t.jsxs(A.Anchor,{...m,as:u,onClick:N,className:a.default.sidenav__link,noStyle:!0,"aria-current":i?"page":void 0,children:[l&&f(l),t.jsx("span",{className:a.default.sidenav__title,children:r})]})})};exports.SideNav=I;exports.default=I;
|
|
@@ -1,98 +1,96 @@
|
|
|
1
1
|
import { jsx as t, jsxs as x } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { FloatingOverlay as
|
|
4
|
-
import
|
|
5
|
-
import { Icon as
|
|
6
|
-
import { Collapse as
|
|
7
|
-
import { Print as
|
|
2
|
+
import b, { createElement as C } from "react";
|
|
3
|
+
import { FloatingOverlay as B, FloatingFocusManager as F } from "../../../../../external/@floating-ui/react/dist/floating-ui.react.es.js";
|
|
4
|
+
import p from "../../../../../external/classnames/index.es.js";
|
|
5
|
+
import { Icon as L } from "../../../../tedi/components/base/icon/icon.es.js";
|
|
6
|
+
import { Collapse as P } from "../../../../tedi/components/content/collapse/collapse.es.js";
|
|
7
|
+
import { Print as R } from "../../../../tedi/components/misc/print/print.es.js";
|
|
8
8
|
import k from "../../../helpers/hooks/use-layout.es.js";
|
|
9
|
-
import { Anchor as
|
|
9
|
+
import { Anchor as j } from "../../anchor/anchor.es.js";
|
|
10
10
|
import { LayoutContext as E } from "../layout-context.es.js";
|
|
11
11
|
import a from "./sidenav.module.scss.es.js";
|
|
12
|
-
import { useSidenavRendered as
|
|
13
|
-
const
|
|
12
|
+
import { useSidenavRendered as H } from "./utility.es.js";
|
|
13
|
+
const O = (n) => requestAnimationFrame(n), Y = (n) => {
|
|
14
14
|
const {
|
|
15
15
|
navItems: i,
|
|
16
|
-
ariaLabel:
|
|
17
|
-
linkAs:
|
|
16
|
+
ariaLabel: r,
|
|
17
|
+
linkAs: o,
|
|
18
18
|
breakToBottomContent: c,
|
|
19
19
|
breakToHeader: f,
|
|
20
20
|
showDividers: d = !0,
|
|
21
21
|
hideSubItemIcons: m = !1,
|
|
22
22
|
className: u,
|
|
23
23
|
...h
|
|
24
|
-
} =
|
|
24
|
+
} = n, _ = k(["mobile", "tablet"]), { menuOpen: N, context: g, getFloatingProps: v, floating: S, headerType: e, y: s } = b.useContext(E), { hasSidenav: l } = H(e, n);
|
|
25
25
|
if (!l)
|
|
26
26
|
return null;
|
|
27
|
-
const
|
|
27
|
+
const y = p(a.sidenav, u, {
|
|
28
28
|
[a["sidenav--has-dividers"]]: d,
|
|
29
29
|
[a["sidenav--hide-subitem-icons"]]: m
|
|
30
|
-
}), I = /* @__PURE__ */ t(
|
|
31
|
-
return _ ? N ? /* @__PURE__ */ t(
|
|
30
|
+
}), I = /* @__PURE__ */ t(R, { visibility: "hide", children: /* @__PURE__ */ t("nav", { "data-name": "sidenav", ...h, className: y, "aria-label": r, children: /* @__PURE__ */ t("ul", { className: a.sidenav__list, children: i.map((T, A) => /* @__PURE__ */ C(M, { as: o, ...T, key: A })) }) }) });
|
|
31
|
+
return _ ? N ? /* @__PURE__ */ t(B, { lockScroll: !0, className: a.sidenav__overlay, children: /* @__PURE__ */ t(F, { context: g, order: ["reference", "content"], children: /* @__PURE__ */ t(
|
|
32
32
|
"div",
|
|
33
33
|
{
|
|
34
|
-
...
|
|
34
|
+
...v({
|
|
35
35
|
style: {
|
|
36
|
-
paddingTop:
|
|
36
|
+
paddingTop: s ?? 0
|
|
37
37
|
},
|
|
38
38
|
className: a.sidenav,
|
|
39
|
-
"aria-label":
|
|
39
|
+
"aria-label": r
|
|
40
40
|
}),
|
|
41
41
|
ref: S,
|
|
42
42
|
children: I
|
|
43
43
|
}
|
|
44
44
|
) }) }) : null : I;
|
|
45
|
-
}, M = (
|
|
46
|
-
const { icon: i, children:
|
|
47
|
-
const l = { className:
|
|
45
|
+
}, M = (n) => {
|
|
46
|
+
const { icon: i, children: r, isActive: o, onClick: c, subItems: f, as: d, ...m } = n, { toggleMenu: u, onHeaderSidenavToggle: h } = b.useContext(E), _ = k(["mobile", "tablet"]), N = p(a.sidenav__item, { [a["sidenav__item--current"]]: o }), g = b.useId(), v = (e) => {
|
|
47
|
+
const l = { className: p(a.sidenav__icon) }, y = typeof e == "string" ? { ...l, name: e, color: "inherit" } : {
|
|
48
48
|
...l,
|
|
49
49
|
...e,
|
|
50
|
-
className:
|
|
50
|
+
className: p(l.className, e == null ? void 0 : e.className),
|
|
51
51
|
background: void 0
|
|
52
52
|
};
|
|
53
|
-
return /* @__PURE__ */ t(
|
|
53
|
+
return /* @__PURE__ */ t(L, { ...y });
|
|
54
54
|
};
|
|
55
|
-
return /* @__PURE__ */ t("li", { "data-name": "sidenav-item", className: N,
|
|
56
|
-
|
|
55
|
+
return /* @__PURE__ */ t("li", { "data-name": "sidenav-item", className: N, children: f ? /* @__PURE__ */ t(
|
|
56
|
+
P,
|
|
57
57
|
{
|
|
58
|
-
id:
|
|
58
|
+
id: g,
|
|
59
59
|
hideCollapseText: !0,
|
|
60
|
-
|
|
60
|
+
contentAsRegion: !1,
|
|
61
|
+
open: o,
|
|
61
62
|
title: /* @__PURE__ */ x(
|
|
62
63
|
"span",
|
|
63
64
|
{
|
|
64
|
-
...(({ _href: e, ...
|
|
65
|
+
...(({ _href: e, ...s }) => s)(m),
|
|
65
66
|
className: a.sidenav__link,
|
|
66
|
-
|
|
67
|
-
role: "menuitem",
|
|
68
|
-
"aria-current": r ? "page" : void 0,
|
|
67
|
+
"aria-current": o ? "page" : void 0,
|
|
69
68
|
children: [
|
|
70
|
-
i &&
|
|
71
|
-
/* @__PURE__ */ t("span", { className: a.sidenav__title, children:
|
|
69
|
+
i && v(i),
|
|
70
|
+
/* @__PURE__ */ t("span", { className: a.sidenav__title, children: r })
|
|
72
71
|
]
|
|
73
72
|
}
|
|
74
73
|
),
|
|
75
|
-
children: /* @__PURE__ */ t("ul", { className: a.sidenav__list,
|
|
74
|
+
children: /* @__PURE__ */ t("ul", { className: a.sidenav__list, children: f.map((e, s) => /* @__PURE__ */ C(M, { as: d, ...e, key: s })) })
|
|
76
75
|
}
|
|
77
76
|
) : (
|
|
78
77
|
// // TODO: Remove ts-ignore
|
|
79
78
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
80
79
|
// @ts-ignore
|
|
81
80
|
/* @__PURE__ */ x(
|
|
82
|
-
|
|
81
|
+
j,
|
|
83
82
|
{
|
|
84
83
|
...m,
|
|
85
84
|
as: d,
|
|
86
85
|
onClick: (e) => {
|
|
87
|
-
c == null || c(e), e.stopPropagation(), typeof h == "function" || (_ ?
|
|
86
|
+
c == null || c(e), e.stopPropagation(), typeof h == "function" || (_ ? O(() => u()) : u());
|
|
88
87
|
},
|
|
89
88
|
className: a.sidenav__link,
|
|
90
89
|
noStyle: !0,
|
|
91
|
-
|
|
92
|
-
"aria-current": r ? "page" : void 0,
|
|
90
|
+
"aria-current": o ? "page" : void 0,
|
|
93
91
|
children: [
|
|
94
|
-
i &&
|
|
95
|
-
/* @__PURE__ */ t("span", { className: a.sidenav__title, children:
|
|
92
|
+
i && v(i),
|
|
93
|
+
/* @__PURE__ */ t("span", { className: a.sidenav__title, children: r })
|
|
96
94
|
]
|
|
97
95
|
}
|
|
98
96
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),b=require("../../../../../external/classnames/index.cjs.js"),n=require("react"),K=require("../../../../../external/react-animate-height/dist/esm/index.cjs.js"),Q=require("../../../providers/printing-provider/printing-provider.cjs.js"),U=require("../../buttons/collapse-button/collapse-button.cjs.js"),V=require("../../misc/print/print.cjs.js"),s=require("./collapse.module.scss.cjs.js"),W=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),X=require("../../layout/grid/row.cjs.js"),q=require("../../layout/grid/col.cjs.js"),w=d=>{const{getCurrentBreakpointProps:O}=W.useBreakpointProps(d.defaultServerBreakpoint),{id:l,children:P,className:k,openText:y,closeText:I,hideCollapseText:T=!1,title:o,titleRowProps:B,defaultOpen:S,open:u,onToggle:i,arrowType:E="default",size:N="default",underline:$=!0,toggleLabel:p,iconOnly:L=!1,controlsId:f,inverted:M=!1,fullRowToggle:a=!1,contentAsRegion:z=!0,...A}=O(d),g=f!==void 0,h=`${l}__trigger`,x=`${l}__content`,D=`${l}__animate`,[F,G]=n.useState(()=>S??!1),v=Q.usePrint(),r=v||(u!==void 0?u:F),H=L===!0&&!o,_=n.useRef(null),c=t=>{G(t),i==null||i(t)},m=n.useRef(c);m.current=c;const j=n.useRef(r);j.current=r,n.useEffect(()=>{const t=_.current;if(!a||!t)return;const R=J=>{J.target.closest("a, button, input, select, textarea, label")||m.current(!j.current)};return t.addEventListener("click",R),()=>t.removeEventListener("click",R)},[a]);const C=e.jsx("div",{id:x,...z?{role:"region","aria-labelledby":h}:{},className:s.default["tedi-collapse__content"],children:P});return e.jsxs("div",{"data-name":"collapse",...A,className:b.default(s.default["tedi-collapse"],k),children:[e.jsx("div",{ref:_,className:b.default(s.default["tedi-collapse__header"],{[s.default["tedi-collapse__header--clickable"]]:a}),children:e.jsxs(X.Row,{justifyContent:"between",alignItems:"center",wrap:"nowrap",...B,children:[o&&e.jsx(q.Col,{children:o}),e.jsx(q.Col,{width:"auto",children:e.jsx(V.Print,{visibility:"hide",children:e.jsx(U.CollapseButton,{id:h,open:r,onOpenChange:c,openText:y,closeText:I,hideText:T||H,arrowType:E,size:N,inverted:M,underline:$,"aria-controls":g?f:x,...p?{"aria-label":p}:{}})})})]})}),!g&&(v?C:e.jsx(K.default,{id:D,duration:300,height:r?"auto":0,"data-testid":"collapse-inner",children:C}))]})};exports.Collapse=w;exports.default=w;
|
|
@@ -116,6 +116,15 @@ export interface CollapseProps extends BreakpointSupport<CollapseBreakpointProps
|
|
|
116
116
|
* built-in `role="region"` panel.
|
|
117
117
|
*/
|
|
118
118
|
controlsId?: string;
|
|
119
|
+
/**
|
|
120
|
+
* Whether the disclosed content panel is exposed as a `region` landmark
|
|
121
|
+
* (`role="region"` + `aria-labelledby`). Turn this **off** for repeated or
|
|
122
|
+
* nested disclosures such as navigation sub-menus, where many labelled regions
|
|
123
|
+
* pollute the landmark map and collide (axe `landmark-unique`); the
|
|
124
|
+
* `aria-expanded` toggle already conveys the relationship.
|
|
125
|
+
* @default true
|
|
126
|
+
*/
|
|
127
|
+
contentAsRegion?: boolean;
|
|
119
128
|
}
|
|
120
129
|
export declare const Collapse: (props: CollapseProps) => JSX.Element;
|
|
121
130
|
export default Collapse;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsxs as x, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import y from "../../../../../external/classnames/index.es.js";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { usePrint as
|
|
6
|
-
import { CollapseButton as
|
|
7
|
-
import { Print as
|
|
3
|
+
import n from "react";
|
|
4
|
+
import M from "../../../../../external/react-animate-height/dist/esm/index.es.js";
|
|
5
|
+
import { usePrint as Q } from "../../../providers/printing-provider/printing-provider.es.js";
|
|
6
|
+
import { CollapseButton as U } from "../../buttons/collapse-button/collapse-button.es.js";
|
|
7
|
+
import { Print as V } from "../../misc/print/print.es.js";
|
|
8
8
|
import o from "./collapse.module.scss.es.js";
|
|
9
|
-
import { useBreakpointProps as
|
|
10
|
-
import { Row as
|
|
9
|
+
import { useBreakpointProps as W } from "../../../helpers/hooks/use-breakpoint-props.es.js";
|
|
10
|
+
import { Row as X } from "../../layout/grid/row.es.js";
|
|
11
11
|
import { Col as O } from "../../layout/grid/col.es.js";
|
|
12
|
-
const
|
|
13
|
-
const { getCurrentBreakpointProps: k } =
|
|
12
|
+
const ce = (d) => {
|
|
13
|
+
const { getCurrentBreakpointProps: k } = W(d.defaultServerBreakpoint), {
|
|
14
14
|
id: i,
|
|
15
15
|
children: I,
|
|
16
16
|
className: P,
|
|
@@ -25,27 +25,36 @@ const ae = (d) => {
|
|
|
25
25
|
arrowType: L = "default",
|
|
26
26
|
size: S = "default",
|
|
27
27
|
underline: $ = !0,
|
|
28
|
-
toggleLabel:
|
|
29
|
-
iconOnly:
|
|
30
|
-
controlsId:
|
|
31
|
-
inverted:
|
|
28
|
+
toggleLabel: u,
|
|
29
|
+
iconOnly: A = !1,
|
|
30
|
+
controlsId: f,
|
|
31
|
+
inverted: z = !1,
|
|
32
32
|
fullRowToggle: a = !1,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
contentAsRegion: H = !0,
|
|
34
|
+
...q
|
|
35
|
+
} = k(d), m = f !== void 0, h = `${i}__trigger`, g = `${i}__content`, D = `${i}__animate`, [F, G] = n.useState(() => j ?? !1), _ = Q(), r = _ || (p !== void 0 ? p : F), J = A === !0 && !l, v = n.useRef(null), c = (t) => {
|
|
36
|
+
G(t), s == null || s(t);
|
|
37
|
+
}, R = n.useRef(c);
|
|
38
|
+
R.current = c;
|
|
39
|
+
const C = n.useRef(r);
|
|
40
|
+
C.current = r, n.useEffect(() => {
|
|
40
41
|
const t = v.current;
|
|
41
42
|
if (!a || !t) return;
|
|
42
|
-
const w = (
|
|
43
|
-
|
|
43
|
+
const w = (K) => {
|
|
44
|
+
K.target.closest("a, button, input, select, textarea, label") || R.current(!C.current);
|
|
44
45
|
};
|
|
45
46
|
return t.addEventListener("click", w), () => t.removeEventListener("click", w);
|
|
46
47
|
}, [a]);
|
|
47
|
-
const b = /* @__PURE__ */ e(
|
|
48
|
-
|
|
48
|
+
const b = /* @__PURE__ */ e(
|
|
49
|
+
"div",
|
|
50
|
+
{
|
|
51
|
+
id: g,
|
|
52
|
+
...H ? { role: "region", "aria-labelledby": h } : {},
|
|
53
|
+
className: o["tedi-collapse__content"],
|
|
54
|
+
children: I
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
return /* @__PURE__ */ x("div", { "data-name": "collapse", ...q, className: y(o["tedi-collapse"], P), children: [
|
|
49
58
|
/* @__PURE__ */ e(
|
|
50
59
|
"div",
|
|
51
60
|
{
|
|
@@ -53,32 +62,32 @@ const ae = (d) => {
|
|
|
53
62
|
className: y(o["tedi-collapse__header"], {
|
|
54
63
|
[o["tedi-collapse__header--clickable"]]: a
|
|
55
64
|
}),
|
|
56
|
-
children: /* @__PURE__ */ x(
|
|
65
|
+
children: /* @__PURE__ */ x(X, { justifyContent: "between", alignItems: "center", wrap: "nowrap", ...E, children: [
|
|
57
66
|
l && /* @__PURE__ */ e(O, { children: l }),
|
|
58
|
-
/* @__PURE__ */ e(O, { width: "auto", children: /* @__PURE__ */ e(
|
|
59
|
-
|
|
67
|
+
/* @__PURE__ */ e(O, { width: "auto", children: /* @__PURE__ */ e(V, { visibility: "hide", children: /* @__PURE__ */ e(
|
|
68
|
+
U,
|
|
60
69
|
{
|
|
61
70
|
id: h,
|
|
62
|
-
open:
|
|
71
|
+
open: r,
|
|
63
72
|
onOpenChange: c,
|
|
64
73
|
openText: T,
|
|
65
74
|
closeText: N,
|
|
66
|
-
hideText: B ||
|
|
75
|
+
hideText: B || J,
|
|
67
76
|
arrowType: L,
|
|
68
77
|
size: S,
|
|
69
|
-
inverted:
|
|
78
|
+
inverted: z,
|
|
70
79
|
underline: $,
|
|
71
|
-
"aria-controls": m ?
|
|
72
|
-
...
|
|
80
|
+
"aria-controls": m ? f : g,
|
|
81
|
+
...u ? { "aria-label": u } : {}
|
|
73
82
|
}
|
|
74
83
|
) }) })
|
|
75
84
|
] })
|
|
76
85
|
}
|
|
77
86
|
),
|
|
78
|
-
!m && (_ ? b : /* @__PURE__ */ e(
|
|
87
|
+
!m && (_ ? b : /* @__PURE__ */ e(M, { id: D, duration: 300, height: r ? "auto" : 0, "data-testid": "collapse-inner", children: b }))
|
|
79
88
|
] });
|
|
80
89
|
};
|
|
81
90
|
export {
|
|
82
|
-
|
|
83
|
-
|
|
91
|
+
ce as Collapse,
|
|
92
|
+
ce as default
|
|
84
93
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),W=require("../../../../../external/classnames/index.cjs.js"),l=require("react"),ue=require("../../base/icon/icon.cjs.js"),Z=require("../../buttons/button/button.cjs.js"),fe=require("../../form/checkbox/checkbox.cjs.js"),Ze=require("../../form/search/search.cjs.js"),c=require("../../overlays/dropdown/dropdown.cjs.js"),Je=require("../../tags/status-badge/status-badge.cjs.js"),r=require("./filter.module.scss.cjs.js"),Ke=require("./filter-group-context.cjs.js"),Qe=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),Ue=require("../../../providers/label-provider/use-labels.cjs.js"),he=b=>b==="large"?24:18,Ve=b=>{const x=l.useId();return b??`tedi-filter-${x.replace(/[^a-zA-Z0-9-]/g,"")}`},pe=l.forwardRef((b,x)=>{const{getCurrentBreakpointProps:me}=Qe.useBreakpointProps(b.defaultServerBreakpoint),{text:g,value:_,disabled:xe=!1,className:ve,id:J,selected:k,defaultSelected:K=!1,onSelectedChange:C,selectedValue:j,defaultSelectedValue:be,onSelectedValueChange:u,multiselect:Q=!1,selectedValues:f,defaultSelectedValues:ge,onSelectedValuesChange:a,options:S=[],searchable:je=!1,showSelectAll:Se=!1,selectAllLabel:we,showClear:U=!1,clearLabel:_e,preserveLabel:V=!1,children:X,onClear:B,prepend:D,hidePrependWhenSelected:ke=!0,append:P,placement:Ce="bottom-start",variant:Le="primary",size:$="default",searchLabel:Y,maxHeight:M}=me(b),{getLabel:ee}=Ue.useLabels(),ye=we??ee("filter.select-all"),te=_e??ee("filter.clear-selection"),L=M===void 0?void 0:typeof M=="number"?`${M}px`:M,i=l.useContext(Ke.FilterGroupContext),y=Ve(J),Ne=l.useRef(null),O=S.length>0,N=!!X,v=O||N,h=O&&!Q,p=O&&Q,F=!!(i!=null&&i.isManaged)&&_!==void 0&&!v,T=F&&!(i!=null&&i.multiselect),le=xe||((i==null?void 0:i.disabled)??!1),[Fe,Be]=l.useState(K),[Me,se]=l.useState(be??""),[qe,z]=l.useState(ge??[]);N&&(K||C)&&k===void 0&&console.warn("[Filter] `defaultSelected` and `onSelectedChange` are not honoured in custom-content mode (when `children` is provided). Drive the selected state yourself via the controlled `selected` prop, e.g. `selected={Boolean(value)}`.");const q=k!==void 0?k:Fe,m=j!==void 0?j:Me,n=f!==void 0?f:qe,w=l.useMemo(()=>F?i.isSelected(_):p?n.length>0:h?m!=="":q,[F,_,i,p,n,h,m,q]),I=l.useMemo(()=>{var e;return!h||!m?null:((e=S.find(s=>s.value===m))==null?void 0:e.label)??null},[h,m,S]),Ie=l.useMemo(()=>h?I&&V?`${g}: ${I}`:I??g:g,[h,I,V,g]),[R,re]=l.useState(!1),[A,ne]=l.useState("");l.useEffect(()=>{R||ne("")},[R]);const G=l.useMemo(()=>{const e=A.trim().toLowerCase();return e?S.filter(s=>s.label.toLowerCase().includes(e)):S},[A,S]),o=l.useMemo(()=>G.filter(e=>!e.disabled),[G]),H=l.useMemo(()=>o.length===0?!1:o.every(e=>n.includes(e.value)),[o,n]),De=l.useMemo(()=>{if(o.length===0)return!1;const e=o.filter(s=>n.includes(s.value)).length;return e>0&&e<o.length},[o,n]),Pe=l.useCallback(e=>{Ne.current=e,typeof x=="function"?x(e):x&&(x.current=e)},[x]),$e=l.useCallback(()=>{if(F){i.selectFilter(_);return}const e=!q;k===void 0&&Be(e),C==null||C(e)},[F,i,_,q,k,C]),Oe=l.useCallback(e=>{const s=m===e?"":e;j===void 0&&se(s),u==null||u(s)},[m,j,u]),Te=l.useCallback(e=>{const s=n.includes(e)?n.filter(d=>d!==e):[...n,e];f===void 0&&z(s),a==null||a(s)},[n,f,a]),ze=l.useCallback(()=>{let e;if(H){const s=new Set(o.map(d=>d.value));e=n.filter(d=>!s.has(d))}else{const s=new Set(n);o.forEach(d=>s.add(d.value)),e=[...s]}f===void 0&&z(e),a==null||a(e)},[H,o,n,f,a]),ie=l.useCallback(()=>{N?B==null||B():p?(f===void 0&&z([]),a==null||a([])):h&&(j===void 0&&se(""),u==null||u("")),re(!1)},[N,B,p,f,a,h,j,u]),Re=w&&ke,Ae=T?"radio":void 0,Ge=T?w:void 0,He=!v&&!T?w:void 0,Ee=t.jsxs(t.Fragment,{children:[!v&&w&&t.jsx(ue.Icon,{className:r.default["tedi-filter__icon"],name:"check",size:he($),color:"inherit"}),D!=null&&t.jsx("span",{className:W.default(r.default["tedi-filter__prepend"],{[r.default["tedi-filter__prepend--hidden"]]:Re}),children:D}),t.jsx("span",{className:r.default["tedi-filter__text"],children:Ie}),P!=null&&t.jsx("span",{className:r.default["tedi-filter__append"],children:P}),p&&w&&n.length>0&&t.jsx(Je.StatusBadge,{className:r.default["tedi-filter__count"],color:le?"neutral":"brand",children:String(n.length)}),v&&t.jsx(ue.Icon,{className:r.default["tedi-filter__icon"],name:"arrow_drop_down",filled:!0,size:he($),color:"inherit"})]}),ae=W.default(r.default["tedi-filter"],r.default[`tedi-filter--${Le}`],$==="large"&&r.default["tedi-filter--large"],w&&r.default["tedi-filter--selected"],ve),oe=t.jsx(Z.Button,{ref:Pe,id:J,type:"button",disabled:le,className:r.default["tedi-filter__button"],onClick:v?void 0:$e,role:v?void 0:Ae,"aria-checked":Ge,"aria-pressed":He,noStyle:!0,children:Ee});if(!v)return t.jsx("div",{className:ae,children:oe});const E=p&&Se?0:null,We=E!==null?1:0,de=()=>G.map((e,s)=>{const d=p?n.includes(e.value):m===e.value,ce=s+We;return p?t.jsx(c.Dropdown.Item,{index:ce,asChild:!0,disabled:e.disabled,closeOnSelect:!1,children:t.jsx(fe.Checkbox,{id:`${y}-option-${s}`,label:e.label,value:e.value,checked:d,disabled:e.disabled,onChange:()=>Te(e.value),name:`${y}-options`})},e.value):t.jsx(c.Dropdown.Item,{index:ce,disabled:e.disabled,active:d,onClick:()=>Oe(e.value),children:e.label},e.value)});return t.jsx("div",{className:ae,children:t.jsxs(c.Dropdown,{open:R,onOpenChange:re,placement:Ce,width:"auto",children:[t.jsx(c.Dropdown.Trigger,{children:oe}),t.jsx(c.Dropdown.Content,{children:N?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:W.default(r.default["tedi-filter-dropdown__custom-content"],{[r.default["tedi-filter-dropdown__options"]]:L!==void 0}),style:L!==void 0?{maxHeight:L}:void 0,children:X}),U&&t.jsxs(t.Fragment,{children:[t.jsx(c.Dropdown.Separator,{}),t.jsx("div",{className:r.default["tedi-filter-dropdown__clear"],children:t.jsx(Z.Button,{visualType:"neutral",size:"small",type:"button",iconLeft:"refresh",onClick:ie,children:te})})]})]}):t.jsxs(t.Fragment,{children:[je&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:r.default["tedi-filter-dropdown__search"],children:t.jsx(Ze.Search,{id:`${y}-search`,label:Y??g,hideLabel:!0,ariaLabel:Y??g,value:A,onChange:ne})}),t.jsx(c.Dropdown.Separator,{})]}),E!==null&&t.jsxs(t.Fragment,{children:[t.jsx(c.Dropdown.Item,{index:E,asChild:!0,closeOnSelect:!1,children:t.jsx(fe.Checkbox,{id:`${y}-select-all`,label:ye,value:"select-all",checked:H,indeterminate:De,onChange:ze,name:`${y}-select-all`})}),t.jsx(c.Dropdown.Separator,{})]}),L!==void 0?t.jsx("div",{className:r.default["tedi-filter-dropdown__options"],style:{maxHeight:L},children:de()}):de(),U&&t.jsxs(t.Fragment,{children:[t.jsx(c.Dropdown.Separator,{}),t.jsx("div",{className:r.default["tedi-filter-dropdown__clear"],children:t.jsx(Z.Button,{visualType:"neutral",size:"small",type:"button",iconLeft:"refresh",onClick:ie,children:te})})]})]})})]})})});pe.displayName="Filter";exports.Filter=pe;
|
|
@@ -93,6 +93,11 @@ export interface FilterProps extends BreakpointSupport<FilterBreakpointProps> {
|
|
|
93
93
|
placement?: React.ComponentProps<typeof Dropdown>['placement'];
|
|
94
94
|
/** Accessible label for the search input. Falls back to `text`. */
|
|
95
95
|
searchLabel?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Caps the height of the dropdown's option list. The list scrolls when it's taller, while the
|
|
98
|
+
* search and "Clear selection" stay pinned. `number` = px, `string` = any CSS length.
|
|
99
|
+
*/
|
|
100
|
+
maxHeight?: React.ComponentProps<typeof Dropdown>['maxHeight'];
|
|
96
101
|
}
|
|
97
102
|
export declare const Filter: React.ForwardRefExoticComponent<FilterProps & React.RefAttributes<HTMLButtonElement>>;
|
|
98
103
|
export default Filter;
|