@egen-civitas/esm-styleguide 1.12.2 → 1.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -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/tool-window-rail.component.d.ts.map +1 -1
- package/dist/workbench/tool-window-rail.component.js +18 -8
- package/dist/workbench/tool-window-zone.component.d.ts.map +1 -1
- package/dist/workbench/tool-window-zone.component.js +16 -5
- package/dist/workbench/workbench-badges.d.ts +14 -0
- package/dist/workbench/workbench-badges.d.ts.map +1 -0
- package/dist/workbench/workbench-badges.js +22 -0
- package/dist/workbench/workbench.module.scss +18 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @egen-civitas/esm-styleguide
|
|
2
2
|
|
|
3
|
+
## 1.13.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fdbe154: Plan de travail : corrige l'erreur « ComponentContext has not been provided » à l'ouverture d'une zone (clic sur un bouton de rail). Les zones sont montées par le shell hors de tout décorateur de composant ; elles fournissent maintenant leur propre `ComponentContext` à l'`ExtensionSlot` qui rend la fenêtre d'outils active.
|
|
8
|
+
|
|
9
|
+
## 1.13.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 10be7cc: Plan de travail : pastilles (compteurs) sur les boutons des rails.
|
|
14
|
+
|
|
15
|
+
- Nouvelle API `setToolWindowBadge(id, badge)` (`id` = nom de l'extension du rail) : une app publie un compteur (ou un court texte) affiché sur son bouton de rail ; `null`, `0` ou `''` le retire. Les nombres supérieurs à 99 s'affichent « 99+ ».
|
|
16
|
+
- Les pastilles vivent dans un store dédié (`workbenchBadgeStore`) et ne sont jamais mémorisées avec la disposition du plan de travail.
|
|
17
|
+
|
|
3
18
|
## 1.12.2
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -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,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,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,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
|
package/dist/workbench/index.js
CHANGED
|
@@ -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,KAAK,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,KAAK,MAAM,OAAO,CAAC;AAyD1B;;;GAGG;AACH,wBAAgB,QAAQ,sBAQvB;AAED,2EAA2E;AAC3E,wBAAgB,SAAS,sBAMxB"}
|
|
@@ -4,6 +4,7 @@ import { useStore } from "@egen-civitas/esm-react-utils";
|
|
|
4
4
|
import { resolveWorkbenchIcon } from "./workbench-icons.js";
|
|
5
5
|
import { toolWindowTitle, useToolWindows } from "./use-tool-windows.js";
|
|
6
6
|
import { toggleToolWindow, workbenchStore } from "./workbench.store.js";
|
|
7
|
+
import { formatToolWindowBadge, workbenchBadgeStore } from "./workbench-badges.js";
|
|
7
8
|
import styles from "./workbench.module.scss";
|
|
8
9
|
function RailGroup({ anchor, label }) {
|
|
9
10
|
const tools = useToolWindows(anchor);
|
|
@@ -26,7 +27,9 @@ function RailGroup({ anchor, label }) {
|
|
|
26
27
|
function RailButton({ tool, active, onClick }) {
|
|
27
28
|
const title = toolWindowTitle(tool);
|
|
28
29
|
const Icon = resolveWorkbenchIcon(tool.meta.icon);
|
|
29
|
-
|
|
30
|
+
// NB : `useStore` retourne l'état étalé (clé = id de fenêtre d'outils).
|
|
31
|
+
const badge = useStore(workbenchBadgeStore)[tool.id];
|
|
32
|
+
return /*#__PURE__*/ _jsxs("button", {
|
|
30
33
|
type: "button",
|
|
31
34
|
className: styles.railButton,
|
|
32
35
|
"aria-pressed": active,
|
|
@@ -34,13 +37,20 @@ function RailButton({ tool, active, onClick }) {
|
|
|
34
37
|
title: title,
|
|
35
38
|
"data-active": active,
|
|
36
39
|
onClick: onClick,
|
|
37
|
-
children:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
children: [
|
|
41
|
+
Icon ? /*#__PURE__*/ _jsx(Icon, {
|
|
42
|
+
size: 18,
|
|
43
|
+
"aria-hidden": "true"
|
|
44
|
+
}) : /*#__PURE__*/ _jsx("span", {
|
|
45
|
+
"aria-hidden": "true",
|
|
46
|
+
children: title.charAt(0).toUpperCase()
|
|
47
|
+
}),
|
|
48
|
+
badge !== undefined && /*#__PURE__*/ _jsx("span", {
|
|
49
|
+
className: styles.railBadge,
|
|
50
|
+
"data-testid": `workbench-badge-${tool.id}`,
|
|
51
|
+
children: formatToolWindowBadge(badge)
|
|
52
|
+
})
|
|
53
|
+
]
|
|
44
54
|
});
|
|
45
55
|
}
|
|
46
56
|
/**
|
|
@@ -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,KAAiC,MAAM,OAAO,CAAC;AACtD,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-window-zone.component.d.ts","sourceRoot":"","sources":["../../src/workbench/tool-window-zone.component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiC,MAAM,OAAO,CAAC;AACtD,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAsBxF,UAAU,mBAAmB;IAC3B,MAAM,EAAE,gBAAgB,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,EAAE,mBAAmB,qBA6D7D"}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import React, { useCallback, useEffect } from "react";
|
|
3
3
|
import { TOOL_WINDOW_SLOTS } from "@egen-civitas/esm-extensions";
|
|
4
|
-
import { ExtensionSlot, useStore } from "@egen-civitas/esm-react-utils";
|
|
4
|
+
import { ComponentContext, ExtensionSlot, useStore } from "@egen-civitas/esm-react-utils";
|
|
5
5
|
import { X } from "lucide-react";
|
|
6
6
|
import { Splitter } from "./splitter.component.js";
|
|
7
7
|
import { toolWindowTitle, useToolWindows } from "./use-tool-windows.js";
|
|
8
8
|
import { closeToolWindow, workbenchStore } from "./workbench.store.js";
|
|
9
9
|
import styles from "./workbench.module.scss";
|
|
10
|
+
/**
|
|
11
|
+
* Contexte de composant des zones. Le shell monte chaque zone dans un `createRoot` autonome, hors de tout
|
|
12
|
+
* `egenComponentDecorator` : sans ce contexte, `ExtensionSlot` lève « ComponentContext has not been provided »
|
|
13
|
+
* dès qu'une fenêtre d'outils s'ouvre. Les extensions rendues gardent, elles, le contexte de leur propre app.
|
|
14
|
+
*/ const ZONE_CONTEXT = {
|
|
15
|
+
moduleName: '@egen-civitas/esm-styleguide',
|
|
16
|
+
featureName: 'workbench'
|
|
17
|
+
};
|
|
10
18
|
/** Variable CSS lue par la grille du body (`_general.scss`) pour dimensionner chaque zone. */ const ZONE_SIZE_VARIABLES = {
|
|
11
19
|
left: '--egen-zone-left-width',
|
|
12
20
|
right: '--egen-zone-right-width',
|
|
@@ -74,10 +82,13 @@ import styles from "./workbench.module.scss";
|
|
|
74
82
|
}),
|
|
75
83
|
/*#__PURE__*/ _jsx("div", {
|
|
76
84
|
className: styles.zoneBody,
|
|
77
|
-
children: /*#__PURE__*/ _jsx(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
85
|
+
children: /*#__PURE__*/ _jsx(ComponentContext.Provider, {
|
|
86
|
+
value: ZONE_CONTEXT,
|
|
87
|
+
children: /*#__PURE__*/ _jsx(ExtensionSlot, {
|
|
88
|
+
name: TOOL_WINDOW_SLOTS[anchor],
|
|
89
|
+
select: selectActive,
|
|
90
|
+
className: styles.zoneSlot
|
|
91
|
+
})
|
|
81
92
|
})
|
|
82
93
|
}),
|
|
83
94
|
/*#__PURE__*/ _jsx(Splitter, {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pastilles (compteurs) des boutons de rail, publiées par les apps.
|
|
3
|
+
*
|
|
4
|
+
* Store séparé de `workbenchStore` : les pastilles sont volatiles et ne doivent jamais être
|
|
5
|
+
* mémorisées avec la disposition du plan de travail. Clé = nom de l'extension (id de la
|
|
6
|
+
* fenêtre d'outils). Une valeur absente, `0` ou vide n'affiche rien.
|
|
7
|
+
*/
|
|
8
|
+
export type ToolWindowBadge = number | string;
|
|
9
|
+
export declare const workbenchBadgeStore: import("zustand").StoreApi<Record<string, ToolWindowBadge>>;
|
|
10
|
+
/** Publie (ou retire avec `null`/`undefined`/`0`/`''`) la pastille de la fenêtre d'outils `id`. */
|
|
11
|
+
export declare function setToolWindowBadge(id: string, badge: ToolWindowBadge | null | undefined): void;
|
|
12
|
+
/** Texte affiché dans la pastille : les nombres supérieurs à 99 sont plafonnés à « 99+ ». */
|
|
13
|
+
export declare function formatToolWindowBadge(badge: ToolWindowBadge): string;
|
|
14
|
+
//# sourceMappingURL=workbench-badges.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workbench-badges.d.ts","sourceRoot":"","sources":["../../src/workbench/workbench-badges.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,CAAC;AAE9C,eAAO,MAAM,mBAAmB,6DAA0E,CAAC;AAE3G,mGAAmG;AACnG,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,QAWvF;AAED,6FAA6F;AAC7F,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAEpE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getGlobalStore } from "@egen-civitas/esm-state";
|
|
2
|
+
export const workbenchBadgeStore = getGlobalStore('workbench-badges', {});
|
|
3
|
+
/** Publie (ou retire avec `null`/`undefined`/`0`/`''`) la pastille de la fenêtre d'outils `id`. */ export function setToolWindowBadge(id, badge) {
|
|
4
|
+
const state = workbenchBadgeStore.getState();
|
|
5
|
+
const empty = badge === null || badge === undefined || badge === 0 || badge === '';
|
|
6
|
+
if (empty) {
|
|
7
|
+
if (!(id in state)) return;
|
|
8
|
+
const next = {
|
|
9
|
+
...state
|
|
10
|
+
};
|
|
11
|
+
delete next[id];
|
|
12
|
+
workbenchBadgeStore.setState(next, true);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (state[id] !== badge) workbenchBadgeStore.setState({
|
|
16
|
+
...state,
|
|
17
|
+
[id]: badge
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/** Texte affiché dans la pastille : les nombres supérieurs à 99 sont plafonnés à « 99+ ». */ export function formatToolWindowBadge(badge) {
|
|
21
|
+
return typeof badge === 'number' && badge > 99 ? '99+' : String(badge);
|
|
22
|
+
}
|
|
@@ -35,7 +35,25 @@ $gap: var(--egen-workbench-gap, 0.375rem);
|
|
|
35
35
|
flex: 1 1 auto;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
.railBadge {
|
|
39
|
+
position: absolute;
|
|
40
|
+
top: 0.125rem;
|
|
41
|
+
right: 0.125rem;
|
|
42
|
+
min-width: 1rem;
|
|
43
|
+
height: 1rem;
|
|
44
|
+
padding: 0 0.25rem;
|
|
45
|
+
border-radius: 999px;
|
|
46
|
+
background: #e41e3f;
|
|
47
|
+
color: #fff;
|
|
48
|
+
font-size: 0.625rem;
|
|
49
|
+
font-weight: 700;
|
|
50
|
+
line-height: 1rem;
|
|
51
|
+
text-align: center;
|
|
52
|
+
pointer-events: none;
|
|
53
|
+
}
|
|
54
|
+
|
|
38
55
|
.railButton {
|
|
56
|
+
position: relative;
|
|
39
57
|
display: inline-flex;
|
|
40
58
|
align-items: center;
|
|
41
59
|
justify-content: center;
|