@cgi-learning-hub/ui 1.4.0-dev.1741976077 → 1.4.0-dev.1741982096
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 +9 -9
- package/dist/components/TreeView/TreeView.d.ts +2 -1
- package/dist/components/TreeView/TreeView.es.js +579 -533
- package/dist/components/stories/TreeView.stories.cjs.js +4 -4
- package/dist/components/stories/TreeView.stories.d.ts +2 -1
- package/dist/components/stories/TreeView.stories.es.js +143 -55
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),m=require("../../createSvgIcon-DJMYlO0S.cjs"),l=require("react"),e=require("../TreeView/TreeView.cjs.js"),a=require("../../Box-DYA49L7w.cjs"),d=require("../../Typography-DPij13XT.cjs"),p=m.createSvgIcon(t.jsx("path",{d:"M17 3H7c-1.1 0-1.99.9-1.99 2L5 21l7-3 7 3V5c0-1.1-.9-2-2-2"}),"Bookmark"),T=m.createSvgIcon(t.jsx("path",{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"}),"Person"),y={title:"Components/TreeView",component:e.default,argTypes:{items:{description:"Liste des éléments à afficher dans le TreeView.",control:"object",table:{type:{summary:"CustomTreeViewItem[]"}}},selectedItemId:{description:"Identifiant de l'élément sélectionné.",control:"text",table:{type:{summary:"string"}}},handleSelectedItemChange:{description:"Fonction appelée lorsqu'un élément est sélectionné.",table:{type:{summary:"(event: React.SyntheticEvent, itemIds: string | null) => void"}}},iconColor:{description:"Couleur des icônes.",control:"select",options:["primary","secondary","success","error","info","warning"],defaultValue:"primary",table:{type:{summary:"string"},defaultValue:{summary:"primary"}}}},parameters:{docs:{description:{component:`
|
|
2
2
|
## TreeView
|
|
3
3
|
|
|
4
4
|
Un composant pour afficher des données hiérarchiques sous forme d'arborescence.
|
|
@@ -15,8 +15,8 @@ Vous pouvez également passer directement un composant SvgIcon comme valeur de \
|
|
|
15
15
|
|
|
16
16
|
### Navigation et sélection
|
|
17
17
|
|
|
18
|
-
- \`
|
|
19
|
-
- \`
|
|
18
|
+
- \`handleSelectedItemChange\`: Permet de réagir quand un utilisateur clique sur un élément
|
|
19
|
+
- \`selectedItemId\`: Permet de définir l'élément sélectionné
|
|
20
20
|
|
|
21
21
|
### Structure des données
|
|
22
22
|
|
|
@@ -32,4 +32,4 @@ interface CustomTreeViewItemProps {
|
|
|
32
32
|
|
|
33
33
|
type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
34
34
|
\`\`\`
|
|
35
|
-
`}}}},
|
|
35
|
+
`}}}},f=({items:i})=>{const[n,r]=l.useState(""),s=l.useCallback((c,o)=>{console.log(`Élément sélectionné: ${o}`),o&&r(o)},[]);return t.jsxs(a.Box,{children:[t.jsxs(d.Typography,{variant:"subtitle1",gutterBottom:!0,children:["Sélection actuelle: ",n||"Aucun élément sélectionné"]}),t.jsx(e.default,{items:i,selectedItemId:n,handleSelectedItemChange:s})]})},u=[{internalId:"documents",label:"Mes formulaires",iconType:e.ICON_TYPE.FOLDER,children:[{internalId:"folder1",label:"Premier dossier",iconType:e.ICON_TYPE.FOLDER,children:[{internalId:"subfolder1",label:"Sous-dossier 1",iconType:e.ICON_TYPE.FOLDER},{internalId:"subfolder2",label:"Sous-dossier 2",iconType:e.ICON_TYPE.FOLDER}]},{internalId:"folder2",label:"Deuxième dossier",iconType:e.ICON_TYPE.FOLDER},{internalId:"folder3",label:"Troisième dossier",iconType:e.ICON_TYPE.FOLDER}]},{internalId:"shared",label:"Formulaires partagés avec moi",iconType:e.ICON_TYPE.SHARE},{internalId:"trash",label:"Corbeille",iconType:e.ICON_TYPE.TRASH}],b=[{internalId:"bookmarks",label:"Favoris",iconType:p,children:[{internalId:"important",label:"Important",iconType:e.ICON_TYPE.CUSTOM,customIcon:T}]},...u],v={render:()=>t.jsx(f,{items:u}),parameters:{docs:{description:{story:"Exemple de base avec des icônes standard et démonstration de sélection."}}}},g={args:{items:u,selectedItemId:"folder1",handleSelectedItemChange:(i,n)=>{console.log(`Élément sélectionné: ${n}`)}},parameters:{docs:{description:{story:"Exemple avec sélection explicite d'un élément spécifique."}}}},h={render:()=>{const[i,n]=l.useState("bookmarks"),r=l.useCallback((s,c)=>{console.log(`Élément sélectionné: ${c}`),c&&n(c)},[]);return t.jsxs(a.Box,{children:[t.jsxs(d.Typography,{variant:"subtitle1",gutterBottom:!0,children:["Élément sélectionné: ",i]}),t.jsx(e.default,{items:b,selectedItemId:i,handleSelectedItemChange:r})]})},parameters:{docs:{description:{story:"Exemple utilisant à la fois des icônes prédéfinies et des icônes personnalisées avec gestion de la sélection."}}}},C={render:()=>{const i=[{internalId:"root",label:"Structure imbriquée complexe",iconType:e.ICON_TYPE.FOLDER,children:[{internalId:"level1-1",label:"Niveau 1.1",iconType:e.ICON_TYPE.FOLDER,children:[{internalId:"level2-1",label:"Niveau 2.1",iconType:e.ICON_TYPE.FOLDER,children:[{internalId:"level3-1",label:"Niveau 3.1",iconType:e.ICON_TYPE.FOLDER},{internalId:"level3-2",label:"Niveau 3.2",iconType:e.ICON_TYPE.SHARE}]},{internalId:"level2-2",label:"Niveau 2.2",iconType:e.ICON_TYPE.TRASH}]},{internalId:"level1-2",label:"Niveau 1.2",iconType:e.ICON_TYPE.CUSTOM,customIcon:p}]}],[n,r]=l.useState("level2-1"),s=l.useCallback((c,o)=>{console.log(`Élément sélectionné: ${o}`),o&&r(o)},[]);return t.jsxs(a.Box,{children:[t.jsxs(d.Typography,{variant:"subtitle1",gutterBottom:!0,children:["Niveau sélectionné: ",n]}),t.jsx(e.default,{items:i,selectedItemId:n,handleSelectedItemChange:s,iconColor:"info"})]})},parameters:{docs:{description:{story:"Exemple d'une structure profondément imbriquée avec différents types d'icônes à chaque niveau et gestion de la sélection."}}}},S={render:()=>{const i=["primary","secondary","success","error","info","warning"],[n,r]=l.useState({primary:"",secondary:"",success:"",error:"",info:"",warning:""});return t.jsx(a.Box,{sx:{display:"flex",flexDirection:"column",gap:3},children:i.map(s=>t.jsxs(a.Box,{children:[t.jsxs(d.Typography,{variant:"subtitle1",gutterBottom:!0,children:["TreeView avec icônes ",s," - Sélection:"," ",n[s]||"aucune"]}),t.jsx(e.default,{items:u,selectedItemId:n[s],handleSelectedItemChange:(c,o)=>{o&&r(I=>({...I,[s]:o}))},iconColor:s})]},s))})},parameters:{docs:{description:{story:"Démonstration des différentes options de couleurs disponibles pour les icônes avec gestion indépendante des sélections."}}}};exports.AvecIconesPersonnalisees=h;exports.Default=v;exports.MultipleColors=S;exports.StructureImbriquee=C;exports.WithExplicitSelection=g;exports.default=y;
|
|
@@ -4,6 +4,7 @@ declare const meta: Meta<typeof TreeView>;
|
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryObj<typeof TreeView>;
|
|
6
6
|
export declare const Default: Story;
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const WithExplicitSelection: Story;
|
|
8
8
|
export declare const AvecIconesPersonnalisees: Story;
|
|
9
9
|
export declare const StructureImbriquee: Story;
|
|
10
|
+
export declare const MultipleColors: Story;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsx as o, jsxs as r } from "react/jsx-runtime";
|
|
2
|
-
import { c as
|
|
3
|
-
import { useState as
|
|
4
|
-
import
|
|
5
|
-
import { B as
|
|
6
|
-
import { T } from "../../Typography-SIQ6eleU.js";
|
|
7
|
-
const
|
|
2
|
+
import { c as f } from "../../createSvgIcon-K1Hd8ryN.js";
|
|
3
|
+
import { useState as m, useCallback as I } from "react";
|
|
4
|
+
import d, { ICON_TYPE as e } from "../TreeView/TreeView.es.js";
|
|
5
|
+
import { B as a } from "../../Box-DgqaLb7j.js";
|
|
6
|
+
import { T as u } from "../../Typography-SIQ6eleU.js";
|
|
7
|
+
const y = f(/* @__PURE__ */ o("path", {
|
|
8
8
|
d: "M17 3H7c-1.1 0-1.99.9-1.99 2L5 21l7-3 7 3V5c0-1.1-.9-2-2-2"
|
|
9
|
-
}), "Bookmark"),
|
|
9
|
+
}), "Bookmark"), b = f(/* @__PURE__ */ o("path", {
|
|
10
10
|
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"
|
|
11
|
-
}), "Person"),
|
|
11
|
+
}), "Person"), V = {
|
|
12
12
|
title: "Components/TreeView",
|
|
13
|
-
component:
|
|
13
|
+
component: d,
|
|
14
14
|
argTypes: {
|
|
15
15
|
items: {
|
|
16
16
|
description: "Liste des éléments à afficher dans le TreeView.",
|
|
@@ -19,11 +19,18 @@ const c = l(/* @__PURE__ */ o("path", {
|
|
|
19
19
|
type: { summary: "CustomTreeViewItem[]" }
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
|
-
|
|
22
|
+
selectedItemId: {
|
|
23
|
+
description: "Identifiant de l'élément sélectionné.",
|
|
24
|
+
control: "text",
|
|
25
|
+
table: {
|
|
26
|
+
type: { summary: "string" }
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
handleSelectedItemChange: {
|
|
23
30
|
description: "Fonction appelée lorsqu'un élément est sélectionné.",
|
|
24
31
|
table: {
|
|
25
32
|
type: {
|
|
26
|
-
summary: "(event: React.SyntheticEvent,
|
|
33
|
+
summary: "(event: React.SyntheticEvent, itemIds: string | null) => void"
|
|
27
34
|
}
|
|
28
35
|
}
|
|
29
36
|
},
|
|
@@ -58,8 +65,8 @@ Vous pouvez également passer directement un composant SvgIcon comme valeur de \
|
|
|
58
65
|
|
|
59
66
|
### Navigation et sélection
|
|
60
67
|
|
|
61
|
-
- \`
|
|
62
|
-
- \`
|
|
68
|
+
- \`handleSelectedItemChange\`: Permet de réagir quand un utilisateur clique sur un élément
|
|
69
|
+
- \`selectedItemId\`: Permet de définir l'élément sélectionné
|
|
63
70
|
|
|
64
71
|
### Structure des données
|
|
65
72
|
|
|
@@ -79,27 +86,28 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
79
86
|
}
|
|
80
87
|
}
|
|
81
88
|
}
|
|
82
|
-
},
|
|
83
|
-
const [
|
|
84
|
-
(
|
|
85
|
-
console.log(`Élément sélectionné: ${s}`),
|
|
89
|
+
}, v = ({ items: i }) => {
|
|
90
|
+
const [t, l] = m(""), n = I(
|
|
91
|
+
(c, s) => {
|
|
92
|
+
console.log(`Élément sélectionné: ${s}`), s && l(s);
|
|
86
93
|
},
|
|
87
94
|
[]
|
|
88
95
|
);
|
|
89
|
-
return /* @__PURE__ */ r(
|
|
90
|
-
/* @__PURE__ */ r(
|
|
96
|
+
return /* @__PURE__ */ r(a, { children: [
|
|
97
|
+
/* @__PURE__ */ r(u, { variant: "subtitle1", gutterBottom: !0, children: [
|
|
91
98
|
"Sélection actuelle: ",
|
|
92
|
-
|
|
99
|
+
t || "Aucun élément sélectionné"
|
|
93
100
|
] }),
|
|
94
101
|
/* @__PURE__ */ o(
|
|
95
|
-
|
|
102
|
+
d,
|
|
96
103
|
{
|
|
97
|
-
items:
|
|
98
|
-
|
|
104
|
+
items: i,
|
|
105
|
+
selectedItemId: t,
|
|
106
|
+
handleSelectedItemChange: n
|
|
99
107
|
}
|
|
100
108
|
)
|
|
101
109
|
] });
|
|
102
|
-
},
|
|
110
|
+
}, p = [
|
|
103
111
|
{
|
|
104
112
|
internalId: "documents",
|
|
105
113
|
label: "Mes formulaires",
|
|
@@ -144,23 +152,23 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
144
152
|
label: "Corbeille",
|
|
145
153
|
iconType: e.TRASH
|
|
146
154
|
}
|
|
147
|
-
],
|
|
155
|
+
], h = [
|
|
148
156
|
{
|
|
149
157
|
internalId: "bookmarks",
|
|
150
158
|
label: "Favoris",
|
|
151
|
-
iconType:
|
|
159
|
+
iconType: y,
|
|
152
160
|
children: [
|
|
153
161
|
{
|
|
154
162
|
internalId: "important",
|
|
155
163
|
label: "Important",
|
|
156
164
|
iconType: e.CUSTOM,
|
|
157
|
-
customIcon:
|
|
165
|
+
customIcon: b
|
|
158
166
|
}
|
|
159
167
|
]
|
|
160
168
|
},
|
|
161
|
-
...
|
|
162
|
-
],
|
|
163
|
-
render: () => /* @__PURE__ */ o(
|
|
169
|
+
...p
|
|
170
|
+
], w = {
|
|
171
|
+
render: () => /* @__PURE__ */ o(v, { items: p }),
|
|
164
172
|
parameters: {
|
|
165
173
|
docs: {
|
|
166
174
|
description: {
|
|
@@ -168,37 +176,54 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
168
176
|
}
|
|
169
177
|
}
|
|
170
178
|
}
|
|
171
|
-
},
|
|
179
|
+
}, x = {
|
|
172
180
|
args: {
|
|
173
|
-
items:
|
|
174
|
-
|
|
175
|
-
|
|
181
|
+
items: p,
|
|
182
|
+
selectedItemId: "folder1",
|
|
183
|
+
handleSelectedItemChange: (i, t) => {
|
|
184
|
+
console.log(`Élément sélectionné: ${t}`);
|
|
176
185
|
}
|
|
177
186
|
},
|
|
178
187
|
parameters: {
|
|
179
188
|
docs: {
|
|
180
189
|
description: {
|
|
181
|
-
story: "Exemple avec
|
|
190
|
+
story: "Exemple avec sélection explicite d'un élément spécifique."
|
|
182
191
|
}
|
|
183
192
|
}
|
|
184
193
|
}
|
|
185
|
-
},
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
194
|
+
}, D = {
|
|
195
|
+
render: () => {
|
|
196
|
+
const [i, t] = m("bookmarks"), l = I(
|
|
197
|
+
(n, c) => {
|
|
198
|
+
console.log(`Élément sélectionné: ${c}`), c && t(c);
|
|
199
|
+
},
|
|
200
|
+
[]
|
|
201
|
+
);
|
|
202
|
+
return /* @__PURE__ */ r(a, { children: [
|
|
203
|
+
/* @__PURE__ */ r(u, { variant: "subtitle1", gutterBottom: !0, children: [
|
|
204
|
+
"Élément sélectionné: ",
|
|
205
|
+
i
|
|
206
|
+
] }),
|
|
207
|
+
/* @__PURE__ */ o(
|
|
208
|
+
d,
|
|
209
|
+
{
|
|
210
|
+
items: h,
|
|
211
|
+
selectedItemId: i,
|
|
212
|
+
handleSelectedItemChange: l
|
|
213
|
+
}
|
|
214
|
+
)
|
|
215
|
+
] });
|
|
191
216
|
},
|
|
192
217
|
parameters: {
|
|
193
218
|
docs: {
|
|
194
219
|
description: {
|
|
195
|
-
story: "Exemple utilisant à la fois des icônes prédéfinies et des icônes personnalisées."
|
|
220
|
+
story: "Exemple utilisant à la fois des icônes prédéfinies et des icônes personnalisées avec gestion de la sélection."
|
|
196
221
|
}
|
|
197
222
|
}
|
|
198
223
|
}
|
|
199
|
-
},
|
|
200
|
-
|
|
201
|
-
|
|
224
|
+
}, L = {
|
|
225
|
+
render: () => {
|
|
226
|
+
const i = [
|
|
202
227
|
{
|
|
203
228
|
internalId: "root",
|
|
204
229
|
label: "Structure imbriquée complexe",
|
|
@@ -237,27 +262,90 @@ type CustomTreeViewItem = TreeViewBaseItem<CustomTreeViewItemProps>;
|
|
|
237
262
|
internalId: "level1-2",
|
|
238
263
|
label: "Niveau 1.2",
|
|
239
264
|
iconType: e.CUSTOM,
|
|
240
|
-
customIcon:
|
|
265
|
+
customIcon: y
|
|
241
266
|
}
|
|
242
267
|
]
|
|
243
268
|
}
|
|
244
|
-
],
|
|
245
|
-
|
|
246
|
-
|
|
269
|
+
], [t, l] = m("level2-1"), n = I(
|
|
270
|
+
(c, s) => {
|
|
271
|
+
console.log(`Élément sélectionné: ${s}`), s && l(s);
|
|
272
|
+
},
|
|
273
|
+
[]
|
|
274
|
+
);
|
|
275
|
+
return /* @__PURE__ */ r(a, { children: [
|
|
276
|
+
/* @__PURE__ */ r(u, { variant: "subtitle1", gutterBottom: !0, children: [
|
|
277
|
+
"Niveau sélectionné: ",
|
|
278
|
+
t
|
|
279
|
+
] }),
|
|
280
|
+
/* @__PURE__ */ o(
|
|
281
|
+
d,
|
|
282
|
+
{
|
|
283
|
+
items: i,
|
|
284
|
+
selectedItemId: t,
|
|
285
|
+
handleSelectedItemChange: n,
|
|
286
|
+
iconColor: "info"
|
|
287
|
+
}
|
|
288
|
+
)
|
|
289
|
+
] });
|
|
290
|
+
},
|
|
291
|
+
parameters: {
|
|
292
|
+
docs: {
|
|
293
|
+
description: {
|
|
294
|
+
story: "Exemple d'une structure profondément imbriquée avec différents types d'icônes à chaque niveau et gestion de la sélection."
|
|
295
|
+
}
|
|
247
296
|
}
|
|
297
|
+
}
|
|
298
|
+
}, F = {
|
|
299
|
+
render: () => {
|
|
300
|
+
const i = [
|
|
301
|
+
"primary",
|
|
302
|
+
"secondary",
|
|
303
|
+
"success",
|
|
304
|
+
"error",
|
|
305
|
+
"info",
|
|
306
|
+
"warning"
|
|
307
|
+
], [t, l] = m({
|
|
308
|
+
primary: "",
|
|
309
|
+
secondary: "",
|
|
310
|
+
success: "",
|
|
311
|
+
error: "",
|
|
312
|
+
info: "",
|
|
313
|
+
warning: ""
|
|
314
|
+
});
|
|
315
|
+
return /* @__PURE__ */ o(a, { sx: { display: "flex", flexDirection: "column", gap: 3 }, children: i.map((n) => /* @__PURE__ */ r(a, { children: [
|
|
316
|
+
/* @__PURE__ */ r(u, { variant: "subtitle1", gutterBottom: !0, children: [
|
|
317
|
+
"TreeView avec icônes ",
|
|
318
|
+
n,
|
|
319
|
+
" - Sélection:",
|
|
320
|
+
" ",
|
|
321
|
+
t[n] || "aucune"
|
|
322
|
+
] }),
|
|
323
|
+
/* @__PURE__ */ o(
|
|
324
|
+
d,
|
|
325
|
+
{
|
|
326
|
+
items: p,
|
|
327
|
+
selectedItemId: t[n],
|
|
328
|
+
handleSelectedItemChange: (c, s) => {
|
|
329
|
+
s && l((T) => ({ ...T, [n]: s }));
|
|
330
|
+
},
|
|
331
|
+
iconColor: n
|
|
332
|
+
}
|
|
333
|
+
)
|
|
334
|
+
] }, n)) });
|
|
248
335
|
},
|
|
249
336
|
parameters: {
|
|
250
337
|
docs: {
|
|
251
338
|
description: {
|
|
252
|
-
story: "
|
|
339
|
+
story: "Démonstration des différentes options de couleurs disponibles pour les icônes avec gestion indépendante des sélections."
|
|
253
340
|
}
|
|
254
341
|
}
|
|
255
342
|
}
|
|
256
343
|
};
|
|
257
344
|
export {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
345
|
+
D as AvecIconesPersonnalisees,
|
|
346
|
+
w as Default,
|
|
347
|
+
F as MultipleColors,
|
|
348
|
+
L as StructureImbriquee,
|
|
349
|
+
x as WithExplicitSelection,
|
|
350
|
+
V as default
|
|
263
351
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cgi-learning-hub/ui",
|
|
3
|
-
"version": "1.4.0-dev.
|
|
3
|
+
"version": "1.4.0-dev.1741982096",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "CGI Learning-hub Team",
|
|
6
6
|
"description": "@cgi-learning-hub/ui is an open-source React component library that implements UI for HUB's features",
|