@orsetra/shared-ui 1.10.18 → 1.10.22
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.
|
@@ -65,7 +65,7 @@ export function UserPanel({ main_base_url }: UserPanelProps) {
|
|
|
65
65
|
>
|
|
66
66
|
<div className="flex flex-col min-w-0 flex-1">
|
|
67
67
|
<span className="text-[11px] text-gray-400 uppercase tracking-widest mb-1">Organisation</span>
|
|
68
|
-
<span className="text-sm font-semibold text-gray-900 truncate">
|
|
68
|
+
<span className="text-sm font-semibold text-gray-900 uppercase truncate">
|
|
69
69
|
{organization?.name ?? '—'}
|
|
70
70
|
</span>
|
|
71
71
|
</div>
|
package/components/ui/index.ts
CHANGED
|
@@ -57,6 +57,7 @@ export { Sheet, SheetTrigger, SheetContent, SheetHeader, SheetFooter, SheetTitle
|
|
|
57
57
|
export { SidePanel, SidePanelTrigger, SidePanelClose, SidePanelContent, SidePanelHeader, SidePanelTitle, SidePanelDescription, SidePanelBody, SidePanelFooter } from './side-panel'
|
|
58
58
|
export { PushPanel, type PushPanelProps } from './push-panel'
|
|
59
59
|
export { Skeleton } from './skeleton'
|
|
60
|
+
export { Spinner, type SpinnerProps } from './spinner'
|
|
60
61
|
export { Slider } from './slider'
|
|
61
62
|
export { Toaster } from './toaster'
|
|
62
63
|
export { Switch } from './switch'
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
|
|
3
|
+
import { cn } from "../../lib/utils"
|
|
4
|
+
|
|
5
|
+
export interface SpinnerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
size?: "sm" | "md" | "lg"
|
|
7
|
+
/** Accessible label announced to screen readers while loading. */
|
|
8
|
+
label?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const SIZE_PX: Record<NonNullable<SpinnerProps["size"]>, number> = {
|
|
12
|
+
sm: 20,
|
|
13
|
+
md: 32,
|
|
14
|
+
lg: 48,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Branded loading indicator: the CX monogram (same mark used as the favicon across every
|
|
19
|
+
* Camel X app) with an animated ring spinning around it, instead of a generic icon spinner.
|
|
20
|
+
*/
|
|
21
|
+
function Spinner({ size = "md", label = "Loading", className, ...props }: SpinnerProps) {
|
|
22
|
+
const px = SIZE_PX[size]
|
|
23
|
+
const iconPx = Math.round(px * 0.62)
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div
|
|
27
|
+
role="status"
|
|
28
|
+
aria-label={label}
|
|
29
|
+
className={cn("relative inline-flex items-center justify-center", className)}
|
|
30
|
+
style={{ width: px, height: px }}
|
|
31
|
+
{...props}
|
|
32
|
+
>
|
|
33
|
+
<svg
|
|
34
|
+
width={px}
|
|
35
|
+
height={px}
|
|
36
|
+
viewBox="0 0 32 32"
|
|
37
|
+
className="animate-spin"
|
|
38
|
+
style={{ animationDuration: "1.1s" }}
|
|
39
|
+
>
|
|
40
|
+
<circle
|
|
41
|
+
cx="16"
|
|
42
|
+
cy="16"
|
|
43
|
+
r="14.5"
|
|
44
|
+
fill="none"
|
|
45
|
+
stroke="#0F62FE"
|
|
46
|
+
strokeOpacity="0.15"
|
|
47
|
+
strokeWidth="2.5"
|
|
48
|
+
/>
|
|
49
|
+
<circle
|
|
50
|
+
cx="16"
|
|
51
|
+
cy="16"
|
|
52
|
+
r="14.5"
|
|
53
|
+
fill="none"
|
|
54
|
+
stroke="#0F62FE"
|
|
55
|
+
strokeWidth="2.5"
|
|
56
|
+
strokeLinecap="round"
|
|
57
|
+
strokeDasharray="22 68"
|
|
58
|
+
/>
|
|
59
|
+
</svg>
|
|
60
|
+
<svg
|
|
61
|
+
width={iconPx}
|
|
62
|
+
height={iconPx}
|
|
63
|
+
viewBox="0 0 32 32"
|
|
64
|
+
className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2"
|
|
65
|
+
>
|
|
66
|
+
<rect width="32" height="32" rx="7" fill="#0F62FE" />
|
|
67
|
+
<text
|
|
68
|
+
x="16.5"
|
|
69
|
+
y="17"
|
|
70
|
+
fontFamily="Helvetica Neue, Arial, sans-serif"
|
|
71
|
+
fontWeight="700"
|
|
72
|
+
fontSize="13"
|
|
73
|
+
letterSpacing="-0.75"
|
|
74
|
+
fill="#FFFFFF"
|
|
75
|
+
textAnchor="middle"
|
|
76
|
+
dominantBaseline="central"
|
|
77
|
+
>
|
|
78
|
+
CX
|
|
79
|
+
</text>
|
|
80
|
+
</svg>
|
|
81
|
+
<span className="sr-only">{label}</span>
|
|
82
|
+
</div>
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { Spinner }
|
|
@@ -103,11 +103,13 @@ export function useQuickAccess() {
|
|
|
103
103
|
const prefix = (ancestor: string, descendant: string) =>
|
|
104
104
|
descendant !== ancestor && descendant.startsWith(ancestor.replace(/\/$/, "") + "/")
|
|
105
105
|
|
|
106
|
-
//
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
// An ancestor of the new path is already tracked → the ancestor wins: bump it,
|
|
107
|
+
// don't add the new (deeper) item at all. A parent beats any of its children
|
|
108
|
+
// because it has the more meaningful, "speaking" title.
|
|
109
|
+
const ancestorOfNew = prev.find(i => prefix(i.id, normId))
|
|
110
|
+
if (ancestorOfNew) {
|
|
111
|
+
const updated = { ...ancestorOfNew, visitCount: ancestorOfNew.visitCount + 1, lastVisit: Date.now() }
|
|
112
|
+
const next = [updated, ...prev.filter(i => i.id !== ancestorOfNew.id)]
|
|
111
113
|
.sort((a, b) => score(b) - score(a))
|
|
112
114
|
.slice(0, POOL_SIZE)
|
|
113
115
|
writeStorage(storageKey, next)
|
|
@@ -115,15 +117,16 @@ export function useQuickAccess() {
|
|
|
115
117
|
return next
|
|
116
118
|
}
|
|
117
119
|
|
|
118
|
-
//
|
|
119
|
-
|
|
120
|
+
// The new path is itself an ancestor of item(s) already tracked → it wins: drop
|
|
121
|
+
// those deeper descendants, track the new shallower item instead.
|
|
122
|
+
const withoutDescendants = prev.filter(i => !prefix(normId, i.id))
|
|
120
123
|
|
|
121
|
-
const existing =
|
|
124
|
+
const existing = withoutDescendants.find(i => i.id === normId)
|
|
122
125
|
const updated: QuickAccessItem = existing
|
|
123
126
|
? { ...existing, label: item.label, icon: item.icon, visitCount: existing.visitCount + 1, lastVisit: Date.now() }
|
|
124
127
|
: { id: normId, label: item.label, href: normId, icon: item.icon, visitCount: 1, lastVisit: Date.now() }
|
|
125
128
|
|
|
126
|
-
const next = [updated, ...
|
|
129
|
+
const next = [updated, ...withoutDescendants.filter(i => i.id !== normId)]
|
|
127
130
|
.sort((a, b) => score(b) - score(a))
|
|
128
131
|
.slice(0, POOL_SIZE)
|
|
129
132
|
|
package/lib/interceptors.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { Interceptors } from "./http-client";
|
|
2
2
|
|
|
3
|
-
// The Zitadel authority itself — a 401 straight from the identity provider (as opposed to our
|
|
4
|
-
// own API backend) means the session is truly invalid there; no retry or token refresh will
|
|
5
|
-
// help, only a full re-authentication. Each app already bakes this in via NEXT_PUBLIC_ZITADEL_AUTHORITY
|
|
6
|
-
// (this file ships as source into every app's own Next.js build, so the env var is inlined
|
|
7
|
-
// per-app exactly as it is in the services that call this authority directly).
|
|
8
|
-
const ZITADEL_AUTHORITY = process.env.NEXT_PUBLIC_ZITADEL_AUTHORITY;
|
|
9
3
|
|
|
10
4
|
export const interceptors: Interceptors = {
|
|
11
5
|
onResponse: (response: any) => {
|
|
@@ -13,10 +7,6 @@ export const interceptors: Interceptors = {
|
|
|
13
7
|
},
|
|
14
8
|
onResponseError: (error: any) => {
|
|
15
9
|
if (error.response?.status === 401 && typeof window !== 'undefined') {
|
|
16
|
-
const requestBaseUrl: string | undefined = error.config?.baseURL;
|
|
17
|
-
if (ZITADEL_AUTHORITY && requestBaseUrl === ZITADEL_AUTHORITY) {
|
|
18
|
-
window.dispatchEvent(new CustomEvent('auth-unauthorized'));
|
|
19
|
-
}
|
|
20
10
|
window.dispatchEvent(new CustomEvent('http-unauthorized'));
|
|
21
11
|
}
|
|
22
12
|
return Promise.reject(error);
|