@dudousxd/nestjs-catalog-react 0.4.0 → 0.7.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.
@@ -36,7 +36,16 @@ export declare function Select({ value, onValueChange, options, ariaLabel, place
36
36
  *
37
37
  * Separate from `Select` so a toolbar can still drop a bare one in.
38
38
  */
39
- export declare function SelectField({ label, hint, ...props }: Parameters<typeof Select>[0] & {
39
+ export declare function SelectField({ label, hint, ariaLabel, ...props }: Omit<Parameters<typeof Select>[0], 'ariaLabel'> & {
40
40
  label: string;
41
41
  hint?: ReactNode;
42
+ /**
43
+ * The accessible name, when it should differ from the visible one.
44
+ *
45
+ * Defaults to `label`, so the common case cannot forget it. Overriding is
46
+ * for the case the call sites already use deliberately: a visible "Kind"
47
+ * reads fine beside the fields around it, while a screen reader announcing
48
+ * "Kind" alone has nothing to go on and wants "Connection kind".
49
+ */
50
+ ariaLabel?: string;
42
51
  }): import("react/jsx-runtime").JSX.Element;
package/dist/ui/select.js CHANGED
@@ -25,6 +25,12 @@ export function Select({ value, onValueChange, options, ariaLabel, placeholder =
25
25
  *
26
26
  * Separate from `Select` so a toolbar can still drop a bare one in.
27
27
  */
28
- export function SelectField({ label, hint, ...props }) {
29
- return (_jsxs("label", { className: "block", children: [_jsx("span", { className: "mb-1 block font-mono text-[10px] uppercase tracking-[0.14em] text-zinc-400 dark:text-zinc-500", children: label }), _jsx(Select, { ...props }), hint && (_jsx("span", { className: "mt-1 block text-[11px] text-zinc-400 dark:text-zinc-500", children: hint }))] }));
28
+ export function SelectField({ label, hint, ariaLabel, ...props }) {
29
+ return (
30
+ // `Select` renders a BUTTON, and a label does not implicitly name a button —
31
+ // which is why `Select` requires an accessible name of its own and is given
32
+ // one below. This element is the visible caption and the layout wrapper; the
33
+ // naming is done by `ariaLabel`.
34
+ // biome-ignore lint/a11y/noLabelWithoutControl: see above
35
+ _jsxs("label", { className: "block", children: [_jsx("span", { className: "mb-1 block font-mono text-[10px] uppercase tracking-[0.14em] text-zinc-400 dark:text-zinc-500", children: label }), _jsx(Select, { ...props, ariaLabel: ariaLabel ?? label }), hint && (_jsx("span", { className: "mt-1 block text-[11px] text-zinc-400 dark:text-zinc-500", children: hint }))] }));
30
36
  }
package/dist/ui/switch.js CHANGED
@@ -10,5 +10,11 @@ import { cn } from '../cn';
10
10
  * checkbox reads as "include this in what I am about to submit".
11
11
  */
12
12
  export function Switch({ checked, onCheckedChange, label, hint, disabled, }) {
13
- return (_jsxs("label", { className: "flex items-start gap-2.5", children: [_jsx(BaseSwitch.Root, { checked: checked, onCheckedChange: onCheckedChange, disabled: disabled, className: cn('relative mt-0.5 h-4 w-7 shrink-0 rounded-full border transition-colors outline-none', 'border-zinc-300 bg-zinc-200 dark:border-zinc-700 dark:bg-zinc-800', 'data-[checked]:border-sky-600 data-[checked]:bg-sky-600', 'focus-visible:ring-2 focus-visible:ring-sky-500/30', 'disabled:opacity-40'), children: _jsx(BaseSwitch.Thumb, { className: cn('block h-3 w-3 translate-x-0.5 rounded-full bg-white shadow-sm transition-transform', 'data-[checked]:translate-x-[14px]') }) }), _jsxs("span", { className: "min-w-0", children: [_jsx("span", { className: "block text-[11px] text-zinc-600 dark:text-zinc-300", children: label }), hint && _jsx("span", { className: "block text-[11px] text-zinc-400 dark:text-zinc-500", children: hint })] })] }));
13
+ return (
14
+ // Base UI's Switch renders a hidden native input inside its root, so the
15
+ // implicit association a wrapping label gives DOES resolve here — verified
16
+ // by `switch.spec.tsx`, which asks for the control by its accessible name.
17
+ // The rule cannot see through the component boundary to know that.
18
+ // biome-ignore lint/a11y/noLabelWithoutControl: see above
19
+ _jsxs("label", { className: "flex items-start gap-2.5", children: [_jsx(BaseSwitch.Root, { checked: checked, onCheckedChange: onCheckedChange, disabled: disabled, className: cn('relative mt-0.5 h-4 w-7 shrink-0 rounded-full border transition-colors outline-none', 'border-zinc-300 bg-zinc-200 dark:border-zinc-700 dark:bg-zinc-800', 'data-[checked]:border-sky-600 data-[checked]:bg-sky-600', 'focus-visible:ring-2 focus-visible:ring-sky-500/30', 'disabled:opacity-40'), children: _jsx(BaseSwitch.Thumb, { className: cn('block h-3 w-3 translate-x-0.5 rounded-full bg-white shadow-sm transition-transform', 'data-[checked]:translate-x-[14px]') }) }), _jsxs("span", { className: "min-w-0", children: [_jsx("span", { className: "block text-[11px] text-zinc-600 dark:text-zinc-300", children: label }), hint && _jsx("span", { className: "block text-[11px] text-zinc-400 dark:text-zinc-500", children: hint })] })] }));
14
20
  }
@@ -137,6 +137,49 @@ export function toFlowEdges(edges, nodes, brokenEdgeIds) {
137
137
  };
138
138
  });
139
139
  }
140
+ /** Who feeds each node, by node id. Every node gets an entry, most of them empty. */
141
+ function feedersByNode(nodes, edges) {
142
+ const incoming = new Map();
143
+ for (const node of nodes)
144
+ incoming.set(node.id, []);
145
+ for (const edge of edges) {
146
+ const list = incoming.get(edge.to);
147
+ if (list)
148
+ list.push(edge.from);
149
+ }
150
+ return incoming;
151
+ }
152
+ /**
153
+ * Move one node to one column past the deepest thing feeding it, never left.
154
+ *
155
+ * Only ever increasing is what makes it safe to call repeatedly on the same
156
+ * node, which is what the relaxation below relies on.
157
+ */
158
+ function placeAfterFeeders(id, column, feeders) {
159
+ const depth = feeders.length === 0 ? 0 : Math.max(...feeders.map((from) => (column.get(from) ?? 0) + 1));
160
+ column.set(id, Math.max(depth, column.get(id) ?? 0));
161
+ }
162
+ /**
163
+ * Layer a graph that has no usable run order, by longest path.
164
+ *
165
+ * Relax every node repeatedly until nothing moves. With no cycle that settles in
166
+ * at most one pass per node; with a cycle the pass cap is what stops it, and the
167
+ * nodes on the cycle end up wherever the cap left them. So a graph with a loop
168
+ * still draws — badly — rather than hanging while somebody is trying to see the
169
+ * loop they need to remove.
170
+ */
171
+ function relaxColumns(nodes, incoming, column) {
172
+ for (let pass = 0; pass < nodes.length + 1; pass += 1) {
173
+ const before = [...column.values()].join(',');
174
+ for (const node of nodes)
175
+ placeAfterFeeders(node.id, column, incoming.get(node.id) ?? []);
176
+ if ([...column.values()].join(',') === before)
177
+ break;
178
+ }
179
+ for (const node of nodes)
180
+ if (!column.has(node.id))
181
+ column.set(node.id, 0);
182
+ }
140
183
  /**
141
184
  * Which column each node belongs in, left to right.
142
185
  *
@@ -148,50 +191,23 @@ export function toFlowEdges(edges, nodes, brokenEdgeIds) {
148
191
  *
149
192
  * `workflowRunOrder` throws on a graph it will not run, which is a graph
150
193
  * somebody is in the middle of drawing — half-wired, or with a loop they are
151
- * about to remove. That is exactly when a canvas most needs to draw, so the
152
- * fallback below layers the graph by longest path anyway, capping the relaxation
153
- * at the node count so a cycle cannot spin it forever.
194
+ * about to remove. That is exactly when a canvas most needs to draw, so
195
+ * `relaxColumns` layers it by longest path anyway.
154
196
  */
155
197
  function columnsFor(nodes, edges) {
156
- const incoming = new Map();
157
- for (const node of nodes)
158
- incoming.set(node.id, []);
159
- for (const edge of edges) {
160
- const list = incoming.get(edge.to);
161
- if (list)
162
- list.push(edge.from);
163
- }
198
+ const incoming = feedersByNode(nodes, edges);
164
199
  const column = new Map();
165
- const place = (id) => {
166
- const feeders = incoming.get(id) ?? [];
167
- const depth = feeders.length === 0 ? 0 : Math.max(...feeders.map((from) => (column.get(from) ?? 0) + 1));
168
- column.set(id, Math.max(depth, column.get(id) ?? 0));
169
- };
170
200
  try {
171
201
  // Topological order, so one pass is exact: everything feeding a node has
172
202
  // already been placed by the time the node is reached.
173
- for (const entry of workflowRunOrder({ nodes, edges }))
174
- place(entry.node.id);
175
- return column;
203
+ for (const entry of workflowRunOrder({ nodes, edges })) {
204
+ placeAfterFeeders(entry.node.id, column, incoming.get(entry.node.id) ?? []);
205
+ }
176
206
  }
177
207
  catch {
178
- // The graph is not runnable yet. Relax repeatedly instead; with no cycle
179
- // this settles in at most one pass per node, and with a cycle the cap is
180
- // what stops it. Nodes on the cycle end up wherever the cap left them, so a
181
- // graph with a loop still draws — badly — rather than hanging while
182
- // somebody is trying to see the loop they need to remove.
183
- for (let pass = 0; pass < nodes.length + 1; pass += 1) {
184
- const before = [...column.values()].join(',');
185
- for (const node of nodes)
186
- place(node.id);
187
- if ([...column.values()].join(',') === before)
188
- break;
189
- }
190
- for (const node of nodes)
191
- if (!column.has(node.id))
192
- column.set(node.id, 0);
193
- return column;
208
+ relaxColumns(nodes, incoming, column);
194
209
  }
210
+ return column;
195
211
  }
196
212
  /**
197
213
  * Lay the graph out left to right, one column per dependency depth.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudousxd/nestjs-catalog-react",
3
- "version": "0.4.0",
3
+ "version": "0.7.1",
4
4
  "description": "Ready-made React screens for @dudousxd/nestjs-catalog — a model manager and a generic object explorer you can drop into your own app shell.",
5
5
  "license": "MIT",
6
6
  "author": "Davide Carvalho",
@@ -63,7 +63,13 @@
63
63
  "react": ">=18",
64
64
  "react-dom": ">=18",
65
65
  "recharts": ">=2.12.0",
66
- "@dudousxd/nestjs-catalog": ">=0.1.0"
66
+ "@dudousxd/nestjs-catalog": ">=0.1.0",
67
+ "@tanstack/react-table": ">=9",
68
+ "@tiptap/react": ">=3",
69
+ "@tiptap/starter-kit": ">=3",
70
+ "@tiptap/pm": ">=3",
71
+ "tiptap-markdown": ">=0.9",
72
+ "@tiptap/core": ">=3"
67
73
  },
68
74
  "devDependencies": {
69
75
  "@base-ui/react": "1.6.0",
@@ -94,7 +100,13 @@
94
100
  "recharts": "2.15.4",
95
101
  "tailwind-merge": "3.4.1",
96
102
  "typescript": "5.9.3",
97
- "@dudousxd/nestjs-catalog": "0.3.1"
103
+ "@tanstack/react-table": "9.0.0",
104
+ "@tiptap/react": "3.29.2",
105
+ "@tiptap/starter-kit": "3.29.2",
106
+ "@tiptap/pm": "3.29.2",
107
+ "tiptap-markdown": "0.9.0",
108
+ "@tiptap/core": "3.29.2",
109
+ "@dudousxd/nestjs-catalog": "0.4.1"
98
110
  },
99
111
  "dependencies": {
100
112
  "clsx": "2.1.1",