hamzus-ui 0.0.250 → 0.0.252
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import Portal from '../Portal/Portal.svelte';
|
|
3
|
-
import { onDestroy, onMount } from 'svelte';
|
|
3
|
+
import { onDestroy, onMount, tick } from 'svelte';
|
|
4
4
|
|
|
5
5
|
// import
|
|
6
6
|
|
|
@@ -34,19 +34,17 @@
|
|
|
34
34
|
|
|
35
35
|
const padding = 7;
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
$: if (forceOpen === true) {
|
|
38
|
+
open();
|
|
39
39
|
|
|
40
|
+
forceOpen = false;
|
|
41
|
+
}
|
|
42
|
+
$: if (forceClose === true) {
|
|
43
|
+
close();
|
|
40
44
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
$: if (forceClose === true) {
|
|
44
|
-
close()
|
|
45
|
-
|
|
45
|
+
forceClose = false;
|
|
46
|
+
}
|
|
46
47
|
|
|
47
|
-
forceClose = false
|
|
48
|
-
}
|
|
49
|
-
|
|
50
48
|
const entryPosition = {
|
|
51
49
|
bottom: ['-12px', '0px'],
|
|
52
50
|
[`bottom-right`]: ['-12px', '-12px'],
|
|
@@ -62,7 +60,7 @@
|
|
|
62
60
|
[`right-bottom`]: ['12px', '-12px']
|
|
63
61
|
};
|
|
64
62
|
// function
|
|
65
|
-
function handleDisplay(e, force) {
|
|
63
|
+
async function handleDisplay(e, force) {
|
|
66
64
|
if (!force && avoidOpening) {
|
|
67
65
|
return;
|
|
68
66
|
}
|
|
@@ -72,11 +70,15 @@
|
|
|
72
70
|
}
|
|
73
71
|
|
|
74
72
|
if (!display) {
|
|
73
|
+
toggleDisplay();
|
|
74
|
+
|
|
75
|
+
await tick();
|
|
76
|
+
|
|
75
77
|
calculate();
|
|
78
|
+
} else {
|
|
79
|
+
toggleDisplay();
|
|
76
80
|
}
|
|
77
81
|
|
|
78
|
-
toggleDisplay();
|
|
79
|
-
|
|
80
82
|
if (onOpen !== undefined && typeof onOpen === 'function') {
|
|
81
83
|
onOpen(e);
|
|
82
84
|
}
|
|
@@ -96,7 +98,6 @@
|
|
|
96
98
|
disableExitEvent();
|
|
97
99
|
enableScroll();
|
|
98
100
|
} else {
|
|
99
|
-
|
|
100
101
|
interval = setInterval(() => {
|
|
101
102
|
calculate();
|
|
102
103
|
}, 100);
|
|
@@ -104,17 +105,21 @@
|
|
|
104
105
|
enableExitEvent();
|
|
105
106
|
disableScroll();
|
|
106
107
|
}
|
|
107
|
-
|
|
108
|
+
|
|
108
109
|
display = !display;
|
|
109
110
|
};
|
|
110
111
|
|
|
111
|
-
let open = () => {
|
|
112
|
+
let open = async () => {
|
|
112
113
|
if (display) {
|
|
113
114
|
return;
|
|
114
115
|
}
|
|
115
|
-
calculate();
|
|
116
116
|
|
|
117
117
|
toggleDisplay();
|
|
118
|
+
|
|
119
|
+
await tick();
|
|
120
|
+
|
|
121
|
+
calculate();
|
|
122
|
+
|
|
118
123
|
};
|
|
119
124
|
let close = () => {
|
|
120
125
|
if (!display) {
|
|
@@ -125,7 +130,6 @@
|
|
|
125
130
|
};
|
|
126
131
|
|
|
127
132
|
function calculate() {
|
|
128
|
-
|
|
129
133
|
// recuperer les données
|
|
130
134
|
maxContentHeight = null;
|
|
131
135
|
maxContentWidth = null;
|
|
@@ -133,9 +137,9 @@
|
|
|
133
137
|
// recuperer le contenue du trigger
|
|
134
138
|
const triggerContent = getFirstChild(trigger);
|
|
135
139
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
140
|
+
if (triggerContent === null) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
139
143
|
|
|
140
144
|
// recuperer la position du trigger par rapport a la fenetre
|
|
141
145
|
const triggerRect = triggerContent.getBoundingClientRect();
|
|
@@ -176,14 +180,14 @@
|
|
|
176
180
|
// ya plus de place ne bas du coup on display en bas et on contraint la hauteur du content
|
|
177
181
|
}
|
|
178
182
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
+
// si il est hors de la vue (horizontalement) alors on le set a droite (fix pour la table)
|
|
184
|
+
if (triggerRight <= (contentWidth - triggerWidth) / 2) {
|
|
185
|
+
leftCalc = window.innerWidth - contentWidth - padding;
|
|
186
|
+
}
|
|
183
187
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
188
|
+
if (triggerLeft <= (contentWidth - triggerWidth) / 2) {
|
|
189
|
+
leftCalc = padding;
|
|
190
|
+
}
|
|
187
191
|
|
|
188
192
|
top = topCalc;
|
|
189
193
|
left = leftCalc;
|
|
@@ -214,14 +218,14 @@
|
|
|
214
218
|
// on contraint la max height du dropdown
|
|
215
219
|
}
|
|
216
220
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
+
// si il est hors de la vue (horizontalement) alors on le set a droite (fix pour la table)
|
|
222
|
+
if (triggerRight <= (contentWidth - triggerWidth) / 2) {
|
|
223
|
+
leftCalc = window.innerWidth - contentWidth - padding;
|
|
224
|
+
}
|
|
221
225
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
226
|
+
if (triggerLeft <= (contentWidth - triggerWidth) / 2) {
|
|
227
|
+
leftCalc = padding;
|
|
228
|
+
}
|
|
225
229
|
|
|
226
230
|
top = topCalc;
|
|
227
231
|
left = leftCalc;
|
|
@@ -290,9 +294,7 @@
|
|
|
290
294
|
|
|
291
295
|
const subCalc = {
|
|
292
296
|
bottom: () => {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
// aligner le contenue au bas du trigger
|
|
297
|
+
// aligner le contenue au bas du trigger
|
|
296
298
|
top = triggerTop;
|
|
297
299
|
},
|
|
298
300
|
top: () => {
|
|
@@ -303,7 +305,7 @@
|
|
|
303
305
|
const contentWidth = contentContent.offsetWidth;
|
|
304
306
|
const contentHeight = contentContent.offsetHeight;
|
|
305
307
|
|
|
306
|
-
|
|
308
|
+
// aligner le contenue au bas du trigger
|
|
307
309
|
top = triggerTop - (contentHeight - triggerHeight);
|
|
308
310
|
},
|
|
309
311
|
left: () => {
|
|
@@ -329,9 +331,9 @@
|
|
|
329
331
|
|
|
330
332
|
calc[axe]();
|
|
331
333
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
334
|
+
if (subDirection) {
|
|
335
|
+
subCalc[subDirection]();
|
|
336
|
+
}
|
|
335
337
|
}
|
|
336
338
|
|
|
337
339
|
// Bloquer le scroll
|
|
@@ -354,7 +356,6 @@
|
|
|
354
356
|
}
|
|
355
357
|
|
|
356
358
|
function enableExitEvent() {
|
|
357
|
-
|
|
358
359
|
document.addEventListener('click', checkClick);
|
|
359
360
|
}
|
|
360
361
|
function disableExitEvent() {
|
|
@@ -362,12 +363,11 @@
|
|
|
362
363
|
}
|
|
363
364
|
|
|
364
365
|
function checkClick(event) {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
366
|
+
// si avoidClosing est true on skip
|
|
367
|
+
if (avoidClosing) {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
371
|
// si il click sur le trigger alors on skip
|
|
372
372
|
if (
|
|
373
373
|
event.target.closest('.parent-popover-hamzus') &&
|
|
@@ -383,9 +383,8 @@
|
|
|
383
383
|
}
|
|
384
384
|
|
|
385
385
|
// si il clique sur un contenue on skip
|
|
386
|
-
|
|
387
|
-
if (event.target.closest('.content-popover-hamzus')) {
|
|
388
386
|
|
|
387
|
+
if (event.target.closest('.content-popover-hamzus')) {
|
|
389
388
|
return;
|
|
390
389
|
}
|
|
391
390
|
|
|
@@ -397,6 +396,7 @@
|
|
|
397
396
|
|
|
398
397
|
for (const child of node.children) {
|
|
399
398
|
const display = getComputedStyle(child).display;
|
|
399
|
+
console.log(child);
|
|
400
400
|
|
|
401
401
|
if (display !== 'contents') {
|
|
402
402
|
return child; // trouvé !
|
|
@@ -420,7 +420,6 @@
|
|
|
420
420
|
triggerWidth = triggerContent.offsetWidth;
|
|
421
421
|
triggerHeight = triggerContent.offsetHeight;
|
|
422
422
|
|
|
423
|
-
|
|
424
423
|
return () => {
|
|
425
424
|
document.removeEventListener('userScroll', updatePos);
|
|
426
425
|
window.removeEventListener('scroll', updatePos);
|
|
@@ -47,13 +47,7 @@
|
|
|
47
47
|
|
|
48
48
|
$: handleChange(search);
|
|
49
49
|
|
|
50
|
-
$:
|
|
51
|
-
if (multiple) {
|
|
52
|
-
onChange(selection?.map(el=>el.id) ?? null)
|
|
53
|
-
}else{
|
|
54
|
-
onChange(selection?.id ?? null)
|
|
55
|
-
}
|
|
56
|
-
}
|
|
50
|
+
$: onChange(selection ?? null)
|
|
57
51
|
|
|
58
52
|
// fnctions
|
|
59
53
|
function formatInput(inputValue) {
|