nish-ui 1.8.0 → 2.0.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.
Files changed (152) hide show
  1. package/README.md +223 -61
  2. package/dist/base-tailwind.css +1757 -0
  3. package/dist/base.css +1590 -1445
  4. package/dist/chart.d.ts +4 -1
  5. package/dist/chart.js +122 -49
  6. package/dist/elements-all.d.ts +8 -0
  7. package/dist/elements-all.js +178 -0
  8. package/dist/elements-charts.d.ts +124 -2
  9. package/dist/elements-charts.js +131 -1
  10. package/dist/elements-data.d.ts +166 -2
  11. package/dist/elements-data.js +46 -1
  12. package/dist/elements-forms.d.ts +71 -0
  13. package/dist/elements-forms.js +24 -25
  14. package/dist/elements.d.ts +71 -0
  15. package/dist/elements.js +4 -5
  16. package/dist/esm/chart-values.js +58 -0
  17. package/dist/esm/chart.js +10 -0
  18. package/dist/esm/cn.js +19 -0
  19. package/dist/esm/combobox-filter.js +13 -0
  20. package/dist/esm/components/accordion.js +166 -0
  21. package/dist/esm/components/app-shell.js +198 -0
  22. package/dist/esm/components/avatar-classes.js +28 -0
  23. package/dist/esm/components/avatar.js +113 -0
  24. package/dist/esm/components/breadcrumbs.js +154 -0
  25. package/dist/esm/components/canvas/follow-caption.js +32 -0
  26. package/dist/esm/components/canvas/follow.js +119 -0
  27. package/dist/esm/components/canvas/icons.js +70 -0
  28. package/dist/esm/components/canvas/index.js +10 -0
  29. package/dist/esm/components/canvas/layout.js +258 -0
  30. package/dist/esm/components/canvas/legend.js +93 -0
  31. package/dist/esm/components/canvas/minimap.js +127 -0
  32. package/dist/esm/components/canvas/node.js +87 -0
  33. package/dist/esm/components/canvas/route.js +262 -0
  34. package/dist/esm/components/canvas/system-canvas.js +837 -0
  35. package/dist/esm/components/canvas/types.js +10 -0
  36. package/dist/esm/components/canvas/view.js +47 -0
  37. package/dist/esm/components/chart-hooks.js +19 -0
  38. package/dist/esm/components/charts.js +467 -0
  39. package/dist/esm/components/client.js +24 -0
  40. package/dist/esm/components/combobox.js +343 -0
  41. package/dist/esm/components/command.js +403 -0
  42. package/dist/esm/components/data-classes.js +159 -0
  43. package/dist/esm/components/data.js +517 -0
  44. package/dist/esm/components/display-classes.js +130 -0
  45. package/dist/esm/components/display.js +755 -0
  46. package/dist/esm/components/error-boundary.js +64 -0
  47. package/dist/esm/components/feedback.js +136 -0
  48. package/dist/esm/components/file-dropzone.js +184 -0
  49. package/dist/esm/components/filters.js +108 -0
  50. package/dist/esm/components/flow.js +746 -0
  51. package/dist/esm/components/forms-classes.js +43 -0
  52. package/dist/esm/components/forms.js +581 -0
  53. package/dist/esm/components/hooks-classes.js +9 -0
  54. package/dist/esm/components/hooks.js +236 -0
  55. package/dist/esm/components/icons.js +96 -0
  56. package/dist/esm/components/inbox-classes.js +29 -0
  57. package/dist/esm/components/inbox.js +257 -0
  58. package/dist/esm/components/latest.js +13 -0
  59. package/dist/esm/components/layout-vars.js +96 -0
  60. package/dist/esm/components/layout.js +272 -0
  61. package/dist/esm/components/media.js +143 -0
  62. package/dist/esm/components/nav.js +614 -0
  63. package/dist/esm/components/overlay-classes.js +66 -0
  64. package/dist/esm/components/overlay.js +1447 -0
  65. package/dist/esm/components/pagination-classes.js +29 -0
  66. package/dist/esm/components/pagination.js +154 -0
  67. package/dist/esm/components/portal.js +16 -0
  68. package/dist/esm/components/primitives-classes.js +198 -0
  69. package/dist/esm/components/primitives.js +268 -0
  70. package/dist/esm/components/progress.js +77 -0
  71. package/dist/esm/components/provider.js +32 -0
  72. package/dist/esm/components/radio-group.js +186 -0
  73. package/dist/esm/components/resource-classes.js +133 -0
  74. package/dist/esm/components/resource.js +209 -0
  75. package/dist/esm/components/segmented.js +178 -0
  76. package/dist/esm/components/separator.js +38 -0
  77. package/dist/esm/components/service-tokens.js +221 -0
  78. package/dist/esm/components/settings.js +301 -0
  79. package/dist/esm/components/slider.js +262 -0
  80. package/dist/esm/components/split-classes.js +8 -0
  81. package/dist/esm/components/split.js +411 -0
  82. package/dist/esm/components/strings.js +119 -0
  83. package/dist/esm/components/table.js +144 -0
  84. package/dist/esm/components/tabs-classes.js +21 -0
  85. package/dist/esm/components/tabs.js +201 -0
  86. package/dist/esm/components/tag-input.js +257 -0
  87. package/dist/esm/components/theme-toggle.js +177 -0
  88. package/dist/esm/components/toast.js +361 -0
  89. package/dist/esm/components/url-state.js +118 -0
  90. package/dist/esm/components/visually-hidden.js +20 -0
  91. package/dist/esm/format.js +320 -0
  92. package/dist/esm/inbox-client.js +2 -0
  93. package/dist/esm/inbox-types.js +2 -0
  94. package/dist/esm/index.js +320 -0
  95. package/dist/esm/runtime.js +37 -0
  96. package/dist/esm/server/inbox/client.js +297 -0
  97. package/dist/esm/server/inbox/types.js +24 -0
  98. package/dist/esm/sparkline-path.js +59 -0
  99. package/dist/esm/split-layout.js +419 -0
  100. package/dist/esm/system-canvas.js +2 -0
  101. package/dist/esm/theme.js +804 -0
  102. package/dist/esm/tokens.mjs +425 -0
  103. package/dist/esm/url.js +20 -0
  104. package/dist/files.json +5 -1
  105. package/dist/fonts/LICENSE-Inter.txt +93 -0
  106. package/dist/format.d.ts +32 -18
  107. package/dist/format.js +227 -82
  108. package/dist/inbox-client.js +3 -1
  109. package/dist/index.d.ts +1689 -667
  110. package/dist/nish-components.css +4701 -3169
  111. package/dist/nish-components.min.css +1 -0
  112. package/dist/nish.css +1603 -1450
  113. package/dist/nish.min.css +1 -0
  114. package/dist/node/eslint.js +29 -14
  115. package/dist/node/th-check.js +29 -14
  116. package/dist/node/vite.d.ts +12 -0
  117. package/dist/node/vite.js +12 -2
  118. package/dist/server/hono.d.ts +15 -6
  119. package/dist/server/hono.js +30 -25
  120. package/dist/server/index.d.ts +3 -10
  121. package/dist/server/index.js +71 -38
  122. package/dist/{spa-DuVB5O7S.d.ts → spa-BLlMc0eI.d.ts} +38 -5
  123. package/dist/system-canvas-BLuWd69H.d.ts +183 -0
  124. package/dist/system-canvas.d.ts +2 -168
  125. package/dist/tailwind-core.css +114 -0
  126. package/dist/tailwind.css +3 -7
  127. package/dist/theme-init.js +23 -9
  128. package/dist/theme-init.sha256 +1 -0
  129. package/dist/theme.d.ts +246 -4
  130. package/dist/theme.global.js +357 -90
  131. package/dist/theme.js +338 -68
  132. package/dist/tokens.css +14 -6
  133. package/dist/tokens.dtcg.json +1513 -0
  134. package/dist/tokens.js +29 -14
  135. package/dist/tokens.json +512 -0
  136. package/package.json +51 -13
  137. package/dist/chart.js.map +0 -1
  138. package/dist/elements-charts.js.map +0 -1
  139. package/dist/elements-data.js.map +0 -1
  140. package/dist/elements-forms.js.map +0 -1
  141. package/dist/elements.js.map +0 -1
  142. package/dist/format.js.map +0 -1
  143. package/dist/inbox-client.js.map +0 -1
  144. package/dist/index.js +0 -10260
  145. package/dist/index.js.map +0 -1
  146. package/dist/server/hono.js.map +0 -1
  147. package/dist/server/index.js.map +0 -1
  148. package/dist/split-layout.js.map +0 -1
  149. package/dist/system-canvas.js +0 -2204
  150. package/dist/system-canvas.js.map +0 -1
  151. package/dist/theme.global.js.map +0 -1
  152. package/dist/theme.js.map +0 -1
@@ -0,0 +1,178 @@
1
+ "use client";
2
+
3
+ // src/components/segmented.tsx
4
+ import { useEffect, useId, useRef, useState } from "react";
5
+ import { cn } from "../cn.js";
6
+ import { useScrollEdges } from "./layout-vars.js";
7
+ import { revealInRow } from "./nav.js";
8
+ import { FloatingTip, keyboardFocused, touchTracker } from "./overlay.js";
9
+ import { isRtl } from "./client.js";
10
+ import { SEGMENTED_SELECTED, SEGMENTED_SIZE, setRef } from "./forms-classes.js";
11
+ import { jsx, jsxs } from "react/jsx-runtime";
12
+ function Segmented({
13
+ ref,
14
+ label,
15
+ options,
16
+ value: valueProp,
17
+ defaultValue,
18
+ onChange,
19
+ onValueChange,
20
+ name,
21
+ form,
22
+ required,
23
+ size = "sm",
24
+ block = false,
25
+ overflow = "scroll",
26
+ fullWidth = false,
27
+ className,
28
+ onKeyDown,
29
+ ...rest
30
+ }) {
31
+ const [own, setOwn] = useState(defaultValue);
32
+ const controlled = valueProp !== void 0;
33
+ const value = controlled ? valueProp : own;
34
+ const fill = block || fullWidth;
35
+ const scroll = overflow === "scroll";
36
+ const groupRef = useRef(null);
37
+ useScrollEdges(groupRef);
38
+ const refs = useRef([]);
39
+ const tipAnchor = useRef(null);
40
+ const [tipAt, setTipAt] = useState(null);
41
+ const tipId = useId();
42
+ const [touch] = useState(touchTracker);
43
+ const showTip = (i) => {
44
+ if (options[i]?.tip == null) return;
45
+ tipAnchor.current = refs.current[i];
46
+ setTipAt(i);
47
+ };
48
+ const hideTip = (i) => setTipAt((cur) => cur === i ? null : cur);
49
+ const enabled = options.map((o, i) => o.disabled ? -1 : i).filter((i) => i >= 0);
50
+ const selected = options.findIndex((o) => o.value === value);
51
+ useEffect(() => {
52
+ const el = selected >= 0 ? refs.current[selected] : null;
53
+ if (scroll && el && groupRef.current) revealInRow(groupRef.current, el);
54
+ }, [selected, scroll, options.length]);
55
+ const pick = (i) => {
56
+ const o = options[i];
57
+ if (!o || o.disabled) return;
58
+ if (!controlled) setOwn(o.value);
59
+ onChange?.(o.value);
60
+ onValueChange?.(o.value);
61
+ refs.current[i]?.focus();
62
+ };
63
+ const move = (from, dir) => {
64
+ if (!enabled.length) return;
65
+ const pos = enabled.indexOf(from);
66
+ const next = pos < 0 ? enabled[dir === 1 ? 0 : enabled.length - 1] : enabled[(pos + dir + enabled.length) % enabled.length];
67
+ pick(next);
68
+ };
69
+ const tabStop = selected >= 0 && !options[selected].disabled ? selected : enabled[0] ?? -1;
70
+ return /* @__PURE__ */ jsxs(
71
+ "div",
72
+ {
73
+ ...rest,
74
+ ref: (node) => {
75
+ groupRef.current = node;
76
+ setRef(ref, node);
77
+ },
78
+ role: "radiogroup",
79
+ "aria-label": label,
80
+ "aria-required": required || void 0,
81
+ className: cn(
82
+ "rounded-lg border border-th-line bg-th-elevated p-0.5",
83
+ fill ? "flex w-full" : "inline-flex",
84
+ scroll && "max-w-full overflow-x-auto nish-no-scrollbar nish-scroll-fade",
85
+ className
86
+ ),
87
+ onKeyDown: (e) => {
88
+ onKeyDown?.(e);
89
+ if (e.defaultPrevented) return;
90
+ const rtl = isRtl(groupRef.current);
91
+ const from = refs.current.findIndex((el) => el === document.activeElement);
92
+ const at = from >= 0 ? from : selected;
93
+ if (e.key === "Escape" && tipAt != null) {
94
+ setTipAt(null);
95
+ return;
96
+ }
97
+ if (e.key === (rtl ? "ArrowLeft" : "ArrowRight") || e.key === "ArrowDown") {
98
+ e.preventDefault();
99
+ move(at, 1);
100
+ } else if (e.key === (rtl ? "ArrowRight" : "ArrowLeft") || e.key === "ArrowUp") {
101
+ e.preventDefault();
102
+ move(at, -1);
103
+ } else if (e.key === "Home") {
104
+ e.preventDefault();
105
+ if (enabled.length) pick(enabled[0]);
106
+ } else if (e.key === "End") {
107
+ e.preventDefault();
108
+ if (enabled.length) pick(enabled[enabled.length - 1]);
109
+ }
110
+ },
111
+ children: [
112
+ options.map((o, i) => {
113
+ const on = o.value === value;
114
+ const tipShown = tipAt === i && o.tip != null;
115
+ return /* @__PURE__ */ jsx(
116
+ "button",
117
+ {
118
+ ref: (el) => {
119
+ refs.current[i] = el;
120
+ },
121
+ type: "button",
122
+ role: "radio",
123
+ "aria-checked": on,
124
+ "aria-label": o.ariaLabel,
125
+ "aria-describedby": tipShown ? tipId : void 0,
126
+ "data-state": on ? "checked" : "unchecked",
127
+ "data-disabled": o.disabled ? "" : void 0,
128
+ title: o.tip != null ? void 0 : o.title,
129
+ disabled: o.disabled,
130
+ tabIndex: i === tabStop ? 0 : -1,
131
+ onClick: () => pick(i),
132
+ onPointerEnter: touch.onPointer,
133
+ onPointerDown: (e) => {
134
+ touch.onPointer(e);
135
+ setTipAt(null);
136
+ },
137
+ onMouseEnter: o.tip != null ? () => !touch.recent() && showTip(i) : void 0,
138
+ onMouseLeave: o.tip != null ? () => hideTip(i) : void 0,
139
+ onFocus: o.tip != null ? (e) => keyboardFocused(e.currentTarget) && showTip(i) : void 0,
140
+ onBlur: o.tip != null ? () => hideTip(i) : void 0,
141
+ className: cn(
142
+ "inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md font-medium tabular-nums transition-colors pointer-coarse:min-h-11 pointer-coarse:min-w-11",
143
+ "disabled:cursor-not-allowed disabled:text-th-ghost forced-colors:disabled:text-[color:GrayText]",
144
+ fill && (scroll ? "flex-1 shrink-0" : "min-w-0 flex-1"),
145
+ scroll && !fill && "shrink-0",
146
+ SEGMENTED_SIZE[size],
147
+ on ? SEGMENTED_SELECTED[o.tone ?? "accent"] : "text-th-hi2 hover:text-th-hi disabled:hover:text-th-ghost"
148
+ ),
149
+ children: o.label
150
+ },
151
+ o.value
152
+ );
153
+ }),
154
+ name != null ? options.map((o) => /* @__PURE__ */ jsx(
155
+ "input",
156
+ {
157
+ type: "radio",
158
+ "aria-hidden": "true",
159
+ tabIndex: -1,
160
+ className: "sr-only pointer-events-none",
161
+ name,
162
+ value: o.value,
163
+ form,
164
+ required,
165
+ checked: o.value === value,
166
+ onChange: () => {
167
+ }
168
+ },
169
+ o.value
170
+ )) : null,
171
+ tipAt != null && options[tipAt]?.tip != null ? /* @__PURE__ */ jsx(FloatingTip, { anchor: tipAnchor, id: tipId, tip: options[tipAt].tip }, tipAt) : null
172
+ ]
173
+ }
174
+ );
175
+ }
176
+ export {
177
+ Segmented
178
+ };
@@ -0,0 +1,38 @@
1
+ // src/components/separator.tsx
2
+ import { cn } from "../cn.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ var LINE = "bg-th-line forced-colors:bg-[CanvasText]";
5
+ function Separator({ orientation = "horizontal", decorative = true, label, className, ref, ...rest }) {
6
+ const a11y = decorative ? { role: "none" } : { role: "separator", "aria-orientation": orientation };
7
+ const hasLabel = label != null && label !== false && label !== "" && orientation === "horizontal";
8
+ if (hasLabel) {
9
+ return /* @__PURE__ */ jsxs(
10
+ "div",
11
+ {
12
+ "data-orientation": orientation,
13
+ ...a11y,
14
+ ...rest,
15
+ ref,
16
+ className: cn("flex w-full items-center gap-3 text-xs text-th-hi3", className),
17
+ children: [
18
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: cn("h-px flex-1", LINE) }),
19
+ /* @__PURE__ */ jsx("span", { className: "shrink-0", children: label }),
20
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: cn("h-px flex-1", LINE) })
21
+ ]
22
+ }
23
+ );
24
+ }
25
+ return /* @__PURE__ */ jsx(
26
+ "div",
27
+ {
28
+ "data-orientation": orientation,
29
+ ...a11y,
30
+ ...rest,
31
+ ref,
32
+ className: cn("shrink-0", LINE, orientation === "horizontal" ? "h-px w-full" : "w-px self-stretch", className)
33
+ }
34
+ );
35
+ }
36
+ export {
37
+ Separator
38
+ };
@@ -0,0 +1,221 @@
1
+ "use client";
2
+
3
+ // src/components/service-tokens.tsx
4
+ import {
5
+ useCallback,
6
+ useEffect,
7
+ useMemo,
8
+ useRef,
9
+ useState
10
+ } from "react";
11
+ import { cn } from "../cn.js";
12
+ import { date } from "../format.js";
13
+ import { ErrorState, SkeletonRows } from "./feedback.js";
14
+ import { ConfirmDialog } from "./overlay.js";
15
+ import { Badge, Button } from "./primitives.js";
16
+ import { apiFetch } from "./resource.js";
17
+ import { useNishStrings } from "./provider.js";
18
+ import { SettingRow, SettingsSection } from "./settings.js";
19
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
20
+ function useServiceTokens(url = "/api/service-tokens") {
21
+ const strings = useNishStrings();
22
+ const [tokens, setTokens] = useState(
23
+ void 0
24
+ );
25
+ const [loading, setLoading] = useState(true);
26
+ const [error, setError] = useState(null);
27
+ const [nonce, setNonce] = useState(0);
28
+ const seq = useRef(0);
29
+ useEffect(() => {
30
+ const mine = ++seq.current;
31
+ const ctl = new AbortController();
32
+ apiFetch(url, { signal: ctl.signal }).then((r) => {
33
+ if (seq.current !== mine) return;
34
+ setTokens(r.tokens);
35
+ setLoading(false);
36
+ }).catch((e) => {
37
+ if (seq.current !== mine || e instanceof Error && e.name === "AbortError")
38
+ return;
39
+ setError(e instanceof Error ? e.message : strings.failedToLoad);
40
+ setLoading(false);
41
+ });
42
+ return () => ctl.abort();
43
+ }, [url, nonce]);
44
+ const reload = useCallback(() => {
45
+ setLoading(true);
46
+ setError(null);
47
+ setNonce((n) => n + 1);
48
+ }, []);
49
+ const revoke = useCallback(
50
+ async (id) => {
51
+ const r = await apiFetch(
52
+ `${url}/${encodeURIComponent(id)}/revoke`,
53
+ // A JSON body (and so a JSON content type): some apps refuse non-JSON writes.
54
+ { method: "POST", body: {} }
55
+ );
56
+ seq.current++;
57
+ setTokens(r.tokens);
58
+ setError(null);
59
+ setLoading(false);
60
+ },
61
+ [url]
62
+ );
63
+ return { tokens, loading, error, reload, revoke };
64
+ }
65
+ function when(raw) {
66
+ if (!raw) return "";
67
+ const d = /^\d{4}-\d{2}-\d{2}$/.test(raw) ? `${raw}T12:00:00` : raw;
68
+ const out = date(d, "medium");
69
+ return out === "\u2014" || out === "" || Number.isNaN(new Date(d).getTime()) ? raw : out;
70
+ }
71
+ function sortTokens(list) {
72
+ return [...list].sort(
73
+ (a, b) => Number(a.revoked) - Number(b.revoked) || a.name.localeCompare(b.name)
74
+ );
75
+ }
76
+ function ServiceTokensSection({
77
+ tokens,
78
+ error,
79
+ onRetry,
80
+ onRevoke,
81
+ title: titleProp,
82
+ description: descriptionProp,
83
+ id = "service-tokens",
84
+ className,
85
+ emptyMessage = "No service tokens. No machine client can read this app.",
86
+ revokeBody,
87
+ createdLabel = (when2) => `created ${when2}`,
88
+ envSourceLabel = "from SERVICE_TOKENS",
89
+ ...rest
90
+ }) {
91
+ const strings = useNishStrings();
92
+ const title = titleProp ?? strings.serviceTokens;
93
+ const description = descriptionProp ?? strings.serviceTokensIntro;
94
+ const [target, setTarget] = useState(null);
95
+ const [pending, setPending] = useState(false);
96
+ const [failure, setFailure] = useState(null);
97
+ const mounted = useRef(true);
98
+ useEffect(() => {
99
+ mounted.current = true;
100
+ return () => {
101
+ mounted.current = false;
102
+ };
103
+ }, []);
104
+ const sorted = useMemo(
105
+ () => tokens ? sortTokens(tokens) : void 0,
106
+ [tokens]
107
+ );
108
+ const close = () => {
109
+ setTarget(null);
110
+ setFailure(null);
111
+ };
112
+ const confirm = async () => {
113
+ if (!target) return;
114
+ setPending(true);
115
+ setFailure(null);
116
+ try {
117
+ await onRevoke(target.id);
118
+ if (mounted.current) close();
119
+ } catch (e) {
120
+ if (mounted.current)
121
+ setFailure(
122
+ e instanceof Error ? e.message : strings.tokenRevokeFailed
123
+ );
124
+ } finally {
125
+ if (mounted.current) setPending(false);
126
+ }
127
+ };
128
+ const errorRow = sorted !== void 0 && error ? /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2 px-4 py-2", children: [
129
+ /* @__PURE__ */ jsx(
130
+ "p",
131
+ {
132
+ role: "alert",
133
+ className: "min-w-0 flex-1 break-words text-sm text-th-loss",
134
+ children: error
135
+ }
136
+ ),
137
+ onRetry ? /* @__PURE__ */ jsx(Button, { size: "sm", onClick: onRetry, children: strings.errorTryAgain }) : null
138
+ ] }) : null;
139
+ let content;
140
+ if (sorted === void 0 && error) {
141
+ content = /* @__PURE__ */ jsxs("div", { className: "grid gap-2 p-4", children: [
142
+ /* @__PURE__ */ jsx(ErrorState, { message: error, compact: true }),
143
+ onRetry ? /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx(Button, { size: "sm", onClick: onRetry, children: strings.errorTryAgain }) }) : null
144
+ ] });
145
+ } else if (sorted === void 0) {
146
+ content = /* @__PURE__ */ jsx("div", { className: "p-4", children: /* @__PURE__ */ jsx(SkeletonRows, { rows: 3, height: 48, label: strings.loadingServiceTokens }) });
147
+ } else if (sorted.length === 0) {
148
+ content = /* @__PURE__ */ jsxs(Fragment, { children: [
149
+ errorRow,
150
+ /* @__PURE__ */ jsx("p", { className: "px-4 py-6 text-sm text-th-hi3", children: emptyMessage })
151
+ ] });
152
+ } else {
153
+ const rows = sorted.map((t) => {
154
+ const parts = [t.id, t.scopes.join(", "), createdLabel(when(t.created))];
155
+ if (t.source === "env") parts.push(envSourceLabel);
156
+ return /* @__PURE__ */ jsx(
157
+ SettingRow,
158
+ {
159
+ label: /* @__PURE__ */ jsx("span", { className: cn("break-words", t.revoked && "text-th-hi3"), children: t.name }),
160
+ description: /* @__PURE__ */ jsx("span", { className: "break-words", children: parts.join(" \xB7 ") }),
161
+ inline: true,
162
+ children: t.revoked ? /* @__PURE__ */ jsx(
163
+ Badge,
164
+ {
165
+ tone: "neutral",
166
+ title: t.revokedAt ? strings.tokenRevokedAt(when(t.revokedAt)) : strings.tokenRevoked,
167
+ children: strings.tokenRevoked
168
+ }
169
+ ) : /* @__PURE__ */ jsx(
170
+ Button,
171
+ {
172
+ variant: "danger",
173
+ size: "sm",
174
+ "aria-label": strings.tokenRevokeNamed(t.name),
175
+ onClick: () => setTarget(t),
176
+ children: strings.tokenRevoke
177
+ }
178
+ )
179
+ },
180
+ `${t.id}:${t.name}:${t.created}`
181
+ );
182
+ });
183
+ content = /* @__PURE__ */ jsxs(Fragment, { children: [
184
+ errorRow,
185
+ rows
186
+ ] });
187
+ }
188
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
189
+ /* @__PURE__ */ jsx(
190
+ SettingsSection,
191
+ {
192
+ ...rest,
193
+ title,
194
+ description,
195
+ id,
196
+ className,
197
+ children: content
198
+ }
199
+ ),
200
+ target ? /* @__PURE__ */ jsx(
201
+ ConfirmDialog,
202
+ {
203
+ title: strings.tokenRevokeTitle(target.name),
204
+ body: /* @__PURE__ */ jsxs(Fragment, { children: [
205
+ revokeBody ?? /* @__PURE__ */ jsx("p", { children: 'Anything using this token gets "Unauthorized" from now on. This cannot be undone: to restore access, issue a new token with npm run tokens in nishant/mcp.' }),
206
+ failure ? /* @__PURE__ */ jsx("p", { role: "alert", className: "mt-3 text-th-loss", children: failure }) : null
207
+ ] }),
208
+ confirmLabel: strings.tokenRevoke,
209
+ cancelLabel: strings.cancel,
210
+ tone: "danger",
211
+ pending,
212
+ onConfirm: () => void confirm(),
213
+ onCancel: close
214
+ }
215
+ ) : null
216
+ ] });
217
+ }
218
+ export {
219
+ ServiceTokensSection,
220
+ useServiceTokens
221
+ };