@better-auth-ui/heroui 1.6.7 → 1.6.9

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 (280) hide show
  1. package/dist/components/auth/additional-field.d.ts +2 -2
  2. package/dist/components/auth/additional-field.js +133 -266
  3. package/dist/components/auth/api-key/api-key-skeleton.js +4 -20
  4. package/dist/components/auth/api-key/api-key.d.ts +6 -2
  5. package/dist/components/auth/api-key/api-key.js +16 -54
  6. package/dist/components/auth/api-key/api-keys-empty.d.ts +3 -1
  7. package/dist/components/auth/api-key/api-keys-empty.js +8 -34
  8. package/dist/components/auth/api-key/api-keys.d.ts +10 -2
  9. package/dist/components/auth/api-key/api-keys.js +21 -40
  10. package/dist/components/auth/api-key/create-api-key-dialog.d.ts +3 -1
  11. package/dist/components/auth/api-key/create-api-key-dialog.js +43 -73
  12. package/dist/components/auth/api-key/delete-api-key-dialog.d.ts +4 -2
  13. package/dist/components/auth/api-key/delete-api-key-dialog.js +16 -50
  14. package/dist/components/auth/api-key/new-api-key-dialog.js +23 -59
  15. package/dist/components/auth/api-key/organization-api-keys.d.ts +14 -0
  16. package/dist/components/auth/api-key/organization-api-keys.js +22 -0
  17. package/dist/components/auth/auth-provider.d.ts +1 -1
  18. package/dist/components/auth/auth-provider.js +10 -16
  19. package/dist/components/auth/auth.d.ts +3 -3
  20. package/dist/components/auth/auth.js +86 -61
  21. package/dist/components/auth/delete-user/danger-zone.d.ts +3 -3
  22. package/dist/components/auth/delete-user/danger-zone.js +11 -17
  23. package/dist/components/auth/delete-user/delete-account.d.ts +9 -0
  24. package/dist/components/auth/delete-user/delete-account.js +50 -0
  25. package/dist/components/auth/email/email-changed-email.d.ts +2 -2
  26. package/dist/components/auth/email/email-changed-email.js +22 -29
  27. package/dist/components/auth/email/email-verification-email.d.ts +2 -2
  28. package/dist/components/auth/email/email-verification-email.js +22 -29
  29. package/dist/components/auth/email/magic-link-email.d.ts +2 -2
  30. package/dist/components/auth/email/magic-link-email.js +22 -29
  31. package/dist/components/auth/email/new-device-email.d.ts +2 -2
  32. package/dist/components/auth/email/new-device-email.js +22 -29
  33. package/dist/components/auth/email/organization-invitation-email.d.ts +3 -0
  34. package/dist/components/auth/email/organization-invitation-email.js +23 -0
  35. package/dist/components/auth/email/otp-email.d.ts +2 -2
  36. package/dist/components/auth/email/otp-email.js +21 -28
  37. package/dist/components/auth/email/password-changed-email.d.ts +2 -2
  38. package/dist/components/auth/email/password-changed-email.js +22 -29
  39. package/dist/components/auth/email/reset-password-email.d.ts +2 -2
  40. package/dist/components/auth/email/reset-password-email.js +22 -29
  41. package/dist/components/auth/error-toaster.js +32 -16
  42. package/dist/components/auth/field-separator.d.ts +1 -1
  43. package/dist/components/auth/field-separator.js +4 -17
  44. package/dist/components/auth/forgot-password.d.ts +1 -1
  45. package/dist/components/auth/forgot-password.js +36 -88
  46. package/dist/components/auth/magic-link/magic-link-button.d.ts +1 -1
  47. package/dist/components/auth/magic-link/magic-link-button.js +33 -19
  48. package/dist/components/auth/magic-link/magic-link.d.ts +2 -2
  49. package/dist/components/auth/magic-link/magic-link.js +39 -86
  50. package/dist/components/auth/multi-session/manage-account.d.ts +1 -1
  51. package/dist/components/auth/multi-session/manage-account.js +32 -48
  52. package/dist/components/auth/multi-session/manage-accounts.d.ts +1 -1
  53. package/dist/components/auth/multi-session/manage-accounts.js +32 -33
  54. package/dist/components/auth/multi-session/switch-account-submenu-content.d.ts +3 -1
  55. package/dist/components/auth/multi-session/switch-account-submenu-content.js +24 -27
  56. package/dist/components/auth/multi-session/switch-account-submenu-item.d.ts +3 -2
  57. package/dist/components/auth/multi-session/switch-account-submenu-item.js +16 -19
  58. package/dist/components/auth/multi-session/switch-account-submenu.d.ts +2 -1
  59. package/dist/components/auth/multi-session/switch-account-submenu.js +23 -23
  60. package/dist/components/auth/organization/change-organization-logo.d.ts +4 -0
  61. package/dist/components/auth/organization/change-organization-logo.js +69 -0
  62. package/dist/components/auth/organization/create-organization-dialog.d.ts +13 -0
  63. package/dist/components/auth/organization/create-organization-dialog.js +37 -0
  64. package/dist/components/auth/organization/delete-organization-dialog.d.ts +7 -0
  65. package/dist/components/auth/organization/delete-organization-dialog.js +25 -0
  66. package/dist/components/auth/organization/delete-organization-skeleton.d.ts +4 -0
  67. package/dist/components/auth/organization/delete-organization-skeleton.js +8 -0
  68. package/dist/components/auth/organization/delete-organization.d.ts +5 -0
  69. package/dist/components/auth/organization/delete-organization.js +27 -0
  70. package/dist/components/auth/organization/invite-member-dialog.d.ts +13 -0
  71. package/dist/components/auth/organization/invite-member-dialog.js +47 -0
  72. package/dist/components/auth/organization/leave-organization-dialog.d.ts +7 -0
  73. package/dist/components/auth/organization/leave-organization-dialog.js +21 -0
  74. package/dist/components/auth/organization/leave-organization.d.ts +4 -0
  75. package/dist/components/auth/organization/leave-organization.js +16 -0
  76. package/dist/components/auth/organization/organization-danger-zone.d.ts +16 -0
  77. package/dist/components/auth/organization/organization-danger-zone.js +23 -0
  78. package/dist/components/auth/organization/organization-invitation-row-skeleton.d.ts +5 -0
  79. package/dist/components/auth/organization/organization-invitation-row-skeleton.js +9 -0
  80. package/dist/components/auth/organization/organization-invitation-row.d.ts +5 -0
  81. package/dist/components/auth/organization/organization-invitation-row.js +31 -0
  82. package/dist/components/auth/organization/organization-invitations-empty.d.ts +8 -0
  83. package/dist/components/auth/organization/organization-invitations-empty.js +13 -0
  84. package/dist/components/auth/organization/organization-invitations.d.ts +9 -0
  85. package/dist/components/auth/organization/organization-invitations.js +66 -0
  86. package/dist/components/auth/organization/organization-logo.d.ts +15 -0
  87. package/dist/components/auth/organization/organization-logo.js +14 -0
  88. package/dist/components/auth/organization/organization-member-row-skeleton.d.ts +4 -0
  89. package/dist/components/auth/organization/organization-member-row-skeleton.js +9 -0
  90. package/dist/components/auth/organization/organization-member-row.d.ts +9 -0
  91. package/dist/components/auth/organization/organization-member-row.js +34 -0
  92. package/dist/components/auth/organization/organization-members.d.ts +9 -0
  93. package/dist/components/auth/organization/organization-members.js +67 -0
  94. package/dist/components/auth/organization/organization-people.d.ts +10 -0
  95. package/dist/components/auth/organization/organization-people.js +11 -0
  96. package/dist/components/auth/organization/organization-profile.d.ts +9 -0
  97. package/dist/components/auth/organization/organization-profile.js +34 -0
  98. package/dist/components/auth/organization/organization-row.d.ts +8 -0
  99. package/dist/components/auth/organization/organization-row.js +31 -0
  100. package/dist/components/auth/organization/organization-settings.d.ts +12 -0
  101. package/dist/components/auth/organization/organization-settings.js +13 -0
  102. package/dist/components/auth/organization/organization-switcher.d.ts +20 -0
  103. package/dist/components/auth/organization/organization-switcher.js +48 -0
  104. package/dist/components/auth/organization/organization-view-skeleton.d.ts +6 -0
  105. package/dist/components/auth/organization/organization-view-skeleton.js +9 -0
  106. package/dist/components/auth/organization/organization-view.d.ts +15 -0
  107. package/dist/components/auth/organization/organization-view.js +31 -0
  108. package/dist/components/auth/organization/organization.d.ts +17 -0
  109. package/dist/components/auth/organization/organization.js +60 -0
  110. package/dist/components/auth/organization/organizations-empty.d.ts +4 -0
  111. package/dist/components/auth/organization/organizations-empty.js +9 -0
  112. package/dist/components/auth/organization/organizations-settings.d.ts +17 -0
  113. package/dist/components/auth/organization/organizations-settings.js +17 -0
  114. package/dist/components/auth/organization/organizations.d.ts +10 -0
  115. package/dist/components/auth/organization/organizations.js +21 -0
  116. package/dist/components/auth/organization/remove-member-dialog.d.ts +9 -0
  117. package/dist/components/auth/organization/remove-member-dialog.js +20 -0
  118. package/dist/components/auth/organization/slug-field.d.ts +19 -0
  119. package/dist/components/auth/organization/slug-field.js +38 -0
  120. package/dist/components/auth/organization/user-invitation-row-skeleton.d.ts +4 -0
  121. package/dist/components/auth/organization/user-invitation-row-skeleton.js +8 -0
  122. package/dist/components/auth/organization/user-invitation-row.d.ts +10 -0
  123. package/dist/components/auth/organization/user-invitation-row.js +22 -0
  124. package/dist/components/auth/organization/user-invitations-empty.d.ts +4 -0
  125. package/dist/components/auth/organization/user-invitations-empty.js +12 -0
  126. package/dist/components/auth/organization/user-invitations.d.ts +10 -0
  127. package/dist/components/auth/organization/user-invitations.js +18 -0
  128. package/dist/components/auth/passkey/add-passkey-dialog.d.ts +5 -0
  129. package/dist/components/auth/passkey/add-passkey-dialog.js +22 -0
  130. package/dist/components/auth/passkey/delete-passkey-dialog.d.ts +11 -0
  131. package/dist/components/auth/passkey/delete-passkey-dialog.js +14 -0
  132. package/dist/components/auth/passkey/passkey-button.d.ts +1 -1
  133. package/dist/components/auth/passkey/passkey-button.js +24 -23
  134. package/dist/components/auth/passkey/passkey-skeleton.d.ts +1 -0
  135. package/dist/components/auth/passkey/passkey-skeleton.js +5 -0
  136. package/dist/components/auth/passkey/passkey.d.ts +2 -5
  137. package/dist/components/auth/passkey/passkey.js +16 -44
  138. package/dist/components/auth/passkey/passkeys-empty.d.ts +4 -0
  139. package/dist/components/auth/passkey/passkeys-empty.js +9 -0
  140. package/dist/components/auth/passkey/passkeys.d.ts +1 -1
  141. package/dist/components/auth/passkey/passkeys.js +15 -105
  142. package/dist/components/auth/provider-button.d.ts +2 -2
  143. package/dist/components/auth/provider-button.js +28 -24
  144. package/dist/components/auth/provider-buttons.js +28 -18
  145. package/dist/components/auth/reset-password.d.ts +1 -1
  146. package/dist/components/auth/reset-password.js +56 -146
  147. package/dist/components/auth/settings/account/account-settings.d.ts +2 -2
  148. package/dist/components/auth/settings/account/account-settings.js +21 -19
  149. package/dist/components/auth/settings/account/change-avatar.js +53 -88
  150. package/dist/components/auth/settings/account/change-email.d.ts +1 -1
  151. package/dist/components/auth/settings/account/change-email.js +27 -53
  152. package/dist/components/auth/settings/account/user-profile.d.ts +1 -1
  153. package/dist/components/auth/settings/account/user-profile.js +64 -85
  154. package/dist/components/auth/settings/security/active-session.d.ts +1 -1
  155. package/dist/components/auth/settings/security/active-session.js +50 -57
  156. package/dist/components/auth/settings/security/active-sessions.d.ts +1 -1
  157. package/dist/components/auth/settings/security/active-sessions.js +21 -32
  158. package/dist/components/auth/settings/security/change-password.d.ts +1 -1
  159. package/dist/components/auth/settings/security/change-password.js +76 -186
  160. package/dist/components/auth/settings/security/linked-account.d.ts +1 -1
  161. package/dist/components/auth/settings/security/linked-account.js +37 -55
  162. package/dist/components/auth/settings/security/linked-accounts.d.ts +1 -1
  163. package/dist/components/auth/settings/security/linked-accounts.js +34 -43
  164. package/dist/components/auth/settings/security/security-settings.d.ts +2 -2
  165. package/dist/components/auth/settings/security/security-settings.js +19 -21
  166. package/dist/components/auth/settings/settings.d.ts +4 -4
  167. package/dist/components/auth/settings/settings.js +52 -44
  168. package/dist/components/auth/sign-in.d.ts +2 -2
  169. package/dist/components/auth/sign-in.js +63 -132
  170. package/dist/components/auth/sign-out.js +32 -26
  171. package/dist/components/auth/sign-up.d.ts +2 -2
  172. package/dist/components/auth/sign-up.js +97 -211
  173. package/dist/components/auth/theme/appearance.d.ts +1 -1
  174. package/dist/components/auth/theme/appearance.js +23 -71
  175. package/dist/components/auth/theme/theme-toggle-item.js +56 -61
  176. package/dist/components/auth/user/user-avatar.d.ts +4 -4
  177. package/dist/components/auth/user/user-avatar.js +31 -28
  178. package/dist/components/auth/user/user-button.d.ts +6 -7
  179. package/dist/components/auth/user/user-button.js +38 -72
  180. package/dist/components/auth/user/user-view.d.ts +13 -7
  181. package/dist/components/auth/user/user-view.js +26 -36
  182. package/dist/components/auth/username/sign-in-username.d.ts +2 -2
  183. package/dist/components/auth/username/sign-in-username.js +87 -147
  184. package/dist/components/auth/username/username-field.d.ts +1 -1
  185. package/dist/components/auth/username/username-field.js +44 -52
  186. package/dist/email.d.ts +8 -7
  187. package/dist/email.js +8 -8
  188. package/dist/index.d.ts +21 -21
  189. package/dist/index.js +21 -22
  190. package/dist/lib/auth/api-key-plugin.d.ts +7 -4
  191. package/dist/lib/auth/api-key-plugin.js +12 -10
  192. package/dist/lib/auth/auth-plugin.d.ts +10 -6
  193. package/dist/lib/auth/auth-plugin.js +1 -0
  194. package/dist/lib/auth/delete-user-plugin.d.ts +6 -6
  195. package/dist/lib/auth/delete-user-plugin.js +6 -9
  196. package/dist/lib/auth/magic-link-plugin.d.ts +5 -5
  197. package/dist/lib/auth/magic-link-plugin.js +17 -12
  198. package/dist/lib/auth/multi-session-plugin.d.ts +5 -5
  199. package/dist/lib/auth/multi-session-plugin.js +8 -11
  200. package/dist/lib/auth/organization-plugin.d.ts +37 -0
  201. package/dist/lib/auth/organization-plugin.js +19 -0
  202. package/dist/lib/auth/passkey-plugin.d.ts +9 -6
  203. package/dist/lib/auth/passkey-plugin.js +8 -11
  204. package/dist/lib/auth/theme-plugin.d.ts +6 -6
  205. package/dist/lib/auth/theme-plugin.js +25 -22
  206. package/dist/lib/auth/username-plugin.d.ts +11 -11
  207. package/dist/lib/auth/username-plugin.js +18 -17
  208. package/dist/plugins.d.ts +46 -22
  209. package/dist/plugins.js +47 -22
  210. package/package.json +25 -19
  211. package/src/components/auth/api-key/api-key.tsx +25 -16
  212. package/src/components/auth/api-key/api-keys-empty.tsx +8 -4
  213. package/src/components/auth/api-key/api-keys.tsx +52 -14
  214. package/src/components/auth/api-key/create-api-key-dialog.tsx +17 -4
  215. package/src/components/auth/api-key/delete-api-key-dialog.tsx +10 -2
  216. package/src/components/auth/api-key/organization-api-keys.tsx +55 -0
  217. package/src/components/auth/delete-user/danger-zone.tsx +3 -3
  218. package/src/components/auth/delete-user/{delete-user.tsx → delete-account.tsx} +9 -9
  219. package/src/components/auth/email/organization-invitation-email.tsx +38 -0
  220. package/src/components/auth/error-toaster.tsx +28 -10
  221. package/src/components/auth/forgot-password.tsx +10 -2
  222. package/src/components/auth/multi-session/manage-accounts.tsx +1 -1
  223. package/src/components/auth/multi-session/switch-account-submenu-content.tsx +7 -2
  224. package/src/components/auth/multi-session/switch-account-submenu-item.tsx +4 -2
  225. package/src/components/auth/multi-session/switch-account-submenu.tsx +8 -4
  226. package/src/components/auth/organization/change-organization-logo.tsx +171 -0
  227. package/src/components/auth/organization/create-organization-dialog.tsx +133 -0
  228. package/src/components/auth/organization/delete-organization-dialog.tsx +97 -0
  229. package/src/components/auth/organization/delete-organization-skeleton.tsx +17 -0
  230. package/src/components/auth/organization/delete-organization.tsx +77 -0
  231. package/src/components/auth/organization/invite-member-dialog.tsx +177 -0
  232. package/src/components/auth/organization/leave-organization-dialog.tsx +95 -0
  233. package/src/components/auth/organization/leave-organization.tsx +59 -0
  234. package/src/components/auth/organization/organization-danger-zone.tsx +68 -0
  235. package/src/components/auth/organization/organization-invitation-row-skeleton.tsx +29 -0
  236. package/src/components/auth/organization/organization-invitation-row.tsx +97 -0
  237. package/src/components/auth/organization/organization-invitations-empty.tsx +39 -0
  238. package/src/components/auth/organization/organization-invitations.tsx +351 -0
  239. package/src/components/auth/organization/organization-logo.tsx +64 -0
  240. package/src/components/auth/organization/organization-member-row-skeleton.tsx +24 -0
  241. package/src/components/auth/organization/organization-member-row.tsx +157 -0
  242. package/src/components/auth/organization/organization-members.tsx +284 -0
  243. package/src/components/auth/organization/organization-people.tsx +26 -0
  244. package/src/components/auth/organization/organization-profile.tsx +141 -0
  245. package/src/components/auth/organization/organization-row.tsx +66 -0
  246. package/src/components/auth/organization/organization-settings.tsx +38 -0
  247. package/src/components/auth/organization/organization-switcher.tsx +233 -0
  248. package/src/components/auth/organization/organization-view-skeleton.tsx +36 -0
  249. package/src/components/auth/organization/organization-view.tsx +109 -0
  250. package/src/components/auth/organization/organization.tsx +162 -0
  251. package/src/components/auth/organization/organizations-empty.tsx +35 -0
  252. package/src/components/auth/organization/organizations-settings.tsx +36 -0
  253. package/src/components/auth/organization/organizations.tsx +80 -0
  254. package/src/components/auth/organization/remove-member-dialog.tsx +95 -0
  255. package/src/components/auth/organization/slug-field.tsx +111 -0
  256. package/src/components/auth/organization/user-invitation-row-skeleton.tsx +17 -0
  257. package/src/components/auth/organization/user-invitation-row.tsx +90 -0
  258. package/src/components/auth/organization/user-invitations-empty.tsx +30 -0
  259. package/src/components/auth/organization/user-invitations.tsx +59 -0
  260. package/src/components/auth/passkey/add-passkey-dialog.tsx +109 -0
  261. package/src/components/auth/passkey/delete-passkey-dialog.tsx +95 -0
  262. package/src/components/auth/passkey/passkey-skeleton.tsx +16 -0
  263. package/src/components/auth/passkey/passkey.tsx +23 -22
  264. package/src/components/auth/passkey/passkeys-empty.tsx +35 -0
  265. package/src/components/auth/passkey/passkeys.tsx +33 -154
  266. package/src/components/auth/settings/account/change-email.tsx +1 -1
  267. package/src/components/auth/settings/account/user-profile.tsx +5 -5
  268. package/src/components/auth/settings/security/active-sessions.tsx +6 -4
  269. package/src/components/auth/settings/security/linked-accounts.tsx +2 -2
  270. package/src/components/auth/settings/settings.tsx +77 -14
  271. package/src/components/auth/user/user-avatar.tsx +4 -1
  272. package/src/components/auth/user/user-button.tsx +14 -11
  273. package/src/components/auth/user/user-view.tsx +32 -12
  274. package/src/email.ts +1 -0
  275. package/src/lib/auth/api-key-plugin.ts +10 -4
  276. package/src/lib/auth/auth-plugin.ts +6 -1
  277. package/src/lib/auth/organization-plugin.tsx +32 -0
  278. package/src/plugins.ts +25 -1
  279. package/dist/components/auth/delete-user/delete-user.d.ts +0 -9
  280. package/dist/components/auth/delete-user/delete-user.js +0 -95
@@ -1,4 +1,4 @@
1
- import { AdditionalFieldProps } from '../../lib/auth/auth-plugin';
2
- export type { AdditionalFieldProps } from '../../lib/auth/auth-plugin';
1
+ import type { AdditionalFieldProps } from "../../lib/auth/auth-plugin";
2
+ export type { AdditionalFieldProps } from "../../lib/auth/auth-plugin";
3
3
  /** Renders a single additional user field via HeroUI v3 components. */
4
4
  export declare function AdditionalField({ name, field, isPending, variant }: AdditionalFieldProps): import("react/jsx-runtime").JSX.Element;
@@ -1,270 +1,137 @@
1
- import { resolveInputType as e } from "@better-auth-ui/core";
2
- import { useAuth as t } from "@better-auth-ui/react";
3
- import { Check as n, Copy as r } from "@gravity-ui/icons";
4
- import { Button as i, Calendar as a, Checkbox as o, ComboBox as s, DateField as c, DatePicker as l, FieldError as u, Input as d, InputGroup as f, Label as p, ListBox as m, NumberField as h, Select as g, Slider as _, Switch as v, TextArea as y, TextField as b, TimeField as x, toast as S } from "@heroui/react";
5
- import { fromDate as C, getLocalTimeZone as w, parseDate as T, parseDateTime as E, toCalendarDate as D, toCalendarDateTime as O } from "@internationalized/date";
6
- import { useRef as k, useState as A } from "react";
7
- import { Fragment as j, jsx as M, jsxs as N } from "react/jsx-runtime";
8
- //#region src/components/auth/additional-field.tsx
9
- function P(e) {
10
- if (e instanceof Date) return D(C(e, w()));
11
- if (typeof e == "string") try {
12
- return T(e.slice(0, 10));
13
- } catch {
14
- return;
15
- }
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { resolveInputType } from "@better-auth-ui/core";
3
+ import { useAuth } from "@better-auth-ui/react";
4
+ import { Check, Copy } from "@gravity-ui/icons";
5
+ import { Button, Calendar, Checkbox, ComboBox, DateField, DatePicker, FieldError, Input, InputGroup, Label, ListBox, NumberField, Select, Slider, Switch, TextArea, TextField, TimeField, toast } from "@heroui/react";
6
+ import { fromDate, getLocalTimeZone, parseDate, parseDateTime, toCalendarDate, toCalendarDateTime } from "@internationalized/date";
7
+ import { useRef, useState } from "react";
8
+ /** Convert a `defaultValue` into a `CalendarDate` for HeroUI date inputs. */
9
+ function toDateValue(value) {
10
+ if (value instanceof Date) {
11
+ return toCalendarDate(fromDate(value, getLocalTimeZone()));
12
+ }
13
+ if (typeof value === "string") {
14
+ try {
15
+ return parseDate(value.slice(0, 10));
16
+ }
17
+ catch {
18
+ return undefined;
19
+ }
20
+ }
21
+ return undefined;
16
22
  }
17
- function F(e) {
18
- if (e instanceof Date) return O(C(e, w()));
19
- if (typeof e == "string") try {
20
- return E(e.replace(/(Z|[+-]\d{2}:?\d{2})$/, ""));
21
- } catch {
22
- return;
23
- }
23
+ /** Convert a `defaultValue` into a `CalendarDateTime` for datetime inputs. */
24
+ function toDateTimeValue(value) {
25
+ if (value instanceof Date) {
26
+ return toCalendarDateTime(fromDate(value, getLocalTimeZone()));
27
+ }
28
+ if (typeof value === "string") {
29
+ try {
30
+ // Strip trailing `Z` or timezone offset for `parseDateTime`.
31
+ return parseDateTime(value.replace(/(Z|[+-]\d{2}:?\d{2})$/, ""));
32
+ }
33
+ catch {
34
+ return undefined;
35
+ }
36
+ }
37
+ return undefined;
24
38
  }
25
- function I({ getValue: e, isDisabled: a }) {
26
- let { localization: o } = t(), [s, c] = A(!1);
27
- async function l() {
28
- let t = e();
29
- if (t) try {
30
- await navigator.clipboard.writeText(t), c(!0), setTimeout(() => c(!1), 1500);
31
- } catch (e) {
32
- S.danger(e instanceof Error ? e.message : String(e));
33
- }
34
- }
35
- return /* @__PURE__ */ M(i, {
36
- isIconOnly: !0,
37
- "aria-label": o.settings.copyToClipboard,
38
- size: "sm",
39
- variant: "ghost",
40
- isDisabled: a,
41
- onPress: l,
42
- children: M(s ? n : r, { className: "size-4" })
43
- });
39
+ /**
40
+ * Icon-only copy button used as an `InputGroup.Suffix`. `getValue` is invoked
41
+ * lazily on click so the button copies the input's *live* value rather than a
42
+ * stale snapshot — important when paired with editable inputs.
43
+ */
44
+ function CopyButton({ getValue, isDisabled }) {
45
+ const { localization } = useAuth();
46
+ const [copied, setCopied] = useState(false);
47
+ async function handleCopy() {
48
+ const value = getValue();
49
+ if (!value)
50
+ return;
51
+ try {
52
+ await navigator.clipboard.writeText(value);
53
+ setCopied(true);
54
+ setTimeout(() => setCopied(false), 1500);
55
+ }
56
+ catch (error) {
57
+ toast.danger(error instanceof Error ? error.message : String(error));
58
+ }
59
+ }
60
+ return (_jsx(Button, { isIconOnly: true, "aria-label": localization.settings.copyToClipboard, size: "sm", variant: "ghost", isDisabled: isDisabled, onPress: handleCopy, children: copied ? _jsx(Check, { className: "size-4" }) : _jsx(Copy, { className: "size-4" }) }));
44
61
  }
45
- function L({ name: n, field: r, isPending: i, variant: S }) {
46
- let { localization: C } = t(), w = e(r), T = S === "transparent" ? "primary" : "secondary", E = k(null);
47
- if (r.render) return /* @__PURE__ */ M(j, { children: r.render({
48
- name: n,
49
- field: r,
50
- isPending: i,
51
- variant: S
52
- }) });
53
- if (w === "hidden") return /* @__PURE__ */ M("input", {
54
- type: "hidden",
55
- name: n,
56
- value: r.defaultValue == null ? "" : r.defaultValue instanceof Date ? r.defaultValue.toISOString() : String(r.defaultValue)
57
- });
58
- if (w === "textarea") return /* @__PURE__ */ N(b, {
59
- name: n,
60
- defaultValue: r.defaultValue == null ? void 0 : String(r.defaultValue),
61
- isDisabled: i,
62
- isReadOnly: r.readOnly,
63
- children: [
64
- /* @__PURE__ */ M(p, { children: r.label }),
65
- /* @__PURE__ */ M(y, {
66
- placeholder: r.placeholder,
67
- required: r.required,
68
- variant: T
69
- }),
70
- /* @__PURE__ */ M(u, {})
71
- ]
72
- });
73
- if (w === "number") {
74
- let e = r.formatOptions?.maximumFractionDigits;
75
- return /* @__PURE__ */ N(h, {
76
- name: n,
77
- defaultValue: typeof r.defaultValue == "number" ? r.defaultValue : r.defaultValue != null && r.defaultValue !== "" ? Number(r.defaultValue) : void 0,
78
- minValue: r.min,
79
- maxValue: r.max,
80
- step: r.step ?? (e ? 1 / 10 ** e : 1),
81
- formatOptions: r.formatOptions,
82
- isDisabled: i,
83
- isReadOnly: r.readOnly,
84
- variant: T,
85
- children: [
86
- /* @__PURE__ */ M(p, { children: r.label }),
87
- /* @__PURE__ */ N(h.Group, { children: [
88
- /* @__PURE__ */ M(h.DecrementButton, {}),
89
- /* @__PURE__ */ M(h.Input, {
90
- placeholder: r.placeholder,
91
- required: r.required
92
- }),
93
- /* @__PURE__ */ M(h.IncrementButton, {})
94
- ] }),
95
- /* @__PURE__ */ M(u, {})
96
- ]
97
- });
98
- }
99
- if (w === "slider") {
100
- let e = r.formatOptions?.maximumFractionDigits;
101
- return /* @__PURE__ */ N(_, {
102
- defaultValue: typeof r.defaultValue == "number" ? r.defaultValue : r.defaultValue == null ? void 0 : Number(r.defaultValue),
103
- minValue: r.min ?? 0,
104
- maxValue: r.max ?? 100,
105
- step: r.step ?? (e ? 1 / 10 ** e : 1),
106
- formatOptions: r.formatOptions,
107
- isDisabled: i || r.readOnly,
108
- className: "flex flex-col gap-2",
109
- children: [/* @__PURE__ */ N("div", {
110
- className: "flex items-center justify-between gap-2",
111
- children: [/* @__PURE__ */ M(p, { children: r.label }), /* @__PURE__ */ M(_.Output, { className: "text-sm text-muted" })]
112
- }), /* @__PURE__ */ N(_.Track, { children: [/* @__PURE__ */ M(_.Fill, {}), /* @__PURE__ */ M(_.Thumb, { name: n })] })]
113
- });
114
- }
115
- if (w === "switch") return /* @__PURE__ */ N(v, {
116
- name: n,
117
- defaultSelected: r.defaultValue === !0 || r.defaultValue === "true",
118
- isDisabled: i,
119
- isReadOnly: r.readOnly,
120
- children: [/* @__PURE__ */ M(v.Control, { children: /* @__PURE__ */ M(v.Thumb, {}) }), /* @__PURE__ */ M(p, { children: r.label })]
121
- });
122
- if (w === "checkbox") return /* @__PURE__ */ N(o, {
123
- name: n,
124
- defaultSelected: r.defaultValue === !0 || r.defaultValue === "true",
125
- isDisabled: i,
126
- isReadOnly: r.readOnly,
127
- isRequired: r.required,
128
- variant: T,
129
- children: [/* @__PURE__ */ M(o.Control, { children: /* @__PURE__ */ M(o.Indicator, {}) }), /* @__PURE__ */ M(o.Content, { children: /* @__PURE__ */ M(p, { children: r.label }) })]
130
- });
131
- if (w === "select") return /* @__PURE__ */ N(g, {
132
- className: "[&[data-required=true]>.label]:after:content-none",
133
- name: n,
134
- defaultValue: r.defaultValue == null ? void 0 : String(r.defaultValue),
135
- placeholder: r.placeholder,
136
- isDisabled: i || r.readOnly,
137
- isRequired: r.required,
138
- variant: T,
139
- fullWidth: !0,
140
- children: [
141
- /* @__PURE__ */ M(p, { children: r.label }),
142
- /* @__PURE__ */ N(g.Trigger, { children: [/* @__PURE__ */ M(g.Value, {}), /* @__PURE__ */ M(g.Indicator, {})] }),
143
- /* @__PURE__ */ M(g.Popover, { children: /* @__PURE__ */ M(m, { children: r.options?.map((e) => /* @__PURE__ */ N(m.Item, {
144
- id: e.value,
145
- textValue: typeof e.label == "string" ? e.label : e.value,
146
- children: [e.label, /* @__PURE__ */ M(m.ItemIndicator, {})]
147
- }, e.value)) }) }),
148
- /* @__PURE__ */ M(u, {})
149
- ]
150
- });
151
- if (w === "combobox") return /* @__PURE__ */ N(s, {
152
- className: "[&[data-required=true]>.label]:after:content-none",
153
- name: n,
154
- defaultSelectedKey: r.defaultValue == null ? void 0 : String(r.defaultValue),
155
- isDisabled: i,
156
- isReadOnly: r.readOnly,
157
- isRequired: r.required,
158
- variant: T,
159
- fullWidth: !0,
160
- children: [
161
- /* @__PURE__ */ M(p, { children: r.label }),
162
- /* @__PURE__ */ N(s.InputGroup, { children: [/* @__PURE__ */ M(d, { placeholder: r.placeholder }), /* @__PURE__ */ M(s.Trigger, {})] }),
163
- /* @__PURE__ */ M(s.Popover, { children: /* @__PURE__ */ M(m, { children: r.options?.map((e) => /* @__PURE__ */ N(m.Item, {
164
- id: e.value,
165
- textValue: typeof e.label == "string" ? e.label : e.value,
166
- children: [e.label, /* @__PURE__ */ M(m.ItemIndicator, {})]
167
- }, e.value)) }) }),
168
- /* @__PURE__ */ M(u, {})
169
- ]
170
- });
171
- if (w === "date" || w === "datetime") {
172
- let e = w === "datetime";
173
- return /* @__PURE__ */ M(l, {
174
- className: "w-full [&[data-required=true]>.label]:after:content-none",
175
- name: n,
176
- defaultValue: e ? F(r.defaultValue) : P(r.defaultValue),
177
- granularity: e ? "minute" : "day",
178
- isDisabled: i,
179
- isReadOnly: r.readOnly,
180
- isRequired: r.required,
181
- children: ({ state: t }) => /* @__PURE__ */ N(j, { children: [
182
- /* @__PURE__ */ M(p, { children: r.label }),
183
- /* @__PURE__ */ N(c.Group, {
184
- variant: T,
185
- fullWidth: !0,
186
- children: [/* @__PURE__ */ M(c.Input, { children: (e) => /* @__PURE__ */ M(c.Segment, { segment: e }) }), /* @__PURE__ */ M(c.Suffix, { children: /* @__PURE__ */ M(l.Trigger, { children: /* @__PURE__ */ M(l.TriggerIndicator, {}) }) })]
187
- }),
188
- /* @__PURE__ */ M(u, {}),
189
- /* @__PURE__ */ N(l.Popover, {
190
- className: "flex flex-col gap-3",
191
- children: [/* @__PURE__ */ N(a, {
192
- "aria-label": typeof r.label == "string" ? r.label : n,
193
- children: [
194
- /* @__PURE__ */ N(a.Header, { children: [
195
- /* @__PURE__ */ N(a.YearPickerTrigger, { children: [/* @__PURE__ */ M(a.YearPickerTriggerHeading, {}), /* @__PURE__ */ M(a.YearPickerTriggerIndicator, {})] }),
196
- /* @__PURE__ */ M(a.NavButton, { slot: "previous" }),
197
- /* @__PURE__ */ M(a.NavButton, { slot: "next" })
198
- ] }),
199
- /* @__PURE__ */ N(a.Grid, { children: [/* @__PURE__ */ M(a.GridHeader, { children: (e) => /* @__PURE__ */ M(a.HeaderCell, { children: e }) }), /* @__PURE__ */ M(a.GridBody, { children: (e) => /* @__PURE__ */ M(a.Cell, { date: e }) })] }),
200
- /* @__PURE__ */ M(a.YearPickerGrid, { children: /* @__PURE__ */ M(a.YearPickerGridBody, { children: ({ year: e }) => /* @__PURE__ */ M(a.YearPickerCell, { year: e }) }) })
201
- ]
202
- }), e && /* @__PURE__ */ N("div", {
203
- className: "flex items-center justify-between",
204
- children: [/* @__PURE__ */ M(p, { children: C.settings.time }), /* @__PURE__ */ M(x, {
205
- "aria-label": C.settings.time,
206
- granularity: "minute",
207
- value: t.timeValue,
208
- onChange: (e) => t.setTimeValue(e),
209
- children: /* @__PURE__ */ M(x.Group, {
210
- variant: "secondary",
211
- children: /* @__PURE__ */ M(x.Input, { children: (e) => /* @__PURE__ */ M(x.Segment, { segment: e }) })
212
- })
213
- })]
214
- })]
215
- })
216
- ] })
217
- });
218
- }
219
- let D = r.prefix != null, O = r.suffix != null || r.copyable, A = r.type === "number", L = r.formatOptions?.maximumFractionDigits, R = A ? "number" : void 0, z = A ? L ? "decimal" : "numeric" : void 0, B = L ? 1 / 10 ** L : void 0;
220
- return D || O ? /* @__PURE__ */ N(b, {
221
- name: n,
222
- defaultValue: r.defaultValue == null ? void 0 : String(r.defaultValue),
223
- isDisabled: i,
224
- isReadOnly: r.readOnly,
225
- children: [
226
- /* @__PURE__ */ M(p, { children: r.label }),
227
- /* @__PURE__ */ N(f, {
228
- variant: T,
229
- children: [
230
- D && /* @__PURE__ */ M(f.Prefix, { children: r.prefix }),
231
- /* @__PURE__ */ M(f.Input, {
232
- ref: E,
233
- placeholder: r.placeholder,
234
- required: r.required,
235
- type: R,
236
- inputMode: z,
237
- step: B
238
- }),
239
- r.copyable ? /* @__PURE__ */ M(f.Suffix, {
240
- className: "px-0",
241
- children: /* @__PURE__ */ M(I, {
242
- getValue: () => E.current?.value,
243
- isDisabled: i
244
- })
245
- }) : r.suffix != null && /* @__PURE__ */ M(f.Suffix, { children: r.suffix })
246
- ]
247
- }),
248
- /* @__PURE__ */ M(u, {})
249
- ]
250
- }) : /* @__PURE__ */ N(b, {
251
- name: n,
252
- defaultValue: r.defaultValue == null ? void 0 : String(r.defaultValue),
253
- isDisabled: i,
254
- isReadOnly: r.readOnly,
255
- children: [
256
- /* @__PURE__ */ M(p, { children: r.label }),
257
- /* @__PURE__ */ M(d, {
258
- placeholder: r.placeholder,
259
- required: r.required,
260
- variant: T,
261
- type: R,
262
- inputMode: z,
263
- step: B
264
- }),
265
- /* @__PURE__ */ M(u, {})
266
- ]
267
- });
62
+ /** Renders a single additional user field via HeroUI v3 components. */
63
+ export function AdditionalField({ name, field, isPending, variant }) {
64
+ const { localization } = useAuth();
65
+ const inputType = resolveInputType(field);
66
+ const inputVariant = variant === "transparent" ? "primary" : "secondary";
67
+ // Used by `inputType: "input"` with `copyable: true` so the copy button
68
+ // reads the input's *live* value rather than a stale `defaultValue`.
69
+ const inputRef = useRef(null);
70
+ if (field.render) {
71
+ return _jsx(_Fragment, { children: field.render({ name, field, isPending, variant }) });
72
+ }
73
+ if (inputType === "hidden") {
74
+ return (_jsx("input", { type: "hidden", name: name, value: field.defaultValue == null
75
+ ? ""
76
+ : field.defaultValue instanceof Date
77
+ ? field.defaultValue.toISOString()
78
+ : String(field.defaultValue) }));
79
+ }
80
+ if (inputType === "textarea") {
81
+ return (_jsxs(TextField, { name: name, defaultValue: field.defaultValue == null ? undefined : String(field.defaultValue), isDisabled: isPending, isReadOnly: field.readOnly, children: [_jsx(Label, { children: field.label }), _jsx(TextArea, { placeholder: field.placeholder, required: field.required, variant: inputVariant }), _jsx(FieldError, {})] }));
82
+ }
83
+ if (inputType === "number") {
84
+ const maxFractionDigits = field.formatOptions?.maximumFractionDigits;
85
+ return (_jsxs(NumberField, { name: name, defaultValue: typeof field.defaultValue === "number"
86
+ ? field.defaultValue
87
+ : field.defaultValue != null && field.defaultValue !== ""
88
+ ? Number(field.defaultValue)
89
+ : undefined, minValue: field.min, maxValue: field.max, step: field.step ?? (maxFractionDigits ? 1 / 10 ** maxFractionDigits : 1), formatOptions: field.formatOptions, isDisabled: isPending, isReadOnly: field.readOnly, variant: inputVariant, children: [_jsx(Label, { children: field.label }), _jsxs(NumberField.Group, { children: [_jsx(NumberField.DecrementButton, {}), _jsx(NumberField.Input, { placeholder: field.placeholder, required: field.required }), _jsx(NumberField.IncrementButton, {})] }), _jsx(FieldError, {})] }));
90
+ }
91
+ if (inputType === "slider") {
92
+ const maxFractionDigits = field.formatOptions?.maximumFractionDigits;
93
+ return (_jsxs(Slider, { defaultValue: typeof field.defaultValue === "number"
94
+ ? field.defaultValue
95
+ : field.defaultValue != null
96
+ ? Number(field.defaultValue)
97
+ : undefined, minValue: field.min ?? 0, maxValue: field.max ?? 100, step: field.step ?? (maxFractionDigits ? 1 / 10 ** maxFractionDigits : 1), formatOptions: field.formatOptions, isDisabled: isPending || field.readOnly, className: "flex flex-col gap-2", children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx(Label, { children: field.label }), _jsx(Slider.Output, { className: "text-sm text-muted" })] }), _jsxs(Slider.Track, { children: [_jsx(Slider.Fill, {}), _jsx(Slider.Thumb, { name: name })] })] }));
98
+ }
99
+ if (inputType === "switch") {
100
+ return (_jsxs(Switch, { name: name, defaultSelected: field.defaultValue === true || field.defaultValue === "true", isDisabled: isPending, isReadOnly: field.readOnly, children: [_jsx(Switch.Control, { children: _jsx(Switch.Thumb, {}) }), _jsx(Label, { children: field.label })] }));
101
+ }
102
+ if (inputType === "checkbox") {
103
+ return (_jsxs(Checkbox, { name: name, defaultSelected: field.defaultValue === true || field.defaultValue === "true", isDisabled: isPending, isReadOnly: field.readOnly, isRequired: field.required, variant: inputVariant, children: [_jsx(Checkbox.Control, { children: _jsx(Checkbox.Indicator, {}) }), _jsx(Checkbox.Content, { children: _jsx(Label, { children: field.label }) })] }));
104
+ }
105
+ if (inputType === "select") {
106
+ return (_jsxs(Select, { className: "[&[data-required=true]>.label]:after:content-none", name: name, defaultValue: field.defaultValue != null ? String(field.defaultValue) : undefined, placeholder: field.placeholder, isDisabled: isPending || field.readOnly, isRequired: field.required, variant: inputVariant, fullWidth: true, children: [_jsx(Label, { children: field.label }), _jsxs(Select.Trigger, { children: [_jsx(Select.Value, {}), _jsx(Select.Indicator, {})] }), _jsx(Select.Popover, { children: _jsx(ListBox, { children: field.options?.map((option) => (_jsxs(ListBox.Item, { id: option.value, textValue: typeof option.label === "string" ? option.label : option.value, children: [option.label, _jsx(ListBox.ItemIndicator, {})] }, option.value))) }) }), _jsx(FieldError, {})] }));
107
+ }
108
+ if (inputType === "combobox") {
109
+ return (_jsxs(ComboBox, { className: "[&[data-required=true]>.label]:after:content-none", name: name, defaultSelectedKey: field.defaultValue != null ? String(field.defaultValue) : undefined, isDisabled: isPending, isReadOnly: field.readOnly, isRequired: field.required, variant: inputVariant, fullWidth: true, children: [_jsx(Label, { children: field.label }), _jsxs(ComboBox.InputGroup, { children: [_jsx(Input, { placeholder: field.placeholder }), _jsx(ComboBox.Trigger, {})] }), _jsx(ComboBox.Popover, { children: _jsx(ListBox, { children: field.options?.map((option) => (_jsxs(ListBox.Item, { id: option.value, textValue: typeof option.label === "string" ? option.label : option.value, children: [option.label, _jsx(ListBox.ItemIndicator, {})] }, option.value))) }) }), _jsx(FieldError, {})] }));
110
+ }
111
+ if (inputType === "date" || inputType === "datetime") {
112
+ const isDateTime = inputType === "datetime";
113
+ const defaultValue = isDateTime
114
+ ? toDateTimeValue(field.defaultValue)
115
+ : toDateValue(field.defaultValue);
116
+ return (_jsx(DatePicker, { className: "w-full [&[data-required=true]>.label]:after:content-none", name: name, defaultValue: defaultValue, granularity: isDateTime ? "minute" : "day", isDisabled: isPending, isReadOnly: field.readOnly, isRequired: field.required, children: ({ state }) => (_jsxs(_Fragment, { children: [_jsx(Label, { children: field.label }), _jsxs(DateField.Group, { variant: inputVariant, fullWidth: true, children: [_jsx(DateField.Input, { children: (segment) => _jsx(DateField.Segment, { segment: segment }) }), _jsx(DateField.Suffix, { children: _jsx(DatePicker.Trigger, { children: _jsx(DatePicker.TriggerIndicator, {}) }) })] }), _jsx(FieldError, {}), _jsxs(DatePicker.Popover, { className: "flex flex-col gap-3", children: [_jsxs(Calendar, { "aria-label": typeof field.label === "string" ? field.label : name, children: [_jsxs(Calendar.Header, { children: [_jsxs(Calendar.YearPickerTrigger, { children: [_jsx(Calendar.YearPickerTriggerHeading, {}), _jsx(Calendar.YearPickerTriggerIndicator, {})] }), _jsx(Calendar.NavButton, { slot: "previous" }), _jsx(Calendar.NavButton, { slot: "next" })] }), _jsxs(Calendar.Grid, { children: [_jsx(Calendar.GridHeader, { children: (day) => _jsx(Calendar.HeaderCell, { children: day }) }), _jsx(Calendar.GridBody, { children: (date) => _jsx(Calendar.Cell, { date: date }) })] }), _jsx(Calendar.YearPickerGrid, { children: _jsx(Calendar.YearPickerGridBody, { children: ({ year }) => _jsx(Calendar.YearPickerCell, { year: year }) }) })] }), isDateTime && (_jsxs("div", { className: "flex items-center justify-between", children: [_jsx(Label, { children: localization.settings.time }), _jsx(TimeField, { "aria-label": localization.settings.time, granularity: "minute", value: state.timeValue, onChange: (v) => state.setTimeValue(v), children: _jsx(TimeField.Group, { variant: "secondary", children: _jsx(TimeField.Input, { children: (segment) => _jsx(TimeField.Segment, { segment: segment }) }) }) })] }))] })] })) }));
117
+ }
118
+ // inputType === "input"
119
+ const hasPrefix = field.prefix != null;
120
+ const hasSuffix = field.suffix != null || field.copyable;
121
+ // When `inputType: "input"` is paired with `type: "number"`, restrict the
122
+ // native input to numbers. `formatOptions.maximumFractionDigits` enables
123
+ // fractional input via `step`.
124
+ const isNumeric = field.type === "number";
125
+ const maxFractionDigits = field.formatOptions?.maximumFractionDigits;
126
+ const nativeInputType = isNumeric ? "number" : undefined;
127
+ const nativeInputMode = isNumeric
128
+ ? maxFractionDigits
129
+ ? "decimal"
130
+ : "numeric"
131
+ : undefined;
132
+ const nativeStep = maxFractionDigits ? 1 / 10 ** maxFractionDigits : undefined;
133
+ if (hasPrefix || hasSuffix) {
134
+ return (_jsxs(TextField, { name: name, defaultValue: field.defaultValue == null ? undefined : String(field.defaultValue), isDisabled: isPending, isReadOnly: field.readOnly, children: [_jsx(Label, { children: field.label }), _jsxs(InputGroup, { variant: inputVariant, children: [hasPrefix && _jsx(InputGroup.Prefix, { children: field.prefix }), _jsx(InputGroup.Input, { ref: inputRef, placeholder: field.placeholder, required: field.required, type: nativeInputType, inputMode: nativeInputMode, step: nativeStep }), field.copyable ? (_jsx(InputGroup.Suffix, { className: "px-0", children: _jsx(CopyButton, { getValue: () => inputRef.current?.value, isDisabled: isPending }) })) : (field.suffix != null && (_jsx(InputGroup.Suffix, { children: field.suffix })))] }), _jsx(FieldError, {})] }));
135
+ }
136
+ return (_jsxs(TextField, { name: name, defaultValue: field.defaultValue == null ? undefined : String(field.defaultValue), isDisabled: isPending, isReadOnly: field.readOnly, children: [_jsx(Label, { children: field.label }), _jsx(Input, { placeholder: field.placeholder, required: field.required, variant: inputVariant, type: nativeInputType, inputMode: nativeInputMode, step: nativeStep }), _jsx(FieldError, {})] }));
268
137
  }
269
- //#endregion
270
- export { L as AdditionalField };
@@ -1,21 +1,5 @@
1
- import { Skeleton as e } from "@heroui/react";
2
- import { jsx as t, jsxs as n } from "react/jsx-runtime";
3
- //#region src/components/auth/api-key/api-key-skeleton.tsx
4
- function r() {
5
- return /* @__PURE__ */ t("div", {
6
- className: "flex items-center justify-between",
7
- children: /* @__PURE__ */ n("div", {
8
- className: "flex items-center gap-3",
9
- children: [/* @__PURE__ */ t(e, { className: "size-10 rounded-xl" }), /* @__PURE__ */ n("div", {
10
- className: "flex flex-col gap-1",
11
- children: [
12
- /* @__PURE__ */ t(e, { className: "h-4 w-28 rounded-lg" }),
13
- /* @__PURE__ */ t(e, { className: "h-3 w-36 rounded-lg" }),
14
- /* @__PURE__ */ t(e, { className: "h-3 w-32 rounded-lg" })
15
- ]
16
- })]
17
- })
18
- });
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Skeleton } from "@heroui/react";
3
+ export function ApiKeySkeleton() {
4
+ return (_jsx("div", { className: "flex items-center justify-between", children: _jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Skeleton, { className: "size-10 rounded-xl" }), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx(Skeleton, { className: "h-4 w-28 rounded-lg" }), _jsx(Skeleton, { className: "h-3 w-36 rounded-lg" }), _jsx(Skeleton, { className: "h-3 w-32 rounded-lg" })] })] }) }));
19
5
  }
20
- //#endregion
21
- export { r as ApiKeySkeleton };
@@ -1,5 +1,9 @@
1
- import { ListedApiKey } from '@better-auth-ui/react';
1
+ import { type ListedApiKey } from "@better-auth-ui/react";
2
2
  export type ApiKeyProps = {
3
3
  apiKey: ListedApiKey;
4
+ /** Hide the row's delete button (e.g., when caller lacks `apiKey:delete`). */
5
+ hideDelete?: boolean;
6
+ /** Scope the delete payload to an organization (sets `configId`). */
7
+ organizationId?: string;
4
8
  };
5
- export declare function ApiKey({ apiKey }: ApiKeyProps): import("react/jsx-runtime").JSX.Element;
9
+ export declare function ApiKey({ apiKey, hideDelete, organizationId }: ApiKeyProps): import("react/jsx-runtime").JSX.Element;
@@ -1,55 +1,17 @@
1
- import { apiKeyPlugin as e } from "../../../lib/auth/api-key-plugin.js";
2
- import { DeleteApiKeyDialog as t } from "./delete-api-key-dialog.js";
3
- import { useAuth as n, useAuthPlugin as r } from "@better-auth-ui/react";
4
- import { Key as i, Xmark as a } from "@gravity-ui/icons";
5
- import { Button as o } from "@heroui/react";
6
- import { useState as s } from "react";
7
- import { jsx as c, jsxs as l } from "react/jsx-runtime";
8
- //#region src/components/auth/api-key/api-key.tsx
9
- function u({ apiKey: u }) {
10
- let { localization: d } = n(), { localization: f } = r(e), [p, m] = s(!1), h = `${u.start}${"*".repeat(16)}`;
11
- return /* @__PURE__ */ l("div", {
12
- className: "flex items-center gap-3",
13
- children: [
14
- /* @__PURE__ */ c("div", {
15
- className: "flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-secondary",
16
- children: /* @__PURE__ */ c(i, { className: "size-4.5" })
17
- }),
18
- /* @__PURE__ */ l("div", {
19
- className: "flex flex-col min-w-0",
20
- children: [
21
- /* @__PURE__ */ c("span", {
22
- className: "text-sm font-medium leading-tight truncate",
23
- children: u.name || f.apiKey
24
- }),
25
- /* @__PURE__ */ c("span", {
26
- className: "text-xs text-muted font-mono truncate",
27
- children: h
28
- }),
29
- /* @__PURE__ */ c("span", {
30
- className: "text-xs text-muted",
31
- children: new Date(u.createdAt).toLocaleString(void 0, {
32
- dateStyle: "medium",
33
- timeStyle: "short"
34
- })
35
- })
36
- ]
37
- }),
38
- /* @__PURE__ */ l(o, {
39
- className: "ml-auto shrink-0",
40
- variant: "outline",
41
- size: "sm",
42
- onPress: () => m(!0),
43
- "aria-label": f.deleteApiKey,
44
- children: [/* @__PURE__ */ c(a, {}), d.settings.delete]
45
- }),
46
- /* @__PURE__ */ c(t, {
47
- isOpen: p,
48
- onOpenChange: m,
49
- apiKey: u
50
- })
51
- ]
52
- });
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useAuth, useAuthPlugin } from "@better-auth-ui/react";
3
+ import { Key, Xmark } from "@gravity-ui/icons";
4
+ import { Button } from "@heroui/react";
5
+ import { useState } from "react";
6
+ import { apiKeyPlugin } from "../../../lib/auth/api-key-plugin";
7
+ import { DeleteApiKeyDialog } from "./delete-api-key-dialog";
8
+ export function ApiKey({ apiKey, hideDelete, organizationId }) {
9
+ const { localization } = useAuth();
10
+ const { localization: apiKeyLocalization } = useAuthPlugin(apiKeyPlugin);
11
+ const [deleteOpen, setDeleteOpen] = useState(false);
12
+ const preview = `${apiKey.start}${"*".repeat(16)}`;
13
+ return (_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("div", { className: "flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-secondary", children: _jsx(Key, { className: "size-4.5" }) }), _jsxs("div", { className: "flex flex-col min-w-0", children: [_jsx("span", { className: "text-sm font-medium leading-tight truncate", children: apiKey.name || apiKeyLocalization.apiKey }), _jsx("span", { className: "text-xs text-muted font-mono truncate", children: preview }), _jsx("span", { className: "text-xs text-muted", children: new Date(apiKey.createdAt).toLocaleString(undefined, {
14
+ dateStyle: "medium",
15
+ timeStyle: "short"
16
+ }) })] }), !hideDelete && (_jsxs(_Fragment, { children: [_jsxs(Button, { className: "ml-auto shrink-0", variant: "outline", size: "sm", onPress: () => setDeleteOpen(true), "aria-label": apiKeyLocalization.deleteApiKey, children: [_jsx(Xmark, {}), localization.settings.delete] }), _jsx(DeleteApiKeyDialog, { isOpen: deleteOpen, onOpenChange: setDeleteOpen, apiKey: apiKey, organizationId: organizationId })] }))] }));
53
17
  }
54
- //#endregion
55
- export { u as ApiKey };
@@ -1,4 +1,6 @@
1
1
  export type ApiKeysEmptyProps = {
2
2
  onCreatePress: () => void;
3
+ /** Hide the empty-state "Create API key" button. */
4
+ hideCreate?: boolean;
3
5
  };
4
- export declare function ApiKeysEmpty({ onCreatePress }: ApiKeysEmptyProps): import("react/jsx-runtime").JSX.Element;
6
+ export declare function ApiKeysEmpty({ onCreatePress, hideCreate }: ApiKeysEmptyProps): import("react/jsx-runtime").JSX.Element;
@@ -1,35 +1,9 @@
1
- import { apiKeyPlugin as e } from "../../../lib/auth/api-key-plugin.js";
2
- import { useAuthPlugin as t } from "@better-auth-ui/react";
3
- import { Key as n } from "@gravity-ui/icons";
4
- import { Button as r } from "@heroui/react";
5
- import { jsx as i, jsxs as a } from "react/jsx-runtime";
6
- //#region src/components/auth/api-key/api-keys-empty.tsx
7
- function o({ onCreatePress: o }) {
8
- let { localization: s } = t(e);
9
- return /* @__PURE__ */ a("div", {
10
- className: "flex flex-col items-center justify-center gap-4",
11
- children: [
12
- /* @__PURE__ */ i("div", {
13
- className: "flex size-10 items-center justify-center rounded-xl bg-surface-secondary",
14
- children: /* @__PURE__ */ i(n, { className: "size-4.5" })
15
- }),
16
- /* @__PURE__ */ a("div", {
17
- className: "flex flex-col items-center justify-center gap-1 text-center",
18
- children: [/* @__PURE__ */ i("p", {
19
- className: "text-sm font-semibold",
20
- children: s.noApiKeys
21
- }), /* @__PURE__ */ i("p", {
22
- className: "text-muted text-xs",
23
- children: s.apiKeysDescription
24
- })]
25
- }),
26
- /* @__PURE__ */ i(r, {
27
- size: "sm",
28
- onPress: o,
29
- children: s.createApiKey
30
- })
31
- ]
32
- });
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useAuthPlugin } from "@better-auth-ui/react";
3
+ import { Key } from "@gravity-ui/icons";
4
+ import { Button } from "@heroui/react";
5
+ import { apiKeyPlugin } from "../../../lib/auth/api-key-plugin";
6
+ export function ApiKeysEmpty({ onCreatePress, hideCreate }) {
7
+ const { localization: apiKeyLocalization } = useAuthPlugin(apiKeyPlugin);
8
+ return (_jsxs("div", { className: "flex flex-col items-center justify-center gap-4", children: [_jsx("div", { className: "flex size-10 items-center justify-center rounded-xl bg-surface-secondary", children: _jsx(Key, { className: "size-4.5" }) }), _jsxs("div", { className: "flex flex-col items-center justify-center gap-1 text-center", children: [_jsx("p", { className: "text-sm font-semibold", children: apiKeyLocalization.noApiKeys }), _jsx("p", { className: "text-muted text-xs", children: apiKeyLocalization.apiKeysDescription })] }), !hideCreate && (_jsx(Button, { size: "sm", onPress: onCreatePress, children: apiKeyLocalization.createApiKey }))] }));
33
9
  }
34
- //#endregion
35
- export { o as ApiKeysEmpty };
@@ -1,6 +1,14 @@
1
- import { CardProps } from '@heroui/react';
1
+ import { type CardProps } from "@heroui/react";
2
2
  export type ApiKeysProps = {
3
3
  className?: string;
4
4
  variant?: CardProps["variant"];
5
+ /** Scope the list and create payload to an organization. */
6
+ organizationId?: string;
7
+ /** Force the loading skeleton and disable the list query. */
8
+ isPending?: boolean;
9
+ /** Hide the "Create API key" button (header + empty state). */
10
+ hideCreate?: boolean;
11
+ /** Hide the per-row delete button on listed keys. */
12
+ hideDelete?: boolean;
5
13
  };
6
- export declare function ApiKeys({ className, variant }: ApiKeysProps): import("react/jsx-runtime").JSX.Element;
14
+ export declare function ApiKeys({ className, variant, organizationId, isPending: isPendingProp, hideCreate, hideDelete }: ApiKeysProps): import("react/jsx-runtime").JSX.Element;