@lincyaw/aegis-ui 0.15.0 → 0.17.0

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime");;/* empty css */const b=require("./linkComponent.cjs"),o=require("../../locale/useStrings.cjs");function d({items:s,className:i,linkComponent:c}){const t=o.useStrings(),l=["aegis-breadcrumb",i??""].filter(Boolean).join(" "),u=c??b.DefaultLink;return e.jsx("nav",{"aria-label":t.breadcrumb,className:l,children:e.jsx("ol",{className:"aegis-breadcrumb__list",children:s.map((r,n)=>{const a=n===s.length-1;return e.jsxs("li",{className:"aegis-breadcrumb__item",children:[r.to&&!a?e.jsx(u,{to:r.to,className:"aegis-breadcrumb__link",children:r.label}):e.jsx("span",{className:a?"aegis-breadcrumb__text aegis-breadcrumb__text--current":"aegis-breadcrumb__text","aria-current":a?"page":void 0,children:r.label}),!a&&e.jsx("span",{className:"aegis-breadcrumb__sep","aria-hidden":"true",children:"/"})]},n)})})})}exports.Breadcrumb=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime");;/* empty css */const g=require("./linkComponent.cjs"),_=require("../../locale/useStrings.cjs");function p({items:s,className:t,ariaLabel:l,linkComponent:u}){const o=_.useStrings(),b=["aegis-breadcrumb",t??""].filter(Boolean).join(" "),d=u??g.DefaultLink,i=s.some(e=>e.current!==void 0);return r.jsx("nav",{"aria-label":l??o.breadcrumb,className:b,children:r.jsx("ol",{className:"aegis-breadcrumb__list",children:s.map((e,c)=>{const n=c===s.length-1,a=i?e.current===!0:n,m=e.to!==void 0&&(i||!n);return r.jsxs("li",{className:"aegis-breadcrumb__item",children:[m&&e.to!==void 0?r.jsx(d,{to:e.to,className:a?"aegis-breadcrumb__link aegis-breadcrumb__link--current":"aegis-breadcrumb__link","aria-current":a?"page":void 0,children:e.label}):r.jsx("span",{className:a?"aegis-breadcrumb__text aegis-breadcrumb__text--current":"aegis-breadcrumb__text","aria-current":a?"page":void 0,children:e.label}),!n&&r.jsx("span",{className:"aegis-breadcrumb__sep","aria-hidden":"true",children:"/"})]},c)})})})}exports.Breadcrumb=p;
2
2
  //# sourceMappingURL=Breadcrumb.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Breadcrumb.cjs","sources":["../../../src/components/ui/Breadcrumb.tsx"],"sourcesContent":["import { type ReactElement, type ReactNode } from 'react';\n\nimport { useStrings } from '../../locale';\nimport './Breadcrumb.css';\nimport { DefaultLink, type LinkComponent } from './linkComponent';\n\nexport interface BreadcrumbItem {\n label: ReactNode;\n /** Optional destination. If omitted, the item renders as plain text. */\n to?: string;\n}\n\ninterface BreadcrumbProps {\n items: BreadcrumbItem[];\n className?: string;\n /**\n * Component used to render linked breadcrumb items. Defaults to an\n * unstyled `<a href>`. Sub-apps using a router should pass their\n * Link adapter here.\n */\n linkComponent?: LinkComponent;\n}\n\nexport function Breadcrumb({\n items,\n className,\n linkComponent,\n}: BreadcrumbProps): ReactElement {\n const strings = useStrings();\n const cls = ['aegis-breadcrumb', className ?? ''].filter(Boolean).join(' ');\n const LinkImpl = linkComponent ?? DefaultLink;\n\n return (\n <nav aria-label={strings.breadcrumb} className={cls}>\n <ol className=\"aegis-breadcrumb__list\">\n {items.map((item, idx) => {\n const isLast = idx === items.length - 1;\n return (\n <li key={idx} className=\"aegis-breadcrumb__item\">\n {item.to && !isLast ? (\n <LinkImpl to={item.to} className=\"aegis-breadcrumb__link\">\n {item.label}\n </LinkImpl>\n ) : (\n <span\n className={\n isLast\n ? 'aegis-breadcrumb__text aegis-breadcrumb__text--current'\n : 'aegis-breadcrumb__text'\n }\n aria-current={isLast ? 'page' : undefined}\n >\n {item.label}\n </span>\n )}\n {!isLast && (\n <span className=\"aegis-breadcrumb__sep\" aria-hidden=\"true\">\n /\n </span>\n )}\n </li>\n );\n })}\n </ol>\n </nav>\n );\n}\n"],"names":["Breadcrumb","items","className","linkComponent","strings","useStrings","cls","LinkImpl","DefaultLink","jsx","item","idx","isLast","jsxs"],"mappings":"qOAuBO,SAASA,EAAW,CACzB,MAAAC,EACA,UAAAC,EAAA,cACAC,CACF,EAAkC,CAChC,MAAMC,EAAUC,EAAAA,WAAA,EACVC,EAAM,CAAC,mBAAoBJ,GAAa,EAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,EACpEK,EAAWJ,GAAiBK,EAAAA,YAElC,OACEC,EAAAA,IAAC,MAAA,CAAI,aAAYL,EAAQ,WAAY,UAAWE,EAC9C,SAAAG,EAAAA,IAAC,KAAA,CAAG,UAAU,yBACX,SAAAR,EAAM,IAAI,CAACS,EAAMC,IAAQ,CACxB,MAAMC,EAASD,IAAQV,EAAM,OAAS,EACtC,OACEY,EAAAA,KAAC,KAAA,CAAa,UAAU,yBACrB,SAAA,CAAAH,EAAK,IAAM,CAACE,EACXH,EAAAA,IAACF,EAAA,CAAS,GAAIG,EAAK,GAAI,UAAU,yBAC9B,SAAAA,EAAK,KAAA,CACR,EAEAD,EAAAA,IAAC,OAAA,CACC,UACEG,EACI,yDACA,yBAEN,eAAcA,EAAS,OAAS,OAE/B,SAAAF,EAAK,KAAA,CAAA,EAGT,CAACE,GACAH,MAAC,OAAA,CAAK,UAAU,wBAAwB,cAAY,OAAO,SAAA,GAAA,CAE3D,CAAA,CAAA,EApBKE,CAsBT,CAEJ,CAAC,EACH,EACF,CAEJ"}
1
+ {"version":3,"file":"Breadcrumb.cjs","sources":["../../../src/components/ui/Breadcrumb.tsx"],"sourcesContent":["import { type ReactElement, type ReactNode } from 'react';\n\nimport { useStrings } from '../../locale';\nimport './Breadcrumb.css';\nimport { DefaultLink, type LinkComponent } from './linkComponent';\n\nexport interface BreadcrumbItem {\n label: ReactNode;\n /** Optional destination. If omitted, the item renders as plain text. */\n to?: string;\n /**\n * Marks the item as the current page: `aria-current=\"page\"` and main ink.\n * When no item sets it, the last item is the current page and renders as\n * text. Once any item sets it, every item with `to` renders as a link,\n * the last included, and only the items set to `true` are current, so a\n * trail can end at a page other than the one shown.\n */\n current?: boolean;\n}\n\ninterface BreadcrumbProps {\n items: BreadcrumbItem[];\n className?: string;\n /** Accessible name of the navigation. Defaults to the locale's `breadcrumb`. */\n ariaLabel?: string;\n /**\n * Component used to render linked breadcrumb items. Defaults to an\n * unstyled `<a href>`. Sub-apps using a router should pass their\n * Link adapter here.\n */\n linkComponent?: LinkComponent;\n}\n\nexport function Breadcrumb({\n items,\n className,\n ariaLabel,\n linkComponent,\n}: BreadcrumbProps): ReactElement {\n const strings = useStrings();\n const cls = ['aegis-breadcrumb', className ?? ''].filter(Boolean).join(' ');\n const LinkImpl = linkComponent ?? DefaultLink;\n const explicit = items.some((item) => item.current !== undefined);\n\n return (\n <nav aria-label={ariaLabel ?? strings.breadcrumb} className={cls}>\n <ol className=\"aegis-breadcrumb__list\">\n {items.map((item, idx) => {\n const isLast = idx === items.length - 1;\n const isCurrent = explicit ? item.current === true : isLast;\n const linked = item.to !== undefined && (explicit || !isLast);\n return (\n <li key={idx} className=\"aegis-breadcrumb__item\">\n {linked && item.to !== undefined ? (\n <LinkImpl\n to={item.to}\n className={\n isCurrent\n ? 'aegis-breadcrumb__link aegis-breadcrumb__link--current'\n : 'aegis-breadcrumb__link'\n }\n aria-current={isCurrent ? 'page' : undefined}\n >\n {item.label}\n </LinkImpl>\n ) : (\n <span\n className={\n isCurrent\n ? 'aegis-breadcrumb__text aegis-breadcrumb__text--current'\n : 'aegis-breadcrumb__text'\n }\n aria-current={isCurrent ? 'page' : undefined}\n >\n {item.label}\n </span>\n )}\n {!isLast && (\n <span className=\"aegis-breadcrumb__sep\" aria-hidden=\"true\">\n /\n </span>\n )}\n </li>\n );\n })}\n </ol>\n </nav>\n );\n}\n"],"names":["Breadcrumb","items","className","ariaLabel","linkComponent","strings","useStrings","cls","LinkImpl","DefaultLink","explicit","item","jsx","idx","isLast","isCurrent","linked","jsxs"],"mappings":"qOAiCO,SAASA,EAAW,CACzB,MAAAC,EACA,UAAAC,EACA,UAAAC,EAAA,cACAC,CACF,EAAkC,CAChC,MAAMC,EAAUC,EAAAA,WAAA,EACVC,EAAM,CAAC,mBAAoBL,GAAa,EAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,EACpEM,EAAWJ,GAAiBK,EAAAA,YAC5BC,EAAWT,EAAM,KAAMU,GAASA,EAAK,UAAY,MAAS,EAEhE,aACG,MAAA,CAAI,aAAYR,GAAaE,EAAQ,WAAY,UAAWE,EAC3D,SAAAK,EAAAA,IAAC,KAAA,CAAG,UAAU,yBACX,SAAAX,EAAM,IAAI,CAACU,EAAME,IAAQ,CACxB,MAAMC,EAASD,IAAQZ,EAAM,OAAS,EAChCc,EAAYL,EAAWC,EAAK,UAAY,GAAOG,EAC/CE,EAASL,EAAK,KAAO,SAAcD,GAAY,CAACI,GACtD,OACEG,EAAAA,KAAC,KAAA,CAAa,UAAU,yBACrB,SAAA,CAAAD,GAAUL,EAAK,KAAO,OACrBC,EAAAA,IAACJ,EAAA,CACC,GAAIG,EAAK,GACT,UACEI,EACI,yDACA,yBAEN,eAAcA,EAAY,OAAS,OAElC,SAAAJ,EAAK,KAAA,CAAA,EAGRC,EAAAA,IAAC,OAAA,CACC,UACEG,EACI,yDACA,yBAEN,eAAcA,EAAY,OAAS,OAElC,SAAAJ,EAAK,KAAA,CAAA,EAGT,CAACG,GACAF,MAAC,OAAA,CAAK,UAAU,wBAAwB,cAAY,OAAO,SAAA,GAAA,CAE3D,CAAA,CAAA,EA5BKC,CA8BT,CAEJ,CAAC,EACH,EACF,CAEJ"}
@@ -4,10 +4,20 @@ export interface BreadcrumbItem {
4
4
  label: ReactNode;
5
5
  /** Optional destination. If omitted, the item renders as plain text. */
6
6
  to?: string;
7
+ /**
8
+ * Marks the item as the current page: `aria-current="page"` and main ink.
9
+ * When no item sets it, the last item is the current page and renders as
10
+ * text. Once any item sets it, every item with `to` renders as a link,
11
+ * the last included, and only the items set to `true` are current, so a
12
+ * trail can end at a page other than the one shown.
13
+ */
14
+ current?: boolean;
7
15
  }
8
16
  interface BreadcrumbProps {
9
17
  items: BreadcrumbItem[];
10
18
  className?: string;
19
+ /** Accessible name of the navigation. Defaults to the locale's `breadcrumb`. */
20
+ ariaLabel?: string;
11
21
  /**
12
22
  * Component used to render linked breadcrumb items. Defaults to an
13
23
  * unstyled `<a href>`. Sub-apps using a router should pass their
@@ -15,5 +25,5 @@ interface BreadcrumbProps {
15
25
  */
16
26
  linkComponent?: LinkComponent;
17
27
  }
18
- export declare function Breadcrumb({ items, className, linkComponent, }: BreadcrumbProps): ReactElement;
28
+ export declare function Breadcrumb({ items, className, ariaLabel, linkComponent, }: BreadcrumbProps): ReactElement;
19
29
  export {};
@@ -1,29 +1,38 @@
1
- import { jsx as r, jsxs as m } from "react/jsx-runtime";
1
+ import { jsx as e, jsxs as _ } from "react/jsx-runtime";
2
2
  /* empty css */
3
- import { DefaultLink as o } from "./linkComponent.js";
4
- import { useStrings as d } from "../../locale/useStrings.js";
5
- function h({
3
+ import { DefaultLink as g } from "./linkComponent.js";
4
+ import { useStrings as p } from "../../locale/useStrings.js";
5
+ function x({
6
6
  items: s,
7
- className: i,
8
- linkComponent: l
7
+ className: t,
8
+ ariaLabel: l,
9
+ linkComponent: o
9
10
  }) {
10
- const n = d(), t = ["aegis-breadcrumb", i ?? ""].filter(Boolean).join(" "), b = l ?? o;
11
- return /* @__PURE__ */ r("nav", { "aria-label": n.breadcrumb, className: t, children: /* @__PURE__ */ r("ol", { className: "aegis-breadcrumb__list", children: s.map((a, c) => {
12
- const e = c === s.length - 1;
13
- return /* @__PURE__ */ m("li", { className: "aegis-breadcrumb__item", children: [
14
- a.to && !e ? /* @__PURE__ */ r(b, { to: a.to, className: "aegis-breadcrumb__link", children: a.label }) : /* @__PURE__ */ r(
11
+ const b = p(), u = ["aegis-breadcrumb", t ?? ""].filter(Boolean).join(" "), d = o ?? g, i = s.some((r) => r.current !== void 0);
12
+ return /* @__PURE__ */ e("nav", { "aria-label": l ?? b.breadcrumb, className: u, children: /* @__PURE__ */ e("ol", { className: "aegis-breadcrumb__list", children: s.map((r, n) => {
13
+ const c = n === s.length - 1, a = i ? r.current === !0 : c, m = r.to !== void 0 && (i || !c);
14
+ return /* @__PURE__ */ _("li", { className: "aegis-breadcrumb__item", children: [
15
+ m && r.to !== void 0 ? /* @__PURE__ */ e(
16
+ d,
17
+ {
18
+ to: r.to,
19
+ className: a ? "aegis-breadcrumb__link aegis-breadcrumb__link--current" : "aegis-breadcrumb__link",
20
+ "aria-current": a ? "page" : void 0,
21
+ children: r.label
22
+ }
23
+ ) : /* @__PURE__ */ e(
15
24
  "span",
16
25
  {
17
- className: e ? "aegis-breadcrumb__text aegis-breadcrumb__text--current" : "aegis-breadcrumb__text",
18
- "aria-current": e ? "page" : void 0,
19
- children: a.label
26
+ className: a ? "aegis-breadcrumb__text aegis-breadcrumb__text--current" : "aegis-breadcrumb__text",
27
+ "aria-current": a ? "page" : void 0,
28
+ children: r.label
20
29
  }
21
30
  ),
22
- !e && /* @__PURE__ */ r("span", { className: "aegis-breadcrumb__sep", "aria-hidden": "true", children: "/" })
23
- ] }, c);
31
+ !c && /* @__PURE__ */ e("span", { className: "aegis-breadcrumb__sep", "aria-hidden": "true", children: "/" })
32
+ ] }, n);
24
33
  }) }) });
25
34
  }
26
35
  export {
27
- h as Breadcrumb
36
+ x as Breadcrumb
28
37
  };
29
38
  //# sourceMappingURL=Breadcrumb.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Breadcrumb.js","sources":["../../../src/components/ui/Breadcrumb.tsx"],"sourcesContent":["import { type ReactElement, type ReactNode } from 'react';\n\nimport { useStrings } from '../../locale';\nimport './Breadcrumb.css';\nimport { DefaultLink, type LinkComponent } from './linkComponent';\n\nexport interface BreadcrumbItem {\n label: ReactNode;\n /** Optional destination. If omitted, the item renders as plain text. */\n to?: string;\n}\n\ninterface BreadcrumbProps {\n items: BreadcrumbItem[];\n className?: string;\n /**\n * Component used to render linked breadcrumb items. Defaults to an\n * unstyled `<a href>`. Sub-apps using a router should pass their\n * Link adapter here.\n */\n linkComponent?: LinkComponent;\n}\n\nexport function Breadcrumb({\n items,\n className,\n linkComponent,\n}: BreadcrumbProps): ReactElement {\n const strings = useStrings();\n const cls = ['aegis-breadcrumb', className ?? ''].filter(Boolean).join(' ');\n const LinkImpl = linkComponent ?? DefaultLink;\n\n return (\n <nav aria-label={strings.breadcrumb} className={cls}>\n <ol className=\"aegis-breadcrumb__list\">\n {items.map((item, idx) => {\n const isLast = idx === items.length - 1;\n return (\n <li key={idx} className=\"aegis-breadcrumb__item\">\n {item.to && !isLast ? (\n <LinkImpl to={item.to} className=\"aegis-breadcrumb__link\">\n {item.label}\n </LinkImpl>\n ) : (\n <span\n className={\n isLast\n ? 'aegis-breadcrumb__text aegis-breadcrumb__text--current'\n : 'aegis-breadcrumb__text'\n }\n aria-current={isLast ? 'page' : undefined}\n >\n {item.label}\n </span>\n )}\n {!isLast && (\n <span className=\"aegis-breadcrumb__sep\" aria-hidden=\"true\">\n /\n </span>\n )}\n </li>\n );\n })}\n </ol>\n </nav>\n );\n}\n"],"names":["Breadcrumb","items","className","linkComponent","strings","useStrings","cls","LinkImpl","DefaultLink","jsx","item","idx","isLast","jsxs"],"mappings":";;;;AAuBO,SAASA,EAAW;AAAA,EACzB,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAAC;AACF,GAAkC;AAChC,QAAMC,IAAUC,EAAA,GACVC,IAAM,CAAC,oBAAoBJ,KAAa,EAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,GACpEK,IAAWJ,KAAiBK;AAElC,SACE,gBAAAC,EAAC,OAAA,EAAI,cAAYL,EAAQ,YAAY,WAAWE,GAC9C,UAAA,gBAAAG,EAAC,MAAA,EAAG,WAAU,0BACX,UAAAR,EAAM,IAAI,CAACS,GAAMC,MAAQ;AACxB,UAAMC,IAASD,MAAQV,EAAM,SAAS;AACtC,WACE,gBAAAY,EAAC,MAAA,EAAa,WAAU,0BACrB,UAAA;AAAA,MAAAH,EAAK,MAAM,CAACE,IACX,gBAAAH,EAACF,GAAA,EAAS,IAAIG,EAAK,IAAI,WAAU,0BAC9B,UAAAA,EAAK,MAAA,CACR,IAEA,gBAAAD;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WACEG,IACI,2DACA;AAAA,UAEN,gBAAcA,IAAS,SAAS;AAAA,UAE/B,UAAAF,EAAK;AAAA,QAAA;AAAA,MAAA;AAAA,MAGT,CAACE,KACA,gBAAAH,EAAC,QAAA,EAAK,WAAU,yBAAwB,eAAY,QAAO,UAAA,IAAA,CAE3D;AAAA,IAAA,EAAA,GApBKE,CAsBT;AAAA,EAEJ,CAAC,GACH,GACF;AAEJ;"}
1
+ {"version":3,"file":"Breadcrumb.js","sources":["../../../src/components/ui/Breadcrumb.tsx"],"sourcesContent":["import { type ReactElement, type ReactNode } from 'react';\n\nimport { useStrings } from '../../locale';\nimport './Breadcrumb.css';\nimport { DefaultLink, type LinkComponent } from './linkComponent';\n\nexport interface BreadcrumbItem {\n label: ReactNode;\n /** Optional destination. If omitted, the item renders as plain text. */\n to?: string;\n /**\n * Marks the item as the current page: `aria-current=\"page\"` and main ink.\n * When no item sets it, the last item is the current page and renders as\n * text. Once any item sets it, every item with `to` renders as a link,\n * the last included, and only the items set to `true` are current, so a\n * trail can end at a page other than the one shown.\n */\n current?: boolean;\n}\n\ninterface BreadcrumbProps {\n items: BreadcrumbItem[];\n className?: string;\n /** Accessible name of the navigation. Defaults to the locale's `breadcrumb`. */\n ariaLabel?: string;\n /**\n * Component used to render linked breadcrumb items. Defaults to an\n * unstyled `<a href>`. Sub-apps using a router should pass their\n * Link adapter here.\n */\n linkComponent?: LinkComponent;\n}\n\nexport function Breadcrumb({\n items,\n className,\n ariaLabel,\n linkComponent,\n}: BreadcrumbProps): ReactElement {\n const strings = useStrings();\n const cls = ['aegis-breadcrumb', className ?? ''].filter(Boolean).join(' ');\n const LinkImpl = linkComponent ?? DefaultLink;\n const explicit = items.some((item) => item.current !== undefined);\n\n return (\n <nav aria-label={ariaLabel ?? strings.breadcrumb} className={cls}>\n <ol className=\"aegis-breadcrumb__list\">\n {items.map((item, idx) => {\n const isLast = idx === items.length - 1;\n const isCurrent = explicit ? item.current === true : isLast;\n const linked = item.to !== undefined && (explicit || !isLast);\n return (\n <li key={idx} className=\"aegis-breadcrumb__item\">\n {linked && item.to !== undefined ? (\n <LinkImpl\n to={item.to}\n className={\n isCurrent\n ? 'aegis-breadcrumb__link aegis-breadcrumb__link--current'\n : 'aegis-breadcrumb__link'\n }\n aria-current={isCurrent ? 'page' : undefined}\n >\n {item.label}\n </LinkImpl>\n ) : (\n <span\n className={\n isCurrent\n ? 'aegis-breadcrumb__text aegis-breadcrumb__text--current'\n : 'aegis-breadcrumb__text'\n }\n aria-current={isCurrent ? 'page' : undefined}\n >\n {item.label}\n </span>\n )}\n {!isLast && (\n <span className=\"aegis-breadcrumb__sep\" aria-hidden=\"true\">\n /\n </span>\n )}\n </li>\n );\n })}\n </ol>\n </nav>\n );\n}\n"],"names":["Breadcrumb","items","className","ariaLabel","linkComponent","strings","useStrings","cls","LinkImpl","DefaultLink","explicit","item","jsx","idx","isLast","isCurrent","linked","jsxs"],"mappings":";;;;AAiCO,SAASA,EAAW;AAAA,EACzB,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAAC;AACF,GAAkC;AAChC,QAAMC,IAAUC,EAAA,GACVC,IAAM,CAAC,oBAAoBL,KAAa,EAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,GACpEM,IAAWJ,KAAiBK,GAC5BC,IAAWT,EAAM,KAAK,CAACU,MAASA,EAAK,YAAY,MAAS;AAEhE,2BACG,OAAA,EAAI,cAAYR,KAAaE,EAAQ,YAAY,WAAWE,GAC3D,UAAA,gBAAAK,EAAC,MAAA,EAAG,WAAU,0BACX,UAAAX,EAAM,IAAI,CAACU,GAAME,MAAQ;AACxB,UAAMC,IAASD,MAAQZ,EAAM,SAAS,GAChCc,IAAYL,IAAWC,EAAK,YAAY,KAAOG,GAC/CE,IAASL,EAAK,OAAO,WAAcD,KAAY,CAACI;AACtD,WACE,gBAAAG,EAAC,MAAA,EAAa,WAAU,0BACrB,UAAA;AAAA,MAAAD,KAAUL,EAAK,OAAO,SACrB,gBAAAC;AAAA,QAACJ;AAAA,QAAA;AAAA,UACC,IAAIG,EAAK;AAAA,UACT,WACEI,IACI,2DACA;AAAA,UAEN,gBAAcA,IAAY,SAAS;AAAA,UAElC,UAAAJ,EAAK;AAAA,QAAA;AAAA,MAAA,IAGR,gBAAAC;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WACEG,IACI,2DACA;AAAA,UAEN,gBAAcA,IAAY,SAAS;AAAA,UAElC,UAAAJ,EAAK;AAAA,QAAA;AAAA,MAAA;AAAA,MAGT,CAACG,KACA,gBAAAF,EAAC,QAAA,EAAK,WAAU,yBAAwB,eAAY,QAAO,UAAA,IAAA,CAE3D;AAAA,IAAA,EAAA,GA5BKC,CA8BT;AAAA,EAEJ,CAAC,GACH,GACF;AAEJ;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),e=require("react"),L=require("../../hooks/useIsomorphicLayoutEffect.cjs"),Q=require("../../hooks/useMediaQuery.cjs"),M=require("../../lib/scrollView.cjs");;/* empty css */const N=require("./selectedRowDetail.cjs"),A="(max-width: 768px)",O=e.createContext(null);function $(i,l,f,g,o){const p=o.top+g,u=i.top<p?i.top-p:Math.max(i.bottom-o.bottom,0);return Math.max(u,l+f-o.bottom)}function z({boxRef:i}){const l=e.useContext(O);return c.jsx("div",{ref:i,className:"aegis-detail-beside__inline",role:"group",children:l})}function F({columns:i,detail:l,children:f,revealKey:g,scrollContainer:o=null,className:p}){const u=Q.useMediaQuery(A),[P,x]=e.useState(!1),C=e.useRef(null),w=e.useRef(null),b=e.useRef(null),d=e.useRef(null),R=e.useRef(!1),E=e.useRef(0),y=e.useRef(g),j=e.useRef(void 0),B=e.useRef({children:f,detail:l}),a=e.useCallback(()=>{const t=d.current,s=b.current;if(t===null||s===null)return;const r=t.getBoundingClientRect(),n=w.current;if(n===null)s.style.setProperty("--aegis-detail-beside-row-height",`${String(r.height)}px`);else{const m=n.getBoundingClientRect().top;n.style.height=`${String(Math.max(r.top-m,0))}px`}},[]),h=e.useCallback(()=>{a();const t=d.current,s=b.current;if(t===null||s===null)return;const r=t.getBoundingClientRect(),n=w.current,m=$(r,n===null?r.bottom:n.getBoundingClientRect().top,s.getBoundingClientRect().height,parseFloat(getComputedStyle(s).scrollMarginTop),M.viewBoundsOf(o)),D=M.scrollerOf(o);Math.abs(m)>=1&&D.scrollBy({top:m,behavior:"instant"}),E.current=D.scrollTop},[a,o]),v=e.useCallback(()=>{j.current=y.current,R.current=!0,x(!0),queueMicrotask(()=>{h(),x(!1)})},[h]),S=e.useCallback(t=>{const s=t!==d.current;d.current=t,t===null?(R.current=!1,x(!1)):j.current!==y.current?v():(s&&(R.current=!1),a())},[a,v]),_=e.useCallback(()=>{x(!0)},[]);L.useIsomorphicLayoutEffect(()=>{const t=B.current.children!==f||B.current.detail!==l;B.current={children:f,detail:l},y.current=g,j.current!==g&&d.current!==null?v():(t&&(R.current=!1),a())}),L.useIsomorphicLayoutEffect(()=>{const t=C.current;if(t===null)return;const s=new ResizeObserver(()=>{R.current?h():a()});for(const n of u?[t]:[t,b.current])n!==null&&s.observe(n);const r=n=>{n.target instanceof Node&&d.current?.contains(n.target)&&v()};return t.addEventListener("click",r),()=>{s.disconnect(),t.removeEventListener("click",r)}},[u,a,h,v]),e.useEffect(()=>{const t=M.scrollerOf(o),s=o??window,r=()=>{Math.abs(t.scrollTop-E.current)>=1&&(R.current=!1)};return s.addEventListener("scroll",r,{passive:!0}),()=>{s.removeEventListener("scroll",r)}},[o]);const k=e.useMemo(()=>u?c.jsx(z,{boxRef:b}):null,[u]),I=e.useMemo(()=>({placeRow:S,awaitRow:_,inline:k}),[S,_,k]),q=c.jsx(N.SelectedRowDetailContext.Provider,{value:null,children:l}),T=["aegis-detail-beside",p??""].filter(Boolean).join(" ");return c.jsx(N.SelectedRowDetailContext.Provider,{value:I,children:c.jsx(O.Provider,{value:q,children:c.jsxs("div",{className:T,style:{"--aegis-detail-beside-columns":i},"aria-busy":P||void 0,children:[c.jsx("div",{ref:C,className:"aegis-detail-beside__list",children:f}),!u&&c.jsxs("div",{className:"aegis-detail-beside__side",children:[c.jsx("div",{ref:w}),c.jsx("div",{ref:b,className:"aegis-detail-beside__detail",children:q})]})]})})})}exports.DetailBeside=F;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),e=require("react"),L=require("../../hooks/useIsomorphicLayoutEffect.cjs"),Q=require("../../hooks/useMediaQuery.cjs"),M=require("../../lib/scrollView.cjs");;/* empty css */const N=require("./selectedRowDetail.cjs"),A="(max-width: 768px)",O=e.createContext(null);function $(u,l,f,g,o){const p=o.top+g,a=u.top<p?u.top-p:Math.max(u.bottom-o.bottom,0);return Math.max(a,l+f-o.bottom)}function z({boxRef:u}){const l=e.useContext(O);return c.jsx("div",{ref:u,className:"aegis-detail-beside__inline",role:"group",children:l})}function F({columns:u,detail:l,children:f,revealKey:g,scrollContainer:o=null,className:p}){const a=Q.useMediaQuery(A),[P,x]=e.useState(!1),C=e.useRef(null),y=e.useRef(null),v=e.useRef(null),d=e.useRef(null),R=e.useRef(!1),E=e.useRef(0),w=e.useRef(g),j=e.useRef(void 0),B=e.useRef({children:f,detail:l}),i=e.useCallback(()=>{const t=d.current,s=v.current,r=y.current;if(t===null){r?.style.removeProperty("height");return}if(s===null)return;const n=t.getBoundingClientRect();if(r===null)s.style.setProperty("--aegis-detail-beside-row-height",`${String(n.height)}px`);else{const m=r.getBoundingClientRect().top;r.style.height=`${String(Math.max(n.top-m,0))}px`}},[]),h=e.useCallback(()=>{i();const t=d.current,s=v.current;if(t===null||s===null)return;const r=t.getBoundingClientRect(),n=y.current,m=$(r,n===null?r.bottom:n.getBoundingClientRect().top,s.getBoundingClientRect().height,parseFloat(getComputedStyle(s).scrollMarginTop),M.viewBoundsOf(o)),D=M.scrollerOf(o);Math.abs(m)>=1&&D.scrollBy({top:m,behavior:"instant"}),E.current=D.scrollTop},[i,o]),b=e.useCallback(()=>{j.current=w.current,R.current=!0,x(!0),queueMicrotask(()=>{h(),x(!1)})},[h]),S=e.useCallback(t=>{const s=t!==d.current;d.current=t,t===null?(R.current=!1,x(!1),i()):j.current!==w.current?b():(s&&(R.current=!1),i())},[i,b]),_=e.useCallback(()=>{x(!0)},[]);L.useIsomorphicLayoutEffect(()=>{const t=B.current.children!==f||B.current.detail!==l;B.current={children:f,detail:l},w.current=g,j.current!==g&&d.current!==null?b():(t&&(R.current=!1),i())}),L.useIsomorphicLayoutEffect(()=>{const t=C.current;if(t===null)return;const s=new ResizeObserver(()=>{R.current?h():i()});for(const n of a?[t]:[t,v.current])n!==null&&s.observe(n);const r=n=>{n.target instanceof Node&&d.current?.contains(n.target)&&b()};return t.addEventListener("click",r),()=>{s.disconnect(),t.removeEventListener("click",r)}},[a,i,h,b]),e.useEffect(()=>{const t=M.scrollerOf(o),s=o??window,r=()=>{Math.abs(t.scrollTop-E.current)>=1&&(R.current=!1)};return s.addEventListener("scroll",r,{passive:!0}),()=>{s.removeEventListener("scroll",r)}},[o]);const k=e.useMemo(()=>a?c.jsx(z,{boxRef:v}):null,[a]),I=e.useMemo(()=>({placeRow:S,awaitRow:_,inline:k}),[S,_,k]),q=c.jsx(N.SelectedRowDetailContext.Provider,{value:null,children:l}),T=["aegis-detail-beside",p??""].filter(Boolean).join(" ");return c.jsx(N.SelectedRowDetailContext.Provider,{value:I,children:c.jsx(O.Provider,{value:q,children:c.jsxs("div",{className:T,style:{"--aegis-detail-beside-columns":u},"aria-busy":P||void 0,children:[c.jsx("div",{ref:C,className:"aegis-detail-beside__list",children:f}),!a&&c.jsxs("div",{className:"aegis-detail-beside__side",children:[c.jsx("div",{ref:y}),c.jsx("div",{ref:v,className:"aegis-detail-beside__detail",children:q})]})]})})})}exports.DetailBeside=F;
2
2
  //# sourceMappingURL=DetailBeside.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"DetailBeside.cjs","sources":["../../../src/components/ui/DetailBeside.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type ReactNode,\n type RefObject,\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect';\nimport { useMediaQuery } from '../../hooks/useMediaQuery';\nimport {\n type ViewBounds,\n scrollerOf,\n viewBoundsOf,\n} from '../../lib/scrollView';\nimport './DetailBeside.css';\nimport {\n type SelectedRowDetail,\n SelectedRowDetailContext,\n} from './selectedRowDetail';\n\nexport interface DetailBesideProps {\n /**\n * `grid-template-columns` of the list and the detail above 768 px, e.g.\n * `'3fr 2fr'`.\n */\n columns: string;\n /**\n * The selected item's detail: one element, such as a `Panel` titled with\n * the item's name. It is never taller than the view, so a long Panel\n * scrolls its body. Render it anew from the host's data whenever that\n * data changes: that render tells DetailBeside the change was new data,\n * so the page stays where it is. A detail that fetches its own data and\n * redraws without this host rendering leaves the page following the row,\n * and its next change of size scrolls the page.\n */\n detail: ReactNode;\n /**\n * The list: a `TraceTree`, `FileTree`, `DataTable` or `ServiceMap`, in a\n * Panel say. The detail follows the row it draws selected. Like\n * `detail`, render it anew from the host's data whenever that data\n * changes, so the page stays where it is on new data; a list that fetches\n * its own data and redraws without this host rendering leaves the page\n * following the row, and its next change of size scrolls the page.\n */\n children: ReactNode;\n /**\n * The selection as the page's address names it, or null where the\n * address names none and the list shows a default. It changes only by\n * the viewer's doing: a click, a key, a link, back or forward. The page\n * scrolls to the selected row when this changes, and on the first\n * placement after mount; a row that comes into place for new data, such\n * as a default the data moved, is only levelled with.\n */\n revealKey: string | null;\n /** The element that scrolls the page; omitted or null means the viewport. */\n scrollContainer?: HTMLElement | null;\n className?: string;\n}\n\nconst NARROW_QUERY = '(max-width: 768px)';\n\n/**\n * The detail as the inline slot draws it. It is kept out of the context the\n * lists read, so a new detail re-renders the slot and not the list.\n */\nconst DetailContext = createContext<ReactNode>(null);\n\n/**\n * How far to scroll so the row is in the view, clear of the `inset` at the\n * view's top, and the detail, whose top can rise no higher than `ceiling`,\n * fits above the view's bottom.\n */\nfunction revealDistance(\n row: DOMRect,\n ceiling: number,\n height: number,\n inset: number,\n view: ViewBounds,\n): number {\n const top = view.top + inset;\n const toRow =\n row.top < top ? row.top - top : Math.max(row.bottom - view.bottom, 0);\n return Math.max(toRow, ceiling + height - view.bottom);\n}\n\n/** The detail right after the selected row, at 768 px and below. */\nfunction InlineDetail({ boxRef }: { boxRef: RefObject<HTMLDivElement> }) {\n const detail = useContext(DetailContext);\n return (\n <div ref={boxRef} className=\"aegis-detail-beside__inline\" role=\"group\">\n {detail}\n </div>\n );\n}\n\n/**\n * A tree, table or map with the selected item's detail beside it. Above\n * 768 px the detail stands in a column on the right, level with the\n * selected row: when the row is too low for it, its bottom meets the\n * view's bottom, and while the page scrolls it stays in the view below\n * the header. At 768 px and below the list draws the detail right after\n * the selected row, the rows that follow under it; a map draws it over\n * the map, under the node. When the page opens with a selection,\n * `revealKey` changes or the viewer clicks the selected row, the page\n * scrolls at once, as little as it takes to show the row and the detail\n * whole, and again whenever the list or the detail changes size, until the\n * viewer scrolls or the host renders a new list or detail. Any other\n * placement, such as new data moving the selection or the rows, levels\n * the detail with its row by the same rule and leaves the page where it\n * is; the browser's scroll anchoring can still move it when rows arrive\n * above the view, unless the host sets `overflow-anchor: none` on its\n * scroller. The wrapper is `aria-busy` while a selected row it reveals is\n * still on its way.\n */\nexport function DetailBeside({\n columns,\n detail,\n children,\n revealKey,\n scrollContainer = null,\n className,\n}: DetailBesideProps) {\n const narrow = useMediaQuery(NARROW_QUERY);\n const [busy, setBusy] = useState(false);\n const listRef = useRef<HTMLDivElement>(null);\n const spacerRef = useRef<HTMLDivElement>(null);\n const detailRef = useRef<HTMLDivElement>(null);\n const rowRef = useRef<HTMLElement | null>(null);\n /** Whether the page is still where the last reveal left it. */\n const followRef = useRef(false);\n const revealedAtRef = useRef(0);\n /** The latest render's revealKey, and the last reveal's: undefined before the first. */\n const revealKeyRef = useRef(revealKey);\n const revealedKeyRef = useRef<string | null | undefined>(undefined);\n /** The latest render's list and detail, which change when the host renders them anew. */\n const shownRef = useRef({ children, detail });\n\n /**\n * Sets the detail level with the row: above 768 px through the spacer's\n * height, at and below by telling the inline detail how tall the row is.\n */\n const place = useCallback(() => {\n const row = rowRef.current;\n const box = detailRef.current;\n if (row === null || box === null) {\n return;\n }\n const rowBox = row.getBoundingClientRect();\n const spacer = spacerRef.current;\n if (spacer === null) {\n box.style.setProperty(\n '--aegis-detail-beside-row-height',\n `${String(rowBox.height)}px`,\n );\n } else {\n const top = spacer.getBoundingClientRect().top;\n spacer.style.height = `${String(Math.max(rowBox.top - top, 0))}px`;\n }\n }, []);\n\n /** Places the row and scrolls as little as it takes to show it and its detail whole. */\n const reveal = useCallback(() => {\n place();\n const row = rowRef.current;\n const box = detailRef.current;\n if (row === null || box === null) {\n return;\n }\n const rowBox = row.getBoundingClientRect();\n const spacer = spacerRef.current;\n const distance = revealDistance(\n rowBox,\n spacer === null ? rowBox.bottom : spacer.getBoundingClientRect().top,\n box.getBoundingClientRect().height,\n parseFloat(getComputedStyle(box).scrollMarginTop),\n viewBoundsOf(scrollContainer),\n );\n const scroller = scrollerOf(scrollContainer);\n if (Math.abs(distance) >= 1) {\n scroller.scrollBy({ top: distance, behavior: 'instant' });\n }\n revealedAtRef.current = scroller.scrollTop;\n }, [place, scrollContainer]);\n\n // A list places its row while React attaches refs, before the detail's\n // own ref is in and before the re-renders its layout effects ask for,\n // so the reveal waits for the commit to finish.\n const revealSoon = useCallback(() => {\n revealedKeyRef.current = revealKeyRef.current;\n followRef.current = true;\n setBusy(true);\n queueMicrotask(() => {\n reveal();\n setBusy(false);\n });\n }, [reveal]);\n\n // A row placed while a reveal is due is revealed; any other is levelled\n // with, and a new one ends following.\n const placeRow = useCallback(\n (row: HTMLElement | null) => {\n const fresh = row !== rowRef.current;\n rowRef.current = row;\n if (row === null) {\n followRef.current = false;\n setBusy(false);\n } else if (revealedKeyRef.current !== revealKeyRef.current) {\n revealSoon();\n } else {\n if (fresh) {\n followRef.current = false;\n }\n place();\n }\n },\n [place, revealSoon],\n );\n\n const awaitRow = useCallback(() => {\n setBusy(true);\n }, []);\n\n // Runs after the lists have placed their rows in this commit, so a new\n // revealKey reveals the row it selects. A render by the host without one\n // ends following.\n useIsomorphicLayoutEffect(() => {\n const rendered =\n shownRef.current.children !== children ||\n shownRef.current.detail !== detail;\n shownRef.current = { children, detail };\n revealKeyRef.current = revealKey;\n if (revealedKeyRef.current !== revealKey && rowRef.current !== null) {\n revealSoon();\n } else {\n if (rendered) {\n followRef.current = false;\n }\n place();\n }\n });\n\n useIsomorphicLayoutEffect(() => {\n const list = listRef.current;\n if (list === null) {\n return undefined;\n }\n const observer = new ResizeObserver(() => {\n if (followRef.current) {\n reveal();\n } else {\n place();\n }\n });\n // At 768 px and below the detail lies inside the list.\n for (const box of narrow ? [list] : [list, detailRef.current]) {\n if (box !== null) {\n observer.observe(box);\n }\n }\n const activate = (event: MouseEvent): void => {\n if (\n event.target instanceof Node &&\n rowRef.current?.contains(event.target)\n ) {\n revealSoon();\n }\n };\n list.addEventListener('click', activate);\n return () => {\n observer.disconnect();\n list.removeEventListener('click', activate);\n };\n }, [narrow, place, reveal, revealSoon]);\n\n useEffect(() => {\n const scroller = scrollerOf(scrollContainer);\n const target = scrollContainer ?? window;\n const scrolled = (): void => {\n if (Math.abs(scroller.scrollTop - revealedAtRef.current) >= 1) {\n followRef.current = false;\n }\n };\n target.addEventListener('scroll', scrolled, { passive: true });\n return () => {\n target.removeEventListener('scroll', scrolled);\n };\n }, [scrollContainer]);\n\n const inline = useMemo(\n () => (narrow ? <InlineDetail boxRef={detailRef} /> : null),\n [narrow],\n );\n const slot = useMemo(\n (): SelectedRowDetail => ({ placeRow, awaitRow, inline }),\n [placeRow, awaitRow, inline],\n );\n const isolated = (\n <SelectedRowDetailContext.Provider value={null}>\n {detail}\n </SelectedRowDetailContext.Provider>\n );\n\n const cls = ['aegis-detail-beside', className ?? '']\n .filter(Boolean)\n .join(' ');\n\n return (\n <SelectedRowDetailContext.Provider value={slot}>\n <DetailContext.Provider value={isolated}>\n <div\n className={cls}\n style={{ '--aegis-detail-beside-columns': columns } as CSSProperties}\n aria-busy={busy || undefined}\n >\n <div ref={listRef} className=\"aegis-detail-beside__list\">\n {children}\n </div>\n {!narrow && (\n <div className=\"aegis-detail-beside__side\">\n <div ref={spacerRef} />\n <div ref={detailRef} className=\"aegis-detail-beside__detail\">\n {isolated}\n </div>\n </div>\n )}\n </div>\n </DetailContext.Provider>\n </SelectedRowDetailContext.Provider>\n );\n}\n"],"names":["NARROW_QUERY","DetailContext","createContext","revealDistance","row","ceiling","height","inset","view","top","toRow","InlineDetail","boxRef","detail","useContext","jsx","DetailBeside","columns","children","revealKey","scrollContainer","className","narrow","useMediaQuery","busy","setBusy","useState","listRef","useRef","spacerRef","detailRef","rowRef","followRef","revealedAtRef","revealKeyRef","revealedKeyRef","shownRef","place","useCallback","box","rowBox","spacer","reveal","distance","viewBoundsOf","scroller","scrollerOf","revealSoon","placeRow","fresh","awaitRow","useIsomorphicLayoutEffect","rendered","list","observer","activate","event","useEffect","target","scrolled","inline","useMemo","slot","isolated","SelectedRowDetailContext","cls","jsxs"],"mappings":"6VAiEMA,EAAe,qBAMfC,EAAgBC,EAAAA,cAAyB,IAAI,EAOnD,SAASC,EACPC,EACAC,EACAC,EACAC,EACAC,EACQ,CACR,MAAMC,EAAMD,EAAK,IAAMD,EACjBG,EACJN,EAAI,IAAMK,EAAML,EAAI,IAAMK,EAAM,KAAK,IAAIL,EAAI,OAASI,EAAK,OAAQ,CAAC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AAAU,IAChD,CAACZ,EAAUE,EAAUU,CAAM,CAAA,EAEvBG,EACJhD,MAACiD,EAAAA,yBAAyB,SAAzB,CAAkC,MAAO,KACvC,SAAAnD,EACH,EAGIoD,EAAM,CAAC,sBAAuB5C,GAAa,EAAE,EAChD,OAAO,OAAO,EACd,KAAK,GAAG,EAEX,OACEN,EAAAA,IAACiD,EAAAA,yBAAyB,SAAzB,CAAkC,MAAOF,EACxC,SAAA/C,EAAAA,IAACd,EAAc,SAAd,CAAuB,MAAO8D,EAC7B,SAAAG,EAAAA,KAAC,MAAA,CACC,UAAWD,EACX,MAAO,CAAE,gCAAiChD,CAAA,EAC1C,YAAWO,GAAQ,OAEnB,SAAA,CAAAT,EAAAA,IAAC,MAAA,CAAI,IAAKY,EAAS,UAAU,4BAC1B,SAAAT,EACH,EACC,CAACI,GACA4C,EAAAA,KAAC,MAAA,CAAI,UAAU,4BACb,SAAA,CAAAnD,EAAAA,IAAC,MAAA,CAAI,IAAKc,CAAA,CAAW,QACpB,MAAA,CAAI,IAAKC,EAAW,UAAU,8BAC5B,SAAAiC,CAAA,CACH,CAAA,CAAA,CACF,CAAA,CAAA,CAAA,EAGN,CAAA,CACF,CAEJ"}
1
+ {"version":3,"file":"DetailBeside.cjs","sources":["../../../src/components/ui/DetailBeside.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type ReactNode,\n type RefObject,\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect';\nimport { useMediaQuery } from '../../hooks/useMediaQuery';\nimport {\n type ViewBounds,\n scrollerOf,\n viewBoundsOf,\n} from '../../lib/scrollView';\nimport './DetailBeside.css';\nimport {\n type SelectedRowDetail,\n SelectedRowDetailContext,\n} from './selectedRowDetail';\n\nexport interface DetailBesideProps {\n /**\n * `grid-template-columns` of the list and the detail above 768 px, e.g.\n * `'3fr 2fr'`.\n */\n columns: string;\n /**\n * The selected item's detail: one element, such as a `Panel` titled with\n * the item's name. It is never taller than the view, so a long Panel\n * scrolls its body. Render it anew from the host's data whenever that\n * data changes: that render tells DetailBeside the change was new data,\n * so the page stays where it is. A detail that fetches its own data and\n * redraws without this host rendering leaves the page following the row,\n * and its next change of size scrolls the page.\n */\n detail: ReactNode;\n /**\n * The list: a `TraceTree`, `FileTree`, `DataTable`, `TreeTable` or\n * `ServiceMap`, in a Panel say. The detail follows the row it draws\n * selected. Like `detail`, render it anew from the host's data whenever\n * that data changes, so the page stays where it is on new data; a list\n * that fetches its own data and redraws without this host rendering\n * leaves the page following the row, and its next change of size scrolls\n * the page.\n */\n children: ReactNode;\n /**\n * The selection as the page's address names it, or null where the\n * address names none and the list shows a default. It changes only by\n * the viewer's doing: a click, a key, a link, back or forward. The page\n * scrolls to the selected row when this changes, and on the first\n * placement after mount; a row that comes into place for new data, such\n * as a default the data moved, is only levelled with.\n */\n revealKey: string | null;\n /** The element that scrolls the page; omitted or null means the viewport. */\n scrollContainer?: HTMLElement | null;\n className?: string;\n}\n\nconst NARROW_QUERY = '(max-width: 768px)';\n\n/**\n * The detail as the inline slot draws it. It is kept out of the context the\n * lists read, so a new detail re-renders the slot and not the list.\n */\nconst DetailContext = createContext<ReactNode>(null);\n\n/**\n * How far to scroll so the row is in the view, clear of the `inset` at the\n * view's top, and the detail, whose top can rise no higher than `ceiling`,\n * fits above the view's bottom.\n */\nfunction revealDistance(\n row: DOMRect,\n ceiling: number,\n height: number,\n inset: number,\n view: ViewBounds,\n): number {\n const top = view.top + inset;\n const toRow =\n row.top < top ? row.top - top : Math.max(row.bottom - view.bottom, 0);\n return Math.max(toRow, ceiling + height - view.bottom);\n}\n\n/** The detail right after the selected row, at 768 px and below. */\nfunction InlineDetail({ boxRef }: { boxRef: RefObject<HTMLDivElement> }) {\n const detail = useContext(DetailContext);\n return (\n <div ref={boxRef} className=\"aegis-detail-beside__inline\" role=\"group\">\n {detail}\n </div>\n );\n}\n\n/**\n * A tree, table or map with the selected item's detail beside it. Above\n * 768 px the detail stands in a column on the right, level with the\n * selected row: when the row is too low for it, its bottom meets the\n * view's bottom, and while the page scrolls it stays in the view below\n * the header; while the list draws no row selected, it stands at the\n * column's top. At 768 px and below the list draws the detail right after\n * the selected row, the rows that follow under it; a map draws it over\n * the map, under the node. When the page opens with a selection,\n * `revealKey` changes or the viewer clicks the selected row, the page\n * scrolls at once, as little as it takes to show the row and the detail\n * whole, and again whenever the list or the detail changes size, until the\n * viewer scrolls or the host renders a new list or detail. Any other\n * placement, such as new data moving the selection or the rows, levels\n * the detail with its row by the same rule and leaves the page where it\n * is; the browser's scroll anchoring can still move it when rows arrive\n * above the view, unless the host sets `overflow-anchor: none` on its\n * scroller. The wrapper is `aria-busy` while a selected row it reveals is\n * still on its way.\n */\nexport function DetailBeside({\n columns,\n detail,\n children,\n revealKey,\n scrollContainer = null,\n className,\n}: DetailBesideProps) {\n const narrow = useMediaQuery(NARROW_QUERY);\n const [busy, setBusy] = useState(false);\n const listRef = useRef<HTMLDivElement>(null);\n const spacerRef = useRef<HTMLDivElement>(null);\n const detailRef = useRef<HTMLDivElement>(null);\n const rowRef = useRef<HTMLElement | null>(null);\n /** Whether the page is still where the last reveal left it. */\n const followRef = useRef(false);\n const revealedAtRef = useRef(0);\n /** The latest render's revealKey, and the last reveal's: undefined before the first. */\n const revealKeyRef = useRef(revealKey);\n const revealedKeyRef = useRef<string | null | undefined>(undefined);\n /** The latest render's list and detail, which change when the host renders them anew. */\n const shownRef = useRef({ children, detail });\n\n /**\n * Sets the detail level with the row: above 768 px through the spacer's\n * height, at and below by telling the inline detail how tall the row is.\n * While the list draws no row selected, such as when a filter or a closed\n * parent hides it, the detail stands at the top of its column.\n */\n const place = useCallback(() => {\n const row = rowRef.current;\n const box = detailRef.current;\n const spacer = spacerRef.current;\n if (row === null) {\n spacer?.style.removeProperty('height');\n return;\n }\n if (box === null) {\n return;\n }\n const rowBox = row.getBoundingClientRect();\n if (spacer === null) {\n box.style.setProperty(\n '--aegis-detail-beside-row-height',\n `${String(rowBox.height)}px`,\n );\n } else {\n const top = spacer.getBoundingClientRect().top;\n spacer.style.height = `${String(Math.max(rowBox.top - top, 0))}px`;\n }\n }, []);\n\n /** Places the row and scrolls as little as it takes to show it and its detail whole. */\n const reveal = useCallback(() => {\n place();\n const row = rowRef.current;\n const box = detailRef.current;\n if (row === null || box === null) {\n return;\n }\n const rowBox = row.getBoundingClientRect();\n const spacer = spacerRef.current;\n const distance = revealDistance(\n rowBox,\n spacer === null ? rowBox.bottom : spacer.getBoundingClientRect().top,\n box.getBoundingClientRect().height,\n parseFloat(getComputedStyle(box).scrollMarginTop),\n viewBoundsOf(scrollContainer),\n );\n const scroller = scrollerOf(scrollContainer);\n if (Math.abs(distance) >= 1) {\n scroller.scrollBy({ top: distance, behavior: 'instant' });\n }\n revealedAtRef.current = scroller.scrollTop;\n }, [place, scrollContainer]);\n\n // A list places its row while React attaches refs, before the detail's\n // own ref is in and before the re-renders its layout effects ask for,\n // so the reveal waits for the commit to finish.\n const revealSoon = useCallback(() => {\n revealedKeyRef.current = revealKeyRef.current;\n followRef.current = true;\n setBusy(true);\n queueMicrotask(() => {\n reveal();\n setBusy(false);\n });\n }, [reveal]);\n\n // A row placed while a reveal is due is revealed; any other is levelled\n // with, and a new one ends following.\n const placeRow = useCallback(\n (row: HTMLElement | null) => {\n const fresh = row !== rowRef.current;\n rowRef.current = row;\n if (row === null) {\n followRef.current = false;\n setBusy(false);\n place();\n } else if (revealedKeyRef.current !== revealKeyRef.current) {\n revealSoon();\n } else {\n if (fresh) {\n followRef.current = false;\n }\n place();\n }\n },\n [place, revealSoon],\n );\n\n const awaitRow = useCallback(() => {\n setBusy(true);\n }, []);\n\n // Runs after the lists have placed their rows in this commit, so a new\n // revealKey reveals the row it selects. A render by the host without one\n // ends following.\n useIsomorphicLayoutEffect(() => {\n const rendered =\n shownRef.current.children !== children ||\n shownRef.current.detail !== detail;\n shownRef.current = { children, detail };\n revealKeyRef.current = revealKey;\n if (revealedKeyRef.current !== revealKey && rowRef.current !== null) {\n revealSoon();\n } else {\n if (rendered) {\n followRef.current = false;\n }\n place();\n }\n });\n\n useIsomorphicLayoutEffect(() => {\n const list = listRef.current;\n if (list === null) {\n return undefined;\n }\n const observer = new ResizeObserver(() => {\n if (followRef.current) {\n reveal();\n } else {\n place();\n }\n });\n // At 768 px and below the detail lies inside the list.\n for (const box of narrow ? [list] : [list, detailRef.current]) {\n if (box !== null) {\n observer.observe(box);\n }\n }\n const activate = (event: MouseEvent): void => {\n if (\n event.target instanceof Node &&\n rowRef.current?.contains(event.target)\n ) {\n revealSoon();\n }\n };\n list.addEventListener('click', activate);\n return () => {\n observer.disconnect();\n list.removeEventListener('click', activate);\n };\n }, [narrow, place, reveal, revealSoon]);\n\n useEffect(() => {\n const scroller = scrollerOf(scrollContainer);\n const target = scrollContainer ?? window;\n const scrolled = (): void => {\n if (Math.abs(scroller.scrollTop - revealedAtRef.current) >= 1) {\n followRef.current = false;\n }\n };\n target.addEventListener('scroll', scrolled, { passive: true });\n return () => {\n target.removeEventListener('scroll', scrolled);\n };\n }, [scrollContainer]);\n\n const inline = useMemo(\n () => (narrow ? <InlineDetail boxRef={detailRef} /> : null),\n [narrow],\n );\n const slot = useMemo(\n (): SelectedRowDetail => ({ placeRow, awaitRow, inline }),\n [placeRow, awaitRow, inline],\n );\n const isolated = (\n <SelectedRowDetailContext.Provider value={null}>\n {detail}\n </SelectedRowDetailContext.Provider>\n );\n\n const cls = ['aegis-detail-beside', className ?? '']\n .filter(Boolean)\n .join(' ');\n\n return (\n <SelectedRowDetailContext.Provider value={slot}>\n <DetailContext.Provider value={isolated}>\n <div\n className={cls}\n style={{ '--aegis-detail-beside-columns': columns } as CSSProperties}\n aria-busy={busy || undefined}\n >\n <div ref={listRef} className=\"aegis-detail-beside__list\">\n {children}\n </div>\n {!narrow && (\n <div className=\"aegis-detail-beside__side\">\n <div ref={spacerRef} />\n <div ref={detailRef} className=\"aegis-detail-beside__detail\">\n {isolated}\n </div>\n </div>\n )}\n </div>\n </DetailContext.Provider>\n </SelectedRowDetailContext.Provider>\n );\n}\n"],"names":["NARROW_QUERY","DetailContext","createContext","revealDistance","row","ceiling","height","inset","view","top","toRow","InlineDetail","boxRef","detail","useContext","jsx","DetailBeside","columns","children","revealKey","scrollContainer","className","narrow","useMediaQuery","busy","setBusy","useState","listRef","useRef","spacerRef","detailRef","rowRef","followRef","revealedAtRef","revealKeyRef","revealedKeyRef","shownRef","place","useCallback","box","spacer","rowBox","reveal","distance","viewBoundsOf","scroller","scrollerOf","revealSoon","placeRow","fresh","awaitRow","useIsomorphicLayoutEffect","rendered","list","observer","activate","event","useEffect","target","scrolled","inline","useMemo","slot","isolated","SelectedRowDetailContext","cls","jsxs"],"mappings":"6VAkEMA,EAAe,qBAMfC,EAAgBC,EAAAA,cAAyB,IAAI,EAOnD,SAASC,EACPC,EACAC,EACAC,EACAC,EACAC,EACQ,CACR,MAAMC,EAAMD,EAAK,IAAMD,EACjBG,EACJN,EAAI,IAAMK,EAAML,EAAI,IAAMK,EAAM,KAAK,IAAIL,EAAI,OAASI,EAAK,OAAQ,CAAC,EACtE,OAAO,KAAK,IAAIE,EAAOL,EAAUC,EAASE,EAAK,MAAM,CACvD,CAGA,SAASG,EAAa,CAAE,OAAAC,GAAiD,CACvE,MAAMC,EAASC,EAAAA,WAAWb,CAAa,EACvC,OACEc,MAAC,OAAI,IAAKH,EAAQ,UAAU,8BAA8B,KAAK,QAC5D,SAAAC,CAAA,CACH,CAEJ,CAsBO,SAASG,EAAa,CAC3B,QAAAC,EACA,OAAAJ,EACA,SAAAK,EACA,UAAAC,EACA,gBAAAC,EAAkB,KAClB,UAAAC,CACF,EAAsB,CACpB,MAAMC,EAASC,EAAAA,cAAcvB,CAAY,EACnC,CAACwB,EAAMC,CAAO,EAAIC,EAAAA,SAAS,EAAK,EAChCC,EAAUC,EAAAA,OAAuB,IAAI,EACrCC,EAAYD,EAAAA,OAAuB,IAAI,EACvC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CAAI,IAAKY,EAAS,UAAU,4BAC1B,SAAAT,EACH,EACC,CAACI,GACA4C,EAAAA,KAAC,MAAA,CAAI,UAAU,4BACb,SAAA,CAAAnD,EAAAA,IAAC,MAAA,CAAI,IAAKc,CAAA,CAAW,QACpB,MAAA,CAAI,IAAKC,EAAW,UAAU,8BAC5B,SAAAiC,CAAA,CACH,CAAA,CAAA,CACF,CAAA,CAAA,CAAA,EAGN,CAAA,CACF,CAEJ"}
@@ -16,12 +16,13 @@ export interface DetailBesideProps {
16
16
  */
17
17
  detail: ReactNode;
18
18
  /**
19
- * The list: a `TraceTree`, `FileTree`, `DataTable` or `ServiceMap`, in a
20
- * Panel say. The detail follows the row it draws selected. Like
21
- * `detail`, render it anew from the host's data whenever that data
22
- * changes, so the page stays where it is on new data; a list that fetches
23
- * its own data and redraws without this host rendering leaves the page
24
- * following the row, and its next change of size scrolls the page.
19
+ * The list: a `TraceTree`, `FileTree`, `DataTable`, `TreeTable` or
20
+ * `ServiceMap`, in a Panel say. The detail follows the row it draws
21
+ * selected. Like `detail`, render it anew from the host's data whenever
22
+ * that data changes, so the page stays where it is on new data; a list
23
+ * that fetches its own data and redraws without this host rendering
24
+ * leaves the page following the row, and its next change of size scrolls
25
+ * the page.
25
26
  */
26
27
  children: ReactNode;
27
28
  /**
@@ -42,7 +43,8 @@ export interface DetailBesideProps {
42
43
  * 768 px the detail stands in a column on the right, level with the
43
44
  * selected row: when the row is too low for it, its bottom meets the
44
45
  * view's bottom, and while the page scrolls it stays in the view below
45
- * the header. At 768 px and below the list draws the detail right after
46
+ * the header; while the list draws no row selected, it stands at the
47
+ * column's top. At 768 px and below the list draws the detail right after
46
48
  * the selected row, the rows that follow under it; a map draws it over
47
49
  * the map, under the node. When the page opens with a selection,
48
50
  * `revealKey` changes or the viewer clicks the selected row, the page
@@ -1,86 +1,90 @@
1
- import { jsx as l, jsxs as O } from "react/jsx-runtime";
2
- import { useState as z, useRef as s, useCallback as b, useEffect as F, useMemo as P, useContext as U, createContext as W } from "react";
1
+ import { jsx as i, jsxs as k } from "react/jsx-runtime";
2
+ import { useState as z, useRef as s, useCallback as h, useEffect as F, useMemo as O, useContext as U, createContext as W } from "react";
3
3
  import { useIsomorphicLayoutEffect as j } from "../../hooks/useIsomorphicLayoutEffect.js";
4
4
  import { useMediaQuery as Y } from "../../hooks/useMediaQuery.js";
5
5
  import { viewBoundsOf as G, scrollerOf as T } from "../../lib/scrollView.js";
6
6
  /* empty css */
7
7
  import { SelectedRowDetailContext as A } from "./selectedRowDetail.js";
8
8
  const H = "(max-width: 768px)", I = W(null);
9
- function J(i, c, d, m, o) {
10
- const R = o.top + m, u = i.top < R ? i.top - R : Math.max(i.bottom - o.bottom, 0);
11
- return Math.max(u, c + d - o.bottom);
9
+ function J(u, c, f, m, o) {
10
+ const b = o.top + m, a = u.top < b ? u.top - b : Math.max(u.bottom - o.bottom, 0);
11
+ return Math.max(a, c + f - o.bottom);
12
12
  }
13
- function K({ boxRef: i }) {
13
+ function K({ boxRef: u }) {
14
14
  const c = U(I);
15
- return /* @__PURE__ */ l("div", { ref: i, className: "aegis-detail-beside__inline", role: "group", children: c });
15
+ return /* @__PURE__ */ i("div", { ref: u, className: "aegis-detail-beside__inline", role: "group", children: c });
16
16
  }
17
17
  function oe({
18
- columns: i,
18
+ columns: u,
19
19
  detail: c,
20
- children: d,
20
+ children: f,
21
21
  revealKey: m,
22
22
  scrollContainer: o = null,
23
- className: R
23
+ className: b
24
24
  }) {
25
- const u = Y(H), [Q, h] = z(!1), E = s(null), B = s(null), g = s(null), f = s(null), p = s(!1), N = s(0), y = s(m), M = s(void 0), _ = s({ children: d, detail: c }), a = b(() => {
26
- const e = f.current, t = g.current;
27
- if (e === null || t === null)
25
+ const a = Y(H), [Q, R] = z(!1), E = s(null), y = s(null), g = s(null), d = s(null), p = s(!1), N = s(0), B = s(m), M = s(void 0), _ = s({ children: f, detail: c }), l = h(() => {
26
+ const e = d.current, t = g.current, r = y.current;
27
+ if (e === null) {
28
+ r?.style.removeProperty("height");
29
+ return;
30
+ }
31
+ if (t === null)
28
32
  return;
29
- const r = e.getBoundingClientRect(), n = B.current;
30
- if (n === null)
33
+ const n = e.getBoundingClientRect();
34
+ if (r === null)
31
35
  t.style.setProperty(
32
36
  "--aegis-detail-beside-row-height",
33
- `${String(r.height)}px`
37
+ `${String(n.height)}px`
34
38
  );
35
39
  else {
36
- const w = n.getBoundingClientRect().top;
37
- n.style.height = `${String(Math.max(r.top - w, 0))}px`;
40
+ const w = r.getBoundingClientRect().top;
41
+ r.style.height = `${String(Math.max(n.top - w, 0))}px`;
38
42
  }
39
- }, []), x = b(() => {
40
- a();
41
- const e = f.current, t = g.current;
43
+ }, []), x = h(() => {
44
+ l();
45
+ const e = d.current, t = g.current;
42
46
  if (e === null || t === null)
43
47
  return;
44
- const r = e.getBoundingClientRect(), n = B.current, w = J(
48
+ const r = e.getBoundingClientRect(), n = y.current, w = J(
45
49
  r,
46
50
  n === null ? r.bottom : n.getBoundingClientRect().top,
47
51
  t.getBoundingClientRect().height,
48
52
  parseFloat(getComputedStyle(t).scrollMarginTop),
49
53
  G(o)
50
- ), k = T(o);
51
- Math.abs(w) >= 1 && k.scrollBy({ top: w, behavior: "instant" }), N.current = k.scrollTop;
52
- }, [a, o]), v = b(() => {
53
- M.current = y.current, p.current = !0, h(!0), queueMicrotask(() => {
54
- x(), h(!1);
54
+ ), P = T(o);
55
+ Math.abs(w) >= 1 && P.scrollBy({ top: w, behavior: "instant" }), N.current = P.scrollTop;
56
+ }, [l, o]), v = h(() => {
57
+ M.current = B.current, p.current = !0, R(!0), queueMicrotask(() => {
58
+ x(), R(!1);
55
59
  });
56
- }, [x]), C = b(
60
+ }, [x]), C = h(
57
61
  (e) => {
58
- const t = e !== f.current;
59
- f.current = e, e === null ? (p.current = !1, h(!1)) : M.current !== y.current ? v() : (t && (p.current = !1), a());
62
+ const t = e !== d.current;
63
+ d.current = e, e === null ? (p.current = !1, R(!1), l()) : M.current !== B.current ? v() : (t && (p.current = !1), l());
60
64
  },
61
- [a, v]
62
- ), S = b(() => {
63
- h(!0);
65
+ [l, v]
66
+ ), S = h(() => {
67
+ R(!0);
64
68
  }, []);
65
69
  j(() => {
66
- const e = _.current.children !== d || _.current.detail !== c;
67
- _.current = { children: d, detail: c }, y.current = m, M.current !== m && f.current !== null ? v() : (e && (p.current = !1), a());
70
+ const e = _.current.children !== f || _.current.detail !== c;
71
+ _.current = { children: f, detail: c }, B.current = m, M.current !== m && d.current !== null ? v() : (e && (p.current = !1), l());
68
72
  }), j(() => {
69
73
  const e = E.current;
70
74
  if (e === null)
71
75
  return;
72
76
  const t = new ResizeObserver(() => {
73
- p.current ? x() : a();
77
+ p.current ? x() : l();
74
78
  });
75
- for (const n of u ? [e] : [e, g.current])
79
+ for (const n of a ? [e] : [e, g.current])
76
80
  n !== null && t.observe(n);
77
81
  const r = (n) => {
78
- n.target instanceof Node && f.current?.contains(n.target) && v();
82
+ n.target instanceof Node && d.current?.contains(n.target) && v();
79
83
  };
80
84
  return e.addEventListener("click", r), () => {
81
85
  t.disconnect(), e.removeEventListener("click", r);
82
86
  };
83
- }, [u, a, x, v]), F(() => {
87
+ }, [a, l, x, v]), F(() => {
84
88
  const e = T(o), t = o ?? window, r = () => {
85
89
  Math.abs(e.scrollTop - N.current) >= 1 && (p.current = !1);
86
90
  };
@@ -88,24 +92,24 @@ function oe({
88
92
  t.removeEventListener("scroll", r);
89
93
  };
90
94
  }, [o]);
91
- const D = P(
92
- () => u ? /* @__PURE__ */ l(K, { boxRef: g }) : null,
93
- [u]
94
- ), $ = P(
95
+ const D = O(
96
+ () => a ? /* @__PURE__ */ i(K, { boxRef: g }) : null,
97
+ [a]
98
+ ), $ = O(
95
99
  () => ({ placeRow: C, awaitRow: S, inline: D }),
96
100
  [C, S, D]
97
- ), L = /* @__PURE__ */ l(A.Provider, { value: null, children: c }), q = ["aegis-detail-beside", R ?? ""].filter(Boolean).join(" ");
98
- return /* @__PURE__ */ l(A.Provider, { value: $, children: /* @__PURE__ */ l(I.Provider, { value: L, children: /* @__PURE__ */ O(
101
+ ), L = /* @__PURE__ */ i(A.Provider, { value: null, children: c }), q = ["aegis-detail-beside", b ?? ""].filter(Boolean).join(" ");
102
+ return /* @__PURE__ */ i(A.Provider, { value: $, children: /* @__PURE__ */ i(I.Provider, { value: L, children: /* @__PURE__ */ k(
99
103
  "div",
100
104
  {
101
105
  className: q,
102
- style: { "--aegis-detail-beside-columns": i },
106
+ style: { "--aegis-detail-beside-columns": u },
103
107
  "aria-busy": Q || void 0,
104
108
  children: [
105
- /* @__PURE__ */ l("div", { ref: E, className: "aegis-detail-beside__list", children: d }),
106
- !u && /* @__PURE__ */ O("div", { className: "aegis-detail-beside__side", children: [
107
- /* @__PURE__ */ l("div", { ref: B }),
108
- /* @__PURE__ */ l("div", { ref: g, className: "aegis-detail-beside__detail", children: L })
109
+ /* @__PURE__ */ i("div", { ref: E, className: "aegis-detail-beside__list", children: f }),
110
+ !a && /* @__PURE__ */ k("div", { className: "aegis-detail-beside__side", children: [
111
+ /* @__PURE__ */ i("div", { ref: y }),
112
+ /* @__PURE__ */ i("div", { ref: g, className: "aegis-detail-beside__detail", children: L })
109
113
  ] })
110
114
  ]
111
115
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DetailBeside.js","sources":["../../../src/components/ui/DetailBeside.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type ReactNode,\n type RefObject,\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect';\nimport { useMediaQuery } from '../../hooks/useMediaQuery';\nimport {\n type ViewBounds,\n scrollerOf,\n viewBoundsOf,\n} from '../../lib/scrollView';\nimport './DetailBeside.css';\nimport {\n type SelectedRowDetail,\n SelectedRowDetailContext,\n} from './selectedRowDetail';\n\nexport interface DetailBesideProps {\n /**\n * `grid-template-columns` of the list and the detail above 768 px, e.g.\n * `'3fr 2fr'`.\n */\n columns: string;\n /**\n * The selected item's detail: one element, such as a `Panel` titled with\n * the item's name. It is never taller than the view, so a long Panel\n * scrolls its body. Render it anew from the host's data whenever that\n * data changes: that render tells DetailBeside the change was new data,\n * so the page stays where it is. A detail that fetches its own data and\n * redraws without this host rendering leaves the page following the row,\n * and its next change of size scrolls the page.\n */\n detail: ReactNode;\n /**\n * The list: a `TraceTree`, `FileTree`, `DataTable` or `ServiceMap`, in a\n * Panel say. The detail follows the row it draws selected. Like\n * `detail`, render it anew from the host's data whenever that data\n * changes, so the page stays where it is on new data; a list that fetches\n * its own data and redraws without this host rendering leaves the page\n * following the row, and its next change of size scrolls the page.\n */\n children: ReactNode;\n /**\n * The selection as the page's address names it, or null where the\n * address names none and the list shows a default. It changes only by\n * the viewer's doing: a click, a key, a link, back or forward. The page\n * scrolls to the selected row when this changes, and on the first\n * placement after mount; a row that comes into place for new data, such\n * as a default the data moved, is only levelled with.\n */\n revealKey: string | null;\n /** The element that scrolls the page; omitted or null means the viewport. */\n scrollContainer?: HTMLElement | null;\n className?: string;\n}\n\nconst NARROW_QUERY = '(max-width: 768px)';\n\n/**\n * The detail as the inline slot draws it. It is kept out of the context the\n * lists read, so a new detail re-renders the slot and not the list.\n */\nconst DetailContext = createContext<ReactNode>(null);\n\n/**\n * How far to scroll so the row is in the view, clear of the `inset` at the\n * view's top, and the detail, whose top can rise no higher than `ceiling`,\n * fits above the view's bottom.\n */\nfunction revealDistance(\n row: DOMRect,\n ceiling: number,\n height: number,\n inset: number,\n view: ViewBounds,\n): number {\n const top = view.top + inset;\n const toRow =\n row.top < top ? row.top - top : Math.max(row.bottom - view.bottom, 0);\n return Math.max(toRow, ceiling + height - view.bottom);\n}\n\n/** The detail right after the selected row, at 768 px and below. */\nfunction InlineDetail({ boxRef }: { boxRef: RefObject<HTMLDivElement> }) {\n const detail = useContext(DetailContext);\n return (\n <div ref={boxRef} className=\"aegis-detail-beside__inline\" role=\"group\">\n {detail}\n </div>\n );\n}\n\n/**\n * A tree, table or map with the selected item's detail beside it. Above\n * 768 px the detail stands in a column on the right, level with the\n * selected row: when the row is too low for it, its bottom meets the\n * view's bottom, and while the page scrolls it stays in the view below\n * the header. At 768 px and below the list draws the detail right after\n * the selected row, the rows that follow under it; a map draws it over\n * the map, under the node. When the page opens with a selection,\n * `revealKey` changes or the viewer clicks the selected row, the page\n * scrolls at once, as little as it takes to show the row and the detail\n * whole, and again whenever the list or the detail changes size, until the\n * viewer scrolls or the host renders a new list or detail. Any other\n * placement, such as new data moving the selection or the rows, levels\n * the detail with its row by the same rule and leaves the page where it\n * is; the browser's scroll anchoring can still move it when rows arrive\n * above the view, unless the host sets `overflow-anchor: none` on its\n * scroller. The wrapper is `aria-busy` while a selected row it reveals is\n * still on its way.\n */\nexport function DetailBeside({\n columns,\n detail,\n children,\n revealKey,\n scrollContainer = null,\n className,\n}: DetailBesideProps) {\n const narrow = useMediaQuery(NARROW_QUERY);\n const [busy, setBusy] = useState(false);\n const listRef = useRef<HTMLDivElement>(null);\n const spacerRef = useRef<HTMLDivElement>(null);\n const detailRef = useRef<HTMLDivElement>(null);\n const rowRef = useRef<HTMLElement | null>(null);\n /** Whether the page is still where the last reveal left it. */\n const followRef = useRef(false);\n const revealedAtRef = useRef(0);\n /** The latest render's revealKey, and the last reveal's: undefined before the first. */\n const revealKeyRef = useRef(revealKey);\n const revealedKeyRef = useRef<string | null | undefined>(undefined);\n /** The latest render's list and detail, which change when the host renders them anew. */\n const shownRef = useRef({ children, detail });\n\n /**\n * Sets the detail level with the row: above 768 px through the spacer's\n * height, at and below by telling the inline detail how tall the row is.\n */\n const place = useCallback(() => {\n const row = rowRef.current;\n const box = detailRef.current;\n if (row === null || box === null) {\n return;\n }\n const rowBox = row.getBoundingClientRect();\n const spacer = spacerRef.current;\n if (spacer === null) {\n box.style.setProperty(\n '--aegis-detail-beside-row-height',\n `${String(rowBox.height)}px`,\n );\n } else {\n const top = spacer.getBoundingClientRect().top;\n spacer.style.height = `${String(Math.max(rowBox.top - top, 0))}px`;\n }\n }, []);\n\n /** Places the row and scrolls as little as it takes to show it and its detail whole. */\n const reveal = useCallback(() => {\n place();\n const row = rowRef.current;\n const box = detailRef.current;\n if (row === null || box === null) {\n return;\n }\n const rowBox = row.getBoundingClientRect();\n const spacer = spacerRef.current;\n const distance = revealDistance(\n rowBox,\n spacer === null ? rowBox.bottom : spacer.getBoundingClientRect().top,\n box.getBoundingClientRect().height,\n parseFloat(getComputedStyle(box).scrollMarginTop),\n viewBoundsOf(scrollContainer),\n );\n const scroller = scrollerOf(scrollContainer);\n if (Math.abs(distance) >= 1) {\n scroller.scrollBy({ top: distance, behavior: 'instant' });\n }\n revealedAtRef.current = scroller.scrollTop;\n }, [place, scrollContainer]);\n\n // A list places its row while React attaches refs, before the detail's\n // own ref is in and before the re-renders its layout effects ask for,\n // so the reveal waits for the commit to finish.\n const revealSoon = useCallback(() => {\n revealedKeyRef.current = revealKeyRef.current;\n followRef.current = true;\n setBusy(true);\n queueMicrotask(() => {\n reveal();\n setBusy(false);\n });\n }, [reveal]);\n\n // A row placed while a reveal is due is revealed; any other is levelled\n // with, and a new one ends following.\n const placeRow = useCallback(\n (row: HTMLElement | null) => {\n const fresh = row !== rowRef.current;\n rowRef.current = row;\n if (row === null) {\n followRef.current = false;\n setBusy(false);\n } else if (revealedKeyRef.current !== revealKeyRef.current) {\n revealSoon();\n } else {\n if (fresh) {\n followRef.current = false;\n }\n place();\n }\n },\n [place, revealSoon],\n );\n\n const awaitRow = useCallback(() => {\n setBusy(true);\n }, []);\n\n // Runs after the lists have placed their rows in this commit, so a new\n // revealKey reveals the row it selects. A render by the host without one\n // ends following.\n useIsomorphicLayoutEffect(() => {\n const rendered =\n shownRef.current.children !== children ||\n shownRef.current.detail !== detail;\n shownRef.current = { children, detail };\n revealKeyRef.current = revealKey;\n if (revealedKeyRef.current !== revealKey && rowRef.current !== null) {\n revealSoon();\n } else {\n if (rendered) {\n followRef.current = false;\n }\n place();\n }\n });\n\n useIsomorphicLayoutEffect(() => {\n const list = listRef.current;\n if (list === null) {\n return undefined;\n }\n const observer = new ResizeObserver(() => {\n if (followRef.current) {\n reveal();\n } else {\n place();\n }\n });\n // At 768 px and below the detail lies inside the list.\n for (const box of narrow ? [list] : [list, detailRef.current]) {\n if (box !== null) {\n observer.observe(box);\n }\n }\n const activate = (event: MouseEvent): void => {\n if (\n event.target instanceof Node &&\n rowRef.current?.contains(event.target)\n ) {\n revealSoon();\n }\n };\n list.addEventListener('click', activate);\n return () => {\n observer.disconnect();\n list.removeEventListener('click', activate);\n };\n }, [narrow, place, reveal, revealSoon]);\n\n useEffect(() => {\n const scroller = scrollerOf(scrollContainer);\n const target = scrollContainer ?? window;\n const scrolled = (): void => {\n if (Math.abs(scroller.scrollTop - revealedAtRef.current) >= 1) {\n followRef.current = false;\n }\n };\n target.addEventListener('scroll', scrolled, { passive: true });\n return () => {\n target.removeEventListener('scroll', scrolled);\n };\n }, [scrollContainer]);\n\n const inline = useMemo(\n () => (narrow ? <InlineDetail boxRef={detailRef} /> : null),\n [narrow],\n );\n const slot = useMemo(\n (): SelectedRowDetail => ({ placeRow, awaitRow, inline }),\n [placeRow, awaitRow, inline],\n );\n const isolated = (\n <SelectedRowDetailContext.Provider value={null}>\n {detail}\n </SelectedRowDetailContext.Provider>\n );\n\n const cls = ['aegis-detail-beside', className ?? '']\n .filter(Boolean)\n .join(' ');\n\n return (\n <SelectedRowDetailContext.Provider value={slot}>\n <DetailContext.Provider value={isolated}>\n <div\n className={cls}\n style={{ '--aegis-detail-beside-columns': columns } as CSSProperties}\n aria-busy={busy || undefined}\n >\n <div ref={listRef} className=\"aegis-detail-beside__list\">\n {children}\n </div>\n {!narrow && (\n <div className=\"aegis-detail-beside__side\">\n <div ref={spacerRef} />\n <div ref={detailRef} className=\"aegis-detail-beside__detail\">\n {isolated}\n </div>\n </div>\n )}\n </div>\n </DetailContext.Provider>\n </SelectedRowDetailContext.Provider>\n );\n}\n"],"names":["NARROW_QUERY","DetailContext","createContext","revealDistance","row","ceiling","height","inset","view","top","toRow","InlineDetail","boxRef","detail","useContext","jsx","DetailBeside","columns","children","revealKey","scrollContainer","className","narrow","useMediaQuery","busy","setBusy","useState","listRef","useRef","spacerRef","detailRef","rowRef","followRef","revealedAtRef","revealKeyRef","revealedKeyRef","shownRef","place","useCallback","box","rowBox","spacer","reveal","distance","viewBoundsOf","scroller","scrollerOf","revealSoon","placeRow","fresh","awaitRow","useIsomorphicLayoutEffect","rendered","list","observer","activate","event","useEffect","target","scrolled","inline","useMemo","slot","isolated","SelectedRowDetailContext","cls","jsxs"],"mappings":";;;;;;;AAiEA,MAAMA,IAAe,sBAMfC,IAAgBC,EAAyB,IAAI;AAOnD,SAASC,EACPC,GACAC,GACAC,GACAC,GACAC,GACQ;AACR,QAAMC,IAAMD,EAAK,MAAMD,GACjBG,IACJN,EAAI,MAAMK,IAAML,EAAI,MAAMK,IAAM,KAAK,IAAIL,EAAI,SAASI,EAAK,QAAQ,CAAC;AACtE,SAAO,KAAK,IAAIE,GAAOL,IAAUC,IAASE,EAAK,MAAM;AACvD;AAGA,SAASG,EAAa,EAAE,QAAAC,KAAiD;AACvE,QAAMC,IAASC,EAAWb,CAAa;AACvC,SACE,gBAAAc,EAAC,SAAI,KAAKH,GAAQ,WAAU,+BAA8B,MAAK,SAC5D,UAAAC,EAAA,CACH;AAEJ;AAqBO,SAASG,GAAa;AAAA,EAC3B,SAAAC;AAAA,EACA,QAAAJ;AAAA,EACA,UAAAK;AAAA,EACA,WAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,WAAAC;AACF,GAAsB;AACpB,QAAMC,IAASC,EAAcvB,CAAY,GACnC,CAACwB,GAAMC,CAAO,IAAIC,EAAS,EAAK,GAChCC,IAAUC,EAAuB,IAAI,GACrCC,IAAYD,EAAuB,IAAI,GACvCE,IAAYF,EAAuB,IAAI,GACvCG,IAASH,EAA2B,IAAI,GAExCI,IAAYJ,EAAO,EAAK,GACxBK,IAAgBL,EAAO,C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;AAAA,QAAA,gBAAAT,EAAC,OAAA,EAAI,KAAKY,GAAS,WAAU,6BAC1B,UAAAT,GACH;AAAA,QACC,CAACI,KACA,gBAAA4C,EAAC,OAAA,EAAI,WAAU,6BACb,UAAA;AAAA,UAAA,gBAAAnD,EAAC,OAAA,EAAI,KAAKc,EAAA,CAAW;AAAA,4BACpB,OAAA,EAAI,KAAKC,GAAW,WAAU,+BAC5B,UAAAiC,EAAA,CACH;AAAA,QAAA,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAGN,EAAA,CACF;AAEJ;"}
1
+ {"version":3,"file":"DetailBeside.js","sources":["../../../src/components/ui/DetailBeside.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type ReactNode,\n type RefObject,\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect';\nimport { useMediaQuery } from '../../hooks/useMediaQuery';\nimport {\n type ViewBounds,\n scrollerOf,\n viewBoundsOf,\n} from '../../lib/scrollView';\nimport './DetailBeside.css';\nimport {\n type SelectedRowDetail,\n SelectedRowDetailContext,\n} from './selectedRowDetail';\n\nexport interface DetailBesideProps {\n /**\n * `grid-template-columns` of the list and the detail above 768 px, e.g.\n * `'3fr 2fr'`.\n */\n columns: string;\n /**\n * The selected item's detail: one element, such as a `Panel` titled with\n * the item's name. It is never taller than the view, so a long Panel\n * scrolls its body. Render it anew from the host's data whenever that\n * data changes: that render tells DetailBeside the change was new data,\n * so the page stays where it is. A detail that fetches its own data and\n * redraws without this host rendering leaves the page following the row,\n * and its next change of size scrolls the page.\n */\n detail: ReactNode;\n /**\n * The list: a `TraceTree`, `FileTree`, `DataTable`, `TreeTable` or\n * `ServiceMap`, in a Panel say. The detail follows the row it draws\n * selected. Like `detail`, render it anew from the host's data whenever\n * that data changes, so the page stays where it is on new data; a list\n * that fetches its own data and redraws without this host rendering\n * leaves the page following the row, and its next change of size scrolls\n * the page.\n */\n children: ReactNode;\n /**\n * The selection as the page's address names it, or null where the\n * address names none and the list shows a default. It changes only by\n * the viewer's doing: a click, a key, a link, back or forward. The page\n * scrolls to the selected row when this changes, and on the first\n * placement after mount; a row that comes into place for new data, such\n * as a default the data moved, is only levelled with.\n */\n revealKey: string | null;\n /** The element that scrolls the page; omitted or null means the viewport. */\n scrollContainer?: HTMLElement | null;\n className?: string;\n}\n\nconst NARROW_QUERY = '(max-width: 768px)';\n\n/**\n * The detail as the inline slot draws it. It is kept out of the context the\n * lists read, so a new detail re-renders the slot and not the list.\n */\nconst DetailContext = createContext<ReactNode>(null);\n\n/**\n * How far to scroll so the row is in the view, clear of the `inset` at the\n * view's top, and the detail, whose top can rise no higher than `ceiling`,\n * fits above the view's bottom.\n */\nfunction revealDistance(\n row: DOMRect,\n ceiling: number,\n height: number,\n inset: number,\n view: ViewBounds,\n): number {\n const top = view.top + inset;\n const toRow =\n row.top < top ? row.top - top : Math.max(row.bottom - view.bottom, 0);\n return Math.max(toRow, ceiling + height - view.bottom);\n}\n\n/** The detail right after the selected row, at 768 px and below. */\nfunction InlineDetail({ boxRef }: { boxRef: RefObject<HTMLDivElement> }) {\n const detail = useContext(DetailContext);\n return (\n <div ref={boxRef} className=\"aegis-detail-beside__inline\" role=\"group\">\n {detail}\n </div>\n );\n}\n\n/**\n * A tree, table or map with the selected item's detail beside it. Above\n * 768 px the detail stands in a column on the right, level with the\n * selected row: when the row is too low for it, its bottom meets the\n * view's bottom, and while the page scrolls it stays in the view below\n * the header; while the list draws no row selected, it stands at the\n * column's top. At 768 px and below the list draws the detail right after\n * the selected row, the rows that follow under it; a map draws it over\n * the map, under the node. When the page opens with a selection,\n * `revealKey` changes or the viewer clicks the selected row, the page\n * scrolls at once, as little as it takes to show the row and the detail\n * whole, and again whenever the list or the detail changes size, until the\n * viewer scrolls or the host renders a new list or detail. Any other\n * placement, such as new data moving the selection or the rows, levels\n * the detail with its row by the same rule and leaves the page where it\n * is; the browser's scroll anchoring can still move it when rows arrive\n * above the view, unless the host sets `overflow-anchor: none` on its\n * scroller. The wrapper is `aria-busy` while a selected row it reveals is\n * still on its way.\n */\nexport function DetailBeside({\n columns,\n detail,\n children,\n revealKey,\n scrollContainer = null,\n className,\n}: DetailBesideProps) {\n const narrow = useMediaQuery(NARROW_QUERY);\n const [busy, setBusy] = useState(false);\n const listRef = useRef<HTMLDivElement>(null);\n const spacerRef = useRef<HTMLDivElement>(null);\n const detailRef = useRef<HTMLDivElement>(null);\n const rowRef = useRef<HTMLElement | null>(null);\n /** Whether the page is still where the last reveal left it. */\n const followRef = useRef(false);\n const revealedAtRef = useRef(0);\n /** The latest render's revealKey, and the last reveal's: undefined before the first. */\n const revealKeyRef = useRef(revealKey);\n const revealedKeyRef = useRef<string | null | undefined>(undefined);\n /** The latest render's list and detail, which change when the host renders them anew. */\n const shownRef = useRef({ children, detail });\n\n /**\n * Sets the detail level with the row: above 768 px through the spacer's\n * height, at and below by telling the inline detail how tall the row is.\n * While the list draws no row selected, such as when a filter or a closed\n * parent hides it, the detail stands at the top of its column.\n */\n const place = useCallback(() => {\n const row = rowRef.current;\n const box = detailRef.current;\n const spacer = spacerRef.current;\n if (row === null) {\n spacer?.style.removeProperty('height');\n return;\n }\n if (box === null) {\n return;\n }\n const rowBox = row.getBoundingClientRect();\n if (spacer === null) {\n box.style.setProperty(\n '--aegis-detail-beside-row-height',\n `${String(rowBox.height)}px`,\n );\n } else {\n const top = spacer.getBoundingClientRect().top;\n spacer.style.height = `${String(Math.max(rowBox.top - top, 0))}px`;\n }\n }, []);\n\n /** Places the row and scrolls as little as it takes to show it and its detail whole. */\n const reveal = useCallback(() => {\n place();\n const row = rowRef.current;\n const box = detailRef.current;\n if (row === null || box === null) {\n return;\n }\n const rowBox = row.getBoundingClientRect();\n const spacer = spacerRef.current;\n const distance = revealDistance(\n rowBox,\n spacer === null ? rowBox.bottom : spacer.getBoundingClientRect().top,\n box.getBoundingClientRect().height,\n parseFloat(getComputedStyle(box).scrollMarginTop),\n viewBoundsOf(scrollContainer),\n );\n const scroller = scrollerOf(scrollContainer);\n if (Math.abs(distance) >= 1) {\n scroller.scrollBy({ top: distance, behavior: 'instant' });\n }\n revealedAtRef.current = scroller.scrollTop;\n }, [place, scrollContainer]);\n\n // A list places its row while React attaches refs, before the detail's\n // own ref is in and before the re-renders its layout effects ask for,\n // so the reveal waits for the commit to finish.\n const revealSoon = useCallback(() => {\n revealedKeyRef.current = revealKeyRef.current;\n followRef.current = true;\n setBusy(true);\n queueMicrotask(() => {\n reveal();\n setBusy(false);\n });\n }, [reveal]);\n\n // A row placed while a reveal is due is revealed; any other is levelled\n // with, and a new one ends following.\n const placeRow = useCallback(\n (row: HTMLElement | null) => {\n const fresh = row !== rowRef.current;\n rowRef.current = row;\n if (row === null) {\n followRef.current = false;\n setBusy(false);\n place();\n } else if (revealedKeyRef.current !== revealKeyRef.current) {\n revealSoon();\n } else {\n if (fresh) {\n followRef.current = false;\n }\n place();\n }\n },\n [place, revealSoon],\n );\n\n const awaitRow = useCallback(() => {\n setBusy(true);\n }, []);\n\n // Runs after the lists have placed their rows in this commit, so a new\n // revealKey reveals the row it selects. A render by the host without one\n // ends following.\n useIsomorphicLayoutEffect(() => {\n const rendered =\n shownRef.current.children !== children ||\n shownRef.current.detail !== detail;\n shownRef.current = { children, detail };\n revealKeyRef.current = revealKey;\n if (revealedKeyRef.current !== revealKey && rowRef.current !== null) {\n revealSoon();\n } else {\n if (rendered) {\n followRef.current = false;\n }\n place();\n }\n });\n\n useIsomorphicLayoutEffect(() => {\n const list = listRef.current;\n if (list === null) {\n return undefined;\n }\n const observer = new ResizeObserver(() => {\n if (followRef.current) {\n reveal();\n } else {\n place();\n }\n });\n // At 768 px and below the detail lies inside the list.\n for (const box of narrow ? [list] : [list, detailRef.current]) {\n if (box !== null) {\n observer.observe(box);\n }\n }\n const activate = (event: MouseEvent): void => {\n if (\n event.target instanceof Node &&\n rowRef.current?.contains(event.target)\n ) {\n revealSoon();\n }\n };\n list.addEventListener('click', activate);\n return () => {\n observer.disconnect();\n list.removeEventListener('click', activate);\n };\n }, [narrow, place, reveal, revealSoon]);\n\n useEffect(() => {\n const scroller = scrollerOf(scrollContainer);\n const target = scrollContainer ?? window;\n const scrolled = (): void => {\n if (Math.abs(scroller.scrollTop - revealedAtRef.current) >= 1) {\n followRef.current = false;\n }\n };\n target.addEventListener('scroll', scrolled, { passive: true });\n return () => {\n target.removeEventListener('scroll', scrolled);\n };\n }, [scrollContainer]);\n\n const inline = useMemo(\n () => (narrow ? <InlineDetail boxRef={detailRef} /> : null),\n [narrow],\n );\n const slot = useMemo(\n (): SelectedRowDetail => ({ placeRow, awaitRow, inline }),\n [placeRow, awaitRow, inline],\n );\n const isolated = (\n <SelectedRowDetailContext.Provider value={null}>\n {detail}\n </SelectedRowDetailContext.Provider>\n );\n\n const cls = ['aegis-detail-beside', className ?? '']\n .filter(Boolean)\n .join(' ');\n\n return (\n <SelectedRowDetailContext.Provider value={slot}>\n <DetailContext.Provider value={isolated}>\n <div\n className={cls}\n style={{ '--aegis-detail-beside-columns': columns } as CSSProperties}\n aria-busy={busy || undefined}\n >\n <div ref={listRef} className=\"aegis-detail-beside__list\">\n {children}\n </div>\n {!narrow && (\n <div className=\"aegis-detail-beside__side\">\n <div ref={spacerRef} />\n <div ref={detailRef} className=\"aegis-detail-beside__detail\">\n {isolated}\n </div>\n </div>\n )}\n </div>\n </DetailContext.Provider>\n </SelectedRowDetailContext.Provider>\n );\n}\n"],"names":["NARROW_QUERY","DetailContext","createContext","revealDistance","row","ceiling","height","inset","view","top","toRow","InlineDetail","boxRef","detail","useContext","jsx","DetailBeside","columns","children","revealKey","scrollContainer","className","narrow","useMediaQuery","busy","setBusy","useState","listRef","useRef","spacerRef","detailRef","rowRef","followRef","revealedAtRef","revealKeyRef","revealedKeyRef","shownRef","place","useCallback","box","spacer","rowBox","reveal","distance","viewBoundsOf","scroller","scrollerOf","revealSoon","placeRow","fresh","awaitRow","useIsomorphicLayoutEffect","rendered","list","observer","activate","event","useEffect","target","scrolled","inline","useMemo","slot","isolated","SelectedRowDetailContext","cls","jsxs"],"mappings":";;;;;;;AAkEA,MAAMA,IAAe,sBAMfC,IAAgBC,EAAyB,IAAI;AAOnD,SAASC,EACPC,GACAC,GACAC,GACAC,GACAC,GACQ;AACR,QAAMC,IAAMD,EAAK,MAAMD,GACjBG,IACJN,EAAI,MAAMK,IAAML,EAAI,MAAMK,IAAM,KAAK,IAAIL,EAAI,SAASI,EAAK,QAAQ,CAAC;AACtE,SAAO,KAAK,IAAIE,GAAOL,IAAUC,IAASE,EAAK,MAAM;AACvD;AAGA,SAASG,EAAa,EAAE,QAAAC,KAAiD;AACvE,QAAMC,IAASC,EAAWb,CAAa;AACvC,SACE,gBAAAc,EAAC,SAAI,KAAKH,GAAQ,WAAU,+BAA8B,MAAK,SAC5D,UAAAC,EAAA,CACH;AAEJ;AAsBO,SAASG,GAAa;AAAA,EAC3B,SAAAC;AAAA,EACA,QAAAJ;AAAA,EACA,UAAAK;AAAA,EACA,WAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,WAAAC;AACF,GAAsB;AACpB,QAAMC,IAASC,EAAcvB,CAAY,GACnC,CAACwB,GAAMC,CAAO,IAAIC,EAAS,EAAK,GAChCC,IAAUC,EAAuB,IAAI,GACrCC,IAAYD,EAAuB,IAAI,GACvCE,IAAYF,EAAuB,IAAI,GACvCG,IAASH,EAA2B,IAAI,GAExCI,IAAYJ,EAAO,EAAK,GACxBK,IAAgBL,EAAO,CAAC,GAExBM,IAAeN,EAAOT,CAAS,GAC/BgB,IAAiBP,EAAkC,MAAS,GAE5DQ,IAAWR,EAAO,EAAE,UAAAV,GAAU,QAAAL,GAAQ,GAQtCwB,IAAQC,EAAY,MAAM;AAC9B,UAAMlC,IAAM2B,EAAO,SACbQ,IAAMT,EAAU,SAChBU,IAASX,EAAU;AACzB,QAAIzB,MAAQ,MAAM;AAChB,MAAAoC,GAAQ,MAAM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AW;AAAA,4BACpB,OAAA,EAAI,KAAKC,GAAW,WAAU,+BAC5B,UAAAiC,EAAA,CACH;AAAA,QAAA,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAGN,EAAA,CACF;AAEJ;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),_=require("react"),Y=require("@ant-design/icons"),G=require("../../hooks/useMediaQuery.cjs"),J=require("./EmptyState.cjs");;/* empty css */const X=require("./selectedRowDetail.cjs"),Z=require("../../locale/useStrings.cjs"),ee="(max-width: 768px)",T="data-aegis-tree-table-row",te="data-aegis-tree-table-caret",re='a, button, input, select, textarea, label, [role="button"], [role="link"], [role="checkbox"]';function se(r){return r===void 0?"minmax(0, 1fr)":typeof r=="number"?`${String(r)}px`:r}function q(r,i,a,o,h=[]){for(const l of r){const c=a(l);if(c===i)return h;const d=q(o(l)??[],i,a,o,[...h,c]);if(d.length>0)return d}return[]}function I(r,i,a,o,h=null,l=0,c=[]){return r.forEach((d,f)=>{const g=a(d),m=o(d)??[];c.push({row:d,key:g,parentKey:h,depth:l,position:f+1,siblings:r.length,hasChildren:m.length>0}),m.length>0&&i.has(g)&&I(m,i,a,o,g,l+1,c)}),c}function ae(r,i){if(window.getSelection()?.type==="Range")return!0;const a=r.closest(re);return a!==null&&i.contains(a)}function ne({row:r,rowKey:i,depth:a,position:o,siblings:h,hasChildren:l,expanded:c,selectable:d,selected:f,tabbable:g,folded:m,columns:R,placeRow:v}){const N={expanded:l&&c},A=["aegis-tree-table__row",d?"aegis-tree-table__row--selectable":"",f?"aegis-tree-table__row--selected":""].filter(Boolean).join(" ");return n.jsx("div",{ref:v,className:A,role:"row","data-aegis-tree-table-row":i,"aria-level":a+1,"aria-posinset":o,"aria-setsize":h,"aria-expanded":l?c:void 0,"aria-selected":d?f:void 0,tabIndex:g?0:-1,style:{"--aegis-tree-table-depth":a},children:R.map((b,p)=>{const w=["aegis-tree-table__cell",p===0?"aegis-tree-table__cell--tree":"",b.numeric?"aegis-tree-table__cell--numeric":"",b.truncate?"aegis-tree-table__cell--truncate":""].filter(Boolean).join(" ");return n.jsxs("div",{className:w,role:"gridcell",children:[p===0&&n.jsx("span",{className:"aegis-tree-table__caret","aria-hidden":"true","data-aegis-tree-table-caret":l?"":void 0,children:l&&n.jsx(Y.RightOutlined,{className:"aegis-tree-table__chevron"})}),m&&p>0&&n.jsx("span",{className:"aegis-tree-table__label",children:b.header}),n.jsx("div",{className:"aegis-tree-table__content",children:b.render(r,N)})]},b.key)})})}const ie=_.memo(ne);function le({columns:r,data:i,rowKey:a,getSubRows:o,ariaLabel:h,expandedKeys:l,defaultExpandedKeys:c=[],onExpandedKeysChange:d,selectedKey:f,onSelect:g,emptyTitle:m,emptyDescription:R,framed:v=!0,className:N}){const A=Z.useStrings(),b=G.useMediaQuery(ee),p=_.useContext(X.SelectedRowDetailContext),w=_.useRef(null),x=f??null,[D,O]=_.useState(()=>[...c,...x===null?[]:q(i,x,a,o)]),[B,F]=_.useState(x);x!==B&&(F(x),x!==null&&O([...new Set([...D,...q(i,x,a,o)])]));const j=l??D,E=_.useMemo(()=>new Set(j),[j]),u=I(i,E,a,o),[K,L]=_.useState(),M=[K,f].find(e=>u.some(t=>t.key===e))??u[0]?.key,U=g!==void 0||f!==void 0,C=(e,t)=>{const s=t?[...j,e]:j.filter(y=>y!==e);l===void 0&&O(s),d?.(s)},S=e=>{if(!(e instanceof Element))return-1;const t=e.closest(`[${T}]`);if(t===null||t.parentElement!==w.current)return-1;const s=t.getAttribute(T);return u.findIndex(y=>y.key===s)},k=e=>{const t=w.current?.querySelectorAll(`:scope > [${T}]`).item(e);t instanceof HTMLElement&&t.focus()},$=e=>{const t=S(e.target);if(t<0||!(e.target instanceof Element))return;const s=u[t];e.target.closest(`[${te}]`)!==null?C(s.key,!E.has(s.key)):ae(e.target,e.currentTarget)||g?.(s.row)},Q=e=>{const t=S(e.target);if(t<0||!(e.target instanceof Element)||!e.target.hasAttribute(T))return;const s=u[t],y=s.hasChildren&&E.has(s.key);switch(e.key){case"ArrowDown":k(t+1);break;case"ArrowUp":k(t-1);break;case"Home":k(0);break;case"End":k(u.length-1);break;case"ArrowRight":y?k(t+1):s.hasChildren&&C(s.key,!0);break;case"ArrowLeft":if(y)C(s.key,!1);else if(s.parentKey!==null){const{parentKey:V}=s;k(u.findIndex(W=>W.key===V))}break;case"Enter":case" ":g?.(s.row);break;default:return}e.preventDefault()},H=e=>{const t=S(e.target);t>=0&&e.target.hasAttribute(T)&&L(u[t].key)},z=["aegis-tree-table",v?"aegis-tree-table--framed":"",b?"aegis-tree-table--folded":"",N??""].filter(Boolean).join(" "),P={"--aegis-tree-table-columns":r.map(e=>se(e.width)).join(" ")};return n.jsxs("div",{className:z,style:P,children:[n.jsxs("div",{ref:w,className:"aegis-tree-table__grid",role:"treegrid","aria-label":h,tabIndex:-1,onClick:$,onKeyDown:Q,onFocus:H,children:[!b&&n.jsx("div",{className:"aegis-tree-table__head",role:"row",children:r.map(e=>n.jsx("div",{className:e.numeric?"aegis-tree-table__th aegis-tree-table__th--numeric":"aegis-tree-table__th",role:"columnheader",children:e.header},e.key))}),u.map(e=>{const t=f===e.key;return n.jsxs(_.Fragment,{children:[n.jsx(ie,{row:e.row,rowKey:e.key,depth:e.depth,position:e.position,siblings:e.siblings,hasChildren:e.hasChildren,expanded:E.has(e.key),selectable:U,selected:t,tabbable:e.key===M,folded:b,columns:r,placeRow:t?p?.placeRow:void 0}),t&&p?.inline?n.jsx("div",{className:"aegis-tree-table__inline",role:"row",children:n.jsx("div",{role:"gridcell",children:p.inline})}):null]},e.key)})]}),u.length===0&&n.jsx(J.EmptyState,{title:m??A.noData,description:R})]})}exports.TreeTable=le;
2
+ //# sourceMappingURL=TreeTable.cjs.map