allaw-ui 4.1.2 → 4.1.4
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/assets/allaw-font.eot +0 -0
- package/dist/assets/allaw-font.svg +3 -2
- package/dist/assets/allaw-font.ttf +0 -0
- package/dist/assets/allaw-font.woff +0 -0
- package/dist/components/atoms/inputs/SearchBar.css +28 -2
- package/dist/components/atoms/inputs/SearchBar.d.ts +1 -0
- package/dist/components/atoms/inputs/SearchBar.js +11 -3
- package/dist/components/atoms/inputs/SearchBar.stories.d.ts +8 -0
- package/dist/components/atoms/inputs/SearchBar.stories.js +14 -1
- package/dist/components/molecules/contactCard/contactCard.module.css +0 -1
- package/dist/components/molecules/proSwitch/AvatarBubble.d.ts +16 -0
- package/dist/components/molecules/proSwitch/AvatarBubble.js +72 -0
- package/dist/components/molecules/proSwitch/AvatarBubble.stories.d.ts +93 -0
- package/dist/components/molecules/proSwitch/AvatarBubble.stories.js +215 -0
- package/dist/components/molecules/proSwitch/AvatarToggleGroup.d.ts +21 -0
- package/dist/components/molecules/proSwitch/AvatarToggleGroup.js +150 -0
- package/dist/components/molecules/proSwitch/AvatarToggleGroup.stories.d.ts +75 -0
- package/dist/components/molecules/proSwitch/AvatarToggleGroup.stories.js +276 -0
- package/dist/components/molecules/proSwitch/ProSwitch.d.ts +16 -0
- package/dist/components/molecules/proSwitch/ProSwitch.js +86 -0
- package/dist/components/molecules/proSwitch/ProSwitch.stories.d.ts +9 -0
- package/dist/components/molecules/proSwitch/ProSwitch.stories.js +144 -0
- package/dist/components/molecules/proSwitch/ProSwitchModal.d.ts +21 -0
- package/dist/components/molecules/proSwitch/ProSwitchModal.js +285 -0
- package/dist/components/molecules/proSwitch/ProSwitchModal.stories.d.ts +60 -0
- package/dist/components/molecules/proSwitch/ProSwitchModal.stories.js +194 -0
- package/dist/components/molecules/proSwitch/avatarBubble.module.css +116 -0
- package/dist/components/molecules/proSwitch/avatarToggleGroup.module.css +183 -0
- package/dist/components/molecules/proSwitch/proSwitch.module.css +32 -0
- package/dist/components/molecules/proSwitch/proSwitchModal.module.css +370 -0
- package/dist/styles/icons.css +3 -0
- package/package.json +4 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { action } from "@storybook/addon-actions";
|
|
3
|
+
import ProSwitch from "./ProSwitch";
|
|
4
|
+
export default {
|
|
5
|
+
title: "Components/Molecules/ProSwitch/ProSwitch",
|
|
6
|
+
component: ProSwitch,
|
|
7
|
+
};
|
|
8
|
+
var samplePros = [
|
|
9
|
+
{
|
|
10
|
+
token: "t1",
|
|
11
|
+
proUserId: "1",
|
|
12
|
+
name: "Dupont",
|
|
13
|
+
firstName: "Jean",
|
|
14
|
+
profilePictureLink: "https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?w=150&h=150&fit=crop&crop=face",
|
|
15
|
+
profession: "AVOCAT",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
token: "t2",
|
|
19
|
+
proUserId: "2",
|
|
20
|
+
name: "Martin",
|
|
21
|
+
firstName: "Marie",
|
|
22
|
+
profilePictureLink: "",
|
|
23
|
+
profession: "NOTAIRE",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
token: "t3",
|
|
27
|
+
proUserId: "3",
|
|
28
|
+
name: "Durand",
|
|
29
|
+
firstName: "Pierre",
|
|
30
|
+
profilePictureLink: "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=150&h=150&fit=crop&crop=face",
|
|
31
|
+
profession: "AVOCAT",
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
token: "t4",
|
|
35
|
+
proUserId: "4",
|
|
36
|
+
name: "Bernard",
|
|
37
|
+
firstName: "Sophie",
|
|
38
|
+
profilePictureLink: "",
|
|
39
|
+
profession: "COMMISSAIRE",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
token: "t5",
|
|
43
|
+
proUserId: "5",
|
|
44
|
+
name: "Petit",
|
|
45
|
+
firstName: "Lucas",
|
|
46
|
+
profilePictureLink: "https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=150&h=150&fit=crop&crop=face",
|
|
47
|
+
profession: "AVOCAT",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
token: "t6",
|
|
51
|
+
proUserId: "6",
|
|
52
|
+
name: "Rousseau",
|
|
53
|
+
firstName: "Emma",
|
|
54
|
+
profilePictureLink: "",
|
|
55
|
+
profession: "NOTAIRE",
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
token: "t7",
|
|
59
|
+
proUserId: "7",
|
|
60
|
+
name: "Leroy",
|
|
61
|
+
firstName: "François",
|
|
62
|
+
profilePictureLink: "https://images.unsplash.com/photo-1506794778202-cad84cf45f1d?w=150&h=150&fit=crop&crop=face",
|
|
63
|
+
profession: "AVOCAT",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
token: "t8",
|
|
67
|
+
proUserId: "8",
|
|
68
|
+
name: "Moreau",
|
|
69
|
+
firstName: "Alice",
|
|
70
|
+
profilePictureLink: "",
|
|
71
|
+
profession: "COMMISSAIRE",
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
token: "t9",
|
|
75
|
+
proUserId: "9",
|
|
76
|
+
name: "Girard",
|
|
77
|
+
firstName: "Paul",
|
|
78
|
+
profilePictureLink: "",
|
|
79
|
+
profession: "AVOCAT",
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
token: "t10",
|
|
83
|
+
proUserId: "10",
|
|
84
|
+
name: "Fabre",
|
|
85
|
+
firstName: "Julie",
|
|
86
|
+
profilePictureLink: "",
|
|
87
|
+
profession: "NOTAIRE",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
token: "t11",
|
|
91
|
+
proUserId: "11",
|
|
92
|
+
name: "Simon",
|
|
93
|
+
firstName: "Antoine",
|
|
94
|
+
profilePictureLink: "",
|
|
95
|
+
profession: "AVOCAT",
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
token: "t12",
|
|
99
|
+
proUserId: "12",
|
|
100
|
+
name: "Michel",
|
|
101
|
+
firstName: "Claire",
|
|
102
|
+
profilePictureLink: "",
|
|
103
|
+
profession: "COMMISSAIRE",
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
token: "t13",
|
|
107
|
+
proUserId: "13",
|
|
108
|
+
name: "Garcia",
|
|
109
|
+
firstName: "Hugo",
|
|
110
|
+
profilePictureLink: "",
|
|
111
|
+
profession: "AVOCAT",
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
token: "t14",
|
|
115
|
+
proUserId: "14",
|
|
116
|
+
name: "David",
|
|
117
|
+
firstName: "Sarah",
|
|
118
|
+
profilePictureLink: "",
|
|
119
|
+
profession: "NOTAIRE",
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
token: "t15",
|
|
123
|
+
proUserId: "15",
|
|
124
|
+
name: "Robert",
|
|
125
|
+
firstName: "Nicolas",
|
|
126
|
+
profilePictureLink: "",
|
|
127
|
+
profession: "AVOCAT",
|
|
128
|
+
},
|
|
129
|
+
];
|
|
130
|
+
export var SingleSelect = function () {
|
|
131
|
+
var _a = useState(["1"]), selected = _a[0], setSelected = _a[1];
|
|
132
|
+
return (React.createElement(ProSwitch, { pros: samplePros.slice(0, 15), selected: selected, mode: "single", onSelect: function (pros) {
|
|
133
|
+
setSelected(pros.map(function (p) { return p.proUserId; }));
|
|
134
|
+
action("onSelect")(pros);
|
|
135
|
+
}, onOrderChange: action("onOrderChange") }));
|
|
136
|
+
};
|
|
137
|
+
export var MultiSelectOverflow = function () {
|
|
138
|
+
var _a = useState(["1", "2"]), selected = _a[0], setSelected = _a[1];
|
|
139
|
+
return (React.createElement("div", { style: { width: 200 } },
|
|
140
|
+
React.createElement(ProSwitch, { pros: samplePros, selected: selected, mode: "multiple", onSelect: function (pros) {
|
|
141
|
+
setSelected(pros.map(function (p) { return p.proUserId; }));
|
|
142
|
+
action("onSelect")(pros);
|
|
143
|
+
}, onOrderChange: action("onOrderChange") })));
|
|
144
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface Pro {
|
|
3
|
+
token: string;
|
|
4
|
+
proUserId: string;
|
|
5
|
+
name: string;
|
|
6
|
+
firstName: string;
|
|
7
|
+
profilePictureLink: string;
|
|
8
|
+
profession?: string;
|
|
9
|
+
}
|
|
10
|
+
interface ProSwitchModalProps {
|
|
11
|
+
open: boolean;
|
|
12
|
+
pros: Pro[];
|
|
13
|
+
selected: string[];
|
|
14
|
+
mode: "single" | "multiple";
|
|
15
|
+
onClosePortal: () => void;
|
|
16
|
+
onOpenPortal?: () => void;
|
|
17
|
+
onOrderChange?: (pros: Pro[]) => void;
|
|
18
|
+
onSelect?: (selected: Pro[]) => void;
|
|
19
|
+
}
|
|
20
|
+
declare const ProSwitchModal: React.FC<ProSwitchModalProps>;
|
|
21
|
+
export default ProSwitchModal;
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
21
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
22
|
+
import ReactDOM from "react-dom";
|
|
23
|
+
import { DndContext, closestCenter, KeyboardSensor, PointerSensor, useSensor, useSensors, DragOverlay, } from "@dnd-kit/core";
|
|
24
|
+
import { arrayMove, SortableContext, sortableKeyboardCoordinates, rectSortingStrategy, useSortable, defaultAnimateLayoutChanges, } from "@dnd-kit/sortable";
|
|
25
|
+
import { CSS } from "@dnd-kit/utilities";
|
|
26
|
+
import AvatarBubble from "./AvatarBubble";
|
|
27
|
+
import SearchBar from "../../atoms/inputs/SearchBar";
|
|
28
|
+
import TinyInfo from "../../atoms/typography/TinyInfo";
|
|
29
|
+
import styles from "./proSwitchModal.module.css";
|
|
30
|
+
import Paragraph from "src/components/atoms/typography/Paragraph";
|
|
31
|
+
var LOCALSTORAGE_KEY = "allaw.proSwitch.order";
|
|
32
|
+
// Composant SortableItem pour wrapper chaque élément
|
|
33
|
+
var SortableItem = function (_a) {
|
|
34
|
+
var pro = _a.pro, isSelected = _a.isSelected, isReorder = _a.isReorder, onSelect = _a.onSelect, hasActiveDrag = _a.hasActiveDrag;
|
|
35
|
+
var _b = useSortable({
|
|
36
|
+
id: pro.proUserId,
|
|
37
|
+
animateLayoutChanges: defaultAnimateLayoutChanges,
|
|
38
|
+
transition: {
|
|
39
|
+
duration: 250,
|
|
40
|
+
easing: "cubic-bezier(0.25, 1, 0.5, 1)",
|
|
41
|
+
},
|
|
42
|
+
}), attributes = _b.attributes, listeners = _b.listeners, setNodeRef = _b.setNodeRef, transform = _b.transform, transition = _b.transition, sortableDragging = _b.isDragging;
|
|
43
|
+
// Console.log uniquement si transform existe et a des valeurs non-nulles
|
|
44
|
+
if (transform && (transform.x !== 0 || transform.y !== 0)) {
|
|
45
|
+
console.log("\uD83D\uDD04 ".concat(pro.firstName, ": transform=").concat(transform.x, ",").concat(transform.y));
|
|
46
|
+
}
|
|
47
|
+
var style = {
|
|
48
|
+
transform: CSS.Transform.toString(transform),
|
|
49
|
+
transition: transition,
|
|
50
|
+
};
|
|
51
|
+
var gridItemClass = [
|
|
52
|
+
styles.gridItem,
|
|
53
|
+
sortableDragging ? styles.dragging : "",
|
|
54
|
+
isReorder && !sortableDragging && !hasActiveDrag ? styles.wiggle : "",
|
|
55
|
+
]
|
|
56
|
+
.filter(Boolean)
|
|
57
|
+
.join(" ");
|
|
58
|
+
return (React.createElement("div", __assign({ ref: setNodeRef, style: style, className: gridItemClass }, (isReorder ? attributes : {}), (isReorder ? listeners : {})),
|
|
59
|
+
React.createElement("div", { className: styles.avatarWrapper },
|
|
60
|
+
React.createElement(AvatarBubble, { firstName: pro.firstName, name: pro.name, src: pro.profilePictureLink, size: 56, isSelected: isSelected, onClick: !isReorder ? function () { return onSelect(pro); } : undefined, disabled: false, disableHoverAnimation: isReorder, borderThick: true })),
|
|
61
|
+
React.createElement("div", { className: styles.name }, isSelected ? (React.createElement("strong", null,
|
|
62
|
+
pro.firstName,
|
|
63
|
+
" ",
|
|
64
|
+
pro.name)) : ("".concat(pro.firstName, " ").concat(pro.name)))));
|
|
65
|
+
};
|
|
66
|
+
var ProSwitchModal = function (_a) {
|
|
67
|
+
var open = _a.open, pros = _a.pros, selected = _a.selected, mode = _a.mode, onClosePortal = _a.onClosePortal, onOpenPortal = _a.onOpenPortal, onOrderChange = _a.onOrderChange, onSelect = _a.onSelect;
|
|
68
|
+
var _b = useState(""), search = _b[0], setSearch = _b[1];
|
|
69
|
+
var _c = useState(false), isReorder = _c[0], setIsReorder = _c[1];
|
|
70
|
+
var _d = useState([]), order = _d[0], setOrder = _d[1];
|
|
71
|
+
var _e = useState(null), draggedId = _e[0], setDraggedId = _e[1];
|
|
72
|
+
var _f = useState(null), hoveredId = _f[0], setHoveredId = _f[1];
|
|
73
|
+
var _g = useState(null), activeDragPro = _g[0], setActiveDragPro = _g[1];
|
|
74
|
+
var _h = useState(pros), filteredPros = _h[0], setFilteredPros = _h[1];
|
|
75
|
+
var modalRef = useRef(null);
|
|
76
|
+
var firstInputRef = useRef(null);
|
|
77
|
+
var _j = useState(null), reorderLabel = _j[0], setReorderLabel = _j[1];
|
|
78
|
+
// Focus trap
|
|
79
|
+
useEffect(function () {
|
|
80
|
+
if (open && firstInputRef.current) {
|
|
81
|
+
firstInputRef.current.focus();
|
|
82
|
+
}
|
|
83
|
+
if (open && onOpenPortal)
|
|
84
|
+
onOpenPortal();
|
|
85
|
+
// eslint-disable-next-line
|
|
86
|
+
}, [open]);
|
|
87
|
+
// Filtrage live
|
|
88
|
+
useEffect(function () {
|
|
89
|
+
var lower = search.trim().toLowerCase();
|
|
90
|
+
var filtered = pros.filter(function (p) {
|
|
91
|
+
return p.firstName.toLowerCase().includes(lower) ||
|
|
92
|
+
p.name.toLowerCase().includes(lower);
|
|
93
|
+
});
|
|
94
|
+
setFilteredPros(filtered);
|
|
95
|
+
}, [search, pros]);
|
|
96
|
+
// Initial order from localStorage or props
|
|
97
|
+
useEffect(function () {
|
|
98
|
+
if (open) {
|
|
99
|
+
var stored = localStorage.getItem(LOCALSTORAGE_KEY);
|
|
100
|
+
if (stored) {
|
|
101
|
+
var arr = JSON.parse(stored);
|
|
102
|
+
// Only keep pros present in the current list
|
|
103
|
+
setOrder(arr.filter(function (id) { return pros.some(function (p) { return p.proUserId === id; }); }));
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
setOrder(pros.map(function (p) { return p.proUserId; }));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}, [open, pros]);
|
|
110
|
+
// Gestion fermeture (overlay, esc)
|
|
111
|
+
useEffect(function () {
|
|
112
|
+
if (!open)
|
|
113
|
+
return;
|
|
114
|
+
var handleKey = function (e) {
|
|
115
|
+
if (e.key === "Escape")
|
|
116
|
+
onClosePortal();
|
|
117
|
+
};
|
|
118
|
+
document.addEventListener("keydown", handleKey);
|
|
119
|
+
return function () { return document.removeEventListener("keydown", handleKey); };
|
|
120
|
+
}, [open, onClosePortal]);
|
|
121
|
+
var handleOverlayClick = function (e) {
|
|
122
|
+
if (e.target === modalRef.current)
|
|
123
|
+
onClosePortal();
|
|
124
|
+
};
|
|
125
|
+
// DnD-kit setup avec activation plus sensible
|
|
126
|
+
var sensors = useSensors(useSensor(PointerSensor, {
|
|
127
|
+
activationConstraint: {
|
|
128
|
+
distance: 8,
|
|
129
|
+
delay: 0,
|
|
130
|
+
tolerance: 5,
|
|
131
|
+
},
|
|
132
|
+
}), useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }));
|
|
133
|
+
// Créer la liste ordonnée des pros filtrés
|
|
134
|
+
var sortedAndFilteredPros = order
|
|
135
|
+
.map(function (id) { return filteredPros.find(function (p) { return p.proUserId === id; }); })
|
|
136
|
+
.filter(Boolean);
|
|
137
|
+
var sortedPros = order
|
|
138
|
+
.map(function (id) { return pros.find(function (p) { return p.proUserId === id; }); })
|
|
139
|
+
.filter(Boolean);
|
|
140
|
+
console.log("🔧 State:", {
|
|
141
|
+
isReorder: isReorder,
|
|
142
|
+
draggedId: draggedId,
|
|
143
|
+
prosCount: sortedAndFilteredPros.length,
|
|
144
|
+
orderLength: order.length,
|
|
145
|
+
});
|
|
146
|
+
// Réordonnancement handlers
|
|
147
|
+
var handleDragStart = function (event) {
|
|
148
|
+
console.log("🚀 DragStart:", event.active.id);
|
|
149
|
+
setDraggedId(event.active.id);
|
|
150
|
+
var pro = sortedAndFilteredPros.find(function (p) { return p.proUserId === event.active.id; });
|
|
151
|
+
setActiveDragPro(pro || null);
|
|
152
|
+
};
|
|
153
|
+
var handleDragOver = function (event) {
|
|
154
|
+
var _a;
|
|
155
|
+
setHoveredId(((_a = event.over) === null || _a === void 0 ? void 0 : _a.id) || null);
|
|
156
|
+
};
|
|
157
|
+
var handleDragEnd = function (event) {
|
|
158
|
+
var _a;
|
|
159
|
+
console.log("🏁 DragEnd:", event.active.id, "→", (_a = event.over) === null || _a === void 0 ? void 0 : _a.id);
|
|
160
|
+
setDraggedId(null);
|
|
161
|
+
setHoveredId(null);
|
|
162
|
+
setActiveDragPro(null);
|
|
163
|
+
var active = event.active, over = event.over;
|
|
164
|
+
if (active.id !== (over === null || over === void 0 ? void 0 : over.id)) {
|
|
165
|
+
var oldIndex = order.indexOf(active.id);
|
|
166
|
+
var newIndex = order.indexOf(over.id);
|
|
167
|
+
console.log("📊 Reorder:", oldIndex, "→", newIndex);
|
|
168
|
+
var newOrder = arrayMove(order, oldIndex, newIndex);
|
|
169
|
+
setOrder(newOrder);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
var handleDragCancel = function () {
|
|
173
|
+
console.log("❌ DragCancel");
|
|
174
|
+
setDraggedId(null);
|
|
175
|
+
setHoveredId(null);
|
|
176
|
+
setActiveDragPro(null);
|
|
177
|
+
};
|
|
178
|
+
var handleValidate = function () {
|
|
179
|
+
localStorage.setItem(LOCALSTORAGE_KEY, JSON.stringify(order));
|
|
180
|
+
if (onOrderChange)
|
|
181
|
+
onOrderChange(sortedPros);
|
|
182
|
+
setIsReorder(false);
|
|
183
|
+
};
|
|
184
|
+
var handleCancel = function () {
|
|
185
|
+
setOrder(pros.map(function (p) { return p.proUserId; }));
|
|
186
|
+
setIsReorder(false);
|
|
187
|
+
};
|
|
188
|
+
// Sélection
|
|
189
|
+
var handleSelect = function (pro) {
|
|
190
|
+
if (!onSelect)
|
|
191
|
+
return;
|
|
192
|
+
var newSelected;
|
|
193
|
+
if (mode === "single") {
|
|
194
|
+
newSelected = [pro.proUserId];
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
if (selected.includes(pro.proUserId)) {
|
|
198
|
+
newSelected = selected.filter(function (id) { return id !== pro.proUserId; });
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
newSelected = __spreadArray(__spreadArray([], selected, true), [pro.proUserId], false);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
var selectedPros = pros.filter(function (p) { return newSelected.includes(p.proUserId); });
|
|
205
|
+
onSelect(selectedPros);
|
|
206
|
+
};
|
|
207
|
+
// Détermination dynamique du max-width selon le nombre de profils
|
|
208
|
+
var modalMaxWidth = 580;
|
|
209
|
+
if (pros.length <= 2)
|
|
210
|
+
modalMaxWidth = 326;
|
|
211
|
+
else if (pros.length === 3)
|
|
212
|
+
modalMaxWidth = 445;
|
|
213
|
+
else if (pros.length >= 4)
|
|
214
|
+
modalMaxWidth = 580;
|
|
215
|
+
useEffect(function () {
|
|
216
|
+
function updateLabel() {
|
|
217
|
+
var w = window.innerWidth;
|
|
218
|
+
if (w > 540)
|
|
219
|
+
setReorderLabel("Réorganiser les profils");
|
|
220
|
+
else if (w > 480)
|
|
221
|
+
setReorderLabel("Changer ordre");
|
|
222
|
+
else if (w > 414)
|
|
223
|
+
setReorderLabel("Ordre");
|
|
224
|
+
else
|
|
225
|
+
setReorderLabel(null);
|
|
226
|
+
}
|
|
227
|
+
updateLabel();
|
|
228
|
+
window.addEventListener("resize", updateLabel);
|
|
229
|
+
return function () { return window.removeEventListener("resize", updateLabel); };
|
|
230
|
+
}, []);
|
|
231
|
+
if (!open)
|
|
232
|
+
return null;
|
|
233
|
+
return ReactDOM.createPortal(React.createElement("div", { className: styles.overlay, ref: modalRef, "aria-modal": "true", "aria-labelledby": "pro-switch-modal-title", tabIndex: -1, onMouseDown: handleOverlayClick },
|
|
234
|
+
React.createElement("div", { className: styles.modal, role: "dialog", style: { maxWidth: modalMaxWidth } },
|
|
235
|
+
React.createElement("header", { className: styles.header },
|
|
236
|
+
pros.length > 4 ? (isReorder ? (React.createElement(React.Fragment, null,
|
|
237
|
+
React.createElement("div", { className: styles.headerReorderLabel }, reorderLabel && (React.createElement(Paragraph, { variant: "medium", color: "mid-grey", text: reorderLabel }))),
|
|
238
|
+
React.createElement("div", { className: styles.headerReorderActions },
|
|
239
|
+
React.createElement("button", { className: styles.cancelBtn, onClick: handleCancel, type: "button" }, "Annuler"),
|
|
240
|
+
React.createElement("button", { className: styles.validateBtn, onClick: handleValidate, type: "button" }, "Valider")))) : (React.createElement("div", { className: styles.searchContainer },
|
|
241
|
+
React.createElement(SearchBar, { value: search, onChange: setSearch, placeholder: "Rechercher...", showClear: true, endIcon: "allaw-icon-search" })))) : (React.createElement("div", { style: { flex: 1 } })),
|
|
242
|
+
pros.length > 4 && (React.createElement("div", { className: styles.buttonContainer, style: { justifyContent: "flex-start" } },
|
|
243
|
+
React.createElement("div", { className: styles.reorderContainer },
|
|
244
|
+
React.createElement("button", { className: styles.reorderBtn, onClick: function () { return setIsReorder(function (v) { return !v; }); }, "aria-label": isReorder
|
|
245
|
+
? "Quitter le mode réordonnancement"
|
|
246
|
+
: "Activer le mode réordonnancement", "aria-pressed": isReorder, type: "button" },
|
|
247
|
+
React.createElement("i", { className: isReorder ? "allaw-icon-drag" : "allaw-icon-drag" }))),
|
|
248
|
+
React.createElement("div", { className: styles.closeContainer },
|
|
249
|
+
React.createElement("button", { className: styles.closeBtn, onClick: onClosePortal, "aria-label": "Fermer la fen\u00EAtre de s\u00E9lection des professionnels", type: "button" },
|
|
250
|
+
React.createElement("i", { className: "allaw-icon-close" }))))),
|
|
251
|
+
pros.length <= 4 && (React.createElement("div", { className: styles.buttonContainer, style: { justifyContent: "flex-end" } },
|
|
252
|
+
React.createElement("div", { className: styles.closeContainer },
|
|
253
|
+
React.createElement("button", { className: styles.closeBtn, onClick: onClosePortal, "aria-label": "Fermer la fen\u00EAtre de s\u00E9lection des professionnels", type: "button" },
|
|
254
|
+
React.createElement("i", { className: "allaw-icon-close" })))))),
|
|
255
|
+
React.createElement("main", { className: styles.body },
|
|
256
|
+
React.createElement(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragStart: handleDragStart, onDragOver: handleDragOver, onDragEnd: handleDragEnd, onDragCancel: handleDragCancel },
|
|
257
|
+
React.createElement(SortableContext, { items: sortedAndFilteredPros.map(function (p) { return p.proUserId; }), strategy: rectSortingStrategy },
|
|
258
|
+
React.createElement("div", { className: styles.grid + (isReorder ? " " + styles.reorderMode : "") }, sortedAndFilteredPros.map(function (pro) {
|
|
259
|
+
return isReorder ? (React.createElement("div", { key: pro.proUserId, className: styles.gridItemContainer },
|
|
260
|
+
React.createElement(SortableItem, { pro: pro, isSelected: selected.includes(pro.proUserId), isReorder: isReorder, onSelect: handleSelect, hasActiveDrag: !!draggedId }),
|
|
261
|
+
hoveredId === pro.proUserId && draggedId && (React.createElement("div", { className: styles.dropSlot })))) : (React.createElement("div", { key: pro.proUserId, className: styles.gridItem, onClick: function () { return handleSelect(pro); } },
|
|
262
|
+
React.createElement("div", { className: styles.avatarWrapper },
|
|
263
|
+
React.createElement(AvatarBubble, { firstName: pro.firstName, name: pro.name, src: pro.profilePictureLink, size: 56, isSelected: selected.includes(pro.proUserId), disabled: false, disableHoverAnimation: false, borderThick: true })),
|
|
264
|
+
React.createElement("div", { className: styles.name }, selected.includes(pro.proUserId) ? (React.createElement("strong", null,
|
|
265
|
+
pro.firstName,
|
|
266
|
+
" ",
|
|
267
|
+
pro.name)) : ("".concat(pro.firstName, " ").concat(pro.name)))));
|
|
268
|
+
}))),
|
|
269
|
+
React.createElement(DragOverlay, { dropAnimation: {
|
|
270
|
+
duration: 200,
|
|
271
|
+
easing: "cubic-bezier(0.18, 0.67, 0.6, 1.22)",
|
|
272
|
+
} }, activeDragPro ? (React.createElement("div", { className: styles.dragOverlay },
|
|
273
|
+
React.createElement("div", { className: styles.avatarWrapper },
|
|
274
|
+
React.createElement(AvatarBubble, { firstName: activeDragPro.firstName, name: activeDragPro.name, src: activeDragPro.profilePictureLink, size: 56, isSelected: selected.includes(activeDragPro.proUserId), disabled: false, disableHoverAnimation: true })),
|
|
275
|
+
React.createElement("div", { className: styles.name }, selected.includes(activeDragPro.proUserId) ? (React.createElement("strong", null,
|
|
276
|
+
activeDragPro.firstName,
|
|
277
|
+
" ",
|
|
278
|
+
activeDragPro.name)) : ("".concat(activeDragPro.firstName, " ").concat(activeDragPro.name))))) : null)),
|
|
279
|
+
isReorder ? (React.createElement(TinyInfo, { variant: "medium14", text: "D\u00E9placez les profils pour modifier leur ordre", startIcon: "allaw-icon-info", color: "mid-grey", className: styles.reorderInfo })) : (React.createElement("div", { className: styles.selectionInfo },
|
|
280
|
+
"S\u00E9lection : ",
|
|
281
|
+
selected.length,
|
|
282
|
+
"/",
|
|
283
|
+
pros.length))))), document.body);
|
|
284
|
+
};
|
|
285
|
+
export default ProSwitchModal;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
export let title: string;
|
|
3
|
+
export { ProSwitchModal as component };
|
|
4
|
+
export let tags: string[];
|
|
5
|
+
export namespace argTypes {
|
|
6
|
+
namespace open {
|
|
7
|
+
let control: boolean;
|
|
8
|
+
}
|
|
9
|
+
namespace pros {
|
|
10
|
+
let control_1: boolean;
|
|
11
|
+
export { control_1 as control };
|
|
12
|
+
}
|
|
13
|
+
namespace selected {
|
|
14
|
+
let control_2: boolean;
|
|
15
|
+
export { control_2 as control };
|
|
16
|
+
}
|
|
17
|
+
namespace mode {
|
|
18
|
+
export namespace control_3 {
|
|
19
|
+
let type: string;
|
|
20
|
+
let options: string[];
|
|
21
|
+
}
|
|
22
|
+
export { control_3 as control };
|
|
23
|
+
}
|
|
24
|
+
namespace onClosePortal {
|
|
25
|
+
let action: string;
|
|
26
|
+
}
|
|
27
|
+
namespace onOpenPortal {
|
|
28
|
+
let action_1: string;
|
|
29
|
+
export { action_1 as action };
|
|
30
|
+
}
|
|
31
|
+
namespace onOrderChange {
|
|
32
|
+
let action_2: string;
|
|
33
|
+
export { action_2 as action };
|
|
34
|
+
}
|
|
35
|
+
namespace onSelect {
|
|
36
|
+
let action_3: string;
|
|
37
|
+
export { action_3 as action };
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export namespace parameters {
|
|
41
|
+
namespace backgrounds {
|
|
42
|
+
let _default: string;
|
|
43
|
+
export { _default as default };
|
|
44
|
+
export let values: {
|
|
45
|
+
name: string;
|
|
46
|
+
value: string;
|
|
47
|
+
}[];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export default _default;
|
|
52
|
+
export const Default: any;
|
|
53
|
+
export const Single: any;
|
|
54
|
+
export const Reorder: any;
|
|
55
|
+
export const Scroll: any;
|
|
56
|
+
export const FallbackInitiales: any;
|
|
57
|
+
export const Responsive: any;
|
|
58
|
+
export const ResponsiveMobile: any;
|
|
59
|
+
export const FewProfiles: any;
|
|
60
|
+
import ProSwitchModal from "./ProSwitchModal";
|