@tedi-design-system/react 19.0.0-rc.3 → 19.0.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/bundle-stats.html +1 -1
- package/package.json +1 -1
- package/src/tedi/components/navigation/breadcrumbs/breadcrumbs.cjs.js +1 -1
- package/src/tedi/components/navigation/breadcrumbs/breadcrumbs.es.js +35 -32
- package/src/tedi/components/overlays/dropdown/dropdown-item/dropdown-item.cjs.js +1 -1
- package/src/tedi/components/overlays/dropdown/dropdown-item/dropdown-item.d.ts +8 -4
- package/src/tedi/components/overlays/dropdown/dropdown-item/dropdown-item.es.js +85 -54
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("../../../../../external/classnames/index.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("../../../../../external/classnames/index.cjs.js"),l=require("react"),S=require("../../base/icon/icon.cjs.js"),M=require("../../buttons/button/button.cjs.js"),t=require("./breadcrumbs.module.scss.cjs.js"),P=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),D=require("../../../providers/label-provider/use-labels.cjs.js"),d=require("../../overlays/dropdown/dropdown.cjs.js"),y=i=>{const o=[];return l.Children.forEach(i,a=>{if(l.isValidElement(a)){if(a.type===l.Fragment){o.push(...y(a.props.children));return}o.push(a)}}),o},E=e.jsx(S.Icon,{name:"chevron_right",size:16,color:"brand"}),N=i=>{const{children:o,ariaLabel:a,showMoreLabel:k,separator:w=E,className:p}=i,{getCurrentBreakpointProps:B}=P.useBreakpointProps(i.defaultServerBreakpoint),{variant:q="long",maxItems:h,itemsBeforeCollapse:v=1,itemsAfterCollapse:C=1}=B(i),{getLabel:f}=D.useLabels(),x=a??f("breadcrumbs"),L=k??f("breadcrumbs.show-more"),s=y(o);if(s.length===0)return null;if(q==="short"){if(s.length<2)return null;const r=s[s.length-2],c=r.props,n=typeof r.type!="string"&&c.iconLeft===void 0?l.cloneElement(r,{iconLeft:"arrow_back"}):r;return e.jsx("nav",{"aria-label":x,className:b.default(t.default["tedi-breadcrumbs"],p),children:e.jsx("ol",{className:t.default["tedi-breadcrumbs__list"],children:e.jsx("li",{className:t.default["tedi-breadcrumbs__item"],children:n})})})}const u=Math.max(0,v),m=Math.max(1,C),g=h!==void 0&&s.length>h&&s.length>u+m?[...s.slice(0,u).map(r=>({kind:"item",element:r})),{kind:"ellipsis",hidden:s.slice(u,s.length-m)},...s.slice(s.length-m).map(r=>({kind:"item",element:r}))]:s.map(r=>({kind:"item",element:r})),j=g.length-1;return e.jsx("nav",{"aria-label":x,className:b.default(t.default["tedi-breadcrumbs"],p),children:e.jsx("ol",{className:t.default["tedi-breadcrumbs__list"],children:g.map((r,c)=>e.jsxs(l.Fragment,{children:[r.kind==="item"?e.jsx("li",{className:b.default(t.default["tedi-breadcrumbs__item"],{[t.default["tedi-breadcrumbs__current"]]:c===j}),children:r.element}):e.jsx("li",{className:t.default["tedi-breadcrumbs__item"],children:e.jsxs(d.Dropdown,{children:[e.jsx(d.Dropdown.Trigger,{children:e.jsxs(M.Button,{noStyle:!0,className:t.default["tedi-breadcrumbs__ellipsis"],children:[e.jsx("span",{"aria-hidden":"true",children:"…"}),e.jsx("span",{className:"sr-only",children:L})]})}),e.jsx(d.Dropdown.Content,{children:r.hidden.map((n,_)=>{const I=typeof n.type!="string"?l.cloneElement(n,{noStyle:!0}):n;return e.jsx(d.Dropdown.Item,{index:_,asChild:!0,children:I},n.key??_)})})]})}),c<j&&e.jsx("li",{className:t.default["tedi-breadcrumbs__separator"],"aria-hidden":"true",children:w})]},c))})})};N.displayName="Breadcrumbs";exports.Breadcrumbs=N;
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
import { jsx as r, jsxs as p } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { cloneElement as
|
|
4
|
-
import { Icon as
|
|
5
|
-
import { Button as
|
|
2
|
+
import u from "../../../../../external/classnames/index.es.js";
|
|
3
|
+
import { cloneElement as k, Fragment as C, Children as P, isValidElement as j } from "react";
|
|
4
|
+
import { Icon as A } from "../../base/icon/icon.es.js";
|
|
5
|
+
import { Button as T } from "../../buttons/button/button.es.js";
|
|
6
6
|
import s from "./breadcrumbs.module.scss.es.js";
|
|
7
|
-
import { useBreakpointProps as
|
|
8
|
-
import { useLabels as
|
|
7
|
+
import { useBreakpointProps as z } from "../../../helpers/hooks/use-breakpoint-props.es.js";
|
|
8
|
+
import { useLabels as D } from "../../../providers/label-provider/use-labels.es.js";
|
|
9
9
|
import { Dropdown as c } from "../../overlays/dropdown/dropdown.es.js";
|
|
10
10
|
const v = (l) => {
|
|
11
|
-
const
|
|
11
|
+
const i = [];
|
|
12
12
|
return P.forEach(l, (a) => {
|
|
13
|
-
if (
|
|
14
|
-
if (a.type ===
|
|
15
|
-
|
|
13
|
+
if (j(a)) {
|
|
14
|
+
if (a.type === C) {
|
|
15
|
+
i.push(...v(a.props.children));
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
i.push(a);
|
|
19
19
|
}
|
|
20
|
-
}),
|
|
21
|
-
},
|
|
22
|
-
const { children:
|
|
23
|
-
variant:
|
|
20
|
+
}), i;
|
|
21
|
+
}, F = /* @__PURE__ */ r(A, { name: "chevron_right", size: 16, color: "brand" }), V = (l) => {
|
|
22
|
+
const { children: i, ariaLabel: a, showMoreLabel: B, separator: L = F, className: h } = l, { getCurrentBreakpointProps: w } = z(l.defaultServerBreakpoint), {
|
|
23
|
+
variant: x = "long",
|
|
24
24
|
maxItems: b,
|
|
25
|
-
itemsBeforeCollapse:
|
|
26
|
-
itemsAfterCollapse:
|
|
27
|
-
} =
|
|
25
|
+
itemsBeforeCollapse: I = 1,
|
|
26
|
+
itemsAfterCollapse: M = 1
|
|
27
|
+
} = w(l), { getLabel: f } = D(), _ = a ?? f("breadcrumbs"), S = B ?? f("breadcrumbs.show-more"), t = v(i);
|
|
28
28
|
if (t.length === 0) return null;
|
|
29
|
-
if (
|
|
29
|
+
if (x === "short") {
|
|
30
30
|
if (t.length < 2) return null;
|
|
31
|
-
const e = t[t.length - 2],
|
|
32
|
-
return /* @__PURE__ */ r("nav", { "aria-label": _, className:
|
|
31
|
+
const e = t[t.length - 2], o = e.props, n = typeof e.type != "string" && o.iconLeft === void 0 ? k(e, { iconLeft: "arrow_back" }) : e;
|
|
32
|
+
return /* @__PURE__ */ r("nav", { "aria-label": _, className: u(s["tedi-breadcrumbs"], h), children: /* @__PURE__ */ r("ol", { className: s["tedi-breadcrumbs__list"], children: /* @__PURE__ */ r("li", { className: s["tedi-breadcrumbs__item"], children: n }) }) });
|
|
33
33
|
}
|
|
34
|
-
const m = Math.max(0,
|
|
34
|
+
const m = Math.max(0, I), d = Math.max(1, M), g = b !== void 0 && t.length > b && t.length > m + d ? [
|
|
35
35
|
...t.slice(0, m).map((e) => ({ kind: "item", element: e })),
|
|
36
36
|
{
|
|
37
37
|
kind: "ellipsis",
|
|
@@ -39,26 +39,29 @@ const v = (l) => {
|
|
|
39
39
|
},
|
|
40
40
|
...t.slice(t.length - d).map((e) => ({ kind: "item", element: e }))
|
|
41
41
|
] : t.map((e) => ({ kind: "item", element: e })), N = g.length - 1;
|
|
42
|
-
return /* @__PURE__ */ r("nav", { "aria-label": _, className:
|
|
42
|
+
return /* @__PURE__ */ r("nav", { "aria-label": _, className: u(s["tedi-breadcrumbs"], h), children: /* @__PURE__ */ r("ol", { className: s["tedi-breadcrumbs__list"], children: g.map((e, o) => /* @__PURE__ */ p(C, { children: [
|
|
43
43
|
e.kind === "item" ? /* @__PURE__ */ r(
|
|
44
44
|
"li",
|
|
45
45
|
{
|
|
46
|
-
className:
|
|
47
|
-
[s["tedi-breadcrumbs__current"]]:
|
|
46
|
+
className: u(s["tedi-breadcrumbs__item"], {
|
|
47
|
+
[s["tedi-breadcrumbs__current"]]: o === N
|
|
48
48
|
}),
|
|
49
49
|
children: e.element
|
|
50
50
|
}
|
|
51
51
|
) : /* @__PURE__ */ r("li", { className: s["tedi-breadcrumbs__item"], children: /* @__PURE__ */ p(c, { children: [
|
|
52
|
-
/* @__PURE__ */ r(c.Trigger, { children: /* @__PURE__ */ p(
|
|
52
|
+
/* @__PURE__ */ r(c.Trigger, { children: /* @__PURE__ */ p(T, { noStyle: !0, className: s["tedi-breadcrumbs__ellipsis"], children: [
|
|
53
53
|
/* @__PURE__ */ r("span", { "aria-hidden": "true", children: "…" }),
|
|
54
|
-
/* @__PURE__ */ r("span", { className: "sr-only", children:
|
|
54
|
+
/* @__PURE__ */ r("span", { className: "sr-only", children: S })
|
|
55
55
|
] }) }),
|
|
56
|
-
/* @__PURE__ */ r(c.Content, { children: e.hidden.map((
|
|
56
|
+
/* @__PURE__ */ r(c.Content, { children: e.hidden.map((n, y) => {
|
|
57
|
+
const E = typeof n.type != "string" ? k(n, { noStyle: !0 }) : n;
|
|
58
|
+
return /* @__PURE__ */ r(c.Item, { index: y, asChild: !0, children: E }, n.key ?? y);
|
|
59
|
+
}) })
|
|
57
60
|
] }) }),
|
|
58
|
-
|
|
59
|
-
] },
|
|
61
|
+
o < N && /* @__PURE__ */ r("li", { className: s["tedi-breadcrumbs__separator"], "aria-hidden": "true", children: L })
|
|
62
|
+
] }, o)) }) });
|
|
60
63
|
};
|
|
61
|
-
|
|
64
|
+
V.displayName = "Breadcrumbs";
|
|
62
65
|
export {
|
|
63
|
-
|
|
66
|
+
V as Breadcrumbs
|
|
64
67
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react/jsx-runtime"),U=require("../../../../../../external/@floating-ui/react/dist/floating-ui.react.cjs.js"),D=require("../../../../../../external/classnames/index.cjs.js"),m=require("react"),z=require("../dropdown-context.cjs.js"),u=require("./dropdown-item.module.scss.cjs.js"),g=(n,t)=>r=>{n==null||n(r),r.defaultPrevented||t==null||t(r)},A=({children:n,onClick:t,disabled:r,active:x,index:d,indent:p,asChild:s=!1,closeOnSelect:f=!0,isParent:I=!1,className:b,role:y,...q})=>{const{getItemProps:R,listItemsRef:P,setOpen:a,activeIndex:k,divided:E,variant:l}=z.useDropdownContext(),K=s?"div":"button",c=s&&f!==!1&&m.isValidElement(n),w=e=>{typeof d=="number"&&(P.current[d]=e)},N=m.isValidElement(n)?n.ref:void 0,T=U.useMergeRefs([w,N]),j=e=>typeof e!="number"||e<=0?{}:{"--dropdown-indent-level":e,"--dropdown-indent":`${e}rem`},V=e=>{if(r){e.preventDefault();return}const o=e.currentTarget.querySelector('input[type="checkbox"], input[type="radio"]');if(o){o.click();return}t==null||t(e),(!s||c)&&f&&a(!1)},M=e=>{if(r){(e.key==="Enter"||e.key===" ")&&e.preventDefault();return}if(e.key==="Enter"||e.key===" "){const o=e.currentTarget.querySelector('input[type="checkbox"], input[type="radio"]');if(o){e.preventDefault(),o.click(),!s&&f&&a(!1);return}if(c){e.preventDefault(),e.currentTarget.click();return}e.preventDefault(),t==null||t(e),!s&&f&&a(!1)}},_={ref:w,tabIndex:k===d?0:-1,className:D.default(u.default["tedi-dropdown__item"],{[u.default["tedi-dropdown__item--active"]]:x,[u.default["tedi-dropdown__item--disabled"]]:r,[u.default["tedi-dropdown__item--divided"]]:E,[u.default["tedi-dropdown__item--indent"]]:p,[u.default["tedi-dropdown__item--tree-item"]]:l==="tree"&&p,[u.default["tedi-dropdown__item--tree-parent"]]:l==="tree"&&I},b),style:j(p),onClick:V,onKeyDown:M,...q},v=s&&f===!1?{..._,role:y}:R({role:y??"menuitem",disabled:s?void 0:r,..._});if(c){const e=n,o=e.props,i=v;return m.cloneElement(e,{...i,ref:T,className:D.default(i.className,o.className),style:{...i.style,...o.style},"aria-disabled":r||void 0,tabIndex:r?-1:i.tabIndex,onClick:g(i.onClick,o.onClick),onKeyDown:g(i.onKeyDown,o.onKeyDown)})}return S.jsx(K,{...v,children:n})};exports.DropdownItem=A;
|
|
@@ -34,10 +34,14 @@ export type DropdownItemProps = {
|
|
|
34
34
|
*/
|
|
35
35
|
indent?: number;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* **
|
|
40
|
-
*
|
|
37
|
+
* Render the item as its child element instead of a `<button>`.
|
|
38
|
+
*
|
|
39
|
+
* - **Navigable child (default `closeOnSelect`)** — e.g. a `Link`: the item props (`role`,
|
|
40
|
+
* roving `tabindex`, handlers, styles) are merged directly onto the child so it becomes the
|
|
41
|
+
* single focusable `menuitem`. This avoids a focusable wrapper *and* a focusable child (a
|
|
42
|
+
* double Tab stop) and keeps the role and accessible name on one element.
|
|
43
|
+
* - **Form control (`closeOnSelect={false}`)** — e.g. a `Checkbox` / `Radio`: the child is
|
|
44
|
+
* wrapped in a plain `<div>` menuitem that forwards activation to the inner control.
|
|
41
45
|
*
|
|
42
46
|
* @default false
|
|
43
47
|
*/
|
|
@@ -1,70 +1,101 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { jsx as $ } from "react/jsx-runtime";
|
|
2
|
+
import { useMergeRefs as z } from "../../../../../../external/@floating-ui/react/dist/floating-ui.react.es.js";
|
|
3
|
+
import D from "../../../../../../external/classnames/index.es.js";
|
|
4
|
+
import { isValidElement as I, cloneElement as A } from "react";
|
|
5
|
+
import { useDropdownContext as B } from "../dropdown-context.es.js";
|
|
6
|
+
import p from "./dropdown-item.module.scss.es.js";
|
|
7
|
+
const b = (n, e) => (o) => {
|
|
8
|
+
n == null || n(o), o.defaultPrevented || e == null || e(o);
|
|
9
|
+
}, W = ({
|
|
10
|
+
children: n,
|
|
11
|
+
onClick: e,
|
|
12
|
+
disabled: o,
|
|
13
|
+
active: g,
|
|
14
|
+
index: m,
|
|
15
|
+
indent: u,
|
|
16
|
+
asChild: s = !1,
|
|
17
|
+
closeOnSelect: i = !0,
|
|
18
|
+
isParent: l = !1,
|
|
19
|
+
className: x,
|
|
20
|
+
role: d,
|
|
21
|
+
...k
|
|
18
22
|
}) => {
|
|
19
|
-
const { getItemProps:
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const { getItemProps: K, listItemsRef: N, setOpen: a, activeIndex: P, divided: R, variant: y } = B(), E = s ? "div" : "button", c = s && i !== !1 && I(n), w = (t) => {
|
|
24
|
+
typeof m == "number" && (N.current[m] = t);
|
|
25
|
+
}, T = I(n) ? n.ref : void 0, q = z([w, T]), V = (t) => typeof t != "number" || t <= 0 ? {} : {
|
|
26
|
+
"--dropdown-indent-level": t,
|
|
27
|
+
"--dropdown-indent": `${t}rem`
|
|
28
|
+
}, j = (t) => {
|
|
29
|
+
if (o) {
|
|
30
|
+
t.preventDefault();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const r = t.currentTarget.querySelector(
|
|
25
34
|
'input[type="checkbox"], input[type="radio"]'
|
|
26
35
|
);
|
|
27
|
-
if (
|
|
28
|
-
|
|
36
|
+
if (r) {
|
|
37
|
+
r.click();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
e == null || e(t), (!s || c) && i && a(!1);
|
|
41
|
+
}, M = (t) => {
|
|
42
|
+
if (o) {
|
|
43
|
+
(t.key === "Enter" || t.key === " ") && t.preventDefault();
|
|
29
44
|
return;
|
|
30
45
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (!n && (e.key === "Enter" || e.key === " ")) {
|
|
34
|
-
e.preventDefault();
|
|
35
|
-
const p = e.currentTarget.querySelector(
|
|
46
|
+
if (t.key === "Enter" || t.key === " ") {
|
|
47
|
+
const r = t.currentTarget.querySelector(
|
|
36
48
|
'input[type="checkbox"], input[type="radio"]'
|
|
37
49
|
);
|
|
38
|
-
|
|
50
|
+
if (r) {
|
|
51
|
+
t.preventDefault(), r.click(), !s && i && a(!1);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (c) {
|
|
55
|
+
t.preventDefault(), t.currentTarget.click();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
t.preventDefault(), e == null || e(t), !s && i && a(!1);
|
|
39
59
|
}
|
|
40
|
-
},
|
|
41
|
-
ref
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
className: j(
|
|
46
|
-
r["tedi-dropdown__item"],
|
|
60
|
+
}, v = {
|
|
61
|
+
ref: w,
|
|
62
|
+
tabIndex: P === m ? 0 : -1,
|
|
63
|
+
className: D(
|
|
64
|
+
p["tedi-dropdown__item"],
|
|
47
65
|
{
|
|
48
|
-
[
|
|
49
|
-
[
|
|
50
|
-
[
|
|
51
|
-
[
|
|
52
|
-
[
|
|
53
|
-
[
|
|
66
|
+
[p["tedi-dropdown__item--active"]]: g,
|
|
67
|
+
[p["tedi-dropdown__item--disabled"]]: o,
|
|
68
|
+
[p["tedi-dropdown__item--divided"]]: R,
|
|
69
|
+
[p["tedi-dropdown__item--indent"]]: u,
|
|
70
|
+
[p["tedi-dropdown__item--tree-item"]]: y === "tree" && u,
|
|
71
|
+
[p["tedi-dropdown__item--tree-parent"]]: y === "tree" && l
|
|
54
72
|
},
|
|
55
|
-
|
|
73
|
+
x
|
|
56
74
|
),
|
|
57
|
-
style:
|
|
58
|
-
onClick:
|
|
59
|
-
onKeyDown:
|
|
75
|
+
style: V(u),
|
|
76
|
+
onClick: j,
|
|
77
|
+
onKeyDown: M,
|
|
78
|
+
...k
|
|
79
|
+
}, _ = s && i === !1 ? { ...v, role: d } : K({
|
|
80
|
+
role: d ?? "menuitem",
|
|
81
|
+
disabled: s ? void 0 : o,
|
|
60
82
|
...v
|
|
61
|
-
}, N = o && s === !1 ? { ...a, role: m } : b({
|
|
62
|
-
role: m ?? "menuitem",
|
|
63
|
-
disabled: o ? void 0 : n,
|
|
64
|
-
...a
|
|
65
83
|
});
|
|
66
|
-
|
|
84
|
+
if (c) {
|
|
85
|
+
const t = n, r = t.props, f = _;
|
|
86
|
+
return A(t, {
|
|
87
|
+
...f,
|
|
88
|
+
ref: q,
|
|
89
|
+
className: D(f.className, r.className),
|
|
90
|
+
style: { ...f.style, ...r.style },
|
|
91
|
+
"aria-disabled": o || void 0,
|
|
92
|
+
tabIndex: o ? -1 : f.tabIndex,
|
|
93
|
+
onClick: b(f.onClick, r.onClick),
|
|
94
|
+
onKeyDown: b(f.onKeyDown, r.onKeyDown)
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return /* @__PURE__ */ $(E, { ..._, children: n });
|
|
67
98
|
};
|
|
68
99
|
export {
|
|
69
|
-
|
|
100
|
+
W as DropdownItem
|
|
70
101
|
};
|