@egen-civitas/esm-styleguide 3.0.0 → 3.1.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 +11 -0
- package/dist/workbench/compartments.d.ts +47 -0
- package/dist/workbench/compartments.d.ts.map +1 -0
- package/dist/workbench/compartments.js +147 -0
- package/dist/workbench/index.d.ts +1 -0
- package/dist/workbench/index.d.ts.map +1 -1
- package/dist/workbench/index.js +1 -0
- package/dist/workbench/splitter.component.d.ts +18 -0
- package/dist/workbench/splitter.component.d.ts.map +1 -1
- package/dist/workbench/splitter.component.js +68 -1
- package/dist/workbench/tool-window-header.component.d.ts +2 -0
- package/dist/workbench/tool-window-header.component.d.ts.map +1 -1
- package/dist/workbench/tool-window-header.component.js +3 -1
- package/dist/workbench/tool-window-rail.component.d.ts.map +1 -1
- package/dist/workbench/tool-window-rail.component.js +7 -5
- package/dist/workbench/tool-window-zone.component.d.ts +11 -4
- package/dist/workbench/tool-window-zone.component.d.ts.map +1 -1
- package/dist/workbench/tool-window-zone.component.js +144 -57
- package/dist/workbench/use-tool-windows.d.ts +7 -1
- package/dist/workbench/use-tool-windows.d.ts.map +1 -1
- package/dist/workbench/use-tool-windows.js +4 -2
- package/dist/workbench/workbench.module.scss +76 -13
- package/dist/workbench/workbench.store.d.ts +37 -4
- package/dist/workbench/workbench.store.d.ts.map +1 -1
- package/dist/workbench/workbench.store.js +124 -10
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @egen-civitas/esm-styleguide
|
|
2
2
|
|
|
3
|
+
## 3.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- fa07dbd: Compartiments verticaux dans les zones gauche et droite. Chaque zone devient une pile de compartiments dont les hauteurs (en % de la zone) totalisent toujours 100 : aucun débordement, contenu défilant en interne, redimensionnement libre entre voisins (les autres s'ajustent selon leurs minimum et maximum). La zone actuelle devient le compartiment par défaut (dimensions fixées par le shell) et porte désormais le fond sombre à la place de la zone. Une app choisit, dans la `meta` de son option de rail, d'afficher dans le compartiment par défaut ou dans un compartiment propre via `meta.compartment` (`{ height, minHeight, maxHeight }` en %, valeurs par défaut `DEFAULT_COMPARTMENT_HEIGHTS`). Nouveaux exports : `getToolWindowCompartment`, `DEFAULT_COMPARTMENT_HEIGHTS`, `ToolWindowCompartment`, `closeToolWindow(anchor, id?)` pour fermer un seul compartiment.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [fa07dbd]
|
|
12
|
+
- @egen-civitas/esm-extensions@2.2.0
|
|
13
|
+
|
|
3
14
|
## 3.0.0
|
|
4
15
|
|
|
5
16
|
### Major Changes
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calcul des hauteurs des compartiments verticaux d'une zone latérale (gauche ou droite).
|
|
3
|
+
*
|
|
4
|
+
* Fonctions pures, sans dépendance au DOM ni au store : la zone empile des compartiments dont les
|
|
5
|
+
* hauteurs, en **% de la zone**, totalisent toujours 100 (aucun débordement). Chaque compartiment a une
|
|
6
|
+
* hauteur de base, un minimum et un maximum.
|
|
7
|
+
*/
|
|
8
|
+
/** Identifiant réservé du compartiment par défaut d'une zone (aucune fenêtre d'outils ne peut le porter). */
|
|
9
|
+
export declare const DEFAULT_COMPARTMENT_ID = "__default__";
|
|
10
|
+
/**
|
|
11
|
+
* Dimensions du compartiment par défaut (en % de la zone). Fixées par le shell : les apps ne peuvent pas les
|
|
12
|
+
* modifier. Maximum à 100 pour qu'il remplisse la zone quand il est seul.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DEFAULT_COMPARTMENT_LIMITS: Readonly<{
|
|
15
|
+
height: number;
|
|
16
|
+
minHeight: number;
|
|
17
|
+
maxHeight: number;
|
|
18
|
+
}>;
|
|
19
|
+
export interface CompartmentItem {
|
|
20
|
+
/** Clé stable du compartiment dans sa zone. */
|
|
21
|
+
key: string;
|
|
22
|
+
/** Hauteur de base (%), utilisée tant que le compartiment n'a pas de hauteur mémorisée. */
|
|
23
|
+
height: number;
|
|
24
|
+
/** Hauteur minimale (%). */
|
|
25
|
+
minHeight: number;
|
|
26
|
+
/** Hauteur maximale (%). */
|
|
27
|
+
maxHeight: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Hauteurs (%) des compartiments ouverts, dans l'ordre : somme exacte de 100, chacune dans ses bornes.
|
|
31
|
+
*
|
|
32
|
+
* `stored` : hauteurs déjà mémorisées. Un compartiment sans valeur mémorisée (nouvellement ouvert) reçoit sa
|
|
33
|
+
* hauteur de base et les autres se partagent le reste proportionnellement à leurs hauteurs.
|
|
34
|
+
*/
|
|
35
|
+
export declare function fitCompartmentHeights(items: readonly CompartmentItem[], stored?: Readonly<Record<string, number | undefined>>): number[];
|
|
36
|
+
/**
|
|
37
|
+
* Déplace la frontière entre le compartiment `index` et le suivant de `delta` points de pourcentage
|
|
38
|
+
* (positif : vers le bas). La somme reste 100 :
|
|
39
|
+
*
|
|
40
|
+
* - le côté qui gagne de la place s'agrandit en commençant par le compartiment contre la frontière,
|
|
41
|
+
* puis le suivant s'il atteint son maximum ;
|
|
42
|
+
* - le côté qui en perd rétrécit de la même façon, jusqu'aux minimums.
|
|
43
|
+
*
|
|
44
|
+
* Le déplacement est borné par ce que les deux côtés peuvent absorber : la frontière s'arrête net.
|
|
45
|
+
*/
|
|
46
|
+
export declare function resizeCompartmentBoundary(heights: readonly number[], items: readonly CompartmentItem[], index: number, delta: number): number[];
|
|
47
|
+
//# sourceMappingURL=compartments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compartments.d.ts","sourceRoot":"","sources":["../../src/workbench/compartments.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,6GAA6G;AAC7G,eAAO,MAAM,sBAAsB,gBAAgB,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAIzG,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,+CAA+C;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,2FAA2F;IAC3F,MAAM,EAAE,MAAM,CAAC;IACf,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB;AAkBD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,SAAS,eAAe,EAAE,EACjC,MAAM,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAM,GACxD,MAAM,EAAE,CAiEV;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,KAAK,EAAE,SAAS,eAAe,EAAE,EACjC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,MAAM,EAAE,CA8BV"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calcul des hauteurs des compartiments verticaux d'une zone latérale (gauche ou droite).
|
|
3
|
+
*
|
|
4
|
+
* Fonctions pures, sans dépendance au DOM ni au store : la zone empile des compartiments dont les
|
|
5
|
+
* hauteurs, en **% de la zone**, totalisent toujours 100 (aucun débordement). Chaque compartiment a une
|
|
6
|
+
* hauteur de base, un minimum et un maximum.
|
|
7
|
+
*/ /** Identifiant réservé du compartiment par défaut d'une zone (aucune fenêtre d'outils ne peut le porter). */ export const DEFAULT_COMPARTMENT_ID = '__default__';
|
|
8
|
+
/**
|
|
9
|
+
* Dimensions du compartiment par défaut (en % de la zone). Fixées par le shell : les apps ne peuvent pas les
|
|
10
|
+
* modifier. Maximum à 100 pour qu'il remplisse la zone quand il est seul.
|
|
11
|
+
*/ export const DEFAULT_COMPARTMENT_LIMITS = {
|
|
12
|
+
height: 60,
|
|
13
|
+
minHeight: 25,
|
|
14
|
+
maxHeight: 100
|
|
15
|
+
};
|
|
16
|
+
const TOTAL = 100;
|
|
17
|
+
const EPSILON = 1e-6;
|
|
18
|
+
/** Arrondit à 0,01 % : assez fin pour un glissement fluide, assez grossier pour ne pas osciller. */ const round = (n)=>Math.round(n * 100) / 100;
|
|
19
|
+
/** Bornes effectives : minimums réduits proportionnellement s'ils dépassent 100, maximums ignorés s'ils n'atteignent pas 100. */ function effectiveLimits(items) {
|
|
20
|
+
const sumMin = items.reduce((total, item)=>total + item.minHeight, 0);
|
|
21
|
+
const sumMax = items.reduce((total, item)=>total + item.maxHeight, 0);
|
|
22
|
+
const minScale = sumMin > TOTAL ? TOTAL / sumMin : 1;
|
|
23
|
+
const mins = items.map((item)=>item.minHeight * minScale);
|
|
24
|
+
const maxs = items.map((item)=>sumMax < TOTAL ? TOTAL : Math.max(item.maxHeight, item.minHeight * minScale));
|
|
25
|
+
return {
|
|
26
|
+
mins,
|
|
27
|
+
maxs
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Hauteurs (%) des compartiments ouverts, dans l'ordre : somme exacte de 100, chacune dans ses bornes.
|
|
32
|
+
*
|
|
33
|
+
* `stored` : hauteurs déjà mémorisées. Un compartiment sans valeur mémorisée (nouvellement ouvert) reçoit sa
|
|
34
|
+
* hauteur de base et les autres se partagent le reste proportionnellement à leurs hauteurs.
|
|
35
|
+
*/ export function fitCompartmentHeights(items, stored = {}) {
|
|
36
|
+
if (items.length === 0) return [];
|
|
37
|
+
if (items.length === 1) return [
|
|
38
|
+
TOTAL
|
|
39
|
+
];
|
|
40
|
+
const { mins, maxs } = effectiveLimits(items);
|
|
41
|
+
const known = items.map((item)=>{
|
|
42
|
+
const value = stored[item.key];
|
|
43
|
+
return typeof value === 'number' && Number.isFinite(value) && value > 0;
|
|
44
|
+
});
|
|
45
|
+
const fresh = items.reduce((total, item, i)=>total + (known[i] ? 0 : item.height), 0);
|
|
46
|
+
const knownSum = items.reduce((total, item, i)=>total + (known[i] ? stored[item.key] : 0), 0);
|
|
47
|
+
const knownTarget = TOTAL - fresh;
|
|
48
|
+
// Valeurs de départ : nouveaux à leur base, les autres ramenés à la place restante (ou tout ramené à 100 sinon).
|
|
49
|
+
let values;
|
|
50
|
+
if (knownSum > 0 && knownTarget > 0) {
|
|
51
|
+
values = items.map((item, i)=>known[i] ? stored[item.key] * knownTarget / knownSum : item.height);
|
|
52
|
+
} else {
|
|
53
|
+
const raw = items.map((item, i)=>known[i] ? stored[item.key] : item.height);
|
|
54
|
+
const sum = raw.reduce((total, v)=>total + v, 0);
|
|
55
|
+
values = raw.map((v)=>v * TOTAL / sum);
|
|
56
|
+
}
|
|
57
|
+
// Écrêtage itératif : on fige les compartiments qui sortent de leurs bornes et on redistribue le reste.
|
|
58
|
+
const fixed = items.map(()=>undefined);
|
|
59
|
+
for(let pass = 0; pass <= items.length; pass += 1){
|
|
60
|
+
const fixedSum = fixed.reduce((total, v)=>total + (v ?? 0), 0);
|
|
61
|
+
const freeIndexes = items.map((_, i)=>i).filter((i)=>fixed[i] === undefined);
|
|
62
|
+
if (freeIndexes.length === 0) break;
|
|
63
|
+
const freeSum = freeIndexes.reduce((total, i)=>total + values[i], 0);
|
|
64
|
+
const scale = freeSum > 0 ? (TOTAL - fixedSum) / freeSum : 0;
|
|
65
|
+
const scaled = new Map(freeIndexes.map((i)=>[
|
|
66
|
+
i,
|
|
67
|
+
freeSum > 0 ? values[i] * scale : (TOTAL - fixedSum) / freeIndexes.length
|
|
68
|
+
]));
|
|
69
|
+
let excess = 0; // > 0 : trop grand une fois écrêté ; < 0 : trop petit
|
|
70
|
+
for (const i of freeIndexes){
|
|
71
|
+
const v = scaled.get(i);
|
|
72
|
+
excess += Math.min(maxs[i], Math.max(mins[i], v)) - v;
|
|
73
|
+
}
|
|
74
|
+
const tooSmall = freeIndexes.filter((i)=>scaled.get(i) < mins[i] - EPSILON);
|
|
75
|
+
const tooBig = freeIndexes.filter((i)=>scaled.get(i) > maxs[i] + EPSILON);
|
|
76
|
+
if (tooSmall.length === 0 && tooBig.length === 0) {
|
|
77
|
+
for (const i of freeIndexes)fixed[i] = scaled.get(i);
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
// Excès positif (on a relevé des minimums) : on fige les minimums ; négatif : les maximums ; nul : les deux.
|
|
81
|
+
const toFix = excess > EPSILON ? tooSmall : excess < -EPSILON ? tooBig : [
|
|
82
|
+
...tooSmall,
|
|
83
|
+
...tooBig
|
|
84
|
+
];
|
|
85
|
+
for (const i of toFix.length > 0 ? toFix : [
|
|
86
|
+
...tooSmall,
|
|
87
|
+
...tooBig
|
|
88
|
+
]){
|
|
89
|
+
fixed[i] = Math.min(maxs[i], Math.max(mins[i], scaled.get(i)));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const result = items.map((_, i)=>fixed[i] ?? values[i]);
|
|
93
|
+
// Somme exacte : l'arrondi est absorbé par le plus grand compartiment.
|
|
94
|
+
const rounded = result.map(round);
|
|
95
|
+
const drift = round(TOTAL - rounded.reduce((total, v)=>total + v, 0));
|
|
96
|
+
if (drift !== 0) {
|
|
97
|
+
let largest = 0;
|
|
98
|
+
rounded.forEach((v, i)=>{
|
|
99
|
+
if (v > rounded[largest]) largest = i;
|
|
100
|
+
});
|
|
101
|
+
rounded[largest] = round(rounded[largest] + drift);
|
|
102
|
+
}
|
|
103
|
+
return rounded;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Déplace la frontière entre le compartiment `index` et le suivant de `delta` points de pourcentage
|
|
107
|
+
* (positif : vers le bas). La somme reste 100 :
|
|
108
|
+
*
|
|
109
|
+
* - le côté qui gagne de la place s'agrandit en commençant par le compartiment contre la frontière,
|
|
110
|
+
* puis le suivant s'il atteint son maximum ;
|
|
111
|
+
* - le côté qui en perd rétrécit de la même façon, jusqu'aux minimums.
|
|
112
|
+
*
|
|
113
|
+
* Le déplacement est borné par ce que les deux côtés peuvent absorber : la frontière s'arrête net.
|
|
114
|
+
*/ export function resizeCompartmentBoundary(heights, items, index, delta) {
|
|
115
|
+
const next = [
|
|
116
|
+
...heights
|
|
117
|
+
];
|
|
118
|
+
if (index < 0 || index >= heights.length - 1 || !Number.isFinite(delta) || delta === 0) return next;
|
|
119
|
+
const { mins, maxs } = effectiveLimits(items);
|
|
120
|
+
const above = Array.from({
|
|
121
|
+
length: index + 1
|
|
122
|
+
}, (_, k)=>index - k); // du plus proche de la frontière au plus loin
|
|
123
|
+
const below = Array.from({
|
|
124
|
+
length: heights.length - index - 1
|
|
125
|
+
}, (_, k)=>index + 1 + k);
|
|
126
|
+
const growing = delta > 0 ? above : below;
|
|
127
|
+
const shrinking = delta > 0 ? below : above;
|
|
128
|
+
const growCapacity = growing.reduce((total, i)=>total + Math.max(0, maxs[i] - next[i]), 0);
|
|
129
|
+
const shrinkCapacity = shrinking.reduce((total, i)=>total + Math.max(0, next[i] - mins[i]), 0);
|
|
130
|
+
const amount = Math.min(Math.abs(delta), growCapacity, shrinkCapacity);
|
|
131
|
+
if (amount <= 0) return next;
|
|
132
|
+
let toGrow = amount;
|
|
133
|
+
for (const i of growing){
|
|
134
|
+
const step = Math.min(toGrow, Math.max(0, maxs[i] - next[i]));
|
|
135
|
+
next[i] += step;
|
|
136
|
+
toGrow -= step;
|
|
137
|
+
if (toGrow <= EPSILON) break;
|
|
138
|
+
}
|
|
139
|
+
let toShrink = amount;
|
|
140
|
+
for (const i of shrinking){
|
|
141
|
+
const step = Math.min(toShrink, Math.max(0, next[i] - mins[i]));
|
|
142
|
+
next[i] -= step;
|
|
143
|
+
toShrink -= step;
|
|
144
|
+
if (toShrink <= EPSILON) break;
|
|
145
|
+
}
|
|
146
|
+
return next.map(round);
|
|
147
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/workbench/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kCAAkC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/workbench/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kCAAkC,CAAC;AACjD,cAAc,mBAAmB,CAAC"}
|
package/dist/workbench/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ToolWindowAnchor } from '@egen-civitas/esm-extensions';
|
|
3
|
+
import { type CompartmentItem } from './compartments.js';
|
|
4
|
+
import { type SideAnchor } from './workbench.store.js';
|
|
3
5
|
interface SplitterProps {
|
|
4
6
|
anchor: ToolWindowAnchor;
|
|
5
7
|
/** Libellé accessible de la poignée. */
|
|
@@ -27,5 +29,21 @@ interface CornerSplitterProps {
|
|
|
27
29
|
* disponibles (souris et clavier) ; l'angle est donc un raccourci pointeur, masqué aux lecteurs d'écran.
|
|
28
30
|
*/
|
|
29
31
|
export declare function CornerSplitter({ side, label }: CornerSplitterProps): React.JSX.Element;
|
|
32
|
+
interface CompartmentSplitterProps {
|
|
33
|
+
anchor: SideAnchor;
|
|
34
|
+
/** Rang de la frontière : celle qui sépare le compartiment `index` du suivant. */
|
|
35
|
+
index: number;
|
|
36
|
+
/** Compartiments affichés dans la zone, dans l'ordre. */
|
|
37
|
+
items: readonly CompartmentItem[];
|
|
38
|
+
/** Hauteurs courantes (%) des compartiments. */
|
|
39
|
+
heights: readonly number[];
|
|
40
|
+
label: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Poignée entre deux compartiments empilés d'une zone latérale : glisser (souris/doigt) ou flèches haut/bas
|
|
44
|
+
* déplacent la frontière ; les autres compartiments s'ajustent selon leurs minimum et maximum, la somme restant
|
|
45
|
+
* à 100 % de la zone. Double-clic : hauteurs de base. Elle occupe l'écart entre les deux cartes.
|
|
46
|
+
*/
|
|
47
|
+
export declare function CompartmentSplitter({ anchor, index, items, heights, label }: CompartmentSplitterProps): React.JSX.Element;
|
|
30
48
|
export {};
|
|
31
49
|
//# sourceMappingURL=splitter.component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"splitter.component.d.ts","sourceRoot":"","sources":["../../src/workbench/splitter.component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiB,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"splitter.component.d.ts","sourceRoot":"","sources":["../../src/workbench/splitter.component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiB,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAErE,OAAO,EAAoD,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC3G,OAAO,EAML,KAAK,UAAU,EAChB,MAAM,sBAAsB,CAAC;AAM9B,UAAU,aAAa;IACrB,MAAM,EAAE,gBAAgB,CAAC;IACzB,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,aAAa,qBAwExD;AAED,KAAK,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;AAEnC,UAAU,mBAAmB;IAC3B,qEAAqE;IACrE,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,mBAAmB,qBA+ClE;AAOD,UAAU,wBAAwB;IAChC,MAAM,EAAE,UAAU,CAAC;IACnB,kFAAkF;IAClF,KAAK,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,KAAK,EAAE,SAAS,eAAe,EAAE,CAAC;IAClC,gDAAgD;IAChD,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,wBAAwB,qBAyDrG"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import React, { useRef } from "react";
|
|
3
3
|
import { useStore } from "@egen-civitas/esm-react-utils";
|
|
4
|
-
import {
|
|
4
|
+
import { fitCompartmentHeights, resizeCompartmentBoundary } from "./compartments.js";
|
|
5
|
+
import { clampZoneSize, resetZoneSize, setCompartmentHeights, setZoneSize, workbenchStore } from "./workbench.store.js";
|
|
5
6
|
import styles from "./workbench.module.scss";
|
|
6
7
|
const KEYBOARD_STEP = 16;
|
|
7
8
|
const RESIZING_ATTRIBUTE = 'data-workbench-resizing';
|
|
@@ -131,3 +132,69 @@ const RESIZING_ATTRIBUTE = 'data-workbench-resizing';
|
|
|
131
132
|
onDoubleClick: reset
|
|
132
133
|
});
|
|
133
134
|
}
|
|
135
|
+
const COMPARTMENT_KEYBOARD_STEP = 5; // points de pourcentage
|
|
136
|
+
const toRecord = (items, heights)=>Object.fromEntries(items.map((item, i)=>[
|
|
137
|
+
item.key,
|
|
138
|
+
heights[i]
|
|
139
|
+
]));
|
|
140
|
+
/**
|
|
141
|
+
* Poignée entre deux compartiments empilés d'une zone latérale : glisser (souris/doigt) ou flèches haut/bas
|
|
142
|
+
* déplacent la frontière ; les autres compartiments s'ajustent selon leurs minimum et maximum, la somme restant
|
|
143
|
+
* à 100 % de la zone. Double-clic : hauteurs de base. Elle occupe l'écart entre les deux cartes.
|
|
144
|
+
*/ export function CompartmentSplitter({ anchor, index, items, heights, label }) {
|
|
145
|
+
const start = useRef(null);
|
|
146
|
+
const onPointerDown = (event)=>{
|
|
147
|
+
if (event.button !== 0) return;
|
|
148
|
+
const zone = event.currentTarget.parentElement;
|
|
149
|
+
if (!zone) return;
|
|
150
|
+
// Hauteur répartie entre les compartiments = hauteur de la zone moins les écarts (poignées).
|
|
151
|
+
const gap = event.currentTarget.getBoundingClientRect().height;
|
|
152
|
+
const available = zone.getBoundingClientRect().height - gap * (items.length - 1);
|
|
153
|
+
if (!(available > 0)) return;
|
|
154
|
+
start.current = {
|
|
155
|
+
y: event.clientY,
|
|
156
|
+
heights: [
|
|
157
|
+
...heights
|
|
158
|
+
],
|
|
159
|
+
perPixel: 100 / available
|
|
160
|
+
};
|
|
161
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
162
|
+
document.documentElement.setAttribute(RESIZING_ATTRIBUTE, `compartment-${anchor}`);
|
|
163
|
+
event.preventDefault();
|
|
164
|
+
};
|
|
165
|
+
const onPointerMove = (event)=>{
|
|
166
|
+
const origin = start.current;
|
|
167
|
+
if (!origin) return;
|
|
168
|
+
const delta = (event.clientY - origin.y) * origin.perPixel;
|
|
169
|
+
setCompartmentHeights(toRecord(items, resizeCompartmentBoundary(origin.heights, items, index, delta)));
|
|
170
|
+
};
|
|
171
|
+
const stopDragging = (event)=>{
|
|
172
|
+
if (!start.current) return;
|
|
173
|
+
start.current = null;
|
|
174
|
+
event.currentTarget.releasePointerCapture?.(event.pointerId);
|
|
175
|
+
document.documentElement.removeAttribute(RESIZING_ATTRIBUTE);
|
|
176
|
+
};
|
|
177
|
+
const onKeyDown = (event)=>{
|
|
178
|
+
if (event.key !== 'ArrowUp' && event.key !== 'ArrowDown') return;
|
|
179
|
+
const delta = event.key === 'ArrowDown' ? COMPARTMENT_KEYBOARD_STEP : -COMPARTMENT_KEYBOARD_STEP;
|
|
180
|
+
setCompartmentHeights(toRecord(items, resizeCompartmentBoundary(heights, items, index, delta)));
|
|
181
|
+
event.preventDefault();
|
|
182
|
+
};
|
|
183
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
184
|
+
role: "separator",
|
|
185
|
+
tabIndex: 0,
|
|
186
|
+
"aria-label": label,
|
|
187
|
+
"aria-orientation": "horizontal",
|
|
188
|
+
"aria-valuenow": Math.round(heights[index]),
|
|
189
|
+
"aria-valuemin": 0,
|
|
190
|
+
"aria-valuemax": 100,
|
|
191
|
+
"data-compartment-splitter": index,
|
|
192
|
+
className: styles.compartmentSplitter,
|
|
193
|
+
onPointerDown: onPointerDown,
|
|
194
|
+
onPointerMove: onPointerMove,
|
|
195
|
+
onPointerUp: stopDragging,
|
|
196
|
+
onPointerCancel: stopDragging,
|
|
197
|
+
onDoubleClick: ()=>setCompartmentHeights(toRecord(items, fitCompartmentHeights(items, {}))),
|
|
198
|
+
onKeyDown: onKeyDown
|
|
199
|
+
});
|
|
200
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import React, { type ReactNode } from 'react';
|
|
2
|
+
/** Attribut posé sur le conteneur (compartiment) qui affiche une fenêtre d'outils ; son en-tête s'y trouve. */
|
|
3
|
+
export declare const TOOL_WINDOW_CONTAINER_ATTRIBUTE = "data-tool-window-container";
|
|
2
4
|
/** Attribut de l'emplacement d'en-tête d'une zone (entre le titre et le bouton de fermeture). */
|
|
3
5
|
export declare const TOOL_WINDOW_HEADER_ATTRIBUTE = "data-tool-window-header";
|
|
4
6
|
export interface ToolWindowHeaderProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-window-header.component.d.ts","sourceRoot":"","sources":["../../src/workbench/tool-window-header.component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAqC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGjF,iGAAiG;AACjG,eAAO,MAAM,4BAA4B,4BAA4B,CAAC;AAEtE,MAAM,WAAW,qBAAqB;IACpC,kFAAkF;IAClF,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"tool-window-header.component.d.ts","sourceRoot":"","sources":["../../src/workbench/tool-window-header.component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAqC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGjF,+GAA+G;AAC/G,eAAO,MAAM,+BAA+B,+BAA+B,CAAC;AAE5E,iGAAiG;AACjG,eAAO,MAAM,4BAA4B,4BAA4B,CAAC;AAEtE,MAAM,WAAW,qBAAqB;IACpC,kFAAkF;IAClF,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,EAAE,qBAAqB,qBAiBnE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import React, { useLayoutEffect, useRef, useState } from "react";
|
|
3
3
|
import { createPortal } from "react-dom";
|
|
4
|
+
/** Attribut posé sur le conteneur (compartiment) qui affiche une fenêtre d'outils ; son en-tête s'y trouve. */ export const TOOL_WINDOW_CONTAINER_ATTRIBUTE = 'data-tool-window-container';
|
|
4
5
|
/** Attribut de l'emplacement d'en-tête d'une zone (entre le titre et le bouton de fermeture). */ export const TOOL_WINDOW_HEADER_ATTRIBUTE = 'data-tool-window-header';
|
|
5
6
|
/**
|
|
6
7
|
* Place `children` dans l'en-tête de la zone qui affiche la fenêtre d'outils, à droite du titre et à
|
|
@@ -14,7 +15,8 @@ import { createPortal } from "react-dom";
|
|
|
14
15
|
// undefined : pas encore résolu · null : hors zone (rendu sur place) · élément : emplacement de la zone.
|
|
15
16
|
const [slot, setSlot] = useState(undefined);
|
|
16
17
|
useLayoutEffect(()=>{
|
|
17
|
-
|
|
18
|
+
// Compartiment de la fenêtre (une zone latérale peut en empiler plusieurs) ; à défaut, la zone elle-même.
|
|
19
|
+
const zone = markerRef.current?.closest(`[${TOOL_WINDOW_CONTAINER_ATTRIBUTE}], aside[data-anchor]`);
|
|
18
20
|
setSlot(zone?.querySelector(`[${TOOL_WINDOW_HEADER_ATTRIBUTE}]`) ?? null);
|
|
19
21
|
}, []);
|
|
20
22
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-window-rail.component.d.ts","sourceRoot":"","sources":["../../src/workbench/tool-window-rail.component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-window-rail.component.d.ts","sourceRoot":"","sources":["../../src/workbench/tool-window-rail.component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAmFlD;;;GAGG;AACH,wBAAgB,QAAQ,sBAQvB;AAED,6GAA6G;AAC7G,wBAAgB,SAAS,sBAQxB"}
|
|
@@ -4,14 +4,15 @@ import { isSafeToolWindowIconUrl } from "@egen-civitas/esm-extensions";
|
|
|
4
4
|
import { useStore } from "@egen-civitas/esm-react-utils";
|
|
5
5
|
import { resolveWorkbenchIcon } from "./workbench-icons.js";
|
|
6
6
|
import { toolWindowTitle, useToolWindows } from "./use-tool-windows.js";
|
|
7
|
-
import { toggleToolWindow, workbenchStore } from "./workbench.store.js";
|
|
7
|
+
import { getOpenCompartments, toggleCompartment, toggleToolWindow, workbenchStore } from "./workbench.store.js";
|
|
8
8
|
import { formatToolWindowBadge, workbenchBadgeStore } from "./workbench-badges.js";
|
|
9
9
|
import styles from "./workbench.module.scss";
|
|
10
10
|
function RailGroup({ anchor, label, rail }) {
|
|
11
11
|
const tools = useToolWindows(anchor, rail);
|
|
12
12
|
// NB : `useStore` retourne toujours un objet (état étalé) : on lit l'état entier, jamais une valeur primitive.
|
|
13
|
-
const
|
|
14
|
-
const activeId = active[anchor];
|
|
13
|
+
const state = useStore(workbenchStore);
|
|
14
|
+
const activeId = state.active[anchor];
|
|
15
|
+
const openOwn = getOpenCompartments(anchor, state);
|
|
15
16
|
if (tools.length === 0) return null;
|
|
16
17
|
return /*#__PURE__*/ _jsx("div", {
|
|
17
18
|
role: "group",
|
|
@@ -20,8 +21,9 @@ function RailGroup({ anchor, label, rail }) {
|
|
|
20
21
|
className: `${styles.railGroup} egen-anim-stagger egen-anim-stagger--fade`,
|
|
21
22
|
children: tools.map((tool)=>/*#__PURE__*/ _jsx(RailButton, {
|
|
22
23
|
tool: tool,
|
|
23
|
-
active: tool.id === activeId,
|
|
24
|
-
onClick: ()
|
|
24
|
+
active: tool.compartment ? openOwn.includes(tool.id) : tool.id === activeId,
|
|
25
|
+
onClick: ()=>// Compartiment propre : s'ouvre/se ferme sans toucher au compartiment par défaut de la zone.
|
|
26
|
+
tool.compartment ? toggleCompartment(anchor, tool.id) : toggleToolWindow(anchor, tool.id)
|
|
25
27
|
}, tool.id))
|
|
26
28
|
});
|
|
27
29
|
}
|
|
@@ -4,10 +4,17 @@ interface ToolWindowZoneProps {
|
|
|
4
4
|
anchor: ToolWindowAnchor;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
|
-
* Zone redimensionnable (gauche, droite ou bas) :
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Zone redimensionnable (gauche, droite ou bas) : empile les compartiments qui affichent les fenêtres d'outils
|
|
8
|
+
* des rails, chacun sous son en-tête (titre + fermeture).
|
|
9
|
+
*
|
|
10
|
+
* - Le **compartiment par défaut** affiche la fenêtre d'outils active du rail (une seule à la fois).
|
|
11
|
+
* - Les fenêtres dont `meta.compartment` est un objet ont chacune **leur compartiment propre**, ouvert à côté
|
|
12
|
+
* du compartiment par défaut (zones gauche et droite uniquement).
|
|
13
|
+
*
|
|
14
|
+
* Les hauteurs des compartiments totalisent toujours 100 % de la zone (aucun débordement) ; chacun défile en
|
|
15
|
+
* interne et se redimensionne face à ses voisins. La zone elle-même est transparente : le fond sombre est
|
|
16
|
+
* porté par les compartiments. Repliée (taille 0) tant qu'aucune fenêtre d'outils valide n'est ouverte : une
|
|
17
|
+
* fenêtre dont l'app n'est plus montée replie donc la zone toute seule.
|
|
11
18
|
*/
|
|
12
19
|
export declare function ToolWindowZone({ anchor }: ToolWindowZoneProps): React.JSX.Element;
|
|
13
20
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-window-zone.component.d.ts","sourceRoot":"","sources":["../../src/workbench/tool-window-zone.component.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"tool-window-zone.component.d.ts","sourceRoot":"","sources":["../../src/workbench/tool-window-zone.component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkG,MAAM,OAAO,CAAC;AACvH,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAqDxF,UAAU,mBAAmB;IAC3B,MAAM,EAAE,gBAAgB,CAAC;CAC1B;AAQD;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,EAAE,mBAAmB,qBA2H7D"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
2
|
+
import React, { Fragment, useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
3
3
|
import { TOOL_WINDOW_SLOTS } from "@egen-civitas/esm-extensions";
|
|
4
4
|
import { ComponentContext, ExtensionSlot, useStore } from "@egen-civitas/esm-react-utils";
|
|
5
5
|
import { X } from "lucide-react";
|
|
6
|
-
import { CornerSplitter, Splitter } from "./splitter.component.js";
|
|
7
|
-
import { TOOL_WINDOW_HEADER_ATTRIBUTE } from "./tool-window-header.component.js";
|
|
6
|
+
import { CompartmentSplitter, CornerSplitter, Splitter } from "./splitter.component.js";
|
|
7
|
+
import { TOOL_WINDOW_CONTAINER_ATTRIBUTE, TOOL_WINDOW_HEADER_ATTRIBUTE } from "./tool-window-header.component.js";
|
|
8
8
|
import { toolWindowTitle, useToolWindows } from "./use-tool-windows.js";
|
|
9
|
-
import {
|
|
9
|
+
import { DEFAULT_COMPARTMENT_ID, DEFAULT_COMPARTMENT_LIMITS, fitCompartmentHeights } from "./compartments.js";
|
|
10
|
+
import { closeToolWindow, compartmentKey, getOpenCompartments, setCompartmentHeights, workbenchStore } from "./workbench.store.js";
|
|
10
11
|
import styles from "./workbench.module.scss";
|
|
11
12
|
/**
|
|
12
13
|
* Contexte de composant des zones. Le shell monte chaque zone dans un `createRoot` autonome, hors de tout
|
|
@@ -33,27 +34,59 @@ const EXIT_CLASS = {
|
|
|
33
34
|
bottom: 'egen-anim-slide-out-to-bottom'
|
|
34
35
|
};
|
|
35
36
|
/**
|
|
36
|
-
* Zone redimensionnable (gauche, droite ou bas) :
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
37
|
+
* Zone redimensionnable (gauche, droite ou bas) : empile les compartiments qui affichent les fenêtres d'outils
|
|
38
|
+
* des rails, chacun sous son en-tête (titre + fermeture).
|
|
39
|
+
*
|
|
40
|
+
* - Le **compartiment par défaut** affiche la fenêtre d'outils active du rail (une seule à la fois).
|
|
41
|
+
* - Les fenêtres dont `meta.compartment` est un objet ont chacune **leur compartiment propre**, ouvert à côté
|
|
42
|
+
* du compartiment par défaut (zones gauche et droite uniquement).
|
|
43
|
+
*
|
|
44
|
+
* Les hauteurs des compartiments totalisent toujours 100 % de la zone (aucun débordement) ; chacun défile en
|
|
45
|
+
* interne et se redimensionne face à ses voisins. La zone elle-même est transparente : le fond sombre est
|
|
46
|
+
* porté par les compartiments. Repliée (taille 0) tant qu'aucune fenêtre d'outils valide n'est ouverte : une
|
|
47
|
+
* fenêtre dont l'app n'est plus montée replie donc la zone toute seule.
|
|
40
48
|
*/ export function ToolWindowZone({ anchor }) {
|
|
41
49
|
const tools = useToolWindows(anchor);
|
|
42
50
|
// NB : `useStore` retourne toujours un objet (état étalé) : on lit l'état entier, jamais une valeur primitive.
|
|
43
|
-
const
|
|
51
|
+
const state = useStore(workbenchStore);
|
|
52
|
+
const { active, sizes } = state;
|
|
44
53
|
const activeId = active[anchor];
|
|
45
54
|
const size = sizes[anchor];
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
55
|
+
const side = anchor === 'bottom' ? null : anchor;
|
|
56
|
+
// Compartiments à afficher : le défaut (fenêtre active du rail) puis les propres, dans l'ordre d'ouverture.
|
|
57
|
+
const compartments = [];
|
|
58
|
+
const currentDefault = tools.find((tool)=>!tool.compartment && tool.id === activeId);
|
|
59
|
+
if (currentDefault) {
|
|
60
|
+
compartments.push({
|
|
61
|
+
tool: currentDefault,
|
|
62
|
+
item: {
|
|
63
|
+
key: compartmentKey(side ?? 'left'),
|
|
64
|
+
...DEFAULT_COMPARTMENT_LIMITS
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
if (side) {
|
|
69
|
+
for (const id of getOpenCompartments(side, state)){
|
|
70
|
+
const tool = tools.find((candidate)=>candidate.id === id && candidate.compartment);
|
|
71
|
+
if (tool?.compartment) compartments.push({
|
|
72
|
+
tool,
|
|
73
|
+
item: {
|
|
74
|
+
key: compartmentKey(side, id),
|
|
75
|
+
...tool.compartment
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const targetOpen = compartments.length > 0;
|
|
81
|
+
// La zone reste montée le temps de l'animation de fermeture : on garde les derniers compartiments affichés.
|
|
82
|
+
const lastRef = useRef([]);
|
|
50
83
|
const wasOpenRef = useRef(false);
|
|
51
84
|
const [phase, setPhase] = useState('open');
|
|
52
|
-
if (
|
|
53
|
-
lastRef.current =
|
|
85
|
+
if (targetOpen) {
|
|
86
|
+
lastRef.current = compartments;
|
|
54
87
|
}
|
|
55
|
-
const displayed =
|
|
56
|
-
const open =
|
|
88
|
+
const displayed = targetOpen ? compartments : phase === 'closing' ? lastRef.current : [];
|
|
89
|
+
const open = displayed.length > 0;
|
|
57
90
|
useLayoutEffect(()=>{
|
|
58
91
|
if (targetOpen === wasOpenRef.current) {
|
|
59
92
|
return;
|
|
@@ -62,7 +95,7 @@ const EXIT_CLASS = {
|
|
|
62
95
|
setPhase(targetOpen ? 'opening' : 'closing');
|
|
63
96
|
const timer = window.setTimeout(()=>{
|
|
64
97
|
if (!targetOpen) {
|
|
65
|
-
lastRef.current =
|
|
98
|
+
lastRef.current = [];
|
|
66
99
|
}
|
|
67
100
|
setPhase('open');
|
|
68
101
|
}, MOTION_MS);
|
|
@@ -83,18 +116,30 @@ const EXIT_CLASS = {
|
|
|
83
116
|
}, [
|
|
84
117
|
anchor
|
|
85
118
|
]);
|
|
86
|
-
//
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
|
|
119
|
+
// Hauteurs (%) des compartiments : somme de 100, bornes respectées ; mémorisées dès qu'il y en a plusieurs.
|
|
120
|
+
const items = displayed.map(({ item })=>item);
|
|
121
|
+
const heights = fitCompartmentHeights(items, state.heights ?? {});
|
|
122
|
+
const heightsSignature = items.map((item, i)=>`${item.key}=${heights[i]}`).join('|');
|
|
123
|
+
useEffect(()=>{
|
|
124
|
+
if (!targetOpen || items.length < 2) return;
|
|
125
|
+
setCompartmentHeights(Object.fromEntries(items.map((item, i)=>[
|
|
126
|
+
item.key,
|
|
127
|
+
heights[i]
|
|
128
|
+
])));
|
|
129
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- la signature résume `items` et `heights`
|
|
130
|
+
}, [
|
|
131
|
+
targetOpen,
|
|
132
|
+
heightsSignature
|
|
90
133
|
]);
|
|
91
|
-
const title = displayed ? toolWindowTitle(displayed) : '';
|
|
134
|
+
const title = displayed[0] ? toolWindowTitle(displayed[0].tool) : '';
|
|
92
135
|
const motionClass = phase === 'closing' ? EXIT_CLASS[anchor] : phase === 'opening' ? ENTER_CLASS[anchor] : '';
|
|
136
|
+
const settled = phase !== 'closing';
|
|
93
137
|
return /*#__PURE__*/ _jsx("aside", {
|
|
94
138
|
"data-testid": `workbench-zone-${anchor}`,
|
|
95
139
|
"data-anchor": anchor,
|
|
96
140
|
"data-open": targetOpen,
|
|
97
141
|
"data-phase": phase,
|
|
142
|
+
"data-compartments": displayed.length,
|
|
98
143
|
"aria-label": title || undefined,
|
|
99
144
|
hidden: !open,
|
|
100
145
|
style: {
|
|
@@ -103,41 +148,28 @@ const EXIT_CLASS = {
|
|
|
103
148
|
className: `${styles.zone} ${styles[`zone-${anchor}`]} ${motionClass}`,
|
|
104
149
|
children: open && /*#__PURE__*/ _jsxs(_Fragment, {
|
|
105
150
|
children: [
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
"aria-hidden": "true"
|
|
151
|
+
displayed.map(({ tool, item }, index)=>/*#__PURE__*/ _jsxs(Fragment, {
|
|
152
|
+
children: [
|
|
153
|
+
index > 0 && settled && side && /*#__PURE__*/ _jsx(CompartmentSplitter, {
|
|
154
|
+
anchor: side,
|
|
155
|
+
index: index - 1,
|
|
156
|
+
items: items,
|
|
157
|
+
heights: heights,
|
|
158
|
+
label: `Redimensionner ${toolWindowTitle(displayed[index - 1].tool)} et ${toolWindowTitle(tool)}`
|
|
159
|
+
}),
|
|
160
|
+
index > 0 && !(settled && side) && /*#__PURE__*/ _jsx("span", {
|
|
161
|
+
"aria-hidden": "true",
|
|
162
|
+
className: styles.compartmentGap
|
|
163
|
+
}),
|
|
164
|
+
/*#__PURE__*/ _jsx(Compartment, {
|
|
165
|
+
anchor: anchor,
|
|
166
|
+
tool: tool,
|
|
167
|
+
height: heights[index],
|
|
168
|
+
own: item.key !== compartmentKey(side ?? 'left'),
|
|
169
|
+
single: displayed.length === 1
|
|
126
170
|
})
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}),
|
|
130
|
-
/*#__PURE__*/ _jsx("div", {
|
|
131
|
-
className: `${styles.zoneBody} egen-anim-fade-in`,
|
|
132
|
-
children: /*#__PURE__*/ _jsx(ComponentContext.Provider, {
|
|
133
|
-
value: ZONE_CONTEXT,
|
|
134
|
-
children: /*#__PURE__*/ _jsx(ExtensionSlot, {
|
|
135
|
-
name: TOOL_WINDOW_SLOTS[anchor],
|
|
136
|
-
select: selectActive,
|
|
137
|
-
className: styles.zoneSlot
|
|
138
|
-
})
|
|
139
|
-
})
|
|
140
|
-
}, displayedId),
|
|
171
|
+
]
|
|
172
|
+
}, item.key)),
|
|
141
173
|
phase !== 'closing' && /*#__PURE__*/ _jsx(Splitter, {
|
|
142
174
|
anchor: anchor,
|
|
143
175
|
label: `Redimensionner ${title}`
|
|
@@ -154,3 +186,58 @@ const EXIT_CLASS = {
|
|
|
154
186
|
})
|
|
155
187
|
});
|
|
156
188
|
}
|
|
189
|
+
/** Un compartiment : carte sombre arrondie, en-tête (titre, actions, fermeture) et corps qui défile. */ function Compartment({ anchor, tool, height, own, single }) {
|
|
190
|
+
const title = toolWindowTitle(tool);
|
|
191
|
+
const selectTool = useCallback((extensions)=>extensions.filter((extension)=>extension.name === tool.id), [
|
|
192
|
+
tool.id
|
|
193
|
+
]);
|
|
194
|
+
return /*#__PURE__*/ _jsxs("section", {
|
|
195
|
+
"data-testid": `workbench-compartment-${anchor}-${own ? tool.id : DEFAULT_COMPARTMENT_ID}`,
|
|
196
|
+
"data-compartment": own ? 'own' : 'default',
|
|
197
|
+
"data-height": Math.round(height * 100) / 100,
|
|
198
|
+
[TOOL_WINDOW_CONTAINER_ATTRIBUTE]: '',
|
|
199
|
+
// Hauteur proportionnelle (flex-grow = pourcentage, base nulle) : la somme remplit exactement la zone,
|
|
200
|
+
// écarts entre compartiments compris, sans calcul en pixels.
|
|
201
|
+
style: single ? undefined : {
|
|
202
|
+
flex: `${height} 1 0%`
|
|
203
|
+
},
|
|
204
|
+
className: styles.compartment,
|
|
205
|
+
children: [
|
|
206
|
+
/*#__PURE__*/ _jsxs("header", {
|
|
207
|
+
className: styles.zoneHeader,
|
|
208
|
+
children: [
|
|
209
|
+
/*#__PURE__*/ _jsx("h2", {
|
|
210
|
+
className: styles.zoneTitle,
|
|
211
|
+
children: title
|
|
212
|
+
}),
|
|
213
|
+
/*#__PURE__*/ _jsx("div", {
|
|
214
|
+
className: styles.zoneHeaderTools,
|
|
215
|
+
[TOOL_WINDOW_HEADER_ATTRIBUTE]: ''
|
|
216
|
+
}),
|
|
217
|
+
/*#__PURE__*/ _jsx("button", {
|
|
218
|
+
type: "button",
|
|
219
|
+
className: styles.zoneClose,
|
|
220
|
+
"aria-label": `Fermer ${title}`,
|
|
221
|
+
title: `Fermer ${title}`,
|
|
222
|
+
onClick: ()=>closeToolWindow(anchor, tool.id),
|
|
223
|
+
children: /*#__PURE__*/ _jsx(X, {
|
|
224
|
+
size: 14,
|
|
225
|
+
"aria-hidden": "true"
|
|
226
|
+
})
|
|
227
|
+
})
|
|
228
|
+
]
|
|
229
|
+
}),
|
|
230
|
+
/*#__PURE__*/ _jsx("div", {
|
|
231
|
+
className: `${styles.zoneBody} egen-anim-fade-in`,
|
|
232
|
+
children: /*#__PURE__*/ _jsx(ComponentContext.Provider, {
|
|
233
|
+
value: ZONE_CONTEXT,
|
|
234
|
+
children: /*#__PURE__*/ _jsx(ExtensionSlot, {
|
|
235
|
+
name: TOOL_WINDOW_SLOTS[anchor],
|
|
236
|
+
select: selectTool,
|
|
237
|
+
className: styles.zoneSlot
|
|
238
|
+
})
|
|
239
|
+
})
|
|
240
|
+
}, tool.id)
|
|
241
|
+
]
|
|
242
|
+
});
|
|
243
|
+
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { type ToolWindowAnchor, type ToolWindowMeta } from '@egen-civitas/esm-extensions';
|
|
1
|
+
import { type ResolvedToolWindowCompartment, type ToolWindowAnchor, type ToolWindowMeta } from '@egen-civitas/esm-extensions';
|
|
2
2
|
export interface ToolWindow {
|
|
3
3
|
/** Nom de l'extension : identifiant de la fenêtre d'outils dans sa zone. */
|
|
4
4
|
id: string;
|
|
5
5
|
moduleName: string;
|
|
6
6
|
meta: ToolWindowMeta;
|
|
7
|
+
/**
|
|
8
|
+
* Hauteurs du compartiment propre demandé par la fenêtre (zones gauche et droite), ou `null` : elle
|
|
9
|
+
* s'affiche dans le compartiment par défaut de la zone (toujours le cas dans la zone basse).
|
|
10
|
+
*/
|
|
11
|
+
compartment: ResolvedToolWindowCompartment | null;
|
|
7
12
|
}
|
|
8
13
|
/** Titre affiché (traduit si `titleKey` a une traduction dans le module de l'app). */
|
|
9
14
|
export declare function toolWindowTitle({ moduleName, meta }: ToolWindow): string;
|
|
@@ -12,6 +17,7 @@ export declare function toolWindowTitle({ moduleName, meta }: ToolWindow): strin
|
|
|
12
17
|
*
|
|
13
18
|
* Zones `left` et `bottom` : celles de l'app active (le rail change avec l'app) et celles qui
|
|
14
19
|
* déclarent `meta.global` (toujours présentes).
|
|
20
|
+
* Zones `left` et `right` : une fenêtre dont `meta.compartment` est un objet a son propre compartiment (voir `ToolWindow.compartment`).
|
|
15
21
|
* Zone `right` : globale, toujours toutes les extensions déclarées.
|
|
16
22
|
* Zone `bottom` + `rail` : ne garde que les entrées portées par ce rail (`meta.rail`, défaut `left`).
|
|
17
23
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-tool-windows.d.ts","sourceRoot":"","sources":["../../src/workbench/use-tool-windows.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AAKtC,MAAM,WAAW,UAAU;IACzB,4EAA4E;IAC5E,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"use-tool-windows.d.ts","sourceRoot":"","sources":["../../src/workbench/use-tool-windows.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,6BAA6B,EAElC,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AAKtC,MAAM,WAAW,UAAU;IACzB,4EAA4E;IAC5E,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,cAAc,CAAC;IACrB;;;OAGG;IACH,WAAW,EAAE,6BAA6B,GAAG,IAAI,CAAC;CACnD;AAED,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,UAAU,GAAG,MAAM,CAExE;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,EAAE,CAgC9F"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
-
import { isToolWindowMeta, TOOL_WINDOW_SLOTS } from "@egen-civitas/esm-extensions";
|
|
2
|
+
import { getToolWindowCompartment, isToolWindowMeta, TOOL_WINDOW_SLOTS } from "@egen-civitas/esm-extensions";
|
|
3
3
|
import { useAssignedExtensions } from "@egen-civitas/esm-react-utils";
|
|
4
4
|
import { translateFrom } from "@egen-civitas/esm-translations";
|
|
5
5
|
import { useActiveAppModules } from "./use-active-app-modules.js";
|
|
@@ -11,6 +11,7 @@ import { useActiveAppModules } from "./use-active-app-modules.js";
|
|
|
11
11
|
*
|
|
12
12
|
* Zones `left` et `bottom` : celles de l'app active (le rail change avec l'app) et celles qui
|
|
13
13
|
* déclarent `meta.global` (toujours présentes).
|
|
14
|
+
* Zones `left` et `right` : une fenêtre dont `meta.compartment` est un objet a son propre compartiment (voir `ToolWindow.compartment`).
|
|
14
15
|
* Zone `right` : globale, toujours toutes les extensions déclarées.
|
|
15
16
|
* Zone `bottom` + `rail` : ne garde que les entrées portées par ce rail (`meta.rail`, défaut `left`).
|
|
16
17
|
*/ export function useToolWindows(anchor, rail) {
|
|
@@ -26,7 +27,8 @@ import { useActiveAppModules } from "./use-active-app-modules.js";
|
|
|
26
27
|
}).map(({ extension })=>({
|
|
27
28
|
id: extension.name,
|
|
28
29
|
moduleName: extension.moduleName,
|
|
29
|
-
meta: extension.meta
|
|
30
|
+
meta: extension.meta,
|
|
31
|
+
compartment: anchor === 'bottom' ? null : getToolWindowCompartment(extension.meta)
|
|
30
32
|
})), [
|
|
31
33
|
assigned,
|
|
32
34
|
activeModules,
|
|
@@ -110,9 +110,9 @@ $gap: var(--egen-workbench-gap, 0.375rem);
|
|
|
110
110
|
height: calc(100% - #{$gap});
|
|
111
111
|
min-width: 0;
|
|
112
112
|
min-height: 0;
|
|
113
|
-
|
|
114
|
-
//
|
|
115
|
-
background:
|
|
113
|
+
// La zone est transparente : le fond sombre (même léger assombrissement que la carte centrale, voir
|
|
114
|
+
// _general.scss) est porté par chaque compartiment, qui est une carte à part entière.
|
|
115
|
+
background: transparent;
|
|
116
116
|
color: var(--colors-surface-foreground, #fff);
|
|
117
117
|
|
|
118
118
|
// Distance de glissement des animations d'ouverture/fermeture (classes egen-anim-*).
|
|
@@ -134,10 +134,8 @@ $gap: var(--egen-workbench-gap, 0.375rem);
|
|
|
134
134
|
pointer-events: none;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
&[data-phase='opening'] .
|
|
138
|
-
&[data-phase='
|
|
139
|
-
&[data-phase='closing'] .zoneHeader,
|
|
140
|
-
&[data-phase='closing'] .zoneBody {
|
|
137
|
+
&[data-phase='opening'] .compartment,
|
|
138
|
+
&[data-phase='closing'] .compartment {
|
|
141
139
|
flex-shrink: 0;
|
|
142
140
|
}
|
|
143
141
|
|
|
@@ -145,8 +143,7 @@ $gap: var(--egen-workbench-gap, 0.375rem);
|
|
|
145
143
|
&.zone-left[data-phase='closing'],
|
|
146
144
|
&.zone-right[data-phase='opening'],
|
|
147
145
|
&.zone-right[data-phase='closing'] {
|
|
148
|
-
.
|
|
149
|
-
.zoneBody {
|
|
146
|
+
.compartment {
|
|
150
147
|
min-width: var(--egen-zone-inner-size);
|
|
151
148
|
}
|
|
152
149
|
}
|
|
@@ -157,12 +154,79 @@ $gap: var(--egen-workbench-gap, 0.375rem);
|
|
|
157
154
|
align-items: flex-end;
|
|
158
155
|
}
|
|
159
156
|
|
|
160
|
-
&.zone-bottom[data-phase='opening'] .
|
|
161
|
-
&.zone-bottom[data-phase='closing'] .
|
|
157
|
+
&.zone-bottom[data-phase='opening'] .compartment,
|
|
158
|
+
&.zone-bottom[data-phase='closing'] .compartment {
|
|
162
159
|
min-height: var(--egen-zone-inner-size);
|
|
163
160
|
}
|
|
164
161
|
}
|
|
165
162
|
|
|
163
|
+
// ── Compartiments ───────────────────────────────────────────────────────────
|
|
164
|
+
// Carte sombre arrondie ; plusieurs s'empilent dans une zone latérale. Leurs hauteurs (flex-grow en %,
|
|
165
|
+
// base nulle) totalisent exactement la zone : jamais de débordement, le corps défile en interne.
|
|
166
|
+
.compartment {
|
|
167
|
+
position: relative;
|
|
168
|
+
display: flex;
|
|
169
|
+
flex: 1 1 0%;
|
|
170
|
+
flex-direction: column;
|
|
171
|
+
box-sizing: border-box;
|
|
172
|
+
min-width: 0;
|
|
173
|
+
min-height: 0;
|
|
174
|
+
overflow: hidden;
|
|
175
|
+
border-radius: $radius;
|
|
176
|
+
background: var(--egen-workbench-card-bg, rgb(0 0 0 / 24%));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Écart entre deux compartiments (hors animation) : même largeur que l'écart entre deux zones.
|
|
180
|
+
.compartmentGap {
|
|
181
|
+
flex: 0 0 $gap;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Poignée entre deux compartiments : elle occupe l'écart ; la zone de saisie déborde de 2px de chaque côté.
|
|
185
|
+
.compartmentSplitter {
|
|
186
|
+
position: relative;
|
|
187
|
+
z-index: 2;
|
|
188
|
+
flex: 0 0 $gap;
|
|
189
|
+
cursor: row-resize;
|
|
190
|
+
touch-action: none;
|
|
191
|
+
|
|
192
|
+
&::before {
|
|
193
|
+
content: '';
|
|
194
|
+
position: absolute;
|
|
195
|
+
inset: -2px 0;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
&::after {
|
|
199
|
+
content: '';
|
|
200
|
+
position: absolute;
|
|
201
|
+
top: 50%;
|
|
202
|
+
right: 0;
|
|
203
|
+
left: 0;
|
|
204
|
+
height: 2px;
|
|
205
|
+
border-radius: 999px;
|
|
206
|
+
background: var(--colors-primary-500, #3b82f6);
|
|
207
|
+
opacity: 0;
|
|
208
|
+
transform: translateY(-50%);
|
|
209
|
+
transition: opacity 120ms ease;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
&:hover::after,
|
|
213
|
+
&:focus-visible::after {
|
|
214
|
+
opacity: 0.8;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
&:focus-visible {
|
|
218
|
+
outline: none;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
:global(html[data-workbench-resizing^='compartment-']) .compartmentSplitter::after {
|
|
223
|
+
opacity: 1;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
:global(html[data-workbench-resizing^='compartment-']) {
|
|
227
|
+
cursor: row-resize;
|
|
228
|
+
}
|
|
229
|
+
|
|
166
230
|
.zoneHeader {
|
|
167
231
|
display: flex;
|
|
168
232
|
align-items: center;
|
|
@@ -228,8 +292,7 @@ $gap: var(--egen-workbench-gap, 0.375rem);
|
|
|
228
292
|
flex: 1 1 auto;
|
|
229
293
|
min-height: 0;
|
|
230
294
|
overflow: auto;
|
|
231
|
-
|
|
232
|
-
border-bottom-right-radius: $radius;
|
|
295
|
+
scrollbar-width: thin;
|
|
233
296
|
}
|
|
234
297
|
|
|
235
298
|
.zoneSlot {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ToolWindowAnchor } from '@egen-civitas/esm-extensions';
|
|
2
2
|
/**
|
|
3
3
|
* État global du plan de travail du shell (rails + zones façon IntelliJ).
|
|
4
4
|
*
|
|
@@ -11,12 +11,24 @@ export declare const WORKBENCH_STORAGE_KEY = "egen-workbench-layout";
|
|
|
11
11
|
export declare const ZONE_ANCHORS: readonly ToolWindowAnchor[];
|
|
12
12
|
/** Taille par défaut des zones, en pixels (largeur pour left/right, hauteur pour bottom). */
|
|
13
13
|
export declare const DEFAULT_ZONE_SIZES: Readonly<Record<ToolWindowAnchor, number>>;
|
|
14
|
+
/** Zones latérales : les seules à pouvoir être divisées en compartiments verticaux. */
|
|
15
|
+
export type SideAnchor = 'left' | 'right';
|
|
16
|
+
export declare const SIDE_ANCHORS: readonly SideAnchor[];
|
|
14
17
|
export interface WorkbenchState {
|
|
15
18
|
/** Largeur (left/right) ou hauteur (bottom) de chaque zone, en pixels. */
|
|
16
19
|
sizes: Record<ToolWindowAnchor, number>;
|
|
17
20
|
/** Fenêtre d'outils (nom de l'extension) affichée dans chaque zone ; `null` : zone repliée. */
|
|
18
21
|
active: Record<ToolWindowAnchor, string | null>;
|
|
22
|
+
/**
|
|
23
|
+
* Zones latérales : fenêtres d'outils ouvertes dans un compartiment **propre** (empilées sous le compartiment
|
|
24
|
+
* par défaut, dans l'ordre d'ouverture). Le compartiment par défaut reste porté par `active`.
|
|
25
|
+
*/
|
|
26
|
+
compartments: Record<SideAnchor, string[]>;
|
|
27
|
+
/** Hauteur mémorisée de chaque compartiment, en % de sa zone (clé : voir `compartmentKey`). */
|
|
28
|
+
heights: Record<string, number>;
|
|
19
29
|
}
|
|
30
|
+
/** Clé de mémorisation de la hauteur d'un compartiment ; `id` omis : compartiment par défaut de la zone. */
|
|
31
|
+
export declare function compartmentKey(anchor: SideAnchor, id?: string): string;
|
|
20
32
|
/**
|
|
21
33
|
* Borne une taille de zone : minimum fixe, maximum = plafond fixe ET part de la fenêtre
|
|
22
34
|
* (50 % de la largeur, 70 % de la hauteur), pour que le contenu central reste toujours visible.
|
|
@@ -26,12 +38,33 @@ export declare function clampZoneSize(anchor: ToolWindowAnchor, size: number, vi
|
|
|
26
38
|
height: number;
|
|
27
39
|
}): number;
|
|
28
40
|
export declare const workbenchStore: import("zustand").StoreApi<WorkbenchState>;
|
|
29
|
-
/**
|
|
41
|
+
/** Fenêtres d'outils ouvertes dans un compartiment propre de la zone `anchor` (liste vide pour la zone basse). */
|
|
42
|
+
export declare function getOpenCompartments(anchor: ToolWindowAnchor, state?: Partial<WorkbenchState>): string[];
|
|
43
|
+
/** Vrai si la fenêtre d'outils `id` demande un compartiment propre (`meta.compartment`) dans la zone `anchor`. */
|
|
44
|
+
export declare function hasOwnCompartment(anchor: ToolWindowAnchor, id: string): boolean;
|
|
45
|
+
/** Ouvre la fenêtre `id` dans un compartiment propre de la zone `anchor` (sans effet si déjà ouverte). */
|
|
46
|
+
export declare function openCompartment(anchor: SideAnchor, id: string): void;
|
|
47
|
+
/** Referme le compartiment propre `id` de la zone `anchor` ; les autres se partagent la place libérée. */
|
|
48
|
+
export declare function closeCompartment(anchor: SideAnchor, id: string): void;
|
|
49
|
+
/** Ouvre le compartiment propre `id` de la zone `anchor`, ou le referme s'il est ouvert. */
|
|
50
|
+
export declare function toggleCompartment(anchor: SideAnchor, id: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* Mémorise les hauteurs (en %) des compartiments d'une zone latérale. `heights` est indexé par clé de
|
|
53
|
+
* compartiment (voir `compartmentKey`) ; seules les valeurs réellement modifiées déclenchent une mise à jour.
|
|
54
|
+
*/
|
|
55
|
+
export declare function setCompartmentHeights(heights: Readonly<Record<string, number>>): void;
|
|
56
|
+
/**
|
|
57
|
+
* Ouvre la fenêtre d'outils `id` dans la zone `anchor` ; un second appel sur la même la referme.
|
|
58
|
+
* Selon sa `meta.compartment`, elle occupe le compartiment par défaut de la zone ou un compartiment propre.
|
|
59
|
+
*/
|
|
30
60
|
export declare function toggleToolWindow(anchor: ToolWindowAnchor, id: string): void;
|
|
31
61
|
/** Ouvre la fenêtre d'outils `id` dans la zone `anchor` (sans la refermer si elle est déjà affichée). */
|
|
32
62
|
export declare function openToolWindow(anchor: ToolWindowAnchor, id: string): void;
|
|
33
|
-
/**
|
|
34
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Replie la zone `anchor` (compartiment par défaut et compartiments propres). Avec `id`, ne referme que
|
|
65
|
+
* cette fenêtre d'outils.
|
|
66
|
+
*/
|
|
67
|
+
export declare function closeToolWindow(anchor: ToolWindowAnchor, id?: string): void;
|
|
35
68
|
/** Redimensionne la zone `anchor` (valeur bornée par `clampZoneSize`). */
|
|
36
69
|
export declare function setZoneSize(anchor: ToolWindowAnchor, size: number): void;
|
|
37
70
|
/** Rétablit la taille par défaut de la zone `anchor`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workbench.store.d.ts","sourceRoot":"","sources":["../../src/workbench/workbench.store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"workbench.store.d.ts","sourceRoot":"","sources":["../../src/workbench/workbench.store.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,8BAA8B,CAAC;AAGtC;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAE7D,eAAO,MAAM,YAAY,EAAE,SAAS,gBAAgB,EAAgC,CAAC;AAErF,6FAA6F;AAC7F,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAA0C,CAAC;AAQrH,uFAAuF;AACvF,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;AAE1C,eAAO,MAAM,YAAY,EAAE,SAAS,UAAU,EAAsB,CAAC;AAErE,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IACxC,+FAA+F;IAC/F,MAAM,EAAE,MAAM,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IAChD;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;IAC3C,+FAA+F;IAC/F,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,4GAA4G;AAC5G,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,GAAE,MAA+B,GAAG,MAAM,CAE9F;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAA6D,GACrG,MAAM,CAMR;AAwCD,eAAO,MAAM,cAAc,4CAAiE,CAAC;AAY7F,kHAAkH;AAClH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,gBAAgB,EACxB,KAAK,GAAE,OAAO,CAAC,cAAc,CAA6B,YAG3D;AAED,kHAAkH;AAClH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAS/E;AAED,0GAA0G;AAC1G,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,QAQ7D;AAED,0GAA0G;AAC1G,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,QAQ9D;AAED,4FAA4F;AAC5F,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,QAG/D;AAMD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,QAI9E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,EAAE,EAAE,EAAE,MAAM,QAIpE;AAED,yGAAyG;AACzG,wBAAgB,cAAc,CAAC,MAAM,EAAE,gBAAgB,EAAE,EAAE,EAAE,MAAM,QAIlE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,gBAAgB,EAAE,EAAE,CAAC,EAAE,MAAM,QAapE;AAED,0EAA0E;AAC1E,wBAAgB,WAAW,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,QAIjE;AAED,yDAAyD;AACzD,wBAAgB,aAAa,CAAC,MAAM,EAAE,gBAAgB,QAErD"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { getGlobalStore } from "@egen-civitas/esm-state";
|
|
2
|
+
import { getAssignedExtensions, getToolWindowCompartment, TOOL_WINDOW_SLOTS } from "@egen-civitas/esm-extensions";
|
|
3
|
+
import { DEFAULT_COMPARTMENT_ID } from "./compartments.js";
|
|
2
4
|
/**
|
|
3
5
|
* État global du plan de travail du shell (rails + zones façon IntelliJ).
|
|
4
6
|
*
|
|
@@ -31,6 +33,13 @@ const ZONE_LIMITS = {
|
|
|
31
33
|
max: 720
|
|
32
34
|
}
|
|
33
35
|
};
|
|
36
|
+
export const SIDE_ANCHORS = [
|
|
37
|
+
'left',
|
|
38
|
+
'right'
|
|
39
|
+
];
|
|
40
|
+
/** Clé de mémorisation de la hauteur d'un compartiment ; `id` omis : compartiment par défaut de la zone. */ export function compartmentKey(anchor, id = DEFAULT_COMPARTMENT_ID) {
|
|
41
|
+
return `${anchor}:${id}`;
|
|
42
|
+
}
|
|
34
43
|
/**
|
|
35
44
|
* Borne une taille de zone : minimum fixe, maximum = plafond fixe ET part de la fenêtre
|
|
36
45
|
* (50 % de la largeur, 70 % de la hauteur), pour que le contenu central reste toujours visible.
|
|
@@ -53,7 +62,12 @@ function defaultState() {
|
|
|
53
62
|
left: null,
|
|
54
63
|
right: null,
|
|
55
64
|
bottom: null
|
|
56
|
-
}
|
|
65
|
+
},
|
|
66
|
+
compartments: {
|
|
67
|
+
left: [],
|
|
68
|
+
right: []
|
|
69
|
+
},
|
|
70
|
+
heights: {}
|
|
57
71
|
};
|
|
58
72
|
}
|
|
59
73
|
function readStoredState() {
|
|
@@ -68,6 +82,15 @@ function readStoredState() {
|
|
|
68
82
|
const active = parsed?.active?.[anchor];
|
|
69
83
|
if (typeof active === 'string' && active.length > 0) state.active[anchor] = active;
|
|
70
84
|
}
|
|
85
|
+
for (const anchor of SIDE_ANCHORS){
|
|
86
|
+
const open = parsed?.compartments?.[anchor];
|
|
87
|
+
if (Array.isArray(open)) {
|
|
88
|
+
state.compartments[anchor] = open.filter((id, index)=>typeof id === 'string' && id.length > 0 && open.indexOf(id) === index);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
for (const [key, value] of Object.entries(parsed?.heights ?? {})){
|
|
92
|
+
if (typeof value === 'number' && Number.isFinite(value) && value > 0 && value <= 100) state.heights[key] = value;
|
|
93
|
+
}
|
|
71
94
|
} catch {
|
|
72
95
|
// stockage indisponible ou contenu corrompu : disposition par défaut
|
|
73
96
|
}
|
|
@@ -81,7 +104,77 @@ workbenchStore.subscribe((state)=>{
|
|
|
81
104
|
// quota dépassé ou stockage désactivé : la disposition reste valable pour la session
|
|
82
105
|
}
|
|
83
106
|
});
|
|
84
|
-
|
|
107
|
+
const isSide = (anchor)=>anchor === 'left' || anchor === 'right';
|
|
108
|
+
/** Fenêtres d'outils ouvertes dans un compartiment propre de la zone `anchor` (liste vide pour la zone basse). */ export function getOpenCompartments(anchor, state = workbenchStore.getState()) {
|
|
109
|
+
return isSide(anchor) ? state.compartments?.[anchor] ?? [] : [];
|
|
110
|
+
}
|
|
111
|
+
/** Vrai si la fenêtre d'outils `id` demande un compartiment propre (`meta.compartment`) dans la zone `anchor`. */ export function hasOwnCompartment(anchor, id) {
|
|
112
|
+
if (!isSide(anchor)) return false;
|
|
113
|
+
try {
|
|
114
|
+
const extension = getAssignedExtensions(TOOL_WINDOW_SLOTS[anchor]).find((candidate)=>candidate.name === id);
|
|
115
|
+
return Boolean(extension?.meta && getToolWindowCompartment(extension.meta));
|
|
116
|
+
} catch {
|
|
117
|
+
// slot pas encore enregistré (appel d'une app avant le montage du rail) : compartiment par défaut
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/** Ouvre la fenêtre `id` dans un compartiment propre de la zone `anchor` (sans effet si déjà ouverte). */ export function openCompartment(anchor, id) {
|
|
122
|
+
const state = workbenchStore.getState();
|
|
123
|
+
const open = getOpenCompartments(anchor, state);
|
|
124
|
+
if (!open.includes(id)) {
|
|
125
|
+
workbenchStore.setState({
|
|
126
|
+
compartments: {
|
|
127
|
+
...defaultCompartments(),
|
|
128
|
+
...state.compartments,
|
|
129
|
+
[anchor]: [
|
|
130
|
+
...open,
|
|
131
|
+
id
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/** Referme le compartiment propre `id` de la zone `anchor` ; les autres se partagent la place libérée. */ export function closeCompartment(anchor, id) {
|
|
138
|
+
const state = workbenchStore.getState();
|
|
139
|
+
const open = getOpenCompartments(anchor, state);
|
|
140
|
+
if (open.includes(id)) {
|
|
141
|
+
workbenchStore.setState({
|
|
142
|
+
compartments: {
|
|
143
|
+
...defaultCompartments(),
|
|
144
|
+
...state.compartments,
|
|
145
|
+
[anchor]: open.filter((other)=>other !== id)
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/** Ouvre le compartiment propre `id` de la zone `anchor`, ou le referme s'il est ouvert. */ export function toggleCompartment(anchor, id) {
|
|
151
|
+
if (getOpenCompartments(anchor).includes(id)) closeCompartment(anchor, id);
|
|
152
|
+
else openCompartment(anchor, id);
|
|
153
|
+
}
|
|
154
|
+
function defaultCompartments() {
|
|
155
|
+
return {
|
|
156
|
+
left: [],
|
|
157
|
+
right: []
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Mémorise les hauteurs (en %) des compartiments d'une zone latérale. `heights` est indexé par clé de
|
|
162
|
+
* compartiment (voir `compartmentKey`) ; seules les valeurs réellement modifiées déclenchent une mise à jour.
|
|
163
|
+
*/ export function setCompartmentHeights(heights) {
|
|
164
|
+
const current = workbenchStore.getState().heights ?? {};
|
|
165
|
+
const changed = Object.entries(heights).some(([key, value])=>Math.abs((current[key] ?? -1) - value) > 0.005);
|
|
166
|
+
if (changed) workbenchStore.setState({
|
|
167
|
+
heights: {
|
|
168
|
+
...current,
|
|
169
|
+
...heights
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Ouvre la fenêtre d'outils `id` dans la zone `anchor` ; un second appel sur la même la referme.
|
|
175
|
+
* Selon sa `meta.compartment`, elle occupe le compartiment par défaut de la zone ou un compartiment propre.
|
|
176
|
+
*/ export function toggleToolWindow(anchor, id) {
|
|
177
|
+
if (isSide(anchor) && hasOwnCompartment(anchor, id)) return toggleCompartment(anchor, id);
|
|
85
178
|
const { active } = workbenchStore.getState();
|
|
86
179
|
workbenchStore.setState({
|
|
87
180
|
active: {
|
|
@@ -91,6 +184,7 @@ workbenchStore.subscribe((state)=>{
|
|
|
91
184
|
});
|
|
92
185
|
}
|
|
93
186
|
/** Ouvre la fenêtre d'outils `id` dans la zone `anchor` (sans la refermer si elle est déjà affichée). */ export function openToolWindow(anchor, id) {
|
|
187
|
+
if (isSide(anchor) && hasOwnCompartment(anchor, id)) return openCompartment(anchor, id);
|
|
94
188
|
const { active } = workbenchStore.getState();
|
|
95
189
|
if (active[anchor] !== id) workbenchStore.setState({
|
|
96
190
|
active: {
|
|
@@ -99,14 +193,34 @@ workbenchStore.subscribe((state)=>{
|
|
|
99
193
|
}
|
|
100
194
|
});
|
|
101
195
|
}
|
|
102
|
-
/**
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
196
|
+
/**
|
|
197
|
+
* Replie la zone `anchor` (compartiment par défaut et compartiments propres). Avec `id`, ne referme que
|
|
198
|
+
* cette fenêtre d'outils.
|
|
199
|
+
*/ export function closeToolWindow(anchor, id) {
|
|
200
|
+
const state = workbenchStore.getState();
|
|
201
|
+
if (id !== undefined) {
|
|
202
|
+
if (isSide(anchor) && getOpenCompartments(anchor, state).includes(id)) return closeCompartment(anchor, id);
|
|
203
|
+
if (state.active[anchor] === id) workbenchStore.setState({
|
|
204
|
+
active: {
|
|
205
|
+
...state.active,
|
|
206
|
+
[anchor]: null
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
const patch = {};
|
|
212
|
+
if (state.active[anchor] !== null) patch.active = {
|
|
213
|
+
...state.active,
|
|
214
|
+
[anchor]: null
|
|
215
|
+
};
|
|
216
|
+
if (isSide(anchor) && getOpenCompartments(anchor, state).length > 0) {
|
|
217
|
+
patch.compartments = {
|
|
218
|
+
...defaultCompartments(),
|
|
219
|
+
...state.compartments,
|
|
220
|
+
[anchor]: []
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
if (Object.keys(patch).length > 0) workbenchStore.setState(patch);
|
|
110
224
|
}
|
|
111
225
|
/** Redimensionne la zone `anchor` (valeur bornée par `clampZoneSize`). */ export function setZoneSize(anchor, size) {
|
|
112
226
|
const { sizes } = workbenchStore.getState();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@egen-civitas/esm-styleguide",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "The styleguide for Egen SPA",
|
|
6
6
|
"main": "dist/internal.js",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"@egen-civitas/esm-config": "^2.0.0",
|
|
101
101
|
"@egen-civitas/esm-data-api": "^2.0.0",
|
|
102
102
|
"@egen-civitas/esm-error-handling": "^1.0.2",
|
|
103
|
-
"@egen-civitas/esm-extensions": "^2.
|
|
103
|
+
"@egen-civitas/esm-extensions": "^2.2.0",
|
|
104
104
|
"@egen-civitas/esm-globals": "^2.0.0",
|
|
105
105
|
"@egen-civitas/esm-navigation": "^1.0.2",
|
|
106
106
|
"@egen-civitas/esm-react-utils": "^3.0.0",
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
"@egen-civitas/esm-data-api": "^2.0.0",
|
|
124
124
|
"@egen-civitas/esm-error-handling": "^1.0.2",
|
|
125
125
|
"@egen-civitas/esm-expression-evaluator": "^1.0.0",
|
|
126
|
-
"@egen-civitas/esm-extensions": "^2.
|
|
126
|
+
"@egen-civitas/esm-extensions": "^2.2.0",
|
|
127
127
|
"@egen-civitas/esm-globals": "^2.0.0",
|
|
128
128
|
"@egen-civitas/esm-navigation": "^1.0.2",
|
|
129
129
|
"@egen-civitas/esm-react-utils": "^3.0.0",
|