@ciridae/ui 1.2.2 → 1.4.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.
Files changed (64) hide show
  1. package/README.md +2 -2
  2. package/dist/components/app-frame.js +4 -4
  3. package/dist/components/button.d.ts +0 -11
  4. package/dist/components/button.js +1 -26
  5. package/dist/components/color-theme.d.ts +3 -12
  6. package/dist/components/color-theme.js +2 -29
  7. package/dist/components/dropzone.d.ts +0 -4
  8. package/dist/components/dropzone.js +4 -9
  9. package/dist/components/feedback-sheet.d.ts +1 -16
  10. package/dist/components/feedback-sheet.js +7 -144
  11. package/dist/components/hotkeys.d.ts +1 -11
  12. package/dist/components/hotkeys.js +3 -44
  13. package/dist/components/keyboard-shortcuts.d.ts +0 -2
  14. package/dist/components/keyboard-shortcuts.js +2 -46
  15. package/dist/components/locale.d.ts +11 -42
  16. package/dist/components/locale.js +12 -48
  17. package/dist/components/log-list.d.ts +0 -2
  18. package/dist/components/log-list.js +0 -22
  19. package/dist/components/profile-dialog.d.ts +10 -0
  20. package/dist/components/profile-dialog.js +46 -0
  21. package/dist/components/record.d.ts +0 -23
  22. package/dist/components/record.js +2 -80
  23. package/dist/components/select.d.ts +7 -0
  24. package/dist/components/select.js +21 -2
  25. package/dist/components/sidebar.d.ts +0 -1
  26. package/dist/components/sidebar.js +0 -10
  27. package/dist/components/tabs.d.ts +0 -3
  28. package/dist/components/tabs.js +0 -4
  29. package/dist/feedback/contract.d.ts +1 -25
  30. package/dist/feedback/contract.js +2 -6
  31. package/dist/feedback/operator-controller.d.ts +3 -10
  32. package/dist/feedback/operator-controller.js +1 -28
  33. package/dist/preset.d.ts +0 -6
  34. package/dist/preset.js +0 -5
  35. package/dist/styled-system/styles.css +20 -82
  36. package/dist/theme/options.d.ts +1 -19
  37. package/dist/theme/options.js +0 -1
  38. package/dist/theme/tokens.d.ts +1 -8
  39. package/dist/theme/tokens.js +1 -17
  40. package/package.json +5 -49
  41. package/dist/components/profile-header.d.ts +0 -15
  42. package/dist/components/profile-header.js +0 -40
  43. package/dist/components/recent-items.d.ts +0 -28
  44. package/dist/components/recent-items.js +0 -63
  45. package/dist/components/theme-customizer.d.ts +0 -50
  46. package/dist/components/theme-customizer.js +0 -84
  47. package/dist/components/theme-toggle.d.ts +0 -3
  48. package/dist/components/theme-toggle.js +0 -65
  49. package/dist/feedback/comment-types.d.ts +0 -17
  50. package/dist/feedback/comment-types.js +0 -1
  51. package/dist/feedback/feedback-cache.d.ts +0 -6
  52. package/dist/feedback/feedback-cache.js +0 -58
  53. package/dist/feedback/feedback-center-model.d.ts +0 -8
  54. package/dist/feedback/feedback-center-model.js +0 -37
  55. package/dist/feedback/feedback-composer-types.d.ts +0 -11
  56. package/dist/feedback/feedback-composer-types.js +0 -1
  57. package/dist/feedback/feedback-controller.d.ts +0 -56
  58. package/dist/feedback/feedback-controller.js +0 -181
  59. package/dist/feedback/feedback-tracking-types.d.ts +0 -14
  60. package/dist/feedback/feedback-tracking-types.js +0 -1
  61. package/dist/feedback/submit-feedback-with-attachments.d.ts +0 -10
  62. package/dist/feedback/submit-feedback-with-attachments.js +0 -10
  63. package/dist/theme/index.d.ts +0 -3
  64. package/dist/theme/index.js +0 -7
package/README.md CHANGED
@@ -16,11 +16,11 @@ recognise its `css` import alias. The components use only this preset's tokens;
16
16
 
17
17
  ```ts
18
18
  // panda.config.ts
19
- import { ciridaePreset } from "@ciridae/ui/preset";
19
+ import { createCiridaePreset } from "@ciridae/ui/preset";
20
20
  import { defineConfig } from "@pandacss/dev";
21
21
 
22
22
  export default defineConfig({
23
- presets: [ciridaePreset],
23
+ presets: [createCiridaePreset()],
24
24
  importMap: { css: ["#primitives/css", "styled-system/css"] },
25
25
  include: ["./src/**/*.{ts,tsx}", "./node_modules/@ciridae/ui/dist/**/*.js"],
26
26
  });
@@ -26,12 +26,12 @@ export function useColorThemeMenuItem() {
26
26
  const colorTheme = useColorTheme();
27
27
  const { labels } = useCiridaeLocale();
28
28
  const choices = [
29
- { value: "system", label: labels.themeCustomizer.system },
30
- { value: "light", label: labels.themeCustomizer.light },
31
- { value: "dark", label: labels.themeCustomizer.dark },
29
+ { value: "system", label: labels.colorTheme.system },
30
+ { value: "light", label: labels.colorTheme.light },
31
+ { value: "dark", label: labels.colorTheme.dark },
32
32
  ];
33
33
  return {
34
- label: labels.themeCustomizer.colorTheme,
34
+ label: labels.colorTheme.title,
35
35
  icon: _jsx(CircleHalfIcon, { className: icon({ size: "small" }) }),
36
36
  items: choices.map((choice) => ({
37
37
  label: choice.label,
@@ -19,17 +19,6 @@ export type ButtonProps = Omit<BaseButtonProps, "className"> & {
19
19
  */
20
20
  export declare const ButtonSizeContext: import("react").Context<NonNullable<"medium" | "large" | "small" | undefined>>;
21
21
  export declare function Button({ className, variant, size: ownSize, fullWidth, loading, icon, shortcut, children, disabled, ...props }: ButtonProps): import("react").JSX.Element;
22
- export type DataButtonState = "idle" | "pending" | "error" | "success";
23
- export type DataButtonProps = Omit<ButtonProps, "children" | "icon" | "loading"> & {
24
- state: DataButtonState;
25
- idleLabel: ReactNode;
26
- pendingLabel?: ReactNode;
27
- errorLabel?: ReactNode;
28
- successLabel?: ReactNode;
29
- icon?: ReactNode;
30
- };
31
- /** Async action button with consistent pending, retry, and completion feedback. */
32
- export declare function DataButton({ state, idleLabel, pendingLabel, errorLabel, successLabel, variant, icon, disabled, ...props }: DataButtonProps): import("react").JSX.Element;
33
22
  type IconButtonSize = "compact" | "send" | "small" | "medium" | "large";
34
23
  /**
35
24
  * The size an `IconButton` takes where it does not set its own, so the container decides: the
@@ -1,11 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Button as BaseButton } from "@base-ui/react/button";
3
- import { CheckCircleIcon, WarningCircleIcon } from "@phosphor-icons/react";
4
3
  import { createContext, useContext } from "react";
5
4
  import { css, cva, cx } from "#primitives/css";
6
5
  import { faceEdge } from "./gradient-edge.js";
7
6
  import { formatForDisplay } from "./hotkeys.js";
8
- import { icon as iconStyle, Spinner } from "./icon.js";
7
+ import { Spinner } from "./icon.js";
9
8
  import { ShortcutHint } from "./keycap.js";
10
9
  import { useCiridaeLocale } from "./locale.js";
11
10
  const raisedHoverLight = "[linear-gradient(token(colors.bg.hover), token(colors.bg.hover)), token(gradients.raised)]";
@@ -159,30 +158,6 @@ export function Button({ className, variant = "primary", size: ownSize, fullWidt
159
158
  const edge = faceEdge(buttonEdges[variant]);
160
159
  return (_jsxs(BaseButton, { ...props, disabled: disabled || loading, "aria-busy": loading || undefined, className: cx(action({ variant, size, fullWidth }), edge.className, className), "data-ciridae-ui": "", "data-edge": edge["data-edge"], children: [loading ? _jsx(Spinner, { "aria-hidden": "true" }) : icon, children, shortcut && _jsx(ShortcutHint, { hotkey: shortcut, className: buttonHint })] }));
161
160
  }
162
- /** Async action button with consistent pending, retry, and completion feedback. */
163
- export function DataButton({ state, idleLabel, pendingLabel, errorLabel, successLabel, variant = "primary", icon, disabled, ...props }) {
164
- const { labels } = useCiridaeLocale();
165
- const presentation = state === "pending"
166
- ? {
167
- label: pendingLabel ?? labels.common.working,
168
- icon: _jsx(Spinner, { "aria-hidden": "true" }),
169
- variant,
170
- }
171
- : state === "error"
172
- ? {
173
- label: errorLabel ?? labels.common.retry,
174
- icon: _jsx(WarningCircleIcon, { className: iconStyle({ size: "small" }) }),
175
- variant: "danger",
176
- }
177
- : state === "success"
178
- ? {
179
- label: successLabel ?? labels.common.done,
180
- icon: _jsx(CheckCircleIcon, { className: iconStyle({ size: "small" }) }),
181
- variant: "success",
182
- }
183
- : { label: idleLabel, icon, variant };
184
- return (_jsx(Button, { ...props, variant: presentation.variant, disabled: disabled || state === "success", loading: state === "pending", icon: presentation.icon, children: presentation.label }));
185
- }
186
161
  const round = cva({
187
162
  base: {
188
163
  textDecoration: "none",
@@ -1,6 +1,6 @@
1
1
  import { type ReactNode } from "react";
2
- import type { Brand, CiridaeTheme, ColorTheme } from "../theme/options.js";
3
- export type { Brand, ColorTheme } from "../theme/options.js";
2
+ import type { ColorTheme } from "../theme/options.js";
3
+ export type { ColorTheme } from "../theme/options.js";
4
4
  /** What the reader chose: a theme, or to follow the operating system's. */
5
5
  export type ColorThemePreference = ColorTheme | "system";
6
6
  type ColorThemeContextValue = {
@@ -16,13 +16,6 @@ export type ThemeProviderProps = {
16
16
  /** Used until the reader chooses, and whenever nothing readable is stored. */
17
17
  defaultColorTheme?: ColorThemePreference;
18
18
  storageKey?: string;
19
- /** What the product calls itself, for `useBrand`. */
20
- brand?: Brand;
21
- /**
22
- * Faces to show over the ones the stylesheet was built with, switchable at runtime, such as a
23
- * preview. Leave it out to keep the built faces.
24
- */
25
- fonts?: CiridaeTheme["fonts"];
26
19
  };
27
20
  /**
28
21
  * Owns the document's color theme. The chosen theme is written to
@@ -30,8 +23,6 @@ export type ThemeProviderProps = {
30
23
  * `_light` values resolve through, so every component follows without
31
24
  * threading a prop.
32
25
  */
33
- export declare function ThemeProvider({ children, defaultColorTheme, storageKey, brand, fonts, }: ThemeProviderProps): import("react").JSX.Element;
26
+ export declare function ThemeProvider({ children, defaultColorTheme, storageKey, }: ThemeProviderProps): import("react").JSX.Element;
34
27
  /** Throws outside a `ThemeProvider`, where there is no theme to report or change. */
35
28
  export declare function useColorTheme(): ColorThemeContextValue;
36
- /** Throws outside a `ThemeProvider` given a `brand`, where there is no name to show. */
37
- export declare function useBrand(): Brand;
@@ -1,7 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { createContext, useCallback, useContext, useEffect, useMemo, useState, } from "react";
3
3
  import { SkulletProvider } from "skullet/react";
4
- import { fontStylesheet } from "../theme/tokens.js";
5
4
  /** The attribute the `light` Panda condition and `ciridae.css` both select on. */
6
5
  const THEME_ATTRIBUTE = "data-ciridae-theme";
7
6
  const DEFAULT_STORAGE_KEY = "ciridae-ui-color-theme";
@@ -33,7 +32,6 @@ function readSystemTheme() {
33
32
  return globalThis.matchMedia?.(lightSchemeQuery).matches ? "light" : "dark";
34
33
  }
35
34
  const ColorThemeContext = createContext(null);
36
- const BrandContext = createContext(null);
37
35
  // Both modes use the product's resolved ink, so custom palettes follow the same theme. The
38
36
  // highlight paints over the bar: dark ink would smear it, so light has none and holds still.
39
37
  const loadingTheme = {
@@ -48,31 +46,13 @@ const loadingTheme = {
48
46
  animation: "shimmer",
49
47
  speed: "slow",
50
48
  };
51
- const RUNTIME_FONTS_ELEMENT_ID = "ciridae-runtime-fonts";
52
- function useRuntimeFonts(fonts) {
53
- const display = fonts?.display;
54
- const sans = fonts?.sans;
55
- const mono = fonts?.mono;
56
- useEffect(() => {
57
- const document = globalThis.document;
58
- if (!document || (!display && !sans && !mono))
59
- return;
60
- const existing = document.getElementById(RUNTIME_FONTS_ELEMENT_ID);
61
- const style = existing instanceof HTMLStyleElement ? existing : document.createElement("style");
62
- style.id = RUNTIME_FONTS_ELEMENT_ID;
63
- style.textContent = fontStylesheet({ display, sans, mono });
64
- document.head.append(style);
65
- return () => style.remove();
66
- }, [display, sans, mono]);
67
- }
68
49
  /**
69
50
  * Owns the document's color theme. The chosen theme is written to
70
51
  * `data-ciridae-theme` on the document element, which is what the tokens'
71
52
  * `_light` values resolve through, so every component follows without
72
53
  * threading a prop.
73
54
  */
74
- export function ThemeProvider({ children, defaultColorTheme = "dark", storageKey = DEFAULT_STORAGE_KEY, brand, fonts, }) {
75
- useRuntimeFonts(fonts);
55
+ export function ThemeProvider({ children, defaultColorTheme = "dark", storageKey = DEFAULT_STORAGE_KEY, }) {
76
56
  const [preference, setPreferenceState] = useState(() => readStoredPreference(storageKey) ?? defaultColorTheme);
77
57
  const [systemTheme, setSystemTheme] = useState(readSystemTheme);
78
58
  // Only a `system` preference follows the operating system as it changes.
@@ -105,7 +85,7 @@ export function ThemeProvider({ children, defaultColorTheme = "dark", storageKey
105
85
  const setTheme = setPreference;
106
86
  const toggleTheme = useCallback(() => setTheme(theme === "dark" ? "light" : "dark"), [setTheme, theme]);
107
87
  const value = useMemo(() => ({ theme, preference, setPreference, setTheme, toggleTheme }), [theme, preference, setPreference, setTheme, toggleTheme]);
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 }) }) }));
88
+ return (_jsx(ColorThemeContext.Provider, { value: value, children: _jsx(SkulletProvider, { mode: theme, theme: loadingTheme, reveal: "smart", children: children }) }));
109
89
  }
110
90
  /** Throws outside a `ThemeProvider`, where there is no theme to report or change. */
111
91
  export function useColorTheme() {
@@ -114,10 +94,3 @@ export function useColorTheme() {
114
94
  throw new Error("useColorTheme must be used within a ThemeProvider");
115
95
  return value;
116
96
  }
117
- /** Throws outside a `ThemeProvider` given a `brand`, where there is no name to show. */
118
- export function useBrand() {
119
- const brand = useContext(BrandContext);
120
- if (!brand)
121
- throw new Error("useBrand must be used within a ThemeProvider given a brand");
122
- return brand;
123
- }
@@ -1,6 +1,5 @@
1
1
  import { useRender } from "@base-ui/react/use-render";
2
2
  import { type ReactNode } from "react";
3
- import { type ButtonProps } from "./button.js";
4
3
  /** One square per file, as a chat app draws them: an image's thumbnail, or a file's icon over its name. */
5
4
  export declare const fileSquare: string;
6
5
  export type DropzoneContextValue = {
@@ -21,9 +20,6 @@ export type DropzoneProps = useRender.ComponentProps<"div"> & {
21
20
  export declare function Dropzone({ onFiles, dropLabel, disabled, accept, render, className, children, ...props }: DropzoneProps): import("react").JSX.Element;
22
21
  /** The enclosing `Dropzone`'s picker, for a trigger of the caller's own, such as an icon button. */
23
22
  export declare function useDropzonePicker(): DropzoneContextValue;
24
- export type DropzoneTriggerProps = Omit<ButtonProps, "onClick">;
25
- /** Opens the enclosing `Dropzone`'s file picker; a paperclip unless it sets its own icon. */
26
- export declare function DropzoneTrigger({ icon: triggerIcon, variant, disabled, ...props }: DropzoneTriggerProps): import("react").JSX.Element;
27
23
  /** A dashed pad at rest inside a `Dropzone`: drop files on it, or browse for them. */
28
24
  export declare function DropzonePad({ className }: {
29
25
  className?: string;
@@ -1,14 +1,14 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  /*
3
3
  * A file drop target: any element, by default a div, that takes files dropped on it or pasted into
4
- * it and highlights while files are dragged over it; `DropzoneTrigger` opens the file picker, and
5
- * `DropzoneFileList` lists the files the caller holds. The caller owns the files and their limits.
4
+ * it and highlights while files are dragged over it; `DropzoneFileList` lists the files the caller
5
+ * holds. The caller owns the files and their limits.
6
6
  */
7
7
  import { useRender } from "@base-ui/react/use-render";
8
- import { FileIcon, FilePdfIcon, FileTextIcon, FileZipIcon, PaperclipIcon, UploadSimpleIcon, XIcon, } from "@phosphor-icons/react";
8
+ import { FileIcon, FilePdfIcon, FileTextIcon, FileZipIcon, UploadSimpleIcon, XIcon, } from "@phosphor-icons/react";
9
9
  import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
10
10
  import { css, cx } from "#primitives/css";
11
- import { Button, IconButton } from "./button.js";
11
+ import { IconButton } from "./button.js";
12
12
  import { icon, Spinner } from "./icon.js";
13
13
  import { Lightbox } from "./lightbox.js";
14
14
  import { useCiridaeLocale } from "./locale.js";
@@ -302,11 +302,6 @@ export function useDropzonePicker() {
302
302
  throw new Error("useDropzonePicker must be inside a Dropzone.");
303
303
  return dropzone;
304
304
  }
305
- /** Opens the enclosing `Dropzone`'s file picker; a paperclip unless it sets its own icon. */
306
- export function DropzoneTrigger({ icon: triggerIcon, variant = "secondary", disabled, ...props }) {
307
- const dropzone = useDropzonePicker();
308
- return (_jsx(Button, { ...props, variant: variant, disabled: disabled || dropzone.disabled, icon: triggerIcon ?? _jsx(PaperclipIcon, { className: icon({ size: "small" }) }), onClick: dropzone.openPicker }));
309
- }
310
305
  /** A dashed pad at rest inside a `Dropzone`: drop files on it, or browse for them. */
311
306
  export function DropzonePad({ className }) {
312
307
  const dropzone = useDropzonePicker();
@@ -1,6 +1,5 @@
1
1
  import { type ReactNode } from "react";
2
2
  import { type FeedbackItem, type FeedbackSummary } from "../feedback/contract.js";
3
- import { type FeedbackTriageStatus, type OperatorFeedbackItem, type OperatorFeedbackSummary } from "../feedback/operator-contract.js";
4
3
  import { type FeedbackScreenshotPointer } from "./feedback-screenshot.js";
5
4
  import { type CiridaeLabels } from "./locale.js";
6
5
  export type FeedbackKind = "wrong" | "idea" | "question";
@@ -70,27 +69,13 @@ export type FeedbackSentProps = {
70
69
  /** Resolves once `item` is withdrawn. */
71
70
  onWithdraw: (feedbackId: string) => Promise<void>;
72
71
  };
73
- /** The All tab, for the people who answer feedback: everyone's items, triaged and replied to. */
74
- export type FeedbackOperatorProps = {
75
- /** Every reporter's feedback, in any order; the tab lists the latest change first. */
76
- items: FeedbackLoadState<readonly OperatorFeedbackSummary[]>;
77
- /** Loads the item into `item`; the sheet shows it once the ids match. */
78
- onOpenItem: (feedbackId: string) => void;
79
- item?: FeedbackLoadState<OperatorFeedbackItem>;
80
- /** Resolves once `item` carries the reply; rejecting keeps the reply in the composer. */
81
- onReply: (feedbackId: string, body: string) => Promise<void>;
82
- /** Resolves once `item` carries the status; withdrawing stays the reporter's. */
83
- onStatusChange: (feedbackId: string, status: FeedbackTriageStatus) => Promise<void>;
84
- };
85
72
  export type FeedbackSheetProps = Omit<FeedbackFormProps, "onClose"> & {
86
73
  open: boolean;
87
74
  onOpenChange: (open: boolean) => void;
88
75
  /** Controls in the sheet's header, before the close button. */
89
76
  actions?: ReactNode;
90
- /** The person's own tickets; without it or `operator` the sheet is the form alone. */
77
+ /** The person's own tickets; without it the sheet is the form alone. */
91
78
  sent?: FeedbackSentProps;
92
- /** For an operator, the Tickets tab lists everyone's, with a filter for their own (`sent`). */
93
- operator?: FeedbackOperatorProps;
94
79
  /** Rewords the sheet's labels over the locale's. */
95
80
  labels?: Partial<FeedbackLabels>;
96
81
  };
@@ -4,16 +4,13 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
4
4
  * attach a screenshot, with numbered pointers and notes on it, and files dropped on the form,
5
5
  * picked or pasted; the form owns its validation and the sending, sent and failed states.
6
6
  * Tickets: everything the person filed, and each item's conversation with the Ciridae team as a
7
- * thread they can reply in, with the item's actions, such as withdrawing it, behind its menu. For
8
- * an operator it lists everyone's instead, filtered (their own among the filters) and searched,
9
- * each item the same thread with a status to set. The sheet is presentational: the caller owns the requests behind
10
- * `onSubmit`, `sent` and `operator`; `useFeedbackOperatorSheet` builds `operator` from the API.
7
+ * thread they can reply in, with the item's actions, such as withdrawing it, behind its menu. The
8
+ * sheet is presentational: the caller owns the requests behind `onSubmit` and `sent`.
11
9
  */
12
10
  import { ArrowClockwiseIcon, ArrowLeftIcon, ChatCircleTextIcon, DotsThreeIcon, SquaresFourIcon, } from "@phosphor-icons/react";
13
11
  import { createContext, useContext, useId, useState } from "react";
14
12
  import { css, cx } from "#primitives/css";
15
- import { feedbackAttachmentLimits, feedbackStatusSchema, feedbackTypeSchema, } from "../feedback/contract.js";
16
- import { feedbackTriageStatusSchema, } from "../feedback/operator-contract.js";
13
+ import { feedbackAttachmentLimits, } from "../feedback/contract.js";
17
14
  import { Button, IconButton } from "./button.js";
18
15
  import { ChatComposer, ChatThread } from "./chat.js";
19
16
  import { useCopy } from "./copyable-id.js";
@@ -21,10 +18,8 @@ import { DateTime } from "./date-time.js";
21
18
  import { Drawer, DrawerBody, DrawerField, DrawerFooter, DrawerForm } from "./drawer.js";
22
19
  import { Dropzone, DropzoneFileList, DropzonePad } from "./dropzone.js";
23
20
  import { FeedbackScreenshot, screenshotFile, usePageScreenshot, } from "./feedback-screenshot.js";
24
- import { FilterBar, matchesFilter } from "./filter-bar.js";
25
21
  import { Checkbox, Textarea } from "./form-controls.js";
26
22
  import { directional, icon, Spinner } from "./icon.js";
27
- import { SearchInput } from "./input.js";
28
23
  import { Eyebrow } from "./layout.js";
29
24
  import { useCiridaeLocale } from "./locale.js";
30
25
  import { Menu } from "./menu.js";
@@ -208,11 +203,6 @@ const sentEmpty = css({
208
203
  textAlign: "center",
209
204
  });
210
205
  const padded = css({ padding: "panel.comfortable" });
211
- const listToolbar = css({
212
- paddingBlock: "panel.compact",
213
- paddingInline: "panel.comfortable",
214
- borderBottom: "1px solid token(colors.border.subtle)",
215
- });
216
206
  /* An item: its subject and status pinned over the thread, which scrolls; the reply below. */
217
207
  const itemHeader = css({
218
208
  position: "sticky",
@@ -376,27 +366,20 @@ function FailedNotice({ title, children, action, }) {
376
366
  export function FeedbackSheet({ labels, ...props }) {
377
367
  return (_jsx(FeedbackLabelsContext, { value: labels, children: _jsx(FeedbackSheetContent, { ...props }) }));
378
368
  }
379
- function FeedbackSheetContent({ open, onOpenChange, actions, sent, operator, errorDetail, ...formProps }) {
369
+ function FeedbackSheetContent({ open, onOpenChange, actions, sent, errorDetail, ...formProps }) {
380
370
  const labels = useFeedbackLabels();
381
- const operatorLabels = useCiridaeLocale().labels.feedbackOperator;
382
371
  const [tab, setTab] = useState("new");
383
372
  const [openItemId, setOpenItemId] = useState(null);
384
- const showAll = tab === "tickets" && operator !== undefined;
385
- const showSent = tab === "tickets" && !showAll && sent !== undefined;
373
+ const showSent = tab === "tickets" && sent !== undefined;
386
374
  const close = () => {
387
375
  onOpenChange(false);
388
376
  setOpenItemId(null);
389
377
  };
390
378
  const back = () => setOpenItemId(null);
391
- return (_jsx(Drawer, { open: open, onOpenChange: (next) => (next ? onOpenChange(true) : close()), title: showAll ? operatorLabels.allTitle : showSent ? labels.sentTitle : labels.sendTitle, icon: _jsx(ChatCircleTextIcon, { className: icon({ size: "small" }), weight: "fill" }), actions: _jsxs(_Fragment, { children: [(sent || operator) && (_jsx(TabsRoot, { value: tab, onValueChange: (value) => {
379
+ return (_jsx(Drawer, { open: open, onOpenChange: (next) => (next ? onOpenChange(true) : close()), title: showSent ? labels.sentTitle : labels.sendTitle, icon: _jsx(ChatCircleTextIcon, { className: icon({ size: "small" }), weight: "fill" }), actions: _jsxs(_Fragment, { children: [sent && (_jsx(TabsRoot, { value: tab, onValueChange: (value) => {
392
380
  setTab(value);
393
381
  setOpenItemId(null);
394
- }, children: _jsxs(TabsList, { variant: "contained", children: [_jsx(TabsTab, { value: "new", children: labels.newTab }), _jsx(TabsTab, { value: "tickets", children: labels.ticketsTab })] }) })), actions] }), children: showAll ? (openItemId === null ? (_jsx(OperatorList, { operator: operator, ownIds: sent?.items.status === "loaded"
395
- ? new Set(sent.items.data.map((item) => item.id))
396
- : undefined, errorDetail: errorDetail, onOpen: (feedbackId) => {
397
- operator.onOpenItem(feedbackId);
398
- setOpenItemId(feedbackId);
399
- } })) : (_jsx(OperatorItem, { feedbackId: openItemId, operator: operator, errorDetail: errorDetail, onBack: back }, openItemId))) : !showSent ? (_jsx(FeedbackForm, { ...formProps, errorDetail: errorDetail, onClose: close })) : openItemId === null ? (_jsx(FeedbackList, { items: sent.items, rows: (items) => items.map((item) => ({
382
+ }, children: _jsxs(TabsList, { variant: "contained", children: [_jsx(TabsTab, { value: "new", children: labels.newTab }), _jsx(TabsTab, { value: "tickets", children: labels.ticketsTab })] }) })), actions] }), children: !showSent ? (_jsx(FeedbackForm, { ...formProps, errorDetail: errorDetail, onClose: close })) : openItemId === null ? (_jsx(FeedbackList, { items: sent.items, rows: (items) => items.map((item) => ({
400
383
  id: item.id,
401
384
  subject: item.subject,
402
385
  status: item.status,
@@ -424,63 +407,6 @@ function FeedbackList({ items, rows, empty, toolbar, errorDetail, onOpen, }) {
424
407
  return (_jsx("li", { children: _jsxs("button", { type: "button", className: sentRow, "data-needs-reply": needsReply ? "" : undefined, onClick: () => onOpen(row.id), children: [_jsxs("span", { className: sentRowCopy, children: [_jsxs("span", { className: sentRowSubject, children: [needsReply && _jsx("span", { className: needsReplyDot, "aria-hidden": "true" }), _jsx("span", { children: row.subject })] }), _jsx("span", { className: sentRowMeta, children: row.meta })] }), _jsx(Status, { variant: display.variant, children: display.label })] }) }, row.id));
425
408
  }) }))] }));
426
409
  }
427
- /** Everyone's feedback, latest change first, narrowed by status, type and a search. */
428
- function OperatorList({ operator, ownIds, errorDetail, onOpen, }) {
429
- const labels = useFeedbackLabels();
430
- const operatorLabels = useCiridaeLocale().labels.feedbackOperator;
431
- const [filters, setFilters] = useState([]);
432
- const [search, setSearch] = useState("");
433
- const query = search.trim().toLowerCase();
434
- const fields = [
435
- ...(ownIds
436
- ? [
437
- {
438
- key: "reporter",
439
- label: operatorLabels.reporter,
440
- kind: "multi",
441
- options: [{ value: "mine", label: operatorLabels.mine }],
442
- },
443
- ]
444
- : []),
445
- {
446
- key: "status",
447
- label: operatorLabels.status,
448
- kind: "multi",
449
- options: feedbackStatusSchema.options.map((value) => ({
450
- value,
451
- label: statusDisplay(value, labels).label,
452
- })),
453
- },
454
- {
455
- key: "type",
456
- label: operatorLabels.type,
457
- kind: "multi",
458
- options: feedbackTypeSchema.options.map((value) => ({
459
- value,
460
- label: typeLabel(value, labels),
461
- })),
462
- },
463
- ];
464
- return (_jsx(FeedbackList, { items: operator.items, rows: (items) => items
465
- .filter((item) => filters.every((filter) => matchesFilter(filter.field === "reporter"
466
- ? ownIds?.has(item.id)
467
- ? "mine"
468
- : "others"
469
- : filter.field === "status"
470
- ? item.status
471
- : item.type, filter)) &&
472
- (query === "" ||
473
- [item.subject, item.description, item.reporterEmail].some((value) => value?.toLowerCase().includes(query))))
474
- // ISO timestamps in one format sort as text.
475
- .sort((left, right) => right.updatedAt.localeCompare(left.updatedAt))
476
- .map((item) => ({
477
- id: item.id,
478
- subject: item.subject,
479
- status: item.status,
480
- meta: (_jsxs(_Fragment, { children: [item.reporterEmail ?? operatorLabels.reporter, " \u00B7 ", typeLabel(item.type, labels), " \u00B7", " ", _jsx(DateTime, { value: item.updatedAt })] })),
481
- })), empty: filters.length > 0 || query !== "" ? operatorLabels.noMatches : operatorLabels.noneReceived, toolbar: _jsx(FilterBar, { className: listToolbar, fields: fields, value: filters, onValueChange: setFilters, children: _jsx(SearchInput, { variant: "ghost", "aria-label": operatorLabels.search, placeholder: operatorLabels.search, value: search, onValueCommit: setSearch }) }), errorDetail: errorDetail, onOpen: onOpen }));
482
- }
483
- /* What the thread shows in time order: the description, each status change, each message. */
484
410
  function listThreadEntries(item, labels) {
485
411
  const entries = [
486
412
  {
@@ -511,35 +437,6 @@ function listThreadEntries(item, labels) {
511
437
  ];
512
438
  return entries.sort((earlier, later) => earlier.at - later.at);
513
439
  }
514
- /**
515
- * The operator's side of the same thread: the reporter's description and messages across from
516
- * them, their own team's replies on their side.
517
- */
518
- function listOperatorThreadEntries(item, reporter) {
519
- const entries = [
520
- {
521
- kind: "message",
522
- id: "description",
523
- side: "assistant",
524
- author: { name: reporter },
525
- at: Date.parse(item.createdAt),
526
- body: item.description,
527
- attachments: item.attachments,
528
- },
529
- ...item.messages.map((message) => {
530
- const fromReporter = message.author.role === "reporter";
531
- return {
532
- kind: "message",
533
- id: message.id,
534
- side: fromReporter ? "assistant" : "user",
535
- author: fromReporter ? { name: message.author.name } : undefined,
536
- at: message.createdAt_epoch_milliseconds,
537
- body: message.body,
538
- };
539
- }),
540
- ];
541
- return entries.sort((earlier, later) => earlier.at - later.at);
542
- }
543
440
  /** Runs `action`, reporting it pending, then idle, or failed with its error. */
544
441
  function usePendingAction(action) {
545
442
  const [state, setState] = useState({ status: "idle" });
@@ -619,37 +516,3 @@ function SentItem({ feedbackId, item, errorDetail, onReply, onWithdraw, onBack,
619
516
  canReply: loaded.canReply,
620
517
  }, headerEnd: _jsxs(_Fragment, { children: [display && (_jsx(Status, { className: itemStatus, variant: display.variant, children: display.label })), _jsx(Menu, { align: "end", items: actions, trigger: _jsx(IconButton, { "aria-label": labels.actions, variant: "ghost", size: "small", disabled: withdraw.state.status === "pending", children: withdraw.state.status === "pending" ? (_jsx(Spinner, { label: labels.withdrawing })) : (_jsx(DotsThreeIcon, { className: icon({ size: "small" }) })) }) })] }), notices: withdraw.state.status === "failed" && (_jsx(FailedNotice, { title: labels.withdrawFailed, children: errorDetail?.(withdraw.state.error) })), replyDisabled: withdraw.state.status === "pending", errorDetail: errorDetail, onReply: onReply, onBack: onBack }));
621
518
  }
622
- /** An item as its operator sees it: the reporter's thread, a status to set, and a reply. */
623
- function OperatorItem({ feedbackId, operator, errorDetail, onBack, }) {
624
- const labels = useFeedbackLabels();
625
- const operatorLabels = useCiridaeLocale().labels.feedbackOperator;
626
- const [pendingStatus, setPendingStatus] = useState(null);
627
- const statusChange = usePendingAction(async (status) => {
628
- setPendingStatus(status);
629
- try {
630
- await operator.onStatusChange(feedbackId, status);
631
- }
632
- finally {
633
- setPendingStatus(null);
634
- }
635
- });
636
- const { item } = operator;
637
- const loaded = item?.status === "loaded" && item.data.id === feedbackId ? item.data : null;
638
- const status = pendingStatus ?? loaded?.status;
639
- const reporter = loaded?.reporterEmail ?? operatorLabels.reporter;
640
- const statusOptions = [
641
- // A withdrawn item is the reporter's call; it shows, but cannot be chosen.
642
- ...(status === "withdrawn" ? ["withdrawn"] : []),
643
- ...feedbackTriageStatusSchema.options,
644
- ].map((value) => ({ value, label: statusDisplay(value, labels).label }));
645
- return (_jsx(FeedbackThreadItem, { feedbackId: feedbackId, item: item, loaded: loaded && {
646
- subject: loaded.subject,
647
- meta: (_jsxs(_Fragment, { children: [reporter, " \u00B7 ", typeLabel(loaded.type, labels), " \u00B7 ", _jsx(DateTime, { value: loaded.createdAt })] })),
648
- entries: listOperatorThreadEntries(loaded, reporter),
649
- canReply: loaded.canReply,
650
- }, headerEnd: _jsx(Select, { label: operatorLabels.status, options: statusOptions, value: status, disabled: status === "withdrawn" || statusChange.state.status === "pending", onValueChange: (value) => {
651
- const next = feedbackTriageStatusSchema.safeParse(value);
652
- if (next.success && next.data !== status)
653
- statusChange.run(next.data);
654
- } }), notices: statusChange.state.status === "failed" && (_jsx(FailedNotice, { title: operatorLabels.statusFailed, children: errorDetail?.(statusChange.state.error) })), errorDetail: errorDetail, onReply: operator.onReply, onBack: onBack }));
655
- }
@@ -1,6 +1,5 @@
1
- import { type CustomHotkeys } from "@tanstack/react-hotkeys";
2
1
  import { type ReactNode } from "react";
3
- export { defineAppHotkeys, detectPlatform, formatForDisplay, HotkeysProvider, useAppHotkeyList, useAppHotkeys, useCustomHotkeys, useHotkey, useHotkeyHint, useHotkeyRecorder, useHotkeyRegistrations, useHotkeys, useKeyHold, } from "@tanstack/react-hotkeys";
2
+ export { detectPlatform, formatForDisplay, HotkeysProvider, useHotkey, useHotkeyRegistrations, useHotkeys, } from "@tanstack/react-hotkeys";
4
3
  export type { AppHotkey, CustomHotkeys, Hotkey, HotkeyChord, HotkeyMeta, RegisterableHotkey, UseHotkeyDefinition, } from "@tanstack/react-hotkeys";
5
4
  /** The scope of the hotkeys registered inside `AppShell`. */
6
5
  export declare const PAGE_HOTKEY_SCOPE = "page";
@@ -16,12 +15,3 @@ export declare function HotkeyLayer({ enabled, children }: {
16
15
  enabled?: boolean;
17
16
  children: ReactNode;
18
17
  }): import("react").JSX.Element;
19
- /**
20
- * The person's rebound hotkeys, kept in `localStorage` as JSON under `storageKey`, as the root
21
- * `HotkeysProvider`'s `customHotkeys` and `onCustomHotkeysChange`. Entries that are no hotkey are
22
- * dropped with a warning.
23
- */
24
- export declare function storedCustomHotkeys(storageKey: string): {
25
- customHotkeys: CustomHotkeys;
26
- onCustomHotkeysChange: (customHotkeys: CustomHotkeys) => void;
27
- };
@@ -8,15 +8,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
8
8
  * - inside an overlay (dialog, drawer, popover, menu, select, command menu) it fires only while
9
9
  * that overlay is the top one, since each overlay is a `HotkeyLayer`.
10
10
  * Single keys and Shift combos skip text fields and ARIA widgets; Mod combos and Escape fire
11
- * there too. `Mod` is Cmd on a Mac and Ctrl elsewhere. An app declares the hotkeys a person may
12
- * rebind with `defineAppHotkeys`, passes them to a root `HotkeysProvider` with the saved
13
- * `customHotkeys`, and registers each with `useHotkey(useAppHotkeys()[id], ...)`;
14
- * `KeyboardShortcutSettings` lists and records them.
11
+ * there too. `Mod` is Cmd on a Mac and Ctrl elsewhere.
15
12
  */
16
- import { HotkeysProvider, normalizeHotkey, validateHotkey, } from "@tanstack/react-hotkeys";
13
+ import { HotkeysProvider } from "@tanstack/react-hotkeys";
17
14
  import { useId } from "react";
18
- import { z } from "zod";
19
- export { defineAppHotkeys, detectPlatform, formatForDisplay, HotkeysProvider, useAppHotkeyList, useAppHotkeys, useCustomHotkeys, useHotkey, useHotkeyHint, useHotkeyRecorder, useHotkeyRegistrations, useHotkeys, useKeyHold, } from "@tanstack/react-hotkeys";
15
+ export { detectPlatform, formatForDisplay, HotkeysProvider, useHotkey, useHotkeyRegistrations, useHotkeys, } from "@tanstack/react-hotkeys";
20
16
  /** The scope of the hotkeys registered inside `AppShell`. */
21
17
  export const PAGE_HOTKEY_SCOPE = "page";
22
18
  /** Gives the hotkeys registered inside it to the page, paused while an overlay is open. */
@@ -31,40 +27,3 @@ export function HotkeyLayer({ enabled, children }) {
31
27
  const scope = `layer${useId()}`;
32
28
  return (_jsx(HotkeysProvider, { scope: scope, exclusive: { allow: ["global"] }, enabled: enabled, children: children }));
33
29
  }
34
- const storedCustomHotkeysSchema = z.record(z.string(), z.union([z.string(), z.array(z.string()), z.null()]));
35
- /**
36
- * The person's rebound hotkeys, kept in `localStorage` as JSON under `storageKey`, as the root
37
- * `HotkeysProvider`'s `customHotkeys` and `onCustomHotkeysChange`. Entries that are no hotkey are
38
- * dropped with a warning.
39
- */
40
- export function storedCustomHotkeys(storageKey) {
41
- const customHotkeys = {};
42
- try {
43
- const text = globalThis.localStorage?.getItem(storageKey);
44
- const stored = storedCustomHotkeysSchema.safeParse(text ? JSON.parse(text) : {});
45
- if (!stored.success)
46
- console.warn(`Ignoring saved hotkeys under ${storageKey}`, stored.error);
47
- for (const [id, hotkey] of Object.entries(stored.data ?? {})) {
48
- if (hotkey === null)
49
- customHotkeys[id] = null;
50
- else if (validateHotkey(hotkey).valid)
51
- customHotkeys[id] = normalizeHotkey(hotkey);
52
- else
53
- console.warn(`Ignoring saved hotkey ${id} under ${storageKey}`, hotkey);
54
- }
55
- }
56
- catch (error) {
57
- console.warn(`Ignoring unreadable saved hotkeys under ${storageKey}`, error);
58
- }
59
- return {
60
- customHotkeys,
61
- onCustomHotkeysChange: (next) => {
62
- try {
63
- globalThis.localStorage?.setItem(storageKey, JSON.stringify(next));
64
- }
65
- catch (error) {
66
- console.warn(`Could not save hotkeys under ${storageKey}`, error);
67
- }
68
- },
69
- };
70
- }
@@ -6,5 +6,3 @@ export type KeyboardShortcutsProps = {
6
6
  onOpenChange?: (open: boolean) => void;
7
7
  };
8
8
  export declare function KeyboardShortcuts({ hotkey, open: ownOpen, onOpenChange, }: KeyboardShortcutsProps): import("react").JSX.Element;
9
- /** The app's rebindable hotkeys under their groups, each with Change and, once changed, Reset. */
10
- export declare function KeyboardShortcutSettings(): import("react").JSX.Element[];