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

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 (68) hide show
  1. package/bundle-stats.html +1 -1
  2. package/component.manifest.json +8 -8
  3. package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.cjs.js +1 -1
  4. package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.es.js +1 -1
  5. package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
  6. package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.es.js +1 -1
  7. package/external/hoist-non-react-statics/external/react-is/index.cjs.js +1 -1
  8. package/external/hoist-non-react-statics/external/react-is/index.es.js +1 -1
  9. package/external/prop-types/external/react-is/cjs/react-is.development.cjs.js +1 -1
  10. package/external/prop-types/external/react-is/cjs/react-is.development.es.js +1 -1
  11. package/external/prop-types/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
  12. package/external/prop-types/external/react-is/cjs/react-is.production.min.es.js +1 -1
  13. package/external/prop-types/external/react-is/index.cjs.js +1 -1
  14. package/external/prop-types/external/react-is/index.es.js +1 -1
  15. package/index.css +1 -1
  16. package/package.json +2 -2
  17. package/src/community/components/map-components/map-layer/map-layer.cjs.js +1 -1
  18. package/src/community/components/map-components/map-layer/map-layer.es.js +1 -1
  19. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group-context.cjs.js +1 -0
  20. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group-context.d.ts +20 -0
  21. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group-context.es.js +5 -0
  22. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.cjs.js +1 -0
  23. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.d.ts +72 -0
  24. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.es.js +124 -0
  25. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.module.scss.cjs.js +1 -0
  26. package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.module.scss.es.js +13 -0
  27. package/src/tedi/components/form/checkbox/checkbox.cjs.js +1 -1
  28. package/src/tedi/components/form/checkbox/checkbox.d.ts +8 -2
  29. package/src/tedi/components/form/checkbox/checkbox.es.js +146 -110
  30. package/src/tedi/components/form/checkbox/checkbox.module.scss.cjs.js +1 -1
  31. package/src/tedi/components/form/checkbox/checkbox.module.scss.es.js +11 -3
  32. package/src/tedi/components/form/checkbox/index.cjs.js +1 -0
  33. package/src/tedi/components/form/checkbox/index.d.ts +11 -0
  34. package/src/tedi/components/form/checkbox/index.es.js +7 -0
  35. package/src/tedi/components/form/choice-group/choice-group.d.ts +11 -0
  36. package/src/tedi/components/form/choice-group/components/choice-group-item/choice-group-item.cjs.js +1 -1
  37. package/src/tedi/components/form/choice-group/components/choice-group-item/choice-group-item.es.js +15 -15
  38. package/src/tedi/components/form/choice-input.types.d.ts +41 -10
  39. package/src/tedi/components/form/radio/index.cjs.js +1 -0
  40. package/src/tedi/components/form/radio/index.d.ts +11 -0
  41. package/src/tedi/components/form/radio/index.es.js +7 -0
  42. package/src/tedi/components/form/radio/radio-group/radio-group-context.cjs.js +1 -0
  43. package/src/tedi/components/form/radio/radio-group/radio-group-context.d.ts +21 -0
  44. package/src/tedi/components/form/radio/radio-group/radio-group-context.es.js +5 -0
  45. package/src/tedi/components/form/radio/radio-group/radio-group.cjs.js +1 -0
  46. package/src/tedi/components/form/radio/radio-group/radio-group.d.ts +56 -0
  47. package/src/tedi/components/form/radio/radio-group/radio-group.es.js +78 -0
  48. package/src/tedi/components/form/radio/radio-group/radio-group.module.scss.cjs.js +1 -0
  49. package/src/tedi/components/form/radio/radio-group/radio-group.module.scss.es.js +13 -0
  50. package/src/tedi/components/form/radio/radio.cjs.js +1 -1
  51. package/src/tedi/components/form/radio/radio.d.ts +7 -2
  52. package/src/tedi/components/form/radio/radio.es.js +116 -78
  53. package/src/tedi/components/form/radio/radio.module.scss.cjs.js +1 -1
  54. package/src/tedi/components/form/radio/radio.module.scss.es.js +11 -3
  55. package/src/tedi/components/form/textarea/textarea.cjs.js +1 -1
  56. package/src/tedi/components/form/textarea/textarea.es.js +71 -62
  57. package/src/tedi/components/navigation/table-of-contents/components/table-of-contents-row/table-of-contents-row.cjs.js +1 -1
  58. package/src/tedi/components/navigation/table-of-contents/components/table-of-contents-row/table-of-contents-row.d.ts +12 -0
  59. package/src/tedi/components/navigation/table-of-contents/components/table-of-contents-row/table-of-contents-row.es.js +57 -27
  60. package/src/tedi/components/navigation/table-of-contents/table-of-contents.cjs.js +1 -1
  61. package/src/tedi/components/navigation/table-of-contents/table-of-contents.d.ts +17 -0
  62. package/src/tedi/components/navigation/table-of-contents/table-of-contents.es.js +65 -51
  63. package/src/tedi/index.d.ts +2 -2
  64. package/src/tedi/providers/label-provider/labels-map.cjs.js +1 -1
  65. package/src/tedi/providers/label-provider/labels-map.d.ts +14 -0
  66. package/src/tedi/providers/label-provider/labels-map.es.js +25 -11
  67. package/tedi.cjs.js +1 -1
  68. 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 L=require("react/jsx-runtime"),w=require("../../../../../external/classnames/index.cjs.js"),a=require("react"),O=require("../textfield/textfield.cjs.js"),d=require("./textarea.module.scss.cjs.js"),N=a.forwardRef((_,o)=>{const{className:b,helper:p=[],characterLimit:s,onChange:n,onChangeEvent:g,value:l,defaultValue:q,autoGrow:t=!1,minRows:u=3,maxRows:y=12,height:H="7.5rem",maxHeight:i,...F}=_,[T,A]=a.useState(q??""),c=a.useRef(null),[v,E]=a.useState("auto"),j=a.useCallback(e=>{!l&&!(n||g)&&A(e),n==null||n(e)},[l,n,g]),m=a.useMemo(()=>l??T,[l,T]),r=a.useCallback(()=>{if(!t||!c.current)return;const e=c.current,$=e.style.overflow;e.style.overflow="hidden";const f=window.getComputedStyle(e);let h=parseFloat(f.lineHeight);isNaN(h)&&(h=(parseFloat(f.fontSize)||16)*1.5);const S=parseFloat(f.paddingTop),R=parseFloat(f.paddingBottom),B=e.scrollHeight-S-R;let x=Math.ceil(B/h);x=Math.min(Math.max(x,u),y);const M=`${x*h+S+R}px`;e.style.height=M,E(M),e.style.overflow=$,e.style.overflowY=e.scrollHeight>e.clientHeight?"auto":"hidden"},[t,u,y]);a.useEffect(()=>{t&&requestAnimationFrame(()=>{r()})},[m,t,r]),a.useEffect(()=>{t&&c.current&&r()},[t,r]);const k=a.useCallback(e=>{o&&(typeof o=="function"?o(e):o.current=e),e!=null&&e.input&&e.input instanceof HTMLTextAreaElement&&(c.current=e.input,t&&setTimeout(r,0))},[o,t,r]),z=a.useMemo(()=>t?{rows:u,style:{...i?{maxHeight:i}:{},overflow:"hidden",height:v}}:{style:{height:H,...i?{maxHeight:i}:{},overflow:"auto"}},[t,u,i,H,v]),C=m.length,I=s?`${C}/${s}`:"",V=[...Array.isArray(p)?p:[p],...s?[{type:C>s?"error":"hint",text:I,position:"right",className:w.default(d.default["tedi-textarea__character-count"])}]:[]];return L.jsx(O.TextField,{...F,ref:k,"data-name":"textarea",inputClassName:w.default(d.default["tedi-textarea__input"],{[d.default["tedi-textarea__input--auto-grow"]]:t}),isTextArea:!0,className:w.default(d.default["tedi-textarea"],b),value:m,onChange:j,onChangeEvent:g,helper:V,input:z})});N.displayName="Textarea";exports.Textarea=N;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("react/jsx-runtime"),b=require("../../../../../external/classnames/index.cjs.js"),a=require("react"),L=require("../textfield/textfield.cjs.js"),m=require("./textarea.module.scss.cjs.js"),M=a.forwardRef((N,i)=>{const{className:_,helper:w=[],characterLimit:d,onChange:l,onChangeEvent:y,value:h,defaultValue:q,autoGrow:t=!1,minRows:f=3,maxRows:v=12,height:T="7.5rem",maxHeight:c,...z}=N,[C,A]=a.useState(q??""),u=a.useRef(null),[R,E]=a.useState("auto"),O=a.useCallback(e=>{!h&&!(l||y)&&A(e),l==null||l(e)},[h,l,y]),H=a.useMemo(()=>h??C,[h,C]),r=a.useCallback(()=>{if(!t||!u.current)return;const e=u.current,p=e.style.overflow;e.style.overflow="hidden";const o=window.getComputedStyle(e);let n=parseFloat(o.lineHeight);isNaN(n)&&(n=(parseFloat(o.fontSize)||16)*1.5);const s=parseFloat(o.paddingTop),g=parseFloat(o.paddingBottom),x=o.boxSizing==="border-box"?(parseFloat(o.borderTopWidth)||0)+(parseFloat(o.borderBottomWidth)||0):0;e.style.height="auto";const I=e.scrollHeight-s-g,V=Math.ceil((I-1)/n),F=`${Math.min(Math.max(V,f),v)*n+s+g+x}px`;e.style.height=F,E(F),e.style.overflow=p,e.style.overflowY=e.scrollHeight-e.clientHeight>1?"auto":"hidden"},[t,f,v]);a.useEffect(()=>{t&&requestAnimationFrame(()=>{r()})},[H,t,r]),a.useEffect(()=>{t&&u.current&&r()},[t,r]),a.useEffect(()=>{const e=u.current;if(!t||!e||typeof ResizeObserver>"u")return;let p=e.clientWidth;const o=new ResizeObserver(n=>{var x;const s=((x=n[0])==null?void 0:x.contentRect.width)??0,g=s!==p;p=s,s>0&&g&&r()});return o.observe(e),()=>o.disconnect()},[t,r]);const W=a.useCallback(e=>{i&&(typeof i=="function"?i(e):i.current=e),e!=null&&e.input&&e.input instanceof HTMLTextAreaElement&&(u.current=e.input,t&&setTimeout(r,0))},[i,t,r]),j=a.useMemo(()=>t?{rows:f,style:{...c?{maxHeight:c}:{},overflow:"hidden",height:R}}:{style:{height:T,...c?{maxHeight:c}:{},overflow:"auto"}},[t,f,c,T,R]),S=H.length,k=d?`${S}/${d}`:"",B=[...Array.isArray(w)?w:[w],...d?[{type:S>d?"error":"hint",text:k,position:"right",className:b.default(m.default["tedi-textarea__character-count"])}]:[]];return $.jsx(L.TextField,{...z,ref:W,"data-name":"textarea",inputClassName:b.default(m.default["tedi-textarea__input"],{[m.default["tedi-textarea__input--auto-grow"]]:t}),isTextArea:!0,className:b.default(m.default["tedi-textarea"],_),value:H,onChange:O,onChangeEvent:y,helper:B,input:j})});M.displayName="Textarea";exports.Textarea=M;
@@ -1,93 +1,102 @@
1
- import { jsx as q } from "react/jsx-runtime";
2
- import w from "../../../../../external/classnames/index.es.js";
3
- import a, { forwardRef as G, useRef as O, useEffect as S } from "react";
1
+ import { jsx as j } from "react/jsx-runtime";
2
+ import v from "../../../../../external/classnames/index.es.js";
3
+ import a, { forwardRef as q, useRef as G, useEffect as b } from "react";
4
4
  import { TextField as P } from "../textfield/textfield.es.js";
5
- import p from "./textarea.module.scss.es.js";
6
- const Y = G((F, r) => {
5
+ import x from "./textarea.module.scss.es.js";
6
+ const Y = q((_, i) => {
7
7
  const {
8
- className: M,
9
- helper: f = [],
10
- characterLimit: i,
11
- onChange: s,
12
- onChangeEvent: g,
13
- value: l,
14
- defaultValue: A,
8
+ className: z,
9
+ helper: w = [],
10
+ characterLimit: h,
11
+ onChange: l,
12
+ onChangeEvent: y,
13
+ value: p,
14
+ defaultValue: M,
15
15
  autoGrow: e = !1,
16
- minRows: c = 3,
17
- maxRows: H = 12,
18
- height: y = "7.5rem",
19
- maxHeight: n,
20
- ...b
21
- } = F, [v, k] = a.useState(A ?? ""), u = O(null), [C, z] = a.useState("auto"), E = a.useCallback(
16
+ minRows: f = 3,
17
+ maxRows: C = 12,
18
+ height: R = "7.5rem",
19
+ maxHeight: c,
20
+ ...A
21
+ } = _, [T, W] = a.useState(M ?? ""), u = G(null), [F, k] = a.useState("auto"), B = a.useCallback(
22
22
  (t) => {
23
- !l && !(s || g) && k(t), s == null || s(t);
23
+ !p && !(l || y) && W(t), l == null || l(t);
24
24
  },
25
- [l, s, g]
26
- ), x = a.useMemo(() => l ?? v, [l, v]), o = a.useCallback(() => {
25
+ [p, l, y]
26
+ ), H = a.useMemo(() => p ?? T, [p, T]), r = a.useCallback(() => {
27
27
  if (!e || !u.current) return;
28
- const t = u.current, L = t.style.overflow;
28
+ const t = u.current, d = t.style.overflow;
29
29
  t.style.overflow = "hidden";
30
- const h = window.getComputedStyle(t);
31
- let m = parseFloat(h.lineHeight);
32
- isNaN(m) && (m = (parseFloat(h.fontSize) || 16) * 1.5);
33
- const N = parseFloat(h.paddingTop), _ = parseFloat(h.paddingBottom), j = t.scrollHeight - N - _;
34
- let d = Math.ceil(j / m);
35
- d = Math.min(Math.max(d, c), H);
36
- const R = `${d * m + N + _}px`;
37
- t.style.height = R, z(R), t.style.overflow = L, t.style.overflowY = t.scrollHeight > t.clientHeight ? "auto" : "hidden";
38
- }, [e, c, H]);
39
- S(() => {
30
+ const o = window.getComputedStyle(t);
31
+ let n = parseFloat(o.lineHeight);
32
+ isNaN(n) && (n = (parseFloat(o.fontSize) || 16) * 1.5);
33
+ const s = parseFloat(o.paddingTop), m = parseFloat(o.paddingBottom), g = o.boxSizing === "border-box" ? (parseFloat(o.borderTopWidth) || 0) + (parseFloat(o.borderBottomWidth) || 0) : 0;
34
+ t.style.height = "auto";
35
+ const $ = t.scrollHeight - s - m, L = Math.ceil(($ - 1) / n), S = `${Math.min(Math.max(L, f), C) * n + s + m + g}px`;
36
+ t.style.height = S, k(S), t.style.overflow = d, t.style.overflowY = t.scrollHeight - t.clientHeight > 1 ? "auto" : "hidden";
37
+ }, [e, f, C]);
38
+ b(() => {
40
39
  e && requestAnimationFrame(() => {
41
- o();
40
+ r();
42
41
  });
43
- }, [x, e, o]), S(() => {
44
- e && u.current && o();
45
- }, [e, o]);
46
- const I = a.useCallback(
42
+ }, [H, e, r]), b(() => {
43
+ e && u.current && r();
44
+ }, [e, r]), b(() => {
45
+ const t = u.current;
46
+ if (!e || !t || typeof ResizeObserver > "u") return;
47
+ let d = t.clientWidth;
48
+ const o = new ResizeObserver((n) => {
49
+ var g;
50
+ const s = ((g = n[0]) == null ? void 0 : g.contentRect.width) ?? 0, m = s !== d;
51
+ d = s, s > 0 && m && r();
52
+ });
53
+ return o.observe(t), () => o.disconnect();
54
+ }, [e, r]);
55
+ const E = a.useCallback(
47
56
  (t) => {
48
- r && (typeof r == "function" ? r(t) : r.current = t), t != null && t.input && t.input instanceof HTMLTextAreaElement && (u.current = t.input, e && setTimeout(o, 0));
57
+ i && (typeof i == "function" ? i(t) : i.current = t), t != null && t.input && t.input instanceof HTMLTextAreaElement && (u.current = t.input, e && setTimeout(r, 0));
49
58
  },
50
- [r, e, o]
51
- ), V = a.useMemo(() => e ? {
52
- rows: c,
59
+ [i, e, r]
60
+ ), I = a.useMemo(() => e ? {
61
+ rows: f,
53
62
  style: {
54
- ...n ? { maxHeight: n } : {},
63
+ ...c ? { maxHeight: c } : {},
55
64
  overflow: "hidden",
56
- height: C
65
+ height: F
57
66
  }
58
67
  } : {
59
68
  style: {
60
- height: y,
61
- ...n ? { maxHeight: n } : {},
69
+ height: R,
70
+ ...c ? { maxHeight: c } : {},
62
71
  overflow: "auto"
63
72
  }
64
- }, [e, c, n, y, C]), T = x.length, $ = i ? `${T}/${i}` : "", B = [
65
- ...Array.isArray(f) ? f : [f],
66
- ...i ? [
73
+ }, [e, f, c, R, F]), N = H.length, O = h ? `${N}/${h}` : "", V = [
74
+ ...Array.isArray(w) ? w : [w],
75
+ ...h ? [
67
76
  {
68
- type: T > i ? "error" : "hint",
69
- text: $,
77
+ type: N > h ? "error" : "hint",
78
+ text: O,
70
79
  position: "right",
71
- className: w(p["tedi-textarea__character-count"])
80
+ className: v(x["tedi-textarea__character-count"])
72
81
  }
73
82
  ] : []
74
83
  ];
75
- return /* @__PURE__ */ q(
84
+ return /* @__PURE__ */ j(
76
85
  P,
77
86
  {
78
- ...b,
79
- ref: I,
87
+ ...A,
88
+ ref: E,
80
89
  "data-name": "textarea",
81
- inputClassName: w(p["tedi-textarea__input"], {
82
- [p["tedi-textarea__input--auto-grow"]]: e
90
+ inputClassName: v(x["tedi-textarea__input"], {
91
+ [x["tedi-textarea__input--auto-grow"]]: e
83
92
  }),
84
93
  isTextArea: !0,
85
- className: w(p["tedi-textarea"], M),
86
- value: x,
87
- onChange: E,
88
- onChangeEvent: g,
89
- helper: B,
90
- input: V
94
+ className: v(x["tedi-textarea"], z),
95
+ value: H,
96
+ onChange: B,
97
+ onChangeEvent: y,
98
+ helper: V,
99
+ input: I
91
100
  }
92
101
  );
93
102
  });
@@ -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[];