@coffre/ui 0.10.0 → 0.10.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.
- package/dist/chunks/{audit-sentence-Bjhg00cn.js → audit-sentence-DpYySuqg.js} +2 -2
- package/dist/chunks/{audit-sentence-Bjhg00cn.js.map → audit-sentence-DpYySuqg.js.map} +1 -1
- package/dist/chunks/{connected-apps-CZI7xxUq.js → connected-apps-D48SFJsG.js} +4 -4
- package/dist/chunks/{connected-apps-CZI7xxUq.js.map → connected-apps-D48SFJsG.js.map} +1 -1
- package/dist/chunks/{delete-place-D3UQGl3b.js → delete-place-Cg_M6rAq.js} +4 -4
- package/dist/chunks/{delete-place-D3UQGl3b.js.map → delete-place-Cg_M6rAq.js.map} +1 -1
- package/dist/chunks/{directory-CyHmxYP-.js → directory-_LTgdiIM.js} +8 -8
- package/dist/chunks/{directory-CyHmxYP-.js.map → directory-_LTgdiIM.js.map} +1 -1
- package/dist/chunks/{folders-Dw240WMJ.js → folders-D3A1NGpt.js} +2 -2
- package/dist/chunks/{folders-Dw240WMJ.js.map → folders-D3A1NGpt.js.map} +1 -1
- package/dist/chunks/{grants-CEIdNqJU.js → grants-CNM913EY.js} +5 -5
- package/dist/chunks/{grants-CEIdNqJU.js.map → grants-CNM913EY.js.map} +1 -1
- package/dist/chunks/{multi-combobox-CsIXihuc.js → multi-combobox-B0JzP1QN.js} +2 -2
- package/dist/chunks/{multi-combobox-CsIXihuc.js.map → multi-combobox-B0JzP1QN.js.map} +1 -1
- package/dist/chunks/{offboarding-CvGgTmHi.js → offboarding-BeaNM3sf.js} +3 -3
- package/dist/chunks/{offboarding-CvGgTmHi.js.map → offboarding-BeaNM3sf.js.map} +1 -1
- package/dist/chunks/{personal-tokens-BX97oX4a.js → personal-tokens-KsXajpx4.js} +4 -4
- package/dist/chunks/{personal-tokens-BX97oX4a.js.map → personal-tokens-KsXajpx4.js.map} +1 -1
- package/dist/chunks/{principal-page-Bp2O8kIW.js → principal-page-BaiZXh6D.js} +13 -13
- package/dist/chunks/{principal-page-Bp2O8kIW.js.map → principal-page-BaiZXh6D.js.map} +1 -1
- package/dist/chunks/{project-page-CUXV4FDR.js → project-page-CYZ_MkfX.js} +2 -2
- package/dist/chunks/{project-page-CUXV4FDR.js.map → project-page-CYZ_MkfX.js.map} +1 -1
- package/dist/chunks/{protected-YYW3U-Sq.js → protected-BL_DsZO6.js} +2 -2
- package/dist/chunks/{protected-YYW3U-Sq.js.map → protected-BL_DsZO6.js.map} +1 -1
- package/dist/chunks/{queries-DEOPOpsT.js → queries-Danu0o75.js} +73 -29
- package/dist/chunks/queries-Danu0o75.js.map +1 -0
- package/dist/chunks/{references-DsXkt064.js → references-BK2aPXae.js} +4 -4
- package/dist/chunks/{references-DsXkt064.js.map → references-BK2aPXae.js.map} +1 -1
- package/dist/chunks/{role-field-CCUeZd1a.js → role-field-DIJiRz9B.js} +3 -3
- package/dist/chunks/{role-field-CCUeZd1a.js.map → role-field-DIJiRz9B.js.map} +1 -1
- package/dist/chunks/{row-state-BsIHspy4.js → row-state-xtRGFnDc.js} +2 -2
- package/dist/chunks/{row-state-BsIHspy4.js.map → row-state-xtRGFnDc.js.map} +1 -1
- package/dist/chunks/{theme-3b4DnCow.js → theme-Ck45wzWB.js} +2 -2
- package/dist/chunks/{theme-3b4DnCow.js.map → theme-Ck45wzWB.js.map} +1 -1
- package/dist/chunks/{ui-2kwXXfrX.js → ui-D-blFWfx.js} +29 -5
- package/dist/chunks/{ui-2kwXXfrX.js.map → ui-D-blFWfx.js.map} +1 -1
- package/dist/chunks/{use-action-COW-XFw8.js → use-action-BafZVwux.js} +2 -2
- package/dist/chunks/{use-action-COW-XFw8.js.map → use-action-BafZVwux.js.map} +1 -1
- package/dist/chunks/{use-change-hfqE7baE.js → use-change-DhV6i_Ge.js} +3 -3
- package/dist/chunks/{use-change-hfqE7baE.js.map → use-change-DhV6i_Ge.js.map} +1 -1
- package/dist/chunks/{use-roles-C_Tj5wBH.js → use-roles-Daje0ikO.js} +2 -2
- package/dist/chunks/{use-roles-C_Tj5wBH.js.map → use-roles-Daje0ikO.js.map} +1 -1
- package/dist/chunks/{use-shell-DBLG80kk.js → use-shell-BX9mzfaL.js} +2 -2
- package/dist/chunks/{use-shell-DBLG80kk.js.map → use-shell-BX9mzfaL.js.map} +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/pages/account.js +9 -9
- package/dist/pages/approval.js +1 -1
- package/dist/pages/audit.js +96 -34
- package/dist/pages/audit.js.map +1 -1
- package/dist/pages/device-login.js +1 -1
- package/dist/pages/environment.js +10 -10
- package/dist/pages/login.js +2 -2
- package/dist/pages/oauth-authorize.js +1 -1
- package/dist/pages/project-access.js +9 -9
- package/dist/pages/project-environments.js +11 -11
- package/dist/pages/project-settings.js +7 -7
- package/dist/pages/project.js +2 -2
- package/dist/pages/projects.js +7 -7
- package/dist/pages/service-account.js +9 -9
- package/dist/pages/service-accounts.js +4 -4
- package/dist/pages/settings.js +6 -6
- package/dist/pages/unregistered.js +1 -1
- package/dist/pages/user.js +5 -5
- package/dist/pages/users.js +4 -4
- package/package.json +3 -3
- package/src/components/ui.tsx +25 -2
- package/src/lib/queries.ts +81 -29
- package/src/options.ts +2 -3
- package/src/pages/audit.tsx +99 -26
- package/src/parity.ts +1 -1
- package/dist/chunks/queries-DEOPOpsT.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-2kwXXfrX.js","names":[],"sources":["../../src/lib/preferences.tsx","../../src/lib/clipboard.ts","../../src/lib/copy-attempts.ts","../../src/components/ui.tsx"],"sourcesContent":["import { createContext, useContext, type RefObject } from 'react';\n\nimport { PREFERENCE_COOKIES, preferencesIn, type Preferences } from '@coffre/core/pages';\n\nexport type { Preferences };\n\nexport type Theme = Preferences['theme'];\n\n/**\n * The preferences in the browser's cookies, as the server read them in the\n * request's: each is a cookie, so the server renders the page as the\n * visitor left it, from the first byte, and the browser hydrates the same.\n */\nexport function browserPreferences(): Preferences {\n return preferencesIn(document.cookie);\n}\n\n/** Keep a choice for a year; the default, by removing it. */\nfunction remember(name: string, value: string | null) {\n document.cookie =\n value === null ? `${name}=; Path=/; SameSite=Lax; Max-Age=0` : `${name}=${value}; Path=/; SameSite=Lax; Max-Age=31536000`;\n}\n\nexport function rememberTheme(theme: Theme) {\n remember(PREFERENCE_COOKIES.theme, theme === 'system' ? null : theme);\n}\n\nexport function rememberSidebar(sidebar: Preferences['sidebar']) {\n remember(PREFERENCE_COOKIES.sidebar, sidebar === 'collapsed' ? 'collapsed' : null);\n}\n\ntype PreferencesValue = Preferences & {\n setTheme(theme: Theme): void;\n setSidebar(sidebar: Preferences['sidebar']): void;\n /** coffre's element, which menus, dialogs and tooltips render into, so they are drawn in its theme. */\n portal: RefObject<HTMLDivElement | null>;\n};\n\nexport const PreferencesContext = createContext<PreferencesValue | null>(null);\n\n/** The visitor's preferences, and the switches, from `<CoffreProvider>`. */\nexport function usePreferences(): PreferencesValue {\n const value = useContext(PreferencesContext);\n if (value === null) throw new Error(\"coffre's pages render inside <CoffreProvider>, in the app's root document\");\n return value;\n}\n","/**\n * Writing to the clipboard, from text that may still be on its way.\n *\n * A browser lets a page write to the clipboard only inside a click's user\n * gesture, and Safari drops the gesture across an `await`. So a value that has\n * to be fetched first (Copy on a hidden secret) is handed over as a promise:\n * `clipboard.write` is called at once, with the promise inside a\n * `ClipboardItem`, and the browser waits for it. Where that is not supported,\n * the text is awaited, then written with `writeText`, which is what every\n * browser but Safari allows.\n *\n * The text goes through byte for byte: no trimming, no newline changes.\n */\n\n/** What of the clipboard `copyText` uses; the browser's `navigator.clipboard` fits. */\nexport type ClipboardLike = {\n writeText(text: string): Promise<void>;\n write?(items: unknown[]): Promise<void>;\n};\n\ntype ClipboardItemConstructor = new (items: Record<string, Promise<string>>) => unknown;\n\nexport async function copyText(\n text: string | Promise<string>,\n {\n clipboard = globalThis.navigator?.clipboard as ClipboardLike | undefined,\n item = (globalThis as { ClipboardItem?: ClipboardItemConstructor }).ClipboardItem,\n }: { clipboard?: ClipboardLike; item?: ClipboardItemConstructor } = {},\n): Promise<void> {\n // A read that fails after the copy has ended is nobody's to hear: not an unhandled rejection.\n if (typeof text !== 'string') text.catch(() => {});\n if (clipboard === undefined) throw new Error('The clipboard is not available here.');\n if (typeof text !== 'string' && item !== undefined && clipboard.write !== undefined) {\n // Called before anything is awaited: this is what keeps the user gesture.\n // The text goes in as a string, not a Blob: decoding a Blob drops a leading U+FEFF.\n await clipboard.write([new item({ 'text/plain': text })]);\n return;\n }\n await clipboard.writeText(await text);\n}\n","import { copyText } from './clipboard.ts';\n\n/**\n * How a copy ended, as far as anyone still cares.\n *\n * `superseded`: a newer copy began before this one ended, so this one reports\n * nothing and writes nothing. Its result, good or bad, is not what the person\n * asked for last.\n */\nexport type CopyResult = { outcome: 'copied' } | { outcome: 'failed'; failure: unknown } | { outcome: 'superseded' };\n\n/** What a copy button shows: a copy under way, or how the last one ended, for a moment. */\nexport type CopyFeedback = 'idle' | 'pending' | 'copied' | 'failed';\n\n/**\n * Copies where the latest one wins, and what they look like while they run.\n *\n * The clipboard is one resource per page, so \"latest\" is decided per page: every\n * copy, from any row, takes a number from one counter before it awaits anything,\n * and only the newest reports, shows feedback, or writes. A copy may start while\n * an earlier one is still reading or waiting on the clipboard: a retry after a\n * refusal, a click on another row, a row filtered out and back, a button replaced\n * by a remount. When a copy from another copier takes over, the older one drops\n * its pending or \"Copied\" feedback and goes back to idle. A copier belongs to\n * whoever outlives the button (a row); the button only subscribes to it, so a\n * remount picks up where it was.\n */\nexport type Copier = {\n run(text: string | Promise<string>): Promise<CopyResult>;\n feedback(): CopyFeedback;\n subscribe(listener: () => void): () => void;\n};\n\nconst SUPERSEDED = new Error('A newer copy began.');\n\n/** The page's newest copy, and the copier that made it. */\nlet latest = 0;\nlet owner: { drop(): void } | null = null;\n\nexport function createCopier({\n copy = copyText,\n copiedMs = 1400,\n failedMs = 3000,\n}: { copy?: typeof copyText; copiedMs?: number; failedMs?: number } = {}): Copier {\n let feedback: CopyFeedback = 'idle';\n let timer: ReturnType<typeof setTimeout> | null = null;\n const listeners = new Set<() => void>();\n\n function show(next: CopyFeedback) {\n if (feedback === next) return;\n feedback = next;\n for (const listener of listeners) listener();\n }\n\n function stopTimer() {\n if (timer !== null) clearTimeout(timer);\n timer = null;\n }\n\n const self = {\n /** Another copier's copy took over: nothing of this one's is left showing. */\n drop() {\n stopTimer();\n show('idle');\n },\n };\n\n return {\n feedback: () => feedback,\n subscribe(listener) {\n listeners.add(listener);\n return () => void listeners.delete(listener);\n },\n async run(text) {\n const attempt = ++latest;\n if (owner !== null && owner !== self) owner.drop();\n owner = self;\n stopTimer();\n show('pending');\n // A read that finishes after a newer copy began, anywhere on the page, is\n // refused here, so it never reaches the clipboard: the fallback does not\n // write it, and a ClipboardItem whose payload rejects writes nothing.\n const gated =\n typeof text === 'string'\n ? text\n : text.then((value) => {\n if (attempt !== latest) throw SUPERSEDED;\n return value;\n });\n let result: CopyResult = { outcome: 'copied' };\n try {\n // Called before anything is awaited: the click's gesture is still live.\n await copy(gated);\n } catch (failure) {\n result = { outcome: 'failed', failure };\n }\n if (attempt !== latest) return { outcome: 'superseded' };\n show(result.outcome === 'copied' ? 'copied' : 'failed');\n timer = setTimeout(() => show('idle'), result.outcome === 'copied' ? copiedMs : failedMs);\n return result;\n },\n };\n}\n","import { useEffect, useRef, useState, useSyncExternalStore, type ReactElement, type ReactNode } from 'react';\nimport { AlertDialog } from '@base-ui/react/alert-dialog';\nimport { Dialog } from '@base-ui/react/dialog';\nimport { Menu } from '@base-ui/react/menu';\nimport { Popover } from '@base-ui/react/popover';\nimport { Tooltip } from '@base-ui/react/tooltip';\nimport { AlertCircle, AlertTriangle, Check, Copy, Info, Loader, X } from './icons';\nimport { createCopier, type Copier } from '../lib/copy-attempts';\nimport { usePreferences } from '../lib/preferences';\n\n/* -------------------------------------------------------------------------- */\n/* Tooltip */\n/* -------------------------------------------------------------------------- */\n\nexport function TooltipProvider({ children }: { children: ReactNode }) {\n // 400ms before the first tip; afterwards adjacent tips open instantly, which\n // makes a row of controls feel immediate without the delay losing its\n // purpose (preventing accidental activation on a passing cursor).\n return (\n <Tooltip.Provider delay={400} timeout={300}>\n {children}\n </Tooltip.Provider>\n );\n}\n\nexport function Tip({\n label,\n side,\n children,\n}: {\n label: ReactNode;\n side?: 'top' | 'right' | 'bottom' | 'left';\n children: ReactElement;\n}) {\n const { portal } = usePreferences();\n return (\n <Tooltip.Root>\n <Tooltip.Trigger render={children} />\n <Tooltip.Portal container={portal}>\n <Tooltip.Positioner\n className=\"tooltip-positioner\"\n side={side}\n sideOffset={6}\n collisionPadding={8}\n >\n <Tooltip.Popup className=\"tooltip\">{label}</Tooltip.Popup>\n </Tooltip.Positioner>\n </Tooltip.Portal>\n </Tooltip.Root>\n );\n}\n\n/**\n * The same bubble as Tip, for a note a touch screen must reach too.\n *\n * A tooltip opens on hover and focus only, so on a phone it never opens. This\n * one also opens on a tap, which means its trigger has to be a real button.\n * With a mouse, hover alone drives it: a click would otherwise close the note\n * the hover just opened.\n */\nexport function Toggletip({\n label,\n side,\n align,\n children,\n}: {\n label: ReactNode;\n side?: 'top' | 'right' | 'bottom' | 'left';\n /** `end` for a trigger at the right edge, so the tip opens leftwards. */\n align?: 'start' | 'center' | 'end';\n children: ReactElement;\n}) {\n const { portal } = usePreferences();\n const [open, setOpen] = useState(false);\n const mouse = useRef(false);\n const hover = (next: boolean) => (event: { pointerType: string }) => {\n if (event.pointerType === 'mouse') setOpen(next);\n };\n\n return (\n <Popover.Root\n open={open}\n onOpenChange={(next, { reason }) => {\n const clicked = reason === 'trigger-press' && mouse.current;\n mouse.current = false;\n if (!clicked) setOpen(next);\n }}\n >\n <Popover.Trigger\n render={children}\n onPointerEnter={hover(true)}\n onPointerLeave={hover(false)}\n onPointerDown={(event) => {\n mouse.current = event.pointerType === 'mouse';\n }}\n />\n <Popover.Portal container={portal}>\n <Popover.Positioner\n className=\"tooltip-positioner\"\n side={side}\n align={align}\n sideOffset={6}\n collisionPadding={16}\n >\n {/* Focus stays on the trigger, so there is nothing to return it to. */}\n <Popover.Popup className=\"tooltip\" initialFocus={false} finalFocus={false}>\n {label}\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Menu */\n/* -------------------------------------------------------------------------- */\n\n/**\n * A menu's floating panel, placed against its `Menu.Trigger`.\n *\n * The callers keep the rest of Base UI's menu parts: the trigger, the items\n * and their separators read better at the call site than behind props.\n */\nexport function MenuPopup({\n side,\n align,\n className,\n children,\n}: {\n side?: 'top' | 'bottom';\n align: 'start' | 'end';\n className?: string;\n children: ReactNode;\n}) {\n const { portal } = usePreferences();\n return (\n <Menu.Portal container={portal}>\n <Menu.Positioner className=\"menu-positioner\" side={side} align={align} sideOffset={6}>\n <Menu.Popup className={className === undefined ? 'menu' : `menu ${className}`}>\n {children}\n </Menu.Popup>\n </Menu.Positioner>\n </Menu.Portal>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Feedback primitives */\n/* -------------------------------------------------------------------------- */\n\nexport function Spinner({ size = 14 }: { size?: number }) {\n return <Loader size={size} className=\"spinner\" />;\n}\n\nexport function ErrorLine({ error }: { error: string | null }) {\n if (error === null) return null;\n return (\n <p className=\"error-line\" role=\"alert\">\n <AlertCircle size={14} />\n <span>{error}</span>\n </p>\n );\n}\n\nconst NOTICE_ICON = {\n info: Info,\n good: Check,\n bad: AlertTriangle,\n warn: AlertTriangle,\n neutral: Info,\n} as const;\n\nexport function Notice({\n tone = 'neutral',\n children,\n}: {\n tone?: keyof typeof NOTICE_ICON;\n children: ReactNode;\n}) {\n const Icon = NOTICE_ICON[tone];\n return (\n <div\n className={`notice${tone === 'neutral' ? '' : ` notice-${tone}`}`}\n role={tone === 'bad' ? 'alert' : undefined}\n >\n <Icon size={16} />\n <div>{children}</div>\n </div>\n );\n}\n\n/**\n * Nothing here yet, said in a sentence.\n *\n * It sits where the table would have been, left-aligned like the rows it\n * stands in for, rather than as a centred illustration.\n */\nexport function EmptyState({\n title,\n children,\n actions,\n}: {\n title: string;\n children?: ReactNode;\n actions?: ReactNode;\n}) {\n return (\n <div className=\"empty\">\n <p className=\"empty-title\">{title}</p>\n {children !== undefined && <p className=\"empty-body\">{children}</p>}\n {actions !== undefined && <div className=\"empty-actions\">{actions}</div>}\n </div>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Text */\n/* -------------------------------------------------------------------------- */\n\n/**\n * An identifier that wraps after its underscores rather than mid-word.\n *\n * To the line breaker `DOCUSIGN_INTEGRATION_KEY` is one word, so a narrow\n * column cuts it wherever room runs out (`…_KE` / `Y`). A <wbr> after each\n * underscore offers the natural places instead. Copied text is unchanged, and\n * `overflow-wrap: anywhere` still catches a segment too long for any line.\n */\nexport function breakAfterUnderscores(text: string): ReactNode {\n return text\n .split('_')\n .flatMap((part, index) => (index === 0 ? [part] : ['_', <wbr key={index} />, part]));\n}\n\n/* -------------------------------------------------------------------------- */\n/* Copy */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Copy to clipboard with a settled confirmation.\n *\n * The glyph turns into a check, and screen readers hear \"Copied\", for 1.4s --\n * long enough to be noticed after the eye has moved on, short enough not to\n * look stuck. A copy that fails says so the same way, in red, rather than\n * leaving the click looking ignored.\n *\n * `value` is the text. A caller that must read it first (Copy on a hidden\n * secret) passes the `copier` it owns instead, and `onCopy`, called inside the\n * click so the clipboard write keeps its user gesture, which starts a copy on\n * that copier. Copies do not lock the button: a click while one is out starts\n * the next, and the latest one's ending is the one that shows. The copier's\n * owner outlives the button, so a remount keeps the feedback of a copy in flight.\n */\nexport function CopyButton({\n label = 'Copy',\n variant = 'icon',\n ...source\n}: {\n label?: string;\n /** `act` sits among a table row's actions; `icon` anywhere else. */\n variant?: 'icon' | 'act';\n} & ({ value: string; copier?: undefined; onCopy?: undefined } | { value?: undefined; copier: Copier; onCopy: () => void })) {\n const [own] = useState(() => createCopier());\n const copier = source.copier ?? own;\n const state = useSyncExternalStore(copier.subscribe, copier.feedback, copier.feedback);\n\n function copy() {\n if (source.copier !== undefined) source.onCopy();\n else void own.run(source.value);\n }\n\n const text = state === 'copied' ? 'Copied' : state === 'failed' ? 'Copy failed' : label;\n return (\n <Tip label={text}>\n <button\n type=\"button\"\n className={variant === 'act' ? 'act act-icon' : 'btn btn-quiet btn-sm btn-icon'}\n aria-label={label}\n aria-busy={state === 'pending'}\n onClick={copy}\n >\n {state === 'pending' ? (\n <Spinner size={13} />\n ) : state === 'copied' ? (\n <Check size={14} className=\"copied\" />\n ) : state === 'failed' ? (\n <AlertCircle size={14} className=\"copy-failed\" />\n ) : (\n <Copy size={14} />\n )}\n <span className=\"visually-hidden\" aria-live=\"polite\">\n {state === 'copied' ? 'Copied' : state === 'failed' ? 'Copy failed' : ''}\n </span>\n </button>\n </Tip>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Confirmation */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Confirmation for actions with reach.\n *\n * Reserved for changes that affect other people or other screens (archiving a\n * project, revoking a grant). Restoring one secret is reversible and gets an\n * undo toast instead -- a dialog on every action trains people to dismiss them.\n */\ntype ConfirmProps = {\n title: ReactNode;\n body: ReactNode;\n /** What the body's sentence cannot hold, such as a list: after it, outside its paragraph. */\n detail?: ReactNode;\n confirmLabel: string;\n destructive?: boolean;\n /** While something must happen first, which `detail` says. */\n confirmDisabled?: boolean;\n onConfirm: () => void;\n};\n\nfunction ConfirmContent({ title, body, detail, confirmLabel, destructive, confirmDisabled, onConfirm }: ConfirmProps) {\n const { portal } = usePreferences();\n return (\n <AlertDialog.Portal container={portal}>\n <AlertDialog.Backdrop className=\"overlay\" />\n <AlertDialog.Popup className=\"dialog dialog-confirm\">\n <AlertDialog.Title className=\"dialog-title\">{title}</AlertDialog.Title>\n <AlertDialog.Description className=\"dialog-body\">{body}</AlertDialog.Description>\n {detail}\n <div className=\"dialog-actions\">\n <AlertDialog.Close className=\"btn\">Cancel</AlertDialog.Close>\n <AlertDialog.Close\n className={`btn ${destructive === false ? 'btn-primary' : 'btn-danger'}`}\n onClick={onConfirm}\n disabled={confirmDisabled}\n >\n {confirmLabel}\n </AlertDialog.Close>\n </div>\n </AlertDialog.Popup>\n </AlertDialog.Portal>\n );\n}\n\nexport function ConfirmButton({\n trigger,\n disabled,\n ...confirm\n}: ConfirmProps & { trigger: ReactElement; disabled?: boolean }) {\n return (\n <AlertDialog.Root>\n <AlertDialog.Trigger render={trigger} disabled={disabled} />\n <ConfirmContent {...confirm} />\n </AlertDialog.Root>\n );\n}\n\n/**\n * The same confirmation, opened from something that is not a trigger.\n *\n * A menu item cannot be one: it unmounts as the menu closes, taking the dialog\n * with it. So the caller keeps the open state and the dialog lives outside the\n * menu entirely.\n */\nexport function ConfirmDialog({\n open,\n onOpenChange,\n ...confirm\n}: ConfirmProps & { open: boolean; onOpenChange: (open: boolean) => void }) {\n return (\n <AlertDialog.Root open={open} onOpenChange={onOpenChange}>\n <ConfirmContent {...confirm} />\n </AlertDialog.Root>\n );\n}\n\n/**\n * A plain modal, for a task you chose to begin.\n *\n * Distinct from ConfirmButton: that one interrupts to ask about something you\n * already started, this one holds a form.\n */\nexport function Modal({\n open,\n onOpenChange,\n title,\n description,\n wide = false,\n children,\n}: {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n title: ReactNode;\n description?: ReactNode;\n wide?: boolean;\n children: ReactNode;\n}) {\n const { portal } = usePreferences();\n return (\n <Dialog.Root open={open} onOpenChange={onOpenChange}>\n <Dialog.Portal container={portal}>\n <Dialog.Backdrop className=\"overlay\" />\n <Dialog.Popup className={`dialog${wide ? ' dialog-wide' : ''}`}>\n <div className=\"dialog-head\">\n <Dialog.Title className=\"dialog-title\">{title}</Dialog.Title>\n <Dialog.Close className=\"btn btn-quiet btn-sm btn-icon\" aria-label=\"Close\">\n <X size={15} />\n </Dialog.Close>\n </div>\n {description !== undefined && (\n <Dialog.Description className=\"dialog-body\">{description}</Dialog.Description>\n )}\n {children}\n </Dialog.Popup>\n </Dialog.Portal>\n </Dialog.Root>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Time */\n/* -------------------------------------------------------------------------- */\n\nconst RELATIVE_STEPS: [limit: number, divisor: number, unit: Intl.RelativeTimeFormatUnit][] = [\n [60, 1, 'second'],\n [3600, 60, 'minute'],\n [86400, 3600, 'hour'],\n [2592000, 86400, 'day'],\n [31536000, 2592000, 'month'],\n [Infinity, 31536000, 'year'],\n];\n\nfunction relative(iso: string, now: number, style: 'long' | 'narrow' = 'long'): string {\n const delta = (new Date(iso).getTime() - now) / 1000;\n const magnitude = Math.abs(delta);\n const [, divisor, unit] = RELATIVE_STEPS.find(([limit]) => magnitude < limit)!;\n const formatter = new Intl.RelativeTimeFormat('en', { numeric: 'auto', style });\n return formatter.format(Math.round(delta / divisor), unit);\n}\n\n/** A UTC time as the log writes it: `2026-10-17 08:45:13`, to the millisecond when `precise`. */\nexport function absolute(iso: string, precise: boolean): string {\n return iso.replace('T', ' ').replace('Z', '').slice(0, precise ? 23 : 19);\n}\n\n/**\n * A timestamp. Absolute UTC by default, \"3 hours ago\" on hover.\n *\n * Absolute is the default on purpose: in the audit log this is evidence, and\n * someone reading it is often transcribing it into a finding. `relative` flips\n * the two, in the short form (\"5h ago\"), for glanceable metadata like \"last\n * written\". The relative form can\n * differ between server and client by a rounding step, so that one text node\n * opts out of the hydration check rather than render a placeholder first.\n */\nexport function Timestamp({\n iso,\n precise = false,\n display = 'absolute',\n}: {\n iso: string;\n precise?: boolean;\n display?: 'absolute' | 'relative';\n}) {\n const [now, setNow] = useState<number | null>(null);\n useEffect(() => setNow(Date.now()), [iso]);\n\n if (display === 'relative') {\n return (\n <Tip label={`${absolute(iso, precise)} UTC`}>\n <time dateTime={iso} suppressHydrationWarning>\n {relative(iso, now ?? Date.now(), 'narrow')}\n </time>\n </Tip>\n );\n }\n\n const body = (\n <time className=\"mono\" dateTime={iso}>\n {absolute(iso, precise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,SAAS,KAAK,GAAG;YAAI;CAAU,CAAA;AACpD"}
|
|
1
|
+
{"version":3,"file":"ui-D-blFWfx.js","names":[],"sources":["../../src/lib/preferences.tsx","../../src/lib/clipboard.ts","../../src/lib/copy-attempts.ts","../../src/components/ui.tsx"],"sourcesContent":["import { createContext, useContext, type RefObject } from 'react';\n\nimport { PREFERENCE_COOKIES, preferencesIn, type Preferences } from '@coffre/core/pages';\n\nexport type { Preferences };\n\nexport type Theme = Preferences['theme'];\n\n/**\n * The preferences in the browser's cookies, as the server read them in the\n * request's: each is a cookie, so the server renders the page as the\n * visitor left it, from the first byte, and the browser hydrates the same.\n */\nexport function browserPreferences(): Preferences {\n return preferencesIn(document.cookie);\n}\n\n/** Keep a choice for a year; the default, by removing it. */\nfunction remember(name: string, value: string | null) {\n document.cookie =\n value === null ? `${name}=; Path=/; SameSite=Lax; Max-Age=0` : `${name}=${value}; Path=/; SameSite=Lax; Max-Age=31536000`;\n}\n\nexport function rememberTheme(theme: Theme) {\n remember(PREFERENCE_COOKIES.theme, theme === 'system' ? null : theme);\n}\n\nexport function rememberSidebar(sidebar: Preferences['sidebar']) {\n remember(PREFERENCE_COOKIES.sidebar, sidebar === 'collapsed' ? 'collapsed' : null);\n}\n\ntype PreferencesValue = Preferences & {\n setTheme(theme: Theme): void;\n setSidebar(sidebar: Preferences['sidebar']): void;\n /** coffre's element, which menus, dialogs and tooltips render into, so they are drawn in its theme. */\n portal: RefObject<HTMLDivElement | null>;\n};\n\nexport const PreferencesContext = createContext<PreferencesValue | null>(null);\n\n/** The visitor's preferences, and the switches, from `<CoffreProvider>`. */\nexport function usePreferences(): PreferencesValue {\n const value = useContext(PreferencesContext);\n if (value === null) throw new Error(\"coffre's pages render inside <CoffreProvider>, in the app's root document\");\n return value;\n}\n","/**\n * Writing to the clipboard, from text that may still be on its way.\n *\n * A browser lets a page write to the clipboard only inside a click's user\n * gesture, and Safari drops the gesture across an `await`. So a value that has\n * to be fetched first (Copy on a hidden secret) is handed over as a promise:\n * `clipboard.write` is called at once, with the promise inside a\n * `ClipboardItem`, and the browser waits for it. Where that is not supported,\n * the text is awaited, then written with `writeText`, which is what every\n * browser but Safari allows.\n *\n * The text goes through byte for byte: no trimming, no newline changes.\n */\n\n/** What of the clipboard `copyText` uses; the browser's `navigator.clipboard` fits. */\nexport type ClipboardLike = {\n writeText(text: string): Promise<void>;\n write?(items: unknown[]): Promise<void>;\n};\n\ntype ClipboardItemConstructor = new (items: Record<string, Promise<string>>) => unknown;\n\nexport async function copyText(\n text: string | Promise<string>,\n {\n clipboard = globalThis.navigator?.clipboard as ClipboardLike | undefined,\n item = (globalThis as { ClipboardItem?: ClipboardItemConstructor }).ClipboardItem,\n }: { clipboard?: ClipboardLike; item?: ClipboardItemConstructor } = {},\n): Promise<void> {\n // A read that fails after the copy has ended is nobody's to hear: not an unhandled rejection.\n if (typeof text !== 'string') text.catch(() => {});\n if (clipboard === undefined) throw new Error('The clipboard is not available here.');\n if (typeof text !== 'string' && item !== undefined && clipboard.write !== undefined) {\n // Called before anything is awaited: this is what keeps the user gesture.\n // The text goes in as a string, not a Blob: decoding a Blob drops a leading U+FEFF.\n await clipboard.write([new item({ 'text/plain': text })]);\n return;\n }\n await clipboard.writeText(await text);\n}\n","import { copyText } from './clipboard.ts';\n\n/**\n * How a copy ended, as far as anyone still cares.\n *\n * `superseded`: a newer copy began before this one ended, so this one reports\n * nothing and writes nothing. Its result, good or bad, is not what the person\n * asked for last.\n */\nexport type CopyResult = { outcome: 'copied' } | { outcome: 'failed'; failure: unknown } | { outcome: 'superseded' };\n\n/** What a copy button shows: a copy under way, or how the last one ended, for a moment. */\nexport type CopyFeedback = 'idle' | 'pending' | 'copied' | 'failed';\n\n/**\n * Copies where the latest one wins, and what they look like while they run.\n *\n * The clipboard is one resource per page, so \"latest\" is decided per page: every\n * copy, from any row, takes a number from one counter before it awaits anything,\n * and only the newest reports, shows feedback, or writes. A copy may start while\n * an earlier one is still reading or waiting on the clipboard: a retry after a\n * refusal, a click on another row, a row filtered out and back, a button replaced\n * by a remount. When a copy from another copier takes over, the older one drops\n * its pending or \"Copied\" feedback and goes back to idle. A copier belongs to\n * whoever outlives the button (a row); the button only subscribes to it, so a\n * remount picks up where it was.\n */\nexport type Copier = {\n run(text: string | Promise<string>): Promise<CopyResult>;\n feedback(): CopyFeedback;\n subscribe(listener: () => void): () => void;\n};\n\nconst SUPERSEDED = new Error('A newer copy began.');\n\n/** The page's newest copy, and the copier that made it. */\nlet latest = 0;\nlet owner: { drop(): void } | null = null;\n\nexport function createCopier({\n copy = copyText,\n copiedMs = 1400,\n failedMs = 3000,\n}: { copy?: typeof copyText; copiedMs?: number; failedMs?: number } = {}): Copier {\n let feedback: CopyFeedback = 'idle';\n let timer: ReturnType<typeof setTimeout> | null = null;\n const listeners = new Set<() => void>();\n\n function show(next: CopyFeedback) {\n if (feedback === next) return;\n feedback = next;\n for (const listener of listeners) listener();\n }\n\n function stopTimer() {\n if (timer !== null) clearTimeout(timer);\n timer = null;\n }\n\n const self = {\n /** Another copier's copy took over: nothing of this one's is left showing. */\n drop() {\n stopTimer();\n show('idle');\n },\n };\n\n return {\n feedback: () => feedback,\n subscribe(listener) {\n listeners.add(listener);\n return () => void listeners.delete(listener);\n },\n async run(text) {\n const attempt = ++latest;\n if (owner !== null && owner !== self) owner.drop();\n owner = self;\n stopTimer();\n show('pending');\n // A read that finishes after a newer copy began, anywhere on the page, is\n // refused here, so it never reaches the clipboard: the fallback does not\n // write it, and a ClipboardItem whose payload rejects writes nothing.\n const gated =\n typeof text === 'string'\n ? text\n : text.then((value) => {\n if (attempt !== latest) throw SUPERSEDED;\n return value;\n });\n let result: CopyResult = { outcome: 'copied' };\n try {\n // Called before anything is awaited: the click's gesture is still live.\n await copy(gated);\n } catch (failure) {\n result = { outcome: 'failed', failure };\n }\n if (attempt !== latest) return { outcome: 'superseded' };\n show(result.outcome === 'copied' ? 'copied' : 'failed');\n timer = setTimeout(() => show('idle'), result.outcome === 'copied' ? copiedMs : failedMs);\n return result;\n },\n };\n}\n","import { useEffect, useRef, useState, useSyncExternalStore, type ReactElement, type ReactNode } from 'react';\nimport { AlertDialog } from '@base-ui/react/alert-dialog';\nimport { Dialog } from '@base-ui/react/dialog';\nimport { Menu } from '@base-ui/react/menu';\nimport { Popover } from '@base-ui/react/popover';\nimport { Tooltip } from '@base-ui/react/tooltip';\nimport { AlertCircle, AlertTriangle, Check, Copy, Info, Loader, X } from './icons';\nimport { createCopier, type Copier } from '../lib/copy-attempts';\nimport { usePreferences } from '../lib/preferences';\n\n/* -------------------------------------------------------------------------- */\n/* Tooltip */\n/* -------------------------------------------------------------------------- */\n\nexport function TooltipProvider({ children }: { children: ReactNode }) {\n // 400ms before the first tip; afterwards adjacent tips open instantly, which\n // makes a row of controls feel immediate without the delay losing its\n // purpose (preventing accidental activation on a passing cursor).\n return (\n <Tooltip.Provider delay={400} timeout={300}>\n {children}\n </Tooltip.Provider>\n );\n}\n\nexport function Tip({\n label,\n side,\n children,\n}: {\n label: ReactNode;\n side?: 'top' | 'right' | 'bottom' | 'left';\n children: ReactElement;\n}) {\n const { portal } = usePreferences();\n return (\n <Tooltip.Root>\n <Tooltip.Trigger render={children} />\n <Tooltip.Portal container={portal}>\n <Tooltip.Positioner\n className=\"tooltip-positioner\"\n side={side}\n sideOffset={6}\n collisionPadding={8}\n >\n <Tooltip.Popup className=\"tooltip\">{label}</Tooltip.Popup>\n </Tooltip.Positioner>\n </Tooltip.Portal>\n </Tooltip.Root>\n );\n}\n\n/**\n * The same bubble as Tip, for a note a touch screen must reach too.\n *\n * A tooltip opens on hover and focus only, so on a phone it never opens. This\n * one also opens on a tap, which means its trigger has to be a real button.\n * With a mouse, hover alone drives it: a click would otherwise close the note\n * the hover just opened.\n */\nexport function Toggletip({\n label,\n side,\n align,\n children,\n}: {\n label: ReactNode;\n side?: 'top' | 'right' | 'bottom' | 'left';\n /** `end` for a trigger at the right edge, so the tip opens leftwards. */\n align?: 'start' | 'center' | 'end';\n children: ReactElement;\n}) {\n const { portal } = usePreferences();\n const [open, setOpen] = useState(false);\n const mouse = useRef(false);\n const hover = (next: boolean) => (event: { pointerType: string }) => {\n if (event.pointerType === 'mouse') setOpen(next);\n };\n\n return (\n <Popover.Root\n open={open}\n onOpenChange={(next, { reason }) => {\n const clicked = reason === 'trigger-press' && mouse.current;\n mouse.current = false;\n if (!clicked) setOpen(next);\n }}\n >\n <Popover.Trigger\n render={children}\n onPointerEnter={hover(true)}\n onPointerLeave={hover(false)}\n onPointerDown={(event) => {\n mouse.current = event.pointerType === 'mouse';\n }}\n />\n <Popover.Portal container={portal}>\n <Popover.Positioner\n className=\"tooltip-positioner\"\n side={side}\n align={align}\n sideOffset={6}\n collisionPadding={16}\n >\n {/* Focus stays on the trigger, so there is nothing to return it to. */}\n <Popover.Popup className=\"tooltip\" initialFocus={false} finalFocus={false}>\n {label}\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Menu */\n/* -------------------------------------------------------------------------- */\n\n/**\n * A menu's floating panel, placed against its `Menu.Trigger`.\n *\n * The callers keep the rest of Base UI's menu parts: the trigger, the items\n * and their separators read better at the call site than behind props.\n */\nexport function MenuPopup({\n side,\n align,\n className,\n children,\n}: {\n side?: 'top' | 'bottom';\n align: 'start' | 'end';\n className?: string;\n children: ReactNode;\n}) {\n const { portal } = usePreferences();\n return (\n <Menu.Portal container={portal}>\n <Menu.Positioner className=\"menu-positioner\" side={side} align={align} sideOffset={6}>\n <Menu.Popup className={className === undefined ? 'menu' : `menu ${className}`}>\n {children}\n </Menu.Popup>\n </Menu.Positioner>\n </Menu.Portal>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Feedback primitives */\n/* -------------------------------------------------------------------------- */\n\nexport function Spinner({ size = 14 }: { size?: number }) {\n return <Loader size={size} className=\"spinner\" />;\n}\n\nexport function ErrorLine({ error }: { error: string | null }) {\n if (error === null) return null;\n return (\n <p className=\"error-line\" role=\"alert\">\n <AlertCircle size={14} />\n <span>{error}</span>\n </p>\n );\n}\n\nconst NOTICE_ICON = {\n info: Info,\n good: Check,\n bad: AlertTriangle,\n warn: AlertTriangle,\n neutral: Info,\n} as const;\n\nexport function Notice({\n tone = 'neutral',\n children,\n}: {\n tone?: keyof typeof NOTICE_ICON;\n children: ReactNode;\n}) {\n const Icon = NOTICE_ICON[tone];\n return (\n <div\n className={`notice${tone === 'neutral' ? '' : ` notice-${tone}`}`}\n role={tone === 'bad' ? 'alert' : undefined}\n >\n <Icon size={16} />\n <div>{children}</div>\n </div>\n );\n}\n\n/**\n * Nothing here yet, said in a sentence.\n *\n * It sits where the table would have been, left-aligned like the rows it\n * stands in for, rather than as a centred illustration.\n */\nexport function EmptyState({\n title,\n children,\n actions,\n}: {\n title: string;\n children?: ReactNode;\n actions?: ReactNode;\n}) {\n return (\n <div className=\"empty\">\n <p className=\"empty-title\">{title}</p>\n {children !== undefined && <p className=\"empty-body\">{children}</p>}\n {actions !== undefined && <div className=\"empty-actions\">{actions}</div>}\n </div>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Text */\n/* -------------------------------------------------------------------------- */\n\n/**\n * An identifier that wraps after its underscores rather than mid-word.\n *\n * To the line breaker `DOCUSIGN_INTEGRATION_KEY` is one word, so a narrow\n * column cuts it wherever room runs out (`…_KE` / `Y`). A <wbr> after each\n * underscore offers the natural places instead. Copied text is unchanged, and\n * `overflow-wrap: anywhere` still catches a segment too long for any line.\n */\nexport function breakAfterUnderscores(text: string): ReactNode {\n return text\n .split('_')\n .flatMap((part, index) => (index === 0 ? [part] : ['_', <wbr key={index} />, part]));\n}\n\n/* -------------------------------------------------------------------------- */\n/* Copy */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Copy to clipboard with a settled confirmation.\n *\n * The glyph turns into a check, and screen readers hear \"Copied\", for 1.4s --\n * long enough to be noticed after the eye has moved on, short enough not to\n * look stuck. A copy that fails says so the same way, in red, rather than\n * leaving the click looking ignored.\n *\n * `value` is the text. A caller that must read it first (Copy on a hidden\n * secret) passes the `copier` it owns instead, and `onCopy`, called inside the\n * click so the clipboard write keeps its user gesture, which starts a copy on\n * that copier. Copies do not lock the button: a click while one is out starts\n * the next, and the latest one's ending is the one that shows. The copier's\n * owner outlives the button, so a remount keeps the feedback of a copy in flight.\n */\nexport function CopyButton({\n label = 'Copy',\n variant = 'icon',\n ...source\n}: {\n label?: string;\n /** `act` sits among a table row's actions; `icon` anywhere else. */\n variant?: 'icon' | 'act';\n} & ({ value: string; copier?: undefined; onCopy?: undefined } | { value?: undefined; copier: Copier; onCopy: () => void })) {\n const [own] = useState(() => createCopier());\n const copier = source.copier ?? own;\n const state = useSyncExternalStore(copier.subscribe, copier.feedback, copier.feedback);\n\n function copy() {\n if (source.copier !== undefined) source.onCopy();\n else void own.run(source.value);\n }\n\n const text = state === 'copied' ? 'Copied' : state === 'failed' ? 'Copy failed' : label;\n return (\n <Tip label={text}>\n <button\n type=\"button\"\n className={variant === 'act' ? 'act act-icon' : 'btn btn-quiet btn-sm btn-icon'}\n aria-label={label}\n aria-busy={state === 'pending'}\n onClick={copy}\n >\n {state === 'pending' ? (\n <Spinner size={13} />\n ) : state === 'copied' ? (\n <Check size={14} className=\"copied\" />\n ) : state === 'failed' ? (\n <AlertCircle size={14} className=\"copy-failed\" />\n ) : (\n <Copy size={14} />\n )}\n <span className=\"visually-hidden\" aria-live=\"polite\">\n {state === 'copied' ? 'Copied' : state === 'failed' ? 'Copy failed' : ''}\n </span>\n </button>\n </Tip>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Confirmation */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Confirmation for actions with reach.\n *\n * Reserved for changes that affect other people or other screens (archiving a\n * project, revoking a grant). Restoring one secret is reversible and gets an\n * undo toast instead -- a dialog on every action trains people to dismiss them.\n */\ntype ConfirmProps = {\n title: ReactNode;\n body: ReactNode;\n /** What the body's sentence cannot hold, such as a list: after it, outside its paragraph. */\n detail?: ReactNode;\n confirmLabel: string;\n destructive?: boolean;\n /** While something must happen first, which `detail` says. */\n confirmDisabled?: boolean;\n onConfirm: () => void;\n};\n\nfunction ConfirmContent({ title, body, detail, confirmLabel, destructive, confirmDisabled, onConfirm }: ConfirmProps) {\n const { portal } = usePreferences();\n return (\n <AlertDialog.Portal container={portal}>\n <AlertDialog.Backdrop className=\"overlay\" />\n <AlertDialog.Popup className=\"dialog dialog-confirm\">\n <AlertDialog.Title className=\"dialog-title\">{title}</AlertDialog.Title>\n <AlertDialog.Description className=\"dialog-body\">{body}</AlertDialog.Description>\n {detail}\n <div className=\"dialog-actions\">\n <AlertDialog.Close className=\"btn\">Cancel</AlertDialog.Close>\n <AlertDialog.Close\n className={`btn ${destructive === false ? 'btn-primary' : 'btn-danger'}`}\n onClick={onConfirm}\n disabled={confirmDisabled}\n >\n {confirmLabel}\n </AlertDialog.Close>\n </div>\n </AlertDialog.Popup>\n </AlertDialog.Portal>\n );\n}\n\nexport function ConfirmButton({\n trigger,\n disabled,\n ...confirm\n}: ConfirmProps & { trigger: ReactElement; disabled?: boolean }) {\n return (\n <AlertDialog.Root>\n <AlertDialog.Trigger render={trigger} disabled={disabled} />\n <ConfirmContent {...confirm} />\n </AlertDialog.Root>\n );\n}\n\nconst hydrated = () => true;\nconst serverRender = () => false;\nconst unchanging = () => () => {};\n\n/**\n * Whether a dialog's root is drawn: always once the page is the browser's,\n * which closes it with its animation; on the server and while hydrating,\n * only when it is open. Closed, a dialog draws nothing, so the page's HTML\n * is the same either way, and the server skips a root per dialog: four in\n * each row of an environment's table. Its trigger is elsewhere, so mounting\n * it after hydration remounts nothing else.\n */\nfunction useHydrated(open: boolean): boolean {\n return useSyncExternalStore(unchanging, hydrated, serverRender) || open;\n}\n\n/**\n * The same confirmation, opened from something that is not a trigger.\n *\n * A menu item cannot be one: it unmounts as the menu closes, taking the dialog\n * with it. So the caller keeps the open state and the dialog lives outside the\n * menu entirely.\n */\nexport function ConfirmDialog({\n open,\n onOpenChange,\n ...confirm\n}: ConfirmProps & { open: boolean; onOpenChange: (open: boolean) => void }) {\n if (!useHydrated(open)) return null;\n return (\n <AlertDialog.Root open={open} onOpenChange={onOpenChange}>\n <ConfirmContent {...confirm} />\n </AlertDialog.Root>\n );\n}\n\n/**\n * A plain modal, for a task you chose to begin.\n *\n * Distinct from ConfirmButton: that one interrupts to ask about something you\n * already started, this one holds a form.\n */\nexport function Modal({\n open,\n onOpenChange,\n title,\n description,\n wide = false,\n children,\n}: {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n title: ReactNode;\n description?: ReactNode;\n wide?: boolean;\n children: ReactNode;\n}) {\n const { portal } = usePreferences();\n if (!useHydrated(open)) return null;\n return (\n <Dialog.Root open={open} onOpenChange={onOpenChange}>\n <Dialog.Portal container={portal}>\n <Dialog.Backdrop className=\"overlay\" />\n <Dialog.Popup className={`dialog${wide ? ' dialog-wide' : ''}`}>\n <div className=\"dialog-head\">\n <Dialog.Title className=\"dialog-title\">{title}</Dialog.Title>\n <Dialog.Close className=\"btn btn-quiet btn-sm btn-icon\" aria-label=\"Close\">\n <X size={15} />\n </Dialog.Close>\n </div>\n {description !== undefined && (\n <Dialog.Description className=\"dialog-body\">{description}</Dialog.Description>\n )}\n {children}\n </Dialog.Popup>\n </Dialog.Portal>\n </Dialog.Root>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Time */\n/* -------------------------------------------------------------------------- */\n\nconst RELATIVE_STEPS: [limit: number, divisor: number, unit: Intl.RelativeTimeFormatUnit][] = [\n [60, 1, 'second'],\n [3600, 60, 'minute'],\n [86400, 3600, 'hour'],\n [2592000, 86400, 'day'],\n [31536000, 2592000, 'month'],\n [Infinity, 31536000, 'year'],\n];\n\n/** One formatter per style, made once: making one costs more than a row of a page renders around it. */\nconst RELATIVE = {\n long: new Intl.RelativeTimeFormat('en', { numeric: 'auto', style: 'long' }),\n narrow: new Intl.RelativeTimeFormat('en', { numeric: 'auto', style: 'narrow' }),\n};\n\nfunction relative(iso: string, now: number, style: 'long' | 'narrow' = 'long'): string {\n const delta = (new Date(iso).getTime() - now) / 1000;\n const magnitude = Math.abs(delta);\n const [, divisor, unit] = RELATIVE_STEPS.find(([limit]) => magnitude < limit)!;\n return RELATIVE[style].format(Math.round(delta / divisor), unit);\n}\n\n/** A UTC time as the log writes it: `2026-10-17 08:45:13`, to the millisecond when `precise`. */\nexport function absolute(iso: string, precise: boolean): string {\n return iso.replace('T', ' ').replace('Z', '').slice(0, precise ? 23 : 19);\n}\n\n/**\n * A timestamp. Absolute UTC by default, \"3 hours ago\" on hover.\n *\n * Absolute is the default on purpose: in the audit log this is evidence, and\n * someone reading it is often transcribing it into a finding. `relative` flips\n * the two, in the short form (\"5h ago\"), for glanceable metadata like \"last\n * written\". The relative form can\n * differ between server and client by a rounding step, so that one text node\n * opts out of the hydration check rather than render a placeholder first.\n */\nexport function Timestamp({\n iso,\n precise = false,\n display = 'absolute',\n}: {\n iso: string;\n precise?: boolean;\n display?: 'absolute' | 'relative';\n}) {\n const [now, setNow] = useState<number | null>(null);\n useEffect(() => setNow(Date.now()), [iso]);\n\n if (display === 'relative') {\n return (\n <Tip label={`${absolute(iso, precise)} UTC`}>\n <time dateTime={iso} suppressHydrationWarning>\n {relative(iso, now ?? Date.now(), 'narrow')}\n </time>\n </Tip>\n );\n }\n\n const body = (\n <time className=\"mono\" dateTime={iso}>\n {absolute(iso, precise)}\n </time>\n );\n if (now === null) return body;\n return <Tip label={relative(iso, now)}>{body}</Tip>;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAaA,SAAgB,qBAAkC;CAChD,OAAO,cAAc,SAAS,MAAM;AACtC;;AAGA,SAAS,SAAS,MAAc,OAAsB;CACpD,SAAS,SACP,UAAU,OAAO,GAAG,KAAK,sCAAsC,GAAG,KAAK,GAAG,MAAM;AACpF;AAEA,SAAgB,cAAc,OAAc;CAC1C,SAAS,mBAAmB,OAAO,UAAU,WAAW,OAAO,KAAK;AACtE;AAEA,SAAgB,gBAAgB,SAAiC;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AS,KAAK,GAAG;YAAI;CAAU,CAAA;AACpD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as refresh } from "./queries-Danu0o75.js";
|
|
2
2
|
import { o as failureMessage } from "./page-JTORvh-N.js";
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import { useQueryClient } from "@tanstack/react-query";
|
|
@@ -46,4 +46,4 @@ function useAction() {
|
|
|
46
46
|
//#endregion
|
|
47
47
|
export { useAction as t };
|
|
48
48
|
|
|
49
|
-
//# sourceMappingURL=use-action-
|
|
49
|
+
//# sourceMappingURL=use-action-BafZVwux.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-action-
|
|
1
|
+
{"version":3,"file":"use-action-BafZVwux.js","names":[],"sources":["../../src/lib/use-action.ts"],"sourcesContent":["import { useQueryClient, type QueryKey } from '@tanstack/react-query';\nimport { useState } from 'react';\n\nimport { failureMessage } from './coffre';\nimport { refresh } from './queries';\n\n/**\n * Run a change against the API, then refetch what it touched. A failed call\n * leaves the page as it was and says why, in `error`.\n *\n * Each change names what it touches (`affects` in `lib/queries.ts`), and\n * those queries are refetched before the change counts as done: at once where\n * they are on screen, such as the sidebar's project tree, and on next use\n * where they are not. So your own change always shows, and nothing else is\n * asked for again.\n */\nexport function useAction() {\n const queryClient = useQueryClient();\n const [pending, setPending] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n async function run<T>(\n fn: () => Promise<T>,\n {\n affects,\n onSuccess,\n }: {\n affects: QueryKey[] | ((result: T) => QueryKey[]);\n // `unknown` rather than `void`, so a one-expression callback can end in\n // `toast.success(...)` -- which returns an id -- without a block body.\n onSuccess?: (result: T) => unknown;\n },\n ): Promise<void> {\n setPending(true);\n let result: T;\n try {\n result = await fn();\n } catch (failure) {\n setError(failureMessage(failure));\n setPending(false);\n return;\n }\n\n setError(null);\n try {\n await refresh(queryClient, typeof affects === 'function' ? affects(result) : affects);\n await onSuccess?.(result);\n } catch {\n setError('The change was saved, but the page could not refresh. Reload before you retry.');\n }\n setPending(false);\n }\n\n return { pending, error, setError, run };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,YAAY;CAC1B,MAAM,cAAc,eAAe;CACnC,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,OAAO,YAAY,SAAwB,IAAI;CAEtD,eAAe,IACb,IACA,EACE,SACA,aAOa;EACf,WAAW,IAAI;EACf,IAAI;EACJ,IAAI;GACF,SAAS,MAAM,GAAG;EACpB,SAAS,SAAS;GAChB,SAAS,eAAe,OAAO,CAAC;GAChC,WAAW,KAAK;GAChB;EACF;EAEA,SAAS,IAAI;EACb,IAAI;GACF,MAAM,QAAQ,aAAa,OAAO,YAAY,aAAa,QAAQ,MAAM,IAAI,OAAO;GACpF,MAAM,YAAY,MAAM;EAC1B,QAAQ;GACN,SAAS,gFAAgF;EAC3F;EACA,WAAW,KAAK;CAClB;CAEA,OAAO;EAAE;EAAS;EAAO;EAAU;CAAI;AACzC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as refresh, o as keys, t as affects } from "./queries-Danu0o75.js";
|
|
2
2
|
import { a as Refusal, o as failureMessage, s as memberRef } from "./page-JTORvh-N.js";
|
|
3
|
-
import { o as announce } from "./row-state-
|
|
3
|
+
import { o as announce } from "./row-state-xtRGFnDc.js";
|
|
4
4
|
import { useCallback } from "react";
|
|
5
5
|
import { EVERYWHERE, unscoped } from "@coffre/core/access";
|
|
6
6
|
import { useMutation, useMutationState, useQueryClient } from "@tanstack/react-query";
|
|
@@ -1310,4 +1310,4 @@ function useChangeStatus(list) {
|
|
|
1310
1310
|
//#endregion
|
|
1311
1311
|
export { restoreSecret as A, valueEdit as B, projectsList as C, removeMember as D, removeBinding as E, unlinkIdentity as F, stricter as G, SENSITIVITIES as H, companionsOf as I, regenerateWaits as J, waitsForValue as K, hasSecretEditConflict as L, revokeGrant as M, revokeMemberToken as N, renameEnvironment as O, saveSecrets as P, madeSensitive as R, moveSecret as S, regenerateSecret as T, levelsIn as U, LEVELS as V, markable as W, accessRows as X, regeneratedKeys as Y, projectAccessLabel as Z, forkKey as _, UnsavedEdits as a, invite as b, changeRole as c, directoryList as d, disconnectApp as f, environmentId as g, endSession as h, changeOptions as i, revokeCredential as j, restoreMissing as k, createEnvironment as l, dismissMissing as m, useChangeStatus as n, archiveEnvironment as o, disconnectMemberApp as p, liveGeneration as q, changeKey as r, archiveSecret as s, useChange as t, createProject as u, grantAccess as v, protectEnvironment as w, missingList as x, grantId as y, secretChangeFor as z };
|
|
1312
1312
|
|
|
1313
|
-
//# sourceMappingURL=use-change-
|
|
1313
|
+
//# sourceMappingURL=use-change-DhV6i_Ge.js.map
|