@brdgapp/ui 0.1.1 → 1.0.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/CHANGELOG.md +83 -0
- package/README.md +39 -85
- package/components/action-menu.d.ts +65 -0
- package/components/action-menu.js +48 -0
- package/components/avatar.d.ts +50 -0
- package/components/avatar.js +91 -0
- package/components/badge.d.ts +12 -0
- package/components/badge.js +23 -0
- package/components/bottom-sheet.d.ts +17 -0
- package/components/bottom-sheet.js +12 -0
- package/components/brand-mark.d.ts +20 -0
- package/components/brand-mark.js +44 -0
- package/components/button-group.d.ts +25 -0
- package/components/button-group.js +53 -0
- package/components/button.d.ts +33 -0
- package/components/button.js +82 -0
- package/components/card.d.ts +78 -0
- package/components/card.js +75 -0
- package/components/checkbox.d.ts +22 -0
- package/components/checkbox.js +35 -0
- package/components/collapsible.d.ts +29 -0
- package/components/collapsible.js +38 -0
- package/components/column-filter-menu.d.ts +15 -0
- package/components/column-filter-menu.js +30 -0
- package/components/column-sort-button.d.ts +18 -0
- package/components/column-sort-button.js +14 -0
- package/components/confirm-dialog.d.ts +20 -0
- package/components/confirm-dialog.js +17 -0
- package/components/copy-field.d.ts +17 -0
- package/components/copy-field.js +36 -0
- package/components/data-state.d.ts +44 -0
- package/components/data-state.js +25 -0
- package/components/data-table.d.ts +65 -0
- package/components/data-table.js +84 -0
- package/components/dialog.d.ts +19 -0
- package/components/dialog.js +10 -0
- package/components/drawer.d.ts +21 -0
- package/components/drawer.js +17 -0
- package/components/expandable-bio.d.ts +8 -0
- package/components/expandable-bio.js +26 -0
- package/components/field.d.ts +29 -0
- package/components/field.js +27 -0
- package/components/filter-chip.d.ts +11 -0
- package/components/filter-chip.js +8 -0
- package/components/filter-pill.d.ts +34 -0
- package/components/filter-pill.js +35 -0
- package/components/hover-card.d.ts +21 -0
- package/components/hover-card.js +20 -0
- package/components/icon-button.d.ts +16 -0
- package/components/icon-button.js +32 -0
- package/components/illustration.d.ts +33 -0
- package/components/illustration.js +70 -0
- package/components/info-hint.d.ts +29 -0
- package/components/info-hint.js +42 -0
- package/components/input.d.ts +9 -0
- package/components/input.js +15 -0
- package/components/network-graph.d.ts +48 -0
- package/components/network-graph.js +37 -0
- package/components/page-banner.d.ts +20 -0
- package/components/page-banner.js +29 -0
- package/components/scene.d.ts +12 -0
- package/components/scene.js +7 -0
- package/components/search-input.d.ts +8 -0
- package/components/search-input.js +14 -0
- package/components/segmented-control.d.ts +18 -0
- package/components/segmented-control.js +14 -0
- package/components/skeleton.d.ts +12 -0
- package/components/skeleton.js +21 -0
- package/components/skip-link.d.ts +8 -0
- package/components/skip-link.js +7 -0
- package/components/stat-box.d.ts +23 -0
- package/components/stat-box.js +29 -0
- package/components/switch.d.ts +13 -0
- package/components/switch.js +8 -0
- package/components/tabs.d.ts +6 -0
- package/components/tabs.js +25 -0
- package/components/tag-input.d.ts +15 -0
- package/components/tag-input.js +40 -0
- package/components/tag.d.ts +27 -0
- package/components/tag.js +35 -0
- package/components/textarea.d.ts +12 -0
- package/components/textarea.js +78 -0
- package/components/theme-switch.d.ts +6 -0
- package/components/theme-switch.js +16 -0
- package/components/toast.d.ts +25 -0
- package/components/toast.js +44 -0
- package/hooks/use-is-mobile.d.ts +2 -0
- package/hooks/use-is-mobile.js +16 -0
- package/hooks/use-mock-query.d.ts +23 -0
- package/hooks/use-mock-query.js +36 -0
- package/hooks/use-theme.d.ts +11 -0
- package/hooks/use-theme.js +34 -0
- package/lib/demo-controls.d.ts +24 -0
- package/lib/demo-controls.js +24 -0
- package/lib/format.d.ts +17 -0
- package/lib/format.js +55 -0
- package/lib/layout.d.ts +19 -0
- package/lib/layout.js +24 -0
- package/lib/motion.d.ts +16 -0
- package/lib/motion.js +18 -0
- package/lib/theme.d.ts +21 -0
- package/lib/theme.js +63 -0
- package/lib/utils.d.ts +22 -0
- package/lib/utils.js +27 -0
- package/package.json +32 -16
- package/styles/globals.css +595 -0
- package/src/index.ts +0 -18
- package/src/network-people-helper/README.md +0 -130
- package/src/network-people-helper/api.ts +0 -174
- package/src/network-people-helper/contact-avatar.tsx +0 -63
- package/src/network-people-helper/domain.ts +0 -14
- package/src/network-people-helper/icons.tsx +0 -130
- package/src/network-people-helper/index.ts +0 -6
- package/src/network-people-helper/network-people-helper.tsx +0 -397
- package/src/network-people-helper/network-people-nudge.tsx +0 -98
- package/src/network-people-helper/open-helper.ts +0 -22
- package/src/network-people-helper/person-menu.tsx +0 -211
- package/src/network-people-helper/styles.css +0 -848
- package/src/network-people-helper/types.ts +0 -23
- package/src/network-people-helper/use-network-people-list.ts +0 -122
- package/src/network-people-helper/use-network-preview.ts +0 -43
- package/src/provider.tsx +0 -59
- package/src/styles.css +0 -1
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
# Network people helper
|
|
2
|
-
|
|
3
|
-
Shows how many people you know at a specific domain, and who they are, from the signed-in user’s Bridge network.
|
|
4
|
-
|
|
5
|
-
Use it on any screen that is about one company or firm. Pass that domain. The component looks up the signed-in user’s contacts whose email domain matches, then renders a floating widget: “You know 6 people at Brdg”, with avatars. Opening it lists those people (name, role, company, email) so the user can make an intro, copy an intro link, or open a Bridge profile. Apps can add their own row actions, such as adding the person as a team member.
|
|
6
|
-
|
|
7
|
-
Nothing appears when the user is signed out, or when they know nobody at that domain.
|
|
8
|
-
|
|
9
|
-
The app must already wrap the tree in `BridgeUIProvider`. See the [package README](../../README.md).
|
|
10
|
-
|
|
11
|
-
## Floating widget
|
|
12
|
-
|
|
13
|
-
```tsx
|
|
14
|
-
import { NetworkPeopleHelper } from "@brdgapp/ui"
|
|
15
|
-
|
|
16
|
-
<NetworkPeopleHelper
|
|
17
|
-
domain={domain}
|
|
18
|
-
placement="bottom-end"
|
|
19
|
-
customActions={[
|
|
20
|
-
{
|
|
21
|
-
id: "add-team-member",
|
|
22
|
-
label: "Add as team member",
|
|
23
|
-
description: "Save them on this firm's team so they show up with the rest of the roster.",
|
|
24
|
-
onSelect: (contact) => addTeamMember(contact),
|
|
25
|
-
},
|
|
26
|
-
]}
|
|
27
|
-
/>
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
`domain` is required. The component cleans it (strips protocol, `www.`, path, and query) and sends it as `domain_override`.
|
|
31
|
-
|
|
32
|
-
### What it requests
|
|
33
|
-
|
|
34
|
-
After about 3 seconds on the page it requests:
|
|
35
|
-
|
|
36
|
-
- `GET {apiBaseUrl}/search/owned_full_network_contacts/count?domain_override=`
|
|
37
|
-
- `GET {apiBaseUrl}/search/owned_full_network_contacts?domain_override=&limit=&offset=`
|
|
38
|
-
|
|
39
|
-
Requests send `Authorization: Bearer <token>` from the provider’s `getAccessToken`.
|
|
40
|
-
|
|
41
|
-
When the count is greater than zero, the widget appears: icon, then the “You know N people at …” note, then a searchable list with infinite scroll. “Do not show again” hides it for the rest of the browser session (`sessionStorage` key `bridge-network-helper-dismissed:<domain>`).
|
|
42
|
-
|
|
43
|
-
### Props
|
|
44
|
-
|
|
45
|
-
| Prop | Required | Default | Purpose |
|
|
46
|
-
| --- | --- | --- | --- |
|
|
47
|
-
| `domain` | yes | — | Company or firm domain to match contacts against. |
|
|
48
|
-
| `organizationLabel` | no | cleaned domain | Text after “at”. Pass a display name such as `"Brdg"` when the screen already has one. The contacts API does not return an organization name. |
|
|
49
|
-
| `enabled` | no | `true` | Set `false` to skip the request and render nothing. |
|
|
50
|
-
| `checkDelayMs` | no | `3000` | Wait after the page visit before the first request. |
|
|
51
|
-
| `placement` | no | `"bottom-end"` | Fixed corner. See below. |
|
|
52
|
-
| `className` | no | — | Extra class on the fixed root. |
|
|
53
|
-
| `style` | no | — | Extra inline style on the fixed root. |
|
|
54
|
-
| `customActions` | no | `[]` | Extra rows in each person’s menu. |
|
|
55
|
-
|
|
56
|
-
`placement` is one of `"bottom-end"`, `"bottom-start"`, `"top-end"`, `"top-start"`. `"bottom-end"` is fixed, bottom-right, with a slightly larger offset from 640px up.
|
|
57
|
-
|
|
58
|
-
Override that position in the app’s CSS. These variables win over the preset:
|
|
59
|
-
|
|
60
|
-
```css
|
|
61
|
-
.my-helper {
|
|
62
|
-
--bridge-helper-bottom: 5rem;
|
|
63
|
-
--bridge-helper-right: 2rem;
|
|
64
|
-
--bridge-helper-z: 50;
|
|
65
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
The full set is `--bridge-helper-top`, `--bridge-helper-right`, `--bridge-helper-bottom`, `--bridge-helper-left`, and `--bridge-helper-z`.
|
|
69
|
-
|
|
70
|
-
Colors follow the host app’s `--foreground`, `--background`, `--muted`, `--muted-foreground`, and `--border` when those exist. Otherwise the widget uses its own defaults. The Bridge blue accent is `#0038ff`.
|
|
71
|
-
|
|
72
|
-
### Person menu
|
|
73
|
-
|
|
74
|
-
Built-in actions, shown only when the contact has the field they need:
|
|
75
|
-
|
|
76
|
-
- **Make intro** opens `https://intros.brdg.app/inbox?action=make-intro&n1=<email>` when `email` is set.
|
|
77
|
-
- **Copy intro link** copies `shareLink`.
|
|
78
|
-
- **View Bridge profile** opens `https://os.brdg.app/to/<username>` when `username` is set.
|
|
79
|
-
|
|
80
|
-
Change those URLs with `introInboxUrl` and `profileUrlForUsername` on `BridgeUIProvider`.
|
|
81
|
-
|
|
82
|
-
Custom actions are not built in. “Add as team member” and “Add as founder” belong to the app. Pass them only on the screens where they apply. `onSelect` receives the row’s contact:
|
|
83
|
-
|
|
84
|
-
```ts
|
|
85
|
-
type NetworkContact = {
|
|
86
|
-
id: string
|
|
87
|
-
name: string
|
|
88
|
-
email: string | null
|
|
89
|
-
shareLink: string | null
|
|
90
|
-
profilePicUrl: string | null
|
|
91
|
-
position: string | null
|
|
92
|
-
company: string | null
|
|
93
|
-
username: string | null
|
|
94
|
-
isMember: boolean
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
type NetworkPersonAction = {
|
|
98
|
-
id: string
|
|
99
|
-
label: string
|
|
100
|
-
description?: string
|
|
101
|
-
icon?: React.ReactNode
|
|
102
|
-
onSelect: (contact: NetworkContact) => void
|
|
103
|
-
}
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
Custom actions render above the built-in ones. The component does not check edit permission. If the user must not see an action, omit it from `customActions`.
|
|
107
|
-
|
|
108
|
-
## Inline nudge
|
|
109
|
-
|
|
110
|
-
`NetworkPeopleNudge` is the same note, inline in a team or founders section. It uses the same request as the floating helper. Clicking it opens the helper’s people list on this page.
|
|
111
|
-
|
|
112
|
-
```tsx
|
|
113
|
-
import { NetworkPeopleNudge } from "@brdgapp/ui"
|
|
114
|
-
|
|
115
|
-
<NetworkPeopleNudge domain={domain} organizationLabel={displayName} />
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
Pass `onOpen` when the click should do something else. `organizationLabel`, `enabled`, and `className` match the helper.
|
|
119
|
-
|
|
120
|
-
`openNetworkPeopleHelper(domain)` opens the floating helper from any other button. It clears the session dismiss for that domain.
|
|
121
|
-
|
|
122
|
-
## Files
|
|
123
|
-
|
|
124
|
-
| File | Role |
|
|
125
|
-
| --- | --- |
|
|
126
|
-
| `network-people-helper.tsx` | Floating widget. |
|
|
127
|
-
| `network-people-nudge.tsx` | Inline note that opens the widget. |
|
|
128
|
-
| `api.ts` | Count, preview, and paged contact requests. |
|
|
129
|
-
| `styles.css` | Widget styles. Imported by the package stylesheet. |
|
|
130
|
-
| `index.ts` | Public exports for this component. |
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import { cleanDomain } from "./domain"
|
|
2
|
-
import type { BridgeClientConfig } from "../provider"
|
|
3
|
-
import type { NetworkContact } from "./types"
|
|
4
|
-
|
|
5
|
-
export const PREVIEW_LIMIT = 3
|
|
6
|
-
export const PAGE_SIZE = 20
|
|
7
|
-
const CACHE_MS = 5 * 60 * 1000
|
|
8
|
-
|
|
9
|
-
type PreviewResult = {
|
|
10
|
-
count: number
|
|
11
|
-
contacts: NetworkContact[]
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
type CacheEntry = {
|
|
15
|
-
at: number
|
|
16
|
-
data: PreviewResult
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const previewCache = new Map<string, CacheEntry>()
|
|
20
|
-
const previewInflight = new Map<string, Promise<PreviewResult>>()
|
|
21
|
-
|
|
22
|
-
type ApiContact = {
|
|
23
|
-
id?: unknown
|
|
24
|
-
ref_id?: unknown
|
|
25
|
-
name?: unknown
|
|
26
|
-
given_name?: unknown
|
|
27
|
-
email?: unknown
|
|
28
|
-
share_link?: unknown
|
|
29
|
-
profile_pic_url?: unknown
|
|
30
|
-
position?: unknown
|
|
31
|
-
company?: unknown
|
|
32
|
-
username?: unknown
|
|
33
|
-
is_member?: unknown
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function mapShareLink(raw: unknown): string | null {
|
|
37
|
-
if (typeof raw !== "string") return null
|
|
38
|
-
const trimmed = raw.trim()
|
|
39
|
-
if (!trimmed) return null
|
|
40
|
-
if (/^https?:\/\//i.test(trimmed)) return trimmed
|
|
41
|
-
if (trimmed.startsWith("/")) return `https://brdg.app${trimmed}`
|
|
42
|
-
return `https://brdg.app/${trimmed}`
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function mapContact(raw: ApiContact): NetworkContact | null {
|
|
46
|
-
const id = String(raw.id ?? raw.ref_id ?? "").trim()
|
|
47
|
-
if (!id) return null
|
|
48
|
-
const name =
|
|
49
|
-
(typeof raw.name === "string" && raw.name.trim()) ||
|
|
50
|
-
(typeof raw.given_name === "string" && raw.given_name.trim()) ||
|
|
51
|
-
"Contact"
|
|
52
|
-
const username = typeof raw.username === "string" && raw.username.trim() ? raw.username.trim() : null
|
|
53
|
-
return {
|
|
54
|
-
id,
|
|
55
|
-
name,
|
|
56
|
-
email: typeof raw.email === "string" && raw.email.trim() ? raw.email.trim() : null,
|
|
57
|
-
shareLink: mapShareLink(raw.share_link),
|
|
58
|
-
profilePicUrl:
|
|
59
|
-
typeof raw.profile_pic_url === "string" && raw.profile_pic_url.trim()
|
|
60
|
-
? raw.profile_pic_url.trim()
|
|
61
|
-
: null,
|
|
62
|
-
position: typeof raw.position === "string" && raw.position.trim() ? raw.position.trim() : null,
|
|
63
|
-
company: typeof raw.company === "string" && raw.company.trim() ? raw.company.trim() : null,
|
|
64
|
-
username,
|
|
65
|
-
isMember: raw.is_member === true && Boolean(username),
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async function bridgeGet(config: BridgeClientConfig, pathWithQuery: string): Promise<unknown> {
|
|
70
|
-
const token = await config.getAccessToken()
|
|
71
|
-
if (!token) {
|
|
72
|
-
const error = new Error("Not authenticated")
|
|
73
|
-
error.name = "BridgeAuthError"
|
|
74
|
-
throw error
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const response = await fetch(`${config.apiBaseUrl}${pathWithQuery}`, {
|
|
78
|
-
method: "GET",
|
|
79
|
-
headers: {
|
|
80
|
-
Accept: "application/json",
|
|
81
|
-
Authorization: `Bearer ${token}`,
|
|
82
|
-
},
|
|
83
|
-
cache: "no-store",
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
if (!response.ok) {
|
|
87
|
-
const error = new Error("Failed to load network contacts.")
|
|
88
|
-
error.name = response.status === 401 ? "BridgeAuthError" : "BridgeRequestError"
|
|
89
|
-
throw error
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return response.json()
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function cacheKey(config: BridgeClientConfig, domain: string, token: string): string {
|
|
96
|
-
return `${config.apiBaseUrl}|${token}|${domain}`
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export function fetchNetworkPreview(config: BridgeClientConfig, domain: string): Promise<PreviewResult> {
|
|
100
|
-
const cleaned = cleanDomain(domain)
|
|
101
|
-
if (!cleaned) return Promise.resolve({ count: 0, contacts: [] })
|
|
102
|
-
|
|
103
|
-
const inflightKey = `${config.apiBaseUrl}|${cleaned}`
|
|
104
|
-
const existing = previewInflight.get(inflightKey)
|
|
105
|
-
if (existing) return existing
|
|
106
|
-
|
|
107
|
-
const request = loadCachedPreview(config, cleaned).finally(() => {
|
|
108
|
-
previewInflight.delete(inflightKey)
|
|
109
|
-
})
|
|
110
|
-
previewInflight.set(inflightKey, request)
|
|
111
|
-
return request
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
async function loadCachedPreview(config: BridgeClientConfig, domain: string): Promise<PreviewResult> {
|
|
115
|
-
const token = await config.getAccessToken()
|
|
116
|
-
if (!token) return { count: 0, contacts: [] }
|
|
117
|
-
|
|
118
|
-
const key = cacheKey(config, domain, token)
|
|
119
|
-
const cached = previewCache.get(key)
|
|
120
|
-
if (cached && Date.now() - cached.at < CACHE_MS) return cached.data
|
|
121
|
-
|
|
122
|
-
const data = await loadPreview(config, domain)
|
|
123
|
-
previewCache.set(key, { at: Date.now(), data })
|
|
124
|
-
return data
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
async function loadPreview(config: BridgeClientConfig, domain: string): Promise<PreviewResult> {
|
|
128
|
-
const baseParams = new URLSearchParams({ domain_override: domain })
|
|
129
|
-
const listParams = new URLSearchParams(baseParams)
|
|
130
|
-
listParams.set("limit", String(PREVIEW_LIMIT))
|
|
131
|
-
listParams.set("offset", "0")
|
|
132
|
-
|
|
133
|
-
const [countBody, listBody] = await Promise.all([
|
|
134
|
-
bridgeGet(config, `/search/owned_full_network_contacts/count?${baseParams.toString()}`),
|
|
135
|
-
bridgeGet(config, `/search/owned_full_network_contacts?${listParams.toString()}`),
|
|
136
|
-
])
|
|
137
|
-
|
|
138
|
-
const countRaw = (countBody as { count?: unknown })?.count
|
|
139
|
-
const count = typeof countRaw === "number" && countRaw >= 0 ? countRaw : 0
|
|
140
|
-
const contactsRaw = (listBody as { contacts?: unknown })?.contacts
|
|
141
|
-
const contacts = Array.isArray(contactsRaw)
|
|
142
|
-
? contactsRaw
|
|
143
|
-
.map((item) => mapContact(item as ApiContact))
|
|
144
|
-
.filter((item): item is NetworkContact => item !== null)
|
|
145
|
-
.slice(0, PREVIEW_LIMIT)
|
|
146
|
-
: []
|
|
147
|
-
|
|
148
|
-
return { count, contacts }
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export async function fetchNetworkPage(
|
|
152
|
-
config: BridgeClientConfig,
|
|
153
|
-
domain: string,
|
|
154
|
-
options: { offset: number; search?: string },
|
|
155
|
-
): Promise<NetworkContact[]> {
|
|
156
|
-
const cleaned = cleanDomain(domain)
|
|
157
|
-
if (!cleaned) return []
|
|
158
|
-
|
|
159
|
-
const offset = Math.max(options.offset, 0)
|
|
160
|
-
const search = options.search?.trim() ?? ""
|
|
161
|
-
const params = new URLSearchParams({
|
|
162
|
-
domain_override: cleaned,
|
|
163
|
-
limit: String(PAGE_SIZE),
|
|
164
|
-
offset: String(offset),
|
|
165
|
-
})
|
|
166
|
-
if (search) params.set("s", search)
|
|
167
|
-
|
|
168
|
-
const body = await bridgeGet(config, `/search/owned_full_network_contacts?${params.toString()}`)
|
|
169
|
-
const contactsRaw = (body as { contacts?: unknown })?.contacts
|
|
170
|
-
if (!Array.isArray(contactsRaw)) return []
|
|
171
|
-
return contactsRaw
|
|
172
|
-
.map((item) => mapContact(item as ApiContact))
|
|
173
|
-
.filter((item): item is NetworkContact => item !== null)
|
|
174
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import { useState, type CSSProperties } from "react"
|
|
4
|
-
import { CheckIcon } from "./icons"
|
|
5
|
-
import type { NetworkContact } from "./types"
|
|
6
|
-
|
|
7
|
-
const FALLBACK_COUNT = 6
|
|
8
|
-
|
|
9
|
-
function initials(name: string): string {
|
|
10
|
-
const parts = name.trim().split(/\s+/).filter(Boolean)
|
|
11
|
-
if (parts.length === 0) return "?"
|
|
12
|
-
if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase()
|
|
13
|
-
return `${parts[0][0] ?? ""}${parts[parts.length - 1][0] ?? ""}`.toUpperCase()
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function colorIndex(seed: string): number {
|
|
17
|
-
if (!seed) return 0
|
|
18
|
-
const code = seed.charCodeAt(0)
|
|
19
|
-
return Number.isFinite(code) ? code % FALLBACK_COUNT : 0
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function ContactAvatar({
|
|
23
|
-
contact,
|
|
24
|
-
size = "sm",
|
|
25
|
-
style,
|
|
26
|
-
}: {
|
|
27
|
-
contact: Pick<NetworkContact, "id" | "name" | "profilePicUrl" | "username" | "isMember">
|
|
28
|
-
size?: "sm" | "md"
|
|
29
|
-
style?: CSSProperties
|
|
30
|
-
}) {
|
|
31
|
-
const [hasError, setHasError] = useState(false)
|
|
32
|
-
const showImage = Boolean(contact.profilePicUrl) && !hasError
|
|
33
|
-
const isMember = contact.isMember || Boolean(contact.username)
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<span
|
|
37
|
-
className={`bridge-network-helper-avatar bridge-network-helper-avatar--${size}`}
|
|
38
|
-
style={style}
|
|
39
|
-
title={contact.name}
|
|
40
|
-
>
|
|
41
|
-
<span className="bridge-network-helper-avatar__face">
|
|
42
|
-
{showImage ? (
|
|
43
|
-
<img
|
|
44
|
-
src={contact.profilePicUrl ?? undefined}
|
|
45
|
-
alt=""
|
|
46
|
-
onError={() => setHasError(true)}
|
|
47
|
-
loading="lazy"
|
|
48
|
-
referrerPolicy="no-referrer"
|
|
49
|
-
/>
|
|
50
|
-
) : (
|
|
51
|
-
<span className={`bridge-network-helper-avatar__fallback is-${colorIndex(contact.name || contact.id)}`}>
|
|
52
|
-
{initials(contact.name)}
|
|
53
|
-
</span>
|
|
54
|
-
)}
|
|
55
|
-
</span>
|
|
56
|
-
{isMember ? (
|
|
57
|
-
<span className="bridge-network-helper-avatar__badge" aria-label="Bridge member" title="Bridge member">
|
|
58
|
-
<CheckIcon />
|
|
59
|
-
</span>
|
|
60
|
-
) : null}
|
|
61
|
-
</span>
|
|
62
|
-
)
|
|
63
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export function cleanDomain(domain: string): string {
|
|
2
|
-
if (!domain || typeof domain !== "string") return ""
|
|
3
|
-
let cleaned = domain.trim().replace(/^https?:\/\//i, "")
|
|
4
|
-
cleaned = cleaned.replace(/^www\./i, "")
|
|
5
|
-
cleaned = cleaned.replace(/\/+$/, "")
|
|
6
|
-
cleaned = cleaned.split("/")[0]?.split("?")[0] ?? ""
|
|
7
|
-
return cleaned.toLowerCase()
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function organizationLabelFromDomain(domain: string, organizationLabel?: string | null): string {
|
|
11
|
-
const custom = organizationLabel?.trim()
|
|
12
|
-
if (custom) return custom
|
|
13
|
-
return cleanDomain(domain)
|
|
14
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import type { ReactNode, SVGProps } from "react"
|
|
2
|
-
|
|
3
|
-
type IconProps = SVGProps<SVGSVGElement>
|
|
4
|
-
|
|
5
|
-
function Icon({ children, ...props }: IconProps & { children: ReactNode }) {
|
|
6
|
-
return (
|
|
7
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" aria-hidden="true" {...props}>
|
|
8
|
-
{children}
|
|
9
|
-
</svg>
|
|
10
|
-
)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function SearchIcon(props: IconProps) {
|
|
14
|
-
return (
|
|
15
|
-
<Icon {...props}>
|
|
16
|
-
<circle cx="11" cy="11" r="7" />
|
|
17
|
-
<path d="m20 20-3.5-3.5" strokeLinecap="round" />
|
|
18
|
-
</Icon>
|
|
19
|
-
)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function EyeOffIcon(props: IconProps) {
|
|
23
|
-
return (
|
|
24
|
-
<Icon {...props}>
|
|
25
|
-
<path d="M3 3l18 18" strokeLinecap="round" />
|
|
26
|
-
<path d="M10.6 10.6a2 2 0 0 0 2.8 2.8" strokeLinecap="round" />
|
|
27
|
-
<path d="M9.9 5.1A10.8 10.8 0 0 1 12 5c6 0 10 7 10 7a18 18 0 0 1-3.2 4.1" strokeLinecap="round" />
|
|
28
|
-
<path d="M6.1 6.1A18 18 0 0 0 2 12s4 7 10 7a10.8 10.8 0 0 0 4.1-.8" strokeLinecap="round" />
|
|
29
|
-
</Icon>
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function ChevronUpIcon(props: IconProps) {
|
|
34
|
-
return (
|
|
35
|
-
<Icon {...props}>
|
|
36
|
-
<path d="m6 14 6-6 6 6" strokeLinecap="round" strokeLinejoin="round" />
|
|
37
|
-
</Icon>
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function ChevronDownIcon(props: IconProps) {
|
|
42
|
-
return (
|
|
43
|
-
<Icon {...props}>
|
|
44
|
-
<path d="m6 10 6 6 6-6" strokeLinecap="round" strokeLinejoin="round" />
|
|
45
|
-
</Icon>
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function CheckIcon(props: IconProps) {
|
|
50
|
-
return (
|
|
51
|
-
<Icon {...props}>
|
|
52
|
-
<path d="m5 12 5 5L20 7" strokeLinecap="round" strokeLinejoin="round" />
|
|
53
|
-
</Icon>
|
|
54
|
-
)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function CopyIcon(props: IconProps) {
|
|
58
|
-
return (
|
|
59
|
-
<Icon {...props}>
|
|
60
|
-
<rect x="9" y="9" width="11" height="11" rx="2" />
|
|
61
|
-
<path d="M5 15V5a2 2 0 0 1 2-2h10" strokeLinecap="round" />
|
|
62
|
-
</Icon>
|
|
63
|
-
)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function UserPlusIcon(props: IconProps) {
|
|
67
|
-
return (
|
|
68
|
-
<Icon {...props}>
|
|
69
|
-
<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2" strokeLinecap="round" />
|
|
70
|
-
<circle cx="9" cy="7" r="4" />
|
|
71
|
-
<path d="M19 8v6M22 11h-6" strokeLinecap="round" />
|
|
72
|
-
</Icon>
|
|
73
|
-
)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function LinkIcon(props: IconProps) {
|
|
77
|
-
return (
|
|
78
|
-
<Icon {...props}>
|
|
79
|
-
<path d="M10 13a5 5 0 0 0 7.1.1l2.1-2.1a5 5 0 0 0-7.1-7.1L10.7 5" strokeLinecap="round" />
|
|
80
|
-
<path d="M14 11a5 5 0 0 0-7.1-.1L4.8 13a5 5 0 0 0 7.1 7.1L13.3 19" strokeLinecap="round" />
|
|
81
|
-
</Icon>
|
|
82
|
-
)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function UserIcon(props: IconProps) {
|
|
86
|
-
return (
|
|
87
|
-
<Icon {...props}>
|
|
88
|
-
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" strokeLinecap="round" />
|
|
89
|
-
<circle cx="12" cy="7" r="4" />
|
|
90
|
-
</Icon>
|
|
91
|
-
)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export function MoreIcon(props: IconProps) {
|
|
95
|
-
return (
|
|
96
|
-
<Icon {...props}>
|
|
97
|
-
<circle cx="12" cy="5" r="1" fill="currentColor" stroke="none" />
|
|
98
|
-
<circle cx="12" cy="12" r="1" fill="currentColor" stroke="none" />
|
|
99
|
-
<circle cx="12" cy="19" r="1" fill="currentColor" stroke="none" />
|
|
100
|
-
</Icon>
|
|
101
|
-
)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export function BridgeHelperIcon({ motion = "nudge" }: { motion?: "nudge" | "wave" | "breath" | "none" }) {
|
|
105
|
-
return (
|
|
106
|
-
<svg
|
|
107
|
-
className={motion === "none" ? "helper-icon" : `helper-icon ${motion}`}
|
|
108
|
-
viewBox="0 0 109 60"
|
|
109
|
-
aria-hidden="true"
|
|
110
|
-
>
|
|
111
|
-
<g>
|
|
112
|
-
<circle className="dot d1" cx="21.5" cy="5.5" r="6" />
|
|
113
|
-
<circle className="dot d2" cx="85.5" cy="5.5" r="6" />
|
|
114
|
-
<circle className="dot d3" cx="21.5" cy="21.5" r="6" />
|
|
115
|
-
<circle className="dot d4" cx="37.5" cy="21.5" r="6" />
|
|
116
|
-
<circle className="dot d5" cx="69.5" cy="21.5" r="6" />
|
|
117
|
-
<circle className="dot d6" cx="85.5" cy="21.5" r="6" />
|
|
118
|
-
<circle className="dot d7" cx="5.5" cy="37.5" r="6" />
|
|
119
|
-
<circle className="dot d8" cx="21.5" cy="37.5" r="6" />
|
|
120
|
-
<circle className="dot d9" cx="37.5" cy="37.5" r="6" />
|
|
121
|
-
<circle className="dot d10" cx="53.5" cy="37.5" r="6" />
|
|
122
|
-
<circle className="dot d11" cx="69.5" cy="37.5" r="6" />
|
|
123
|
-
<circle className="dot d12" cx="85.5" cy="37.5" r="6" />
|
|
124
|
-
<circle className="dot d13" cx="102" cy="37.5" r="6" />
|
|
125
|
-
<circle className="dot d14" cx="21.5" cy="53.5" r="6" />
|
|
126
|
-
<circle className="dot d15" cx="85.5" cy="53.5" r="6" />
|
|
127
|
-
</g>
|
|
128
|
-
</svg>
|
|
129
|
-
)
|
|
130
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { NetworkPeopleHelper } from "./network-people-helper"
|
|
2
|
-
export type { NetworkPeopleHelperProps } from "./network-people-helper"
|
|
3
|
-
export { NetworkPeopleNudge } from "./network-people-nudge"
|
|
4
|
-
export type { NetworkPeopleNudgeProps } from "./network-people-nudge"
|
|
5
|
-
export { openNetworkPeopleHelper } from "./open-helper"
|
|
6
|
-
export type { NetworkContact, NetworkPersonAction, HelperPlacement } from "./types"
|