@cgi-learning-hub/ui 1.4.0-dev.1742391176 → 1.4.0-dev.1742463865
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/components/TreeView/TreeView.cjs.js +7 -7
- package/dist/components/TreeView/TreeView.es.js +414 -414
- package/dist/components/TreeView/style.cjs.js +1 -1
- package/dist/components/TreeView/style.es.js +15 -10
- package/dist/components/TreeView/types.d.ts +4 -0
- package/dist/components/stories/TreeView.stories.cjs.js +9 -3
- package/dist/components/stories/TreeView.stories.d.ts +1 -0
- package/dist/components/stories/TreeView.stories.es.js +267 -144
- package/package.json +1 -1
- package/dist/components/TreeView/style.d.ts +0 -12
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { jsx as e, jsxs as s } from "react/jsx-runtime";
|
|
2
|
-
import { c as
|
|
3
|
-
import { useState as
|
|
4
|
-
import
|
|
2
|
+
import { c as E } from "../../createSvgIcon-BFqOnlgU.js";
|
|
3
|
+
import { useState as I, useCallback as C } from "react";
|
|
4
|
+
import h from "../TreeView/TreeView.es.js";
|
|
5
5
|
import { ICON_TYPE as r } from "../TreeView/types.es.js";
|
|
6
6
|
import { B as a } from "../../Box-C-j-U8SH.js";
|
|
7
|
-
import { T as
|
|
8
|
-
import { G as
|
|
9
|
-
import { P as
|
|
10
|
-
import { B as
|
|
11
|
-
import { D as
|
|
12
|
-
import { L as
|
|
13
|
-
import { L as
|
|
14
|
-
const O =
|
|
7
|
+
import { T as m } from "../../Typography-DZ11k9cZ.js";
|
|
8
|
+
import { G as b, L as q, a as H } from "../../ListItemText-CADHegDF.js";
|
|
9
|
+
import { P as v } from "../../Paper-DeL_n4k9.js";
|
|
10
|
+
import { B as L } from "../../Button-CQQdMCSm.js";
|
|
11
|
+
import { D as k } from "../../Divider-CT4XaEn6.js";
|
|
12
|
+
import { L as B } from "../../List-CFInjv2S.js";
|
|
13
|
+
import { L as $ } from "../../ListItem-BAAZxsu5.js";
|
|
14
|
+
const O = E(/* @__PURE__ */ e("path", {
|
|
15
15
|
d: "M17 3H7c-1.1 0-1.99.9-1.99 2L5 21l7-3 7 3V5c0-1.1-.9-2-2-2"
|
|
16
|
-
}), "Bookmark"),
|
|
16
|
+
}), "Bookmark"), F = E(/* @__PURE__ */ e("path", {
|
|
17
17
|
d: "M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8zm2 16H8v-2h8zm0-4H8v-2h8zm-3-5V3.5L18.5 9z"
|
|
18
|
-
}), "Description"),
|
|
18
|
+
}), "Description"), A = E(/* @__PURE__ */ e("path", {
|
|
19
19
|
d: "M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4m0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4"
|
|
20
20
|
}), "Person"), re = {
|
|
21
21
|
title: "Components/TreeView",
|
|
22
|
-
component:
|
|
22
|
+
component: h,
|
|
23
23
|
argTypes: {
|
|
24
24
|
items: {
|
|
25
25
|
description: "**[Requis]** Liste des éléments à afficher dans le TreeView.",
|
|
@@ -56,6 +56,15 @@ const O = x(/* @__PURE__ */ e("path", {
|
|
|
56
56
|
type: { summary: "string" },
|
|
57
57
|
defaultValue: { summary: "primary" }
|
|
58
58
|
}
|
|
59
|
+
},
|
|
60
|
+
height: {
|
|
61
|
+
description: "**[Optionnel]** Hauteur du TreeView avec gestion automatique du défilement.",
|
|
62
|
+
control: "number",
|
|
63
|
+
table: {
|
|
64
|
+
required: !1,
|
|
65
|
+
type: { summary: "number | string" },
|
|
66
|
+
defaultValue: { summary: "auto" }
|
|
67
|
+
}
|
|
59
68
|
}
|
|
60
69
|
},
|
|
61
70
|
parameters: {
|
|
@@ -81,6 +90,12 @@ Vous pouvez également passer directement un composant SvgIcon comme valeur de \
|
|
|
81
90
|
- \`handleSelectedItemChange\`: Permet de réagir quand un utilisateur clique sur un élément
|
|
82
91
|
- \`selectedItemId\`: Permet de définir l'élément sélectionné
|
|
83
92
|
|
|
93
|
+
### Contrôle de la hauteur et du défilement
|
|
94
|
+
|
|
95
|
+
- \`height\`: Définit une hauteur fixe pour le TreeView et active le défilement vertical automatique
|
|
96
|
+
- Accepte une valeur numérique (en pixels) ou une chaîne (par exemple "400px", "100%")
|
|
97
|
+
- Quand spécifié, le TreeView sera limité à cette hauteur et affichera une barre de défilement si nécessaire
|
|
98
|
+
|
|
84
99
|
### Gestion du Drag and Drop
|
|
85
100
|
|
|
86
101
|
Le TreeView inclut des attributs \`data-\` qui vous permettent d'identifier facilement les éléments lors d'opérations de glisser-déposer :
|
|
@@ -108,48 +123,48 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
108
123
|
}
|
|
109
124
|
}
|
|
110
125
|
}
|
|
111
|
-
},
|
|
112
|
-
const
|
|
113
|
-
|
|
126
|
+
}, V = (i) => {
|
|
127
|
+
const o = [], l = (n) => {
|
|
128
|
+
o.push(n), n.children && n.children.forEach(
|
|
114
129
|
(t) => l(t)
|
|
115
130
|
);
|
|
116
131
|
};
|
|
117
|
-
return
|
|
118
|
-
},
|
|
119
|
-
items:
|
|
120
|
-
selectedItemId:
|
|
132
|
+
return i.forEach((n) => l(n)), o;
|
|
133
|
+
}, P = ({
|
|
134
|
+
items: i,
|
|
135
|
+
selectedItemId: o,
|
|
121
136
|
onItemSelect: l
|
|
122
137
|
}) => {
|
|
123
|
-
const
|
|
124
|
-
return /* @__PURE__ */ s(
|
|
125
|
-
/* @__PURE__ */ e(
|
|
126
|
-
/* @__PURE__ */ e(
|
|
127
|
-
/* @__PURE__ */ e(
|
|
128
|
-
|
|
138
|
+
const n = V(i);
|
|
139
|
+
return /* @__PURE__ */ s(v, { sx: { width: "100%", maxHeight: 300, overflow: "auto" }, children: [
|
|
140
|
+
/* @__PURE__ */ e(m, { variant: "h6", sx: { p: 2 }, children: "Sélection externe" }),
|
|
141
|
+
/* @__PURE__ */ e(k, {}),
|
|
142
|
+
/* @__PURE__ */ e(B, { children: n.map((t) => /* @__PURE__ */ e($, { disablePadding: !0, children: /* @__PURE__ */ e(
|
|
143
|
+
q,
|
|
129
144
|
{
|
|
130
|
-
selected:
|
|
145
|
+
selected: o === t.internalId,
|
|
131
146
|
onClick: () => l(t.internalId),
|
|
132
|
-
children: /* @__PURE__ */ e(
|
|
147
|
+
children: /* @__PURE__ */ e(H, { primary: t.label })
|
|
133
148
|
}
|
|
134
149
|
) }, t.internalId)) })
|
|
135
150
|
] });
|
|
136
|
-
},
|
|
137
|
-
items:
|
|
138
|
-
onRandomSelect:
|
|
151
|
+
}, Y = ({
|
|
152
|
+
items: i,
|
|
153
|
+
onRandomSelect: o
|
|
139
154
|
}) => {
|
|
140
|
-
const l =
|
|
141
|
-
return /* @__PURE__ */ e(a, { sx: { mt: 2, mb: 2 }, children: /* @__PURE__ */ e(
|
|
155
|
+
const l = V(i);
|
|
156
|
+
return /* @__PURE__ */ e(a, { sx: { mt: 2, mb: 2 }, children: /* @__PURE__ */ e(L, { variant: "contained", color: "primary", onClick: () => {
|
|
142
157
|
const t = Math.floor(Math.random() * l.length);
|
|
143
|
-
|
|
158
|
+
o(l[t].internalId);
|
|
144
159
|
}, children: "Sélection aléatoire" }) });
|
|
145
|
-
}, M = ({ id:
|
|
160
|
+
}, M = ({ id: i, label: o }) => /* @__PURE__ */ e(
|
|
146
161
|
a,
|
|
147
162
|
{
|
|
148
163
|
draggable: !0,
|
|
149
164
|
onDragStart: (l) => {
|
|
150
165
|
l.dataTransfer.setData(
|
|
151
166
|
"application/json",
|
|
152
|
-
JSON.stringify({ id:
|
|
167
|
+
JSON.stringify({ id: i, label: o })
|
|
153
168
|
);
|
|
154
169
|
},
|
|
155
170
|
sx: {
|
|
@@ -163,12 +178,12 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
163
178
|
backgroundColor: "grey.200"
|
|
164
179
|
}
|
|
165
180
|
},
|
|
166
|
-
children: /* @__PURE__ */ s(
|
|
167
|
-
/* @__PURE__ */ e(
|
|
168
|
-
|
|
181
|
+
children: /* @__PURE__ */ s(m, { variant: "body2", display: "flex", alignItems: "center", children: [
|
|
182
|
+
/* @__PURE__ */ e(F, { fontSize: "small", sx: { mr: 1 } }),
|
|
183
|
+
o
|
|
169
184
|
] })
|
|
170
185
|
}
|
|
171
|
-
),
|
|
186
|
+
), w = [
|
|
172
187
|
{
|
|
173
188
|
internalId: "documents",
|
|
174
189
|
label: "Mes formulaires",
|
|
@@ -213,7 +228,7 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
213
228
|
label: "Corbeille",
|
|
214
229
|
iconType: r.TRASH
|
|
215
230
|
}
|
|
216
|
-
],
|
|
231
|
+
], z = [
|
|
217
232
|
{
|
|
218
233
|
internalId: "bookmarks",
|
|
219
234
|
label: "Favoris",
|
|
@@ -223,12 +238,12 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
223
238
|
internalId: "important",
|
|
224
239
|
label: "Important",
|
|
225
240
|
iconType: r.CUSTOM,
|
|
226
|
-
customIcon:
|
|
241
|
+
customIcon: A
|
|
227
242
|
}
|
|
228
243
|
]
|
|
229
244
|
},
|
|
230
|
-
...
|
|
231
|
-
],
|
|
245
|
+
...w
|
|
246
|
+
], S = [
|
|
232
247
|
{
|
|
233
248
|
internalId: "documents",
|
|
234
249
|
label: "Documents",
|
|
@@ -275,17 +290,17 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
275
290
|
}
|
|
276
291
|
], ne = {
|
|
277
292
|
render: () => {
|
|
278
|
-
const [
|
|
279
|
-
(
|
|
280
|
-
console.log(`Élément sélectionné: ${t}`), t &&
|
|
293
|
+
const [i, o] = I(""), l = C(
|
|
294
|
+
(n, t) => {
|
|
295
|
+
console.log(`Élément sélectionné: ${t}`), t && o(t);
|
|
281
296
|
},
|
|
282
297
|
[]
|
|
283
298
|
);
|
|
284
299
|
return /* @__PURE__ */ e(a, { sx: { maxWidth: 300, overflowY: "hidden" }, children: /* @__PURE__ */ e(
|
|
285
|
-
|
|
300
|
+
h,
|
|
286
301
|
{
|
|
287
|
-
items:
|
|
288
|
-
selectedItemId:
|
|
302
|
+
items: w,
|
|
303
|
+
selectedItemId: i,
|
|
289
304
|
handleSelectedItemChange: l
|
|
290
305
|
}
|
|
291
306
|
) });
|
|
@@ -299,16 +314,16 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
299
314
|
}
|
|
300
315
|
}
|
|
301
316
|
}
|
|
302
|
-
},
|
|
317
|
+
}, ie = {
|
|
303
318
|
args: {
|
|
304
|
-
items:
|
|
319
|
+
items: w,
|
|
305
320
|
selectedItemId: "folder1",
|
|
306
|
-
handleSelectedItemChange: (
|
|
307
|
-
console.log(`Élément sélectionné: ${
|
|
321
|
+
handleSelectedItemChange: (i, o) => {
|
|
322
|
+
console.log(`Élément sélectionné: ${o}`);
|
|
308
323
|
},
|
|
309
324
|
iconColor: "success"
|
|
310
325
|
},
|
|
311
|
-
render: (
|
|
326
|
+
render: (i) => /* @__PURE__ */ e(a, { sx: { maxWidth: 300, overflowY: "hidden" }, children: /* @__PURE__ */ e(h, { ...i }) }),
|
|
312
327
|
parameters: {
|
|
313
328
|
docs: {
|
|
314
329
|
description: {
|
|
@@ -316,19 +331,19 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
316
331
|
}
|
|
317
332
|
}
|
|
318
333
|
}
|
|
319
|
-
},
|
|
334
|
+
}, oe = {
|
|
320
335
|
render: () => {
|
|
321
|
-
const [
|
|
322
|
-
(
|
|
323
|
-
console.log(`Élément sélectionné: ${t}`), t &&
|
|
336
|
+
const [i, o] = I("bookmarks"), l = C(
|
|
337
|
+
(n, t) => {
|
|
338
|
+
console.log(`Élément sélectionné: ${t}`), t && o(t);
|
|
324
339
|
},
|
|
325
340
|
[]
|
|
326
341
|
);
|
|
327
342
|
return /* @__PURE__ */ e(a, { sx: { maxWidth: 300, overflowY: "hidden" }, children: /* @__PURE__ */ e(
|
|
328
|
-
|
|
343
|
+
h,
|
|
329
344
|
{
|
|
330
|
-
items:
|
|
331
|
-
selectedItemId:
|
|
345
|
+
items: z,
|
|
346
|
+
selectedItemId: i,
|
|
332
347
|
handleSelectedItemChange: l
|
|
333
348
|
}
|
|
334
349
|
) });
|
|
@@ -344,7 +359,7 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
344
359
|
}
|
|
345
360
|
}, le = {
|
|
346
361
|
render: () => {
|
|
347
|
-
const
|
|
362
|
+
const i = [
|
|
348
363
|
{
|
|
349
364
|
internalId: "root",
|
|
350
365
|
label: "Structure imbriquée complexe",
|
|
@@ -387,18 +402,18 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
387
402
|
}
|
|
388
403
|
]
|
|
389
404
|
}
|
|
390
|
-
], [
|
|
405
|
+
], [o, l] = I("level2-1"), n = C(
|
|
391
406
|
(t, d) => {
|
|
392
407
|
console.log(`Élément sélectionné: ${d}`), d && l(d);
|
|
393
408
|
},
|
|
394
409
|
[]
|
|
395
410
|
);
|
|
396
411
|
return /* @__PURE__ */ e(a, { sx: { maxWidth: 400, overflowY: "hidden" }, children: /* @__PURE__ */ e(
|
|
397
|
-
|
|
412
|
+
h,
|
|
398
413
|
{
|
|
399
|
-
items:
|
|
400
|
-
selectedItemId:
|
|
401
|
-
handleSelectedItemChange:
|
|
414
|
+
items: i,
|
|
415
|
+
selectedItemId: o,
|
|
416
|
+
handleSelectedItemChange: n
|
|
402
417
|
}
|
|
403
418
|
) });
|
|
404
419
|
},
|
|
@@ -413,7 +428,7 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
413
428
|
}
|
|
414
429
|
}, se = {
|
|
415
430
|
render: () => {
|
|
416
|
-
const
|
|
431
|
+
const i = ["primary", "secondary", "info"], [o, l] = I({
|
|
417
432
|
primary: "",
|
|
418
433
|
secondary: "",
|
|
419
434
|
info: ""
|
|
@@ -427,7 +442,7 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
427
442
|
gap: 3,
|
|
428
443
|
overflowY: "hidden"
|
|
429
444
|
},
|
|
430
|
-
children:
|
|
445
|
+
children: i.map((n) => /* @__PURE__ */ s(
|
|
431
446
|
a,
|
|
432
447
|
{
|
|
433
448
|
sx: {
|
|
@@ -435,24 +450,24 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
435
450
|
overflowY: "hidden"
|
|
436
451
|
},
|
|
437
452
|
children: [
|
|
438
|
-
/* @__PURE__ */ s(
|
|
453
|
+
/* @__PURE__ */ s(m, { variant: "subtitle2", gutterBottom: !0, children: [
|
|
439
454
|
"Icônes ",
|
|
440
|
-
|
|
455
|
+
n
|
|
441
456
|
] }),
|
|
442
457
|
/* @__PURE__ */ e(
|
|
443
|
-
|
|
458
|
+
h,
|
|
444
459
|
{
|
|
445
|
-
items:
|
|
446
|
-
selectedItemId:
|
|
460
|
+
items: w,
|
|
461
|
+
selectedItemId: o[n],
|
|
447
462
|
handleSelectedItemChange: (t, d) => {
|
|
448
|
-
d && l((
|
|
463
|
+
d && l((u) => ({ ...u, [n]: d }));
|
|
449
464
|
},
|
|
450
|
-
iconColor:
|
|
465
|
+
iconColor: n
|
|
451
466
|
}
|
|
452
467
|
)
|
|
453
468
|
]
|
|
454
469
|
},
|
|
455
|
-
|
|
470
|
+
n
|
|
456
471
|
))
|
|
457
472
|
}
|
|
458
473
|
);
|
|
@@ -468,50 +483,157 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
468
483
|
}
|
|
469
484
|
}, ae = {
|
|
470
485
|
render: () => {
|
|
471
|
-
const
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
486
|
+
const i = () => {
|
|
487
|
+
var u, y;
|
|
488
|
+
const d = [];
|
|
489
|
+
for (let p = 1; p <= 5; p++) {
|
|
490
|
+
const T = {
|
|
491
|
+
internalId: `main-folder-${p}`,
|
|
492
|
+
label: `Dossier principal ${p}`,
|
|
493
|
+
iconType: r.FOLDER,
|
|
494
|
+
children: []
|
|
495
|
+
};
|
|
496
|
+
for (let c = 1; c <= 10; c++) {
|
|
497
|
+
const f = {
|
|
498
|
+
internalId: `subfolder-${p}-${c}`,
|
|
499
|
+
label: `Sous-dossier ${p}.${c}`,
|
|
500
|
+
iconType: r.FOLDER,
|
|
501
|
+
children: []
|
|
502
|
+
};
|
|
503
|
+
for (let g = 1; g <= 5; g++)
|
|
504
|
+
(u = f.children) == null || u.push({
|
|
505
|
+
internalId: `item-${p}-${c}-${g}`,
|
|
506
|
+
label: `Élément ${p}.${c}.${g}`,
|
|
507
|
+
iconType: r.CUSTOM,
|
|
508
|
+
customIcon: F
|
|
509
|
+
});
|
|
510
|
+
(y = T.children) == null || y.push(f);
|
|
511
|
+
}
|
|
512
|
+
d.push(T);
|
|
513
|
+
}
|
|
514
|
+
return d;
|
|
515
|
+
}, [o, l] = I(""), n = i(), t = C(
|
|
516
|
+
(d, u) => {
|
|
517
|
+
u && l(u);
|
|
518
|
+
},
|
|
519
|
+
[]
|
|
520
|
+
);
|
|
521
|
+
return /* @__PURE__ */ s(a, { children: [
|
|
522
|
+
/* @__PURE__ */ e(m, { variant: "h6", gutterBottom: !0, children: "TreeView avec hauteur limitée et défilement vertical" }),
|
|
523
|
+
/* @__PURE__ */ s(b, { container: !0, spacing: 3, children: [
|
|
524
|
+
/* @__PURE__ */ e(b, { item: !0, xs: 12, md: 6, children: /* @__PURE__ */ s(v, { sx: { p: 2 }, children: [
|
|
525
|
+
/* @__PURE__ */ e(m, { variant: "subtitle2", gutterBottom: !0, children: "Hauteur de 300px avec overflow" }),
|
|
526
|
+
/* @__PURE__ */ e(a, { sx: { border: "1px solid #e0e0e0", borderRadius: 1 }, children: /* @__PURE__ */ e(
|
|
527
|
+
h,
|
|
528
|
+
{
|
|
529
|
+
items: n,
|
|
530
|
+
selectedItemId: o,
|
|
531
|
+
handleSelectedItemChange: t,
|
|
532
|
+
height: 300
|
|
533
|
+
}
|
|
534
|
+
) })
|
|
535
|
+
] }) }),
|
|
536
|
+
/* @__PURE__ */ e(b, { item: !0, xs: 12, md: 6, children: /* @__PURE__ */ s(v, { sx: { p: 2 }, children: [
|
|
537
|
+
/* @__PURE__ */ e(m, { variant: "subtitle2", gutterBottom: !0, children: "Hauteur de 500px avec overflow" }),
|
|
538
|
+
/* @__PURE__ */ e(a, { sx: { border: "1px solid #e0e0e0", borderRadius: 1 }, children: /* @__PURE__ */ e(
|
|
539
|
+
h,
|
|
540
|
+
{
|
|
541
|
+
items: n,
|
|
542
|
+
selectedItemId: o,
|
|
543
|
+
handleSelectedItemChange: t,
|
|
544
|
+
height: 500
|
|
545
|
+
}
|
|
546
|
+
) })
|
|
547
|
+
] }) })
|
|
548
|
+
] }),
|
|
549
|
+
/* @__PURE__ */ e(a, { mt: 4, children: /* @__PURE__ */ s(v, { sx: { p: 2 }, children: [
|
|
550
|
+
/* @__PURE__ */ e(m, { variant: "subtitle2", gutterBottom: !0, children: "TreeView expansé manuellement" }),
|
|
551
|
+
/* @__PURE__ */ s(a, { sx: { display: "flex", mb: 2 }, children: [
|
|
552
|
+
/* @__PURE__ */ e(
|
|
553
|
+
L,
|
|
554
|
+
{
|
|
555
|
+
variant: "outlined",
|
|
556
|
+
onClick: () => l("subfolder-1-1"),
|
|
557
|
+
sx: { mr: 1 },
|
|
558
|
+
children: "Sélectionner Sous-dossier 1.1"
|
|
559
|
+
}
|
|
560
|
+
),
|
|
561
|
+
/* @__PURE__ */ e(
|
|
562
|
+
L,
|
|
563
|
+
{
|
|
564
|
+
variant: "outlined",
|
|
565
|
+
onClick: () => l("item-3-5-2"),
|
|
566
|
+
children: "Sélectionner Élément 3.5.2"
|
|
567
|
+
}
|
|
568
|
+
)
|
|
569
|
+
] }),
|
|
570
|
+
/* @__PURE__ */ e(a, { sx: { borderRadius: 1 }, children: /* @__PURE__ */ e(
|
|
571
|
+
h,
|
|
572
|
+
{
|
|
573
|
+
items: n,
|
|
574
|
+
selectedItemId: o,
|
|
575
|
+
handleSelectedItemChange: t,
|
|
576
|
+
height: 400
|
|
577
|
+
}
|
|
578
|
+
) })
|
|
579
|
+
] }) })
|
|
580
|
+
] });
|
|
581
|
+
},
|
|
582
|
+
parameters: {
|
|
583
|
+
controls: { disable: !0 },
|
|
584
|
+
actions: { disable: !0 },
|
|
585
|
+
docs: {
|
|
586
|
+
description: {
|
|
587
|
+
story: "Cette story démontre l'utilisation de la prop `height` pour contrôler la hauteur du TreeView. Elle permet de vérifier le comportement du défilement (overflow) lorsque le contenu dépasse la hauteur définie. Différentes hauteurs sont utilisées pour voir l'impact sur l'expérience utilisateur."
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}, de = {
|
|
592
|
+
render: () => {
|
|
593
|
+
const [i, o] = I("reports"), l = (d, u) => {
|
|
594
|
+
console.log("TreeView sélection:", u), u && o(u);
|
|
595
|
+
}, n = (d) => {
|
|
596
|
+
console.log("Sélection externe:", d), o(d);
|
|
475
597
|
};
|
|
476
598
|
return /* @__PURE__ */ s(a, { sx: { width: "100%", overflowY: "hidden" }, children: [
|
|
477
|
-
/* @__PURE__ */ s(
|
|
599
|
+
/* @__PURE__ */ s(m, { variant: "subtitle1", gutterBottom: !0, children: [
|
|
478
600
|
"Élément sélectionné: ",
|
|
479
601
|
/* @__PURE__ */ e("strong", { children: (() => {
|
|
480
|
-
const
|
|
481
|
-
(
|
|
602
|
+
const u = V(S).find(
|
|
603
|
+
(y) => y.internalId === i
|
|
482
604
|
);
|
|
483
|
-
return
|
|
605
|
+
return u ? u.label : "Aucun élément sélectionné";
|
|
484
606
|
})() }),
|
|
485
607
|
" (ID:",
|
|
486
608
|
" ",
|
|
487
|
-
|
|
609
|
+
i,
|
|
488
610
|
")"
|
|
489
611
|
] }),
|
|
490
612
|
/* @__PURE__ */ e(
|
|
491
|
-
|
|
613
|
+
Y,
|
|
492
614
|
{
|
|
493
|
-
items:
|
|
494
|
-
onRandomSelect:
|
|
615
|
+
items: S,
|
|
616
|
+
onRandomSelect: n
|
|
495
617
|
}
|
|
496
618
|
),
|
|
497
|
-
/* @__PURE__ */ s(
|
|
498
|
-
/* @__PURE__ */ e(
|
|
499
|
-
/* @__PURE__ */ e(
|
|
619
|
+
/* @__PURE__ */ s(b, { container: !0, spacing: 3, sx: { overflowY: "hidden" }, children: [
|
|
620
|
+
/* @__PURE__ */ e(b, { item: !0, xs: 12, md: 6, children: /* @__PURE__ */ s(v, { sx: { p: 2, overflowY: "hidden" }, children: [
|
|
621
|
+
/* @__PURE__ */ e(m, { variant: "h6", gutterBottom: !0, children: "TreeView" }),
|
|
500
622
|
/* @__PURE__ */ e(
|
|
501
|
-
|
|
623
|
+
h,
|
|
502
624
|
{
|
|
503
|
-
items:
|
|
504
|
-
selectedItemId:
|
|
625
|
+
items: S,
|
|
626
|
+
selectedItemId: i,
|
|
505
627
|
handleSelectedItemChange: l
|
|
506
628
|
}
|
|
507
629
|
)
|
|
508
630
|
] }) }),
|
|
509
|
-
/* @__PURE__ */ e(
|
|
510
|
-
|
|
631
|
+
/* @__PURE__ */ e(b, { item: !0, xs: 12, md: 6, children: /* @__PURE__ */ e(
|
|
632
|
+
P,
|
|
511
633
|
{
|
|
512
|
-
items:
|
|
513
|
-
selectedItemId:
|
|
514
|
-
onItemSelect:
|
|
634
|
+
items: S,
|
|
635
|
+
selectedItemId: i,
|
|
636
|
+
onItemSelect: n
|
|
515
637
|
}
|
|
516
638
|
) })
|
|
517
639
|
] })
|
|
@@ -526,37 +648,37 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
526
648
|
}
|
|
527
649
|
}
|
|
528
650
|
}
|
|
529
|
-
},
|
|
651
|
+
}, ce = {
|
|
530
652
|
render: () => {
|
|
531
|
-
var
|
|
532
|
-
const [
|
|
533
|
-
...
|
|
534
|
-
]), [l,
|
|
653
|
+
var p, T;
|
|
654
|
+
const [i, o] = I([
|
|
655
|
+
...w
|
|
656
|
+
]), [l, n] = I("folder1"), [t, d] = I(null), u = [
|
|
535
657
|
{ id: "doc1", label: "Document 1" },
|
|
536
658
|
{ id: "doc2", label: "Document 2" },
|
|
537
659
|
{ id: "doc3", label: "Document 3" }
|
|
538
|
-
],
|
|
539
|
-
|
|
540
|
-
const
|
|
541
|
-
let
|
|
542
|
-
|
|
660
|
+
], y = (c) => {
|
|
661
|
+
c.preventDefault();
|
|
662
|
+
const f = c.target, g = f.closest("[data-treeview-item]");
|
|
663
|
+
let x = null, R = null;
|
|
664
|
+
g ? (x = g.getAttribute("data-treeview-item"), R = g.getAttribute("data-treeview-item-label")) : f.closest("[data-treeview-root]") && (x = null, R = "Racine du TreeView");
|
|
543
665
|
try {
|
|
544
|
-
const
|
|
666
|
+
const D = JSON.parse(c.dataTransfer.getData("application/json"));
|
|
545
667
|
d({
|
|
546
|
-
itemId:
|
|
547
|
-
itemLabel:
|
|
548
|
-
droppedItem:
|
|
549
|
-
}),
|
|
550
|
-
} catch (
|
|
551
|
-
console.error("Erreur lors de la récupération des données",
|
|
668
|
+
itemId: x,
|
|
669
|
+
itemLabel: R,
|
|
670
|
+
droppedItem: D
|
|
671
|
+
}), x && n(x);
|
|
672
|
+
} catch (D) {
|
|
673
|
+
console.error("Erreur lors de la récupération des données", D);
|
|
552
674
|
}
|
|
553
675
|
};
|
|
554
676
|
return /* @__PURE__ */ s(a, { sx: { maxWidth: 700, overflowY: "hidden" }, children: [
|
|
555
|
-
/* @__PURE__ */ e(
|
|
556
|
-
/* @__PURE__ */ e(
|
|
557
|
-
/* @__PURE__ */ e(a, { sx: { display: "flex", mb: 2 }, children:
|
|
558
|
-
/* @__PURE__ */ s(
|
|
559
|
-
/* @__PURE__ */ e(
|
|
677
|
+
/* @__PURE__ */ e(m, { variant: "h6", gutterBottom: !0, children: "Exemple de Drag & Drop avec le TreeView" }),
|
|
678
|
+
/* @__PURE__ */ e(m, { variant: "body2", gutterBottom: !0, children: "Glissez-déposez un des documents ci-dessous sur un élément du TreeView." }),
|
|
679
|
+
/* @__PURE__ */ e(a, { sx: { display: "flex", mb: 2 }, children: u.map((c) => /* @__PURE__ */ e(M, { id: c.id, label: c.label }, c.id)) }),
|
|
680
|
+
/* @__PURE__ */ s(b, { container: !0, spacing: 3, children: [
|
|
681
|
+
/* @__PURE__ */ e(b, { item: !0, xs: 12, md: 6, children: /* @__PURE__ */ s(
|
|
560
682
|
a,
|
|
561
683
|
{
|
|
562
684
|
sx: {
|
|
@@ -567,45 +689,45 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
567
689
|
overflowY: "hidden",
|
|
568
690
|
backgroundColor: "background.paper"
|
|
569
691
|
},
|
|
570
|
-
onDragOver: (
|
|
571
|
-
onDrop:
|
|
692
|
+
onDragOver: (c) => c.preventDefault(),
|
|
693
|
+
onDrop: y,
|
|
572
694
|
children: [
|
|
573
|
-
/* @__PURE__ */ e(
|
|
695
|
+
/* @__PURE__ */ e(m, { variant: "subtitle1", gutterBottom: !0, children: "Zone de drop" }),
|
|
574
696
|
/* @__PURE__ */ e(
|
|
575
|
-
|
|
697
|
+
h,
|
|
576
698
|
{
|
|
577
|
-
items:
|
|
699
|
+
items: i,
|
|
578
700
|
selectedItemId: l,
|
|
579
|
-
handleSelectedItemChange: (
|
|
580
|
-
|
|
701
|
+
handleSelectedItemChange: (c, f) => {
|
|
702
|
+
f && n(f);
|
|
581
703
|
}
|
|
582
704
|
}
|
|
583
705
|
)
|
|
584
706
|
]
|
|
585
707
|
}
|
|
586
708
|
) }),
|
|
587
|
-
/* @__PURE__ */ e(
|
|
588
|
-
/* @__PURE__ */ e(
|
|
709
|
+
/* @__PURE__ */ e(b, { item: !0, xs: 12, md: 6, children: /* @__PURE__ */ s(v, { sx: { p: 2, minHeight: 300 }, children: [
|
|
710
|
+
/* @__PURE__ */ e(m, { variant: "subtitle1", gutterBottom: !0, children: "Informations du dernier drop" }),
|
|
589
711
|
t ? /* @__PURE__ */ s(a, { children: [
|
|
590
|
-
/* @__PURE__ */ s(
|
|
712
|
+
/* @__PURE__ */ s(m, { variant: "body2", children: [
|
|
591
713
|
/* @__PURE__ */ e("strong", { children: "Élément cible :" }),
|
|
592
714
|
" ",
|
|
593
715
|
t.itemLabel,
|
|
594
716
|
" ",
|
|
595
717
|
t.itemId && `(ID: ${t.itemId})`
|
|
596
718
|
] }),
|
|
597
|
-
/* @__PURE__ */ s(
|
|
719
|
+
/* @__PURE__ */ s(m, { variant: "body2", children: [
|
|
598
720
|
/* @__PURE__ */ e("strong", { children: "Élément déposé :" }),
|
|
599
721
|
" ",
|
|
600
|
-
(
|
|
722
|
+
(p = t.droppedItem) == null ? void 0 : p.label,
|
|
601
723
|
" (ID:",
|
|
602
724
|
" ",
|
|
603
|
-
(
|
|
725
|
+
(T = t.droppedItem) == null ? void 0 : T.id,
|
|
604
726
|
")"
|
|
605
727
|
] }),
|
|
606
728
|
/* @__PURE__ */ s(a, { sx: { mt: 2 }, children: [
|
|
607
|
-
/* @__PURE__ */ e(
|
|
608
|
-
/* @__PURE__ */ e(
|
|
729
|
+
/* @__PURE__ */ e(m, { variant: "body2", children: /* @__PURE__ */ e("strong", { children: "Code pour gérer ce drop :" }) }),
|
|
730
|
+
/* @__PURE__ */ e(v, { sx: { p: 1, mt: 1, backgroundColor: "grey.100" }, children: /* @__PURE__ */ e(
|
|
609
731
|
"pre",
|
|
610
732
|
{
|
|
611
733
|
style: {
|
|
@@ -636,7 +758,7 @@ const handleDrop = (e) => {
|
|
|
636
758
|
}
|
|
637
759
|
) })
|
|
638
760
|
] })
|
|
639
|
-
] }) : /* @__PURE__ */ e(
|
|
761
|
+
] }) : /* @__PURE__ */ e(m, { variant: "body2", children: "Aucun élément déposé pour le moment. Glissez un document sur le TreeView pour voir les informations ici." })
|
|
640
762
|
] }) })
|
|
641
763
|
] })
|
|
642
764
|
] });
|
|
@@ -652,12 +774,13 @@ const handleDrop = (e) => {
|
|
|
652
774
|
}
|
|
653
775
|
};
|
|
654
776
|
export {
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
777
|
+
ce as AvecDragAndDrop,
|
|
778
|
+
oe as AvecIconesPersonnalisees,
|
|
779
|
+
ie as Controlable,
|
|
658
780
|
ne as Default,
|
|
781
|
+
ae as GrandeHauteurLimitee,
|
|
659
782
|
se as OptionsDeCouleurs,
|
|
660
783
|
le as StructureImbriquee,
|
|
661
|
-
|
|
784
|
+
de as Synchronicite,
|
|
662
785
|
re as default
|
|
663
786
|
};
|