@floless/app 0.127.4 → 0.127.6

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.
@@ -403,6 +403,7 @@
403
403
  #selBar button:focus-visible{outline:2px solid var(--brand);outline-offset:1px}
404
404
  #selBar button .car{position:absolute;right:1px;bottom:0;font-size:8px;opacity:.7;pointer-events:none}
405
405
  #selBar button .seldot{position:absolute;top:2px;right:2px;width:6px;height:6px;border-radius:50%;background:var(--brand);box-shadow:0 0 0 1.5px var(--panel)}
406
+ body:not(.v3d) #selBar [data-cls=reference]{display:none} /* borrowed IFC geometry has no 2D pick surface */
406
407
  /* shared type flyout (Members / Connections) — opens upward from the bar */
407
408
  #selFly{position:fixed;z-index:46;min-width:210px;background:var(--panel);border:1px solid var(--line);border-radius:10px;box-shadow:0 10px 30px rgba(0,0,0,.55);padding:6px;display:none}
408
409
  #selFly.open{display:block}
@@ -826,6 +827,11 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
826
827
  .m3dmenu label{display:flex;align-items:center;gap:7px;padding:7px 12px;color:var(--text);font-size:12px;cursor:pointer;white-space:nowrap}
827
828
  .m3dmenu label:hover{background:#334155}
828
829
  .m3dmenu label input{margin:0;cursor:pointer} /* the global input[type=checkbox] rule now sets the box size, so this no longer inherits input{width:100%} and no longer needs `width:auto` — which on an appearance:none box would collapse it (View / Plane / Work toggles) */
830
+ .m3dmenu .m3d-actions{display:flex;gap:6px;padding:4px 8px}
831
+ .m3dmenu .m3d-actions button{flex:1;width:auto;text-align:center;padding:5px 9px;border:1px solid #475569;border-radius:6px;background:#334155}
832
+ .m3dmenu .m3d-actions button:hover{background:#475569}
833
+ .m3dmenu .m3d-actions button.mprimary{background:var(--brand);border-color:var(--brand);color:#fff}
834
+ .m3dmenu .m3d-actions button.mprimary:hover{background:var(--brand)}
829
835
  .m3dmenu .wpprow{display:flex;gap:4px;align-items:center;padding:4px 12px}
830
836
  .m3dmenu .wpprow button{width:auto;flex:none;padding:4px 8px;border:1px solid var(--line);border-radius:5px}
831
837
  .m3dmenu .wpprow input{width:74px;height:24px;background:var(--bg);color:var(--text);border:1px solid var(--line);border-radius:5px;padding:0 6px;font:12px system-ui}
@@ -1123,6 +1129,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
1123
1129
  #m3dLegend .lrow.off{opacity:.4}
1124
1130
  /* hidden/off (or a disabled clip) → the box goes HOLLOW (outline of its own colour); the row also dims. No grayscale — the empty box already signals "hidden". */
1125
1131
  #m3dLegend .lrow.off .lsw,#m3dLegend .lrow.dim.dimoff .lsw{background:transparent;box-shadow:inset 0 0 0 1.6px var(--sw)}
1132
+ #m3dLegend .lrow.mixed .lsw{background:linear-gradient(var(--sw),var(--sw)) center/7px 2px no-repeat;box-shadow:inset 0 0 0 1.6px var(--sw)}
1126
1133
  #m3dLegend .lrow.solo{background:rgba(59,130,246,.12)} /* in the isolated set (Explorer-style multi-select highlight) */
1127
1134
  #m3dLegend .lrow.lsel{box-shadow:inset 2px 0 0 var(--brand)} /* selected in 3D — brand left-bar (distinct from .solo's isolate tint; the two can coexist) */
1128
1135
  #m3dLegend .lrow.dim .lsw{--sw:#67e8f9} /* dim overlays are cyan — same filled(on)/hollow(off) box as every other row */
@@ -1444,17 +1451,30 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
1444
1451
  <button data-mode=shadowed data-tip="Realistic with cast shadows — more depth, at a cost to frame rate">Shadowed</button>
1445
1452
  </div>
1446
1453
  </div>
1447
- <button id=m3dIso data-tip="Isolate selected — hide everything else (Esc to exit)" style="display:none">Isolate</button>
1454
+ <div class=m3dwrap id=m3dIsoWrap style="display:none">
1455
+ <button id=m3dIso aria-haspopup=menu aria-controls=m3dIsoMenu aria-expanded=false data-tip="Visibility actions for the selected objects">Isolate ▾</button>
1456
+ <div id=m3dIsoMenu class=m3dmenu role=menu>
1457
+ <button role=menuitem data-vis=show-all data-tip="Restore every hidden or isolated object" style="display:none">Show all</button>
1458
+ <hr data-vis-divider style="display:none">
1459
+ <button role=menuitem data-vis=isolate data-tip="Show only the selected objects (Esc to restore)">Isolate selected</button>
1460
+ <button role=menuitem data-vis=hide data-tip="Hide the selected objects">Hide selected</button>
1461
+ </div>
1462
+ </div>
1448
1463
  <button id=m3dViewsBtn data-tip="Saved views — save, switch, and manage named viewpoints">Views</button>
1449
1464
  <span class=tb-sep></span>
1450
1465
  <!-- Display toggles: reference lines + mark labels (grouped into a menu, like Plane / Work area).
1451
1466
  The Dimension tool moved to the header so it lives in one place across 2D and 3D. -->
1452
1467
  <div class=m3dwrap>
1453
- <button id=m3dView data-tip="Show or hide reference lines, mark labels, and property labels on the 3D model">View ▾</button>
1468
+ <button id=m3dView aria-haspopup=menu aria-controls=m3dViewMenu aria-expanded=false data-tip="Show or hide reference lines, mark labels, and property labels on the 3D model">View ▾</button>
1454
1469
  <div id=m3dViewMenu class=m3dmenu role=menu>
1455
1470
  <label data-tip="Show each member's reference line (centreline)"><input type=checkbox id=m3dRef> Ref line</label>
1456
1471
  <label data-tip="Show each member's mark / id label in the 3D view"><input type=checkbox id=m3dLabels> Mark labels</label>
1457
1472
  <label data-tip="Show or hide property labels in the 3D view (the property selection is shared with 2D — this hides them here only)"><input type=checkbox id=m3dPropLabels checked> Property labels</label>
1473
+ <hr>
1474
+ <div class=m3d-actions id=m3dViewActions>
1475
+ <button id=m3dViewHideAll role=menuitem data-tip="Hide reference lines, mark labels, and property labels">Hide all</button>
1476
+ <button id=m3dViewShowAll class=mprimary role=menuitem data-tip="Show reference lines, mark labels, and property labels">Show all</button>
1477
+ </div>
1458
1478
  </div>
1459
1479
  </div>
1460
1480
  <span class=tb-sep></span>
@@ -1532,6 +1552,7 @@ text.mlentx{fill:#e2e8f0;text-anchor:middle;dominant-baseline:central;font-famil
1532
1552
  <button data-cls=connection data-fly=connections aria-label="Connections" data-tip="Connections — click to choose which connection types can be selected · Alt+click: toggle all types"><svg viewBox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><rect x="4" y="4" width="10" height="10" rx="1"/><circle cx="6.5" cy="6.5" r="1.15" fill="currentColor" stroke="none"/><circle cx="11.5" cy="6.5" r="1.15" fill="currentColor" stroke="none"/><circle cx="6.5" cy="11.5" r="1.15" fill="currentColor" stroke="none"/><circle cx="11.5" cy="11.5" r="1.15" fill="currentColor" stroke="none"/></svg><span class=car aria-hidden=true>▾</span></button>
1533
1553
  <button data-cls=grid aria-label="Grid lines" data-tip="Grid lines — allow selecting grid lines (area-select / Ctrl+A)"><svg viewBox="0 0 18 18" fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round aria-hidden=true><path d="M6 2v14M12 2v14M2 6h14M2 12h14"/></svg></button>
1534
1554
  <button data-cls=dim aria-label="Dimensions" data-tip="Dimensions — allow selecting dimensions"><svg viewBox="0 0 18 18" fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round aria-hidden=true><path d="M3 5v8M15 5v8M3 9h12M3 9l3-2M3 9l3 2M15 9l-3-2M15 9l-3 2"/></svg></button>
1555
+ <button data-cls=reference aria-label="Reference models" data-tip="Reference models — allow selecting reference models. Visibility and snapping are controlled separately."><svg viewBox="0 0 18 18" fill=none stroke=currentColor stroke-width=1.35 stroke-linejoin=round aria-hidden=true><path d="M2.5 5.5l5-2.5 5 2.5-5 2.5-5-2.5Z"/><path d="M2.5 5.5v5l5 2.5 5-2.5v-5M7.5 8v5"/><path d="M10.5 8.5l2-1 3 1.5v3l-3 1.5"/></svg></button>
1535
1556
  </div>
1536
1557
  <!-- Quick-access snap toggles (same persistent state as the ⋯ menu → Snapping section; keep the two in sync — same 7 items).
1537
1558
  Glyphs mirror SNAP_KINDS_2D — see the endpoint-glyph constraint there before "correcting" ◻ to □. -->
@@ -2934,7 +2955,7 @@ const autofillTOS=syncDefaults;
2934
2955
  // grid that does not live on a sheet, so without this line every grid edit on a v2 document would be
2935
2956
  // unundoable — silently, since Ctrl+Z would restore the sheets and report success.
2936
2957
  function snapshot(){
2937
- if(MODEL_V2)return JSON.stringify({v2:true,members:C.members,grid:C.grid||null,plans:C.plans.map(p=>({sheet:p.sheet,dims:p.dims||[],memberRefs:p.memberRefs||[],memberObservations:p.memberObservations||[],frame:p.frame||null})),joints:C.joints||[],connections:C.connections||[],details:C.detail_placements||[],views:C.views||[],member_types:C.member_types||[],dim_style:C.dim_style||null,member_styles:C.member_styles||{}});
2958
+ if(MODEL_V2)return JSON.stringify({v2:true,members:C.members,grid:C.grid||null,plans:C.plans.map(p=>({sheet:p.sheet,dims:p.dims||[],memberRefs:p.memberRefs||[],memberObservations:p.memberObservations||[],frame:p.frame||null})),joints:C.joints||[],connections:C.connections||[],details:C.detail_placements||[],views:C.views||[],member_types:C.member_types||[],dim_style:C.dim_style||null,member_styles:C.member_styles||{},...(Array.isArray(C.reference_models)?{reference_models:C.reference_models}:{})});
2938
2959
  return JSON.stringify({planes:C.plans.map(p=>({sheet:p.sheet,members:p.members,dims:p.dims||[],frame:p.frame||null,grid:p.grid||null})),joints:C.joints||[],connections:Array.isArray(C.connections)?C.connections:null,clips:(window.Steel3DView&&window.Steel3DView.clipState)?window.Steel3DView.clipState():null,details:(C.detail_placements||[]),member_types:C.member_types||[],dim_style:C.dim_style||null,member_styles:C.member_styles||{}});
2939
2960
  }
2940
2961
  // Undo/redo is a SINGLE GLOBAL stack (not per-plane): snapshot() above captures EVERY plane's
@@ -3013,6 +3034,7 @@ function apply(json){
3013
3034
  cmDraft=null;cmPrevClear();cmHudClose(); // same for an in-progress Move/Copy pick — the base may reference removed geometry
3014
3035
  if(window.Steel3DView&&window.Steel3DView.cmClear3d)window.Steel3DView.cmClear3d(); // and the 3D-side draft/ghosts
3015
3036
  if(window.Steel3DView&&window.Steel3DView.setClipState&&'clips' in d)window.Steel3DView.setClipState(d.clips); // restore clips + work area alongside the contract
3037
+ if(MODEL_V2&&'reference_models' in d)pushReferences(); // native sync3D cannot repaint the editor-only reference layer
3016
3038
  if('member_types' in d)C.member_types=sanitizeMemberTypes(d.member_types);
3017
3039
  if('member_styles' in d)C.member_styles=(d.member_styles&&typeof d.member_styles==='object'&&!Array.isArray(d.member_styles))?d.member_styles:{}; // F5: model-global per-type line styles ride the undo stack (like dim_style) so a setMemberLineStyle() edit() is undoable
3018
3040
  scheduleSave();render();sync3D();}
@@ -4461,7 +4483,7 @@ function reflect2dGridSelection(){const geo=gridGeo()||{};
4461
4483
  if(!selDimIds.size){svg.querySelectorAll('.dimsel').forEach(el=>el.classList.remove('dimsel'));svg.querySelectorAll('circle.dimhandle').forEach(el=>el.remove());} // an additive grid click keeps an already-selected dimension visibly selected; a plain grid click cleared selDimIds above
4462
4484
  if(!selIds.size)svg.querySelectorAll('circle.handle,circle.numbg,text.numtx,g.mlenlabels').forEach(el=>el.remove());
4463
4485
  panel();try{updateConnCrumb();}catch(_){}syncPropLabelsAfterRender();}
4464
- function selectGridLine(id,additive,surgical=false){if(!id||!selGridOK())return;if(!additive){selDimIds.clear();sel3dDimIds.clear();selIds.clear();selGridIds=new Set([id]);if(window.Steel3DView&&window.Steel3DView.setSelectedClips)window.Steel3DView.setSelectedClips([]);}else{selGridIds.has(id)?selGridIds.delete(id):selGridIds.add(id);}surgical?reflect2dGridSelection():render();} // additive grid picks preserve an intentional mixed dimension/grid selection in either click order
4486
+ function selectGridLine(id,additive,surgical=false){if(!id||!selGridOK())return;clearWholeReferenceSelection();if(!additive){selDimIds.clear();sel3dDimIds.clear();selIds.clear();selGridIds=new Set([id]);if(window.Steel3DView&&window.Steel3DView.setSelectedClips)window.Steel3DView.setSelectedClips([]);}else{selGridIds.has(id)?selGridIds.delete(id):selGridIds.add(id);}surgical?reflect2dGridSelection():render();} // additive grid picks preserve an intentional mixed dimension/grid selection in either click order
4465
4487
  // selected grid lines → display rows {label,type} for the inspector (resolves labels/types from gridGeo)
4466
4488
  function gridSelSummary(){const geo=gridGeo()||{};const out=[];
4467
4489
  for(const id of selGridIds){
@@ -4925,6 +4947,10 @@ function doDup(){const arr=sel2d();if(!arr.length)return;const o=12,pv=snapshot(
4925
4947
  selIds=ns;selDimIds.clear();mode='sel';setMode();pushUndo(pv);render();}
4926
4948
  function esc(s){return String(s).replace(/[<>&"]/g,c=>({'<':'&lt;','>':'&gt;','&':'&amp;','"':'&quot;'}[c]));}
4927
4949
  function render(){
4950
+ // Selection has many entry points (2D clicks/marquees, 3D picks, inspectors, Locate actions). Enforce
4951
+ // the one-target invariant at their shared paint boundary as well as at the direct 3D sinks: if any
4952
+ // native/dimension/grid target is about to be shown selected, a stale whole-reference selection ends.
4953
+ if(refSelectedId&&(selIds.size||selDimIds.size||selGridIds.size||sel3dDimIds.size))clearWholeReferenceSelection();
4928
4954
  // A v2 document has no 2D plan to draw (§1): its members are world-mm and model-level, and the sheet
4929
4955
  // registration that would place them back into this sheet's display space is computed at migration and
4930
4956
  // never persisted — the adapter's own sheetFrame() refuses to fabricate one. So the canvas stays empty
@@ -5338,12 +5364,12 @@ function panel(){
5338
5364
  if(csaxisMode){p.innerHTML=`<span class=badge>Set local axes</span>
5339
5365
  <div class=hint style="margin-top:8px">${csDraft?'Click the <b>second</b> point — the local-X direction. Y follows at 90°.':'Click the <b>origin</b> point to start.'}</div>
5340
5366
  <div class=hint style="margin-top:8px">Two clicks define the frame; snaps to member ends &amp; grid (<b>Alt</b> off). <b>Esc</b> cancels.</div>`;return;}
5341
- if(cmTool){const nsel=selIds.size;
5367
+ if(cmTool){const refTarget=view3d&&!selIds.size&&refSelectedId&&refSelectedObjIdx===null?refById(refSelectedId):null,nsel=refTarget?1:selIds.size;
5342
5368
  p.innerHTML=`<span class=badge>${cmTool==='move'?'Move':(cmArrayMode?'Copy array':'Copy')}</span>
5343
5369
  <div class=hint id=cmHint style="margin-top:8px">${esc(cmHintText())}</div>
5344
5370
  ${cmTool==='copy'&&!cmArrayMode?`<div class=sect style="margin-top:12px">Copies</div><input id=cmN inputmode=numeric value="${cmCount}" autocomplete=off><div class=hint style="margin-top:4px">×N places a row — each copy one step further along the pick (linear).</div>`:''}
5345
5371
  ${cmArrayMode?`<div class=sect style="margin-top:12px">Array counts</div><div class=elab>Direction A</div><input id=cmNA inputmode=numeric value="${cmCountA}" autocomplete=off><div class=elab>Direction B</div><input id=cmNB inputmode=numeric value="${cmCountB}" autocomplete=off><div class=hint id=cmCapHint style="margin-top:4px">Counts include the original — 4 × 6 fills a 4-by-6 grid (max 100).</div>`:''}
5346
- <div class=hint style="margin-top:8px">${nsel} member${nsel===1?'':'s'} selected. ${view3d?'<b>Shift</b>=straight · <b>X/Y/Z</b> lock (press again to release · <b>F</b> clears; lock two to snap to whichever you drag toward) · <b>Alt</b>=lock out-of-plane':'<b>Shift</b>=straight · <b>X/Y/F</b> axis · <b>Alt</b>=no snap'} · type after the first pick for an exact value · <b>Esc</b> cancels. Connections don't copy.</div>`;
5372
+ <div class=hint style="margin-top:8px">${refTarget?'1 reference model selected.':nsel+' member'+(nsel===1?'':'s')+' selected.'} ${view3d?'<b>Shift</b>=straight · <b>X/Y/Z</b> lock (press again to release · <b>F</b> clears; lock two to snap to whichever you drag toward) · <b>Alt</b>=lock out-of-plane':'<b>Shift</b>=straight · <b>X/Y/F</b> axis · <b>Alt</b>=no snap'} · type after the first pick for an exact value · <b>Esc</b> cancels.${refTarget?'':' Connections don’t copy.'}</div>`;
5347
5373
  const wireN=(id,set)=>{const i=document.getElementById(id);if(i)i.onchange=e=>{const n=Math.max(1,Math.min(99,Math.round(Number(e.target.value)||1)));set(n);e.target.value=n;
5348
5374
  const ch=document.getElementById('cmCapHint');if(ch)ch.style.color=(cmArrayMode&&cmCountA*cmCountB>100)?'#fca5a5':'';cmRefreshPrev();};};
5349
5375
  wireN('cmN',n=>cmCount=n);wireN('cmNA',n=>cmCountA=n);wireN('cmNB',n=>cmCountB=n);
@@ -6108,12 +6134,12 @@ function saveOriginGrid(){try{localStorage.setItem(OGRID_ON_KEY,originGridOn?'1'
6108
6134
  // connection kinds — may enter a selection. One persisted source of truth, consulted at every pick
6109
6135
  // sink (2D click/marquee/Ctrl+A, 3D pick/box). Default: everything ON, so nothing is filtered out
6110
6136
  // (that default is also what fixes the silent Ctrl+A/marquee drops of dims + grids). GLOBAL like snaps.
6111
- // State: grid/dim are plain on/off; Members & Connections have per-TYPE switches (mtype/ckind, absent===on)
6137
+ // State: grid/dim/reference are plain on/off; Members & Connections have per-TYPE switches (mtype/ckind, absent===on)
6112
6138
  // and their class button is DERIVED (all/some/none on) — so "Members off" just means every member type off.
6113
6139
  const SELF_KEY='steel:selFilter:v1';
6114
6140
  // Grids default OFF (opt-in) — grid-line selection is a deliberate act, so a plain marquee/Ctrl+A doesn't
6115
- // sweep the structural grid unless you switch it on. Members/Connections/Dimensions default ON.
6116
- let selFilter=(()=>{try{const s=JSON.parse(localStorage.getItem(SELF_KEY)||'{}');return {grid:s.grid===true,dim:s.dim!==false,mtype:(s.mtype&&typeof s.mtype==='object')?s.mtype:{},ckind:(s.ckind&&typeof s.ckind==='object')?s.ckind:{}};}catch(_){return {grid:false,dim:true,mtype:{},ckind:{}};}})();
6141
+ // sweep the structural grid unless you switch it on. Members/Connections/Dimensions/References default ON.
6142
+ let selFilter=(()=>{try{const s=JSON.parse(localStorage.getItem(SELF_KEY)||'{}');return {grid:s.grid===true,dim:s.dim!==false,reference:s.reference!==false,mtype:(s.mtype&&typeof s.mtype==='object')?s.mtype:{},ckind:(s.ckind&&typeof s.ckind==='object')?s.ckind:{}};}catch(_){return {grid:false,dim:true,reference:true,mtype:{},ckind:{}};}})();
6117
6143
  function saveSelFilter(){try{localStorage.setItem(SELF_KEY,JSON.stringify(selFilter));}catch(_){}}
6118
6144
  const normConnKind=k=>String(k||'').trim().toLowerCase(); // 'base-plate' | 'shear-plate' | 'custom'
6119
6145
  const selTypeOK=k=>selFilter.mtype[k]!==false; // per-member-type; absent === allowed
@@ -6123,6 +6149,7 @@ function connKindOfPart(id){const p=partsById&&partsById[id];if(!p||!p.conn)retu
6123
6149
  function selConnPartOK(id){return selKindOK(connKindOfPart(id));}
6124
6150
  const selGridOK=()=>selFilter.grid!==false;
6125
6151
  const selDimOK=()=>selFilter.dim!==false;
6152
+ const selReferenceOK=()=>selFilter.reference!==false;
6126
6153
  // classify any id already in / entering selIds — connection part, placed detail, or plain member — → allowed?
6127
6154
  function selIdOK(id){if(id==null)return true;if(partsById&&partsById[id]&&partsById[id].conn)return selConnPartOK(id);if(/^det:/.test(id))return true;const m=byId(id);return m?selMemberOK(m):true;}
6128
6155
  // a type fires when a transient override forces exactly it (override ignores running-snaps, AutoCAD-style), else when its running-snap is on
@@ -7015,8 +7042,14 @@ function disarmCm(){cmTool=null;cmArrayMode=false;cmDraft=null;cmHudClose();cmPr
7015
7042
  if(window.Steel3DView&&window.Steel3DView.cmClear3d)window.Steel3DView.cmClear3d();} // drop the 3D-side pick/preview too
7016
7043
  function armCm(tool,array){ // re-arming the same config toggles the tool off — works in 2D and (on the working plane) in 3D
7017
7044
  if(cmTool===tool&&cmArrayMode===!!array){disarmCm();render();return;}
7045
+ const refTarget=view3d&&!selIds.size&&refSelectedId&&refSelectedObjIdx===null?refById(refSelectedId):null;
7046
+ if(view3d&&refSelectedObjIdx!==null){toast('Select the whole reference model to move it');return;}
7047
+ if(refTarget&&tool!=='move'){toast('Reference models can only be moved');return;}
7048
+ if(refTarget&&refDisp(refTarget).locked){toast('“'+refTarget.name+'” is locked — unlock it to move it');return;}
7049
+ const refObjects=refTarget&&(refGeom.get(refTarget.id)||{}).objects;
7050
+ if(refTarget&&(!Array.isArray(refObjects)||!refObjects.length)){toast(refLoading.has(refTarget.id)?'Still reading its geometry — try again in a moment':'There is no reference geometry to move yet');return;}
7018
7051
  if(view3d&&window.Steel3DView){const dm=document.getElementById('m3dDim');if(dm&&dm.classList.contains('on'))window.Steel3DView.toggleDimTool();if(window.Steel3DView.disarmFrame3d)window.Steel3DView.disarmFrame3d();if(window.Steel3DView.armRefMeasure3d){window.Steel3DView.armRefMeasure3d(null);refMeasureClear();}} // the 3D dim tool + the local frame share the left-click — disarm both
7019
- if(!selIds.size){toast('Select members first, then '+(tool==='move'?'Move':'Copy'));return;}
7052
+ if(!selIds.size&&!refTarget){toast(view3d&&tool==='move'?'Select members or a reference model first, then Move':'Select members first, then '+(tool==='move'?'Move':'Copy'));return;}
7020
7053
  if(mode==='add'){mode='sel';setMode();if(window.Steel3DView&&window.Steel3DView.drClear3d)window.Steel3DView.drClear3d();}
7021
7054
  if(dimMode){dimMode=false;setDimMode();}
7022
7055
  if(csaxisMode){csaxisMode=false;setCsMode();}
@@ -7329,6 +7362,7 @@ svg.addEventListener('pointerdown',e=>{if(e.button!==0)return;const t=e.target;
7329
7362
  if(isDimAnchorableMember(m))gm={mid:m.id,pt:ref0.pt,rigid:ref0.pt==='mid'||(m.role||'beam')==='column',ow:[m.wp[0].slice(),m.wp[1].slice()],oa:(end===0?d0.a:d0.b).slice()};}
7330
7363
  buildSnap(gm?new Set([id,gm.mid]):id);drag={type:'dimend',id,end,grip:gm,pre:snapshot()};svg.setPointerCapture(e.pointerId);e.preventDefault();return;}
7331
7364
  if(t.dataset.dim&&mode==='sel'&&selDimOK()){const did=t.dataset.dim,add=e.ctrlKey||e.metaKey;
7365
+ clearWholeReferenceSelection();
7332
7366
  if(!add&&_lastDimDown&&_lastDimDown.id===did&&(e.timeStamp-_lastDimDown.t)<400){_lastDimDown=null;selDimIds=new Set([did]);openDimEdit(did);e.preventDefault();return;} // F8: double-click a dim → value editor. Detected HERE (in pointerdown), NOT via the native dblclick event, so the select-render between the two clicks can't swallow it (Codex R4 #2).
7333
7367
  _lastDimDown={id:did,t:e.timeStamp};
7334
7368
  selIds.clear();if(!add)selGridIds.clear(); // a plain dim click is exclusive (clears member + grid selection); Ctrl keeps an intentional mixed grid/dim selection. Dimensions select-switch off → click falls through (inert)
@@ -7901,16 +7935,17 @@ addEventListener('keydown',e=>{
7901
7935
  if(k==='z'&&!e.shiftKey){e.preventDefault();doUndo();}
7902
7936
  else if(k==='y'||(k==='z'&&e.shiftKey)){e.preventDefault();doRedo();}
7903
7937
  else if(k==='d'&&selIds.size){e.preventDefault();doDup();}
7904
- else if(k==='a'&&!inForm){e.preventDefault(); // Ctrl+A — select all MEMBERS (honouring the Members switch) plus, in 2D, the visible dims + grid lines. Was: active-plan members only, and it CLEARED dims + never grabbed grids.
7905
- // Scope to what's VISIBLE: 3D asks the renderer for visible member meshes after legend/isolate/work-area filtering; 2D uses the active plan (matching its marquee). Connections + 3D dims are picked by click/box, not swept by Ctrl+A.
7906
- const memberIds=view3d?(window.Steel3DView&&window.Steel3DView.visibleMemberIds?window.Steel3DView.visibleMemberIds():[]):P.members.map(m=>m.id);
7907
- selIds=new Set(memberIds.filter(id=>{const m=byId(id);return m&&selMemberOK(m);}));
7938
+ else if(k==='a'&&!inForm){e.preventDefault(); // Ctrl+A — select every visible/selectable object: 3D members + connection parts, plus logical grids when their switch is on; 2D keeps its members + dims + grids scope.
7939
+ // Scope to what's VISIBLE: 3D asks the renderer after legend/isolate/work-area/selection-hide filtering, then the editor applies its per-type Select switches. 2D uses the active plan, matching its marquee.
7940
+ const objectIds=view3d?(window.Steel3DView&&window.Steel3DView.visibleObjectIds?window.Steel3DView.visibleObjectIds():[]):P.members.map(m=>m.id);
7941
+ selIds=new Set(objectIds.filter(selIdOK));
7908
7942
  selDimIds.clear();sel3dDimIds.clear();selGridIds.clear();
7909
- if(selGridOK())selGridIds=new Set(gridSelectables().map(g=>g.id));
7943
+ if(selGridOK())selGridIds=new Set(view3d?(window.Steel3DView&&window.Steel3DView.visibleGridIds?window.Steel3DView.visibleGridIds():[]):gridSelectables().map(g=>g.id));
7910
7944
  if(!view3d){ // the 2D-drawable dimensions join the sweep
7911
7945
  if(selDimOK()&&dimsVisible)selDimIds=new Set((P.dims||[]).map(d=>d.id)); // dimensions now included — fixes the reported "Ctrl+A doesn't select dimensions" (skip when dims are hidden, like the marquee)
7912
7946
  }
7913
- render();}
7947
+ if(selIds.size||selDimIds.size||selGridIds.size)clearWholeReferenceSelection();
7948
+ render();}
7914
7949
  else if(k==='s'){e.preventDefault();persist();(window.flushContract?window.flushContract():Promise.resolve()).then(()=>toast('Saved ✓')).catch(()=>toast('Save failed'));}}); // edits autosave; Ctrl+S just flushes now (no browser "save page" dialog)
7915
7950
  // zoom bar
7916
7951
  document.getElementById('zIn').onclick=()=>zoomCentered(zoom*1.25);
@@ -8404,6 +8439,15 @@ function modelReadsV2(){
8404
8439
  return {g,geo:gc.gridGeometry(g,V2_PT_PER_FT,V2_GRID_OPTS),k:1,flipY:false};}, // k=1 and no flip: the stored coordinates ARE the scene's
8405
8440
  };
8406
8441
  }
8442
+ // One canvas has one action target. Direct native/grid/clip sinks call this before taking selection for
8443
+ // immediate state coherence, and render() is the invariant boundary that covers 2D + programmatic sinks.
8444
+ function clearWholeReferenceSelection(){
8445
+ if(!refSelectedId)return false;
8446
+ refSelectedId=null;refSelectedObjIdx=null;
8447
+ const v=window.Steel3DView;if(v&&v.selectReference)v.selectReference(null);
8448
+ if(legendTab==='refs')renderRefsTab();
8449
+ return true;
8450
+ }
8407
8451
  const view3dApi={
8408
8452
  // The model read half — see modelReadsV1 / modelReadsV2 above. Built ONCE per view init; the arm is
8409
8453
  // decided by MODEL_RO, which boot() pinned from the validated type and nothing changes afterwards.
@@ -8440,14 +8484,14 @@ const view3dApi={
8440
8484
  for(const p of (C.detail_placements||[])){if(!p||!p.id)continue;const raw=C.custom_details[p.detailName];if(raw==null)continue;const url=String(raw).startsWith('data:')?raw:'data:image/jpeg;base64,'+raw;const el={kind:'image',id:'det:'+p.id,group:'detail',url,pos:p.pos||[0,0,0],u:p.u,n:p.n,rotZ:p.rotZ||0,size:p.size||1000,opacity:p.opacity==null?1:p.opacity};sc.elements.push(el);pb[el.id]=el;}
8441
8485
  copesByMember=cm;partsById=pb;return sc;}, // cache resolved parts by id (real dims for the part Inspector) AND cope labels per member; placed details ride in as image elements
8442
8486
 
8443
- onSelect:(id,additive)=>{if(id&&!selIdOK(id))return;selDimIds.clear();sel3dDimIds.clear();if(!id){selIds=new Set();if(!additive)selGridIds.clear();}else{if(additive){selIds.has(id)?selIds.delete(id):selIds.add(id);}else{selIds=new Set([id]);selGridIds.clear();}}render();if(window.Steel3DView&&window.Steel3DView.refreshDims)window.Steel3DView.refreshDims();}, // 3D pick → shared model-wide selection (byId/selArr span all sheets, so no plan switch needed; clears dimension + non-additive grid selection so Delete is unambiguous). A filtered object (Select switch off) is inert.
8487
+ onSelect:(id,additive)=>{if(id&&!selIdOK(id))return;if(id)clearWholeReferenceSelection();selDimIds.clear();sel3dDimIds.clear();if(!id){selIds=new Set();if(!additive)selGridIds.clear();}else{if(additive){selIds.has(id)?selIds.delete(id):selIds.add(id);}else{selIds=new Set([id]);selGridIds.clear();}}render();if(window.Steel3DView&&window.Steel3DView.refreshDims)window.Steel3DView.refreshDims();}, // 3D pick → shared model-wide selection (byId/selArr span all sheets, so no plan switch needed; clears dimension + non-additive grid selection so Delete is unambiguous). A filtered object (Select switch off) is inert.
8444
8488
  onSelectMany:(ids,additive)=>{const ids2=(ids||[]).filter(selIdOK); // 3D box / whole-connection → gate each framed id through the Select switches (members by type, connection parts by kind)
8445
8489
  if(!additive&&(ids||[]).length&&!ids2.length)return; // a direct pick / box that caught ONLY filtered objects → inert (leave the current selection), matching a filtered single-pick; a genuinely empty box (ids empty) still falls through and clears
8446
- selDimIds.clear();sel3dDimIds.clear();
8490
+ if(ids2.length)clearWholeReferenceSelection();selDimIds.clear();sel3dDimIds.clear();
8447
8491
  if(additive){for(const id of ids2)selIds.has(id)?selIds.delete(id):selIds.add(id);} // Ctrl/Shift + 3D area-select → toggle each framed object into the current selection (add/remove), like Tekla — spans sheets
8448
8492
  else{selIds=new Set(ids2);selGridIds.clear();}
8449
8493
  if(mode==='add'){mode='sel';setMode();}render();if(window.Steel3DView&&window.Steel3DView.refreshDims)window.Steel3DView.refreshDims();}, // 3D box-select → shared selection
8450
- onSelectBatch:({memberIds=[],gridIds=[]},additive)=>{const mids=memberIds.filter(selIdOK),gridAllowed=selGridOK(),gids=gridAllowed?gridIds:[];if(!additive&&(memberIds.length||gridIds.length)&&!mids.length&&!gids.length)return;selDimIds.clear();sel3dDimIds.clear();if(additive){for(const id of mids)selIds.has(id)?selIds.delete(id):selIds.add(id);for(const id of gids)selGridIds.has(id)?selGridIds.delete(id):selGridIds.add(id);}else{selIds=new Set(mids);selGridIds=new Set(gids);if(window.Steel3DView&&window.Steel3DView.setSelectedClips)window.Steel3DView.setSelectedClips([]);}render();if(window.Steel3DView&&window.Steel3DView.refreshDims)window.Steel3DView.refreshDims();}, // Atomic 3D area/direct pick for members + logical grids: filter each class, toggle additively, otherwise replace both selections together.
8494
+ onSelectBatch:({memberIds=[],gridIds=[]},additive)=>{const mids=memberIds.filter(selIdOK),gridAllowed=selGridOK(),gids=gridAllowed?gridIds:[];if(!additive&&(memberIds.length||gridIds.length)&&!mids.length&&!gids.length)return;if(mids.length||gids.length)clearWholeReferenceSelection();selDimIds.clear();sel3dDimIds.clear();if(additive){for(const id of mids)selIds.has(id)?selIds.delete(id):selIds.add(id);for(const id of gids)selGridIds.has(id)?selGridIds.delete(id):selGridIds.add(id);}else{selIds=new Set(mids);selGridIds=new Set(gids);if(window.Steel3DView&&window.Steel3DView.setSelectedClips)window.Steel3DView.setSelectedClips([]);}render();if(window.Steel3DView&&window.Steel3DView.refreshDims)window.Steel3DView.refreshDims();}, // Atomic 3D area/direct pick for members + logical grids: filter each class, toggle additively, otherwise replace both selections together.
8451
8495
  // THE MEMBER LIST. v1 keeps one per sheet; v2 keeps ONE at the document root, which IS the whole model —
8452
8496
  // so for v2 both of these answer the same list, truthfully, rather than the silent [] that reading
8453
8497
  // `C.plans[].members` would give (§8.3). The view takes ids and hands the records back to
@@ -8471,6 +8515,9 @@ const view3dApi={
8471
8515
  originGrid:()=>({on:originGridOn,incMm:originGridInc*25.4}), // UCS Stage 6 origin-relative snap — read live per hover; incMm from the inches step. Off ⇒ view skips it; requires a local frame to have any effect
8472
8516
  canSelectId:(id)=>selIdOK(id), // Select-filter predicate for the 3D view (e.g. don't draw a whole-connection envelope for a fully-filtered connection)
8473
8517
  canSelectGrid:()=>selGridOK(), // Grid line/bubble picks and area selection obey the same Select switch as 2D.
8518
+ canSelectReference:()=>selReferenceOK(), // Reference picks/drills obey their 3D-only Select switch; visibility and snapping stay independent.
8519
+ gridScopeKey:()=>MODEL_V2?'model':String(((C&&Number.isInteger(C.active))?C.active:'')+':'+((P&&P.sheet)||'')), // v2's grid is model-global; v1 needs the plan index too because its valid schema permits duplicate sheet labels
8520
+ onGridSelectionReset:()=>queueMicrotask(()=>{if(!selGridIds.size)return;selGridIds.clear();render();}), // a grid rebuild may invalidate positional ids; mirror the renderer reset after its current stack completes
8474
8521
  ptPerFt:()=>MODEL_V2?v2Refuse('ptPerFt — a drawing scale belongs to a SHEET; v2 members and grid are world mm'):(P&&P.pt_per_ft>0?P.pt_per_ft:1),
8475
8522
  defaultTosMm:()=>MODEL_V2?v2Refuse('defaultTosMm — v2 materialised every elevation, so a substituted default would silently relocate members'):(defaultTOS!=null?defaultTOS*25.4:0), // editor stores default T.O.S in inches
8476
8523
  geoMode:()=>geoMode, // 'el' | 'split' | null — armed Trim/Extend/Split state
@@ -8530,7 +8577,7 @@ const view3dApi={
8530
8577
  onDeleteDim3d:(id)=>{if(!canWriteModel())return;C.dims3d=(C.dims3d||[]).filter(x=>x.id!==id);sel3dDimIds.delete(id);scheduleSave();refreshDims3d();},
8531
8578
  onSelectDim3d:(id,mods)=>{ // Ctrl/Shift multi-select (same as parts); selecting a dim is exclusive with member/2D-dim/clip selection
8532
8579
  if(id&&!selDimOK())return; // Dimensions select-switch off → a 3D dim is inert too
8533
- if(!id){sel3dDimIds.clear();render();return;}
8580
+ if(!id){sel3dDimIds.clear();render();return;}clearWholeReferenceSelection();
8534
8581
  selIds=new Set();selDimIds.clear();selGridIds.clear();if(window.Steel3DView&&window.Steel3DView.setSelectedClips)window.Steel3DView.setSelectedClips([]);
8535
8582
  const ids=(C.dims3d||[]).map(d=>d.id),cur=new Set(sel3dDimIds);let next;
8536
8583
  if(mods&&mods.shift&&dim3dAnchor!=null&&ids.includes(dim3dAnchor)&&ids.includes(id)){const i0=ids.indexOf(dim3dAnchor),i1=ids.indexOf(id);next=ids.slice(Math.min(i0,i1),Math.max(i0,i1)+1);}
@@ -8548,11 +8595,17 @@ const view3dApi={
8548
8595
  // app under the cursor without a round-trip per pointer move. Advisory: the release re-resolves.
8549
8596
  hostWindows:async()=>{try{const r=await fetch('/api/host-windows');return await r.json();}catch(e){return null;}},
8550
8597
  // 3D Move/Copy: the 3D view reads the armed tool + counts, and hands commit offsets back in scene mm.
8551
- cmState:()=>cmTool?{tool:cmTool,array:cmArrayMode,count:cmCount,countA:cmCountA,countB:cmCountB}:null,
8598
+ cmState:()=>cmTool?{tool:cmTool,array:cmArrayMode,count:cmCount,countA:cmCountA,countB:cmCountB,referenceId:(view3d&&refSelectedObjIdx===null?refSelectedId:null)}:null,
8552
8599
  // mm → plan px (Y FLIPPED) + inches for dz, now owned by the model boundary. toDisplayOffsets MUTATES
8553
8600
  // NOTHING on purpose: cmApplyOffsets below is what moves the members, and it also owns the empty-selection
8554
8601
  // toast, the 100-copy cap and the distance toast — which measures from these same ROUNDED offsets.
8555
- onTransform3d:(offsMm)=>{cmApplyOffsets(MC().toDisplayOffsets(offsMm));},
8602
+ onTransform3d:(offsMm)=>{const refTarget=refSelectedId&&refSelectedObjIdx===null?refById(refSelectedId):null;
8603
+ if(refTarget&&cmTool==='move'&&!selIds.size){const off=offsMm&&offsMm[0];if(!off||off.length<3)return;
8604
+ if(refDisp(refTarget).locked){toast('“'+refTarget.name+'” is locked — unlock it to move it');disarmCm();render();return;}
8605
+ const old=(refTarget.placement&&refTarget.placement.origin)||[0,0,0],next=[0,1,2].map(i=>(Number(old[i])||0)+(Number(off[i])||0));
8606
+ refEdit(refTarget.id,{placement:{origin:next}});
8607
+ toast('Moved 1 reference model · '+fmtFtIn(Math.hypot(off[0],off[1],off[2])/25.4));panel();return;}
8608
+ cmApplyOffsets(MC().toDisplayOffsets(offsMm));},
8556
8609
  disarmTransform:()=>{if(cmTool){disarmCm();render();}}, // the 3D dim tool arming kicks Move/Copy off the left-click
8557
8610
  // 3D draw-on-plane (spec §7): the editor's add-member mode + profile drive it; two plane picks (scene mm) come back here.
8558
8611
  addModeActive:()=>mode==='add',
@@ -8577,7 +8630,7 @@ const view3dApi={
8577
8630
  selIds=new Set([id]);});
8578
8631
  const asCol=hIn<6&&dzIn>6;
8579
8632
  toast('Added '+(asCol?'a column':'a beam')+' on the working plane'+(((addType==='column')!==asCol)?' — the pick geometry set the type, not '+memberTypeLabel(addType):''));}, // say it out loud when 3D geometry overrode the Add panel's type
8580
- onClipsChange:()=>{build3DLegend();}, // a clip added / removed / toggled → rebuild the legend's Clip section
8633
+ onClipsChange:()=>{const v=window.Steel3DView;if(v&&v.selectedClips&&v.selectedClips().length)clearWholeReferenceSelection();build3DLegend();}, // a clip added / removed / toggled → its renderer-side selection also takes the one action target, then rebuild the legend's Clip section
8581
8634
  beginClipEdit:()=>pushUndo(snapshot()), // a clip / work-area manipulation → push a pre-edit snapshot so Ctrl+Z/Y restores it
8582
8635
  onClipModeChange:(m)=>{const b=document.getElementById('m3dClip');if(b){b.classList.toggle('on',!!m);b.textContent=m?'Clip ✕':'Clip ▾';}}, // armed → button fills brand-blue + becomes a cancel target (✕ = cancel)
8583
8636
  onInsertModeChange:(on)=>{const b=document.getElementById('m3dInsert');if(b){b.classList.toggle('on',!!on);b.textContent=on?'✕ Cancel insert':'Insert…';} if(!on)favDisarmed();}, // armed → cancel target; disarm also clears any armed favourite (the pinned bar + the .armed row)
@@ -8591,22 +8644,16 @@ const view3dApi={
8591
8644
  // describing the first object while the 3D view highlights the second.
8592
8645
  onReferenceSelect:(id,obj)=>{
8593
8646
  const nextId=id||null,nextIdx=obj&&Number.isInteger(obj.index)?obj.index:null;
8594
- if(refSelectedId===nextId&&refSelectedObjIdx===nextIdx)return;
8647
+ const nativeSelected=selIds.size||selDimIds.size||selGridIds.size||sel3dDimIds.size;
8648
+ if(refSelectedId===nextId&&refSelectedObjIdx===nextIdx&&!(nextId&&nativeSelected))return;
8595
8649
  refSelectedId=nextId;refSelectedObjIdx=nextIdx;
8596
- // DRILLING IN TAKES THE SELECTION, NOT JUST THE PANEL — the exact mirror of `clickSelect` dropping the
8597
- // reference the moment a click lands on one of our own members. The two are one selection between
8598
- // them, and the first cut let them coexist: with a beam selected, drilling into a reference object put
8599
- // its facts in the panel while Delete and the arrow keys still acted on the beam. Panel and keystroke
8600
- // target pointing at different things is the worst state this feature has.
8601
- //
8602
- // Only a DRILL steals. Selecting a whole reference (a row click) does not take the panel, so it has no
8603
- // business taking the selection either.
8604
- //
8605
- // This is also what keeps `panel()`'s release guard from fighting an intentional drill: the guard fires
8606
- // when something of ours is selected, and by the time it runs, nothing is. The browser pass caught
8607
- // that — with a marquee selection live, drilling was silently impossible.
8608
- const stole=nextIdx!==null&&(selIds.size||selDimIds.size||selGridIds.size||sel3dDimIds.size);
8650
+ // A REFERENCE TAKES THE SELECTION, whole or drilled. Move with two points accepts a whole reference,
8651
+ // so letting a beam remain selected would make one toolbar command have two incompatible targets.
8652
+ // Drilling already needed the same exclusivity for a more dangerous reason: the panel could describe
8653
+ // an IFC object while Delete and the arrow keys still acted on our beam. One canvas now has one target.
8654
+ const stole=nextId!==null&&!!nativeSelected;
8609
8655
  if(stole){selIds.clear();selDimIds.clear();selGridIds.clear();sel3dDimIds.clear();}
8656
+ if(nextId&&window.Steel3DView&&window.Steel3DView.setSelectedClips)window.Steel3DView.setSelectedClips([]);
8610
8657
  // The object tree, if the user has it open, comes to the object — see `revealRefTreeObject`. It
8611
8658
  // repaints the tab itself, so the ordinary repaint below is skipped when it did.
8612
8659
  if(!(nextId&&nextIdx!==null&&revealRefTreeObject(nextId,nextIdx))&&legendTab==='refs')renderRefsTab();
@@ -8730,7 +8777,7 @@ const view3dApi={
8730
8777
  edit(()=>{if(!Array.isArray(C.detail_placements))C.detail_placements=[];C.detail_placements.push(place);selIds=new Set(['det:'+id]);});
8731
8778
  toast('Detail placed'+(pick.anchorId?' on '+pick.anchorId:'')+' — adjust it in the panel or ask the AI to build it');
8732
8779
  detailRequest('create',place);},
8733
- onIsolateChange:()=>{updateIsolateBtn();refresh3DLegend();}, // isolate / show-all (incl. Esc, legend "show all", showAllGroups clearing connHidden) → refresh the toolbar button + the legend rows' hidden state
8780
+ onIsolateChange:()=>{updateIsolateBtn();refresh3DLegend();}, // every object-visibility change (isolate, group/part/selection hide, Show all) → refresh recovery control + legend rows
8734
8781
  onWorkAreaChange:()=>updateWorkBtn(), // work area set / toggled → refresh the button + its checkbox
8735
8782
  };
8736
8783
  // Re-extrude the 3D model after a structural edit (keeps the camera where it is). Selection-only
@@ -8799,6 +8846,7 @@ let clipAnchor=null;
8799
8846
  // Shift = the range from the anchor (in list order). Selecting a clip clears member/dim/grid selection (exclusive).
8800
8847
  function clipSelect(id,e){
8801
8848
  if(!window.Steel3DView)return;
8849
+ clearWholeReferenceSelection();
8802
8850
  if(selIds.size||sel3dDimIds.size||selGridIds.size||(typeof selDimIds!=='undefined'&&selDimIds.size)){selIds=new Set();sel3dDimIds.clear();selGridIds.clear();if(typeof selDimIds!=='undefined')selDimIds.clear();render();}
8803
8851
  const ids=window.Steel3DView.getClips().map(c=>c.id),cur=new Set(window.Steel3DView.selectedClips());
8804
8852
  let next;
@@ -11712,8 +11760,8 @@ function build3DLegend(){const host=document.getElementById('m3dLegendBody');if(
11712
11760
  if(opts.onToggle)tog.addEventListener('click',e=>{e.stopPropagation();opts.onToggle();refresh3DLegend();});
11713
11761
  updateCatTog(hdr);return hdr;};
11714
11762
  // master state/action over a set of part-group keys (members + connection categories share this)
11715
- const grpState=keys=>{const h=new Set(window.Steel3DView.groupState().hidden);const n=keys.filter(k=>h.has(k)).length;return n===0?'on':(n===keys.length?'off':'mixed');};
11716
- const grpToggle=keys=>{const h=new Set(window.Steel3DView.groupState().hidden);window.Steel3DView.setGroupsHidden(keys,keys.every(k=>!h.has(k)));}; // all-on → hide all; else show all
11763
+ const grpState=keys=>{const h=new Set(window.Steel3DView.groupState().hidden),sh=new Set(window.Steel3DView.selectionHiddenIds?window.Steel3DView.selectionHiddenIds():[]);let shown=0,hiddenCount=0;for(const k of keys){const ids=allMembers().filter(m=>profileKeyOf(m)===k).map(m=>m.id),n=ids.filter(id=>sh.has(id)).length;if(h.has(k)||(ids.length&&n===ids.length))hiddenCount++;else if(n){}else shown++;}return hiddenCount===keys.length?'off':(shown===keys.length?'on':'mixed');};
11764
+ const grpToggle=keys=>{window.Steel3DView.setGroupsHidden(keys,grpState(keys)==='on');}; // all-on → hide all; mixed/off → show all (also clears Hide-selected ids in those groups)
11717
11765
  const members=groups.filter(g=>!CONN_ORDER.includes(g.key));
11718
11766
  const conns=groups.filter(g=>CONN_ORDER.includes(g.key)).sort((a,b)=>CONN_ORDER.indexOf(a.key)-CONN_ORDER.indexOf(b.key));
11719
11767
  if(members.length){ // By profile ⇄ By type toggle, above the hint
@@ -11756,7 +11804,7 @@ function build3DLegend(){const host=document.getElementById('m3dLegendBody');if(
11756
11804
  else{
11757
11805
  const byConn=new Map(); // connType → Map(part-kind → [ids])
11758
11806
  for(const e of connParts){const ct=connTypeOf(e.id);if(!byConn.has(ct))byConn.set(ct,new Map());const pk=byConn.get(ct);if(!pk.has(e.group))pk.set(e.group,[]);pk.get(e.group).push(e.id);}
11759
- const hiddenSet=()=>new Set(window.Steel3DView.connHiddenIds());
11807
+ const hiddenSet=()=>new Set([...(window.Steel3DView.connHiddenIds?window.Steel3DView.connHiddenIds():[]),...(window.Steel3DView.selectionHiddenIds?window.Steel3DView.selectionHiddenIds():[])]);
11760
11808
  const order=[...CONN_TYPES.map(t=>t.k),...[...byConn.keys()].filter(k=>!CONN_TYPES.some(t=>t.k===k))];
11761
11809
  for(const ct of order){const pk=byConn.get(ct);if(!pk||!pk.size)continue;
11762
11810
  const allIds=[].concat(...[...pk.values()]),label=(CONN_TYPES.find(t=>t.k===ct)||{}).label||'Other',ck='conn-'+ct;
@@ -11835,14 +11883,15 @@ function build3DLegend(){const host=document.getElementById('m3dLegendBody');if(
11835
11883
  }
11836
11884
  {const rst=Object.assign(document.createElement('div'),{className:'lreset',id:'m3dLegendReset',textContent:'Show all'});rst.setAttribute('role','button');rst.dataset.tip='Restore every hidden / isolated object in this panel';rst.addEventListener('click',legendReset);host.insertBefore(rst,host.firstChild);} // Show-all reset — body's first child (above the mode toggle); visibility set by updateLegendReset (via refresh3DLegend)
11837
11885
  refresh3DLegend();applyLegendFilter();refreshLegendSel();} // the Objects body's visibility is owned by the active-tab class, not set here
11838
- // The contextual Isolate / Show all toolbar button: visible when something's selected OR while isolated (so
11839
- // "Show all" stays reachable after the selection is cleared). Updated on selection change + via onIsolateChange.
11840
- function updateIsolateBtn(){const b=document.getElementById('m3dIso');if(!b||!window.Steel3DView||!window.Steel3DView.isIsolated)return;
11841
- const iso=window.Steel3DView.isIsolated();
11842
- b.style.display=(iso||selIds.size>0)?'':'none';
11843
- b.classList.toggle('on',iso);
11844
- b.textContent=iso?'Show all':'Isolate';
11845
- b.setAttribute('data-tip', iso?'Restore all hidden members':'Isolate selected — hide everything else (Esc to exit)');} // themed tooltip, updated with state (no native title)
11886
+ // Contextual visibility menu: selection exposes Isolate/Hide; any active object filter keeps Show all reachable
11887
+ // after Hide selected clears that now-invisible selection. Updated on selection change + every visibility callback.
11888
+ function updateIsolateBtn(){const wrap=document.getElementById('m3dIsoWrap'),b=document.getElementById('m3dIso'),menu=document.getElementById('m3dIsoMenu');if(!wrap||!b||!menu||!window.Steel3DView)return;
11889
+ const V=window.Steel3DView,filtered=V.hasVisibilityFilter?V.hasVisibilityFilter():!!(V.isIsolated&&V.isIsolated()),hasSel=selIds.size>0||selGridIds.size>0;
11890
+ const visible=filtered||hasSel;if(!visible&&wrap.contains(document.activeElement)){const stable=document.getElementById('m3dViewsBtn');if(stable)stable.focus();}wrap.style.display=visible?'':'none';b.classList.toggle('on',filtered);b.textContent=filtered?'Show all ▾':'Isolate ▾';
11891
+ b.setAttribute('data-tip',filtered?'Restore hidden objects or change the current selection’s visibility':'Visibility actions for the selected objects');
11892
+ const show=menu.querySelector('[data-vis=show-all]'),div=menu.querySelector('[data-vis-divider]'),iso=menu.querySelector('[data-vis=isolate]'),hide=menu.querySelector('[data-vis=hide]');
11893
+ if(show)show.style.display=filtered?'':'none';if(div)div.style.display=(filtered&&hasSel)?'':'none';if(iso)iso.style.display=hasSel?'':'none';if(hide)hide.style.display=hasSel?'':'none';
11894
+ if(!filtered&&!hasSel){menu.classList.remove('open');b.setAttribute('aria-expanded','false');}}
11846
11895
  // The Work area button + its two slider toggles reflect the live work-area state (api.onWorkAreaChange).
11847
11896
  // "Show work area" = box drawn / sectioning on; "Show whole parts" = touching parts shown whole vs cut at the box.
11848
11897
  // The whole-parts row only appears once a work area exists (nothing to act on before that — no dimmed dead control).
@@ -11855,10 +11904,10 @@ function updateWorkBtn(){const b=document.getElementById('m3dWork'),ck=document.
11855
11904
  // some = ◪ mixed. Colour comes from data-state (CSS); the glyph from the textContent.
11856
11905
  function updateCatTog(hdr){const tog=hdr&&hdr.querySelector('.cat-tog');if(!tog||!hdr._getState||tog.style.display==='none')return;
11857
11906
  const state=hdr._getState();tog.dataset.state=state;tog.textContent=state==='on'?'■':(state==='off'?'□':'◪');}
11858
- function refresh3DLegend(){if(!window.Steel3DView)return;const st=window.Steel3DView.groupState(),hidden=new Set(st.hidden),solo=new Set(st.solo);
11859
- document.querySelectorAll('#m3dLegend .lrow[data-key]').forEach(r=>{const k=r.dataset.key;const off=hidden.has(k)||(solo.size>0&&!solo.has(k));r.classList.toggle('off',off);r.classList.toggle('solo',solo.size>0&&solo.has(k));const sw=r.querySelector('.lsw');if(sw)sw.setAttribute('aria-checked',String(!off));}); // PROFILE rows (data-key); .off = hidden or outside the isolated set → box hollows; .solo = inside it (Explorer-style highlight)
11907
+ function refresh3DLegend(){if(!window.Steel3DView)return;const st=window.Steel3DView.groupState(),hidden=new Set(st.hidden),solo=new Set(st.solo),sh=new Set(window.Steel3DView.selectionHiddenIds?window.Steel3DView.selectionHiddenIds():[]);
11908
+ document.querySelectorAll('#m3dLegend .lrow[data-key]').forEach(r=>{const k=r.dataset.key,ids=legRowIds(r),n=ids.filter(id=>sh.has(id)).length;const off=hidden.has(k)||(solo.size>0&&!solo.has(k))||(ids.length>0&&n===ids.length),mixed=!off&&n>0;r.classList.toggle('off',off);r.classList.toggle('mixed',mixed);r.classList.toggle('solo',solo.size>0&&solo.has(k));const sw=r.querySelector('.lsw');if(sw)sw.setAttribute('aria-checked',mixed?'mixed':String(!off));}); // PROFILE rows: filled=shown, hollow=hidden, dash=mixed
11860
11909
  const ch=new Set(window.Steel3DView.connHiddenIds?window.Steel3DView.connHiddenIds():[]); // per-part connection hide
11861
- document.querySelectorAll('#m3dLegend .lrow[data-connkey]').forEach(r=>{const ids=r._ids||[];const off=ids.length>0&&ids.every(id=>ch.has(id));r.classList.toggle('off',off);const sw=r.querySelector('.lsw');if(sw)sw.setAttribute('aria-checked',String(!off));});
11910
+ document.querySelectorAll('#m3dLegend .lrow[data-connkey]').forEach(r=>{const ids=r._ids||[],n=ids.filter(id=>ch.has(id)||sh.has(id)).length,off=ids.length>0&&n===ids.length,mixed=!off&&n>0;r.classList.toggle('off',off);r.classList.toggle('mixed',mixed);const sw=r.querySelector('.lsw');if(sw)sw.setAttribute('aria-checked',mixed?'mixed':String(!off));});
11862
11911
  document.querySelectorAll('#m3dLegend .cat-hdr').forEach(updateCatTog);updateLegendReset();} // refresh the type-category master toggles + the show-all reset bar's visibility
11863
11912
  // ── Objects-list SELECTION — click a row (its name) to select its object[s] in 3D; Ctrl/Cmd add/remove, Shift range ──
11864
11913
  // Plain click is deferred (leg3dClickT) so a dbl-click can isolate instead; a modified click selects immediately
@@ -11866,6 +11915,7 @@ function refresh3DLegend(){if(!window.Steel3DView)return;const st=window.Steel3D
11866
11915
  function legendRowClick(e,row){if(row&&row._dragging)return;const mods={ctrl:e.ctrlKey||e.metaKey,shift:e.shiftKey};clearTimeout(leg3dClickT);if(mods.ctrl||mods.shift)legendSelect(row,mods);else leg3dClickT=setTimeout(()=>legendSelect(row,mods),220);}
11867
11916
  function legendSelect(row,mods){
11868
11917
  if(!row)return;const ids=legRowIds(row);if(!ids.length)return;
11918
+ clearWholeReferenceSelection();
11869
11919
  if(mods&&mods.shift&&legendSelAnchor&&document.body.contains(legendSelAnchor)){ // Shift → union every VISIBLE object row from the anchor to here (a search-hidden row can't be range-selected)
11870
11920
  const rows=[...document.querySelectorAll('#m3dLegend .lrow[data-key]:not(.qhide),#m3dLegend .lrow[data-connkey]:not(.qhide)')];
11871
11921
  const i0=rows.indexOf(legendSelAnchor),i1=rows.indexOf(row);
@@ -11882,7 +11932,7 @@ function refreshLegendSel(){const host=document.getElementById('m3dLegend');if(!
11882
11932
  // (the clicked row's current state drives the direction). Members toggle by group key, connections by part id.
11883
11933
  function legendBoxToggle(row){if(!row||!window.Steel3DView)return;
11884
11934
  const rows=row.classList.contains('lsel')?[...document.querySelectorAll('#m3dLegend .lrow.lsel')]:[row];
11885
- const willHide=!row.classList.contains('off'); // one direction for all: hide if the clicked box was shown, else show
11935
+ const willHide=!row.classList.contains('off')&&!row.classList.contains('mixed'); // filled → hide; hollow/dash → show all
11886
11936
  const keys=[],ids=[];for(const r of rows){if(r.dataset.connkey)ids.push(...(r._ids||[]));else if(r.dataset.key)keys.push(r.dataset.key);}
11887
11937
  if(keys.length&&window.Steel3DView.setGroupsHidden)window.Steel3DView.setGroupsHidden(keys,willHide);
11888
11938
  if(ids.length&&window.Steel3DView.setIdsHidden)window.Steel3DView.setIdsHidden(ids,willHide);
@@ -11899,7 +11949,7 @@ function legendReset(){if(!window.Steel3DView)return;window.Steel3DView.showAllG
11899
11949
  // Show the reset bar only when 3D visibility is non-default (something hidden / solo'd / isolated). Indifferent to search.
11900
11950
  function updateLegendReset(){const b=document.getElementById('m3dLegendReset');if(!b||!window.Steel3DView)return;
11901
11951
  const st=window.Steel3DView.groupState();
11902
- const filtered=(st.hidden&&st.hidden.length>0)||(st.solo&&st.solo.length>0)||(window.Steel3DView.isIsolated&&window.Steel3DView.isIsolated())||(window.Steel3DView.connHiddenIds&&window.Steel3DView.connHiddenIds().length>0);
11952
+ const filtered=(window.Steel3DView.hasVisibilityFilter&&window.Steel3DView.hasVisibilityFilter())||(st.hidden&&st.hidden.length>0)||(st.solo&&st.solo.length>0)||(window.Steel3DView.isIsolated&&window.Steel3DView.isIsolated())||(window.Steel3DView.connHiddenIds&&window.Steel3DView.connHiddenIds().length>0);
11903
11953
  b.classList.toggle('show',filtered);}
11904
11954
  // ── Objects-list SEARCH ──────────────────────────────────────────────────────────────────────────────────────
11905
11955
  // Search narrows the MEMBER + CONNECTION rows only (never Dimensions/Grid/Clip, never the 3D scene). Crossing
@@ -11971,14 +12021,23 @@ function wire3DBar(){if(bar3dWired||!window.Steel3DView)return;bar3dWired=true;
11971
12021
  // Property labels: independent 3D visibility for the shared prop-label selection (B1) — clears/repushes the 3D labels.
11972
12022
  document.getElementById('m3dPropLabels').onchange=e=>{if(!canWritePropLabelVis()){e.target.checked=plVis(true);return;}C.prop_labels.vis3d=e.target.checked;scheduleSave();refreshPropLabels3d();};
11973
12023
  roDisablePropLabelToggles(); // the 3D legend is built lazily, so the boot-time pass could not have reached this one
12024
+ function sync3dAnnotationChecks(){document.getElementById('m3dRef').checked=!!d3.refLine();document.getElementById('m3dLabels').checked=!!d3.labelsOn();document.getElementById('m3dPropLabels').checked=!!(C.prop_labels&&plVis(true));}
12025
+ function setAll3dAnnotations(show){if(!canWritePropLabelVis()){sync3dAnnotationChecks();toast('Annotation visibility is locked for this model');return;}
12026
+ d3.setRefLine(show);d3.setLabelsOn(show);C.prop_labels.vis3d=show;scheduleSave();refreshPropLabels3d();sync3dAnnotationChecks();}
11974
12027
  // View menu: groups the Ref line + Labels toggles (same open/close discipline as Clip / Work area / Plane).
11975
12028
  const viewBtn=document.getElementById('m3dView'),viewMenu=document.getElementById('m3dViewMenu');
12029
+ function menuItems(menu){return [...menu.querySelectorAll('button,input')].filter(el=>!el.disabled&&el.offsetParent!==null);}
12030
+ function menuKeys(e,menu,trigger,close){const items=menuItems(menu);if(e.key==='Escape'){e.preventDefault();e.stopPropagation();close(true);return;}if(!items.length)return;const i=items.indexOf(document.activeElement);if(e.key==='ArrowDown'){e.preventDefault();e.stopPropagation();items[(i+1+items.length)%items.length].focus();}else if(e.key==='ArrowUp'){e.preventDefault();e.stopPropagation();items[(i-1+items.length)%items.length].focus();}else if(e.key==='Home'){e.preventDefault();e.stopPropagation();items[0].focus();}else if(e.key==='End'){e.preventDefault();e.stopPropagation();items[items.length-1].focus();}else if((e.key==='Enter'||e.key===' ')&&i>=0){e.preventDefault();e.stopPropagation();items[i].click();}}
11976
12031
  function viewMenuOutside(e){if(!viewMenu.contains(e.target)&&e.target!==viewBtn)viewMenuClose();}
11977
- function viewMenuClose(){viewMenu.classList.remove('open');document.removeEventListener('mousedown',viewMenuOutside,true);}
12032
+ function viewMenuClose(focus=false){viewMenu.classList.remove('open');viewBtn.setAttribute('aria-expanded','false');document.removeEventListener('mousedown',viewMenuOutside,true);if(focus)viewBtn.focus();}
11978
12033
  viewBtn.onclick=e=>{e.stopPropagation();
11979
12034
  if(viewMenu.classList.contains('open'))viewMenuClose();
11980
- else{document.getElementById('m3dRef').checked=!!d3.refLine();document.getElementById('m3dLabels').checked=!!d3.labelsOn();document.getElementById('m3dPropLabels').checked=!!(C.prop_labels&&plVis(true)); // reflect live state on open
11981
- viewMenu.classList.add('open');document.addEventListener('mousedown',viewMenuOutside,true);}};
12035
+ else{sync3dAnnotationChecks();document.getElementById('m3dViewActions').style.display=canWritePropLabelVis()?'':'none'; // all means all: omit the bulk row if Property labels cannot be changed
12036
+ viewMenu.classList.add('open');viewBtn.setAttribute('aria-expanded','true');document.addEventListener('mousedown',viewMenuOutside,true);menuItems(viewMenu)[0]?.focus();}};
12037
+ document.getElementById('m3dViewHideAll').onclick=()=>setAll3dAnnotations(false);
12038
+ document.getElementById('m3dViewShowAll').onclick=()=>setAll3dAnnotations(true);
12039
+ viewBtn.addEventListener('keydown',e=>{if(e.key==='Escape'&&viewMenu.classList.contains('open')){e.preventDefault();e.stopPropagation();viewMenuClose(true);}else if((e.key==='ArrowDown'||e.key==='Enter'||e.key===' ')&&!viewMenu.classList.contains('open')){e.preventDefault();e.stopPropagation();viewBtn.click();}});
12040
+ viewMenu.addEventListener('keydown',e=>menuKeys(e,viewMenu,viewBtn,viewMenuClose));
11982
12041
  // Insert a detail: the ▾ menu lists the detail library + an "add image" option; picking one arms a
11983
12042
  // placement pick (onInsertPlace drops it). While armed the button is a cancel target (onInsertModeChange).
11984
12043
  // The menu is built with DOM nodes (textContent) — the detail names are user text, never innerHTML.
@@ -12095,7 +12154,18 @@ function wire3DBar(){if(bar3dWired||!window.Steel3DView)return;bar3dWired=true;
12095
12154
  ci$('ciBackdrop').onclick=()=>{if(ci$('ciProgStage').style.display==='none')ciClose();}; // no-op mid-run so a stray backdrop click can't orphan the AWARE run
12096
12155
  document.addEventListener('keydown',e=>{if(e.key==='Escape'&&ci$('connImportModal').style.display==='flex'){e.stopPropagation();ciClose();}},true);
12097
12156
  }
12098
- document.getElementById('m3dIso').onclick=()=>{if(d3.isIsolated())d3.clearIsolation();else d3.isolateSelected();}; // onIsolateChange refreshes the button label/visibility
12157
+ // Selection visibility: Isolate + Hide share one contextual menu; Show all remains reachable after the
12158
+ // hidden selection is cleared. Same outside-click/Escape discipline as the neighbouring 3D menus.
12159
+ const isoBtn=document.getElementById('m3dIso'),isoMenu=document.getElementById('m3dIsoMenu');
12160
+ function isoMenuOutside(e){if(!isoMenu.contains(e.target)&&e.target!==isoBtn)isoMenuClose();}
12161
+ function isoMenuClose(focus=false){isoMenu.classList.remove('open');isoBtn.setAttribute('aria-expanded','false');document.removeEventListener('mousedown',isoMenuOutside,true);if(focus){const wrap=document.getElementById('m3dIsoWrap');(wrap.style.display!=='none'?isoBtn:document.getElementById('m3dViewsBtn'))?.focus();}}
12162
+ isoBtn.onclick=e=>{e.stopPropagation();if(isoMenu.classList.contains('open'))isoMenuClose();else{updateIsolateBtn();const tip=document.getElementById('tooltip');if(tip)tip.classList.remove('show'); // the trigger tip must not cover the first menu row when the menu opens beneath the pointer
12163
+ isoMenu.classList.add('open');isoBtn.setAttribute('aria-expanded','true');document.addEventListener('mousedown',isoMenuOutside,true);menuItems(isoMenu)[0]?.focus();}};
12164
+ isoMenu.querySelector('[data-vis=show-all]').onclick=()=>{d3.showAllGroups();isoMenuClose(true);toast('Showing all objects');};
12165
+ isoMenu.querySelector('[data-vis=isolate]').onclick=()=>{d3.isolateSelected();isoMenuClose(true);};
12166
+ isoMenu.querySelector('[data-vis=hide]').onclick=()=>{const n=d3.hideSelected?d3.hideSelected():0;if(n){selIds.clear();selGridIds.clear();render();toast(n+' object'+(n===1?'':'s')+' hidden');}isoMenuClose(true);};
12167
+ isoBtn.addEventListener('keydown',e=>{if(e.key==='Escape'&&isoMenu.classList.contains('open')){e.preventDefault();e.stopPropagation();isoMenuClose(true);}else if((e.key==='ArrowDown'||e.key==='Enter'||e.key===' ')&&!isoMenu.classList.contains('open')){e.preventDefault();e.stopPropagation();isoBtn.click();}});
12168
+ isoMenu.addEventListener('keydown',e=>menuKeys(e,isoMenu,isoBtn,isoMenuClose));
12099
12169
  // Views toolbar button: open the panel on the Views tab (or, if it's already open on Views, toggle it closed — a natural toolbar toggle).
12100
12170
  {const vb=document.getElementById('m3dViewsBtn');if(vb)vb.onclick=()=>{const p=document.getElementById('m3dLegend');const openOnViews=p&&p.style.display!=='none'&&legendTab==='views';if(openOnViews)setLegendPanelCollapsed(true);else{wireLegendTabs();showLegendPanel('views',true);}updateViewsBtn();};}
12101
12171
  // Work area: the ▢ Work area button opens a menu (Set to all objects / Define from selection / Show work area).
@@ -14517,7 +14587,8 @@ boot().catch(err => { document.body.replaceChildren(Object.assign(document.creat
14517
14587
  // Themed tooltips (replaces native title=) for the 3D toolbar — one shared element, shown on
14518
14588
  // data-tip hover after a short delay, positioned below the control and clamped to the viewport.
14519
14589
  (function(){ const tip=document.createElement('div'); tip.id='tooltip'; document.body.appendChild(tip); let t=null;
14520
- function show(el){ const txt=el.getAttribute('data-tip'); if(!txt) return; tip.textContent=txt; tip.classList.add('show');
14590
+ function show(el){ if(el.getAttribute('aria-haspopup')==='menu'&&el.getAttribute('aria-expanded')==='true')return; // an opening trigger can still have a pending hover timer; never let its tip cover the menu below it
14591
+ const txt=el.getAttribute('data-tip'); if(!txt) return; tip.textContent=txt; tip.classList.add('show');
14521
14592
  const r=el.getBoundingClientRect(), tw=tip.offsetWidth, th=tip.offsetHeight;
14522
14593
  let x=Math.max(6,Math.min(r.left+r.width/2-tw/2, innerWidth-tw-6)), y=r.bottom+6; if(y+th>innerHeight-6) y=r.top-th-6;
14523
14594
  tip.style.left=x+'px'; tip.style.top=y+'px'; }
@@ -296,6 +296,7 @@ export function createV2CommandSession(model, options = {}) {
296
296
  if (Object.hasOwn(saved, 'member_types')) draft.member_types = clone(saved.member_types || []);
297
297
  if (Object.hasOwn(saved, 'dim_style')) draft.dim_style = clone(saved.dim_style || {});
298
298
  if (Object.hasOwn(saved, 'member_styles')) draft.member_styles = clone(saved.member_styles || {});
299
+ if (Object.hasOwn(saved, 'reference_models')) draft.reference_models = clone(saved.reference_models || []);
299
300
  return { structural: true };
300
301
  });
301
302
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floless/app",
3
- "version": "0.127.4",
3
+ "version": "0.127.6",
4
4
  "type": "module",
5
5
  "description": "Thin localhost host for floless.app — serves web/ and shells the aware CLI. No engine, no LLM.",
6
6
  "bin": {