@pasquelin/panels 0.2.0 → 0.3.0
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.
- package/CHANGELOG.md +28 -0
- package/dist/core/types.d.ts +9 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +120 -116
- package/llms-full.txt +10 -1
- package/llms.txt +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,33 @@ All notable changes to `@pasquelin/panels`.
|
|
|
5
5
|
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
|
|
6
6
|
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.3.0] — 2026-09-01
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **`fillActions` on `<Panel>`.** Whether a panel's actions take the header's free width or hug
|
|
13
|
+
the close button. The chassis guessed it from "publishes actions and sits in a horizontal
|
|
14
|
+
zone", which is right for a montage bar and wrong for a band holding a list with two buttons —
|
|
15
|
+
and only the project knows which of its panels is which. Left out, the guess stands.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- **`reset()` no longer settles against an empty registry.** Called before any panel is declared
|
|
20
|
+
it settled the view EMPTY — and an entry is what stops anything reopening it, so every half
|
|
21
|
+
stayed shut for good.
|
|
22
|
+
- **`<Panel>` fields reach the registry by spread**, not one by one. `fillActions` was the second
|
|
23
|
+
field in two releases to be added to the type and forgotten in the collector.
|
|
24
|
+
|
|
25
|
+
### Tests
|
|
26
|
+
|
|
27
|
+
- The frame's GEOMETRY is covered here at last: a zone drawing nothing takes neither room nor
|
|
28
|
+
handle, a column keeps its divider only between two open halves, an untouched half is flexed
|
|
29
|
+
rather than sized, the band runs under the opposite column and parts its own two halves.
|
|
30
|
+
🛑 These were IA Studio's, and it let them go on migrating — on the assumption that this
|
|
31
|
+
library covered them. It did not.
|
|
32
|
+
- `PanelHeader` keeps what is trailing outside the box that clips: a crowded row loses its
|
|
33
|
+
actions, never its way out.
|
|
34
|
+
|
|
8
35
|
## [0.2.0] — 2026-09-01
|
|
9
36
|
|
|
10
37
|
Two changes to the same idea: **what a half shows is resolved when it is drawn, not written down
|
|
@@ -148,6 +175,7 @@ First release.
|
|
|
148
175
|
- Optional `@pasquelin/panels/dockview` entry point for document tabs.
|
|
149
176
|
- No runtime dependencies.
|
|
150
177
|
|
|
178
|
+
[0.3.0]: https://github.com/pasquelin/panels/releases/tag/v0.3.0
|
|
151
179
|
[0.2.0]: https://github.com/pasquelin/panels/releases/tag/v0.2.0
|
|
152
180
|
[0.1.1]: https://github.com/pasquelin/panels/releases/tag/v0.1.1
|
|
153
181
|
[0.1.0]: https://github.com/pasquelin/panels/releases/tag/v0.1.0
|
package/dist/core/types.d.ts
CHANGED
|
@@ -68,6 +68,15 @@ export type PanelSpec<Id extends string = string> = {
|
|
|
68
68
|
opens?: number;
|
|
69
69
|
/** Takes the zone WHOLE: shown, the other half draws nothing. `primary` only. */
|
|
70
70
|
solo?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Lets the actions take the header's free width rather than hug the close button — for a
|
|
73
|
+
* panel whose row is wide and mostly empty, and which carries a whole bar there.
|
|
74
|
+
*
|
|
75
|
+
* Left out, the chassis gives that width to any panel in a horizontal zone that publishes
|
|
76
|
+
* actions. Which is a guess: a band holding a list with two buttons wants them at the end,
|
|
77
|
+
* and only the project knows which of its panels is which.
|
|
78
|
+
*/
|
|
79
|
+
fillActions?: boolean;
|
|
71
80
|
};
|
|
72
81
|
/**
|
|
73
82
|
* Which panel each half of each zone currently shows. Three states, not two: the key absent is
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),d=require("react"),x=require("./cx-YyuC5RtB.cjs"),fe=e=>{let n;const t=new Set,s=(a,f)=>{const h=typeof a=="function"?a(n):a;if(!Object.is(h,n)){const p=n;n=f??(typeof h!="object"||h===null)?h:Object.assign({},n,h),t.forEach(g=>g(n,p))}},c=()=>n,i={setState:s,getState:c,getInitialState:()=>l,subscribe:a=>(t.add(a),()=>t.delete(a))},l=n=e(s,c,i);return i},Ge=(e=>e?fe(e):fe),Je=e=>e;function Ke(e,n=Je){const t=d.useSyncExternalStore(e.subscribe,d.useCallback(()=>n(e.getState()),[e,n]),d.useCallback(()=>n(e.getInitialState()),[e,n]));return d.useDebugValue(t),t}const k=["left","right","top","bottomLeft","bottomRight"],re=["primary","secondary"],U="default",be=["bottomLeft","bottomRight"];function V(e){return e==="bottomLeft"||e==="bottomRight"}function C(e){return e==="top"||V(e)}const B={left:{column:["left","top"],band:"bottomLeft"},right:{column:["right"],band:"bottomRight"}};function K(e){return e==="left"||e==="top"}const R=140,ie=240,_=100,xe={left:320,right:260,top:180,bottomLeft:240,bottomRight:240},we="bottomRight";function z(e){return V(e)?we:e}const N={left:"right",right:"left",top:we,bottomLeft:"top",bottomRight:"top"};function Se(e,n,t){return Math.min(Math.max(e,n),t)}function ce(e,n,t){const s=Math.max(R,Math.round(n-t-ie));return Se(Math.round(e),R,s)}function T(e,n){const t=Math.max(_,Math.round(n-_));return Se(Math.round(e),_,t)}function ye(e,n,t,s){return t(n)?e.sizes[z(n)]??s(n):0}function Xe(e,n,t,s,c){const r={...e.sizes},o={...e.splits};for(const l of k){const a=r[l];if(a!==void 0){const h=C(l)?t:n,p=ye(e,N[l],s,c);r[l]=ce(a,h,p)}const f=o[l];f!==void 0&&(o[l]=T(f,C(l)?n:t))}const i=e.bandSplit===void 0?void 0:T(e.bandSplit,n);return{sizes:r,splits:o,bandSplit:i}}function je(e,n,t){const s=t-ie,c=e+n;if(c<=s)return[e,n];const r=a=>a===0?0:R,o=r(e)+r(n);if(s<=o)return[Math.min(e,r(e)),Math.min(n,r(n))];const i=s/c,l=Math.max(r(e),Math.round(e*i));return[l,Math.max(r(n),Math.round(s-l))]}function E(e){return e.views[e.view]??{}}function J(e,n){const t={...n??{}};for(const s of k)for(const c of re)t[s]?.[c]===void 0&&Pe(e,s,c)!==void 0&&(t[s]={...t[s],[c]:null});return t}function X(e,n){return Object.hasOwn(e.views,n)}function Pe(e,n,t){return e.find(s=>s.zone===n&&s.slot===t)}function P(e,n){return n==null?void 0:e.find(t=>t.id===n)}function he(e,n,t){const s=E(e)[n];if(!s||!(t in s))return;const c=P(e.registry,s[t]);return c?.zone===n&&c.slot===t?c:Pe(e.registry,n,t)}function I(e,n){const t=he(e,n,"primary");return t?.solo===!0?{primary:t}:{primary:t,secondary:he(e,n,"secondary")}}function M(e,n){const{primary:t,secondary:s}=I(e,n);return{primary:t?.id,secondary:s?.id}}function A(e,n){return V(n)?be.some(t=>F(e,t)):F(e,n)}function F(e,n){const t=M(e,n);return t.primary!==void 0||t.secondary!==void 0}function D(e,n){return Math.max(xe[e],n?.opens??0)}function Qe(e,n,t,s){const{slot:c,id:r}=t,o=E(e)[n]??{},i={...e.stashed};if(t.solo===!0&&c==="primary")return i[n]=o,[{[c]:r},i];if(s?.solo!==!0)return[{...o,[c]:r},e.stashed];const l=i[n];if(delete i[n],l)return[{...l,[c]:r},i];const a={...o,[c]:r};return c!==s.slot&&delete a[s.slot],[a,i]}function en(e,n,t){const s=E(e)[n]??{},c=s[t],r=e.stashed[n];if(r&&c!==void 0&&P(e.registry,c)?.solo===!0){const i={...e.stashed};return delete i[n],[r,i]}const o={...s};return delete o[t],[o,e.stashed]}const pe={sizes:{},splits:{}};function Ne(e={}){const n=e.initial,t=(s,c)=>({...s.views,[s.view]:c});return Ge()((s,c)=>({registry:[],view:e.view??U,views:n?.views??{},lengths:n?.lengths??pe,focusedZone:null,stashed:{},available:{width:0,height:0},declare:r=>s({registry:r}),settle:r=>s(o=>{const i=r??o.defaults;return X(o,o.view)?i===o.defaults?o:{defaults:i}:{views:t(o,J(o.registry,i)),defaults:i}}),setView:r=>s(o=>o.view===r?o:{view:r,views:X(o,r)?o.views:{...o.views,[r]:J(o.registry,o.defaults)},focusedZone:null,stashed:{}}),show:r=>s(o=>{const i=P(o.registry,r);if(!i)return o;const{zone:l}=i,a=I(o,l);if(a[i.slot]?.id===r)return{focusedZone:l};const[f,h]=Qe(o,l,i,a.primary);return{views:t(o,{...E(o),[l]:f}),stashed:h,focusedZone:l}}),close:(r,o)=>s(i=>{const[l,a]=en(i,r,o),f=t(i,{...E(i),[r]:l}),h=F({registry:i.registry,view:i.view,views:f},r);return{views:f,stashed:a,focusedZone:!h&&i.focusedZone===r?null:i.focusedZone}}),toggle:r=>{const o=c(),i=P(o.registry,r);i&&(M(o,i.zone)[i.slot]===r?o.close(i.zone,i.slot):o.show(r))},focus:r=>s(o=>o.focusedZone===r?o:{focusedZone:r}),resize:(r,o,i)=>s(l=>{const a=ye(l.lengths,N[r],p=>A(l,p),p=>D(p,I(l,p).primary)),f=ce(o,i,a),h=z(r);return f===l.lengths.sizes[h]?l:{lengths:{...l.lengths,sizes:{...l.lengths.sizes,[h]:f}}}}),resplit:(r,o,i)=>s(l=>{const a=T(o,i);return a===l.lengths.splits[r]?l:{lengths:{...l.lengths,splits:{...l.lengths.splits,[r]:a}}}}),resplitBand:(r,o)=>s(i=>{const l=T(r,o);return l===i.lengths.bandSplit?i:{lengths:{...i.lengths,bandSplit:l}}}),fit:(r,o)=>s(i=>({available:{width:r,height:o},lengths:Xe(i.lengths,r,o,l=>A(i,l),l=>D(l,I(i,l).primary))})),reset:()=>s(r=>({views:{[r.view]:J(r.registry,r.defaults)},lengths:pe,focusedZone:null,stashed:{},registry:r.registry}))}))}const nn=()=>{const e=new Map;return{read:n=>e.get(n)??null,write:(n,t)=>{e.set(n,t)}}},_e=()=>({read:e=>{try{return globalThis.localStorage?.getItem(e)??null}catch{return null}},write:(e,n)=>{try{globalThis.localStorage?.setItem(e,n)}catch{}}}),le=2;function j(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function me(e){const n={};for(const t of k){const s=e[t];if(j(s))for(const c of re){const r=s[c];r!==null&&typeof r!="string"||(n[t]={...n[t],[c]:r})}}return n}function ge(e){const n={};for(const t of k){const s=e[t];typeof s=="number"&&Number.isFinite(s)&&(n[t]=s)}return n}function tn(e,n){if(e.version===1)return j(e.open)?{[n]:me(e.open)}:void 0;if(e.version!==le||!j(e.views))return;const t=Object.create(null);for(const[s,c]of Object.entries(e.views))j(c)&&(t[s]=me(c));return t}function Ie(e,n,t=U){const s=e.read(n);if(s===null)return;let c;try{c=JSON.parse(s)}catch{return}if(!j(c)||!j(c.lengths))return;const r=tn(c,t);if(!r)return;const o=c.lengths;if(!j(o.sizes)||!j(o.splits))return;const i=o.bandSplit;return{views:r,lengths:{sizes:ge(o.sizes),splits:ge(o.splits),bandSplit:typeof i=="number"&&Number.isFinite(i)?i:void 0}}}function Ce(e,n,t){const s={version:le,views:t.views,lengths:t.lengths};e.write(n,JSON.stringify(s))}const Ee=typeof globalThis.document>"u"?d.useEffect:d.useLayoutEffect,Me=d.createContext(null);function Ze({store:e,storageKey:n="panels:layout",storage:t,defaultOpen:s,view:c,children:r}){const[o]=d.useState(()=>t===null?null:t??_e()),[i]=d.useState(()=>{const l=c??U,a=o?Ie(o,n,l):void 0;return e?(a&&e.setState(a),e):Ne({view:l,initial:a})});return Ee(()=>{const l=i.getState();c!==void 0&&l.setView(c),l.settle(s)}),d.useEffect(()=>{if(!o)return;let l;return i.subscribe(a=>{X(a,a.view)&&(l?.views===a.views&&l.lengths===a.lengths||(l={views:a.views,lengths:a.lengths},Ce(o,n,a)))})},[o,i,n]),u.jsx(Me.Provider,{value:i,children:r})}function Z(){const e=d.useContext(Me);if(!e)throw new Error("usePanelsStore must be used inside a <Panels> or <PanelsProvider>");return e}function b(e){const n=Z();return Ke(n,e)}function O(){const e=Z();return d.useMemo(()=>{const{show:n,close:t,toggle:s,focus:c,resize:r,resplit:o,resplitBand:i,fit:l,reset:a}=e.getState();return{show:n,close:t,toggle:s,focus:c,resize:r,resplit:o,resplitBand:i,fit:l,reset:a}},[e])}function Oe({icon:e,label:n,active:t,accented:s,acts:c,className:r,children:o,ref:i,...l}){return u.jsxs("button",{type:"button",ref:i,"aria-label":n,"aria-pressed":c?void 0:t,className:x.cx("pnl-icon-button",t&&"pnl-icon-button--active",s&&"pnl-icon-button--accented",r),...l,children:[e!==void 0&&u.jsx("span",{className:"pnl-icon-button__glyph",children:e}),o]})}const Q={IconButton:Oe},Le=d.createContext(Q),sn=Le.Provider;function ae(){return d.useContext(Le)}function on(e){return e===void 0?Q:{...Q,...e}}function Re(e){const n=Z();d.useEffect(()=>{const t=e.current;if(!t)return;const s=()=>{const{clientWidth:r,clientHeight:o}=t;r===0||o===0||n.getState().fit(r,o)};if(s(),typeof ResizeObserver>"u")return;const c=new ResizeObserver(s);return c.observe(t),()=>c.disconnect()},[e,n])}function L(){const e=b(s=>s.registry),n=b(s=>s.view),t=b(s=>s.views[s.view]);return d.useMemo(()=>({registry:e,view:n,views:t===void 0?{}:{[n]:t}}),[e,n,t])}function ze(e){const n=L();return d.useMemo(()=>M(n,e),[n,e])}function ee(e){const n=L();return d.useMemo(()=>I(n,e),[n,e])}function ne(e){const n=L();return d.useMemo(()=>F(n,e),[n,e])}function Te(e){const n=L();return d.useMemo(()=>A(n,e),[n,e])}function Fe(){return{left:ne(B.left.band),right:ne(B.right.band)}}function ke(){const e=d.useRef(null);return d.useMemo(()=>({start:(t,s)=>{t.currentTarget.setPointerCapture(t.pointerId),e.current={...s,pointerId:t.pointerId}},matching:t=>e.current?.pointerId===t.pointerId?e.current:null,cancel:()=>{e.current=null}}),[])}function H({axis:e,invert:n=!1,size:t,onSize:s,measure:c,label:r,min:o,max:i,step:l=16,className:a}){const f=ke(),h=d.useRef(null),p=e==="vertical",g=d.useCallback(m=>(p?m?.clientHeight:m?.clientWidth)??0,[p]),y=d.useCallback(m=>{const w=f.matching(m);if(!w)return;const G=(p?m.clientY:m.clientX)-w.position;s(w.size+G*(n?-1:1),w.available)},[f,n,p,s]),v=d.useCallback(m=>{const w=p?"ArrowUp":"ArrowLeft",q=p?"ArrowDown":"ArrowRight";if(m.key!==w&&m.key!==q)return;const G=g(h.current?.parentElement),$e=t??c?.()??0,qe=m.key===q?1:-1;m.preventDefault(),s($e+l*qe*(n?-1:1),G)},[n,p,c,s,g,t,l]);return u.jsx("div",{ref:h,role:"separator",tabIndex:0,"aria-label":r,"aria-orientation":p?"horizontal":"vertical","aria-valuenow":t===void 0?void 0:Math.round(t),"aria-valuemin":o,"aria-valuemax":i,onPointerDown:m=>{f.start(m,{position:p?m.clientY:m.clientX,size:t??c?.()??0,available:g(m.currentTarget.parentElement)})},onPointerMove:y,onPointerUp:f.cancel,onPointerCancel:f.cancel,onLostPointerCapture:f.cancel,onKeyDown:v,className:x.cx("pnl-handle",p?"pnl-handle--row":"pnl-handle--col",a)})}function ve(e,n,t,s){return s?n??D(t,e):0}function Be(e){const n=ee(e),t=ee(N[e]),s=Te(N[e]),c=b(a=>a.lengths.sizes[z(e)]),r=b(a=>a.lengths.sizes[z(N[e])]),o=b(a=>a.lengths.splits[e]),i=b(a=>C(e)?a.available.height:a.available.width),l=b(a=>a.focusedZone===e);return d.useMemo(()=>{const{primary:a,secondary:f}=n,h=a!==void 0||f!==void 0,p=ve(a,c,e,h),g=ve(t.primary,r,N[e],s);return{primary:a,secondary:f,draws:h,size:i===0?p:je(p,g,i)[0],split:o,focused:l}},[n,t,s,c,r,i,o,l,e])}function Ae(e){const n=b(t=>t.registry);return d.useMemo(()=>[["primary",n.filter(s=>s.zone===e&&s.slot==="primary")],["secondary",n.filter(s=>s.zone===e&&s.slot==="secondary")]].filter(([,s])=>s.length>0),[n,e])}const De=d.createContext(new Map),He=De.Provider;function Ue(e){return d.useContext(De).get(e)}function Ve({title:e,children:n,fillActions:t,trailing:s,className:c}){return u.jsxs("header",{className:x.cx("pnl-header",c),children:[u.jsx("span",{className:x.cx("pnl-header__title",t&&"pnl-header__title--fixed"),children:e}),u.jsx("span",{className:x.cx("pnl-header__actions",t&&"pnl-header__actions--fill"),children:n}),u.jsx("span",{className:"pnl-header__trailing",children:s})]})}function Y({orientation:e="vertical",className:n}){return u.jsx("span",{"aria-hidden":"true",className:x.cx("pnl-separator",`pnl-separator--${e}`,n)})}function ue({children:e,className:n,...t}){return u.jsx("section",{className:x.cx("pnl-surface",n),...t,children:e})}function rn({panel:e,length:n,closeLabel:t,onFocus:s}){const{close:c}=O(),{IconButton:r}=ae(),o=Ue(e.id);return u.jsxs(ue,{"aria-label":e.title,onPointerDownCapture:s,className:n===void 0?"pnl-surface--fill":"pnl-surface--give",style:n===void 0?void 0:{flexBasis:n},children:[u.jsx(Ve,{title:e.title,fillActions:o?.actions!==void 0&&C(e.zone),trailing:u.jsxs(u.Fragment,{children:[o?.actions!==void 0&&u.jsx(Y,{}),u.jsx(r,{label:t,acts:!0,onClick:()=>c(e.zone,e.slot),className:"pnl-icon-button--header",icon:u.jsx(cn,{})})]}),children:o?.actions}),u.jsx("div",{className:x.cx("pnl-body"),children:o?.content})]})}const te=d.memo(rn);function cn(){return u.jsx("svg",{viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true",focusable:"false",children:u.jsx("path",{fill:"currentColor",d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})})}function ln({zone:e,labels:n}){const t=Be(e),{focus:s,resize:c,resplit:r}=O(),o=d.useRef(null),i=d.useCallback(()=>s(e),[s,e]),l=C(e),a=d.useCallback(()=>l?o.current?.clientHeight??0:o.current?.clientWidth??0,[l]);if(!t.draws)return null;const{primary:f,secondary:h,size:p,split:g}=t,y=u.jsxs("div",{ref:o,className:x.cx("pnl-zone",l?"pnl-zone--row":"pnl-zone--col"),style:{[l?"height":"width"]:p},children:[f&&u.jsx(te,{panel:f,closeLabel:n.closePanel,onFocus:i}),f&&h&&u.jsx(H,{axis:l?"horizontal":"vertical",invert:!0,size:g,min:_,label:n.resizeSplit,onSize:(m,w)=>r(e,m,w)}),h&&u.jsx(te,{panel:h,length:f&&g!==void 0?g:void 0,closeLabel:n.closePanel,onFocus:i})]}),v=u.jsx(H,{axis:l?"vertical":"horizontal",invert:!K(e),size:p,min:R,measure:a,label:n.resizeZone,onSize:(m,w)=>c(e,m,w)});return K(e)?u.jsxs(u.Fragment,{children:[y,v]}):u.jsxs(u.Fragment,{children:[v,y]})}const S=d.memo(ln);function Ye({left:e,right:n,labels:t}){const s=b(o=>o.lengths.bandSplit),{resplitBand:c}=O(),r=d.useCallback((o,i)=>c(o,i),[c]);return!e&&!n?null:!e||!n?u.jsx(S,{zone:e?"bottomLeft":"bottomRight",labels:t}):u.jsxs("div",{className:"pnl-band",children:[u.jsx("div",{className:x.cx("pnl-band__half",s===void 0&&"pnl-band__half--even"),style:s===void 0?void 0:{width:s},children:u.jsx(S,{zone:"bottomLeft",labels:t})}),u.jsx(H,{axis:"horizontal",size:s,min:_,label:t.resizeBand,onSize:r}),u.jsx("div",{className:"pnl-band__half pnl-band__half--rest",children:u.jsx(S,{zone:"bottomRight",labels:t})})]})}function W(e){return null}W.displayName="Panels.Center";const We={closePanel:"Close panel",resizeZone:"Resize panel area",resizeSplit:"Resize the two panels",resizeBand:"Resize the bottom panels"};function $(e){return null}$.displayName="Panels.Panel";function se({side:e,header:n,className:t}){const{column:s,band:c}=B[e];return u.jsxs("div",{role:"toolbar","aria-orientation":"vertical",className:x.cx("pnl-rail",`pnl-rail--${e}`,t),children:[u.jsxs("div",{className:"pnl-rail__group",children:[n!==void 0&&u.jsxs(u.Fragment,{children:[n,u.jsx(Y,{orientation:"horizontal"})]}),s.map(r=>u.jsx(oe,{zone:r},r))]}),u.jsx(oe,{zone:c})]})}function oe({zone:e}){const n=Ae(e),t=ze(e),s=b(o=>o.focusedZone===e),{toggle:c}=O(),{IconButton:r}=ae();return n.length===0?null:u.jsx("div",{className:"pnl-rail__group",children:n.map(([o,i],l)=>u.jsxs(d.Fragment,{children:[l>0&&u.jsx(Y,{orientation:"horizontal"}),i.map(a=>{const f=t[o]===a.id;return u.jsx(r,{icon:a.icon,label:a.title,active:f,accented:f&&s,onClick:()=>c(a.id),className:"pnl-rail__button"},a.id)})]},`${e}:${o}`))})}function an(e){const n=[],t=new Map,s=[];let c=null;for(const r of d.Children.toArray(e)){if(!d.isValidElement(r)){s.push(r);continue}if(r.type===W){c=r;continue}if(r.type!==$){s.push(r);continue}const o=r.props,{id:i,zone:l,slot:a="primary",title:f,icon:h,opens:p,solo:g,actions:y,children:v}=o;n.push({id:i,zone:l,slot:a,title:f,icon:h,opens:p,solo:g}),t.set(i,{content:v,actions:y})}return{specs:n,content:t,centre:c,loose:s}}function de({header:e,footer:n,railHeader:t,labels:s,theme:c,className:r,components:o,children:i,...l}){return u.jsx(Ze,{...l,children:u.jsx(un,{header:e,footer:n,railHeader:t,labels:s,theme:c,className:r,components:o,children:i})})}function un({header:e,footer:n,railHeader:t,labels:s,theme:c,className:r,components:o,children:i}){const l=Z(),a=d.useRef(null);Re(a);const[f]=d.useState(()=>on(o)),{specs:h,content:p,centre:g,loose:y}=d.useMemo(()=>an(i),[i]),v=d.useMemo(()=>({...We,...s}),[s]);Ee(()=>{l.getState().declare(h)},[l,h]);const m=Fe();return u.jsx(sn,{value:f,children:u.jsx(He,{value:p,children:u.jsxs("div",{"data-pnl-theme":c,className:x.cx("pnl-root",r),children:[e,u.jsxs("div",{className:"pnl-middle",children:[u.jsx(se,{side:"left",header:t}),u.jsxs("div",{ref:a,className:"pnl-columns",children:[u.jsx(S,{zone:"top",labels:v}),u.jsxs("div",{className:"pnl-row",children:[!m.left&&u.jsx(S,{zone:"left",labels:v}),u.jsxs("div",{className:"pnl-stack",children:[u.jsxs("div",{className:"pnl-row",children:[m.left&&u.jsx(S,{zone:"left",labels:v}),u.jsx(ue,{className:"pnl-centre",children:g?.props.children}),m.right&&u.jsx(S,{zone:"right",labels:v})]}),u.jsx(Ye,{left:m.left,right:m.right,labels:v})]}),!m.right&&u.jsx(S,{zone:"right",labels:v})]})]}),u.jsx(se,{side:"right"})]}),n,y]})})})}de.Panel=$;de.Center=W;function dn(){const e=Z(),n=L(),t=b(o=>o.focusedZone),s=O(),c=d.useCallback(o=>{const i=P(n.registry,o);return i!==void 0&&M(n,i.zone)[i.slot]===o},[n]),r=d.useCallback(o=>{const i=P(n.registry,o);!i||M(n,i.zone)[i.slot]!==o||e.getState().close(i.zone,i.slot)},[n,e]);return d.useMemo(()=>({panels:n.registry,reveal:s.show,close:r,toggle:s.toggle,isShown:c,focusedZone:t,reset:s.reset}),[n,s.show,s.toggle,s.reset,r,c,t])}exports.cx=x.cx;exports.BOTTOM_ZONES=be;exports.Band=Ye;exports.Center=W;exports.ContentProvider=He;exports.DEFAULT_LABELS=We;exports.DEFAULT_SIZES=xe;exports.DEFAULT_VIEW=U;exports.IconButton=Oe;exports.LAYOUT_VERSION=le;exports.MIN_CENTER=ie;exports.MIN_SIZE=R;exports.MIN_SPLIT=_;exports.Panel=$;exports.PanelFrame=te;exports.PanelHeader=Ve;exports.Panels=de;exports.PanelsProvider=Ze;exports.Rail=se;exports.RailZone=oe;exports.ResizeHandle=H;exports.SLOTS=re;exports.Separator=Y;exports.Surface=ue;exports.ZONES=k;exports.ZONES_BY_SIDE=B;exports.ZoneEdge=S;exports.browserStorage=_e;exports.createPanelsStore=Ne;exports.fitSplit=T;exports.fitZoneSize=ce;exports.isBottom=V;exports.isHorizontal=C;exports.isLeading=K;exports.memoryStorage=nn;exports.openOf=E;exports.readLayout=Ie;exports.sharedSizes=je;exports.shownIn=M;exports.shownSpecsIn=I;exports.sizeKeyOf=z;exports.specOf=P;exports.undraggedSizeOf=D;exports.useArrangement=L;exports.useBandHalves=Fe;exports.useContainerFit=Re;exports.usePanelContent=Ue;exports.usePanels=dn;exports.usePanelsActions=O;exports.usePanelsComponents=ae;exports.usePanelsState=b;exports.usePanelsStore=Z;exports.usePointerDrag=ke;exports.useShownIn=ze;exports.useShownSpecsIn=ee;exports.useZone=Be;exports.useZoneDraws=ne;exports.useZonePanels=Ae;exports.useZoneTakesRoom=Te;exports.writeLayout=Ce;exports.zoneDraws=F;exports.zoneTakesRoom=A;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),d=require("react"),b=require("./cx-YyuC5RtB.cjs"),fe=e=>{let n;const t=new Set,s=(a,f)=>{const h=typeof a=="function"?a(n):a;if(!Object.is(h,n)){const p=n;n=f??(typeof h!="object"||h===null)?h:Object.assign({},n,h),t.forEach(g=>g(n,p))}},c=()=>n,i={setState:s,getState:c,getInitialState:()=>l,subscribe:a=>(t.add(a),()=>t.delete(a))},l=n=e(s,c,i);return i},Ge=(e=>e?fe(e):fe),Je=e=>e;function Ke(e,n=Je){const t=d.useSyncExternalStore(e.subscribe,d.useCallback(()=>n(e.getState()),[e,n]),d.useCallback(()=>n(e.getInitialState()),[e,n]));return d.useDebugValue(t),t}const k=["left","right","top","bottomLeft","bottomRight"],re=["primary","secondary"],U="default",be=["bottomLeft","bottomRight"];function V(e){return e==="bottomLeft"||e==="bottomRight"}function C(e){return e==="top"||V(e)}const A={left:{column:["left","top"],band:"bottomLeft"},right:{column:["right"],band:"bottomRight"}};function K(e){return e==="left"||e==="top"}const R=140,ie=240,_=100,xe={left:320,right:260,top:180,bottomLeft:240,bottomRight:240},we="bottomRight";function z(e){return V(e)?we:e}const N={left:"right",right:"left",top:we,bottomLeft:"top",bottomRight:"top"};function Se(e,n,t){return Math.min(Math.max(e,n),t)}function ce(e,n,t){const s=Math.max(R,Math.round(n-t-ie));return Se(Math.round(e),R,s)}function T(e,n){const t=Math.max(_,Math.round(n-_));return Se(Math.round(e),_,t)}function ye(e,n,t,s){return t(n)?e.sizes[z(n)]??s(n):0}function Xe(e,n,t,s,c){const r={...e.sizes},o={...e.splits};for(const l of k){const a=r[l];if(a!==void 0){const h=C(l)?t:n,p=ye(e,N[l],s,c);r[l]=ce(a,h,p)}const f=o[l];f!==void 0&&(o[l]=T(f,C(l)?n:t))}const i=e.bandSplit===void 0?void 0:T(e.bandSplit,n);return{sizes:r,splits:o,bandSplit:i}}function je(e,n,t){const s=t-ie,c=e+n;if(c<=s)return[e,n];const r=a=>a===0?0:R,o=r(e)+r(n);if(s<=o)return[Math.min(e,r(e)),Math.min(n,r(n))];const i=s/c,l=Math.max(r(e),Math.round(e*i));return[l,Math.max(r(n),Math.round(s-l))]}function E(e){return e.views[e.view]??{}}function J(e,n){const t={...n??{}};for(const s of k)for(const c of re)t[s]?.[c]===void 0&&Pe(e,s,c)!==void 0&&(t[s]={...t[s],[c]:null});return t}function X(e,n){return Object.hasOwn(e.views,n)}function Pe(e,n,t){return e.find(s=>s.zone===n&&s.slot===t)}function j(e,n){return n==null?void 0:e.find(t=>t.id===n)}function he(e,n,t){const s=E(e)[n];if(!s||!(t in s))return;const c=j(e.registry,s[t]);return c?.zone===n&&c.slot===t?c:Pe(e.registry,n,t)}function I(e,n){const t=he(e,n,"primary");return t?.solo===!0?{primary:t}:{primary:t,secondary:he(e,n,"secondary")}}function M(e,n){const{primary:t,secondary:s}=I(e,n);return{primary:t?.id,secondary:s?.id}}function B(e,n){return V(n)?be.some(t=>F(e,t)):F(e,n)}function F(e,n){const t=M(e,n);return t.primary!==void 0||t.secondary!==void 0}function D(e,n){return Math.max(xe[e],n?.opens??0)}function Qe(e,n,t,s){const{slot:c,id:r}=t,o=E(e)[n]??{},i={...e.stashed};if(t.solo===!0&&c==="primary")return i[n]=o,[{[c]:r},i];if(s?.solo!==!0)return[{...o,[c]:r},e.stashed];const l=i[n];if(delete i[n],l)return[{...l,[c]:r},i];const a={...o,[c]:r};return c!==s.slot&&delete a[s.slot],[a,i]}function en(e,n,t){const s=E(e)[n]??{},c=s[t],r=e.stashed[n];if(r&&c!==void 0&&j(e.registry,c)?.solo===!0){const i={...e.stashed};return delete i[n],[r,i]}const o={...s};return delete o[t],[o,e.stashed]}const pe={sizes:{},splits:{}};function Ne(e={}){const n=e.initial,t=(s,c)=>({...s.views,[s.view]:c});return Ge()((s,c)=>({registry:[],view:e.view??U,views:n?.views??{},lengths:n?.lengths??pe,focusedZone:null,stashed:{},available:{width:0,height:0},declare:r=>s({registry:r}),settle:r=>s(o=>{const i=r??o.defaults;return X(o,o.view)?i===o.defaults?o:{defaults:i}:{views:t(o,J(o.registry,i)),defaults:i}}),setView:r=>s(o=>o.view===r?o:{view:r,views:X(o,r)?o.views:{...o.views,[r]:J(o.registry,o.defaults)},focusedZone:null,stashed:{}}),show:r=>s(o=>{const i=j(o.registry,r);if(!i)return o;const{zone:l}=i,a=I(o,l);if(a[i.slot]?.id===r)return{focusedZone:l};const[f,h]=Qe(o,l,i,a.primary);return{views:t(o,{...E(o),[l]:f}),stashed:h,focusedZone:l}}),close:(r,o)=>s(i=>{const[l,a]=en(i,r,o),f=t(i,{...E(i),[r]:l}),h=F({registry:i.registry,view:i.view,views:f},r);return{views:f,stashed:a,focusedZone:!h&&i.focusedZone===r?null:i.focusedZone}}),toggle:r=>{const o=c(),i=j(o.registry,r);i&&(M(o,i.zone)[i.slot]===r?o.close(i.zone,i.slot):o.show(r))},focus:r=>s(o=>o.focusedZone===r?o:{focusedZone:r}),resize:(r,o,i)=>s(l=>{const a=ye(l.lengths,N[r],p=>B(l,p),p=>D(p,I(l,p).primary)),f=ce(o,i,a),h=z(r);return f===l.lengths.sizes[h]?l:{lengths:{...l.lengths,sizes:{...l.lengths.sizes,[h]:f}}}}),resplit:(r,o,i)=>s(l=>{const a=T(o,i);return a===l.lengths.splits[r]?l:{lengths:{...l.lengths,splits:{...l.lengths.splits,[r]:a}}}}),resplitBand:(r,o)=>s(i=>{const l=T(r,o);return l===i.lengths.bandSplit?i:{lengths:{...i.lengths,bandSplit:l}}}),fit:(r,o)=>s(i=>({available:{width:r,height:o},lengths:Xe(i.lengths,r,o,l=>B(i,l),l=>D(l,I(i,l).primary))})),reset:()=>s(r=>({views:r.registry.length===0?{}:{[r.view]:J(r.registry,r.defaults)},lengths:pe,focusedZone:null,stashed:{},registry:r.registry}))}))}const nn=()=>{const e=new Map;return{read:n=>e.get(n)??null,write:(n,t)=>{e.set(n,t)}}},_e=()=>({read:e=>{try{return globalThis.localStorage?.getItem(e)??null}catch{return null}},write:(e,n)=>{try{globalThis.localStorage?.setItem(e,n)}catch{}}}),le=2;function y(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function me(e){const n={};for(const t of k){const s=e[t];if(y(s))for(const c of re){const r=s[c];r!==null&&typeof r!="string"||(n[t]={...n[t],[c]:r})}}return n}function ge(e){const n={};for(const t of k){const s=e[t];typeof s=="number"&&Number.isFinite(s)&&(n[t]=s)}return n}function tn(e,n){if(e.version===1)return y(e.open)?{[n]:me(e.open)}:void 0;if(e.version!==le||!y(e.views))return;const t=Object.create(null);for(const[s,c]of Object.entries(e.views))y(c)&&(t[s]=me(c));return t}function Ie(e,n,t=U){const s=e.read(n);if(s===null)return;let c;try{c=JSON.parse(s)}catch{return}if(!y(c)||!y(c.lengths))return;const r=tn(c,t);if(!r)return;const o=c.lengths;if(!y(o.sizes)||!y(o.splits))return;const i=o.bandSplit;return{views:r,lengths:{sizes:ge(o.sizes),splits:ge(o.splits),bandSplit:typeof i=="number"&&Number.isFinite(i)?i:void 0}}}function Ce(e,n,t){const s={version:le,views:t.views,lengths:t.lengths};e.write(n,JSON.stringify(s))}const Ee=typeof globalThis.document>"u"?d.useEffect:d.useLayoutEffect,Me=d.createContext(null);function Ze({store:e,storageKey:n="panels:layout",storage:t,defaultOpen:s,view:c,children:r}){const[o]=d.useState(()=>t===null?null:t??_e()),[i]=d.useState(()=>{const l=c??U,a=o?Ie(o,n,l):void 0;return e?(a&&e.setState(a),e):Ne({view:l,initial:a})});return Ee(()=>{const l=i.getState();c!==void 0&&l.setView(c),l.settle(s)}),d.useEffect(()=>{if(!o)return;let l;return i.subscribe(a=>{X(a,a.view)&&(l?.views===a.views&&l.lengths===a.lengths||(l={views:a.views,lengths:a.lengths},Ce(o,n,a)))})},[o,i,n]),u.jsx(Me.Provider,{value:i,children:r})}function Z(){const e=d.useContext(Me);if(!e)throw new Error("usePanelsStore must be used inside a <Panels> or <PanelsProvider>");return e}function v(e){const n=Z();return Ke(n,e)}function O(){const e=Z();return d.useMemo(()=>{const{show:n,close:t,toggle:s,focus:c,resize:r,resplit:o,resplitBand:i,fit:l,reset:a}=e.getState();return{show:n,close:t,toggle:s,focus:c,resize:r,resplit:o,resplitBand:i,fit:l,reset:a}},[e])}function Oe({icon:e,label:n,active:t,accented:s,acts:c,className:r,children:o,ref:i,...l}){return u.jsxs("button",{type:"button",ref:i,"aria-label":n,"aria-pressed":c?void 0:t,className:b.cx("pnl-icon-button",t&&"pnl-icon-button--active",s&&"pnl-icon-button--accented",r),...l,children:[e!==void 0&&u.jsx("span",{className:"pnl-icon-button__glyph",children:e}),o]})}const Q={IconButton:Oe},Le=d.createContext(Q),sn=Le.Provider;function ae(){return d.useContext(Le)}function on(e){return e===void 0?Q:{...Q,...e}}function Re(e){const n=Z();d.useEffect(()=>{const t=e.current;if(!t)return;const s=()=>{const{clientWidth:r,clientHeight:o}=t;r===0||o===0||n.getState().fit(r,o)};if(s(),typeof ResizeObserver>"u")return;const c=new ResizeObserver(s);return c.observe(t),()=>c.disconnect()},[e,n])}function L(){const e=v(s=>s.registry),n=v(s=>s.view),t=v(s=>s.views[s.view]);return d.useMemo(()=>({registry:e,view:n,views:t===void 0?{}:{[n]:t}}),[e,n,t])}function ze(e){const n=L();return d.useMemo(()=>M(n,e),[n,e])}function ee(e){const n=L();return d.useMemo(()=>I(n,e),[n,e])}function ne(e){const n=L();return d.useMemo(()=>F(n,e),[n,e])}function Te(e){const n=L();return d.useMemo(()=>B(n,e),[n,e])}function Fe(){return{left:ne(A.left.band),right:ne(A.right.band)}}function ke(){const e=d.useRef(null);return d.useMemo(()=>({start:(t,s)=>{t.currentTarget.setPointerCapture(t.pointerId),e.current={...s,pointerId:t.pointerId}},matching:t=>e.current?.pointerId===t.pointerId?e.current:null,cancel:()=>{e.current=null}}),[])}function H({axis:e,invert:n=!1,size:t,onSize:s,measure:c,label:r,min:o,max:i,step:l=16,className:a}){const f=ke(),h=d.useRef(null),p=e==="vertical",g=d.useCallback(m=>(p?m?.clientHeight:m?.clientWidth)??0,[p]),P=d.useCallback(m=>{const w=f.matching(m);if(!w)return;const G=(p?m.clientY:m.clientX)-w.position;s(w.size+G*(n?-1:1),w.available)},[f,n,p,s]),x=d.useCallback(m=>{const w=p?"ArrowUp":"ArrowLeft",q=p?"ArrowDown":"ArrowRight";if(m.key!==w&&m.key!==q)return;const G=g(h.current?.parentElement),$e=t??c?.()??0,qe=m.key===q?1:-1;m.preventDefault(),s($e+l*qe*(n?-1:1),G)},[n,p,c,s,g,t,l]);return u.jsx("div",{ref:h,role:"separator",tabIndex:0,"aria-label":r,"aria-orientation":p?"horizontal":"vertical","aria-valuenow":t===void 0?void 0:Math.round(t),"aria-valuemin":o,"aria-valuemax":i,onPointerDown:m=>{f.start(m,{position:p?m.clientY:m.clientX,size:t??c?.()??0,available:g(m.currentTarget.parentElement)})},onPointerMove:P,onPointerUp:f.cancel,onPointerCancel:f.cancel,onLostPointerCapture:f.cancel,onKeyDown:x,className:b.cx("pnl-handle",p?"pnl-handle--row":"pnl-handle--col",a)})}function ve(e,n,t,s){return s?n??D(t,e):0}function Ae(e){const n=ee(e),t=ee(N[e]),s=Te(N[e]),c=v(a=>a.lengths.sizes[z(e)]),r=v(a=>a.lengths.sizes[z(N[e])]),o=v(a=>a.lengths.splits[e]),i=v(a=>C(e)?a.available.height:a.available.width),l=v(a=>a.focusedZone===e);return d.useMemo(()=>{const{primary:a,secondary:f}=n,h=a!==void 0||f!==void 0,p=ve(a,c,e,h),g=ve(t.primary,r,N[e],s);return{primary:a,secondary:f,draws:h,size:i===0?p:je(p,g,i)[0],split:o,focused:l}},[n,t,s,c,r,i,o,l,e])}function Be(e){const n=v(t=>t.registry);return d.useMemo(()=>[["primary",n.filter(s=>s.zone===e&&s.slot==="primary")],["secondary",n.filter(s=>s.zone===e&&s.slot==="secondary")]].filter(([,s])=>s.length>0),[n,e])}const De=d.createContext(new Map),He=De.Provider;function Ue(e){return d.useContext(De).get(e)}function Ve({title:e,children:n,fillActions:t,trailing:s,className:c}){return u.jsxs("header",{className:b.cx("pnl-header",c),children:[u.jsx("span",{className:b.cx("pnl-header__title",t&&"pnl-header__title--fixed"),children:e}),u.jsx("span",{className:b.cx("pnl-header__actions",t&&"pnl-header__actions--fill"),children:n}),u.jsx("span",{className:"pnl-header__trailing",children:s})]})}function Y({orientation:e="vertical",className:n}){return u.jsx("span",{"aria-hidden":"true",className:b.cx("pnl-separator",`pnl-separator--${e}`,n)})}function ue({children:e,className:n,...t}){return u.jsx("section",{className:b.cx("pnl-surface",n),...t,children:e})}function rn({panel:e,length:n,closeLabel:t,onFocus:s}){const{close:c}=O(),{IconButton:r}=ae(),o=Ue(e.id);return u.jsxs(ue,{"aria-label":e.title,onPointerDownCapture:s,className:n===void 0?"pnl-surface--fill":"pnl-surface--give",style:n===void 0?void 0:{flexBasis:n},children:[u.jsx(Ve,{title:e.title,fillActions:e.fillActions??(o?.actions!==void 0&&C(e.zone)),trailing:u.jsxs(u.Fragment,{children:[o?.actions!==void 0&&u.jsx(Y,{}),u.jsx(r,{label:t,acts:!0,onClick:()=>c(e.zone,e.slot),className:"pnl-icon-button--header",icon:u.jsx(cn,{})})]}),children:o?.actions}),u.jsx("div",{className:b.cx("pnl-body"),children:o?.content})]})}const te=d.memo(rn);function cn(){return u.jsx("svg",{viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true",focusable:"false",children:u.jsx("path",{fill:"currentColor",d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})})}function ln({zone:e,labels:n}){const t=Ae(e),{focus:s,resize:c,resplit:r}=O(),o=d.useRef(null),i=d.useCallback(()=>s(e),[s,e]),l=C(e),a=d.useCallback(()=>l?o.current?.clientHeight??0:o.current?.clientWidth??0,[l]);if(!t.draws)return null;const{primary:f,secondary:h,size:p,split:g}=t,P=u.jsxs("div",{ref:o,className:b.cx("pnl-zone",l?"pnl-zone--row":"pnl-zone--col"),style:{[l?"height":"width"]:p},children:[f&&u.jsx(te,{panel:f,closeLabel:n.closePanel,onFocus:i}),f&&h&&u.jsx(H,{axis:l?"horizontal":"vertical",invert:!0,size:g,min:_,label:n.resizeSplit,onSize:(m,w)=>r(e,m,w)}),h&&u.jsx(te,{panel:h,length:f&&g!==void 0?g:void 0,closeLabel:n.closePanel,onFocus:i})]}),x=u.jsx(H,{axis:l?"vertical":"horizontal",invert:!K(e),size:p,min:R,measure:a,label:n.resizeZone,onSize:(m,w)=>c(e,m,w)});return K(e)?u.jsxs(u.Fragment,{children:[P,x]}):u.jsxs(u.Fragment,{children:[x,P]})}const S=d.memo(ln);function Ye({left:e,right:n,labels:t}){const s=v(o=>o.lengths.bandSplit),{resplitBand:c}=O(),r=d.useCallback((o,i)=>c(o,i),[c]);return!e&&!n?null:!e||!n?u.jsx(S,{zone:e?"bottomLeft":"bottomRight",labels:t}):u.jsxs("div",{className:"pnl-band",children:[u.jsx("div",{className:b.cx("pnl-band__half",s===void 0&&"pnl-band__half--even"),style:s===void 0?void 0:{width:s},children:u.jsx(S,{zone:"bottomLeft",labels:t})}),u.jsx(H,{axis:"horizontal",size:s,min:_,label:t.resizeBand,onSize:r}),u.jsx("div",{className:"pnl-band__half pnl-band__half--rest",children:u.jsx(S,{zone:"bottomRight",labels:t})})]})}function W(e){return null}W.displayName="Panels.Center";const We={closePanel:"Close panel",resizeZone:"Resize panel area",resizeSplit:"Resize the two panels",resizeBand:"Resize the bottom panels"};function $(e){return null}$.displayName="Panels.Panel";function se({side:e,header:n,className:t}){const{column:s,band:c}=A[e];return u.jsxs("div",{role:"toolbar","aria-orientation":"vertical",className:b.cx("pnl-rail",`pnl-rail--${e}`,t),children:[u.jsxs("div",{className:"pnl-rail__group",children:[n!==void 0&&u.jsxs(u.Fragment,{children:[n,u.jsx(Y,{orientation:"horizontal"})]}),s.map(r=>u.jsx(oe,{zone:r},r))]}),u.jsx(oe,{zone:c})]})}function oe({zone:e}){const n=Be(e),t=ze(e),s=v(o=>o.focusedZone===e),{toggle:c}=O(),{IconButton:r}=ae();return n.length===0?null:u.jsx("div",{className:"pnl-rail__group",children:n.map(([o,i],l)=>u.jsxs(d.Fragment,{children:[l>0&&u.jsx(Y,{orientation:"horizontal"}),i.map(a=>{const f=t[o]===a.id;return u.jsx(r,{icon:a.icon,label:a.title,active:f,accented:f&&s,onClick:()=>c(a.id),className:"pnl-rail__button"},a.id)})]},`${e}:${o}`))})}function an(e){const n=[],t=new Map,s=[];let c=null;for(const r of d.Children.toArray(e)){if(!d.isValidElement(r)){s.push(r);continue}if(r.type===W){c=r;continue}if(r.type!==$){s.push(r);continue}const o=r.props,{actions:i,children:l,slot:a="primary",...f}=o;n.push({...f,slot:a}),t.set(f.id,{content:l,actions:i})}return{specs:n,content:t,centre:c,loose:s}}function de({header:e,footer:n,railHeader:t,labels:s,theme:c,className:r,components:o,children:i,...l}){return u.jsx(Ze,{...l,children:u.jsx(un,{header:e,footer:n,railHeader:t,labels:s,theme:c,className:r,components:o,children:i})})}function un({header:e,footer:n,railHeader:t,labels:s,theme:c,className:r,components:o,children:i}){const l=Z(),a=d.useRef(null);Re(a);const[f]=d.useState(()=>on(o)),{specs:h,content:p,centre:g,loose:P}=d.useMemo(()=>an(i),[i]),x=d.useMemo(()=>({...We,...s}),[s]);Ee(()=>{l.getState().declare(h)},[l,h]);const m=Fe();return u.jsx(sn,{value:f,children:u.jsx(He,{value:p,children:u.jsxs("div",{"data-pnl-theme":c,className:b.cx("pnl-root",r),children:[e,u.jsxs("div",{className:"pnl-middle",children:[u.jsx(se,{side:"left",header:t}),u.jsxs("div",{ref:a,className:"pnl-columns",children:[u.jsx(S,{zone:"top",labels:x}),u.jsxs("div",{className:"pnl-row",children:[!m.left&&u.jsx(S,{zone:"left",labels:x}),u.jsxs("div",{className:"pnl-stack",children:[u.jsxs("div",{className:"pnl-row",children:[m.left&&u.jsx(S,{zone:"left",labels:x}),u.jsx(ue,{className:"pnl-centre",children:g?.props.children}),m.right&&u.jsx(S,{zone:"right",labels:x})]}),u.jsx(Ye,{left:m.left,right:m.right,labels:x})]}),!m.right&&u.jsx(S,{zone:"right",labels:x})]})]}),u.jsx(se,{side:"right"})]}),n,P]})})})}de.Panel=$;de.Center=W;function dn(){const e=Z(),n=L(),t=v(o=>o.focusedZone),s=O(),c=d.useCallback(o=>{const i=j(n.registry,o);return i!==void 0&&M(n,i.zone)[i.slot]===o},[n]),r=d.useCallback(o=>{const i=j(n.registry,o);!i||M(n,i.zone)[i.slot]!==o||e.getState().close(i.zone,i.slot)},[n,e]);return d.useMemo(()=>({panels:n.registry,reveal:s.show,close:r,toggle:s.toggle,isShown:c,focusedZone:t,reset:s.reset}),[n,s.show,s.toggle,s.reset,r,c,t])}exports.cx=b.cx;exports.BOTTOM_ZONES=be;exports.Band=Ye;exports.Center=W;exports.ContentProvider=He;exports.DEFAULT_LABELS=We;exports.DEFAULT_SIZES=xe;exports.DEFAULT_VIEW=U;exports.IconButton=Oe;exports.LAYOUT_VERSION=le;exports.MIN_CENTER=ie;exports.MIN_SIZE=R;exports.MIN_SPLIT=_;exports.Panel=$;exports.PanelFrame=te;exports.PanelHeader=Ve;exports.Panels=de;exports.PanelsProvider=Ze;exports.Rail=se;exports.RailZone=oe;exports.ResizeHandle=H;exports.SLOTS=re;exports.Separator=Y;exports.Surface=ue;exports.ZONES=k;exports.ZONES_BY_SIDE=A;exports.ZoneEdge=S;exports.browserStorage=_e;exports.createPanelsStore=Ne;exports.fitSplit=T;exports.fitZoneSize=ce;exports.isBottom=V;exports.isHorizontal=C;exports.isLeading=K;exports.memoryStorage=nn;exports.openOf=E;exports.readLayout=Ie;exports.sharedSizes=je;exports.shownIn=M;exports.shownSpecsIn=I;exports.sizeKeyOf=z;exports.specOf=j;exports.undraggedSizeOf=D;exports.useArrangement=L;exports.useBandHalves=Fe;exports.useContainerFit=Re;exports.usePanelContent=Ue;exports.usePanels=dn;exports.usePanelsActions=O;exports.usePanelsComponents=ae;exports.usePanelsState=v;exports.usePanelsStore=Z;exports.usePointerDrag=ke;exports.useShownIn=ze;exports.useShownSpecsIn=ee;exports.useZone=Ae;exports.useZoneDraws=ne;exports.useZonePanels=Be;exports.useZoneTakesRoom=Te;exports.writeLayout=Ce;exports.zoneDraws=F;exports.zoneTakesRoom=B;
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { jsx as u, jsxs as
|
|
2
|
-
import F, { useEffect as nn, useLayoutEffect as kn, useState as W, useMemo as
|
|
3
|
-
import { c as
|
|
1
|
+
import { jsx as u, jsxs as g, Fragment as A } from "react/jsx-runtime";
|
|
2
|
+
import F, { useEffect as nn, useLayoutEffect as kn, useState as W, useMemo as w, useContext as tn, createContext as en, useRef as H, useCallback as _, memo as Sn, Fragment as Dn, Children as jn, isValidElement as Hn } from "react";
|
|
3
|
+
import { c as b } from "./cx-CcykAxZN.js";
|
|
4
4
|
const an = (n) => {
|
|
5
5
|
let t;
|
|
6
6
|
const e = /* @__PURE__ */ new Set(), o = (a, d) => {
|
|
7
7
|
const f = typeof a == "function" ? a(t) : a;
|
|
8
8
|
if (!Object.is(f, t)) {
|
|
9
9
|
const h = t;
|
|
10
|
-
t = d ?? (typeof f != "object" || f === null) ? f : Object.assign({}, t, f), e.forEach((
|
|
10
|
+
t = d ?? (typeof f != "object" || f === null) ? f : Object.assign({}, t, f), e.forEach((m) => m(t, h));
|
|
11
11
|
}
|
|
12
12
|
}, c = () => t, i = { setState: o, getState: c, getInitialState: () => l, subscribe: (a) => (e.add(a), () => e.delete(a)) }, l = t = n(o, c, i);
|
|
13
13
|
return i;
|
|
@@ -34,7 +34,7 @@ const G = {
|
|
|
34
34
|
function un(n) {
|
|
35
35
|
return n === "left" || n === "top";
|
|
36
36
|
}
|
|
37
|
-
const
|
|
37
|
+
const B = 140, Pn = 240, Z = 100, Wn = {
|
|
38
38
|
left: 320,
|
|
39
39
|
right: 260,
|
|
40
40
|
top: 180,
|
|
@@ -56,8 +56,8 @@ function In(n, t, e) {
|
|
|
56
56
|
return Math.min(Math.max(n, t), e);
|
|
57
57
|
}
|
|
58
58
|
function xn(n, t, e) {
|
|
59
|
-
const o = Math.max(
|
|
60
|
-
return In(Math.round(n),
|
|
59
|
+
const o = Math.max(B, Math.round(t - e - Pn));
|
|
60
|
+
return In(Math.round(n), B, o);
|
|
61
61
|
}
|
|
62
62
|
function D(n, t) {
|
|
63
63
|
const e = Math.max(Z, Math.round(t - Z));
|
|
@@ -83,7 +83,7 @@ function Gn(n, t, e, o, c) {
|
|
|
83
83
|
function Jn(n, t, e) {
|
|
84
84
|
const o = e - Pn, c = n + t;
|
|
85
85
|
if (c <= o) return [n, t];
|
|
86
|
-
const s = (a) => a === 0 ? 0 :
|
|
86
|
+
const s = (a) => a === 0 ? 0 : B, r = s(n) + s(t);
|
|
87
87
|
if (o <= r)
|
|
88
88
|
return [Math.min(n, s(n)), Math.min(t, s(t))];
|
|
89
89
|
const i = o / c, l = Math.max(s(n), Math.round(n * i));
|
|
@@ -247,7 +247,11 @@ function qn(n = {}) {
|
|
|
247
247
|
// The view in front is settled on the spot, not left for the next render: nothing
|
|
248
248
|
// re-renders the provider when a button inside the chassis is what asked for the reset,
|
|
249
249
|
// so the frame stayed blank — and the arrangement being escaped stayed on disk.
|
|
250
|
-
|
|
250
|
+
//
|
|
251
|
+
// 🛑 Unless nothing is declared yet, and then it is left UNSETTLED: settled against an
|
|
252
|
+
// empty registry it would be settled EMPTY, and having an entry is what stops anything
|
|
253
|
+
// reopening it. Every half would stay shut for good.
|
|
254
|
+
views: s.registry.length === 0 ? {} : { [s.view]: $(s.registry, s.defaults) },
|
|
251
255
|
lengths: fn,
|
|
252
256
|
focusedZone: null,
|
|
253
257
|
// Left behind, a solo panel closed after a reset would give back the zone the reset
|
|
@@ -280,14 +284,14 @@ const Ct = () => {
|
|
|
280
284
|
}
|
|
281
285
|
}
|
|
282
286
|
}), En = 2;
|
|
283
|
-
function
|
|
287
|
+
function P(n) {
|
|
284
288
|
return typeof n == "object" && n !== null && !Array.isArray(n);
|
|
285
289
|
}
|
|
286
290
|
function hn(n) {
|
|
287
291
|
const t = {};
|
|
288
292
|
for (const e of U) {
|
|
289
293
|
const o = n[e];
|
|
290
|
-
if (
|
|
294
|
+
if (P(o))
|
|
291
295
|
for (const c of Nn) {
|
|
292
296
|
const s = o[c];
|
|
293
297
|
s !== null && typeof s != "string" || (t[e] = { ...t[e], [c]: s });
|
|
@@ -305,11 +309,11 @@ function pn(n) {
|
|
|
305
309
|
}
|
|
306
310
|
function nt(n, t) {
|
|
307
311
|
if (n.version === 1)
|
|
308
|
-
return
|
|
309
|
-
if (n.version !== En || !
|
|
312
|
+
return P(n.open) ? { [t]: hn(n.open) } : void 0;
|
|
313
|
+
if (n.version !== En || !P(n.views)) return;
|
|
310
314
|
const e = /* @__PURE__ */ Object.create(null);
|
|
311
315
|
for (const [o, c] of Object.entries(n.views))
|
|
312
|
-
|
|
316
|
+
P(c) && (e[o] = hn(c));
|
|
313
317
|
return e;
|
|
314
318
|
}
|
|
315
319
|
function tt(n, t, e = on) {
|
|
@@ -321,11 +325,11 @@ function tt(n, t, e = on) {
|
|
|
321
325
|
} catch {
|
|
322
326
|
return;
|
|
323
327
|
}
|
|
324
|
-
if (!
|
|
328
|
+
if (!P(c) || !P(c.lengths)) return;
|
|
325
329
|
const s = nt(c, e);
|
|
326
330
|
if (!s) return;
|
|
327
331
|
const r = c.lengths;
|
|
328
|
-
if (!
|
|
332
|
+
if (!P(r.sizes) || !P(r.splits)) return;
|
|
329
333
|
const i = r.bandSplit;
|
|
330
334
|
return {
|
|
331
335
|
views: s,
|
|
@@ -375,13 +379,13 @@ function O() {
|
|
|
375
379
|
if (!n) throw new Error("usePanelsStore must be used inside a <Panels> or <PanelsProvider>");
|
|
376
380
|
return n;
|
|
377
381
|
}
|
|
378
|
-
function
|
|
382
|
+
function v(n) {
|
|
379
383
|
const t = O();
|
|
380
384
|
return Yn(t, n);
|
|
381
385
|
}
|
|
382
386
|
function R() {
|
|
383
387
|
const n = O();
|
|
384
|
-
return
|
|
388
|
+
return w(() => {
|
|
385
389
|
const { show: t, close: e, toggle: o, focus: c, resize: s, resplit: r, resplitBand: i, fit: l, reset: a } = n.getState();
|
|
386
390
|
return { show: t, close: e, toggle: o, focus: c, resize: s, resplit: r, resplitBand: i, fit: l, reset: a };
|
|
387
391
|
}, [n]);
|
|
@@ -397,14 +401,14 @@ function rt({
|
|
|
397
401
|
ref: i,
|
|
398
402
|
...l
|
|
399
403
|
}) {
|
|
400
|
-
return /* @__PURE__ */
|
|
404
|
+
return /* @__PURE__ */ g(
|
|
401
405
|
"button",
|
|
402
406
|
{
|
|
403
407
|
type: "button",
|
|
404
408
|
ref: i,
|
|
405
409
|
"aria-label": t,
|
|
406
410
|
"aria-pressed": c ? void 0 : e,
|
|
407
|
-
className:
|
|
411
|
+
className: b(
|
|
408
412
|
"pnl-icon-button",
|
|
409
413
|
e && "pnl-icon-button--active",
|
|
410
414
|
o && "pnl-icon-button--accented",
|
|
@@ -440,37 +444,37 @@ function ct(n) {
|
|
|
440
444
|
}, [n, t]);
|
|
441
445
|
}
|
|
442
446
|
function T() {
|
|
443
|
-
const n =
|
|
444
|
-
return
|
|
447
|
+
const n = v((o) => o.registry), t = v((o) => o.view), e = v((o) => o.views[o.view]);
|
|
448
|
+
return w(
|
|
445
449
|
() => ({ registry: n, view: t, views: e === void 0 ? {} : { [t]: e } }),
|
|
446
450
|
[n, t, e]
|
|
447
451
|
);
|
|
448
452
|
}
|
|
449
453
|
function lt(n) {
|
|
450
454
|
const t = T();
|
|
451
|
-
return
|
|
455
|
+
return w(() => L(t, n), [t, n]);
|
|
452
456
|
}
|
|
453
|
-
function
|
|
457
|
+
function gn(n) {
|
|
454
458
|
const t = T();
|
|
455
|
-
return
|
|
459
|
+
return w(() => E(t, n), [t, n]);
|
|
456
460
|
}
|
|
457
|
-
function
|
|
461
|
+
function mn(n) {
|
|
458
462
|
const t = T();
|
|
459
|
-
return
|
|
463
|
+
return w(() => j(t, n), [t, n]);
|
|
460
464
|
}
|
|
461
465
|
function at(n) {
|
|
462
466
|
const t = T();
|
|
463
|
-
return
|
|
467
|
+
return w(() => X(t, n), [t, n]);
|
|
464
468
|
}
|
|
465
469
|
function ut() {
|
|
466
470
|
return {
|
|
467
|
-
left:
|
|
468
|
-
right:
|
|
471
|
+
left: mn(G.left.band),
|
|
472
|
+
right: mn(G.right.band)
|
|
469
473
|
};
|
|
470
474
|
}
|
|
471
475
|
function dt() {
|
|
472
476
|
const n = H(null);
|
|
473
|
-
return
|
|
477
|
+
return w(() => ({
|
|
474
478
|
start: (e, o) => {
|
|
475
479
|
e.currentTarget.setPointerCapture(e.pointerId), n.current = { ...o, pointerId: e.pointerId };
|
|
476
480
|
},
|
|
@@ -492,10 +496,10 @@ function Q({
|
|
|
492
496
|
step: l = 16,
|
|
493
497
|
className: a
|
|
494
498
|
}) {
|
|
495
|
-
const d = dt(), f = H(null), h = n === "vertical",
|
|
499
|
+
const d = dt(), f = H(null), h = n === "vertical", m = _(
|
|
496
500
|
(p) => (h ? p?.clientHeight : p?.clientWidth) ?? 0,
|
|
497
501
|
[h]
|
|
498
|
-
),
|
|
502
|
+
), I = _(
|
|
499
503
|
(p) => {
|
|
500
504
|
const S = d.matching(p);
|
|
501
505
|
if (!S) return;
|
|
@@ -503,14 +507,14 @@ function Q({
|
|
|
503
507
|
o(S.size + Y * (t ? -1 : 1), S.available);
|
|
504
508
|
},
|
|
505
509
|
[d, t, h, o]
|
|
506
|
-
),
|
|
510
|
+
), y = _(
|
|
507
511
|
(p) => {
|
|
508
512
|
const S = h ? "ArrowUp" : "ArrowLeft", V = h ? "ArrowDown" : "ArrowRight";
|
|
509
513
|
if (p.key !== S && p.key !== V) return;
|
|
510
|
-
const Y =
|
|
511
|
-
p.preventDefault(), o(
|
|
514
|
+
const Y = m(f.current?.parentElement), An = e ?? c?.() ?? 0, Bn = p.key === V ? 1 : -1;
|
|
515
|
+
p.preventDefault(), o(An + l * Bn * (t ? -1 : 1), Y);
|
|
512
516
|
},
|
|
513
|
-
[t, h, c, o,
|
|
517
|
+
[t, h, c, o, m, e, l]
|
|
514
518
|
);
|
|
515
519
|
return /* @__PURE__ */ u(
|
|
516
520
|
"div",
|
|
@@ -527,15 +531,15 @@ function Q({
|
|
|
527
531
|
d.start(p, {
|
|
528
532
|
position: h ? p.clientY : p.clientX,
|
|
529
533
|
size: e ?? c?.() ?? 0,
|
|
530
|
-
available:
|
|
534
|
+
available: m(p.currentTarget.parentElement)
|
|
531
535
|
});
|
|
532
536
|
},
|
|
533
|
-
onPointerMove:
|
|
537
|
+
onPointerMove: I,
|
|
534
538
|
onPointerUp: d.cancel,
|
|
535
539
|
onPointerCancel: d.cancel,
|
|
536
540
|
onLostPointerCapture: d.cancel,
|
|
537
|
-
onKeyDown:
|
|
538
|
-
className:
|
|
541
|
+
onKeyDown: y,
|
|
542
|
+
className: b("pnl-handle", h ? "pnl-handle--row" : "pnl-handle--col", a)
|
|
539
543
|
}
|
|
540
544
|
);
|
|
541
545
|
}
|
|
@@ -543,48 +547,48 @@ function vn(n, t, e, o) {
|
|
|
543
547
|
return o ? t ?? K(e, n) : 0;
|
|
544
548
|
}
|
|
545
549
|
function ft(n) {
|
|
546
|
-
const t =
|
|
550
|
+
const t = gn(n), e = gn(x[n]), o = at(x[n]), c = v(
|
|
547
551
|
(a) => a.lengths.sizes[k(n)]
|
|
548
|
-
), s =
|
|
552
|
+
), s = v(
|
|
549
553
|
(a) => a.lengths.sizes[k(x[n])]
|
|
550
|
-
), r =
|
|
554
|
+
), r = v((a) => a.lengths.splits[n]), i = v(
|
|
551
555
|
(a) => M(n) ? a.available.height : a.available.width
|
|
552
|
-
), l =
|
|
553
|
-
return
|
|
554
|
-
const { primary: a, secondary: d } = t, f = a !== void 0 || d !== void 0, h = vn(a, c, n, f),
|
|
556
|
+
), l = v((a) => a.focusedZone === n);
|
|
557
|
+
return w(() => {
|
|
558
|
+
const { primary: a, secondary: d } = t, f = a !== void 0 || d !== void 0, h = vn(a, c, n, f), m = vn(e.primary, s, x[n], o);
|
|
555
559
|
return {
|
|
556
560
|
primary: a,
|
|
557
561
|
secondary: d,
|
|
558
562
|
draws: f,
|
|
559
563
|
// Zero until the container has been measured: bounding against nothing would collapse
|
|
560
564
|
// every zone to its floor on the very first paint.
|
|
561
|
-
size: i === 0 ? h : Jn(h,
|
|
565
|
+
size: i === 0 ? h : Jn(h, m, i)[0],
|
|
562
566
|
split: r,
|
|
563
567
|
focused: l
|
|
564
568
|
};
|
|
565
569
|
}, [t, e, o, c, s, i, r, l, n]);
|
|
566
570
|
}
|
|
567
571
|
function ht(n) {
|
|
568
|
-
const t =
|
|
569
|
-
return
|
|
572
|
+
const t = v((e) => e.registry);
|
|
573
|
+
return w(() => [
|
|
570
574
|
["primary", t.filter((o) => o.zone === n && o.slot === "primary")],
|
|
571
575
|
["secondary", t.filter((o) => o.zone === n && o.slot === "secondary")]
|
|
572
576
|
].filter(([, o]) => o.length > 0), [t, n]);
|
|
573
577
|
}
|
|
574
578
|
const Rn = en(/* @__PURE__ */ new Map()), pt = Rn.Provider;
|
|
575
|
-
function
|
|
579
|
+
function gt(n) {
|
|
576
580
|
return tn(Rn).get(n);
|
|
577
581
|
}
|
|
578
|
-
function
|
|
582
|
+
function mt({
|
|
579
583
|
title: n,
|
|
580
584
|
children: t,
|
|
581
585
|
fillActions: e,
|
|
582
586
|
trailing: o,
|
|
583
587
|
className: c
|
|
584
588
|
}) {
|
|
585
|
-
return /* @__PURE__ */
|
|
586
|
-
/* @__PURE__ */ u("span", { className:
|
|
587
|
-
/* @__PURE__ */ u("span", { className:
|
|
589
|
+
return /* @__PURE__ */ g("header", { className: b("pnl-header", c), children: [
|
|
590
|
+
/* @__PURE__ */ u("span", { className: b("pnl-header__title", e && "pnl-header__title--fixed"), children: n }),
|
|
591
|
+
/* @__PURE__ */ u("span", { className: b("pnl-header__actions", e && "pnl-header__actions--fill"), children: t }),
|
|
588
592
|
/* @__PURE__ */ u("span", { className: "pnl-header__trailing", children: o })
|
|
589
593
|
] });
|
|
590
594
|
}
|
|
@@ -593,12 +597,12 @@ function sn({ orientation: n = "vertical", className: t }) {
|
|
|
593
597
|
"span",
|
|
594
598
|
{
|
|
595
599
|
"aria-hidden": "true",
|
|
596
|
-
className:
|
|
600
|
+
className: b("pnl-separator", `pnl-separator--${n}`, t)
|
|
597
601
|
}
|
|
598
602
|
);
|
|
599
603
|
}
|
|
600
604
|
function Tn({ children: n, className: t, ...e }) {
|
|
601
|
-
return /* @__PURE__ */ u("section", { className:
|
|
605
|
+
return /* @__PURE__ */ u("section", { className: b("pnl-surface", t), ...e, children: n });
|
|
602
606
|
}
|
|
603
607
|
function vt({
|
|
604
608
|
panel: n,
|
|
@@ -606,11 +610,11 @@ function vt({
|
|
|
606
610
|
closeLabel: e,
|
|
607
611
|
onFocus: o
|
|
608
612
|
}) {
|
|
609
|
-
const { close: c } = R(), { IconButton: s } = On(), r =
|
|
613
|
+
const { close: c } = R(), { IconButton: s } = On(), r = gt(n.id);
|
|
610
614
|
return (
|
|
611
615
|
// The zone owns its length: a half given one keeps it, the other takes what is left. Both
|
|
612
616
|
// sized here would make the pair overflow the zone the user dragged.
|
|
613
|
-
/* @__PURE__ */
|
|
617
|
+
/* @__PURE__ */ g(
|
|
614
618
|
Tn,
|
|
615
619
|
{
|
|
616
620
|
"aria-label": n.title,
|
|
@@ -619,11 +623,11 @@ function vt({
|
|
|
619
623
|
style: t === void 0 ? void 0 : { flexBasis: t },
|
|
620
624
|
children: [
|
|
621
625
|
/* @__PURE__ */ u(
|
|
622
|
-
|
|
626
|
+
mt,
|
|
623
627
|
{
|
|
624
628
|
title: n.title,
|
|
625
|
-
fillActions: r?.actions !== void 0 && M(n.zone),
|
|
626
|
-
trailing: /* @__PURE__ */
|
|
629
|
+
fillActions: n.fillActions ?? (r?.actions !== void 0 && M(n.zone)),
|
|
630
|
+
trailing: /* @__PURE__ */ g(A, { children: [
|
|
627
631
|
r?.actions !== void 0 && /* @__PURE__ */ u(sn, {}),
|
|
628
632
|
/* @__PURE__ */ u(
|
|
629
633
|
s,
|
|
@@ -639,7 +643,7 @@ function vt({
|
|
|
639
643
|
children: r?.actions
|
|
640
644
|
}
|
|
641
645
|
),
|
|
642
|
-
/* @__PURE__ */ u("div", { className:
|
|
646
|
+
/* @__PURE__ */ u("div", { className: b("pnl-body"), children: r?.content })
|
|
643
647
|
]
|
|
644
648
|
}
|
|
645
649
|
)
|
|
@@ -656,16 +660,16 @@ function bt() {
|
|
|
656
660
|
) });
|
|
657
661
|
}
|
|
658
662
|
function wt({ zone: n, labels: t }) {
|
|
659
|
-
const e = ft(n), { focus: o, resize: c, resplit: s } = R(), r = H(null), i =
|
|
663
|
+
const e = ft(n), { focus: o, resize: c, resplit: s } = R(), r = H(null), i = _(() => o(n), [o, n]), l = M(n), a = _(
|
|
660
664
|
() => l ? r.current?.clientHeight ?? 0 : r.current?.clientWidth ?? 0,
|
|
661
665
|
[l]
|
|
662
666
|
);
|
|
663
667
|
if (!e.draws) return null;
|
|
664
|
-
const { primary: d, secondary: f, size: h, split:
|
|
668
|
+
const { primary: d, secondary: f, size: h, split: m } = e, I = /* @__PURE__ */ g(
|
|
665
669
|
"div",
|
|
666
670
|
{
|
|
667
671
|
ref: r,
|
|
668
|
-
className:
|
|
672
|
+
className: b("pnl-zone", l ? "pnl-zone--row" : "pnl-zone--col"),
|
|
669
673
|
style: { [l ? "height" : "width"]: h },
|
|
670
674
|
children: [
|
|
671
675
|
d && /* @__PURE__ */ u(bn, { panel: d, closeLabel: t.closePanel, onFocus: i }),
|
|
@@ -674,7 +678,7 @@ function wt({ zone: n, labels: t }) {
|
|
|
674
678
|
{
|
|
675
679
|
axis: l ? "horizontal" : "vertical",
|
|
676
680
|
invert: !0,
|
|
677
|
-
size:
|
|
681
|
+
size: m,
|
|
678
682
|
min: Z,
|
|
679
683
|
label: t.resizeSplit,
|
|
680
684
|
onSize: (p, S) => s(n, p, S)
|
|
@@ -684,46 +688,46 @@ function wt({ zone: n, labels: t }) {
|
|
|
684
688
|
bn,
|
|
685
689
|
{
|
|
686
690
|
panel: f,
|
|
687
|
-
length: d &&
|
|
691
|
+
length: d && m !== void 0 ? m : void 0,
|
|
688
692
|
closeLabel: t.closePanel,
|
|
689
693
|
onFocus: i
|
|
690
694
|
}
|
|
691
695
|
)
|
|
692
696
|
]
|
|
693
697
|
}
|
|
694
|
-
),
|
|
698
|
+
), y = /* @__PURE__ */ u(
|
|
695
699
|
Q,
|
|
696
700
|
{
|
|
697
701
|
axis: l ? "vertical" : "horizontal",
|
|
698
702
|
invert: !un(n),
|
|
699
703
|
size: h,
|
|
700
|
-
min:
|
|
704
|
+
min: B,
|
|
701
705
|
measure: a,
|
|
702
706
|
label: t.resizeZone,
|
|
703
707
|
onSize: (p, S) => c(n, p, S)
|
|
704
708
|
}
|
|
705
709
|
);
|
|
706
|
-
return un(n) ? /* @__PURE__ */
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
] }) : /* @__PURE__ */
|
|
710
|
-
|
|
711
|
-
|
|
710
|
+
return un(n) ? /* @__PURE__ */ g(A, { children: [
|
|
711
|
+
I,
|
|
712
|
+
y
|
|
713
|
+
] }) : /* @__PURE__ */ g(A, { children: [
|
|
714
|
+
y,
|
|
715
|
+
I
|
|
712
716
|
] });
|
|
713
717
|
}
|
|
714
|
-
const
|
|
718
|
+
const N = Sn(wt);
|
|
715
719
|
function yt({ left: n, right: t, labels: e }) {
|
|
716
|
-
const o =
|
|
720
|
+
const o = v((r) => r.lengths.bandSplit), { resplitBand: c } = R(), s = _(
|
|
717
721
|
(r, i) => c(r, i),
|
|
718
722
|
[c]
|
|
719
723
|
);
|
|
720
|
-
return !n && !t ? null : !n || !t ? /* @__PURE__ */ u(
|
|
724
|
+
return !n && !t ? null : !n || !t ? /* @__PURE__ */ u(N, { zone: n ? "bottomLeft" : "bottomRight", labels: e }) : /* @__PURE__ */ g("div", { className: "pnl-band", children: [
|
|
721
725
|
/* @__PURE__ */ u(
|
|
722
726
|
"div",
|
|
723
727
|
{
|
|
724
|
-
className:
|
|
728
|
+
className: b("pnl-band__half", o === void 0 && "pnl-band__half--even"),
|
|
725
729
|
style: o === void 0 ? void 0 : { width: o },
|
|
726
|
-
children: /* @__PURE__ */ u(
|
|
730
|
+
children: /* @__PURE__ */ u(N, { zone: "bottomLeft", labels: e })
|
|
727
731
|
}
|
|
728
732
|
),
|
|
729
733
|
/* @__PURE__ */ u(
|
|
@@ -736,7 +740,7 @@ function yt({ left: n, right: t, labels: e }) {
|
|
|
736
740
|
onSize: s
|
|
737
741
|
}
|
|
738
742
|
),
|
|
739
|
-
/* @__PURE__ */ u("div", { className: "pnl-band__half pnl-band__half--rest", children: /* @__PURE__ */ u(
|
|
743
|
+
/* @__PURE__ */ u("div", { className: "pnl-band__half pnl-band__half--rest", children: /* @__PURE__ */ u(N, { zone: "bottomRight", labels: e }) })
|
|
740
744
|
] });
|
|
741
745
|
}
|
|
742
746
|
function cn(n) {
|
|
@@ -755,15 +759,15 @@ function ln(n) {
|
|
|
755
759
|
ln.displayName = "Panels.Panel";
|
|
756
760
|
function wn({ side: n, header: t, className: e }) {
|
|
757
761
|
const { column: o, band: c } = G[n];
|
|
758
|
-
return /* @__PURE__ */
|
|
762
|
+
return /* @__PURE__ */ g(
|
|
759
763
|
"div",
|
|
760
764
|
{
|
|
761
765
|
role: "toolbar",
|
|
762
766
|
"aria-orientation": "vertical",
|
|
763
|
-
className:
|
|
767
|
+
className: b("pnl-rail", `pnl-rail--${n}`, e),
|
|
764
768
|
children: [
|
|
765
|
-
/* @__PURE__ */
|
|
766
|
-
t !== void 0 && /* @__PURE__ */
|
|
769
|
+
/* @__PURE__ */ g("div", { className: "pnl-rail__group", children: [
|
|
770
|
+
t !== void 0 && /* @__PURE__ */ g(A, { children: [
|
|
767
771
|
t,
|
|
768
772
|
/* @__PURE__ */ u(sn, { orientation: "horizontal" })
|
|
769
773
|
] }),
|
|
@@ -775,8 +779,8 @@ function wn({ side: n, header: t, className: e }) {
|
|
|
775
779
|
);
|
|
776
780
|
}
|
|
777
781
|
function yn({ zone: n }) {
|
|
778
|
-
const t = ht(n), e = lt(n), o =
|
|
779
|
-
return t.length === 0 ? null : /* @__PURE__ */ u("div", { className: "pnl-rail__group", children: t.map(([r, i], l) => /* @__PURE__ */
|
|
782
|
+
const t = ht(n), e = lt(n), o = v((r) => r.focusedZone === n), { toggle: c } = R(), { IconButton: s } = On();
|
|
783
|
+
return t.length === 0 ? null : /* @__PURE__ */ u("div", { className: "pnl-rail__group", children: t.map(([r, i], l) => /* @__PURE__ */ g(Dn, { children: [
|
|
780
784
|
l > 0 && /* @__PURE__ */ u(sn, { orientation: "horizontal" }),
|
|
781
785
|
i.map((a) => {
|
|
782
786
|
const d = e[r] === a.id;
|
|
@@ -811,8 +815,8 @@ function Nt(n) {
|
|
|
811
815
|
o.push(s);
|
|
812
816
|
continue;
|
|
813
817
|
}
|
|
814
|
-
const r = s.props, {
|
|
815
|
-
t.push({
|
|
818
|
+
const r = s.props, { actions: i, children: l, slot: a = "primary", ...d } = r;
|
|
819
|
+
t.push({ ...d, slot: a }), e.set(d.id, { content: l, actions: i });
|
|
816
820
|
}
|
|
817
821
|
return { specs: t, content: e, centre: c, loose: o };
|
|
818
822
|
}
|
|
@@ -853,53 +857,53 @@ function Pt({
|
|
|
853
857
|
}) {
|
|
854
858
|
const l = O(), a = H(null);
|
|
855
859
|
ct(a);
|
|
856
|
-
const [d] = W(() => it(r)), { specs: f, content: h, centre:
|
|
860
|
+
const [d] = W(() => it(r)), { specs: f, content: h, centre: m, loose: I } = w(() => Nt(i), [i]), y = w(() => ({ ...St, ...o }), [o]);
|
|
857
861
|
Mn(() => {
|
|
858
862
|
l.getState().declare(f);
|
|
859
863
|
}, [l, f]);
|
|
860
864
|
const p = ut();
|
|
861
|
-
return /* @__PURE__ */ u(st, { value: d, children: /* @__PURE__ */ u(pt, { value: h, children: /* @__PURE__ */
|
|
865
|
+
return /* @__PURE__ */ u(st, { value: d, children: /* @__PURE__ */ u(pt, { value: h, children: /* @__PURE__ */ g("div", { "data-pnl-theme": c, className: b("pnl-root", s), children: [
|
|
862
866
|
n,
|
|
863
|
-
/* @__PURE__ */
|
|
867
|
+
/* @__PURE__ */ g("div", { className: "pnl-middle", children: [
|
|
864
868
|
/* @__PURE__ */ u(wn, { side: "left", header: e }),
|
|
865
|
-
/* @__PURE__ */
|
|
866
|
-
/* @__PURE__ */ u(
|
|
867
|
-
/* @__PURE__ */
|
|
868
|
-
!p.left && /* @__PURE__ */ u(
|
|
869
|
-
/* @__PURE__ */
|
|
870
|
-
/* @__PURE__ */
|
|
871
|
-
p.left && /* @__PURE__ */ u(
|
|
872
|
-
/* @__PURE__ */ u(Tn, { className: "pnl-centre", children:
|
|
873
|
-
p.right && /* @__PURE__ */ u(
|
|
869
|
+
/* @__PURE__ */ g("div", { ref: a, className: "pnl-columns", children: [
|
|
870
|
+
/* @__PURE__ */ u(N, { zone: "top", labels: y }),
|
|
871
|
+
/* @__PURE__ */ g("div", { className: "pnl-row", children: [
|
|
872
|
+
!p.left && /* @__PURE__ */ u(N, { zone: "left", labels: y }),
|
|
873
|
+
/* @__PURE__ */ g("div", { className: "pnl-stack", children: [
|
|
874
|
+
/* @__PURE__ */ g("div", { className: "pnl-row", children: [
|
|
875
|
+
p.left && /* @__PURE__ */ u(N, { zone: "left", labels: y }),
|
|
876
|
+
/* @__PURE__ */ u(Tn, { className: "pnl-centre", children: m?.props.children }),
|
|
877
|
+
p.right && /* @__PURE__ */ u(N, { zone: "right", labels: y })
|
|
874
878
|
] }),
|
|
875
|
-
/* @__PURE__ */ u(yt, { left: p.left, right: p.right, labels:
|
|
879
|
+
/* @__PURE__ */ u(yt, { left: p.left, right: p.right, labels: y })
|
|
876
880
|
] }),
|
|
877
|
-
!p.right && /* @__PURE__ */ u(
|
|
881
|
+
!p.right && /* @__PURE__ */ u(N, { zone: "right", labels: y })
|
|
878
882
|
] })
|
|
879
883
|
] }),
|
|
880
884
|
/* @__PURE__ */ u(wn, { side: "right" })
|
|
881
885
|
] }),
|
|
882
886
|
t,
|
|
883
|
-
|
|
887
|
+
I
|
|
884
888
|
] }) }) });
|
|
885
889
|
}
|
|
886
890
|
Fn.Panel = ln;
|
|
887
891
|
Fn.Center = cn;
|
|
888
892
|
function Zt() {
|
|
889
|
-
const n = O(), t = T(), e =
|
|
893
|
+
const n = O(), t = T(), e = v((r) => r.focusedZone), o = R(), c = _(
|
|
890
894
|
(r) => {
|
|
891
895
|
const i = C(t.registry, r);
|
|
892
896
|
return i !== void 0 && L(t, i.zone)[i.slot] === r;
|
|
893
897
|
},
|
|
894
898
|
[t]
|
|
895
|
-
), s =
|
|
899
|
+
), s = _(
|
|
896
900
|
(r) => {
|
|
897
901
|
const i = C(t.registry, r);
|
|
898
902
|
!i || L(t, i.zone)[i.slot] !== r || n.getState().close(i.zone, i.slot);
|
|
899
903
|
},
|
|
900
904
|
[t, n]
|
|
901
905
|
);
|
|
902
|
-
return
|
|
906
|
+
return w(
|
|
903
907
|
() => ({
|
|
904
908
|
panels: t.registry,
|
|
905
909
|
reveal: o.show,
|
|
@@ -923,11 +927,11 @@ export {
|
|
|
923
927
|
rt as IconButton,
|
|
924
928
|
En as LAYOUT_VERSION,
|
|
925
929
|
Pn as MIN_CENTER,
|
|
926
|
-
|
|
930
|
+
B as MIN_SIZE,
|
|
927
931
|
Z as MIN_SPLIT,
|
|
928
932
|
ln as Panel,
|
|
929
933
|
bn as PanelFrame,
|
|
930
|
-
|
|
934
|
+
mt as PanelHeader,
|
|
931
935
|
Fn as Panels,
|
|
932
936
|
ot as PanelsProvider,
|
|
933
937
|
wn as Rail,
|
|
@@ -938,10 +942,10 @@ export {
|
|
|
938
942
|
Tn as Surface,
|
|
939
943
|
U as ZONES,
|
|
940
944
|
G as ZONES_BY_SIDE,
|
|
941
|
-
|
|
945
|
+
N as ZoneEdge,
|
|
942
946
|
Qn as browserStorage,
|
|
943
947
|
qn as createPanelsStore,
|
|
944
|
-
|
|
948
|
+
b as cx,
|
|
945
949
|
D as fitSplit,
|
|
946
950
|
xn as fitZoneSize,
|
|
947
951
|
rn as isBottom,
|
|
@@ -959,17 +963,17 @@ export {
|
|
|
959
963
|
T as useArrangement,
|
|
960
964
|
ut as useBandHalves,
|
|
961
965
|
ct as useContainerFit,
|
|
962
|
-
|
|
966
|
+
gt as usePanelContent,
|
|
963
967
|
Zt as usePanels,
|
|
964
968
|
R as usePanelsActions,
|
|
965
969
|
On as usePanelsComponents,
|
|
966
|
-
|
|
970
|
+
v as usePanelsState,
|
|
967
971
|
O as usePanelsStore,
|
|
968
972
|
dt as usePointerDrag,
|
|
969
973
|
lt as useShownIn,
|
|
970
|
-
|
|
974
|
+
gn as useShownSpecsIn,
|
|
971
975
|
ft as useZone,
|
|
972
|
-
|
|
976
|
+
mn as useZoneDraws,
|
|
973
977
|
ht as useZonePanels,
|
|
974
978
|
at as useZoneTakesRoom,
|
|
975
979
|
et as writeLayout,
|
package/llms-full.txt
CHANGED
|
@@ -88,7 +88,7 @@ usual missing piece.
|
|
|
88
88
|
`components` `theme` `className`
|
|
89
89
|
|
|
90
90
|
### `<Panel>` props
|
|
91
|
-
`id` `zone` `slot?` `title` `icon?` `actions?` `opens?` `solo?`
|
|
91
|
+
`id` `zone` `slot?` `title` `icon?` `actions?` `opens?` `solo?` `fillActions?`
|
|
92
92
|
|
|
93
93
|
### Hooks
|
|
94
94
|
- `usePanels<Id>()` → `{ panels, reveal, close, toggle, isShown, focusedZone, reset }`
|
|
@@ -449,6 +449,15 @@ arrangement nobody remembers making, is not a restoration.
|
|
|
449
449
|
|
|
450
450
|
`solo` only applies to `primary`.
|
|
451
451
|
|
|
452
|
+
## `fillActions`
|
|
453
|
+
|
|
454
|
+
A panel in a horizontal zone gets the header's free width for its actions — right for a montage
|
|
455
|
+
bar, wrong for a band holding a list with two buttons. Say which yours is:
|
|
456
|
+
|
|
457
|
+
```tsx
|
|
458
|
+
<Panel id="problems" zone="bottomRight" title="Problems" fillActions={false} actions={…}>
|
|
459
|
+
```
|
|
460
|
+
|
|
452
461
|
## Adding and removing panels
|
|
453
462
|
|
|
454
463
|
The registry follows your JSX, in the order you declare it. A panel that stops being declared
|
package/llms.txt
CHANGED
|
@@ -88,7 +88,7 @@ usual missing piece.
|
|
|
88
88
|
`components` `theme` `className`
|
|
89
89
|
|
|
90
90
|
### `<Panel>` props
|
|
91
|
-
`id` `zone` `slot?` `title` `icon?` `actions?` `opens?` `solo?`
|
|
91
|
+
`id` `zone` `slot?` `title` `icon?` `actions?` `opens?` `solo?` `fillActions?`
|
|
92
92
|
|
|
93
93
|
### Hooks
|
|
94
94
|
- `usePanels<Id>()` → `{ panels, reveal, close, toggle, isShown, focusedZone, reset }`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pasquelin/panels",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Châssis à panneaux React : rails d'icônes, zones redimensionnables, centre libre. Headless + composants par défaut, entièrement surchargeable.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "pnpm@11.16.0",
|