@bevel-software/platform-core-frontend 0.4.0 → 0.4.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.
Files changed (30) hide show
  1. package/package.json +2 -2
  2. package/src/core/__tests__/ShellRoutes.test.tsx +95 -95
  3. package/src/lib/utils.ts +138 -138
  4. package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +156 -156
  5. package/src/modules/admin/components/UserAccountsPage.tsx +353 -353
  6. package/src/modules/layout/components/MaintenanceOverlay.tsx +104 -104
  7. package/src/modules/library/__tests__/DetailDialog.test.tsx +200 -200
  8. package/src/modules/library/__tests__/loadout.test.tsx +72 -72
  9. package/src/modules/library/__tests__/status.test.ts +117 -117
  10. package/src/modules/library/components/ChangeRequestDock.tsx +47 -47
  11. package/src/modules/library/components/CompareView.tsx +357 -357
  12. package/src/modules/library/components/DetailDialog.tsx +566 -566
  13. package/src/modules/library/components/GearIcon.tsx +12 -12
  14. package/src/modules/library/components/LibraryCard.tsx +132 -132
  15. package/src/modules/library/components/LibraryPage.tsx +254 -254
  16. package/src/modules/library/components/LoadoutSidebar.tsx +156 -156
  17. package/src/modules/library/components/StatusGem.tsx +21 -21
  18. package/src/modules/library/components/SuggestChange.tsx +171 -171
  19. package/src/modules/library/components/particles.ts +50 -50
  20. package/src/modules/library/library.css +320 -320
  21. package/src/modules/library/state/loadout.tsx +129 -129
  22. package/src/modules/library/utils/status.ts +116 -116
  23. package/src/modules/secrets-vault/components/SecretsPage.tsx +276 -276
  24. package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +51 -51
  25. package/src/modules/toolbar/components/AppSwitcher.tsx +108 -108
  26. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +548 -548
  27. package/src/modules/workspace/components/FileExplorer.tsx +1068 -1068
  28. package/src/modules/workspace/components/FileViewer.tsx +906 -906
  29. package/src/modules/workspace/utils/fileTree.ts +179 -179
  30. package/src/shared/components/PageShell.tsx +51 -51
@@ -1,171 +1,171 @@
1
- import { useEffect, useRef, useState, type RefObject } from 'react';
2
-
3
- interface SuggestChangeProps {
4
- /** The file-viewer element whose text selections trigger the chip. */
5
- containerRef: RefObject<HTMLElement | null>;
6
- /** Raw content of the file on screen (selection must occur in it verbatim). */
7
- raw: string | null;
8
- /** Commit the suggestion; resolves when it landed on the suggestion branch. */
9
- onSubmit(find: string, replace: string, note: string): Promise<void>;
10
- }
11
-
12
- interface ChipState {
13
- text: string;
14
- left: number;
15
- top: number;
16
- }
17
-
18
- /**
19
- * Select-text → "Suggest a change" chip → small form. The selection must be a
20
- * single-line stretch that appears verbatim in the raw file content (rendered
21
- * markdown can differ from source — same guard as the approved mock).
22
- */
23
- export function SuggestChange({ containerRef, raw, onSubmit }: SuggestChangeProps) {
24
- const [chip, setChip] = useState<ChipState | null>(null);
25
- const [form, setForm] = useState<ChipState | null>(null);
26
- const [replaceValue, setReplaceValue] = useState('');
27
- const [note, setNote] = useState('');
28
- const [busy, setBusy] = useState(false);
29
- const [error, setError] = useState<string | null>(null);
30
- const rootRef = useRef<HTMLDivElement>(null);
31
-
32
- useEffect(() => {
33
- function onMouseUp(e: MouseEvent) {
34
- if (rootRef.current?.contains(e.target as Node)) return;
35
- const sel = window.getSelection();
36
- const text = sel?.toString().trim() ?? '';
37
- const container = containerRef.current;
38
- if (
39
- !container ||
40
- !sel ||
41
- sel.rangeCount === 0 ||
42
- !sel.anchorNode ||
43
- !container.contains(sel.anchorNode) ||
44
- text.length <= 2 ||
45
- text.includes('\n')
46
- ) {
47
- setChip(null);
48
- return;
49
- }
50
- const r = sel.getRangeAt(0).getBoundingClientRect();
51
- setChip({
52
- text,
53
- left: Math.max(8, r.left + r.width / 2 - 70),
54
- top: Math.max(8, r.top - 40),
55
- });
56
- }
57
- document.addEventListener('mouseup', onMouseUp);
58
- return () => document.removeEventListener('mouseup', onMouseUp);
59
- }, [containerRef]);
60
-
61
- useEffect(() => {
62
- function onKeyDown(e: KeyboardEvent) {
63
- if (e.key === 'Escape' && (form || chip)) {
64
- e.stopPropagation();
65
- setForm(null);
66
- setChip(null);
67
- }
68
- }
69
- if (!form && !chip) return;
70
- document.addEventListener('keydown', onKeyDown, true);
71
- return () => document.removeEventListener('keydown', onKeyDown, true);
72
- }, [form, chip]);
73
-
74
- async function submit() {
75
- if (!form) return;
76
- const replace = replaceValue.trim();
77
- if (!replace || replace === form.text) {
78
- setForm(null);
79
- return;
80
- }
81
- if (raw !== null && !raw.includes(form.text)) {
82
- setError('Select a plain stretch of text to suggest on.');
83
- return;
84
- }
85
- setBusy(true);
86
- setError(null);
87
- try {
88
- await onSubmit(form.text, replace, note.trim());
89
- setForm(null);
90
- window.getSelection()?.removeAllRanges();
91
- } catch (err) {
92
- setError(err instanceof Error ? err.message : "Couldn't save your suggestion.");
93
- } finally {
94
- setBusy(false);
95
- }
96
- }
97
-
98
- return (
99
- <div ref={rootRef}>
100
- {chip && !form && (
101
- <button
102
- type="button"
103
- className="fixed z-[85] flex items-center gap-1.5 rounded-full bg-slate-800 px-3.5 py-1.5 text-xs font-semibold text-white shadow-[0_8px_24px_rgba(22,35,58,0.32)] hover:bg-slate-700"
104
- style={{ left: chip.left, top: chip.top }}
105
- onClick={() => {
106
- setForm(chip);
107
- setReplaceValue(chip.text);
108
- setNote('');
109
- setError(null);
110
- setChip(null);
111
- }}
112
- >
113
- Suggest a change
114
- </button>
115
- )}
116
- {form && (
117
- <div
118
- className="fixed z-[85] w-[290px] rounded-[14px] border border-slate-200 bg-white p-4 shadow-[0_16px_44px_rgba(22,35,58,0.24)]"
119
- style={{
120
- left: Math.min(Math.max(8, form.left), window.innerWidth - 300),
121
- top: Math.min(Math.max(8, form.top + 34), window.innerHeight - 260),
122
- }}
123
- role="dialog"
124
- aria-label="Suggest a change"
125
- >
126
- <h5 className="mb-2 text-[12.5px] font-bold text-slate-800">Suggest a change</h5>
127
- <div className="mb-1 max-h-[58px] overflow-auto rounded-md bg-[#fdecec] px-2 py-1 font-mono text-[11px] text-[#b91c1c] line-through">
128
- {form.text}
129
- </div>
130
- <label className="mb-1 mt-2 block text-[10px] font-bold uppercase tracking-[.07em] text-slate-400">
131
- Your version
132
- <textarea
133
- rows={3}
134
- className="mt-1 w-full resize-y rounded-lg border border-slate-200 px-2 py-1.5 text-xs font-normal normal-case tracking-normal text-slate-800 outline-none focus:border-[#0d9488]"
135
- value={replaceValue}
136
- onChange={(e) => setReplaceValue(e.target.value)}
137
- />
138
- </label>
139
- <label className="mb-1 mt-2 block text-[10px] font-bold uppercase tracking-[.07em] text-slate-400">
140
- Note (optional)
141
- <input
142
- className="mt-1 w-full rounded-lg border border-slate-200 px-2 py-1.5 text-xs font-normal normal-case tracking-normal text-slate-800 outline-none focus:border-[#0d9488]"
143
- placeholder="Why this change?"
144
- value={note}
145
- onChange={(e) => setNote(e.target.value)}
146
- />
147
- </label>
148
- {error && <div className="mt-1 text-[11px] text-[#c53030]">{error}</div>}
149
- <div className="mt-3 flex justify-end gap-2">
150
- <button
151
- type="button"
152
- className="rounded-[10px] border border-slate-200 px-3.5 py-2 text-[12.5px] font-semibold text-slate-500 hover:text-slate-800"
153
- onClick={() => setForm(null)}
154
- disabled={busy}
155
- >
156
- Cancel
157
- </button>
158
- <button
159
- type="button"
160
- className="rounded-[10px] bg-gradient-to-br from-[#0d9488] to-[#0f766e] px-4 py-2 text-[12.5px] font-bold text-white shadow-[0_4px_14px_rgba(13,148,136,0.22)] disabled:opacity-60"
161
- onClick={() => void submit()}
162
- disabled={busy}
163
- >
164
- {busy ? 'Saving…' : 'Suggest'}
165
- </button>
166
- </div>
167
- </div>
168
- )}
169
- </div>
170
- );
171
- }
1
+ import { useEffect, useRef, useState, type RefObject } from 'react';
2
+
3
+ interface SuggestChangeProps {
4
+ /** The file-viewer element whose text selections trigger the chip. */
5
+ containerRef: RefObject<HTMLElement | null>;
6
+ /** Raw content of the file on screen (selection must occur in it verbatim). */
7
+ raw: string | null;
8
+ /** Commit the suggestion; resolves when it landed on the suggestion branch. */
9
+ onSubmit(find: string, replace: string, note: string): Promise<void>;
10
+ }
11
+
12
+ interface ChipState {
13
+ text: string;
14
+ left: number;
15
+ top: number;
16
+ }
17
+
18
+ /**
19
+ * Select-text → "Suggest a change" chip → small form. The selection must be a
20
+ * single-line stretch that appears verbatim in the raw file content (rendered
21
+ * markdown can differ from source — same guard as the approved mock).
22
+ */
23
+ export function SuggestChange({ containerRef, raw, onSubmit }: SuggestChangeProps) {
24
+ const [chip, setChip] = useState<ChipState | null>(null);
25
+ const [form, setForm] = useState<ChipState | null>(null);
26
+ const [replaceValue, setReplaceValue] = useState('');
27
+ const [note, setNote] = useState('');
28
+ const [busy, setBusy] = useState(false);
29
+ const [error, setError] = useState<string | null>(null);
30
+ const rootRef = useRef<HTMLDivElement>(null);
31
+
32
+ useEffect(() => {
33
+ function onMouseUp(e: MouseEvent) {
34
+ if (rootRef.current?.contains(e.target as Node)) return;
35
+ const sel = window.getSelection();
36
+ const text = sel?.toString().trim() ?? '';
37
+ const container = containerRef.current;
38
+ if (
39
+ !container ||
40
+ !sel ||
41
+ sel.rangeCount === 0 ||
42
+ !sel.anchorNode ||
43
+ !container.contains(sel.anchorNode) ||
44
+ text.length <= 2 ||
45
+ text.includes('\n')
46
+ ) {
47
+ setChip(null);
48
+ return;
49
+ }
50
+ const r = sel.getRangeAt(0).getBoundingClientRect();
51
+ setChip({
52
+ text,
53
+ left: Math.max(8, r.left + r.width / 2 - 70),
54
+ top: Math.max(8, r.top - 40),
55
+ });
56
+ }
57
+ document.addEventListener('mouseup', onMouseUp);
58
+ return () => document.removeEventListener('mouseup', onMouseUp);
59
+ }, [containerRef]);
60
+
61
+ useEffect(() => {
62
+ function onKeyDown(e: KeyboardEvent) {
63
+ if (e.key === 'Escape' && (form || chip)) {
64
+ e.stopPropagation();
65
+ setForm(null);
66
+ setChip(null);
67
+ }
68
+ }
69
+ if (!form && !chip) return;
70
+ document.addEventListener('keydown', onKeyDown, true);
71
+ return () => document.removeEventListener('keydown', onKeyDown, true);
72
+ }, [form, chip]);
73
+
74
+ async function submit() {
75
+ if (!form) return;
76
+ const replace = replaceValue.trim();
77
+ if (!replace || replace === form.text) {
78
+ setForm(null);
79
+ return;
80
+ }
81
+ if (raw !== null && !raw.includes(form.text)) {
82
+ setError('Select a plain stretch of text to suggest on.');
83
+ return;
84
+ }
85
+ setBusy(true);
86
+ setError(null);
87
+ try {
88
+ await onSubmit(form.text, replace, note.trim());
89
+ setForm(null);
90
+ window.getSelection()?.removeAllRanges();
91
+ } catch (err) {
92
+ setError(err instanceof Error ? err.message : "Couldn't save your suggestion.");
93
+ } finally {
94
+ setBusy(false);
95
+ }
96
+ }
97
+
98
+ return (
99
+ <div ref={rootRef}>
100
+ {chip && !form && (
101
+ <button
102
+ type="button"
103
+ className="fixed z-[85] flex items-center gap-1.5 rounded-full bg-slate-800 px-3.5 py-1.5 text-xs font-semibold text-white shadow-[0_8px_24px_rgba(22,35,58,0.32)] hover:bg-slate-700"
104
+ style={{ left: chip.left, top: chip.top }}
105
+ onClick={() => {
106
+ setForm(chip);
107
+ setReplaceValue(chip.text);
108
+ setNote('');
109
+ setError(null);
110
+ setChip(null);
111
+ }}
112
+ >
113
+ Suggest a change
114
+ </button>
115
+ )}
116
+ {form && (
117
+ <div
118
+ className="fixed z-[85] w-[290px] rounded-[14px] border border-slate-200 bg-white p-4 shadow-[0_16px_44px_rgba(22,35,58,0.24)]"
119
+ style={{
120
+ left: Math.min(Math.max(8, form.left), window.innerWidth - 300),
121
+ top: Math.min(Math.max(8, form.top + 34), window.innerHeight - 260),
122
+ }}
123
+ role="dialog"
124
+ aria-label="Suggest a change"
125
+ >
126
+ <h5 className="mb-2 text-[12.5px] font-bold text-slate-800">Suggest a change</h5>
127
+ <div className="mb-1 max-h-[58px] overflow-auto rounded-md bg-[#fdecec] px-2 py-1 font-mono text-[11px] text-[#b91c1c] line-through">
128
+ {form.text}
129
+ </div>
130
+ <label className="mb-1 mt-2 block text-[10px] font-bold uppercase tracking-[.07em] text-slate-400">
131
+ Your version
132
+ <textarea
133
+ rows={3}
134
+ className="mt-1 w-full resize-y rounded-lg border border-slate-200 px-2 py-1.5 text-xs font-normal normal-case tracking-normal text-slate-800 outline-none focus:border-[#0d9488]"
135
+ value={replaceValue}
136
+ onChange={(e) => setReplaceValue(e.target.value)}
137
+ />
138
+ </label>
139
+ <label className="mb-1 mt-2 block text-[10px] font-bold uppercase tracking-[.07em] text-slate-400">
140
+ Note (optional)
141
+ <input
142
+ className="mt-1 w-full rounded-lg border border-slate-200 px-2 py-1.5 text-xs font-normal normal-case tracking-normal text-slate-800 outline-none focus:border-[#0d9488]"
143
+ placeholder="Why this change?"
144
+ value={note}
145
+ onChange={(e) => setNote(e.target.value)}
146
+ />
147
+ </label>
148
+ {error && <div className="mt-1 text-[11px] text-[#c53030]">{error}</div>}
149
+ <div className="mt-3 flex justify-end gap-2">
150
+ <button
151
+ type="button"
152
+ className="rounded-[10px] border border-slate-200 px-3.5 py-2 text-[12.5px] font-semibold text-slate-500 hover:text-slate-800"
153
+ onClick={() => setForm(null)}
154
+ disabled={busy}
155
+ >
156
+ Cancel
157
+ </button>
158
+ <button
159
+ type="button"
160
+ className="rounded-[10px] bg-gradient-to-br from-[#0d9488] to-[#0f766e] px-4 py-2 text-[12.5px] font-bold text-white shadow-[0_4px_14px_rgba(13,148,136,0.22)] disabled:opacity-60"
161
+ onClick={() => void submit()}
162
+ disabled={busy}
163
+ >
164
+ {busy ? 'Saving…' : 'Suggest'}
165
+ </button>
166
+ </div>
167
+ </div>
168
+ )}
169
+ </div>
170
+ );
171
+ }
@@ -1,50 +1,50 @@
1
- import type { LoadoutKind } from '../state/loadout';
2
-
3
- /**
4
- * Particle flight from a card to its freshly-landed loadout row (Web
5
- * Animations API, ~14 particles, green for skills / teal for integrations) —
6
- * straight from the approved mock. Called after the add re-render; looks the
7
- * row up by its `data-loadout-key` and quietly no-ops if it isn't there
8
- * (e.g. reduced test DOM).
9
- */
10
- export function flyParticles(fromRect: DOMRect, kind: LoadoutKind, id: string): void {
11
- requestAnimationFrame(() => {
12
- const row = document.querySelector<HTMLElement>(
13
- `[data-loadout-key="${CSS.escape(`${kind}:${id}`)}"]`,
14
- );
15
- if (!row) return;
16
- row.classList.add('lib-slot-arrive');
17
- const to = row.getBoundingClientRect();
18
- const sx = fromRect.left + fromRect.width / 2;
19
- const sy = fromRect.top + fromRect.height / 2;
20
- const ex = to.left + to.width / 2;
21
- const ey = to.top + to.height / 2;
22
- for (let i = 0; i < 14; i++) {
23
- const p = document.createElement('div');
24
- p.className = 'lib-particle' + (kind === 'integration' ? ' lib-particle-tool' : '');
25
- const size = 4 + Math.random() * 5;
26
- p.style.width = `${size}px`;
27
- p.style.height = `${size}px`;
28
- document.body.appendChild(p);
29
- // Start scattered across the card, arc upward toward the row.
30
- const jx = sx + (Math.random() - 0.5) * fromRect.width * 0.7;
31
- const jy = sy + (Math.random() - 0.5) * fromRect.height * 0.6;
32
- const mx = (jx + ex) / 2 + (Math.random() - 0.5) * 120;
33
- const my = (jy + ey) / 2 - (50 + Math.random() * 90);
34
- const animation = p.animate(
35
- [
36
- { transform: `translate(${jx}px,${jy}px) scale(1)`, opacity: 1 },
37
- { transform: `translate(${mx}px,${my}px) scale(.9)`, opacity: 0.95, offset: 0.55 },
38
- { transform: `translate(${ex}px,${ey}px) scale(.2)`, opacity: 0 },
39
- ],
40
- {
41
- duration: 480 + Math.random() * 280,
42
- delay: Math.random() * 100,
43
- easing: 'cubic-bezier(.3,.1,.3,1)',
44
- fill: 'forwards',
45
- },
46
- );
47
- animation.onfinish = () => p.remove();
48
- }
49
- });
50
- }
1
+ import type { LoadoutKind } from '../state/loadout';
2
+
3
+ /**
4
+ * Particle flight from a card to its freshly-landed loadout row (Web
5
+ * Animations API, ~14 particles, green for skills / teal for integrations) —
6
+ * straight from the approved mock. Called after the add re-render; looks the
7
+ * row up by its `data-loadout-key` and quietly no-ops if it isn't there
8
+ * (e.g. reduced test DOM).
9
+ */
10
+ export function flyParticles(fromRect: DOMRect, kind: LoadoutKind, id: string): void {
11
+ requestAnimationFrame(() => {
12
+ const row = document.querySelector<HTMLElement>(
13
+ `[data-loadout-key="${CSS.escape(`${kind}:${id}`)}"]`,
14
+ );
15
+ if (!row) return;
16
+ row.classList.add('lib-slot-arrive');
17
+ const to = row.getBoundingClientRect();
18
+ const sx = fromRect.left + fromRect.width / 2;
19
+ const sy = fromRect.top + fromRect.height / 2;
20
+ const ex = to.left + to.width / 2;
21
+ const ey = to.top + to.height / 2;
22
+ for (let i = 0; i < 14; i++) {
23
+ const p = document.createElement('div');
24
+ p.className = 'lib-particle' + (kind === 'integration' ? ' lib-particle-tool' : '');
25
+ const size = 4 + Math.random() * 5;
26
+ p.style.width = `${size}px`;
27
+ p.style.height = `${size}px`;
28
+ document.body.appendChild(p);
29
+ // Start scattered across the card, arc upward toward the row.
30
+ const jx = sx + (Math.random() - 0.5) * fromRect.width * 0.7;
31
+ const jy = sy + (Math.random() - 0.5) * fromRect.height * 0.6;
32
+ const mx = (jx + ex) / 2 + (Math.random() - 0.5) * 120;
33
+ const my = (jy + ey) / 2 - (50 + Math.random() * 90);
34
+ const animation = p.animate(
35
+ [
36
+ { transform: `translate(${jx}px,${jy}px) scale(1)`, opacity: 1 },
37
+ { transform: `translate(${mx}px,${my}px) scale(.9)`, opacity: 0.95, offset: 0.55 },
38
+ { transform: `translate(${ex}px,${ey}px) scale(.2)`, opacity: 0 },
39
+ ],
40
+ {
41
+ duration: 480 + Math.random() * 280,
42
+ delay: Math.random() * 100,
43
+ easing: 'cubic-bezier(.3,.1,.3,1)',
44
+ fill: 'forwards',
45
+ },
46
+ );
47
+ animation.onfinish = () => p.remove();
48
+ }
49
+ });
50
+ }