@ciridae/ui 1.1.1 → 1.2.1

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.
Files changed (40) hide show
  1. package/dist/app/auth.js +7 -0
  2. package/dist/app/frame.d.ts +8 -0
  3. package/dist/app/frame.js +15 -0
  4. package/dist/app/index.d.ts +1 -0
  5. package/dist/app/index.js +1 -0
  6. package/dist/components/button.js +3 -1
  7. package/dist/components/chat.js +2 -11
  8. package/dist/components/color-theme.js +16 -1
  9. package/dist/components/data-grid.d.ts +5 -1
  10. package/dist/components/data-grid.js +4 -3
  11. package/dist/components/environment-frame.d.ts +1 -1
  12. package/dist/components/environment-frame.js +4 -8
  13. package/dist/components/feedback-screenshot.d.ts +7 -0
  14. package/dist/components/feedback-screenshot.js +57 -9
  15. package/dist/components/feedback-sheet.d.ts +5 -2
  16. package/dist/components/feedback-sheet.js +27 -8
  17. package/dist/components/form-controls.js +2 -1
  18. package/dist/components/locale.d.ts +27 -1
  19. package/dist/components/locale.js +19 -1
  20. package/dist/components/member-directory.d.ts +35 -0
  21. package/dist/components/member-directory.js +125 -0
  22. package/dist/components/overlays.js +11 -0
  23. package/dist/components/select.js +4 -1
  24. package/dist/components/shell.js +4 -2
  25. package/dist/components/sidebar.js +1 -1
  26. package/dist/components/skeleton.d.ts +5 -0
  27. package/dist/components/skeleton.js +18 -5
  28. package/dist/feedback/client.js +11 -2
  29. package/dist/feedback/contract.d.ts +1 -0
  30. package/dist/feedback/generated/index.d.ts +1 -1
  31. package/dist/feedback/generated/types.gen.d.ts +379 -5
  32. package/dist/feedback/generated/zod.gen.d.ts +329 -6
  33. package/dist/feedback/generated/zod.gen.js +130 -7
  34. package/dist/preset.js +0 -2
  35. package/dist/styled-system/styles.css +68 -59
  36. package/dist/styled-system/tokens/index.mjs +0 -8
  37. package/dist/styled-system/tokens/tokens.d.ts +2 -2
  38. package/dist/theme/tokens.d.ts +1 -1
  39. package/dist/theme/tokens.js +0 -6
  40. package/package.json +7 -1
package/dist/app/auth.js CHANGED
@@ -3,6 +3,7 @@ import { parseSameOriginPath } from "@ciridae/auth/client";
3
3
  import { useCiridaeAuth, useCompleteCiridaeSignIn } from "@ciridae/auth/react";
4
4
  import { useCallback, useEffect, useState } from "react";
5
5
  import { useLocation, useNavigate } from "react-router-dom";
6
+ import { forgetShapes } from "skullet";
6
7
  import { CiridaeMark } from "../components/brand-icons.js";
7
8
  import { icon, Spinner } from "../components/icon.js";
8
9
  import { Stack } from "../components/layout.js";
@@ -20,6 +21,12 @@ function SignInLoading() {
20
21
  /** Renders children for a signed-in session and sends everyone else to the auth service. */
21
22
  export function RequireSignIn({ children, loading = _jsx(SignInLoading, {}), }) {
22
23
  const { auth, session } = useCiridaeAuth();
24
+ const signedInUserId = session.status === "signedIn" ? session.user.uid : null;
25
+ // Skullet remembers layout outlines across visits. Never carry them across accounts.
26
+ useEffect(() => {
27
+ forgetShapes();
28
+ return () => forgetShapes();
29
+ }, [signedInUserId]);
23
30
  const signInUrl = session.status === "signedOut"
24
31
  ? auth.getSignInUrl(window.location.pathname + window.location.search)
25
32
  : null;
@@ -0,0 +1,8 @@
1
+ import { type AppFrameProps } from "../components/app-frame.js";
2
+ import { type FeedbackScope } from "./feedback.js";
3
+ export type CiridaeAppFrameProps = AppFrameProps & {
4
+ /** Enables the shared feedback controls and sheet for this app's inbox. */
5
+ feedbackScope?: FeedbackScope | null;
6
+ };
7
+ /** AppFrame with opt-in Ciridae feedback: one footer row, rail and phone controls, and the sheet. */
8
+ export declare function CiridaeAppFrame({ feedbackScope, footnote, railActions, compactActions, overlays, ...props }: CiridaeAppFrameProps): import("react").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ChatCircleTextIcon } from "@phosphor-icons/react";
3
+ import { useState } from "react";
4
+ import { AppFrame } from "../components/app-frame.js";
5
+ import { Button, IconButton } from "../components/button.js";
6
+ import { icon } from "../components/icon.js";
7
+ import { Tooltip } from "../components/overlays.js";
8
+ import { SidebarItem } from "../components/sidebar.js";
9
+ import { FeedbackDialog } from "./feedback.js";
10
+ /** AppFrame with opt-in Ciridae feedback: one footer row, rail and phone controls, and the sheet. */
11
+ export function CiridaeAppFrame({ feedbackScope, footnote, railActions, compactActions, overlays, ...props }) {
12
+ const [feedbackOpen, setFeedbackOpen] = useState(false);
13
+ const openFeedback = () => setFeedbackOpen(true);
14
+ return (_jsx(AppFrame, { ...props, footnote: feedbackScope ? (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "link", icon: _jsx(ChatCircleTextIcon, { className: icon({ size: "small" }) }), onClick: openFeedback, children: "Feedback" }), footnote] })) : (footnote), railActions: feedbackScope ? (_jsxs(_Fragment, { children: [_jsx(Tooltip, { content: "Feedback", side: "inline-end", children: _jsx(SidebarItem, { "aria-label": "Feedback", icon: _jsx(ChatCircleTextIcon, { className: icon() }), onClick: openFeedback }) }), railActions] })) : (railActions), compactActions: feedbackScope ? (_jsxs(_Fragment, { children: [_jsx(IconButton, { variant: "ghost", "aria-label": "Feedback", onClick: openFeedback, children: _jsx(ChatCircleTextIcon, { className: icon() }) }), compactActions] })) : (compactActions), overlays: _jsxs(_Fragment, { children: [overlays, feedbackScope && (_jsx(FeedbackDialog, { scope: feedbackScope, open: feedbackOpen, onOpenChange: setFeedbackOpen }))] }) }));
15
+ }
@@ -2,6 +2,7 @@
2
2
  export { RequireSignIn, SignInCallbackPage } from "./auth.js";
3
3
  export { AppErrorBoundary } from "./error-boundary.js";
4
4
  export { FeedbackDialog, type FeedbackScope } from "./feedback.js";
5
+ export { CiridaeAppFrame, type CiridaeAppFrameProps } from "./frame.js";
5
6
  export { errorMessage, errorStatus, errorTraceId, QueryContent, reportedInline, reportedInlineMeta, requestErrorDescription, RequestErrorToasts, RequestFieldError, requestErrorToast, withResponseDetails, } from "./request-errors.js";
6
7
  export { initializeSentry, setSentryOrganization } from "./sentry.js";
7
8
  export { AppTelemetryProvider } from "./telemetry.js";
package/dist/app/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  export { RequireSignIn, SignInCallbackPage } from "./auth.js";
3
3
  export { AppErrorBoundary } from "./error-boundary.js";
4
4
  export { FeedbackDialog } from "./feedback.js";
5
+ export { CiridaeAppFrame } from "./frame.js";
5
6
  export { errorMessage, errorStatus, errorTraceId, QueryContent, reportedInline, reportedInlineMeta, requestErrorDescription, RequestErrorToasts, RequestFieldError, requestErrorToast, withResponseDetails, } from "./request-errors.js";
6
7
  export { initializeSentry, setSentryOrganization } from "./sentry.js";
7
8
  export { AppTelemetryProvider } from "./telemetry.js";
@@ -104,7 +104,9 @@ const action = cva({
104
104
  // Words only, in the text around it: no face, no height, underlined on hover.
105
105
  link: {
106
106
  background: "transparent",
107
- color: "fg.primary",
107
+ color: "[inherit]",
108
+ alignItems: "baseline",
109
+ "& > svg": { alignSelf: "center" },
108
110
  fontFamily: "[inherit]",
109
111
  fontWeight: "[inherit]",
110
112
  letterSpacing: "[inherit]",
@@ -13,6 +13,7 @@ import { useCiridaeLocale } from "./locale.js";
13
13
  import { LogGroupHeader } from "./log-entry.js";
14
14
  import { MentionInput } from "./mention-input.js";
15
15
  import { useResolvedFileUrl } from "./resolved-file-url.js";
16
+ import { Skeleton } from "./skeleton.js";
16
17
  export { MessageText, splitSources, } from "../chat/message-text.js";
17
18
  const pageComposer = css({
18
19
  display: "flex",
@@ -490,7 +491,6 @@ const attachmentList = css({
490
491
  fontSize: "code",
491
492
  "& a": { color: "[inherit]" },
492
493
  });
493
- /* The lines stand in for the reply's text, so each is that text's bar height. */
494
494
  const thinking = css({
495
495
  display: "grid",
496
496
  gap: "layout.contentGap",
@@ -506,15 +506,6 @@ const thinking = css({
506
506
  lineHeight: "tight",
507
507
  "& > span": { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
508
508
  },
509
- "& > [data-line]": {
510
- display: "block",
511
- height: "[calc(token(fontSizes.body) * 0.75)]",
512
- borderRadius: "round",
513
- background: "[token(gradients.skeletonFill)]",
514
- },
515
- "& > [data-line]:nth-of-type(1)": { width: "[98%]" },
516
- "& > [data-line]:nth-of-type(2)": { width: "[87%]" },
517
- "& > [data-line]:nth-of-type(3)": { width: "[66%]" },
518
509
  });
519
510
  const failure = css({
520
511
  display: "grid",
@@ -757,7 +748,7 @@ function ThreadEntryContent({ entry, side, groupPosition, renderCustom, attachme
757
748
  }
758
749
  function AgentThinking({ label }) {
759
750
  const { labels } = useCiridaeLocale();
760
- return (_jsxs("div", { className: thinking, children: [_jsxs("div", { "data-status": "", children: [_jsx(Spinner, { "aria-hidden": "true" }), _jsx("span", { children: label ?? labels.common.working })] }), _jsx("span", { "data-line": "" }), _jsx("span", { "data-line": "" }), _jsx("span", { "data-line": "" })] }));
751
+ return (_jsxs("div", { className: thinking, children: [_jsxs("div", { "data-status": "", children: [_jsx(Spinner, { "aria-hidden": "true" }), _jsx("span", { children: label ?? labels.common.working })] }), _jsx(Skeleton, { shape: "text", height: "line", width: "98%" }), _jsx(Skeleton, { shape: "text", height: "line", width: "87%" }), _jsx(Skeleton, { shape: "text", height: "line", width: "66%" })] }));
761
752
  }
762
753
  function AgentSteps({ steps }) {
763
754
  const { labels } = useCiridaeLocale();
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { createContext, useCallback, useContext, useEffect, useMemo, useState, } from "react";
3
+ import { SkulletProvider } from "skullet/react";
3
4
  import { fontStylesheet } from "../theme/tokens.js";
4
5
  /** The attribute the `light` Panda condition and `ciridae.css` both select on. */
5
6
  const THEME_ATTRIBUTE = "data-ciridae-theme";
@@ -33,6 +34,20 @@ function readSystemTheme() {
33
34
  }
34
35
  const ColorThemeContext = createContext(null);
35
36
  const BrandContext = createContext(null);
37
+ // Both modes use the product's resolved ink, so custom palettes follow the same theme. The
38
+ // highlight paints over the bar: dark ink would smear it, so light has none and holds still.
39
+ const loadingTheme = {
40
+ light: {
41
+ base: "color-mix(in srgb, var(--colors-fg\\.primary) 8%, transparent)",
42
+ highlight: "transparent",
43
+ },
44
+ dark: {
45
+ base: "color-mix(in srgb, var(--colors-fg\\.primary) 8%, transparent)",
46
+ highlight: "color-mix(in srgb, var(--colors-fg\\.primary) 5%, transparent)",
47
+ },
48
+ animation: "shimmer",
49
+ speed: "slow",
50
+ };
36
51
  const RUNTIME_FONTS_ELEMENT_ID = "ciridae-runtime-fonts";
37
52
  function useRuntimeFonts(fonts) {
38
53
  const display = fonts?.display;
@@ -90,7 +105,7 @@ export function ThemeProvider({ children, defaultColorTheme = "dark", storageKey
90
105
  const setTheme = setPreference;
91
106
  const toggleTheme = useCallback(() => setTheme(theme === "dark" ? "light" : "dark"), [setTheme, theme]);
92
107
  const value = useMemo(() => ({ theme, preference, setPreference, setTheme, toggleTheme }), [theme, preference, setPreference, setTheme, toggleTheme]);
93
- return (_jsx(ColorThemeContext.Provider, { value: value, children: _jsx(BrandContext.Provider, { value: brand ?? null, children: children }) }));
108
+ return (_jsx(ColorThemeContext.Provider, { value: value, children: _jsx(BrandContext.Provider, { value: brand ?? null, children: _jsx(SkulletProvider, { mode: theme, theme: loadingTheme, reveal: "smart", children: children }) }) }));
94
109
  }
95
110
  /** Throws outside a `ThemeProvider`, where there is no theme to report or change. */
96
111
  export function useColorTheme() {
@@ -167,6 +167,10 @@ export type DataGridProps<Row extends RowData> = Omit<ComponentProps<"div">, "ch
167
167
  */
168
168
  export declare function DataGrid<Row extends RowData>({ data, columns, getRowId, variant, density, sorting: sortingProp, defaultSorting, onSortingChange, manualSorting, page, enableRowSelection, rowSelection: rowSelectionProp, defaultRowSelection, onRowSelectionChange, stickySelectColumn, columnVisibility: columnVisibilityProp, defaultColumnVisibility, onColumnVisibilityChange, columnOrder: columnOrderProp, defaultColumnOrder, onColumnOrderChange, headerMenu, filters, onFiltersChange, getRowHref, renderRowLink, onRowClick, activeRowId, keyboardNavigation, virtualize, rowActions, renderRowDetail, groupBy, renderGroupRow, loading, empty, noResults, filtered, hideHeader, fill, narrowScreenLayout, footer, labels: ownLabels, className, frameClassName, style, ...props }: DataGridProps<Row>): import("react").JSX.Element;
169
169
  export type TableProps<Row extends RowData> = Omit<DataGridProps<Row>, "defaultSorting" | "empty"> & {
170
+ /** Representative rows measured with the real columns instead of authored placeholder cells. */
171
+ loadingSample?: readonly Row[];
172
+ /** Accessible announcement for measured loading. */
173
+ loadingLabel?: string;
170
174
  /** The sort the table starts with; `defaultSorting` on `DataGrid`. */
171
175
  initialSorting?: SortingState;
172
176
  /** Shown when there are no rows; `empty` on `DataGrid`. */
@@ -176,4 +180,4 @@ export type TableProps<Row extends RowData> = Omit<DataGridProps<Row>, "defaultS
176
180
  * `DataGrid` with the plain look: flush with its section, rows that light on hover when they lead
177
181
  * somewhere.
178
182
  */
179
- export declare function Table<Row extends RowData>({ variant, initialSorting, emptyMessage, ...props }: TableProps<Row>): import("react").JSX.Element;
183
+ export declare function Table<Row extends RowData>({ variant, initialSorting, emptyMessage, loadingSample, loadingLabel, ...props }: TableProps<Row>): import("react").JSX.Element;
@@ -20,7 +20,7 @@ import { icon } from "./icon.js";
20
20
  import { useCiridaeLocale } from "./locale.js";
21
21
  import { Menu } from "./menu.js";
22
22
  import { Popover } from "./overlays.js";
23
- import { Skeleton } from "./skeleton.js";
23
+ import { ContentSkeleton, Skeleton } from "./skeleton.js";
24
24
  /** TanStack uses this type-only slot to type `meta`. */
25
25
  const columnMeta = {};
26
26
  const tableFeatureSet = tableFeatures({
@@ -511,8 +511,9 @@ export function DataGrid({ data, columns, getRowId, variant = "framed", density
511
511
  * `DataGrid` with the plain look: flush with its section, rows that light on hover when they lead
512
512
  * somewhere.
513
513
  */
514
- export function Table({ variant = "plain", initialSorting, emptyMessage, ...props }) {
515
- return (_jsx(DataGrid, { variant: variant, defaultSorting: initialSorting, empty: emptyMessage, ...props }));
514
+ export function Table({ variant = "plain", initialSorting, emptyMessage, loadingSample, loadingLabel = "Loading rows", ...props }) {
515
+ const render = (data, loading = props.loading) => (_jsx(DataGrid, { variant: variant, defaultSorting: initialSorting, empty: emptyMessage, ...props, data: data, loading: loading }));
516
+ return loadingSample ? (_jsx(ContentSkeleton, { data: props.loading ? undefined : props.data, sample: loadingSample, label: loadingLabel, fill: props.fill, children: (data) => render(data, false) })) : (render(props.data));
516
517
  }
517
518
  const emptySorting = [];
518
519
  const emptySelection = {};
@@ -9,5 +9,5 @@ export type EnvironmentFrameProps = ComponentProps<"div"> & {
9
9
  /** The strip's tint: `warning` for a staging build, `info` for dev. */
10
10
  tone?: SiteBannerProps["tone"];
11
11
  };
12
- /** An environment strip, which the reader can dismiss for the session, and an inset AppShell viewport. */
12
+ /** An environment strip, which the reader can dismiss for the session, and the AppShell viewport below it. */
13
13
  export declare function EnvironmentFrame({ label, tone, children, className, ...props }: EnvironmentFrameProps): import("react").JSX.Element;
@@ -15,19 +15,15 @@ const environmentBanner = css({
15
15
  _phone: { paddingInlineStart: "panel.default" },
16
16
  });
17
17
  const viewport = css({
18
+ position: "relative",
18
19
  flex: "1",
19
20
  minHeight: "0",
20
21
  overflow: "hidden",
21
22
  background: "[token(gradients.canvas)]",
22
- // Only under the environment strip does the app read as inset below it.
23
- "&[data-under-banner]": {
24
- borderTopRadius: "field",
25
- boxShadow: "[inset 0 2px 4px rgba(0, 0, 0, 0.18)]",
26
- },
27
23
  // Keep the shell and its phone layout within the space below the site banner. On a desktop the
28
24
  // shell's row sizes the main panel inside its block margins, so a full height would push it past
29
25
  // them; a phone's main panel is a full window tall, so there it takes the space under the strip.
30
- "& > [data-ciridae-ui]": { height: "full", background: "transparent" },
26
+ "& > [data-ciridae-ui]": { position: "absolute", height: "full", background: "transparent" },
31
27
  // The main panel keeps its own 8 corners, as the Figma's page card has them everywhere.
32
28
  "& > [data-ciridae-ui] > main": { _phone: { height: "full" } },
33
29
  "& > [data-ciridae-ui] > main > header": {
@@ -58,7 +54,7 @@ function rememberDismissedForSession() {
58
54
  console.warn(`Could not save ${dismissedStorageKey}; the strip stays hidden until the page reloads`, error);
59
55
  }
60
56
  }
61
- /** An environment strip, which the reader can dismiss for the session, and an inset AppShell viewport. */
57
+ /** An environment strip, which the reader can dismiss for the session, and the AppShell viewport below it. */
62
58
  export function EnvironmentFrame({ label, tone = "info", children, className, ...props }) {
63
59
  const { labels } = useCiridaeLocale();
64
60
  const [dismissed, setDismissed] = useState(readDismissedForSession);
@@ -67,5 +63,5 @@ export function EnvironmentFrame({ label, tone = "info", children, className, ..
67
63
  rememberDismissedForSession();
68
64
  setDismissed(true);
69
65
  };
70
- return (_jsxs("div", { ...props, className: cx(frame, className), children: [shown && (_jsx(SiteBanner, { className: environmentBanner, tone: tone, onDismiss: dismiss, children: typeof label === "string" ? labels.shell.environment(label) : label })), _jsx("div", { className: viewport, "data-under-banner": shown || undefined, children: children })] }));
66
+ return (_jsxs("div", { ...props, className: cx(frame, className), children: [shown && (_jsx(SiteBanner, { className: environmentBanner, tone: tone, onDismiss: dismiss, children: typeof label === "string" ? labels.shell.environment(label) : label })), _jsx("div", { className: viewport, children: children })] }));
71
67
  }
@@ -10,6 +10,13 @@ export type PlacedScreenshotPointer = FeedbackScreenshotPointer & {
10
10
  };
11
11
  /** The most pointers one screenshot takes. */
12
12
  export declare const MAX_SCREENSHOT_POINTERS = 7;
13
+ /**
14
+ * The page as a PNG object URL, captured once `enabled` turns on: undefined while it renders, null
15
+ * when it could not be. Portaled layers, such as the feedback sheet itself, are left out.
16
+ */
17
+ export declare function usePageScreenshot(enabled: boolean): string | null | undefined;
18
+ /** The screenshot as a file to upload with the feedback. */
19
+ export declare function screenshotFile(src: string): Promise<File>;
13
20
  /** The thumbnail beside "Include a screenshot", and the dialog it opens to annotate it. */
14
21
  export declare function FeedbackScreenshot({ src, pointers, onPointersChange, disabled, }: {
15
22
  src: string;
@@ -1,29 +1,33 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  /*
3
- * The feedback form's screenshot: a thumbnail that opens a dialog where clicking the image drops a
3
+ * The feedback form's screenshot: the page captured under the sheet, and a thumbnail that opens a dialog where clicking the image drops a
4
4
  * numbered pointer, each with a note. Pointers sit at fractions of the image's width and height,
5
5
  * so they land on the same spot at any size.
6
6
  */
7
7
  import { XIcon } from "@phosphor-icons/react";
8
- import { useRef, useState } from "react";
8
+ import { snapdom } from "@zumer/snapdom";
9
+ import { useEffect, useRef, useState } from "react";
9
10
  import { css } from "#primitives/css";
10
- import { Button, IconButton } from "./button.js";
11
+ import { IconButton } from "./button.js";
12
+ import { Textarea } from "./form-controls.js";
11
13
  import { icon } from "./icon.js";
12
- import { Input } from "./input.js";
13
14
  import { useCiridaeLocale } from "./locale.js";
14
15
  import { Dialog } from "./overlays.js";
15
16
  /** The most pointers one screenshot takes. */
16
17
  export const MAX_SCREENSHOT_POINTERS = 7;
18
+ /* Runs the dialog's width behind an image its height limit keeps narrower. */
19
+ const stageFrame = css({
20
+ display: "grid",
21
+ justifyItems: "center",
22
+ borderBlockEnd: "1px solid token(colors.border.control)",
23
+ background: "bg.field",
24
+ });
17
25
  /* The image and its pointers share one box, so a pointer's percentages are the image's. */
18
26
  const stage = css({
19
27
  position: "relative",
20
- justifySelf: "center",
21
28
  width: "[fit-content]",
22
29
  maxWidth: "full",
23
30
  overflow: "hidden",
24
- border: "1px solid token(colors.border.control)",
25
- borderRadius: "control",
26
- background: "bg.field",
27
31
  });
28
32
  const stageButton = css({
29
33
  display: "block",
@@ -65,6 +69,12 @@ const pointerList = css({
65
69
  padding: "none",
66
70
  listStyle: "none",
67
71
  });
72
+ /* One line until the note needs more. */
73
+ const pointerNote = css({
74
+ /* Doubled, to outrank the Textarea's own taller minimum and resize handle. */
75
+ "&&": { minHeight: "control.default", resize: "none" },
76
+ fieldSizing: "content",
77
+ });
68
78
  const pointerRow = css({
69
79
  display: "grid",
70
80
  gridTemplateColumns: "auto minmax(0, 1fr) auto",
@@ -109,6 +119,44 @@ const thumbnailCount = css({
109
119
  lineHeight: "tight",
110
120
  fontVariantNumeric: "tabular-nums",
111
121
  });
122
+ /**
123
+ * The page as a PNG object URL, captured once `enabled` turns on: undefined while it renders, null
124
+ * when it could not be. Portaled layers, such as the feedback sheet itself, are left out.
125
+ */
126
+ export function usePageScreenshot(enabled) {
127
+ const [src, setSrc] = useState();
128
+ useEffect(() => {
129
+ if (!enabled)
130
+ return;
131
+ let live = true;
132
+ let url;
133
+ snapdom(document.body, { exclude: ["[data-base-ui-portal]"], excludeMode: "remove" })
134
+ .then((capture) => capture.toBlob({ type: "png" }))
135
+ .then((blob) => {
136
+ url = URL.createObjectURL(blob);
137
+ if (live)
138
+ setSrc(url);
139
+ else
140
+ URL.revokeObjectURL(url);
141
+ })
142
+ .catch((error) => {
143
+ console.warn("Could not capture the page for feedback", error);
144
+ if (live)
145
+ setSrc(null);
146
+ });
147
+ return () => {
148
+ live = false;
149
+ if (url)
150
+ URL.revokeObjectURL(url);
151
+ };
152
+ }, [enabled]);
153
+ return src;
154
+ }
155
+ /** The screenshot as a file to upload with the feedback. */
156
+ export async function screenshotFile(src) {
157
+ const blob = await (await fetch(src)).blob();
158
+ return new File([blob], `screenshot.${blob.type.split("/")[1] ?? "png"}`, { type: blob.type });
159
+ }
112
160
  function placeAt(pointer) {
113
161
  return { left: `${pointer.x * 100}%`, top: `${pointer.y * 100}%` };
114
162
  }
@@ -153,7 +201,7 @@ export function FeedbackScreenshot({ src, pointers, onPointersChange, disabled,
153
201
  onPointersChange(pointers.map((pointer) => (pointer.id === id ? { ...pointer, ...at } : pointer)));
154
202
  };
155
203
  const remove = (id) => onPointersChange(pointers.filter((pointer) => pointer.id !== id));
156
- return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: thumbnail, "aria-label": pointers.length ? labels.annotateCount(pointers.length) : labels.annotate, disabled: disabled, onClick: () => setOpen(true), children: [_jsx("img", { src: src, alt: "" }), pointers.map((pointer) => (_jsx("span", { className: thumbnailDot, style: placeAt(pointer) }, pointer.id))), pointers.length > 0 && _jsx("span", { className: thumbnailCount, children: pointers.length })] }), _jsxs(Dialog, { open: open, onOpenChange: setOpen, title: labels.annotate, kind: "info", size: "wide", actions: _jsx(Button, { onClick: () => setOpen(false), children: common.done }), children: [_jsxs("div", { className: stage, children: [_jsx("button", { type: "button", ref: image, className: stageButton, "aria-label": labels.addPointer, "data-full": (full && pointers.every((pointer) => pointer.note.trim())) || undefined, onClick: drop, children: _jsx("img", { src: src, alt: labels.screenshot }) }), pointers.map((pointer, index) => (_jsx("span", { className: pointerMark, style: placeAt(pointer), "aria-hidden": "true", onPointerDown: (event) => event.currentTarget.setPointerCapture(event.pointerId), onPointerMove: (event) => drag(pointer.id, event), children: index + 1 }, pointer.id)))] }), pointers.length > 0 && (_jsx("ol", { className: pointerList, children: pointers.map((pointer, index) => (_jsxs("li", { className: pointerRow, children: [_jsx("span", { className: pointerBadge, "aria-hidden": "true", children: index + 1 }), _jsx(Input, { ref: (element) => {
204
+ return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: thumbnail, "aria-label": pointers.length ? labels.annotateCount(pointers.length) : labels.annotate, disabled: disabled, onClick: () => setOpen(true), children: [_jsx("img", { src: src, alt: "" }), pointers.map((pointer) => (_jsx("span", { className: thumbnailDot, style: placeAt(pointer) }, pointer.id))), pointers.length > 0 && _jsx("span", { className: thumbnailCount, children: pointers.length })] }), _jsxs(Dialog, { open: open, onOpenChange: setOpen, title: labels.annotate, titleVisibility: "hidden", kind: "info", dismiss: "footer", closeLabel: common.done, size: "wide", children: [_jsx("div", { className: stageFrame, "data-dialog-bleed": "", children: _jsxs("div", { className: stage, children: [_jsx("button", { type: "button", ref: image, className: stageButton, "aria-label": labels.addPointer, "data-full": (full && pointers.every((pointer) => pointer.note.trim())) || undefined, onClick: drop, children: _jsx("img", { src: src, alt: labels.screenshot }) }), pointers.map((pointer, index) => (_jsx("span", { className: pointerMark, style: placeAt(pointer), "aria-hidden": "true", onPointerDown: (event) => event.currentTarget.setPointerCapture(event.pointerId), onPointerMove: (event) => drag(pointer.id, event), children: index + 1 }, pointer.id)))] }) }), pointers.length > 0 && (_jsx("ol", { className: pointerList, children: pointers.map((pointer, index) => (_jsxs("li", { className: pointerRow, children: [_jsx("span", { className: pointerBadge, "aria-hidden": "true", children: index + 1 }), _jsx(Textarea, { className: pointerNote, rows: 1, ref: (element) => {
157
205
  if (element && focusPointerId.current === pointer.id) {
158
206
  element.focus();
159
207
  focusPointerId.current = null;
@@ -10,7 +10,7 @@ export type FeedbackSheetValues = {
10
10
  includeScreenshot: boolean;
11
11
  /** Pointers on the screenshot, in order; empty when it is not included. */
12
12
  annotations: FeedbackScreenshotPointer[];
13
- /** Files to upload with the feedback, within `feedbackAttachmentLimits`. */
13
+ /** Files to upload with the feedback, the screenshot among them, within `feedbackAttachmentLimits`. */
14
14
  attachments: File[];
15
15
  };
16
16
  export type { FeedbackScreenshotPointer };
@@ -31,7 +31,10 @@ export type FeedbackLabels = CiridaeLabels["feedback"];
31
31
  export declare function formatFeedbackDescription({ whatHappened, annotations }: FeedbackSheetValues): string;
32
32
  export type FeedbackFormProps = {
33
33
  where: FeedbackWhere;
34
- /** The page as the person sees it, as an image or data URL, to include and annotate. */
34
+ /**
35
+ * The page as the person sees it, as a same-origin image, object or data URL, since it is
36
+ * fetched to upload; captured on open when left out.
37
+ */
35
38
  screenshot?: string;
36
39
  /** Sends the feedback; rejecting shows the failed state with the message kept for a retry. */
37
40
  onSubmit: (values: FeedbackSheetValues) => Promise<{
@@ -20,7 +20,7 @@ import { useCopy } from "./copyable-id.js";
20
20
  import { DateTime } from "./date-time.js";
21
21
  import { Drawer, DrawerBody, DrawerField, DrawerFooter, DrawerForm } from "./drawer.js";
22
22
  import { Dropzone, DropzoneFileList, DropzonePad } from "./dropzone.js";
23
- import { FeedbackScreenshot, } from "./feedback-screenshot.js";
23
+ import { FeedbackScreenshot, screenshotFile, usePageScreenshot, } from "./feedback-screenshot.js";
24
24
  import { FilterBar, matchesFilter } from "./filter-bar.js";
25
25
  import { Checkbox, Textarea } from "./form-controls.js";
26
26
  import { directional, icon, Spinner } from "./icon.js";
@@ -123,8 +123,6 @@ const screenshotPreview = css({
123
123
  borderRadius: "keycap",
124
124
  background: "bg.field",
125
125
  color: "fg.muted",
126
- fontSize: "code",
127
- fontWeight: "medium",
128
126
  });
129
127
  const sent = css({
130
128
  display: "flex",
@@ -283,6 +281,13 @@ export function FeedbackForm({ where: about, screenshot, onSubmit, errorDetail,
283
281
  const [sendState, setSendState] = useState({ status: "idle" });
284
282
  const messageErrorId = useId();
285
283
  const submitting = sendState.status === "submitting";
284
+ const captured = usePageScreenshot(screenshot === undefined);
285
+ const image = screenshot ?? captured;
286
+ // Sending waits for an included screenshot that is still capturing.
287
+ const capturing = includeScreenshot && image === undefined;
288
+ const { count, bytes } = feedbackAttachmentLimits;
289
+ // An included screenshot, captured or still capturing, takes one of the slots.
290
+ const fileSlots = count - (includeScreenshot && image !== null ? 1 : 0);
286
291
  const reset = () => {
287
292
  setKind("wrong");
288
293
  setWhatHappened("");
@@ -295,18 +300,17 @@ export function FeedbackForm({ where: about, screenshot, onSubmit, errorDetail,
295
300
  };
296
301
  // Keeps what fits the limits and names the first file or limit that did not.
297
302
  const addAttachments = (files) => {
298
- const { count, bytes } = feedbackAttachmentLimits;
299
303
  const empty = files.find((file) => file.size === 0);
300
304
  const oversize = files.find((file) => file.size > bytes);
301
305
  const fitting = files.filter((file) => file.size > 0 && file.size <= bytes);
302
- const added = fitting.slice(0, Math.max(0, count - attachments.length));
306
+ const added = fitting.slice(0, Math.max(0, fileSlots - attachments.length));
303
307
  setAttachments([...attachments, ...added]);
304
308
  setAttachmentError(oversize
305
309
  ? labels.fileTooLarge(oversize.name, formatFileSize(bytes))
306
310
  : empty
307
311
  ? labels.fileEmpty(empty.name)
308
312
  : added.length < fitting.length
309
- ? labels.tooManyFiles(count)
313
+ ? labels.tooManyFiles(fileSlots)
310
314
  : null);
311
315
  };
312
316
  const removeAttachment = (removed) => {
@@ -321,6 +325,21 @@ export function FeedbackForm({ where: about, screenshot, onSubmit, errorDetail,
321
325
  setValidation(null);
322
326
  setSendState({ status: "submitting" });
323
327
  try {
328
+ const screenshotUpload = includeScreenshot && image ? await screenshotFile(image) : null;
329
+ // Files added while the screenshot was off can leave it no slot, and a long page can
330
+ // capture over the size limit.
331
+ const limitError = !screenshotUpload
332
+ ? null
333
+ : screenshotUpload.size > bytes
334
+ ? labels.fileTooLarge(screenshotUpload.name, formatFileSize(bytes))
335
+ : attachments.length >= count
336
+ ? labels.tooManyFiles(count - 1)
337
+ : null;
338
+ if (limitError) {
339
+ setAttachmentError(limitError);
340
+ setSendState({ status: "idle" });
341
+ return;
342
+ }
324
343
  const { reference } = await onSubmit({
325
344
  kind,
326
345
  whatHappened: whatHappened.trim(),
@@ -328,7 +347,7 @@ export function FeedbackForm({ where: about, screenshot, onSubmit, errorDetail,
328
347
  annotations: includeScreenshot
329
348
  ? pointers.map((pointer) => ({ x: pointer.x, y: pointer.y, note: pointer.note.trim() }))
330
349
  : [],
331
- attachments,
350
+ attachments: screenshotUpload ? [...attachments, screenshotUpload] : attachments,
332
351
  });
333
352
  setSendState({ status: "sent", reference });
334
353
  }
@@ -343,7 +362,7 @@ export function FeedbackForm({ where: about, screenshot, onSubmit, errorDetail,
343
362
  return (_jsxs(DrawerForm, { noValidate: true, onSubmit: (event) => {
344
363
  event.preventDefault();
345
364
  void send();
346
- }, children: [_jsxs(Dropzone, { render: _jsx(DrawerBody, { className: body }), disabled: submitting, onFiles: addAttachments, children: [sendState.status === "error" && (_jsx(FailedNotice, { title: labels.sendFailed, children: errorDetail?.(sendState.error) })), _jsx(DrawerField, { label: labels.type, children: _jsx(Select, { label: labels.type, size: "medium", options: kindOptions(labels), value: kind, disabled: submitting, onValueChange: (value) => isFeedbackKind(value) && setKind(value) }) }), _jsx(DrawerField, { label: labels.where, children: _jsx("div", { className: where, children: whereContent }) }), _jsx(DrawerField, { label: labels.whatHappened, error: validation, children: _jsx(Textarea, { className: message, value: whatHappened, placeholder: labels.whatHappenedPlaceholder, "aria-invalid": validation ? true : undefined, "aria-describedby": validation ? messageErrorId : undefined, disabled: submitting, onChange: (event) => setWhatHappened(event.target.value) }) }), _jsxs("div", { className: screenshotRow, children: [_jsx(Checkbox, { checked: includeScreenshot, disabled: submitting, onCheckedChange: (checked) => setIncludeScreenshot(checked), children: _jsx("span", { className: screenshotCopy, children: labels.includeScreenshot }) }), screenshot ? (_jsx(FeedbackScreenshot, { src: screenshot, pointers: pointers, onPointersChange: setPointers, disabled: submitting || !includeScreenshot })) : (_jsx("span", { className: screenshotPreview, children: labels.preview }))] }), _jsxs(DrawerField, { label: labels.attachments, error: attachmentError, children: [_jsx(DropzoneFileList, { files: attachments, pending: submitting, disabled: submitting, onRemove: removeAttachment }), _jsx(DropzonePad, {})] })] }), _jsxs(DrawerFooter, { children: [_jsx(Button, { size: "medium", variant: "secondary", disabled: submitting, onClick: onClose, children: locale.common.cancel }), _jsx(Button, { type: "submit", size: "medium", loading: submitting, icon: sendState.status === "error" ? (_jsx(ArrowClockwiseIcon, { className: icon({ size: "small" }) })) : undefined, children: submitting
365
+ }, children: [_jsxs(Dropzone, { render: _jsx(DrawerBody, { className: body }), disabled: submitting, onFiles: addAttachments, children: [sendState.status === "error" && (_jsx(FailedNotice, { title: labels.sendFailed, children: errorDetail?.(sendState.error) })), _jsx(DrawerField, { label: labels.type, children: _jsx(Select, { label: labels.type, size: "medium", options: kindOptions(labels), value: kind, disabled: submitting, onValueChange: (value) => isFeedbackKind(value) && setKind(value) }) }), _jsx(DrawerField, { label: labels.where, children: _jsx("div", { className: where, children: whereContent }) }), _jsx(DrawerField, { label: labels.whatHappened, error: validation, children: _jsx(Textarea, { className: message, value: whatHappened, placeholder: labels.whatHappenedPlaceholder, "aria-invalid": validation ? true : undefined, "aria-describedby": validation ? messageErrorId : undefined, disabled: submitting, onChange: (event) => setWhatHappened(event.target.value) }) }), image !== null && (_jsxs("div", { className: screenshotRow, children: [_jsx(Checkbox, { checked: includeScreenshot, disabled: submitting, onCheckedChange: (checked) => setIncludeScreenshot(checked), children: _jsx("span", { className: screenshotCopy, children: labels.includeScreenshot }) }), image ? (_jsx(FeedbackScreenshot, { src: image, pointers: pointers, onPointersChange: setPointers, disabled: submitting || !includeScreenshot })) : (_jsx("span", { className: screenshotPreview, children: _jsx(Spinner, {}) }))] })), _jsxs(DrawerField, { label: labels.attachments, error: attachmentError, children: [_jsx(DropzoneFileList, { files: attachments, pending: submitting, disabled: submitting, onRemove: removeAttachment }), _jsx(DropzonePad, {})] })] }), _jsxs(DrawerFooter, { children: [_jsx(Button, { size: "medium", variant: "secondary", disabled: submitting, onClick: onClose, children: locale.common.cancel }), _jsx(Button, { type: "submit", size: "medium", disabled: capturing, loading: submitting, icon: sendState.status === "error" ? (_jsx(ArrowClockwiseIcon, { className: icon({ size: "small" }) })) : undefined, children: submitting
347
366
  ? labels.sending
348
367
  : sendState.status === "error"
349
368
  ? locale.common.tryAgain
@@ -17,7 +17,8 @@ export const checkMark = cva({
17
17
  display: "inline-grid",
18
18
  placeItems: "center",
19
19
  padding: "none",
20
- border: "1px solid transparent",
20
+ // No reserved border: the edge and the face fill the mark, and the focus ring sits against it.
21
+ border: "0",
21
22
  background: "[token(gradients.selected)]",
22
23
  color: "bg.canvas",
23
24
  _light: { color: "fg.onAccent", background: "bg.check" },
@@ -124,6 +124,33 @@ export declare const englishLabels: {
124
124
  userChip: {
125
125
  copyEmail: string;
126
126
  };
127
+ memberDirectory: {
128
+ title: string;
129
+ search: string;
130
+ columns: {
131
+ member: string;
132
+ status: string;
133
+ role: string;
134
+ activity: string;
135
+ };
136
+ statuses: {
137
+ active: string;
138
+ invited: string;
139
+ expired: string;
140
+ };
141
+ memberSort: [string, string];
142
+ activitySort: [string, string];
143
+ you: string;
144
+ lastActive: string;
145
+ accountConnected: string;
146
+ noActivity: string;
147
+ invitationSent: string;
148
+ invitationExpired: string;
149
+ empty: string;
150
+ noMatches: string;
151
+ clearFilters: string;
152
+ unavailable: string;
153
+ };
127
154
  activity: {
128
155
  show: string;
129
156
  all: string;
@@ -169,7 +196,6 @@ export declare const englishLabels: {
169
196
  whatHappened: string;
170
197
  whatHappenedPlaceholder: string;
171
198
  includeScreenshot: string;
172
- preview: string;
173
199
  attachments: string;
174
200
  kindWrong: string;
175
201
  kindIdea: string;
@@ -106,6 +106,24 @@ export const englishLabels = {
106
106
  attachFiles: "Attach files",
107
107
  },
108
108
  userChip: { copyEmail: "Copy email" },
109
+ memberDirectory: {
110
+ title: "Members",
111
+ search: "Search members",
112
+ columns: { member: "Member", status: "Status", role: "Role", activity: "Activity" },
113
+ statuses: { active: "Active", invited: "Invited", expired: "Expired" },
114
+ memberSort: ["A to Z", "Z to A"],
115
+ activitySort: ["Oldest first", "Newest first"],
116
+ you: "You",
117
+ lastActive: "Last active",
118
+ accountConnected: "Account connected",
119
+ noActivity: "No activity yet",
120
+ invitationSent: "Invitation sent",
121
+ invitationExpired: "Invitation expired",
122
+ empty: "No members found",
123
+ noMatches: "No members match your search and filters",
124
+ clearFilters: "Clear filters",
125
+ unavailable: "Could not load members",
126
+ },
109
127
  activity: {
110
128
  show: "Show",
111
129
  all: "All",
@@ -151,7 +169,6 @@ export const englishLabels = {
151
169
  whatHappened: "What happened?",
152
170
  whatHappenedPlaceholder: "Tell us what happened",
153
171
  includeScreenshot: "Include a screenshot",
154
- preview: "Preview",
155
172
  attachments: "Attachments",
156
173
  kindWrong: "Something is wrong",
157
174
  kindIdea: "An idea",
@@ -475,6 +492,7 @@ function mergeLabels(overrides) {
475
492
  dates: { ...englishLabels.dates, ...overrides.dates },
476
493
  dropzone: { ...englishLabels.dropzone, ...overrides.dropzone },
477
494
  userChip: { ...englishLabels.userChip, ...overrides.userChip },
495
+ memberDirectory: { ...englishLabels.memberDirectory, ...overrides.memberDirectory },
478
496
  activity: { ...englishLabels.activity, ...overrides.activity },
479
497
  notifications: { ...englishLabels.notifications, ...overrides.notifications },
480
498
  feedback: { ...englishLabels.feedback, ...overrides.feedback },
@@ -0,0 +1,35 @@
1
+ import { type SortingState } from "./data-grid.js";
2
+ import { type FilterValue } from "./filter-bar.js";
3
+ /** Ordered healthiest first, which is also how the Status column sorts ascending. */
4
+ export declare const MEMBER_STATUSES: readonly ["active", "invited", "expired"];
5
+ /** The built-in roles; a member may also hold a role the organization defines. */
6
+ export declare const MEMBER_ROLES: readonly ["admin", "member"];
7
+ export declare const MEMBER_DIRECTORY_COLUMNS: readonly ["member", "status", "role", "activity"];
8
+ export type MemberStatus = (typeof MEMBER_STATUSES)[number];
9
+ export type MemberRole = (typeof MEMBER_ROLES)[number];
10
+ export type MemberDirectoryColumn = (typeof MEMBER_DIRECTORY_COLUMNS)[number];
11
+ export type DirectoryMember = {
12
+ id: string;
13
+ name: string | null;
14
+ email: string;
15
+ pictureUrl: string | null;
16
+ role: string;
17
+ status: MemberStatus;
18
+ lastActiveAt: string | null;
19
+ };
20
+ export type MemberDirectoryProps = {
21
+ members: DirectoryMember[];
22
+ loading?: boolean;
23
+ /** Why the list could not load; pass it only when there is nothing to show. */
24
+ error?: string;
25
+ onRetry?: () => void;
26
+ currentMemberId?: string | null;
27
+ search: string;
28
+ onSearchChange: (search: string) => void;
29
+ filters: FilterValue[];
30
+ onFiltersChange: (filters: FilterValue[]) => void;
31
+ sorting: SortingState;
32
+ onSortingChange: (sorting: SortingState) => void;
33
+ onClearFilters: () => void;
34
+ };
35
+ export declare function MemberDirectory({ members, loading, error, onRetry, currentMemberId, search, onSearchChange, filters, onFiltersChange, sorting, onSortingChange, onClearFilters, }: MemberDirectoryProps): import("react").JSX.Element;