@coffre/ui 0.1.18 → 0.2.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 (235) hide show
  1. package/README.md +23 -3
  2. package/dist/{server/_coffre/assets/affordances-CKANXDTG.js → chunks/affordances-DAvsVz7u.js} +12 -7
  3. package/dist/chunks/affordances-DAvsVz7u.js.map +1 -0
  4. package/dist/chunks/directory-CSjWWUQ1.js +370 -0
  5. package/dist/chunks/directory-CSjWWUQ1.js.map +1 -0
  6. package/dist/{server/_coffre/assets/grants-DdKT11Ny.js → chunks/grants-saMQagmG.js} +41 -39
  7. package/dist/chunks/grants-saMQagmG.js.map +1 -0
  8. package/dist/chunks/icons-D-PfAfnH.js +203 -0
  9. package/dist/chunks/icons-D-PfAfnH.js.map +1 -0
  10. package/dist/chunks/mounted-jJmqqV_n.js +17 -0
  11. package/dist/chunks/mounted-jJmqqV_n.js.map +1 -0
  12. package/dist/{server/_coffre/assets/offboarding-CRz-K82H.js → chunks/offboarding-C6l30DZR.js} +70 -69
  13. package/dist/chunks/offboarding-C6l30DZR.js.map +1 -0
  14. package/dist/chunks/page-C5HcNqf2.js +190 -0
  15. package/dist/chunks/page-C5HcNqf2.js.map +1 -0
  16. package/dist/chunks/page-route-Drfw7lmn.js +20 -0
  17. package/dist/chunks/page-route-Drfw7lmn.js.map +1 -0
  18. package/dist/{server/_coffre/assets/principal-page-C-EFwJQw.js → chunks/principal-page-D_91OA0l.js} +105 -103
  19. package/dist/chunks/principal-page-D_91OA0l.js.map +1 -0
  20. package/dist/{server/_coffre/assets → chunks}/project-environments-lEzFHUt4.js +2 -0
  21. package/dist/chunks/project-environments-lEzFHUt4.js.map +1 -0
  22. package/dist/chunks/queries-CQ81o4so.js +376 -0
  23. package/dist/chunks/queries-CQ81o4so.js.map +1 -0
  24. package/dist/{server/_coffre/assets/row-state-C2P57xT1.js → chunks/row-state-0PsrEzOL.js} +22 -21
  25. package/dist/chunks/row-state-0PsrEzOL.js.map +1 -0
  26. package/dist/{server/_coffre/assets → chunks}/signin-errors-BEFlVDbQ.js +2 -0
  27. package/dist/chunks/signin-errors-BEFlVDbQ.js.map +1 -0
  28. package/dist/chunks/theme-B2vQolVR.js +86 -0
  29. package/dist/chunks/theme-B2vQolVR.js.map +1 -0
  30. package/dist/chunks/ui-DixXLQvQ.js +405 -0
  31. package/dist/chunks/ui-DixXLQvQ.js.map +1 -0
  32. package/dist/{server/_coffre/assets/use-action-B-xpvVRO.js → chunks/use-action-CWsg_YWU.js} +8 -6
  33. package/dist/chunks/use-action-CWsg_YWU.js.map +1 -0
  34. package/dist/{server/_coffre/assets/use-change-C8BCf3oU.js → chunks/use-change-c6CeLRin.js} +10 -474
  35. package/dist/chunks/use-change-c6CeLRin.js.map +1 -0
  36. package/dist/chunks/use-shell-jxd7Tzd-.js +26 -0
  37. package/dist/chunks/use-shell-jxd7Tzd-.js.map +1 -0
  38. package/dist/{server/_coffre/assets → chunks}/validation-BQtqPe2V.js +2 -0
  39. package/dist/chunks/validation-BQtqPe2V.js.map +1 -0
  40. package/dist/index.d.ts +386 -18
  41. package/dist/index.js +1147 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/pages/account.d.ts +9 -0
  44. package/dist/pages/account.js +334 -0
  45. package/dist/pages/account.js.map +1 -0
  46. package/dist/pages/audit.d.ts +3 -0
  47. package/dist/{server/_coffre/assets/audit-qB9G2AQJ.js → pages/audit.js} +102 -100
  48. package/dist/pages/audit.js.map +1 -0
  49. package/dist/pages/device-login.d.ts +9 -0
  50. package/dist/pages/device-login.js +211 -0
  51. package/dist/pages/device-login.js.map +1 -0
  52. package/dist/pages/environment.d.ts +3 -0
  53. package/dist/{server/_coffre/assets/projects._project._environment-C6uybzeU.js → pages/environment.js} +323 -469
  54. package/dist/pages/environment.js.map +1 -0
  55. package/dist/pages/login.d.ts +10 -0
  56. package/dist/pages/login.js +104 -0
  57. package/dist/pages/login.js.map +1 -0
  58. package/dist/pages/project.d.ts +2 -0
  59. package/dist/{server/_coffre/assets/projects._project.index-3CXwkyTh.js → pages/project.js} +223 -225
  60. package/dist/pages/project.js.map +1 -0
  61. package/dist/pages/projects.d.ts +3 -0
  62. package/dist/{server/_coffre/assets/projects.index-iSoBpRFz.js → pages/projects.js} +83 -81
  63. package/dist/pages/projects.js.map +1 -0
  64. package/dist/pages/settings.d.ts +3 -0
  65. package/dist/{server/_coffre/assets/settings-BDQTF5XW.js → pages/settings.js} +20 -18
  66. package/dist/pages/settings.js.map +1 -0
  67. package/dist/pages/token.d.ts +3 -0
  68. package/dist/{server/_coffre/assets/tokens._token-CrBMpcbN.js → pages/token.js} +195 -265
  69. package/dist/pages/token.js.map +1 -0
  70. package/dist/pages/tokens.d.ts +3 -0
  71. package/dist/pages/tokens.js +39 -0
  72. package/dist/pages/tokens.js.map +1 -0
  73. package/dist/pages/unregistered.d.ts +8 -0
  74. package/dist/pages/unregistered.js +54 -0
  75. package/dist/pages/unregistered.js.map +1 -0
  76. package/dist/pages/user.d.ts +3 -0
  77. package/dist/pages/user.js +16 -0
  78. package/dist/pages/user.js.map +1 -0
  79. package/dist/pages/users.d.ts +3 -0
  80. package/dist/pages/users.js +39 -0
  81. package/dist/pages/users.js.map +1 -0
  82. package/dist/project-BqIy8gYR.d.ts +5 -0
  83. package/dist/vite.d.ts +16 -0
  84. package/dist/vite.js +52 -0
  85. package/package.json +36 -21
  86. package/src/assets/icon.svg +1 -0
  87. package/src/components/affordances.ts +10 -4
  88. package/src/components/command-palette.tsx +229 -203
  89. package/src/components/directory.tsx +34 -38
  90. package/src/components/principal.tsx +7 -3
  91. package/src/components/shell.tsx +89 -127
  92. package/src/components/theme.tsx +14 -81
  93. package/src/components/ui.tsx +97 -68
  94. package/src/index.ts +29 -0
  95. package/src/layout.tsx +113 -0
  96. package/src/lib/coffre.ts +8 -4
  97. package/src/lib/mounted.ts +13 -0
  98. package/src/lib/page-context.ts +31 -0
  99. package/src/lib/page-route.ts +22 -0
  100. package/src/lib/preferences.tsx +46 -0
  101. package/src/options.ts +240 -0
  102. package/src/{routes → pages}/account.tsx +7 -24
  103. package/src/{routes → pages}/audit.tsx +5 -16
  104. package/src/{routes/auth.device.tsx → pages/device-login.tsx} +8 -21
  105. package/src/{routes/projects.$project.$environment.tsx → pages/environment.tsx} +43 -52
  106. package/src/{routes → pages}/login.tsx +5 -16
  107. package/src/{routes/projects.$project.index.tsx → pages/project.tsx} +38 -50
  108. package/src/{routes/projects.index.tsx → pages/projects.tsx} +2 -7
  109. package/src/{routes → pages}/settings.tsx +3 -10
  110. package/src/{routes/tokens.$token.tsx → pages/token.tsx} +6 -7
  111. package/src/{routes/tokens.index.tsx → pages/tokens.tsx} +3 -8
  112. package/src/{routes → pages}/unregistered.tsx +1 -6
  113. package/src/pages/user.tsx +10 -0
  114. package/src/{routes/users.index.tsx → pages/users.tsx} +3 -8
  115. package/src/register.ts +55 -0
  116. package/src/router.tsx +31 -62
  117. package/src/styles/globals.css +104 -46
  118. package/src/vite.ts +78 -0
  119. package/dist/client/.assetsignore +0 -2
  120. package/dist/client/_coffre/assets/account-BoLGAxbD.js +0 -2
  121. package/dist/client/_coffre/assets/account-CnnuRTDB.js +0 -1
  122. package/dist/client/_coffre/assets/affordances-CEafRJcN.js +0 -1
  123. package/dist/client/_coffre/assets/audit-CHSvKLWX.js +0 -1
  124. package/dist/client/_coffre/assets/audit-Cn4hmS4u.js +0 -2
  125. package/dist/client/_coffre/assets/auth.device-Co5vrpaA.js +0 -2
  126. package/dist/client/_coffre/assets/auth.device-DAlqWacc.js +0 -1
  127. package/dist/client/_coffre/assets/directory-H8Eh3MnS.js +0 -1
  128. package/dist/client/_coffre/assets/dist-Braunv_x.js +0 -1
  129. package/dist/client/_coffre/assets/globals-CpMrgkV6.css +0 -1
  130. package/dist/client/_coffre/assets/grants-DPDxJXU1.js +0 -1
  131. package/dist/client/_coffre/assets/icons-Dc_-t0lp.js +0 -1
  132. package/dist/client/_coffre/assets/index-sUCIXRgJ.js +0 -12
  133. package/dist/client/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
  134. package/dist/client/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
  135. package/dist/client/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
  136. package/dist/client/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
  137. package/dist/client/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
  138. package/dist/client/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
  139. package/dist/client/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
  140. package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
  141. package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  142. package/dist/client/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  143. package/dist/client/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  144. package/dist/client/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  145. package/dist/client/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  146. package/dist/client/_coffre/assets/link-DBINMwm6.js +0 -1
  147. package/dist/client/_coffre/assets/login-BZFYfL1Y.js +0 -1
  148. package/dist/client/_coffre/assets/login-CYCKWTOD.js +0 -2
  149. package/dist/client/_coffre/assets/offboarding-Bwpftp3g.js +0 -1
  150. package/dist/client/_coffre/assets/page-C_hnzdaR.js +0 -1
  151. package/dist/client/_coffre/assets/preload-helper-CLkO85Nq.js +0 -1
  152. package/dist/client/_coffre/assets/principal-page-DLho8TSJ.js +0 -1
  153. package/dist/client/_coffre/assets/project-environments-CfIH5kFM.js +0 -1
  154. package/dist/client/_coffre/assets/projects._project._environment-DHRRvQw0.js +0 -3
  155. package/dist/client/_coffre/assets/projects._project._environment-TLI-RjBZ.js +0 -2
  156. package/dist/client/_coffre/assets/projects._project.index-BO-8FZIY.js +0 -2
  157. package/dist/client/_coffre/assets/projects._project.index-DGl921dP.js +0 -1
  158. package/dist/client/_coffre/assets/projects.index-BDn7Bhoo.js +0 -1
  159. package/dist/client/_coffre/assets/row-state-DJ-KLamZ.js +0 -1
  160. package/dist/client/_coffre/assets/settings-q9G1QvR_.js +0 -1
  161. package/dist/client/_coffre/assets/signin-errors-CroZWZgm.js +0 -1
  162. package/dist/client/_coffre/assets/suspense-O8sP0mEC.js +0 -1
  163. package/dist/client/_coffre/assets/tokens._token-B_qczpT9.js +0 -2
  164. package/dist/client/_coffre/assets/tokens._token-T-sqwMbz.js +0 -2
  165. package/dist/client/_coffre/assets/tokens.index-CcXSZnAG.js +0 -1
  166. package/dist/client/_coffre/assets/ui-BXP2IqrW.js +0 -46
  167. package/dist/client/_coffre/assets/unregistered-D2JXJ90x.js +0 -1
  168. package/dist/client/_coffre/assets/use-action-BpzKWhgg.js +0 -1
  169. package/dist/client/_coffre/assets/use-change-CKj3Inq9.js +0 -1
  170. package/dist/client/_coffre/assets/use-shell-W0SusPkz.js +0 -1
  171. package/dist/client/_coffre/assets/useQuery-B-lxFSES.js +0 -1
  172. package/dist/client/_coffre/assets/useSuspenseQuery-BZ-nzHST.js +0 -1
  173. package/dist/client/_coffre/assets/users._user-Bb3BGYHl.js +0 -1
  174. package/dist/client/_coffre/assets/users._user-DXmvKrzE.js +0 -2
  175. package/dist/client/_coffre/assets/users.index-BvzP3qwW.js +0 -1
  176. package/dist/client/_coffre/assets/validation-9Cl_XS-l.js +0 -1
  177. package/dist/server/.vite/manifest.json +0 -668
  178. package/dist/server/_coffre/assets/_tanstack-start-manifest_v-GsKnGGRy.js +0 -162
  179. package/dist/server/_coffre/assets/account-CV-a2IU2.js +0 -329
  180. package/dist/server/_coffre/assets/account-hk6wcIXU.js +0 -162
  181. package/dist/server/_coffre/assets/async-local-storage-C10uQtMM.js +0 -3108
  182. package/dist/server/_coffre/assets/audit-C1_Ej6YB.js +0 -31
  183. package/dist/server/_coffre/assets/auth.device-6JRrWbSV.js +0 -210
  184. package/dist/server/_coffre/assets/auth.device-CLoAxC2T.js +0 -29
  185. package/dist/server/_coffre/assets/directory-B-_rqsPx.js +0 -371
  186. package/dist/server/_coffre/assets/dist-CnnV3t2g.js +0 -908
  187. package/dist/server/_coffre/assets/empty-plugin-adapters-Cq4--YW-.js +0 -5
  188. package/dist/server/_coffre/assets/globals-CpMrgkV6.css +0 -1
  189. package/dist/server/_coffre/assets/icons-DOFT-eWB.js +0 -1704
  190. package/dist/server/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
  191. package/dist/server/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
  192. package/dist/server/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
  193. package/dist/server/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
  194. package/dist/server/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
  195. package/dist/server/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
  196. package/dist/server/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
  197. package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
  198. package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  199. package/dist/server/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  200. package/dist/server/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  201. package/dist/server/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  202. package/dist/server/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  203. package/dist/server/_coffre/assets/lazyRouteComponent-CqBNCGuZ.js +0 -480
  204. package/dist/server/_coffre/assets/link-42ZWdjzZ.js +0 -422
  205. package/dist/server/_coffre/assets/login-DRKUKkaW.js +0 -22
  206. package/dist/server/_coffre/assets/login-DnwxVl4Y.js +0 -102
  207. package/dist/server/_coffre/assets/matchContext-qLfYbC6_.js +0 -56
  208. package/dist/server/_coffre/assets/page-D6n45dcK.js +0 -3561
  209. package/dist/server/_coffre/assets/projects._project._environment-CS8DdSMY.js +0 -48
  210. package/dist/server/_coffre/assets/projects._project.index-BGfcNpj0.js +0 -23
  211. package/dist/server/_coffre/assets/react-dom-bBoJXlK2.js +0 -1718
  212. package/dist/server/_coffre/assets/router-9BTgJhWG.js +0 -2322
  213. package/dist/server/_coffre/assets/start-DR3rN0St.js +0 -4
  214. package/dist/server/_coffre/assets/suspense-C-2QfDd2.js +0 -602
  215. package/dist/server/_coffre/assets/tokens._token-rY86Cjgp.js +0 -10
  216. package/dist/server/_coffre/assets/tokens.index-Bq5qDW9q.js +0 -37
  217. package/dist/server/_coffre/assets/ui-Cc0CGMtr.js +0 -14881
  218. package/dist/server/_coffre/assets/unregistered-D9ZKLOPJ.js +0 -53
  219. package/dist/server/_coffre/assets/use-shell-DwOzEi87.js +0 -462
  220. package/dist/server/_coffre/assets/useQuery-CTe86qFq.js +0 -8
  221. package/dist/server/_coffre/assets/useRouter-CaUSUNsw.js +0 -473
  222. package/dist/server/_coffre/assets/useSuspenseQuery-CSoHzrMb.js +0 -117
  223. package/dist/server/_coffre/assets/users._user-BmLKYeo_.js +0 -10
  224. package/dist/server/_coffre/assets/users._user-BmiHwQx3.js +0 -14
  225. package/dist/server/_coffre/assets/users.index-BiEax90r.js +0 -37
  226. package/dist/server/index.js +0 -13911
  227. package/src/assets/favicon-32.png +0 -0
  228. package/src/components/agentation.tsx +0 -34
  229. package/src/entry.ts +0 -19
  230. package/src/routeTree.gen.ts +0 -367
  231. package/src/routes/__root.tsx +0 -169
  232. package/src/routes/access.tsx +0 -11
  233. package/src/routes/index.tsx +0 -15
  234. package/src/routes/users.$user.tsx +0 -13
  235. package/src/types.ts +0 -21
@@ -0,0 +1,405 @@
1
+ import { G as X, S as Loader, _ as Info, a as Check, n as AlertCircle, r as AlertTriangle, u as Copy } from "./icons-D-PfAfnH.js";
2
+ import { createContext, useContext, useEffect, useRef, useState } from "react";
3
+ import { Dialog } from "@base-ui/react/dialog";
4
+ import { Menu } from "@base-ui/react/menu";
5
+ import { PREFERENCE_COOKIES, preferencesIn } from "@coffre/core/pages";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { AlertDialog } from "@base-ui/react/alert-dialog";
8
+ import { Popover } from "@base-ui/react/popover";
9
+ import { Tooltip } from "@base-ui/react/tooltip";
10
+ //#region src/lib/preferences.tsx
11
+ /**
12
+ * The preferences in the browser's cookies, as the server read them in the
13
+ * request's: each is a cookie, so the server renders the page as the
14
+ * visitor left it, from the first byte, and the browser hydrates the same.
15
+ */
16
+ function browserPreferences() {
17
+ return preferencesIn(document.cookie);
18
+ }
19
+ /** Keep a choice for a year; the default, by removing it. */
20
+ function remember(name, value) {
21
+ document.cookie = value === null ? `${name}=; Path=/; SameSite=Lax; Max-Age=0` : `${name}=${value}; Path=/; SameSite=Lax; Max-Age=31536000`;
22
+ }
23
+ function rememberTheme(theme) {
24
+ remember(PREFERENCE_COOKIES.theme, theme === "system" ? null : theme);
25
+ }
26
+ function rememberSidebar(sidebar) {
27
+ remember(PREFERENCE_COOKIES.sidebar, sidebar === "collapsed" ? "collapsed" : null);
28
+ }
29
+ var PreferencesContext = createContext(null);
30
+ /** The visitor's preferences, and the switches, from `<CoffreProvider>`. */
31
+ function usePreferences() {
32
+ const value = useContext(PreferencesContext);
33
+ if (value === null) throw new Error("coffre's pages render inside <CoffreProvider>, in the app's root document");
34
+ return value;
35
+ }
36
+ //#endregion
37
+ //#region src/components/ui.tsx
38
+ function TooltipProvider({ children }) {
39
+ return /* @__PURE__ */ jsx(Tooltip.Provider, {
40
+ delay: 400,
41
+ timeout: 300,
42
+ children
43
+ });
44
+ }
45
+ function Tip({ label, side, children }) {
46
+ const { portal } = usePreferences();
47
+ return /* @__PURE__ */ jsxs(Tooltip.Root, { children: [/* @__PURE__ */ jsx(Tooltip.Trigger, { render: children }), /* @__PURE__ */ jsx(Tooltip.Portal, {
48
+ container: portal,
49
+ children: /* @__PURE__ */ jsx(Tooltip.Positioner, {
50
+ className: "tooltip-positioner",
51
+ side,
52
+ sideOffset: 6,
53
+ collisionPadding: 8,
54
+ children: /* @__PURE__ */ jsx(Tooltip.Popup, {
55
+ className: "tooltip",
56
+ children: label
57
+ })
58
+ })
59
+ })] });
60
+ }
61
+ /**
62
+ * The same bubble as Tip, for a note a touch screen must reach too.
63
+ *
64
+ * A tooltip opens on hover and focus only, so on a phone it never opens. This
65
+ * one also opens on a tap, which means its trigger has to be a real button.
66
+ * With a mouse, hover alone drives it: a click would otherwise close the note
67
+ * the hover just opened.
68
+ */
69
+ function Toggletip({ label, side, align, children }) {
70
+ const { portal } = usePreferences();
71
+ const [open, setOpen] = useState(false);
72
+ const mouse = useRef(false);
73
+ const hover = (next) => (event) => {
74
+ if (event.pointerType === "mouse") setOpen(next);
75
+ };
76
+ return /* @__PURE__ */ jsxs(Popover.Root, {
77
+ open,
78
+ onOpenChange: (next, { reason }) => {
79
+ const clicked = reason === "trigger-press" && mouse.current;
80
+ mouse.current = false;
81
+ if (!clicked) setOpen(next);
82
+ },
83
+ children: [/* @__PURE__ */ jsx(Popover.Trigger, {
84
+ render: children,
85
+ onPointerEnter: hover(true),
86
+ onPointerLeave: hover(false),
87
+ onPointerDown: (event) => {
88
+ mouse.current = event.pointerType === "mouse";
89
+ }
90
+ }), /* @__PURE__ */ jsx(Popover.Portal, {
91
+ container: portal,
92
+ children: /* @__PURE__ */ jsx(Popover.Positioner, {
93
+ className: "tooltip-positioner",
94
+ side,
95
+ align,
96
+ sideOffset: 6,
97
+ collisionPadding: 16,
98
+ children: /* @__PURE__ */ jsx(Popover.Popup, {
99
+ className: "tooltip",
100
+ initialFocus: false,
101
+ finalFocus: false,
102
+ children: label
103
+ })
104
+ })
105
+ })]
106
+ });
107
+ }
108
+ /**
109
+ * A menu's floating panel, placed against its `Menu.Trigger`.
110
+ *
111
+ * The callers keep the rest of Base UI's menu parts: the trigger, the items
112
+ * and their separators read better at the call site than behind props.
113
+ */
114
+ function MenuPopup({ side, align, className, children }) {
115
+ const { portal } = usePreferences();
116
+ return /* @__PURE__ */ jsx(Menu.Portal, {
117
+ container: portal,
118
+ children: /* @__PURE__ */ jsx(Menu.Positioner, {
119
+ className: "menu-positioner",
120
+ side,
121
+ align,
122
+ sideOffset: 6,
123
+ children: /* @__PURE__ */ jsx(Menu.Popup, {
124
+ className: className === void 0 ? "menu" : `menu ${className}`,
125
+ children
126
+ })
127
+ })
128
+ });
129
+ }
130
+ function Spinner({ size = 14 }) {
131
+ return /* @__PURE__ */ jsx(Loader, {
132
+ size,
133
+ className: "spinner"
134
+ });
135
+ }
136
+ function ErrorLine({ error }) {
137
+ if (error === null) return null;
138
+ return /* @__PURE__ */ jsxs("p", {
139
+ className: "error-line",
140
+ role: "alert",
141
+ children: [/* @__PURE__ */ jsx(AlertCircle, { size: 14 }), /* @__PURE__ */ jsx("span", { children: error })]
142
+ });
143
+ }
144
+ var NOTICE_ICON = {
145
+ info: Info,
146
+ good: Check,
147
+ bad: AlertTriangle,
148
+ neutral: Info
149
+ };
150
+ function Notice({ tone = "neutral", children }) {
151
+ const Icon = NOTICE_ICON[tone];
152
+ return /* @__PURE__ */ jsxs("div", {
153
+ className: `notice${tone === "neutral" ? "" : ` notice-${tone}`}`,
154
+ role: tone === "bad" ? "alert" : void 0,
155
+ children: [/* @__PURE__ */ jsx(Icon, { size: 16 }), /* @__PURE__ */ jsx("div", { children })]
156
+ });
157
+ }
158
+ /**
159
+ * Nothing here yet, said in a sentence.
160
+ *
161
+ * It sits where the table would have been, left-aligned like the rows it
162
+ * stands in for, rather than as a centred illustration.
163
+ */
164
+ function EmptyState({ title, children, actions }) {
165
+ return /* @__PURE__ */ jsxs("div", {
166
+ className: "empty",
167
+ children: [
168
+ /* @__PURE__ */ jsx("p", {
169
+ className: "empty-title",
170
+ children: title
171
+ }),
172
+ children !== void 0 && /* @__PURE__ */ jsx("p", {
173
+ className: "empty-body",
174
+ children
175
+ }),
176
+ actions !== void 0 && /* @__PURE__ */ jsx("div", {
177
+ className: "empty-actions",
178
+ children: actions
179
+ })
180
+ ]
181
+ });
182
+ }
183
+ /**
184
+ * An identifier that wraps after its underscores rather than mid-word.
185
+ *
186
+ * To the line breaker `DOCUSIGN_INTEGRATION_KEY` is one word, so a narrow
187
+ * column cuts it wherever room runs out (`…_KE` / `Y`). A <wbr> after each
188
+ * underscore offers the natural places instead. Copied text is unchanged, and
189
+ * `overflow-wrap: anywhere` still catches a segment too long for any line.
190
+ */
191
+ function breakAfterUnderscores(text) {
192
+ return text.split("_").flatMap((part, index) => index === 0 ? [part] : [
193
+ "_",
194
+ /* @__PURE__ */ jsx("wbr", {}, index),
195
+ part
196
+ ]);
197
+ }
198
+ /**
199
+ * Copy to clipboard with a settled confirmation.
200
+ *
201
+ * The glyph turns into a check, and screen readers hear "Copied", for 1.4s --
202
+ * long enough to be noticed after the eye has moved on, short enough not to
203
+ * look stuck.
204
+ */
205
+ function CopyButton({ value, label = "Copy", variant = "icon" }) {
206
+ const [copied, setCopied] = useState(false);
207
+ const timer = useRef(null);
208
+ useEffect(() => () => {
209
+ if (timer.current !== null) clearTimeout(timer.current);
210
+ }, []);
211
+ async function copy() {
212
+ try {
213
+ await navigator.clipboard.writeText(value);
214
+ } catch {
215
+ return;
216
+ }
217
+ setCopied(true);
218
+ if (timer.current !== null) clearTimeout(timer.current);
219
+ timer.current = setTimeout(() => setCopied(false), 1400);
220
+ }
221
+ return /* @__PURE__ */ jsx(Tip, {
222
+ label: copied ? "Copied" : label,
223
+ children: /* @__PURE__ */ jsxs("button", {
224
+ type: "button",
225
+ className: variant === "act" ? "act act-icon" : "btn btn-quiet btn-sm btn-icon",
226
+ "aria-label": label,
227
+ onClick: copy,
228
+ children: [copied ? /* @__PURE__ */ jsx(Check, {
229
+ size: 14,
230
+ className: "copied"
231
+ }) : /* @__PURE__ */ jsx(Copy, { size: 14 }), /* @__PURE__ */ jsx("span", {
232
+ className: "visually-hidden",
233
+ "aria-live": "polite",
234
+ children: copied ? "Copied" : ""
235
+ })]
236
+ })
237
+ });
238
+ }
239
+ function ConfirmContent({ title, body, confirmLabel, destructive, onConfirm }) {
240
+ const { portal } = usePreferences();
241
+ return /* @__PURE__ */ jsxs(AlertDialog.Portal, {
242
+ container: portal,
243
+ children: [/* @__PURE__ */ jsx(AlertDialog.Backdrop, { className: "overlay" }), /* @__PURE__ */ jsxs(AlertDialog.Popup, {
244
+ className: "dialog dialog-confirm",
245
+ children: [
246
+ /* @__PURE__ */ jsx(AlertDialog.Title, {
247
+ className: "dialog-title",
248
+ children: title
249
+ }),
250
+ /* @__PURE__ */ jsx(AlertDialog.Description, {
251
+ className: "dialog-body",
252
+ children: body
253
+ }),
254
+ /* @__PURE__ */ jsxs("div", {
255
+ className: "dialog-actions",
256
+ children: [/* @__PURE__ */ jsx(AlertDialog.Close, {
257
+ className: "btn",
258
+ children: "Cancel"
259
+ }), /* @__PURE__ */ jsx(AlertDialog.Close, {
260
+ className: `btn ${destructive === false ? "btn-primary" : "btn-danger"}`,
261
+ onClick: onConfirm,
262
+ children: confirmLabel
263
+ })]
264
+ })
265
+ ]
266
+ })]
267
+ });
268
+ }
269
+ function ConfirmButton({ trigger, disabled, ...confirm }) {
270
+ return /* @__PURE__ */ jsxs(AlertDialog.Root, { children: [/* @__PURE__ */ jsx(AlertDialog.Trigger, {
271
+ render: trigger,
272
+ disabled
273
+ }), /* @__PURE__ */ jsx(ConfirmContent, { ...confirm })] });
274
+ }
275
+ /**
276
+ * The same confirmation, opened from something that is not a trigger.
277
+ *
278
+ * A menu item cannot be one: it unmounts as the menu closes, taking the dialog
279
+ * with it. So the caller keeps the open state and the dialog lives outside the
280
+ * menu entirely.
281
+ */
282
+ function ConfirmDialog({ open, onOpenChange, ...confirm }) {
283
+ return /* @__PURE__ */ jsx(AlertDialog.Root, {
284
+ open,
285
+ onOpenChange,
286
+ children: /* @__PURE__ */ jsx(ConfirmContent, { ...confirm })
287
+ });
288
+ }
289
+ /**
290
+ * A plain modal, for a task you chose to begin.
291
+ *
292
+ * Distinct from ConfirmButton: that one interrupts to ask about something you
293
+ * already started, this one holds a form.
294
+ */
295
+ function Modal({ open, onOpenChange, title, description, wide = false, children }) {
296
+ const { portal } = usePreferences();
297
+ return /* @__PURE__ */ jsx(Dialog.Root, {
298
+ open,
299
+ onOpenChange,
300
+ children: /* @__PURE__ */ jsxs(Dialog.Portal, {
301
+ container: portal,
302
+ children: [/* @__PURE__ */ jsx(Dialog.Backdrop, { className: "overlay" }), /* @__PURE__ */ jsxs(Dialog.Popup, {
303
+ className: `dialog${wide ? " dialog-wide" : ""}`,
304
+ children: [
305
+ /* @__PURE__ */ jsxs("div", {
306
+ className: "dialog-head",
307
+ children: [/* @__PURE__ */ jsx(Dialog.Title, {
308
+ className: "dialog-title",
309
+ children: title
310
+ }), /* @__PURE__ */ jsx(Dialog.Close, {
311
+ className: "btn btn-quiet btn-sm btn-icon",
312
+ "aria-label": "Close",
313
+ children: /* @__PURE__ */ jsx(X, { size: 15 })
314
+ })]
315
+ }),
316
+ description !== void 0 && /* @__PURE__ */ jsx(Dialog.Description, {
317
+ className: "dialog-body",
318
+ children: description
319
+ }),
320
+ children
321
+ ]
322
+ })]
323
+ })
324
+ });
325
+ }
326
+ var RELATIVE_STEPS = [
327
+ [
328
+ 60,
329
+ 1,
330
+ "second"
331
+ ],
332
+ [
333
+ 3600,
334
+ 60,
335
+ "minute"
336
+ ],
337
+ [
338
+ 86400,
339
+ 3600,
340
+ "hour"
341
+ ],
342
+ [
343
+ 2592e3,
344
+ 86400,
345
+ "day"
346
+ ],
347
+ [
348
+ 31536e3,
349
+ 2592e3,
350
+ "month"
351
+ ],
352
+ [
353
+ Infinity,
354
+ 31536e3,
355
+ "year"
356
+ ]
357
+ ];
358
+ function relative(iso, now, style = "long") {
359
+ const delta = (new Date(iso).getTime() - now) / 1e3;
360
+ const magnitude = Math.abs(delta);
361
+ const [, divisor, unit] = RELATIVE_STEPS.find(([limit]) => magnitude < limit);
362
+ return new Intl.RelativeTimeFormat("en", {
363
+ numeric: "auto",
364
+ style
365
+ }).format(Math.round(delta / divisor), unit);
366
+ }
367
+ function absolute(iso, precise) {
368
+ return iso.replace("T", " ").replace("Z", "").slice(0, precise ? 23 : 19);
369
+ }
370
+ /**
371
+ * A timestamp. Absolute UTC by default, "3 hours ago" on hover.
372
+ *
373
+ * Absolute is the default on purpose: in the audit log this is evidence, and
374
+ * someone reading it is often transcribing it into a finding. `relative` flips
375
+ * the two, in the short form ("5h ago"), for glanceable metadata like "last
376
+ * written". The relative form can
377
+ * differ between server and client by a rounding step, so that one text node
378
+ * opts out of the hydration check rather than render a placeholder first.
379
+ */
380
+ function Timestamp({ iso, precise = false, display = "absolute" }) {
381
+ const [now, setNow] = useState(null);
382
+ useEffect(() => setNow(Date.now()), [iso]);
383
+ if (display === "relative") return /* @__PURE__ */ jsx(Tip, {
384
+ label: `${absolute(iso, precise)} UTC`,
385
+ children: /* @__PURE__ */ jsx("time", {
386
+ dateTime: iso,
387
+ suppressHydrationWarning: true,
388
+ children: relative(iso, now ?? Date.now(), "narrow")
389
+ })
390
+ });
391
+ const body = /* @__PURE__ */ jsx("time", {
392
+ className: "mono",
393
+ dateTime: iso,
394
+ children: absolute(iso, precise)
395
+ });
396
+ if (now === null) return body;
397
+ return /* @__PURE__ */ jsx(Tip, {
398
+ label: relative(iso, now),
399
+ children: body
400
+ });
401
+ }
402
+ //#endregion
403
+ export { rememberSidebar as _, ErrorLine as a, Notice as c, Tip as d, Toggletip as f, browserPreferences as g, PreferencesContext as h, EmptyState as i, Spinner as l, breakAfterUnderscores as m, ConfirmDialog as n, MenuPopup as o, TooltipProvider as p, CopyButton as r, Modal as s, ConfirmButton as t, Timestamp as u, rememberTheme as v, usePreferences as y };
404
+
405
+ //# sourceMappingURL=ui-DixXLQvQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui-DixXLQvQ.js","names":[],"sources":["../../src/lib/preferences.tsx","../../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","import { useEffect, useRef, useState, 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 { 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 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.\n */\nexport function CopyButton({\n value,\n label = 'Copy',\n variant = 'icon',\n}: {\n value: string;\n label?: string;\n /** `act` sits among a table row's actions; `icon` anywhere else. */\n variant?: 'icon' | 'act';\n}) {\n const [copied, setCopied] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => () => {\n if (timer.current !== null) clearTimeout(timer.current);\n }, []);\n\n async function copy() {\n try {\n await navigator.clipboard.writeText(value);\n } catch {\n return; // Clipboard denied; say nothing rather than claim success.\n }\n setCopied(true);\n if (timer.current !== null) clearTimeout(timer.current);\n timer.current = setTimeout(() => setCopied(false), 1400);\n }\n\n return (\n <Tip label={copied ? 'Copied' : label}>\n <button\n type=\"button\"\n className={variant === 'act' ? 'act act-icon' : 'btn btn-quiet btn-sm btn-icon'}\n aria-label={label}\n onClick={copy}\n >\n {copied ? <Check size={14} className=\"copied\" /> : <Copy size={14} />}\n <span className=\"visually-hidden\" aria-live=\"polite\">\n {copied ? 'Copied' : ''}\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 confirmLabel: string;\n destructive?: boolean;\n onConfirm: () => void;\n};\n\nfunction ConfirmContent({ title, body, confirmLabel, destructive, 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 <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 >\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\nfunction 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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AAE;AAC1E;;;;;;;;;;;AAYA,SAAgB,UAAU,EACxB,KACA,UAAU,OACV,UAAU,cAKT;CACD,MAAM,CAAC,KAAK,UAAU,SAAwB,IAAI;CAClD,gBAAgB,OAAO,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;CAEzC,IAAI,YAAY,YACd,OACE,oBAAC,KAAD;EAAK,OAAO,GAAG,SAAS,KAAK,OAAO,EAAE;YACpC,oBAAC,QAAD;GAAM,UAAU;GAAK,0BAAA;aAClB,SAAS,KAAK,OAAO,KAAK,IAAI,GAAG,QAAQ;EACtC,CAAA;CACH,CAAA;CAIT,MAAM,OACJ,oBAAC,QAAD;EAAM,WAAU;EAAO,UAAU;YAC9B,SAAS,KAAK,OAAO;CAClB,CAAA;CAER,IAAI,QAAQ,MAAM,OAAO;CACzB,OAAO,oBAAC,KAAD;EAAK,OAAO,SAAS,KAAK,GAAG;YAAI;CAAU,CAAA;AACpD"}
@@ -1,8 +1,8 @@
1
- import { i as require_react, s as __toESM } from "./useRouter-CaUSUNsw.js";
2
- import { g as refresh, y as failureMessage } from "./page-D6n45dcK.js";
3
- import { f as useQueryClient } from "./suspense-C-2QfDd2.js";
1
+ import { o as failureMessage } from "./page-C5HcNqf2.js";
2
+ import { d as refresh } from "./queries-CQ81o4so.js";
3
+ import { useState } from "react";
4
+ import { useQueryClient } from "@tanstack/react-query";
4
5
  //#region src/lib/use-action.ts
5
- var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
6
6
  /**
7
7
  * Run a change against the API, then refetch what it touched. A failed call
8
8
  * leaves the page as it was and says why, in `error`.
@@ -15,8 +15,8 @@ var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
15
15
  */
16
16
  function useAction() {
17
17
  const queryClient = useQueryClient();
18
- const [pending, setPending] = (0, import_react.useState)(false);
19
- const [error, setError] = (0, import_react.useState)(null);
18
+ const [pending, setPending] = useState(false);
19
+ const [error, setError] = useState(null);
20
20
  async function run(fn, { affects, onSuccess }) {
21
21
  setPending(true);
22
22
  let result;
@@ -45,3 +45,5 @@ function useAction() {
45
45
  }
46
46
  //#endregion
47
47
  export { useAction as t };
48
+
49
+ //# sourceMappingURL=use-action-CWsg_YWU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-action-CWsg_YWU.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"}