@cgi-learning-hub/ui 1.6.0-dev.1749207390 → 1.6.0-dev.1749214505
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/dist/{Autocomplete-XmIFWgiQ.js → Autocomplete-BVy1WjPe.js} +45 -45
- package/dist/Autocomplete-v4ZcHulv.cjs +6 -0
- package/dist/components/ButtonGroup/ButtonGroup.cjs.js +1 -0
- package/dist/components/ButtonGroup/ButtonGroup.d.ts +3 -0
- package/dist/components/{SwitchView/SwitchView.es.js → ButtonGroup/ButtonGroup.es.js} +11 -11
- package/dist/components/ButtonGroup/index.cjs.js +1 -0
- package/dist/components/ButtonGroup/index.d.ts +2 -0
- package/dist/components/ButtonGroup/index.es.js +4 -0
- package/dist/components/{SwitchView → ButtonGroup}/types.d.ts +3 -3
- package/dist/components/index.cjs.js +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.es.js +23 -23
- package/dist/components/stories/Autocomplete.stories.cjs.js +1 -1
- package/dist/components/stories/Autocomplete.stories.es.js +1 -1
- package/dist/components/stories/ButtonGroup.stories.cjs.js +143 -0
- package/dist/components/stories/{SwitchView.stories.d.ts → ButtonGroup.stories.d.ts} +3 -3
- package/dist/components/stories/{SwitchView.stories.es.js → ButtonGroup.stories.es.js} +150 -150
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +23 -23
- package/package.json +1 -1
- package/dist/Autocomplete-CpRv6_iv.cjs +0 -6
- package/dist/components/SwitchView/SwitchView.cjs.js +0 -1
- package/dist/components/SwitchView/SwitchView.d.ts +0 -3
- package/dist/components/SwitchView/index.cjs.js +0 -1
- package/dist/components/SwitchView/index.d.ts +0 -2
- package/dist/components/SwitchView/index.es.js +0 -4
- package/dist/components/stories/SwitchView.stories.cjs.js +0 -143
- /package/dist/components/{SwitchView → ButtonGroup}/style.cjs.js +0 -0
- /package/dist/components/{SwitchView → ButtonGroup}/style.es.js +0 -0
- /package/dist/components/{SwitchView → ButtonGroup}/types.cjs.js +0 -0
- /package/dist/components/{SwitchView → ButtonGroup}/types.es.js +0 -0
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
-
import { c as
|
|
3
|
-
import { useState as u, useCallback as
|
|
4
|
-
import m from "../
|
|
2
|
+
import { c as B } from "../../createSvgIcon-BWru5SCV.js";
|
|
3
|
+
import { useState as u, useCallback as f } from "react";
|
|
4
|
+
import m from "../ButtonGroup/ButtonGroup.es.js";
|
|
5
5
|
import { B as d } from "../../Box-DjbKEblU.js";
|
|
6
6
|
import { T as n } from "../../Typography-CYUXO-Vm.js";
|
|
7
7
|
import { G as l } from "../../Grid-CpuW2Xrl.js";
|
|
8
8
|
import { B as y } from "../../Button-WTdCmXYm.js";
|
|
9
9
|
import { P as s } from "../../Paper-yeP8q4RO.js";
|
|
10
|
-
const I =
|
|
10
|
+
const I = B(/* @__PURE__ */ e("path", {
|
|
11
11
|
d: "M20 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2M8 11H4V6h4zm6 0h-4V6h4zm6 0h-4V6h4zM8 18H4v-5h4zm6 0h-4v-5h4zm6 0h-4v-5h4z"
|
|
12
|
-
}), "CalendarViewMonth"),
|
|
12
|
+
}), "CalendarViewMonth"), T = B(/* @__PURE__ */ e("path", {
|
|
13
13
|
fillRule: "evenodd",
|
|
14
14
|
d: "M3 3v8h8V3zm6 6H5V5h4zm-6 4v8h8v-8zm6 6H5v-4h4zm4-16v8h8V3zm6 6h-4V5h4zm-6 4v8h8v-8zm6 6h-4v-4h4z"
|
|
15
|
-
}), "GridView"),
|
|
15
|
+
}), "GridView"), V = B(/* @__PURE__ */ e("path", {
|
|
16
16
|
d: "M3 13h2v-2H3zm0 4h2v-2H3zm0-8h2V7H3zm4 4h14v-2H7zm0 4h14v-2H7zM7 7v2h14V7z"
|
|
17
|
-
}), "List"),
|
|
17
|
+
}), "List"), w = B(/* @__PURE__ */ e("path", {
|
|
18
18
|
d: "M21 8H3V4h18zm0 2H3v4h18zm0 6H3v4h18z"
|
|
19
|
-
}), "TableRows"),
|
|
19
|
+
}), "TableRows"), S = B(/* @__PURE__ */ e("path", {
|
|
20
20
|
d: "M2 4v7h20V4zm8 16h12v-7H10zm-8 0h6v-7H2z"
|
|
21
|
-
}), "ViewComfy"),
|
|
21
|
+
}), "ViewComfy"), z = B(/* @__PURE__ */ e("path", {
|
|
22
22
|
d: "M14.67 5v6.5H9.33V5zm1 6.5H21V5h-5.33zm-1 7.5v-6.5H9.33V19zm1-6.5V19H21v-6.5zm-7.34 0H3V19h5.33zm0-1V5H3v6.5z"
|
|
23
|
-
}), "ViewModule"),
|
|
24
|
-
title: "Components/
|
|
23
|
+
}), "ViewModule"), F = {
|
|
24
|
+
title: "Components/ButtonGroup",
|
|
25
25
|
component: m,
|
|
26
26
|
argTypes: {
|
|
27
|
-
|
|
28
|
-
description: "**[Requis]** Liste des boutons à afficher dans le
|
|
27
|
+
buttonList: {
|
|
28
|
+
description: "**[Requis]** Liste des boutons à afficher dans le ButtonGroup.",
|
|
29
29
|
control: "object",
|
|
30
30
|
table: {
|
|
31
31
|
required: !0,
|
|
32
|
-
type: { summary: "readonly
|
|
32
|
+
type: { summary: "readonly ButtonItem[]" }
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
viewMode: {
|
|
@@ -87,13 +87,13 @@ const I = z(/* @__PURE__ */ e("path", {
|
|
|
87
87
|
docs: {
|
|
88
88
|
description: {
|
|
89
89
|
component: `
|
|
90
|
-
##
|
|
90
|
+
## ButtonGroup
|
|
91
91
|
|
|
92
92
|
Un composant générique TypeScript pour permettre à l'utilisateur de basculer entre différents modes d'affichage ou options avec une sécurité de type complète.
|
|
93
93
|
|
|
94
94
|
### 🔥 Typage générique et sécurité des types
|
|
95
95
|
|
|
96
|
-
Le
|
|
96
|
+
Le ButtonGroup utilise TypeScript générique avancé pour inférer automatiquement les types des valeurs possibles à partir de la liste des boutons fournie. **Il n'est plus nécessaire de définir un enum**, les types sont déduits automatiquement grâce à la magie de TypeScript !
|
|
97
97
|
|
|
98
98
|
**Point clé** : Utilisez toujours \`as const\` après votre tableau de boutons pour permettre l'inférence de type littéral.
|
|
99
99
|
|
|
@@ -117,8 +117,8 @@ const handleViewChange = useCallback((value: ViewType) => {
|
|
|
117
117
|
setCurrentView(value);
|
|
118
118
|
}, []);
|
|
119
119
|
|
|
120
|
-
<
|
|
121
|
-
|
|
120
|
+
<ButtonGroup
|
|
121
|
+
buttonList={viewButtons}
|
|
122
122
|
viewMode={currentView}
|
|
123
123
|
onChange={handleViewChange} // ← Pas d'erreur 'any' !
|
|
124
124
|
/>
|
|
@@ -148,18 +148,18 @@ const handleViewChange = (value) => { // ← 'value' aura le type 'any'
|
|
|
148
148
|
|
|
149
149
|
### 📋 Structure des données
|
|
150
150
|
|
|
151
|
-
Le composant attend un tableau d'objets \`
|
|
151
|
+
Le composant attend un tableau d'objets \`ButtonItem\` typé de manière générique :
|
|
152
152
|
|
|
153
153
|
\`\`\`typescript
|
|
154
|
-
interface
|
|
154
|
+
interface ButtonItem<T extends string = string> {
|
|
155
155
|
value: T; // Valeur unique pour ce bouton (obligatoire)
|
|
156
156
|
icon: ReactNode; // Icône à afficher (obligatoire)
|
|
157
157
|
disabled?: boolean; // Désactiver ce bouton spécifique (facultatif)
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
// Le composant infère automatiquement T à partir de votre tableau
|
|
161
|
-
type SwitchViewProps<T extends readonly
|
|
162
|
-
|
|
161
|
+
type SwitchViewProps<T extends readonly ButtonItem<string>[]> = {
|
|
162
|
+
buttonList: T;
|
|
163
163
|
viewMode: T[number]["value"]; // Type inféré automatiquement
|
|
164
164
|
onChange: (value: T[number]["value"]) => void; // Type inféré automatiquement
|
|
165
165
|
// ... autres props
|
|
@@ -205,37 +205,37 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
}, x = [
|
|
208
|
-
{ value: "cards", icon: /* @__PURE__ */ e(
|
|
209
|
-
{ value: "table", icon: /* @__PURE__ */ e(
|
|
210
|
-
{ value: "list", icon: /* @__PURE__ */ e(
|
|
208
|
+
{ value: "cards", icon: /* @__PURE__ */ e(z, {}) },
|
|
209
|
+
{ value: "table", icon: /* @__PURE__ */ e(w, {}) },
|
|
210
|
+
{ value: "list", icon: /* @__PURE__ */ e(V, {}) }
|
|
211
211
|
], M = [
|
|
212
|
-
{ value: "grid", icon: /* @__PURE__ */ e(
|
|
213
|
-
{ value: "cards", icon: /* @__PURE__ */ e(
|
|
214
|
-
{ value: "table", icon: /* @__PURE__ */ e(
|
|
215
|
-
{ value: "list", icon: /* @__PURE__ */ e(
|
|
212
|
+
{ value: "grid", icon: /* @__PURE__ */ e(T, {}) },
|
|
213
|
+
{ value: "cards", icon: /* @__PURE__ */ e(S, {}) },
|
|
214
|
+
{ value: "table", icon: /* @__PURE__ */ e(w, {}) },
|
|
215
|
+
{ value: "list", icon: /* @__PURE__ */ e(V, {}) },
|
|
216
216
|
{ value: "calendar", icon: /* @__PURE__ */ e(I, {}) }
|
|
217
217
|
], q = [
|
|
218
|
-
{ value: "cards", icon: /* @__PURE__ */ e(
|
|
219
|
-
{ value: "table", icon: /* @__PURE__ */ e(
|
|
220
|
-
{ value: "list", icon: /* @__PURE__ */ e(
|
|
218
|
+
{ value: "cards", icon: /* @__PURE__ */ e(z, {}) },
|
|
219
|
+
{ value: "table", icon: /* @__PURE__ */ e(w, {}), disabled: !0 },
|
|
220
|
+
{ value: "list", icon: /* @__PURE__ */ e(V, {}) }
|
|
221
221
|
], j = {
|
|
222
222
|
render: () => {
|
|
223
|
-
const [
|
|
224
|
-
console.log(`Vue sélectionnée: ${i}`),
|
|
223
|
+
const [r, o] = u("cards"), c = f((i) => {
|
|
224
|
+
console.log(`Vue sélectionnée: ${i}`), o(i);
|
|
225
225
|
}, []);
|
|
226
226
|
return /* @__PURE__ */ t(d, { sx: { p: 2 }, children: [
|
|
227
227
|
/* @__PURE__ */ e(n, { variant: "h6", gutterBottom: !0, children: "Sélecteur de vue standard" }),
|
|
228
228
|
/* @__PURE__ */ e(
|
|
229
229
|
m,
|
|
230
230
|
{
|
|
231
|
-
|
|
232
|
-
viewMode:
|
|
231
|
+
buttonList: x,
|
|
232
|
+
viewMode: r,
|
|
233
233
|
onChange: c
|
|
234
234
|
}
|
|
235
235
|
),
|
|
236
236
|
/* @__PURE__ */ t(n, { variant: "body2", sx: { mt: 2 }, children: [
|
|
237
237
|
"Vue actuelle: ",
|
|
238
|
-
/* @__PURE__ */ e("strong", { children:
|
|
238
|
+
/* @__PURE__ */ e("strong", { children: r })
|
|
239
239
|
] })
|
|
240
240
|
] });
|
|
241
241
|
},
|
|
@@ -250,9 +250,9 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
250
250
|
}
|
|
251
251
|
}, N = {
|
|
252
252
|
render: () => {
|
|
253
|
-
const [
|
|
253
|
+
const [r, o] = u("table"), [c, i] = u(
|
|
254
254
|
"primary"
|
|
255
|
-
), [h, a] = u("small"), [v,
|
|
255
|
+
), [h, a] = u("small"), [v, b] = u(
|
|
256
256
|
"horizontal"
|
|
257
257
|
);
|
|
258
258
|
return /* @__PURE__ */ t(d, { sx: { p: 2 }, children: [
|
|
@@ -283,15 +283,15 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
283
283
|
] }),
|
|
284
284
|
/* @__PURE__ */ t(l, { size: { xs: 12, sm: 6, md: 3 }, children: [
|
|
285
285
|
/* @__PURE__ */ e(n, { variant: "subtitle2", gutterBottom: !0, children: "Taille" }),
|
|
286
|
-
/* @__PURE__ */ e(d, { sx: { display: "flex", gap: 1 }, children: ["small", "medium", "large"].map((
|
|
286
|
+
/* @__PURE__ */ e(d, { sx: { display: "flex", gap: 1 }, children: ["small", "medium", "large"].map((g) => /* @__PURE__ */ e(
|
|
287
287
|
y,
|
|
288
288
|
{
|
|
289
289
|
size: "small",
|
|
290
|
-
variant: h ===
|
|
291
|
-
onClick: () => a(
|
|
292
|
-
children:
|
|
290
|
+
variant: h === g ? "contained" : "outlined",
|
|
291
|
+
onClick: () => a(g),
|
|
292
|
+
children: g
|
|
293
293
|
},
|
|
294
|
-
|
|
294
|
+
g
|
|
295
295
|
)) })
|
|
296
296
|
] }),
|
|
297
297
|
/* @__PURE__ */ t(l, { size: { xs: 12, sm: 6, md: 3 }, children: [
|
|
@@ -302,7 +302,7 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
302
302
|
{
|
|
303
303
|
size: "small",
|
|
304
304
|
variant: v === "horizontal" ? "contained" : "outlined",
|
|
305
|
-
onClick: () =>
|
|
305
|
+
onClick: () => b("horizontal"),
|
|
306
306
|
children: "Horizontal"
|
|
307
307
|
}
|
|
308
308
|
),
|
|
@@ -311,7 +311,7 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
311
311
|
{
|
|
312
312
|
size: "small",
|
|
313
313
|
variant: v === "vertical" ? "contained" : "outlined",
|
|
314
|
-
onClick: () =>
|
|
314
|
+
onClick: () => b("vertical"),
|
|
315
315
|
children: "Vertical"
|
|
316
316
|
}
|
|
317
317
|
)
|
|
@@ -319,16 +319,16 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
319
319
|
] }),
|
|
320
320
|
/* @__PURE__ */ t(l, { size: { xs: 12, sm: 6, md: 3 }, children: [
|
|
321
321
|
/* @__PURE__ */ e(n, { variant: "subtitle2", gutterBottom: !0, children: "Vue actuelle" }),
|
|
322
|
-
/* @__PURE__ */ e(n, { variant: "body2", color: "primary", children: /* @__PURE__ */ e("strong", { children:
|
|
322
|
+
/* @__PURE__ */ e(n, { variant: "body2", color: "primary", children: /* @__PURE__ */ e("strong", { children: r }) })
|
|
323
323
|
] })
|
|
324
324
|
] }),
|
|
325
325
|
/* @__PURE__ */ e(s, { sx: { p: 3, display: "inline-block" }, children: /* @__PURE__ */ e(
|
|
326
326
|
m,
|
|
327
327
|
{
|
|
328
|
-
|
|
329
|
-
viewMode:
|
|
330
|
-
onChange: (
|
|
331
|
-
console.log(`Vue sélectionnée: ${
|
|
328
|
+
buttonList: x,
|
|
329
|
+
viewMode: r,
|
|
330
|
+
onChange: (g) => {
|
|
331
|
+
console.log(`Vue sélectionnée: ${g}`), o(g);
|
|
332
332
|
},
|
|
333
333
|
colorVariant: c,
|
|
334
334
|
size: h,
|
|
@@ -349,18 +349,18 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
349
349
|
}
|
|
350
350
|
}, W = {
|
|
351
351
|
render: () => {
|
|
352
|
-
const
|
|
353
|
-
{ value: "on", icon: /* @__PURE__ */ e(
|
|
354
|
-
{ value: "off", icon: /* @__PURE__ */ e(
|
|
355
|
-
],
|
|
356
|
-
{ value: "active", icon: /* @__PURE__ */ e(
|
|
357
|
-
{ value: "inactive", icon: /* @__PURE__ */ e(
|
|
358
|
-
{ value: "pending", icon: /* @__PURE__ */ e(
|
|
352
|
+
const r = [
|
|
353
|
+
{ value: "on", icon: /* @__PURE__ */ e(z, {}) },
|
|
354
|
+
{ value: "off", icon: /* @__PURE__ */ e(w, {}) }
|
|
355
|
+
], o = [
|
|
356
|
+
{ value: "active", icon: /* @__PURE__ */ e(S, {}) },
|
|
357
|
+
{ value: "inactive", icon: /* @__PURE__ */ e(V, {}) },
|
|
358
|
+
{ value: "pending", icon: /* @__PURE__ */ e(T, {}) }
|
|
359
359
|
], c = [
|
|
360
|
-
{ value: "edit", icon: /* @__PURE__ */ e(
|
|
361
|
-
{ value: "view", icon: /* @__PURE__ */ e(
|
|
362
|
-
{ value: "preview", icon: /* @__PURE__ */ e(
|
|
363
|
-
], [i, h] = u("on"), [a, v] = u("active"), [
|
|
360
|
+
{ value: "edit", icon: /* @__PURE__ */ e(z, {}) },
|
|
361
|
+
{ value: "view", icon: /* @__PURE__ */ e(w, {}) },
|
|
362
|
+
{ value: "preview", icon: /* @__PURE__ */ e(V, {}) }
|
|
363
|
+
], [i, h] = u("on"), [a, v] = u("active"), [b, g] = u("edit");
|
|
364
364
|
return /* @__PURE__ */ t(d, { sx: { p: 2 }, children: [
|
|
365
365
|
/* @__PURE__ */ e(n, { variant: "h6", gutterBottom: !0, children: "Différents contextes d'utilisation" }),
|
|
366
366
|
/* @__PURE__ */ e(n, { variant: "body2", color: "text.secondary", paragraph: !0, children: "Le même composant s'adapte automatiquement à différents types de données." }),
|
|
@@ -380,7 +380,7 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
380
380
|
/* @__PURE__ */ e(
|
|
381
381
|
m,
|
|
382
382
|
{
|
|
383
|
-
|
|
383
|
+
buttonList: r,
|
|
384
384
|
viewMode: i,
|
|
385
385
|
onChange: (p) => {
|
|
386
386
|
console.log("Simple:", p), h(p);
|
|
@@ -407,7 +407,7 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
407
407
|
/* @__PURE__ */ e(
|
|
408
408
|
m,
|
|
409
409
|
{
|
|
410
|
-
|
|
410
|
+
buttonList: o,
|
|
411
411
|
viewMode: a,
|
|
412
412
|
onChange: (p) => {
|
|
413
413
|
console.log("Status:", p), v(p);
|
|
@@ -435,17 +435,17 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
435
435
|
/* @__PURE__ */ e(
|
|
436
436
|
m,
|
|
437
437
|
{
|
|
438
|
-
|
|
439
|
-
viewMode:
|
|
438
|
+
buttonList: c,
|
|
439
|
+
viewMode: b,
|
|
440
440
|
onChange: (p) => {
|
|
441
|
-
console.log("Mode:", p),
|
|
441
|
+
console.log("Mode:", p), g(p);
|
|
442
442
|
},
|
|
443
443
|
size: "medium"
|
|
444
444
|
}
|
|
445
445
|
),
|
|
446
446
|
/* @__PURE__ */ t(n, { variant: "body2", sx: { mt: 1 }, children: [
|
|
447
447
|
"Mode: ",
|
|
448
|
-
|
|
448
|
+
b
|
|
449
449
|
] })
|
|
450
450
|
] }) })
|
|
451
451
|
] }),
|
|
@@ -477,13 +477,13 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
477
477
|
}
|
|
478
478
|
}, _ = {
|
|
479
479
|
render: () => {
|
|
480
|
-
const
|
|
480
|
+
const r = ["primary", "secondary"], [o, c] = u({
|
|
481
481
|
primary: "cards",
|
|
482
482
|
secondary: "table"
|
|
483
483
|
});
|
|
484
484
|
return /* @__PURE__ */ t(d, { sx: { p: 2 }, children: [
|
|
485
485
|
/* @__PURE__ */ e(n, { variant: "h6", gutterBottom: !0, children: "Comparaison des variantes de couleurs" }),
|
|
486
|
-
/* @__PURE__ */ e(l, { container: !0, spacing: 3, children:
|
|
486
|
+
/* @__PURE__ */ e(l, { container: !0, spacing: 3, children: r.map((i) => /* @__PURE__ */ e(l, { size: { xs: 12, md: 6 }, children: /* @__PURE__ */ t(s, { sx: { p: 2 }, children: [
|
|
487
487
|
/* @__PURE__ */ t(n, { variant: "subtitle1", gutterBottom: !0, children: [
|
|
488
488
|
"Variante ",
|
|
489
489
|
i
|
|
@@ -491,8 +491,8 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
491
491
|
/* @__PURE__ */ e(
|
|
492
492
|
m,
|
|
493
493
|
{
|
|
494
|
-
|
|
495
|
-
viewMode:
|
|
494
|
+
buttonList: x,
|
|
495
|
+
viewMode: o[i],
|
|
496
496
|
onChange: (h) => {
|
|
497
497
|
c((a) => ({ ...a, [i]: h }));
|
|
498
498
|
},
|
|
@@ -501,7 +501,7 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
501
501
|
),
|
|
502
502
|
/* @__PURE__ */ t(n, { variant: "body2", sx: { mt: 1 }, children: [
|
|
503
503
|
"Sélectionné: ",
|
|
504
|
-
|
|
504
|
+
o[i]
|
|
505
505
|
] })
|
|
506
506
|
] }) }, i)) })
|
|
507
507
|
] });
|
|
@@ -517,18 +517,18 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
517
517
|
}
|
|
518
518
|
}, $ = {
|
|
519
519
|
render: () => {
|
|
520
|
-
const
|
|
520
|
+
const r = [
|
|
521
521
|
"small",
|
|
522
522
|
"medium",
|
|
523
523
|
"large"
|
|
524
|
-
], [
|
|
524
|
+
], [o, c] = u({
|
|
525
525
|
small: "cards",
|
|
526
526
|
medium: "table",
|
|
527
527
|
large: "list"
|
|
528
528
|
});
|
|
529
529
|
return /* @__PURE__ */ t(d, { sx: { p: 2 }, children: [
|
|
530
530
|
/* @__PURE__ */ e(n, { variant: "h6", gutterBottom: !0, children: "Comparaison des tailles" }),
|
|
531
|
-
/* @__PURE__ */ e(l, { container: !0, spacing: 3, children:
|
|
531
|
+
/* @__PURE__ */ e(l, { container: !0, spacing: 3, children: r.map((i) => /* @__PURE__ */ e(l, { size: { xs: 12, md: 4 }, children: /* @__PURE__ */ t(s, { sx: { p: 2 }, children: [
|
|
532
532
|
/* @__PURE__ */ t(n, { variant: "subtitle1", gutterBottom: !0, children: [
|
|
533
533
|
"Taille ",
|
|
534
534
|
i
|
|
@@ -536,8 +536,8 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
536
536
|
/* @__PURE__ */ e(
|
|
537
537
|
m,
|
|
538
538
|
{
|
|
539
|
-
|
|
540
|
-
viewMode:
|
|
539
|
+
buttonList: x,
|
|
540
|
+
viewMode: o[i],
|
|
541
541
|
onChange: (h) => {
|
|
542
542
|
c((a) => ({ ...a, [i]: h }));
|
|
543
543
|
},
|
|
@@ -546,7 +546,7 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
546
546
|
),
|
|
547
547
|
/* @__PURE__ */ t(n, { variant: "body2", sx: { mt: 1 }, children: [
|
|
548
548
|
"Sélectionné: ",
|
|
549
|
-
|
|
549
|
+
o[i]
|
|
550
550
|
] })
|
|
551
551
|
] }) }, i)) })
|
|
552
552
|
] });
|
|
@@ -562,8 +562,8 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
562
562
|
}
|
|
563
563
|
}, J = {
|
|
564
564
|
render: () => {
|
|
565
|
-
const [
|
|
566
|
-
|
|
565
|
+
const [r, o] = u("grid"), c = f((i) => {
|
|
566
|
+
o(i);
|
|
567
567
|
}, []);
|
|
568
568
|
return /* @__PURE__ */ t(d, { sx: { p: 2 }, children: [
|
|
569
569
|
/* @__PURE__ */ e(n, { variant: "h6", gutterBottom: !0, children: "Orientation verticale" }),
|
|
@@ -573,8 +573,8 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
573
573
|
/* @__PURE__ */ e(
|
|
574
574
|
m,
|
|
575
575
|
{
|
|
576
|
-
|
|
577
|
-
viewMode:
|
|
576
|
+
buttonList: M,
|
|
577
|
+
viewMode: r,
|
|
578
578
|
onChange: c,
|
|
579
579
|
orientation: "vertical",
|
|
580
580
|
size: "medium"
|
|
@@ -586,8 +586,8 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
586
586
|
/* @__PURE__ */ e(
|
|
587
587
|
m,
|
|
588
588
|
{
|
|
589
|
-
|
|
590
|
-
viewMode:
|
|
589
|
+
buttonList: M,
|
|
590
|
+
viewMode: r,
|
|
591
591
|
onChange: c,
|
|
592
592
|
orientation: "horizontal",
|
|
593
593
|
size: "medium"
|
|
@@ -597,7 +597,7 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
597
597
|
] }),
|
|
598
598
|
/* @__PURE__ */ t(n, { variant: "body2", sx: { mt: 2 }, children: [
|
|
599
599
|
"Vue actuelle: ",
|
|
600
|
-
/* @__PURE__ */ e("strong", { children:
|
|
600
|
+
/* @__PURE__ */ e("strong", { children: r })
|
|
601
601
|
] })
|
|
602
602
|
] });
|
|
603
603
|
},
|
|
@@ -612,8 +612,8 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
612
612
|
}
|
|
613
613
|
}, K = {
|
|
614
614
|
render: () => {
|
|
615
|
-
const [
|
|
616
|
-
|
|
615
|
+
const [r, o] = u("cards"), c = f((i) => {
|
|
616
|
+
o(i);
|
|
617
617
|
}, []);
|
|
618
618
|
return /* @__PURE__ */ t(d, { sx: { p: 2 }, children: [
|
|
619
619
|
/* @__PURE__ */ e(n, { variant: "h6", gutterBottom: !0, children: "Gestion des boutons désactivés" }),
|
|
@@ -621,15 +621,15 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
621
621
|
/* @__PURE__ */ e(
|
|
622
622
|
m,
|
|
623
623
|
{
|
|
624
|
-
|
|
625
|
-
viewMode:
|
|
624
|
+
buttonList: q,
|
|
625
|
+
viewMode: r,
|
|
626
626
|
onChange: c,
|
|
627
627
|
size: "medium"
|
|
628
628
|
}
|
|
629
629
|
),
|
|
630
630
|
/* @__PURE__ */ t(n, { variant: "body2", sx: { mt: 2 }, children: [
|
|
631
631
|
"Vue actuelle: ",
|
|
632
|
-
/* @__PURE__ */ e("strong", { children:
|
|
632
|
+
/* @__PURE__ */ e("strong", { children: r })
|
|
633
633
|
] }),
|
|
634
634
|
/* @__PURE__ */ e(n, { variant: "body2", color: "text.secondary", sx: { mt: 1 }, children: 'Le bouton "Table" est désactivé dans cet exemple' }),
|
|
635
635
|
/* @__PURE__ */ t(d, { sx: { mt: 2 }, children: [
|
|
@@ -638,7 +638,7 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
638
638
|
{
|
|
639
639
|
variant: "outlined",
|
|
640
640
|
size: "small",
|
|
641
|
-
onClick: () =>
|
|
641
|
+
onClick: () => o("list"),
|
|
642
642
|
sx: { mr: 1 },
|
|
643
643
|
children: "Sélectionner Liste"
|
|
644
644
|
}
|
|
@@ -648,7 +648,7 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
648
648
|
{
|
|
649
649
|
variant: "outlined",
|
|
650
650
|
size: "small",
|
|
651
|
-
onClick: () =>
|
|
651
|
+
onClick: () => o("cards"),
|
|
652
652
|
children: "Sélectionner Cartes"
|
|
653
653
|
}
|
|
654
654
|
)
|
|
@@ -667,8 +667,8 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
667
667
|
}
|
|
668
668
|
}, Q = {
|
|
669
669
|
render: () => {
|
|
670
|
-
const [
|
|
671
|
-
|
|
670
|
+
const [r, o] = u("grid"), c = f((i) => {
|
|
671
|
+
o(i);
|
|
672
672
|
}, []);
|
|
673
673
|
return /* @__PURE__ */ t(d, { sx: { p: 2 }, children: [
|
|
674
674
|
/* @__PURE__ */ e(n, { variant: "h6", gutterBottom: !0, children: "Plus d'options d'affichage" }),
|
|
@@ -676,8 +676,8 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
676
676
|
/* @__PURE__ */ e(
|
|
677
677
|
m,
|
|
678
678
|
{
|
|
679
|
-
|
|
680
|
-
viewMode:
|
|
679
|
+
buttonList: M,
|
|
680
|
+
viewMode: r,
|
|
681
681
|
onChange: c,
|
|
682
682
|
colorVariant: "secondary",
|
|
683
683
|
size: "large"
|
|
@@ -685,9 +685,9 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
685
685
|
),
|
|
686
686
|
/* @__PURE__ */ t(n, { variant: "body2", sx: { mt: 2 }, children: [
|
|
687
687
|
"Vue actuelle: ",
|
|
688
|
-
/* @__PURE__ */ e("strong", { children:
|
|
688
|
+
/* @__PURE__ */ e("strong", { children: r })
|
|
689
689
|
] }),
|
|
690
|
-
/* @__PURE__ */ e(n, { variant: "body2", color: "text.secondary", sx: { mt: 1 }, children: "Cet exemple montre un
|
|
690
|
+
/* @__PURE__ */ e(n, { variant: "body2", color: "text.secondary", sx: { mt: 1 }, children: "Cet exemple montre un ButtonGroup avec 5 options différentes en variante secondary et taille large" })
|
|
691
691
|
] })
|
|
692
692
|
] });
|
|
693
693
|
},
|
|
@@ -702,19 +702,19 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
702
702
|
}
|
|
703
703
|
}, X = {
|
|
704
704
|
render: () => {
|
|
705
|
-
const [
|
|
706
|
-
console.log("Changement de vue:", a),
|
|
707
|
-
}, []), i =
|
|
708
|
-
console.log("Changement externe:", a),
|
|
705
|
+
const [r, o] = u("cards"), c = f((a) => {
|
|
706
|
+
console.log("Changement de vue:", a), o(a);
|
|
707
|
+
}, []), i = f((a) => {
|
|
708
|
+
console.log("Changement externe:", a), o(a);
|
|
709
709
|
}, []);
|
|
710
710
|
return /* @__PURE__ */ t(d, { sx: { p: 2 }, children: [
|
|
711
711
|
/* @__PURE__ */ e(n, { variant: "h6", gutterBottom: !0, children: "Synchronisation avec d'autres composants" }),
|
|
712
712
|
/* @__PURE__ */ t(n, { variant: "subtitle1", gutterBottom: !0, children: [
|
|
713
713
|
"Vue actuelle: ",
|
|
714
|
-
/* @__PURE__ */ e("strong", { children:
|
|
714
|
+
/* @__PURE__ */ e("strong", { children: r })
|
|
715
715
|
] }),
|
|
716
716
|
/* @__PURE__ */ e(n, { variant: "body2", color: "text.secondary", paragraph: !0, children: (() => {
|
|
717
|
-
switch (
|
|
717
|
+
switch (r) {
|
|
718
718
|
case "cards":
|
|
719
719
|
return "Affichage en cartes - Idéal pour une vue d'ensemble visuelle";
|
|
720
720
|
case "table":
|
|
@@ -727,12 +727,12 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
727
727
|
})() }),
|
|
728
728
|
/* @__PURE__ */ t(l, { container: !0, spacing: 3, children: [
|
|
729
729
|
/* @__PURE__ */ e(l, { size: { xs: 12, md: 6 }, children: /* @__PURE__ */ t(s, { sx: { p: 2 }, children: [
|
|
730
|
-
/* @__PURE__ */ e(n, { variant: "subtitle1", gutterBottom: !0, children: "
|
|
730
|
+
/* @__PURE__ */ e(n, { variant: "subtitle1", gutterBottom: !0, children: "ButtonGroup Principal" }),
|
|
731
731
|
/* @__PURE__ */ e(
|
|
732
732
|
m,
|
|
733
733
|
{
|
|
734
|
-
|
|
735
|
-
viewMode:
|
|
734
|
+
buttonList: x,
|
|
735
|
+
viewMode: r,
|
|
736
736
|
onChange: c,
|
|
737
737
|
size: "medium"
|
|
738
738
|
}
|
|
@@ -743,7 +743,7 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
743
743
|
/* @__PURE__ */ e(d, { sx: { display: "flex", flexDirection: "column", gap: 1 }, children: x.map((a) => /* @__PURE__ */ t(
|
|
744
744
|
y,
|
|
745
745
|
{
|
|
746
|
-
variant:
|
|
746
|
+
variant: r === a.value ? "contained" : "outlined",
|
|
747
747
|
onClick: () => i(a.value),
|
|
748
748
|
size: "small",
|
|
749
749
|
startIcon: a.icon,
|
|
@@ -778,7 +778,7 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
778
778
|
size: "small",
|
|
779
779
|
onClick: () => {
|
|
780
780
|
const v = (x.findIndex(
|
|
781
|
-
(
|
|
781
|
+
(b) => b.value === r
|
|
782
782
|
) + 1) % x.length;
|
|
783
783
|
i(x[v].value);
|
|
784
784
|
},
|
|
@@ -793,25 +793,25 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
793
793
|
actions: { disable: !0 },
|
|
794
794
|
docs: {
|
|
795
795
|
description: {
|
|
796
|
-
story: "Démonstration de la synchronisation entre le
|
|
796
|
+
story: "Démonstration de la synchronisation entre le ButtonGroup et d'autres composants. Cette story montre comment le ButtonGroup peut être intégré dans une interface complexe où la sélection peut provenir de différentes sources mais reste synchronisée."
|
|
797
797
|
}
|
|
798
798
|
}
|
|
799
799
|
}
|
|
800
800
|
}, Y = {
|
|
801
801
|
render: () => {
|
|
802
|
-
const
|
|
803
|
-
{ value: "overview", icon: /* @__PURE__ */ e(
|
|
804
|
-
{ value: "detailed", icon: /* @__PURE__ */ e(
|
|
805
|
-
{ value: "analytics", icon: /* @__PURE__ */ e(
|
|
806
|
-
],
|
|
807
|
-
{ value: "grid", icon: /* @__PURE__ */ e(
|
|
808
|
-
{ value: "list", icon: /* @__PURE__ */ e(
|
|
809
|
-
{ value: "tree", icon: /* @__PURE__ */ e(
|
|
802
|
+
const r = [
|
|
803
|
+
{ value: "overview", icon: /* @__PURE__ */ e(S, {}) },
|
|
804
|
+
{ value: "detailed", icon: /* @__PURE__ */ e(w, {}) },
|
|
805
|
+
{ value: "analytics", icon: /* @__PURE__ */ e(T, {}) }
|
|
806
|
+
], o = [
|
|
807
|
+
{ value: "grid", icon: /* @__PURE__ */ e(T, {}) },
|
|
808
|
+
{ value: "list", icon: /* @__PURE__ */ e(V, {}) },
|
|
809
|
+
{ value: "tree", icon: /* @__PURE__ */ e(z, {}) }
|
|
810
810
|
], c = [
|
|
811
811
|
{ value: "chart", icon: /* @__PURE__ */ e(I, {}) },
|
|
812
|
-
{ value: "table", icon: /* @__PURE__ */ e(
|
|
813
|
-
{ value: "raw", icon: /* @__PURE__ */ e(
|
|
814
|
-
], [i, h] = u("overview"), [a, v] = u("grid"), [
|
|
812
|
+
{ value: "table", icon: /* @__PURE__ */ e(w, {}) },
|
|
813
|
+
{ value: "raw", icon: /* @__PURE__ */ e(V, {}), disabled: !0 }
|
|
814
|
+
], [i, h] = u("overview"), [a, v] = u("grid"), [b, g] = u("chart");
|
|
815
815
|
return /* @__PURE__ */ t(d, { sx: { p: 2 }, children: [
|
|
816
816
|
/* @__PURE__ */ e(n, { variant: "h6", gutterBottom: !0, children: "Cas d'utilisation dans une interface complexe" }),
|
|
817
817
|
/* @__PURE__ */ t(l, { container: !0, spacing: 3, children: [
|
|
@@ -820,7 +820,7 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
820
820
|
/* @__PURE__ */ e(
|
|
821
821
|
m,
|
|
822
822
|
{
|
|
823
|
-
|
|
823
|
+
buttonList: r,
|
|
824
824
|
viewMode: i,
|
|
825
825
|
onChange: (p) => h(p),
|
|
826
826
|
colorVariant: "primary",
|
|
@@ -838,7 +838,7 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
838
838
|
/* @__PURE__ */ e(
|
|
839
839
|
m,
|
|
840
840
|
{
|
|
841
|
-
|
|
841
|
+
buttonList: o,
|
|
842
842
|
viewMode: a,
|
|
843
843
|
onChange: (p) => v(p),
|
|
844
844
|
colorVariant: "secondary",
|
|
@@ -855,16 +855,16 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
855
855
|
/* @__PURE__ */ e(
|
|
856
856
|
m,
|
|
857
857
|
{
|
|
858
|
-
|
|
859
|
-
viewMode:
|
|
860
|
-
onChange: (p) =>
|
|
858
|
+
buttonList: c,
|
|
859
|
+
viewMode: b,
|
|
860
|
+
onChange: (p) => g(p),
|
|
861
861
|
colorVariant: "primary",
|
|
862
862
|
size: "large"
|
|
863
863
|
}
|
|
864
864
|
),
|
|
865
865
|
/* @__PURE__ */ t(n, { variant: "body2", sx: { mt: 2 }, children: [
|
|
866
866
|
"Format: ",
|
|
867
|
-
|
|
867
|
+
b
|
|
868
868
|
] }),
|
|
869
869
|
/* @__PURE__ */ e(n, { variant: "caption", color: "text.secondary", children: '(Le mode "raw" est temporairement désactivé)' })
|
|
870
870
|
] }) })
|
|
@@ -887,7 +887,7 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
887
887
|
" ",
|
|
888
888
|
/* @__PURE__ */ e("strong", { children: a }),
|
|
889
889
|
" | Données: ",
|
|
890
|
-
/* @__PURE__ */ e("strong", { children:
|
|
890
|
+
/* @__PURE__ */ e("strong", { children: b })
|
|
891
891
|
] })
|
|
892
892
|
]
|
|
893
893
|
}
|
|
@@ -927,32 +927,32 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
927
927
|
actions: { disable: !0 },
|
|
928
928
|
docs: {
|
|
929
929
|
description: {
|
|
930
|
-
story: "Exemple d'utilisation complexe montrant comment le
|
|
930
|
+
story: "Exemple d'utilisation complexe montrant comment le ButtonGroup peut être utilisé dans différents contextes au sein d'une même interface, avec différentes configurations (tailles, couleurs, orientations) selon le besoin. Chaque instance a son propre type inféré automatiquement."
|
|
931
931
|
}
|
|
932
932
|
}
|
|
933
933
|
}
|
|
934
934
|
}, Z = {
|
|
935
935
|
render: () => {
|
|
936
|
-
const
|
|
936
|
+
const r = {
|
|
937
937
|
CARDS: "cards",
|
|
938
938
|
TABLE: "table",
|
|
939
939
|
LIST: "list"
|
|
940
|
-
},
|
|
941
|
-
r
|
|
942
|
-
r
|
|
943
|
-
r
|
|
940
|
+
}, o = (C, L, D = !1) => ({ value: C, icon: L, disabled: D }), c = [
|
|
941
|
+
o(r.CARDS, /* @__PURE__ */ e(z, {})),
|
|
942
|
+
o(r.TABLE, /* @__PURE__ */ e(w, {})),
|
|
943
|
+
o(r.LIST, /* @__PURE__ */ e(V, {}))
|
|
944
944
|
], i = [
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
945
|
+
o("dashboard", /* @__PURE__ */ e(T, {})),
|
|
946
|
+
o("users", /* @__PURE__ */ e(S, {})),
|
|
947
|
+
o("settings", /* @__PURE__ */ e(I, {})),
|
|
948
|
+
o("logs", /* @__PURE__ */ e(V, {}), !0)
|
|
949
949
|
// désactivé
|
|
950
950
|
], [h, a] = u(
|
|
951
|
-
|
|
952
|
-
), [v,
|
|
951
|
+
r.CARDS
|
|
952
|
+
), [v, b] = u("dashboard"), g = f((C) => {
|
|
953
953
|
console.log("Vue commune changée:", C), a(C);
|
|
954
|
-
}, []), p =
|
|
955
|
-
console.log("Vue admin changée:", C),
|
|
954
|
+
}, []), p = f((C) => {
|
|
955
|
+
console.log("Vue admin changée:", C), b(C);
|
|
956
956
|
}, []);
|
|
957
957
|
return /* @__PURE__ */ t(d, { sx: { p: 2 }, children: [
|
|
958
958
|
/* @__PURE__ */ e(n, { variant: "h6", gutterBottom: !0, children: "🚀 Bonnes pratiques pour le typage" }),
|
|
@@ -972,9 +972,9 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
972
972
|
/* @__PURE__ */ e(
|
|
973
973
|
m,
|
|
974
974
|
{
|
|
975
|
-
|
|
975
|
+
buttonList: c,
|
|
976
976
|
viewMode: h,
|
|
977
|
-
onChange:
|
|
977
|
+
onChange: g,
|
|
978
978
|
size: "medium"
|
|
979
979
|
}
|
|
980
980
|
),
|
|
@@ -998,7 +998,7 @@ const createViewButton = <T extends string>(value: T, icon: ReactNode) =>
|
|
|
998
998
|
/* @__PURE__ */ e(
|
|
999
999
|
m,
|
|
1000
1000
|
{
|
|
1001
|
-
|
|
1001
|
+
buttonList: i,
|
|
1002
1002
|
viewMode: v,
|
|
1003
1003
|
onChange: p,
|
|
1004
1004
|
colorVariant: "secondary",
|
|
@@ -1073,8 +1073,8 @@ const handleChange = useCallback((value: ViewType) => {
|
|
|
1073
1073
|
"pre",
|
|
1074
1074
|
{
|
|
1075
1075
|
style: { margin: 0, fontSize: "0.875rem", overflow: "auto" },
|
|
1076
|
-
children: `<
|
|
1077
|
-
|
|
1076
|
+
children: `<ButtonGroup
|
|
1077
|
+
buttonList={buttons}
|
|
1078
1078
|
viewMode={view}
|
|
1079
1079
|
onChange={handleChange} // ← Pas de type 'any' !
|
|
1080
1080
|
/>`
|
|
@@ -1114,7 +1114,7 @@ const handleChange = useCallback((value: ViewType) => {
|
|
|
1114
1114
|
actions: { disable: !0 },
|
|
1115
1115
|
docs: {
|
|
1116
1116
|
description: {
|
|
1117
|
-
story: "Cette story présente les meilleures pratiques pour utiliser le
|
|
1117
|
+
story: "Cette story présente les meilleures pratiques pour utiliser le ButtonGroup avec un typage TypeScript optimal. Elle montre comment structurer votre code pour éviter les types 'any' et maximiser la sécurité de type."
|
|
1118
1118
|
}
|
|
1119
1119
|
}
|
|
1120
1120
|
}
|
|
@@ -1131,5 +1131,5 @@ export {
|
|
|
1131
1131
|
$ as TaillesDifferentes,
|
|
1132
1132
|
W as TypageGenerique,
|
|
1133
1133
|
_ as VariantesDecouleurs,
|
|
1134
|
-
|
|
1134
|
+
F as default
|
|
1135
1135
|
};
|