@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.
- package/bundle-stats.html +1 -1
- package/component.manifest.json +8 -8
- package/index.css +1 -1
- package/package.json +1 -1
- package/src/community/components/map-components/map-layer/map-layer.cjs.js +1 -1
- package/src/community/components/map-components/map-layer/map-layer.es.js +1 -1
- package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group-context.cjs.js +1 -0
- package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group-context.d.ts +20 -0
- package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group-context.es.js +5 -0
- package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.cjs.js +1 -0
- package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.d.ts +72 -0
- package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.es.js +124 -0
- package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.module.scss.cjs.js +1 -0
- package/src/tedi/components/form/checkbox/checkbox-group/checkbox-group.module.scss.es.js +13 -0
- package/src/tedi/components/form/checkbox/checkbox.cjs.js +1 -1
- package/src/tedi/components/form/checkbox/checkbox.d.ts +8 -2
- package/src/tedi/components/form/checkbox/checkbox.es.js +146 -110
- package/src/tedi/components/form/checkbox/checkbox.module.scss.cjs.js +1 -1
- package/src/tedi/components/form/checkbox/checkbox.module.scss.es.js +11 -3
- package/src/tedi/components/form/checkbox/index.cjs.js +1 -0
- package/src/tedi/components/form/checkbox/index.d.ts +11 -0
- package/src/tedi/components/form/checkbox/index.es.js +7 -0
- package/src/tedi/components/form/choice-group/choice-group.d.ts +11 -0
- package/src/tedi/components/form/choice-group/components/choice-group-item/choice-group-item.cjs.js +1 -1
- package/src/tedi/components/form/choice-group/components/choice-group-item/choice-group-item.es.js +15 -15
- package/src/tedi/components/form/choice-input.types.d.ts +41 -10
- package/src/tedi/components/form/radio/index.cjs.js +1 -0
- package/src/tedi/components/form/radio/index.d.ts +11 -0
- package/src/tedi/components/form/radio/index.es.js +7 -0
- package/src/tedi/components/form/radio/radio-group/radio-group-context.cjs.js +1 -0
- package/src/tedi/components/form/radio/radio-group/radio-group-context.d.ts +21 -0
- package/src/tedi/components/form/radio/radio-group/radio-group-context.es.js +5 -0
- package/src/tedi/components/form/radio/radio-group/radio-group.cjs.js +1 -0
- package/src/tedi/components/form/radio/radio-group/radio-group.d.ts +56 -0
- package/src/tedi/components/form/radio/radio-group/radio-group.es.js +78 -0
- package/src/tedi/components/form/radio/radio-group/radio-group.module.scss.cjs.js +1 -0
- package/src/tedi/components/form/radio/radio-group/radio-group.module.scss.es.js +13 -0
- package/src/tedi/components/form/radio/radio.cjs.js +1 -1
- package/src/tedi/components/form/radio/radio.d.ts +7 -2
- package/src/tedi/components/form/radio/radio.es.js +116 -78
- package/src/tedi/components/form/radio/radio.module.scss.cjs.js +1 -1
- package/src/tedi/components/form/radio/radio.module.scss.es.js +11 -3
- package/src/tedi/components/navigation/table-of-contents/components/table-of-contents-row/table-of-contents-row.cjs.js +1 -1
- package/src/tedi/components/navigation/table-of-contents/components/table-of-contents-row/table-of-contents-row.d.ts +12 -0
- package/src/tedi/components/navigation/table-of-contents/components/table-of-contents-row/table-of-contents-row.es.js +57 -27
- package/src/tedi/components/navigation/table-of-contents/table-of-contents.cjs.js +1 -1
- package/src/tedi/components/navigation/table-of-contents/table-of-contents.d.ts +17 -0
- package/src/tedi/components/navigation/table-of-contents/table-of-contents.es.js +65 -51
- package/src/tedi/index.d.ts +2 -2
- package/src/tedi/providers/label-provider/labels-map.cjs.js +1 -1
- package/src/tedi/providers/label-provider/labels-map.d.ts +14 -0
- package/src/tedi/providers/label-provider/labels-map.es.js +25 -11
- package/tedi.cjs.js +1 -1
- package/tedi.es.js +298 -294
|
@@ -1,98 +1,136 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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:
|
|
14
|
-
className:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
hideLabel: y,
|
|
16
|
+
value: s,
|
|
17
|
+
className: y,
|
|
18
|
+
onChange: c,
|
|
19
|
+
hideLabel: C,
|
|
18
20
|
helper: r,
|
|
19
|
-
checked:
|
|
20
|
-
defaultChecked:
|
|
21
|
-
hover:
|
|
22
|
-
name:
|
|
23
|
-
tooltip:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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:
|
|
102
|
+
className: t(a["tedi-radio"], { [a["tedi-radio--disabled"]]: h }),
|
|
36
103
|
"data-name": "radio",
|
|
37
|
-
...
|
|
104
|
+
...w,
|
|
38
105
|
children: [
|
|
39
|
-
/* @__PURE__ */
|
|
40
|
-
/* @__PURE__ */
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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__ */
|
|
76
|
-
|
|
113
|
+
m && /* @__PURE__ */ i(V, { children: /* @__PURE__ */ i(
|
|
114
|
+
ae,
|
|
77
115
|
{
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
id: o,
|
|
116
|
+
className: Z,
|
|
117
|
+
id: n,
|
|
81
118
|
"data-testid": "radio-label",
|
|
82
|
-
hideLabel:
|
|
119
|
+
hideLabel: C,
|
|
83
120
|
label: m,
|
|
84
|
-
tooltip:
|
|
85
|
-
required:
|
|
86
|
-
labelProps:
|
|
121
|
+
tooltip: P,
|
|
122
|
+
required: I,
|
|
123
|
+
labelProps: F
|
|
87
124
|
}
|
|
88
125
|
) })
|
|
89
126
|
] }),
|
|
90
|
-
r && /* @__PURE__ */
|
|
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
|
-
|
|
97
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
22
|
+
d as default
|
|
15
23
|
};
|
|
@@ -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"),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
|
|
2
|
-
import
|
|
3
|
-
import { useContext as
|
|
4
|
-
import { Separator as
|
|
5
|
-
import { TableOfContentsContext as
|
|
6
|
-
import
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
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":
|
|
13
|
-
className:
|
|
14
|
-
[
|
|
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__ */
|
|
18
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
58
|
+
l.id ?? r
|
|
31
59
|
)) }),
|
|
32
|
-
|
|
60
|
+
E && /* @__PURE__ */ a(T, { className: o["tedi-table-of-contents__separator"] })
|
|
33
61
|
]
|
|
34
62
|
}
|
|
35
63
|
);
|
|
36
64
|
};
|
|
37
|
-
|
|
65
|
+
y.displayName = "TableOfContentsRow";
|
|
38
66
|
export {
|
|
39
|
-
|
|
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"),
|
|
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
|
|
2
|
-
import
|
|
3
|
-
import { useMemo as p, createContext as
|
|
4
|
-
import { Affix as
|
|
5
|
-
import { TableOfContentsCollapsible as
|
|
6
|
-
import { TableOfContentsItem as
|
|
7
|
-
import { TableOfContentsList as
|
|
8
|
-
import
|
|
9
|
-
import { useLabels as
|
|
10
|
-
import { useBreakpointProps as
|
|
11
|
-
import { Card as
|
|
12
|
-
import { CardContent as
|
|
13
|
-
const
|
|
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 = (
|
|
16
|
-
const { id:
|
|
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:
|
|
19
|
-
separator:
|
|
18
|
+
id: s,
|
|
19
|
+
separator: i,
|
|
20
20
|
slot: l,
|
|
21
|
-
content: /* @__PURE__ */ o(
|
|
22
|
-
children:
|
|
21
|
+
content: /* @__PURE__ */ o(S, { children: c }),
|
|
22
|
+
children: e.length ? L(r) : void 0
|
|
23
23
|
};
|
|
24
|
-
}),
|
|
25
|
-
const
|
|
26
|
-
if (!a) return
|
|
27
|
-
const
|
|
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
|
|
30
|
-
if (t.id === a || t.children &&
|
|
31
|
-
return
|
|
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
|
|
35
|
+
return i(n, []), s;
|
|
36
36
|
};
|
|
37
|
-
function
|
|
38
|
-
const { getLabel: a } =
|
|
39
|
-
children:
|
|
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:
|
|
43
|
+
activeId: e,
|
|
44
44
|
defaultOpen: c = !0,
|
|
45
45
|
numbered: d = !1,
|
|
46
|
-
sticky:
|
|
46
|
+
sticky: b = !0,
|
|
47
47
|
variant: C = "default",
|
|
48
|
-
bordered:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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:
|
|
57
|
-
[
|
|
58
|
-
[
|
|
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(
|
|
74
|
+
children: /* @__PURE__ */ o(q, { nodes: m, heading: B })
|
|
61
75
|
}
|
|
62
|
-
),
|
|
63
|
-
return /* @__PURE__ */ o(
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
79
|
+
h.displayName = "TableOfContents";
|
|
80
|
+
h.Item = x;
|
|
81
|
+
h.Collapsible = M;
|
|
68
82
|
export {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
83
|
+
h as TableOfContents,
|
|
84
|
+
K as TableOfContentsContext,
|
|
85
|
+
Q as buildActiveTrail,
|
|
86
|
+
L as childrenToNodes
|
|
73
87
|
};
|
package/src/tedi/index.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
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';
|