@orsetra/shared-ui 1.10.20 → 1.10.23

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>
@@ -80,7 +80,7 @@ export function UserPanel({ main_base_url }: UserPanelProps) {
80
80
  {/* Droite — Business Unit */}
81
81
  <div className="flex flex-col justify-center flex-1 min-w-0 px-4 py-4">
82
82
  <span className="text-[11px] text-gray-400 uppercase tracking-widest mb-1">Business Unit</span>
83
- <span className="text-sm font-semibold text-gray-900 truncate">
83
+ <span className="text-sm font-semibold text-gray-900 uppercase truncate">
84
84
  {currentProject?.name ?? '—'}
85
85
  </span>
86
86
  <div className="flex items-center gap-3 mt-1.5">
@@ -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
- // A deeper item for this path already exists → bump its score, skip adding the shallower one
107
- const deeper = prev.find(i => prefix(normId, i.id))
108
- if (deeper) {
109
- const updated = { ...deeper, visitCount: deeper.visitCount + 1, lastVisit: Date.now() }
110
- const next = [updated, ...prev.filter(i => i.id !== deeper.id)]
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
- // Remove any shallower items that are ancestors of the new path
119
- const withoutAncestors = prev.filter(i => !prefix(i.id, normId))
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 = withoutAncestors.find(i => i.id === normId)
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, ...withoutAncestors.filter(i => i.id !== normId)]
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orsetra/shared-ui",
3
- "version": "1.10.20",
3
+ "version": "1.10.23",
4
4
  "description": "Shared UI components for Orsetra platform",
5
5
  "main": "./index.ts",
6
6
  "types": "./index.ts",