@cgi-learning-hub/ui 1.4.0-dev.1742031677 → 1.4.0-dev.1742033609
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/{CustomTreeItem-GHUeoYTN.cjs → CustomTreeItem-dmAy1wfu.cjs} +3 -3
- package/dist/{CustomTreeItem-CyfVhVMC.js → CustomTreeItem-kFMLEWpp.js} +88 -87
- package/dist/components/TreeView/TreeView.cjs.js +7 -7
- package/dist/components/TreeView/TreeView.es.js +291 -292
- package/dist/components/TreeView/components/CustomTreeItem.cjs.js +1 -1
- package/dist/components/TreeView/components/CustomTreeItem.d.ts +1 -2
- package/dist/components/TreeView/components/CustomTreeItem.es.js +3 -3
- package/dist/components/TreeView/style.cjs.js +1 -1
- package/dist/components/TreeView/style.d.ts +1 -0
- package/dist/components/TreeView/style.es.js +7 -6
- package/dist/components/stories/TreeView.stories.cjs.js +30 -2
- package/dist/components/stories/TreeView.stories.d.ts +1 -0
- package/dist/components/stories/TreeView.stories.es.js +309 -147
- package/package.json +1 -1
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { c as
|
|
3
|
-
import { useState as p, useCallback as
|
|
4
|
-
import
|
|
5
|
-
import { ICON_TYPE as
|
|
6
|
-
import { B as
|
|
7
|
-
import { T as
|
|
8
|
-
import { G as
|
|
9
|
-
import { P as
|
|
10
|
-
import { B as
|
|
11
|
-
import { D as
|
|
12
|
-
import { L } from "../../List-BTPrBGqY.js";
|
|
13
|
-
import { L as
|
|
14
|
-
const
|
|
1
|
+
import { jsx as e, jsxs as s } from "react/jsx-runtime";
|
|
2
|
+
import { c as x } from "../../createSvgIcon-B62eln-G.js";
|
|
3
|
+
import { useState as p, useCallback as R } from "react";
|
|
4
|
+
import I from "../TreeView/TreeView.es.js";
|
|
5
|
+
import { ICON_TYPE as r } from "../TreeView/types.es.js";
|
|
6
|
+
import { B as a } from "../../Box-GMNejc_m.js";
|
|
7
|
+
import { T as c } from "../../Typography-Ct2Sc9KM.js";
|
|
8
|
+
import { G as h, L as V, a as F } from "../../ListItemText-B_hEVsaT.js";
|
|
9
|
+
import { P as T } from "../../Paper-BrsaeLlu.js";
|
|
10
|
+
import { B as k } from "../../Button-x5rtZxJN.js";
|
|
11
|
+
import { D as q } from "../../Divider-CNGfzZqD.js";
|
|
12
|
+
import { L as H } from "../../List-BTPrBGqY.js";
|
|
13
|
+
import { L as A } from "../../ListItem-C9OfYRAP.js";
|
|
14
|
+
const O = x(/* @__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"), P = x(/* @__PURE__ */ e("path", {
|
|
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"), B = x(/* @__PURE__ */ e("path", {
|
|
17
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"
|
|
18
|
-
}), "Person"),
|
|
20
|
+
}), "Person"), re = {
|
|
19
21
|
title: "Components/TreeView",
|
|
20
|
-
component:
|
|
22
|
+
component: I,
|
|
21
23
|
argTypes: {
|
|
22
24
|
items: {
|
|
23
25
|
description: "**[Requis]** Liste des éléments à afficher dans le TreeView.",
|
|
@@ -79,6 +81,15 @@ Vous pouvez également passer directement un composant SvgIcon comme valeur de \
|
|
|
79
81
|
- \`handleSelectedItemChange\`: Permet de réagir quand un utilisateur clique sur un élément
|
|
80
82
|
- \`selectedItemId\`: Permet de définir l'élément sélectionné
|
|
81
83
|
|
|
84
|
+
### Gestion du Drag and Drop
|
|
85
|
+
|
|
86
|
+
Le TreeView inclut des attributs \`data-\` qui vous permettent d'identifier facilement les éléments lors d'opérations de glisser-déposer :
|
|
87
|
+
- \`data-treeview-root="true"\` : Identifie la racine du TreeView
|
|
88
|
+
- \`data-treeview-item="itemId"\` : Contient l'ID de l'élément
|
|
89
|
+
- \`data-treeview-item-label="label"\` : Contient le libellé de l'élément
|
|
90
|
+
|
|
91
|
+
Pour gérer le drop, ajoutez des gestionnaires d'événements au niveau du conteneur parent et utilisez \`event.target.closest('[data-treeview-item]')\` pour identifier l'élément cible.
|
|
92
|
+
|
|
82
93
|
### Structure des données
|
|
83
94
|
|
|
84
95
|
Le composant attend un tableau d'objets \`CustomTreeViewItem\` qui étend l'interface \`TreeViewBaseItem\` de MUI:
|
|
@@ -97,159 +108,185 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
97
108
|
}
|
|
98
109
|
}
|
|
99
110
|
}
|
|
100
|
-
},
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
(
|
|
111
|
+
}, C = (n) => {
|
|
112
|
+
const i = [], l = (o) => {
|
|
113
|
+
i.push(o), o.children && o.children.forEach(
|
|
114
|
+
(t) => l(t)
|
|
104
115
|
);
|
|
105
116
|
};
|
|
106
|
-
return n.forEach((
|
|
107
|
-
},
|
|
117
|
+
return n.forEach((o) => l(o)), i;
|
|
118
|
+
}, Y = ({
|
|
108
119
|
items: n,
|
|
109
|
-
selectedItemId:
|
|
110
|
-
onItemSelect:
|
|
120
|
+
selectedItemId: i,
|
|
121
|
+
onItemSelect: l
|
|
111
122
|
}) => {
|
|
112
|
-
const
|
|
113
|
-
return /* @__PURE__ */
|
|
114
|
-
/* @__PURE__ */ e(
|
|
115
|
-
/* @__PURE__ */ e(
|
|
116
|
-
/* @__PURE__ */ e(
|
|
117
|
-
|
|
123
|
+
const o = C(n);
|
|
124
|
+
return /* @__PURE__ */ s(T, { sx: { width: "100%", maxHeight: 300, overflow: "auto" }, children: [
|
|
125
|
+
/* @__PURE__ */ e(c, { variant: "h6", sx: { p: 2 }, children: "Sélection externe" }),
|
|
126
|
+
/* @__PURE__ */ e(q, {}),
|
|
127
|
+
/* @__PURE__ */ e(H, { children: o.map((t) => /* @__PURE__ */ e(A, { disablePadding: !0, children: /* @__PURE__ */ e(
|
|
128
|
+
V,
|
|
118
129
|
{
|
|
119
|
-
selected:
|
|
120
|
-
onClick: () =>
|
|
121
|
-
children: /* @__PURE__ */ e(
|
|
130
|
+
selected: i === t.internalId,
|
|
131
|
+
onClick: () => l(t.internalId),
|
|
132
|
+
children: /* @__PURE__ */ e(F, { primary: t.label })
|
|
122
133
|
}
|
|
123
|
-
) },
|
|
134
|
+
) }, t.internalId)) })
|
|
124
135
|
] });
|
|
125
|
-
},
|
|
136
|
+
}, z = ({
|
|
126
137
|
items: n,
|
|
127
|
-
onRandomSelect:
|
|
138
|
+
onRandomSelect: i
|
|
128
139
|
}) => {
|
|
129
|
-
const
|
|
130
|
-
return /* @__PURE__ */ e(
|
|
131
|
-
const
|
|
132
|
-
|
|
140
|
+
const l = C(n);
|
|
141
|
+
return /* @__PURE__ */ e(a, { sx: { mt: 2, mb: 2 }, children: /* @__PURE__ */ e(k, { variant: "contained", color: "primary", onClick: () => {
|
|
142
|
+
const t = Math.floor(Math.random() * l.length);
|
|
143
|
+
i(l[t].internalId);
|
|
133
144
|
}, children: "Sélection aléatoire" }) });
|
|
134
|
-
},
|
|
145
|
+
}, M = ({ id: n, label: i }) => /* @__PURE__ */ e(
|
|
146
|
+
a,
|
|
147
|
+
{
|
|
148
|
+
draggable: !0,
|
|
149
|
+
onDragStart: (l) => {
|
|
150
|
+
l.dataTransfer.setData(
|
|
151
|
+
"application/json",
|
|
152
|
+
JSON.stringify({ id: n, label: i })
|
|
153
|
+
);
|
|
154
|
+
},
|
|
155
|
+
sx: {
|
|
156
|
+
padding: 1,
|
|
157
|
+
margin: 1,
|
|
158
|
+
backgroundColor: "grey.100",
|
|
159
|
+
borderRadius: 1,
|
|
160
|
+
display: "inline-block",
|
|
161
|
+
cursor: "grab",
|
|
162
|
+
"&:hover": {
|
|
163
|
+
backgroundColor: "grey.200"
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
children: /* @__PURE__ */ s(c, { variant: "body2", display: "flex", alignItems: "center", children: [
|
|
167
|
+
/* @__PURE__ */ e(P, { fontSize: "small", sx: { mr: 1 } }),
|
|
168
|
+
i
|
|
169
|
+
] })
|
|
170
|
+
}
|
|
171
|
+
), g = [
|
|
135
172
|
{
|
|
136
173
|
internalId: "documents",
|
|
137
174
|
label: "Mes formulaires",
|
|
138
|
-
iconType:
|
|
175
|
+
iconType: r.FOLDER,
|
|
139
176
|
children: [
|
|
140
177
|
{
|
|
141
178
|
internalId: "folder1",
|
|
142
179
|
label: "Premier dossier",
|
|
143
|
-
iconType:
|
|
180
|
+
iconType: r.FOLDER,
|
|
144
181
|
children: [
|
|
145
182
|
{
|
|
146
183
|
internalId: "subfolder1",
|
|
147
184
|
label: "Sous-dossier 1",
|
|
148
|
-
iconType:
|
|
185
|
+
iconType: r.FOLDER
|
|
149
186
|
},
|
|
150
187
|
{
|
|
151
188
|
internalId: "subfolder2",
|
|
152
189
|
label: "Sous-dossier 2",
|
|
153
|
-
iconType:
|
|
190
|
+
iconType: r.FOLDER
|
|
154
191
|
}
|
|
155
192
|
]
|
|
156
193
|
},
|
|
157
194
|
{
|
|
158
195
|
internalId: "folder2",
|
|
159
196
|
label: "Deuxième dossier",
|
|
160
|
-
iconType:
|
|
197
|
+
iconType: r.FOLDER
|
|
161
198
|
},
|
|
162
199
|
{
|
|
163
200
|
internalId: "folder3",
|
|
164
201
|
label: "Troisième dossier",
|
|
165
|
-
iconType:
|
|
202
|
+
iconType: r.FOLDER
|
|
166
203
|
}
|
|
167
204
|
]
|
|
168
205
|
},
|
|
169
206
|
{
|
|
170
207
|
internalId: "shared",
|
|
171
208
|
label: "Formulaires partagés avec moi",
|
|
172
|
-
iconType:
|
|
209
|
+
iconType: r.SHARE
|
|
173
210
|
},
|
|
174
211
|
{
|
|
175
212
|
internalId: "trash",
|
|
176
213
|
label: "Corbeille",
|
|
177
|
-
iconType:
|
|
214
|
+
iconType: r.TRASH
|
|
178
215
|
}
|
|
179
|
-
],
|
|
216
|
+
], N = [
|
|
180
217
|
{
|
|
181
218
|
internalId: "bookmarks",
|
|
182
219
|
label: "Favoris",
|
|
183
|
-
iconType:
|
|
220
|
+
iconType: O,
|
|
184
221
|
children: [
|
|
185
222
|
{
|
|
186
223
|
internalId: "important",
|
|
187
224
|
label: "Important",
|
|
188
|
-
iconType:
|
|
189
|
-
customIcon:
|
|
225
|
+
iconType: r.CUSTOM,
|
|
226
|
+
customIcon: B
|
|
190
227
|
}
|
|
191
228
|
]
|
|
192
229
|
},
|
|
193
|
-
...
|
|
194
|
-
],
|
|
230
|
+
...g
|
|
231
|
+
], y = [
|
|
195
232
|
{
|
|
196
233
|
internalId: "documents",
|
|
197
234
|
label: "Documents",
|
|
198
|
-
iconType:
|
|
235
|
+
iconType: r.SHARE,
|
|
199
236
|
children: [
|
|
200
237
|
{
|
|
201
238
|
internalId: "reports",
|
|
202
239
|
label: "Rapports",
|
|
203
|
-
iconType:
|
|
240
|
+
iconType: r.FOLDER,
|
|
204
241
|
children: [
|
|
205
242
|
{
|
|
206
243
|
internalId: "report1",
|
|
207
244
|
label: "Rapport Janvier",
|
|
208
|
-
iconType:
|
|
245
|
+
iconType: r.FOLDER
|
|
209
246
|
},
|
|
210
247
|
{
|
|
211
248
|
internalId: "report2",
|
|
212
249
|
label: "Rapport Février",
|
|
213
|
-
iconType:
|
|
250
|
+
iconType: r.FOLDER
|
|
214
251
|
},
|
|
215
252
|
{
|
|
216
253
|
internalId: "report3",
|
|
217
254
|
label: "Rapport Mars",
|
|
218
|
-
iconType:
|
|
255
|
+
iconType: r.FOLDER
|
|
219
256
|
}
|
|
220
257
|
]
|
|
221
258
|
},
|
|
222
|
-
{ internalId: "invoices", label: "Factures", iconType:
|
|
259
|
+
{ internalId: "invoices", label: "Factures", iconType: r.FOLDER }
|
|
223
260
|
]
|
|
224
261
|
},
|
|
225
262
|
{
|
|
226
263
|
internalId: "media",
|
|
227
264
|
label: "Médias",
|
|
228
|
-
iconType:
|
|
265
|
+
iconType: r.FOLDER,
|
|
229
266
|
children: [
|
|
230
|
-
{ internalId: "images", label: "Images", iconType:
|
|
231
|
-
{ internalId: "videos", label: "Vidéos", iconType:
|
|
267
|
+
{ internalId: "images", label: "Images", iconType: r.FOLDER },
|
|
268
|
+
{ internalId: "videos", label: "Vidéos", iconType: r.FOLDER }
|
|
232
269
|
]
|
|
233
270
|
},
|
|
234
271
|
{
|
|
235
272
|
internalId: "downloads",
|
|
236
273
|
label: "Téléchargements",
|
|
237
|
-
iconType:
|
|
274
|
+
iconType: r.FOLDER
|
|
238
275
|
}
|
|
239
|
-
],
|
|
276
|
+
], ne = {
|
|
240
277
|
render: () => {
|
|
241
|
-
const [n,
|
|
242
|
-
(
|
|
243
|
-
console.log(`Élément sélectionné: ${
|
|
278
|
+
const [n, i] = p(""), l = R(
|
|
279
|
+
(o, t) => {
|
|
280
|
+
console.log(`Élément sélectionné: ${t}`), t && i(t);
|
|
244
281
|
},
|
|
245
282
|
[]
|
|
246
283
|
);
|
|
247
|
-
return /* @__PURE__ */ e(
|
|
248
|
-
|
|
284
|
+
return /* @__PURE__ */ e(a, { sx: { maxWidth: 300, overflowY: "hidden" }, children: /* @__PURE__ */ e(
|
|
285
|
+
I,
|
|
249
286
|
{
|
|
250
|
-
items:
|
|
287
|
+
items: g,
|
|
251
288
|
selectedItemId: n,
|
|
252
|
-
handleSelectedItemChange:
|
|
289
|
+
handleSelectedItemChange: l
|
|
253
290
|
}
|
|
254
291
|
) });
|
|
255
292
|
},
|
|
@@ -262,16 +299,16 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
262
299
|
}
|
|
263
300
|
}
|
|
264
301
|
}
|
|
265
|
-
},
|
|
302
|
+
}, oe = {
|
|
266
303
|
args: {
|
|
267
|
-
items:
|
|
304
|
+
items: g,
|
|
268
305
|
selectedItemId: "folder1",
|
|
269
|
-
handleSelectedItemChange: (n,
|
|
270
|
-
console.log(`Élément sélectionné: ${
|
|
306
|
+
handleSelectedItemChange: (n, i) => {
|
|
307
|
+
console.log(`Élément sélectionné: ${i}`);
|
|
271
308
|
},
|
|
272
309
|
iconColor: "success"
|
|
273
310
|
},
|
|
274
|
-
render: (n) => /* @__PURE__ */ e(
|
|
311
|
+
render: (n) => /* @__PURE__ */ e(a, { sx: { maxWidth: 300, overflowY: "hidden" }, children: /* @__PURE__ */ e(I, { ...n }) }),
|
|
275
312
|
parameters: {
|
|
276
313
|
docs: {
|
|
277
314
|
description: {
|
|
@@ -279,20 +316,20 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
279
316
|
}
|
|
280
317
|
}
|
|
281
318
|
}
|
|
282
|
-
},
|
|
319
|
+
}, ie = {
|
|
283
320
|
render: () => {
|
|
284
|
-
const [n,
|
|
285
|
-
(
|
|
286
|
-
console.log(`Élément sélectionné: ${
|
|
321
|
+
const [n, i] = p("bookmarks"), l = R(
|
|
322
|
+
(o, t) => {
|
|
323
|
+
console.log(`Élément sélectionné: ${t}`), t && i(t);
|
|
287
324
|
},
|
|
288
325
|
[]
|
|
289
326
|
);
|
|
290
|
-
return /* @__PURE__ */ e(
|
|
291
|
-
|
|
327
|
+
return /* @__PURE__ */ e(a, { sx: { maxWidth: 300, overflowY: "hidden" }, children: /* @__PURE__ */ e(
|
|
328
|
+
I,
|
|
292
329
|
{
|
|
293
|
-
items:
|
|
330
|
+
items: N,
|
|
294
331
|
selectedItemId: n,
|
|
295
|
-
handleSelectedItemChange:
|
|
332
|
+
handleSelectedItemChange: l
|
|
296
333
|
}
|
|
297
334
|
) });
|
|
298
335
|
},
|
|
@@ -305,63 +342,63 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
305
342
|
}
|
|
306
343
|
}
|
|
307
344
|
}
|
|
308
|
-
},
|
|
345
|
+
}, le = {
|
|
309
346
|
render: () => {
|
|
310
347
|
const n = [
|
|
311
348
|
{
|
|
312
349
|
internalId: "root",
|
|
313
350
|
label: "Structure imbriquée complexe",
|
|
314
|
-
iconType:
|
|
351
|
+
iconType: r.FOLDER,
|
|
315
352
|
children: [
|
|
316
353
|
{
|
|
317
354
|
internalId: "level1-1",
|
|
318
355
|
label: "Niveau 1.1",
|
|
319
|
-
iconType:
|
|
356
|
+
iconType: r.FOLDER,
|
|
320
357
|
children: [
|
|
321
358
|
{
|
|
322
359
|
internalId: "level2-1",
|
|
323
360
|
label: "Niveau 2.1",
|
|
324
|
-
iconType:
|
|
361
|
+
iconType: r.FOLDER,
|
|
325
362
|
children: [
|
|
326
363
|
{
|
|
327
364
|
internalId: "level3-1V",
|
|
328
365
|
label: "VOUS M'AVEZ TROUVÉ HIHIHI",
|
|
329
|
-
iconType:
|
|
366
|
+
iconType: r.FOLDER
|
|
330
367
|
},
|
|
331
368
|
{
|
|
332
369
|
internalId: "level3-2",
|
|
333
370
|
label: "Niveau 3.2",
|
|
334
|
-
iconType:
|
|
371
|
+
iconType: r.SHARE
|
|
335
372
|
}
|
|
336
373
|
]
|
|
337
374
|
},
|
|
338
375
|
{
|
|
339
376
|
internalId: "level2-2",
|
|
340
377
|
label: "Niveau 2.2",
|
|
341
|
-
iconType:
|
|
378
|
+
iconType: r.TRASH
|
|
342
379
|
}
|
|
343
380
|
]
|
|
344
381
|
},
|
|
345
382
|
{
|
|
346
383
|
internalId: "level1-2",
|
|
347
384
|
label: "Niveau 1.2",
|
|
348
|
-
iconType:
|
|
349
|
-
customIcon:
|
|
385
|
+
iconType: r.CUSTOM,
|
|
386
|
+
customIcon: O
|
|
350
387
|
}
|
|
351
388
|
]
|
|
352
389
|
}
|
|
353
|
-
], [
|
|
354
|
-
(
|
|
355
|
-
console.log(`Élément sélectionné: ${
|
|
390
|
+
], [i, l] = p("level2-1"), o = R(
|
|
391
|
+
(t, d) => {
|
|
392
|
+
console.log(`Élément sélectionné: ${d}`), d && l(d);
|
|
356
393
|
},
|
|
357
394
|
[]
|
|
358
395
|
);
|
|
359
|
-
return /* @__PURE__ */ e(
|
|
360
|
-
|
|
396
|
+
return /* @__PURE__ */ e(a, { sx: { maxWidth: 400, overflowY: "hidden" }, children: /* @__PURE__ */ e(
|
|
397
|
+
I,
|
|
361
398
|
{
|
|
362
399
|
items: n,
|
|
363
|
-
selectedItemId:
|
|
364
|
-
handleSelectedItemChange:
|
|
400
|
+
selectedItemId: i,
|
|
401
|
+
handleSelectedItemChange: o
|
|
365
402
|
}
|
|
366
403
|
) });
|
|
367
404
|
},
|
|
@@ -374,15 +411,15 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
374
411
|
}
|
|
375
412
|
}
|
|
376
413
|
}
|
|
377
|
-
},
|
|
414
|
+
}, se = {
|
|
378
415
|
render: () => {
|
|
379
|
-
const n = ["primary", "secondary", "info"], [
|
|
416
|
+
const n = ["primary", "secondary", "info"], [i, l] = p({
|
|
380
417
|
primary: "",
|
|
381
418
|
secondary: "",
|
|
382
419
|
info: ""
|
|
383
420
|
});
|
|
384
421
|
return /* @__PURE__ */ e(
|
|
385
|
-
|
|
422
|
+
a,
|
|
386
423
|
{
|
|
387
424
|
sx: {
|
|
388
425
|
display: "flex",
|
|
@@ -390,32 +427,32 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
390
427
|
gap: 3,
|
|
391
428
|
overflowY: "hidden"
|
|
392
429
|
},
|
|
393
|
-
children: n.map((
|
|
394
|
-
|
|
430
|
+
children: n.map((o) => /* @__PURE__ */ s(
|
|
431
|
+
a,
|
|
395
432
|
{
|
|
396
433
|
sx: {
|
|
397
434
|
maxWidth: 250,
|
|
398
435
|
overflowY: "hidden"
|
|
399
436
|
},
|
|
400
437
|
children: [
|
|
401
|
-
/* @__PURE__ */
|
|
438
|
+
/* @__PURE__ */ s(c, { variant: "subtitle2", gutterBottom: !0, children: [
|
|
402
439
|
"Icônes ",
|
|
403
|
-
|
|
440
|
+
o
|
|
404
441
|
] }),
|
|
405
442
|
/* @__PURE__ */ e(
|
|
406
|
-
|
|
443
|
+
I,
|
|
407
444
|
{
|
|
408
|
-
items:
|
|
409
|
-
selectedItemId: o
|
|
410
|
-
handleSelectedItemChange: (
|
|
411
|
-
|
|
445
|
+
items: g,
|
|
446
|
+
selectedItemId: i[o],
|
|
447
|
+
handleSelectedItemChange: (t, d) => {
|
|
448
|
+
d && l((m) => ({ ...m, [o]: d }));
|
|
412
449
|
},
|
|
413
|
-
iconColor:
|
|
450
|
+
iconColor: o
|
|
414
451
|
}
|
|
415
452
|
)
|
|
416
453
|
]
|
|
417
454
|
},
|
|
418
|
-
|
|
455
|
+
o
|
|
419
456
|
))
|
|
420
457
|
}
|
|
421
458
|
);
|
|
@@ -429,21 +466,21 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
429
466
|
}
|
|
430
467
|
}
|
|
431
468
|
}
|
|
432
|
-
},
|
|
469
|
+
}, ae = {
|
|
433
470
|
render: () => {
|
|
434
|
-
const [n,
|
|
435
|
-
console.log("TreeView sélection:",
|
|
436
|
-
},
|
|
437
|
-
console.log("Sélection externe:",
|
|
471
|
+
const [n, i] = p("reports"), l = (d, m) => {
|
|
472
|
+
console.log("TreeView sélection:", m), m && i(m);
|
|
473
|
+
}, o = (d) => {
|
|
474
|
+
console.log("Sélection externe:", d), i(d);
|
|
438
475
|
};
|
|
439
|
-
return /* @__PURE__ */
|
|
440
|
-
/* @__PURE__ */
|
|
476
|
+
return /* @__PURE__ */ s(a, { sx: { width: "100%", overflowY: "hidden" }, children: [
|
|
477
|
+
/* @__PURE__ */ s(c, { variant: "subtitle1", gutterBottom: !0, children: [
|
|
441
478
|
"Élément sélectionné: ",
|
|
442
479
|
/* @__PURE__ */ e("strong", { children: (() => {
|
|
443
|
-
const
|
|
444
|
-
(
|
|
480
|
+
const m = C(y).find(
|
|
481
|
+
(w) => w.internalId === n
|
|
445
482
|
);
|
|
446
|
-
return
|
|
483
|
+
return m ? m.label : "Aucun élément sélectionné";
|
|
447
484
|
})() }),
|
|
448
485
|
" (ID:",
|
|
449
486
|
" ",
|
|
@@ -451,30 +488,30 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
451
488
|
")"
|
|
452
489
|
] }),
|
|
453
490
|
/* @__PURE__ */ e(
|
|
454
|
-
|
|
491
|
+
z,
|
|
455
492
|
{
|
|
456
|
-
items:
|
|
457
|
-
onRandomSelect:
|
|
493
|
+
items: y,
|
|
494
|
+
onRandomSelect: o
|
|
458
495
|
}
|
|
459
496
|
),
|
|
460
|
-
/* @__PURE__ */
|
|
461
|
-
/* @__PURE__ */ e(
|
|
462
|
-
/* @__PURE__ */ e(
|
|
497
|
+
/* @__PURE__ */ s(h, { container: !0, spacing: 3, sx: { overflowY: "hidden" }, children: [
|
|
498
|
+
/* @__PURE__ */ e(h, { item: !0, xs: 12, md: 6, children: /* @__PURE__ */ s(T, { sx: { p: 2, overflowY: "hidden" }, children: [
|
|
499
|
+
/* @__PURE__ */ e(c, { variant: "h6", gutterBottom: !0, children: "TreeView" }),
|
|
463
500
|
/* @__PURE__ */ e(
|
|
464
|
-
|
|
501
|
+
I,
|
|
465
502
|
{
|
|
466
|
-
items:
|
|
503
|
+
items: y,
|
|
467
504
|
selectedItemId: n,
|
|
468
|
-
handleSelectedItemChange:
|
|
505
|
+
handleSelectedItemChange: l
|
|
469
506
|
}
|
|
470
507
|
)
|
|
471
508
|
] }) }),
|
|
472
|
-
/* @__PURE__ */ e(
|
|
473
|
-
|
|
509
|
+
/* @__PURE__ */ e(h, { item: !0, xs: 12, md: 6, children: /* @__PURE__ */ e(
|
|
510
|
+
Y,
|
|
474
511
|
{
|
|
475
|
-
items:
|
|
512
|
+
items: y,
|
|
476
513
|
selectedItemId: n,
|
|
477
|
-
onItemSelect:
|
|
514
|
+
onItemSelect: o
|
|
478
515
|
}
|
|
479
516
|
) })
|
|
480
517
|
] })
|
|
@@ -489,13 +526,138 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
489
526
|
}
|
|
490
527
|
}
|
|
491
528
|
}
|
|
529
|
+
}, de = {
|
|
530
|
+
render: () => {
|
|
531
|
+
var E, L;
|
|
532
|
+
const [n, i] = p([
|
|
533
|
+
...g
|
|
534
|
+
]), [l, o] = p("folder1"), [t, d] = p(null), m = [
|
|
535
|
+
{ id: "doc1", label: "Document 1" },
|
|
536
|
+
{ id: "doc2", label: "Document 2" },
|
|
537
|
+
{ id: "doc3", label: "Document 3" }
|
|
538
|
+
], w = (u) => {
|
|
539
|
+
u.preventDefault();
|
|
540
|
+
const b = u.target, D = b.closest("[data-treeview-item]");
|
|
541
|
+
let f = null, S = null;
|
|
542
|
+
D ? (f = D.getAttribute("data-treeview-item"), S = D.getAttribute("data-treeview-item-label")) : b.closest("[data-treeview-root]") && (f = null, S = "Racine du TreeView");
|
|
543
|
+
try {
|
|
544
|
+
const v = JSON.parse(u.dataTransfer.getData("application/json"));
|
|
545
|
+
d({
|
|
546
|
+
itemId: f,
|
|
547
|
+
itemLabel: S,
|
|
548
|
+
droppedItem: v
|
|
549
|
+
}), f && o(f);
|
|
550
|
+
} catch (v) {
|
|
551
|
+
console.error("Erreur lors de la récupération des données", v);
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
return /* @__PURE__ */ s(a, { sx: { maxWidth: 700, overflowY: "hidden" }, children: [
|
|
555
|
+
/* @__PURE__ */ e(c, { variant: "h6", gutterBottom: !0, children: "Exemple de Drag & Drop avec le TreeView" }),
|
|
556
|
+
/* @__PURE__ */ e(c, { variant: "body2", gutterBottom: !0, children: "Glissez-déposez un des documents ci-dessous sur un élément du TreeView." }),
|
|
557
|
+
/* @__PURE__ */ e(a, { sx: { display: "flex", mb: 2 }, children: m.map((u) => /* @__PURE__ */ e(M, { id: u.id, label: u.label }, u.id)) }),
|
|
558
|
+
/* @__PURE__ */ s(h, { container: !0, spacing: 3, children: [
|
|
559
|
+
/* @__PURE__ */ e(h, { item: !0, xs: 12, md: 6, children: /* @__PURE__ */ s(
|
|
560
|
+
a,
|
|
561
|
+
{
|
|
562
|
+
sx: {
|
|
563
|
+
p: 2,
|
|
564
|
+
border: "1px dashed gray",
|
|
565
|
+
borderRadius: 1,
|
|
566
|
+
minHeight: 300,
|
|
567
|
+
overflowY: "hidden",
|
|
568
|
+
backgroundColor: "background.paper"
|
|
569
|
+
},
|
|
570
|
+
onDragOver: (u) => u.preventDefault(),
|
|
571
|
+
onDrop: w,
|
|
572
|
+
children: [
|
|
573
|
+
/* @__PURE__ */ e(c, { variant: "subtitle1", gutterBottom: !0, children: "Zone de drop" }),
|
|
574
|
+
/* @__PURE__ */ e(
|
|
575
|
+
I,
|
|
576
|
+
{
|
|
577
|
+
items: n,
|
|
578
|
+
selectedItemId: l,
|
|
579
|
+
handleSelectedItemChange: (u, b) => {
|
|
580
|
+
b && o(b);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
)
|
|
584
|
+
]
|
|
585
|
+
}
|
|
586
|
+
) }),
|
|
587
|
+
/* @__PURE__ */ e(h, { item: !0, xs: 12, md: 6, children: /* @__PURE__ */ s(T, { sx: { p: 2, minHeight: 300 }, children: [
|
|
588
|
+
/* @__PURE__ */ e(c, { variant: "subtitle1", gutterBottom: !0, children: "Informations du dernier drop" }),
|
|
589
|
+
t ? /* @__PURE__ */ s(a, { children: [
|
|
590
|
+
/* @__PURE__ */ s(c, { variant: "body2", children: [
|
|
591
|
+
/* @__PURE__ */ e("strong", { children: "Élément cible :" }),
|
|
592
|
+
" ",
|
|
593
|
+
t.itemLabel,
|
|
594
|
+
" ",
|
|
595
|
+
t.itemId && `(ID: ${t.itemId})`
|
|
596
|
+
] }),
|
|
597
|
+
/* @__PURE__ */ s(c, { variant: "body2", children: [
|
|
598
|
+
/* @__PURE__ */ e("strong", { children: "Élément déposé :" }),
|
|
599
|
+
" ",
|
|
600
|
+
(E = t.droppedItem) == null ? void 0 : E.label,
|
|
601
|
+
" (ID:",
|
|
602
|
+
" ",
|
|
603
|
+
(L = t.droppedItem) == null ? void 0 : L.id,
|
|
604
|
+
")"
|
|
605
|
+
] }),
|
|
606
|
+
/* @__PURE__ */ s(a, { sx: { mt: 2 }, children: [
|
|
607
|
+
/* @__PURE__ */ e(c, { variant: "body2", children: /* @__PURE__ */ e("strong", { children: "Code pour gérer ce drop :" }) }),
|
|
608
|
+
/* @__PURE__ */ e(T, { sx: { p: 1, mt: 1, backgroundColor: "grey.100" }, children: /* @__PURE__ */ e(
|
|
609
|
+
"pre",
|
|
610
|
+
{
|
|
611
|
+
style: {
|
|
612
|
+
margin: 0,
|
|
613
|
+
fontSize: "0.8rem",
|
|
614
|
+
whiteSpace: "pre-wrap"
|
|
615
|
+
},
|
|
616
|
+
children: `// Dans votre gestionnaire d'événements
|
|
617
|
+
const handleDrop = (e) => {
|
|
618
|
+
e.preventDefault();
|
|
619
|
+
|
|
620
|
+
// Identifier l'élément cible
|
|
621
|
+
const target = e.target;
|
|
622
|
+
const treeviewItem = target.closest('[data-treeview-item]');
|
|
623
|
+
|
|
624
|
+
if (treeviewItem) {
|
|
625
|
+
const targetId = treeviewItem.getAttribute('data-treeview-item');
|
|
626
|
+
const targetLabel = treeviewItem.getAttribute('data-treeview-item-label');
|
|
627
|
+
|
|
628
|
+
// Récupérer les données de l'élément déposé
|
|
629
|
+
const droppedData = JSON.parse(e.dataTransfer.getData('application/json'));
|
|
630
|
+
|
|
631
|
+
console.log(\`Élément "\${droppedData.label}" déposé sur "\${targetLabel}"\`);
|
|
632
|
+
|
|
633
|
+
// Votre logique pour traiter le drop...
|
|
634
|
+
}
|
|
635
|
+
};`
|
|
636
|
+
}
|
|
637
|
+
) })
|
|
638
|
+
] })
|
|
639
|
+
] }) : /* @__PURE__ */ e(c, { variant: "body2", children: "Aucun élément déposé pour le moment. Glissez un document sur le TreeView pour voir les informations ici." })
|
|
640
|
+
] }) })
|
|
641
|
+
] })
|
|
642
|
+
] });
|
|
643
|
+
},
|
|
644
|
+
parameters: {
|
|
645
|
+
controls: { disable: !0 },
|
|
646
|
+
actions: { disable: !0 },
|
|
647
|
+
docs: {
|
|
648
|
+
description: {
|
|
649
|
+
story: "Cette story démontre comment utiliser les attributs `data-` du TreeView pour implémenter une fonctionnalité de drag and drop. Glissez un document sur un élément du TreeView pour voir comment accéder aux informations de l'élément cible."
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
492
653
|
};
|
|
493
654
|
export {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
655
|
+
de as AvecDragAndDrop,
|
|
656
|
+
ie as AvecIconesPersonnalisees,
|
|
657
|
+
oe as Controlable,
|
|
658
|
+
ne as Default,
|
|
659
|
+
se as OptionsDeCouleurs,
|
|
660
|
+
le as StructureImbriquee,
|
|
661
|
+
ae as Synchronicite,
|
|
662
|
+
re as default
|
|
501
663
|
};
|