@unicitylabs/sphere-ui 0.1.0
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/README.md +192 -0
- package/dist/canvas/index.d.ts +3 -0
- package/dist/canvas/index.js +0 -0
- package/dist/forms/index.d.ts +1 -0
- package/dist/forms/index.js +0 -0
- package/dist/hooks/index.d.ts +122 -0
- package/dist/hooks/index.js +813 -0
- package/dist/index-DMHfA7fr.d.ts +90 -0
- package/dist/index-DsEO4kM1.d.ts +126 -0
- package/dist/index.d.ts +199 -0
- package/dist/index.js +1095 -0
- package/dist/panels/index.d.ts +3 -0
- package/dist/panels/index.js +0 -0
- package/package.json +60 -0
- package/src/styles/components.css +121 -0
- package/src/styles/index.css +2 -0
- package/src/styles/tokens.css +81 -0
package/README.md
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# @unicitylabs/sphere-ui
|
|
2
|
+
|
|
3
|
+
Shared UI library for the Sphere ecosystem. Provides a unified design system, components, and hooks used across all Sphere applications.
|
|
4
|
+
|
|
5
|
+
## Packages that use sphere-ui
|
|
6
|
+
|
|
7
|
+
| App | Description |
|
|
8
|
+
|-----|-------------|
|
|
9
|
+
| [sphere](https://github.com/unicity-sphere/sphere) | Wallet & marketplace |
|
|
10
|
+
| [sphere-dev](https://github.com/unicity-sphere/sphere-dev) | Developer Portal |
|
|
11
|
+
| [sphere-backoffice](https://github.com/unicity-sphere/sphere-backoffice) | Admin panel |
|
|
12
|
+
| [sphere-quest](https://github.com/unicity-sphere/sphere-quest) | Quest frontend (iframe) |
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @unicitylabs/sphere-ui
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
For local development, link from the monorepo:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install file:../sphere-ui
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
### Styles
|
|
29
|
+
|
|
30
|
+
Import the design system in your app's entry point:
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import '@unicitylabs/sphere-ui/styles';
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
This provides:
|
|
37
|
+
- Tailwind 4 theme tokens (colors, fonts, shadows, radii)
|
|
38
|
+
- Light/dark mode CSS variables
|
|
39
|
+
- Component classes (`sphere-card`, `btn-primary`, `badge-*`, `sphere-input`, etc.)
|
|
40
|
+
|
|
41
|
+
### Components
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import {
|
|
45
|
+
Field,
|
|
46
|
+
Section,
|
|
47
|
+
FormModal,
|
|
48
|
+
ConfirmDialog,
|
|
49
|
+
DataTable,
|
|
50
|
+
StatusBadge,
|
|
51
|
+
SearchInput,
|
|
52
|
+
EmptyState,
|
|
53
|
+
CustomSelect,
|
|
54
|
+
PageShell,
|
|
55
|
+
AlertBanner,
|
|
56
|
+
AddressDisplay,
|
|
57
|
+
JsonPanel,
|
|
58
|
+
JsonToggleButton,
|
|
59
|
+
ChainInput,
|
|
60
|
+
MemoConditionsEditor,
|
|
61
|
+
} from '@unicitylabs/sphere-ui';
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Hooks
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import {
|
|
68
|
+
useCanvasState,
|
|
69
|
+
useAchievementCanvasState,
|
|
70
|
+
useTestMode,
|
|
71
|
+
useChainMode,
|
|
72
|
+
useAchievementTestMode,
|
|
73
|
+
useAchievementChainMode,
|
|
74
|
+
} from '@unicitylabs/sphere-ui/hooks';
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Icons
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import {
|
|
81
|
+
IconBack, IconUndo, IconEdit, IconTrash, IconPlus,
|
|
82
|
+
IconSearch, IconCheck, IconX, IconChain, IconPlay,
|
|
83
|
+
IconStar, IconDiamond, IconCircle,
|
|
84
|
+
// ... and more
|
|
85
|
+
} from '@unicitylabs/sphere-ui';
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Types
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
import type {
|
|
92
|
+
QuestData,
|
|
93
|
+
TrackData,
|
|
94
|
+
AchievementData,
|
|
95
|
+
QuestFormApi,
|
|
96
|
+
TrackFormApi,
|
|
97
|
+
AchievementFormApi,
|
|
98
|
+
QueryKeys,
|
|
99
|
+
} from '@unicitylabs/sphere-ui';
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Design System
|
|
103
|
+
|
|
104
|
+
### Tailwind Theme Tokens
|
|
105
|
+
|
|
106
|
+
Defined in `src/styles/tokens.css` via `@theme {}` block:
|
|
107
|
+
|
|
108
|
+
| Token | Light | Dark |
|
|
109
|
+
|-------|-------|------|
|
|
110
|
+
| `--color-bg-primary` | `#f5f5f5` | `#060606` |
|
|
111
|
+
| `--color-bg-card` | `#ffffff` | `#111111` |
|
|
112
|
+
| `--color-text-primary` | `#171717` | `#fefefe` |
|
|
113
|
+
| `--color-text-muted` | `#a3a3a3` | `rgba(255,255,255,0.28)` |
|
|
114
|
+
| `--color-brand-orange` | `#FF6F00` | `#FF6F00` |
|
|
115
|
+
| `--font-display` | Anton | Anton |
|
|
116
|
+
| `--font-sans` | Geist | Geist |
|
|
117
|
+
| `--font-mono` | Geist Mono | Geist Mono |
|
|
118
|
+
|
|
119
|
+
### Component Classes
|
|
120
|
+
|
|
121
|
+
| Class | Description |
|
|
122
|
+
|-------|-------------|
|
|
123
|
+
| `sphere-card` | Card with border, radius, hover effect |
|
|
124
|
+
| `sphere-card-glow` | Card with orange glow shadow |
|
|
125
|
+
| `sphere-input` | Text input with focus ring |
|
|
126
|
+
| `sphere-textarea` | Multi-line text input |
|
|
127
|
+
| `sphere-select` | Select dropdown |
|
|
128
|
+
| `sphere-table` | Table with header/row styles |
|
|
129
|
+
| `btn-primary` | Orange primary button |
|
|
130
|
+
| `btn-secondary` | Outlined secondary button |
|
|
131
|
+
| `btn-danger` | Red danger button |
|
|
132
|
+
| `badge-green` | Green status badge |
|
|
133
|
+
| `badge-orange` | Orange status badge |
|
|
134
|
+
| `badge-gray` | Gray status badge |
|
|
135
|
+
| `badge-red` | Red status badge |
|
|
136
|
+
| `badge-blue` | Blue status badge |
|
|
137
|
+
| `badge-purple` | Purple status badge |
|
|
138
|
+
| `badge-yellow` | Yellow status badge |
|
|
139
|
+
|
|
140
|
+
Backward-compatible aliases `admin-card`, `admin-input`, etc. are also available.
|
|
141
|
+
|
|
142
|
+
## Development
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
npm install # Install dependencies
|
|
146
|
+
npm run build # Build with tsup (ESM + DTS)
|
|
147
|
+
npm run dev # Watch mode
|
|
148
|
+
npm run typecheck # TypeScript check
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Build Output
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
dist/
|
|
155
|
+
index.js # Base components + types
|
|
156
|
+
index.d.ts
|
|
157
|
+
forms/index.js # Quest/Track/Achievement form exports
|
|
158
|
+
canvas/index.js # Canvas component exports
|
|
159
|
+
panels/index.js # Panel component exports
|
|
160
|
+
hooks/index.js # Hook exports
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Architecture
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
src/
|
|
167
|
+
styles/
|
|
168
|
+
tokens.css # Tailwind 4 @theme tokens + light/dark CSS vars
|
|
169
|
+
components.css # Reusable utility classes
|
|
170
|
+
index.css # Barrel CSS import
|
|
171
|
+
components/ # 15 base UI components
|
|
172
|
+
hooks/ # 6 canvas/chain/test mode hooks
|
|
173
|
+
forms/ # Quest/Track/Achievement form barrel
|
|
174
|
+
canvas/ # Canvas component barrel
|
|
175
|
+
panels/ # Panel component barrel
|
|
176
|
+
types.ts # Shared TypeScript interfaces
|
|
177
|
+
index.ts # Main barrel export
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Peer Dependencies
|
|
181
|
+
|
|
182
|
+
- `react` ^19.0.0
|
|
183
|
+
- `react-dom` ^19.0.0
|
|
184
|
+
- `@tanstack/react-query` ^5.0.0
|
|
185
|
+
- `@tanstack/react-table` ^8.0.0
|
|
186
|
+
- `@dnd-kit/core` ^6.0.0
|
|
187
|
+
- `@dnd-kit/sortable` ^8.0.0
|
|
188
|
+
- `lucide-react` ^0.400.0
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
|
+
MIT
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { A as AchievementData, a as AchievementFormApi, b as QuestData, c as QuestFormApi, T as TrackData, d as TrackFormApi } from '../index-DMHfA7fr.js';
|
|
File without changes
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
export { A as AchPendingChange, a as AchSelectedItem, C as CanvasAchievement, b as CanvasQuest, c as CanvasTrack, P as PendingChange, S as SelectedItem, d as chainColor, g as getAchLaneId, e as getLaneId, u as useAchievementCanvasState, f as useCanvasState } from '../index-DsEO4kM1.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
import '@dnd-kit/core';
|
|
4
|
+
|
|
5
|
+
type QuestTestState = 'locked' | 'ready' | 'verifying' | 'passed' | 'failed';
|
|
6
|
+
interface TestModeState {
|
|
7
|
+
active: boolean;
|
|
8
|
+
withVerification: boolean;
|
|
9
|
+
ignoreChain: boolean;
|
|
10
|
+
completedIds: Set<string>;
|
|
11
|
+
verifyingId: string | null;
|
|
12
|
+
failedIds: Map<string, string>;
|
|
13
|
+
}
|
|
14
|
+
/** Minimal quest interface for test state computation */
|
|
15
|
+
interface TestableQuest {
|
|
16
|
+
_id: string;
|
|
17
|
+
status: string;
|
|
18
|
+
prerequisites?: string[];
|
|
19
|
+
chains?: Record<string, number>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Compute the test-mode display state for a single quest.
|
|
23
|
+
* - ignoreChain=true -> all ACTIVE quests are READY
|
|
24
|
+
* - ignoreChain=false -> respect chains map + prerequisites
|
|
25
|
+
*/
|
|
26
|
+
declare function computeQuestTestState(quest: TestableQuest, state: TestModeState, allQuests: TestableQuest[]): QuestTestState;
|
|
27
|
+
declare function useTestMode(verifyFn?: (questId: string) => Promise<{
|
|
28
|
+
passed: boolean;
|
|
29
|
+
reason?: string;
|
|
30
|
+
}>): {
|
|
31
|
+
testMode: TestModeState;
|
|
32
|
+
enterTestMode: () => void;
|
|
33
|
+
exitTestMode: () => void;
|
|
34
|
+
toggleVerification: () => void;
|
|
35
|
+
toggleIgnoreChain: () => void;
|
|
36
|
+
claimQuest: (questId: string) => Promise<void>;
|
|
37
|
+
resetTest: () => void;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** Minimal interface for chainable items */
|
|
41
|
+
interface ChainableItem {
|
|
42
|
+
_id: string;
|
|
43
|
+
chains?: Record<string, number>;
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
}
|
|
46
|
+
interface ChainModeState {
|
|
47
|
+
active: boolean;
|
|
48
|
+
selectedChain: string | null;
|
|
49
|
+
}
|
|
50
|
+
interface ChainModeActions {
|
|
51
|
+
toggle: () => void;
|
|
52
|
+
selectChain: (group: string) => void;
|
|
53
|
+
deselectChain: () => void;
|
|
54
|
+
exit: () => void;
|
|
55
|
+
}
|
|
56
|
+
interface ChainModeComputed<T> {
|
|
57
|
+
chainMap: Map<string, T[]>;
|
|
58
|
+
chainGroups: string[];
|
|
59
|
+
}
|
|
60
|
+
type ChainMode<T> = ChainModeState & ChainModeActions & ChainModeComputed<T>;
|
|
61
|
+
declare function useChainMode<T extends ChainableItem>(items: T[]): ChainMode<T>;
|
|
62
|
+
|
|
63
|
+
type AchTestState = 'locked' | 'ready' | 'completed' | 'claimed';
|
|
64
|
+
interface AchievementProgressEntry {
|
|
65
|
+
achievementId: string;
|
|
66
|
+
current?: number;
|
|
67
|
+
completed?: boolean;
|
|
68
|
+
claimed?: boolean;
|
|
69
|
+
[key: string]: unknown;
|
|
70
|
+
}
|
|
71
|
+
interface AchTestModeState {
|
|
72
|
+
active: boolean;
|
|
73
|
+
walletAddress: string;
|
|
74
|
+
ignoreChain: boolean;
|
|
75
|
+
progressMap: Map<string, AchievementProgressEntry>;
|
|
76
|
+
loading: boolean;
|
|
77
|
+
error: string | null;
|
|
78
|
+
}
|
|
79
|
+
/** Minimal achievement interface for test state computation */
|
|
80
|
+
interface TestableAchievement {
|
|
81
|
+
_id: string;
|
|
82
|
+
status: string;
|
|
83
|
+
chains?: Record<string, number>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Compute the test-mode display state for a single achievement.
|
|
87
|
+
*/
|
|
88
|
+
declare function computeAchTestState(ach: TestableAchievement, state: AchTestModeState, allAchievements: TestableAchievement[]): AchTestState;
|
|
89
|
+
declare function useAchievementTestMode(fetchProgressFn?: (address: string) => Promise<AchievementProgressEntry[]>): {
|
|
90
|
+
testMode: AchTestModeState;
|
|
91
|
+
enterTestMode: () => void;
|
|
92
|
+
exitTestMode: () => void;
|
|
93
|
+
toggleIgnoreChain: () => void;
|
|
94
|
+
setWalletAddress: (address: string) => void;
|
|
95
|
+
fetchProgress: (address?: string) => Promise<void>;
|
|
96
|
+
clearProgress: () => void;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/** Minimal interface for chainable achievements */
|
|
100
|
+
interface ChainableAchievement {
|
|
101
|
+
_id: string;
|
|
102
|
+
chains?: Record<string, number>;
|
|
103
|
+
[key: string]: unknown;
|
|
104
|
+
}
|
|
105
|
+
interface AchChainModeState {
|
|
106
|
+
active: boolean;
|
|
107
|
+
selectedChain: string | null;
|
|
108
|
+
}
|
|
109
|
+
interface AchChainModeActions {
|
|
110
|
+
toggle: () => void;
|
|
111
|
+
selectChain: (group: string) => void;
|
|
112
|
+
deselectChain: () => void;
|
|
113
|
+
exit: () => void;
|
|
114
|
+
}
|
|
115
|
+
interface AchChainModeComputed<T> {
|
|
116
|
+
chainMap: Map<string, T[]>;
|
|
117
|
+
chainGroups: string[];
|
|
118
|
+
}
|
|
119
|
+
type AchChainMode<T> = AchChainModeState & AchChainModeActions & AchChainModeComputed<T>;
|
|
120
|
+
declare function useAchievementChainMode<T extends ChainableAchievement>(achievements: T[]): AchChainMode<T>;
|
|
121
|
+
|
|
122
|
+
export { type AchChainMode, type AchChainModeActions, type AchChainModeComputed, type AchChainModeState, type AchTestModeState, type AchTestState, type AchievementProgressEntry, type ChainMode, type ChainModeActions, type ChainModeComputed, type ChainModeState, type QuestTestState, type TestModeState, computeAchTestState, computeQuestTestState, useAchievementChainMode, useAchievementTestMode, useChainMode, useTestMode };
|