@egen-civitas/esm-styleguide 1.12.2 → 1.13.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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @egen-civitas/esm-styleguide
2
2
 
3
+ ## 1.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 10be7cc: Plan de travail : pastilles (compteurs) sur les boutons des rails.
8
+
9
+ - 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+ ».
10
+ - Les pastilles vivent dans un store dédié (`workbenchBadgeStore`) et ne sont jamais mémorisées avec la disposition du plan de travail.
11
+
3
12
  ## 1.12.2
4
13
 
5
14
  ### Patch Changes
@@ -6,4 +6,5 @@ export * from './splitter.component.js';
6
6
  export * from './workbench-icons.js';
7
7
  export * from './workbench.render.js';
8
8
  export * from './workbench.store.js';
9
+ export * from './workbench-badges.js';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -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"}
@@ -6,3 +6,4 @@ export * from "./splitter.component.js";
6
6
  export * from "./workbench-icons.js";
7
7
  export * from "./workbench.render.js";
8
8
  export * from "./workbench.store.js";
9
+ export * from "./workbench-badges.js";
@@ -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;AAiD1B;;;GAGG;AACH,wBAAgB,QAAQ,sBAQvB;AAED,2EAA2E;AAC3E,wBAAgB,SAAS,sBAMxB"}
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
- return /*#__PURE__*/ _jsx("button", {
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: Icon ? /*#__PURE__*/ _jsx(Icon, {
38
- size: 18,
39
- "aria-hidden": "true"
40
- }) : /*#__PURE__*/ _jsx("span", {
41
- "aria-hidden": "true",
42
- children: title.charAt(0).toUpperCase()
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
  /**
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egen-civitas/esm-styleguide",
3
- "version": "1.12.2",
3
+ "version": "1.13.0",
4
4
  "license": "MPL-2.0",
5
5
  "description": "The styleguide for Egen SPA",
6
6
  "main": "dist/internal.js",