File size: 43,986 Bytes
4cfab62
 
 
 
 
 
 
 
 
 
 
 
 
 
10ab9ba
4cfab62
10ab9ba
1d4419b
 
 
 
4cfab62
 
 
 
 
 
 
 
 
52c6936
 
 
 
 
 
 
 
4cfab62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52c6936
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19b91ce
4cfab62
19b91ce
 
 
 
 
 
 
4cfab62
 
 
 
 
 
 
 
 
 
1d4419b
 
 
 
4cfab62
 
 
 
 
 
1d4419b
4cfab62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19b91ce
4cfab62
 
 
 
 
 
 
 
 
 
 
 
19b91ce
4cfab62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1d4419b
 
 
4cfab62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52c6936
4cfab62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c1fc133
4cfab62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74f72af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4cfab62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74f72af
 
 
 
 
 
 
 
 
 
 
 
 
4cfab62
 
74f72af
4cfab62
74f72af
4cfab62
 
74f72af
 
4cfab62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72b6f27
4cfab62
72b6f27
4cfab62
 
 
 
 
 
 
 
 
 
72b6f27
4cfab62
72b6f27
4cfab62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72b6f27
 
4cfab62
 
 
72b6f27
 
4cfab62
19b91ce
4cfab62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10ab9ba
 
 
4cfab62
 
 
10ab9ba
 
 
4cfab62
 
 
10ab9ba
 
 
 
 
 
4cfab62
 
 
 
 
1d4419b
 
 
10ab9ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4cfab62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10ab9ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4cfab62
 
 
 
 
52c6936
 
 
 
 
 
 
 
 
 
4cfab62
52c6936
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4cfab62
 
 
 
 
 
 
52c6936
 
 
 
 
 
 
 
 
4cfab62
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
// ---------------------------------------------------------------------------
// shell/NavExtras.tsx — C-SCHEMA (wave 2026-08-02): the database list's
// three-dots menu, folder heads, and the schema drawer.
//
// Kept out of Shell.tsx so the shell's frame stays readable: Shell owns the
// STATE (prefs, open folders, which schema is open) and the save round-trip;
// these components own only their own popover/drawer chrome. Menus are
// position:fixed against the trigger — the rail scrolls and clips, so an
// absolutely-positioned child could never escape it (the same lesson as the
// collapsed-rail tooltip).
// ---------------------------------------------------------------------------

import { useEffect, useRef, useState } from "react";
import type { ReactNode } from "react";
import { fetchSchema, saveSchemaMap } from "./nav";
import type { NavFolder, SchemaPayload, TableFootprint } from "./nav";
import { WORKSPACE_STALE_EVENT, signal } from "../apiContract";
// W51-T31 — the rail's own overlays join the ONE Escape stack (C8 / DESIGN.md §4). Each
// registration is gated on that overlay's OWN open flag: the arbiter preventDefaults a claimed
// Escape, and Escape is also the browser's cancel-this-drag key for the folder drag-and-drop.
import { useEscapeClose } from "../ui/useEscapeClose";
// ⚠ WAVE 19 R8 / C1 — IMPORTED, NEVER REDEFINED, and the contract says so in as
// many words ("Shapes/tones = the grid's existing vocabulary verbatim (12
// shapes, 5 tones); B imports, never redefines"). A second copy of this
// vocabulary in the shell is a whitelist that can drift by one member from the
// one the host validates against — and a tone the server does not recognise
// degrades to the default, so the user's choice disappears on reload with
// nothing on screen to say why. These are READ-ONLY imports across the session
// fence: `customer-grid/**` is another session's tree this wave (HARD RULE 3).
import "./navExtras.css";
// ⭐ W46-T45 / C6 — AFTER `navExtras.css`, DELIBERATELY AND ALWAYS. The wave sheet
// re-shapes the schema drawer onto the Settings modal's values, so it must land
// LATER in the bundle than the sheet it overrides; a wave sheet is imported by
// the component that owns its surface and never added to `index.css`, which
// would give a lane-local override a global blast radius. Every selector in it
// is additionally anchored on `.shell-schema`, so it wins on specificity too
// and does not rest on import order alone.
import "../styles/wave46/schema-viewer.css";

/**
 * WAVE 21 item 12 (ruling R11) — HORIZONTAL, and it is the same three dots turned
 * 90°, not a different mark.
 *
 * The rail and the views list are read as one surface, and they were drawing the
 * "there is a menu here" affordance two different ways: this glyph stacked its
 * circles (cx fixed, cy walking) while `ViewSidebar`'s row buttons have always
 * rendered three MIDDLE DOTs on the baseline. Same promise, two pictures — the
 * thing R11 names. Only the axis moves: radius, viewBox and the 14px box in
 * `navExtras.css` are untouched, so the hit target and the optical weight are
 * exactly what shipped.
 */
function DotsIcon() {
  return (
    <svg viewBox="0 0 16 16" aria-hidden="true" className="shell-dots-icon">
      <circle cx="3.2" cy="8" r="1.35" />
      <circle cx="8" cy="8" r="1.35" />
      <circle cx="12.8" cy="8" r="1.35" />
    </svg>
  );
}

/**
 * W46-T45 (owner instruction 23) — the mark on "View schema".
 *
 * ⛔ LOCAL, NOT `customer-grid/iconShapes.ts`. That module is the GRID's shape
 * vocabulary (the 12 shapes a database icon may take) and belongs to another
 * session's tree; DESIGN.md §4 counts shell glyphs as part of the same
 * vocabulary but the shell draws its own, exactly as `DotsIcon`, `PlusIcon` and
 * `FixedFolderMark` above already do. Same grammar as `PlusIcon`: a 16-square
 * viewBox, `aria-hidden` because the row's own words are the label, no fill,
 * `currentColor` for the stroke, and every dimension in CSS rather than an
 * inline style.
 *
 * ⚠ A TABLE GRID, NOT A FOLDER. The folder mark already means "a folder in the
 * rail" here, and a second meaning on the same picture is the drift a shared
 * vocabulary exists to prevent. Header rule plus one column divider reads as
 * "the shape of the data", which is what the panel behind it shows.
 */
function SchemaIcon() {
  return (
    <svg
      viewBox="0 0 16 16"
      aria-hidden="true"
      fill="none"
      stroke="currentColor"
      className="shell-schema-glyph"
    >
      <rect x="2.4" y="3.2" width="11.2" height="9.6" rx="1.4" />
      <path d="M2.4 6.5h11.2M2.4 9.65h11.2M6.6 6.5v6.3" />
    </svg>
  );
}

function FixedFolderMark() {
  return (
    <svg
      viewBox="0 0 16 16"
      aria-hidden="true"
      className="shell-nav-icon cg-folder-mark"
      style={{ fill: "var(--lp-purple-deep)", stroke: "var(--lp-purple-deep)", opacity: 1 }}
    >
      <path d="M2.4 12.6V4.2a.6.6 0 0 1 .6-.6h3.2l1.5 1.7h5.3a.6.6 0 0 1 .6.6v6.7a.6.6 0 0 1-.6.6H3a.6.6 0 0 1-.6-.6z" />
    </svg>
  );
}

/** A fixed-position popover anchored to a trigger rect, closed on outside
 *  click or Escape. Small on purpose — the shell does not import the grid's
 *  Popover, so the two chrome trees stay independently deletable. */
function useMenu() {
  const [at, setAt] = useState<{ x: number; y: number } | null>(null);
  const ref = useRef<HTMLDivElement>(null);
  // W51-T31 — Escape resolves through the shared stack, so a menu opened while a dialog is
  // already up no longer races it on listener registration order. Outside-click stays local:
  // this popover is not portalled and has no anchor to hand the grid's primitive.
  useEscapeClose(at !== null, () => setAt(null), { container: () => ref.current });
  useEffect(() => {
    if (!at) return;
    const onDown = (e: MouseEvent) => {
      if (ref.current && !ref.current.contains(e.target as Node)) setAt(null);
    };
    document.addEventListener("mousedown", onDown, true);
    return () => document.removeEventListener("mousedown", onDown, true);
  }, [at]);
  const openFrom = (el: HTMLElement) => {
    const r = el.getBoundingClientRect();
    setAt({ x: Math.round(r.right + 4), y: Math.round(r.top) });
  };
  return { at, ref, openFrom, close: () => setAt(null) };
}

function MenuShell({
  at,
  menuRef,
  wide,
  children,
}: {
  at: { x: number; y: number };
  menuRef: React.RefObject<HTMLDivElement>;
  /** WAVE 21 item 6 — the delete confirm needs prose width; a menu of one-line
   *  actions does not. The CLAMP moves with the class, because a wider panel
   *  clamped at the narrow width spills off the right edge on exactly the rows
   *  furthest from it. */
  wide?: boolean;
  children: ReactNode;
}) {
  // Clamp to the viewport so a row near the bottom does not spill the menu off it.
  const width = wide ? 320 : 248;
  const style = {
    left: Math.min(at.x, Math.max(8, window.innerWidth - width)),
    top: Math.min(at.y, Math.max(8, window.innerHeight - 260)),
  };
  return (
    <div
      className={"shell-navmenu" + (wide ? " is-wide" : "")}
      style={style}
      ref={menuRef}
      role="menu"
    >
      {children}
    </div>
  );
}

export function RowMenu({
  entryLabel,
  canSchema,
  onSchema,
  canRename,
  onRename,
  onShare,
  canDelete,
  onLoadFootprint,
  onDelete,
}: {
  entryLabel: string;
  canSchema: boolean;
  onSchema: () => void;
  /**
   * WAVE 19 R8 — rename is `ut_*` (custom) DATABASES ONLY, and this flag is how
   * the row says so. A built-in label is a compiled registry literal: renaming
   * `customer_data` would mean the nav and every other reader of
   * `core/registry.py` disagreeing about what the module is called. The SERVER
   * refuses a `name` for a non-`ut_` key regardless (C1, fail-closed) — this
   * only spares the user a control whose write would bounce.
   */
  canRename?: boolean;
  onRename?: (name: string) => void;
  /** WAVE 20 item 18 (C-SHARE) — open the access editor for THIS database.
   *  Absent = the row does not offer sharing (a group head has nothing to share). */
  onShare?: () => void;
  /**
   * ⭐ WAVE 21 item 6 (ruling R3, contract C3, wiring W-5) — may this session
   * DELETE this database?
   *
   * ⛔ REQUIRED, NOT OPTIONAL, and that is the wave-20 lesson written into a type.
   * Four features shipped dead behind 43 green gates because the prop that carried
   * them across an ownership fence was `?`-marked: an unmounted optional prop is
   * `undefined`, which reads as "the feature is off" and is indistinguishable from
   * "the feature was never built". A required prop makes the unmounted case a
   * COMPILE ERROR. The value is the server's (`NavPage.canDelete`), narrower than
   * `manage` on purpose — see the note there.
   */
  canDelete: boolean;
  /** What deleting would destroy. Resolves null when the server would not say —
   *  the face then asks WITHOUT counts rather than inventing zeros. */
  onLoadFootprint: () => Promise<TableFootprint | null>;
  /** Do it. Resolves the server's own words on refusal, which the face shows in
   *  place of the confirmation — a delete that failed must never look like one
   *  that worked. */
  onDelete: () => Promise<{ ok: boolean; error?: string }>;
}) {
  const { at, ref, openFrom, close } = useMenu();
  // Which face the popover is showing. Reset on every open, so a menu that was
  // left mid-rename does not reopen into somebody else's half-typed name.
  const [mode, setMode] = useState<"menu" | "rename" | "delete">("menu");
  const [name, setName] = useState(entryLabel);
  /**
   * WAVE 21 item 6 — the delete face's own state. `footprint: undefined` means
   * "still asking", `null` means "the server would not say" — two different
   * things the face words differently, which is why it is not a plain object.
   */
  const [del, setDel] = useState<{
    footprint?: TableFootprint | null;
    busy: boolean;
    error: string;
  }>({ busy: false, error: "" });
  const renameOn = !!canRename && !!onRename;
  if (!canSchema && !renameOn && !onShare && !canDelete) return null;
  const submitRename = () => {
    const clean = name.trim().replace(/\s+/g, " ");
    if (clean && clean !== entryLabel) onRename?.(clean);
    close();
  };
  /**
   * ⚠ THE FOOTPRINT IS FETCHED WHEN THE FACE OPENS, NOT WHEN THE MENU DOES.
   * Same reasoning as `PermsEditor.prepareCopy` ("the targets are fetched BEFORE
   * the confirm"): the question has to name what is being destroyed, and a
   * confirm written from the rail's own knowledge can only name the table. The
   * cost is paid by the person who clicked Delete, never by everyone who opened
   * a menu.
   */
  const openDelete = () => {
    setDel({ busy: false, error: "" });
    setMode("delete");
    void onLoadFootprint().then((f) => setDel((cur) => ({ ...cur, footprint: f })));
  };
  const runDelete = () => {
    setDel((cur) => ({ ...cur, busy: true, error: "" }));
    void onDelete().then((r) => {
      if (r.ok) {
        close();
        setDel({ busy: false, error: "" });
        return;
      }
      // ⛔ THE MENU STAYS OPEN ON A REFUSAL. Closing it would leave a rail whose
      // row is still there and no statement anywhere about why — which reads as
      // "the click did nothing" and invites a second one.
      setDel((cur) => ({ ...cur, busy: false, error: r.error || "It could not be deleted." }));
    });
  };
  return (
    <>
      <button
        type="button"
        className="shell-dots"
        aria-label={`Options for ${entryLabel}`}
        aria-haspopup="menu"
        onClick={(e) => {
          e.preventDefault();
          e.stopPropagation();
          setMode("menu");
          setName(entryLabel);
          openFrom(e.currentTarget);
        }}
      >
        <DotsIcon />
      </button>
      {at && (
        <MenuShell at={at} menuRef={ref} wide={mode === "delete"}>
          {mode === "delete" && canDelete ? (
            <DeleteFace
              entryLabel={entryLabel}
              state={del}
              onCancel={() => setMode("menu")}
              onConfirm={runDelete}
            />
          ) : mode === "rename" && renameOn ? (
            <form
              className="shell-navmenu-form"
              onSubmit={(e) => {
                e.preventDefault();
                submitRename();
              }}
            >
              <input
                className="shell-navmenu-input"
                autoFocus
                maxLength={60}
                value={name}
                aria-label={`Rename ${entryLabel}`}
                onChange={(e) => setName(e.target.value)}
                // W51-T31 — no Escape branch here. The menu that contains this form owns the
                // key through `useEscapeClose`, which claims it in the capture phase, so a
                // handler on the input could never run and would read as the live one.
              />
              <button type="submit" className="shell-navmenu-go" disabled={!name.trim()}>
                Save
              </button>
            </form>
          ) : (
            <>
              {renameOn ? (
                <button
                  type="button"
                  className="shell-navmenu-item"
                  onClick={() => setMode("rename")}
                >
                  Rename
                </button>
              ) : null}
              {canSchema ? (
                <button
                  type="button"
                  className="shell-navmenu-item"
                  onClick={() => {
                    close();
                    onSchema();
                  }}
                >
                  <SchemaIcon />
                  View schema
                </button>
              ) : null}
              {/* WAVE 20 item 18 (R10, C-SHARE) — a DATABASE shares with the same two
                  roles a view does. Gated on `onShare`, which the Shell passes only
                  for a real database row, so a family head or a hand-off link never
                  offers to share something that has no id on the server. */}
              {onShare ? (
                <button
                  type="button"
                  className="shell-navmenu-item"
                  onClick={() => {
                    close();
                    onShare();
                  }}
                >
                  Share…
                </button>
              ) : null}
              {/* ⭐ WAVE 21 item 6 (R3) — LAST, and the only destructive row in this
                  menu. Gated on the server's `canDelete` alone: R3 scopes the verb to
                  the CREATOR or an admin and refuses it outright for connector-backed
                  databases, so a row that may not be deleted does not say so — it
                  simply has nothing here to click. (An entry that explains why it is
                  disabled is the right pattern for a thing you could earn; this one
                  you cannot.) */}
              {canDelete ? (
                <button
                  type="button"
                  className="shell-navmenu-item is-danger"
                  onClick={openDelete}
                >
                  Delete database…
                </button>
              ) : null}
            </>
          )}
        </MenuShell>
      )}
    </>
  );
}

/** One footprint line: "12 records", "1 view". Singular/plural is the whole of
 *  the formatting, because a count with the wrong noun reads as a bug in the
 *  count. */
function countLine(n: number, one: string, many: string): string {
  return `${n.toLocaleString()} ${n === 1 ? one : many}`;
}

/**
 * ⭐ WAVE 21 item 6 (R3, contract C3) — the confirm face: what deleting this
 * database destroys, stated before the button that does it.
 *
 * Shaped after `PermsEditor`'s confirm (`.set-confirm`, the strongest one this
 * codebase has) and not after a `window.confirm`: the browser dialog cannot say
 * anything specific, and a destructive question whose answer depends on facts
 * the asker has not been given is not really being asked.
 *
 * THREE STATES, worded differently on purpose:
 *   · footprint undefined — still asking the server. The button is disabled;
 *     confirming against numbers that have not arrived is confirming against
 *     nothing.
 *   · footprint null      — the server would not say. The question is put
 *     WITHOUT counts and says so. Inventing zeros here would be a specific,
 *     checkable claim about the user's data that nobody verified
 *     ([[no-unverifiable-aggregates]]).
 *   · footprint present   — every family it names, listed.
 *
 * ⚠ The automations line is the one that is NOT about destruction: C3 pauses
 * bound automations and stamps them "target deleted" rather than removing them,
 * so it names them (they will still be there afterwards, switched off) instead
 * of counting them away.
 */
function DeleteFace({
  entryLabel,
  state,
  onCancel,
  onConfirm,
}: {
  entryLabel: string;
  state: { footprint?: TableFootprint | null; busy: boolean; error: string };
  onCancel: () => void;
  onConfirm: () => void;
}) {
  const f = state.footprint;
  const asking = f === undefined;
  return (
    <div className="shell-navconfirm" role="alertdialog" aria-modal="true"
         aria-label={`Delete ${entryLabel}`}>
      <h4 className="shell-navconfirm-h">Delete “{entryLabel}”?</h4>
      {asking ? (
        <p className="shell-navmenu-note">Checking what this database holds…</p>
      ) : f === null ? (
        <p className="shell-navmenu-note">
          The server did not say what this database holds. Deleting it removes its records,
          columns, views, comments, documents and sharing, permanently.
        </p>
      ) : (
        <>
          <p className="shell-navmenu-note">This cannot be undone. It permanently removes:</p>
          <ul className="shell-navconfirm-list">
            <li>{countLine(f.rows, "record", "records")}</li>
            <li>{countLine(f.fields, "column", "columns")}</li>
            <li>{countLine(f.views, "view", "views")}</li>
            <li>
              {countLine(f.sharedUsers, "person it is shared with",
                         "people it is shared with")}
            </li>
          </ul>
          {f.automations.length ? (
            <p className="shell-navmenu-note">
              {/* The VERB agrees too. "1 automation write here" was on screen before the
                  first screenshot was read — the kind of thing every assertion passes. */}
              {countLine(f.automations.length, "automation", "automations")}{" "}
              {f.automations.length === 1 ? "writes" : "write"} here (
              {f.automations.map((a) => a.name).join(", ")}) — {f.automations.length === 1
                ? "it is"
                : "they are"}{" "}
              switched off, not deleted.
            </p>
          ) : null}
        </>
      )}
      {state.error ? <p className="shell-navconfirm-err">{state.error}</p> : null}
      <div className="shell-navconfirm-actions">
        <button
          type="button"
          className="shell-navconfirm-go"
          disabled={asking || state.busy}
          onClick={onConfirm}
        >
          {state.busy ? "Deleting…" : "Delete"}
        </button>
        <button
          type="button"
          className="shell-navmenu-item is-quiet"
          disabled={state.busy}
          onClick={onCancel}
        >
          Keep it
        </button>
      </div>
    </div>
  );
}

function PlusIcon() {
  return (
    <svg viewBox="0 0 16 16" aria-hidden="true" className="shell-newthing-plus">
      <path d="M8 3.4v9.2M3.4 8h9.2" />
    </svg>
  );
}

/**
 * Wave 14 C-NAVFOLD gave the list's bottom a quiet "+ New folder" (the Views-rail
 * precedent). WAVE 19 R11 made it "+ Create new…" with Folder | Database behind it.
 *
 * ⭐ WAVE 24 items 1 + 15a (ruling R9) — IT LEAVES THE RAIL AND BECOMES THE DATABASE
 * FLYOUT'S FOOTER, and it now carries the creatable things: New database ·
 * From a template · New folder. The flyout's three standalone `.shell-dbfly-make`
 * buttons are deleted; this one control replaces them.
 *
 * ⭐ WAVE 25 item 5a (ruling R8) — "AUTOMATED DATABASE" IS DELETED FROM THIS MENU,
 * so it carries THREE rows rather than four. R8: creating a database is one act and
 * pointing an automation at it is another, so the automation door lives on the
 * automation surface (its rail button and its empty state) and this menu stops
 * offering a database that is really an automation.
 * ⚠ `From a template` and `New folder` are UNTOUCHED — neither was ever an automated
 * database, and R9 keeps the template door working here (see the Home card's own note
 * on why exactly one of the two template doors is boarded).
 *
 * ⭐ WAVE 14's item 1 WAS ALSO A TYPOGRAPHY FIX, and it is worth keeping the
 * measurement because wave 47 finished the job from the other end. MEASURED on
 * staging v12: the six rail rows all rendered 13.8125px / w500 / Inter /
 * rgb(32,36,51) — identical, `<a>` and `<button>` alike. The ONE row in that band
 * that differed was this one, because `.shell-newfolder` declares `--lp-fs-2xs`
 * (12.75px) with no `font-weight` (so 400, inherited) and `--lp-muted`. Taking the
 * row OUT of the rail is what made that band read as one set.
 *
 * ⭐⭐ WAVE 47 T10 (owner instruction 1) — THE EXPANDED ROW NO LONGER WEARS
 * `.shell-newfolder` AT ALL, so do not read the paragraph above as a description of
 * this button's current register. Once W46-T04 mounted this control inside the views
 * rail's `.cg-data-create`, the person walking from a database into a folder path saw
 * the SAME door twice in two different treatments: `.shell-newfolder`'s 12.75px /
 * muted here, `.cg-create-btn`'s `--lp-fs-xs` / `--lp-ink` / w400 one level down. The
 * owner named the second one as the keeper, so the expanded branch now renders
 * `cg-link-btn cg-create-btn` with the same icon/label spans `ViewSidebar.tsx` uses.
 * ⚠ `.shell-newfolder` SURVIVES IN `navExtras.css` AND IS STILL READ HERE, by the
 * COLLAPSED branch alone: `is-collapsed` is a modifier that supplies only the grid
 * centring and leans on the base rule for the reset, the radius and the hover. It is
 * not dead CSS and a sweep must not take it.
 * ⚠ `.shell-newfolder-form` is a SEPARATE selector, not a modifier of that base — the
 * naming form wears `shell-navmenu-form shell-newfolder-form` and never wore
 * `.shell-newfolder`. Reading the two as one rule is how a sweep deletes the wrong one.
 * ⚠ RESIDUAL, and it is deliberate rather than missed: the view layer's wrapper
 * `.cg-create-new` adds `padding: 2px 2px 0` that `.cg-data-create` does not carry, so
 * the two doors still sit 2px apart horizontally. Closing it needs a CSS edit this
 * ticket did not own; both wrappers already share `margin-top: 8px`.
 *
 * ⚠ THE `canFolder` GATE SURVIVES THE MOVE, and it has to. Wave 19's note: folders
 * over an empty list are an empty gesture, but a freshly provisioned tenant must
 * still be able to create a DATABASE. So with no entries the menu simply omits its
 * folder row rather than the control collapsing to a single-purpose button — inside
 * a panel there is room for a menu whatever the tenant has, which is the one thing
 * the 236px rail could not say.
 */
export function CreateNewRow({
  collapsed,
  onExpand,
  onCreateFolder,
  onNewDatabase,
  onFromTemplate,
  canFolder,
}: {
  collapsed: boolean;
  /** Collapsed, the row's one honest behaviour is "open the rail first". */
  onExpand: () => void;
  onCreateFolder: (name: string) => void;
  onNewDatabase: () => void;
  /** R9's second row — the template picker, over a database you already have. */
  onFromTemplate: () => void;
  /* ⛔ `onAutomated` LEFT WITH THE ROW IT OPENED (wave 25 item 5a, R8). */
  /** Folders over an empty list are an empty gesture — the row is omitted, not the menu. */
  canFolder: boolean;
}) {
  const { at, ref, openFrom, close } = useMenu();
  const [naming, setNaming] = useState(false);
  const [name, setName] = useState("");
  const submit = () => {
    const clean = name.trim().replace(/\s+/g, " ");
    if (!clean) return;
    onCreateFolder(clean);
    setName("");
    setNaming(false);
  };
  // ⛔ The 56px strip cannot hold a popover — the same reason the account row
  // expands instead of opening its menu. Preserved from the button this row
  // replaced, which did exactly this before opening its dialog.
  //
  // ⚠ WAVE 24: this branch is now UNREACHABLE FROM THE RAIL (the row is not there
  // any more) but it is NOT dead — the flyout can be opened with the rail folded,
  // and `collapsed` is still passed. Kept rather than deleted, because the panel's
  // own note says the folded rail is exactly the state a user who opened it is most
  // likely to be in.
  if (collapsed) {
    return (
      <button
        type="button"
        className="shell-newfolder is-collapsed"
        aria-label="Create new"
        title="Create new"
        onClick={onExpand}
      >
        <PlusIcon />
      </button>
    );
  }
  if (!naming) {
    return (
      <>
        {/* THE LABEL NO LONGER FOLLOWS `canFolder`. In the rail it had to: with one
            real branch, "+ Create new…" beside an `aria-haspopup` was a control
            promising a choice it was not about to offer. In the footer there are
            always at least two (database / template), so the menu is real whatever
            the tenant has and the label can simply be true.
            ⚠ TWO, NOT THREE, since R8 took the automated row (wave 25) — still a
            genuine choice, which is the property the label depends on. If a future
            ruling takes the template row as well, this reasoning inverts and the
            control has to become a plain button again. */}
        {/* ⭐ WAVE 47 T10 (owner instruction 1) — THIS ROW WEARS THE VIEW LAYER'S REGISTER,
            not its own. Owner, verbatim: *"The '+ Create new...' format for the Database and
            when we get to the folder path in the database is different visually. I like the one
            that is formatted under the database, with the lighter color, fix it so it visually
            doesn't jump"*.
            `cg-link-btn cg-create-btn` + the `cg-create-icon` / `cg-create-label` spans are
            LITERALLY the markup `ViewSidebar.tsx`'s own create door renders, and `index.css` is
            the app-global sheet, so this is one class set read by two call sites rather than two
            class sets kept in step by hand. That second shape is what drifted: see the register
            comparison in this component's own doc block.
            ⛔ `aria-expanded` is not decoration here. `.cg-create-btn[aria-expanded="true"]`
            is what paints the HELD state while the menu is open, so the visual state is driven
            off the accessible one and there is no second source of truth to forget. */}
        <button
          type="button"
          className="cg-link-btn cg-create-btn"
          aria-haspopup="menu"
          aria-expanded={!!at}
          onClick={(e) => openFrom(e.currentTarget)}
        >
          <span className="cg-create-icon" aria-hidden="true">+</span>
          <span className="cg-create-label">Create new…</span>
        </button>
        {at && (
          <MenuShell at={at} menuRef={ref}>
            <button
              type="button"
              className="shell-navmenu-item"
              onClick={() => {
                close();
                onNewDatabase();
              }}
            >
              New database
            </button>
            <button
              type="button"
              className="shell-navmenu-item"
              onClick={() => {
                close();
                onFromTemplate();
              }}
            >
              From a template
            </button>
            {canFolder ? (
              <button
                type="button"
                className="shell-navmenu-item"
                onClick={() => {
                  close();
                  setNaming(true);
                }}
              >
                New folder
              </button>
            ) : null}
          </MenuShell>
        )}
      </>
    );
  }
  return (
    <form
      className="shell-navmenu-form shell-newfolder-form"
      onSubmit={(e) => {
        e.preventDefault();
        submit();
      }}
    >
      <input
        className="shell-navmenu-input"
        autoFocus
        maxLength={40}
        placeholder="Folder name"
        value={name}
        onChange={(e) => setName(e.target.value)}
        onKeyDown={(e) => {
          if (e.key === "Escape") {
            setName("");
            setNaming(false);
          }
        }}
      />
      <button type="submit" className="shell-navmenu-go" disabled={!name.trim()}>
        Add
      </button>
    </form>
  );
}

export function FolderHead({
  folder,
  count,
  open,
  collapsed,
  onToggle,
  onRename,
  onDelete,
  isDrop,
  dropProps,
}: {
  folder: NavFolder;
  count: number;
  /* ⛔ WAVE 35 · T07 (owner item 9) — the `important?: NavImportant` prop is DELETED. It carried
     wave-34 R1's per-folder SUM of mark-important numbers; item 9 retires that badge, and `tsc`'s
     unused-locals check is what named this prop the moment its only reader went. */
  open: boolean;
  collapsed: boolean;
  onToggle: () => void;
  onRename: (name: string) => void;
  onDelete: () => void;
  /** Wave 14 C-NAVFOLD — a database row is being dragged over this folder. */
  isDrop?: boolean;
  /** dragover/drop handlers, owned by the Shell (it holds the placement writer). */
  dropProps?: React.HTMLAttributes<HTMLDivElement>;
}) {
  const { at, ref, openFrom, close } = useMenu();
  const [renaming, setRenaming] = useState(false);
  const [name, setName] = useState(folder.name);
  const submit = () => {
    const clean = name.trim().replace(/\s+/g, " ");
    if (clean && clean !== folder.name) onRename(clean);
    setRenaming(false);
    close();
  };
  if (collapsed) {
    // The folded rail has no room for folder chrome; members render flat and the
    // folder simply waits for the rail to open again.
    return null;
  }
  return (
    <div
      className={"shell-nav-folder" + (isDrop ? " is-drop" : "")}
      {...(dropProps ?? {})}
    >
      {/* R3: no chevron — the Views-rail folder look. Open state reads from the members
          below it (and aria-expanded says it aloud); the mark + bold label ARE the row. */}
      <button
        type="button"
        className="shell-nav-folderbtn"
        aria-expanded={open}
        onClick={onToggle}
      >
        <FixedFolderMark />
        <span className="shell-nav-label">{folder.name}</span>
        <span className="shell-nav-foldercount">{count}</span>
        {/* ⛔⛔ WAVE 35 · T07 (owner item 9, R4) — THE IMPORTANT SUM IS GONE FROM HERE.
            Owner: remove the count *"anywhere else but the View itself"*. Wave 34's R1/C1 put a
            sum of marked RECORDS beside this folder row; item 9 is later and retires it. The star
            count now reaches the user through Home and the Starred module instead (W35-T16/T17).
            ⚠ `count` STAYS, and the distinction is the whole reason this note is here rather than
            the row simply being deleted: `count` is how many BLOCKS the folder holds and has meant
            that since wave 14 — it is not a star count and owner item 9 does not name it. Deleting
            it would retire an unrelated wave-14 feature under cover of this ruling
            (PRD amendment A2). */}
      </button>
      <button
        type="button"
        className="shell-dots"
        aria-label={`Options for folder ${folder.name}`}
        aria-haspopup="menu"
        onClick={(e) => {
          e.stopPropagation();
          setName(folder.name);
          setRenaming(false);
          openFrom(e.currentTarget);
        }}
      >
        <DotsIcon />
      </button>
      {at && (
        <MenuShell at={at} menuRef={ref}>
          {renaming ? (
            <form
              className="shell-navmenu-form"
              onSubmit={(e) => {
                e.preventDefault();
                submit();
              }}
            >
              <input
                className="shell-navmenu-input"
                autoFocus
                maxLength={40}
                value={name}
                onChange={(e) => setName(e.target.value)}
              />
              <button type="submit" className="shell-navmenu-go" disabled={!name.trim()}>
                Save
              </button>
            </form>
          ) : (
            <button
              type="button"
              className="shell-navmenu-item"
              onClick={() => setRenaming(true)}
            >
              Rename folder
            </button>
          )}
          <button
            type="button"
            className="shell-navmenu-item is-danger"
            onClick={() => {
              close();
              onDelete();
            }}
          >
            Delete folder
          </button>
        </MenuShell>
      )}
    </div>
  );
}

export function SchemaDrawer({
  schemaKey,
  onClose,
}: {
  schemaKey: string;
  onClose: () => void;
}) {
  const [state, setState] = useState<
    { phase: "loading" } | { phase: "ready"; schema: SchemaPayload } | { phase: "error" }
  >({ phase: "loading" });
  const [mapSaving, setMapSaving] = useState(false);
  const [mapError, setMapError] = useState("");
  const [mapDraft, setMapDraft] = useState({ latField: "", lonField: "" });
  useEffect(() => {
    let cancelled = false;
    setState({ phase: "loading" });
    setMapSaving(false);
    setMapError("");
    setMapDraft({ latField: "", lonField: "" });
    fetchSchema(schemaKey).then((schema) => {
      if (cancelled) return;
      setState(schema ? { phase: "ready", schema } : { phase: "error" });
      if (schema) {
        setMapDraft({
          latField: schema.map.latField ?? "",
          lonField: schema.map.lonField ?? "",
        });
      }
    });
    return () => {
      cancelled = true;
    };
  }, [schemaKey]);
  // W51-T31 — the schema drawer is only ever rendered while it is open, so its entry is
  // unconditionally active; the stack still resolves Escape to whichever overlay is on top.
  useEscapeClose(true, onClose);
  const mapPairIncomplete = Boolean(mapDraft.latField) !== Boolean(mapDraft.lonField);
  const saveMap = async () => {
    if (state.phase !== "ready" || !state.schema.map.canConfigure || mapSaving) return;
    if (mapPairIncomplete) {
      setMapError("Choose both a latitude and a longitude field, or leave both on Built-in.");
      return;
    }
    setMapSaving(true);
    setMapError("");
    const map = await saveSchemaMap(
      schemaKey,
      mapDraft.latField || undefined,
      mapDraft.lonField || undefined,
    );
    setMapSaving(false);
    if (!map) {
      setMapError("The Map setup was not saved. Try again.");
      return;
    }
    setState((current) => current.phase === "ready"
      ? { ...current, schema: { ...current.schema, map } }
      : current);
    setMapDraft({ latField: map.latField ?? "", lonField: map.lonField ?? "" });
    // Map consumes this database-owned setting from its workspace envelope. Reuse the existing
    // refresh signal so an open Map changes immediately without coupling the shell to grid state.
    signal(WORKSPACE_STALE_EVENT);
  };
  return (
    <div className="shell-schema-backdrop" onMouseDown={onClose}>
      <aside
        className="shell-schema"
        role="dialog"
        aria-label="Database schema"
        onMouseDown={(e) => e.stopPropagation()}
      >
        {/* wave17 item 3 (R6) — the drawer opens on a mark, not on a sentence. */}
        {state.phase === "loading" && (
          <div className="shell-schema-empty is-spin">
            <span className="lp-spin lp-spin--lg" role="status" aria-label="Loading" />
          </div>
        )}
        {state.phase === "error" && (
          <div className="shell-schema-empty">
            The schema could not be loaded. Close this panel and try again.
          </div>
        )}
        {state.phase === "ready" && (
          <>
            <header className="shell-schema-head">
              <div>
                <div className="shell-schema-title">{state.schema.label}</div>
                {state.schema.source && (
                  <div className="shell-schema-sub">Source · {state.schema.source}</div>
                )}
              </div>
              <button
                type="button"
                className="shell-schema-close"
                aria-label="Close schema"
                onClick={onClose}
              >
                ×
              </button>
            </header>
            <div className="shell-schema-body">
              {state.schema.note && (
                <div className="shell-schema-note">{state.schema.note}</div>
              )}
              <div className="shell-schema-kicker">Map</div>
              <div className="shell-schema-card shell-schema-map-setup">
                <div className="shell-schema-setup-label">Pin location</div>
                {state.schema.map.canConfigure ? (
                  <>
                    <label className="shell-schema-setup-control">
                      <span>Latitude</span>
                      <select
                        aria-label="Map latitude field"
                        value={mapDraft.latField}
                        disabled={mapSaving}
                        onChange={(event) => {
                          setMapError("");
                          setMapDraft((draft) => ({ ...draft, latField: event.target.value }));
                        }}
                      >
                        <option value="">Built-in lat</option>
                        {state.schema.map.fields.map((field) => (
                          <option key={field.key} value={field.key}>
                            {field.label}
                          </option>
                        ))}
                      </select>
                    </label>
                    <label className="shell-schema-setup-control">
                      <span>Longitude</span>
                      <select
                        aria-label="Map longitude field"
                        value={mapDraft.lonField}
                        disabled={mapSaving}
                        onChange={(event) => {
                          setMapError("");
                          setMapDraft((draft) => ({ ...draft, lonField: event.target.value }));
                        }}
                      >
                        <option value="">Built-in lon</option>
                        {state.schema.map.fields.map((field) => (
                          <option key={field.key} value={field.key}>
                            {field.label}
                          </option>
                        ))}
                      </select>
                    </label>
                    {mapPairIncomplete && (
                      <div className="shell-schema-setup-status" role="status">
                        Choose the other coordinate field to save this pair.
                      </div>
                    )}
                    <div className="shell-schema-setup-actions">
                      <button
                        type="button"
                        disabled={mapSaving || mapPairIncomplete}
                        onClick={() => void saveMap()}
                      >
                        {mapSaving ? "Saving…" : "Save Map setup"}
                      </button>
                    </div>
                  </>
                ) : (
                  <div className="shell-schema-setup-value">
                    {state.schema.map.latField && state.schema.map.lonField
                      ? `${state.schema.map.fields.find((field) => field.key === state.schema.map.latField)?.label ?? state.schema.map.latField} / ${state.schema.map.fields.find((field) => field.key === state.schema.map.lonField)?.label ?? state.schema.map.lonField}`
                      : state.schema.map.fields.find((field) => field.key === state.schema.map.coordField)?.label
                        ?? "Built-in lat / lon when supplied"}
                  </div>
                )}
                <p className="shell-schema-setup-help">
                  {state.schema.map.canConfigure
                    ? "Choose the latitude and longitude fields used to plot records. Leave both on Built-in to use the default lat / lon pair. Map stays available for every database."
                    : "A database editor can choose custom latitude and longitude fields here. Map stays available for every database."}
                </p>
                {mapError && <div className="shell-schema-setup-error" role="alert">{mapError}</div>}
              </div>
              {state.schema.fields.length > 0 && (
                <>
                  <div className="shell-schema-kicker">
                    Fields · {state.schema.fields.length}
                  </div>
                  {/* W46-T45 — ONE containment layer, the `.set-card` sibling of the
                      Settings modal. The kicker stays outside it, exactly as
                      `.set-h4` sits above `.set-card`. */}
                  <div className="shell-schema-card">
                    <table className="shell-schema-table">
                      <thead>
                        <tr>
                          <th>Field</th>
                          <th>Type</th>
                          <th>Source</th>
                        </tr>
                      </thead>
                      <tbody>
                        {state.schema.fields.map((f) => (
                          <tr key={f.key}>
                            <td>
                              <div className="shell-schema-fname">{f.label}</div>
                              {f.description && (
                                <div className="shell-schema-fdesc">{f.description}</div>
                              )}
                              {f.options && (
                                <div className="shell-schema-fdesc">
                                  Choices: {f.options.join(" · ")}
                                </div>
                              )}
                            </td>
                            <td className="shell-schema-type">{f.type}</td>
                            <td className="shell-schema-type">{f.source}</td>
                          </tr>
                        ))}
                      </tbody>
                    </table>
                  </div>
                </>
              )}
              {state.schema.measures.length > 0 && (
                <>
                  <div className="shell-schema-kicker">
                    Semantic measures · {state.schema.measures.length}
                  </div>
                  <div className="shell-schema-card">
                    <div className="shell-schema-measures">
                      {state.schema.measures.map((m) => (
                        <div key={m.key} className="shell-schema-measure">
                          <span className="shell-schema-fname">{m.label}</span>
                          <span className="shell-schema-type">{m.type}</span>
                        </div>
                      ))}
                    </div>
                  </div>
                </>
              )}
            </div>
          </>
        )}
      </aside>
    </div>
  );
}