@lincyaw/aegis-ui 0.19.0 → 0.20.1
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/dist/components/ui/AnchoredPopover.cjs +1 -1
- package/dist/components/ui/AnchoredPopover.cjs.map +1 -1
- package/dist/components/ui/AnchoredPopover.d.ts +7 -1
- package/dist/components/ui/AnchoredPopover.js +64 -62
- package/dist/components/ui/AnchoredPopover.js.map +1 -1
- package/dist/components/ui/DataTable.cjs +1 -1
- package/dist/components/ui/DataTable.cjs.map +1 -1
- package/dist/components/ui/DataTable.d.ts +11 -1
- package/dist/components/ui/DataTable.js +78 -74
- package/dist/components/ui/DataTable.js.map +1 -1
- package/dist/components/ui/DetailBeside.cjs +1 -1
- package/dist/components/ui/DetailBeside.cjs.map +1 -1
- package/dist/components/ui/DetailBeside.d.ts +9 -4
- package/dist/components/ui/DetailBeside.js +91 -77
- package/dist/components/ui/DetailBeside.js.map +1 -1
- package/dist/components/ui/IdentityCell.cjs +1 -1
- package/dist/components/ui/IdentityCell.cjs.map +1 -1
- package/dist/components/ui/IdentityCell.d.ts +6 -1
- package/dist/components/ui/IdentityCell.js +17 -15
- package/dist/components/ui/IdentityCell.js.map +1 -1
- package/dist/components/ui/PaneLayout.cjs +1 -1
- package/dist/components/ui/PaneLayout.cjs.map +1 -1
- package/dist/components/ui/PaneLayout.d.ts +7 -2
- package/dist/components/ui/PaneLayout.js +20 -22
- package/dist/components/ui/PaneLayout.js.map +1 -1
- package/dist/components/ui/Select.cjs +1 -1
- package/dist/components/ui/Select.cjs.map +1 -1
- package/dist/components/ui/Select.d.ts +8 -2
- package/dist/components/ui/Select.js +44 -38
- package/dist/components/ui/Select.js.map +1 -1
- package/dist/components/ui/TimeDisplay.cjs +1 -1
- package/dist/components/ui/TimeDisplay.cjs.map +1 -1
- package/dist/components/ui/TimeDisplay.d.ts +11 -3
- package/dist/components/ui/TimeDisplay.js +39 -34
- package/dist/components/ui/TimeDisplay.js.map +1 -1
- package/dist/components/ui/Timeline.cjs +1 -1
- package/dist/components/ui/Timeline.cjs.map +1 -1
- package/dist/components/ui/Timeline.d.ts +17 -4
- package/dist/components/ui/Timeline.js +88 -67
- package/dist/components/ui/Timeline.js.map +1 -1
- package/dist/components/ui/Toolbar.cjs.map +1 -1
- package/dist/components/ui/Toolbar.d.ts +2 -1
- package/dist/components/ui/Toolbar.js.map +1 -1
- package/dist/components/ui/TraceTree.cjs +1 -1
- package/dist/components/ui/TraceTree.cjs.map +1 -1
- package/dist/components/ui/TraceTree.d.ts +7 -1
- package/dist/components/ui/TraceTree.js +127 -119
- package/dist/components/ui/TraceTree.js.map +1 -1
- package/dist/components/ui/linkComponent.cjs +1 -1
- package/dist/components/ui/linkComponent.cjs.map +1 -1
- package/dist/components/ui/linkComponent.d.ts +6 -4
- package/dist/components/ui/linkComponent.js +12 -10
- package/dist/components/ui/linkComponent.js.map +1 -1
- package/dist/layouts/shell/AegisShell.cjs +1 -1
- package/dist/layouts/shell/AegisShell.cjs.map +1 -1
- package/dist/layouts/shell/AegisShell.js +24 -24
- package/dist/layouts/shell/AegisShell.js.map +1 -1
- package/dist/layouts/shell/RouterLink.cjs +1 -1
- package/dist/layouts/shell/RouterLink.cjs.map +1 -1
- package/dist/layouts/shell/RouterLink.js +14 -12
- package/dist/layouts/shell/RouterLink.js.map +1 -1
- package/dist/layouts/shell/types.d.ts +6 -0
- package/dist/locale/strings.cjs +1 -1
- package/dist/locale/strings.cjs.map +1 -1
- package/dist/locale/strings.d.ts +2 -0
- package/dist/locale/strings.js +7 -5
- package/dist/locale/strings.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),q=require("react"),b=require("@ant-design/icons");;/* empty css */const y=require("../../locale/useStrings.cjs");function p({value:i,options:g,onChange:c,label:l,labelPlacement:h="above",ariaLabel:j,placeholder:t,allowClear:v=!1,disabled:n=!1,id:x,"aria-describedby":m,className:_}){const r=y.useStrings(),S=q.useId(),d=x??S,o=v&&i!==""&&!n,f=t!==void 0&&i==="",a=l!==void 0&&h==="inline",u=e.jsxs("label",{className:"aegis-select__label",htmlFor:d,children:[l,a&&e.jsx("span",{"aria-hidden":!0,children:r.labelSeparator})]}),N=["aegis-select",o?"aegis-select--clearable":"",f?"aegis-select--placeholder":"",a?"aegis-select--inline":"",_??""].filter(Boolean).join(" ");return e.jsxs("div",{className:N,"data-aegis-field":!0,children:[l!==void 0&&!a&&u,e.jsxs("div",{className:"aegis-select__control",children:[a&&u,e.jsxs("select",{className:"aegis-select__native",id:d,value:i,disabled:n,"aria-label":j,"aria-describedby":m,onChange:s=>{c(s.target.value)},children:[t!==void 0&&e.jsx("option",{value:"",disabled:!0,children:t}),g.map(s=>e.jsx("option",{value:s.value,disabled:s.disabled,children:s.label},s.value))]}),e.jsx(b.DownOutlined,{className:"aegis-select__chevron","aria-hidden":!0}),o&&e.jsx("button",{type:"button",className:"aegis-select__clear","aria-label":r.clearSelection,onClick:()=>{c("")},children:e.jsx(b.CloseOutlined,{"aria-hidden":!0})})]})]})}exports.Select=p;
|
|
2
2
|
//# sourceMappingURL=Select.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.cjs","sources":["../../../src/components/ui/Select.tsx"],"sourcesContent":["import { type ReactNode, useId } from 'react';\n\nimport { CloseOutlined, DownOutlined } from '@ant-design/icons';\n\nimport { useStrings } from '../../locale';\nimport './Select.css';\n\nexport interface SelectOption {\n value: string;\n label: string;\n disabled?: boolean;\n}\n\ninterface SelectProps {\n value: string;\n options: SelectOption[];\n onChange: (value: string) => void;\n /** Caption
|
|
1
|
+
{"version":3,"file":"Select.cjs","sources":["../../../src/components/ui/Select.tsx"],"sourcesContent":["import { type ReactNode, useId } from 'react';\n\nimport { CloseOutlined, DownOutlined } from '@ant-design/icons';\n\nimport { useStrings } from '../../locale';\nimport './Select.css';\n\nexport interface SelectOption {\n value: string;\n label: string;\n disabled?: boolean;\n}\n\ninterface SelectProps {\n value: string;\n options: SelectOption[];\n onChange: (value: string) => void;\n /** Caption of the control, as its `<label>`, so it names the select. */\n label?: ReactNode;\n /**\n * `above` (default) sets the caption over the control. `inline` sets it\n * inside the control before the value, followed by the locale's label\n * separator (\"Run: e3b0aa32\"), for a compact selector in a bar.\n */\n labelPlacement?: 'above' | 'inline';\n /** Accessible name for a select shown without a visible caption, e.g. a compact filter. */\n ariaLabel?: string;\n /** Rendered as a disabled first option when `value` is empty. */\n placeholder?: string;\n /** Shows a clear control once a value is set. */\n allowClear?: boolean;\n disabled?: boolean;\n /** Lets a caller's `<label htmlFor>` point at the control. */\n id?: string;\n /** Ids of the text that describes the select, such as a FormRow's description. */\n 'aria-describedby'?: string;\n className?: string;\n}\n\nexport function Select({\n value,\n options,\n onChange,\n label,\n labelPlacement = 'above',\n ariaLabel,\n placeholder,\n allowClear = false,\n disabled = false,\n id,\n 'aria-describedby': describedBy,\n className,\n}: SelectProps) {\n const strings = useStrings();\n const ownId = useId();\n const selectId = id ?? ownId;\n const clearable = allowClear && value !== '' && !disabled;\n const showsPlaceholder = placeholder !== undefined && value === '';\n const inline = label !== undefined && labelPlacement === 'inline';\n const caption = (\n <label className=\"aegis-select__label\" htmlFor={selectId}>\n {label}\n {inline && <span aria-hidden>{strings.labelSeparator}</span>}\n </label>\n );\n const cls = [\n 'aegis-select',\n clearable ? 'aegis-select--clearable' : '',\n showsPlaceholder ? 'aegis-select--placeholder' : '',\n inline ? 'aegis-select--inline' : '',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n return (\n <div className={cls} data-aegis-field>\n {label !== undefined && !inline && caption}\n <div className=\"aegis-select__control\">\n {inline && caption}\n <select\n className=\"aegis-select__native\"\n id={selectId}\n value={value}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-describedby={describedBy}\n onChange={(event) => {\n onChange(event.target.value);\n }}\n >\n {placeholder !== undefined && (\n <option value=\"\" disabled>\n {placeholder}\n </option>\n )}\n {options.map((option) => (\n <option\n key={option.value}\n value={option.value}\n disabled={option.disabled}\n >\n {option.label}\n </option>\n ))}\n </select>\n <DownOutlined className=\"aegis-select__chevron\" aria-hidden />\n {clearable && (\n <button\n type=\"button\"\n className=\"aegis-select__clear\"\n aria-label={strings.clearSelection}\n onClick={() => {\n onChange('');\n }}\n >\n <CloseOutlined aria-hidden />\n </button>\n )}\n </div>\n </div>\n );\n}\n"],"names":["Select","value","options","onChange","label","labelPlacement","ariaLabel","placeholder","allowClear","disabled","id","describedBy","className","strings","useStrings","ownId","useId","selectId","clearable","showsPlaceholder","inline","caption","jsxs","jsx","cls","event","option","DownOutlined","CloseOutlined"],"mappings":"kPAuCO,SAASA,EAAO,CACrB,MAAAC,EACA,QAAAC,EACA,SAAAC,EACA,MAAAC,EACA,eAAAC,EAAiB,QACjB,UAAAC,EACA,YAAAC,EACA,WAAAC,EAAa,GACb,SAAAC,EAAW,GACX,GAAAC,EACA,mBAAoBC,EACpB,UAAAC,CACF,EAAgB,CACd,MAAMC,EAAUC,EAAAA,WAAA,EACVC,EAAQC,EAAAA,MAAA,EACRC,EAAWP,GAAMK,EACjBG,EAAYV,GAAcP,IAAU,IAAM,CAACQ,EAC3CU,EAAmBZ,IAAgB,QAAaN,IAAU,GAC1DmB,EAAShB,IAAU,QAAaC,IAAmB,SACnDgB,EACJC,EAAAA,KAAC,QAAA,CAAM,UAAU,sBAAsB,QAASL,EAC7C,SAAA,CAAAb,EACAgB,GAAUG,EAAAA,IAAC,OAAA,CAAK,cAAW,GAAE,WAAQ,cAAA,CAAe,CAAA,EACvD,EAEIC,EAAM,CACV,eACAN,EAAY,0BAA4B,GACxCC,EAAmB,4BAA8B,GACjDC,EAAS,uBAAyB,GAClCR,GAAa,EAAA,EAEZ,OAAO,OAAO,EACd,KAAK,GAAG,EACX,OACEU,EAAAA,KAAC,MAAA,CAAI,UAAWE,EAAK,mBAAgB,GAClC,SAAA,CAAApB,IAAU,QAAa,CAACgB,GAAUC,EACnCC,EAAAA,KAAC,MAAA,CAAI,UAAU,wBACZ,SAAA,CAAAF,GAAUC,EACXC,EAAAA,KAAC,SAAA,CACC,UAAU,uBACV,GAAIL,EACJ,MAAAhB,EACA,SAAAQ,EACA,aAAYH,EACZ,mBAAkBK,EAClB,SAAWc,GAAU,CACnBtB,EAASsB,EAAM,OAAO,KAAK,CAC7B,EAEC,SAAA,CAAAlB,IAAgB,QACfgB,MAAC,SAAA,CAAO,MAAM,GAAG,SAAQ,GACtB,SAAAhB,CAAA,CACH,EAEDL,EAAQ,IAAKwB,GACZH,EAAAA,IAAC,SAAA,CAEC,MAAOG,EAAO,MACd,SAAUA,EAAO,SAEhB,SAAAA,EAAO,KAAA,EAJHA,EAAO,KAAA,CAMf,CAAA,CAAA,CAAA,EAEHH,EAAAA,IAACI,EAAAA,aAAA,CAAa,UAAU,wBAAwB,cAAW,GAAC,EAC3DT,GACCK,EAAAA,IAAC,SAAA,CACC,KAAK,SACL,UAAU,sBACV,aAAYV,EAAQ,eACpB,QAAS,IAAM,CACbV,EAAS,EAAE,CACb,EAEA,SAAAoB,EAAAA,IAACK,EAAAA,cAAA,CAAc,cAAW,EAAA,CAAC,CAAA,CAAA,CAC7B,CAAA,CAEJ,CAAA,EACF,CAEJ"}
|
|
@@ -8,8 +8,14 @@ interface SelectProps {
|
|
|
8
8
|
value: string;
|
|
9
9
|
options: SelectOption[];
|
|
10
10
|
onChange: (value: string) => void;
|
|
11
|
-
/** Caption
|
|
11
|
+
/** Caption of the control, as its `<label>`, so it names the select. */
|
|
12
12
|
label?: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* `above` (default) sets the caption over the control. `inline` sets it
|
|
15
|
+
* inside the control before the value, followed by the locale's label
|
|
16
|
+
* separator ("Run: e3b0aa32"), for a compact selector in a bar.
|
|
17
|
+
*/
|
|
18
|
+
labelPlacement?: 'above' | 'inline';
|
|
13
19
|
/** Accessible name for a select shown without a visible caption, e.g. a compact filter. */
|
|
14
20
|
ariaLabel?: string;
|
|
15
21
|
/** Rendered as a disabled first option when `value` is empty. */
|
|
@@ -23,5 +29,5 @@ interface SelectProps {
|
|
|
23
29
|
'aria-describedby'?: string;
|
|
24
30
|
className?: string;
|
|
25
31
|
}
|
|
26
|
-
export declare function Select({ value, options, onChange, label, ariaLabel, placeholder, allowClear, disabled, id, 'aria-describedby': describedBy, className, }: SelectProps): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
export declare function Select({ value, options, onChange, label, labelPlacement, ariaLabel, placeholder, allowClear, disabled, id, 'aria-describedby': describedBy, className, }: SelectProps): import("react/jsx-runtime").JSX.Element;
|
|
27
33
|
export {};
|
|
@@ -1,45 +1,51 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useId as
|
|
3
|
-
import { DownOutlined as
|
|
1
|
+
import { jsxs as l, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useId as w } from "react";
|
|
3
|
+
import { DownOutlined as x, CloseOutlined as y } from "@ant-design/icons";
|
|
4
4
|
/* empty css */
|
|
5
|
-
import { useStrings as
|
|
6
|
-
function
|
|
7
|
-
value:
|
|
8
|
-
options:
|
|
9
|
-
onChange:
|
|
10
|
-
label:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
import { useStrings as I } from "../../locale/useStrings.js";
|
|
6
|
+
function F({
|
|
7
|
+
value: s,
|
|
8
|
+
options: b,
|
|
9
|
+
onChange: r,
|
|
10
|
+
label: t,
|
|
11
|
+
labelPlacement: h = "above",
|
|
12
|
+
ariaLabel: g,
|
|
13
|
+
placeholder: c,
|
|
14
|
+
allowClear: v = !1,
|
|
15
|
+
disabled: n = !1,
|
|
16
|
+
id: _,
|
|
17
|
+
"aria-describedby": f,
|
|
18
|
+
className: p
|
|
18
19
|
}) {
|
|
19
|
-
const
|
|
20
|
+
const o = I(), N = w(), d = _ ?? N, m = v && s !== "" && !n, S = c !== void 0 && s === "", i = t !== void 0 && h === "inline", u = /* @__PURE__ */ l("label", { className: "aegis-select__label", htmlFor: d, children: [
|
|
21
|
+
t,
|
|
22
|
+
i && /* @__PURE__ */ a("span", { "aria-hidden": !0, children: o.labelSeparator })
|
|
23
|
+
] }), j = [
|
|
20
24
|
"aegis-select",
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
m ? "aegis-select--clearable" : "",
|
|
26
|
+
S ? "aegis-select--placeholder" : "",
|
|
27
|
+
i ? "aegis-select--inline" : "",
|
|
28
|
+
p ?? ""
|
|
24
29
|
].filter(Boolean).join(" ");
|
|
25
|
-
return /* @__PURE__ */
|
|
26
|
-
|
|
27
|
-
/* @__PURE__ */
|
|
28
|
-
|
|
30
|
+
return /* @__PURE__ */ l("div", { className: j, "data-aegis-field": !0, children: [
|
|
31
|
+
t !== void 0 && !i && u,
|
|
32
|
+
/* @__PURE__ */ l("div", { className: "aegis-select__control", children: [
|
|
33
|
+
i && u,
|
|
34
|
+
/* @__PURE__ */ l(
|
|
29
35
|
"select",
|
|
30
36
|
{
|
|
31
37
|
className: "aegis-select__native",
|
|
32
|
-
id:
|
|
33
|
-
value:
|
|
34
|
-
disabled:
|
|
35
|
-
"aria-label":
|
|
36
|
-
"aria-describedby":
|
|
38
|
+
id: d,
|
|
39
|
+
value: s,
|
|
40
|
+
disabled: n,
|
|
41
|
+
"aria-label": g,
|
|
42
|
+
"aria-describedby": f,
|
|
37
43
|
onChange: (e) => {
|
|
38
|
-
|
|
44
|
+
r(e.target.value);
|
|
39
45
|
},
|
|
40
46
|
children: [
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
c !== void 0 && /* @__PURE__ */ a("option", { value: "", disabled: !0, children: c }),
|
|
48
|
+
b.map((e) => /* @__PURE__ */ a(
|
|
43
49
|
"option",
|
|
44
50
|
{
|
|
45
51
|
value: e.value,
|
|
@@ -51,23 +57,23 @@ function P({
|
|
|
51
57
|
]
|
|
52
58
|
}
|
|
53
59
|
),
|
|
54
|
-
/* @__PURE__ */
|
|
55
|
-
|
|
60
|
+
/* @__PURE__ */ a(x, { className: "aegis-select__chevron", "aria-hidden": !0 }),
|
|
61
|
+
m && /* @__PURE__ */ a(
|
|
56
62
|
"button",
|
|
57
63
|
{
|
|
58
64
|
type: "button",
|
|
59
65
|
className: "aegis-select__clear",
|
|
60
|
-
"aria-label":
|
|
66
|
+
"aria-label": o.clearSelection,
|
|
61
67
|
onClick: () => {
|
|
62
|
-
|
|
68
|
+
r("");
|
|
63
69
|
},
|
|
64
|
-
children: /* @__PURE__ */
|
|
70
|
+
children: /* @__PURE__ */ a(y, { "aria-hidden": !0 })
|
|
65
71
|
}
|
|
66
72
|
)
|
|
67
73
|
] })
|
|
68
74
|
] });
|
|
69
75
|
}
|
|
70
76
|
export {
|
|
71
|
-
|
|
77
|
+
F as Select
|
|
72
78
|
};
|
|
73
79
|
//# sourceMappingURL=Select.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","sources":["../../../src/components/ui/Select.tsx"],"sourcesContent":["import { type ReactNode, useId } from 'react';\n\nimport { CloseOutlined, DownOutlined } from '@ant-design/icons';\n\nimport { useStrings } from '../../locale';\nimport './Select.css';\n\nexport interface SelectOption {\n value: string;\n label: string;\n disabled?: boolean;\n}\n\ninterface SelectProps {\n value: string;\n options: SelectOption[];\n onChange: (value: string) => void;\n /** Caption
|
|
1
|
+
{"version":3,"file":"Select.js","sources":["../../../src/components/ui/Select.tsx"],"sourcesContent":["import { type ReactNode, useId } from 'react';\n\nimport { CloseOutlined, DownOutlined } from '@ant-design/icons';\n\nimport { useStrings } from '../../locale';\nimport './Select.css';\n\nexport interface SelectOption {\n value: string;\n label: string;\n disabled?: boolean;\n}\n\ninterface SelectProps {\n value: string;\n options: SelectOption[];\n onChange: (value: string) => void;\n /** Caption of the control, as its `<label>`, so it names the select. */\n label?: ReactNode;\n /**\n * `above` (default) sets the caption over the control. `inline` sets it\n * inside the control before the value, followed by the locale's label\n * separator (\"Run: e3b0aa32\"), for a compact selector in a bar.\n */\n labelPlacement?: 'above' | 'inline';\n /** Accessible name for a select shown without a visible caption, e.g. a compact filter. */\n ariaLabel?: string;\n /** Rendered as a disabled first option when `value` is empty. */\n placeholder?: string;\n /** Shows a clear control once a value is set. */\n allowClear?: boolean;\n disabled?: boolean;\n /** Lets a caller's `<label htmlFor>` point at the control. */\n id?: string;\n /** Ids of the text that describes the select, such as a FormRow's description. */\n 'aria-describedby'?: string;\n className?: string;\n}\n\nexport function Select({\n value,\n options,\n onChange,\n label,\n labelPlacement = 'above',\n ariaLabel,\n placeholder,\n allowClear = false,\n disabled = false,\n id,\n 'aria-describedby': describedBy,\n className,\n}: SelectProps) {\n const strings = useStrings();\n const ownId = useId();\n const selectId = id ?? ownId;\n const clearable = allowClear && value !== '' && !disabled;\n const showsPlaceholder = placeholder !== undefined && value === '';\n const inline = label !== undefined && labelPlacement === 'inline';\n const caption = (\n <label className=\"aegis-select__label\" htmlFor={selectId}>\n {label}\n {inline && <span aria-hidden>{strings.labelSeparator}</span>}\n </label>\n );\n const cls = [\n 'aegis-select',\n clearable ? 'aegis-select--clearable' : '',\n showsPlaceholder ? 'aegis-select--placeholder' : '',\n inline ? 'aegis-select--inline' : '',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n return (\n <div className={cls} data-aegis-field>\n {label !== undefined && !inline && caption}\n <div className=\"aegis-select__control\">\n {inline && caption}\n <select\n className=\"aegis-select__native\"\n id={selectId}\n value={value}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-describedby={describedBy}\n onChange={(event) => {\n onChange(event.target.value);\n }}\n >\n {placeholder !== undefined && (\n <option value=\"\" disabled>\n {placeholder}\n </option>\n )}\n {options.map((option) => (\n <option\n key={option.value}\n value={option.value}\n disabled={option.disabled}\n >\n {option.label}\n </option>\n ))}\n </select>\n <DownOutlined className=\"aegis-select__chevron\" aria-hidden />\n {clearable && (\n <button\n type=\"button\"\n className=\"aegis-select__clear\"\n aria-label={strings.clearSelection}\n onClick={() => {\n onChange('');\n }}\n >\n <CloseOutlined aria-hidden />\n </button>\n )}\n </div>\n </div>\n );\n}\n"],"names":["Select","value","options","onChange","label","labelPlacement","ariaLabel","placeholder","allowClear","disabled","id","describedBy","className","strings","useStrings","ownId","useId","selectId","clearable","showsPlaceholder","inline","caption","jsxs","jsx","cls","event","option","DownOutlined","CloseOutlined"],"mappings":";;;;;AAuCO,SAASA,EAAO;AAAA,EACrB,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,gBAAAC,IAAiB;AAAA,EACjB,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,UAAAC,IAAW;AAAA,EACX,IAAAC;AAAA,EACA,oBAAoBC;AAAA,EACpB,WAAAC;AACF,GAAgB;AACd,QAAMC,IAAUC,EAAA,GACVC,IAAQC,EAAA,GACRC,IAAWP,KAAMK,GACjBG,IAAYV,KAAcP,MAAU,MAAM,CAACQ,GAC3CU,IAAmBZ,MAAgB,UAAaN,MAAU,IAC1DmB,IAAShB,MAAU,UAAaC,MAAmB,UACnDgB,IACJ,gBAAAC,EAAC,SAAA,EAAM,WAAU,uBAAsB,SAASL,GAC7C,UAAA;AAAA,IAAAb;AAAA,IACAgB,KAAU,gBAAAG,EAAC,QAAA,EAAK,eAAW,IAAE,YAAQ,eAAA,CAAe;AAAA,EAAA,GACvD,GAEIC,IAAM;AAAA,IACV;AAAA,IACAN,IAAY,4BAA4B;AAAA,IACxCC,IAAmB,8BAA8B;AAAA,IACjDC,IAAS,yBAAyB;AAAA,IAClCR,KAAa;AAAA,EAAA,EAEZ,OAAO,OAAO,EACd,KAAK,GAAG;AACX,SACE,gBAAAU,EAAC,OAAA,EAA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"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),o=require("react"),C=require("../../lib/format.cjs");;/* empty css */const p=require("./relativeTime.cjs"),y=require("../../locale/useStrings.cjs"),n=t=>String(t).padStart(2,"0");function w(t){const e=Math.floor(t/1e3);return`${String(Math.floor(e/3600))}:${n(Math.floor(e/60)%60)}:${n(e%60)}`}function $(t){return`${String(t.getUTCFullYear())}-${n(t.getUTCMonth()+1)}-${n(t.getUTCDate())} ${n(t.getUTCHours())}:${n(t.getUTCMinutes())}:${n(t.getUTCSeconds())}`}function S(t,e){const i=`${n(t.getUTCHours())}:${n(t.getUTCMinutes())}`;return t.getUTCFullYear()===e.getUTCFullYear()&&t.getUTCMonth()===e.getUTCMonth()&&t.getUTCDate()===e.getUTCDate()?i:`${n(t.getUTCMonth()+1)}-${n(t.getUTCDate())} ${i}`}function m(t){const e=new Date,i=t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate(),a=`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`;return i?a:`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${a}`}function b({value:t,mode:e="absolute",refreshMs:i=6e4,now:a,className:U}){const g=y.useStrings(),r=o.useMemo(()=>{if(t==null||t==="")return null;const l=t instanceof Date?t:new Date(t);return Number.isNaN(l.getTime())?null:l},[t]),[f,h]=o.useState(()=>Date.now());o.useEffect(()=>{if(e!=="relative")return;const l=window.setInterval(()=>{h(Date.now())},i);return()=>{window.clearInterval(l)}},[e,i]);const s=typeof t=="number"?t:r?.getTime(),u=s!==void 0&&Number.isFinite(s),T=o.useMemo(()=>e==="duration"?u?C.formatDuration(s):null:e==="hms"?u?w(s):null:r===null?null:e==="relative"?p.relativeTime(r,g,f):e==="utc"?$(r):e==="utc-day"?S(r,new Date(a??Date.now())):m(r),[r,e,s,u,f,a,g]),M=o.useMemo(()=>{if(e==="duration"||e==="hms")return u?`${String(s)} ms`:void 0;if(!(e==="absolute"||e==="utc"||r===null))return e==="utc-day"?$(r):m(r)},[r,e,s,u]),D=["aegis-time-display",U??""].filter(Boolean).join(" ");return T===null?c.jsxs("span",{className:D,children:[c.jsx("span",{"aria-hidden":"true",children:"—"}),c.jsx("span",{className:"aegis-time-display__no-value",children:g.noValue})]}):c.jsx("span",{className:D,title:M,children:T})}exports.TimeDisplay=b;
|
|
2
2
|
//# sourceMappingURL=TimeDisplay.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeDisplay.cjs","sources":["../../../src/components/ui/TimeDisplay.tsx"],"sourcesContent":["import { useEffect, useMemo, useState } from 'react';\n\nimport { formatDuration } from '../../lib/format';\nimport { useStrings } from '../../locale';\nimport './TimeDisplay.css';\nimport { relativeTime } from './relativeTime';\n\ninterface TimeDisplayProps {\n /**\n * ISO string, timestamp ms, or Date object. An empty or unreadable value\n * shows an em dash, read out as the locale's `noValue`.\n */\n value: string | number | Date | null | undefined;\n /**\n * 'absolute' = full timestamp, 'relative' = \"2m ago\" with the timestamp as\n * its tooltip, 'duration' = elapsed time with the exact milliseconds as its\n * tooltip, 'utc' = `YYYY-MM-DD HH:MM:SS` in UTC, the same text in every\n * time zone and on every day, 'hms' = elapsed time as `H:MM:SS` in whole\n * seconds, the hours neither padded nor capped (`0:00:05`, `27:03:09`),\n * with the exact milliseconds as its tooltip.\n */\n mode?: 'absolute' | 'relative' | 'duration' | 'utc' | 'hms';\n /** For relative mode: refresh interval in ms (default 60 000). */\n refreshMs?: number;\n className?: string;\n}\n\nconst pad = (n: number): string => String(n).padStart(2, '0');\n\nfunction formatHms(ms: number): string {\n const seconds = Math.floor(ms / 1000);\n return `${String(Math.floor(seconds / 3600))}:${pad(Math.floor(seconds / 60) % 60)}:${pad(seconds % 60)}`;\n}\n\nfunction formatUtc(d: Date): string {\n return `${String(d.getUTCFullYear())}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}:${pad(d.getUTCSeconds())}`;\n}\n\nfunction formatAbsolute(d: Date): string {\n const now = new Date();\n const sameDay =\n d.getFullYear() === now.getFullYear() &&\n d.getMonth() === now.getMonth() &&\n d.getDate() === now.getDate();\n\n const time = `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;\n\n if (sameDay) {\n return time;\n }\n return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${time}`;\n}\n\nexport function TimeDisplay({\n value,\n mode = 'absolute',\n refreshMs = 60_000,\n className,\n}: TimeDisplayProps) {\n const strings = useStrings();\n const d = useMemo(() => {\n if (value === null || value === undefined || value === '') {\n return null;\n }\n const date = value instanceof Date ? value : new Date(value);\n return Number.isNaN(date.getTime()) ? null : date;\n }, [value]);\n\n const [now, setNow] = useState(() => Date.now());\n useEffect(() => {\n if (mode !== 'relative') {\n return;\n }\n const id = window.setInterval(() => {\n setNow(Date.now());\n }, refreshMs);\n return () => {\n window.clearInterval(id);\n };\n }, [mode, refreshMs]);\n\n const durationMs = typeof value === 'number' ? value : d?.getTime();\n const hasDuration = durationMs !== undefined && Number.isFinite(durationMs);\n\n const display = useMemo(() => {\n if (mode === 'duration') {\n return hasDuration ? formatDuration(durationMs) : null;\n }\n if (mode === 'hms') {\n return hasDuration ? formatHms(durationMs) : null;\n }\n if (d === null) {\n return null;\n }\n if (mode === 'relative') {\n return relativeTime(d, strings, now);\n }\n if (mode === 'utc') {\n return formatUtc(d);\n }\n return formatAbsolute(d);\n }, [d, mode, durationMs, hasDuration, now, strings]);\n\n const tooltip = useMemo(() => {\n if (mode === 'duration' || mode === 'hms') {\n return hasDuration ? `${String(durationMs)} ms` : undefined;\n }\n if (mode === 'absolute' || mode === 'utc' || d === null) {\n return undefined;\n }\n return formatAbsolute(d);\n }, [d, mode, durationMs, hasDuration]);\n\n const cls = ['aegis-time-display', className ?? ''].filter(Boolean).join(' ');\n\n if (display === null) {\n return (\n <span className={cls}>\n <span aria-hidden=\"true\">—</span>\n <span className=\"aegis-time-display__no-value\">{strings.noValue}</span>\n </span>\n );\n }\n\n return (\n <span className={cls} title={tooltip}>\n {display}\n </span>\n );\n}\n"],"names":["pad","n","formatHms","ms","seconds","formatUtc","d","
|
|
1
|
+
{"version":3,"file":"TimeDisplay.cjs","sources":["../../../src/components/ui/TimeDisplay.tsx"],"sourcesContent":["import { useEffect, useMemo, useState } from 'react';\n\nimport { formatDuration } from '../../lib/format';\nimport { useStrings } from '../../locale';\nimport './TimeDisplay.css';\nimport { relativeTime } from './relativeTime';\n\ninterface TimeDisplayProps {\n /**\n * ISO string, timestamp ms, or Date object. An empty or unreadable value\n * shows an em dash, read out as the locale's `noValue`.\n */\n value: string | number | Date | null | undefined;\n /**\n * 'absolute' = full timestamp, 'relative' = \"2m ago\" with the timestamp as\n * its tooltip, 'duration' = elapsed time with the exact milliseconds as its\n * tooltip, 'utc' = `YYYY-MM-DD HH:MM:SS` in UTC, the same text in every\n * time zone and on every day, 'hms' = elapsed time as `H:MM:SS` in whole\n * seconds, the hours neither padded nor capped (`0:00:05`, `27:03:09`),\n * with the exact milliseconds as its tooltip, 'utc-day' = `HH:MM` in UTC\n * when the moment falls on the same UTC day as `now`, else `MM-DD HH:MM`,\n * with the `utc` text as its tooltip.\n */\n mode?: 'absolute' | 'relative' | 'duration' | 'utc' | 'hms' | 'utc-day';\n /** For relative mode: refresh interval in ms (default 60 000). */\n refreshMs?: number;\n /**\n * For utc-day mode: the moment whose UTC day counts as today, from the\n * host's clock (ISO string, timestamp ms or Date). Defaults to the\n * browser's clock at render.\n */\n now?: string | number | Date;\n className?: string;\n}\n\nconst pad = (n: number): string => String(n).padStart(2, '0');\n\nfunction formatHms(ms: number): string {\n const seconds = Math.floor(ms / 1000);\n return `${String(Math.floor(seconds / 3600))}:${pad(Math.floor(seconds / 60) % 60)}:${pad(seconds % 60)}`;\n}\n\nfunction formatUtc(d: Date): string {\n return `${String(d.getUTCFullYear())}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}:${pad(d.getUTCSeconds())}`;\n}\n\nfunction formatUtcDay(d: Date, now: Date): string {\n const time = `${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}`;\n const sameDay =\n d.getUTCFullYear() === now.getUTCFullYear() &&\n d.getUTCMonth() === now.getUTCMonth() &&\n d.getUTCDate() === now.getUTCDate();\n return sameDay\n ? time\n : `${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ${time}`;\n}\n\nfunction formatAbsolute(d: Date): string {\n const now = new Date();\n const sameDay =\n d.getFullYear() === now.getFullYear() &&\n d.getMonth() === now.getMonth() &&\n d.getDate() === now.getDate();\n\n const time = `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;\n\n if (sameDay) {\n return time;\n }\n return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${time}`;\n}\n\nexport function TimeDisplay({\n value,\n mode = 'absolute',\n refreshMs = 60_000,\n now: today,\n className,\n}: TimeDisplayProps) {\n const strings = useStrings();\n const d = useMemo(() => {\n if (value === null || value === undefined || value === '') {\n return null;\n }\n const date = value instanceof Date ? value : new Date(value);\n return Number.isNaN(date.getTime()) ? null : date;\n }, [value]);\n\n const [now, setNow] = useState(() => Date.now());\n useEffect(() => {\n if (mode !== 'relative') {\n return;\n }\n const id = window.setInterval(() => {\n setNow(Date.now());\n }, refreshMs);\n return () => {\n window.clearInterval(id);\n };\n }, [mode, refreshMs]);\n\n const durationMs = typeof value === 'number' ? value : d?.getTime();\n const hasDuration = durationMs !== undefined && Number.isFinite(durationMs);\n\n const display = useMemo(() => {\n if (mode === 'duration') {\n return hasDuration ? formatDuration(durationMs) : null;\n }\n if (mode === 'hms') {\n return hasDuration ? formatHms(durationMs) : null;\n }\n if (d === null) {\n return null;\n }\n if (mode === 'relative') {\n return relativeTime(d, strings, now);\n }\n if (mode === 'utc') {\n return formatUtc(d);\n }\n if (mode === 'utc-day') {\n return formatUtcDay(d, new Date(today ?? Date.now()));\n }\n return formatAbsolute(d);\n }, [d, mode, durationMs, hasDuration, now, today, strings]);\n\n const tooltip = useMemo(() => {\n if (mode === 'duration' || mode === 'hms') {\n return hasDuration ? `${String(durationMs)} ms` : undefined;\n }\n if (mode === 'absolute' || mode === 'utc' || d === null) {\n return undefined;\n }\n if (mode === 'utc-day') {\n return formatUtc(d);\n }\n return formatAbsolute(d);\n }, [d, mode, durationMs, hasDuration]);\n\n const cls = ['aegis-time-display', className ?? ''].filter(Boolean).join(' ');\n\n if (display === null) {\n return (\n <span className={cls}>\n <span aria-hidden=\"true\">—</span>\n <span className=\"aegis-time-display__no-value\">{strings.noValue}</span>\n </span>\n );\n }\n\n return (\n <span className={cls} title={tooltip}>\n {display}\n </span>\n );\n}\n"],"names":["pad","n","formatHms","ms","seconds","formatUtc","d","formatUtcDay","now","time","formatAbsolute","sameDay","TimeDisplay","value","mode","refreshMs","today","className","strings","useStrings","useMemo","date","setNow","useState","useEffect","id","durationMs","hasDuration","display","formatDuration","relativeTime","tooltip","cls","jsxs","jsx"],"mappings":"0RAmCMA,EAAOC,GAAsB,OAAOA,CAAC,EAAE,SAAS,EAAG,GAAG,EAE5D,SAASC,EAAUC,EAAoB,CACrC,MAAMC,EAAU,KAAK,MAAMD,EAAK,GAAI,EACpC,MAAO,GAAG,OAAO,KAAK,MAAMC,EAAU,IAAI,CAAC,CAAC,IAAIJ,EAAI,KAAK,MAAMI,EAAU,EAAE,EAAI,EAAE,CAAC,IAAIJ,EAAII,EAAU,EAAE,CAAC,EACzG,CAEA,SAASC,EAAUC,EAAiB,CAClC,MAAO,GAAG,OAAOA,EAAE,eAAA,CAAgB,CAAC,IAAIN,EAAIM,EAAE,YAAA,EAAgB,CAAC,CAAC,IAAIN,EAAIM,EAAE,WAAA,CAAY,CAAC,IAAIN,EAAIM,EAAE,YAAA,CAAa,CAAC,IAAIN,E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,CAAAE,EAAAA,IAAC,OAAA,CAAK,cAAY,OAAO,SAAA,IAAC,EAC1BA,EAAAA,IAAC,OAAA,CAAK,UAAU,+BAAgC,WAAQ,OAAA,CAAQ,CAAA,EAClE,QAKD,OAAA,CAAK,UAAWF,EAAK,MAAOD,EAC1B,SAAAH,EACH,CAEJ"}
|
|
@@ -10,12 +10,20 @@ interface TimeDisplayProps {
|
|
|
10
10
|
* tooltip, 'utc' = `YYYY-MM-DD HH:MM:SS` in UTC, the same text in every
|
|
11
11
|
* time zone and on every day, 'hms' = elapsed time as `H:MM:SS` in whole
|
|
12
12
|
* seconds, the hours neither padded nor capped (`0:00:05`, `27:03:09`),
|
|
13
|
-
* with the exact milliseconds as its tooltip
|
|
13
|
+
* with the exact milliseconds as its tooltip, 'utc-day' = `HH:MM` in UTC
|
|
14
|
+
* when the moment falls on the same UTC day as `now`, else `MM-DD HH:MM`,
|
|
15
|
+
* with the `utc` text as its tooltip.
|
|
14
16
|
*/
|
|
15
|
-
mode?: 'absolute' | 'relative' | 'duration' | 'utc' | 'hms';
|
|
17
|
+
mode?: 'absolute' | 'relative' | 'duration' | 'utc' | 'hms' | 'utc-day';
|
|
16
18
|
/** For relative mode: refresh interval in ms (default 60 000). */
|
|
17
19
|
refreshMs?: number;
|
|
20
|
+
/**
|
|
21
|
+
* For utc-day mode: the moment whose UTC day counts as today, from the
|
|
22
|
+
* host's clock (ISO string, timestamp ms or Date). Defaults to the
|
|
23
|
+
* browser's clock at render.
|
|
24
|
+
*/
|
|
25
|
+
now?: string | number | Date;
|
|
18
26
|
className?: string;
|
|
19
27
|
}
|
|
20
|
-
export declare function TimeDisplay({ value, mode, refreshMs, className, }: TimeDisplayProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare function TimeDisplay({ value, mode, refreshMs, now: today, className, }: TimeDisplayProps): import("react/jsx-runtime").JSX.Element;
|
|
21
29
|
export {};
|
|
@@ -1,55 +1,60 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { formatDuration as
|
|
1
|
+
import { jsxs as C, jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as g, useState as M, useEffect as w } from "react";
|
|
3
|
+
import { formatDuration as y } from "../../lib/format.js";
|
|
4
4
|
/* empty css */
|
|
5
|
-
import { relativeTime as
|
|
6
|
-
import { useStrings as
|
|
7
|
-
const
|
|
8
|
-
function
|
|
9
|
-
const
|
|
10
|
-
return `${String(Math.floor(
|
|
5
|
+
import { relativeTime as S } from "./relativeTime.js";
|
|
6
|
+
import { useStrings as N } from "../../locale/useStrings.js";
|
|
7
|
+
const n = (t) => String(t).padStart(2, "0");
|
|
8
|
+
function F(t) {
|
|
9
|
+
const e = Math.floor(t / 1e3);
|
|
10
|
+
return `${String(Math.floor(e / 3600))}:${n(Math.floor(e / 60) % 60)}:${n(e % 60)}`;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
return `${String(t.getUTCFullYear())}-${
|
|
12
|
+
function D(t) {
|
|
13
|
+
return `${String(t.getUTCFullYear())}-${n(t.getUTCMonth() + 1)}-${n(t.getUTCDate())} ${n(t.getUTCHours())}:${n(t.getUTCMinutes())}:${n(t.getUTCSeconds())}`;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
const
|
|
17
|
-
return
|
|
15
|
+
function b(t, e) {
|
|
16
|
+
const i = `${n(t.getUTCHours())}:${n(t.getUTCMinutes())}`;
|
|
17
|
+
return t.getUTCFullYear() === e.getUTCFullYear() && t.getUTCMonth() === e.getUTCMonth() && t.getUTCDate() === e.getUTCDate() ? i : `${n(t.getUTCMonth() + 1)}-${n(t.getUTCDate())} ${i}`;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function T(t) {
|
|
20
|
+
const e = /* @__PURE__ */ new Date(), i = t.getFullYear() === e.getFullYear() && t.getMonth() === e.getMonth() && t.getDate() === e.getDate(), a = `${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`;
|
|
21
|
+
return i ? a : `${t.getFullYear()}-${n(t.getMonth() + 1)}-${n(t.getDate())} ${a}`;
|
|
22
|
+
}
|
|
23
|
+
function _({
|
|
20
24
|
value: t,
|
|
21
|
-
mode:
|
|
22
|
-
refreshMs:
|
|
23
|
-
|
|
25
|
+
mode: e = "absolute",
|
|
26
|
+
refreshMs: i = 6e4,
|
|
27
|
+
now: a,
|
|
28
|
+
className: p
|
|
24
29
|
}) {
|
|
25
|
-
const l =
|
|
30
|
+
const l = N(), r = g(() => {
|
|
26
31
|
if (t == null || t === "")
|
|
27
32
|
return null;
|
|
28
33
|
const u = t instanceof Date ? t : new Date(t);
|
|
29
34
|
return Number.isNaN(u.getTime()) ? null : u;
|
|
30
|
-
}, [t]), [
|
|
31
|
-
|
|
32
|
-
if (
|
|
35
|
+
}, [t]), [f, U] = M(() => Date.now());
|
|
36
|
+
w(() => {
|
|
37
|
+
if (e !== "relative")
|
|
33
38
|
return;
|
|
34
39
|
const u = window.setInterval(() => {
|
|
35
|
-
|
|
36
|
-
},
|
|
40
|
+
U(Date.now());
|
|
41
|
+
}, i);
|
|
37
42
|
return () => {
|
|
38
43
|
window.clearInterval(u);
|
|
39
44
|
};
|
|
40
|
-
}, [
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
return
|
|
44
|
-
if (!(
|
|
45
|
-
return
|
|
46
|
-
}, [r,
|
|
47
|
-
return m === null ? /* @__PURE__ */
|
|
45
|
+
}, [e, i]);
|
|
46
|
+
const o = typeof t == "number" ? t : r?.getTime(), s = o !== void 0 && Number.isFinite(o), m = g(() => e === "duration" ? s ? y(o) : null : e === "hms" ? s ? F(o) : null : r === null ? null : e === "relative" ? S(r, l, f) : e === "utc" ? D(r) : e === "utc-day" ? b(r, new Date(a ?? Date.now())) : T(r), [r, e, o, s, f, a, l]), h = g(() => {
|
|
47
|
+
if (e === "duration" || e === "hms")
|
|
48
|
+
return s ? `${String(o)} ms` : void 0;
|
|
49
|
+
if (!(e === "absolute" || e === "utc" || r === null))
|
|
50
|
+
return e === "utc-day" ? D(r) : T(r);
|
|
51
|
+
}, [r, e, o, s]), $ = ["aegis-time-display", p ?? ""].filter(Boolean).join(" ");
|
|
52
|
+
return m === null ? /* @__PURE__ */ C("span", { className: $, children: [
|
|
48
53
|
/* @__PURE__ */ c("span", { "aria-hidden": "true", children: "—" }),
|
|
49
54
|
/* @__PURE__ */ c("span", { className: "aegis-time-display__no-value", children: l.noValue })
|
|
50
|
-
] }) : /* @__PURE__ */ c("span", { className:
|
|
55
|
+
] }) : /* @__PURE__ */ c("span", { className: $, title: h, children: m });
|
|
51
56
|
}
|
|
52
57
|
export {
|
|
53
|
-
|
|
58
|
+
_ as TimeDisplay
|
|
54
59
|
};
|
|
55
60
|
//# sourceMappingURL=TimeDisplay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeDisplay.js","sources":["../../../src/components/ui/TimeDisplay.tsx"],"sourcesContent":["import { useEffect, useMemo, useState } from 'react';\n\nimport { formatDuration } from '../../lib/format';\nimport { useStrings } from '../../locale';\nimport './TimeDisplay.css';\nimport { relativeTime } from './relativeTime';\n\ninterface TimeDisplayProps {\n /**\n * ISO string, timestamp ms, or Date object. An empty or unreadable value\n * shows an em dash, read out as the locale's `noValue`.\n */\n value: string | number | Date | null | undefined;\n /**\n * 'absolute' = full timestamp, 'relative' = \"2m ago\" with the timestamp as\n * its tooltip, 'duration' = elapsed time with the exact milliseconds as its\n * tooltip, 'utc' = `YYYY-MM-DD HH:MM:SS` in UTC, the same text in every\n * time zone and on every day, 'hms' = elapsed time as `H:MM:SS` in whole\n * seconds, the hours neither padded nor capped (`0:00:05`, `27:03:09`),\n * with the exact milliseconds as its tooltip.\n */\n mode?: 'absolute' | 'relative' | 'duration' | 'utc' | 'hms';\n /** For relative mode: refresh interval in ms (default 60 000). */\n refreshMs?: number;\n className?: string;\n}\n\nconst pad = (n: number): string => String(n).padStart(2, '0');\n\nfunction formatHms(ms: number): string {\n const seconds = Math.floor(ms / 1000);\n return `${String(Math.floor(seconds / 3600))}:${pad(Math.floor(seconds / 60) % 60)}:${pad(seconds % 60)}`;\n}\n\nfunction formatUtc(d: Date): string {\n return `${String(d.getUTCFullYear())}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}:${pad(d.getUTCSeconds())}`;\n}\n\nfunction formatAbsolute(d: Date): string {\n const now = new Date();\n const sameDay =\n d.getFullYear() === now.getFullYear() &&\n d.getMonth() === now.getMonth() &&\n d.getDate() === now.getDate();\n\n const time = `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;\n\n if (sameDay) {\n return time;\n }\n return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${time}`;\n}\n\nexport function TimeDisplay({\n value,\n mode = 'absolute',\n refreshMs = 60_000,\n className,\n}: TimeDisplayProps) {\n const strings = useStrings();\n const d = useMemo(() => {\n if (value === null || value === undefined || value === '') {\n return null;\n }\n const date = value instanceof Date ? value : new Date(value);\n return Number.isNaN(date.getTime()) ? null : date;\n }, [value]);\n\n const [now, setNow] = useState(() => Date.now());\n useEffect(() => {\n if (mode !== 'relative') {\n return;\n }\n const id = window.setInterval(() => {\n setNow(Date.now());\n }, refreshMs);\n return () => {\n window.clearInterval(id);\n };\n }, [mode, refreshMs]);\n\n const durationMs = typeof value === 'number' ? value : d?.getTime();\n const hasDuration = durationMs !== undefined && Number.isFinite(durationMs);\n\n const display = useMemo(() => {\n if (mode === 'duration') {\n return hasDuration ? formatDuration(durationMs) : null;\n }\n if (mode === 'hms') {\n return hasDuration ? formatHms(durationMs) : null;\n }\n if (d === null) {\n return null;\n }\n if (mode === 'relative') {\n return relativeTime(d, strings, now);\n }\n if (mode === 'utc') {\n return formatUtc(d);\n }\n return formatAbsolute(d);\n }, [d, mode, durationMs, hasDuration, now, strings]);\n\n const tooltip = useMemo(() => {\n if (mode === 'duration' || mode === 'hms') {\n return hasDuration ? `${String(durationMs)} ms` : undefined;\n }\n if (mode === 'absolute' || mode === 'utc' || d === null) {\n return undefined;\n }\n return formatAbsolute(d);\n }, [d, mode, durationMs, hasDuration]);\n\n const cls = ['aegis-time-display', className ?? ''].filter(Boolean).join(' ');\n\n if (display === null) {\n return (\n <span className={cls}>\n <span aria-hidden=\"true\">—</span>\n <span className=\"aegis-time-display__no-value\">{strings.noValue}</span>\n </span>\n );\n }\n\n return (\n <span className={cls} title={tooltip}>\n {display}\n </span>\n );\n}\n"],"names":["pad","n","formatHms","ms","seconds","formatUtc","d","
|
|
1
|
+
{"version":3,"file":"TimeDisplay.js","sources":["../../../src/components/ui/TimeDisplay.tsx"],"sourcesContent":["import { useEffect, useMemo, useState } from 'react';\n\nimport { formatDuration } from '../../lib/format';\nimport { useStrings } from '../../locale';\nimport './TimeDisplay.css';\nimport { relativeTime } from './relativeTime';\n\ninterface TimeDisplayProps {\n /**\n * ISO string, timestamp ms, or Date object. An empty or unreadable value\n * shows an em dash, read out as the locale's `noValue`.\n */\n value: string | number | Date | null | undefined;\n /**\n * 'absolute' = full timestamp, 'relative' = \"2m ago\" with the timestamp as\n * its tooltip, 'duration' = elapsed time with the exact milliseconds as its\n * tooltip, 'utc' = `YYYY-MM-DD HH:MM:SS` in UTC, the same text in every\n * time zone and on every day, 'hms' = elapsed time as `H:MM:SS` in whole\n * seconds, the hours neither padded nor capped (`0:00:05`, `27:03:09`),\n * with the exact milliseconds as its tooltip, 'utc-day' = `HH:MM` in UTC\n * when the moment falls on the same UTC day as `now`, else `MM-DD HH:MM`,\n * with the `utc` text as its tooltip.\n */\n mode?: 'absolute' | 'relative' | 'duration' | 'utc' | 'hms' | 'utc-day';\n /** For relative mode: refresh interval in ms (default 60 000). */\n refreshMs?: number;\n /**\n * For utc-day mode: the moment whose UTC day counts as today, from the\n * host's clock (ISO string, timestamp ms or Date). Defaults to the\n * browser's clock at render.\n */\n now?: string | number | Date;\n className?: string;\n}\n\nconst pad = (n: number): string => String(n).padStart(2, '0');\n\nfunction formatHms(ms: number): string {\n const seconds = Math.floor(ms / 1000);\n return `${String(Math.floor(seconds / 3600))}:${pad(Math.floor(seconds / 60) % 60)}:${pad(seconds % 60)}`;\n}\n\nfunction formatUtc(d: Date): string {\n return `${String(d.getUTCFullYear())}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}:${pad(d.getUTCSeconds())}`;\n}\n\nfunction formatUtcDay(d: Date, now: Date): string {\n const time = `${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}`;\n const sameDay =\n d.getUTCFullYear() === now.getUTCFullYear() &&\n d.getUTCMonth() === now.getUTCMonth() &&\n d.getUTCDate() === now.getUTCDate();\n return sameDay\n ? time\n : `${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ${time}`;\n}\n\nfunction formatAbsolute(d: Date): string {\n const now = new Date();\n const sameDay =\n d.getFullYear() === now.getFullYear() &&\n d.getMonth() === now.getMonth() &&\n d.getDate() === now.getDate();\n\n const time = `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;\n\n if (sameDay) {\n return time;\n }\n return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${time}`;\n}\n\nexport function TimeDisplay({\n value,\n mode = 'absolute',\n refreshMs = 60_000,\n now: today,\n className,\n}: TimeDisplayProps) {\n const strings = useStrings();\n const d = useMemo(() => {\n if (value === null || value === undefined || value === '') {\n return null;\n }\n const date = value instanceof Date ? value : new Date(value);\n return Number.isNaN(date.getTime()) ? null : date;\n }, [value]);\n\n const [now, setNow] = useState(() => Date.now());\n useEffect(() => {\n if (mode !== 'relative') {\n return;\n }\n const id = window.setInterval(() => {\n setNow(Date.now());\n }, refreshMs);\n return () => {\n window.clearInterval(id);\n };\n }, [mode, refreshMs]);\n\n const durationMs = typeof value === 'number' ? value : d?.getTime();\n const hasDuration = durationMs !== undefined && Number.isFinite(durationMs);\n\n const display = useMemo(() => {\n if (mode === 'duration') {\n return hasDuration ? formatDuration(durationMs) : null;\n }\n if (mode === 'hms') {\n return hasDuration ? formatHms(durationMs) : null;\n }\n if (d === null) {\n return null;\n }\n if (mode === 'relative') {\n return relativeTime(d, strings, now);\n }\n if (mode === 'utc') {\n return formatUtc(d);\n }\n if (mode === 'utc-day') {\n return formatUtcDay(d, new Date(today ?? Date.now()));\n }\n return formatAbsolute(d);\n }, [d, mode, durationMs, hasDuration, now, today, strings]);\n\n const tooltip = useMemo(() => {\n if (mode === 'duration' || mode === 'hms') {\n return hasDuration ? `${String(durationMs)} ms` : undefined;\n }\n if (mode === 'absolute' || mode === 'utc' || d === null) {\n return undefined;\n }\n if (mode === 'utc-day') {\n return formatUtc(d);\n }\n return formatAbsolute(d);\n }, [d, mode, durationMs, hasDuration]);\n\n const cls = ['aegis-time-display', className ?? ''].filter(Boolean).join(' ');\n\n if (display === null) {\n return (\n <span className={cls}>\n <span aria-hidden=\"true\">—</span>\n <span className=\"aegis-time-display__no-value\">{strings.noValue}</span>\n </span>\n );\n }\n\n return (\n <span className={cls} title={tooltip}>\n {display}\n </span>\n );\n}\n"],"names":["pad","n","formatHms","ms","seconds","formatUtc","d","formatUtcDay","now","time","formatAbsolute","sameDay","TimeDisplay","value","mode","refreshMs","today","className","strings","useStrings","useMemo","date","setNow","useState","useEffect","id","durationMs","hasDuration","display","formatDuration","relativeTime","tooltip","cls","jsxs","jsx"],"mappings":";;;;;;AAmCA,MAAMA,IAAM,CAACC,MAAsB,OAAOA,CAAC,EAAE,SAAS,GAAG,GAAG;AAE5D,SAASC,EAAUC,GAAoB;AACrC,QAAMC,IAAU,KAAK,MAAMD,IAAK,GAAI;AACpC,SAAO,GAAG,OAAO,KAAK,MAAMC,IAAU,IAAI,CAAC,CAAC,IAAIJ,EAAI,KAAK,MAAMI,IAAU,EAAE,IAAI,EAAE,CAAC,IAAIJ,EAAII,IAAU,EAAE,CAAC;AACzG;AAEA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,CAAC,IAEbI,EAAeJ,CAAC;AAAA,EACzB,GAAG,CAACA,GAAGQ,GAAMY,GAAYC,CAAW,CAAC,GAE/BK,IAAM,CAAC,sBAAsBf,KAAa,EAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAE5E,SAAIW,MAAY,OAEZ,gBAAAK,EAAC,QAAA,EAAK,WAAWD,GACf,UAAA;AAAA,IAAA,gBAAAE,EAAC,QAAA,EAAK,eAAY,QAAO,UAAA,KAAC;AAAA,IAC1B,gBAAAA,EAAC,QAAA,EAAK,WAAU,gCAAgC,YAAQ,QAAA,CAAQ;AAAA,EAAA,GAClE,sBAKD,QAAA,EAAK,WAAWF,GAAK,OAAOD,GAC1B,UAAAH,GACH;AAEJ;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),f=require("react"),E=require("../../agent/core/usePrimitiveSurface.cjs");;/* empty css */const F=require("./linkComponent.cjs");function L({items:s,variant:j="dot",density:v="comfortable",mode:x="listbox",selectedId:r,onSelect:d,linkComponent:k,scrollable:N=!1,ariaLabel:y,className:w,style:C,surface:S}){const a=f.useRef(null),T=E.usePrimitiveSurface(S,s,"timeline",a),[q,_]=f.useState(void 0),u=j==="numbered",b=v==="compact",o=x==="list",c=!o&&d!==void 0,I=k??F.DefaultLink,D=["aegis-timeline",u?"aegis-timeline--numbered":"",b?"aegis-timeline--compact":"",c?"aegis-timeline--selectable":"",o?"aegis-timeline--list":"",N?"aegis-timeline--scrollable":"",w??""].filter(Boolean).join(" "),R=s.findIndex(e=>e.id===r),h=s.findIndex(e=>e.id===q),A=h>=0?h:Math.max(R,0);f.useLayoutEffect(()=>{const e=a.current,t=e?.querySelector(":scope > .aegis-timeline__item--selected");if(!e||!t)return;const n=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop,l=n+t.offsetHeight;n<e.scrollTop?e.scrollTop=n:l>e.scrollTop+e.clientHeight&&(e.scrollTop=l-e.clientHeight)},[r]);const m=e=>{e<0||e>=s.length||(_(s[e].id),a.current?.querySelectorAll(':scope > [role="option"]')[e]?.focus())},B=(e,t)=>{switch(e.key){case"ArrowDown":m(t+1);break;case"ArrowUp":m(t-1);break;case"Home":m(0);break;case"End":m(s.length-1);break;case"Enter":case" ":d?.(s[t]);break;default:return}e.preventDefault()};return i.jsx("ol",{ref:a,className:D,style:C,role:c?"listbox":o?"list":void 0,"aria-label":y,...T,children:s.map((e,t)=>{const n=e.id===r,l=o?e.href:void 0,g=["aegis-timeline__item",u?"aegis-timeline__item--numbered":"",(c||o)&&n?"aegis-timeline__item--selected":"",l!==void 0?"aegis-timeline__item--link":""].filter(Boolean).join(" "),p=i.jsxs(i.Fragment,{children:[u?i.jsx("span",{className:"aegis-timeline__marker",children:e.marker??String(t+1).padStart(2,"0")}):i.jsx("span",{className:"aegis-timeline__dot",style:e.dotColor?{background:e.dotColor}:void 0}),i.jsxs("div",{className:"aegis-timeline__body",children:[i.jsxs("div",{className:"aegis-timeline__row",children:[i.jsx("span",{className:"aegis-timeline__title",title:b&&typeof e.title=="string"?e.title:void 0,children:l!==void 0?i.jsx(I,{to:l,className:"aegis-timeline__link","aria-current":n?"true":void 0,children:e.title}):e.title}),e.meta?i.jsx("span",{className:"aegis-timeline__meta",children:e.meta}):null]}),e.description?i.jsx("div",{className:"aegis-timeline__desc",children:e.description}):null,e.timestamp?i.jsx("div",{className:"aegis-timeline__time",children:e.timestamp}):null]})]});return o?i.jsx("li",{className:g,"aria-current":n&&l===void 0?"true":void 0,children:p},e.id):c?i.jsx("li",{className:g,role:"option","aria-selected":e.id===r,tabIndex:t===A?0:-1,onClick:()=>{d(e)},onKeyDown:H=>{B(H,t)},onFocus:()=>{_(e.id)},children:p},e.id):i.jsx("li",{className:g,children:p},e.id)})})}exports.Timeline=L;
|
|
2
2
|
//# sourceMappingURL=Timeline.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Timeline.cjs","sources":["../../../src/components/ui/Timeline.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type ReactNode,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport {\n type PrimitiveSurface,\n usePrimitiveSurface,\n} from '../../agent/core/usePrimitiveSurface';\nimport './Timeline.css';\n\nexport interface TimelineItem {\n id: string;\n /** Headline — actor / event / verb, e.g. \"alice@aegis updated `db.dsn`\". */\n title: ReactNode;\n /** Body — optional secondary line. */\n description?: ReactNode;\n /** Absolute timestamp, in the numeric face. */\n timestamp?: ReactNode;\n /** Slot at the end of the title row, in the numeric face (e.g. a revision). */\n meta?: ReactNode;\n /** CSS colour for the dot, e.g. `var(--accent-success)`. */\n dotColor?: string;\n /**\n * Leading label in the `numbered` variant, e.g. a step number.\n * Defaults to the 1-based position, zero-padded to two digits.\n */\n marker?: ReactNode;\n}\n\nexport type TimelineSurface = PrimitiveSurface<TimelineItem[]>;\n\ninterface TimelineProps {\n items: TimelineItem[];\n /**\n * `numbered` replaces the dot and connector with a leading marker\n * column, separates rows with hairlines and keeps the line breaks of\n * each description.\n */\n variant?: 'dot' | 'numbered';\n /**\n * `compact` keeps each title on one line with an ellipsis (a string title\n * shows in full on hover) and tightens the rows.\n */\n density?: 'comfortable' | 'compact';\n /**\n * The selected item, drawn inverted when `onSelect` is set. With `onSelect` the list is a\n * listbox: each item is an option, clicked or chosen with Enter or Space,\n * and ↑ ↓ Home End move between them from one tab stop.\n */\n selectedId?: string;\n onSelect?: (item: TimelineItem) => void;\n /**\n * Bounds the list to `--timeline-scroll-max-height` and scrolls it. The\n * list scrolls itself, never the page, to keep the selected item in view\n * when it mounts and when `selectedId` changes.\n */\n scrollable?: boolean;\n /** The list's accessible name; name a selectable list. */\n ariaLabel?: string;\n className?: string;\n style?: CSSProperties;\n surface?: TimelineSurface;\n}\n\nexport function Timeline({\n items,\n variant = 'dot',\n density = 'comfortable',\n selectedId,\n onSelect,\n scrollable = false,\n ariaLabel,\n className,\n style,\n surface,\n}: TimelineProps) {\n const wrapRef = useRef<HTMLOListElement>(null);\n const agentAttrs = usePrimitiveSurface(surface, items, 'timeline', wrapRef);\n const [focusedId, setFocusedId] = useState<string | undefined>(undefined);\n const numbered = variant === 'numbered';\n const compact = density === 'compact';\n const selectable = onSelect !== undefined;\n const rootClass = [\n 'aegis-timeline',\n numbered ? 'aegis-timeline--numbered' : '',\n compact ? 'aegis-timeline--compact' : '',\n selectable ? 'aegis-timeline--selectable' : '',\n scrollable ? 'aegis-timeline--scrollable' : '',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n\n const selectedIndex = items.findIndex((it) => it.id === selectedId);\n const focusedIndex = items.findIndex((it) => it.id === focusedId);\n const tabStopIndex =\n focusedIndex >= 0 ? focusedIndex : Math.max(selectedIndex, 0);\n\n useLayoutEffect(() => {\n const list = wrapRef.current;\n const item = list?.querySelector<HTMLElement>(\n ':scope > .aegis-timeline__item--selected',\n );\n if (!list || !item) {\n return;\n }\n const top =\n item.getBoundingClientRect().top -\n list.getBoundingClientRect().top +\n list.scrollTop;\n const bottom = top + item.offsetHeight;\n if (top < list.scrollTop) {\n list.scrollTop = top;\n } else if (bottom > list.scrollTop + list.clientHeight) {\n list.scrollTop = bottom - list.clientHeight;\n }\n }, [selectedId]);\n\n const focusItem = (index: number): void => {\n if (index < 0 || index >= items.length) {\n return;\n }\n setFocusedId(items[index].id);\n wrapRef.current\n ?.querySelectorAll<HTMLElement>(':scope > [role=\"option\"]')\n [index]?.focus();\n };\n\n const handleKeyDown = (\n event: KeyboardEvent<HTMLLIElement>,\n index: number,\n ): void => {\n switch (event.key) {\n case 'ArrowDown':\n focusItem(index + 1);\n break;\n case 'ArrowUp':\n focusItem(index - 1);\n break;\n case 'Home':\n focusItem(0);\n break;\n case 'End':\n focusItem(items.length - 1);\n break;\n case 'Enter':\n case ' ':\n onSelect?.(items[index]);\n break;\n default:\n return;\n }\n event.preventDefault();\n };\n\n return (\n <ol\n ref={wrapRef}\n className={rootClass}\n style={style}\n role={selectable ? 'listbox' : undefined}\n aria-label={ariaLabel}\n {...agentAttrs}\n >\n {items.map((it, index) => {\n const className = [\n 'aegis-timeline__item',\n numbered ? 'aegis-timeline__item--numbered' : '',\n selectable && it.id === selectedId\n ? 'aegis-timeline__item--selected'\n : '',\n ]\n .filter(Boolean)\n .join(' ');\n const content = (\n <>\n {numbered ? (\n <span className=\"aegis-timeline__marker\">\n {it.marker ?? String(index + 1).padStart(2, '0')}\n </span>\n ) : (\n <span\n className=\"aegis-timeline__dot\"\n style={it.dotColor ? { background: it.dotColor } : undefined}\n />\n )}\n <div className=\"aegis-timeline__body\">\n <div className=\"aegis-timeline__row\">\n <span\n className=\"aegis-timeline__title\"\n title={\n compact && typeof it.title === 'string'\n ? it.title\n : undefined\n }\n >\n {it.title}\n </span>\n {it.meta ? (\n <span className=\"aegis-timeline__meta\">{it.meta}</span>\n ) : null}\n </div>\n {it.description ? (\n <div className=\"aegis-timeline__desc\">{it.description}</div>\n ) : null}\n {it.timestamp ? (\n <div className=\"aegis-timeline__time\">{it.timestamp}</div>\n ) : null}\n </div>\n </>\n );\n if (!selectable) {\n return (\n <li key={it.id} className={className}>\n {content}\n </li>\n );\n }\n return (\n <li\n key={it.id}\n className={className}\n role=\"option\"\n aria-selected={it.id === selectedId}\n tabIndex={index === tabStopIndex ? 0 : -1}\n onClick={() => {\n onSelect(it);\n }}\n onKeyDown={(event) => {\n handleKeyDown(event, index);\n }}\n onFocus={() => {\n setFocusedId(it.id);\n }}\n >\n {content}\n </li>\n );\n })}\n </ol>\n );\n}\n"],"names":["Timeline","items","variant","density","selectedId","onSelect","scrollable","ariaLabel","className","style","surface","wrapRef","useRef","agentAttrs","usePrimitiveSurface","focusedId","setFocusedId","useState","numbered","compact","selectable","rootClass","selectedIndex","it","focusedIndex","tabStopIndex","useLayoutEffect","list","item","top","bottom","focusIt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Y,MAAC,OAAA,CAAK,UAAU,uBAAwB,SAAAZ,EAAG,KAAK,EAC9C,IAAA,EACN,EACCA,EAAG,YACFY,MAAC,MAAA,CAAI,UAAU,uBAAwB,SAAAZ,EAAG,YAAY,EACpD,KACHA,EAAG,UACFY,MAAC,MAAA,CAAI,UAAU,uBAAwB,SAAAZ,EAAG,UAAU,EAClD,IAAA,CAAA,CACN,CAAA,EACF,EAEF,OAAKH,EAQHe,EAAAA,IAAC,KAAA,CAEC,UAAW3B,EACX,KAAK,SACL,gBAAee,EAAG,KAAOnB,EACzB,SAAU4B,IAAUP,EAAe,EAAI,GACvC,QAAS,IAAM,CACbpB,EAASkB,CAAE,CACb,EACA,UAAYW,GAAU,CACpBD,EAAcC,EAAOF,CAAK,CAC5B,EACA,QAAS,IAAM,CACbhB,EAAaO,EAAG,EAAE,CACpB,EAEC,SAAAa,CAAA,EAfIb,EAAG,EAAA,QAPP,KAAA,CAAe,UAAWf,EACxB,SAAA4B,CAAA,EADMb,EAAG,EAEZ,CAuBN,CAAC,CAAA,CAAA,CAGP"}
|
|
1
|
+
{"version":3,"file":"Timeline.cjs","sources":["../../../src/components/ui/Timeline.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type ReactNode,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport {\n type PrimitiveSurface,\n usePrimitiveSurface,\n} from '../../agent/core/usePrimitiveSurface';\nimport './Timeline.css';\nimport { DefaultLink, type LinkComponent } from './linkComponent';\n\nexport interface TimelineItem {\n id: string;\n /** Headline — actor / event / verb, e.g. \"alice@aegis updated `db.dsn`\". */\n title: ReactNode;\n /** Body — optional secondary line. */\n description?: ReactNode;\n /** Absolute timestamp, in the numeric face. */\n timestamp?: ReactNode;\n /** Slot at the end of the title row, in the numeric face (e.g. a revision). */\n meta?: ReactNode;\n /** CSS colour for the dot, e.g. `var(--accent-success)`. */\n dotColor?: string;\n /**\n * Leading label in the `numbered` variant, e.g. a step number.\n * Defaults to the 1-based position, zero-padded to two digits.\n */\n marker?: ReactNode;\n /** In the `list` mode, makes the item a link to this destination. */\n href?: string;\n}\n\nexport type TimelineSurface = PrimitiveSurface<TimelineItem[]>;\n\ninterface TimelineProps {\n items: TimelineItem[];\n /**\n * `numbered` replaces the dot and connector with a leading marker\n * column, separates rows with hairlines and keeps the line breaks of\n * each description.\n */\n variant?: 'dot' | 'numbered';\n /**\n * `compact` keeps each title on one line with an ellipsis (a string title\n * shows in full on hover) and tightens the rows.\n */\n density?: 'comfortable' | 'compact';\n /**\n * `listbox` (default): with `onSelect` the list is a listbox. `list`: the\n * list stays a list of items, the selected one marked `aria-current` and\n * each item with an `href` a link, e.g. one per run that opens its page.\n */\n mode?: 'listbox' | 'list';\n /**\n * The selected item, drawn inverted when `onSelect` is set or in the\n * `list` mode. With `onSelect` in the `listbox` mode each item is an\n * option, clicked or chosen with Enter or Space, and ↑ ↓ Home End move\n * between them from one tab stop.\n */\n selectedId?: string;\n /** Fired when an item is chosen in the `listbox` mode; a `list` follows its links instead. */\n onSelect?: (item: TimelineItem) => void;\n /** Renders the `list` mode's links. Defaults to an `<a href>`; routed apps pass their Link adapter. */\n linkComponent?: LinkComponent;\n /**\n * Bounds the list to `--timeline-scroll-max-height` and scrolls it. The\n * list scrolls itself, never the page, to keep the selected item in view\n * when it mounts and when `selectedId` changes.\n */\n scrollable?: boolean;\n /** The list's accessible name; name a selectable list. */\n ariaLabel?: string;\n className?: string;\n style?: CSSProperties;\n surface?: TimelineSurface;\n}\n\nexport function Timeline({\n items,\n variant = 'dot',\n density = 'comfortable',\n mode = 'listbox',\n selectedId,\n onSelect,\n linkComponent,\n scrollable = false,\n ariaLabel,\n className,\n style,\n surface,\n}: TimelineProps) {\n const wrapRef = useRef<HTMLOListElement>(null);\n const agentAttrs = usePrimitiveSurface(surface, items, 'timeline', wrapRef);\n const [focusedId, setFocusedId] = useState<string | undefined>(undefined);\n const numbered = variant === 'numbered';\n const compact = density === 'compact';\n const list = mode === 'list';\n const selectable = !list && onSelect !== undefined;\n const LinkImpl = linkComponent ?? DefaultLink;\n const rootClass = [\n 'aegis-timeline',\n numbered ? 'aegis-timeline--numbered' : '',\n compact ? 'aegis-timeline--compact' : '',\n selectable ? 'aegis-timeline--selectable' : '',\n list ? 'aegis-timeline--list' : '',\n scrollable ? 'aegis-timeline--scrollable' : '',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n\n const selectedIndex = items.findIndex((it) => it.id === selectedId);\n const focusedIndex = items.findIndex((it) => it.id === focusedId);\n const tabStopIndex =\n focusedIndex >= 0 ? focusedIndex : Math.max(selectedIndex, 0);\n\n useLayoutEffect(() => {\n const list = wrapRef.current;\n const item = list?.querySelector<HTMLElement>(\n ':scope > .aegis-timeline__item--selected',\n );\n if (!list || !item) {\n return;\n }\n const top =\n item.getBoundingClientRect().top -\n list.getBoundingClientRect().top +\n list.scrollTop;\n const bottom = top + item.offsetHeight;\n if (top < list.scrollTop) {\n list.scrollTop = top;\n } else if (bottom > list.scrollTop + list.clientHeight) {\n list.scrollTop = bottom - list.clientHeight;\n }\n }, [selectedId]);\n\n const focusItem = (index: number): void => {\n if (index < 0 || index >= items.length) {\n return;\n }\n setFocusedId(items[index].id);\n wrapRef.current\n ?.querySelectorAll<HTMLElement>(':scope > [role=\"option\"]')\n [index]?.focus();\n };\n\n const handleKeyDown = (\n event: KeyboardEvent<HTMLLIElement>,\n index: number,\n ): void => {\n switch (event.key) {\n case 'ArrowDown':\n focusItem(index + 1);\n break;\n case 'ArrowUp':\n focusItem(index - 1);\n break;\n case 'Home':\n focusItem(0);\n break;\n case 'End':\n focusItem(items.length - 1);\n break;\n case 'Enter':\n case ' ':\n onSelect?.(items[index]);\n break;\n default:\n return;\n }\n event.preventDefault();\n };\n\n return (\n <ol\n ref={wrapRef}\n className={rootClass}\n style={style}\n role={selectable ? 'listbox' : list ? 'list' : undefined}\n aria-label={ariaLabel}\n {...agentAttrs}\n >\n {items.map((it, index) => {\n const current = it.id === selectedId;\n const href = list ? it.href : undefined;\n const className = [\n 'aegis-timeline__item',\n numbered ? 'aegis-timeline__item--numbered' : '',\n (selectable || list) && current\n ? 'aegis-timeline__item--selected'\n : '',\n href !== undefined ? 'aegis-timeline__item--link' : '',\n ]\n .filter(Boolean)\n .join(' ');\n const content = (\n <>\n {numbered ? (\n <span className=\"aegis-timeline__marker\">\n {it.marker ?? String(index + 1).padStart(2, '0')}\n </span>\n ) : (\n <span\n className=\"aegis-timeline__dot\"\n style={it.dotColor ? { background: it.dotColor } : undefined}\n />\n )}\n <div className=\"aegis-timeline__body\">\n <div className=\"aegis-timeline__row\">\n <span\n className=\"aegis-timeline__title\"\n title={\n compact && typeof it.title === 'string'\n ? it.title\n : undefined\n }\n >\n {href !== undefined ? (\n <LinkImpl\n to={href}\n className=\"aegis-timeline__link\"\n aria-current={current ? 'true' : undefined}\n >\n {it.title}\n </LinkImpl>\n ) : (\n it.title\n )}\n </span>\n {it.meta ? (\n <span className=\"aegis-timeline__meta\">{it.meta}</span>\n ) : null}\n </div>\n {it.description ? (\n <div className=\"aegis-timeline__desc\">{it.description}</div>\n ) : null}\n {it.timestamp ? (\n <div className=\"aegis-timeline__time\">{it.timestamp}</div>\n ) : null}\n </div>\n </>\n );\n if (list) {\n return (\n <li\n key={it.id}\n className={className}\n aria-current={current && href === undefined ? 'true' : undefined}\n >\n {content}\n </li>\n );\n }\n if (!selectable) {\n return (\n <li key={it.id} className={className}>\n {content}\n </li>\n );\n }\n return (\n <li\n key={it.id}\n className={className}\n role=\"option\"\n aria-selected={it.id === selectedId}\n tabIndex={index === tabStopIndex ? 0 : -1}\n onClick={() => {\n onSelect(it);\n }}\n onKeyDown={(event) => {\n handleKeyDown(event, index);\n }}\n onFocus={() => {\n setFocusedId(it.id);\n }}\n >\n {content}\n </li>\n );\n })}\n </ol>\n );\n}\n"],"names":["Timeline","items","variant","density","mode","selectedId","onSelect","linkComponent","scrollable","ariaLabel","className","style","surface","wrapRef","useRef","agentAttrs","usePrimitiveSurface","focusedId","setFocusedId","useState","numbered","compact","list","selectable","LinkImpl","DefaultLink","rootClass","selectedIndex","it","focusedIndex","tabStopIndex","useLayoutEffect","item","top","bottom","focusItem","index","handleKeyDown","event","jsx","current","href","content","jsxs","Fragment"],"mappings":"mQAkFO,SAASA,EAAS,CACvB,MAAAC,EACA,QAAAC,EAAU,MACV,QAAAC,EAAU,cACV,KAAAC,EAAO,UACP,WAAAC,EACA,SAAAC,EAAA,cACAC,EACA,WAAAC,EAAa,GACb,UAAAC,EACA,UAAAC,EACA,MAAAC,EACA,QAAAC,CACF,EAAkB,CAChB,MAAMC,EAAUC,EAAAA,OAAyB,IAAI,EACvCC,EAAaC,EAAAA,oBAAoBJ,EAASX,EAAO,WAAYY,CAAO,EACpE,CAACI,EAAWC,CAAY,EAAIC,EAAAA,SAA6B,MAAS,EAClEC,EAAWlB,IAAY,WACvBmB,EAAUlB,IAAY,UACtBmB,EAAOlB,IAAS,OAChBmB,EAAa,CAACD,GAAQhB,IAAa,OACnCkB,EAAWjB,GAAiBkB,EAAAA,YAC5BC,EAAY,CAChB,iBACAN,EAAW,2BAA6B,GACxCC,EAAU,0BAA4B,GACtCE,EAAa,6BAA+B,GAC5CD,EAAO,uBAAyB,GAChCd,EAAa,6BAA+B,GAC5CE,GAAa,EAAA,EAEZ,OAAO,OAAO,EACd,KAAK,GAAG,EAELiB,EAAgB1B,EAAM,UAAW2B,GAAOA,EAAG,KAAOvB,CAAU,EAC5DwB,EAAe5B,EAAM,UAAW2B,GAAOA,EAAG,KAAOX,CAAS,EAC1Da,EACJD,GAAgB,EAAIA,EAAe,KAAK,IAAIF,EAAe,CAAC,EAE9DI,EAAAA,gBAAgB,IAAM,CACpB,MAAMT,EAAOT,EAAQ,QACfmB,EAAOV,GAAM,cACjB,0CAAA,EAEF,GAAI,CAACA,GAAQ,CAACU,EACZ,OAEF,MAAMC,EACJD,EAAK,wBAAwB,IAC7BV,EAAK,sBAAA,EAAwB,IAC7BA,EAAK,UACDY,EAASD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CAGP"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CSSProperties, ReactNode } from 'react';
|
|
2
2
|
import { PrimitiveSurface } from '../../agent/core/usePrimitiveSurface';
|
|
3
|
+
import { LinkComponent } from './linkComponent';
|
|
3
4
|
export interface TimelineItem {
|
|
4
5
|
id: string;
|
|
5
6
|
/** Headline — actor / event / verb, e.g. "alice@aegis updated `db.dsn`". */
|
|
@@ -17,6 +18,8 @@ export interface TimelineItem {
|
|
|
17
18
|
* Defaults to the 1-based position, zero-padded to two digits.
|
|
18
19
|
*/
|
|
19
20
|
marker?: ReactNode;
|
|
21
|
+
/** In the `list` mode, makes the item a link to this destination. */
|
|
22
|
+
href?: string;
|
|
20
23
|
}
|
|
21
24
|
export type TimelineSurface = PrimitiveSurface<TimelineItem[]>;
|
|
22
25
|
interface TimelineProps {
|
|
@@ -33,12 +36,22 @@ interface TimelineProps {
|
|
|
33
36
|
*/
|
|
34
37
|
density?: 'comfortable' | 'compact';
|
|
35
38
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
+
* `listbox` (default): with `onSelect` the list is a listbox. `list`: the
|
|
40
|
+
* list stays a list of items, the selected one marked `aria-current` and
|
|
41
|
+
* each item with an `href` a link, e.g. one per run that opens its page.
|
|
42
|
+
*/
|
|
43
|
+
mode?: 'listbox' | 'list';
|
|
44
|
+
/**
|
|
45
|
+
* The selected item, drawn inverted when `onSelect` is set or in the
|
|
46
|
+
* `list` mode. With `onSelect` in the `listbox` mode each item is an
|
|
47
|
+
* option, clicked or chosen with Enter or Space, and ↑ ↓ Home End move
|
|
48
|
+
* between them from one tab stop.
|
|
39
49
|
*/
|
|
40
50
|
selectedId?: string;
|
|
51
|
+
/** Fired when an item is chosen in the `listbox` mode; a `list` follows its links instead. */
|
|
41
52
|
onSelect?: (item: TimelineItem) => void;
|
|
53
|
+
/** Renders the `list` mode's links. Defaults to an `<a href>`; routed apps pass their Link adapter. */
|
|
54
|
+
linkComponent?: LinkComponent;
|
|
42
55
|
/**
|
|
43
56
|
* Bounds the list to `--timeline-scroll-max-height` and scrolls it. The
|
|
44
57
|
* list scrolls itself, never the page, to keep the selected item in view
|
|
@@ -51,5 +64,5 @@ interface TimelineProps {
|
|
|
51
64
|
style?: CSSProperties;
|
|
52
65
|
surface?: TimelineSurface;
|
|
53
66
|
}
|
|
54
|
-
export declare function Timeline({ items, variant, density, selectedId, onSelect, scrollable, ariaLabel, className, style, surface, }: TimelineProps): import("react/jsx-runtime").JSX.Element;
|
|
67
|
+
export declare function Timeline({ items, variant, density, mode, selectedId, onSelect, linkComponent, scrollable, ariaLabel, className, style, surface, }: TimelineProps): import("react/jsx-runtime").JSX.Element;
|
|
55
68
|
export {};
|