@dbx-tools/ui 0.9.131 → 0.9.136

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 CHANGED
@@ -1,9 +1,8 @@
1
1
  # @dbx-tools/ui
2
2
 
3
- Use one tree-shakeable React package for the shared AppKit UI foundation,
4
- branding, passwordless authentication, email surfaces, and AI Search controls.
5
- Mastra chat and Teams Adaptive Cards remain separate packages because they have
6
- larger optional dependency families.
3
+ Use this React package for the shared Databricks AppKit UI foundation, branding,
4
+ passwordless authentication, email surfaces, and Databricks AI Search controls.
5
+ Import only the subpaths that your browser application uses.
7
6
 
8
7
  ## Foundation
9
8
 
@@ -12,9 +11,27 @@ import { Button, BrandPicker } from "@dbx-tools/ui/react";
12
11
  import "@dbx-tools/ui/styles.css";
13
12
  ```
14
13
 
15
- `./react` re-exports the tested AppKit UI primitives and adds `BrandPicker`.
14
+ `./react` re-exports Databricks AppKit UI primitives and adds `BrandPicker`.
16
15
  `./styles.css` provides Tailwind, Streamdown, code-block, and brand-token bridge
17
- styles for dbx-tools feature UI.
16
+ styles for dbx-tools UI packages.
17
+
18
+ ## Choose a UI package
19
+
20
+ - Use `@dbx-tools/ui` for common AppKit components, branding, authentication,
21
+ email, and search. Import its base stylesheet and any feature stylesheet.
22
+ Authentication components call [@dbx-tools/auth-gate](../../node/auth-gate)
23
+ routes. Search components pair with [@dbx-tools/search](../../node/search)
24
+ and use AppKit's published `aiSearch` client configuration.
25
+ - Use [@dbx-tools/ui-mastra](../mastra) with
26
+ [@dbx-tools/appkit-mastra](../../node/appkit-mastra). Import the AppKit UI
27
+ stylesheet before the Mastra stylesheet. Mount chat inside the application's
28
+ authentication boundary. The client reads the plugin's published
29
+ `clientConfig()` payload.
30
+ - Use [@dbx-tools/ui-teams](../teams) with
31
+ [@dbx-tools/teams](../../node/teams). Import the AppKit UI stylesheet before
32
+ the Teams stylesheet. The preview components use explicit HTTP endpoints and
33
+ don't consume published plugin client configuration. Microsoft Teams bot
34
+ authentication remains a server concern.
18
35
 
19
36
  ## Branding
20
37
 
@@ -34,7 +51,9 @@ import { AuthGate, PasskeyManager } from "@dbx-tools/ui/auth/react";
34
51
  ```
35
52
 
36
53
  These components consume the browser-safe `@dbx-tools/shared-auth` contracts and
37
- the routes provided by `@dbx-tools/auth-gate`.
54
+ the routes provided by `@dbx-tools/auth-gate`. Set `passkeyNamePrefix` on either
55
+ component to override the server-provided prefix used before the humanized tunnel
56
+ subdomain.
38
57
 
39
58
  ## Email
40
59
 
@@ -44,7 +63,7 @@ import "@dbx-tools/ui/email/styles.css";
44
63
  ```
45
64
 
46
65
  Email components consume `@dbx-tools/shared-email` and
47
- `@dbx-tools/shared-email-template`; transport and approval remain server concerns.
66
+ `@dbx-tools/shared-email-template`. Transport and approval remain server concerns.
48
67
 
49
68
  ## Search
50
69
 
@@ -53,13 +72,15 @@ import { SearchBox, SearchResults, useSearch } from "@dbx-tools/ui/search/react"
53
72
  import "@dbx-tools/ui/search/styles.css";
54
73
  ```
55
74
 
56
- Search components consume `@dbx-tools/shared-search` and AppKit's browser query
57
- hook. Backend selection remains in `@dbx-tools/search`.
75
+ Search components consume
76
+ [@dbx-tools/shared-search](../../shared/search) and AppKit's browser query
77
+ hook. Backend selection and workspace access remain in
78
+ [@dbx-tools/search](../../node/search).
58
79
 
59
- ## Export Map
80
+ ## Package exports
60
81
 
61
- - `./react`, `./styles.css` - common AppKit UI foundation.
62
- - `./branding/react`, `./branding/browser`, `./branding/assets` - brand runtime and assets.
63
- - `./auth/react` - passwordless sign-in and passkey management.
64
- - `./email/react`, `./email/styles.css` - approval, preview, and compose UI.
65
- - `./search/react`, `./search/styles.css` - AI Search controls and state.
82
+ - `./react`, `./styles.css`: common AppKit UI foundation.
83
+ - `./branding/react`, `./branding/browser`, `./branding/assets`: brand runtime and assets.
84
+ - `./auth/react`: passwordless sign-in and passkey management.
85
+ - `./email/react`, `./email/styles.css`: approval, preview, and compose UI.
86
+ - `./search/react`, `./search/styles.css`: Databricks AI Search controls and state.
package/index.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  // Hand edits are overwritten on the next watch; this file is read-only.
4
4
 
5
5
  export const PACKAGE_IDENTIFIER = "@dbx-tools/ui";
6
- export const PACKAGE_VERSION = "0.9.131";
6
+ export const PACKAGE_VERSION = "0.9.136";
7
7
  export * as authReactAuthClient from "./src/auth/react/auth-client.ts";
8
8
  export * as authReactAuthGate from "./src/auth/react/auth-gate.tsx";
9
9
  export * as authReactPasskeyManager from "./src/auth/react/passkey-manager.tsx";
package/package.json CHANGED
@@ -30,11 +30,11 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@databricks/appkit-ui": "0.81.0",
33
- "@dbx-tools/shared-auth": "^0.9.131",
34
- "@dbx-tools/shared-core": "^0.9.131",
35
- "@dbx-tools/shared-email": "^0.9.131",
36
- "@dbx-tools/shared-email-template": "^0.9.131",
37
- "@dbx-tools/shared-search": "^0.9.131",
33
+ "@dbx-tools/shared-auth": "^0.9.136",
34
+ "@dbx-tools/shared-core": "^0.9.136",
35
+ "@dbx-tools/shared-email": "^0.9.136",
36
+ "@dbx-tools/shared-email-template": "^0.9.136",
37
+ "@dbx-tools/shared-search": "^0.9.136",
38
38
  "lucide-react": "^0.554.0",
39
39
  "shiki": "^3.0.0",
40
40
  "streamdown": "^2.5.0",
@@ -44,7 +44,7 @@
44
44
  "publishConfig": {
45
45
  "access": "public"
46
46
  },
47
- "version": "0.9.131",
47
+ "version": "0.9.136",
48
48
  "dbxToolsConfig": {
49
49
  "tags": [
50
50
  "ui"
@@ -12,6 +12,7 @@ export {
12
12
  getAuthStatus,
13
13
  listPasskeys,
14
14
  logout,
15
+ passkeyDisplayName,
15
16
  removePasskey,
16
17
  renamePasskey,
17
18
  requestEmailOtp,
@@ -5,24 +5,32 @@ import {
5
5
  beginPasskeyEnrollment,
6
6
  beginPasskeySignIn,
7
7
  getAuthStatus,
8
+ passkeyDisplayName,
8
9
  requestEmailOtp,
9
10
  type PasskeyOperation,
10
11
  verifyEmailOtp,
11
12
  } from "./auth-client.ts";
12
13
  import { BrandIcon, useBrand } from "../../branding/react/index.ts";
13
- import { Button, Input } from "../../react/index.ts";
14
+ import { Button, Checkbox, Input, Label } from "../../react/index.ts";
14
15
 
15
- type Phase = "loading" | "email" | "code" | "enroll" | "authed" | "open";
16
+ type Phase = "loading" | "email" | "code" | "authed" | "open";
16
17
 
17
18
  /** Protected content and optional sign-in copy rendered by {@link AuthGate}. */
18
19
  export interface AuthGateProps {
19
20
  children: ReactNode;
20
21
  title?: string;
21
22
  description?: string;
23
+ /** Prefix added before the humanized tunnel subdomain in new passkey names. */
24
+ passkeyNamePrefix?: string;
22
25
  }
23
26
 
24
- /** Email OTP gate with conditional passkey sign-in and first-login enrollment. */
25
- export function AuthGate({ children, title, description }: AuthGateProps): ReactNode {
27
+ /** Email OTP gate with conditional passkey sign-in and optional inline enrollment. */
28
+ export function AuthGate({
29
+ children,
30
+ title,
31
+ description,
32
+ passkeyNamePrefix,
33
+ }: AuthGateProps): ReactNode {
26
34
  const { context: brand } = useBrand();
27
35
  const [phase, setPhase] = useState<Phase>("loading");
28
36
  const [email, setEmail] = useState("");
@@ -30,6 +38,10 @@ export function AuthGate({ children, title, description }: AuthGateProps): React
30
38
  const [busy, setBusy] = useState(false);
31
39
  const [notice, setNotice] = useState<string | null>(null);
32
40
  const [passkeysEnabled, setPasskeysEnabled] = useState(false);
41
+ const [configuredPasskeyNamePrefix, setConfiguredPasskeyNamePrefix] = useState<
42
+ string | undefined
43
+ >();
44
+ const [createPasskey, setCreatePasskey] = useState(true);
33
45
  const passkeyOperation = useRef<PasskeyOperation | undefined>(undefined);
34
46
 
35
47
  const cancelPasskey = useCallback(() => {
@@ -46,6 +58,7 @@ export function AuthGate({ children, title, description }: AuthGateProps): React
46
58
  .then((status) => {
47
59
  if (cancelled) return;
48
60
  setPasskeysEnabled(status.passkeysEnabled === true);
61
+ setConfiguredPasskeyNamePrefix(status.passkeyNamePrefix);
49
62
  setPhase(status.enabled ? (status.authenticated ? "authed" : "email") : "open");
50
63
  })
51
64
  .catch(() => {
@@ -128,17 +141,45 @@ export function AuthGate({ children, title, description }: AuthGateProps): React
128
141
  setBusy(true);
129
142
  setNotice(null);
130
143
  try {
131
- if (!(await verifyEmailOtp(email, code.trim(), email.split("@")[0] || "User"))) {
132
- throw new Error("OTP verification failed");
144
+ const verified = await verifyEmailOtp(
145
+ email,
146
+ code.trim(),
147
+ email.split("@")[0] || "User",
148
+ ).catch(() => false);
149
+ if (!verified) {
150
+ setNotice("That verification code is incorrect or has expired.");
151
+ return;
133
152
  }
134
- setPhase(passkeysEnabled ? "enroll" : "authed");
135
- } catch {
136
- setNotice("That verification code is incorrect or has expired.");
153
+ if (passkeysEnabled && createPasskey) {
154
+ let operation: PasskeyOperation | undefined;
155
+ try {
156
+ operation = beginPasskeyEnrollment(
157
+ passkeyDisplayName(passkeyNamePrefix ?? configuredPasskeyNamePrefix),
158
+ );
159
+ passkeyOperation.current = operation;
160
+ await operation.result;
161
+ } catch {
162
+ // The verified OTP session remains valid when enrollment is unavailable or cancelled.
163
+ } finally {
164
+ if (operation && passkeyOperation.current === operation) {
165
+ passkeyOperation.current = undefined;
166
+ }
167
+ }
168
+ }
169
+ setPhase("authed");
137
170
  } finally {
138
171
  setBusy(false);
139
172
  }
140
173
  },
141
- [busy, code, email, passkeysEnabled],
174
+ [
175
+ busy,
176
+ code,
177
+ configuredPasskeyNamePrefix,
178
+ createPasskey,
179
+ email,
180
+ passkeyNamePrefix,
181
+ passkeysEnabled,
182
+ ],
142
183
  );
143
184
 
144
185
  const usePasskey = useCallback(async () => {
@@ -164,29 +205,6 @@ export function AuthGate({ children, title, description }: AuthGateProps): React
164
205
  }
165
206
  }, [cancelPasskey]);
166
207
 
167
- const enroll = useCallback(async () => {
168
- cancelPasskey();
169
- const operation = beginPasskeyEnrollment("Primary passkey");
170
- passkeyOperation.current = operation;
171
- setBusy(true);
172
- setNotice(null);
173
- try {
174
- if (!(await operation.result)) throw new Error("Passkey enrollment failed");
175
- if (passkeyOperation.current !== operation) return;
176
- passkeyOperation.current = undefined;
177
- setPhase("authed");
178
- } catch {
179
- if (passkeyOperation.current === operation) {
180
- setNotice("Unable to create a passkey. You can continue with email recovery.");
181
- }
182
- } finally {
183
- if (passkeyOperation.current === operation) {
184
- passkeyOperation.current = undefined;
185
- setBusy(false);
186
- }
187
- }
188
- }, [cancelPasskey]);
189
-
190
208
  if (phase === "authed" || phase === "open") return <>{children}</>;
191
209
  if (phase === "loading") return null;
192
210
 
@@ -201,9 +219,7 @@ export function AuthGate({ children, title, description }: AuthGateProps): React
201
219
  {description ??
202
220
  (phase === "code"
203
221
  ? "Enter the 6-digit verification code sent to your email address."
204
- : phase === "enroll"
205
- ? "Create a passkey for faster, phishing-resistant sign-in next time."
206
- : "Enter your email for a one-time code, or use a passkey.")}
222
+ : "Enter your email for a one-time code, or use a passkey.")}
207
223
  </p>
208
224
 
209
225
  {phase === "email" ? (
@@ -246,29 +262,24 @@ export function AuthGate({ children, title, description }: AuthGateProps): React
246
262
  onChange={(event) => setCode(event.target.value)}
247
263
  required
248
264
  />
265
+ {passkeysEnabled ? (
266
+ <div className="flex items-center gap-2">
267
+ <Checkbox
268
+ id="create-passkey"
269
+ checked={createPasskey}
270
+ disabled={busy}
271
+ onCheckedChange={(checked) => setCreatePasskey(checked === true)}
272
+ />
273
+ <Label htmlFor="create-passkey" className="text-sm font-normal">
274
+ Create a passkey for this tunnel host
275
+ </Label>
276
+ </div>
277
+ ) : null}
249
278
  <Button type="submit" disabled={busy} className="w-full">
250
279
  Continue
251
280
  </Button>
252
281
  </form>
253
- ) : (
254
- <div className="space-y-3">
255
- <Button type="button" disabled={busy} className="w-full" onClick={enroll}>
256
- Create a passkey
257
- </Button>
258
- <Button
259
- type="button"
260
- variant="ghost"
261
- className="w-full"
262
- onClick={() => {
263
- cancelPasskey();
264
- setBusy(false);
265
- setPhase("authed");
266
- }}
267
- >
268
- Not now
269
- </Button>
270
- </div>
271
- )}
282
+ ) : null}
272
283
 
273
284
  {notice ? (
274
285
  <p role="status" aria-live="polite" className="mt-3 text-xs text-muted-foreground">
@@ -2,7 +2,9 @@ import { type ReactNode, useCallback, useEffect, useRef, useState } from "react"
2
2
 
3
3
  import {
4
4
  beginPasskeyEnrollment,
5
+ getAuthStatus,
5
6
  listPasskeys,
7
+ passkeyDisplayName,
6
8
  type PasskeyOperation,
7
9
  type Passkey,
8
10
  removePasskey,
@@ -13,15 +15,20 @@ import { Button, Input } from "../../react/index.ts";
13
15
  /** Styling options for the authenticated passkey management surface. */
14
16
  export interface PasskeyManagerProps {
15
17
  className?: string;
18
+ /** Prefix added before the humanized tunnel subdomain in new passkey names. */
19
+ passkeyNamePrefix?: string;
16
20
  }
17
21
 
18
22
  /** Authenticated management surface for a user's Better Auth passkeys. */
19
- export function PasskeyManager({ className }: PasskeyManagerProps): ReactNode {
23
+ export function PasskeyManager({ className, passkeyNamePrefix }: PasskeyManagerProps): ReactNode {
20
24
  const [passkeys, setPasskeys] = useState<Passkey[]>([]);
21
25
  const [names, setNames] = useState<Record<string, string>>({});
22
26
  const [busy, setBusy] = useState(false);
23
27
  const [loaded, setLoaded] = useState(false);
24
28
  const [notice, setNotice] = useState<string | null>(null);
29
+ const [configuredPasskeyNamePrefix, setConfiguredPasskeyNamePrefix] = useState<
30
+ string | undefined
31
+ >();
25
32
  const enrollment = useRef<PasskeyOperation | undefined>(undefined);
26
33
 
27
34
  const cancelEnrollment = useCallback(() => {
@@ -33,9 +40,10 @@ export function PasskeyManager({ className }: PasskeyManagerProps): ReactNode {
33
40
  useEffect(() => cancelEnrollment, [cancelEnrollment]);
34
41
 
35
42
  const refresh = useCallback(async () => {
36
- const values = await listPasskeys();
43
+ const [values, status] = await Promise.all([listPasskeys(), getAuthStatus()]);
37
44
  setPasskeys(values);
38
45
  setNames(Object.fromEntries(values.map((passkey) => [passkey.id, passkey.name ?? "Passkey"])));
46
+ setConfiguredPasskeyNamePrefix(status.passkeyNamePrefix);
39
47
  setLoaded(true);
40
48
  setNotice(null);
41
49
  }, []);
@@ -46,7 +54,9 @@ export function PasskeyManager({ className }: PasskeyManagerProps): ReactNode {
46
54
 
47
55
  const add = useCallback(async () => {
48
56
  cancelEnrollment();
49
- const operation = beginPasskeyEnrollment();
57
+ const operation = beginPasskeyEnrollment(
58
+ passkeyDisplayName(passkeyNamePrefix ?? configuredPasskeyNamePrefix),
59
+ );
50
60
  enrollment.current = operation;
51
61
  setBusy(true);
52
62
  setNotice(null);
@@ -62,7 +72,7 @@ export function PasskeyManager({ className }: PasskeyManagerProps): ReactNode {
62
72
  setBusy(false);
63
73
  }
64
74
  }
65
- }, [cancelEnrollment, refresh]);
75
+ }, [cancelEnrollment, configuredPasskeyNamePrefix, passkeyNamePrefix, refresh]);
66
76
 
67
77
  const rename = useCallback(
68
78
  async (id: string) => {
@@ -27,7 +27,7 @@ export interface EmailPreviewProps {
27
27
  brand?: EmailBrand;
28
28
  }
29
29
 
30
- /** Initials for the sender avatar when no logo is available. */
30
+ /** Initials for the sender avatar when no icon or logo is available. */
31
31
  function senderInitials(name: string): string {
32
32
  const parts = name.trim().split(/\s+/).filter(Boolean);
33
33
  if (parts.length === 0) return "?";
@@ -63,11 +63,18 @@ export const EmailPreview = ({ email, brand }: EmailPreviewProps) => {
63
63
  <div className="space-y-3 border-b border-border bg-background px-4 py-3">
64
64
  <div className="flex items-start gap-3">
65
65
  <div
66
- className="flex size-10 shrink-0 items-center justify-center rounded-full text-xs font-semibold"
66
+ className="flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-xl border border-border/70 text-xs font-semibold"
67
67
  style={{ backgroundColor: theme.accent, color: theme.onAccent }}
68
- aria-hidden
69
68
  >
70
- {senderInitials(theme.name)}
69
+ {theme.logoUrl ? (
70
+ <img
71
+ src={theme.logoUrl}
72
+ alt={`${theme.name} icon`}
73
+ className="size-8 object-contain"
74
+ />
75
+ ) : (
76
+ <span aria-hidden>{senderInitials(theme.name)}</span>
77
+ )}
71
78
  </div>
72
79
  <div className="min-w-0 flex-1 space-y-1">
73
80
  <div className="flex items-baseline justify-between gap-3">
@@ -99,8 +106,13 @@ export const EmailPreview = ({ email, brand }: EmailPreviewProps) => {
99
106
  </ul>
100
107
  ) : null}
101
108
  </div>
102
- <div style={{ backgroundColor: theme.surface }}>
103
- <EmailCard subject={subject} body={email.body || ""} brand={theme} framed={false} />
109
+ <div className="p-3 sm:p-4" style={{ backgroundColor: theme.background }}>
110
+ <div
111
+ className="overflow-hidden rounded-xl border"
112
+ style={{ borderColor: theme.border, backgroundColor: theme.surface }}
113
+ >
114
+ <EmailCard subject={subject} body={email.body || ""} brand={theme} framed={false} />
115
+ </div>
104
116
  </div>
105
117
  </div>
106
118
  );
@@ -55,6 +55,14 @@ export function parseUniversalSearchResult(value: unknown): SearchResult {
55
55
  return searchSchemas.searchResultSchema.parse(value);
56
56
  }
57
57
 
58
+ /** A single configured index is already the complete universal-search set. */
59
+ export function usesUniversalSearchRoute(
60
+ universal: boolean | undefined,
61
+ indexCount: number,
62
+ ): boolean {
63
+ return universal === true && indexCount !== 1;
64
+ }
65
+
58
66
  function toHits(
59
67
  results: Array<{ score: number; data: Record<string, unknown> }>,
60
68
  index: string | null,
@@ -76,6 +84,7 @@ export function useSearch(options: UseSearchOptions = {}): UseSearchState {
76
84
  const native = useAiSearchQuery({ ...(options.index ? { alias: options.index } : {}) });
77
85
  const debounceMs = options.debounceMs ?? 200;
78
86
  const minLength = options.minLength ?? 1;
87
+ const useUniversalRoute = usesUniversalSearchRoute(options.universal, native.indexes.length);
79
88
 
80
89
  const [query, setQueryState] = useState("");
81
90
  const [hits, setHits] = useState<SearchHit[]>([]);
@@ -93,7 +102,7 @@ export function useSearch(options: UseSearchOptions = {}): UseSearchState {
93
102
  setUniversalLoading(false);
94
103
  return;
95
104
  }
96
- if (!options.universal) {
105
+ if (!useUniversalRoute) {
97
106
  const resolvedQueryType = searchSchemas.toAiSearchQueryType(options.mode);
98
107
  const request: AiSearchRequest = {
99
108
  queryText: text,
@@ -132,7 +141,7 @@ export function useSearch(options: UseSearchOptions = {}): UseSearchState {
132
141
  if (abortRef.current === controller) setUniversalLoading(false);
133
142
  }
134
143
  },
135
- [minLength, native.alias, native.search, options.limit, options.mode, options.universal],
144
+ [minLength, native.alias, native.search, options.limit, options.mode, useUniversalRoute],
136
145
  );
137
146
 
138
147
  const setQuery = useCallback(
@@ -179,8 +188,8 @@ export function useSearch(options: UseSearchOptions = {}): UseSearchState {
179
188
  }),
180
189
  [native.alias, native.indexes, options.limit],
181
190
  );
182
- const loading = options.universal ? universalLoading : native.loading;
183
- const error = options.universal ? universalError : native.error;
191
+ const loading = useUniversalRoute ? universalLoading : native.loading;
192
+ const error = useUniversalRoute ? universalError : native.error;
184
193
  return useMemo(
185
194
  () => ({ query, setQuery, hits, loading, error, config, submit, clear }),
186
195
  [query, setQuery, hits, loading, error, config, submit, clear],