@tedi-design-system/react 19.2.0-rc.7 → 19.2.0-rc.8

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.
Files changed (54) hide show
  1. package/bundle-stats.html +1 -1
  2. package/component.manifest.json +8 -8
  3. package/index.css +1 -1
  4. package/package.json +1 -1
  5. package/src/community/components/map-components/map-layer/map-layer.cjs.js +1 -1
  6. package/src/community/components/map-components/map-layer/map-layer.es.js +1 -1
  7. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group-context.cjs.js +1 -0
  8. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group-context.d.ts +20 -0
  9. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group-context.es.js +5 -0
  10. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.cjs.js +1 -0
  11. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.d.ts +72 -0
  12. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.es.js +124 -0
  13. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.module.scss.cjs.js +1 -0
  14. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.module.scss.es.js +13 -0
  15. package/src/tedi/components/form/checkbox/checkbox.cjs.js +1 -1
  16. package/src/tedi/components/form/checkbox/checkbox.d.ts +8 -2
  17. package/src/tedi/components/form/checkbox/checkbox.es.js +146 -110
  18. package/src/tedi/components/form/checkbox/checkbox.module.scss.cjs.js +1 -1
  19. package/src/tedi/components/form/checkbox/checkbox.module.scss.es.js +11 -3
  20. package/src/tedi/components/form/checkbox/index.cjs.js +1 -0
  21. package/src/tedi/components/form/checkbox/index.d.ts +11 -0
  22. package/src/tedi/components/form/checkbox/index.es.js +7 -0
  23. package/src/tedi/components/form/choice-group/choice-group.d.ts +11 -0
  24. package/src/tedi/components/form/choice-group/components/choice-group-item/choice-group-item.cjs.js +1 -1
  25. package/src/tedi/components/form/choice-group/components/choice-group-item/choice-group-item.es.js +15 -15
  26. package/src/tedi/components/form/choice-input.types.d.ts +41 -10
  27. package/src/tedi/components/form/radio/index.cjs.js +1 -0
  28. package/src/tedi/components/form/radio/index.d.ts +11 -0
  29. package/src/tedi/components/form/radio/index.es.js +7 -0
  30. package/src/tedi/components/form/radio/radio-group/radio-group-context.cjs.js +1 -0
  31. package/src/tedi/components/form/radio/radio-group/radio-group-context.d.ts +21 -0
  32. package/src/tedi/components/form/radio/radio-group/radio-group-context.es.js +5 -0
  33. package/src/tedi/components/form/radio/radio-group/radio-group.cjs.js +1 -0
  34. package/src/tedi/components/form/radio/radio-group/radio-group.d.ts +56 -0
  35. package/src/tedi/components/form/radio/radio-group/radio-group.es.js +78 -0
  36. package/src/tedi/components/form/radio/radio-group/radio-group.module.scss.cjs.js +1 -0
  37. package/src/tedi/components/form/radio/radio-group/radio-group.module.scss.es.js +13 -0
  38. package/src/tedi/components/form/radio/radio.cjs.js +1 -1
  39. package/src/tedi/components/form/radio/radio.d.ts +7 -2
  40. package/src/tedi/components/form/radio/radio.es.js +116 -78
  41. package/src/tedi/components/form/radio/radio.module.scss.cjs.js +1 -1
  42. package/src/tedi/components/form/radio/radio.module.scss.es.js +11 -3
  43. package/src/tedi/components/navigation/table-of-contents/components/table-of-contents-row/table-of-contents-row.cjs.js +1 -1
  44. package/src/tedi/components/navigation/table-of-contents/components/table-of-contents-row/table-of-contents-row.d.ts +12 -0
  45. package/src/tedi/components/navigation/table-of-contents/components/table-of-contents-row/table-of-contents-row.es.js +57 -27
  46. package/src/tedi/components/navigation/table-of-contents/table-of-contents.cjs.js +1 -1
  47. package/src/tedi/components/navigation/table-of-contents/table-of-contents.d.ts +17 -0
  48. package/src/tedi/components/navigation/table-of-contents/table-of-contents.es.js +65 -51
  49. package/src/tedi/index.d.ts +2 -2
  50. package/src/tedi/providers/label-provider/labels-map.cjs.js +1 -1
  51. package/src/tedi/providers/label-provider/labels-map.d.ts +14 -0
  52. package/src/tedi/providers/label-provider/labels-map.es.js +25 -11
  53. package/tedi.cjs.js +1 -1
  54. package/tedi.es.js +298 -294
@@ -1,98 +1,136 @@
1
- import { jsxs as c, jsx as d } from "react/jsx-runtime";
2
- import l from "../../../../../external/classnames/index.es.js";
3
- import n from "react";
1
+ import { jsx as i, jsxs as l } from "react/jsx-runtime";
2
+ import t from "../../../../../external/classnames/index.es.js";
3
+ import o from "react";
4
+ import { Icon as ee } from "../../base/icon/icon.es.js";
4
5
  import { FeedbackText as q } from "../feedback-text/feedback-text.es.js";
5
- import { FormLabel as v } from "../form-label/form-label.es.js";
6
- import e from "./radio.module.scss.es.js";
7
- import { Row as E } from "../../layout/grid/row.es.js";
8
- import { Col as N } from "../../layout/grid/col.es.js";
9
- const K = (C) => {
10
- const {
11
- id: o,
6
+ import { FormLabel as ae } from "../form-label/form-label.es.js";
7
+ import a from "./radio.module.scss.es.js";
8
+ import { RadioGroupContext as ie } from "./radio-group/radio-group-context.es.js";
9
+ import { useBreakpointProps as de } from "../../../helpers/hooks/use-breakpoint-props.es.js";
10
+ import { Row as re } from "../../layout/grid/row.es.js";
11
+ import { Col as V } from "../../layout/grid/col.es.js";
12
+ const te = (k) => {
13
+ const e = o.useContext(ie), { getCurrentBreakpointProps: $ } = de(k.defaultServerBreakpoint), {
14
+ id: L,
12
15
  label: m,
13
- value: p,
14
- className: g,
15
- disabled: s,
16
- onChange: a,
17
- hideLabel: y,
16
+ value: s,
17
+ className: y,
18
+ onChange: c,
19
+ hideLabel: C,
18
20
  helper: r,
19
- checked: t,
20
- defaultChecked: R,
21
- hover: x,
22
- name: j,
23
- tooltip: h,
24
- labelProps: w,
25
- size: f = "default",
26
- invalid: I,
27
- required: u,
28
- ...L
29
- } = C, [_, $] = n.useState(R || !1), b = n.useRef(null), z = n.useMemo(() => a && typeof t < "u" ? t : _, [a, _, t]), B = (i) => {
30
- typeof t > "u" && $(i == null ? void 0 : i.target.checked), a == null || a(p, i == null ? void 0 : i.target.checked);
31
- }, k = r ? r.id ?? `${o}-helper` : void 0, F = h ? `${o}-tooltip` : void 0, M = l(e["tedi-radio__label"], { [e["tedi-radio--disabled"]]: s });
32
- return /* @__PURE__ */ c(
21
+ checked: p,
22
+ defaultChecked: j,
23
+ hover: E,
24
+ name: D,
25
+ tooltip: P,
26
+ description: b,
27
+ icon: _,
28
+ labelProps: F,
29
+ size: G,
30
+ variant: M,
31
+ cardVariant: S,
32
+ disabled: H,
33
+ invalid: T,
34
+ required: I,
35
+ ...w
36
+ } = $(k), u = G ?? (e == null ? void 0 : e.size) ?? "default", B = M ?? (e == null ? void 0 : e.variant) ?? "default", U = S ?? (e == null ? void 0 : e.cardVariant) ?? "primary", h = H ?? (e == null ? void 0 : e.disabled) ?? !1, A = T ?? (e == null ? void 0 : e.invalid), J = I ?? (e == null ? void 0 : e.required);
37
+ B === "card" && P && console.warn('Radio: `tooltip` is not supported with `variant="card"` and will be ignored. Use `description`.');
38
+ const K = o.useId(), n = L ?? K, O = D ?? (e == null ? void 0 : e.name), [x, Q] = o.useState(j || !1), N = e !== null, W = o.useMemo(() => N ? (e == null ? void 0 : e.value) === s : c && typeof p < "u" ? p : x, [N, e, s, c, p, x]), X = (d) => {
39
+ N ? e == null || e.onValueChange(s) : typeof p > "u" && Q(d == null ? void 0 : d.target.checked), c == null || c(s, d == null ? void 0 : d.target.checked);
40
+ }, f = r ? r.id ?? `${n}-helper` : void 0, Y = f, z = /* @__PURE__ */ i(
41
+ "input",
42
+ {
43
+ id: n,
44
+ value: s,
45
+ name: O,
46
+ type: "radio",
47
+ disabled: h,
48
+ checked: W,
49
+ required: J,
50
+ onChange: X,
51
+ className: a["tedi-radio__input"],
52
+ "aria-describedby": Y
53
+ }
54
+ ), v = /* @__PURE__ */ i(
55
+ "span",
56
+ {
57
+ "aria-hidden": "true",
58
+ className: t(
59
+ a["tedi-radio__indicator"],
60
+ { [a["tedi-radio__indicator--hover"]]: E },
61
+ { [a[`tedi-radio__indicator--size-${u}`]]: u },
62
+ { [a["tedi-radio__indicator--invalid"]]: A }
63
+ ),
64
+ "data-testid": "radio-indicator"
65
+ }
66
+ );
67
+ if (B === "card") {
68
+ const d = `${n}-label`, R = b ? `${n}-description` : void 0, g = [R, f].filter(Boolean).join(" ") || void 0;
69
+ return /* @__PURE__ */ l(
70
+ "label",
71
+ {
72
+ "data-name": "radio",
73
+ className: t(
74
+ a["tedi-radio"],
75
+ a["tedi-radio--card"],
76
+ a[`tedi-radio--card-${U}`],
77
+ { [a["tedi-radio--card-with-icon"]]: !!_ },
78
+ { [a["tedi-radio--disabled"]]: h },
79
+ y
80
+ ),
81
+ ...w,
82
+ children: [
83
+ /* @__PURE__ */ l("span", { className: a["tedi-radio__card-control"], children: [
84
+ o.cloneElement(z, {
85
+ "aria-labelledby": m ? d : void 0,
86
+ "aria-describedby": g
87
+ }),
88
+ v,
89
+ _ && /* @__PURE__ */ i(ee, { name: _, size: u === "default" ? 18 : 24, className: a["tedi-radio__card-icon"] }),
90
+ /* @__PURE__ */ i("span", { id: d, className: t(a["tedi-radio__card-label"], { "sr-only": C }), children: m })
91
+ ] }),
92
+ b && /* @__PURE__ */ i("span", { id: R, className: a["tedi-radio__card-description"], children: b }),
93
+ r && /* @__PURE__ */ i(q, { id: f, ...r, className: t(a["tedi-radio__helper"], r.className) })
94
+ ]
95
+ }
96
+ );
97
+ }
98
+ const Z = t(a["tedi-radio__label"], { [a["tedi-radio--disabled"]]: h });
99
+ return /* @__PURE__ */ l(
33
100
  "div",
34
101
  {
35
- className: l(e["tedi-radio"], { [e["tedi-radio--disabled"]]: s }),
102
+ className: t(a["tedi-radio"], { [a["tedi-radio--disabled"]]: h }),
36
103
  "data-name": "radio",
37
- ...L,
104
+ ...w,
38
105
  children: [
39
- /* @__PURE__ */ c(E, { gutter: 0, children: [
40
- /* @__PURE__ */ d(N, { width: "auto", children: /* @__PURE__ */ c("div", { className: e["tedi-radio__outer-indicator-wrapper"], children: [
41
- /* @__PURE__ */ d(
42
- "input",
43
- {
44
- id: o,
45
- value: p,
46
- name: j,
47
- type: "radio",
48
- disabled: s,
49
- checked: z,
50
- onChange: B,
51
- className: e["tedi-radio__input"],
52
- "aria-describedby": [k, F].filter(Boolean).join(" "),
53
- required: u
54
- }
55
- ),
56
- /* @__PURE__ */ d(
57
- "div",
58
- {
59
- "aria-hidden": "true",
60
- onClick: () => {
61
- var i;
62
- return (i = b.current) == null ? void 0 : i.click();
63
- },
64
- className: l(
65
- e["tedi-radio__indicator"],
66
- { [e["tedi-radio__indicator--hover"]]: x },
67
- { [e[`tedi-radio__indicator--size-${f}`]]: f },
68
- { [e["tedi-radio__indicator--invalid"]]: I },
69
- g
70
- ),
71
- "data-testid": "radio-indicator"
72
- }
73
- )
106
+ /* @__PURE__ */ l(re, { gutter: 0, children: [
107
+ /* @__PURE__ */ i(V, { width: "auto", children: /* @__PURE__ */ l("div", { className: a["tedi-radio__outer-indicator-wrapper"], children: [
108
+ z,
109
+ o.cloneElement(v, {
110
+ className: t(v.props.className, y)
111
+ })
74
112
  ] }) }),
75
- m && /* @__PURE__ */ d(N, { children: /* @__PURE__ */ d(
76
- v,
113
+ m && /* @__PURE__ */ i(V, { children: /* @__PURE__ */ i(
114
+ ae,
77
115
  {
78
- ref: b,
79
- className: M,
80
- id: o,
116
+ className: Z,
117
+ id: n,
81
118
  "data-testid": "radio-label",
82
- hideLabel: y,
119
+ hideLabel: C,
83
120
  label: m,
84
- tooltip: h,
85
- required: u,
86
- labelProps: w
121
+ tooltip: P,
122
+ required: I,
123
+ labelProps: F
87
124
  }
88
125
  ) })
89
126
  ] }),
90
- r && /* @__PURE__ */ d(q, { id: k, ...r, className: l(e["tedi-radio__helper"], r.className) })
127
+ r && /* @__PURE__ */ i(q, { id: f, ...r, className: t(a["tedi-radio__helper"], r.className) })
91
128
  ]
92
129
  }
93
130
  );
94
131
  };
132
+ te.displayName = "Radio";
95
133
  export {
96
- K as Radio,
97
- K as default
134
+ te as Radio,
135
+ te as default
98
136
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i={"tedi-radio":"tedi-radio-c814e478","tedi-radio--disabled":"tedi-radio--disabled-fb9dbcd0","tedi-radio__input":"tedi-radio__input-62863a92","tedi-radio__indicator":"tedi-radio__indicator-c6e05a3f","tedi-radio__indicator--size-default":"tedi-radio__indicator--size-default-dd9e104b","tedi-radio__indicator--size-large":"tedi-radio__indicator--size-large-c5c7d068","tedi-radio__indicator--invalid":"tedi-radio__indicator--invalid-d5a930d7","tedi-radio__indicator--hover":"tedi-radio__indicator--hover-6e11a48a","tedi-radio__outer-indicator-wrapper":"tedi-radio__outer-indicator-wrapper-7c0ad4cd","tedi-radio__helper":"tedi-radio__helper-266c7814"};exports.default=i;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d={"tedi-radio":"tedi-radio-c814e478","tedi-radio--disabled":"tedi-radio--disabled-fb9dbcd0","tedi-radio__input":"tedi-radio__input-62863a92","tedi-radio__indicator":"tedi-radio__indicator-c6e05a3f","tedi-radio__indicator--size-default":"tedi-radio__indicator--size-default-dd9e104b","tedi-radio__indicator--size-large":"tedi-radio__indicator--size-large-c5c7d068","tedi-radio__indicator--invalid":"tedi-radio__indicator--invalid-d5a930d7","tedi-radio__indicator--hover":"tedi-radio__indicator--hover-6e11a48a","tedi-radio__outer-indicator-wrapper":"tedi-radio__outer-indicator-wrapper-7c0ad4cd","tedi-radio__helper":"tedi-radio__helper-266c7814","tedi-radio--card":"tedi-radio--card-f10f7b18","tedi-radio__card-control":"tedi-radio__card-control-d010324f","tedi-radio__card-label":"tedi-radio__card-label-19b7c642","tedi-radio__card-icon":"tedi-radio__card-icon-fa03c66c","tedi-radio__card-description":"tedi-radio__card-description-69c958cf","tedi-radio--card-with-icon":"tedi-radio--card-with-icon-0735f37d","tedi-radio--card-primary":"tedi-radio--card-primary-f05b3587","tedi-radio--card-secondary":"tedi-radio--card-secondary-9a5fbafe"};exports.default=d;
@@ -1,4 +1,4 @@
1
- const i = {
1
+ const d = {
2
2
  "tedi-radio": "tedi-radio-c814e478",
3
3
  "tedi-radio--disabled": "tedi-radio--disabled-fb9dbcd0",
4
4
  "tedi-radio__input": "tedi-radio__input-62863a92",
@@ -8,8 +8,16 @@ const i = {
8
8
  "tedi-radio__indicator--invalid": "tedi-radio__indicator--invalid-d5a930d7",
9
9
  "tedi-radio__indicator--hover": "tedi-radio__indicator--hover-6e11a48a",
10
10
  "tedi-radio__outer-indicator-wrapper": "tedi-radio__outer-indicator-wrapper-7c0ad4cd",
11
- "tedi-radio__helper": "tedi-radio__helper-266c7814"
11
+ "tedi-radio__helper": "tedi-radio__helper-266c7814",
12
+ "tedi-radio--card": "tedi-radio--card-f10f7b18",
13
+ "tedi-radio__card-control": "tedi-radio__card-control-d010324f",
14
+ "tedi-radio__card-label": "tedi-radio__card-label-19b7c642",
15
+ "tedi-radio__card-icon": "tedi-radio__card-icon-fa03c66c",
16
+ "tedi-radio__card-description": "tedi-radio__card-description-69c958cf",
17
+ "tedi-radio--card-with-icon": "tedi-radio--card-with-icon-0735f37d",
18
+ "tedi-radio--card-primary": "tedi-radio--card-primary-f05b3587",
19
+ "tedi-radio--card-secondary": "tedi-radio--card-secondary-9a5fbafe"
12
20
  };
13
21
  export {
14
- i as default
22
+ d as default
15
23
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),_=require("../../../../../../../external/classnames/index.cjs.js"),w=require("react"),R=require("../../../../misc/separator/separator.cjs.js"),$=require("../../table-of-contents.cjs.js"),e=require("../../table-of-contents.module.scss.cjs.js"),c=({node:m,depth:i,index:r,numberPrefix:a})=>{const{activeId:p,numbered:o,activeTrail:x,defaultOpen:j}=w.useContext($.TableOfContentsContext),{id:n,content:v,children:s,separator:h,slot:d}=m,C=!!(s!=null&&s.length),u=!!n&&n===p,O=C&&(j||!!n&&x.has(n)),N=Math.min(i,2),l=a?`${a}.${r+1}`:`${r+1}`,q=a?l:`${l}.`,T=o?"ol":"ul";return t.jsxs("li",{"aria-current":u?"location":void 0,className:_.default(e.default["tedi-table-of-contents__item"],{[e.default["tedi-table-of-contents__item--selected"]]:u}),children:[t.jsxs("div",{className:_.default(e.default["tedi-table-of-contents__row"],e.default[`tedi-table-of-contents__row--level-${N}`]),children:[o&&t.jsx("span",{className:e.default["tedi-table-of-contents__number"],"aria-hidden":"true",children:q}),t.jsx("span",{className:e.default["tedi-table-of-contents__content"],children:v}),d!==void 0&&t.jsx("div",{className:e.default["tedi-table-of-contents__slot"],children:d})]}),O&&t.jsx(T,{className:e.default["tedi-table-of-contents__group"],children:s.map((f,b)=>t.jsx(c,{node:f,depth:i+1,index:b,numberPrefix:o?l:void 0},f.id??b))}),h&&t.jsx(R.Separator,{className:e.default["tedi-table-of-contents__separator"]})]})};c.displayName="TableOfContentsRow";exports.TableOfContentsRow=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),x=require("../../../../../../../external/classnames/index.cjs.js"),p=require("react"),D=require("../../../../misc/separator/separator.cjs.js"),G=require("../../table-of-contents.cjs.js"),o=require("../../table-of-contents.module.scss.cjs.js"),H=8,j=n=>{let e=(n==null?void 0:n.parentElement)??null;for(;e&&e!==document.body&&e!==document.documentElement;){const{overflowY:t}=window.getComputedStyle(e);if((t==="auto"||t==="scroll"||t==="overlay")&&e.scrollHeight>e.clientHeight)return e;e=e.parentElement}return null},y=(n,e,t,l,c=H)=>n<t+c?n-t-c:e>l-c?e-l+c:0,m=({node:n,depth:e,index:t,numberPrefix:l})=>{const{activeId:c,numbered:f,activeTrail:O,defaultOpen:N,scrollActiveIntoView:_,activeIdChanged:h}=p.useContext(G.TableOfContentsContext),{id:i,content:q,children:d,separator:M,slot:w}=n,$=!!(d!=null&&d.length),u=!!i&&i===c,A=$&&(N||!!i&&O.has(i)),E=Math.min(e,2),R=p.useRef(null);p.useEffect(()=>{var S;if(!_||!u||!h)return;const a=R.current;if(!a)return;const r=j(a);if(!r||typeof r.scrollBy!="function")return;const v=a.getBoundingClientRect(),C=r.getBoundingClientRect(),g=y(v.top,v.bottom,C.top,C.bottom);if(g===0)return;const I=typeof window<"u"&&((S=window.matchMedia)==null?void 0:S.call(window,"(prefers-reduced-motion: reduce)").matches);r.scrollBy({top:g,behavior:I?"auto":"smooth"})},[_,u,h]);const b=l?`${l}.${t+1}`:`${t+1}`,T=l?b:`${b}.`,B=f?"ol":"ul";return s.jsxs("li",{"aria-current":u?"location":void 0,className:x.default(o.default["tedi-table-of-contents__item"],{[o.default["tedi-table-of-contents__item--selected"]]:u}),children:[s.jsxs("div",{ref:R,className:x.default(o.default["tedi-table-of-contents__row"],o.default[`tedi-table-of-contents__row--level-${E}`]),children:[f&&s.jsx("span",{className:o.default["tedi-table-of-contents__number"],"aria-hidden":"true",children:T}),s.jsx("span",{className:o.default["tedi-table-of-contents__content"],children:q}),w!==void 0&&s.jsx("div",{className:o.default["tedi-table-of-contents__slot"],children:w})]}),A&&s.jsx(B,{className:o.default["tedi-table-of-contents__group"],children:d.map((a,r)=>s.jsx(m,{node:a,depth:e+1,index:r,numberPrefix:f?b:void 0},a.id??r))}),M&&s.jsx(D.Separator,{className:o.default["tedi-table-of-contents__separator"]})]})};m.displayName="TableOfContentsRow";exports.TableOfContentsRow=m;exports.getRowScrollDelta=y;exports.getScrollableAncestor=j;
@@ -6,6 +6,18 @@ interface TableOfContentsRowProps {
6
6
  /** Parent's number (e.g. `'2'`) for building hierarchical ordinals like `2.1`. */
7
7
  numberPrefix?: string;
8
8
  }
9
+ /**
10
+ * Nearest scrollable ancestor that is a real in-page container (never `body` / `documentElement`),
11
+ * so bringing the active row into view scrolls only the table-of-contents' own scroll area and can
12
+ * never scroll the whole document. Returns `null` when no such container exists.
13
+ */
14
+ export declare const getScrollableAncestor: (element: HTMLElement | null) => HTMLElement | null;
15
+ /**
16
+ * Minimal vertical scroll (with an {@link SCROLL_MARGIN}px margin) to bring the row's
17
+ * `[top, bottom]` band inside the container's `[top, bottom]` band. Returns `0` when the row is
18
+ * already visible — "nearest" semantics: scroll up if it's above, down if it's below, else nothing.
19
+ */
20
+ export declare const getRowScrollDelta: (rowTop: number, rowBottom: number, containerTop: number, containerBottom: number, margin?: number) => number;
9
21
  export declare const TableOfContentsRow: {
10
22
  ({ node, depth, index, numberPrefix }: TableOfContentsRowProps): JSX.Element;
11
23
  displayName: string;
@@ -1,40 +1,70 @@
1
- import { jsxs as p, jsx as e } from "react/jsx-runtime";
2
- import _ from "../../../../../../../external/classnames/index.es.js";
3
- import { useContext as j } from "react";
4
- import { Separator as y } from "../../../../misc/separator/separator.es.js";
5
- import { TableOfContentsContext as R } from "../../table-of-contents.es.js";
6
- import t from "../../table-of-contents.module.scss.es.js";
7
- const b = ({ node: u, depth: i, index: r, numberPrefix: s }) => {
8
- const { activeId: h, numbered: a, activeTrail: v, defaultOpen: N } = j(R), { id: o, content: C, children: n, separator: O, slot: c } = u, $ = !!(n != null && n.length), d = !!o && o === h, w = $ && (N || !!o && v.has(o)), T = Math.min(i, 2), l = s ? `${s}.${r + 1}` : `${r + 1}`, x = s ? l : `${l}.`, g = a ? "ol" : "ul";
9
- return /* @__PURE__ */ p(
1
+ import { jsxs as N, jsx as a } from "react/jsx-runtime";
2
+ import g from "../../../../../../../external/classnames/index.es.js";
3
+ import { useContext as G, useRef as H, useEffect as L } from "react";
4
+ import { Separator as T } from "../../../../misc/separator/separator.es.js";
5
+ import { TableOfContentsContext as D } from "../../table-of-contents.es.js";
6
+ import o from "../../table-of-contents.module.scss.es.js";
7
+ const V = 8, Y = (n) => {
8
+ let t = (n == null ? void 0 : n.parentElement) ?? null;
9
+ for (; t && t !== document.body && t !== document.documentElement; ) {
10
+ const { overflowY: e } = window.getComputedStyle(t);
11
+ if ((e === "auto" || e === "scroll" || e === "overlay") && t.scrollHeight > t.clientHeight) return t;
12
+ t = t.parentElement;
13
+ }
14
+ return null;
15
+ }, k = (n, t, e, s, c = V) => n < e + c ? n - e - c : t > s - c ? t - s + c : 0, y = ({ node: n, depth: t, index: e, numberPrefix: s }) => {
16
+ const { activeId: c, numbered: f, activeTrail: S, defaultOpen: O, scrollActiveIntoView: p, activeIdChanged: b } = G(D), { id: i, content: $, children: d, separator: E, slot: _ } = n, M = !!(d != null && d.length), u = !!i && i === c, x = M && (O || !!i && S.has(i)), A = Math.min(t, 2), h = H(null);
17
+ L(() => {
18
+ var C;
19
+ if (!p || !u || !b) return;
20
+ const l = h.current;
21
+ if (!l) return;
22
+ const r = Y(l);
23
+ if (!r || typeof r.scrollBy != "function") return;
24
+ const w = l.getBoundingClientRect(), v = r.getBoundingClientRect(), R = k(w.top, w.bottom, v.top, v.bottom);
25
+ if (R === 0) return;
26
+ const j = typeof window < "u" && ((C = window.matchMedia) == null ? void 0 : C.call(window, "(prefers-reduced-motion: reduce)").matches);
27
+ r.scrollBy({ top: R, behavior: j ? "auto" : "smooth" });
28
+ }, [p, u, b]);
29
+ const m = s ? `${s}.${e + 1}` : `${e + 1}`, B = s ? m : `${m}.`, I = f ? "ol" : "ul";
30
+ return /* @__PURE__ */ N(
10
31
  "li",
11
32
  {
12
- "aria-current": d ? "location" : void 0,
13
- className: _(t["tedi-table-of-contents__item"], {
14
- [t["tedi-table-of-contents__item--selected"]]: d
33
+ "aria-current": u ? "location" : void 0,
34
+ className: g(o["tedi-table-of-contents__item"], {
35
+ [o["tedi-table-of-contents__item--selected"]]: u
15
36
  }),
16
37
  children: [
17
- /* @__PURE__ */ p("div", { className: _(t["tedi-table-of-contents__row"], t[`tedi-table-of-contents__row--level-${T}`]), children: [
18
- a && /* @__PURE__ */ e("span", { className: t["tedi-table-of-contents__number"], "aria-hidden": "true", children: x }),
19
- /* @__PURE__ */ e("span", { className: t["tedi-table-of-contents__content"], children: C }),
20
- c !== void 0 && /* @__PURE__ */ e("div", { className: t["tedi-table-of-contents__slot"], children: c })
21
- ] }),
22
- w && /* @__PURE__ */ e(g, { className: t["tedi-table-of-contents__group"], children: n.map((m, f) => /* @__PURE__ */ e(
23
- b,
38
+ /* @__PURE__ */ N(
39
+ "div",
24
40
  {
25
- node: m,
26
- depth: i + 1,
27
- index: f,
28
- numberPrefix: a ? l : void 0
41
+ ref: h,
42
+ className: g(o["tedi-table-of-contents__row"], o[`tedi-table-of-contents__row--level-${A}`]),
43
+ children: [
44
+ f && /* @__PURE__ */ a("span", { className: o["tedi-table-of-contents__number"], "aria-hidden": "true", children: B }),
45
+ /* @__PURE__ */ a("span", { className: o["tedi-table-of-contents__content"], children: $ }),
46
+ _ !== void 0 && /* @__PURE__ */ a("div", { className: o["tedi-table-of-contents__slot"], children: _ })
47
+ ]
48
+ }
49
+ ),
50
+ x && /* @__PURE__ */ a(I, { className: o["tedi-table-of-contents__group"], children: d.map((l, r) => /* @__PURE__ */ a(
51
+ y,
52
+ {
53
+ node: l,
54
+ depth: t + 1,
55
+ index: r,
56
+ numberPrefix: f ? m : void 0
29
57
  },
30
- m.id ?? f
58
+ l.id ?? r
31
59
  )) }),
32
- O && /* @__PURE__ */ e(y, { className: t["tedi-table-of-contents__separator"] })
60
+ E && /* @__PURE__ */ a(T, { className: o["tedi-table-of-contents__separator"] })
33
61
  ]
34
62
  }
35
63
  );
36
64
  };
37
- b.displayName = "TableOfContentsRow";
65
+ y.displayName = "TableOfContentsRow";
38
66
  export {
39
- b as TableOfContentsRow
67
+ y as TableOfContentsRow,
68
+ k as getRowScrollDelta,
69
+ Y as getScrollableAncestor
40
70
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),g=require("../../../../../external/classnames/index.cjs.js"),i=require("react"),P=require("../../misc/affix/affix.cjs.js"),S=require("./components/table-of-contents-collapsible/table-of-contents-collapsible.cjs.js"),j=require("./components/table-of-contents-item/table-of-contents-item.cjs.js"),B=require("./components/table-of-contents-list/table-of-contents-list.cjs.js"),f=require("./table-of-contents.module.scss.cjs.js"),M=require("../../../providers/label-provider/use-labels.cjs.js"),w=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),E=require("../../content/card/card.cjs.js"),R=require("../../content/card/card-content/card-content.cjs.js"),y=i.createContext({activeTrail:new Set}),m=t=>i.isValidElement(t)&&t.type===j.TableOfContentsItem,h=t=>i.Children.toArray(t).filter(m).map(l=>{const{id:o,separator:a,slot:c,children:s}=l.props,e=i.Children.toArray(s),n=e.filter(m),d=e.filter(u=>!m(u));return{id:o,separator:a,slot:c,content:r.jsx(r.Fragment,{children:d}),children:n.length?h(s):void 0}}),k=(t,l)=>{const o=new Set;if(!l)return o;const a=(c,s)=>{for(const e of c){const n=e.id?[...s,e.id]:s;if(e.id===l||e.children&&a(e.children,n))return n.forEach(d=>o.add(d)),!0}return!1};return a(t,[]),o};function b(t){const{getLabel:l}=M.useLabels(),{getCurrentBreakpointProps:o}=w.useBreakpointProps(t.defaultServerBreakpoint),{children:a,heading:c,headingLevel:s="h3",ariaLabel:e,activeId:n,defaultOpen:d=!0,numbered:u=!1,sticky:p=!0,variant:x="default",bordered:N=!1,className:L}=o(t),A=c===void 0?l("table-of-contents.title"):c,C=i.useMemo(()=>h(a),[a]),T=i.useMemo(()=>k(C,n),[C,n]),I=i.useMemo(()=>({activeId:n,numbered:u,headingLevel:s,ariaLabel:e,activeTrail:T,defaultOpen:d}),[n,u,s,e,T,d]),v=r.jsx("div",{className:g.default(f.default["tedi-table-of-contents"],{[f.default["tedi-table-of-contents--transparent"]]:x==="transparent",[f.default["tedi-table-of-contents--bordered"]]:N}),children:r.jsx(B.TableOfContentsList,{nodes:C,heading:A})}),O=g.default({[f.default["tedi-table-of-contents--sticky"]]:p},L),q=x==="transparent"?r.jsx("div",{className:O,children:v}):r.jsx(E.Card,{className:O,children:r.jsx(R.CardContent,{padding:0,children:v})});return r.jsx(y.Provider,{value:I,children:p?r.jsx(P.Affix,{position:"sticky",top:1.5,bottom:1.5,children:q}):q})}b.displayName="TableOfContents";b.Item=j.TableOfContentsItem;b.Collapsible=S.TableOfContentsCollapsible;exports.TableOfContents=b;exports.TableOfContentsContext=y;exports.buildActiveTrail=k;exports.childrenToNodes=h;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),I=require("../../../../../external/classnames/index.cjs.js"),s=require("react"),B=require("../../misc/affix/affix.cjs.js"),E=require("./components/table-of-contents-collapsible/table-of-contents-collapsible.cjs.js"),k=require("./components/table-of-contents-item/table-of-contents-item.cjs.js"),M=require("./components/table-of-contents-list/table-of-contents-list.cjs.js"),f=require("./table-of-contents.module.scss.cjs.js"),R=require("../../../providers/label-provider/use-labels.cjs.js"),V=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),F=require("../../content/card/card.cjs.js"),H=require("../../content/card/card-content/card-content.cjs.js"),A=s.createContext({activeTrail:new Set}),h=n=>s.isValidElement(n)&&n.type===k.TableOfContentsItem,m=n=>s.Children.toArray(n).filter(h).map(l=>{const{id:a,separator:i,slot:c,children:o}=l.props,t=s.Children.toArray(o),e=t.filter(h),d=t.filter(u=>!h(u));return{id:a,separator:i,slot:c,content:r.jsx(r.Fragment,{children:d}),children:e.length?m(o):void 0}}),N=(n,l)=>{const a=new Set;if(!l)return a;const i=(c,o)=>{for(const t of c){const e=t.id?[...o,t.id]:o;if(t.id===l||t.children&&i(t.children,e))return e.forEach(d=>a.add(d)),!0}return!1};return i(n,[]),a};function b(n){const{getLabel:l}=R.useLabels(),{getCurrentBreakpointProps:a}=V.useBreakpointProps(n.defaultServerBreakpoint),{children:i,heading:c,headingLevel:o="h3",ariaLabel:t,activeId:e,defaultOpen:d=!0,numbered:u=!1,sticky:p=!0,variant:v="default",bordered:L=!1,scrollActiveIntoView:x=!1,className:P}=a(n),S=c===void 0?l("table-of-contents.title"):c,C=s.useMemo(()=>m(i),[i]),T=s.useMemo(()=>N(C,e),[C,e]),O=s.useRef(e),g=O.current!==e;s.useEffect(()=>{O.current=e},[e]);const w=s.useMemo(()=>({activeId:e,numbered:u,headingLevel:o,ariaLabel:t,activeTrail:T,defaultOpen:d,scrollActiveIntoView:x,activeIdChanged:g}),[e,u,o,t,T,d,x,g]),q=r.jsx("div",{className:I.default(f.default["tedi-table-of-contents"],{[f.default["tedi-table-of-contents--transparent"]]:v==="transparent",[f.default["tedi-table-of-contents--bordered"]]:L}),children:r.jsx(M.TableOfContentsList,{nodes:C,heading:S})}),j=I.default({[f.default["tedi-table-of-contents--sticky"]]:p},P),y=v==="transparent"?r.jsx("div",{className:j,children:q}):r.jsx(F.Card,{className:j,children:r.jsx(H.CardContent,{padding:0,children:q})});return r.jsx(A.Provider,{value:w,children:p?r.jsx(B.Affix,{position:"sticky",top:1.5,bottom:1.5,children:y}):y})}b.displayName="TableOfContents";b.Item=k.TableOfContentsItem;b.Collapsible=E.TableOfContentsCollapsible;exports.TableOfContents=b;exports.TableOfContentsContext=A;exports.buildActiveTrail=N;exports.childrenToNodes=m;
@@ -17,6 +17,16 @@ type TableOfContentsBreakpointProps = {
17
17
  * @default true
18
18
  */
19
19
  sticky?: boolean;
20
+ /**
21
+ * Keep the active item visible inside a scrollable table of contents. When the `activeId`
22
+ * changes, the active item's row is scrolled into view within the nearest scroll container
23
+ * (the sticky card, or a scrollable wrapper you provide) using "nearest" semantics — it only
24
+ * scrolls when the row is out of view, leaving ~8px of margin. Positions on the row itself,
25
+ * not its expanded children. Has no effect in non-scrollable layouts and respects
26
+ * `prefers-reduced-motion`.
27
+ * @default false
28
+ */
29
+ scrollActiveIntoView?: boolean;
20
30
  };
21
31
  export interface TableOfContentsProps extends BreakpointSupport<TableOfContentsBreakpointProps> {
22
32
  /**
@@ -87,6 +97,13 @@ interface TableOfContentsContextValue {
87
97
  ariaLabel?: string;
88
98
  activeTrail: Set<string>;
89
99
  defaultOpen?: boolean;
100
+ scrollActiveIntoView?: boolean;
101
+ /**
102
+ * True only on renders where `activeId` genuinely changed from its previously committed value
103
+ * (never on the initial render, including Strict Mode's mount-effect replay). Rows use it to
104
+ * scroll into view only on a real transition — not when a selected child first mounts on load.
105
+ */
106
+ activeIdChanged?: boolean;
90
107
  }
91
108
  export declare const TableOfContentsContext: import('react').Context<TableOfContentsContextValue>;
92
109
  export declare const childrenToNodes: (children: ReactNode) => TableOfContentsNode[];
@@ -1,73 +1,87 @@
1
- import { jsx as o, Fragment as B } from "react/jsx-runtime";
2
- import N from "../../../../../external/classnames/index.es.js";
3
- import { useMemo as p, createContext as E, Children as k, isValidElement as P } from "react";
4
- import { Affix as S } from "../../misc/affix/affix.es.js";
5
- import { TableOfContentsCollapsible as V } from "./components/table-of-contents-collapsible/table-of-contents-collapsible.es.js";
6
- import { TableOfContentsItem as O } from "./components/table-of-contents-item/table-of-contents-item.es.js";
7
- import { TableOfContentsList as j } from "./components/table-of-contents-list/table-of-contents-list.es.js";
8
- import m from "./table-of-contents.module.scss.es.js";
9
- import { useLabels as F } from "../../../providers/label-provider/use-labels.es.js";
10
- import { useBreakpointProps as H } from "../../../helpers/hooks/use-breakpoint-props.es.js";
11
- import { Card as M } from "../../content/card/card.es.js";
12
- import { CardContent as q } from "../../content/card/card-content/card-content.es.js";
13
- const z = E({
1
+ import { jsx as o, Fragment as S } from "react/jsx-runtime";
2
+ import I from "../../../../../external/classnames/index.es.js";
3
+ import { useMemo as p, useRef as V, useEffect as R, createContext as j, Children as O, isValidElement as F } from "react";
4
+ import { Affix as H } from "../../misc/affix/affix.es.js";
5
+ import { TableOfContentsCollapsible as M } from "./components/table-of-contents-collapsible/table-of-contents-collapsible.es.js";
6
+ import { TableOfContentsItem as x } from "./components/table-of-contents-item/table-of-contents-item.es.js";
7
+ import { TableOfContentsList as q } from "./components/table-of-contents-list/table-of-contents-list.es.js";
8
+ import f from "./table-of-contents.module.scss.es.js";
9
+ import { useLabels as z } from "../../../providers/label-provider/use-labels.es.js";
10
+ import { useBreakpointProps as D } from "../../../helpers/hooks/use-breakpoint-props.es.js";
11
+ import { Card as G } from "../../content/card/card.es.js";
12
+ import { CardContent as J } from "../../content/card/card-content/card-content.es.js";
13
+ const K = j({
14
14
  activeTrail: /* @__PURE__ */ new Set()
15
- }), u = (e) => P(e) && e.type === O, x = (e) => k.toArray(e).filter(u).map((a) => {
16
- const { id: i, separator: s, slot: l, children: r } = a.props, t = k.toArray(r), n = t.filter(u), c = t.filter((d) => !u(d));
15
+ }), u = (n) => F(n) && n.type === x, L = (n) => O.toArray(n).filter(u).map((a) => {
16
+ const { id: s, separator: i, slot: l, children: r } = a.props, t = O.toArray(r), e = t.filter(u), c = t.filter((d) => !u(d));
17
17
  return {
18
- id: i,
19
- separator: s,
18
+ id: s,
19
+ separator: i,
20
20
  slot: l,
21
- content: /* @__PURE__ */ o(B, { children: c }),
22
- children: n.length ? x(r) : void 0
21
+ content: /* @__PURE__ */ o(S, { children: c }),
22
+ children: e.length ? L(r) : void 0
23
23
  };
24
- }), D = (e, a) => {
25
- const i = /* @__PURE__ */ new Set();
26
- if (!a) return i;
27
- const s = (l, r) => {
24
+ }), Q = (n, a) => {
25
+ const s = /* @__PURE__ */ new Set();
26
+ if (!a) return s;
27
+ const i = (l, r) => {
28
28
  for (const t of l) {
29
- const n = t.id ? [...r, t.id] : r;
30
- if (t.id === a || t.children && s(t.children, n))
31
- return n.forEach((c) => i.add(c)), !0;
29
+ const e = t.id ? [...r, t.id] : r;
30
+ if (t.id === a || t.children && i(t.children, e))
31
+ return e.forEach((c) => s.add(c)), !0;
32
32
  }
33
33
  return !1;
34
34
  };
35
- return s(e, []), i;
35
+ return i(n, []), s;
36
36
  };
37
- function b(e) {
38
- const { getLabel: a } = F(), { getCurrentBreakpointProps: i } = H(e.defaultServerBreakpoint), {
39
- children: s,
37
+ function h(n) {
38
+ const { getLabel: a } = z(), { getCurrentBreakpointProps: s } = D(n.defaultServerBreakpoint), {
39
+ children: i,
40
40
  heading: l,
41
41
  headingLevel: r = "h3",
42
42
  ariaLabel: t,
43
- activeId: n,
43
+ activeId: e,
44
44
  defaultOpen: c = !0,
45
45
  numbered: d = !1,
46
- sticky: h = !0,
46
+ sticky: b = !0,
47
47
  variant: C = "default",
48
- bordered: A = !1,
49
- className: L
50
- } = i(e), I = l === void 0 ? a("table-of-contents.title") : l, f = p(() => x(s), [s]), v = p(() => D(f, n), [f, n]), w = p(
51
- () => ({ activeId: n, numbered: d, headingLevel: r, ariaLabel: t, activeTrail: v, defaultOpen: c }),
52
- [n, d, r, t, v, c]
53
- ), T = /* @__PURE__ */ o(
48
+ bordered: w = !1,
49
+ scrollActiveIntoView: v = !1,
50
+ className: E
51
+ } = s(n), B = l === void 0 ? a("table-of-contents.title") : l, m = p(() => L(i), [i]), g = p(() => Q(m, e), [m, e]), T = V(e), y = T.current !== e;
52
+ R(() => {
53
+ T.current = e;
54
+ }, [e]);
55
+ const P = p(
56
+ () => ({
57
+ activeId: e,
58
+ numbered: d,
59
+ headingLevel: r,
60
+ ariaLabel: t,
61
+ activeTrail: g,
62
+ defaultOpen: c,
63
+ scrollActiveIntoView: v,
64
+ activeIdChanged: y
65
+ }),
66
+ [e, d, r, t, g, c, v, y]
67
+ ), N = /* @__PURE__ */ o(
54
68
  "div",
55
69
  {
56
- className: N(m["tedi-table-of-contents"], {
57
- [m["tedi-table-of-contents--transparent"]]: C === "transparent",
58
- [m["tedi-table-of-contents--bordered"]]: A
70
+ className: I(f["tedi-table-of-contents"], {
71
+ [f["tedi-table-of-contents--transparent"]]: C === "transparent",
72
+ [f["tedi-table-of-contents--bordered"]]: w
59
73
  }),
60
- children: /* @__PURE__ */ o(j, { nodes: f, heading: I })
74
+ children: /* @__PURE__ */ o(q, { nodes: m, heading: B })
61
75
  }
62
- ), g = N({ [m["tedi-table-of-contents--sticky"]]: h }, L), y = C === "transparent" ? /* @__PURE__ */ o("div", { className: g, children: T }) : /* @__PURE__ */ o(M, { className: g, children: /* @__PURE__ */ o(q, { padding: 0, children: T }) });
63
- return /* @__PURE__ */ o(z.Provider, { value: w, children: h ? /* @__PURE__ */ o(S, { position: "sticky", top: 1.5, bottom: 1.5, children: y }) : y });
76
+ ), k = I({ [f["tedi-table-of-contents--sticky"]]: b }, E), A = C === "transparent" ? /* @__PURE__ */ o("div", { className: k, children: N }) : /* @__PURE__ */ o(G, { className: k, children: /* @__PURE__ */ o(J, { padding: 0, children: N }) });
77
+ return /* @__PURE__ */ o(K.Provider, { value: P, children: b ? /* @__PURE__ */ o(H, { position: "sticky", top: 1.5, bottom: 1.5, children: A }) : A });
64
78
  }
65
- b.displayName = "TableOfContents";
66
- b.Item = O;
67
- b.Collapsible = V;
79
+ h.displayName = "TableOfContents";
80
+ h.Item = x;
81
+ h.Collapsible = M;
68
82
  export {
69
- b as TableOfContents,
70
- z as TableOfContentsContext,
71
- D as buildActiveTrail,
72
- x as childrenToNodes
83
+ h as TableOfContents,
84
+ K as TableOfContentsContext,
85
+ Q as buildActiveTrail,
86
+ L as childrenToNodes
73
87
  };
@@ -49,14 +49,14 @@ export * from './components/form/number-field/number-field';
49
49
  export * from './components/form/toggle/toggle';
50
50
  export * from './components/form/feedback-text/feedback-text';
51
51
  export * from './components/form/search';
52
- export * from './components/form/radio/radio';
52
+ export * from './components/form/radio';
53
53
  export * from './components/form/choice-group';
54
54
  export * from './components/form/file-upload/file-upload';
55
55
  export * from './components/form/file-dropzone/file-dropzone';
56
56
  export * from './components/form/select/select';
57
57
  export * from './components/form/time-field/time-field';
58
58
  export * from './components/form/time-picker/time-picker';
59
- export * from './components/form/checkbox/checkbox';
59
+ export * from './components/form/checkbox';
60
60
  export * from './components/form/slider/slider';
61
61
  export * from './components/form/date-field/date-field';
62
62
  export * from './components/filter/filter';