@situaction/traq-ui-ste 1.1.34 → 1.1.35
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.
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import '../../styles/Modal.css';const
|
|
4
|
-
overlay:
|
|
5
|
-
modalContent:
|
|
6
|
-
},
|
|
7
|
-
({ open:
|
|
8
|
-
const
|
|
9
|
-
return
|
|
10
|
-
!m && m !== void 0 &&
|
|
11
|
-
}, [m,
|
|
12
|
-
if (
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
top: `${
|
|
16
|
-
left: `${
|
|
17
|
-
})
|
|
1
|
+
import { jsxs as j, Fragment as M, jsx as v } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as N, useRef as S, useState as k, useEffect as w, useLayoutEffect as q } from "react";
|
|
3
|
+
import '../../styles/Modal.css';const A = "_overlay_lv2n7_2", B = "_modalContent_lv2n7_12", g = {
|
|
4
|
+
overlay: A,
|
|
5
|
+
modalContent: B
|
|
6
|
+
}, O = N(
|
|
7
|
+
({ open: t, onClose: d, children: y, position: e, className: _, disableOverlay: b = !1, autoCloseCondition: m, anchorRef: a }, x) => {
|
|
8
|
+
const E = S(null), c = x || E, [l, $] = k();
|
|
9
|
+
return w(() => {
|
|
10
|
+
!m && m !== void 0 && t && d();
|
|
11
|
+
}, [m, t, d]), q(() => {
|
|
12
|
+
if (a != null && a.current && t && !e) {
|
|
13
|
+
const r = a.current.getBoundingClientRect();
|
|
14
|
+
$({
|
|
15
|
+
top: `${r.bottom + window.scrollY}px`,
|
|
16
|
+
left: `${r.left + window.scrollX}px`
|
|
17
|
+
});
|
|
18
18
|
}
|
|
19
|
-
}, [
|
|
20
|
-
const
|
|
19
|
+
}, [a, t, e]), w(() => {
|
|
20
|
+
const r = (u) => {
|
|
21
21
|
const f = c.current;
|
|
22
|
-
f && !f.contains(u.target) &&
|
|
23
|
-
(
|
|
24
|
-
) &&
|
|
22
|
+
f && !f.contains(u.target) && t && ![...document.querySelectorAll(".dialog")].some(
|
|
23
|
+
(L) => L.contains(u.target)
|
|
24
|
+
) && d();
|
|
25
25
|
};
|
|
26
|
-
return document.addEventListener("mousedown",
|
|
27
|
-
document.removeEventListener("mousedown",
|
|
26
|
+
return document.addEventListener("mousedown", r), () => {
|
|
27
|
+
document.removeEventListener("mousedown", r);
|
|
28
28
|
};
|
|
29
|
-
}, [
|
|
30
|
-
!b && /* @__PURE__ */ v("div", { className:
|
|
29
|
+
}, [d, t, c]), t ? /* @__PURE__ */ j(M, { children: [
|
|
30
|
+
!b && /* @__PURE__ */ v("div", { className: g.overlay }),
|
|
31
31
|
/* @__PURE__ */ v(
|
|
32
32
|
"div",
|
|
33
33
|
{
|
|
34
34
|
ref: c,
|
|
35
|
-
className: `${
|
|
36
|
-
onMouseDown: (
|
|
35
|
+
className: `${g.modalContent} ${_ || ""}`,
|
|
36
|
+
onMouseDown: (r) => r.stopPropagation(),
|
|
37
37
|
style: {
|
|
38
38
|
position: "absolute",
|
|
39
|
-
top: (e == null ? void 0 : e.top) ?? (
|
|
40
|
-
left: (e == null ? void 0 : e.left) ?? (
|
|
39
|
+
top: (e == null ? void 0 : e.top) ?? (l == null ? void 0 : l.top) ?? "50%",
|
|
40
|
+
left: (e == null ? void 0 : e.left) ?? (l == null ? void 0 : l.left) ?? "50%",
|
|
41
41
|
right: e == null ? void 0 : e.right,
|
|
42
42
|
bottom: e == null ? void 0 : e.bottom,
|
|
43
|
-
width:
|
|
44
|
-
transform: !(e != null && e.top) && !(e != null && e.left) && !
|
|
43
|
+
width: e == null ? void 0 : e.width,
|
|
44
|
+
transform: !(e != null && e.top) && !(e != null && e.left) && !l ? "translate(-50%, -50%)" : void 0
|
|
45
45
|
},
|
|
46
|
-
children:
|
|
46
|
+
children: y
|
|
47
47
|
}
|
|
48
48
|
)
|
|
49
49
|
] }) : null;
|
|
50
50
|
}
|
|
51
51
|
);
|
|
52
52
|
export {
|
|
53
|
-
|
|
53
|
+
O as Modal
|
|
54
54
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsxs as $, jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
3
|
-
import { Button as
|
|
4
|
-
import { IconButton as
|
|
2
|
+
import { useState as x, useRef as h, useEffect as w } from "react";
|
|
3
|
+
import { Button as N } from "../button/Button.js";
|
|
4
|
+
import { IconButton as W } from "../icon-button/IconButton.js";
|
|
5
5
|
import { Icon as p } from "../icon/Icon.js";
|
|
6
|
-
import { Modal as
|
|
6
|
+
import { Modal as q } from "../modal/Modal.js";
|
|
7
7
|
import "../theme/ThemeContext.js";
|
|
8
8
|
import '../../styles/Size.css';import '../../styles/Select.css';/* empty css */
|
|
9
|
-
const
|
|
10
|
-
selectContainer:
|
|
9
|
+
const z = "_selectContainer_1o5wx_54", A = "_selected_1o5wx_57", D = "_children_1o5wx_61", G = "_active_1o5wx_78", H = "_selectList_1o5wx_82", J = "_modal_1o5wx_91", Q = "_dropdownFadeIn_1o5wx_1", X = "_itemLabel_1o5wx_98", m = {
|
|
10
|
+
selectContainer: z,
|
|
11
11
|
selected: A,
|
|
12
12
|
children: D,
|
|
13
13
|
active: G,
|
|
@@ -16,101 +16,100 @@ const q = "_selectContainer_1o5wx_54", A = "_selected_1o5wx_57", D = "_children_
|
|
|
16
16
|
dropdownFadeIn: Q,
|
|
17
17
|
itemLabel: X
|
|
18
18
|
}, ce = ({
|
|
19
|
-
selected:
|
|
20
|
-
size:
|
|
21
|
-
listItem:
|
|
22
|
-
modeDisplay:
|
|
23
|
-
onSelect:
|
|
24
|
-
positionOverride:
|
|
25
|
-
placeholder:
|
|
19
|
+
selected: _,
|
|
20
|
+
size: b = "m",
|
|
21
|
+
listItem: c,
|
|
22
|
+
modeDisplay: g = "all",
|
|
23
|
+
onSelect: B,
|
|
24
|
+
positionOverride: R,
|
|
25
|
+
placeholder: P = "Sélectionner",
|
|
26
26
|
autoCloseCondition: j,
|
|
27
|
-
fullWidth:
|
|
27
|
+
fullWidth: T = !1
|
|
28
28
|
}) => {
|
|
29
|
-
const [
|
|
29
|
+
const [n, u] = x(!1), U = h(null), [V, F] = x({
|
|
30
30
|
top: "calc(100% + 6px)",
|
|
31
|
-
left: "0px"
|
|
32
|
-
|
|
33
|
-
}), [c, F] = k(y ?? null);
|
|
31
|
+
left: "0px"
|
|
32
|
+
}), [s, L] = x(_ ?? null);
|
|
34
33
|
w(() => {
|
|
35
|
-
|
|
36
|
-
}, [
|
|
37
|
-
|
|
38
|
-
}, [
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
},
|
|
42
|
-
const e =
|
|
43
|
-
return
|
|
44
|
-
|
|
34
|
+
_ ? L(_) : c.length > 0 ? L(c[0]) : L(null), console.log(c);
|
|
35
|
+
}, [_, c]), w(() => {
|
|
36
|
+
R && F(R);
|
|
37
|
+
}, [R]);
|
|
38
|
+
const M = (e) => {
|
|
39
|
+
L(e), u(!1), B && B(e);
|
|
40
|
+
}, O = () => {
|
|
41
|
+
const e = s == null ? void 0 : s.icon, o = (s == null ? void 0 : s.label) || P || "Sélectionner";
|
|
42
|
+
return g === "icon" && e ? /* @__PURE__ */ r(W, { ref: d, mode: "tertiary", size: b, onClick: () => u(!n), children: /* @__PURE__ */ r(p, { icon: s.icon }) }) : g === "text" ? /* @__PURE__ */ r(
|
|
43
|
+
N,
|
|
45
44
|
{
|
|
46
45
|
ref: d,
|
|
47
46
|
mode: "tertiary",
|
|
48
47
|
label: o,
|
|
49
|
-
childrenRight: /* @__PURE__ */ r(p, { icon:
|
|
50
|
-
size:
|
|
51
|
-
fullWidth:
|
|
52
|
-
onClick: () => u(!
|
|
48
|
+
childrenRight: /* @__PURE__ */ r(p, { icon: n ? "CaretUp" : "CaretDown", size: 14, weight: "bold" }),
|
|
49
|
+
size: b,
|
|
50
|
+
fullWidth: T,
|
|
51
|
+
onClick: () => u(!n)
|
|
53
52
|
}
|
|
54
|
-
) :
|
|
55
|
-
|
|
53
|
+
) : g === "all" ? /* @__PURE__ */ r(
|
|
54
|
+
N,
|
|
56
55
|
{
|
|
57
56
|
ref: d,
|
|
58
57
|
mode: "tertiary",
|
|
59
58
|
label: o,
|
|
60
|
-
size:
|
|
61
|
-
fullWidth:
|
|
62
|
-
childrenLeft: e && /* @__PURE__ */ r(p, { icon:
|
|
63
|
-
childrenRight: /* @__PURE__ */ r(p, { icon:
|
|
64
|
-
onClick: () => u(!
|
|
59
|
+
size: b,
|
|
60
|
+
fullWidth: T,
|
|
61
|
+
childrenLeft: e && /* @__PURE__ */ r(p, { icon: s.icon }),
|
|
62
|
+
childrenRight: /* @__PURE__ */ r(p, { icon: n ? "CaretUp" : "CaretDown", size: 14, weight: "bold" }),
|
|
63
|
+
onClick: () => u(!n)
|
|
65
64
|
}
|
|
66
65
|
) : /* @__PURE__ */ r(
|
|
67
|
-
|
|
66
|
+
N,
|
|
68
67
|
{
|
|
69
68
|
ref: d,
|
|
70
69
|
mode: "tertiary",
|
|
71
|
-
fullWidth:
|
|
72
|
-
label:
|
|
73
|
-
size:
|
|
74
|
-
onClick: () => u(!
|
|
70
|
+
fullWidth: T,
|
|
71
|
+
label: P ?? "Sélectionner",
|
|
72
|
+
size: b,
|
|
73
|
+
onClick: () => u(!n)
|
|
75
74
|
}
|
|
76
75
|
);
|
|
77
|
-
},
|
|
78
|
-
if (!
|
|
76
|
+
}, E = h(null), C = h({}), [k, v] = x(""), f = h(null), K = h({}), S = (e) => {
|
|
77
|
+
if (!n) return;
|
|
79
78
|
const o = e.key.length === 1 ? e.key.toLowerCase() : "";
|
|
80
79
|
if (!o) return;
|
|
81
|
-
const i =
|
|
80
|
+
const i = k + o;
|
|
82
81
|
v(i);
|
|
83
|
-
const
|
|
84
|
-
var
|
|
85
|
-
return (
|
|
82
|
+
const a = c.find((t) => {
|
|
83
|
+
var l;
|
|
84
|
+
return (l = t.label) == null ? void 0 : l.toLowerCase().startsWith(i);
|
|
86
85
|
});
|
|
87
|
-
if (
|
|
88
|
-
const
|
|
89
|
-
|
|
86
|
+
if (a) {
|
|
87
|
+
const t = C.current[a.value];
|
|
88
|
+
t == null || t.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
90
89
|
}
|
|
91
90
|
f.current && clearTimeout(f.current), f.current = setTimeout(() => {
|
|
92
91
|
v("");
|
|
93
92
|
}, 500);
|
|
94
93
|
};
|
|
95
|
-
w(() => (
|
|
96
|
-
window.removeEventListener("keydown",
|
|
97
|
-
}), [
|
|
94
|
+
w(() => (n ? window.addEventListener("keydown", S) : (window.removeEventListener("keydown", S), v("")), () => {
|
|
95
|
+
window.removeEventListener("keydown", S);
|
|
96
|
+
}), [n, k, c]), w(() => {
|
|
98
97
|
const e = (o) => {
|
|
99
|
-
if (!
|
|
98
|
+
if (!n) return;
|
|
100
99
|
const i = o.key.length === 1 ? o.key.toLowerCase() : "";
|
|
101
100
|
if (!i) return;
|
|
102
|
-
const
|
|
103
|
-
v(
|
|
104
|
-
const
|
|
105
|
-
(
|
|
106
|
-
var
|
|
107
|
-
return (
|
|
101
|
+
const a = k + i;
|
|
102
|
+
v(a);
|
|
103
|
+
const t = c.find(
|
|
104
|
+
(l) => {
|
|
105
|
+
var y;
|
|
106
|
+
return (y = l.label) == null ? void 0 : y.toLowerCase().startsWith(a);
|
|
108
107
|
}
|
|
109
108
|
);
|
|
110
|
-
if (
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
top:
|
|
109
|
+
if (t && E.current && t.value in C.current && C.current[t.value]) {
|
|
110
|
+
const l = E.current, y = C.current[t.value];
|
|
111
|
+
l.scrollTo({
|
|
112
|
+
top: y.offsetTop - l.offsetTop,
|
|
114
113
|
behavior: "smooth"
|
|
115
114
|
});
|
|
116
115
|
}
|
|
@@ -119,56 +118,55 @@ const q = "_selectContainer_1o5wx_54", A = "_selected_1o5wx_57", D = "_children_
|
|
|
119
118
|
}, 700);
|
|
120
119
|
};
|
|
121
120
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
122
|
-
}, [
|
|
123
|
-
if (!
|
|
121
|
+
}, [n, c, k]), w(() => {
|
|
122
|
+
if (!n) return;
|
|
124
123
|
const e = (o) => {
|
|
125
124
|
const i = o.key.toLowerCase();
|
|
126
125
|
if (i.length === 1) {
|
|
127
|
-
const
|
|
128
|
-
(
|
|
129
|
-
var
|
|
130
|
-
return (
|
|
126
|
+
const a = c.find(
|
|
127
|
+
(t) => {
|
|
128
|
+
var l;
|
|
129
|
+
return (l = t.label) == null ? void 0 : l.toLowerCase().startsWith(i);
|
|
131
130
|
}
|
|
132
131
|
);
|
|
133
|
-
if (
|
|
134
|
-
const
|
|
135
|
-
|
|
132
|
+
if (a) {
|
|
133
|
+
const t = K.current[a.value];
|
|
134
|
+
t && t.scrollIntoView({ block: "start", behavior: "smooth" });
|
|
136
135
|
}
|
|
137
136
|
}
|
|
138
137
|
};
|
|
139
138
|
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
140
|
-
}, [
|
|
139
|
+
}, [n, c]);
|
|
141
140
|
const d = h(null);
|
|
142
141
|
return w(() => {
|
|
143
|
-
if (
|
|
142
|
+
if (n && d.current) {
|
|
144
143
|
const e = d.current.getBoundingClientRect().height;
|
|
145
|
-
|
|
144
|
+
F({
|
|
146
145
|
top: `${e + 6}px`,
|
|
147
|
-
left: "0px"
|
|
148
|
-
width: "100%"
|
|
146
|
+
left: "0px"
|
|
149
147
|
});
|
|
150
148
|
}
|
|
151
|
-
}, [
|
|
152
|
-
|
|
149
|
+
}, [n]), /* @__PURE__ */ $("div", { className: m.selectContainer, children: [
|
|
150
|
+
O(),
|
|
153
151
|
/* @__PURE__ */ r(
|
|
154
|
-
|
|
152
|
+
q,
|
|
155
153
|
{
|
|
156
154
|
ref: U,
|
|
157
155
|
anchorRef: d,
|
|
158
|
-
open:
|
|
156
|
+
open: n,
|
|
159
157
|
onClose: () => u(!1),
|
|
160
158
|
position: V,
|
|
161
159
|
disableOverlay: !0,
|
|
162
160
|
className: m.modal,
|
|
163
161
|
autoCloseCondition: j,
|
|
164
|
-
children: /* @__PURE__ */ r("div", { className: m.selectList, ref:
|
|
162
|
+
children: /* @__PURE__ */ r("div", { className: m.selectList, ref: E, children: c.map((e) => /* @__PURE__ */ $(
|
|
165
163
|
"div",
|
|
166
164
|
{
|
|
167
165
|
ref: (o) => K.current[e.value] = o,
|
|
168
|
-
className: `${m.children} ${(
|
|
169
|
-
onClick: () =>
|
|
166
|
+
className: `${m.children} ${(s == null ? void 0 : s.value) === e.value ? m.active : ""}`,
|
|
167
|
+
onClick: () => M(e),
|
|
170
168
|
children: [
|
|
171
|
-
e.icon && /* @__PURE__ */ r(p, { icon: e.icon }),
|
|
169
|
+
e.icon && /* @__PURE__ */ r(p, { icon: e.icon, size: 16 }),
|
|
172
170
|
e.label && /* @__PURE__ */ r("div", { className: m.itemLabel, children: e.label })
|
|
173
171
|
]
|
|
174
172
|
},
|