@drawbridge/components 0.1.40 → 0.1.41
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.
|
@@ -58,7 +58,10 @@ const railItems = ({
|
|
|
58
58
|
};
|
|
59
59
|
const railCount = (items = []) => required(items).length;
|
|
60
60
|
const railFirst = (items = []) => required(items)[0];
|
|
61
|
-
const railView = ({ guide, panel, support }) =>
|
|
61
|
+
const railView = ({ guide, opened, panel, path, support }) => {
|
|
62
|
+
if (panel === "guide") return guide && opened === path ? "guide" : null;
|
|
63
|
+
return panel === "support" && !support ? "next" : panel || null;
|
|
64
|
+
};
|
|
62
65
|
const railSupport = ({ organization, params = {}, path = "" }) => Boolean(params.organization && (organization == null ? void 0 : organization.support) === true && !path.startsWith("/admin"));
|
|
63
66
|
const railOverlap = (a, b) => a.left < b.right && b.left < a.right && a.top < b.bottom && b.top < a.bottom;
|
|
64
67
|
const railOnScreen = (rect, { height, width }) => rect.bottom > 0 && rect.right > 0 && rect.top < height && rect.left < width;
|
|
@@ -30,7 +30,10 @@ const railItems = ({
|
|
|
30
30
|
};
|
|
31
31
|
const railCount = (items = []) => required(items).length;
|
|
32
32
|
const railFirst = (items = []) => required(items)[0];
|
|
33
|
-
const railView = ({ guide, panel, support }) =>
|
|
33
|
+
const railView = ({ guide, opened, panel, path, support }) => {
|
|
34
|
+
if (panel === "guide") return guide && opened === path ? "guide" : null;
|
|
35
|
+
return panel === "support" && !support ? "next" : panel || null;
|
|
36
|
+
};
|
|
34
37
|
const railSupport = ({ organization, params = {}, path = "" }) => Boolean(params.organization && (organization == null ? void 0 : organization.support) === true && !path.startsWith("/admin"));
|
|
35
38
|
const railOverlap = (a, b) => a.left < b.right && b.left < a.right && a.top < b.bottom && b.top < a.bottom;
|
|
36
39
|
const railOnScreen = (rect, { height, width }) => rect.bottom > 0 && rect.right > 0 && rect.top < height && rect.left < width;
|
|
@@ -58,8 +58,8 @@ const titles = {
|
|
|
58
58
|
};
|
|
59
59
|
const RING_MS = 3e3;
|
|
60
60
|
const RAIL_MS = 200;
|
|
61
|
-
const useRail = () => {
|
|
62
|
-
var _a;
|
|
61
|
+
const useRail = (path) => {
|
|
62
|
+
var _a, _b;
|
|
63
63
|
const queryClient = (0, import_react_query.useQueryClient)();
|
|
64
64
|
const rail = (0, import_react_query.useQuery)({
|
|
65
65
|
queryFn: () => ({
|
|
@@ -68,11 +68,13 @@ const useRail = () => {
|
|
|
68
68
|
queryKey: ["rail"]
|
|
69
69
|
});
|
|
70
70
|
return {
|
|
71
|
-
|
|
71
|
+
opened: (_a = rail.data) == null ? void 0 : _a.path,
|
|
72
|
+
panel: ((_b = rail.data) == null ? void 0 : _b.panel) || null,
|
|
72
73
|
set: (panel) => queryClient.setQueryData(
|
|
73
74
|
["rail"],
|
|
74
75
|
{
|
|
75
|
-
panel
|
|
76
|
+
panel,
|
|
77
|
+
path
|
|
76
78
|
}
|
|
77
79
|
)
|
|
78
80
|
};
|
|
@@ -223,7 +225,7 @@ const ScreenGuide = ({
|
|
|
223
225
|
},
|
|
224
226
|
key
|
|
225
227
|
)),
|
|
226
|
-
step.target !== "body"
|
|
228
|
+
step.target !== "body" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
227
229
|
import_button.default,
|
|
228
230
|
{
|
|
229
231
|
...{
|
|
@@ -234,14 +236,6 @@ const ScreenGuide = ({
|
|
|
234
236
|
},
|
|
235
237
|
children: "Show me"
|
|
236
238
|
}
|
|
237
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
238
|
-
"p",
|
|
239
|
-
{
|
|
240
|
-
...{
|
|
241
|
-
className: "text-sm text-gray-dark"
|
|
242
|
-
},
|
|
243
|
-
children: "Applies to the whole screen"
|
|
244
|
-
}
|
|
245
239
|
)
|
|
246
240
|
]
|
|
247
241
|
}
|
|
@@ -390,7 +384,7 @@ const TemplateRail = ({
|
|
|
390
384
|
path = ""
|
|
391
385
|
}) => {
|
|
392
386
|
const queryClient = (0, import_react_query.useQueryClient)();
|
|
393
|
-
const { panel, set } = useRail();
|
|
387
|
+
const { opened, panel, set } = useRail(path);
|
|
394
388
|
const items = (0, import_rail.railItems)({
|
|
395
389
|
account,
|
|
396
390
|
campaign,
|
|
@@ -406,7 +400,9 @@ const TemplateRail = ({
|
|
|
406
400
|
});
|
|
407
401
|
const view = (0, import_rail.railView)({
|
|
408
402
|
guide,
|
|
403
|
+
opened,
|
|
409
404
|
panel,
|
|
405
|
+
path,
|
|
410
406
|
support
|
|
411
407
|
});
|
|
412
408
|
const [previous, setPrevious] = (0, import_react.useState)(view);
|
|
@@ -427,7 +423,8 @@ const TemplateRail = ({
|
|
|
427
423
|
const toggle = (next) => set(view === next ? null : next);
|
|
428
424
|
const close = () => set(null);
|
|
429
425
|
const aside = (0, import_react.useRef)(null);
|
|
430
|
-
const
|
|
426
|
+
const nav = (0, import_react.useRef)(null);
|
|
427
|
+
const wasOpen = (0, import_react.useRef)(Boolean(view));
|
|
431
428
|
const arrived = (0, import_react.useRef)(Boolean(view));
|
|
432
429
|
if (!view) arrived.current = false;
|
|
433
430
|
const opener = (0, import_react.useRef)(null);
|
|
@@ -487,8 +484,8 @@ const TemplateRail = ({
|
|
|
487
484
|
() => {
|
|
488
485
|
var _a, _b;
|
|
489
486
|
const open = Boolean(view);
|
|
490
|
-
if (open ===
|
|
491
|
-
|
|
487
|
+
if (open === wasOpen.current) return;
|
|
488
|
+
wasOpen.current = open;
|
|
492
489
|
if (open) {
|
|
493
490
|
opener.current = document.activeElement;
|
|
494
491
|
(_a = aside.current) == null ? void 0 : _a.focus();
|
|
@@ -499,6 +496,25 @@ const TemplateRail = ({
|
|
|
499
496
|
},
|
|
500
497
|
[view]
|
|
501
498
|
);
|
|
499
|
+
(0, import_react.useEffect)(
|
|
500
|
+
() => {
|
|
501
|
+
if (view !== "guide") return void 0;
|
|
502
|
+
const onPointerDown = ({ target }) => {
|
|
503
|
+
var _a, _b;
|
|
504
|
+
if (((_a = aside.current) == null ? void 0 : _a.contains(target)) || ((_b = nav.current) == null ? void 0 : _b.contains(target))) return;
|
|
505
|
+
opener.current = null;
|
|
506
|
+
queryClient.setQueryData(
|
|
507
|
+
["rail"],
|
|
508
|
+
{
|
|
509
|
+
panel: null
|
|
510
|
+
}
|
|
511
|
+
);
|
|
512
|
+
};
|
|
513
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
514
|
+
return () => document.removeEventListener("pointerdown", onPointerDown);
|
|
515
|
+
},
|
|
516
|
+
[queryClient, view]
|
|
517
|
+
);
|
|
502
518
|
const phone = () => window.matchMedia("(max-width: 767px)").matches;
|
|
503
519
|
(0, import_focus.useTrap)(
|
|
504
520
|
Boolean(view),
|
|
@@ -649,6 +665,7 @@ const TemplateRail = ({
|
|
|
649
665
|
{
|
|
650
666
|
...{
|
|
651
667
|
"aria-label": "Rail",
|
|
668
|
+
ref: nav,
|
|
652
669
|
className: "hidden md:flex flex-col items-center gap-2 w-12 h-full shrink-0 py-3 bg-white border-l border-gray relative z-20"
|
|
653
670
|
},
|
|
654
671
|
children: [
|
|
@@ -709,7 +726,7 @@ const useRailRows = ({
|
|
|
709
726
|
params = {},
|
|
710
727
|
path = ""
|
|
711
728
|
}) => {
|
|
712
|
-
const { set } = useRail();
|
|
729
|
+
const { set } = useRail(path);
|
|
713
730
|
const page = useRailPage({ campaign, params, path });
|
|
714
731
|
const count = (0, import_rail.railCount)((0, import_rail.railItems)({ account, campaign, organization, page, params, path }));
|
|
715
732
|
return [
|
|
@@ -23,8 +23,8 @@ const titles = {
|
|
|
23
23
|
};
|
|
24
24
|
const RING_MS = 3e3;
|
|
25
25
|
const RAIL_MS = 200;
|
|
26
|
-
const useRail = () => {
|
|
27
|
-
var _a;
|
|
26
|
+
const useRail = (path) => {
|
|
27
|
+
var _a, _b;
|
|
28
28
|
const queryClient = useQueryClient();
|
|
29
29
|
const rail = useQuery({
|
|
30
30
|
queryFn: () => ({
|
|
@@ -33,11 +33,13 @@ const useRail = () => {
|
|
|
33
33
|
queryKey: ["rail"]
|
|
34
34
|
});
|
|
35
35
|
return {
|
|
36
|
-
|
|
36
|
+
opened: (_a = rail.data) == null ? void 0 : _a.path,
|
|
37
|
+
panel: ((_b = rail.data) == null ? void 0 : _b.panel) || null,
|
|
37
38
|
set: (panel) => queryClient.setQueryData(
|
|
38
39
|
["rail"],
|
|
39
40
|
{
|
|
40
|
-
panel
|
|
41
|
+
panel,
|
|
42
|
+
path
|
|
41
43
|
}
|
|
42
44
|
)
|
|
43
45
|
};
|
|
@@ -188,7 +190,7 @@ const ScreenGuide = ({
|
|
|
188
190
|
},
|
|
189
191
|
key
|
|
190
192
|
)),
|
|
191
|
-
step.target !== "body"
|
|
193
|
+
step.target !== "body" && /* @__PURE__ */ jsx(
|
|
192
194
|
Button,
|
|
193
195
|
{
|
|
194
196
|
...{
|
|
@@ -199,14 +201,6 @@ const ScreenGuide = ({
|
|
|
199
201
|
},
|
|
200
202
|
children: "Show me"
|
|
201
203
|
}
|
|
202
|
-
) : /* @__PURE__ */ jsx(
|
|
203
|
-
"p",
|
|
204
|
-
{
|
|
205
|
-
...{
|
|
206
|
-
className: "text-sm text-gray-dark"
|
|
207
|
-
},
|
|
208
|
-
children: "Applies to the whole screen"
|
|
209
|
-
}
|
|
210
204
|
)
|
|
211
205
|
]
|
|
212
206
|
}
|
|
@@ -355,7 +349,7 @@ const TemplateRail = ({
|
|
|
355
349
|
path = ""
|
|
356
350
|
}) => {
|
|
357
351
|
const queryClient = useQueryClient();
|
|
358
|
-
const { panel, set } = useRail();
|
|
352
|
+
const { opened, panel, set } = useRail(path);
|
|
359
353
|
const items = railItems({
|
|
360
354
|
account,
|
|
361
355
|
campaign,
|
|
@@ -371,7 +365,9 @@ const TemplateRail = ({
|
|
|
371
365
|
});
|
|
372
366
|
const view = railView({
|
|
373
367
|
guide,
|
|
368
|
+
opened,
|
|
374
369
|
panel,
|
|
370
|
+
path,
|
|
375
371
|
support
|
|
376
372
|
});
|
|
377
373
|
const [previous, setPrevious] = useState(view);
|
|
@@ -392,7 +388,8 @@ const TemplateRail = ({
|
|
|
392
388
|
const toggle = (next) => set(view === next ? null : next);
|
|
393
389
|
const close = () => set(null);
|
|
394
390
|
const aside = useRef(null);
|
|
395
|
-
const
|
|
391
|
+
const nav = useRef(null);
|
|
392
|
+
const wasOpen = useRef(Boolean(view));
|
|
396
393
|
const arrived = useRef(Boolean(view));
|
|
397
394
|
if (!view) arrived.current = false;
|
|
398
395
|
const opener = useRef(null);
|
|
@@ -452,8 +449,8 @@ const TemplateRail = ({
|
|
|
452
449
|
() => {
|
|
453
450
|
var _a, _b;
|
|
454
451
|
const open = Boolean(view);
|
|
455
|
-
if (open ===
|
|
456
|
-
|
|
452
|
+
if (open === wasOpen.current) return;
|
|
453
|
+
wasOpen.current = open;
|
|
457
454
|
if (open) {
|
|
458
455
|
opener.current = document.activeElement;
|
|
459
456
|
(_a = aside.current) == null ? void 0 : _a.focus();
|
|
@@ -464,6 +461,25 @@ const TemplateRail = ({
|
|
|
464
461
|
},
|
|
465
462
|
[view]
|
|
466
463
|
);
|
|
464
|
+
useEffect(
|
|
465
|
+
() => {
|
|
466
|
+
if (view !== "guide") return void 0;
|
|
467
|
+
const onPointerDown = ({ target }) => {
|
|
468
|
+
var _a, _b;
|
|
469
|
+
if (((_a = aside.current) == null ? void 0 : _a.contains(target)) || ((_b = nav.current) == null ? void 0 : _b.contains(target))) return;
|
|
470
|
+
opener.current = null;
|
|
471
|
+
queryClient.setQueryData(
|
|
472
|
+
["rail"],
|
|
473
|
+
{
|
|
474
|
+
panel: null
|
|
475
|
+
}
|
|
476
|
+
);
|
|
477
|
+
};
|
|
478
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
479
|
+
return () => document.removeEventListener("pointerdown", onPointerDown);
|
|
480
|
+
},
|
|
481
|
+
[queryClient, view]
|
|
482
|
+
);
|
|
467
483
|
const phone = () => window.matchMedia("(max-width: 767px)").matches;
|
|
468
484
|
useTrap(
|
|
469
485
|
Boolean(view),
|
|
@@ -614,6 +630,7 @@ const TemplateRail = ({
|
|
|
614
630
|
{
|
|
615
631
|
...{
|
|
616
632
|
"aria-label": "Rail",
|
|
633
|
+
ref: nav,
|
|
617
634
|
className: "hidden md:flex flex-col items-center gap-2 w-12 h-full shrink-0 py-3 bg-white border-l border-gray relative z-20"
|
|
618
635
|
},
|
|
619
636
|
children: [
|
|
@@ -674,7 +691,7 @@ const useRailRows = ({
|
|
|
674
691
|
params = {},
|
|
675
692
|
path = ""
|
|
676
693
|
}) => {
|
|
677
|
-
const { set } = useRail();
|
|
694
|
+
const { set } = useRail(path);
|
|
678
695
|
const page = useRailPage({ campaign, params, path });
|
|
679
696
|
const count = railCount(railItems({ account, campaign, organization, page, params, path }));
|
|
680
697
|
return [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drawbridge/components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.41",
|
|
4
4
|
"exports": {
|
|
5
5
|
"./advertisement": {
|
|
6
6
|
"types": "./types/advertisement.d.ts",
|
|
@@ -1954,7 +1954,7 @@
|
|
|
1954
1954
|
"@analytics/google-tag-manager": "0.5.5",
|
|
1955
1955
|
"@drawbridge/drawbridge-agents": "0.1.104",
|
|
1956
1956
|
"@drawbridge/drawbridge-telemetry": "0.0.19",
|
|
1957
|
-
"@drawbridge/drawbridge-utils": "0.0.
|
|
1957
|
+
"@drawbridge/drawbridge-utils": "0.0.238",
|
|
1958
1958
|
"@headlessui/react": "2.2.9",
|
|
1959
1959
|
"@hookform/resolvers": "3.1.1",
|
|
1960
1960
|
"@sentry/nextjs": "10.58.0",
|