@orangecheck/ui 0.7.0 → 0.8.1
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/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +115 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +116 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Boxes, ChevronDown, Check } from 'lucide-react';
|
|
1
|
+
import { Boxes, ChevronDown, Check, CornerDownLeft } from 'lucide-react';
|
|
2
2
|
import Link5 from 'next/link';
|
|
3
3
|
import { useState, useRef, useEffect, useId } from 'react';
|
|
4
4
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
|
+
import { useRouter } from 'next/router';
|
|
5
6
|
import { useOcSession } from '@orangecheck/auth-client';
|
|
6
7
|
|
|
7
8
|
// src/ecosystem-switcher.tsx
|
|
@@ -337,7 +338,17 @@ function OcLogoDropdown({
|
|
|
337
338
|
const [open, setOpen] = useState(false);
|
|
338
339
|
const containerRef = useRef(null);
|
|
339
340
|
const menuId = useId();
|
|
341
|
+
const router = useRouter();
|
|
340
342
|
const currentCategory = findFamilyProperty(current)?.category ?? "hub";
|
|
343
|
+
function handleTriggerClick(e) {
|
|
344
|
+
if (e.detail >= 2) {
|
|
345
|
+
e.preventDefault();
|
|
346
|
+
setOpen(false);
|
|
347
|
+
void router.push(homeHref);
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
setOpen((v) => !v);
|
|
351
|
+
}
|
|
341
352
|
useEffect(() => {
|
|
342
353
|
if (!open) return;
|
|
343
354
|
function onDoc(e) {
|
|
@@ -370,11 +381,12 @@ function OcLogoDropdown({
|
|
|
370
381
|
"aria-haspopup": "menu",
|
|
371
382
|
"aria-expanded": open,
|
|
372
383
|
"aria-controls": menuId,
|
|
373
|
-
"aria-label": "OrangeCheck family \xB7 open property menu",
|
|
374
|
-
title: "
|
|
375
|
-
onClick:
|
|
376
|
-
className: triggerClassName ?? "group hover:bg-accent/30 -mx-1.5 -my-1 flex min-h-[40px] items-center gap-2 rounded-sm px-1.5 py-1 transition-colors",
|
|
384
|
+
"aria-label": "OrangeCheck family \xB7 click to open property menu, double-click to go home",
|
|
385
|
+
title: "single-click \xB7 family menu \xB7 double-click \xB7 go home",
|
|
386
|
+
onClick: handleTriggerClick,
|
|
387
|
+
className: triggerClassName ?? "group hover:bg-accent/30 -mx-1.5 -my-1 flex min-h-[40px] items-center gap-2 rounded-sm px-1.5 py-1 transition-colors " + (open ? "bg-accent/20" : ""),
|
|
377
388
|
"data-oc-logo-dropdown-trigger": "",
|
|
389
|
+
"data-oc-logo-dropdown-open": open ? "true" : "false",
|
|
378
390
|
children: [
|
|
379
391
|
children,
|
|
380
392
|
/* @__PURE__ */ jsx(CategoryChip, { category: currentCategory }),
|
|
@@ -383,7 +395,24 @@ function OcLogoDropdown({
|
|
|
383
395
|
ChevronDown,
|
|
384
396
|
{
|
|
385
397
|
"aria-hidden": true,
|
|
386
|
-
className: "text-muted-foreground/70 group-hover:text-foreground/80 h-3.5 w-3.5 shrink-0 transition-transform " + (open ? "rotate-180" : "")
|
|
398
|
+
className: "text-muted-foreground/70 group-hover:text-foreground/80 h-3.5 w-3.5 shrink-0 transition-transform duration-200 " + (open ? "rotate-180" : "")
|
|
399
|
+
}
|
|
400
|
+
),
|
|
401
|
+
/* @__PURE__ */ jsxs(
|
|
402
|
+
"span",
|
|
403
|
+
{
|
|
404
|
+
"aria-hidden": true,
|
|
405
|
+
className: "pointer-events-none ml-0.5 hidden items-center gap-1 font-mono text-[9px] tracking-widest uppercase transition-all duration-200 sm:inline-flex " + (open ? "text-muted-foreground/70 translate-x-0 opacity-100" : "-translate-x-1 opacity-0"),
|
|
406
|
+
"data-oc-logo-dropdown-home-hint": "",
|
|
407
|
+
children: [
|
|
408
|
+
/* @__PURE__ */ jsx(
|
|
409
|
+
CornerDownLeft,
|
|
410
|
+
{
|
|
411
|
+
className: "h-3 w-3 " + (open ? "motion-safe:animate-pulse" : "")
|
|
412
|
+
}
|
|
413
|
+
),
|
|
414
|
+
/* @__PURE__ */ jsx("span", { className: "text-primary/70", children: "home" })
|
|
415
|
+
]
|
|
387
416
|
}
|
|
388
417
|
)
|
|
389
418
|
]
|
|
@@ -492,6 +521,8 @@ function OcAccountMenuView({
|
|
|
492
521
|
signInUrl = "/signin",
|
|
493
522
|
signInLabel = "sign in",
|
|
494
523
|
menuItems,
|
|
524
|
+
primaryNavLinks,
|
|
525
|
+
secondaryNavLinks,
|
|
495
526
|
showFamilyDashboard,
|
|
496
527
|
build,
|
|
497
528
|
siteState,
|
|
@@ -613,7 +644,16 @@ function OcAccountMenuView({
|
|
|
613
644
|
/* @__PURE__ */ jsx("div", { className: "text-foreground/90 font-mono text-[11px] leading-tight break-all", children: account.didOc }),
|
|
614
645
|
displayName ? /* @__PURE__ */ jsx("div", { className: "text-muted-foreground/80 mt-1 font-mono text-[10px] tracking-wide", children: displayName }) : null
|
|
615
646
|
] }),
|
|
616
|
-
/* @__PURE__ */
|
|
647
|
+
primaryNavLinks && primaryNavLinks.length > 0 ? /* @__PURE__ */ jsx(
|
|
648
|
+
PopoverSection,
|
|
649
|
+
{
|
|
650
|
+
label: "navigate",
|
|
651
|
+
items: primaryNavLinks,
|
|
652
|
+
onItemClick: () => setOpen(false)
|
|
653
|
+
}
|
|
654
|
+
) : null,
|
|
655
|
+
/* @__PURE__ */ jsxs("div", { className: "p-1", "data-oc-account-menu-section": "account", children: [
|
|
656
|
+
primaryNavLinks && primaryNavLinks.length > 0 ? /* @__PURE__ */ jsx("div", { className: "text-muted-foreground/60 px-3 pb-1 pt-2 font-mono text-[10px] tracking-widest uppercase", children: "\xA7 account" }) : null,
|
|
617
657
|
menuItems?.map((item) => {
|
|
618
658
|
const onClick = () => setOpen(false);
|
|
619
659
|
const cls = "hover:bg-accent flex items-center gap-2 px-3 py-2 font-mono text-[11px] tracking-wide transition-colors";
|
|
@@ -699,6 +739,15 @@ function OcAccountMenuView({
|
|
|
699
739
|
}
|
|
700
740
|
)
|
|
701
741
|
] }),
|
|
742
|
+
secondaryNavLinks && secondaryNavLinks.length > 0 ? /* @__PURE__ */ jsx(
|
|
743
|
+
PopoverSection,
|
|
744
|
+
{
|
|
745
|
+
label: "more",
|
|
746
|
+
items: secondaryNavLinks,
|
|
747
|
+
onItemClick: () => setOpen(false),
|
|
748
|
+
bordered: true
|
|
749
|
+
}
|
|
750
|
+
) : null,
|
|
702
751
|
build ? /* @__PURE__ */ jsx(BuildFooter, { hostname, build, state: siteState }) : null
|
|
703
752
|
]
|
|
704
753
|
}
|
|
@@ -707,6 +756,66 @@ function OcAccountMenuView({
|
|
|
707
756
|
}
|
|
708
757
|
);
|
|
709
758
|
}
|
|
759
|
+
function PopoverSection({
|
|
760
|
+
label,
|
|
761
|
+
items,
|
|
762
|
+
onItemClick,
|
|
763
|
+
bordered
|
|
764
|
+
}) {
|
|
765
|
+
const cls = "hover:bg-accent flex items-center gap-2 px-3 py-2 font-mono text-[11px] tracking-wide transition-colors";
|
|
766
|
+
return /* @__PURE__ */ jsxs(
|
|
767
|
+
"div",
|
|
768
|
+
{
|
|
769
|
+
className: "p-1 " + (bordered ? "border-border border-t" : ""),
|
|
770
|
+
"data-oc-account-menu-section": label,
|
|
771
|
+
children: [
|
|
772
|
+
/* @__PURE__ */ jsxs("div", { className: "text-muted-foreground/60 px-3 pt-2 pb-1 font-mono text-[10px] tracking-widest uppercase", children: [
|
|
773
|
+
"\xA7 ",
|
|
774
|
+
label
|
|
775
|
+
] }),
|
|
776
|
+
items.map((item) => {
|
|
777
|
+
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
778
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", "aria-hidden": true, children: "\u2192" }),
|
|
779
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1", children: item.label }),
|
|
780
|
+
item.external ? /* @__PURE__ */ jsx(
|
|
781
|
+
"span",
|
|
782
|
+
{
|
|
783
|
+
className: "text-muted-foreground/70 text-[10px]",
|
|
784
|
+
"aria-hidden": true,
|
|
785
|
+
children: "\u2197"
|
|
786
|
+
}
|
|
787
|
+
) : null
|
|
788
|
+
] });
|
|
789
|
+
return item.external ? /* @__PURE__ */ jsx(
|
|
790
|
+
"a",
|
|
791
|
+
{
|
|
792
|
+
href: item.href,
|
|
793
|
+
target: "_blank",
|
|
794
|
+
rel: "noreferrer",
|
|
795
|
+
onClick: onItemClick,
|
|
796
|
+
role: "menuitem",
|
|
797
|
+
className: cls,
|
|
798
|
+
"data-oc-account-menu-item": "",
|
|
799
|
+
children: inner
|
|
800
|
+
},
|
|
801
|
+
item.href
|
|
802
|
+
) : /* @__PURE__ */ jsx(
|
|
803
|
+
Link5,
|
|
804
|
+
{
|
|
805
|
+
href: item.href,
|
|
806
|
+
onClick: onItemClick,
|
|
807
|
+
role: "menuitem",
|
|
808
|
+
className: cls,
|
|
809
|
+
"data-oc-account-menu-item": "",
|
|
810
|
+
children: inner
|
|
811
|
+
},
|
|
812
|
+
item.href
|
|
813
|
+
);
|
|
814
|
+
})
|
|
815
|
+
]
|
|
816
|
+
}
|
|
817
|
+
);
|
|
818
|
+
}
|
|
710
819
|
function BuildFooter({
|
|
711
820
|
hostname,
|
|
712
821
|
build,
|