@burdenoff/microfe-vibecontrols 2026.1115.2 → 2026.1115.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  import { FC } from 'react';
2
2
  import { ComponentCardData } from '../idp-components';
3
3
  import { ScorecardTier } from '../../generated/wspace-types';
4
+ import { ComponentTableSort } from './componentSort';
4
5
  export interface ComponentTableRowData extends ComponentCardData {
5
6
  /** Owner display name (`ownerName` on VibecontrolsComponent). */
6
7
  ownerName: string | null;
@@ -9,10 +10,18 @@ export interface ComponentTableRowData extends ComponentCardData {
9
10
  /** `scorecard.securityTier` — null when no tier is met/tagged. */
10
11
  securityTier: ScorecardTier | null;
11
12
  }
12
- export type ComponentSortField = 'name' | 'owner' | 'lifecycle' | 'tier' | 'version' | 'health';
13
13
  export interface ComponentsTableProps {
14
+ /** Rows in the order the server returned them for `sort`. */
14
15
  components: ComponentTableRowData[];
15
16
  onOpen: (component: ComponentTableRowData) => void;
17
+ /** The active sort. The page sends it to the server for every column but Tier. */
18
+ sort: ComponentTableSort;
19
+ onSortChange: (sort: ComponentTableSort) => void;
20
+ /**
21
+ * Tier has no server ordering, so it can only be sorted once every row is
22
+ * loaded. While more pages remain the Tier header is disabled.
23
+ */
24
+ canSortTier: boolean;
16
25
  className?: string;
17
26
  }
18
27
  /**
@@ -23,8 +32,9 @@ export interface ComponentsTableProps {
23
32
  * fragment, and Tier/Health from the `scorecard { overallScore securityTier }`
24
33
  * selection on the list query.
25
34
  *
26
- * Sorting is client-side over the rows currently loaded: ComponentFilterInput
27
- * and PaginationInput expose no sort/orderBy argument, so there is no
28
- * server-side ordering to delegate to.
35
+ * Sorting is done by the server across the whole catalogue (BOFF-7059); the
36
+ * table only renders the rows in the order it is given. Tier is the exception:
37
+ * it has no server ordering, so it is sortable only once every row is loaded,
38
+ * and then sorted here.
29
39
  */
30
40
  export declare const ComponentsTable: FC<ComponentsTableProps>;
@@ -1,8 +1,8 @@
1
- import { ScorecardTier as e } from "../../generated/wspace-types.js";
2
- import { useTr as t } from "../../shared/hooks/useTr.js";
3
- import { ComponentHealthCell as n } from "./ComponentHealthCell.js";
4
- import { ComponentTierBadge as r } from "./ComponentTierBadge.js";
5
- import { useMemo as i, useState as a } from "react";
1
+ import { useTr as e } from "../../shared/hooks/useTr.js";
2
+ import { ComponentHealthCell as t } from "./ComponentHealthCell.js";
3
+ import { nextSort as n, sortRowsByTier as r } from "./componentSort.js";
4
+ import { ComponentTierBadge as i } from "./ComponentTierBadge.js";
5
+ import { useMemo as a } from "react";
6
6
  import { Box as o, ChevronDown as s, ChevronUp as c, Code as l, Cog as u, Database as d, Globe as f, Library as p, Server as m, Smartphone as h } from "lucide-react";
7
7
  import { jsx as g, jsxs as _ } from "react/jsx-runtime";
8
8
  // src/components/components/ComponentsTable.tsx
@@ -20,59 +20,31 @@ var v = {
20
20
  ACTIVE: "bg-status-success-bg-subtle text-status-success-text",
21
21
  DEPRECATED: "bg-status-error-bg-subtle text-status-error-text",
22
22
  END_OF_LIFE: "bg-status-error-bg-subtle text-status-error-text"
23
- }, b = {
24
- EXPERIMENTAL: 0,
25
- ACTIVE: 1,
26
- DEPRECATED: 2,
27
- END_OF_LIFE: 3
28
- }, x = {
29
- [e.Bronze]: 0,
30
- [e.Silver]: 1,
31
- [e.Gold]: 2
32
23
  };
33
- function S(e, t, n, r) {
34
- return e === null && t === null ? 0 : e === null ? 1 : t === null ? -1 : r(e, t) * n;
35
- }
36
- function C(e, t, n, r) {
37
- switch (n) {
38
- case "owner": return S(e.ownerName, t.ownerName, r, (e, t) => e.localeCompare(t));
39
- case "lifecycle": return ((b[e.lifecycle] ?? 99) - (b[t.lifecycle] ?? 99)) * r;
40
- case "tier": return S(e.securityTier, t.securityTier, r, (e, t) => x[e] - x[t]);
41
- case "version": return S(e.version, t.version, r, (e, t) => e.localeCompare(t, void 0, {
42
- numeric: !0,
43
- sensitivity: "base"
44
- }));
45
- case "health": return S(e.overallScore, t.overallScore, r, (e, t) => e - t);
46
- default: return e.name.localeCompare(t.name) * r;
47
- }
48
- }
49
- function w(e) {
24
+ function b(e) {
50
25
  return e.split(/[\s._-]+/).filter(Boolean).slice(0, 2).map((e) => e[0]?.toUpperCase() ?? "").join("");
51
26
  }
52
- var T = ({ components: e, onOpen: l, className: u = "" }) => {
53
- let d = t(), [f, p] = a("name"), [m, h] = a("asc"), b = i(() => {
54
- let t = m === "asc" ? 1 : -1;
55
- return [...e].sort((e, n) => {
56
- let r = C(e, n, f, t);
57
- return r === 0 ? e.name.localeCompare(n.name) : r;
58
- });
59
- }, [
60
- e,
61
- f,
62
- m
63
- ]), x = (e) => {
64
- f === e ? h((e) => e === "asc" ? "desc" : "asc") : (p(e), h(e === "name" || e === "owner" ? "asc" : "desc"));
65
- }, S = (e, t, n = "left", r = "") => {
66
- let i = f === e;
27
+ var x = ({ components: l, onOpen: u, sort: d, onSortChange: f, canSortTier: p, className: m = "" }) => {
28
+ let h = e(), x = a(() => d.column === "tier" && p ? r(l, d.direction) : l, [
29
+ l,
30
+ d,
31
+ p
32
+ ]), S = (e, t, r = "left", i = "") => {
33
+ let a = d.column === e, o = e === "tier" && !p;
67
34
  return /* @__PURE__ */ g("th", {
68
35
  scope: "col",
69
- "aria-sort": i ? m === "asc" ? "ascending" : "descending" : "none",
70
- className: `px-3 py-2 text-xs font-medium ${n === "right" ? "text-right" : "text-left"} ${r}`,
36
+ "aria-sort": a && !o ? d.direction === "asc" ? "ascending" : "descending" : "none",
37
+ className: `px-3 py-2 text-xs font-medium ${r === "right" ? "text-right" : "text-left"} ${i}`,
71
38
  children: /* @__PURE__ */ _("button", {
72
39
  type: "button",
73
- onClick: () => x(e),
74
- className: `inline-flex items-center gap-1 rounded transition-colors hover:text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus ${i ? "text-text-primary" : "text-text-secondary"} ${n === "right" ? "flex-row-reverse" : ""}`,
75
- children: [t, i ? g(m === "asc" ? c : s, {
40
+ onClick: () => f(n(d, e)),
41
+ disabled: o,
42
+ title: o ? h("component.tierSortNeedsAllRows", "Load all rows to sort by tier") : void 0,
43
+ className: `inline-flex items-center gap-1 rounded transition-colors hover:text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus disabled:cursor-not-allowed disabled:text-text-muted disabled:hover:text-text-muted ${a ? "text-text-primary" : "text-text-secondary"} ${r === "right" ? "flex-row-reverse" : ""}`,
44
+ children: [t, a && !o ? d.direction === "asc" ? /* @__PURE__ */ g(c, {
45
+ className: "size-3",
46
+ "aria-hidden": "true"
47
+ }) : /* @__PURE__ */ g(s, {
76
48
  className: "size-3",
77
49
  "aria-hidden": "true"
78
50
  }) : null]
@@ -80,30 +52,30 @@ var T = ({ components: e, onOpen: l, className: u = "" }) => {
80
52
  });
81
53
  };
82
54
  return /* @__PURE__ */ g("div", {
83
- className: `overflow-x-auto rounded-card border border-border-seam bg-bg-surface shadow-elevation-1 ${u}`,
55
+ className: `overflow-x-auto rounded-card border border-border-seam bg-bg-surface shadow-elevation-1 ${m}`,
84
56
  children: /* @__PURE__ */ _("table", {
85
57
  className: "w-full min-w-[52rem] text-sm",
86
58
  children: [
87
59
  /* @__PURE__ */ g("caption", {
88
60
  className: "sr-only",
89
- children: d("component.tableCaption", "Components in your catalog, sortable by column")
61
+ children: h("component.tableCaption", "Components in your catalog, sortable by column")
90
62
  }),
91
63
  /* @__PURE__ */ g("thead", {
92
64
  className: "bg-bg-sunken text-text-secondary",
93
65
  children: /* @__PURE__ */ _("tr", { children: [
94
- S("name", d("component.columnComponent", "Component")),
95
- S("owner", d("component.ownerLabel", "Owner")),
96
- S("lifecycle", d("component.lifecycle", "Lifecycle")),
97
- S("tier", d("component.columnTier", "Tier")),
98
- S("version", d("component.version", "Version")),
99
- S("health", d("component.columnHealth", "Health"), "right")
66
+ S("name", h("component.columnComponent", "Component")),
67
+ S("owner", h("component.ownerLabel", "Owner")),
68
+ S("lifecycle", h("component.lifecycle", "Lifecycle")),
69
+ S("tier", h("component.columnTier", "Tier")),
70
+ S("version", h("component.version", "Version")),
71
+ S("health", h("component.columnHealth", "Health"), "right")
100
72
  ] })
101
73
  }),
102
- /* @__PURE__ */ g("tbody", { children: b.map((e) => {
103
- let t = v[e.type] ?? o;
74
+ /* @__PURE__ */ g("tbody", { children: x.map((e) => {
75
+ let n = v[e.type] ?? o;
104
76
  return /* @__PURE__ */ _("tr", {
105
77
  "data-component-id": e.id,
106
- onClick: () => l(e),
78
+ onClick: () => u(e),
107
79
  className: "cursor-pointer border-t border-border-subtle transition-colors hover:bg-bg-sunken",
108
80
  children: [
109
81
  /* @__PURE__ */ g("td", {
@@ -112,7 +84,7 @@ var T = ({ components: e, onOpen: l, className: u = "" }) => {
112
84
  className: "flex items-center gap-3",
113
85
  children: [/* @__PURE__ */ g("span", {
114
86
  className: "flex size-8 flex-shrink-0 items-center justify-center rounded-lg bg-[var(--color-accent-soft)]",
115
- children: /* @__PURE__ */ g(t, {
87
+ children: /* @__PURE__ */ g(n, {
116
88
  className: "size-4 text-action-primary-bg",
117
89
  "aria-hidden": "true"
118
90
  })
@@ -121,13 +93,13 @@ var T = ({ components: e, onOpen: l, className: u = "" }) => {
121
93
  children: [/* @__PURE__ */ g("button", {
122
94
  type: "button",
123
95
  onClick: (t) => {
124
- t.stopPropagation(), l(e);
96
+ t.stopPropagation(), u(e);
125
97
  },
126
98
  className: "block max-w-[18rem] truncate rounded text-left font-medium text-text-primary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus",
127
99
  children: e.name
128
100
  }), /* @__PURE__ */ g("span", {
129
101
  className: "block text-xs text-text-secondary",
130
- children: d("component.typeLabelInline", "Type · {{type}}", { type: e.type })
102
+ children: h("component.typeLabelInline", "Type · {{type}}", { type: e.type })
131
103
  })]
132
104
  })]
133
105
  })
@@ -139,27 +111,27 @@ var T = ({ components: e, onOpen: l, className: u = "" }) => {
139
111
  children: [/* @__PURE__ */ g("span", {
140
112
  "aria-hidden": "true",
141
113
  className: "flex size-6 flex-shrink-0 items-center justify-center rounded-full bg-bg-sunken text-[0.625rem] font-semibold text-text-secondary",
142
- children: w(e.ownerName)
114
+ children: b(e.ownerName)
143
115
  }), /* @__PURE__ */ g("span", {
144
116
  className: "max-w-[12rem] truncate text-text-primary",
145
117
  children: e.ownerName
146
118
  })]
147
119
  }) : /* @__PURE__ */ g("span", {
148
120
  className: "text-xs text-text-muted",
149
- title: d("component.noOwner", "No owner recorded"),
150
- children: d("component.unassigned", "Unassigned")
121
+ title: h("component.noOwner", "No owner recorded"),
122
+ children: h("component.unassigned", "Unassigned")
151
123
  })
152
124
  }),
153
125
  /* @__PURE__ */ g("td", {
154
126
  className: "px-3 py-2.5",
155
127
  children: /* @__PURE__ */ g("span", {
156
128
  className: `inline-flex items-center rounded px-2 py-0.5 text-xs ${y[e.lifecycle] ?? "bg-bg-sunken text-text-secondary"}`,
157
- children: d(`component.lifecycle.${e.lifecycle.toLowerCase()}`, e.lifecycle)
129
+ children: h(`component.lifecycle.${e.lifecycle.toLowerCase()}`, e.lifecycle)
158
130
  })
159
131
  }),
160
132
  /* @__PURE__ */ g("td", {
161
133
  className: "px-3 py-2.5",
162
- children: /* @__PURE__ */ g(r, { tier: e.securityTier })
134
+ children: /* @__PURE__ */ g(i, { tier: e.securityTier })
163
135
  }),
164
136
  /* @__PURE__ */ g("td", {
165
137
  className: "px-3 py-2.5",
@@ -173,7 +145,7 @@ var T = ({ components: e, onOpen: l, className: u = "" }) => {
173
145
  }),
174
146
  /* @__PURE__ */ g("td", {
175
147
  className: "px-3 py-2.5",
176
- children: /* @__PURE__ */ g(n, { score: e.overallScore })
148
+ children: /* @__PURE__ */ g(t, { score: e.overallScore })
177
149
  })
178
150
  ]
179
151
  }, e.id);
@@ -182,4 +154,4 @@ var T = ({ components: e, onOpen: l, className: u = "" }) => {
182
154
  })
183
155
  });
184
156
  };
185
- export { T as ComponentsTable };
157
+ export { x as ComponentsTable };
@@ -0,0 +1,38 @@
1
+ import { ComponentSortInput, ScorecardTier } from '../../generated/wspace-types';
2
+ export type ComponentColumn = 'name' | 'owner' | 'lifecycle' | 'tier' | 'version' | 'health';
3
+ export type SortDirection = 'asc' | 'desc';
4
+ export interface ComponentTableSort {
5
+ column: ComponentColumn;
6
+ direction: SortDirection;
7
+ }
8
+ /** The order the page opens with: name, A to Z. */
9
+ export declare const DEFAULT_COMPONENT_SORT: ComponentTableSort;
10
+ /** True when the column is ordered by the server across the whole catalogue. */
11
+ export declare function isServerSortable(column: ComponentColumn): column is Exclude<ComponentColumn, 'tier'>;
12
+ /**
13
+ * The `filter.sort` value for ListComponents. Tier has no server ordering, so
14
+ * it asks for the default order (name, A to Z): once every row is loaded the
15
+ * table re-sorts by tier, and while rows remain the table shows that default.
16
+ */
17
+ export declare function toServerSort(sort: ComponentTableSort): ComponentSortInput;
18
+ /**
19
+ * The sort the table shows. A tier sort is only meaningful over the whole
20
+ * catalogue, so while more rows remain the table shows the default order,
21
+ * which is also the order the server returns for a tier request.
22
+ */
23
+ export declare function displayedSort(sort: ComponentTableSort, hasMore: boolean): ComponentTableSort;
24
+ /**
25
+ * Clicking a header: the same column flips direction; a new column starts in
26
+ * the direction that reads best (names A to Z; scores, tiers and versions best first).
27
+ */
28
+ export declare function nextSort(current: ComponentTableSort, column: ComponentColumn): ComponentTableSort;
29
+ interface TierSortable {
30
+ name: string;
31
+ securityTier: ScorecardTier | null;
32
+ }
33
+ /**
34
+ * Tier order for a fully loaded catalogue. Rows without a tier come last in
35
+ * both directions; ties keep name order.
36
+ */
37
+ export declare function sortRowsByTier<T extends TierSortable>(rows: readonly T[], direction: SortDirection): T[];
38
+ export {};
@@ -0,0 +1,50 @@
1
+ import { ComponentSortDirection as e, ComponentSortField as t, ScorecardTier as n } from "../../generated/wspace-types.js";
2
+ // src/components/components/componentSort.ts
3
+ var r = {
4
+ column: "name",
5
+ direction: "asc"
6
+ }, i = {
7
+ name: t.Name,
8
+ owner: t.Owner,
9
+ lifecycle: t.Lifecycle,
10
+ version: t.Version,
11
+ health: t.Health
12
+ };
13
+ function a(e) {
14
+ return e !== "tier";
15
+ }
16
+ function o(t) {
17
+ let n = a(t.column) ? t.column : "name", o = n === t.column ? t.direction : r.direction;
18
+ return {
19
+ field: i[n],
20
+ direction: o === "asc" ? e.Asc : e.Desc
21
+ };
22
+ }
23
+ function s(e, t) {
24
+ return e.column === "tier" && t ? r : e;
25
+ }
26
+ function c(e, t) {
27
+ return e.column === t ? {
28
+ column: t,
29
+ direction: e.direction === "asc" ? "desc" : "asc"
30
+ } : {
31
+ column: t,
32
+ direction: t === "name" || t === "owner" ? "asc" : "desc"
33
+ };
34
+ }
35
+ var l = {
36
+ [n.Bronze]: 0,
37
+ [n.Silver]: 1,
38
+ [n.Gold]: 2
39
+ };
40
+ function u(e, t) {
41
+ let n = t === "asc" ? 1 : -1;
42
+ return [...e].sort((e, t) => {
43
+ if (e.securityTier === null && t.securityTier === null) return e.name.localeCompare(t.name);
44
+ if (e.securityTier === null) return 1;
45
+ if (t.securityTier === null) return -1;
46
+ let r = (l[e.securityTier] - l[t.securityTier]) * n;
47
+ return r === 0 ? e.name.localeCompare(t.name) : r;
48
+ });
49
+ }
50
+ export { r as DEFAULT_COMPONENT_SORT, s as displayedSort, a as isServerSortable, c as nextSort, u as sortRowsByTier, o as toServerSort };
@@ -1,5 +1,7 @@
1
1
  export { ComponentsTable } from './ComponentsTable';
2
- export type { ComponentsTableProps, ComponentTableRowData, ComponentSortField, } from './ComponentsTable';
2
+ export type { ComponentsTableProps, ComponentTableRowData } from './ComponentsTable';
3
+ export { DEFAULT_COMPONENT_SORT, displayedSort, isServerSortable, nextSort, sortRowsByTier, toServerSort, } from './componentSort';
4
+ export type { ComponentColumn, ComponentTableSort, SortDirection } from './componentSort';
3
5
  export { ComponentTierBadge } from './ComponentTierBadge';
4
6
  export type { ComponentTierBadgeProps } from './ComponentTierBadge';
5
7
  export { ComponentHealthCell } from './ComponentHealthCell';
@@ -1,3 +1,5 @@
1
- export { ComponentsTable } from "./ComponentsTable.js";
1
+ import { ComponentsTable as e } from "./ComponentsTable.js";
2
+ import { DEFAULT_COMPONENT_SORT as t, displayedSort as n, toServerSort as r } from "./componentSort.js";
2
3
  import "./ComponentTierBadge.js";
3
4
  import "./ComponentHealthCell.js";
5
+ export { e as ComponentsTable, t as DEFAULT_COMPONENT_SORT, n as displayedSort, r as toServerSort };